summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2016-09-28 09:48:21 +0200
committerrekado <rekado@elephly.net>2016-09-28 09:50:26 +0200
commit79d76a04b0d9a6c104c8756fcdf31495451cc42e (patch)
treef5fbfac7c028c016399aedd3ef549cd30261051c
parent0147aafaff58d048d99fe66abd7bc4b769d564a7 (diff)
Scales are functions.
A scale is a procedure that takes a root note and returns a list of scale notes.
-rw-r--r--scales.scm38
1 files changed, 26 insertions, 12 deletions
diff --git a/scales.scm b/scales.scm
index 0ac91db..271d6ce 100644
--- a/scales.scm
+++ b/scales.scm
@@ -21,26 +21,40 @@
;;; Common scales
+(define (steps->scale steps)
+ "Given a list of semitone steps, return a procedure that takes a
+root note and returns a list of scale notes."
+ (let ((offsets (reverse
+ (fold (lambda (step acc)
+ (cons (+ step (car acc)) acc))
+ '(0) steps))))
+ (lambda (root)
+ (let ((notes (all-notes-from root)))
+ (map (lambda (offset)
+ (make-scale-note (list-ref notes offset)
+ offset))
+ offsets)))))
+
(define lydian
- '(2 2 2 1 2 2 1))
+ (steps->scale '(2 2 2 1 2 2 1)))
(define ionian
- '(2 2 1 2 2 2 1))
+ (steps->scale '(2 2 1 2 2 2 1)))
(define mixolydian
- '(2 2 1 2 2 1 2))
+ (steps->scale '(2 2 1 2 2 1 2)))
(define lydian-b7
- '(2 2 2 1 2 1 2))
+ (steps->scale '(2 2 2 1 2 1 2)))
(define altered
- '(1 2 1 2 2 2 2))
+ (steps->scale '(1 2 1 2 2 2 2)))
(define symmetrical-diminished
- '(1 2 1 2 1 2 1 2))
+ (steps->scale '(1 2 1 2 1 2 1 2)))
(define dorian
- '(2 1 2 2 2 1 2))
+ (steps->scale '(2 1 2 2 2 1 2)))
(define aeolian
- '(2 1 2 2 1 2 2))
+ (steps->scale '(2 1 2 2 1 2 2)))
(define phrygian
- '(1 2 2 2 1 2 2))
+ (steps->scale '(1 2 2 2 1 2 2)))
(define locrian
- '(1 2 2 1 2 2 2))
+ (steps->scale '(1 2 2 1 2 2 2)))
;;; Tunings
@@ -106,8 +120,8 @@ indicated for as many FRETS as specified."
;;; Examples
(when #f
- (print-fretboard (fretboard tuning-guitar (scale->notes 'aeolian 'e) 7 5))
+ (print-fretboard (fretboard tuning-guitar (aeolian 'e) 7 5))
(print-stick
(map (lambda (string-group)
- (fretboard string-group (scale->notes 'aeolian 'e) 7 5))
+ (fretboard string-group (aeolian 'e) 7 5))
tuning-grand-stick-matched-reciprocal-6+6)))