diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 8a10b95ec7..7e1106c6d6 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1740,17 +1740,21 @@ MidiRegionView::start_playing_midi_chord (vector > not player->play (); } +bool +MidiRegionView::note_in_region_time_range (const std::shared_ptr note) const +{ + const std::shared_ptr midi_reg = midi_region(); + return (timepos_t (note->time()) >= _region->start()) && (timepos_t (note->time()) < _region->start() + _region->length()); +} bool MidiRegionView::note_in_region_range (const std::shared_ptr note, bool& visible) const { const std::shared_ptr midi_reg = midi_region(); - /* must compare double explicitly as Beats::operator< rounds to ppqn */ - const bool outside = (timepos_t (note->time()) < _region->start()) || (timepos_t (note->time()) >= _region->start() + _region->length()); + const bool outside = !note_in_region_time_range (note); - visible = (note->note() >= _current_range_min) && - (note->note() <= _current_range_max); + visible = (note->note() >= _current_range_min) && (note->note() <= _current_range_max); return !outside; } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 5e3ffaeacf..b61443f767 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -234,6 +234,8 @@ public: * @return true iff the note is within the (time) extent of the region. */ bool note_in_region_range(const std::shared_ptr note, bool& visible) const; + /* Test if a note is withing this region's time range. Return true if so */ + bool note_in_region_time_range(const std::shared_ptr note) const; /** Get the region position in pixels relative to session. */ double get_position_pixels(); diff --git a/gtk2_ardour/velocity_ghost_region.cc b/gtk2_ardour/velocity_ghost_region.cc index c3b6972554..d4bac1048d 100644 --- a/gtk2_ardour/velocity_ghost_region.cc +++ b/gtk2_ardour/velocity_ghost_region.cc @@ -138,10 +138,11 @@ VelocityGhostRegion::add_note (NoteBase* nb) MidiStreamView* mv = midi_view(); if (mv) { - if (!nb->item()->visible()) { - l->hide(); - } else { + MidiRegionView* mrv = dynamic_cast (&parent_rv); + if (mrv->note_in_region_time_range (nb->note())) { set_size_and_position (*event); + } else { + l->hide(); } } }