For those which are interested in Biquad filter…
Here is a testsketch with low corner frequency:
The amplitude-difference (peak to peak) between the filtered tone and one halftone under and over is as follows:
103.82Hz: 0.13V
Filtered tone= 110Hz: 1.95V Amplitude
116.54Hz: 0.13V
Difference 1.82V
65.4Hz: 0.12V
Filtered tone= 69,29Hz: 1.89V Amplitude
73.41Hz: 0.12V
Difference 1.77V
Despite of written in notes @ https://www.pjrc.com/teensy/gui/index.html?info=AudioFilterBiquad
‘Biquad filters with low corner frequency (under about 400 Hz) can run into trouble with limited numerical precision, causing the filter to perform poorly` with Teensy 3.6 works well.
Maybe because the new powerful microcontroller??
These test results are really great!
Here is a testsketch with low corner frequency:
Code:
/*
[url]https://www.pjrc.com/teensy/gui/index.html?info=AudioFilterBiquad[/url]
Biquad filters test with low corner frequency @ Teensy 3.6.
Try out following sketch.
*/
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=105,240
AudioAmplifier amp1; //xy=264,226
AudioFilterBiquad biquad1; //xy=441,226
AudioAnalyzePeak peak1; //xy=621,226
AudioConnection patchCord1(i2s1, 0, amp1, 0);
AudioConnection patchCord2(amp1, biquad1);
AudioConnection patchCord3(biquad1, peak1);
AudioControlSGTL5000 sgtl5000_1; //xy=362,332
// GUItool: end automatically generated code
elapsedMillis msecs;
//Tones and frequencies
float C = 65.40;
float CIS = 69.29;
float D = 73.41;
float GIS = 103.82;
float A = 110;
float AIS = 116.54;
//Tones and frequencies
void setup() {
Serial.begin(9600);
AudioMemory(30);
sgtl5000_1.enable();
// MicIn
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50); // sgtl5000_1.micGain(30); original
amp1.gain(0); //MicIn (i2s1) gain (again)
//MicIn
delay(1000);
}
void loop() {
// Filter
//File > Examples > Audio > Effects > Filter
// Butterworth filter, 12 db/octave
// biquad1.setLowpass(0, 700, 0.707);
// Linkwitz-Riley filter, 48 dB/octave
biquad1.setBandpass(0, CIS, 15);
biquad1.setBandpass(1, CIS, 15);
biquad1.setBandpass(2, CIS, 15);
biquad1.setBandpass(3, CIS, 15);
// Filter
amp1.gain(0.9); // to ajusd MicIn(i2s1)-gain: Filters must have their input signals attenuated, so the signal does not exceed 1.0 (or 2 if measured peak to peak).
// Amplitude to serial monitor
if (msecs > 100) {
if (peak1.available() ) { //&& peak2.available() commented out...only Mono needed.
msecs = 0;
float leftNumber = peak1.readPeakToPeak();
//float rightNumber = Peak.read();
Serial.println(leftNumber); //left channel
//Serial.println();
// Amplitude to serial monitor
}
}
}
The amplitude-difference (peak to peak) between the filtered tone and one halftone under and over is as follows:
103.82Hz: 0.13V
Filtered tone= 110Hz: 1.95V Amplitude
116.54Hz: 0.13V
Difference 1.82V
65.4Hz: 0.12V
Filtered tone= 69,29Hz: 1.89V Amplitude
73.41Hz: 0.12V
Difference 1.77V
Despite of written in notes @ https://www.pjrc.com/teensy/gui/index.html?info=AudioFilterBiquad
‘Biquad filters with low corner frequency (under about 400 Hz) can run into trouble with limited numerical precision, causing the filter to perform poorly` with Teensy 3.6 works well.
Maybe because the new powerful microcontroller??
These test results are really great!