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

Thread: Need help for getting started with first audio project

  1. #1
    Member
    Join Date
    Jan 2023
    Location
    София
    Posts
    32

    Need help for getting started with first audio project

    Hello, I got my Teensy 4.1 board and experimented a little running display and nice UIs from it, but I have decided to try out some audio.
    I have an Adafruit DAC, type UDA1334A. My goal is to use this DAC with my computer, using the Teensy as a USB audio device.
    The Teensy does get recognized by the computer, but I have no sound output. Here is my code:
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputUSB            usb1;           //xy=560,391
    AudioOutputI2S           i2s1;           //xy=772,392
    AudioConnection          patchCord1(usb1, 0, i2s1, 0);
    AudioConnection          patchCord2(usb1, 1, i2s1, 1);
    // GUItool: end automatically generated code
    
    void setup() {
      AudioMemory(12);
    }
    My wiring:
    https://imgur.com/a/stqtxNP (Sorry for the link, the photos didn't want to upload)

  2. #2
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Did you see the video tutorial on this page?

    Paul

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,714
    There are some limitations on file size and type - screen clip of the linked image as PNG works here
    Click image for larger version. 

Name:	AudioImage.jpg 
Views:	7 
Size:	105.1 KB 
ID:	30105

    There are helpful notes on each item in the right pane like: File > Examples > Audio > HardwareTesting > PassThroughUSB
    This example relies on "AudioControlSGTL5000 sgtl5000_1; " that will cause updates that may be missing as indicated below.

    This note on USB may apply, though maybe i2s1 should qualify?
    Code:
    USB input & output does not cause the Teensy Audio Library to update. At least one non-USB input or output object must be present for the entire library to update properly.
    Though the right pane indicated list doesn't seem to include the AdaF 1334 DAC in use:
    Code:
    Compatible DAC Chips:
    
    PCM5102A
    PCM1808
    PCM5242
    CS4344

  4. #4
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    The Adafruit UDA1334A does work with the audio library, see this page.

    Paul

  5. #5
    Member
    Join Date
    Jan 2023
    Location
    София
    Posts
    32
    Hello, I got it working. I used an example to create a sine wave and it works just fine, I can hear the sine wave on the output clearly and adjust its frequency with the potentiometer I have connected, the issue here is the USB.

  6. #6
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Quote Originally Posted by Windorey View Post
    the issue here is the USB.
    If you want your setup to be recognized as a USB audio device for your computer, you need to set the USB type to "Audio":

    Click image for larger version. 

Name:	Untitled.png 
Views:	1 
Size:	43.1 KB 
ID:	30107

    Then this code will do the trick:
    Code:
    // set Tools > USB Type: to "Audio"
    
    #include <Audio.h>
    
    AudioInputUSB            usb1;   
    AudioOutputI2S           i2s1;      
    AudioConnection          patchCord1(usb1, 0, i2s1, 0);
    AudioConnection          patchCord2(usb1, 1, i2s1, 1);
    
    void setup(){
      AudioMemory(12);
    }
    
    void loop(){
    }
    Paul

  7. #7
    Member
    Join Date
    Jan 2023
    Location
    София
    Posts
    32
    This is exactly what I'm doing, but there is no sound output

  8. #8
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Did you tell Windows or Mac to use the Teensy audio device instead of the default audio device?

    Paul

  9. #9
    Member
    Join Date
    Jan 2023
    Location
    София
    Posts
    32
    I did, yes.

  10. #10
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    That is strange. Hooked up a UDA1334A board to a Teensy 4.1:

    Click image for larger version. 

Name:	T41plusUDA1334A.jpg 
Views:	9 
Size:	58.4 KB 
ID:	30110

    and uploaded this code:
    Code:
    // UDA1334A bd  Teensy 4.x
    // VIN          3V3           
    // GND          GND          
    // WSEL         20                  
    // DIN          7 
    // BCLK         21             
    // set Tools > USB Type: to "Audio"
    
    #include <Audio.h>
    
    AudioInputUSB            usb1;   
    AudioOutputI2S           i2s1;      
    AudioConnection          patchCord1(usb1, 0, i2s1, 0);
    AudioConnection          patchCord2(usb1, 1, i2s1, 1);
    
    void setup(){
      AudioMemory(12);
    }
    
    void loop(){
    }
    Set my PC to use the Teensy audio device:

    Click image for larger version. 

Name:	Untitled.png 
Views:	3 
Size:	19.1 KB 
ID:	30111

    Sound is playing on my speakers as I'm writing this message...

    Could you show me your setup? Please doublecheck the wiring.

    Paul

  11. #11
    Member
    Join Date
    Jan 2023
    Location
    София
    Posts
    32
    It turns out it's from the wiring.
    The connections weren't making a good contact, I switched to a new breadboard, new wires and it started working correctly without holding it.
    Also, if you know, for me there is a popping sound every-so-often while using this. Is there any way to eliminate that popping?

  12. #12
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Good to hear it's working now!
    About the popping sound - this not something I heard before and should not be there. Could it be the amplifier your using?
    You could try to power the UDA1334A board from the 3V3 Teensy pin like I did. Although I doubt whether that will avoid the every-so-often popping sound.

    Paul

Posting Permissions

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