diff options
author | David Robillard <d@drobilla.net> | 2013-01-20 00:46:55 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-20 00:46:55 +0000 |
commit | 88de45b7ccc933ee46a13d4e4e21caf9e5fb379e (patch) | |
tree | 5e72e7caa7b88b8d29e8dad226c317fc8e31d3bb /gtk2_ardour | |
parent | 448c156b4bac6204dd6b627b07b226f63f1301b4 (diff) |
Support note names from midnam files (tested with the DM5).
Do this via a simple MasterDeviceNames::note_name() function. The same really
needs to be done for program names, this stuff is absolutely brutal to use.
Store note names in a vector indexed by number instead of a list with string
"numbers" for reasonable lookup time.
Make some references const that should be.
git-svn-id: svn://localhost/ardour2/branches/3.0@13908 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 28 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 8 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 25 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.h | 5 |
4 files changed, 50 insertions, 16 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index bfc0489d0f..6931e5172b 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1846,7 +1846,7 @@ MidiRegionView::patch_change_to_patch_key (MidiModel::PatchChangePtr p) } void -MidiRegionView::get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) +MidiRegionView::get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const { MidiModel::PatchChanges::iterator i = _model->patch_change_lower_bound (time); while (i != _model->patch_changes().end() && (*i)->channel() != channel) { @@ -3808,14 +3808,32 @@ MidiRegionView::delete_sysex (CanvasSysEx* sysex) void MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const { - char buf[24]; - snprintf (buf, sizeof (buf), "%s (%d) Chn %d\nVel %d", - Evoral::midi_note_name (n->note()).c_str(), + using namespace MIDI::Name; + + std::string name; + + MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview); + if (mtv) { + boost::shared_ptr<MasterDeviceNames> device_names(mtv->get_device_names()); + if (device_names) { + MIDI::Name::PatchPrimaryKey patch_key; + get_patch_key_at(n->time(), n->channel(), patch_key); + name = device_names->note_name(mtv->gui_property(X_("midnam-custom-device-mode")), + n->channel(), + patch_key.bank_number, + patch_key.program_number, + n->note()); + } + } + + char buf[128]; + snprintf (buf, sizeof (buf), "%d %s\nCh %d Vel %d", (int) n->note (), + name.empty() ? Evoral::midi_note_name (n->note()).c_str() : name.c_str(), (int) n->channel() + 1, (int) n->velocity()); - show_verbose_cursor (buf, 10, 20); + show_verbose_cursor(buf, 10, 20); } void diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 65d8855093..6facd2e003 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -127,11 +127,11 @@ public: * @key a reference to an instance of MIDI::Name::PatchPrimaryKey whose fields will * will be set according to the result of the lookup */ - void get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key); + void get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const; - /** Convert a given PatchChange into a PatchPrimaryKey - */ - MIDI::Name::PatchPrimaryKey patch_change_to_patch_key (ARDOUR::MidiModel::PatchChangePtr); + /** Convert a given PatchChange into a PatchPrimaryKey + */ + MIDI::Name::PatchPrimaryKey patch_change_to_patch_key (ARDOUR::MidiModel::PatchChangePtr); /** Change old_patch to new_patch. * @param old_patch the canvas patch change which is to be altered diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index b9162cfe2b..9d96ca756f 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -232,8 +232,7 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt) } 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"))); + boost::shared_ptr<MIDI::Name::MasterDeviceNames> device_names = get_device_names(); if (device_names) { set_gui_property (X_("midnam-custom-device-mode"), *device_names->custom_device_mode_names().begin()); @@ -760,10 +759,27 @@ 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::CustomDeviceMode> +MidiTimeAxisView::get_device_mode() +{ + using namespace MIDI::Name; + + boost::shared_ptr<MasterDeviceNames> device_names = get_device_names(); + if (!device_names) { + return boost::shared_ptr<MIDI::Name::CustomDeviceMode>(); + } + + return device_names->custom_device_mode_by_name( + gui_property (X_("midnam-custom-device-mode"))); +} + boost::shared_ptr<MIDI::Name::MasterDeviceNames> -MidiTimeAxisView::get_device_names(const std::string& model) +MidiTimeAxisView::get_device_names() { using namespace MIDI::Name; + + const std::string model = gui_property (X_("midnam-model-name")); + boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance() .document_by_model(model); if (midnam) { @@ -807,8 +823,7 @@ MidiTimeAxisView::build_controller_menu () } using namespace MIDI::Name; - boost::shared_ptr<MasterDeviceNames> device_names = get_device_names( - _midnam_model_selector.get_active_text()); + boost::shared_ptr<MasterDeviceNames> device_names = get_device_names(); if (device_names && !device_names->controls().empty()) { /* Controllers names available in midnam file, generate fancy menu */ diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index 635d529d34..d61b64f36c 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -80,6 +80,9 @@ class MidiTimeAxisView : public RouteTimeAxisView ARDOUR::NoteMode note_mode() const { return _note_mode; } ARDOUR::ColorMode color_mode() const { return _color_mode; } + boost::shared_ptr<MIDI::Name::MasterDeviceNames> get_device_names(); + boost::shared_ptr<MIDI::Name::CustomDeviceMode> get_device_mode(); + void update_range(); sigc::signal<void, ARDOUR::ChannelMode, uint16_t>& signal_channel_mode_changed() { @@ -112,8 +115,6 @@ class MidiTimeAxisView : public RouteTimeAxisView 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); void set_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection = false); |