Stealth MP3s

Few people realize that WAV files, perhaps the most universal sound-file format, are actually containers that can hold many different types of data. Using
Publish date:
Social count:
Few people realize that WAV files, perhaps the most universal sound-file format, are actually containers that can hold many different types of data. Using

Few people realize that WAV files, perhaps the most universal sound-file format, are actually containers that can hold many different types of data. Using a free, 44 KB program by Peter Luijer called WaveMP3, I've been converting standard MP3s into files that look and play back like WAVs but retain the tiny size of the originals. These MP3-encoded WAVs are especially useful on the Web, because unlike other compressed audio files (including straight MP3s), they play back without helper applications or esoteric plug-ins.

Disguising your MP3s as WAVs also enables you to use them in some programs that don't officially support the MP3 format, such as older versions of Microsoft Office and some underground video encoders. In this article, I'll explain how MP3-encoded WAVs work, how to create them, and how to use them to pump up your site.


Along with AIFF and AU, WAV is one of the few sound-file formats that almost all Web browsers support “right out of the box.” However, AU is an obsolete, compressed format that sounds rather nasty, and AIFF plays back unpredictably on certain browsers. Further, AIFF technically doesn't support data compression, which is why the AIFC format was developed. According to two Mac audio programmers that I contacted, Tom Erbe (SoundHack) and Norman Franke (SoundApp), it should be possible to embed an MP3 in an AIFC file, but neither has come across such a beast. WAVs, on the other hand, are everywhere. For short sound effects, such as an “audio logo” that announces your home page, they're often ideal. (See the sidebar “Embedding Manual” for the HTML code to create such background sounds.)

The drawback with standard WAV files, however, is their gargantuan size. A 2-second stereo WAV file at 16-bit, 44.1 kHz resolution gobbles up 341 KB, which could easily take 50 seconds to download on a standard 56 kbps modem. You can cut that by 75 percent by collapsing the file to mono and downsampling it to 22.05 kHz; because most of your visitors will have wimpy multimedia speakers, they won't hear much difference. Still, 12.5 seconds is a long time to wait on the Web, and that doesn't count the download times for any graphics or text on the page. With sounds that don't have much high-frequency content or dynamic range, you can lop off another 75 percent by pummeling the files down to 8-bit, 11.025 kHz mono, but the resulting trashy quality is more appropriate for comedy vocal effects than elegant logos. It's better to shorten the sound. A 1-second, 16-bit, 22 kHz, mono WAV file should download in about six seconds, which is reasonable.

But for a site I recently designed to promote a friend's new shakuhachi CD (see Fig. 1), I wanted to introduce the page with longer musical excerpts; a brief blip wouldn't be enough to set the meditative mood. And I didn't want to monkey with formats like Flash, RealAudio, QuickTime, WMA, or straight MP3s that might require the visitor to install a plug-in or a helper application.

That's when I discovered MP3-encoded WAVs. Using Steinberg WaveLab, I extracted multibar phrases from the CD, mixed them to mono, and encoded them as 64 kbps MP3s, which I then camouflaged with WaveMP3.

Due to the way MP3 compression works, a 64 kbps mono file has about the same audio quality as a standard 128 kbps stereo file. That's because kbps is a measure of the data rate, not the audio frequencies. Reproducing an extra stereo channel requires more data, so the encoder must reduce the sound quality to maintain the rate.

You lose some sense of spaciousness by converting to mono, of course, but in this case the duration was more important. As an example, I reduced a 6.7-second, 585 KB mono WAV file to a 52 KB, MP3-encoded WAV with negligible reduction in sound quality — at least for this Web application. That's more than a 20:1 compression ratio over the original stereo file.


Most types of audio files — including WAV, AIFF, and MP3 — contain raw samples of the original analog waveform and additional descriptive data about those samples, usually stored in the file header. Without that so-called metadata, the playback device or program would have no clue which sampling rate, resolution, or number of channels to use. (In the case of compressed formats like MP3, the player also needs to know which decompression algorithm to use.) An audio file without metadata is called a raw file. (For more on sound-file anatomy, see “Square One: Making Waves” in the April 2002 issue of EM.)

Rather than use a single header, WAV files store data in chunks. Typically, the Data chunk contains uncompressed, pulse-code-modulation (PCM) audio samples. But if the preceding Format chunk specifies a different format, other types of audio data — such as MP3 — can be stored instead. WAV files also contain a List/Info chunk, which can hold textual information about the file, just as ID3 tags can be used to store artist and song names (and even simple graphics) in an MP3 file.

Converting MP3s into MP3-encoded WAVs with WaveMP3 is easy. (See the sidebar “Extend Your MP3” for a download link.) Just drag an MP3 file onto the program's icon, and WaveMP3 adds the correct chunks and creates a new WAV file. If the program finds an ID3v1 tag at the end of the MP3, it creates a List chunk and fills in the corresponding data fields, which can then be displayed in newer versions of Windows Media Player.

Dragging an MP3-encoded WAV file onto the icon changes it back to an MP3. The program also works on groups of files. Unfortunately, it only works in Windows. I couldn't find a similar program for the Mac, although I successfully ran WaveMP3 under Connectix Virtual PC. (Incidentally, Virtual PC is a terrific tool for Web developers, because it lets you quickly test your pages on multiple operating systems.)

During my file-format experimentations, I noticed that I was able to “convert” MP3s to MP3-encoded WAVs and play them in Windows Media Player just by changing the file extension from MP3 to WAV, so I asked WaveMP3 author Luijer if his program was really necessary. “Unfortunately, simply renaming an MP3 doesn't make it a real WAV file,” he replied. That point was borne out when I tried unsuccessfully to open the bogus WAV file in other programs. “The reason Media Player will still play it is because it determines the format by looking at the contents of the file,” Luijer continued. “Try renaming an MP3 or WAV to DOC and opening it in Media Player [from the File menu by setting the file type to ‘All files’]. It will still play.”

Luijer also notes that it's not possible to rewrite the file chunks with a text editor, because “MP3 files and the WAV header use raw byte data — values from 0 to 255.” It might be possible with a binary file-viewing utility and a morbidly detailed knowledge of the file formats, but we're here to make music.


Rather than disguise an MP3 as a WAV to sneak it onto a Web page, you can embed the MP3 itself, using the syntax in the “Embedding Manual” sidebar. But for that to work, your server must be configured to handle the MP3 MIME type. Also, some Web-hosting services specifically prohibit MP3s. With Macromedia's Flash Player supposedly deployed in 90 percent of browsers, saving the MP3 as a Flash file is a good alternative. Another option is to save the MP3 as an audio-only QuickTime movie with the extension MOV; although not as universal as WAV or Flash, QuickTime is reasonably well supported.

Nonetheless, there's a lot to be said for near-universal compatibility. “I actually did a rewrite of WaveMP3 because I received many requests from users of FlasK MPEG and VirtualDub,” says Luijer. “Those programs are used to make backup copies of DVD-video discs and to recode DVDs to the new DivX format [for CD-ROM]. They support only WAV files as audio input, so people are using my program to be able to use MP3s.”

If you don't label your MP3-encoded WAVs clearly, you could inadvertently use one in a situation in which you would otherwise want a high-quality WAV file — burning a CD, for example. Besides that, I've found only one drawback with the format, and although it's potentially serious, it probably won't affect many people. Specifically, the Mac version of Microsoft Internet Explorer crashes if RealNetworks' RealPlayer has been set to handle WAV files and the Mac tries to load a page with embedded MP3-WAVs.

“On Windows systems it all seems to work nicely,” Luijer says. “Because the WAV format was designed to be flexible, it is not very optimized when it comes to adding data like cue points, playlists, and so on. Those chunks need to be ‘wrapped’ inside subchunks and filled with ‘junk’ chunks — empty bytes — to make sure they're all correctly aligned, which increases the file size. Another drawback of the format is that it's not streamable. But apart from those minor drawbacks, it's a good, well-thought-out format.”

David Battinomakes big sounds and little sounds, a music-technology consulting service.


Fig. A shows the technique I used to play a random sound every time a visitor loads the home page. The code is based on a JavaScript by Peter Gehrig and Urs Dudli of, a bonanza of offbeat JavaScripts. The randomizing technique shown here can also be used to display movies, links, images, text, or other objects.

To use this script, place the