diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 5e05dfc3b6..f3650786c4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3485,8 +3485,8 @@ Editor::setup_tooltips () set_tooltip (tav_shrink_button, _("Shrink Tracks")); set_tooltip (visible_tracks_selector, _("Number of visible tracks")); set_tooltip (draw_length_selector, _("Note Length to Draw (AUTO uses the current Grid setting)")); - set_tooltip (draw_velocity_selector, _("Note Velocity to Draw")); - set_tooltip (draw_channel_selector, _("Note Channel to Draw")); + set_tooltip (draw_velocity_selector, _("Note Velocity to Draw (AUTO uses the nearest note's velocity)")); + set_tooltip (draw_channel_selector, _("Note Channel to Draw (AUTO uses the nearest note's channel)")); set_tooltip (grid_type_selector, _("Grid Mode")); set_tooltip (snap_mode_button, _("Snap Mode\n\nRight-click to visit Snap preferences.")); set_tooltip (edit_point_selector, _("Edit Point")); diff --git a/gtk2_ardour/midi_automation_line.cc b/gtk2_ardour/midi_automation_line.cc index 5b0d3b2ef0..67b1df6531 100644 --- a/gtk2_ardour/midi_automation_line.cc +++ b/gtk2_ardour/midi_automation_line.cc @@ -76,7 +76,7 @@ MidiAutomationLine::get_verbose_cursor_string (double fraction) const return AutomationLine::get_verbose_cursor_string(fraction); } - const uint8_t channel = mtv->get_channel_for_add(); + const uint8_t channel = mtv->get_preferred_midi_channel(); boost::shared_ptr value_names = mtv->route()->instrument_info().value_name_list_by_control (channel, _parameter.id()); if (!value_names) { diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 1593a5a9df..b142c9b2ac 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -829,6 +829,7 @@ MidiRegionView::show_list_editor () _list_editor->present (); } + /** Add a note to the model, and the view, at a canvas (click) coordinate. * \param t time in samples relative to the position of the region * \param y vertical position in pixels @@ -855,7 +856,7 @@ MidiRegionView::create_note_at (timepos_t const & t, double y, Temporal::Beats l Temporal::Beats region_start = t.beats(); const double note = view->y_to_note(y); - const uint8_t chan = mtv->get_channel_for_add(); + const uint8_t chan = get_channel_for_add(region_start); const uint8_t velocity = get_velocity_for_add (region_start); const boost::shared_ptr new_note (new NoteType (chan, region_start, length, (uint8_t)note, velocity)); @@ -2002,7 +2003,7 @@ MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const /** Add a patch change to the region. * @param t Time in samples relative to region position * @param patch Patch to add; time and channel are ignored (time is converted from t, and channel comes from - * MidiTimeAxisView::get_channel_for_add()) + * MidiTimeAxisView::get_preferred_midi_channel()) */ void MidiRegionView::add_patch_change (timecnt_t const & t, Evoral::PatchChange const & patch) @@ -3917,7 +3918,7 @@ MidiRegionView::update_ghost_note (double x, double y, uint32_t state) _ghost_note->note()->set_time (snapped_beats); _ghost_note->note()->set_length (length); _ghost_note->note()->set_note (y_to_note (y)); - _ghost_note->note()->set_channel (mtv->get_channel_for_add ()); + _ghost_note->note()->set_channel (mtv->get_preferred_midi_channel ()); _ghost_note->note()->set_velocity (get_velocity_for_add (snapped_beats)); update_note (_ghost_note, false); @@ -4249,6 +4250,32 @@ MidiRegionView::show_verbose_cursor (string const & text, double xoffset, double trackview.editor().verbose_cursor()->set_offset (ArdourCanvas::Duple (xoffset, yoffset)); } + +uint8_t +MidiRegionView::get_channel_for_add (MidiModel::TimeType time) const +{ + /* first, use the user-specified channel in the editor */ + PublicEditor& editor = trackview.editor(); + if (editor.draw_channel() != Editing::DRAW_CHAN_AUTO) { + return editor.draw_channel(); + } + + /* second, use the nearest note in the region-view (consistent with get_velocity_for_add behavior) */ + if (!_model->notes().empty()) { + MidiModel::Notes::const_iterator m = _model->note_lower_bound(time); + return (*m)->channel(); + } + + /* lastly: query the track's channel filter */ + MidiTimeAxisView* const mtv = dynamic_cast(&trackview); + if (mtv) { + return mtv->get_preferred_midi_channel(); + } + + /* fallback: ch0 */ + return 0; +} + uint8_t MidiRegionView::get_velocity_for_add (MidiModel::TimeType time) const { diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index f464fae878..8359ebb974 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -441,6 +441,7 @@ public: void show_verbose_cursor (boost::shared_ptr) const; uint8_t get_velocity_for_add (ARDOUR::MidiModel::TimeType time) const; + uint8_t get_channel_for_add (ARDOUR::MidiModel::TimeType time) const; uint8_t _current_range_min; uint8_t _current_range_max; diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index e30dc15a4a..2a001bf962 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -1724,7 +1724,7 @@ MidiTimeAxisView::stop_step_editing () * of the channel selector. */ uint8_t -MidiTimeAxisView::get_channel_for_add () const +MidiTimeAxisView::get_preferred_midi_channel () const { if (_editor.draw_channel() != Editing::DRAW_CHAN_AUTO) { return _editor.draw_channel(); diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index 4c31792b0a..8e401d55e5 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -108,7 +108,7 @@ public: void first_idle (); void set_note_highlight (uint8_t note); - uint8_t get_channel_for_add () const; + uint8_t get_preferred_midi_channel () const; void get_per_region_note_selection (std::list > > > >&); void use_midnam_info (); diff --git a/gtk2_ardour/piano_roll_header.cc b/gtk2_ardour/piano_roll_header.cc index a2f5a9d93f..e38bfce3be 100644 --- a/gtk2_ardour/piano_roll_header.cc +++ b/gtk2_ardour/piano_roll_header.cc @@ -688,7 +688,7 @@ PianoRollHeader::send_note_on (uint8_t note) //cerr << "note on: " << (int) note << endl; if (track) { - _event[0] = (MIDI_CMD_NOTE_ON | mtv->get_channel_for_add ()); + _event[0] = (MIDI_CMD_NOTE_ON | mtv->get_preferred_midi_channel ()); _event[1] = note; _event[2] = 100; @@ -703,7 +703,7 @@ PianoRollHeader::send_note_off (uint8_t note) MidiTimeAxisView* mtv = dynamic_cast (&_view.trackview ()); if (track) { - _event[0] = (MIDI_CMD_NOTE_OFF | mtv->get_channel_for_add ()); + _event[0] = (MIDI_CMD_NOTE_OFF | mtv->get_preferred_midi_channel ()); _event[1] = note; _event[2] = 100;