Senior Design II
Final Report
Cody Butler
Mike Fergades
David Fritz
Hirotaka Maezawa
Fall 2006
Abstract
Speaker design, speaker placement, room interactions, and many other elements in the
Source/Speaker/Listener path interfere with the frequency response of the system from
the listeners reference position. This project corrects, to a reasonable tolerance, these
interactions, providing a flatline frequency response, for a given reference point. The
system acts as a digital audio equalizer within the tape monitor loop of a receiver. By
using a microphone connected to the equalizer situated at the listeners position, the
system generates test tones to characterize the room, speakers, and other elements in the
system that interfere with the frequency response. The system then creates a filter based
on this response, to normalize the frequency response of the system, and then applies the
filter in real time to an incoming audio stream. The effect is a more accurate sounding
audio system regardless of speaker type, room interactions, and listener position.
-2-
Table of Contents
Abstract ............................................................................................................................... 2
Table of Contents................................................................................................................ 3
1. Introduction..................................................................................................................... 4
2. Filter Design.................................................................................................................... 6
2.1 Initial Considerations ................................................................................................ 6
2.2 Filter Specifications .................................................................................................. 7
2.3 Filter Creation ......................................................................................................... 10
2.4 Filter Application .................................................................................................... 12
3. Implementation ............................................................................................................. 15
3.1 Implementation Overview ...................................................................................... 15
3.2 Hardware Overview ................................................................................................ 15
3.3 Filter Implementation.............................................................................................. 17
3.3.1 Interrupt Service Routine..................................................................................... 18
3.3.2 Main Path of Execution ....................................................................................... 20
3.4 User Interface Implementation ............................................................................... 23
4. Psychoacoustics Test .................................................................................................... 27
5. Results and Conclusions ............................................................................................... 30
5.1 Filter Results ........................................................................................................... 30
5.2 Filter Conclusions ................................................................................................... 34
5.3 Psychoacoustics Results.......................................................................................... 34
6. System Limitations ....................................................................................................... 36
6.1 Limitations Overview ............................................................................................. 36
6.2 Communication Speed Between The DSP Board and PC ...................................... 36
6.3 Calibration............................................................................................................... 36
6.4 Speaker type............................................................................................................ 37
7. Considerations and Tradeoffs ....................................................................................... 38
7.1 Considerations and Tradeoffs Overview ................................................................ 38
7.2 Frequency Resolution ............................................................................................. 38
7.2.1 Increase DSP Speed / Increase Memory.............................................................. 38
7.2.2 Analog bypass filter ............................................................................................. 39
8. Future Work .................................................................................................................. 40
8.1 Filter Improvements................................................................................................ 40
8.1.1 Live Feedback...................................................................................................... 40
8.1.2 Analog Bypass ..................................................................................................... 40
8.2 Psychoacoustics Tests Improvements..................................................................... 41
9. Acknowledgements....................................................................................................... 42
10. References................................................................................................................... 43
11. Appendix A................................................................................................................. 44
Specifications................................................................................................................ 44
-3-
1. Introduction
Audio played on loudspeakers is affected both by the loudspeakers themselves, and the
environment it is played in. By changing the environment, the listeners position, or the
speakers themselves, the frequency response of the system is changed. This concept leads
to the study of acoustic room correction.
Prior to the 1950s, it was common practice to simply ignore a rooms acoustic properties
[1]. In the late 1960s, room correction methods began to develop and large filters were
often custom designed for large halls to compensate for their acoustic properties.
This project aims to develop a digital signal processor based, automatic audio equalizer
that compensates for speaker and room aberrations present in any environment. This is
accomplished by means of producing a set of test tones, generated by the system, which
are recorded by a microphone placed at the listeners position. The recorded tones are
characterized to obtain a room and speaker response, and used to create a filter that when
applied to an audio stream, produces a normalized frequency response.
-4-
Section 2 provides a discussion of the filter algorithm, its design and a comparison of
other possible filter choices. Section 3 discusses the implementation of the system.
Section 4 discusses the psychoacoustic tests. Section 5 details the conclusions and results
from the normalized frequency response filter and its implementation, and the
psychoacoustic tests. Further sections provide concluding remarks, references, and
necessary appendices.
-5-
2. Filter Design
2.1 Initial Considerations
On designing the filter algorithm for this project, several key considerations were noted.
The filter algorithm would have to be optimized for audio applications and for the
hardware we used for testing. Specifically, CD quality audio would be a minimum
requirement, as well as the filter working over the entire range of human hearing. An
immediate limitation of the test equipment having a frequency response no lower than
30Hz limited the filter operating range to that of 30Hz to 22050Hz.
After a literature search, the Audio Team concluded that the use of a finite impulse
response filter (FIR) would best serve the application presented. The benefits of using an
FIR filter over an infinite impulse response (IIR) filter are numerous and detailed in
Table 1.
Finite Impulse Response
Strengths
Weaknesses
Easy to implement Computationally
more expensive
Stable
Uses more memory
Linear Phase
Simple filter
creation
-6-
10.7
Hz/bin
dB
1
44.1
kHz (CD Quality)
Finite Impulse Response
Linear (Constant Delay)
200
ms MAX
2
left and right channel
dB (per band)
12
Variable
<200Hz: 100Hz
>200Hz: 1/3rd Octave
4096
Taps
Table 2. Filter specific specifications
Note that in Table 2, a 10.7Hz/bin frequency resolution is given. This comes from the
choice to use a 44.1 kHz sample rate with a 4096 point FFT algorithm. During the course
of this project, several people questioned whether this granularity would be sufficient for
the design. After research, it was found to be sufficient due to the critical band masking
effect that occurs in human hearing.
Backus [2] describes the critical bands as bandwidths over which two tones listened to
within the critical band are indistinguishable in loudness. This is due to physiological
processes in the human auditory system and the critical band is generally accepted to be
approximately 1/3rd of an octave. This bandwidth is on an octave scale since human
hearing is logarithmic. Since 1/3rd of an octave above our filter base frequency of 30Hz is
1
Precision at which amplitude of frequency components in each bin can be adjusted. The nominal value of
1dB is a worst case condition.
-7-
Evidence of this results from a test performed on several students and faculty by playing
unfiltered audio vs. filtered audio (with the filter being an allpass filter). The subjects
were asked to identify differences (if any) they could distinguish between the two signals.
Even when told which stream they were listening to, not one subject could identify a
difference between the signals. This further concludes that signal reconstruction is
possible with the given frequency resolution.
Linear phase is achieved simply by setting the phase component of our filter to a constant
(in our case 0).
The delay specification is derived from the filter length and sample rate. The time to
buffer 4096 samples at 44.1 kHz is ~93ms. With a full buffer being required to filter, as
described later, twice the amount of time is required to buffer, filter, and play audio,
bringing the total delay to 186ms. The delay maximum was rounded to the nearest 100.
Tests were performed on several students and faculty members to test if the 186ms delay
was noticeable when using controls on a CD player. No subjects were able to distinguish
a delay difference.
-8-
A correction range of 12db is given for practical reasons. If a signal were boosted
beyond the limits of the audio codec, distortion would occur due to clipping at the codec
output. For this reason the input signal is pushed down 12db upon buffering, and then
adjusted according to the filter coefficients. This way, no input signal can be boosted
beyond the normal maximum output level.
1/3rd octave smoothing is implemented during filter creation, as discussed in section 2.3,
to prevent correcting for spikes in the recorded signal generated due to noise or other
aberrations.
Finally, a 4096 tap filter was chosen due to limitations in resources on the DSP board and
to maintain the realtime constraint as given in the problem statement. The FFT
algorithm employed in this design is a radix-4, decimation in frequency, complex Fast
Fourier Transform. Due to the radix, only filter lengths of powers of 4 can be used. The
next power of four above 4096 is 16384, causing the DSP board to run out of several
resources (CPU time and memory), and creates an unnatural delay of almost 750ms. This
is easily detected by the user and is considered not to be realtime.
-9-
Following signal generation and recording, an FFT is performed on the entire buffer and
normalized by dividing it by the known reference signal. This can also be considered as
the impulse response of the system. This normalized signal represents the rooms transfer
function. In order to receive a flatline frequency response, the filter must nullify this
transfer function. Simply finding the reciprocal of the transfer function satisfies this
requirement such that H ( j )
1
= 1 for all .
H ( j )
As shown in Figure 1, the amplitude of the normalized response of the system is very
noisy. This is possibly due in part to room reverberation. As the sweep is played, low
frequency components reflect and interfere with higher frequency components that are
currently being recorded. This can interfere with the amplitude response. In order to
compensate for this effect, a 1/3rd octave block moving average smoothing filter is
applied to the filter at this point, also shown in Figure 1.
- 10 -
Unsmoothed Response
Gain (dB)
50
-50
0
10
10
10
10
Frequency (Hz)
Smoothed Response
10
10
60
Gain (dB)
40
20
0
-20
-40
0
10
10
10
10
Frequency (Hz)
10
10
Figure 1. Unsmoothed and smoothed amplitude response of a filter. Note the amount of noise in the
unsmoothed response.
After smoothing, the filter is clipped at 12dB and stored into a filter array for
application.
The entire process is completed twice, once for the left channel, and again for the right.
During calibration, the left or right channel is automatically disabled to prevent
interference to the other.
- 11 -
Generate
Calibration
Audio
Record
Calibration
Audio
Normalize
Find Reciprocal
Clip at 12db
- 12 -
0.5
0
-0.5
-1
100
200
300
400
500
Time
600
700
800
900
1000
100
200
300
400
500
Time
600
700
800
900
1000
1
0.5
0
-0.5
-1
- 13 -
Filter Array
Buffer
FFT
IFFT
- 14 -
3. Implementation
3.1 Implementation Overview
The Digital Audio Equalizer required two major components to be implemented A
filter implementation containing filter calibration, application, and control software
running on a Digital Signal Processor, and a graphical user interface running on a host PC
for interfacing to the DSP. Initially, the DSP implementation was intended to run
autonomously without any user intervention whatsoever. However, as features were
added to the design it became apparent that a user interface would be required.
- 15 -
225MHz
192kb SRAM
8 Instructions / cycle
- 16 -
Figure 6 The Behringer ECM8000 frequency response. Note that over the range of human hearing, the
response does not deviate from the flatline by more than 3db.
- 17 -
Check Status
Passthrough
Mute
Output = Input
Output = 0
Filter
NO
Calibrate
YES
Buffer full?
Swap buffers
output buffer = work buffer
work buffer = input buffer
input buffer = output buffer
Sweep Buffer
Full?
NO
YES
Set
channel done
flag
Output = 0
Return
Figure 7. Flow diagram of the Interrupt Service Routine on the DSP board.
- 18 -
For passthrough mode, the ISR simply outputs to the receiver the current input sample
from the audio codec. No filtering is done.
For mute mode, the ISR simply outputs nothing to the receiver. No filtering is done.
In Filter mode, the ISR manages a three buffer system of data used for input, output, and
filtering. At each ISR entry, the incoming audio sample is stored to an input buffer and a
sample from the output buffer is played to the receiver. If the ISR detects that the input
buffer is full, it performs a buffer switch. The input buffer is swapped into the work
buffer, which is then flagged to be filtered by the main path of execution. The work
buffer, which has already been filtered, is swapped into the output buffer for playback.
Finally the output buffer, which contains invalid data, is recycled to the input buffer for
new data.
In calibrate mode, the ISR plays a sample from a previously generated logarithmic sweep
(30Hz to 22050Hz). This sweep is 32768 samples in length (743ms). The ISR also stores
a sample from the microphone input to a large buffer to be worked on after the sweep has
been played. When the sweep is complete, the ISR marks a channel done flag. This flag
- 19 -
Before the ISR returns to the main path of execution, a read command is issued to
attempt to receive a new mode flag from the user interface. The command is nonblocking and is scheduled by the real time operating system running on the DSP to
handle any incoming data. If data exists, the mode flag is set to the new value.
- 20 -
Filter
Passthrough
Calibrate
Apply Window
FFT
User
Flatline
Filter Mode
Play sweep
FFT
Smooth
Apply Filter
Normalize
Apply Psychoacoustic Filter
Apply filter to
original sweep
YES
First Pass?
IFFT
NO
For both the mute and passthrough status modes, nothing is done within the main path,
and a simple busy wait occurs.
If the status mode is set to filter, the main path first checks if the work buffer (described
in 3.3.1) has been flagged for filtering. If so, the filter operation occurs as detailed in
section 2.4. After filtering, the block flag is cleared and a busy wait occurs until either the
status mode changes or a new work buffer is prepared.
If the status mode is set to calibrate, the main path coordinates calibration with the ISR.
First, by generating a logarithmic sweep, setting output to the left channel only, and
clearing the channel done flag, the main path waits for the ISR to play and record the
- 21 -
- 22 -
The user interface is written in C++ with Microsoft Foundation Class in Visual Studio
2005. Since the only communication to the board is via USB, most common Windows
XP systems should be able to run the software without any problems.
- 23 -
If the user chooses to supply his or her own filter data, a User Defined option is
provided. A file format has been defined as containing two columns of floats and 4096
rows. It would appear as:
1.00
1.01
1.02
.
.
.
1.50
.500
.501
.502
.
.
.
1.00
The left column represents the left channel filter spectra and the right column represents
the right channel. This format contains no phase adjustment capability. The first row
represents the most negative frequency (-22050Hz), with the midpoint being 0Hz (DC).
The data should be symmetric about the midpoint. To set a user defined filter, select the
User Defined radio button, select the file in the Filename field, and click the
Download button. The Download button appears where the Calibrate button is in
Figure 9.
A third radio button Passthrough mode is available to apply no filter to the audio
stream.
- 24 -
The Toggle Input button is used to switch between microphone and line-in inputs. This
is used primarily for testing the microphone and this button is not used for calibration.
The device automatically switches between line-in and microphone input during
calibration.
A choice of four filters (detailed in section 4) is given. To perform a double blind test, a
Double Blind button is provided that randomizes the filters and masks the names as
shown in figure 11.
- 25 -
Finally, two plot windows are provided to allow the user to view the filter and filter
effectiveness spectra. Three plots exist on each of the two channel windows. The red plot
shows the unfiltered frequency response of the room with respect to the listeners
position. The blue plot shows the filter spectra. Finally, the green plot shows the filtered
frequency response.
- 26 -
4. Psychoacoustics Test
Psychoacoustics is the study of the psychology of the human perception of sound [5].
Psychoacoustics is a subjective measurement, not an objective measurement. Therefore,
personal preference, the persons mood, and a host of other psychological factors can
come in to play when making use of the mental framework of the psychoacoustic field.
Double blind tests were conducted in order to study how listeners would rate audio that
had been room corrected and then processed in with additional filters shown in figure 12.
- 27 -
Filter 1
dB
0
-6
Filter 3
Filter 2
dB
dB
6
0
6k
-5
300
Frequency (Hz)
6k
30
Frequency (Hz)
6k
Frequency (Hz)
Figure 12 Filters (1) Low end boost (2) Midrange boost (3) Low and High boost
Figure 13 shows how the tests were set up. The room correction device was first allowed
to characterize the rooms response with respect to the position of the listener. The
listener / test subject is then brought in and seated with a wireless keyboard which
allowed them to interact with the computer which is controlling the room corrector.
A song is played on a set-top CD player and passed through the equalizer. With the
keyboard, the user can switch between several versions of the room correction filter. The
first is just a filter which created a flatline response. There are three additional filters
which are then applied on top of the flatline filter. These additional filters, shown in
figure 12 are as follows:
- 28 -
Using the psychoacoustics menu on the user interface running in double blind mode, the
user selects between the four filters and rates them from most favorite to least favorite.
Since the test is double blind, the information telling which letter corresponded to which
filter is not revealed to anyone until the test is done. This made sure that the testers do
not unduly influence the test.
- 29 -
Figure 14. Filter performance evaluation. The blue plot is the unfiltered response,
the green is the filtered response. The gray band is the target 3dB band for the filter.
This response was generated by Boston Acoustics Speakers, listening point was at 6 feet
directly facing the speakers.
By the end of the allotted project design time, all specifications as given in Appendix A
have been met. The filter corrects the room response with respect to the listeners
position to within a 3dB band in most configurations. Certain other configurations cause
the improvement to deteriorate. Several examples are shown on the following pages.
- 30 -
Figure 15 shows an evaluation of correction with a pair of Boston Acoustics speakers and
the listening position at 1 foot from the speakers. Note that the low frequency mode near
100Hz is not corrected very well. Most of the unfiltered response is situated above the
flatline. Likely, the user should lower the volume on the receiver slightly and attempt to
recalibrate.
- 31 -
Figure 16 shows a pair of Paradigm speakers with the listening point at 5.5 feet. The
signal is easily corrected to within the 3dB band.
Figure 17 Paradigm speakers with microphone 5.5 feet away and speakers rotated 45 degrees.
Figure 17 shows the Paradigm speakers with the listening position at 5.5 feet, with the
speakers turned in at 45 degrees. Again, the correction works quite well. Notice the
second mode near 200Hz, likely caused by a room reflection.
- 32 -
The Paradigm speakers are again used in figure 18. The listening point is in the corner of
the room, facing the speakers. While not entirely visible here, human subjects noticed a
large bass boost when listening from the corner of the room.
Figure 19 Paradigm speakers with microphone placed in open metal cabinet adjacent to speakers.
Paradigm speakers are used again in figure 19, with the listening position inside a metal
cabinet. We are very surprised with the results. Notice the large null near 2kHz.
- 33 -
The test results, shown in figure 20, show that the midrange boost filter, when applied to
the flat line response, was the most popular. The least popular was the filter which
boosted the bass and high frequencies. The error bars shown in figure 20 show that it is
not possible to determine which filter came in first, but the midrange filter does have a
lead over all the other filters error bars aside. Surprisingly, the flatline room corrected
filter came in second or third.
- 34 -
The results differ from what was expected. We thought that the flatline response and the
bass and treble boosting filters would be the preferred choices of listeners, but that is not
the case.
It has been found that a flatline room response is not the best or most desirable type of
filter, but it could serve as a good starting point upon which additional filters could be
added.
Several other considerations for this test have been made and are discussed in section 8.2.
- 35 -
6. System Limitations
6.1 Limitations Overview
This system has several practical limitations that were not resolved for several reasons
including time constraints, lack of equipment, small budget, and lack of knowledge in the
field of acoustics engineering.
6.3 Calibration
The major limitation of the calibration phase is that the user must adjust the volume
manually to ensure proper calibration. The reason this is inconvenient is because the
calibration phase takes approximately 30 seconds. If the volume is too high, the filter
will clip and not be calibrated properly. The same will occur if the volume is too low. If
this occurs, the user must adjust the volume appropriately and re-calibrate.
- 36 -
- 37 -
- 38 -
- 39 -
8. Future Work
8.1 Filter Improvements
8.1.1 Live Feedback
A possible entry point for a future redesign of this project would be to add a live
feedback system to the filter. This would incorporate constant microphone recording
from the listeners position to account for changing room noise or other interferences. A
major hurdle to overcome in this addition would be the delay shift from audio output to
the microphone. Sound travels relatively slow through air and the system would have to
be aware of the distance from the speakers that the listener was at. The system could use
this data to look ahead in the audio stream to make dynamic filter corrections based on
current room conditions.
- 40 -
It is thought that having a larger sample size will allow for an increased understanding of
how people, in general, perceive the filtered test music. A larger sampling of listeners is
recommended for any future tests performed.
In the tests a single song, Les Toreadors, from the Carmen Suite, was used. The use of
a variety of types of music would make the testing procedure much longer but would
perhaps allow for a better understanding of how people rate the different filters.
Listeners expect different types of results from different types of music. Orchestral
music is often expected to be very clear and precise. In orchestral music, a listener is
much more likely to react negatively to dissonance caused by a bad listening
environment. In other types of music, such as heavy metal, the dissonance caused by a
bad listening environment might be less bothersome to the listener.
The use of an anechoic chamber would be beneficial in terms of studying the listeners
response to music. The anechoic chamber would ideally remove any reflections or
reverberations that exist in a normal room which would make the room correction much
easier and possibly not necessary, reducing influences to the test made by shortcomings
of the flatline filter.
- 41 -
9. Acknowledgements
We would like to thank Dr. Damon Chandler for his devoted effort to our project and our
sanity during this last semester. Dr. Chandler provided endless ideas and suggestions that
gave our team the ability to complete our project. His interest in our well being and
defense of our design proved invaluable when criticism came our way. Thank you.
We would also like to thank Dr. Jim West, Dr. Keith Teague, Dr. Sohum Sohoni, Dr.
Jack Allison, Dr. Rao Yarlagadda, and Dr. Alan Cheville for their input both in design
ideas and equipment.
A very special thanks goes to the entire fourth floor of Engineering South. We apologize
for playing that logarithmic sweep that loud so often this semester.
- 42 -
10. References
[1] Ronald Genereux, Adaptive Filters for Loudspeakers and Rooms, in 93rd
Convention of Audio Engineering Society, 1992.
[2] Backus, John, The Acoustical Foundations of Music, 2nd Ed, W W Norton, New
York, 1977
[3] Dr. Chandler, (personal communication), August 31, 2006.
[4] Helms, H.D. Fast Fourier Transform Methods of Computing Difference Equations
and Simulating Filters. IEEE Transactions on Audio and Electroacoustics, AU-15,
No. 2 (June, 1967), pp. 85-90.
[5] Wikipedia Contributors, Wikipedia, The Free Encyclopedia, Psychoacoustics,
September 29, 2006, http://en.wikipedia.org/wiki/Psychoacoustics.
- 43 -
11. Appendix A
Specifications
Filter Specifications
Frequency Resolution
Amplitude Resolution2
Sample Rate
Filter Type
Phase
Total Delay
Number of Filters
Correction Range
Smoothing Bandwidth
10.7
1
44.1
Finite Impulse Response
Linear (Constant Delay)
250
2
12
Variable
<200Hz: 100Hz
>200Hz: 1/3rd Octave
Hz/bin
dB
kHz (CD Quality)
ms MAX
left and right channel
dB (per band)
5
3
VDC
ADC MAX
Mechanical Specifications
Board Length
Board Width
Case Length
Case Width
Case Height
Total Weight
Case Material
8.75
4.50
10.25
5.00
1.50
68.5
Aluminum Body, Steel Hinge
inch
inch
inch
inch
inch
ounce
User Interface
A Win32 application is used for calibration, demonstration, and debugging.
The software provides:
Precision at which amplitude of frequency components in each bin can be adjusted. The nominal value of
1dB is a worst case condition.
- 44 -