[ask]Need to Detect 1kHz tone peak amplitude by just using teensy 3.2 board?

Status
Not open for further replies.
Hi all, i am newbie on teensy board. Currently, I am using teensy 3.2 to generate 1kHz tone and also able to read back the 1kz freq by connecting a mems mic. But in the mean time, I wish to capture the peak amplitude of the tone together with the freq. Do anyone have ideas how to capture the peak amplitude?
I do not use the audio adaptor board. What I have just the teensy 3.2 board. Need help!! Thanks.

Here is my simple code that get from gitHub.

#include "FreqMeasure.h"

void setup() {

// initialize serial communication at 9600 bits per second:
// AudioMemory(4);
Serial.begin(9600);
// play a note on pin 8 for 200 ms:
tone(8, 1000, 2000);
delay(200);

FreqMeasure.begin();
}
double sum=0;
int count=0;

void loop() {

if (FreqMeasure.available()) {
// average several reading together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
float frequency = FreqMeasure.countToFrequency(sum / count);
Serial.println(frequency);
sum = 0;
count = 0;

}
}
// turn off tone function for pin 8:
// noTone(8);
}
 
Status
Not open for further replies.
Back
Top