Skip to content

Fix Sf2 Player's reverb and chorus effects#8274

Open
jlintgod1 wants to merge 2 commits intoLMMS:masterfrom
jlintgod1:sf2-effects-fix
Open

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

Conversation

@jlintgod1
Copy link

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

Monospace-V commented Feb 21, 2026

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

Monospace-V commented Feb 24, 2026

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
Member

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

@jlintgod1
Copy link
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
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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants