From f2bdcbb402e42998635102e01645d8f075a38c23 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 14 Mar 2008 00:37:31 -0500 Subject: [PATCH] Add logarithmic option --- Waveform.C | 7 +++++++ Waveform.H | 1 + 2 files changed, 8 insertions(+) diff --git a/Waveform.C b/Waveform.C index 50a43f4..66af80a 100644 --- a/Waveform.C +++ b/Waveform.C @@ -34,6 +34,7 @@ bool Waveform::fill = true; bool Waveform::outline = true; bool Waveform::vary_color = true; +bool Waveform::logarithmic = true; /* TODO: split the variations into separate functions. eg, plain, * outlined, filled, polygonal, rectified. */ @@ -68,6 +69,12 @@ Waveform::draw ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int chan p.max *= _scale; p.min *= _scale; + if ( Waveform::logarithmic ) + { + p.max = 10.0f * log10f( p.max ); + p.min = 10.0f * log10f( p.min ); + } + const float diff = fabs( p.max - p.min ); if ( diff > 2.0f ) diff --git a/Waveform.H b/Waveform.H index b29bfd3..08cfd65 100644 --- a/Waveform.H +++ b/Waveform.H @@ -34,6 +34,7 @@ public: static bool fill; static bool outline; static bool vary_color; + static bool logarithmic; static void draw ( int rx, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color );