osdir.com
mailing list archive

Subject: Using Stalin as a realtime extension language for Snd. - msg#00088

List: lisp.ccrma.general

Date: Prev Next Index Thread: Prev Next Index

Lately I've been working on making the Scheme compiler
"Stalin" work as an extension language for the realtime
system in Snd.

Its still a little bit incomplete, and there are some known
bugs, but its very cool and there's definitly sound now.

Stalin is an almost conforming R4RS Scheme
compiler written by Jeffrey Siskind, and it produces
code which competes with, and is often faster than,
hand-written C. And of course it provides common Scheme
features such as closures, higher order functions,
lists, vectors, continuations and so on.

And since all of this is now available in realtime, this
system should provide the first no-compromise
realtime music programming environment.


Evaluating the following block makes a cloud of 50-60 sinus grains
playing simultaniously, spawning a new grain every 15 ms
on average:

(<rt-stalin>
(let loop ()
(spawn :wait (irandom 30):-ms
(loop)
(define osc (make-oscil :frequency (ibetween 50 2000)))
(define duration (ibetween 400 2000):-ms)
(define e (make-env '(0 0 0.5 0.05 1 0) :end duration))
(block :dur duration :cont #f
(out (* (env e)
(oscil osc)))))))

(http://www.notam02.no/~kjetism/jack_capture_05.mp3)

On my four year old machine, this block uses about 50%
cpu time. I think though, that much of that
time is spent in the garbage collector/memory allocator,
and there are some thing which can yet be done to
significantly increase the performance of the garbage
collector and memory allocator.

Note that everyting inside the <rt-stalin> block happens
inside the realtime thread, including the spawning of
new "block" blocks, so scheduling is guaranteed
to both be on time and to be frame accurate. (This can
be done in the language "Chuck" as well, but at about
100 times (I would guess) slower speed. (I have measured
Chuck to be about 40 times slower than the RT compiler
when doing frame by frame processing, so Chuck is
probably about 100 times (or so) slower than Stalin.))


The following block creates a simple polyphonic midi soft synth:

(<rt-stalin>
(let loop ()
(wait-midi :cont (loop)
(when (midi-play?)
(let ((note (midi-note)))

;; Spawn a simple oscillator
(define oscillator (spawn
(let ((osc (make-oscil :frequency (midi-to-freq
note))))
(block
(out (* 0.2 (oscil osc)))))))

;; Spawn a job waiting for a stop message for this note.
(spawn
(wait-midi :cont #f
(when (and (midi-stop?)
(= note
(midi-note)))
(stop oscillator)
#t))) ;; Got it. Stop waiting for more midi.

#t))))) ;; Got it.

I think I'll change the syntax a little bit for midi though.


The code for Snd is in CVS. Required packages are:

Stalin:
http://cobweb.ecn.purdue.edu/~qobi/software.html

Rollendurchmesserzeitsammler: (at least v0.0.3)
http://www.notam02.no/arkiv/src/

libpcl:
http://www.xmailserver.org/libpcl.html



(Oh, and I've added coroutines to the old "rt" compiler
as well, like in Chuck. See the file rt-coroutines.scm)


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Getting started

In the cmn package, (trace output-file) should show you what file cmn thinks it is writing. The Mac Finder might be able to find it, or just look for any eps file in the current directory.

Next Message by Date: click to view message preview

ancient music

Dear Bill, my friend Stephane, music teacher, needs symbols to write scores from late XVe (1450-..): brevis, semi-brevis, maxima, etc. Is there a way to do that in CMN ? Thanks, -- R. Bastian www.musiques-rb.org

Previous Message by Thread: click to view message preview

Getting started

I'm using mac system 10.2.8 with clisp version 2.43-2 (downloaded from fink) and I can't get cmn to work. I'm following all of the instructions to the best of my ability and I'm not getting any error messages but the file aaa.eps isn't showing up anywhere. And I don't have ghostscript--was intending to open the eps file with Preview if I could find it. So what is it I'm doing wrong? I'm a musician, not a computer guy, so please, don't tell me to frimfram the bobwip and googaw the geezer because I don't know what a frimfram is or what it does to a geezer. Probably not something good I would suspect. Regards, Lee (musically literate guitarist)

Next Message by Thread: click to view message preview

Re: Using Stalin as a realtime extension language for Snd.

On Mon, 26 May 2008, Kjetil S. Matheussen wrote: > Evaluating the following block makes a cloud of 50-60 sinus grains Oops, it just came to my attention that in English, unlike most other languages in the world, sinus is called "sine", while sinus is a part of the nose or something. Well, hopefully no one misunderstood too much what I ment. :-)
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by