Content uploaded by Maarten Van Walstijn
Author content
All content in this area was uploaded by Maarten Van Walstijn on Sep 13, 2023
Content may be subject to copyright.
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
TUNABLE COLLISIONS: HAMMER-STRING SIMULATION
WITH TIME-VARIANT PARAMETERS
Maarten van Walstijn and Abhiram Bhanuprakash
SARC
Queen’s University Belfast
Belfast, UK
m.vanwalstijn|abhanuprakash01@qub.ac.uk
Vasileios Chatziioannou
Department of Music Acoustics (IWK)
University of Music and Performing Arts
Vienna, Austria
chatziioannou@mdw.ac.at
ABSTRACT
In physical modelling synthesis, articulation and tuning are ef-
fected via time-variation in one or more parameters. Adopting
hammered strings as a test case, this paper develops extended forms
of such control, proposing a numerical formulation that affords on-
line adjustment of each of its scaled-form parameters, including
those featuring in the one-sided power law for modelling hammer-
string collisions. Starting from a modally-expanded representation
of the string, an explicit scheme is constructed based on quadratis-
ing the contact energy. Compared to the case of time-invariant
contact parameters, updating the scheme’s state variables relies on
the evaluation of two additional analytic partial derivatives of the
auxiliary variable. A numerical energy balance is derived and the
numerical contact force is shown to be strictly non-adhesive. Ex-
ample results with time-variant tension and time-variant contact
stiffness are detailed, and real-time viability is demonstrated.
1. INTRODUCTION
The manipulation of variables is intrinsic to musical instrument
performance. For example, to produce a specific sound with a vi-
olin the musician controls the speed, normal force, and angle of
the bow as well as the position of fingers that press the string to
the fingerboard. In hammered string instruments, which is the tar-
get of the current study, such articulation is normally restricted to
the acceleration of keys that drive the hammer motion and the ad-
justment of tension during the tuning process, although in certain
instrument families, such as dulcimers, the striking position on the
string can also be varied.
In musical instrument modelling, articulation and tuning are
accomplished through variation over time of the relevant physical
parameters. This is exploited in physics-based synthesis for the ex-
ploration of the sound of acoustic instruments (of both existing and
modular design) across their parameter spaces [1]. Recently, spe-
cific attention has been given to on-line tuning of parameters that
are normally considered to remain constant [2, 3]. To contribute
towards facilitating such extended synthesis control, this paper sets
out to numerically model the interaction between a hammer and a
stiff string under time-variance of a non-redundant set of model
parameters. For the resulting algorithm to be of practical use, it
should be computationally efficient, numerically stable, and free
of audible artefacts. In addition, the response to driving forces
Copyright: © 2023 Maarten van Walstijn et al. This is an open-access article dis-
tributed under the terms of the Creative Commons Attribution 4.0 International Li-
cense, which permits unrestricted use, distribution, adaptation, and reproduction in
any medium, provided the original author and source are credited.
and parameter manipulations should ideally be similar to what can
be expected in that regard from the underlying physical laws, and
parameter time-variance should not necessarily lead to large am-
plitude swings in the chosen output signal.
Solutions to various similar and related problems can be found
across the literature. Most notably, simulation of string vibrations
under time-varying tension (or an equivalent string length adjust-
ment) has been reported using digital waveguides [4], mass-spring-
damper systems [5], finite-difference methods [3], and modal syn-
thesis [6]. The challenge increases when nonlinearities are intro-
duced, perhaps most tellingly so when one-sided forces are in-
volved. For example, models in which a finger or other object
can be dynamically brought in contact with a string while also its
position along the string axis can be varied over time (e.g. [7, 8])
typically rely on an iterative solver to update the state variables,
which severely reduces the scope for parallelisation and real-time
implementation [9]. Similarly, in [2] all 29 parameters of a modal-
form string-bridge-plate model with nonlinear spring connections
were made tunable, but the use of an iterative solver meant that
for real-time audio rendering the parameter space and the rate of
change in parameters had to be empirically constrained to avoid
instability issues and artefacts. In [10] this issue was side-stepped
by casting the update equations in analytic form, but so far this
has been made to work only for a small subset of cases in which a
unity contact power law exponent applies.
Originating separately in Port-Hamiltonian form [11], the re-
cent emergence of energy quadratisation approaches, including the
Invariant Energy Quadratisation (IEQ) method [12] and the Scalar
Auxiliary Variable (SAV) method [13], has paved the way for nu-
merical simulation of nonlinear musical instruments vibrations with-
out the use of iterative solvers [14, 15], with specific scheme vari-
ants introduced for modelling collisions [16, 17]. The current pa-
per extends energy quadratisation to modelling lumped conserva-
tive nonlinearities under parameter time-variance, taking hammer-
string interaction as a case study. For completeness, additional
innovations that improve the handling of tension time-variance in
modal-form algorithms are introduced.
The paper is structured as follows. The hammer-string system
equations are outlined in Section 2, including a scaled form that is
modally expanded. The discretisation of the resulting equations is
presented in Section 3, with the update equations provided and also
featuring analyses of the key properties of the resulting algorithm.
The proposed formulation is then explored, exemplified, and tested
in Section 4 via a number of numerical experiments, followed by
concluding remarks in Section 5. Sound examples are available on
the accompanying github page1.
1https://github.com/mvanwalstijn/Tunable-Collisions
DAFx.1
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
2. HAMMER-STRING MODEL
In the following, ∂tyand ∂xydenote the partial derivatives with
respect to time tand string axis position x, respectively, and the to-
tal time derivative is written as dty. Considering a string of length
L, mass density ρ, cross section A, Young’s modulus E, moment
of inertia Iinteracting with a hammer of mass mhstriking from
above, the equations governing the transversal string displacement
u=u(x, t)and hammer position uh=uh(t)can be written as
[18]:
ρA∂2
tu=T ∂2
xu−EI ∂4
xu+θ(x)Fc,(1)
dtmhdtuh=Fe−Fc.(2)
The driving of the hammer is represented here with the excitation
force Fe=Fe(t), the specific form of which depends on the type
of instrument. For example, a simplified form of modelling Np
successive piano hammer strikes at time instants t=τlis:
Fe(t) =
Np
X
l=1
mhVe,l
| {z }
pe,l
δ(t−τl) + Fstop,l(t),(3)
where Ve,l <0is an externally supplied hammer velocity param-
eter. In the absence of gravity, we emulate the hammer coming to
rest at uh=umax after bouncing back from the string, which is
represented in (3) by the forces Fstop,l(t)<0; in practice, one
may achieve this by simply capping the hammer displacement at
uh=umax. Modelling the driving of the hammer in dulcimers or
clavichords would require different formulations of Fe(t).
The contact force in (1,2) is assumed to be non-hysteretic un-
der parameter constancy, and is defined with a power-law:
Fc=−κ[y]α
+
≤0,(4)
where [y(t)]
+
= max(0, us(t)−uh(t)) is the effective inter-object
compression. For simplicity, the contact force is applied at a single
point, using θ(x) = δ(x−xh). Correspondingly, the displacement
of the string as ‘seen’ by the hammer is us(t) = u(xh, t). Simply
supported boundary conditions are assumed:
u(0, t) = ∂2
xu(0, t) = 0, u(L, t) = ∂2
xu(L, t) = 0,(5)
and initial conditions are set as
uh(0) = umax, dtuh(0) = 0, u(x, 0) = 0, ∂tu(0, x) = 0.
(6)
As in previous studies (e.g. [10]), the force at the end of the string
is chosen as an appropriate output variable:
Fs(t) = −T ∂xu(L, t) + EI ∂3
xu(L, t).(7)
2.1. Scaled Form
The parameters ρ,A, and Lare considered to remain constant over
time. To obtain a form of the system equations with fewer param-
eters, the following non-dimensional variables are introduced:
¯x=x
L,¯u=u
L,¯uh=uh
L.(8)
Then, after substitution, the system can be written as
∂2
t¯u=¯
T∂2
¯x¯u−π−2B∂4
¯x¯u+¯
θ(¯x)¯
Fc,(9)
dt¯mhdt¯uh=¯
Fe−¯
Fc,(10)
Scaled-Form H-S Model DAC
Gout
7
Fe
7
Fs
7mh7xhK,
6
f1B20212223
Figure 1: Schematic diagram of the scaled-form hammer-string
model.
where
¯
Fc= ¯κ¯y
z }| {
¯us−¯uhα
+
,¯
Fe=
Np
X
l
¯pe,l
z }| {
pe,l
ρAL2δ(t−τl),(11)
¯mh=mh
ρAL ,¯
T=T
ρAL2,B=EI π2
T L2,(12)
¯κ=κLα−2
ρA ,¯xh=xh
L,¯
θ(¯x) = δ( ¯x−¯xh).(13)
The new parameter Bis the inharmonicity factor [19], ¯mhis the
hammer/string mass ratio, and ¯us(t) = ¯u(¯xh, t). Analogously, we
may define
¯
Fs(t) = Fs
ρAL2=¯
Tπ−2B∂3
¯x−∂¯x¯u(1, t).(14)
2.2. Energy Quadratisation
The scaled-form contact force in (11) can be expressed as:
¯
Fc=−∂¯y¯
Φ,¯
Φ(¯y) = ¯κ
α+ 1 [ ¯y]α+1
+
,(15)
where the actual contact potential Φ(in Joules) relates to its scaled-
form counterpart as Φ = ρAL3¯
Φ. Taking a split-potential energy
quadratisation approach [15], the scaled-form contact potential is
written in quadratic form with ¯
Φ = 1
2ψ2. Making use of the chain
rule, this allows writing the contact force as
¯
Fc=−ψ
g¯y
z}|{
∂¯yψ=−ψdtψ−dt¯κ
g¯κ
z}|{
∂¯κψ−dtα
gα
z}|{
∂αψ
dt¯y.(16)
Defining the auxiliary variable ψas the positive square root of 2¯
Φ,
the gradient variables g¯y,gα, and g¯κcan be expressed directly as
functions of ¯y,α, and ¯κas follows:
g¯y=q1
2¯κ(α+ 1) [ ¯y]α−1
+
, g¯κ=s[y]α+1
+
2¯κ(α+ 1) (17)
gα=s1
2¯κ[¯y]α+1
+
α+ 1 log [¯y]
+
+ε−1
α+ 1,(18)
where a positive constant of the size of the machine epsilon has
been included within the log term in (18) for handling the case
where [¯y]
+
approaches zero. Following similar principles as ap-
plied in IEQ and SAV methods, the numerical scheme will be con-
structed in explicit form by directly discretising the equations con-
tained within (16) and making use of the analytic expressions in
(17,18) to evaluate the gradient variables. A novel aspect is the
emergence of the additional gradient terms gαand g¯κdue to time
variance in the power law parameters. It is worth noting that if ψis
defined as −√2¯
Φ, for consistency the terms g¯y,g¯κand gαwould
also have to have a minus sign in front of the square root symbol.
DAFx.2
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
2.3. Parameter Control
Figure 1 shows the inputs and outputs of the scaled-form model.
The output gain Gout is needed to scale ¯
Fsto the [−1,1] input
range of the digital-to-analog converter. Each of the ten control
parameters in Figure 1 is considered to be adjustable on the fly, and
as such is treated as time-dependent. Four of those parameters (B,
¯mh,¯xh, and α) readily appear in the scaled-form model equations
(9-13). The parameters η0,1,2,3are damping coefficients that will
be introduced in Section 2.4. This subsection explains how the
remaining two parameters ( ˘
f1,K) are related to the scaled-form
model parameters. The tension parameter ( ¯
T) can be calculated
directly from the string’s fundamental frequency ˘
f1(in Hz) in the
absence of stiffness as ¯
T= 4 ˘
f2
1. To enable independent control
of the effective stiffness (through K) and the ‘contact nonlinearity’
(through α), ¯κhas been re-parameterised as follows:
¯κ= (α+ 1)KK
¯
Φrα
.(19)
where ¯
Φrdenotes a (constant-over-time) scaled-form reference po-
tential that represents the amount of contact energy that can ap-
proximately be expected2. This is exemplified in Figure 2. Exam-
ple values for the control parameters, which were transcribed from
[20], are listed in Table 1. Where needed, the string constants ρA
and Lare used for un-scaling displacements, forces, or energies,
but they do not otherwise feature within the scaled-form model
that forms the basis for numerical simulation.
7y
7
)
(a)
,= 1
,= 2
,= 4
7y
7
)
(b)
K=1
2Kr
K=Kr
K= 2Kr
Figure 2: Contact potential curves for (a): a range of αvalues
with K=Krand (b): a range of Kvalues and α= 2. In both
subfigures, the horizontal dashed line indicates the scaled-form
reference potential (¯
Φr).
2.4. Modal Expansion
For the boundary conditions in (5), we may expand the string dis-
placement as
¯u(¯x, t) =
M
X
i=1
√2 sin(iπ¯x(t))
| {z }
vi(¯x(t)) eui(t) = [v(¯x)]Tu,(20)
where vi(¯x(t)) and eui(t)are the modal shape function and the
modal displacement for the ith mode, and v(¯x)and uare the
respective column vector representations (with time dependence
dropped in the notation). Substituting (20) into (9), multiplying
with the basis functions, and spatially integrating from ¯x= 0 to
2The Kvalues in Table 1 have been transcribed using ¯
Φr≈0.75/L2,
which is a representative value of the average piano key, derived from set-
ting the unscaled version Φrequal to the kinetic energy of a hammer with
¯mh= 0.75 and dtuh=−1.41 m/s.
Table 1: Scaled-form model parameter values (transcribed from [20]).
piano C2 piano C4 piano C7
˘
f1[Hz] 65.4 262 2093
B7.4×10−53.77 ×10−48.6×10−3
η0[s−1] 0.5 0.5 0.5
η1[s−1] 0.01 0.01 0.1
η2[s−1] 0.0 0.0 0.0
η3[s−1] 10−610−610−4
¯mh0.14 0.75 4.71
K[s−2] 335 2560 4.3×104
α2.3 2.5 3.0
¯xh0.12 0.12 0.0625
ρA [kg m−1] 18.4×10−36.3×10−35.2×10−3
L[m] 1.90 0.62 0.09
¯x= 1 then leads to a set of coupled ordinary differential equations
which may be expressed in vector form as
d2
tu+Rdtu+Ku =h¯
Fc,(21)
where h=v(¯xh)and Kis an M×Mdiagonal matrix with the
non-zero elements
Ki,i =i2π2¯
T1 + Bi2.(22)
Initally, since there is no string damping in (9), the M×Mdamp-
ing matrix Rcontains only zeros. String damping can be intro-
duced in polynomial form by setting the diagonal elements of R
to:
Ri,i = 2 η0+η1iπ +η2i2π2+η3i3π3.(23)
Of particular relevance is the case where η2= 0, which can be
shown (see [2]) to align well with the experimentally validated
damping formulation by Woodhouse [21]. The ith mode frequency
for free vibration (i.e. e
Fi= 0) then is
ωi=qKi,i −1
4R2
i,i,(24)
which takes on an imaginary value in case of overdamping. In
modal form, the string displacement at the contact point can be
written as us=hTu, and the string force in (14) becomes
¯
Fs(t) = −
M
X
i=1
iπ ¯
T(t)1 + B(t)i2(−1)i
| {z }
wi(t)eui(t) = −wTu.
(25)
The direct dependence of wion ¯
Tcan lead to large swings in the
output amplitude when time-varying the string tension. The need
for output gain adjustments can be significantly reduced by replac-
ing wi(t)with the adjusted output weights ˙wi(t) = q¯
T(0)
¯
T(t)wi(t).
2.5. Energy Balance and Conserved Quantities
An energy balance equation can be obtained by pre-multiplying
(21) with (dtu)T, multipling (10) with dt¯uh, and adding the re-
sulting equations, yielding
dt¯
H=1
2uT(dtK)u−(dtu)TRdtu−(dth)Tu¯
Fc+dt¯uh¯
Fe
−(dt¯uh)2dt¯mh+ψ(g¯κdt¯κ+gαdtα),(26)
in which the scaled-form Hamiltonian ¯
Htakes the form :
¯
H=(dtu)Tdtu
2+uTKu
2+¯mh(dt¯uh)2
2+ψ2
2≥0.(27)
DAFx.3
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
From (10) and (26), it is immediately clear that the scaled-form
hammer momentum ¯ph= ¯mhdt¯uhand system Hamiltonian ¯
H
are conserved under specific conditions:
dt¯ph= 0 if ¯
Fe,¯
Fc= 0,(28)
dt¯
H= 0 if ¯
Fe, η0, η1, η2, η3= 0,
∂t¯
T , ∂tB, ∂t¯mh, ∂t¯κ, ∂tα, ∂t¯xh= 0.(29)
The numerical scheme will be constructed such that the discrete
counterparts of ¯
Hand ¯phare conserved under the same conditions.
3. NUMERICAL FORMULATION
3.1. Difference and Averaging Operators
The numerical model will evaluate variables and parameters at
discrete-time instants tn=n∆t. The usual form unis employed
to denote the approximation to uat time t=n∆t. The following
shift operators are defined:
ϵt
+
un=un
+
1
2, ϵt
−
un=un
−
1
2.(30)
Elemental temporal difference and averaging operators can then be
constructed as
δt=ϵt
+
−ϵt
−
∆t
, µt=ϵt
+
+ϵt
−
2, δt·=ϵ2
t
+
−ϵ2
t
−
2∆t
,(31)
δt+=ϵ2
t
+
−1
∆t
, δt−=1−ϵ2
t
−
∆t
µt·=ϵ2
t
+
+ϵ2
t
−
2.(32)
where we can identify several equivalences (e.g. δt·=δtµt).
Finite-difference approximations are achieved by either combin-
ing or directly applying these elemental operators, e.g.
δ2
tun=un+1 −2un+un−1
∆2
t
=∂2
tu(n∆t) + O(∆2
t),(33)
µ2
tun=un+1 + 2un+un−1
4=u(n∆t) + O(∆2
t),(34)
δt·un=un+1 −un−1
2∆t
=∂tu(n∆t) + O(∆2
t).(35)
The following product identities can be derived for arbitrary grid
functions un,qn:
δt(δtun)2= 2δt·unδ2
tun
, δt(µtun)2= 2δt·unµ2
tun
,(36)
δt{µtqnδtun}δtun=1
2δtµtqn(δtun)2+δt·qnδt
+
unδt
−
un
,
(37)
which is useful for the purposes of numerical energy analysis.
3.2. Discretisation
Let unbe a column vector holding the modal displacements eun
i,
i= 1,2,··· M. The size of this vector (i.e. M) will not be varied
on-line. Taking into account the need to avoid both numerical dis-
persion and mode aliasing, the mode dynamics in (21) with time-
varying parameters can be discretised in vector form as follows:
δ2
tun+b
Rnδt·un+µ2
tb
Knµ2
tun=¯
Fn
cµt·hn,(38)
where the non-zero elements of the adjusted diagonal matrices b
Rn
and b
Knare
0 10 20 30 40
!(kHz)
0
5
10
15
20
F(!) (kHz)
0 5 10 15 20
!(kHz)
0
0.5
1
W(!)
Figure 3: The mode frequency soft-clipping function F(ω)(left)
and the suppression weight function W(ω)(right) for ∆t=
1/44100. The dashed line indicates the Nyquist frequency
(π/∆t), and the dotted line represents the cut-off frequency (ωa).
b
Rn
i,i =2bn
i
∆t
,b
Kn
i,i =4
∆2
t
an
i.(39)
The real-valued coefficients in (39) are:
an
i=
1−Υn
+
,i + Υn
−
,i+ Υn
+
,iΥn
−
,i
1 + Υn
+
,i + Υn
−
,i+ Υn
+
,iΥn
−
,i
,(40)
bn
i=2−2Υn
+
,iΥn
−
,i
1 + Υn
+
,i + Υn
−
,i+ Υn
+
,iΥn
−
,i
,(41)
featuring the complex-conjugate pair
Υn
±,i = exp ±jF(ωn
i)∆t−1
2Rn
i,i∆t,(42)
where j = √−1and
F(ω) = ω:ω2< ω2
a
ζarctan[ζ−1(ω−ωa)] + ωa: otherwise (43)
is a function that ‘soft-clips’ the mode frequencies (see the plot on
the left-hand side of Figure 3), as such preventing aliased mode
frequencies. Here ωais an appropriate ‘cut-off frequency’ chosen
below the Nyquist frequency (ωa= 0.9π/∆tis used throughout
the paper), and ζ= 2/∆t−2ωa/π. Since the ‘out-of-range’
modes will have incorrect resonance frequencies, they need to be
suppressed in the calculation of both ¯usand ¯
Fs. This can be
achieved by calculating the elements of the vectors hnand wnas
hn
i=W(ωn
i)·vi(¯xn
h)and wn
i=W(ωn
i)·wi(n∆t), respectively,
where W(ω)is a smooth weight function
W(ω) = 1
1 + [Re(ω)/ωa]200 ,(44)
which strongly suppresses frequencies larger than ωa(see the plot
on the right-hand side of Figure 3). Using (24), it can be shown
that |Υn
±,i| ≤ 1for both under- and over-damped modes. It fol-
lows from (40,41) that an
i≥0and bn
i≥0, meaning that the di-
agonal elements of b
Rnand b
Knare guaranteed non-negative. For
constancy in the mode frequencies ωn
i, the above discretisation re-
sults into a scheme free of numerical dispersion and attenuation,
similarly to the modal-form schemes proposed in previous studies
[22, 2]. Expanding (38), one may derive the update form
un+1 =un−1+Cnµt·hn¯
Fn
c−2zn,(45)
with
zn=1
2hBnun−1−Anuni,(46)
DAFx.4
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
where the elements of the diagonal matrices An,Bn, and Cnare:
An
i,i =2−2µ2
tan
i
1 + µ2
tan
i+µ2
tbn
i
,(47)
Bn
i,i =2 + 2µ2
tan
i
1 + µ2
tan
i+µ2
tbn
i
,(48)
Cn
i,i =∆2
t
1 + µ2
tan
i+µ2
tbn
i
.(49)
The hammer dynamics in (10) are discretised with:
δtµt¯mn
hδt¯un
h=¯
Fn
e−¯
Fn
c.(50)
Setting ξn
h= ∆2
t/µt¯mn
+
1
2
hand γn=µt¯mn
−
1
2
h/µt¯mn
+
1
2
h, this can
be written as
¯un+1
h= ¯un−1
h−ξn
h¯
Fn
c−2zn
h,(51)
where
zn
h=1
2(1 + γn)¯un−1
h−¯un
h−1
2ξn
h¯
Fn
e.(52)
By pre-multiplying (45) with (hn)Tand subtracting (50), the fol-
lowing scalar equation is obtained:
¯yn+1
−¯yn−1
| {z }
sn
=h(hn)TCnµt·hn+ξn
hi
| {z }
ξn
¯
Fn
c−2h(hn)Tzn
−zn
hi
| {z }
zn
.
(53)
The contact force ¯
Fn
cas written in quadratised form in (16) is dis-
cretised with:
¯
Fn
c=−(µtψn)·gn
¯y,δtψn−gn
¯κδt·¯κn−gn
αδt·αn
δt·¯yn=gn
¯y,
(54)
where we can substitute 2∆tδt·¯yn=sn. From the second equa-
tion, a separate update of the auxiliary variable is found as
ψn
+
1
2=ψn
−
1
2+1
2gn
¯ysn+1
2gn
¯κ(¯κn
+
1
−¯κn
−
1)+ gn
α(αn
+
1
−αn
−
1)
| {z }
χn
.
(55)
Substituting the first equation in (54) into (53) we then can, making
use of (55), obtain the explicit solution
sn=−
2zn+ξnψn
−
1
2+1
2χngn
¯y
1 + 1
4ξn(gn
¯y)2,(56)
where it is seen that the denominator in (56) is guaranteed posi-
tive, hence solution existence is ensured. Under the assumption
that the auxiliary variable remains non-negative during simulation,
the gradient variables gn
¯κand gn
αcan be calculated directly as per
equations (17,18). The remaining gradient variable gn
¯ythen has to
be constrained such that ψn
+
1
2≥0, which in the time-variant case
translates to satisfying the quadratic inequality
1
4ψn
−
1
2ξn(gn
¯y)2+zngn
¯y−ψn
−
1
2+χn≤0.(57)
This leads to the evaluation of gn
¯yin branched form as given in
the Appendix. Once snhas been calculated, the auxiliary variable
is updated with (55). The [.]
+
operator is subsequently applied to
ensure that the value of ψn
+
1
2does not become ever so slightly
negative due to finite-precision errors. Next, the contact force ¯
Fn
c
is calculated with (54), after which the state variables uand uh
can be updated with (45) and (50), respectively. Finally, the output
signal is calculated with ¯
Fn
s= (wn)Tun. Note that the matrices
ˆ
Knand ˆ
Rnare not calculated within the algorithm; this is needed
only in instances where one wants to track the evolution of the
system energy. The update of the modal displacements requires
only the elements expressed in (47-49).
3.3. Non-Adhesive Contact Force
For the explicit scheme presented above, guaranteed non-adhesion
can be shown starting from the inequality ψn
+
1
2≥0for all n,
from which it follows that µtψn≥0. From (61) we have that
`gn
¯y≥0by definition. Further, given that the numerator of (62) is
non-negative, it follows that ˙gn
¯y≥0. Seen together with (60) this
means that gn
¯y≥0, and therefore that ¯
Fn
c=−µtψngn
¯y≤0.
3.4. Energy Balance and Conserved Quantities
From (50) it is immediately clear that the numerical hammer mo-
mentum ¯pn
+
1
2
h=µt¯mn
+
1
2
hδt¯un
+
1
2
his conserved when no forces act
upon the hammer. A discrete energy balance can be derived by
pre-multiplying (38) with (δt·un)T, (50) with δt·un
hand adding
the resulting equations:
δt¯
Hn=1
4(µtun
+
1
2)Tδt·b
Knµtun
+
1
2+1
4(µtun
−
1
2)Tδt·b
Knµtun
−
1
2
−(δt·un)Tb
Rnδt·un+δt·¯un
h¯
Fn
e−δt·¯mn
hδt
+
¯un
hδt
−
¯un
h
−¯
Fn
c(δt·hn)T
µt·un+µtψn(gn
¯κδt·¯κn+gn
αδt·αn),(58)
¯
Hn
+
1
2=1
2(δtun
+
1
2)Tδtun
+
1
2+1
2(µtun
+
1
2)Tµtb
Kn
+
1
2µtun
+
1
2
+1
2µt¯mn
+
1
2
h(δt¯un
+
1
2
h)2+1
2(ψn
+
1
2)2≥0.(59)
Here we made use of the product identities in (36-37). It follows
directly that the numerical energy ¯
Hn
+
1
2is conserved for constant
parameters and no damping or external force. Further, the terms on
both sides of (58) are consistent approximations to the correspond-
ing terms in (26), so we can expect the simulation to exhibit en-
ergy behaviour under parameter time-variance that approximates
that of the underlying continuous-domain model (see Figure 6 for
a numerical verification).
3.5. Blockwise Parameter Updates & Linear Interpolation
Under the assumption that the control parameters vary over time
relatively slowly, they can be updated every Nbsamples, such that
the control rate is Nbtimes lower than the audio sampling rate,
in which case the parameter signals are assumed to be bandlim-
ited in the sense of containing no frequency components above
f= 1/(2Nb∆t). Given that one round of updating of the model
parameters is computationally more expensive than one time step
of updating the state variables, such a blockwise parameter update
form yields significant computational savings. To alleviate audible
artefacts, the following parameters and coefficients are linearly in-
terpolated over each block, at very low cost: ¯mh,¯κ,α,hi,ai,bi.
The coefficients ξhand γhas well as the diagonals of A,B, and
Care updated at each time step using the aforementioned linearly-
interpolated values.
DAFx.5
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
4. NUMERICAL EXPERIMENTS
4.1. Contact Force Signals with Static Parameters
Before exploring parameter time-variance, we first verify the cor-
rectness of the algorithm and its implementation for the case of
constant parameters. Figure 4 shows the contact force signal for
three hammer striking velocities, using a standard audio rate (i.e.
∆t= 1/44100 s). The resulting waveforms are similar to those
obtained in previous studies (e.g. [20]).
1 2 3 4 5 6 7 8 9 10 11
time (ms)
0
5
10
15
!Fc(N)
7pe=!3:5 s!1[dtuh=!2:89 m/s]
7pe=!1:4 s!1[dtuh=!1:16 m/s]
7pe=!0:8 s!1[dtuh=!0:66 m/s]
Figure 4: Contact force signals for a C4 string with static param-
eters. For each hammer velocity, the black dashed line indicates
the exact solution as approximated with 24 times oversampling.
4.2. String Tuning
Of special interest is the behaviour of the algorithm under time-
varying tension, because this involves string modes moving out of
and into the normal frequency range of interest. Figure 5 shows
the amplitude normalised spectrograms of four simulation output
signals. In each simulation, the string was excited with a hard
hammer (K= 100000 s−2,α= 1.2) at t= 0.2s, and the pa-
rameter ˘
f1was subsequently increased upwards in a linear fashion
by a factor of 1.5, and then linearly decreased back to its origi-
nal value. The time step is ∆t= 1/(OF ·44100) s, where OF
is the oversampling factor. The top left plot, obtained with two
times oversampling, can be considered as the nominally correct
result. For wider comparison we also include the result obtained
with the dynamic grid model [3], for which Nb= 1. Visible in
the top right plot (Nb= 1) is the suppression of the out-of-range
modes according to the weight function W(ω). High-frequency
artefacts appear with Nb= 128 (bottom left plot), but these are
generally more than 60 dB below the level of the partial tones, and
as such barely or not audible. A noticeable difference with the
FD dynamic grid result is that the mode frequencies evolve in a
more regular fashion, and as such the proposed methodology does
not rely on frequency-dependent damping and/or oversampling to
mask audible artefacts. Secondly, with the modal-form algorithm
the modes that drift out of range when the tension increases are
‘pulled back’ into range once the tension is reduced.
4.3. Energy and Output Amplitude
A similar experiment is conducted here, this time with no string
damping, to investigate the behavour of the output amplitude and
the numerical energy under time-varying tension. Figure 6(b) shows
the output signal as calculated with wiand ˙wi, respectively, con-
firming that the use of adjusted output weights helps reducing out-
put amplitude swings. Figure 6(c) compares the corresponding nu-
merical energy evolution as calculated with oversampling factors
Figure 5: Spectral evolution of the string force signal under time-
varying tension. The model parameters are ˘
f1= 1000 Hz, B=
2.55×10−6,η0= 0.5s−1,η1= 0 s−1,η2= 0.0001 s−1,η3= 0
s−1,¯mh= 0.3,¯xh= 1/23.
OF = 1 and OF = 24, in both cases using M= 60. The close-
ness of these two curves demonstrates that the numerical energy
balance remains approximately correct in the presence of mode-
frequency soft-clipping (which occurs only for OF = 1 here) and
other approximation errors.
4.4. Time-Varying Contact Parameters
Among less conventional forms of parameter time-variance, the
terrain of on-the-fly adjustment of the contact parameters seems
particularly uncharted. To investigate how the algorithm handles
such time-variance, single hammer-string collisions were simu-
lated in which the effective stiffness parameter Kwas set to either
rapidly increase (see the left-hand side plots of Figure 7) or rapidly
decrease (see the right-hand side plots of Figure 7) during contact.
As can be seen in the bottom plots, time-variance in Kleads to
hysteresis in the force-vs-compression curve. For increasing K,
the hysteresis is ‘inverted’ (i.e. in the opposite direction to what is
normally observed with hysteresis in piano hammers due to loss
mechanisms). The main take-away from these results is that fast
time-variance in K– and indeed in α, which was also tested but
not shown here – can be simulated without artefacts.
4.5. Computational Efficiency
To asses the viability of real-time implementation, the real-time
factor (RTF), which is defined here as a measure of how much real
time passes with the computation of one second of audio output,
was recorded for a range of Nband Mvalues. The piano C2 pa-
DAFx.6
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
500
1000
6
f1(Hz)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-40
-20
0
20
40
Fstr (N)
contact wi
_wi
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time (s)
0
10
20
H(J)
hammer
pulse hammer
stop OF = 1
OF = 24
Figure 6: Simulation with time-varying tension and no damping.
Top: fundamental frequency profile. Middle: output waveforms
for OF = 1. Bottom: system energy. The parameters are those for
a piano C4 string, with ∆t= 1/(OF ·44100) s and Nb= 32.
rameters listed in Table 1 were used in the simulations, applying
regular hammering with randomised hammer velocities across 0.5
s simulation time. For each set (Nb,M), the RTF was calculated
as an average over 50 simulations. The computations were per-
formed in Matlab on an Intel i7-6700 CPU. As can be seen from
the results presented in Figure 8, the RTF remains below 0.75 for
block sizes of 32 and above with up to 1000 string modes. For ref-
erence, the number of modes needed to cover the audio range for
an A0, which is the lowest key on standard pianos, is about 300.
Because of the uncoupled structure of the modal update form, sig-
nificant efficiency gains compared to Matlab implementations can
be made utilising parallel processing methods in optimised C++
implementations. Examples include the use of Advanced Vector
Extensions (see, e.g. [2]).
5. CONCLUSION
A numerical scheme for simulating hammer-string interaction with
time-varying parameters has been formulated in modal form. As
part of adapting the energy quadratisation approach to modelling
collisions under parameter time variance, two new gradient vari-
ables were introduced. The physical correctness of the algorithm
is underpinned by the numerical contact force being provably non-
adhesive and by the existence of a numerical energy balance, the
form of which directly mirrors that of the continuous-domain model.
With respect to handling time-varying string tension, modes
with frequencies that exceed the available frequency bandwidth
for a given time step remain active within the numerical model,
with their frequencies adjusted to fall into a narrow frequency band
just below the Nyquist frequency. These out-of-range modes con-
tinue to contribute to the overall system energy (hence a numerical
energy balance exists) but are suppressed in the calculation of the
output signal and of the string displacement at the hammer position
and as such do not interfere with the sound synthesis process while
they are out of range. In addition, a pragmatic form of re-scaling
of the output force signal under time-variance in the string tension
9 10 11 12
2000
4000
K
9 10 11 12
2000
4000
9 10 11 12
time (ms)
-2
0
2
4
6
!Fc(N)
9 10 11 12
time (ms)
-2
0
2
4
6
0 0.1 0.2 0.3
y(mm)
0
2
4
6
!Fc(N)
0 0.1 0.2 0.3
y(mm)
0
2
4
6
Figure 7: Simulation with time-variation in the contact stiffness
parameter (K). Left: increasing stiffness. Right: decreasing stiff-
ness. In each subplot, the dashed line indicates the simulation with
constant K. The parameters are those for a piano C4 string, with
∆t= 1/44100 s and Nb= 32.
was introduced to avoid large amplitude fluctuations, meaning a
much reduced need to make adjustments to the output gain.
The off-line numerical experiments conducted within this work
indicate that the algorithm’s computational load is sufficiently small
for real-time implementation and that no audible artefacts arise
under parameter time-variance. More exhaustive testing on the
latter point is still required though, and this is perhaps best done
through on-line control. A real-time controlled implementation
will also provide better opportunities to explore the possibilities
that the proposed model can offer as the sound engine of a (live-
performable) virtual-acoustic musical instrument.
6. ACKNOWLEDGMENTS
This work was supported by the European Union’s Horizon 2020
research and innovation programme under the Marie Skłodowska-
Curie grant agreement No 812719.
7. REFERENCES
[1] S. Mehes, M. van Walstijn, and P. Stapleton, “Virtual-
Acoustic Instrument Design: Exploring the Parameter Space
of a String-Plate Model,” in New Interfaces for Musical Ex-
pression, Copenhagen, 2017, pp. 399–403.
[2] M. van Walstijn and S. Mehes, “An explorative string-bridge-
plate model with tunable parameters,” in 20th Int. Conf. on
Digital Audio Effects (DAFx-17), 2017, pp. 291–298.
[3] S. Willemsen, S. Bilbao, M. Ducceschi, and S. Serafin,
“The dynamic grid: time-varying parameters for musical in-
strument simulations based on finite-difference time-domain
schemes,” J. Aud. Eng. Soc., vol. 70, no. 9, pp. 650–660,
september 2022.
DAFx.7
Proceedings of the 26th International Conference on Digital Audio Effects (DAFx23), Copenhagen, Denmark, 4 - 7 September 2023
0 200 400 600 800 1000
M
0
0.2
0.4
0.6
0.8
real time factor
Nb= 32
Nb= 64
Nb= 128
Nb= 256
Figure 8: Matlab real-time factor for specific combinations of
number of modes (M) and block size (Nb).
[4] J. Pakarinen, T. Puputti, and V. Välimäki, “Virtual Slide Gui-
tar,” Computer Music Journal, vol. 32, no. 3, pp. 42–54, 09
2008.
[5] C. Cadoz, A. Luciani, and J. Florens, “Cordis-anima: A
modeling and simulation system for sound and image syn-
thesis: The general formalism,” Computer Music Journal,
vol. 17, no. 1, pp. 19–29, 1993.
[6] J. Morrison and J. Adrien, “Mosaic: A framework for modal
synthesis,” Computer Music Journal, vol. 17, no. 1, pp. 45–
56, 1993.
[7] S. Bilbao and A. Torin, “Numerical simulation of
string/barrier collisions: The fretboard,” in Proc. of the
17th Int. Conf. on Digital Audio Effects (DAFx-14), Erlan-
gen, Germany, September 1-5, 2014, 2014, pp. 137–144.
[8] C. Desvages and S. Bilbao, “Two-polarisation physical
model of bowed strings with nonlinear contact and friction
forces, and application to gesture-based sound synthesis,”
Applied Sciences, vol. 6, no. 5, 2016.
[9] S. Bilbao, J. Perry, P. Graham A. Gray, K. Kavoussanakis,
G. Delap, T. Mudd, G. Sassoon T. Wishart, and S. Young,
“Large-Scale Physical Modeling Synthesis, Parallel Com-
puting, and Musical Experimentation: The NESS Project in
Practice,” Computer Music Journal, vol. 43, no. 2-3, pp. 31–
47, 2019.
[10] A. Bhanuprakash, M. van Walstijn, and P. Stapleton, “A fi-
nite difference model for articulated slide-string simulation,”
in Proc. Int. Conf. Digital Audio Effects (DAFx-20),. Sept.
2020, pp. 195–202, University of Music and Performing Arts
Vienna.
[11] N. Lopes, T. Hélie, and A. Falaize, “Explicit second-order
accurate method for the passive guaranteed simulation of
port-Hamiltonian systems,” in 5th IFAC Workshop on La-
grangian and Hamiltonian Methods for Nonlinear Control
LHMNC 2015, Lyon, France, July 2015, IFAC, vol. 48 of
IFAC-PapersOnLine, pp. 223–228.
[12] J. Zhao, Q. Wang, and Z. Yang, “Numerical approximations
for a phase field dendritic crystal growth model based on the
invariant energy quadratization approach,” Int. J. Num. Meth.
Eng., vol. 110, no. 3, pp. 279–300, 2017.
[13] J. Shen, J. Xu, and J. Yang, “The scalar auxiliary vari-
able (SAV) approach for gradient flows,” J. Computational
Physics, vol. 353, pp. 407–416, 2018.
[14] M. Ducceschi and S. Bilbao, “Simulation of the geomet-
rically exact nonlinear string via energy quadratisation,” J.
Sound and Vibr., vol. 534, pp. 117021, 2022.
[15] S. Bilbao, M. Ducceschi, and F. Zama, “Explicit exactly
energy-conserving methods for hamiltonian systems,” J.
Computational Physics, vol. 472, pp. 111697, 2023.
[16] M. Ducceschi and S. Bilbao, “Non-iterative solvers for non-
linear problems: the case of collisions,” in Proc. of the 22nd
Conf. of Digital Audio Effects (DAFx-19), Birmingham, UK,
September 2019, pp. 17–24.
[17] M. Ducceschi, S. Bilbao, S. Willemsen, and S. Serafin,
“Linearly-implicit schemes for collisions in musical acous-
tics based on energy quadratisation,” J. Acoust. Soc. Am.,
vol. 149, no. 5, pp. 3502–3516, 2021.
[18] A. Chaigne and A. Askenfelt, “Numerical simulations of
piano strings. I. A physical model for a struck string using
finite difference methods,” J. Acoust. Soc. Am., vol. 95, pp.
1112–1118, 1994.
[19] N. H. Fletcher and T. D Rossing, The Physics of Musical
Instruments, Springer-Verlag, New York, 1991, Second Edi-
tion: 1998.
[20] A. Chaigne and A. Askenfelt, “Numerical simulations of
piano strings. II. Comparisons with measurements and sys-
tematic exploration of some hammer-string parameters,” J.
Acoust. Soc. Am., vol. 95, no. 3, pp. 1631–1640, 1994.
[21] J. Woodhouse, “Plucked guitar transients: Comparison of
measurements and synthesis,” Acta Acustica united with
Acustica, vol. 90, no. 5, pp. 945–965, 2004.
[22] M. van Walstijn, J. Bridges, and S. Mehes, “A Real-Time
Synthesis Oriented Tanpura Model,” in Proc. Int. Conf. Dig-
ital Audio Effects (DAFx-16), 2016, pp. 175–182.
8. APPENDIX: BRANCHED EVALUATION OF gn
¯y
For the update equations (55,56), the gradient variable gn
¯yis calcu-
lated as
gn
¯y=
min(`gn
¯y,˙gn
¯y+) : ¯yn>0
˙gn
¯y+: ¯yn<0&¯yn−1>0
0 : otherwise
,(60)
where `gn
¯ydenotes the nominal value according to (17):
`gn
¯y=g¯y(¯yn) = q1
2¯κn(αn+ 1) [ ¯yn]αn−1
+
.(61)
The term ˙gn
¯y+is the positive root of the quadratic term on the left-
hand side of (57) that needs to remain non-positive to ensure that
ψn
+
1
2≥0:
˙gn
¯y+= 2 −zn+r(zn)2+ξnψn
−
1
2hψn
−
1
2+χni
+
qεξn(zn)2+ (ξnψn
−
1
2)2
.(62)
The inclusion of the term εξn(zn)2in the denominator, where
ε > 0is of the order of the machine epsilon, helps ensure that
the correct solution is found for ψn
−
1
2→0. The operator [.]
+
is
applied within the square root to ensure a real root and that ˙gn
¯y≥0.
The middle branch in (60) effectively sets ψn
+
1
2to zero at the end
of contact, as such altogether avoiding any spurious non-zero con-
tact force values at time instances where there is no contact.
DAFx.8