From a1715cbbb9e32d4611381394ac490dadde1e43ad Mon Sep 17 00:00:00 2001 From: Bill Peterson Date: Tue, 12 Dec 2023 14:06:21 -0600 Subject: [PATCH 1/2] interrupt event processing on patch rule patch rules should halt further processing of an event --- fluidpatcher/__init__.py | 1 + fluidpatcher/pfluidsynth.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fluidpatcher/__init__.py b/fluidpatcher/__init__.py index 99fbd1e..e7ea0ad 100644 --- a/fluidpatcher/__init__.py +++ b/fluidpatcher/__init__.py @@ -460,6 +460,7 @@ def _midisignal_handler(self, sig): else: sig.patch = -1 sig.val = 0 + return True if self.midi_callback: self.midi_callback(sig) def _refresh_bankfonts(self): diff --git a/fluidpatcher/pfluidsynth.py b/fluidpatcher/pfluidsynth.py index 277a80d..b05831c 100644 --- a/fluidpatcher/pfluidsynth.py +++ b/fluidpatcher/pfluidsynth.py @@ -626,9 +626,9 @@ def custom_midi_router(self, event): elif LADSPA_SUPPORT and 'ladspafx' in rule: if res.ladspafx in self.ladspafx: self.ladspafx[res.ladspafx].setcontrol(res.port, res.val) - else: - # not handled here, pass it to the callback - if self.midi_callback: self.midi_callback(res) + elif self.midi_callback: + # not handled here, pass result to the callback + if self.midi_callback(res): return if dt > 0: self.clocks = t, self.clocks[0] if self.midi_callback: # send the original event to the callback From 8d35e6a906b3de01009b3c12b6db41c159bfae96 Mon Sep 17 00:00:00 2001 From: Bill Peterson Date: Tue, 12 Dec 2023 14:36:21 -0600 Subject: [PATCH 2/2] Update __init__.py send patch signal to callback first, then interrupt event processing --- fluidpatcher/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fluidpatcher/__init__.py b/fluidpatcher/__init__.py index e7ea0ad..c27aa2c 100644 --- a/fluidpatcher/__init__.py +++ b/fluidpatcher/__init__.py @@ -460,8 +460,9 @@ def _midisignal_handler(self, sig): else: sig.patch = -1 sig.val = 0 - return True if self.midi_callback: self.midi_callback(sig) + if 'patch' in sig: + return True def _refresh_bankfonts(self): sfneeded = set()