2 declare description "Nonlinear Banded Waveguide Models";
3 declare author "Romain Michon";
4 declare copyright "Romain Michon (rmichon@ccrma.stanford.edu)";
6 declare licence "STK-4.3"; // Synthesis Tool Kit 4.3 (MIT style license);
7 declare description "This instrument uses banded waveguide. For more information, see Essl, G. and Cook, P. Banded Waveguides: Towards Physical Modelling of Bar Percussion Instruments, Proceedings of the 1999 International Computer Music Conference.";
10 import("instrument.lib");
12 //==================== GUI SPECIFICATION ================
14 freq = nentry("h:Basic_Parameters/freq [1][unit:Hz] [tooltip:Tone frequency]",440,20,20000,1);
15 gain = nentry("h:Basic_Parameters/gain [1][tooltip:Gain (value between 0 and 1)]",0.8,0,1,0.01);
16 gate = button("h:Basic_Parameters/gate [1][tooltip:noteOn = 1, noteOff = 0]");
18 select = nentry("h:Physical_and_Nonlinearity/v:Physical_Parameters/Excitation_Selector
19 [2][tooltip:0=Bow; 1=Strike]",0,0,1,1);
20 integrationConstant = hslider("h:Physical_and_Nonlinearity/v:Physical_Parameters/Integration_Constant
21 [2][tooltip:A value between 0 and 1]",0,0,1,0.01);
22 baseGain = hslider("h:Physical_and_Nonlinearity/v:Physical_Parameters/Base_Gain
23 [2][tooltip:A value between 0 and 1]",1,0,1,0.01);
24 bowPressure = hslider("h:Physical_and_Nonlinearity/v:Physical_Parameters/Bow_Pressure
25 [2][tooltip:Bow pressure on the instrument (Value between 0 and 1)]",0.2,0,1,0.01);
26 bowPosition = hslider("h:Physical_and_Nonlinearity/v:Physical_Parameters/Bow_Position
27 [2][tooltip:Bow position on the instrument (Value between 0 and 1)]",0,0,1,0.01);
29 //==================== MODAL PARAMETERS ================
36 basegains(1,0) = pow(0.9,1);
37 excitation(1,0) = 1*gain/nMode(1);
40 basegains(1,1) = pow(0.9,2);
41 excitation(1,1) = 1*gain/nMode(1);
44 basegains(1,2) = pow(0.9,3);
45 excitation(1,2) = 1*gain/nMode(1);
48 basegains(1,3) = pow(0.9,4);
49 excitation(1,3) = 1*gain/nMode(1);
51 //==================== SIGNAL PROCESSING ================
53 //----------------------- Synthesis parameters computing and functions declaration ----------------------------
55 //the number of modes depends on the preset being used
56 nModes = nMode(preset);
58 //bow table parameters
60 tableSlope = 10 - (9*bowPressure);
62 delayLengthBase = SR/freq;
64 //delay lengths in number of samples
65 delayLength(x) = delayLengthBase/modes(preset,x);
68 delayLine(x) = delay(4096,delayLength(x));
70 //Filter bank: bandpass filters (declared in instrument.lib)
71 radius = 1 - PI*32/SR;
72 bandPassFilter(x) = bandPass(freq*modes(preset,x),radius);
74 //Delay lines feedback for bow table lookup control
75 baseGainApp = 0.8999999999999999 + (0.1*baseGain);
76 velocityInputApp = integrationConstant;
77 velocityInput = velocityInputApp + _*baseGainApp,par(i,(nModes-1),(_*baseGainApp)) :> +;
79 //Bow velocity is controled by an ADSR envelope
80 maxVelocity = 0.03 + 0.1*gain;
81 bowVelocity = maxVelocity*adsr(0.02,0.005,90,0.01,gate);
83 //stereoizer is declared in instrument.lib and implement a stereo spacialisation in function of
84 //the frequency period in number of samples
85 stereo = stereoizer(delayLengthBase);
87 //----------------------- Algorithm implementation ----------------------------
89 //Bow table lookup (bow is decalred in instrument.lib)
90 bowing = bowVelocity - velocityInput <: *(bow(tableOffset,tableSlope)) : /(nModes);
93 resonance(x) = + : + (excitation(preset,x)*select) : delayLine(x) : *(basegains(preset,x)) : bandPassFilter(x);
97 (bowing*((select-1)*-1) <:
98 //nModes resonances with nModes feedbacks for bow table look-up
99 par(i,nModes,(resonance(i)~_)))~par(i,nModes,_) :> + :
100 //Signal Scaling and stereo
101 *(14) : stereo : instrReverb;