Repository navigation
Expand file tree
/
Copy pathuniBar.dsp
More file actions
93 lines (73 loc) · 2.72 KB
/
Copy pathuniBar.dsp
File metadata and controls
93 lines (73 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
declare name "Banded Waveguide Modeled Uniform Bar";
declare author "Romain Michon";
declare version "1.0";
import("math.lib");
import("music.lib");
import("filter.lib");
import("table.lib");
//==================== GUI SPECIFICATION ================
freq = nentry("freq", 440, 20, 20000, 1);
gain = nentry("gain", 0.8, 0, 1, 0.01);
gate = button("gate");
select = nentry("selector",0,0,1,1);
integrationConstant = hslider("integrationConstant",0,0,1,0.01);
//trackVelocity = nentry("trackVelocity",0,0,1,1);
baseGain = hslider("baseGain",1,0,1,0.01);
bowPressure = hslider("bowPressure",0.2,0,1,0.01);
bowPosition = hslider("bowPosition",0,0,1,0.01);
//==================== MODAL PARAMETERS ================
nModes = 4;
modes0 = 1;
modes1 = 2.756;
modes2 = 5.404;
modes3 = 8.933;
basegains0 = pow(0.9,1);
basegains1 = pow(0.9,2);
basegains2 = pow(0.9,3);
basegains3 = pow(0.9,4);
excitation = 1*gain/nModes;
//==================== SIGNAL PROCESSING ================
tableOffset = 0;
tableSlope = 10 - (9*bowPressure);
base = SR/freq;
//delay lengths in number of samples
delay0Length = base/modes0;
delay1Length = base/modes1;
delay2Length = base/modes2;
delay3Length = base/modes3;
//delay lines
delay0 = delay(4096,delay0Length);
delay1 = delay(4096,delay1Length);
delay2 = delay(4096,delay2Length);
delay3 = delay(4096,delay3Length);
//Filter bank
radius = 1-PI*32/SR;
bandPass0 = bandPass(freq*modes0,radius);
bandPass1 = bandPass(freq*modes1,radius);
bandPass2 = bandPass(freq*modes2,radius);
bandPass3 = bandPass(freq*modes3,radius);
//Delay lines feedback for bow table lookup control
baseGainApp = 0.8999999999999999 + (0.1 * baseGain);
velocityInputApp = integrationConstant;
velocityInput(fdbk0,fdbk1,fdbk2,fdbk3) = velocityInputApp + (baseGainApp*fdbk0) :
_+(baseGainApp*fdbk1) :
_+(baseGainApp*fdbk2) :
_+(baseGainApp*fdbk3);
//Bow velocity is controled by an ADSR envelope
maxVelocity = 0.03 + (0.1 * gain);
//bowTarget = _ + 0.005 * ;
//bowVelocity = (maxVelocity*adsr(0.02,0.005,90,0.01,gate))*(1-trackVelocity) + ((_*0.9995 : _+ bowTarget));
bowVelocity = maxVelocity*adsr(0.02,0.005,90,0.01,gate);
//Bow table lookup
input = (bowVelocity - velocityInput) <: _*bow(tableOffset,tableSlope) : _/nModes;
//Resonance system
resonance0(in0) = (_+in0+(excitation*select) : delay0 : _*basegains0 : bandPass0);
resonance1(in1) = (_+in1+(excitation*select) : delay1 : _*basegains1 : bandPass1);
resonance2(in2) = (_+in2+(excitation*select) : delay2 : _*basegains2 : bandPass2);
resonance3(in3) = (_+in3+(excitation*select) : delay3 : _*basegains3 : bandPass3);
process =
//Bowed Excitation
(input*((select-1)*-1) <:
resonance0(_)~_,resonance1(_)~_,resonance2(_)~_,resonance3(_)~_) ~(_,_,_,_) :> + :
//Signal Scaling and stereo
_*4 <: _,_;