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