Skip to content

Commit 95e6f47

Browse files
committed
miclogger - added average signal (optional)
1 parent 949373d commit 95e6f47

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

usermods/audioreactive/audio_reactive.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ static void autoResetPeak(void); // peak auto-reset function
146146
// shared vars for debugging
147147
#ifdef MIC_LOGGER
148148
static volatile float micReal_min = 0.0f; // MicIn data min from last batch of samples
149+
static volatile float micReal_avg = 0.0f; // MicIn data average (from last batch of samples)
149150
static volatile float micReal_max = 0.0f; // MicIn data max from last batch of samples
150151
#if 0
151-
static volatile float micReal_min2 = 0.0f; // MicIn data min from last batch of samples
152-
static volatile float micReal_max2 = 0.0f; // MicIn data max from last batch of samples
152+
static volatile float micReal_min2 = 0.0f; // MicIn data min after filtering
153+
static volatile float micReal_max2 = 0.0f; // MicIn data max after filtering
153154
#endif
154155
#endif
155156

@@ -345,13 +346,15 @@ void FFTcode(void * parameter)
345346
#ifdef MIC_LOGGER
346347
float datMin = 0.0f;
347348
float datMax = 0.0f;
349+
double datAvg = 0.0f;
348350
for (int i=0; i < samplesFFT; i++) {
349351
if (i==0) {
350352
datMin = datMax = vReal[i];
351353
} else {
352354
if (datMin > vReal[i]) datMin = vReal[i];
353355
if (datMax < vReal[i]) datMax = vReal[i];
354356
}
357+
datAvg += vReal[i];
355358
}
356359
#endif
357360

@@ -374,6 +377,7 @@ void FFTcode(void * parameter)
374377
#ifdef MIC_LOGGER
375378
micReal_min = datMin;
376379
micReal_max = datMax;
380+
micReal_avg = datAvg / samplesFFT;
377381
#if 0
378382
// compute mix/max again after filering - usefull for filter debugging
379383
for (int i=0; i < samplesFFT; i++) {
@@ -814,6 +818,7 @@ class AudioReactive : public Usermod {
814818
// Debugging functions for audio input and sound processing. Comment out the values you want to see
815819
PLOT_PRINT("micMin:"); PLOT_PRINT(micReal_min); PLOT_PRINT("\t");
816820
PLOT_PRINT("micMax:"); PLOT_PRINT(micReal_max); PLOT_PRINT("\t");
821+
//PLOT_PRINT("micAvg:"); PLOT_PRINT(micReal_avg); PLOT_PRINT("\t");
817822
//PLOT_PRINT("micDC:"); PLOT_PRINT((micReal_min + micReal_max)/2.0f);PLOT_PRINT("\t");
818823
PLOT_PRINT("micReal:"); PLOT_PRINT(micDataReal); PLOT_PRINT("\t");
819824
PLOT_PRINT("volumeSmth:"); PLOT_PRINT(volumeSmth); PLOT_PRINT("\t");

0 commit comments

Comments
 (0)