Files
bruitiste/src/domain/audio/WavExporter.ts
2025-09-30 14:20:50 +02:00

25 lines
589 B
TypeScript

import { encodeWAV } from '../../lib/bytebeat/wavEncoder'
import type { BitDepth } from '../../lib/bytebeat/types'
export type { BitDepth }
export interface ExportOptions {
sampleRate: number
bitDepth?: BitDepth
}
export function exportToWav(
samples: Float32Array,
options: ExportOptions
): Blob {
const bitDepth = options.bitDepth || 8
return encodeWAV(samples, options.sampleRate, bitDepth)
}
export function createDownloadUrl(blob: Blob): string {
return URL.createObjectURL(blob)
}
export function revokeDownloadUrl(url: string): void {
URL.revokeObjectURL(url)
}