mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-17 13:19:09 +00:00
chorus: avoid overwriting input buffer when storing samples in the delay line.
In `fluid_rvoice_mixer.c`:`fluid_rvoice_mixer_process_fx()`: If an audio processing callback is used, `mix_fx_to_out` would be `FALSE`. As a result, `in_ch` and `out_ch_l` points to the same buffer. In `fluid_chorus.c`:`fluid_chorus_processreplace()`: ```C /* process stereo unit */ /* store the chorus stereo unit d_out to left and right output */ left_out[sample_index] = d_out[0] * chorus->wet1 + d_out[1] * chorus->wet2; right_out[sample_index] = d_out[1] * chorus->wet1 + d_out[0] * chorus->wet2; /* Write the current input sample into the circular buffer */ push_in_delay_line(chorus, in[sample_index]); ``` Here the chorus processing code writes to the left output buffer (which will overwrite the input buffer in this case) before the sample from the input buffer is stored into the delay buffer, making the chorus output all zeros. If no audio processing callback is used, `mix_fx_to_out` would be `TRUE` and `in` and `left_out` will not point to the same buffer, therefore the order doesn't matter. Simply swapping the two steps should be a sufficient fix. This patch also apply the same change to `fluid_chorus_processmix` only for the sake of consistency (since they are almost exact copies of each other). Resolves #751.
This commit is contained in:
parent
fd9bf6a6b0
commit
8e9d361651
1 changed files with 6 additions and 6 deletions
|
@ -980,13 +980,13 @@ void fluid_chorus_processmix(fluid_chorus_t *chorus, const fluid_real_t *in,
|
|||
d_out[1] += out ;
|
||||
}
|
||||
|
||||
/* Write the current input sample into the circular buffer */
|
||||
push_in_delay_line(chorus, in[sample_index]);
|
||||
|
||||
/* process stereo unit */
|
||||
/* Add the chorus stereo unit d_out to left and right output */
|
||||
left_out[sample_index] += d_out[0] * chorus->wet1 + d_out[1] * chorus->wet2;
|
||||
right_out[sample_index] += d_out[1] * chorus->wet1 + d_out[0] * chorus->wet2;
|
||||
|
||||
/* Write the current input sample into the circular buffer */
|
||||
push_in_delay_line(chorus, in[sample_index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1052,12 +1052,12 @@ void fluid_chorus_processreplace(fluid_chorus_t *chorus, const fluid_real_t *in,
|
|||
d_out[1] += out ;
|
||||
}
|
||||
|
||||
/* Write the current input sample into the circular buffer */
|
||||
push_in_delay_line(chorus, in[sample_index]);
|
||||
|
||||
/* process stereo unit */
|
||||
/* store the chorus stereo unit d_out to left and right output */
|
||||
left_out[sample_index] = d_out[0] * chorus->wet1 + d_out[1] * chorus->wet2;
|
||||
right_out[sample_index] = d_out[1] * chorus->wet1 + d_out[0] * chorus->wet2;
|
||||
|
||||
/* Write the current input sample into the circular buffer */
|
||||
push_in_delay_line(chorus, in[sample_index]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue