From c9023ae73d6d70fead3e827811b384e2b171e4d6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 28 Mar 2015 23:24:41 -0400 Subject: Fix mute of MIDI tracks with channel forcing. This moves MIDI channel filtering into a reusable class and moves filtering to the source, rather than modifying the buffer afterwards. This is necessary so that the playlist trackers reflect the emitted notes (and thus are able to stop them in situations like mute). As a perk, this is also faster because events are just dropped on read, rather than pushed into a buffer then later removed (which is very slow). Really hammering on mute or solo still seems to produce stuck notes occasionally (perhaps related to multiple-on warnings). I am not yet sure why, but occasional beats always. --- libs/ardour/midi_source.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libs/ardour/midi_source.cc') diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 47cfb1b0a0..ab972fabd8 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -38,10 +38,11 @@ #include "evoral/EventSink.hpp" #include "ardour/debug.h" +#include "ardour/file_source.h" +#include "ardour/midi_channel_filter.h" #include "ardour/midi_model.h" -#include "ardour/midi_state_tracker.h" #include "ardour/midi_source.h" -#include "ardour/file_source.h" +#include "ardour/midi_state_tracker.h" #include "ardour/session.h" #include "ardour/session_directory.h" #include "ardour/source_factory.h" @@ -190,6 +191,7 @@ MidiSource::midi_read (const Lock& lm, framepos_t start, framecnt_t cnt, MidiStateTracker* tracker, + MidiChannelFilter* filter, const std::set& filtered) const { BeatsFramesConverter converter(_session.tempo_map(), source_start); @@ -218,6 +220,13 @@ MidiSource::midi_read (const Lock& lm, for (; i != _model->end(); ++i) { const framecnt_t time_frames = converter.to(i->time()); if (time_frames < start + cnt) { + if (filter && filter->filter(i->buffer(), i->size())) { + DEBUG_TRACE (DEBUG::MidiSourceIO, + string_compose ("%1: filter event @ %2 type %3 size %4\n", + _name, time_frames + source_start, i->event_type(), i->size())); + continue; + } + // Offset by source start to convert event time to session time dst.write (time_frames + source_start, i->event_type(), i->size(), i->buffer()); @@ -237,7 +246,7 @@ MidiSource::midi_read (const Lock& lm, } return cnt; } else { - return read_unlocked (lm, dst, source_start, start, cnt, tracker); + return read_unlocked (lm, dst, source_start, start, cnt, tracker, filter); } } -- cgit v1.2.3