Skip to content

Instantly share code, notes, and snippets.

@kevindjacobson
Created January 23, 2015 06:55
Show Gist options
  • Save kevindjacobson/824f91b9f22f2daf28c9 to your computer and use it in GitHub Desktop.
Save kevindjacobson/824f91b9f22f2daf28c9 to your computer and use it in GitHub Desktop.
require "midi"
require "eventmachine"
# prompt the user to select an input and output
EventMachine.run do
@input = UniMIDI::Input.gets
@output = UniMIDI::Output.gets
EventMachine.set_timer_quantum(10);
MIDI.using(@output) do
@cc_timer = EventMachine::PeriodicTimer.new(0.02) do
@count ||= 1
@count += 1
@count %= 127
@count = 1 if @count == 0
puts @count
cc 1, @count
cc 93, 127 - @count
end
@note_timer = EventMachine::PeriodicTimer.new(60/ 150.0) do
off
octave 3
note %w{D F G Ab A C D}[rand(7)]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment