Snd lab #3

Snd and CM procedures, structure and unit conversions

Our scheme examples are structured for simplicity. They combine definitions in the CLM instrument definition syntax with definitions in the CM event patterning syntax. They are designed to work together with minimal typing on your part.


Open in anjuta and evaluate the file ~cc/220a/scm/sine/circle-fft-sines.scm

make-clm-event is a shorthand way to specify a single event defined as a clm instrument

It has two parts

per event

where we define temporary variables including any unit generator objects used to compute the event

per sample

(optionally) define more temporary variables local to each sample audio calculation

compute and output the audio sample


This defines a CLM instrument that then can be called at a given time, with a set of parameters for each event and a process that will loop per sample to create the signal.


make-clm-event is executed at the start of a CM process to produce a pattern of events

In the example, it creates a pair of sines that form the bottom and top halves of a frequency circle. Have a look in a sonogram.


For comparison, open, evaluate, and look at the spectrum of ~cc/220a/scm/noise/noise.scm

In this example, there are also 2 sound-generating objects, not oscillators, but instead the scheme's random procedure.


Some useful conversions between log scales, and linear (dB<->amplitude, keynum<->frequency). All these are loaded into the evaluation context when running a course example.


CLM provides the procedures

db->linear to convert a (logarithmic) dB value to a linear amplitude value

linear->db to convert a linear amplitude value to dB

hz->radians to convert a frequency to the appropriate increment for a periodic function, based on the sample rate


CM provides the procedures

keynum to convert a frequency to a midi key number, must be given the keyword :hz as in (keynum 440.0 :hz)

hertz to convert a midi key number to a frequency


Outside of the structured examples for the course, things still work but are a bit more detailed in syntax. Open the two files in ~cc/220a/scm/bird/ in anjuta, and first evaluate bird.scm to play a sequence of bird calls written directly in CLM without using the course example structure. The second file, unBird.scm, is commented with indications of the guts of the CLM definitions for just the first birdcall.