phillipps76
Member
It seems that the lower notes are detected due possibly to their stronger amplitude. is it possible to patch the input into a bandpass filter then into notefreq to detect notes in higher frequencies? I try and there is no output even when running a 500hz sine wave.
here is my code:
#include <Audio.h>
// Audio setup
AudioInputI2S i2sInput; // Line-in input
AudioFilterStateVariable bandPassFilter1; // Single band-pass filter
AudioAnalyzeNoteFrequency notefreq1; // Single note frequency analyzer
AudioControlSGTL5000 audioShield; // Audio shield for Teensy
AudioConnection patchCord1(i2sInput, 0, bandPassFilter1, 0);
AudioConnection patchCord2(bandPassFilter1, 0, notefreq1, 0);
void setup() {
Serial.begin(115200); // Initialize Serial for debugging
AudioMemory(30); // Allocate memory for audio processing
// Audio Shield setup
audioShield.enable();
audioShield.inputSelect(AUDIO_INPUT_LINEIN); // Use line-in for audio input
audioShield.lineInLevel(15); // Set input gain to maximum
// Configure the band-pass filter
bandPassFilter1.frequency(500); // Focus on 440 Hz for testing
bandPassFilter1.resonance(0.1); // Moderate range for the filter
// Configure the note frequency analyzer
notefreq1.begin(0.10); // Threshold for Yin algorithm
Serial.println("Setup complete. Waiting for signal...");
}
void loop() {
// Analyze notes from the filtered range
if (notefreq1.available()) {
float note1 = notefreq1.read(); // Get detected note frequency
float prob1 = notefreq1.probability(); // Get detection probability
Serial.printf("Note: %3.2f Hz | Probability: %.2f\n", note1, prob1);
} else {
Serial.println("No note detected.");
}
}
thanks for any help or advice.
here is my code:
#include <Audio.h>
// Audio setup
AudioInputI2S i2sInput; // Line-in input
AudioFilterStateVariable bandPassFilter1; // Single band-pass filter
AudioAnalyzeNoteFrequency notefreq1; // Single note frequency analyzer
AudioControlSGTL5000 audioShield; // Audio shield for Teensy
AudioConnection patchCord1(i2sInput, 0, bandPassFilter1, 0);
AudioConnection patchCord2(bandPassFilter1, 0, notefreq1, 0);
void setup() {
Serial.begin(115200); // Initialize Serial for debugging
AudioMemory(30); // Allocate memory for audio processing
// Audio Shield setup
audioShield.enable();
audioShield.inputSelect(AUDIO_INPUT_LINEIN); // Use line-in for audio input
audioShield.lineInLevel(15); // Set input gain to maximum
// Configure the band-pass filter
bandPassFilter1.frequency(500); // Focus on 440 Hz for testing
bandPassFilter1.resonance(0.1); // Moderate range for the filter
// Configure the note frequency analyzer
notefreq1.begin(0.10); // Threshold for Yin algorithm
Serial.println("Setup complete. Waiting for signal...");
}
void loop() {
// Analyze notes from the filtered range
if (notefreq1.available()) {
float note1 = notefreq1.read(); // Get detected note frequency
float prob1 = notefreq1.probability(); // Get detection probability
Serial.printf("Note: %3.2f Hz | Probability: %.2f\n", note1, prob1);
} else {
Serial.println("No note detected.");
}
}
thanks for any help or advice.