Arduino Forum

Products => Arduino Due => Topic started by: rickyelqasem on May 19, 2018, 11:16 pm

Title: Due Audio.Begin() speed for 44100 mono files
Post by: rickyelqasem on May 19, 2018, 11:16 pm
Please remind me the speed setting for Audio.Begin() so I can play 44100 mono wav files? I had it working a few weeks back but when set it to:

Audio.begin(44100, 100);

my wavs are playing a double speed. If I set to 22050 it plays at correct speed but it seems like I lose a bit of quality.
Title: Re: Due Audio.Begin() speed for 44100 mono files
Post by: ard_newbie on May 20, 2018, 05:47 am
When I look at Audio.h library, I see that the 2 DACs are enabled (stereo). I don't think this library can be used to play .wav files in mono, only in stereo.

The header of a .wav file (first 44 bytes) provides informations on the number of bites per sample (e.g. 16) , sample rate (e.g. 44.1 Khz), whether it's a mono or stereo recording and the number of bytes to read. So "all" you have to do is open the .wav file, extract the above informations, transform 16-bit samples into 12-bit samples and program the DAC peripheral accordingly.

IMO, the way the PDC DMA for DACC is handled in this library is really weird.
Title: Re: Due Audio.Begin() speed for 44100 mono files
Post by: rickyelqasem on May 20, 2018, 03:29 pm
But when I look at other articles I've seen people put (44100, 100) is mono.. and I've positive I had it working before. My MACbook died and I lost the code.
Title: Re: Due Audio.Begin() speed for 44100 mono files
Post by: rickyelqasem on May 20, 2018, 10:59 pm
Ok I remembered what it is, I need 32k files not 8 bit... speed was right for 32k files. but the only way to get was to 1/2 sample rate which is while I lost quality...