Making Virtual Electric Guitars and Guitar Effects
Using Faust and Octave
Extended Karplus-Strong Algorithm
Tuning the EKS String
Tuning by Linear InterpolationSearch Physical Audio Signal Processing
Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?
An overview of linear interpolation, among others, is given in §3.2. The transfer function of first-order linear-interpolation can be written as
Faust Implementation.
Faust includes a function fdelay(n,d,x) defined in music.lib which provides fractional (non-integer) delay by means of linear interpolation:
fdelay(n,d,x) = delay(n,int(d),x)*(1 - frac(d))
+ delay(n,int(d)+1,x)*frac(d);
Note that it also specifies a second delay line. However, a second
delay-line is not implemented in the generated C++ code because
Faust has an optimization rule that consolidates all delay-lines
having the same input signal to one shared delay line.
A single-delay-line version can be defined as follows:
linterp(d,x) = (1-d) * x + d * x'; fdelay1(n,d,x) = delay(n,int(d),x) : linterp(frac(d));Note that these definitions are not equivalent. While they are equivalent when the delay d is fixed, they diverge when int(d) changes from one sample to the next. In the dual-delay-line specification, the desired result is obtained, while in the single-delay-line case, x' becomes a one-sample delay of the old delay-line output instead of the new delay-line output. This inconsistency can potentially cause audible clicks when the tuning is rapidly varied.
A proper implementation of the single-delay-line case involves
resetting the linear-interpolator state variable when the delay-length
changes. Conceptually, the linear interpolator should be implemented
as two delay-line taps with gains
and
, as indicated
in Fig.
. This structure is produced by the Faust
optimization rules from the dual-delay-line specification as above.
Linear delay-line interpolation works well in a digital waveguide string model as long as the modeled string is sufficiently damped. Specifically, the string damping must be sufficient to mask the changing roll-off in the