Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 9cc3d6a0e3
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (31 sloc) 0.897 kB
# Get all measures, so events can be mapped to measures:
require 'rubygems'
require 'midilib'
require 'midilib/sequence'
require 'rubymusicengine'
require 'scales'
=begin
This application generates a simple random midi file and then outputs the notes generated and
at what time it did each note
=end
def song_creator_and_display
seq = MIDI::Sequence.new()
s=[ ]
100.times {|n| s << lydian_min[rand(lydian_min.size)] }
s.to_midi("new_song1.mid")
# Then takes the new generated midi file and maps out the notes and time
File.open("new_song1.mid", 'rb') { | file | seq.read(file) }
measures = seq.get_measures
count=0
seq.each { | track |
track.each { | e |
if e.note_on? then
count = count + 1
e.print_note_names = true
# puts "the note #{count} was #{e.note_to_s}"
puts measures.to_mbt(e)+ " " + "#{e.note_to_s}"
end
}
}
end
song_creator_and_display
Jump to Line
Something went wrong with that request. Please try again.