Clean up comments to create_note_at, since it no longers snaps its length parameter...
authorCarl Hetherington <carl@carlh.net>
Fri, 30 Dec 2011 13:41:16 +0000 (13:41 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 30 Dec 2011 13:41:16 +0000 (13:41 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11116 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h

index d03084e2d0d0375acb0589991574c694e12f388b..02e5f91f7d72600d0d5709df8039c022de197283 100644 (file)
@@ -4446,11 +4446,15 @@ NoteCreateDrag::finished (GdkEvent* event, bool had_movement)
        framecnt_t length = abs (_note[0] - _note[1]);
 
        framecnt_t const g = grid_frames (start);
+       double const one_tick = 1 / Timecode::BBT_Time::ticks_per_bar_division;
+       
        if (_editor->snap_mode() == SnapNormal && length < g) {
-               length = g;
+               length = g - one_tick;
        }
 
-       _region_view->create_note_at (start, _drag_rect->property_y1(), _region_view->region_frames_to_region_beats (length), true, false);
+       double const length_beats = max (one_tick, _region_view->region_frames_to_region_beats (length));
+
+       _region_view->create_note_at (start, _drag_rect->property_y1(), length_beats, false);
 }
 
 double
index 43532f145c081af285e6c2653462dd934e6123ae..0437b4b938bb61fe7ada657edff39543e502fbf6 100644 (file)
@@ -482,7 +482,12 @@ MidiRegionView::button_release (GdkEventButton* ev)
                                                beats = 1;
                                        }
 
-                                       create_note_at (editor.pixel_to_frame (event_x), event_y, beats, true, true);
+                                       /* Shorten the length by 1 tick so that we can add a new note at the next
+                                          grid snap without it overlapping this one.
+                                       */
+                                       beats -= 1.0 / Timecode::BBT_Time::ticks_per_bar_division;
+
+                                       create_note_at (editor.pixel_to_frame (event_x), event_y, beats, true);
                                }
 
                                break;
@@ -496,7 +501,12 @@ MidiRegionView::button_release (GdkEventButton* ev)
                                        beats = 1;
                                }
 
-                               create_note_at (editor.pixel_to_frame (event_x), event_y, beats, true, true);
+                               /* Shorten the length by 1 tick so that we can add a new note at the next
+                                  grid snap without it overlapping this one.
+                               */
+                               beats -= 1.0 / Timecode::BBT_Time::ticks_per_bar_division;
+                               
+                               create_note_at (editor.pixel_to_frame (event_x), event_y, beats, true);
 
                                break;
                        }
@@ -778,12 +788,11 @@ MidiRegionView::show_list_editor ()
 /** Add a note to the model, and the view, at a canvas (click) coordinate.
  * \param t time in frames relative to the position of the region
  * \param y vertical position in pixels
- * \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.
- * \param snap_x true to snap x to the grid, otherwise false.
+ * \param length duration of the note in beats
+ * \param snap_t true to snap t to the grid, otherwise false.
  */
 void
-MidiRegionView::create_note_at (framepos_t t, double y, double length, bool sh, bool snap_x)
+MidiRegionView::create_note_at (framepos_t t, double y, double length, bool snap_t)
 {
        MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
        MidiStreamView* const view = mtv->midi_view();
@@ -794,27 +803,14 @@ MidiRegionView::create_note_at (framepos_t t, double y, double length, bool sh,
        assert(note <= 127.0);
 
        // Start of note in frames relative to region start
-       if (snap_x) {
+       if (snap_t) {
                framecnt_t grid_frames;
                t = snap_frame_to_grid_underneath (t, grid_frames);
        }
-       assert (t >= 0);
 
+       assert (t >= 0);
        assert (length != 0);
 
-       if (sh) {
-               /* shorten the note down, but rather than using 1 frame (which
-                  would be the highest resolution, use 1 tick since all
-                  musical data is essentially quantized to this unit. it
-                  is bigger, but not by enough to make any difference.
-
-                  old single frame code:
-
-                  length = region_frames_to_region_beats (region_beats_to_region_frames (length) - 1);
-               */
-               length -= 1.0/Timecode::BBT_Time::ticks_per_bar_division;
-       }
-
        const boost::shared_ptr<NoteType> new_note (new NoteType (mtv->get_channel_for_add (),
                                                                  region_frames_to_region_beats(t + _region->start()), 
                                                                  length,
index b42b7e5a364df47f9e8af9dbdd94abc16c77b264..6e0a3b4a3669569938730e4546d6b6d99f3a8b09 100644 (file)
@@ -290,7 +290,7 @@ public:
        void trim_front_starting ();
        void trim_front_ending ();
 
-       void create_note_at (framepos_t, double, double, bool, bool);
+       void create_note_at (framepos_t, double, double, bool);
        
 protected:
        /** Allows derived types to specify their visibility requirements