Well, turns out Recorder.js does exactly what I wanted. I thought it was only for exporting to disk, but when I looked closer I realized it can save to buffers too. Hooray!
Save audio in a buffer for later playback
With the Web Audio API, I want to save audio in a buffer for later use. I've found some examples of saving audio to disk, but I only want to store it in memory. I tried connecting the output of the last AudioNode in the chain to an AudioBuffer, but it seems AudioBuffer doesn't have a method for accepting inputs.
var contextClass = (window.AudioContext || window.webkitAudioContext); // Output compressor var compressor = context.createDynamicsCompressor(); var compressor.connect(context.destination); var music = context.createBufferSource(); // Load some content into music with XMLHttpRequest... music.connect(compressor); music.start(0); // Set up recording buffer var recordBuffer = context.createBuffer(2, 10000, 44100); compressor.connect(recordBuffer); // Failed to execute 'connect' on 'AudioNode': No function was found that matched the signature provided.
Is there something I can use instead of AudioBuffer to achieve this? Is there a way to do this without saving files to disk?