 brightness = 1.0
 spinRate = 1.0
 
-midiTime = 0
 previousNow = 0
 spinAngle = 0
 
+# Time clock in seconds
+clock = () -> 0.001 * new Date().getTime()
+
+# Midi to frequency
+midiToHz = (key) -> 440 * Math.pow 2, (key - 69) / 12
+
+# Midi note to angle, one rev per octave
+midiToAngle = (key) -> (2 * Math.PI / 12) * key
+
+
 input.on 'message', (deltaTime, message) ->
-
-    # Keep time
-    midiTime += deltaTime
+    console.log message
 
     switch message[0]
         when 0x80  # Voice 0, note off

            info =
                key: key
                velocity: message[2]
                timestamp: midiTime

            # Split keyboard into particles and LFOs
            if key >= 60

        when 0xb0  # Voice 0, Control Change
            switch message[1]
                when 7   # "Data entry" slider, brightness
                    brightness = message[2] * 2.0 / 127

                when 1   # "Modulation" slider, particle speed
                    particleLifetime = 0.1 + message[2] * 2.0 / 127
