Skip to content

Commit

Permalink
[speaker, i2s_audio] I2S Speaker implementation using a ring buffer (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrendt authored Oct 16, 2024
1 parent 22478ff commit 1c845e0
Show file tree
Hide file tree
Showing 13 changed files with 569 additions and 234 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ esphome/components/at581x/* @X-Ryl669
esphome/components/atc_mithermometer/* @ahpohl
esphome/components/atm90e26/* @danieltwagner
esphome/components/atm90e32/* @circuitsetup @descipher
esphome/components/audio/* @kahrendt
esphome/components/audio_dac/* @kbx81
esphome/components/b_parasite/* @rbaron
esphome/components/ballu/* @bazuchan
Expand Down
9 changes: 9 additions & 0 deletions esphome/components/audio/__init__.py
Original file line number Diff line number Diff line change
@@ -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({}),
)
21 changes: 21 additions & 0 deletions esphome/components/audio/audio.h
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion esphome/components/i2s_audio/speaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
register_i2s_audio_component,
)

AUTO_LOAD = ["audio"]
CODEOWNERS = ["@jesserockz"]
DEPENDENCIES = ["i2s_audio"]

Expand Down Expand Up @@ -72,7 +73,7 @@ def validate_esp32_variant(config):
.extend(
{
cv.Optional(
CONF_TIMEOUT, default="100ms"
CONF_TIMEOUT, default="500ms"
): cv.positive_time_period_milliseconds,
}
)
Expand Down
Loading

0 comments on commit 1c845e0

Please sign in to comment.