|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "analyze_peakdetect.h" |
|
|
#include "analyze_peakdetect.h" |
|
|
|
|
|
|
|
|
// #define PEAKREPORTVERBS |
|
|
|
|
|
|
|
|
|
|
|
void AudioPeak::update(void) |
|
|
void AudioPeak::update(void) |
|
|
{ |
|
|
{ |
|
|
audio_block_t *block; |
|
|
audio_block_t *block; |
|
|
const int16_t *p, *end; |
|
|
const int16_t *p, *end; |
|
|
block = receiveReadOnly(); |
|
|
block = receiveReadOnly(); |
|
|
if (!block) { |
|
|
if (!block) { |
|
|
#ifdef PEAKREPORTVERBS |
|
|
|
|
|
Serial.println("AudioPeak !block"); |
|
|
|
|
|
#endif |
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (!m_enabled) { |
|
|
if (!m_enabled) { |
|
|
|
|
|
|
|
|
if(d<min) min=d; |
|
|
if(d<min) min=d; |
|
|
if(d>max) max=d; |
|
|
if(d>max) max=d; |
|
|
} while (p < end); |
|
|
} while (p < end); |
|
|
#ifdef PEAKREPORTVERBS |
|
|
|
|
|
Serial.println("AudioPeak ran"); |
|
|
|
|
|
#endif |
|
|
|
|
|
release(block); |
|
|
release(block); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
if(!noReset) |
|
|
if(!noReset) |
|
|
{ |
|
|
{ |
|
|
min=0; |
|
|
|
|
|
max=0; |
|
|
|
|
|
|
|
|
min=32767; |
|
|
|
|
|
max=-32767; |
|
|
} |
|
|
} |
|
|
m_enabled=true; |
|
|
m_enabled=true; |
|
|
} |
|
|
} |
|
|
uint16_t AudioPeak::Dpp(void) |
|
|
uint16_t AudioPeak::Dpp(void) |
|
|
{ |
|
|
{ |
|
|
return max-min; |
|
|
|
|
|
|
|
|
if(max>min) return max-min; else return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|