-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsweet-dreams.rb
143 lines (132 loc) · 4.47 KB
/
sweet-dreams.rb
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
require './lib/synth.rb'
bpm = 140
drum_synth = Instrument.new(bpm, NoiseOscillator.new(44100, 123.0, 0.6), [], nil, nil)
bass_synth = Instrument.new(bpm, SawtoothOscillator.new(44100, 123.0, 0.3), [1.0], nil, nil)
voice_synth = Instrument.new(bpm, SineOscillator.new(44100, 220.0, 1.0), [0.1, 0.4], nil, nil)
drums = Track.new(drum_synth)
24.times do
drums.notes << Note.new(:_, 0, 4)
drums.notes << Note.new(:a, 0, 16)
drums.notes << Note.new(:_, 0, 16)
drums.notes << Note.new(:_, 0, 8)
end
bass = Track.new(bass_synth)
6.times do
bass.notes << Note.new(:a, 0, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 1, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 2, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 2, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:c, 1, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:c, 2, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 1, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 2, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:f, 0, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:f, 0, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:f, 1, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 2, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:e, 0, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:e, 0, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:e, 1, 16)
bass.notes << Note.new(:_, 1, 16)
bass.notes << Note.new(:a, 2, 16)
bass.notes << Note.new(:_, 1, 16)
end
voice = Track.new(voice_synth)
4.times do
voice.notes << Note.new(:_, 1, 1)
end
voice.notes << Note.new(:_, 1, 4)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:_, 4, 16)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:_, 4, 16)
voice.notes << Note.new(:a, 4, 4)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:_, 4, 16)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:b, 4, 2)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:a, 4, 8)
voice.notes << Note.new(:c, 4, 4)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:a, 4, 16)
voice.notes << Note.new(:a, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:a, 4, 16)
voice.notes << Note.new(:a, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:d, 4, 4)
voice.notes << Note.new(:d, 4, 16)
voice.notes << Note.new(:_, 4, 16)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:b, 4, 8)
voice.notes << Note.new(:_, 4, 8)
voice.notes << Note.new(:a, 4, 8)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:a, 4, 8)
voice.notes << Note.new(:c, 4, 4)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:a, 4, 16)
voice.notes << Note.new(:a, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:a, 4, 16)
voice.notes << Note.new(:a, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:b, 4, 4)
voice.notes << Note.new(:_, 4, 4)
voice.notes << Note.new(:c, 4, 4)
voice.notes << Note.new(:a, 4, 8)
voice.notes << Note.new(:c, 4, 4)
voice.notes << Note.new(:a, 4, 4)
voice.notes << Note.new(:a, 4, 8)
voice.notes << Note.new(:c, 4, 16)
voice.notes << Note.new(:c, 4, 32)
voice.notes << Note.new(:_, 4, 32)
voice.notes << Note.new(:c, 4, 8)
voice.notes << Note.new(:d, 4, 8)
voice.notes << Note.new(:c, 4, 4)
voice.notes << Note.new(:b, 4, 4)
s = Song.new()
s.tracks = [drums, bass, voice]
wave = WaveFile.new(1, 44100, 8)
wave.sample_data = s.next_samples(s.sample_length)
wave.save $0[0..-3] + 'wav'