This how-to shows how to convert an MP3, WAV or other audio file into a raw format. There are many reasons why such a conversion is needed. The reason I wrote it is because so that the MICO shield for Arduino can play sounds, music off the MicroSD card. There are many many other uses for such conversion, so even if you’re not an Arduino / MICO user, read on….
Purpose: This tutorial show how to take an audio file (in WAV, MP3 or other format) and convert into raw format so that the MICO Shield can play the sound.
Background: MICO plays sounds off the MicroSD card using a library called SimpleSDAudio . This library has a few limitations that you need to be aware of. One of the limitations is that files must be converted prior to use. See below the other limitations of this library:
Restrictions of SimpleSDAudio Library
- Audio file must be converted prior use
- Audio files must reside in root directory of card
- File name of audio file must be in 8.3-format
- Audio file must reside completely non-fragmented on card
- Minimum controller required: ATmega368. ATmega168 is too low on RAM.
Now that we covered the basics let’s see what it takes to get an audio file in the format MICO can play.
Convert WAV to RAW
1. Overview
The process described in this tutorial covers taking a big audio file with several spoken words on it and breaking into individual words. For example, taking a single audio file that reads: “one, two, three…” and breaking into one file with the word “one”, another file with the word “two” and so on.
In summary, this tutorial shows you how-to:
Create Audio file-> Break-up words -> Convert to mono -> Resample at 62500 -> batch export
2. Recording the Audio:
Record the Audio. You can use Audacity, Windows Sound Recorder or other program of your preference. Preference is that you record in WAV format
3. Preparation steps:
1. Install Audacity. It’s FREE
2. If you have a .WMA file you’ll need to install an Audacity plugin.
4. Break-up the words
In this step you take one recorded file with several words, and break it up word by word
File -> Export Selection…
1. Open the Audio file. Example: Igor_0_to_9.wav
2. Select one number
3. Go to File -> Export Selection…
Create a folder to store your files. I created one called “exported_files”
Save file as 0, use default type.
4. Repeat steps 2 and 3 for each sound 1, 2,3 so on.
5. Close Audacity, and back-up your exported files
5.Conversions
1. Open all the Wav Audio files into Audacity.
TIP: you can drag and drop them
Press CONTROL + A to select all files
2. Convert all to MONO: Track -> Stereo track to Mono
3. Change Project Rate (Hz) to 62500
Now we’re ready to export. Select option File->Export Multiple
After hitting OK, you should see the generated files in your folder. Done!
Now that you have all files converted do not forget to read about these limitations of the SimpleSD Library:
Preparation of SD card and conversion of audio files
The audio library uses a very trimmed SD library that uses the FAT only to find the start sector of the files. Therefore the file must be completely non-fragmented on the SD card. The best way to ensure this is to do a fresh and full format of the card (don’t use quick format!). After formating the SD card, only copy new files on it. Don’t delete files and avoid rename operations that creates file names that doesn’t fit into 8.3 format (see http://en.wikipedia.org/wiki/8.3_filename ). All files must placed in root directory as folders are not supported by the audio library.