Add Pattern Studio, SMC-PAD MIDI helpers, and the current venue workspaces.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
55a38478db
commit
12420bec93
19 files changed
+8954
No files matched your search
Executable
+219
@@ -0,0 +1,219 @@
|
||||
#!/usr/bin/env bash
|
||||
# Flash LuxDMX onto a Seeed Studio XIAO ESP32S3.
|
||||
#
|
||||
# The XIAO is an ESP32-S3R8 (octal 8 MB PSRAM, native USB only). It shows up
|
||||
# as an Espressif "USB JTAG/serial" port (/dev/ttyACM*), not a ttyUSB UART
|
||||
# dongle. This downloads the current LuxDMX release and writes the
|
||||
# octal-PSRAM image. esptool detects the flash size and rewrites the image
|
||||
# header to match (this board reports 16 MB). The partition table ends at
|
||||
# 4 MB, so either size fits. The write is a full erase, so the first boot
|
||||
# opens the setup access point.
|
||||
#
|
||||
# scripts/flash_luxdmx_xiao.sh
|
||||
# scripts/flash_luxdmx_xiao.sh --port /dev/ttyACM0
|
||||
# scripts/flash_luxdmx_xiao.sh --plain # leave the PSRAM unused
|
||||
# scripts/flash_luxdmx_xiao.sh --version v1.0.273
|
||||
# scripts/flash_luxdmx_xiao.sh --dry-run
|
||||
#
|
||||
# A full USB flash erases saved Wi-Fi and config. To update a board that is
|
||||
# already set up, use the device's own Firmware Update page instead.
|
||||
#
|
||||
# After it boots, join the open Wi-Fi "LuxDMX-setup" and open
|
||||
# http://192.168.4.1. In /config apply the "Seeed XIAO ESP32-S3" template:
|
||||
# DMX data is D0 (GPIO1) and the RDM return is D1 (GPIO2). The DevKit
|
||||
# defaults (GPIO16/17) are not broken out on this board.
|
||||
set -euo pipefail
|
||||
|
||||
REPO="tombueng/LuxDMX"
|
||||
TAG="latest"
|
||||
PORT=""
|
||||
PLAIN=0
|
||||
YES=0
|
||||
DRY=0
|
||||
BAUD=921600
|
||||
|
||||
usage() {
|
||||
sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 2
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--port) PORT="${2:?}"; shift 2 ;;
|
||||
--version) TAG="${2:?}"; shift 2 ;;
|
||||
--baud) BAUD="${2:?}"; shift 2 ;;
|
||||
--plain) PLAIN=1; shift ;;
|
||||
--yes) YES=1; shift ;;
|
||||
--dry-run) DRY=1; shift ;;
|
||||
-h|--help) usage ;;
|
||||
*) echo "Unknown option: $1" >&2; usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Ubuntu's esptool package is missing the ESP32-S3 flasher stub, so a
|
||||
# version check is not enough. Use it only when that stub is actually there.
|
||||
esptool_has_s3_stub() {
|
||||
"$1" - << 'PY'
|
||||
import pathlib, sys
|
||||
try:
|
||||
import esptool
|
||||
except ImportError:
|
||||
sys.exit(1)
|
||||
root = pathlib.Path(esptool.__file__).resolve().parent / "targets" / "stub_flasher"
|
||||
ok = (root / "stub_flasher_32s3.json").is_file() or any(root.glob("*/esp32s3.json"))
|
||||
sys.exit(0 if ok else 1)
|
||||
PY
|
||||
}
|
||||
|
||||
if esptool_has_s3_stub python3; then
|
||||
ESPTOOL=(python3 -m esptool)
|
||||
else
|
||||
VENV="${XDG_CACHE_HOME:-$HOME/.cache}/luxdmx/esptool-venv"
|
||||
if [[ ! -x "$VENV/bin/python" ]] || ! esptool_has_s3_stub "$VENV/bin/python"; then
|
||||
echo "System esptool has no ESP32-S3 stub. Installing one into ${VENV}…"
|
||||
python3 -m venv "$VENV"
|
||||
"$VENV/bin/pip" install -q 'esptool>=4.8,<5'
|
||||
fi
|
||||
ESPTOOL=("$VENV/bin/python" -m esptool)
|
||||
fi
|
||||
|
||||
if [[ "$PLAIN" -eq 1 ]]; then
|
||||
BOOT="bootloader-esp32s3.bin"
|
||||
PARTS="partitions-esp32s3.bin"
|
||||
APP="firmware-esp32s3.bin"
|
||||
IMAGE="plain ESP32-S3 (PSRAM left unused)"
|
||||
else
|
||||
BOOT="bootloader-esp32s3-psram.bin"
|
||||
PARTS="partitions-esp32s3-psram.bin"
|
||||
APP="firmware-esp32s3-psram.bin"
|
||||
IMAGE="ESP32-S3 octal PSRAM (XIAO ESP32S3 / S3R8)"
|
||||
fi
|
||||
|
||||
find_port() {
|
||||
if [[ -n "$PORT" ]]; then
|
||||
[[ -e "$PORT" ]] || { echo "Port not found: $PORT" >&2; exit 1; }
|
||||
echo "$PORT"
|
||||
return
|
||||
fi
|
||||
local -a matches=()
|
||||
local p
|
||||
shopt -s nullglob
|
||||
for p in /dev/serial/by-id/*; do
|
||||
case "$p" in
|
||||
*[Ee]spressif*|*[Ss]eeed*|*[Xx][Ii][Aa][Oo]*)
|
||||
matches+=("$(readlink -f "$p")")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shopt -u nullglob
|
||||
if [[ ${#matches[@]} -eq 1 ]]; then
|
||||
echo "${matches[0]}"
|
||||
return
|
||||
fi
|
||||
if [[ ${#matches[@]} -gt 1 ]]; then
|
||||
echo "More than one Espressif/Seeed serial port. Pass --port." >&2
|
||||
printf ' %s\n' "${matches[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
shopt -s nullglob
|
||||
matches=(/dev/ttyACM*)
|
||||
shopt -u nullglob
|
||||
if [[ ${#matches[@]} -eq 1 && -e "${matches[0]}" ]]; then
|
||||
echo "${matches[0]}"
|
||||
return
|
||||
fi
|
||||
echo "No XIAO found. Plug in the USB-C port, then re-run." >&2
|
||||
echo "If it still does not appear: hold B, tap R, release B, and pass --port." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
CACHE_ROOT="${XDG_CACHE_HOME:-$HOME/.cache}/luxdmx"
|
||||
mkdir -p "$CACHE_ROOT"
|
||||
|
||||
mapfile -t DL < <(python3 - "$CACHE_ROOT" "$TAG" "$BOOT" "$PARTS" "boot_app0.bin" "$APP" << 'PY'
|
||||
import json, pathlib, sys, urllib.request
|
||||
cache_root, tag, *names = sys.argv[1:]
|
||||
api = f"https://api.github.com/repos/tombueng/LuxDMX/releases/tags/{tag}"
|
||||
req = urllib.request.Request(api, headers={"Accept": "application/vnd.github+json", "User-Agent": "luxdmx-flash"})
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
release = json.load(resp)
|
||||
name = release.get("name") or release.get("tag_name") or tag
|
||||
# "Latest → v1.0.273 (....)" — cache by the version, not the moving tag.
|
||||
version = name
|
||||
for token in name.replace("→", " ").replace("(", " ").split():
|
||||
if token.startswith("v") and token[1:2].isdigit():
|
||||
version = token
|
||||
break
|
||||
assets = {a["name"]: a for a in release.get("assets", [])}
|
||||
missing = [n for n in names if n not in assets]
|
||||
if missing:
|
||||
sys.exit(f"Release {version} has no {', '.join(missing)}")
|
||||
dest = pathlib.Path(cache_root) / version
|
||||
dest.mkdir(parents=True, exist_ok=True)
|
||||
for n in names:
|
||||
path = dest / n
|
||||
size = assets[n]["size"]
|
||||
if path.is_file() and path.stat().st_size == size:
|
||||
continue
|
||||
url = assets[n]["browser_download_url"]
|
||||
tmp = path.with_suffix(path.suffix + ".part")
|
||||
urllib.request.urlretrieve(url, tmp)
|
||||
if tmp.stat().st_size != size:
|
||||
tmp.unlink(missing_ok=True)
|
||||
sys.exit(f"Short download: {n}")
|
||||
tmp.replace(path)
|
||||
print(version)
|
||||
print(dest)
|
||||
PY
|
||||
)
|
||||
|
||||
VERSION="${DL[0]}"
|
||||
DIR="${DL[1]}"
|
||||
PORT="$(find_port)"
|
||||
|
||||
echo "LuxDMX ${VERSION} (${IMAGE})"
|
||||
echo "Port ${PORT} baud ${BAUD}"
|
||||
echo "This erases the whole flash, including saved Wi-Fi and config."
|
||||
|
||||
if [[ "$DRY" -eq 1 ]]; then
|
||||
echo "Dry run — not flashing."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$YES" -ne 1 ]]; then
|
||||
if [[ ! -t 0 ]]; then
|
||||
echo "Pass --yes to flash without a prompt." >&2
|
||||
exit 1
|
||||
fi
|
||||
read -r -p "Flash now? [y/N] " ans
|
||||
[[ "$ans" == [yY] ]] || { echo "Cancelled."; exit 1; }
|
||||
fi
|
||||
|
||||
set +e
|
||||
"${ESPTOOL[@]}" --chip esp32s3 --port "$PORT" --baud "$BAUD" \
|
||||
--before default_reset --after hard_reset \
|
||||
write_flash --erase-all --flash_mode keep --flash_freq keep --flash_size detect --compress \
|
||||
0x0000 "${DIR}/${BOOT}" \
|
||||
0x8000 "${DIR}/${PARTS}" \
|
||||
0xe000 "${DIR}/boot_app0.bin" \
|
||||
0x10000 "${DIR}/${APP}"
|
||||
rc=$?
|
||||
set -e
|
||||
|
||||
if [[ $rc -ne 0 ]]; then
|
||||
echo >&2
|
||||
echo "Flash failed. Put the XIAO in download mode and run this again:" >&2
|
||||
echo " hold B, tap R, release B, then: $0 --port $PORT --yes" >&2
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
cat << 'EOF'
|
||||
|
||||
Flashed. On first boot the XIAO opens an open Wi-Fi network:
|
||||
SSID LuxDMX-setup
|
||||
URL http://192.168.4.1
|
||||
|
||||
In /config, apply the "Seeed XIAO ESP32-S3" template so the DMX pins
|
||||
match the header (D0 = data out, D1 = RDM return). Then point QLC+
|
||||
Art-Net at the address shown there, universe 0.
|
||||
EOF
|
||||
@@ -0,0 +1,392 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build shows/midi.qxw — M-VAVE SMC-PAD controlling 20× BCC145 (Dim + RGBW)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / "shows" / "midi.qxw"
|
||||
PROFILE_SRC = ROOT / "inputprofiles" / "M-VAVE-SMC-PAD.qxi"
|
||||
PROFILE_DST = Path.home() / ".qlcplus" / "inputprofiles" / "M-VAVE-SMC-PAD.qxi"
|
||||
|
||||
PROFILE_NAME = "M-VAVE SMC-PAD"
|
||||
MIDI_UNIVERSE_ID = 1 # Universe 2
|
||||
OMNI_MIDICHANNEL = 16 # pads ch10 + knobs ch1
|
||||
PAD_MIDI_CH = 9
|
||||
|
||||
# 20× BCC145, 8ch mode, physical/UI start channel 88
|
||||
# QLC XML Address is 0-based: Address 87 → DMX/UI channel 88 (same as xchc.qxw).
|
||||
BCC_COUNT = 20
|
||||
BCC_START_ADDRESS = 87
|
||||
BCC_CHANNELS = 8
|
||||
UNIVERSE_CHANNELS = BCC_START_ADDRESS + BCC_COUNT * BCC_CHANNELS # 247
|
||||
# 8ch map: 0 Dim, 1 Strobe, 2–5 RGBW, 6 Macro, 7 Speed
|
||||
STROBE_CH, MACRO_CH, SPEED_CH = 1, 6, 7
|
||||
|
||||
# Knob bank 1 (CC 30–37): knobs 1–8 — master Dim/RGBW/Strobe/Macro/Speed
|
||||
# Knob bank 2 (CC 38–44): knobs 9–15 — Dim boost for #9–#15 (HTP vs master)
|
||||
KNOB_BANK1 = [
|
||||
# (cc, caption, widget_id, dmx_ch, fg, cng, value, fixtures|None)
|
||||
(32, "Dim", 0, 0, "4294967295", "None", 200, None),
|
||||
(36, "R", 1, 2, "4294901760", "Red", 0, None),
|
||||
(37, "G", 2, 3, "4278255360", "Green", 0, None),
|
||||
(34, "B", 3, 4, "4278190335", "Blue", 0, None),
|
||||
(35, "W", 4, 5, "4294967295", "None", 0, None),
|
||||
(33, "Strobe", 5, STROBE_CH, "4294922844", "None", 0, None),
|
||||
(30, "Macro", 6, MACRO_CH, "4288256409", "None", 0, None),
|
||||
(31, "Speed", 7, SPEED_CH, "4286611584", "None", 0, None),
|
||||
]
|
||||
KNOB_BANK2 = [
|
||||
# (cc, caption, widget_id, fixture_id)
|
||||
(38, "F9", 20, 8),
|
||||
(39, "F10", 21, 9),
|
||||
(40, "F11", 22, 10),
|
||||
(41, "F12", 23, 11),
|
||||
(42, "F13", 24, 12),
|
||||
(43, "F14", 25, 13),
|
||||
(44, "F15", 26, 14),
|
||||
]
|
||||
|
||||
# 4×4 pads → colour flashes / utility (scenes built below)
|
||||
# note 36..51 with OMNI encoding
|
||||
PAD_COLORS = [
|
||||
# (name, r, g, b, w) — bottom row left→right, then up
|
||||
("Red", 255, 0, 0, 0),
|
||||
("Green", 0, 255, 0, 0),
|
||||
("Blue", 0, 0, 255, 0),
|
||||
("White", 0, 0, 0, 255),
|
||||
("Yellow", 255, 255, 0, 0),
|
||||
("Cyan", 0, 255, 255, 0),
|
||||
("Magenta", 255, 0, 255, 0),
|
||||
("Orange", 255, 80, 0, 0),
|
||||
("Warm", 255, 120, 40, 80),
|
||||
("Cool", 80, 120, 255, 40),
|
||||
("Pink", 255, 40, 120, 0),
|
||||
("Lime", 120, 255, 0, 0),
|
||||
("Full", 255, 255, 255, 255),
|
||||
("Half", 128, 128, 128, 128),
|
||||
("Dim50", 0, 0, 0, 0), # blackout colour; dim stays
|
||||
("Black", 0, 0, 0, 0),
|
||||
]
|
||||
|
||||
|
||||
def detect_midi_uid() -> str:
|
||||
"""Prefer smoothed virtual port when the smoother daemon is running."""
|
||||
try:
|
||||
out = subprocess.check_output(["aconnect", "-l"], text=True)
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
out = ""
|
||||
for name in (
|
||||
"SMC-PAD Smooth",
|
||||
"SMC-PAD Bluetooth",
|
||||
"SINCO SMC-PAD-Private",
|
||||
"SINCO SMC-PAD-Master",
|
||||
"SINCO",
|
||||
):
|
||||
if name in out:
|
||||
return name
|
||||
return "SMC-PAD Bluetooth"
|
||||
|
||||
|
||||
ARTNET_OUTPUT_IP = "192.168.1.175"
|
||||
# Device Art-Net universe (IceRay SwOut); keep in sync with the box
|
||||
ARTNET_OUTPUT_UNI = "0"
|
||||
ARTNET_LINE = "0"
|
||||
|
||||
|
||||
def detect_artnet_uid() -> str:
|
||||
"""Local IPv4 on the same /24 as the Art-Net node (prefer wlan/eth)."""
|
||||
try:
|
||||
out = subprocess.check_output(["ip", "-4", "-o", "addr", "show"], text=True)
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
return "192.168.1.90"
|
||||
prefix = ".".join(ARTNET_OUTPUT_IP.split(".")[:3]) + "."
|
||||
candidates: list[str] = []
|
||||
for line in out.splitlines():
|
||||
# 2: wlo1 inet 192.168.1.90/24 ...
|
||||
parts = line.split()
|
||||
if len(parts) < 4 or parts[2] != "inet":
|
||||
continue
|
||||
ip = parts[3].split("/", 1)[0]
|
||||
iface = parts[1]
|
||||
if ip.startswith(prefix) and not iface.startswith(("lo", "vir", "docker", "br-", "mpq")):
|
||||
candidates.append(ip)
|
||||
return candidates[0] if candidates else "192.168.1.90"
|
||||
|
||||
|
||||
def output_xml() -> str:
|
||||
uid = detect_artnet_uid()
|
||||
return f""" <Output Plugin="ArtNet" UID="{uid}" Line="{ARTNET_LINE}">
|
||||
<PluginParameters outputIP="{ARTNET_OUTPUT_IP}" outputUni="{ARTNET_OUTPUT_UNI}" UniverseChannels="{UNIVERSE_CHANNELS}"/>
|
||||
</Output>"""
|
||||
|
||||
|
||||
def install_profile() -> None:
|
||||
PROFILE_DST.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(PROFILE_SRC, PROFILE_DST)
|
||||
|
||||
|
||||
def appearance(fg: str = "Default") -> str:
|
||||
return f""" <Appearance>
|
||||
<FrameStyle>Sunken</FrameStyle>
|
||||
<ForegroundColor>{fg}</ForegroundColor>
|
||||
<BackgroundColor>Default</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>"""
|
||||
|
||||
|
||||
def fixture_ids() -> range:
|
||||
return range(BCC_COUNT)
|
||||
|
||||
|
||||
def slider(
|
||||
wid: int,
|
||||
caption: str,
|
||||
x: int,
|
||||
y: int,
|
||||
dmx_ch: int,
|
||||
*,
|
||||
fg: str,
|
||||
cng: str,
|
||||
value: int,
|
||||
midi_cc: int | None,
|
||||
fixtures: range | list[int] | None = None,
|
||||
width: int = 60,
|
||||
height: int = 280,
|
||||
) -> str:
|
||||
inp = ""
|
||||
if midi_cc is not None:
|
||||
inp = f'\n <Input Universe="{MIDI_UNIVERSE_ID}" Channel="{midi_cc}"/>'
|
||||
fids = list(fixture_ids() if fixtures is None else fixtures)
|
||||
channels = "\n".join(
|
||||
f' <Channel Fixture="{fid}">{dmx_ch}</Channel>' for fid in fids
|
||||
)
|
||||
return f""" <Slider Caption="{caption}" ID="{wid}" WidgetStyle="Slider" InvertedAppearance="false">
|
||||
<WindowState Visible="True" X="{x}" Y="{y}" Width="{width}" Height="{height}"/>
|
||||
{appearance(fg)}
|
||||
<SliderMode ValueDisplayStyle="Exact" ClickAndGoType="{cng}" Monitor="true">Level</SliderMode>
|
||||
<Level LowLimit="0" HighLimit="255" Value="{value}">
|
||||
{channels}
|
||||
</Level>
|
||||
<Playback>
|
||||
<Function>4294967295</Function>
|
||||
</Playback>{inp}
|
||||
</Slider>"""
|
||||
|
||||
|
||||
def scene_xml(fid: int, name: str, r: int, g: int, b: int, w: int) -> str:
|
||||
# BCC145 8ch: Dim left to slider; force Strobe/Macro/Speed off; set RGBW.
|
||||
vals = [
|
||||
(STROBE_CH, 0),
|
||||
(2, r),
|
||||
(3, g),
|
||||
(4, b),
|
||||
(5, w),
|
||||
(MACRO_CH, 0),
|
||||
(SPEED_CH, 0),
|
||||
]
|
||||
fv = "\n".join(
|
||||
f' <FixtureVal ID="{fx}" Channel="{ch}">{v}</FixtureVal>'
|
||||
for fx in fixture_ids()
|
||||
for ch, v in vals
|
||||
)
|
||||
return f""" <Function ID="{fid}" Type="Scene" Name="{name}">
|
||||
<Bus Role="Fade">1</Bus>
|
||||
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
|
||||
<Direction>Forward</Direction>
|
||||
<RunOrder>Loop</RunOrder>
|
||||
{fv}
|
||||
</Function>"""
|
||||
|
||||
|
||||
def fixtures_xml() -> str:
|
||||
blocks = []
|
||||
for i in fixture_ids():
|
||||
addr = BCC_START_ADDRESS + i * BCC_CHANNELS
|
||||
blocks.append(
|
||||
f""" <Fixture>
|
||||
<Manufacturer>beamZ</Manufacturer>
|
||||
<Model>BCC145</Model>
|
||||
<Mode>8 Channel</Mode>
|
||||
<ID>{i}</ID>
|
||||
<Name>BCC145 #{i + 1}</Name>
|
||||
<Universe>0</Universe>
|
||||
<Address>{addr}</Address>
|
||||
<Channels>{BCC_CHANNELS}</Channels>
|
||||
</Fixture>"""
|
||||
)
|
||||
return "\n".join(blocks)
|
||||
|
||||
|
||||
def button_xml(wid: int, caption: str, x: int, y: int, func_id: int, midi_ch: int, bg: str) -> str:
|
||||
return f""" <Button Caption="{caption}" ID="{wid}" Icon="">
|
||||
<WindowState Visible="True" X="{x}" Y="{y}" Width="70" Height="56"/>
|
||||
<Appearance>
|
||||
<FrameStyle>None</FrameStyle>
|
||||
<ForegroundColor>4294967295</ForegroundColor>
|
||||
<BackgroundColor>{bg}</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>
|
||||
<Function ID="{func_id}"/>
|
||||
<Action>Toggle</Action>
|
||||
<Intensity Adjust="False">100</Intensity>
|
||||
<Input Universe="{MIDI_UNIVERSE_ID}" Channel="{midi_ch}"/>
|
||||
</Button>"""
|
||||
|
||||
|
||||
def bg_color(r: int, g: int, b: int) -> str:
|
||||
# QLC packed ARGB as decimal
|
||||
return str((0xFF << 24) | (r << 16) | (g << 8) | b)
|
||||
|
||||
|
||||
def build(uid: str) -> str:
|
||||
functions = []
|
||||
buttons = []
|
||||
for i, (name, r, g, b, w) in enumerate(PAD_COLORS):
|
||||
fid = 10 + i
|
||||
note = 36 + i
|
||||
midi_ch = (PAD_MIDI_CH << 12) | (128 + note)
|
||||
functions.append(scene_xml(fid, name, r, g, b, w))
|
||||
row, col = divmod(i, 4)
|
||||
# pad grid: bottom row is notes 36-39 → visual row 3
|
||||
vx = 20 + col * 80
|
||||
vy = 20 + (3 - row) * 66
|
||||
buttons.append(
|
||||
button_xml(10 + i, name, vx, vy, fid, midi_ch, bg_color(r, g, b))
|
||||
)
|
||||
|
||||
sliders = []
|
||||
for i, (cc, cap, wid, dmx, fg, cng, val, fxs) in enumerate(KNOB_BANK1):
|
||||
sliders.append(
|
||||
slider(
|
||||
wid,
|
||||
cap,
|
||||
360 + i * 58,
|
||||
20,
|
||||
dmx,
|
||||
fg=fg,
|
||||
cng=cng,
|
||||
value=val,
|
||||
midi_cc=cc,
|
||||
fixtures=fxs,
|
||||
)
|
||||
)
|
||||
for i, (cc, cap, wid, fx) in enumerate(KNOB_BANK2):
|
||||
sliders.append(
|
||||
slider(
|
||||
wid,
|
||||
cap,
|
||||
360 + i * 58,
|
||||
310,
|
||||
0, # Dim
|
||||
fg="4294967295",
|
||||
cng="None",
|
||||
value=200,
|
||||
midi_cc=cc,
|
||||
fixtures=[fx],
|
||||
height=120,
|
||||
)
|
||||
)
|
||||
|
||||
vc_widgets = "\n".join(buttons + sliders)
|
||||
funcs = "\n".join(functions)
|
||||
fixtures = fixtures_xml()
|
||||
dmx_out = output_xml()
|
||||
|
||||
return f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Workspace>
|
||||
<Workspace xmlns="http://www.qlcplus.org/Workspace" CurrentWindow="VirtualConsole">
|
||||
<Creator>
|
||||
<Name>Q Light Controller Plus</Name>
|
||||
<Version>4.12.7</Version>
|
||||
<Author>Jimmy</Author>
|
||||
</Creator>
|
||||
<Engine>
|
||||
<InputOutputMap>
|
||||
<Universe Name="Universe 1" ID="0">
|
||||
{dmx_out}
|
||||
</Universe>
|
||||
<Universe Name="Universe 2" ID="1">
|
||||
<Input Plugin="MIDI" UID="{uid}" Line="0" Profile="{PROFILE_NAME}">
|
||||
<PluginParameters midichannel="{OMNI_MIDICHANNEL}"/>
|
||||
</Input>
|
||||
</Universe>
|
||||
<Universe Name="Universe 3" ID="2"/>
|
||||
<Universe Name="Universe 4" ID="3"/>
|
||||
</InputOutputMap>
|
||||
{fixtures}
|
||||
{funcs}
|
||||
</Engine>
|
||||
<VirtualConsole>
|
||||
<Frame Caption="">
|
||||
<Appearance>
|
||||
<FrameStyle>None</FrameStyle>
|
||||
<ForegroundColor>Default</ForegroundColor>
|
||||
<BackgroundColor>Default</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>
|
||||
{vc_widgets}
|
||||
</Frame>
|
||||
<Properties>
|
||||
<Size Width="900" Height="460"/>
|
||||
<GrandMaster ChannelMode="Intensity" ValueMode="Reduce" SliderMode="Normal"/>
|
||||
</Properties>
|
||||
</VirtualConsole>
|
||||
<SimpleDesk>
|
||||
<Engine/>
|
||||
</SimpleDesk>
|
||||
</Workspace>
|
||||
"""
|
||||
|
||||
|
||||
def patch_qsettings(uid: str) -> None:
|
||||
conf = Path.home() / ".config" / "qlcplus" / "Q Light Controller Plus.conf"
|
||||
if not conf.exists():
|
||||
return
|
||||
text = conf.read_text()
|
||||
key = uid.replace(" ", "%20")
|
||||
pattern = rf"(Input\\{re.escape(key)}\\midichannel=)\d+"
|
||||
if re.search(pattern, text):
|
||||
text = re.sub(pattern, rf"\g<1>{OMNI_MIDICHANNEL}", text)
|
||||
elif "[midiplugin]" in text and f"Input\\{key}\\midichannel=" not in text:
|
||||
text = text.replace(
|
||||
"[midiplugin]\n",
|
||||
f"[midiplugin]\nInput\\{key}\\midichannel={OMNI_MIDICHANNEL}\n"
|
||||
f"Input\\{key}\\mode=Control Change\n"
|
||||
f"Input\\{key}\\initmessage=\n",
|
||||
1,
|
||||
)
|
||||
conf.write_text(text)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
uid = detect_midi_uid()
|
||||
install_profile()
|
||||
patch_qsettings(uid)
|
||||
OUT.write_text(build(uid))
|
||||
ui_start = BCC_START_ADDRESS + 1
|
||||
ui_last = BCC_START_ADDRESS + BCC_COUNT * BCC_CHANNELS
|
||||
print(f"Wrote {OUT}")
|
||||
print(f" MIDI: {uid} OMNI on Universe 2")
|
||||
print(
|
||||
f" Art-Net → {ARTNET_OUTPUT_IP} uni {ARTNET_OUTPUT_UNI} "
|
||||
f"(local {detect_artnet_uid()})"
|
||||
)
|
||||
print(
|
||||
f" {BCC_COUNT}× BCC145 8ch @ UI {ui_start}–{ui_last} "
|
||||
f"(XML Address {BCC_START_ADDRESS}–{BCC_START_ADDRESS + (BCC_COUNT - 1) * BCC_CHANNELS})"
|
||||
)
|
||||
print(" Bank1 knobs 1–8: Dim/RGBW/Strobe/Macro/Speed (all)")
|
||||
print(" Bank2 knobs 9–15: Dim for #9–#15")
|
||||
print(" 16 pads → colour scenes (all fixtures; strobe/macro forced off)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Launch Mover Pattern Studio (local web app) for the shows in this repo.
|
||||
# scripts/pattern_studio.sh # opens http://127.0.0.1:8765 in your browser
|
||||
# scripts/pattern_studio.sh --port 9000 --no-browser
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
exec python3 -m patternstudio "$@"
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Smooth SMC-PAD knob CCs so RGBW fades feel less stepped.
|
||||
|
||||
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".
|
||||
|
||||
Point QLC+ MIDI input at that virtual port (midi.qxw does this via
|
||||
patch_smc_pad.py once the smoother is running).
|
||||
|
||||
Usage:
|
||||
.venv/bin/python scripts/smooth_smc_pad.py
|
||||
# optional: --tau 0.05 (seconds; lower = snappier, higher = silkier)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import math
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
import glob
|
||||
|
||||
for p in glob.glob(str(ROOT / ".venv" / "lib" / "python*" / "site-packages")):
|
||||
sys.path.insert(0, p)
|
||||
import rtmidi
|
||||
|
||||
VIRTUAL_NAME = "SMC-PAD Smooth"
|
||||
SOURCE_HINTS = (
|
||||
"SMC-PAD Bluetooth",
|
||||
"SINCO SMC-PAD-Private",
|
||||
"SINCO SMC-PAD-Master",
|
||||
"SINCO",
|
||||
"SMC-PAD",
|
||||
)
|
||||
|
||||
|
||||
def find_source_port(midiin: rtmidi.MidiIn) -> int:
|
||||
ports = midiin.get_ports()
|
||||
for hint in SOURCE_HINTS:
|
||||
for i, name in enumerate(ports):
|
||||
if hint in name and VIRTUAL_NAME not in name:
|
||||
return i
|
||||
raise SystemExit(
|
||||
"No SMC-PAD MIDI source found. Ports:\n " + "\n ".join(ports or ["(none)"])
|
||||
)
|
||||
|
||||
|
||||
def _alsa_port(client_substr: str, port_substr: str | None = None) -> str | None:
|
||||
"""Return 'client:port' for an aconnect client/port name match."""
|
||||
try:
|
||||
out = subprocess.check_output(["aconnect", "-l"], text=True)
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
return None
|
||||
client = None
|
||||
client_name = None
|
||||
for line in out.splitlines():
|
||||
m = re.match(r"client (\d+): '([^']+)'", line)
|
||||
if m:
|
||||
client, client_name = int(m.group(1)), m.group(2)
|
||||
continue
|
||||
m = re.match(r"\s+(\d+)\s+'([^']+)'", line)
|
||||
if not m or client is None or client_name is None:
|
||||
continue
|
||||
port, pname = int(m.group(1)), m.group(2).strip()
|
||||
if client_substr not in client_name and client_substr not in pname:
|
||||
continue
|
||||
if port_substr and port_substr not in pname and port_substr not in client_name:
|
||||
continue
|
||||
if VIRTUAL_NAME in pname:
|
||||
continue
|
||||
return f"{client}:{port}"
|
||||
return None
|
||||
|
||||
|
||||
def ensure_alsa_link() -> None:
|
||||
"""Bluetooth MIDI sometimes drops the ALSA subscription; re-subscribe."""
|
||||
src = None
|
||||
for hint in ("SMC-PAD Bluetooth", "SINCO", "SMC-PAD"):
|
||||
src = _alsa_port(hint)
|
||||
if src:
|
||||
break
|
||||
dst = _alsa_port("smc-smooth-in")
|
||||
if not src or not dst:
|
||||
return
|
||||
subprocess.run(["aconnect", src, dst], capture_output=True)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
ap = argparse.ArgumentParser(description=__doc__)
|
||||
ap.add_argument(
|
||||
"--tau",
|
||||
type=float,
|
||||
default=0.055,
|
||||
help="smoothing time constant in seconds (default 0.055)",
|
||||
)
|
||||
ap.add_argument("--rate", type=float, default=120.0, help="update Hz")
|
||||
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")
|
||||
|
||||
src = find_source_port(midiin)
|
||||
src_name = midiin.get_ports()[src]
|
||||
midiin.open_port(src)
|
||||
midiin.ignore_types(timing=True, active_sense=True, sysex=True)
|
||||
midiout.open_virtual_port(VIRTUAL_NAME)
|
||||
|
||||
# current/target as floats 0..127, keyed by (channel, cc)
|
||||
current: dict[tuple[int, int], float] = {}
|
||||
target: dict[tuple[int, int], float] = {}
|
||||
last_sent: dict[tuple[int, int], int] = {}
|
||||
|
||||
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)
|
||||
ensure_alsa_link()
|
||||
|
||||
dt = 1.0 / args.rate
|
||||
alpha = 1.0 - math.exp(-dt / max(args.tau, 1e-4))
|
||||
next_link_check = time.monotonic() + 2.0
|
||||
|
||||
try:
|
||||
while True:
|
||||
now = time.monotonic()
|
||||
if now >= next_link_check:
|
||||
ensure_alsa_link()
|
||||
next_link_check = now + 2.0
|
||||
|
||||
# Drain inbound
|
||||
while True:
|
||||
msg = midiin.get_message()
|
||||
if msg is None:
|
||||
break
|
||||
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)
|
||||
|
||||
# Ease CC toward targets and emit when quantized value moves
|
||||
for key, tgt in list(target.items()):
|
||||
cur = current.get(key, tgt)
|
||||
cur = cur + (tgt - cur) * alpha
|
||||
# Snap when close so we actually reach the endpoint
|
||||
if abs(tgt - cur) < 0.15:
|
||||
cur = tgt
|
||||
current[key] = cur
|
||||
q = int(round(cur))
|
||||
q = 0 if q < 0 else 127 if q > 127 else q
|
||||
if last_sent.get(key) != q:
|
||||
ch, cc = key
|
||||
midiout.send_message([0xB0 | ch, cc, q])
|
||||
last_sent[key] = q
|
||||
|
||||
time.sleep(dt)
|
||||
except KeyboardInterrupt:
|
||||
print("\nStopped.", flush=True)
|
||||
finally:
|
||||
midiin.close_port()
|
||||
midiout.close_port()
|
||||
del midiin
|
||||
del midiout
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# Reliable MIDI bring-up for shows/midi.qxw
|
||||
#
|
||||
# Order matters:
|
||||
# 1) pad present (Bluetooth or USB)
|
||||
# 2) smoother (creates "SMC-PAD Smooth")
|
||||
# 3) patch workspace to that port
|
||||
# 4) open QLC+ last
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
PYTHON="${ROOT}/.venv/bin/python"
|
||||
[[ -x "$PYTHON" ]] || PYTHON=python3
|
||||
|
||||
pad_present() {
|
||||
aconnect -l 2>/dev/null | grep -Eq "SMC-PAD Bluetooth|SINCO|SMC-PAD"
|
||||
}
|
||||
|
||||
echo "Waiting for SMC-PAD (Bluetooth or USB)…"
|
||||
for _ in $(seq 1 30); do
|
||||
if pad_present; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if ! pad_present; then
|
||||
echo "No SMC-PAD in aconnect -l. Pair/connect the pad, then re-run." >&2
|
||||
aconnect -l >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restart smoother so it re-opens the pad port cleanly (avoid pkill -f; it matches this script)
|
||||
while read -r pid; do
|
||||
[[ -n "$pid" ]] && kill "$pid" 2>/dev/null || true
|
||||
done < <(ps -eo pid,args | awk '/[.]venv\/bin\/python .*smooth_smc_pad[.]py/ {print $1}')
|
||||
sleep 0.4
|
||||
nohup "$PYTHON" scripts/smooth_smc_pad.py --tau 0.055 >>/tmp/smooth_smc_pad.log 2>&1 &
|
||||
for _ in $(seq 1 20); do
|
||||
if aconnect -l 2>/dev/null | grep -q 'SMC-PAD Smooth'; then
|
||||
break
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
if ! aconnect -l 2>/dev/null | grep -q 'SMC-PAD Smooth'; then
|
||||
echo "Smoother failed to create SMC-PAD Smooth. See /tmp/smooth_smc_pad.log" >&2
|
||||
tail -20 /tmp/smooth_smc_pad.log >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 scripts/patch_smc_pad.py
|
||||
|
||||
kill "$(pgrep -x qlcplus)" 2>/dev/null || true
|
||||
sleep 0.5
|
||||
nohup qlcplus --open "$ROOT/shows/midi.qxw" >/tmp/qlcplus.log 2>&1 &
|
||||
sleep 1.5
|
||||
|
||||
echo
|
||||
echo "Chain (expect pad → Smooth → qlcplus):"
|
||||
aconnect -l | grep -E "SMC-PAD|SINCO|Smooth|qlcplus|smc-smooth" -A2 || aconnect -l
|
||||
echo
|
||||
echo "OK — twist a knob / hit a pad. If silent: re-run this script (don't pick Midi Through in IO)."
|
||||
Reference in new issue
Block a user