spek

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

commit 1e5e93682451ddceae322f86ab5a33153038449a
parent c6dc7afcea9a7909ae03f038942ce986541ff56b
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Tue, 18 Sep 2012 22:37:49 -0700

Adjustable dynamic range

Diffstat:
Msrc/spek-spectrogram.cc | 19++++++++++++-------
Msrc/spek-spectrogram.hh | 2++
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/spek-spectrogram.cc b/src/spek-spectrogram.cc @@ -44,7 +44,10 @@ END_EVENT_TABLE() enum { - THRESHOLD = -92, + MAX_RANGE = 0, + MIN_RANGE = -140, + URANGE = -20, + LRANGE = -100, NFFT = 2048, BANDS = NFFT / 2 + 1, LPAD = 60, @@ -68,7 +71,9 @@ SpekSpectrogram::SpekSpectrogram(wxFrame *parent) : sample_rate(0), palette(RULER, BANDS), image(1, 1), - prev_width(-1) + prev_width(-1), + urange(URANGE), + lrange(LRANGE) { SetBackgroundStyle(wxBG_STYLE_CUSTOM); SetFocus(); @@ -155,10 +160,10 @@ void SpekSpectrogram::on_have_sample(SpekHaveSampleEvent& event) } // TODO: check image size, quit if wrong. - double range = log(1.0 - THRESHOLD); + double range = log(1.0 + this->urange - this->lrange); for (int y = 0; y < bands; y++) { - double value = MAX(THRESHOLD, values[y]); - double level = log(1.0 - THRESHOLD + value) / range; + double value = MIN(this->urange, MAX(this->lrange, values[y])); + double level = log(1.0 + value - this->lrange) / range; uint32_t color = spek_palette_spectrum(level); this->image.SetRGB( sample, @@ -323,9 +328,9 @@ void SpekSpectrogram::render(wxDC& dc) // TRANSLATORS: keep "-00" unchanged, it's used to calc the text width _("-00 dB"), density_factors, - -THRESHOLD, + this->urange - this->lrange, 3.0, - (h - TPAD - BPAD) / (double)THRESHOLD, + (h - TPAD - BPAD) / (double)(this->lrange - this->urange), h - TPAD - BPAD, density_formatter ); diff --git a/src/spek-spectrogram.hh b/src/spek-spectrogram.hh @@ -52,6 +52,8 @@ private: wxImage palette; wxImage image; int prev_width; + int urange; + int lrange; DECLARE_EVENT_TABLE() };