Author Topic: How to play WAV audio files from an SD card on Wiring?  (Read 1561 times)

0 Members and 1 Guest are viewing this topic.

gcarrillo

How to play WAV audio files from an SD card on Wiring?
« on: March 30, 2015, 03:20:19 PM »
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: [Select]
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

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.


Regards,

Germán Carrillo
----
[1] https://github.com/TMRh20/TMRpcm
[2] https://github.com/TMRh20/TMRpcm/blob/master/TMRpcm/examples/basic/basic.ino
[3] https://dl.dropboxusercontent.com/u/25697161/1.wav
« Last Edit: April 01, 2015, 11:15:27 AM by gcarrillo »

gcarrillo

Re: How to play WAV audio files from an SD card on Wiring?
« Reply #1 on: April 01, 2015, 11:14:19 AM »
Solved!

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!


barragan

Re: How to play WAV audio files from an SD card on Wiring?
« Reply #2 on: April 01, 2015, 07:32:30 PM »
Excellent!! : )