libfluidsynth  2.2.4
Synthesis Voice Control

Low-level access to synthesis voices. More...

Functions

fluid_voice_tfluid_synth_alloc_voice (fluid_synth_t *synth, fluid_sample_t *sample, int channum, int key, int vel)
 Allocate a synthesis voice. More...
 
void fluid_synth_get_voicelist (fluid_synth_t *synth, fluid_voice_t *buf[], int bufsize, int ID)
 Get list of currently playing voices. More...
 
int fluid_synth_start (fluid_synth_t *synth, unsigned int id, fluid_preset_t *preset, int audio_chan, int midi_chan, int key, int vel)
 Create and start voices using an arbitrary preset and a MIDI note on event. More...
 
void fluid_synth_start_voice (fluid_synth_t *synth, fluid_voice_t *voice)
 Activate a voice previously allocated with fluid_synth_alloc_voice(). More...
 
int fluid_synth_stop (fluid_synth_t *synth, unsigned int id)
 Stop notes for a given note event voice ID. More...
 

Detailed Description

Low-level access to synthesis voices.

Function Documentation

◆ fluid_synth_alloc_voice()

fluid_voice_t* fluid_synth_alloc_voice ( fluid_synth_t synth,
fluid_sample_t sample,
int  chan,
int  key,
int  vel 
)

Allocate a synthesis voice.

Parameters
synthFluidSynth instance
sampleSample to assign to the voice
chanMIDI channel number (0 to MIDI channel count - 1)
keyMIDI note number for the voice (0-127)
velMIDI velocity for the voice (0-127)
Returns
Allocated synthesis voice or NULL on error

This function is called by a SoundFont's preset in response to a noteon event. The returned voice comes with default modulators and generators. A single noteon event may create any number of voices, when the preset is layered.

Note
Should only be called from within synthesis thread, which includes SoundFont loader preset noteon method.

◆ fluid_synth_get_voicelist()

void fluid_synth_get_voicelist ( fluid_synth_t synth,
fluid_voice_t buf[],
int  bufsize,
int  id 
)

Get list of currently playing voices.

Parameters
synthFluidSynth instance
bufArray to store voices to (NULL terminated if not filled completely)
bufsizeCount of indexes in buf
idVoice ID to search for or < 0 to return list of all playing voices
Note
Should only be called from within synthesis thread, which includes SoundFont loader preset noteon methods. Voices are only guaranteed to remain unchanged until next synthesis process iteration.

◆ fluid_synth_start()

int fluid_synth_start ( fluid_synth_t synth,
unsigned int  id,
fluid_preset_t preset,
int  audio_chan,
int  chan,
int  key,
int  vel 
)

Create and start voices using an arbitrary preset and a MIDI note on event.

Using this function is only supported when the setting synth.dynamic-sample-loading is false!

Parameters
synthFluidSynth instance
idVoice group ID to use (can be used with fluid_synth_stop()).
presetPreset to synthesize
audio_chanUnused currently, set to 0
chanMIDI channel number (0 to MIDI channel count - 1)
keyMIDI note number (0-127)
velMIDI velocity number (1-127)
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Note
Should only be called from within synthesis thread, which includes SoundFont loader preset noteon method.

◆ fluid_synth_start_voice()

void fluid_synth_start_voice ( fluid_synth_t synth,
fluid_voice_t voice 
)

Activate a voice previously allocated with fluid_synth_alloc_voice().

Parameters
synthFluidSynth instance
voiceVoice to activate

This function is called by a SoundFont's preset in response to a noteon event. Exclusive classes are processed here.

Note
Should only be called from within synthesis thread, which includes SoundFont loader preset noteon method.

◆ fluid_synth_stop()

int fluid_synth_stop ( fluid_synth_t synth,
unsigned int  id 
)

Stop notes for a given note event voice ID.

Parameters
synthFluidSynth instance
idVoice note event ID
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Note
In FluidSynth versions prior to 1.1.0 FLUID_FAILED would be returned if no matching voice note event ID was found. Versions after 1.1.0 only return FLUID_FAILED if an error occurs.