From 171771741069d4adf30321975fb9eb11791a05d0 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Mon, 21 Oct 2024 05:08:52 -0600 Subject: [PATCH] nRF52: Fix volume control in example --- .../NRF52_SD_Playback_I2S_Auto.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Platforms/NRF52/NRF52_SD_Playback_I2S_Auto/NRF52_SD_Playback_I2S_Auto.ino b/examples/Platforms/NRF52/NRF52_SD_Playback_I2S_Auto/NRF52_SD_Playback_I2S_Auto.ino index 647c009..6ba7801 100644 --- a/examples/Platforms/NRF52/NRF52_SD_Playback_I2S_Auto/NRF52_SD_Playback_I2S_Auto.ino +++ b/examples/Platforms/NRF52/NRF52_SD_Playback_I2S_Auto/NRF52_SD_Playback_I2S_Auto.ino @@ -121,9 +121,9 @@ void loadBuffer() { } else { myFile.read(aaAudio.dacBuffer16, BUFFER_SIZE); // Change this to dacBuffer16 for 16-bit samples for (uint32_t i = 0; i < BUFFER_SIZE / 2; i++) { - aaAudio.dacBuffer16[i] += 0x8000; - aaAudio.dacBuffer16[i] *= volumeControl; - aaAudio.dacBuffer16[i] -= 0x8000; + int16_t sample = aaAudio.dacBuffer16[i]; + sample *= volumeControl; + aaAudio.dacBuffer16[i] = (uint16_t)sample; } aaAudio.feedDAC(0, BUFFER_SIZE / 2); // change this to 3200 for 16-bit samples }