From a5e9df66684c5dc5bc132dd1d90efd63a5bfe87c Mon Sep 17 00:00:00 2001 From: Troy <5659019+troyhacks@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:14:03 -0500 Subject: [PATCH] Revert "Merge pull request #204 from troyhacks/Strip_Level_Color_Adjust" This reverts commit db55872732889daf449b1b66317f7c783f2ee0d6, reversing changes made to 972257a7ee8cf800b9ec3d445039727b30003eb4. --- usermods/audioreactive/audio_reactive.h | 2 +- usermods/audioreactive/audio_source.h | 18 +++--------------- wled00/bus_manager.cpp | 6 +----- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 1e5f9681..5e343a2b 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -348,7 +348,7 @@ static float lastFftCalc[NUM_GEQ_CHANNELS] = {0.0f}; // backup #if !defined(CONFIG_IDF_TARGET_ESP32C3) // audio source parameters and constant -constexpr SRate_t SAMPLE_RATE = 96000; // Base sample rate in Hz - 22Khz is a standard rate. Physical sample time -> 23ms +constexpr SRate_t SAMPLE_RATE = 22050; // Base sample rate in Hz - 22Khz is a standard rate. Physical sample time -> 23ms //constexpr SRate_t SAMPLE_RATE = 16000; // 16kHz - use if FFTtask takes more than 20ms. Physical sample time -> 32ms //constexpr SRate_t SAMPLE_RATE = 20480; // Base sample rate in Hz - 20Khz is experimental. Physical sample time -> 25ms //constexpr SRate_t SAMPLE_RATE = 10240; // Base sample rate in Hz - previous default. Physical sample time -> 50ms diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h index 2313001b..e8bba8ef 100644 --- a/usermods/audioreactive/audio_source.h +++ b/usermods/audioreactive/audio_source.h @@ -186,7 +186,6 @@ class AudioSource { 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 I2S_datatype newSampleBuffer[I2S_SAMPLES_MAX+4] = { 0 }; // global buffer for i2s_read - I2S_datatype newSampleBuffer4x[(I2S_SAMPLES_MAX*4)+4] = { 0 }; // global buffer for i2s_read }; /* Basic I2S microphone source @@ -195,12 +194,12 @@ class AudioSource { */ class I2SSource : public AudioSource { public: - I2SSource(SRate_t sampleRate, int blockSize, float sampleScale = 1.0f, bool i2sMaster=false) : + I2SSource(SRate_t sampleRate, int blockSize, float sampleScale = 1.0f, bool i2sMaster=true) : AudioSource(sampleRate, blockSize, sampleScale, i2sMaster) { _config = { .mode = i2sMaster ? i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX) : i2s_mode_t(I2S_MODE_SLAVE | I2S_MODE_RX), - .sample_rate = _sampleRate, // slave mode: may help to set this to 96000, as the other side (master) controls sample rates - .bits_per_sample = I2S_SAMPLE_RESOLUTION, + .sample_rate = _sampleRate, + .bits_per_sample = I2S_SAMPLE_RESOLUTION, // slave mode: may help to set this to 96000, as the other side (master) controls sample rates .channel_format = I2S_MIC_CHANNEL, #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0) .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S), @@ -395,8 +394,6 @@ class I2SSource : public AudioSource { memset(buffer, 0, sizeof(float) * num_samples); // clear output buffer I2S_datatype *newSamples = newSampleBuffer; // use global input buffer - I2S_datatype *newSamples_buff = newSampleBuffer4x; // use oversampling global input buffer - if (num_samples > I2S_SAMPLES_MAX) num_samples = I2S_SAMPLES_MAX; // protect the buffer from overflow err = i2s_read(AR_I2S_PORT, (void *)newSamples, num_samples * sizeof(I2S_datatype), &bytes_read, portMAX_DELAY); @@ -411,15 +408,6 @@ class I2SSource : public AudioSource { return; } - if (_sampleRate == 96000) { - int current = 0; - for (int i = 0; i < 2048; i += 4) { - newSamples[current] = newSamples_buff[i]; - current++; - } - num_samples /= 4; // back to 512 samples - } - // Store samples in sample buffer and update DC offset for (int i = 0; i < num_samples; i++) { diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index ff12b85e..5dd51d0a 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -102,7 +102,7 @@ uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaul uint8_t swapW = defaultColorOrder >> 4; for (uint8_t i = 0; i < _count; i++) { if (pix >= _mappings[i].start && pix < (_mappings[i].start + _mappings[i].len)) { - return _mappings[i].colorOrder | (swapW << 4); // WLED-MM/TroyHacks: Disabling this disables color order mapping. + return _mappings[i].colorOrder | (swapW << 4); } } return defaultColorOrder; @@ -202,10 +202,6 @@ void IRAM_ATTR BusDigital::setPixelColor(uint16_t pix, uint32_t c) { case 2: c = RGBW32(R(cOld), G(cOld), W(c) , 0); break; } } - if (_colorOrder != co) { - c = RGBW32(dim8_lin(R(c)), dim8_lin(G(c)), dim8_lin(B(c)), 0); // WLED-MM/TroyHacks - remap pixels not in the default color order - co = _colorOrder; // keep the original color order, as this is a hack. :) - } PolyBus::setPixelColor(_busPtr, _iType, pix, c, co); }