Give it a few music cues, each generated as one mood (elevenlabs-generate-music: a
calm intro, a tension cue, a chase that ends on a chord, a quiet ending), and the
film's timeline; get one score WAV with every change where the story turns, each cue
entering at full strength on a beat, and the music dipped under the spoken lines. The
cut is local and free, so re-fitting the score to a re-timed cut is a re-run, not a
new generation. To cut picture to a song the person brings, use python-map-song-bars
instead: there the song is the clock.
Inputs
- The cues, each converted to 48 kHz stereo 16-bit WAV before anything reads it:
exec("ffmpeg", ["-y", "-i", "audio/music/cues/chase_a.mp3", "-ar", "48000", "-ac", "2", "audio/music/cues/chase_a.wav"], cwd). - The timeline: where each section starts and ends on the film's clock, and the
story beat each change belongs to, as the person named it ("after the line, not
before", "a second before he grabs it"). Take them from the cut's spec or build
script, never from memory: when the cut is re-timed, every
atmoves with it. - The spoken lines' spans on the same clock, for the dips.
Run it
Write the three scripts in references/score_cues.md into the job's scripts/
unchanged (find_beats.py, cut_score.py, measure_levels.py).
-
Measure every cue. Give a BPM range around what the prompt asked for, or the autocorrelation can lock onto half or double the tempo:
exec("python", ["scripts/find_beats.py", "audio/music/cues/tension_a.wav", "--min-bpm", "100", "--max-bpm", "190"], cwd)Read
bpm,period,first_full_beatandrms_db_per_second. The level curve shows a fade-up the prompt forbade, a quiet stretch, and where a composed ending (the chord) starts. -
Write the plan (
audio/score/plan_a.json; the format is in the script's docstring), one entry per cue:piecesstart on a beat: the first full-strength beat for an entry that must start in earnest, or a later beat chosen by working back from a chord (below).- To fill a section longer than the cue, add a second piece that jumps back a whole
number of beats (
[[1.255, 10.855], [7.255, 13.255]]at a 0.4 s period: 24 beats, then back 9 beats for 15 more). Giveperiodand the script warns about a piece that isn't whole beats. - A hard cut:
fade_outof 0.03 to 0.06 s, then silence, then the next entry. gain_dbper cue to set the ladder of levels;liftfor a cue generated quieter at its start than the rest.dipsunder every spoken line.
-
Cut it and check the levels at every section, silence and dip:
exec("python", ["scripts/cut_score.py", "audio/score/plan_a.json"], cwd) exec("python", ["scripts/measure_levels.py", "audio/score/score_a.wav", "0:3", "3:11", "11.1:12.9", "13:28.6", "28.65:29.05", "29.1:43", "43:46"], cwd) -
Lay it in the cut's spec as one audio track (
hn4a-compositor) and normalize the finished mix once (ffmpeg-normalize-loudness).
Placing the changes
- A change goes on the story beat the person names, and after a spoken line rather than under it: the turn placed under the announcer's line came back with a note to move it after the line.
- Silence before a hit. End the cue before with a 0.06 s fade, leave a gap, then enter on a beat at full strength. On the worked score the alarm played alone in 1.8 s of silence (11.1–12.9 s, measured digital silence), and 0.45 s of silence sat before the chase (28.6–29.075 s).
- Enter on the first full-strength beat, never on the cue's own start: a cue
trimmed with
silenceremovestill faded up over its first second, and the note was that it should simply start, not fade up. Cutting in at the measured first full beat (1.255 s on a 150 BPM tension cue) fixed it. - End on a resolving chord on the picture cut. A chase that just stopped drew a
note that the music should resolve, not die off. Generate the chase with a final
plan section that is one sustained major chord on its first beat
(
elevenlabs-generate-music), then work back from it: if the chord is at 18.0 s in the cue and the picture cut is at 43.0 s, a cue entering at 29.075 s starts from 18.0 − (43.0 − 29.075) = 4.075 s in the cue, which must be a beat. Move the entry by whole beats until both the entry and the chord land. - Nudge with
tempoonly for under about 1.5%.atempo0.9931 and 0.9846 were inaudible on the tension and chase cues; past 3% the script warns, and moving the entry by a beat is better. - Dip under every spoken line, by 6 to 7 dB, 0.25 s down and 0.4 s back up. On the worked score a line's span measured −20.3 dBFS against −14.8 around it.
What you get
One 48 kHz stereo WAV of exactly length seconds, limited at 0.95, plus a printout of
where each cue plays. The plan JSON is the score's source: keep it with the job's notes
and change it (never the WAV) when the cut moves.
Tips and traps
- A cue asked for "full intensity from the very first beat, no fade-in" may still
fade up. The tension cue reached full level at 0.99 s; a chase generated from a
plan sat at about −20 dBFS for its first 10 s, then −12.5. Measure every cue;
liftthe quiet start (+7 dB for 6.2 s, ramped back over 0.6 s) or enter later. - The worked ladder of levels (section RMS on the finished score): intro −18 dBFS (its cue was loud, so −7 dB), alarm alone in silence, tension −14.6, chase −12.5, chord −15.0, quiet ending −19.0. The score then sat at 0.55 in the cut's spec under voices at 1.0.
- Re-timing the cut moves every
at: shifting the score 2 s later for a held shot was an edit to four numbers and a re-run. - Cues generated together drift in key and tempo (150, 169 and 187.5 BPM on the worked score): hard cuts with silence between hide it, crossfades expose it.
Check it
measure_levels.pyover every section, every gap (a silence reads −180 dBFS) and every dip, against the plan.- Listen to each entry and each join with the picture: on the beat, no click, no fade-up, and the chord on the cut.
- Then put the score under the picture to the person (
review_chooseagainst the previous score); the music is their pick.
Worked example
A 61 s silent-action short with voiceover lines (a calm morning, an alarm, a chase, an escape into quiet), four cues for about $0.25 after three single-bed attempts:
| Cue | Source | Tempo | Placed |
|---|---|---|---|
| Intro | cue_intro_a, 14 s from a one-section plan | 82 BPM | 0.3–13.3 s of the cue at 0 s, −7 dB, 0.4 s fade |
| Tension | cue_tension_a, 20 s prompt cue | 150 BPM, period 0.4 s | 1.255–10.855 then 7.255–13.255 at 15.0 s, 0.03 s fade |
| Chase | cue_chase_resolve_a, 24 s plan: 18 s run, 6 s chord | 169 BPM | from 4.075 s at 31.075 s, +7 dB lift for 6.2 s, chord on the 45.0 s cut |
| Ending | cue_outside_c, 18 s prompt cue | — | first 9 s at 53.0 s, 0.4 s in, 0.8 s out |
Dips of 6 to 7 dB under three lines. The person's notes on the first edited score (cuts on beats, the change after the line, a real start after the silence) and on the first cut (the chase a second before he grabs it, from nothing; a resolution) were each a change to the plan and a re-run.


