From 18a1429b225a2b8c3d879c4794b3a3926725adec Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 9 Feb 2012 00:19:00 -0800 Subject: [PATCH] Mixer: Create unique OSC paths even when multiple instances of a module/plugin with the same name exist in a chain. --- mixer/src/Chain.C | 17 +++++++++++++++++ mixer/src/Chain.H | 2 ++ mixer/src/Module.C | 9 ++++++++- mixer/src/Module.H | 5 +++++ mixer/src/Module_Parameter_Editor.C | 2 ++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mixer/src/Chain.C b/mixer/src/Chain.C index 15adc29..49db7da 100644 --- a/mixer/src/Chain.C +++ b/mixer/src/Chain.C @@ -357,6 +357,23 @@ Chain::configure_ports ( void ) parent()->redraw(); } +int +Chain::get_module_instance_number ( Module *m ) +{ + int n = 0; + + for ( int i = 0; i < modules(); ++i ) + { + if ( module(i) == m ) + break; + + if ( ! strcmp( module(i)->name(), m->name() ) ) + n++; + } + + return n; +} + /* calculate the minimum number of buffers required to satisfy this chain */ int Chain::required_buffers ( void ) diff --git a/mixer/src/Chain.H b/mixer/src/Chain.H index b28df80..a3a5778 100644 --- a/mixer/src/Chain.H +++ b/mixer/src/Chain.H @@ -89,6 +89,8 @@ public: const char *name ( void ) const { return _name; } void name ( const char *name ); + int get_module_instance_number ( Module *m ); + void configure_ports ( void ); int required_buffers ( void ); diff --git a/mixer/src/Module.C b/mixer/src/Module.C index 8e49631..a47e98d 100644 --- a/mixer/src/Module.C +++ b/mixer/src/Module.C @@ -200,7 +200,13 @@ Module::Port::generate_osc_path () char *path; // /mixer/strip/STRIPNAME/control/MODULENAME/CONTROLNAME - asprintf( &path, "/mixer/strip/%s/control/%s/%s", module()->chain()->name(), p->module()->label(), p->name() ); + + int n = module()->chain()->get_module_instance_number( module() ); + + if ( n > 0 ) + asprintf( &path, "/mixer/strip/%s/control/%s.%i/%s", module()->chain()->name(), p->module()->label(), n, p->name() ); + else + asprintf( &path, "/mixer/strip/%s/control/%s/%s", module()->chain()->name(), p->module()->label(), p->name() ); // asprintf( &path, "/mixer/strip/control/%s/%s", p->module()->label(), p->name() ); @@ -220,6 +226,7 @@ Module::Port::change_osc_path ( char *path ) if ( _osc_path ) { mixer->osc_endpoint->del_method( _osc_path, "f" ); + mixer->osc_endpoint->del_method( _osc_path_cv, "f" ); free( _osc_path ); free( _osc_path_cv ); diff --git a/mixer/src/Module.H b/mixer/src/Module.H index 14e8987..754b5c3 100644 --- a/mixer/src/Module.H +++ b/mixer/src/Module.H @@ -158,6 +158,11 @@ public: void buffer ( void *buf, nframes_t nframes ) { _buf = buf; _nframes = nframes; }; void *buffer ( void ) const { return _buf; } + const char *osc_path ( ) + { + return _osc_path; + } + void update_osc_port ( ) { if ( INPUT == _direction ) diff --git a/mixer/src/Module_Parameter_Editor.C b/mixer/src/Module_Parameter_Editor.C index a7911dd..f9dab01 100644 --- a/mixer/src/Module_Parameter_Editor.C +++ b/mixer/src/Module_Parameter_Editor.C @@ -245,6 +245,8 @@ Module_Parameter_Editor::make_controls ( void ) } + w->tooltip( p->osc_path() ); + Fl_Button *bound; w->align(FL_ALIGN_TOP);