Gain of simple lowpass CMPT 889: Decay Rate Tutorial/Implementation Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University • What is the decay rate of the original simple low pass filter y(n) = 0.5x(n) − 0.5x(n − 1)? November 13, 2009 • The steps are as follows 1. find the gain of the filter; 2. find the attenuation due to the filter in the context of the model with a known period; 3. find the associated time constants τ and t60; 1 CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial Gain Attenuation of simple lowpass • Consider the frequency response of the filter: • Consider the attenuation caused by this filter in the context of a model with delay N + 1/2 or with fundamenatal frequency −jωT 1+e 2 ejωT /2 + e−jωT /2 −jωT /2 = e 2 = cos(ωT /2)e−jωT /2. H(ejωT ) = 2 f1 = 1 fs . = (N + 1/2)Ts (N + 1/2) • Consider the number of trips through the loop after n samples (t = nTs seconds): • The gain is given by the magnitude of the frequency response: M= G(ω) = | cos(ωT /2)e−jωT /2| = cos(ωT /2). n nTsfs tfs = = = tf1. N + 1/2 N + 1/2 N + 1/2 • The attenuation at time t = nTs is then given by α(t) , G(f1)tf1 = cos(πf1T )tf1 . • The gain at frequency f is given by • In general the attenuation at time t = nTs is given by G(f ) = cos(πf T ). tfs α(t) , G(f1) N+P (f1) where P (f1) is the phase delay of the lowpass filter at frequency f1. CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 3 CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 4 Time constant τ Note Duration (t60) • The time constant τ , i.e. time to decay by 1/e, is given by • The t60 (time to decay by 60 dB) is the time after which the note can no longer be heard, i.e., the note duration. α(t) = e−t/τ t ln α(t) = − τ τ = − • An attenuation of 60 dB corresponds to an mplitude of 0.001. t 1 =− ln α(t) f1 ln(cos(πf1T )) • To convert τ to t60: 0.001 = e−t60/τ t60 ln(0.001) = − τ t60 = − ln(0.001)τ ≈ 6.91τ • or more generally τ =− t 1 = − fs ln α(t) ln G(f1) N +P (f ) CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 5 Shortening the Note Duration CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 6 Setting ρ for a desired t60 • The lowpass filter 0.5y(n) + 0.5y(n − N ) has a set t60 for a note at frequency f1. • For a desired t60, determine the corresponding time constant τ t60 t60 = . τ =− ln(0.001) ln(1000) • Consider multiplying by a factor 0 < ρ <= 1. 1 + e−jωT . H(ejωT ) = ρ 2 • The time constant is given by 1 f1 ln(ρ cos(πf1T )) 1 ln(ρ cos(πf1T )) = − f1 τ 1 ρ cos(πf1T ) = exp − f1τ −1/(f1τ ) e ρ = − cos(πf1T ) • This changes the gain at frequency f1 to τ = − G(f ) = ρ cos(πf1T ), and the attenuation at time t to α(f ) = (ρ cos(πf1T ))tf1 . • As this is just a scalar gain, it does not effect the phase delay of 1/2 a sample (nor the frequency f1). • The time constant is given by 1 τ =− f1 ln(ρ cos(πf1T )) CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 7 CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 8 Decay Stretching • To find the stretch factor S τ = − • The new filter is H = = = = = ln(G(S; f )) = − (1 − S) + Se−jwT [(1 − S)ejωT /2 + Se−jωT /2]e−jωT /2 [ejωT /2 − S(ejωT /2 − e−jωT /2]e−jωT /2 [cos(ωT /2) + j sin(ωT /2) − 2jS sin(ωT /2)]e−jωT /2 [cos(ωT /2) + j sin(ωT /2)(1 − 2S)]e−jωT /2 • The gain of the filter is q G(S; f ) = cos2(ωT /2) + (1 − 2S)2 sin2(ωT /2) N +S fs ln(G(S; f ) N +S fsτ G(S; f ) = e−(N +S)/(fsτ ) G(S; f ) = e−N/(fsτ ) e−S/(fsτ ) • As you can see this gets a little harrowing. Since eS/(f sτ ) ≈ 1 for the values of S we are considering, we may use an approximation. • The attenuation at time t is q tf 2 2 2 α(t) = cos (ωT /2) + (1 − 2S) sin (ωT /2) • The time constant is N +S 1 1 =− τ =− = − fs f ln(G(f )) f s ln(G(f )) N +S ln(G(S; f )) CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 9 Finding approximate Stretch Factor S • The Stretch factor S for a give frequency f and time constant τ (omitting phase delay) is approximated by 1 f ln(G(S; f ) 1 ln(G(S; f )) = − fτ G(S; f ) = e−1/(f τ ) τ =− q cos2(πf T ) + (1 − 2S)2 sin2(πf T ) = e−1/(f τ ) cos2(πf T ) + (1 − 2S)2 sin2(πf T ) = e−2/(f τ ) e−2/(f τ ) − cos2(πf T ) (1 − 2S)2 = sin2(πf T ) s e−2/(f1τ ) − cos2(πf T ) (1 − 2S) = ± sin2(πf T ) s e−2/(f1τ ) − cos2(πf T ) 2S = 1 ± sin2(πf T ) s e−2/(f1τ ) − cos2(πf T ) 1 S= ± 2 4 sin2(πf T ) CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 11 CMPT 889: Computational Modelling for Sound Synthesis: Decay Rate Tutorial 10