connected up recording

This commit is contained in:
Dave Griffiths 2015-07-21 14:58:13 +01:00
parent 20b9b3d112
commit 8302566719
17 changed files with 300 additions and 31 deletions

View File

@ -836,6 +836,13 @@
</property>
</widget>
</item>
<item>
<widget class="QDial" name="dialVolume">
<property name="value">
<number>99</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -850,9 +857,12 @@
</spacer>
</item>
<item>
<widget class="QDial" name="dialVolume">
<property name="value">
<number>99</number>
<widget class="QLabel" name="label_13">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../qt/samplebrain.qrc">:/images/images/at.png</pixmap>
</property>
</widget>
</item>
@ -1427,13 +1437,13 @@
</hints>
</connection>
<connection>
<sender>pushButtonStop</sender>
<sender>pushButtonStopRecord</sender>
<signal>released()</signal>
<receiver>MainWindow</receiver>
<slot>stop_record()</slot>
<hints>
<hint type="sourcelabel">
<x>144</x>
<x>328</x>
<y>543</y>
</hint>
<hint type="destinationlabel">

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Dave Griffiths
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <QtGui>
#include <iostream>
@ -5,7 +21,8 @@
using namespace std;
MainWindow::MainWindow()
MainWindow::MainWindow() :
m_last_file(".")
{
m_Ui.setupUi(this);
setUnifiedTitleAndToolBarOnMac(true);

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <QtGui>
#include "generated/ui_samplebrain.h"
@ -33,13 +49,13 @@ private slots:
void volume_slot(int s) { lo_send(m_audio_address,"/volume","f",s/100.0f); }
void run_slot() {}
void load_target() {
QString s=QFileDialog::getOpenFileName(
m_last_file=QFileDialog::getOpenFileName(
this,
QString("Select an wav file"),
".",
m_last_file,
QString("Sounds (*.wav)"));
lo_send(m_process_address,"/load_target","s",s.toStdString().c_str());
lo_send(m_process_address,"/load_target","s",m_last_file.toStdString().c_str());
}
void target_block_size(int s) { lo_send(m_process_address,"/target_block_size","i",s); }
void target_block_overlap(double s) { lo_send(m_process_address,"/target_overlap","f",s); }
@ -49,15 +65,15 @@ private slots:
void fft_spectrum_size(int) {}
void generate() { lo_send(m_process_address,"/generate_brain",""); }
void load_sound() {
QString s=QFileDialog::getOpenFileName(
m_last_file=QFileDialog::getOpenFileName(
this,
QString("Select an wav file"),
".",
m_last_file,
QString("Sounds (*.wav)"));
lo_send(m_process_address,"/load_sample","s",s.toStdString().c_str());
lo_send(m_process_address,"/load_sample","s",m_last_file.toStdString().c_str());
m_Ui.listWidgetSounds->addItem(s);
m_Ui.listWidgetSounds->addItem(m_last_file);
}
void delete_sound() {
QList<QListWidgetItem *> itemList = m_Ui.listWidgetSounds->selectedItems();
@ -94,12 +110,12 @@ private slots:
void record() {
if (m_save_wav=="") {
QString s=QFileDialog::getSaveFileName(
m_last_file=QFileDialog::getSaveFileName(
this,
QString("Select an wav file"),
".",
m_last_file,
QString("Sounds (*.wav)"));
m_save_wav = s.toStdString();
m_save_wav = m_last_file.toStdString();
// chop off .wav
size_t pos = m_save_wav.find_last_of(".");
if (pos!=string::npos) {
@ -109,18 +125,19 @@ private slots:
}
char fn[1024];
snprintf(fn,1024,"%s-%i.wav",m_save_wav.c_str(),m_record_id);
lo_send(m_process_address,"/record","s",fn);
snprintf(fn,1024,"%s-%i",m_save_wav.c_str(),m_record_id);
lo_send(m_audio_address,"/record","s",fn);
cerr<<fn<<endl;
m_record_id++;
}
void stop_record() {
lo_send(m_process_address,"/stop","");
lo_send(m_audio_address,"/stop","");
}
private:
string m_save_wav;
QString m_last_file;
u32 m_record_id;
Ui_MainWindow m_Ui;
lo_address m_audio_address;

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "audio_thread.h"
#include <iostream>
@ -32,7 +48,8 @@ void audio_thread::run_audio(void* c, unsigned int frames) {
audio_thread *at = (audio_thread*)c;
at->m_audio_device->left_out.zero();
at->process(at->m_audio_device->left_out,
at->m_audio_device->right_out);
at->m_audio_device->right_out);
at->m_audio_device->maybe_record();
}
void audio_thread::process(sample &s, sample &s2) {
@ -68,6 +85,14 @@ void audio_thread::process(sample &s, sample &s2) {
if (name=="/volume") {
m_renderer->set_volume(cmd.get_float(0)*10);
}
if (name=="/record") {
m_renderer->set_playing(true);
m_audio_device->start_recording(cmd.get_string(0));
}
if (name=="/stop") {
m_audio_device->stop_recording();
m_renderer->set_playing(false);
}
}
s.zero();

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Dave Griffiths
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jellyfish/fluxa/OSC_server.h"
#include "process_thread.h"
#include "renderer.h"

View File

@ -1,14 +1,14 @@
/********************************************************************************
** Form generated from reading UI file 'samplebrainMg4993.ui'
** Form generated from reading UI file 'samplebrainB32443.ui'
**
** Created: Sun Jul 19 11:35:24 2015
** Created: Tue Jul 21 14:56:57 2015
** by: Qt User Interface Compiler version 4.8.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef SAMPLEBRAINMG4993_H
#define SAMPLEBRAINMG4993_H
#ifndef SAMPLEBRAINB32443_H
#define SAMPLEBRAINB32443_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
@ -128,8 +128,9 @@ public:
QPushButton *pushButtonStop;
QPushButton *pushButtonRecord;
QPushButton *pushButtonStopRecord;
QSpacerItem *horizontalSpacer;
QDial *dialVolume;
QSpacerItem *horizontalSpacer;
QLabel *label_13;
QStatusBar *statusbar;
void setupUi(QMainWindow *MainWindow)
@ -645,16 +646,22 @@ public:
horizontalLayout_12->addWidget(pushButtonStopRecord);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_12->addItem(horizontalSpacer);
dialVolume = new QDial(centralwidget);
dialVolume->setObjectName(QString::fromUtf8("dialVolume"));
dialVolume->setValue(99);
horizontalLayout_12->addWidget(dialVolume);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_12->addItem(horizontalSpacer);
label_13 = new QLabel(centralwidget);
label_13->setObjectName(QString::fromUtf8("label_13"));
label_13->setPixmap(QPixmap(QString::fromUtf8(":/images/images/at.png")));
horizontalLayout_12->addWidget(label_13);
verticalLayout_7->addLayout(horizontalLayout_12);
@ -699,7 +706,7 @@ public:
QObject::connect(radioButton_hannTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_hann(bool)));
QObject::connect(radioButton_rectangleTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_rectangle(bool)));
QObject::connect(sliderRatio, SIGNAL(valueChanged(int)), MainWindow, SLOT(ratio_slot(int)));
QObject::connect(pushButtonStop, SIGNAL(released()), MainWindow, SLOT(stop_record()));
QObject::connect(pushButtonStopRecord, SIGNAL(released()), MainWindow, SLOT(stop_record()));
QObject::connect(pushButtonRecord, SIGNAL(released()), MainWindow, SLOT(record()));
tabWidget->setCurrentIndex(0);
@ -760,6 +767,7 @@ public:
pushButtonStop->setText(QString());
pushButtonRecord->setText(QString());
pushButtonStopRecord->setText(QString());
label_13->setText(QString());
} // retranslateUi
};
@ -770,4 +778,4 @@ namespace Ui {
QT_END_NAMESPACE
#endif // SAMPLEBRAINMG4993_H
#endif // SAMPLEBRAINB32443_H

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Dave Griffiths
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "process_thread.h"
#include <iostream>
#include <unistd.h>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Dave Griffiths
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jellyfish/fluxa/OSC_server.h"
#include "brain.h"
#include <pthread.h>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Dave Griffiths
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h>
#include <iostream>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <string>
#include "jellyfish/fluxa/sample.h"
#include "jellyfish/core/types.h"

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
#include <sndfile.h>
#include <jellyfish/audio.h>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <list>
#include <vector>
#include <string>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "renderer.h"
#include <iostream>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <list>
#include <jellyfish/fluxa/sample.h>
#include "brain.h"

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "window.h"
#include <cmath>
#include <iostream>

View File

@ -1,3 +1,19 @@
// Copyright (C) 2015 Foam Kernow
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <string>
#include <vector>
#include "jellyfish/fluxa/sample.h"