varied and wide changes to get input and output combos closer to working
This commit is contained in:
@@ -239,6 +239,67 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
|
||||
fkey_packer->show_all();
|
||||
}
|
||||
|
||||
void
|
||||
MackieControlProtocolGUI::update_port_combos (vector<string> const& midi_inputs, vector<string> const& midi_outputs,
|
||||
Gtk::ComboBoxText* input_combo,
|
||||
Gtk::ComboBoxText* output_combo,
|
||||
boost::shared_ptr<Surface> surface)
|
||||
{
|
||||
vector<string> short_midi_inputs;
|
||||
vector<string> short_midi_outputs;
|
||||
|
||||
/* Prepend "Disconnected" */
|
||||
|
||||
short_midi_inputs.push_back (_("Disconnected"));
|
||||
short_midi_outputs.push_back (_("Disconnected"));
|
||||
|
||||
/* generate short versions of all the port names */
|
||||
|
||||
for (vector<string>::const_iterator s = midi_inputs.begin(); s != midi_inputs.end(); ++s) {
|
||||
short_midi_inputs.push_back ((*s).substr ((*s).find (':') + 1));
|
||||
}
|
||||
for (vector<string>::const_iterator s = midi_outputs.begin(); s != midi_outputs.end(); ++s) {
|
||||
short_midi_outputs.push_back ((*s).substr ((*s).find (':') + 1));
|
||||
}
|
||||
|
||||
bool input_found = false;
|
||||
bool output_found = true;
|
||||
|
||||
Gtkmm2ext::set_popdown_strings (*input_combo, short_midi_inputs);
|
||||
|
||||
vector<string>::iterator shrt = short_midi_inputs.begin();
|
||||
shrt++; /* skip "Disconnected" */
|
||||
|
||||
for (vector<string>::const_iterator s = midi_inputs.begin(); s != midi_inputs.end(); ++s, ++shrt) {
|
||||
if (surface->port().input().connected_to (*s)) {
|
||||
input_combo->set_active_text (*shrt);
|
||||
input_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!input_found) {
|
||||
input_combo->set_active_text (_("Disconnected"));
|
||||
}
|
||||
|
||||
Gtkmm2ext::set_popdown_strings (*output_combo, short_midi_outputs);
|
||||
|
||||
shrt = short_midi_outputs.begin();
|
||||
shrt++; /* skip "Disconnected" */
|
||||
|
||||
for (vector<string>::const_iterator s = midi_outputs.begin(); s != midi_outputs.end(); ++s, ++shrt) {
|
||||
if (surface->port().output().connected_to (*s)) {
|
||||
output_combo->set_active_text (*shrt);
|
||||
output_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!output_found) {
|
||||
output_combo->set_active_text (_("Disconnected"));
|
||||
}
|
||||
}
|
||||
|
||||
Gtk::Widget*
|
||||
MackieControlProtocolGUI::device_dependent_widget ()
|
||||
{
|
||||
@@ -267,22 +328,13 @@ MackieControlProtocolGUI::device_dependent_widget ()
|
||||
ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
|
||||
ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
|
||||
|
||||
|
||||
port_combos.clear ();
|
||||
input_combos.clear ();
|
||||
output_combos.clear ();
|
||||
|
||||
if (!_cp.device_info().uses_ipmidi()) {
|
||||
|
||||
for (uint32_t n = 0; n < n_surfaces; ++n) {
|
||||
|
||||
|
||||
Gtk::ComboBoxText* input_combo = manage (new Gtk::ComboBoxText);
|
||||
Gtk::ComboBoxText* output_combo = manage (new Gtk::ComboBoxText);
|
||||
|
||||
port_combos.push_back (input_combo);
|
||||
port_combos.push_back (output_combo);
|
||||
|
||||
Gtkmm2ext::set_popdown_strings (*output_combo, midi_outputs);
|
||||
Gtkmm2ext::set_popdown_strings (*input_combo, midi_inputs);
|
||||
|
||||
boost::shared_ptr<Surface> surface = _cp.nth_surface (n);
|
||||
|
||||
if (!surface) {
|
||||
@@ -290,20 +342,16 @@ MackieControlProtocolGUI::device_dependent_widget ()
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
for (vector<string>::iterator s = midi_inputs.begin(); s != midi_inputs.end(); ++s) {
|
||||
Gtk::ComboBoxText* input_combo = manage (new Gtk::ComboBoxText);
|
||||
Gtk::ComboBoxText* output_combo = manage (new Gtk::ComboBoxText);
|
||||
|
||||
if (surface->port().input().connected_to (*s)) {
|
||||
input_combo->set_active_text (*s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
input_combo->set_data ("surface", surface.get());
|
||||
output_combo->set_data ("surface", surface.get());
|
||||
|
||||
for (vector<string>::iterator s = midi_outputs.begin(); s != midi_outputs.end(); ++s) {
|
||||
if (surface->port().output().connected_to (*s)) {
|
||||
output_combo->set_active_text (*s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
input_combos.push_back (input_combo);
|
||||
output_combos.push_back (output_combo);
|
||||
|
||||
update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
|
||||
|
||||
string send_string;
|
||||
string receive_string;
|
||||
@@ -721,7 +769,7 @@ void
|
||||
MackieControlProtocolGUI::surface_combo_changed ()
|
||||
{
|
||||
_cp.not_session_load();
|
||||
_cp.set_device (_surface_combo.get_active_text());
|
||||
_cp.set_device (_surface_combo.get_active_text(), false);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -779,3 +827,47 @@ MackieControlProtocolGUI::touch_sensitive_change ()
|
||||
int sensitivity = (int) touch_sensitivity_adjustment.get_value ();
|
||||
_cp.set_touch_sensitivity (sensitivity);
|
||||
}
|
||||
|
||||
void
|
||||
MackieControlProtocolGUI::surface_connectivity_change (Surface* raw_surface)
|
||||
{
|
||||
boost::shared_ptr<Surface> surface;
|
||||
|
||||
for (MackieControlProtocol::Surfaces::iterator s = _cp.surfaces.begin(); s != _cp.surfaces.end(); ++s) {
|
||||
if ((*s).get() == raw_surface) {
|
||||
surface = *s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::ComboBoxText* input_combo = 0;
|
||||
Gtk::ComboBoxText* output_combo = 0;
|
||||
|
||||
for (vector<Gtk::ComboBoxText*>::iterator c = input_combos.begin(); c != input_combos.end(); ++c) {
|
||||
if ((*c)->get_data ("surface") == raw_surface) {
|
||||
input_combo = *c;
|
||||
}
|
||||
}
|
||||
|
||||
for (vector<Gtk::ComboBoxText*>::iterator c = output_combos.begin(); c != output_combos.end(); ++c) {
|
||||
if ((*c)->get_data ("surface") == raw_surface) {
|
||||
output_combo = *c;
|
||||
}
|
||||
}
|
||||
|
||||
if (!input_combo || !output_combo) {
|
||||
return;
|
||||
}
|
||||
|
||||
vector<string> midi_inputs;
|
||||
vector<string> midi_outputs;
|
||||
|
||||
ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
|
||||
ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
|
||||
|
||||
update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ namespace ArdourSurface {
|
||||
|
||||
class MackieControlProtocol;
|
||||
|
||||
namespace Mackie {
|
||||
class Surface;
|
||||
}
|
||||
|
||||
class MackieControlProtocolGUI : public Gtk::Notebook
|
||||
{
|
||||
public:
|
||||
@@ -51,7 +55,8 @@ class MackieControlProtocolGUI : public Gtk::Notebook
|
||||
Gtk::ComboBoxText _profile_combo;
|
||||
|
||||
typedef std::vector<Gtk::ComboBoxText*> PortCombos;
|
||||
PortCombos port_combos;
|
||||
PortCombos input_combos;
|
||||
PortCombos output_combos;
|
||||
|
||||
struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
|
||||
AvailableActionColumns() {
|
||||
@@ -124,6 +129,17 @@ class MackieControlProtocolGUI : public Gtk::Notebook
|
||||
|
||||
PBD::ScopedConnection device_change_connection;
|
||||
void device_changed ();
|
||||
|
||||
void update_port_combos (std::vector<std::string> const&, std::vector<std::string> const&,
|
||||
Gtk::ComboBoxText* input_combo,
|
||||
Gtk::ComboBoxText* output_combo,
|
||||
boost::shared_ptr<Mackie::Surface> surface);
|
||||
|
||||
/* this takes a raw pointer to Surface, because it connects to a signal
|
||||
emitted by a Surface and we don't want to use
|
||||
boost::shared_from_this.
|
||||
*/
|
||||
void surface_connectivity_change (Mackie::Surface* raw_surface);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -686,19 +686,20 @@ MackieControlProtocol::set_device_info (const string& device_name)
|
||||
}
|
||||
|
||||
int
|
||||
MackieControlProtocol::set_device (const string& device_name)
|
||||
MackieControlProtocol::set_device (const string& device_name, bool force)
|
||||
{
|
||||
if (device_name == device_info().name()) {
|
||||
if (device_name == device_info().name() && !force) {
|
||||
/* already using that device, nothing to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (set_device_info (device_name)) {
|
||||
cerr << "Unknown device name\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
clear_surfaces ();
|
||||
|
||||
port_connection.disconnect ();
|
||||
hui_connection.disconnect ();
|
||||
|
||||
if (_device_info.device_type() == DeviceInfo::HUI) {
|
||||
@@ -711,6 +712,10 @@ MackieControlProtocol::set_device (const string& device_name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_device_info.uses_ipmidi()) {
|
||||
ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::connection_handler, this, _1, _2, _3, _4, _5), this);
|
||||
}
|
||||
|
||||
switch_banks (0, true);
|
||||
|
||||
DeviceChanged ();
|
||||
@@ -1766,10 +1771,14 @@ MackieControlProtocol::ipmidi_restart ()
|
||||
void
|
||||
MackieControlProtocol::clear_surfaces ()
|
||||
{
|
||||
port_connection.disconnect ();
|
||||
clear_ports ();
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
_master_surface.reset ();
|
||||
surfaces.clear ();
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
_master_surface.reset ();
|
||||
surfaces.clear ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1818,3 +1827,17 @@ MackieControlProtocol::nth_surface (uint32_t n) const
|
||||
|
||||
return boost::shared_ptr<Surface> ();
|
||||
}
|
||||
|
||||
void
|
||||
MackieControlProtocol::connection_handler (boost::weak_ptr<ARDOUR::Port> wp1, std::string name1, boost::weak_ptr<ARDOUR::Port> wp2, std::string name2, bool yn)
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
|
||||
for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
|
||||
if ((*s)->connection_handler (wp1, name1, wp2, name2, yn)) {
|
||||
cerr << (*s)->name() << " Connected, or disconnected\n";
|
||||
ConnectionChange (*s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
namespace ARDOUR {
|
||||
class AutomationControl;
|
||||
class Port;
|
||||
}
|
||||
|
||||
namespace MIDI {
|
||||
@@ -133,11 +134,12 @@ class MackieControlProtocol
|
||||
Mackie::DeviceProfile& device_profile() { return _device_profile; }
|
||||
|
||||
PBD::Signal0<void> DeviceChanged;
|
||||
PBD::Signal1<void,boost::shared_ptr<Mackie::Surface> > ConnectionChange;
|
||||
|
||||
void device_ready ();
|
||||
|
||||
int set_active (bool yn);
|
||||
int set_device (const std::string&);
|
||||
int set_device (const std::string&, bool force);
|
||||
void set_profile (const std::string&);
|
||||
|
||||
FlipMode flip_mode () const { return _flip_mode; }
|
||||
@@ -350,6 +352,11 @@ class MackieControlProtocol
|
||||
void initialize ();
|
||||
int set_device_info (const std::string& device_name);
|
||||
|
||||
/* MIDI port connection management */
|
||||
|
||||
PBD::ScopedConnection port_connection;
|
||||
void connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool);
|
||||
|
||||
/* BUTTON HANDLING */
|
||||
|
||||
typedef std::set<uint32_t> DownButtonList;
|
||||
|
||||
@@ -125,9 +125,7 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
|
||||
DEBUG_TRACE (DEBUG::MackieControl, "init_strips done\n");
|
||||
}
|
||||
|
||||
if (!_mcp.device_info().uses_ipmidi()) {
|
||||
ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&Surface::connection_handler, this, _1, _2, _3, _4, _5), &_mcp);
|
||||
} else {
|
||||
if (_mcp.device_info().uses_ipmidi()) {
|
||||
/* ipMIDI port already exists, we can just assume that we're
|
||||
* connected.
|
||||
*
|
||||
@@ -149,8 +147,6 @@ Surface::~Surface ()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::MackieControl, "Surface::~Surface init\n");
|
||||
|
||||
port_connection.disconnect ();
|
||||
|
||||
if (input_source) {
|
||||
g_source_destroy (input_source);
|
||||
input_source = 0;
|
||||
@@ -172,11 +168,11 @@ Surface::~Surface ()
|
||||
DEBUG_TRACE (DEBUG::MackieControl, "Surface::~Surface done\n");
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
Surface::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn)
|
||||
{
|
||||
if (!_port) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
string ni = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->input_name());
|
||||
@@ -194,6 +190,9 @@ Surface::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, b
|
||||
} else {
|
||||
connection_state &= ~OutputConnected;
|
||||
}
|
||||
} else {
|
||||
/* not our ports */
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((connection_state & (InputConnected|OutputConnected)) == (InputConnected|OutputConnected)) {
|
||||
@@ -228,6 +227,8 @@ Surface::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, b
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 disconnected (input or output or both)\n", _name));
|
||||
_active = false;
|
||||
}
|
||||
|
||||
return true; /* connection status changed */
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
|
||||
@@ -165,11 +165,11 @@ public:
|
||||
|
||||
void display_message_for (std::string const& msg, uint64_t msecs);
|
||||
|
||||
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool);
|
||||
|
||||
XMLNode& get_state ();
|
||||
int set_state (const XMLNode&, int version);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
MackieControlProtocol& _mcp;
|
||||
SurfacePort* _port;
|
||||
@@ -181,7 +181,6 @@ public:
|
||||
Mackie::JogWheel* _jog_wheel;
|
||||
Fader* _master_fader;
|
||||
float _last_master_gain_written;
|
||||
PBD::ScopedConnection port_connection;
|
||||
|
||||
void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
|
||||
MidiByteArray host_connection_query (MidiByteArray& bytes);
|
||||
@@ -192,7 +191,6 @@ public:
|
||||
void init_strips (uint32_t n);
|
||||
void setup_master ();
|
||||
void master_gain_changed ();
|
||||
void connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool);
|
||||
|
||||
enum ConnectionState {
|
||||
InputConnected = 0x1,
|
||||
|
||||
Reference in New Issue
Block a user