;; plunder.lisp ;; Tools for making plunderphonic remixes in CLM ;; by Matt Wright, March 12, 2004 ;; To use these procedures you must define the following global variables: ;; *soundfile* - file name of the soundfile you're plundering ;; *regions* - association list containing start and end times (in seconds) for all regions ;; *srate* - Global sampling rate (of both input file and output) ;; *tempo* - The usual CLM global for interpreting rhythm, if you want to use play-patterns ;; Simple way to play a sample (defun mixr (time region-name amp) (let* ((region (cdr (assoc region-name *regions*))) (start (car region)) (stop (cadr region))) (mix *soundfile* :input-frame (floor (* *srate* start)) :frames (floor (* *srate* (- stop start))) :amplitude amp :output-frame (floor (* *srate* time)) ))) ;; This version uses the cut.ins instrument to play a region ;; in the same way as mixr, but currently it exposes a bug ;; in cut.ins in which it always starts at time 0 in the input file. (defun cutr (time region-name amp) (let ((region (cdr (assoc region-name *regions*)))) (format t "~s~%" region) (one-cut time amp :soundfile *soundfile* :sound-start-time (car region) :sound-end-time (cadr region) :vib-osc-amp 0 :vib-noi-amp 0 ))) ;; The duration of a region (defun region-dur (region-name) (let* ((region (cdr (assoc region-name *regions*)))) (- (cadr region) (car region)))) (defun repeat-region (time region-name amp n) (if (= n 0) nil (progn (mixr time region-name amp) (repeat-region (+ time (region-dur region-name)) region-name amp (- n 1)) ))) (defun play-all-regions () ;; Good for testing your list of regions and to remind yourself of ;; what you have to work with (with-sound (:srate srate) (let ((time 0)) (loop for r in *regions* do (let ((name (car r))) (format t "~s~%" name) (mixr time name 1.) (incf time (+ 0.3 (region-dur name))) ))))) ;;; Rhythmic Stuff with Common Music Patterns (defun play-patterns (time n timbres rhythms) (loop repeat n do (let ((timbre (next timbres)) (notes (next rhythms))) (loop for n in notes do (mixr time timbre 0.7) (setq time (+ time (rhythm n))) ))) time) ;;; Granular stuff (defun stretch-it (region-name time duration) (let* ((region (cdr (assoc region-name *regions*))) (start (car region)) (end (cadr region))) (grani time duration .6 *soundfile* :grain-start `(0 ,(/ start soundfile-duration) 1 ,(/ end soundfile-duration)) :srate-spread 2. :grain-duration 0.2 )) ) (defun ritard (region-name time duration) (let* ((region (cdr (assoc region-name *regions*))) (start (car region)) (end (cadr region))) (grani time duration .6 *soundfile* :grain-start `(0 ,(/ start soundfile-duration) 1 ,(/ end soundfile-duration)) :srate-spread 2. :grain-duration 0.2 :grain-density '(0 10 1 1) )) )