[CM] Realtime music programming using Snd-Rt

Kjetil S. Matheussen k.s.matheussen at notam02.no
Thu Jul 17 05:44:12 PDT 2008


Current Snd contains code which is able to run
the examples in the paper without using
a minute to compile:

http://www.notam02.no/arkiv/doc/snd-rt/icmc2008_examples.txt


[The reason it's so much faster now is that I've added some
non-cps call/cc removal algorithms to the
stalin preprocessor in snd since call/cc and cps-ed code takes
a very long time to compile with stalin. (((The stalin
preprocessor knows about some functions which are continuations,
and the Stalin compiler itself doesn't know about those.)))
Some code with call/cc will of course still have to
be translated to cps code, but most of the most important ones
(those who are added by wait, spawn, block, etc) are removed.]


Here is an extended version of the midi softsynth w/adsr envelope:

(<rt-stalin>
 (while #t
   (wait-midi :command note-on
     (define adsr (make-adsr :a 20:-ms :d 20:-ms :s 0.2 :r 50:-ms))
     (define osc
       (make-oscil :freq (midi-to-freq (midi-note))))
     (spawn
       (block
         (define vol (adsr))
         (if vol
             (out (* 0.2 vol (midi-vol) (oscil osc)))
             (stop))))
     (spawn
       (wait-midi :command note-off :note (midi-note)
         (-> adsr stop))))))


I have also added stack checks, cpu checks and a very simple
backtrace to stalin code. This makes developing very
convenient, but the code also takes xx (maybe xxx) times
longer to execute.

To remove those checks, do:
(<rt-stalin> :runtime-checks #f ...)



More information about the Cmdist mailing list