tidalcycles / strudel

Web-based environment for live coding algorithmic patterns, incorporating a faithful port of TidalCycles to JavaScript
https://strudel.cc/
GNU Affero General Public License v3.0
579 stars 105 forks source link

[BUG FIX] Audio worklets sometimes dont load #1121

Closed daslyfe closed 4 weeks ago

daslyfe commented 4 weeks ago

Race condition prevented from loading sometimes before being being played leading to silence or a messed up audio context state

felixroos commented 4 weeks ago

it might be simpler to promise cache initAudioOnFirstClick and do await initAudioOnFirstClick inside beforeEval? I think the presence of audioContext doesn't mean that the worklets are loaded

felixroos commented 4 weeks ago

so the problem was the first event getting played before audioworklets being ready?

daslyfe commented 4 weeks ago

so the problem was the first event getting played before audioworklets being ready?

yes it was two things

  1. there was no awaiting in the loadWorklets function, so it was sometimes not initialized before it was referenced
  2. the initAudioOnFirstClick happens at the same time as you hit the play button if you have not clicked anything else yet