mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
clang fixes
This commit is contained in:
parent
6d8b093e63
commit
08e2af8a3e
3 changed files with 9 additions and 9 deletions
|
@ -179,7 +179,7 @@ AudioDecoderState AudioDecoder::decode(bool stop_gracefully) {
|
||||||
this->end_of_file_ = true;
|
this->end_of_file_ = true;
|
||||||
} else if (state == FileDecoderState::FAILED) {
|
} else if (state == FileDecoderState::FAILED) {
|
||||||
return AudioDecoderState::FAILED;
|
return AudioDecoderState::FAILED;
|
||||||
} else if ((state == FileDecoderState::MORE_TO_PROCESS)) {
|
} else if (state == FileDecoderState::MORE_TO_PROCESS) {
|
||||||
this->potentially_failed_count_ = 0;
|
this->potentially_failed_count_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ esp_err_t AudioMixer::start(Speaker *speaker, const std::string &task_name, UBas
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->task_handle_ == nullptr) {
|
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_);
|
(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;
|
AudioMixer *this_mixer = (AudioMixer *) params;
|
||||||
|
|
||||||
TaskEvent event;
|
TaskEvent event;
|
||||||
|
@ -199,9 +199,9 @@ void AudioMixer::audio_mixer_task_(void *params) {
|
||||||
while (samples_left_to_duck > 0) {
|
while (samples_left_to_duck > 0) {
|
||||||
// Ensure we only point to valid index in the Q15 scaling factor table
|
// Ensure we only point to valid index in the Q15 scaling factor table
|
||||||
uint8_t safe_db_reduction_index =
|
uint8_t safe_db_reduction_index =
|
||||||
clamp<uint8_t>(current_ducking_db_reduction, 0, decibel_reduction_table.size() - 1);
|
clamp<uint8_t>(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,
|
this_mixer->scale_audio_samples_(current_media_buffer, current_media_buffer, q15_scale_factor,
|
||||||
samples_left_to_duck);
|
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
|
// We still need to apply a ducking scaling, but we are done transitioning
|
||||||
|
|
||||||
uint8_t safe_db_reduction_index =
|
uint8_t safe_db_reduction_index =
|
||||||
clamp<uint8_t>(target_ducking_db_reduction, 0, decibel_reduction_table.size() - 1);
|
clamp<uint8_t>(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);
|
this_mixer->scale_audio_samples_(media_buffer, media_buffer, q15_scale_factor, samples_read);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct CommandEvent {
|
||||||
// Gives the Q15 fixed point scaling factor to reduce by 0 dB, 1dB, ..., 50 dB
|
// 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)
|
// 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)
|
// float to Q15 fixed point formula: q15_scale_factor = floating_point_scale_factor * 2^(15)
|
||||||
static const std::vector<int16_t> decibel_reduction_table = {
|
static const std::vector<int16_t> DECIBEL_REDUCTION_TABLE = {
|
||||||
32767, 29201, 26022, 23189, 20665, 18415, 16410, 14624, 13032, 11613, 10349, 9222, 8218, 7324, 6527, 5816, 5183,
|
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,
|
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};
|
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,
|
void scale_audio_samples_(int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor,
|
||||||
size_t samples_to_scale);
|
size_t samples_to_scale);
|
||||||
|
|
||||||
static void audio_mixer_task_(void *params);
|
static void audio_mixer_task(void *params);
|
||||||
TaskHandle_t task_handle_{nullptr};
|
TaskHandle_t task_handle_{nullptr};
|
||||||
StaticTask_t task_stack_;
|
StaticTask_t task_stack_;
|
||||||
StackType_t *stack_buffer_{nullptr};
|
StackType_t *stack_buffer_{nullptr};
|
||||||
|
|
Loading…
Reference in a new issue