mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-19 07:50:49 +00:00
Updated fluid_ct2hz function. New fluid_ct2hz_real function which doesn't
apply filter fc limits that shouldn't be applied when determining the sample size.
This commit is contained in:
parent
800ca2ee2a
commit
c9193d8f81
3 changed files with 40 additions and 26 deletions
|
@ -92,6 +92,43 @@ fluid_conversion_config(void)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_ct2hz
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_ct2hz_real(fluid_real_t cents)
|
||||
{
|
||||
if (cents < 0)
|
||||
return (fluid_real_t) 1.0;
|
||||
else if (cents < 900) {
|
||||
return (fluid_real_t) 6.875 * fluid_ct2hz_tab[(int) (cents + 300)];
|
||||
} else if (cents < 2100) {
|
||||
return (fluid_real_t) 13.75 * fluid_ct2hz_tab[(int) (cents - 900)];
|
||||
} else if (cents < 3300) {
|
||||
return (fluid_real_t) 27.5 * fluid_ct2hz_tab[(int) (cents - 2100)];
|
||||
} else if (cents < 4500) {
|
||||
return (fluid_real_t) 55.0 * fluid_ct2hz_tab[(int) (cents - 3300)];
|
||||
} else if (cents < 5700) {
|
||||
return (fluid_real_t) 110.0 * fluid_ct2hz_tab[(int) (cents - 4500)];
|
||||
} else if (cents < 6900) {
|
||||
return (fluid_real_t) 220.0 * fluid_ct2hz_tab[(int) (cents - 5700)];
|
||||
} else if (cents < 8100) {
|
||||
return (fluid_real_t) 440.0 * fluid_ct2hz_tab[(int) (cents - 6900)];
|
||||
} else if (cents < 9300) {
|
||||
return (fluid_real_t) 880.0 * fluid_ct2hz_tab[(int) (cents - 8100)];
|
||||
} else if (cents < 10500) {
|
||||
return (fluid_real_t) 1760.0 * fluid_ct2hz_tab[(int) (cents - 9300)];
|
||||
} else if (cents < 11700) {
|
||||
return (fluid_real_t) 3520.0 * fluid_ct2hz_tab[(int) (cents - 10500)];
|
||||
} else if (cents < 12900) {
|
||||
return (fluid_real_t) 7040.0 * fluid_ct2hz_tab[(int) (cents - 11700)];
|
||||
} else if (cents < 14100) {
|
||||
return (fluid_real_t) 14080.0 * fluid_ct2hz_tab[(int) (cents - 12900)];
|
||||
} else {
|
||||
return (fluid_real_t) 1.0; /* some loony trying to make you deaf */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_ct2hz
|
||||
*/
|
||||
|
@ -103,32 +140,8 @@ fluid_ct2hz(fluid_real_t cents)
|
|||
cents = 13500; /* 20 kHz */
|
||||
} else if (cents < 1500){
|
||||
cents = 1500; /* 20 Hz */
|
||||
};
|
||||
if ((cents >= 6900) && (cents < 8100)) {
|
||||
return (fluid_real_t) 440.0 * fluid_ct2hz_tab[(int) (cents - 6900)];
|
||||
} else if ((cents >= 8100) && (cents < 9300)) {
|
||||
return (fluid_real_t) 880.0 * fluid_ct2hz_tab[(int) (cents - 8100)];
|
||||
} else if ((cents >= 5700) && (cents < 6900)) {
|
||||
return (fluid_real_t) 220.0 * fluid_ct2hz_tab[(int) (cents - 5700)];
|
||||
} else if ((cents >= 9300) && (cents < 10500)) {
|
||||
return (fluid_real_t) 1760.0 * fluid_ct2hz_tab[(int) (cents - 9300)];
|
||||
} else if ((cents >= 4500) && (cents < 5700)) {
|
||||
return (fluid_real_t) 110.0 * fluid_ct2hz_tab[(int) (cents - 4500)];
|
||||
} else if ((cents >= 10500) && (cents < 11700)) {
|
||||
return (fluid_real_t) 3520.0 * fluid_ct2hz_tab[(int) (cents - 10500)];
|
||||
} else if ((cents >= 3300) && (cents < 4500)) {
|
||||
return (fluid_real_t) 55.0 * fluid_ct2hz_tab[(int) (cents - 3300)];
|
||||
} else if ((cents >= 11700) && (cents < 12900)) {
|
||||
return (fluid_real_t) 7040.0 * fluid_ct2hz_tab[(int) (cents - 11700)];
|
||||
} else if ((cents >= 2100) && (cents < 3300)) {
|
||||
return (fluid_real_t) 27.5 * fluid_ct2hz_tab[(int) (cents - 2100)];
|
||||
} else if ((cents >= 12900) && (cents < 14100)) {
|
||||
return (fluid_real_t) 14080.0 * fluid_ct2hz_tab[(int) (cents - 12900)];
|
||||
} else if ((cents >= 900) && (cents < 2100)) {
|
||||
return (fluid_real_t) 13.75 * fluid_ct2hz_tab[(int) (cents - 900)];
|
||||
} else {
|
||||
return (fluid_real_t) 1.0; /* some loony trying to make you deaf */
|
||||
}
|
||||
return fluid_ct2hz_real(cents);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
void fluid_conversion_config(void);
|
||||
|
||||
fluid_real_t fluid_ct2hz_real(fluid_real_t cents);
|
||||
fluid_real_t fluid_ct2hz(fluid_real_t cents);
|
||||
fluid_real_t fluid_cb2amp(fluid_real_t cb);
|
||||
fluid_real_t fluid_atten2amp(fluid_real_t atten);
|
||||
|
|
|
@ -587,7 +587,7 @@ fluid_voice_write(fluid_voice_t* voice,
|
|||
* through the original waveform with each step in the output
|
||||
* buffer. It is the ratio between the frequencies of original
|
||||
* waveform and output waveform.*/
|
||||
incr = fluid_ct2hz(voice->pitch
|
||||
incr = fluid_ct2hz_real(voice->pitch
|
||||
+ voice->modlfo_val * voice->modlfo_to_pitch
|
||||
+ voice->viblfo_val * voice->viblfo_to_pitch
|
||||
+ voice->modenv_val * voice->modenv_to_pitch) / voice->root_pitch;
|
||||
|
|
Loading…
Reference in a new issue