mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-21 03:11:13 +00:00
Update fluidsynth_fx example to explain effects mixing
This commit is contained in:
parent
871e409572
commit
98d395bab0
1 changed files with 32 additions and 7 deletions
|
@ -44,21 +44,36 @@ int fx_function(void *data, int len,
|
|||
{
|
||||
struct fx_data_t *fx_data = (struct fx_data_t *) data;
|
||||
int i, k;
|
||||
float *out_i;
|
||||
|
||||
/* Call the synthesizer to fill the output buffers with its
|
||||
* audio output. */
|
||||
if(fluid_synth_process(fx_data->synth, len, nfx, fx, nout, out) != FLUID_OK)
|
||||
if(fx == 0)
|
||||
{
|
||||
/* Some error occurred. Very unlikely to happen, though. */
|
||||
return FLUID_FAILED;
|
||||
/* Note that some audio drivers may not provide buffers for effects like
|
||||
* reverb and chorus. In this case it's your decision what to do. If you
|
||||
* had called fluid_synth_process() like in the else branch below, no
|
||||
* effects would have been rendered. Instead, you may mix the effects
|
||||
* directly into the out buffers. */
|
||||
if(fluid_synth_process(fx_data->synth, len, nout, out, nout, out) != FLUID_OK)
|
||||
{
|
||||
/* Some error occurred. Very unlikely to happen, though. */
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the synthesizer to fill the output buffers with its
|
||||
* audio output. */
|
||||
if(fluid_synth_process(fx_data->synth, len, nfx, fx, nout, out) != FLUID_OK)
|
||||
{
|
||||
/* Some error occurred. Very unlikely to happen, though. */
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
/* Apply your effects here. In this example, the gain is
|
||||
* applied to all the output buffers. */
|
||||
for(i = 0; i < nout; i++)
|
||||
{
|
||||
out_i = out[i];
|
||||
float *out_i = out[i];
|
||||
|
||||
for(k = 0; k < len; k++)
|
||||
{
|
||||
|
@ -66,6 +81,16 @@ int fx_function(void *data, int len,
|
|||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < nfx; i++)
|
||||
{
|
||||
float *fx_i = fx[i];
|
||||
|
||||
for(k = 0; k < len; k++)
|
||||
{
|
||||
fx_i[k] *= fx_data->gain;
|
||||
}
|
||||
}
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue