Hello,
as I show in my last post the “notefreq”-app works on my Teensy.
In the meantime I increase my equipment with the AudioAdaptor for Teensy.
https://www.pjrc.com/store/teensy3_audio.html
The goal was to get “notefreq” work in real, through the mic input from AudioAdaptor and not via transformed wav to sketch files.
First step was to attach the microphone and to test it.
A simple task with video tutorial and documentation:
See Part 2-4: Using the Microphone
https://github.com/PaulStoffregen/AudioWorkshop2015/raw/master/workshop.pdf
Code:
// Advanced Microcontroller-based Audio Workshop
//
// https://github.com/PaulStoffregen/AudioWorkshop2015/raw/master/workshop.pdf
// https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
//
// Part 2-4: Using The Microphone
///////////////////////////////////
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s2; //xy=64,105
AudioOutputI2S i2s3; //xy=301,212
AudioConnection patchCord1(i2s2, 0, i2s3, 0);
AudioConnection patchCord2(i2s2, 0, i2s3, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=203,275
// GUItool: end automatically generated code
///////////////////////////////////
void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(30);
delay(1000);
}
void loop() {
// do nothing
}
Until this point everything ok. Mic and output to my stereo amp works fine! 
Next step:
Design of note frequency detection via mic.
I used this simply design...Image: Note_Freq_mic1
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=246,135
AudioAnalyzeNoteFrequency notefreq1; //xy=623,182
AudioConnection patchCord1(i2s1, 0, notefreq1, 0);
// GUItool: end automatically generated code
void setup() {
AudioMemory(30);
/*
* Initialize the yin algorithm's absolute
* threshold, this is good number.
*/
notefreq1.begin(.15);
// pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// read back fundamental frequency
if (notefreq1.available()) {
float note = notefreq1.read();
float prob = notefreq1.probability();
Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
}
}
Unfortunately with completely silence it prints out a frequency of ca. 83Hz.
Image: Note_Freq_mic1_80Hz Dropbox - Note_Freq_mic1_80Hz.JPG - Simplify your life
To understand the problem better I connect also the output to hear what happens.
Image: Note_Freq_mic_output Dropbox - Note_Freq_mic_output.JPG - Simplify your life
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=352,135
AudioAnalyzeNoteFrequency notefreq1; //xy=600,228
AudioOutputI2S i2s2; //xy=626,144
AudioConnection patchCord1(i2s1, 0, notefreq1, 0);
AudioConnection patchCord2(i2s1, 0, i2s2, 0);
AudioConnection patchCord3(i2s1, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=525,305
// GUItool: end automatically generated code
//---------------------------------------------------------------------------------------
void setup() {
AudioMemory(30);
Serial.begin(9600);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(30);
delay(1000);
/*
* Initialize the yin algorithm's absolute
* threshold, this is good number.
*/
notefreq1.begin(.15);
//pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// read back fundamental frequency
if (notefreq1.available()) {
float note = notefreq1.read();
float prob = notefreq1.probability();
Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
}
}
On every new line that prints on serial monitor I hear a noise. If I halve the CPU speed from 48Mhz to 24Mhz the detected frequency duplicates to 170Hz and the noise I hear at my loudspeakers is also half as fast.
Why I have this issue? Any elementary error in programming? 
BR