- Added a new header file `AudioLevelTracker.h` to track audio levels with a history of up to 3 seconds and a maximum range limit. - `Config.h` has been added with new serial and I2S configurations. The aim is to configure these peripherals for audio processing. - Added new header file `I2SConfig.h` with setup functions for initializing and reading from I2S interface. - The `AudioLevelTracker.cpp` file has been updated to include functionality for tracking the maximum audio level over a specified duration. - Initial setup for I2S communication with a microphone. - Updated `Arduino` code with improved I2S configuration and dynamic range limiting.
23 lines
535 B
C++
23 lines
535 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <deque>
|
|
|
|
class AudioLevelTracker {
|
|
public:
|
|
AudioLevelTracker();
|
|
void updateMaxLevel(int32_t sample);
|
|
int32_t getMaxLevel() const;
|
|
void resetMaxLevel();
|
|
|
|
private:
|
|
struct SamplePoint {
|
|
uint32_t timestamp;
|
|
int32_t value;
|
|
};
|
|
std::deque<SamplePoint> sampleHistory;
|
|
int32_t maxLevel;
|
|
|
|
static const uint32_t HISTORY_DURATION_MS = 3000; // 3 seconds history
|
|
static const int32_t MAX_RANGE_LIMIT = 200000000; // Maximum allowed range limit
|
|
}; |