13
0

add options to swap mute and solo and to create mapping stops

This commit is contained in:
Hoger Dehnhardt 2023-05-30 08:22:25 +02:00 committed by Paul Davis
parent 7634c4936c
commit e22a0eb1db
6 changed files with 193 additions and 112 deletions

View File

@ -16,28 +16,26 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "c1_gui.h"
#include <gtkmm/alignment.h>
#include <gtkmm/label.h>
#include <gtkmm/liststore.h>
#include "pbd/unwind.h"
#include "pbd/strsplit.h"
#include "pbd/file_utils.h"
#include "pbd/i18n.h"
#include "pbd/strsplit.h"
#include "pbd/unwind.h"
#include "ardour/audioengine.h"
#include "ardour/debug.h"
#include "ardour/filesystem_paths.h"
#include "ardour/parameter_descriptor.h"
#include "console1.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/utils.h"
#include "ardour/audioengine.h"
#include "ardour/filesystem_paths.h"
#include "ardour/parameter_descriptor.h"
#include "ardour/debug.h"
#include "console1.h"
#include "c1_gui.h"
#include "pbd/i18n.h"
using namespace PBD;
using namespace ARDOUR;
using namespace ArdourSurface;
@ -79,8 +77,9 @@ Console1::build_gui ()
C1GUI::C1GUI (Console1& p)
: c1 (p)
, table (2, 5)
, action_table (5, 4)
, table (6, 4)
, swap_solo_mute_cb ()
, create_plugin_stubs_btn ()
, ignore_active_change (false)
{
set_border_width (12);
@ -101,14 +100,26 @@ C1GUI::C1GUI (Console1& p)
}
Gtk::Label* l;
Gtk::Alignment* align;
int row = 0;
input_combo.pack_start (midi_port_columns.short_name);
output_combo.pack_start (midi_port_columns.short_name);
input_combo.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &C1GUI::active_port_changed), &input_combo, true));
output_combo.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &C1GUI::active_port_changed), &output_combo, false));
input_combo.signal_changed ().connect (
sigc::bind (sigc::mem_fun (*this, &C1GUI::active_port_changed), &input_combo, true));
output_combo.signal_changed ().connect (
sigc::bind (sigc::mem_fun (*this, &C1GUI::active_port_changed), &output_combo, false));
// swap_solo_mute (_ ("Swap Solo and Mute"));
swap_solo_mute_cb.set_tooltip_text (
_ ("If checked Ardour the mute and solo buttons are swept so they have the same order as in the GUI."));
swap_solo_mute_cb.set_active (p.swap_solo_mute);
swap_solo_mute_cb.signal_toggled ().connect (sigc::mem_fun (*this, &C1GUI::set_swap_solo_mute));
// create_plugin_stubs (_ ("Create Plugin Mapping Stubs"));
create_plugin_stubs_btn.set_tooltip_text (_ ("If checked a mapping stub is created for every unknown plugin."));
create_plugin_stubs_btn.set_active (p.create_mapping_stubs);
create_plugin_stubs_btn.signal_toggled ().connect (sigc::mem_fun (*this, &C1GUI::set_create_mapping_stubs));
l = manage (new Gtk::Label);
l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _ ("Incoming MIDI on:")));
@ -124,6 +135,20 @@ C1GUI::C1GUI (Console1& p)
table.attach (output_combo, 1, 2, row, row + 1, AttachOptions (FILL | EXPAND), AttachOptions (0), 0, 0);
row++;
l = manage (new Gtk::Label);
l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _ ("Swap Solo and Mute:")));
l->set_alignment (1.0, 0.5);
table.attach (*l, 0, 1, row, row + 1, AttachOptions (FILL | EXPAND), AttachOptions (0));
table.attach (swap_solo_mute_cb, 1, 2, row, row + 1);
row++;
l = manage (new Gtk::Label);
l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _ ("Create Plugin Mapping Stubs:")));
l->set_alignment (1.0, 0.5);
table.attach (*l, 0, 1, row, row + 1, AttachOptions (FILL | EXPAND), AttachOptions (0));
table.attach (create_plugin_stubs_btn, 1, 2, row, row + 1);
row++;
hpacker.pack_start (table, true, true);
set_spacing (12);
@ -136,13 +161,26 @@ C1GUI::C1GUI (Console1& p)
/* catch future changes to connection state */
ARDOUR::AudioEngine::instance()->PortRegisteredOrUnregistered.connect (_port_connections, invalidator (*this), boost::bind (&C1GUI::connection_handler, this), gui_context());
ARDOUR::AudioEngine::instance()->PortPrettyNameChanged.connect (_port_connections, invalidator (*this), boost::bind (&C1GUI::connection_handler, this), gui_context());
c1.ConnectionChange.connect (_port_connections, invalidator (*this), boost::bind (&C1GUI::connection_handler, this), gui_context());
ARDOUR::AudioEngine::instance ()->PortRegisteredOrUnregistered.connect (
_port_connections, invalidator (*this), boost::bind (&C1GUI::connection_handler, this), gui_context ());
ARDOUR::AudioEngine::instance ()->PortPrettyNameChanged.connect (
_port_connections, invalidator (*this), boost::bind (&C1GUI::connection_handler, this), gui_context ());
c1.ConnectionChange.connect (
_port_connections, invalidator (*this), boost::bind (&C1GUI::connection_handler, this), gui_context ());
}
C1GUI::~C1GUI ()
C1GUI::~C1GUI () {}
void
C1GUI::set_swap_solo_mute ()
{
c1.swap_solo_mute = !c1.swap_solo_mute;
}
void
C1GUI::set_create_mapping_stubs ()
{
c1.create_mapping_stubs = !c1.create_mapping_stubs;
}
void
@ -164,8 +202,10 @@ C1GUI::update_port_combos ()
vector<string> midi_inputs;
vector<string> midi_outputs;
ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsTerminal), midi_inputs);
ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsTerminal), midi_outputs);
ARDOUR::AudioEngine::instance ()->get_ports (
"", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput | ARDOUR::IsTerminal), midi_inputs);
ARDOUR::AudioEngine::instance ()->get_ports (
"", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput | ARDOUR::IsTerminal), midi_outputs);
Glib::RefPtr<Gtk::ListStore> input = build_midi_port_list (midi_inputs, true);
Glib::RefPtr<Gtk::ListStore> output = build_midi_port_list (midi_outputs, false);
@ -181,7 +221,6 @@ C1GUI::update_port_combos ()
i = children.begin ();
++i; /* skip "Disconnected" */
for (n = 1; i != children.end (); ++i, ++n) {
string port_name = (*i)[midi_port_columns.full_name];
if (c1.input_port ()->connected_to (port_name)) {

View File

@ -24,6 +24,7 @@
#include <gtkmm/box.h>
#include <gtkmm/combobox.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/image.h>
#include <gtkmm/table.h>
#include <gtkmm/treestore.h>
@ -52,10 +53,11 @@ private:
PBD::ScopedConnectionList lcxl_connections;
Gtk::VBox hpacker;
Gtk::Table table;
Gtk::Table action_table;
Gtk::ComboBox input_combo;
Gtk::ComboBox output_combo;
Gtk::Image image;
Gtk::CheckButton swap_solo_mute_cb;
Gtk::CheckButton create_plugin_stubs_btn;
void update_port_combos ();
PBD::ScopedConnection connection_change_connection;
@ -77,6 +79,9 @@ private:
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
void active_port_changed (Gtk::ComboBox*,bool for_input);
void set_swap_solo_mute ();
void set_create_mapping_stubs ();
};
}

View File

@ -43,11 +43,13 @@ Console1::bank (bool up)
if ((current_bank + 1) * bank_size < list_size) {
changed = true;
++current_bank;
current_strippable_index = 0;
}
} else {
if (current_bank > 0) {
changed = true;
--current_bank;
current_strippable_index = bank_size - 1;
}
}
if (changed) {
@ -134,7 +136,7 @@ void
Console1::select (const uint32_t i)
{
uint32_t strip_index = current_bank * bank_size + i;
DEBUG_TRACE (DEBUG::Console1, string_compose ("select( %1 ) : idx %2\n", i, strip_index));
DEBUG_TRACE (DEBUG::Console1, string_compose ("select( %1 / %2 ) : idx %3\n", current_bank, i, strip_index));
select_rid_by_index (strip_index);
}
@ -581,19 +583,19 @@ Console1::map_mute ()
DEBUG_TRACE (DEBUG::Console1, "Console1::map_mute ...\n");
if (_current_stripable) {
if (_current_stripable->mute_control ()->muted ()) {
get_button (MUTE)->set_led_state (true);
get_button (swap_solo_mute ? SOLO : MUTE)->set_led_state (true);
} else if (_current_stripable->mute_control ()->muted_by_others_soloing () ||
_current_stripable->mute_control ()->muted_by_masters ()) {
DEBUG_TRACE (DEBUG::Console1, "Console1::map_mute start blinking\n");
start_blinking (MUTE);
start_blinking (swap_solo_mute ? SOLO : MUTE);
} else {
DEBUG_TRACE (DEBUG::Console1, "Console1::map_mute stop blinking\n");
stop_blinking (MUTE);
stop_blinking (swap_solo_mute ? SOLO : MUTE);
}
} else {
DEBUG_TRACE (DEBUG::Console1, "Console1::map_mute stop blinking 2\n");
stop_blinking (MUTE);
stop_blinking (swap_solo_mute ? SOLO : MUTE);
}
}
@ -612,7 +614,7 @@ Console1::map_phase ()
{
DEBUG_TRACE (DEBUG::Console1, "map_phase \n");
ControllerButton* controllerButton = get_button (PHASE_INV);
if (_current_stripable) {
if (_current_stripable && _current_stripable->phase_control ()) {
uint32_t channels = _current_stripable->phase_control ()->size ();
uint32_t inverted = 0;
for (uint32_t i = 0; i < channels; ++i) {
@ -692,7 +694,7 @@ Console1::map_solo ()
{
DEBUG_TRACE (DEBUG::Console1, "map_solo()\n");
try {
ControllerButton* controllerButton = get_button (SOLO);
ControllerButton* controllerButton = get_button (swap_solo_mute ? MUTE : SOLO);
if (_current_stripable) {
controllerButton->set_led_state (_current_stripable->solo_control ()->soloed ());
} else {

View File

@ -338,7 +338,7 @@ Console1::spill_plugins (const int32_t plugin_index)
PluginMappingMap::iterator pmmit = pluginMappingMap.find (plugin->unique_id ());
mapping_found = (pmmit != pluginMappingMap.end ());
if (!mapping_found) {
if (!mapping_found && create_mapping_stubs ) {
create_mapping (proc, plugin);
return true;
}

View File

@ -16,12 +16,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "console1.h"
#include <chrono>
#include <thread>
#include <glibmm-2.4/glibmm/main.h>
#include <boost/optional.hpp>
#include <glibmm-2.4/glibmm/main.h>
#include "pbd/abstract_ui.cc" // instantiate template
#include "pbd/controllable.h"
@ -38,8 +39,6 @@
#include "ardour/stripable.h"
#include "ardour/track.h"
#include "ardour/vca_manager.h"
#include "console1.h"
#include "c1_control.h"
#include "c1_gui.h"
@ -139,6 +138,27 @@ Console1::input_port_name () const
#endif
}
XMLNode&
Console1::get_state () const
{
XMLNode& node = MIDISurface::get_state ();
node.set_property ("swap-solo-mute", swap_solo_mute);
node.set_property ("create-mapping-stubs", create_mapping_stubs);
return node;
}
int
Console1::set_state (const XMLNode& node, int version)
{
MIDISurface::set_state (node, version);
std::string tmp;
node.get_property ("swap-solo-mute", tmp);
swap_solo_mute = (tmp == "1");
node.get_property ("create-mapping-stubs", tmp);
create_mapping_stubs = (tmp == "1");
return 0;
}
std::string
Console1::output_port_name () const
{
@ -192,10 +212,10 @@ Console1::connect_session_signals ()
DEBUG_TRACE (DEBUG::Console1, "connect_session_signals\n");
// receive routes added
session->RouteAdded.connect (
session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::create_strip_invetory, this), this);
session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::create_strip_inventory, this), this);
// receive VCAs added
session->vca_manager ().VCAAdded.connect (
session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::create_strip_invetory, this), this);
session_connections, MISSING_INVALIDATOR, boost::bind (&Console1::create_strip_inventory, this), this);
// receive record state toggled
// session->RecordStateChanged.connect(session_connections,
@ -241,7 +261,7 @@ void
Console1::notify_session_loaded ()
{
DEBUG_TRACE (DEBUG::Console1, "************** Session Loaded() ********************\n");
create_strip_invetory ();
create_strip_inventory ();
connect_internal_signals ();
if (session) {
DEBUG_TRACE (DEBUG::Console1, "session available\n");
@ -289,10 +309,13 @@ Console1::setup_controls ()
new ControllerButton (
this, ControllerID::PAGE_DOWN, boost::function<void (uint32_t)> (boost::bind (&Console1::bank, this, false)));
new ControllerButton (
this, ControllerID::MUTE, boost::function<void (uint32_t)> (boost::bind (&Console1::mute, this, _1)));
new ControllerButton (
this, ControllerID::SOLO, boost::function<void (uint32_t)> (boost::bind (&Console1::solo, this, _1)));
new ControllerButton (this,
swap_solo_mute ? ControllerID::SOLO : ControllerID::MUTE,
boost::function<void (uint32_t)> (boost::bind (&Console1::mute, this, _1)));
new ControllerButton (this,
swap_solo_mute ? ControllerID::MUTE : ControllerID::SOLO,
boost::function<void (uint32_t)> (boost::bind (&Console1::solo, this, _1)));
new ControllerButton (
this, ControllerID::PHASE_INV, boost::function<void (uint32_t)> (boost::bind (&Console1::phase, this, _1)));
@ -523,6 +546,7 @@ Console1::stripable_selection_changed ()
void
Console1::drop_current_stripable ()
{
DEBUG_TRACE (DEBUG::Console1, "drop_current_stripable \n");
if (_current_stripable) {
if (_current_stripable == session->monitor_out ()) {
set_current_stripable (session->master_out ());
@ -576,14 +600,20 @@ Console1::set_current_stripable (std::shared_ptr<Stripable> r)
_current_stripable->DropReferences.connect (
stripable_connections, MISSING_INVALIDATOR, boost::bind (&Console1::drop_current_stripable, this), this);
if (_current_stripable->mute_control ()) {
_current_stripable->mute_control ()->Changed.connect (
stripable_connections, MISSING_INVALIDATOR, boost::bind (&Console1::map_mute, this), this);
}
if (_current_stripable->solo_control ()) {
_current_stripable->solo_control ()->Changed.connect (
stripable_connections, MISSING_INVALIDATOR, boost::bind (&Console1::map_solo, this), this);
}
if (_current_stripable->phase_control ()) {
_current_stripable->phase_control ()->Changed.connect (
stripable_connections, MISSING_INVALIDATOR, boost::bind (&Console1::map_phase, this), this);
}
// Rec Enabled
std::shared_ptr<Track> t = std::dynamic_pointer_cast<Track> (_current_stripable);
@ -1091,16 +1121,17 @@ Console1::midi_to_control (Controllable controllable, uint32_t val, uint32_t max
}
void
Console1::create_strip_invetory ()
Console1::create_strip_inventory ()
{
DEBUG_TRACE (DEBUG::Console1, "create_strip_invetory()\n");
StripableList sl;
DEBUG_TRACE (DEBUG::Console1, "create_strip_inventory()\n");
// StripableList sl;
boost::optional<order_t> master_order;
strip_inventory.clear ();
session->get_stripables (sl);
StripableList sl = session->get_stripables ();
uint32_t index = 0;
for (const auto& s : sl) {
PresentationInfo pi = s->presentation_info ();
DEBUG_TRACE (DEBUG::Console1, string_compose ("%1: ", s->name ()));
if (pi.flags () & ARDOUR::PresentationInfo::Hidden) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("strip hidden: index %1, order %2\n", index, pi.order ()));
continue;
@ -1113,7 +1144,7 @@ Console1::create_strip_invetory ()
}
if (pi.flags () & ARDOUR::PresentationInfo::MonitorOut) {
DEBUG_TRACE (DEBUG::Console1,
string_compose ("monitor strip found at index %1, order %2\n", index, pi.order ()));
string_compose ("monitor strip found at index %1, order %2 - ignoring\n", index, pi.order ()));
continue;
}
strip_inventory.insert (std::make_pair (index, pi.order ()));
@ -1124,7 +1155,7 @@ Console1::create_strip_invetory ()
strip_inventory.insert (std::make_pair (index, master_order.value ()));
}
DEBUG_TRACE (DEBUG::Console1,
string_compose ("create_strip_invetory - inventory size %1\n", strip_inventory.size ()));
string_compose ("create_strip_inventory - inventory size %1\n", strip_inventory.size ()));
}
order_t

View File

@ -105,8 +105,12 @@ class Console1 : public MIDISurface
std::string input_port_name () const override;
std::string output_port_name () const override;
/*XMLNode& get_state () const;
int set_state (const XMLNode&, int version);*/
XMLNode& get_state () const override;
int set_state (const XMLNode&, int version) override;
bool swap_solo_mute;
bool create_mapping_stubs;
PBD::Signal0<void> ConnectionChange;
/* Timer Events */
@ -326,7 +330,7 @@ class Console1 : public MIDISurface
StripInventoryMap strip_inventory;
void create_strip_invetory ();
void create_strip_inventory ();
order_t get_inventory_order_by_index (const uint32_t index);
uint32_t get_index_by_inventory_order (order_t order);