diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-06-13 14:48:48 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-06-13 14:48:48 +0000 |
commit | cab3072f83bb2e959e5ece5e344c568caf474be6 (patch) | |
tree | b978580e776fca0adc75959a34786821c92f5070 /gtk2_ardour/midi_region_view.cc | |
parent | 5afe60f0e3e726dbf3bb13944d723a86a3cfde0d (diff) |
add MIDI channel editing for current note selection, bound to "c" by default
git-svn-id: svn://localhost/ardour2/branches/3.0@9718 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 8553900278..54f6a2c59a 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -54,6 +54,7 @@ #include "ghostregion.h" #include "gui_thread.h" #include "keyboard.h" +#include "midi_channel_dialog.h" #include "midi_cut_buffer.h" #include "midi_list_editor.h" #include "midi_region_view.h" @@ -769,6 +770,9 @@ MidiRegionView::key_press (GdkEventKey* ev) } else if (ev->keyval == GDK_Control_L) { return true; + } else if (ev->keyval == GDK_c) { + channel_edit (); + return true; } return false; @@ -785,6 +789,53 @@ MidiRegionView::key_release (GdkEventKey* ev) } void +MidiRegionView::channel_edit () +{ + bool first = true; + bool mixed = false; + uint8_t current_channel; + + if (_selection.empty()) { + return; + } + + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { + Selection::iterator next = i; + if (first) { + current_channel = (*i)->note()->channel (); + first = false; + } else { + if (current_channel != (*i)->note()->channel()) { + mixed = true; + } + } + } + + MidiChannelDialog channel_dialog (current_channel); + int ret = channel_dialog.run (); + + switch (ret) { + case Gtk::RESPONSE_OK: + break; + default: + return; + } + + uint8_t new_channel = channel_dialog.active_channel (); + + start_note_diff_command (_("channel edit")); + + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ) { + Selection::iterator next = i; + ++next; + change_note_channel (*i, new_channel); + i = next; + } + + apply_diff (); +} + +void MidiRegionView::show_list_editor () { if (!_list_editor) { @@ -2470,12 +2521,6 @@ MidiRegionView::commit_resizing (ArdourCanvas::CanvasNoteEvent* primary, bool at } void -MidiRegionView::change_note_channel (CanvasNoteEvent* event, int8_t channel) -{ - note_diff_add_change (event, MidiModel::NoteDiffCommand::Channel, (uint8_t) channel); -} - -void MidiRegionView::change_note_velocity(CanvasNoteEvent* event, int8_t velocity, bool relative) { uint8_t new_velocity; @@ -2580,6 +2625,28 @@ MidiRegionView::trim_note (CanvasNoteEvent* event, Evoral::MusicalTime front_del } void +MidiRegionView::change_note_channel (CanvasNoteEvent* event, int8_t chn, bool relative) +{ + uint8_t new_channel; + + if (relative) { + if (chn < 0.0) { + if (event->note()->channel() < -chn) { + new_channel = 0; + } else { + new_channel = event->note()->channel() + chn; + } + } else { + new_channel = event->note()->channel() + chn; + } + } else { + new_channel = (uint8_t) chn; + } + + note_diff_add_change (event, MidiModel::NoteDiffCommand::Channel, new_channel); +} + +void MidiRegionView::change_note_time (CanvasNoteEvent* event, Evoral::MusicalTime delta, bool relative) { Evoral::MusicalTime new_time; |