| @@ -692,9 +692,19 @@ Chain::handle ( int m ) | |||
| } | |||
| else if ( test_press( FL_BUTTON1 | FL_SHIFT ) ) | |||
| { | |||
| Module *mod = (Module*)Plugin_Module::pick_plugin(); | |||
| // Module *mod = (Module*)Plugin_Module::pick_plugin(); | |||
| Module *mod = Module::pick_module(); | |||
| if ( mod ) | |||
| { | |||
| if ( !strcmp( mod->name(), "JACK" ) ) | |||
| { | |||
| DMESSAGE( "Special casing JACK module" ); | |||
| JACK_Module *jm = (JACK_Module*)mod; | |||
| jm->chain( this ); | |||
| jm->configure_inputs( m->ninputs() ); | |||
| jm->configure_outputs( m->ninputs() ); | |||
| } | |||
| if ( ! insert( m, mod ) ) | |||
| fl_alert( "Cannot insert this module at this point in the chain" ); | |||
| redraw(); | |||
| @@ -27,6 +27,12 @@ | |||
| #include "Module_Parameter_Editor.H" | |||
| #include "Chain.H" | |||
| #include "JACK_Module.H" | |||
| #include "Gain_Module.H" | |||
| #include "Mono_Pan_Module.H" | |||
| #include "Meter_Module.H" | |||
| #include "Plugin_Module.H" | |||
| Module::Module ( int W, int H, const char *L ) : Fl_Group( 0, 0, W, H, L ) | |||
| @@ -307,6 +313,51 @@ Module::draw_label ( void ) | |||
| delete[] s; | |||
| } | |||
| #include <FL/Fl_Menu_Button.H> | |||
| Module * | |||
| Module::pick_module ( void ) | |||
| { | |||
| Fl_Menu_Button *menu = new Fl_Menu_Button( 0, 0, 400, 400 ); | |||
| menu->type( Fl_Menu_Button::POPUP3 ); | |||
| // menu->add( "JACK", 0, 0, (void*)1 ); | |||
| menu->add( "Gain", 0, 0, (void*)2 ); | |||
| menu->add( "Meter", 0, 0, (void*)3 ); | |||
| menu->add( "Mono Pan", 0, 0, (void*)4 ); | |||
| Plugin_Module::add_plugins_to_menu( menu ); | |||
| menu->popup(); | |||
| if ( menu->value() < 0 ) | |||
| return NULL; | |||
| void * v = menu->menu()[ menu->value() ].user_data(); | |||
| if ( ! v ) | |||
| return NULL; | |||
| switch ( (int)v ) | |||
| { | |||
| case 1: | |||
| return new JACK_Module(); | |||
| case 2: | |||
| return new Gain_Module(); | |||
| case 3: | |||
| return new Meter_Module(); | |||
| case 4: | |||
| return new Mono_Pan_Module(); | |||
| } | |||
| Plugin_Module::Plugin_Info *pi = (Plugin_Module::Plugin_Info*)v; | |||
| Plugin_Module *m = new Plugin_Module(); | |||
| m->load( pi->id ); | |||
| return m; | |||
| } | |||
| #include "FL/test_press.H" | |||
| int | |||
| @@ -310,6 +310,8 @@ public: | |||
| char *get_parameters ( void ) const; | |||
| void set_parameters ( const char * ); | |||
| static Module * pick_module ( void ); | |||
| virtual bool initialize ( void ) { return true; } | |||
| /* for the given number of inputs, return how many outputs this | |||
| @@ -107,6 +107,22 @@ Plugin_Module::set ( Log_Entry &e ) | |||
| #include <FL/Fl_Menu_Button.H> | |||
| void | |||
| Plugin_Module::add_plugins_to_menu ( Fl_Menu_Button *menu ) | |||
| { | |||
| Plugin_Module::Plugin_Info *pia = Plugin_Module::discover(); | |||
| char path[1024]; | |||
| for ( Plugin_Module::Plugin_Info *pi = pia; pi->path; ++pi ) | |||
| { | |||
| snprintf( path, sizeof( path ), "%s/%s", "Plugin", pi->path ); | |||
| menu->add(path, 0, NULL, pi, 0 ); | |||
| } | |||
| delete[] pia; | |||
| } | |||
| /* allow the user to pick a plugin */ | |||
| Plugin_Module * | |||
| Plugin_Module::pick_plugin ( void ) | |||
| @@ -22,7 +22,27 @@ | |||
| #include "Module.H" | |||
| #include "Loggable.H" | |||
| class Plugin_Module : Module { | |||
| class Fl_Menu_Button; | |||
| class Plugin_Module : public Module { | |||
| public: | |||
| struct Plugin_Info | |||
| { | |||
| const char *path; | |||
| unsigned long id; | |||
| Plugin_Info ( ) | |||
| { | |||
| path = 0; | |||
| id = 0; | |||
| } | |||
| }; | |||
| bool load ( unsigned long id ); | |||
| private: | |||
| void init ( void ); | |||
| @@ -48,21 +68,8 @@ class Plugin_Module : Module { | |||
| int _plugin_outs; | |||
| bool _crosswire; | |||
| struct Plugin_Info | |||
| { | |||
| const char *path; | |||
| unsigned long id; | |||
| Plugin_Info ( ) | |||
| { | |||
| path = 0; | |||
| id = 0; | |||
| } | |||
| }; | |||
| static Plugin_Info* discover ( void ); | |||
| bool load ( unsigned long id ); | |||
| void set_input_buffer ( int n, void *buf ); | |||
| void set_output_buffer ( int n, void *buf ); | |||
| @@ -82,6 +89,7 @@ public: | |||
| virtual ~Plugin_Module(); | |||
| static Plugin_Module * pick_plugin ( void ); | |||
| static void add_plugins_to_menu ( Fl_Menu_Button *menu ); | |||
| int plugin_ins ( void ) const { return _plugin_ins; } | |||
| int plugin_outs ( void ) const { return _plugin_outs; } | |||