-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_beats.ck
More file actions
97 lines (82 loc) · 1.69 KB
/
git_beats.ck
File metadata and controls
97 lines (82 loc) · 1.69 KB
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
string beat_files[7];
"beats/otf_01" => beat_files[0];
"beats/otf_02" => beat_files[1];
"beats/otf_03" => beat_files[2];
"beats/otf_04" => beat_files[3];
"beats/otf_05" => beat_files[4];
"beats/otf_06" => beat_files[5];
"beats/otf_07" => beat_files[6];
// default file
"data_test.txt" => string filename;
// look at command line
if( me.args() > 0 ) me.arg(0) => filename;
// open a file
FileIO fio;
fio.open( filename, FileIO.READ );
fun void fives()
{
5000::ms => now;
}
fun void funks(int high, int low)
{
Machine.add(beat_files[high]) => int special_beat;
fives();
Machine.replace(special_beat, beat_files[low]);
fives();
Machine.remove(special_beat);
}
fun void random_funk()
{
Std.rand2(1,20) => int random;
if (random > 19)
{
funks(6,1);
}
if (random > 18 && random <= 19)
{
funks(5,4);
}
}
fun void beatify( int value )
{
if ( value <= 12 )
{
Machine.add(beat_files[value/2]) => int something_useful;
if (value == 0)
{
random_funk();
1000::ms => now;
}
if (value == 2)
{
random_funk();
2000::ms => now;
}
else
(value*2000)::ms => now;
Machine.remove( something_useful );
}
else
{
Machine.add(beat_files[(value%10)/2]) => int other_something_useful;
(value*1000)::ms => now;
Machine.remove( other_something_useful );
}
}
// ensure file is ok
if( !fio.good() )
{
cherr <= "can't open file: " <= filename <= " for reading..."
<= IO.newline();
me.exit();
}
// variable to read into
int val;
// loop until end <-- except it doesn't seem to ever die...
while( fio => val )
{
cherr <= val <= IO.newline();
// sporkage!!
spork ~ beatify( val );
500::ms => now;
}