diff options
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 43 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.h | 2 | ||||
-rw-r--r-- | libs/midi++2/midnam_patch.cc | 2 |
4 files changed, 30 insertions, 19 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 48f942f2b5..bfc0489d0f 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1232,7 +1232,7 @@ MidiRegionView::display_patch_changes_on_channel (uint8_t channel, bool active_c continue; } - string patch_name = instrument_info().get_patch_name ((*i)->bank(), (*i)->program(), channel); + const string patch_name = instrument_info().get_patch_name ((*i)->bank(), (*i)->program(), channel); add_canvas_patch_change (*i, patch_name, active_channel); } } diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 973bbb77e5..b9162cfe2b 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -231,6 +231,15 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt) set_gui_property (X_("midnam-model-name"), "Generic"); } + if (gui_property (X_("midnam-custom-device-mode")).empty()) { + boost::shared_ptr<MIDI::Name::MasterDeviceNames> device_names = get_device_names( + gui_property (X_("midnam-model-name"))); + if (device_names) { + set_gui_property (X_("midnam-custom-device-mode"), + *device_names->custom_device_mode_names().begin()); + } + } + _midnam_model_selector.set_active_text (gui_property (X_("midnam-model-name"))); _midnam_custom_device_mode_selector.set_active_text (gui_property (X_("midnam-custom-device-mode"))); @@ -373,14 +382,9 @@ MidiTimeAxisView::model_changed() _midnam_custom_device_mode_selector.clear_items(); - if (device_modes.size() < 2) { - _midnam_custom_device_mode_selector.hide(); - } else { - _midnam_custom_device_mode_selector.show(); - for (std::list<std::string>::const_iterator i = device_modes.begin(); - i != device_modes.end(); ++i) { - _midnam_custom_device_mode_selector.append_text(*i); - } + for (std::list<std::string>::const_iterator i = device_modes.begin(); + i != device_modes.end(); ++i) { + _midnam_custom_device_mode_selector.append_text(*i); } _midnam_custom_device_mode_selector.set_active(0); @@ -756,6 +760,19 @@ MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_ dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true); } +boost::shared_ptr<MIDI::Name::MasterDeviceNames> +MidiTimeAxisView::get_device_names(const std::string& model) +{ + using namespace MIDI::Name; + boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance() + .document_by_model(model); + if (midnam) { + return midnam->master_device_names(model); + } else { + return boost::shared_ptr<MasterDeviceNames>(); + } +} + void MidiTimeAxisView::build_controller_menu () { @@ -790,15 +807,9 @@ MidiTimeAxisView::build_controller_menu () } using namespace MIDI::Name; - const Glib::ustring model = _midnam_model_selector.get_active_text(); - boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance() - .document_by_model(model); - boost::shared_ptr<MasterDeviceNames> device_names; + boost::shared_ptr<MasterDeviceNames> device_names = get_device_names( + _midnam_model_selector.get_active_text()); - if (midnam) { - device_names = midnam->master_device_names(model); - } - if (device_names && !device_names->controls().empty()) { /* Controllers names available in midnam file, generate fancy menu */ unsigned n_items = 0; diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index 04e37913b5..635d529d34 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -111,6 +111,8 @@ class MidiTimeAxisView : public RouteTimeAxisView void build_automation_action_menu (bool); Gtk::Menu* build_note_mode_menu(); Gtk::Menu* build_color_mode_menu(); + + boost::shared_ptr<MIDI::Name::MasterDeviceNames> get_device_names(const std::string& model); void set_note_mode (ARDOUR::NoteMode mode, bool apply_to_selection = false); void set_color_mode (ARDOUR::ColorMode, bool force = false, bool redisplay = true, bool apply_to_selection = false); diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index 82fc579d1a..39238114c7 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -453,8 +453,6 @@ CustomDeviceMode::get_state(void) boost::shared_ptr<CustomDeviceMode> MasterDeviceNames::custom_device_mode_by_name(std::string mode_name) { - // can't assert this, since in many of the patch files the mode name is empty - //assert(mode_name != ""); return _custom_device_modes[mode_name]; } |