[fluxus] every-frame functions
Dave Griffiths
dave at pawfal.org
Wed Jun 29 06:48:07 PDT 2005
>>>I'm not sure I get exactly what you mean, but maybe a better way of
>>>doing this would be to do something like
>>>
>>>(define (osc-repl)
>>> (if (osc-msg "/code") ; if /code message is recieved
>>> (eval-string (osc 0))) ; read the first argument as code
>>> (if (osc-msg "/foo") ; if /foo message is recieved
>>> (do-something-else))
>>> (render-stuff)) ; call other functions
>>>
>>>(start-osc "88008")
>>>(every-frame "(osc-repl)")
>>>
>>>then you could send a message along the lines of
>>>/code "(build-sphere 12 12)"
>>>
>>>you could send one message for code that is to be evaluated once, and
>>>another for code to be evaluated each frame etc etc.
>
> maybe something like the following could work, in that it provides a way
> for
> new functions to be evaluated at 'every-frame', without disturbing
> functions that allready are. ,.
>
> essentially just shifting the burden error to another palace ;)
>
>
> (define frame-functions '())
>
> (define (add-frame-fcn str)
> (set! frame-functions
> (cons str frame-functions)))
>
> (define (rem-frame-fcn str)
> (set! frame-functions
> (delete str frame-functions)))
>
> (define (clear-frame-fcn)
> (set! frame-functions '()))
>
> (define (mevery-frame)
> (map eval-string frame-functions))
>
> (every-frame "(mevery-frame)")
>
> ,. then register new functions using add-frame-fcn, rather than
> every-frame.
> (while being careful not to load scripts that call every-frame )
that's a neat solution... I think the multiple interpreters approach would
be the best fix, as the scripts wouldn't be able to mess with each other -
but I'm worried about the cpu overhead. Not that you'd have to use them, I
suppose...
> also this works given the name of functions as strings, ie. (add-frame-fcn
> "convulse") rather than using something similar to (every-frame
> "(convulse)"). is there a particular reason why the function is referenced
> this way?+
not really, I just wasn't sure how to do it. I was going to have an
implicit function called every frame (a bit like processing does this) but
I thought it would be easier to just specify a fragment of script.
cheers,
dave
More information about the Fluxus
mailing list