Previous page: Daily Crap 2009-09-20
Next page: Daily Crap 2009-09-27


MIDI Helix

header graphic screenshot

An idea that had been rolling around in my head for a while was making some kind of visualization for Sonic the Hedgehog background music. I already have a library of Sonic MIDIs, so I wouldn't even have to manually notate the music.

Project Requirements
Languages/Environments Libraries
Ruby, ruby-processing midilib, OpenGL, Minim

I'm new to ruby-processing and I couldn't get gems to work inside my patch. So I exported timing information in a separate Ruby script:

require "rubygems"
require 'midilib/sequence'
require 'midilib/io/midifile'

DEFAULT_MIDI_TEST_FILE = 'Mushroom Hill Zone Act 2.mid'

seq = MIDI::Sequence.new()

File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb') { |file| seq.read(file) }

# turn any string into a stand-up filename
def namitize(name)
  name.gsub(/[^a-zA-Z ]/, "").strip.gsub(/ +/, "_").downcase
end

seq.each { |track|
  # ignore tracks with very few notes
  next if track.events.length < 7

  filename = "track.#{namitize track.name}.txt"
  puts "*** #{filename}"
  open(filename, "w") do |f|
    track.each do |e|
      if e.note?
        f.puts "#{e.time_from_start} #{e.channel} #{e.note} #{e.note_on? ? e.velocity : "0"}"
      end
    end
  end
}

And then, some visuals:

I posted the timing code previously in August 17th's Daily Crap.


Comments

Click here to view the comments on this post.