I've started adapting and merging MickMad's code into the core library. Still a work in progress, but this is finally moving forward to becoming a fully supported feature on Teensy and the audio lib.
@Paul, how are we going to handle the different size of packets for Isochronous endpoints?
I'm working on that right now... a lot of #ifdef AUDIO_INTERFACE
The packet received may be larger than the negotiated MaxPacket size. Typically, this is caused by a software bug. For DMA overrun errors due to oversized data packets, the USB specification is ambiguous. It assumes correct software drivers on both sides. NAKing the packet can result in retransmission of the already oversized packet data. Therefore, in response to oversized packets, the USB core continues ACKing the packet for non-isochronous transfers.
// Feature Descriptor (Table 4.7, p. 43, USB Device Class Definition for Audio Data Formats 2.0)
0x0A, // bLength
0x24, // bDescriptorType = CS_INTERFACE
0x06, // bDescriptorSubtype = FEATURE_UNIT
0x31, // bUnitID
0x30, // bSourceID
0x01, // bControlSize
0x03, // bmaControls(0) (MASTER, VOL)
0x03, // bmaControls(1) Left
0x03, // bmaControls(2) Right
0x00, // iFeature
// Output Terminal Descriptor (Table 4.9, p.53, USB Device Class Definition for Audio Devices 2.0)
0x09, // bLength
0x24, // bDescriptorType = CS_INTERFACE
0x03, // bDescriptorSubtype = OUTPUT_TERMINAL
0x40, // bTerminalID = OUTPUT_TERMINAL_ID
0x02, 0x03, // wTerminalType = HEADPHONES
0x00, // bAssocTerminal
//0x30, // bCSourceID = INPUT_TERMINAL_ID
0x31, // bCSourceID = FEATURE UNIT_ID
0x00, // iTerminal
#include <Audio.h>
AudioInputUSB usb1; //xy=200,69
AudioOutputI2S i2s1; //xy=365,94
AudioConnection patchCord1(usb1, 0, i2s1, 0);
AudioConnection patchCord2(usb1, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=302,184
// the setup routine runs once when you press reset:
void setup() {
AudioMemory(12);
Serial1.begin(115200);
Serial1.println("*********************");
sgtl5000_1.enable();
sgtl5000_1.volume(0.75);
}
int count=0;
// the loop routine runs over and over again forever:
void loop() {
Serial.println(count++);
delay(500); // wait for a second
}
#include <Audio.h>
#include <SD.h>
AudioPlaySdWav playWav1;
AudioOutputUSB audioOutput;
AudioOutputAnalog dac;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
// Use these with the audio adaptor board
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
void setup() {
Serial.begin(9600);
Serial1.begin(115200);
Serial1.println("=======================");
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(20);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
}
void playFile(const char *filename)
{
Serial1.print("Playing file: ");
Serial1.println(filename);
playWav1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
while (playWav1.isPlaying()) {
}
}
void loop() {
playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format
delay(500);
playFile("SDTEST2.WAV");
delay(500);
playFile("SDTEST3.WAV");
delay(500);
playFile("SDTEST4.WAV");
delay(1500);
}
teensy31.menu.usb.audio=Audio
teensy31.menu.usb.audio.build.usbtype=USB_AUDIO
teensy31.menu.usb.audio.fake_serial=teensy_gateway
#define PRODUCT_ID 0x0485
Das E/A-Gerät ist falsch konfiguriert, oder die Konfigurationsparameter für den Treiber sind falsch.
C0000182
#include <Audio.h>
AudioInputUSB usb1; //xy=200,69
AudioMixer4 mixer1; //xy=324,161
AudioOutputAnalog dac1; //xy=365,94
AudioConnection patchCord1(usb1, 0, mixer1, 0);
AudioConnection patchCord2(usb1, 1, mixer1, 1);
AudioConnection patchCord3(mixer1, dac1);
#define PROP_AMP_ENABLE 5
// the setup routine runs once when you press reset:
void setup() {
//Start Amplifier
pinMode(PROP_AMP_ENABLE, OUTPUT);
digitalWrite(PROP_AMP_ENABLE, HIGH);
AudioMemory(12);
Serial1.begin(115200);
Serial1.println("*********************");
}
int count=0;
// the loop routine runs over and over again forever:
void loop() {
Serial.println(count++);
delay(500); // wait for a second
}
Works !!!
To use it with the prop-shield:
Code:#include <Audio.h> AudioInputUSB usb1; //xy=200,69 AudioMixer4 mixer1; //xy=324,161 AudioOutputAnalog dac1; //xy=365,94 AudioConnection patchCord1(usb1, 0, mixer1, 0); AudioConnection patchCord2(usb1, 1, mixer1, 1); AudioConnection patchCord3(mixer1, dac1);
The main problem on Mac was not transmitting (silence) on the unused input endpoint when it's enabled. Apparently Apple expects data to be arriving if it's enabled the input endpoint, and even if you're not using it, OSX refuses to send to the output endpoint. Seems strange, but it's true.
If anyone has good sound setup with Windows, please give this a try. Windows is the system I use the least, so I really depend on help finding Windows issues.
#include <Audio.h>
AudioSynthWaveformSine wav1;
AudioOutputUSB audioOutput;
AudioConnection patchCord5(wav1, 0, audioOutput, 0);
AudioInputUSB usbin;
AudioOutputI2S out1;
AudioConnection patchCord1(usbin, 0, out1, 0);
AudioConnection patchCord2(usbin, 1, out1, 1);
AudioControlSGTL5000 sgtl5000_1;
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
AudioMemory(12);
pinMode(led, OUTPUT);
wav1.frequency(220);
wav1.amplitude(1);
sgtl5000_1.enable();
sgtl5000_1.volume(0.50);
}
int count=0;
int ledon = 0;
// the loop routine runs over and over again forever:
void loop() {
ledon ^= 1; // flip bit
digitalWrite(led, ledon);
delay(500);
}
Isn't is possible to use pin 14 for the prop shield ? Ok, requires a short wire instead of a header pin.. but that should'nt be a problem.
Perhaps Paul can add a jumper for a future "REV 2" of the prop-shield ?