Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/AudioTools/CoreAudio/AudioAnalog/AnalogDriverESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ class AnalogDriverESP32 : public AnalogDriverBase {
if (i2s_read(port_no, dest, size_bytes, &result, adc_config.timeout)!=ESP_OK){
TRACEE();
}
// Scale 12-bit ADC values to 16-bit
uint16_t *samples = reinterpret_cast<uint16_t *>(dest);
size_t sample_count = result / sizeof(uint16_t);
for (size_t i = 0; i < sample_count; i++) {
samples[i] <<= 4; // Scale 12-bit to 16-bit
}
// make sure that the center is at 0
if (adc_config.is_auto_center_read){
auto_center.convert(dest, result);
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/CoreAudio/AudioAnalog/AnalogDriverESP32V1.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
*result16 = 0;
}
} else {
*result16 = data;
*result16 = data << 4; // Scale 12-bit to 16-bit
}
result16++;
} else {
Expand Down