-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflute.scd
68 lines (48 loc) · 1.88 KB
/
flute.scd
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
// Originally found at http://ecmc.rochester.edu/ecmc/docs/supercollider/scbook/Ch21_Interface_Investigations/ixi%20SC%20tutorial/ixi_SC_tutorial_10.html
SynthDef("waveguideFlute", { arg scl = 0.2, freq = 440, ipress = 0.9, ibreath = 0.09, ifeedbk1 = 0.4, ifeedbk2 = 0.4, dur = 1, gate = 1, amp = 2;
var kenv1, kenv2, kenvibr, kvibr, sr, cr, block;
var poly, signalOut, ifqc;
var aflow1, asum1, asum2, afqc, atemp1, ax, apoly, asum3, avalue, atemp2, aflute1;
var fdbckArray;
sr = SampleRate.ir;
cr = ControlRate.ir;
block = cr.reciprocal;
ifqc = freq;
// noise envelope
kenv1 = EnvGen.kr(Env.new(
[ 0.0, 1.1 * ipress, ipress, ipress, 0.0 ], [ 0.06, 0.2, dur - 0.46, 0.2 ], 'linear' )
);
// overall envelope
kenv2 = EnvGen.kr(Env.new(
[ 0.0, amp, amp, 0.0 ], [ 0.1, dur - 0.02, 0.1 ], 'linear' ), doneAction: 2
);
// vibrato envelope
kenvibr = EnvGen.kr(Env.new( [ 0.0, 0.0, 1, 1, 0.0 ], [ 0.5, 0.5, dur - 1.5, 0.5 ], 'linear') );
// create air flow and vibrato
aflow1 = LFClipNoise.ar( sr, kenv1 );
kvibr = SinOsc.ar( 5, 0, 0.1 * kenvibr );
asum1 = ( ibreath * aflow1 ) + kenv1 + kvibr;
afqc = ifqc.reciprocal - ( asum1/20000 ) - ( 9/sr ) + ( ifqc/12000000 ) - block;
fdbckArray = LocalIn.ar( 1 );
aflute1 = fdbckArray;
asum2 = asum1 + ( aflute1 * ifeedbk1 );
//ax = DelayL.ar( asum2, ifqc.reciprocal * 0.5, afqc * 0.5 );
ax = DelayC.ar( asum2, ifqc.reciprocal - block * 0.5, afqc * 0.5 - ( asum1/ifqc/cr ) + 0.001 );
apoly = ax - ( ax.cubed );
asum3 = apoly + ( aflute1 * ifeedbk2 );
avalue = LPF.ar( asum3, 2000 );
aflute1 = DelayC.ar( avalue, ifqc.reciprocal - block, afqc );
fdbckArray = [ aflute1 ];
LocalOut.ar( fdbckArray );
signalOut = avalue;
OffsetOut.ar( 0, [ signalOut * kenv2, signalOut * kenv2 ] );
}).add;
// Example
(
Pbind(
\instrument, "waveguideFlute",
\degree, Pseq([0, 1, 2, 3, 4], 2),
\dur, Pwhite(0.5, 1),
\amp, Pwhite(0.1, 0.4)
).play
)