-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathantaras.dsp
68 lines (51 loc) · 1.73 KB
/
antaras.dsp
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
import("music.lib"); //adsr
import("math.lib"); //tanh
import("effect.lib"); //dcblocker
//parameters
RHO = 1.2;
SOUND_SPEED = 343.54;
ONE_OVER_RHO_C = 1.0 / (RHO * SOUND_SPEED);
gate = button("Play"); // on-off
length1 = hslider("Length_1", 15, 1, 350, 0.1)*0.001;
length2 = hslider("Length_2", 15, 1, 350, 0.1)*0.001;
radius1 = hslider("Radius_1", 4, 1, 200, 0.1)*0.001;
radius2 = hslider("Radius_2", 4, 1, 200, 0.1)*0.001;
//delays
uptube1 = fdelay(4096, (length1 * SR)/(SOUND_SPEED));
downtube1 = fdelay(4096, (length1 * SR)/(SOUND_SPEED));
uptube2 = fdelay(4096, (length2 * SR) / (SOUND_SPEED) );
downtube2 = fdelay(4096, (length2 * SR) / (SOUND_SPEED) );
// filters
lossesFilter = iir((b0,b1,b2,b3),(a1,a2,a3))
with {
a1 = -0.33623476246554;
a2 = -0.71257915055968;
a3 = 0.14508304017256;
b0 = 0.83820223947141;
b1 = -0.16888603248373;
b2 = -0.64759781930259;
b3 = 0.07424498608506;
};
endReflection = iir((b0,b1,b2),(a1,a2))
with {
a1 = -0.3587;
a2 = -0.0918;
b0 = -0.1254;
b1 = -0.3237;
b2 = -0.1003;
};
// 2portj
portj = (_, _) <: (_,_,_,_) : (_,(_-_)*kr,_) : (_, (_ <: (_,_)) ,_ ) : (_+_, _+_)
with {
kr = ((radius2*radius2) - (radius1*radius1)) / ((radius2*radius2) + (radius1*radius1));
};
// resonador
res = inmix <: (uptube1, downtube2, _) : (portj,_) : (uptube2, downtube1,_) <: (_,_,!,!,_,_) : outmix
with {
inmix(dt1, ut2, input) = (dt1+input, ut2, dt1);
outmix(ut2, dt1, outn, outp) = (dt1, ut2, outn, outp);
};
calc(out, in) = (out, in) <: (_,! , _,_, _,_) : (! , (_+_) , (_-_)*ONE_OVER_RHO_C ); // solo Pp y Vac
resonator = ((res~_(endReflection)):(!,_,_,_))~_(lossesFilter): !,_,_ : calc ;
process = (1-1') : resonator;
//process = gate * noise : resonator;