Register colour aliases for tempo curve.
[ardour.git] / gtk2_ardour / midi_region_view.cc
index 324ca0eaf6201d289ac562265786fb9c10b3c7c4..9e271cc3987af4b2925263ceeb903473ce19f45c 100644 (file)
@@ -928,6 +928,11 @@ MidiRegionView::create_note_at (framepos_t t, double y, Evoral::Beats length, bo
 
        MidiTimeAxisView* const mtv  = dynamic_cast<MidiTimeAxisView*>(&trackview);
        MidiStreamView* const   view = mtv->midi_view();
+       boost::shared_ptr<MidiRegion> mr  = boost::dynamic_pointer_cast<MidiRegion> (_region);
+
+       if (!mr) {
+               return;
+       }
 
        // Start of note in frames relative to region start
        if (snap_t) {
@@ -935,9 +940,8 @@ MidiRegionView::create_note_at (framepos_t t, double y, Evoral::Beats length, bo
                t = snap_frame_to_grid_underneath (t, grid_frames);
        }
 
-       const MidiModel::TimeType beat_time = region_frames_to_region_beats(
-               t + _region->start());
-
+       const MidiModel::TimeType beat_time = Evoral::Beats (trackview.session()->tempo_map().beat_at_frame (_region->position() + t)
+                                                            - (mr->beat() - mr->start_beats().to_double()));
        const double  note     = view->y_to_note(y);
        const uint8_t chan     = mtv->get_channel_for_add();
        const uint8_t velocity = get_velocity_for_add(beat_time);
@@ -3331,9 +3335,8 @@ void
 MidiRegionView::patch_entered (PatchChange* p)
 {
        ostringstream s;
-       /* XXX should get patch name if we can */
        s << _("Bank ") << (p->patch()->bank() + MIDI_BP_ZERO) << '\n'
-         << _("Program ") << ((int) p->patch()->program()) + MIDI_BP_ZERO << '\n'
+         << instrument_info().get_patch_name_without (p->patch()->bank(), p->patch()->program(), p->patch()->channel()) << '\n'
          << _("Channel ") << ((int) p->patch()->channel() + 1);
        show_verbose_cursor (s.str(), 10, 20);
        p->item().grab_focus();
@@ -3876,7 +3879,9 @@ MidiRegionView::set_step_edit_cursor_width (Evoral::Beats beats)
        _step_edit_cursor_width = beats;
 
        if (_step_edit_cursor) {
-               _step_edit_cursor->set_x1 (_step_edit_cursor->x0() + trackview.editor().sample_to_pixel (region_beats_to_region_frames (beats)));
+               _step_edit_cursor->set_x1 (_step_edit_cursor->x0() + trackview.editor().sample_to_pixel (
+                                                  region_beats_to_region_frames (_step_edit_cursor_position + beats)
+                                                  - region_beats_to_region_frames (_step_edit_cursor_position)));
        }
 }