-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathofferingCalung.ck
132 lines (120 loc) · 3.84 KB
/
offeringCalung.ck
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
// global argument variables
int INSTR;
float AMP;
if (me.args())
{
Std.atoi(me.arg(0)) => INSTR;
Std.atof(me.arg(1)) => AMP;
}
fun void Phrase(int instr, float amp)
{
//intialize reverb
NRev r => Pan2 p => dac;
.1 => r.mix;
// CREATE INSTRUMENTS AND ARRAY TO HOLD THEIR NAMES
// Create GAMELAN object
GAMELAN gam;
gam.connect(r);
["jeg", "jub", "cal", "ugal", "pem", "kan"] @=> string gamelan[];
gamelan[instr] @=> string currentInstr;
<<<currentInstr>>>;
// the period
.56=> float timeDiv;
timeDiv::second => dur T;
int freq;
// set random panning and amplitude
Math.random2(0, 1) => int lr;
//Math.random2f(0.05, 0.4) => float amp;
// synchronize to period (for on-the-fly synchronization)
// disable to create a more 'cloud-like' texture
T - (now % T) => now;
// scale (pentatonic; in semitones)
[ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] @=> int scale[];
// variables for components that encourage variation
1=> int counter;
0=> int advance;
1=> int root;
float Tscale;
.725*timeDiv=> float lngNote;
.525*timeDiv=> float medNote;
.35*timeDiv=> float shrtNote;
// infinite time loop
while( true )
{
// random weights for creating variation
Math.random2(1, 6) => int weight1;
Math.random2(1, 5) => int weight2;
Math.random2(1, 10) => int weight3;
// if counter == 1, first note is either C or D depending on weight1
if (counter == 1) {
if (weight1 < 2) {
if (root == 1) {
0 => root;
} else {
1 => root;
}
scale[root] => freq;
} else {
scale[root] => freq;
}
medNote=> Tscale;
// cycle through middle portion of phrase
} else if (counter < (scale.cap()-2)) {
scale[counter]-1 => freq;
if (counter == (scale.cap()-3)) {
if (weight2 > 1) {
medNote=> Tscale;
} else {
shrtNote=> Tscale;
}
} else {
shrtNote=> Tscale;
}
// sometimes a higher note is added to the ended depending of weight2
} else {
if (weight2 > 1) {
// a value of 1 for advance causes no note to be played
1 => advance;
} else {
// occassionally it will the highest note depending on weight3
if (weight3 > 1) {
scale[counter]-1 => freq;
} else {
scale[counter] => freq;
}
}
0 => counter;
lngNote=> Tscale;
}
counter++;
// advance time
if (advance == 1) {
// skip this note
0 => advance;
now => now;
} else {
if (currentInstr == "jeg") {
-0.6+lr => p.pan;
gam.jegogan(freq, amp, Tscale*4);
} else if (currentInstr == "jub") {
-0.5+lr => p.pan;
gam.jublag(freq, amp, Tscale*2);
} else if (currentInstr == "cal") {
-0.2+lr => p.pan;
gam.calun(freq, amp, Tscale*2);
} else if (currentInstr == "ugal") {
0.2-lr => p.pan;
gam.ugal(freq, amp, Tscale);
} else if (currentInstr == "pem") {
0.5-lr => p.pan;
gam.pemade(freq, amp, Tscale/2);
} else if (currentInstr == "kan") {
0.6-lr => p.pan;
gam.kantil(freq, amp, Tscale/2);
}
now => now;
}
}
}
<<<INSTR>>>;<<<AMP>>>;
Phrase(INSTR, AMP);