Struct instrument::Instrument [] [src]

pub struct Instrument<M, NFG> where
    NFG: NoteFreqGenerator
{ pub mode: M, pub voices: Vec<Voice<NFG::NoteFreq>>, pub detune: f32, pub note_freq_gen: NFG, pub attack_ms: Ms, pub release_ms: Ms, }

A performable Instrument type that converts Note events into a sequence of voices, each with their own unique amplitude and frequency per frame. This is useful for driving the playback of instrument types like synthesisers or samplers.

Instrument handles the following logic:

  • Playback mode: Legato, Retrigger or Polyphonic.
  • Note on detuning.
  • Note on "interoplation" / frequency generation: Legato or Constant.
  • Sustained note warping:
  • Multi-channel audio processing.

Fields

The mode of note playback.

The stack of Voices used by the Instrument. - If the Instrument is in Mono mode, it will play one voice at a time. - If the Instrument is in Poly mode, it will play all voices at once.

The amount each voice's note_on should be detuned.

Note on "interoplation" / frequency generation: Legato or Constant.

A duration in frames over which the amplitude of each note will fade in after note_on.

A duration in frames over which the amplitude of each note will fade out after note_off.

Methods

impl<M, NFG> Instrument<M, NFG> where
    NFG: NoteFreqGenerator
[src]

Construct a new Instrument of the given mode using the given note frequency generator.

Build the Instrument with the given number of voices.

Set the note fades for the Instrument in frames.

Set the attack.

Set the release.

Set the Instrument's note_on detune amount.

Convert Self into a new Instrument with the given NoteFreqGenerator.

Generates new NoteFreqs for each of the currently active Voices.

Set the number of voices that the Instrument shall use.

Return whether or not there are any currently active voices.

Begin playback of a note. Instrument will try to use a free Voice to do this.

If no Voices are free, the one playing the oldest note will be chosen to play the new note instead.

Stop playback of the note that was triggered with the matching frequency.

Stop playback and clear the current notes.

Provides an Iterator like type that consecutively yields the next_frame_per_voice for the given sample_hz.

Produces an Iterator that yields the amplitude and frequency of each voice for the next frame.

Trait Implementations

impl<M: Clone, NFG: Clone> Clone for Instrument<M, NFG> where
    NFG: NoteFreqGenerator,
    NFG::NoteFreq: Clone
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<M: Debug, NFG: Debug> Debug for Instrument<M, NFG> where
    NFG: NoteFreqGenerator,
    NFG::NoteFreq: Debug
[src]

Formats the value using the given formatter.

impl<M: PartialEq, NFG: PartialEq> PartialEq for Instrument<M, NFG> where
    NFG: NoteFreqGenerator,
    NFG::NoteFreq: PartialEq
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.