CCRMA

Introduction to CLM


Lecture Slides


Introduction to CLM (Common Lisp Music)

Take a look at the whole sheebang... the score producer (if you use it) is Common Music / Stella. It writes a file in one of many possible syntaxes that the sound producing programs know how to interpret or play. CLM is also part of lisp, MusicKit, for example, is not part of the lisp image, it is an external software package that is part of the NeXT operating system...

Here's a more detailed look at the lisp world as usually used here at ccrma... Three different packages are compiled as part of the Common Lisp executable, CLM (sound synthesis and processing), CMN (common music notation) and CM (algorithmic composition).

Several ways to run lisp at ccrma... During the workshop we will be using Linux and we'll be running the common lisp executable image as a subprocess of the xemacs editor.

A tour of CLM

This shows how a clm instrument generates both compiled lisp code for the initialization section and highly optimized C code for the sample generating loop...

The source files are usually ".lisp" or ".ins" (instrument) files. The compilation process generates a fast load compiled file, ".fasl"/".fisl" or ".fusl" depending on the platform you are running and a object file ".o" or ".so" depending on the platform.

A very simple instrument, just one sine wave with an envelope. You'll see the basic components of an instrument repeated over and over. The basic components are always the same...

Let's split it into three parts so that we can analyse it easily. The first part declares the instrument (defines and names the instrument and its parameters), the second part defines the "unit generators" or black boxes that will be connected together in the third part. The third part is the "run" loop that generates the samples that are merged into the output soundfile. It "connects" together the unit generators and creates a sample (number) for each iteration of the loop.

"make-oscil" creates the oscillator, "oscil" uses it; "make-env" creates the envelope, "env" uses it.

WARNING: the code in the slide has an obsolete function in it, please use the code below it

and here's the text:

(definstrument simp (start-time duration frequency amplitude 
		        &key (amp-env '(0 0 50 1 100 0)))
  (multiple-value-bind (beg end) (times->samples start-time duration)
    (let ((s (make-oscil :frequency frequency))
	  (amp (make-env :envelope amp-env :duration duration :scaler amplitude)))
      (run 
       (loop for i from beg to end do
	 (outa i (* (env amp) (oscil s))))))))
Some ways to use our sinewave oscillator through the "with-sound" macro:

This is what you do to interact with clm, first create a file with the instrument code in it, compile and load it in the lisp interpreter, test it. If not happy then edit it and go back to the beginning of the loop. Sometimes testing involves just changing parameters to the instrument call and that does not require a recompilation...


©1996-2001 Fernando Lopez-Lezcano. All Rights Reserved.
nando@ccrma.stanford.edu