-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhamlet.ck
executable file
·61 lines (45 loc) · 1.08 KB
/
hamlet.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
/*
* Sonification
* Use channels to set the notes to side
*/
SinOsc s => dac => WvOut wv => blackhole;
.2 => float timeSt;
me.arg(0) => string original;
//file sizes
int texta[3400];
int size;
//create the array and push into a variable
readInts(original) @=> texta;
"hamtone" => wv.wavFilename;
1 => wv.record;
for (0 => int i; i<size;i++) {
play(s, texta[i]);
}
0 => wv.record;
null @=> wv;
// play the note
fun void play(SinOsc s, int noteone) {
// start the first note
noteone => s.freq;
100::ms => now;
}
// read the ints into an array
// http://wiki.cs.princeton.edu/index.php/ChucK/Dev/IO/FileIO
fun int[] readInts(string path) {
// open the file
FileIO file;
if (!file.open(path, FileIO.READ)) {
<<< "file read failed" >>>;
<<< path >>>;
int ret[0]; // error opening the specified file
return ret;
}
// read the size of the array
file => size;
// now read in the contents
int ret[size];
for (0 => int i; i < size; i++)
file => ret[i];
file.close();
return ret;
}