Add a Meter base class, rename VU Meter to DPM.

This commit is contained in:
Jonathan Moore Liles 2008-03-12 11:05:36 -05:00
parent 43fe378e17
commit 0101ee43b9
4 changed files with 26 additions and 59 deletions

View File

@ -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;
}

View File

@ -21,15 +21,11 @@
#include <FL/Fl_Valuator.H> // 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; }

View File

@ -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

View File

@ -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 {} {