ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
i2s_audio_speaker_standard.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
5#include "i2s_audio_speaker.h"
6
7namespace esphome::i2s_audio {
8
9enum class I2SCommFmt : uint8_t {
10 STANDARD, // Philips / I2S standard
11 PCM, // PCM short
12 MSB, // MSB / left-justified
13};
14
18 public:
19 void dump_config() override;
20
22
23#ifdef USE_I2S_AUDIO_FULL_DUPLEX
24 void build_full_duplex_config(i2s_chan_config_t &chan_cfg, i2s_std_config_t &std_cfg) override;
25#endif
26
27 protected:
28 void run_speaker_task() override;
29 esp_err_t start_i2s_driver(audio::AudioStreamInfo &audio_stream_info) override;
30
33 void build_i2s_config_(const audio::AudioStreamInfo &output_stream_info, i2s_chan_config_t &chan_cfg,
34 i2s_std_config_t &std_cfg) const;
35
36#ifdef USE_I2S_AUDIO_FULL_DUPLEX
39#endif
40
42 uint8_t slot_memory_bits_() const;
43
44#ifdef USE_ESP32_VARIANT_ESP32
49 size_t write_widened_(const uint8_t *input, uint32_t frames);
50#endif
51
54 return esp32_mono_swap_needed(stream_info) ? 2 : 1;
55 }
56
58};
59
60} // namespace esphome::i2s_audio
61
62#endif // USE_ESP32
Abstract base class for I2S audio speaker implementations.
Standard I2S speaker implementation.
audio::AudioStreamInfo full_duplex_stream_info_() const
The output format of a full duplex bus, fixed by the configuration since the channel is set up once.
static uint32_t dma_frame_multiple(const audio::AudioStreamInfo &stream_info)
Frame multiple for DMA buffers and writes; 2 keeps ESP32 mono sample pairs word-aligned.
size_t write_widened_(const uint8_t *input, uint32_t frames)
Widens frames to the output bit depth through a small stack buffer and writes them to the peripheral.
uint8_t slot_memory_bits_() const
Bits per sample that the configured slot takes in DMA memory.
esp_err_t start_i2s_driver(audio::AudioStreamInfo &audio_stream_info) override
void build_i2s_config_(const audio::AudioStreamInfo &output_stream_info, i2s_chan_config_t &chan_cfg, i2s_std_config_t &std_cfg) const
Builds the channel and standard mode configuration for the given output format.
void build_full_duplex_config(i2s_chan_config_t &chan_cfg, i2s_std_config_t &std_cfg) override
size_t size_t const char * fmt
Definition helpers.h:1334
static void uint32_t