         subtype: "noteOn"
         noteNumber: note
         velocity: 64
-  
+
       noteOffEvent =
         channel: 0
         type: "channel"
         subtype: "noteOff"
         noteNumber: note
-  
-      player?.handleEvent noteOnEvent, time: t + time
-      player?.handleEvent noteOffEvent, time: t + time
+
+      player.handleEvent noteOnEvent, time: now + time
+      player.handleEvent noteOffEvent, time: now + time + 0.25
 
 document.addEventListener "visibilitychange", (e) ->
   if document.hidden

  t = context.currentTime - timeOffset
  player.consumeEventsUntilTime(t + LOOKAHEAD)

consumeSequencer = ->
  return unless sequencer
  t = context.currentTime - timeOffset

  sTime = sequencerState.time
  timeSlice = t + LOOKAHEAD - sTime

  if timeSlice > 0
    sequencerState.time = t + LOOKAHEAD

    sequencer.notesAfter(sTime).filter ([time]) ->
      time < timeSlice
    .forEach ([time, note]) ->
      console.log t + time, note

      noteOnEvent =
        channel: 0

  # Download wav

sequencer = null

do ->
  Sequencer = require "./sequencer"
