5
votes

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)?

1
What exactly is your use case? Sound manipulation is possible though numerous non-JS tools and what your describing sounds like there is no need to use the Web Audio API. If you really want to use it, you probably want to run JS serverside, which means Node.js. - Dan
I'd like to do some leveling based on rms, and also some convolution on wav files. I will only need to do this processing once, but the files will be played back many times. I am running into memory limits with php server-side doing this stuff, so I want to do it client-side. The web audio api can do most of this already, and if I can get the processing back out with relative ease it will do the job nicely. - Rob Allsopp
Delegating that off to the client does not sound wise to me. For starters, if you do then the client will need to POST the modified sound file back to your server (since you're wanting to do it only one time). If you allow the client to post files back, you have to worry about security. Check this out for help processing sound in PHP. - Dan
Take a look at Recorder.js - MarijnS95

1 Answers

0
votes

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.