Audio V2: Resume() audio sprites not working

I noticed that resume() doesn’t resume from the same playback time when it was paused(), if loopStart or loopEnd is set.

It instead always plays from the loopStart playback time value, and not from when it was paused.

Playground: https://playground.babylonjs.com/#6FZCRD#1

This also happens with Sound Buffers.

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.

@RaananW

verified, most certainly a bug. let me look into that.

@RaananW

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;  
}  

i’ll look into that

@RaananW

Very nice.

I still notice it goes out of sync when setting currentTime after Pause.

I think there is another bug somewhere else.

Here’s a much simpler playground, just a button which skips to 6.0s.

https://playground.babylonjs.com/#6FZCRD#3

  1. Press Play, then press currentTime = 6.0, works perfectly every time. deviation 0.

  2. Now Pause Resume, then skipping deviation is not 0, unless sound is Stopped.

I don’t understand what is happening, I am simply setting the exact same currentTime.

But because of this, when changing the active sprite of a paused/resumed sound, it goes out of sync.