Using USB Audio Input Module

Status
Not open for further replies.

jshooks

Well-known member
Just wanted to know if anyone has used the USB Audio Interface block from the Audio Design Tool for playing music. I have an application where I need to switch between audio line in, playSDWave and (hopefully) USB inputs for FFT processing. The 1st two selections are not be a problem, but don't know if you can use the Mixer blocks in the attached design diagram for the USB block. I'm not sure if the port is a serial or I2S1 bus. The assumption (unless I am misunderstanding) here is the "USB" input port is really a USB-to-serial port on the Teensy 3.x. as the instructions state to set the USB Type to Audio under the Tools menu in Arduino IDE. This would then have to be the Teensy programming/monitor port (Serial1). Is there is any sample code for playing the USB data steam. I would appreciate any help on this.
 

Attachments

  • Audio Mixer Config.PNG
    Audio Mixer Config.PNG
    20 KB · Views: 302
I need to switch between audio line in, playSDWave and (hopefully) USB inputs for FFT processing .... but don't know if you can use the Mixer blocks in the attached design diagram for the USB block.

Sure you can. Just set the channels to gain = 1.0 to let the signal through, or gain = 0 to turn it off. The data from the USB is no different than any other audio.

I'm not sure if the port is a serial or I2S1 bus. The assumption (unless I am misunderstanding) here is the "USB" input port is really a USB-to-serial port on the Teensy 3.x. as the instructions state to set the USB Type to Audio under the Tools menu in Arduino IDE. This would then have to be the Teensy programming/monitor port (Serial1).

Not sure I fully understand this question.

I can tell you setting Tools > USB Type to Audio causes Teensy to become a USB sound card. From your PC's point of view, it pretty much the same as if you have something like this:

usbsound.jpg

However, Teensy actually implement a multi-function device with audio and a HID interface with emulates serial. So you can still use Serial.print() and have it show up in the Arduino Serial Monitor. With Teensyduino 1.42, the Tools > Ports menu was redesigned so it is aware of these non-serial types, so you can select them and use them the same way as ordinary serial.

There's also a Tools > USB Type option for Audio + MIDI + Serial. In that case it implements serial (shows up as a /dev/tty or COM port on your PC) and also audio. USB is pretty awesome like that, where 1 device can have many interfaces, so it shows up as a multi-function device to your PC.


Is there is any sample code for playing the USB data steam.

Yes. Just click File > Examples > Audio > HardwareTesting > PassThroughUSB. When this is running, use your PC's sound control panel to select Teensy Audio as your output device. Then play music on your PC and it will stream out to the Teensy and be played through the audio shield.

The USB audio supports both input and output, even both simultaneously. If you have input or synthesis of audio, you can send it to the USB output and your PC will see it as a microphone. If you select it in the sound control panel, your PC will use that as its sound input.
 
Thanks Paul, that is great news! I wish I had discovered this info a while ago, but I obviously didn't ask the right questions.

Now the big question is, can you plug a USB memory stick into the Teensy USB/serial port and play recorded songs through the Audio Shield or does it only work directly from a PC? If you can, I assume the format could be Meg3 if using the correct audio player library like the one Frank B has posted. Also, it would be great if you could somehow save the imported songs to the SD card in Meg3 format as they would take less storage space than wave files. That may be asking to much for the Teensy 3.2, but maybe the 3.6 with more buffer memory. From what I have been reading on the forums, the SD card can cause delays in writing/reading without enough cache memory.
 
Now the big question is, can you plug a USB memory stick into the Teensy USB/serial port and play recorded songs through the Audio Shield

Nope, sorry, USB memory sticks aren't supported yet. Someday they will be for Teensy 3.6 (and future boards), but 3.5 & earlier lack a USB host port to plug in USB devices. Today 3.6 is the only Teensy with USB host.

You can play WAV & MP3 (with Frank's lib) from SD cards.
 
Status
Not open for further replies.
Back
Top