angel iniesta & carlos lopez thesis

Upload: sabira1975

Post on 07-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    1/134

    Project realized by: Carlos Lpez Snchez

    ngel Iniesta Navarro

    Telekommunikationstechnik & -systeme (TKS)

    Department of Systems Theory & Signal Processing

    Project supervised by: Armin Veichtlbauer

    Peter Haber

    Salzburg University of Applied Sciences and Technologies

    June 2004

    Digital Filtering vs DSPfor Acoustic Echo and Noise

    Cancelling

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    2/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    1

    Index

    1. Introduction page1.1.

    Motivation.4

    1.2.Surrounding of the topic..41.2.1. The Acoustic Echo Problem....41.2.2. Introduction to the Echo Cancellers....51.2.3. Acoustic Echo Cancellers....6

    1.2.3.1. AEC components...........71.2.3.2. AEC metrics...8

    1.2.4. AEC Conclusions............9

    2. Theoretical Background2.1.Area: fundamentals of signals and systems processing...10

    2.1.1. Signals and Systems..102.1.2. Linearity112.1.3. Examples of Linear and Nonlinear Systems.112.1.4. Convolution...122.1.5. Correlation.132.1.6. The Discrete Fourier Transform (DFT).132.1.7. Frequency Response of Systems...152.1.8. Inverse DFT (IDFT)..162.1.9. The Fast Fourier Transform (FFT)16

    2.1.9.1. How the FFT works...162.1.9.2. Efficiency of the FFT.....172.1.9.3. Some Terminology used in FFT172.1.9.4. Implementation of FFT..17

    2.2.Digital Filters and DSPs.182.2.1. Digital Filters18

    2.2.1.1. Introduction...182.2.1.2. How Information is Represented in Signals..192.2.1.3. The Four Common Frequency Responses.202.2.1.4. Filter Classification212.2.1.5. Windowed-Sinc Filters..212.2.1.6. Recursive Filters232.2.1.7. Non-recursive filters: FIR filters...24

    2.2.1.7.1. FIR impulse response...252.2.1.7.2. The convolution representationof a FIR filter252.2.1.7.3. Finite in FIR filters...26

    2.2.1.8. Chebyshev Filters..26

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    3/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    4/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    3

    3.3.1. Selected Floating Point DSPs models..793.3.2. Selected Fixed Point DSPs models..803.3.3. TMS320C6713 DSP Starter Kit (DSK)81

    4. Description of the chosen solution4.1.Acoustic Echo Cancelling...84

    4.1.1. Modeling....864.1.1.1. Describing the AEC model blocks....86

    4.1.1.1.1. C6713 DSK DIP Switch...864.1.1.1.2. C6713 DSK ADC.874.1.1.1.3. C6713 DSK DAC.874.1.1.1.4. C62x General Real FIR87

    4.1.2. Testing in simulation environment884.1.2.1. Parameters setup...88

    4.1.3. Analyzing the simulation results.......90

    4.2. Acoustic Noise Cancelling..92

    4.2.1. Introduction to Acoustic Noise Cancellers....92

    4.2.2. ANC Modelling.934.2.2.1. Describing the ANC blocks and

    its parameters setup..954.2.2.1.1. Acoustic environment block954.2.2.1.2. C6713 DSK DIP Switch..954.2.2.1.3. C6713 DSK ADC / DAC.964.2.2.1.4. Fast Adapt / Slow Adapt blocks...964.2.2.1.5. Normalized LMS filter block...96

    4.2.2.1.5.1. General description..964.2.2.1.5.2. Supported Data Types..97

    4.2.3. Testing and analyzing in thesimulation environment...98

    4.2.3.1. Simulation before adaptation with

    white noise source......984.2.3.2. Simulation after adaptation withwhite noise source1004.2.3.3. Simulation before adaptation with

    pink noise source..1024.2.3.4. Simulation after adaptation with

    pink noise source..1044.2.3.5. Describing the wave files specifications.1074.2.3.6. Different type of Noise signals108

    4.2.4. ANC conclusions..109

    Appendix: A. LMS algorithms in Matlab110B. Bibliography....133

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    5/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    4

    1. Introduction

    1.1. MotivationAcoustic echo and noise cancellers are quite interesting nowadays because they arerequired in many applications such as speakerphones and audio/video conferencing.Moreover it is a new field for us, which we have not studied in depth. That are thereasons which motivate us to develop this thesis theme.

    1.2. Surrounding of the topic

    The problem that has to be solved is the presence of the acoustic echo and noise signalsin a communication between two or more users who are being interrupted by their ownecho and possible acoustic noise, forcing them to stop speaking until the echo is fadedaway and the process is repeated over and over again. This problem degrades the qualityof the communication considerably. Firstly, let is talk about the acoustic echo problem,that is how the echo appears in the communication system, and then we will introducethe technique to remove or cancel this undesireble signal through an Acoustic EchoCanceller(AEC) system.

    1.2.1. The Acoustic Echo Problem

    Acoustic echo is inevitable whenever a loudspeaker is placed near a microphone in afull-duplex communication application. This is the case in speaker-phones, audio andvideo conferencing, desktop communication, and many other communication scenarios.Especially hands-free mobile communication and kits for cars are becomingincreasingly important due to safety regulations introduced in more and more countries.In all those and similar communication scenarios, the voice from the loudspeaker (FarEnd Speech, FES) is inevitably picked by the microphone (NES) and transmitted backto the remote speaker as shown in the next figure. This makes the remote speaker hear

    her own voice distorted and delayed by the communication channel, which is known asecho. The longer the channel delay, the more annoying the echo becomes until it makesnatural conversation impossible and decreases the perceived quality of thecommunication service. It is therefore absolutely necessary to avoid transmitting backthe echo picked by the microphone.

    Modern full-duplex communication systems make use of an acoustic echo canceller(AEC) to prevent the echo from being transmitted back to the channel. The AEC isemployed in each terminal, and has completely different requirements than the NetworkEcho Canceller employed by the telephone network provider to eliminate the electricecho. The AEC basically estimates the echo and subtracts the estimated echo from the

    microphone signal as shown in the next figure. The resulting signal (RESidual) istransmitted to the far end speaker through the communication channel.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    6/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    5

    In conclusion, acoustic echo is generated whenever a loudspeaker and a microphoneare closely placed in an enclosure, as we have shown in the previous figure.

    1.2.2. Introduction to the Echo Cancellers

    Echo Cancellers have become essential components in todays telecommunicationsapplications. Echo Cancellers can be divided into two main categories, namely NetworkEcho Cancellers (NEC) and Acoustic Echo Cancellers (AEC). Both types of echocancellers rely on an adaptive filter to estimate the echo path and subsequently use thisestimate to reduce the echo in transmitted signals. The requirements, performance,underlying structure, and adaptive algorihms used to implement a NEC are usuallydifferent from those used to implement an AEC.

    Figure: block diagram of the acoustic echo canceller

    The problem addressed by acoustic echo canceller in all the applications which have

    describe before is illustrated in the last figure. In this figure, one side of acommunication channel (of an audio conference, for instance) is shown. The received

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    7/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    6

    speech or audio signal (Rout) is played through a loudspeaker so that all users in thelocal conference room can hear what the remote users say. The speech of the local users(Sin) is collected by one or more microphones and transmitted through thecommunication channel to the remote users. The problem in this audio setup is that thevoice signal Rout played through the loudspeaker and its reflections off the room

    boundaries (represented in the figure by the gray lines) will also be collected by thelocal microphones and transmitted back with the voice of the local users to the remoteusers, who will hear their own voice delayed by the network and acoustic delay of thecommunication chain.

    1.2.3. Acoustic Echo Cancellers

    The acoustic echo problem mentioned above can be considerably reduced by an AEC asshown in the last figure. The main function of the acoustic echo canceller is to estimatethe acoustic transfer function from the local speakers to the local microphones including

    the reflections paths. Filtering the incoming voice signal through the estimated acoustictransfer function produces an estimate of echo free signal y(n). Substracting thisestimated echo from the microphone signal results in the echo free signal e(n) =d(n)y(n) which is transmitted through the communication channel instead of themicrophone signal d(n). In the best case, when the estimate is accurate, this leads tocompletely eliminating the acoustic echo. The G.167 recommendations requires

    practical echo cancellers to achieve an echo reduction in the range of 40 to 45dB.

    Acoustic echo cancellers usually employ adjustable (or adaptive) finite impulseresponse (FIR) filters to estimate the acoustic echo path. The FIR coefficients areadjusted using an adaptive algorithm to minimize the error signal (Sout). The input(reference) signal for the adaptive filter is the far end speech (Rin) while its desiredsignal is the near end speech (Sin). After convergence, the adaptive filter coefficientswill have an impulse response close to the acoustic impulse response between theloudspeaker and the microphone placed in the local space. The filter response includesthe responses of:

    the Digital to Analog (D/A) converter before the loudspeaker the power amplifier driving the loudspeaker the loudspeaker response the acoustic path including the reflections off the room boundaries

    the microphone response the pre-amplifier after the microphone the Analog to Digital (A/D) converter after the microphone

    Since this acoustic impulse response can last several hundreds of miliseconds, acousticecho cancellers usually need long adaptive FIR filters. The G.167 recommendationsassumes an average reverberation time of 400ms for teleconferencing applications, and500ms for hands-free telephones. At sampling frequency of 8kHz or 16kHz, AECsemploying adaptive filters of several thousands coefficients are, therefore, notuncommon in practice. Adapting and filtering through such a large filter in real time is areal challence, and advanced, more efficient signal processing algorithms that reduce

    computational complexity and speed the convergence rate of the adaptive filter must beused.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    8/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    9/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    8

    Non-Linear Processor (NLP): when neither speakers is active, or the residualsiganl level is low enough, the CU generates a command to active the NLPlocated in the residual path to output a suitable signal to further reduce the echo.

    Noise Reduction Unit (NR): this block is very important and necessary whenthe communication device operates in noisy acoustic environment or when

    cheap components are used that generate internal noise. The NR unit cleans themicrophone signal from such noise, therefore improving speech quality anddecreases the recognition error rate in voice command and voice recognitionsystems.

    Automatic Gain Control (AGC): the AGC unit keeps the sound level of itsoutput at a predifined value regardless of the sound level of its input. Toimprove signal to noise ratio, the Rout signal is first passed through an AGC

    before being sent to the communication channel. Another AGC unit might alsobe used at the Sout end to automatically adjust the speaker sound. This unit isvery important, to avoid communication quality loss when the speakers are farfrom the microphones or when they are moving while talking.

    1.2.3.2. AEC metrics

    It is often required to compare the performance of several implementations of AECs ortest whether a specific implementation complies to a certain standard such as the G.167.Here summarizes the most important metrics that specify the performance of an AEC.

    AEC Processing Delay: this is the extra delay which might result from processing the different signals inside the AEC. The G.167 recommndationsallow maximum of 16ms delay in each direction of speech transmission for end-to-end digital communication systems. The maximum is reduced to 2ms forhands-free telephones connected to the PSTN and 10ms for mobile radiosystems.

    Weighted Terminal Coupling Loss Single Talk: this is the amount of echoreduction when the far end user is talking while the near end user is not talking.This quantity is measured by first resetting all AEC coefficients and applying asignal at the Rin input, the measured signal at Sout is called Sout1. The AECadaptation is then enabled for a sufficiently long time. No other signals areapplied to the microphone except for the loudspeaker sound due the Rin signal.The second measurement of Sout is called Sout2. The difference between Sout2

    and Sout1 in dB is the single talk coupling loss. The G.167 requires a couplingloss of 40 to 45 dB for different digital analog systems. Weighted Terminal Coupling Loss Doubled Talk: similar to the singled talk

    case, this quantity is the amount of echo reduction when both users of thecommunication system are talking at the same time. Here the difference betweenSout2 and Sout1 in dB is the double talk coupling loss. The G.167 requires acoupling loss of 25 to 30 dB for the different applications.

    Initial Convergence Time: this quantity is the amount of coupling lossachieved after one second for the moment of enabling the AEC. This ismeasured by first resetting all the AEC coefficients and then enablingadaptation. The difference in Sout before enabling the AEC adaptation and its

    value after 1s of adaptation is the coupling loss. G.167 requires this couplingloss to be at least 20 dB for all applications.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    10/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    11/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    12/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    11

    For instance, when you speak into a telephone, you expect the other person to hearsomething that resembles your voice.Unfortunately, the input signal to a transmission line is seldom identical to the outputsignal. If you understand how the transmission line (the system) is changing the signal,maybe you can compensate for its effect. In still other cases, the system may represent

    some physical process that you want to study or analyze. Radar and sonar are goodexamples of this. These methods operate by comparing the transmitted and reflectedsignals to find the characteristics of a remote object. In terms of system theory, the

    problem is to find the system that changes the transmitted signal into the receivedsignal. At first glance, it may seem an overwhelming task to understand all of the

    possible systems in the world. Fortunately, most useful systems fall into a categorycalled linear systems. This fact is extremely important. Without the linear systemconcept, we would be forced to examine the individual characteristics of manyunrelated systems. With this approach, we can focus on the traits of the linear systemcategory as a whole. Our first task is to identify what properties make a system linear,and how they fit into the everyday notion of electronics, software, and other signal

    processing systems.

    2.1.2. Linearity

    A system is called linear if it has two mathematical properties: homogeneity andadditivity. If you can show that a system has bothproperties, then you have proven thatthe system is linear. Likewise, if you canshow that a system doesn't have one or both

    properties, you have proven thatit isn't linear. A third property, shift invariance, is nota strict requirement for linearity, but it is a mandatory property for most DSPtechniques. When you see the term linear system used in DSP, you should assume itincludes shift invariance unless you have reason to believe otherwise. These three

    propertiesform the mathematics of how linear system theory is defined and used.

    2.1.3. Examples of Linear and Nonlinear Systems

    Examples ofLinearSystems:

    Wave propagation such as sound and electromagnetic waves.Electrical circuits composed of resistors, capacitors, and inductors.Electronic circuits, such as amplifiers and filters.

    Mechanical motion from the interaction of masses, springs, and dashpots (dampeners).Systems described by differential equations such as resistor-capacitor-inductornetworks.Multiplication by a constant, that is, amplification or attenuation of the signal.Signal changes, such as echoes, resonances, and image blurring.The unity system where the output is always equal to the input.The null system where the output is always equal to the zero, regardless of the input.Differentiation and integration, and the analogous operations of first difference andrunning sum for discrete signals.Small perturbations in an otherwise nonlinear system, for instance, a small signal

    being amplified by a properly biased transistor.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    13/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    14/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    13

    The equation that represents the convolution is:

    The system outputy[n] is the convolution of the input signalx[n] which convolves withthe system impulse response h[n].

    2.1.5. Correlation

    Correlation is a mathematical operation that is very similar to convolution. Just as withconvolution, correlation uses two signals to produce a third signal. This third signal is

    called the cross-correlation of the two input signals. If a signal is correlated with itself,the resulting signal is instead called the autocorrelation.

    Correlation is the optimal technique for detecting a known waveform in random noise.That is, the peak is higher above the noise using correlation than can be produced byany other linear system. Using correlation to detect a known waveform is frequentlycalled matched filtering.

    2.1.6. The Discrete Fourier Transform (DFT)

    Fourier analysis is a family of mathematical techniques, all based on decomposingsignals into sinusoids. The Discrete Fourier Transform is the family member used withdigitizedsignals.

    Before we get started on the DFT, let's look for a moment at theFourier transform (FT)and explain why we are not talking about it instead. The Fourier transform of acontinuous-time signalx(t) may be defined as:

    Thus, right off the bat, we need calculus. The DFT, on the other hand, replaces theinfiniteintegralwith afinitesum:

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    15/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    14

    A signal can be eithercontinuous ordiscrete, and it can be eitherperiodic oraperiodic.The combination of these two features generates the four categories:

    Aperiodic-ContinuousThis includes, for example, decaying exponentials and the Gaussian curve. These

    signals extend to both positive and negative infinity without repeating in a periodic pattern. The Fourier Transform for this type of signal is simply called the FourierTransform.

    Periodic-ContinuousHere the examples include: sine waves, square waves, and any waveform that repeatsitself in a regular pattern from negative to positive infinity. This version of the Fouriertransform is called the Fourier Series.

    Aperiodic-DiscreteThese signals are only defined at discrete points between positive and negative infinity,

    and do not repeat themselves in a periodic fashion. This type of Fourier transform iscalled the Discrete Time Fourier Transform.

    Periodic-DiscreteThese are discrete signals that repeat themselves in a periodic fashion from negative to

    positive infinity. This class of Fourier Transform is sometimes called the DiscreteFourier Series, but is most often called the DiscreteFourier Transform.

    The four categories are shown on the following figure:

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    16/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    15

    2.1.7. Frequency Response of Systems

    Systems are analyzed in the time domainby using convolution. A similar analysis canbe done in thefrequency domain. Using the Fourier transform, every input signal can berepresented as a group of cosine waves, each with a specified amplitude and phase shift.

    Likewise, the DFT can be used to represent every output signal in a similar form. Thismeans that any linear system can be completely described by how it changes theamplitude and phase of cosine waves passing through it. This information is called thesystem's frequency response. Since both the impulse response and the frequencyresponse contain complete information about the system, there must be a one-to-onecorrespondence between the two. Given one, you can calculate the other. Therelationship between the impulse response and the frequency response is one of thefoundations of signal processing: A system's frequency response is the FourierTransform of its impulse response.Keeping with standard DSP notation, impulse responses use lower case variables, whilethe corresponding frequency responses are upper case. Since h[ ] is the common symbol

    for the impulse response, H[] is used for the frequency response. Systems are describedin the time domain by convolution, that is:x[n] * h[n] =y[n]. In the frequency domain,the input spectrum is multiplied by the frequency response, resulting in the outputspectrum. As an equation: X[f ] H[f ] = Y[f ]. That is, convolution in the time domaincorresponds to multiplication in the frequency domain. And convolution in thefrequency domain corresponds to multiplication in the time domain. The next figureillustrates the relationship betwen the impulse response and the frequency response:

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    17/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    16

    2.1.8. Inverse DFT

    The inverseDFT(the IDFT) is given by:

    In summary, the DFT is proportional to the set of coefficients of projection onto thesinusoidal basis set, and the IDFT is the reconstruction of the original signal as asuperposition of its sinusoidal projections. This basic architecture extends to all linearorthogonal transforms, including wavelets, Fourier transforms, Fourier series, thediscrete-time Fourier transform (DTFT), and certain short-time Fourier transforms(STFT).

    2.1.9. The Fast Fourier Transform (FFT)

    The Fast Fourier Transform is another method for calculating the DFT. While itproduces the same result as the other approaches, it is incredibly more efficient, oftenreducing the computation time by hundreds. This is the same improvement as flying ina jet aircraft versus walking! The FFT requires a few dozen lines of code, and it is oneof the most complicated algorithms in DSP.

    2.1.9.1. How the FFT works

    By making use of periodicities in the sines that are multiplied to do the transforms, theFFT greatly reduces the amount of calculation required. Here's a little overview.

    Functionally, the FFT decomposes the set of data to be transformed into a series ofsmaller data sets to be transformed. Then, it decomposes those smaller sets into even

    smallersets. At each stage of processing, the results of the previous stage are combinedin special way. Finally, it calculates the DFT of each small data set. For example, anFFT of size 32 is broken into 2 FFT's of size 16, which are broken into 4 FFT's of size8, which are broken into 8 FFT's of size 4, which are broken into 16 FFT's of size 2.Calculating a DFT of size 2 is trivial.

    Here is a slightly more rigorous explanation: It turns out that it is possible to take theDFT of the first N/2 points and combine them in a special way with the DFT of thesecond N/2 points to produce a single N-point DFT. Each of these N/2-point DFTs can

    be calculated using smaller DFTs in the same way. One (radix-2) FFT begins,therefore, by calculating N/2 2-point DFTs. These are combined to form N/4 4-pointDFTs. The next stage produces N/8 8-point DFTs, and so on, until a single N-pointDFT is produced.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    18/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    17

    2.1.9.2. Efficiency of the FFT

    The DFT takes N^2 operations for N points. Since at any stage the computation requiredto combine smaller DFTs into larger DFTs is proportional to N, and there are log2(N)stages (for radix 2), the total computation is proportional toN * log2(N). Therefore, the

    ratio between a DFT computation and an FFT computation for the same N isproportional to N / log2(n). In cases where N is small this ratio is not very significant, but when N becomes large, this ratio gets very large. (Every time you double N, thenumerator doubles, but the denominator only increases by 1.)

    2.1.9.3. Some Terminology used in FFT

    The radix is the size of an FFT decomposition. For single-radix FFT's, the transformsize must be a power of the radix.

    FFT's can be decomposed using DFT's of even and odd points, which is called a

    Decimation-In-Time (DIT) FFT, or they can be decomposed using a first-half/second-half approach, which is called a Decimation-In-Frequency (DIF) FFT. Generally, theuser does not need to worry which type is being used.

    2.1.9.4. Implementation of FFT

    Except as a learning exercise, you generally will never have to. Many good FFTimplementations are available in C, Fortran and other languages, and microprocessormanufacturers generally provide free optimized FFT implementations in their

    processors' assembly code, Therefore, it is not so important to understand how the FFTreally works, as it is to understand how to use it.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    19/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    18

    2.2. Digital Filters and DSPs

    2.2.1. Digital Filters

    2.2.1.1. IntroductionDigital filters are used for two general purposes: (1) separation of signals that have beencombined, and (2) restoration of signals that have been distorted in some way. Analog(electronic) filters can be used for these same tasks; however, digital filters can achievefar superior results.

    Digital filters are a very important part of Digital Signal Processing (DSP). In fact, theirextraordinary performance is one of the key reasons that DSP has become so popular.As mentioned in the introduction, filters have two uses: signal separation and signalrestoration. Signal separation is needed when a signal has been contaminated with

    interference, noise, or other signals.

    Signal restoration is used when a signal has been distorted in some way. For example,an audio recording made with poor equipment may be filtered to better represent thesound as it actually occurred.

    These problems can be attacked with either analog or digital filters. Which is better?Analog filters are cheap, fast, and have a large dynamic range in both amplitude andfrequency. Digital filters, in comparison, are vastly superior in the level of performancethat can be achieved.

    It is common in DSP to say that a filter's input and output signals are in the timedomain. This is because signals are usually created by sampling at regular intervals oftime. But this is not the only way sampling can take place.The second most common way of sampling is at equal intervals in space. Many otherdomains are possible; however, time and space are by far the most common. When yousee the term time domain in DSP, remember that it may actually refer to samples takenover time, or it may be a general reference to any domain that the samples are taken in.

    The most straightforward way to implement a digital filter is by convolving the inputsignal with the digital filter's impulse response. All possible linear filters can be made inthis manner. When the impulseresponse is used in this way, filter designers give it aspecial name: the filterkernel.

    There is also another way to make digital filters, called recursion. When a filter isimplemented by convolution, each sample in the output is calculated by weightingthesamples in the input, and adding them together.Recursive filters are an extension of this, using previously calculated values from theoutput, besides points from the input. Instead of using a filter kernel, recursive filters aredefined by a set ofrecursion coefficients.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    20/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    19

    The important point is that all linear filters have an impulse response, even if you don'tuse it to implement the filter. To find the impulse response of a recursive filter, simplyfeed in an impulse, and see what comes out. The impulse responses of recursive filtersare composed of sinusoids that exponentially decay in amplitude. In principle, thismakes their impulse responses infinitely long. However, the amplitude eventually drops

    below the round-off noise of the system, and the remaining samples can be ignored.Because of this characteristic, recursive filters are also called Infinite ImpulseResponse or IIR filters. In comparison, filters carried out by convolution are calledFinite Impulse Response orFIRfilters.

    A digital filter uses a digital processor to perform numerical calculations on sampledvalues of the signal. The processor may be a general-purpose computer such as a PC, ora specialised DSP (Digital Signal Processor) chip. The analog input signal must first besampled and digitised using anADC(analog to digital converter). The resulting binarynumbers, representing successive sampled values of the input signal, are transferred tothe processor, which carries out numerical calculations on them. These calculations

    typically involve multiplying the input values by constants and adding the productstogether. If necessary, the results of these calculations, which now represent sampledvalues of the filtered signal, are output through a DAC(digital to analog converter) toconvert the signal back to analog form.

    Note that in a digital filter, the signal is represented by a sequence of numbers, ratherthan a voltage or current. The following diagram shows the basic setup of such asystem:

    2.2.1.2. How Information is Represented in Signals

    The most important part of any DSP task is understanding how information is containedin the signals you are working with. There are only two ways that are common forinformation to be represented in naturally occurring signals. We will call these:information represented in the time domain, and information represented in thefrequency domain.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    21/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    20

    Information represented in the time domain describes when something occurs and whatthe amplitude of the occurrence is. In contrast, information represented in the frequencydomain is more indirect. By measuring the frequency, phase, and amplitude of this

    periodic motion, information can often be obtained about the system producing themotion.

    This brings us to the importance of the step and frequency responses. Thestep responsedescribes how information represented in the time domain is being modified by thesystem. In contrast, the frequency response shows how information represented in the

    frequency domain is being changed. Thisdistinction is absolutely critical in filter designbecause it is not possible tooptimize a filter for both applications. Good performance inthe time domainresults in poor performance in the frequency domain, and vice versa.

    2.2.1.3. The Four Common Frequency Responses

    Frequency domain filters are generally used to pass certain frequencies (the passband),while blocking others (thestopband). These four responses are the most common: low-

    pass, high-pass, band-pass, and band-reject:

    The purpose of these filters is to allow some frequencies to pass unaltered, whilecompletely blocking other frequencies. The passband refers to those frequencies thatare passed, while the stopband contains those frequencies that are blocked. Thetransition band is between. A fast roll-off means that the transition band is verynarrow. The division between the passband and transition band is called the cutofffrequency. In analog filter design, the cutoff frequency is usually defined to be wherethe amplitude is reduced to 0.707 (i.e., -3dB). Digital filters are less standardized, and itis common to see 99%, 90%, 70.7%, and 50% amplitude levels defined to be the cutoff

    frequency.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    22/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    21

    2.2.1.4. Filter Classification

    Digital filters are classified by their use and by their implementation. Time domainfilters are used when the information is encoded in the shape of the signal's waveform.Time domain filtering is used for such actions as: smoothing, DC removal, waveform

    shaping, etc. In contrast, frequency domain filters are used when the information iscontained in the amplitude, frequency, and phase of the component sinusoids. The goalof these filters is to separate one band of frequencies from another. Custom filters areused when a special action is required by the filter, something more elaborate than thefour basic responses (high-pass, low-pass, band-pass and band-reject).

    Digital filters can be implemented in two ways, by convolution (also called finiteimpulse response orFIR) and by recursion (also called infinite impulse response or

    IIR). Filters carried out by convolution can have far better performance than filters usingrecursion, but execute much more slowly.

    2.2.1.5. Windowed-Sinc Filters

    Windowed-sinc filters are used to separate one band of frequencies from another. Theyare very stable, produce few surprises, and can be pushed to incredible performancelevels. These exceptional frequency domain characteristics are obtained at the expenseof poor performance in the time domain, including excessive ripple and overshoot in thestep response. When carried out by standard convolution, windowed-sinc filters are easyto program, but slow to execute.

    The next figure illustrates the idea behind the windowed-sinc filter. In (a), thefrequency response of the ideal low-pass filter is shown. All frequencies below thecutoff frequency, fC, are passed with unity amplitude, while all higher frequencies are

    blocked.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    23/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    24/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    25/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    26/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    27/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    26

    A FIR filter thus operates by convolving the input signal x[n] with the filter's impulseresponse h[n].

    2.2.1.7.3. Finite in FIR filters

    From the previous equation, we can see that the impulse response becomes zero aftertime M = N1. Therefore, a tapped delay line can only implement finite-durationimpulse responses in the sense that the non-zero portion of the impulse response must

    be finite. This is what is meant by the termfinite impulse response (FIR).

    FIR digital filtering is the most common technique used in digital signal processing.

    2.2.1.8. Chebyshev Filters

    Chebyshev filters are used to separate one band of frequencies from another. Althoughthey cannot match the performance of the windowed-sinc filter, they are more thanadequate for many applications. The primary attribute of Chebyshev filters is theirspeed, typically more than an order of magnitude faster than the windowed-sinc. This is

    because they are carried out by recursion rather than convolution. The design of thesefilters is based on a mathematical technique called thez-transform.

    2.2.1.8.1. The Chebyshev and Butterworth Responses

    The Chebyshev response is a mathematical strategy for achieving a faster rolloffbyallowing ripple in the frequency response. Analog and digital filters that use thisapproach are called Chebyshev filters. These filters are named from their use of theChebyshev polynomials, developed by the Russian mathematician Pafnuti Chebyshev(1821-1894).

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    28/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    27

    The previous figure shows the frequency response of low-pass Chebyshev filters with

    passband ripples of: 0%, 0.5% and 20%. As the ripple increases (bad), the roll-offbecomes sharper (good). The Chebyshev response is an optimal tradeoff between thesetwo parameters. When the ripple is set to 0%, the filter is called a maximally flat orButterworth filter (after S. Butterworth, a British engineer who described this responsein 1930). A ripple of 0.5% is a often good choice for digital filters. This matches thetypical precision and accuracy of the analog electronics that the signal has passedthrough.These Chebyshev filters are called type 1 filters, meaning that the ripple is only allowedin the passband. In comparison, type 2 Chebyshev filters have ripple only in the

    stopband. Type 2 filters are seldom used, and we won't discuss them. There is, however,an important design called the elliptic filter, which has ripple in both the passband and

    the stopband. Elliptic filters provide the fastest roll-off for a given number of poles, butare much harder to design. We won't discuss the elliptic filter here, but be aware that itis frequently the first choice of professional filter designers, both in analog electronicsand DSP. If you need this level of performance, buy a software package for designingdigital filters.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    29/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    30/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    29

    Simplicity:

    some things can be done more easily digitally than with analogue systems.

    DSP is used in a very wide variety of applications like: telephony, radar, digital TV,

    audio, sonar, multimedia, fax, process control, etc., but most share some commonfeatures:

    they use a lot of maths (multiplying and adding signals). they deal with signals that come from the real world. they require a response in a certain time.

    Where general purpose DSP processors are concerned, most applications deal withsignal frequencies that are in the audio range.

    Continueing with DSP, Digital Signal Processing is carried out by mathematical

    operations. In comparison, word processing and similar programs merely rearrangestored data. This means that computers designed for business and other generalapplications are not optimized for algorithms such as digital filtering and Fourieranalysis.Digital Signal Processors are microprocessors specifically designed to handleDigital Signal Processing tasks. These devices have seen tremendous growth in the lastdecade, finding use in everything from cellular telephones to advanced scientificinstruments. In fact, hardware engineers use "DSP" to mean Digital Signal Processor,

    just as algorithm developers use "DSP" to meanDigital Signal Processing.

    2.2.2.2. DSPs vs Microprocessors

    The last forty years have shown that computers are extremely capable in two broadareas, data manipulation, such as word processing and database management, andmathematical calculation, used in science, engineering, and Digital Signal Processing.All microprocessors can perform both tasks; however, it is difficult (expensive) to makea device that is optimizedfor both. There are technical tradeoffs in the hardware design,suchas the size of the instruction set and how interrupts are handled. Even more important,there are marketingissues involved: development and manufacturing cost, competitive

    position, product lifetime, and so on. As a broad generalization, these factors have madetraditional microprocessors, such as the Pentium, primarily directed at datamanipulation. Similarly, DSPs are designed to perform the mathematical calculationsneeded in Digital Signal Processing.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    31/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    30

    In the previous figure we observe that digital computers are useful for two general tasks:data manipulation and mathematical calculation. Data manipulation is based on movingdata and testing inequalities, while mathematical calculation uses multiplication andaddition.

    Data manipulation involves storing and sorting information. For instance, consider aword processing program. The basic task is to store the information (typed in by theoperator), organize the information (cut and paste, spell checking, page layout, etc.), andthen retrieve the information (such as saving the document on a floppy disk or printingit with a laser printer). These tasks are accomplished by movingdata from one locationto another, and testingfor inequalities (A=B,A

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    32/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    31

    The previous figure illustrates an eight sample circular buffer. We have placed thiscircular buffer in eight consecutive memory locations, 20041 to 20048. Figure (a)shows how the eight samples from the input might be stored at one particular instant intime, while (b) shows the changes after the next sample is acquired. The idea of circular

    buffering is that the end of this linear array is connected to its beginning; memorylocation 20041 is viewed as being next to 20048, just as 20044 is next to 20045. Youkeep track of the array by a pointer (a variable whose value is an address) that indicateswhere the most recent sample resides. For instance, in (a) the pointer contains theaddress 20044, while in (b) it contains 20045. When a new sample is acquired, itreplaces the oldest sample in the array, and the pointer is moved one address ahead.Circular buffers are efficient because only one value needs to be changed when a newsample is acquired.The whole point of this discussion is that DSPs should be optimized at managingcircular buffers to achieve the highest possible execution speed.

    Circular buffering is also useful in off-lineprocessing. Consider a program where boththe input and the output signals are completely contained in memory. Circular bufferingisn't needed for a convolution calculation, because every sample can be immediatelyaccessed. However, many algorithms are implemented in stages, with an intermediatesignal being created between each stage. For instance, a recursive filter carried out as aseries of biquads

    operates in this way. The brute force method is to store the entire length of eachintermediate signal in memory. Circular buffering provides another option: store onlythose intermediate samples needed for the calculation at hand. This reduces the requiredamount of memory, at the expense of a more complicated algorithm. The important ideais that circular buffers are useful for off-line processing, but critical for real-timeapplications.

    In the following table we will see the steps needed to implement an FIR filter usingcircular buffers for both the input signal and the coefficients. The efficient handling ofthese individual tasks is what separates a DSP from a traditional microprocessor.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    33/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    32

    1. Obtain a sample with the ADC; generate an interrupt2. Detect and manage the interrupt3. Move the sample into the input signal's circular buffer4. Update the pointer for the input signal's circular buffer5. Zero the accumulator

    6. Control the loop through each of the coefficients

    7. Fetch the coefficient from the coefficient's circular buffer8. Update the pointer for the coefficient's circular buffer9. Fetch the sample from the input signal's circular buffer10. Update the pointer for the input signal's circular buffer11. Multiply the coefficient by the sample12. Add the product to the accumulator

    13. Move the output sample (accumulator) to a holding buffer14. Move the output sample from the holding buffer to the DAC

    The goal is to make these steps execute quickly. Since steps 6-12 will be repeated manytimes (once for each coefficient in the filter), special attention must be given to these

    operations. Traditional microprocessors must generally carry out these 14 steps inserial(one after another), while DSPs are designed to perform them in parallel. In somecases, all of the operations within the loop (steps 6-12) can be completed in a singleclock cycle.

    2.2.2.4. Architecture of the Digital Signal Processor

    One of the biggest bottlenecks in executing DSP algorithms is transferring informationto and from memory. This includes data, such as samples from the input signal and thefilter coefficients, as well as program instructions, the binary codes that go into the

    program sequencer. For example, suppose we need to multiply two numbers that residesomewhere in memory. To do this, we must fetch three binary values from memory, thenumbers to be multiplied, plus the program instruction describing what to do.

    The previous figure shows how this seemingly simple task is done in a traditionalmicroprocessor. This is often called a Von Neumann architecture. Von Neumannarchitecture contains a single memory and a single bus for transferring data into and outof the central processing unit (CPU). Multiplying two numbers requires at least threeclock cycles, one to transfer each of the three numbers over the bus from the memory tothe CPU.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    34/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    33

    We don't count the time to transfer the result back to memory, because we assume that itremains in the CPU for additional manipulation (such as the sum of products in an FIRfilter).

    The Harvard architecture is shown in (b). This is named for the work done at HarvardUniversity in the 1940s under the leadership of Howard Aiken (1900-1973). Aiken

    insisted on separate memories for data and program instructions, with separate buses foreach. Since the buses operate independently, program instructions and data can befetched at the same time, improving the speed over the single bus design. Most presentday DSPs use this dual bus architecture.

    Figure (c) illustrates the next level of sophistication, the Super Harvard Architecture.These are called SHARC DSPs, a contraction of the longer term, Super HarvardARChitecture. The idea is to build upon theHarvard architecture by adding features toimprove the throughput. While theSHARC DSPs are optimized in dozens of ways, twoareas are importantenough to be included: an instruction cache, and anI/Ocontroller.

    Now lets look inside the CPU. At the top of the diagram are two blocks labeled DataAddress Generator (DAG), one for each of the two memories. These control theaddresses sent to the program and data memories, specifying where the information is to

    be read from or written to.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    35/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    36/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    35

    The previous figure shows the typical DSP architecture. And this is the simplifieddiagram of a SHARC DSP, where we can observe the blocks that compose the CPU,which we have described before.

    2.2.2.5. Data formats: Fixed and Floating Point

    Digital Signal Processing can be divided into two categories, fixed point and floatingpoint. These refer to the format used to store and manipulate numbers within thedevices. Fixed point DSPs usually represent each number with a minimum of 16 bits,although a different length can be used. In comparison, floating point DSPs typicallyuse a minimum of 32 bits to store each value. Lets study these two data formats.

    It is worth noting that fixed point format is not quite the same as integer:

    The integer format is straightforward: representing whole numbers from 0 up to thelargest whole number that can be represented with the available number of bits. Fixedpoint format is used to represent numbers that lie between 0 and 1: with a 'binary point'assumed to lie just after the most significant bit. The most significant bit in both casescarries the sign of the number.

    The size of the fraction represented by the smallest bit is the precision of thefixed point format.

    The size of the largest number that can be represented in the available wordlength is the dynamic range of the fixed point format.

    To make the best use of the full available word length in the fixed point format, theprogrammer has to make some decisions:

    If a fixed point number becomes too large for the available word length, the programmer has to scale the number down, by shifting it to the right: in theprocess lower bits may drop off the end and be lost.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    37/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    36

    If a fixed point number is small, the number of bits actually used to represent itis small. The programmer may decide to scale the number up, in order to usemore of the available word length.

    In both cases the programmer has to keep a track of by how much the binary point has

    been shifted, in order to restore all numbers to the same scale at some later stage.

    Floating point format has the remarkable property of automatically scaling all numbersby moving, and keeping track of, the binary point so that all numbers use the full wordlength available but never overflow:

    Floating point numbers have two parts: the mantissa, which is similar to the fixed point part of the number, and an exponent which is used to keep track of how the binarypoint is shifted. Every number is scaled by the floating point hardware:

    If a number becomes too large for the available word length, the hardwareautomatically scales it down, by shifting it to the right.

    If a number is small, the hardware automatically scale it up, in order to use thefull available word length of the mantissa.

    In both cases the exponent is used to count how many times the number has beenshifted. In floating point numbers the binary point comes after the second most

    significant bit in the mantissa.

    The block floating point format provides some of the benefits of floating point, but byscaling blocks of numbers rather than each individual number:

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    38/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    37

    Block floating point numbers are actually represented by the full word length of a fixedpoint format.

    If any one of a block of numbers becomes too large for the available wordlength, the programmer scales down all the numbers in the block, by shiftingthem to the right.

    If the largest of a block of numbers is small, the programmer scales up allnumbers in the block, in order to use the full available word length of themantissa.

    In both cases the exponent is used to count how many times the numbers in the blockhave been shifted.

    Some specialised processors, such as those from Zilog, have special features to supportthe use of block floating point format: more usually, it is up to the programmer to testeach block of numbers and carry out the necessary scaling.

    The floating point format has one further advantage over fixed point: it is faster.Because of quantisation error, a basic direct form 1 IIR filtersecond order sectionrequires an extra multiplier, to scale numbers and avoid overflow. But the floating pointhardware automatically scales every number to avoid overflow, so this extra multiplieris not required:

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    39/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    40/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    41/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    40

    In the previous figure we have introduced a new technique which is the Fast FourierTransform convolution. FFT convolution is a fast way to carry out FIR filters. In atypical case, a 512 sample segment is taken from the input, padded with an additional512 zeros, and converted into its frequency spectrum by using a 1024 point FFT. Aftermultiplying this spectrum by the desired frequency response, a 1024 point Inverse FFT

    is used to move back into the time domain. The resulting 1024 points are combined withthe adjacent processed segments using the overlapadd method. This produces 512 pointsof the output signal.

    FFT convolution can also be applied in two-dimensions (2D), such as for image processing. For instance, suppose we want to process an 800600 pixel image in thefrequency domain. First, pad the image with zeros to make it 10241024. The two-dimensional frequency spectrum is then calculated by taking the FFT of each of therows, followed by taking the FFT of each of the resulting columns. After multiplyingthis 10241024 spectrum by the desired frequency response, the two-dimensionalInverse FFT is taken. This is carried out by taking the Inverse FFT of each of the rows,

    and then each of the resulting columns. Adding the number of clock cycles and dividingby the number of samples, we find that this entire procedure takes roughly 150 clockcycles per pixel. For a 40 MHz SHARC DSP, this corresponds to a data throughput ofabout 260k samples/second.

    Comparing these different techniques shown in the previous illustration, we can makean important observation. Nearly all DSP techniques require between 4 and 400instructions (clock cycles in the SHARC family) to execute. For a SHARC DSPoperating at 40 MHz, we can immediately conclude that its data throughput will be

    between 100k and 10M samples per second, depending on how complex of algorithm isused.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    42/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    41

    2.3. Analog vs. Digital Filters

    2.3.1. Introduction

    Most digital signals originate in analog electronics. If the signal needs to be filtered, is itbetter to use an analog filter before digitization, or a digital filter after? We will answerthis question by letting two of the best contenders deliver their blows.

    The goal will be to provide a low-pass filter at 1 kHz. Fighting for the analog side is asix pole Chebyshev filter with 0.5 dB (6%) ripple. This can be constructed with 3operational amplifiers, 12 resistors, and 6 capacitors. In the digital corner, thewindowed-sinc is warming up and ready to fight. The analog signal is digitized at a 10kHz sampling rate, making the cutoff frequency 0.1 on the digital frequency scale. Thelength of the windowed-sinc will be chosen to be 129 points, providing the same 90% to

    10% roll-off as the analog filter. Fair is fair. The next figure shows the frequency andstep responses for these two filters.

    Let's compare the two filters blow-by-blow. As shown in (a) and (b), the analog filterhas a 6% ripple in the passband, while the digital filter is perfectly flat (within 0.02%).The analog designer might argue that the ripple can beselectedin the design; however,this misses the point. The flatness achievable with analog filters is limited by theaccuracy of their resistors and capacitors. Even if a Butterworth response is designed(i.e., 0% ripple), filters of this complexity will have a residue ripple of, perhaps, 1%. Onthe other hand, the flatness of digital filters is primarily limited by round-off error,making them hundreds of times flatter than their analog counterparts. Score one point

    for the digital filter.

    Next, look at the frequency response on a log scale, as shown in (c) and (d). Again, thedigital filter is clearly the victor in both roll-offand stopbandattenuation. Even if theanalog performance is improved by adding additional stages, it still can't compare to thedigital filter. For instance, imagine that you need to improve these two parameters by afactor of 100. This can be done with simple modifications to the windowed-sinc, but isvirtually impossible for the analog circuit. Score two more for the digital filter.

    The step response of the two filters is shown in (e) and (f). The digital filter's stepresponse is symmetrical between the lower and upper portions of the step, i.e., it has a

    linear phase. The analog filter's step response is notsymmetrical, i.e., it has a nonlinear phase. One more point for the digital filter. Lastly, the analog filter overshoots about20% on one side of the step. The digital filter overshoots about 10%, but on both sidesof the step. Since both are bad, no points are awarded.

    In spite of this beating, there are still many applications where analog filters should, ormust, be used. This is not related to the actual performance of the filter (i.e., what goesin and what comes out), but to the general advantages that analog circuits have overdigital techniques. The first advantage isspeed: digital is slow; analog is fast.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    43/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    42

    For example, a personal computer can only filter data at about 10,000 samples persecond, using FFT convolution. Even simple operational amplifiers can operate at 100kHz to 1 MHz, 10 to 100 times as fast as the digital system!

    The second inherent advantage of analog over digital is dynamic range. This comes in

    two flavors. Amplitude dynamic range is the ratio between the largest signal that canbe passed through a system, and the inherent noise of the system. For instance, a 12 bitADC has a saturation level of 4095, and an rms quantization noise of 0.29 digitalnumbers, for a dynamic range of about 14000. In comparison, a standard op amp has asaturation voltage of about 20 volts and an internal noise of about 2 microvolts, for adynamic range of about ten million. Just as before, a simple op amp devastates thedigital system.

    The other flavor is frequency dynamic range. For example, it is easy to design an opamp circuit to simultaneously handle frequencies between 0.01 Hz and 100 kHz (sevendecades). When this is tried with a digital system, the computer becomes swamped with

    data. For instance, sampling at 200 kHz, it takes 20 million points to capture onecomplete cycle at 0.01 Hz. You may have noticed that the frequency response of digitalfilters is almost always plotted on a linear frequency scale, while analog filters areusually displayed with a logarithmic frequency. This is because digital filters need alinear scale to show their exceptional filter performance, while analog filters need thelogarithmic scale to show their huge dynamic range.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    44/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    43

    2.3.2. Advantages of using digital filters in front of analog circuits

    The following list gives some of the main advantages of digital over analog filters.

    1. A digital filter isprogrammable, i.e. its operation is determined by a program storedin the processor's memory. This means the digital filter can easily be changed withoutaffecting the circuitry (hardware). An analog filter can only be changed by redesigningthe filter circuit.

    2. Digital filters are easily designed, tested and implemented on a general-purposecomputer or workstation.

    3. The characteristics of analog filter circuits (particularly those containing activecomponents) are subject to drift and are dependent on temperature. Digital filters do notsuffer from these problems, and so are extremely stable with respect both to time andtemperature.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    45/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    44

    4. Unlike their analog counterparts, digital filters can handle low frequency signalsaccurately. As the speed of DSP technology continues to increase, digital filters are

    being applied to high frequency signals in the RF (radio frequency) domain, which inthe past was the exclusive preserve of analog technology.

    5. Digital filters are very much more versatile in their ability to process signals in avariety of ways; this includes the ability of some types of digital filter to adapt tochanges in the characteristics of the signal.

    6. Fast DSP processors can handle complex combinations of filters in parallel orcascade (series), making the hardware requirements relatively simple and compact incomparison with the equivalent analog circuitry.

    Comparative table between Digital and Analog Filtering

    DIGITAL FILTERS ANALOG FILTERS

    High Accuracy Less Accuracy - ComponentTolerances

    Linear Phase (FIR Filters) Non-Linear Phase

    No Drift Due to Component Variations Drift Due to Component Variations

    Flexible, Adaptive Filtering Possible Adaptive Filters Difficult

    Easy to Simulate and Design Difficult to Simulate and Design

    Computation Must be Completed in SamplingPeriod-Limits Real Time Operation

    Analog Filters Required at High Frequencies andfor Anti-Aliasing Filters

    Requires High Performance ADC, DAC & DSP No ADC, DAC, or DSP Required

    In the previous table we can observe the pros and cons of using analog or digital filters,and evaluating all the comparations we conclude obviously that using digital filters ismore apropiate for our application.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    46/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    45

    3. Analysis of the possible solutions

    3.1. Solution ways

    In this chapter is going to study in depth the two possible solution ways such as thecommon adaptive filteringand digital signal processors (configured or programmed towork as an adaptive filter in the main application). At first, lets introduce us in the fieldof digital adaptive filtering (circuits).

    3.1.1. Digital Adaptive Filters for Echo Cancelling

    In this subchapter we begin with an examination of the filter structure with emphasis on

    FIR (Finite Impulse Response) filters. This is followed by a review of the Wiener filterleading to the development of the LMS (Least Mean Squares) algorithm. The NLMS(normalised LMS) is detailed with a comparison of its main characteristics to the LMS.Thus the standard elements of an echo canceller are described. We will start byintroducing what is anEcho canceller.

    3.1.1.1. The Echo Canceller

    Simplifying the echo canceller down to its major components, it is found that it is quitea basic mechanism. Essentially it is an adaptive filter used for the purpose of directsystem modelling, as shown in the next figure.

    An adaptive filteris a device which extracts the required information from a signal byadjusting its parameters in response to the environment to give the optimal solution. It ismade up of two elements, a filter and an adaptive algorithm.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    47/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    48/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    47

    FIR filterstructure

    The FIR filter consists of a series of delays, multipliers and adders; has one input, x(n),and one output, y(n). The output is expressed as a linear combination of the delayedinput samples:

    where wi(n) are the filter coefficients and N is the filter length. y(n) therefore is theconvolution (inner product) of the two vectors w(n) andx(n).

    The significant advantage that FIR filters have over other structures is the importantfact that their transfer functions contain only zeros:

    This makes FIR filters inherently and unconditionally stable. IIR filters on the otherhand, generally have both poles and zeros in their transfer functions and their output islikely to oscillate indefinitely as the poles move outside the unit circle. However,subject to constraints, there are conditionally stable IIR filter forms such as lattice

    filters.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    49/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    50/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    49

    On due consideration of this filtering problem, N. Wiener and E. Hopf, in 1931,produced a formula for obtaining the optimum solution for the estimated filter taps for alinear continuous-time filter. This formula required the solution of an integral equation,which has become known as the Wiener-Hopf equation and was based on minimisingthe mean square error of the system. It was then developed by Levinson in 1947 to

    produce the Wiener-Hopf equation for discrete-time signals. This is expressed as:

    Rw0 = P

    the solution of which is:

    w0 = (1/ R) P

    wherew0 is the optimum tap-weight vector, R is the (NN) auto-correlation matrix ofthe tap inputs, andPis the (N1) cross-correlation vector between the tap inputs and the

    desired response.

    Wiener filters minimise the mean square error of the system. This cost function is oneof the simplest to mathematically solve and in the majority of cases it has a singleglobal minimum, particularly in the case of a FIR filter. For the ideal situation thereforethe optimum solution of a Wiener filter exists and can be reached exactly.

    3.1.1.4. Least Mean Squares Algorithm

    In practice Wiener filters are commonly implemented as FIR filters using a LMS familyalgorithm. LMS algorithms are capable of arriving at close approximations of the same(optimum) solution as the Wiener-Hopf equation but without directly solving theequation. The method of least squares is accredited to Gauss though Legendre, whoindependently developed the same algorithm. With work commencing on adaptivefilters in the late 1950s, the least squares algorithm was developed to produce the leastmean squares.This achievement was a result of the work of Widrow and Hoff on an adaptive linearelement known as Adaline, which was a pattern recognition scheme. From the LMScame the normalised LMSand later the leaky LMS. Then came the development of thesigned LMS and the Quantized LMS and so on.The LMS algorithm follows a stochastic gradient approach to finding the optimumWiener solution, w0, by minimization of the mean-square error, where the error is thedifference between the output from the filter and the desired response. It basicallyfollows the steepest descent method to finding an optimum solution of the cost function,which in this case is the mean-squared error.The steepest descent algorithm is expressed as:

    w^(k+1) = w^(k) ^(k) F {w^(k)}

    whereby the filter coefficients, w, are updated proportionally to the gradient value F

    [w^(k)], ^(k) is a small step size and the minus sign ensures that the parameterestimates descend the error surface.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    51/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    50

    However, whereas an actual or determined value for the gradient is calculated at eachstage in the steepest descent, with a stochastic gradient method instantaneous values areused to calculate an estimate of the gradient. This gives a random or stochastic gradient.

    In order to derive the LMS algorithm (previous equation) is rewritten in terms of the

    mean-squared error cost function, as given in the next equation:

    w(n+1) = w(n) w (e(n))

    and solving the gradient to find its value, we conclude: w (e(n)) = = 2 e(n)x(n)

    Substituting this value in the last equation, the LMS algorithm is given by:

    w(n+1) = w(n) + 2e(n)x(n)

    The LMS has a number of favourable properties that makes it a popular algorithm touse: one of the greatest advantages of the LMS is its simplicity; it does not requiredirect calculation of the correlation functions nor matrix inversion which can be quiteexpensive computationally; It is a straight forward algorithm to carry out having oneach iteration only (N+1) multiplications and N additions, where N is the number oftap-weights in the filter; Another favoured property of the LMS is its robustness; smalluncertainties, non-linearities or small (energy) disturbances cause only small estimationerrors. These do not cause the LMS to veer wildly from its adaptation path but tocontinue tracking to the optimum solution.

    Generally a sufficient condition for the stability of the LMS is for the step size to liewithin the range 0

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    52/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    53/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    52

    w(n+1) = w(n) + {e(n)x(n) / x ^T(n) x(n)}

    On each iteration, the tap-weight change (gradient) is normalised with respect to thesquared Euclidean norm of the input signal. This minimises the effect of the signal

    power on the coefficient change.

    The NLMS aims to find the step-size that minimises the instantaneous output error and by doing so it follows the principle of minimal disturbance which states that in thelight of newinput data, the parameters of an adaptive system should only be disturbedin a minimalfashion. Thus for the NLMS, when new input data is received, the tap-weight vector is updated with only an optimal minimal change and consequentlysuccessive values for the tap-weights do not vastly oscillate. This results in theadaptation path being optimised: the convergence rate has been optimised.

    For highly correlated and nonstationary signals such as speech, the NLMS has a

    significant improvement in the convergence rate over the LMS, due to the normalisationwhich minimises the effect of the input signal power. For uncorrelated and stationarysignals such as white noise, the NLMS still gives an improved performance with theconvergence rate being constant and maximum. Nevertheless, the convergence rate ofthe NLMS is still dependant on the eigenvalue spread of the input signal andconsequently it converges slowly compared to other algorithmic families.

    However, the NLMS is the most popular algorithm used in echo cancellationtechnology, with the following version being most often used in practicalimplementations:

    w(n+1) = w(n) + {e(n)x(n) / x ^T(n) x(n) + }

    is a very small constant which is used to prevent a division by zero or other nominalvalue close to zero. This situation occurs when the estimated input signal power is verysmall and would, from equation we have seen previously to this, result in a tap-weight

    change of infinity. By including , the maximum step-size is limited and a more stableNLMS algorithm is obtained.

    In comparison to the LMS the NLMS is convergent in the mean if the step-size lies in

    the range 0

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    54/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    53

    3.1.1.6. Non-Linearities And Echo Cancellation

    Though FIR filters are not capable of exactly matching the systems desired response, inmany cases it is possible to achieve a satisfactory output from a FIR filter based onlinear assumptions, even if the system exhibits some minor non-linearities. This is so

    with echo cancellation and generally speaking it has been found that echo paths aresufficiently linear to be modelled by adaptive linear transversal filters.

    For purely digital transmission systems, non-linear echo cancellation may provide a better performance. However, it is not in widespread use since non-linear echocancellers are much more complex than standard linear ones, with the complexityincreasing exponentially with the size of the data symbol alphabet. Consequently therehas to be a very strong need for the extra performance benefits to outweigh the use of alinear echo canceller.

    A major problem with non-linearities is that they are not generally simple-matters and

    tend to be memory-intensive; Volterra-based cancellers need to use at least a secondorder Volterra-series to effectively model non-linearities. The number of filtercoefficients increases rapidly as the order increases which will depend on the memoryand size of the non-linearity. Table look-up filters also depend on memory, where foreach input sample there is a possible L output values each stored at a memory address.Therefore the larger the filter the more unmanageable the look-up is and the slower theconvergence.

    Another possibility is to use recursive filters but these may become unstable.Precautions therefore need to be taken to prevent this instability but these may result ina decrease in performance of the IIR filters.

    In general, weighing up the pros and cons, linear FIR adaptive filters still hold the upperhand in echo cancellation technology, being simpler, more cost-effective, giving areasonable level of cancellation and being on the whole, stable. Therefore for the

    purpose of this thesis, the echo canceller model could be based on linear FIR adaptivefilters.

    3.1.1.7. ERLE

    The performance of an echo canceller is usually given in terms of the echo return loss

    enhancement(ERLE). This is a comparison of the echoes before and after cancellation.It is calculated as:

    where z(n) desired signal (actual echo only),z(n) replicated echo.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    55/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    54

    For the calculation of the ERLE it is assumed that the system is not in a double-talksituation.

    The ERLE therefore is the amount of attenuation of the echo signal introduced by theecho canceller. It does not include any further reduction in the residual echo by any

    extra nonlinear processing after the basic echo cancellation. The ERLE provides afigure of merit for determining how effective the echo cancellation process is; itassumes that there is always a certain amount of loss incurred by echo and then showsthe rate of improvement after echo cancellation. It reflects both the convergence rateand the steady-state residual echo. The plot of ERLE versus time shows the rate ofchange in the enhancement: it shows the rate of convergence of the algorithm to thesteady-state error value. The ERLE gives a good indication of the performance of theecho canceller.

    Over time the ERLE changes; initially it may be quite small but as the algorithmconverges towards the optimum tap-weight values it increases. Theoretically the steady

    state ERLE could be very large and an ideal echo canceller with a perfectly linear echosignal would output an infinite ERLE in a very short period of time. Practicallyhowever, there are limiting factors to this result; the echo path always contains somenon-linearities introduced by various components in the transmission path; the devicesthat generate the echo produce a certain amount of echo loss that little can be doneabout and the use of finite-precision devices limit the accuracy of the computations.Therefore the ERLE will not reach its theoretical steady-state maximum value.

    Nevertheless, a good performing echo canceller will output a very large steady-stateERLE in a very short convergence time.

    3.1.1.8. ERL

    The ERLE can also be given in terms of the echo return loss (ERL): the ERLE is theapparent increase in ERL resulting from the echo cancellation process.

    The ERL is the attenuation of a signal by the network elements and the echo generatingdevice; it is a measure of the loss estimate of the hybrid and transmission line. (It is not

    just the amount of attenuation caused by the hybrid alone but it is a good estimate of thehybrid loss). The ERL is the ratio in dB of the input signal to the echo signal, asexperienced in the actual telephone circuit without any form of echo protection. It isgiven by the following formula:

    For the calculation of the ERL it is assumed that the system is not in a double-talk

    situation.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    56/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    57/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    56

    3.1.2. Available DSPs on the market

    3.1.2.1 List of all DSPs companies on the market

    Alacron Alex Computer Systems Analog Devices Angeles Design Systems Corporation. Ariel Corporation Atmel Corporation Berkeley Design Technology, Inc.- DSP Technology Specialists Bittware Research Systems Bridgenorth Signal Processing Clarkspur Design Inc. - designer of configurable core integrated circuits for DSP Clearline Communications - providing comprehensive and progressive voice

    quality products Coreco Inc. Data Translation DNA Enterprises, Inc. DSP Communications, Inc. DSP Developement Corporation - DADiSP DSP Group, Inc. DSP Software Engineering DSP Solutions DSP Tools, Inc. Elanix Incorporated Eonic Systems, Inc. GO DSP Corporation Hyperception Hyperstone Electronics Improv Systems, Inc.- designs configurable integrated circuit architectures,

    compilers, system applications and support technology Innovative Integration Loughborough Sound Images Massana - DSP Algorithm developement and IC Design Motorola

    Multiprocessor Toolsmiths Inc. National Instruments Numerix, Ltd. Nyvalla DSP Parallel Performance Group, Inc. Pentek Signalogic, Inc. Silicon Systems, Inc. Sonitech International, Inc. Spectron Microsystems Spectrum Signal Processing

    Tasking Texas Instruments

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    58/134

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    59/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    58

    3.1.2.2. Texas Instruments

    TMS320 DSP Family Overview

    Since the launch of Texas Instruments first single-chip Digital Signal Processor (DSP)in 1982, TI has provided designers an accelerated time-to-market with next-generation,

    breakthrough systems as well as complementary technology and support. DSPs areunique microprocessors that are programmable and operate in real-time much fasterthan general-purpose microprocessors. The ability to crunch vast quantities of numbers,while racing a clock is the value digital signal processors bring to the electronicsmarketplace.

    The TMS320 DSP family offers the most extensive selection of DSPs availableanywhere, with a balance of general-purpose and application-specific processors to suityour needs.

    There are three distinct Instruction Set Architectures that are completely code-compatible within platforms:

    Highest Performance: TMS320C6000 DSP platform

    Raising the bar in performance and cost efficiency, the C6000 DSP platform offers abroad portfolio of the industry's fastest DSPs running at clock speeds up to 1 GHz. The platform consists of the TMS320C64x and TMS320C62x fixed-point generationsas well as the TMS320C67x floating-point generation. Optimal for designers workingon targeted broadband infrastructure, performance audio and imaging applications, theC6000 DSP platform's performance ranges from 1200 to 8000 MIPS for fixed-point and600 to 1350 MFLOPS for floating point.

    Best Power Efficiency: TMS320C5000 DSP Platform

    TMS320C5000 DSP Platform is optimized for the consumer digital market - the heartof the mobile Internet - and it's convergence with other consumer electronics. With aroadmap to power consumption as low as 0.33mA/MHz, the TMS320C55x andTMS320C54x DSPs are optimized for personal and portable products like digital

    music players, GPS receivers, portable medical equipment, 3G cell phones, and digitalcameras as well as MIPS-intensive voice and data applications and extremely costeffective single and multi-channel applications.Based on the C55x DSP core, the OMAP5910 processor integrates a C55x DSP corewith a TI-enhanced ARM925 on a single chip for the optimal combination of high

    performance with low power consumption. This unique architecture offers an attractivesolution to both DSP and ARM developers, providing the low power real-time signal

    processing capabilities of a DSP coupled with the command and control functionality ofan ARM. Sampling today, the OMAP5910 is optimal for designers working withdevices that require embedded applications processing in a connected environment.

  • 8/6/2019 Angel Iniesta & Carlos Lopez Thesis

    60/134

    Digital Filtering vs DSP for Acoustic Echo and Noise Cancelling ngel Iniesta & Carlos Lpez

    _______________________________________________________________________

    59

    Control Optimized: TMS320C2000 DSP Platform

    TMS320C2000 DSP Platform provides the digital control industry with the highestlevel of on-chip integration and powerful computational abilities that produceunparalleled improvements in energy efficiency. The TMS320C28x DSP generation

    is the highest-performance solution for digital control. The TMS320C24x DSPgeneration is the foundation for this diverse platform. This generation delivers powerand control advantages that allow designers to implement advanced, cost-efficientcontrol systems

    Tools and Software

    For rapid DSP product development, the TMS320 DSP family is supported by theeXpressDSP Real-Time Software Technology that includes Code Composer Studio

    integrated development environment, DSP/BIOS Real-time software kernel, TMS320DSP Algorithm Standard and choices for reusable, modular software from the largestThird-Party Network in the industry.

    Complementary Data Converter and Power Management Products

    TI also offer a range of complementary data converter and power management productsto get your designs to market faster. And because most of TI's new analog products aredesigned to work directly with TI DSPs, TI can focus on providing total solution sets.

    Changing the world, providing more choices for every market requirement and aroadmap leading from today's needs to tomorrow's demands.

    TI families which can work as echo canceller

    Inside the three most important families of TI (C2000, C5000 and C6000), o