Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
click sound: test the preview against the clip it is crossing
一个成熟的剪辑猿ab6ba937f234
diff --git a/src/lib/ai-edition/clickSound.test.ts b/src/lib/ai-edition/clickSound.test.tsindex 72746942b..6a7c827c9 100644--- a/src/lib/ai-edition/clickSound.test.ts+++ b/src/lib/ai-edition/clickSound.test.ts@@ -1,15 +1,19 @@-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import type { CursorTelemetryPoint } from "@/components/video-editor/types";+import { nativeBridgeClient } from "@/native/client";import type { ClickCue } from "./clickSound";import {buildClickCues,clickCuesFitTake,+ clickSoundForDocument,crossedClickHits,levelClickCues,+ loadClickCues,placeClickHits,placedClickHits,playClickHits,resetClickPlayhead,+ takeCrossedClickHits,} from "./clickSound";const point = (@@ -167,6 +171,40 @@ describe("placedClickHits", () => {});});+describe("takeCrossedClickHits with a mounted clip", () => {+ // The placement test above says which clip keeps the click; this says the preview listens to it.+ const document = doc(+ [clip(), clip({ id: "clip_2", timelineStartSec: 10, timelineEndSec: 20 })],+ [],+ [cut(2, 0.1)],+ );++ it("fires a click a twin clip keeps only over the clip that keeps it", async () => {+ const getTelemetry = vi+ .spyOn(nativeBridgeClient.cursor, "getTelemetry")+ .mockResolvedValue([point(2050, "click")]);+ try {+ await loadClickCues(asset.originalPath);+ clickSoundForDocument(document, { clickSound: true, clickSoundGainDb: 0 });+ // clip_1 cut 2..2.1 away, so its clock owes nothing across it.+ resetClickPlayhead();+ takeCrossedClickHits(2, asset.originalPath, "clip_1");+ expect(takeCrossedClickHits(2.06, asset.originalPath, "clip_1")).toEqual([]);+ resetClickPlayhead();+ takeCrossedClickHits(2, asset.originalPath, "clip_2");+ expect(+ takeCrossedClickHits(2.06, asset.originalPath, "clip_2").map((c) => c.timeSec),+ ).toEqual([2.05]);+ // An unresolved clip id is not a reason to go silent: the edit's whole list plays.+ resetClickPlayhead();+ takeCrossedClickHits(2, asset.originalPath);+ expect(takeCrossedClickHits(2.06, asset.originalPath).map((c) => c.timeSec)).toEqual([2.05]);+ } finally {+ getTelemetry.mockRestore();+ }+ });+});+describe("levelClickCues", () => {it("scales every cue by the level the user set, and leaves 0 dB alone", () => {const cues = [cue(1), { timeSec: 2, gain: 0.85, release: true }];