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

Thread: Teensy 4.1 usb audio out. How?

  1. #1

    Teensy 4.1 usb audio out. How?

    I try to get my Teensy 4.1 to output audio to usb.

    The following code doesn't work. Teensy appears as usb audio device on MacOS, but I can't hear any white noise when I select it's input.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    //#include <SPI.h>
    //#include <SD.h>
    //#include <SerialFlash.h>
    
    AudioSynthNoiseWhite     noise1;         //xy=164,557AudioOutputUSB
    AudioOutputUSB           usb1;           //xy=370,519 
    AudioConnection          patchCord1(noise1, 0, usb1, 0);
    AudioConnection          patchCord2(noise1, 0, usb1, 1);
    
    // GUItool: end automatically generated code
     
    //used to blink the led to show that something is happening
    int led=13;
    
    void setup() {
      AudioMemory(80);
    
    
    delay(500);
      pinMode(led, OUTPUT);     
    }
    
    void loop() {
    
    }

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,042
    You need to include at least one audio object that generates a clock, for instance AudioInputI2S or AudioOutputI2S.
    Without a clocked object nothing ever happens.

  3. #3
    Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    61
    Also, as I found out last night, you need to set the noise generator going by setting its amplitude to a non-zero value...

  4. #4
    thanks. I got it working. I think it would make sense to include a example in teensyduino.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,259
    Quote Originally Posted by flocked View Post
    I think it would make sense to include a example in teensyduino.
    File > Examples > Audio > HardwareTesting > WavFilePlayerUSB

  6. #6
    Ah perfect. I was searching for it. Maybe rename it it to WavFilePlayerUSBOutput?

Posting Permissions

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