summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-02-11 13:41:44 -0700
committerPaul Davis <paul@linuxaudiosystems.com>2020-02-11 13:41:44 -0700
commitde74cca6b8e3a17ac0aa9e6985002307d1b89f5d (patch)
tree1c6f77fa75590c79a080f7a7c94b3820c0a5f4a3
parentcc7eca74534e3699d15721d9b4c9c9efed45567f (diff)
further attempts to rationalize MIDNAM mess
Attempt to re-use GUI property for MIDNAM device mode, and if it doesn't exist, use the first from the model's device mode list. Also require at least one device mode in the MIDNAM file (via assert) - consider anything else to be malformed
-rw-r--r--gtk2_ardour/midi_time_axis.cc40
1 files changed, 23 insertions, 17 deletions
diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc
index 510169788f..979bc7cf83 100644
--- a/gtk2_ardour/midi_time_axis.cc
+++ b/gtk2_ardour/midi_time_axis.cc
@@ -113,6 +113,8 @@ using namespace std;
static const uint32_t MIDI_CONTROLS_BOX_MIN_HEIGHT = 160;
static const uint32_t KEYBOARD_MIN_HEIGHT = 130;
+#define DEFAULT_MIDNAM_MODEL (X_("Generic"))
+
MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanvas::Canvas& canvas)
: SessionHandlePtr (sess)
, RouteTimeAxisView (ed, sess, canvas)
@@ -256,7 +258,7 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
if (gui_property (X_("midnam-model-name")).empty()) {
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_route->the_instrument ());
if (!pi || !pi->plugin ()->has_midnam ()) {
- set_gui_property (X_("midnam-model-name"), "Generic");
+ set_gui_property (X_("midnam-model-name"), DEFAULT_MIDNAM_MODEL);
}
}
@@ -409,7 +411,7 @@ MidiTimeAxisView::setup_midnam_patches ()
}
if (!get_device_names()) {
- model_changed ("Generic");
+ model_changed (DEFAULT_MIDNAM_MODEL);
}
}
@@ -465,12 +467,21 @@ MidiTimeAxisView::update_patch_selector ()
void
-MidiTimeAxisView::model_changed(const std::string& model)
+MidiTimeAxisView::model_changed (const std::string& m)
{
typedef MIDI::Name::MidiPatchManager PatchManager;
PatchManager& patch_manager = PatchManager::instance();
+ std::string model (m);
+
+ std::list<std::string> device_modes = patch_manager.custom_device_mode_names_by_model (model);
+
+ if (device_modes.empty()) {
+ model = DEFAULT_MIDNAM_MODEL;
+ device_modes = patch_manager.custom_device_mode_names_by_model (model);
+ assert (!device_modes.empty());
+ }
- const std::list<std::string> device_modes = patch_manager.custom_device_mode_names_by_model (model);
+ const std::string current_mode = gui_property (X_("midname-custom-device-mode"));
if (patch_manager.is_custom_model (model)) {
_midnam_model_selector.set_text (_("Plugin Provided"));
@@ -490,12 +501,14 @@ MidiTimeAxisView::model_changed(const std::string& model)
_midnam_custom_device_mode_selector.AddMenuElem (Gtk::Menu_Helpers::MenuElem(*i, sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::custom_device_mode_changed), *i)));
}
- if (gui_property (X_("midnam-custom-device-mode")).empty()) {
- if (!device_modes.empty()) {
+ if (current_mode.empty()) {
+ custom_device_mode_changed (device_modes.front());
+ } else {
+ if (find (device_modes.begin(), device_modes.end(), current_mode) == device_modes.end()) {
custom_device_mode_changed (device_modes.front());
+ } else {
+ custom_device_mode_changed (current_mode);
}
- } else {
- custom_device_mode_changed (gui_property (X_("midnam-custom-device-mode")));
}
if (device_modes.size() > 1) {
@@ -504,13 +517,6 @@ MidiTimeAxisView::model_changed(const std::string& model)
_midnam_custom_device_mode_selector.hide();
}
- // now this is a real bad hack
- if (device_modes.size() > 0) {
- _route->instrument_info().set_external_instrument (model, device_modes.front());
- } else {
- _route->instrument_info().set_external_instrument (model, "");
- }
-
// Rebuild controller menu
_controller_menu_map.clear ();
delete controller_menu;
@@ -528,7 +534,7 @@ MidiTimeAxisView::custom_device_mode_changed(const std::string& mode)
const std::string model = gui_property (X_("midnam-model-name"));
set_gui_property (X_("midnam-custom-device-mode"), mode);
- _midnam_custom_device_mode_selector.set_text(mode);
+ _midnam_custom_device_mode_selector.set_text (mode);
_route->instrument_info().set_external_instrument (model, mode);
}
@@ -1223,7 +1229,7 @@ MidiTimeAxisView::show_all_automation (bool apply_to_selection)
// Show automation for all controllers named in midnam file
boost::shared_ptr<MasterDeviceNames> device_names = get_device_names();
- if (gui_property (X_("midnam-model-name")) != "Generic" &&
+ if (gui_property (X_("midnam-model-name")) != DEFAULT_MIDNAM_MODEL &&
device_names && !device_names->controls().empty()) {
const std::string device_mode = gui_property (X_("midnam-custom-device-mode"));
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();