Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

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

  1. #1
    Junior Member
    Join Date
    Mar 2017
    Posts
    15

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

    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 by Bryan.S; 02-26-2020 at 02:35 PM.

  2. #2
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    125
    You need AudioOutput USB and appropriate connections

  3. #3
    Junior Member
    Join Date
    Mar 2017
    Posts
    15
    oh, ok thanks, much appreciated!

  4. #4
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    125
    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

  5. #5
    Junior Member
    Join Date
    Mar 2017
    Posts
    15
    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.

  6. #6
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    125
    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

  7. #7
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    125
    Not getting the same results here. Audio is being recorded.

    The settings were all at default as well.
    Click image for larger version. 

Name:	A674E14D-F084-43C0-852D-41A627750C27.jpeg 
Views:	13 
Size:	92.5 KB 
ID:	19188
    Click image for larger version. 

Name:	E5B5374C-94CE-44A7-B4B6-1C733D0F969D.jpeg 
Views:	7 
Size:	79.9 KB 
ID:	19189
    Click image for larger version. 

Name:	C749933A-2AE8-4DFB-9F28-37C909F2110A.jpeg 
Views:	12 
Size:	93.8 KB 
ID:	19190

  8. #8
    Junior Member
    Join Date
    Mar 2017
    Posts
    15
    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 by Bryan.S; 02-26-2020 at 11:03 PM.

  9. #9
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    125
    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.

  10. #10
    Junior Member
    Join Date
    Mar 2017
    Posts
    15
    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.

  11. #11
    Junior Member
    Join Date
    Mar 2017
    Posts
    15
    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.

  12. #12
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    125
    Check this control, it lets you change playback speed.

    Click image for larger version. 

Name:	2469DF9A-29BD-4505-92F2-84CA1FA405AC.jpeg 
Views:	6 
Size:	83.1 KB 
ID:	19200

  13. #13
    Junior Member
    Join Date
    Mar 2017
    Posts
    15
    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 by Bryan.S; 02-28-2020 at 12:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •