Log in
TechniqueBy HypernaturalVersion 1, updated

Cut a score from cues

hn/python-cut-score-from-cues

Score a short film from separate generated music cues instead of one bed: measure each cue's tempo, beat grid and first full-strength beat, then cut them together in one ffmpeg pass so every entry starts in earnest on a beat (no fade-up), a cue loops by whole beats to fill its section, a half second of silence sits before a hit, a section ends on a composed resolving chord placed on the picture cut, and the music dips under spoken lines. Use when the music must turn hard at a story beat (an alarm, a chase, an escape), when a single bed's 'dramatic turn' came out as a fade or as noise, or to re-fit a score to a changed timeline without generating again.

SKILL.md

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 at moves 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).

  1. 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_beat and rms_db_per_second. The level curve shows a fade-up the prompt forbade, a quiet stretch, and where a composed ending (the chord) starts.

  2. Write the plan (audio/score/plan_a.json; the format is in the script's docstring), one entry per cue:

    • pieces start 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). Give period and the script warns about a piece that isn't whole beats.
    • A hard cut: fade_out of 0.03 to 0.06 s, then silence, then the next entry.
    • gain_db per cue to set the ladder of levels; lift for a cue generated quieter at its start than the rest.
    • dips under every spoken line.
  3. 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)
    
  4. 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 silenceremove still 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 tempo only for under about 1.5%. atempo 0.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; lift the 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.py over 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_choose against 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:

CueSourceTempoPlaced
Introcue_intro_a, 14 s from a one-section plan82 BPM0.3–13.3 s of the cue at 0 s, −7 dB, 0.4 s fade
Tensioncue_tension_a, 20 s prompt cue150 BPM, period 0.4 s1.255–10.855 then 7.255–13.255 at 15.0 s, 0.03 s fade
Chasecue_chase_resolve_a, 24 s plan: 18 s run, 6 s chord169 BPMfrom 4.075 s at 31.075 s, +7 dB lift for 6.2 s, chord on the 45.0 s cut
Endingcue_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.

FAQs

Score a short film from separate generated music cues instead of one bed: measure each cue's tempo, beat grid and first full-strength beat, then cut them together in one ffmpeg pass so every entry starts in earnest on a beat (no fade-up), a cue loops by whole beats to fill its section, a half second of silence sits before a hit, a section ends on a composed resolving chord placed on the picture cut, and the music dips under spoken lines. Use when the music must turn hard at a story beat (an alarm, a chase, an escape), when a single bed's 'dramatic turn' came out as a fade or as noise, or to re-fit a score to a changed timeline without generating again.

Install Hypernatural Desktop, a free Mac app, and connect it to Claude Code, Codex or Claude Desktop. Then describe the video you want and your agent finds the skill itself, or paste this page's link (https://hypernatural.ai/skill/hn/python-cut-score-from-cues) and it installs hn/python-cut-score-from-cues and follows it.

Nothing. The skill is free and runs with tools on your own Mac, like python and ffmpeg.

Yes. Ask your agent to adjust it for your job, or to save its own version. You can publish your version under your own handle so anyone can install it.

Go make something cool.

Install the app, open your agent, describe the video. That's the whole onboarding.

Sticker HypernaturalSticker BannerSticker TVBoy