The first attempt to generate musicalsounds by solvingthe equations of vibratingstringsby means of finitedifference methods (FDM) wasmadeby Hiller and Ruiz [J. Audio Eng. Soc.19, 462472 (1971)]. It is shownhere how this numericalapproachand the underlyingphysical modelcan be improvedin order to simulatethe motionof the pianostringwith a high degree of realism.Startingfrom the fundamental equations of a damped,stiff stringinteracting with a
nonlinear hammer, a numerical finite differenceschemeis derived, from which the time histories
of stringdisplacement andvelocity for eachpointof the stringarecomputed in thetimedomain. The interacting forcebetween hammerand string,as well as the forceactingon the bridge,are givenby the samescheme. The performance of the model is illustratedby a few examples of simulated string waveforms.A brief discussion of the aspectsof numerical stability and dispersion with reference to the properchoiceof sampling parameters is alsoincluded.
PACS numbers: 43.75.Mn
LIST OF SYMBOLS
N p s
T
c=
E
dampingcoefficients transverse wave velocityof string Young's modulusof string force density fundamental frequency
v(x,t)
VHO
Xo
y(x,t) a =xo/L
at=l/fe
Ax= L/N
spatialwindow spatialindex
coefficient of hammer stiffness
K
L
/(t)
K
Ms=pL Mr Mr/Ms
string tension transverse string velocity hammer velocity initial hammer velocity (t = 0) distance of hammerfrom agrafie transverse displacement of string relativehammerstrikingposition(RHSP) time step spatialstep string stiffness parameter hammer displacement radiusof gyrationof string linear massdensity of string
decay rate
hammer-stringmassratio (HSMR)
time index
INTRODUCTION
The vibrationalproperties of a musicalinstrument-like any other vibrating structurecan be described by a set of differentialand partial differentialequations derived
from sucha set of equations. Consequently, it is necessary to use numerical methodswhen testingthe validity of a physicalmodel of a musicalinstrument.
Once the numerical difficulties have been mastered, a
from the general lawsof physics. Sucha set of equations, which definethe instrumentwith a higheror lesserdegree of perfection, is oftenreferred to asa physical model.Due to the complex design of the traditionalinstruments, which
in most cases also include a nonlinear excitation mecha-
meansthat the influence of step-by-step variations of significantdesignparameters like string properties, plate resonances,and others, can be evaluated. Such a systematic researchmethod could hardly be achievedwhen working
with real instruments, not even with the assistance of
0001-4966/94/95(2)/1112/7/$6.00
advanced physicalmodels,which reproduce the performanceof traditional instruments with highfidelity,canbe usedas a tool for computer-aided-lutherie (CAL). Variousnumerical methods havebeenused extensively for manyyears in otherbranches of acoustics, for example in underwater acoustics wherethe goalis to solvethe elas-
with a nonlinearcompression characteristic. He investigated, in particular,somedetailsof the hammer-string interaction, and the efficiency in the energytransmission from hammerto string.The effectof stringinharmonicity was taken into accountin a simplified mannerby slightly
rectly,andjudgethe realism of the simulation. Amongthe largenumberof numericaltechniques available, finite differencemethods(FDM) are particularlywell suitedfor
solving hyperbolic equations in thetime domain. 2Forsystems in one dimension, like the transverse motion of a
other things?
In comparison with the earlier studies mentioned above, the present modelhasthe featureof a detailedmodequation thatsimulates thepropagation along thestring. 3 eling of the piano string and hammeras closelyas possible The generality of FDM makesit possible to alsousethem to the basicphysical relations: Our modelis entirelybased for solvingproblems in two and three dimensions. The approximations of the continuous equamain practicallimit then is set by the rapidly increasing on finite difference tionsfor the transverse vibrations of a dampedstiff string computingtime. struckby a nonlinearhammer.The blow of the hammeris Historically, Hiller and Ruiz werethe firstto solvethe represented by a forcedensityterm in the waveequation, equations of the vibratingstringnumerically in order to simulate musical sounds? Themodel of thepiano string distributedin time and space,and the dampingis frequencydependent. and hammerusedby thesepioneers was,however,rather The presentation is organized as follows.In Sec.I, the crudein viewof the improvements in pianomodeling over the last two decades? Forexample, the crucial value ofthe continuousmodel for the dampedstiff string is briefly reviewed,with regardto the waveequation,and to the equacontact duration between hammer and string, in reality the hammer-stringinteraction.In Sec.If, being a result of the complexhammer-stringinteraction, tions governing it is shown how thistheoretical background canbeput into was set beforehand as a known parameter. a discreteform for time-domainsimulations. SomeimporSomeyearslater, Baconand Bowsherdeveloped a disof numerical stability, dispersion, and accucrete model for the struck stringwhere the hammerwas tant aspects racyarebrieflydiscussed here,in particular theselection of defined byitsmass anditsinitial velocity. 6 Displacement the appropriate number N of spatial steps as a function of waveforms werecomputed for bothhammerand stringat the contact point.Their modelcanbe regarded asthe first the fundamentalfrequencyf of the string, for a given sampling frequency f. A detailed treatment of the numerseriousattempt to achievea realisticdescription of the ical aspects can be found in a previous paper by the first hammer-stringinteractionin the time domain.However,
severaleffectswere not modeledin detail. The damping was includedas a single fluid (dashpot) term, and the stiffness of the string was neglected. The model assumed further a linear compression law of the felt. From a numericalpoint of view,no attemptsweremadeto investigate stability,dispersion, and accuracy problems. More recently,Boutilionmadeuseof finitedifferences for modelinga piano string without stiffness, assuming a nonlinear compression law and the presence of a hysteresis in the felt. He investigated, in particular, the hammerstringinteraction for two notes,in the bass and mid range,
respectively. 7
In all three papers mentioned, the numerical velocity,
i.e., the ratio betweenthe discrete spatialand time steps, was set equal to the physicaltransverse velocity of the string. It has beenshownthat this particularchoiceis possible for an ideal string only, and that the numerical
scheme becomesunstable if stiffness,or nonlinear effects
piano string in a plane perpendicular to the soundboard. The vibrationsare governed by the followingequation:
2-2 --
oy 3---+f(x,xo,t), +2b
(1)
dueto largevibrationamplitudes, are takeninto account in the model. 3 At aboutthe sametime, Suzukipresented an alternative for simulating the motionof hammerand string,using a stringmodelwith lumpedelements struckby a hammer
1113 J. Acoust. Soc.Am.,Vol. 95, No. 2, February 1994
in which stiffness and damping terms are included.The stiffness parameteris givenby
e=(ES/TL2).
(2)
B. Initial and boundary conditions For the struck string, it is now well known that the force Ft(t) is a result of a nonlinearinteractionprocess
main causeof dispersion in piano strings,especially in the lowest range of the instrument,givesrise to a "precursor" which precedes the main pulsesin the string waveform. Possibly it could also affect the perceived attack transient. 0
The two partial derivatives of odd order with respect to time in Eq. (1) simulatea frequency-dependent decay
rate of the form,
a= 1/r=b +b3o 2.
(3)
As a consequence, the decaytimesof the partialsin the simulatedtones will decreasewith frequency,as can be
Mud----= --F(t),
(7)
and wherethe stiffness parameters K andp of the felt are derivedfrom experimental data on real piano hammers. The losses in the felt are neglected. In the computerprogram,the interactionprocess ends when the displacement of the hammer head becomes less than the displacement of the string at the center of the contactsegment (x0). This yields,amongotherthings,the contactdurationbetween hammerand string.
The string is assumed to be hingedat both ends,which
(0,t)=I x (L,t)=O.
Theseboundaryconditions do not correspond strictly due to string polarization, differences in horizontal and to the string terminations in real pianos, and will be reconverticalsoundboard admittance, and "mistuning"within a sidered in a future work. string triplet. The continuousmodel of piano stringsdevelopedin The forcedensity term f(xXo,t) in Eq. ( 1) represents this sectionforms the basit of our numerical model. Emthe excitationby the hammer. This excitationis limited in
time and distributed over a certain width. It is assumed
that the force densityterm doesnot propagate along the string, so that the time and spacedependence can be separated,
phasis will nowbe put on the computational methods used for solving the equations, and the obtained algorithms will
be discussed.
II. TIME-DOMAIN
SIMULATIONS
(4)
A. String model
From a physicalpoint of view, it is clear that the dimensionless spatialwindowg(x,x o) accounts for the width of the hammer.Within the contextof numericalanalysis, it is interesting to notice that the use of such a smoothing
window eliminates the artifacts that occur in the solution
The equations of motion for the string and hammer presented in Sec.I are formulatedin discreteform using standardexplicitdifferences schemes centered in space and
time? Themain variable is thetransverse string displacement y(x,t) which is computedfor the discretepositions xi= i fix, and at discretetime stepstn= n At. Valuesof the hammerpositionr/(t) are computed, usingthe sametime grid and the sameincrementAt. In the following,the simplified notation,
y( x,t ) - y( xi,t,) -, y( i,n ),
will be used for convenience
(in the form of strongdiscontinuities), when the excitation is concentrated in a singlepoint. The density termfu(t) is relatedto the time historyof the forceFn(t) exerted by the hammeron the stringby the followingexpression:
(9)
wherethe lengthof the stringsegment interacting with the hammeris equalto 28x.
1114 d. Acoust.Soc. Am., VoL 95, No. 2, February1994
In a secondstage,the velocity and accelerationof the hammer, and of each discretepoint of the string, are derived from the correspondingdisplacementvalues by
means of finite differences centered in time. Finite differ-
1000
(b)
1oo
a2= [- 1+bAt+2b3/At]/D
(el
D= 1+bAt+2b3/At
lO
ences centered in space are usedfor computing the force transferred fromonesegment of the string to its adjacent segments. Thisgives, in particular, theforce Fa(t) exerted
by the stringon the bridge.The interaction forcebetween
(__ AH L E
100 1oo0 10o0o
lO
be confused with the intrinsicphysical dispersion due to the stiffness term in Eq. (1). As a resultof the grid dispersion, the eigenfrequencies of the stringand the inharmonicityare slightlyunderestimated for a givenstiffness parameter.Fortunately,this appliesprimarily to the frey(i,n+ 1) =a(i,n) +azv(i,n- 1) quency range just belowthe Nyquistfrequency (re/2). By usinga sufficiently high sampling rate so that the string +a3[Y(i+ l,n) + y(i- 1,n)] +a4[y(i+ 2,n) partials nearthe Nyquistfrequency contain no significant energy, the effects of this underestimation can be made +y(i- 2,n) ] +a 5[y(i+ l,n- 1) inaudible. Further, in orderto limit thedispersion asmuch +y(i-- 1,n-- 1) +y(i,n-2) ] as possible, N should be equalto the highest possible integervaluewhichis immediately lowerthanNraax. + [At2NFn(n)g(i, io) ]/Ms, (10) Usually,the actualsampling frequency fe, is determined by the audio equipment. Therefore, it wasdecided where thecoefficients a to a5 aregiven in TableI. to select, in this particular experiment, one of the standard Before starting thecomputation, an appropriate num(32, 44.1,and48 kHz) for theoutput sampling rate. ber (N) of spatialstepsmust be selected. For a standard values Figure 1 showsNm as a functionof the fundamental explicitfinite difference scheme, it hasbeenshowntheoret(f) of the string,at a sampling rateof fe48 icallythat thisselection is criticalfor stability andnumer- frequency values of the stiffness parameter. icaldispersion. 3 In practice, thestability condition pro- kHz for threedifferent for f shownin the figurecoverthe vides uswitha maximum number (Nmax) ofdiscrete string The threedecades rangeof a grandpiano.Noticethat Na is not directly segments, (i.e., with a minimum segment lengthAXmin) , dependent on the string length, but rather on the ratio assuming thatthe (dimensionless) stiffness parameter (e), thisparameter and the transverse wavevelocity. thefundamental frequency (f) of thestring, andthesam- between In practice, the computation will be madeat a lower pling frequency (re) aregiven. Thestability condition'ran be written as sampling rate (sayf,= 16 kHz) for notes with fundamental frequencybelow 100 Hz, in order to limit N to an Nma x={ [ -- 1+ ( 1+ 16e)1/2]/8E}1/2, ( 11) acceptable value.The synthesized signals will be then inwhere terpolated by a factor2 or 3 and'played backat a standard
renceequations where,for eachpointi, the variable under examination at a futuretime step(n + 1) is a function of the same variable at the same position i andat adjacent positions (i--2,i--l,i+l,i+2) at present and past time steps (n, n'--1,andn-- 2). Therecurrence equation for the transverse displacement of a dampedstiff stringcorresponding to Eq. (1), is givenby
FIG. 1. Maximumnumber of spatialsteps Nma x as a function of the fundamental frequency ft of thestringfor different values of thestiffness
y=fo/2f.
to
(12)
sampling rate.At theotherend,oversampling will benecessary for thehighest notes of theinstrument (typically for
truncation errorsmay appearin the solution for too small valuesof N. In this range,the computations were made with a sampling rate of 64 kHz, or even96 kHz for note C7, andthe signals wereplayed backafterlow-pass filter-
If thestiffness is neglected (e=0), thenEq. (11) reduces f greaterthan 1 kHz, i.e., for noteC6 and above),since
Nmax=y. (13)
ing and decimation. lem of numerical dispersion must alsobe taken into account.It hasbeenshown that someunwanted dispersive B. Modeling the initial and boundary conditions effects (grid dispersion) may be present in the solution if an explicit finitedifference scheme is used for solving the At timet=0 (n----O), the hammer velocity is assumed stiff string equation) This numerical dispersion should not to be equalto Vn0, and its displacement and the force
exerted on the stringare takenequalto zero.For the sake of simplicity,only the simplest case,where the stringis assumed to be at restat the originof time, will be presented below. Note, however,that the model can handleany initial condition.With the string at rest at t=0,
y(i,0) =0.
At time t=At given by (n=l),
0.5
Z -1 0
VVVVVVVVvlvvvvvvvvv
10 20 30
40 50 60
(14)
the hammer displacement is
ms
(15)
At that time, Eq. (10) generally cannotbe usedfor computing the stringdisplacement, sincefour time steps are involvedin the generalrecurrence equation. One solution, however, consists in assuming that the stringis at rest for the first threetime steps. Anothertechnique usedhere
FIG. 2. Illustrationof a repetitionof a note showingcomputed string displacement (at 40 mm from the hammer,bridgeside). First blow of hammerat t=0 with stringinitiallyat rest,followed by a repeated blow at t= 32 ms with stringin motion.
the worst cases.It was thereforedecidedto calculateonly the first estimate of the variables, in order to limit the
computational time. Once the valuesof the displacements are known for
(16)
F(1) =K I/(1)--y(i0,1)I p.
(17)
This enables us to compute a first estimate of the displacement y(i,2). In orderto limit the time and space dependence for n=2, a simplified version ofEq. (10) is used, wherethe stiffness and damping termsare neglected. This
yields
afterwhichtime the stringis left to freevibrations. In this case,Eq. (10) still applies, but the forceterm is temporarily removed. By furthercomparisons of stringandhammer displacements, the possibilityof hammer recontact
can be taken into account. This latter feature has been
y(i,2) =y(i-
+ [AI2NFn( 1)g(i,io)]/Ms.
(18)
(2)=2(I)--i(O)--[At2Fn(1)]/Mn,
and the hammer force is now written as
(19)
(20)
At this stage,one may ask if it is fully justifiedto compute the displacements in Eqs. (18) and (19) at time n=2 using the valueof the forceat time n= 1, i.e., with a timedelayequalto At. Thisfollows fromthe implicitform of Eq. (20), which requires thevalues of thedisplacements in order to computethe hammerforce. Normally,the effects of this approximation canbe neglected, provided thatthesampling frequency issufficiently high.In that case, only the high-frequency content of the synthesized signal will be affectedby the delay, and the influence on the computations will be small. An accurate
estimation of the effect can be obtained by iterating the
needto assume that the stringinitially is at rest.The force density termf(x,xo,t) canbeintroduced at anytimein the waveequation, whatever the vibrational stateof the string. Thus the model makes it possible to simulatenot only isolatedtones,but also a musicalfragmentwith realistic transitionsbetweennotes (see Fig. 2). In this case,repeatednotesare obtained by re-initializing the hammer positionto zero beforestrikingthe movingstring.This featureis not availablein today'scommercial synthesizers. As for the boundary conditions, the numerical expressionscorresponding to hingedendscasein Eq. (8) are straightforward and yield: y(0,n)=0
y(-
and y(N,n)=O,
and
(22)
(23)
1,n) = --y(1,n)
procedure described above, and calculating a second estimateof the displacements using Eq. (20), whichin turn
leads to a more accurate estimate of the hammer force.
frequency-dependent admittance,then the secondcondition in Eq. (23) can conveniently be replaced by the discrete form of the appropriatedifferentialequation.This refinementhas already been successfully applied to the
This procedure canbe repeated until no significant differences between successiveresults are observed. In our sim-
guitar?
The conditions givenin Eq. (23) are importantfor derivingspecific recurrence equations for the pointsi= 1
and i=N--1 which are closeto the string terminations. Due to the stiffness term, Eq. (1) is of the fourth-order in
A. Chaigne andA. Askenfelt: Simulations of piano string 1116
ulations, the algorithm converged rapidly,and the differences between the first and second estimates for
STRING,
1
BRIDGE
SIDE
STRING,
1
AGRAFFE SIDE
STRING
VELOCITY
o /"k
-i
-1
ms
10
ms
10
:3
-3 -3
d)l
5 ms 10 FORCE
ms
10
HAMMER
10
-1
0
3
ms 10
5
ms
10
FORCE AT THE
BRIDGE
o
-3 -5
/ .
ms 10
ms
10
FIG. 4. Simulated velocity profile of a piano string(C4) duringthefirst 4 msaftertheblow.Thetimestep between successive plots is62.5its.The stringterminations are indicated by A (agrafie)and B (bridge),and the
striking point by H (hammer).
mm from the hammer);(d) stringvelocity. Strikingpoint(e) string displacement, (f) stringvelocity.(g) hammer force.Bridge(h) force
transmitted to the bridge.
the damping coefficients b and b3 of the string,werederived from experimental data by means of standard curvefitting procedures.
space, andthusthe recurrence equation for the pointi will dependon the vibrationalstate of pointsi--2 to i+2. Therefore,it is necessary to know the valuesof the displacements y( -- 1,n) andy(N+ 1,n) in orderto compute
the solution at i= 1 and i=N-1, respectively. Because i= - 1andi=N+ 1donotbelong to the"physical" string, Eq. (23) mustbe usedfor replacing y(- 1,n) and y(N
+ 1,n) by expressions involving only the values of the displacements for i withinthe interval[0,N].
Ill. STRUCTURE
COMPUTER
AND PERFORMANCE
OF THE
PROGRAM
The simulationprogram is written in Turbo-Pascal, and runson a 80486based Personal Computer DEC station 425 PC677-A3.At a clockspeed of 25 MHz, it takes about100s to obtain1 s of sound at a sampling frequency of 32 kHz, with the stringdividedinto N= 100 spatial steps. This valueis a typicalorderof magnitude for the computing time, although it may vary slightlyfrom one
string to the other.
The main part of the programholdsthe modelof the string motion, described in theprevious section. Thispart
is linked with data files which contain the values of the
hammer and stringparameters actuallyusedin the simulations. Some of the parameters weremeasured by the authors,while otherswereextractedfrom the literature. 9'15'17
In its standard executable version, the programstarts with an interaction with the user,requesting the sampling frequency (in kHz), the fundamental frequency (in Hz), and the durationof the computed note (in s). This enables the programto compute the number(N) of spatialsteps, usingEqs. ( 11)-(13). This procedure is followedby the computation of thefirstthreetimesteps (n =0 to n=2), as described in the previous section, usingEqs. (14)-(20). Then,therecurrence parameters of thedamped stiffstring givenin Table I are calculated oncefor all. For n3, the programcomputes the hammerforceF(n), stringdisplacement y(i,n), andhammer displacement, /(n), in parallel. If the condition in Eq. (21) is met, the forceterm is removedfrom the recurrence scheme in Eq. (10) before the computations proceed. At eachtimestep, theprogram canprovide a complete setof signals, adding four variables--v(i,n), the stringvelocityat eachpointof the string, FB(n), the forceexerted by the stringon the bridge,vu(n), hammervelocity, and art(n) hammer acceleration--to y( i,n), l( n), andF( n), which are the three principalvariables in the computations.Examples of waveforms generated by the modelfor note C4 are shownin Fig. 3. A greatadvantage of using a finitedifference methodis that eachphysical quantity(displacement, velocity, force) isdirectly available for all discrete points at each timestep. In this way, it becomes straightforward to plot the stateof the stringat successive instants, in orderto obtaina viewof the wavepropagation alongthe string.This featureis illustrated in Fig. 4, whichshows the velocity profile of a C4 string during the first 4 ms after the blow of the hammer.
ment of SpeechCommunication and Music Acoustics, Royal Institute of Technology (KTH), Stockholm,with financialsupportfrom Centre National de la Recherche Scientifique (CNRS). The projectwas further supported by the Swedish Natural Science Research Council(NFR),
the Swedish Council for Research in the Humanities and
The numerical modelpresented in this paperhas interestingfeatures,which allow a simulationof a piano string very closelyto the basic physicalrelations.The methodis time efficient, and the numerical advantages and limitationshavebeenthoroughly investigated and are well documented. The first examples and comparisons with measurements indicate that the model generateswaveforms and spectrawhich closelyresemble the signals observedin real pianos.Althoughall detailsin the design of the pianostill are not modeled asrealistically asdesired(in particular the boundaryconditions),we considerthe model to be a promisingtool for exploringthe spaceof string-hammerparameters and their influenceon piano
tone.
"G. Weinreieh, "Coupled piano strings," J. Aeoust. Soc. Am.62, 14741484 (1977).
ACKNOWLEDGMENTS