Synthesis Parameters
Functions to control and query synthesis parameters like gain and polyphony count.
Enumerations
fluid_interp
Synthesis interpolation method.
| Value | Description |
|---|---|
FLUID_INTERP_NONE |
No interpolation: Fastest, but questionable audio quality. |
FLUID_INTERP_LINEAR |
Straight-line interpolation: A bit slower, reasonable audio quality. |
FLUID_INTERP_4THORDER |
Fourth-order interpolation, best quality, the default. |
FLUID_INTERP_7THORDER |
Seventh-point sinc interpolation. This interpolation method was believed to provide highest quality. However, in Feb. 2025 it was discovered that for certain samples it does introduce ringing artifacts, which are not present in the 4th order interpolation. This is not a bug, it's rather a limitation of only using 7 points for the sinc interpolation. |
FLUID_INTERP_DEFAULT |
Default interpolation method. |
FLUID_INTERP_HIGHEST |
Highest interpolation method. |
fluid_synth_add_mod
Enum used with fluid_synth_add_default_mod() to specify how to handle duplicate modulators.
| Value | Description |
|---|---|
FLUID_SYNTH_OVERWRITE |
Overwrite any existing matching modulator. |
FLUID_SYNTH_ADD |
Sum up modulator amounts. |
Functions
fluid_synth_add_default_mod()
Adds the specified modulator mod as default modulator to the synth.
mod will take effect for any subsequently created voice.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
mod |
Modulator info (values copied, passed in object can be freed immediately afterwards) |
mode |
Determines how to handle an existing identical modulator (fluid_synth_add_mod) |
Returns: FLUID_OK on success, FLUID_FAILED otherwise
Note
Not realtime safe (due to internal memory allocation) and therefore should not be called from synthesis context at the risk of stalling audio output.
fluid_synth_count_audio_channels()
Get the total count of audio channels.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Count of audio channel stereo pairs (1 = 2 channels, 2 = 4, etc)
fluid_synth_count_audio_groups()
Get the total number of allocated audio channels.
Usually identical to the number of audio channels. Can be employed by LADSPA effects subsystem.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Count of audio group stereo pairs (1 = 2 channels, 2 = 4, etc)
fluid_synth_count_effects_channels()
Get the total number of allocated effects channels.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Count of allocated effects channels
fluid_synth_count_effects_groups()
Get the total number of allocated effects units.
This is the same number as initially provided by the setting synth.effects-groups.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Count of allocated effects units
fluid_synth_count_midi_channels()
Get the total count of MIDI channels.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Count of MIDI channels
fluid_synth_get_active_voice_count()
Get current number of active voices.
I.e. the no. of voices that have been started and have not yet finished. Unless called from synthesis context, this number does not necessarily have to be equal to the number of voices currently processed by the DSP loop, see below. Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Number of currently active voices.
Since
1.1.0
Note
To generate accurate continuous statistics of the voice count, caller should ensure this function is called synchronously with the audio synthesis process. This can be done in the new_fluid_audio_driver2() audio callback function for example. Otherwise every call to this function may return different voice counts as it may change after any (concurrent) call to fluid_synth_write_*() made by e.g. an audio driver or the applications audio rendering thread.
fluid_synth_get_gain()
Get synth output gain value.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Synth gain value (0.0 to 10.0)
fluid_synth_get_internal_bufsize()
Get the internal synthesis buffer size value.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Internal buffer size in audio frames.
Audio is synthesized at this number of frames at a time. Defaults to 64 frames. I.e. the synth can only react to notes, control changes, and other audio affecting events after having processed 64 audio frames.
fluid_synth_get_polyphony()
Get current synthesizer polyphony (max number of voices).
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
Returns: Synth polyphony value.
Since
1.0.6
fluid_synth_remove_default_mod()
Removes the specified modulator mod from the synth's default modulator list.
fluid_mod_test_identity() will be used to test modulator matching.
Parameters:
| Name | Description |
|---|---|
synth |
synth instance |
mod |
The modulator to remove |
Returns: FLUID_OK if a matching modulator was found and successfully removed, FLUID_FAILED otherwise
Note
Not realtime safe (due to internal memory freeing) and therefore should not be called from synthesis context at the risk of stalling audio output.
fluid_synth_set_gain()
Set synth output gain value.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
gain |
Gain value (function clamps value to the range 0.0 to 10.0) |
fluid_synth_set_interp_method()
Set synthesis interpolation method on one or all MIDI channels.
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
chan |
MIDI channel to set interpolation method on or -1 for all channels |
interp_method |
Interpolation method (fluid_interp) |
Returns: FLUID_OK on success, FLUID_FAILED otherwise
fluid_synth_set_polyphony()
Set synthesizer polyphony (max number of voices).
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
polyphony |
Polyphony to assign |
Returns: FLUID_OK on success, FLUID_FAILED otherwise
Since
1.0.6
fluid_synth_set_sample_rate()
Set up an event to change the sample-rate of the synth during the next rendering call.
Danger
This function is broken-by-design! Don't use it! Starting with fluidsynth 2.4.4 it's a no-op. Instead, specify the sample-rate when creating the synth.
Deprecated
As of fluidsynth 2.1.0 this function has been deprecated. Changing the sample-rate is generally not considered to be a realtime use-case, as it always produces some audible artifact ("click", "pop") on the dry sound and effects (because LFOs for chorus and reverb need to be reinitialized). The sample-rate change may also require memory allocation deep down in the effect units. However, this memory allocation may fail and there is no way for the caller to know that, because the actual change of the sample-rate is executed during rendering. This function cannot (must not) do the sample-rate change itself, otherwise the synth needs to be locked down, causing rendering to block. Esp. do not use this function if this synth instance is used by an audio driver, because the audio driver cannot be notified by this sample-rate change. Long story short: don't use it.
fluid_synth_t* synth; // assume initialized
// [...]
// sample-rate change needed? Delete the audio driver, if any.
delete_fluid_audio_driver(adriver);
// then delete the synth
delete_fluid_synth(synth);
// update the sample-rate
fluid_settings_setnum(settings, "synth.sample-rate", 22050.0);
// and re-create objects
synth = new_fluid_synth(settings);
adriver = new_fluid_audio_driver(settings, synth);
Parameters:
| Name | Description |
|---|---|
synth |
FluidSynth instance |
sample_rate |
New sample-rate (Hz) |
Since
1.1.2