diff --git a/.claude/launch.json b/.claude/launch.json index d6e4453..30035ae 100644 --- a/.claude/launch.json +++ b/.claude/launch.json @@ -2,9 +2,9 @@ "version": "0.0.1", "configurations": [ { - "name": "padeditor", + "name": "padcontroller", "runtimeExecutable": ".venv/bin/python", - "runtimeArgs": ["-m", "padeditor", "--no-browser"], + "runtimeArgs": ["-m", "padcontroller", "--no-browser"], "port": 8770 } ] diff --git a/Pipfile b/Pipfile index 6705ec6..65f099e 100644 --- a/Pipfile +++ b/Pipfile @@ -14,5 +14,5 @@ python_version = "3.12" [scripts] midi = "python scripts/pad/midi.py" -padcontroller = "python -m padeditor.padcontroller" -padeditor = "python -m padeditor" +padcontroller-midi = "python -m padcontroller.midi" +padcontroller = "python -m padcontroller" diff --git a/README.md b/README.md index 732eb51..6f1fd4c 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,13 @@ manufacturer/model is missing. ## SMC-PAD pad controller -`padeditor.padcontroller` reads the SMC-PAD, smooths its knobs, applies the Play -layer, and sends the result on a virtual MIDI port named `SMC-PAD Smooth` for -QLC+. Run it by hand with `.venv/bin/python -m padeditor.padcontroller`, or install +`padcontroller.midi` reads the SMC-PAD, smooths its knobs, applies the Play +layer, and sends the result on a virtual MIDI port named `padcontroller` for +QLC+. Run it by hand with `.venv/bin/python -m padcontroller.midi`, or install it as a systemd user service that starts at login and waits for the pad: ```bash -padeditor/systemd/install.sh +padcontroller/systemd/install.sh ``` Options after the command go to the pad controller (for example `--lock-knobs`). @@ -76,7 +76,7 @@ python3 scripts/shows/make_chataigne.py shows/test.show.json chataigne/test Open `chataigne/test/test.noisette`. The **Pad** (MIDI) module reads the SMC-PAD directly (`--pad` picks the port: USB `SINCO SMC-PAD-Master` by default, or -`SMC-PAD Bluetooth`). The script does the Play-layer shift that `padeditor/layer.py` does for +`SMC-PAD Bluetooth`). The script does the Play-layer shift that `padcontroller/layer.py` does for QLC+, with no knob smoothing, so the pad controller is not needed. Set the lamps with `scripts/pad/pad_lamps.py`. The **Lights** (DMX) module sends Art-Net to the node in the spec. The **Preview** module sends a copy to 127.0.0.1 for the simulator (`--preview ''` leaves it out). If it comes up on the wrong output, set DMX Type to Art-Net, diff --git a/chataigne/show.template.js b/chataigne/show.template.js index 712db0c..7a37f5d 100644 --- a/chataigne/show.template.js +++ b/chataigne/show.template.js @@ -1,5 +1,5 @@ // Pads pick colours, sliders mix a custom colour, like the QLC+ virtual console. -// It reads the pad directly: Play shifts bank 2 here, as padeditor/layer.py does +// It reads the pad directly: Play shifts bank 2 here, as padcontroller/layer.py does // when QLC+ is used. // Generated by scripts/shows/make_chataigne.py: edit this template, not the output. // @@ -11,7 +11,7 @@ var LAMP = "Lamp"; var LAMP_OFF = 0.3; // brightness of a pad's tile when it is not playing var FADE_RATE = 100; // script updates per second -var PLAY_CC = 27; // hold Play to move bank 2 (notes 52-67) up 16, like padeditor/layer.py +var PLAY_CC = 27; // hold Play to move bank 2 (notes 52-67) up 16, like padcontroller/layer.py var BANK_FIRST = 52; var BANK_LAST = 67; var BANK_SHIFT = 16; diff --git a/chataigne/test/test.js b/chataigne/test/test.js index 4d63392..c5531b7 100644 --- a/chataigne/test/test.js +++ b/chataigne/test/test.js @@ -1,5 +1,5 @@ // Pads pick colours, sliders mix a custom colour, like the QLC+ virtual console. -// It reads the pad directly: Play shifts bank 2 here, as padeditor/layer.py does +// It reads the pad directly: Play shifts bank 2 here, as padcontroller/layer.py does // when QLC+ is used. // Generated by scripts/shows/make_chataigne.py: edit this template, not the output. // @@ -70,7 +70,7 @@ var GROUPS = [ var LAMP = "Lamp"; var LAMP_OFF = 0.3; // brightness of a pad's tile when it is not playing var FADE_RATE = 100; // script updates per second -var PLAY_CC = 27; // hold Play to move bank 2 (notes 52-67) up 16, like padeditor/layer.py +var PLAY_CC = 27; // hold Play to move bank 2 (notes 52-67) up 16, like padcontroller/layer.py var BANK_FIRST = 52; var BANK_LAST = 67; var BANK_SHIFT = 16; diff --git a/padcontroller/__init__.py b/padcontroller/__init__.py new file mode 100644 index 0000000..73eaed4 --- /dev/null +++ b/padcontroller/__init__.py @@ -0,0 +1 @@ +"""Pad Controller: the SMC-PAD preset editor and MIDI intercept.""" diff --git a/padeditor/__main__.py b/padcontroller/__main__.py similarity index 73% rename from padeditor/__main__.py rename to padcontroller/__main__.py index cb6f625..4bd0b14 100644 --- a/padeditor/__main__.py +++ b/padcontroller/__main__.py @@ -1,4 +1,4 @@ -"""python3 -m padeditor [--port 8770]""" +"""python3 -m padcontroller [--port 8770]""" from __future__ import annotations @@ -6,18 +6,18 @@ import argparse import threading import webbrowser -from padeditor.server import make_server +from padcontroller.server import make_server def main(argv: list[str] | None = None) -> int: - parser = argparse.ArgumentParser(prog="padeditor", description="SMC-PAD preset editor") + parser = argparse.ArgumentParser(prog="padcontroller", description="Pad Controller: SMC-PAD preset editor") parser.add_argument("--host", default="127.0.0.1") parser.add_argument("--port", type=int, default=8770) parser.add_argument("--no-browser", action="store_true") args = parser.parse_args(argv) server = make_server(args.host, args.port) url = f"http://{args.host}:{args.port}/" - print(f"SMC-PAD editor → {url} Ctrl+C to quit") + print(f"Pad Controller → {url} Ctrl+C to quit") if not args.no_browser: threading.Timer(0.4, webbrowser.open, args=(url,)).start() try: diff --git a/padeditor/device.py b/padcontroller/device.py similarity index 96% rename from padeditor/device.py rename to padcontroller/device.py index ba3884f..aac6844 100644 --- a/padeditor/device.py +++ b/padcontroller/device.py @@ -13,8 +13,8 @@ import sys import time from pathlib import Path -from padeditor.preset import GLOBAL_LEN, IMAGE_LEN, changed_ranges -from padeditor.sysex import ( +from padcontroller.preset import GLOBAL_LEN, IMAGE_LEN, changed_ranges +from padcontroller.sysex import ( CMD_READ, MEM_GLOBAL, MEM_PRESET, @@ -84,7 +84,7 @@ def transact(midiout, midiin, message: list[int], timeout: float = 0.8, expect: def decode_body(raw: bytes) -> bytes: - from padeditor.sysex import decode + from padcontroller.sysex import decode return decode(raw[1:-1]) @@ -182,7 +182,7 @@ def read_global(link: Link | None = None) -> bytes: def set_bank(bank: int, link: Link | None = None) -> int: """Switch the pad bank the way MidiSuite does: one live byte in the global block. It does not commit; Save keeps whatever the block holds.""" - from padeditor.preset import GLOBAL_BANK + from padcontroller.preset import GLOBAL_BANK if bank not in (0, 1): raise PadError("pad bank must be 0 or 1") @@ -235,7 +235,7 @@ def save_image(desired: bytes, link: Link | None = None, settings: bytes | None def write_colour(preset: int, index: int, rgb: tuple[int, int, int] | list[int]) -> int: """Light one pad. The same three-byte write MidiSuite sends while its colour picker moves. It does not commit; Save does that.""" - from padeditor.preset import colour_offset + from padcontroller.preset import colour_offset if len(rgb) != 3: raise PadError("a pad colour needs red, green, and blue") @@ -270,7 +270,7 @@ def probe_relative(listen: float = 2.5) -> str: when a turn of that knob sends a step, ``absolute`` when it sends a running value, or ``silent`` when nothing arrives. """ - from padeditor.preset import KNOB_AT, KNOB_COUNT, KNOB_LEN, PRESET_COUNT, PRESET_LEN, RELATIVE_TYPE + from padcontroller.preset import KNOB_AT, KNOB_COUNT, KNOB_LEN, PRESET_COUNT, PRESET_LEN, RELATIVE_TYPE knob = KNOB_COUNT - 1 offsets = [index * PRESET_LEN + KNOB_AT + knob * KNOB_LEN for index in range(PRESET_COUNT)] diff --git a/padeditor/factory.bin b/padcontroller/factory.bin similarity index 100% rename from padeditor/factory.bin rename to padcontroller/factory.bin diff --git a/padeditor/layer.py b/padcontroller/layer.py similarity index 100% rename from padeditor/layer.py rename to padcontroller/layer.py diff --git a/padeditor/padcontroller.py b/padcontroller/midi.py similarity index 93% rename from padeditor/padcontroller.py rename to padcontroller/midi.py index 1049b01..a0ad327 100644 --- a/padeditor/padcontroller.py +++ b/padcontroller/midi.py @@ -2,20 +2,20 @@ 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". +~120 Hz before emitting on a virtual port named "padcontroller". On start it also sets the pad lamps over USB (scripts/pad/pad_lamps.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 padeditor/layer.py). +While Play is held, bank 2 notes 52–67 go out as 68–83 (see padcontroller/layer.py). Point QLC+ MIDI input at that virtual port (midi.qxw does this via patch_smc_pad.py once the pad controller is running). Usage: - .venv/bin/python -m padeditor.padcontroller + .venv/bin/python -m padcontroller.midi # optional: --tau 0.05 (seconds; lower = snappier, higher = silkier) -padeditor/systemd/install.sh runs it as a systemd user service. +padcontroller/systemd/install.sh runs it as a systemd user service. """ from __future__ import annotations @@ -35,13 +35,13 @@ for p in glob.glob(str(ROOT / ".venv" / "lib" / "python*" / "site-packages")): sys.path.insert(0, p) import rtmidi -from padeditor.layer import PlayLayer # noqa: E402 +from padcontroller.layer import PlayLayer # noqa: E402 # The lamp colours come from the show scripts, which are not part of this package. sys.path.insert(0, str(ROOT / "scripts" / "pad")) from pad_lamps import set_lamps # noqa: E402 -VIRTUAL_NAME = "SMC-PAD Smooth" +VIRTUAL_NAME = "padcontroller" SOURCE_HINTS = ( "SMC-PAD Bluetooth", "SINCO SMC-PAD-Private", @@ -96,7 +96,7 @@ def ensure_alsa_link() -> None: src = _alsa_port(hint) if src: break - dst = _alsa_port("smc-smooth-in") + dst = _alsa_port("padcontroller-in") if not src or not dst: return subprocess.run(["aconnect", src, dst], capture_output=True) @@ -119,8 +119,8 @@ def main() -> None: 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") - midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA, name="smc-smooth-out") + midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA, name="padcontroller-in") + midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA, name="padcontroller-out") src = find_source_port(midiin) src_name = midiin.get_ports()[src] diff --git a/padeditor/preset.py b/padcontroller/preset.py similarity index 100% rename from padeditor/preset.py rename to padcontroller/preset.py diff --git a/padeditor/server.py b/padcontroller/server.py similarity index 97% rename from padeditor/server.py rename to padcontroller/server.py index 1550f5a..4045255 100644 --- a/padeditor/server.py +++ b/padcontroller/server.py @@ -10,8 +10,8 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path from urllib.parse import urlparse -from padeditor.device import Link, PadError, connected, read_global, read_image, save_image, set_bank, write_colour -from padeditor.preset import IMAGE_LEN, PresetError, pack, pack_global, unpack, unpack_global +from padcontroller.device import Link, PadError, connected, read_global, read_image, save_image, set_bank, write_colour +from padcontroller.preset import IMAGE_LEN, PresetError, pack, pack_global, unpack, unpack_global STATIC_DIR = Path(__file__).parent / "static" # The image MidiSuite uploads for its factory reset, and its global block. diff --git a/padeditor/static/app.js b/padcontroller/static/app.js similarity index 100% rename from padeditor/static/app.js rename to padcontroller/static/app.js diff --git a/padeditor/static/index.html b/padcontroller/static/index.html similarity index 96% rename from padeditor/static/index.html rename to padcontroller/static/index.html index cfad576..6abac25 100644 --- a/padeditor/static/index.html +++ b/padcontroller/static/index.html @@ -3,12 +3,12 @@
-