sono icon indicating copy to clipboard operation
sono copied to clipboard

Are custom loop points supported?

Open tgrajewski opened this issue 5 years ago • 2 comments

Web Audio allows to set the .loopStart and .loopEnd properties on the AudioBufferSourceNode. Can I use them with Sono?

tgrajewski avatar Dec 07 '18 12:12 tgrajewski

Hi @tgrajewski you can access the AudioBufferSourceNode of a sound via sound.sourceNode so you could set it after creating the sound. If it's not loaded you'll need to wait for the 'ready' event.

Something like:

const sound = sono.create('my_sound.mp3')
sound.loop = true
sound.once('ready', () => {
  sound.sourceNode.loopStart = 1
  sound.sourceNode.loopEnd = 2
  sound.play()
})

ianmcgregor avatar Dec 10 '18 21:12 ianmcgregor

@ianmcgregor I've hoped that it would be that simple, but unfortunately it doesn't work. The .sourceNode property is GainNode and doesn't have the .loopStart and .loopEnd properties. I'm missing something?

tgrajewski avatar Dec 11 '18 10:12 tgrajewski