Skip to main content

device_envoy_esp/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"), target_os = "none"))]
8use crate::audio_player;
9
10#[cfg(all(not(doc), not(feature = "host"), target_os = "none"))]
11audio_player! {
12    pub AudioPlayerGenerated {
13        data_pin: GPIO21,
14        bit_clock_pin: GPIO12,
15        word_select_pin: GPIO13,
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/// The macro also generates [`AudioPlayerGeneratedPlayable`], a trait-object
30/// alias for clip sources at the same sample rate.
31///
32/// Auto-generated.
33pub struct AudioPlayerGenerated;
34
35#[cfg(doc)]
36/// Trait-object clip source type at [`VOICE_22050_HZ`].
37///
38/// See the [audio_player module documentation](mod@crate::audio_player) for
39/// usage examples.
40pub type AudioPlayerGeneratedPlayable = dyn Playable<VOICE_22050_HZ>;
41
42#[cfg(doc)]
43use crate::audio_player::{AtEnd, AudioPlayer, Playable, Volume, VOICE_22050_HZ};
44#[cfg(doc)]
45use crate::Result;
46
47#[cfg(doc)]
48impl AudioPlayerGenerated {
49    /// Sample rate used for playback by this generated player type.
50    ///
51    /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
52    pub const SAMPLE_RATE_HZ: u32 = VOICE_22050_HZ;
53    /// Maximum number of clips accepted by `play(...)`.
54    pub const MAX_CLIPS: usize = 16;
55    /// Initial runtime volume relative to [`Self::MAX_VOLUME`].
56    pub const INITIAL_VOLUME: Volume = Volume::MAX;
57    /// Runtime volume ceiling for this generated player type.
58    pub const MAX_VOLUME: Volume = Volume::MAX;
59
60    /// Creates and spawns the generated audio player instance.
61    ///
62    /// See the [`audio_player`](mod@crate::audio_player) module docs for usage.
63    pub fn new(
64        data_pin: impl Sized,
65        bit_clock_pin: impl Sized,
66        word_select_pin: impl Sized,
67        i2s: impl Sized,
68        dma: impl Sized,
69        spawner: embassy_executor::Spawner,
70    ) -> Result<&'static Self> {
71        static INSTANCE: AudioPlayerGenerated = AudioPlayerGenerated;
72        let _ = (data_pin, bit_clock_pin, word_select_pin, i2s, dma, spawner);
73        Ok(&INSTANCE)
74    }
75}
76
77#[cfg(doc)]
78impl AudioPlayer<VOICE_22050_HZ> for AudioPlayerGenerated {
79    const SAMPLE_RATE_HZ: u32 = VOICE_22050_HZ;
80    const MAX_CLIPS: usize = 16;
81    const INITIAL_VOLUME: Volume = Volume::MAX;
82    const MAX_VOLUME: Volume = Volume::MAX;
83
84    fn play<I>(&self, audio_clips: I, at_end: AtEnd)
85    where
86        I: IntoIterator<Item = &'static dyn Playable<VOICE_22050_HZ>>,
87    {
88        let _ = (audio_clips, at_end);
89    }
90
91    fn stop(&self) {}
92
93    async fn wait_until_stopped(&self) {}
94
95    fn set_volume(&self, volume: Volume) {
96        let _ = volume;
97    }
98
99    fn volume(&self) -> Volume {
100        Volume::MAX
101    }
102}