/ challenges-old / string
Sign in
challenges-old / string
string / challenges / string-pluck-v1 / README.md
8.3 KBPreviewCodeBlameHistoryRaw

string-pluck-v1: plucked damped string, pickup velocity#

This is the hello-world challenge of the collection. The model is a linear damped string with fixed ends, released from rest from its static equilibrium under a finger load of finite width. The deliverable is a two second mono wav file containing the transverse velocity of the string at a fixed pickup point. Every quantity below is defined in the continuum, so the true solution is a specific function of time that does not depend on any discretization. A modal series solution is given in the appendix; it converges to the true solution and can be evaluated to machine precision, so this challenge is mainly a test of the submission and scoring pipeline.

The machine-readable version of this specification is challenge.json.

Model#

Let u(x,t)u(x, t) denote the transverse displacement in meters of the string at position x∈[0,L]x \in [0, L] and time t≥0t \ge 0. The string satisfies

∂2u∂t2=c2∂2u∂x2−2σ0∂u∂t+κ∂3u∂x2∂t,0<x<L,t>0,\frac{\partial^2 u}{\partial t^2} = c^2 \frac{\partial^2 u}{\partial x^2} - 2\sigma_0 \frac{\partial u}{\partial t} + \kappa \frac{\partial^3 u}{\partial x^2 \partial t}, \qquad 0 < x < L, \quad t > 0,

with fixed ends

u(0,t)=u(L,t)=0,t≥0,u(0, t) = u(L, t) = 0, \qquad t \ge 0,

and initial conditions

u(x,0)=u0(x),∂u∂t(x,0)=0,0≤x≤L.u(x, 0) = u_0(x), \qquad \frac{\partial u}{\partial t}(x, 0) = 0, \qquad 0 \le x \le L.

Here cc is the wave speed, σ0\sigma_0 is a frequency-independent loss rate, and κ\kappa is a Kelvin-Voigt viscosity that damps high frequencies faster than low ones.

The initial shape u0u_0 is the static equilibrium of the string under a transverse load of finite width centered at the pluck point xpx_p, which is how a finger or plectrum deforms the string before release. The load profile is a raised cosine of half-width ww,

g(x)={Q2w(1+cos⁡π(x−xp)w),∣x−xp∣≤w,0,otherwise,g(x) = \begin{cases} \dfrac{Q}{2w}\left(1 + \cos\dfrac{\pi (x - x_p)}{w}\right), & |x - x_p| \le w, \\[1ex] 0, & \text{otherwise,} \end{cases}

and u0u_0 solves the static problem u0′′=−gu_0'' = -g on (0,L)(0, L) with u0(0)=u0(L)=0u_0(0) = u_0(L) = 0. Here Q=∫0Lg dxQ = \int_0^L g\,dx is the total load expressed as a slope (force divided by tension), and it is fixed by requiring the pluck height u0(xp)=hu_0(x_p) = h. In closed form,

u0(x)=Q τ(x)+Q κ(x−xp),τ(x)={x(L−xp)/L,x≤xp,xp(L−x)/L,x≥xp,u_0(x) = Q\,\tau(x) + Q\,\kappa(x - x_p), \qquad \tau(x) = \begin{cases} x (L - x_p) / L, & x \le x_p, \\ x_p (L - x) / L, & x \ge x_p, \end{cases}
κ(y)={y H(y)−12w[(y+w)22−w2π2(1+cos⁡πyw)],∣y∣≤w,0,otherwise,Q=hxp(L−xp)/L−w(14−1π2),\kappa(y) = \begin{cases} y\,H(y) - \dfrac{1}{2w}\left[ \dfrac{(y + w)^2}{2} - \dfrac{w^2}{\pi^2}\left(1 + \cos\dfrac{\pi y}{w}\right) \right], & |y| \le w, \\[1ex] 0, & \text{otherwise,} \end{cases} \qquad Q = \frac{h}{x_p (L - x_p) / L - w\left(\tfrac{1}{4} - \tfrac{1}{\pi^2}\right)},

where HH is the Heaviside step (H(y)=1H(y) = 1 for y>0y > 0, else 00). τ\tau is the triangle produced by a point load, and κ\kappa is the correction from spreading the load over the contact region; it vanishes outside ∣y∣≤w|y| \le w. Note that u0u_0 is three times continuously differentiable, since gg is continuously differentiable, and that w<xp<L−ww < x_p < L - w so the fixed-end conditions hold.

Parameters#

Symbol Value Unit Meaning
LL 0.65 m string length
cc 143 m/s wave speed (fundamental c/2L=110c / 2L = 110 Hz)
σ0\sigma_0 3 1/s frequency-independent loss rate
κ\kappa 0.004 m^2/s Kelvin-Voigt viscosity
hh 0.002 m pluck height u0(xp)u_0(x_p)
xpx_p 0.1625 m pluck center (L/4L/4)
ww 0.006 m half-width of the finger load
xmx_m 0.54 m pickup position

All values are exact decimal numbers, not rounded measurements.

Output signal#

The audio signal is the transverse velocity of the string at the pickup point,

s(t)=∂u∂t(xm,t),in m/s.s(t) = \frac{\partial u}{\partial t}(x_m, t), \qquad \text{in m/s}.

The deliverable is a wav file with the following properties.

Property Value
channels 1
sample rate fsf_s 48000 Hz
number of samples NN 96000 (2.0 s)
sample format 32-bit IEEE float (WAVE_FORMAT_IEEE_FLOAT)
sample kk, for k=0,…,N−1k = 0, \dots, N-1 s(k/fs)/srefs(k / f_s) / s_\text{ref}
srefs_\text{ref} see output.signal_scale in challenge.json (m/s)

The first sample is at t=0t = 0, where s(0)=0s(0) = 0. Samples are pointwise values of the continuum signal. No anti-aliasing filter is applied, even though s(t)s(t) contains frequency content above the Nyquist frequency; that content is heavily damped by the Kelvin-Voigt term and is part of the exact answer. The scale srefs_\text{ref} is a fixed constant chosen so that the peak sample magnitude is roughly 0.5. Do not normalize the signal; absolute amplitude is compared.

Error measures#

Let aka_k and rkr_k, k=0,…,N−1k = 0, \dots, N-1, be the samples of a submitted solution and of the reference solution. Two error measures are computed. Both are relative and dimensionless, and both are reported for every solution.

Waveform error (primary):

Ewave=(∑k(ak−rk)2)1/2(∑krk2)1/2.E_\text{wave} = \frac{\left( \sum_k (a_k - r_k)^2 \right)^{1/2}}{\left( \sum_k r_k^2 \right)^{1/2}}.

Spectrogram error. Let M=2048M = 2048 be the frame length and H=512H = 512 the hop. The periodic Hann window is gj=12(1−cos⁡(2πj/M))g_j = \tfrac{1}{2}\left(1 - \cos(2\pi j / M)\right) for j=0,…,M−1j = 0, \dots, M-1. Frame mm of a signal xx is xmH+j gjx_{mH + j}\, g_j, for m=0,…,⌊(N−M)/H⌋m = 0, \dots, \lfloor (N - M) / H \rfloor, with no zero padding at either end. Let Xm[q]X_m[q], q=0,…,M/2q = 0, \dots, M/2, be its discrete Fourier transform, Xm[q]=∑j=0M−1xmH+j gj e−2πiqj/MX_m[q] = \sum_{j=0}^{M-1} x_{mH+j}\, g_j\, e^{-2\pi i q j / M}. Then

Espec=(∑m,q(∣Am[q]∣−∣Rm[q]∣)2)1/2(∑m,q∣Rm[q]∣2)1/2.E_\text{spec} = \frac{\left( \sum_{m, q} \left( |A_m[q]| - |R_m[q]| \right)^2 \right)^{1/2}}{\left( \sum_{m, q} |R_m[q]|^2 \right)^{1/2}}.

The spectrogram error ignores phase within a frame and is less sensitive than the waveform error to small frequency errors that accumulate into phase drift over the two seconds.

Reference solution#

There is no externally supplied ground truth. The reference is chosen automatically from the submitted solutions by the procedure described in the collection README, unless reference_solution in challenge.json names one explicitly. For this particular challenge the modal series in the appendix gives an essentially exact answer, which is expected to be selected.

Optional field export#

A submission may additionally provide the displacement field for visualization. This is not scored. The file is HDF5 with three datasets: x, float64, shape (201,), the positions xi=iL/200x_i = i L / 200 in meters; t, float64, shape (4001,), the times tj=j/2000t_j = j / 2000 in seconds; and u, float32, shape (4001, 201), with u[j, i] =u(xi,tj)= u(x_i, t_j) in meters. Root attributes challenge_id, solution_id, quantity ("transverse displacement") and units ("m") are recommended. The grid is stated under fields in challenge.json. A file of this size is about 3 MB uncompressed and can live in the solution repository; gzip compression inside the file is welcome.

Appendix: modal series solution#

This appendix is provided for convenience and verification; it is not part of the challenge definition, and a submission may use any method.

Expanding u(x,t)=∑n≥1an(t)sin⁡(knx)u(x, t) = \sum_{n \ge 1} a_n(t) \sin(k_n x) with kn=nπ/Lk_n = n\pi / L, each coefficient satisfies

an′′+2αnan′+c2kn2an=0,αn=σ0+12κkn2,a_n'' + 2\alpha_n a_n' + c^2 k_n^2 a_n = 0, \qquad \alpha_n = \sigma_0 + \tfrac{1}{2}\kappa k_n^2,

with an(0)=Ana_n(0) = A_n and an′(0)=0a_n'(0) = 0. Integrating by parts twice, using u0′′=−gu_0'' = -g and the fixed ends,

An=2L∫0Lu0(x)sin⁡(knx) dx=2Lkn2∫0Lg(x)sin⁡(knx) dx=2QL w kn3 sin⁡(knxp) sin⁡(knw) (π/w)2(π/w)2−kn2.A_n = \frac{2}{L} \int_0^L u_0(x) \sin(k_n x)\, dx = \frac{2}{L k_n^2} \int_0^L g(x) \sin(k_n x)\, dx = \frac{2Q}{L\, w\, k_n^3}\, \sin(k_n x_p)\, \sin(k_n w)\, \frac{(\pi / w)^2}{(\pi/w)^2 - k_n^2}.

With the parameters above, (π/w)2−kn2≠0(\pi/w)^2 - k_n^2 \ne 0 for every integer nn, since L/wL / w is not an integer. For every mode that matters αn<ckn\alpha_n < c k_n (the modes are underdamped up to roughly n=14800n = 14800), and in that case, with ωn=c2kn2−αn2\omega_n = \sqrt{c^2 k_n^2 - \alpha_n^2},

an(t)=Ane−αnt(cos⁡ωnt+αnωnsin⁡ωnt),an′(t)=−Anc2kn2ωne−αntsin⁡ωnt.a_n(t) = A_n e^{-\alpha_n t} \left( \cos \omega_n t + \frac{\alpha_n}{\omega_n} \sin \omega_n t \right), \qquad a_n'(t) = -A_n \frac{c^2 k_n^2}{\omega_n} e^{-\alpha_n t} \sin \omega_n t.

The pickup velocity is then

s(t)=∑n≥1an′(t)sin⁡(knxm).s(t) = \sum_{n \ge 1} a_n'(t) \sin(k_n x_m).

Since ∣An∣=O(n−5)|A_n| = O(n^{-5}) and ∣an′∣|a_n'| carries an extra factor of nn, the terms decay like n−4n^{-4} before damping is taken into account, and for t>0t > 0 the exponential factor makes the series converge rapidly. In practice a few hundred modes give the signal to single precision for all t≥1/fst \ge 1 / f_s; at t=0t = 0 the exact value is s(0)=0s(0) = 0.

↑↓ move↵openescclose