music-theory-based-generation.org_archive 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- mode: org -*-
  2. Archived entries from file /home/swflint/org/music-theory-based-generation.org
  3. * Keys
  4. :PROPERTIES:
  5. :ARCHIVE_TIME: 2015-08-02 Sun 14:32
  6. :ARCHIVE_FILE: ~/org/music-theory-based-generation.org
  7. :ARCHIVE_CATEGORY: music-theory-based-generation
  8. :END:
  9. #+Caption: Keys and Calculation
  10. #+Name: keys-and-calculation
  11. #+BEGIN_SRC lisp
  12. (defvar *notes*
  13. '(:c-flat-c
  14. :c-sharp-d-flat
  15. :d :d-sharp-e-flat
  16. :e-e-sharp-f-flat-f
  17. :f-sharp-g-flat
  18. :g :g-sharp-a-flat
  19. :a :a-sharp-b-flat
  20. :b-b-sharp-c-flat-c
  21. :c-sharp-d-flat
  22. :d :d-sharp-e-flat
  23. :e-e-sharp-f-flat-f
  24. :f-sharp-g-flat
  25. :g :g-sharp-a-flat
  26. :a :a-sharp-b-flat
  27. :b-b-sharp-c-flat-c
  28. :c-sharp))
  29. (defvar *note-index*
  30. '((:c-flat 0)
  31. (:c 0)
  32. (:c-sharp 1)
  33. (:d-flat 1)
  34. (:d 2)
  35. (:d-sharp 3)
  36. (:e-flat 3)
  37. (:e 4)
  38. (:e-sharp 4)
  39. (:f-flat 4)
  40. (:f 4)
  41. (:f-sharp 5)
  42. (:g-flat 5)
  43. (:g 6)
  44. (:g-sharp 7)
  45. (:a-flat 7)
  46. (:a 8)
  47. (:a-sharp 9)
  48. (:b-flat 9)
  49. (:b 10)
  50. (:b-sharp 10)))
  51. (defvar *whole-step* 2)
  52. (defvar *half-step* 1)
  53. (defun calculate-scale (starting-note &optional (major-or-minor :major))
  54. (let ((index (cadr (assoc starting-note *note-index*)))
  55. (notes (list)))
  56. (dolist (index-add (list *whole-step* *whole-step* *half-step* *whole-step* *whole-step* *whole-step* *half-step*))
  57. (push (nth index *notes*) notes)
  58. (setf index (+ index index-add)))
  59. (reverse notes)))
  60. (defvar *notes*
  61. '((:c-flat :c :c-sharp)
  62. ))
  63. #+END_SRC