pub struct Audio { /* private fields */ }Expand description
The audio service, from cx.audio(). Cloning it is cheap.
Implementations§
Source§impl Audio
impl Audio
Sourcepub fn peaks(
&self,
target: impl IntoProp<Option<PeakTarget>>,
) -> ReadSignal<Vec<f32>>
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
impl Audio
Sourcepub fn play_sound(&self, path: impl AsRef<Path>)
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
impl Audio
Sourcepub fn default_sink(&self) -> ReadSignal<Option<Sink>>
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.
Sourcepub fn change_volume(&self, percent: i32)
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.
Sourcepub fn toggle_mute(&self)
pub fn toggle_mute(&self)
Mutes the default sink, or unmutes it. With no sink or no server it does nothing.
Sourcepub fn sinks(&self) -> ReadSignal<Vec<AudioNode>>
pub fn sinks(&self) -> ReadSignal<Vec<AudioNode>>
Every sink, in the server’s order. Empty while there is no server.
Sourcepub fn sources(&self) -> ReadSignal<Vec<AudioNode>>
pub fn sources(&self) -> ReadSignal<Vec<AudioNode>>
Every source except sinks’ monitors, in the server’s order.
Sourcepub fn default_source(&self) -> ReadSignal<Option<AudioNode>>
pub fn default_source(&self) -> ReadSignal<Option<AudioNode>>
The default source, where a call’s microphone sound comes from.
Sourcepub fn streams(&self) -> ReadSignal<Vec<AudioStream>>
pub fn streams(&self) -> ReadSignal<Vec<AudioStream>>
Every app playing sound, in the server’s order.
Sourcepub fn set_default_sink(&self, name: &str)
pub fn set_default_sink(&self, name: &str)
Makes the sink called name the default.
Sourcepub fn set_default_source(&self, name: &str)
pub fn set_default_source(&self, name: &str)
Makes the source called name the default.
Sourcepub fn set_sink_volume(&self, name: &str, percent: u32)
pub fn set_sink_volume(&self, name: &str, percent: u32)
Sets every channel of the sink called name to percent, at most
100.
Sourcepub fn set_sink_volumes(&self, name: &str, percents: &[u32])
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.
Sourcepub fn set_sink_mute(&self, name: &str, muted: bool)
pub fn set_sink_mute(&self, name: &str, muted: bool)
Mutes the sink called name, or unmutes it.
Sourcepub fn set_source_volume(&self, name: &str, percent: u32)
pub fn set_source_volume(&self, name: &str, percent: u32)
Sets every channel of the source called name to percent, at most
100.
Sourcepub fn set_source_volumes(&self, name: &str, percents: &[u32])
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.
Sourcepub fn set_source_mute(&self, name: &str, muted: bool)
pub fn set_source_mute(&self, name: &str, muted: bool)
Mutes the source called name, or unmutes it, as a microphone
button does.
Sourcepub fn set_stream_volume(&self, index: u32, percent: u32)
pub fn set_stream_volume(&self, index: u32, percent: u32)
Sets every channel of the stream numbered index to percent, at
most 100.
Sourcepub fn set_stream_volumes(&self, index: u32, percents: &[u32])
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.
Sourcepub fn set_stream_mute(&self, index: u32, muted: bool)
pub fn set_stream_mute(&self, index: u32, muted: bool)
Mutes the stream numbered index, or unmutes it.
Sourcepub fn move_stream(&self, index: u32, sink: &str)
pub fn move_stream(&self, index: u32, sink: &str)
Moves the stream numbered index to play to the sink called sink.