Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > midi scheduler in ruby

Reply
Thread Tools

midi scheduler in ruby

 
 
Gaspard Bucher
Guest
Posts: n/a
 
      09-25-2007
I am writing ruby wrappers around rtMidi
(http://www.music.mcgill.ca/~gary/rtmidi/) and need to trigger "note
off".

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 ]
[wait ]
[note off]

1. What is the best way to implement such a scheduler ?

2. Should I create a thread in C that checks for events in a buffer ?

3. Should this scheduler be implemented in Ruby ?
class Scheduler
def initialize
@events = []
Thread.new
while(true) do
sleep 0.01 # ?
if @events[0] && @events[0].time >= Time.now
@events.shift.trigger
end
end
end
end

def <<(e)
i = 0
while(@events[i] && e.time <= @events[i])
i += 1
end
if @events[i]
@events[i..i] << [e, i]
else
@events << e
end
end
end

Many thanks for your insight.

Gaspard

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dotnet scheduler like the Windows "Schedued Tasks" scheduler? Codemonkey ASP .Net 8 06-10-2011 10:53 AM
Portable midi communication with external midi instruments? Asbjørn Bjørnstad Java 0 10-09-2008 03:03 PM
Real Time Midi File Playback - Reading and Writing midi at the sametime Gilly Python 6 05-04-2008 09:16 PM
D/L midi files launches a midi player I want the midi file Vlad Firefox 2 06-10-2005 02:25 AM
Java MIDI output device to MIDI Yoke. Hugo Villeneuve Java 0 07-04-2003 10:31 PM



Advertisments