Importing the worklet module
Warning
Make sure you always update worklet_processor.min.js
along with the npm package! Creating a script that automatically copies it is recommended.
The problem
the addModule
method uses URL relative to the page URL, so I (the creator) can’t simply just do
async function addWorkletHelper(context)
{
await context.audioWorklet.addModule("./worklet_processor.min.js")
}
Tip
If you know a better way of doing this, please let me know!
The Solution
Copy the worklet_processor.min.js
from spessasynth_lib/synthetizer
to your destination, for example src
folder.
I suggest creating an automation script, such as the one shown here.
Tip
This method seems to work with webpack.