summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/midi_region_view.cc14
-rw-r--r--gtk2_ardour/midi_region_view.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 9062b369fb..486e09900f 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -348,7 +348,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
if (!success) {
beats = 1;
}
- create_note_at (event_x, event_y, beats);
+ create_note_at (event_x, event_y, beats, true);
break;
}
default:
@@ -369,7 +369,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
const double length = trackview.editor().pixel_to_frame
(_drag_rect->property_x2() - _drag_rect->property_x1());
- create_note_at (x, _drag_rect->property_y1(), frames_to_beats(length));
+ create_note_at (x, _drag_rect->property_y1(), frames_to_beats(length), false);
}
delete _drag_rect;
@@ -650,9 +650,11 @@ MidiRegionView::show_list_editor ()
/** Add a note to the model, and the view, at a canvas (click) coordinate.
* \param x horizontal position in pixels
* \param y vertical position in pixels
- * \param length duration of the note in beats */
+ * \param length duration of the note in beats, which will be snapped to the grid
+ * \param sh true to make the note 1 frame shorter than the snapped version of \a length.
+ */
void
-MidiRegionView::create_note_at(double x, double y, double length)
+MidiRegionView::create_note_at(double x, double y, double length, bool sh)
{
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
MidiStreamView* const view = mtv->midi_view();
@@ -672,6 +674,10 @@ MidiRegionView::create_note_at(double x, double y, double length)
assert (length != 0);
+ if (sh) {
+ length = frames_to_beats (beats_to_frames (length) - 1);
+ }
+
const boost::shared_ptr<NoteType> new_note(new NoteType(0,
frames_to_beats(start_frames + _region->start()), length,
(uint8_t)note, 0x40));
diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h
index 6c5dff9ff2..23904c9ddc 100644
--- a/gtk2_ardour/midi_region_view.h
+++ b/gtk2_ardour/midi_region_view.h
@@ -169,7 +169,7 @@ class MidiRegionView : public RegionView
void end_write();
void extend_active_notes();
- void create_note_at(double x, double y, double length);
+ void create_note_at(double x, double y, double length, bool);
void display_model(boost::shared_ptr<ARDOUR::MidiModel> model);