Extensions of the Karplus-Strong Plucked-String Algorithm
Total Page:16
File Type:pdf, Size:1020Kb
([WHQVLRQVRIWKH.DUSOXV6WURQJ3OXFNHG6WULQJ$OJRULWKP $XWKRU V 'DYLG$-DIIHDQG-XOLXV26PLWK 5HYLHZHGZRUN V 6RXUFH&RPSXWHU0XVLF-RXUQDO9RO1R 6XPPHU SS 3XEOLVKHGE\The MIT Press 6WDEOH85/http://www.jstor.org/stable/3680063 . $FFHVVHG Your use of the JSTOR archive indicates your acceptance of the Terms & Conditions of Use, available at . http://www.jstor.org/page/info/about/policies/terms.jsp . JSTOR is a not-for-profit service that helps scholars, researchers, and students discover, use, and build upon a wide range of content in a trusted digital archive. We use information technology and tools to increase productivity and facilitate new forms of scholarship. For more information about JSTOR, please contact [email protected]. The MIT Press is collaborating with JSTOR to digitize, preserve and extend access to Computer Music Journal. http://www.jstor.org This content downloaded on Wed, 9 Jan 2013 14:25:21 PM All use subject to JSTOR Terms and Conditions DavidA. Jaffe and Julius 0. Smith Extensions of the Center for Computer Research in Music and Acoustics (CCRMA) StanfordUniversity Karplus-Strong California 94305 Stanford, Plucked-String Algorithm Introduction The String-SimulationAlgorithm In 1960, an efficient computational model for vi- The Karplus-Strongplucked-string algorithm is pre- brating strings, based on physical resonating, was sented in this issue of Computer Music Journal. proposed by McIntyre and Woodhouse (1960). This From our point of view, the algorithm consists of model plays a crucial role in their recent work on a high-order digital filter, which represents the bowed strings (McIntyre,Schumacher, and Wood- string; and a short noise burst, which represents house 1981; 1983), and methods for calibratingthe the "pluck." The digital filter is given by the dif- model to recorded data have been developed (Smith ference equation 1983). Yn-N + YN+ in Alex devised an = Xn + Yn-N yn-(N+1) Independently, 1978, Strong Yn Yn= 2 (1) efficient special case of the McIntyre-Woodhouse string model that produces remarkablyrich and re- where x. is the input signal amplitude at sample n, alistic timbres despite its simplicity (Karplusand y, is the output amplitude at sample n, and N is Strong 1983). Since then, Strong and Kevin Karplus the (approximate)desired pitch period of the note in have explored several variations and refinements of samples. The noise burst is defined by the with an on algorithm, emphasis small-system Au, n = 1 We have found that the 0, 1, 2,...,N- implementations. Karplus- xn = 0, n N, Strong algorithm can be used with equally impres- sive results on fast, high-power equipment. The where A is the desired amplitude, and un, [-1,1] is availability of multiplies, for example, allows sev- the output of a random-numbergenerator. The out- eral modifications and extensions that increase its put yn is taken beginning at time n = N in our usefulness and flexibility. These extensions are de- implementation. scribed in this paper. The developments were moti- vated by musical needs that arose during the composition of May All YourChildren Be Acrobats Analysis of the String Simulator (1981) for computer-generatedtape, eight guitars, and voice and Silicon Valley Breakdown (1982) for Before proceeding to practical extensions of the al- four-channel, computer-generatedtape, both writ- gorithm, we will describe the theory on which ten by David Jaffe.Our theoretical approachand many of them are based. Various concepts from the extensions based on it have also been applied to digital filter theory are employed. For a tutorial in- the McIntyre-Woodhousealgorithm (Smith 1983). troduction to digital filter theory, see the works by Smith (1982b) and Steiglitz (1974). The input-output relation of Eq. (1) may be ex- David A. Jaffeis also affiliated with the Music Departmentat StanfordUniversity, and Julius O. Smith is also affiliatedwith the Electrical EngineeringDepartment there. 1. In some situations, the sound more closely resembles a string Computer Music Journal,Vol. 7, No. 2, struck with a hammer or mallet than one plucked with a pick, Summer 1983, 0148-9267/83/020056-14 $04.00/0, but we will always use the term pluck when referringto the ? 1983 Massachusetts Institute of Technology. excitation. 56 Computer Music Journal This content downloaded on Wed, 9 Jan 2013 14:25:21 PM All use subject to JSTOR Terms and Conditions Fig.1. Blockdiagram for the basic stringsimulator. pressed differently by means of delay-operatornota- tion. We define the unit-sample delay operatord by the relation dkx A-Xn-k, where x, is an arbitrarysignal, and k is an integer. (The symbol A means "is defined as.")Thus, multi- plying a signal by dk delays the signal in time by k samples. In these terms, Eq. (1) becomes dNy + dN+lyn yn = tor is the following set of difference equations: L+d Vn = Yn-N =x+n 2 V= n + Vn- Solving for yn yields 2 = Xn1 yn xn + Wn Yn XI+d' (2) 1- dN The frequency response of a digital filter is de- 2 fined as the transfer function evaluated at z = e's = + where is the sam- We can convert linear delay-operatorequations cos(oT,) j sin(o Ts), T, in seconds is the inverse of the sam- immediately to z-transform equations by replacing pling period (Ts rate o = is radian is each time signal with its z-transform, and replacing pling fj, 27rf frequency, f in and = \-7. The re- d with z-'. It is customary to denote a time signal frequency Hz, j frequency of the simulator is then in lowercase letters (e.g., x) and the corresponding sponse string z-transform in uppercase letters (e.g., X(z)). The 1 H(e,Ts) = transferfunction of a (linear, time-invariant) digital He') 1 - Ha eiw sHb(es)' filter is the z-transform of the output signal divided where by the z-transform of the input. The transferfunc- tion of the string simulator is then found to be 1 + e- 'T = e-' T H|(e 2Ts) e 2cos(coT,/2) Y(z)Y _ 1 H(Z) A =X H X(z)x 1 l+z - = e-fTscos(rfTs) 2 Hb(es s) = e-iN = e- if.NT 1 In this it is to consider 1 - Ha(z)Hb(z)' paper necessary the am- plitude response and phase delay of the feedback fil- where ters separately.The amplitude response is defined as the magnitude of the frequency response, and 1 + z- it gives the gain of the filter as a function of fre- Ha(z) Q 2 quency. The phase delay is defined as minus the Hb(z) z-N complex angle of the frequency response divided by radian frequency, and it gives the time delay This form of the description is shown in Fig. 1. The (in seconds) experienced by a sinusoid at each feedback loop consists of a length N delay line frequency. Hb(z) in series with a two-point average Ha(z). Cor- The amplitude response of each component filter responding to this breakdown of the string simula- is given by Jaffeand Smith 57 This content downloaded on Wed, 9 Jan 2013 14:25:21 PM All use subject to JSTOR Terms and Conditions ___ Ga(f)A IHa(eiTs)I= cos(oT,/2)l = Icos(T7fT)l NTs + Ts/2 sec. Experience shows this to corre- spond well with perceived pitch. Gb(f) A IHbleews)I 1. Thus the delay line Hb is lossless, and the two- point average Ha exhibits a gain that decreases with Decayof "Harmonics" frequency according to the first quadrantof a co- sine. We will assume hereafter that all frequencies Since the signal is only quasi-periodic,it does not are restricted to the Nyquist limit, that is, Ifl consist of discrete sinusoids. Essentially, we have fs/2. In this range, we have (cos(i7fTj)= cos(1rfTs). many narrow "bands"of energy decaying to zero at It is convenient to define phase delay in units different rates. When these energy bands are cen- consisting of samples rather than seconds. The tered at frequencies that are an integer multiple of a phase delays of Ha and Hb in samples are given by lowest frequency, they will be referredto as har- monics. When the frequency components are not Pa(f)"- - / H(e'2) =1 necessarily uniformly the term will ~oT, 2' spaced, partial be used to emphasize the possibility of inharmo- nicity. Consider, then, a partial at frequency f Hz Pb(f) A - / Hb(e'S) = N. PfT, circulating in the loop. On each pass through the loop, it suffers an attenuation to the (Lz denotes the complex angle of z). The two-point equal loop- amplitude response, = that averagehas a phase delay equal to half a sample, Ga(f)Gb(f) cos(IrfTs); is, and the delay line has a phase delay equal to its one period's attenuation = cos(rfTs). length. Since the round-trip time in the N + Since the total loop consists of Haand Hbin se- loop equals 1/2 samples, the number of the ries, the loop gain and effective loop length are trips through loop after n samples (nTssec) is equal to n/(N + 1/2) = loop gain = G(f) Gb(f) = cos(rfT,), tfS/(N + 1/2). Thus the attenuation factor at time and t = nT, is given by tf5 loop length = Pa(f) + Pb(f) = N + 1/2 (samples) af(t) A [cos(7rfTs)]N + 2. (3) for each sinusoidal Hz. frequency f For example, an initial partial amplitude A at time In a we synthesizing single plucked-string note, 0 becomes amplitude Aaf(t) at time t seconds, feed in N of white noise at A samples amplitude where f is the frequency of the partial.