Go Down

Topic: New library for PWM playback from SD cards: SimpleSDAudio (Read 45 times) previous topic - next topic

cobra18t

Well, I am starting to port the code over to the chipkit Uno32. First I had to port the library back to Arduino 0023, since that is what the chipkit software--MPIDE--is based on. This was mostly just changing

Code: [Select]
#include <Arduino.h>

to

Code: [Select]
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif


as well as converting the examples from .ino back to .pde files. After this massaging, I got it to compile in 0023.

The code is not pretty at the moment since I am using a lot of "#if defined (__PIC32MX__)" to switch between AVR and PIC specific code. I have the SD card library working on the Uno32, so now I need to port over the PWM.

I am running the SD card at 400kHz during initialization and then at 20MHz for everything after that. It is looking like the PWM will be sampled at 78125Hz for full rate and 39062.5Hz for half rate. These values were chosen to give perfect 8bit resolution on the PWM and still be close to the original 62500 and 31250Hz values.


cobra18t

For anyone interested in further details regarding my chipkit port, follow the progress at http://chipkit.org/forum/viewtopic.php?f=7&t=1652&p=7026#p7026.


-Thomas

PWBarrett

Might I make a request?...

that SdPlay.deInit(); would release whatever SPI timers etc that were grabbed by calling init().

I'm trying to use this in the same project with the Servo.h library, but there's apparently a conflict.
Once I call SdPlay.init(), I can no longer position servos where I want, even if I'm not playing a sound.

Not really a problem since I don't need to do both simultaneously.
I could init(), setFile, play etc., then deInit before returning, but deInit isn't putting things back the way they were...

Any suggestions?
-- thanks

Tuttut

Hi,
I released a new version of the library. The core audio output function is now written in assembler and thus allowing playback of either STEREO and FULLRATE or HALFRATE with four channels. Two channels can be combined to get 16-bit resolution using only a resistor and a trimmer. But in this case the faint noise of the controller can be heard, so I recommend using cheap Schmitt-Trigger buffers (like 74HC14 or else) to get rid of the noise that is on top of the digital signals of the Arduino. With HALFRATE and QUADRO mode and those Schmitt-Trigger circuit you can get a quality that is very good also for music or sound with big dynamics. I is still not full CD quality but quite near to it.

Also I did a patch that you can apply to Arduino that frees the timer0 from all the core functions and makes it available for audio output (timer2 is then used instead of timer0 for core functions like millis and so on). This way audio can be output on pins 6 and 5 instead of pins 9 and 10 on ATmega328 based platforms like Uno, Duemillanove and Ethernet or on all 4 pins together allowing also the Uno to do 16-bit stereo output...  :smiley-mr-green:

Further, for Windows user I included the SOX binaries in the library so you can convert WAV-files using the drag'n'drop targets.

Have fun!

Go Up