Skip to content

Commit 5dcae73

Browse files
committed
Merge branch '2.2.x' into master
2 parents 2715e4b + 8784dbb commit 5dcae73

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

Diff for: src/rvoice/fluid_adsr_env.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct _fluid_env_data_t
3737
};
3838

3939
/* Indices for envelope tables */
40-
enum fluid_voice_envelope_index_t
40+
enum fluid_voice_envelope_index
4141
{
4242
FLUID_VOICE_ENVDELAY,
4343
FLUID_VOICE_ENVATTACK,
@@ -49,22 +49,22 @@ enum fluid_voice_envelope_index_t
4949
FLUID_VOICE_ENVLAST
5050
};
5151

52-
typedef enum fluid_voice_envelope_index_t fluid_adsr_env_section_t;
52+
typedef enum fluid_voice_envelope_index fluid_adsr_env_section_t;
5353

5454
typedef struct _fluid_adsr_env_t fluid_adsr_env_t;
5555

5656
struct _fluid_adsr_env_t
5757
{
5858
fluid_env_data_t data[FLUID_VOICE_ENVLAST];
5959
unsigned int count;
60-
int section;
6160
fluid_real_t val; /* the current value of the envelope */
61+
fluid_adsr_env_section_t section;
6262
};
6363

6464
/* For performance, all functions are inlined */
6565

6666
static FLUID_INLINE void
67-
fluid_adsr_env_calc(fluid_adsr_env_t *env, int is_volenv)
67+
fluid_adsr_env_calc(fluid_adsr_env_t *env)
6868
{
6969
fluid_env_data_t *env_data;
7070
fluid_real_t x;
@@ -76,7 +76,8 @@ fluid_adsr_env_calc(fluid_adsr_env_t *env, int is_volenv)
7676
{
7777
// If we're switching envelope stages from decay to sustain, force the value to be the end value of the previous stage
7878
// Hmm, should this only apply to volenv? It was so before refactoring, so keep it for now. [DH]
79-
if(env->section == FLUID_VOICE_ENVDECAY && is_volenv)
79+
// No, must apply to both, otherwise some voices may sound detuned. [TM] (https://github.com/FluidSynth/fluidsynth/issues/1059)
80+
if(env->section == FLUID_VOICE_ENVDECAY)
8081
{
8182
env->val = env_data->min * env_data->coeff;
8283
}
@@ -106,8 +107,6 @@ fluid_adsr_env_calc(fluid_adsr_env_t *env, int is_volenv)
106107
}
107108

108109
env->val = x;
109-
110-
111110
}
112111

113112
/* This one cannot be inlined since it is referenced in
@@ -118,7 +117,7 @@ static FLUID_INLINE void
118117
fluid_adsr_env_reset(fluid_adsr_env_t *env)
119118
{
120119
env->count = 0;
121-
env->section = 0;
120+
env->section = FLUID_VOICE_ENVDELAY;
122121
env->val = 0.0f;
123122
}
124123

Diff for: src/rvoice/fluid_rvoice.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ fluid_rvoice_write(fluid_rvoice_t *voice, fluid_real_t *dsp_buf)
331331

332332
/******************* vol env **********************/
333333

334-
fluid_adsr_env_calc(&voice->envlfo.volenv, 1);
334+
fluid_adsr_env_calc(&voice->envlfo.volenv);
335335
fluid_check_fpe("voice_write vol env");
336336

337337
if(fluid_adsr_env_get_section(&voice->envlfo.volenv) == FLUID_VOICE_ENVFINISHED)
@@ -341,7 +341,7 @@ fluid_rvoice_write(fluid_rvoice_t *voice, fluid_real_t *dsp_buf)
341341

342342
/******************* mod env **********************/
343343

344-
fluid_adsr_env_calc(&voice->envlfo.modenv, 0);
344+
fluid_adsr_env_calc(&voice->envlfo.modenv);
345345
fluid_check_fpe("voice_write mod env");
346346

347347
/******************* lfo **********************/

Diff for: src/synth/fluid_synth.c

+6
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,10 @@ fluid_synth_remove_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod)
15571557

15581558
/**
15591559
* Send a MIDI controller event on a MIDI channel.
1560+
*
1561+
* Most CCs are 7-bits wide in FluidSynth. There are a few exceptions which may be 14-bits wide as are documented here:
1562+
* https://github.com/FluidSynth/fluidsynth/wiki/FluidFeatures#midi-control-change-implementation-chart
1563+
*
15601564
* @param synth FluidSynth instance
15611565
* @param chan MIDI channel number (0 to MIDI channel count - 1)
15621566
* @param num MIDI controller number (0-127)
@@ -1571,6 +1575,8 @@ fluid_synth_remove_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod)
15711575
* could be used as CC global for all channels belonging to basic channel 7.
15721576
* - Let a basic channel 0 in mode 3. If MIDI channel 15 is disabled it could be used
15731577
* as CC global for all channels belonging to basic channel 0.
1578+
* @warning Contrary to the MIDI Standard, this function does not clear LSB controllers,
1579+
* when MSB controllers are received.
15741580
*/
15751581
int
15761582
fluid_synth_cc(fluid_synth_t *synth, int chan, int num, int val)

Diff for: src/synth/fluid_voice.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,9 @@ fluid_voice_update_param(fluid_voice_t *voice, int gen)
11101110
/* Modulation envelope */
11111111
case GEN_MODENVDELAY: /* SF2.01 section 8.1.3 # 25 */
11121112
fluid_clip(x, -12000.0f, 5000.0f);
1113+
count = NUM_BUFFERS_DELAY(x);
11131114
fluid_voice_update_modenv(voice, TRUE, FLUID_VOICE_ENVDELAY,
1114-
NUM_BUFFERS_DELAY(x), 0.0f, 0.0f, -1.0f, 1.0f);
1115+
count, 0.0f, 0.0f, -1.0f, 1.0f);
11151116
break;
11161117

11171118
case GEN_MODENVATTACK: /* SF2.01 section 8.1.3 # 26 */

0 commit comments

Comments
 (0)