I basically want to create multiple sound sprites from one buffer, each with unique startOffset, loopStart, loopEnd, and be able to pause resume them individually like normal sounds.
Thanks it’s working now.
I’ve notice another bug I’m gonna write it here:
I’ve modified the sound file, it’s now the first 5 seconds merged 3 times.
To simulate 3 identical audio sprites in one file.
Now press Play, then press Sprite 1, 2, 3. It jumps perfectly in sync. Works as expected.
Then press Pause then Resume, now everything is broken.
Example Playground: https://playground.babylonjs.com/#6FZCRD#2
Not sure if this is the problem, but setting loopStart and loopEnd while the sound is playing, does not propagate, unlike pitch and playbackRate
Something like adding loopStart, loopEnd setters on _WebAudioStaticSoundInstance that directly write to the live AudioBufferSourceNode:
public set loopStart(value: number) {
this._options.loopStart = value;
// missing: iterate instances and call instance.loopStart = value
}
public set loopStart(value: number) {
if (this.\_sourceNode) this.\_sourceNode.loopStart = value;
}