pub struct Oscillator<T> { /* private fields */ }

Implementations§

source§

impl Oscillator<f32>

source

pub fn sine(sample_rate: f32) -> Oscillator<f32>

Construct a sine generator

source§

impl<T> Oscillator<T>

source

pub fn new_with_sample_rate( sample_rate: f32, generator_fn: fn(_: T) -> T ) -> Self

Construct a new oscillator with a given sample rate

source

pub fn new(generator_fn: fn(_: T) -> T) -> Self

Construct an oscillator with 44.1Hz default sample rate

source§

impl<T> Oscillator<T>

source

pub fn set_generator(&mut self, generator_fn: fn(_: T) -> T)

Set the generator function

source§

impl<T> Oscillator<T>

source

pub fn set_sample_rate(&mut self, sample_rate: f32)

Set the sample rate

source§

impl<T> Oscillator<T>

source

pub fn get_frequency(&self) -> f32

Get the oscillator frequency

source

pub fn set_frequency(&mut self, frequency: f32)

Set the oscillator frequency

source§

impl<T> Oscillator<T>
where T: From<f32>,

source

pub fn next_sample(&mut self) -> T

Process a single sample & update the oscillator phase.

source

pub fn tick_n(&mut self, n: f32)

source

pub fn tick(&mut self)

source

pub fn value_for_phase(&self, phase: T) -> T

source

pub fn get(&self) -> T

source

pub fn phase(&self) -> f32

Return the current phase as a number between 0-1

Trait Implementations§

source§

impl<T: Clone> Clone for Oscillator<T>

source§

fn clone(&self) -> Oscillator<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Oscillator<T>

§

impl<T> Send for Oscillator<T>

§

impl<T> Sync for Oscillator<T>

§

impl<T> Unpin for Oscillator<T>

§

impl<T> UnwindSafe for Oscillator<T>

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<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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.