|
|
float | square (const float v) |
| |
|
float | decibel_A_scaling (const float frequency) |
| | Scaling for the DecibelA model.
|
| |
|
float | decibel_B_scaling (const float frequency) |
| | Scaling for the DecibelB model.
|
| |
|
float | decibel_C_scaling (const float frequency) |
| | Scaling for the DecibelC model.
|
| |
| void | set_sensitivity (const uint8_t sensitivity) |
| | Set the microphone sensitivity, applied as a gain on the raw samples (FFT, sound level and auto gain input). The gain is logarithmic: 0 is minSensitivityGain, defaultSensitivity is no gain, maxSensitivity is maxSensitivityGain. Not saved: restored to defaultSensitivity on reboot.
|
| |
| uint8_t | get_sensitivity () |
| | Get the microphone sensitivity.
|
| |
| float | sensitivity_to_gain (const uint8_t sensitivity) |
| | Get the gain applied to the raw samples for a sensitivity.
|
| |
|
int16_t | saturate_to_int16 (const float value) |
| | Convert a gained sample to int16: an out of range float to integer conversion is undefined, so saturate first.
|
| |
| bool | enable () |
| | Start the microphone data analysis, if not already started.
|
| |
|
void | disable () |
| | Disable the microphone data analysis, if its running.
|
| |
|
void | disable_after_non_use () |
| | disable microphone if last used a target time ago
|
| |
|
static bool | init_sound_struct () |
| | Fill the constant parts of the sound structure.
|
| |
|
SoundStruct & | process_sound_data (const hal::microphone::PdmData &data) |
| |
| SoundStruct & | get_sound_characteristics () |
| | Compute and process sound data.
|
| |
|
|
common::fft::FftAnalyzer< hal::microphone::PdmData::SAMPLE_SIZE, SoundStruct::numberOfFFtChanels, float > | fftAnalyzer |
| |
|
volatile uint8_t | _sensitivity = defaultSensitivity |
| | Set by the inputs (main loop), read by the sound processing (user thread): a single byte write is atomic.
|
| |
|
bool | isStarted = false |
| |
|
uint32_t | lastMicFunctionCall = 0 |
| |
|
float | autoGain = 1.0f |
| |
|
bool | hasProcessedSample = false |
| | Has a sample been processed since the microphone started.
|
| |
|
uint64_t | lastProcessedSampleTime_us = 0 |
| | Start time of the last processed sample: the platform can return the same sample many times.
|
| |
|
static constexpr float | minAutoGain = 0.0001f |
| |
|
static constexpr float | maxAutoGain = 30.0f |
| |
|
static constexpr float | distortionFactor = 0.00005f |
| |
|
static constexpr float | desiredoutputRMS = desiredoutput * desiredoutput |
| |
|
static constexpr float | inverseInt16Max = 1.0f / static_cast<float>(INT16_MAX) |
| | multiplications are faster than divisions on the target
|
| |
|
static constexpr float | inverseDesiredoutputRMS = 1.0f / desiredoutputRMS |
| |
|
SoundStruct | soundStruct |
| |
|
constexpr float | silenceLevelDb = 30.0 |
| | Decibel level for a silent room.
|
| |
|
constexpr float | highLevelDb = 80.0 |
| | Microphone is not good enough at after this.
|
| |
|
constexpr float | desiredoutput = 0.5f |
| | Desired output of the auto gain (0-1)
|
| |
|
constexpr int16_t | gainedSignalTarget = INT16_MAX * desiredoutput |
| | Desired output of the auto gain (0-INT16_MAX)
|
| |
|
constexpr uint8_t | defaultSensitivity = 50 |
| | Default microphone sensitivity: no gain applied to the samples.
|
| |
|
constexpr uint8_t | maxSensitivity = 100 |
| | Maximum microphone sensitivity.
|
| |
|
constexpr float | minSensitivityGain = 0.1f |
| | Gain applied to the samples at the minimum sensitivity (0)
|
| |
|
constexpr float | maxSensitivityGain = 10.0f |
| | Gain applied to the samples at the maximum sensitivity (maxSensitivity)
|
| |
Handle the microphone physical interface.