BackgroundI recommend the excellent, free Audacity software in many of my audio articles. Audacity, along with the LAME MP3 encoder, does a great job of recording, editing, and converting audio to the MP3 format for use on your website. And as I explain in the article how do I embed sound and music in a web page, the Flash-based XSPF Web Music Player makes it easy to put that music on your website.
Where The Trouble StartsUnfortunately, there's one catch: Audacity and Flash don't always play nicely together. If you're recording high-quality MP3 files at 128kbps or more— and for quality recordings of multiple performers in a band, you definitely should be— then you won't have any problems. But if you are recording lower-bitrate MP3 files, perhaps to save disk space and download time for speech or acoustic "singer/songwriter" performances, then Audacity can produce files that Flash player hates. And that's when the high-pitched chipmunk sounds start!
The Sampling Rate ProblemMP3 files always start out at a certain "sampling rate-" a certain number of cycles per second. For our purposes it's good enough to know that high sampling rates sound great, and low sampling rates sound... not so great. But for speech and one-person acoustic performances, they can be just fine.
The problem is that Flash Player only supports two sampling rates: 22,050 samples per second, and 44,100 samples per second. And at low bitrates, Audacity likes to create MP3 files with lots of different sampling rates, such as 16,000 or 32,000 samples per second.
So, what's the solution? Currently the best fix is to convert your audio files to MP3s manually, using the command line version of the LAME MP3 encoder.
The SolutionSound scary? It's not! All you need to do is visit the LAME Binaries for Windows page and pick up the latest version of LAME for Windows (users of non-Windows operating systems should visit the LAME home page to locate a version of LAME for their operating system). Windows will offer to open the zip file for you. Do that, and select "Extract all files." Then extract the files to a folder that's convenient for you. I use c:\audio for most of my audio work.
Once you have the LAME tools on your computer, all you have to do is record your music to a WAV file with Audacity. Follow the steps in the article How do I convert my music to MP3 format— but instead of exporting an MP3 file, directly from Audacity, select "Export as WAV..." instead.
Export your song as c:\audio\mysong.wav.
Then open the Windows command line prompt by following these steps:
1. Start -> Run
2. In the "Open:" field, enter: cmd.exe
3. Click "OK"
Now, move to your c:\audio folder with the following command:
cd \audioBe sure to press "enter" after entering this command.
Finally, type this command to convert your WAV file to an MP3 file with a sample rate that Flash Player will accept:
lame -b 48 --resample 22.05 mysong.wav mysong.mp3
Converting Existing MP3 FilesYou can also "fix" your existing MP3 files with LAME. This is a good technique if you are not willing or able to go back to the original source material. But be aware that although LAME tries to minimize the damage, there is a loss of quality when you re-encode or "transcode" an MP3 file like this. MP3 achieves its wonderful file sizes through "lossy" encoding - throwing away the parts of the audio that the ear doesn't really notice. Doing that more than once can have bad consequences.
That said, here's how to "fix" an existing MP3 file with a sampling rate Flash can't handle. I assume that your existing file is mysongin.mp3 and you want to produce a new file called mysongout.mp3. Substitute your own file names:
lame --resample 22.05 mysongin.mp3 mysongout.mp3
Notice that I haven't changed the bitrate here, only the sampling rate, because that's what Flash is angry about. But you can also specify -b 32, for instance, to downgrade to a very small (and, unfortunately, very low-quality) 32kbps file. You can also force monophonic (non-stereo) output with the -a option, which will also save space.
Yes, you could specify a bitrate higher than the original MP3 file, but it wouldn't do you any good! You can't get something for nothing— you need good source material to make a quality product.
Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!