You can avoid needed a user to deploy a separate JS file by using "inline worker" techniques. You can see a good example here: https://www.html5rocks.com/en/tutorials/workers/basics/
On Saturday, September 22, 2018 at 3:23:28 AM UTC-7, Floh wrote: > > Sorry for being slightly off-topic, but maybe someone here has found a > solution for my problem (AFAIL traditional WebWorkers have pretty much the > same problem). > > So here's what's bugging me currently about the new Audio Worklet stuff, > which is the recommended way to stream audio samples into WebAudio in the > future: as far as I can see, there *has* to be a separate JS file which > contains the code that's running in the audio thread. > > This is a bit of a bother if I want to create an audio library that lives > entirely in a C header. With the (deprecated) ScriptProcessorNode approach, > I can use the EM_JS and EM_ASM macros to embed the required JS code right > into the C header, but this idea doesn't work if the JS code needs to > remain in its own file. > > As far as I can see, Audio Worklets always take a 'module URL', and need > to load the JS code through a separate HTTP request ( > https://developer.mozilla.org/en-US/docs/Web/API/Worklet/addModule). > > The problem here (for a library writer) is that suddenly the whole thing > leaks out into the build system and deployment. It's a big step from just > saying "all you need to do is include this header and you're done" to "oh > btw, you also need to put this separate JS file on the web server as well", > or worse "this code needs to be compiled into a separate WASM module". > > Did someone figure out a solution how I can put all required worklet code > along with the main-thread code into a single C header file? > > Of course ideally I just want to give the audio worklet a JS function > object (or even better a C function pointer) that should run in the audio > thread context, but I guess such a simple solution was a bit too > straightforward for the web world? ;) > > Cheers! > -Floh. > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.