Hello,
I'm trying to create an audio pass thru with the GIGA R, using the following code. It works intermittently. I can hear the audio, but there's also a lot of TV snow like noise. Is the GIGA R1 not suited for this type of application? Also, what values should I use for bits per channel and queue depth? Code follows, any help would be appreciated, thanks!
/*
attempting to use GIGI R1 as an audio pass thru device
based on pass thru code in the arduino advanced audio library
pin setup
Audio In (from DAW)
- from audio interface 1 - via 3.5mm stero jack to 3.5mm audio breakout board
- tip to pin A0
- rind to pin A1
- GND to GND
Audio Out
- to audio interface 2 - via 3.5mm stereo jack to 3.5mm audio breakout board
- tip to pin DAC0
- ring to pin DAC1
- GND to GND
*/
// libs
#include <Arduino_AdvancedAnalog.h>
// vars
AdvancedADC adcL(A0); // create an adc for left channel - Pin A0
//AdvancedADC adcR(A1); // create an adc for the right channel - pin A1
AdvancedDAC dacL(A12); // create a dac for the left channel - pin dac0 aka pin 12
//AdvancedDAC dacR(A13); // create a dac for the left channel - pin dac1 aka pin 13
int SampleRate = 26040;
int NumOfSamplesPerChannel = 32;
int QueueDepth = 64;
/* notes
what is the correct # samples per channel and queue depth?
*/
// setup
void setup() {
Serial.begin(9600);
// initiliaize the ADC's and DAC's
// Resolution, sample rate, number of samples per channel, queue depth.
if (!adcL.begin(AN_RESOLUTION_12, SampleRate, NumOfSamplesPerChannel, QueueDepth)) { // goal 12bit bit depth, 26040hz sample rate
Serial.println("Failed to start adc left!");
while (1);
}
/*
if (!adcR.begin(AN_RESOLUTION_12, SampleRate, NumOfSamplesPerChannel, QueueDepth)) {
Serial.println("Failed to start adc right!");
while (1);
}
*/
if (!dacL.begin(AN_RESOLUTION_12, SampleRate)) {
Serial.println("Failed to start dac left!");
while (1);
}
/*
if (!dacR.begin(AN_RESOLUTION_12, 26040)) {
Serial.println("Failed to start dac right!");
while (1);
}
*/
}
// loop
void loop() {
if (adcL.available()) { // if adc available
dacL.write(adcL.read()); // dac read the adc
}
//if (adcR.available()) { // if adc available
//dacR.write(adcR.read()); // dac read the adc
//}
}