Sawing Logs

LOGARITHMS IN MUSIC AND AUDIO
Author:
Publish date:
Image placeholder title

Logarithm is a term that appears in many digital audio settings — logarithmic taper, logarithmic Velocity curve — but what does it really mean? It turns out that logarithms are useful in describing many of the concepts on which we depend. Frequencies, octaves, volume, and more behave in ways that would be awkward to describe without logarithms. In this article, I'll demystify the logarithm and explain its various applications in music and audio.

As electronic musicians, we deal with all sorts of numbers whose resolution changes drastically from low to high. Consider, for example, the relatively simple and familiar concept of musical octaves. Because an increase in pitch of one octave corresponds to a doubling of the fundamental frequency, an octave above 20 Hz is 40 Hz, whereas an octave above 1,000 Hz is 2,000 Hz. Between 20 and 40 Hz, a variation of 1 Hz represents 5 percent (1/20) of the octave — between 1,000 and 2,000 Hz, it represents only 0.1 percent (1/1,000) of the octave.

Image placeholder title

FIG. 1: The traditional display of a frequency-response graph (A) uses a scale that is linear with respect to pitch and logarithmic with respect to frequency. A linear frequency graph (B) compresses most of the octaves in the low end of the scale.
Illustration by Chuck Dahmer

To put this doubling in mathematical terms, as the octave increases, frequency increases by a power of two: the frequency n octaves above a pitch P is P × 2n. Because n is literally the exponent of 2, this is called an exponential relationship. If pitch rises at a steady rate, as when a musician plays an ascending chromatic scale, frequency rises at an increasing rate. The distance in terms of frequency between each subsequent pair of notes is greater than the distance between the previous pair of notes, yet musically each is a semitone (half step). Fig. 1 illustrates the relationship between musical intervals and frequencies.

So what is a logarithm? The logarithm is n, the octave. A logarithm is the power to which a certain base b must be raised to equal a particular number x. In other words, if bn = x, then logb(x) = n. A logarithm is the inverse of an exponent.

Logarithms solve two problems. First, they allow us to make meaningful comparisons of things, such as musical intervals, when the underlying numeric relationships vary according to range. An octave is still an octave whether it spans 20 Hz or 1,000 Hz. Second, logarithms enable us to describe very large and very small numbers with relatively simple numbers, as you'll see.

To Infinity and Beyond

Our ears can detect the sound of an insect's wings at arm's length, and our ears can be instantly damaged by a train horn at the same distance. In between are all the useful volumes. The ratio between the sound pressure of these two sounds is about a million to one. Imagine a manufacturer describing the signal-to-noise ratio of a new preamp in those terms!

Of course, this is why we use decibels (see the “Square One Classic” article “Decibels Demystified,” parts 1 and 2, available online at www.emusician.com). Decibels define the ratio between two powers, so we can make meaningful comparisons between two numbers regardless of whether we're talking pascals or micropascals. They also narrow that million-to-one span to a range of 120 dB. A bel is the power to which 10 must be raised to equal the ratio in question — by definition, it's a logarithm. A decibel is simply a tenth of a bel. If sound A is 100 times louder than sound B, the ratio of their intensities is 100:1, or 100. Because 100 = 102, the ratio is 2 bels, or 20 decibels. Mathematically, d = 10 log10(IA/IB), with d representing the number of decibels and IA and IB representing the intensities of sounds A and B, respectively. The decibel, being a logarithm, allows us to describe the relative power of two signals regardless of whether their absolute powers are very small numbers or very large numbers.

The numbers tend to get a bit squirrelly when decibels are used to describe different things. If you double the power of a signal, it increases by 3 dB: because 100.3 = 2 (approximately), 10 log10(2/1) = 10 × 0.3 = 3. However, since power increases by the square of the voltage, doubling the voltage yields an increase of 6 dB. The math for this depends on the simple fact that squaring a number multiplies its logarithm by 2. We therefore use 20 log10(2/1) = 20 × 0.3 = 6. To double the subjective loudness of a sound requires about ten times the power, so “twice as loud” means 10 dB higher: 10 log10(10/1) = 10 × 1 = 10. If all the math just makes you reach for the aspirin, just remember that a decibel is a logarithmic unit that enables us to cover a million-to-one scale with ease and clarity.

Tapers and Curves

Image placeholder title

FIG. 2: A fader''s taper is logarithmic with respect to voltage, spreading the useful dynamic range more evenly across its length.
Illustration by Chuck Dahmer

If a fader on a console were built so that voltage varied evenly across the fader's length, then it would lower the volume by only 6 dB at its halfway point, leaving the vast majority of the fader's useful range in the bottom half of its travel. This would make smooth fade-outs virtually impossible. Instead, a fader has a logarithmic taper (see Fig. 2) so that it makes much smaller voltage changes at the bottom of its travel than at the top. This configuration is sometimes called audio taper, and it allows the fader to change level consistently across its range. Another way to say this is that the fader is linear with respect to volume rather than linear with respect to voltage.

Synthesizer keyboards often feature logarithmic Velocity response so that the loudest volumes are reserved for only the highest few Velocities — those that require the greatest effort. This corresponds to the way acoustic instruments respond. Sometimes inverse logarithmic (aka exponential, of course) response can be assigned to controllers to allow finer resolution in the upper range of the control.

In the digital world, each bit of quantization doubles the resolution, so n-bit audio has a resolution of 2n quantization intervals. (This is true of fixed-point quantization — floating-point works a bit differently. See “Square One: How Your DAW Does Math” in the April 2007 issue of EM, available online at www.emusician.com.) Simultaneously, each bit doubles the voltage range that can be measured, increasing dynamic range by 6 dB. If this sounds suspiciously similar to the logarithmic nature of analog audio, it's no coincidence. PCM digital audio takes a quite literal approach to describing the analog waveform, so its structure is appropriately logarithmic.

Image placeholder title

FIG. 3: Most DAWs offer a variety of linear, logarithmic, and exponential fade curves.
Illustration by Chuck Dahmer

In most DAWs, a variety of exponential and logarithmic fade curves is available, in addition to a linear fade (see Fig. 3). Typically, a linear fade-out dies away too quickly at the end, just as a linear-taper fader has too little low-volume resolution. A logarithmic curve gets progressively shallower as the volume drops, yielding effectively better resolution at the bottom (see Web Clips 1 and 2).

Be a bit wary when you hear the terms logarithmic and exponential. If you exchange the x and y axes of a logarithmic curve, you get an exponential curve. For most musical purposes, we are using logarithms to describe exponential phenomena. This lets us speak in terms of decibels, minor thirds, and so forth and leave the serious number crunching to the pocket-protector crowd.

Brian Smithers is course director of audio workstations at Full Sail Real World Education. His latest book is Mixing in Pro Tools: Skill Pack (Thomson Learning, 2006).