Skip to content

Commit 2277d81

Browse files
authored
AR sound sync bugfix
local samples were "sneaking in" when mode "receive or local" was receiving from network source.
1 parent 14ab70d commit 2277d81

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

usermods/audioreactive/audio_reactive.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,9 @@ class AudioReactive : public Usermod {
16131613
my_magnitude = fmaxf(receivedPacket->FFT_Magnitude, 0.0f);
16141614
FFT_Magnitude = my_magnitude;
16151615
FFT_MajorPeak = constrain(receivedPacket->FFT_MajorPeak, 1.0f, 11025.0f); // restrict value to range expected by effects
1616+
soundPressure = volumeSmth; // substitute - V2 format does not (yet) include this value
1617+
agcSensitivity = 128.0f; // substitute - V2 format does not (yet) include this value
1618+
16161619
return true;
16171620
}
16181621

@@ -1642,6 +1645,8 @@ class AudioReactive : public Usermod {
16421645
my_magnitude = fmaxf(receivedPacket->FFT_Magnitude, 0.0);
16431646
FFT_Magnitude = my_magnitude;
16441647
FFT_MajorPeak = constrain(receivedPacket->FFT_MajorPeak, 1.0, 11025.0); // restrict value to range expected by effects
1648+
soundPressure = volumeSmth; // substitute - V1 format does not include this value
1649+
agcSensitivity = 128.0f; // substitute - V1 format does not include this value
16451650
}
16461651

16471652
bool receiveAudioData() // check & process new data. return TRUE in case that new audio data was received.
@@ -2015,12 +2020,12 @@ class AudioReactive : public Usermod {
20152020
DEBUG_PRINTF( " RealtimeMode = %d; RealtimeOverride = %d\n", int(realtimeMode), int(realtimeOverride));
20162021
}
20172022
#endif
2018-
if ((disableSoundProcessing == true) && (audioSyncEnabled < AUDIOSYNC_REC)) lastUMRun = millis(); // just left "realtime mode" - update timekeeping
2023+
if ((disableSoundProcessing == true) && (audioSyncEnabled != AUDIOSYNC_REC)) lastUMRun = millis(); // just left "realtime mode" - update timekeeping
20192024
disableSoundProcessing = false;
20202025
}
20212026

20222027
if (audioSyncEnabled == AUDIOSYNC_REC) disableSoundProcessing = true; // make sure everything is disabled IF in audio Receive mode
2023-
if (audioSyncEnabled & AUDIOSYNC_SEND) disableSoundProcessing = false; // keep running audio IF we're in audio Transmit mode
2028+
if (audioSyncEnabled == AUDIOSYNC_SEND) disableSoundProcessing = false; // keep running audio IF we're in audio Transmit mode
20242029
#ifdef ARDUINO_ARCH_ESP32
20252030
if (!audioSource->isInitialized()) { // no audio source
20262031
disableSoundProcessing = true;
@@ -2132,6 +2137,8 @@ class AudioReactive : public Usermod {
21322137
volumeSmth =0.0f;
21332138
volumeRaw =0;
21342139
my_magnitude = 0.1; FFT_Magnitude = 0.01; FFT_MajorPeak = 2;
2140+
soundPressure = 1.0f;
2141+
agcSensitivity = 64.0f;
21352142
#ifdef ARDUINO_ARCH_ESP32
21362143
multAgc = 1;
21372144
#endif

0 commit comments

Comments
 (0)