diff --git a/libs/surfaces/console1/c1_control.h b/libs/surfaces/console1/c1_control.h index 2629c03e92..e1f377ecf1 100644 --- a/libs/surfaces/console1/c1_control.h +++ b/libs/surfaces/console1/c1_control.h @@ -4,66 +4,146 @@ #include "ardour/debug.h" #include "console1.h" -namespace ArdourSurface { +namespace Console1 +{ using ControllerID = Console1::ControllerID; class Controller { - public: - enum ControllerType - { - CONTROLLER, - CONTROLLER_BUTTON, - MULTISTATE_BUTTON, - ENCODER, - METER - }; +public: Controller (Console1* console1, ControllerID id) - : console1 (console1) - , _id (id) + : console1 (console1) + , _id (id) { } - virtual ~Controller () {} + Controller (Console1* console1, + ControllerID id, + std::function action, + std::function shift_action = 0, + std::function plugin_action = 0, + std::function plugin_shift_action = 0) + : console1 (console1) + , _id (id) + , action (action) + , shift_action (shift_action) + , plugin_action (plugin_action) + , plugin_shift_action (plugin_shift_action) + { + } - Console1* console1; - ControllerID id () const { return _id; } + virtual ~Controller () + { + } - virtual ControllerType get_type () { return CONTROLLER; } + Console1* console1; + ControllerID id () const + { + return _id; + } - protected: - ControllerID _id; + virtual void clear_value() {} + + virtual ControllerType get_type () + { + return CONTROLLER; + } + + void set_action (std::function new_action) + { + action = new_action; + } + + void set_plugin_action (std::function new_action) + { + plugin_action = new_action; + } + + void set_plugin_shift_action (std::function new_action) + { + plugin_shift_action = new_action; + } + std::function get_action (){ + return action; + } + std::function get_shift_action () + { + return shift_action; + } + + std::function get_plugin_action () + { + return plugin_action; + } + + std::function get_plugin_shift_action () + { + return plugin_shift_action; + } + +protected: + ControllerID _id; + std::function action; + std::function shift_action; + std::function plugin_action; + std::function plugin_shift_action; +}; + +class Encoder : public Controller +{ +public: + Encoder (Console1* console1, + ControllerID id, + std::function action, + std::function shift_action = 0, + std::function plugin_action = 0, + std::function plugin_shift_action = 0) + : Controller (console1, id, action, shift_action, plugin_action, plugin_shift_action) + { + console1->controllerMap.insert (std::make_pair (id, this)); + } + + ControllerType get_type () + { + return ENCODER; + } + + virtual void set_value (uint32_t value) + { + MIDI::byte buf[3]; + buf[0] = 0xB0; + buf[1] = _id; + buf[2] = value; + + console1->write (buf, 3); + } + + PBD::Signal* plugin_signal; }; class ControllerButton : public Controller { - public: - ControllerButton (Console1* console1, - ControllerID id, +public: + ControllerButton (Console1* console1, + ControllerID id, std::function action, - std::function shift_action = 0, - std::function plugin_action = 0, - std::function plugin_shift_action = 0 ) - : Controller (console1, id) - , action (action) - , shift_action (shift_action) - , plugin_action (plugin_action) - , plugin_shift_action (plugin_shift_action) + std::function shift_action = 0, + std::function plugin_action = 0, + std::function plugin_shift_action = 0) + : Controller (console1, id, action, shift_action, plugin_action, plugin_shift_action) { - console1->buttons.insert (std::make_pair (id, this)); + console1->controllerMap.insert (std::make_pair (id, this)); } - ControllerType get_type () { return CONTROLLER_BUTTON; } - - void set_action (std::function new_action) { action = new_action; } - void set_plugin_action (std::function new_action) { plugin_action = new_action; } - void set_plugin_shift_action (std::function new_action) { plugin_shift_action = new_action; } + ControllerType get_type () + { + return CONTROLLER_BUTTON; + } virtual void set_led_state (bool onoff) { - // DEBUG_TRACE(DEBUG::Console1, "ControllerButton::set_led_state ...\n"); MIDI::byte buf[3]; buf[0] = 0xB0; buf[1] = _id; @@ -74,7 +154,6 @@ class ControllerButton : public Controller virtual void set_led_value (uint32_t val) { - // DEBUG_TRACE(DEBUG::Console1, "ControllerButton::set_led_state ...\n"); MIDI::byte buf[3]; buf[0] = 0xB0; buf[1] = _id; @@ -82,34 +161,28 @@ class ControllerButton : public Controller console1->write (buf, 3); } - std::function action; - std::function shift_action; - std::function plugin_action; - std::function plugin_shift_action; }; class MultiStateButton : public Controller { - public: - MultiStateButton (Console1* console1, - ControllerID id, - std::vector state_values, +public: + MultiStateButton (Console1* console1, + ControllerID id, + std::vector state_values, std::function action, - std::function shift_action = 0, - std::function plugin_action = 0, - std::function plugin_shift_action = 0 - ) - : Controller (console1, id) - , action (action) - , shift_action (shift_action) - , plugin_action (action) - , plugin_shift_action (shift_action) - , state_values (state_values) + std::function shift_action = 0, + std::function plugin_action = 0, + std::function plugin_shift_action = 0) + : Controller (console1, id, action, shift_action, plugin_action, plugin_shift_action) + , state_values (state_values) { - console1->multi_buttons.insert (std::make_pair (id, this)); + console1->controllerMap.insert (std::make_pair (id, this)); } - ControllerType get_type () { return MULTISTATE_BUTTON; } + ControllerType get_type () + { + return MULTISTATE_BUTTON; + } virtual void set_led_state (uint32_t state) { @@ -123,36 +196,33 @@ class MultiStateButton : public Controller console1->write (buf, 3); } - void set_action (std::function new_action) { action = new_action; } - void set_plugin_action (std::function new_action) { plugin_action = new_action; } - void set_plugin_shift_action (std::function new_action) { plugin_shift_action = new_action; } + uint32_t state_count () + { + return state_values.size (); + } - uint32_t state_count () { return state_values.size (); } - - std::function action; - std::function shift_action; - std::function plugin_action; - std::function plugin_shift_action; - - private: +private: std::vector state_values; }; class Meter : public Controller { - public: - Meter (Console1* console1, - ControllerID id, +public: + Meter (Console1* console1, + ControllerID id, std::function action, std::function shift_action = 0) - : Controller (console1, id) - , action (action) - , shift_action (shift_action) + : Controller (console1, id) + , action (action) + , shift_action (shift_action) { console1->meters.insert (std::make_pair (id, this)); } - ControllerType get_type () { return METER; } + ControllerType get_type () + { + return METER; + } virtual void set_value (uint32_t value) { @@ -167,46 +237,6 @@ class Meter : public Controller std::function shift_action; }; -class Encoder : public Controller -{ - public: - Encoder (Console1* console1, - ControllerID id, - std::function action, - std::function shift_action = 0, - std::function plugin_action = 0, - std::function plugin_shift_action = 0) - : Controller (console1, id) - , action (action) - , shift_action (shift_action) - , plugin_action (plugin_action) - , plugin_shift_action (plugin_action) - { - console1->encoders.insert (std::make_pair (id, this)); - } +} // namespace Console1 - ControllerType get_type () { return ENCODER; } - - void set_action (std::function new_action) { action = new_action; } - void set_plugin_action (std::function new_action) { plugin_action = new_action; } - void set_plugin_shift_action (std::function new_action) { plugin_shift_action = new_action; } - - virtual void set_value (uint32_t value) - { - MIDI::byte buf[3]; - buf[0] = 0xB0; - buf[1] = _id; - buf[2] = value; - - console1->write (buf, 3); - } - std::function action; - std::function shift_action; - std::function plugin_action; - std::function plugin_shift_action; - - PBD::Signal* plugin_signal; -}; - -} #endif // ardour_surface_console1_button_h diff --git a/libs/surfaces/console1/c1_gui.cc b/libs/surfaces/console1/c1_gui.cc index c8c20a5a97..9214b0ba3c 100644 --- a/libs/surfaces/console1/c1_gui.cc +++ b/libs/surfaces/console1/c1_gui.cc @@ -40,11 +40,13 @@ using namespace PBD; using namespace ARDOUR; -using namespace ArdourSurface; using namespace std; using namespace Gtk; using namespace Gtkmm2ext; +namespace Console1 +{ + void* Console1::get_gui () const { @@ -383,7 +385,7 @@ C1GUI::change_controller (const Glib::ustring &sPath, const TreeModel::iterator string controllerName = (*iter)[c1.plugin_controller_columns.controllerName]; int controllerId = (*iter)[c1.plugin_controller_columns.controllerId]; - pc.parameters[index].controllerId = ArdourSurface::Console1::ControllerID (controllerId); + pc.parameters[index].controllerId = Console1::ControllerID (controllerId); (*row).set_value (plugin_assignment_editor_columns.controllerName, controllerName); DEBUG_TRACE (DEBUG::Console1, string_compose ("Column Name: Controller, index %1, name %2 \n", index, controllerName)); @@ -488,3 +490,5 @@ void C1GUI::write_plugin_assignment(){ c1.write_plugin_mapping (pc); assignement_changed = false; } + +} // namespace Console1 \ No newline at end of file diff --git a/libs/surfaces/console1/c1_gui.h b/libs/surfaces/console1/c1_gui.h index 9a6217ba16..3594d6a7a6 100644 --- a/libs/surfaces/console1/c1_gui.h +++ b/libs/surfaces/console1/c1_gui.h @@ -45,7 +45,7 @@ namespace ActionManager { #include "console1.h" -namespace ArdourSurface { +namespace Console1 { class C1GUI : public Gtk::Notebook { @@ -120,7 +120,7 @@ private: Glib::RefPtr build_midi_port_list (std::vector const & ports, bool for_input); - ArdourSurface::Console1::PluginMapping pc; + Console1::PluginMapping pc; Gtk::CellRendererCombo* make_action_renderer (Glib::RefPtr model, Gtk::TreeModelColumnBase column); void build_plugin_assignment_editor (); @@ -135,6 +135,6 @@ private: void active_plugin_changed (Gtk::ComboBox* combo); void write_plugin_assignment (); }; -} +} // namespace Console1 #endif /* __ardour_console1_gui_h__ */ diff --git a/libs/surfaces/console1/c1_operations.cc b/libs/surfaces/console1/c1_operations.cc index 097408d894..4c95eae1b7 100644 --- a/libs/surfaces/console1/c1_operations.cc +++ b/libs/surfaces/console1/c1_operations.cc @@ -27,13 +27,15 @@ #include "console1.h" using namespace ARDOUR; -using namespace ArdourSurface; using namespace PBD; using namespace Glib; using namespace std; /* Operations */ +namespace Console1 +{ + void Console1::bank (bool up) { @@ -145,7 +147,7 @@ Console1::select (const uint32_t i) void Console1::shift (const uint32_t val) { - DEBUG_TRACE (DEBUG::Console1, "shift()\n"); + DEBUG_TRACE (DEBUG::Console1, string_compose( "shift (%1)\n", val )); shift_state = !shift_state; ShiftChange (val); } @@ -674,7 +676,7 @@ Console1::map_select () void Console1::map_shift (bool shift) { - DEBUG_TRACE (DEBUG::Console1, "map_shift()\n"); + DEBUG_TRACE (DEBUG::Console1, string_compose ("map_shift(%1)\n", shift)); try { ControllerButton* controllerButton = get_button (PRESET); controllerButton->set_led_state (shift); @@ -687,7 +689,7 @@ Console1::map_shift (bool shift) void Console1::map_plugin_state (bool plugin_state) { - DEBUG_TRACE (DEBUG::Console1, "map_plugin_state()\n"); + DEBUG_TRACE (DEBUG::Console1, string_compose ("map_plugin_state(%1)\n", plugin_state) ); try { ControllerButton* controllerButton = get_button (TRACK_GROUP); controllerButton->set_led_state (in_plugin_state); @@ -699,10 +701,6 @@ Console1::map_plugin_state (bool plugin_state) stop_blinking (ControllerID (FOCUS1 + i)); } map_stripable_state (); - } else { - // I don't plan shift functionality with plugins... - shift (0); - // map all plugin related operations } } @@ -1237,3 +1235,5 @@ Console1::map_encoder (ControllerID controllerID, std::shared_ptrsecond; } @@ -289,24 +289,23 @@ Console1::remove_plugin_operations () { plugin_connections.drop_connections (); - for (auto& e : encoders) { - e.second->set_plugin_action (0); - e.second->set_plugin_shift_action (0); - e.second->set_value (0); - } - for (auto& b : buttons) { - if (b.first == ControllerID::TRACK_GROUP) + for (auto& c : controllerMap) { + if (c.first == ControllerID::TRACK_GROUP) continue; - if (b.first >= ControllerID::FOCUS1 && b.first <= ControllerID::FOCUS20) + if (c.first >= ControllerID::FOCUS1 && c.first <= ControllerID::FOCUS20) continue; - b.second->set_plugin_action (0); - b.second->set_plugin_shift_action (0); - b.second->set_led_state (false); - } - for (auto& m : multi_buttons) { - m.second->set_plugin_action (0); - m.second->set_plugin_shift_action (0); - m.second->set_led_state (false); + c.second->set_plugin_action (0); + c.second->set_plugin_shift_action (0); + c.second->clear_value (); + if( c.second->get_type() == ControllerType::CONTROLLER_BUTTON ) + { + ControllerButton* b = dynamic_cast (c.second); + b->set_led_state (false); + } else if (c.second->get_type () == ControllerType::MULTISTATE_BUTTON ) + { + MultiStateButton* b = dynamic_cast (c.second); + b->set_led_state (false); + } } } @@ -326,12 +325,15 @@ Console1::find_plugin (const int32_t plugin_index) while ((ext_plugin_index < plugin_index) && (int_plugin_index < (int)bank_size)) { ++int_plugin_index; + DEBUG_TRACE (DEBUG::Console1, string_compose ("find_plugin: int index %1, ext index %2\n", int_plugin_index, ext_plugin_index)); proc = r->nth_plugin (int_plugin_index); if (!proc) { + DEBUG_TRACE (DEBUG::Console1, "find_plugin: plugin not found\n"); continue; - ; } + DEBUG_TRACE (DEBUG::Console1, "find_plugin: plugin found\n"); if (!proc->display_to_user ()) { + DEBUG_TRACE (DEBUG::Console1, "find_plugin: display to user failed\n"); continue; } @@ -483,7 +485,7 @@ Console1::spill_plugins (const int32_t plugin_index) return false; int32_t n_controls = -1; - DEBUG_TRACE (DEBUG::Console1, string_compose ("Found plugin %1\n", proc->name ())); + DEBUG_TRACE (DEBUG::Console1, string_compose ("spill_plugins: Found plugin %1\n", proc->name ())); std::shared_ptr plugin_insert = std::dynamic_pointer_cast (proc); if (!plugin_insert) return false; @@ -492,7 +494,7 @@ Console1::spill_plugins (const int32_t plugin_index) if (!plugin) return false; - DEBUG_TRACE (DEBUG::Console1, string_compose ("Found plugin id %1\n", plugin->unique_id ())); + DEBUG_TRACE (DEBUG::Console1, string_compose ("spill_plugins: Found plugin id %1\n", plugin->unique_id ())); // Setup mute button setup_plugin_mute_button(plugin_insert); @@ -510,15 +512,15 @@ Console1::spill_plugins (const int32_t plugin_index) PluginMapping pluginMapping = pmmit->second; DEBUG_TRACE (DEBUG::Console1, - string_compose ("Plugin mapping found for id %1, name %2\n", pluginMapping.id, pluginMapping.name)); + string_compose ("spill_plugins: Plugin mapping found for id %1, name %2\n", pluginMapping.id, pluginMapping.name)); set p = proc->what_can_be_automated (); for (set::iterator j = p.begin (); j != p.end (); ++j) { ++n_controls; std::string n = proc->describe_parameter (*j); - DEBUG_TRACE (DEBUG::Console1, string_compose ("Plugin parameter %1: %2\n", n_controls, n)); - if (n == "hidden") { + DEBUG_TRACE (DEBUG::Console1, string_compose ("spill_plugins: Plugin parameter %1: %2\n", n_controls, n)); + if (n == "hidden") { continue; } ParameterDescriptor parameterDescriptor; @@ -555,7 +557,7 @@ Glib::RefPtr Console1::getPluginControllerModel() { plugin_controller_model = Gtk::ListStore::create (plugin_controller_columns); Gtk::TreeModel::Row plugin_controller_combo_row; - for( const auto &controller : controllerMap ){ + for( const auto &controller : controllerNameIdMap ){ plugin_controller_combo_row = *(plugin_controller_model->append ()); plugin_controller_combo_row[plugin_controller_columns.controllerId] = controller.second; plugin_controller_combo_row[plugin_controller_columns.controllerName] = X_(controller.first); @@ -563,4 +565,4 @@ Glib::RefPtr Console1::getPluginControllerModel() return plugin_controller_model; } -} +} // namespace Console1 diff --git a/libs/surfaces/console1/console1.cc b/libs/surfaces/console1/console1.cc index c4ad5f57fc..023a65027d 100644 --- a/libs/surfaces/console1/console1.cc +++ b/libs/surfaces/console1/console1.cc @@ -41,12 +41,16 @@ #include "c1_control.h" #include "c1_gui.h" + + using namespace ARDOUR; -using namespace ArdourSurface; using namespace PBD; using namespace Glib; using namespace std; +namespace Console1 +{ + Console1::Console1 (Session& s) : MIDISurface (s, X_ ("Softube Console1"), X_ ("Console1"), false) , gui (0) @@ -66,25 +70,17 @@ Console1::~Console1 () stop_event_loop (); MIDISurface::drop (); - for (const auto& b : buttons) { - delete b.second; - } - for (const auto& e : encoders) { - delete e.second; - } - for (const auto& m : meters) { - delete m.second; - } - for (const auto& mb : multi_buttons) { - delete mb.second; + for (const auto& c : controllerMap) { + delete c.second; } } void Console1::all_lights_out () { - for (ButtonMap::iterator b = buttons.begin (); b != buttons.end (); ++b) { - b->second->set_led_state (false); + for (ControllerMap::iterator b = controllerMap.begin (); b != controllerMap.end (); ++b) { + if( b->second->get_type() == ControllerType::CONTROLLER_BUTTON ) + (dynamic_cast(b->second))->set_led_state (false); } } @@ -277,18 +273,22 @@ Console1::setup_controls () for (uint32_t i = 0; i < 20; ++i) { new ControllerButton (this, - ControllerID (FOCUS1 + i), - std::function (std::bind (&Console1::select, this, i)), - 0, - std::function (std::bind (&Console1::select_plugin, this, i))); + ControllerID (FOCUS1 + i), + std::function (std::bind (&Console1::select, this, i)), + std::function (std::bind (&Console1::select, this, i)), + std::function (std::bind (&Console1::select_plugin, this, i)), + std::function (std::bind (&Console1::select_plugin, this, i))); } new ControllerButton ( this, ControllerID::PRESET, std::function (std::bind (&Console1::shift, this, _1))); new ControllerButton (this, - ControllerID::TRACK_GROUP, - std::function (std::bind (&Console1::plugin_state, this, _1))); + ControllerID::TRACK_GROUP, + std::function (std::bind (&Console1::plugin_state, this, _1)), + std::function (std::bind (&Console1::plugin_state, this, _1)), + std::function (std::bind (&Console1::plugin_state, this, _1)), + std::function (std::bind (&Console1::plugin_state, this, _1))); new ControllerButton ( this, ControllerID::DISPLAY_ON, std::function (std::bind (&Console1::rude_solo, this, _1))); @@ -438,64 +438,42 @@ void Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb) { uint32_t controller_number = static_cast (tb->controller_number); - uint32_t value = static_cast (tb->value); -DEBUG_TRACE (DEBUG::Console1, + uint32_t value = static_cast (tb->value); + DEBUG_TRACE (DEBUG::Console1, string_compose ("handle_midi_controller_message cn: '%1' val: '%2'\n", controller_number, value)); + DEBUG_TRACE (DEBUG::Console1, + string_compose ("handle_midi_controller_message shift state: '%1' plugin state: '%2'\n", shift_state, in_plugin_state)); + try { - Encoder* e = get_encoder (ControllerID (controller_number)); - if (in_plugin_state && e->plugin_action) { - e->plugin_action (value); - } else if (shift_state && e->shift_action) { - e->shift_action (value); - } else { - e->action (value); + Controller* controller = controllerMap[ControllerID (controller_number)]; + if (controller ) { + DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message; Controller Found'\n"); + if (shift_state && in_plugin_state && controller->get_plugin_shift_action ()) { + controller->get_plugin_shift_action () (value); + DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: plugin_shift_action'\n" ); + } else if (in_plugin_state && controller->get_plugin_action ()) { + controller->get_plugin_action () (value); + DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: plugin_action'\n"); + } else if (shift_state && controller->get_shift_action ()) { + controller->get_shift_action () (value); + DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: shift_action'\n"); + } else { + controller->get_action () (value); + DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: action'\n"); + } + return; } - return; - } catch (ControlNotFoundException const&) { + else { + DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: Controller not found'\n"); + } + } + catch (ControlNotFoundException const&) { DEBUG_TRACE (DEBUG::Console1, string_compose ("handle_midi_controller_message: encoder not found cn: " "'%1' val: '%2'\n", controller_number, value)); } - - try { - ControllerButton* b = get_button (ControllerID (controller_number)); - if (in_plugin_state && b->plugin_action) { - DEBUG_TRACE (DEBUG::Console1, "Executing plugin_action\n"); - b->plugin_action (value); - } else if (shift_state && b->shift_action) { - DEBUG_TRACE (DEBUG::Console1, "Executing shift_action\n"); - b->shift_action (value); - } else { - DEBUG_TRACE (DEBUG::Console1, "Executing action\n"); - b->action (value); - } - return; - } catch (ControlNotFoundException const&) { - DEBUG_TRACE (DEBUG::Console1, - string_compose ("handle_midi_controller_message: button not found cn: " - "'%1' val: '%2'\n", - controller_number, - value)); - } - - try { - MultiStateButton* mb = get_mbutton (ControllerID (controller_number)); - if (shift_state && mb->shift_action) { - mb->shift_action (value); - } else { - mb->action (value); - } - - return; - } catch (ControlNotFoundException const&) { - DEBUG_TRACE (DEBUG::Console1, - string_compose ("handle_midi_controller_message: mbutton not found cn: " - "'%1' val: '%2'\n", - controller_number, - value)); - } } void @@ -955,15 +933,6 @@ Console1::blinker () return true; } -ControllerButton* -Console1::get_button (ControllerID id) const -{ - ButtonMap::const_iterator b = buttons.find (id); - if (b == buttons.end ()) - throw (ControlNotFoundException ()); - return const_cast (b->second); -} - Meter* Console1::get_meter (ControllerID id) const { @@ -973,22 +942,42 @@ Console1::get_meter (ControllerID id) const return const_cast (m->second); } +Controller* +Console1::get_controller (ControllerID id) const +{ + ControllerMap::const_iterator c = controllerMap.find (id); + if (c == controllerMap.end ()) + throw (ControlNotFoundException ()); + return (c->second); +} + +Controller* +Console1::get_controller (ControllerID id, ControllerType controllerType) const +{ + ControllerMap::const_iterator c = controllerMap.find (id); + if ((c == controllerMap.end ()) || (c->second->get_type () != controllerType)) + throw (ControlNotFoundException ()); + return (c->second); +} + Encoder* Console1::get_encoder (ControllerID id) const { - EncoderMap::const_iterator m = encoders.find (id); - if (m == encoders.end ()) - throw (ControlNotFoundException ()); - return const_cast (m->second); + return dynamic_cast (get_controller (id, ControllerType::ENCODER)); } +ControllerButton* +Console1::get_button (ControllerID id) const +{ + return dynamic_cast (get_controller (id, ControllerType::CONTROLLER_BUTTON)); +} + + + MultiStateButton* Console1::get_mbutton (ControllerID id) const { - MultiStateButtonMap::const_iterator m = multi_buttons.find (id); - if (m == multi_buttons.end ()) - throw (ControlNotFoundException ()); - return const_cast (m->second); + return dynamic_cast (get_controller (id, ControllerType::MULTISTATE_BUTTON)); } ControllerID @@ -1263,10 +1252,11 @@ Console1::master_monitor_has_changed () } const std::string Console1::findControllerNameById (const ControllerID id){ - for( const auto &controller : controllerMap ){ + for( const auto &controller : controllerNameIdMap ){ if( controller.second == id ){ return controller.first; - } + } } return std::string(); -} \ No newline at end of file +} +} // namespace Console1 \ No newline at end of file diff --git a/libs/surfaces/console1/console1.h b/libs/surfaces/console1/console1.h index ea654dd80c..c7bb5626c8 100644 --- a/libs/surfaces/console1/console1.h +++ b/libs/surfaces/console1/console1.h @@ -61,20 +61,15 @@ namespace PBD { class Controllable; } +namespace Console1 +{ + class MIDIControllable; class MIDIFunction; class MIDIAction; -namespace ArdourSurface { - class C1GUI; -// XXX TODO: these classes should not be in the ArdourSurface namespace -// which is shared with all other ctrl surfaces. -// -// ArdourSurface::Meter etc may cause conflicts. -// best add a C1 prefix, or additional namespace - class Controller; class ControllerButton; class MultiStateButton; @@ -92,6 +87,14 @@ public: ControlNotFoundException () {} }; +enum ControllerType { + CONTROLLER, + CONTROLLER_BUTTON, + MULTISTATE_BUTTON, + ENCODER, + METER +}; + class Console1 : public MIDISurface { @@ -141,18 +144,17 @@ public: PBD::Signal PluginStateChange; PBD::Signal EQBandQBindingChange; - enum ControllerID - { - CONTROLLER_NONE = 0, - VOLUME = 7, - PAN = 10, - MUTE = 12, - SOLO = 13, - ORDER = 14, - DRIVE = 15, + enum ControllerID { + CONTROLLER_NONE = 0, + VOLUME = 7, + PAN = 10, + MUTE = 12, + SOLO = 13, + ORDER = 14, + DRIVE = 15, EXTERNAL_SIDECHAIN = 17, - CHARACTER = 18, - FOCUS1 = 21, + CHARACTER = 18, + FOCUS1 = 21, FOCUS2, FOCUS3, FOCUS4, @@ -171,63 +173,62 @@ public: FOCUS17, FOCUS18, FOCUS19, - FOCUS20 = 40, - COMP = 46, - COMP_THRESH = 47, - COMP_RELEASE = 48, - COMP_RATIO = 49, - COMP_PAR = 50, - COMP_ATTACK = 51, - SHAPE = 53, - SHAPE_GATE = 54, - SHAPE_SUSTAIN = 55, - SHAPE_RELEASE = 56, - SHAPE_PUNCH = 57, - PRESET = 58, - HARD_GATE = 59, + FOCUS20 = 40, + COMP = 46, + COMP_THRESH = 47, + COMP_RELEASE = 48, + COMP_RATIO = 49, + COMP_PAR = 50, + COMP_ATTACK = 51, + SHAPE = 53, + SHAPE_GATE = 54, + SHAPE_SUSTAIN = 55, + SHAPE_RELEASE = 56, + SHAPE_PUNCH = 57, + PRESET = 58, + HARD_GATE = 59, FILTER_TO_COMPRESSORS = 61, - HIGH_SHAPE = 65, - EQ = 80, - HIGH_GAIN = 82, - HIGH_FREQ = 83, - HIGH_MID_GAIN = 85, - HIGH_MID_FREQ = 86, - HIGH_MID_SHAPE = 87, - LOW_MID_GAIN = 88, - LOW_MID_FREQ = 89, - LOW_MID_SHAPE = 90, - LOW_GAIN = 91, - LOW_FREQ = 92, - LOW_SHAPE = 93, - PAGE_UP = 96, - PAGE_DOWN = 97, - DISPLAY_ON = 102, - LOW_CUT = 103, - MODE = 104, - HIGH_CUT = 105, - GAIN = 107, - PHASE_INV = 108, - INPUT_METER_L = 110, - INPUT_METER_R = 111, - OUTPUT_METER_L = 112, - OUTPUT_METER_R = 113, - SHAPE_METER = 114, - COMP_METER = 115, - TRACK_COPY = 120, - TRACK_GROUP = 123, + HIGH_SHAPE = 65, + EQ = 80, + HIGH_GAIN = 82, + HIGH_FREQ = 83, + HIGH_MID_GAIN = 85, + HIGH_MID_FREQ = 86, + HIGH_MID_SHAPE = 87, + LOW_MID_GAIN = 88, + LOW_MID_FREQ = 89, + LOW_MID_SHAPE = 90, + LOW_GAIN = 91, + LOW_FREQ = 92, + LOW_SHAPE = 93, + PAGE_UP = 96, + PAGE_DOWN = 97, + DISPLAY_ON = 102, + LOW_CUT = 103, + MODE = 104, + HIGH_CUT = 105, + GAIN = 107, + PHASE_INV = 108, + INPUT_METER_L = 110, + INPUT_METER_R = 111, + OUTPUT_METER_L = 112, + OUTPUT_METER_R = 113, + SHAPE_METER = 114, + COMP_METER = 115, + TRACK_COPY = 120, + TRACK_GROUP = 123, }; - enum EQ_MODE - { - EQM_UNDEFINED = -1, - EQM_HARRISON = 0, - EQM_SSL = 1 - }; + enum EQ_MODE { + EQM_UNDEFINED = -1, + EQM_HARRISON = 0, + EQM_SSL = 1 + }; - using ControllerMap = std::map; + using ControllerNameIdMap = std::map; - ControllerMap controllerMap{ { "CONTROLLER_NONE", ControllerID::CONTROLLER_NONE }, + ControllerNameIdMap controllerNameIdMap{ { "CONTROLLER_NONE", ControllerID::CONTROLLER_NONE }, { "VOLUME", ControllerID::VOLUME }, { "PAN", ControllerID::PAN }, { "MUTE", ControllerID::MUTE }, @@ -394,74 +395,72 @@ public: void select_rid_by_index (const uint32_t index); /* Controller Maps*/ - typedef std::map ButtonMap; - typedef std::map MultiStateButtonMap; - typedef std::map MeterMap; - typedef std::map EncoderMap; + typedef std::map MeterMap; - ButtonMap buttons; - ControllerButton* get_button (ControllerID) const; + typedef std::map ControllerMap; - MultiStateButtonMap multi_buttons; - MultiStateButton* get_mbutton (ControllerID id) const; + MeterMap meters; + Meter* get_meter (ControllerID) const; + ControllerButton* get_button (ControllerID) const; - MeterMap meters; - Meter* get_meter (ControllerID) const; + MultiStateButton* get_mbutton (ControllerID id) const; - EncoderMap encoders; - Encoder* get_encoder (ControllerID) const; + Encoder* get_encoder (ControllerID) const; - typedef std::map SendControllerMap; - SendControllerMap send_controllers{ { 0, LOW_FREQ }, { 1, LOW_MID_FREQ }, { 2, HIGH_MID_FREQ }, - { 3, HIGH_FREQ }, { 4, LOW_GAIN }, { 5, LOW_MID_GAIN }, - { 6, HIGH_MID_GAIN }, { 7, HIGH_GAIN }, { 8, LOW_MID_SHAPE }, - { 9, HIGH_MID_SHAPE }, { 10, LOW_MID_SHAPE }, { 11, HIGH_MID_SHAPE } }; + ControllerMap controllerMap; + Controller* get_controller (ControllerID id) const; + Controller* get_controller (ControllerID id, ControllerType controllerType) const; - ControllerID get_send_controllerid (uint32_t); + typedef std::map SendControllerMap; + SendControllerMap send_controllers{ { 0, LOW_FREQ }, { 1, LOW_MID_FREQ }, { 2, HIGH_MID_FREQ }, { 3, HIGH_FREQ }, + { 4, LOW_GAIN }, { 5, LOW_MID_GAIN }, { 6, HIGH_MID_GAIN }, { 7, HIGH_GAIN }, + { 8, LOW_MID_SHAPE }, { 9, HIGH_MID_SHAPE }, { 10, LOW_MID_SHAPE }, { 11, HIGH_MID_SHAPE } }; - /* */ - void all_lights_out (); + ControllerID get_send_controllerid (uint32_t); - void notify_transport_state_changed () override; - void notify_solo_active_changed (bool) override; + /* */ + void all_lights_out (); - sigc::connection periodic_connection; + void notify_transport_state_changed () override; + void notify_solo_active_changed (bool) override; - bool periodic (); - void periodic_update_meter (); + sigc::connection periodic_connection; - // Meter Handlig - uint32_t last_output_meter_l = 0; - uint32_t last_output_meter_r = 0; + bool periodic (); + void periodic_update_meter (); - std::shared_ptr gate_redux_meter = 0; - uint32_t last_gate_meter = 0; + // Meter Handlig + uint32_t last_output_meter_l = 0; + uint32_t last_output_meter_r = 0; - std::shared_ptr comp_redux_meter = 0; - uint32_t last_comp_redux = 0; + std::shared_ptr gate_redux_meter = 0; + uint32_t last_gate_meter = 0; - sigc::connection blink_connection; - typedef std::list Blinkers; - Blinkers blinkers; - bool blink_state; - bool blinker (); - void start_blinking (ControllerID); - void stop_blinking (ControllerID); + std::shared_ptr comp_redux_meter = 0; + uint32_t last_comp_redux = 0; - void set_current_stripable (std::shared_ptr); - void drop_current_stripable (); - /*void use_master (); - void use_monitor ();*/ + sigc::connection blink_connection; + typedef std::list Blinkers; + Blinkers blinkers; + bool blink_state; + bool blinker (); + void start_blinking (ControllerID); + void stop_blinking (ControllerID); + + void set_current_stripable (std::shared_ptr); + void drop_current_stripable (); + /*void use_master (); + void use_monitor ();*/ void stripable_selection_changed () override; - /*PBD::ScopedConnection selection_connection;*/ - PBD::ScopedConnectionList stripable_connections; - PBD::ScopedConnectionList console1_connections; - PBD::ScopedConnectionList plugin_connections; + /*PBD::ScopedConnection selection_connection;*/ + PBD::ScopedConnectionList stripable_connections; + PBD::ScopedConnectionList console1_connections; + PBD::ScopedConnectionList plugin_connections; - void map_stripable_state (); + void map_stripable_state (); - void notify_parameter_changed (std::string) override; - void band_q_usage_changed (); + void notify_parameter_changed (std::string) override; + void band_q_usage_changed (); /* operations (defined in c1_operations.cc) */ @@ -707,5 +706,5 @@ public: Glib::RefPtr getPluginControllerModel(); void write_plugin_mapping (PluginMapping &mapping); }; -} +} // namespace Console1 #endif /* ardour_surface_console1_h */ diff --git a/libs/surfaces/console1/console1_interface.cc b/libs/surfaces/console1/console1_interface.cc index 0b04edc0bd..636ec2c6f3 100644 --- a/libs/surfaces/console1/console1_interface.cc +++ b/libs/surfaces/console1/console1_interface.cc @@ -22,15 +22,14 @@ #include "console1.h" using namespace ARDOUR; -using namespace ArdourSurface; static ControlProtocol* new_console1 (Session* s) { - Console1* console1 = 0; + Console1::Console1* console1 = 0; try { - console1 = new Console1 (*s); + console1 = new Console1::Console1 (*s); } catch (failed_constructor& err) { delete console1; console1 = 0;