Struct synth::Synth
[−]
[src]
pub struct Synth<M, NFG, W, A, F, FW> where NFG: NoteFreqGenerator { pub oscillators: Vec<Oscillator<W, A, F, FW>>, pub mode: M, pub channels: Vec<f32>, pub voices: Vec<Voice<NFG::NoteFreq>>, pub detune: f32, pub spread: f32, pub duration: Duration, pub base_pitch: BasePitch, pub volume: f32, pub note_freq_gen: NFG, pub loop_data: Option<(LoopStart, LoopEnd)>, pub fade_data: Option<(Attack, Release)>, pub is_paused: bool, }
The Synth
generates audio via a vector of Voice
s, while a Voice
generates audio via a
vector of Oscillator
s, creating a small DSP tree.
Fields
oscillators: Vec<Oscillator<W, A, F, FW>>
Oscillators for playback.
mode: M
The mode of note playback.
channels: Vec<f32>
The amplitude for each channel.
voices: Vec<Voice<NFG::NoteFreq>>
The voices used by the Synth. - If the Synth is in Poly mode, it will play one voice at a time. - If the Synth is in Mono mode, it will play all voices at once.
detune: f32
The amount each voice's note_on should be detuned.
spread: f32
The amount each voice should be spread across the available channels.
duration: Duration
Duration of the Synth instrument in samples.
base_pitch: BasePitch
Base pitch of the Synth instrument in Steps.
volume: f32
Amplitude multiplier (volume).
note_freq_gen: NFG
The duration at which it takes to drift from the current note to some new note.
loop_data: Option<(LoopStart, LoopEnd)>
Data used for looping over a duration of the Synth.
fade_data: Option<(Attack, Release)>
Data used for fading in / out from playback.
is_paused: bool
Is the playback currently paused?
Methods
impl<M, NFG, W, A, F, FW> Synth<M, NFG, W, A, F, FW> where NFG: NoteFreqGenerator
[src]
fn new(mode: M, note_freq_gen: NFG) -> Self
Constructor for a new Synth.
fn num_voices(self, num_voices: usize) -> Self
Return the synth with the given number of voices.
fn set_num_voices(&mut self, num_voices: usize)
Set the number of voices that the Synth shall use.
fn mode<NewM>(self, new_mode: NewM) -> Synth<NewM, NFG, W, A, F, FW>
Changes the mode of the Synth.
fn oscillator(self, oscillator: Oscillator<W, A, F, FW>) -> Self
Add an oscillator to a Synth.
fn oscillators<I: Iterator<Item=Oscillator<W, A, F, FW>>>(self, oscillators: I) -> Self
Add multiple oscillators to a Synth.
fn duration(self, duration: Duration) -> Self
Set the Synth's duration.
fn channels(self, channels: Vec<f32>) -> Self
Set the amplitude for each channel.
fn stereo_pan(self, pan: f32) -> Self
Set the amplitude of each channel according to a given stereo pan between -1.0 and 1.0. If the given value is outside the range -1.0..1.0, it will be clamped to range. The synth's number of channels will be set to two if it does not already have two.
fn base_pitch(self, base_pitch: BasePitch) -> Self
Set the Synth's base pitch.
fn detune(self, detune: f32) -> Self
Set the Synth's detune amount.
fn spread(self, spread: f32) -> Self
Set the Synth's spread amount.
fn volume(self, vol: f32) -> Self
Set the Synth's volume.
fn note_freq_generator<NewNFG>(self, generator: NewNFG) -> Synth<M, NewNFG, W, A, F, FW> where NewNFG: NoteFreqGenerator
Set the Synth's portamento duration in milliseconds.
fn loop_points(self, start: LoopStart, end: LoopEnd) -> Synth<M, NFG, W, A, F, FW>
Set the loop data for the synth.
fn fade(self, attack: Attack, release: Release) -> Synth<M, NFG, W, A, F, FW>
Set the fade data for the synth.
fn loop_start(self, start: LoopStart) -> Synth<M, NFG, W, A, F, FW>
Set the start loop point.
fn loop_end(self, end: LoopEnd) -> Synth<M, NFG, W, A, F, FW>
Set the end loop point.
fn attack(self, attack: Attack) -> Synth<M, NFG, W, A, F, FW>
Set the attack.
fn release(self, release: Release) -> Synth<M, NFG, W, A, F, FW>
Set the release.
fn add_oscillator(&mut self, oscillator: Oscillator<W, A, F, FW>)
Add an oscillator.
fn remove_oscillator(&mut self, idx: usize) -> Oscillator<W, A, F, FW>
Remove and return the oscillator at the given idx.
fn is_active(&self) -> bool
Return whether or not there are any currently active voices.
fn note_on<T>(&mut self, note_hz: T, note_vel: NoteVelocity) where M: Mode, T: Into<Hz>
Begin playback of a note. Synth will try to use a free Voice
to do this.
If no Voice
s are free, the one playing the oldest note will be chosen to
play the new note instead.
fn note_off<T>(&mut self, note_hz: T) where M: Mode, T: Into<Hz>
Stop playback of the note that was triggered with the matching frequency.
fn pause(&mut self)
Pause playback.
fn unpause(&mut self)
Unpause playback.
fn stop(&mut self) where M: Mode
Stop playback and clear the current notes.
Trait Implementations
impl<M: Decodable, NFG: Decodable, W: Decodable, A: Decodable, F: Decodable, FW: Decodable> Decodable for Synth<M, NFG, W, A, F, FW> where NFG: NoteFreqGenerator, NFG::NoteFreq: Decodable
[src]
fn decode<__DMNFGWAFFW: Decoder>(__arg_0: &mut __DMNFGWAFFW) -> Result<Synth<M, NFG, W, A, F, FW>, __DMNFGWAFFW::Error>
impl<M: Encodable, NFG: Encodable, W: Encodable, A: Encodable, F: Encodable, FW: Encodable> Encodable for Synth<M, NFG, W, A, F, FW> where NFG: NoteFreqGenerator, NFG::NoteFreq: Encodable
[src]
fn encode<__SMNFGWAFFW: Encoder>(&self, __arg_0: &mut __SMNFGWAFFW) -> Result<(), __SMNFGWAFFW::Error>
impl<M: Clone, NFG: Clone, W: Clone, A: Clone, F: Clone, FW: Clone> Clone for Synth<M, NFG, W, A, F, FW> where NFG: NoteFreqGenerator, NFG::NoteFreq: Clone
[src]
fn clone(&self) -> Synth<M, NFG, W, A, F, FW>
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
impl<M: Debug, NFG: Debug, W: Debug, A: Debug, F: Debug, FW: Debug> Debug for Synth<M, NFG, W, A, F, FW> where NFG: NoteFreqGenerator, NFG::NoteFreq: Debug
[src]
impl<S, M, NFG, W, A, F, FW> DspNode<S> for Synth<M, NFG, W, A, F, FW> where S: Sample, NFG: NoteFreqGenerator, W: Waveform, A: Amplitude, F: Frequency, FW: FreqWarp
[src]
fn audio_requested(&mut self, output: &mut [S], settings: DspSettings)
Request audio from the Node given some stream format Settings. If the Node has no inputs, the buffer
will be zeroed. If the Node has some inputs, the buffer
will consist of the inputs summed together. Read more
fn dry(&self) -> f32
Following the call to the Node
's audio_requested
method, the Graph
will sum together some of the original (dry) signal with some of the processed (wet) signal. Read more
fn wet(&self) -> f32
Following the call to the Node
's audio_requested
method, the Graph
will sum together some of the original (dry) signal with some of the processed (wet) signal. Read more