[CM] Newbie learning. . . . CM / CLM-3 / SND / Scheme???

Kjetil S. Matheussen k.s.matheussen@notam02.no
Sat, 26 May 2007 17:21:47 +0200 (CEST)

On Fri, 25 May 2007, Bill Schottstaedt wrote:

>>  I suppose if I have a go with the docs I can work out how to use Snd as a
>>  batchable Music V engine?
> I hope so.  In terms of with-sound and clm, if anything you can do more in 
> Snd
> than in CL.  The error handling in Snd is much better than in any of the 
> lisps
> except maybe ACL (Common Lisp debuggers are much worse than you can imagine, 
> and no
> attempt is ever made to help with foreign functions -- you sometimes can't 
> even
> use gdb).  CL/CLM is still about twice as fast -- I only ran "Phrygians" 
> through
> both, but someday I'll have time to make a more comprehensive comparison.
> But that speed up is swamped by the time you'll spend tearing your hair and
> cursing if you ever make a typo or any mistake of any kind.  Whenever I 
> launch
> into some new project, I use Snd (rather than CL) without even a second 
> thought.
> Once developed, the code is very easy to translate from Scheme to CL -- they 
> are
> almost the same language and CLM is fully supported in both. clm23.scm has a
> list of the differences.

The rt-compiler can be used in non-realtime as well, although the 
language is not as nice as scheme or common lisp. But it should be faster 
than both though, in case extreme speed is necesarry using snd for running 

(define (gen-sin duration freq)
   (let ((v (make-vct (* (mus-srate) duration) 0.0))
 	(osc (make-oscil :frequency freq)))

     ((rt-func (lambda ()
 		(vct-map! v
 			  (lambda ()
 			    (* 0.8 (oscil osc)))))))
      (lambda ()
        (do ((i 0 (1+ i)))
 	   ((= i (vct-length v)))
 	 (outa i (vct-ref v i) *output*))))))

  (:output "/tmp/ai.snd" :srate 44100 :to-snd #f)
  (gen-sin 5 440))

The generated c code for the inner loop of the above code looks like this:

 		while (!((rt_gen2__3 == rt_gen1__1->length))) {
 		    rt_gen1__1->data[rt_gen2__3] =
 			((0.8 * mus_oscil(rt_globals->osc__4, 0, 0)));