summaryrefslogtreecommitdiff
path: root/libs/ardour/smf_source.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-03-28 23:24:41 -0400
committerDavid Robillard <d@drobilla.net>2015-03-29 00:51:56 -0400
commitc9023ae73d6d70fead3e827811b384e2b171e4d6 (patch)
tree3a6cb5a0a7d436bed457f961afb272b82f1626be /libs/ardour/smf_source.cc
parent050c9c3f7d695ea8736d050f3eac5c4f0a3158ca (diff)
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.
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r--libs/ardour/smf_source.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 7f5e8059c9..d5c89b5ee9 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -37,13 +37,14 @@
#include "evoral/Control.hpp"
#include "evoral/SMF.hpp"
+#include "ardour/debug.h"
+#include "ardour/midi_channel_filter.h"
#include "ardour/midi_model.h"
#include "ardour/midi_ring_buffer.h"
#include "ardour/midi_state_tracker.h"
#include "ardour/parameter_types.h"
#include "ardour/session.h"
#include "ardour/smf_source.h"
-#include "ardour/debug.h"
#include "i18n.h"
@@ -208,7 +209,8 @@ SMFSource::read_unlocked (const Lock& lock,
framepos_t const source_start,
framepos_t start,
framecnt_t duration,
- MidiStateTracker* tracker) const
+ MidiStateTracker* tracker,
+ MidiChannelFilter* filter) const
{
int ret = 0;
uint64_t time = 0; // in SMF ticks, 1 tick per _ppqn
@@ -281,9 +283,11 @@ SMFSource::read_unlocked (const Lock& lock,
const framepos_t ev_frame_time = converter.to(Evoral::Beats::ticks_at_rate(time, ppqn())) + source_start;
if (ev_frame_time < start + duration) {
- destination.write (ev_frame_time, ev_type, ev_size, ev_buffer);
- if (tracker) {
- tracker->track(ev_buffer);
+ if (!filter || !filter->filter(ev_buffer, ev_size)) {
+ destination.write (ev_frame_time, ev_type, ev_size, ev_buffer);
+ if (tracker) {
+ tracker->track(ev_buffer);
+ }
}
} else {
break;