Sha256: 316ed0c8c8efce82a3e4bdc23657571f5bd642a6fddb72568dc4422e928485ea

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'rubyonacid/factories/example'

#This factory chooses notes, play durations, etc.
factory = RubyOnAcid::ExampleFactory.new
    
#This factory randomly resets the meta factory.
@resetter = RubyOnAcid::SkipFactory.new(:odds => 0.999)

begin
  require 'midiator'
rescue LoadError
  raise "It appears that MIDIator is not installed. 'sudo gem install midiator' to install it."
end

Thread.abort_on_exception = true

midi = MIDIator::Interface.new
midi.autodetect_driver

loop do
  midi.play(
    factory.get(:note, :min => 10, :max => 127).to_i,
    factory.get(:duration, :max => 0.1),
    factory.get(:channel, :max => 10).to_i,
    factory.get(:velocity, :max => 127)
  )
  factory.reset_assignments if @resetter.boolean(:reset)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyonacid-0.4.0 examples/midi.rb