Skip to content

Commit

Permalink
revert bit shift to match previous behavior (esphome#7109)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrendt authored Jul 19, 2024
1 parent c5b77f4 commit 32b927d
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ size_t I2SAudioMicrophone::read(int16_t *buf, size_t len) {
size_t samples_read = bytes_read / sizeof(int32_t);
samples.resize(samples_read);
for (size_t i = 0; i < samples_read; i++) {
samples[i] = reinterpret_cast<int32_t *>(buf)[i] >> 16;
int32_t temp = reinterpret_cast<int32_t *>(buf)[i] >> 14;
samples[i] = clamp<int16_t>(temp, INT16_MIN, INT16_MAX);
}
memcpy(buf, samples.data(), samples_read * sizeof(int16_t));
return samples_read * sizeof(int16_t);
Expand Down

0 comments on commit 32b927d

Please sign in to comment.