| @@ -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 <FL/Fl.H> | |||
| #include <FL/fl_draw.H> | |||
| 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; | |||
| } | |||
| @@ -21,14 +21,10 @@ | |||
| #include <FL/Fl_Valuator.H> // for FL_HORIZONTAL and FL_VERTICAL | |||
| class VU_Meter : public Fl_Widget | |||
| { | |||
| float _peak; | |||
| #include "Meter.H" | |||
| float _value; | |||
| float _minimum; | |||
| float _maximum; | |||
| class DPM : public Meter | |||
| { | |||
| int _type; | |||
| int _divisions; | |||
| @@ -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 ); | |||
| 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; } | |||
| DPM ( int X, int Y, int W, int H, const char *L = 0 ); | |||
| 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; } | |||
| @@ -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 | |||
| @@ -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 {} { | |||