Teensy 3.2 as USB Sound Card

Status
Not open for further replies.

Revalogics

Well-known member
Hi everyone, this is my first post here in this forum.

Is it possible to use Teensy 3.2 (alone or with some other audio shields) to work as a USB soundcard? I have a USB soundcard but it doesn't work properly in Ubuntu (Linux) [sound input appears glitchy and glitch grows over time]. In Windows 8.1, it works well.

I want a line-in (mic-in but from a physical audio mixer, for recording) and line-out (headphones, for playback) kind of a soundcard and incoming and outgoing sound is sent through USB, and the PC should see the device as a soundcard. I will be using it for realtime purposes like voice processing and live sound synthesis.
 
Yes.

Look at File > Examples > Audio > HardwareTesting > PassThroughUSB and File > Examples > Audio > HardwareTesting > WavFilePlayerUSB.

These require the Tools > USB Type menu in Arduino to be set to Audio.

Yes, it's possible to combine these, and nearly everything else from the Design Tool. The examples all use I2S and the audio shield, but of course you could connect the other (lower quality) inputs or outputs in the design tool if you don't want to use I2S digital audio and a good quality codec.

The USB audio has a known problem with Macintosh. I've recently been communicating with some people at Apple, so there's hope it may get resolved sometime in 2017.

Windows and Linux work great.
 
Oh cool haha :) Thanks Paul, I'll definitely give it a go when I get my own Teensy. Will be testing it with low-latency audio system (Jack) I use in Linux.
 
Oh shoot, I just installed Arduino and Teensyduino in Linux, and I saw its new feature: "Audio". Probably I was using old release of Teensyduino in Windows haha :), will be updating it. Thanks again.
 
Paul, I have a somewhat related question --- At the moment I don't have an audio shield or any other output device, for that matter. I was piping the USB audio from my computer to a FFT256 filter to drive some NeoPixels. I could never get audio out. I replaced the AudioUSB with white noise and things worked. Looking further in the code, could it be the 'update_responsibility' issue? Does audio always get 'pulled' or can it get pushed as well? If so, maybe it be useful to create a SinkSource type filter.

BTW: I like your audio design panel --- reminds me of DirectShow Filter Graphs (which is a good thing).
 
Hi everyone, I finally got my own Teensy, but it's a Teensy 3.6. I already made it to capture sound using built-in ADC and send it to PC (sound was clear, but when nothing is connected (external components are removed), all I got is pink noise). I also tried to send sound from PC to its 2 DACs and it worked flawlessly (with just 12 bits of resolution, the outputs were clear). But when I tried to use USB to DAC and ADC to USB simultaneously, both sounds (incoming and outgoing) are distorted. I tried it using different audio memory, but still distorted.

I guess, I'll just use ADC (stereo) to USB alone, along with some other sketch, and playback will be done with my laptop's on-board headphone jack.

I ran them with a LED blinker code using elapsedMillis and the blinker code did not interfere with audio.

The microcontroller is warm though, running at 180 MHz, and at overclock speeds. 96 MHz and below, the MCU is cool.
 
But when I tried to use USB to DAC and ADC to USB simultaneously, both sounds (incoming and outgoing) are distorted.

This might be a bug in the audio library. Or it could be something about your code. Or it could be an issue with drivers. Most problems are on Mac so far... earlier you mentioned Windows 8.1 but it's not clear to me which system and what software you're using.

If you want me to look into this, you need to post much more info, *ALL* the details to exactly recreate the problem here.


The microcontroller is warm though, running at 180 MHz

Yes, that's normal. The chip does warm up when running at the higher speeds.
 
I'm running Win 8.1 now, here is my test code:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputUSB usb1; //xy=131,207
AudioInputAnalogStereo adcs1; //xy=152,257
AudioOutputAnalogStereo dacs1; //xy=294,202
AudioOutputUSB usb2; //xy=346,250
AudioConnection patchCord1(usb1, 0, dacs1, 0);
AudioConnection patchCord2(usb1, 1, dacs1, 1);
AudioConnection patchCord3(adcs1, 0, usb2, 0);
AudioConnection patchCord4(adcs1, 1, usb2, 1);
// GUItool: end automatically generated code

int pin = 13;
elapsedMillis LED0timer;

void setup() {
AudioMemory(16);
pinMode(pin, OUTPUT);
digitalWrite(pin, 1);
}

void loop() {
if(LED0timer >= 0 && LED0timer <= 500) digitalWrite(pin, 1);
if(LED0timer >= 501 && LED0timer <= 1000) digitalWrite(pin, 0);
if(LED0timer >= 1001) LED0timer = 0;
}

I listened to DACs using a headphone connected to a 33 µF capacitor then to DACs of Teensy 3.6. I tested the ADCs using discrete components based on the schematic in the "Audio System Design Tool" then to music player (cellphone) and then my own hand (as 60 Hz noise source :D).

I used VoiceMeeter Banana (it's just a software audio mixer) to send incoming sound (ADC) to my laptop speaker and route playing music (from Foobar 2000) to outgoing sound (to DACs).

VoiceMeeter Software: https://www.facebook.com/vbaudiosoftware/
Foobar 2000: www.foobar2000.org
 
Status
Not open for further replies.
Back
Top