Struct synth::Voice [] [src]

pub struct Voice<NF> {
    pub oscillator_states: Vec<OscillatorState>,
    pub maybe_note: Option<(NoteState, NoteHz, NF, NoteVelocity)>,
    pub playhead: Playhead,
    pub loop_playhead: LoopPlayhead,
}

A single Voice. A Synth may consist of any number of Voices.

Fields

oscillator_states: Vec<OscillatorState>

The current phase for each oscillator owned by the Synth.

maybe_note: Option<(NoteState, NoteHz, NF, NoteVelocity)>

Data for a note, if there is one currently being played.

playhead: Playhead

Playhead over the current note.

loop_playhead: LoopPlayhead

Playhead over the loop duration.

Methods

impl<NF> Voice<NF>
[src]

fn new(num_oscillators: usize) -> Voice<NF>

Constructor for a Voice.

fn reset_playheads(&mut self)

Reset the voice's playheads.

fn note_on(&mut self, hz: NoteHz, freq: NF, vel: NoteVelocity)

Trigger playback with the given note, resetting all playheads.

fn note_off(&mut self)

Release playback of the current not eif there is one.

fn stop(&mut self)

Stop playback of the current note if there is one and reset the playheads.

fn fill_buffer<S, W, A, F, FW>(&mut self, output: &mut [S], settings: DspSettings, oscillators: &[Oscillator<W, A, F, FW>], duration: Samples, base_pitch: Hz, loop_data: Option<&(LoopStart, LoopEnd)>, fade_data: Option<&(Attack, Release)>) where NF: NoteFreq, S: Sample + FromSample<f32>, W: Waveform, A: Amplitude, F: Frequency, FW: FreqWarp

Generate and fill the audio buffer for the given parameters.

Trait Implementations

impl<NF: Decodable> Decodable for Voice<NF>
[src]

fn decode<__DNF: Decoder>(__arg_0: &mut __DNF) -> Result<Voice<NF>, __DNF::Error>

impl<NF: Encodable> Encodable for Voice<NF>
[src]

fn encode<__SNF: Encoder>(&self, __arg_0: &mut __SNF) -> Result<(), __SNF::Error>

impl<NF: Debug> Debug for Voice<NF>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<NF: Clone> Clone for Voice<NF>
[src]

fn clone(&self) -> Voice<NF>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more