Revalogics
Well-known member
So I have made a sketch for Teensy 3.6 I have that uses a single ADC as an input and USB as an output with nothing connected between them. I tested it using Windows and it worked OK, aside from faint RF noises I'm hearing so I put a 40nF ceramic capacitor between ADC input and AGND. I tried it on Linux (Ubuntu 16.04) using JACK audio connection toolkit, a realtime low-latency audio driver, and it worked OK for the first few seconds and gets noisy and noisy as time goes by and after a while, noise comes down gradually, going to clean audio again. Maybe it is caused by the inaccuracy of the sample rate?
I choose 48000 Hz because clock frequencies in Teensy can be divided and will arrive at 48000 accurately.
Anyone knows how to change the sample rate, especially for ADC, USB, and any other peripherals involved?
I choose 48000 Hz because clock frequencies in Teensy can be divided and will arrive at 48000 accurately.
Anyone knows how to change the sample rate, especially for ADC, USB, and any other peripherals involved?
Code:
#include <Audio.h>
AudioInputAnalog adc1;
AudioOutputUSB usb1;
AudioConnection patchCord1(adc1, 0, usb1, 0);
AudioConnection patchCord2(adc1, 0, usb1, 1);
elapsedMillis fader13timer2;
byte fader13timer = 0;
byte fader13PWM = 0;
boolean dir = 0;
void setup() {
AudioMemory(16);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
fader13();
}
void fader13() {
if(fader13timer == 0) digitalWrite(13, 1);
if(fader13timer >= fader13PWM) digitalWrite(13, 0);
if(fader13timer2 >= 5) {
fader13timer2 = 0;
if(dir) {
fader13PWM++;
if(fader13PWM == 255) dir = 0;
}
if(!dir) {
fader13PWM--;
if(fader13PWM == 0) dir = 1;
}
}
fader13timer++;
}