Open source CapCut alternative.
TypeScript
feat(site): a sound can be raised past the level it came in at
David Le0e7d61d79fce
diff --git a/site/src/cut/components/AudioPanel.tools.ts b/site/src/cut/components/AudioPanel.tools.tsindex 5026426b..9d60594e 100644--- a/site/src/cut/components/AudioPanel.tools.ts+++ b/site/src/cut/components/AudioPanel.tools.ts@@ -42,7 +42,7 @@ export const AUDIO_TOOLS = [items: { type: "string" },description: "Project asset ids to match the sound of — an audio track to emulate, or video/images whose mood the score should carry. Append @seconds to match the passage around a pinned moment (\"<id>@62\")",},- volume: num("Bed volume 0..1.5 when placed (default 0.4 so it sits under speech)"),+ volume: num("Bed volume 0..3 when placed (default 0.4 so it sits under speech)"),add_to_timeline: bool("Place it on the soundtrack (default false — it stays on its chat card until the user asks)"),start: num("Timeline start in seconds (passing it implies add_to_timeline; default when placed: the playhead)"),}, ["prompt"]),diff --git a/site/src/cut/components/Inspector.tools.ts b/site/src/cut/components/Inspector.tools.tsindex cc71eb2a..13d7ec86 100644--- a/site/src/cut/components/Inspector.tools.ts+++ b/site/src/cut/components/Inspector.tools.ts@@ -156,10 +156,10 @@ export const INSPECTOR_TOOLS = [{name: "update_audio",description:- "Update a soundtrack clip: volume (0..1.5), fadeIn/fadeOut seconds, start position, in/out trim, speed, hidden, or duck. `duck` is voiceover ducking — while this clip plays, ALL other audio (video-clip sound and other music) drops to that gain (0..1); pass 1 to clear ducking. Use it to make a voiceover sit over quieter music.",+ "Update a soundtrack clip: volume (0..3), fadeIn/fadeOut seconds, start position, in/out trim, speed, hidden, or duck. `duck` is voiceover ducking — while this clip plays, ALL other audio (video-clip sound and other music) drops to that gain (0..1); pass 1 to clear ducking. Use it to make a voiceover sit over quieter music.",inputSchema: obj({id: str("Soundtrack clip id"),- volume: num("0..1.5"),+ volume: num("0..3 (1 = unchanged, above 1 boosts)"),fadeIn: num("Fade-in seconds"),fadeOut: num("Fade-out seconds"),start: num("Timeline start s"),@@ -173,7 +173,7 @@ export const INSPECTOR_TOOLS = [{name: "set_clip_volume",description: "Set the gain on a video clip's own audio (soundtrack clips use update_audio).",- inputSchema: obj({ clipId: str("Video clip id"), volume: num("0..1.5 (1 = unchanged)") }, ["clipId", "volume"]),+ inputSchema: obj({ clipId: str("Video clip id"), volume: num("0..3 (1 = unchanged, up to 3 boosts the clip's own sound)") }, ["clipId", "volume"]),},{name: "detach_audio",diff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsxindex 13c08d2c..a813ef26 100644--- a/site/src/cut/components/Inspector.tsx+++ b/site/src/cut/components/Inspector.tsx@@ -517,7 +517,7 @@ function ClipPanel({ clip, onColor }: { clip: VideoClip; onColor: () => void })valueClassName="w-9 text-muted-foreground"value={volume}min={0}- max={1.5}+ max={3}step={0.05}snap={[1]}format={formatPercent}@@ -758,7 +758,7 @@ function ClipGeneratedAudio({ clip }: { clip: VideoClip }) {valueClassName="w-9 text-muted-foreground"value={genVol}min={0}- max={1.5}+ max={3}step={0.05}snap={[1]}format={formatPercent}@@ -879,7 +879,7 @@ function AudioPanel({ clip }: { clip: AudioClip }) {valueClassName="w-9 text-muted-foreground"value={clip.volume}min={0}- max={1.5}+ max={3}step={0.05}snap={[1]}format={formatPercent}diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex 4db5b76f..07a9db16 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -1392,8 +1392,8 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {set_clip_volume: (s, input) => {const clip = requireItem(s.clips, input.clipId, "video clip");- if (!isNum(input.volume)) throw new ToolError("volume is required (0..1.5).");- const volume = clamp(input.volume, 0, 1.5);+ if (!isNum(input.volume)) throw new ToolError("volume is required (0..3).");+ const volume = clamp(input.volume, 0, 3);s.updateClip(clip.id, { volume: Math.abs(volume - 1) < 1e-4 ? undefined : volume });const next = useEditor.getState().clips.find((c) => c.id === clip.id)!;return { id: next.id, volume: next.volume ?? 1 };@@ -1891,7 +1891,7 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {const aSpeed = a.speed && a.speed > 0 ? a.speed : 1;const len = (a.out - a.in) / aSpeed;const patch: Partial<AudioClip> = {};- if (isNum(input.volume)) patch.volume = clamp(input.volume, 0, 1.5);+ if (isNum(input.volume)) patch.volume = clamp(input.volume, 0, 3);if (isNum(input.fadeIn)) patch.fadeIn = clamp(input.fadeIn, 0, len / 2);if (isNum(input.fadeOut)) patch.fadeOut = clamp(input.fadeOut, 0, len / 2);if (isNum(input.start)) patch.start = Math.max(0, input.start);@@ -2992,7 +2992,7 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {const start = isNum(input.start) ? Math.max(0, input.start) : playheadAt();cur.addAudioFromAsset(asset.id, start);// Sits under speech at a soft bed volume by default; the model can raise it.- const volume = isNum(input.volume) ? clamp(input.volume, 0, 1.5) : 0.4;+ const volume = isNum(input.volume) ? clamp(input.volume, 0, 3) : 0.4;const sel = useEditor.getState().selection;const clipId = sel?.kind === "audio" ? sel.id : null;if (clipId) useEditor.getState().updateAudio(clipId, { volume });diff --git a/site/src/cut/lib/previewMixer.ts b/site/src/cut/lib/previewMixer.tsindex 9f29f611..4756a5db 100644--- a/site/src/cut/lib/previewMixer.ts+++ b/site/src/cut/lib/previewMixer.ts@@ -537,7 +537,7 @@ export class PreviewMixer {}const live = this.voices.get(v.id) ?? this.open(v, t);if (!live) continue;- live.gain.gain.value = Math.max(0, Math.min(1.5, v.gain));+ live.gain.gain.value = Math.max(0, Math.min(3, v.gain));// A read that hangs holds the voice as surely as one that fails, and it// holds it quietly: nothing else would ever notice, and the voice would// wait on it for the rest of the play.diff --git a/site/src/cut/lib/types.ts b/site/src/cut/lib/types.tsindex fa25fc50..677f16d4 100644--- a/site/src/cut/lib/types.ts+++ b/site/src/cut/lib/types.ts@@ -475,7 +475,7 @@ export interface VideoClip {in: number; // trim-in inside the source, secondsout: number; // trim-out inside the source, secondsmuted: boolean;- /** Gain on the clip's own audio, 0..1.5; absent = 1 (unchanged). */+ /** Gain on the clip's own audio, 0..3; absent = 1 (unchanged). */volume?: number;/** How the clip meets its region: letterboxed ("fit", default) or scaled to* cover it ("fill", cropping the overflow). */@@ -912,7 +912,7 @@ export interface AudioClip {start: number; // timeline position, secondsin: number;out: number;- volume: number; // 0..1.5+ volume: number; // 0..3fadeIn?: number; // seconds, ramp up from the clip startfadeOut?: number; // seconds, ramp down into the clip end/** Muted from the final mix but kept on the timeline (grayed). */diff --git a/site/src/cut/server/exportPipeline.ts b/site/src/cut/server/exportPipeline.tsindex 8eda1b33..a849bdec 100644--- a/site/src/cut/server/exportPipeline.ts+++ b/site/src/cut/server/exportPipeline.ts@@ -66,7 +66,7 @@ export interface ExportSpec {in: number;out: number;muted: boolean;- /** Gain on the clip's own audio, 0..1.5; absent = 1 (unchanged). */+ /** Gain on the clip's own audio, 0..3; absent = 1 (unchanged). */volume?: number;/** "fit" letterboxes (default); "fill" covers the region and crops. */fit?: "fit" | "fill";@@ -155,7 +155,7 @@ export interface ExportSpec {panX?: number; // crop-window pan -1..1, across whatever overflowspanY?: number;muted: boolean;- /** Gain on the clip's own audio, 0..1.5; absent = 1 (unchanged). */+ /** Gain on the clip's own audio, 0..3; absent = 1 (unchanged). */volume?: number;speed?: number;/** Transition ramps, timeline seconds from this overlay's head/tail. On