mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-31 13:40:35 +00:00
Mapping of fx unit output to dry buffers in mix mode. (#668)
Currently, all fx unit output (in mix mode) are mapped to the `first buffer`. This is not appropriate for synth.audio-groups > 1 This PR allows the mapping of fx output based on `fx unit index` and `synth.audio-groups` value. This allows us to get the `fx output `mixed to the respective `buffer` on which a `MIDI channel` is mapped. For example: with `synth.audio-groups = 3` and `synth.effect-groups = 3`: - MIDI chan 0 (dry + fx0) is mapped to buf 0 - MIDI chan 1 (dry + fx1) is mapped to buf 1 - MIDI chan 2 (dry + fx2) is mapped to buf 2
This commit is contained in:
parent
7834c4eb62
commit
57af8803f2
1 changed files with 27 additions and 11 deletions
|
@ -125,6 +125,8 @@ fluid_rvoice_mixer_process_fx(fluid_rvoice_mixer_t *mixer, int current_blockcoun
|
|||
{
|
||||
const int fx_channels_per_unit = mixer->buffers.fx_buf_count / mixer->fx_units;
|
||||
int i, f;
|
||||
int dry_count = mixer->buffers.buf_count; /* dry buffers count */
|
||||
int dry_idx; /* dry buffer index */
|
||||
|
||||
void (*reverb_process_func)(fluid_revmodel_t *rev, const fluid_real_t *in, fluid_real_t *left_out, fluid_real_t *right_out);
|
||||
void (*chorus_process_func)(fluid_chorus_t *chorus, const fluid_real_t *in, fluid_real_t *left_out, fluid_real_t *right_out);
|
||||
|
@ -164,15 +166,22 @@ fluid_rvoice_mixer_process_fx(fluid_rvoice_mixer_t *mixer, int current_blockcoun
|
|||
for(f = 0; f < mixer->fx_units; f++)
|
||||
{
|
||||
int buf_idx = f * fx_channels_per_unit + SYNTH_REVERB_CHANNEL;
|
||||
|
||||
for(i = 0; i < current_blockcount * FLUID_BUFSIZE; i += FLUID_BUFSIZE)
|
||||
int samp_idx = buf_idx * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE;
|
||||
int sample_count = current_blockcount * FLUID_BUFSIZE;
|
||||
|
||||
/* in mix mode, map fx out_rev at index f to a dry buffer at index dry_idx */
|
||||
if(mixer->mix_fx_to_out)
|
||||
{
|
||||
/* dry buffer mapping, should be done more flexible in the future */
|
||||
dry_idx = (f % dry_count) * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE;
|
||||
}
|
||||
|
||||
for(i = 0; i < sample_count; i += FLUID_BUFSIZE, samp_idx += FLUID_BUFSIZE)
|
||||
{
|
||||
int samp_idx = buf_idx * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE + i;
|
||||
|
||||
reverb_process_func(mixer->fx[f].reverb,
|
||||
&in_rev[samp_idx],
|
||||
mixer->mix_fx_to_out ? &out_rev_l[i] : &out_rev_l[samp_idx],
|
||||
mixer->mix_fx_to_out ? &out_rev_r[i] : &out_rev_r[samp_idx]);
|
||||
mixer->mix_fx_to_out ? &out_rev_l[dry_idx + i] : &out_rev_l[samp_idx],
|
||||
mixer->mix_fx_to_out ? &out_rev_r[dry_idx + i] : &out_rev_r[samp_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,15 +194,22 @@ fluid_rvoice_mixer_process_fx(fluid_rvoice_mixer_t *mixer, int current_blockcoun
|
|||
for(f = 0; f < mixer->fx_units; f++)
|
||||
{
|
||||
int buf_idx = f * fx_channels_per_unit + SYNTH_CHORUS_CHANNEL;
|
||||
int samp_idx = buf_idx * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE;
|
||||
int sample_count = current_blockcount * FLUID_BUFSIZE;
|
||||
|
||||
for(i = 0; i < current_blockcount * FLUID_BUFSIZE; i += FLUID_BUFSIZE)
|
||||
/* in mix mode, map fx out_ch at index f to a dry buffer at index dry_idx */
|
||||
if(mixer->mix_fx_to_out)
|
||||
{
|
||||
/* dry buffer mapping, should be done more flexible in the future */
|
||||
dry_idx = (f % dry_count) * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE;
|
||||
}
|
||||
|
||||
for(i = 0; i < sample_count; i += FLUID_BUFSIZE, samp_idx += FLUID_BUFSIZE)
|
||||
{
|
||||
int samp_idx = buf_idx * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE + i;
|
||||
|
||||
chorus_process_func(mixer->fx[f].chorus,
|
||||
&in_ch [samp_idx],
|
||||
mixer->mix_fx_to_out ? &out_ch_l[i] : &out_ch_l[samp_idx],
|
||||
mixer->mix_fx_to_out ? &out_ch_r[i] : &out_ch_r[samp_idx]);
|
||||
mixer->mix_fx_to_out ? &out_ch_l[dry_idx + i] : &out_ch_l[samp_idx],
|
||||
mixer->mix_fx_to_out ? &out_ch_r[dry_idx + i] : &out_ch_r[samp_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue