agentcut 0.2.26 → 0.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +177 -177
  2. package/dist/studio/agents/claude.js +3 -2
  3. package/dist/studio/agents/claude.js.map +1 -1
  4. package/dist/studio/chat.js +1 -1
  5. package/dist/studio/chat.js.map +1 -1
  6. package/dist/studio/cli.js +24 -24
  7. package/dist/studio/download.d.ts +24 -0
  8. package/dist/studio/download.js +234 -0
  9. package/dist/studio/download.js.map +1 -0
  10. package/dist/studio/host.js +8 -0
  11. package/dist/studio/host.js.map +1 -1
  12. package/dist/studio/housekeeping.d.ts +2 -2
  13. package/dist/studio/housekeeping.js +18 -17
  14. package/dist/studio/housekeeping.js.map +1 -1
  15. package/dist/studio/release-cursor.js +21 -21
  16. package/dist/studio/release-video.js +10 -10
  17. package/dist/studio/tools.js +7 -0
  18. package/dist/studio/tools.js.map +1 -1
  19. package/package.json +56 -56
  20. package/template/AGENTS.md +14 -14
  21. package/template/components/README.md +70 -70
  22. package/template/components/before-after/BeforeAfter.tsx +89 -89
  23. package/template/components/catalog.ts +107 -107
  24. package/template/components/cinematic/Device3D.tsx +324 -324
  25. package/template/components/cinematic/devices3d/display-model.ts +184 -184
  26. package/template/components/cinematic/devices3d/iphone-model.ts +643 -643
  27. package/template/components/cinematic/devices3d/macbook-model.ts +608 -608
  28. package/template/components/cinematic/devices3d/models.ts +657 -657
  29. package/template/components/cinematic/devices3d/runtime.ts +267 -267
  30. package/template/components/cinematic/math.ts +100 -100
  31. package/template/components/color/grade-effect.ts +650 -650
  32. package/template/components/color/grade.ts +512 -512
  33. package/template/components/color/looks.ts +154 -154
  34. package/template/components/countdown/Countdown.tsx +166 -166
  35. package/template/components/dot-trace-title/DotTraceTitle.tsx +181 -181
  36. package/template/components/dot-trace-title/meta.json +51 -51
  37. package/template/components/generate/GenerateReveal.tsx +381 -381
  38. package/template/components/hook-card/HookCard.tsx +554 -554
  39. package/template/components/index.ts +199 -199
  40. package/template/components/lib.ts +191 -191
  41. package/template/components/line-diagram/LineDiagram.tsx +205 -205
  42. package/template/components/line-diagram/meta.json +215 -215
  43. package/template/components/list-card/ListCard.tsx +104 -104
  44. package/template/components/live-clip.ts +75 -75
  45. package/template/components/looks.tsx +1447 -1447
  46. package/template/components/loops/LoopCanvas.tsx +132 -132
  47. package/template/components/loops/engine.ts +184 -184
  48. package/template/components/loops/library.ts +667 -667
  49. package/template/components/loops/library2.ts +777 -777
  50. package/template/components/motion-loop/MotionLoop.tsx +37 -37
  51. package/template/components/motion-loop/meta.json +311 -311
  52. package/template/components/props.ts +73 -73
  53. package/template/components/quote-card/QuoteCard.tsx +71 -71
  54. package/template/components/style-layer.tsx +233 -233
  55. package/template/components/styles.ts +113 -113
  56. package/template/components/types.ts +66 -66
  57. package/template/components/word-pop/WordPop.tsx +59 -59
  58. package/template/components/word-stack/WordStack.tsx +122 -122
  59. package/template/presets/charcoal-sketch/PROMPT.md +48 -48
  60. package/template/presets/charcoal-sketch/scripts/duck_music.py +34 -34
  61. package/template/presets/punk-cut-paper/scenes/Motif.tsx +376 -376
  62. package/template/presets/punk-cut-paper/scenes/Photo.tsx +73 -73
  63. package/template/presets/punk-cut-paper/scenes/Ransom.tsx +119 -119
  64. package/template/runtime/composition.tsx +1189 -1189
  65. package/template/runtime/helpers.tsx +230 -230
  66. package/template/runtime/index.tsx +22 -22
  67. package/template/runtime/types.ts +315 -315
  68. package/template/skill/SKILL.md +186 -187
  69. package/template/skill/references/broll.md +44 -44
  70. package/template/skill/references/browser-export.md +61 -61
  71. package/template/skill/references/cinematic.md +206 -206
  72. package/template/skill/references/color.md +79 -79
  73. package/template/skill/references/craft.md +97 -97
  74. package/template/skill/references/editing-styles.md +57 -57
  75. package/template/skill/references/feature-launch.md +34 -34
  76. package/template/skill/references/footage.md +72 -72
  77. package/template/skill/references/format.md +142 -142
  78. package/template/skill/references/how-to.md +146 -146
  79. package/template/skill/references/launch-direction.md +89 -89
  80. package/template/skill/references/loops.md +151 -151
  81. package/template/skill/references/mcp-external.md +19 -19
  82. package/template/skill/references/performance.md +93 -93
  83. package/template/skill/references/person-cutout.md +19 -19
  84. package/template/skill/references/presets.md +60 -60
  85. package/template/skill/references/product-launch.md +134 -134
  86. package/template/skill/references/release-capture.md +53 -53
  87. package/template/skill/references/sound.md +167 -166
  88. package/template/skill/references/style-spy.md +160 -160
  89. package/template/skill/references/website-howto.md +45 -45
  90. package/template/starter/.studio/chat.json +1 -1
  91. package/template/starter/layers.json +46 -46
  92. package/template/starter/notes.md +4 -4
  93. package/template/starter/project.json +13 -13
  94. package/template/starter/scenes/Title.tsx +38 -38
@@ -1,122 +1,122 @@
1
- import { AbsoluteFill, useCurrentFrame } from "remotion";
2
- import { FONTS, blurStyle, easeInOut, easeOutExpo, exitOut, fill, mix, ramp } from "../lib";
3
- import type { MotionBaseProps } from "../types";
4
-
5
- type Props = MotionBaseProps & {
6
- lead: string;
7
- words: string[];
8
- layout: string;
9
- color: string;
10
- accent: string;
11
- background: string;
12
- size: number;
13
- weight: string;
14
- font: string;
15
- };
16
-
17
- /**
18
- * "We help you / design / ship / grow": a fixed lead phrase beside a roller of words. The roller
19
- * snaps up one word at a time like a slot reel; the centered word is lit in the accent while its
20
- * neighbours shrink, fade and blur above and below it. It lands on the last word.
21
- */
22
- export function WordStack(props: Props) {
23
- const frame = useCurrentFrame();
24
- const { width, height, durationInFrames: d } = props;
25
- const vertical = height > width;
26
- const stacked = props.layout === "stacked" || vertical;
27
- const fontSize = (props.size / 100) * Math.min(width, height) * (vertical ? 1.05 : 1);
28
- const words = props.words.length ? props.words : [""];
29
- const enter = ramp(frame, 0, 24, easeOutExpo);
30
- const out = exitOut(frame, d, 12);
31
- const lineH = fontSize * 1.12;
32
-
33
- // Each word holds for an equal share; the roller snaps to the next one at the end of each share.
34
- const usable = Math.max(1, d - 18 - 18);
35
- const slot = usable / words.length;
36
- const snap = Math.min(16, slot * 0.7);
37
- let position = 0;
38
- for (let i = 1; i < words.length; i++) position += ramp(frame, 18 + i * slot - snap, snap, easeInOut);
39
- // The reel also rises into place on the way in.
40
- position -= (1 - enter) * 1.2;
41
-
42
- const text = {
43
- fontFamily: FONTS[props.font] ?? FONTS.sans,
44
- fontWeight: Number(props.weight) || 700,
45
- fontSize,
46
- lineHeight: 1.12,
47
- letterSpacing: "-0.03em",
48
- color: props.color,
49
- whiteSpace: "nowrap",
50
- } as const;
51
-
52
- return (
53
- <AbsoluteFill
54
- style={{
55
- background: fill(props.background),
56
- alignItems: "center",
57
- justifyContent: "center",
58
- opacity: out,
59
- overflow: "hidden",
60
- }}
61
- >
62
- <div
63
- style={{
64
- ...text,
65
- display: "flex",
66
- flexDirection: stacked ? "column" : "row",
67
- alignItems: "center",
68
- gap: stacked ? fontSize * 0.5 : fontSize * 0.32,
69
- }}
70
- >
71
- {props.lead ? (
72
- <span
73
- style={{
74
- display: "inline-block",
75
- opacity: enter,
76
- transform: `translateX(${stacked ? 0 : mix(-fontSize * 0.4, 0, enter)}px) translateY(${stacked ? mix(fontSize * 0.3, 0, enter) : 0}px)`,
77
- ...blurStyle((1 - enter) * fontSize * 0.06),
78
- }}
79
- >
80
- {props.lead}
81
- </span>
82
- ) : null}
83
- {/* Every word sits in the same grid cell, so the reel is as wide as the longest word. */}
84
- <span style={{ display: "inline-grid", height: lineH }}>
85
- {words.map((word, i) => {
86
- const offset = i - position;
87
- const away = Math.abs(offset);
88
- if (away > 2.6) return <span key={i} style={{ gridArea: "1 / 1", visibility: "hidden" }}>{word}</span>;
89
- const lit = Math.max(0, 1 - away);
90
- return (
91
- <span
92
- key={i}
93
- style={{
94
- gridArea: "1 / 1",
95
- justifySelf: stacked ? "center" : "start",
96
- transformOrigin: stacked ? "50% 50%" : "0% 50%",
97
- transform: `translateY(${offset * lineH * 0.92}px) scale(${1 - Math.min(1, away) * 0.22 - Math.max(0, away - 1) * 0.12})`,
98
- opacity: Math.max(0, 1 - away * 0.62) * enter,
99
- color: mixColor(props.color, props.accent, lit),
100
- ...blurStyle(Math.min(away, 2) * fontSize * 0.035),
101
- }}
102
- >
103
- {word}
104
- </span>
105
- );
106
- })}
107
- </span>
108
- </div>
109
- </AbsoluteFill>
110
- );
111
- }
112
-
113
- /** a→b between two hex colors (falls back to the nearer one for other color formats). */
114
- function mixColor(a: string, b: string, t: number) {
115
- const pa = /^#?([0-9a-f]{6})$/i.exec(a.trim());
116
- const pb = /^#?([0-9a-f]{6})$/i.exec(b.trim());
117
- if (!pa || !pb) return t > 0.5 ? b : a;
118
- const na = parseInt(pa[1], 16);
119
- const nb = parseInt(pb[1], 16);
120
- const ch = (s: number) => Math.round(mix((na >> s) & 255, (nb >> s) & 255, t));
121
- return `rgb(${ch(16)}, ${ch(8)}, ${ch(0)})`;
122
- }
1
+ import { AbsoluteFill, useCurrentFrame } from "remotion";
2
+ import { FONTS, blurStyle, easeInOut, easeOutExpo, exitOut, fill, mix, ramp } from "../lib";
3
+ import type { MotionBaseProps } from "../types";
4
+
5
+ type Props = MotionBaseProps & {
6
+ lead: string;
7
+ words: string[];
8
+ layout: string;
9
+ color: string;
10
+ accent: string;
11
+ background: string;
12
+ size: number;
13
+ weight: string;
14
+ font: string;
15
+ };
16
+
17
+ /**
18
+ * "We help you / design / ship / grow": a fixed lead phrase beside a roller of words. The roller
19
+ * snaps up one word at a time like a slot reel; the centered word is lit in the accent while its
20
+ * neighbours shrink, fade and blur above and below it. It lands on the last word.
21
+ */
22
+ export function WordStack(props: Props) {
23
+ const frame = useCurrentFrame();
24
+ const { width, height, durationInFrames: d } = props;
25
+ const vertical = height > width;
26
+ const stacked = props.layout === "stacked" || vertical;
27
+ const fontSize = (props.size / 100) * Math.min(width, height) * (vertical ? 1.05 : 1);
28
+ const words = props.words.length ? props.words : [""];
29
+ const enter = ramp(frame, 0, 24, easeOutExpo);
30
+ const out = exitOut(frame, d, 12);
31
+ const lineH = fontSize * 1.12;
32
+
33
+ // Each word holds for an equal share; the roller snaps to the next one at the end of each share.
34
+ const usable = Math.max(1, d - 18 - 18);
35
+ const slot = usable / words.length;
36
+ const snap = Math.min(16, slot * 0.7);
37
+ let position = 0;
38
+ for (let i = 1; i < words.length; i++) position += ramp(frame, 18 + i * slot - snap, snap, easeInOut);
39
+ // The reel also rises into place on the way in.
40
+ position -= (1 - enter) * 1.2;
41
+
42
+ const text = {
43
+ fontFamily: FONTS[props.font] ?? FONTS.sans,
44
+ fontWeight: Number(props.weight) || 700,
45
+ fontSize,
46
+ lineHeight: 1.12,
47
+ letterSpacing: "-0.03em",
48
+ color: props.color,
49
+ whiteSpace: "nowrap",
50
+ } as const;
51
+
52
+ return (
53
+ <AbsoluteFill
54
+ style={{
55
+ background: fill(props.background),
56
+ alignItems: "center",
57
+ justifyContent: "center",
58
+ opacity: out,
59
+ overflow: "hidden",
60
+ }}
61
+ >
62
+ <div
63
+ style={{
64
+ ...text,
65
+ display: "flex",
66
+ flexDirection: stacked ? "column" : "row",
67
+ alignItems: "center",
68
+ gap: stacked ? fontSize * 0.5 : fontSize * 0.32,
69
+ }}
70
+ >
71
+ {props.lead ? (
72
+ <span
73
+ style={{
74
+ display: "inline-block",
75
+ opacity: enter,
76
+ transform: `translateX(${stacked ? 0 : mix(-fontSize * 0.4, 0, enter)}px) translateY(${stacked ? mix(fontSize * 0.3, 0, enter) : 0}px)`,
77
+ ...blurStyle((1 - enter) * fontSize * 0.06),
78
+ }}
79
+ >
80
+ {props.lead}
81
+ </span>
82
+ ) : null}
83
+ {/* Every word sits in the same grid cell, so the reel is as wide as the longest word. */}
84
+ <span style={{ display: "inline-grid", height: lineH }}>
85
+ {words.map((word, i) => {
86
+ const offset = i - position;
87
+ const away = Math.abs(offset);
88
+ if (away > 2.6) return <span key={i} style={{ gridArea: "1 / 1", visibility: "hidden" }}>{word}</span>;
89
+ const lit = Math.max(0, 1 - away);
90
+ return (
91
+ <span
92
+ key={i}
93
+ style={{
94
+ gridArea: "1 / 1",
95
+ justifySelf: stacked ? "center" : "start",
96
+ transformOrigin: stacked ? "50% 50%" : "0% 50%",
97
+ transform: `translateY(${offset * lineH * 0.92}px) scale(${1 - Math.min(1, away) * 0.22 - Math.max(0, away - 1) * 0.12})`,
98
+ opacity: Math.max(0, 1 - away * 0.62) * enter,
99
+ color: mixColor(props.color, props.accent, lit),
100
+ ...blurStyle(Math.min(away, 2) * fontSize * 0.035),
101
+ }}
102
+ >
103
+ {word}
104
+ </span>
105
+ );
106
+ })}
107
+ </span>
108
+ </div>
109
+ </AbsoluteFill>
110
+ );
111
+ }
112
+
113
+ /** a→b between two hex colors (falls back to the nearer one for other color formats). */
114
+ function mixColor(a: string, b: string, t: number) {
115
+ const pa = /^#?([0-9a-f]{6})$/i.exec(a.trim());
116
+ const pb = /^#?([0-9a-f]{6})$/i.exec(b.trim());
117
+ if (!pa || !pb) return t > 0.5 ? b : a;
118
+ const na = parseInt(pa[1], 16);
119
+ const nb = parseInt(pb[1], 16);
120
+ const ch = (s: number) => Math.round(mix((na >> s) & 255, (nb >> s) & 255, t));
121
+ return `rgb(${ch(16)}, ${ch(8)}, ${ch(0)})`;
122
+ }
@@ -1,48 +1,48 @@
1
- # Preset: Charcoal Sketch (product explainer, one colour hero)
2
-
3
- The style gallery fills the [brackets] from its form and sends this to the agent. You can also paste it into a
4
- Agentcut chat yourself.
5
-
6
- ---
7
-
8
- Make a video in the **Charcoal Sketch preset**. Product / topic: [what it is, who it's for]. Story: [pains and how
9
- the product solves each one, or the beats you want]. Colour hero: [the mascot / logo / product images to keep in colour,
10
- e.g. `assets/mascot/*.png`]. Length: [~60 s]. Voice-over: [yes: Gemini Puck / no].
11
- Music: [new 80s synth-pop from Lyria / a file I give you]. End card: [name, tagline, URL].
12
-
13
- Start from the kit in `library/presets/charcoal-sketch/`: copy `scenes/Paper.tsx`, `scenes/Grain.tsx`,
14
- `scenes/lib/` (sketch.tsx, painfix.tsx) and `assets/paper/` into the new project, and the hero images into
15
- `assets/mascot/<pose>.png` (the `Mascot` component reads that path). `scenes/examples/` holds the scenes from the
16
- first video (Hook, pain/fix beats, EndCard) to copy and adapt into `scenes/`. Use `scripts/build_layers.example.py` as the
17
- timeline template (one cue sheet → layers.json) and `scripts/duck_music.py` to duck the music under the voice. Fonts in
18
- project.json: Cabin Sketch:400;700, Caveat:500;700, Patrick Hand:400, Outfit:700;800. Background #E9E6DF.
19
-
20
- The look, so it matches the first video:
21
- - **World:** everything is soft graphite / charcoal on off-white drawing paper: grey lines only, no colour at all.
22
- Lines are hand-wobbled with a faint charcoal halo, drawn on stroke by stroke, and re-drawn every 3 frames so they
23
- "boil" like rotoscoped pencil. Drawn elements animate on twos. Diagonal hatching for shading, soft charcoal smudges
24
- under objects, charcoal dust swapped on threes over everything, darker paper toward the edges.
25
- - **The only colour:** the hero (mascot / logo / product) in full colour, moving smoothly on ones with springs and a
26
- hatched pencil shadow under it. That contrast is the whole idea: sketch world, one real thing alive in it.
27
- - **Comic book:** thick sketched panel borders. The hook is a comic page with one panel per phrase, each with a caption
28
- box in Cabin Sketch. On the music's drop the hero jumps out and the page blows away.
29
- - **Pain → fix beats:** each beat is one big panel. The pain is a messy sketch with a hand-lettered question and a double
30
- underline, the hero peeking confused from a corner. On a bar line the hero dashes across the frame and erases it
31
- (eraser smear on the seam); the fix redraws neatly behind it with a lettered statement and a check mark, and the
32
- hero lands in a happy pose. Product UI is redrawn as clean sketches (calendar grids, panels, buttons, cards), not
33
- screenshots, with real labels and nothing the product can't do.
34
- - **Type:** Cabin Sketch for titles and captions, Caveat for handwriting, Patrick Hand for small UI labels. Text is
35
- written on left to right and jitters slightly on threes.
36
- - **End card:** one double-bordered panel, the hero waving with pencil rays, the name lettered huge in Cabin Sketch
37
- with an underline, the tagline in Caveat, the URL in a sketched box. Rays pulse on the final hit.
38
- - **Sound:** bright mid-80s synth-pop (drum machine, gated snare, synth bass, bouncy analog lead, about 150 BPM, no
39
- vocals). Scene changes and hero dashes land on bar lines. Real paper SFX: pencil scribble on every draw-on, paper
40
- swipe on each dash, taps for cards landing, rubber stamp / clicks where the UI does something. Music ducked under the
41
- voice (voice ≥ 6 LU above the music).
42
- - **Format:** [wide 1920×1080 / also mobile 1080×1920] (the kit's coordinates are drawn for 1920×1080; redesign the
43
- layouts for mobile, don't crop).
44
-
45
- Workflow: write the script first and generate the voice (check every take with a transcription), make the music and
46
- find its bar grid, show me the cue sheet in a few lines, then build beat by beat with captures. Write the cue sheet
47
- and the sound numbers in notes.md. Every scene, voice line and sound is its own clip so I can edit it on the timeline.
48
- Don't export until I ask.
1
+ # Preset: Charcoal Sketch (product explainer, one colour hero)
2
+
3
+ The style gallery fills the [brackets] from its form and sends this to the agent. You can also paste it into a
4
+ Agentcut chat yourself.
5
+
6
+ ---
7
+
8
+ Make a video in the **Charcoal Sketch preset**. Product / topic: [what it is, who it's for]. Story: [pains and how
9
+ the product solves each one, or the beats you want]. Colour hero: [the mascot / logo / product images to keep in colour,
10
+ e.g. `assets/mascot/*.png`]. Length: [~60 s]. Voice-over: [yes: Gemini Puck / no].
11
+ Music: [new 80s synth-pop from Lyria / a file I give you]. End card: [name, tagline, URL].
12
+
13
+ Start from the kit in `library/presets/charcoal-sketch/`: copy `scenes/Paper.tsx`, `scenes/Grain.tsx`,
14
+ `scenes/lib/` (sketch.tsx, painfix.tsx) and `assets/paper/` into the new project, and the hero images into
15
+ `assets/mascot/<pose>.png` (the `Mascot` component reads that path). `scenes/examples/` holds the scenes from the
16
+ first video (Hook, pain/fix beats, EndCard) to copy and adapt into `scenes/`. Use `scripts/build_layers.example.py` as the
17
+ timeline template (one cue sheet → layers.json) and `scripts/duck_music.py` to duck the music under the voice. Fonts in
18
+ project.json: Cabin Sketch:400;700, Caveat:500;700, Patrick Hand:400, Outfit:700;800. Background #E9E6DF.
19
+
20
+ The look, so it matches the first video:
21
+ - **World:** everything is soft graphite / charcoal on off-white drawing paper: grey lines only, no colour at all.
22
+ Lines are hand-wobbled with a faint charcoal halo, drawn on stroke by stroke, and re-drawn every 3 frames so they
23
+ "boil" like rotoscoped pencil. Drawn elements animate on twos. Diagonal hatching for shading, soft charcoal smudges
24
+ under objects, charcoal dust swapped on threes over everything, darker paper toward the edges.
25
+ - **The only colour:** the hero (mascot / logo / product) in full colour, moving smoothly on ones with springs and a
26
+ hatched pencil shadow under it. That contrast is the whole idea: sketch world, one real thing alive in it.
27
+ - **Comic book:** thick sketched panel borders. The hook is a comic page with one panel per phrase, each with a caption
28
+ box in Cabin Sketch. On the music's drop the hero jumps out and the page blows away.
29
+ - **Pain → fix beats:** each beat is one big panel. The pain is a messy sketch with a hand-lettered question and a double
30
+ underline, the hero peeking confused from a corner. On a bar line the hero dashes across the frame and erases it
31
+ (eraser smear on the seam); the fix redraws neatly behind it with a lettered statement and a check mark, and the
32
+ hero lands in a happy pose. Product UI is redrawn as clean sketches (calendar grids, panels, buttons, cards), not
33
+ screenshots, with real labels and nothing the product can't do.
34
+ - **Type:** Cabin Sketch for titles and captions, Caveat for handwriting, Patrick Hand for small UI labels. Text is
35
+ written on left to right and jitters slightly on threes.
36
+ - **End card:** one double-bordered panel, the hero waving with pencil rays, the name lettered huge in Cabin Sketch
37
+ with an underline, the tagline in Caveat, the URL in a sketched box. Rays pulse on the final hit.
38
+ - **Sound:** bright mid-80s synth-pop (drum machine, gated snare, synth bass, bouncy analog lead, about 150 BPM, no
39
+ vocals). Scene changes and hero dashes land on bar lines. Real paper SFX: pencil scribble on every draw-on, paper
40
+ swipe on each dash, taps for cards landing, rubber stamp / clicks where the UI does something. Music ducked under the
41
+ voice (voice ≥ 6 LU above the music).
42
+ - **Format:** [wide 1920×1080 / also mobile 1080×1920] (the kit's coordinates are drawn for 1920×1080; redesign the
43
+ layouts for mobile, don't crop).
44
+
45
+ Workflow: write the script first and generate the voice (check every take with a transcription), make the music and
46
+ find its bar grid, show me the cue sheet in a few lines, then build beat by beat with captures. Write the cue sheet
47
+ and the sound numbers in notes.md. Every scene, voice line and sound is its own clip so I can edit it on the timeline.
48
+ Don't export until I ask.
@@ -1,34 +1,34 @@
1
- """Duck the score under the voice-over. python scripts/duck_music.py assets/music/<new-name>.wav
2
- Reads the voice clips from layers.json, finds speech in each take (energy gate), lowers the Lyria take by DUCK dB
3
- there (150 ms attack, 400 ms release). Use a new output name on every rerun (the listen tools cache by path),
4
- then point MUSIC in build_layers.py at it and rebuild."""
5
- import json, sys
6
- import numpy as np, soundfile as sf, librosa
7
-
8
- DUCK = -14.0; ATT = 0.15; REL = 0.40; FPS = 30
9
- SRC = "assets/music/synthpop-sketch-take1.mp3"
10
- OUT = sys.argv[1]
11
- layers = json.load(open("layers.json", encoding="utf-8"))
12
- voice = next(t for t in layers["tracks"] if t["id"] == "voice")["clips"]
13
- y, sr = librosa.load(SRC, sr=44100, mono=False)
14
- y = y.T # (n, 2)
15
- mask = np.zeros(len(y))
16
- for v in voice:
17
- x, vsr = sf.read(v["src"]); x = x if x.ndim == 1 else x.mean(1)
18
- w = int(0.02 * vsr)
19
- e = np.array([np.sqrt((x[k:k + w] ** 2).mean()) for k in range(0, len(x) - w, w)])
20
- db = 20 * np.log10(e + 1e-9)
21
- on = np.where(db > db.max() - 32)[0]
22
- if not len(on):
23
- continue
24
- s = v["from"] / FPS + on[0] * 0.02; t = v["from"] / FPS + (on[-1] + 1) * 0.02
25
- mask[int(s * sr):int(t * sr)] = 1
26
- g = np.zeros(len(y)); a = int(ATT * sr); r = int(REL * sr)
27
- idx = np.where(np.diff(np.r_[0, mask, 0]))[0].reshape(-1, 2)
28
- for s, t in idx:
29
- g[max(0, s - a):s] = np.maximum(g[max(0, s - a):s], np.linspace(0, 1, s - max(0, s - a)))
30
- g[s:t] = 1
31
- e = min(len(y), t + r); g[t:e] = np.maximum(g[t:e], np.linspace(1, 0, e - t))
32
- gain = 10 ** (DUCK * g / 20)
33
- sf.write(OUT, y * gain[:, None], sr, subtype="PCM_24")
34
- print("ducked spans (s):", [(round(s / sr, 2), round(t / sr, 2)) for s, t in idx])
1
+ """Duck the score under the voice-over. python scripts/duck_music.py assets/music/<new-name>.wav
2
+ Reads the voice clips from layers.json, finds speech in each take (energy gate), lowers the Lyria take by DUCK dB
3
+ there (150 ms attack, 400 ms release). Use a new output name on every rerun (the listen tools cache by path),
4
+ then point MUSIC in build_layers.py at it and rebuild."""
5
+ import json, sys
6
+ import numpy as np, soundfile as sf, librosa
7
+
8
+ DUCK = -14.0; ATT = 0.15; REL = 0.40; FPS = 30
9
+ SRC = "assets/music/synthpop-sketch-take1.mp3"
10
+ OUT = sys.argv[1]
11
+ layers = json.load(open("layers.json", encoding="utf-8"))
12
+ voice = next(t for t in layers["tracks"] if t["id"] == "voice")["clips"]
13
+ y, sr = librosa.load(SRC, sr=44100, mono=False)
14
+ y = y.T # (n, 2)
15
+ mask = np.zeros(len(y))
16
+ for v in voice:
17
+ x, vsr = sf.read(v["src"]); x = x if x.ndim == 1 else x.mean(1)
18
+ w = int(0.02 * vsr)
19
+ e = np.array([np.sqrt((x[k:k + w] ** 2).mean()) for k in range(0, len(x) - w, w)])
20
+ db = 20 * np.log10(e + 1e-9)
21
+ on = np.where(db > db.max() - 32)[0]
22
+ if not len(on):
23
+ continue
24
+ s = v["from"] / FPS + on[0] * 0.02; t = v["from"] / FPS + (on[-1] + 1) * 0.02
25
+ mask[int(s * sr):int(t * sr)] = 1
26
+ g = np.zeros(len(y)); a = int(ATT * sr); r = int(REL * sr)
27
+ idx = np.where(np.diff(np.r_[0, mask, 0]))[0].reshape(-1, 2)
28
+ for s, t in idx:
29
+ g[max(0, s - a):s] = np.maximum(g[max(0, s - a):s], np.linspace(0, 1, s - max(0, s - a)))
30
+ g[s:t] = 1
31
+ e = min(len(y), t + r); g[t:e] = np.maximum(g[t:e], np.linspace(1, 0, e - t))
32
+ gain = 10 ** (DUCK * g / 20)
33
+ sf.write(OUT, y * gain[:, None], sr, subtype="PCM_24")
34
+ print("ducked spans (s):", [(round(s / sr, 2), round(t / sr, 2)) for s, t in idx])