For some reason, following code that was modified from PassThroughUSB -example, doesn't function while using queues. How to make it work? Left channel is flooded with unwanted noise, wheras right channel (without queues) is correct audio from PC.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioInputUSB usb1; //xy=200,69 (must set Tools > USB Type to Audio)
AudioOutputI2S i2s1; //xy=365,94
AudioRecordQueue queue1;
AudioPlayQueue queue3;
AudioConnection patchCord1(usb1, 0, queue1, 0);
AudioConnection patchCord3(queue3, 0, i2s1, 0);
AudioConnection patchCord2(usb1, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=302,184
short array1[AUDIO_BLOCK_SAMPLES];
void setup() {
AudioMemory(80);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
}
void loop() {
// INPUT
memcpy(&array1, queue1.readBuffer(), AUDIO_BLOCK_SAMPLES*2);
queue1.freeBuffer();
// OUTPUT
memcpy(queue3.getBuffer(), &array1, AUDIO_BLOCK_SAMPLES*2);
queue3.playBuffer();
}