spessasus / SpessaSynth

MIDI SoundFont/DLS synthesizer library written in JavaScript.
https://spessasus.github.io/SpessaSynth/
Other
70 stars 7 forks source link

[QUESTION]noise when play midi after loading sf3 for the first time #47

Open daxiangpanda opened 2 weeks ago

daxiangpanda commented 2 weeks ago

After loading the SF3 soundfont with SpessaSynth, there is noticeable noise at the beginning of the MIDI when it is played for the first time. If you click to replay the MIDI, the noise disappears. Do you have any suggestions to resolve this issue?

spessasus commented 2 weeks ago

It's probably the chromium bug. There's not much I can do about it.

Try playing the MIDI in Firefox and it shouldn't happen.

daxiangpanda commented 2 weeks ago

Is this bug related to audioContext.audioWorklet.addModule?

spessasus commented 2 weeks ago

Is this bug related to audioContext.audioWorklet.addModule?

No, not really. It's the way Chromium renders audio.

You see, when Spessasynth loads a MIDI, it preloads all the sample's used in it for smooth playback. Sf3 uses compressed samples which, as you might guess, take time to decompress.

And that's fine. It stalls the audio thread for a little while before starting the playback, which is fine on Firefox.

But not on Chromium. When it stalls chromium's audio thread, it then tried to "catch up" by trying to render all lost audio frames in a split second! This is what you perceive as crackling.

I hope this clears things up.

spessasus commented 2 weeks ago

Hi, here's the link to chromium bug tracker regarding this bug:

https://issues.chromium.org/issues/367304685