From cff2c15583b4c5d3eaf56912b47c198c029f3d7b Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 10 Feb 2012 04:01:02 -0800 Subject: [PATCH] Mixer: Fix mirroring and OSC automation of Spatialization controls. --- mixer/src/Controller_Module.C | 2 ++ mixer/src/Module_Parameter_Editor.C | 39 +++++++++++++++++++++-------- mixer/src/Module_Parameter_Editor.H | 8 ++++++ 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/mixer/src/Controller_Module.C b/mixer/src/Controller_Module.C index 9b1235e..09d08c7 100644 --- a/mixer/src/Controller_Module.C +++ b/mixer/src/Controller_Module.C @@ -555,6 +555,8 @@ Controller_Module::handle_control_changed ( Port *p ) pan->point( 0 )->azimuth( control_output[0].control_value() ); pan->point( 0 )->elevation( control_output[1].control_value() ); + + pan->redraw(); } else { diff --git a/mixer/src/Module_Parameter_Editor.C b/mixer/src/Module_Parameter_Editor.C index f521b90..6a29ac4 100644 --- a/mixer/src/Module_Parameter_Editor.C +++ b/mixer/src/Module_Parameter_Editor.C @@ -117,8 +117,7 @@ Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_ Module_Parameter_Editor::~Module_Parameter_Editor ( ) { - - + controls_by_port.clear(); } @@ -130,14 +129,17 @@ Module_Parameter_Editor::make_controls ( void ) control_pack->clear(); + controls_by_port.clear(); /* these are for detecting related parameter groups which can be better represented by a single control */ - int azimuth_port_number = -1; + azimuth_port_number = -1; float azimuth_value = 0.0f; - int elevation_port_number = -1; + elevation_port_number = -1; float elevation_value = 0.0f; + controls_by_port.resize( module->control_input.size() ); + for ( unsigned int i = 0; i < module->control_input.size(); ++i ) { Fl_Widget *w; @@ -243,6 +245,7 @@ Module_Parameter_Editor::make_controls ( void ) } + controls_by_port[i] = w; w->tooltip( p->osc_path() ); @@ -309,6 +312,9 @@ Module_Parameter_Editor::make_controls ( void ) Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o ); control_pack->add( flg ); + + controls_by_port[azimuth_port_number] = o; + controls_by_port[elevation_port_number] = o; } @@ -387,21 +393,34 @@ void Module_Parameter_Editor::handle_control_changed ( Module::Port *p ) { int i = _module->control_input_port_index( p ); + + Fl_Widget *w = controls_by_port[i]; - /* FIXME: very hacky in that it assumes the control is an Fl_Valuator... (which buttons are not) */ - Fl_Group *g = (Fl_Group*)control_pack->child( i ); - Fl_Group *g2 = (Fl_Group*)g->child( 0 ); + if ( i == azimuth_port_number || + i == elevation_port_number ) + { + Panner *_panner = (Panner*)w; + + if ( i == azimuth_port_number ) + _panner->point(0)->azimuth( p->control_value() ); + else if ( i == elevation_port_number ) + _panner->point(0)->elevation( p->control_value() ); + + _panner->redraw(); + + return; + } if ( p->hints.type == Module::Port::Hints::BOOLEAN ) { - Fl_Button *v = (Fl_Button*)g2->child( 0 ); + Fl_Button *v = (Fl_Button*)w; v->value( p->control_value() ); - } + } else { - Fl_Valuator *v = (Fl_Valuator*)g2->child( 0 ); + Fl_Valuator *v = (Fl_Valuator*)w; v->value( p->control_value() ); } diff --git a/mixer/src/Module_Parameter_Editor.H b/mixer/src/Module_Parameter_Editor.H index 193f17f..c82b61d 100644 --- a/mixer/src/Module_Parameter_Editor.H +++ b/mixer/src/Module_Parameter_Editor.H @@ -25,6 +25,9 @@ class Fl_Pack; class Fl_Flowpack; class Module; class Fl_Menu_Button; +class Panner; + +#include class Module_Parameter_Editor : public Fl_Double_Window { @@ -66,6 +69,11 @@ class Module_Parameter_Editor : public Fl_Double_Window Fl_Menu_Button *mode_choice; bool _resized; + int azimuth_port_number; + int elevation_port_number; + + std::vector controls_by_port; + public: void handle_control_changed ( Module::Port *p );