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

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

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

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>,