;;; ;;; Chapter 12 ;;; Etudes, Op. 4: Score Generation ;;; ;;; Examples and Interactions from scores.html ;;; generated from Common Music 2.4.1 on 19 Jan 2004, 08:23:15. ;;; ;;; ;;; Interaction 1: Using the pwd and cd functions. ;;; (pwd) (cd "/tmp/") (pwd) ;;; ;;; Interaction 2: Generating a MIDI event to a MIDI file. ;;; (define one (new midi :time 0 :keynum 60 :duration 2)) (events one "myscore.mid") (midi-file-print "myscore.mid") ;;; ;;; Interaction 3: Listening to a MIDI file on OSX. ;;; ;;; (osx-play-midi-file "myscore.mid") ;;; ;;; Interaction 4: Activating file versioning and setting an output hook for automatic playback. ;;; ;;; (set-midi-file-versions! true) ;;; (set-midi-output-hook! #'osx-play-midi-file) ;;; ;;; Example 1: Definition of a list of events. ;;; (define up (loop for key from 60 to 72 for beg from 0 by .1 collect (new midi :time beg :keynum key :duration 1))) ;;; ;;; Interaction 5: Generating a score from a list of events. ;;; (events up "myscore.mid") ;;; ;;; Example 2: Create a list of midi events between two key numbers. ;;; ;; see this thread for why the simple "for key from key1 by step" does not work in sbcl ;; http://ccrma-mail.stanford.edu/pipermail/cmdist/2005-October/002697.html (define (strums key1 key2 rate dur amp) (let ((step (if (< key2 key1) -1 1)) (diff (abs (- key1 key2)))) (loop repeat (+ diff 1) for key = key1 then (+ key step) for beg from 0 by rate collect (new midi :time beg :duration dur :amplitude amp :keynum key)))) ;;; ;;; Interaction 6: Generating strum data. ;;; (pprint (strums 60 61 .1 1 .2)) ;;; ;;; Interaction 7: Creating two strum sequences. ;;; (new seq :name 'ups :subobjects (strums 48 60 .1 1 .4)) (new seq :name 'downs :subobjects (strums 84 72 .1 1 .4)) (events (list #&ups #&downs) "myscore.mid") ;;; ;;; Interaction 8: The effect of start time offsets. ;;; (events (list #&ups #&downs) "myscore.mid" 5) (events (list #&ups #&downs) "myscore.mid" '(0 .5)) (events (list #&ups #&downs #&ups #&downs ) "myscore.mid" '(0 .5 1 1.5))