[CM] Faust and Snd-rt

Kjetil S. Matheussen k.s.matheussen at notam02.no
Mon, 17 Mar 2008 15:58:15 +0100 (CET)


Hi,

Latest versions of snd and snd-ls: 
http://www.notam02.no/arkiv/src/snd/snd-ls-0.9.8.9.tar.gz
contain code to use faust from snd-rt.

I have mentioned this both on the linux audio mailing
list and on the linux audio conference but haven't had
time to implement it yet.

This is the faust module containing glue code for snd-rt:

  http://www.notam02.no/arkiv/src/snd/snd-rt-gtk.cpp

...which must be copied it into the lib/faust directory.
Hopefully Yann will include it in faust. (Its almost
entirely similar to the jack-gtk module though.)



Simplest example:

  (<rt-faust> (out (osc 400)))



...which is exactly the same as:

  (<rt-faust> "process=osc(400);")



Larger example:

  (<rt-faust> (import "math.lib")
              (= (smooth c) (colon "*(1-c)" "+~*(c)"))
              (= vol        (colon  (hslider "volume (db)" 0 -96 0 0.1)
                                    db2linear
                                    (smooth 0.99)))
              (= freq       (hslider "freq" 1000 0 24000 0.1))
              (out (vgroup "Osc" (* (osci freq) vol))))



Evaluating code in the x11 buffer, for example from the faust software 
catalog:

  (<rt-faust> :autoimport-libs #f	   
             (x11-selection))


Import code from url:

  (<rt-faust> (url "http://..."))



Import local file:

  (<rt-faust> (include "/home/kjetil/snd-run/osc.dsp"))



Display the faust source of the lastest evaluated faust object:
  (display-faust-source)



Sending sound from one RT object to another:

(let ((abus (make-bus)))
  (<rt-faust> :in-bus abus
              (= (smooth c) "*(1-c) : +~*(c)")
              (= gain       (colon (vslider " dB " 0 -96 4 0.1)
                                   db2linear
                                   (smooth 0.999)))
              (out (vgroup "fader" "*(gain)")))
  (<rt-out> :out-bus abus
            (oscil)))


Using faust to monitor the output of the RT engine:

  (<rt-faust> :in-bus *out-bus*
             "vmeter(x)       = attach(x, envelop(x) : vbargraph(\"dB\", -96, 10));
              hmeter(x)       = attach(x, envelop(x) : hbargraph(\"dB\", -96, 10));
              envelop         = abs : max(db2linear(-96)) : linear2db : min(10)  : max ~ -(96.0/SR);
              process         = vmeter;")



Faust lisp macro:

  (define-faust-macro (oscivol freq vol)
    `(* ,vol (osci ,freq)))

  (<rt-faust> (out (oscivol 500 0.2)))



Calling Faust functions from Snd-Rt code.
Both the frequency slider and the volume
slider will appear in the same dialog:

  (<rt-out> (* (<faust> (= freq    (vslider "freq" 600 0 2400 0.1))
                        (= process (vgroup "ai" (osc freq))))
               (<slider> "vol" 0.0 0.1 1.0)))