mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Added waveform with controls
This commit is contained in:
1 parent
fa7375d0e9
commit
5454784cff
5 files changed
+329
-24
No files matched your search
@@ -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 }
|
||||
}
|
||||
Reference in new issue
Block a user