[CM] GUILE -> Abnormal Exit (snd-rt)

Kjetil S. Matheussen k.s.matheussen@notam02.no
Sun, 11 Mar 2007 14:23:36 +0100 (CET)


On Sun, 11 Mar 2007, Esben Stien wrote:

> Trying to run some GUI code, I'm getting:
>
> <jack-rt-driver> -> destructor
>
> Some deprecated features have been used.  Set the environment
> variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
> program to get more information.  Set it to "no" to suppress
> this message.
>
> Process scheme exited abnormally with code 1
>
> Here's the code:
>

...

>  (let* ((start (floor (* start-time (mus-srate))))
> 	 (len (floor (* duration (mus-srate))))
> 					;wtf?

...

>    ;;
> ;    (instrument
>     (<rt-play> 0 2

...

>    (exit (lambda ()
> 	    (-> instrument stop)
> 	    (-> d hide)))
>


Whats happening here is that "exit" is not a variable in the let* block, 
but a command being executed (thats why snd is exiting).



>
> Any pointers as to what I'm doing wrong?. When I uncomment the
> "instrument" line, I'm getting an error that "instrument" is
> undefined, but it seems to work fine for the examples in
> rt-examples.scm.
>

Yes, you should not uncomment the "instrument" line, because that is the 
name of the variable holding the <rt> instance, which you need later.

The reason for the error you get seems like an indentation error. The
last variable in the instrument is "d". Everything after that are 
commands to be executed. And it seems like you are missing a paranthesis
after the declaration of "d".

You also need letrec* instead of let*, because you are referencing
"d" in "exit", which is declared later.

A version with those changes is below. I don't get any sound though, but
maybe its not supposed to make any sound yet?


(definstrument (a_new_gnu_order start-time duration frequency amplitude #:key
          (partial0 1.0)(partial-amplitude0 0.8)
          (partial1 1.593)(partial-amplitude1 0.6)
          (partial2 2.135)(partial-amplitude2 0.6)
          (partial3 2.295)(partial-amplitude3 0.35)
          (partial4 2.917)(partial-amplitude4 0.3)
          (partial5 3.598)(partial-amplitude5 0.2)
          (amplitude-envelope-list '(0 0 .04 1 .4 1 1 0))
          ;;(amplitude-envelope '(0 0.5 1 0 1 0)))
          #:allow-other-keys)
   (letrec* ((start (floor (* start-time (mus-srate))))
          (len (floor (* duration (mus-srate))))
                                         ;wtf?
          (foundit 1)
          (face 100.0)
          ;;base oscillator
          (sine0 (make-oscil :frequency frequency))
          (sine1 (make-oscil :frequency (* partial0 frequency)))
          (sine2 (make-oscil :frequency (* partial1 frequency)))
          (sine3 (make-oscil :frequency (* partial2 frequency)))
          (sine4 (make-oscil :frequency (* partial3 frequency)))
          (sine5 (make-oscil :frequency (* partial4 frequency)))
          (sine6 (make-oscil :frequency (* partial5 frequency)))
          ;;insert modulating oscillator
          (mod (make-oscil :frequency 50))
          (indenv '(0 2 100 1))
 	 ;;snare   (indenv '(0 100 50 0))
          (devf (make-env :envelope indenv
                          :scaler (in-hz 75)
                          :start start
                          :end len))
          (amplitude-envelope (make-env :envelope amplitude-envelope-list
                                        :scaler amplitude
                                        :start start
                                        :end len))
          (output (make-vct len))
 	 ;;delete these two old lines from havanna
 	 ;;(osc (make-oscil))
          ;;(vol 4/6)
 	 (face 0.5)
 	 (instrument
 	  (<rt-play>
 		     (lambda ()
 		       (receive-midi (lambda (control data1 data2)
 				       (set! control (logand #xf0 control))
 				       ;;(printf "gakk! %x %x %x\\n" control data1 data2)
 				       (if (= control #x90)
 					   (begin
 					     (set! foundit 1)))))

 		       (out
 			(* face
 			   (env amplitude-envelope)
 			   (+ (* partial-amplitude0 (oscil sine1 (* (env devf) (oscil mod))))
 			      (* partial-amplitude1 (oscil sine2 (* (env devf) (oscil mod))))
 			      (* partial-amplitude2 (oscil sine3))
 			      (* partial-amplitude3 (oscil sine4))
 			      (* partial-amplitude4 (oscil sine5))
 			      (* partial-amplitude5 (oscil sine6))
 			      )
 			   )
 			)
 		       )
 		     )
 	  )
 	 (exit (lambda ()
 		 (-> instrument stop)
 		 (-> d hide)))

 	 (d (<dialog> "Finally!"  exit
 		      "Close" exit
 		      "Stop" (<- instrument stop)
 		      "Start" (<- instrument play))))

     (<slider> d "Amplitude"
 	      0 (-> instrument face) 1.0
 	      (lambda (val)
 		(set! (-> instrument face) val))
 	      1000)

     (-> d show)))