Skip to content

Commit

Permalink
Incomplete workaround for issue 1068
Browse files Browse the repository at this point in the history
  • Loading branch information
derselbst committed Mar 10, 2022
1 parent 22144a4 commit ef1f409
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
28 changes: 6 additions & 22 deletions src/synth/fluid_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fluid_mod_get_source_value(const unsigned char mod_src,
}
else if(mod_src == PORTAMENTO_CTRL)
{
// an invalid portamento fromkey should be treated as 0 when it's actually used for moulating
// an invalid portamento fromkey should be treated as 0 when it's actually used for modulating
if(!fluid_channel_is_valid_note(val))
{
val = 0;
Expand Down Expand Up @@ -390,18 +390,14 @@ fluid_mod_transform_source_value(fluid_real_t val, unsigned char mod_flags, cons
*
* Output = Amount * Map(primary source input) * Map(secondary source input)
*
* 2)When primary source input (src1) is set to General Controller 'No Controller',
* output is forced to 0.
*
* 3)When secondary source input (src2) is set to General Controller 'No Controller',
* output is forced to +1.0
* 2) When a source is set to FLUID_MOD_NONE, its input value is treated as +1.0
*/
fluid_real_t
fluid_mod_get_value(fluid_mod_t *mod, fluid_voice_t *voice)
{
extern fluid_mod_t default_vel2filter_mod;

fluid_real_t v1 = 0.0, v2 = 1.0;
fluid_real_t v1, v2;
fluid_real_t range1 = 127.0, range2 = 127.0;

/* 'special treatment' for default controller
Expand Down Expand Up @@ -441,38 +437,26 @@ fluid_mod_get_value(fluid_mod_t *mod, fluid_voice_t *voice)
// end S. Christian Collins' mod

/* get the initial value of the first source */
if(mod->src1 > 0)
if(mod->src1 > FLUID_MOD_NONE)
{
v1 = fluid_mod_get_source_value(mod->src1, mod->flags1, &range1, voice);

/* transform the input value */
v1 = fluid_mod_transform_source_value(v1, mod->flags1, range1);
}
/* When primary source input (src1) is set to General Controller 'No Controller',
output is forced to 0.0
*/
else
{
return 0.0;
}

/* no need to go further */
if(v1 == 0.0f)
{
return 0.0f;
v1 = 1.0f;
}

/* get the second input source */
if(mod->src2 > 0)
if(mod->src2 > FLUID_MOD_NONE)
{
v2 = fluid_mod_get_source_value(mod->src2, mod->flags2, &range2, voice);

/* transform the second input value */
v2 = fluid_mod_transform_source_value(v2, mod->flags2, range2);
}
/* When secondary source input (src2) is set to General Controller 'No Controller',
output is forced to +1.0
*/
else
{
v2 = 1.0f;
Expand Down
5 changes: 1 addition & 4 deletions src/synth/fluid_voice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ fluid_voice_get_lower_boundary_for_attenuation(fluid_voice_t *voice)
3)absolute value of amount.
When at least one source mapping is bipolar:
min_val is -|amount| regardless the sign of amount.
min_val is -|amount| regardless the sign of amount.
When both sources mapping are unipolar:
min_val is -|amount|, if amount is negative.
min_val is 0, if amount is positive
Expand Down Expand Up @@ -1833,9 +1833,6 @@ fluid_voice_get_lower_boundary_for_attenuation(fluid_voice_t *voice)
return lower_bound;
}




int fluid_voice_set_param(fluid_voice_t *voice, int gen, fluid_real_t nrpn_value)
{
voice->gen[gen].nrpn = nrpn_value;
Expand Down

3 comments on commit ef1f409

@jjceresa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention the case where both src1 and src2 are set to FLUID_MOD_NONE`.
In this case the function fluid_mod_get_value() must return 0.0f (not 1.0f !).

@jjceresa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the function fluid_mod_get_value() must return 0.0f (not 1.0f !).

Yet another typo mistake.

In this case the function fluid_mod_get_value() must return 0.0f (not 1.0f x amount !).

@davy7125
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention the case where both src1 and src2 are set to FLUID_MOD_NONE`. In this case the function fluid_mod_get_value() must return 0.0f (not 1.0f !).

According to the specifications and to my understanding, if "no controller" is set in src1 or src2, this shouldn't cancel the modulator. So the result of 1 by 1 is still 1, not a special case in which 0 is returned.

Capture d’écran du 2023-07-17 16-17-30

Please sign in to comment.