Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

refactor(editor): remove the mute feature from imported audio tracks

Benjamin Freeman3354280e89e9
diff --git a/crates/compositor/src/audio.rs b/crates/compositor/src/audio.rs
index bfc7d264c..5de0e19d4 100644
--- a/crates/compositor/src/audio.rs
+++ b/crates/compositor/src/audio.rs
@@ -1390,19 +1390,16 @@ pub fn assemble_concatenated_pcm(
/// track that runs past the video is truncated to it, so the audio and video
/// streams stay the same length for the muxer.
///
-/// A muted track, or one whose file has no decodable audio, is skipped — the same
-/// degradation a stream-less clip gets. `trim_end_sec` must be concrete (the
-/// renderer sends `trimEnd ?? durationSec`): `decode_clip_audio` preallocates from
-/// it, so an unbounded end would try to allocate the whole real line.
+/// A track whose file has no decodable audio is skipped — the same degradation a
+/// stream-less clip gets. `trim_end_sec` must be concrete (the renderer sends
+/// `trimEnd ?? durationSec`): `decode_clip_audio` preallocates from it, so an
+/// unbounded end would try to allocate the whole real line.
pub fn mix_external_tracks(mut programme: PlanarPcm, tracks: &[SceneAudioTrack]) -> PlanarPcm {
let programme_len = programme.first().map(Vec::len).unwrap_or(0);
if programme_len == 0 {
return programme;
}
for track in tracks {
- if track.mute {
- continue;
- }
let trim_start = track.trim_start_sec.max(0.0);
let Some(trim_end) = track.trim_end_sec else {
// Without a concrete end there is no safe window to decode (see the doc
@@ -1783,28 +1780,17 @@ mod tests {
}
#[test]
- fn mix_external_tracks_skips_muted_and_empty_windows() {
+ fn mix_external_tracks_skips_empty_windows() {
let programme = planar(&[0.4, 0.4]);
- let tracks = vec![
- SceneAudioTrack {
- path: "/nope.mp3".into(),
- start_sec: 0.0,
- gain_db: 0.0,
- trim_start_sec: 0.0,
- trim_end_sec: Some(1.0),
- mute: true,
- },
- SceneAudioTrack {
- path: "/nope.mp3".into(),
- start_sec: 0.0,
- gain_db: 0.0,
- trim_start_sec: 2.0,
- trim_end_sec: Some(1.0), // end <= start: empty window, never decoded
- mute: false,
- },
- ];
- // Both tracks are skipped before any decode, so the programme is untouched
- // even though the path does not exist.
+ let tracks = vec![SceneAudioTrack {
+ path: "/nope.mp3".into(),
+ start_sec: 0.0,
+ gain_db: 0.0,
+ trim_start_sec: 2.0,
+ trim_end_sec: Some(1.0), // end <= start: empty window, never decoded
+ }];
+ // The empty window is skipped before any decode, so the programme is
+ // untouched even though the path does not exist.
let out = mix_external_tracks(programme, &tracks);
assert_eq!(out[0], vec![0.4, 0.4]);
}
diff --git a/crates/compositor/src/scene.rs b/crates/compositor/src/scene.rs
index 3a88e4870..5d79ba1b6 100644
--- a/crates/compositor/src/scene.rs
+++ b/crates/compositor/src/scene.rs
@@ -453,8 +453,6 @@ pub struct SceneAudioTrack {
pub trim_start_sec: f64,
#[serde(default)]
pub trim_end_sec: Option<f64>,
- #[serde(default)]
- pub mute: bool,
}
#[derive(Debug, Clone, Copy, Deserialize)]
diff --git a/src/components/ai-edition/VirtualPreview.audio.test.ts b/src/components/ai-edition/VirtualPreview.audio.test.ts
index c8e38beff..aeb2781e8 100644
--- a/src/components/ai-edition/VirtualPreview.audio.test.ts
+++ b/src/components/ai-edition/VirtualPreview.audio.test.ts
@@ -93,7 +93,6 @@ describe("resolveTimelineAudioPlayback", () => {
trimStartSec: 2,
trimEndSec: 8,
gainDb: 0,
- mute: false,
label: "",
};
@@ -114,14 +113,6 @@ describe("resolveTimelineAudioPlayback", () => {
});
});
- it("never plays while muted, even inside its window", () => {
- const muted = { ...track, mute: true };
- expect(resolveTimelineAudioPlayback(13, muted)).toEqual({
- targetTimeSec: 5,
- shouldPlay: false,
- });
- });
-
it("uses the asset duration as the out-point when the tail isn't trimmed", () => {
const untrimmed = { ...track, trimStartSec: 0, trimEndSec: undefined, durationSec: 5 };
// Span is 10..15. At 14 → 4s of source, still playing.
diff --git a/src/components/ai-edition/VirtualPreview.playback.test.tsx b/src/components/ai-edition/VirtualPreview.playback.test.tsx
index d6b2d9f6c..ae195532f 100644
--- a/src/components/ai-edition/VirtualPreview.playback.test.tsx
+++ b/src/components/ai-edition/VirtualPreview.playback.test.tsx
@@ -247,7 +247,6 @@ describe("VirtualPreview imported audio tracks", () => {
trimStartSec: 1,
trimEndSec: 3,
gainDb: 0,
- mute: false,
label: "",
};
diff --git a/src/components/ai-edition/VirtualPreview.tsx b/src/components/ai-edition/VirtualPreview.tsx
index eb9e83943..00b17bc0e 100644
--- a/src/components/ai-edition/VirtualPreview.tsx
+++ b/src/components/ai-edition/VirtualPreview.tsx
@@ -76,9 +76,9 @@ export function resolveAudioTrackPlayback(
*
* A track occupies `[timelineStartSec, timelineStartSec + (trimEnd - trimStart)]`
* on the timeline; its source position is `trimStart` plus however far the
- * playhead is into that span. Outside the span — or when muted — it parks at the
- * nearer trim edge and stays paused, the same discipline `resolveAudioTrackPlayback`
- * uses so the rAF never seeks an element into nothing.
+ * playhead is into that span. Outside the span it parks at the nearer trim edge
+ * and stays paused, the same discipline `resolveAudioTrackPlayback` uses so the
+ * rAF never seeks an element into nothing.
*
* This is the RAW/document timeline the ruler, playhead and lane all use — NOT
* the trim-compressed output timeline — because that is where the track was
@@ -92,7 +92,7 @@ export function resolveTimelineAudioPlayback(virtualTimeSec: number, track: Axcu
const local = virtualTimeSec - track.timelineStartSec;
return {
targetTimeSec: Math.min(Math.max(trimStart, trimStart + local), trimEnd),
- shouldPlay: !track.mute && local >= 0 && local < windowLen,
+ shouldPlay: local >= 0 && local < windowLen,
};
}
diff --git a/src/components/ai-edition/v4/EditorShellV4.module.css b/src/components/ai-edition/v4/EditorShellV4.module.css
index 2096aa159..0a72c761b 100644
--- a/src/components/ai-edition/v4/EditorShellV4.module.css
+++ b/src/components/ai-edition/v4/EditorShellV4.module.css
@@ -1509,9 +1509,6 @@
.laneAudio:active {
cursor: pointer;
}
-.laneAudioMuted {
- opacity: 0.5;
-}
/* The label rides above the waveform (which is inset:0 behind it). */
.laneAudioLabel {
position: relative;
diff --git a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
index 750e1f689..0ece54317 100644
--- a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
@@ -357,7 +357,6 @@ describe("V4Timeline audio lane drag", () => {
trimStartSec: 0,
trimEndSec: undefined as number | undefined,
gainDb: 0,
- mute: false,
label: "vo",
});
diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsx
index 9fcfbf48e..cff3eb60e 100644
--- a/src/components/ai-edition/v4/V4Timeline.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.tsx
@@ -10,7 +10,6 @@ import {
Sparkles,
SplitSquareHorizontal,
Trash2,
- VolumeX,
Wand2,
ZoomIn,
} from "lucide-react";
@@ -374,7 +373,7 @@ const AudioLanePill = memo(function AudioLanePill({
tabIndex={0}
className={`${styles.lanePill} ${styles.laneAudio}${
selected ? ` ${styles.lanePillSel}` : ""
- }${track.mute ? ` ${styles.laneAudioMuted}` : ""}`}
+ }`}
style={{ left: `${leftPct}%`, width: `${widthPct}%`, minWidth: 3 }}
// Body drag moves the track; it also selects and stops the .tlTracks scrub.
onPointerDown={(e) => onStartDrag(e, track, "move")}
@@ -399,7 +398,7 @@ const AudioLanePill = memo(function AudioLanePill({
gain={audioGainScalar(track.gainDb)}
/>
<span className={styles.laneAudioLabel}>
- {track.mute ? <VolumeX size={11} /> : <Music size={11} />}
+ <Music size={11} />
{label}
</span>
<span
diff --git a/src/lib/ai-edition/document/audioTracks.test.ts b/src/lib/ai-edition/document/audioTracks.test.ts
index cddee21dd..ddec1ce05 100644
--- a/src/lib/ai-edition/document/audioTracks.test.ts
+++ b/src/lib/ai-edition/document/audioTracks.test.ts
@@ -4,7 +4,6 @@ import {
appendAudioTrack,
removeAudioTrack,
setAudioTrackGain,
- setAudioTrackMute,
setAudioTrackPlacement,
} from "./audioTracks";
@@ -36,14 +35,6 @@ describe("audioTracks document ops (issue #350)", () => {
expect(setAudioTrackGain(doc, track.id, Number.NaN).audioTracks[0]?.gainDb).toBe(0);
});
- it("setAudioTrackMute toggles mute without touching gain", () => {
- const { doc, track } = docWithTrack();
- const withGain = setAudioTrackGain(doc, track.id, -3);
- const muted = setAudioTrackMute(withGain, track.id, true);
- expect(muted.audioTracks[0]?.mute).toBe(true);
- expect(muted.audioTracks[0]?.gainDb).toBe(-3);
- });
-
it("setAudioTrackPlacement writes position and trim together, staying schema-valid", () => {
const { doc, track } = docWithTrack();
const placed = setAudioTrackPlacement(doc, track.id, {
diff --git a/src/lib/ai-edition/document/audioTracks.ts b/src/lib/ai-edition/document/audioTracks.ts
index 5fb49c55b..a70042f59 100644
--- a/src/lib/ai-edition/document/audioTracks.ts
+++ b/src/lib/ai-edition/document/audioTracks.ts
@@ -72,12 +72,3 @@ export function setAudioTrackGain(
): AxcutDocument {
return updateAudioTrack(doc, trackId, (t) => ({ ...t, gainDb: finite(gainDb) }));
}
-
-/** Mute or unmute a track without losing its stored gain. */
-export function setAudioTrackMute(
- doc: AxcutDocument,
- trackId: string,
- mute: boolean,
-): AxcutDocument {
- return updateAudioTrack(doc, trackId, (t) => ({ ...t, mute }));
-}
diff --git a/src/lib/ai-edition/schema/index.test.ts b/src/lib/ai-edition/schema/index.test.ts
index 2c6b25be4..2e69c6a42 100644
--- a/src/lib/ai-edition/schema/index.test.ts
+++ b/src/lib/ai-edition/schema/index.test.ts
@@ -975,7 +975,7 @@ describe("v6 -> v7 trim clip-anchor migration", () => {
});
describe("audio tracks (issue #350)", () => {
- it("applies defaults for gain, mute, trim, position, and label", () => {
+ it("applies defaults for gain, trim, position, and label", () => {
const track = audioTrackSchema.parse({
id: "audio_1",
assetId: "asset_1",
@@ -985,7 +985,6 @@ describe("audio tracks (issue #350)", () => {
expect(track.trimStartSec).toBe(0);
expect(track.trimEndSec).toBeUndefined();
expect(track.gainDb).toBe(0);
- expect(track.mute).toBe(false);
expect(track.label).toBe("");
});
diff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.ts
index f0998feed..ba6b188bf 100644
--- a/src/lib/ai-edition/schema/index.ts
+++ b/src/lib/ai-edition/schema/index.ts
@@ -491,7 +491,7 @@ export const zoomRegionSchema = endGteStart(
//
// `assetId` points at an asset with `kind: "audio"`. `timelineStartSec` places
// the track's head; `trimStartSec`/`trimEndSec` window the source file (both in
-// source seconds); `gainDb` + `mute` set its level.
+// source seconds); `gainDb` sets its level.
export const audioTrackSchema = z
.object({
id: z.string().min(1),
@@ -505,7 +505,6 @@ export const audioTrackSchema = z
// the tail so the pill and the export agree on where the track stops.
trimEndSec: z.number().nonnegative().optional(),
gainDb: z.number().default(0),
- mute: z.boolean().default(false),
label: z.string().default(""),
})
.refine((data) => data.trimEndSec === undefined || data.trimEndSec >= data.trimStartSec, {
@@ -1040,7 +1039,7 @@ export function ensureDocument(value: unknown): AxcutDocument {
* Build a timeline audio track for an imported audio asset (issue #350). The
* head is placed at `timelineStartSec` (output-timeline seconds) and the track
* spans the whole source file until the user trims it. Parsed through the schema
- * so every default (gain, mute, trim) is applied in one place.
+ * so every default (gain, trim) is applied in one place.
*/
export function createAudioTrack(input: {
assetId: string;
diff --git a/src/lib/ai-edition/store/documentWriteAudit.test.ts b/src/lib/ai-edition/store/documentWriteAudit.test.ts
index 0f0065152..3641782fb 100644
--- a/src/lib/ai-edition/store/documentWriteAudit.test.ts
+++ b/src/lib/ai-edition/store/documentWriteAudit.test.ts
@@ -241,12 +241,10 @@ const DECLARED: WritePath[] = [
w("src/lib/ai-edition/store/useTimeline.ts", "insertClipAt", "save", "gesture"),
w("src/lib/ai-edition/store/useTimeline.ts", "moveClip", "save", "gesture"),
// Imported audio tracks (issue #350). Each is a direct user edit — drag/trim the
- // track (placeAudioTrack), change its level, mute it, or delete it — one undo
- // step apiece.
+ // track (placeAudioTrack), change its level, or delete it — one undo step apiece.
w("src/lib/ai-edition/store/useTimeline.ts", "placeAudioTrack", "save", "gesture"),
w("src/lib/ai-edition/store/useTimeline.ts", "removeAudioTrack", "save", "gesture"),
w("src/lib/ai-edition/store/useTimeline.ts", "setAudioTrackGain", "save", "gesture"),
- w("src/lib/ai-edition/store/useTimeline.ts", "toggleAudioTrackMute", "save", "gesture"),
// The round-2 defect: a background duration probe every freshly imported asset
// fires, because `addAsset` never populates `durationSec`.
w("src/lib/ai-edition/store/useTimeline.ts", "probeAndCorrectClip", "save", "automatic"),
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index 0fca8c68e..c79ec343f 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -1358,7 +1358,7 @@ describe("useTimeline audio tracks", () => {
expect(useProjectStore.getState().document?.audioTracks).toEqual([]);
});
- it("place / gain / mute update the track and each is one undo step", async () => {
+ it("place / gain update the track and each is one undo step", async () => {
const { result } = renderTimeline();
let id = "";
await act(async () => {
@@ -1375,9 +1375,6 @@ describe("useTimeline audio tracks", () => {
await act(async () => {
await result.current.setAudioTrackGain(id, -6);
});
- await act(async () => {
- await result.current.toggleAudioTrackMute(id);
- });
const track = useProjectStore.getState().document?.audioTracks[0];
expect(track).toMatchObject({
@@ -1385,14 +1382,13 @@ describe("useTimeline audio tracks", () => {
trimStartSec: 1,
trimEndSec: 8,
gainDb: -6,
- mute: true,
});
- // Four writes (add + three edits) → the mute undoes first.
+ // Three writes (add + place + gain) → the gain edit undoes first.
act(() => {
expect(undo()).toBe(true);
});
- expect(useProjectStore.getState().document?.audioTracks[0]?.mute).toBe(false);
+ expect(useProjectStore.getState().document?.audioTracks[0]?.gainDb).toBe(0);
});
it("removeAudioTrack deletes the track", async () => {
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index db58c38fa..aed880208 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -10,7 +10,6 @@ import { useScopedT } from "@/contexts/I18nContext";
import {
removeAudioTrack as removeAudioTrackInDocument,
setAudioTrackGain as setAudioTrackGainInDocument,
- setAudioTrackMute as setAudioTrackMuteInDocument,
setAudioTrackPlacement as setAudioTrackPlacementInDocument,
} from "../document/audioTracks";
import { createId } from "../document/ids";
@@ -1250,18 +1249,6 @@ export function useTimeline() {
[document, saveDocument],
);
- const toggleAudioTrackMute = useCallback(
- async (trackId: string) => {
- if (!document) return;
- const track = document.audioTracks.find((t) => t.id === trackId);
- if (!track) return;
- await saveDocument(setAudioTrackMuteInDocument(document, trackId, !track.mute), {
- history: true,
- });
- },
- [document, saveDocument],
- );
-
return {
zoomRegions: document?.zoomRanges ?? [],
trimRanges: document?.timeline.trimRanges ?? [],
@@ -1287,7 +1274,6 @@ export function useTimeline() {
removeAudioTrack,
placeAudioTrack,
setAudioTrackGain,
- toggleAudioTrackMute,
selectedAudioTrackId,
selectAudioTrack,
selectRegion,
diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.ts
index 6b2bcde7c..51d02b712 100644
--- a/src/native/sceneDescription.test.ts
+++ b/src/native/sceneDescription.test.ts
@@ -2008,7 +2008,6 @@ describe("buildSceneDescription.audioTracks", () => {
trimStartSec: 2,
trimEndSec: 12 as number | undefined,
gainDb: -3,
- mute: false,
label: "",
};
@@ -2021,7 +2020,6 @@ describe("buildSceneDescription.audioTracks", () => {
gainDb: -3,
trimStartSec: 2,
trimEndSec: 12,
- mute: false,
},
]);
});
diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.ts
index db03ad82b..6f203c392 100644
--- a/src/native/sceneDescription.ts
+++ b/src/native/sceneDescription.ts
@@ -426,7 +426,6 @@ export interface SceneDescription {
gainDb: number;
trimStartSec: number;
trimEndSec: number;
- mute: boolean;
}>;
/**
* Per-clip screen crop (fractions of the frame), or null for the identity
@@ -519,7 +518,6 @@ export function buildSceneDescription(
gainDb: track.gainDb,
trimStartSec: track.trimStartSec,
trimEndSec,
- mute: track.mute,
},
];
});