;; https://en.wikipedia.org/wiki/Scientific_pitch_notation
;; e.g. Eb3.aiff -> E flat 3 (which is midi note 51)
(define scientific-pitch-notation-to-midi-number
(lambda (name)
(let ((result (regex:matched name "^([abcdefgABCDEFG])([#b])?(-?[0-9])$")))
(if (null? result)
#f
(let ((offset (+ 12 (* (string->number (cadddr result)) 12)))
(pc (case (modulo (- (modulo (char->integer (car (string->list (cadr result)))) 16) 3) 7)
((0) 0) ((1) 2) ((2) 4) ((3) 5) ((4) 7) ((5) 9) ((6) 11))))
(+ offset pc
(cond ((string=? (caddr result) "#") 1)
((string=? (caddr result) "b") -1)
(else 0))))))))