anchor.diff:    (coerce (+ (- (ensure-pitch tuning) 440.0d0)
                (* 440.0d0 (expt 2.0d0 (/ (- (ensure-piano-key key) 49.0d0) 12.0d0))))
             'single-float))
  +
  +(defun pitch->piano-key (pitch &key (tuning 440.0d0))
  +  (let ((pitch (ensure-double-float (- pitch (- 440.0d0 tuning)))))
  +    (let* ((key (round (+ 49.0d0 (/ (* 12.0d0 (log (/ pitch 440.0d0))) (log 2.0d0)))))
  +           (offset (- pitch (piano-key->pitch key :tuning tuning))))
  +      (values key (if (< (abs offset) 0.001d0) 0.0 (/ (round (* offset 1000.0)) 1000.0))))))
  +
  +(defun piano-key->notation (key &key (notation 'english))
  +  (unless (<= 1 key 88) (error (format NIL "Invalid key: ~a" key)))
  +  (cond
  +    ((< key 4)
  +     (notation (if (= key 3) #\B #\A) 0 :sharp-p (= key 2) :notation notation))
  +    ((= key 88) (notation #\C 8 :notation notation))
  +    (T (let ((key-of-octave (mod (- key 3) 12))
  +             (black-keys '(2 4 7 9 11)))
  +         (when (= 0 key-of-octave) (setf key-of-octave 12))
  +         (notation (note-from-order (- key-of-octave (length (loop for black in black-keys
  +                                                                   until (< key-of-octave black)
  +                                                                   collecting black))))
  +                   (floor (+ key 8) 12)
  +                   :sharp-p (find key-of-octave black-keys)
  +                   :notation notation)))))
  +
  +(defun pitch->notation (pitch &key (tuning 440.0d0) (notation 'english))
  +  (multiple-value-bind (key offset)
  +      (pitch->piano-key pitch :tuning tuning)
  +    (values (piano-key->notation key :notation notation) offset)))
  
positive.code: (in-package #:thelonious)
  
  (define-condition invalid-key-notation-error (error)
    ((text :initarg :text :reader text)))
  
negative.code:       (#\A 6)
        ((#\B #\H) 7))))
  
  (defun note-from-order (number &key (notation 'english))
    (ecase number
      (1 #\C)
      (2 #\D)
      (3 #\E)
      (4 #\F)
      (5 #\G)
      (6 #\A)
      (7 (ecase notation
           (english #\B)
           (german #\H)))))
  
  (defun notation (note octave &key flat-p sharp-p (notation 'english))
    (ecase notation
      (english (format NIL "~a~a~a"
                       note (cond (flat-p #\u266D) (sharp-p #\#) (T "")) octave))))
  
  (defun ensure-piano-key (key)
    (cond
      ((typep key 'integer) key)
  