audioreactive - spelling corrections in comments

This commit is contained in:
Frank
2023-10-08 01:36:08 +02:00
parent 28b46d8ee3
commit 1fa5dc8ea8
2 changed files with 38 additions and 38 deletions

View File

@@ -21,13 +21,13 @@
* .... * ....
*/ */
#define FFT_PREFER_EXACT_PEAKS // use different FFT wndowing -> results in "sharper" peaks and less "leaking" into other frequencies #define FFT_PREFER_EXACT_PEAKS // use different FFT windowing -> results in "sharper" peaks and less "leaking" into other frequencies
//#define SR_STATS //#define SR_STATS
#if !defined(FFTTASK_PRIORITY) #if !defined(FFTTASK_PRIORITY)
#define FFTTASK_PRIORITY 1 // standard: looptask prio #define FFTTASK_PRIORITY 1 // standard: looptask prio
//#define FFTTASK_PRIORITY 2 // above looptask, below asyc_tcp //#define FFTTASK_PRIORITY 2 // above looptask, below async_tcp
//#define FFTTASK_PRIORITY 4 // above asyc_tcp //#define FFTTASK_PRIORITY 4 // above async_tcp
#endif #endif
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
@@ -109,7 +109,7 @@ static float volumeSmth = 0.0f; // either sampleAvg or sampleAgc
static float FFT_MajorPeak = 1.0f; // FFT: strongest (peak) frequency static float FFT_MajorPeak = 1.0f; // FFT: strongest (peak) frequency
static float FFT_Magnitude = 0.0f; // FFT: volume (magnitude) of peak frequency static float FFT_Magnitude = 0.0f; // FFT: volume (magnitude) of peak frequency
static bool samplePeak = false; // Boolean flag for peak - used in effects. Responding routine may reset this flag. Auto-reset after strip.getMinShowDelay() static bool samplePeak = false; // Boolean flag for peak - used in effects. Responding routine may reset this flag. Auto-reset after strip.getMinShowDelay()
static bool udpSamplePeak = false; // Boolean flag for peak. Set at the same tiem as samplePeak, but reset by transmitAudioData static bool udpSamplePeak = false; // Boolean flag for peak. Set at the same time as samplePeak, but reset by transmitAudioData
static unsigned long timeOfPeak = 0; // time of last sample peak detection. static unsigned long timeOfPeak = 0; // time of last sample peak detection.
static uint8_t fftResult[NUM_GEQ_CHANNELS]= {0};// Our calculated freq. channel result table to be used by effects static uint8_t fftResult[NUM_GEQ_CHANNELS]= {0};// Our calculated freq. channel result table to be used by effects
@@ -123,7 +123,7 @@ static uint16_t decayTime = 300; // int: decay time in milliseconds
// peak detection // peak detection
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
static void detectSamplePeak(void); // peak detection function (needs scaled FFT reasults in vReal[]) - no used for 8266 receive-only mode static void detectSamplePeak(void); // peak detection function (needs scaled FFT results in vReal[]) - no used for 8266 receive-only mode
#endif #endif
static void autoResetPeak(void); // peak auto-reset function static void autoResetPeak(void); // peak auto-reset function
static uint8_t maxVol = 31; // (was 10) Reasonable value for constant volume for 'peak detector', as it won't always trigger (deprecated) static uint8_t maxVol = 31; // (was 10) Reasonable value for constant volume for 'peak detector', as it won't always trigger (deprecated)
@@ -150,7 +150,7 @@ static uint8_t inputLevel = 128; // UI slider value
#endif #endif
// user settable options for FFTResult scaling // user settable options for FFTResult scaling
static uint8_t FFTScalingMode = 3; // 0 none; 1 optimized logarithmic; 2 optimized linear; 3 optimized sqare root static uint8_t FFTScalingMode = 3; // 0 none; 1 optimized logarithmic; 2 optimized linear; 3 optimized square root
#ifndef SR_FREQ_PROF #ifndef SR_FREQ_PROF
static uint8_t pinkIndex = 0; // 0: default; 1: line-in; 2: IMNP441 static uint8_t pinkIndex = 0; // 0: default; 1: line-in; 2: IMNP441
#else #else
@@ -220,7 +220,7 @@ static void postProcessFFTResults(bool noiseGateOpen, int numberOfChannels); //
static TaskHandle_t FFT_Task = nullptr; static TaskHandle_t FFT_Task = nullptr;
// Table of multiplication factors so that we can even out the frequency response. // Table of multiplication factors so that we can even out the frequency response.
#define MAX_PINK 10 // 0 = standard, 1= line-in (pink moise only), 2..4 = IMNP441, 5..6 = ICS-43434, ,7=SPM1423, 8..9 = userdef, 10= flat (no pink noise adjustment) #define MAX_PINK 10 // 0 = standard, 1= line-in (pink noise only), 2..4 = IMNP441, 5..6 = ICS-43434, ,7=SPM1423, 8..9 = userdef, 10= flat (no pink noise adjustment)
static const float fftResultPink[MAX_PINK+1][NUM_GEQ_CHANNELS] = { static const float fftResultPink[MAX_PINK+1][NUM_GEQ_CHANNELS] = {
{ 1.70f, 1.71f, 1.73f, 1.78f, 1.68f, 1.56f, 1.55f, 1.63f, 1.79f, 1.62f, 1.80f, 2.06f, 2.47f, 3.35f, 6.83f, 9.55f }, // 0 default from SR WLED { 1.70f, 1.71f, 1.73f, 1.78f, 1.68f, 1.56f, 1.55f, 1.63f, 1.79f, 1.62f, 1.80f, 2.06f, 2.47f, 3.35f, 6.83f, 9.55f }, // 0 default from SR WLED
// { 1.30f, 1.32f, 1.40f, 1.46f, 1.52f, 1.57f, 1.68f, 1.80f, 1.89f, 2.00f, 2.11f, 2.21f, 2.30f, 2.39f, 3.09f, 4.34f }, // - Line-In Generic -> pink noise adjustment only // { 1.30f, 1.32f, 1.40f, 1.46f, 1.52f, 1.57f, 1.68f, 1.80f, 1.89f, 2.00f, 2.11f, 2.21f, 2.30f, 2.39f, 3.09f, 4.34f }, // - Line-In Generic -> pink noise adjustment only
@@ -244,7 +244,7 @@ static const float fftResultPink[MAX_PINK+1][NUM_GEQ_CHANNELS] = {
/* how to make your own profile: /* how to make your own profile:
* =============================== * ===============================
* preparation: make sure your microphone has direct line-of-sigh with the speaker, 1-2meter distance is best * preparation: make sure your microphone has direct line-of-sigh with the speaker, 1-2meter distance is best
* Prepare your HiFi equipment: disable all "Sound enhancements" - like Loudness, Equalizer, Bass Boost. Bass/Trebble controls set to middle. * Prepare your HiFi equipment: disable all "Sound enhancements" - like Loudness, Equalizer, Bass Boost. Bass/Treble controls set to middle.
* Your HiFi equipment should receive its audio input from Line-In, SPDIF, HDMI, or another "undistorted" connection (like CDROM). * Your HiFi equipment should receive its audio input from Line-In, SPDIF, HDMI, or another "undistorted" connection (like CDROM).
* Try not to use Bluetooth or MP3 when playing the "pink noise" audio. BT-audio and MP3 both perform "acoustic adjustments" that we don't want now. * Try not to use Bluetooth or MP3 when playing the "pink noise" audio. BT-audio and MP3 both perform "acoustic adjustments" that we don't want now.
@@ -258,7 +258,7 @@ static const float fftResultPink[MAX_PINK+1][NUM_GEQ_CHANNELS] = {
* Your own profile: * Your own profile:
* - Target for each LED bar is 50% to 75% of the max height --> 8(high) x 16(wide) panel means target = 5. 32 x 16 means target = 22. * - Target for each LED bar is 50% to 75% of the max height --> 8(high) x 16(wide) panel means target = 5. 32 x 16 means target = 22.
* - From left to right - count the LEDs in each of the 16 frequency colums (that's why you need the photo). This is the barheight for each channel. * - From left to right - count the LEDs in each of the 16 frequency columns (that's why you need the photo). This is the barheight for each channel.
* - math time! Find the multiplier that will bring each bar to to target. * - math time! Find the multiplier that will bring each bar to to target.
* * in case of square root scale: multiplier = (target * target) / (barheight * barheight) * * in case of square root scale: multiplier = (target * target) / (barheight * barheight)
* * in case of linear scale: multiplier = target / barheight * * in case of linear scale: multiplier = target / barheight
@@ -360,7 +360,7 @@ static float mapf(float x, float in_min, float in_max, float out_min, float out_
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
} }
// compute average of several FFT resut bins // compute average of several FFT result bins
// linear average // linear average
static float fftAddAvgLin(int from, int to) { static float fftAddAvgLin(int from, int to) {
float result = 0.0f; float result = 0.0f;
@@ -430,7 +430,7 @@ void FFTcode(void * parameter)
for(uint_fast16_t binInd = 0; binInd < samplesFFT; binInd++) { for(uint_fast16_t binInd = 0; binInd < samplesFFT; binInd++) {
float binFreq = binInd * binWidth + binWidth/2.0f; float binFreq = binInd * binWidth + binWidth/2.0f;
if (binFreq > (SAMPLE_RATE * 0.42f)) if (binFreq > (SAMPLE_RATE * 0.42f))
binFreq = (SAMPLE_RATE * 0.42f) - 0.25 * (binFreq - (SAMPLE_RATE * 0.42f)); // supress noise and aliasing binFreq = (SAMPLE_RATE * 0.42f) - 0.25 * (binFreq - (SAMPLE_RATE * 0.42f)); // suppress noise and aliasing
pinkFactors[binInd] = sqrtf(binFreq) / pinkcenter; pinkFactors[binInd] = sqrtf(binFreq) / pinkcenter;
} }
pinkFactors[0] *= 0.5; // suppress 0-42hz bin pinkFactors[0] *= 0.5; // suppress 0-42hz bin
@@ -482,7 +482,7 @@ void FFTcode(void * parameter)
#endif #endif
xLastWakeTime = xTaskGetTickCount(); // update "last unblocked time" for vTaskDelay xLastWakeTime = xTaskGetTickCount(); // update "last unblocked time" for vTaskDelay
isFirstRun = !isFirstRun; // toggle throtte isFirstRun = !isFirstRun; // toggle throttle
#ifdef MIC_LOGGER #ifdef MIC_LOGGER
float datMin = 0.0f; float datMin = 0.0f;
@@ -619,7 +619,7 @@ void FFTcode(void * parameter)
* *
* Andrew's updated mapping of 256 bins down to the 16 result bins with Sample Freq = 10240, samplesFFT = 512 and some overlap. * Andrew's updated mapping of 256 bins down to the 16 result bins with Sample Freq = 10240, samplesFFT = 512 and some overlap.
* Based on testing, the lowest/Start frequency is 60 Hz (with bin 3) and a highest/End frequency of 5120 Hz in bin 255. * Based on testing, the lowest/Start frequency is 60 Hz (with bin 3) and a highest/End frequency of 5120 Hz in bin 255.
* Now, Take the 60Hz and multiply by 1.320367784 to get the next frequency and so on until the end. Then detetermine the bins. * Now, Take the 60Hz and multiply by 1.320367784 to get the next frequency and so on until the end. Then determine the bins.
* End frequency = Start frequency * multiplier ^ 16 * End frequency = Start frequency * multiplier ^ 16
* Multiplier = (End frequency/ Start frequency) ^ 1/16 * Multiplier = (End frequency/ Start frequency) ^ 1/16
* Multiplier = 1.320367784 * Multiplier = 1.320367784
@@ -673,7 +673,7 @@ void FFTcode(void * parameter)
fftCalc[13] = fftAddAvg(86,103); // 18 3704 - 4479 high mid fftCalc[13] = fftAddAvg(86,103); // 18 3704 - 4479 high mid
fftCalc[14] = fftAddAvg(104,164) * 0.88f; // 61 4479 - 7106 high mid + high -- with slight damping fftCalc[14] = fftAddAvg(104,164) * 0.88f; // 61 4479 - 7106 high mid + high -- with slight damping
} }
else if (freqDist == 1) { //WLEDMM: Rightshft: note ewowi: frequencies in comments are not correct else if (freqDist == 1) { //WLEDMM: Rightshift: note ewowi: frequencies in comments are not correct
if (useInputFilter==1) { if (useInputFilter==1) {
// skip frequencies below 100hz // skip frequencies below 100hz
fftCalc[ 0] = 0.8f * fftAddAvg(1,1); fftCalc[ 0] = 0.8f * fftAddAvg(1,1);
@@ -717,7 +717,7 @@ void FFTcode(void * parameter)
memcpy(fftCalc, lastFftCalc, sizeof(fftCalc)); // restore last "good" channels memcpy(fftCalc, lastFftCalc, sizeof(fftCalc)); // restore last "good" channels
} }
// post-processing of frequency channels (pink noise adjustment, AGC, smooting, scaling) // post-processing of frequency channels (pink noise adjustment, AGC, smoothing, scaling)
if (pinkIndex > MAX_PINK) pinkIndex = MAX_PINK; if (pinkIndex > MAX_PINK) pinkIndex = MAX_PINK;
//postProcessFFTResults((fabsf(sampleAvg) > 0.25f)? true : false , NUM_GEQ_CHANNELS); //postProcessFFTResults((fabsf(sampleAvg) > 0.25f)? true : false , NUM_GEQ_CHANNELS);
postProcessFFTResults((fabsf(volumeSmth)>0.25f)? true : false , NUM_GEQ_CHANNELS); // this function modifies fftCalc, fftAvg and fftResult postProcessFFTResults((fabsf(volumeSmth)>0.25f)? true : false , NUM_GEQ_CHANNELS); // this function modifies fftCalc, fftAvg and fftResult
@@ -775,7 +775,7 @@ static void runMicFilter(uint16_t numSamples, float *sampleBuffer) // p
// FIR lowpass, to remove high frequency noise // FIR lowpass, to remove high frequency noise
float highFilteredSample; float highFilteredSample;
if (i < (numSamples-1)) highFilteredSample = beta1*sampleBuffer[i] + beta2*last_vals[0] + beta2*sampleBuffer[i+1]; // smooth out spikes if (i < (numSamples-1)) highFilteredSample = beta1*sampleBuffer[i] + beta2*last_vals[0] + beta2*sampleBuffer[i+1]; // smooth out spikes
else highFilteredSample = beta1*sampleBuffer[i] + beta2*last_vals[0] + beta2*last_vals[1]; // spcial handling for last sample in array else highFilteredSample = beta1*sampleBuffer[i] + beta2*last_vals[0] + beta2*last_vals[1]; // special handling for last sample in array
last_vals[1] = last_vals[0]; last_vals[1] = last_vals[0];
last_vals[0] = sampleBuffer[i]; last_vals[0] = sampleBuffer[i];
sampleBuffer[i] = highFilteredSample; sampleBuffer[i] = highFilteredSample;
@@ -1010,7 +1010,7 @@ class AudioReactive : public Usermod {
// variables used by getSample() and agcAvg() // variables used by getSample() and agcAvg()
int16_t micIn = 0; // Current sample starts with negative values and large values, which is why it's 16 bit signed int16_t micIn = 0; // Current sample starts with negative values and large values, which is why it's 16 bit signed
double sampleMax = 0.0; // Max sample over a few seconds. Needed for AGC controler. double sampleMax = 0.0; // Max sample over a few seconds. Needed for AGC controller.
double micLev = 0.0; // Used to convert returned value to have '0' as minimum. A leveller double micLev = 0.0; // Used to convert returned value to have '0' as minimum. A leveller
float expAdjF = 0.0f; // Used for exponential filter. float expAdjF = 0.0f; // Used for exponential filter.
float sampleReal = 0.0f; // "sampleRaw" as float, to provide bits that are lost otherwise (before amplification by sampleGain or inputLevel). Needed for AGC. float sampleReal = 0.0f; // "sampleRaw" as float, to provide bits that are lost otherwise (before amplification by sampleGain or inputLevel). Needed for AGC.
@@ -1048,7 +1048,7 @@ class AudioReactive : public Usermod {
//////////////////// ////////////////////
void logAudio() void logAudio()
{ {
if (disableSoundProcessing && (!udpSyncConnected || ((audioSyncEnabled & 0x02) == 0))) return; // no audio availeable if (disableSoundProcessing && (!udpSyncConnected || ((audioSyncEnabled & 0x02) == 0))) return; // no audio available
#ifdef MIC_LOGGER #ifdef MIC_LOGGER
// Debugging functions for audio input and sound processing. Comment out the values you want to see // Debugging functions for audio input and sound processing. Comment out the values you want to see
PLOT_PRINT("volumeSmth:"); PLOT_PRINT(volumeSmth + 256.0f); PLOT_PRINT("\t"); // +256 to move above other lines PLOT_PRINT("volumeSmth:"); PLOT_PRINT(volumeSmth + 256.0f); PLOT_PRINT("\t"); // +256 to move above other lines
@@ -1141,13 +1141,13 @@ class AudioReactive : public Usermod {
* 2. we use two setpoints, one at ~60%, and one at ~80% of the maximum signal * 2. we use two setpoints, one at ~60%, and one at ~80% of the maximum signal
* 3. the amplification depends on signal level: * 3. the amplification depends on signal level:
* a) normal zone - very slow adjustment * a) normal zone - very slow adjustment
* b) emergency zome (<10% or >90%) - very fast adjustment * b) emergency zone (<10% or >90%) - very fast adjustment
*/ */
void agcAvg(unsigned long the_time) void agcAvg(unsigned long the_time)
{ {
const int AGC_preset = (soundAgc > 0)? (soundAgc-1): 0; // make sure the _compiler_ knows this value will not change while we are inside the function const int AGC_preset = (soundAgc > 0)? (soundAgc-1): 0; // make sure the _compiler_ knows this value will not change while we are inside the function
float lastMultAgc = multAgc; // last muliplier used float lastMultAgc = multAgc; // last multiplier used
float multAgcTemp = multAgc; // new multiplier float multAgcTemp = multAgc; // new multiplier
float tmpAgc = sampleReal * multAgc; // what-if amplified signal float tmpAgc = sampleReal * multAgc; // what-if amplified signal
@@ -1187,13 +1187,13 @@ class AudioReactive : public Usermod {
if (((multAgcTemp > 0.085f) && (multAgcTemp < 6.5f)) //integrator anti-windup by clamping if (((multAgcTemp > 0.085f) && (multAgcTemp < 6.5f)) //integrator anti-windup by clamping
&& (multAgc*sampleMax < agcZoneStop[AGC_preset])) //integrator ceiling (>140% of max) && (multAgc*sampleMax < agcZoneStop[AGC_preset])) //integrator ceiling (>140% of max)
control_integrated += control_error * 0.002 * 0.25; // 2ms = intgration time; 0.25 for damping control_integrated += control_error * 0.002 * 0.25; // 2ms = integration time; 0.25 for damping
else else
control_integrated *= 0.9; // spin down that beasty integrator control_integrated *= 0.9; // spin down that integrator beast
// apply PI Control // apply PI Control
tmpAgc = sampleReal * lastMultAgc; // check "zone" of the signal using previous gain tmpAgc = sampleReal * lastMultAgc; // check "zone" of the signal using previous gain
if ((tmpAgc > agcZoneHigh[AGC_preset]) || (tmpAgc < soundSquelch + agcZoneLow[AGC_preset])) { // upper/lower emergy zone if ((tmpAgc > agcZoneHigh[AGC_preset]) || (tmpAgc < soundSquelch + agcZoneLow[AGC_preset])) { // upper/lower emergency zone
multAgcTemp = lastMultAgc + agcFollowFast[AGC_preset] * agcControlKp[AGC_preset] * control_error; multAgcTemp = lastMultAgc + agcFollowFast[AGC_preset] * agcControlKp[AGC_preset] * control_error;
multAgcTemp += agcFollowFast[AGC_preset] * agcControlKi[AGC_preset] * control_integrated; multAgcTemp += agcFollowFast[AGC_preset] * agcControlKi[AGC_preset] * control_integrated;
} else { // "normal zone" } else { // "normal zone"
@@ -1201,7 +1201,7 @@ class AudioReactive : public Usermod {
multAgcTemp += agcFollowSlow[AGC_preset] * agcControlKi[AGC_preset] * control_integrated; multAgcTemp += agcFollowSlow[AGC_preset] * agcControlKi[AGC_preset] * control_integrated;
} }
// limit amplification again - PI controler sometimes "overshoots" // limit amplification again - PI controller sometimes "overshoots"
//multAgcTemp = constrain(multAgcTemp, 0.015625f, 32.0f); // 1/64 < multAgcTemp < 32 //multAgcTemp = constrain(multAgcTemp, 0.015625f, 32.0f); // 1/64 < multAgcTemp < 32
if (multAgcTemp > 32.0f) multAgcTemp = 32.0f; if (multAgcTemp > 32.0f) multAgcTemp = 32.0f;
if (multAgcTemp < 1.0f/64.0f) multAgcTemp = 1.0f/64.0f; if (multAgcTemp < 1.0f/64.0f) multAgcTemp = 1.0f/64.0f;
@@ -1231,7 +1231,7 @@ class AudioReactive : public Usermod {
void getSample() void getSample()
{ {
float sampleAdj; // Gain adjusted sample value float sampleAdj; // Gain adjusted sample value
float tmpSample; // An interim sample variable used for calculatioins. float tmpSample; // An interim sample variable used for calculations.
#ifdef WLEDMM_FASTPATH #ifdef WLEDMM_FASTPATH
constexpr float weighting = 0.35f; // slightly reduced filter strength, to reduce audio latency constexpr float weighting = 0.35f; // slightly reduced filter strength, to reduce audio latency
constexpr float weighting2 = 0.25f; constexpr float weighting2 = 0.25f;
@@ -1407,7 +1407,7 @@ class AudioReactive : public Usermod {
if (limiterOn == false) return; if (limiterOn == false) return;
long delta_time = millis() - last_time; long delta_time = millis() - last_time;
delta_time = constrain(delta_time , 1, 1000); // below 1ms -> 1ms; above 1sec -> sily lil hick-up delta_time = constrain(delta_time , 1, 1000); // below 1ms -> 1ms; above 1sec -> silly lil hick-up
float deltaSample = volumeSmth - last_volumeSmth; float deltaSample = volumeSmth - last_volumeSmth;
if (attackTime > 0) { // user has defined attack time > 0 if (attackTime > 0) { // user has defined attack time > 0
@@ -1443,11 +1443,11 @@ class AudioReactive : public Usermod {
receivedFormat = 0; receivedFormat = 0;
DEBUGSR_PRINTLN(F("AR connectUDPSoundSync(): connection lost, UDP closed.")); DEBUGSR_PRINTLN(F("AR connectUDPSoundSync(): connection lost, UDP closed."));
} }
return; // neither AP nor other connections availeable return; // neither AP nor other connections available
} }
if (udpSyncConnected) return; // already connected if (udpSyncConnected) return; // already connected
if (millis() - last_connection_attempt < 15000) return; // only try once in 15 seconds if (millis() - last_connection_attempt < 15000) return; // only try once in 15 seconds
if (updateIsRunning) return; // don't reconect during OTA if (updateIsRunning) return; // don't reconnect during OTA
// if we arrive here, we need a UDP connection but don't have one // if we arrive here, we need a UDP connection but don't have one
last_connection_attempt = millis(); last_connection_attempt = millis();
@@ -1641,7 +1641,7 @@ class AudioReactive : public Usermod {
um_data->u_type[10] = UMT_FLOAT; um_data->u_type[10] = UMT_FLOAT;
#else #else
// ESP8266 // ESP8266
// See https://github.com/MoonModules/WLED/pull/60#issuecomment-1666972133 for explaination of these alternative sources of data // See https://github.com/MoonModules/WLED/pull/60#issuecomment-1666972133 for explanation of these alternative sources of data
um_data->u_data[6] = &maxVol; // assigned in effect function from UI element!!! (Puddlepeak, Ripplepeak, Waterfall) um_data->u_data[6] = &maxVol; // assigned in effect function from UI element!!! (Puddlepeak, Ripplepeak, Waterfall)
um_data->u_type[6] = UMT_BYTE; um_data->u_type[6] = UMT_BYTE;
@@ -1758,7 +1758,7 @@ class AudioReactive : public Usermod {
if (!audioSource) enabled = false; // audio failed to initialise if (!audioSource) enabled = false; // audio failed to initialise
#endif #endif
if (enabled) onUpdateBegin(false); // create FFT task, and initailize network if (enabled) onUpdateBegin(false); // create FFT task, and initialize network
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
if (FFT_Task == nullptr) enabled = false; // FFT task creation failed if (FFT_Task == nullptr) enabled = false; // FFT task creation failed
@@ -1897,9 +1897,9 @@ class AudioReactive : public Usermod {
#if defined(SR_DEBUG) #if defined(SR_DEBUG)
// complain when audio userloop has been delayed for long time. Currently we need userloop running between 500 and 1500 times per second. // complain when audio userloop has been delayed for long time. Currently we need userloop running between 500 and 1500 times per second.
// softhack007 disabled temporarily - avoid serial console spam with MANY leds and low FPS // softhack007 disabled temporarily - avoid serial console spam with MANY LEDs and low FPS
//if ((userloopDelay > /*23*/ 65) && !disableSoundProcessing && (audioSyncEnabled == 0)) { //if ((userloopDelay > /*23*/ 65) && !disableSoundProcessing && (audioSyncEnabled == 0)) {
//DEBUG_PRINTF("[AR userLoop] hickup detected -> was inactive for last %d millis!\n", userloopDelay); //DEBUG_PRINTF("[AR userLoop] hiccup detected -> was inactive for last %d millis!\n", userloopDelay);
//} //}
#endif #endif
@@ -2207,7 +2207,7 @@ class AudioReactive : public Usermod {
} else { } else {
// Analog or I2S digital input // Analog or I2S digital input
if (audioSource && (audioSource->isInitialized())) { if (audioSource && (audioSource->isInitialized())) {
// audio source sucessfully configured // audio source successfully configured
if (audioSource->getType() == AudioSource::Type_I2SAdc) { if (audioSource->getType() == AudioSource::Type_I2SAdc) {
infoArr.add(F("ADC analog")); infoArr.add(F("ADC analog"));
} else { } else {

View File

@@ -163,7 +163,7 @@ class AudioSource {
SRate_t _sampleRate; // Microphone sampling rate SRate_t _sampleRate; // Microphone sampling rate
int _blockSize; // I2S block size int _blockSize; // I2S block size
bool _initialized; // Gets set to true if initialization is successful bool _initialized; // Gets set to true if initialization is successful
bool _i2sMaster; // when false, ESP32 will be in I2S SLAVE mode (for devices that only operate in MASTER mode). Only workds in newer IDF >= 4.4.x bool _i2sMaster; // when false, ESP32 will be in I2S SLAVE mode (for devices that only operate in MASTER mode). Only works in newer IDF >= 4.4.x
float _sampleScale; // pre-scaling factor for I2S samples float _sampleScale; // pre-scaling factor for I2S samples
I2S_datatype newSampleBuffer[I2S_SAMPLES_MAX+4] = { 0 }; // global buffer for i2s_read I2S_datatype newSampleBuffer[I2S_SAMPLES_MAX+4] = { 0 }; // global buffer for i2s_read
}; };
@@ -418,7 +418,7 @@ class I2SSource : public AudioSource {
}; };
/* ES7243 Microphone /* ES7243 Microphone
This is an I2S microphone that requires ininitialization over This is an I2S microphone that requires initialization over
I2C before I2S data can be received I2C before I2S data can be received
*/ */
class ES7243 : public I2SSource { class ES7243 : public I2SSource {
@@ -483,8 +483,8 @@ public:
} }
}; };
/* ES8388 Sound Modude /* ES8388 Sound Module
This is an I2S sound processing unit that requires ininitialization over This is an I2S sound processing unit that requires initialization over
I2C before I2S data can be received. I2C before I2S data can be received.
*/ */
class ES8388Source : public I2SSource { class ES8388Source : public I2SSource {
@@ -532,7 +532,7 @@ class ES8388Source : public I2SSource {
// The mics *and* line-in are BOTH connected to LIN2/RIN2 on the AudioKit // The mics *and* line-in are BOTH connected to LIN2/RIN2 on the AudioKit
// so there's no way to completely eliminate the mics. It's also hella noisy. // so there's no way to completely eliminate the mics. It's also hella noisy.
// Line-in works OK on the AudioKit, generally speaking, as the mics really need // Line-in works OK on the AudioKit, generally speaking, as the mics really need
// amplification to be noticable in a quiet room. If you're in a very loud room, // amplification to be noticeable in a quiet room. If you're in a very loud room,
// the mics on the AudioKit WILL pick up sound even in line-in mode. // the mics on the AudioKit WILL pick up sound even in line-in mode.
// TL;DR: Don't use the AudioKit for anything, use the LyraT. // TL;DR: Don't use the AudioKit for anything, use the LyraT.
// //