Hi there!
I'm looking to output high frequency sine waves (~18kHz - ~20kHz) through this Adafruit mono Class D Amplifier (https://www.adafruit.com/product/2130). Here's the very basic preliminary code to test the output, generating random frequencies in that range once every second: (note, I am not using the audio shield)
I have a DC blocking capacitor (10uf) on the output, still doesn't remove the intense harmonic distortion occurring at the lower frequencies. I know the speaker is capable of cleanly outputting the high frequency because I get great results when directly plugging it into my iPhone's tone generator (those high frequencies are completely inaudible to human ears, which is exactly what I want). Is this a matter of the teensy's analog 12-bit resolution not being high enough to produce a smooth sine wave?
Thanks in advance for any help!
I'm looking to output high frequency sine waves (~18kHz - ~20kHz) through this Adafruit mono Class D Amplifier (https://www.adafruit.com/product/2130). Here's the very basic preliminary code to test the output, generating random frequencies in that range once every second: (note, I am not using the audio shield)
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
AudioSynthWaveformSine sine1;
AudioOutputAnalog dac1;
AudioConnection patchCord2(sine1, 0, dac1, 0);
long freq = 18500;
void setup() {
AudioMemory(20);
sine1.frequency(freq);
sine1.amplitude(1);
}
void loop(){
sine1.frequency(int(random(0,1500)) + freq);
delay(1000);
}
I have a DC blocking capacitor (10uf) on the output, still doesn't remove the intense harmonic distortion occurring at the lower frequencies. I know the speaker is capable of cleanly outputting the high frequency because I get great results when directly plugging it into my iPhone's tone generator (those high frequencies are completely inaudible to human ears, which is exactly what I want). Is this a matter of the teensy's analog 12-bit resolution not being high enough to produce a smooth sine wave?
Thanks in advance for any help!