summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_region_view.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-12-23 21:05:50 +0000
committerDavid Robillard <d@drobilla.net>2008-12-23 21:05:50 +0000
commit2a2067388314ae1695f3be4d6ea9e3c3628f91ba (patch)
tree93b83d5f618e6161c7b8ede87f26565720789e44 /gtk2_ardour/midi_region_view.cc
parent270f1abe8d2a3e3da369a8e64bc0e6806309304d (diff)
Fix note velocity editing.
Don't abuse/leak selection when editing velocity (fix editing velocity of a single note actually editing velocity of every note who's velocity had previously been edited). Properly preserve selection for MIDI operations in general. Less crap method of delineating scroll events to canvas items (no exhaustive type cases needed in editor_canvas_events.cc). Fix silly comment style in midi_region_view.h (hans: please note this and follow in the future). git-svn-id: svn://localhost/ardour2/branches/3.0@4343 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r--gtk2_ardour/midi_region_view.cc48
1 files changed, 26 insertions, 22 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index f176f10367..cff4d358a8 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -1338,7 +1338,7 @@ MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote)
copy->set_note(new_pitch);
command_remove_note(*i);
- command_add_note(copy, true);
+ command_add_note(copy, (*i)->selected());
i = next;
}
@@ -1386,9 +1386,9 @@ MidiRegionView::snap_to_pixel(double x)
}
double
-MidiRegionView::get_position_pixels(void)
+MidiRegionView::get_position_pixels()
{
- nframes64_t region_frame = get_position();
+ nframes64_t region_frame = get_position();
return trackview.editor.frame_to_pixel(region_frame);
}
@@ -1519,30 +1519,34 @@ MidiRegionView::commit_resizing(CanvasNote::NoteEnd note_end, double event_x, bo
apply_command();
}
+void
+MidiRegionView::change_note_velocity(CanvasNoteEvent* event, int8_t velocity, bool relative)
+{
+ const boost::shared_ptr<Evoral::Note> copy(new Evoral::Note(*(event->note().get())));
+
+ if (relative) {
+ uint8_t new_velocity = copy->velocity() + velocity;
+ clamp_0_to_127(new_velocity);
+ copy->set_velocity(new_velocity);
+ } else {
+ copy->set_velocity(velocity);
+ }
+
+ command_remove_note(event);
+ command_add_note(copy, event->selected());
+}
void
-MidiRegionView::change_velocity(uint8_t velocity, bool relative)
+MidiRegionView::change_velocity(CanvasNoteEvent* ev, int8_t velocity, bool relative)
{
start_delta_command(_("change velocity"));
+
+ change_note_velocity(ev, velocity, relative);
+
for (Selection::iterator i = _selection.begin(); i != _selection.end();) {
Selection::iterator next = i;
++next;
-
- CanvasNoteEvent *event = *i;
- const boost::shared_ptr<Evoral::Note> copy(new Evoral::Note(*(event->note().get())));
-
- if (relative) {
- uint8_t new_velocity = copy->velocity() + velocity;
- clamp_0_to_127(new_velocity);
-
- copy->set_velocity(new_velocity);
- } else { // absolute
- copy->set_velocity(velocity);
- }
-
- command_remove_note(event);
- command_add_note(copy, true);
-
+ change_note_velocity(*i, velocity, relative);
i = next;
}
@@ -1557,13 +1561,13 @@ MidiRegionView::change_channel(uint8_t channel)
Selection::iterator next = i;
++next;
- CanvasNoteEvent *event = *i;
+ CanvasNoteEvent* event = *i;
const boost::shared_ptr<Evoral::Note> copy(new Evoral::Note(*(event->note().get())));
copy->set_channel(channel);
command_remove_note(event);
- command_add_note(copy, true);
+ command_add_note(copy, event->selected());
i = next;
}