Created
June 25, 2019 13:40
-
-
Save jackrusher/efc96f061b401d19b4b4de133be9daf9 to your computer and use it in GitHub Desktop.
Some example code for calculating triad transformations using Ernst Levy's concept of Negative Harmony, as recently popularized by Jacob Collier.
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
(def the-notes | |
(cycle [:c :db :d :eb :e :f :gb :g :ab :a :bb :b])) | |
(def key-offset | |
(zipmap (take 12 the-notes) (range))) | |
(defn triads [the-key] | |
(let [offset (key-offset the-key) | |
scale (cycle [0 2 4 5 7 9 11])] | |
(map | |
#(vector (nth the-notes (+ offset (nth scale (+ % 0))) ) | |
(nth the-notes (+ offset (nth scale (+ % 2)))) | |
(nth the-notes (+ offset (nth scale (+ % 4))))) | |
(range 7)))) | |
(defn negative-harmony [the-key] | |
(let [offset (key-offset the-key)] | |
(reduce | |
(fn [m [a b]] (assoc m a b b a)) ; bi-directional | |
{} | |
(map vector | |
(take 6 (drop (+ offset 10) the-notes)) | |
(reverse (take 6 (drop (+ offset 16) the-notes))))))) | |
(map (fn [chord] | |
[chord (mapv (negative-harmony :c) chord)]) | |
(triads :c)) | |
;;C-major negative harmony | |
;;triads counterparts | |
([[:c :e :g] [:g :eb :c]] ; C -> Cm | |
[[:d :f :a] [:f :d :bb]] ; Dm -> Bb | |
[[:e :g :b] [:eb :c :ab]] ; Em -> Ab | |
[[:f :a :c] [:d :bb :g]] ; F -> Gm | |
[[:g :b :d] [:c :ab :f]] ; G -> Fm | |
[[:a :c :e] [:bb :g :eb]] ; Am -> Eb | |
[[:b :d :f] [:ab :f :d]]) ; Bo -> Abo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment