diff options
Diffstat (limited to 'dgedit')
-rw-r--r-- | dgedit/canvastoollisten.cc | 14 | ||||
-rw-r--r-- | dgedit/canvastoollisten.h | 4 | ||||
-rw-r--r-- | dgedit/canvastoolselections.cc | 16 | ||||
-rw-r--r-- | dgedit/canvastoolselections.h | 6 | ||||
-rw-r--r-- | dgedit/mainwindow.cc | 26 |
5 files changed, 60 insertions, 6 deletions
diff --git a/dgedit/canvastoollisten.cc b/dgedit/canvastoollisten.cc index 4254137..f638f93 100644 --- a/dgedit/canvastoollisten.cc +++ b/dgedit/canvastoollisten.cc @@ -43,6 +43,8 @@ Player::Player(Canvas *c) sf.byte_format = AO_FMT_NATIVE; dev = ao_open_live(ao_default_driver_id(), &sf, 0); + + volume = 1000; } Player::~Player() @@ -57,7 +59,7 @@ void Player::run() if(playing) { short s[BUFSZ]; for(size_t i = 0; i < BUFSZ; i++) { - if(i + pos < canvas->size) s[i] = canvas->data[pos + i] * ((2<<16) - 1); + if(i + pos < canvas->size) s[i] = canvas->data[pos + i] * volume; else { s[i] = 0; playing = false; @@ -75,6 +77,11 @@ void Player::run() } } +void Player::setVolume(double v) +{ + volume = v; +} + CanvasToolListen::CanvasToolListen(Canvas *c) : player(c) { @@ -128,3 +135,8 @@ void CanvasToolListen::update() canvas->update(r); lastpos = pos; } + +void CanvasToolListen::setVolume(int v) +{ + player.setVolume(v); +} diff --git a/dgedit/canvastoollisten.h b/dgedit/canvastoollisten.h index 74a7831..090d83b 100644 --- a/dgedit/canvastoollisten.h +++ b/dgedit/canvastoollisten.h @@ -46,9 +46,12 @@ public: volatile bool playing; volatile size_t pos; + void setVolume(double v); + private: ao_device *dev; Canvas *canvas; + double volume; }; class CanvasToolListen : public CanvasTool { @@ -63,6 +66,7 @@ public: public slots: void update(); + void setVolume(int v); private: Canvas *canvas; diff --git a/dgedit/canvastoolselections.cc b/dgedit/canvastoolselections.cc index 35c8e05..5188cb0 100644 --- a/dgedit/canvastoolselections.cc +++ b/dgedit/canvastoolselections.cc @@ -194,6 +194,17 @@ void CanvasToolSelections::thresholdChanged(double t) threshold = t; } +void CanvasToolSelections::noiseFloorChanged(int t) +{ + double div = 666.0 / 0.00003; + noise_floor = (double)t/div; +} + +void CanvasToolSelections::fadeoutChanged(int t) +{ + fadeout = (double)t/1000.0; +} + void CanvasToolSelections::autoCreateSelections() { float *data = canvas->data; @@ -218,17 +229,16 @@ void CanvasToolSelections::autoCreateSelections() } int minsize = 100; // attack. - float minval = 0.00003; // noise floor int to = i; float runavg = fabs(data[from]); - while((runavg > minval || + while((runavg > noise_floor || to < from + minsize) && to < (int)size) { double p = 0.9; runavg = runavg * p + fabs(data[to]) * (1 - p); to++; } - _selections[from] = Selection(from, to, 2, (to - from) / 3); + _selections[from] = Selection(from, to, 2, ((to - from) / 3) * fadeout); i = to+1; } diff --git a/dgedit/canvastoolselections.h b/dgedit/canvastoolselections.h index a9e4d56..99114de 100644 --- a/dgedit/canvastoolselections.h +++ b/dgedit/canvastoolselections.h @@ -57,6 +57,8 @@ public slots: void autoCreateSelections(); void clearSelections(); void thresholdChanged(double threshold); + void noiseFloorChanged(int t); + void fadeoutChanged(int t); private: bool selection_is_moving_left; @@ -67,7 +69,9 @@ private: Canvas *canvas; double threshold; - + double noise_floor; + double fadeout; + QColor colSelBg; QColor colSel; QColor colActiveSelBg; diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index afa8a16..ada7f95 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -151,11 +151,35 @@ MainWindow::MainWindow() configs->addWidget(new QLabel("Attack length:")); QSlider *slider = new QSlider(Qt::Horizontal); - slider->setRange(10, 10000); + slider->setRange(10, 1000); slider->setValue(666); connect(slider, SIGNAL(sliderMoved(int)), sorter, SLOT(setAttackLength(int))); configs->addWidget(slider); + configs->addWidget(new QLabel("Falloff:")); + QSlider *slider2 = new QSlider(Qt::Horizontal); + slider2->setRange(1, 10000); + slider2->setValue(666); + connect(slider2, SIGNAL(sliderMoved(int)), + selections, SLOT(noiseFloorChanged(int))); + configs->addWidget(slider2); + + configs->addWidget(new QLabel("Fadelength:")); + QSlider *slider3 = new QSlider(Qt::Horizontal); + slider3->setRange(1, 2000); + slider3->setValue(666); + connect(slider3, SIGNAL(sliderMoved(int)), + selections, SLOT(fadeoutChanged(int))); + configs->addWidget(slider3); + + configs->addWidget(new QLabel("Player volume:")); + QSlider *slider4 = new QSlider(Qt::Horizontal); + slider4->setRange(0, 1000000); + slider4->setValue(100000); + connect(slider4, SIGNAL(sliderMoved(int)), + listen, SLOT(setVolume(int))); + configs->addWidget(slider4); + configs->addWidget(new QLabel("Prefix:")); QLineEdit *prefix = new QLineEdit(); connect(prefix, SIGNAL(textChanged(const QString &)), |