I am trying to save the output from webAudio API for future use , so far i think getting PCM data and saving it as a file will do my expectation , I am wondering if the webAudio or mozAudio already supports saving the output stream if not how can i get the pcm data from the output stream
Share
There isn’t a good sense of the requirements here outside of attempting to capture web audio in some programmatic way. The presumption here is you want to do this from code executing in JavaScript on the page that’s currently being browsed, but that also isn’t entirely clear.
As Incognito points out, you can do this in Chrome by using a callback hanging off
decodeAudioData(). But, this may be overly complicated for your uses if you’re simply trying to capture, for example, the output of a single web stream and decode it into PCM for use in your sound tools of choice.Another strategy you might consider, for cases when the media URL is obscured or otherwise difficult to decode using your current tools, is capture from your underlying sound card. This gives you the decoding for free, at the potential expense of a lower sampling rate if (and only if) your sound card isn’t able to sample the stream effectively.
As we know, you’re already encoding analog signals digitally anyway via your desire for PCM encoding. Obviously, only do this if you have the legal right to use the files being sampled.
Regardless of the route you choose, best of luck to you. Be it programmatic stream dissection or spot sampling, you should now have more than enough information to proceed.
Edit: Based on additional information from the OP, this seems like the needed solution (merged from here and here, using NodeJS’ implementation of
fs):(Warning: untested code. If this doesn’t work, edits are welcome.)
This effectively spools out
decodeAudioDatafrom the Web Audio API, decodes PCM from the supplieddata, then attempts to save it to the targetsaveLocation. Simple enough, really.