Skip to content

Commit 24840b0

Browse files
authored
Merge pull request #96 from GeekFunkLabs/patch-rules-bug
Fix direct patch selection
2 parents 133c848 + 1a622c0 commit 24840b0

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

fluidpatcher.pyw

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ class MainWindow(wx.Frame):
256256
def listener(self, sig):
257257
if hasattr(sig, 'val'):
258258
if hasattr(sig, 'patch') and fp.patches:
259-
if sig.patch < 0:
259+
if sig.patch == -1:
260260
self.select_patch(pno=(self.pno + sig.val) % len(fp.patches))
261261
else:
262-
self.select_patch(pno=self.patch)
262+
self.select_patch(pno=sig.patch)
263263
elif hasattr(sig, 'lcdwrite'):
264264
if hasattr(sig, 'format'):
265265
val = format(sig.val, sig.format)

fluidpatcher/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- libfluidsynth
1717
"""
1818

19-
__version__ = '0.8.3'
19+
__version__ = '0.8.4'
2020

2121
from pathlib import Path
2222
from copy import deepcopy
@@ -451,10 +451,12 @@ def _midisignal_handler(self, sig):
451451
if sig.patch in self.patches:
452452
sig.patch = self.patches.index(sig.patch)
453453
elif sig.patch == 'select':
454-
sig.patch = int(sig.val) % len(self.patches)
455-
elif sig.patch[-1] in '+-':
454+
sig.patch = int(sig.val - 1) % len(self.patches)
455+
elif str(sig.patch)[-1] in '+-':
456456
sig.val = int(sig.patch[-1] + sig.patch[:-1])
457457
sig.patch = -1
458+
elif isinstance(sig.patch, int):
459+
sig.patch -= 1
458460
else:
459461
sig.patch = -1
460462
sig.val = 0

headlesspi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def connect_controls():
4040
fp.add_router_rule(type=TYPE, chan=CHAN, par1=INC_PATCH, par2='1-127', patch='1+')
4141
fp.add_router_rule(type=TYPE, chan=CHAN, par1=BANK_INC, par2='1-127', bank=1)
4242
if SELECT_PATCH != None:
43-
selectspec = f"0-127=0-{min(len(fp.patches) - 1, 127)}" # transform CC values into patch numbers
43+
selectspec = f"0-127=1-{min(len(fp.patches), 128)}" # transform CC values into patch numbers
4444
fp.add_router_rule(type='cc', chan=CHAN, par1=SELECT_PATCH, par2=selectspec, patch='select')
4545
if SHUTDOWN_BTN != None:
4646
fp.add_router_rule(type=TYPE, chan=CHAN, par1=SHUTDOWN_BTN, shutdown=1)
@@ -152,7 +152,7 @@ def select_patch(self, n, force=False):
152152
def listener(self, sig):
153153
# catches custom midi :sig to change patch/bank
154154
if hasattr(sig, 'patch'):
155-
if sig.patch < 0:
155+
if sig.patch == -1:
156156
self.select_patch((self.pno + sig.val) % len(fp.patches))
157157
else:
158158
self.select_patch(sig.patch)

squishbox.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
shell command access and wifi control.
2020
"""
2121

22-
__version__ = '0.8.3'
22+
__version__ = '0.8.4'
2323

2424
import re
2525
import subprocess
@@ -736,7 +736,7 @@ def listener(self, sig):
736736
routing, and additional parameters corresponding to the rule
737737
parameters. The following custom rules are handled:
738738
739-
- `patch`: a patch index to be selected. If `patch` has a '+' or '-'
739+
- `patch`: a patch name or index to be selected. If `patch` has a '+' or '-'
740740
suffix, increment the current patch index instead.
741741
- `lcdwrite`: a string to be written to the LCD, right-justified. If `format`
742742
is provided, the formatted `val` parameter is appended
@@ -745,7 +745,7 @@ def listener(self, sig):
745745
"""
746746
if 'val' in sig:
747747
if 'patch' in sig:
748-
if sig.patch < 0:
748+
if sig.patch == -1:
749749
self.pno = (self.pno + sig.val) % len(fp.patches)
750750
else:
751751
self.pno = sig.patch
@@ -764,6 +764,7 @@ def listener(self, sig):
764764

765765
def patchmode(self):
766766
"""Selects a patch and displays the main screen"""
767+
sb.lcd_clear()
767768
if fp.patches:
768769
warn = fp.apply_patch(self.pno)
769770
else:
@@ -961,6 +962,7 @@ def system_menu(self):
961962
sb.lcd_write("Shutting down..", 0, mode='ljust')
962963
sb.lcd_write("Wait 30s, unplug", 1, mode='ljust', now=True)
963964
sb.shell_cmd("sudo poweroff")
965+
sys.exit()
964966
elif k == 1:
965967
self.midi_devices()
966968
elif k == 2:

0 commit comments

Comments
 (0)