libfluidsynth
1.1.11
|
Synthesis voice manipulation functions. More...
Enumerations | |
enum | fluid_voice_add_mod { FLUID_VOICE_OVERWRITE, FLUID_VOICE_ADD, FLUID_VOICE_DEFAULT } |
Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators. More... | |
Functions | |
FLUIDSYNTH_API void | fluid_voice_update_param (fluid_voice_t *voice, int gen) |
Update all the synthesis parameters, which depend on generator gen. More... | |
FLUIDSYNTH_API void | fluid_voice_add_mod (fluid_voice_t *voice, fluid_mod_t *mod, int mode) |
Adds a modulator to the voice. More... | |
FLUIDSYNTH_API void | fluid_voice_gen_set (fluid_voice_t *voice, int gen, float val) |
Set the value of a generator. More... | |
FLUIDSYNTH_API float | fluid_voice_gen_get (fluid_voice_t *voice, int gen) |
Get the value of a generator. More... | |
FLUIDSYNTH_API void | fluid_voice_gen_incr (fluid_voice_t *voice, int gen, float val) |
Offset the value of a generator. More... | |
FLUIDSYNTH_API unsigned int | fluid_voice_get_id (const fluid_voice_t *voice) |
Get the unique ID of the noteon-event. More... | |
FLUIDSYNTH_API int | fluid_voice_is_playing (const fluid_voice_t *voice) |
Check if a voice is producing sound. More... | |
FLUIDSYNTH_API int | fluid_voice_is_on (const fluid_voice_t *voice) |
Check if a voice is ON. More... | |
FLUIDSYNTH_API int | fluid_voice_is_sustained (const fluid_voice_t *voice) |
Check if a voice keeps playing after it has received a noteoff due to being held by sustain. More... | |
FLUIDSYNTH_API int | fluid_voice_is_sostenuto (const fluid_voice_t *voice) |
Check if a voice keeps playing after it has received a noteoff due to being held by sostenuto. More... | |
FLUIDSYNTH_API int | fluid_voice_get_channel (const fluid_voice_t *voice) |
If the voice is playing, gets the midi channel the voice is playing on. More... | |
FLUIDSYNTH_API int | fluid_voice_get_actual_key (const fluid_voice_t *voice) |
If the voice is playing, gets the midi key the voice is actually playing at. More... | |
FLUIDSYNTH_API int | fluid_voice_get_key (const fluid_voice_t *voice) |
If the voice is playing, gets the midi key from the noteon event, by which the voice was initially turned on with. More... | |
FLUIDSYNTH_API int | fluid_voice_get_actual_velocity (const fluid_voice_t *voice) |
If the voice is playing, gets the midi velocity the voice is actually playing at. More... | |
FLUIDSYNTH_API int | fluid_voice_get_velocity (const fluid_voice_t *voice) |
If the voice is playing, gets the midi velocity from the noteon event, by which the voice was initially turned on with. More... | |
FLUIDSYNTH_API int | fluid_voice_optimize_sample (fluid_sample_t *s) |
Calculate the peak volume of a sample for voice off optimization. More... | |
Synthesis voice manipulation functions.
The interface to the synthesizer's voices. Examples on using them can be found in fluid_defsfont.c. Most of these functions should only be called from within synthesis context, such as the SoundFont loader's noteon method.
enum fluid_voice_add_mod |
Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators.
FLUIDSYNTH_API void fluid_voice_update_param | ( | fluid_voice_t * | voice, |
int | gen | ||
) |
Update all the synthesis parameters, which depend on generator gen.
voice | Voice instance |
gen | Generator id (fluid_gen_type) |
This is only necessary after changing a generator of an already operating voice. Most applications will not need this function.
References fluid_mod_get_dest(), FLUID_OK, fluid_voice_gen_set(), fluid_voice_is_playing(), GEN_ATTENUATION, GEN_CHORUSSEND, GEN_COARSETUNE, GEN_ENDADDRCOARSEOFS, GEN_ENDADDROFS, GEN_ENDLOOPADDRCOARSEOFS, GEN_ENDLOOPADDROFS, GEN_EXCLUSIVECLASS, GEN_FILTERFC, GEN_FILTERQ, GEN_FINETUNE, GEN_KEYNUM, GEN_KEYTOMODENVDECAY, GEN_KEYTOMODENVHOLD, GEN_KEYTOVOLENVDECAY, GEN_KEYTOVOLENVHOLD, GEN_MODENVATTACK, GEN_MODENVDECAY, GEN_MODENVDELAY, GEN_MODENVHOLD, GEN_MODENVRELEASE, GEN_MODENVSUSTAIN, GEN_MODENVTOFILTERFC, GEN_MODENVTOPITCH, GEN_MODLFODELAY, GEN_MODLFOFREQ, GEN_MODLFOTOFILTERFC, GEN_MODLFOTOPITCH, GEN_MODLFOTOVOL, GEN_OVERRIDEROOTKEY, GEN_PAN, GEN_PITCH, GEN_REVERBSEND, GEN_STARTADDRCOARSEOFS, GEN_STARTADDROFS, GEN_STARTLOOPADDRCOARSEOFS, GEN_STARTLOOPADDROFS, GEN_VELOCITY, GEN_VIBLFODELAY, GEN_VIBLFOFREQ, GEN_VIBLFOTOPITCH, GEN_VOLENVATTACK, GEN_VOLENVDECAY, GEN_VOLENVDELAY, GEN_VOLENVHOLD, GEN_VOLENVRELEASE, and GEN_VOLENVSUSTAIN.
Referenced by fluid_ramsfont_izone_set_loop(), fluid_synth_get_cpu_load(), fluid_voice_gen_get(), and fluid_voice_get_velocity().
FLUIDSYNTH_API void fluid_voice_add_mod | ( | fluid_voice_t * | voice, |
fluid_mod_t * | mod, | ||
int | mode | ||
) |
Adds a modulator to the voice.
voice | Voice instance |
mod | Modulator info (copied) |
mode | Determines how to handle an existing identical modulator FLUID_VOICE_ADD to add (offset) the modulator amounts, FLUID_VOICE_OVERWRITE to replace the modulator, FLUID_VOICE_DEFAULT when adding a default modulator - no duplicate should exist so don't check. |
References _fluid_mod_t::amount, _fluid_mod_t::flags1, FLUID_MOD_CC, FLUID_MOD_CHANNELPRESSURE, FLUID_MOD_KEY, FLUID_MOD_KEYPRESSURE, FLUID_MOD_NONE, FLUID_MOD_PITCHWHEEL, FLUID_MOD_PITCHWHEELSENS, fluid_mod_test_identity(), FLUID_MOD_VELOCITY, FLUID_NUM_MOD, FLUID_VOICE_ADD, FLUID_VOICE_OVERWRITE, FLUID_WARN, and _fluid_mod_t::src1.
FLUIDSYNTH_API void fluid_voice_gen_set | ( | fluid_voice_t * | voice, |
int | i, | ||
float | val | ||
) |
Set the value of a generator.
voice | Voice instance |
i | Generator ID (fluid_gen_type) |
val | Generator value |
References GEN_SAMPLEMODE, and GEN_SET.
Referenced by fluid_ramsfont_izone_set_loop(), and fluid_voice_update_param().
FLUIDSYNTH_API float fluid_voice_gen_get | ( | fluid_voice_t * | voice, |
int | gen | ||
) |
Get the value of a generator.
voice | Voice instance |
gen | Generator ID (fluid_gen_type) |
References _fluid_mod_t::dest, FLUID_OK, fluid_voice_get_actual_key(), fluid_voice_is_playing(), fluid_voice_update_param(), GEN_ABS_NRPN, GEN_ATTENUATION, GEN_CHORUSSEND, GEN_ENDADDROFS, GEN_ENDLOOPADDROFS, GEN_FILTERFC, GEN_FILTERQ, GEN_KEYNUM, GEN_MODENVATTACK, GEN_MODENVDECAY, GEN_MODENVDELAY, GEN_MODENVHOLD, GEN_MODENVRELEASE, GEN_MODENVTOFILTERFC, GEN_MODENVTOPITCH, GEN_MODLFODELAY, GEN_MODLFOFREQ, GEN_MODLFOTOFILTERFC, GEN_MODLFOTOPITCH, GEN_MODLFOTOVOL, GEN_OVERRIDEROOTKEY, GEN_PAN, GEN_PITCH, GEN_REVERBSEND, GEN_SCALETUNE, GEN_STARTADDROFS, GEN_STARTLOOPADDROFS, GEN_VELOCITY, GEN_VIBLFODELAY, GEN_VIBLFOFREQ, GEN_VIBLFOTOPITCH, GEN_VOLENVATTACK, GEN_VOLENVDECAY, GEN_VOLENVDELAY, GEN_VOLENVHOLD, GEN_VOLENVRELEASE, and _fluid_gen_t::mod.
FLUIDSYNTH_API void fluid_voice_gen_incr | ( | fluid_voice_t * | voice, |
int | i, | ||
float | val | ||
) |
Offset the value of a generator.
voice | Voice instance |
i | Generator ID (fluid_gen_type) |
val | Value to add to the existing value |
References GEN_SET.
Referenced by fluid_ramsfont_izone_set_loop().
FLUIDSYNTH_API unsigned int fluid_voice_get_id | ( | const fluid_voice_t * | voice | ) |
Get the unique ID of the noteon-event.
voice | Voice instance |
A SoundFont loader may store the voice processes it has created for real-time control during the operation of a voice (for example: parameter changes in SoundFont editor). The synth uses a pool of voices, which are 'recycled' and never deallocated.
Before modifying an existing voice, check
Otherwise the voice has finished playing.
Referenced by fluid_ramsfont_izone_set_loop(), fluid_synth_alloc_voice(), fluid_synth_get_chorus_type(), fluid_synth_noteoff(), fluid_synth_stop(), and fluid_synth_write_s16().
FLUIDSYNTH_API int fluid_voice_is_playing | ( | const fluid_voice_t * | voice | ) |
Check if a voice is producing sound.
This is also true after a voice received a noteoff as it may be playing in release phase.
voice | Voice instance |
References fluid_voice_is_sostenuto(), and fluid_voice_is_sustained().
Referenced by delete_fluid_synth(), fluid_ramsfont_izone_set_loop(), fluid_synth_all_notes_off(), fluid_synth_all_sounds_off(), fluid_synth_alloc_voice(), fluid_synth_get_chorus_type(), fluid_synth_get_voicelist(), fluid_synth_set_gain(), fluid_synth_set_polyphony(), fluid_synth_system_reset(), fluid_voice_gen_get(), and fluid_voice_update_param().
FLUIDSYNTH_API int fluid_voice_is_on | ( | const fluid_voice_t * | voice | ) |
Check if a voice is ON.
A voice is ON, if it has not yet received a noteoff event.
voice | Voice instance |
Referenced by fluid_synth_get_cpu_load(), fluid_synth_noteoff(), and fluid_synth_stop().
FLUIDSYNTH_API int fluid_voice_is_sustained | ( | const fluid_voice_t * | voice | ) |
Check if a voice keeps playing after it has received a noteoff due to being held by sustain.
voice | Voice instance |
Referenced by fluid_synth_noteoff(), fluid_voice_is_playing(), and fluid_voice_optimize_sample().
FLUIDSYNTH_API int fluid_voice_is_sostenuto | ( | const fluid_voice_t * | voice | ) |
Check if a voice keeps playing after it has received a noteoff due to being held by sostenuto.
voice | Voice instance |
Referenced by fluid_synth_get_chorus_type(), fluid_synth_noteoff(), fluid_voice_is_playing(), and fluid_voice_optimize_sample().
FLUIDSYNTH_API int fluid_voice_get_channel | ( | const fluid_voice_t * | voice | ) |
If the voice is playing, gets the midi channel the voice is playing on.
Else the result is undefined.
voice | Voice instance |
Referenced by fluid_synth_all_notes_off(), fluid_synth_all_sounds_off(), fluid_synth_alloc_voice(), fluid_synth_get_chorus_type(), fluid_synth_noteoff(), fluid_synth_set_gen(), fluid_synth_system_reset(), and fluid_synth_write_s16().
FLUIDSYNTH_API int fluid_voice_get_actual_key | ( | const fluid_voice_t * | voice | ) |
If the voice is playing, gets the midi key the voice is actually playing at.
Else the result is undefined. If the voice was started from an instrument which uses a fixed key generator, it returns that. Else returns the same as fluid_voice_get_key
.
voice | Voice instance |
References fluid_voice_get_key(), and GEN_KEYNUM.
Referenced by fluid_mod_get_amount(), and fluid_voice_gen_get().
FLUIDSYNTH_API int fluid_voice_get_key | ( | const fluid_voice_t * | voice | ) |
If the voice is playing, gets the midi key from the noteon event, by which the voice was initially turned on with.
Else the result is undefined.
voice | Voice instance |
Referenced by fluid_synth_get_chorus_type(), fluid_synth_noteoff(), fluid_synth_write_s16(), and fluid_voice_get_actual_key().
FLUIDSYNTH_API int fluid_voice_get_actual_velocity | ( | const fluid_voice_t * | voice | ) |
If the voice is playing, gets the midi velocity the voice is actually playing at.
Else the result is undefined. If the voice was started from an instrument which uses a fixed velocity generator, it returns that. Else returns the same as fluid_voice_get_velocity
.
voice | Voice instance |
References fluid_voice_get_velocity(), and GEN_VELOCITY.
Referenced by fluid_mod_get_amount().
FLUIDSYNTH_API int fluid_voice_get_velocity | ( | const fluid_voice_t * | voice | ) |
If the voice is playing, gets the midi velocity from the noteon event, by which the voice was initially turned on with.
Else the result is undefined.
voice | Voice instance |
References _fluid_mod_t::amount, _fluid_mod_t::dest, _fluid_mod_t::flags1, _fluid_mod_t::flags2, FLUID_MOD_BIPOLAR, FLUID_MOD_CC, FLUID_MOD_PITCHWHEEL, FLUID_OK, fluid_voice_update_param(), GEN_ABS_NRPN, GEN_ATTENUATION, GEN_SET, and _fluid_mod_t::src1.
Referenced by fluid_voice_get_actual_velocity().
FLUIDSYNTH_API int fluid_voice_optimize_sample | ( | fluid_sample_t * | s | ) |
Calculate the peak volume of a sample for voice off optimization.
s | Sample to optimize |
If the peak volume during the loop is known, then the voice can be released earlier during the release phase. Otherwise, the voice will operate (inaudibly), until the envelope is at the nominal turnoff point. So it's a good idea to call fluid_voice_optimize_sample() on each sample once.
References _fluid_sample_t::amplitude_that_reaches_noise_floor, _fluid_sample_t::amplitude_that_reaches_noise_floor_is_valid, CHANNEL_TYPE_DRUM, _fluid_sample_t::data, FLUID_OK, fluid_voice_is_sostenuto(), fluid_voice_is_sustained(), _fluid_sample_t::loopend, _fluid_sample_t::loopstart, and _fluid_sample_t::valid.