From 154074326fdfaa325d469ed006f8a076cdabea50 Mon Sep 17 00:00:00 2001 From: Peter Hanappe Date: Wed, 25 Feb 2004 22:57:18 +0000 Subject: [PATCH] Fixed bug in volume envelope (in fluid_voice_update_param(), case GEN_VOLENVDECAY): the minimum value was converted to linear amplitude instead of a normalized value of the cB (1-cB/1000). Because of that, the decay section went on for too long. --- fluidsynth/src/fluid_cmd.c | 1 - fluidsynth/src/fluid_voice.c | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fluidsynth/src/fluid_cmd.c b/fluidsynth/src/fluid_cmd.c index 5051e890..87c410b1 100644 --- a/fluidsynth/src/fluid_cmd.c +++ b/fluidsynth/src/fluid_cmd.c @@ -328,7 +328,6 @@ fluid_source(fluid_cmd_handler_t* handler, char* filename) if (file < 0) { return file; } - fluid_shell_init(&shell, NULL, handler, file, fluid_get_stdout()); return fluid_shell_run(&shell); } diff --git a/fluidsynth/src/fluid_voice.c b/fluidsynth/src/fluid_voice.c index 3a5a66fc..dc971fc6 100644 --- a/fluidsynth/src/fluid_voice.c +++ b/fluidsynth/src/fluid_voice.c @@ -960,7 +960,7 @@ fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) * example, the pitch depends on GEN_COARSETUNE, GEN_FINETUNE and * GEN_PITCH. voice->pitch. Unnecessary recalculation is avoided * by removing all but one generator from the list of voice - * parameters. Same with GEN_XXX and GEN_XXXCOARSE: the + * parameters. Same with GEN_XXX and GEN_XXXCOARSE: the * initialisation list contains only GEN_XXX. */ @@ -1338,7 +1338,8 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_VOLENVDELAY: /* SF2.01 section 8.1.3 # 33 */ x = _GEN(voice, GEN_VOLENVDELAY); fluid_clip(x, -12000.0f, 5000.0f); - voice->volenv_data[FLUID_VOICE_ENVDELAY].count = NUM_BUFFERS_DELAY(x); + count = NUM_BUFFERS_DELAY(x); + voice->volenv_data[FLUID_VOICE_ENVDELAY].count = count; voice->volenv_data[FLUID_VOICE_ENVDELAY].coeff = 0.0f; voice->volenv_data[FLUID_VOICE_ENVDELAY].incr = 0.0f; voice->volenv_data[FLUID_VOICE_ENVDELAY].min = -1.0f; @@ -1369,12 +1370,13 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_VOLENVDECAY: /* SF2.01 section 8.1.3 # 36 */ case GEN_VOLENVSUSTAIN: /* SF2.01 section 8.1.3 # 37 */ case GEN_KEYTOVOLENVDECAY: /* SF2.01 section 8.1.3 # 40 */ + y = 1.0f - 0.001f * _GEN(voice, GEN_VOLENVSUSTAIN); + fluid_clip(y, 0.0f, 1.0f); count = calculate_hold_decay_buffers(voice, GEN_VOLENVDECAY, GEN_KEYTOVOLENVDECAY, 1); /* 1 for decay */ voice->volenv_data[FLUID_VOICE_ENVDECAY].count = count; voice->volenv_data[FLUID_VOICE_ENVDECAY].coeff = 1.0f; voice->volenv_data[FLUID_VOICE_ENVDECAY].incr = count ? -1.0f / count : 0.0f; - /* fluid_cb2amp checks the range */ - voice->volenv_data[FLUID_VOICE_ENVDECAY].min = fluid_cb2amp(_GEN(voice, GEN_VOLENVSUSTAIN)); + voice->volenv_data[FLUID_VOICE_ENVDECAY].min = y; voice->volenv_data[FLUID_VOICE_ENVDECAY].max = 2.0f; break;