#!/bin/sh
# Run Resonant Garden. Needs an unlocked screen (ChuGL opens a window) and,
# for the LIVE experience, a microphone / audio input (live piano).
#
#   ./run.sh                 # live mic — the real piece (play to wake the garden)
#   ./run.sh keys            # live MIDI keyboard — play a digital piano in real time (keys=N picks the input port)
#   ./run.sh midi            # play the bundled MIDI piece (data/demo.mid) — no mic needed
#   ./run.sh midi=song.mid   # play your own .mid (path relative to the project, or absolute)
#   ./run.sh preview         # auto-ripples + forced warm scene, no mic needed
#   ./run.sh full            # fullscreen, for the demo recording
#   ./run.sh capture         # render one frame to /tmp/garden_frame.png, then quit
#   ./run.sh midi full       # flags combine (e.g. MIDI demo, fullscreen)
cd "$(dirname "$0")"
CHUCK="$HOME/projects/ccrma-workshop/chuck/src/chuck"
[ -x "$CHUCK" ] || CHUCK="chuck"            # fall back to chuck on PATH
CHUGIN="$HOME/.chuck/lib/ChuGL.chug"

# ChucK takes script arguments as main.ck:arg1:arg2 (colon-separated), not as shell args.
ARGS=""
for a in "$@"; do ARGS="$ARGS:$a"; done

"$CHUCK" --chugin:"$CHUGIN" "main.ck$ARGS"
# (Your `chuck` alias already loads ChuGL, so `chuck main.ck:preview` also works.)
