Hold Play to move bank 2 up a layer in the SMC-PAD smoother.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c060720ee
commit
e413530658
3 files changed
+177
-16
No files matched your search
+30
-16
@@ -5,6 +5,10 @@ Reads the physical pad (Bluetooth or USB), passes pad notes through
|
||||
immediately, and eases Control Change values toward their targets at
|
||||
~120 Hz before emitting on a virtual port named "SMC-PAD Smooth".
|
||||
|
||||
On start it also sets the pad lamps over USB (pad_colours.py): bank 1 off and
|
||||
bank 2 in the colours from shows/test.qxw. On Bluetooth it says so and carries on.
|
||||
While Play is held, bank 2 notes 52–67 go out as 68–83 (see pad_layer.py).
|
||||
|
||||
Point QLC+ MIDI input at that virtual port (midi.qxw does this via
|
||||
patch_smc_pad.py once the smoother is running).
|
||||
|
||||
@@ -30,6 +34,10 @@ for p in glob.glob(str(ROOT / ".venv" / "lib" / "python*" / "site-packages")):
|
||||
sys.path.insert(0, p)
|
||||
import rtmidi
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from pad_lamps import set_lamps # noqa: E402
|
||||
from pad_layer import PlayLayer # noqa: E402
|
||||
|
||||
VIRTUAL_NAME = "SMC-PAD Smooth"
|
||||
SOURCE_HINTS = (
|
||||
"SMC-PAD Bluetooth",
|
||||
@@ -100,6 +108,12 @@ def main() -> None:
|
||||
help="smoothing time constant in seconds (default 0.055)",
|
||||
)
|
||||
ap.add_argument("--rate", type=float, default=120.0, help="update Hz")
|
||||
ap.add_argument(
|
||||
"--lock-knobs",
|
||||
action="store_true",
|
||||
help="knobs 1-10 move test.qxw's custom sliders only after the Custom pad is pressed",
|
||||
)
|
||||
ap.add_argument("--no-lamps", action="store_true", help="leave the pad lamp colours alone")
|
||||
args = ap.parse_args()
|
||||
|
||||
midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA, name="smc-smooth-in")
|
||||
@@ -115,11 +129,14 @@ def main() -> None:
|
||||
current: dict[tuple[int, int], float] = {}
|
||||
target: dict[tuple[int, int], float] = {}
|
||||
last_sent: dict[tuple[int, int], int] = {}
|
||||
layer = PlayLayer(lock_knobs=args.lock_knobs)
|
||||
|
||||
print(f"Source: {src_name}", flush=True)
|
||||
print(f"Virtual: {VIRTUAL_NAME} (tau={args.tau}s @ {args.rate} Hz)", flush=True)
|
||||
print("Pass notes through; smooth CC. Ctrl+C to stop.", flush=True)
|
||||
print("Pass notes through (Play held shifts bank 2 up 16); smooth CC. Ctrl+C to stop.", flush=True)
|
||||
ensure_alsa_link()
|
||||
if not args.no_lamps:
|
||||
set_lamps()
|
||||
|
||||
dt = 1.0 / args.rate
|
||||
alpha = 1.0 - math.exp(-dt / max(args.tau, 1e-4))
|
||||
@@ -140,21 +157,18 @@ def main() -> None:
|
||||
data, _ = msg
|
||||
if not data:
|
||||
continue
|
||||
status = data[0]
|
||||
cmd = status & 0xF0
|
||||
ch = status & 0x0F
|
||||
|
||||
if cmd == 0xB0 and len(data) >= 3:
|
||||
# Control Change → smooth
|
||||
cc, val = data[1], data[2]
|
||||
key = (ch, cc)
|
||||
target[key] = float(val)
|
||||
if key not in current:
|
||||
current[key] = float(val)
|
||||
last_sent[key] = -1
|
||||
else:
|
||||
# Notes, aftertouch, PC, etc. → immediate
|
||||
midiout.send_message(data)
|
||||
for out in layer.handle(list(data)):
|
||||
cmd = out[0] & 0xF0
|
||||
if cmd == 0xB0 and len(out) >= 3:
|
||||
# Control Change → smooth
|
||||
key = (out[0] & 0x0F, out[1])
|
||||
target[key] = float(out[2])
|
||||
if key not in current:
|
||||
current[key] = float(out[2])
|
||||
last_sent[key] = -1
|
||||
else:
|
||||
# Notes, aftertouch, PC, etc. → immediate
|
||||
midiout.send_message(out)
|
||||
|
||||
# Ease CC toward targets and emit when quantized value moves
|
||||
for key, tgt in list(target.items()):
|
||||
|
||||
Reference in new issue
Block a user