Merge pull request #251 from FluidSynth/polish

Some optimizations
This commit is contained in:
Tom M 2017-10-27 22:27:01 +02:00 committed by GitHub
commit 9c7b8f330d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -514,7 +514,7 @@ fluid_rvoice_noteoff(fluid_rvoice_t* voice, unsigned int min_ticks)
*/
if (fluid_adsr_env_get_val(&voice->envlfo.volenv) > 0){
fluid_real_t lfo = fluid_lfo_get_val(&voice->envlfo.modlfo) * -voice->envlfo.modlfo_to_vol;
fluid_real_t amp = fluid_adsr_env_get_val(&voice->envlfo.volenv) * pow (10.0, lfo / -200);
fluid_real_t amp = fluid_adsr_env_get_val(&voice->envlfo.volenv) * fluid_cb2amp(lfo);
fluid_real_t env_value = - ((-200 * log (amp) / log (10.0) - lfo) / 960.0 - 1);
fluid_clip (env_value, 0.0, 1.0);
fluid_adsr_env_set_val(&voice->envlfo.volenv, env_value);

View file

@ -1014,7 +1014,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
fluid_clip(x, -12000.0f, 8000.0f);
count = 1 + NUM_BUFFERS_ATTACK(x);
fluid_voice_update_volenv(voice, FLUID_VOICE_ENVATTACK,
count, 1.0f, count ? 1.0f / count : 0.0f, -1.0f, 1.0f);
count, 1.0f, 1.0f / count, -1.0f, 1.0f);
break;
case GEN_VOLENVHOLD: /* SF2.01 section 8.1.3 # 35 */
@ -1039,7 +1039,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
fluid_clip(x, FLUID_MIN_VOLENVRELEASE, 8000.0f);
count = 1 + NUM_BUFFERS_RELEASE(x);
fluid_voice_update_volenv(voice, FLUID_VOICE_ENVRELEASE,
count, 1.0f, count ? -1.0f / count : 0.0f, 0.0f, 1.0f);
count, 1.0f, -1.0f / count, 0.0f, 1.0f);
break;
/* Modulation envelope */
@ -1055,7 +1055,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
fluid_clip(x, -12000.0f, 8000.0f);
count = 1 + NUM_BUFFERS_ATTACK(x);
fluid_voice_update_modenv(voice, FLUID_VOICE_ENVATTACK,
count, 1.0f, count ? 1.0f / count : 0.0f, -1.0f, 1.0f);
count, 1.0f, 1.0f / count, -1.0f, 1.0f);
break;
case GEN_MODENVHOLD: /* SF2.01 section 8.1.3 # 27 */
@ -1080,7 +1080,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
fluid_clip(x, -12000.0f, 8000.0f);
count = 1 + NUM_BUFFERS_RELEASE(x);
fluid_voice_update_modenv(voice, FLUID_VOICE_ENVRELEASE,
count, 1.0f, count ? -1.0f / count : 0.0f, 0.0f, 2.0f);
count, 1.0f, -1.0f / count, 0.0f, 2.0f);
break;