AudioOutput

Struct AudioOutput 

Source
pub struct AudioOutput(/* private fields */);
Expand description

Represents an open audio output stream.

You can use AUDIOS.open_output to open a new output stream.

Implementations§

Source§

impl AudioOutput

Source

pub fn id(&self) -> AudioOutputId

Unique ID of this output.

Source

pub fn cue(&self, audio: impl Into<AudioMix>)

Enqueue the audio for playback in this output.

The audio will play when the output is playing and the previous cued audio finishes.

Source

pub fn volume(&self) -> Var<Factor>

Volume of the sound.

The value multiplies the samples, 1.fct() is the natural volume from the source.

Source

pub fn speed(&self) -> Var<Factor>

Speed of the sound.

This is a multiplier of the playback speed and pitch.

  • 0.5.fct() doubles the total duration and halves (lowers) the pitch.
  • 2.fct() halves the total duration and doubles (raises) the pitch.
Source

pub fn state(&self) -> Var<AudioOutputState>

Output playback state.

This variable can be set to change the state.

Note that because variable modifications apply at once you cannot stop and play in the same update cycle using this. Use the

The default value is AudioOutputState::Playing.

Source

pub fn play(&self)

Change state to Playing.

Audio is sent to the device for playback as audio is cued.

Source

pub fn pause(&self)

Change state to Paused.

Audio playback is paused, cue requests are buffered.

Source

pub fn stop(&self)

Change state to Stopped.

Audio playback is paused, all current cue requests are dropped.

Source

pub fn stop_play(&self)

Change state to Stopped and then Playing in the same update cycle.

Source

pub fn perm(&self)

Keep the audio output open until the end of the app.

Source

pub fn is_connected(&self) -> Var<bool>

Read-only variable that tracks if this output is connected with the view-process.

When this is false the error might be set. Outputs automatically try to reconnect in case of view-process respawn, but note that it will respawn in the Stopped state.

Source

pub fn error(&self) -> Var<Option<Txt>>

Gets an error message if view-process connection has failed.

Reconnection is attempted on view-process respawn, the is_connected tracks the ok status. Note that the first connection attempt is true in is_connected and None here.

Source§

impl AudioOutput

Source

pub fn downgrade(&self) -> WeakAudioOutput

Create a weak reference to this audio output.

Trait Implementations§

Source§

impl Clone for AudioOutput

Source§

fn clone(&self) -> AudioOutput

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AudioOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AudioOutput

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for AudioOutput

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> AnyVarValue for T
where T: Debug + PartialEq + Clone + Any + Send + Sync,

Source§

fn clone_boxed(&self) -> BoxAnyVarValue

Clone the value.
Source§

fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool

Gets if self and other are equal.
Source§

fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool

Swap value with other if both are of the same type.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoVar<T> for T
where T: VarValue,

Source§

fn into_var(self) -> Var<T>

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> IntoValue<T> for T
where T: VarValue,

Source§

impl<T> StateValue for T
where T: Any + Send + Sync,

Source§

impl<T> VarValue for T