Saving Csound output file


I’d like to let users download a sound file (such as a .wav) generated by csound. I’ve found an example but it doesn’t work with the current version of csound-web that I’ve downloaded (6.15.0). I think this is because the code I have is missing the RequestFileFromLocal function.

Was that function removed recently? If you can help me understand why, and what my options are, I would be very grateful! I’d prefer to run csound purely in the browser. I can generate an audio file by attaching a MediaRecorder to the audio graph but I’d rather not go through that intermediate step.

It looks to me that the version of csound used in that page was from before AudioWorklets were added and everything was done in main thread via ScriptProcessorNode, which makes FS work and available there too. I would guess that when I added the AudioWorklet implementation and split out AudioNode implementations, I missed adding that back into the API.

We’re using a different codebase for 6.16.0 that exposes more of FS object and async options for reading/writing files. For 6.15.0, I think you might have to modify the source to add RequestFileFromLocal to CsoundObj and have it delegate to the two node implementations that would ultimately route to calls Emscripten’s FS implementation to read the file from virtual filesystem and return it to the caller. (These would mirror what were in calls that writeToFS.)