All Forums > Project Questions / Guidelines

How to play WAV audio files from an SD card on Wiring?


Hi all,

I'd like to ask you what's the best way to play audio files from an SD card on Wiring.

I've used the library TMRpcm [1] on Arduino Uno with success. One needs to have an SD or a micro SD configured, convert the audio files to a specific format (WAV, 8-bits, 16kHz), optionally make an amplifier circuit, and the like. I already have that done.

However, since Wiring gives me twice the memory than Arduino Uno (my script already exceeds Arduino UNO's memory), I'd like to implement my project on Wiring. I'm working with a Wiring S, Wiring v.1.0.1-dev as IDE, and already changed all include <Arduino.h> by include <Wiring.h> on all files in the TMRpcm library.

When I run the basic example [2] (adjusting the audio file name and setting the SD_ChipSelectPin to 20, and the speaker pin to 16) I get the following error message:

--- Code: ---core.a(WHardwareTimer.cpp.o): In function `__vector_15':
C:\Users\toshiba\Downloads\wiring-v1.0.1-dev\cores\AVR8Bit/WHardwareTimer.cpp:140: multiple definition of `__vector_15'
TMRpcm\TMRpcm.cpp.o:C:\Users\toshiba\Downloads\wiring-v1.0.1-dev\libraries\TMRpcm/TMRpcm.cpp:650: first defined here
core.a(WHardwareTimer.cpp.o): In function `__vector_12':
C:\Users\toshiba\Downloads\wiring-v1.0.1-dev\cores\AVR8Bit/WHardwareTimer.cpp:145: multiple definition of `__vector_12'
TMRpcm\TMRpcm.cpp.o:C:\Users\toshiba\Downloads\wiring-v1.0.1-dev\libraries\TMRpcm/TMRpcm.cpp:569: first defined here
collect2.exe: error: ld returned 1 exit status

--- End code ---

If I comment these definitions in the library (TMRpcm.cpp file) or in the WHardwareTimer.cpp file included in Wiring, the code compiles and I can upload it to my Wiring S, but the audio file cannot be heard.

Here [3] you can get a 31KB sample audio file (already converted to the required format).

Could you please help me solve this problem? What am I missing? I can provide you with more details if needed.


Germán Carrillo


After commenting the double definition of the timer (one by the TMRpcm library and one by Wiring) on WHardwareTimer.cpp, I just needed to try with other pins, rather than 16 or 4 for the audio output. So, in the end, pin 20 for CS/SS and pin 6 for audio output. For the record, I'm using timer 2 in the TMRpcm library, just needed to enable it in pcmConfig.h

Now I can hear audio from the WAV file stored in my microSD!

Excellent!! : )


[0] Message Index

Go to full version