-
Notifications
You must be signed in to change notification settings - Fork 6
/
generate-samples.js
97 lines (94 loc) · 4.36 KB
/
generate-samples.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
const durations = require('./src/durations.js');
const MelodyQueue = require('./src/MelodyQueue.js');
const waveGenerator = require('./src/WaveGenerator.js');
const note = require('./src/note.js');
let melody1 = new MelodyQueue();
melody1.enqueueTone(durations.Q, note('G4'));
melody1.enqueueTone(durations.Q, note('E4'));
melody1.enqueueTone(durations.Q, note('E4'));
melody1.enqueueTone(durations.Q, note('F4'));
melody1.enqueueTone(durations.Q, note('D4'));
melody1.enqueueTone(durations.Q, note('D4'));
melody1.enqueueTone(durations.E, note('C4'));
melody1.enqueueTone(durations.E, note('E4'));
melody1.enqueueTone(durations.E, note('G4'));
waveGenerator.save('./kotek.wav', melody1);
let melody2 = new MelodyQueue();
melody2.enqueueTone(durations.H, note('C4'));
melody2.enqueueTone(durations.H, note('G4'));
melody2.enqueueTone(durations.E, note('F4'));
melody2.enqueueTone(durations.E, note('E4'));
melody2.enqueueTone(durations.E, note('D4'));
melody2.enqueueTone(durations.H, note('C5'));
melody2.enqueueTone(durations.H, note('G4'));
melody2.enqueueTone(durations.E, note('F4'));
melody2.enqueueTone(durations.E, note('E4'));
melody2.enqueueTone(durations.E, note('D4'));
melody2.enqueueTone(durations.H, note('C5'));
melody2.enqueueTone(durations.H, note('G4'));
melody2.enqueueTone(durations.E, note('F4'));
melody2.enqueueTone(durations.E, note('E4'));
melody2.enqueueTone(durations.E, note('F4'));
melody2.enqueueTone(durations.H, note('D4'));
waveGenerator.save('./starwars.wav', melody2);
let melody3 = new MelodyQueue(durations.HT);
melody3.setAutoPause(durations.HT);
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'), note('G4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
melody3.enqueueTone(durations.E, note('C4'), note('E4'));
for (let i = 0; i < 14; ++i) {
melody3.enqueueTone(i == 7 ? durations.H : durations.E, [note('B3'), note('D4'), note('E4')]);
}
melody3.setAutoPause(0);
melody3.enqueuePause(durations.T);
melody3.enqueueTone(durations.Q, note('E4'));
melody3.enqueueTone(durations.Q, note('G4'));
melody3.enqueueTone(durations.H, note('A4'));
melody3.enqueuePause(durations.HT);
melody3.enqueueTone(durations.Q, note('A4'));
melody3.enqueueTone(durations.Q, note('B4'));
melody3.enqueueTone(durations.H, note('E4'));
melody3.enqueuePause(durations.HT);
melody3.enqueueTone(durations.Q, note('E4'));
melody3.enqueueTone(durations.Q, note('G4'));
melody3.enqueueTone(durations.H, note('A4'));
melody3.enqueuePause(durations.HT);
melody3.enqueueTone(durations.Q, note('A4'));
melody3.enqueueTone(durations.Q, note('B4'));
melody3.enqueueTone(durations.H, note('E4'));
melody3.enqueuePause(durations.HT);
melody3.enqueueTone(durations.E, note('D4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('D4'));
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, note('D4'));
melody3.enqueueTone(durations.H, note('E4'));
melody3.setAutoPause(durations.HT);
melody3.enqueueTone(durations.E, note('C4'));
melody3.enqueueTone(durations.E, [note('B3'), note('C4')]);
melody3.enqueueTone(durations.E, [note('B3'), note('C4')]);
melody3.enqueueTone(durations.E, [note('A3'), note('C4')]);
melody3.enqueueTone(durations.E, [note('A3'), note('C4')]);
melody3.enqueueTone(durations.E, [note('G3'), note('C4')]);
melody3.enqueueTone(durations.E, [note('C4'), note('F4')]);
melody3.enqueueTone(durations.H, [note('B3'), note('E4')]);
waveGenerator.save('./rocky.wav', melody3);