Struct Synth

Source
pub struct Synth {
    pub channel_count: usize,
    pub next_synth: usize,
    /* private fields */
}

Fields§

§channel_count: usize§next_synth: usize

Implementations§

Source§

impl Synth

Source

pub fn new() -> Synth

Examples found in repository?
examples/simple_synth.rs (line 6)
5fn main() {
6    let mut synth = Synth::new();
7    let voice = synth.new_synth(1.0, 220.0);
8    std::thread::sleep(Duration::from_secs(2));
9    synth.set_volume(voice, 0.5);
10    synth.set_pitch(voice, 440.0);
11    std::thread::sleep(Duration::from_secs(2));
12    synth.stop_all();
13    std::thread::sleep(Duration::from_millis(100));
14}
More examples
Hide additional examples
examples/smooth_pitch.rs (line 6)
5fn main() {
6    let mut syn = Synth::new();
7    let v = syn.new_synth(0.5, 440.0);
8    std::thread::sleep(Duration::from_secs(1));
9    syn.set_pitch_lerp(v, 220.0, 10.0);
10    std::thread::sleep(Duration::from_secs(10));
11    let mut f = 440.0f32;
12    for _i in 0..1000 {
13        f -= 0.1;
14        syn.set_pitch(v, f);
15        std::thread::sleep(Duration::from_millis(10));
16    }
17}
Source

pub fn get_sinks() -> SinkList

Source

pub fn new_on_sink(audio_sink: impl Into<Device>) -> Synth

Source

pub fn new_synth(&mut self, volume: f32, pitch: f32) -> SynthId

Examples found in repository?
examples/simple_synth.rs (line 7)
5fn main() {
6    let mut synth = Synth::new();
7    let voice = synth.new_synth(1.0, 220.0);
8    std::thread::sleep(Duration::from_secs(2));
9    synth.set_volume(voice, 0.5);
10    synth.set_pitch(voice, 440.0);
11    std::thread::sleep(Duration::from_secs(2));
12    synth.stop_all();
13    std::thread::sleep(Duration::from_millis(100));
14}
More examples
Hide additional examples
examples/smooth_pitch.rs (line 7)
5fn main() {
6    let mut syn = Synth::new();
7    let v = syn.new_synth(0.5, 440.0);
8    std::thread::sleep(Duration::from_secs(1));
9    syn.set_pitch_lerp(v, 220.0, 10.0);
10    std::thread::sleep(Duration::from_secs(10));
11    let mut f = 440.0f32;
12    for _i in 0..1000 {
13        f -= 0.1;
14        syn.set_pitch(v, f);
15        std::thread::sleep(Duration::from_millis(10));
16    }
17}
Source

pub fn set_volume(&mut self, synth: SynthId, volume: f32)

Examples found in repository?
examples/simple_synth.rs (line 9)
5fn main() {
6    let mut synth = Synth::new();
7    let voice = synth.new_synth(1.0, 220.0);
8    std::thread::sleep(Duration::from_secs(2));
9    synth.set_volume(voice, 0.5);
10    synth.set_pitch(voice, 440.0);
11    std::thread::sleep(Duration::from_secs(2));
12    synth.stop_all();
13    std::thread::sleep(Duration::from_millis(100));
14}
Source

pub fn set_volume_lerp(&mut self, synth: SynthId, volume: f32, lerp_time: f32)

Source

pub fn set_pitch(&mut self, synth: SynthId, pitch: f32)

Examples found in repository?
examples/simple_synth.rs (line 10)
5fn main() {
6    let mut synth = Synth::new();
7    let voice = synth.new_synth(1.0, 220.0);
8    std::thread::sleep(Duration::from_secs(2));
9    synth.set_volume(voice, 0.5);
10    synth.set_pitch(voice, 440.0);
11    std::thread::sleep(Duration::from_secs(2));
12    synth.stop_all();
13    std::thread::sleep(Duration::from_millis(100));
14}
More examples
Hide additional examples
examples/smooth_pitch.rs (line 14)
5fn main() {
6    let mut syn = Synth::new();
7    let v = syn.new_synth(0.5, 440.0);
8    std::thread::sleep(Duration::from_secs(1));
9    syn.set_pitch_lerp(v, 220.0, 10.0);
10    std::thread::sleep(Duration::from_secs(10));
11    let mut f = 440.0f32;
12    for _i in 0..1000 {
13        f -= 0.1;
14        syn.set_pitch(v, f);
15        std::thread::sleep(Duration::from_millis(10));
16    }
17}
Source

pub fn set_pitch_lerp(&mut self, synth: SynthId, pitch: f32, lerp_time: f32)

Examples found in repository?
examples/smooth_pitch.rs (line 9)
5fn main() {
6    let mut syn = Synth::new();
7    let v = syn.new_synth(0.5, 440.0);
8    std::thread::sleep(Duration::from_secs(1));
9    syn.set_pitch_lerp(v, 220.0, 10.0);
10    std::thread::sleep(Duration::from_secs(10));
11    let mut f = 440.0f32;
12    for _i in 0..1000 {
13        f -= 0.1;
14        syn.set_pitch(v, f);
15        std::thread::sleep(Duration::from_millis(10));
16    }
17}
Source

pub fn set_channel_mask(&mut self, synth: SynthId, channel_mask: ChannelMask)

Source

pub fn set_channel_mask_lerp( &mut self, synth: SynthId, channel_mask: ChannelMask, lerp_time: f32, )

Source

pub fn stop_all(&mut self)

Examples found in repository?
examples/simple_synth.rs (line 12)
5fn main() {
6    let mut synth = Synth::new();
7    let voice = synth.new_synth(1.0, 220.0);
8    std::thread::sleep(Duration::from_secs(2));
9    synth.set_volume(voice, 0.5);
10    synth.set_pitch(voice, 440.0);
11    std::thread::sleep(Duration::from_secs(2));
12    synth.stop_all();
13    std::thread::sleep(Duration::from_millis(100));
14}

Auto Trait Implementations§

§

impl Freeze for Synth

§

impl !RefUnwindSafe for Synth

§

impl !Send for Synth

§

impl !Sync for Synth

§

impl Unpin for Synth

§

impl !UnwindSafe for Synth

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,