;; returns the type of scale given a pc or the pc itself
;; if no known scale is found
(define pc:scale-from-pc
(lambda (pc)
(let ((scale (let loop ((scale pc)
(ivls '()))
(if (null? (cdr scale))
(reverse ivls)
(loop (cdr scale) (cons (let ((v (- (cadr scale) (car scale))))
(if (< v 0)
(+ 12 v)
v)) ivls))))))
(let check ((scales *pc:scales*))
(if (null? scales)
pc
(if (equal? scale (cdar scales))
(caar scales)
(check (cdr scales))))))))