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

Thread: Playing RAW/WAV from SD Card via I2S

  1. #1
    Junior Member weeky's Avatar
    Join Date
    Aug 2016
    Location
    Berlin, Germany
    Posts
    14

    Playing RAW/WAV from SD Card via I2S

    Hi,
    I'm new on this forum and quite new in the topic of teensy. For a small project I need to be able to play some short sound files. I used a WTV020 board in combination with a simple 2.5 Watt Mono Amp from Adafruit and it worked...okay. The sound module does not work that great and I get a lot of click and pop and some annoying beep noises produced by the sound module.

    Now I want to take this project a step further and need the power of a teensy and I thought I might as well use it's capability to output I2S sound. Unfortunately the enclosure is not big enough for the Audio Adaptor. So my question is:

    Can I use the simple SD Card Adaptor for the Teensy, read the sound files and output them via I2S to an Adafruit MAX98357A I2S Amplifier? Will this reduce the produced noise (no ground loops)? Or will it be better to use a Teensy Prop Shield in combination with the SD Card Adaptor and Output the sound via it's internal amplifier (then I could use the flash memory for short sounds which need to be played immediately?)?

    Best Regards

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by weeky View Post
    Hi,
    I'm new on this forum and quite new in the topic of teensy. For a small project I need to be able to play some short sound files. I used a WTV020 board in combination with a simple 2.5 Watt Mono Amp from Adafruit and it worked...okay. The sound module does not work that great and I get a lot of click and pop and some annoying beep noises produced by the sound module.

    Now I want to take this project a step further and need the power of a teensy and I thought I might as well use it's capability to output I2S sound. Unfortunately the enclosure is not big enough for the Audio Adaptor. So my question is:

    Can I use the simple SD Card Adaptor for the Teensy, read the sound files and output them via I2S to an Adafruit MAX98357A I2S Amplifier? Will this reduce the produced noise (no ground loops)? Or will it be better to use a Teensy Prop Shield in combination with the SD Card Adaptor and Output the sound via it's internal amplifier (then I could use the flash memory for short sounds which need to be played immediately?)?

    Best Regards
    I just ordered this board. Let's see if we can bring it to work. Worst case we have to adjust some things in I2S output

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    A question, what are these soundfiles, how long are they (in seconds) ?
    If they are very short, it might be possible to convert them to AAC (which makes them even smaller) and store them in the teensy-flash..?

  4. #4
    Junior Member weeky's Avatar
    Join Date
    Aug 2016
    Location
    Berlin, Germany
    Posts
    14
    Some of them are bigger (200-300kByte), some of them smaller, but they are a few. So I don't think storing them in the flash would work.

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Don't under-estimate the compression of aac.. and since that board is mono, reducing them to one channel helps even more.

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    But , of course, the prop-shield will work , too. you can store the sounds in the prop-shield flash - which means you don't need the sd-card.

  7. #7
    Junior Member weeky's Avatar
    Join Date
    Aug 2016
    Location
    Berlin, Germany
    Posts
    14
    Well, that might work for a few I guess. But I'm planning to extend that project, so I guess I will need the storage space of a SD card. But just for clarity, in theory playing raw or wav from a sd card to output them on the teensy in I2S format to an external device works, and is not a unique feature of the audio adaptor?

  8. #8
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    No, no unique feature of the audio adaptor.
    But, maybe, we have to adjust the output-I2S-format a bit. There is no "standard" I2S, and some chips need adjustments.
    At a first glance (took a quick look to the datasheet), we might have luck and it works out of the box. maybe.

  9. #9
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,273
    Note, I suspect the prop shield may have problems with i2s.

    As I read the pin layouts, i2s uses pin 9 for BCLK, pin 11 for MCLK, pin 13 for RXD0, pin 22/A8 for TXD0, pin 23/A9 for LCRLK.

    The audio shield which uses i2s, has to use the alternate pin 7 for SPI MOSI (normally pin 11) and alternate pin 14 for SPI SCLK (normally pin 13). I don't believe that i2s has alternate pins for the Teensy 3.1/3.2.

    The prop shield does not allow the use of the alternate SPI pins, and uses pin 7 for LED enable.

    The forthcoming Teensy 3.5/3.6 will have other alternate pins for i2s.

  10. #10
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    lol, yes of course. The prop-shield uses the DAC-Output.
    Should'nt matter after the amplifier..

  11. #11
    Junior Member weeky's Avatar
    Join Date
    Aug 2016
    Location
    Berlin, Germany
    Posts
    14
    Well, that's not too bad, I guess I have to use a sd card anyway. Frank I'm very interested in your project using the same hardware as I'm planning to use. Glad to hear that it is no unique feature of the adio adaptor. Just out of curiosity, the way I understood is that the teensy sends the audio via I2S to the audio adaptor which processes it? So I could theoretically simply take the signal on the I2S pins and process them in the external device e.g. a digital amplifier? But the audio adaptor does not fit anyway.

  12. #12
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Yes, you can use I2S DACs - as noted above, some use slightly different data-formats.
    Recently, Ben & I added support for the PT8211, a very small and very cheap stereo dac https://forum.pjrc.com/threads/29284...l=1#post109025

    edit: i don't know anything about your project - perhaps SPDIF is an option, too ?
    Last edited by Frank B; 08-03-2016 at 08:03 PM.

  13. #13
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    My Adafruit MAX98357A arrives tomorrow (hopefully: I'll be not @home..)
    I'll test it as soon I have it.

  14. #14
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by Frank B View Post
    My Adafruit MAX98357A arrives tomorrow (hopefully: I'll be not @home..)
    I'll test it as soon I have it.
    Ok...that was boring...no fun...

    It workes out of the box, flawlessly, and without any problems...
    Last edited by Frank B; 08-05-2016 at 03:06 PM.

  15. #15
    Junior Member VoltVisionFrenchy's Avatar
    Join Date
    Feb 2013
    Location
    Warren, PA
    Posts
    13
    Frank,
    I just received my new T3.5 and T3.6 and I am ready to start diving into I2S audio for the first time. I have the same Adafruit MAX98357A breakout sitting here that I would like to try.
    1) Do you think my Picoscope2203 (analog bandwidth = 5MHz max) is up to the task of I2S debugging? What bandwidth scope do you use?
    2) I am looking at the PJRC audio library gui (http://www.pjrc.com/teensy/gui) and I notice that the control section does not include the MAX98357A. Do you use the GUI? Did you get the MAX98357A working with some other example code?

    I hope to run through Paul's audio workshop this weekend:
    https://hackaday.io/project/8292-mic...-supercon-2015

    Thanks!
    frenchy (Steve French)
    www.voltvision.com

  16. #16
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by VoltVisionFrenchy View Post
    Frank,
    I just received my new T3.5 and T3.6 and I am ready to start diving into I2S audio for the first time. I have the same Adafruit MAX98357A breakout sitting here that I would like to try.
    1) Do you think my Picoscope2203 (analog bandwidth = 5MHz max) is up to the task of I2S debugging? What bandwidth scope do you use?
    2) I am looking at the PJRC audio library gui (http://www.pjrc.com/teensy/gui) and I notice that the control section does not include the MAX98357A. Do you use the GUI? Did you get the MAX98357A working with some other example code?

    I hope to run through Paul's audio workshop this weekend:
    https://hackaday.io/project/8292-mic...-supercon-2015

    Thanks!
    frenchy (Steve French)
    www.voltvision.com

    Hi, Steve,

    1) 5MHz is way too slow. The clock signal is more than double speed.. i guess you need minimum 25MHz, better more. I don't own a scope, and use a Salae Logic Analyzer (100MHz) instead.
    But, good news: No need to debug anything these days.. I2S "just works" :-)

    Edit: for <=192MHz !. My Teensy 3.6 has problems with I2S on higher overclocking.

    2) Yes, use the Audio-Library and simply add the I2S-Object (but not the SGTL5000 control). That's all to do.

    Have fun
    Frank
    Last edited by Frank B; 10-07-2016 at 03:25 PM.

Posting Permissions

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