World Wide Waveforms - EMusician

World Wide Waveforms

Sonifying your Web site is much easier than it used to be.
Author:
Publish date:

When site visitors click on the link, the MP3 file starts downloading to their browsers. Most modern browsers buffer a certain amount of the file and start playback when the browser calculates that the file can be played back without interruption. Alternatively, visitors may have configured their browsers to use a preferred audio player — such as iTunes, WinAmp, or Windows Media Player — to automatically play Web audio content. Unfortunately, client-side issues are beyond the control of the Web-site creator, and each browser deals with audio a bit differently.The only server-side problem that could arise is that your Web-hosting company might not have its Web server configured to recognize MP3 files with their proper MIME type. That problem is exceedingly rare. If, however, a file that is in the right place with a link that is written correctly will not play and your browser properly plays back MP3 files from other Web sites, you should contact your Web host's support staff to see if MP3s are intentionally or unintentionally blocked on its servers.As an alternative to posting download links, you can embed the audio in your Web pages. That allows the file to start playing automatically when the page is loaded. Embedded audio can be supremely irritating if used incorrectly — nothing drives me more crazy than visiting a Web site only to find a Homer Simpson sample blaring through my studio monitors at 90 dB. A better way to use embedded audio is to have a separate page on your site for each embedded file. That allows you to create your own graphics for the audio as well as include links to other songs and places to buy your music. Providing pictures and text also gives the visitor something to do while the audio is being fetched from the server. The HTML code to embed a song named Nabakov would be www.mysite.com/music/Nabakov.mp3” autostart=true loop=false volume=100 hidden=true>.Instead of embedding a whole song, you might consider embedding a short, low-volume loop that is representative of your music. To do that, simply change “loop=false” to “loop=true” in the HTML code. When people visit the page, the loop will automatically play in the background without scaring them to death.These examples are not only useful for people who hand code their HTML; all of the same things can also be done in most of the popular Web-authoring programs. For example, in Macromedia's Dreamweaver, you can create a link to point to an MP3 file by selecting the link and then browsing to the correct file in the Property Inspector. The Property Inspector can also be used to embed audio files in a Web page. The audio can be set to play when a link is clicked on or when the mouse rolls over a picture. The results can be either incredibly amateurish or, when used judiciously, very professional. Macromedia suggests using its Flash authoring tools to save music as Shockwave files to overcome the differences in how browsers and platforms deal with MP3 audio. That has pros and cons, but it is an alternative to MP3 that is worth considering.Finally, you might want to give visitors to your site instructions on downloading your music instead of just listening to it. If a song plays back inside a browser, it will most likely remain in the browser's cache for a certain amount of time. However, the user will not be able to easily find the song for playback or for loading into a portable MP3 player. Although it might seem like Web browsing 101, it is a good idea to remind visitors that they can right-click (Windows) or Control-click (Mac OS) on the file to open a contextual menu that allows them to save the MP3 anywhere on their hard drive.WEB MULTICASTINGWhen a small number of people are trying to stream music from a Web site, the Web server can handle all of the audio data without much trouble. If, however, you are lucky enough to have lots of people who want to listen to your music at the same time, your server might run out of bandwidth or processing power. Then it's time to consider Web multicasting.Multicasting takes a single data stream from the Web server and routes it simultaneously to everyone who is requesting it. That is accomplished by sending the content to smart routers and switches that can handle new requests for the data stream on their own. If a computer makes a request to listen to a particular song, the nearest router or switch that is already broadcasting the song simply adds the new computer to the list. That saves bandwidth by putting less stress on the server providing the content and by routing the data from the source closest to the receiver.Multicasting is the best solution for providing Web content to many users simultaneously, but it is not a do-it-yourself project. Your Web server will have to connect to a machine that is dedicated to multicast streaming, and there is usually an extra charge for that service. The two biggest players in multicasting are Microsoft and Real Networks. If you have a commercial company hosting your Web site, you will have to find out what, if any, multimedia streaming and multicasting options are available. If multicasting is offered and is the only way to solve the lucky problem of having too many listeners, the smart decision is to put up the cash.While putting your music on the Web can include some obstacles, it is undoubtedly worth the effort. The Web gives independent and unsigned artists a superb tool with which they can present their music 24 hours a day, 7 days a week, across the globe. It also provides more established artists with a direct connection to the people who will hear and buy their music. Web-savvy musicians such as Todd Rundgren and Big Head Todd and the Monsters use their Web sites as serious money-making and promotional tools. The more you learn about Web audio, the better you can leverage the Web to get your music out to the masses.Thad Brownis a musician, writer, and consultant whose online avatar resides atwww.thadbrown.com.ALTERNATIVE FILE FORMATSMP3 is not the only file format used on the Web. Some alternatives are listed below.AAC is the native format used by iTunes. While not very common on the Web, both Mac and PC users can play AAC files if they have the current version of QuickTime installed.Windows users can create and play files in Microsoft's proprietary WMA format. Personally, I think both AAC and WMA files sound better than MP3 at the same bit rate, but fewer people will have the software to play them back.While there are many free software encoders to make MP3s, the core technology used to make MP3s is still patented. Ogg Vorbis (www.vorbis.com) is an open source, free codec that presents an alternative to MP3. If you are interested in open source software, this is a codec that you may want to learn more about.Real Audio from Real Networks (www.real.com) is another proprietary format. While Real Audio files can sound decent, most often the format is used for lower-quality sound and video for Web broadcasting. Real Player (a free cross-platform download) must be installed to play Real Audio files.Shorten (http://wiki.etree.org) is a fairly new lossless-compression scheme. No data is lost, and after the file is decompressed, it plays back exactly as the original did. Unfortunately, the degree of compression is much less for lossless formats — 50 to 70 percent in the case of Shorten — making them less suitable for Web posting. Still, the audio quality is the best possible.Apple Lossless is a lossless-compression scheme that was recently introduced by Apple as part of its QuickTime package. iTunes can be used to encode in that format, and the typical file size reduction is 50 percent.

Few tools are of more value to musicians than the Internet. A prominent Web presence is the only way to have your music, and information about it, available all day, every day. Web sites can be used for mundane tasks such as promoting gigs and signing up email subscribers. To take full advantage of the Web, however, you should include examples of your music on your Web site. That could mean anything from sharing a few demos with friends to multicasting for hundreds of people simultaneously. In this article, I'll concentrate on how audio is compressed, how to choose an appropriate compression format, and how to write the basic HTML code for adding audio to your Web page. Along the way, I'll offer some useful tips on how to make the most of your Web site.

BANDWIDTH REALITIES

Image placeholder title

FIG. 1: Apple''s iTunes is an excellent program for playing and encoding compressed audio in a variety of formats. The encoding setup window is shown in the inset.

If everyone in the world sat at the end of a fiber-optic connection to the Internet, inserting Web audio would be a simple matter of uploading your perfectly mixed 24-bit files to your Web site and adding a few links to them. In reality, people can use anything from a 56k modem to a fiber-optic connection. No matter what connection speed visitors to your Web site use, they should all have a good musical experience. As a reference, users of dial-up modems top out at 56 kbps, DSL users top out at 1,500 kbps (uploads are slower), and cable modem users top out at around 2,500 kbps. Those are absolute maximums; quite often, real-world performance is much slower, and for various reasons, bandwidth can change day to day with most Internet providers. The Internet can also slow down as a result of hacker attacks and backbone failures. In short, bandwidth varies, even for those who have the best Internet connections.

Compared with most kinds of Web content, audio files are very large. For example, one page of my graphics-intensive personal Web site, including graphics files and HTML code, is about 85 Kb of data. One second of stereo CD-quality audio is 1,410 Kb of data; in other words, one second of audio on a CD contains more than 16 times the amount of data contained in one of my personal Web pages. That fact represents the main problem with posting audio on a Web site: only the fastest Internet connections operating under the best of circumstances can stream true CD-quality audio.

Even if everyone had an Internet connection fast enough to stream full-bandwidth 16-bit, 44.1 kHz audio files, that still might not be the most cost-effective way to download audio files. Most commercial Web-hosting companies charge their customers according to how much data is downloaded each month. The solution to that problem is to compress the audio files.

THEORY OF COMPRESSION

Before I discuss the tools that are available for making compressed audio, it is important to understand the basics of audio compression. Audio-compression schemes use what are called codecs to minimize file size. (“Codec” stands for “encode/decode.”) Creating the file is half of the equation; after you compress a file using one of various codecs (see the sidebar “Alternative File Formats”), the person downloading the file has to decode it for playback.

Image placeholder title

FIG. 2: Cubase SX can export an MP3 directly, at a wide variety of bit rates.

By far the most common codec is MP3, so for this article I'll concentrate on how to make good MP3 files for the Web. All codecs perform similarly, so what I present in this article applies to all other types of codecs.

The science of audio perception is called psychoacoustics, and while many of its precepts are used in designing audio-compression tools, the one most often used is called masking. Masking occurs when one sound that is similar in harmonic content to another is louder than the other. In such cases, the softer sound may be imperceptible. An example would be two violins playing the same note, except one violin is played loudly and the other softly. You would barely hear the softer violin, if at all. Audio codecs exploit that fact by getting rid of data that is likely to be masked in one way or another, so that when the audio is decoded, you hear something as close to the original as possible. That process is called perceptual coding, because it hinges on what our ears and brains can, and more importantly, cannot perceive.

An MP3 encoder works on many small chunks of audio called frames. The MP3 standard dictates that each frame last 26 ms, so an MP3 encoder outputs as many 26 ms frames as necessary to encode the file. Each frame is compared with the mathematical models of perception in the codec itself, and the data that is deemed least important by the codec is discarded. Depending on which settings are specified by the user, the codec can be forced to keep more or less data. The less data that is kept, the more likely it is that some important data will be discarded, resulting in a degradation of audio quality. All perceptual encoding is lossy, which means that some information is lost in the process — what comes out is not exactly what went in. Compressed audio can sound good, but even the best encoders make some changes to an audio file. Working with compressed audio is all about the trade-off between audio quality and file size.

PRACTICE OF COMPRESSION

Most musicians and audio engineers classify audio by its sampling rate (the number of times an incoming audio stream is sampled per second) and its word length (how many bits of resolution each sample uses). CDs have 44,100 samples per second and use 16-bit words for each sample. Even modest home-recording setups can now record at a much higher resolution, but 16-bit, 44.1 kHz audio is still a benchmark, if only because of the millions of CDs that use that standard.

Image placeholder title

FIG. 3: Shown above is WinAmp, a popular and fully featured Windows MP3 player.

Different terminology is used to describe compressed audio; it is categorized by its bit rate. The most common bit rate for MP3 files, for example, is 128 kbps, meaning that the file contains 128 Kb of data for each second of audio. MP3 files at that bit rate are often called CD quality. There is an obvious decline, however, in audio quality compared with that of a CD. If there were a compressed-audio-file standard, it would be the 128 kbps MP3.

When encoding an MP3, you can use a constant bit rate (CBR) or a variable bit rate (VBR). As the name implies, a CBR file uses the same bit rate throughout the song, whereas a VBR encoder will vary the bit rate based on the complexity of the audio being encoded. In a silent section, for example, the bit rate could be zero, whereas the bit rate for a section with a full band could be the maximum that the codec supports. VBR files are usually preferable, because they sound better than CBR files of the same size. The only downside to VBR files is that some older MP3 players may not be able to play them.

Both Mac and Windows platforms have excellent free tools for making compressed audio files. If you have Mac OS X, you can configure iTunes to make MP3 files instead of using the default Advanced Audio Coding (AAC) file type. Select Preferences from the iTunes menu, click on the Importing button, and select the MP3 encoder (see Fig. 1). Mac OS 9 users can download SoundApp (www.spies.com/~franke/SoundApp), a useful audio-file converter for older versions of the Mac OS. Windows users have dozens of options for free MP3 encoders. I prefer Cdex (www.cdex.n3.net), an easy-to-use, free ripper that has lots of options for encoding and saving files. Alternatively, many digital audio sequencers export files in MP3 and other compressed audio formats (see Fig. 2).

Once you are armed with the tools to make an MP3, the next step is to decide which settings to use. When ripping CDs for my personal use, I use a high VBR because, even when I use the highest-quality settings, a file is compressed to one-fifth of its original size. MP3s of that quality sound good on almost any player (see Fig. 3). For Web content, however, those files are too large for people who have slower Internet connections to download and play conveniently. For Web content, start at 128 kbps VBR, see how big the file is, and listen to how good (or bad) it sounds. Even someone with a dial-up modem can download a file at that bit rate without experiencing excessive aggravation. If the audio quality at 128 kbps is not good enough, increase the bit rate in small increments until you're satisfied with the sound.

An even better idea is to create more than one file for your Web site — a high-resolution file for the people with faster network connections, and a lower-resolution file for the others. That enables all visitors to your site the chance to enjoy your music by allowing them to choose between audio quality and download speed.

You can often EQ your audio source files to make them sound better after compression. Because the encoding process throws out some data, the encoder is making choices about what is important in a mix and how it should sound. Sometimes parts of an MP3 file don't sound right. That is especially true with hi-hats, but it can apply to any part of a mix. Problems with sound quality are more common with lower-bit-rate MP3s, because the encoder has to get rid of more data, resulting in a greater effect on the sound. Keep in mind that equalizing for compression is different from equalizing for normal playback — the sound after compression is what you're concerned with.

Make your low-resolution file as small as possible. Using a VBR file is almost always a good idea. Trim all silence at the beginning and the end of a song. If you are forced to make small files, you can do two drastic things: set the encoder's output sampling rate to 22 kHz, and encode in mono. That will reduce the audio quality, but depending on the content and the encoder, it might be good enough. The encoded file will be reduced to a quarter of its original size (half due to the encoder's sampling-rate cut and half again for encoding in mono).

The final task when making an MP3 for your Web site is to edit the ID3 tags. ID3 tags contain information about the artist, the musical style, and an optional thumbnail image. Always include the URL to your Web site in case someone hears the file and wants to find more music like it. Each software encoder has the ID3 information in a different place, but any decent ripper will have the ability to edit the tags.

To illustrate the differences in audio quality using various bit rates, I've posted snippets of one of my songs — one version in its original WAV format (see Web Clip 1) and three that are MP3 encoded: 192 kbps, 128 kbps, and 128 kbps at a 22 kHz sampling rate (see Web Clips 2, 3, and 4).

HTML BASICS

A few years ago, getting an audio file to play back from a Web site took a fair amount of effort on both the server and client sides. Today, assuming that the person visiting the Web site has modern software and hardware, the task is straightforward. The simplest method is to use an FTP client to put the MP3 on the Web server, and then add a link to the file on the Web site. The link is similar to a Web-page link, but the target is the MP3 file. For example, the HTML code to link to a song named Nabakov would be www.mysite.com/music/Nabakov.mp3”>Nabakov.