anchor.diff:                    :release-at 'release-midi-at)
   
   (enable-backend :midi)
  +
  +(export '(midi-truncate-clamp bipolar-1-to-midi unipolar-1-to-midi frequency-to-midi midi-panic set-cc-mapping get-cc-mapping))
  
positive.code: 
  (midihelper:start-midihelper)
  
  (defparameter *midi-channels-instruments* (make-list 16 :initial-element 0))
  
  ;;; backend functions
  
  
negative.code: 
  (defun play-midi (event &optional task)
    (declare (ignore task))
    (let* ((channel (midi-truncate-clamp (or (event-value event :channel) 0) 15))
           (pgm (midi-truncate-clamp (event-value event :instrument)))
           (note (midi-truncate-clamp (event-value event :midinote)))
           (velocity (unipolar-1-to-midi (event-value event :amp))) ;; FIX: maybe this shouldn't be linear?
           (time (local-time:timestamp+ (or (raw-event-value event :timestamp-at-start) (local-time:now))
                                        (truncate (* (or (raw-event-value event :latency) *latency*) 1000000000))
                                        :nsec))
           (extra-params (loop :for key :in (keys event)
                            :for cc-mapping = (get-cc-mapping key)
                            :if cc-mapping
                            :collect (list (car cc-mapping) (funcall (nth 3 cc-mapping) (event-value event key))))))
      (bt:make-thread (lambda ()
                        (sleep (local-time:timestamp-difference time (local-time:now)))
                        (when (and pgm
                                   (not (= pgm (nth channel *midi-channels-instruments*))))
                          (midihelper:send-event (midihelper:ev-pgmchange channel pgm)))
                        (loop :for i :in extra-params
                           :do (midihelper:send-event (midihelper:ev-cc channel (car i) (cadr i))))
                        (midihelper:send-event (midihelper:ev-noteon channel note velocity))
                        (sleep (dur-time (sustain event)))
                        (midihelper:send-event (midihelper:ev-noteoff channel note velocity)))
  