Flanger. Fractional Delay using Linear Interpolation. Flange Comb Filter Parameters. Music 206: Delay and Digital Filters II

Similar documents
CMPT 468: Delay Effects

FIR/Convolution. Visulalizing the convolution sum. Convolution

FIR/Convolution. Visulalizing the convolution sum. Frequency-Domain (Fast) Convolution

Digital Filters. Linearity and Time Invariance. Implications of Linear Time Invariance (LTI) Music 270a: Introduction to Digital Filters

Music 270a: Fundamentals of Digital Audio and Discrete-Time Signals

Subtractive Synthesis. Describing a Filter. Filters. CMPT 468: Subtractive Synthesis

Outline. Discrete time signals. Impulse sampling z-transform Frequency response Stability INF4420. Jørgen Andreas Michaelsen Spring / 37 2 / 37

Music 171: Amplitude Modulation

MUS420 Lecture Time Varying Delay Effects

(i) Understanding the basic concepts of signal modeling, correlation, maximum likelihood estimation, least squares and iterative numerical methods

Continuous vs. Discrete signals. Sampling. Analog to Digital Conversion. CMPT 368: Lecture 4 Fundamentals of Digital Audio, Discrete-Time Signals

Resonator Factoring. Julius Smith and Nelson Lee

4.5 Fractional Delay Operations with Allpass Filters

CMPT 318: Lecture 4 Fundamentals of Digital Audio, Discrete-Time Signals

DIGITAL FILTERS. !! Finite Impulse Response (FIR) !! Infinite Impulse Response (IIR) !! Background. !! Matlab functions AGC DSP AGC DSP

Team proposals are due tomorrow at 6PM Homework 4 is due next thur. Proposal presentations are next mon in 1311EECS.

INTRODUCTION TO COMPUTER MUSIC PHYSICAL MODELS. Professor of Computer Science, Art, and Music. Copyright by Roger B.

(i) Understanding of the characteristics of linear-phase finite impulse response (FIR) filters

Lecture 17 z-transforms 2

Electrical & Computer Engineering Technology

2.1 BASIC CONCEPTS Basic Operations on Signals Time Shifting. Figure 2.2 Time shifting of a signal. Time Reversal.

The University of Texas at Austin Dept. of Electrical and Computer Engineering Final Exam

ECE438 - Laboratory 7a: Digital Filter Design (Week 1) By Prof. Charles Bouman and Prof. Mireille Boutin Fall 2015

Signals and Systems Using MATLAB

Spectrum. Additive Synthesis. Additive Synthesis Caveat. Music 270a: Modulation

(i) Understanding of the characteristics of linear-phase finite impulse response (FIR) filters

APPLIED SIGNAL PROCESSING

On-Chip Implementation of Cascaded Integrated Comb filters (CIC) for DSP applications

Music 270a: Modulation

Synthesis Algorithms and Validation

Signals and Filtering

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY DIGITAL SIGNAL PROCESSING UNIT 3

CMPT 468: Frequency Modulation (FM) Synthesis

DSP Laboratory (EELE 4110) Lab#10 Finite Impulse Response (FIR) Filters

Signals. Continuous valued or discrete valued Can the signal take any value or only discrete values?

B.Tech III Year II Semester (R13) Regular & Supplementary Examinations May/June 2017 DIGITAL SIGNAL PROCESSING (Common to ECE and EIE)

Noise removal example. Today s topic. Digital Signal Processing. Lecture 3. Application Specific Integrated Circuits for

Sampling and Reconstruction of Analog Signals

Digital Signal Processing. VO Embedded Systems Engineering Armin Wasicek WS 2009/10

Music 171: Sinusoids. Tamara Smyth, Department of Music, University of California, San Diego (UCSD) January 10, 2019

GSM Interference Cancellation For Forensic Audio

Instruction Manual for Concept Simulators. Signals and Systems. M. J. Roberts

Design of FIR Filters

CHAPTER 6 INTRODUCTION TO SYSTEM IDENTIFICATION

Project 1. Notch filter Fig. 1: (Left) voice signal segment. (Right) segment corrupted by 700-Hz sinusoidal buzz.

SMS045 - DSP Systems in Practice. Lab 1 - Filter Design and Evaluation in MATLAB Due date: Thursday Nov 13, 2003

Signal Processing for Speech Applications - Part 2-1. Signal Processing For Speech Applications - Part 2

SAMPLING THEORY. Representing continuous signals with discrete numbers

INTRODUCTION TO COMPUTER MUSIC SAMPLING SYNTHESIS AND FILTERS. Professor of Computer Science, Art, and Music

Laboratory Assignment 4. Fourier Sound Synthesis

y(n)= Aa n u(n)+bu(n) b m sin(2πmt)= b 1 sin(2πt)+b 2 sin(4πt)+b 3 sin(6πt)+ m=1 x(t)= x = 2 ( b b b b

C.8 Comb filters 462 APPENDIX C. LABORATORY EXERCISES

ECE 429 / 529 Digital Signal Processing

Multirate Digital Signal Processing

SECTION 7: FREQUENCY DOMAIN ANALYSIS. MAE 3401 Modeling and Simulation

The University of Texas at Austin Dept. of Electrical and Computer Engineering Midterm #1

On the Most Efficient M-Path Recursive Filter Structures and User Friendly Algorithms To Compute Their Coefficients

Adaptive Systems Homework Assignment 3

INFINITE IMPULSE RESPONSE (IIR) FILTERS

Linear Frequency Modulation (FM) Chirp Signal. Chirp Signal cont. CMPT 468: Lecture 7 Frequency Modulation (FM) Synthesis

Sound Synthesis Methods

Corso di DATI e SEGNALI BIOMEDICI 1. Carmelina Ruggiero Laboratorio MedInfo

Problem Point Value Your score Topic 1 28 Filter Analysis 2 24 Filter Implementation 3 24 Filter Design 4 24 Potpourri Total 100

NAME STUDENT # ELEC 484 Audio Signal Processing. Midterm Exam July Listening test

ELEC-C5230 Digitaalisen signaalinkäsittelyn perusteet

Digital Filters IIR (& Their Corresponding Analog Filters) Week Date Lecture Title

WARPED FILTER DESIGN FOR THE BODY MODELING AND SOUND SYNTHESIS OF STRING INSTRUMENTS

THE CITADEL THE MILITARY COLLEGE OF SOUTH CAROLINA. Department of Electrical and Computer Engineering. ELEC 423 Digital Signal Processing

CS3291: Digital Signal Processing

Final Exam. EE313 Signals and Systems. Fall 1999, Prof. Brian L. Evans, Unique No

Digital Filtering: Realization

Advanced Digital Signal Processing Part 5: Digital Filters

Signal Analysis. Peak Detection. Envelope Follower (Amplitude detection) Music 270a: Signal Analysis

Discrete-Time Signal Processing (DTSP) v14

Complex Sounds. Reading: Yost Ch. 4

Chapter 18. Superposition and Standing Waves

Digital Signal Processing

Final Exam Practice Questions for Music 421, with Solutions

FLASH rf gun. beam generated within the (1.3 GHz) RF gun by a laser. filling time: typical 55 μs. flat top time: up to 800 μs

SCUBA-2. Low Pass Filtering


Interpolation Error in Waveform Table Lookup

Laboratory Assignment 2 Signal Sampling, Manipulation, and Playback

GEORGIA INSTITUTE OF TECHNOLOGY. SCHOOL of ELECTRICAL and COMPUTER ENGINEERING. ECE 2026 Summer 2018 Lab #8: Filter Design of FIR Filters

EE 470 Signals and Systems

EE247 Lecture 26. This lecture is taped on Wed. Nov. 28 th due to conflict of regular class hours with a meeting

The Case for Oversampling

ESE531 Spring University of Pennsylvania Department of Electrical and System Engineering Digital Signal Processing

THE BEATING EQUALIZER AND ITS APPLICATION TO THE SYNTHESIS AND MODIFICATION OF PIANO TONES

1. In the command window, type "help conv" and press [enter]. Read the information displayed.

Room Impulse Response Measurement and Analysis. Music 318, Winter 2010, Impulse Response Measurement

The University of Queensland School of Information Technology and Electrical Engineering. ELEC3004/7312: Signals, Systems and Controls

EECS40 RLC Lab guide

Problem Point Value Your score Topic 1 28 Discrete-Time Filter Analysis 2 24 Improving Signal Quality 3 24 Filter Bank Design 4 24 Potpourri Total 100

Narrow-Band and Wide-Band Frequency Masking FIR Filters with Short Delay

PROBLEM SET 6. Note: This version is preliminary in that it does not yet have instructions for uploading the MATLAB problems.

ABC Math Student Copy

Biomedical Signals. Signals and Images in Medicine Dr Nabeel Anwar

Phase Correction System Using Delay, Phase Invert and an All-pass Filter

Experiments #6. Convolution and Linear Time Invariant Systems

Transcription:

Flanger Music 26: Delay and Digital Filters II Tamara Smyth, trsmyth@ucsd.edu Department of Music, University of California, San Diego (UCSD) January 22, 26 The well known flanger is a feedforward comb filter with a time-varying delay M(n) (see flanging.mov). Flanging, used in recording studios since the 96s, creates a rapidly varying high-frequency sound by adding a signal to an image of itself that is delayed by a short, variable amount of time. Flanging was accomplished in analog studios by summing the outputs of two tape machines playing the same tape. flange Figure : Two tape machines are used to produce the flanging effect. By touching (and releasing) the flange on one supply reel, it would s to slow it down (and speed it up). Music 26: Delay and Digital Filters II 2 Flange Comb Filter Parameters Fractional Delay using Linear Interpolation The flange simulation is a feedforward comb filter, where the delay M(n) is a function of time, = x(n)+gx(n M(n)). coefficient g (DEPTH parameter), determines the prominence of the flanging effect. flange is typically swept from a few milliseconds to to produce characteristic flange sound. The time-varying delay can be handled by modulating M(n) with a low-frequency oscillator (LFO) sinusoid: where M(n) = M [+Asin(2πfnT)], f rate or speed of the flanger, in Hz A excursion (maximum delay swing) M average delay length controlling the average notch density. For a successful flanging effect, M(n) must change smoothly over time: M(n) should not have jumps in values associated with rounding to the nearest integer. One of the simplest ways to handle fractional delay is by using linear Interpolation: the linear interpolator effectively draws a line between neighbouring samples, and returns the appropriate value on that line. amplitude.5.5 Linearly interpolating to obtain value at sample 8.25 7.5 8 8.5 9 9.5 8.25 time (samples) Figure 2: Linear Interpolation. Music 26: Delay and Digital Filters II 3 Music 26: Delay and Digital Filters II 4

Linear Interpolation (Implementation) Tapped Delay Line The fractional part of the delay, δ, effectively determines how far to go along the line between samples. A fractional delay ˆx(n (M +δ)), reads from the delay line at neighbouring delays M and M +, and takes the weighted sum of the outputs: ˆx(n (M +δ)) = ( δ)x(n M) +δx(n (M +)), where M is the integer and δ is the fractional part. Notice that if δ =, the fractional delay reduces to the regular integer delay. Linear interpolation in a circular delay line (Matlab): A tap refers to the extraction of the signal at a certain position within the delay-line. The tap may be interpolating or non-interpolating, and also may be scaled. A tap implements a shorter delay line within a larger delay line. x(n) z M b b x(n M ) z (M2 M) Figure 3: A delay line tapped after a delay of M samples. = x(n M 2) if (outptr==) z = (-delta)*dline(outptr) + delta*dline(mmax); else z = (-delta)*dline(outptr) + delta*dline(outptr-); end Music 26: Delay and Digital Filters II 5 Music 26: Delay and Digital Filters II 6 Multi-Tap Delay Line Example Chorus Multi-Tapped delay lines efficiently simulate multiple echoes from the same source signal. x(n) b z M b z (M2 M) b2 z (M3 M2) Figure 4: A multi-tapped delay with length M3. In the above figure, the total delay line length is M 3 samples, and the internal taps are located at delays of M and M 2 samples, respectively. The output signal is a linear combination of the input signal x(n), the delay-line output x(n M 3 ), and the two tap signals x(n M ) and x(n M 2 ). The difference equation is given by = b x(n)+b x(n M )+b 2 x(n M 2 )+b 3 x(n M 3 ) b3 A Chorus is produced when several musicians play simultaneously, but inevitably with small changes in the amplitudes and timings between each individual s sound. The chorus effect is a signal processing unit that changes the sound of a single source to a chorus by implementing the variability occurring when several sources attempt to play in unison. Convolution is equivalent to tapping a delay line every sample and multiplying the output of each tap by the value of the impulse response for that time. Music 26: Delay and Digital Filters II 7 Music 26: Delay and Digital Filters II 8

Chorus Implementation A Simple Recursive (IIR) Filter A chorus effect may be efficiently implemented using a multi-tap fractional delay line: taps are not fixed and usually range from to 5 ms. their instantaneous delay may be determined using a random noise generator or, as in the flanger, a Low Frequency Oscillator (LFO). Using FIR filters to reproduce a desired frequency response often requires a very high-order filter, i.e., a greater number of coefficients and more computation. It is often possible to reduce the number of feedforward coefficients by introducing feedback coefficients. A simple first-order recursive low-pass filter is given by = x(n)+.9y(n ) z M(n) g = x(n)+x(n ) x(n) z M2(n) z M3(n) g2 g3 amplitude (linear).8.6.4.2.5..5.2.25.3.35.4.45.5 z M4(n) Figure 5: A bank for variable delay lines realize the chorus effect. The chorus is similar to the flanger, only there are multiple delayed copies of the input, and the delay times are typically longer (where a flanger is about - ms, a chorus is about -5 ms). g4 amplitude (linear).8.6.4.2 = x(n)+.9y(n ).5..5.2.25.3.35.4.45.5 frequency (normalized) Figure 6: The spectral magnitude of the first-order FIR and IIR (recursive) lowpass filters. Music 26: Delay and Digital Filters II 9 Music 26: Delay and Digital Filters II The General Difference Equation for LTI filters The Simple Feedback Comb Filter The general difference equation for LTI filters includes feedback terms, and is given by = b x(n) + b x(n )+ +b M x(n M) a y(n ) a N y(n N) This can be implemented in Matlab using the filter function: B =...; % feedforward coefficients A =...; % feedback coefficients y = filter(b, A, x); Matlab specifies coefficients according to the filter transfer function and NOT the difference equation: all feedback coefficients (except the first) have a sign opposite to that in the difference equation; this is explained by moving the y terms in the difference equation to the left of the equal sign (a step in arriving at the filter transfer function): +a y(n )+ = b x(n)+b x(n )+ What happens when we multiply the output of a delay line by a gain factor g then feed it back to the input? x(n) g z M Figure 7: The signal flow diagram of a comb filter. The difference equation for this filter is = x(n)+gy(n M), If the input to the filter is an impulse x(n) = {,,,...} the output (impulse response) will be... g τ g 2 g 3 Figure 8: Impulse response for filter = x(n)+gy(n M), where τ = M/fs. Music 26: Delay and Digital Filters II Music 26: Delay and Digital Filters II 2

Effect of Feedback Delay Effect of the Feedback coefficient g Since the pulses are equally spaced in time at an interval equal to the loop time τ = M/f s seconds, it is periodic and will sound at the frequency f = /τ..8.6.4.2 Simple feedback comp filter where feedback coefficient g =.8.5..5.2.25.3.35.4.45.5 Coefficient g is the depth parameter, where values closer to yield more extreme maxima and minima. Magnitude (db).8.6.4.2 5 5 2 Comp filter feedback coefficient g =..5..5.2.25.3.35.4.45.5 25.5..5.2.25.3.35.4.45.5 Frequency (H) Comp filter feedback coefficient g =.5.8.6.4.2.5..5.2.25.3.35.4.45.5 Magnitude (db) 5 5 2.5..5.2.25.3.35.4.45.5 Frequency (H) Magnitude (db) 5 5 2 25.5..5.2.25.3.35.4.45.5 Frequency (H) Comp filter feedback coefficient g =.9.8.6.4.2 Figure 9: Impulse and magnitude response of a comb filter with feedback g =.8. The spacing between the maxima of the teeth is equal to the natural frequency f. Magnitude (db) 5 5 2.5..5.2.25.3.35.4.45.5 25.5..5.2.25.3.35.4.45.5 Frequency (H) Figure : Impulse and Magnitude Response with increasing feedback coefficient. Music 26: Delay and Digital Filters II 3 Music 26: Delay and Digital Filters II 4 Feedback Comb Filter Decay Rate Obtaining a desired T 6 The response decays exponentially as determined by the loop time and gain factor g (values near yield longer decay times). (offset for comparison) 3 2.5 2.5.5 f = 22.5 Hz, T6 =.25 (blue),.5 (green), and.75 (red) seconds..2.3.4.5.6.7 Figure : Comb filter impulse responses with a changing the decay rate. The T 6 is the time to decay to an inaudible level of -6 db or by. on a linear scale. Given a loop time of M samples (frequency f ) and a desired T 6, what should be the value of g? If the loop has a delay of M samples, the number of trips through the loop after n samples, or after t seconds is n M = tf s M = tf, where f is the fundamental frequency of the loop. Attenuation at time t is given by α(t) = g tf. At time t = T 6, the attenuation is., α(t 6 ) = g T 6f = g T 6f s /M =., and solving for g yields g =. M/(f st 6 ). Music 26: Delay and Digital Filters II 5 Music 26: Delay and Digital Filters II 6

General Comb Filter A very simple string model Combining both the feedforward and feedback comb filter yields the general comb filter, given by the difference equation = x(n)+g x(n M ) g 2 y(n M 2 ) where g and g 2 are the feedforward and feedback coefficients, respectively. x(n).5.5.5 z M g g 2 z M2 Figure 2: Signal flow diagram for digital comb filters. 5 5 2 25 3 35 4 A very simple string model can be implemented using a single delay line and our simple first-order low pass filter H(z) to model frequency-dependent loss. z N H(z) y(n N) Figure 4: A very simple model of a rigidly terminated string. Though losses are distributed along the length of the string, in an LTI system they may be lumped to a single observation point and approximated with H(z). Different quality string sounds can be created by changing this filter. This model may be interpreted as a feedback comb filter with lowpassed feedback or a simplified digital waveguide model. How is this model excited? How is the string plucked? Figure 3: Comb Filter Impulse Response. Music 26: Delay and Digital Filters II 7 Music 26: Delay and Digital Filters II 8 Karplus-Strong Pluck String Controlling Karplus-Strong When the delay-line initial conditions consist of white noise, the algorithm is known as the Karplus-Strong algorithm. White noise is a sequence of uncorrelated random values. It can be generated in Matlab as follows: N =...; % length of vector y = randn(, N); % N samples of Gaussian white noise % with zero mean and unit variance x = rand(, N); % N samples of white noise, % uniform between and xn = 2*(x-.5); % uniform between - and Filling the delay line with white noise is akin to plucking the string with a random initial displacement a very energetic excitation. What are the control parameters of this model? Controlling Dynamics: Limit the range of random numbers change the Matlab line xn = 2*(x-.5); % uniform between - and Filter the white noise serving as the initial conditions. The cut-off frequency of the filter will control the effective dynamic level (since acoustic instruments are usually brighter at louder dynamic levels). Sounding frequency (pitch) Change the delay line length, where f = f s /(N +/2). The /2 term in the denominator is due to the low-pass filter s phase delay of /2 sample. Notice that the delay-line length is of an integer size. This limits the resolution of possible sounding frequencies. Music 26: Delay and Digital Filters II 9 Music 26: Delay and Digital Filters II 2

Limits of integer-length delay lines Frequency-dependent decay rate At low frequencies (large N), this is less of a problem, but becomes increasingly problematic at higher frequencies when delay-line lengths are small and a single sample delay can make a bigger difference. Another (control) problem with KS is that, because of the low-pass filter in the feedback loop, the decay rate is dependent on frequency. 8 Integer Delay Frequency Quantization Plucked string at 44 Hz.8 7 6.6.4 Quantized Frequency (Hz) 5 4 3.2.5.5 2 2.5 3 2 Plucked string at 882 Hz.8 2 3 4 5 6 7 8 Desired Frequency (Hz) Figure 5: As the desired frequency gets higher, it is quantized to fewer possible values; there is a single frequency value for all desired frequencies between 7 and 8 Hz..6.4.2.5.5 2 2.5 3 Example: at f s = 44, to obtain a frequency of 882 Hz, a delay of f s /882 = 5 samples is required; the next highest possible frequency with an integer number of samples is f s /49 = 9 Hz. Music 26: Delay and Digital Filters II 2 Figure 6: Decay rate is faster at higher frequencies. This behaviour is generally desired, as it is a characteristic of acoustic systems, but it is too extreme in the KS. Music 26: Delay and Digital Filters II 22 Selected Smith and Jaffe Extensions Tuning In a paper by Smith and Jaffe (Computer Music Journal, Summer 983) extensions to the Karplus-Strong are developed in a musical context: Tuning (fractional delay) using allpass filters as an alternative to linear interpolation Decay rate shortening and stretching Dynamics Plucking position Rests at the ends of notes (i.e. turning off the algorithm without hearing a click) Glissandi and Slurs Sympathetic String Simulation Find paper here For large N (low pitches) the difference between N and N + is slight, but becomes increasingly noticeable for small N (high pitches). Recall, the fundamental frequency (which is inversely proportional to the period) is given by f f s = (N +/2)T s N +/2 which may be expressed more generally in terms of phase delay of our feedback filter: f = f s N +P a (f ). We need to introduce a filter into the feedback loop that can contribute a small delay without alterning the loop gain. What kind of filters can introduce a frequency-dependent delay without having an effect on gain? Music 26: Delay and Digital Filters II 23 Music 26: Delay and Digital Filters II 24

First-Order Allpass Filter Phase delay of First-Order Allpass Filter The first-order allpass filter has difference equation = Cx(n)+x(n ) Cy(n ), where C < for stability. The phase delay, unlike the 2-point averager, is dependent on frequency. phase (radians) phase (radians).5.5 2 2.5 3..2.3.4.5 First order allpass with c =.9 5 5 2 Low frequency phase response (up to omega = ) The low-frequency phase delay may be approximated by P c (f) C +C. The filter coefficient C may be solved as a function of the desired phase delay P c (f). C P c(f) +P c (f). Notice if P c = then C = : this produces a pole-zero cancellation on the unit circle which can cause an unstable filter due to round-off errors! thus, the one-sample delay control is shifted to ǫ P c (+ǫ)..6 2 3 4 5 6 7 frequency (khz) Music 26: Delay and Digital Filters II 25 Music 26: Delay and Digital Filters II 26 Setting the Allpass Phase Delay to a Desired Frequency Attenuation of Harmonics A fundamental frequency f has a corresponding period of P = f s /f samples. The model should then have a phase delay of N +P a (f )+P c (f ) = P samples. where P a (f ) = /2 for the two-point averager. The delay line length N becomes N Floor(P P a (f ) ǫ), where ǫ is a number much less than, that was used to shift P c (f ) s one-sampe delay range above to. The fractional phase delay (in samples) for the allpass interpolator becomes P c (f ) P N P a (f ). On each pass through the delay-line loop, a partial at frequency f is subject to an attenuation equal to the loop amplitude response H(ωT). The frequency response H(ωT) of the simple lowpass filter may be found by testing with a complex sinusoid x(n) = e ωnt : = x(n)+x(n ) = e jωnt +e jω(n )T = e jωnt +e jωnt e jωt = (+e jωt )e ωnt = (+e jωt )x(n), where H(e jωt ) = (+e jωt ). The gain of the filter is given by G(ω) = H(e jωt ) = (+e jωt ) = (e jωt/2 +e jωt/2 )e jωt/2 = 2cos(ωT/2)e jωt/2 = 2cos(ωT/2) Music 26: Delay and Digital Filters II 27 Music 26: Delay and Digital Filters II 28

Loop Attenuation at frequency f Solving for corresponding time constant The gain of the low-pass filter at frequency f is G a (f) = cos(πft s ). After M passes through the delay-line loop, a partial at frequency f is subject to attenuation cos(πft s ) M. Since the round-trip time in the loop is N +/2 samples, the number of trips through the loop after n samples (n = tf s ) is given by M = n N +/2 = tf s N +/2 = tf. The attenuation factor at time t = nt s is given by α f (t) cos(πft s ) tf. The time constant τ is the time to decay by /e. To solve for τ f, the time constant for frequency f, α f (t) = e t/τ f lnα f (t) = t (take log of both sides) τ f τ f = t lnα f (t) t = tf ln(cos(πft s )) seconds = f ln(cos(πft s )) seconds = (N +/2)T s ln(cos(πft s )) seconds. That is, a partial or harmonic of frequency f, having an initial amplitude of A at time, will have amplitude Aα f (t) at time t seconds. Music 26: Delay and Digital Filters II 29 Music 26: Delay and Digital Filters II 3 Attenuation and Decay with General Loss Filter Relating to the T 6 The filter accounting for frequency-dependent loss may be other than a two-point averager. A general presentation of the attenuation factor for the k th harmonics is given by α k (t) = G a (f k ) tfs N+Pa(f k), and the decay for each harmonic becomes τ k = N +P a(f k ) f s lng a (2πf k T s ), where G a (f k ) and P a (f k ) are the gain and phase delays, respectively, of the filter used. For audio/music, it is more useful to define the time constant as the time it takes to decay -6dB, or. times the initial value. The attenuation factor at time t = T 6 (f) is given by α f (T 6 (f)) =.. Conversion from τ to T 6 is done by. = e T 6/τ ln(.) = T 6 τ T 6 = ln(.)τ 6.9τ Music 26: Delay and Digital Filters II 3 Music 26: Delay and Digital Filters II 32

Decay of non-harmonics Decay-time Shortening The previous analysis describes the attenuation due to propagation around the loop. Sinusoids that do not fit into the loop, are quicky destroyed by self interference. 2 8 6 4 2 2.2.4.6.8.2.4.6.8 2 Figure 7: Destructive interference occurs at odd harmonics of the fundamental frequency. Though the loop is initialized with random numbers, after a very short time the primary frequencies remaining in the loop are those with an integer number of periods in N + /2 samples. Music 26: Delay and Digital Filters II 33 f 2f 3f 4f 5f To shorten the decay time, a loss factor of ρ can be introduced in the feedback loop, yielding y(n N)+y(n (N +)) = x(n)+ρ 2 The amplitude envelope of a sinusoid at frequency f, is now proportional to α f (t,ρ) = ρcos(πft s ) tf = ρ tf α f (t). and the decay-time constant for the fundamental frequency becomes τ (ρ) = f ln ρcos(πf T s ). Note that ρ cannot be used to lengthen the decay time, since the amplitude at Hz would increase exponentially. ρ if the string is to be stable. ρ is used to shorten the low-pitch notes. Music 26: Delay and Digital Filters II 34 Setting ρ for a desired T 6 Decay Stretching For a desired T 6, determine the corresponding time constant τ τ t 6 6.9. Use this value in solving for ρ, τ = f ln ρcos(πf T) ln ρcos(πf T) = f τ ρcos(πf T) = e f τ ρ = e /(f τ) cos(πf T) To stretch the decay, and reduce the lowpass effect at high frequencies, the simple lowpass can be replaced with a two-point weigthed average = ( S)x(n)+Sx(n ), where S, the stretching factor, is between and. For stability, S can t be greater than. When S = /2, the filter reduces the the previous two-point averager. When S = or, the frequency-dependent term (delay) disappears, and the gain response is unity for all f. At intermediate values, < S <, the note duration is finite, with a minimum for S = /2. The resulting decay time is then a function of loss factor ρ and stretch factor S. Music 26: Delay and Digital Filters II 35 Music 26: Delay and Digital Filters II 36

Effect of Decay Stretching on Tuning Time constant as a function of S Changing S changes the effective loop length as a function of frequency since it changes the phase delay of the overall loop. we must therefore compute P a (f ) when using the allpass filter fractional delay to tune to the desired frequency. As shown in the paper by Smith and Jaffe, for low frequencies relative to the sampling rate, we may use the approximation See this in Matlab: P a (f,s) S, S. S =.6; [H, omega] = freqz([-s S], ); Recall the gain of the simple 2-point averager is G(ω) = +e jωt The gain of the weighted 2-point averager is G(S;ω) = ( S)+Se jωt = ( S)+S[cos(ωT)+jsin(ωT))] = [( S)+S(cos(ωT)] 2 +S 2 sin 2 (ωt)) = ( S) 2 +2S( S)cos(ωT)+S 2. The time constant is τ = f ln(g(s;ω)) = N +S f s ln(g(s;ω)) % start at index 2 to avoid division by mean(angle(h(2:end))./omega(2:end)); When S = /2, we have the basic string algorithm. Music 26: Delay and Digital Filters II 37 Music 26: Delay and Digital Filters II 38