Pārlūkot izejas kodu

Improve accuracy in AudioPeak(..);

min and max resetting to 0 each reset wasn't as accurate in a shortened
sampling time as making them the opposite of their potential maximums.

removed conditional serial prints as well, they were a hangover from
trying to make AudioInputAnalog & AudioOutputAnalog cooperate in a 'non
standard' order for my current pet project.

Considered renaming Dpp() to what it is abbreviating, being
DataPeak2Peak, but not sure that is a good name anyway.
dds
robsoles pirms 10 gadiem
vecāks
revīzija
250e0d412f
1 mainītis faili ar 3 papildinājumiem un 11 dzēšanām
  1. +3
    -11
      analyze_peakdetect.cpp

+ 3
- 11
analyze_peakdetect.cpp Parādīt failu

@@ -26,17 +26,12 @@

#include "analyze_peakdetect.h"

// #define PEAKREPORTVERBS

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) {
@@ -50,9 +45,6 @@ void AudioPeak::update(void)
if(d<min) min=d;
if(d>max) max=d;
} while (p < end);
#ifdef PEAKREPORTVERBS
Serial.println("AudioPeak ran");
#endif
release(block);
}

@@ -60,13 +52,13 @@ void AudioPeak::begin(bool noReset)
{
if(!noReset)
{
min=0;
max=0;
min=32767;
max=-32767;
}
m_enabled=true;
}
uint16_t AudioPeak::Dpp(void)
{
return max-min;
if(max>min) return max-min; else return 0;
}


Notiek ielāde…
Atcelt
Saglabāt