diff --git a/esphome/components/speaker/media_player/audio_decoder.cpp b/esphome/components/speaker/media_player/audio_decoder.cpp index c7c401887e..d8aabc2f2c 100644 --- a/esphome/components/speaker/media_player/audio_decoder.cpp +++ b/esphome/components/speaker/media_player/audio_decoder.cpp @@ -179,7 +179,7 @@ AudioDecoderState AudioDecoder::decode(bool stop_gracefully) { this->end_of_file_ = true; } else if (state == FileDecoderState::FAILED) { return AudioDecoderState::FAILED; - } else if ((state == FileDecoderState::MORE_TO_PROCESS)) { + } else if (state == FileDecoderState::MORE_TO_PROCESS) { this->potentially_failed_count_ = 0; } } diff --git a/esphome/components/speaker/media_player/audio_mixer.cpp b/esphome/components/speaker/media_player/audio_mixer.cpp index b032b8c218..56e9367aa0 100644 --- a/esphome/components/speaker/media_player/audio_mixer.cpp +++ b/esphome/components/speaker/media_player/audio_mixer.cpp @@ -28,7 +28,7 @@ esp_err_t AudioMixer::start(Speaker *speaker, const std::string &task_name, UBas } if (this->task_handle_ == nullptr) { - this->task_handle_ = xTaskCreateStatic(AudioMixer::audio_mixer_task_, task_name.c_str(), TASK_STACK_SIZE, + this->task_handle_ = xTaskCreateStatic(AudioMixer::audio_mixer_task, task_name.c_str(), TASK_STACK_SIZE, (void *) this, priority, this->stack_buffer_, &this->task_stack_); } @@ -61,7 +61,7 @@ void AudioMixer::resume_task() { } } -void AudioMixer::audio_mixer_task_(void *params) { +void AudioMixer::audio_mixer_task(void *params) { AudioMixer *this_mixer = (AudioMixer *) params; TaskEvent event; @@ -199,9 +199,9 @@ void AudioMixer::audio_mixer_task_(void *params) { while (samples_left_to_duck > 0) { // Ensure we only point to valid index in the Q15 scaling factor table uint8_t safe_db_reduction_index = - clamp(current_ducking_db_reduction, 0, decibel_reduction_table.size() - 1); + clamp(current_ducking_db_reduction, 0, DECIBEL_REDUCTION_TABLE.size() - 1); - int16_t q15_scale_factor = decibel_reduction_table[safe_db_reduction_index]; + int16_t q15_scale_factor = DECIBEL_REDUCTION_TABLE[safe_db_reduction_index]; this_mixer->scale_audio_samples_(current_media_buffer, current_media_buffer, q15_scale_factor, samples_left_to_duck); @@ -225,9 +225,9 @@ void AudioMixer::audio_mixer_task_(void *params) { // We still need to apply a ducking scaling, but we are done transitioning uint8_t safe_db_reduction_index = - clamp(target_ducking_db_reduction, 0, decibel_reduction_table.size() - 1); + clamp(target_ducking_db_reduction, 0, DECIBEL_REDUCTION_TABLE.size() - 1); - int16_t q15_scale_factor = decibel_reduction_table[safe_db_reduction_index]; + int16_t q15_scale_factor = DECIBEL_REDUCTION_TABLE[safe_db_reduction_index]; this_mixer->scale_audio_samples_(media_buffer, media_buffer, q15_scale_factor, samples_read); } } diff --git a/esphome/components/speaker/media_player/audio_mixer.h b/esphome/components/speaker/media_player/audio_mixer.h index 8599b2635d..25b2bedc08 100644 --- a/esphome/components/speaker/media_player/audio_mixer.h +++ b/esphome/components/speaker/media_player/audio_mixer.h @@ -67,7 +67,7 @@ struct CommandEvent { // Gives the Q15 fixed point scaling factor to reduce by 0 dB, 1dB, ..., 50 dB // dB to PCM scaling factor formula: floating_point_scale_factor = 2^(-db/6.014) // float to Q15 fixed point formula: q15_scale_factor = floating_point_scale_factor * 2^(15) -static const std::vector decibel_reduction_table = { +static const std::vector DECIBEL_REDUCTION_TABLE = { 32767, 29201, 26022, 23189, 20665, 18415, 16410, 14624, 13032, 11613, 10349, 9222, 8218, 7324, 6527, 5816, 5183, 4619, 4116, 3668, 3269, 2913, 2596, 2313, 2061, 1837, 1637, 1459, 1300, 1158, 1032, 920, 820, 731, 651, 580, 517, 461, 411, 366, 326, 291, 259, 231, 206, 183, 163, 146, 130, 116, 103}; @@ -137,7 +137,7 @@ class AudioMixer { void scale_audio_samples_(int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor, size_t samples_to_scale); - static void audio_mixer_task_(void *params); + static void audio_mixer_task(void *params); TaskHandle_t task_handle_{nullptr}; StaticTask_t task_stack_; StackType_t *stack_buffer_{nullptr};