Skip to content

Commit

Permalink
Fix clamp (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam authored Sep 17, 2024
1 parent 3b9b09f commit 785d96d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions esphome/components/nabu_microphone/nabu_microphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ void NabuMicrophone::read_task_(void *params) {
int32_t channel_1_sample = 0;
if ((this_microphone->channel_1_ != nullptr) && (!this_microphone->channel_1_->get_mute_state())) {
channel_1_sample = buffer[NUMBER_OF_CHANNELS * i] >> channel_1_shift;
channel_1_samples[i] = clamp<int16_t>(channel_1_sample, INT16_MIN, INT16_MAX);
channel_1_samples[i] = (int16_t)clamp<int32_t>(channel_1_sample, INT16_MIN, INT16_MAX);
}

int32_t channel_2_sample = 0;
if ((this_microphone->channel_2_ != nullptr) && (!this_microphone->channel_2_->get_mute_state())) {
channel_2_sample = buffer[NUMBER_OF_CHANNELS * i + 1] >> channel_2_shift;
channel_2_samples[i] = clamp<int16_t>(channel_2_sample, INT16_MIN, INT16_MAX);
channel_2_samples[i] = (int16_t)clamp<int32_t>(channel_2_sample, INT16_MIN, INT16_MAX);
}
}

Expand Down

0 comments on commit 785d96d

Please sign in to comment.