[music-dsp] Digital Filter
James Chandler Jr
jchandjr at bellsouth.net
Tue Jan 8 17:30:15 EST 2002
If you want to analyze rooms with sine waves, it might be wise to use a very
slow swept sine wave. Beware, keep a modest speaker amplitude, and cover
your ears when it gets to the high frequencies (G). Using a
constant-amplitude sine wave, the higher frequencies can be dangerous to
speaker tweeters and painful to ears.
Fixed-frequency sine waves have problems for room analysis-- rooms typically
have lots of fine detail in amplitude response, which can vary 20 dB or more
between very close frequency intervals.
You can easily find situations where the response to a 1000 Hz sine wave
might be drastically louder or quieter than the response to a 999 Hz or 1001
Hz sine wave.
With a swept sine wave, you can record the response at all frequencies, and
either visually or mathematically smooth out these fine-grain amplitude
The sine sweep should be slow to increase the frequency resolution of your
measurement. Rooms can "ring" at some frequencies. On a fast sweep, a
ringing frequency will confuse the measurement of frequencies following the
As a dumb example, perhaps you could construct a test WAVE file (or
synthesize the audio in real-time)-- a sine that sweeps from 20 Hz to 20,000
Hz in 40 seconds. Do the math so the wave sweeps up 1 octave every 4
seconds. Then you could view the recorded room response in an ordinary audio
graphic editor program, and exactly determine the frequency of peaks and
dips. The first four seconds of the file represents 20 Hz to 40 Hz, the next
four seconds represents 40 Hz to 80 Hz, etc.
With sine wave test tones, you don't particularly need to use a bandpass
filter on the recorded room response, unless possibly there is a lot of
extraneous noise in the room you want to try to filter out.
If you want to calculate the amplitude and draw a graph, rather than just
visually examine the response in an audio editor program, you would measure
the absolute value of small pieces of the room response file.
At 20 Hz, each wave cycle has a duration of 50 mS, so down there your
"measurement window" would need to be AT LEAST 50 mS wide to properly
measure the peak absolute value of the signal. As the frequency increases,
the wave period decreases, and you could use narrower measurement windows at
higher frequencies. Its would be simplest to pick a measurement window big
enough for the bass, and then use the same size thruout the frequency range.
There are many approaches to measuring the amplitude of the recorded room
response. You could use fixed-duration "bins" and just get the Max absolute
value peak in each time slot. Perhaps calculate the peak value of the room
response sine wave file in 400 mS bins. 2.5 measurements per second, 10
frequency bins per octave if you used a 40 second exponential sine sweep.
Rather than the Peak absolute value, you can also measure the average
absolute value or RMS value in each time slot. Its a matter of taste, and
what kind of information you want to retrieve.
Or you could use an algorithm for a decaying Peak, Average, or RMS
measurement, to emulate the response of some audio level meter standard.
Meter standards typically specify an attack and decay time, the time it
takes for the meter to rise to full level after a signal hits, and the time
it takes for the meter to fall to zero after the signal ends.
Once you have an array of frequency-vs-amplitude measurements, you can chart
it in dB rather than raw numbers--
AmplitudedB = 20 Log10(BinAmplitude/ReferenceAmplitude);
It might be convenient to pick the loudest bin as your ReferenceAmplitude.
That way one bin will read 0 dB, and the rest of the bins will measure in
negative dB below the loudest bin. No matter whether different response
files are loud or soft, you can directly compare different frequency
response charts, since they are always referenced against the loudest bin in
James Chandler Jr.
dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links
More information about the music-dsp