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

Support SF2.04 absolute value modulators #1391

Closed
derselbst opened this issue Oct 3, 2024 · 5 comments · Fixed by #1409
Closed

Support SF2.04 absolute value modulators #1391

derselbst opened this issue Oct 3, 2024 · 5 comments · Fixed by #1409
Milestone

Comments

@derselbst
Copy link
Member

Related discussion

--

Is your feature request related to a problem?

Fluidsynth doesn't support absolute value modulator transforms. In fact, it actively disables them during loading:

/* *** Transform *** */
/* SF2.01 only uses the 'linear' transform (0).
* Deactivate the modulator by setting the amount to 0 in any other case.
*/
if(mod_src->trans != 0)
{
mod_dest->amount = 0;
}

Describe the solution you'd like

SF2.04 8.3:

The output value of the multiplier is to be the absolute value of the input value, as
defined by the relationship:

Describe alternatives you've considered

--

Additional context

--

Please upvote this issue if you're lacking this functionality.

@spessasus
Copy link
Contributor

Hi,

I'm sorry if I misunderstood something, but reading the SF spec isn't this just Math.abs of the value?

The output value of the multiplier is to be the absolute value of the input value, as
defined by the relationship:
output = square root ((input value)^2)

Square root of squared value is just abs of that value.

So making:

/* it's as simple as that: */
return (fluid_real_t) mod->amount * v1 * v2;

this:

if(mod-> trans == 2) return fabs((fluid_real_t) mod->amount * v1 * v2);
return (fluid_real_t) mod->amount * v1 * v2;

would implement it? Or am I reading the SFspec incorrectly?

@derselbst
Copy link
Member Author

Square root of squared value is just abs of that value.

Yes, that's also my understanding. I'm just wondering what would be the purpose / use-case behind this.

@derselbst
Copy link
Member Author

Implementing this would require to introduce a new field in the fluid_mod struct, which should also be modifiable via the API. Such an API change to the modulator API should be considered together with feature #1355.

@spessasus
Copy link
Contributor

Here's a test soundfont:
absolute value test.zip

NOTE: Rename .zip to .sf2, zip is so github will accept this

@spessasus
Copy link
Contributor

It works exactly like the I described above (tested on polyphone and spessasynth)

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

Successfully merging a pull request may close this issue.

2 participants