diff --git a/examples/NoiseSensor/sound_detector.cpp b/examples/NoiseSensor/sound_detector.cpp index 889b341..bda619c 100644 --- a/examples/NoiseSensor/sound_detector.cpp +++ b/examples/NoiseSensor/sound_detector.cpp @@ -22,7 +22,7 @@ #define MIC_I2S_PORT I2S_NUM_1 #define MIC_BLOCK_FRAMES 256 // 16 ms at 16 kHz #define MIC_SLOTS 4 // 4-slot TDM -#define MIC_GAIN GAIN_37_5DB +#define MIC_GAIN GAIN_18DB // Set to 1 to print detected levels while tuning the microphones on hardware. #ifndef SOUND_DETECTOR_DEBUG @@ -43,8 +43,8 @@ static constexpr float FLOOR_MARGIN = 1.25f; static constexpr float ABS_GATE = 0.0008f; static constexpr float BALANCE_DEADBAND = 0.02f; static constexpr float BALANCE_GAIN = 1.8f; // widen the usable stereo range -static constexpr float LOUD_MIN_DB = -60.0f; -static constexpr float LOUD_MAX_DB = -20.0f; +static constexpr float LOUD_MIN_DB = -50.0f; +static constexpr float LOUD_MAX_DB = -6.0f; static constexpr uint32_t HOLD_MS = 260; // Slot discovery: the codec emits four TDM slots but only two microphones are @@ -295,8 +295,8 @@ void SoundDetector::processBlock(const int16_t *frames, size_t frameCount) if (sigR < 0.0f) sigR = 0.0f; // Adaptive gate: a sound must stand clearly above its channel's floor. - float gateL = fmaxf(floorL_ * 2.0f, ABS_GATE); - float gateR = fmaxf(floorR_ * 2.0f, ABS_GATE); + float gateL = fmaxf(floorL_ * 1.5f, ABS_GATE); + float gateR = fmaxf(floorR_ * 1.5f, ABS_GATE); bool present = (sigL > gateL) || (sigR > gateR); uint32_t now = millis(); @@ -332,9 +332,9 @@ void SoundDetector::processBlock(const int16_t *frames, size_t frameCount) if ((uint32_t)(millis() - lastPrintMs) > 1000) { lastPrintMs = millis(); Serial.printf("mic rms %.4f %.4f %.4f %.4f | pair L%d R%d | " - "bal %+.2f loud %.2f%s\n", + "sig %.3f %.3f | bal %+.2f loud %.2f%s\n", rms[0], rms[1], rms[2], rms[3], - leftSlot_, rightSlot_, balance, loudness, + leftSlot_, rightSlot_, sigL, sigR, balance, loudness, active ? "" : " (quiet)"); } #endif