浏览代码

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 10 年前
父节点
当前提交
250e0d412f
共有 1 个文件被更改,包括 3 次插入11 次删除
  1. +3
    -11
      analyze_peakdetect.cpp

+ 3
- 11
analyze_peakdetect.cpp 查看文件



#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;
} }



正在加载...
取消
保存