Skip to content

Fix Sf2 Player's reverb and chorus effects - #8274

Closed
jlintgod1 wants to merge 4 commits into
LMMS:masterfrom
jlintgod1:sf2-effects-fix
Closed

Fix Sf2 Player's reverb and chorus effects#8274
jlintgod1 wants to merge 4 commits into
LMMS:masterfrom
jlintgod1:sf2-effects-fix

Conversation

@jlintgod1

Copy link
Copy Markdown
Contributor

This PR fixes Sf2 Player's built in reverb and chorus effects not working with most soundfonts by automatically setting some MIDI controllers that control them (controllers 91 and 93). From what I looked at in the SoundFont specification, controllers 91 and 93 add to soundfont generators/parameters for reverb and chorus effect sends. Some of the soundfonts I looked at (i.e. just the SGM soundfont) don't have anything set for those generators, resulting in a default value of 0 and no audio being sent or processed by any effects.

I typically use separate audio effects for reverb and chorus, but I think it's still useful for beginners who might not know about them yet (and see the ones in Sf2 Player).

Some other notes (might out of scope for this PR?)

  • I was thinking of changing the tooltips for the reverb and chorus buttons to remove "(if supported)", since the effects work for a lot of the soundfonts I tried (some general MIDI soundfonts, a few game soundfonts, and even some of my custom ones), but I'm not sure if there are still soundfonts that don't work with effects.
  • Chorus (at least from a first glance) works only when the voices parameter is 2 or greater. The parameter could be clamped to 2, but I don't know how it would affect older projects if it was set to 0 or 1.

@Monospace-V

Monospace-V commented Feb 21, 2026

Copy link
Copy Markdown
Member

Other than that this will probably break backward compatibility (I have absolutely made projects using the parameters assuming that they worked and failed to disable when they didn't, and I'm certain others have too, we will probably have to fix that), I do have a query.
I was under the impression that for soundfonts that have reverb and chorus enabled, they are specifically set up in the soundfont, Perhaps with particular parameters or a different audio file. Or is this just a normal audio effect with only the controls accessible to us apply?

@jlintgod1

Copy link
Copy Markdown
Contributor Author

Other than that this will probably break backward compatibility (I have absolutely made projects using the parameters assuming that they worked and failed to disable when they didn't, and I'm certain others have too, we will probably have to fix that),

I didn't consider this, and I think it also brings up the question of how to handle it if someone had an effect enabled and it just happened to work for their soundfont.

I was under the impression that for soundfonts that have reverb and chorus enabled, they are specifically set up in the soundfont, Perhaps with particular parameters or a different audio file. Or is this just a normal audio effect with only the controls accessible to us apply?

From what I found in Polyphone (and probably the SoundFont specification too), the only control that a soundfont has (outside a file/sample with the effect baked in) is one generator/parameter for each effect to control the percentage of each effect. All of the other parameters for an effect (like reverb damping and amount of chorus voices) are within the program/player playing the soundfont (in this case, the Fluidsynth library used by Sf2 Player), rather than the soundfont itself. So they're actually just audio effects built into Sf2 Player, with the soundfont determining the effect amount.

Not sure if it makes sense or if it's actually how it works though.

@Monospace-V

Copy link
Copy Markdown
Member

From what I found in Polyphone (and probably the SoundFont specification too), the only control that a soundfont has (outside a file/sample with the effect baked in) is one generator/parameter for each effect to control the percentage of each effect. All of the other parameters for an effect (like reverb damping and amount of chorus voices) are within the program/player playing the soundfont (in this case, the Fluidsynth library used by Sf2 Player), rather than the soundfont itself. So they're actually just audio effects built into Sf2 Player, with the soundfont determining the effect amount.

Not sure if it makes sense or if it's actually how it works though.

https://discord.com/channels/203559236729438208/203559236729438208/1475444249955667998
Further information regarding this point (I asked a user who makes soundfonts). Looks like reverb dimension layers are possible with audio files, and there's some context on how reverb can be done too.

@jlintgod1

Copy link
Copy Markdown
Contributor Author

https://discord.com/channels/203559236729438208/203559236729438208/1475444249955667998
Further information regarding this point (I asked a user who makes soundfonts). Looks like reverb dimension layers are possible with audio files, and there's some context on how reverb can be done too.

Thanks for the information (and a explanation more concise than mine)! With this in mind though, I might add some new modes for reverb/chorus effects to better support Soundfonts that already have reverb effects. The four I have in mind:

  • Off: Self explanatory
  • On (idk what to name this): Enables Fluidsynth's built-in effect, for Soundfonts that have an effect generator/parameter pre-set
  • Controller Only: Only the MIDI controller for the effect is set, for Soundfonts that have an audio file for an effect (what you looked into)
  • Forced: Fluidsynth's built-in effect is enabled and the effect MIDI controller is set, for most other Soundfonts that don't have any effect defaults

If you or anyone else has any other feedback (before I think about adding it in), feel free to bring it up.

@Monospace-V

Monospace-V commented Feb 24, 2026

Copy link
Copy Markdown
Member

I'm not entirely sure how it works, and it's possible some have fluidsynth's inbuilt set available for enabling as you mentioned.
The only thing I hope for from this is backward compatibility, so you'll need to check that things that don't have a parameter available but have the parameter on are switched off in this process.
To give an understanding of how rarely I've found reverb and chorus in a soundfont, it is more likely for a user to have reverb and chorus on and non-functional than on and functional. I hope it should be simple to check if it's unavailable, and LMMS can toggle it off by default when loading a project from a commit earlier to yours.

Added check to ensure older projects with effects enabled don't sound different (by disabling said effects). Additional TODO notes are in DataFile.
@Monospace-V

Copy link
Copy Markdown
Member

Does your commit run a backward compatibility check, or does it universally turn it off?

@jlintgod1

Copy link
Copy Markdown
Contributor Author

Does your commit run a backward compatibility check, or does it universally turn it off?

Currently (through a new upgrade function) it checks if the project was saved in an older version, and if it is, it turns off reverb and chorus for any Sf2 Players that have it enabled and notifies the user:
2026-02-27_11-49
It will not disable effects if the project was saved with this PR.

I did have plans to check for a default reverb/chorus parameter in a Soundfont, but I wasn't able to find a way to get it. I either found functions that only got an offset (which is always be 0 for newly loaded Sf2 Players) or functions that only work for currently active voices (which requires a note event/voice to exist).

@Monospace-V

Copy link
Copy Markdown
Member

This is not backward compatibility.
I am not comfortable with this PR's approach to this problem.
Why not ask in the discord to see if any other dev can help you with this?
Also, we generally avoid extra pop-ups.

@rubiefawn

Copy link
Copy Markdown
Contributor

Backwards compatibility is tricky here because this has been a problem for a very long time. If there is a reasonable way on project load to detect if a soundfont was previously broken and saved in an old version, then the chorus/reverb parameters should be silently set to 0 to preserve the project's behavior. If there is no reasonable way to detect this (which sounds like it might be the case), then backwards compatibility might be more trouble than it's worth, and users can either turn their chorus & reverb off or load their project in an older version of LMMS.

@jlintgod1

Copy link
Copy Markdown
Contributor Author

Honestly, the whole problem of getting this to work with old projects and various different SoundFonts has kinda made it difficult for me to continue working on this PR, and it's made me contemplate whether it should be fixed at all (especially if I'm approaching it incorrectly and there's if there's no other solution for backwards compatibility).

I did randomly think of an alternate solution that involves setting the MIDI controllers directly within LMMS (through the MIDI CC rack) when reverb/chorus is toggled, but I don't know if an instrument can and should be allowed to do that. Not to mention it would also require a fix that actually sends the controllers from the rack to Fluidsynth (they currently aren't).

I might ask more about this on the Discord (but not now because college is scary!!) because I don't want to try implementing something that could be even more iffy than what I already had.

jlintgod1 and others added 2 commits April 12, 2026 18:08
I was initially going to have everything in Sf2Player, but I didn't know (until now) if other instruments had version checks when loading/saving settings.

There is still no check for default reverb/chorus parameters since there doesn't seem to be a good way to determine them (within Fluidsynth) without janky workarounds.
@jlintgod1
jlintgod1 marked this pull request as draft April 13, 2026 00:53
@messmerd messmerd added the bug label May 2, 2026
@jlintgod1 jlintgod1 closed this Jul 20, 2026
@jlintgod1

Copy link
Copy Markdown
Contributor Author

This was randomly closed (see #8448 (comment) for why), but I've been thinking of closing this for a while. There's still some problems with keeping it backwards compatible with older projects and whole bunch of other alternatives I need to consider. I've also been thinking of actually making a PR for #8437, which would at least allow the user to force-enable reverb/chorus if they need it. It also relates to my previous comment/idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants