Last active
September 17, 2018 19:49
-
-
Save aike/fc55b32807de1ab85d2506f3a9f3aafe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define $roots {| [0 "C"] [1 "C#"] [2 "D"] [3 "D#"] [4 "E"] [5 "F"] [6 "F#"] [7 "G"] [8 "G#"] [9 "A"] [10 "A#"] [11 "B"] |}) | |
(define $detect-root | |
(lambda [$notes] | |
roots_(modulo (car (sort notes)) 12))) | |
(define $detect-chord | |
(lambda [$notes] | |
(match (sort notes) (multiset integer) | |
{[<cons $n <cons ,(+ n 4) <cons ,(+ n 7) <nil>>>> "Major"] | |
[<cons $n <cons ,(+ n 3) <cons ,(+ n 7) <nil>>>> "Minor"] | |
[<cons $n <cons ,(+ n 5) <cons ,(+ n 7) <nil>>>> "Sus4"] | |
[<cons $n <cons ,(+ n 3) <cons ,(+ n 6) <nil>>>> "Dim"] | |
[<cons $n <cons ,(+ n 4) <cons ,(+ n 7) <cons ,(+ n 10) <nil>>>>> "7"] | |
[<cons $n <cons ,(+ n 4) <cons ,(+ n 7) <cons ,(+ n 11) <nil>>>>> "Major7"] | |
[<cons $n <cons ,(+ n 3) <cons ,(+ n 7) <cons ,(+ n 10) <nil>>>>> "Minor7"] | |
[_ "unknown"]}))) | |
(define $main | |
(lambda [$args] | |
(let {[$num-args (map read args)]} | |
(S.concat {(detect-root num-args) " " (detect-chord num-args)}))))) | |
Author
aike
commented
Sep 17, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment