I am writing ruby wrappers around rtMidi
(http://www.music.mcgill.ca/~gary/rtmidi/) and need to trigger “note
This is the api I wish to implement:
@midiout = RtMidi.new(‘port name’)
note = 62
velocity = 100
duration = 0.25 # 1/4
@midiout.play(note, velocity, duration)
When a note is played, a first midi event is created for the velocity,
then, a little later a second for the note off:
[note on ]
What is the best way to implement such a scheduler ?
Should I create a thread in C that checks for events in a buffer ?
Should this scheduler be implemented in Ruby ?
@events = 
sleep 0.01 # ?
if @events && @events.time >= Time.now
i = 0
while(@events[i] && e.time <= @events[i])
i += 1
@events[i…i] << [e, i]
@events << e
Many thanks for your insight.