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

32-bit float Rendering with Automatic Gain Control/Output Leveller on final stage #1302

Open
KynikossDragonn opened this issue Feb 2, 2024 · 0 comments

Comments

@KynikossDragonn
Copy link

Is your feature request related to a problem?

FluidSynth's "gain" is very variable depending on a myriad of possible situations; The programs in the Sound Font used being too loud over others; the MIDI setting Channel volumes very high overall or also playing voices with maximum volume/velocity. Clipping can end up happening at a moments notice and the only way around it is to manually adjust gain when it happens, and keep adjusting it until the clipping stops for that particular song. The gain might be too soft for one song but too loud for others.

Describe the solution you'd like

I feel like the best possible solution is if FluidSynth is rendering in a pure 32-bit floating point sample environment, something at the end of the rendering stage could dynamically soft-level the samples so that they don't clip/distort when finally mixed to 16-bit or 24-bit sample formats used by whatever sound hardware being used with FluidSynth. A automatic gain control/soft-leveler would allow one to just leave the "gain" variable at 1.0 without having to adjust it all the time. The dynamic range of the resulting audio will obviously suffer from this but I feel it's better than hard distortion and crackling that clipping results in.

OpenAL Soft has such a system in place that can be enabled with the output-limiter variable being set to true under [general] with a $HOME/.alsoftrc or alsoft.conf configuration file. OpenAL Soft also performs all audio rendering with 32-bit floating point samples. The output-limiter ensures that the amplitude of the resulting audio samples is low enough to not clip when finally output as 24-bit or 16-bit depending on the sound device.

This feature should also similarly to OpenAL Soft be a configurable option for users that do not need such automatic gain control/soft-leveling in instances the dynamic range of the audio needs to remain intact; e.g. for file rendering purposes.

Describe alternatives you've considered

I've experimented with running FluidSynth with a low gain value but having a process perform the leveling afterward, but if clipping still somehow happens, the clipping is still present. In addition; there's noticeable "hissing" because of quantization error from performing volume amplification+leveling already operating on samples being received in 16-bit in my particular use case.

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

No branches or pull requests

1 participant