Hello everyone,
The facts:
My current setup is Teensy3.6, arduino 1.8.5, Teensyduino 1.40, osx.
Compiling for cpu speeds 24-192MHz everything works fine.
Compiling for 216-240MHz and the audio from the adapter board is distorted.
You can clearly see the jitter on LRCLK with a scope.
Audio from the dac is not distorted.
For those who don't have acces to a scope, I have included a small program to demonstrate the effect.
You can also use it to compare the outputs of the adapter board and the dac with a scope.
The questions:
Is this a hardware limitation due to some kind of clock divider stuff or is it some software problem?
And how can we solve this?
The code:
generate a 4400Hz sine for 2 secs and then sweep to 8800Hz in 4 secs, rinse and repeat.
Comment everything in the main loop to disable the sweep if you want to compare the 2 outputs on your scope.
Now compile for 192MHz cpu speed and listen. This is smooth.
Now compile for 240MHz cpu speed and listen. What is happening?
Now compile for 216MHz cpu speed and listen. Oh the horror!
*warning*: your pet(s) may not like this sound.
One final thought, long time ago I once told myself(luckily I didnt swear) I would never use arduino and here I am admitting defeat thanks to Paul's Teensys and audio library.
Great stuff, thank you very much!
The facts:
My current setup is Teensy3.6, arduino 1.8.5, Teensyduino 1.40, osx.
Compiling for cpu speeds 24-192MHz everything works fine.
Compiling for 216-240MHz and the audio from the adapter board is distorted.
You can clearly see the jitter on LRCLK with a scope.
Audio from the dac is not distorted.
For those who don't have acces to a scope, I have included a small program to demonstrate the effect.
You can also use it to compare the outputs of the adapter board and the dac with a scope.
The questions:
Is this a hardware limitation due to some kind of clock divider stuff or is it some software problem?
And how can we solve this?
The code:
generate a 4400Hz sine for 2 secs and then sweep to 8800Hz in 4 secs, rinse and repeat.
Comment everything in the main loop to disable the sweep if you want to compare the 2 outputs on your scope.
Now compile for 192MHz cpu speed and listen. This is smooth.
Now compile for 240MHz cpu speed and listen. What is happening?
Now compile for 216MHz cpu speed and listen. Oh the horror!
*warning*: your pet(s) may not like this sound.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=71,83
AudioSynthWaveformSineModulated sine_fm1; //xy=199,83
AudioOutputI2S i2s1; //xy=370,58
AudioOutputAnalogStereo dacs1; //xy=380,119
AudioConnection patchCord1(sine1, sine_fm1);
AudioConnection patchCord2(sine_fm1, 0, i2s1, 0);
AudioConnection patchCord3(sine_fm1, 0, i2s1, 1);
AudioConnection patchCord4(sine_fm1, 0, dacs1, 0);
AudioConnection patchCord5(sine_fm1, 0, dacs1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=73,34
// GUItool: end automatically generated code
void setup() {
AudioMemory(2);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sine1.frequency(.0625);
sine_fm1.frequency(4400);
sine1.amplitude(0);
sine_fm1.amplitude(1);
}
void loop() {
delay(2000);
sine1.phase(0);
sine1.amplitude(1);
delay(4000);
sine1.amplitude(0);
}
One final thought, long time ago I once told myself(luckily I didnt swear) I would never use arduino and here I am admitting defeat thanks to Paul's Teensys and audio library.
Great stuff, thank you very much!