#! /usr/bin/env ruby

require 'smf'
include  SMF

class Array; def rand() self[Kernel.rand(self.size)] end end

sq = Sequence.new
tr = Track.new
sq << tr
tr << SequenceName.new(0, 'rand2')
srand
for ch in 0..2
  offset = 0
  for i in 0..127
    note = [0, 2, 4, 5, 7, 9, 10].rand
    note += (rand(1) + 4 + ch) * 12
    vel  = rand(127) + 1
    tr << NoteOn. new(offset, ch, note, vel)
    offset += [12, 24, 48, 96, 192, 384].rand
    tr << NoteOff.new(offset, ch, note, 64)
  end
end
sq.save('rand2.mid')
