quiet-js
quiet-js copied to clipboard
Saving the generated audio for WAV or MP3
Dear Brian, it's me again, needing your assistance. I would like to generate the sound and be able to export it to wav or any other format with the JS version.
Can you give me directions on how to do it?
Thank you very much as always!
Hi @carlosguedes,
The JS lib doesn't have that functionality. I didn't think it'd be particularly useful.
You could fork it to get the raw samples relatively easily, but then you would still need to put them in the WAV container. The C library uses libsndfile to do that, which won't be present here.
If you want to try, the first step would be to add a new function that wrap quiet_encoder_emit. It's already called by the webaudio callbacks in JS, so you could just find those and copy/paste into a new function that returns the samples. You'd also have to add some way to disable the webaudio bits so that you could invoke consume directly.
Let me know if you have more questions.
Dear Brain, first of all thanks for great api. can you please share the code for generating audio ?
Hi @brian-armstrong,
I'm trying to get raw samples, could you please tell me if this function returns them?
var written = Module.ccall('quiet_encoder_emit', 'number', ['pointer', 'pointer', 'number'], [encoder, samples, sampleBufferSize]);
Hi @carlosguedes,
Have you managed to set it up somehow?
@brian-armstrong, may I ask your attention here, I've created a PR for this issue that allows downloading transmissions in ".wav" format: https://github.com/quiet/quiet-js/pull/41
@carlosguedes, @trghauri, @yaroslav-perec FYI.