Mixer: Add mute control to Gain module and Mute button to each mixer strip.

This commit is contained in:
Jonathan Moore Liles 2013-09-01 21:35:16 -07:00
parent 2cca17376a
commit e927781ee0
4 changed files with 55 additions and 13 deletions

View File

@ -395,9 +395,11 @@ Controller_Module::connect_to ( Port *p )
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
{
Fl_Light_Button *o = new Fl_Light_Button( 0, 0, 40, 40, p->name() );
Fl_Button *o = new Fl_Button( 0, 0, 40, 40, p->name() );
w = o;
o->type( FL_TOGGLE_BUTTON );
o->value( p->control_value() );
o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
_type = TOGGLE;
@ -487,7 +489,14 @@ Controller_Module::connect_to ( Port *p )
else
{
/* HACK: hide label */
if ( _type == TOGGLE )
{
w->align( FL_ALIGN_INSIDE );
}
else
{
w->labeltype( FL_NO_LABEL );
}
w->resize( x(), y(), this->w(), h() );
add( w );
resizable( w );

View File

@ -30,6 +30,7 @@ Gain_Module::Gain_Module ( )
add_port( Port( this, Port::INPUT, Port::AUDIO ) );
add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
{
Port p( this, Port::INPUT, Port::CONTROL, "Gain (dB)" );
p.hints.type = Port::Hints::LOGARITHMIC;
p.hints.ranged = true;
@ -41,6 +42,21 @@ Gain_Module::Gain_Module ( )
p.control_value( p.hints.default_value );
add_port( p );
}
{
Port p( this, Port::INPUT, Port::CONTROL, "Mute" );
p.hints.type = Port::Hints::BOOLEAN;
p.hints.ranged = true;
p.hints.minimum = 0.0f;
p.hints.maximum = 1.0f;
p.hints.default_value = 0.0f;
p.connect_to( new float );
p.control_value( p.hints.default_value );
add_port( p );
}
end();
@ -52,6 +68,7 @@ Gain_Module::Gain_Module ( )
Gain_Module::~Gain_Module ( )
{
delete (float*)control_input[0].buffer();
delete (float*)control_input[1].buffer();
log_destroy();
}
@ -88,7 +105,7 @@ Gain_Module::handle_sample_rate_change ( nframes_t n )
void
Gain_Module::process ( nframes_t nframes )
{
const float gt = DB_CO( control_input[0].control_value() );
const float gt = DB_CO( control_input[1].control_value() ? -90.f : control_input[0].control_value() );
sample_t gainbuf[nframes];
@ -96,7 +113,6 @@ Gain_Module::process ( nframes_t nframes )
if ( use_gainbuf )
{
for ( int i = audio_input.size(); i--; )
{
if ( audio_input[i].connected() && audio_output[i].connected() )

View File

@ -126,6 +126,7 @@ Mixer_Strip::get ( Log_Entry &e ) const
/* since the default controllers aren't logged, we have to store
* this setting as part of the mixer strip */
e.add( ":gain_mode", gain_controller->mode() );
e.add( ":mute_mode", mute_controller->mode() );
if ( ! _group->single() )
e.add( ":group", _group );
else
@ -164,6 +165,10 @@ Mixer_Strip::set ( Log_Entry &e )
{
_gain_controller_mode = atoi( v );
}
else if ( ! strcmp( s, ":mute_mode" ) )
{
_mute_controller_mode = atoi( v );
}
else if ( ! strcmp( s, ":group" ) )
{
int i;
@ -236,6 +241,7 @@ Mixer_Strip::chain ( Chain *c )
/* FIXME: don't hardcode this list of modules */
spatialization_controller->chain( c );
gain_controller->chain( c );
mute_controller->chain( c );
jack_input_controller->chain( c );
meter_indicator->chain( c );
}
@ -422,6 +428,8 @@ Mixer_Strip::handle_module_added ( Module *m )
{
gain_controller->connect_to( &m->control_input[0] );
gain_controller->mode( (Controller_Module::Mode)_gain_controller_mode );
mute_controller->connect_to( &m->control_input[1] );
mute_controller->mode( (Controller_Module::Mode)_mute_controller_mode );
}
else if ( 0 == strcmp( m->name(), "Meter" ) )
{
@ -459,6 +467,8 @@ Mixer_Strip::update ( void )
meter_indicator->update();
gain_controller->update();
mute_controller->update();
if ( _chain )
{
_chain->update();
@ -490,6 +500,7 @@ Mixer_Strip::init ( )
{
selection_color( FL_RED );
_mute_controller_mode = 0;
_gain_controller_mode = 0;
_chain = 0;
_group = 0;
@ -576,6 +587,10 @@ Mixer_Strip::init ( )
o->callback( ((Fl_Callback*)cb_handle), this );
o->when(FL_WHEN_RELEASE);
}
{ Controller_Module *o = mute_controller = new Controller_Module( true );
o->pad( false );
o->size( 45, 22 );
}
o->end();
}

View File

@ -91,6 +91,7 @@ private:
chain has been added and the controller connected to a default
module */
int _gain_controller_mode;
int _mute_controller_mode;
Fl_Flip_Button *width_button;
Fl_Flip_Button *tab_button;
@ -109,6 +110,7 @@ private:
Fl_Box *spatialization_label;
Controller_Module *gain_controller;
Controller_Module *mute_controller;
Controller_Module *jack_input_controller;
Controller_Module *spatialization_controller;
Meter_Indicator_Module *meter_indicator;