-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshaman.scd
151 lines (121 loc) · 2.77 KB
/
shaman.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//todo
//have new type of if's
//shaman
~pan= 0.1; //stereo width
//generate ~notes for the shaman to play
~gen = { |bpb,bjorkdum,bjorkaccent|
var para;
var bjork1;
var bjork2;
~notes = Array.fill3D(3, bpb, 5, nil); //nb. of instruments, beatsPerBar, note metadata, values
/* note metadata:
//0 - freq/playback rate
//1 - amplitude
//2 - sustain
//3 - panning
4 - sample library
*/
//paradiddle
1.do{
if(bpb < 32,
{
a = nil ! (bpb/2); //first half of the paradiddle (maybe the divider can be an argument as well)
a.size.asInteger.do{ |i|
if(i<((bpb/2)-1), //relationship between 8%3,12%5,16&7
{a[i] = i%2;}, //write 0 and 1 after each other
{a[i] = a[0];} //only write 0 from now on
);
};
b = 1 - a; //flip all ones and zeros
para = a ++ b; //concatenate the results
para.postln
},
{
para = Array.fill(bpb, { arg i; i%2 });
para.postln // 1st step
};
);
};
//Euclidean
bjork1 = Bjorklund(bjorkdum,bpb);
bpb.do{ |i|
if(bjork1[i]==1,
{
para[i] = 2;
}
)
};
para.postln; //2nd step
bjork2 = Bjorklund(bjorkaccent,bpb);
bjork2.postln; //3rd step
bpb.do{ |x|
case
{para[x]==0}
{
~notes[0][x][0] = 1; //freq
//~notes[0][x][1] = 1; //amp
//~notes[i][x][2] =
//~notes[0][x][3] = ~panning[0]; //right
// improve: can case be replaced with something faster?
case
{bjork2[x]==0}
{~notes[0][x][4] = ~sampleBufs[0][0]}
{bjork2[x]==1}
{~notes[0][x][4] = ~sampleBufs[0][1]}
}
{para[x]==1}
{
~notes[1][x][0] = 1;
//~notes[1][x][1] = 1;
//~notes[i][x][2] =
//~notes[1][x][3] = ~panning[1]; //left
case
{bjork2[x]==0}
{~notes[1][x][4] = ~sampleBufs[1][0]}
{bjork2[x]==1}
{~notes[1][x][4] = ~sampleBufs[1][1]}
}
{para[x]==2}
{
~notes[2][x][0] = 1;
//~notes[2][x][1] = 1;
//~notes[i][x][2] =
//~notes[2][x][3] = 0; //center
case
{bjork2[x]==0}
{~notes[2][x][4] = ~sampleBufs[2][0]}
{bjork2[x]==1}
{~notes[2][x][4] = ~sampleBufs[2][1]}
};
};
};
// variation
~shaman = { |bps,bpb|
t.clear;
t.tempo_(bps);
t.schedAbs(0,{t.beatsPerBar=bpb;});
t.play({
x = (t.beats%bpb).round;
if (~notes[0][(x).round][4] != nil, // 0 left
{
Ndef(\0).spawn([\buffer, (~notes[0][x][4]).choose, \amp, ~shamanVol, \pan, ~pan],); //retrigger
}
);
if (~notes[1][(x).round][4] != nil, // 1 right
{
Ndef(\1).spawn([\buffer, (~notes[1][x][4]).choose, \amp, ~shamanVol, \pan, ~pan.neg]); //retrigger
}
);
if (~notes[2][(x).round][4] != nil, // 2 middle
{
Ndef(\2).spawn([\buffer, (~notes[2][x][4]).choose, \amp, ~shamanVol, \pan, 0]); //retrigger
}
);
if (~timer[2] !== 0, // 2 middle
{
Ndef(\theta).spawn([\sustain, (3.rand+1)/10, \decay, (2.rand+1)]); //retrigger
}
);
1
});
};