Sie sind auf Seite 1von 72

ClickheretopurchasetheentirebookinPDFformat.

Chapter9
DigitalSignalProcessing
9.1IntroductiontoDSP
OneofmyfirstprofessorsinDigitalSignalProcessing(betterknownasDSP)summarizedtheentirefieldusing
thesimpleflowchartshowninFigure9.1.

Figure9.1:DSPinaverysmallnutshell.Themaththatisdoneistheprocessingdonetothedigital
signal.Thiscouldbeadelay,anEQorareverbuniteitherway,itsjustmath.
Essentially,thatsjustaboutit.Theideaisthatyouhavesomesignalthatyouhaveconvertedfromanalogto
adiscreterepresentationusingtheprocedurewesawinSection8.1.Youwanttochangethissignalsomehow
thiscouldmeanjustaboutanything...youmightwanttodelayit,filterit,mixitwithanothersignal,compressit,
makereverberationoutofitanything...Everythingthatyouwanttodotothatsignalmeansthatyouaregoing
totakealongstringofnumbersandturnthemintoalongstringofdifferentnumbers.Thisisprocessingofthe
digitalsignalor,DigitalSignalProcessingitsthemaththatisappliedtothesignaltoturnitintotheother
signalthatyourelookingfor.
9.1.1BlockDiagramsandNotation
Usually,ablockdiagramofaDSPalgorithmwontrunfromtoptobottomasisshowninFigure9.1.Justlike
analogcircuitdiagrams,DSPdiagramstypicallyrunfromlefttoright,withotherdirectionsbeingusedeither
whennecessary(tomakeafeedbackloop,forexample)orfordifferentsignalslikecontrolsignalsasinthecase
ofanalogVCAs(Seesection6.2.3).
LetsstartbylookingatablockdiagramofasimpleDSPalgorithm.

Figure9.2:Basicblockdiagramofacombfilterimplementedinthedigitaldomain.
LetslookatallofthecomponentsofFigure9.2toseewhattheymean.
Lookingfromlefttorightyoucanseethefollowing:

x[t]Thisactuallyhasacoupleofthingsinitthatwehavetotalkabout.Firstly,theresthexwhichtells
usthatthisisaninputsignalwithavalueofx(xisusuallyusedtoindicatethatitsaninput,yforoutput).
Thetinthesquarebracketsisthesamplenumberofthesignalinotherwords,itsthetimethatthe
signalsvalueisx.Notethatthesquarebracketsareusuallyusedtodenotethatwearemeasuringa
discretetimesignal,andnotaninstantaneousmeasurementofacontinuoustimesignal.
zkThisisanindicationofadelayofksamples.Weknowthattisasamplenumber,andwerejust
subtractingsomenumberofsamplestothat(infact,weresubtractingksamples).Subtractingkfromthe
samplenumbermeansthatweregettingearlierintime,so[tk]meansthatweredelayingthesignalat
time[t]byksamples.Weuseadelaytohearsomethingnowthatactuallycameinearlier.So,thisblockis
justadelayunitwithadelaytimeofksamples.Sincethedelaytimeisexpressedinanumberofsamples,
wecallitanintegerdelaytodistinguishitfromothertypesthatwellseelater.Wellalsotalklater(in
Section9.7)aboutwhyitswrittenusingaz.
aThereisalittletrianglewithanaoveritinthediagram.Thisisagainfunctionwhereaisthe
multiplier.Everythingthatpassesthroughthatlittletriangle(whichmeans,inthiscase,everythingthat
comesoutofthedelaybox)getsmultipliedbya.
Thecirclewiththe+signinitindicatesthatthetwosignalscominginfromtheleftandbelowareadded
togetherandsentouttheright.Sometimesyouwillalsoseethisasacirclewithainitinstead.Thisis
justanotherwayofsayingthesamething.
y[t]Asyoucanprobablyguess,thisisthevalueofthesampleattimetattheoutput(hencethey)ofthe
system.
Thereisanotherwayofexpressingthisblockdiagramusingmath.Equation9.1showsexactlythesame
informationwithoutdoinganydrawing.
(9.1)
9.1.2NormalizedFrequency
IfyoustartreadingbooksaboutDSP,youllnoticethattheyuseastrangewayoflabelingthefrequencyofa
signal.Insteadofseeinggraphswithfrequencyrangesof20Hzto20kHz,youllusuallyseesomethingcalleda
normalizedfrequencyrangingfrom0to0.5andnounitattached(itsnot0to0.5Hz).
Whatdoesthismean?Well,thinkaboutadigitalaudiosignal.Ifwerecordasignalwitha48kHzsample
rateandplayitbackwitha48kHzsamplingrate,thenthefrequencyofthesignalthatwentinisthesameasthe
frequencyofthesignalthatcomesout.However,ifweplaybackthesignalwitha24kHzsamplingrateinstead,
thenthefrequencyofthesignalthatcomesoutwillbeonehalfthatoftherecordedsignal.Theratiooftheinput
frequencytotheoutputfrequencyofthesignalisthesameastheratiooftherecordingsamplingratetothe
playbacksamplingrate.Thisprobablydoesntcomeasasurprise.(Rememberaswellthatsinceachangein
samplingratewillchangethesamplingperiodthetimeittakestoplayonesamplethenadelaycomposedof
anintegernumberofsampleswillalsochangeitslengthintime.)
Whathappensifyoureallydontknowthesamplingrate?Youjusthaveabunchofsamplesthatrepresenta
timevaryingsignal.Youknowthatthesamplingrateisconstant,youjustdontknowitsfrequency.Thisisthe
whataDSPprocessorknows.So,allyouknowiswhatthefrequencyofthesignalisrelativetothesampling
rate.Ifthesamplesallhavethesamevalue,thenthesignalmusthaveafrequencyof0(theDSPassumesthat
youvedoneyourantialiasingproperly...).Ifthesignalbouncesbackbetweenpositiveandnegativeonevery
sample,thenitsfrequencymustbetheNyquistFrequencyonehalfofthesamplingrate.
So,accordingtotheDSPprocessor,thesamplingratehasafrequencyof1andyoursignalwillhavea
frequencythatcanrangefrom0to0.5.Thisiscalledthenormalizedfrequencyofthesignal.
Theresanimportantthingtorememberhere.Usuallypeopleusethewordnormalizetomeanthat
somethingischanged(younormalizeamixingconsolebyreturningalltheknobstoadefaultsetting,for
example).Withnormalizedfrequency,nothingischangeditsjustawayofdescribingthefrequencyofthe
signal.
PUTASHORTDISCUSSIONHEREREGARDINGTHEUSEOFt

9.1.3SuggestedReadingList

9.2FFTs,DFTsandtheRelationshipBetweentheTimeandFrequencyDomains
NOTETOSELF:CHECKALLTHECOMPLEXNUMBERSINTHISSECTION
Note:

Ifyoureunhappywiththeconceptsofrealandimaginarycomponentsinasignal,andhowtheyrerepresented
usingcomplexnumbers,youdbettergobackandreadChapter1.6.
9.2.1FourierinaNutshell
WesawbrieflyinSection3.1.17thatthereisadirectrelationshipbetweenthetimeandfrequencydomainsfora
givensignal.Inface,ifweknoweverythingthereistoknowaboutthefrequencydomain,wealreadyknowits
shapeinthetimedomainandviceversa.Nowletslookatthatrelationshipalittlemoreclosely.
TakeasinewavelikethetopplotshowninFigure9.3andaddittoanothersinewavewithonethirdthe
amplitudeandthreetimesthefrequency(themiddleplot,alsoinFigure9.3).Theresultwillbeshapedlikethe
bottomplotinFigure9.3.

Figure9.3:Thebottomplotisthesumofthetoptwoplots.
Ifwecontinuewiththisseries,addingasinewaveat5timesthefrequencyand1/5ththeamplitude,7times
thefrequencyand1/7ththeamplitudeandsoonupto31timesthefrequency(and1/31theamplitude)yougeta
waveformthatlookslikeFigure9.4.

Figure9.4:Thesumofoddharmonicsofasinewavewheretheamplitudeofeachis1/nwherenis
theharmonicnumberuptothe31stharmonic.
Asisbeginningtobecomeapparent,theresultstartstoapproachasquarewave.Infact,ifwekeptgoingwith
theseriesuptoHz,thesumwouldbeaperfectsquarewave.
Theotherissuetoconsideristherelativephaseoftheharmonics.Forexample,ifwetakethesamesinusoids
asareshowninFigures9.3and9.4andoffseteachby90beforesumming,wegetaverydifferentresultascan

beseeninFigures9.5and9.6.

Figure9.5:Thebottomplotisthesumofthetoptwoplots.Notethatthefrequenciesandamplitudes
ofthetwocomponentsareidenticaltothoseshowninFigure1,however,theresultofaddingthe
twoproducesaverydifferentwaveform.

Figure9.6:Thesumofoddharmonicsofasinewavewheretheamplitudeofeachis1/nwherenis
theharmonicnumberuptothe31stharmonic.
Thisisntanewideainfact,itwasoriginallysuggestedbyaguynamedJeanBaptisteFourierthatany
waveform(suchasasquarewave)canbeconsideredasasumofanumberofsinusoidalwaveswithdifferent
frequenciesandphaserelationships.Thismeansthatwecancreateawaveformoutofsinusoidalwaveslikewe
didinFigures9.3and9.4,butitalsomeansthatwecantakeanywaveformandlookatitsindividual
components.Thisconceptwillcomeasnosurprisetomusicians,whocallthesecomponentsharmonicsthe
timbresofaviolinandaviolaplayingthesamenotearedifferentbecauseofthedifferentrelationshipsofthe
harmonicsintheirspectra(onespectrum,twospectra)
Usingalotofmathandcalculus,itispossibletocalculatewhatisknownasaFourierTransformofa
signaltofindoutwhatitssinusoidalcomponentsare.Wewontdothat.Thereisalsoawaytodothisquickly
calledaFastFourierTransformorFFT.Wewontdothateither.TheFFTisusedforsignalsthatarecontinuous
intime.Aswealreadyknow,thisisnotthecasefordigitalaudiosignals,wheretimeandamplitudearedivided
intodiscretedivisions.Consequently,indigitalaudioweuseavariationontheFFTcalledaDiscreteFourier
TransformorDFT.Thisiswhatwelllookat.Onethingtonoteisthatmostpeopleinthedigitalworldusethe
termFFTwhentheyreallymeanDFTinfact,youllrarelyhearsomeonetalkaboutDFTseventhrough
thatswhattheyredoing.Justremember,ifyouredoingwhatyouthinkisanFFTtoadigitalsignal,youre
reallydoingaDFT.
9.2.2DiscreteFourierTransforms
Letstakeadigitalaudiosignalandviewjustaportionofit,showninFigure9.7.Wellcallthatportionthe
windowbecausetheaudiosignalextendsonbothsidesofitanditsasifwerelookingataportionofitthrough
awindow.Forthepurposesofthisdiscussion,thewindowlength,usuallyexpressedinpointsisonly1024
sampleslong(therefore,inthiscasewehavea1024pointwindow).


Figure9.7:Aplotofadigitalaudiosignal1024sampleslong.
Aswealreadyknow,thissignalisactuallyastringofnumbers,oneforeachsample.Tofindtheamountof0
Hzinthissignal,allweneedtodoistoaddthevaluesofalltheindividualsamples.Technicallyspeaking,we
reallyshouldmakeitanaverageanddividetheresultbythenumberofsamples,butwereinarush,sodont
bother.Ifthewaveisperfectlysymmetricalaroundthe0line(likeasinusoidalwave,forinstance...)thenthe
totalwillbe0becauseallofthepositivevalueswillcanceloutallofthenegativevalues.IftheresaDC
componentinthesignal,thenaddingthevaluesofallthesampleswillshowusthistotallevel.
So,ifweaddupallthevaluesofeachofthe1024samplesinthesignalshown,wegetthenumber4.4308.
Thisisameasureofthelevelofthe0Hzcomponent(inelectricalengineeringjargon,theDCoffset)inthe
signal.Therefore,wecansaythatthebinrepresentingthe0Hzcomponenthasavalueof4.4308.Notethatthe
particularvalueisgoingtodependonyoursignal,butImgivingnumberslike4.4308justasanexample.
Weknowthatthewindowlengthoftheaudiosignalis,inourcase,1024sampleslong.Letscreateacosine
wavethatsthesamelength,countingfrom0to2(or,inotherwords,0to360).(Technicallyspeaking,its
periodis1025samples,andwerecuttingoffthelastone...)Now,takethesignaland,samplebysample,
multiplyitbyitscorrespondingsampleinthecosinewaveasshowninFigure9.8.

Figure9.8:Thetopplotistheoriginalsignal.Themiddleplotisoneperiodofacosinewave(minus
thelastsample).Thebottomplotistheresultwhenwemultiplythetoptwo,samplebysample.
Now,takethelistofnumbersthatyouvejustcreatedandaddthemalltogether(forthisparticularexample,
theresulthappenstobe6.8949).Thisistherealcomponentatafrequencywhoseperiodisthelengthofthe
audiowindow.(Inourcase,thewindowlengthis1024samples,sotheperiodforthiscomponentis
wherefs
isthesamplingrate.)
Repeattheprocess,butuseasinewaveinsteadofacosineandyougettheimaginarycomponentforthe
samefrequency,showninFigure9.9.


Figure9.9:Thetopplotistheoriginalsignal.Themiddleplotisoneperiodofaninvertedsinewave
(minusthelastsample).Thebottomplotistheresultwhenwemultiplythetoptwo,sampleby
sample.
Takethatlistofnumbersandaddthemandtheresultistheimaginarycomponentatafrequencywhose
periodisthelengthofthesample(forthisparticularexample,theresulthappenstobe0.9981).
Letsassumethatthesamplingrateis44.1kHz,thismeansthatourbinrepresentingthefrequencyof
43.0664Hz(remember,44100/1024)containsthecomplexvalue6.8949+0.9981i.Wellseewhatwecando
withthisinamoment.
Now,repeatthesameprocedureusingthenextharmonicofthecosinewave,showninFigure9.10.

Figure9.10:Thetopplotistheoriginalsignal.Themiddleplotistwoperiodsofacosinewave(minus
thelastsample).Thebottomplotistheresultwhenwemultiplythetoptwo,samplebysample.
Takethatlistofnumbersandaddthemandtheresultistherealcomponentatafrequencywhoseperiodis
theonehalfthelengthoftheaudiowindow(forthisparticularexample,theresulthappenstobe4.1572).
Andagain,werepeattheprocedurewiththenextharmonicofthesinewave,showninFigure9.11.

Figure9.11:Thetopplotistheoriginalsignal.Themiddleplotistwoperiodsofaninvertedsine
wave(minusthelastsample).Thebottomplotistheresultwhenwemultiplythetoptwo,sample
bysample.
Takethatlistofnumbersandaddthemandtheresultistheimaginarycomponentatafrequencywhose
periodisthelengthofthesample(forthisparticularexample,theresulthappenstobe1.0118).

Ifyouwanttocalculatethefrequencyofthisbin,its2timesthefrequencyofthelastbin(becausethe
frequencyofthecosineandsinewavesaretwotimesthefundamental).Thereforeits2
,or,inthis
example,2*(44100/1024)=86.1328Hz.
Nowwehavethe86.1328Hzbincontainingthecomplexnumber4.15721.0118i.
Thisprocedureisrepeated,usingeachharmonicofthecosineandsineuntilyougetuptoafrequencywhere
youhave1024periodsofthecosineandsineinthewindow.(Actually,youjustgouptothefrequencywherethe
numberofperiodsinthecosineorthesineisequaltothelengthofthewindowinsamples.)
Usingthesenumbers,wecancreateTable9.1.
Bin
Number
0
1
2

Frequency(Hz) Real
component
0Hz
4.4308
43.0664Hz
6.8949
86.1328Hz
4.1572

Imaginary
component
N/A
0.9981i
1.0118i

Table9.1:Theresultsofourmultiplicationandaveragingdescribedaboveforthefirstthreebins.
Thesearejustthefirstthreebinsof1024(binnumbers0to1023).
Howcanweusethisinformation?Well,rememberfromthechapteroncomplexnumbersthatthemagnitude
ofasignalessentially,theamplitudeofthesignalthatweseeiscalculatedfromtherealandimaginary
componentsusingthePythagoreantheorem.Therefore,intheexampleabove,themagnituderesponsecanbe
calculatedbytakingthesquarerootofthesumofthesquaresoftherealandimaginaryresultsoftheDFT.Huh?
CheckoutTable9.2.

BinNumber
0
1
2

Frequency(Hz)
0Hz
43.0664Hz
86.1328Hz

Magnitude
4.4308
6.9668
4.2786

Table9.2:Themagnitudeofeachbin,calculatedusingthedatainTable9.1
Ifwekeepfillingoutthistableuptothe1024thbin,andgraphedtheresultsofMagnitudevs.BinFrequency
wedhavewhateveryonecallstheFrequencyResponseofthesignal.Thiswouldtellus,frequencybyfrequency
theamplituderelationshipofthevariousharmonicsinthesignal.Theonethingthatitwouldnttellusiswhat
thephaserelationshipofthevariousharmonicsare.Howcanwecalculatethat?Well,rememberfromthe
chapterontrigonometrythattherelativelevelsoftherealandimaginarycomponentscanbecalculatedusingthe
phaseandamplitudeofasignal.Also,rememberfromthechapteroncomplexnumbersthatthephaseofthe
signalcanbecalculatedusingtherelativelevelsoftherealandimaginarycomponentsusingtheequation:
(9.2)
So,nowwecancreateatableofphaserelationships,binbybinasshowninTable9.3:
BinNumber Frequency(Hz) arctan(

) Phase(degrees)

0Hz

arctan

43.0664Hz

arctan

8.2231

86.1328Hz

arctan

13.6561

Table9.3:Thephaseofeachbin,calculatedusingthedatainTable9.1
So,forexample,thesignalshowninFigure3hasacomponentat86.1328Hzwithamagnitudeof4.2786
andaphaseoffsetof13.6561.
Notethatyoullsometimeshearpeoplesayingsomethingalongthelinesoftherealcomponentbeingthe
signalandtheimaginarycomponentcontainingthephaseinformation.Ifyouhearthis,ignoreititswrong.
Youneedboththerealandtheimaginarycomponentstodetermineboththemagnitudeandthephasecontentof
yoursignal.Ifyouhaveoneortheother,youllgetanideaofwhatsgoingon,butnotaverygoodone.
9.2.3Acoupleofmoredetailsondetail
WhenyoudoaDFT,theresalimitonthenumberofbinsyoucancalculate.Thistotalnumberisdependenton
thenumberofsamplesintheaudiosignalthatyoureusing,wherethenumberofbinsequalsthenumberof
samples.Justtomakecomputershappier(andthereforefaster)wetendtodoDFTsusingwindowlengthswhich
arepowersof2,soyoullseelengthslike256points,or1024points.So,a256pointDFTwilltakeinadigital
audiosignalthatis256sampleslongandgiveyouback256bins,eachcontainingacomplexnumber
representingtherealandimaginarycomponentsofthesignal.
Now,rememberthatthebinsareevenlyspacedfrom0Hzuptothesamplingrate,soifyouhave1024bins
andthesamplingrateis44.1kHzthenyougetabinevery44100/1024Hzor43.0664Hz.ThelongertheDFT
window,thebettertheresolutionyougetbecauseyouredividingthesamplingratebyabiggernumberandthe
spacinginfrequencygetssmaller.Intuitively,thismakessense.Forexample,letssaythatweusedaDFTlength
of4points.Ataverylowfrequency,thereisntenoughchangein4samples(whichisalltheDFTknows
about...)toseeadifference,sotheDFTcantcalculatealowfrequency.Thelongerthewindowlength,thelower
thefrequencywecanlookat.Ifyouwantedtoseewhatwashappeningat1Hz,thenyouregoingtohaveto
waitforatleast1fullperiodofthewaveformtounderstandwhatsgoingon.ThismeansthatyourDFTwindow
lengthastobeatleastthesizeofallthesamplesinonesecond(becausetheperiodofa1Hzwaveis1second).
Therefore,thebetterlowfrequencyresolutionyouwant,thelongeraDFTwindowyouregoingtohavetouse.
Thisisgreat,butifyouretryingtodothisinrealtime,meaningthatyouwantaDFTofasignalthatyoure
listeningtowhileyourelisteningtoit,thenyouhavetorememberthattheDFTcantbecalculateduntilallof
thesamplesinthewindowareknown.Therefore,ifyouwantgoodlowfrequencyresolution,youllhavetowait
alittlewhileforit.Forexample,ifyourwindowsizeis8192sampleslong,thenthefirstDFTresultwontcome
outofthesystemuntil8192samplesafterthemusicstarts.Essentially,yourealwayslookingatwhathasjust
happenednotwhatishappening.Therefore,ifyouwantafasterresponse,youneedtouseasmallerwindow
length.
Themoralofthestoryhereisthatyoucanchoosebetweengoodlowfrequencyresolutionorfastresponse
butyoureallycanthaveboth(butthereareacoupleofwaysofcheating...).
9.2.4RedundancyintheDFTResult
IfyougothroughthemotionsanddoaDFTbinbybin,youllstarttonoticethattheresultsstartmirroring
themselves.Forexample,ifyoudoan8pointDFT,thenbins0upto4willallbedifferent,thenbin5willbe
identicaltobin3,bins6and2arethesame,andbins7and1arethesame.Thisisbecausethefrequenciesofthe
DFTbinsgofrom0Hztothesamplingrate,buttheaudiosignalonlygoestohalfofthesamplingrate,normally
calledtheNyquistfrequency.AbovetheNyquist,aliasingoccursandwegetredundantinformation.Theodd
thinghereisthefactthatweactuallyeliminatedinformationabovetheNyquistfrequencyontheconversion
fromanalogtodigital,butthereisstillstuffthereitsjustamirrorimageofthesignalwekept.
Consequently,whenwedoaDFT,sincewegetthismirroreffect,wetypicallythrowawaytheredundant
dataandkeepalittlemorethanhalfthenumberofbinsinfact,itsonemorethanhalfthenumber.So,ifyou
doa256pointDFT,thenyouarereallygiven256frequencybins,butonly129ofthoseareusable(256/2+1).

InrealbooksonDSP,theylltellyouthat,foranNpointDFT,yougetN/2+1bins.Thesebinsgofrom0Hzup
totheNyquistfrequencyor .
Also,youllnoticethatatthefirstandlastbins(at0HzandtheNyquistfrequency)onlycontainrealvalues
noimaginarycomponents.Thisisbecause,inbothcases,wecantcalculatethephase.Thereisnophase
informationat0Hz,andsince,attheNyquistfrequency,thesamplesarealwayshittingthesamepointonthe
sinusoid,wedontseeitsphase.
9.2.5Whatstheuse?
Goodquestion.Well,whatwevedoneistolookatasignalrepresentedintheTimedomain(inotherwords,
whatdoesthesignaldoifwelookatitoveraperiodoftime)andconvertthatintoarepresentationinthe
Frequencydomain(inotherwords,whataretherepresentedfrequenciesinthissignal).Thesetwodomainsare
completelyinterrelated.Thatistosaythatifyoutakeanysignalinthetimedomain,ithasonlyone
representationinthefrequencydomain.Ifyoutakethatsignalsrepresentationinthefrequencydomain,youcan
convertitbacktothetimedomain.Essentially,youcancalculateonefromtheotherbecausetheyarejusttwo
differentwaysofexpressingthesamesignal.
Forexample,Icanusethewordtwoorthesymbol2toexpressaquantity.Bothmeanexactlythesame
thingthereisnodifferencebetween2chairsandtwochairs.Thesameistruewhenyouremovingback
andforthbetweenthefrequencydomainandtimedomainrepresentationsofthesamesignal.Thesignalstaysthe
sameyoujusthavetwodifferentwaysofwritingitdown.
9.2.6Themath
NowthatyouknowhowaDFTisactuallyperformed,letslookathowtheotherbooksdescribeit.Youll
usuallyseeaDFTdefinedusingaslightlyuglyequationlikeEquation9.3.Thisactuallyisthemathematical
representationoftheprocessIjustdescribed,wherethesignalismultipliedbytherealandinvertedimaginary
components,frequencybyfrequency,andtheresultsarealladdeduptogiveasinglecomplexnumberper
frequency.
(9.3)
whereXisadiscretetimesignal,nisthetimeinsamples,andfisthefrequencyrelativetothesamplingrate
InEquation9.3,youhaveasignalcalledXthathasanumberofsamplesinit(thesamplenumberiscalledn,
sothevalueofthesampleattime0iscalledX(0)thereforen=0).ThesamplesinsignalXgoingfromthe
beginningoftime(n=)totheendoftime(n=)aremultipliedbyej2fn(rememberfromSection1.7that
thismeansacosinewaveandanupsidedownsinewave)atsomefrequencyf.Alloftheresultsofthat
multiplicationarethenaddedtogether(hencethe).Thisisdoneforallfrequenciesbetween (halfofthe
samplingrate,butrotatingbackwards)to .
So,themathinEquation9.3describesthesamethingaswasdiscussedinthischapter.Itjustmakesthingsa
littlelessaccessible.
IfyouaredoinganFFTinsteadofaDFT,thenthingsareslightlydifferentasisshowninEquation9.4.The
onlyrealdifferenceisthatwedonthavealimitationonf.Apartfromthat,thingsarejustaboutthesame,but
becausewereworkingwithcontinuoustime,wehavetouseanintegralinsteadofasimplesum(ifthe
differenceisconfusing,seeSection1.9).
(9.4)
whereXisadiscretetimesignal,isthetime,andfisthefrequencyrelativetothesamplingrate

9.2.7SuggestedReadingList
[Strawn,1985]

9.3WindowingFunctions
Nowthatweknowhowtoconvertatimedomainsignalintoafrequencydomainrepresentation,letstryitout.
Wellstartbycreatingasimplesinewavethatlastsfor1024samplesandiscomprisedofnearly4cyclesasis
showninFigure9.12.

Figure9.12:Asinewave.
Ifwedoa1024pointDFTofthissignalandshowthemodulusofeachbin(notincludingtheredundancyin
themirrorimage),itwilllooklikeFigure9.13.

Figure9.13:TheDFTofthesinewaveinFigure9.12.
Youllnoticethattheresabigspikeatonefrequencyandalittlenoise(verylittle...350dBisaVERY
smallnumber)inalloftheotherbins.Incaseyourewondering,thenoiseiscausedbythelimitedresolutionof
MATLABwhichIusedforcreatingthesegraphs.MATLABcalculatesnumberswitharesolutionof64bits
(floatingpoint).Thatgivesusadynamicrangeofabout385dBorsotoworkwithmorethanenoughforthis
textbook...Morethanenoughformostthings,actually...
Now,whatwouldhappenifwehadadifferentfrequency?Forexample,Figure9.14showsasinewavewith
afrequencyof0.875timestheoneinFigure9.12.


Figure9.14:Asinewavewithafrequencyof0.875timestheoneinFigure9.12.
Ifwedoa1024pointDFTonthissignalandjustlookatthemodulusoftheresult,wegettheplotshownin
Figure9.15.

Figure9.15:TheDFTofthesinewaveinFigure9.14.
YoullprobablynoticethatFigure9.13isverydifferentfromFigure9.15.Wecantellfromtheformer
almostexactlywhatthesignalis,andwhatitisnt.Inthelatter,however,wegetabigmushofinformation.We
canseethattheresmoreinformationinthelowendthaninthehighend,butwereallycanttellthatitsasine
wave.Whydoesthishappen?
Theproblemisthatweveonlytakenasliceoftime.WhenyoudoaDFT,itassumesthatthetimesignal
yourefeedingitisperiodic.Letsmakethesameassumptiononourtwosinewavesshownabove.Ifwetakethe
firstone(showninFigure9.12)andrepeatit,itwilllooklikeFigure9.16.Youcanseethattherepetitionjoins
smoothlywiththefirstpresentationofthesignal,sothesignalcontinuestobeasinewave.Ifwekeptrepeating
thesignal,youdgetsmoothconnectionsbetweenthesignalsandyoudjustmakealongerandlongersinewave.
Inotherwords,asfarasthecomputerknows,thesinewavethatitsanalysingstartedatthebeginningoftime,it
willcontinueuntiltheendoftime,anditwillalwaysbeasinewave.

Figure9.16:ThesinewaveinFigure9.12repeatedonce.
Ifwetakethesecondsinewave(showninFigure9.14)andrepeatit,wegetFigure9.17.Now,wecansee
thatthingsarentsopretty.Becausethelengthofthesignalisnotanintegernumberofcyclesofthesinewave,
whenwerepeatit,wegetanastylookchangeinthesinewave.Infact,ifyoulookatFigure9.17,youcansee

thatitcantbecalledasinewaveanymore.Ithassomepartsthatlooklikeasinewave,buttheresaspikeinthe
middle.Ifwekeeprepeatingthesignaloverandover,wevegetaspikeforeveryrepetition.

Figure9.17:ThesinewaveinFigure9.14repeatedonce.
Thatspike(alsocalledadiscontinuity)inthetimesignalcontainsenergyinfrequencybinsotherthanwhere
thesinewaveis.infact,thisenergycanbeseenintheDFTthatwedidinFigure9.15.
Themoralofthestorythusfaristhatifyoursignalsperiodisnotthesamelengthas1moresamplethanthe
windowoftimeyouredoingtheDFTon,thenyouregoingtogetastrangeresult.Whydoesithavetobe1
moresample?Thisisbecauseiftheperiodwasequaltothewindowlength,thenwhenyourepeatedit,youdget
arepetitionofthesignalbecausethefirstsampleinthewindowisthesameasthelast.(Infact,ifyoulook
carefullyattheendofthesignalinFigure9.12,youllseethatitdoesntquitegetbackto0forexactlythis
reason.
Howdowesolvethisproblem?Well,wehavetodosomethingtothesignaltomakesurethatthenastyspike
goesawaywhenwerepeatit.Theconceptisbasicallythesameasdoingacrossfadebetweentwosounds
werejustgoingtomakesurethatthesignalinthewindowstartsat0,fadesin,andthenfadesawayto0before
wedotheDFT.Wedothisbyintroducingsomethingcalledawindowingfunction.Thisisatimedependentgain
thatismultipliedbyoursignalasisshowninFigure9.18.

Figure9.18:Anexampleofawindowingfunction.TheXvalueofthesignalcorrespondstoatime
positionwithinthewindow.TheYvalueisagainmultiplierusedtochangethelevelofthesignal
weremeasuring.
LetstakethesignalinFigure9.14theonethatcausedusalltheproblems.Ifwemultiplyeachofthe
samplesinthatsignalwithitscorrespondinggainshowninFigure9.18,thenwegetasignalthatlookslikethe
oneshowninFigure9.19.


Figure9.19:TheresultofthesignalinFigure9.14multipliedbythegainfunctionshowninFigure
9.18.
YoullnoticethatthesignalstillhasthesinewavefromFigure9.14,butwevechangeditslevelovertimeso
thatitstartsandendswitha0value.Thisway,whenwerepeatit,theendsjointogetherseamlessly.Now,ifwe
doa1024pointDFTonthissignalwegetFigure9.20.

Figure9.20:TheDFTofthesignalshowninFigure9.19.
Okay,sotheendresultisntperfect,butweveattenuatedthejunkinformationbyasmuchas100dB,which,
ifyouaskmeisprettydarnedgood.
Ofcourse,likeeverythinginlife,thiscomesatacost.Whathappensifweapplythesamewindowing
functiontothewellbehavedsignalinFigure9.12anddoaDFT?TheresultwilllooklikeFigure9.21.

Figure9.21:TheresultofthesignalinFigure9.12multipliedbythegainfunctionshowninFigure
9.18.
So,youcanseethatapplyingthewindowingfunctionmadebadthingsbetterbutgoodthingsworse.The
moralhereisthatyouneedtoknowthatusingawindowingfunctionwillhaveaneffectontheoutputofyour
DFTcalculation.Sometimesyoushoulduseit,sometimesyoushouldnt.Ifyoudontknowwhetheryoushould
ornot,youshouldtryitwithandwithoutanddecidewhichworkedbest.


Figure9.22:TheDFTofthesignalshowninFigure9.21.
So,weveseenthatapplyingawindowingfunctionwillchangetheresultingfrequencyresponse.Thegood
thingisthatthischangeispredictable,anddifferentfordifferentfunctions,soyoucannotonlychoosewhether
ornottowindowyoursignal,butyoucanalsochoosewhatkindofwindowtouseaccordingtoyour
requirements.
Thereareessentiallyaninfinitenumberofdifferentwindowingfunctionsavailableforyou,buttherearea
numberofstandardonesthateveryoneusesfordifferentreasons.Welllookatonlyasmallnumberofthemto
avoidmakingthebooklongerthanitneedstobe...
9.3.1IntroductiontoRectangularWindows
Therectangularwindowisthesimplestofallthewindowingfunctionsbecauseyoudonthavetodoanything.If
youmultiplyeachvalueinyourtimesignalby1(inotherwords,donothingtoyoursignal)thenyourgain
functionwilllooklikeFigures9.23to9.26,dependingonhowlongyourwindowis.Thesegraphslooklike
rectangles,sowecalldoingnothingormultiplyingby1arectangularwindow.(Somefolkscallthisa
DirichletwindowaftertheGermanmathematicianJohannPeterGustavLejeuneDirichlet1

Figure9.23:Timevs.gainresponseofrectangularwindowingfunction2sampleslong.

Figure9.24:Timevs.gainresponseofrectangularwindowingfunction4sampleslong.

Figure9.25:Timevs.gainresponseofrectangularwindowingfunction8sampleslong.

Figure9.26:Timevs.gainresponseofrectangularwindowingfunction64sampleslong.
Now,letsdosomethingalittlestrange.LetspretendforawhilethatthewindowingfunctioninFigure9.23
isactuallyanaudiosignalandletslookatitsspectruminotherwords,ifyousentthatsignaltoaloudspeaker,
whatisitsfrequencycontent?WecanfindthisoutbydoingaDFTofthesignal,whichresultsinthegeneral
responseshowninFigure9.27.

Figure9.27:Frequencyresponse(normalised)ofthe2samplelongrectangularwindowingfunction

showninFigure9.23.
Noticethatthefrequencyaxisofthisplotisshownasamultipleofthesamplingrate,goingfrom0Hz(DC)
totheNyquistfrequency(0.5*thesamplingrate).Thismakessomeintuitivesense,sincethetimesignal(1)has
onlypositivevalues(thereforeithastohavesomeDCcomponentkeepingitabove0...)and(2)istwo1sina
rowthereforeanythingattheNyquist(whichwouldbegoingpositiveandnegativeonadjacentsamples)will
notexist.
IfwedothesameforFigures9.24to9.26wegetthemagnituderesponsesshowninFigures9.28to9.30.
Youmightbecurioustonotethattherehalfasmanynotchesinthemagnituderesponsesastherearesamplesin
thetimesignals.Thisisnotreallyveryimportantitsjustinteresting...

Figure9.28:Frequencyresponseofthe4samplelongrectangularwindowingfunctionshownin
Figure9.24.

Figure9.29:Frequencyresponseofthe8samplelongrectangularwindowingfunctionshownin
Figure9.25.

Figure9.30:Frequencyresponseofthe64samplelongrectangularwindowingfunctionshownin
Figure9.26.
So,youcanseethatthespectralcontentofarectangularwindowingfunction(inotherwords,asignalwitha
bunchof1sinarow)hasaweirdbehaviourwithalotofnotchesinitthelongerthewindowlength,themore
notcheswehave.Thisalsomeansthat,thelongerthewindowlength,themorecloselythenotchesarespacedin
frequency.
9.3.2SpectralLeakage
Hereswherethingsgetalittleweird...Ifwetakeaportionofasinewaveandmultiplyitbyarectangular
windowingfunction(inotherwords,donothingtoit...)anddoaDFToftheresult,wellseesomethingstrange
thatwevealreadylearnedtoexpect...sortof...Whatwellseeisthat,althoughthesinewaveshouldconsistof
energyatonlyonefrequency,theDFTwillprobablytellusthattheresenergyinlotsofotherfrequencybins
(unless,aswealreadysaw,thatthesinewavehasexactlythesamefrequencyasthecentrefrequencyofoneof
theDFTbinsbutthisisaspecialcasethatneverhappensinthewild).Whatwellseeisenergyfromthesignal
leakingintootherfrequencybinsaneffectthatiscalledspectralleakage.
Forexample,wesawbackinFigure9.15that,ifwerenotreallycarefulorreallylucky,aDFTwilltellus
thatthereisenergyinfrequencybinswherewedontexpectittobethatsthespectralleakage.Thenicething
isthatitshasaverypredictablebehaviour.
ThinkbacktotheplotsinFigures9.27to9.30.Isaidthattheseweremagnitudeplotsofthespectralcontent
ofrectangularwindowsofdifferentlengths,ifwetreatedthemasiftheywereaudiosignalsinsteadof
windowingfunctions.Itturnsoutthatthesearealsoplotsofthespectralleakagethosefunctionswillgenerateif
weusethemtowindowatimesignalbeforedoingaDFTofit.Illexplainwhatthatmeans...
Letssaythatwemakeasinewavewithafrequencyof1024Hz,andwedoaDFTofit,anditjustso
happensthatoneofourDFTbinshasacentrefrequencyof1024Hz.Then,thefrequencyofthesinewaveisthe
sameasabinfrequencyandwellmagicallygetnospectralleakage.ThisisillustratedinFigure9.31.

Figure9.31:Acasewherethesignalbeinganalysedisasinewavewiththesamefrequencyasoneof
theDFTbins.TheblueXisthemagnitudeofthesinewave,andtheredstaristheoutputofthe
DFT.Noticehowallotherbinshavedeep(actually,infinite)notchesonthem.Thiscommentwill
makemoresenseshortly...
Nowletstakeacasewherethefrequencyofthesinewaveishalfwaybetweenthecentrefrequenciesoftwo
adjacentDFTbins.Whatwillhappen?Well,sincetherearenoDFTbinswherethesinewaveis(infrequency)
theenergyhastoshowupsomewhere...So,itleaksallovertheplace.TakealookatFigure??whichshowsthis
case.

Figure9.32:Acasewherethesignalbeinganalysedisasinewavewithafrequencythatisexactly
halfwaybetweentwoadjacentDFTbins.TheblueXisthemagnitudeofthesinewave(notice
thatthereisnoDFTbinthere...),andtheredstarsaretheoutputsoftheDFT.Noticehowall
otherbinsnowhaveanoutput,sincethenotchesarentonthemliketheywereinFigure9.31.
Ifthesinewavehasafrequencysomewhereelse,thenthedistributionofenergyintheDFTbinswillchange,
asyoucanseeinFigures9.33and9.34.

Figure9.33:Acasewherethesignalbeinganalysedisasinewavewithafrequencythatis25%ofthe
waybetweentwoadjacentDFTbins.TheblueXisthemagnitudeofthesinewave(noticethat
thereisnoDFTbinthere...),andtheredstarsaretheoutputsoftheDFT.

Figure9.34:casewherethesignalbeinganalysedisasinewavewithafrequencythatis75%ofthe
waybetweentwoadjacentDFTbins.TheblueXisthemagnitudeofthesinewave(noticethat
thereisnoDFTbinthere...),andtheredstarsaretheoutputsoftheDFT.
Oneminorproblem:ImbeingalittlemisleadinginFigures9.34to9.34.Youhavetorememberinthese
plotsthattheonlyoutputfromtheDFTwillbethevaluesoftheredstars.Althoughtheeffectoftherectangular
windowwillbetheblackline,theonlywayweseeitisasdiscretevaluesforeachbin.
So,nowyoushouldbeabletomakeasmalljump.LookatFigure9.32,rescaleitinyourheadsothattheX
axis(which,althoughitslabeledDFTbinsisreallythefrequencydomain...)isonalogarithmicscaleinstead
ofalinearone.YoushouldcomeupwithaplotthatisnotverydifferentfromFigure9.15.Infact,theyshow
essentiallythesamething...
So,nowthatweknowhowtoreadtheSpectralLeakageplotsabove,letsploughthroughsomedifferent
typesofwindowingfunctionsanddiscusstheireffectontheresultsyoullseecomingoutofaDFT.
9.3.3RectangularWindows(Part2)
Aswevealreadyseen,arectangularwindowhastheniceeffectthat,ifyourfrequencycontentofthesignal
youreanalysingisexactlythesameasyourDFTbinfrequencies,thenyougetaverygoodideaofwhatsgoing
oninthesignal.However,ifthefrequenciesdontlineupnicely(forexample,ifyoureusingaDFTtogetan
ideaofthespectralcontentofasnippetofaBachviolinpartita)thenyoullgetsmearingallovertheplace,and
youcantreallygetmuchofanideaofwhatsgoingoninanythingotherthanageneralsense.

Ontheotherhand,arectangularwindowiscertainlyeasytouse,sinceyoudonthavetodoanythingtoyour
signalotherthantakeasliceofit.However,ifyouregoingtothetroubleofdoingaDFT,thenabitof
windowingisntgoingtohurtyou...

Figure9.35:Spectralleakagecausedbyarectangularwindowingfunction.

Figure9.36:Closeupofthespectralleakagecausedbyarectangularwindowingfunction.

Figure9.37:CAPTIONTOGOHERE

Figure9.38:CAPTIONTOGOHERE
9.3.4Hann
YouhavealreadyseenoneotherstandardwindowingfunctioninFigure9.18.ThisisknownasaHannwindow2
andisdefinedusingtheequationbelow[Morfey,2001].

Thislooksalittlecomplicated,butifyouspendsometimewithit,youllseethatitisexactlythesamemath
asacardioidmicrophone.Itsaysthat,withinthewindow,youhavethesameresponseasacardioidmicrophone
(replacingtheangleofincidenceinthemicrophonewiththetimewithinthewindow),andoutsidethewindow,
thegainis0.3ThisisshowninFigure9.39

Figure9.39:Timevs.gainresponseofHannwindowingfunction.
ThespectralleakageforaHanningwindowisshowninFigure9.40.Youcanseeherethat,comparedtothe
rectangularwindow,wegetmuchmoreattenuationofunwantedsignalsfarawayfromthefrequencieswere
interestedin.Butthiscomesatacost...

Figure9.40:SpectralleakagecausedbyaHannwindowingfunction.

Figure9.41:CloseupofthespectralleakagecausedbyaHannwindowingfunction.
TakealookatFigure9.41whichshowsacloseupofthespectralleakageofaHanningwindow.Youcansee
herethatthecentrelobeismuchwiderthantheonewesawforarectangularwindow.So,thismeansthat,
althoughyoullgetbetterrejectionofsignalsfarawayfromthefrequenciesthatyoureinterestedin,youllalso
getmoregarbageleakingintoDFTbinsveryclosetothosefrequencies.So,ifyoureinterestedinabroad
perspective,thiswindowmightbeuseful,ifyourezoominginonaspecificfrequency,youmightbebetteroff
usinganotherwindowingfunction.

Figure9.42:CAPTIONTOGOHERE

Figure9.43:CAPTIONTOGOHERE
9.3.5Hamming
OurnextwindowingfunctionisknownastheHamming4window.Theequationforthisis

ThisgainresponsecanbeseeninFigure9.44.Noticethatthisoneisslightlyweirdinthatitneveractually
reaches0attheendsofthewindow,soyoudontgetacompletelysmoothtransition.

Figure9.44:Timevs.gainresponseofHammingwindowingfunction.
ThespectralleakagecausedbyaHammingwindowisshowninFigure9.45.Noticethattherejectionof
frequenciesfarawayfromthecentreisbetterthanwiththerectangularwindow,butworsethanwiththeHanning
function.

Figure9.45:SpectralleakagecausedbyaHammingwindowingfunction.
So,whydoweusetheHammingwindowinsteadoftheHanningifitsrejectionisworseawayfromthe0Hz
line?Thecentrelobeisstillquitewide,sothatdoesntgiveusanadvantage.However,takealookatthelobes
adjacenttothecentreinFigure9.46.Noticethatthesearequitelow,andverynarrow,particularlywhentheyre
comparedtotheothertwofunctions.Welllookatthemsidebysideinonegraphalittlelater,sononeedtoflip
pagesbackandforthatthispoint.

Figure9.46:CloseupofthespectralleakagecausedbyaHammingwindowingfunction.

Figure9.47:CAPTIONTOGOHERE

Figure9.48:CAPTIONTOGOHERE
9.3.6Triangular

Figure9.49:Timevs.gainresponseofTriangularwindowingfunction.

Figure9.50:SpectralleakagecausedbyaTriangularwindowingfunction.

Figure9.51:CloseupofthespectralleakagecausedbyaTriangularwindowingfunction.

Figure9.52:CAPTIONTOGOHERE

Figure9.53:CAPTIONTOGOHERE
9.3.7Bartlett

Figure9.54:Timevs.gainresponseofBartlettwindowingfunction.

Figure9.55:SpectralleakagecausedbyaBartlettwindowingfunction.

Figure9.56:CloseupofthespectralleakagecausedbyaBartlettwindowingfunction.

Figure9.57:CAPTIONTOGOHERE

Figure9.58:CAPTIONTOGOHERE
9.3.8BartlettHann

Figure9.59:Timevs.gainresponseofBartlettHannwindowingfunction.

Figure9.60:SpectralleakagecausedbyaBartlettHannwindowingfunction.

Figure9.61:CloseupofthespectralleakagecausedbyaBartlettHannwindowingfunction.
9.3.9Blackman

[OppenheimandSchafer,1999]

Figure9.62:Timevs.gainresponseofBlackmanwindowingfunction.

Figure9.63:SpectralleakagecausedbyaBlackmanwindowingfunction.

Figure9.64:CloseupofthespectralleakagecausedbyaBlackmanwindowingfunction.

Figure9.65:CAPTIONTOGOHERE

Figure9.66:CAPTIONTOGOHERE
9.3.10BlackmanHarris

where
a0=0.35875
a1=0.48829
a2=0.14128
a3=0.01168
[Harris,1978]

Figure9.67:Timevs.gainresponseofBlackmanHarriswindowingfunction.

Figure9.68:SpectralleakagecausedbyaBlackmanHarriswindowingfunction.

Figure9.69:CloseupofthespectralleakagecausedbyaBlackmanHarriswindowingfunction.
9.3.11BlackmanNuttall

where
a0=0.3635819
a1=0.4891775
a2=0.1365995
a3=0.0106411
[Nuttall,1981]

Figure9.70:Timevs.gainresponseofBlackmanNuttallwindowingfunction.

Figure9.71:SpectralleakagecausedbyaBlackmanNuttallwindowingfunction.

Figure9.72:CloseupofthespectralleakagecausedbyaBlackmanNuttallwindowingfunction.
9.3.12Tukey
NOTES:
Alsoknownasataperedcosinewindow
TheTukeywindowisaninterestingone,sinceitsactuallyafamilyofwindows.
When=0,thenaTukeywindowisarectangularwindow.When=1,thenaTukeywindowisaHann
window.

xislinspace(0,L1)

Figure9.73:Timevs.gainresponseofanexampleofaTukeywindowingfunction.

Figure9.74:SpectralleakagecausedbytheTukeywindowingfunctionshowninFigure9.73.

Figure9.75:CloseupofthespectralleakagecausedbyaTukeywindowingfunction.
9.3.13Morefunctions
TherearelotsmorewindowingfunctionssuchasBohman,andParzen(alsoknownasdelaVallePoussin).
9.3.14Comparisons
Figure9.76showsthethreestandardwindowscomparedononegraph.Asyoucansee,therectangularwindow
inbluehasthenarrowestcentrelobeofthethree,buttheleastattenuationofitsotherlobes.TheHanning
windowinblackhasawidercentrelobebutgoodrejectionofitsotherlobes,gettingbetterandbetterasweget
furtherawayinfrequency.Finally,theHammingwindowinredhasawidecentrelobe,butmuchbetterrejection
initsadjacentlobes.

Figure9.76:Frequencyresponseofthreecommonwindowingfunctions.Rectangular(blue),
Hamming(red)andHanning(black).
9.3.15Onelastlittlething...
Theresaratherbasicproblemthatwevebeendancingaroundforthepasttwochapters.Aswevenowseen,a
FourierTransformisagreattoolifyouhaveatimedomainsignalandyouwanttogetanideaofitsspectral
content.However,youllonlygetanideayouwontknowanythingaccurately...Thebasicproblemisthat,in
ordertohaveprecisioninthefrequencydomain,youllneedtotakeaverylongsliceoftime...Themore
precisionyouwantinfrequency,thelongeryoullhavetowaitfortheanswer.Ofcourse,thismeansthatifyou
wanttotakeaveryshortsliceoftime(say,theimpulseresponseofaloudspeakerbeforethefirstwallreflection
arrivesatyourmicrophone,foreexample...)thenyourcostisprettybadresolutioninthefrequencydomain.
Inotherwords,youcanthavegoodtimeresolutionandfrequencyresolutioninthesamemeasurement.Oneis
thecostforgettingtheother.ThisproblemisapartofwhatisknownastheGaborLimitortheHeisenberg
GaborLimit.5
AnadditionalproblemassociatedwiththeGaborLimitisthatasignalcanbeeithertimelimitedorband
limited,butitcannotsimultaneouslybeboth.ThisisintuitivelyseeninFigured9.14and9.15whereitssortof
shownthat,bytakingasliceofasinewave,youcreateasignalthathasaninfinitefrequencybandwidth.
9.3.16SuggestedReadingList

9.4FIRFilters
WevenowseeninSections9.2thatthereisadirectlinkbetweenthetimedomainandthefrequencydomain.If
wemakeachangeinasignalinthetimedomain,thenwemustincurachangeinthefrequencycontentofthe
signal.Waybackinthesectiononanalogfilterswelookedathowwecanusetheslowtimeresponseofa
capacitororaninductortochangethefrequencyresponseofasignalpassedthroughit.
Nowwearegoingtostartthinkingabouthowtointentionallychangethefrequencyresponseofasignalby
makingchangestoitinthetimedomaindigitally.
9.4.1CombFilters
WevealreadyseenbackinSection3.2.4thatacombfilterisaneffectthatiscausedwhenasignalismixedwith
adelayedversionofitself.Thishappensinreallifeallthetimewhenadirectsoundmeetsareflectionofthe
samesoundatyoureardrum.Thesetwosignalsaremixedacousticallyandtheresultisachangeinthetimbreof
thedirectsound.
So,letsimplementthisdigitally.ThiscanbedoneprettyeasilyusingtheblockdiagramshowninFigure
9.77whichcorrespondstoEquation9.5.

Figure9.77:Basicblockdiagramofacombfilterimplementedinthedigitaldomain.
(9.5)
ThisimplementationiscalledaFiniteImpulseResponsecombfilterorFIRcombfilterbecause,aswellsee
inthecomingsections,itsimpulseresponseisfinite(meaningitendsatsomepredictabletime)andthatits
frequencyresponselooksalittlelikeahaircomb.
Aswecanseeinthediagram,theoutputconsistsoftheadditionoftwosignals,theoriginalinputandagain
modifieddelayedsignal(thedelayistheblockwiththezkinit.Welltalklateraboutwhythatnotationisused,
butfornow,youllneedtoknowthatthedelaytimeisksamples.).Letsassumefortheremainderofthissection
thatthegainvalueaisbetween1and1,andisnot0.(Ifitwas0,thenwewouldntheartheoutputofthedelay
andwewouldnthaveacombfilter,wedjusthaveathroughputwheretheoutputisidenticaltotheinput.)
Ifwerethinkingintermsofacoustics,thedirectsoundissimulatedbythenondelayedsignal(thethrough
put)andthereflectionissimulatedbytheoutputofthedelay.
DelaywithPositiveGain

LetstakeanFIRcombfilterasisdescribedinFigure9.90andEquation9.5andmakethedelaytimeequalto1
sample,anda=1.Whatwillthisalgorithmdotoanaudiosignal?
Wellstartbythinkingaboutasinewavewithaverylowfrequencyinthiscasethephasedifference
betweentheinputandtheoutputofthedelayisverysmallbecauseitsonly1sample.Thelowerthefrequency,
thesmallerthephasedifferenceuntil,at0Hz(DC)thereisnophasedifference(becausethereisnophase...).
Sincetheoutputistheadditionofthevaluesofthetwosamples(now,and1sampleago),wegetmoreatthe
outputthantheinput.At0Hz,theoutputisequaltoexactlytwotimestheinput.Asthefrequencygoeshigher,
thephasedifferencecausedbythedelaygetsbiggerandtheoutputgetssmaller.
Now,letsthinkofasinewaveattheNyquistfrequency(seeSection8.1.3ifyouneedadefinition).Atthis
frequency,asampleandtheprevioussampleareseparatedby180,therefore,theyareidenticalbutoppositein

polarity.Therefore,theoutputofthiscombfilterwillbe0attheNyquistFrequencybecausethesamplesare
cancellingthemselves.AtfrequenciesbelowtheNyquist,wegetmoreandmoreoutputfromthefilter.
IfweweretoplottheresultingfrequencyresponseoftheoutputofthefilteritwouldlooklikeFigure9.78.
(Notethattheplotusesanormalizedfrequency,explainedinSection9.1.2.)

Figure9.78:FrequencyresponseofanFIRcombfilterwithadelayof1sample,a0=1,anda1=1
WhatwouldhappenifthedelayintheFIRcombfilterwere2sampleslong?Wecanthinkoftheresultinthe
samewayaswedidinthepreviousdescription.AtDC,thefilterwillbehaveinthesamewayastheFIRcomb
witha1sampledelay.AttheNyquistFrequency,however,thingswillbealittledifferent...AttheNyquist
frequency(anormalizedfrequencyof0.5),everysecondsamplehasanidenticalvaluebecausetheyre360
apart.Therefore,theoutputofthefilterattheNyquistFrequencywillbetwotimestheinputvalue,justasinthe
caseofDC.
AtonehalftheNyquistFrequency(anormalizedfrequencyof0.25)thereisa90phasedifferencebetween
samples,thereforethereisa180phasedifferencebetweentheinputandtheoutputofthedelay.Therefore,at
thisfrequency,ourFIRcombfilterwillhavenooutput.
ThefinalfrequencyresponseisshowninFigure9.79.

Figure9.79:FrequencyresponseofanFIRcombfilterwithadelayof2samples,a0=1,anda1=1
AsweincreasethedelaytimeintheFIRcombfilter,thefirstnotchinthefrequencyresponsedropslower
andlowerinfrequencyascanbeseeninFigures9.80and9.81.


Figure9.80:FrequencyresponseofanFIRcombfilterwithadelayof3samples,a0=1,anda1=1

Figure9.81:FrequencyresponseofanFIRcombfilterwithadelayof4samples,a0=1,anda1=1
Uptonow,wehavebeenlookingatthefrequencyresponsegraphsonalinearscale.Thishasbeentogive
youanideaofthebehaviouroftheFIRcombfilterinamathematicalsense,butitreallydoesntprovidean
intuitivefeelforhowitwillsound.Inordertogetthis,wehavetoplotthefrequencyresponseonasemi
logarithmicplot(wheretheXaxisshowsthefrequencyonalogarithmicscaleandtheYaxisisonalinear
scale).ThisisshowninFigure9.82.

Figure9.82:FrequencyresponseofanFIRcombfilterwithadelayof3samples,a0=1,anda1=1.
NotethatthisisthesameasthegraphinFigure9.80
Sofar,wehavekeptthegainontheoutputofthedelayat1tomakethingssimple.Whathappensifthisisset
toasmaller(butstillpositive)number?Thebumpsandnotchesinthefrequencyresponsewillstillbeinthe
sameplaces(inotherwords,thewontchangeinfrequency)buttheywontbeasdrastic.Thebumpswontbeas
bigandthenotcheswontbeasdeep.


Figure9.83:FrequencyresponseofanFIRcombfilterwithadelayof3samples,a0=1.Blacka1=1,
bluea1=0.5,reda1=0.25.

Figure9.84:FrequencyresponsesofanFIRcombfilterwithadelayof3samples,a0=1.Blacka1=
1,bluea1=0.5,reda1=0.25.

Figure9.85:FrequencyresponsesofanFIRcombfilterwithadelayof3samples,a0=1.Blacka1=
1,bluea1=0.5,reda1=0.25.
DelaywithNegativeGain

Intheprevioussectionwelimitedthevalueofthegainappliedtothedelaycomponenttopositivevaluesonly.
However,wealsohavetoconsiderwhathappenswhenthisgainissettoanegativevalue.Inessence,the
behaviouristhesame,butwehaveareversalbetweentheconstructiveanddestructiveinterferences.Inother
words,whatwerebumpsbeforebecomenotches,andthenotchesbecomebumps.
Forexample,letsuseanFIRcombfilterwithadelayof1sampleandwherea0=1,anda1=1.AtDC,the
outputofthedelaycomponentwillbeidenticaltobutoppositeinpolaritywiththenondelayedcomponent.This
meansthattheywillcanceleachotherandwegetnooutputfromthefilter.Atanormalizedfrequencyof0.5(the
NyquistFrequency)thetwocomponentswillbe180outofphase,butsinceweremultiplyingoneby1,they
addtomaketwicetheinputvalue.
TheendresultisafrequencyresponseasisshowninFigures9.86.


Figure9.86:FrequencyresponseofanFIRcombfilterwithadelayof1sample,a0=1,anda1=1
Ifwehavealongerdelaytime,thenwegetasimilarbehaviourasisshowninFigure9.87.

Figure9.87:FrequencyresponseofanFIRcombfilterwithadelayof4samples,a0=1,anda1=1
Ifthegainappliedtotheoutputofthedelayissettoavaluegreaterthan1butlessthan0,weseeasimilar
reductioninthedeviationfromagainof1aswesawintheexampleswithFIRcombfilterswithapositivegain
delaycomponent.
9.4.2FrequencyResponseDeviation
IfyouwanttogetanideaoftheeffectofanFIRcombfilteronafrequencyresponse,wecancalculatethelevels
ofthemaximaandminimainitsfrequencyresponse.Forexample,themaximumvalueofthefrequency
responseshowninFigure9.85is6dB.TheminimumvalueisdB.Thereforeatotalpeaktopeakvariationin
thefrequencyresponseisdB.
WecancalculatethesedirectlyusingEquations9.6and9.7[Martin,2002a].
(9.6)
(9.7)
InordertofindthetotalpeaktopeakvariationinthefrequencyresponseoftheFIRcombfilter,wecanuse
Equation9.8.
(9.8)
9.4.3ImpulseResponsevs.FrequencyResponse
Wehaveseeninearliersectionsofthisbookthatthetimedomainandthefrequencydomainarejusttwo
differentwaysofexpressingthesamething.Thisruleholdstruefordigitalfiltersaswellassignals.
BackinSection3.5.3thatweusedanimpulseresponsetofindthebehaviourofastringonamusical

instrument.WecandothesameforafilterimplementedinDSP,withalittlefudginghereandthere...Firstwe
havetomakethedigitalequivalentofanimpulse.Thisisfairlysimple,wejusthavetomakeaninfinitestringof
0swithasingle1somewhere.UsuallywhenthissignalisdescribedinaDSPbook,wethinkofthe1as
happeningnow,thereforeweseeadescriptionlikeEquation9.4.3.

ThisdigitalequivalenttoanimpulseiscalledaDiracimpulse(namedafterPaulDirac,anEnglish
mathematician6).Althoughinthedigitaldomainitlooksalotlikeanimpulse,itreallyisntbecauseitisnt
infinitelyshortofinfinitelyloud.Ontheotherhand,itbehavedinaverysimilarwaytoarealimpulsesince,in
thedigitaldomain,ithasaflatfrequencyresponsefromDCtotheNyquistFrequency.
WhathappensattheoutputwhenwesendtheDiracimpulsethroughtheFIRcombfilterwitha3sample
delay?First,weseetheDiraccomeouttheoutputatthesametimeitarrivesattheinput,butmultipliedbythe
gainvaluea0(uptonow,wehaveused1forthisvalue).Then,threesampleslater,weseetheimpulseagainat
theoutput,thistimemultipliedbythegainvaluea1.
Sincenothinghappensafterthis,theimpulseresponsehasended(wecouldkeepmeasuringit,butwewould
justget0sforever...)whichiswhywecalltheseFIR(forfiniteimpulseresponse)filters.Ifanimpulsegoesin,
thefilterwillstopgivingyouanoutputatapredictabletime.
Figure9.88showsthreeexamplesofdifferentFIRcombfilterimpulseresponsesandtheircorresponding
frequencyresponses.Notethatthedelayvaluesforallthreefiltersarethesame,thereforethenotchesandpeaks
inthefrequencyresponsesareallmatched.Onlythevalueofa1waschanged,thereforemodifyingtheamountof
modulationinthefrequencyresponses.

Figure9.88:ImpulseandcorrespondingfrequencyresponsesofFIRcombfilterswithadelayof3
samples.Blacka1=1,bluea1=0.5,reda1=0.25.
9.4.4Morecomplicatedfilters
Sofar,wehaveonlylookedatonesimpletypeofFIRfiltertheFIRcomb.Infact,thereareaninfinitenumber
ofothertypesofFIRfiltersbutmostofthemdonthavespecificnames(goodthingtoo,sincethereisaninfinite
numberofthem...wewouldspendforevernamingthings...).


Figure9.89:GeneralblockdiagramforanFIRfilter.
Figure9.89showsthegeneralblockdiagramforanFIRfilter.Noticethattherecanbeanynumberofdelays,
eachwithitsowndelaytimeandgain.
9.4.5SuggestedReadingList
[Steiglitz,1996]

9.5IIRFilters
SincewehaveaclassoffiltersthatarespecificallycalledFiniteImpulseResponsefilters,thenitstandsto
reasonthattheyrecalledthattodistinguishthemfromanothertypeoffilterwithaninfiniteimpulseresponse.If
youalreadyguessthis,thenyoudberight.ThatotherclassiscalledInfiniteImpulseResponse(orIIR)filtersfor
reasonsthatwillbeexplainedbelow.
9.5.1CombFilters
WehavealreadyseeninSection9.4.1thatacombfilterisonewithafrequencyresponsethatlookslikeahair
comb.InanFIRcombfilter,thisisaccomplishedbyaddingasignaltoadelayedcopyofitself.
ThiscanalsobeaccomplishedasanIIRfilter,however,boththeimplementationandtheresultsareslightly
different.
Figure9.90showsasimpleIIRcombfilter

Figure9.90:BasicblockdiagramofanIIRcombfilterimplementedinthedigitaldomain.
Ascanbeseenintheblockdiagram,wearenowusingfeedbackasacomponentinthefiltersdesign.The
outputofthefilterisfedbackwardsthroughadelayandagainmultiplierandtheresultisaddedbacktothe
input,whichisfedbackthroughthesamedelayandsoon...
Sincetheoutputofthedelayisconnected(throughthegainandthesumming)backtotheinputofthedelay,
itkeepsthesignalinaloopforever.ThatmeansthatifwesendaDiracimpulseintothefilter,theoutputofthe
filterwillbebusyforever,thereforeithasaninfiniteimpulseresponse.
ThefeedbackloopcanalsobeseeninEquation9.9whichshowsthegeneralequationforasimpleIIRcomb
filter.Noticethatthereisayonbothsidesoftheequationtheoutputatthemomenty[t]isformedoftwo
components,theinputatthesametime(now)x[t]andtheoutputfromksamplesagoindicatedbythey[tk].Of

course,bothofthesecomponentsaremultipliedbytheirrespectivegainfactors.
(9.9)
PositiveFeedback

LetsusetheblockdiagramshowninFigure9.77andmakeanIIRcomb.Wellmakea0=1,a1=0.5andk=3.
TheresultofthisisthataDiracimpulsecomesinthefilterandimmediatelyappearsattheoutput(becausea0=
1).Threesampleslater,italsocomesouttheoutputatonehalfthelevel(becausea1=0.5andk=3).
TheresultingimpulseresponsewilllooklikeFigure9.91.

Figure9.91:TheimpulseresponseoftheIIRcombfiltershowninFigure9.77andEquation9.9with
a0=1,a1=0.5andk=3.
Notethat,inFigure9.91,Ionlyplottedthefirst20samplesoftheimpulseresponse,however,itinfact
extendstoinfinity.
Whatwillthefrequencyresponseofthisfilterlooklike?ThisisshowninFigure9.92.

Figure9.92:ThefrequencyresponseoftheIIRcombfiltershowninFigure9.77andEquation9.9
witha0=1,a1=0.5andm=3.
ComparethiswiththeFIRcombfiltershowninFigure9.83.Thereareacoupleofthingstonoticeaboutthe
similarityanddifferencebetweenthetwographs.
Thesimilarityisthatthepeaksanddipsinthetwographsareatthesamefrequencies.Theyarentthesame
basicshape,buttheyappearatthesameplace.Thisisduetothematching3sampledelaysandthefactthatthe
gainappliedtothedelaysarebothpositive.
Thedifferencebetweenthegraphsisobviouslytheshapeofthecurveitself.WheretheFIRfilterhadbroad
peaksandnarrowdips,theIIRfilterhastheoppositenarrowpeaksandbroaddips.Thisisgoingtocausethe
twofilterstosoundverydifferent.Generallyspeaking,itismucheasierforustohearaboostthanacut.The
narrowpeaksinthefrequencyresponseofanIIRfilterareimmediatelyobviousasaudibleboostsinthesignal.
Thisisnotonlycausedbythefactthatthenarrowfrequencybandsareboosted,butthatthereisasmearingof

energyintimeatthosefrequenciesknownasringing.Infact,ifyoutakeanIIRfilterwithafairlyhighvalueof
a1saybetween0.5and0.999ofa0,andputinanimpulse,youllhearatoneringinginthefilter.Thehigherthe
gainofa1,thelongertheringingandthemoreobviousthetone.Thisfrequencyresponsechangecanbeseenin
Figure9.93.

Figure9.93:ThefrequencyresponseoftheIIRcombfiltershowninFigure9.77andEquation9.9
witha0=1andm=3.Blacka0=0.999,Reda0=0.5andbluea0=0.25.
NegativeFeedback

JustliketheFIRcounterpart,anIIRcombfiltercanhaveanegativegainatthedelayoutput.Ascanbeseenin
Figure9.92,positivefeedbackcausesalargeboostinthelowfrequencieswithapeakatDC.Thiscanbe
avoidedbyusinganegativefeedbackvalue.
Theinterestingthinghereisthattheresultofthenegativefeedbackthroughadelaycausestheimpulse
responsetoflipbackandforthinpolarityascanbeseeninFigure9.94.

Figure9.94:ThefrequencyresponseoftheIIRcombfiltershowninFigure9.77andEquation9.9
witha0=1,a1=0.5andm=3.
TheresultingfrequencyresponseforthisfilterisshowninFigure9.95.

Figure9.95:ThefrequencyresponseoftheIIRcombfiltershowninFigure9.77andEquation9.9
witha0=1,a1=0.5andm=3.

IIRcombfilterswithnegativefeedbacksufferfromthesameringingproblemsasthosewithpositive
feedbackascanbeseeninthefrequencyresponsegraphinFigure9.96.

Figure9.96:ThefrequencyresponseoftheIIRcombfiltershowninFigure9.77andEquation9.9
witha0=1andk=3.Blacka0=0.999,Reda0=0.5andbluea0=0.25.
9.5.2Danger!
ThereisoneimportantthingtobewareofwhenusingIIRfilters.Alwaysrememberthatfeedbackisanangry
animalthatcanlashoutandattackyouifyourenotcareful.Ifthevalueofthefeedbackgaingoeshigherthan1,
thenthingsgetuglyveryquickly.Thesignalcomesoutofthedelaylouderthanitwentit,andcirculatesbackto
theinputofthedelaywhereitcomesoutevenlouderandsoonandsoon.Dependingonthedelaytime,itwill
takeasmallfractionofasecondforthefiltertooverload.And,sinceithasaninfiniteimpulseresponse,evenif
youpullthefeedbackgainbacktolessthan1,thedistortionthatyoumayhavecausedwillalwaysbecirculating
inthefilter.Theonlywaytogetridofitistodropa1to0untilthedelayclearsoutandthenstartagain.
(AlthoughsomeIIRfiltersallowyoutosendaclearcommand,tellingthemtoforgeteverythingthatshappened
beforenow,andtocontinueonasifyouwerenormal.TakealookatsomeofthefiltersinMax/MSP,for
example.)
9.5.3Biquadratic
Whileitsfuntomakecombfilterstogetstarted(everybuddingguitaristhasaflangeroraphaserintheirkitof
pedaleffects.Therichkidsevenhavebothandclaimthattheyknowthedifference!)IIRfilterscanbealittle
moreuseful.Now,dontgetmewrong,FIRfiltersarealsouseful,butasyoullseeifyoueverhavetostart
workingwiththem,theyreprettyexpensiveintermsofprocessingpower.Basically,ifyouwanttodo
somethinginteresting,youhavetodoitforalongtime(ratherZen,no?).IfyouhaveanFIRfilterwithalong,
impulseresponse,thenthatmeansalotofdelays(orlongones)andlotsofmathtodo.Wellseeaworstcase
scenarioinSection9.6.1.
AsimpleIIRfilterhastheadvantageofhavingonlythreeoperations(twomultipliesandoneadd)andone
delay,andstillhavinganinfiniteimpulseresponse,soyoucandointerestingthingswithaminimumof
processing.
OneofthemostcommonbuildingblocksinanyDSPalgorithmisalittlepackagecalledabiquadraticfilter
orbiquadforshort.Thisisasortofminialgorithmthatcontainsajustsmallnumberofdelays,gainsand
additionsasisshowninFigure9.97,butitturnsouttobeaprettypowerfullittletoolsortoftheopampofthe
DSPworldintermsofusefulness.

Figure9.97:Blockdiagramofoneimplementationofabiquadfilter.Thereareotherwaystoachieve

thesamealgorithm,butwewontdiscussthatinthisbook.Check[Christensen,2003]formore
information.
Okay,letslookatwhatabiquaddoes,goingthroughit,gainbygain.
Takealookata0.Thesignalx[t]comesin,getsmultipliedbya0andgetsaddedtheoutputatthesame
time.Thisisjustagainappliedtotheinput.
Nowletslookata1.Thesignalx[t]comesin,getsdelayedby1sample,multipliedbya1andaddedtothe
output.Byitself,thisisjustthefeedforwardcomponentofanFIRcombfilterwithadelayof1sample.
a2.Thesignalx[t]comesin,getsdelayedby2samples,multipliedbya2andaddedtotheoutput.Byitself,
thisisjustthefeedforwardcomponentofanFIRcombfilterwithadelayof2samples.
b1.Thesignalx[t]comesin,getsdelayedby1sample,multipliedbyb1andaddedtotheinput.Byitself,
thisisjustthefeedbackcomponentofanIIRcombfilterwithadelayof1sample.
b2.Thesignalx[t]comesin,getsdelayedby2samples,multipliedbyb1andaddedtotheinput.Byitself,
thisisjustthefeedbackcomponentofanIIRcombfilterwithadelayof2samples.
TheendresultisanalgorithmdescribedbyEquation9.10.
(9.10)
So,whatweveseenisthatabiquadisanassemblyoftwoFIRcombsandtwoIIRcombs,allinoneneat
littlepackage.Theinterestingthingisthatthisalgorithmisextremelypowerful.So,Illbetyouresittingthere
wonderingwhatitsusedfor?Letslookatjustacoupleofexamples.
CalculatingBiquadCoefficients

ImportantNote:Ifyouwanttheoriginalversionofthissection,gototheoriginalsource,writtenbyRobert
BristowJohnsonandcalledtheAudioEQCookbook.Youllfinditathttp://www.musicdsp.org/files/AudioEQ
Cookbook.txt,or,ifitmoves,justdoasearchforRobertBristowJohnsonsAudioEQCookbook.
Beforewegoon,pleasemakesurethatyouvereadSection6.1.6.ItsimportantIpromise!
So,ifyourestillreading,letsgoon...
IfyouregoingtobuildasecondorderIIRfilterusingabiquad,firstyouneedtodecideonsomethings:
1. Whatkindoffilterresponsedoyouwant?(i.e.peaking,shelving,bandpass,etc...
2. Whatisyourdesiredcentreorcutofffrequency(dependingonwhatkindoffilteryouremaking)?
3. Whatisyourdesiredgain(ifapplicableforthetypeoffilter)?
4. WhatisyourdesiredQ(keepinginmindthediscussioninSection6.1.6?
Nomatterwhattypeoffilteryouregoingtomake(well...almostnomatter...),youllneedtostartwitha
coupleofbasicequationsshowninEquations9.11to9.16.
(9.11)
wheregainisindB.
(9.12)
wherefcisthecutofffrequency(orcentrefrequencyinthecaseofpeakingfiltersortheshelfmidpoint
frequencyforshelvingfilters).Notethatthefrequencyfchereisgivenasanormalizedfrequencybetween0and
0.5.Ifyouprefertothinkintermsofthemoreusualwayofdescribingfrequency,inHertz,thenyoullneedto
doanextralittlebitofmathasisshowninEquation9.13.

(9.13)
wherefcisthecutofffrequency(orcentrefrequencyinthecaseofpeakingfiltersortheshelfmidpoint
frequencyforshelvingfilters)inHzandfsisthesamplingrateinHz.Importantnote:Youshoulduseeither
Equation9.12orEquation9.13,dependingonwhichwayyouprefertostatethefrequency.However,Iwould
recommendthatyougetusedtothinkingintermsofnormalizedfrequency,soyoushouldbehappywithusing
Equation9.12.
(9.14)
UsethepreviousequationtoconvertbandwidthorbwintoaQvalue.
Then,ifyouarebuildingapeakingfilter,youuseEquation9.15.
(9.15)
Ifyourebuildingashelvingfilter,youuseEquation9.16.
(9.16)
whereSisashelfslopeparameter.ThelowerSis,thelowertheslopeofthesteepestpartinthemagnitude
responseofthefilter(atfc).IfSis1orlower,thentheslopeofthemagnituderesponsedoesnotchangepolarity
throughtheentirefrequencyrange.Forexample,ifyouremakingahighshelvingfilterwithaboostandShasa
valueof1thentheslopeofthemagnituderesponseispositiveatallfrequencies.IfS>1thenthemagnitude
response,goingfromlowtohighfrequencies,willbeflat,dipinasmallnotch,thenturnaroundandheaduptoa
peakabovethedesiredgainvalue,turnaroundagain,andheaddowntothatvalue.
VeryImportantNoteregardingthedefinitionofQ:YoumightrememberfromaSection6.1.6thatwe
definedtheQofafilterusingthecentrefrequencyandthebandwidth,wherethebandwidthwasmeasuredasa
differencebetweenthetwofrequenciesthatare3dBlowerthanthepeakatthecentrefrequency.Althoughthis
istheclassicaldefinitionofQ,itisnottheoneusedhereatleastforpeakingandshelvingfilters.TheQthat
wereusinghereistheonethatsaysthatthebandwidthisdefinedbythehalfgain(indB)frequencypoints.See
Section6.1.6formoreinfo.
Lowpassfilter

Wealreadyknowfromanearliersectionwhatalowpassfilteris.OnewaytoimplementthisinaDSPchainis
toinsertabiquadandcalculateitscoefficientsusingtheequationsbelow.
(9.17)
(9.18)
(9.19)
(9.20)
(9.21)
(9.22)

Lowshelvingfilter

Likewise,wecould,instead,createalowshelvingfilterusingcoefficientscalculatedintheequationsbelow.
(9.23)
(9.24)
(9.25)
(9.26)
(9.27)
(9.28)
Peakingfilter

Thefollowingequationswillresultinareciprocalpeakdipfilterconfiguration.
(9.29)
(9.30)
(9.31)
(9.32)
(9.33)
(9.34)
Highshelvingfilter

Thefollowingequationswillproduceahighshelvingfilter.
(9.35)
(9.36)
(9.37)
(9.38)
(9.39)
(9.40)
Highpassfilter

Finally,thefollowingequationswillproduceahighpassfilter.
(9.41)
(9.42)
(9.43)
(9.44)
(9.45)
(9.46)
Gettingthefinalvaluesforthecoefficients

IfyoureworkinginMATLABorOctave,thenyoullfindthat,inordertobuildasecondorderIIRfilter,youll
needthreeAcoefficientsandthreeBcoefficients.Inthiscase,youalreadyhavethevaluesyouwant.Just
usetheequationsbelow.
(9.47)
(9.48)
However,ifyoureworkinginMax/MSP(forexample...)thenyouonlyneedfivecoefficients.Thisis
becausethecoefficientsarenormalisedandthefirstfeedbackcoefficientisassumedtobe1.Inordertodothe
normalisationforMax/MSP,thenyoullneedthefollowingequations.
(9.49)

(9.50)

(9.51)

(9.52)
(9.53)
insertthesevaluesbackintoEquation9.9
IfyoureworkinginPureData,thenyoureinforabitofaconfusion.Seemoreaboutthisinthenextsection.
BiquadImplementation:Beware!

DifferentsoftwarepackagesusedifferentversionsofEquation9.10,resultinginmuchconfusionanddelay.
MATLABandOctave

IfyoureworkinginMATLAB,thenyouusethefilterfunctionwiththreeinputs,theacoefficients,theb
coefficients,andtheinputsignal,usingthesyntax
output=filter(b,a,input)
Whatyouneedtoknowisthatthebcoefficientsarethefeedforwardandtheacoefficientsarethefeedback.
ThiscanbeseeninMATLABsversionofEquation9.10,showninEquation9.55.
(9.54)
Noticethattherearenegativesignsinfrontofthetwofeedbackcoefficients.Whatsalittleoddisthatthis
equation(fromMATLABsusermanual)isntreallytrue.WhenyouusethefilterfunctioninMATLAB,it
actuallyusesthea0coefficienttonormalisetheothercoefficients.So,althoughEquation9.55isshowninthe
usermanual,theactualequationusedis
(9.55)
Max/MSP
IfyoureworkinginMax/MSP,thenyouusethebiquad~objectwithfivecoefficients,theacoefficients,and
thebcoefficients.However,Max/MSPcoefficientsaredifferentfromMATLABinthatthetheacoefficientsare
thefeedforwardandthebcoefficientsarethefeedback.ThiscanbeseeninMax/MSPsversionofEquation
9.10,showninEquation9.56.
(9.56)
Noticethat,likeMATLAB,therearenegativesignsinfrontofthetwofeedbackcoefficients.However,
noticethat,theasandbsareswappedinregardstowhicharefeedbackandwhicharefeedforward.
PureData
DespitehavingthesameancestryasMax/MSP,PureData(a.k.a.PD)usesadifferentsyntaxforitsbiquad~
object.LikeMax/MSP,youprovidefivecoefficients,however,thefirsttwoarethefeedbackcoefficients,and
thelastthreearethefeedforward.Tobefair,inthePDreferencetheyarelistedasfbandffcoefficients,nota
andb,however,ifyoucomparetheordertothecofficientsinMax/MSP,youllseethattheyrereversed.This
isnttheonlydifference,sincePureDatausesEquation9.57.
(9.57)
Okay,okay,Ivefudgedthingsalittleherebynamingthemaandbinsteadoffbandffjustforthe
purposesofcomparison.However,noticethatthefeedbackcoefficientsarenowprecededbypositivesnot
negatives(asinMATLABandMax/MSP).So,ifyouregoingtousetheRobertBristowJohnsonequations
abovetocalculateyourbiquadcoefficients,youllneedtoaddapolarityfliponyourfeedbackcoefficientswhen
younormalisethem.IfyoureportingfromMax/MSPtoPureDataandyoujustdropinyourbiquadcoefficients
directly,bad,badthingswillprobablyhappentoyoursignal.
9.5.4Allpassfilters
ThereisaninterestingtypeoffilterthatisfrequentlyusedinDSPthatwedidnttalkaboutverymuchinthe
chapteronanalogelectronics.Thisistheallpassfilter.
Asitsnameimplies,anallpassfilterallowsallfrequenciestopassthroughitwithoutachangeinmagnitude.
Thereforethefrequencyresponseofanallpassfilterisflat.Thismaysoundalittlestrangewhybuildafilter
thatdoesntdoanythingtothefrequencyresponse?Well,thenicethingaboutanallpassisthat,althoughit
doesntchangethefrequencyresponse,itdoeschangethephaseresponseofyoursignal.Thiscanbeusefulfor
varioussituationsaswellseebelow.

FINISHTHISOFF

Figure9.98:Blockdiagramofafirstorderallpassfilter[Steiglitz,1996].
9.5.5SuggestedReadingList
[Steiglitz,1996]
http://www.musicdsp.org/files/AudioEQCookbook.txt
[BristowJohnson,1994]
[Moorer,1983]
[Christensen,2003]

9.6Convolution,CorrelationandCoherence
9.6.1Convolution
LetsthinkofthemostinefficientwaytobuildanFIRfilter.BackinSection9.4wesawageneraldiagramfor
anFIRthatshowedastackofdelays,eachwithitsownindependentgain.Wellbuildasimilardevice,butwell
haveanindependentdelayandgainforeverypossibleintegerdelaytime(meaningadelayvalueofaninteger
numberofsampleslike4or13,butnot2.4or15.2).Whenweneedaparticulardelaytime,wellturnonthe
correspondingdelaysgain,andalltherestwellleaveat0allthetime.
Forexample,asmartwaytodoanFIRcombfilterwithadelayof6samplesisshowninFigure9.99and
Equation9.58.

Figure9.99:AsmartwaytoimplementanFIRcombfilterwithadelayof6samplesandwherea0=1
anda1=0.75.
(9.58)
Therearestupidwaystodothisaswell.ForexampletakealookatFigure9.100andEquation9.59.Inthis
case,wehavealotofdelaysthatareimplemented(thereforetakinguplotsofmemory)buttheiroutputgainsare
setto0,thereforetheyrenotbeingused.


Figure9.100:AstupidwaytoimplementthesameFIRcombfiltershowninFigure9.99.
(9.59)
WecouldsavealittlememoryandstillbestupidbyimplementingthealgorithmshowninFigure9.101.In
thiscase,eachdelayis1samplelong,arrangedinatypeofbucketbrigade,butwestillhaveabunchof
unnecessarycomputationbeingdone.

Figure9.101:AslightlylessstupidwaytoimplementtheFIRcombfilter.
Letsstillbestupidandthinkofthisinadifferentway.TakealookattheimpulseresponseofourFIRfilter,
showninFigure9.102.


Figure9.102:TheimpulseresponseoftheFIRcombfiltershowninFigure9.99.
Now,considereachofthevaluesinourimpulseresponsetobethegainvalueforitscorrespondingdelay
timeasisshowninFigure9.100.
Attime0,thefirstsignalsamplegetsmultipliedbythefirstvalueininimpulseresponse.Thatsthevalueof
theoutput.
Attime1(1samplelater)thefirstsignalsamplegetsmovedtothesecondvalueintheimpulseresponse
andismultipliedbyit.Atthesametime,thesecondsignalsampleismultipliedbythefirstvalueintheimpulse
response.Theresultsofthetwomultiplicationsareaddedtogetherandthatstheoutputvalue.
Attime2(1samplelateragain...)thefirstsignalsamplegetsmovedtothethirdvalueintheimpulse
responseandismultipliedbyit.Thesecondsignalsamplegetsmovedtothesecondvalueintheimpulse
responseandismultipliedbyit.Thethirdsignalsampleismultipliedbythefirstvalueintheimpulseresponse.
Theresultsofthethreemultiplicationsareaddedtogetherandthatstheoutputvalue.
Astimegoeson,thisprocessisrepeatedoverandover.Foreachsampleperiod,eachvalueintheimpulse
responseismultipliedbyitscorrespondingsampleinthesignal.Theresultsofallofthesemultiplicationsare
addedtogetherandthatistheoutputoftheprocedureforthatsampleperiod.
Inessence,wereusingthevaluesofthesamplesintheimpulseresponseasindividualgainvaluesinamulti
tapdelay.Eachsampleisitsowntap,withanintegerdelayvaluecorrespondingtotheindexnumberofthe
sampleintheimpulseresponse.
Thiswholeprocessiscalledconvolution.Whatweredoingisconvolvingtheincomingsignalwithan
impulseresponse.
Ofcourse,ifyourimpulseresponseisassimpleastheoneshownabove,thenitsstillreallystupidtodo
yourfilteringthiswaybecausewereessentiallydoingthesamethingaswhatsshowninFigure9.101.
However,ifyouhaveareallycomplicatedimpulseresponse,thenthisisthewaytogo(althoughwerebe
lookingatasmartwaytodothemathlater...).
Onereasonconvolutionisattractiveisthatitgivesyouanidenticalresultasusingtheoriginalfilterthats
describedbytheimpulseresponse(assumingthatyourimpulseresponsewasmeasuredcorrectly).So,ifyoucan
godowntoyourlocalFIRfilterrentalstore,rentagoodFIRcombfilterfortheweekend,measureitsimpulse
responseandreturnthefiltertothestoreonMonday.Afterthat,ifyouconvolveyoursignalswiththemeasured
impulseresponse,itsthesameasusingthefilter.Coolhuh?
Thereasonweliketoavoiddoingconvolutionforfilteringisthatitsjustsoexpensiveintermsof
computationalpower.Foreverysamplethatcomesoutoftheconvolver,itsbrainhadtodoasmany
multiplicationsastherearesamplesintheimpulseresponse,andonlyonefeweradditions.Forexample,ifyour
impulseresponsewas8sampleslong,thentheconvolverdoes8multiplications(oneforeverysampleinthe
impulseresponse)and7additions(addingtheresultsofthe8multiplications)foreverysamplethatcomesout.
Thatsnotsobadifyourimpulseresponseisonly8sampleslong,butwhatifitssomethinglike100,000
sampleslong?Thatsalotofmathtodooneverysampleperiod!
So,nowyoureprobablysittingtherethinking,WhywouldIhaveanimpulseresponseofafilterthats
100,000sampleslong?Well,thinkbacktoSection3.11andyoullrememberthatwecanmakeanimpulse

responsemeasurementofaroom.Ifyoudothis,andstoretheimpulseresponse,youcanconvolveasignalwith
theimpulseresponseandyougetyoursignalinthatroom.Well,technically,yougetyoursignalplayedoutof
theloudspeakeryouusedtodotheIRmeasurementatthatparticularlocationintheroom,pickedupbythe
measurementmicrophoneatitsparticularplacement...Ifyoudothisinabigconcerthallorachurch,youcould
easilygetuptoa5secondlongimpulseresponse,correspondingtoa220,500samplelongFIRfilterat44.1
kHz.Thisthenmeans440,999mathematicaloperations(multiplicationsandadditions)foreveryoutputsample,
whichinturnmeans19,448,066,900operationspersecondperchannelofaudio...Thatsalotfarmorethana
normalcomputercanperformthesedays.
So,heresthedilemma,wewanttouseconvolution,butwedonthavethecomputationalpowertodoitthe
wayIjustdescribedit.Thatmethod,withallthemultiplicationsandadditionsofeverysinglesampleiscalled
realconvolution.
So,letsthinkofabetterwaytodothis.Wehaveasignalthathasaparticularfrequencycontent(or
response),andweresendingitthroughafilterthathasaparticularfrequencyresponse.Theresultingoutputhas
afrequencycontentequivalenttothemultiplicationofthesetwofrequencyresponsesasisshowninFigure9.103

Figure9.103:Thetopgraphisthefrequencycontentofanarbitrarysignal(actuallyitsarecordingof
Handel).ThemiddleplotisthefrequencyresponseofanFIRcombfilterwitha3sampledelay.
Thebottomgraphisthefrequencycontentofthesignalfilteredthroughthecombfilter.Notice
thattheresultisthesameasifwehadmultipliedthetopfrequencyplotbythemiddleplot,binby
bin.
So,wenowknowtwointerestingthings:
puttingasignalthroughfilterproducesthesameresultasconvolvingthesignalwiththeimpulseresponse
ofthefilter.
puttingasignalthroughafilterproducesthesamefrequencycontentasmultiplyingthefrequencycontent
ofthesignalandthefrequencyresponseofthefilter.
Luckily,somesmartpeoplehavefiguredoutsomecleverwaystodoaDFTthatdonttakemuch
computationalpower.(Ifyouwanttolearnaboutthis,gogetagoodDSPtextbookandlookuptheword
butterfly.)
So,whatwecandoisthefollowing:
1. takeasliceofoursignalanddoaDFTonit.Thisgivesusthefrequencycontentofthesignal.
2. taketheimpulseresponseofthefilteranddoaDFTonit.
3. multiplytheresultsoftheDFTskeepingtherealandimaginarycomponentsseparate.Inotherwords,you
multiplytherealcomponentstogether,andmultiplytheimaginarycomponentstogether,binbybin.
4. taketheresultingrealandimaginarycomponentsanddoanIDFT(inversediscretefouriertransform),
convertingfromthefrequencydomainbacktothetimedomain.
5. sendthetimedomainout.
Thisprocedure,calledfastconvolutionwillgiveyouexactlythesameresultsasifyoudidrealconvolution,
howeveryouusealotlesscomputationalpower.

Thereareacoupleofthingstoworryaboutwhenyouredoingfastconvolution.
ThewindowlengthsofthetwoDFTsmustbethesame.
Whenyouconvolvetwosignalsoflengthn,thentheresultingoutputhasalengthof2n1.Thisisnt
immediatelyobvious,butitcanbeifwethinkofasituationwhereoneofthesignalsistheimpulse
responseofreverberationandtheotherismusic.Ifyouplay1024samplesofmusicinaroomwitha
reverbtimeof1024samples,thentheresultingtotalsoundwillbe2047samplesbecausewehavetowait
forthelastsampleofmusictogetthroughthewholereverberationtail.Therefore,ifyouredoingfast
convolution,thentheIDFThastobetwicethelengthofthetwoindividualDFTstomaketheoutput
windowtwicethelengthoftheinputwindows.Thismeansthatyouroutputishalfwaythroughplaying
whenthenewinputwindowsarestartingtogetthrough.Thereforeyouhavetomixthenewoutputwith
thehold.Thisiswhatsknownastheoverlapaddprocess.
Themath

FINDTHISEQUATION
(9.60)
9.6.2Autocorrelation
Ifyouhavearandomnumberthatliesintherangeof1to1andyoumultiplyitbyarandomnumberthatliesin
thesamerange,youllgetarandomnumberthatliesinthesamerange.AswesawinSection4.16,theresultof
themultiplicationwillhaveadifferentprobabilitydistributionfunction,butwellignorethatfornow.Thepoint
fornowisthatarandomnumbertimesarandomnumberequalsarandomnumber.
Ifyounowtakearandomnumberthatliesintherangeof1to1andmultiplyitbyitself.youllgeta
positivenumber.Again,wellignoretheprobabilitydistributionfunctionoftheresult.Thepointisthatarandom
numbersquaredispositive.
Letsthinkbacktotheprocessofrealconvolutionwiththeexampleofconvolvinganaudiosignalwiththe
impulseresponseofaroom.Thefirstsampleofthesignalismultipliedbythefirsttap(sample)intheimpulse
responsefirst.Thetwosignals(theaudiosignalandtheimpulseresponse)movethrougheachotheruntilthelast
sampleoftheaudiosignalismultipliedbythelasttapintheimpulseresponse.Thisisconceptuallyrepresented
inFigure9.104.

Figure9.104:Ablockdiagramoftheconceptofconvolution.Noticethatoneofthesignalsistime
reversed.
Noticeinthatfigurethatthetwosignalsareoppositeeachotherinotherwords,theaudiosignalinthe
diagramreadsstarttoendfromrighttoleftwhiletheimpulseresponsereadsfromlefttoright.
Whatwouldhappenifwedidexactlythesamemath,butwedidnttimereverseoneofthesignals?Thisidea
isshowninFigure9.105.

Figure9.105:Ablockdiagramofaprocesssimilartoconvolution,butitsnot.Noticethatneitherof
thesignalsistimereversed.

Youmaybeaskingyourselfwhatusethiscouldpossiblybe.Afairquestion.Letshavealookatan
example.Wellstartbylookingataseriesof16completelyrandomnumbers,showninFigure9.106.IfIwerea
statisticianoramathematician,Iwouldsaythatthesewererandomnumbers.IfIwerearecordingengineer,I
wouldcallitwhitenoise.

Figure9.106:
Letstakethatsignal,andputitthoughttheprocessshowninFigure9.105.Insteadofusingtwodifferent
signals,weregoingtousethesamesignalforboth.So,westartasinFigure9.107,withthetwosignalslined
up,readytomultiplybyeachother.Inthiscase,weremultiplyingeachsamplebyitscorrespondingsample(see
thecaption).Wethenaddalltheresultsofthemultiplicationsandwegetaresult.Inthiscase,sinceallthe
multiplicationsresultedin0,thesumofall32zerosis0.

Figure9.107:ThetopgraphshowstheoriginalnoisesignalfromFigure9.106.Themiddlegraph
showsthesamesignal,butoffsetintime.Wemultiplysample1fromthetopgraphbysample1
fromthemiddlegraphandtheresultissample1inthebottomgraph.Wethenaddallthevalues
inthebottomgraphtoeachother,andtheresultis0.
Oncewegetthatresult,weshiftthetwosignalsclosertogetherbyonesampleandrepeatthewholeprocess,
asisshowninFigure9.108.

Figure9.108:ThesametwosignalsasinFigure9.107,movedclosertogetherbyonesample.After
thesearemultiplied,samplebysample,andalltheresultsareaddedtogether,theresultinthis
particularcasewillbe0.15.

Thenwemovethesignalsbyonesampleanddoitagain,asisshowninFigure9.109.

Figure9.109:Theprocessagain,withthesignalsmovedbyonesample.Theresultofthisadditionis
0.32.
Wekeepdoingthisoverandover,eachtime,movingthetwosignalsbyonesampleandaddingtheresultsof
themultiplications.Eventually,wegettoapointwherethesignalsarealmostalignedasinFigure9.110.

Figure9.110:Theprocessagain,afterthesignalshavebeenmoveduntiltheyrealmostaligned.The
resultofthisadditionis0.02.
Thenwegettoapointintheprocesswhereanimportantthinghappens.thetwosignalsarealigned,ascanbe
seeninFigure9.111.Upuntilnow,theoutputfromeachsetofmultiplicationsandadditionshasresultedina
fairlysmallnumber,asweveseen(thelistofallthevaluesthatIhaventshownwillbegivenlater...).Thisis
becauseweremultiplyingrandomnumbersthatmightbeeitherpositiveornegative,resultinnumbersthat
mightbeeitherpositiveornegative,andaddingthemalltogether.(Ifthetwosignalsareverylong,and
completelyrandom,theresultwillbe0.)However,whenthetwosignalsarealigned,theresultofallthe
individualmultiplicationswillbepositive(becauseanynumberotherthan0,whenmultipliedbyitself,givesa
positiveresult).
Ifthesignalsareverylongandrandom,notonlywillwegetaresultveryclosetozeroforallother
alignments,wellgetaverybignumberforthismiddlealignment.Thelongerthesignals,thebiggerthenumber
willbe.

Figure9.111:Theprocessagain,whenthesignalshavebeenaligned.Theresultofthisadditionis

2.18.Noticethatthisisamuchbiggernumberthantheotheronesweveseen.
Wekeepgoingwiththeprocedure,movingthesignalsonesampleinthesamedirectionandrepeatingthe
process,asisshowninFigure9.112.NoticethatthislooksverysimilartothealignmentshowninFigure9.110.
Infact,thetwoareidentical,itsjustthatthetopandmiddlegraphshaveswappedplaces,ineffect.Asexpected,
theresultoftheadditionwillbeidenticalinthetwocases.

Figure9.112:Theprocessagain,afterthesignalshavebeenmovedonesamplepastthepointwhere
theyarealigned.Theresultofthisadditionis0.02.
Theprocesscontinues,providingasymmetricalsetofresults,untilthetwosignalshavemovedapartfrom
eachother,resultinginazeroagain,justaswesawinthebeginning.
IfweactuallydothisprocessforthesetofnumbersinitiallyshowninFigure9.106,wegetthefollowingset
ofnumbers:0.15,0.32,0.02,0.20,0.08,0.12,0.01,0.43,0.11,0.38,0.02,0.59,0.24,0.35,0.02,2.18,
0.02,0.35,0.24,0.59,0.02,0.38,0.11,0.43,0.01,0.12,0.08,0.20,0.02,0.32,0.15.Ifwethentakethese
numbersandgraphthem,wegettheplotshowninFigure9.113.

Figure9.113:Theresultofthemultiplicationsandadditionsforthewholeprocessusingthesignal
shownabove.Therearetwothingstonotice.First,thattheresultingsignalissymmetrical.
Second,thatthereisabigspikerightinthemiddletheresultofwhenthetwosignalswere
aligned.
Theresultofthiswholethingactuallygivesussomeinformation.TakealookatFigure9.113,andyoullsee
threeimportantcharacteristics.Firstly,thesignalissymmetrical.Thisdoesnttellusmuch,otherthanthatthe
signalsthatwentthroughtheprocedurewerethesame.Secondly,mostofthevaluesareclosetozero.Thistells
usthatthesignalswererandom.Thirdly,theresabigspikeinthemiddleofthegraph,whichtellsusthatthe
signalslinedupandmatchedeachotheratsomepoint.
Whatwehavedoneisaprocedurecalledautocorrelationinotherwords,weremeasuringhowwellthe
signalisrelated(orcorelated,tobeprecise)toitself.Thismaysoundlikeasillythingtoaskofcourseasignal
isrelatedtoitself,right?Well,actually,no.Wesawabovethat,unlessthesignalsarealigned,theresultofthe
multiplicationsandadditionsare0.Thismeantthat,unlessthesignalwasalignedwithitself,itisunrelatedto
itself(becauseitisnoise).
Whatwouldhappenifthewedidthesamething,exceptthatouroriginalsignalwasperiodicinsteadof

noise?TakealookatFigure9.114.Noticethattheoutputoftheautocorrelationstillhasabigpeakinthemiddle
essentiallytellingusthatthesignalisverysimilar(ifnotidentical)toitself.Butyoullalsonoticethatthe
outputoftheautocorrelationlookssortofperiodic.Itsasinusoidalwavewithanenvelope.Whyisthis?Its
becausetheoriginalsignalisperiodic.Asthewemovethesignalthroughitselfintheautocorrelationprocess,
theoutputtellsusthatthesignalissimilartoitselfwhenitsshiftedintime.So,forexample,thefirstwaveinthe
signalisidenticaltothelastwaveinthesignal.Thereforeaperiodiccomponentintheoutputofthe
autocorrelationtellsusthatthesignalbeingautocorrelatedisperiodicoratleastthatithasaperiodic
component.

Figure9.114:Thetopplotisthesignal.Thebottomistheresultoftheautocorrelationofthesignal.
So,autocorrelationcantelluswhetherasignalhasperiodiccomponents.Iftheautocorrelationhasperiodic
components,thenthesignalmustaswell.Iftheautocorrelationdoesnot,andisjustlowrandomnumbers,witha
spikeinthemiddle,thenthesignaldoesnothaveanyperiodiccomponents.
Themath

FINDTHISEQUATION
(9.61)
9.6.3Crosscorrelation
Whatifweweretodothesameprocedure,butinsteadofusingonesignal,weusetwodifferentsignals?Allof
themathistheidentical,wejusthaveadifferentname.Becausethesignalsarenotthesame,itsnot
autocorrelation.Nowwecallitcrosscorrelation.
Letsstartbyhavingtwosignals,andwedontknowiftheyreidenticalornot.Wecanputthemthroughthe
crosscorrelationprocedureandlookattheresult.Iftheresabigspikeinthemiddle,thatsasureindicationthat
thesignalsaresimilar,ifnotidentical.Ifthereisaspike,butitsnotinthemiddle,thenthesignalsaresimilar,
butnotaligned.Infact,thedelaydifferencebetweenthemcanbemeasuredbythetimedifferencebetweenthe
spikeandthemiddleofthecrosscorrelationoutput.
9.6.4Correlationcoefficient
ThisisexplainedinSection4.14.
9.6.5Coherence
Beforereadingthissection,ifyourenotcompletelyfamiliarwiththeideaofacorrelationcoefficient,youshould
gobackandreadSection4.14.
Wesawinthediscussionofacorrelationcoefficientthatthisisanumberthatcantellushowtwosignalsare
relatedtoeachother.Ifthesignalsarecompletelyrandom,thentheircorrelationcoefficientgivesusaverygood
ideaofhowsimilartheyare.However,ifthesignalsare(inaworstcasescenario)sinusoidalwaves,thenthe

correlationcoefficientcangiveusaveryincorrectimpressionofwhatsreallygoingon.Inaddition,the
correlationcoefficientisasinglenumberthatdoesnttelluswhatsgoingonindifferentfrequencybands.
Ifwewanttogetabetterideaofthesimilarityoftwosignalsindifferentfrequencybands,wecanusea
differentfunctioncalledthecoherencefunction(alsoknownasacrosspowerspectraldensityfunctionor
CPSD).Thisisconsiderablymorecomplicatedthancalculatingthecorrelationcoefficient,butinsomecases,the
twoproducerelatedresults.
LetssaythatwehavetwosignalsthatwellcallXandY.Westartbydoinganautocorrelationofeachof
thesesignals,sowehaveRXXandRYY.Thenwedoacrosscorrelationofthetwosignals,givingusRXY.Then,
wedoanDFTofeachofthese,givingusSXX(theDFToftheautocorrelationofX),SYY,andSXY(theDFTofthe
crosscorrelationofXandY).RememberthattheoutputsoftheDFTsgiveuscomplexinformationineach
frequencybin,sowecanknowthemagnitudeandphaseofeachbin.
FINISHTHISOFFTHECOHERENCEFUNCTIONISACROSSCORRELATIONTHATHASBEEN
NORMALIZEDUSINGTHEPRODUCTOFTHETWOAUTOCORRELATIONS.AVERAGEFFTOFTHE
NORMALIZEDCROSSCORRELATION.THISTELLSUSTHERELATIONSHIPBETWEENTHE
PHASES.IFTHEPHASESAREIDENTICAL
THEFOLLOWINGISNOTESTOSELF
CalculatingCoherence

Giventwosignals,x(t)andy(t)(wheretistime),thecoherenceofthesetwosignalsxy2(f)atagivenfrequencyf
canbecalculatedusingEquation9.62[ShanmuganandBreipohl,1988].
(9.62)
Gxy(f)istheonesidedcrosspowerspectraldensityfunctioncalculatedusingEquation9.63[Shanmuganand
Breipohl,1988].
(9.63)
Gxx(f)istheonesidedautospectraldensityfunctioncalculatedusingEquation9.64[Shanmuganand
Breipohl,1988].
(9.64)
Sxy(f)isthecrosspowerspectraldensityfunction(alsoknownasthecrossspectrum)ofx(t)andy(t).Thisis
theFouriertransformofthecrosscorrelationofx(t)andy(t)andiscalculatedusingEquation9.65[Bendatand
Piersol,1980]
(9.65)
Sxx(f)istheautospectraldensityfunction(alsoknownastheautospectrumorthepowerspectraldensity
function)ofx(t).ThisistheFouriertransformoftheautocorrelationofx(t)andiscalculatedusingEquation9.66
[BendatandPiersol,1980].
(9.66)
whereisatimeoffsetappliedtox(t)andy(t)andRxy()isthecrosscorrelationfunctionofx(t)andy(t),

calculatedusingEquation9.67[BendatandPiersol,1980].
(9.67)
whereTistherecordlengthofthesignalisatimeoffsetappliedtox(t)anditselfRxx()isthe
autocorrelationfunctionofx(t),calculatedusingEquation9.68[BendatandPiersol,1980].
(9.68)
Discussion

Thecoherencexy2(f)isavaluethatcanrangefrom0to1.Ifthetwosignalsx(t)andy(t)arecompletely
independent,thentheywillhaveacoherenceof0atallfrequenciesexceptf0=0Hz.Ifxy2(fn)=0,thenthetwo
signalsaresaidtobeincoherentatfrequencyfn.Conversely,ifxy2(fn)=1,thetwosignalsaresaidtobefully
coherentatfrequencyfn[ShanmuganandBreipohl,1988].
Theprimaryadvantageofusingthecoherencefunctionoveracorrelationcoefficientisthatitdoesnot
producemisleadingresultswhenthesignalsareperiodic.Forexample,inthecaseoftwosinusoidalwaveforms
withidenticalfrequencyandaphaseoffsetof90,theircorrelationcoefficientwillbe0,however,thecoherence
forthetwosignalswillbe1atthefrequencyofthesinusoid.
However,thisexampleisalsoisanindicatorofthedisadvantageofusingthecoherencefunction.Inthecase
ofperiodicsignals,phasedifferencesarenotreflected.Thisisalsotrueofpolarityinversions,typically
consideredasaphaserotationof180.Forexample,giventwosignalsthatareidenticalexceptforpolaritythe
correlationcoefficientofthetwosignalswillbe1whereasthecoherenceofthetwosignalswillbe1atall
frequencies.Theformerindicatesthatthetwosignalsareidentical,butoppositeinpolarity.Thecoherence
functionsimplyindicatesthatthetwosignalsarelinearlyrelated[Morfey,2001].
9.6.6SuggestedReadingList

9.7Thezdomain
9.7.1Introduction
Sofar,wehaveseenthatdigitalaudiomeansthatwearetakingacontinuoussignalandslicingitintodiscrete
timefortransmission,storage,orprocessing.Wehavealsoseenthatwecandosomemathonthisdiscretetime
signaltodetermineitsfrequencycontent.Wehavealsoseenthatwecancreatedigitalfiltersthatbasically
consistofthreesimplebuildingblocks,addition,multiplicationanddelay,whichcanbeusedtomodifythe
signal.
Whatwehaventyetseen,however,ishowtofigureoutwhatafilterdoes,justbylookingatitsstructure.
Norhavewetalkedabouthowtodesignadigitalfilter.Thisiswherethischapterwillcomeinhandy.
Onenoteofwarning...Thiswholechapterisbasicallyaparaphraseofamuch,muchbetterintroductionto
digitalsignalprocessingbyKenSteiglitz[Steiglitz,1996].IfyourereallyinterestedinlearningDSP,gooutand
buythisbook.
Okay,togetstarted,letsdoalittlereview.Thenextcoupleofequationsshouldbeburntintoyourbrainfor
theremainderofthischapter,althoughIllbringthembacknowandagaintoremindyou.
Thefirstequationistheoneforradianfrequency,discussedinSection3.1.11.
(9.69)

wherefisthenormalizedfrequency(whereDC=0,theNyquistfrequencyis0.5andthesamplingrateis1)
andistheradianfrequencyinradians/samples.Noticethatweremeasuringtimeinsamples,notinseconds.
Unfortunately,ourDSPcomputercanttelltimeinseconds,itcanonlytelltimeinsamples,sowehaveto
accommodate.Therefore,wheneveryouseeatimevaluelistedinthissection,itsinsamples.
Anotherequationthatyouprobablylearnedinhighschool,andshouldhavereadbackinSection1.3states
that
(9.70)
Thenextequation,whichwesawinSection1.7iscalledEulersIdentity.Thisstatesthat
(9.71)
YoumightnoticethatImadeaslightchangeinEquation9.71comparedwithEquation1.76inthatI
replacedthewithanttomakethingsalittleeasiertodealwithinthetimedomain.Rememberthatisjust
anotherwayofthinkingoffrequency(seesection3.1.11)andtisthetimeinsamples.
Wehavetomakeavariationonthisequationbyaddinganextradelayofksamples:
(9.72)
Youshouldalsorememberthatwecanplaywithexponentsasfollows:

Anotherbasicequationtorememberisthefollowing
(9.75)
foranyvalueof
Therefore,ifwemakeaplotwherethexaxisisthevalueofcos()andtheyaxisisthevalueofsin()and
weplotalltheanglesfrom0to2(or0to360),wegetacircle.(GobacktothediscussiononPythagorasin
Section1.2ifthisisntobvious.)
Ifweputajinfrontofthesin2()intheequation(soitlookslikecos2()+jsin2())asimilarthinghappens.
Thismeansthatthesin2()componentisnowimaginary,andcantbemixedwiththecos2().Wecanstilluse
thisequationtodrawaperfectcircle,butnowwereusingarealandanimaginaryaxesaswesawbackinFigure
1.6.13.
Okay...thatsaboutit.Nowwereready.
9.7.2Filterfrequencyresponse
Letstakeaverysimplefilter,showninFigure9.115whereweaddtheinputsignaltoadelayedversionofthe
inputsignalthathasbeendelayedbyksamplesandmultipliedbyagainofa1.

Figure9.115:Asimplefilterusingonedelayofksamplesmultipliedbyagainandaddedtotheinput.

WehavealreadyseenthatthisfiltercanbewrittenasEquation9.76:
(9.76)
Letsputtheoutputofasimplephasorintotheinputofthisfilter.Aphasorisjustasinusoidalwave
generatorthatisthinkingintermsofarotatingwheel,thereforeithasarealandimaginarycomponent.
Consequently,wecandescribethephasorsoutputusingcos(t)+jsin(t),which,aswesawabovecanalsobe
writtenasejt.
Sincetheoutputofthatphasorisconnectedtotheinputofthefilterthen
(9.77)
Therefore,wecanrewriteEquation9.76forthefilterasfollows:

Thislastequationisactuallyprettyinteresting.Rememberthattheinput,x[t]isequaltoejt.Sowhat?Well,
thismeansthatwecanthinkoftheequationasisshowninFigure9.116.

Figure9.116:AnintuitivewayofthinkingofEquation9.80.
NoticethattheendofEquation9.80hasalotofsinit.Thismeansthatitisfrequencydependent.We
alreadyknowthatifyoumultiplyasignalbysomething,thatsomethingisgain.Wealsoknowthatifthatgain
isdependentonfrequency(meaningthatitisdifferentatdifferentfrequencies)thenitwillchangethefrequency
response.So,sinceweknowallthat,weshouldalsoseethatthewhattheinputismultipliedbytogetthe
outputpartofEquation9.80isafrequencydependentgain,andthereforeisamathematicaldescriptionofthe
filtersfrequencyresponse.
Pleasemakesurethatthislastparagraphmadesensebeforeyoumoveon...
LetsbelazyandrewriteEquation9.80alittlesimpler.Wellinventasymbolthatmeansthefrequency
responseofthefilter.Weknowthatthiswillbeafrequencydependentfunction,sowellkeepaninthere,so
letsusethesymbolH().Although,ifweneedtodescribeanotherfilter,wecanuseadifferentletter,likeG()
forexample...
Weknowthatthefrequencyresponseofourfilteraboveis1+a1ejkandwevealreadydecidedthatwere
goingtousethegeneralsymbolH()toreplacethatmessymath,butjusttomakethingsclear,letswriteit
down...
(9.81)
Oneimportantthingtonoticehereisthattheaboveequationdoesnthaveanytsinit.Thismeansthatitis
notdependentonwhattimeitis,soitneverchanges.ThisiswhatiscommonlyknownasaLinearTime
InvariantorLTIsystem.Thismeanstwothings.Thelinearpartmeansthateverythingthatcomesinistreated
thesameway,nomatterwhat.Thetimeinvariantpartmeansthatthecharacteristicsofthefilterneverchange
(orvary)overtime.

Thingsarestillalittlecomplicatedbecausewerestillworkingwithcomplexnumbers,soletstakecareof
that.Wehaveseenthatthereasonforusingcomplexnotationistoputmagnitudeandphaseinformationintoone
neatlittlepackage(seeSection1.6forthisdiscussion.)Wehavealsoseenthatwecantakeasignalrepresented
incomplexnotationandpullthemagnitudeandphaseinformationbackoutifwemust.Thiscanalsobedone
withH()(thefrequencyresponse)ofourfilter.Theequationbelowisageneralformshowinghowtodothis.
(9.82)
ThisdividesthefrequencyresponseH()intothefiltersmagnituderesponse
(seeSection??ifyou
needsomeinfoongettingthemagnituderesponse)andthephaseshift()atfrequency.Becarefulherenot
tojumptoconclusions!Thephaseshiftisnot,its()butwecancalculatetomakealittlemoresense
intuitively.
(9.83)
WherethesymbolsmeansTheimaginarycomponentof...andmeansTherealcomponentof...
DontpanicitsnotsodifficulttoseewhattherealandimaginarycomponentsoftheH()arebecausethe
imaginarycomponentshaveajinthem.Forexample,ifwelookatthefilterthatwestartedwithatthebeginning
ofthischapter,itsfrequencyresponsewas:

Sothismeansthat
(9.87)
and
(9.88)
NoticethatIdidntputthejintherebecauseIdontneedtosaythatitsimaginary...Ialreadyknowthatits
theimaginarycomponentthatImlookingfor.
So,tocalculatethephaseofourexamplefilter,wejustputthosetworesultsintoEquation9.83asfollows:

9.7.3Thezplane
Letslookatanevensimplerexamplebeforewegotoomuchfurther.Figure9.117showsasimpledelaylineof
ksampleswiththeresultmultipliedbyagainfactorofa1.

Figure9.117:Adelaylineofksamplesmultipliedbyagain.
Thisdelaycanbeexpressedastheequation:

Asyouveprobablynoticedbynoticedbynow,wetendtowriteejalot,soletsbelazyagainanduse
anothersymbolinsteadwellusez,therefore
(9.93)
Whatifyouwanttowriteadelay,asinejk?Well,welljustwrite(youguessedit...)zk.Thereforez2isa2
sampledelaybecauseej2isa2sampledelayaswell.
Alwaysrememberthatzisacomplexvariable.Inotherwords,

Therefore,wecanplotthevalueofzonaCartesiangraphwitharealandanimaginaryaxis,justlikewere
alwaysbeendoing.
9.7.4Transferfunction
LetstakeasignalandsenditthroughtwogainfunctionsconnectedinseriesasisshowninFigure9.118.

Figure9.118:Twogainstagesinseries.
WecanthinkofthisastwoseparatemodulesasisshowninFigure9.119.

Figure9.119:AsimplifiedwayofthinkingofFigure9.118.
So,letscalculatehowytrelatestoxt.UsingFigure9.119,wecanwritethefollowingequations:
(9.96)
and
(9.97)
Therefore

WhatItookalongwhiletosayhereisthat,ifyouhavetwogainstages(or,moregenerally,twofilters)
connectedinseries,youcanmultiplytheeffectsthattheyhaveontheinputtofindouttheoutput.
Sofar,wehavebeenthinkingintermsoftheinstantaneousvalueofeachsample,samplebysample.Thats
whywehavebeenusingtermslikex[t]andy[t]wevebeenquitespecificaboutwhichsampleweretalking
about.However,sinceweredealingwithLTIsystems,wecansaythatthesamethinghappenstoeverysample
inthesignal.Consequently,wedonthavetothinkintermsofindividualsamplesgoingthroughthefilter,we
canthinkofthewholesignal(say,aJohnnyCashtune,forexample).Whenwespeakofthewholesignal,weuse
thingslikeXandYinsteadofx[t]andy[t].Thatwholesignaliswhatiscalledanoperator.
Inthecaseofthelastfilterwelookedat(theonewiththetwogainsinseriesshowninFigure9.118),wecan
writetheequationintermsofoperators.
(9.101)
Inthiscase,wecanseethattheoperatorXismultipliedbya0a1inordertobecomeY.Thisisasimplewayto
thinkofDSPifyourenotworkinginrealtime.YoutaketheJohnnyCashtuneonyourharddisc.Multiplyits
contentsbya0a1andyougetanoutput,whichisaJohnnyCashtuneatadifferentlevel(assumingthata0a11).
Thatthingthattheinputoperatorismultipliedbyiscalledthetransferfunctionofthefilterandis
representedbythesymbolH(z).So,thetransferfunctionofourpreviousfilterisa0a1.Inotherwords,H(z)=
Noticethatthetransferfunctionintheequationisheldinsquarebrackets.

Figure9.120:Transferfunctionofafilterwithoperatorsasinputsandoutputs.
Letslookatanothersimpleexampleusingtwo1sampledelaysconnectedinseriesasisshowninFigure
9.121

Figure9.121:Twodelaysconnectedinseries.
Theequationforthisfilterwouldbe

andtherefore

(9.104)
NoticethatIwasabletosimplymultiplythetwodelaysz1andz1togethertogetz2.Thisisoneoftheslick
thingsaboutusingzktoindicateadelay.Ifyoumultiplythemtogether,youjustaddtheexponents,therefore
addingthedelaytimes.
Letsdoonemorefilterbeforemovingon...
Figure9.122showsafairlysimplefilterwhichaddsagainmodifiedversionoftheinputwithadelayed,
gainmodifiedversionoftheinput.

Figure9.122:Afilterwhichaddsagainmodifiedversionoftheinputwithadelayed,gainmodified
versionoftheinput.
Theequationforthisfilteris

Therefore
(9.108)
andsoa0+a1zkisthetransferfunctionofthefilter.
9.7.5Calculatingfiltersaspolynomials
Letstakethisastepfurther.WellbuildabigfilteroutoftwosmallerfiltersasisshowninFigure9.123.The
transferfunctionG(z)=a0+a1z1whilethetransferfunctionH(z)=b0+b1z1.

Figure9.123:Twofiltersinseries.
(9.109)
(9.110)
Therefore

Therefore
(9.115)
Inotherwords,wecouldimplementexactlythesamefilterasisshowninFigure9.124.Thenagain,this
mightnotbethesmartestwaytoimplementit.Justkeepinmindthatthereareotherwaystogetthesameresult.
Weknowthatthesewillgivethesameresultbecausetheirmathematicalexpressionsareidentical.

Figure9.124:AnequivalentresulttothecascadedfiltersshowninFigure9.123
ThethingtonoticeaboutthissectionwasthewayImanipulatedtheequationforthecascadedfilters.Ijust
treatedthenotationasifitwasapolynomialstraightoutofahighschoolalgebratextbook.Thecoolthingis
that,aslongasIdontscrewup,everystepofthewaydescribesthesamefilterinanunderstandableway(as
longasyourememberwhatzkmeans...).
9.7.6Zeros
LetsgobacktoasimplerfilterasisshowninFigure9.125.

Figure9.125:Asimplefilter.
Thisgivesustheequation
(9.116)
Ifwewritethisouttheoldwaythatis,beforeweknewabouttheletterz,theequivalentwouldlooklike
this:

So1+a1ejiswhatthefilterdoestotheinputejt.Thinkof1+a1ejasafunctionoffrequency.Itis
complex(thereforeitcausesaphaseshiftinthesignal).Consequently,wesaythatitisacomplexfunctionof.
Inthezdomain,theequivalentis1a1z1.

So,sinceweknowthat
(9.119)
thenwecansaythat
(9.120)
Inotherwords,thetransferfunctionisthesameasthefrequencyresponseofthefilter.
Weknowthatthetransferfunctionofthisfilteris1a1z1.Youshouldalsorememberthat =z1.Therefore,

Okay,nowIhaveaquestion.Whatvaluesintheaboveequationmakethenumerator(thetoppartofthe
fraction)equalto0.Theanswer,inthisparticularcaseisz=a1.Ifthefilterhadbeendifferent,wewouldhave
gottenadifferentanswer.(Foredifferentfilterwemighthavegottenmorethanoneanswer...butthatcomes
later.)Noticethatifthenumeratoris0,thenH(z)=0.Thiswillbeimportantlater.
Anotherquestion:Whatvalueswillmakethedenominator(thebottompartoftheequation)equalto0?The
answer,inthisparticularcaseisz=0.Again,itmighthavebeenpossible(withadifferentfilter)togetmorethan
oneanswer.Noticeinthiscase,thatifthedenominatoris0,thenH(z)=.
Letsgraphzonacartesianplot.Wellmakethexaxistherealaxiswhereweplottherealcomponentofz,
andtheyaxisistheimaginaryaxis.
Weknowthat

Wealsoknowthat
(9.126)
foranyvalueof.
Therefore,ifwemakeaCartesianplotofzthenwegetacirclewitharadiusof1asisshowninFigure9.126.
Noticethattheamountofrotationcorrespondstotheradianfrequency,startingatDCwherez=1(noticethat
thereisnoimaginarycomponent)andgoingtotheNyquistfrequencyatz=1.Whenz=j1,weareata
normalizedfrequencyof0.25,oronequarterofthesamplingrate.Thismightnotmakesenseyet,butstickwith
meforawhile.


Figure9.126:Thefrequencyaxisinthezplane.Thetophalfofthecirclecorrespondstopositive
frequencies,thebottomhalfcorrespondstonegativefrequencies[Steiglitz,1996].
Ifitdoesntmakesense,itmightbebecausetheproblemisthatitappearsthatweareconfusingfrequency
andphase.However,inonesense,theyaredirectlyconnected,becausewearedescribingfrequencyintermsof
radianspersampleinsteadofthemoreusualcompletecyclesofthewaveformpersecond.Normallywedescribe
thefrequencyofawaveformbyhowmanycompletecyclesgobyeachsecond.Forexample,wesaya1kHz
tonemeaningthatweget1000completecycleseachsecond.Alternatively,wecouldsay360000degreesper
secondwhichsaysthesamething.Ifwecountedfasterthanasecond,thenwewouldsaysomethinglike360
degreespermillisecondor0.36degreespermicrosecond.Theseallsaythesamething.Noticethatwere
usingtherateofchangeofthephasetodescribethefrequency,justlikewedowhenweuse.
Ifwebackupabittothelastfilterwewereworkingon,wesaidthatitstransferfunctionwas
(9.127)
WecanthereforeeasilycalculatethemagnitudeofH(z)usingtheequation:
(9.128)
Animportantthingtorememberhereisthat,whenyouredealingwithcomplexnumbers,asweareatthe
moment,thebarsonthesidesofthevaluesdonotmeantheabsolutevalueof...astheynormallydo.They
meanthemagnitudeof...instead.Alsorememberthatyoucalculatethemagnitudebyfindingthehypotenuse
ofthetrianglewheretherealandimaginarycomponentsaretheothertwosides.
Since
(9.129)
and
(9.130)
and,becauseofPythagoras
(9.131)
then
(9.132)
So,thismeansthat

WefoundoutfromourquestionsandanswersattheendofSection9.7.6that(forourfilterthatwerestill
workingon)H(z)=0whenz=1.CHECKTHISLASTSENTENCE...Letsthenmarkthatpointwitha0(a
zero)onthegraphofthezplane.Notethata1hasonlyarealcomponent,thereforea1hasonlyarealcomponent
aswell.Consequently,the0thatweputonthegraphsitsrightontherealaxis.

Figure9.127:Azeroplottedonthezplane
Hereswherethingsgetinteresting(finally!).Themagnituderesponse(whatmostnormalpeoplecallthe
frequencyresponse)ofthisfiltercanbefoundbymeasuringthedistancefromthe0thatweplottedtothe
circleonthegraph.SeeFigure9.128

Figure9.128:Findingthemagnituderesponseofthefilterusingthezeroplottedonthezplane.

Figure9.129:Anequivalentplotto9.128,ifweunwrappedthefrequencyaxisfromacircletoa
straightline.Notethatthisplotisonlyroughlytoscaleitisnotterriblyaccurate.
YoumightbesittingtherewonderingwhathappensifIhavemorethanonezeroontheplot?Thisis
actuallyprettysimple,youjustpickavaluefor,thenmeasurethedistancefromeachzeroontheplottothe
frequency.Thenyoumultiplyallyourdistancestogether,andtheresultisthemagnituderesponseofthefilter
atthatfrequency.

Thereisanother,possiblymoreintuitivewayofthinkingaboutthis.Cutacircleoutofasheetofheavy
rubber,andmagicallysuspenditinspace.Thecircledirectlycorrespondstothezplane.Ifyouhaveazeroon
thezplane,youpushtherubberdownwithapointystickasfaraspossible,preferablyinfinitely.Thiswillputa
dentintherubberthatlooksabitlikeafunnel.Thiswillpulldowntheedgeofthecircle.Thecloserthezerois
totheedge,themoretheedgewillgetpulleddown.
Ifyouwereabletounwraptheedgeofthecircle,keepingitsverticalshape,youwouldhaveapictureofthe
frequencyresponse.
MAKEA3DPLOTOFTHISINMATHEMATICATOILLUSTRATETHISPOINT.

Figure9.130:Therelationshipbetweenthesampledtime,discretefrequencyandzdomains
[Watkinson,1988].
9.7.7Poles
Sofarwehavelookedathowtocalculatethefrequencyresponse(thereforethemagnitudeandphaseresponses)
ofadigitalfilterusingzerosinthezplane.However,youmayhavenoticedthatwehaveonlydiscussedFIR
filtersinthissection.Wehavenotlookedatwhathappenswhenyouintroducefeedback,thereforecreatingan
IIRfilter.
So,letsmakeasimpleIIRfilterwithasingledelayedfeedbackwithgainasisshowninFigure9.131.

Figure9.131:AsimpleIIRfilterwithonedelayandonegain.
Theequationforthisfilteris
(9.136)
Noticenowthattheoutputisthesumoftheinput(thext)andagainmodifiedversion(usingthegaina1)of
theoutputytwithadelayofksamples.
Wealreadyknowfromtheprevioussectionhowtowritethisequationsymbolicallyusingoperators(think
backtotheJohnnyCashexample)asisshownintheequationbelow.
(9.137)
Letsdoalittlestandardhighschoolalgebraonthisequation...

So,inaweirdway,wecanthinkofthisIIRfilterthatreliesonfeedbackasaFIRfilterthatonlycontains
feedforward,exceptthatwehavetothinkofthefilterbackwards.Theinput,Xissimplytheoutputofthefilter,
Y,minusadelayed,gainvariedversionoftheoutput.ThiscanbeseenintuitivelyifyoucompareFigure9.115
withFigure9.131.Youllnoticethat,ifyoulookatoneofthediagramsbackwards(followingthesignalpath
fromrighttoleft),theyreidentical.
Letscontinuewiththealgebra,pickingupwhereweleftoff...

Therefore,wecanseerightawaythatthetransferfunctionofthisIIRfilteris
(9.146)
becausethatswhatgetsmultipliedbytheinputtogettheoutput.
This,inturn,meansthatthemagnituderesponseofthefilteris

Thisraisesaninterestingproblem.Whathappensifwemakethedenominatorequalto0?Firstofall,lets
findoutwhatvaluesmakethishappen.

RememberEulersidentitywhichstatesthat
(9.153)
Wethereforeknowthat,foranyvalueofandk,1ejk1.Inotherwords,asinusoidalwaveformjust
swingsbackandforthovertimebetween1and1.
Wesawthatthedenominatoroftheequationforthemagnituderesponseofourfilterwillbe0when

(9.154)
Therefore,themagnituderesponseofthefilterwillbe0(atsomevaluesforandk)whena11.THIS
STATEMENTDOESNOTMAKESENSE.FIXIT.
Sowhat?Well,ifthedenominatorintheequationdescribingthemagnituderesponseofthefiltergoesto0,
thenthemagnituderesponsegoesto.Therefore,nomatterwhattheinputofthefilter(otherthananinputof
0),theoutputwillbe.Thisisbadbecauseaninfiniteoutputsignalisvery,veryloud...Anintuitivewayto
thinkofthisisthatthefiltergoesnutsifthefeedbackcausesittogetlouderandlouderovertime.Inthecaseofa
singlefeedbackdelay,thisiseasytothinkof,sinceitsjustaquestionofwhetherthegainappliedtothatdelay
outputsabiggerresultthantheinput,whichisfedintothedelayagainandmadebiggerandbiggerandsoon.In
thecaseofacomplicatedfilterlotsoffeedbackandfeedforwardpaths(andthereforelotsofpolesandzeros)
youllhavetodosomemathtofigureoutwhatwillmakethefiltergetoutofcontrol.
Wesawthat,ifthenumeratorofthemagnituderesponseequationofthefiltergoesto0,thenweputazeroin
thezplaneplotoftheresponse.Similarly,ifthedenominatoroftheequationgoesto0,thenweputapoleonthe
zplaneplotoftheresponse.Whereasazerocanbethoughtofasadeepdentinthe3Dplotofthezplane,a
poleisaveryhighpointytentlikeshapecomingupoffthezplane.ThisisshowninFigures9.132.

Figure9.132:Apoleplottedonthezplane
NoticeinFigure9.132thatIhavemarkedthepoleusinganXandplaceditwherezk=a1Thismayseem
odd,sincewesaidacoupleofequationsagothatthemagicnumberiswhere =zk.Iagreeitisalittleodd,
butjusttrustmefornow.Weputthepoleontheplotwherezk=thebottomhalfoftheequation(inthiscase,a1)
andwellseeinacoupleofparagraphshowittiesbackto .
Aswesawbefore,onewaytointuitivelythinkoftheresultofapoleonthemagnituderesponseofthefilter
istounwraptheedgeofthecircleandseehowthepolepullsuptheedge.Thiswillgiveyouanideaofwherethe
totalgainofthefilterishigherthan1relativetofrequency.
Alternately,wecanthinkofthemagnituderesponse,againusingthedistancefromthepoleslocationtothe
edgeofthecircleinthezplane.However,thereisadifferenceinthewaywethinkofthiswhencomparedwith
thezeros.Inthecaseofthezeros,themagnituderesponseatagivenfrequencywassimplythedistancebetween
thezeroandtheedgeofthecircleaswesawinFigures9.128and9.129.Wealsosawthat,ifyouhavemorethan
onezero,youmultiplytheirdistances(tothelocationofasinglefrequencyonthecircle)togethertogetthetotal
gainofthefilterforthatfrequency.Thesameisalmosttrueforpoles,howeveryoudividethedistanceinsteadof
multiplying.So,inthecaseofafilterwithonlyonepole,youdivide1bythedistancefromthepoleslocationto
afrequencyonthecircletogetthegainofthefilteratthatfrequency.ThisisshowninFigures9.133and9.134.
(See,ItoldyouthatIdlinkitbackto ...)


Figure9.133:Findingthemagnituderesponseofthefilterusingthepoleplottedonthezplane.

Figure9.134:Anequivalentplotto9.133,ifweunwrappedthefrequencyaxisfromacircletoa
straightline.Noticethattheplotshows
.Notethatthisplotisonlyroughlytoscaleitisnot
terriblyaccurate.

Figure9.135:ThemagnituderesponsecalculatedfromtheplotinFigure9.134.Notethatthisplotis
onlyroughlytoscaleitisnotterriblyaccurate.
TEXTANDGRAPHSTOEXPLAINTHEFOLLOWINGZPLANEPLOTS
NOTESTOSELF:
MAGNITUDE
Poles,Magnitude=1/D
Zeros,Magnitude=D
PHASE
Poles,Clockwiserotation,addthephaseangle
Zeros,Clockwiserotation,subtractthephaseangle

Figure9.136:INSERTCAPTION.

Figure9.137:INSERTCAPTION.

Figure9.138:INSERTCAPTION.

Figure9.139:INSERTCAPTION.

Figure9.140:INSERTCAPTION.

Figure9.141:INSERTCAPTION.

Figure9.142:INSERTCAPTION.

Figure9.143:INSERTCAPTION.
WHATIFTHEREARETWOORMOREPOLESORZEROS?
Poles,Magnitude=1/D1*1/D2
Zeros,Mag=D1*D2
PhasesameaswithsinglePoleorZero

Figure9.144:INSERTCAPTION.
9.7.8SuggestedReadingList
[Steiglitz,1996]

9.8DigitalReverberation
9.8.1History
Sincetheapplicationofdigitalsignalprocessingtoaudiosignals,therehavebeenmanyattemptstocreatean
impressionofspaceusingvariousalgorithms.Forthepast40years,numerousresearchersandcommercial

developershavedevisedmultiplestrategiesforsynthesizingvirtualacousticenvironmentswithvaryingdegrees
ofsuccess.Differentmethodshaveproventobemoresuitedtoparticularapplicationswhichcanbedividedinto
twomajorfields:
1. commercialclassicalmusicproductionandfilmandtelevisionpostproduction
2. commercialpopmusicproduction,electroacousticmusiccomposition(includingcomputermusic)and
computergames.
Intheformercase,syntheticreverberationistypicallyusedtomimicrealacousticenvironments,generally
withtheintentionofdeceivinglistenersintobelievingitisanactualspace.Inthelattercase,thesynthetic
environmentsaregenerallyintendedtoappeartobeexactlythatsyntheticacousticswhicharephysically
impossibleintherealworld,essentiallyresultingintheprocessingbeingusedmoreasaninstrumentthanan
environment.Ineitherinstance,thereverberationmustbeaestheticallyacceptableinordertoenhanceand
complementratherthandetractfromtheperformanceitaccompanies.
Unfortunately,asispointedoutbyGardner[Gardner,1992a],sincealargepartofthedevelopmentof
syntheticreverberationalgorithmshasbeencarriedoutbycorporateconcernsforcommercialproducts,many
secretsregardingtheiralgorithmsarenotshared.Companiesthatrelyonthesaleofsuchproductsmaintain
superiorproductqualitybyensuringthattheirproceduresarenotusedbycompetitors,thusknowledgeis
hoardedratherthandistributed,consequentlyslowingprogressinthefield.Asaresult,manyspecificsregarding
currentcommerciallydevelopedalgorithmscanonlybeeithersurmisedorreverseengineered.
Variousalgorithmsandapproachestoacousticssimulationhavebeendevelopedsincetheadventofdigital
signalprocessingintheaudioandfilmindustries.Thesecanbelooselyorganizedintothreegroupsbasedon
theirbasicproceduralcharacteristics:
1. tappedrecirculatingdelaymodels
2. geometricmodelsand
3. stochasticmodels.
Tappedrecirculatingdelaymodel

Mostmoderndigitalreverberationenginesuseacollectionofmultitapdelays,recursivecombfiltersandallpass
filtersconnectedinseriesandparallelwithvariouscombinationsofparameterconfigurationstogenerate
artificialacousticspaces.Sincethesesystemsarebasedonassembliesofsimpletappeddelayswithfeedbackand
gaincontroltheyfallunderthegeneraltermoftappedrecirculatingdelayorTRDmodels[Roads,1994].This
hasbeenthestandardmethodofgeneratingartificialreverberationforapproximately40years.
Thefirstwidelyacceptedmethodofcreatingsyntheticreverberationusingdigitalsignalprocessingis
attributedtoManfredR.Schroederwho,in1961and1962,publishedtwoseminalpapersdescribingprocedures
usingsimpleseriesandparallelarrangementsofrecursivecombandallpassfilterslabelledunitreverberators
[Schroeder,1961][Schroeder,1962](seeFigure9.145)Despitethefactthatthesemodelsusedhoursof
computationtimeonmainframecomputers,theyremainedthealgorithmsofchoiceandwereusedextensivelyat
centressuchasStanfordUniversityandIRCAMforoveradecade[Moorer,1979].

Figure9.145:OneofSchroedersoriginaltworeverberationalgorithmsbasedonunitreverberators.

Figure9.146:OneofSchroedersoriginaltworeverberationalgorithmsbasedonunitreverberators.
In1970Schroedersuggestedanimprovementtohissystemwiththeinclusionofearlypowerintheformof
discretereflectionswhichwillbediscussedinthesubsequentsection[Schroeder,1970].WhiletheSchroeder
algorithmswereuniversallyacceptedtheydoexhibitanumberofproblemsoutlinedin1979byJamesMoorer.
Thesecomplaintscentrearoundthelackofperceptualtransparencyofthesystem,primarilyaresultofthe
excessivesimplicityoftheunitreverberators.Moorerspecifiesthreemajorproblemswiththesystem[Moorer,
1979].
1. Alaginthereverberantdecaybuildup,dependentontheorderofthesystem.Unlikethecaseinreal
acousticswhichappeartostartwithadensereverberantfieldanddecayexponentially,theSchroeder
algorithmtendstohaveanaudiblyslowerattackenvelope.
2. Thesmoothnessofthedecayishighlydependentontherelationshipofthevariousgainanddelay
parametersettingsoftheunitreverberators.Despitetheuseofprimerelationshipsbetweenvariousdelay
times,raggedsoundingdecayswereeasytoachieve.
3. Anaudibleringingeffectisfrequentlytheresultofthealgorithm,typicallyrelatedtotheresonant
frequenciescausedbythedelaytimerelationshipsintheunitreverberators.
Moorer[Moorer,1979]suggestedanumberofimprovementsonSchroedersoriginalalgorithmincludingthe
introductionoftwonewunitreverberators,termedanoscillatoryallpassandanoscillatorycomb,andthe
useoflowpassfilteringinthefeedbackloopsbothtosmearthetimeresponseofdiscreteechoesandtosimulate
theabsorptionofhighfrequencysignalsinairforthereverberantfield.
Geometricmodel

TheTRDmodelreliesheavilyontheperceptualattributesoftheunitreverberatorsintheattempttomimicreal
acoustics.Whiletheuseofvariouscombinationsofrecursivecombandallpassfiltersapproximatesthediffuse
decayofareverberantspace,thereisnoefforttoreplicateprecisecharacteristicsofphysicalspaces.Although
thissystemcanbeusedtoprovideanadequatesimulationofthelatercomponentsinareverberantdecay,itcan
onlybeexpectedtoprovidearoughapproximationforcriticalapplicationsinspiteofSchroedersclaimin1962
thattheoutputfromsuchasystem,insomeregards,wasperceptuallyindistinguishablefromrecordingsmade
inrealspaces.
In1970,theTRDsystemwasimproveddramaticallywithSchroedersinclusionofamultitapdelaywhich
providedsimulatedearlyreflections[Schroeder,1970].Overthepast30years,thissystemhasundergone
numerousimprovements,[Gardner,1992b][Christiansen,1992]thankslargelytoincreasesincomplexitywith
increasedprocessingpower.Despitethefactthatthismodelwasthefirstsystemtobeusedtosynthesize
artificialacousticenvironments,itremainsthemostcommonlyusedmodelineventhenewestcommercial
devices.ItsinitialdevelopmentreliedontheefficiencyoftheTRDalgorithmsandtheuseofrecursiveelements
tomodelreverberationperceptually.Whilethissystemdoesnotprovideanaccuraterepresentationofthereal
characteristicsofareverberantspace,itsefficiencyandperceptualadequacylieattheheartofitscontinued
acceptance.
Therearetwoprincipalmethodsusedincalculatingtherealtemporalandspatialcharacteristicsofthe
reflectionpatternofanenclosure,eachprovidingadvantagesanddisadvantages.Thesearetheraytracemodel
andtheimagemodel.Twoadditionalmethodologiesarederivedfromtheseandareknownastheconetrace
model(alsoknownasbeamtracing)andthehybridmethod.
Raytracemodel
SchroedersintentionintheadditionofamultitapdelaytotheTRDsystemwastosimulatetheearly
reflectionpatternofarealenclosure.Inordertodeterminetheappropriatedelaytimes,gainsandpanningfor
thesedelays,hechosetouseatwodimensionalmodelofarealroom,calculatingthepathsof300soundrays
propagatingoutwardsfromthesoundsourcetowardsthewalls[Schroeder,1970].Assuminglinearresponse
characteristicsbothfromtheairandthereflectivesurface,hesubsequentlycalculatedaseriesofdelaysto
simulatetheearlyreflectionpatternsforagivensourceandlistenerlocationandspecifiedroomgeometry.This
delayclusterwasthenusedtoprovidetheearlyreflectionpatternoftheroom,withtheTRDmodelbeingusedto
providethedesiredreverberantcharacteristics.

Thisisasimpleexampleofthesystemwhichhascometobeknownasraytracing.Init,theexpanding
wavefrontisconsideredasanumberofraysofenergy,typicallyequallyspacedangularlyaroundthesound
source.Aseachraypropagatesoutwards,itwillmeetareflectingsurfaceandsubsequentlyberedirectedinto
theenclosureatanewangle.Thisprocedurecontinuesuntileitherapredeterminedlimitontheordernumberof
thereflectionisreachedortherayencountersthereceiver.Theappropriatetimeandgainofeachrayatthe
receiveristhereforecalculatedandstored,withthecollectionofallincomingraysresultinginthecalculated
impulseresponseoftheroom.Inmoresophisticatedsystems,theabsorptivecharacteristicsofeachreflecting
surfacecanbeincludedbyapplyinganappropriatefiltertotheimpulseforeachcorrespondingreflection.
Thissystemisanexcellentmethodforcalculatingtheimpulseresponseofaroomwithnumeroussurfaces
withirregulargeometrysincethelocalinteractionofeachraywiththesurroundingenvironmentisconsidered
throughoutitsentirepropagation.Consequently,angularcalculationsaremadeinseriesandaretherefore
relativelysimple.Asaresultitisthesystemmostwidelyusedinsoftwaredevelopedforacousticsprediction
[Dalenbcketal.,1994].Oneprincipaldangerwiththissystemisthat,unlessalargenumberofraysareused,it
ispossiblethatloworderreflectionswillbeomittedsincetheywilloccurbetweenangles.Thisisbecausethe
radiationpatternsofsoundsourcesarecalculatedonquantizedanglesinsteadofcontinuousspace.Consequently,
itispossiblethatthelocationofthereceiverdoesnotcorrespondtoanyoftheemittedraysforsomereflections.
Imagemodel
Whiletheraytracemodelprovidesanexcellentandefficientmethodofcalculatingthespatialandtemporal
locationsofreflectionsinanenclosurewithirregulargeometry,itrequiresaverylargenumberofcalculatedrays
inordertoassurethatallearlyreflectionsarefound.Incaseswhereonlytheloworderreflectionsarerequired,
theimagemodelprovidesamoreefficientmethodofcalculationforspecularreflectivesurfaces.Inthismodel,
thesoundsourceiseffectivelyduplicatedtomultiplelocationsoutsidetheenclosure.Theselocationscorrespond
tothevirtuallocationsofsoundsourceswhich,inafreefield,wouldresultinthesamedelayedpressurewaveas
aperfectspecularreflection.Figure9.147illustratesthisconcept.Thefigureontheleftdemonstratesthedirect
soundandfirstreflectionusingasimpleraytracemodel.Init,thereflectioniscalculatedtooccurataparticular
locationonthereflectingsurface.Inthefigureontheright,theimagemodelisusedwherethesoundsourceis
duplicatedontheoppositesideofthereflectingsurface.Theincomingpressurewavefromthisduplicatedsource
exactlymatchesthepressurewaveofthereflectioninthediagramontheleft.

Figure9.147:Simpleraytracemodel(left)vs.imagemodel(right).
Thismodelwasfirstproposedforthebuildingofimpulseresponsesofdigitallysynthesizedacoustic
environmentsin1979byAllenandBerkley[AllenandBerkley,1979]however,themethodwasusedbymany
otherresearchersprevioustothistomodelspecularreflectivesurfacesofarectangularenclosure[Eyring,1930]
[GibbsandJones,1972][Berman,1975].Inthispaper,theysuggestedfindingthetotalpropagationdelaysofa
reflectionusingthismodel,andsubsequentlyroundingthedelaytothenearestsampleinthesyntheticimpulse
response.Thissystemcouldberepeatedforanynumberofreflectionswiththeresultingimpulseresponseused
asanFIRfilterthroughwhichanechoicrecordingswouldbeconvolved.
Peterson[Peterson,1986]suggestedanimprovementtothissystemintheformofinterpolateddelays.
WhereasAllenandBerkleyassumedthatamaximumtemporalquantizationerror,causedbyroundingoffdelay
values,of wastolerable,(whereTsisthesamplingperiod)Petersonsuggestedthatthiscorrespondedtoan
unacceptableinterchannelphaseerror.Thiserrorcanbeeliminatedbyusinginterpolatedratherthanquantized
delayvalues.

Theadvantagesoftheimagemodelsystemlieintheefficiencyofitsmethodofcalculationforspecific
reflections.Theimpulseresponsesofindividualreflectionsarecalculatedasdesired,andthusloworder
reflectionsareprovidedbythesystemveryquickly.Theprincipaldisadvantageofthesystemisitsdifficultyin
processingirregulargeometries,particularlyforhigherorderreflections.Whereastheraytracemodelcomputes
thevariousreflectionsofasinglerayinseries,theimagemodeldoessoinparallelallreflectionsofagivenray
mustbeknownsimultaneouslyinordertoreturnaresult[Borish,1984].Consequently,thismodelisusedin
systemswheretheenclosureisconstructedofrelativelysimpleshapesandonlylowerorderreflectionsare
required.
Conetracemodel
Theconetracemethodwasdevelopedinanattempttomaintainthesimplicityoftheraytracemodelfor
higherorderreflections,whileensuringthatlowerorderreflectionswerenotomittedduetoquantizationofthe
angulardirectionsofthesoundradiation.Inthisprocedure,ratherthanusingdiscreteraysemanatingfromthe
soundsourceatspecificangles,aseriesofHoverlappingconesarecalculatedwithagainfunctionwhichis
dependentontherelationshipbetweentheangularspreadoftheconeo(derivedusingEquation9.155)andthe
locationofthereceiveratangle.Thisgain,GiscalculatedusingEquation9.156[vanMaercke,1986].

Figure9.148:Simpleraytracemethod(left)vs.conetracemethod(right).

Figure9.149:Anglesusedforcalculatinggainwithincone(seeEquation9.155).Inordertosimplify
thediagram,thereflectedconeshowninFigure9.148hasbeenshownwithoutthereflections.
(9.155)

(9.156)
Hybridmethod
Anotherapproachwhichcombinesthesimplicityoftheraytracemodelwiththeaccuracyoftheimage
modelisthehybridmethod.Thissystemissimplyacombinationofthetwo,usingtheimagemodelforlower
orderreflectionsandraytracingforthehigherorders[Vrlander,1989].
Physicalmodels

Whiletheraytraceandimagemodelsusemathematicaldescriptionsofrealacousticspaces,theydonot
necessarilymimicthebehaviourofanacousticwavefrontinthosespaces.Thisisduelargelytothefactthateach
considersonlythepropagationspeedanddirectionoftheexpandingwavefront,anddoesnottakeintoaccount
suchfactorsasthediffusionordiffraction[Kleineretal.,1993].Asaresult,althoughthesemodelswillprovide
excellentmodelsofearlyspecularreflectionpatterns,theydonotproduceaccurateimpulseresponsesforhigh
ordersofreflections.Thisisbecausethespatialspreadofquantizedradiationanglesincreaseswithdistancefrom
thesoundsource,andthustheorderofthereflection.Consequently,itislikelythatmanyreflectionswillnotbe
recordedatthereceiversposition.Inordertoachieveahigherlevelofaccuracy,amodelwhichisbasedona
largersetofphysicalrulesisrequired.Inthissocalledphysicalmodel,thesystemisequippedwithequations
thatdescribethemechanicalandacousticbehaviourofthevariouscomponentsofthephysicalsystembeing
modeled.Intheory,theresultisasystemthatmimicsthebehaviourofthephysicalcounterpart[Roads,1994].
Thetermphysicalmodeliswidelyusedinmanyfieldstodescribevarioussystems.Inmusictechnology
basedapplications,aphysicalmodelisonewheremathematicalmodelsofphysicalacousticsareusedtoproduce
thecharacteristicsofaresonantinstrumentorenclosure[Roads,1994].Thismathematicalmodelcantake
variousforms,however,thetypicalimplementationinvolvesarecursivedelayincludingafilterinthefeedback
path,anexampleofwhichistheKarplusStrongpluckedstringalgorithm[KarplusandStrong,1983].
Twogeneralmethodsofphysicalmodelsusedinauralizationandpredictiveacousticssoftwareareknownas
theboundaryelementmethod(BEM),andthefiniteelementmethodFEM.
Boundaryelementmethod
Usingtheboundaryelementmethod,surfacesaresubdividedintodiscretecomponents,eachwithaparticular
setofreflectivecharacteristics[Kleineretal.,1993].Eachofthesecomponentsisconsideredtobeasound
source,reradiatingpowerintotheenclosurewithanindividualcontributiontothewholeroomimpulse
response.
Oneoftheprincipalproblemswiththeboundaryelementmethodisthelargenumberofcalculationsrequired
inordertobuildacompleteimpulseresponse.Thisisparticularlytruewithhigherorderreflections,sincethe
increaseinthenumberofinteractingelementsisexponentiallyproportionaltotheorderofreflection.
Finiteelementmodel
Theboundaryelementmethodislimitedinthatitonlyconsidersthecharacteristicsofthesurfaceswhich
defineaspacewhileneglectingthebehaviourofelementswithinthespaceitself.Thefiniteelementmodel
correctsforthisomission,subdividingtheentireroomintoacollectionofinterconnecteddiscreteelements
arrangedinamesh.Inthismanner,theentirespaceismodeled,albeitwitharatherhighcomputationalcost.One
notableexampleofthefiniteelementmethodisthedigitalwaveguidemesh.
Digitalwaveguidemesh
Varioussystemshavebeendevelopedandproposedwhichusetheconceptofdigitalwaveguidestosimulate
theresonantandreverberantcharacteristicsbothofroomacousticsand,onasmallerscale,ofinstrument
acoustics.InitiallyproposedforroommodelsbyCrawfordin1968[Roads,1994],digitalwaveguidesuse
bidirectionaldelaylines(andthereforerecursion)tosimulatethecharacteristicsofacousticwaveguideswith
considerableefficiency.Anotabledevelopmentinthefieldofroomacousticsmodelingwastheextensionofthe
digitalwaveguideintoamultidimensionalmesh.Thismeshiscomprisedofanumberofdiscretedigital
waveguidesthatareinterconnectedusingscatteringjunctions.Initscanonicalform,thedelaytimeofthe
individualbidirectionaldelaysis1sample.Thepurposeofthescatteringjunctionsistoredistributethewave
energyintoconnecteddelaysbasedontherelativeacousticimpedancesoftheincomingandoutgoing
waveguides.Forexample,inthecaseofascatteringjunctioninthecentreofaroom,theimpedancesofthe
outputsofallconnecteddelayswouldbeequal,thereforeanyincomingenergyisequallydistributedamongall
theirinputs.Bycomparison,ifthescatteringjunctionislocatedataveryreflectivesurface,thenthereisa
mismatchintheamplitudesofthewaveformsthatareroutedtotheconnecteddelays,sendingmorepowerin
somedirectionsthanothers.
Typically,digitalwaveguidemeshesarearrangedinatwodimensionalconfigurationasisrepresentedin
Figure9.150.Oneexcellentintroductorydescriptionofthissystemis[DuyneandIII,1993].


Figure9.150:Twodimensionaldigitalwaveguidemesh.Eachcircledenotesascatteringjunctionwith
fourconnectedbidirectionaldelays[DuyneandIII,1993].
Thereareanumberofproblemsassociatedwiththeimplementationofdigitalwaveguidemeshessuchas
dispersionandquantizationerror.Oneparticulardifficultywithusingthediscreteratherthanacontinuous
representationofspacethatoccursinthemeshisfrequencydependentdifferencesinwavepropagationspeedin
differentdirectionsonthemesh.Thisisparticularlynoticeableintwodimensionalmesheswithsquarelayoutsas
showninFigure9.150.Insuchaconfiguration,diagonallytravellingwaveshaveafrequencyindependent
propagationspeed.Lowfrequencywavestravellingalongeitherofthetwoaxeswillhaveanidenticalspeedto
theirdiagonalcounterparts,however,highfrequencyinformationtravelingalongtheaxeshasaspeedof0.707
thatoflowerfrequencies.Thisresultsinadistortionofthewavefrontintheformofalossoftransient
informationinsomepropagationdirections.
Onesolutiontothisproblemistoincreasethenumberofdimensionsonthemesh.Althoughthesystemis
stillusedtomodelatwodimensionalsurface,itcontainsalargernumberofaxesandthusreducesdifferencesin
wavespeedwithdirection.OneexampleofsuchasystemisshowninFigure9.151whichdisplaysatriangular
mesh.Savioja[Savioja,1999]providesanevaluationofvariousmeshtopologiesandtheresultingwavespeeds.

Figure9.151:Twodimensionaltriangulardigitalwaveguidemesh.
Digitalwaveguidemeshesalsosufferfromcumulativequantizationerrorsduetothemultiplicityofparallel
andseriescombinationsofgainmodificationinthejunctions.Onesuggestedsolutiontothisissueisthere
distributionoftheerrorintothespatialdomain.Inthistopology,thequantizationerroristradedforamuchless
significantdispersionerroronthemesh[DuyneandIII,1993].
Unfortunately,althoughphysicalmodellingreverberationsystemscanproduceexcellentresults,the
processingpowerrequiredtosimulatethecharacteristicsoflargethreedimensionalspacesispresently
prohibitiveinrealtimesystems.
Convolutionthroughameasurementofrealspace

In1979,Moorer(1979)discussedtheoptionofusingameasurementofanexistingspaceasadigital

reverberator.Inthissystem,animpulseresponseofarealroomismeasuredandstored,andthecharacteristicsof
themeasurementsystemaresubtracted.ThisimpulseresponsecansubsequentlybeusedasanFIRfilterthatcan
beconvolvedwithananechoicrecordingtoproducearesultequivalenttotherecordingreproducedinthespace.
Morerecently,ithasbecomepossibletoimplementsuchasysteminrealtimeasisexemplifiedbyvarious
hardwareandsoftwareimplementations.
Therearetwopossiblemethodologiesforperformingtheactualconvolutionknownasrealconvolutionand
fastconvolution.Inthefirst,theimpulseresponseiseffectivelytreatedasamultitapdelaywithalargenumber
oftaps(equaltothelengthoftheimpulseresponseinsamples)andagaincontroloneach.Althoughthissystem
canprovideanoutputwithextremelylowlatency,ittypicallyrequiresanenormousamountofprocessingpower.
Considerforexample,thatinthecaseofa2secondreverberanttailsampledat44.1kHz,aprocessingsystem
usingrealconvolutionworkinginrealtimeonastandardfloatingpointprocessorwithalargecachewouldbe
requiredtoperformapproximately7.8billionoperationspersecondperchannel.
Fastconvolutionreliesontheinterrelatedpropertiesofthefrequencyandtimedomains.Sincethecomplex
multiplicationoftwosignalsinthefrequencydomainisequivalenttotheconvolutionofthesamesignalsinthe
timedomain,itispossibletoperformanFFToneachsignalsimultaneously,multiplytheirrespectiverealand
imaginarycomponents,andperforminganinverseFFTontheproduct,producingatemporalconvolutionofthe
signals.Thisprocedureresultsinaconsiderablesavingsinoperations(844millionoperationspersecondforthe
sameconfigurationasthepreviousexamplewithanFFTsizeof2048samples),howeveritdoesincuranumber
ofissuestoconsidersuchaslatenciescausedbytheFFTblocksizeandstrategiesfordealingwithoverlapping
resultsoftheIFFTprocess.
Therearetwoprincipaldisadvantagesofaconvolutionbasedreverberator:
1. Parametermanipulation:Ifthesystemisbasedonameasuredimpulseresponse,thenitisimpossibleto
altercharacteristicsofthereverberantspaceinabelievablemanner.Forexample,inonecommercially
availabledevice,theuserisofferedacontroloverthereverberationtime,however,thismerelycontrolsa
decayenvelopewhichisappliedtothemeasuredimpulseresponsebeforeconvolution.Whilethis
emulatesanalteredabsorptioncoefficientforthereflectivesurfacesinthespace,itcanresultinsome
drasticeffectssuchastheeliminationofallbuttheearlyreflectionpatterns.
2. Processingpower:Inordertoconvolvesignalsthroughanimpulseresponseinrealtimewithazero
latency,realconvolutionmustbeused.Whilethisispossible,itrequirescomputationalpowerthat,until
recently,hasbeenprohibitive.Thiswillceasetobeanissueinthenearfuturefor44.1kHzand48kHz,
however,itwillbeanumberofyearsbeforehighersamplingratesarefeasible.
Thereisoneoverridingadvantageinusingthistopology:soundquality.Noartificialreverberationdeveloped
todatematchestherealismofasystemthatusescorrectlypreparedmeasuredimpulseresponsesofrealspaces.
Stochasticmodel

Intheory,areverberantdecayapproachesaperfectlydiffusefieldinfact,manylinearacousticstextsassume
thatthereverberanttailisadiffusefield.Whiletherearesomeindicationsthatthismaybeoverlysimplifiedit
canbeusedasanapproximation.Forexample,inaTRDmodel,allpassandrecursivecombfiltersareusedto
createaperceptualequivalenttoaroomsreverberanttail.Whenadeviceisintendedforamultichanneloutput,
manufacturerstypicallyaltertheparametersofthesefiltersinordertoachievetherequirednumberof
uncorrelated,butperceptuallysimilarsignalsinanefforttosimulatethistheoreticaldiffusefield.
In1998,RubakandJohansensuggestedthatanimpulseresponseofthisfieldcouldbesimulatedusinga
recursivepseudorandomalgorithmwithanapplieddecayenvelope.Accordingtopreliminarylisteningtests,
theyreportedthatapseudorandomreverberatorcouldproducehighqualityreverberationwithaminimumecho
densityof2000persecondandarepetitionrateofnogreaterthan10Hz[RubakandJohansen,1998][Rubakand
Johansen,1999].
Informalexperimentsprovethatthismethoddoesindeedproducegoodresults,howeveranextensiononthis
modelisrecommended.Amorerealisticandcontrollabledecaycurvecanbeachievedbydividingthe
uncorrelatednoisesamplesintoconstituentfrequencybandsandapplyingadifferentexponentialdecayenvelope
toeach,typicallyusingshortertimesforhigherfrequencybands.

Oneexcellentcharacteristicofthisalgorithmistheautomaticdecorrelationofthevariousoutputchannels
whendifferentoriginalnoisesamplesareused.Thiscontrastswiththesometimespainstakingattentiontothe
parameterrelationshipsrequiredtoachievethesameisolatedresultwithunitreverberators.Itshouldbenoted,
however,thatalthoughthissystemprovidesresultsequallingorpossiblyimprovingontheTRDmodel,itis
considerablymorecomputationallyexpensiveandthereforeunattractiveasausefulprocedure.
9.8.2SuggestedReadingList

Das könnte Ihnen auch gefallen