;;; "Unlabelled: Random Stories with no Coherence?" ;;; Mus 220b Assignment #3 ;;; Steven Backer #| (in-package :cm) (compile-file "grani.ins") (load "grani.cmucl) |# ;;; Note: This code may take a while to synthesize (~45min on 3.2GHz!). ;;; Ideally, I would have moved some of the code into an instrument, ;;; but of course, time is not free... ;;;---------------------------------------------------------- ;; define my classmates? No, just tell part of their stories... (defparameter slb "./classmates/improv.wav") (defparameter per "./classmates/per.wav") (defparameter brad "./classmates/brad.wav") (defparameter juan-pablo "./classmates/juan-pablo.wav") (defparameter jen "./classmates/jen.snd") (defparameter jack "./classmates/jack.wav") (defparameter jonathan "./classmates/jonathan.wav") (defparameter jesse "./classmates/jesse.wav") (defparameter kris "./classmates/kris.snd") (defparameter dean "./classmates/dean.wav") (defparameter paul "./classmates/paul.wav") (defparameter robert "./classmates/robert.wav") (defparameter gjm "./classmates/gjm.wav") (defparameter bruno "./classmates/bruno.wav") (defparameter storm "./classmates/storm.wav") (defparameter mitchell "./classmates/mitchell.wav") (defparameter lillian "./classmates/lillian.wav") (defparameter wilmot "./classmates/wilmot.wav") ;;; "Random Element #1" ;; Note: and easy way to get timbre changes in the result is to modify this roll to include more or less copies of certain pieces ;; e.g. - apply a weighting function to each. Here - "everyone gets an A" :) (setf roll (new heap :of (list slb per brad juan-pablo jen jack jonathan jesse kris dean paul robert gjm bruno storm mitchell lillian wilmot))) ;;; Exponential - "Random Element #2" ;;; delta controls the horizontal scale of the density function (defun exponential (delta) (/ (- (log (random 1.0))) delta)) ;;; Gaussian - "Random Element #3" ;;; mu = center of the distribution (between 0 and 1) ;;; sigma = standard deviation (% of span) 68.26% of results fall into ;;; mu+-sigma (defun gaussian (sigma mu &optional (n 12)) (let* ((novr (/ n 2)) (scale (/ (sqrt (/ n 12)))) (sum (loop repeat n sum (random 1.0)))) (+ (* sigma scale (- sum novr)) mu))) ;; Choose some initial values (defparameter sigma 0.6) (defparameter mu 0.3) ;; first 220a class (defun 220intro () (loop repeat 5 do (grani 0 10 0.1 "./classmates/Bills_Bobwhite.wav"))) ;; grani loops - move this into an instrument so it will run faster? (defun classmate (beg numLoop duration offset spread grain-duration amp) (loop repeat (* 18 numLoop) ;; use a grain from each classmate before repeating for time = beg then (+ time (gaussian sigma mu) offset) ;; spread out grains for name = (next roll) do ;; select grain sources in random order (grani time duration amp name :grain-start (gaussian 0.3 0.5) :grain-duration grain-duration :grain-duration-spread spread :grain-density (exponential 0.11)))) ;; Main (with-sound (:srate 44100 :channels 2 :statistics t) (220intro) (classmate 1 1 200 0 0.5 0.99 0.09) (loop repeat 10 for time2 = 7 then (+ time2 (gaussian sigma mu) 5) for degree = (+ 90 (gaussian 0.3 0.5)) ;future goal-add spatialization to grains do (classmate time2 1 17 5 0 0.99 0.09)) (classmate 60 1 5 6 0.5 6 0.35) (classmate 0 1 1 5 0 0.99 0.09) (classmate 0 2 1 5 0 1 0.2))