Introduction: ARDUINO MUSIC PLAYER
Plays 8-bit PCM uncompressed files
just a few resistors, a capacitor and an SD card shield
audio output to any amplified speaker
Convert mp3 audio to raw 8bit PCM with audacity, the free audio editor
The program opens and reads a file named “AUDIO”. The audio file must be raw uncompressed data in 8-bit unsigned format at 44100 Hz. However, the audio produced by the analog port of the arduino is only 6-bit.
The program uses the ‘SdFat’ library but you can use the standard ‘SD’ that comes with the arduino IDE. Timer1 is set to cause an event every 22us. Don’t forget to change the divide by 4 line in the ISR function if you choose to use PORTD for 8-bit output. In that case you need a standalone controller on a breadboard so that the serial port connections to the USB-to-TTL controller do not interfere with the DAC out.
FILE CONVERSION PROCEDURE
1. open/import your audio mp3 file to audacity
2. Select from the menu ‘Tracks/Mix/Mix Stereo Down to Mono’
3. Select from the menu ‘Tracks/Resample’ and choose the 44100 entry
4. Optionally select from the menu ‘Effects/Amplify’ and arrange for the waveform peak amplitude to reach the upper and lower limits without clipping for best acoustic effect.
5. Select from the menu ‘Files/Export/Export Audio’ and choose type “other uncompressed files”, header “RAW header-less” and encoding “unsigned 8-bit PCM”. Finally, make sure the filename is “AUDIO” with no extension.