(eval-when-compile
  (require 'cl))

(defun midimacs-keyboard-notes ()
  '((?z . C2)
    (?s . Cs2)
    (?x . D2)
    (?d . Ds2)
    (?c . E2)
    (?v . F2)
    (?g . Fs2)
    (?b . G2)
    (?h . Gs2)
    (?n . A2)
    (?j . As2)
    (?m . B2)
    (?, . C3)
    (?l . Cs3)
    (?. . D3)
    (?\; . Ds3)
    (?/ . E3)
    (?q . C3)
    (?2 . Cs3)
    (?w . D3)
    (?3 . Ds3)
    (?e . E3)
    (?r . F3)
    (?5 . Fs3)
    (?t . G3)
    (?6 . Gs3)
    (?y . A3)
    (?7 . As3)
    (?u . B3)
    (?i . C4)
    (?9 . Cs4)
    (?o . D4)
    (?0 . Ds4)
    (?p . E4)
    (?\[ . F4)
    (?+ . Fs4)
    (?\] . G4)))

(defun midimacs-record-key (pitch)
  (let* ((song-time (midimacs-quantized-song-time))
         (duration midimacs-default-recording-duration)
         (channel (midimacs-score-channel midimacs-recording-score))
         (start-time (midimacs-score-start-time midimacs-recording-score))
         (rel-time (midimacs-time- song-time start-time)))

    (when (midimacs-time> rel-time (make-midimacs-time))
      (midimacs-play-note channel pitch duration)
      (midimacs-add-note-to-score midimacs-recording-score rel-time pitch duration))))


(provide 'midimacs-keyboard)
