Next  |  Prev  |  Up  |  Top  |  REALSIMPLE Top

Exciting the Digitar String

A new ``pluck'' is obtained in the digitar algorithm by writing new random numbers into the waveform memory (the delay line in Fig.1). The fundamental frequency $F_0$ is approximately given by the sampling rate $f_s$ divided by the memory length $N$, or $F_0\approx f_s/N$. This relation is not exact because the two-point average adds a half-sample phase delay [12].5A more accurate formula is therefore

F_0 = \frac{f_s}{N+\frac{1}{2}}.
\end{displaymath} (1)

This formula can be used as exact for practical purposes, but it is not exact in theory due to the slight decay per period caused by the two-point average.6

Figure 2 lists a Faust program implementing the digitar algorithm (adapted from the programming example karplus.dsp distributed with Faust), and Fig.3 shows the block diagram generated by faust for the resonator definition in Fig.2 (using the -svg command-line option, as discussed in the Faust intro [15]). If this Faust code is not self-explanatory, see [15] and/or [9].

Figure 2: Faust program ks.dsp specifying the Karplus-Strong (KS) digitar algorithm.

import("music.lib"); // define noise, SR, delay

// MIDI-driven parameters:
freq = nentry("freq Hz", 440, 20, 20000, 1); // Hz
gain = nentry("gain", 1, 0, 10, 0.01);    // 0 to 1
gate = button("gate");                    // 0 or 1

// Excitation gate (convert gate to a one-period pulse):
diffgtz(x) = (x-x') > 0;
decay(n,x) = x - (x>0)/n;
release(n) = + ~ decay(n);
trigger(n) = diffgtz : release(n) : > (0.0);

// Resonator:
average(x) = (x+x')/2;
P = SR/freq;
resonator = (+ : delay(4096, P)) ~ (average);

process = noise : *(gain) : *(gate : trigger(P)) 
                : resonator;

Figure 3: Faust-generated block diagram of the resonator definition in Fig.2. For the digitar algorithm, a one-period burst of white noise may be injected as an input signal. For historical accuracy, the feedback should be eliminated during the excitation noise-burst (making the adder unnecessary), but this makes little difference in the sound under normal conditions.
\resizebox{4.5in}{!}{\includegraphics{\figdir /resonator.eps}}

Next  |  Prev  |  Up  |  Top  |  REALSIMPLE Top

Download faust_strings.pdf

``Making Virtual Electric Guitars and Associated Effects Using Faust'', by Julius O. Smith III,
REALSIMPLE Project — work supported in part by the Wallenberg Global Learning Network .
Released 2013-08-22 under the Creative Commons License (Attribution 2.5), by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University