From 60aaa8343c04908da31f031781ca16c01ab51049 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Wed, 2 Apr 2014 20:36:57 +0200 Subject: Added presets of slider values. --- dgedit/mainwindow.cc | 69 +++++++++++++++++++++++++++++++++++++--------------- dgedit/mainwindow.h | 17 +++++++++++++ dgedit/presets.ini | 12 +++++++++ 3 files changed, 79 insertions(+), 19 deletions(-) create mode 100644 dgedit/presets.ini diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index 30cd626..adf1321 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -39,10 +39,8 @@ #include #include #include -#include #include "canvastool.h" -#include "canvastoolselections.h" #include "canvastoolthreshold.h" #include "canvastoollisten.h" @@ -76,7 +74,7 @@ MainWindow::MainWindow() addTool(toolbar, canvas, listen); CanvasTool *threshold = new CanvasToolThreshold(canvas); addTool(toolbar, canvas, threshold); - CanvasTool *selections = new CanvasToolSelections(canvas); + selections = new CanvasToolSelections(canvas); connect(threshold, SIGNAL(thresholdChanged(double)), selections, SLOT(thresholdChanged(double))); addTool(toolbar, canvas, selections); @@ -152,28 +150,33 @@ MainWindow::MainWindow() configs->addLayout(btns); + configs->addWidget(new QLabel("Presets:")); + presets = new QComboBox(); + connect(presets, SIGNAL(currentIndexChanged(int)), this, SLOT(setPreset(int))); + configs->addWidget(presets); + configs->addWidget(new QLabel("Attack length:")); - QSlider *slider = new QSlider(Qt::Horizontal); - slider->setRange(10, 1000); - connect(slider, SIGNAL(sliderMoved(int)), sorter, SLOT(setAttackLength(int))); - slider->setValue(666); - configs->addWidget(slider); + slider_attacklength = new QSlider(Qt::Horizontal); + slider_attacklength->setRange(10, 1000); + connect(slider_attacklength, SIGNAL(sliderMoved(int)), sorter, SLOT(setAttackLength(int))); + slider_attacklength->setValue(666); + configs->addWidget(slider_attacklength); configs->addWidget(new QLabel("Falloff:")); - QSlider *slider2 = new QSlider(Qt::Horizontal); - slider2->setRange(1, 10000); - connect(slider2, SIGNAL(sliderMoved(int)), + slider_falloff = new QSlider(Qt::Horizontal); + slider_falloff->setRange(1, 10000); + connect(slider_falloff, SIGNAL(sliderMoved(int)), selections, SLOT(noiseFloorChanged(int))); - slider2->setValue(666); - configs->addWidget(slider2); + slider_falloff->setValue(666); + configs->addWidget(slider_falloff); configs->addWidget(new QLabel("Fadelength:")); - QSlider *slider3 = new QSlider(Qt::Horizontal); - slider3->setRange(1, 2000); - connect(slider3, SIGNAL(sliderMoved(int)), + slider_fadelength = new QSlider(Qt::Horizontal); + slider_fadelength->setRange(1, 2000); + connect(slider_fadelength, SIGNAL(sliderMoved(int)), selections, SLOT(fadeoutChanged(int))); - slider3->setValue(666); - configs->addWidget(slider3); + slider_fadelength->setValue(666); + configs->addWidget(slider_fadelength); configs->addWidget(new QLabel("Player volume:")); QSlider *slider4 = new QSlider(Qt::Horizontal); @@ -224,8 +227,24 @@ MainWindow::MainWindow() yoffset->setValue(MAXVAL/2); xscale->setValue(0); xoffset->setValue(0); - + loadSettings(); + + QSettings settings("presets.ini", QSettings::IniFormat); + QStringList list = settings.childGroups(); + for(int i = 0; i != list.size(); i++) { + QString presetname = list.at(i); + Preset p; + settings.beginGroup(presetname); + p.attacklength = settings.value("attacklength", 0).toInt(); + p.falloff = settings.value("falloff", 0).toInt(); + p.fadelength = settings.value("fadelength", 0).toInt(); + settings.endGroup(); + QVariant v; + v.setValue(p); + presets->addItem(presetname, v); + } + statusBar()->showMessage("Ready"); } @@ -302,3 +321,15 @@ void MainWindow::loadFile(QString filename) statusBar()->showMessage("Ready"); setCursor(Qt::ArrowCursor); } + +void MainWindow::setPreset(int index) +{ + QVariant v = presets->itemData(index); + Preset p = v.value(); + slider_attacklength->setValue(p.attacklength); + slider_falloff->setValue(p.falloff); + slider_fadelength->setValue(p.fadelength); +// sorter->setAttackLength(p.attacklength); +// selections->noiseFloorChanged(p.falloff); +// selections->fadeoutChanged(p.fadeout); +} diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h index f6fff27..c358d3c 100644 --- a/dgedit/mainwindow.h +++ b/dgedit/mainwindow.h @@ -29,11 +29,22 @@ #include #include +#include +#include #include "canvas.h" #include "audioextractor.h" #include "samplesorter.h" #include "filelist.h" +#include "canvastoolselections.h" + +class Preset { +public: + int attacklength; + int falloff; + int fadelength; +}; +Q_DECLARE_METATYPE(Preset) class MainWindow : public QMainWindow { Q_OBJECT @@ -47,6 +58,7 @@ public slots: void setYOffset(int); void doExport(); void loadFile(QString filename); + void setPreset(int); protected: void closeEvent(QCloseEvent*); @@ -57,12 +69,17 @@ private: SampleSorter *sorter; Canvas *canvas; + CanvasToolSelections *selections; AudioExtractor *extractor; FileList *filelist; QScrollBar *yoffset; QScrollBar *yscale; QScrollBar *xscale; QScrollBar *xoffset; + QComboBox *presets; + QSlider *slider_attacklength; + QSlider *slider_falloff; + QSlider *slider_fadelength; }; #endif/*__DRUMGIZMO_MAINWINDOW_H__*/ diff --git a/dgedit/presets.ini b/dgedit/presets.ini new file mode 100644 index 0000000..4ef75ee --- /dev/null +++ b/dgedit/presets.ini @@ -0,0 +1,12 @@ +[Snare] + attacklength = 1 + falloff = 2 + fadelength = 3 +[Tom] + attacklength = 10 + falloff = 20 + fadelength = 30 +[Kickdrum] + attacklength = 100 + falloff = 200 + fadelength = 300 -- cgit v1.2.3 From e9720cba4e117dc26da46b0a72b56a576a950e17 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Wed, 2 Apr 2014 20:41:14 +0200 Subject: Updating prefix lineedit on presets change. --- dgedit/mainwindow.cc | 5 +++-- dgedit/mainwindow.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index adf1321..2799fdf 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -187,7 +186,7 @@ MainWindow::MainWindow() configs->addWidget(slider4); configs->addWidget(new QLabel("Prefix:")); - QLineEdit *prefix = new QLineEdit(); + prefix = new QLineEdit(); connect(prefix, SIGNAL(textChanged(const QString &)), extractor, SLOT(setOutputPrefix(const QString &))); prefix->setText("kick-r"); @@ -236,6 +235,7 @@ MainWindow::MainWindow() QString presetname = list.at(i); Preset p; settings.beginGroup(presetname); + p.name = presetname; p.attacklength = settings.value("attacklength", 0).toInt(); p.falloff = settings.value("falloff", 0).toInt(); p.fadelength = settings.value("fadelength", 0).toInt(); @@ -329,6 +329,7 @@ void MainWindow::setPreset(int index) slider_attacklength->setValue(p.attacklength); slider_falloff->setValue(p.falloff); slider_fadelength->setValue(p.fadelength); + prefix->setText(p.name); // sorter->setAttackLength(p.attacklength); // selections->noiseFloorChanged(p.falloff); // selections->fadeoutChanged(p.fadeout); diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h index c358d3c..efdce99 100644 --- a/dgedit/mainwindow.h +++ b/dgedit/mainwindow.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "canvas.h" #include "audioextractor.h" @@ -40,6 +41,7 @@ class Preset { public: + QString name; int attacklength; int falloff; int fadelength; @@ -80,6 +82,7 @@ private: QSlider *slider_attacklength; QSlider *slider_falloff; QSlider *slider_fadelength; + QLineEdit *prefix; }; #endif/*__DRUMGIZMO_MAINWINDOW_H__*/ -- cgit v1.2.3 From d8053dd8e6d38165d9ac6a689081bc4a753ff7ad Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Wed, 2 Apr 2014 20:46:57 +0200 Subject: Added prefix name to presets.ini. --- dgedit/mainwindow.cc | 4 ++-- dgedit/mainwindow.h | 2 +- dgedit/presets.ini | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index 2799fdf..3436c25 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -235,7 +235,7 @@ MainWindow::MainWindow() QString presetname = list.at(i); Preset p; settings.beginGroup(presetname); - p.name = presetname; + p.prefix = settings.value("prefix", "unknown").toString(); p.attacklength = settings.value("attacklength", 0).toInt(); p.falloff = settings.value("falloff", 0).toInt(); p.fadelength = settings.value("fadelength", 0).toInt(); @@ -329,7 +329,7 @@ void MainWindow::setPreset(int index) slider_attacklength->setValue(p.attacklength); slider_falloff->setValue(p.falloff); slider_fadelength->setValue(p.fadelength); - prefix->setText(p.name); + prefix->setText(p.prefix); // sorter->setAttackLength(p.attacklength); // selections->noiseFloorChanged(p.falloff); // selections->fadeoutChanged(p.fadeout); diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h index efdce99..fd4af57 100644 --- a/dgedit/mainwindow.h +++ b/dgedit/mainwindow.h @@ -41,7 +41,7 @@ class Preset { public: - QString name; + QString prefix; int attacklength; int falloff; int fadelength; diff --git a/dgedit/presets.ini b/dgedit/presets.ini index 4ef75ee..6434f05 100644 --- a/dgedit/presets.ini +++ b/dgedit/presets.ini @@ -1,12 +1,15 @@ -[Snare] +[Bright snare] + prefix = "Snare" attacklength = 1 falloff = 2 fadelength = 3 -[Tom] +[Tommy gun] + prefix = "Tom" attacklength = 10 falloff = 20 fadelength = 30 [Kickdrum] + prefix = "Kickass" attacklength = 100 falloff = 200 fadelength = 300 -- cgit v1.2.3