From b4a7f2131fe43d28741db5a6dbb6e359a8ee8caa Mon Sep 17 00:00:00 2001 From: Grygorii Zharun Date: Tue, 3 Jun 2014 02:00:17 -0500 Subject: [PATCH] [Summary] Added midi channels control support into state controller and preference panel [git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 465247] --- gtk2_ardour/device_connection_control.h | 1 - gtk2_ardour/midi_device_connection_control.cc | 171 +++++++++++++ gtk2_ardour/midi_device_connection_control.h | 65 +++++ gtk2_ardour/tracks_control_panel.cc | 5 +- gtk2_ardour/tracks_control_panel.h | 4 +- gtk2_ardour/tracks_control_panel.logic.cc | 237 ++++++++++++++---- gtk2_ardour/tracks_control_panel.logic.h | 21 +- gtk2_ardour/ui/device_playback_control.xml | 42 ---- ...re_control.xml => midi_device_control.xml} | 26 +- gtk2_ardour/ui/tracks_preferences.xml | 4 +- gtk2_ardour/wscript | 1 + libs/ardour/ardour/engine_state_controller.h | 29 ++- libs/ardour/engine_state_controller.cc | 191 +++++++++++++- 13 files changed, 685 insertions(+), 112 deletions(-) create mode 100644 gtk2_ardour/midi_device_connection_control.cc create mode 100644 gtk2_ardour/midi_device_connection_control.h delete mode 100644 gtk2_ardour/ui/device_playback_control.xml rename gtk2_ardour/ui/{midi_capture_control.xml => midi_device_control.xml} (56%) diff --git a/gtk2_ardour/device_connection_control.h b/gtk2_ardour/device_connection_control.h index f84c11ef2b..9f47262455 100644 --- a/gtk2_ardour/device_connection_control.h +++ b/gtk2_ardour/device_connection_control.h @@ -24,7 +24,6 @@ #include #include "waves_ui.h" -class XMLTree; class DeviceConnectionControl : public Gtk::Layout { diff --git a/gtk2_ardour/midi_device_connection_control.cc b/gtk2_ardour/midi_device_connection_control.cc new file mode 100644 index 0000000000..3e2c3f666e --- /dev/null +++ b/gtk2_ardour/midi_device_connection_control.cc @@ -0,0 +1,171 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + */ + +#include "midi_device_connection_control.h" +#include "pbd/convert.h" + +const char * MidiDeviceConnectionControl::capture_id_name = "_capture_id_name"; +const char * MidiDeviceConnectionControl::playback_id_name = "_playback_id_name"; + + +MidiDeviceConnectionControl::MidiDeviceConnectionControl (const std::string& midi_device_name, + bool has_capture, bool capture_active, + bool has_playback, bool playback_active) +: Gtk::Layout() +, _capture_active(false) +, _playback_active(false) +, _capture_on_button (NULL) +, _capture_off_button (NULL) +, _playback_on_button (NULL) +, _playback_off_button (NULL) +, _name_label (NULL) + +{ + build_layout("midi_device_control.xml"); + + _capture_on_button = &_children.get_waves_button ("capture_on_button"); + _capture_off_button = &_children.get_waves_button ("capture_off_button"); + + if (!has_capture) { + _capture_on_button->hide(); + _capture_off_button->hide(); + _capture_on_button = NULL; + _capture_off_button = NULL; + } + + _playback_on_button = &_children.get_waves_button ("playback_on_button"); + _playback_off_button = &_children.get_waves_button ("playback_off_button"); + + if (!has_playback) { + _playback_on_button->hide(); + _playback_off_button->hide(); + _playback_on_button = NULL; + _playback_off_button = NULL; + } + + _name_label = &_children.get_label ("midi_device_name_label"); + init(midi_device_name, capture_active, playback_active); +} + + +void MidiDeviceConnectionControl::init(const std::string& name, bool capture_active, bool playback_active ) +{ + _capture_on_button->signal_clicked.connect (sigc::mem_fun (*this, &MidiDeviceConnectionControl::on_capture_active_on)); + _capture_off_button->signal_clicked.connect (sigc::mem_fun (*this, &MidiDeviceConnectionControl::on_capture_active_off)); + _playback_on_button->signal_clicked.connect (sigc::mem_fun (*this, &MidiDeviceConnectionControl::on_playback_active_on)); + _playback_off_button->signal_clicked.connect (sigc::mem_fun (*this, &MidiDeviceConnectionControl::on_playback_active_off)); + + if (_name_label != NULL) { + _name_label->set_text (name); + } + + set_capture_active(capture_active); + set_playback_active(playback_active); +} + + +bool +MidiDeviceConnectionControl::build_layout (const std::string& file_name) +{ + const XMLTree* layout = WavesUI::load_layout(file_name); + if (layout == NULL) { + return false; + } + + XMLNode* root = layout->root(); + if ((root == NULL) || strcasecmp(root->name().c_str(), "layout")) { + return false; + } + + WavesUI::set_attributes(*this, *root, XMLNodeMap()); + WavesUI::create_ui(layout, *this, _children); + return true; +} + + +void +MidiDeviceConnectionControl::set_capture_active (bool active) +{ + if (_capture_on_button == NULL || _capture_off_button == NULL) { + return; + } + + _capture_on_button->set_active (active); + _capture_off_button->set_active (!active); + _capture_active = active; +} + + +void +MidiDeviceConnectionControl::set_playback_active (bool active) +{ + if (_playback_on_button == NULL || _playback_off_button == NULL) { + return; + } + + _playback_on_button->set_active (active); + _playback_off_button->set_active (!active); + _playback_active = active; +} + + +void +MidiDeviceConnectionControl::on_capture_active_on(WavesButton*) +{ + if (_capture_active) { + return; + } + + set_capture_active (true); + signal_capture_active_changed(this, true); +} + +void +MidiDeviceConnectionControl::on_capture_active_off(WavesButton*) +{ + if (!_capture_active) { + return; + } + + set_capture_active (false); + signal_capture_active_changed(this, false); +} + + +void +MidiDeviceConnectionControl::on_playback_active_on(WavesButton*) +{ + if (_playback_active) { + return; + } + + set_playback_active (true); + signal_playback_active_changed(this, true); +} + +void +MidiDeviceConnectionControl::on_playback_active_off(WavesButton*) +{ + if (!_playback_active) { + return; + } + + set_playback_active (false); + signal_playback_active_changed(this, false); +} diff --git a/gtk2_ardour/midi_device_connection_control.h b/gtk2_ardour/midi_device_connection_control.h new file mode 100644 index 0000000000..f6b3834097 --- /dev/null +++ b/gtk2_ardour/midi_device_connection_control.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + */ + +#ifndef __midi_device_connection_control_h__ +#define __midi_device_connection_control_h__ + +#include +#include +#include "waves_ui.h" + + +class MidiDeviceConnectionControl : public Gtk::Layout +{ +public: + + static const char* capture_id_name; + static const char* playback_id_name; + + MidiDeviceConnectionControl (const std::string& midi_device_name, + bool has_capture, bool capture_active, + bool has_playback, bool playback_active); + + bool build_layout (const std::string& file_name); + void set_capture_active (bool active); + void set_playback_active (bool active); + + sigc::signal2 signal_capture_active_changed; + sigc::signal2 signal_playback_active_changed; + +private: + void init(const std::string& name, bool capture_active, bool playback_active ); + void on_capture_active_on(WavesButton*); + void on_capture_active_off(WavesButton*); + void on_playback_active_on(WavesButton*); + void on_playback_active_off(WavesButton*); + + // flag which reflects control "active" state + bool _capture_active; + bool _playback_active; + + WavesUI::WidgetMap _children; + WavesButton* _capture_on_button; + WavesButton* _capture_off_button; + WavesButton* _playback_on_button; + WavesButton* _playback_off_button; + Gtk::Label* _name_label; +}; + +#endif // __midi_device_connection_control_h__ diff --git a/gtk2_ardour/tracks_control_panel.cc b/gtk2_ardour/tracks_control_panel.cc index e52228886c..458b0a5198 100644 --- a/gtk2_ardour/tracks_control_panel.cc +++ b/gtk2_ardour/tracks_control_panel.cc @@ -62,9 +62,8 @@ TracksControlPanel::TracksControlPanel () : WavesDialog ("tracks_preferences.xml") , _device_capture_list (named_children ().get_vbox("device_capture_list")) , _device_playback_list (named_children ().get_vbox("device_playback_list")) - , _midi_capture_list (named_children ().get_vbox("midi_capture_list")) - , _midi_playback_list (named_children ().get_vbox("midi_playback_list")) - , _all_inputs_on_button (named_children ().get_waves_button("all_inputs_on_button")) + , _midi_device_list (named_children ().get_vbox("midi_device_list")) + , _all_inputs_on_button (named_children ().get_waves_button("all_inputs_on_button")) , _all_inputs_off_button (named_children ().get_waves_button("all_inputs_off_button")) , _all_outputs_on_button (named_children ().get_waves_button("all_outputs_on_button")) , _all_outputs_off_button (named_children ().get_waves_button("all_outputs_off_button")) diff --git a/gtk2_ardour/tracks_control_panel.h b/gtk2_ardour/tracks_control_panel.h index 722f3a9631..f6cedd9467 100644 --- a/gtk2_ardour/tracks_control_panel.h +++ b/gtk2_ardour/tracks_control_panel.h @@ -33,6 +33,7 @@ #include "waves_dialog.h" #include "device_connection_control.h" +#include "midi_device_connection_control.h" class WavesButton; @@ -44,8 +45,7 @@ class TracksControlPanel : public WavesDialog, public PBD::ScopedConnectionList private: Gtk::VBox& _device_capture_list; Gtk::VBox& _device_playback_list; - Gtk::VBox& _midi_capture_list; - Gtk::VBox& _midi_playback_list; + Gtk::VBox& _midi_device_list; WavesButton& _all_inputs_on_button; WavesButton& _all_inputs_off_button; WavesButton& _all_outputs_on_button; diff --git a/gtk2_ardour/tracks_control_panel.logic.cc b/gtk2_ardour/tracks_control_panel.logic.cc index 7848a4d841..7b7cde3532 100644 --- a/gtk2_ardour/tracks_control_panel.logic.cc +++ b/gtk2_ardour/tracks_control_panel.logic.cc @@ -28,7 +28,6 @@ #include "ardour/engine_state_controller.h" #include "ardour/rc_configuration.h" -#include "device_connection_control.h" #include "ardour_ui.h" #include "gui_thread.h" #include "utils.h" @@ -58,6 +57,33 @@ namespace { return false; } } + + static const char* audio_port_name_prefix = "system:"; + static const char* midi_port_name_prefix = "system_midi:"; + static const char* midi_capture_suffix = " capture"; + static const char* midi_playback_suffix = " playback"; + + struct MidiDeviceDescriptor { + std::string name; + std::string capture_name; + bool capture_active; + std::string playback_name; + bool playback_active; + + MidiDeviceDescriptor(const std::string& name) : + name(name), + capture_name(""), + capture_active(false), + playback_name(""), + playback_active(false) + {} + + bool operator==(const MidiDeviceDescriptor& rhs) { + return name == rhs.name; + } + }; + + typedef std::vector MidiDeviceDescriptorVec; } void @@ -90,8 +116,10 @@ TracksControlPanel::init () EngineStateController::instance()->PortRegistrationChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_port_registration_update, this), gui_context()); EngineStateController::instance()->BufferSizeChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_buffer_size_update, this), gui_context()); EngineStateController::instance()->DeviceListChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_device_list_update, this, _1), gui_context()); - EngineStateController::instance()->InputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_input_configuration_changed, this), gui_context()); - EngineStateController::instance()->OutputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_output_configuration_changed, this), gui_context()); + EngineStateController::instance()->InputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_audio_input_configuration_changed, this), gui_context()); + EngineStateController::instance()->OutputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_audio_output_configuration_changed, this), gui_context()); + EngineStateController::instance()->MIDIInputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_midi_input_configuration_changed, this), gui_context()); + EngineStateController::instance()->MIDIOutputConfigChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_midi_output_configuration_changed, this), gui_context()); /* Global configuration parameters update */ Config->ParameterChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::on_parameter_changed, this, _1), gui_context()); @@ -110,21 +138,22 @@ TracksControlPanel::init () populate_input_channels(); populate_output_channels(); + populate_midi_channels(); populate_default_session_path(); _audio_settings_tab_button.set_active(true); } -DeviceConnectionControl& TracksControlPanel::add_device_capture_control(std::string device_capture_name, bool active, uint16_t capture_number, std::string track_name) +DeviceConnectionControl& TracksControlPanel::add_device_capture_control(std::string port_name, bool active, uint16_t capture_number, std::string track_name) { - std::string port_name(""); - std::string pattern("system:"); - remove_pattern_from_string(device_capture_name, pattern, port_name); + std::string device_capture_name(""); + std::string pattern(audio_port_name_prefix); + remove_pattern_from_string(port_name, pattern, device_capture_name); - DeviceConnectionControl &capture_control = *manage (new DeviceConnectionControl(port_name, active, capture_number, track_name)); + DeviceConnectionControl &capture_control = *manage (new DeviceConnectionControl(device_capture_name, active, capture_number, track_name)); - char * id_str = new char [device_capture_name.length()+1]; - std::strcpy (id_str, device_capture_name.c_str()); + char * id_str = new char [port_name.length()+1]; + std::strcpy (id_str, port_name.c_str()); capture_control.set_data(DeviceConnectionControl::id_name, id_str); _device_capture_list.pack_start (capture_control, false, false); @@ -132,16 +161,16 @@ DeviceConnectionControl& TracksControlPanel::add_device_capture_control(std::str return capture_control; } -DeviceConnectionControl& TracksControlPanel::add_device_playback_control(std::string device_playback_name, bool active, uint16_t playback_number) +DeviceConnectionControl& TracksControlPanel::add_device_playback_control(std::string port_name, bool active, uint16_t playback_number) { - std::string port_name(""); - std::string pattern("system:"); - remove_pattern_from_string(device_playback_name, pattern, port_name); + std::string device_playback_name(""); + std::string pattern(audio_port_name_prefix); + remove_pattern_from_string(port_name, pattern, device_playback_name); - DeviceConnectionControl &playback_control = *manage (new DeviceConnectionControl(port_name, active, playback_number)); + DeviceConnectionControl &playback_control = *manage (new DeviceConnectionControl(device_playback_name, active, playback_number)); - char * id_str = new char [device_playback_name.length()+1]; - std::strcpy (id_str, device_playback_name.c_str()); + char * id_str = new char [port_name.length()+1]; + std::strcpy (id_str, port_name.c_str()); playback_control.set_data(DeviceConnectionControl::id_name, id_str); _device_playback_list.pack_start (playback_control, false, false); @@ -149,20 +178,28 @@ DeviceConnectionControl& TracksControlPanel::add_device_playback_control(std::st return playback_control; } -DeviceConnectionControl& TracksControlPanel::add_midi_capture_control(std::string device_capture_name, bool active) +MidiDeviceConnectionControl& TracksControlPanel::add_midi_device_control(const std::string& midi_device_name, + const std::string& capture_name, bool capture_active, + const std::string& playback_name, bool playback_active) { - DeviceConnectionControl &capture_control = *manage (new DeviceConnectionControl(device_capture_name, active)); - _midi_capture_list.pack_start (capture_control, false, false); - capture_control.signal_active_changed.connect (sigc::mem_fun (*this, &TracksControlPanel::on_midi_capture_active_changed)); - return capture_control; -} - -DeviceConnectionControl& TracksControlPanel::add_midi_playback_control(bool active) -{ - DeviceConnectionControl &playback_control = *manage (new DeviceConnectionControl(active)); - _midi_playback_list.pack_start (playback_control, false, false); - playback_control.signal_active_changed.connect(sigc::mem_fun (*this, &TracksControlPanel::on_midi_playback_active_changed)); - return playback_control; + MidiDeviceConnectionControl &midi_device_control = *manage (new MidiDeviceConnectionControl(midi_device_name, !capture_name.empty(), capture_active, !playback_name.empty(), playback_active)); + + if (!capture_name.empty()) { + char * capture_id_str = new char [capture_name.length()+1]; + std::strcpy (capture_id_str, capture_name.c_str()); + midi_device_control.set_data(MidiDeviceConnectionControl::capture_id_name, capture_id_str); + } + + if (!playback_name.empty()) { + char * playback_id_str = new char [playback_name.length()+1]; + std::strcpy (playback_id_str, playback_name.c_str()); + midi_device_control.set_data(MidiDeviceConnectionControl::playback_id_name, playback_id_str); + } + + _midi_device_list.pack_start (midi_device_control, false, false); + midi_device_control.signal_capture_active_changed.connect (sigc::mem_fun (*this, &TracksControlPanel::on_midi_capture_active_changed)); + midi_device_control.signal_playback_active_changed.connect(sigc::mem_fun (*this, &TracksControlPanel::on_midi_playback_active_changed)); + return midi_device_control; } void @@ -318,7 +355,7 @@ TracksControlPanel::populate_input_channels() if (input_iter->active) { std::string port_name(""); - std::string pattern("system:"); + std::string pattern(audio_port_name_prefix); remove_pattern_from_string(input_iter->name, pattern, port_name); number = number_count++; @@ -367,16 +404,61 @@ TracksControlPanel::populate_output_channels() } - -void update_channel_numbers() +void +TracksControlPanel::populate_midi_channels() { + cleanup_midi_device_list(); -} - - -void update_channel_names() -{ + std::vector midi_input_states, midi_output_states; + EngineStateController::instance()->get_physical_midi_input_states(midi_input_states); + EngineStateController::instance()->get_physical_midi_output_states(midi_output_states); + // now group corresponding inputs and outputs into a vector of midi device descriptors + MidiDeviceDescriptorVec midi_device_descriptors; + std::vector::const_iterator state_iter; + // process inputs + for (state_iter = midi_input_states.begin(); state_iter != midi_input_states.end(); ++state_iter) { + // strip the device name from input port name + std::string device_name(""); + remove_pattern_from_string(state_iter->name, midi_port_name_prefix, device_name); + remove_pattern_from_string(device_name, midi_capture_suffix, device_name); + + MidiDeviceDescriptor device_descriptor(device_name); + device_descriptor.capture_name = state_iter->name; + device_descriptor.capture_active = state_iter->active; + midi_device_descriptors.push_back(device_descriptor); + } + + // process outputs + for (state_iter = midi_output_states.begin(); state_iter != midi_output_states.end(); ++state_iter){ + // strip the device name from input port name + std::string device_name(""); + remove_pattern_from_string(state_iter->name, midi_port_name_prefix, device_name); + remove_pattern_from_string(device_name, midi_playback_suffix, device_name); + + // check if we already have descriptor for this device + MidiDeviceDescriptor device_descriptor(device_name); + MidiDeviceDescriptorVec::iterator found_iter; + found_iter = std::find(midi_device_descriptors.begin(), midi_device_descriptors.end(), device_descriptor ); + + if (found_iter != midi_device_descriptors.end() ) { + found_iter->playback_name = state_iter->name; + found_iter->playback_active = state_iter->active; + } else { + device_descriptor.capture_name.clear(); + device_descriptor.playback_name = state_iter->name; + device_descriptor.playback_active = state_iter->active; + midi_device_descriptors.push_back(device_descriptor); + } + } + + // now add midi device controls + MidiDeviceDescriptorVec::iterator iter; + for (iter = midi_device_descriptors.begin(); iter != midi_device_descriptors.end(); ++iter ) { + add_midi_device_control(iter->name, + iter->capture_name, iter->capture_active, + iter->playback_name, iter->playback_active); + } } @@ -422,6 +504,28 @@ TracksControlPanel::cleanup_output_channels_list() } +void +TracksControlPanel::cleanup_midi_device_list() +{ + std::vector midi_device_controls = _midi_device_list.get_children(); + + while (midi_device_controls.size() != 0) { + Gtk::Widget* item = midi_device_controls.back(); + + MidiDeviceConnectionControl* control = dynamic_cast(item); + + if (control) { + control->remove_data(MidiDeviceConnectionControl::capture_id_name); + control->remove_data(MidiDeviceConnectionControl::capture_id_name); + } + + midi_device_controls.pop_back(); + _midi_device_list.remove(*item); + delete item; + } +} + + void TracksControlPanel::on_control_panel(WavesButton*) { @@ -808,13 +912,17 @@ void TracksControlPanel::on_playback_active_changed(DeviceConnectionControl* pla } -void TracksControlPanel::on_midi_capture_active_changed(DeviceConnectionControl* capture_control, bool active) +void TracksControlPanel::on_midi_capture_active_changed(MidiDeviceConnectionControl* control, bool active) { + const char * id_name = (char*)control->get_data(MidiDeviceConnectionControl::capture_id_name); + EngineStateController::instance()->set_physical_midi_input_state(id_name, active); } -void TracksControlPanel::on_midi_playback_active_changed(DeviceConnectionControl* playback_control, bool active) +void TracksControlPanel::on_midi_playback_active_changed(MidiDeviceConnectionControl* control, bool active) { + const char * id_name = (char*)control->get_data(MidiDeviceConnectionControl::playback_id_name); + EngineStateController::instance()->set_physical_midi_output_state(id_name, active); } @@ -822,6 +930,7 @@ void TracksControlPanel::on_port_registration_update() { populate_input_channels(); populate_output_channels(); + populate_midi_channels(); } @@ -861,13 +970,13 @@ TracksControlPanel::on_parameter_changed (const std::string& parameter_name) if (parameter_name == "output-auto-connect") { populate_output_mode(); } else if (parameter_name == "tracks-auto-naming") { - on_input_configuration_changed (); + on_audio_input_configuration_changed (); } } void -TracksControlPanel::on_input_configuration_changed () +TracksControlPanel::on_audio_input_configuration_changed () { std::vector capture_controls = _device_capture_list.get_children(); @@ -905,7 +1014,7 @@ TracksControlPanel::on_input_configuration_changed () void -TracksControlPanel::on_output_configuration_changed() +TracksControlPanel::on_audio_output_configuration_changed() { std::vector playback_controls = _device_playback_list.get_children(); @@ -934,7 +1043,47 @@ TracksControlPanel::on_output_configuration_changed() } - + +void +TracksControlPanel::on_midi_input_configuration_changed () +{ + std::vector midi_controls = _midi_device_list.get_children(); + + std::vector::iterator control_iter = midi_controls.begin(); + + for (; control_iter != midi_controls.end(); ++control_iter) { + MidiDeviceConnectionControl* control = dynamic_cast (*control_iter); + + if (control) { + + const char* capture_id_name = (char*)control->get_data(MidiDeviceConnectionControl::capture_id_name); + bool new_state = EngineStateController::instance()->get_physical_midi_input_state(capture_id_name ); + control->set_capture_active(new_state); + } + } +} + + +void +TracksControlPanel::on_midi_output_configuration_changed () +{ + std::vector midi_controls = _midi_device_list.get_children(); + + std::vector::iterator control_iter = midi_controls.begin(); + + for (; control_iter != midi_controls.end(); ++control_iter) { + MidiDeviceConnectionControl* control = dynamic_cast (*control_iter); + + if (control) { + + const char* playback_id_name = (char*)control->get_data(MidiDeviceConnectionControl::playback_id_name); + bool new_state = EngineStateController::instance()->get_physical_midi_output_state(playback_id_name); + control->set_playback_active(new_state); + } + } +} + + std::string TracksControlPanel::bufsize_as_string (uint32_t sz) { diff --git a/gtk2_ardour/tracks_control_panel.logic.h b/gtk2_ardour/tracks_control_panel.logic.h index ea45ebc044..ffd9a7cb06 100644 --- a/gtk2_ardour/tracks_control_panel.logic.h +++ b/gtk2_ardour/tracks_control_panel.logic.h @@ -65,10 +65,11 @@ // methods virtual void init(); - DeviceConnectionControl& add_device_capture_control(std::string device_capture_name, bool active, uint16_t capture_number, std::string track_name); - DeviceConnectionControl& add_device_playback_control(std::string device_playback_name, bool active, uint16_t playback_number); - DeviceConnectionControl& add_midi_capture_control(std::string device_capture_name, bool active); - DeviceConnectionControl& add_midi_playback_control(bool active); + DeviceConnectionControl& add_device_capture_control(std::string port_name, bool active, uint16_t capture_number, std::string track_name); + DeviceConnectionControl& add_device_playback_control(std::string port_name, bool active, uint16_t playback_number); + MidiDeviceConnectionControl& add_midi_device_control(const std::string& midi_device_name, + const std::string& capture_name, bool capture_active, + const std::string& playback_name, bool playback_active); void on_audio_settings (WavesButton*); void on_midi_settings (WavesButton*); @@ -83,8 +84,8 @@ void on_apply(WavesButton*); void on_capture_active_changed (DeviceConnectionControl* capture_control, bool active); void on_playback_active_changed (DeviceConnectionControl* playback_control, bool active); - void on_midi_capture_active_changed (DeviceConnectionControl* capture_control, bool active); - void on_midi_playback_active_changed (DeviceConnectionControl* playback_control, bool active); + void on_midi_capture_active_changed (MidiDeviceConnectionControl* control, bool active); + void on_midi_playback_active_changed (MidiDeviceConnectionControl* control, bool active); void on_all_inputs_on_button(WavesButton*); void on_all_inputs_off_button(WavesButton*); void on_all_outputs_on_button(WavesButton*); @@ -106,6 +107,7 @@ void populate_output_mode (); void populate_input_channels(); void populate_output_channels(); + void populate_midi_channels(); void populate_default_session_path(); // Engine State update callback handlers @@ -113,11 +115,14 @@ void on_buffer_size_update (); void on_device_list_update (bool current_device_disconnected); void on_parameter_changed (const std::string& parameter_name); - void on_input_configuration_changed (); - void on_output_configuration_changed (); + void on_audio_input_configuration_changed (); + void on_audio_output_configuration_changed (); + void on_midi_input_configuration_changed (); + void on_midi_output_configuration_changed (); void cleanup_input_channels_list(); void cleanup_output_channels_list(); + void cleanup_midi_device_list(); std::string bufsize_as_string (uint32_t sz); diff --git a/gtk2_ardour/ui/device_playback_control.xml b/gtk2_ardour/ui/device_playback_control.xml deleted file mode 100644 index d690764071..0000000000 --- a/gtk2_ardour/ui/device_playback_control.xml +++ /dev/null @@ -1,42 +0,0 @@ - - -