get note display working in pianoroll PRH (needs set_visible_channel())

This commit is contained in:
Paul Davis 2025-06-11 11:54:28 -06:00
parent 2ac2a4fd4c
commit 15079176ac
3 changed files with 23 additions and 16 deletions

View file

@ -357,6 +357,21 @@ MidiView::set_region (std::shared_ptr<MidiRegion> mr)
set_model (_midi_region->midi_source (0)->model());
}
int
MidiView::pick_visible_channel () const
{
int n = 0;
while (n < 16) {
if (_model->channels_present() & (1 << n)) {
return n;
}
++n;
}
return n;
}
void
MidiView::set_model (std::shared_ptr<MidiModel> m)
{
@ -374,22 +389,7 @@ MidiView::set_model (std::shared_ptr<MidiModel> m)
//set_height (trackview.current_height());
if (_show_source) {
int n = 0;
while (n < 16) {
if (_model->channels_present() & (1 << n)) {
set_visible_channel (n);
break;
}
++n;
}
if (n == 16) {
/* No channel data in model, use channel 0 (1) */
set_visible_channel (0);
}
}
set_visible_channel (pick_visible_channel());
_model->ContentsChanged.connect (connections_requiring_model, invalidator (*this), std::bind (&MidiView::model_changed, this), gui_context());
@ -5359,6 +5359,10 @@ MidiView::set_visibility_note_range (MidiViewBackground::VisibleNoteRange nvr, b
void
MidiView::set_visible_channel (int chn, bool clear_selection)
{
if (!_show_source) {
return;
}
_visible_channel = chn;
VisibleChannelChanged(); /* EMIT SIGNAL */

View file

@ -378,6 +378,7 @@ class MidiView : public virtual sigc::trackable, public LineMerger
int visible_channel() const { return _visible_channel; }
void set_visible_channel (int, bool clear_selection = true);
int pick_visible_channel () const;
PBD::Signal<void()> VisibleChannelChanged;
protected:

View file

@ -2564,6 +2564,8 @@ Pianoroll::set_region (std::shared_ptr<ARDOUR::MidiRegion> r)
view->show_start (true);
view->show_end (true);
set_visible_channel (view->pick_visible_channel());
r->DropReferences.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::unset, this, false), gui_context());
r->PropertyChanged.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::region_prop_change, this, _1), gui_context());