PC Audacity recording of teensy & audio shield as USB audio device not working

Status
Not open for further replies.

Bryan.S

Member
I see others are able to use Audacity on a PC for recording audio from the Teensy/audio shield but it is not working for me. I can see the teensy as a USB audio device and select it for input and output in audacity but when either monitoring it or trying to record there is no audio signal present. I can go to youtube and play a video and hear it on the audio shields headphone connection. That works fine, but seems the audio does not get to the PC for recording. I also mixed in the microphone on the audio shield and that does not produce any audio to the PC either. Teensy is selected as my audio input recording device and playback device in windows audio settings. Audacity does work if I use stereomix as an input, but not the teensy if I try to record a YouTube video's audio.
I am using a teensy 3.2 and audio shield on a windows 10 laptop. Also, I have a octows2811 board hooked up to the teensy but it isn't being used yet.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>


// GUItool: begin automatically generated code
AudioInputI2S            i2s2;           //xy=121,318
AudioInputUSB            usb1;           //xy=122,247
AudioMixer4              mixer2;         //xy=271,331
AudioMixer4              mixer1;         //xy=274,262
AudioOutputI2S           i2s1;           //xy=463,295
AudioConnection          patchCord1(i2s2, 0, mixer1, 1);
AudioConnection          patchCord2(i2s2, 1, mixer2, 1);
AudioConnection          patchCord3(usb1, 0, mixer1, 0);
AudioConnection          patchCord4(usb1, 1, mixer2, 0);
AudioConnection          patchCord5(mixer2, 0, i2s1, 1);
AudioConnection          patchCord6(mixer1, 0, i2s1, 0);
AudioControlSGTL5000     sgtl5000_1;     //xy=273,457
// GUItool: end automatically generated code


void setup() {                
  AudioMemory(12);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
  sgtl5000_1.micGain(35);
  mixer1.gain(0, .8);
  mixer1.gain(1, .8);
  mixer2.gain(0, .8);
  mixer2.gain(1, .8);
}

void loop() {
  // read the PC's volume setting
  float vol = usb1.volume();

  // scale to a nice range (not too loud)
  // and adjust the audio shield output volume
  if (vol > 0) {
    // scale 0 = 1.0 range to:
    //  0.3 = almost silent
    //  0.8 = really loud
    vol = 0.3 + vol * 0.5;
  }

  // use the scaled volume setting.  Delete this for fixed volume.
  sgtl5000_1.volume(vol);

  delay(1000);
}
 
Last edited:
FYI, splitting outputs is fine so you can

Code:
AudioOutputUSB USBOut;

AudioConnection patchCordUSBoutL ( mixer1, 0, USBOut , 0);
AudioConnection patchCordUSBoutR (mixer2, 0, USBOut, 1);

Naming them however you wish
 
This worked kind of, I can hear audio perfectly out of the Laptops headphone output now as the teensy is now sending out USB audio. But, in audacity all I get when trying to record is just random noise spikes when selecting the teensy as input. Recording was at 48khz and I switch to 44.1 khz and still just noise spikes. The spikes to seem to correspond with the audio a little bit. Monitoring the teensy's input on audacity's bargraph shows a pretty good signal strength although some significant lag from the audio input.
 
Got nothing but wild punches for you. The fact that you hear audio "perfectly" out of the laptop headphones says the Teensy is doing the job, the problem at this point is how the computer and Audacity are interacting.

Since you're using Windows you can look and see if Audacity has any buffering or latency controls and try adjusting those. You can try disabling duplex operation as well.

I do have Audacity on a windows machine, Ill see if I can reproduce yr trouble
 
Not getting the same results here. Audio is being recorded.

The settings were all at default as well.
A674E14D-F084-43C0-852D-41A627750C27.jpeg
E5B5374C-94CE-44A7-B4B6-1C733D0F969D.jpeg
C749933A-2AE8-4DFB-9F28-37C909F2110A.jpeg
 
Well thought I had it for a second but I had steromix on instead of the teensy. Still doing the same even after setting it up like you have.
Going to try my other DAW software and see what happens.
 
Last edited:
Referring to your redacted reply , not sure how line or mic input should matter since you're looping USB through the teensy.

I selected line in because there's no mic hardware soldered to my audio shield.

I also tried recording a YouTube video instead of a signal through line in and that worked over here as well.

The "interface " setting in Audacity could matter for you, try the different choices. By default my system is selecting MME. You can try increasing the buffer, and reducing the latency compensation.
 
Yeah, thought I had it working but turned out I had stereo Mix as input. Duh! Absolutely no audio at all into audacity, adobe Audition, or cakewalk studio. But plays through my laptop's headphones. I noticed also if you have the Teensy monitor your PC's volume in a loop say every second and adjusts the volume out it produces clicks I am hearing in my headphones when no audio is being played. One click every second. hardcoded the volume level and no more clicking noise.
Any way I stripped it all down, no mixers, no line in, just USB in and USB out audio, still not recording anything in any program I use. I have other USB audio devices I just such
as a Native Instruments Komplete Audio 6, and a Boss GT-1 Guitar effects pedal. Both work as USB input and output devices I use for recording. Thought I would try using the teensy with the audio shield to make a more portable audio device for recording a guitar and have in mixed in with musical backing tracks on youtube. Other option would be to put backing tracks on an SD card and mix it with a guitar input Battery operated. Anyways I'm going to try this on another computer later tonight I think and see what happens.Will let you know how it turns out.
 
So, I finally got it working, Teensy needs to be selected as the playback device when you click the speaker icon on the taskbar. Setting it in the audio software I think won't work until it is set in the task bar. I think that is what fixed it for me. I thought I had set that in windows audio settings and that would take care of it, but it didn't. Anyways it is working and I can record but with one other problem. The audio is compressed in time when I play it back. The one song I recorded the singer almost sounds like a chipmonk singing (pitch change). Not sure what it causing that now. Looks like this is gonna take some experimenting to get everything working right.
 
Think maybe I didn't have the sample rate correct in Audacity. Audacity was at 48k and the teensy was 44.1k when I did the recording. I'll have to try it again tonight. I already knew about the playback speed thing but it only is temporary when playing.

Just recorded another song and it came out just fine. So, I did not have the correct sample rate before.

Thanks again for your help....
 
Last edited:
Status
Not open for further replies.
Back
Top