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 voices: Vec<Voice>, pub instrument: Instrument<M, NFG>, pub volume: f32, pub spread: f32, pub loop_points: Option<(f64, f64)>, pub duration_ms: Ms, pub base_pitch: Hz, }
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.
voices: Vec<Voice>
Per-instrument::Voice
state that is unique to the Synth
.
instrument: Instrument<M, NFG>
The instrument used for performing the synth.
volume: f32
An amplitude multiplier.
spread: f32
The amount each voice should be spread across the available channels.
loop_points: Option<(f64, f64)>
The start and end points that will be looped.
duration_ms: Ms
Duration of the Synth instrument in samples.
base_pitch: Hz
Base pitch of the Synth instrument in Steps.
Methods
impl<NFG, W, A, F, FW> Synth<Mono, NFG, W, A, F, FW> where
NFG: NoteFreqGenerator,
[src]
NFG: NoteFreqGenerator,
fn retrigger(nfg: NFG) -> Self
impl<NFG, W, A, F, FW> Synth<Mono, NFG, W, A, F, FW> where
NFG: NoteFreqGenerator,
[src]
NFG: NoteFreqGenerator,
fn legato(nfg: NFG) -> Self
impl<NFG, W, A, F, FW> Synth<Poly, NFG, W, A, F, FW> where
NFG: NoteFreqGenerator,
[src]
NFG: NoteFreqGenerator,
fn poly(nfg: NFG) -> Self
impl<M, NFG, W, A, F, FW> Synth<M, NFG, W, A, F, FW> where
NFG: NoteFreqGenerator,
[src]
NFG: NoteFreqGenerator,
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 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
self,
oscillators: I
) -> Self
Add multiple oscillators to a Synth.
fn duration<D>(self, duration_ms: D) -> Self where
D: Into<Ms>,
D: Into<Ms>,
Set the Synth's duration.
fn base_pitch(self, base_pitch: Hz) -> 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(self, generator: NFG) -> Self
Convert Self
into a new Synth
with the given NoteFreqGenerator.
fn loop_points(self, start: f64, end: f64) -> Self
Set the loop data for the synth.
fn fade<Attack, Release>(self, attack: Attack, release: Release) -> Self where
Attack: Into<Ms>,
Release: Into<Ms>,
Attack: Into<Ms>,
Release: Into<Ms>,
Set the fade data for the synth.
fn loop_start(self, start: f64) -> Self
Set the start loop point.
fn loop_end(self, end: f64) -> Self
Set the end loop point.
fn attack<Attack>(self, attack: Attack) -> Self where
Attack: Into<Ms>,
Attack: Into<Ms>,
Set the attack in milliseconds.
fn release<Release>(self, release: Release) -> Self where
Release: Into<Ms>,
Release: Into<Ms>,
Set the release in milliseconds.
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>,
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>,
M: Mode,
T: Into<Hz>,
Stop playback of the note that was triggered with the matching frequency.
fn stop(&mut self) where
M: Mode,
M: Mode,
Stop playback and clear the current notes.
fn map_instrument<Map, NewM, NewNFG>(
self,
map: Map
) -> Synth<NewM, NewNFG, W, A, F, FW> where
Map: FnOnce(Instrument<M, NFG>) -> Instrument<NewM, NewNFG>,
NewNFG: NoteFreqGenerator,
self,
map: Map
) -> Synth<NewM, NewNFG, W, A, F, FW> where
Map: FnOnce(Instrument<M, NFG>) -> Instrument<NewM, NewNFG>,
NewNFG: NoteFreqGenerator,
Map the Instrument
to a new Instrument
in place.
This is useful for providing wrapper builder methods for the Synth.
fn frames<FRM>(
&mut self,
sample_hz: f64
) -> Frames<FRM, NFG::NoteFreq, W, A, F, FW> where
FRM: Frame,
<FRM::Sample as Sample>::Float: FromSample<f32>,
<FRM::Sample as Sample>::Signed: FromSample<f32>,
&mut self,
sample_hz: f64
) -> Frames<FRM, NFG::NoteFreq, W, A, F, FW> where
FRM: Frame,
<FRM::Sample as Sample>::Float: FromSample<f32>,
<FRM::Sample as Sample>::Signed: FromSample<f32>,
Produces an Iterator
that endlessly yields new Frame
s
fn fill_slice<FRM>(&mut self, output: &mut [FRM], sample_hz: f64) where
FRM: Frame,
<FRM::Sample as Sample>::Float: FromSample<f32>,
<FRM::Sample as Sample>::Signed: FromSample<f32>,
M: Mode,
NFG: NoteFreqGenerator,
W: Waveform,
A: Amplitude,
F: Frequency,
FW: FreqWarp,
FRM: Frame,
<FRM::Sample as Sample>::Float: FromSample<f32>,
<FRM::Sample as Sample>::Signed: FromSample<f32>,
M: Mode,
NFG: NoteFreqGenerator,
W: Waveform,
A: Amplitude,
F: Frequency,
FW: FreqWarp,
Additively fill the given slice of Frame
s with the Synth::frames
method.
Trait Implementations
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,
[src]
NFG: NoteFreqGenerator,
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,
[src]
NFG: NoteFreqGenerator,
impl<M, NFG, W, A, F, FW> PartialEq for Synth<M, NFG, W, A, F, FW> where
M: PartialEq,
NFG: PartialEq + NoteFreqGenerator,
W: PartialEq,
A: PartialEq,
F: PartialEq,
FW: PartialEq,
Instrument<M, NFG>: PartialEq,
[src]
M: PartialEq,
NFG: PartialEq + NoteFreqGenerator,
W: PartialEq,
A: PartialEq,
F: PartialEq,
FW: PartialEq,
Instrument<M, NFG>: PartialEq,
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<FRM, M, NFG, W, A, F, FW> Node<FRM> for Synth<M, NFG, W, A, F, FW> where
FRM: Frame,
<FRM::Sample as Sample>::Float: FromSample<f32>,
<FRM::Sample as Sample>::Signed: FromSample<f32>,
M: Mode,
NFG: NoteFreqGenerator,
W: Waveform,
A: Amplitude,
F: Frequency,
FW: FreqWarp,
[src]
FRM: Frame,
<FRM::Sample as Sample>::Float: FromSample<f32>,
<FRM::Sample as Sample>::Signed: FromSample<f32>,
M: Mode,
NFG: NoteFreqGenerator,
W: Waveform,
A: Amplitude,
F: Frequency,
FW: FreqWarp,
fn audio_requested(&mut self, output: &mut [FRM], sample_hz: f64)
Request audio from the Node given some sample_hz
(aka sample rate in hertz). 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) -> <<F as Frame>::Sample as Sample>::Float
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) -> <<F as Frame>::Sample as Sample>::Float
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