Hi!
I've ran into a bug in the Teensy audio library when playing audio over USB.
Apparently "AudioOutputUSB" only works when there is also a different audio output (like AudioOutputAnalog) present in the sketch.
The following code should send a sound over USB but it only works when AudioOutputAnalog is uncommented.
My best guess is that there is some optimization going on that checks whether there actually is an audio output available before it processes any sounds but doesn't take in account AudioOutputUSB.
I've ran into a bug in the Teensy audio library when playing audio over USB.
Apparently "AudioOutputUSB" only works when there is also a different audio output (like AudioOutputAnalog) present in the sketch.
The following code should send a sound over USB but it only works when AudioOutputAnalog is uncommented.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioSynthWaveformSine sine1;
//AudioOutputAnalog dac1;
AudioOutputUSB usb1;
AudioConnection patchCord1(sine1, 0, usb1, 0);
AudioConnection patchCord2(sine1, 0, usb1, 1);
void setup() {
AudioMemory(15);
sine1.amplitude(0.2);
sine1.frequency(500);
}
void loop() {
}
My best guess is that there is some optimization going on that checks whether there actually is an audio output available before it processes any sounds but doesn't take in account AudioOutputUSB.