libfluidsynth
2.4.5
|
The functions in this section can be used to render audio directly to memory buffers. More...
Functions | |
int | fluid_synth_nwrite_float (fluid_synth_t *synth, int len, float **left, float **right, float **fx_left, float **fx_right) |
Synthesize a block of floating point audio to separate audio buffers (multi-channel rendering). More... | |
int | fluid_synth_process (fluid_synth_t *synth, int len, int nfx, float *fx[], int nout, float *out[]) |
Synthesize floating point audio to stereo audio channels (implements the default interface fluid_audio_func_t). More... | |
int | fluid_synth_write_float (fluid_synth_t *synth, int len, void *lout, int loff, int lincr, void *rout, int roff, int rincr) |
Synthesize a block of floating point audio samples to audio buffers. More... | |
int | fluid_synth_write_s16 (fluid_synth_t *synth, int len, void *lout, int loff, int lincr, void *rout, int roff, int rincr) |
Synthesize a block of 16 bit audio samples to audio buffers. More... | |
The functions in this section can be used to render audio directly to memory buffers.
They are used internally by the Audio Driver and File Renderer, but can also be used manually for custom processing of the rendered audio.
int fluid_synth_nwrite_float | ( | fluid_synth_t * | synth, |
int | len, | ||
float ** | left, | ||
float ** | right, | ||
float ** | fx_left, | ||
float ** | fx_right | ||
) |
Synthesize a block of floating point audio to separate audio buffers (multi-channel rendering).
synth | FluidSynth instance |
len | Count of audio frames to synthesize |
left | Array of float buffers to store left channel of planar audio (as many as synth.audio-channels buffers, each of len in size) |
right | Array of float buffers to store right channel of planar audio (size: dito) |
fx_left | Since 1.1.7: If not NULL , array of float buffers to store left effect channels (as many as synth.effects-channels buffers, each of len in size) |
fx_right | Since 1.1.7: If not NULL , array of float buffers to store right effect channels (size: dito) |
First effect channel used by reverb, second for chorus.
Usage example:
int fluid_synth_process | ( | fluid_synth_t * | synth, |
int | len, | ||
int | nfx, | ||
float * | fx[], | ||
int | nout, | ||
float * | out[] | ||
) |
Synthesize floating point audio to stereo audio channels (implements the default interface fluid_audio_func_t).
synth | FluidSynth instance |
len | Count of audio frames to synthesize and store in every single buffer provided by out and fx . Zero value is permitted, the function does nothing and return FLUID_OK. |
nfx | Count of arrays in fx . Must be a multiple of 2 (because of stereo) and in the range 0 <= nfx/2 <= (fluid_synth_count_effects_channels() * fluid_synth_count_effects_groups()) . Note that zero value is valid and allows to skip mixing effects in all fx output buffers. |
fx | Array of buffers to store effects audio to. Buffers may alias with buffers of out . Individual NULL buffers are permitted and will cause to skip mixing any audio into that buffer. |
nout | Count of arrays in out . Must be a multiple of 2 (because of stereo) and in the range 0 <= nout/2 <= fluid_synth_count_audio_channels() . Note that zero value is valid and allows to skip mixing dry audio in all out output buffers. |
out | Array of buffers to store (dry) audio to. Buffers may alias with buffers of fx . Individual NULL buffers are permitted and will cause to skip mixing any audio into that buffer. |
fx == NULL
while nfx > 0
, or out == NULL
while nout > 0
.nfx
or nout
not multiple of 2.len < 0
.nfx
or nout
exceed the range explained above.Synthesize and mix audio to a given number of planar audio buffers. Therefore pass nout = N*2
float buffers to out
in order to render the synthesized audio to N
stereo channels. Each float buffer must be able to hold len
elements.
out
contains an array of planar buffers for normal, dry, stereo audio (alternating left and right). Like:
for zero-based channel index i
. The buffer layout of fx
used for storing effects like reverb and chorus looks similar:
where 0 <= k < fluid_synth_count_effects_groups()
is a zero-based index denoting the effects unit and 0 <= j < fluid_synth_count_effects_channels()
is a zero-based index denoting the effect channel within unit k
.
Any playing voice is assigned to audio channels based on the MIDI channel it's playing on: Let chan
be the zero-based MIDI channel index an arbitrary voice is playing on. To determine the audio channel and effects unit it is going to be rendered to use:
i = chan % fluid_synth_count_audio_groups()
k = chan % fluid_synth_count_effects_groups()
out
and all effects channels to the buffers in fx
, provided that nout > 0
and nfx > 0
respectively. If nout/2 < fluid_synth_count_audio_channels()
it will wrap around. Same is true for effects audio if nfx/2 < (fluid_synth_count_effects_channels() * fluid_synth_count_effects_groups())
. See usage examples below. int fluid_synth_write_float | ( | fluid_synth_t * | synth, |
int | len, | ||
void * | lout, | ||
int | loff, | ||
int | lincr, | ||
void * | rout, | ||
int | roff, | ||
int | rincr | ||
) |
Synthesize a block of floating point audio samples to audio buffers.
synth | FluidSynth instance |
len | Count of audio frames to synthesize |
lout | Array of floats to store left channel of audio |
loff | Offset index in 'lout' for first sample |
lincr | Increment between samples stored to 'lout' |
rout | Array of floats to store right channel of audio |
roff | Offset index in 'rout' for first sample |
rincr | Increment between samples stored to 'rout' |
Useful for storing interleaved stereo (lout = rout, loff = 0, roff = 1, lincr = 2, rincr = 2).
lout
resp. rout
. int fluid_synth_write_s16 | ( | fluid_synth_t * | synth, |
int | len, | ||
void * | lout, | ||
int | loff, | ||
int | lincr, | ||
void * | rout, | ||
int | roff, | ||
int | rincr | ||
) |
Synthesize a block of 16 bit audio samples to audio buffers.
synth | FluidSynth instance |
len | Count of audio frames to synthesize |
lout | Array of 16 bit words to store left channel of audio |
loff | Offset index in 'lout' for first sample |
lincr | Increment between samples stored to 'lout' |
rout | Array of 16 bit words to store right channel of audio |
roff | Offset index in 'rout' for first sample |
rincr | Increment between samples stored to 'rout' |
Useful for storing interleaved stereo (lout = rout, loff = 0, roff = 1, lincr = 2, rincr = 2).
lout
resp. rout
.