import * as WavDecoder from 'wav-decoder' ; import * as WavEncoder from 'wav-encoder' ; import { copy } from '../AudioBufferUtils' ; import { XAudioBuffer } from '../XAudioBuffer' ; import { writeFile } from '../pio' ; import { join } from 'path' ; export async function dumpWave ( output , filename = 'test.wav' ) { let channelData = [ ] ; for ( let i = 0 ; i < output . numberOfChannels ; i ++ ) { channelData . push ( output . getChannelData ( i ) ) ; } const encoded = await WavEncoder . encode ( { sampleRate : output . sampleRate , channelData } ) ; const dest = join ( process . cwd ( ) , filename ) ; await writeFile ( dest , new DataView ( encoded ) ) ; }