[][src]Struct fluidlite::Synth

pub struct Synth { /* fields omitted */ }

The synth object

You create a new synthesizer with Synth::new(). Use the settings structure to specify the synthesizer characteristics.

You have to load a SoundFont in order to hear any sound. For that you use the Synth::sfload() function.

You can use the audio driver functions described below to open the audio device and create a background audio thread.

The API for sending MIDI events is probably what you expect: Synth::noteon(), Synth::noteoff(), ...

Methods

impl Synth[src]

MIDI channel messages

pub fn note_on(&self, chan: Chan, key: Key, vel: Vel) -> Status[src]

Send a noteon message.

pub fn note_off(&self, chan: Chan, key: Key) -> Status[src]

Send a noteoff message.

pub fn cc(&self, chan: Chan, ctrl: Ctrl, val: Val) -> Status[src]

Send a control change message.

pub fn get_cc(&self, chan: Chan, ctrl: Ctrl) -> Result<Val>[src]

Get a control value.

pub fn pitch_bend(&self, chan: Chan, val: Val) -> Status[src]

Send a pitch bend message.

pub fn get_pitch_bend(&self, chan: Chan) -> Result<Val>[src]

Get the pitch bend value.

pub fn pitch_wheel_sens(&self, chan: Chan, val: Val) -> Status[src]

Set the pitch wheel sensitivity.

pub fn get_pitch_wheel_sens(&self, chan: Chan) -> Result<Val>[src]

Get the pitch wheel sensitivity.

pub fn program_change(&self, chan: Chan, prog: Prog) -> Status[src]

Send a program change message.

pub fn channel_pressure(&self, chan: Chan, val: Val) -> Status[src]

pub fn bank_select(&self, chan: Chan, bank: Bank) -> Status[src]

Select a bank.

pub fn sfont_select(&self, chan: Chan, sfont_id: FontId) -> Status[src]

Select a sfont.

pub fn program_select(
    &self,
    chan: Chan,
    sfont_id: FontId,
    bank_num: Bank,
    preset_num: PresetId
) -> Status
[src]

Select a preset for a channel. The preset is specified by the SoundFont ID, the bank number, and the preset number. This allows any preset to be selected and circumvents preset masking due to previously loaded SoundFonts on the SoundFont stack.

pub fn get_program(&self, chan: Chan) -> Result<(FontId, Bank, PresetId)>[src]

Returns the program, bank, and SoundFont number of the preset on a given channel.

pub fn program_reset(&self) -> Status[src]

Send a bank select and a program change to every channel to reinitialize the preset of the channel.

This function is useful mainly after a SoundFont has been loaded, unloaded or reloaded.

pub fn system_reset(&self) -> Status[src]

Send a reset.

A reset turns all the notes off and resets the controller values.

impl Synth[src]

SoundFont management

pub fn sfload<P: AsRef<Path>>(
    &self,
    filename: P,
    reset_presets: bool
) -> Result<FontId>
[src]

Loads a SoundFont file and creates a new SoundFont. The newly loaded SoundFont will be put on top of the SoundFont stack. Presets are searched starting from the SoundFont on the top of the stack, working the way down the stack until a preset is found.

pub fn sfreload(&self, id: FontId) -> Result<FontId>[src]

Reload a SoundFont. The reloaded SoundFont retains its ID and index on the stack.

pub fn sfunload(&self, id: FontId, reset_presets: bool) -> Status[src]

Removes a SoundFont from the stack and deallocates it.

pub fn sfcount(&self) -> u32[src]

Count the number of loaded SoundFonts.

pub fn get_sfont(&self, num: u32) -> Option<FontRef>[src]

Get a SoundFont. The SoundFont is specified by its index on the stack. The top of the stack has index zero.

  • num The number of the SoundFont (0 <= num < sfcount)

pub fn sfont_iter(&self) -> FontIter[src]

Get an iterator over loaded SoundFonts.

pub fn get_sfont_by_id(&self, id: FontId) -> Option<FontRef>[src]

Get a SoundFont. The SoundFont is specified by its ID.

pub fn remove_sfont(&self, sfont: FontRef)[src]

Remove a SoundFont that was previously added using fluid_synth_add_sfont(). The synthesizer does not delete the SoundFont; this is responsability of the caller.

pub fn get_channel_preset(&self, chan: Chan) -> Option<PresetRef>[src]

Get the preset of a channel

pub fn set_bank_offset(&self, sfont_id: FontId, offset: u32) -> Status[src]

Offset the bank numbers in a SoundFont. Returns -1 if an error occured (out of memory or negative offset)

pub fn get_bank_offset(&self, sfont_id: FontId) -> Result<u32>[src]

Get the offset of the bank numbers in a SoundFont.

impl Synth[src]

pub fn add_sfloader(&self, loader: Loader)[src]

Add a SoundFont loader to the synthesizer. Note that SoundFont loader don't necessarily load SoundFonts. They can load any type of wavetable data but export a SoundFont interface.

impl Synth[src]

Reverb

pub fn set_reverb_params(
    &self,
    roomsize: f64,
    damp: f64,
    width: f64,
    level: f64
)
[src]

Set the parameters for the built-in reverb unit

pub fn set_reverb(&self, params: &ReverbParams)[src]

Set the parameters for the built-in reverb unit

pub fn set_reverb_on(&self, on: bool)[src]

Turn on/off the built-in reverb unit

pub fn get_reverb_roomsize(&self) -> f64[src]

Query the current reverb room size

pub fn get_reverb_damp(&self) -> f64[src]

Query the current reverb dumping

pub fn get_reverb_level(&self) -> f64[src]

Query the current reverb level

pub fn get_reverb_width(&self) -> f64[src]

Query the current reverb width

pub fn get_reverb(&self) -> ReverbParams[src]

Query the current reverb params

impl Synth[src]

Chorus

pub fn set_chorus_params(
    &self,
    nr: u32,
    level: f64,
    speed: f64,
    depth: f64,
    mode: ChorusMode
)
[src]

Set up the chorus. It should be turned on with Synth::chorus_on(). If faulty parameters are given, all new settings are discarded. Keep in mind, that the needed CPU time is proportional to nr.

pub fn set_chorus(&self, params: &ChorusParams)[src]

Set up the chorus. It should be turned on with Synth::chorus_on(). If faulty parameters are given, all new settings are discarded. Keep in mind, that the needed CPU time is proportional to nr.

pub fn set_chorus_on(&self, on: bool)[src]

Turn on/off the built-in chorus unit

pub fn get_chorus_nr(&self) -> u32[src]

Query the current chorus nr

pub fn get_chorus_level(&self) -> f64[src]

Query the current chorus level

pub fn get_chorus_speed(&self) -> f64[src]

Query the current chorus speed (Hz)

pub fn get_chorus_depth(&self) -> f64[src]

Query the current chorus depth (mS)

pub fn get_chorus_mode(&self) -> ChorusMode[src]

Query the current chorus mode

pub fn get_chorus(&self) -> ChorusParams[src]

Query the current chorus params

impl Synth[src]

pub fn count_midi_channels(&self) -> u32[src]

Returns the number of MIDI channels that the synthesizer uses internally

pub fn count_audio_channels(&self) -> u32[src]

Returns the number of audio channels that the synthesizer uses internally

pub fn count_audio_groups(&self) -> u32[src]

Returns the number of audio groups that the synthesizer uses internally. This is usually identical to audio_channels.

pub fn count_effects_channels(&self) -> u32[src]

Returns the number of effects channels that the synthesizer uses internally

impl Synth[src]

Synthesis parameters

pub fn set_gain(&self, gain: f32)[src]

Set the master gain

pub fn get_gain(&self) -> f32[src]

Get the master gain

pub fn set_polyphony(&self, polyphony: u32) -> Status[src]

Set the polyphony limit (FluidSynth >= 1.0.6)

pub fn get_polyphony(&self) -> u32[src]

Get the polyphony limit (FluidSynth >= 1.0.6)

pub fn get_internal_buffer_size(&self) -> usize[src]

Get the internal buffer size. The internal buffer size if not the same thing as the buffer size specified in the settings. Internally, the synth always uses a specific buffer size independent of the buffer size used by the audio driver. The internal buffer size is normally 64 samples. The reason why it uses an internal buffer size is to allow audio drivers to call the synthesizer with a variable buffer length. The internal buffer size is useful for client who want to optimize their buffer sizes.

pub fn set_interp_method(
    &self,
    chan: Option<u32>,
    interp_method: InterpMethod
) -> Status
[src]

Set the interpolation method for one channel (Some(chan)) or all channels (None)

impl Synth[src]

Generator interface

pub fn set_gen(&self, chan: Chan, param: GenParam, value: f32) -> Status[src]

Change the value of a generator. This function allows to control all synthesis parameters in real-time. The changes are additive, i.e. they add up to the existing parameter value. This function is similar to sending an NRPN message to the synthesizer. The function accepts a float as the value of the parameter. The parameter numbers and ranges are described in the SoundFont 2.01 specification, paragraph 8.1.3, page 48.

pub fn get_gen(&self, chan: Chan, param: GenParam) -> f32[src]

Retreive the value of a generator. This function returns the value set by a previous call 'set_gen()' or by an NRPN message.

Returns the value of the generator.

impl Synth[src]

Tuning

pub fn create_key_tuning<S: AsRef<str>>(
    &self,
    tuning_bank: Bank,
    tuning_prog: Prog,
    name: S,
    pitch: &[f64; 128]
) -> Status
[src]

Create a new key-based tuning with given name, number, and pitches. The array 'pitches' should have length 128 and contains the pitch in cents of every key in cents. However, if 'pitches' is NULL, a new tuning is created with the well-tempered scale.

pub fn create_octave_tuning<S: AsRef<str>>(
    &self,
    tuning_bank: Bank,
    tuning_prog: Prog,
    name: S,
    pitch: &[f64; 12]
) -> Status
[src]

Create a new octave-based tuning with given name, number, and pitches. The array 'pitches' should have length 12 and contains derivation in cents from the well-tempered scale. For example, if pitches[0] equals -33, then the C-keys will be tuned 33 cents below the well-tempered C.

pub fn activate_octave_tuning<S: AsRef<str>>(
    &self,
    bank: Bank,
    prog: Prog,
    name: S,
    pitch: &[f64; 12],
    apply: bool
) -> Status
[src]

pub fn tune_notes<K, P>(
    &self,
    tuning_bank: Bank,
    tuning_prog: Prog,
    keys: K,
    pitch: P,
    apply: bool
) -> Status where
    K: AsRef<[u32]>,
    P: AsRef<[f64]>, 
[src]

Request a note tuning changes. Both they 'keys' and 'pitches' arrays should be of length 'num_pitches'. If 'apply' is non-zero, the changes should be applied in real-time, i.e. sounding notes will have their pitch updated. 'APPLY' IS CURRENTLY IGNORED. The changes will be available for newly triggered notes only.

pub fn select_tuning(
    &self,
    chan: Chan,
    tuning_bank: Bank,
    tuning_prog: Prog
) -> Status
[src]

Select a tuning for a channel.

pub fn activate_tuning(
    &self,
    chan: Chan,
    bank: Bank,
    prog: Prog,
    apply: bool
) -> Status
[src]

pub fn reset_tuning(&self, chan: Chan) -> Status[src]

Set the tuning to the default well-tempered tuning on a channel.

Important traits for TuningIter<'a>
pub fn tuning_iter(&self) -> TuningIter[src]

Get the iterator throught the list of available tunings.

pub fn tuning_dump(
    &self,
    bank: Bank,
    prog: Prog
) -> Result<(String, [f64; 128])>
[src]

Dump the data of a tuning.

This function returns both the name and pitch values of a tuning.

pub fn tuning_dump_name(&self, bank: Bank, prog: Prog) -> Result<String>[src]

Dump the data of a tuning.

This function returns the only name of a tuning.

pub fn tuning_dump_pitch(&self, bank: Bank, prog: Prog) -> Result<[f64; 128]>[src]

Dump the data of a tuning.

This function returns the only pitch values of a tuning.

impl Synth[src]

Synthesizer plugin

pub fn write<S: IsSamples>(&self, samples: S) -> Status[src]

Write sound samples to the sample data buffer

pub unsafe fn write_i16(
    &self,
    len: usize,
    lbuf: *mut i16,
    loff: u32,
    lincr: u32,
    rbuf: *mut i16,
    roff: u32,
    rincr: u32
) -> Status
[src]

Write samples as 16-bit signed integers

Note: The len must corresponds to the lenghtes of buffers.

pub unsafe fn write_f32(
    &self,
    len: usize,
    lbuf: *mut f32,
    loff: u32,
    lincr: u32,
    rbuf: *mut f32,
    roff: u32,
    rincr: u32
) -> Status
[src]

Write samples as 32-bit floating-point numbers

Note: The len must corresponds to the lenghtes of buffers.

impl Synth[src]

pub fn new(settings: Settings) -> Result<Self>[src]

Creates a new synthesizer object.

As soon as the synthesizer is created, it will start playing.

pub fn set_sample_rate(&self, sample_rate: f32)[src]

Set synth sample rate

pub fn get_settings(&self) -> SettingsRef[src]

Get a reference to the settings of the synthesizer.

Trait Implementations

impl Drop for Synth[src]

impl Send for Synth[src]

Auto Trait Implementations

impl RefUnwindSafe for Synth

impl !Sync for Synth

impl Unpin for Synth

impl UnwindSafe for Synth

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.