This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
song.js
373 lines (364 loc) · 8.29 KB
/
song.js
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
// http://sb.bitsnbites.eu/?data=U0JveAsC7d2xihNRFADQO2-SSCCVYJciYGHlB-hWgo1gsdiLiDY2VllQlmWnEEPcbFwIiIisYO8X2ASUgH_lRBMN4y4plGQHz4HJffe9Idy8zDS5hJnuRrR7qSgiFaPLEaez0_ghNSN6Ebc6Wcry-dFoxlYcLOKLRRwuF0ZRC_urNZf6i_hsK9V0ur-G3c4Z6zd-T3ZmZ9Zfs-3_o_Zh1Eu13kHN698PAAAAAAD4e5NKXv39_G0lf1XJ31fy8YbrT9Mii-m8N9fd_Vzmo_ayN3cpK9P5kS7KXg9qfq0M3S4AAAAAAAD_tfxrP_LZYTk6vPNm3odrZvnRpyudl3k0ludkW-rOrfayzvuv1vE541UnlXy84fqX8fUiDiqf6bgyf1Sp-6TyPmOXLQAAAAAAQC2lh3uRnvTbEY92DiLyncjy6_dSb9B4kG-7tndr1j-sWf_o6wUAAAAAAOAiub-Xxe2nkUWjdfXnTMoju3Z35Rlz2ZZKm6yJAAAAAAAAUCfpcRH5t6IcNVs3y9cvrSwNInqT1vOW3QEAAAAAAIB_R28OAAAAAAAANkNvDgAAAAAAADbjOw
// This music has been exported by SoundBox. You can use it with
// http://sb.bitsnbites.eu/player-small.js in your own product.
// See http://sb.bitsnbites.eu/demo.html for an example of how to
// use it in a demo.
function loadSong() {
info = "loading music... 0%";
setTimeout(function() {
loadingStart = Date.now();
// load music
mp = new CPlayer();
mp.init(song);
genSound();
},500); // give time to display message
}
// load music
function genSound() {
var progress =mp.generate();
info = "loading music... " + Math.floor(progress * 100) + "%";
if (progress <1) {
if (Date.now()-loadingStart > progress * 20000) {
// too slow
info = "device is too slow to synthesize music";
setTimeout(function() {info=null;}, 5000);
localStorage.musicOn = 0;
} else {
setTimeout(genSound, 100);
}
} else {
info = null;
// Put the generated song in an Audio element.
var wave = mp.createWave();
backgroundMusic = document.createElement("audio");
backgroundMusic.src = URL.createObjectURL(new Blob([wave], {type: "audio/wav"}));
backgroundMusic.loop = true;
if (localStorage.musicOn == 1) {
backgroundMusic.play();
}
}
}
// Song data
var song = {
songData: [
{ // Instrument 0
i: [
2, // OSC1_WAVEFORM
128, // OSC1_VOL
128, // OSC1_SEMI
0, // OSC1_XENV
2, // OSC2_WAVEFORM
128, // OSC2_VOL
140, // OSC2_SEMI
18, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
158, // ENV_ATTACK
198, // ENV_SUSTAIN
158, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
0, // LFO_WAVEFORM
0, // LFO_AMT
0, // LFO_FREQ
0, // LFO_FX_FREQ
2, // FX_FILTER
5, // FX_FREQ
0, // FX_RESONANCE
0, // FX_DIST
32, // FX_DRIVE
0, // FX_PAN_AMT
0, // FX_PAN_FREQ
65, // FX_DELAY_AMT
12 // FX_DELAY_TIME
],
// Patterns
p: [1,2,1,3,1,2,1,3,4,5],
// Columns
c: [
{n: [125,,,,,,,,132,,,,,,,,137,,,,,,,,,140],
f: []},
{n: [123,,,,137,,,,,,,,,,,,116,,,,,,,,120],
f: [,,,,,,,,,,,,,,12,28,,,,,,,,,,28,12,,,,,,,,,,,,,,,,,,,,57,12,,,,,,,,,,12,198]},
{n: [123,,,,137,,,,,,,,,,,,,,,,,,,,140],
f: []},
{n: [137,,,,,,,,,,,,,,,,137],
f: []},
{n: [137,,,,,,,,,,,,,,,,135],
f: []}
]
},
{ // Instrument 1
i: [
2, // OSC1_WAVEFORM
192, // OSC1_VOL
128, // OSC1_SEMI
1, // OSC1_XENV
0, // OSC2_WAVEFORM
192, // OSC2_VOL
140, // OSC2_SEMI
18, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
28, // ENV_ATTACK
80, // ENV_SUSTAIN
187, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
0, // LFO_WAVEFORM
140, // LFO_AMT
9, // LFO_FREQ
0, // LFO_FX_FREQ
2, // FX_FILTER
5, // FX_FREQ
0, // FX_RESONANCE
0, // FX_DIST
32, // FX_DRIVE
0, // FX_PAN_AMT
0, // FX_PAN_FREQ
7, // FX_DELAY_AMT
1 // FX_DELAY_TIME
],
// Patterns
p: [,,,1,,,,2],
// Columns
c: [
{n: [,,,,,,,,,,,,,,,,135],
f: []},
{n: [,,,,,,,,,,,,,,,,137],
f: []}
]
},
{ // Instrument 2
i: [
3, // OSC1_WAVEFORM
196, // OSC1_VOL
116, // OSC1_SEMI
0, // OSC1_XENV
3, // OSC2_WAVEFORM
198, // OSC2_VOL
127, // OSC2_SEMI
0, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
127, // ENV_ATTACK
73, // ENV_SUSTAIN
150, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
2, // LFO_WAVEFORM
0, // LFO_AMT
5, // LFO_FREQ
1, // LFO_FX_FREQ
3, // FX_FILTER
139, // FX_FREQ
173, // FX_RESONANCE
21, // FX_DIST
12, // FX_DRIVE
134, // FX_PAN_AMT
3, // FX_PAN_FREQ
0, // FX_DELAY_AMT
4 // FX_DELAY_TIME
],
// Patterns
p: [,,,,,,,,1,2],
// Columns
c: [
{n: [137,,,,,,,,,,,,140,,,,,,,,,,,,,,,,,,,,,,,,141,,,,,,,,,,,,141,,,,,,,,,,,,,,,,,,,,,,,,144,,,,,,,,,,,,,,,,142],
f: []},
{n: [137,,,,,,,,137,,,,,,,,143,,,,,,,,135,,,,,,,,140,,,,,,,,141,,,,,,,,135,,,,,,,,139,,,,,,,,144,,,,,,,,144,,,,,,,,137,,,,,,,,142],
f: []}
]
},
{ // Instrument 3
i: [
2, // OSC1_WAVEFORM
97, // OSC1_VOL
117, // OSC1_SEMI
0, // OSC1_XENV
2, // OSC2_WAVEFORM
105, // OSC2_VOL
116, // OSC2_SEMI
9, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
99, // ENV_ATTACK
59, // ENV_SUSTAIN
125, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
3, // LFO_WAVEFORM
59, // LFO_AMT
0, // LFO_FREQ
1, // LFO_FX_FREQ
3, // FX_FILTER
45, // FX_FREQ
82, // FX_RESONANCE
2, // FX_DIST
32, // FX_DRIVE
135, // FX_PAN_AMT
4, // FX_PAN_FREQ
95, // FX_DELAY_AMT
3 // FX_DELAY_TIME
],
// Patterns
p: [],
// Columns
c: [
]
},
{ // Instrument 4
i: [
0, // OSC1_WAVEFORM
93, // OSC1_VOL
117, // OSC1_SEMI
1, // OSC1_XENV
0, // OSC2_WAVEFORM
68, // OSC2_VOL
110, // OSC2_SEMI
0, // OSC2_DETUNE
1, // OSC2_XENV
0, // NOISE_VOL
4, // ENV_ATTACK
6, // ENV_SUSTAIN
35, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
0, // LFO_WAVEFORM
0, // LFO_AMT
0, // LFO_FREQ
0, // LFO_FX_FREQ
2, // FX_FILTER
3, // FX_FREQ
0, // FX_RESONANCE
1, // FX_DIST
39, // FX_DRIVE
76, // FX_PAN_AMT
5, // FX_PAN_FREQ
0, // FX_DELAY_AMT
0 // FX_DELAY_TIME
],
// Patterns
p: [,,,,,,,,1],
// Columns
c: [
{n: [147,,,,,,,,147,,,,,,,,147,,,,,,,,147],
f: []}
]
},
{ // Instrument 5
i: [
2, // OSC1_WAVEFORM
100, // OSC1_VOL
128, // OSC1_SEMI
0, // OSC1_XENV
3, // OSC2_WAVEFORM
201, // OSC2_VOL
128, // OSC2_SEMI
0, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
5, // ENV_ATTACK
6, // ENV_SUSTAIN
58, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
0, // LFO_WAVEFORM
195, // LFO_AMT
6, // LFO_FREQ
1, // LFO_FX_FREQ
2, // FX_FILTER
135, // FX_FREQ
0, // FX_RESONANCE
0, // FX_DIST
32, // FX_DRIVE
147, // FX_PAN_AMT
6, // FX_PAN_FREQ
121, // FX_DELAY_AMT
6 // FX_DELAY_TIME
],
// Patterns
p: [],
// Columns
c: [
]
},
{ // Instrument 6
i: [
2, // OSC1_WAVEFORM
100, // OSC1_VOL
128, // OSC1_SEMI
0, // OSC1_XENV
3, // OSC2_WAVEFORM
201, // OSC2_VOL
128, // OSC2_SEMI
0, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
5, // ENV_ATTACK
6, // ENV_SUSTAIN
58, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
0, // LFO_WAVEFORM
195, // LFO_AMT
6, // LFO_FREQ
1, // LFO_FX_FREQ
2, // FX_FILTER
135, // FX_FREQ
0, // FX_RESONANCE
0, // FX_DIST
32, // FX_DRIVE
147, // FX_PAN_AMT
6, // FX_PAN_FREQ
121, // FX_DELAY_AMT
6 // FX_DELAY_TIME
],
// Patterns
p: [],
// Columns
c: [
]
},
{ // Instrument 7
i: [
2, // OSC1_WAVEFORM
100, // OSC1_VOL
128, // OSC1_SEMI
0, // OSC1_XENV
3, // OSC2_WAVEFORM
201, // OSC2_VOL
128, // OSC2_SEMI
0, // OSC2_DETUNE
0, // OSC2_XENV
0, // NOISE_VOL
5, // ENV_ATTACK
6, // ENV_SUSTAIN
58, // ENV_RELEASE
0, // ARP_CHORD
0, // ARP_SPEED
0, // LFO_WAVEFORM
195, // LFO_AMT
6, // LFO_FREQ
1, // LFO_FX_FREQ
2, // FX_FILTER
135, // FX_FREQ
0, // FX_RESONANCE
0, // FX_DIST
32, // FX_DRIVE
147, // FX_PAN_AMT
6, // FX_PAN_FREQ
121, // FX_DELAY_AMT
6 // FX_DELAY_TIME
],
// Patterns
p: [],
// Columns
c: [
]
}
],
rowLen: 20672, // In sample lengths
patternLen: 32, // Rows per pattern
endPattern: 11 // End pattern
};