mirror of
https://gitlab.com/then-try-this/samplebrain.git
synced 2025-05-12 18:47:21 +00:00
Merge branch 'master' of gitlab.com:nebogeo/samplebrain
This commit is contained in:
commit
b4d50b666b
@ -16,7 +16,7 @@ SRCS := src/fft.cpp \
|
||||
TARGET_SRCS := src/main.cpp
|
||||
|
||||
# @CFLAGS@
|
||||
CCFLAGS = -Ofast -march=native -mtune=native -std=c++11 -ffast-math -Wno-unused -Isrc -I/opt/local/include
|
||||
CCFLAGS = -g -Ofast -march=native -mtune=native -std=c++11 -ffast-math -Wno-unused -Isrc -I/opt/local/include
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
|
||||
|
156
samplebrain/interface/buttons.svg
Normal file
156
samplebrain/interface/buttons.svg
Normal file
@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.3.1 r9886"
|
||||
sodipodi:docname="New document 1">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="255.65918"
|
||||
inkscape:cy="681.62441"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:window-width="814"
|
||||
inkscape:window-height="690"
|
||||
inkscape:window-x="525"
|
||||
inkscape:window-y="129"
|
||||
inkscape:window-maximized="0">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2985" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none"
|
||||
id="path2987"
|
||||
sodipodi:cx="225"
|
||||
sodipodi:cy="427.36218"
|
||||
sodipodi:rx="125"
|
||||
sodipodi:ry="125"
|
||||
d="m 350,427.36218 a 125,125 0 1 1 -250,0 125,125 0 1 1 250,0 z"
|
||||
transform="translate(25,200)" />
|
||||
<rect
|
||||
style="fill:#e60000;fill-opacity:1;stroke:none"
|
||||
id="rect3757"
|
||||
width="150"
|
||||
height="150"
|
||||
x="100"
|
||||
y="102.36218"
|
||||
ry="50"
|
||||
inkscape:export-filename="/home/dave/code/samplebrain/samplebrain/qt/images/record.png"
|
||||
inkscape:export-xdpi="120"
|
||||
inkscape:export-ydpi="120" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
id="path3759"
|
||||
sodipodi:cx="175"
|
||||
sodipodi:cy="177.36218"
|
||||
sodipodi:rx="45"
|
||||
sodipodi:ry="45"
|
||||
d="m 220,177.36218 a 45,45 0 1 1 -90,0 45,45 0 1 1 90,0 z" />
|
||||
<rect
|
||||
style="fill:#000000;fill-opacity:1;stroke:none"
|
||||
id="rect3757-0"
|
||||
width="150"
|
||||
height="150"
|
||||
x="250"
|
||||
y="102.36218"
|
||||
ry="50"
|
||||
inkscape:export-filename="/home/dave/code/samplebrain/samplebrain/qt/images/stop.png"
|
||||
inkscape:export-xdpi="120"
|
||||
inkscape:export-ydpi="120" />
|
||||
<rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
id="rect3779"
|
||||
width="70"
|
||||
height="70"
|
||||
x="290"
|
||||
y="142.36218"
|
||||
ry="0" />
|
||||
<rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
id="rect3781"
|
||||
width="30"
|
||||
height="10"
|
||||
x="400"
|
||||
y="282.36218" />
|
||||
<rect
|
||||
style="fill:#00d02f;fill-opacity:1;stroke:none"
|
||||
id="rect3757-8"
|
||||
width="150"
|
||||
height="150"
|
||||
x="100"
|
||||
y="252.36218"
|
||||
ry="50"
|
||||
inkscape:export-filename="/home/dave/code/samplebrain/samplebrain/qt/images/play.png"
|
||||
inkscape:export-xdpi="120"
|
||||
inkscape:export-ydpi="120" />
|
||||
<rect
|
||||
style="fill:#0b45f0;fill-opacity:1;stroke:none"
|
||||
id="rect3757-0-2"
|
||||
width="150"
|
||||
height="150"
|
||||
x="250"
|
||||
y="252.36218"
|
||||
ry="50"
|
||||
inkscape:export-filename="/home/dave/code/samplebrain/samplebrain/qt/images/pause.png"
|
||||
inkscape:export-xdpi="120"
|
||||
inkscape:export-ydpi="120" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
|
||||
d="m 140,372.36218 0,-90 80,50 z"
|
||||
id="path3810"
|
||||
inkscape:connector-curvature="0" />
|
||||
<rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
id="rect3812"
|
||||
width="30"
|
||||
height="70"
|
||||
x="290"
|
||||
y="292.36218" />
|
||||
<rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
id="rect3812-5"
|
||||
width="30"
|
||||
height="70"
|
||||
x="330"
|
||||
y="292.36218" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.5 KiB |
File diff suppressed because it is too large
Load Diff
@ -92,7 +92,9 @@ private slots:
|
||||
lo_send(m_audio_address,"/boredom","f",s);
|
||||
m_Ui.sliderBoredom->setValue(s*100);
|
||||
}
|
||||
|
||||
void synapses(int s) {
|
||||
lo_send(m_audio_address,"/synapses","i",s);
|
||||
}
|
||||
void target_mix_slot(int s) {
|
||||
lo_send(m_audio_address,"/target_mix","f",s/100.0f);
|
||||
m_Ui.doubleSpinBoxTargetMix->setValue(s/100.0f);
|
||||
@ -103,11 +105,12 @@ private slots:
|
||||
}
|
||||
|
||||
void volume_slot(int s) { lo_send(m_audio_address,"/volume","f",s/100.0f); }
|
||||
void invert_slot(bool s) { if (s) {
|
||||
lo_send(m_audio_address,"/search_algo","i",1);
|
||||
} else {
|
||||
lo_send(m_audio_address,"/search_algo","i",0);
|
||||
}}
|
||||
|
||||
void algo_basic(bool s) { if (s) lo_send(m_audio_address,"/search_algo","i",0); }
|
||||
void algo_rev_basic(bool s) { if (s) lo_send(m_audio_address,"/search_algo","i",1); }
|
||||
void algo_synaptic(bool s) { if (s) lo_send(m_audio_address,"/search_algo","i",2); }
|
||||
void algo_synaptic_slide(bool s) { if (s) lo_send(m_audio_address,"/search_algo","i",3); }
|
||||
|
||||
void run_slot() {}
|
||||
void load_target() {
|
||||
m_last_file=QFileDialog::getOpenFileName(
|
||||
@ -196,6 +199,26 @@ private slots:
|
||||
lo_send(m_audio_address,"/stop","");
|
||||
}
|
||||
|
||||
void load_brain() {
|
||||
m_last_file=QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QString("Select a brain file"),
|
||||
m_last_file,
|
||||
QString("Brains (*.brain)"));
|
||||
|
||||
lo_send(m_process_address,"/load_brain","s",m_last_file.toStdString().c_str());
|
||||
}
|
||||
void save_brain() {
|
||||
m_last_file=QFileDialog::getSaveFileName(
|
||||
this,
|
||||
QString("Select a brain file"),
|
||||
m_last_file,
|
||||
QString("Brains (*.brain)"));
|
||||
|
||||
lo_send(m_process_address,"/save_brain","s",m_last_file.toStdString().c_str());
|
||||
}
|
||||
|
||||
|
||||
void update_status() {
|
||||
m_feedback.poll(m_Ui.statusbar);
|
||||
}
|
||||
|
@ -37,9 +37,7 @@ static bool state = 1;
|
||||
|
||||
audio_thread::~audio_thread() {
|
||||
state=0;
|
||||
cerr<<"deleting audio device"<<endl;
|
||||
if (m_audio_device!=NULL) delete m_audio_device;
|
||||
cerr<<"deleting renderer"<<endl;
|
||||
delete m_renderer;
|
||||
}
|
||||
|
||||
@ -64,7 +62,7 @@ void audio_thread::process(sample &s, sample &s2) {
|
||||
command_ring_buffer::command cmd;
|
||||
while (m_osc.get(cmd)) {
|
||||
string name = cmd.m_name;
|
||||
cerr<<name<<endl;
|
||||
//cerr<<name<<endl;
|
||||
if (name=="/start") {
|
||||
m_renderer->set_playing(true);
|
||||
}
|
||||
@ -117,6 +115,9 @@ void audio_thread::process(sample &s, sample &s2) {
|
||||
if (name=="/boredom") {
|
||||
m_renderer->get_source().set_usage_falloff(cmd.get_float(0));
|
||||
}
|
||||
if (name=="/synapses") {
|
||||
m_renderer->get_params()->m_num_synapses=cmd.get_int(0);
|
||||
}
|
||||
}
|
||||
|
||||
s.zero();
|
||||
|
@ -33,10 +33,11 @@ public:
|
||||
static void run_audio(void* c, unsigned int frames);
|
||||
audio_device *m_audio_device;
|
||||
|
||||
renderer *m_renderer;
|
||||
|
||||
private:
|
||||
void start_audio();
|
||||
|
||||
renderer *m_renderer;
|
||||
OSC_server m_osc;
|
||||
process_thread &m_process_thread;
|
||||
pthread_mutex_t* m_brain_mutex;
|
||||
|
@ -1,20 +1,19 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'samplebraing19815.ui'
|
||||
** Form generated from reading UI file 'samplebrainuQB562.ui'
|
||||
**
|
||||
** Created: Mon Jul 27 14:41:28 2015
|
||||
** Created: Tue Aug 4 16:33:54 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 SAMPLEBRAING19815_H
|
||||
#define SAMPLEBRAING19815_H
|
||||
#ifndef SAMPLEBRAINUQB562_H
|
||||
#define SAMPLEBRAINUQB562_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QButtonGroup>
|
||||
#include <QtGui/QCheckBox>
|
||||
#include <QtGui/QDial>
|
||||
#include <QtGui/QDoubleSpinBox>
|
||||
#include <QtGui/QGridLayout>
|
||||
@ -43,7 +42,7 @@ public:
|
||||
QVBoxLayout *verticalLayout_4;
|
||||
QTabWidget *tabWidget;
|
||||
QWidget *controlTab;
|
||||
QHBoxLayout *horizontalLayout_17;
|
||||
QHBoxLayout *horizontalLayout_19;
|
||||
QVBoxLayout *verticalLayout_3;
|
||||
QLabel *label_19;
|
||||
QHBoxLayout *horizontalLayout_16;
|
||||
@ -68,7 +67,16 @@ public:
|
||||
QLabel *label_25;
|
||||
QSlider *sliderBoredom;
|
||||
QDoubleSpinBox *doubleSpinBoxBoredom;
|
||||
QCheckBox *checkBoxInvert;
|
||||
QHBoxLayout *horizontalLayout_17;
|
||||
QLabel *label_26;
|
||||
QSlider *sliderSynapses;
|
||||
QSpinBox *spinBoxSynapses;
|
||||
QLabel *label_27;
|
||||
QHBoxLayout *horizontalLayout_18;
|
||||
QRadioButton *radioButtonAlgoBasic;
|
||||
QRadioButton *radioButtonAlgoRevBasic;
|
||||
QRadioButton *radioButtonSynaptic;
|
||||
QRadioButton *radioButtonSynapticSlide;
|
||||
QSpacerItem *horizontalSpacer_2;
|
||||
QSpacerItem *verticalSpacer_3;
|
||||
QLabel *label_23;
|
||||
@ -101,8 +109,6 @@ public:
|
||||
QLabel *label_14;
|
||||
QPushButton *pushButtonGenerateTarget;
|
||||
QSpacerItem *verticalSpacer;
|
||||
QWidget *sampleTab;
|
||||
QHBoxLayout *horizontalLayout_5;
|
||||
QVBoxLayout *verticalLayout_2;
|
||||
QLabel *label_3;
|
||||
QHBoxLayout *horizontalLayout_4;
|
||||
@ -112,18 +118,18 @@ public:
|
||||
QLabel *label_2;
|
||||
QDoubleSpinBox *doubleSpinBoxBlockOverlap;
|
||||
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_dodgy;
|
||||
QRadioButton *radioButton_blackman;
|
||||
QRadioButton *radioButton_rectagle;
|
||||
QRadioButton *radioButton_bartlett;
|
||||
QRadioButton *radioButton_flattop;
|
||||
QRadioButton *radioButton_hann;
|
||||
QLabel *label_4;
|
||||
QPushButton *pushButtonGenerate;
|
||||
QHBoxLayout *horizontalLayout_7;
|
||||
QPushButton *pushButtonLosdBrain;
|
||||
QPushButton *pushButtonLoadBrain;
|
||||
QPushButton *pushButtonSaveBrain;
|
||||
QSpacerItem *verticalSpacer_2;
|
||||
QVBoxLayout *verticalLayout;
|
||||
@ -145,12 +151,15 @@ public:
|
||||
QSpacerItem *horizontalSpacer;
|
||||
QLabel *label_13;
|
||||
QStatusBar *statusbar;
|
||||
QButtonGroup *buttonGroup;
|
||||
QButtonGroup *buttonGroup_2;
|
||||
QButtonGroup *buttonGroup_3;
|
||||
|
||||
void setupUi(QMainWindow *MainWindow)
|
||||
{
|
||||
if (MainWindow->objectName().isEmpty())
|
||||
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
|
||||
MainWindow->resize(643, 619);
|
||||
MainWindow->resize(1134, 691);
|
||||
centralwidget = new QWidget(MainWindow);
|
||||
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
|
||||
verticalLayout_4 = new QVBoxLayout(centralwidget);
|
||||
@ -164,8 +173,8 @@ public:
|
||||
tabWidget->setFont(font);
|
||||
controlTab = new QWidget();
|
||||
controlTab->setObjectName(QString::fromUtf8("controlTab"));
|
||||
horizontalLayout_17 = new QHBoxLayout(controlTab);
|
||||
horizontalLayout_17->setObjectName(QString::fromUtf8("horizontalLayout_17"));
|
||||
horizontalLayout_19 = new QHBoxLayout(controlTab);
|
||||
horizontalLayout_19->setObjectName(QString::fromUtf8("horizontalLayout_19"));
|
||||
verticalLayout_3 = new QVBoxLayout();
|
||||
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
|
||||
label_19 = new QLabel(controlTab);
|
||||
@ -199,6 +208,7 @@ public:
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(sliderRatio->sizePolicy().hasHeightForWidth());
|
||||
sliderRatio->setSizePolicy(sizePolicy);
|
||||
sliderRatio->setMaximum(100);
|
||||
sliderRatio->setValue(50);
|
||||
sliderRatio->setOrientation(Qt::Horizontal);
|
||||
|
||||
@ -232,6 +242,7 @@ public:
|
||||
sliderNRatio->setObjectName(QString::fromUtf8("sliderNRatio"));
|
||||
sizePolicy.setHeightForWidth(sliderNRatio->sizePolicy().hasHeightForWidth());
|
||||
sliderNRatio->setSizePolicy(sizePolicy);
|
||||
sliderNRatio->setMaximum(100);
|
||||
sliderNRatio->setValue(0);
|
||||
sliderNRatio->setOrientation(Qt::Horizontal);
|
||||
|
||||
@ -303,6 +314,7 @@ public:
|
||||
sliderNovelty->setObjectName(QString::fromUtf8("sliderNovelty"));
|
||||
sizePolicy.setHeightForWidth(sliderNovelty->sizePolicy().hasHeightForWidth());
|
||||
sliderNovelty->setSizePolicy(sizePolicy);
|
||||
sliderNovelty->setMaximum(100);
|
||||
sliderNovelty->setValue(0);
|
||||
sliderNovelty->setOrientation(Qt::Horizontal);
|
||||
|
||||
@ -333,6 +345,7 @@ public:
|
||||
sliderBoredom->setObjectName(QString::fromUtf8("sliderBoredom"));
|
||||
sizePolicy.setHeightForWidth(sliderBoredom->sizePolicy().hasHeightForWidth());
|
||||
sliderBoredom->setSizePolicy(sizePolicy);
|
||||
sliderBoredom->setMaximum(100);
|
||||
sliderBoredom->setValue(0);
|
||||
sliderBoredom->setOrientation(Qt::Horizontal);
|
||||
|
||||
@ -351,14 +364,83 @@ public:
|
||||
|
||||
verticalLayout_3->addLayout(horizontalLayout_11);
|
||||
|
||||
checkBoxInvert = new QCheckBox(controlTab);
|
||||
checkBoxInvert->setObjectName(QString::fromUtf8("checkBoxInvert"));
|
||||
checkBoxInvert->setSizeIncrement(QSize(0, 0));
|
||||
checkBoxInvert->setIconSize(QSize(16, 16));
|
||||
horizontalLayout_17 = new QHBoxLayout();
|
||||
horizontalLayout_17->setObjectName(QString::fromUtf8("horizontalLayout_17"));
|
||||
label_26 = new QLabel(controlTab);
|
||||
label_26->setObjectName(QString::fromUtf8("label_26"));
|
||||
label_26->setFont(font2);
|
||||
|
||||
verticalLayout_3->addWidget(checkBoxInvert);
|
||||
horizontalLayout_17->addWidget(label_26);
|
||||
|
||||
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
sliderSynapses = new QSlider(controlTab);
|
||||
sliderSynapses->setObjectName(QString::fromUtf8("sliderSynapses"));
|
||||
sizePolicy.setHeightForWidth(sliderSynapses->sizePolicy().hasHeightForWidth());
|
||||
sliderSynapses->setSizePolicy(sizePolicy);
|
||||
sliderSynapses->setMaximum(1000);
|
||||
sliderSynapses->setValue(20);
|
||||
sliderSynapses->setOrientation(Qt::Horizontal);
|
||||
|
||||
horizontalLayout_17->addWidget(sliderSynapses);
|
||||
|
||||
spinBoxSynapses = new QSpinBox(controlTab);
|
||||
spinBoxSynapses->setObjectName(QString::fromUtf8("spinBoxSynapses"));
|
||||
sizePolicy1.setHeightForWidth(spinBoxSynapses->sizePolicy().hasHeightForWidth());
|
||||
spinBoxSynapses->setSizePolicy(sizePolicy1);
|
||||
spinBoxSynapses->setMaximum(1000);
|
||||
spinBoxSynapses->setValue(20);
|
||||
|
||||
horizontalLayout_17->addWidget(spinBoxSynapses);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(horizontalLayout_17);
|
||||
|
||||
label_27 = new QLabel(controlTab);
|
||||
label_27->setObjectName(QString::fromUtf8("label_27"));
|
||||
QFont font3;
|
||||
font3.setFamily(QString::fromUtf8("Comic Sans MS"));
|
||||
font3.setPointSize(10);
|
||||
font3.setBold(true);
|
||||
font3.setWeight(75);
|
||||
label_27->setFont(font3);
|
||||
|
||||
verticalLayout_3->addWidget(label_27);
|
||||
|
||||
horizontalLayout_18 = new QHBoxLayout();
|
||||
horizontalLayout_18->setObjectName(QString::fromUtf8("horizontalLayout_18"));
|
||||
radioButtonAlgoBasic = new QRadioButton(controlTab);
|
||||
buttonGroup_3 = new QButtonGroup(MainWindow);
|
||||
buttonGroup_3->setObjectName(QString::fromUtf8("buttonGroup_3"));
|
||||
buttonGroup_3->addButton(radioButtonAlgoBasic);
|
||||
radioButtonAlgoBasic->setObjectName(QString::fromUtf8("radioButtonAlgoBasic"));
|
||||
radioButtonAlgoBasic->setChecked(true);
|
||||
|
||||
horizontalLayout_18->addWidget(radioButtonAlgoBasic);
|
||||
|
||||
radioButtonAlgoRevBasic = new QRadioButton(controlTab);
|
||||
buttonGroup_3->addButton(radioButtonAlgoRevBasic);
|
||||
radioButtonAlgoRevBasic->setObjectName(QString::fromUtf8("radioButtonAlgoRevBasic"));
|
||||
|
||||
horizontalLayout_18->addWidget(radioButtonAlgoRevBasic);
|
||||
|
||||
radioButtonSynaptic = new QRadioButton(controlTab);
|
||||
buttonGroup_3->addButton(radioButtonSynaptic);
|
||||
radioButtonSynaptic->setObjectName(QString::fromUtf8("radioButtonSynaptic"));
|
||||
radioButtonSynaptic->setChecked(false);
|
||||
|
||||
horizontalLayout_18->addWidget(radioButtonSynaptic);
|
||||
|
||||
radioButtonSynapticSlide = new QRadioButton(controlTab);
|
||||
buttonGroup_3->addButton(radioButtonSynapticSlide);
|
||||
radioButtonSynapticSlide->setObjectName(QString::fromUtf8("radioButtonSynapticSlide"));
|
||||
radioButtonSynapticSlide->setEnabled(false);
|
||||
radioButtonSynapticSlide->setCheckable(true);
|
||||
|
||||
horizontalLayout_18->addWidget(radioButtonSynapticSlide);
|
||||
|
||||
|
||||
verticalLayout_3->addLayout(horizontalLayout_18);
|
||||
|
||||
horizontalSpacer_2 = new QSpacerItem(21, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
verticalLayout_3->addItem(horizontalSpacer_2);
|
||||
|
||||
@ -434,7 +516,7 @@ public:
|
||||
verticalLayout_3->addLayout(horizontalLayout_9);
|
||||
|
||||
|
||||
horizontalLayout_17->addLayout(verticalLayout_3);
|
||||
horizontalLayout_19->addLayout(verticalLayout_3);
|
||||
|
||||
verticalLayout_6 = new QVBoxLayout();
|
||||
verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6"));
|
||||
@ -490,42 +572,52 @@ public:
|
||||
gridLayout_2 = new QGridLayout();
|
||||
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
|
||||
radioButton_bartlettTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2 = new QButtonGroup(MainWindow);
|
||||
buttonGroup_2->setObjectName(QString::fromUtf8("buttonGroup_2"));
|
||||
buttonGroup_2->addButton(radioButton_bartlettTarget);
|
||||
radioButton_bartlettTarget->setObjectName(QString::fromUtf8("radioButton_bartlettTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_bartlettTarget, 3, 0, 1, 1);
|
||||
|
||||
radioButton_blackmanTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2->addButton(radioButton_blackmanTarget);
|
||||
radioButton_blackmanTarget->setObjectName(QString::fromUtf8("radioButton_blackmanTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_blackmanTarget, 4, 0, 1, 1);
|
||||
|
||||
radioButton_gaussianTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2->addButton(radioButton_gaussianTarget);
|
||||
radioButton_gaussianTarget->setObjectName(QString::fromUtf8("radioButton_gaussianTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_gaussianTarget, 2, 1, 1, 1);
|
||||
|
||||
radioButton_hammingTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2->addButton(radioButton_hammingTarget);
|
||||
radioButton_hammingTarget->setObjectName(QString::fromUtf8("radioButton_hammingTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_hammingTarget, 3, 1, 1, 1);
|
||||
|
||||
radioButton_hannTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2->addButton(radioButton_hannTarget);
|
||||
radioButton_hannTarget->setObjectName(QString::fromUtf8("radioButton_hannTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_hannTarget, 4, 1, 1, 1);
|
||||
|
||||
radioButton_flattopTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2->addButton(radioButton_flattopTarget);
|
||||
radioButton_flattopTarget->setObjectName(QString::fromUtf8("radioButton_flattopTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_flattopTarget, 5, 0, 1, 1);
|
||||
|
||||
radioButton_dodgyTarget = new QRadioButton(controlTab);
|
||||
buttonGroup_2->addButton(radioButton_dodgyTarget);
|
||||
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);
|
||||
buttonGroup_2->addButton(radioButton_rectangleTarget);
|
||||
radioButton_rectangleTarget->setObjectName(QString::fromUtf8("radioButton_rectangleTarget"));
|
||||
|
||||
gridLayout_2->addWidget(radioButton_rectangleTarget, 5, 1, 1, 1);
|
||||
@ -549,16 +641,11 @@ public:
|
||||
verticalLayout_6->addItem(verticalSpacer);
|
||||
|
||||
|
||||
horizontalLayout_17->addLayout(verticalLayout_6);
|
||||
horizontalLayout_19->addLayout(verticalLayout_6);
|
||||
|
||||
tabWidget->addTab(controlTab, QString());
|
||||
sampleTab = new QWidget();
|
||||
sampleTab->setObjectName(QString::fromUtf8("sampleTab"));
|
||||
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);
|
||||
label_3 = new QLabel(controlTab);
|
||||
label_3->setObjectName(QString::fromUtf8("label_3"));
|
||||
label_3->setFont(font1);
|
||||
|
||||
@ -566,13 +653,13 @@ public:
|
||||
|
||||
horizontalLayout_4 = new QHBoxLayout();
|
||||
horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
|
||||
label = new QLabel(sampleTab);
|
||||
label = new QLabel(controlTab);
|
||||
label->setObjectName(QString::fromUtf8("label"));
|
||||
label->setFont(font);
|
||||
|
||||
horizontalLayout_4->addWidget(label);
|
||||
|
||||
spinBoxBlockSize = new QSpinBox(sampleTab);
|
||||
spinBoxBlockSize = new QSpinBox(controlTab);
|
||||
spinBoxBlockSize->setObjectName(QString::fromUtf8("spinBoxBlockSize"));
|
||||
spinBoxBlockSize->setMaximum(99999);
|
||||
spinBoxBlockSize->setValue(3000);
|
||||
@ -584,13 +671,13 @@ public:
|
||||
|
||||
horizontalLayout_6 = new QHBoxLayout();
|
||||
horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
|
||||
label_2 = new QLabel(sampleTab);
|
||||
label_2 = new QLabel(controlTab);
|
||||
label_2->setObjectName(QString::fromUtf8("label_2"));
|
||||
label_2->setFont(font);
|
||||
|
||||
horizontalLayout_6->addWidget(label_2);
|
||||
|
||||
doubleSpinBoxBlockOverlap = new QDoubleSpinBox(sampleTab);
|
||||
doubleSpinBoxBlockOverlap = new QDoubleSpinBox(controlTab);
|
||||
doubleSpinBoxBlockOverlap->setObjectName(QString::fromUtf8("doubleSpinBoxBlockOverlap"));
|
||||
doubleSpinBoxBlockOverlap->setMaximum(1);
|
||||
doubleSpinBoxBlockOverlap->setSingleStep(0.01);
|
||||
@ -603,56 +690,66 @@ public:
|
||||
|
||||
gridLayout = new QGridLayout();
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||
radioButton_bartlett = new QRadioButton(sampleTab);
|
||||
radioButton_bartlett->setObjectName(QString::fromUtf8("radioButton_bartlett"));
|
||||
radioButton_gaussian = new QRadioButton(controlTab);
|
||||
buttonGroup = new QButtonGroup(MainWindow);
|
||||
buttonGroup->setObjectName(QString::fromUtf8("buttonGroup"));
|
||||
buttonGroup->addButton(radioButton_gaussian);
|
||||
radioButton_gaussian->setObjectName(QString::fromUtf8("radioButton_gaussian"));
|
||||
|
||||
gridLayout->addWidget(radioButton_bartlett, 3, 0, 1, 1);
|
||||
gridLayout->addWidget(radioButton_gaussian, 3, 1, 1, 1);
|
||||
|
||||
radioButton_dodgy = new QRadioButton(sampleTab);
|
||||
radioButton_hamming = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_hamming);
|
||||
radioButton_hamming->setObjectName(QString::fromUtf8("radioButton_hamming"));
|
||||
|
||||
gridLayout->addWidget(radioButton_hamming, 4, 1, 1, 1);
|
||||
|
||||
radioButton_dodgy = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_dodgy);
|
||||
radioButton_dodgy->setObjectName(QString::fromUtf8("radioButton_dodgy"));
|
||||
radioButton_dodgy->setChecked(true);
|
||||
|
||||
gridLayout->addWidget(radioButton_dodgy, 2, 0, 1, 1);
|
||||
gridLayout->addWidget(radioButton_dodgy, 3, 0, 1, 1);
|
||||
|
||||
radioButton_blackman = new QRadioButton(sampleTab);
|
||||
radioButton_blackman = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_blackman);
|
||||
radioButton_blackman->setObjectName(QString::fromUtf8("radioButton_blackman"));
|
||||
|
||||
gridLayout->addWidget(radioButton_blackman, 4, 0, 1, 1);
|
||||
gridLayout->addWidget(radioButton_blackman, 5, 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 = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_rectagle);
|
||||
radioButton_rectagle->setObjectName(QString::fromUtf8("radioButton_rectagle"));
|
||||
|
||||
gridLayout->addWidget(radioButton_rectagle, 5, 1, 1, 1);
|
||||
gridLayout->addWidget(radioButton_rectagle, 6, 1, 1, 1);
|
||||
|
||||
label_4 = new QLabel(sampleTab);
|
||||
radioButton_bartlett = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_bartlett);
|
||||
radioButton_bartlett->setObjectName(QString::fromUtf8("radioButton_bartlett"));
|
||||
|
||||
gridLayout->addWidget(radioButton_bartlett, 4, 0, 1, 1);
|
||||
|
||||
radioButton_flattop = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_flattop);
|
||||
radioButton_flattop->setObjectName(QString::fromUtf8("radioButton_flattop"));
|
||||
|
||||
gridLayout->addWidget(radioButton_flattop, 6, 0, 1, 1);
|
||||
|
||||
radioButton_hann = new QRadioButton(controlTab);
|
||||
buttonGroup->addButton(radioButton_hann);
|
||||
radioButton_hann->setObjectName(QString::fromUtf8("radioButton_hann"));
|
||||
|
||||
gridLayout->addWidget(radioButton_hann, 5, 1, 1, 1);
|
||||
|
||||
label_4 = new QLabel(controlTab);
|
||||
label_4->setObjectName(QString::fromUtf8("label_4"));
|
||||
|
||||
gridLayout->addWidget(label_4, 1, 0, 1, 1);
|
||||
gridLayout->addWidget(label_4, 2, 0, 1, 1);
|
||||
|
||||
|
||||
verticalLayout_2->addLayout(gridLayout);
|
||||
|
||||
pushButtonGenerate = new QPushButton(sampleTab);
|
||||
pushButtonGenerate = new QPushButton(controlTab);
|
||||
pushButtonGenerate->setObjectName(QString::fromUtf8("pushButtonGenerate"));
|
||||
pushButtonGenerate->setFont(font);
|
||||
|
||||
@ -660,13 +757,13 @@ public:
|
||||
|
||||
horizontalLayout_7 = new QHBoxLayout();
|
||||
horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7"));
|
||||
pushButtonLosdBrain = new QPushButton(sampleTab);
|
||||
pushButtonLosdBrain->setObjectName(QString::fromUtf8("pushButtonLosdBrain"));
|
||||
pushButtonLosdBrain->setFont(font);
|
||||
pushButtonLoadBrain = new QPushButton(controlTab);
|
||||
pushButtonLoadBrain->setObjectName(QString::fromUtf8("pushButtonLoadBrain"));
|
||||
pushButtonLoadBrain->setFont(font);
|
||||
|
||||
horizontalLayout_7->addWidget(pushButtonLosdBrain);
|
||||
horizontalLayout_7->addWidget(pushButtonLoadBrain);
|
||||
|
||||
pushButtonSaveBrain = new QPushButton(sampleTab);
|
||||
pushButtonSaveBrain = new QPushButton(controlTab);
|
||||
pushButtonSaveBrain->setObjectName(QString::fromUtf8("pushButtonSaveBrain"));
|
||||
pushButtonSaveBrain->setFont(font);
|
||||
|
||||
@ -680,36 +777,36 @@ public:
|
||||
verticalLayout_2->addItem(verticalSpacer_2);
|
||||
|
||||
|
||||
horizontalLayout_5->addLayout(verticalLayout_2);
|
||||
horizontalLayout_19->addLayout(verticalLayout_2);
|
||||
|
||||
verticalLayout = new QVBoxLayout();
|
||||
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
|
||||
label_5 = new QLabel(sampleTab);
|
||||
label_5 = new QLabel(controlTab);
|
||||
label_5->setObjectName(QString::fromUtf8("label_5"));
|
||||
label_5->setFont(font);
|
||||
|
||||
verticalLayout->addWidget(label_5);
|
||||
|
||||
listWidgetSounds = new QListWidget(sampleTab);
|
||||
listWidgetSounds = new QListWidget(controlTab);
|
||||
listWidgetSounds->setObjectName(QString::fromUtf8("listWidgetSounds"));
|
||||
|
||||
verticalLayout->addWidget(listWidgetSounds);
|
||||
|
||||
horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
|
||||
pushButtonLoadSound = new QPushButton(sampleTab);
|
||||
pushButtonLoadSound = new QPushButton(controlTab);
|
||||
pushButtonLoadSound->setObjectName(QString::fromUtf8("pushButtonLoadSound"));
|
||||
pushButtonLoadSound->setFont(font);
|
||||
|
||||
horizontalLayout_2->addWidget(pushButtonLoadSound);
|
||||
|
||||
pushButtonDeleteSound = new QPushButton(sampleTab);
|
||||
pushButtonDeleteSound = new QPushButton(controlTab);
|
||||
pushButtonDeleteSound->setObjectName(QString::fromUtf8("pushButtonDeleteSound"));
|
||||
pushButtonDeleteSound->setFont(font);
|
||||
|
||||
horizontalLayout_2->addWidget(pushButtonDeleteSound);
|
||||
|
||||
pushButtonClearBrain = new QPushButton(sampleTab);
|
||||
pushButtonClearBrain = new QPushButton(controlTab);
|
||||
pushButtonClearBrain->setObjectName(QString::fromUtf8("pushButtonClearBrain"));
|
||||
pushButtonClearBrain->setFont(font);
|
||||
|
||||
@ -719,9 +816,9 @@ public:
|
||||
verticalLayout->addLayout(horizontalLayout_2);
|
||||
|
||||
|
||||
horizontalLayout_5->addLayout(verticalLayout);
|
||||
horizontalLayout_19->addLayout(verticalLayout);
|
||||
|
||||
tabWidget->addTab(sampleTab, QString());
|
||||
tabWidget->addTab(controlTab, QString());
|
||||
logTab = new QWidget();
|
||||
logTab->setObjectName(QString::fromUtf8("logTab"));
|
||||
horizontalLayout_15 = new QHBoxLayout(logTab);
|
||||
@ -809,28 +906,14 @@ public:
|
||||
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(pushButtonGenerate, SIGNAL(released()), MainWindow, SLOT(generate()));
|
||||
QObject::connect(pushButtonLoadSound, SIGNAL(released()), MainWindow, SLOT(load_sound()));
|
||||
QObject::connect(doubleSpinBoxBlockOverlap, SIGNAL(valueChanged(double)), MainWindow, SLOT(block_overlap(double)));
|
||||
QObject::connect(radioButton_hammingTarget, SIGNAL(toggled(bool)), MainWindow, SLOT(window_target_hamming(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)));
|
||||
@ -841,7 +924,6 @@ public:
|
||||
QObject::connect(sliderRatio, SIGNAL(valueChanged(int)), MainWindow, SLOT(ratio_slot(int)));
|
||||
QObject::connect(sliderNRatio, SIGNAL(valueChanged(int)), MainWindow, SLOT(n_ratio_slot(int)));
|
||||
QObject::connect(doubleSpinBoxNRatio, SIGNAL(valueChanged(double)), MainWindow, SLOT(n_ratio_slot(double)));
|
||||
QObject::connect(checkBoxInvert, SIGNAL(toggled(bool)), MainWindow, SLOT(invert_slot(bool)));
|
||||
QObject::connect(sliderNMix, SIGNAL(valueChanged(int)), MainWindow, SLOT(n_mix_slot(int)));
|
||||
QObject::connect(sliderTargetMix, SIGNAL(valueChanged(int)), MainWindow, SLOT(target_mix_slot(int)));
|
||||
QObject::connect(doubleSpinBoxNMix, SIGNAL(valueChanged(double)), MainWindow, SLOT(n_mix_slot(double)));
|
||||
@ -850,6 +932,30 @@ public:
|
||||
QObject::connect(sliderBoredom, SIGNAL(valueChanged(int)), MainWindow, SLOT(boredom_slot(int)));
|
||||
QObject::connect(doubleSpinBoxNovelty, SIGNAL(valueChanged(double)), MainWindow, SLOT(novelty_slot(double)));
|
||||
QObject::connect(sliderNovelty, SIGNAL(valueChanged(int)), MainWindow, SLOT(novelty_slot(int)));
|
||||
QObject::connect(sliderSynapses, SIGNAL(valueChanged(int)), spinBoxSynapses, SLOT(setValue(int)));
|
||||
QObject::connect(sliderSynapses, SIGNAL(valueChanged(int)), MainWindow, SLOT(synapses(int)));
|
||||
QObject::connect(spinBoxSynapses, SIGNAL(valueChanged(int)), sliderSynapses, SLOT(setValue(int)));
|
||||
QObject::connect(spinBoxSynapses, SIGNAL(valueChanged(int)), MainWindow, SLOT(synapses(int)));
|
||||
QObject::connect(radioButtonAlgoBasic, SIGNAL(toggled(bool)), MainWindow, SLOT(algo_basic(bool)));
|
||||
QObject::connect(radioButtonAlgoRevBasic, SIGNAL(toggled(bool)), MainWindow, SLOT(algo_rev_basic(bool)));
|
||||
QObject::connect(radioButtonSynaptic, SIGNAL(toggled(bool)), MainWindow, SLOT(algo_synaptic(bool)));
|
||||
QObject::connect(radioButtonSynapticSlide, SIGNAL(toggled(bool)), MainWindow, SLOT(algo_synaptic_slide(bool)));
|
||||
QObject::connect(pushButtonLoadBrain, SIGNAL(released()), MainWindow, SLOT(load_brain()));
|
||||
QObject::connect(pushButtonSaveBrain, SIGNAL(released()), MainWindow, SLOT(save_brain()));
|
||||
QObject::connect(spinBoxBlockSize, SIGNAL(valueChanged(int)), MainWindow, SLOT(block_size(int)));
|
||||
QObject::connect(doubleSpinBoxBlockOverlap, SIGNAL(valueChanged(double)), MainWindow, SLOT(block_overlap(double)));
|
||||
QObject::connect(radioButton_dodgy, SIGNAL(toggled(bool)), MainWindow, SLOT(window_dodgy(bool)));
|
||||
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_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_target_rectangle(bool)));
|
||||
QObject::connect(pushButtonGenerate, SIGNAL(released()), MainWindow, SLOT(generate()));
|
||||
QObject::connect(pushButtonLoadSound, SIGNAL(released()), MainWindow, SLOT(load_sound()));
|
||||
QObject::connect(pushButtonDeleteSound, SIGNAL(released()), MainWindow, SLOT(delete_sound()));
|
||||
QObject::connect(pushButtonClearBrain, SIGNAL(released()), MainWindow, SLOT(clear_brain()));
|
||||
|
||||
tabWidget->setCurrentIndex(0);
|
||||
|
||||
@ -859,7 +965,7 @@ public:
|
||||
|
||||
void retranslateUi(QMainWindow *MainWindow)
|
||||
{
|
||||
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "samplebrain 0.0.5", 0, QApplication::UnicodeUTF8));
|
||||
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "samplebrain 0.6", 0, QApplication::UnicodeUTF8));
|
||||
label_19->setText(QApplication::translate("MainWindow", "brain tweaks", 0, QApplication::UnicodeUTF8));
|
||||
label_6->setText(QApplication::translate("MainWindow", "fft / mfcc", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
@ -896,9 +1002,32 @@ public:
|
||||
sliderBoredom->setToolTip(QApplication::translate("MainWindow", "how long it takes for the novelty to ware off", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
checkBoxInvert->setToolTip(QString());
|
||||
label_26->setToolTip(QString());
|
||||
#endif // QT_NO_TOOLTIP
|
||||
checkBoxInvert->setText(QApplication::translate("MainWindow", "search for least similar", 0, QApplication::UnicodeUTF8));
|
||||
label_26->setText(QApplication::translate("MainWindow", "synpases", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
sliderSynapses->setToolTip(QApplication::translate("MainWindow", "how many connections to search (ordered in closeness)", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
spinBoxSynapses->setToolTip(QApplication::translate("MainWindow", "how many connections to search (ordered in closeness)", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
label_27->setText(QApplication::translate("MainWindow", "algorithm", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
radioButtonAlgoBasic->setToolTip(QApplication::translate("MainWindow", "full brain search", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
radioButtonAlgoBasic->setText(QApplication::translate("MainWindow", "basic", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
radioButtonAlgoRevBasic->setToolTip(QApplication::translate("MainWindow", "full brain reverse search", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
radioButtonAlgoRevBasic->setText(QApplication::translate("MainWindow", "rev basic", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
radioButtonSynaptic->setToolTip(QApplication::translate("MainWindow", "search based on synapse connections", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
radioButtonSynaptic->setText(QApplication::translate("MainWindow", "synaptic", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
radioButtonSynapticSlide->setToolTip(QApplication::translate("MainWindow", "search based on synapses and sonify search process", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
radioButtonSynapticSlide->setText(QApplication::translate("MainWindow", "synaptic slide", 0, QApplication::UnicodeUTF8));
|
||||
label_23->setText(QApplication::translate("MainWindow", "mix", 0, QApplication::UnicodeUTF8));
|
||||
label_21->setText(QApplication::translate("MainWindow", "dynamic / normalised ", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
@ -922,27 +1051,26 @@ public:
|
||||
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));
|
||||
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_dodgy->setText(QApplication::translate("MainWindow", "dodgy", 0, QApplication::UnicodeUTF8));
|
||||
radioButton_blackman->setText(QApplication::translate("MainWindow", "blackman", 0, QApplication::UnicodeUTF8));
|
||||
radioButton_rectagle->setText(QApplication::translate("MainWindow", "rectangle", 0, QApplication::UnicodeUTF8));
|
||||
radioButton_bartlett->setText(QApplication::translate("MainWindow", "bartlett", 0, QApplication::UnicodeUTF8));
|
||||
radioButton_flattop->setText(QApplication::translate("MainWindow", "flat top", 0, QApplication::UnicodeUTF8));
|
||||
radioButton_hann->setText(QApplication::translate("MainWindow", "hann", 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));
|
||||
pushButtonGenerate->setText(QApplication::translate("MainWindow", "(re)generate brain", 0, QApplication::UnicodeUTF8));
|
||||
pushButtonLoadBrain->setText(QApplication::translate("MainWindow", "load brain", 0, QApplication::UnicodeUTF8));
|
||||
pushButtonSaveBrain->setText(QApplication::translate("MainWindow", "save brain", 0, QApplication::UnicodeUTF8));
|
||||
label_5->setText(QApplication::translate("MainWindow", "brain contents", 0, QApplication::UnicodeUTF8));
|
||||
pushButtonLoadSound->setText(QApplication::translate("MainWindow", "load sound", 0, QApplication::UnicodeUTF8));
|
||||
pushButtonDeleteSound->setText(QApplication::translate("MainWindow", "delete selected", 0, QApplication::UnicodeUTF8));
|
||||
pushButtonClearBrain->setText(QApplication::translate("MainWindow", "clear brain", 0, QApplication::UnicodeUTF8));
|
||||
tabWidget->setTabText(tabWidget->indexOf(sampleTab), QApplication::translate("MainWindow", "brain", 0, QApplication::UnicodeUTF8));
|
||||
tabWidget->setTabText(tabWidget->indexOf(controlTab), QApplication::translate("MainWindow", "search", 0, QApplication::UnicodeUTF8));
|
||||
tabWidget->setTabText(tabWidget->indexOf(logTab), QApplication::translate("MainWindow", "log", 0, QApplication::UnicodeUTF8));
|
||||
pushButtonPlay->setText(QString());
|
||||
pushButtonStop->setText(QString());
|
||||
@ -959,4 +1087,4 @@ namespace Ui {
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // SAMPLEBRAING19815_H
|
||||
#endif // SAMPLEBRAINUQB562_H
|
||||
|
@ -56,7 +56,7 @@ void process_thread::process() {
|
||||
while(true) {
|
||||
while (m_osc.get(cmd)) {
|
||||
string name = cmd.m_name;
|
||||
cerr<<name<<endl;
|
||||
//cerr<<name<<endl;
|
||||
if (name=="/load_sample") {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
m_source.load_sound(cmd.get_string(0));
|
||||
@ -75,8 +75,10 @@ void process_thread::process() {
|
||||
}
|
||||
if (name=="/generate_brain") {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
cerr<<m_window_type<<endl;
|
||||
m_source.init(m_source_block_size, m_source_overlap, m_window_type);
|
||||
search_params p(1,0,0,100,0);
|
||||
m_source.build_synapses_fixed(p);
|
||||
m_renderer->reset();
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
}
|
||||
if (name=="/load_target") {
|
||||
@ -90,11 +92,9 @@ void process_thread::process() {
|
||||
}
|
||||
if (name=="/target_overlap") {
|
||||
m_target_overlap = m_target_block_size*cmd.get_float(0);
|
||||
cerr<<m_target_overlap<<endl;
|
||||
}
|
||||
if (name=="/generate_target") {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
cerr<<m_target_window_type<<endl;
|
||||
m_target.init(m_target_block_size, m_target_overlap, m_target_window_type);
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
}
|
||||
@ -104,7 +104,46 @@ void process_thread::process() {
|
||||
if (name=="/target_window_type") {
|
||||
m_target_window_type=(window::type)cmd.get_int(0);
|
||||
}
|
||||
if (name=="/load_brain") {
|
||||
load_source(cmd.get_string(0));
|
||||
}
|
||||
if (name=="/save_brain") {
|
||||
save_source(cmd.get_string(0));
|
||||
}
|
||||
}
|
||||
usleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void process_thread::load_source(const std::string &filename) {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
ifstream ifs(filename.c_str(),ios::binary);
|
||||
ifs||m_source;
|
||||
ifs.close();
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
}
|
||||
|
||||
void process_thread::load_target(const std::string &filename) {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
ifstream ifs(filename.c_str(),ios::binary);
|
||||
ifs||m_target;
|
||||
ifs.close();
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
}
|
||||
|
||||
void process_thread::save_source(const std::string &filename) {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
ofstream ofs(filename.c_str(),ios::binary);
|
||||
ofs||m_source;
|
||||
ofs.close();
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
}
|
||||
|
||||
void process_thread::save_target(const std::string &filename) {
|
||||
pthread_mutex_lock(m_brain_mutex);
|
||||
ofstream ofs(filename.c_str(),ios::binary);
|
||||
ofs||m_target;
|
||||
ofs.close();
|
||||
pthread_mutex_unlock(m_brain_mutex);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "jellyfish/fluxa/OSC_server.h"
|
||||
#include "brain.h"
|
||||
#include "renderer.h"
|
||||
#include <pthread.h>
|
||||
|
||||
#pragma once
|
||||
@ -27,11 +28,20 @@ public:
|
||||
process_thread();
|
||||
~process_thread();
|
||||
|
||||
brain m_source, m_target;
|
||||
pthread_mutex_t* m_brain_mutex;
|
||||
|
||||
void register_renderer(renderer *p) { m_renderer=p; }
|
||||
|
||||
void process();
|
||||
|
||||
void load_source(const std::string &filename);
|
||||
void load_target(const std::string &filename);
|
||||
void save_source(const std::string &filename);
|
||||
void save_target(const std::string &filename);
|
||||
|
||||
// only for use in mutex
|
||||
brain m_source, m_target;
|
||||
|
||||
private:
|
||||
OSC_server m_osc;
|
||||
u32 m_source_block_size;
|
||||
@ -41,6 +51,9 @@ private:
|
||||
window::type m_window_type;
|
||||
window::type m_target_window_type;
|
||||
pthread_t *m_thread;
|
||||
|
||||
// only use in mutex obvs...
|
||||
renderer *m_renderer;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ int main( int argc , char *argv[] ){
|
||||
|
||||
process_thread pt;
|
||||
audio_thread at(pt);
|
||||
pt.register_renderer(at.m_renderer);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ block::block(const string &filename, const sample &pcm, u32 rate, const window &
|
||||
|
||||
// rerun the normalised version
|
||||
normalise(m_n_pcm);
|
||||
w.run(m_n_pcm);
|
||||
process(m_n_pcm,m_n_fft,m_n_mfcc);
|
||||
|
||||
if (ditchpcm) {
|
||||
@ -180,8 +181,24 @@ double block::compare(const block &other, const search_params ¶ms) const {
|
||||
other.m_usage, params.m_usage_importance);
|
||||
}
|
||||
|
||||
ios &spiralcore::operator||(ios &s, block &b) {
|
||||
u32 version=1;
|
||||
string id("block");
|
||||
s||id||version;
|
||||
|
||||
s||b.m_pcm||b.m_fft||b.m_mfcc;
|
||||
s||b.m_n_pcm||b.m_n_fft||b.m_n_mfcc;
|
||||
|
||||
s||b.m_block_size||b.m_rate||b.m_orig_filename;
|
||||
stream_vector(s,b.m_synapse);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
bool block::unit_test() {
|
||||
|
||||
stream_unit_test();
|
||||
|
||||
sample ntest(3);
|
||||
u32 idx=0;
|
||||
ntest[idx++]=-1;
|
||||
@ -228,6 +245,25 @@ bool block::unit_test() {
|
||||
assert(bb.m_rate==44100);
|
||||
assert(bb.m_block_size==data.get_length());
|
||||
|
||||
ofstream of("test_data/blocktest.bin",ios::binary);
|
||||
of||bb;
|
||||
of.close();
|
||||
|
||||
cerr<<"written"<<endl;
|
||||
|
||||
ifstream ifs("test_data/blocktest.bin",ios::binary);
|
||||
block bbb;
|
||||
ifs||bbb;
|
||||
ifs.close();
|
||||
|
||||
assert(bbb.m_pcm.get_length()==data.get_length());
|
||||
//assert(bb.m_fft.get_length()==data.get_length());
|
||||
assert(bbb.m_mfcc.get_length()==MFCC_FILTERS);
|
||||
assert(bbb.m_orig_filename==string("test"));
|
||||
assert(bbb.m_rate==44100);
|
||||
assert(bbb.m_block_size==data.get_length());
|
||||
|
||||
|
||||
search_params p(0,0,0,100,0);
|
||||
block bb2("test",data,44100,w);
|
||||
assert(bb.compare(bb2,p)==0);
|
||||
@ -238,7 +274,7 @@ bool block::unit_test() {
|
||||
|
||||
sample data2(200);
|
||||
for (u32 i=0; i<data.get_length(); i++) {
|
||||
data[i]=i%10;
|
||||
data2[i]=i%10;
|
||||
}
|
||||
|
||||
block cpy("test",data,100,w);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mfcc.h"
|
||||
#include "search_params.h"
|
||||
#include "window.h"
|
||||
#include "jellyfish/core/stream.h"
|
||||
|
||||
#ifndef BLOCK
|
||||
#define BLOCK
|
||||
@ -32,6 +33,7 @@ class block {
|
||||
public:
|
||||
// runs analysis on pcm
|
||||
block(const std::string &filename, const sample &pcm, u32 rate, const window &w, bool ditchpcm=false);
|
||||
block() {}
|
||||
|
||||
// returns distance based on ratio of fft-mfcc values
|
||||
double compare(const block &other, const search_params ¶ms) const;
|
||||
@ -71,8 +73,12 @@ private:
|
||||
std::vector<u32> m_synapse;
|
||||
float m_usage;
|
||||
|
||||
friend ios &operator||(ios &s, block &b);
|
||||
|
||||
};
|
||||
|
||||
ios &operator||(ios &s, block &b);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,9 @@
|
||||
using namespace std;
|
||||
using namespace spiralcore;
|
||||
|
||||
static const u32 NUM_FIXED_SYNAPSES = 1000;
|
||||
static const double usage_factor = 1000000;
|
||||
|
||||
brain::brain() :
|
||||
m_current_block_index(0),
|
||||
m_average_error(0),
|
||||
@ -89,8 +92,6 @@ const block &brain::get_block(u32 index) const {
|
||||
return m_blocks[index];
|
||||
}
|
||||
|
||||
static const double usage_factor = 1000000;
|
||||
|
||||
// returns index to block
|
||||
u32 brain::search(const block &target, const search_params ¶ms) {
|
||||
double closest = FLT_MAX;
|
||||
@ -129,6 +130,7 @@ u32 brain::rev_search(const block &target, const search_params ¶ms) {
|
||||
return furthest_index;
|
||||
}
|
||||
|
||||
// really slow - every to every comparison of blocks calculating average distance
|
||||
double brain::calc_average_diff(search_params ¶ms) {
|
||||
double diff=0;
|
||||
for (vector<block>::const_iterator i=m_blocks.begin(); i!=m_blocks.end(); ++i) {
|
||||
@ -140,16 +142,17 @@ double brain::calc_average_diff(search_params ¶ms) {
|
||||
return diff;
|
||||
}
|
||||
|
||||
void brain::build_synapses(search_params ¶ms, double thresh) {
|
||||
void brain::build_synapses_thresh(search_params ¶ms, double thresh) {
|
||||
m_average_error = calc_average_diff(params)*thresh;
|
||||
double err=m_average_error*thresh;
|
||||
double err = m_average_error*thresh;
|
||||
u32 brain_size = m_blocks.size();
|
||||
u32 outer_index=0;
|
||||
u32 outer_index = 0;
|
||||
for (vector<block>::iterator i=m_blocks.begin(); i!=m_blocks.end(); ++i) {
|
||||
u32 index = 0;
|
||||
status::update("building synapses %d%%",(int)(outer_index/(float)brain_size*100));
|
||||
for (vector<block>::const_iterator j=m_blocks.begin(); j!=m_blocks.end(); ++j) {
|
||||
if (index!=outer_index) {
|
||||
// collect connections that are under threshold in closeness
|
||||
double diff = i->compare(*j,params);
|
||||
if (diff<err) {
|
||||
i->get_synapse().push_back(index);
|
||||
@ -161,21 +164,83 @@ void brain::build_synapses(search_params ¶ms, double thresh) {
|
||||
}
|
||||
}
|
||||
|
||||
void brain::build_synapses_fixed(search_params ¶ms) {
|
||||
//m_average_error = calc_average_diff(params)*thresh;
|
||||
u32 brain_size = m_blocks.size();
|
||||
u32 outer_index = 0;
|
||||
u32 num_synapses = NUM_FIXED_SYNAPSES;
|
||||
if (num_synapses>=m_blocks.size()) num_synapses=m_blocks.size()-1;
|
||||
|
||||
for (vector<block>::iterator i=m_blocks.begin(); i!=m_blocks.end(); ++i) {
|
||||
status::update("building synapses %d%%",(int)(outer_index/(float)brain_size*100));
|
||||
u32 index = 0;
|
||||
vector<pair<int,double>> collect;
|
||||
|
||||
// collect comparisons to all other blocks
|
||||
for (vector<block>::const_iterator j=m_blocks.begin(); j!=m_blocks.end(); ++j) {
|
||||
assert(index<m_blocks.size());
|
||||
if (index!=outer_index) {
|
||||
double diff = i->compare(*j,params);
|
||||
collect.push_back(pair<int,double>(index,diff));
|
||||
}
|
||||
++index;
|
||||
}
|
||||
|
||||
// sort them by closeness
|
||||
sort(collect.begin(),collect.end(),
|
||||
[](const pair<int,double> &a,
|
||||
const pair<int,double> &b) -> bool {
|
||||
return a.second<b.second;
|
||||
});
|
||||
|
||||
|
||||
// add the closest ones to the list
|
||||
for(u32 n=0; n<num_synapses; ++n) {
|
||||
assert(collect[n].first<m_blocks.size());
|
||||
|
||||
i->get_synapse().push_back(collect[n].first);
|
||||
}
|
||||
|
||||
++outer_index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brain::jiggle() {
|
||||
if (m_blocks.size()>0) {
|
||||
m_current_block_index=rand()%m_blocks.size();
|
||||
} else {
|
||||
m_current_block_index=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 brain::search_synapses(const block &target, search_params ¶ms) {
|
||||
const block ¤t = get_block(m_current_block_index);
|
||||
double closest = DBL_MAX;
|
||||
u32 closest_index = 0;
|
||||
// find nearest in synaptic connections
|
||||
if (current.get_synapse_const().size()<params.m_num_synapses) {
|
||||
params.m_num_synapses = current.get_synapse_const().size()-1;
|
||||
}
|
||||
assert(current.get_synapse_const().size()>params.m_num_synapses);
|
||||
|
||||
u32 synapse_count=0;
|
||||
// use m_num_synapses to restrict search
|
||||
// only makes sense when ordered by closeness in fixed mode
|
||||
vector<u32>::const_iterator i=current.get_synapse_const().begin();
|
||||
while (i!=current.get_synapse_const().end() &&
|
||||
synapse_count<params.m_num_synapses) {
|
||||
assert(*i<m_blocks.size());
|
||||
|
||||
// cerr<<"searching "<<current.get_synapse_const().size()<<" connections"<<endl;
|
||||
for (vector<u32>::const_iterator i=current.get_synapse_const().begin();
|
||||
i!=current.get_synapse_const().end(); ++i) {
|
||||
const block &other = get_block(*i);
|
||||
double diff = target.compare(other,params);
|
||||
if (diff<closest) {
|
||||
closest=diff;
|
||||
closest_index = *i;
|
||||
}
|
||||
++i;
|
||||
++synapse_count;
|
||||
}
|
||||
|
||||
deplete_usage();
|
||||
@ -223,6 +288,24 @@ void brain::deplete_usage() {
|
||||
}
|
||||
*/
|
||||
|
||||
ios &spiralcore::operator||(ios &s, brain::sound &b) {
|
||||
u32 version=0;
|
||||
string id("brain::sound");
|
||||
s||id||version;
|
||||
s||b.m_filename||b.m_sample;
|
||||
}
|
||||
|
||||
ios &spiralcore::operator||(ios &s, brain &b) {
|
||||
u32 version=0;
|
||||
string id("brain");
|
||||
s||id||version;
|
||||
stream_vector(s,b.m_blocks);
|
||||
stream_list(s,b.m_samples);
|
||||
s||b.m_block_size||b.m_overlap||b.m_window;
|
||||
s||b.m_current_block_index||b.m_current_error||
|
||||
b.m_average_error||b.m_usage_falloff;
|
||||
}
|
||||
|
||||
bool brain::unit_test() {
|
||||
brain b;
|
||||
assert(b.m_samples.size()==0);
|
||||
@ -258,6 +341,27 @@ bool brain::unit_test() {
|
||||
assert(b3.search(b2.m_blocks[19],p)==19);
|
||||
assert(b3.search(b2.m_blocks[29],p)==29);
|
||||
|
||||
|
||||
ofstream of("test_data/test.brain",ios::binary);
|
||||
of||b3;
|
||||
of.close();
|
||||
|
||||
brain b4;
|
||||
ifstream ifs("test_data/test.brain",ios::binary);
|
||||
ifs||b4;
|
||||
ifs.close();
|
||||
|
||||
assert(b3.m_samples.size()==b4.m_samples.size());
|
||||
assert(b3.m_blocks.size()==b4.m_blocks.size());
|
||||
|
||||
assert(b4.search(b2.m_blocks[0],p)==0);
|
||||
assert(b4.search(b2.m_blocks[9],p)==9);
|
||||
assert(b4.search(b2.m_blocks[19],p)==19);
|
||||
assert(b4.search(b2.m_blocks[29],p)==29);
|
||||
|
||||
|
||||
cerr<<"!!!"<<endl;
|
||||
|
||||
// sample r = b2.resynth(b,1);
|
||||
// assert(r.get_length()==200);
|
||||
|
||||
|
@ -35,11 +35,16 @@ public:
|
||||
// rewrites whole brain
|
||||
void init(u32 block_size, u32 overlap, window::type t, bool ditchpcm=false);
|
||||
|
||||
// randomise the synaptic pointer
|
||||
void jiggle();
|
||||
|
||||
class sound {
|
||||
public:
|
||||
sound(const std::string &name, const sample &sample) :
|
||||
m_filename(name), m_sample(sample) {}
|
||||
|
||||
sound() {}; // needed for streaming
|
||||
|
||||
std::string m_filename;
|
||||
sample m_sample;
|
||||
};
|
||||
@ -68,12 +73,15 @@ public:
|
||||
|
||||
// synaptic search
|
||||
double calc_average_diff(search_params ¶ms);
|
||||
void build_synapses(search_params ¶ms, double threshold);
|
||||
void build_synapses_thresh(search_params ¶ms, double threshold);
|
||||
void build_synapses_fixed(search_params ¶ms);
|
||||
u32 search_synapses(const block &target, search_params ¶ms);
|
||||
double get_current_error() { return m_current_error/m_average_error; }
|
||||
|
||||
static bool unit_test();
|
||||
|
||||
friend ios &operator||(ios &s, brain &b);
|
||||
|
||||
private:
|
||||
|
||||
void chop_and_add(const sample &s, u32 count, bool ditchpcm=false);
|
||||
@ -93,6 +101,9 @@ private:
|
||||
float m_usage_falloff;
|
||||
};
|
||||
|
||||
ios &operator||(ios &s, brain::sound &b);
|
||||
ios &operator||(ios &s, brain &b);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -38,8 +38,6 @@ void unit_test() {
|
||||
cerr<<"testing renderer"<<endl;
|
||||
if (renderer::unit_test()) cerr<<"passed"<<endl;
|
||||
else cerr<<"failed"<<endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
audio_device *a = NULL;
|
||||
@ -56,45 +54,61 @@ void run_audio(void* c, unsigned int frames) {
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unit_test();
|
||||
// unit_test();
|
||||
u32 len=1000;
|
||||
search_params p(0.5,0,0,99,0);
|
||||
|
||||
cerr<<"starting"<<endl;
|
||||
brain source, target;
|
||||
/* {
|
||||
brain source;
|
||||
// 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/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/claps.wav");
|
||||
// source.load_sound("../sound/source/eagle.wav");
|
||||
// source.load_sound("../sound/source/rise.wav");
|
||||
// source.load_sound("../sound/source/totalsine.wav");
|
||||
// target.load_sound("../sound/source/apache.wav");
|
||||
|
||||
// source.load_sound("../sound/source/totalsine.wav");
|
||||
// source.load_sound("../sound/source/sailingbybit.wav");
|
||||
// source.load_sound("../sound/source/dreambit.wav");
|
||||
source.load_sound("../sound/source/KONG.WAV");
|
||||
source.load_sound("../sound/source/BIRD.WAV");
|
||||
source.load_sound("../sound/source/CCBEGIN.WAV");
|
||||
source.load_sound("../sound/source/cc-end.wav");
|
||||
source.load_sound("../sound/source/cc-extra.wav");
|
||||
source.load_sound("../sound/source/cc-high.wav");
|
||||
source.load_sound("../sound/source/cc-magic.wav");
|
||||
source.load_sound("../sound/source/cc-start.wav");
|
||||
source.load_sound("../sound/source/cc-warp.wav");
|
||||
|
||||
//target.load_sound("../sound/source/sailingbybit.wav");
|
||||
|
||||
target.load_sound("../sound/source/apache.wav");
|
||||
//target.load_sound("../sound/source/dreambit.wav");
|
||||
|
||||
//target.load_sound("../sound/source/sb-left.wav");
|
||||
//target.load_sound("../sound/source/rise.wav");
|
||||
cerr<<"loaded sounds"<<endl;
|
||||
cerr<<endl;
|
||||
u32 len=3000;
|
||||
source.init(len,len-len,window::HANN);
|
||||
target.init(len,len-len/8,window::HANN);
|
||||
|
||||
cerr<<"synapse stuff"<<endl;
|
||||
cerr<<"synapse stuff"<<endl;
|
||||
cerr<<"synapse stuff"<<endl;
|
||||
|
||||
search_params p(0.5,0,0,99,0);
|
||||
source.build_synapses(p,0.9);
|
||||
source.build_synapses_fixed(p);
|
||||
source.set_usage_falloff(0.9);
|
||||
|
||||
ofstream of("8bit.brain",ios::binary);
|
||||
of||source;
|
||||
of.close();
|
||||
}
|
||||
*/
|
||||
|
||||
brain source;
|
||||
ifstream ifs("8bit.brain",ios::binary);
|
||||
ifs||source;
|
||||
ifs.close();
|
||||
|
||||
brain target;
|
||||
target.load_sound("../sound/source/apache.wav");
|
||||
//target.load_sound("../sound/source/pw2.wav");
|
||||
//target.load_sound("../sound/source/sailingbybit.wav");
|
||||
|
||||
target.init(len,len-len/8,window::HANN);
|
||||
|
||||
cerr<<"ready..."<<endl;
|
||||
cerr<<"we have "<<source.get_num_blocks()<<" brain blocks ("<<source.get_num_blocks()*len/44100.0<<" secs)"<<endl<<endl;
|
||||
|
||||
@ -104,8 +118,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
renderer rr(source,target);
|
||||
rr.set_playing(true);
|
||||
rr.get_params()->m_ratio=0.5;
|
||||
rr.get_params()->m_ratio=0;
|
||||
rr.get_params()->m_usage_importance=0.5;
|
||||
rr.get_params()->m_num_synapses=150;
|
||||
rr.set_slide_error(5.5);
|
||||
rr.set_search_algo(renderer::SYNAPTIC);
|
||||
|
||||
|
@ -43,6 +43,7 @@ void renderer::reset() {
|
||||
m_render_time=0;
|
||||
m_target_index=0;
|
||||
m_render_blocks.clear();
|
||||
m_source.jiggle();
|
||||
}
|
||||
|
||||
void renderer::process(u32 nframes, float *buf) {
|
||||
@ -170,8 +171,10 @@ bool renderer::unit_test() {
|
||||
|
||||
renderer rr(source,target);
|
||||
rr.set_playing(true);
|
||||
float *buf=new float[10];
|
||||
float *buf=new float[400];
|
||||
rr.process(10,buf);
|
||||
rr.process(10,buf);
|
||||
|
||||
assert(rr.m_render_blocks.size()==2);
|
||||
rr.process(10,buf);
|
||||
assert(rr.m_render_blocks.size()==2);
|
||||
@ -184,7 +187,10 @@ bool renderer::unit_test() {
|
||||
|
||||
target.init(10,5,window::RECTANGLE);
|
||||
rr.process(10,buf);
|
||||
assert(rr.m_render_blocks.size()==5);
|
||||
rr.process(10,buf);
|
||||
rr.process(10,buf);
|
||||
rr.process(10,buf);
|
||||
assert(rr.m_render_blocks.size()==4);
|
||||
delete[] buf;
|
||||
|
||||
}
|
||||
|
@ -26,13 +26,16 @@ public:
|
||||
m_n_ratio(n_ratio),
|
||||
m_fft1_start(s1),
|
||||
m_fft1_end(e1),
|
||||
m_usage_importance(usage_importance) {}
|
||||
m_usage_importance(usage_importance),
|
||||
m_num_synapses(20)
|
||||
{}
|
||||
|
||||
float m_ratio;
|
||||
float m_n_ratio;
|
||||
int m_fft1_start;
|
||||
int m_fft1_end;
|
||||
u32 m_fft1_start;
|
||||
u32 m_fft1_end;
|
||||
float m_usage_importance;
|
||||
u32 m_num_synapses;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -108,3 +108,25 @@ void window::run(const sample &input) const {
|
||||
input[n]*=(*m_windows[m_current_type])[n];
|
||||
}
|
||||
}
|
||||
|
||||
ios &spiralcore::operator||(ios &s, window &b) {
|
||||
u32 version=0;
|
||||
string id("window");
|
||||
s||id||version;
|
||||
s||b.m_current_type;
|
||||
std::ofstream *pos=dynamic_cast<std::ofstream*>(&s);
|
||||
if (pos!=NULL) {
|
||||
u32 size=0;
|
||||
// get the size from the first window
|
||||
if (b.m_windows.size()>0) {
|
||||
size=b.m_windows[0]->get_length();
|
||||
}
|
||||
s||size;
|
||||
} else {
|
||||
u32 size=0;
|
||||
s||size;
|
||||
// reinit using size if we are reading in
|
||||
b.init(size);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
void set_current_type(type t) { m_current_type=t; }
|
||||
void run(const sample &sample) const;
|
||||
|
||||
friend ios &operator||(ios &s, window &b);
|
||||
|
||||
private:
|
||||
void clear();
|
||||
|
||||
@ -53,6 +55,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
ios &operator||(ios &s, window &b);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
BIN
samplebrain/test_data/noise.wav
Normal file
BIN
samplebrain/test_data/noise.wav
Normal file
Binary file not shown.
BIN
samplebrain/test_data/up.wav
Normal file
BIN
samplebrain/test_data/up.wav
Normal file
Binary file not shown.
87
test.cpp
87
test.cpp
@ -4,6 +4,9 @@
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
class desc {
|
||||
@ -54,9 +57,89 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename T>ios &operator||(ios &s, T &v) {
|
||||
ofstream *pos=dynamic_cast<ofstream*>(&s);
|
||||
if (pos!=NULL) {
|
||||
ofstream &os = *pos;
|
||||
return os.write((char*)(&v),sizeof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
ifstream *pis=dynamic_cast<ifstream*>(&s);
|
||||
assert(pis);
|
||||
ifstream &is = *pis;
|
||||
return is.read((char *)(&v),sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>ios &stream_array(ios &s, T *v, size_t &len) {
|
||||
ofstream *pos=dynamic_cast<ofstream*>(&s);
|
||||
if (pos!=NULL) {
|
||||
ofstream &os = *pos;
|
||||
os||len;
|
||||
return os.write((char*)v,sizeof(T)*len);
|
||||
}
|
||||
else
|
||||
{
|
||||
ifstream *pis=dynamic_cast<ifstream*>(&s);
|
||||
assert(pis);
|
||||
ifstream &is = *pis;
|
||||
is||len;
|
||||
return is.read((char *)v,sizeof(T)*len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class sertest {
|
||||
public:
|
||||
sertest() {
|
||||
size = 100;
|
||||
buf = new float[size];
|
||||
}
|
||||
|
||||
void build() {
|
||||
for (unsigned int n=0; n<size; n++) {
|
||||
buf[n]=n;
|
||||
}
|
||||
}
|
||||
|
||||
float a;
|
||||
int c;
|
||||
float *buf;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
bool operator||(ios &s, sertest &v) {
|
||||
s||v.a||v.c;
|
||||
stream_array(s,v.buf,v.size);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
auto func = [] () { cout << "Hello world"; };
|
||||
func(); // now call the function
|
||||
|
||||
sertest ss;
|
||||
ss.a=100;
|
||||
ss.c=230;
|
||||
ss.build();
|
||||
|
||||
ofstream of("test.bin", ios::binary);
|
||||
of||ss;
|
||||
of.close();
|
||||
|
||||
sertest sb;
|
||||
ifstream inf("test.bin", ios::binary);
|
||||
inf||sb;
|
||||
inf.close();
|
||||
|
||||
cerr<<sb.a<<" "<<sb.c<<" "<<sb.buf[50]<<endl;
|
||||
|
||||
|
||||
// auto func = [] () { cout << "Hello world"; };
|
||||
// func(); // now call the function
|
||||
|
||||
/* test t=test(999);
|
||||
desc d;
|
||||
|
Loading…
x
Reference in New Issue
Block a user