Skip to content

Commit

Permalink
Reorder LADSPA fx mixing
Browse files Browse the repository at this point in the history
This PR moves mixing of LADSPA effects in fluid_rvoice_mixer_process_fx() before mixing of the internal reverb and chorus effects.

Currently, if a user sets synth.audio-groups >1, LADSPA effects can be applied to specific MIDI channels only. The user can then follow @mawe42's great suggestion from the mailing list and use a zero-gain amp effect to mix the LADSPA buffers back to the first host port for output to the sound card (This seems like the most proper way to do this IMO - the LADSPA subsystem shouldn't have to figure out what FluidSynth's audio output channels are on its own).

However, since the internal reverb and chorus are applied first and don't care about synth.audio-groups, the LADSPA effects will appear in the internal effects buffers regardless of which audio_group the currently-playing MIDI channels are part of. Increasing synth.effects-groups is not ideal since it adds a lot of processing load, and also would seem to require that effects-groups always be equal to audio-groups. A user could disable the internal reverb and chorus and add them as LADSPA effects, but it's nice to be able to have backing instruments or tracks from MIDI files play "normally" (i.e. according to the soundfonts' reverb and chorus settings), while a user plays lead with interesting effects that don't alter the backing voices.

Resolves #1117.
  • Loading branch information
albedozero authored and derselbst committed Jun 27, 2022
1 parent 24898c1 commit 57554ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/bindings/fluid_ladspa.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ int fluid_ladspa_reset(fluid_ladspa_fx_t *fx)
* @param block_count number of blocks to render
* @param block_size number of samples in a block
*
* FluidSynth calls this function during main output mixing, just after
* the internal reverb and chorus effects have been processed.
* FluidSynth calls this function during main output mixing,
* just before processing the internal reverb and chorus effects.
*
* It copies audio data from the supplied buffers, runs all effects and copies the
* resulting audio back into the same buffers.
Expand Down
22 changes: 11 additions & 11 deletions src/rvoice/fluid_rvoice_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ fluid_rvoice_mixer_process_fx(fluid_rvoice_mixer_t *mixer, int current_blockcoun

fluid_profile_ref_var(prof_ref);

#ifdef LADSPA

/* Run the signal through the LADSPA Fx unit. The buffers have already been
* set up in fluid_rvoice_mixer_set_ladspa. */
if(mixer->ladspa_fx)
{
fluid_ladspa_run(mixer->ladspa_fx, current_blockcount, FLUID_BUFSIZE);
fluid_check_fpe("LADSPA");
}

#endif

if(mix_fx_to_out)
{
Expand Down Expand Up @@ -238,17 +249,6 @@ fluid_rvoice_mixer_process_fx(fluid_rvoice_mixer_t *mixer, int current_blockcoun
current_blockcount * FLUID_BUFSIZE);
}

#ifdef LADSPA

/* Run the signal through the LADSPA Fx unit. The buffers have already been
* set up in fluid_rvoice_mixer_set_ladspa. */
if(mixer->ladspa_fx)
{
fluid_ladspa_run(mixer->ladspa_fx, current_blockcount, FLUID_BUFSIZE);
fluid_check_fpe("LADSPA");
}

#endif
}

/**
Expand Down

0 comments on commit 57554ee

Please sign in to comment.