Record Sounds from AudioContext (Web Audio API)
Solution 1
Currently, there's not a native way to do that, but as Max said in the comment above, Recorderjs does essentially this (it doesn't chain onto the destination, but is a ScriptProcessorNode you can connect other nodes to, and have its input recorded. I built on Recorderjs to do a simple audio file recorder - https://github.com/cwilso/AudioRecorder.
Solution 2
Sine to opus file: https://developer.mozilla.org/de/docs/Web/API/AudioContext/createMediaStreamDestination
In the following simple example, we create a MediaStreamAudioDestinationNode, an OscillatorNode and a MediaRecorder (the example will therefore only work in Firefox at this time.) The MediaRecorder is set up to record information from the MediaStreamDestinationNode.
Chrome supports it, too: https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
kennysong
Updated on June 12, 2022Comments
-
kennysong about 2 years
Is there a way to record the audio data that's being sent to
webkitAudioContext.destination
?The data that the nodes are sending there is being played by the browser, so there should be some way to store that data into a (.wav) file.
-
Tomáš Zato about 10 yearsStill, recorder.js must work somehow - so there must be a way to do that. Fact that you don't want to bother explaining is not an excuse.
-
Chris Geirman over 9 yearsYour demo is pretty awesome! Thanks for sharing that!