Add peak hold to VU meter widget.
This commit is contained in:
parent
39549d1113
commit
b90a3ac6e5
|
@ -2,7 +2,8 @@
|
||||||
version 1.0108
|
version 1.0108
|
||||||
header_name {.H}
|
header_name {.H}
|
||||||
code_name {.C}
|
code_name {.C}
|
||||||
decl {\#include "VU_Meter.H"} {}
|
decl {\#include "VU_Meter.H"} {selected public global
|
||||||
|
}
|
||||||
|
|
||||||
widget_class Mixer_Strip {open
|
widget_class Mixer_Strip {open
|
||||||
xywh {1051 42 124 816} type Double box UP_FRAME color 32 selection_color 63 resizable
|
xywh {1051 42 124 816} type Double box UP_FRAME color 32 selection_color 63 resizable
|
||||||
|
@ -21,7 +22,7 @@ widget_class Mixer_Strip {open
|
||||||
} {
|
} {
|
||||||
Fl_Button {} {
|
Fl_Button {} {
|
||||||
label {@circle}
|
label {@circle}
|
||||||
private xywh {7 143 35 25} type Toggle
|
private xywh {7 143 35 25} type Toggle labelsize 10
|
||||||
}
|
}
|
||||||
Fl_Button {} {
|
Fl_Button {} {
|
||||||
label m
|
label m
|
||||||
|
@ -35,13 +36,13 @@ widget_class Mixer_Strip {open
|
||||||
Fl_Group {} {open
|
Fl_Group {} {open
|
||||||
xywh {13 178 104 509} resizable
|
xywh {13 178 104 509} resizable
|
||||||
} {
|
} {
|
||||||
Fl_Value_Slider {} {
|
Fl_Value_Slider gain {
|
||||||
label Gain
|
label Gain
|
||||||
callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );}
|
callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );}
|
||||||
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
|
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 {} {
|
Fl_Box meter {
|
||||||
label VU selected
|
label VU
|
||||||
xywh {57 193 55 484} box ROUNDED_BOX selection_color 88
|
xywh {57 193 55 484} box ROUNDED_BOX selection_color 88
|
||||||
class VU_Meter
|
class VU_Meter
|
||||||
}
|
}
|
||||||
|
|
23
VU_Meter.C
23
VU_Meter.C
|
@ -31,6 +31,8 @@ VU_Meter::VU_Meter ( int X, int Y, int W, int H, const char *L ) :
|
||||||
Fl_Widget( X, Y, W, H, L )
|
Fl_Widget( X, Y, W, H, L )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
_peak = 0.0f;
|
||||||
|
|
||||||
divisions( 32 );
|
divisions( 32 );
|
||||||
type( FL_VERTICAL );
|
type( FL_VERTICAL );
|
||||||
|
|
||||||
|
@ -53,6 +55,7 @@ VU_Meter::draw ( void )
|
||||||
// draw_box( FL_FLAT_BOX, x(), y(), w(), h(), color() );
|
// draw_box( FL_FLAT_BOX, x(), y(), w(), h(), color() );
|
||||||
|
|
||||||
int v = (value() / maximum()) * _divisions;
|
int v = (value() / maximum()) * _divisions;
|
||||||
|
int pv = (_peak / maximum()) * _divisions;
|
||||||
|
|
||||||
int bh = h() / _divisions;
|
int bh = h() / _divisions;
|
||||||
int bw = w() / _divisions;
|
int bw = w() / _divisions;
|
||||||
|
@ -61,7 +64,7 @@ VU_Meter::draw ( void )
|
||||||
{
|
{
|
||||||
Fl_Color c = fl_color_average( _max_color, _min_color, (float)p / _divisions );
|
Fl_Color c = fl_color_average( _max_color, _min_color, (float)p / _divisions );
|
||||||
|
|
||||||
if ( p > v )
|
if ( p > v && p != pv )
|
||||||
// c = fl_color_average( color(), c, _dim );
|
// c = fl_color_average( color(), c, _dim );
|
||||||
c = fl_color_average( FL_BLACK, c, _dim );
|
c = fl_color_average( FL_BLACK, c, _dim );
|
||||||
|
|
||||||
|
@ -72,6 +75,22 @@ VU_Meter::draw ( void )
|
||||||
draw_box( box(), x() + (p * bw), y(), bw, h(), c );
|
draw_box( box(), x() + (p * bw), y(), bw, h(), c );
|
||||||
else
|
else
|
||||||
draw_box( box(), x(), y() + h() - (p * bh), w(), bh, c );
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
class VU_Meter : public Fl_Widget
|
class VU_Meter : public Fl_Widget
|
||||||
{
|
{
|
||||||
|
|
||||||
|
float _peak;
|
||||||
|
|
||||||
float _value;
|
float _value;
|
||||||
float _minimum;
|
float _minimum;
|
||||||
float _maximum;
|
float _maximum;
|
||||||
|
@ -38,12 +40,12 @@ class VU_Meter : public Fl_Widget
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void draw ( void );
|
virtual void draw ( void );
|
||||||
|
virtual int handle ( int m );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VU_Meter ( int X, int Y, int W, int H, const char *L = 0 );
|
VU_Meter ( int X, int Y, int W, int H, const char *L = 0 );
|
||||||
|
|
||||||
|
|
||||||
void maximum( float v ) { _maximum = v; redraw(); }
|
void maximum( float v ) { _maximum = v; redraw(); }
|
||||||
float maximum ( void ) const { return _maximum; }
|
float maximum ( void ) const { return _maximum; }
|
||||||
|
|
||||||
|
@ -53,6 +55,8 @@ public:
|
||||||
void value ( float v ) { _value = v; redraw(); }
|
void value ( float v ) { _value = v; redraw(); }
|
||||||
float value ( void ) const { return _value; }
|
float value ( void ) const { return _value; }
|
||||||
|
|
||||||
|
void reset ( void ) { _peak = 0.0f; }
|
||||||
|
|
||||||
bool divisions ( void ) const { return _divisions; }
|
bool divisions ( void ) const { return _divisions; }
|
||||||
void divisions ( int v ) { _divisions = v; }
|
void divisions ( int v ) { _divisions = v; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue