feat ✨: Added new header files AudioLevelTracker.h, Config.h, I2SConfig.h, and updated Arduino code for improved I2S communication and dynamic range limiting.
- 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.
This commit is contained in:
23
include/AudioLevelTracker.h
Normal file
23
include/AudioLevelTracker.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#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
|
||||
};
|
||||
Reference in New Issue
Block a user