Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

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

  1. #1

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

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

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,928
    See the audio library FFT and peak measure tools, the audio board is just a handy package to do things through and the audio library will happily read from a mic on an analog pin or a couple of other sources

    http://www.pjrc.com/teensy/td_libs_Audio.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •