Skip to main content

Audio

Struct Audio 

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

The audio service, from cx.audio(). Cloning it is cheap.

Implementations§

Source§

impl Audio

Source

pub fn peaks( &self, target: impl IntoProp<Option<PeakTarget>>, ) -> ReadSignal<Vec<f32>>

A peak meter, as Quickshell’s PwNodePeakMonitor: each channel’s loudest sample over the last 1/25 s, from 0 to 1, in the order of the target’s channels. Empty while there is no target; all 0 while nothing plays.

target takes a PeakTarget or a closure returning an Option of one; None stops the meter. A panic in the closure is logged and stops the meter until the next change.

While it records, the shell wakes 25 times a second, but the signal is set only when a peak changes. A sink’s or stream’s meter records only while something plays; a source’s records all the time. It stops when the context that asked goes.

Source§

impl Audio

Source

pub fn play_sound(&self, path: impl AsRef<Path>)

Plays the WAV file at path once on the default sink, as Qt’s SoundEffect. It is read at once, on the loop’s thread, so keep sounds short. A file that can’t be read or played is logged once and skipped, and with no audio server nothing plays. The stream goes once the server has played it, and nothing wakes the shell after.

Source§

impl Audio

Source

pub fn default_sink(&self) -> ReadSignal<Option<Sink>>

The default sink. None while there is no audio server or the server has no sink. Every caller gets the same signal.

Source

pub fn change_volume(&self, percent: i32)

Changes the default sink’s volume by percent, louder when positive, and keeps it within 0-100%, so a step from above 100% lands on 100%. Every channel moves by the same amount, keeping their balance, except that one reaching 0% or 100% stops there. With no sink or no server it does nothing.

Source

pub fn toggle_mute(&self)

Mutes the default sink, or unmutes it. With no sink or no server it does nothing.

Source

pub fn sinks(&self) -> ReadSignal<Vec<AudioNode>>

Every sink, in the server’s order. Empty while there is no server.

Source

pub fn sources(&self) -> ReadSignal<Vec<AudioNode>>

Every source except sinks’ monitors, in the server’s order.

Source

pub fn default_source(&self) -> ReadSignal<Option<AudioNode>>

The default source, where a call’s microphone sound comes from.

Source

pub fn streams(&self) -> ReadSignal<Vec<AudioStream>>

Every app playing sound, in the server’s order.

Source

pub fn set_default_sink(&self, name: &str)

Makes the sink called name the default.

Source

pub fn set_default_source(&self, name: &str)

Makes the source called name the default.

Source

pub fn set_sink_volume(&self, name: &str, percent: u32)

Sets every channel of the sink called name to percent, at most 100.

Source

pub fn set_sink_volumes(&self, name: &str, percents: &[u32])

Sets each channel of the sink called name to its own percent, at most 100, in the order of AudioNode::channels, as a balance slider does. A list of another length than the sink’s channels is logged and not sent.

Source

pub fn set_sink_mute(&self, name: &str, muted: bool)

Mutes the sink called name, or unmutes it.

Source

pub fn set_source_volume(&self, name: &str, percent: u32)

Sets every channel of the source called name to percent, at most 100.

Source

pub fn set_source_volumes(&self, name: &str, percents: &[u32])

Sets each channel of the source called name, as set_sink_volumes does a sink’s.

Source

pub fn set_source_mute(&self, name: &str, muted: bool)

Mutes the source called name, or unmutes it, as a microphone button does.

Source

pub fn set_stream_volume(&self, index: u32, percent: u32)

Sets every channel of the stream numbered index to percent, at most 100.

Source

pub fn set_stream_volumes(&self, index: u32, percents: &[u32])

Sets each channel of the stream numbered index, as set_sink_volumes does a sink’s.

Source

pub fn set_stream_mute(&self, index: u32, muted: bool)

Mutes the stream numbered index, or unmutes it.

Source

pub fn move_stream(&self, index: u32, sink: &str)

Moves the stream numbered index to play to the sink called sink.

Trait Implementations§

Source§

impl Clone for Audio

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Audio

§

impl !Send for Audio

§

impl !Sync for Audio

§

impl !UnwindSafe for Audio

§

impl Forget for Audio

§

impl Freeze for Audio

§

impl Move for Audio

§

impl Unpin for Audio

§

impl UnsafeUnpin for Audio

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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