[CM] sprouts & closure in CM

taube@uiuc.edu taube@uiuc.edu
Sun, 12 Jun 2005 09:37:44 -0500

>   So I find myself wanting to (1) decouple the calling and sprouted
>   functions; and (2) be able to pass values back from the latter to the
>   former. Condition (2) would enable me for example, to use the last
>   pitch in some random sprout as the starting pitch to the next sprout
>   (thereby letting me form feedback chains etc).

i think i see what you want to do: so your main process wants to sprout, then
wait until the sproutee stops and "returns" a value, then the main function
continues on using that value to sprout a new process, and so on?
ill have to think about this, currently processes are lisp functinos called by a
scheudler; ie there is no place to return values to.

im thinking perhaps a realtime scheduler might be able to do this more easily,
ie the caller sprouts and then waits for some condition to arise.

>   Maybe process & sprout aren't really built for this, but I'm hoping
>   you're enticed by the possibilities. If I run across a workaround I'll
>   post it to the list.
>   Thanks for your reply. Hope I'm not ruining your summer,
>   Drew
>   taube@uiuc.edu wrote:
> You could chain processes using the 'finally' clause:
> (define (foo reps lev)
>   (process repeat reps
>            output <whatever>
>            wait <whenever>
>            finally
>            (if (> lev 0)
>                (sprout (foo reps (- lev 1))
>                        (now)))))
> (events (foo 20 3) "foo.bar")
> i should probably (re)implement a container like the old Thread class that would
> process each subcontainer and generates all items before moving on to the next
> subcontainer. the problem is that there is no 'rhythm slot for relative time
> values and I havent quite figured out how to fold this into object-time
> (absolute) time values. any ideas welcome!
> ---- Original message ----
> Date: Fri, 10 Jun 2005 14:58:36 -0400
> From: Drew Krause <drkrause@mindspring.com> 
> Subject: [CM] sprouts & closure in CM 
> To: CMDIST <cmdist@ccrma.Stanford.EDU>
> I'd like to do something fairly simple in CM: define a function that
> would place sections end-to-end, starting one section when the previous
> section ends. I can do this by setting a global variable:
> (setf glob-ending '())
> Then defining the 'collecting' program ...
> (define sections (&rest sprts)
>    (process (for sprt in sprts
>    sprout (eval sprt)
>    wait glob-ending)))
> ... and adding the following line to each 'sprouted' section I'm using,
> so it's passed back to "sections":
> finally (setf glob-ending (now))
> This is not the most desirable method for obvious reasons --
> specifically, I'd like this section-length variable to be closed inside
> "sections". Any solutions/other approaches out there? Thanks!
> _______________________________________________
> Cmdist mailing list
> Cmdist@ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist