Tetrachord Transpositions 2020-11-02

by jgart

(define (sign n) (cond ((negative? n) -1) ((positive? n) 1) (else 0))) (define (quotient n1 n2) (* (sign n1) (sign n2) (div (abs n1) (abs n2)))) (define remainder (lambda (x y) (- x (* (quotient x y) y))) ) (define (transpositions l) (define (rot o) (map (lambda (e) (remainder (+ o e) 12)) l)) (map rot (iota 12))) (define (transpose-all chords) (map transpositions chords)) (define tetrachords '((0 1 2 3) (0 1 2 4) (0 2 3 4) (0 1 3 4) (0 1 2 5) (0 3 4 5) (0 1 2 6) (0 4 5 6) (0 1 2 7) (0 1 4 5) (0 1 5 6) (0 1 6 7) (0 2 3 5) (0 1 3 5) (0 2 4 5) (0 2 3 6) (0 3 4 6) (0 1 3 6) (0 3 5 6) (0 2 3 7) (0 4 5 7) (0 1 4 6) (0 2 5 6) (0 1 5 7) (0 2 6 7) (0 3 4 7) (0 1 4 7) (0 3 6 7) (0 1 4 8) (0 3 4 8) (0 1 5 8) (0 2 4 6) (0 2 4 7) (0 3 5 7) (0 2 5 7) (0 2 4 8) (0 2 6 8) (0 3 5 8) (0 2 5 8) (0 3 6 8) (0 3 6 9) (0 1 3 7) (0 4 6 7))) (define chords tetrachords) (define (_show c) (if (string? c) (confirm c) (alert c))) (define (random-sleep s) (sleep (random-integer s))) (define show (begin (_show "https://en.wikipedia.org/wiki/List_of_pitch-class_sets") (random-sleep 2) (_show chords))