1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 06:04:01 +00:00

[speaker, i2s_audio] I2S Speaker implementation using a ring buffer (#7605)

This commit is contained in:
Kevin Ahrendt
2024-10-16 18:47:11 -04:00
committed by GitHub
parent 22478ffb0f
commit 1c845e0ff8
13 changed files with 601 additions and 266 deletions

View File

@@ -0,0 +1,9 @@
import esphome.codegen as cg
import esphome.config_validation as cv
CODEOWNERS = ["@kahrendt"]
audio_ns = cg.esphome_ns.namespace("audio")
CONFIG_SCHEMA = cv.All(
cv.Schema({}),
)

View File

@@ -0,0 +1,21 @@
#pragma once
#include <cstdint>
#include <stddef.h>
namespace esphome {
namespace audio {
struct AudioStreamInfo {
bool operator==(const AudioStreamInfo &rhs) const {
return (channels == rhs.channels) && (bits_per_sample == rhs.bits_per_sample) && (sample_rate == rhs.sample_rate);
}
bool operator!=(const AudioStreamInfo &rhs) const { return !operator==(rhs); }
size_t get_bytes_per_sample() const { return bits_per_sample / 8; }
uint8_t channels = 1;
uint8_t bits_per_sample = 16;
uint32_t sample_rate = 16000;
};
} // namespace audio
} // namespace esphome