瀏覽代碼

Add readPeakToPeak() to AudioAnalyzePeak

dds
PaulStoffregen 8 年之前
父節點
當前提交
32245a94ce
共有 2 個檔案被更改,包括 21 行新增3 行删除
  1. +16
    -2
      analyze_peak.h
  2. +5
    -1
      gui/index.html

+ 16
- 2
analyze_peak.h 查看文件

@@ -45,12 +45,26 @@ public:
}
float read(void) {
__disable_irq();
int diff = max_sample - min_sample;
int min = min_sample;
int max = max_sample;
min_sample = 32767;
max_sample = -32768;
__enable_irq();
return diff / 65535.0;
min = abs(min);
max = abs(max);
if (min > max) max = min;
return (float)max / 32767.0f;
}
float readPeakToPeak(void) {
__disable_irq();
int min = min_sample;
int max = max_sample;
min_sample = 32767;
max_sample = -32768;
__enable_irq();
return (float)(max - min) / 32767.0f;
}

virtual void update(void);
private:
audio_block_t *inputQueueArray[1];

+ 5
- 1
gui/index.html 查看文件

@@ -2082,9 +2082,13 @@ double s_freq = .0625;</p>
<p class=desc>Returns true each time new peak data is available.
</p>
<p class=func><span class=keyword>read</span>();</p>
<p class=desc>Read the highest peak value since the last read.
<p class=desc>Read the highest peak amplitude value since the last read.
Return is from 0.0 to 1.0.
</p>
<p class=func><span class=keyword>readPeakToPeak</span>();</p>
<p class=desc>Read the highest peak-to-peak amplitude since the last read.
Return is from 0.0 to 2.0.
</p>
<h3>Examples</h3>
<p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; PeakMeterMono
</p>

Loading…
取消
儲存