Struct nannou_audio::stream::Stream

source ·
pub struct Stream<M> { /* private fields */ }
Expand description

A clone-able handle around an audio stream.

Implementations§

source§

impl<M> Stream<M>

source

pub fn play(&self) -> Result<(), PlayStreamError>

Command the audio device to start processing this stream.

Calling this will activate capturing/rendering, in turn calling the given audio capture/render function.

Has no effect if the stream is already running.

source

pub fn pause(&self) -> Result<(), PauseStreamError>

Command the audio device to stop processing this stream.

Calling this will pause rendering/capturing.

Has no effect is the stream was already paused.

source

pub fn is_playing(&self) -> bool

Whether or not the stream is currently playing.

source

pub fn is_paused(&self) -> bool

Whether or not the stream is currently paused.

source

pub fn send<F>( &self, update: F ) -> Result<(), SendError<Box<dyn FnMut(&mut M) + Send + 'static>>>
where F: FnOnce(&mut M) + Send + 'static,

Send the given model update to the audio thread to be applied ASAP.

If the audio is currently rendering, the update will be applied immediately after the function call completes.

If the stream is currently paused, the update will be applied immediately.

Note: This function will be applied on the real-time audio thread so users should avoid performing any kind of I/O, locking, blocking, (de)allocations or anything that may run for an indeterminate amount of time.

source

pub fn cpal_config(&self) -> &StreamConfig

The config with which the inner CPAL stream was created.

This should match the actual stream config that is running. If not, there may be a bug in CPAL. However, note that if the sample_format does not match, this just means that nannou is doing a conversion behind the scenes as the hardware itself does not support the target format.

Trait Implementations§

source§

impl<M> Clone for Stream<M>

source§

fn clone(&self) -> Self

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<M> !RefUnwindSafe for Stream<M>

§

impl<M> !Send for Stream<M>

§

impl<M> !Sync for Stream<M>

§

impl<M> Unpin for Stream<M>

§

impl<M> !UnwindSafe for Stream<M>

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

§

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.
source§

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