-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathufo.ck
130 lines (121 loc) · 3.24 KB
/
ufo.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
0 => int C;
2 => int D;
4 => int E;
5 => int F;
7 => int G;
9 => int A;
11 => int B;
0 => int position;
fun void ufo_1( dur beat ) // 隨機和弦 0.375
{
SinOsc s => ADSR env1 => dac;
SinOsc s2 => env1;
SinOsc s3 => env1;
( beat , beat * 5 , 0 , 1::ms ) => env1.set;
while(1)
{
0.125 + position / 100 => s.gain;
0.125 + position / 100 => s2.gain;
0.125 + position / 100 => s3.gain;
Std.mtof( position + Math.random2( 48 , 60 ) ) => s.freq;
Std.mtof( position + Math.random2( 48 , 60 ) ) => s2.freq;
Std.mtof( position + Math.random2( 48 , 60 ) ) => s3.freq;
env1.keyOn();
beat * Math.random2f( 3 , 6 ) => now;
env1.keyOff();
Math.random2f( 0 , 6 ) * beat => now;
}
}
fun void ufo_2( dur beat ) // 隨機兩音 0.025
{
SinOsc s => ADSR env1 => dac;
( 1::ms , beat * 3 , .1 , 1::ms ) => env1.set;
0.025 => s.gain;
while(1)
{
Std.mtof( position + Math.random2( 65 , 83 ) ) => s.freq;
env1.keyOn();
beat * Math.random2f( 1 , 3 ) => now;
env1.keyOff();
Std.mtof( position + Math.random2( 65 , 83 ) ) => s.freq;
env1.keyOn();
beat * Math.random2f( 1 , 3 ) => now;
env1.keyOff();
Math.random2f( 0 , 7 ) * beat => now;
}
}
fun void ufo_3( dur beat ) // 滴滴聲 0.04
{
TriOsc s => ADSR env1 => dac;
TriOsc c => env1;
( 1::ms , beat / 8 , .2 , 1::ms ) => env1.set;
0.03 => s.gain;
0.015 => c.gain;
Std.mtof( 84 + B ) => s.freq;
Std.mtof( 96 + F ) => c.freq;
while(1)
{
for( 0 => int i ; i < 2 ; i++ )
{
env1.keyOn();
beat / 8 => now;
env1.keyOff();
}
beat * 4 => now;
}
}
fun void ufo_4( dur beat ) //長低音 0.4
{
TriOsc s => ADSR env1 => dac;
( beat * 3 , beat * 6 , .3 , 1::ms ) => env1.set;
while(1)
{
0.3 + position / 100 => s.gain;
Std.mtof( Math.random2( 36 , 48 ) ) => s.freq;
env1.keyOn();
beat * Math.random2f( 7 , 9 ) => now;
env1.keyOff();
}
}
fun void ufo_5( dur beat ) // 短7音和弦 0.015 ~ 0.035 * 7 ~= 0.2
{
SinOsc s[7];
ADSR env1 => dac;
for( 0 => int i ; i < 7 ; i++ )
{
s[i] => env1;
}
while(1)
{
( 1::ms , beat / ( 4 + position / 3 ) , 0 , 1::ms ) => env1.set;
for( 0 => int i ; i < 7 ; i++ )
{
for( 0 => int i ; i < 7 ; i++ )
{
Math.random2f( 0.02 , 0.035 ) + ( position / 30 ) => s[i].gain;
}
Std.mtof( position + Math.random2( 60 , 72 ) ) => s[i].freq;
env1.keyOn();
beat / Math.random2f( 4 + position / 3 , 7 + position / 3 ) => now;
env1.keyOff();
}
}
}
fun void p( dur beat )
{
while( 1 )
{
beat * 5 => now;
position ++;
<<< position >>>;
if( position == 20 ) 0 => position;
}
}
1 :: second => dur beat;
spork ~ ufo_1( beat );
spork ~ ufo_2( beat );
spork ~ ufo_3( beat );
spork ~ ufo_4( beat );
spork ~ ufo_5( beat );
spork ~ p( beat );
10 :: minute => now;