spek

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

commit 979862e2b9679b9ba222c2eae8724558b26fb53c
parent 08f651eadab1e74c11f87d51edf3d80699c32abb
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Thu, 20 Sep 2012 10:44:19 -0700

Support non-zero upper value in the dynamic range ruler

Diffstat:
Msrc/spek-ruler.cc | 17+++++++++--------
Msrc/spek-ruler.hh | 5+++--
Msrc/spek-spectrogram.cc | 5++++-
3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/spek-ruler.cc b/src/spek-ruler.cc @@ -22,11 +22,11 @@ SpekRuler::SpekRuler( int x, int y, Position pos, wxString sample_label, - int *factors, int units, double spacing, + int *factors, int min_units, int max_units, double spacing, double scale, double offset, formatter_cb formatter) : x(x), y(y), pos(pos), sample_label(sample_label), - factors(factors), units(units), spacing(spacing), + factors(factors), min_units(min_units), max_units(max_units), spacing(spacing), scale(scale), offset(offset), formatter(formatter) { } @@ -47,12 +47,12 @@ void SpekRuler::draw(wxDC& dc) } // Draw the ticks. - this->draw_tick(dc, 0); - this->draw_tick(dc, units); + this->draw_tick(dc, min_units); + this->draw_tick(dc, max_units); if (factor > 0) { - for (int tick = factor; tick < units; tick += factor) { - if (fabs(this->scale * (units - tick)) < len * 1.2) { + for (int tick = min_units + factor; tick < max_units; tick += factor) { + if (fabs(this->scale * (max_units - tick)) < len * 1.2) { break; } this->draw_tick(dc, tick); @@ -66,8 +66,9 @@ void SpekRuler::draw_tick(wxDC& dc, int tick) double TICK_LEN = 4; wxString label = this->formatter(tick); - int value = this->pos == TOP || this->pos == BOTTOM ? tick : this->units - tick; - double p = this->offset + this->scale * value; + int value = this->pos == TOP || this->pos == BOTTOM ? + tick : this->max_units + this->min_units - tick; + double p = this->offset + this->scale * (value - min_units); wxSize size = dc.GetTextExtent(label); int w = size.GetWidth(); int h = size.GetHeight(); diff --git a/src/spek-ruler.hh b/src/spek-ruler.hh @@ -37,7 +37,7 @@ public: SpekRuler( int x, int y, Position pos, wxString sample_label, - int *factors, int units, double spacing, + int *factors, int min_units, int max_units, double spacing, double scale, double offset, formatter_cb formatter ); @@ -51,7 +51,8 @@ protected: Position pos; wxString sample_label; int *factors; - int units; + int min_units; + int max_units; double spacing; double scale; double offset; diff --git a/src/spek-spectrogram.cc b/src/spek-spectrogram.cc @@ -282,6 +282,7 @@ void SpekSpectrogram::render(wxDC& dc) // TODO: i18n wxT("00:00"), time_factors, + 0, (int)this->duration, 1.5, (w - LPAD - RPAD) / this->duration, @@ -302,6 +303,7 @@ void SpekSpectrogram::render(wxDC& dc) // TRANSLATORS: keep "00" unchanged, it's used to calc the text width _("00 kHz"), freq_factors, + 0, freq, 3.0, (h - TPAD - BPAD) / (double)freq, @@ -332,7 +334,8 @@ void SpekSpectrogram::render(wxDC& dc) // TRANSLATORS: keep "-00" unchanged, it's used to calc the text width _("-00 dB"), density_factors, - this->urange - this->lrange, + -this->urange, + -this->lrange, 3.0, (h - TPAD - BPAD) / (double)(this->lrange - this->urange), h - TPAD - BPAD,