-
Notifications
You must be signed in to change notification settings - Fork 0
/
sweet-child-o-mine.rb
55 lines (50 loc) · 1.47 KB
/
sweet-child-o-mine.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
require './lib/synth.rb'
bpm = 140
lead_synth = Instrument.new(bpm, SquareOscillator.new(44100, 220.0, 0.2), [], nil, nil)
lead = Track.new(lead_synth)
2.times {
lead.notes << Note.new(:a, 3, 8)
lead.notes << Note.new(:a, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:d, 3, 8)
lead.notes << Note.new(:d, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:cs, 4, 8)
lead.notes << Note.new(:e, 3, 8)
}
2.times {
lead.notes << Note.new(:b, 3, 8)
lead.notes << Note.new(:a, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:d, 3, 8)
lead.notes << Note.new(:d, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:cs, 4, 8)
lead.notes << Note.new(:e, 3, 8)
}
2.times {
lead.notes << Note.new(:d, 3, 8)
lead.notes << Note.new(:a, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:d, 3, 8)
lead.notes << Note.new(:d, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:cs, 4, 8)
lead.notes << Note.new(:e, 3, 8)
}
2.times {
lead.notes << Note.new(:a, 3, 8)
lead.notes << Note.new(:a, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:d, 3, 8)
lead.notes << Note.new(:d, 4, 8)
lead.notes << Note.new(:e, 3, 8)
lead.notes << Note.new(:cs, 4, 8)
lead.notes << Note.new(:e, 3, 8)
}
lead.notes << Note.new(:a, 3, 2)
s = Song.new
s.tracks = [lead]
wave = WaveFile.new(1, 44100, 8)
wave.sample_data = s.next_samples(s.sample_length)
wave.save $0[0..-3] + 'wav'