live coding and subsecond sleep

fred lakin at pgc.com
Fri Nov 20 04:44:50 CET 2009


Folks --

Thanks to cmucl and the kind support of folks on this list, my
lisp-based graphics system has gotten to the point of taking it on
the road. There is something called "live coding", which is "the
process of writing software in realtime as part of a performance"
(see wikiped below).

So, is anyone else doing this kind of stuff in cmucl?

And, two technical questions related to starting subprocesses which
automatically do animation whilst I manually do other things at the
same time.

1. Is there a way to get subsecond waits in cmucl? SLEEP, as
expected, doesn't do less than 1 sec

2. The user input loop for my graphics system uses XLIB:EVENT-CASE
-- which has the odd consequence that when I call STREAKX via
START-STREAKXING, every time I move the mouse, it terminates the
current sleep cycle. That is, with the mouse motionless, the visual
object is repainted every 1 second. But if I quickly circle the
mouse, then the vizobj is repainted very much more frequently, as if
being advanced by each mouse event. This effect is not always bad
during performances, but I'd like to understand it and be able to
control it.

thanks,
-f


************ refs and code ******************

http://en.wikipedia.org/wiki/Live_coding

fluxus, scheme-based live coding system
http://www.pawfal.org/fluxus/

impromptu, scheme-based live coding system
http://impromptu.moso.com.au/

OpenGL bindings for CMU Common Lisp and SBCL
http://www.ii.uib.no/~knute/lisp/lisp.html


;;actual wait interval is always 1 second ...
; *unless* mouse is moved when inside XLIB:EVENT-CASE
(defun streak (vizobj &key (wait .001) (loc '(0 . 0)))
  (loop for i from 1 to 99
	as newx = (+ (locx loc) (* i 3))
	as newy = (+ (locy loc) (* i 3))
     do (addToScreenRel-no-scale vizobj newx newy)
        (xlib:display-force-output xlib::*vmacs-display*)
        (SLEEP WAIT)))

(defun start-streaking (vizobj &key (wait .001) (loc '(0 . 0)))
  (let ((copy (vizcopy vizobj)))
    (moveto copy '(0 . 0))
    (MP:MAKE-PROCESS (function (lambda () (streak copy :wait wait :loc loc)))
		     :name "streaker")
    ))



More information about the cmucl-help mailing list