add missing quote
[ardour.git] / gtk2_ardour / midi_streamview.cc
index d1a479d28c9700875d86ae4e3a69e16a83e3989d..9258cf027d385973dd4080f64bcce0a4c881cc31 100644 (file)
@@ -75,7 +75,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
           can be put below ghost regions from MIDI underlays
        */
        _note_lines = new ArdourCanvas::LineSet (_canvas_group, ArdourCanvas::LineSet::Horizontal);
-       
+
        _note_lines->Event.connect(
                sigc::bind(sigc::mem_fun(_trackview.editor(),
                                         &PublicEditor::canvas_stream_view_event),
@@ -345,7 +345,7 @@ MidiStreamView::draw_note_lines()
 
                double h = y - prev_y;
                double mid = y + (h/2.0);
-                               
+
                if (height > 1.0) { // XXX ? should that not be h >= 1 ?
                        _note_lines->add (mid, h, color);
                }
@@ -619,7 +619,7 @@ MidiStreamView::update_rec_box ()
 uint8_t
 MidiStreamView::y_to_note (double y) const
 {
-       int const n = ((contents_height() - y - 1) / contents_height() * (double)contents_note_range())
+       int const n = ((contents_height() - y) / contents_height() * (double)contents_note_range())
                + lowest_note();
 
        if (n < 0) {
@@ -628,7 +628,8 @@ MidiStreamView::y_to_note (double y) const
                return 127;
        }
 
-       return n;
+       /* min due to rounding and/or off-by-one errors */
+       return min ((uint8_t) n, highest_note());
 }
 
 /** Suspend updates to the regions' note ranges and our
@@ -647,7 +648,7 @@ void
 MidiStreamView::resume_updates ()
 {
        _updates_suspended = false;
-       
+
        draw_note_lines ();
        apply_note_range_to_regions ();