use a single controller list

This commit is contained in:
Hoger Dehnhardt 2025-07-25 17:09:12 +02:00
parent 28c89ef3d6
commit fbf6400955
8 changed files with 394 additions and 370 deletions

View file

@ -4,66 +4,146 @@
#include "ardour/debug.h" #include "ardour/debug.h"
#include "console1.h" #include "console1.h"
namespace ArdourSurface { namespace Console1
{
using ControllerID = Console1::ControllerID; using ControllerID = Console1::ControllerID;
class Controller class Controller
{ {
public: public:
enum ControllerType
{
CONTROLLER,
CONTROLLER_BUTTON,
MULTISTATE_BUTTON,
ENCODER,
METER
};
Controller (Console1* console1, ControllerID id) Controller (Console1* console1, ControllerID id)
: console1 (console1) : console1 (console1)
, _id (id) , _id (id)
{ {
} }
virtual ~Controller () {} Controller (Console1* console1,
ControllerID id,
std::function<void (uint32_t)> action,
std::function<void (uint32_t)> shift_action = 0,
std::function<void (uint32_t)> plugin_action = 0,
std::function<void (uint32_t)> 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; virtual ~Controller ()
ControllerID id () const { return _id; } {
}
virtual ControllerType get_type () { return CONTROLLER; } Console1* console1;
ControllerID id () const
{
return _id;
}
protected: virtual void clear_value() {}
ControllerID _id;
virtual ControllerType get_type ()
{
return CONTROLLER;
}
void set_action (std::function<void (uint32_t)> new_action)
{
action = new_action;
}
void set_plugin_action (std::function<void (uint32_t)> new_action)
{
plugin_action = new_action;
}
void set_plugin_shift_action (std::function<void (uint32_t)> new_action)
{
plugin_shift_action = new_action;
}
std::function<void (uint32_t)> get_action (){
return action;
}
std::function<void (uint32_t)> get_shift_action ()
{
return shift_action;
}
std::function<void (uint32_t)> get_plugin_action ()
{
return plugin_action;
}
std::function<void (uint32_t)> get_plugin_shift_action ()
{
return plugin_shift_action;
}
protected:
ControllerID _id;
std::function<void (uint32_t)> action;
std::function<void (uint32_t)> shift_action;
std::function<void (uint32_t)> plugin_action;
std::function<void (uint32_t)> plugin_shift_action;
};
class Encoder : public Controller
{
public:
Encoder (Console1* console1,
ControllerID id,
std::function<void (uint32_t)> action,
std::function<void (uint32_t)> shift_action = 0,
std::function<void (uint32_t)> plugin_action = 0,
std::function<void (uint32_t)> 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<void (uint32_t)>* plugin_signal;
}; };
class ControllerButton : public Controller class ControllerButton : public Controller
{ {
public: public:
ControllerButton (Console1* console1, ControllerButton (Console1* console1,
ControllerID id, ControllerID id,
std::function<void (uint32_t)> action, std::function<void (uint32_t)> action,
std::function<void (uint32_t)> shift_action = 0, std::function<void (uint32_t)> shift_action = 0,
std::function<void (uint32_t)> plugin_action = 0, std::function<void (uint32_t)> plugin_action = 0,
std::function<void (uint32_t)> plugin_shift_action = 0 ) std::function<void (uint32_t)> plugin_shift_action = 0)
: Controller (console1, id) : Controller (console1, id, action, shift_action, plugin_action, plugin_shift_action)
, action (action)
, shift_action (shift_action)
, plugin_action (plugin_action)
, plugin_shift_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; } ControllerType get_type ()
{
void set_action (std::function<void (uint32_t)> new_action) { action = new_action; } return CONTROLLER_BUTTON;
void set_plugin_action (std::function<void (uint32_t)> new_action) { plugin_action = new_action; } }
void set_plugin_shift_action (std::function<void (uint32_t)> new_action) { plugin_shift_action = new_action; }
virtual void set_led_state (bool onoff) virtual void set_led_state (bool onoff)
{ {
// DEBUG_TRACE(DEBUG::Console1, "ControllerButton::set_led_state ...\n");
MIDI::byte buf[3]; MIDI::byte buf[3];
buf[0] = 0xB0; buf[0] = 0xB0;
buf[1] = _id; buf[1] = _id;
@ -74,7 +154,6 @@ class ControllerButton : public Controller
virtual void set_led_value (uint32_t val) virtual void set_led_value (uint32_t val)
{ {
// DEBUG_TRACE(DEBUG::Console1, "ControllerButton::set_led_state ...\n");
MIDI::byte buf[3]; MIDI::byte buf[3];
buf[0] = 0xB0; buf[0] = 0xB0;
buf[1] = _id; buf[1] = _id;
@ -82,34 +161,28 @@ class ControllerButton : public Controller
console1->write (buf, 3); console1->write (buf, 3);
} }
std::function<void (uint32_t)> action;
std::function<void (uint32_t)> shift_action;
std::function<void (uint32_t)> plugin_action;
std::function<void (uint32_t)> plugin_shift_action;
}; };
class MultiStateButton : public Controller class MultiStateButton : public Controller
{ {
public: public:
MultiStateButton (Console1* console1, MultiStateButton (Console1* console1,
ControllerID id, ControllerID id,
std::vector<uint32_t> state_values, std::vector<uint32_t> state_values,
std::function<void (uint32_t)> action, std::function<void (uint32_t)> action,
std::function<void (uint32_t)> shift_action = 0, std::function<void (uint32_t)> shift_action = 0,
std::function<void (uint32_t)> plugin_action = 0, std::function<void (uint32_t)> plugin_action = 0,
std::function<void (uint32_t)> plugin_shift_action = 0 std::function<void (uint32_t)> plugin_shift_action = 0)
) : Controller (console1, id, action, shift_action, plugin_action, plugin_shift_action)
: Controller (console1, id) , state_values (state_values)
, action (action)
, shift_action (shift_action)
, plugin_action (action)
, plugin_shift_action (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) virtual void set_led_state (uint32_t state)
{ {
@ -123,36 +196,33 @@ class MultiStateButton : public Controller
console1->write (buf, 3); console1->write (buf, 3);
} }
void set_action (std::function<void (uint32_t)> new_action) { action = new_action; } uint32_t state_count ()
void set_plugin_action (std::function<void (uint32_t)> new_action) { plugin_action = new_action; } {
void set_plugin_shift_action (std::function<void (uint32_t)> new_action) { plugin_shift_action = new_action; } return state_values.size ();
}
uint32_t state_count () { return state_values.size (); } private:
std::function<void (uint32_t)> action;
std::function<void (uint32_t)> shift_action;
std::function<void (uint32_t)> plugin_action;
std::function<void (uint32_t)> plugin_shift_action;
private:
std::vector<uint32_t> state_values; std::vector<uint32_t> state_values;
}; };
class Meter : public Controller class Meter : public Controller
{ {
public: public:
Meter (Console1* console1, Meter (Console1* console1,
ControllerID id, ControllerID id,
std::function<void ()> action, std::function<void ()> action,
std::function<void ()> shift_action = 0) std::function<void ()> shift_action = 0)
: Controller (console1, id) : Controller (console1, id)
, action (action) , action (action)
, shift_action (shift_action) , shift_action (shift_action)
{ {
console1->meters.insert (std::make_pair (id, this)); 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) virtual void set_value (uint32_t value)
{ {
@ -167,46 +237,6 @@ class Meter : public Controller
std::function<void ()> shift_action; std::function<void ()> shift_action;
}; };
class Encoder : public Controller } // namespace Console1
{
public:
Encoder (Console1* console1,
ControllerID id,
std::function<void (uint32_t)> action,
std::function<void (uint32_t)> shift_action = 0,
std::function<void (uint32_t)> plugin_action = 0,
std::function<void (uint32_t)> 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));
}
ControllerType get_type () { return ENCODER; }
void set_action (std::function<void (uint32_t)> new_action) { action = new_action; }
void set_plugin_action (std::function<void (uint32_t)> new_action) { plugin_action = new_action; }
void set_plugin_shift_action (std::function<void (uint32_t)> 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<void (uint32_t)> action;
std::function<void (uint32_t val)> shift_action;
std::function<void (uint32_t val)> plugin_action;
std::function<void (uint32_t val)> plugin_shift_action;
PBD::Signal<void(uint32_t)>* plugin_signal;
};
}
#endif // ardour_surface_console1_button_h #endif // ardour_surface_console1_button_h

View file

@ -40,11 +40,13 @@
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourSurface;
using namespace std; using namespace std;
using namespace Gtk; using namespace Gtk;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
namespace Console1
{
void* void*
Console1::get_gui () const 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]; string controllerName = (*iter)[c1.plugin_controller_columns.controllerName];
int controllerId = (*iter)[c1.plugin_controller_columns.controllerId]; 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); (*row).set_value (plugin_assignment_editor_columns.controllerName, controllerName);
DEBUG_TRACE (DEBUG::Console1, DEBUG_TRACE (DEBUG::Console1,
string_compose ("Column Name: Controller, index %1, name %2 \n", index, controllerName)); 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); c1.write_plugin_mapping (pc);
assignement_changed = false; assignement_changed = false;
} }
} // namespace Console1

View file

@ -45,7 +45,7 @@ namespace ActionManager {
#include "console1.h" #include "console1.h"
namespace ArdourSurface { namespace Console1 {
class C1GUI : public Gtk::Notebook class C1GUI : public Gtk::Notebook
{ {
@ -120,7 +120,7 @@ private:
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input); Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
ArdourSurface::Console1::PluginMapping pc; Console1::PluginMapping pc;
Gtk::CellRendererCombo* make_action_renderer (Glib::RefPtr<Gtk::ListStore> model, Gtk::TreeModelColumnBase column); Gtk::CellRendererCombo* make_action_renderer (Glib::RefPtr<Gtk::ListStore> model, Gtk::TreeModelColumnBase column);
void build_plugin_assignment_editor (); void build_plugin_assignment_editor ();
@ -135,6 +135,6 @@ private:
void active_plugin_changed (Gtk::ComboBox* combo); void active_plugin_changed (Gtk::ComboBox* combo);
void write_plugin_assignment (); void write_plugin_assignment ();
}; };
} } // namespace Console1
#endif /* __ardour_console1_gui_h__ */ #endif /* __ardour_console1_gui_h__ */

View file

@ -27,13 +27,15 @@
#include "console1.h" #include "console1.h"
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourSurface;
using namespace PBD; using namespace PBD;
using namespace Glib; using namespace Glib;
using namespace std; using namespace std;
/* Operations */ /* Operations */
namespace Console1
{
void void
Console1::bank (bool up) Console1::bank (bool up)
{ {
@ -145,7 +147,7 @@ Console1::select (const uint32_t i)
void void
Console1::shift (const uint32_t val) 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; shift_state = !shift_state;
ShiftChange (val); ShiftChange (val);
} }
@ -674,7 +676,7 @@ Console1::map_select ()
void void
Console1::map_shift (bool shift) Console1::map_shift (bool shift)
{ {
DEBUG_TRACE (DEBUG::Console1, "map_shift()\n"); DEBUG_TRACE (DEBUG::Console1, string_compose ("map_shift(%1)\n", shift));
try { try {
ControllerButton* controllerButton = get_button (PRESET); ControllerButton* controllerButton = get_button (PRESET);
controllerButton->set_led_state (shift); controllerButton->set_led_state (shift);
@ -687,7 +689,7 @@ Console1::map_shift (bool shift)
void void
Console1::map_plugin_state (bool plugin_state) 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 { try {
ControllerButton* controllerButton = get_button (TRACK_GROUP); ControllerButton* controllerButton = get_button (TRACK_GROUP);
controllerButton->set_led_state (in_plugin_state); controllerButton->set_led_state (in_plugin_state);
@ -699,10 +701,6 @@ Console1::map_plugin_state (bool plugin_state)
stop_blinking (ControllerID (FOCUS1 + i)); stop_blinking (ControllerID (FOCUS1 + i));
} }
map_stripable_state (); 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_ptr<ARDOUR::Automa
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n"); DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
} }
} }
} // namespace Console1

View file

@ -35,12 +35,12 @@
#include "console1.h" #include "console1.h"
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourSurface;
using namespace PBD; using namespace PBD;
using namespace Glib; using namespace Glib;
using namespace std; using namespace std;
namespace ArdourSurface { namespace Console1
{
bool bool
Console1::ensure_config_dir () Console1::ensure_config_dir ()
@ -136,8 +136,8 @@ Console1::load_mapping (XMLNode* mapping_xml)
parmap.name = param_name; parmap.name = param_name;
parmap.is_switch = (param_type == "switch"); parmap.is_switch = (param_type == "switch");
if (!param_mapping.empty ()) { if (!param_mapping.empty ()) {
ControllerMap::const_iterator m = controllerMap.find (param_mapping); ControllerNameIdMap::const_iterator m = controllerNameIdMap.find (param_mapping);
if (m != controllerMap.end ()) if (m != controllerNameIdMap.end ())
{ {
parmap.controllerId = m->second; parmap.controllerId = m->second;
} }
@ -289,24 +289,23 @@ Console1::remove_plugin_operations ()
{ {
plugin_connections.drop_connections (); plugin_connections.drop_connections ();
for (auto& e : encoders) { for (auto& c : controllerMap) {
e.second->set_plugin_action (0); if (c.first == ControllerID::TRACK_GROUP)
e.second->set_plugin_shift_action (0);
e.second->set_value (0);
}
for (auto& b : buttons) {
if (b.first == ControllerID::TRACK_GROUP)
continue; continue;
if (b.first >= ControllerID::FOCUS1 && b.first <= ControllerID::FOCUS20) if (c.first >= ControllerID::FOCUS1 && c.first <= ControllerID::FOCUS20)
continue; continue;
b.second->set_plugin_action (0); c.second->set_plugin_action (0);
b.second->set_plugin_shift_action (0); c.second->set_plugin_shift_action (0);
b.second->set_led_state (false); c.second->clear_value ();
} if( c.second->get_type() == ControllerType::CONTROLLER_BUTTON )
for (auto& m : multi_buttons) { {
m.second->set_plugin_action (0); ControllerButton* b = dynamic_cast<ControllerButton *> (c.second);
m.second->set_plugin_shift_action (0); b->set_led_state (false);
m.second->set_led_state (false); } else if (c.second->get_type () == ControllerType::MULTISTATE_BUTTON )
{
MultiStateButton* b = dynamic_cast<MultiStateButton *> (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)) { while ((ext_plugin_index < plugin_index) && (int_plugin_index < (int)bank_size)) {
++int_plugin_index; ++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); proc = r->nth_plugin (int_plugin_index);
if (!proc) { if (!proc) {
DEBUG_TRACE (DEBUG::Console1, "find_plugin: plugin not found\n");
continue; continue;
;
} }
DEBUG_TRACE (DEBUG::Console1, "find_plugin: plugin found\n");
if (!proc->display_to_user ()) { if (!proc->display_to_user ()) {
DEBUG_TRACE (DEBUG::Console1, "find_plugin: display to user failed\n");
continue; continue;
} }
@ -483,7 +485,7 @@ Console1::spill_plugins (const int32_t plugin_index)
return false; return false;
int32_t n_controls = -1; 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<PluginInsert> plugin_insert = std::dynamic_pointer_cast<PluginInsert> (proc); std::shared_ptr<PluginInsert> plugin_insert = std::dynamic_pointer_cast<PluginInsert> (proc);
if (!plugin_insert) if (!plugin_insert)
return false; return false;
@ -492,7 +494,7 @@ Console1::spill_plugins (const int32_t plugin_index)
if (!plugin) if (!plugin)
return false; 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 mute button
setup_plugin_mute_button(plugin_insert); setup_plugin_mute_button(plugin_insert);
@ -510,15 +512,15 @@ Console1::spill_plugins (const int32_t plugin_index)
PluginMapping pluginMapping = pmmit->second; PluginMapping pluginMapping = pmmit->second;
DEBUG_TRACE (DEBUG::Console1, 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<Evoral::Parameter> p = proc->what_can_be_automated (); set<Evoral::Parameter> p = proc->what_can_be_automated ();
for (set<Evoral::Parameter>::iterator j = p.begin (); j != p.end (); ++j) { for (set<Evoral::Parameter>::iterator j = p.begin (); j != p.end (); ++j) {
++n_controls; ++n_controls;
std::string n = proc->describe_parameter (*j); std::string n = proc->describe_parameter (*j);
DEBUG_TRACE (DEBUG::Console1, string_compose ("Plugin parameter %1: %2\n", n_controls, n)); DEBUG_TRACE (DEBUG::Console1, string_compose ("spill_plugins: Plugin parameter %1: %2\n", n_controls, n));
if (n == "hidden") { if (n == "hidden") {
continue; continue;
} }
ParameterDescriptor parameterDescriptor; ParameterDescriptor parameterDescriptor;
@ -555,7 +557,7 @@ Glib::RefPtr<Gtk::ListStore> Console1::getPluginControllerModel()
{ {
plugin_controller_model = Gtk::ListStore::create (plugin_controller_columns); plugin_controller_model = Gtk::ListStore::create (plugin_controller_columns);
Gtk::TreeModel::Row plugin_controller_combo_row; 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_model->append ());
plugin_controller_combo_row[plugin_controller_columns.controllerId] = controller.second; plugin_controller_combo_row[plugin_controller_columns.controllerId] = controller.second;
plugin_controller_combo_row[plugin_controller_columns.controllerName] = X_(controller.first); plugin_controller_combo_row[plugin_controller_columns.controllerName] = X_(controller.first);
@ -563,4 +565,4 @@ Glib::RefPtr<Gtk::ListStore> Console1::getPluginControllerModel()
return plugin_controller_model; return plugin_controller_model;
} }
} } // namespace Console1

View file

@ -41,12 +41,16 @@
#include "c1_control.h" #include "c1_control.h"
#include "c1_gui.h" #include "c1_gui.h"
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourSurface;
using namespace PBD; using namespace PBD;
using namespace Glib; using namespace Glib;
using namespace std; using namespace std;
namespace Console1
{
Console1::Console1 (Session& s) Console1::Console1 (Session& s)
: MIDISurface (s, X_ ("Softube Console1"), X_ ("Console1"), false) : MIDISurface (s, X_ ("Softube Console1"), X_ ("Console1"), false)
, gui (0) , gui (0)
@ -66,25 +70,17 @@ Console1::~Console1 ()
stop_event_loop (); stop_event_loop ();
MIDISurface::drop (); MIDISurface::drop ();
for (const auto& b : buttons) { for (const auto& c : controllerMap) {
delete b.second; delete c.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;
} }
} }
void void
Console1::all_lights_out () Console1::all_lights_out ()
{ {
for (ButtonMap::iterator b = buttons.begin (); b != buttons.end (); ++b) { for (ControllerMap::iterator b = controllerMap.begin (); b != controllerMap.end (); ++b) {
b->second->set_led_state (false); if( b->second->get_type() == ControllerType::CONTROLLER_BUTTON )
(dynamic_cast<ControllerButton*>(b->second))->set_led_state (false);
} }
} }
@ -277,18 +273,22 @@ Console1::setup_controls ()
for (uint32_t i = 0; i < 20; ++i) { for (uint32_t i = 0; i < 20; ++i) {
new ControllerButton (this, new ControllerButton (this,
ControllerID (FOCUS1 + i), ControllerID (FOCUS1 + i),
std::function<void (uint32_t)> (std::bind (&Console1::select, this, i)), std::function<void (uint32_t)> (std::bind (&Console1::select, this, i)),
0, std::function<void (uint32_t)> (std::bind (&Console1::select, this, i)),
std::function<void (uint32_t)> (std::bind (&Console1::select_plugin, this, i))); std::function<void (uint32_t)> (std::bind (&Console1::select_plugin, this, i)),
std::function<void (uint32_t)> (std::bind (&Console1::select_plugin, this, i)));
} }
new ControllerButton ( new ControllerButton (
this, ControllerID::PRESET, std::function<void (uint32_t)> (std::bind (&Console1::shift, this, _1))); this, ControllerID::PRESET, std::function<void (uint32_t)> (std::bind (&Console1::shift, this, _1)));
new ControllerButton (this, new ControllerButton (this,
ControllerID::TRACK_GROUP, ControllerID::TRACK_GROUP,
std::function<void (uint32_t)> (std::bind (&Console1::plugin_state, this, _1))); std::function<void (uint32_t)> (std::bind (&Console1::plugin_state, this, _1)),
std::function<void (uint32_t)> (std::bind (&Console1::plugin_state, this, _1)),
std::function<void (uint32_t)> (std::bind (&Console1::plugin_state, this, _1)),
std::function<void (uint32_t)> (std::bind (&Console1::plugin_state, this, _1)));
new ControllerButton ( new ControllerButton (
this, ControllerID::DISPLAY_ON, std::function<void (uint32_t)> (std::bind (&Console1::rude_solo, this, _1))); this, ControllerID::DISPLAY_ON, std::function<void (uint32_t)> (std::bind (&Console1::rude_solo, this, _1)));
@ -438,64 +438,42 @@ void
Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb) Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb)
{ {
uint32_t controller_number = static_cast<uint32_t> (tb->controller_number); uint32_t controller_number = static_cast<uint32_t> (tb->controller_number);
uint32_t value = static_cast<uint32_t> (tb->value); uint32_t value = static_cast<uint32_t> (tb->value);
DEBUG_TRACE (DEBUG::Console1, DEBUG_TRACE (DEBUG::Console1,
string_compose ("handle_midi_controller_message cn: '%1' val: '%2'\n", controller_number, value)); 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 { try {
Encoder* e = get_encoder (ControllerID (controller_number)); Controller* controller = controllerMap[ControllerID (controller_number)];
if (in_plugin_state && e->plugin_action) { if (controller ) {
e->plugin_action (value); DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message; Controller Found'\n");
} else if (shift_state && e->shift_action) { if (shift_state && in_plugin_state && controller->get_plugin_shift_action ()) {
e->shift_action (value); controller->get_plugin_shift_action () (value);
} else { DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: plugin_shift_action'\n" );
e->action (value); } 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; else {
} catch (ControlNotFoundException const&) { DEBUG_TRACE (DEBUG::Console1, "handle_midi_controller_message: Controller not found'\n");
}
}
catch (ControlNotFoundException const&) {
DEBUG_TRACE (DEBUG::Console1, DEBUG_TRACE (DEBUG::Console1,
string_compose ("handle_midi_controller_message: encoder not found cn: " string_compose ("handle_midi_controller_message: encoder not found cn: "
"'%1' val: '%2'\n", "'%1' val: '%2'\n",
controller_number, controller_number,
value)); 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 void
@ -955,15 +933,6 @@ Console1::blinker ()
return true; 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<ControllerButton*> (b->second);
}
Meter* Meter*
Console1::get_meter (ControllerID id) const Console1::get_meter (ControllerID id) const
{ {
@ -973,22 +942,42 @@ Console1::get_meter (ControllerID id) const
return const_cast<Meter*> (m->second); return const_cast<Meter*> (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* Encoder*
Console1::get_encoder (ControllerID id) const Console1::get_encoder (ControllerID id) const
{ {
EncoderMap::const_iterator m = encoders.find (id); return dynamic_cast<Encoder*> (get_controller (id, ControllerType::ENCODER));
if (m == encoders.end ())
throw (ControlNotFoundException ());
return const_cast<Encoder*> (m->second);
} }
ControllerButton*
Console1::get_button (ControllerID id) const
{
return dynamic_cast<ControllerButton*> (get_controller (id, ControllerType::CONTROLLER_BUTTON));
}
MultiStateButton* MultiStateButton*
Console1::get_mbutton (ControllerID id) const Console1::get_mbutton (ControllerID id) const
{ {
MultiStateButtonMap::const_iterator m = multi_buttons.find (id); return dynamic_cast<MultiStateButton*> (get_controller (id, ControllerType::MULTISTATE_BUTTON));
if (m == multi_buttons.end ())
throw (ControlNotFoundException ());
return const_cast<MultiStateButton*> (m->second);
} }
ControllerID ControllerID
@ -1263,10 +1252,11 @@ Console1::master_monitor_has_changed ()
} }
const std::string Console1::findControllerNameById (const ControllerID id){ const std::string Console1::findControllerNameById (const ControllerID id){
for( const auto &controller : controllerMap ){ for( const auto &controller : controllerNameIdMap ){
if( controller.second == id ){ if( controller.second == id ){
return controller.first; return controller.first;
} }
} }
return std::string(); return std::string();
} }
} // namespace Console1

View file

@ -61,20 +61,15 @@ namespace PBD {
class Controllable; class Controllable;
} }
namespace Console1
{
class MIDIControllable; class MIDIControllable;
class MIDIFunction; class MIDIFunction;
class MIDIAction; class MIDIAction;
namespace ArdourSurface {
class C1GUI; 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 Controller;
class ControllerButton; class ControllerButton;
class MultiStateButton; class MultiStateButton;
@ -92,6 +87,14 @@ public:
ControlNotFoundException () {} ControlNotFoundException () {}
}; };
enum ControllerType {
CONTROLLER,
CONTROLLER_BUTTON,
MULTISTATE_BUTTON,
ENCODER,
METER
};
class Console1 : public MIDISurface class Console1 : public MIDISurface
{ {
@ -141,18 +144,17 @@ public:
PBD::Signal<void(bool)> PluginStateChange; PBD::Signal<void(bool)> PluginStateChange;
PBD::Signal<void(bool)> EQBandQBindingChange; PBD::Signal<void(bool)> EQBandQBindingChange;
enum ControllerID enum ControllerID {
{ CONTROLLER_NONE = 0,
CONTROLLER_NONE = 0, VOLUME = 7,
VOLUME = 7, PAN = 10,
PAN = 10, MUTE = 12,
MUTE = 12, SOLO = 13,
SOLO = 13, ORDER = 14,
ORDER = 14, DRIVE = 15,
DRIVE = 15,
EXTERNAL_SIDECHAIN = 17, EXTERNAL_SIDECHAIN = 17,
CHARACTER = 18, CHARACTER = 18,
FOCUS1 = 21, FOCUS1 = 21,
FOCUS2, FOCUS2,
FOCUS3, FOCUS3,
FOCUS4, FOCUS4,
@ -171,63 +173,62 @@ public:
FOCUS17, FOCUS17,
FOCUS18, FOCUS18,
FOCUS19, FOCUS19,
FOCUS20 = 40, FOCUS20 = 40,
COMP = 46, COMP = 46,
COMP_THRESH = 47, COMP_THRESH = 47,
COMP_RELEASE = 48, COMP_RELEASE = 48,
COMP_RATIO = 49, COMP_RATIO = 49,
COMP_PAR = 50, COMP_PAR = 50,
COMP_ATTACK = 51, COMP_ATTACK = 51,
SHAPE = 53, SHAPE = 53,
SHAPE_GATE = 54, SHAPE_GATE = 54,
SHAPE_SUSTAIN = 55, SHAPE_SUSTAIN = 55,
SHAPE_RELEASE = 56, SHAPE_RELEASE = 56,
SHAPE_PUNCH = 57, SHAPE_PUNCH = 57,
PRESET = 58, PRESET = 58,
HARD_GATE = 59, HARD_GATE = 59,
FILTER_TO_COMPRESSORS = 61, FILTER_TO_COMPRESSORS = 61,
HIGH_SHAPE = 65, HIGH_SHAPE = 65,
EQ = 80, EQ = 80,
HIGH_GAIN = 82, HIGH_GAIN = 82,
HIGH_FREQ = 83, HIGH_FREQ = 83,
HIGH_MID_GAIN = 85, HIGH_MID_GAIN = 85,
HIGH_MID_FREQ = 86, HIGH_MID_FREQ = 86,
HIGH_MID_SHAPE = 87, HIGH_MID_SHAPE = 87,
LOW_MID_GAIN = 88, LOW_MID_GAIN = 88,
LOW_MID_FREQ = 89, LOW_MID_FREQ = 89,
LOW_MID_SHAPE = 90, LOW_MID_SHAPE = 90,
LOW_GAIN = 91, LOW_GAIN = 91,
LOW_FREQ = 92, LOW_FREQ = 92,
LOW_SHAPE = 93, LOW_SHAPE = 93,
PAGE_UP = 96, PAGE_UP = 96,
PAGE_DOWN = 97, PAGE_DOWN = 97,
DISPLAY_ON = 102, DISPLAY_ON = 102,
LOW_CUT = 103, LOW_CUT = 103,
MODE = 104, MODE = 104,
HIGH_CUT = 105, HIGH_CUT = 105,
GAIN = 107, GAIN = 107,
PHASE_INV = 108, PHASE_INV = 108,
INPUT_METER_L = 110, INPUT_METER_L = 110,
INPUT_METER_R = 111, INPUT_METER_R = 111,
OUTPUT_METER_L = 112, OUTPUT_METER_L = 112,
OUTPUT_METER_R = 113, OUTPUT_METER_R = 113,
SHAPE_METER = 114, SHAPE_METER = 114,
COMP_METER = 115, COMP_METER = 115,
TRACK_COPY = 120, TRACK_COPY = 120,
TRACK_GROUP = 123, TRACK_GROUP = 123,
}; };
enum EQ_MODE enum EQ_MODE {
{ EQM_UNDEFINED = -1,
EQM_UNDEFINED = -1, EQM_HARRISON = 0,
EQM_HARRISON = 0, EQM_SSL = 1
EQM_SSL = 1 };
};
using ControllerMap = std::map<std::string, ControllerID>; using ControllerNameIdMap = std::map<std::string, ControllerID>;
ControllerMap controllerMap{ { "CONTROLLER_NONE", ControllerID::CONTROLLER_NONE }, ControllerNameIdMap controllerNameIdMap{ { "CONTROLLER_NONE", ControllerID::CONTROLLER_NONE },
{ "VOLUME", ControllerID::VOLUME }, { "VOLUME", ControllerID::VOLUME },
{ "PAN", ControllerID::PAN }, { "PAN", ControllerID::PAN },
{ "MUTE", ControllerID::MUTE }, { "MUTE", ControllerID::MUTE },
@ -394,74 +395,72 @@ public:
void select_rid_by_index (const uint32_t index); void select_rid_by_index (const uint32_t index);
/* Controller Maps*/ /* Controller Maps*/
typedef std::map<ControllerID, ArdourSurface::ControllerButton*> ButtonMap; typedef std::map<ControllerID, Meter*> MeterMap;
typedef std::map<ControllerID, ArdourSurface::MultiStateButton*> MultiStateButtonMap;
typedef std::map<ControllerID, ArdourSurface::Meter*> MeterMap;
typedef std::map<ControllerID, ArdourSurface::Encoder*> EncoderMap;
ButtonMap buttons; typedef std::map<ControllerID, Controller*> ControllerMap;
ControllerButton* get_button (ControllerID) const;
MultiStateButtonMap multi_buttons; MeterMap meters;
MultiStateButton* get_mbutton (ControllerID id) const; Meter* get_meter (ControllerID) const;
ControllerButton* get_button (ControllerID) const;
MeterMap meters; MultiStateButton* get_mbutton (ControllerID id) const;
Meter* get_meter (ControllerID) const;
EncoderMap encoders; Encoder* get_encoder (ControllerID) const;
Encoder* get_encoder (ControllerID) const;
typedef std::map<uint32_t, ControllerID> SendControllerMap; ControllerMap controllerMap;
SendControllerMap send_controllers{ { 0, LOW_FREQ }, { 1, LOW_MID_FREQ }, { 2, HIGH_MID_FREQ }, Controller* get_controller (ControllerID id) const;
{ 3, HIGH_FREQ }, { 4, LOW_GAIN }, { 5, LOW_MID_GAIN }, Controller* get_controller (ControllerID id, ControllerType controllerType) const;
{ 6, HIGH_MID_GAIN }, { 7, HIGH_GAIN }, { 8, LOW_MID_SHAPE },
{ 9, HIGH_MID_SHAPE }, { 10, LOW_MID_SHAPE }, { 11, HIGH_MID_SHAPE } };
ControllerID get_send_controllerid (uint32_t); typedef std::map<uint32_t, ControllerID> 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 } };
/* */ ControllerID get_send_controllerid (uint32_t);
void all_lights_out ();
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 (); sigc::connection periodic_connection;
void periodic_update_meter ();
// Meter Handlig bool periodic ();
uint32_t last_output_meter_l = 0; void periodic_update_meter ();
uint32_t last_output_meter_r = 0;
std::shared_ptr<ARDOUR::ReadOnlyControl> gate_redux_meter = 0; // Meter Handlig
uint32_t last_gate_meter = 0; uint32_t last_output_meter_l = 0;
uint32_t last_output_meter_r = 0;
std::shared_ptr<ARDOUR::ReadOnlyControl> comp_redux_meter = 0; std::shared_ptr<ARDOUR::ReadOnlyControl> gate_redux_meter = 0;
uint32_t last_comp_redux = 0; uint32_t last_gate_meter = 0;
sigc::connection blink_connection; std::shared_ptr<ARDOUR::ReadOnlyControl> comp_redux_meter = 0;
typedef std::list<ControllerID> Blinkers; uint32_t last_comp_redux = 0;
Blinkers blinkers;
bool blink_state;
bool blinker ();
void start_blinking (ControllerID);
void stop_blinking (ControllerID);
void set_current_stripable (std::shared_ptr<ARDOUR::Stripable>); sigc::connection blink_connection;
void drop_current_stripable (); typedef std::list<ControllerID> Blinkers;
/*void use_master (); Blinkers blinkers;
void use_monitor ();*/ bool blink_state;
bool blinker ();
void start_blinking (ControllerID);
void stop_blinking (ControllerID);
void set_current_stripable (std::shared_ptr<ARDOUR::Stripable>);
void drop_current_stripable ();
/*void use_master ();
void use_monitor ();*/
void stripable_selection_changed () override; void stripable_selection_changed () override;
/*PBD::ScopedConnection selection_connection;*/ /*PBD::ScopedConnection selection_connection;*/
PBD::ScopedConnectionList stripable_connections; PBD::ScopedConnectionList stripable_connections;
PBD::ScopedConnectionList console1_connections; PBD::ScopedConnectionList console1_connections;
PBD::ScopedConnectionList plugin_connections; PBD::ScopedConnectionList plugin_connections;
void map_stripable_state (); void map_stripable_state ();
void notify_parameter_changed (std::string) override; void notify_parameter_changed (std::string) override;
void band_q_usage_changed (); void band_q_usage_changed ();
/* operations (defined in c1_operations.cc) */ /* operations (defined in c1_operations.cc) */
@ -707,5 +706,5 @@ public:
Glib::RefPtr<Gtk::ListStore> getPluginControllerModel(); Glib::RefPtr<Gtk::ListStore> getPluginControllerModel();
void write_plugin_mapping (PluginMapping &mapping); void write_plugin_mapping (PluginMapping &mapping);
}; };
} } // namespace Console1
#endif /* ardour_surface_console1_h */ #endif /* ardour_surface_console1_h */

View file

@ -22,15 +22,14 @@
#include "console1.h" #include "console1.h"
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourSurface;
static ControlProtocol* static ControlProtocol*
new_console1 (Session* s) new_console1 (Session* s)
{ {
Console1* console1 = 0; Console1::Console1* console1 = 0;
try { try {
console1 = new Console1 (*s); console1 = new Console1::Console1 (*s);
} catch (failed_constructor& err) { } catch (failed_constructor& err) {
delete console1; delete console1;
console1 = 0; console1 = 0;