Compare commits

..
2 Commits
Author SHA1 Message Date
jimmyandClaude Opus 5.5 a985452568 Keep reading the virtual pad while the real pad is away.
The pad controller opened the pad's port as its input and closed it when the
pad went, which stopped rtmidi reading at all, so virtual pad presses never
reached QLC+ and the chases stayed on their starting blue. Its input is now a
port of its own, open for the whole run, with the pad linked into it by
aconnect (and the old link dropped when the pad moves between USB and
Bluetooth). It also starts without the pad instead of exiting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:59:44 +13:00
jimmyandClaude Opus 5.5 0b06dfdccf Add a script linking the RGB scripts, fixtures and pad profile into ~/.qlcplus.
The can patterns' Steps and Swap matrices need rgbscripts/steps.js and
swap.js in ~/.qlcplus/rgbscripts. Only can_patterns.py linked them, so a
fresh checkout's patterns did nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:27:40 +13:00
3 changed files with 56 additions and 21 deletions

No files matched your search

+9 -1
View File
@@ -7,7 +7,7 @@ QLC+ show files, fixture definitions, and generators for the XCHC stage
```
fixtures/ Fixture definitions (.qxf) — install into QLC+ if needed
rgbscripts/ RGB matrix scripts; scripts/shows/can_patterns.py links them into ~/.qlcplus/rgbscripts
rgbscripts/ RGB matrix scripts; scripts/install_qlcplus.sh links them into ~/.qlcplus/rgbscripts
shows/ Workspaces to open in QLC+
xchc.qxw Main show (patterns + movers, unified VC)
simple.qxw Manual board: M1/M2 pads, shared + individual RGBW
@@ -23,6 +23,14 @@ tests/ Art-Net / fixture helpers used by scripts
## Open in QLC+
On a new machine, link the RGB scripts, fixtures and pad input profile into
`~/.qlcplus` first, then (re)start QLC+. Without `rgbscripts/steps.js` and
`swap.js` the can patterns load but do nothing.
```bash
scripts/install_qlcplus.sh
```
- Full show: `shows/xchc.qxw`
- Simple RGBW + positions: `shows/simple.qxw`
+17 -20
View File
@@ -84,16 +84,6 @@ def pick_source(names: list[str]) -> int | None:
return None
def find_source_port(midiin: rtmidi.MidiIn) -> int:
ports = midiin.get_ports()
i = pick_source(ports)
if i is None:
raise SystemExit(
"No SMC-PAD MIDI source found. Ports:\n " + "\n ".join(ports or ["(none)"])
)
return i
@dataclass
class AlsaPort:
addr: str # "client:port"
@@ -171,6 +161,13 @@ def ensure_links(src_name: str | None) -> tuple[bool, set[tuple[str | None, str]
return to_qlc, fed
def unlink_source(src_name: str | None) -> None:
"""Take the pad's old port off padcontroller-in, so a pad moving from USB to Bluetooth isn't heard twice."""
m = re.search(r"(\d+:\d+)$", src_name or "")
if m:
subprocess.run(["aconnect", "-d", m.group(1), "padcontroller-in:0"], capture_output=True)
def load_colours(layer: PlayLayer) -> None:
try:
saved = json.loads(COLOURS_FILE.read_text())
@@ -202,9 +199,13 @@ def main() -> None:
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]
midiin.open_port(src)
names = midiin.get_ports()
src = pick_source(names)
src_name = names[src] if src is not None else None
# Our own input port, with the pad linked into it by ensure_links: it keeps reading while
# the pad is away (rtmidi stops reading when an opened port closes), so the virtual pad
# still gets through.
midiin.open_virtual_port("RtMidi input")
midiin.ignore_types(timing=True, active_sense=True, sysex=True)
midiout.open_virtual_port(VIRTUAL_NAME)
@@ -221,7 +222,7 @@ def main() -> None:
# Links made this soon after start are ours being restored, with QLC+'s buttons as they were.
reopen_from = time.monotonic() + 5.0
print(f"Source: {src_name}", flush=True)
print(f"Source: {src_name or '(pad gone, waiting)'}", flush=True)
print(f"Virtual: {VIRTUAL_NAME} (tau={args.tau}s @ {args.rate} Hz)", flush=True)
print("Pass notes through (Play held shifts bank 2 up 16); smooth CC. Ctrl+C to stop.", flush=True)
_, fed = ensure_links(src_name)
@@ -243,12 +244,8 @@ def main() -> None:
best = pick_source(names)
best_name = names[best] if best is not None else None
if best_name != src_name:
midiin.close_port()
if best is not None:
midiin.open_port(best)
print(f"Source: {best_name}", flush=True)
else:
print("Source: (pad gone, waiting)", flush=True)
unlink_source(src_name)
print(f"Source: {best_name or '(pad gone, waiting)'}", flush=True)
src_name = best_name
linked, now_fed = ensure_links(src_name)
if (linked or now_fed - fed) and now >= reopen_from:
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Link this repo's RGB scripts, fixtures and input profiles into ~/.qlcplus,
# where QLC+ looks for them. The shows' can patterns use rgbscripts/steps.js
# and swap.js, so without them those matrices do nothing. Restart QLC+ after
# running this: it reads these folders at startup.
#
# scripts/install_qlcplus.sh # link what is missing; keep files that differ
# scripts/install_qlcplus.sh --force # replace files that differ with links
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
USER_DIR="$HOME/.qlcplus"
FORCE=
[[ "${1:-}" == "--force" ]] && FORCE=1
for dir in rgbscripts fixtures inputprofiles; do
mkdir -p "$USER_DIR/$dir"
for src in "$ROOT/$dir"/*; do
dest="$USER_DIR/$dir/$(basename "$src")"
if [[ -L "$dest" && "$(readlink -f "$dest")" == "$src" ]]; then
continue
fi
if [[ -e "$dest" && ! -L "$dest" ]] && ! cmp -s "$src" "$dest" && [[ -z "$FORCE" ]]; then
echo "Kept $dest: it differs from $dir/$(basename "$src"). --force replaces it." >&2
continue
fi
ln -sfn "$src" "$dest"
echo "Linked $dest"
done
done