Give it a WAV and where the waveform goes; get compositor layers that draw that file's
own waveform, so what the viewer sees is what they hear. The spec format and the
commands are hn4a-compositor's.
Inputs
- The sound as a 16-bit WAV (
ffmpeg -i x.m4a -c:a pcm_s16le x.wav), the same span the spec plays in itsaudio. - Where it sits: a box for still bars, or a row (
y,h) and a playheadxfor an audiogram.
Run it
Write references/waveform.md's module into the job's scripts/ as waveform.py
and call it from the build script beside it:
| Use | Call | Then |
|---|---|---|
| A sound shown on screen | bars(envelope(wav, n), w, h) as a path layer's paths | "in": {"fx": "draw"}, and a marker at the first bar over 0.5 (its peak) |
| Ambience | the same bars | revealed left to right (revealFrom: "left", an anim.reveal over 2.5 s) |
| An audiogram, or a running band | audiogram(id, wav, start, dur, y, h, x=) | the bite in the spec's audio from start |
exec python scripts/build_audiogram.py
exec hn4a-compositor still clips/audiogram.json clips/a_1.0.png --at 1.0
exec hn4a-compositor render clips/audiogram.json
(cwd the job folder; references/waveform.md has the build script.)
What you get
envelope: n peak levels between two times, scaled so the loudest is 1.bars: one stroke per level, centred on the box's middle, at least 3 px each way so silence still reads as a line.audiogram: the waveform laid out atpx_per_s(400) and moved left at that speed, so the bar under the playhead is the moment playing; and the playhead. On a test bite, the bar beside the playhead was 234 of 240 px while the voice peaked and 12 px in the silences, matching the file's level at each moment.
Tips and traps
- The band enters from the playhead: at the clip's start the left half is empty.
Start the waveform a little earlier in a longer file (
t0) if it should be full. - A running band under every scene (a sound-themed piece): one long audiogram at low opacity, e.g. 9600 px wide at 0.22, a fixed 4 px playhead.
- A
drawentrance on a waveform showed it fully drawn by 0.2 s; judge the timing on a still.
Check it
- Stills at a loud and a silent moment: the bar by the playhead tall, then a line.
- The live spec, then the render (
hn4a-compositor, Live spec, then render); watch it with sound.


