modularity
This commit is contained in:
25
src/domain/audio/WavExporter.ts
Normal file
25
src/domain/audio/WavExporter.ts
Normal file
@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user