Skip to main content

Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

The multi-channel output (rodio).

Implementations§

Source§

impl Device

Source

pub fn play( &mut self, sound: &Sound, params: PlayParams, ) -> Result<Option<Channel>, String>

Device::Play: start sound on the first free channel. Ok(None) when all 64 are busy (the original returns null); Err when there is no audio output.

Source

pub fn stop(&mut self, c: Channel)

Device::Stop.

Source

pub fn stop_all(&mut self)

Scene::StopAll.

Source

pub fn update(&mut self) -> Vec<Channel>

Device::Update: free the channels that finished, returning them (the end callbacks).

Source

pub fn is_playing(&self, c: Channel) -> bool

Whether the channel is still allocated and has not finished.

Source

pub fn is_active(&self, c: Channel) -> bool

Whether the channel is allocated and has not finished, paused or not.

Source

pub fn active(&self) -> usize

The number of channels in use.

Source

pub fn pause(&mut self, c: Channel)

Pause a channel. The other channels go on.

Source

pub fn resume(&mut self, c: Channel)

Resume a paused channel.

Source

pub fn is_paused(&self, c: Channel) -> bool

Whether the channel is paused.

Source

pub fn position(&self, c: Channel) -> Duration

Position in the sound (wrapped for looping channels).

Source

pub fn seek(&mut self, c: Channel, position: Duration) -> Result<(), String>

Move a channel to a position in its sound.

Source

pub fn set_volume(&mut self, c: Channel, volume: f32)

Device::SetChannelVolume.

Source

pub fn set_pitch(&mut self, c: Channel, semitones: f32)

Change a channel’s pitch, in semitones.

Source

pub fn set_looping(&mut self, c: Channel, looping: bool)

Change whether a channel loops.

Source

pub fn set_master_volume(&mut self, volume: f32)

Scales every channel.

Source

pub fn unlock(&mut self)

Browsers start audio suspended until a user gesture; nothing to do natively.

Trait Implementations§

Source§

impl Default for Device

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Mixer for Device

Source§

fn play(&mut self, sound: &Sound, params: PlayParams) -> Option<Channel>

Start a sound on a free channel, or return None when no channel is free.
Source§

fn stop(&mut self, channel: Channel)

Stop a channel.
Source§

fn set_volume(&mut self, channel: Channel, volume: f32)

Change a channel’s volume.

Auto Trait Implementations§

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
§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

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.

§

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

§

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.