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

Fix modLfoToVol behavior #1377

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/utils/fluid_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,20 @@ fluid_cb2amp(fluid_real_t cb)
*/

/* minimum attenuation: 0 dB */
if(cb < 0)
if(FLUID_UNLIKELY(cb < 0))
{
return 1.0;
/* Issue #1374: it seems that by using modLfoToVolEnv, the attenuation can become negative and
* therefore the signal needs to be amplified.
* In such a rare case, calculate the attenuation on the fly.
*
* This behavior is backed by the spec saying:
* modLfoToVolume: "A positive number indicates a positive LFO excursion increases volume;
* a negative number indicates a positive excursion decreases volume.
* [...] For example, a value of 100 indicates that the volume will first rise ten dB, then fall ten dB."
*
* And in order to rise, a negative attenuation must be permitted.
*/
return FLUID_POW(10.0f, cb / -200.0f);
}

if(cb >= FLUID_CB_AMP_SIZE)
Expand Down
Loading