Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 30

Thread: SD Card Audio Player

  1. #1
    Senior Member
    Join Date
    May 2013
    Posts
    115

    Teensy SD Card Audio Player

    I'm building a SD Card Hifi Audio player to replace my CD player. I already own a SD Card audio player from China, but it doesn't work properly so I decided to build my own.

    In this thread I'll try to post my progress.

    The first screenshot is the result of my very first test with a Teensy 3.0 connected to a SD card reader, which I bought on AliExpress or eBay. It displays the FLAC files on the card. I used the SDFat Arduino library.

    Click image for larger version. 

Name:	sdcardinfo.png 
Views:	37 
Size:	63.0 KB 
ID:	24647
    Last edited by bigpilot; 04-29-2021 at 06:32 PM.

  2. #2
    Senior Member
    Join Date
    May 2013
    Posts
    115
    Click image for larger version. 

Name:	enclosure.jpg 
Views:	43 
Size:	50.8 KB 
ID:	24652

    I'm also trying to make a visual representation of what the audio player will look like using Blender. The dimensions are exactly to scale, based on the enclosure and LCD display I purchased from AliExpress.

  3. #3
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,090
    You may be in for a tough slog with a Teensy 3.0. IIRC, the 3.0 did not have I2S support or DAC support, so it may be hard to play sounds. You might be able to emit low grade sounds by using one of the PWM pins and some capacitors and use an amplifier and speaker.

    There are 2 main methods for producing sounds on Teensys:
    • I2S -- which is a standard sound system that takes several fixed pins. By default I2S has stereo input and output. There are ways to extend this to quad outputs and above on some platforms;
    • DAC -- this is one or two pins that you can vary the voltage on the pin. You can hook this up to an amplified speaker to produce sound. I2S tends to be better quality, but DAC pins if your board has them are cheaper.


    In terms of Teensy, the sound support is:
    • Teensy 3.0: No sound support as far as I am aware of.
    • Teensy 3.1 and 3.2: I2S support and a single DAC pin. Note, you need to change the SPI pins if you use I2S on Teensy 3.1 and 3.2.
    • Teensy 3.5 and 3.6: I2S support and a pair of DAC pins. Note, you need to change the SPI pins if you use I2S on Teensy 3.5 and 3.6.
    • Teensy LC: It has a single DAC pin. It has simplified I2S support, but parts of the audio library won't run because the processor doesn't support all of the instructions needed.
    • Teensy 4.0 and 4.1 has 2 separate I2S units. Unlike the 3.x, the SPI pins are not remapped. Neither the 4.0 or the 4.1 have any DACs. The 4.0/4.1 also have hardware S/PDIF support.


    If you use the Teensy Audio adapter, versions A-C are for Teensy 3.1, 3.2, 3.5, and 3.6. Version D is for the Teensy 4.0 and 4.1.

    The simplest approach with a Teensy 3.2 is to use the DAC and use a mono speaker with an amplifier. You can buy the speaker and amplifier separately, or you can use a combination unit.


    You can get standalone I2S boards as well. Here is a mono output board that combines I2S and an amplifier for Teensy 3.2 and above. You would need to add a speaker:


    Here is a unit that does stereo. It has a headphone jack that you can plug into directly, or you can plug in a stereo amplifier and two speakers;


    Here is the page for the Teensy audio adapter:


    Finally there are two versions of the prop shield, one with motion sensors, and one without. The prop shield includes a mono amplifier attached to the 3.2's DAC pin, so all you would need to add is a speaker. In addition, the prop shield has a built-in 8 megabyte of flash memory to hold songs. Right now it is a little inconvenient to load songs onto this flash memory, but it is hoped Teensydunio 1.54 or 1.55 will make things easier. For playing sounds, the prop shield should be mated with the 3.2.

  4. #4
    Senior Member
    Join Date
    May 2013
    Posts
    115
    I've switched to Teensy 3.1 as the Audio Codecs package didn't work with it. I even posted a question about it on Github.

    It now compiles without a hitch and I should have it up and running pretty soon.

    Stay tuned.

  5. #5
    Senior Member
    Join Date
    May 2013
    Posts
    115
    The enclosure I'm using is from AliExpress. The enclosure itself is pretty cheap but the shipping hugely expensive.

    I'm using this DAC board with a Burr-Brown PCM5102 D/A converter and an I2S input.
    Last edited by bigpilot; 04-30-2021 at 09:43 AM.

  6. #6
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    The enclosure itself is pretty cheap but the shipping hugely expensive.
    Box on Banggood 26.43 with free shipping, 12.45 with free shipping from Amazon.

  7. #7
    Senior Member
    Join Date
    May 2013
    Posts
    115
    Quote Originally Posted by BriComp View Post
    Box on Banggood 26.43 with free shipping, 12.45 with free shipping from Amazon.
    The exact same one? Could you provide some links?

  8. #8
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    Banggood..but now charging a little bit for shipping
    Amazon
    The Amazon one was difficult to find again, it depended upon which part of the AliExpress description I used.
    I am watching your project, I might be interested in replicating something similar.

  9. #9
    Senior Member
    Join Date
    May 2013
    Posts
    115
    Click image for larger version. 

Name:	audio_player.png 
Views:	51 
Size:	531.7 KB 
ID:	24660

    First picture of my proto-board setup. Teensy 3.1 + DAC + SD Card breaout.

  10. #10
    Senior Member
    Join Date
    May 2013
    Posts
    115
    The SD Card breakout module can be found here.
    Last edited by bigpilot; 04-30-2021 at 05:19 PM.

  11. #11
    Senior Member
    Join Date
    May 2013
    Posts
    115
    I'm planning to add a LCD display and an IR remote control detector.

    Most likely the player will not have any buttons on the front panel since I don't think I'll have enough I/O pins left on the Teensy 3.1 I'm using.
    Last edited by bigpilot; 04-30-2021 at 06:15 PM.

  12. #12
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    If you can squeeze in I2C then this gives you loads of I/O and an automatic keyboard scanner.

    The chip select for the SD card could come from the I2C breakout/expander thereby giving you one 3.1/3.2 pin back for I2C.

  13. #13
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,090
    Quote Originally Posted by bigpilot View Post
    I'm planning to add a LCD display and an IR remote control detector.

    Most likely the player will not have any buttons on the front panel since I don't think I'll have enough I/O pins left on the Teensy 3.1 I'm using.
    It depends on what display you are using, etc. If you go with an I2C display, you just need pins 18 and 19, and you can hook up extenders that allow reading 8 or 16 buttons separately. I2C is a bus, and each device has an address. As long as you don't have the same address, you can hook up several devices on the I2C bus. Now, I2C tends to be slower than SPI, so it is a tradeoff in terms of pins and speed:


    Here is a 16 pin MCP23017 extender that you can use either for digital inputs or outputs:


    Alternatively on the 3.1/3.2, there are 10 pads underneath the Teensy that you can solder wires to bring out the extra pins (plus 2 analog input only pads, and 3.3v/ground).

  14. #14
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    The advantage of the SX1509 (which is I2C) is that you can use some or all of the 16 I/O pins as a keypad scanner. The great thing about this chip is that it will do all the keyboard scanning by itself and tell you when a key has been pressed. Some of the I/O can be dedicated to the keypad whilst the remaining is available for general I/O.

  15. #15
    Senior Member
    Join Date
    May 2013
    Posts
    115
    Nice, I may use the SX1509 breakout board from SparkFun.

  16. #16
    Senior Member
    Join Date
    May 2013
    Posts
    115
    Quote Originally Posted by MichaelMeissner View Post
    It depends on what display you are using, etc. If you go with an I2C display, you just need pins 18 and 19, and you can hook up extenders that allow reading 8 or 16 buttons separately. I2C is a bus, and each device has an address. As long as you don't have the same address, you can hook up several devices on the I2C bus. Now, I2C tends to be slower than SPI, so it is a tradeoff in terms of pins and speed:


    Here is a 16 pin MCP23017 extender that you can use either for digital inputs or outputs:


    Alternatively on the 3.1/3.2, there are 10 pads underneath the Teensy that you can solder wires to bring out the extra pins (plus 2 analog input only pads, and 3.3v/ground).

    I was planning to use a large 2 x 16 LCD with HD44780 controller in 4-bit configuration (so I'd need 7 I/O's).

  17. #17
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    If you simply need 2x16 these can be found with i2c drive as well.

  18. #18
    Senior Member
    Join Date
    May 2013
    Posts
    115
    The LCD I was planning to use is here.

    I haven't found a similarly sized I2C or serial version.

  19. #19
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    Ok, if you can't find the size of LCD that you want to use you can find i2c adaptor boards to convert it to i2c. Basically they use an 8 bit I/o expander to drive the LCD. Usually it's a pcf8574 I believe. There are libraries in existence to drive them.
    Here is an example.

    There are many more out there, probably some closer to you without the long wait.

    Oh if you are going to use the SX1509 then you could use that to drive it.
    Use one of the 8bit ports for the LCD (you would only need 7 of the 8 bits) and the other 8bit port for keypad or whatever. With those 8 bits you could drive a 4X4 key matrix. That's 16 keys, if you need that many.

    In fact it would make a nice little project on it's own to develop a display/keyboard set-up.

    It shouldn't be too difficult to convert the |PCF 8574 over to 1/2 of the SX1509.
    Last edited by BriComp; 04-30-2021 at 09:34 PM.

  20. #20
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,090
    Quote Originally Posted by bigpilot View Post
    The LCD I was planning to use is here.

    I haven't found a similarly sized I2C or serial version.
    That is a rather large display for just 2x16 text.

    I used Digi-ole monitors for awhile. They support either I2C, SPI, or serial Uart. Their largest display (83mm x 42mm) is a mono 128x64 display. I find the smaller OLED displays to be a lot easier to read than the LCD display (particularly in bright light):


    Some of the older Adafruit I2C displays also approach that display:

  21. #21
    Senior Member
    Join Date
    May 2013
    Posts
    115
    I don't think I'll need it if I'm already using the SX1509 for the keys.

    i'm currently not planning to use keys on the front panel, merely an IR detector.

  22. #22
    Senior Member
    Join Date
    May 2013
    Posts
    115
    Quote Originally Posted by MichaelMeissner View Post
    That is a rather large display for just 2x16 text.

    I used Digi-ole monitors for awhile. They support either I2C, SPI, or serial Uart. Their largest display (83mm x 42mm) is a mono 128x64 display. I find the smaller OLED displays to be a lot easier to read than the LCD display (particularly in bright light):


    Some of the older Adafruit I2C displays also approach that display:
    The idea behind the large display is that it should be easily read from a distance. The user will mostly be operating the unit from his / her remote control.

    That looks nice, I'll look into that. But I'm gonna stick with a 2 x 16 display for the first version.
    Last edited by bigpilot; 05-01-2021 at 09:52 AM.

  23. #23
    Senior Member
    Join Date
    May 2013
    Posts
    115
    I'm planning to power the Audio Player through a USB mobile phone power adapter which can be purchased almost everywhere these days. For that I need a breakout board like this one (alternatively this one).

    I also need a 3.3V regulator like this one.

  24. #24
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    423
    I am going to be used some of these on a project I am putting together. The advantage of them, besides being cheap, is that they supply both 5v and 3.3v.

  25. #25

Posting Permissions

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