-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound-narrative.ck
142 lines (123 loc) · 8.55 KB
/
sound-narrative.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
133
134
135
136
137
138
139
140
141
142
// Set the tempo (slow)
20 => float bpm; // Adjust the tempo as needed
// Initialize instruments with a richer timbre
SqrOsc instrument1 => ADSR instrument1ADSR => Gain instrument1Gain => dac;
SqrOsc instrument2 => ADSR instrument2ADSR => Gain instrument2Gain => dac;
Flute flute => ADSR fluteADSR => Gain fluteGain => dac;
// Define note frequencies in Hz for each instrument
[ 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 600.00, 440.0, 440.0, 440.0, 1.00, 293.66, 392.00, 440.00, 293.66, 392.00, 440.00, 293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 1.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
293.66, 392.00, 1.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 293.66, 220.00, 329.63, 349.23, 392.00, 440.00, 293.66,
220.00, 246.94, 277.18, 261.63, 293.66, 329.63, 349.23, 392.00, 440.00,
493.88, 523.25, 587.33, 659.26, 523.25, 440.00, 493.88, 783.99, 880.00,
987.77, 1.00, 1046.50, 987.77, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
349.23, 392.00, 440.00, 493.88, 523.25, 587.33, 659.26, 523.25, 440.00,
493.88, 1.00, 783.99, 880.00, 987.77, 1046.50, 987.77, 100, 100, 100, 100,
100, 200, 200, 200, 200, 200, 100, 100, 100, 100, 100, 200, 200, 200,
200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200,
100, 100, 100, 0.00, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 100, 200, 100, 200,
500, 100, 200, 100, 200, 500, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 293.66, 392.00, 440.00, 293.66, 392.00, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 250, 200, 100, 0, 600.00, 600.00, 600.00 ] @=> float instrument1Notes[];
[ 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 440.0, 440.0, 440.0, 200.00, 600.00, 200.00, 600.00, 600.00, 600.00, 293.66, 392.00, 440.00, 293.66, 392.00, 440.00, 293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 1.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
293.66, 392.00, 440.00, 440.00, 329.63, 0.00, 440.00, 440.00, 329.63, 349.23,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 1.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
349.23, 1.00, 392.00, 440.00, 493.88, 1.00, 523.25, 587.33, 659.26, 523.25, 440.00,
493.88, 783.99, 880.00, 987.77, 1046.50, 987.77, 329.63, 349.23, 392.00,
440.00, 261.63, 196.00, 220.00, 261.63, 196.00, 220.00, 261.63, 293.66,
329.63, 349.23, 392.00, 440.00, 493.88, 523.25, 440.00, 349.23, 392.00,
659.26, 698.46, 783.99, 880.00, 783.99, 100, 100, 100, 100, 100, 200,
200, 200, 200, 200, 100, 100, 100, 100, 100, 100, 200, 100, 200, 500, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 500, 500, 250, 200, 100, 0, 600.00 ,600.00, 600.00 ] @=> float instrument2Notes[];
[ 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 600.00, 600.00, 600.00, 600.00, 200, 1000, 1000, 1000, 1000, 200, 1000, 440.0, 440.0, 440.0, 20.00, 293.66, 392.00, 440.00, 293.66, 392.00, 440.00, 293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63, 293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
293.66, 392.00, 440.00, 440.00, 329.63, 440.00, 440.00, 329.63, 349.23,
220.00, 196.00, 220.00, 349.23, 220.00, 293.66, 220.00, 329.63, 349.23,
392.00, 440.00, 293.66, 220.00, 246.94, 277.18, 261.63, 293.66, 329.63,
349.23, 392.00, 440.00, 493.88, 523.25, 587.33, 659.26, 523.25, 440.00, 493.88,
783.99, 880.00, 987.77, 1046.50, 987.77, 329.63, 349.23, 392.00, 440.00, 246.94,
220.00, 246.94, 277.18, 220.00, 246.94, 277.18, 311.13, 349.23, 392.00, 440.00,
493.88, 554.37, 622.25, 493.88, 392.00, 440.00, 739.99, 880.00, 987.77, 1046.50,
987.77, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 200, 100, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 200, 200, 200, 200, 100, 100, 100, 293.66, 392.00, 440.00, 293.66, 392.00, 200, 200, 200,
200, 100, 100, 100, 200, 100, 100, 200, 100, 200, 500, 100, 200, 100, 200, 500, 250, 200, 100, 0, 600.00, 600.00, 600.00 ] @=> float fluteNotes[];
// Set the articulation parameters for the instrument1
100::ms => instrument1ADSR.attackTime;
300::ms => instrument1ADSR.decayTime;
0.5 => instrument1ADSR.sustainLevel;
400::ms => instrument1ADSR.releaseTime;
// Set the articulation parameters for the instrument2
100::ms => instrument2ADSR.attackTime;
300::ms => instrument2ADSR.decayTime;
0.5 => instrument2ADSR.sustainLevel;
400::ms => instrument2ADSR.releaseTime;
// Set the articulation parameters for the flute
100::ms => fluteADSR.attackTime;
400::ms => fluteADSR.decayTime;
0.7 => fluteADSR.sustainLevel;
400::ms => fluteADSR.releaseTime;
[1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1.0, 0.5, 0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 1] @=> float rhythmFloat[];
0 => int i;
0 => int j;
// Loop through the composition
while (true) {
// Play instrument1
instrument1Notes[i] => instrument1.freq;
instrument1ADSR.keyOn();
// Play instrument2
instrument2Notes[i] => instrument2.freq;
instrument2ADSR.keyOn();
// Play flute
fluteNotes[i] => flute.freq;
fluteADSR.keyOn();
// Control rhythm with floats
rhythmFloat[j] * 1::second => now;
// Release all instruments
instrument1ADSR.keyOff();
instrument2ADSR.keyOff();
fluteADSR.keyOff();
// Increment index
i + 1 => i;
// Increment index
j + 1 => j;
// Reset index when we reach the end of the melody
if (j >= rhythmFloat.cap()) {
0 => j;
}
// Reset index when we reach the end of the melody
if (i >= instrument1Notes.cap()) {
0 => i;
}
}