Implement pitch and trans
This commit is contained in:
parent
dbd0c78589
commit
079d1107b4
@ -72,11 +72,16 @@
|
||||
"Returns the absolute pitch of a pitch class at an octave"
|
||||
(+ (* 12 octave) (pc-to-int pitch-class)))
|
||||
|
||||
;; TODO
|
||||
(defn pitch [abs-pitch]
|
||||
"Returns the pitch class and octave represented by the absolute pitch.
|
||||
In cases of enharmonic equivalence, returns the sharp rather than the flat."
|
||||
())
|
||||
(let [scale [:C :C# :D :D# :E :F :F# :G :G# :A :A# :B]
|
||||
octave (quot abs-pitch 12)
|
||||
index (rem abs-pitch 12)]
|
||||
[(nth scale index) octave]))
|
||||
|
||||
(defn trans [n [pitch-class octave]]
|
||||
(pitch (+ (abs-pitch pitch-class octave) n)))
|
||||
|
||||
;; TODO exercise 2.1 (ii-V-I function)
|
||||
;; this will involve being able to answer, "what pitch is n semitones above this one?"
|
||||
|
Loading…
Reference in New Issue
Block a user