# -*- mode: org -*- Archived entries from file /home/swflint/org/music-theory-based-generation.org * Keys :PROPERTIES: :ARCHIVE_TIME: 2015-08-02 Sun 14:32 :ARCHIVE_FILE: ~/org/music-theory-based-generation.org :ARCHIVE_CATEGORY: music-theory-based-generation :END: #+Caption: Keys and Calculation #+Name: keys-and-calculation #+BEGIN_SRC lisp (defvar *notes* '(:c-flat-c :c-sharp-d-flat :d :d-sharp-e-flat :e-e-sharp-f-flat-f :f-sharp-g-flat :g :g-sharp-a-flat :a :a-sharp-b-flat :b-b-sharp-c-flat-c :c-sharp-d-flat :d :d-sharp-e-flat :e-e-sharp-f-flat-f :f-sharp-g-flat :g :g-sharp-a-flat :a :a-sharp-b-flat :b-b-sharp-c-flat-c :c-sharp)) (defvar *note-index* '((:c-flat 0) (:c 0) (:c-sharp 1) (:d-flat 1) (:d 2) (:d-sharp 3) (:e-flat 3) (:e 4) (:e-sharp 4) (:f-flat 4) (:f 4) (:f-sharp 5) (:g-flat 5) (:g 6) (:g-sharp 7) (:a-flat 7) (:a 8) (:a-sharp 9) (:b-flat 9) (:b 10) (:b-sharp 10))) (defvar *whole-step* 2) (defvar *half-step* 1) (defun calculate-scale (starting-note &optional (major-or-minor :major)) (let ((index (cadr (assoc starting-note *note-index*))) (notes (list))) (dolist (index-add (list *whole-step* *whole-step* *half-step* *whole-step* *whole-step* *whole-step* *half-step*)) (push (nth index *notes*) notes) (setf index (+ index index-add))) (reverse notes))) (defvar *notes* '((:c-flat :c :c-sharp) )) #+END_SRC