I'm working with soundtouchjs-audio-worklet in order to change the tempo/pitch of audio files that have been read into a buffer. The library creates a worklet that can process these buffers, and gives me an AudioWorkletNode to control it. What I need to do is schedule the playback of multiple AudioWorkletNodes so that different audio files can be on a "timeline" of sorts.
I know the AudioBufferSourceNode has a when parameter in it's start() function that you can use to schedule the playback of the node. But AudioWorkletNode doesn't seem to be scheduleable; it just immediately begins playback upon connect()ing it.
I could use setTimeout() to delay calling connect(), but I don't think the timing will be accurate enough. Does anyone know of a way to schedule playback of an AudioWorkletNode? Or an accurate way to connect it at the exact right time?
There is no built-in way to schedule an
AudioWorkletProcessorbut it's possible to use the globalcurrentTimevariable to build it yourself. The processor would then look a bit like this.It can then be "scheduled" to start when
currentTimeis 15 like this: