[CM] Scheme - cm 3.6.0 beta

Heinrich Taube taube at uiuc.edu
Wed Apr 21 04:56:01 PDT 2010


>
> Could you help with this example below?  My Scheme is going well,  
> but this has me stumped.

when you call (sprout (type-samps  '(sf1 sf2)))
then the type-samps is called and its parameter samps  will contain  a  
list of two symbols:  (sf1 sf2)
then you iterate smp over this list of two symbols, so on the first  
iteration smp is the symbol sf1
then you try to take nth of sf1 and thats an error because nth expects  
a list not a symbol and sf1 is a symbol
what you want to do is iterate over the DATA in the sf1 and sf2  
variables rather then the symbols themselves. so you have to evaluage  
sf1 and sf2 when you call type-samps. try calling it like this:

	(sprout (type-samps (list sf1 sf2)))

in this case, since sf1 and sf2 are not in a quoted list they are  
evaluated as variables, since each holds a list the parameter samps  
will now be a list of two lists :
(("\"C:/sampledir/samp1.wav\""  2        10) ("\"C:/sampledir/samp2.wav 
\""  1        32))

so now on the first iteration smp will be set to ("\"C:/sampledir/ 
samp1.wav\""  2        10)
and then (nth smp 0)  will be "\"C:/sampledir/samp1.wav\""
and everythig will work


it appears that you will be working with soundfiles? if so, im not  
sure sndlib will want to see Windows style pathnames. You might need  
to changes those to real pathnames:  "/sampledir/samp1.wav". also cm  
has a really handy (undocumented) function for reading sound file  
directoryes ( look in vkey.scm ) and computing lists like that for  
whole directories.  i will be merging that with a simlar function for  
setting up supercollider buffers in Grace, ill document these this  
weekend when i make the last beta.




On Apr 21, 2010, at 2:11 AM, Adam wrote:

> Thanks again.  Quasiquotation  which I find in R5RS  section 4.2.6
> and now understand. Beaut.
>
> Could you help with this example below?  My Scheme is going
> well, but this has me stumped.
>
> Run first with the 4 comments in place, and then remove
> the 4 comments to see the problem.
>
> Error is that argument sf1 is symbol but should be pair (list).
>> From the predicates below, it seems sf1 sf2 morph from list
> to symbol inside the process.
>
>
> ;                               name      channels  duration
> (define sf1 '("\"C:/sampledir/samp1.wav\""  2        10))
> (define sf2 '("\"C:/sampledir/samp2.wav\""  1        32))
> ; -----
> (define (type-samps samps)
>      (process for smp in samps
> ;              for sname = (nth smp 0)
> ;              for sch = (nth smp 1)
> ;              for sdur = (nth smp 2)
>              do
>               (print smp "  list?   " (list? smp))
>               (print smp " symbol?  " (symbol? smp))
> ;                 (print smp sname sch sdur)
>               (newline) ))
>
> (sprout (type-samps '(sf1 sf2)))
>
> ; -----
>
> (nth sf1 0)
> (nth sf1 1)
> (nth sf1 2)
>
> (print 'sf1 "  list?   " (list? sf1))
> (print 'sf1 " symbol?  " (symbol? sf1))
>
>
>
> _______________________________________________
> Cmdist mailing list
> Cmdist at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist



More information about the Cmdist mailing list