Sync: the visual playhead now advances on a latency-compensated clock (currentTime − outputLatency||baseLatency) so the on-screen pulse lands when the click is HEARD, not when it's queued — previously the visual could lead the audio by the output buffer / Bluetooth latency (up to ~a subdivision). Applied to editor, player, teacher, and the new pages; also bound the visual queue (vq trim). No data races: single-threaded; only the rAF draw touches vqPtr/currentStep, and each vq entry carries the exact scheduled time of its sound. stage.html — foot-pedal stompbox: two heavy footswitches (Tap=tempo / hold=start- stop, Next=item / hold=prev), 1/4" expression-pedal input → tempo sweep, big floor-readable RGB beat light + angled TFT, analog instrument pass-through. showcase.html — pyramid display piece: an RGB-light pendulum easing to each beat plus per-lane segment rows showing subdivisions/accents/mutes (canvas). Both: dual USB-C (data+power and power-thru) to daisy-chain off one source. Wired into embed.js (stage, showcase variants), build.sh, deploy.sh, the concepts gallery + landing cards, info-stage.html (~$52) + info-showcase.html (~$39) with BOMs, and the README. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
3.2 KiB
Bash
Executable file
66 lines
3.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Deploy the metronome to the Caddy web root that serves
|
|
# https://metronome.varasys.io
|
|
#
|
|
# Caddy config: /var/lib/caddy/Caddyfile (metronome.varasys.io:8443 block)
|
|
# Bind-mount: /etc/containers/systemd/caddy.container
|
|
#
|
|
# The web root is bind-mounted read-only into the Caddy container and
|
|
# served by file_server, which picks up changes immediately — so a plain
|
|
# file copy is all that's needed (no container restart).
|
|
set -euo pipefail
|
|
|
|
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
DEST_DIR="/var/lib/caddy/www/metronome"
|
|
DIST_DIR="$SRC_DIR/dist"
|
|
|
|
[[ -f "$SRC_DIR/index.html" ]] || { echo "error: $SRC_DIR/index.html not found" >&2; exit 1; }
|
|
[[ -d "$DEST_DIR" ]] || { echo "error: web root $DEST_DIR is missing — is Caddy set up?" >&2; exit 1; }
|
|
|
|
# Assemble the self-contained pages (inlines assets/ into dist/). dist/ is git-ignored.
|
|
"$SRC_DIR/build.sh"
|
|
[[ -f "$DIST_DIR/index.html" ]] || { echo "error: build did not produce $DIST_DIR/index.html" >&2; exit 1; }
|
|
|
|
# --- compute build version ---------------------------------------------------
|
|
# Formal build: clean tree on a commit tagged v<VERSION> -> "X.Y.Z"
|
|
# Dev build: anything else -> "X.Y.Z-dev.<utc-ts>.<sha>[.dirty]"
|
|
VER="$(cat "$SRC_DIR/VERSION" 2>/dev/null || echo 0.0.0)"
|
|
cd "$SRC_DIR"
|
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)"
|
|
dirty=""; [[ -n "$(git status --porcelain 2>/dev/null)" ]] && dirty=".dirty"
|
|
if [[ "$tag" == "v$VER" && -z "$dirty" ]]; then
|
|
BUILD="$VER" # formal release
|
|
else
|
|
BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ).g$(git rev-parse --short HEAD 2>/dev/null || echo nogit)$dirty"
|
|
fi
|
|
else
|
|
BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ)" # not a git checkout
|
|
fi
|
|
|
|
# stamp the version into the built copy only (source stays clean)
|
|
echo "deployed v$BUILD -> $DEST_DIR"
|
|
for f in index.html editor.html player.html teacher.html stage.html micro.html showcase.html \
|
|
concepts.html embed.html \
|
|
info-editor.html info-initial.html info-teacher.html info-stage.html info-micro.html info-showcase.html; do
|
|
sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$DIST_DIR/$f" > "$DEST_DIR/$f"
|
|
echo " $f ($(stat -c '%s' "$DEST_DIR/$f") bytes)"
|
|
done
|
|
cp "$DIST_DIR/embed.js" "$DEST_DIR/embed.js"; echo " embed.js ($(stat -c '%s' "$DEST_DIR/embed.js") bytes)"
|
|
rm -f "$DEST_DIR/player-asbuilt.html" # renamed to teacher.html
|
|
# (stage.html / info-stage.html are deployed again — now the foot-pedal Stage stompbox)
|
|
|
|
# If real audio samples are added later (see the plan's GM-sample note),
|
|
# sync that directory too.
|
|
if [[ -d "$SRC_DIR/samples" ]]; then
|
|
rsync -a --delete "$SRC_DIR/samples/" "$DEST_DIR/samples/"
|
|
echo "synced samples/ -> $DEST_DIR/samples"
|
|
fi
|
|
|
|
# Smoke test: Caddy serves on :8443 with tls internal; resolve the host
|
|
# to localhost so SNI matches the site block.
|
|
if command -v curl >/dev/null 2>&1; then
|
|
code=$(curl -sk --resolve metronome.varasys.io:8443:127.0.0.1 \
|
|
https://metronome.varasys.io:8443/ -o /dev/null -w '%{http_code}' || echo "??")
|
|
echo "smoke test: metronome.varasys.io -> HTTP $code"
|
|
fi
|