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

Some sf2s ignore sustain #22

Closed
DaforLynx opened this issue Nov 15, 2020 · 6 comments · Fixed by #35
Closed

Some sf2s ignore sustain #22

DaforLynx opened this issue Nov 15, 2020 · 6 comments · Fixed by #35

Comments

@DaforLynx
Copy link

Sorry for the bother again, but I'm hoping you can help me figure out an issue. It's almost certainly something I'm doing wrong, but it's also partly unique to this software. Some soundfonts ignore sustain, cutting out instead of holding. The first of the links below should lead to a download of such a soundfont. The second one is a soundfont that simply refuses to show up. Both of them work normally in almost every other program I've tried (including Musescore, DSK SF2, and sforzando), except for Ardour's Fluid Synth. This happens with all my ripped soundfonts. I've compared working instruments to non-working ones, trying to get all the parameters to match in Polyphone, but still the problem persists. In the third soundfont, the piano works fine (except one of the samples is looped weirdly in JuicySF) but the rest of the instruments cut off like usual.

https://www.dropbox.com/s/5yivcyiyhwawdxn/DPPt.sf2?dl=0
https://www.dropbox.com/s/qkb3u7q5znxxo83/Pok%C3%A9mon%20Diamond_Pearl_Platinum%20Soundfont%20compiled.sf2?dl=0
https://www.dropbox.com/s/0gqcmlg94hdae1f/SEQ_BGM_VS_RS_LEADER.sf2?dl=0

@Birch-san
Copy link
Owner

Birch-san commented Nov 15, 2020

Thanks for the repro. I think I experience the same problem on those soundfonts.
I have to confess I've never delved into "how soundfonts are made", and don't know much about how sustain is implemented in soundfonts (maybe there's clues in the SoundFont 2.04 spec).

juicysfplugin implements sustain by forwarding MIDI CC 64 messages to fluidsynth:
https://github.com/Birch-san/juicysfplugin/blob/9d39d3c/Source/FluidSynthModel.cpp#L330
I do this the same way regardless of which soundfont is used. On the basis that it works for a known-good soundfont (e.g. FatBoy), it's reasonably likely juicysfplugin is doing the right thing.

fluidsynth handles the continuous controller message like this:
https://github.com/FluidSynth/fluidsynth/blob/109c41c355e120ea18d68e8153d17059af765660/src/synth/fluid_synth.c#L1505

If you're experiencing a problem with how sustain is synthesized, then that's either a problem in how the soundfont file was created, or a problem in how fluidsynth synthesizes the audio.

I've checked the changelogs for fluidsynth. I'm not sure which version of 2.xx I used for Windows, but I don't see any changes to how sustain was implemented in the last couple of years. So I think it's not a "bug that could be fixed by updating".

Fluidsynth is a pretty good synthesizer, so my guess is that the problem lies with how the soundfont was created.

@DaforLynx
Copy link
Author

UPDATE: I've found out why those soundfonts don't sustain.

Actually, it's not a problem with the sustain at all. The samples simply don't loop. Here's why:

In Polyphone, I can set either a "sample loop" or use "loop start offset" and "loop end offset" with no loop set in the sample. In programs like sforzando which converts the sf2 data to its own format directly, these are essentially the same thing. In Polyphone, the sound plays normally.

However, it seems they are treated differently in fluidsynth. Or rather that the loop offset parameters are completely ignored even if no loop is set.

The program I used to generate the soundfonts, for some reason, transfers the loop data to the loop offsets rather than the sample loops, for every looping sound. Hence why all the soundfonts that come out of that program don't work properly with JuicySF or even Ardour's implementation of fluidsynth.

I will take a look at fluidsynth to see if that issue is fixed, and if not I'll file an issue with them, because I don't think juicysf has anything to do with it.

@Birch-san
Copy link
Owner

oh awesome; great detective work.

if you have access to a Mac: I've built juicysfplugin with the latest release (2.2.4) of fluidsynth, if that's a convenient way to test their capabilities:
https://github.com/Birch-san/juicysfplugin/releases/tag/3.0.0.macOS

@DaforLynx
Copy link
Author

DaforLynx commented Jan 4, 2022

I don't have a Mac. But it doesn't matter, because I'm running the latest version of fluidsynth from console and it's having the exact same problems. Definitely an issue with it. I'll let you know when the issue gets addressed.

Edit: here's the issue FluidSynth/fluidsynth#1017

@DaforLynx
Copy link
Author

FluidSynth/fluidsynth#1018

Update: the issue should be fixed in version 2.2.5, whenever that releases.

@Birch-san
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants