declare name "Constant-Peak-Gain Resonator Synth";
declare author "Julius Smith";
declare version "1.0";
declare license "GPL";
/* Standard synth controls supported by faust2pd */
freq = nentry("freq", 440, 20, 20000, 1); // Hz
gain = nentry("gain", 0.1, 0, 1, 0.01); // frac
gate = button("gate"); // 0/1
/* User Controls */
bw = hslider("bandwidth (Hz)", 100, 20, 20000, 10);
import("music.lib"); // define noise, adsr, PI, SR, et al.
/* ADSR envelope parameters */
attack = hslider("attack", 0.01,0, 1, 0.001); // sec
decay = hslider("decay", 0.3, 0, 1, 0.001); // sec
sustain = hslider("sustain",0.5, 0, 1, 0.01); // frac
release = hslider("release",0.2, 0, 1, 0.001); // sec
/* Synth */
process = noise * env * gain : filter
with {
env = gate :
vgroup("1-adsr",
adsr(attack, decay, sustain, release));
filter = vgroup("2-filter", (firpart : + ~ feedback));
R = exp(0-PI*bw/SR); // pole radius [0 required]
A = 2*PI*freq/SR; // pole angle (radians)
RR = R*R;
firpart(x) = (x - x'') * ((1-RR)/2);
// time-domain coeffs ASSUMING ONE PIPELINE DELAY:
feedback(v) = 0 + 2*R*cos(A)*v - RR*v';
};
|