Files
nvrl ac01baf9d4
CI / sigil-model (fmt + clippy + test) (push) Failing after 53s
CI / engine + launcher (clippy + build) (push) Failing after 19s
CI / windows cross-build (x86_64-pc-windows-gnu) (push) Failing after 20s
Let the Sigil Tunnel take the sigil's energy through a build
With `--mode sigil --under sigil-tunnel` (the energy look) the sigil
dims to half its glow as a build's tension rises and flares on the
drop's release, while the tunnel brightens, opens up and speeds toward
the drop. The rings widen with tension, cancelling the figure's own
build contraction, a gap pulls them in toward the axis and the release
throws them back out.
2026-11-12 01:11:26 +01:00

298 lines
17 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# sigil
An audio-reactive visual engine. Feed it a track (or a live input) and it
renders a dark, volumetric, GPU-raymarched response that's driven by the
music's structure — onsets, tempo, timbre, harmony — not just its loudness.
Seven visualisers ship today:
- **`sigil`** — a partitioned SDF capsule field: a strange-attractor /
torus-knot backbone grown with spectral ribs, transient debris and harmonic
spokes, raymarched as volumetric glow over black with in-shader chromatic
aberration and ping-pong phosphor feedback.
- **`sigil-tunnel` — Sigil Tunnel**: fly down a corridor of rings, each one
the live sigil figure (backbone, ribs, debris, spokes) in sigil's neon glow
and colours, twisted ring to ring. Forward motion surges in drops and slows
smoothly into gaps. Made to sit behind sigil (`--under sigil-tunnel`).
- **`tunnel`** — a light tunnel you fly down on the beat: a neon ring passes
on every beat and the downbeat ring glows in the accent colour; kicks send
waves of light racing away, hats run packets down the corner rails, a gap
blacks the rings out. Sections change the speed (½, 1 or 2 rings a beat)
and the shape (square, diamond, hexagon, circle…; pick with `--lattice`).
- **`field`** — smoke: coloured smoke rising through the dark. Two plumes
breathe with the bass line, kicks and downbeats blow puffs that curl away,
hats throw embers, the stop before a drop leaves the smoke hanging. A small
smoke simulation (curl-noise advection in the feedback loop), no raymarch.
- **`ophanim`** — three gold rings on gimbals, covered in eyes that open on
the kicks, mids and hats, around a glowing core with six feathered wings and
light shafts. A drop opens every eye, a breakdown folds the wings. Made for
angelcore, and clean as a transparent editor element.
- **`ferro`** — a chrome ferrofluid drop, and the bass is its magnetic field:
every "womb" of a wobble raises its spikes, kicks crown it in step with the
bar, the stop before a drop melts it flat and the drop lands as a burst.
Made for dubstep and riddim; `--bass-style` (riddim, tearout, deathstep,
melodic, …) sets its character, or it picks one from the track.
- **`elastic` — Elastic Matter**: pearlescent membranes curl, stretch and
inflate with the bass. Strikes split the sheets and throw persistent
droplets outward; springs draw them back into the material. Gaps suspend
physical time, builds inflate a cutaway bubble, and later drops expand the
folds into architecture. Reflected softbox lights and thin-film colour
interference replace emissive linework.
Bass music gets its own analysis: the engine tracks the bass line's envelope,
the wobble's filter (growl), the wobble rate, drops, gaps and the position in
the bar, because in a drop the loudness sits flat at its ceiling. Every
graph mode can ride these as modulation sources; the **Riddim** modulation
preset wires them into sigil, tunnel, ophanim and ferro.
Run live (real-time, reacts to a feed or file playback) or render offline
(every frame at a fixed fps with no frame budget, streamed straight into
ffmpeg with the original audio muxed back in — mp4/H.264 by default, or
alpha-preserving WebM/ProRes).
`--transparent` renders a straight-alpha element for video editors: drop the
ProRes 4444 `.mov` (or VP9 `.webm`) on a timeline in normal blend mode and the
glow keeps its full colour over any footage. `--alpha-clip 0.05..0.2` drops
faint haze so the background is fully clear (useful for `tunnel`/`field`).
## Quickstart
```sh
# Build everything (LTO release).
cargo build --release
# Live visualiser (needs a GPU + display). Default mode is `sigil`.
cargo run --release --bin sigil -- song.flac
cargo run --release --bin sigil -- --mode tunnel song.flac
cargo run --release --bin sigil -- monitor # live system audio
# Your hands on it, live: a MIDI controller's knobs become the modulation
# sources ctl1..ctl8 (the first eight CCs you move, or --midi-cc 21,22,…),
# its pads the source `pad`; OSC works too (/sigil/ctl/1..8 <0..1>,
# /sigil/pad). Route them in the matrix / node editor (--routes).
cargo run --release --bin sigil -- --midi-ports
cargo run --release --bin sigil -- monitor --midi --osc 9000 --routes my.ron
# Aspect ratio: 16:9 (default), 9:16 (Reels/TikTok), 4:3, 1:1. Reshapes the
# quality preset's live + render sizes; explicit --live-w/--render-w still win.
cargo run --release --bin sigil -- --aspect 9:16 song.flac
# Syzy-inspired sigil + tunnel combination, with smooth camera banks.
cargo run --release --bin sigil -- --look energy "Take my energy! - Syzy.flac"
# Genre looks: one flag sets mode, form, gains, effects, modulation preset and
# palette (angelcore, ophanim, synthclub, jerseyclub, hoodtrap, mylancore,
# riddim, tearout, melodic). Explicit flags still win; --palette alone
# recolours any mode (auto, seraph, neon, club, ember, moon, toxic).
cargo run --release --bin sigil -- --look ophanim song.flac
cargo run --release --bin sigil -- --mode ferro --bass-style riddim song.flac
cargo run --release --bin sigil -- --mode tunnel --palette ember song.flac
# Your own colours on top of any palette: the music sweeps the hue from the
# first colour (bassy) to the second (bright); accent, highlight and
# background are optional, as are --saturation / --brightness. --bloom turns
# the glow halo down (0..1; the modes cap it near the 0.5 default).
cargo run --release --bin sigil -- --palette neon --hue-from '#ff3ea5' \
--hue-to '#7a5cff' --highlight '#ffffff' --bloom 0.3 song.flac
# Camera: a director cuts between shots (close-up, wide, low angle, orbit,
# tilted) on every phrase and section change; a build pushes in. Turn it off
# for the fixed front camera.
cargo run --release --bin sigil -- --mode ophanim --camera static song.flac
# Offline render (needs ffmpeg on PATH). Audio is muxed from the source.
# A render reads the song's form first (sections, repeats, drops; printed at
# the start), so cuts land on the exact bar, a build ramps up to the real
# drop and a repeated chorus gets the same shots. The preview does the same.
cargo run --release --bin sigil -- --render --out clip.mp4 song.flac
# Several modes in one video: smoke behind ferro, and sections that rotate
# through ophanim / ferro / tunnel (same-sounding sections get the same mode;
# drops cut, the rest dissolves). --scenes needs the song's form: render and
# preview only.
cargo run --release --bin sigil -- --render --mode ferro --under field --out clip.mp4 song.flac
cargo run --release --bin sigil -- --render --mode ophanim --scenes ferro,tunnel --out clip.mp4 song.flac
# Colours from the album cover (embedded art, or cover.jpg next to the track):
# (an optional value: put the track first, or it is read as the image)
cargo run --release --bin sigil -- --render song.flac --cover
# Highlight clip: only the best 30 s (or --clip 15) around the hardest drop,
# build first; written next to the track as <name>-highlight.mp4. Vertical:
cargo run --release --bin sigil -- --render --clip --render-w 1080 --render-h 1920 song.flac
# Your own song form: print the analysed one, edit it (move boundaries, change
# a section's kind / intensity / repeat letter, make a section show another
# mode), render with it. The launcher's Timeline does this for you.
cargo run --release --bin sigil -- --analyze --score-out song.flac > form.ron
cargo run --release --bin sigil -- --render --score form.ron song.flac
# Words: a title card (title and artist from the tags, or --title/--artist),
# synced lyrics (song.lrc next to the track, its lyrics tag, or
# --lyrics FILE.lrc) and kinetic type (the words punch on kicks during drops,
# the title slams in at each drop). Bold Noto Sans unless --font FILE.ttf.
# With --clip the card opens the clip. Live and in the preview the lyrics
# file is re-read when it changes (the launcher's lyric editor).
cargo run --release --bin sigil -- --render --card --lyrics --kinetic song.flac
# Captions (up to 4): your own text, placed (top, center, bottom, corners),
# sized, pulsing on kicks, shown always / between times / during, from or
# until a kind of section. The --text-* flags after a --text set that one.
# Lyrics and the card can move too (--lyrics-place, --card-place).
cargo run --release --bin sigil -- --render \
--text "{title}" --text-place top-left \
--text "AFTER THE DROP" --text-when from-drop --text-place bottom-right --text-pulse 1 \
--lyrics --lyrics-place top --glow-color "#ff2080" song.flac
# Motion blur: average N sub-frames per frame (render takes ~N× as long).
cargo run --release --bin sigil -- --render --motion-blur 6 --out clip.mp4 song.flac
# Windowless preview (what the launcher shows): plays the track and writes
# the render's frames, small, to stdout; play/pause/seek/args on stdin.
cargo run --release --bin sigil -- --preview --preview-h 540 song.flac
# Headless smoke test — no GPU/display/audio device, validates the
# analysis path only (and prints the song's form):
cargo run --bin sigil -- --analyze song.flac
# All flags:
cargo run --release --bin sigil -- --help
```
Live keys (in-memory only, nothing is persisted): `R` reseed · `M` cycle mode ·
`P` save PNG · `F` fullscreen · `H` HUD · `B` feedback · `G` overlay
(modulation matrix + backbone picker) · `S` save routes (.ron) ·
`1`–`0`/`[`/`]` tune expressive gains · `Esc` quit.
## Launcher
Prefer not to memorise flags? `sigil-gui` is a one-page studio: a rail of
sections (look, colours, shape, motion, effects, modulation, output,
settings), the section's editor, and a stage with a **preview** of the
render — play, pause and scrub the track while you tweak, and every change
shows up straight away — over a render bar with one big **Render video**
button (progress, cancel, open folder). A live window for mic or system
audio is one menu away. Pick a genre look, then refine it — your own
colours, saved looks and palettes, a dark or light theme. It remembers your
settings, finds the `sigil` and `ffmpeg` next to it, and spawns the engine.
```sh
cargo build --release # sigil (the engine)
cd sigil-gui && cargo run --release # the launcher
```
## Workspace layout
Four crates. `sigil-model`, `audio-visualizer` and `sigil-vocals` form the
root Cargo workspace; `sigil-gui` is a separate workspace with its own lockfile (the
engine is pinned to nannou 0.19, which would cap the launcher's egui at 0.30).
Both build into the root `target/`, so the launcher finds `sigil` next to it.
| Crate | Role |
|-------|------|
| **`sigil-model`** | serde-only shared data model: the audio→param modulation `Graph`/`Route`/`Source` tables, control nodes, the image-op chain + the screen-FX flag table. Dependency-light (no nannou/wgpu/cpal/symphonia), so both other crates link it. Single source of truth for anything shared between the engine and the launcher. |
| **`audio-visualizer`** | The engine: shared audio analysis + GPU visual pipeline, as a lib consumed by two bins — `audio-visualizer` (console band-meter probe) and `sigil` (visualiser/renderer). |
| **`sigil-vocals`** | Vocal isolation for the launcher's speech to text: an MDX-Net model (ONNX, run with ONNX Runtime loaded at run time) turns a mix into its vocal stem, WAV in, WAV out. A standalone program; links nothing else here. |
| **`sigil-gui`** | The eframe/egui launcher. Builds a `sigil` CLI invocation and spawns it as a subprocess; links `sigil-model` (not the engine). |
The engine is **CLI-driven and near-stateless** — the only file it reads is an
optional `--routes <file.ron>` modulation graph; the launcher owns all
persistence and passes every setting on argv. Because both sides depend on
`sigil-model`, the shared types are one definition: a mismatch is a compile
error, not silent runtime drift.
## Building & testing
```sh
cargo build # engine + model
cargo test # model + engine: graph guards, bass analysis,
# ferro physics, naga validation of every shader
cargo clippy --workspace
cargo fmt --all
(cd sigil-gui && cargo test) # launcher (own workspace)
```
The engine/launcher need their system deps (ALSA, X11/Wayland, GL) to compile
and a GPU to run live/render; `sigil --analyze <file>` is the GPU-free smoke
test for the audio path. CI builds both workspaces, lints with
`-D warnings`, runs the tests, and cross-builds the launcher for
Windows. See [`.github/workflows/ci.yml`](.github/workflows/ci.yml).
## Architecture
The deep dive lives in [`audio-visualizer/CLAUDE.md`](audio-visualizer/CLAUDE.md)
(the engine: audio pipeline, the `Visualizer` trait, the `ShaderPipeline` base,
the modulation graph, determinism guarantees) and [`CLAUDE.md`](CLAUDE.md) (the
workspace + shared-model contract). The central invariant worth knowing up
front: `Analyzer` is the *only* place the STFT/AGC/onset math lives, so the
live path and the offline render feed identical frames through it — `--render`
is bit-reproducible for a given input.
## Requirements
- Rust (edition 2024; a recent stable toolchain).
- A GPU + display for live/render (Vulkan/Metal/DX12 via wgpu).
- `ffmpeg` on `PATH` for `--render`.
- Linux build deps: `libasound2-dev libudev-dev pkg-config libxkbcommon-dev
libwayland-dev libxcursor-dev libxrandr-dev libxi-dev libx11-dev
libgl1-mesa-dev`.
### Take My Energy look
`--look energy` (the **Take My Energy** card in the launcher) layers an elastic
sigil over a Sigil Tunnel of its own rings (`--under sigil-tunnel`).
Cyan-to-violet colours and ice-white highlights follow the spectrum; the Riddim
modulation preset makes the foreground follow the bass line. Both layers draw
from the lissajous, supershape and knot forms; the tunnel's figure uses its
own seed, so it never mirrors the foreground. The title is the arc: through a
build the sigil dims to half its glow while the tunnel opens up, brightens
and speeds toward two rings a beat, as if it were taking the energy; a gap
draws the rings in, and the drop throws them out and flares both layers.
(Any `--mode sigil --under sigil-tunnel` gets this.) Short trails keep the syncopation readable; grain,
scanlines, freeze, strobe, slice glitch and swirl are off. All settings remain editable.
The local track analysis measures approximately 138 BPM, with major drops near
80 s and 231 s. The existing song-form analysis drives builds, gaps and drop
escalation during preview and rendering; this look also works on other tracks.
The director now banks and dollies smoothly between shots in every mode,
including entering and leaving an orbit, with faster moves in drops and slower
moves in quiet passages.
### Elastic Matter
Choose **Elastic Matter** in the launcher's Shape section, or run:
```sh
cargo run --release --bin sigil -- --mode elastic "Take my energy! - Syzy.flac"
```
This is a standalone visualizer with its own CPU simulation and GPU surface
renderer; it also works as a scene or background layer. `--low` controls bass
pressure, `--warp` fold depth, `--ca` iridescence, and `--drive` material
lighting. The material reacts directly to the shared audio analysis, with no
modulation matrix. Palette overrides, transparent export, song-form edits,
smooth camera direction and motion-blur rendering work as in the other modes.
Its physical gap suspension is independent of the optional screen Freeze effect.
Use `--camera static` for a fixed view and `--no-feedback` for clean surfaces
without afterimages. For detailed surfaces use `--march-cap 80`; the shader's
absolute ceiling is 80 iterations, plus 24 analytic droplet intersections.
### Sigil Tunnel
Choose **Sigil Tunnel** in Shape, or run:
```sh
cargo run --release --bin sigil -- --mode sigil-tunnel "Take my energy! - Syzy.flac"
```
Every ring is the sigil figure: the same generator, backbone picker
(`--backbone`), modulation graph, colours, glow and phosphor feedback as
sigil. The tunnel is the figure's memory: the nearest ring shows it now, each
ring further away half a beat earlier, so a morph, a kick or a spin ripples
away down the corridor. The flight is locked to the bar like the light
tunnel's: a ring passes on every beat (two in a drop, one every other beat in
quiet sections) and the accent ring on the downbeat; a build speeds up toward
the drop and a gap stalls it. The CPU spins and flattens the figure; the
shader places a ring every 1.6 units along a gently bending axis with a twist
per ring, keeps a hole open around the flight path and a dark eye at the
vanishing point, and fades rings out before they reach the lens (seen
end-on, near wires turn into flat bands). The trail is shorter than sigil's
and the swirl only turns, because every ring grows toward the camera each
frame. Rendering solves each ray's closest approach to every capsule
analytically (up to 14 rings × 48 segments per pixel, no raymarch); per-ring
bounds skip the rings a ray never comes near. `--camera static` fixes the
gaze while forward travel continues.