SD Card Audio Player

bigpilot

Well-known member
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.

sdcardinfo.png
 
Last edited:
enclosure.jpg

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.
 
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.
 
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.
 
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:
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:
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.
 
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).
 
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.
 
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).
 
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:
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:
 
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.
 
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:
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.
 
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.
 
Back
Top