Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Web Audio API in non-real-time

The Web Audio API seems cool, but I'd really like to use it to processes audio files and then save them as wav files again, and I don't really need to listen to them while they are processing. Is this possible? Is there something like encodeAudioData() to turn the audio buffer back into an ArrayBuffer so I could put it back in a file?

Edit: recorderJS seems almost perfect, but it only outputs 16-bit wavs. Any chance there is something that can do pro-audio formats (24-bit or 32-bit float)?

like image 240
Rob Allsopp Avatar asked Nov 24 '22 04:11

Rob Allsopp


1 Answers

In Web Audio API specification, there is the Offline Context which does exactly what you need.

OfflineAudioContext is a particular type of AudioContext for rendering/mixing-down (potentially) faster than real-time. It does not render to the audio hardware, but instead renders as quickly as possible, calling a completion event handler with the result provided as an AudioBuffer.

like image 163
zya Avatar answered Dec 28 '22 10:12

zya