Go Down

Topic: Sampling audio + exporting to some audible format (Read 1 time) previous topic - next topic


Hello guys, I'm new over here and I've just bought an Arduino Due (I've never used an Arduino before, but so far I haven't had any problem).
I would like to know if you can help me. I've build an amp (3 stage transistor) to an electret mic  with a low pass filter (with a cut off frequency of 3khz). My sampling rate is 10khz (it's enough for me and it won't suffer from aliasing).
My ADC is recording only one channel (mono); I would like to know how to convert my ouput (12 bits) to an audible format (I mean: to store like an audio format i.e .wav and reproduce this sound on the PC).
Sorry if my question is kind of dumb, but I don't know how to proceed. If someone can enlight, please let me know =) Thank you very much!


Here is a description of the WAV format.    Following the header is simply an array of audio samples.  The only things you have to keep in mind are, you have to get the byte-order correct, stereo/multichannel data is alternated/interleaved, and 8-bit files used unsigned integers.

You might have to search-around for a more detailed spec, and I'm not sure how 12-bit samples are handled, since 12-bits is 1.5 bytes.   I know that 12-bit PCM audio is fairly common with some video formats, but I'm not sure if it's standard for WAV.  I'm also not sure if 10kHz is a standard WAV sample rate. 

If you want to handle the WAV file-formatting on the computer-side, I'm sure there are libraries for saving an array of audio samples in WAV format.


Hi, usually even when sampling at 12 bit, you use a 16 bit variable to store the sample. You can dump those 16 bit samples without any header to a binary file eg. on SD card connected to your Arduino. Using Audacity's Raw-Import feature you can then open the file on PC. Audacity will ask you some questions about sample rate and resolution at import, usually after a little bit of figuring around you will find the right settings quickly. You can then do some audio editing and save the file as a .wav file in Audacity.


Thank you very much guys =)
DVDdoug, I haven't found something specified like that... Thank you very much, now I have an idea how to make a file with that extension. About the 12 bit it won't be an issue because as Tuttut's said it store in a 2 byte variable (although it uses only 12 bits); I don't know either if 10khz is a standard fs, but I'm pretty sure that won't be an issue (I've worked with a lot of samples of .wav files and I have downsampled it to so many rates). I'm gonna start to work on this tomorrow and will post the results. Thank you, you were very helpful =)
Tuttut, I didn't know that was some sw that could do something like that... I'll try to use it and then if it works I'm gonna try to make my own conversion (now I know how to procced with the header). Thank you for your help =)
You guys have enlightened me... Thanks once again!


You should also put each 12-bit sample in the high order bits of the 16-bit word so that you maximize the audio amplitude when the WAV file is played.


Go Up