From 0101ee43b9b9fef0dcebc2adc1bc9ffe48b7d0f5 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 12 Mar 2008 11:05:36 -0500 Subject: [PATCH] Add a Meter base class, rename VU Meter to DPM. --- VU_Meter.C => DPM.C | 44 +++++++++++--------------------------------- VU_Meter.H => DPM.H | 29 +++++++++-------------------- Makefile | 6 +++--- Mixer_Strip.fl | 6 +++--- 4 files changed, 26 insertions(+), 59 deletions(-) rename VU_Meter.C => DPM.C (80%) rename VU_Meter.H => DPM.H (76%) diff --git a/VU_Meter.C b/DPM.C similarity index 80% rename from VU_Meter.C rename to DPM.C index 4fd347d..54cffc3 100644 --- a/VU_Meter.C +++ b/DPM.C @@ -17,22 +17,19 @@ /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*******************************************************************************/ -/* a VU meter, either horizontal or vertical. Color is a gradient - from min_color() to max_color(). box() is used to draw the +/* a Digital Peak Meter, either horizontal or vertical. Color is a + gradient from min_color() to max_color(). box() is used to draw the individual 'lights'. division() controls how many 'lights' there - are. */ + are. value() is volume in dBFS */ -#include "VU_Meter.H" +#include "DPM.H" #include #include -VU_Meter::VU_Meter ( int X, int Y, int W, int H, const char *L ) : - Fl_Widget( X, Y, W, H, L ) +DPM::DPM ( int X, int Y, int W, int H, const char *L ) : + Meter( X, Y, W, H, L ) { - - _peak = 0.0f; - divisions( 32 ); type( FL_VERTICAL ); @@ -42,19 +39,17 @@ VU_Meter::VU_Meter ( int X, int Y, int W, int H, const char *L ) : max_color( FL_RED ); box( FL_ROUNDED_BOX ); - - minimum( 0.0f ); - maximum( 1.0f ); - - value( 0.0f ); } +/* which marks to draw beside meter */ +const int marks [] = { -70, -50, -40, -30, -10, -3, 0, 4 }; + void -VU_Meter::draw ( void ) +DPM::draw ( void ) { // draw_box( FL_FLAT_BOX, x(), y(), w(), h(), color() ); int v = pos( value() ); - int pv = pos( _peak ); + int pv = pos( peak() ); int bh = h() / _divisions; int bw = w() / _divisions; @@ -75,21 +70,4 @@ VU_Meter::draw ( void ) else draw_box( box(), x(), y() + h() - (p * bh), w(), bh, c ); } - - if ( value() > _peak ) - _peak = value(); -} - - -int -VU_Meter::handle ( int m ) -{ - switch ( m ) - { - case FL_PUSH: - reset(); - break; - } - - return 0; } diff --git a/VU_Meter.H b/DPM.H similarity index 76% rename from VU_Meter.H rename to DPM.H index dfdaf85..9067381 100644 --- a/VU_Meter.H +++ b/DPM.H @@ -21,15 +21,11 @@ #include // for FL_HORIZONTAL and FL_VERTICAL -class VU_Meter : public Fl_Widget +#include "Meter.H" + +class DPM : public Meter { - float _peak; - - float _value; - float _minimum; - float _maximum; - int _type; int _divisions; float _dim; @@ -37,27 +33,20 @@ class VU_Meter : public Fl_Widget Fl_Color _min_color; Fl_Color _max_color; - int pos ( float v ) { return ( v / _maximum ) * _divisions; } + int pos ( float v ) + { + return deflection( v ) * _divisions; + } protected: virtual void draw ( void ); - virtual int handle ( int m ); public: - VU_Meter ( int X, int Y, int W, int H, const char *L = 0 ); + DPM ( int X, int Y, int W, int H, const char *L = 0 ); - void maximum( float v ) { _maximum = v; redraw(); } - float maximum ( void ) const { return _maximum; } - - void minimum ( float v ) { _minimum = v; redraw(); } - float minimum ( void ) const { return _minimum; } - - void value ( float v ) { if ( pos( v ) != pos( _value ) ) redraw(); _value = v; } - float value ( void ) const { return _value; } - - void reset ( void ) { _peak = 0.0f; } +// void value ( float v ) { if ( pos( v ) != pos( value() ) ) redraw(); Meter::value( v ) } bool divisions ( void ) const { return _divisions; } void divisions ( int v ) { _divisions = v; } diff --git a/Makefile b/Makefile index fd9e4d3..fdf58a6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CXXFLAGS=-ggdb -Wall -O0 +CXXFLAGS=-ggdb -Wall -O0 -fno-rtti -fno-exceptions #LIBS=-L/usr/lib/sox -I/usr/include/sox -lsox -lsfx LIBS=-lsndfile `fltk-config --ldflags` # CXXFLAGS=`fltk-config -cxxflags` @@ -26,8 +26,8 @@ $(OBJS): Makefile test: $(OBJS) $(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@ -mixer: Mixer_Strip.o Mixer.o - $(CXX) $(CXXFLAGS) $(LIBS) Mixer_Strip.o Mixer.o -o $@ +mixer: Mixer_Strip.o Mixer.o DPM.o + $(CXX) $(CXXFLAGS) $(LIBS) Mixer_Strip.o Mixer.o DPM.o -o $@ ESRCS=Audio_File.C Audio_File_SF.C Loggable.C diff --git a/Mixer_Strip.fl b/Mixer_Strip.fl index 121d0c7..2f89d59 100644 --- a/Mixer_Strip.fl +++ b/Mixer_Strip.fl @@ -2,7 +2,7 @@ version 1.0108 header_name {.H} code_name {.C} -decl {\#include "VU_Meter.H"} {selected public global +decl {\#include "DPM.H"} {public global } widget_class Mixer_Strip {open @@ -42,9 +42,9 @@ widget_class Mixer_Strip {open xywh {14 195 33 471} type {Vert Knob} color 32 selection_color 1 minimum 1.5 maximum 0 step 0.01 value 1 textsize 14 } Fl_Box meter { - label VU + label DPM selected xywh {57 193 55 484} box ROUNDED_BOX selection_color 88 - class VU_Meter + class DPM } } Fl_Box {} {