mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Use absolute centibels for range of balance generator
This commit is contained in:
parent
52cc645e7e
commit
2e4a517a3f
3 changed files with 6 additions and 10 deletions
|
@ -86,7 +86,7 @@ static const fluid_gen_info_t fluid_gen_info[] = {
|
|||
{ GEN_EXCLUSIVECLASS, 0, 0, 0.0f, 0.0f, 0.0f },
|
||||
{ GEN_OVERRIDEROOTKEY, 1, 0, 0.0f, 127.0f, -1.0f },
|
||||
{ GEN_PITCH, 1, 0, 0.0f, 127.0f, 0.0f },
|
||||
{ GEN_BALANCE, 1, 0, -1000.0f, 1000.0f, 0.0f }
|
||||
{ GEN_BALANCE, 1, 0, -960.0f, 960.0f, 0.0f }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -414,13 +414,14 @@ fluid_synth_init(void)
|
|||
/* Non-standard MIDI continuous controller 8 to channel stereo balance */
|
||||
fluid_mod_set_source1(&custom_balance_mod, BALANCE_MSB, /* Index=8 */
|
||||
FLUID_MOD_CC /* CC=1 */
|
||||
| FLUID_MOD_LINEAR /* type=0 */
|
||||
| FLUID_MOD_CONCAVE /* type=1 */
|
||||
| FLUID_MOD_BIPOLAR /* P=1 */
|
||||
| FLUID_MOD_POSITIVE /* D=0 */
|
||||
);
|
||||
fluid_mod_set_source2(&custom_balance_mod, 0, 0);
|
||||
fluid_mod_set_dest(&custom_balance_mod, GEN_BALANCE); /* Destination: stereo balance */
|
||||
fluid_mod_set_amount(&custom_balance_mod, 1000.0); /* Amount: 1000 tens of a percent */
|
||||
/* Amount: 96 dB of attenuation (on the opposite channel) */
|
||||
fluid_mod_set_amount(&custom_balance_mod, 960.0);
|
||||
}
|
||||
|
||||
static FLUID_INLINE unsigned int fluid_synth_get_ticks(fluid_synth_t* synth)
|
||||
|
|
|
@ -307,7 +307,7 @@ fluid_pan(fluid_real_t c, int left)
|
|||
* channel is attenuated. If balance is positive, only the left channel is
|
||||
* attenuated.
|
||||
*
|
||||
* @params balance left/right balance, range [-1000;1000] in tens of percent
|
||||
* @params balance left/right balance, range [-960;960] in absolute centibels
|
||||
* @return amount of attenuation [0.0;1.0]
|
||||
*/
|
||||
fluid_real_t fluid_balance(fluid_real_t balance, int left)
|
||||
|
@ -328,12 +328,7 @@ fluid_real_t fluid_balance(fluid_real_t balance, int left)
|
|||
balance = -balance;
|
||||
}
|
||||
|
||||
if (balance >= 1000)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return 1.0f - balance * 0.001f;
|
||||
return fluid_cb2amp(balance);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue