New library for PWM playback from SD cards: SimpleSDAudio

Hi,

Adding a capacitor after the resistance network helped to decrease the noise. However, still ordered some analog amplifiers to see whether I can get better results. Haven't tested the SN74AC14 yet, that one has arrived today.
To get 16 bit mono output I have to set the flags like: SSDA_MODE_FULLRATE | SSDA_MODE_STEREO | SSDA_MODE_AUTOWORKER ? And I have to convert my .wav file to: .BFM? Because with this combination of settings I do not get good results. I get some kind of very noisy output where I'm trying to play a gunshot. What could be the cause of this? Are there any restrictions for the .wav file, too?

Marcel

Hi,
your flags seem to be correct as well as the file format. Of course you need good quality audio material if you want good results. Maybe you have to swap the pwm pins, try playing in 16 bit mode and test what you hear on each of both channels by connecting only one of them to the input of the circuit where the resistor with the lower value is.
On one channel you should hear the sound in good but 8 bit quality and on the other one you should hear loud noise when the 16-bit file is playing. this goes later to the input with the higher value resitor. With both outputs combined you have to adjust the poti the lowest noise. The quality should be then less noisy than 8 bit mode.

how to build class
play next, previous file
Please help :slight_smile:

THX

hmm
#include <SimpleSDAudio.h>
not working with
#include <SD.h>
:frowning:

Hm, looking into crystal ball, try starting with the examples provided by the library. Use Arduino IDE V1.0.x instead of beta versions in case of build trouble.

Great project!!! i will try it!

i am just looking not very much for quality but if possible gapless play of parts of the file or between files... don't know if possible. Want to use atmega328 or 2560

thanks!!

Gap-less playback from SD is always a challenge. Even the .play() function might be fast enough, at least the .setFile() function will always do a lot of searching through the FAT filesystem. First try to play the same file again and again using a loop like:

while(1) {
   if(SdPlay.isStopped()) SdPlay.play();
}

If this works ok for you, you might youself patch the library in a way that the information that is retrieved by setFile is stored somewhere in RAM and used for quicker change of the file to playback. But this might be not the right starting-project for beginners...

Tuttut:
Gap-less playback from SD is always a challenge. Even the .play() function might be fast enough, at least the .setFile() function will always do a lot of searching through the FAT filesystem. First try to play the same file again and again using a loop like:

while(1) {

if(SdPlay.isStopped()) SdPlay.play();
}




If this works ok for you, you might youself patch the library in a way that the information that is retrieved by setFile is stored somewhere in RAM and used for quicker change of the file to playback. But this might be not the right starting-project for beginners...

Thank you SO MUCH for the quick answer and the tip too! ... I'll check it and come back with results..

Hi again.. used the code below

while (S < 1000) {
    S=(pulseIn(13,HIGH,20000);
    if (millis()-t > 999){p=1;t=millis();
    if (p == 1) {
      SdPlay.setFile("START.AFM"); 
      SdPlay.play();p=0;t=millis();}

and my loop played perfect!!.. BUT now i noticed another problem with pulseIn as i am reading a PWM input to change sounds...

any tips if i can do that? is this an interrupt problem or because changes of the timers? is there anyway to measure PWM while playing sound?

Is there a way to adjust the volume?
I have a home automation including a clock with my arduino mega, and would decrease the sound (westminster gong) in the night and set it to normal (it's loud enough) at the day.
Currently i must disable the sound in the night :frowning:
thanks

Hi,
actually there is no such a feature. But usually SD cards have plenty of space - so just prepare one set of files with a lower volume (using a wav editor like Audacity) and switch between them.

Tuttut:
Hi,
actually there is no such a feature. But usually SD cards have plenty of space - so just prepare one set of files with a lower volume (using a wav editor like Audacity) and switch between them.

Good idea. Done. Works.
Thanks...

its possible make this with this library? Onix arts :: Arduino soundcard

SimpleSDAudio patch for Atmega128 with MegaCore bootloader (file SimpleSDAudioDef.h)

SimpleSDAudioDefs.h (15.5 KB)

Hi, I've noticed that if the percentage of memory for global variables is >= 40% the SD Card doesn't initialize anymore! But if the percentage is 39% or less all works perfectly. What's the problem? I tried library version 1.3 and 1.2

I'm getting error code 128

Tuttut:
Edit/New: I updated the library (ported the core output part to hand-optimized ASM) and now also 16 Bit audio output (even in stereo) is possible (combining two PWM outputs using 2 resistors, known as 256R-R-network).

You know about sigma-delta noise-shaping? Its not too hard to get high resolution out of a single 8 bit PWM
channel using it. Basically you shift the quantization noise up in frequency out of the audio band - its
closely related to dithering in 8 bit graphics.

How do you handle upsampling to 62.5kHz BTW?

For best results with sigma delta noise-shaping I'd suggest using 6 bit PWM so you can run PWM at 250kHz,
gives a lot more space to push the noise into, and its much easier to filter too.

Hi everybody. If you want to get a clean 8bit sound, try conversion using Adobe Audition: Dither Depth 0.7 bit, p.d.f. Triangular, Noise Shaping E2 (62.5 kHz) or C3 (31.25 kHz). In 62.5 kHz the dithering is inaudible, in 31.25 kHz it sounds like an audio tape.

I have a problem and question: how to jump sectors? I need to do a simple functions: FF and REW (as in walkmans). I need the function: (n) sector = (n+1) sector. Help! :slight_smile:

I tried this library and it is working better. Let say acceptable sound for low level proccessor. And this library helps to use and manipulate sound for your applications, toys, verbal clock, doorbell, whatever needs sound in the applications. Difficult to use SoX. For preparing tracks, I used https://www.audacityteam.org/ that is free.
Is it necessary to try changing rate 44100 to 62500 this value can be set manually and is not in pop menu. For the right speed tracks playing I import raw as 62500 and export as 44100 . Export as raw. To open a track in raw format, use "import" not "open". Thank you Tuttut