; (new midi) will be the technique for creating MIDI data ; each number is assigned directly to a pitch (+ some octave transposition) ; each number is multiplied by a triplet sixteenth-note ; each number is multiplied by some value to get MIDI velocities 0-127 ; (CM will also let us use 0.0 - 1.0) (define test-row (list 1 3 10 2 7 8 9 4 6 11 12 5)) (define (series row start-time) (cond ((null? row) nil) (t (cons (new midi :time start-time :keynum (+ 59 (car row)) :amplitude (float (/ (car row) 12)) :duration (/ (car row) 6.0)) (series (cdr row) (+ start-time (/ (car row) 6.0))))))) (events (append (series test-row 0) (series (reverse test-row) 0)) "test.mid") (define (series-2 row start-time) (cond ((null? row) nil) (t (let* ((pitch (car row)) (dur (/ pitch 6.0)) (amp (/ dur 2.0))) (cons (new midi :time start-time :keynum (+ 59 pitch) :amplitude amp :duration dur) (series-2 (cdr row) (+ start-time dur))))))) (define (series-3 row start-time) ; ignore this line because it's a comment (if (null? row) ; if nil ; then (let* ((pitch (car row)) ; else..... (dur (/ pitch 6.0)) (amp (/ dur 2.0))) (cons (new midi :time start-time :keynum (+ 59 pitch) :amplitude amp :duration dur) (series-3 (cdr row) (+ start-time dur)))))) (define (rotate-left row) (attach (cdr row) (car row))) (define (attach-2 row element) (append row (list element))) (define (attach row element) (if (null? row) (list element) (cons (car row) (attach (cdr row) element)))) (define (rotate-left-n-times row number-rotations) (if (= number-rotations 0) row (rotate-left-n-times (rotate-left row) (- number-rotations 1)))) (define (rotate-right-cheap row) (rotate-left-n-times row (- (length row) 1))) (define (rotate-right-brilliant row) (cons (car (reverse row)) (reverse (cdr (reverse row))))) (define (rotate-right-with-sweat row) (cons (last-element row) (all-but-last row))) (define (last-element row) (if (null? (cdr row)) (car row) (last-element (cdr row)))) (define (all-but-last row) (if (null? (cdr row)) nil (cons (car row) (all-but-last (cdr row)))))