Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Burst of noise when playing MIDI after loading sf3 for the first time on Chromium #47

Open
daxiangpanda opened this issue Sep 18, 2024 · 6 comments
Labels
invalid This doesn't seem right wontfix This will not be worked on

Comments

@daxiangpanda
Copy link

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?

@daxiangpanda daxiangpanda added the question Further information is requested label Sep 18, 2024
@spessasus
Copy link
Owner

spessasus commented Sep 18, 2024

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
Copy link
Author

Is this bug related to audioContext.audioWorklet.addModule?

@spessasus
Copy link
Owner

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
Copy link
Owner

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

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

@spessasus spessasus added the invalid This doesn't seem right label Oct 3, 2024
@spessasus spessasus changed the title [QUESTION]noise when play midi after loading sf3 for the first time Burst of noise when playing MIDI after loading sf3 for the first time on Chromium Oct 10, 2024
@spessasus spessasus added wontfix This will not be worked on and removed question Further information is requested labels Oct 10, 2024
@spessasus spessasus pinned this issue Oct 18, 2024
@spessasus
Copy link
Owner

I'll keep this issue open until (hopefully) the Chromium bug is fixed.

@henrikvilhelmberglund
Copy link

I had a similar issue caused by not calling context.resume() on user input. In my case I have a playable keyboard instrument, on load it didn't make any sound, only when changing instruments the context would automatically resume and play all of the input sounds at once. Adding context.resume() in the event handlers (before trying to play notes) fixed the issue.

It sounds a bit weird though that SpessaSynth plays back the MIDI at the same time as preloading, shouldn't this be two steps? Are there any tips for implementing this? (actually load the soundfont before attempting playback)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants