infojunkie / musicxml-player

A TypeScript component that loads and plays MusicXML files in the browser using Web Audio and Web MIDI.
https://blog.karimratib.me/demos/musicxml/
GNU General Public License v3.0
34 stars 6 forks source link

[Demo] First play after page load stutters #34

Closed infojunkie closed 4 months ago

infojunkie commented 4 months ago

When loading the page, the JS console shows the following warning:

audio-context-constructor.js:11 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu

When clicking Play for the first time, the audio stutters for a few notes and the JS console shows the following repeated logs:

WebAudioFontOutput.ts:163 audioContext.resume AudioContext {_nativeEventTarget: AudioContext, _listeners: WeakMap, _nativeContext: AudioContext, _destination: AudioDestinationNode, _listener: {…}, …}

This tells me that the audio context does not have enough time to resume after the first user interaction. The first scheduled notes are lost during this interval of time.