Jan Deinhard
Jan Deinhard

Reputation: 20175

How to get access to the output buffer with the Web Audio API?

I'd like to access the audio data in the output/destination buffer. To be specific I would like to save the data to a file. I would also like to add custom effects as AudioNode's.

How can I achieve this with the Web Audio API? I don't see an AudioDestinationBuffer interface or a way to add a custom AudioNode in the specs.

Upvotes: 5

Views: 3747

Answers (2)

user
user

Reputation: 25708

JavaScriptNode, later renamed to ScriptProcessorNode, has been deprecated in favor of AudioWorkletNode. There is an example on the AudioWorkletProcessor MDN page.

Upvotes: 2

Oskar Eriksson
Oskar Eriksson

Reputation: 2641

You'll have to add one of these http://www.w3.org/TR/webaudio/#JavaScriptAudioNode right before connecting to the destination.

This will give you access to the raw audio data, and any processing made by effect nodes etc. will already be applied. Just make sure this is the very last node before the destination.

Here's a little something on how you use the JavaScriptAudioNode http://www.html5rocks.com/en/tutorials/webaudio/games/#toc-clip-detect, which I hope will illustrate how to access the audio data.

Upvotes: 5

Related Questions