250 likes | 365 Views
ECE 598: The Speech Chain. Lecture 5: Room Acoustics; Filters. Today. Room = A Source of Echoes Echo = Delayed, Scaled Copy Addition and Subtraction of Scaled Cosines Frequency Response Impulse Response Filter = A System with Echoes.
E N D
ECE 598: The Speech Chain Lecture 5: Room Acoustics; Filters
Today • Room = A Source of Echoes • Echo = Delayed, Scaled Copy • Addition and Subtraction of Scaled Cosines • Frequency Response • Impulse Response • Filter = A System with Echoes
Room Acoustics Sample Application: The Beckman Cube Virtual Reality Theater
Direct Sound: Mathematical Notation x(t) = (rs/r0) s(t-t0) • x(t) = Recorded sound pressure (Pascals) • s(t) = Sound at the source (Pascals) • rs = radius of the source (lips, loudspeaker, …) • r0 = distance from source to microphone • t0=r0/c = time it takes for sound to travel from source to microphone s(t) = s ejwt x(t) = x ejwt x = s (rs/r0) e-jwt0
Direct Sound + First Echo x(t) = a0 s(t-t0) + a1 s(t-t1) • t1=r1/c = time it takes for the first echo to travel from source to microphone • a0 = rs/r0 (the “1/r scaling” of the direct sound) • a1 = g(w) rs/r1 • g(w) = amount by which echo amplitude is reduced when it bounces off the wall = “reflection coefficient” • g(w) depends on the material: g≈1 for hardwood, g≈0.1 for carpet s(t) = s ejwt x(t) = x ejwt x = s ( a0e-jwt0 + a1e-jwt1)
The Image Source Method for Simulating the Room Response(Berkeley and Allen, 1979) Key Observation: An echo arrives at the microphone from the same direction, having traveled exactly the same distance, as if it had come from an “image source” located behind the wall. The location of the “image source” is the “mirror image” of the location of the true source, after reflection through the wall.
Image Source Method: Lots of Echoes An echo that bounces off multiple walls behaves as if it had come from several rooms away.
Direct Sound + Lots of Echoes ∞ x(t) = an s(t-tn) • a0s(t-t0) = direct sound • ans(t-tn) = nth echo s(t) = s ejwt x(t) = x ejwt x = H(w) s • H(w) is called the “frequency response” of the room, at frequency w: H(w) = an e-jwtn n=0 ∞ n=0
Example: Starter Pistol • Direct sound: an “impulse” (a very short, very loud sound: s(t)=d(t)) • An impulse has energy at all frequencies; we say s(w)=1 regardless of w Impulse response: a series of delayed, scaled impulse echoes, x(t) = an d(t-tn) Frequency response: the frequency “coloration” you hear is the frequency response of the room: x(w) = H(w) s(w) = H(w) = an e-jwtn
Example: Sweep Tone • Direct sound is a cosine, s(t) = ejwt, with w changing slowly • Recorded sound is a scaled, phase-shifted cosine, x(t) = H(w) ejwt • H(w) of the room (the subject of today’s lecture) • Spectrum of the background noise • Signal to noise ratio, as a function of frequency
Today’s Important Math Fact: Cosine + Cosine Echo = Scaled, Shifted Cosine
Cosine + Cosine Echo: Phasor Notation x(t) = a0 ejw(t-t0) + a1 ejw(t-t1) = ejwt (a0 e-jwt0 + a1 e-jwt1) = ejwt (a0 e-jf0 + a1 e-jf1) • f0 = Phase shift caused by traveling from source to microphone, direct sound (in radians) • f1 = Phase shift, first echo (radians)
Cosine + Cosine Echo: Phasor Notation H(w) = a0 e-jf0 + a1 e-jf1 = {a0cos(f0)+a1cos(f1)} - j{a0sin(f0)+a1sin(f1)} ) = axcos(fx) - jaxsin(fx) • So H(w) = axe-jfx for some ax and fx
If s(t) is a cosine, then x(t) is a scaled shifted cosine x(t) = H(w) s(t) = ax e-jfxejwt = ax ej(wt-fx) Re{x(t)} = ax cos(wt-fx) • If s(t)=cos(wt), then x(t) is a scaled, shifted cosine at the same frequency! • The scaling factor ax and the phase shift fx depend on frequency in some way (remember that f0=wt0 and f1=wt1) • Next question: how can we calculate ax and fx?
ONAMI (Oh No! Another Math Idea!)*: Magnitude and Phase of a Complex Number Suppose z=zR+jzI zR = Re{z} zI=Im{z} We can also write z=Aejf = Acosf+jAsinf A = |z| (“magnitude of z”) f = arg(z) (“phase of z”) Obviously, zR=Acosf; zI=Asinf * “oonami” (“oo”=long /o/) means “big wave” in Japanese. Curiously enough, “onami” (short /o/) means “little wave.” Meaningless but entertaining question for the reader: is the magnitude and phase of complex numbers a big wave, or a little wave?
Finding the Magnitude and Phase • Finding the magnitude: A2=zR2+zI2 Proof: zR2+zI2=A2cos2f+A2sin2f = A2(cos2f+sin2f) = A2 • Finding the phase if zR > 0: f=tan-1(zI/zR) Proof: zI/zR=sinf/cosf=tanf • Finding the phase if zR < 0: f=tan-1(zI/zR) -p The Problem: q = tan-1(zI/zR) is always between –p/2 and p/2 so cos(q) is always positive! The Solution: assume, instead, that q = tan-1(-zI/-zR) so Aejq = Acosq+Asinq = -zR-jzI = -z = -Aejf = Aejpejf= Aej(f+p)
Imagining the Magnitude and Phase of a Complex Number: Four Examples Imaginary Part Imaginary Part z=zR+jzI zI A f Real Part zR Real Part zR f A zI Imaginary Part Imaginary Part -zI zI f = q+p q A Real Part zR -zR Real Part zR -zR A f = q-p q -zI zI
Magnitude and Phase of A Frequency Response ∞ H(w) = an e-jwtn = HR+jHI = Aejf • A2 = HR2+HI2 • f = tan-1(HI/HR), possibly ±p • Here’s what it means: • If: • s(t) = ejwt ; Re{s(t)} = cos(wt) • Then: • x(t) = H(w) ejwt ; Re{x(t)} = A cos(wt+f) n=0
Filters ∞ • A “filter” is any system that adds its input to scaled, shifted copies of itself • x(t) = an s(t-tn) • In order to find x(t), we need two pieces of information: • The input, s(t) • The sequence of echo times, tn, and echo amplitudes, an. This whole sequence of information is often summarized by the “impulse response” of the system, h(t) = and(t-tn). Remember that d(t) is a very short, very loud sound, like a gunshot. h(t) is the output of the system if the input is d(t) • Given s(t) and h(t), we find x(t) using “convolution:” • x(t) = s(t)*h(t) = an s(t-tn) • In matlab, • s=wavread(‘speechsound.wav’); • h=wavread(‘impulseresponse.wav’); • x=conv(s,h); or x=filter(h,1,s); n=0 ∞ n=0 ∞ n=0
Summary: Filters • A “filter” is any system that adds the direct sound together with any number of echoes. There are two methods for simulating a filter in software: • Impulse response: • Given h(t) = and(t-tn), compute x(t) = s(t)*h(t) = an s(t-tn) • Frequency response: • Break down s(t) into a sum of cosines, s(t)=s ejwt • Then, for each cosine, compute x(t) = H(w) s(t) = H(w) s ejwt ∞ n=0 ∞ n=0