3#ifdef USE_ESP32_FRAMEWORK_ARDUINO
10static const char *
const TAG =
"audio";
14 if (
call.get_announcement().has_value()) {
18 if (
call.get_media_url().has_value()) {
21 if (this->
audio_->isRunning()) {
25 this->
state = play_state;
41 switch (
call.get_command().value()) {
49 float new_volume = this->
volume + 0.1f;
50 if (new_volume > 1.0f)
57 float new_volume = this->
volume - 0.1f;
58 if (new_volume < 0.0f)
72 if (!this->
audio_->isRunning())
73 this->
audio_->pauseResume();
74 this->
state = play_state;
77 if (this->
audio_->isRunning())
78 this->
audio_->pauseResume();
85 this->
audio_->pauseResume();
86 if (this->
audio_->isRunning()) {
116 if (this->
audio_ !=
nullptr)
123 ESP_LOGCONFIG(TAG,
"Setting up Audio...");
147 !this->
audio_->isRunning()) {
154 if (!this->
parent_->try_lock()) {
158#if SOC_I2S_SUPPORTS_DAC
165 i2s_pin_config_t pin_config = this->
parent_->get_pin_config();
166 pin_config.data_out_num = this->
dout_pin_;
167 i2s_set_pin(this->
parent_->get_port(), &pin_config);
175#if SOC_I2S_SUPPORTS_DAC
202 if (this->
audio_->isRunning()) {
220 traits.set_supports_pause(
true);
225 ESP_LOGCONFIG(TAG,
"Audio:");
227 ESP_LOGCONFIG(TAG,
"Audio failed to initialize!");
230#if SOC_I2S_SUPPORTS_DAC
233 case I2S_DAC_CHANNEL_LEFT_EN:
234 ESP_LOGCONFIG(TAG,
" Internal DAC mode: Left");
236 case I2S_DAC_CHANNEL_RIGHT_EN:
237 ESP_LOGCONFIG(TAG,
" Internal DAC mode: Right");
239 case I2S_DAC_CHANNEL_BOTH_EN:
240 ESP_LOGCONFIG(TAG,
" Internal DAC mode: Left & Right");
248 ESP_LOGCONFIG(TAG,
" I2S DOUT Pin: %d", this->
dout_pin_);
250#if SOC_I2S_SUPPORTS_DAC
virtual void digital_write(bool value)=0
void stop()
Stop running the loop continuously.
void start()
Start running the loop continuously.
I2SAudioComponent * parent_
value_type const & value() const
Providing packet encoding functions for exchanging data with a remote host.
std::unique_ptr< T > make_unique(Args &&...args)
T remap(U value, U min, U max, T min_out, T max_out)
Remap value from the range (min, max) to (min_out, max_out).