mirror of
https://gitlab.com/then-try-this/samplebrain.git
synced 2025-07-03 02:33:34 +00:00
freq/dynamics stuff
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -42,6 +42,8 @@ private slots:
|
||||
void stop_slot() { lo_send(m_audio_address,"/pause",""); }
|
||||
void ratio_slot(int s) { lo_send(m_audio_address,"/ratio","f",s/100.0f); }
|
||||
void ratio_slot(double s) { lo_send(m_audio_address,"/ratio","f",s); }
|
||||
void n_ratio_slot(int s) { lo_send(m_audio_address,"/n_ratio","f",s/100.0f); }
|
||||
void n_ratio_slot(double s) { lo_send(m_audio_address,"/n_ratio","f",s); }
|
||||
void fft1_start_slot(int s) { lo_send(m_audio_address,"/fft1_start","i",s); }
|
||||
void fft1_end_slot(int s) { lo_send(m_audio_address,"/fft1_end","i",s); }
|
||||
void fft2_start_slot(int s){} // { m_renderer->get_params()->m_fft2_start=s; }
|
||||
|
@ -67,6 +67,9 @@ void audio_thread::process(sample &s, sample &s2) {
|
||||
if (name=="/ratio") {
|
||||
m_renderer->get_params()->m_ratio = cmd.get_float(0);
|
||||
}
|
||||
if (name=="/n_ratio") {
|
||||
m_renderer->get_params()->m_n_ratio = cmd.get_float(0);
|
||||
}
|
||||
if (name=="/fft1_start") {
|
||||
m_renderer->get_params()->m_fft1_start = cmd.get_int(0);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'samplebrainB32443.ui'
|
||||
**
|
||||
** Created: Tue Jul 21 14:56:57 2015
|
||||
** Created: Tue Jul 21 15:50:16 2015
|
||||
** by: Qt User Interface Compiler version 4.8.1
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
@ -45,30 +45,23 @@ public:
|
||||
QHBoxLayout *horizontalLayout_8;
|
||||
QVBoxLayout *verticalLayout_3;
|
||||
QLabel *label_19;
|
||||
QHBoxLayout *horizontalLayout_16;
|
||||
QLabel *label_6;
|
||||
QHBoxLayout *horizontalLayout_16;
|
||||
QSlider *sliderRatio;
|
||||
QDoubleSpinBox *doubleSpinBoxRatio;
|
||||
QVBoxLayout *verticalLayout_4;
|
||||
QLabel *label_20;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QSlider *sliderNRatio;
|
||||
QDoubleSpinBox *doubleSpinBoxNRatio;
|
||||
QLabel *label_7;
|
||||
QHBoxLayout *horizontalLayout_3;
|
||||
QLabel *label_9;
|
||||
QSpinBox *spinBoxFFT1Start;
|
||||
QHBoxLayout *horizontalLayout_9;
|
||||
QLabel *label_10;
|
||||
QSpinBox *spinBoxFFT1End;
|
||||
QVBoxLayout *verticalLayout_5;
|
||||
QLabel *label_8;
|
||||
QHBoxLayout *horizontalLayout_10;
|
||||
QLabel *label_11;
|
||||
QSpinBox *spinBoxFFT2Start;
|
||||
QHBoxLayout *horizontalLayout_11;
|
||||
QLabel *label_12;
|
||||
QSpinBox *spinBoxFFT2End;
|
||||
QSpacerItem *verticalSpacer_3;
|
||||
QVBoxLayout *verticalLayout_6;
|
||||
QLabel *label_16;
|
||||
QLabel *label_15;
|
||||
QPushButton *pushButtonLoadTarget;
|
||||
QHBoxLayout *horizontalLayout_13;
|
||||
QLabel *label_17;
|
||||
@ -166,8 +159,6 @@ public:
|
||||
|
||||
verticalLayout_3->addWidget(label_19);
|
||||
|
||||
horizontalLayout_16 = new QHBoxLayout();
|
||||
horizontalLayout_16->setObjectName(QString::fromUtf8("horizontalLayout_16"));
|
||||
label_6 = new QLabel(controlTab);
|
||||
label_6->setObjectName(QString::fromUtf8("label_6"));
|
||||
QFont font2;
|
||||
@ -177,11 +168,10 @@ public:
|
||||
font2.setWeight(75);
|
||||
label_6->setFont(font2);
|
||||
|
||||
horizontalLayout_16->addWidget(label_6);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(horizontalLayout_16);
|
||||
verticalLayout_3->addWidget(label_6);
|
||||
|
||||
horizontalLayout_16 = new QHBoxLayout();
|
||||
horizontalLayout_16->setObjectName(QString::fromUtf8("horizontalLayout_16"));
|
||||
sliderRatio = new QSlider(controlTab);
|
||||
sliderRatio->setObjectName(QString::fromUtf8("sliderRatio"));
|
||||
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
@ -192,23 +182,59 @@ public:
|
||||
sliderRatio->setValue(50);
|
||||
sliderRatio->setOrientation(Qt::Horizontal);
|
||||
|
||||
verticalLayout_3->addWidget(sliderRatio);
|
||||
horizontalLayout_16->addWidget(sliderRatio);
|
||||
|
||||
doubleSpinBoxRatio = new QDoubleSpinBox(controlTab);
|
||||
doubleSpinBoxRatio->setObjectName(QString::fromUtf8("doubleSpinBoxRatio"));
|
||||
QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sizePolicy1.setHorizontalStretch(0);
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
sizePolicy1.setHeightForWidth(doubleSpinBoxRatio->sizePolicy().hasHeightForWidth());
|
||||
doubleSpinBoxRatio->setSizePolicy(sizePolicy1);
|
||||
doubleSpinBoxRatio->setMaximum(1);
|
||||
doubleSpinBoxRatio->setSingleStep(0.01);
|
||||
doubleSpinBoxRatio->setValue(0.5);
|
||||
|
||||
verticalLayout_3->addWidget(doubleSpinBoxRatio);
|
||||
horizontalLayout_16->addWidget(doubleSpinBoxRatio);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(horizontalLayout_16);
|
||||
|
||||
label_20 = new QLabel(controlTab);
|
||||
label_20->setObjectName(QString::fromUtf8("label_20"));
|
||||
label_20->setFont(font2);
|
||||
|
||||
verticalLayout_3->addWidget(label_20);
|
||||
|
||||
horizontalLayout = new QHBoxLayout();
|
||||
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
|
||||
sliderNRatio = new QSlider(controlTab);
|
||||
sliderNRatio->setObjectName(QString::fromUtf8("sliderNRatio"));
|
||||
sizePolicy.setHeightForWidth(sliderNRatio->sizePolicy().hasHeightForWidth());
|
||||
sliderNRatio->setSizePolicy(sizePolicy);
|
||||
sliderNRatio->setValue(50);
|
||||
sliderNRatio->setOrientation(Qt::Horizontal);
|
||||
|
||||
horizontalLayout->addWidget(sliderNRatio);
|
||||
|
||||
doubleSpinBoxNRatio = new QDoubleSpinBox(controlTab);
|
||||
doubleSpinBoxNRatio->setObjectName(QString::fromUtf8("doubleSpinBoxNRatio"));
|
||||
sizePolicy1.setHeightForWidth(doubleSpinBoxNRatio->sizePolicy().hasHeightForWidth());
|
||||
doubleSpinBoxNRatio->setSizePolicy(sizePolicy1);
|
||||
doubleSpinBoxNRatio->setMaximum(1);
|
||||
doubleSpinBoxNRatio->setSingleStep(0.01);
|
||||
doubleSpinBoxNRatio->setValue(0.5);
|
||||
|
||||
horizontalLayout->addWidget(doubleSpinBoxNRatio);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(horizontalLayout);
|
||||
|
||||
verticalLayout_4 = new QVBoxLayout();
|
||||
verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
|
||||
label_7 = new QLabel(controlTab);
|
||||
label_7->setObjectName(QString::fromUtf8("label_7"));
|
||||
label_7->setFont(font2);
|
||||
|
||||
verticalLayout_4->addWidget(label_7);
|
||||
verticalLayout_3->addWidget(label_7);
|
||||
|
||||
horizontalLayout_3 = new QHBoxLayout();
|
||||
horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));
|
||||
@ -223,76 +249,24 @@ public:
|
||||
|
||||
horizontalLayout_3->addWidget(spinBoxFFT1Start);
|
||||
|
||||
|
||||
verticalLayout_4->addLayout(horizontalLayout_3);
|
||||
|
||||
horizontalLayout_9 = new QHBoxLayout();
|
||||
horizontalLayout_9->setObjectName(QString::fromUtf8("horizontalLayout_9"));
|
||||
label_10 = new QLabel(controlTab);
|
||||
label_10->setObjectName(QString::fromUtf8("label_10"));
|
||||
label_10->setFont(font);
|
||||
|
||||
horizontalLayout_9->addWidget(label_10);
|
||||
horizontalLayout_3->addWidget(label_10);
|
||||
|
||||
spinBoxFFT1End = new QSpinBox(controlTab);
|
||||
spinBoxFFT1End->setObjectName(QString::fromUtf8("spinBoxFFT1End"));
|
||||
spinBoxFFT1End->setValue(99);
|
||||
|
||||
horizontalLayout_9->addWidget(spinBoxFFT1End);
|
||||
horizontalLayout_3->addWidget(spinBoxFFT1End);
|
||||
|
||||
|
||||
verticalLayout_4->addLayout(horizontalLayout_9);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(verticalLayout_4);
|
||||
|
||||
verticalLayout_5 = new QVBoxLayout();
|
||||
verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5"));
|
||||
label_8 = new QLabel(controlTab);
|
||||
label_8->setObjectName(QString::fromUtf8("label_8"));
|
||||
label_8->setFont(font2);
|
||||
|
||||
verticalLayout_5->addWidget(label_8);
|
||||
|
||||
horizontalLayout_10 = new QHBoxLayout();
|
||||
horizontalLayout_10->setObjectName(QString::fromUtf8("horizontalLayout_10"));
|
||||
label_11 = new QLabel(controlTab);
|
||||
label_11->setObjectName(QString::fromUtf8("label_11"));
|
||||
label_11->setFont(font);
|
||||
|
||||
horizontalLayout_10->addWidget(label_11);
|
||||
|
||||
spinBoxFFT2Start = new QSpinBox(controlTab);
|
||||
spinBoxFFT2Start->setObjectName(QString::fromUtf8("spinBoxFFT2Start"));
|
||||
|
||||
horizontalLayout_10->addWidget(spinBoxFFT2Start);
|
||||
|
||||
|
||||
verticalLayout_5->addLayout(horizontalLayout_10);
|
||||
|
||||
horizontalLayout_11 = new QHBoxLayout();
|
||||
horizontalLayout_11->setObjectName(QString::fromUtf8("horizontalLayout_11"));
|
||||
label_12 = new QLabel(controlTab);
|
||||
label_12->setObjectName(QString::fromUtf8("label_12"));
|
||||
label_12->setFont(font);
|
||||
|
||||
horizontalLayout_11->addWidget(label_12);
|
||||
|
||||
spinBoxFFT2End = new QSpinBox(controlTab);
|
||||
spinBoxFFT2End->setObjectName(QString::fromUtf8("spinBoxFFT2End"));
|
||||
spinBoxFFT2End->setValue(99);
|
||||
|
||||
horizontalLayout_11->addWidget(spinBoxFFT2End);
|
||||
|
||||
|
||||
verticalLayout_5->addLayout(horizontalLayout_11);
|
||||
verticalLayout_3->addLayout(horizontalLayout_3);
|
||||
|
||||
verticalSpacer_3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
verticalLayout_5->addItem(verticalSpacer_3);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(verticalLayout_5);
|
||||
verticalLayout_3->addItem(verticalSpacer_3);
|
||||
|
||||
|
||||
horizontalLayout_8->addLayout(verticalLayout_3);
|
||||
@ -305,12 +279,6 @@ public:
|
||||
|
||||
verticalLayout_6->addWidget(label_16);
|
||||
|
||||
label_15 = new QLabel(controlTab);
|
||||
label_15->setObjectName(QString::fromUtf8("label_15"));
|
||||
label_15->setFont(font);
|
||||
|
||||
verticalLayout_6->addWidget(label_15);
|
||||
|
||||
pushButtonLoadTarget = new QPushButton(controlTab);
|
||||
pushButtonLoadTarget->setObjectName(QString::fromUtf8("pushButtonLoadTarget"));
|
||||
pushButtonLoadTarget->setFont(font);
|
||||
@ -673,41 +641,41 @@ public:
|
||||
retranslateUi(MainWindow);
|
||||
QObject::connect(pushButtonPlay, SIGNAL(released()), MainWindow, SLOT(play_slot()));
|
||||
QObject::connect(pushButtonStop, SIGNAL(released()), MainWindow, SLOT(stop_slot()));
|
||||
QObject::connect(dialVolume, SIGNAL(sliderMoved(int)), MainWindow, SLOT(volume_slot(int)));
|
||||
QObject::connect(pushButtonStopRecord, SIGNAL(released()), MainWindow, SLOT(stop_record()));
|
||||
QObject::connect(pushButtonRecord, SIGNAL(released()), MainWindow, SLOT(record()));
|
||||
QObject::connect(spinBoxBlockSize, SIGNAL(valueChanged(int)), MainWindow, SLOT(block_size(int)));
|
||||
QObject::connect(pushButtonLoadTarget, SIGNAL(released()), MainWindow, SLOT(load_target()));
|
||||
QObject::connect(pushButtonGenerateTarget, SIGNAL(released()), MainWindow, SLOT(generate_target_blocks()));
|
||||
QObject::connect(spinBoxBlockSizeTarget, SIGNAL(valueChanged(int)), MainWindow, SLOT(target_block_size(int)));
|
||||
QObject::connect(doubleSpinBoxRatio, SIGNAL(valueChanged(double)), MainWindow, SLOT(ratio_slot(double)));
|
||||
QObject::connect(spinBoxFFT1Start, SIGNAL(valueChanged(int)), MainWindow, SLOT(fft1_start_slot(int)));
|
||||
QObject::connect(spinBoxFFT1End, SIGNAL(valueChanged(int)), MainWindow, SLOT(fft1_end_slot(int)));
|
||||
QObject::connect(spinBoxFFT2Start, SIGNAL(valueChanged(int)), MainWindow, SLOT(fft2_start_slot(int)));
|
||||
QObject::connect(spinBoxFFT2End, SIGNAL(valueChanged(int)), MainWindow, SLOT(fft2_end_slot(int)));
|
||||
QObject::connect(pushButtonLoadTarget, SIGNAL(released()), MainWindow, SLOT(load_target()));
|
||||
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(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)));
|
||||
QObject::connect(doubleSpinBoxBlockOverlap, SIGNAL(valueChanged(double)), MainWindow, SLOT(block_overlap(double)));
|
||||
QObject::connect(doubleSpinBoxBlockOverlapTarget, SIGNAL(valueChanged(double)), MainWindow, SLOT(target_block_overlap(double)));
|
||||
QObject::connect(pushButtonClearBrain, SIGNAL(released()), MainWindow, SLOT(clear_brain()));
|
||||
QObject::connect(pushButtonDeleteSound, SIGNAL(released()), MainWindow, SLOT(delete_sound()));
|
||||
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(pushButtonDeleteSound, SIGNAL(released()), MainWindow, SLOT(delete_sound()));
|
||||
QObject::connect(doubleSpinBoxBlockOverlapTarget, SIGNAL(valueChanged(double)), MainWindow, SLOT(target_block_overlap(double)));
|
||||
QObject::connect(radioButton_dodgy, SIGNAL(toggled(bool)), MainWindow, SLOT(window_dodgy(bool)));
|
||||
QObject::connect(radioButton_blackman, SIGNAL(toggled(bool)), MainWindow, SLOT(window_blackman(bool)));
|
||||
QObject::connect(radioButton_hann, SIGNAL(toggled(bool)), MainWindow, SLOT(window_hann(bool)));
|
||||
QObject::connect(radioButton_hamming, SIGNAL(toggled(bool)), MainWindow, SLOT(window_hamming(bool)));
|
||||
QObject::connect(radioButton_gaussian, SIGNAL(toggled(bool)), MainWindow, SLOT(window_gaussian(bool)));
|
||||
QObject::connect(pushButtonClearBrain, SIGNAL(released()), MainWindow, SLOT(clear_brain()));
|
||||
QObject::connect(radioButton_bartlett, SIGNAL(toggled(bool)), MainWindow, SLOT(window_bartlett(bool)));
|
||||
QObject::connect(radioButton_flattop, SIGNAL(toggled(bool)), MainWindow, SLOT(window_flattop(bool)));
|
||||
QObject::connect(radioButton_rectagle, SIGNAL(toggled(bool)), MainWindow, SLOT(window_rectangle(bool)));
|
||||
QObject::connect(radioButton_rectangleTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_rectangle(bool)));
|
||||
QObject::connect(radioButton_flattopTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_flattop(bool)));
|
||||
QObject::connect(radioButton_blackmanTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_blackman(bool)));
|
||||
QObject::connect(radioButton_bartlettTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_bartlett(bool)));
|
||||
QObject::connect(radioButton_dodgyTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_dodgy(bool)));
|
||||
QObject::connect(radioButton_hannTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_hann(bool)));
|
||||
QObject::connect(radioButton_gaussianTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_gaussian(bool)));
|
||||
QObject::connect(sliderRatio, SIGNAL(valueChanged(int)), MainWindow, SLOT(ratio_slot(int)));
|
||||
QObject::connect(pushButtonStopRecord, SIGNAL(released()), MainWindow, SLOT(stop_record()));
|
||||
QObject::connect(pushButtonRecord, SIGNAL(released()), MainWindow, SLOT(record()));
|
||||
QObject::connect(sliderNRatio, SIGNAL(valueChanged(int)), MainWindow, SLOT(n_ratio_slot(int)));
|
||||
QObject::connect(doubleSpinBoxNRatio, SIGNAL(valueChanged(double)), MainWindow, SLOT(n_ratio_slot(double)));
|
||||
|
||||
tabWidget->setCurrentIndex(0);
|
||||
|
||||
@ -720,14 +688,11 @@ public:
|
||||
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "samplebrain 0.0.4", 0, QApplication::UnicodeUTF8));
|
||||
label_19->setText(QApplication::translate("MainWindow", "tweakage", 0, QApplication::UnicodeUTF8));
|
||||
label_6->setText(QApplication::translate("MainWindow", "fft <-> mfcc ratio", 0, QApplication::UnicodeUTF8));
|
||||
label_7->setText(QApplication::translate("MainWindow", "fft subsection 1", 0, QApplication::UnicodeUTF8));
|
||||
label_20->setText(QApplication::translate("MainWindow", "freq & dynamics <-> freq ratio", 0, QApplication::UnicodeUTF8));
|
||||
label_7->setText(QApplication::translate("MainWindow", "fft subsection", 0, QApplication::UnicodeUTF8));
|
||||
label_9->setText(QApplication::translate("MainWindow", "Start", 0, QApplication::UnicodeUTF8));
|
||||
label_10->setText(QApplication::translate("MainWindow", "End", 0, QApplication::UnicodeUTF8));
|
||||
label_8->setText(QApplication::translate("MainWindow", "fft subsection 2", 0, QApplication::UnicodeUTF8));
|
||||
label_11->setText(QApplication::translate("MainWindow", "Start", 0, QApplication::UnicodeUTF8));
|
||||
label_12->setText(QApplication::translate("MainWindow", "End", 0, QApplication::UnicodeUTF8));
|
||||
label_16->setText(QApplication::translate("MainWindow", "target sound", 0, QApplication::UnicodeUTF8));
|
||||
label_15->setText(QApplication::translate("MainWindow", "no sound yet...", 0, QApplication::UnicodeUTF8));
|
||||
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));
|
||||
|
BIN
samplebrain/qt/images/at.jpg
Normal file
BIN
samplebrain/qt/images/at.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
samplebrain/qt/images/at.png
Normal file
BIN
samplebrain/qt/images/at.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
samplebrain/qt/images/pause.png
Normal file
BIN
samplebrain/qt/images/pause.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
samplebrain/qt/images/play.png
Normal file
BIN
samplebrain/qt/images/play.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
samplebrain/qt/images/record.png
Normal file
BIN
samplebrain/qt/images/record.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
samplebrain/qt/images/stop.png
Normal file
BIN
samplebrain/qt/images/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
9
samplebrain/qt/samplebrain.qrc
Normal file
9
samplebrain/qt/samplebrain.qrc
Normal file
@ -0,0 +1,9 @@
|
||||
<RCC>
|
||||
<qresource prefix="images">
|
||||
<file>images/at.png</file>
|
||||
<file>images/pause.png</file>
|
||||
<file>images/play.png</file>
|
||||
<file>images/record.png</file>
|
||||
<file>images/stop.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -15,6 +15,7 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "block.h"
|
||||
@ -26,11 +27,41 @@ Aquila::Mfcc *block::m_mfcc_proc;
|
||||
|
||||
static const int MFCC_FILTERS=12;
|
||||
|
||||
void normalise(sample &in) {
|
||||
// find min/max
|
||||
float max = 0;
|
||||
float min = FLT_MAX;
|
||||
for (u32 i=0; i<in.get_length(); ++i) {
|
||||
if (in[i]<min) min=in[i];
|
||||
if (in[i]>max) max=in[i];
|
||||
}
|
||||
|
||||
float mid = min+(max-min)/2.0f;
|
||||
|
||||
// remove dc
|
||||
for (u32 i=0; i<in.get_length(); ++i) {
|
||||
in[i]-=mid;
|
||||
}
|
||||
min-=mid;
|
||||
max-=mid;
|
||||
|
||||
// squash so biggest value is 1 or -1
|
||||
float div = fabs(min);
|
||||
if (div<max) div=max;
|
||||
div=1/div;
|
||||
|
||||
for (u32 i=0; i<in.get_length(); ++i) {
|
||||
in[i]*=div;
|
||||
}
|
||||
}
|
||||
|
||||
block::block(const string &filename, const sample &pcm, u32 rate, const window &w, bool ditchpcm) :
|
||||
m_pcm(pcm),
|
||||
m_fft(pcm.get_length()),
|
||||
m_mfcc(MFCC_FILTERS),
|
||||
m_n_pcm(pcm),
|
||||
m_n_fft(pcm.get_length()),
|
||||
m_n_mfcc(MFCC_FILTERS),
|
||||
m_block_size(pcm.get_length()),
|
||||
m_rate(rate),
|
||||
m_orig_filename(filename)
|
||||
@ -40,30 +71,19 @@ block::block(const string &filename, const sample &pcm, u32 rate, const window &
|
||||
assert(m_fftw!=NULL);
|
||||
|
||||
w.run(m_pcm);
|
||||
process(m_pcm,m_fft,m_mfcc);
|
||||
|
||||
m_fftw->impulse2freq(m_pcm.get_non_const_buffer());
|
||||
// rerun the normalised version
|
||||
normalise(m_n_pcm);
|
||||
process(m_n_pcm,m_n_fft,m_n_mfcc);
|
||||
|
||||
std::vector<std::complex<double> > mfspec;
|
||||
|
||||
for (u32 i=0; i<m_block_size; ++i) {
|
||||
m_fft[i]=m_fftw->m_spectrum[i][0];
|
||||
|
||||
mfspec.push_back(std::complex<double>(m_fftw->m_spectrum[i][0],
|
||||
m_fftw->m_spectrum[i][1]));
|
||||
if (ditchpcm) {
|
||||
m_pcm.clear();
|
||||
m_n_pcm.clear();
|
||||
}
|
||||
|
||||
if (m_block_size>100) m_fft.crop_to(100);
|
||||
if (ditchpcm) m_pcm.clear();
|
||||
|
||||
// calculate mfcc
|
||||
std::vector<double> m = m_mfcc_proc->calculate(mfspec,MFCC_FILTERS);
|
||||
|
||||
for (u32 i=0; i<MFCC_FILTERS; ++i) {
|
||||
m_mfcc[i] = m[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void block::init_fft(u32 block_size)
|
||||
{
|
||||
if (m_fftw == NULL || m_fftw->m_length!=block_size) {
|
||||
@ -74,48 +94,101 @@ void block::init_fft(u32 block_size)
|
||||
}
|
||||
}
|
||||
|
||||
void block::process(const sample &pcm, sample &fft, sample &mfcc) {
|
||||
m_fftw->impulse2freq(pcm.get_buffer());
|
||||
|
||||
// calculate fft
|
||||
std::vector<std::complex<double> > mfspec;
|
||||
for (u32 i=0; i<m_block_size; ++i) {
|
||||
fft[i]=m_fftw->m_spectrum[i][0];
|
||||
mfspec.push_back(std::complex<double>(m_fftw->m_spectrum[i][0],
|
||||
m_fftw->m_spectrum[i][1]));
|
||||
}
|
||||
|
||||
if (m_block_size>100) fft.crop_to(100);
|
||||
|
||||
// calculate mfcc
|
||||
std::vector<double> m = m_mfcc_proc->calculate(mfspec,MFCC_FILTERS);
|
||||
for (u32 i=0; i<MFCC_FILTERS; ++i) {
|
||||
mfcc[i] = m[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define FFT_BIAS 200
|
||||
|
||||
double block::compare(const block &other, const search_params ¶ms) const {
|
||||
double block::_compare(const sample &fft_a, const sample &mfcc_a,
|
||||
const sample &fft_b, const sample &mfcc_b,
|
||||
const search_params ¶ms) const
|
||||
{
|
||||
double mfcc_acc=0;
|
||||
double fft_acc=0;
|
||||
|
||||
/* s32 fft_start = fftwack-10;
|
||||
s32 fft_end = fftwack+10;
|
||||
if (fft_start<0) fft_start=0;
|
||||
if (fft_end>m_fft.get_length()) fft_end=m_fft.get_length();
|
||||
*/
|
||||
s32 fft_start = params.m_fft1_start;
|
||||
s32 fft_end = fmin(params.m_fft1_end,m_fft.get_length());
|
||||
|
||||
if (params.m_ratio==0) {
|
||||
for (u32 i=fft_start; i<fft_end; ++i) {
|
||||
fft_acc+=(m_fft[i]-other.m_fft[i]) * (m_fft[i]-other.m_fft[i]);
|
||||
fft_acc+=(fft_a[i]-fft_b[i]) * (fft_a[i]-fft_b[i]);
|
||||
}
|
||||
return (fft_acc/(float)m_fft.get_length())*FFT_BIAS;
|
||||
return (fft_acc/(float)fft_a.get_length())*FFT_BIAS;
|
||||
}
|
||||
|
||||
if (params.m_ratio==1) {
|
||||
for (u32 i=0; i<MFCC_FILTERS; ++i) {
|
||||
mfcc_acc+=(m_mfcc[i]-other.m_mfcc[i]) * (m_mfcc[i]-other.m_mfcc[i]);
|
||||
mfcc_acc+=(mfcc_a[i]-mfcc_b[i]) * (mfcc_a[i]-mfcc_b[i]);
|
||||
}
|
||||
return mfcc_acc/(float)MFCC_FILTERS;
|
||||
}
|
||||
|
||||
// calculate both
|
||||
for (u32 i=fft_start; i<fft_end; ++i) {
|
||||
fft_acc+=(m_fft[i]-other.m_fft[i]) * (m_fft[i]-other.m_fft[i]);
|
||||
fft_acc+=(fft_a[i]-fft_b[i]) * (fft_a[i]-fft_b[i]);
|
||||
}
|
||||
for (u32 i=0; i<MFCC_FILTERS; ++i) {
|
||||
mfcc_acc+=(m_mfcc[i]-other.m_mfcc[i]) * (m_mfcc[i]-other.m_mfcc[i]);
|
||||
mfcc_acc+=(mfcc_a[i]-mfcc_b[i]) * (mfcc_a[i]-mfcc_b[i]);
|
||||
}
|
||||
|
||||
return (fft_acc/(float)m_fft.get_length())*(1-params.m_ratio)*FFT_BIAS +
|
||||
return (fft_acc/(float)fft_a.get_length())*(1-params.m_ratio)*FFT_BIAS +
|
||||
(mfcc_acc/(float)MFCC_FILTERS)*params.m_ratio;
|
||||
}
|
||||
|
||||
double block::compare(const block &other, const search_params ¶ms) const {
|
||||
return _compare(m_fft, m_mfcc, other.m_fft, other.m_mfcc, params) * (1-params.m_n_ratio) +
|
||||
_compare(m_n_fft, m_n_mfcc, other.m_n_fft, other.m_n_mfcc, params) * params.m_n_ratio;
|
||||
}
|
||||
|
||||
bool block::unit_test() {
|
||||
|
||||
sample ntest(3);
|
||||
u32 idx=0;
|
||||
ntest[idx++]=-1;
|
||||
ntest[idx++]=1;
|
||||
ntest[idx++]=-1;
|
||||
idx=0;
|
||||
normalise(ntest);
|
||||
assert(feq(ntest[idx++],-1));
|
||||
assert(feq(ntest[idx++],1));
|
||||
assert(feq(ntest[idx++],-1));
|
||||
idx=0;
|
||||
ntest[idx++]=-2;
|
||||
ntest[idx++]=2;
|
||||
ntest[idx++]=-2;
|
||||
normalise(ntest);
|
||||
idx=0;
|
||||
assert(feq(ntest[idx++],-1));
|
||||
assert(feq(ntest[idx++],1));
|
||||
assert(feq(ntest[idx++],-1));
|
||||
idx=0;
|
||||
ntest[idx++]=19;
|
||||
ntest[idx++]=20;
|
||||
ntest[idx++]=19;
|
||||
normalise(ntest);
|
||||
idx=0;
|
||||
assert(feq(ntest[idx++],-1));
|
||||
assert(feq(ntest[idx++],1));
|
||||
assert(feq(ntest[idx++],-1));
|
||||
|
||||
sample data(200);
|
||||
for (u32 i=0; i<data.get_length(); i++) {
|
||||
data[i]=i/(float)data.get_length();
|
||||
@ -133,7 +206,7 @@ bool block::unit_test() {
|
||||
assert(bb.m_rate==44100);
|
||||
assert(bb.m_block_size==data.get_length());
|
||||
|
||||
search_params p(0,0,100,0,100);
|
||||
search_params p(0,0,0,100,0,100);
|
||||
block bb2("test",data,44100,w);
|
||||
assert(bb.compare(bb2,p)==0);
|
||||
p.m_ratio=1;
|
||||
@ -159,5 +232,7 @@ bool block::unit_test() {
|
||||
|
||||
assert(cpy.m_pcm.get_length()==200);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -41,10 +41,21 @@ public:
|
||||
const sample &get_pcm() const { return m_pcm; }
|
||||
|
||||
private:
|
||||
|
||||
void process(const sample &pcm, sample &fft, sample &mfcc);
|
||||
|
||||
double _compare(const sample &fft_a, const sample &mfcc_a,
|
||||
const sample &fft_b, const sample &mfcc_b,
|
||||
const search_params ¶ms) const;
|
||||
|
||||
sample m_pcm;
|
||||
sample m_fft;
|
||||
sample m_mfcc;
|
||||
|
||||
sample m_n_pcm;
|
||||
sample m_n_fft;
|
||||
sample m_n_mfcc;
|
||||
|
||||
u32 m_block_size;
|
||||
u32 m_rate;
|
||||
std::string m_orig_filename;
|
||||
|
@ -153,7 +153,7 @@ bool brain::unit_test() {
|
||||
b2.init(512, 0, window::BLACKMAN);
|
||||
b3.init(512, 0, window::BLACKMAN);
|
||||
|
||||
search_params p(1,0,100,0,100);
|
||||
search_params p(1,0,0,100,0,100);
|
||||
|
||||
assert(b3.search(b2.m_blocks[0],p)==0);
|
||||
assert(b3.search(b2.m_blocks[9],p)==9);
|
||||
|
@ -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 <fft.h>
|
||||
#include <jellyfish/core/types.h>
|
||||
|
||||
@ -19,7 +35,7 @@ FFT::~FFT()
|
||||
fftw_destroy_plan(m_plan);
|
||||
}
|
||||
|
||||
void FFT::impulse2freq(float *imp)
|
||||
void FFT::impulse2freq(const float *imp)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -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 <fftw3.h>
|
||||
|
||||
#ifndef SPIRALCORE_FFT
|
||||
@ -12,7 +28,7 @@ class FFT
|
||||
public:
|
||||
FFT(int length);
|
||||
~FFT();
|
||||
void impulse2freq(float *imp);
|
||||
void impulse2freq(const float *imp);
|
||||
|
||||
fftw_plan m_plan;
|
||||
unsigned int m_length;
|
||||
|
@ -59,19 +59,19 @@ int main(int argc, char *argv[])
|
||||
brain source, target;
|
||||
// source.load_sound("../sound/source/shostakovich6.wav");
|
||||
|
||||
// source.load_sound("../sound/source/808.wav");
|
||||
// source.load_sound("../sound/source/joey.wav");
|
||||
// source.load_sound("../sound/source/pw2.wav");
|
||||
// source.load_sound("../sound/source/pw3.wav");
|
||||
// source.load_sound("../sound/source/claps.wav");
|
||||
// source.load_sound("../sound/source/eagle.wav");
|
||||
source.load_sound("../sound/source/808.wav");
|
||||
source.load_sound("../sound/source/joey.wav");
|
||||
source.load_sound("../sound/source/pw2.wav");
|
||||
source.load_sound("../sound/source/pw3.wav");
|
||||
source.load_sound("../sound/source/claps.wav");
|
||||
source.load_sound("../sound/source/eagle.wav");
|
||||
|
||||
// source.load_sound("../sound/source/sailingbybit.wav");
|
||||
source.load_sound("../sound/source/rise.wav");
|
||||
target.load_sound("../sound/source/apache.wav");
|
||||
// source.load_sound("../sound/source/rise.wav");
|
||||
|
||||
|
||||
//target.load_sound("../sound/source/sb-left.wav");
|
||||
target.load_sound("../sound/source/rise.wav");
|
||||
// target.load_sound("../sound/source/rise.wav");
|
||||
cerr<<"loaded sounds"<<endl;
|
||||
cerr<<endl;
|
||||
u32 len=3000;
|
||||
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
renderer rr(source,target);
|
||||
rr.set_playing(true);
|
||||
rr.get_params()->m_ratio=0;
|
||||
rr.get_params()->m_ratio=0.5;
|
||||
|
||||
a->m_client.set_callback(run_audio, &rr);
|
||||
|
||||
|
@ -46,6 +46,7 @@ void renderer::process(u32 nframes, float *buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// cerr<<"-----------------"<<endl;
|
||||
// cerr<<"tgt start:"<<tgt_start<<endl;
|
||||
// cerr<<"tgt end:"<<tgt_end<<endl;
|
||||
|
@ -25,10 +25,10 @@ namespace spiralcore {
|
||||
|
||||
class renderer {
|
||||
public:
|
||||
renderer(brain &source, brain &target) :
|
||||
renderer(brain &source, brain &target) :
|
||||
m_source(source),
|
||||
m_target(target),
|
||||
m_search_params(0,0,100,0,100)
|
||||
m_target(target),
|
||||
m_search_params(0,0,0,100,0,100)
|
||||
{ init(source,target); }
|
||||
|
||||
void init(brain &source, brain &target);
|
||||
|
@ -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.
|
||||
|
||||
#ifndef SEARCH_PARAMS
|
||||
#define SEARCH_PARAMS
|
||||
|
||||
@ -5,15 +21,16 @@ namespace spiralcore {
|
||||
|
||||
class search_params {
|
||||
public:
|
||||
search_params(float ratio, int s1, int e1, int s2, int e2) :
|
||||
search_params(float ratio, float n_ratio, int s1, int e1, int s2, int e2) :
|
||||
m_ratio(ratio),
|
||||
m_n_ratio(n_ratio),
|
||||
m_fft1_start(s1),
|
||||
m_fft1_end(e1),
|
||||
m_fft2_start(s2),
|
||||
m_fft2_end(e2) {}
|
||||
|
||||
|
||||
float m_ratio;
|
||||
float m_n_ratio;
|
||||
int m_fft1_start;
|
||||
int m_fft1_end;
|
||||
int m_fft2_start;
|
||||
|
Reference in New Issue
Block a user