device_envoy/audio_player/audio_player_generated.rs
1// @generated by `cargo check-all`. Do not edit by hand.
2//! Module containing [`AudioPlayerGenerated`], the sample struct type generated
3//! by the [`audio_player!`](macro@crate::audio_player) macro.
4//!
5//! Auto-generated.
6
7#[cfg(all(not(doc), not(feature = "host")))]
8use crate::audio_player;
9
10#[cfg(all(not(doc), not(feature = "host")))]
11audio_player! {
12 pub AudioPlayerGenerated {
13 data_pin: PIN_8,
14 bit_clock_pin: PIN_9,
15 word_select_pin: PIN_10,
16 sample_rate_hz: crate::audio_player::VOICE_22050_HZ,
17 }
18}
19
20#[cfg(doc)]
21/// Sample struct type generated by the [`audio_player!`](macro@crate::audio_player)
22/// macro, showing methods and associated constants.
23///
24/// This page serves as the reference for what a generated audio player type
25/// provides. For first-time readers, start with the
26/// [`audio_player`](mod@crate::audio_player) module documentation, then return
27/// here for a complete list of available methods and associated constants.
28///
29/// Auto-generated.
30pub struct AudioPlayerGenerated;
31
32#[cfg(doc)]
33use crate::Result;
34#[cfg(doc)]
35use crate::audio_player::{AtEnd, AudioClip, AudioClipBuf, Volume, VOICE_22050_HZ};
36
37#[cfg(doc)]
38impl AudioPlayerGenerated {
39 /// Sample rate used for PCM playback by this generated player type.
40 pub const SAMPLE_RATE_HZ: u32 = VOICE_22050_HZ;
41 /// Initial runtime volume relative to [`Self::MAX_VOLUME`].
42 pub const INITIAL_VOLUME: Volume = Volume::MAX;
43 /// Runtime volume ceiling for this generated player type.
44 pub const MAX_VOLUME: Volume = Volume::MAX;
45
46 /// Returns how many samples are needed for a duration in milliseconds
47 /// at this player's sample rate.
48 #[must_use]
49 pub const fn samples_ms(duration_ms: u32) -> usize {
50 crate::audio_player::samples_for_duration_ms(duration_ms, Self::SAMPLE_RATE_HZ)
51 }
52
53 /// Creates a silent clip at this player's sample rate.
54 ///
55 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
56 #[must_use]
57 pub const fn silence<const SAMPLE_COUNT: usize>(
58 ) -> AudioClipBuf<{ Self::SAMPLE_RATE_HZ }, SAMPLE_COUNT> {
59 AudioClipBuf::silence()
60 }
61
62 /// Creates a sine-wave clip at this player's sample rate.
63 ///
64 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
65 #[must_use]
66 pub const fn tone<const SAMPLE_COUNT: usize>(
67 frequency_hz: u32,
68 ) -> AudioClipBuf<{ Self::SAMPLE_RATE_HZ }, SAMPLE_COUNT> {
69 AudioClipBuf::tone(frequency_hz)
70 }
71
72 /// Creates and spawns the generated audio player instance.
73 ///
74 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
75 pub fn new(
76 data_pin: embassy_rp::Peri<'static, embassy_rp::peripherals::PIN_8>,
77 bit_clock_pin: embassy_rp::Peri<'static, embassy_rp::peripherals::PIN_9>,
78 word_select_pin: embassy_rp::Peri<'static, embassy_rp::peripherals::PIN_10>,
79 pio: embassy_rp::Peri<'static, embassy_rp::peripherals::PIO1>,
80 dma: embassy_rp::Peri<'static, embassy_rp::peripherals::DMA_CH0>,
81 spawner: embassy_executor::Spawner,
82 ) -> Result<&'static Self> {
83 static INSTANCE: AudioPlayerGenerated = AudioPlayerGenerated;
84 let _ = (data_pin, bit_clock_pin, word_select_pin, pio, dma, spawner);
85 Ok(&INSTANCE)
86 }
87
88 /// Starts playback of one or more static audio clips.
89 ///
90 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
91 pub fn play<const CLIP_COUNT: usize>(
92 &self,
93 audio_clips: [&'static AudioClip<{ Self::SAMPLE_RATE_HZ }>; CLIP_COUNT],
94 at_end: AtEnd,
95 ) {
96 let _ = (audio_clips, at_end);
97 }
98
99 /// Stops current playback as soon as possible.
100 ///
101 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
102 pub fn stop(&self) {}
103
104 /// Sets runtime playback volume relative to [`Self::MAX_VOLUME`].
105 ///
106 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
107 pub fn set_volume(&self, volume: Volume) {
108 let _ = volume;
109 }
110
111 /// Returns the current runtime playback volume relative to [`Self::MAX_VOLUME`].
112 ///
113 /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
114 #[must_use]
115 pub fn volume(&self) -> Volume {
116 Volume::MAX
117 }
118
119}