Fix microphone stereo detection on the T-Deck Plus
I2S_CHANNEL_FMT_ALL_LEFT copies a single channel into every slot, so both microphones read the same signal and the balance stayed at zero. Use I2S_CHANNEL_FMT_MULTIPLE (the real TDM mode) instead. The board only fits two of the four ES7210 mic footprints, but the schematic carries all four. Rather than hardcode MIC1/MIC3, the detector now measures the TDM slots and locks onto the two that carry signal, treating the lower slot as the left microphone. Equal maximum gain is applied to all inputs so the pair amplifies consistently. Also widen the balance range (claps produce only a few dB of difference between the closely spaced mics) and recalibrate loudness to the dBFS range seen with 37.5 dB analog gain.
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
* @file sound_detector.h
|
||||
* @brief Dual-microphone sound localizer for the T-Deck Plus (ES7210).
|
||||
*
|
||||
* Reads the two populated MEMS microphones as a 4-slot TDM stream:
|
||||
* slot 0 = MIC1 (left), slot 2 = MIC3 (right)
|
||||
* and exposes a smoothed left/right level, a stereo balance and a loudness
|
||||
* value suitable for placing a radar blip.
|
||||
* Reads the ES7210's four TDM slots and uses the two slots that carry a
|
||||
* populated MEMS microphone (the board only fits two of the four footprints).
|
||||
* Balance is taken from the level difference between the pair, so a sound on
|
||||
* the left or right side moves a radar blip accordingly.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@@ -54,4 +54,12 @@ private:
|
||||
float envR_ = 0.0f;
|
||||
float floorL_ = 0.01f;
|
||||
float floorR_ = 0.01f;
|
||||
|
||||
// The codec always delivers four TDM slots, but only two microphones are
|
||||
// fitted. These are discovered at runtime from whichever slots carry the
|
||||
// most signal.
|
||||
int leftSlot_ = 0;
|
||||
int rightSlot_ = 1;
|
||||
bool pairLocked_ = false;
|
||||
float slotScore_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user