[CM] some CM sprout/process questions
Michael Klingbeil
michael@klingbeil.com
Fri, 27 Sep 2002 22:07:08 -0400
It sounds like each time you are calling 'sv' on your object 'o', you
are overwriting the old slot values. This is one of those examples
where the functional programmers will shout "side effects are bad!"
This isn't a problem if you are immediately sending events out the
midi-port, but if you are putting them into a seq or something like
that, then you need a new object for each event.
Your idea of using copy-object is definitely on the right track and
in fact it should work. Copy-object should work for any kind of CLOS
object... I have used it for stuff not even CM related. What kind of
error are you getting when you attempt to use copy-object? What
version of CM do you have? Maybe there is an old bug?
What I often do to avoid any of this is something like
(output (new csound-event-subclass ...))
just setting the slot values in each output statement. If this is
tedious, then copy-object should (ideally!) do the trick.
You can avoid using defprocess entirely and just insert events into a list:
(setf my-events
(list (new csound-event-subclass ...)
(new csound-event-subclass ...)
(new csound-event-subclass ...)
...))
(events my-events "mypiece.sco" 0 ...)
>My goal is that I would to sprout a short (say three or four) sequence
>of csound score events.
>
>I thought that rather than hassle with patterns, it would be simpler and
>easier to read, if I can simply write a handfull of sv's and output's
>linearly, so to speak.
>
>For example,
>
>(defprocess note ()
> (let (o (new csound-event-subclass ...))
> process repeat 1 do
> (sv o ...)
> (output o)
> (sv o ...)
> (output o)
> (sv o ....)
> (output o)
> wait 4))))
>
>With this process I intend to define a conceptual "note" that is a short
>sequence of csound events (in this particular case, using a negative p3
>on all but the last event).
>
>In this situation, I want to create an object "o" in the let
>initialization and define the values of most of the slots. In the "sv"'s
>I will modify only one or two of the slots.
>
>I tried the above method both by setting the time slot in the "sv"
>functions, and by providing the optional start-time parameter to the
>"output" functions.
>
>The problem is that it seems that the "sv" calls happen all at once, so
>what happens is that the second and third outputs both get the final
>(third) values of the slots.
>
>I then tried using "copy-object" to use a seperate clone an instance of
>the prototype csound object before modifying it for each output, but for
>some reason the "copy-object" method ends up being undefined for my
>csound event subclass.
>
>Questions:
>
>1. Is there a better idiom for this type of thing? In particular, it
>seems awkward to have to define a process using "repeat 1" for this.
>
>2. What doesn't the default copy-object method work? Do I really need to
>define one for every csound subclass? I would think that copy-object by
>default would simply copy all the slots, but is this not the case?
>
>
>Regards
>
>Larry
>_______________________________________________
>Cmdist mailing list
>Cmdist@ccrma.stanford.edu
>http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist