audio/ui
Toggle Mode D
Copy to Clipboardpnpm dlx shadcn@latest add @audio-ui/use-sound-report
Copy to Clipboardimport { useSoundReport } from "@/hooks/use-sound-report";
| Files | hooks/use-sound-report.ts |
|---|---|
| Depends on | arrangement, clip-player, use-bake |
| npm | Nothing |
| Used by | block-audio-editor |
| Export | Kind | What it is |
|---|---|---|
useSoundReport | function | Reads the sound as edited, to tell what it is: its loudness, key and tempo, and whether it meets ACX's audiobook requirements. |
Usage
useSoundReport renders what a track's clips play, as useBake does, and reads it with reportSound of @/lib/engine/analysis: the loudness and true peak, the likeliest key, the tempo when the sound has a beat, and checkAcx's verdict on each of ACX's audiobook requirements (RMS between -23 and -18 dBFS, peak at most -3 dBFS, noise floor at most -60 dBFS on the quietest pause).
Copy to Clipboardimport { useSoundReport } from "@/hooks/use-sound-report"; import { SoundReport } from "@/components/audio-ui/sound-report"; const { analyze, clear, report } = useSoundReport({ doc, // the arrangement's document recordings, sampleRate: 48_000, setStatus, // what the editor says while it works track: "track-1", }); <MenuItem onClick={analyze}>Analyze sound</MenuItem>; <SoundReport onOpenChange={(open) => !open && clear()} report={report} />;
report is null until analyze has read the sound, and again after clear. SoundReport draws it in a dialog.