forked from Gabrielg1976/ruby_music_projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_2.rb
48 lines (44 loc) · 1.21 KB
/
demo_2.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
require'music'
require'scales'
count=0
# Tryout with a four channel monotone setup
midi = LiveMIDI.new
a,b,d,e=rand(52)+33,rand(52)+33,rand(52)+33,rand(52)+33
3.times {
if a > b
puts "Phrase 1"
a.times do
count +=1
midi.note_on(ch=rand(4),nt=persian[rand(persian.length)],vlc=rand(75)+25)
sleep(rand(3)) # = 1 second of time 60 = minute
midi.note_off(ch,nt,0)
end
else
puts "Phrase 2"
b.times do
count+=1
midi.note_on(ch=rand(4),nt=leading_whole_tone[rand(leading_whole_tone.length)],vlc=rand(75)+25)
sleep(rand(2)+1)# = 1 second of time 60 = minute
midi.note_off(ch,nt,0)
end
end
if d > e
puts "Phrase 3"
e.times do
count +=1
midi.note_on(ch=rand(4),nt=hungarian_gypsy[rand(hungarian_gypsy.length)],vlc=rand(75)+25)
sleep(rand(3))# = 1 second of time 60 = minute
midi.note_off(ch,nt,0)
end
else
puts "Phrase 4"
d.times do
count+=1
midi.note_on(ch=rand(4),nt=mixolydian_aug[rand(mixolydian_aug.length)],vlc=rand(75)+25)
sleep(rand(2)+1)# = 1 second of time 60 = minute
midi.note_off(ch,nt,0)
end
end
}
puts "The Composition is Finished"
puts "The Total number of Notes Generated was" + " " + "#{count}"