spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit e076119314a4b288c51720efe4e20af8c8f7ef9f
parent 1e5e93682451ddceae322f86ab5a33153038449a
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Wed, 19 Sep 2012 09:12:15 -0700

Re-start the pipeline when dynamic range is changed, closes #4

Diffstat:
Msrc/spek-spectrogram.cc | 16+++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/spek-spectrogram.cc b/src/spek-spectrogram.cc @@ -99,6 +99,7 @@ void SpekSpectrogram::open(const wxString& path) { this->path = path; start(); + Refresh(); } void SpekSpectrogram::save(const wxString& path) @@ -119,10 +120,17 @@ void SpekSpectrogram::on_char(wxKeyEvent& evt) bool up = evt.GetKeyCode() == WXK_UP; if (C && up) { + this->lrange = MIN(this->lrange + 1, this->urange - 1); } else if (C && dn) { + this->lrange = MAX(this->lrange - 1, MIN_RANGE); } else if (CS && up) { + this->urange = MIN(this->urange + 1, MAX_RANGE); } else if (CS && dn) { + this->urange = MAX(this->urange - 1, this->lrange + 1); } + + start(); + Refresh(); } void SpekSpectrogram::on_idle(wxIdleEvent& evt) @@ -143,7 +151,7 @@ void SpekSpectrogram::on_size(wxSizeEvent& evt) bool width_changed = this->prev_width != size.GetWidth(); this->prev_width = size.GetWidth(); - if (!this->path.IsEmpty() && width_changed) { + if (width_changed) { start(); } } @@ -347,6 +355,10 @@ static void pipeline_cb(int sample, float *values, void *cb_data) void SpekSpectrogram::start() { + if (this->path.IsEmpty()) { + return; + } + this->stop(); // The number of samples is the number of pixels available for the image. @@ -371,8 +383,6 @@ void SpekSpectrogram::start() } else { this->image.Create(1, 1); } - - Refresh(); } void SpekSpectrogram::stop()