25 lines
589 B
TypeScript
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)
|
|
} |