diff --git a/samplebrain/Makefile.in b/samplebrain/Makefile.in index ab83e28..cb4cdc6 100644 --- a/samplebrain/Makefile.in +++ b/samplebrain/Makefile.in @@ -7,6 +7,7 @@ SRCS := src/fft.cpp \ src/main.cpp \ src/mfcc.cpp \ src/renderer.cpp \ + src/window.cpp \ src/aquila/filter/MelFilterBank.cpp \ src/aquila/filter/MelFilter.cpp \ src/aquila/transform/Dct.cpp \ diff --git a/samplebrain/interface/samplebrain.ui b/samplebrain/interface/samplebrain.ui index 6efc474..b8e2f34 100644 --- a/samplebrain/interface/samplebrain.ui +++ b/samplebrain/interface/samplebrain.ui @@ -31,7 +31,7 @@ search - + @@ -307,7 +307,7 @@ - + @@ -410,6 +410,76 @@ + + + + + + bartlett + + + + + + + blackman + + + + + + + gaussian + + + + + + + hamming + + + + + + + hann + + + + + + + flat top + + + + + + + dodgy + + + true + + + + + + + rectangle + + + + + + + window shape + + + + + @@ -445,7 +515,7 @@ brain - + @@ -523,23 +593,72 @@ - - - - - - Comic Sans MS - 75 - true - - + + + - fft spectrum size + bartlett - - + + + + dodgy + + + true + + + + + + + blackman + + + + + + + gaussian + + + + + + + hamming + + + + + + + hann + + + + + + + flat top + + + + + + + rectangle + + + + + + + window shape + + @@ -597,7 +716,7 @@ 20 - 40 + 508 @@ -873,22 +992,6 @@ - - spinBoxSpectSize - valueChanged(int) - MainWindow - fft_spectrum_size(int) - - - 188 - 171 - - - 399 - 301 - - - pushButtonGenerate released() @@ -1017,6 +1120,262 @@ + + radioButton_bartlett + toggled(bool) + MainWindow + window_bartlett(bool) + + + 75 + 232 + + + 361 + 301 + + + + + radioButton_blackman + toggled(bool) + MainWindow + window_blackman(bool) + + + 75 + 261 + + + 361 + 301 + + + + + radioButton_dodgy + toggled(bool) + MainWindow + window_dodgy(bool) + + + 75 + 203 + + + 361 + 301 + + + + + radioButton_flattop + toggled(bool) + MainWindow + window_flattop(bool) + + + 75 + 290 + + + 361 + 301 + + + + + radioButton_gaussian + toggled(bool) + MainWindow + window_gaussian(bool) + + + 188 + 203 + + + 361 + 301 + + + + + radioButton_hamming + toggled(bool) + MainWindow + window_hamming(bool) + + + 188 + 232 + + + 361 + 301 + + + + + radioButton_hann + toggled(bool) + MainWindow + window_hann(bool) + + + 188 + 261 + + + 361 + 301 + + + + + radioButton_rectagle + toggled(bool) + MainWindow + window_rectangle(bool) + + + 188 + 290 + + + 361 + 301 + + + + + radioButton_bartlettTarget + toggled(bool) + MainWindow + window_target_bartlett(bool) + + + 449 + 290 + + + 361 + 301 + + + + + radioButton_blackmanTarget + toggled(bool) + MainWindow + window_target_blackman(bool) + + + 449 + 319 + + + 361 + 301 + + + + + radioButton_dodgyTarget + toggled(bool) + MainWindow + window_target_dodgy(bool) + + + 449 + 261 + + + 361 + 301 + + + + + radioButton_flattopTarget + toggled(bool) + MainWindow + window_target_flattop(bool) + + + 449 + 348 + + + 361 + 301 + + + + + radioButton_gaussianTarget + toggled(bool) + MainWindow + window_target_gaussian(bool) + + + 619 + 261 + + + 361 + 301 + + + + + radioButton_hammingTarget + toggled(bool) + MainWindow + window_target_hamming(bool) + + + 619 + 290 + + + 361 + 301 + + + + + radioButton_hannTarget + toggled(bool) + MainWindow + window_target_hann(bool) + + + 619 + 319 + + + 361 + 301 + + + + + radioButton_rectangleTarget + toggled(bool) + MainWindow + window_target_rectangle(bool) + + + 619 + 348 + + + 361 + 301 + + + play_slot() @@ -1042,5 +1401,21 @@ generate_target_blocks() clear_brain() restart_audio() + window_dodgy(bool) + window_bartlett(bool) + window_blackman(bool) + window_flattop(bool) + window_gaussian(bool) + window_hamming(bool) + window_hann(bool) + window_rectangle(bool) + window_target_dodgy(bool) + window_target_bartlett(bool) + window_target_blackman(bool) + window_target_flattop(bool) + window_target_gaussian(bool) + window_target_hamming(bool) + window_target_hann(bool) + window_target_rectangle(bool) diff --git a/samplebrain/qt/MainWindow.h b/samplebrain/qt/MainWindow.h index ff6d73d..6a97907 100644 --- a/samplebrain/qt/MainWindow.h +++ b/samplebrain/qt/MainWindow.h @@ -3,8 +3,10 @@ #include #include +#include "window.h" using namespace std; +using namespace spiralcore; class MainWindow : public QMainWindow { @@ -71,6 +73,24 @@ private slots: } void restart_audio() { lo_send(m_audio_address,"/restart_audio",""); } + void window_dodgy(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::DODGY); } + void window_bartlett(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::BARTLETT); } + void window_blackman(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::BLACKMAN); } + void window_flattop(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::FLAT_TOP); } + void window_gaussian(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::GAUSSIAN); } + void window_hamming(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::HAMMING); } + void window_hann(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::HANN); } + void window_rectangle(bool s) { if (s) lo_send(m_process_address,"/window_type","i",window::RECTANGLE); } + + void window_target_dodgy(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::DODGY); } + void window_target_bartlett(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::BARTLETT); } + void window_target_blackman(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::BLACKMAN); } + void window_target_flattop(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::FLAT_TOP); } + void window_target_gaussian(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::GAUSSIAN); } + void window_target_hamming(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::HAMMING); } + void window_target_hann(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::HANN); } + void window_target_rectangle(bool s) { if (s) lo_send(m_process_address,"/target_window_type","i",window::RECTANGLE); } + private: Ui_MainWindow m_Ui; lo_address m_audio_address; diff --git a/samplebrain/qt/audio_thread.cpp b/samplebrain/qt/audio_thread.cpp index 24f4ada..c62a9d2 100644 --- a/samplebrain/qt/audio_thread.cpp +++ b/samplebrain/qt/audio_thread.cpp @@ -59,10 +59,10 @@ void audio_thread::process(sample &s, sample &s2) { } if (name=="/restart_audio") { start_audio(); - } - if (name=="/volume") { - m_renderer->set_volume(cmd.get_float(0)*10); - } + } + if (name=="/volume") { + m_renderer->set_volume(cmd.get_float(0)*10); + } } s.zero(); diff --git a/samplebrain/qt/generated/ui_samplebrain.h b/samplebrain/qt/generated/ui_samplebrain.h index 7304627..1888a97 100644 --- a/samplebrain/qt/generated/ui_samplebrain.h +++ b/samplebrain/qt/generated/ui_samplebrain.h @@ -1,14 +1,14 @@ /******************************************************************************** -** Form generated from reading UI file 'samplebrainHz5241.ui' +** Form generated from reading UI file 'samplebrainSB4993.ui' ** -** Created: Sat Jul 11 20:24:05 2015 +** Created: Sat Jul 18 19:57:06 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 SAMPLEBRAINHZ5241_H -#define SAMPLEBRAINHZ5241_H +#ifndef SAMPLEBRAINSB4993_H +#define SAMPLEBRAINSB4993_H #include #include @@ -16,12 +16,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -38,7 +40,7 @@ public: QHBoxLayout *horizontalLayout; QTabWidget *tabWidget; QWidget *controlTab; - QHBoxLayout *horizontalLayout_15; + QHBoxLayout *horizontalLayout_8; QVBoxLayout *verticalLayout_3; QLabel *label_19; QHBoxLayout *horizontalLayout_12; @@ -68,7 +70,7 @@ public: QHBoxLayout *horizontalLayout_17; QDial *dialVolume; QPushButton *pushButtonRestartAudio; - QVBoxLayout *verticalLayout_9; + QVBoxLayout *verticalLayout_6; QLabel *label_16; QLabel *label_15; QPushButton *pushButtonLoadTarget; @@ -78,10 +80,20 @@ public: QHBoxLayout *horizontalLayout_14; QLabel *label_18; QDoubleSpinBox *doubleSpinBoxBlockOverlapTarget; + QGridLayout *gridLayout_2; + QRadioButton *radioButton_bartlettTarget; + QRadioButton *radioButton_blackmanTarget; + QRadioButton *radioButton_gaussianTarget; + QRadioButton *radioButton_hammingTarget; + QRadioButton *radioButton_hannTarget; + QRadioButton *radioButton_flattopTarget; + QRadioButton *radioButton_dodgyTarget; + QRadioButton *radioButton_rectangleTarget; + QLabel *label_14; QPushButton *pushButtonGenerateTarget; QSpacerItem *verticalSpacer; QWidget *sampleTab; - QHBoxLayout *horizontalLayout_8; + QHBoxLayout *horizontalLayout_5; QVBoxLayout *verticalLayout_2; QLabel *label_3; QHBoxLayout *horizontalLayout_4; @@ -90,9 +102,16 @@ public: QHBoxLayout *horizontalLayout_6; QLabel *label_2; QDoubleSpinBox *doubleSpinBoxBlockOverlap; - QHBoxLayout *horizontalLayout_5; + QGridLayout *gridLayout; + QRadioButton *radioButton_bartlett; + QRadioButton *radioButton_dodgy; + QRadioButton *radioButton_blackman; + QRadioButton *radioButton_gaussian; + QRadioButton *radioButton_hamming; + QRadioButton *radioButton_hann; + QRadioButton *radioButton_flattop; + QRadioButton *radioButton_rectagle; QLabel *label_4; - QSpinBox *spinBoxSpectSize; QPushButton *pushButtonGenerate; QHBoxLayout *horizontalLayout_7; QPushButton *pushButtonLosdBrain; @@ -125,8 +144,8 @@ public: tabWidget->setFont(font); controlTab = new QWidget(); controlTab->setObjectName(QString::fromUtf8("controlTab")); - horizontalLayout_15 = new QHBoxLayout(controlTab); - horizontalLayout_15->setObjectName(QString::fromUtf8("horizontalLayout_15")); + horizontalLayout_8 = new QHBoxLayout(controlTab); + horizontalLayout_8->setObjectName(QString::fromUtf8("horizontalLayout_8")); verticalLayout_3 = new QVBoxLayout(); verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3")); label_19 = new QLabel(controlTab); @@ -306,27 +325,27 @@ public: verticalLayout_3->addLayout(horizontalLayout_17); - horizontalLayout_15->addLayout(verticalLayout_3); + horizontalLayout_8->addLayout(verticalLayout_3); - verticalLayout_9 = new QVBoxLayout(); - verticalLayout_9->setObjectName(QString::fromUtf8("verticalLayout_9")); + verticalLayout_6 = new QVBoxLayout(); + verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6")); label_16 = new QLabel(controlTab); label_16->setObjectName(QString::fromUtf8("label_16")); label_16->setFont(font1); - verticalLayout_9->addWidget(label_16); + verticalLayout_6->addWidget(label_16); label_15 = new QLabel(controlTab); label_15->setObjectName(QString::fromUtf8("label_15")); label_15->setFont(font); - verticalLayout_9->addWidget(label_15); + verticalLayout_6->addWidget(label_15); pushButtonLoadTarget = new QPushButton(controlTab); pushButtonLoadTarget->setObjectName(QString::fromUtf8("pushButtonLoadTarget")); pushButtonLoadTarget->setFont(font); - verticalLayout_9->addWidget(pushButtonLoadTarget); + verticalLayout_6->addWidget(pushButtonLoadTarget); horizontalLayout_13 = new QHBoxLayout(); horizontalLayout_13->setObjectName(QString::fromUtf8("horizontalLayout_13")); @@ -344,7 +363,7 @@ public: horizontalLayout_13->addWidget(spinBoxBlockSizeTarget); - verticalLayout_9->addLayout(horizontalLayout_13); + verticalLayout_6->addLayout(horizontalLayout_13); horizontalLayout_14 = new QHBoxLayout(); horizontalLayout_14->setObjectName(QString::fromUtf8("horizontalLayout_14")); @@ -363,26 +382,77 @@ public: horizontalLayout_14->addWidget(doubleSpinBoxBlockOverlapTarget); - verticalLayout_9->addLayout(horizontalLayout_14); + verticalLayout_6->addLayout(horizontalLayout_14); + + gridLayout_2 = new QGridLayout(); + gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2")); + radioButton_bartlettTarget = new QRadioButton(controlTab); + radioButton_bartlettTarget->setObjectName(QString::fromUtf8("radioButton_bartlettTarget")); + + gridLayout_2->addWidget(radioButton_bartlettTarget, 3, 0, 1, 1); + + radioButton_blackmanTarget = new QRadioButton(controlTab); + radioButton_blackmanTarget->setObjectName(QString::fromUtf8("radioButton_blackmanTarget")); + + gridLayout_2->addWidget(radioButton_blackmanTarget, 4, 0, 1, 1); + + radioButton_gaussianTarget = new QRadioButton(controlTab); + radioButton_gaussianTarget->setObjectName(QString::fromUtf8("radioButton_gaussianTarget")); + + gridLayout_2->addWidget(radioButton_gaussianTarget, 2, 1, 1, 1); + + radioButton_hammingTarget = new QRadioButton(controlTab); + radioButton_hammingTarget->setObjectName(QString::fromUtf8("radioButton_hammingTarget")); + + gridLayout_2->addWidget(radioButton_hammingTarget, 3, 1, 1, 1); + + radioButton_hannTarget = new QRadioButton(controlTab); + radioButton_hannTarget->setObjectName(QString::fromUtf8("radioButton_hannTarget")); + + gridLayout_2->addWidget(radioButton_hannTarget, 4, 1, 1, 1); + + radioButton_flattopTarget = new QRadioButton(controlTab); + radioButton_flattopTarget->setObjectName(QString::fromUtf8("radioButton_flattopTarget")); + + gridLayout_2->addWidget(radioButton_flattopTarget, 5, 0, 1, 1); + + radioButton_dodgyTarget = new QRadioButton(controlTab); + radioButton_dodgyTarget->setObjectName(QString::fromUtf8("radioButton_dodgyTarget")); + radioButton_dodgyTarget->setChecked(true); + + gridLayout_2->addWidget(radioButton_dodgyTarget, 2, 0, 1, 1); + + radioButton_rectangleTarget = new QRadioButton(controlTab); + radioButton_rectangleTarget->setObjectName(QString::fromUtf8("radioButton_rectangleTarget")); + + gridLayout_2->addWidget(radioButton_rectangleTarget, 5, 1, 1, 1); + + label_14 = new QLabel(controlTab); + label_14->setObjectName(QString::fromUtf8("label_14")); + + gridLayout_2->addWidget(label_14, 1, 0, 1, 1); + + + verticalLayout_6->addLayout(gridLayout_2); pushButtonGenerateTarget = new QPushButton(controlTab); pushButtonGenerateTarget->setObjectName(QString::fromUtf8("pushButtonGenerateTarget")); pushButtonGenerateTarget->setFont(font); - verticalLayout_9->addWidget(pushButtonGenerateTarget); + verticalLayout_6->addWidget(pushButtonGenerateTarget); verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - verticalLayout_9->addItem(verticalSpacer); + verticalLayout_6->addItem(verticalSpacer); - horizontalLayout_15->addLayout(verticalLayout_9); + horizontalLayout_8->addLayout(verticalLayout_6); tabWidget->addTab(controlTab, QString()); sampleTab = new QWidget(); sampleTab->setObjectName(QString::fromUtf8("sampleTab")); - horizontalLayout_8 = new QHBoxLayout(sampleTab); - horizontalLayout_8->setObjectName(QString::fromUtf8("horizontalLayout_8")); + horizontalLayout_5 = new QHBoxLayout(sampleTab); + horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); verticalLayout_2 = new QVBoxLayout(); verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); label_3 = new QLabel(sampleTab); @@ -428,21 +498,56 @@ public: verticalLayout_2->addLayout(horizontalLayout_6); - horizontalLayout_5 = new QHBoxLayout(); - horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + radioButton_bartlett = new QRadioButton(sampleTab); + radioButton_bartlett->setObjectName(QString::fromUtf8("radioButton_bartlett")); + + gridLayout->addWidget(radioButton_bartlett, 3, 0, 1, 1); + + radioButton_dodgy = new QRadioButton(sampleTab); + radioButton_dodgy->setObjectName(QString::fromUtf8("radioButton_dodgy")); + radioButton_dodgy->setChecked(true); + + gridLayout->addWidget(radioButton_dodgy, 2, 0, 1, 1); + + radioButton_blackman = new QRadioButton(sampleTab); + radioButton_blackman->setObjectName(QString::fromUtf8("radioButton_blackman")); + + gridLayout->addWidget(radioButton_blackman, 4, 0, 1, 1); + + radioButton_gaussian = new QRadioButton(sampleTab); + radioButton_gaussian->setObjectName(QString::fromUtf8("radioButton_gaussian")); + + gridLayout->addWidget(radioButton_gaussian, 2, 1, 1, 1); + + radioButton_hamming = new QRadioButton(sampleTab); + radioButton_hamming->setObjectName(QString::fromUtf8("radioButton_hamming")); + + gridLayout->addWidget(radioButton_hamming, 3, 1, 1, 1); + + radioButton_hann = new QRadioButton(sampleTab); + radioButton_hann->setObjectName(QString::fromUtf8("radioButton_hann")); + + gridLayout->addWidget(radioButton_hann, 4, 1, 1, 1); + + radioButton_flattop = new QRadioButton(sampleTab); + radioButton_flattop->setObjectName(QString::fromUtf8("radioButton_flattop")); + + gridLayout->addWidget(radioButton_flattop, 5, 0, 1, 1); + + radioButton_rectagle = new QRadioButton(sampleTab); + radioButton_rectagle->setObjectName(QString::fromUtf8("radioButton_rectagle")); + + gridLayout->addWidget(radioButton_rectagle, 5, 1, 1, 1); + label_4 = new QLabel(sampleTab); label_4->setObjectName(QString::fromUtf8("label_4")); - label_4->setFont(font); - horizontalLayout_5->addWidget(label_4); - - spinBoxSpectSize = new QSpinBox(sampleTab); - spinBoxSpectSize->setObjectName(QString::fromUtf8("spinBoxSpectSize")); - - horizontalLayout_5->addWidget(spinBoxSpectSize); + gridLayout->addWidget(label_4, 1, 0, 1, 1); - verticalLayout_2->addLayout(horizontalLayout_5); + verticalLayout_2->addLayout(gridLayout); pushButtonGenerate = new QPushButton(sampleTab); pushButtonGenerate->setObjectName(QString::fromUtf8("pushButtonGenerate")); @@ -467,12 +572,12 @@ public: verticalLayout_2->addLayout(horizontalLayout_7); - verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + verticalSpacer_2 = new QSpacerItem(20, 508, QSizePolicy::Minimum, QSizePolicy::Expanding); verticalLayout_2->addItem(verticalSpacer_2); - horizontalLayout_8->addLayout(verticalLayout_2); + horizontalLayout_5->addLayout(verticalLayout_2); verticalLayout = new QVBoxLayout(); verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); @@ -511,7 +616,7 @@ public: verticalLayout->addLayout(horizontalLayout_2); - horizontalLayout_8->addLayout(verticalLayout); + horizontalLayout_5->addLayout(verticalLayout); tabWidget->addTab(sampleTab, QString()); @@ -535,7 +640,6 @@ public: QObject::connect(spinBoxBlockSizeTarget, SIGNAL(valueChanged(int)), MainWindow, SLOT(target_block_size(int))); QObject::connect(pushButtonGenerateTarget, SIGNAL(released()), MainWindow, SLOT(generate_target_blocks())); QObject::connect(spinBoxBlockSize, SIGNAL(valueChanged(int)), MainWindow, SLOT(block_size(int))); - QObject::connect(spinBoxSpectSize, SIGNAL(valueChanged(int)), MainWindow, SLOT(fft_spectrum_size(int))); QObject::connect(pushButtonGenerate, SIGNAL(released()), MainWindow, SLOT(generate())); QObject::connect(pushButtonLoadSound, SIGNAL(released()), MainWindow, SLOT(load_sound())); QObject::connect(dialVolume, SIGNAL(sliderMoved(int)), MainWindow, SLOT(volume_slot(int))); @@ -544,6 +648,22 @@ public: QObject::connect(pushButtonClearBrain, SIGNAL(released()), MainWindow, SLOT(clear_brain())); QObject::connect(pushButtonDeleteSound, SIGNAL(released()), MainWindow, SLOT(delete_sound())); QObject::connect(pushButtonRestartAudio, SIGNAL(released()), MainWindow, SLOT(restart_audio())); + QObject::connect(radioButton_bartlett, SIGNAL(toggled(bool)), MainWindow, SLOT(window_bartlett(bool))); + QObject::connect(radioButton_blackman, SIGNAL(toggled(bool)), MainWindow, SLOT(window_blackman(bool))); + QObject::connect(radioButton_dodgy, SIGNAL(toggled(bool)), MainWindow, SLOT(window_dodgy(bool))); + QObject::connect(radioButton_flattop, SIGNAL(toggled(bool)), MainWindow, SLOT(window_flattop(bool))); + QObject::connect(radioButton_gaussian, SIGNAL(toggled(bool)), MainWindow, SLOT(window_gaussian(bool))); + QObject::connect(radioButton_hamming, SIGNAL(toggled(bool)), MainWindow, SLOT(window_hamming(bool))); + QObject::connect(radioButton_hann, SIGNAL(toggled(bool)), MainWindow, SLOT(window_hann(bool))); + QObject::connect(radioButton_rectagle, SIGNAL(toggled(bool)), MainWindow, SLOT(window_rectangle(bool))); + QObject::connect(radioButton_bartlettTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_bartlett(bool))); + QObject::connect(radioButton_blackmanTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_blackman(bool))); + QObject::connect(radioButton_dodgyTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_dodgy(bool))); + QObject::connect(radioButton_flattopTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_flattop(bool))); + QObject::connect(radioButton_gaussianTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_gaussian(bool))); + QObject::connect(radioButton_hammingTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_hamming(bool))); + 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))); tabWidget->setCurrentIndex(0); @@ -571,12 +691,29 @@ public: pushButtonLoadTarget->setText(QApplication::translate("MainWindow", "load target", 0, QApplication::UnicodeUTF8)); label_17->setText(QApplication::translate("MainWindow", "block size", 0, QApplication::UnicodeUTF8)); label_18->setText(QApplication::translate("MainWindow", "block overlap", 0, QApplication::UnicodeUTF8)); + radioButton_bartlettTarget->setText(QApplication::translate("MainWindow", "bartlett", 0, QApplication::UnicodeUTF8)); + radioButton_blackmanTarget->setText(QApplication::translate("MainWindow", "blackman", 0, QApplication::UnicodeUTF8)); + radioButton_gaussianTarget->setText(QApplication::translate("MainWindow", "gaussian", 0, QApplication::UnicodeUTF8)); + radioButton_hammingTarget->setText(QApplication::translate("MainWindow", "hamming", 0, QApplication::UnicodeUTF8)); + radioButton_hannTarget->setText(QApplication::translate("MainWindow", "hann", 0, QApplication::UnicodeUTF8)); + radioButton_flattopTarget->setText(QApplication::translate("MainWindow", "flat top", 0, QApplication::UnicodeUTF8)); + radioButton_dodgyTarget->setText(QApplication::translate("MainWindow", "dodgy", 0, QApplication::UnicodeUTF8)); + radioButton_rectangleTarget->setText(QApplication::translate("MainWindow", "rectangle", 0, QApplication::UnicodeUTF8)); + label_14->setText(QApplication::translate("MainWindow", "window shape", 0, QApplication::UnicodeUTF8)); pushButtonGenerateTarget->setText(QApplication::translate("MainWindow", "(re)generate blocks", 0, QApplication::UnicodeUTF8)); tabWidget->setTabText(tabWidget->indexOf(controlTab), QApplication::translate("MainWindow", "search", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("MainWindow", "brain parameters", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("MainWindow", "block size", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("MainWindow", "block overlap", 0, QApplication::UnicodeUTF8)); - label_4->setText(QApplication::translate("MainWindow", "fft spectrum size", 0, QApplication::UnicodeUTF8)); + radioButton_bartlett->setText(QApplication::translate("MainWindow", "bartlett", 0, QApplication::UnicodeUTF8)); + radioButton_dodgy->setText(QApplication::translate("MainWindow", "dodgy", 0, QApplication::UnicodeUTF8)); + radioButton_blackman->setText(QApplication::translate("MainWindow", "blackman", 0, QApplication::UnicodeUTF8)); + radioButton_gaussian->setText(QApplication::translate("MainWindow", "gaussian", 0, QApplication::UnicodeUTF8)); + radioButton_hamming->setText(QApplication::translate("MainWindow", "hamming", 0, QApplication::UnicodeUTF8)); + radioButton_hann->setText(QApplication::translate("MainWindow", "hann", 0, QApplication::UnicodeUTF8)); + radioButton_flattop->setText(QApplication::translate("MainWindow", "flat top", 0, QApplication::UnicodeUTF8)); + radioButton_rectagle->setText(QApplication::translate("MainWindow", "rectangle", 0, QApplication::UnicodeUTF8)); + label_4->setText(QApplication::translate("MainWindow", "window shape", 0, QApplication::UnicodeUTF8)); pushButtonGenerate->setText(QApplication::translate("MainWindow", "(re)generate", 0, QApplication::UnicodeUTF8)); pushButtonLosdBrain->setText(QApplication::translate("MainWindow", "load", 0, QApplication::UnicodeUTF8)); pushButtonSaveBrain->setText(QApplication::translate("MainWindow", "save", 0, QApplication::UnicodeUTF8)); @@ -595,4 +732,4 @@ namespace Ui { QT_END_NAMESPACE -#endif // SAMPLEBRAINHZ5241_H +#endif // SAMPLEBRAINSB4993_H diff --git a/samplebrain/qt/process_thread.cpp b/samplebrain/qt/process_thread.cpp index 04b964a..86f219e 100644 --- a/samplebrain/qt/process_thread.cpp +++ b/samplebrain/qt/process_thread.cpp @@ -16,7 +16,8 @@ process_thread::process_thread() : m_source_overlap(0.75), m_target_block_size(3000), m_target_overlap(0.75), - m_env(50) + m_window_type(window::DODGY), + m_target_window_type(window::DODGY) { m_brain_mutex = new pthread_mutex_t; pthread_mutex_init(m_brain_mutex,NULL); @@ -35,9 +36,6 @@ void process_thread::process() { while (m_osc.get(cmd)) { string name = cmd.m_name; cerr<impulse2freq(m_pcm.get_non_const_buffer()); @@ -112,8 +104,11 @@ bool block::unit_test() { for (u32 i=0; i #include +#include #include "brain.h" using namespace std; @@ -31,41 +32,28 @@ void brain::delete_sound(std::string filename) { } } -void save_sample(const string &filename, const sample s) { - SF_INFO sfinfo; - sfinfo.format=SF_FORMAT_WAV | SF_FORMAT_FLOAT; - sfinfo.frames=s.get_length(); - sfinfo.samplerate=44100; - sfinfo.channels=1; - sfinfo.sections=1; - sfinfo.seekable=0; - SNDFILE* f=sf_open(filename.c_str(), SFM_WRITE, &sfinfo); - if (!f) cerr<<"couldn't open "<::iterator i=m_samples.begin(); i!=m_samples.end(); ++i) { - chop_and_add(i->m_sample, block_size, overlap, env, ditchpcm); + chop_and_add(i->m_sample, ditchpcm); } } -void brain::chop_and_add(const sample &s, u32 block_size, u32 overlap, u32 env, bool ditchpcm) { +void brain::chop_and_add(const sample &s, bool ditchpcm) { u32 pos=0; - if (overlap>=block_size) overlap=0; - while (pos+block_size-1=m_block_size) m_overlap=0; + while (pos+m_block_size-1 m_blocks; std::list m_samples; @@ -56,6 +57,8 @@ private: u32 m_block_size; u32 m_overlap; + window m_window; + }; } diff --git a/samplebrain/src/main.cpp b/samplebrain/src/main.cpp index d5ec5d3..a4c108f 100644 --- a/samplebrain/src/main.cpp +++ b/samplebrain/src/main.cpp @@ -58,30 +58,35 @@ int main(int argc, char *argv[]) cerr<<"starting"<m_ratio=0; a->m_client.set_callback(run_audio, &rr); diff --git a/samplebrain/src/renderer.cpp b/samplebrain/src/renderer.cpp index a287095..3fb57ce 100644 --- a/samplebrain/src/renderer.cpp +++ b/samplebrain/src/renderer.cpp @@ -91,26 +91,29 @@ void renderer::process(u32 nframes, float *buf) { bool renderer::unit_test() { brain source; source.load_sound("test_data/up.wav"); - source.init(10,0,0); + source.init(10,0,window::RECTANGLE); brain target; target.load_sound("test_data/up.wav"); - target.init(10,0,0); + target.init(10,0,window::RECTANGLE); renderer rr(source,target); + rr.set_playing(true); float *buf=new float[10]; rr.process(10,buf); assert(rr.m_render_blocks.size()==2); rr.process(10,buf); assert(rr.m_render_blocks.size()==3); + delete[] buf; + buf=new float[20]; rr.process(20,buf); assert(rr.m_render_blocks.size()==4); rr.process(5,buf); assert(rr.m_render_blocks.size()==2); - target.init(10,5,0); + target.init(10,5,window::RECTANGLE); rr.process(10,buf); assert(rr.m_render_blocks.size()==5); - + delete[] buf; } diff --git a/samplebrain/src/window.cpp b/samplebrain/src/window.cpp new file mode 100644 index 0000000..45c86ef --- /dev/null +++ b/samplebrain/src/window.cpp @@ -0,0 +1,94 @@ +#include "window.h" +#include +#include + +using namespace std; +using namespace spiralcore; + +window::window() : + m_current_type(RECTANGLE) +{ +} + +void window::clear() { + for (vector::iterator i=m_windows.begin(); i!=m_windows.end(); ++i) { + delete *i; + } + m_windows.clear(); +} + +void window::init(u32 size) { + clear(); + for (u32 i=0; iget_length()); + + for (u32 n=0; n +#include +#include "jellyfish/fluxa/sample.h" +#include "jellyfish/core/types.h" + +#ifndef WINDOW +#define WINDOW + +namespace spiralcore { + +class window { +public: + window(); + void init(u32 length); + + enum type { + DODGY = 0, + BARTLETT, + BLACKMAN, + FLAT_TOP, + GAUSSIAN, + HAMMING, + HANN, + RECTANGLE, + MAX_TYPES + }; + + void set_current_type(type t) { m_current_type=t; } + void run(const sample &sample) const; + +private: + void clear(); + + type m_current_type; + + std::vector m_windows; + +}; + +} + +#endif