Skip to content

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

Allow imported audio below -12 dB

Daniel Apodaca8418d32b2916
diff --git a/src/components/ai-edition/RightPanes.audioTrack.test.tsx b/src/components/ai-edition/RightPanes.audioTrack.test.tsx
index 595518b8e..36f3c9937 100644
--- a/src/components/ai-edition/RightPanes.audioTrack.test.tsx
+++ b/src/components/ai-edition/RightPanes.audioTrack.test.tsx
@@ -19,6 +19,51 @@ describe("AudioTrackPane reset button", () => {
localStorage.clear();
});
+ it("allows imported audio tracks to be lowered below -12 dB", () => {
+ const setAudioTrackGain = vi.fn();
+ const mockTrack: AxcutAudioTrack = {
+ id: "audio_track_1",
+ clipId: "clip_1",
+ assetId: "asset_audio_1",
+ trackId: "audio_track_1",
+ startMs: 1000,
+ endMs: 5000,
+ durationSec: 10,
+ offsetMs: 0,
+ gainDb: 0,
+ fadeInMs: 0,
+ fadeOutMs: 0,
+ muted: false,
+ loop: false,
+ kind: "music",
+ label: "bg-music.mp3",
+ origin: "user",
+ };
+
+ const tl = {
+ selectedAudioTrackId: "audio_track_1",
+ audioTracks: [mockTrack],
+ assets: [],
+ setAudioTrackGain,
+ } as unknown as TimelineApi;
+
+ render(
+ <I18nProvider>
+ <AudioTrackPane tl={tl} />
+ </I18nProvider>,
+ );
+
+ const gainSlider = screen.getByRole("slider", { name: "Output level" });
+ expect(gainSlider).toHaveAttribute("min", "-60");
+ expect(gainSlider).toHaveAttribute("max", "12");
+
+ fireEvent.change(gainSlider, { target: { value: "-24" } });
+ fireEvent.mouseUp(gainSlider);
+
+ expect(gainSlider).toHaveValue("-24");
+ expect(setAudioTrackGain).toHaveBeenCalledWith("audio_track_1", -24);
+ });
+
it("resets all track parameters (gain, fades, mute, loop) on reset click", () => {
const updateAudioTrack = vi.fn();
const mockTrack: AxcutAudioTrack = {
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx
index 00cc199e1..5303d55dc 100644
--- a/src/components/ai-edition/RightPanes.tsx
+++ b/src/components/ai-edition/RightPanes.tsx
@@ -59,6 +59,8 @@ import type {
} from "@/lib/ai-edition/schema";
import {
AUDIO_GAIN_DB_LIMIT,
+ AUDIO_TRACK_GAIN_DB_MAX,
+ AUDIO_TRACK_GAIN_DB_MIN,
type EditorSettingsPatch,
} from "@/lib/ai-edition/store/editorSettings";
import { useProjectStore } from "@/lib/ai-edition/store/projectStore";
@@ -3336,8 +3338,8 @@ export function AudioTrackPane({ tl, onClose }: { tl: TimelineApi; onClose?: ()
<SliderCell
label={ts("audio.outputGain")}
value={liveGain ?? track.gainDb}
- min={-AUDIO_GAIN_DB_LIMIT}
- max={AUDIO_GAIN_DB_LIMIT}
+ min={AUDIO_TRACK_GAIN_DB_MIN}
+ max={AUDIO_TRACK_GAIN_DB_MAX}
step={0.5}
decimals={1}
suffix=" dB"
diff --git a/src/lib/ai-edition/store/editorSettings.ts b/src/lib/ai-edition/store/editorSettings.ts
index 5d3db3ed6..7fd28a68e 100644
--- a/src/lib/ai-edition/store/editorSettings.ts
+++ b/src/lib/ai-edition/store/editorSettings.ts
@@ -46,6 +46,8 @@ import type { AxcutDocument } from "../schema";
* stretched, concatenated timeline, so the same value meant different delays under a speed
* region, and near a cut the export pulls audio across the junction while the preview cannot. */
export const AUDIO_GAIN_DB_LIMIT = 12;
+export const AUDIO_TRACK_GAIN_DB_MIN = -60;
+export const AUDIO_TRACK_GAIN_DB_MAX = 12;
/** dB to the linear scalar every side of the boundary multiplies by.
*