Permalink
Browse files

Fix race condition between noteons and noteoffs in MIDI::Player.

  • Loading branch information...
1 parent b7a6530 commit 484efa57bcc1b889714d81e94c4d0ac482df8de4 Jeremy Voorhis committed Dec 10, 2008
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/music/midi/player.rb
View
@@ -1,5 +1,5 @@
-require 'midiator'
require 'rubygems'
+require 'midiator'
require 'gamelan'
module Music
@@ -50,7 +50,9 @@ def play(timeline_or_score, blocking = false)
private
def play_note(scheduler, time, note)
att = time
- rel = time + note.duration
+ # hack to ensure noteoffs are performed before ensuing noteons.
+ # FIXME: implement priorities in the scheduler.
+ rel = time + note.duration - scheduler.rate
chn = note.fetch(:channel, 1)
vel = note.fetch(:velocity, 64)
pit = note.pitch.to_i

0 comments on commit 484efa5

Please sign in to comment.