Enum spectrusty_audio::host::cpal::AudioHandleAnyFormat
source · pub enum AudioHandleAnyFormat {
I16(AudioHandle<i16>),
U16(AudioHandle<u16>),
F32(AudioHandle<f32>),
}
Expand description
The enum for producing and controlling the audio playback regardless of the sample format used.
Variants§
Implementations§
source§impl AudioHandleAnyFormat
impl AudioHandleAnyFormat
sourcepub fn sample_format(&self) -> SampleFormat
pub fn sample_format(&self) -> SampleFormat
Returns the sample format of the current variant.
sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Returns the audio sample frequency of the output stream.
sourcepub fn play(&self) -> Result<(), AudioHandleError>
pub fn play(&self) -> Result<(), AudioHandleError>
Starts playback of the audio device.
sourcepub fn pause(&self) -> Result<(), AudioHandleError>
pub fn pause(&self) -> Result<(), AudioHandleError>
Pauses playback of the audio device.
sourcepub fn send_frame(&mut self) -> AudioFrameResult<()>
pub fn send_frame(&mut self) -> AudioFrameResult<()>
Calls the underlying AudioFrameProducer::send_frame.
sourcepub fn create(
host: &Host,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
pub fn create(
host: &Host,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
Creates an instance of the AudioHandleAnyFormat from the provided cpal host
with
the default output device and the default audio parameters.
frame_duration_nanos
is the duration in nanoseconds of the standard emulation frame.latency
is the audio latency passed to the create_carousel.
sourcepub fn create_with_device(
device: &Device,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
pub fn create_with_device(
device: &Device,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
Creates an instance of the AudioHandleAnyFormat from the provided cpal device
with the default audio parameters.
frame_duration_nanos
is the duration in nanoseconds of the standard emulation frame.latency
is the audio latency passed to the create_carousel.
sourcepub fn create_with_device_and_config(
device: &Device,
config: &StreamConfig,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
pub fn create_with_device_and_config(
device: &Device,
config: &StreamConfig,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
Creates an instance of the AudioHandleAnyFormat from the provided cpal device
with the desired audio parameters and sample format.
config
specifies the desired audio parameters.frame_duration_nanos
is the duration in nanoseconds of the standard emulation frame.latency
is the audio latency passed to the create_carousel.
Examples found in repository?
src/host/cpal.rs (lines 141-146)
134 135 136 137 138 139 140 141 142 143 144 145 146 147
pub fn create_with_device(
device: &cpal::Device,
frame_duration_nanos: u32,
latency: usize
) -> Result<Self, AudioHandleError>
{
let config = device.default_output_config()?.config();
Self::create_with_device_and_config(
device,
&config,
frame_duration_nanos,
latency,
)
}
Auto Trait Implementations§
impl !RefUnwindSafe for AudioHandleAnyFormat
impl !Send for AudioHandleAnyFormat
impl !Sync for AudioHandleAnyFormat
impl Unpin for AudioHandleAnyFormat
impl !UnwindSafe for AudioHandleAnyFormat
Blanket Implementations§
source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
source§fn into_sample(self) -> S
fn into_sample(self) -> S
Convert to
S
a sample type from self
.