;; Matt Wright ;; Music 220B Assignment #3: my very own percussion band ; :cl grani ; (load "rhythm-hw3.lisp") (setq cut-vib-osc-amp 0) (setq cut-vib-noi-amp 0) (setq length-of-one-bar 1.9619999) (setq *tempo* (/ 60 (/ length-of-one-bar 4))) (setq srate 44100) (setq soundfile-duration 34.906666) ;; Here are the bits of my input sound that I'll use as sampled percussive hits: (setq regions '((hh (20.873 21.095)) (drugs (20.111 20.873)) (hit1 (1.74 1.974)) (sax (.243 .771)) (groove1 (5.557 6.342)) (guit (7.73 7.986)) (onebar (11.464 13.426)) (bass (19.382 19.622)) (3notes (1.748 2.496)) (this-is-jb (2.753 3.692)) (novox-loop (.328 2.247)) (leave-it (11.473 12.762)) (end (23.668 34.9)) )) ;; Simple way to play a sample taken from one of those regions (defun my-mix (target region-name amp transpose) (let* ((region (cadr (assoc region-name regions))) (start (car region)) (stop (cadr region))) (mix "jb.wav" :input-frame (floor (* srate start)) :frames (floor (* srate (- stop start))) :amplitude amp :output-frame (floor (* srate target)) ))) ;; The duration of a region (defun region-dur (region-name) (let* ((region (cadr (assoc region-name regions)))) (- (cadr region) (car region)))) (defun repeat-region (region-name target n) (if (= n 0) nil (progn (my-mix target region-name 1.0 1.0) (repeat-region region-name (+ target (region-dur region-name)) (- n 1)) ))) ;;; Granular stuff (defun stretch-it (region-name time duration) (let* ((region (cadr (assoc region-name regions))) (start (car region)) (end (cadr region))) (grani time duration .6 "jb.wav" :grain-start `(0 ,(/ start soundfile-duration) 1 ,(/ end soundfile-duration)) :srate-spread 2. :grain-duration 0.2 )) ) (defun this-is-jb (time duration) (stretch-it 'this-is-jb time duration)) (defun leave-it (time duration) (stretch-it 'leave-it time duration)) (defun ritard (region-name time duration) (let* ((region (cadr (assoc region-name regions))) (start (car region)) (end (cadr region))) (grani time duration .6 "jb.wav" :grain-start `(0 ,(/ start soundfile-duration) 1 ,(/ end soundfile-duration)) :srate-spread 2. :grain-duration 0.2 :grain-density '(0 10 1 1) )) ) ;; Pattern stuff (defun busy (time n) (let ((timbres (new cycle :of `(bass hh ,(new heap :of `(hh sax sax hit1 guit guit 3notes 3notes ,(new heap :of '(hh hh hh drugs))))))) (rhythms (new cycle :of `((e e) ,(new cycle :of '((s e s) (e e e) (e s s))) ,(new heap :of '((32nd 32nd s e) (s. s. s. s. s s) (e s 32nd 64th 64th))) ,(new heap :of '((s e.) (s e.) (s s s s) (s e s))))))) (play-patterns time n timbres rhythms) )) (defun medium (time n) (let ((timbres (new cycle :of `(bass hh bass hh ,(new heap :of `(hh sax sax guit guit 3notes 3notes ,(new heap :of '(hh hh hh drugs))))))) (rhythms (new cycle :of `((h) ,(new cycle :of '((q q) (q q) (q q q) (q q) (q q q q))) ,(new heap :of '((s e.) (s e.) (s s s s) (s e s)))) ))) (play-patterns time n timbres rhythms) )) (defun play-patterns (time n timbres rhythms) (loop repeat n do (let ((timbre (next timbres)) (notes (next rhythms))) (loop for n in notes do (my-mix time timbre 0.7 1.0) (setq time (+ time (rhythm n))) ))) time) ;; Sections of my piece: (defun intro () (let ((time 0)) (my-mix time 'hh 0.5 1.0) (setq time (+ time (rhythm 'w))) (my-mix time 'sax 0.5 1.0) (setq time (+ time (rhythm 'w))) (my-mix time 'guit 0.5 1.0) (setq time (+ time (rhythm 'h))) (my-mix time '3notes 0.5 1.0) (setq time (+ time (rhythm 'w+w))) (my-mix time '3notes 0.5 1.0) (setq time (+ time (rhythm 'e.))) (my-mix time '3notes 0.5 1.0) (setq time (+ time (rhythm 'e.))) (my-mix time '3notes 0.5 1.0) (setq time (+ time (rhythm 'h))) time )) (defun sayname (time dur) (let ((repetitions (ceiling (/ dur (region-dur 'novox-loop))))) (repeat-region 'novox-loop time repetitions) (this-is-jb time dur) (+ time dur))) ;; The whole thing: (defun whole-thing () (with-sound (:srate srate) (let* ((t1 (intro)) (t2 (sayname t1 11)) (t3 (medium t2 25)) (t4 (busy t3 30)) ) (leave-it 40 12) (ritard 'end 60 20)))) (whole-thing) #| :cl cut :cl grani ;; Examples ;; Try all my regions (with-sound (:srate srate) (loop for r in regions for time from 0 by (rhythm 'h) do (let ((name (car r))) (format t "~s~%" name) (my-mix time name 1. 1.)))) ;; Play one region (with-sound (:srate srate) (my-mix 0 'guit 0.8 1.0)) (with-sound (:srate srate) (my-mix 0 '3notes 0.8 1.0)) (with-sound (:srate srate) (my-mix 0 'hit1 0.8 1.0)) ;; Rhythmic experimentation (with-sound (:srate srate) (let ((time 0)) (loop for x in '(w w q q q w) do (my-mix time (if (equalp x 'q) 'hit1 'onebar) 1.0 1.0) (setq time (+ time (rhythm x))) ))) (with-sound (:srate srate) (my-mix 0 'groove1 0.8 1.0) (my-mix 1.0 'groove1 0.8 1.0) (my-mix 1.81 'hit1 0.8 1.0) (my-mix 2.0 'groove1 0.8 1.0) (my-mix 2.76 'hit1 0.8 1.0) (my-mix 2.88 'hit1 0.8 1.0) (my-mix 2.99 'hit1 0.8 1.0) (my-mix 3.09 'hit1 0.8 1.0) (my-mix 3.14 'hit1 0.8 1.0) (my-mix 3.19 'hit1 0.8 1.0) (my-mix 3.3 'groove1 0.8 1.0) (my-mix 4.3 'groove1 0.8 1.0) (my-mix 5.1 'drugs 0.8 1.0) (my-mix 5.3 'groove1 0.8 1.0) ) (with-sound (:srate srate) (repeat-region 'onebar 0 3)) (with-sound (:srate srate) (repeat-region 'novox-loop 0 3)) ;; "cut" sucks: (with-sound (:srate srate) (one-cut 0 1. :soundfile "jb.wav" :vib-osc-amp 0 :vib-noi-amp 0 :sound-start-time 20 :sound-end-time 23.24)) (with-sound (:srate srate) (intro)) (with-sound (:srate srate) (sayname 0 10)) (with-sound (:srate srate) (medium 0 30)) (with-sound (:srate srate) (busy 0 30)) |#