 
 state =
   activeLine: 0
+  moveNext: 0
 
 updateViz = ->
   viz.draw(canvas)

  switch
    when keyCode is 8
      state.toSet = 255
    when keyCode is 38
      state.activeLine -= 1
    when keyCode is 40
      state.activeLine += 1
    when 48 <= keyCode <= 57
      state.toSet = keyCode - 48 + 4 * 12
, false

document.addEventListener "mousedown", (e) ->

  # TODO: This should be done in terms of context.currentTime
  track.update(osc.frequency, osc.gain, trackTime, dt, state)

  state.activeLine += state.moveNext
  state.moveNext = 0

invariants = ->
  state.activeLine = state.activeLine % 16
  if state.activeLine < 0
