Logarithms and Decibels
This appendix provides an introduction to logarithms (real and complex) and decibels, a quantitative measure of sound intensity. Several specific dB scales are defined, and dynamic range considerations in audio are considered.Logarithms
A logarithm is fundamentally an exponent applied to a specific base to yield the argument . That is, . The term ``logarithm'' can be abbreviated as ``log''. The base is chosen to be a positive real number, and we normally only take logs of positive real numbers (although it is ok to say that the log of 0 is ). The inverse of a logarithm is called an antilogarithm or antilog; thus, is the antilog of in the base . For any positive number , we have>> x = log(3) x = 1.0986 >> characteristic = floor(x) characteristic = 1 >> mantissa = x  characteristic mantissa = 0.0986 >> % Now do a negativelog example >> x = log(0.05) x = 2.9957 >> characteristic = floor(x) characteristic = 3 >> mantissa = x  characteristic mantissa = 0.0043Logarithms were used in the days before computers to perform multiplication of large numbers. Since , one can look up the logs of and in tables of logarithms, add them together (which is easier than multiplying), and look up the antilog of the result to obtain the product . Log tables are still used in modern computing environments to replace expensive multiplies with lessexpensive table lookups and additions. This is a classic tradeoff between memory (for the log tables) and computation. Nowadays, large numbers are multiplied using FFT fastconvolution techniques.
Changing the Base
By definition, . Taking the log base of both sides givesLogarithms of Negative and Imaginary Numbers
By Euler's identity, , so thatDecibels
A decibel (abbreviated dB) is defined as one tenth of a bel. The bel^{F.1} is an amplitude unit defined for sound as the log (base 10) of the intensity relative to some reference intensity,^{F.2} i.e., The choice of reference intensity (or power) defines the particular choice of dB scale. Signal intensity, power, and energy are always proportional to the square of the signal amplitude. Thus, we can always translate these energyrelated measures into squared amplitude: Since there are 10 decibels to a bel, we also haveProperties of DB Scales
In every kind of dB, a factor of 10 in amplitude increase corresponds to a 20 dB boost (increase by 20 dB):
dB
A function which is proportional to is said to fall off
dB per octave. That is, for every factor of in
(every ``octave''), the amplitude drops close to dB. Thus, 6 dB
per octave is the same thing as 20 dB per decade.
A doubling of power corresponds to a 3 dB boost:
dB
Finally, note that the choice of reference merely determines a
vertical offset in the dB scale:
Specific DB Scales
Since we so often rescale our signals to suit various needs (avoiding overflow, reducing quantization noise, making a nicer plot, etc.), there seems to be little point in worrying about what the dB reference iswe simply choose it implicitly when we rescale to obtain signal values in the range we want to see. In particular, dB relative to full scale ( ), abbreviated dBFS, is perhaps the most commonly used case in the digital audio world. Thus, 0 dBFS means maximum amplitude, and typical amplitude levels are negative in dBFS. In addition, there are a few specific dB scales that are worth knowing about.DBm Scale
One common dB scale in audio recording is the dBm scale in which the reference power is taken to be a milliwatt (1 mW) dissipated by a 600 Ohm resistor. (See §F.3 for a primer on resistors, voltage, current, and power.)DBV Scale
Another dB scale is the dBV scale which sets 0 dBV to 1 volt. Thus, a 100volt signal is
40 dBV
and a 1000volt signal is
60 dBV
Note that the dBV scale is undefined for current or power, unless the
voltage is assumed to be across a standard resistor value, such as 600
Ohms.
DB SPL
Sound Pressure Level (SPL) is defined using a reference which is approximately the intensity of 1000 Hz sinusoid that is just barely audible (zero ``phons''). In pressure units:^{F.3}

In my experience, the ``threshold of pain'' is most often defined as 120 dB. The relationship between sound amplitude and actual loudness is complex [76]. Loudness is a perceptual dimension while sound amplitude is physical. Since loudness sensitivity is closer to logarithmic than linear in amplitude (especially at moderate to high loudnesses), we typically use decibels to represent sound amplitude, especially in spectral displays. The sone amplitude scale is defined in terms of actual loudness perception experiments [76]. At 1kHz and above, loudness perception is approximately logarithmic above 50 dB SPL or so. Below that, it tends toward being more linear. The phon amplitude scale is simply the dB scale at 1kHz [76, p. 111]. At other frequencies, the amplitude in phons is defined by following the equalloudness curve over to 1 kHz and reading off the level there in dB SPL. In other words, all pure tones have the same loudness at the same phon level, and 1 kHz is used to set the reference in dB SPL. Just remember that one phon is one dBSPL at 1 kHz. Looking at the FletcherMunson equalloudness curves [76, p. 124], loudness in phons can be read off along the vertical line at 1 kHz. Classically, the intensity level of a sound wave is its dB SPL level, measuring the peak timedomain pressurewave amplitude relative to watts per centimeter squared (i.e., there is no consideration of the frequency domain here at all). Another classical term still encountered is the sensation level of pure tones: The sensation level is the number of dB SPL above the hearing threshold at that frequency [76, p. 110]. For further information on ``doing it right,'' see, for example,
http://www.measure.demon.co.uk/Acoustics_Software/loudness.html.
DBA (AWeighted DB)
The socalled Aweighted dB scale (abbreviated dBA) is based on the FletcherMunson equalloudness curve for an SPL of 40 phons.^{F.4} Thus, a dBA weighting assumes a fairly quiet pure tone. Despite this assumption, the dBA weighting is often used as an approximate equal loudness adjustment for measured spectra. An analog filter transfer function that can be used to implement an approximate Aweighting is given by^{F.5}DB for Display
In practical signal processing, it is common to choose the maximum signal magnitude as the reference amplitude. That is, we normalize the signal so that the maximum amplitude is defined as 1, or 0 dB. This convention is also used by ``sound level meters'' in audio recording. When displaying magnitude spectra, the highest spectral peak is often normalized to 0 dB. We can then easily read off lower peaks as so many dB below the highest peak. Figure F.1b shows a plot of the Fast Fourier Transform (FFT) of ten periods of a ``Kaiserwindowed'' sinusoid at Hz. (FFT windows are introduced in §8.1.4. The window is used to taper a finiteduration section of the signal.) Note that the peak dB magnitude has been normalized to zero, and that the plot has been clipped at 100 dB. Below is the Matlab code for producing Fig.F.1. Note that it contains several elements (windows, zero padding, spectral interpolation) that we will not cover until later. They are included here as ``forward references'' in order to keep the example realistic and practical, and to give you an idea of ``how far we have to go'' before we know how to do practical spectrum analysis. Otherwise, the example just illustrates plotting spectra on an arbitrary dB scale between convenient limits.% Practical display of the fft of a synthesized sinusoid fs = 44100; % Sampling rate f = 440; % Sinusoidal frequency = A440 nper = 10; % Number of periods to synthesize dur = nper/f; % Duration in seconds T = 1/fs; % Sampling period t = 0:T:dur; % Discretetime axis in seconds L = length(t) % Number of samples to synthesize ZP = 5; % Zero padding factor N = 2^(nextpow2(L*ZP)) % FFT size (power of 2) x = cos(2*pi*f*t); % A sinusoid at A440 ("row vector") w = kaiser(L,8); % An "FFT window" xw = x .* w'; % Need to transpose w to get a row sound(xw,fs); % Might as well listen to it xzp = [xw,zeros(1,NL)];% Zeropadded FFT input buffer X = fft(xzp); % Interpolated spectrum of xw Xmag = abs(X); % Spectral magnitude Xdb = 20*log10(Xmag); % Spectral magnitude in dB XdbMax = max(Xdb); % Peak dB magnitude Xdbn = Xdb  XdbMax; % Normalize to 0dB peak dBmin = 100; % Don't show anything lower than this Xdbp = max(Xdbn,dBmin); % Normalized, clipped, dB mag spec fmaxp = 2*f; % Upper frequency limit of plot, Hz kmaxp = fmaxp*N/fs; % Upper frequency limit of plot, bins fp = fs*[0:kmaxp]/N; % Frequency axis in Hz % Ok, plot it already! subplot(2,1,1); plot(1000*t,xw); xlabel('Time (ms)'); ylabel('Amplitude'); title(sprintf(['a) %d Periods of a %3.0f Hz Sinusoid, ', 'Kaiser Windowed'],nper,f)R); subplot(2,1,2); plot(fp,Xdbp(1:kmaxp+1)); grid; % Plot a dashed line where the peak should be: hold on; plot([440 440],[dBmin,0],''); hold off; xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)'); title(sprintf(['b) Interpolated FFT of %d Periods of ',... '%3.0f Hz Sinusoid'],nper,f));The following more compact Matlab produces essentially the same plot, but without the nice physical units on the horizontal axes:
x = cos([0:2*pi/20:10*2*pi]); % 10 periods, 20 samples/cycle L = length(x); xw = x' .* kaiser(L,8); N = 2^nextpow2(L*5); X = fft([xw',zeros(1,NL)]); subplot(2,1,1); plot(xw); xlabel('Time (samples)'); ylabel('Amplitude'); title('a) 10 Periods of a KaiserWindowed Sinusoid'); subplot(2,1,2); kmaxp = 2*10*5; Xl = 20*log10(abs(X(1:kmaxp+1))); plot([10*5+1,10*5+1],[100,0],[0:kmaxp],max(Xlmax(Xl),100)); grid; xlabel('Frequency (Bins)'); ylabel('Magnitude (dB)'); title('b) Interpolated FFT of 10 Periods of Sinusoid');
Dynamic Range
The dynamic range of a signal processing system can be defined as the maximum dB level sustainable without overflow (or other distortion) minus the dB level of the ``noise floor''. Similarly, the dynamic range of a signal can be defined as its maximum decibel level minus its average ``noise level'' in dB. For digital signals, the limiting noise is ideally quantization noise. Quantization noise is generally modeled as a uniform random variable between plus and minus half the least significant bit (since rounding to the nearest representable sample value is normally used). If denotes the quantization interval, then the maximum quantizationerror magnitude is , and its variance (``noise power'') is (see §G.3 for a derivation of this value). The rms level of the quantization noise is therefore , or about 60% of the maximum error. The number system (see Appendix G and number of bits chosen to represent signal samples determines their available dynamic range. Signal processing operations such as digital filtering may use the same number system as the input signal, or they may use extra bits in the computations, yielding an increased ``internal dynamic range''. Since the threshold of hearing is near 0 dB SPL, and since the ``threshold of pain'' is often defined as 120 dB SPL, we may say that the dynamic range of human hearing is approximately 120 dB. The dynamic range of magnetic tape is approximately 55 dB. To increase the dynamic range available for analog recording on magnetic tape, companding is often used. ``Dolby A'' adds approximately 10 dB to the dynamic range that will fit on magnetic tape (by compressing the signal dynamic range by 10 dB), while DBX adds 30 dB (at the cost of more ``transient distortion'').^{F.7} In general, any dynamic range can be mapped to any other dynamic range, subject only to noise limitations.Voltage, Current, and Resistance
The state of an ideal resistor is completely specified by the voltage across it (call it volts) and the current passing through it ( amperes, or simply ``amps''). The ratio of voltage to current gives the value of the resistor ( resistance in Ohms). The fundamental relation between voltage and current in a resistor is called Ohm's Law:
(Ohm's Law)
where we have indicated also that the voltage and current may vary
with time (while the resistor value normally does not).
The electrical power in watts dissipated by a resistor R
is given by
Exercises
 Show that
 Work out the definition of logarithms using a complex base .
 Try synthesizing a sawtooth waveform which increases by 1/2 dB a few times per second, and again using 1/4 dB increments. See if you agree that quarterdB increments are ``smooth'' enough for you.
Next Section:
Number Systems for Digital Audio
Previous Section:
Taylor Series Expansions