voice.h File Reference

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.
FLUIDSYNTH_API void fluid_voice_add_mod (fluid_voice_t *voice, fluid_mod_t *mod, int mode)
 Adds a modulator to the voice.
FLUIDSYNTH_API void fluid_voice_gen_set (fluid_voice_t *voice, int gen, float val)
 Set the value of a generator.
FLUIDSYNTH_API float fluid_voice_gen_get (fluid_voice_t *voice, int gen)
 Get the value of a generator.
FLUIDSYNTH_API void fluid_voice_gen_incr (fluid_voice_t *voice, int gen, float val)
 Offset the value of a generator.
FLUIDSYNTH_API unsigned int fluid_voice_get_id (fluid_voice_t *voice)
 Get the unique ID of the noteon-event.
FLUIDSYNTH_API int fluid_voice_is_playing (fluid_voice_t *voice)
 Check if a voice is still playing.
FLUIDSYNTH_API int fluid_voice_optimize_sample (fluid_sample_t *s)
 Calculate the peak volume of a sample for voice off optimization.

Detailed Description

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.


Enumeration Type Documentation

Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators.

Enumerator:
FLUID_VOICE_OVERWRITE 

Overwrite any existing matching modulator.

FLUID_VOICE_ADD 

Add (sum) modulator amounts.

FLUID_VOICE_DEFAULT 

For default modulators only, no need to check for duplicates.


Function Documentation

FLUIDSYNTH_API void fluid_voice_update_param ( fluid_voice_t voice,
int  gen 
)
FLUIDSYNTH_API void fluid_voice_add_mod ( fluid_voice_t voice,
fluid_mod_t mod,
int  mode 
)

Adds a modulator to the voice.

Parameters:
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_test_identity(), 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.

Parameters:
voice Voice instance
i Generator ID (fluid_gen_type)
val Generator value

References fluid_voice_gen_set(), GEN_SAMPLEMODE, and GEN_SET.

Referenced by fluid_voice_gen_set().

FLUIDSYNTH_API float fluid_voice_gen_get ( fluid_voice_t voice,
int  gen 
)

Get the value of a generator.

Parameters:
voice Voice instance
gen Generator ID (fluid_gen_type)
Returns:
Current generator value

References fluid_voice_gen_get().

Referenced by fluid_voice_gen_get().

FLUIDSYNTH_API void fluid_voice_gen_incr ( fluid_voice_t voice,
int  i,
float  val 
)

Offset the value of a generator.

Parameters:
voice Voice instance
i Generator ID (fluid_gen_type)
val Value to add to the existing value

References fluid_voice_gen_incr(), and GEN_SET.

Referenced by fluid_voice_gen_incr().

FLUIDSYNTH_API unsigned int fluid_voice_get_id ( fluid_voice_t voice  ) 

Get the unique ID of the noteon-event.

Parameters:
voice Voice instance
Returns:
Note on unique ID

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

  • that its state is still 'playing'
  • that the ID is still the same

Otherwise the voice has finished playing.

References fluid_voice_get_id().

Referenced by fluid_voice_get_id().

FLUIDSYNTH_API int fluid_voice_is_playing ( fluid_voice_t voice  ) 

Check if a voice is still playing.

Parameters:
voice Voice instance
Returns:
TRUE if playing, FALSE otherwise

References fluid_voice_is_playing().

Referenced by delete_fluid_synth(), and fluid_voice_is_playing().

FLUIDSYNTH_API int fluid_voice_optimize_sample ( fluid_sample_t s  ) 

Calculate the peak volume of a sample for voice off optimization.

Parameters:
s Sample to optimize
Returns:
FLUID_OK on success, FLUID_FAILED otherwise

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, _fluid_sample_t::data, FLUID_OK, fluid_voice_optimize_sample(), _fluid_sample_t::loopend, _fluid_sample_t::loopstart, and _fluid_sample_t::valid.

Referenced by fluid_voice_optimize_sample().

Generated on Mon Sep 6 12:29:28 2010 for libfluidsynth by  doxygen 1.6.3