libfluidsynth  2.3.5
Synthesis Parameters

Functions to control and query synthesis parameters like gain and polyphony count. More...

Enumerations

enum  fluid_interp {
  FLUID_INTERP_NONE = 0 ,
  FLUID_INTERP_LINEAR = 1 ,
  FLUID_INTERP_4THORDER = 4 ,
  FLUID_INTERP_7THORDER = 7 ,
  FLUID_INTERP_DEFAULT = FLUID_INTERP_4THORDER ,
  FLUID_INTERP_HIGHEST = FLUID_INTERP_7THORDER
}
 Synthesis interpolation method. More...
 
enum  fluid_synth_add_mod {
  FLUID_SYNTH_OVERWRITE ,
  FLUID_SYNTH_ADD
}
 Enum used with fluid_synth_add_default_mod() to specify how to handle duplicate modulators. More...
 

Functions

int fluid_synth_add_default_mod (fluid_synth_t *synth, const fluid_mod_t *mod, int mode)
 Adds the specified modulator mod as default modulator to the synth. More...
 
int fluid_synth_count_audio_channels (fluid_synth_t *synth)
 Get the total count of audio channels. More...
 
int fluid_synth_count_audio_groups (fluid_synth_t *synth)
 Get the total number of allocated audio channels. More...
 
int fluid_synth_count_effects_channels (fluid_synth_t *synth)
 Get the total number of allocated effects channels. More...
 
int fluid_synth_count_effects_groups (fluid_synth_t *synth)
 Get the total number of allocated effects units. More...
 
int fluid_synth_count_midi_channels (fluid_synth_t *synth)
 Get the total count of MIDI channels. More...
 
int fluid_synth_get_active_voice_count (fluid_synth_t *synth)
 Get current number of active voices. More...
 
float fluid_synth_get_gain (fluid_synth_t *synth)
 Get synth output gain value. More...
 
int fluid_synth_get_internal_bufsize (fluid_synth_t *synth)
 Get the internal synthesis buffer size value. More...
 
int fluid_synth_get_polyphony (fluid_synth_t *synth)
 Get current synthesizer polyphony (max number of voices). More...
 
int fluid_synth_remove_default_mod (fluid_synth_t *synth, const fluid_mod_t *mod)
 Removes the specified modulator mod from the synth's default modulator list. More...
 
void fluid_synth_set_gain (fluid_synth_t *synth, float gain)
 Set synth output gain value. More...
 
int fluid_synth_set_interp_method (fluid_synth_t *synth, int chan, int interp_method)
 Set synthesis interpolation method on one or all MIDI channels. More...
 
int fluid_synth_set_polyphony (fluid_synth_t *synth, int polyphony)
 Set synthesizer polyphony (max number of voices). More...
 
void fluid_synth_set_sample_rate (fluid_synth_t *synth, float sample_rate)
 Set up an event to change the sample-rate of the synth during the next rendering call. More...
 

Detailed Description

Functions to control and query synthesis parameters like gain and polyphony count.

Enumeration Type Documentation

◆ fluid_interp

Synthesis interpolation method.

Enumerator
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, good quality, the default.

FLUID_INTERP_7THORDER 

Seventh-order 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.

Enumerator
FLUID_SYNTH_OVERWRITE 

Overwrite any existing matching modulator.

FLUID_SYNTH_ADD 

Sum up modulator amounts.

Function Documentation

◆ fluid_synth_add_default_mod()

int fluid_synth_add_default_mod ( fluid_synth_t synth,
const fluid_mod_t mod,
int  mode 
)

Adds the specified modulator mod as default modulator to the synth.

mod will take effect for any subsequently created voice.

Parameters
synthFluidSynth instance
modModulator info (values copied, passed in object can be freed immediately afterwards)
modeDetermines 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()

int fluid_synth_count_audio_channels ( fluid_synth_t synth)

Get the total count of audio channels.

Parameters
synthFluidSynth instance
Returns
Count of audio channel stereo pairs (1 = 2 channels, 2 = 4, etc)
Examples
fluidsynth_process.c.

◆ fluid_synth_count_audio_groups()

int fluid_synth_count_audio_groups ( fluid_synth_t synth)

Get the total number of allocated audio channels.

Usually identical to the number of audio channels. Can be employed by LADSPA effects subsystem.

Parameters
synthFluidSynth instance
Returns
Count of audio group stereo pairs (1 = 2 channels, 2 = 4, etc)

◆ fluid_synth_count_effects_channels()

int fluid_synth_count_effects_channels ( fluid_synth_t synth)

Get the total number of allocated effects channels.

Parameters
synthFluidSynth instance
Returns
Count of allocated effects channels
Examples
fluidsynth_process.c.

◆ fluid_synth_count_effects_groups()

int fluid_synth_count_effects_groups ( fluid_synth_t synth)

Get the total number of allocated effects units.

This is the same number as initially provided by the setting synth.effects-groups.

Parameters
synthFluidSynth instance
Returns
Count of allocated effects units
Examples
fluidsynth_process.c.

◆ fluid_synth_count_midi_channels()

int fluid_synth_count_midi_channels ( fluid_synth_t synth)

Get the total count of MIDI channels.

Parameters
synthFluidSynth instance
Returns
Count of MIDI channels

◆ fluid_synth_get_active_voice_count()

int fluid_synth_get_active_voice_count ( fluid_synth_t synth)

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
synthFluidSynth 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()

float fluid_synth_get_gain ( fluid_synth_t synth)

Get synth output gain value.

Parameters
synthFluidSynth instance
Returns
Synth gain value (0.0 to 10.0)

◆ fluid_synth_get_internal_bufsize()

int fluid_synth_get_internal_bufsize ( fluid_synth_t synth)

Get the internal synthesis buffer size value.

Parameters
synthFluidSynth 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()

int fluid_synth_get_polyphony ( fluid_synth_t synth)

Get current synthesizer polyphony (max number of voices).

Parameters
synthFluidSynth instance
Returns
Synth polyphony value.
Since
1.0.6

◆ fluid_synth_remove_default_mod()

int fluid_synth_remove_default_mod ( fluid_synth_t synth,
const fluid_mod_t 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
synthsynth instance
modThe 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()

void fluid_synth_set_gain ( fluid_synth_t synth,
float  gain 
)

Set synth output gain value.

Parameters
synthFluidSynth instance
gainGain value (function clamps value to the range 0.0 to 10.0)

◆ fluid_synth_set_interp_method()

int fluid_synth_set_interp_method ( fluid_synth_t synth,
int  chan,
int  interp_method 
)

Set synthesis interpolation method on one or all MIDI channels.

Parameters
synthFluidSynth instance
chanMIDI channel to set interpolation method on or -1 for all channels
interp_methodInterpolation method (fluid_interp)
Returns
FLUID_OK on success, FLUID_FAILED otherwise

◆ fluid_synth_set_polyphony()

int fluid_synth_set_polyphony ( fluid_synth_t synth,
int  polyphony 
)

Set synthesizer polyphony (max number of voices).

Parameters
synthFluidSynth instance
polyphonyPolyphony to assign
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Since
1.0.6

◆ fluid_synth_set_sample_rate()

void fluid_synth_set_sample_rate ( fluid_synth_t synth,
float  sample_rate 
)

Set up an event to change the sample-rate of the synth during the next rendering call.

Warning
This function is broken-by-design! Don't use it! 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 real-time 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.
// then delete the 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);
struct _fluid_synth_t fluid_synth_t
Synthesizer instance.
Definition: types.h:39
fluid_audio_driver_t * new_fluid_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
Create a new audio driver.
Definition: fluid_adriver.c:330
void delete_fluid_audio_driver(fluid_audio_driver_t *driver)
Deletes an audio driver instance.
Definition: fluid_adriver.c:423
int fluid_settings_setnum(fluid_settings_t *settings, const char *name, double val)
Set a numeric value for a named setting.
Definition: fluid_settings.c:1349
fluid_synth_t * new_fluid_synth(fluid_settings_t *settings)
Create new FluidSynth instance.
Definition: fluid_synth.c:628
void delete_fluid_synth(fluid_synth_t *synth)
Delete a FluidSynth instance.
Definition: fluid_synth.c:1023
Parameters
synthFluidSynth instance
sample_rateNew sample-rate (Hz)
Since
1.1.2