mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 08:28:12 +01:00
revert bit shift to match previous behavior (#7109)
This commit is contained in:
parent
c5b77f4590
commit
32b927de7e
1 changed files with 2 additions and 1 deletions
|
@ -174,7 +174,8 @@ size_t I2SAudioMicrophone::read(int16_t *buf, size_t len) {
|
||||||
size_t samples_read = bytes_read / sizeof(int32_t);
|
size_t samples_read = bytes_read / sizeof(int32_t);
|
||||||
samples.resize(samples_read);
|
samples.resize(samples_read);
|
||||||
for (size_t i = 0; i < samples_read; i++) {
|
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));
|
memcpy(buf, samples.data(), samples_read * sizeof(int16_t));
|
||||||
return samples_read * sizeof(int16_t);
|
return samples_read * sizeof(int16_t);
|
||||||
|
|
Loading…
Reference in a new issue