[CM] scheme, snd, cm_patterns.scm

anders.vinjar at bek.no anders.vinjar at bek.no
Sat Jul 11 03:12:00 PDT 2015

Hi James.

The beauty of the pattern-streams is they are 'streams', embodying a
pattern (eg. a 'heap' in the above example) together with a promise to
deliver the next item whenever you need it.

Typically you set up a generator and store a pointer to that, just like
you've done:

  (define aaa (make-heap '(160 600.345 1000 400)))
After that,

  (next aaa)

will return the next item from aaa anytime you want one.

Using a slightly modified version of your example, you could do
something like:

(let ((aaa (make-heap '(160 600.345 1000 400)))) ;set up a stream
  (with-sound (:output "MyTest.wav" :srate 48000 :channels 2
		       :header-type  mus-riff :statistics #t)
	      (do ((st 0 (+ st 0.25)))
		  ((>= st 2))
		(examp1 st 0.25
			(next aaa)	; next item from aaa
			0.5 48000))))

You'll find a general doc about Ricks patterns here:


Many files included with CMs docs, esp. "doc/patterns1.scm" and
"doc/patterns2.scm" - provide examples of setting up patterns and
using these.


More information about the Cmdist mailing list