small improvements for audioreactive
* added ESP_INTR_FLAG_IRAM to reduce lost samples (only on ESP32 without PSRAM) --> may cause crash if used wrongly * FFT_MajorPeak stabilized, by ignoring extreme results
This commit is contained in:
@@ -617,6 +617,9 @@ void FFTcode(void * parameter)
|
||||
FFT.ComplexToMagnitude(); // Compute magnitudes
|
||||
#endif
|
||||
|
||||
float last_majorpeak = FFT_MajorPeak;
|
||||
float last_magnitude = FFT_Magnitude;
|
||||
|
||||
#ifdef FFT_MAJORPEAK_HUMAN_EAR
|
||||
// scale FFT results
|
||||
for(uint_fast16_t binInd = 0; binInd < samplesFFT; binInd++)
|
||||
@@ -629,6 +632,9 @@ void FFTcode(void * parameter)
|
||||
FFT.MajorPeak(&FFT_MajorPeak, &FFT_Magnitude); // let the effects know which freq was most dominant
|
||||
#endif
|
||||
|
||||
if (FFT_MajorPeak < (SAMPLE_RATE / samplesFFT)) {FFT_MajorPeak = 1.0f; FFT_Magnitude = 0;} // too low - use zero
|
||||
if (FFT_MajorPeak > (0.42f * SAMPLE_RATE)) {FFT_MajorPeak = last_majorpeak; FFT_Magnitude = last_magnitude;} // too high - keep last peak
|
||||
|
||||
#ifdef FFT_MAJORPEAK_HUMAN_EAR
|
||||
// undo scaling - we want unmodified values for FFTResult[] computations
|
||||
for(uint_fast16_t binInd = 0; binInd < samplesFFT; binInd++)
|
||||
|
||||
@@ -185,8 +185,12 @@ class I2SSource : public AudioSource {
|
||||
.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
|
||||
//.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
|
||||
#ifdef WLEDMM_FASTPATH
|
||||
#if CONFIG_IDF_TARGET_ESP32 && !defined(BOARD_HAS_PSRAM) // still need to test on boards with PSRAM
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_IRAM|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3, // IRAM flag reduces missed samples
|
||||
#else
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3, // seems to reduce noise
|
||||
.dma_buf_count = 28, // 160ms buffer (128 * dma_buf_count / sampleRate)
|
||||
#endif
|
||||
.dma_buf_count = 24, // 140ms buffer (128 * dma_buf_count / sampleRate)
|
||||
#else
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2,
|
||||
.dma_buf_count = 8,
|
||||
|
||||
Reference in New Issue
Block a user