Added waveform with controls

This commit is contained in:
Ben committed 2026-07-04 16:37:59 +02:00
1 parent fa7375d0e9
commit 5454784cff
5 files changed
+329 -24

No files matched your search

+8 -2
View File
@@ -68,7 +68,13 @@ export function paintWave(
}
}
export async function analyzeWaveform(url: string, buckets?: number): Promise<WaveColumn[]> {
export interface WaveformAnalysis {
cols: WaveColumn[]
/** The decoded audio, retained for the scratch engine (reused, not re-decoded). */
buffer: AudioBuffer
}
export async function analyzeWaveform(url: string, buckets?: number): Promise<WaveformAnalysis> {
const resp = await fetch(url)
if (!resp.ok) throw new Error(`audio fetch failed: ${resp.status}`)
const arr = await resp.arrayBuffer()
@@ -168,5 +174,5 @@ export async function analyzeWaveform(url: string, buckets?: number): Promise<Wa
b: Math.pow(h / mx, 1.3),
}
}
return cols
return { cols, buffer: audio }
}