Marco Faldetta BSc Music Technology Year 4 Preface
Final Year Project
vii
Chapter three is an investigation on sound cards and sound card connections.
This was the first task in the time schedule for this project, it was necessary to
understand how sound cards are accessed by software and what sound card
would be ideal for the purposes of this project.
Chapter four investigates the available developing tools for audio software in
Windows. In addition, an overview of audio DirectX is given. This was the
second task on the time schedule.
Chapter five describes how a full duplex application was developed. It also
tries to clarify the use of DirectX objects necessary for such a piece of
software.
The appendixes contain clarifications about subjects covered in the report, a
code listing and the time schedule as laid out in the preliminary report.
Chapter 1
Introduction
1.1 Sound, noise and Active Noise Control
Our world is surrounded by sounds. We rely on our hearing to understand our
environment better, to communicate with people and even to relax and have
fun by listening to music.
Not all sounds that surround us are the same; being unpleasant, some of
them can be classified as noise. Noise can be described as unwanted sound.
In the context of the human environment, noise is normally sound which
causes annoyance or disturbs activities. Generally it can be said that sound
becomes unwanted when:
• It hinders speech communication
• It impedes thinking processes
• It interferes with concentration
• It obstructs activities (work or leisure)
• It presents a health risk due to hearing damage.
1
1
What is Noise? http://www.quiet.org.uk/
Marco Faldetta BSc Music Technology Year 4 Chapter 1
Final Year Project
2
The impact of noise on hearing, health and the quality of life can be no longer
disputed. Numerous studies can be found to document that noise, like other
stressors, is related to negative physical and psychological changes in
humans. Individuals and communities do not accept noise anymore as natural
by-product of an industrial society. Means of keeping the noise levels down
are therefore required.
Passive methods to attenuate unwanted noise have been developed using
techniques such as enclosure, barriers and silencers. Covering a broad
frequency range, passive noise attenuators are very effective devices, but
they can be large, expensive and ineffective at low frequencies.
An alternative to passive sound attenuation is Active Noise Control (ANC).
ANC is a method used to reduce noise by measuring sound waves from a
specific source and then creating equal and opposite secondary waves to
cancel out the primary sound.
If two pebbles were tossed into a pool, the waves they generated could meet
and possibly cancel each other out. This principle is known as destructive
interference.
Sound waves work in a very similar way to water waves with the difference
that the disturbance occurs in air.
The whole point of ANC is to match up the positive and negative
disturbances, or pressures, created by sound waves and thus to neutralise
Marco Faldetta BSc Music Technology Year 4 Chapter 1
Final Year Project
3
noise. Sommerfeldt explains: "Pressures add together just like numbers do,
so if you have a 2 and a -2, then you've got zero."
The concept of ANC was patented by
German scientist Paul Lueg in the 1930s,
laying the foundations for today’s research.
However, since active noise control requires
measurements much more precise than he
could obtain with vacuum tubes, the idea
didn't take off at that time.
Figure 1.1 - Paul Lueg’s ANC
system
With the advent of computer chip technology and digital signal processors,
active noise control was reborn in the mid-1980s.
The study of ANC has only recently been applied to practical applications, and
until recently studies have concentrated on noise reduction in confined
spaces. ANC devices exist to attenuate noise in airplane cabins, headsets
and air conditioning devices, but very little has been done for noise
cancellation in free space.
1.2 The ANC Group
Since 1994 the University of Huddersfield has been home to a research
project aimed at achieving the cancellation of unpleasant acoustic noise in
open spaces. Work has been undertaken to bring this dream closer to reality.
Marco Faldetta BSc Music Technology Year 4 Chapter 1
Final Year Project
4
The System that is used by the team today is based on a TMS320C32 DSP
board. It is a Digital Signal Processor, and requires specially designed
programs to perform its calculations. The existing programs were created with
a C compiler designed to work with the board. All the computer programs
used in the project are DOS based.
To accomplish the task of cancelling unpleasant noise, the Active Noise
Control system uses microphones, speakers, an amplifier, an oscillator, an
ADC (analogue-to-digital converter) and DAC (digital-to-analogue converter)
as illustrated in figure 1.2.
DSP
D/A A/D
Power
Amp.
Power
Amp.
Phase
Mod.
OSC.
Interface Unit
Pre-Amps.
Simulated
Primary
Source
(Cancellers)
Secondary
Sources
Detection
System
(Microphones
PC Host
r
r
(3)
(6)
(8)
(2)
(5)
(7)
(1)
(4)
(3)
(6)
(8)
(2)
(5)
(7)
(1)
(4)
s-m
p-m
Figure 1.2 - ECAS Laboratory System
1.3 ANC System
To cancel sound, a noise source is simulated by sending a series of sine
waves to a set of eight speakers; the noise simulator (primary source) is
positioned at the far end of an anechoic chamber.
Marco Faldetta BSc Music Technology Year 4 Chapter 1
Final Year Project
5
An array of microphones is positioned in front of the noise source; they send
the information they pick up to the DSP board.
The DSP board carries out complex processing on the signal received by the
microphones (all the parameters for this processing are defined in the
computer program) and generates an output signal. This output is the anti-
noise (or the same noise in counter-phase with the original sound). Another
set of speakers positioned in front of the noise source receives the anti-noise
signal to cancel out the original sound. This produces a shadow in the
observer plane as shown in figure 1.3.
primary sources (P)
secondary sources (S)
observer plane (O)
microphones (M)
Primary sources (P)
Generate sound;
Secondary sources (S)
are controlled by the
DSP board and create
anti-noise out of the
signal received by the
microphones (M).
The result in the
observer plane (O), is
attenuation of the sound.
Figure 1.3 - Electronically Controlled Acoustic Shadow (ECAS) System
The system works with pure tones, the back board (primary source) outputs
synthesised and synchronised sine waves. The system adapts itself to
different frequencies as instructed by the program that controls the DSP
board. This algorithm is the key to noise cancellation. Many programs have
been created to analyse different aspects of the Noise Cancellation process.
Marco Faldetta BSc Music Technology Year 4 Chapter 1
Final Year Project
6
The best performance is achieved when the system works on eight channels
(eight input output sockets, eight microphones and eight speakers). The
cancellation, however, can be achieved even at a lower number of channels
(1,2 and 4).
1.4 How the project came about
At present, the adaptive algorithm and the digital filter are implemented in C
programs that are downloaded to the DSP board every time the cancellation
process has to be run. This is done with the aid of batch files.
Although the filter is adaptable, some parameters have to be modified
manually for different types of analysis. Several different variables are
involved in the process, and they can only be modified if the program is not
running. The researchers have to modify the C code, compile it and then
download it onto the DSP board again every time one parameter changes. It
is not possible to modify parameters on-line as the program runs.
Furthermore, the processed information can only be inspected or visualised if
the program running on the board is stopped and the data collected off-line.
It would be possible to analyse and modify the process online, but a better
interface should be created to do so. Batch files only send the program to the
DSP Board’s compiler, and there is no way of communicating with that
program once it is on the board.
Marco Faldetta BSc Music Technology Year 4 Chapter 1
Final Year Project
7
In late September 2000, it was suggested that maybe, as computers today
are so powerful (whereas the TMS320C32 processor is mounted on a
Pentium 100MHz machine running on Windows 3.11), the DSP board could
be substituted altogether with a sound card, and the processing could be
done by the CPU of the computer instead of that of the DSP board. Because
of its DOS interface and its ISA connection, the TMS320C32 cannot be used
to perform online analysis of the noise cancellation process.
Is it possible to overcome this limitation? Believably it is, by creating a
Windows application suited to perform noise cancellation analysis with a
multimedia PC and its soundcard.
The task of investigating this possibility was undertaken; it evolved into a final
year project. Professor Wright suggested that an ISA card present at the ANC
laboratory could be suitable and this hypothesis is discussed in chapter three.
The following chapter describes part of the theory behind the existing ANC
system. An important requirement for this project was to be aware of how the
system works in order to implement a new set of programs for the analysis of
the Noise Cancellation process.
Marco Faldetta BSc Music Technology Year 4 Chapter 2
Final Year Project
8
Chapter 2
ANC Theory
This chapter gives an overview of the theory behind noise cancellation.
Although this project does not go as far as implementing noise control
algorithms, these concepts have been studied at the beginning of the
research as background knowledge. Since noise cancellation was the initial
aim of the whole project, its notions are included in this thesis.
2.1 Principles of sound
Sound consists of pressure waves that move through a compressible
medium. These can be generated by vibrating objects or surfaces, which
radiate waves of pressure differences travelling in three dimensions. Figure
2.1 shows a simplified description of this process. The dark areas indicate the
position where the molecules are squeezed together (areas of high pressure
or compressions). The lighter areas indicate areas where molecules are
relatively sparse (areas of low pressure or rarefactions). When the tightly
compressed, molecules in the first part of the image force themselves apart,
they end up compressing their neighbours, thus creating a pressure wave
1
.
The Speed at which the pressure waves travel depends upon the temperature
1
Tim Kientzle, A Programmer’s Guide To Sound
Marco Faldetta BSc Music Technology Year 4 Chapter 2
Final Year Project
9
and density of the medium through which it travels. For air this value is
determined 331.6 meters/sec at 0° Celsius.
Figure 2.1 - a moving pressure wave
A suitable measure of amplitude of these fluctuations can be given by the
mean square value of the fluctuation as defined by the time average:
() ()dttp
T
tp
T
T
T ∫
−
∞→
=
2/
2/
22
1
lim
The root mean square (RMS) amplitude fluctuations are normally denoted by
the value p
rms
. The range of RMS values is vast, and compressed by adopting
a logarithmic scale. The measurement of sound pressure is defined as
ref
rms
p
p
p
L
10
log20=
Marco Faldetta BSc Music Technology Year 4 Chapter 2
Final Year Project
10
Where p
ref
is a reference pressure of 20 !Pa, defined by the amplitude of a
pure tone 10 kHz that is audible by the human ear. This threshold level
corresponds to a sound pressure level of 0 dB
2
.
2.2 Digital Signal Processing
The world of science and engineering is filled with signals: images from
remote space probes, voltages generated by the heart and brain, radar and
sonar echoes, seismic vibrations, and countless others. Digital Signal
Processing is the science of using computers to understand these types of
data. This includes a wide variety of goals: filtering, speech recognition, image
enhancement, data compression, neural networks, and much more.
3
Thus,
provided a signal is given in digital format, it is possible to manipulate it and
use it for ad hoc applications.
To digitise a signal, an Analogue to Digital Converter (ADC) is needed. The
signal will then be represented by a number of discrete values over time. The
accuracy of the representation (precision) is given by the number of samples
per second that are used in the sampling process. The sampling frequency is
the factor that determines the precision of a represented signal. Being a lossy
process, the ideal sampling frequency is the one that represents the signal
accurately enough for a particular application. To reproduce the signal in its
analogue format, a Digital to Analogue Converter (DAC) is used. Acoustic
2
P Nelson, S Elliot, Active Control Of Sound
3
Steven W. Smith, The Scientist and Engineer's Guide to Digital Signal Processing
Marco Faldetta BSc Music Technology Year 4 Chapter 2
Final Year Project
11
noise is a signal, it too can be digitised through an ADC, and it can be
processed in digital format.
2.3 Noise cancellation
Research on noise cancellation is done with the aid computers. These can
perform calculations on the sampled audio data and allow researchers to
develop tools to control its behaviour. Ideally, the tools should be Real-time
DSP applications, computer programs that process audio on the spot and
produce an immediate output as the audio is sampled. The research can
however be performed on off-line data, audio samples are obtained and
processed at a later time.
All the tools used in ANC need to be capable of performing many numerical
operations in very short periods of time.
The TMS320C32 floating-point processor is suitable to carry out processes
like convolution, correlation, filtering and modulation.
For its characteristics, the ANC group at the University of Huddersfield has
been using the TMS320C32 up to this day.
2.4 Methods of noise cancellation
The ANC research focuses on the cancellation of narrow band noise, which is
mostly concentrated within specific frequencies. At present the aim is the
Marco Faldetta BSc Music Technology Year 4 Chapter 2
Final Year Project
12
cancellation of repetitive machine noise. The periodic noise produced by fans
or transformers has a predictable harmonic frequency content; this means it
can be calculated from functions of the machine rotation rate. As it is possible
to know the harmonic content of the sound produced by such devices, noise
cancellation is possible.
There are two methods to perform ANC, feed-forward and feed-back control.
In feed-forward control, the referenced noise input is sensed before it reaches
past the secondary noise cancellation sources, whereas feed-back noise
cancellation is achieved without the benefit of a reference to the input signal.
An example of a feed forward ANC is the system depicted below. A signal
generator provides a reference, which is used to synchronise the control
system to the primary noise source, by means of a non-acoustic sensor
4
.
Figure 2.2 - A Single Channel Narrowband Feed-forward ANC System
The objective of ANC systems is to produce an acoustic output that reduces
the pressure expressed in dB of the signal received by the error microphone;
4
Nick Palmer’s Final Year Project Report
Primary Noise
Source
Signal
Generator
ANC
System
Non-Acoustic
Sensor
Cancelling
Loudspeaker
e(n) x(n)
y(n)
Error
Microphone
Marco Faldetta BSc Music Technology Year 4 Chapter 2
Final Year Project
13
this process allows the creation of the anti-noise, outputted by the secondary
speakers. To achieve this, the system output has to be fed back to an
adaptive algorithm. The performance of the system can be controlled by
adjusting the filter coefficients; the amount of cancellation will depend on
these “weights”.
2.5 Adaptive filters
Digital filters are used to modify the spectral content of an input signal. To
perform this modification, the filters’ magnitude and phase responses must
satisfy certain specifications in the frequency domain. A distinction can be
made between linear and adaptive filters.
Linear filters do not change with time; they apply a constant set of linear
operations to data sequences. These operations can be controlled via
coefficients (or weights), the filtered output will vary according to the
coefficient values. In this application the filtered output will be the anti-noise,
when it is played in front of the primary source the noise will be attenuated.
However, slight changes in either frequency or phase of the primary source
can result in an increase of noise power.
Adaptive filters, as their name says, can “adapt” to new conditions as time
passes. The filter parameters can be adjusted automatically by means of an
adaptive algorithm. This capability makes adaptive filters ideal for applications
in areas where the required filtering operation is unknown or non-stationary.