Nov-11
Synthesized Composition Featuring Algorithmic Constructions
John Chowning, Stria (1980)
filename of piece: /usr/ccrma/snd/pieces/chowning/stria.snd (in 4 channels)
Interview article with Chowning from Composers and the Computer Curtis Roads, Copyright 1985 by William Kaufmann, Inc.
HW5: Algorithms for synthesis and composition
Rewind the brain back to HW1: Definstrument, ascending-sinusoid, etc. only now the syntax is not Scheme, but lisp. CMN is a notation package in lisp and CLM is a synthesis / processing package.
Tracker etude: Algorithmic CMN-generated score to be accompanied by a CLM-generated soundfile. Score for any number of instrumentalists in class.
Programming assignment: Program in lisp a CLM function which recreates the “Deep Note” THX logo. Use 500 oscillators.
Running lisp – here's a transcript of me starting lisp and then quitting it, type-in in highlighted font:
[cc@cmn27 nov-11]$ /usr/bin/clisp-cm-clm-cmn
;; Loading file /usr/lib/clisp/cm-clm-cmn/lispinit.lisp ...
;;
;; CM 2.4.0 (06/28/2003); CLM 2 (08/18/2003); CMN (08/15/2003)
;;
;; Loaded file /usr/lib/clisp/cm-clm-cmn/lispinit.lisp
[1]> (quit)
[cc@cmn27 nov-11]$
In the lisp world, comments are preceded by a semi-colon. Prompts are sequentially numbered, and you can get immediate evaluation of simple expressions:
[1]> (+ 2 2)
4
[2]> (* 234 36 47457 324)
129527996832
[3]>
And if you type in a bogus expression, you are rewarded with an error, but you can back out to where you were (the top-level interpreter) by typing the command “:q”
[1]> (+ 2 Fred)
*** - EVAL: variable FRED has no value
1. Break [2]> :q
[3]>
For CLM sound synthesis, programming gets done in a file and the file is to be compiled and loaded. Copy the file bird.lisp to a directory, then try the following commands to vocalize those birds, one more time... basically the same process as we had for Snd/Scheme (only faster). The lisp program compiles all signal processing functions into C-language and then runs the generated code. The output soundfile has been set to /zap/test.wav and lisp will play the soundfile when the expression “(dac)” is executed.
[1]> (compile-file "bird" :verbose nil)
; Writing "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_BIRD.c"
; Compiling "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_BIRD.c"
; Writing "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_BIGBIRD_2.c"
; Compiling "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_BIGBIRD_2.c"
; Writing "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_BIGBIRD.c"
; Compiling "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_BIGBIRD.c"
#P"/amd/cm-user/user/c/cc/220a/nov-11/bird.fas" ;
543 ;
543
[2]> (load "bird")
;; Loading file /amd/cm-user/user/c/cc/220a/nov-11/bird.fas ...
;; Loading file /amd/cm-user/user/c/cc/220a/nov-11/rc.pool.cl ...
;; Loaded file /amd/cm-user/user/c/cc/220a/nov-11/rc.pool.cl
;; Loaded file /amd/cm-user/user/c/cc/220a/nov-11/bird.fas
T
[3]> (dac)
Algorithm example
An example algorithm using chaos to control frequencies and pitches. Executing “(make-score)” runs the synthesis, outputs to “/zap/test.wav” and plays the sound automatically, plus it outputs a notated page to the file “aaa.eps” which can be viewed with gv or gimp. The file dyn.lisp creates 30 notes, using two iterated maps to determine start and end frequencies. The maps are of the form:
x(n+1) = a + b xn + c xn2
which is rewritten lisp-style as the expression
(setf x (+ 0.92 (* 0.9 x) (* -2.0 (* x x))))
[1]> (compile-file "dyn" :verbose nil)
; Writing "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_PARTIAL.c"
; Compiling "/amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_PARTIAL.c"
#P"/amd/cm-user/user/c/cc/220a/nov-11/dyn.fas" ;
7 ;
7
[2]> (load "dyn")
;; Loading file /amd/cm-user/user/c/cc/220a/nov-11/dyn.fas ...
;; Loaded file /amd/cm-user/user/c/cc/220a/nov-11/dyn.fas
T
[3]> (make-score)
;; Loading file /amd/cm-user/user/c/cc/220a/nov-11/rc.pool.cl ...
;; Loaded file /amd/cm-user/user/c/cc/220a/nov-11/rc.pool.cl
; Loading clm_lnxclp_partial4 into /amd/cm-user/user/c/cc/220a/nov-11/rc...cc -g -O3 -DLINUX -DHAVE_ALSA /amd/cm-user/user/c/cc/220a/nov-11/rc.c -o /amd/cm-user/user/c/cc/220a/nov-11/rc /amd/cm-user/user/c/cc/220a/nov-11/clm_lnxclp_PARTIAL.o -L/usr/lib/clisp/clm -lmus -lasound -lm
#<SCORE #x205DFB05>
[4]>
Each note is a bird-style glissando note. The score shows pitches derived from frequencies at the end of each note (where the glissando ends). Accidentals in the score apply only to the following notehead.


Programming assignment: Recreate the thx logo, otherwise known as “deep note” (by Andy Moorer at Lucasfilm).
The concept is one long tone comprised of hundreds of oscillators, lasting around 20 or 30 seconds. The oscillators begin at random frequencies and slowly glissando into harmonic positions of a low pitch. Use 500 oscillators, but use them wisely, so that they do not create frequencies outside the audio range.
Example thx logo soundfile name: /usr/ccrma/snd/cc/220a/thx.wav have a listen and a look at the sonogram.
The example to build from was shown in class. It's click.lisp and just outputs a sequence of click events. Here's the code with links to references and / or examples. CLM tokens are linked and plain-old lisp is highlighted and can be looked up in a lisp reference (only visible at CCRMA). The “loop” macro is a lisp extension and has been linked to documentation. Everything else is custom code for the example:
(definstrument click (start dur amp) (let* ((len (inexact->exact (round (* *srate* dur)))) (beg (inexact->exact (round (* *srate* start)))) (end (+ beg len))) (run (loop for i from beg to end do (outa i amp) )))) (defun make-clicks () (let* ( (n 15) (durs (make-array n)) (amps (make-array n)) ) (loop for i from 0 below n do (setf (aref durs i ) (/ 0.001 (+ 1 (mod i 4)))) ) (loop for i from 0 below n do (setf (aref amps i ) (random 0.1)) ) (with-sound (:srate 48000 :output "/zap/test.wav" :channels 2) (loop for i from 0 below n do (click (* i 0.15) (aref durs i) (aref amps i)) ))))