;;; Snd tests
;;;
;;;  test 0: constants                           [599]
;;;  test 1: defaults                            [1144]
;;;  test 2: headers                             [1346]
;;;  test 3: variables                           [1663]
;;;  test 4: sndlib                              [2288]
;;;  test 5: simple overall checks               [4961]
;;;  test 6: vcts                                [14029]
;;;  test 7: colors                              [14430]
;;;  test 8: clm                                 [14937]
;;;  test 9: mix                                 [26835]
;;;  test 10: marks                              [29076]
;;;  test 11: dialogs                            [30058]
;;;  test 12: extensions                         [30270]
;;;  test 13: menus, edit lists, hooks, etc      [30541]
;;;  test 14: all together now                   [32142]
;;;  test 15: chan-local vars                    [33061]
;;;  test 16: regularized funcs                  [34861]
;;;  test 17: dialogs and graphics               [39812]
;;;  test 18: enved                              [39904]
;;;  test 19: save and restore                   [39923]
;;;  test 20: transforms                         [41699]
;;;  test 21: new stuff                          [43889]
;;;  test 22: run                                [45895]
;;;  test 23: with-sound                         [52764]
;;;  test 25: X/Xt/Xm                            [57348]
;;;  test 26: Gtk                                [61066]
;;;  test 27: GL                                 [64541]
;;;  test 28: errors                             [64665]
;;;  test all done                               [67140]
;;;  test the end                                [67326]

(define tests 1)
(define keep-going #f)
(define all-args #t)
(define test-at-random 0)
					;(show-ptree 1)
(define profiling #f)

					;(set! *load-hook* (lambda (name) (format #t "load ~S~%" name)))
(if (<= tests 0) (set! tests 1))

(set! *#readers* 
      (cons (cons #\_ (lambda (str)
			(if (string=? str "__line__")
			    (port-line-number)
			    #f)))
            *#readers*))

(if (defined? 'run-clear-counts) (run-clear-counts))

(define O_RDWR 2)
(define O_APPEND 1024)
(define O_RDONLY 0)

(define (copy-file src dest) (system (string-append "cp " src " " dest)))

(define (procedure-property func prop)
  (if (eq? prop 'arity)
      (procedure-arity func)
      (procedure-documentation func)))

(define (string-downcase str)
  (let* ((len (string-length str))
	 (newstr (make-string len)))
    (do ((i 0 (+ 1 i)))
	((= i len))
      (string-set! newstr i (char-downcase (string-ref str i))))
    newstr))

(define (sort lst . opt) (sort! lst (if (null? opt) < (car opt))))

(define* (cfft! data n (dir 1))
  (if (not n) (set! n (length data)))
  (do ((i 0 (+ i 1))
       (j 0))
      ((= i n))
    (if (> j i)
	(let ((temp (data j)))
	  (set! (data j) (data i))
	  (set! (data i) temp)))
    (let ((m (/ n 2)))
      (do () 
	  ((or (< m 2) (< j m)))
	(set! j (- j m))
	(set! m (/ m 2)))
      (set! j (+ j m))))
  (let ((ipow (floor (log n 2)))
	(prev 1))
    (do ((lg 0 (+ lg 1))
	 (mmax 2 (* mmax 2))
	 (pow (/ n 2) (/ pow 2))
	 (theta (make-rectangular 0.0 (* pi dir)) (* theta 0.5)))
	((= lg ipow))
      (let ((wpc (exp theta))
	    (wc 1.0))
	(do ((ii 0 (+ ii 1)))
	    ((= ii prev))
	  (do ((jj 0 (+ jj 1))
	       (i ii (+ i mmax))
	       (j (+ ii prev) (+ j mmax)))
	      ((>= jj pow))
	    (let ((tc (* wc (data j))))
	      (set! (data j) (- (data i) tc))
	      (set! (data i) (+ (data i) tc))))
	  (set! wc (* wc wpc)))
	(set! prev mmax))))
  data)

(define* (fft! rl im n (dir 1))
  (if (not im)
      (let ((clear (copy rl)))
	(fill! clear 0.0)
	(set! im clear)))
  (if (not n)
      (set! n (length rl)))
  (do ((i 0 (+ i 1))
       (j 0))
      ((= i n))
    (if (> j i)
	(let ((tempr (rl j))
	      (tempi (im j)))
	  (set! (rl j) (rl i))
	  (set! (im j) (im i))
	  (set! (rl i) tempr)
	  (set! (im i) tempi)))
    (let ((m (/ n 2)))
      (do () 
	  ((or (< m 2) (< j m)))
	(set! j (- j m))
	(set! m (/ m 2)))
      (set! j (+ j m))))
  (let ((ipow (floor (log n 2)))
	(prev 1))
    (do ((lg 0 (+ lg 1))
	 (mmax 2 (* mmax 2))
	 (pow (/ n 2) (/ pow 2))
	 (theta (* pi dir) (* theta 0.5)))
	((= lg ipow))
      (let ((wpr (cos theta))
	    (wpi (sin theta))
	    (wr 1.0)
	    (wi 0.0))
	(do ((ii 0 (+ ii 1)))
	    ((= ii prev))
	  (do ((jj 0 (+ jj 1))
	       (i ii (+ i mmax))
	       (j (+ ii prev) (+ j mmax)))
	      ((>= jj pow))
	    (let ((tempr (- (* wr (rl j)) (* wi (im j))))
		  (tempi (+ (* wr (im j)) (* wi (rl j)))))
	      (set! (rl j) (- (rl i) tempr))
	      (set! (im j) (- (im i) tempi))
	      (set! (rl i) (+ (rl i) tempr))
	      (set! (im i) (+ (im i) tempi))))
	  (let ((wtemp wr))
	    (set! wr (- (* wr wpr) (* wi wpi)))
	    (set! wi (+ (* wi wpr) (* wtemp wpi)))))
	(set! prev mmax))))
  rl)

(if (not (defined? 'snd-test)) (define snd-test -1))
(define full-test (< snd-test 0))
(define total-tests 28)
(if (not (defined? 'with-exit)) (define with-exit (< snd-test 0)))
(define test-number -1)

(define (snd-display line . args)
  (let ((str (if (null? (cdr args))
		 (car args)
		 (apply format #f args))))
    (format #t "~%~A: ~8T~A" line str)
    (if (not (provided? 'snd-nogui))
	(snd-print (format #f "~%~A: ~A" line str)))))

(define with-big-file #f)
(define big-file-name "/home/bil/zap/sounds/bigger.snd")
(if (and with-big-file 
	 (not (string=? (version) "1.8.0")))
    (begin
      (set! with-big-file (file-exists? big-file-name))
      (if (not with-big-file) (snd-display #__line__ ";no big file"))))
(define big-file-frames 0)

(define original-save-dir (or (save-dir) "~/zap/snd"))
(define original-temp-dir (or (temp-dir) "~/zap/tmp"))
(define original-sound-file-extensions (sound-file-extensions))

(unbind-key #\c 4 #t)
;;; clear out old junk!
(if (file-exists? original-save-dir) 
    (system (format #f "rm ~A/snd_*" original-save-dir)))
(if (file-exists? original-temp-dir) 
    (system (format #f "rm ~A/snd_*" original-temp-dir)))
(if (file-exists? "/tmp")
    (begin ; -noinit possibly
      (system "rm /tmp/snd_*")
      (system "rm /tmp/*.snd")))
(if (file-exists? "/var/tmp")
    (begin ; -noinit possibly
      (system "rm /var/tmp/snd_*")
      (system "rm /var/tmp/*.snd")))
(system "rm core*")

(define home-dir "/home/bil")
(define sf-dir "/sf1")

(if (not (file-exists? (string-append home-dir "/cl/oboe.snd")))
    (if (file-exists? "/export/home/bil/cl/oboe.snd")
	(set! home-dir "/export/home/bil")
	(if (file-exists? "/Users/bil/cl/oboe.snd")
	    (set! home-dir "/Users/bil")
	    (if (file-exists? "/users/b/bil/cl/oboe.snd")
		(set! home-dir "/users/b/bil")))))
(define cwd (string-append (getcwd) "/"))

(define sf-dir1 (string-append home-dir sf-dir "/"))
(if (not (file-exists? (string-append sf-dir1 "alaw.wav")))
    (begin
      (set! sf-dir "/sf")
      (set! sf-dir1 (string-append home-dir sf-dir "/"))
      (if (not (file-exists? (string-append sf-dir1 "alaw.wav")))
	  (begin
	    (snd-display #__line__ ";;;can't find sf directory!")
	    (set! sf-dir1 #f)))))
(set! sf-dir sf-dir1)

(if (not (string=? (getcwd) (string-append home-dir "/cl")))
    (for-each
     (lambda (file)
       (if (not (file-exists? file))
	   (begin
	     (display (format #f "copying ~A~%" file))
	     (copy-file (string-append home-dir "/cl/" file) (string-append (getcwd) "/" file)))))
     (list "4.aiff" "2.snd" "obtest.snd" "oboe.snd" "pistol.snd" "1a.snd" "now.snd" "fyow.snd"
	   "storm.snd" "z.snd" "1.snd" "cardinal.snd" "now.snd.scm" "2a.snd" "4a.snd" "zero.snd"
	   "loop.scm" "cmn-glyphs.lisp" "bullet.xpm" "mb.snd" "funcs.cl" "trumpet.snd")))


;;(setlocale LC_ALL "de_DE")
(set! (with-background-processes) #f)
(define max-optimization 6)
(define sampler-tests 300)

;; try to get a different random number sequence on each run
(set! (mus-rand-seed) (current-time))

(reset-hook! bad-header-hook)
(add-hook! bad-header-hook (lambda (n) #t))

(define with-gui (or (provided? 'snd-gtk)
		     (provided? 'snd-motif)))

(if (not with-gui)
    (define y-bounds (make-procedure-with-setter
		      (lambda args (list -1.0 1.0))
		      (lambda args (list -1.0 1.0)))))

(if (not with-gui)
    (define x-bounds (make-procedure-with-setter
		      (lambda args (list 0.0 0.1))
		      (lambda args (list 0.0 0.1)))))

(if (file-exists? "optimizer.log")
    (delete-file "optimizer.log"))
(define optimizer-log (open-output-file "optimizer.log"))
(define optimizer-test -1)

(reset-hook! optimization-hook)
(define *opt* #f)
(add-hook! optimization-hook 
	   (lambda (msg)
	     (set! *opt* #f)
	     (if (= (optimization) max-optimization)
		 (begin
		   (if (not (= test-number optimizer-test))
		       (begin
			 (display (format #f "-------- test ~A --------~%" test-number) optimizer-log)
			 (set! optimizer-test test-number)))
		   (display msg optimizer-log)
		   (newline optimizer-log)))))

(define (real-time) (exact->inexact (/ (get-internal-real-time) internal-time-units-per-second)))
(define (hundred n) (round (* 100 n)))
(define times '())
(defmacro time (a) 
  `(let ((start (real-time))) 
     ,a 
     (let ((val (hundred (- (real-time) start))))
       (set! times (cons (list ',a val) times)))))

(define original-prompt (listener-prompt))
(set! (show-listener) #t)
(set! (window-x) 600)
(set! (window-y) 10)

(define test14-file #f)

(define (fneq a b) 
  "float equal within .001"
  (> (abs (- a b)) .001))

(define (ffneq a b)
  "float equal within .01"
  (> (abs (- a b)) .01))

(define (fffneq a b) 
  "float equal within .1"
  (> (abs (- a b)) .1))

(define (cneq a b)
  "complex equal within .001"
  (or (> (abs (- (real-part a) (real-part b))) .001)
      (> (abs (- (imag-part a) (imag-part b))) .001)))

(define (feql a b)
  "list equal with fneq"
  (if (null? a)
      (null? b)
      (if (null? b)
	  #f
	  (if (list? (car a))
	      (and (list? (car b))
		   (feql (car a) (car b)))
	      (if (fneq (car a) (car b))
		  #f
		  (feql (cdr a) (cdr b)))))))

(define (ffeql a b)
  "list equal with fffneq"
  (if (null? a)
      (null? b)
      (if (null? b)
	  #f
	  (if (list? (car a))
	      (and (list? (car b))
		   (ffeql (car a) (car b)))
	      (if (fffneq (car a) (car b))
		  #f
		  (ffeql (cdr a) (cdr b)))))))

(define (fveql a b i)
  "vct equal with fneq"
  (if (null? b)
      #t
      (if (fneq (car b) (vct-ref a i))
	  #f
	  (fveql a (cdr b) (+ i 1)))))

(define (vequal v0 v1)
  "general equal with .001"
  (let ((old-fudge (mus-float-equal-fudge-factor)))
    (set! (mus-float-equal-fudge-factor) .001)
    (let ((result (equal? v0 v1)))
      (set! (mus-float-equal-fudge-factor) old-fudge)
      result)))

(define (vequal1 v0 v1)
  "general equal with .01"
  (let ((old-fudge (mus-float-equal-fudge-factor)))
    (set! (mus-float-equal-fudge-factor) .01)
    (let ((result (equal? v0 v1)))
      (set! (mus-float-equal-fudge-factor) old-fudge)
      result)))

(define (vvequal v0 v1)
  "general equal with .00002"
  (let ((old-fudge (mus-float-equal-fudge-factor)))
    (set! (mus-float-equal-fudge-factor) .00002)
    (let ((result (equal? v0 v1)))
      (set! (mus-float-equal-fudge-factor) old-fudge)
      result)))

(define (vmaxdiff v0 v1)
  (vct-peak (vct-subtract! (vct-copy v0) v1)))

(define (sd-equal v0 v1)
  "sound-data equal within .001"
  (let ((old-fudge (mus-float-equal-fudge-factor)))
    (set! (mus-float-equal-fudge-factor) .001)
    (let ((result (equal? v0 v1)))
      (set! (mus-float-equal-fudge-factor) old-fudge)
      result)))

(define* (my-substring str start end)
  "substring with end"
  (substring str start (or end (string-length str))))

(define (string-=? a b)
  "string=? but ignore -0.0"
  (or (string=? a b)
      (let* ((alen (string-length a))
	     (blen (string-length b))
	     (j 0)
	     (happy #t))
	(do ((i 0 (+ 1 i)))
	    ((or (not happy) 
		 (= i alen))
	     (and happy 
		  (= j blen)))
	  (let ((ac (string-ref a i))
		(bc (string-ref b j)))
	    (if (char=? ac bc)
		(set! j (+ 1 j))
		(if (not (and (char=? ac #\-)	
			      (<= i (- alen 7))
			      (string=? (substring a i (+ i 6)) "-0.000")))
		    (if (and (char=? bc #\-)
			     (<= j (- blen 7))
			     (string=? (substring b j (+ j 6)) "-0.000"))
			(begin
			  (set! j (+ 1 j))
			  (if (not (char=? ac (string-ref b j)))
			      (set! happy #f)
			      (set! j (+ 1 j))))
			(set! happy #f)))))))))

(define (dismiss-all-dialogs)
  "(dismiss-all-dialogs) hides all dialogs"
  (if (or (provided? 'xm)
	  (provided? 'xg))
      (for-each
       (lambda (dialog)
	 (if dialog
	     (if (symbol? (car dialog))
		 (if (provided? 'snd-motif)
		     (if (XtIsManaged dialog)
			 (XtUnmanageChild dialog))
		     (if (provided? 'snd-gtk)
			 (gtk_widget_hide dialog)))
		 (for-each
		  (lambda (d)
		    (if (symbol? (car d))
			(if (provided? 'snd-motif)
			    (if (XtIsManaged d)
				(XtUnmanageChild d))
			    (if (provided? 'snd-gtk)
				(gtk_widget_hide d)))))
		  dialog))))
       (dialog-widgets))))

(define safe-color (make-color 1 0 0))
(define (make-color-with-catch c1 c2 c3)
  "make-color but catch 'no-such-color"
  (catch 'no-such-color
	 (lambda () (make-color c1 c2 c3))
	 (lambda args safe-color)))

(define* (safe-display-edits snd chn edpos (with-source #t))
  "display-edits but catch all errors"
  (catch #t
	 (lambda () (display-edits snd chn edpos with-source))
	 (lambda args (snd-display #__line__ ";display-edits error: ~A" args))))

(define (safe-divide a b)
  "divide but check for 0 denom"
  (if (zero? b)
      a
      (/ a b)))

(define timings (make-vector (+ total-tests 1) 0))
(define default-srate (mus-srate))

(snd-display #__line__ ";;~A" (snd-version))
(if (not (defined? 'before-test-hook)) (define before-test-hook (make-hook 1)))
(if (not (defined? 'after-test-hook)) (define after-test-hook (make-hook 1)))
(reset-hook! before-test-hook)
(add-hook! before-test-hook (lambda (n)
			      (set! (mus-srate) default-srate)
			      (dismiss-all-dialogs)
			      (set! (clipping) #f)
			      (set! (mus-clipping) #f) ; this cost me a morning of confusion!
			      (set! test-number n)
			      (vector-set! timings n (real-time))
			      (snd-display #__line__ ";test ~D" n)
			      
			      ))


(define (clear-save-state-files)
  "forget regions and whatnot"
  (let ((regs (regions)))
    (for-each
     (lambda (n)
       (forget-region n))
     regs))
  
  (system (format #f "rm -f ~A/snd_*" (or (save-dir) original-save-dir)))
  (if (file-exists? "/var/tmp") 
      (system (format #f "rm -f /var/tmp/snd_save_*")))
  (if (file-exists? "/tmp") 
      (system (format #f "rm -f /tmp/snd_save_*")))
  (mus-sound-prune))

(reset-hook! after-test-hook)
(add-hook! after-test-hook
	   (lambda (n)
	     (clear-save-state-files)
	     (clear-listener)
	     
	     (if (not (null? (sounds)))
		 (begin
		   (snd-display #__line__ ";end test ~D: open sounds: ~A" n (map short-file-name (sounds)))
		   (for-each close-sound (sounds))))
	     (if (number? (vector-ref timings n))
		 (vector-set! timings n (hundred (- (real-time) (vector-ref timings n)))))))

(define overall-start-time (real-time))
(snd-display #__line__ ";~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))

(define (log-mem tst) 
  (if (> tests 1) (begin (snd-display #__line__ ";test ~D:~D " test-number (+ 1 tst)) )))

(defmacro without-errors (func)
  `(catch #t 
	  (lambda ()
	    ,func)
	  (lambda args 
	    (car args))))

(if (not (provided? 'snd-hooks.scm)) (load "hooks.scm"))
(if (not (provided? 'snd-ws.scm)) (load "ws.scm"))

(define (reset-almost-all-hooks)
  (with-local-hook optimization-hook '() reset-all-hooks))


(define (list-p val)
  "list? and not a null list!"
  (and (list? val)
       (not (null? val))))

(define (arity-ok func args)
  "func accepts args"
  (let ((arity (procedure-arity func)))
    (and (list-p arity)
	 (>= args (car arity))
	 (or (and (list-p (cddr arity))
		  (caddr arity))
	     (<= args (+ (car arity) (cadr arity)))))))

(define (set-arity-ok func args)
  "set proc accepts args"
  (let ((arity (if (procedure-with-setter? func)
		   (cdddr (procedure-arity func))
		   (procedure-arity func))))
    (and (list-p arity)
	 (>= args (car arity))
	 (or (and (list-p (cddr arity))
		  (caddr arity))
	     (<= args (+ (car arity) (cadr arity)))))))

(if (and (> (length (script-args)) 0)
	 (> (script-arg) 0))
    (let ((arg (script-arg))
	  (args (script-args)))
      (if (not (string=? (list-ref args (- arg 1)) "-l")) 
	  (snd-display #__line__ ";script-args[~A]: ~A (~A)?" (- arg 1) (list-ref args (- arg 1)) args))
      (if (not (string=? (list-ref args arg) "snd-test")) 
	  (snd-display #__line__ ";script-args[~A]: ~A (~A)?" arg (list-ref args arg) args))
      (if (> (length args) (+ 1 arg))
	  (begin
	    ;; test-number tests
	    (set! snd-test (string->number (list-ref args (+ 1 arg))))
	    (set! test-at-random 0)
	    (set! full-test (< snd-test 0))
	    (set! with-exit #t)
	    (set! (script-arg) (+ 1 arg))
	    (if (> (length (script-args)) (+ arg 2))
		(begin
		  (set! tests (string->number (list-ref args (+ arg 2))))
		  (set! (script-arg) (+ arg 2))))))))

(if (and (provided? 'snd-motif)
	 (provided? 'xm))
    (begin
      (if (not (provided? 'snd-snd-motif.scm)) (load "snd-motif.scm"))
      (if (not (provided? 'snd-popup.scm)) (load "popup.scm")))
    (if (and (provided? 'snd-gtk)
	     (provided? 'xg))
	(begin
	  (if (not (provided? 'snd-snd-gtk.scm)) (load "snd-gtk.scm"))
	  (if (not (provided? 'snd-gtk-popup.scm)) (load "gtk-popup.scm")))))

(if (not (provided? 'snd-snd7.scm)) (load "snd7.scm")) ; forward-graph
(if (not (provided? 'snd-snd8.scm)) (load "snd8.scm")) ; samples->sound-data
(if (not (provided? 'snd-snd9.scm)) (load "snd9.scm")) ; make-ppolar|zpolar, various generators later moved to generators.scm
(if (not (provided? 'snd-snd10.scm)) (load "snd10.scm"))
(if (not (provided? 'snd-snd11.scm)) (load "snd11.scm"))

					;(define widvardpy (make-variable-display "do-loop" "i*2" 'graph))

(define default-file-buffer-size 65536)
(set! (mus-file-buffer-size) default-file-buffer-size)

(if (not (defined? 'pi)) 
    (snd-display #__line__ ";pi is not defined!")
    (if (fneq pi 3.14159)
	(snd-display #__line__ ";pi is ~A" pi)))


;;; ---------------- test 0: constants ----------------

(define (snd_test_0)
  (letrec ((test-constants 
	    (lambda (lst)
	      (if (not (null? lst))
		  (begin
		    (if (not (= (cadr lst) (caddr lst)))
			(snd-display #__line__ ";~A /= ~A (~A)~%"
				     (car lst) (cadr lst) (caddr lst)))
		    (test-constants (cdddr lst)))))))
    
    (if (or (not (null? (sounds)))
	    (not (null? (mixes)))
	    (not (null? (marks)))
	    (not (null? (regions))))
	(snd-display #__line__ ";start up: ~A ~A ~A ~A" (sounds) (mixes) (marks) (regions)))
    (test-constants
     (list
      'enved-amplitude enved-amplitude 0 
      'bartlett-window bartlett-window 4 
      'bartlett-hann-window bartlett-hann-window 21
      'blackman2-window blackman2-window 6 
      'blackman3-window blackman3-window 7 
      'blackman4-window blackman4-window 8
      'blackman5-window blackman5-window 24
      'blackman6-window blackman6-window 25
      'blackman7-window blackman7-window 26
      'blackman8-window blackman8-window 27
      'blackman9-window blackman9-window 28
      'blackman10-window blackman10-window 29
      'bohman-window bohman-window 22
      'cauchy-window cauchy-window 12 
      'mlt-sine-window mlt-sine-window 33
      'papoulis-window papoulis-window 34
      'dpss-window dpss-window 35
      'sinc-window sinc-window 36
      'channels-combined channels-combined 1 
      'channels-separate channels-separate 0 
      'channels-superimposed channels-superimposed 2
      'connes-window connes-window 18
      'cursor-in-middle cursor-in-middle 3
      'cursor-in-view cursor-in-view 0 
      'cursor-on-left cursor-on-left 1 
      'cursor-on-right cursor-on-right 2 
      'dolph-chebyshev-window dolph-chebyshev-window 16
      'exponential-window exponential-window 9 
      'flat-top-window flat-top-window 23
      'zoom-focus-active zoom-focus-active 2
      'zoom-focus-left zoom-focus-left 0
      'zoom-focus-middle zoom-focus-middle 3
      'zoom-focus-right zoom-focus-right 1 
      'gaussian-window gaussian-window 14 
      'graph-dots graph-dots 1
      'graph-dots-and-lines graph-dots-and-lines 3 
      'graph-filled graph-filled 2 
      'graph-lines graph-lines 0 
      'graph-lollipops graph-lollipops 4
      'hamming-window hamming-window 5
      'hann-window hann-window 1
      'hann-poisson-window hann-poisson-window 17
      'kaiser-window kaiser-window 11 
      'keyboard-no-action keyboard-no-action 4
      'graph-once graph-once 0 
      'parzen-window parzen-window 3
      'poisson-window poisson-window 13
      'rectangular-window rectangular-window 0 
      'riemann-window riemann-window 10 
      'rv2-window rv2-window 30
      'rv3-window rv3-window 31
      'rv4-window rv4-window 32
      'samaraki-window samaraki-window 19
      'ultraspherical-window ultraspherical-window 20
      'graph-as-sonogram graph-as-sonogram 1
      'graph-as-spectrogram graph-as-spectrogram 2 
      'graph-once graph-once 0
      'graph-as-wavogram graph-as-wavogram 3
      'enved-spectrum enved-spectrum 1
      'speed-control-as-float speed-control-as-float 0 
      'speed-control-as-ratio speed-control-as-ratio 1 
      'speed-control-as-semitone speed-control-as-semitone 2 
      'enved-srate enved-srate 2 
      'tukey-window tukey-window 15 
      'welch-window welch-window 2 
      'cursor-cross cursor-cross 0
      'cursor-line cursor-line 1
      'dont-normalize dont-normalize 0
      'envelope-linear envelope-linear 0
      'envelope-exponential envelope-exponential 1
      'normalize-by-channel normalize-by-channel 1
      'normalize-by-sound normalize-by-sound 2
      'normalize-globally normalize-globally 3
      'x-axis-in-samples x-axis-in-samples 1 
      'x-axis-in-beats x-axis-in-beats 3
      'x-axis-in-measures x-axis-in-measures 4
      'x-axis-in-seconds x-axis-in-seconds 0 
      'x-axis-as-clock x-axis-as-clock 5
      'x-axis-as-percentage x-axis-as-percentage 2
      'enved-add-point enved-add-point 0
      'enved-delete-point enved-delete-point 1
      'enved-move-point enved-move-point 2
      'time-graph time-graph 0
      'transform-graph transform-graph 1
      'lisp-graph lisp-graph 2
      'copy-context copy-context 0
      'cursor-context cursor-context 3
      'selection-context selection-context 2
      'mark-context mark-context 4
      'show-no-axes show-no-axes 0
      'show-all-axes show-all-axes 1
      'show-x-axis show-x-axis 2
      'show-all-axes-unlabelled show-all-axes-unlabelled 3
      'show-x-axis-unlabelled show-x-axis-unlabelled 4
      'show-bare-x-axis show-bare-x-axis 5
      
      ;; sndlib constants
      'mus-unsupported mus-unsupported 0
      'mus-next mus-next 1
      'mus-aifc mus-aifc 2
      'mus-riff mus-riff 3
      'mus-nist mus-nist 6
      'mus-raw mus-raw 12
      'mus-ircam mus-ircam 15
      'mus-aiff mus-aiff 49
      'mus-bicsf mus-bicsf 5
      'mus-voc mus-voc 10
      'mus-svx mus-svx 9
      'mus-soundfont mus-soundfont 26
      'mus-rf64 mus-rf64 4
      'mus-caff mus-caff 60
      
      'mus-interp-none mus-interp-none 0
      'mus-interp-linear mus-interp-linear 1
      'mus-interp-sinusoidal mus-interp-sinusoidal 2
      'mus-interp-all-pass mus-interp-all-pass 3
      'mus-interp-lagrange mus-interp-lagrange 4
      'mus-interp-bezier mus-interp-bezier 5
      'mus-interp-hermite mus-interp-hermite 6
      
      'mus-chebyshev-first-kind mus-chebyshev-first-kind 1
      'mus-chebyshev-second-kind mus-chebyshev-second-kind 2
      
      'mus-unknown mus-unknown 0
      'mus-bshort mus-bshort 1
      'mus-lshort mus-lshort 10
      'mus-mulaw mus-mulaw 2
      'mus-alaw mus-alaw 6
      'mus-byte mus-byte 3
      'mus-ubyte mus-ubyte 7
      'mus-bfloat mus-bfloat 4
      'mus-lfloat mus-lfloat 12
      'mus-bint mus-bint 5
      'mus-lint mus-lint 11
      'mus-bintn mus-bintn 17
      'mus-lintn mus-lintn 18
      'mus-b24int mus-b24int 8
      'mus-l24int mus-l24int 16
      'mus-bdouble mus-bdouble 9
      'mus-ldouble mus-ldouble 13
      'mus-ubshort mus-ubshort 14
      'mus-ulshort mus-ulshort 15
      'mus-bfloat-unscaled mus-bfloat-unscaled 19
      'mus-lfloat-unscaled mus-lfloat-unscaled 20
      'mus-bdouble-unscaled mus-bdouble-unscaled 21
      'mus-ldouble-unscaled mus-ldouble-unscaled 22
      ))
    
    (set! (region-graph-style) (region-graph-style))
    (if (not (equal? (region-graph-style) graph-lines))
	(snd-display #__line__ ";region-graph-style set def: ~A" (region-graph-style)))
    (set! (ask-before-overwrite) (ask-before-overwrite)) 
    (if (not (equal? (ask-before-overwrite) #f)) 
	(snd-display #__line__ ";ask-before-overwrite set def: ~A" (ask-before-overwrite)))
    (set! (audio-output-device) (audio-output-device))
    (if (not (equal? (audio-output-device)  0)) 
	(snd-display #__line__ ";audio-output-device set def: ~A" (audio-output-device)))
    (set! (auto-resize) (auto-resize))
    (if (not (equal? (auto-resize)  #t )) 
	(snd-display #__line__ ";auto-resize set def: ~A" (auto-resize)))
    (set! (auto-update) (auto-update))
    (if (not (equal? (auto-update)  #f)) 
	(snd-display #__line__ ";auto-update set def: ~A" (auto-update)))
    (set! (channel-style) (channel-style))
    (if (not (equal? (channel-style)  1 )) 
	(snd-display #__line__ ";channel-style set def: ~A" (channel-style)))
    (set! (color-cutoff) (color-cutoff))
    (if (fneq (color-cutoff)  0.003 )
	(snd-display #__line__ ";color-cutoff set def: ~A" (color-cutoff)))
    (set! (color-inverted) (color-inverted))
    (if (not (equal? (color-inverted)  #t)) 
	(snd-display #__line__ ";color-inverted set def: ~A" (color-inverted)))
    (set! (color-scale) (color-scale))
    (if (fneq (color-scale)  1.0 )
	(snd-display #__line__ ";color-scale set def: ~A" (color-scale)))
    (set! (auto-update-interval) (auto-update-interval))
    (if (fneq (auto-update-interval)  60.0 )
	(snd-display #__line__ ";auto-update-interval set def: ~A" (auto-update-interval)))
    (set! (cursor-update-interval) (cursor-update-interval))
    (if (fneq (cursor-update-interval)  0.05 )
	(snd-display #__line__ ";cursor-update-interval set def: ~A" (cursor-update-interval)))
    (set! (cursor-location-offset) (cursor-location-offset))
    (if (not (= (cursor-location-offset)  0))
	(snd-display #__line__ ";cursor-location-offset set def: ~A" (cursor-location-offset)))
    (set! (dac-combines-channels) (dac-combines-channels))
    (if (not (equal? (dac-combines-channels)  #t)) 
	(snd-display #__line__ ";dac-combines-channels set def: ~A" (dac-combines-channels)))
    (set! (dac-size) (dac-size))
    (if (not (equal? (dac-size)  256 )) 
	(snd-display #__line__ ";dac-size set def: ~A" (dac-size)))
    (set! (minibuffer-history-length) (minibuffer-history-length))
    (if (not (equal? (minibuffer-history-length)  8)) 
	(snd-display #__line__ ";minibuffer-history-length set def: ~A" (minibuffer-history-length)))
    (set! (clipping) (clipping))
    (if (not (equal? (clipping)  #f )) 
	(snd-display #__line__ ";clipping set def: ~A" (clipping)))
    (set! (default-output-chans) (default-output-chans))
    (if (not (equal? (default-output-chans)  1 )) 
	(snd-display #__line__ ";default-output-chans set def: ~A" (default-output-chans)))
    (set! (default-output-data-format) (default-output-data-format))
    (if (and (not (equal? (default-output-data-format) mus-bfloat))
	     (not (equal? (default-output-data-format) mus-lfloat)))
	(snd-display #__line__ ";default-output-data-format set def: ~A" (default-output-data-format)))
    (set! (default-output-srate) (default-output-srate))
    (if (not (equal? (default-output-srate)  44100 )) 
	(snd-display #__line__ ";default-output-srate set def: ~A" (default-output-srate)))
    (set! (default-output-header-type) (default-output-header-type))
    (if (not (equal? (default-output-header-type)  mus-next)) 
	(snd-display #__line__ ";default-output-header-type set def: ~A" (default-output-header-type)))
    (set! (dot-size) (dot-size))
    (if (not (equal? (dot-size)  1 )) 
	(snd-display #__line__ ";dot-size set def: ~A" (dot-size)))
    (set! (cursor-size) (cursor-size))
    (if (not (equal? (cursor-size)  15 )) 
	(snd-display #__line__ ";cursor-size set def: ~A" (cursor-size)))
    (set! (cursor-style) (cursor-style))
    (if (not (equal? (cursor-style)  cursor-cross )) 
	(snd-display #__line__ ";cursor-style set def: ~A" (cursor-style)))
    (set! (tracking-cursor-style) (tracking-cursor-style))
    (if (not (equal? (tracking-cursor-style)  cursor-cross )) 
	(snd-display #__line__ ";tracking-cursor-style set def: ~A" (tracking-cursor-style)))
    (set! (enved-base) (enved-base))
    (if (fneq (enved-base)  1.0 )
	(snd-display #__line__ ";enved-base set def: ~A" (enved-base)))
    (set! (enved-clip?) (enved-clip?))
    (if (not (equal? (enved-clip?)  #t )) 
	(snd-display #__line__ ";enved-clip? set def: ~A" (enved-clip?)))
    (set! (enved-filter) (enved-filter))
    (if (not (equal? (enved-filter) #t)) 
	(snd-display #__line__ ";enved-filter set def: ~A" (enved-filter)))
    (set! (enved-filter-order) (enved-filter-order))
    (if (not (equal? (enved-filter-order)  40)) 
	(snd-display #__line__ ";enved-filter-order set def: ~A" (enved-filter-order)))
    (set! (enved-in-dB) (enved-in-dB))
    (if (not (equal? (enved-in-dB)  #f )) 
	(snd-display #__line__ ";enved-in-dB set def: ~A" (enved-in-dB)))
    (set! (enved-style) (enved-style))
    (if (not (equal? (enved-style)  envelope-linear )) 
	(snd-display #__line__ ";enved-style set def: ~A" (enved-style)))
    (set! (enved-power) (enved-power))
    (if (fneq (enved-power)  3.0)
	(snd-display #__line__ ";enved-power set def: ~A" (enved-power)))
    (set! (enved-target) (enved-target))
    (if (not (equal? (enved-target)  0 )) 
	(snd-display #__line__ ";enved-target set def: ~A" (enved-target)))
    (set! (enved-wave?) (enved-wave?))
    (if (not (equal? (enved-wave?)  #f )) 
	(snd-display #__line__ ";enved-wave? set def: ~A" (enved-wave?)))
    (if with-gui
	(begin
	  (set! (enved-envelope) (enved-envelope))
	  (if (not (equal? (enved-envelope)  '())) 
	      (snd-display #__line__ ";enved-envelope set def: ~A" (enved-envelope)))))
    (set! (eps-file) (eps-file))
    (if (not (equal? (eps-file)  "snd.eps" )) 
	(snd-display #__line__ ";eps-file set def: ~A" (eps-file)))
    (set! (eps-bottom-margin) (eps-bottom-margin))
    (if (fneq (eps-bottom-margin)  0.0)
	(snd-display #__line__ ";eps-bottom-margin set def: ~A" (eps-bottom-margin)))
    (set! (eps-left-margin) (eps-left-margin))
    (if (fneq (eps-left-margin)  0.0)
	(snd-display #__line__ ";eps-left-margin set def: ~A" (eps-left-margin)))
    (set! (eps-size) (eps-size))
    (if (fneq (eps-size)  1.0)
	(snd-display #__line__ ";eps-size set def: ~A" (eps-size)))
    (set! (fft-window-alpha) (fft-window-alpha))
    (if (fneq (fft-window-alpha)  0.0 )
	(snd-display #__line__ ";fft-window-alpha set def: ~A" (fft-window-alpha)))
    (set! (fft-window-beta) (fft-window-beta))
    (if (fneq (fft-window-beta)  0.0 )
	(snd-display #__line__ ";fft-window-beta set def: ~A" (fft-window-beta)))
    (set! (fft-log-frequency) (fft-log-frequency))
    (if (not (equal? (fft-log-frequency)  #f )) 
	(snd-display #__line__ ";fft-log-frequency set def: ~A" (fft-log-frequency)))
    (set! (fft-log-magnitude) (fft-log-magnitude))
    (if (not (equal? (fft-log-magnitude)  #f )) 
	(snd-display #__line__ ";fft-log-magnitude set def: ~A" (fft-log-magnitude)))
    (set! (fft-with-phases) (fft-with-phases))
    (if (not (equal? (fft-with-phases)  #f )) 
	(snd-display #__line__ ";fft-with-phases set def: ~A" (fft-with-phases)))
    (set! (transform-size) (transform-size))
    (if (not (equal? (transform-size)  512 )) 
	(snd-display #__line__ ";transform-size set def: ~A" (transform-size)))
    (set! (transform-graph-type) (transform-graph-type))
    (if (not (equal? (transform-graph-type) graph-once))
	(snd-display #__line__ ";transform-graph-type set def: ~A" (transform-graph-type)))
    (set! (fft-window) (fft-window))
    (if (not (equal? (fft-window)  6 )) 
	(snd-display #__line__ ";fft-window set def: ~A" (fft-window)))
    (set! (graph-cursor) (graph-cursor))
    (if (not (equal? (graph-cursor)  34)) 
	(snd-display #__line__ ";graph-cursor set def: ~A" (graph-cursor)))
    (set! (graph-style) (graph-style))
    (if (not (equal? (graph-style)  graph-lines )) 
	(snd-display #__line__ ";graph-style set def: ~A" (graph-style)))
    (set! (graphs-horizontal) (graphs-horizontal))
    (if (not (equal? (graphs-horizontal)  #t)) 
	(snd-display #__line__ ";graphs-horizontal set def: ~A" (graphs-horizontal)))
    (set! (html-dir) (html-dir))
    (if (not (equal? (html-dir)  ".")) 
	(snd-display #__line__ ";html-dir set def: ~A" (html-dir)))
    (set! (html-program) (html-program))
    (if (not (equal? (html-program)  "firefox")) 
	(snd-display #__line__ ";html-program set def: ~A" (html-program)))
    (set! (just-sounds) (just-sounds))
    (if (not (equal? (just-sounds)  #f)) 
	(snd-display #__line__ ";just-sounds set def: ~A" (just-sounds)))
    (set! (listener-prompt) (listener-prompt))
    (if (not (equal? (listener-prompt)  ">" )) 
	(snd-display #__line__ ";listener-prompt set def: ~A" (listener-prompt)))
    (set! (max-transform-peaks) (max-transform-peaks))
    (if (not (equal? (max-transform-peaks)  100)) 
	(snd-display #__line__ ";max-transform-peaks set def: ~A" (max-transform-peaks)))
    (set! (max-transform-peaks) -123)
    (if (not (equal? (max-transform-peaks) 100)) 
	(snd-display #__line__ ";max-transform-peaks set -123: ~A" (max-transform-peaks)))
    (set! (max-regions) (max-regions))
    (if (not (equal? (max-regions)  16 )) 
	(snd-display #__line__ ";max-regions set def: ~A" (max-regions)))
    (set! (max-virtual-ptrees) (max-virtual-ptrees))
    (if (not (equal? (max-virtual-ptrees)  32 )) 
	(snd-display #__line__ ";max-virtual-ptrees set def: ~A" (max-virtual-ptrees)))
    (set! (min-dB) (min-dB))
    (if (fneq (min-dB)  -60.0 )
	(snd-display #__line__ ";min-dB set def: ~A" (min-dB)))
    (set! (log-freq-start) (log-freq-start))
    (if (fneq (log-freq-start)  32.0 )
	(snd-display #__line__ ";log-freq-start set def: ~A" (log-freq-start)))
    (set! (selection-creates-region) (selection-creates-region))
    (if (not (equal? (selection-creates-region)  #t )) 
	(snd-display #__line__ ";selection-creates-region set def: ~A" (selection-creates-region)))
    (set! (transform-normalization) (transform-normalization))
    (if (not (equal? (transform-normalization)  normalize-by-channel)) 
	(snd-display #__line__ ";transform-normalization set def: ~A" (transform-normalization)))
    (set! (view-files-sort) (view-files-sort))
    (if (not (equal? (view-files-sort)  0 )) 
	(snd-display #__line__ ";view-files-sort set def: ~A" (view-files-sort)))
    (set! (print-length) (print-length))
    (if (not (equal? (print-length)  12 )) 
	(snd-display #__line__ ";print-length set def: ~A" (print-length)))
    (set! (save-state-file) (save-state-file))
    (if (not (equal? (save-state-file)  "saved-snd.scm" )) 
	(snd-display #__line__ ";save-state-file set def: ~A" (save-state-file)))
    (set! (show-axes) (show-axes))
    (if (not (equal? (show-axes)  1)) 
	(snd-display #__line__ ";show-axes set def: ~A" (show-axes)))
    (set! (show-transform-peaks) (show-transform-peaks))
    (if (not (equal? (show-transform-peaks)  #f )) 
	(snd-display #__line__ ";show-transform-peaks set def: ~A" (show-transform-peaks)))
    (set! (show-indices) (show-indices))
    (if (not (equal? (show-indices)  #f)) 
	(snd-display #__line__ ";show-indices set def: ~A" (show-indices)))
    (set! (show-marks) (show-marks))
    (if (not (equal? (show-marks)  #t )) 
	(snd-display #__line__ ";show-marks set def: ~A" (show-marks)))
    (set! (show-mix-waveforms) (show-mix-waveforms))
    (if (not (equal? (show-mix-waveforms)  #t)) 
	(snd-display #__line__ ";show-mix-waveforms set def: ~A" (show-mix-waveforms)))
    (set! (show-selection-transform) (show-selection-transform))
    (if (not (equal? (show-selection-transform)  #f )) 
	(snd-display #__line__ ";show-selection-transform set def: ~A" (show-selection-transform)))
    (set! (show-y-zero) (show-y-zero))
    (if (not (equal? (show-y-zero)  #f )) 
	(snd-display #__line__ ";show-y-zero set def: ~A" (show-y-zero)))
    (set! (show-grid) (show-grid))
    (if (not (equal? (show-grid)  #f )) 
	(snd-display #__line__ ";show-grid set def: ~A" (show-grid)))
    (set! (grid-density) (grid-density))
    (if (fneq (grid-density) 1.0)
	(snd-display #__line__ ";grid-density set def: ~A" (grid-density)))
    (set! (show-sonogram-cursor) (show-sonogram-cursor))
    (if (not (equal? (show-sonogram-cursor)  #f )) 
	(snd-display #__line__ ";show-sonogram-cursor set def: ~A" (show-sonogram-cursor)))
    (set! (sinc-width) (sinc-width))
    (if (not (equal? (sinc-width)  10 )) 
	(snd-display #__line__ ";sinc-width set def: ~A" (sinc-width)))
    (set! (spectrum-end) (spectrum-end))
    (if (fneq (spectrum-end)  1.0)
	(snd-display #__line__ ";spectrum-end set def: ~A" (spectrum-end)))
    (set! (spectro-hop) (spectro-hop))
    (if (not (equal? (spectro-hop)  4 )) 
	(snd-display #__line__ ";spectro-hop set def: ~A" (spectro-hop)))
    (set! (spectrum-start) (spectrum-start))
    (if (fneq (spectrum-start)  0.0 )
	(snd-display #__line__ ";spectrum-start set def: ~A" (spectrum-start)))
    (set! (spectro-x-angle) (spectro-x-angle))
    (if (fneq (spectro-x-angle)  (if (provided? 'gl) 300.0 90.0))
	(snd-display #__line__ ";spectro-x-angle set def: ~A" (spectro-x-angle)))
    (set! (spectro-x-scale) (spectro-x-scale))
    (if (fneq (spectro-x-scale) (if (provided? 'gl) 1.5 1.0))
	(snd-display #__line__ ";spectro-x-scale set def: ~A" (spectro-x-scale)))
    (set! (spectro-y-angle) (spectro-y-angle))
    (if (fneq (spectro-y-angle) (if (provided? 'gl) 320.0 0.0))
	(snd-display #__line__ ";spectro-y-angle set def: ~A" (spectro-y-angle)))
    (set! (spectro-y-scale) (spectro-y-scale))
    (if (fneq (spectro-y-scale)  1.0 )
	(snd-display #__line__ ";spectro-y-scale set def: ~A" (spectro-y-scale)))
    (set! (spectro-z-angle) (spectro-z-angle))
    (if (fneq (spectro-z-angle) (if (provided? 'gl) 0.0 358.0))
	(snd-display #__line__ ";spectro-z-angle set def: ~A" (spectro-z-angle)))
    (set! (spectro-z-scale) (spectro-z-scale))
    (if (fneq (spectro-z-scale) (if (provided? 'gl) 1.0 0.1))
	(snd-display #__line__ ";spectro-z-scale set def: ~A" (spectro-z-scale)))
    (set! (temp-dir) (temp-dir))
    (if (not (equal? (temp-dir)  #f )) 
	(snd-display #__line__ ";temp-dir set def: ~A" (temp-dir)))
    (set! (ladspa-dir) (ladspa-dir))
    (if (not (equal? (ladspa-dir)  #f )) 
	(snd-display #__line__ ";ladspa-dir set def: ~A" (ladspa-dir)))
    (set! (peak-env-dir) (peak-env-dir))
    (if (not (equal? (peak-env-dir)  #f )) 
	(snd-display #__line__ ";peak-env-dir set def: ~A" (peak-env-dir)))
    (set! (tiny-font) (tiny-font))
    (if (and (not (equal? (tiny-font) "6x12"))
	     (not (equal? (tiny-font) "Sans 8")))
	(snd-display #__line__ ";tiny-font set def: ~A" (tiny-font)))
    (set! (transform-type) (transform-type))
    (if (not (equal? (transform-type)  fourier-transform )) 
	(snd-display #__line__ ";transform-type set def: ~A" (transform-type)))
    (set! (trap-segfault) (trap-segfault))
    (if (not (equal? (trap-segfault)  #t)) 
	(snd-display #__line__ ";trap-segfault set def: ~A" (trap-segfault)))
    (set! (with-file-monitor) (with-file-monitor))
    (if (not (equal? (with-file-monitor)  #t)) 
	(snd-display #__line__ ";with-file-monitor set def: ~A" (with-file-monitor)))
    (set! (optimization) (optimization))
    (if (not (equal? (optimization) 6)) 
	(snd-display #__line__ ";optimization set def: ~A" (optimization)))
    (set! (clm-table-size) (clm-table-size))
    (if (not (equal? (clm-table-size) 512)) 
	(snd-display #__line__ ";clm-table-size set def: ~A" (clm-table-size)))
    (set! (clm-default-frequency) (clm-default-frequency))
    (if (fneq (clm-default-frequency) 0.0)
	(snd-display #__line__ ";clm-default-frequency set def: ~A" (clm-default-frequency)))
    (set! (with-verbose-cursor) (with-verbose-cursor))
    (if (not (equal? (with-verbose-cursor)  #f)) 
	(snd-display #__line__ ";with-verbose-cursor set def: ~A" (with-verbose-cursor)))
    (set! (with-inset-graph) (with-inset-graph))
    (if (not (equal? (with-inset-graph)  #f)) 
	(snd-display #__line__ ";with-inset-graph set def: ~A" (with-inset-graph)))
    (set! (with-pointer-focus) (with-pointer-focus))
    (if (not (equal? (with-pointer-focus)  #f)) 
	(snd-display #__line__ ";with-pointer-focus set def: ~A" (with-pointer-focus)))
    (set! (wavelet-type) (wavelet-type))
    (if (not (equal? (wavelet-type)  0 )) 
	(snd-display #__line__ ";wavelet-type set def: ~A" (wavelet-type)))
    (set! (time-graph-type) (time-graph-type))
    (if (not (equal? (time-graph-type)  graph-once)) 
	(snd-display #__line__ ";time-graph-type set def: ~A" (time-graph-type)))
    (set! (wavo-hop) (wavo-hop))
    (if (not (equal? (wavo-hop)  3 )) 
	(snd-display #__line__ ";wavo-hop set def: ~A" (wavo-hop)))
    (set! (wavo-trace) (wavo-trace))
    (if (not (equal? (wavo-trace)  64 )) 
	(snd-display #__line__ ";wavo-trace set def: ~A" (wavo-trace)))
    (set! (x-axis-style) (x-axis-style))
    (if (not (equal? (x-axis-style)  0 )) 
	(snd-display #__line__ ";x-axis-style set def: ~A" (x-axis-style)))
    (set! (beats-per-minute) (beats-per-minute))
    (if (fneq (beats-per-minute)  60.0 )
	(snd-display #__line__ ";beats-per-minute set def: ~A" (beats-per-minute)))
    (set! (beats-per-measure) (beats-per-measure))
    (if (not (= (beats-per-measure)  4))
	(snd-display #__line__ ";beats-per-measure set def: ~A" (beats-per-measure)))
    (set! (zero-pad) (zero-pad))
    (if (not (equal? (zero-pad)  0)) 
	(snd-display #__line__ ";zero-pad set def: ~A" (zero-pad)))
    (set! (zero-pad) -123)
    (if (not (equal? (zero-pad)  0)) 
	(snd-display #__line__ ";zero-pad set -123: ~A" (zero-pad)))
    (if (not (equal? (zero-pad #t #t) '()))
	(snd-display #__line__ ";zero-pad #t: ~A" (zero-pad #t #t)))
    (set! (zoom-focus-style) (zoom-focus-style))
    (if (not (equal? (zoom-focus-style)  2 )) 
	(snd-display #__line__ ";zoom-focus-style set def: ~A" (zoom-focus-style)))
    (set! (mix-waveform-height) (mix-waveform-height))
    (if (not (equal? (mix-waveform-height)  20 )) 
	(snd-display #__line__ ";mix-waveform-height set def: ~A" (mix-waveform-height)))
    (set! (mix-tag-width) (mix-tag-width))
    (if (not (equal? (mix-tag-width)  6)) 
	(snd-display #__line__ ";mix-tag-width set def: ~A" (mix-tag-width)))
    (set! (mix-tag-height) (mix-tag-height))
    (if (not (equal? (mix-tag-height)  14)) 
	(snd-display #__line__ ";mix-tag-height set def: ~A" (mix-tag-height)))
    (set! (mark-tag-width) (mark-tag-width))
    (if (not (equal? (mark-tag-width)  10)) 
	(snd-display #__line__ ";mark-tag-width set def: ~A" (mark-tag-width)))
    (set! (mark-tag-height) (mark-tag-height))
    (if (not (equal? (mark-tag-height)  4)) 
	(snd-display #__line__ ";mark-tag-height set def: ~A" (mark-tag-height)))
    (set! (audio-output-device) (audio-output-device))
    (if (not (equal? (audio-output-device)  0 )) 
	(snd-display #__line__ ";audio-output-device set def: ~A" (audio-output-device)))
    (set! (view-files-sort) (view-files-sort))
    (if (not (= (view-files-sort) 0))
	(snd-display #__line__ ";view-files-sort def: ~A" (view-files-sort)))
    
    (if (and (defined? 'most-positive-fixnum)
	     (> most-positive-fixnum (expt 2 36)))
	(begin
	  (let ((old-max-malloc (mus-max-malloc)))
	    (set! (mus-max-malloc) (expt 2 36))
	    (if (not (= (mus-max-malloc) (expt 2 36)))
		(snd-display #__line__ ";mus-max-malloc as bignum: ~A" (mus-max-malloc)))
	    (set! (mus-max-malloc) old-max-malloc))
	  
	  (let ((old-max-table-size (mus-max-table-size)))
	    (set! (mus-max-table-size) (expt 2 36))
	    (if (not (= (mus-max-table-size) (expt 2 36)))
		(snd-display #__line__ ";mus-max-table-size as bignum: ~A" (mus-max-table-size)))
	    (set! (mus-max-table-size) old-max-table-size))))
    
    (if (not (provided? 'snd-gtk))
	(for-each
	 (lambda (func name)
	   (let ((val (func)))
	     (set! (func) "8x123")
	     (if (or (not (string? (func)))
		     (not (string=? val (func))))
		 (snd-display #__line__ ";set ~A to bogus value: ~A ~A" name val (func)))))
	 (list axis-label-font axis-numbers-font tiny-font peaks-font bold-peaks-font)
	 (list 'axis-label-font 'axis-numbers-font 'tiny-font 'peaks-font 'bold-peaks-font)))
    ))



;;; ---------------- test 1: defaults ----------------

(define good-colormap (if (provided? 'gl) hot-colormap black-and-white-colormap))
(define better-colormap black-and-white-colormap)
(if with-gui
    (if (not (colormap? good-colormap))
	(set! good-colormap
	      (call-with-exit
	       (lambda (return)
		 (do ((i 1 (+ 1 i)))
		     ((= i 20))
		   (if (colormap? (integer->colormap i))
		       (return (integer->colormap i)))))))))
(if with-gui
    (if (not (colormap? better-colormap))
	(set! better-colormap
	      (call-with-exit
	       (lambda (return)
		 (do ((i good-colormap (+ 1 i)))
		     ((= i 20))
		   (if (colormap? (integer->colormap i))
		       (return (integer->colormap i)))))))))

(define (snd_test_1)
  (letrec ((test-defaults
	    (lambda (lst)
	      (if (not (null? lst))
		  (begin
		    (if (not (equal? (cadr lst)  (caddr lst)))
			(if (and (number? (caddr lst))
				 (not (rational? (caddr lst))))
			    (if (fneq (cadr lst) (caddr lst))
				(snd-display #__line__ ";~A /= ~A (~A)" (car lst) (caddr lst) (cadr lst)))
			    (snd-display #__line__ ";~A /= ~A (~A)" (car lst) (caddr lst) (cadr lst))))
		    (test-defaults (cdddr lst)))))))
    
    (for-each close-sound (sounds)) ; in case others opened elsewhere
    (test-defaults
     (list
      'amp-control (without-errors (amp-control)) 'no-such-sound
      'amp-control-bounds (cadr (amp-control-bounds)) 8.0
      'ask-before-overwrite (ask-before-overwrite) #f 
      'audio-output-device (audio-output-device) 0
      'audio-output-device (audio-output-device) 0 
      'auto-resize (auto-resize) #t 
      'auto-update (auto-update) #f
      'auto-update-interval (auto-update-interval) 60.0 
      'beats-per-measure (beats-per-measure) 4
      'beats-per-minute (beats-per-minute) 60.0
      'channel-style (channel-style) 1
      'clipping (clipping) #f 
      'clm-table-size (clm-table-size) 512
      'clm-default-frequency (clm-default-frequency) 0.0
      'color-cutoff (color-cutoff) 0.003 
      'color-inverted (color-inverted) #t
      'color-scale (color-scale) 1.0 
      'colormap (colormap) good-colormap
      'contrast-control (without-errors (contrast-control)) 'no-such-sound
      'contrast-control-amp (contrast-control-amp) 1.0
      'contrast-control-bounds (cadr (contrast-control-bounds)) 10.0
      'contrast-control? (without-errors (contrast-control?)) 'no-such-sound
      'cursor-follows-play (cursor-follows-play) #f
      'cursor-location-offset (cursor-location-offset) 0
      'cursor-size (cursor-size) 15
      'cursor-style (cursor-style) cursor-cross
      'cursor-update-interval (cursor-update-interval) 0.05
      'dac-combines-channels (dac-combines-channels) #t
      'dac-size (dac-size) 256 
      'default-output-chans (default-output-chans) 1 
      'default-output-data-format (default-output-data-format) mus-lfloat
      'default-output-header-type (default-output-header-type) mus-next
      'default-output-srate (default-output-srate) 44100
      'dot-size (dot-size) 1 
      'enved-base (enved-base) 1.0 
      'enved-clip? (enved-clip?) #t
      'enved-envelope (enved-envelope) '()
      'enved-filter (enved-filter) #t
      'enved-filter-order (enved-filter-order) 40
      'enved-in-dB (enved-in-dB) #f 
      'enved-power (enved-power) 3.0
      'enved-style (enved-style) envelope-linear
      'enved-target (enved-target) 0 
      'enved-wave? (enved-wave?) #f 
      'eps-bottom-margin (eps-bottom-margin) 0.0
      'eps-file (eps-file) "snd.eps" 
      'eps-left-margin (eps-left-margin) 0.0
      'eps-size (eps-size) 1.0
      'expand-control (without-errors (expand-control)) 'no-such-sound
      'expand-control-bounds (cadr (expand-control-bounds)) 20.0
      'expand-control-hop (expand-control-hop) 0.05
      'expand-control-jitter (expand-control-jitter) 0.1
      'expand-control-length (expand-control-length) 0.15
      'expand-control-ramp (expand-control-ramp) 0.4
      'expand-control? (without-errors (expand-control?)) 'no-such-sound
      'fft-log-frequency (fft-log-frequency) #f 
      'fft-log-magnitude (fft-log-magnitude) #f 
      'fft-with-phases (fft-with-phases) #f 
      'fft-window (fft-window) 6 
      'fft-window-alpha (fft-window-alpha) 0.0 
      'fft-window-beta (fft-window-beta) 0.0 
      'filter-control-coeffs (without-errors (filter-control-coeffs)) 'no-such-sound
      'filter-control-envelope (without-errors (filter-control-envelope)) 'no-such-sound
      'filter-control-in-dB (filter-control-in-dB) #f
      'filter-control-in-hz (filter-control-in-hz) #f
      'filter-control-order (filter-control-order) 20
      'filter-control? (without-errors (filter-control?)) 'no-such-sound
      'graph-cursor (graph-cursor) 34
      'graph-style (graph-style) graph-lines
      'graphs-horizontal (graphs-horizontal) #t
      'grid-density (grid-density) 1.0
      'html-dir (html-dir) "."
      'html-program (html-program) "firefox"
      'just-sounds (just-sounds) #f
      'ladspa-dir (ladspa-dir) #f 
      'peak-env-dir (peak-env-dir) #f 
      'lisp-graph? (without-errors (lisp-graph?)) 'no-such-sound
      'listener-prompt (listener-prompt) ">" 
      'log-freq-start (log-freq-start) 32.0	
      'mark-tag-height (mark-tag-height) 4
      'mark-tag-width (mark-tag-width) 10
      'max-regions (max-regions) 16 
      'max-virtual-ptrees (max-virtual-ptrees) 32
      'max-transform-peaks (max-transform-peaks) 100
      'min-dB (min-dB) -60.0 
      'minibuffer-history-length (minibuffer-history-length) 8
      'mix-tag-height (mix-tag-height) 14
      'mix-tag-width (mix-tag-width) 6
      'mix-waveform-height (mix-waveform-height) 20 
      'mus-array-print-length (mus-array-print-length) 8
      'mus-clipping (mus-clipping) #f
      'mus-float-equal-fudge-factor (mus-float-equal-fudge-factor) .0000001
      'mus-prescaler (mus-prescaler) 1.0
      'optimization (optimization) 6
      'print-length (print-length) 12 
      'read-only (without-errors (read-only)) 'no-such-sound
      'region-graph-style (region-graph-style) graph-lines
      'reverb-control-feedback (reverb-control-feedback) 1.09
      'reverb-control-length (without-errors (reverb-control-length)) 'no-such-sound
      'reverb-control-length-bounds (cadr (reverb-control-length-bounds)) 5.0
      'reverb-control-lowpass (reverb-control-lowpass) 0.7
      'reverb-control-scale (without-errors (reverb-control-scale)) 'no-such-sound
      'reverb-control-scale-bounds (cadr (reverb-control-scale-bounds)) 4.0
      'reverb-control? (without-errors (reverb-control?)) 'no-such-sound
      'save-state-file (save-state-file) "saved-snd.scm" 
      'selection-creates-region (selection-creates-region) #t 
      'show-axes (show-axes) 1
      'show-controls (show-controls) #f
      'show-grid (show-grid) #f 
      'show-indices (show-indices) #f
      'show-marks (show-marks) #t 
      'show-mix-waveforms (show-mix-waveforms) #t
      'show-selection-transform (show-selection-transform) #f 
      'show-sonogram-cursor (show-sonogram-cursor) #f 
      'show-transform-peaks (show-transform-peaks) #f 
      'show-y-zero (show-y-zero) #f 
      'sinc-width (sinc-width) 10 
      'spectrum-end (spectrum-end) 1.0
      'spectro-hop (spectro-hop) 4 
      'spectrum-start (spectrum-start) 0.0 
      'spectro-x-angle (spectro-x-angle) (if (provided? 'gl) 300.0 90.0)
      'spectro-x-scale (spectro-x-scale) (if (provided? 'gl) 1.5 1.0)
      'spectro-y-angle (spectro-y-angle) (if (provided? 'gl) 320.0 0.0)
      'spectro-y-scale (spectro-y-scale) 1.0 
      'spectro-z-angle (spectro-z-angle) (if (provided? 'gl) 0.0 358.0)
      'spectro-z-scale (spectro-z-scale) (if (provided? 'gl) 1.0 0.1)
      'speed-control (without-errors (speed-control)) 'no-such-sound
      'speed-control-bounds (cadr (speed-control-bounds)) 20.0
      'sync (without-errors (sync)) 'no-such-sound
      'temp-dir (temp-dir) #f 
      'time-graph-type (time-graph-type) graph-once
      'time-graph? (without-errors (time-graph?)) 'no-such-sound
      'tiny-font (tiny-font) (if (provided? 'snd-motif) "6x12" "Sans 8")
      'tracking-cursor-style (tracking-cursor-style) cursor-cross
      'transform-graph-type (transform-graph-type) graph-once
      'transform-graph? (without-errors (transform-graph?)) 'no-such-sound
      'transform-normalization (transform-normalization) normalize-by-channel
      'transform-size (transform-size) 512
      'transform-type (transform-type) fourier-transform
      'view-files-sort (view-files-sort) 0
      'view-files-sort (view-files-sort) 0 
      'wavelet-type (wavelet-type) 0 
      'wavo-hop (wavo-hop) 3 
      'wavo-trace (wavo-trace) 64 
      'with-mix-tags (with-mix-tags) #t
      'with-relative-panes (with-relative-panes) #t
      'with-tracking-cursor (with-tracking-cursor) #f
      'with-verbose-cursor (with-verbose-cursor) #f
      'with-inset-graph (with-inset-graph) #f
      'with-pointer-focus (with-pointer-focus) #f
      'x-axis-style (x-axis-style) 0 
      'zero-pad (zero-pad) 0
      'zoom-focus-style (zoom-focus-style) 2 
      ))
    (if *snd-opened-sound* (snd-display #__line__ ";*snd-opened-sound*: ~A" *snd-opened-sound*))
    ))


(if (and (not (= (default-output-data-format) mus-bfloat))
	 (not (= (default-output-data-format) mus-lfloat)))
    (set! (default-output-data-format) mus-lfloat))


;;; ---------------- test 2: headers ----------------
(define (snd_test_2)
  (if (string? sf-dir)
      (letrec ((test-headers
		(lambda (base-files)
		  (if (not (null? base-files))
		      (let ((testf (car base-files)))
			(let ((file (string-append sf-dir (list-ref testf 0))))
			  (if (file-exists? file)
			      (begin
				(if (not (equal? (mus-sound-chans file) (list-ref testf 1)))
				    (snd-display #__line__ ";~A: chans ~A /= ~A" 
						 (list-ref testf 0) 
						 (mus-sound-chans file) 
						 (list-ref testf 1)))
				(if (not (equal? (mus-sound-srate file) (list-ref testf 2)))
				    (snd-display #__line__ ";~A: srate ~A /= ~A" 
						 (list-ref testf 0) 
						 (mus-sound-srate file) 
						 (list-ref testf 2)))
				(if (fneq (mus-sound-duration file) (list-ref testf 3))
				    (snd-display #__line__ ";~A: duration ~A /= ~A" 
						 (list-ref testf 0)
						 (mus-sound-duration file) 
						 (list-ref testf 3)))
				(if (and (not (= (mus-sound-data-format file) mus-unknown))
					 (not (= (mus-sound-header-type file) 27)) ; bogus header on test case (comdisco)
					 (< (+ (mus-sound-length file) 1)
					    (* (mus-sound-datum-size file) (mus-sound-duration file)
					       (mus-sound-srate file) (mus-sound-chans file))))
				    (snd-display #__line__ ";mus-sound-length ~A: ~A (~A)" file
						 (mus-sound-length file)
						 (* (mus-sound-duration file) (mus-sound-srate file) 
						    (mus-sound-chans file) (mus-sound-datum-size file))))
				(if (fneq (/ (mus-sound-frames file) (mus-sound-srate file)) (mus-sound-duration file))
				    (snd-display #__line__ ";mus-sound-frames ~A: ~A (~A ~A)" file
						 (mus-sound-frames file)
						 (mus-sound-duration file)
						 (/ (mus-sound-frames file) (mus-sound-srate file))))
				(if (> (abs (- (mus-sound-frames file) (/ (mus-sound-samples file) (mus-sound-chans file)))) 1)
				    (snd-display #__line__ ";mus-sound-samples ~A: ~A ~A" file
						 (mus-sound-samples file)
						 (* (mus-sound-frames file) (mus-sound-chans file))))
				(if (not (equal? (mus-header-type-name (mus-sound-header-type file)) (list-ref testf 4)))
				    (snd-display #__line__ ";~A: type ~A /= ~A" 
						 (list-ref testf 0) 
						 (mus-header-type-name (mus-sound-header-type file))
						 (list-ref testf 4)))
				(if (not (equal? (mus-data-format-name (mus-sound-data-format file)) (list-ref testf 5)))
				    (snd-display #__line__ ";~A: type ~A /= ~A"
						 (list-ref testf 0) 
						 (mus-data-format-name (mus-sound-data-format file)) 
						 (list-ref testf 5)))
				(let ((lst (mus-sound-loop-info file)))
				  (if (> (length testf) 6)
				      (begin
					(if (not (equal? (car lst) (list-ref testf 6))) 
					    (snd-display #__line__ ";~A: loop start: ~A" (car lst) (list-ref testf 6)))
					(if (not (equal? (cadr lst) (list-ref testf 7))) 
					    (snd-display #__line__ ";~A: loop end: ~A" (cadr lst) (list-ref testf 7))))
				      (if (not (null? lst))
					  (snd-display #__line__ ";~A thinks it has loop info: ~A" file lst))))
				(mus-sound-forget file))
			      (snd-display #__line__ ";~A missing?" file))
			  (test-headers (cdr base-files))))))))
	
	;; need to make sure raw defaults are consistent with following tests
	(let ((ind (open-raw-sound :file (string-append sf-dir "addf8.nh") :channels 2 :srate 44100 :data-format mus-bshort)))
	  (if (sound? ind) (close-sound ind)))
	(catch #t
	       (lambda ()
		 (if (not (= (mus-sound-header-type (string-append sf-dir "midi60.mid")) -1)) (snd-display #__line__ ";midi60?")))
	       (lambda args args))
	(test-headers
	 (list
	  (list "5_secs.aiff" 1 44100 5.303107 "AIFF" "big endian short (16 bits)")
	  (list "8svx-8.snd" 1 22050 1.88766443729401 "SVX8" "signed byte (8 bits)")
	  (list "Fnonull.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
	  (list "Pmiscck.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
	  (list "Pmiscck.wav" 1 8000 0.00112499995157123 "RIFF" "mulaw (8 bits)")
					;	    (list "Pnossnd.aif" 1 8000 0.0 "AIFC" "mulaw (8 bits)")
	  (list "Poffset.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
	  (list "Porder.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
	  (list "Ptjunk.aif" 1 8000 0.00112499995157123 "AIFC" "mulaw (8 bits)")
	  (list "Ptjunk.wav" 1 8000 0.00112499995157123 "RIFF" "mulaw (8 bits)")
	  (list "SINE24-S.WAV" 2 44100 2.0 "RIFF" "little endian int (24 bits)")
	  (list "a1.asf" 1 16000 3.73656249046326 "asf" "unknown")
	  (list "a2.asf" 1 8000 4.63062477111816 "asf" "unknown")
	  (list "addf8.afsp" 1 8000 2.9760000705719 "Sun/Next" "big endian short (16 bits)")
	  (list "addf8.d" 1 8000 2.9760000705719 "SPPACK" "big endian short (16 bits)")
	  (list "addf8.dwd" 1 8000 2.9760000705719 "DiamondWare" "little endian short (16 bits)")
	  (list "addf8.nh" 2 44100 0.269931972026825 "raw (no header)" "big endian short (16 bits)")
	  (list "addf8.sd" 1 8000 2.9760000705719 "ESPS" "big endian short (16 bits)")
	  (list "addf8.sf_mipseb" 1 8000 2.9760000705719 "IRCAM" "big endian short (16 bits)")
	  (list "addf8.sf_sun" 1 8000 2.9760000705719 "IRCAM" "big endian short (16 bits)")
	  (list "addf8.sf_vax_b" 1 8000 2.9760000705719 "IRCAM" "big endian short (16 bits)")
	  (list "addf8.wav" 1 8000 2.9760000705719 "RIFF" "little endian short (16 bits)")
	  (list "aebass.krz" 1 44100 3.0 "Kurzweil 2000" "big endian short (16 bits)")
	  (list "aiff-16.snd" 2 44100 0.746666669845581 "AIFF" "big endian short (16 bits)")
	  (list "aiff-8.snd" 2 44100 0.746666669845581 "AIFF" "signed byte (8 bits)")
	  (list "alaw.aifc" 1 44100 0.0367800444364548 "AIFC" "alaw (8 bits)")
	  (list "alaw.wav" 1 11025 8.70666694641113 "RIFF" "alaw (8 bits)")
	  (list "astor_basia.mp2" 2 44100 1.02179133892059 "raw (no header)" "big endian short (16 bits)")
	  (list "c.asf" 1 8000 21.3681259155273 "asf" "unknown")
	  (list "ce-c3.w02" 1 33000 3.88848495483398 "TX-16W" "unknown")
	  (list "ce-c4.w03" 1 33000 2.91618180274963 "TX-16W" "unknown")
	  (list "ce-d2.w01" 1 33000 3.46439385414124 "TX-16W" "unknown")
	  (list "clbonef.wav" 1 22050 2.57832193374634 "RIFF" "little endian float (32 bits)")
	  (list "cranker.krz" 1 44100 3.48267579078674 "Kurzweil 2000" "big endian short (16 bits)")
	  (list "d40130.aif" 1 10000 0.100000001490116 "AIFF" "big endian short (16 bits)")
	  (list "d40130.au" 1 10000 0.100000001490116 "Sun/Next" "big endian short (16 bits)")
	  (list "d40130.dsf" 1 8000 0.125 "Delusion" "little endian short (16 bits)")
	  (list "d40130.fsm" 1 8000 0.125249996781349 "Farandole" "little endian short (16 bits)")
	  (list "d40130.iff" 1 10000 0.100000001490116 "SVX8" "signed byte (8 bits)")
	  (list "d40130.pat" 1 10000 0.100000001490116 "Gravis Ultrasound patch" "little endian short (16 bits)")
	  (list "d40130.sds" 1 10000 0.100000001490116 "MIDI sample dump" "unknown")
	  (list "d40130.sdx" 1 10000 0.100000001490116 "Sample dump" "unsigned little endian short (16 bits)")
	  (list "d40130.sf" 1 10000 0.100000001490116 "IRCAM" "little endian short (16 bits)")
	  (list "d40130.smp" 1 8000 0.125 "SMP" "little endian short (16 bits)")
	  (list "d40130.sou" 1 8000 0.125 "SBStudioII" "little endian short (16 bits)")
	  (list "d40130.st3" 1 8000 0.125 "Digiplayer ST3" "unsigned little endian short (16 bits)")
	  (list "d40130.uwf" 1 8000 0.125249996781349 "Ultratracker" "little endian short (16 bits)")
	  (list "d40130.voc" 1 10000 0.100100003182888 "VOC" "unsigned byte (8 bits)")
	  (list "d40130.w00" 1 16000 0.0625 "TX-16W" "unknown")
	  (list "d40130.wav" 1 10000 0.100000001490116 "RIFF" "little endian short (16 bits)")
	  (list "d43.wav" 1 10000 0.100000001490116 "RIFF" "little endian short (16 bits)")
	  (list "digit0v0.aiff" 1 8000 0.560000002384186 "AIFC" "big endian short (16 bits)")
	  (list "esps-16.snd" 1 8000 3.09737491607666 "ESPS" "big endian short (16 bits)")
	  (list "forest.aiff" 2 44100 3.907143 "AIFF" "big endian short (16 bits)" 24981 144332)
	  (list "g721.au" 1 11025 4.35328817367554 "Sun/Next" "unknown")
	  (list "g722.aifc" 1 44100 0.0184353739023209 "AIFC" "unknown")
	  (list "gong.wve" 1 8000 3.96799993515015 "PSION" "alaw (8 bits)")
	  (list "gsm610.wav" 1 11025 1.7687075138092 "RIFF" "unknown")
	  (list "inrs-16.snd" 1 8000 2.46399998664856 "INRS" "little endian short (16 bits)")
	  (list "kirk.wve" 1 8000 1.40799999237061 "PSION" "alaw (8 bits)")
	  (list "loop.aiff" 1 44100 0.0367120169103146 "AIFC" "big endian short (16 bits)" 12 23)
	  (list "m.asf" 1 8000 64.9646224975586 "asf" "unknown")
	  (list "mary-sun4.sig" 1 8000 4.47612476348877 "Comdisco SPW signal" "big endian double (64 bits)")
	  (list "mocksong.wav" 1 11025 7.86956930160522 "RIFF" "little endian short (16 bits)")
	  (list "mono24.wav" 1 22050 1.98997735977173 "RIFF" "little endian int (24 bits)")
	  (list "msadpcm.wav" 1 11025 4.43501138687134 "RIFF" "unknown")
	  (list "n8.snd" 1 44100 0.0367800444364548 "Sun/Next" "signed byte (8 bits)")
	  (list "nasahal.aif" 1 11025 9.89841270446777 "AIFF" "signed byte (8 bits)")
	  (list "nasahal.avi" 1 11025 10.4327440261841 "AVI" "little endian short (16 bits)")
	  (list "nasahal.dig" 1 11025 9.89841270446777 "Sound Designer 1" "big endian short (16 bits)")
	  (list "nasahal.ivc" 2 44100 0.449002265930176 "raw (no header)" "big endian short (16 bits)")
	  (list "nasahal.pat" 1 11025 3.95410442352295 "Gravis Ultrasound patch" "unsigned byte (8 bits)")
	  (list "nasahal.snd" 1 11025 9.89841270446777 "SNDT" "unsigned byte (8 bits)")
	  (list "nasahal.svx" 1 11025 9.89841270446777 "SVX8" "signed byte (8 bits)")
	  (list "nasahal.v8" 1 8000 13.6412496566772 "Covox V8" "unsigned byte (8 bits)")
	  (list "nasahal.voc" 1 11025 9.89941024780273 "VOC" "unsigned byte (8 bits)")
	  (list "nasahal.vox" 2 44100 0.224444448947906 "raw (no header)" "big endian short (16 bits)")
	  (list "nasahal8.wav" 1 11025 9.89841270446777 "RIFF" "unsigned byte (8 bits)")
	  (list "nasahalad.smp" 1 11025 4.94920635223389 "Goldwave sample" "little endian short (16 bits)")
	  (list "next-16.snd" 1 22050 1.00004529953003 "Sun/Next" "big endian short (16 bits)")
	  (list "next-8.snd" 1 22050 0.226757362484932 "Sun/Next" "signed byte (8 bits)")
	  (list "next-dbl.snd" 1 22050 0.226757362484932 "Sun/Next" "big endian double (64 bits)")
	  (list "oboe.ldbl" 1 22050 2.30512475967407 "RIFF" "little endian double (64 bits)")
	  (list "next-flt.snd" 1 22050 0.226757362484932 "Sun/Next" "big endian float (32 bits)")
	  (list "aifc-float.snd" 1 22050 0.226757362484932 "AIFC" "big endian float (32 bits)")
	  (list "next-mulaw.snd" 1 8012 2.03295063972473 "Sun/Next" "mulaw (8 bits)")
	  (list "next24.snd" 1 44100 0.0367800444364548 "Sun/Next" "big endian int (24 bits)")
	  (list "nist-01.wav" 1 16000 2.26912498474121 "NIST" "little endian short (16 bits)")
	  (list "nist-10.wav" 1 16000 2.26912498474121 "NIST" "big endian short (16 bits)")
	  (list "nist-16.snd" 1 16000 1.02400004863739 "NIST" "big endian short (16 bits)")
	  (list "nist-shortpack.wav" 1 16000 4.53824996948242 "NIST" "unknown")
	  (list "none.aifc" 1 44100 0.0367800444364548 "AIFC" "big endian short (16 bits)")
	  (list "nylon2.wav" 2 22050 1.14376413822174 "RIFF" "unknown")
	  (list "o2.adf" 1 44100 0.036780 "CSRE adf" "little endian short (16 bits)")
	  (list "o2.avr" 1 44100 0.0183900222182274 "AVR" "big endian short (16 bits)")
	  (list "o2.bicsf" 1 44100 0.0367800444364548 "IRCAM" "big endian short (16 bits)")
	  (list "o2.mpeg1" 2 44100 0.00709750549867749 "raw (no header)" "big endian short (16 bits)")
	  (list "o2.sd2" 2 44100 0.0183900222182274 "raw (no header)" "big endian short (16 bits)")
	  (list "o2.sf2" 1 44100 0.0367800444364548 "SoundFont" "little endian short (16 bits)")
	  (list "o2.smp" 1 8000 0.202749997377396 "SMP" "little endian short (16 bits)")
	  (list "o2.voc" 1 44100 0.0368934236466885 "VOC" "little endian short (16 bits)")
	  (list "o2.wave" 1 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
	  (list "o2_12bit.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian short (16 bits)")
	  (list "o2_18bit.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian int (24 bits)")
	  (list "o2_711u.wave" 1 44100 0.0367800444364548 "RIFF" "mulaw (8 bits)")
	  (list "o2_722.snd" 1 44100 0.0183900222182274 "Sun/Next" "unknown")
	  (list "o2_726.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
	  (list "o2_726.snd" 1 44100 0.0230158735066652 "Sun/Next" "unknown")
	  (list "o2_728.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
	  (list "o2_8.iff" 1 44100 0.0367800444364548 "SVX8" "signed byte (8 bits)")
	  (list "o2_8.voc" 1 44100 0.0370294786989689 "VOC" "unsigned byte (8 bits)")
	  (list "o2_dvi.wave" 1 44100 0.0232199542224407 "RIFF" "unknown")
	  (list "o2_float.bicsf" 1 44100 0.0367800444364548 "IRCAM" "big endian float (32 bits)")
	  (list "o2_gsm.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
	  (list "o2_u8.avr" 1 44100 0.0367800444364548 "AVR" "unsigned byte (8 bits)")
	  (list "o2_u8.wave" 1 44100 0.0367800444364548 "RIFF" "unsigned byte (8 bits)")
	  (list "o28.mpc" 1 44100 0.036780 "AKAI 4" "little endian short (16 bits)")
	  (list "oboe.g721" 1 22050 1.15287983417511 "Sun/Next" "unknown")
	  (list "oboe.g723_24" 1 22050 0.864761888980865 "Sun/Next" "unknown")
	  (list "oboe.g723_40" 1 22050 1.44126987457275 "Sun/Next" "unknown")
	  (list "oboe.kts" 1 22050 2.305125 "Korg" "big endian short (16 bits)")
	  (list "oboe.its" 1 22050 2.305125 "Impulse Tracker" "little endian short (16 bits)")
	  (list "oboe.sf2" 1 22050 2.30512475967407 "SoundFont" "little endian short (16 bits)")
	  (list "oboe.paf" 1 22050 2.305125 "Ensoniq Paris" "big endian short (16 bits)")
	  (list "oboe.pf1" 1 22050 2.305125 "Ensoniq Paris" "little endian short (16 bits)")
	  (list "oboe.smp" 1 22050 2.305125 "snack SMP" "little endian short (16 bits)")
	  (list "oboe.rf64" 1 22050 2.305125 "rf64" "little endian short (16 bits)")
	  (list "oboe-be32.caf" 1 22050 2.305125 "caff" "normalized big endian int (32 bits)")
	  (list "oboe-bf64.caf" 1 22050 2.305125 "caff" "big endian double (64 bits)")
	  (list "oboe-lf32.caf" 1 22050 2.305125 "caff" "little endian float (32 bits)")
	  (list "oboe-ulaw.caf" 1 22050 2.305125 "caff" "mulaw (8 bits)")
	  (list "oboe.nsp" 1 22050 2.305125 "CSL" "little endian short (16 bits)")
	  (list "oboe.nvf" 1 8000 6.353500 "Creative NVF" "unknown")
	  (list "oboe-ulaw.voc" 1 22050 2.305669 "VOC" "mulaw (8 bits)")
	  (list "oboe-lf32.sf" 1 22050 2.305669 "IRCAM" "little endian float (32 bits)")
	  (list "oboe.wfp" 1 22050 2.305125 "Turtle Beach" "little endian short (16 bits)")
	  (list "oboe.sox" 1 22050 2.305125 "Sox" "normalized little endian int (32 bits)")
	  (list "oki.snd" 2 44100 0.0041950112208724 "raw (no header)" "big endian short (16 bits)")
	  (list "oki.wav" 1 44100 0.016780 "RIFF" "unknown")
	  (list "orv-dvi-adpcm.wav" 1 44100 1.92725622653961 "RIFF" "unknown")
	  (list "riff-16.snd" 1 22050 1.88766443729401 "RIFF" "little endian short (16 bits)")
	  (list "riff-8-u.snd" 1 11025 0.506848096847534 "RIFF" "unsigned byte (8 bits)")
	  (list "rooster.wve" 1 8000 2.04800009727478 "PSION" "alaw (8 bits)")
	  (list "sd1-16.snd" 1 44100 0.400544226169586 "Sound Designer 1" "big endian short (16 bits)")
					;	    (list "segfault.snd" 16777216 576061440 1.24986669902682e-7 "Sun/Next" "unknown")
	  (list "sf-16.snd" 1 22050 1.88766443729401 "IRCAM" "big endian short (16 bits)")
	  (list "si654.adc" 1 16000 6.71362495422363 "ADC/OGI" "big endian short (16 bits)")
	  (list "smp-16.snd" 1 8000 5.2028751373291 "SMP" "little endian short (16 bits)")
	  (list "sound.pat" 1 8000 1.95050001144409 "Gravis Ultrasound patch" "unsigned little endian short (16 bits)")
	  (list "sound.sap" 1 8000 1.95050001144409 "Goldwave sample" "little endian short (16 bits)")
	  (list "sound.sds" 1 8000 1.95050001144409 "MIDI sample dump" "unknown")
	  (list "sound.sfr" 1 8000 1.95050001144409 "SRFS" "little endian short (16 bits)")
	  (list "sound.v8" 1 8000 1.95050001144409 "Covox V8" "unsigned byte (8 bits)")
	  (list "sound.vox" 2 44100 0.044217687100172 "raw (no header)" "big endian short (16 bits)")
	  (list "step.omf" 1 11025 8.70666694641113 "OMF" "signed byte (8 bits)")
	  (list "step.qt" 1 11025 8.70630359649658 "Quicktime" "unsigned byte (8 bits)")
	  (list "sun-16-afsp.snd" 1 8000 2.9760000705719 "Sun/Next" "big endian short (16 bits)")
	  (list "sun-mulaw.snd" 1 8000 4.61950016021729 "Sun/Next" "mulaw (8 bits)")
	  (list "sw1038t_short.wav" 2 8000 6.0 "NIST" "mulaw (8 bits)")
	  (list "swirl.pat" 1 22050 1.0619500875473 "Gravis Ultrasound patch" "unsigned little endian short (16 bits)")
	  (list "sy85.snd" 1 8000 5.05600023269653 "Sy-85" "big endian short (16 bits)")
	  (list "sy99.snd" 1 8000 4.54400014877319 "Sy-99" "big endian short (16 bits)")
	  (list "telephone.wav" 1 16000 2.27881240844727 "NIST" "little endian short (16 bits)")
	  (list "trumps22.adp" 1 22050 3.092880 "RIFF" "unknown")
	  (list "truspech.wav" 1 8000 1.1599999666214 "RIFF" "unknown")
	  (list "ulaw.aifc" 1 44100 0.0367800444364548 "AIFC" "mulaw (8 bits)")
	  (list "voc-8-u.snd" 1 8000 1.49937498569489 "VOC" "unsigned byte (8 bits)")
	  (list "o28.voc" 1 44100 0.036893 "VOC" "little endian short (16 bits)")
	  (list "voxware.wav" 1 8000 0.324000000953674 "RIFF" "unknown")
	  (list "wd.w00" 1 8000 0.202749997377396 "Sy-99" "big endian short (16 bits)")
	  (list "wd1.smp" 1 8000 0.202749997377396 "SMP" "little endian short (16 bits)")
	  (list "wd1.wav" 1 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
	  (list "wheel.mat" 2 44100 0.145646259188652 "raw (no header)" "big endian short (16 bits)")
	  (list "b8.pvf" 1 44100 0.036803 "Portable Voice Format" "signed byte (8 bits)")
	  (list "b16.pvf" 1 44100 0.036803 "Portable Voice Format" "big endian short (16 bits)")
	  (list "b32.pvf" 1 44100 0.036803 "Portable Voice Format" "big endian int (32 bits)")
	  (list "water.voc" 2 32000 42.3463897705078 "VOC" "little endian short (16 bits)")
	  (list "wood.dsf" 1 8000 0.202749997377396 "Delusion" "little endian short (16 bits)")
	  (list "wood.dvi" 1 22100 0.0278733037412167 "RIFF" "unknown")
	  (list "wood.dwd" 1 22100 0.0733936652541161 "DiamondWare" "signed byte (8 bits)")
	  (list "wood.fsm" 1 8000 0.202999994158745 "Farandole" "little endian short (16 bits)")
	  (list "wood.mad" 1 22100 0.0372398197650909 "RIFF" "unknown")
	  (list "wood.maud" 1 44100 0.0183900222182274 "MAUD" "big endian short (16 bits)")
	  (list "wood.pat" 1 22100 0.0733936652541161 "Gravis Ultrasound patch" "little endian short (16 bits)")
	  (list "wood.riff" 1 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
	  (list "wood.rifx" 1 44100 0.0367800444364548 "RIFF" "big endian short (16 bits)")
	  (list "wood.sds" 1 22100 0.0733936652541161 "MIDI sample dump" "unknown")
	  (list "wood.sdx" 1 22100 0.0733936652541161 "Sample dump" "unsigned little endian short (16 bits)")
	  (list "wood.sf" 1 44100 0.0367800444364548 "IRCAM" "big endian short (16 bits)")
	  (list "wood.sndr" 2 44100 0.0092290248721838 "raw (no header)" "big endian short (16 bits)")
	  (list "wood.sndt" 1 44100 0.0367800444364548 "SNDT" "unsigned byte (8 bits)")
	  (list "wood.st3" 1 8000 0.202749997377396 "Digiplayer ST3" "unsigned little endian short (16 bits)")
	  (list "wood.uwf" 1 8000 0.202999994158745 "Ultratracker" "little endian short (16 bits)")
	  (list "wood.w00" 1 16000 0.101374998688698 "TX-16W" "unknown")
	  (list "wood12.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian short (16 bits)")
	  (list "wood16.dwd" 2 44100 0.0367800444364548 "DiamondWare" "little endian short (16 bits)")
	  (list "wood16.wav" 2 44100 0.0367800444364548 "RIFF" "little endian short (16 bits)")
	  (list "wood16.nsp" 2 44100 0.0367800444364548 "CSL" "little endian short (16 bits)")
	  (list "wood16.smp" 2 44100 0.0367800444364548 "snack SMP" "little endian short (16 bits)")
	  (list "wood24.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian int (24 bits)")
	  (list "woodblock.aiff" 1 44100 0.0367800444364548 "AIFF" "big endian short (16 bits)")
	  (list "woodflt.snd" 1 44100 0.0367800444364548 "Sun/Next" "big endian float (32 bits)")
	  (list "RealDrums.sf2" 1 44100 6.39725637435913 "SoundFont" "little endian short (16 bits)")
	  (list "32bit.sf" 1 44100 4.6 "IRCAM" "little endian float (32 bits, unscaled)")
	  (list "PCM_48_8bit_m.w64" 1 48000 0.375 "SoundForge" "unsigned byte (8 bits)")
	  (list "oboe.sf6" 1 22050 2.305125 "SoundForge" "little endian short (16 bits)")
	  (list "addf8.24we" 1 8000 2.976000 "RIFF" "little endian int (24 bits)")
	  (list "hybrid.snd" 1 44100 4.600000 "BICSF" "big endian float (32 bits)")
	  (list "litmanna.sf" 1 44100 .533 "IRCAM" "little endian short (16 bits)")
	  (list "M1F1-float64C-AFsp.aif" 2 8000 2.9366 "AIFC" "big endian double (64 bits)")
	  (list "MacBoing.wav" 1 11127 0.696 "RIFF" "unsigned byte (8 bits)")
	  (list "t15.aiff" 2 44100 135.00 "AIFC" "little endian short (16 bits)")
	  (list "tomf8.aud" 1 8000 2.016000 "INRS" "little endian short (16 bits)")
	  (list "Xhs001x.nsp" 1 10000 6.017400 "CSL" "little endian short (16 bits)")
	  (list "zulu_a4.w11" 1 33000 1.21987879276276 "TX-16W" "unknown" 23342 40042)))
	
	(for-each (lambda (in-name real-name)
		    (if (not (string=? (mus-expand-filename in-name) real-name))
			(snd-display #__line__ ";mus-expand-filename ~A -> ~A" in-name (mus-expand-filename in-name)))
		    (if (file-exists? "/home/bil/./sf1/o2.voc")
			(let ((ind (open-sound in-name)))
			  (if (not (sound? ind))
			      (snd-display #__line__ ";can't open ~A" in-name)
			      (begin
				(if (not (string=? (file-name ind) real-name))
				    (snd-display #__line__ ";expand file name ~A: ~A" in-name (file-name ind)))
				(close-sound ind))))))
		  (list "/home/bil/./sf1/o2.voc" "~/./sf1/o2.voc" "~/cl/../sf1/o2.voc" "/home/bil/cl/../sf1/o2.voc")
		  (list "/home/bil/sf1/o2.voc" "/home/bil/sf1/o2.voc" "/home/bil/sf1/o2.voc" "/home/bil/sf1/o2.voc"))
	
	(let ((lst (mus-sound-mark-info (string-append sf-dir "forest.aiff"))))
	  (if (not (equal? lst '((4 0) (3 0) (2 144332) (1 24981))))
	      (snd-display #__line__ ";mus-sound-mark-info forest: ~A" lst)))
	(let ((lst (mus-sound-mark-info (string-append sf-dir "traffic.aiff"))))
	  (if (not (equal? lst '((4 1) (3 0) (2 171931) (1 99461))))
	      (snd-display #__line__ ";mus-sound-mark-info traffic: ~A" lst)))
	)))



;;; ---------------- test 3: variables ----------------

(define (snd_test_3)
  (let ((ind #f))
    
    (set! ind (open-sound "oboe.snd"))
    (if (and (file-exists? "funcs.cl") 
	     (not (defined? 'swellf)))
	(load "funcs.cl"))
    (let ((td (temp-dir)))
      (catch #t
	     (lambda ()
	       (set! (temp-dir) (string-append home-dir "/test"))
	       (if (not (string=? (temp-dir) (string-append home-dir "/test")))
		   (snd-display #__line__ ";set temp-dir: ~A?" (temp-dir))))
	     (lambda args args))
      (if td 
	  (set! (temp-dir) td)
	  (set! (temp-dir) "")))
    (if (fneq (sample 1000) 0.0328) (snd-display #__line__ ";sample: ~A?" (sample 1000)))
    (if (or (not (hook? output-name-hook)) (not (hook-empty? output-name-hook)))
	(snd-display #__line__ ";output-name-hook: ~A?" output-name-hook))
    (if (or (not (hook? output-comment-hook)) (not (hook-empty? output-comment-hook)))
	(snd-display #__line__ ";output-comment-hook: ~A?" output-comment-hook))
    (if (or (not (hook? peak-env-hook)) (not (hook-empty? peak-env-hook)))
	(snd-display #__line__ ";peak-env-hook: ~A?" peak-env-hook))
    (if (or (not (hook? help-hook)) (not (hook-empty? help-hook)))
	(snd-display #__line__ ";help-hook: ~A?" help-hook))
    (if (or (not (hook? mark-drag-hook)) (not (hook-empty? mark-drag-hook)))
	(snd-display #__line__ ";mark-drag-hook: ~A?" mark-drag-hook))
    (if (or (not (hook? mark-drag-triangle-hook)) (not (hook-empty? mark-drag-triangle-hook)))
	(snd-display #__line__ ";mark-drag-triangle-hook: ~A?" mark-drag-triangle-hook))
    (if (or (not (hook? mix-drag-hook)) (not (hook-empty? mix-drag-hook)))
	(snd-display #__line__ ";mix-drag-hook: ~A?" mix-drag-hook))
    (if (or (not (hook? mouse-drag-hook)) (not (hook-empty? mouse-drag-hook)))
	(snd-display #__line__ ";mouse-drag-hook: ~A?" mouse-drag-hook))
    (if (or (not (hook? mouse-click-hook)) (not (hook-empty? mouse-click-hook)))
	(snd-display #__line__ ";mouse-click-hook: ~A?" mouse-click-hook))
    (if (or (not (hook? mouse-press-hook)) (not (hook-empty? mouse-press-hook)))
	(snd-display #__line__ ";mouse-press-hook: ~A?" mouse-press-hook))
    (if (or (not (hook? start-playing-hook)) (not (hook-empty? start-playing-hook)))
	(snd-display #__line__ ";start-playing-hook: ~A?" start-playing-hook))
    (if (or (not (hook? start-playing-selection-hook)) (not (hook-empty? start-playing-selection-hook)))
	(snd-display #__line__ ";start-playing-selection-hook: ~A?" start-playing-selection-hook))
    (if (not (hook? stop-playing-hook))
	(snd-display #__line__ ";stop-playing-hook: ~A?" stop-playing-hook))
    (if (or (not (hook? key-press-hook)) (not (hook-empty? key-press-hook)))
	(snd-display #__line__ ";key-press-hook: ~A?" key-press-hook))
    (if (or (not (hook? snd-error-hook)) (not (hook-empty? snd-error-hook)))
	(snd-display #__line__ ";snd-error-hook: ~A?" snd-error-hook))
    (if (or (not (hook? snd-warning-hook)) (not (hook-empty? snd-warning-hook)))
	(snd-display #__line__ ";snd-warning-hook: ~A?" snd-warning-hook))
    (if (or (not (hook? name-click-hook)) (not (hook-empty? name-click-hook)))
	(snd-display #__line__ ";name-click-hook: ~A?" name-click-hook))
    (if (or (not (hook? after-apply-controls-hook)) (not (hook-empty? after-apply-controls-hook)))
	(snd-display #__line__ ";after-apply-controls-hook: ~A?" after-apply-controls-hook))
    (if (or (not (hook? enved-hook)) (not (hook-empty? enved-hook)))
	(snd-display #__line__ ";enved-hook: ~A?" enved-hook))
    (if (or (not (hook? mouse-enter-label-hook)) (not (hook-empty? mouse-enter-label-hook)))
	(snd-display #__line__ ";mouse-enter-label-hook: ~A?" mouse-enter-label-hook))
    (if (or (not (hook? mouse-enter-graph-hook)) (not (hook-empty? mouse-enter-graph-hook)))
	(snd-display #__line__ ";mouse-enter-graph-hook: ~A?" mouse-enter-graph-hook))
    (if (or (not (hook? mouse-enter-listener-hook)) (not (hook-empty? mouse-enter-listener-hook)))
	(snd-display #__line__ ";mouse-enter-listener-hook: ~A?" mouse-enter-listener-hook))
    (if (or (not (hook? mouse-leave-label-hook)) (not (hook-empty? mouse-leave-label-hook)))
	(snd-display #__line__ ";mouse-leave-label-hook: ~A?" mouse-leave-label-hook))
    (if (or (not (hook? mouse-leave-graph-hook)) (not (hook-empty? mouse-leave-graph-hook)))
	(snd-display #__line__ ";mouse-leave-graph-hook: ~A?" mouse-leave-graph-hook))
    (if (or (not (hook? mouse-leave-listener-hook)) (not (hook-empty? mouse-leave-listener-hook)))
	(snd-display #__line__ ";mouse-leave-listener-hook: ~A?" mouse-leave-listener-hook))
    (if (or (not (hook? window-property-changed-hook)) (not (hook-empty? window-property-changed-hook)))
	(snd-display #__line__ ";window-property-changed-hook: ~A?" window-property-changed-hook))
    (if (or (not (hook? initial-graph-hook)) (not (hook-empty? initial-graph-hook)))
	(snd-display #__line__ ";initial-graph-hook: ~A?" initial-graph-hook))
    (if (or (not (hook? after-graph-hook)) (not (hook-empty? after-graph-hook)))
	(snd-display #__line__ ";after-graph-hook: ~A?" after-graph-hook))
    (if (or (not (hook? graph-hook)) (not (hook-empty? graph-hook)))
	(snd-display #__line__ ";graph-hook: ~A?" graph-hook))
    
    (set! (show-controls) #t)
    (if with-gui
	(begin
	  (let ((wid (enved-dialog) ))
	    (if (not (equal? wid (list-ref (dialog-widgets) 2)))
		(snd-display #__line__ ";enved-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 2))))
					;(if (not (list-ref (dialog-widgets) 2)) (snd-display #__line__ ";enved-dialog?"))
	  (set! (enved-envelope) '(0.0 0.0 1.0 1.0 2.0 0.0))
	  (if (not (equal? (enved-envelope) (list 0.0 0.0 1.0 1.0 2.0 0.0)))
	      (snd-display #__line__ ";set enved-envelope: ~A?" (enved-envelope)))
	  (set! (enved-envelope) (enved-envelope))
	  (if (not (equal? (enved-envelope) (list 0.0 0.0 1.0 1.0 2.0 0.0)))
	      (snd-display #__line__ ";set enved-envelope to self: ~A?" (enved-envelope)))))
    
    (letrec ((test-vars
	      (lambda (lst)
		(if (not (null? lst))
		    (let* ((name (list-ref (car lst) 0))
			   (getfnc (list-ref (car lst) 1))
			   (setfnc (lambda (val) (set! (getfnc) val)))
			   (initval (list-ref (car lst) 2))
			   (newval (list-ref (car lst) 3)))
		      
		      (setfnc newval)
		      (let ((nowval (getfnc)))
			(if (and (not (equal? newval nowval))
				 (or (not (list? newval))
				     (not (feql newval nowval))))
			    (if (and (number? newval) (not (rational? newval)))
				(if (> (abs (- newval nowval)) .01)
				    (snd-display #__line__ ";~A /= ~A (~A)" name newval nowval))
				(snd-display #__line__ ";~A /= ~A (~A)" name newval nowval)))
			(setfnc initval)
			(set! (getfnc) newval)
			(let ((nowval (getfnc)))
			  (if (and (not (equal? newval nowval))
				   (or (not (list? newval))
				       (not (feql newval nowval))))
			      (if (and (number? newval) (not (rational? newval)))
				  (if (> (abs (- newval nowval)) .01)
				      (snd-display #__line__ ";set! ~A /= ~A (~A)" name newval nowval))
				  (snd-display #__line__ ";set! ~A /= ~A (~A)" name newval nowval)))
			  (setfnc initval))
			(test-vars (cdr lst))))))))
      (test-vars 
       (list
	(list 'amp-control amp-control 1.0 0.5)
	(list 'amp-control-bounds amp-control-bounds (list 0.0 8.0) (list 1.0 5.0))
	(list 'ask-before-overwrite ask-before-overwrite #f #t)
	(list 'audio-input-device audio-input-device 0 1)
	(list 'audio-output-device audio-output-device 0 1)
	(list 'auto-resize auto-resize #t #f)
	(list 'auto-update auto-update #f #t)
	(list 'channel-style channel-style 0 1)
	(list 'colormap colormap good-colormap better-colormap)
	(list 'color-cutoff color-cutoff 0.003 0.01)
	(list 'color-inverted color-inverted #t #f)
	(list 'color-scale color-scale 1.0 0.5)
	(list 'contrast-control contrast-control 0.0 0.5)
	(list 'contrast-control-bounds contrast-control-bounds (list 0.0 10.0) (list 1.0 5.0))
	(list 'contrast-control-amp contrast-control-amp 1.0 0.5)
	(list 'contrast-control? contrast-control? #f #t)
	(list 'auto-update-interval auto-update-interval 60.0 120.0)
	(list 'cursor-update-interval cursor-update-interval 0.05 0.10)
	(list 'cursor-location-offset cursor-location-offset 0 32768)
	(list 'with-tracking-cursor with-tracking-cursor #f #t)
	(list 'cursor-size cursor-size 15 30)
	(list 'cursor-style cursor-style cursor-cross cursor-line)
	(list 'tracking-cursor-style tracking-cursor-style cursor-cross cursor-line)
	(list 'dac-combines-channels dac-combines-channels #t #f)
	(list 'dac-size dac-size 256 512)
	(list 'minibuffer-history-length minibuffer-history-length 8 16)
	(list 'clipping clipping #f #t)
	(list 'default-output-chans default-output-chans 1 2)
	(list 'default-output-data-format default-output-data-format 1 1)
	(list 'default-output-srate default-output-srate 22050 44100)
	(list 'default-output-header-type default-output-header-type mus-next mus-aifc)
	(list 'dot-size dot-size 1 4)
	(list 'enved-base enved-base 1.0  1.5)
	(list 'enved-clip? enved-clip? #f #t)
	(list 'enved-in-dB enved-in-dB #f #t)
	(list 'enved-style enved-style envelope-linear envelope-exponential)
	(list 'enved-power enved-power 3.0 3.5)
	(list 'enved-target enved-target 0 1)
	(list 'enved-wave? enved-wave? #f #t)
	(list 'eps-file eps-file "snd.eps" "snd-1.eps")
	(list 'eps-left-margin eps-left-margin 0.0 72.0)
	(list 'eps-size eps-size 1.0 2.0)
	(list 'eps-bottom-margin eps-bottom-margin 0.0 36.0)
	(list 'expand-control expand-control 1.0 2.0)
	(list 'expand-control-bounds expand-control-bounds (list .001 20.0) (list 1.0 2.0))
	(list 'expand-control-hop expand-control-hop 0.05 0.1)
	(list 'expand-control-jitter expand-control-jitter 0.1 0.2)
	(list 'expand-control-length expand-control-length 0.15 0.2)
	(list 'expand-control-ramp expand-control-ramp 0.4 0.2)
	(list 'expand-control? expand-control? #f #t)
	(list 'fft-window-alpha fft-window-alpha 0.0  1.0)
	(list 'fft-window-beta fft-window-beta 0.0  0.5)
	(list 'fft-log-frequency fft-log-frequency #f #t)
	(list 'fft-log-magnitude fft-log-magnitude #f #t)
	(list 'fft-with-phases fft-with-phases #f #t)
	(list 'transform-size transform-size 512 1024)
	(list 'transform-graph-type transform-graph-type graph-once graph-as-sonogram)
	(list 'fft-window fft-window 6 5)
	(list 'transform-graph? transform-graph? #f #t)
	(list 'filter-control-in-dB filter-control-in-dB #f #t)
	(list 'filter-control-envelope filter-control-envelope (list 0.0 1.0 1.0 1.0) (list 0.0 1.0 1.0 0.0))
	(list 'enved-filter enved-filter #t #f)
	(list 'enved-filter-order enved-filter-order 40 20)
	(list 'filter-control-in-hz filter-control-in-hz #f #t)
	(list 'filter-control-order filter-control-order 20 40)
	(list 'filter-control? filter-control? #f #t)
	(list 'graph-cursor graph-cursor 34 33)
	(list 'graph-style graph-style 0 1)
	(list 'just-sounds just-sounds #f #t)
	(list 'listener-prompt listener-prompt ">" ":")
	(list 'max-transform-peaks max-transform-peaks 100 10)
	(list 'max-regions max-regions 16 6)
	(list 'min-dB min-dB -60.0 -90.0)
	(list 'log-freq-start log-freq-start 32.0 10.0)
	(list 'mix-waveform-height mix-waveform-height 20 40)
	(list 'mix-tag-height mix-tag-height 14 20)
	(list 'mix-tag-width mix-tag-width 6 20)
	(list 'mark-tag-height mark-tag-height 4 20)
	(list 'mark-tag-width mark-tag-width 10 20)
	(list 'mus-prescaler mus-prescaler 1.0 100.0)
	(list 'mus-clipping mus-clipping #f #t)
	(list 'selection-creates-region selection-creates-region #t #f)
	(list 'transform-normalization transform-normalization normalize-by-channel dont-normalize)
	(list 'view-files-sort view-files-sort 0 1)
	(list 'print-length print-length 12 16)
	(list 'region-graph-style region-graph-style graph-lines graph-lollipops)
	(list 'reverb-control-decay reverb-control-decay 1.0 2.0)
	(list 'reverb-control-feedback reverb-control-feedback 1.09 1.6)
	(list 'reverb-control-length reverb-control-length 1.0 2.0)
	(list 'reverb-control-length-bounds reverb-control-length-bounds (list 0.0 5.0) (list 1.0 2.0))
	(list 'reverb-control-lowpass reverb-control-lowpass 0.7 0.9)
	(list 'reverb-control-scale reverb-control-scale 0.0 0.2)
	(list 'reverb-control-scale-bounds reverb-control-scale-bounds (list 0.0 4.0) (list 0.0 0.2))
	(list 'reverb-control? reverb-control? #f #t)
	(list 'show-axes show-axes 1 0)
	(list 'show-transform-peaks show-transform-peaks #f #t)
	(list 'show-indices show-indices #f #t)
	(list 'show-marks show-marks #t #f)
	(list 'show-mix-waveforms show-mix-waveforms #t #f)
	(list 'show-selection-transform show-selection-transform #f #t)
	(list 'show-y-zero show-y-zero #f #t)
	(list 'show-grid show-grid #f #t)
	(list 'grid-density grid-density 1.0 0.5)
	(list 'show-sonogram-cursor show-sonogram-cursor #f #t)
	(list 'sinc-width sinc-width 10 40)
	(list 'spectrum-end spectrum-end 1.0 0.7)
	(list 'spectro-hop spectro-hop 4 10)
	(list 'spectrum-start spectrum-start 0.0 0.1)
	(list 'spectro-x-angle spectro-x-angle (if (provided? 'gl) 300.0 90.0) 60.0)
	(list 'spectro-x-scale spectro-x-scale (if (provided? 'gl) 1.5 1.0) 2.0)
	(list 'spectro-y-angle spectro-y-angle (if (provided? 'gl) 320.0 0.0) 60.0)
	(list 'spectro-y-scale spectro-y-scale 1.0 2.0)
	(list 'spectro-z-angle spectro-z-angle (if (provided? 'gl) 0.0 358.0) 60.0)
	(list 'spectro-z-scale spectro-z-scale (if (provided? 'gl) 1.0 0.1) 0.2)
	(list 'speed-control speed-control 1.0 0.5)
	(list 'speed-control-bounds speed-control-bounds (list 0.05 20.0) (list 1.0 5.0))
	(list 'speed-control-style speed-control-style 0 1)
	(list 'speed-control-tones speed-control-tones 12 18)
	(list 'sync sync 0 1)
	(list 'tiny-font tiny-font (if (provided? 'snd-gtk) "Sans 8" "6x12") (if (provided? 'snd-gtk) "Monospace 10" "9x15"))
	(list 'transform-type transform-type fourier-transform autocorrelation)
	(list 'with-verbose-cursor with-verbose-cursor #f #t)
	(list 'wavelet-type wavelet-type 0 1)
	(list 'time-graph? time-graph? #f #t)
	(list 'time-graph-type time-graph-type graph-once graph-as-wavogram)
	(list 'wavo-hop wavo-hop 3 6)
	(list 'wavo-trace wavo-trace 64 128)
	(list 'with-mix-tags with-mix-tags #t #f)
	(list 'with-relative-panes with-relative-panes #t #f)
	(list 'with-gl with-gl (provided? 'gl) #f)
	(list 'x-axis-style x-axis-style 0 1)
	(list 'beats-per-minute beats-per-minute 30.0 120.0)
	(list 'beats-per-measure beats-per-measure 1 120)
	(list 'zero-pad zero-pad 0 1)
	(list 'zoom-focus-style zoom-focus-style 2 1))))
    
    (letrec ((test-bad-args
	      (lambda (lst)
		(if (not (null? lst))
		    (let* ((name (list-ref (car lst) 0))
			   (getfnc (list-ref (car lst) 1))
			   (setfnc (lambda (val) (set! (getfnc) val)))
			   (initval (list-ref (car lst) 2))
			   (newvals (list-ref (car lst) 3)))
		      (for-each
		       (lambda (n)
			 (catch #t 
				(lambda ()
				  (setfnc n))
				(lambda args (car args)))
			 (let ((nowval (getfnc)))
			   (if (equal? n nowval)
			       (snd-display #__line__ ";(bad set) ~A = ~A (~A)" name n initval))
			   (setfnc initval)))
		       newvals)
		      (test-bad-args (cdr lst)))))))
      (test-bad-args
       (list
	(list 'amp-control amp-control 1.0 '(-1.0 123.123))
	(list 'amp-control-bounds amp-control-bounds (list 0.0 8.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
	(list 'channel-style channel-style 0 '(32 -1 1.0))
	(list 'colormap colormap good-colormap '(321 -123))
	(list 'color-cutoff color-cutoff 0.003 '(-1.0 123.123))
	(list 'color-scale color-scale 1.0 '(-32.0 2000.0))
	(list 'contrast-control contrast-control 0.0 '(-123.123 123.123))
	(list 'contrast-control-bounds contrast-control-bounds (list 0.0 10.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
	(list 'cursor-size cursor-size 15 '(1.123 -2.5))
	(list 'dac-size dac-size 256 '(-1 0 -123))
	(list 'dot-size dot-size 1 '(0 -1 -123))
	(list 'enved-target enved-target 0 '(123 -321))
	(list 'expand-control expand-control 1.0 '(-1.0 0.0))
	(list 'expand-control-bounds expand-control-bounds (list 0.001 20.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
	(list 'expand-control-hop expand-control-hop 0.05 '(-1.0))
	(list 'expand-control-length expand-control-length 0.15 '(-1.0 0.0))
	(list 'expand-control-ramp expand-control-ramp 0.4 '(-1.0 1.0 123.123))
	(list 'fft-window-alpha fft-window-alpha 0.0  '(-1.0 123.123))
	(list 'fft-window-beta fft-window-beta 0.0  '(-1.0 123.123))
	(list 'transform-size transform-size 512 '(-1 0))
	(list 'zero-pad zero-pad 0 '(-1 -123))
	(list 'cursor-style cursor-style cursor-cross '(-1))
	(list 'cursor-style cursor-style cursor-line '(2 123))
	(list 'tracking-cursor-style tracking-cursor-style cursor-cross '(-1))
	(list 'tracking-cursor-style tracking-cursor-style cursor-line '(2 123))
	(list 'transform-graph-type transform-graph-type graph-once '(-1 123))
	(list 'fft-window fft-window 6 '(-1 123))
	(list 'enved-filter-order enved-filter-order 40 '(-1 0))
	(list 'filter-control-order filter-control-order 20 '(-10 -1 0))
	(list 'max-transform-peaks max-transform-peaks 100 '(-1))
	(list 'max-regions max-regions 16 '(-1 -123))
	(list 'view-files-sort view-files-sort 0 '(-1 123))
	(list 'reverb-control-length reverb-control-length 1.0 '(-1.0))
	(list 'show-axes show-axes 1 '(-1 123))
	(list 'sinc-width sinc-width 10 '(-10))
	(list 'spectrum-end spectrum-end 1.0 '(-1.0))
	(list 'spectro-hop spectro-hop 4 '(-10 -1 0))
	(list 'spectrum-start spectrum-start 0.0 '(-1.0))
	(list 'speed-control speed-control 1.0 '(0.0))
	(list 'speed-control-bounds speed-control-bounds (list 0.05 20.0) (list #f (list 0.0) (list 1.0 0.0) 2.0))
	(list 'speed-control-style speed-control-style 0 '(-1 10))
	(list 'transform-type transform-type fourier-transform (list (integer->transform -1) (integer->transform 123)))
	(list 'wavelet-type wavelet-type 0 '(-1 123))
	(list 'wavo-hop wavo-hop 1 '(0 -123))
	(list 'wavo-trace wavo-trace 1 '(0 -123))
	(list 'x-axis-style x-axis-style 0 '(-1 123))
	(list 'zoom-focus-style zoom-focus-style 2 '(-1 123)))))
    
    (set! (window-width) 300)
    (set! (window-height) 300)
    (if (not (equal? (window-width) 300))
	(snd-display #__line__ ";window width: ~A /= 300?" (window-width)))
    (if (not (equal? (window-height) 300))
	(snd-display #__line__ ";window height: ~A /= 300?" (window-height)))
    (set! (window-x) 123)
    (set! (window-y) 321)
    (if (not (equal? (window-x) 123))
	(snd-display #__line__ ";window x: ~A /= 123?" (window-x)))
    (if (not (equal? (window-y) 321))
	(snd-display #__line__ ";window y: ~A /= 321?" (window-y)))
    (set! (window-y) 10) ; get it back out of harm's way
    (set! (color-scale) 100.0)
    (if (fneq (color-scale) 100.0) (snd-display #__line__ ";color-scale to 100: ~A" (color-scale)))
    
    (if (procedure? (search-procedure))
	(snd-display #__line__ ";global search procedure: ~A?" (search-procedure)))
    (set! (search-procedure) (lambda (y) (> y .1)))
    (if (not (procedure? (search-procedure)))
	(snd-display #__line__ ";set global search procedure: ~A?" (search-procedure)))
    (if (not ((search-procedure) .2))
	(snd-display #__line__ ";search > .1 .2"))
    (if ((search-procedure) .02)
	(snd-display #__line__ ";search > .1 .02"))
    (set! (search-procedure) (lambda (y) (< y 0.0)))
    (if ((search-procedure) .02)
	(snd-display #__line__ ";search < 0.0 .02"))
    (set! (search-procedure) #f)
    (if (procedure? (search-procedure))
	(snd-display #__line__ ";global search procedure after reset: ~A?" (search-procedure)))
    (set! (search-procedure) (lambda (y) (> y .1)))
    (if (not (procedure? (search-procedure)))
	(snd-display #__line__ ";set global search procedure: ~A?" (search-procedure)))
    
    (set! (enved-filter-order) 5)
    (if (not (= (enved-filter-order) 6)) (snd-display #__line__ ";set enved-filter-order 5: ~A" (enved-filter-order)))
    (if with-gui
	(begin
	  (set! (enved-envelope) 'zero_to_one) ; funcs.cl above
	  (if (not (feql (enved-envelope) zero_to_one)) (snd-display #__line__ ";set symbol enved-envelope: ~A ~A" (enved-envelope) zero_to_one))
	  (set! (enved-envelope) "mod_down")
	  (if (not (feql (enved-envelope) mod_down)) (snd-display #__line__ ";set string enved-envelope: ~A ~A" (enved-envelope) mod_down))))
    
    (close-sound ind) 
    (dismiss-all-dialogs)
    
    (let ((undef '())
	  (names (list '*snd-opened-sound* 'abort 'add-clm-field 'add-colormap 
		       'add-directory-to-view-files-list 'add-file-filter 'add-file-sorter 'add-file-to-view-files-list 'add-mark
		       'add-player 'add-sound-file-extension 'add-source-file-extension 'add-to-main-menu 'add-to-menu
		       'add-transform 'add-watcher 'after-apply-controls-hook 'after-edit-hook 'after-graph-hook 'after-lisp-graph-hook
		       'after-open-hook 'after-save-as-hook 'after-save-state-hook 'after-transform-hook 'all-pass
		       'all-pass? 'amp-control 'amp-control-bounds 'amplitude-modulate 'analyse-ladspa
		       'apply-controls 'apply-ladspa 'array->file 'array-interp 'as-one-edit
		       'ask-before-overwrite 'asymmetric-fm 'asymmetric-fm? 'audio-input-device 'audio-output-device
		       'auto-resize 'auto-update 'auto-update-interval 'autocorrelate 'autocorrelation
		       'moving-average 'moving-average? 'axis-color 'axis-info 'axis-label-font 'axis-numbers-font
		       'bad-header-hook 'bartlett-window 'bartlett-hann-window 'basic-color 'beats-per-measure 'beats-per-minute
		       'before-close-hook 'before-exit-hook 'before-save-as-hook 'before-save-state-hook 'before-transform-hook
		       'bind-key 'blackman2-window 'blackman3-window 'blackman4-window 
		       'blackman5-window 'blackman6-window 'blackman7-window 'blackman8-window 'blackman9-window 'blackman10-window 
		       'bohman-window 'bold-peaks-font 'bomb 'c-g! 'c-g? 'cauchy-window 'mlt-sine-window
		       'cepstrum 'change-samples-with-origin 'channel->vct 'channel-amp-envs 'channel-data
		       'channel-properties 'channel-property 'channel-style 'channel-widgets 'channels 'channels-combined
		       'channels-separate 'channels-superimposed 'chans 'clear-array 'clear-listener
		       'clear-minibuffer 'clear-sincs 'clip-hook 'clipping 'clm-channel 'clm-print
		       'clm-table-size 'clm-default-frequency 'close-hook 'close-sound 'color->list
		       'color-cutoff 'color-orientation-dialog 'color-hook 'color-inverted 'color-scale
		       'color? 'colormap 'colormap-name 'colormap-ref 'colormap-size
		       'colormap? 'comb 'comb? 'comment 'connes-window
		       'continue-frame->file 'continue-sample->file 'contrast-control 'contrast-control-amp 'contrast-control-bounds
		       'contrast-control? 'contrast-enhancement 'controls->channel 'convolution 'convolve
		       'convolve-files 'convolve-selection-with 'convolve-with 'convolve? 'copy-context
		       'copy-sampler 'count-matches 'current-edit-position
		       'current-font 'cursor 'cursor-color 'cursor-context 'cursor-cross
		       'cursor-in-middle 'cursor-in-view 'cursor-line 'cursor-location-offset 'cursor-on-left
		       'cursor-on-right 'cursor-position 'cursor-size 'cursor-style 'cursor-update-interval
		       'dac-combines-channels 'dac-hook 'dac-size 'data-color 'data-format
		       'data-location 'data-size 'db->linear 'default-output-chans 'default-output-data-format
		       'default-output-header-type 'default-output-srate 'define-envelope 'degrees->radians 'delay
		       'delay-tick 'delay? 'delete-colormap 'delete-file-filter 'delete-file-sorter
		       'delete-mark 'delete-marks 'delete-sample 'delete-samples
		       'delete-selection 'delete-transform 'delete-watcher 'dialog-widgets 'disk-kspace
		       'display-edits 'doit-again-button-color 'doit-button-color 'dolph-chebyshev-window 'dont-normalize
		       'dot-product 'dot-size 'draw-axes 'draw-dot 'draw-dots
		       'draw-line 'draw-lines 'draw-mark-hook 'draw-mix-hook 'draw-string 'drop-hook
		       'during-open-hook 'edit-fragment 'edit-header-dialog 'edit-hook 'edit-list->function
		       'edit-position 'edit-tree 'edits 'edot-product 'env
		       'env-channel 'env-channel-with-base 'env-interp 'env-selection 'env-sound
		       'env? 'enved-add-point 'enved-amplitude 'enved-base 'enved-clip?
		       'enved-delete-point 'enved-dialog 'enved-envelope 'enved-filter 'enved-filter-order
		       'enved-hook 'enved-in-dB 'enved-move-point 'enved-power 'enved-spectrum
		       'enved-srate 'enved-style 'enved-target 'enved-wave? 'enved-waveform-color
		       'envelope-exponential 'envelope-linear 'eps-bottom-margin 'eps-file
		       'eps-left-margin 'eps-size 'exit 'exit-hook
		       'expand-control 'expand-control-bounds 'expand-control-hop 'expand-control-jitter 'expand-control-length
		       'expand-control-ramp 'expand-control? 'exponential-window 'fft 'fft-log-frequency
		       'fft-log-magnitude 'fft-window 'fft-window-alpha 'fft-window-beta 'fft-with-phases 'file->array
		       'file->frame 'file->frame? 'file->sample 'file->sample? 'file->string
		       'file-name 'file-write-date 'fill-polygon 'fill-rectangle 'filter
		       'filtered-comb 'filtered-comb?
		       'filter-channel 'filter-control-coeffs 'filter-control-envelope 'filter-control-in-dB 'filter-control-in-hz
		       'filter-control-order 'filter-control-waveform-color 'filter-control? 'filter-selection 'filter-sound
		       'filter? 'find-channel 'find-dialog 'find-mark 'find-sound
		       'finish-progress-report 'fir-filter 'fir-filter? 'flat-top-window 'focus-widget 'foreground-color
		       'forget-region 'formant 'formant-bank 'formant? 'firmant 'firmant? 
		       'fourier-transform
		       'frame 'frame* 'frame+ 'frame->file 'frame->file?
		       'frame->frame 'frame->list 'frame->sample 'frame-ref 'frame-set!
		       'frame? 'frames 'free-player
		       'free-sampler 'gaussian-window 'gc-off 'gc-on
		       'gl-graph->ps 'glSpectrogram 'goto-listener-end 'granulate 'granulate?
		       'graph 'graph->ps 'graph-as-sonogram 'graph-as-spectrogram 'graph-as-wavogram
		       'graph-color 'graph-cursor 'graph-data 'graph-dots 'graph-dots-and-lines
		       'graph-filled 'graph-hook 'graph-lines 'graph-lollipops 'graph-once
		       'graph-style 'graphs-horizontal 'grid-density 'haar-transform 'hamming-window
		       'hann-poisson-window 'hann-window 'header-type 'help-button-color 'help-dialog
		       'help-hook 'hide-widget 'highlight-color 'html-dir 'html-program
		       'hz->radians 'iir-filter 'iir-filter? 'in 'in-any
		       'ina 'inb 'info-dialog 'init-ladspa 'initial-graph-hook
		       'insert-file-dialog 'insert-region 'insert-sample 'insert-samples 'insert-samples-with-origin
		       'insert-selection 'insert-silence 'insert-sound 'just-sounds 'kaiser-window
		       'key 'key-binding 'key-press-hook 'keyboard-no-action 'ladspa-activate
		       'ladspa-cleanup 'ladspa-connect-port 'ladspa-deactivate 'ladspa-descriptor 'ladspa-dir 'peak-env-dir
		       'ladspa-instantiate 'ladspa-run 'ladspa-run-adding 'ladspa-set-run-adding-gain 'left-sample
		       'linear->db 'lisp-graph 'lisp-graph-hook 'lisp-graph-style 'lisp-graph?
		       'list->vct 'list-ladspa 'listener-click-hook 'listener-color 'listener-font
		       'listener-prompt 'listener-selection 'listener-text-color 'little-endian? 'locsig
		       'locsig-ref 'locsig-reverb-ref 'locsig-reverb-set! 'locsig-set! 'locsig-type
		       'locsig? 'log-freq-start 'main-menu 'main-widgets 'make-all-pass
		       'make-asymmetric-fm 'make-moving-average 'make-bezier 'make-color 'make-comb 'make-filtered-comb
		       'make-convolve 'make-delay 'make-env 'make-fft-window 'make-file->frame
		       'make-file->sample 'make-filter 'make-fir-coeffs 'make-fir-filter 'make-formant 'make-firmant
		       'make-frame 'make-frame->file 'make-granulate 'make-graph-data 'make-iir-filter
		       'make-locsig 'make-mix-sampler 'make-mixer 'make-move-sound 'make-notch 'make-one-pole
		       'make-one-zero 'make-oscil 'make-phase-vocoder 'make-player 'make-polyshape 'make-polywave
		       'make-pulse-train 'make-rand 'make-rand-interp 'make-readin
		       'make-region 'make-region-sampler 'make-sample->file 'make-sampler 'make-sawtooth-wave
		       'make-scalar-mixer 'make-nrxysin 'make-nrxycos 'make-snd->sample 'make-sound-data 'make-square-wave
		       'make-src 'make-ssb-am 'make-ncos 'make-nsin 'make-table-lookup
		       'make-triangle-wave 'make-two-pole 'make-two-zero
		       'make-variable-graph 'make-vct 'make-wave-train 
		       'map-chan 'map-channel 'mark-click-hook 'mark-color 'mark-context
		       'mark-drag-hook 'mark-drag-triangle-hook 'mark-home 'mark-hook 'mark-name 'mark-properties 'mark-property
		       'mark-sample 'mark-sync 'mark-sync-max 'mark-tag-height 'mark-tag-width
		       'mark? 'marks 'max-regions 'max-transform-peaks 'max-virtual-ptrees 'maxamp
		       'maxamp-position 'menu-widgets 'min-dB 'minibuffer-history-length 'mix
		       'mix-amp 'mix-amp-env 'mix-click-hook 'mix-color
		       'mix-dialog-mix 'mix-drag-hook 'mix-file-dialog 'mix-length 'mix-home
		       'mix-name 'mix-position 'mix-properties 'mix-property 'mix-region 'mix-release-hook 'mix-sync 'mix-sync-max
		       'mix-sampler? 'mix-selection 'mix-speed 'mix-tag-height
		       'mix-tag-width 'mix-tag-y
		       'mix-vct 'mix-waveform-height 'mix? 'mixer 'mixer*
		       'mixer+ 'mixer-ref 'mixer-set! 'mixer?
		       'mixes 'mouse-click-hook 'mouse-drag-hook 'mouse-enter-graph-hook
		       'mouse-enter-label-hook 'mouse-enter-listener-hook 'mouse-enter-text-hook 'mouse-leave-graph-hook 'mouse-leave-label-hook
		       'mouse-leave-listener-hook 'mouse-leave-text-hook 'mouse-press-hook 'move-locsig 'move-sound 'move-sound? 'multiply-arrays
		       'mus-aifc 'mus-aiff 'mus-alaw 'mus-alsa-buffer-size 'mus-alsa-buffers
		       'mus-alsa-capture-device 'mus-alsa-device 'mus-alsa-playback-device 'mus-alsa-squelch-warning 'mus-apply
		       'mus-array-print-length 'mus-float-equal-fudge-factor 
		       
		       'mus-b24int 'mus-bdouble 'mus-bdouble-unscaled
		       'mus-bfloat 'mus-bfloat-unscaled 'mus-bicsf 'mus-bint 'mus-bintn
		       'mus-bshort 'mus-byte 'mus-bytes-per-sample 'mus-caff 'mus-channel 'mus-channels
		       'mus-chebyshev-first-kind 'mus-chebyshev-second-kind 'mus-clipping 'mus-close
		       'mus-data 'mus-data-format->string 'mus-data-format-name 'mus-describe 'mus-error-hook
		       'mus-error-type->string 'mus-expand-filename 'mus-feedback 'mus-feedforward 'mus-fft
		       'mus-file-buffer-size 'mus-file-clipping 'mus-file-name 'mus-file-prescaler
		       'mus-frequency 'mus-generator? 'mus-header-raw-defaults 'mus-header-type->string 'mus-header-type-name
		       'mus-hop 'mus-increment 'mus-input? 'mus-interp-all-pass 'mus-interp-bezier
		       'mus-interp-hermite 'mus-interp-lagrange 'mus-interp-linear 'mus-interp-none 'mus-interp-sinusoidal
		       'mus-interp-type 'mus-interpolate 'mus-ircam 'mus-l24int 'mus-ldouble
		       'mus-ldouble-unscaled 'mus-length 'mus-lfloat 'mus-lfloat-unscaled 'mus-lint
		       'mus-lintn 'mus-location 'mus-lshort 'mus-max-malloc 'mus-max-table-size
		       'mus-mix 'mus-mulaw 'mus-name 
		       'mus-next 'mus-nist 'mus-offset 'mus-order 'mus-oss-set-buffers
		       'mus-out-format 'mus-output? 'mus-phase 'mus-prescaler 'mus-ramp
		       'mus-rand-seed 'mus-random 'mus-raw 'mus-reset 'mus-riff
		       'mus-run 'mus-scaler 'mus-set-formant-radius-and-frequency 'mus-sound-chans 'mus-sound-close-input
		       'mus-sound-close-output 'mus-sound-comment 'mus-sound-data-format 'mus-sound-data-location 'mus-sound-datum-size
		       'mus-sound-duration 'mus-sound-forget 'mus-sound-frames 'mus-sound-header-type 'mus-sound-length
		       'mus-sound-loop-info 'mus-sound-mark-info 'mus-sound-maxamp 'mus-sound-maxamp-exists? 'mus-sound-open-input 'mus-sound-open-output
		       'mus-sound-prune 'mus-sound-read 'mus-sound-reopen-output 'mus-sound-report-cache 'mus-sound-samples
		       'mus-sound-seek-frame 'mus-sound-srate 'mus-sound-type-specifier 'mus-sound-write 'mus-sound-write-date
		       'mus-soundfont 'mus-srate 'mus-svx 'mus-ubshort
		       'mus-ubyte 'mus-ulshort 'mus-unknown 'mus-unsupported 'mus-voc
		       'mus-width 'mus-xcoeff 'mus-xcoeffs 'mus-ycoeff 'mus-ycoeffs
		       'name-click-hook 'new-sound 'new-sound-dialog 'new-sound-hook 'new-widget-hook
		       'next-sample 'normalize-by-channel 'normalize-by-sound 'normalize-channel 'normalize-globally
		       'notch 'notch? 'one-pole 'one-pole? 'one-zero
		       'one-zero? 'open-file-dialog 'open-file-dialog-directory 'open-hook 'open-raw-sound 'open-raw-sound-hook
		       'open-sound 'optimization 'optimization-hook 
		       'orientation-hook 'oscil 'oscil? 'out-any 'outa
		       'outb 'outc 'outd 'output-comment-hook 'output-name-hook 
		       'override-samples-with-origin 'pad-channel 'partials->polynomial 'partials->wave
		       'parzen-window 'pausing 'peak-env-hook 'peaks 'peaks-font
		       'phase-partials->wave 'phase-vocoder 'phase-vocoder-amp-increments 'phase-vocoder-amps 'phase-vocoder-freqs
		       'phase-vocoder-phase-increments 'phase-vocoder-phases 'phase-vocoder? 'play
		       'play-hook 'player-home 'player? 'players
		       'playing 'poisson-window 'polar->rectangular 'polynomial 'polyshape 'polywave
		       'polyshape? 'polywave? 'position->x 'position->y 'position-color 'preferences-dialog
		       'previous-sample 'print-dialog 'print-hook 'print-length 'progress-report
		       'prompt-in-minibuffer 'ptree-channel 'pulse-train
		       'pulse-train? 'pushed-button-color 'quit-button-color 'radians->degrees 'radians->hz
		       'ramp-channel 'rand 'rand-interp 'rand-interp? 'rand?
		       'read-hook 'read-mix-sample 'read-only 'read-region-sample
		       'read-sample 'readin 'readin? 
		       'rectangular->magnitudes 'rectangular->polar 'rectangular-window 'redo 'redo-edit
		       'region->vct 'region-chans 'region-home 'region-frames 'region-graph-style 'region-maxamp
		       'region-maxamp-position 'region-position 'region-sample 'region-sampler? 'region-srate
		       'region? 'regions 'remove-from-menu 'report-in-minibuffer 'reset-button-color
		       'reset-controls 'reset-listener-cursor 'restore-controls 'restore-region
		       'reverb-control-decay 'reverb-control-feedback 'reverb-control-length 'reverb-control-length-bounds 'reverb-control-lowpass
		       'reverb-control-scale 'reverb-control-scale-bounds 'reverb-control? 'reverse-channel 'reverse-selection
		       'reverse-sound 'revert-sound 'riemann-window 'right-sample 'ring-modulate
		       'run 'rv2-window 'rv3-window 'rv4-window 
		       'samaraki-window 'sample 'sample->file
		       'sample->file? 'sample->frame 'sampler-at-end? 'sampler-home 'sampler-position
		       'sampler? 'samples 'samples->seconds 'sash-color
		       'save-controls 'save-dir 'save-edit-history 'save-envelopes 'save-hook
		       'save-listener 'save-macros 'save-marks 'save-region 'save-region-dialog
		       'save-selection 'save-selection-dialog 'save-sound 'save-sound-as 'save-sound-dialog
		       'save-state 'save-state-file 'save-state-hook 'sawtooth-wave 'sawtooth-wave?
		       'scale-by 'scale-channel 'scale-selection-by 'scale-selection-to 'scale-to
		       'scan-chan 'scan-channel 'script-arg 'script-args 'search-procedure
		       'seconds->samples 'select-all 'select-channel 'select-channel-hook 'select-sound
		       'select-sound-hook 'selected-channel 'selected-data-color 'selected-graph-color 'selected-sound
		       'selection-chans 'selection-color 'selection-context 'selection-creates-region
		       'selection-frames 'selection-maxamp 'selection-maxamp-position 'selection-member? 'selection-position
		       'selection-srate 'selection? 'send-mozilla
		       'short-file-name 'show-all-axes 'show-all-axes-unlabelled 'show-bare-x-axis
		       'show-axes 'show-controls 'show-grid 'show-indices
		       'show-listener 'show-marks 'show-mix-waveforms 'show-no-axes 'show-selection-transform
		       'show-sonogram-cursor 'show-transform-peaks 'show-widget 'show-x-axis 'show-x-axis-unlabelled
		       'show-y-zero 'sinc-width 'nrxysin 'nrxysin? 'nrxycos 'nrxycos?
		       'smooth-channel 'smooth-selection 'smooth-sound 'snd->sample 'snd->sample?
		       'snd-error 'snd-error-hook 'snd-gcs 'snd-help 'snd-font 'snd-color
		       'snd-print 'snd-simulate-keystroke 'snd-spectrum 'snd-tempnam 'snd-url
		       'snd-urls 'snd-version 'snd-warning 'snd-warning-hook 'sound-data->sound-data
		       'sound-data->vct 'sound-data-chans 'sound-data-length 'sound-data-maxamp 'sound-data-ref 'sound-data-peak
		       'sound-data-set! 'sound-data-scale! 'sound-data-fill! 'sound-data? 
		       'sound-data-multiply! 'sound-data-add! 'sound-data-offset! 'sound-data* 'sound-data+ 'sound-data-copy 'sound-data-reverse!
		       'sound-file-extensions 'sound-file? 'sound-files-in-directory
		       'sound-loop-info 'sound-properties 'sound-property 'sound-widgets 'sound? 'soundfont-info
		       'sounds 'spectrum-end 'spectro-hop 'spectrum-start 'spectro-x-angle
		       'spectro-x-scale 'spectro-y-angle 'spectro-y-scale 'spectro-z-angle 'spectro-z-scale
		       'spectrum 'speed-control 'speed-control-as-float 'speed-control-as-ratio 'speed-control-as-semitone
		       'speed-control-bounds 'speed-control-style 'speed-control-tones 'square-wave 'square-wave?
		       'squelch-update 'srate 'src 'src-channel 'src-selection
		       'src-sound 'src? 'ssb-am 'ssb-am? 'start-hook
		       'start-playing 'start-playing-hook 'start-playing-selection-hook 'start-progress-report 'stop-dac-hook
		       'stop-player 'stop-playing 'stop-playing-hook 'stop-playing-selection-hook 'ncos
		       'ncos? 'nsin 'nsin? 'swap-channels 'sync
		       'sync-max 'syncd-marks 'table-lookup 'table-lookup? 'tap
		       'temp-dir 'text-focus-color 'time-graph 'time-graph-hook 'time-graph-style
		       'time-graph-type 'time-graph? 'tiny-font 
		       'tracking-cursor-style 'transform->vct
		       'transform-dialog 'transform-frames 'transform-graph 'transform-graph-style 'transform-graph-type
		       'transform-graph? 'transform-normalization 'transform-sample 'transform-size 'transform-type
		       'transform? 'trap-segfault 'triangle-wave 'triangle-wave? 'tukey-window
		       'two-pole 'two-pole? 'two-zero 'two-zero? 'ultraspherical-window
		       'unbind-key  'undo 'undo-edit 'undo-hook 'update-hook 'update-lisp-graph
		       'update-sound 'update-time-graph 'update-transform-graph 'variable-graph? 'vct
		       'vct* 'vct+ 'vct->channel 'vct->list 'vct->sound-data
		       'vct->string 'vct->vector 'vct-add! 'vct-copy
		       'vct-fill! 'vct-length 'vct-map! 'vct-move!
		       'vct-multiply! 'vct-offset! 'vct-peak 'vct-ref 'vct-reverse!
		       'vct-scale! 'vct-set! 'vct-subseq 'vct-subtract! 'vct?
		       'vector->vct 'view-files-amp 'view-files-amp-env
		       'view-files-dialog 'view-files-files 'view-files-select-hook 'view-files-selected-files 'view-files-sort
		       'view-files-speed 'view-files-speed-style 'view-mixes-dialog 'view-regions-dialog 'view-sound
		       'walsh-transform
		       'wave-train 'wave-train? 'wavelet-transform 'wavelet-type
		       'wavo-hop 'wavo-trace 'welch-window 'widget-position
		       'widget-size 'widget-text 'window-height 'window-property 'window-property-changed-hook
		       'window-width 'window-x 'window-y 'with-background-processes 'with-file-monitor 'with-gl
		       'with-mix-tags 'with-relative-panes 'with-tracking-cursor 'with-verbose-cursor 'with-inset-graph 'with-pointer-focus
		       'x->position 'x-axis-as-clock 'x-axis-as-percentage 'x-axis-in-beats 'x-axis-in-measures
		       'x-axis-in-samples 'x-axis-in-seconds 'x-axis-label 'x-axis-style 'x-bounds
		       'x-position-slider 'x-zoom-slider 'xramp-channel 'y->position 'y-axis-label
		       'y-bounds 'y-position-slider 'y-zoom-slider 'zero-pad 'zoom-color
		       'zoom-focus-active 'zoom-focus-left 'zoom-focus-middle 'zoom-focus-right 'zoom-focus-style)))
      (for-each
       (lambda (n)
	 (if (not (defined? n))
	     (set! undef (cons n undef))))
       names)
      (if (not (null? undef))
	  (snd-display #__line__ ";undefined: ~A" undef)))
    
    ))

;;; ---------------- test 4: sndlib ----------------

(define buffer-menu #f) ; needed by examp.scm

(if (or (not (provided? 'snd-examp.scm))
	(and (defined? 'ramp) ; why this? protection against funcs?
	     (list? ramp)))
    (load "examp.scm"))

(if (not (provided? 'snd-mix.scm)) (load "mix.scm"))
(if (not (provided? 'snd-env.scm)) (load "env.scm"))

(define (play-sound-1 file)
  "play test func"
  (let* ((sound-fd (mus-sound-open-input file))
	 (chans (mus-sound-chans file))
	 (frames (mus-sound-frames file))
	 (bufsize 256)
	 (data (make-sound-data chans bufsize))
	 (bytes (* bufsize chans 2)))
    (mus-sound-read sound-fd 0 (- bufsize 1) chans data)
    (catch #t
	   (lambda ()
	     (let ((audio-fd (mus-audio-open-output 0 (mus-sound-srate file) chans mus-lshort bytes)))
	       (if (= audio-fd -1)
		   (set! audio-fd (mus-audio-open-output 0 (mus-sound-srate file) chans mus-bshort bytes)))
	       (if (= audio-fd -1)
		   (snd-display #__line__ ";can't play ~A" file)
		   (begin
		     (catch #t
			    (lambda ()
			      (do ((i 0 (+ i bufsize)))
				  ((>= i frames))
				(mus-audio-write audio-fd data bufsize)
				(mus-sound-read sound-fd 0 (- bufsize 1) chans data)))
			    (lambda args (snd-display #__line__ ";play-sound-1: can play audio: ~A" args)))
		     (mus-audio-close audio-fd)))))
	   (lambda args (snd-display #__line__ ";play-sound-1: can't open audio: ~A" args)))
    (mus-sound-close-input sound-fd)))

(definstrument (out-samps beg chan data)
  (let ((len (vct-length data)))
    (run
     (do ((i 0 (+ 1 i)))
	 ((= i len))
       (out-any (+ beg i) (vct-ref data i) chan)))))

(definstrument (out-samps-invert beg chan data)
  (let ((len (vct-length data)))
    (run
     (do ((i 0 (+ 1 i)))
	 ((= i len))
       (out-any (+ beg i) (- (vct-ref data i)) chan)))))

(define (snd_test_4)
  
  (define (frame->byte file frame)
    (+ (mus-sound-data-location file)
       (* (mus-sound-chans file)
	  (mus-sound-datum-size file)
	  frame)))
  
  (define (show-input-1 . arg)
    ;; from rtio.scm
    (define (card+device card device)
      (logior (ash card 16) device))
    (let* ((our-short (if (little-endian?) mus-lshort mus-bshort))
	   (our-srate 22050)
	   (our-dac-buffer-size-in-bytes 512)
	   (our-dac-buffer-size-in-shorts 256)
	   (our-chans 1)
	   (our-chan 0)
	   (our-default-card-number 0)
	   (in-sys (if (not (null? arg)) 
		       (car arg) 
		       our-default-card-number))
	   (in-port (catch 'mus-error
			   (lambda ()
			     (mus-audio-open-input 
			      (card+device in-sys 0) 
			      our-srate our-chans our-short our-dac-buffer-size-in-bytes))
			   (lambda args -1)))
	   (data (make-sound-data our-chans our-dac-buffer-size-in-shorts))
	   (vobj (make-vct our-dac-buffer-size-in-shorts)))
      (if (= in-port -1)
	  (snd-display #__line__ ";can't open audio input port!")
	  (begin
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (mus-audio-read in-port data our-dac-buffer-size-in-shorts)
	      (graph (sound-data->vct data our-chan vobj)))
	    (mus-audio-close in-port)))))
  
  (begin
    
    (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests)) 
      (log-mem clmtest)
      (clear-listener)
      (let ((chns (mus-sound-chans "oboe.snd"))
	    (dl (mus-sound-data-location "oboe.snd"))
	    (fr (mus-sound-frames "oboe.snd"))
	    (smps (mus-sound-samples "oboe.snd"))
	    (len (mus-sound-length "oboe.snd"))
	    (size (mus-sound-datum-size "oboe.snd"))
	    (com (mus-sound-comment "oboe.snd"))
	    (sr (mus-sound-srate "oboe.snd"))
	    (m1 (mus-sound-maxamp-exists? "oboe.snd"))
	    (mal (mus-sound-maxamp "oboe.snd"))
	    (mz (mus-sound-maxamp "z.snd"))
	    (bytes (mus-bytes-per-sample (mus-sound-data-format "oboe.snd"))))
	(if (or (not (= (car mz) 0))
		(fneq (cadr mz) 0.0))
	    (snd-display #__line__ ";mus-sound-maxamp z.snd: ~A (~A ~A)" mz (not (= (car mz) 0)) (fneq (cadr mz) 0.0)))
	(let ((formats (list mus-bshort mus-lshort mus-mulaw mus-alaw mus-byte mus-ubyte mus-bfloat mus-lfloat
			     mus-bint mus-lint mus-bintn mus-lintn mus-b24int mus-l24int mus-bdouble mus-ldouble
			     mus-ubshort mus-ulshort mus-bdouble-unscaled mus-ldouble-unscaled mus-bfloat-unscaled 
			     mus-lfloat-unscaled))
	      (sizes (list 2 2 1 1 1 1 4 4 
			   4 4 4 4 3 3 8 8
			   2 2 8 8 4
			   4)))
	  (for-each
	   (lambda (frm siz)
	     (if (not (= (mus-bytes-per-sample frm) siz))
		 (snd-display #__line__ ";mus-bytes-per-sample ~A: ~A" (mus-data-format-name frm) siz)))
	   formats
	   sizes))
	(if (not (string=? (mus-data-format->string mus-bshort) "mus-bshort"))
	    (snd-display #__line__ ";mus-data-format->string: ~A" (mus-data-format->string mus-bshort)))
	(if (not (string=? (mus-header-type->string mus-aifc) "mus-aifc"))
	    (snd-display #__line__ ";mus-header-type->string: ~A" (mus-header-type->string mus-aifc)))
	(mus-sound-report-cache "hiho.tmp")
	(if (defined? 'read-line)
	    (let ((p (open-input-file "hiho.tmp")))
	      (if (not p)
		  (snd-display #__line__ ";mus-sound-report-cache->hiho.tmp failed?")
		  (let ((line (read-line p)))
		    (if (or (not (string? line))
			    (and (not (string=? line "sound table:"))
				 (not (string=? line (string-append "sound table:" (string #\newline))))))
			(snd-display #__line__ ";print-cache 1: ~A?" line))
		    (close-input-port p)
		    (delete-file "hiho.tmp")))))
	(if (< (string-length (mus-audio-describe)) 10)
	    (snd-display #__line__ ";mus-audio-describe: ~A" (mus-audio-describe)))
	(if (not (= chns 1)) (snd-display #__line__ ";oboe: mus-sound-chans ~D?" chns))
	(if (not (= dl 28)) (snd-display #__line__ ";oboe: mus-sound-data-location ~D (~A)?" dl (= dl 28)))
	(if (not (= fr 50828)) (snd-display #__line__ ";oboe: mus-sound-frames ~D?" fr))
	(if (not (= smps 50828)) (snd-display #__line__ ";oboe: mus-sound-samples ~D?" smps))
	(if (not (= len (+ 28 (* 2 50828)))) (snd-display #__line__ ";oboe: mus-sound-length ~D?" len))
	(if (not (= size 2)) (snd-display #__line__ ";oboe: mus-sound-datum-size ~D?" size))
	(if (not (= bytes 2)) (snd-display #__line__ ";oboe: sound-bytes ~D?" bytes))
	(if (not (= sr 22050)) (snd-display #__line__ ";oboe: mus-sound-srate ~D?" sr))
	(if (and m1 (= clmtest 0)) (snd-display #__line__ ";oboe: mus-sound-maxamp-exists before maxamp: ~A" m1))
	(if (not (mus-sound-maxamp-exists? "oboe.snd")) 
	    (snd-display #__line__ ";oboe: not mus-sound-maxamp-exists after maxamp: ~A" (mus-sound-maxamp-exists? "oboe.snd")))
	
	(if (= clmtest 0)
	    (let ((vals (mus-header-raw-defaults)))
	      (if (or (not (list? vals))
		      (not (= (length vals) 3)))
		  (snd-display #__line__ ";mus-header-raw-defaults: ~A" vals)
		  (let ((sr (car vals))
			(chns (cadr vals))
			(frm (caddr vals)))
		    (if (not (= sr 44100)) (snd-display #__line__ ";mus-header-raw-defaults srate: ~A" sr))
		    (if (not (= chns 2)) (snd-display #__line__ ";mus-header-raw-defaults chns: ~A" chns))
		    (if (not (= frm mus-bshort)) (snd-display #__line__ ";mus-header-raw-defaults format: ~A: ~A" frm (mus-data-format-name frm)))))))
	(set! (mus-header-raw-defaults) (list 12345 3 mus-bdouble-unscaled))
	(let ((vals (mus-header-raw-defaults)))
	  (if (or (not (list? vals))
		  (not (= (length vals) 3)))
	      (snd-display #__line__ ";set mus-header-raw-defaults: ~A" vals)
	      (let ((sr (car vals))
		    (chns (cadr vals))
		    (frm (caddr vals)))
		(if (not (= sr 12345)) (snd-display #__line__ ";set mus-header-raw-defaults srate: ~A" sr))
		(if (not (= chns 3)) (snd-display #__line__ ";set mus-header-raw-defaults chns: ~A" chns))
		(if (not (= frm mus-bdouble-unscaled)) (snd-display #__line__ ";set mus-header-raw-defaults format: ~A: ~A" frm (mus-data-format-name frm))))))
	(set! (mus-header-raw-defaults) (list 44100 2 mus-bshort))
	
	(let ((str (strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "oboe.snd")))))
	  (if (not (string=? str "15-Oct 04:34 PDT"))
	      (snd-display #__line__ ";mus-sound-write-date oboe.snd: ~A?" str)))
	(let ((str (strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "pistol.snd")))))
	  (if (not (string-=? str "01-Jul 13:06 PDT"))
	      (snd-display #__line__ ";mus-sound-write-date pistol.snd: ~A?" str)))
	
	(let ((index (open-sound "oboe.snd"))
	      (long-file-name (let ((name "test"))
				(do ((i 0 (+ 1 i)))
				    ((= i 10)) ; 40 is about the limit in Linux (256 char limit here from OS, not Snd)
				  (set! name (string-append name "-test")))
				(string-append name ".snd"))))
	  (if (variable-graph? index) (snd-display #__line__ ";variable-graph thinks anything is a graph..."))
	  (if (player? index) (snd-display #__line__ ";player? thinks anything is a player..."))
	  (if (not (sound? index)) (snd-display #__line__ ";~A is not a sound?" index))
	  (if (sound? #f) (snd-display #__line__ ";sound? #f -> #t?"))
	  (if (sound? #t) (snd-display #__line__ ";sound? #t -> #t?"))
	  (save-sound-as long-file-name index)
	  (close-sound index)
	  (set! index (open-sound long-file-name))
	  (if (not (sound? index)) (snd-display #__line__ ";can't find test...snd"))
	  (if (or (not (>= (string-length (file-name index)) (string-length long-file-name)))
		  (not (>= (string-length (short-file-name index)) (string-length long-file-name))))
	      (snd-display #__line__ ";file-name lengths: ~A ~A ~A"
			   (string-length (file-name index))
			   (string-length (short-file-name index))
			   (string-length long-file-name)))
	  (close-sound index)
	  (mus-sound-forget long-file-name)
	  (delete-file long-file-name))
	
	(let* ((fsnd (string-append sf-dir "forest.aiff")))
	  (if (file-exists? fsnd)
	      (begin
		(system (format #f "cp ~A fmv.snd" fsnd))
		(let ((index (open-sound "fmv.snd")))
		  (if (not (equal? (sound-loop-info index) (mus-sound-loop-info fsnd)))
		      (snd-display #__line__ ";loop-info: ~A ~A" (sound-loop-info index) (mus-sound-loop-info fsnd)))
		  (set! (sound-loop-info index) (list 12000 14000 1 2 3 4))
		  (if (not (equal? (sound-loop-info index) (list 12000 14000 1 2 3 4 1 1)))
		      (snd-display #__line__ ";set loop-info: ~A" (sound-loop-info index)))
		  (save-sound-as "fmv1.snd" index mus-aifc)
		  (close-sound index)
		  (if (not (equal? (mus-sound-loop-info "fmv1.snd") (list 12000 14000 1 2 3 4 1 1)))
		      (snd-display #__line__ ";saved loop-info: ~A" (mus-sound-loop-info "fmv1.snd"))))))
	  (let ((index (open-sound "oboe.snd")))
	    (save-sound-as "fmv.snd" index mus-aifc)
	    (close-sound index))
	  (let ((index (open-sound "fmv.snd")))
	    (if (not (equal? (sound-loop-info index) '()))
		(snd-display #__line__ ";null loop-info: ~A" (sound-loop-info index)))
	    (set! (sound-loop-info index) (list 1200 1400 4 3 2 1))
	    (if (not (equal? (sound-loop-info index) (list 1200 1400 4 3 2 1 1 1)))
		(snd-display #__line__ ";set null loop-info: ~A" (sound-loop-info index)))
	    (save-sound-as "fmv1.snd" :sound index :header-type mus-aifc)
	    (close-sound index)
	    (if (not (equal? (mus-sound-loop-info "fmv1.snd") (list 1200 1400 4 3 2 1 1 1)))
		(snd-display #__line__ ";saved null loop-info: ~A" (mus-sound-loop-info "fmv1.snd"))))
	  (let ((index (open-sound "fmv.snd")))
	    (set! (sound-loop-info) (list 1200 1400 4 3 2 1 1 0))
	    (if (not (equal? (sound-loop-info index) (list 1200 1400 0 0 2 1 1 0)))
		(snd-display #__line__ ";set null loop-info (no mode1): ~A" (sound-loop-info index)))
	    (save-sound-as "fmv1.snd" index mus-aifc)
	    (close-sound index)
	    (if (not (equal? (mus-sound-loop-info "fmv1.snd") (list 1200 1400 0 0 2 1 1 0)))
		(snd-display #__line__ ";saved null loop-info (no mode1): ~A" (mus-sound-loop-info "fmv1.snd")))))
	
	(if com (snd-display #__line__ ";oboe: mus-sound-comment ~A?" com))
	(let ((fsnd (string-append sf-dir "nasahal8.wav")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com 
							    (string-append "ICRD: 1997-02-22" 
									   (string #\newline)
									   "IENG: Paul R. Roger"
									   (string #\newline)
									   "ISFT: Sound Forge 4.0"
									   (string #\newline)))))
		    (snd-display #__line__ ";mus-sound-comment \"nasahal8.wav\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "8svx-8.snd")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "File created by Sound Exchange  ")))
		    (snd-display #__line__ ";mus-sound-comment \"8svx-8.snd\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "sun-16-afsp.snd")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "AFspdate:1981/02/11 23:03:34 UTC")))
		    (snd-display #__line__ ";mus-sound-comment \"sun-16-afsp.snd\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "smp-16.snd")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "Converted using Sox.                                        ")))
		    (snd-display #__line__ ";mus-sound-comment \"smp-16.snd\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "d40130.au")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "1994 Jesus Villena")))
		    (snd-display #__line__ ";mus-sound-comment \"d40130.au\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "wood.maud")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "file written by SOX MAUD-export ")))
		    (snd-display #__line__ ";mus-sound-comment \"wood.maud\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "addf8.sf_mipseb")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) 
			(not (string-=? com "date=\"Feb 11 18:03:34 1981\" info=\"Original recorded at 20 kHz, 15-bit D/A, digitally filtered and resampled\" speaker=\"AMK female\" text=\"Add the sum to the product of these three.\" ")))
		    (snd-display #__line__ ";mus-sound-comment \"addf8.sf_mipseb\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "mary-sun4.sig")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com (string-append "MARY HAD A LITTLE LAMB" (string #\newline)))))
		    (snd-display #__line__ ";mus-sound-comment \"mary-sun4.sig\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "nasahal.pat")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "This patch saved with Sound Forge 3.0.")))
		    (snd-display #__line__ ";mus-sound-comment \"nasahal.pat\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "next-16.snd")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) 
			(not (string-=? com ";Written on Mon 1-Jul-91 at 12:10 PDT  at localhost (NeXT) using Allegro CL and clm of 25-June-91")))
		    (snd-display #__line__ ";mus-sound-comment \"next-16.snd\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "wood16.nsp")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "Created by Snack   ")))
		    (snd-display #__line__ ";mus-sound-comment \"wood16.nsp\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "wood.sdx")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "1994 Jesus Villena")))
		    (snd-display #__line__ ";mus-sound-comment \"wood.sdx\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "clmcom.aif")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com "this is a comment")))
		    (snd-display #__line__ ";mus-sound-comment \"clmcom.aif\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "anno.aif")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) (not (string-=? com (string-append "1994 Jesus Villena" (string #\newline)))))
		    (snd-display #__line__ ";mus-sound-comment \"anno.aif\") -> ~A?" com)))))
	(let ((fsnd (string-append sf-dir "telephone.wav")))
	  (if (file-exists? fsnd)
	      (begin
		(set! com (mus-sound-comment fsnd))
		(if (or (not (string? com)) 
			(not (string-=? com (string-append "sample_byte_format -s2 01"
							   (string #\newline)
							   "channel_count -i 1"
							   (string #\newline)
							   "sample_count -i 36461"
							   (string #\newline)
							   "sample_rate -i 16000"
							   (string #\newline)
							   "sample_n_bytes -i 2"
							   (string #\newline)
							   "sample_sig_bits -i 16"
							   (string #\newline)))))
		    (snd-display #__line__ ";mus-sound-comment \"telephone.wav\") -> ~A?" com)))))
	
	(if (not (string? (mus-sound-comment (string-append sf-dir "traffic.aiff"))))
	    (snd-display #__line__ ";mus-sound-comment traffic: ~A" (mus-sound-comment (string-append sf-dir "traffic.aiff"))))
	
	(if (= clmtest 0)
	    (begin
	      (if (fneq (cadr mal) .14724) (snd-display #__line__ ";oboe: mus-sound-maxamp ~F?" (cadr mal)))
	      (if (not (= (car mal) 24971)) (snd-display #__line__ ";oboe: mus-sound-maxamp at ~D?" (car mal)))))
	(set! (mus-sound-maxamp "oboe.snd") (list 1234 .5))
	(set! mal (mus-sound-maxamp "oboe.snd"))
	(if (fneq (cadr mal) .5) (snd-display #__line__ ";oboe: set! mus-sound-maxamp ~F?" (cadr mal)))
	(if (not (= (car mal) 1234)) (snd-display #__line__ ";oboe: set! mus-sound-maxamp at ~D?" (car mal)))
	(set! mal (mus-sound-maxamp "4.aiff"))
	(if (= clmtest 0)
	    (if (not (feql mal (list 810071 0.245 810071 0.490 810071 0.735 810071 0.980)))
		(snd-display #__line__ ";mus-sound-maxamp 4.aiff: ~A?" mal)))
	(set! (mus-sound-maxamp "4.aiff") (list 12345 .5 54321 .2 0 .1 9999 .01))
	(set! mal (mus-sound-maxamp "4.aiff"))
	(if (not (feql mal (list 12345 .5 54321 .2 0 .1 9999 .01)))
	    (snd-display #__line__ ";set! mus-sound-maxamp 4.aiff: ~A?" mal))
	(let ((var (catch #t (lambda () (set! (mus-sound-maxamp "oboe.snd") (list 1234))) (lambda args args))))
	  (if (not (eq? (car var) 'wrong-type-arg))
	      (snd-display #__line__ ";set! mus-sound-maxamp bad arg: ~A" var)))
	(if (and (not (= (mus-sound-type-specifier "oboe.snd") #x646e732e))  ;little endian reader
		 (not (= (mus-sound-type-specifier "oboe.snd") #x2e736e64))) ;big endian reader
	    (snd-display #__line__ ";oboe: mus-sound-type-specifier: ~X?" (mus-sound-type-specifier "oboe.snd")))
	(if (not (string-=? (strftime "%d-%b-%Y %H:%M" (localtime (file-write-date "oboe.snd"))) "15-Oct-2006 04:34"))
	    (snd-display #__line__ ";oboe: file-write-date: ~A?" (strftime "%d-%b-%Y %H:%M" (localtime (file-write-date "oboe.snd")))))
	(play-sound-1 "oboe.snd")
	(mus-sound-forget "oboe.snd")
	
	(let ((lasth (do ((i 1 (+ 1 i)))
			 ((string-=? (mus-header-type-name i) "unsupported") i))))
	  (if (< lasth 50) (snd-display #__line__ ";header-type[~A] = ~A" lasth (mus-header-type-name lasth))))
	(let ((lasth (do ((i 1 (+ 1 i)))
			 ((string-=? (mus-data-format-name i) "unknown") i))))
	  (if (< lasth 10) (snd-display #__line__ ";data-format[~A] = ~A" lasth (mus-data-format-name lasth))))
	
	(set! (transform-normalization) dont-normalize)
	(if (not (= (transform-normalization) dont-normalize))
	    (snd-display #__line__ ";set-transform-normalization none -> ~A" (transform-normalization)))
	(set! (transform-normalization) normalize-globally)
	(if (not (= (transform-normalization) normalize-globally))
	    (snd-display #__line__ ";set-transform-normalization globally -> ~A" (transform-normalization)))
	(set! (transform-normalization) normalize-by-channel)
	(if (not (= (transform-normalization) normalize-by-channel))
	    (snd-display #__line__ ";set-transform-normalization channel -> ~A" (transform-normalization)))
	
	(let ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "set-samples test" 100)))
	  (set! (samples 10 3) (make-vct 3 .1))
	  (if (not (vequal (channel->vct 0 20 ind 0) (vct 0 0 0 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";1 set samples 0 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (set! (samples 20 3 ind 0) (make-vct 3 .1))
	  (if (not (vequal (channel->vct 10 20 ind 0) (vct .1 .1 .1 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";2 set samples 10 for .1: ~A" (channel->vct 10 20 ind 0)))
	  (set! (samples 30 3 ind 0 #f "a name") (make-vct 3 .1))
	  (if (not (vequal (channel->vct 20 20 ind 0) (vct .1 .1 .1 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";3 set samples 20 for .1: ~A" (channel->vct 20 20 ind 0)))
	  (set! (samples 0 3 ind 0 #f "a name" 0 1) (make-vct 3 .2))
	  (if (not (vequal (channel->vct 0 20 ind 0) (vct .2 .2 .2 0 0 0 0 0 0 0 .1 .1 .1 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";4 set samples 0 at 1 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (if (not (vequal (channel->vct 20 20 ind 0) (make-vct 20 0.0)))
	      (snd-display #__line__ ";5 set samples 20 at 1 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (let ((nd (new-sound "fmv1.snd" :channels 2)))
	    (vct->channel (make-vct 10 .5) 0 10 nd 0)
	    (vct->channel (make-vct 10 .3) 0 10 nd 1)
	    (save-sound-as "fmv1.snd" nd)
	    (close-sound nd))
	  (if (not (file-exists? "fmv1.snd")) (snd-display #__line__ ";fmv1 not saved??"))
	  (set! (samples 0 10 ind 0 #f "another name" 1) "fmv1.snd")
	  (if (not (vequal (channel->vct 0 20 ind 0) (vct .3 .3 .3 .3 .3 .3 .3 .3 .3 .3 .1 .1 .1 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";6 set samples 0 at 1 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (set! (samples 5 6 ind 0 #f "another name 7" 0) "fmv1.snd")
	  (if (not (vequal (channel->vct 0 20 ind 0) (vct .3 .3 .3 .3 .3 .5 .5 .5 .5 .5 .5 .1 .1 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";7 set samples 0 at 1 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (revert-sound ind)
	  (set! (samples 0 10 ind 0 #f "another name 8" 1 0 #f) "fmv1.snd")
	  (if (not (vequal (channel->vct 0 20 ind 0) (vct .3 .3 .3 .3 .3 .3 .3 .3 .3 .3 0 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";8 set samples 0 at 1 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (set! (samples 10 10 ind 0 #f "another name 9" 0 0) "fmv1.snd")
	  (if (not (vequal (channel->vct 0 20 ind 0) (vct 0 0 0 0 0 0 0 0 0 0 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5)))
	      (snd-display #__line__ ";9 set samples 0 at 1 for .1: ~A" (channel->vct 0 20 ind 0)))
	  (set! (samples 20 10) "fmv1.snd")
	  (if (not (vequal (channel->vct 10 20 ind 0) (make-vct 20 .5)))
	      (snd-display #__line__ ";10 set samples 0 at 1 for .1: ~A" (channel->vct 10 20 ind 0)))
	  (revert-sound ind)
	  (set! (samples 0 10 ind 0 #t "another name" 1 0 #f) "fmv1.snd")
	  (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";11 set-samples truncate to ~A" (frames ind 0)))
	  (revert-sound ind)
	  (delete-file "fmv1.snd")
	  
	  ;; now try to confuse it
	  (let ((tag (catch #t 
			    (lambda () (set! (samples 0 10 ind 0) "fmv1.snd"))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-file)) (snd-display #__line__ ";set-samples, no such file: ~A" tag)))
	  (let ((nd (new-sound "fmv1.snd" :channels 1)))
	    (vct->channel (make-vct 10 .5) 0 10 nd 0)
	    (save-sound-as "fmv1.snd" nd)
	    (close-sound nd))
	  (let ((tag (catch #t
			    (lambda () (set! (samples 0 10 ind 0 #f "another name" 1) "fmv1.snd")) ; chan 1 does not exist
			    (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-channel)) (snd-display #__line__ ";set-samples no such channel: ~A" tag)))
	  (let ((tag (catch #t
			    (lambda () (set! (samples 0 10 ind 0 #f "another name" -1) "fmv1.snd"))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-channel)) (snd-display #__line__ ";set-samples no such channel (-1): ~A" tag)))
	  (let ((tag (catch #t
			    (lambda () (set! (samples 0 -10) "fmv1.snd"))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";set-samples (-10): ~A" tag)))
	  (let ((tag (catch #t
			    (lambda () (set! (samples -10 10) "fmv1.snd"))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-sample)) (snd-display #__line__ ";set-samples (beg -10): ~A" tag)))
	  (close-sound ind))
	
	(let ((len 100))
	  (for-each
	   (lambda (type allowed-diff)
	     (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1))
		   (v (make-vct len))
		   (maxdiff 0.0)
		   (maxpos #f))
	       (vct-set! v 0 0.999)
	       (vct-set! v 1 -1.0)
	       (vct-set! v 2 .1)
	       (vct-set! v 3 -.1)
	       (vct-set! v 4 .01)
	       (vct-set! v 5 -.01)
	       (vct-set! v 4 .001)
	       (vct-set! v 5 -.001)
	       (vct-set! v 6 0.0)
	       (do ((i 7 (+ 1 i)))
		   ((= i len))
		 (let ((val (random 1.9999)))
		   (if (or (> val 2.0)
			   (< val 0.0))
		       (snd-display #__line__ ";random 2.0 -> ~A?" val))
		   (vct-set! v i (- 1.0 val))))
	       (vct->channel v 0 len ind 0)
	       (save-sound-as "test1.snd" ind mus-next :data-format type)
	       (close-sound ind)
	       (set! ind (open-sound "test1.snd"))
	       (let ((v1 (channel->vct 0 len ind 0)))
		 (do ((i 0 (+ 1 i)))
		     ((= i len))
		   (let ((diff (abs (- (vct-ref v i) (vct-ref v1 i)))))
		     (if (> diff maxdiff)
			 (begin
			   (set! maxdiff diff)
			   (set! maxpos i)))))
		 (if (> maxdiff allowed-diff)
		     (snd-display #__line__ ";[line 2841] ~A: ~A at ~A (~A ~A)" 
				  (mus-data-format-name type) 
				  maxdiff maxpos 
				  (vct-ref v maxpos) (vct-ref v1 maxpos)))
		 (close-sound ind))))
	   (list mus-bshort   mus-lshort   mus-mulaw   mus-alaw   mus-byte  
		 mus-lfloat   mus-bint     mus-lint    mus-b24int mus-l24int
		 mus-ubshort  mus-ulshort  mus-ubyte   mus-bfloat mus-bdouble 
		 mus-ldouble)
	   (list (expt 2 -15) (expt 2 -15) 0.02 0.02 (expt 2 -7)
		 (expt 2 -23) (expt 2 -23) (expt 2 -23) (expt 2 -23) (expt 2 -23) ; assuming sndlib bits=24 here (if int)
		 (expt 2 -15) (expt 2 -15) (expt 2 -7) (expt 2 -23) (expt 2 -23)
		 (expt 2 -23))))
	
	(let* ((ob (view-sound "oboe.snd"))
	       (samp (sample 1000 ob))
	       (old-comment (mus-sound-comment "oboe.snd"))
	       (str (string-append "written " 
				   (strftime "%a %d-%b-%Y %H:%M %Z" 
					     (localtime (current-time))))))
	  (set! (comment ob) str)
	  (let ((tag (catch #t
			    (lambda ()
			      (save-sound-as "test.snd" ob mus-aifc mus-bdouble))
			    (lambda args (car args)))))
	    (if (eq? tag 'cannot-save) (snd-display #__line__ ";save-sound-as test.snd write trouble")))
	  (set! (filter-control-in-hz) #t)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug))
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (provided? 'snd-debug)
		(if (snd-sound-pointer 12345) (snd-display #__line__ ";snd-sound-pointer #f: ~A" (snd-sound-pointer 12345))))
	    (if (not (= (header-type ab) mus-aifc)) 
		(snd-display #__line__ ";save-as aifc -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-aifc)) 
		(snd-display #__line__ ";saved-as aifc -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";aifc[1000] = ~A?" (sample 1000 ab)))
	    (if (or (not (string? (mus-sound-comment "test.snd")))
		    (not (string-=? (mus-sound-comment "test.snd") str)))
		(snd-display #__line__ ";output-comment: ~A ~A" (mus-sound-comment "test.snd") str))
	    (if (or (not (string? (comment ab)))
		    (not (string-=? (comment ab) str)))
		(snd-display #__line__ ";output-comment (comment): ~A ~A" (comment ab) str))
	    (close-sound ab))
	  (if (not (equal? old-comment (mus-sound-comment "oboe.snd")))
	      (snd-display #__line__ ";set-comment overwrote current ~A ~A" old-comment (mus-sound-comment "oboe.snd")))
	  (set! (filter-control-in-hz) #f)
	  (save-sound-as "test.snd" ob mus-raw)
	  (let ((ab (open-raw-sound "test.snd" 1 22050 mus-bshort)))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-raw)) 
		(snd-display #__line__ ";save-as raw -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-raw)) 
		(snd-display #__line__ ";saved-as raw -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";raw[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-nist mus-bint)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-nist)) 
		(snd-display #__line__ ";save-as nist -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-nist)) 
		(snd-display #__line__ ";saved-as nist -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-bint)) 
		(snd-display #__line__ ";save-as int -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-bint)) 
		(snd-display #__line__ ";saved-as int -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";nist[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (reset-hook! output-comment-hook)
	  (add-hook! output-comment-hook
		     (lambda (str) 
		       (string-append str " [written by me]")))
	  (save-sound-as :file "test.snd" :sound ob :header-type mus-riff :data-format mus-lfloat)
	  (reset-hook! output-comment-hook)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-riff)) 
		(snd-display #__line__ ";save-as riff -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-riff)) 
		(snd-display #__line__ ";saved-as riff -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-lfloat)) 
		(snd-display #__line__ ";save-as float -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-lfloat)) 
		(snd-display #__line__ ";saved-as float -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";riff[1000] = ~A?" (sample 1000 ab)))
	    (if (or (not (string? (comment ab)))
		    (not (string-=? (comment ab) 
				    (string-append "written " 
						   (strftime "%a %d-%b-%Y %H:%M %Z" (localtime (current-time)))
						   " [written by me]"))))
		(snd-display #__line__ ";output-comment-hook: ~A~%(~A)" (comment ab) (mus-sound-comment "test.snd")))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-aiff mus-b24int)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-aiff)) 
		(snd-display #__line__ ";save-as aiff -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-aiff)) 
		(snd-display #__line__ ";saved-as aiff -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-b24int))
		(snd-display #__line__ ";save-as 24-bit -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-b24int))
		(snd-display #__line__ ";saved-as 24-bit -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";aiff[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-ircam mus-mulaw)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-ircam)) 
		(snd-display #__line__ ";save-as ircam -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-ircam)) 
		(snd-display #__line__ ";saved-as ircam -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-mulaw))
		(snd-display #__line__ ";save-as mulaw -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-mulaw))
		(snd-display #__line__ ";saved-as mulaw -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";ircam[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-next mus-alaw)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-next)) 
		(snd-display #__line__ ";save-as next -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-next)) 
		(snd-display #__line__ ";saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-alaw)) 
		(snd-display #__line__ ";save-as alaw -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-alaw)) 
		(snd-display #__line__ ";saved-as alaw -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";next (alaw)[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-next mus-bdouble)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug))
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-next)) 
		(snd-display #__line__ ";save-as dbl next -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (data-format ab) mus-bdouble)) 
		(snd-display #__line__ ";save-as dbl -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";next (dbl)[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-next mus-bshort)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug))
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-next)) 
		(snd-display #__line__ ";save-as next -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-next)) 
		(snd-display #__line__ ";saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-bshort)) 
		(snd-display #__line__ ";save-as short -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-bshort)) 
		(snd-display #__line__ ";saved-as short -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";next (short)[1000] = ~A?" (sample 1000 ab)))
	    (reset-hook! update-hook)
	    (set! (y-bounds ab 0) (list -3.0 3.0))
	    (set! (data-format ab) mus-lshort)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd"))) ; these set!'s can change the index via update-sound
	    (if (not (= (data-format ab) mus-lshort)) (snd-display #__line__ ";set data-format: ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (equal? (y-bounds ab 0) (list -3.0 3.0))) (snd-display #__line__ ";set data format y-bounds: ~A?" (y-bounds ab 0)))
	    (set! (y-bounds ab 0) (list 2.0))
	    (if (not (equal? (y-bounds ab 0) (list -2.0 2.0))) (snd-display #__line__ ";set data format y-bounds 1: ~A?" (y-bounds ab 0)))
	    (set! (y-bounds ab 0) (list -2.0))
	    (if (not (equal? (y-bounds ab 0) (list -2.0 2.0))) (snd-display #__line__ ";set data format y-bounds -2: ~A?" (y-bounds ab 0)))
	    (set! (header-type ab) mus-aifc)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (header-type ab) mus-aifc)) (snd-display #__line__ ";set header-type: ~A?" (mus-header-type-name (header-type ab))))
	    (set! (channels ab) 3)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (channels ab) 3)) (snd-display #__line__ ";set chans: ~A?" (channels ab)))
	    (set! (data-location ab) 1234)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (data-location ab) 1234)) (snd-display #__line__ ";set data-location: ~A?" (data-location ab)))
	    (let ((old-size (data-size ab)))
	      (set! (data-size ab) 1234)
	      (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (data-size ab) 1234)) (snd-display #__line__ ";set data-size: ~A?" (data-size ab)))
	      (set! (data-size ab) old-size))
	    (set! (srate ab) 12345)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (srate ab) 12345)) (snd-display #__line__ ";set srate: ~A?" (srate ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-next mus-bfloat)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (if (not (= (header-type ab) mus-next)) 
		(snd-display #__line__ ";save-as next -> ~A?" (mus-header-type-name (header-type ab))))
	    (if (not (= (mus-sound-header-type "test.snd") mus-next)) 
		(snd-display #__line__ ";saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	    (if (not (= (data-format ab) mus-bfloat)) 
		(snd-display #__line__ ";save-as float -> ~A?" (mus-data-format-name (data-format ab))))
	    (if (not (= (mus-sound-data-format "test.snd") mus-bfloat)) 
		(snd-display #__line__ ";saved-as float -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	    (if (fneq (sample 1000 ab) samp) (snd-display #__line__ ";next (float)[1000] = ~A?" (sample 1000 ab)))
	    (close-sound ab))
	  (save-sound-as "test.snd" ob mus-next mus-bshort)
	  (close-sound ob)
	  (let ((ab (open-sound "test.snd")))
	    (if (and (provided? 'xm) (provided? 'snd-debug)) 
		(XtCallCallbacks (cadr (sound-widgets ab)) XmNactivateCallback (snd-sound-pointer ab)))
	    (set! (data-format) mus-lshort)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (data-format) mus-lshort)) (snd-display #__line__ ";set data-format: ~A?" (mus-data-format-name (data-format))))
	    (set! (header-type) mus-aifc)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (header-type) mus-aifc)) (snd-display #__line__ ";set header-type: ~A?" (mus-header-type-name (header-type))))
	    (set! (channels) 3)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (channels) 3)) (snd-display #__line__ ";set chans: ~A?" (channels)))
	    (set! (data-location) 1234)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (data-location) 1234)) (snd-display #__line__ ";set data-location: ~A?" (data-location)))
	    (set! (srate) 12345)
	    (if (not (equal? ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	    (if (not (= (srate) 12345)) (snd-display #__line__ ";set srate: ~A?" (srate)))
	    (close-sound ab)))
	
	(let ((ind (open-sound "2a.snd")))
	  (save-sound-as "test.snd" :data-format mus-l24int :header-type mus-riff :channel 0)
	  (let ((ind0 (open-sound "test.snd")))
	    (if (not (= (channels ind0) 1)) 
		(snd-display #__line__ ";save-sound-as :channel 0 chans: ~A" (channels ind0)))
	    (if (not (= (data-format ind0) mus-l24int)) 
		(snd-display #__line__ ";save-sound-as :channel 0 data-format: ~A ~A" (data-format ind0) (mus-data-format-name (data-format ind0))))
	    (if (not (= (header-type ind0) mus-riff))
		(snd-display #__line__ ";save-sound-as :channel 0 header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
	    (if (not (= (srate ind0) (srate ind)))
		(snd-display #__line__ ";save-sound-as :channel 0 srates: ~A ~A" (srate ind0) (srate ind)))    
	    (if (not (= (frames ind0) (frames ind 0)))
		(snd-display #__line__ ";save-sound-as :channel 0 frames: ~A ~A" (frames ind0) (frames ind 0)))
	    (if (fneq (maxamp ind0 0) (maxamp ind 0))
		(snd-display #__line__ ";save-sound-as :channel 0 maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 0)))
	    (close-sound ind0))
	  (save-sound-as "test.snd" :data-format mus-bfloat :header-type mus-aifc :channel 1 :srate 12345)
	  (let ((ind0 (open-sound "test.snd")))
	    (if (not (= (channels ind0) 1)) 
		(snd-display #__line__ ";save-sound-as :channel 1 chans: ~A" (channels ind0)))
	    (if (not (= (data-format ind0) mus-bfloat)) 
		(snd-display #__line__ ";save-sound-as :channel 1 data-format: ~A ~A" (data-format ind0) (mus-data-format-name (data-format ind0))))
	    (if (not (= (header-type ind0) mus-aifc))
		(snd-display #__line__ ";save-sound-as :channel 1 header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
	    (if (not (= (srate ind0) 12345))
		(snd-display #__line__ ";save-sound-as :channel 1 srates: ~A ~A" (srate ind0) (srate ind)))    
	    (if (not (= (frames ind0) (frames ind 1)))
		(snd-display #__line__ ";save-sound-as :channel 1 frames: ~A ~A" (frames ind0) (frames ind 1)))
	    (if (fneq (maxamp ind0 0) (maxamp ind 1))
		(snd-display #__line__ ";save-sound-as :channel 1 maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 1)))
	    (close-sound ind0))
	  (save-sound-as "test.snd" :channel 1 :comment "this is a test")
	  (let ((ind0 (open-sound "test.snd")))
	    (if (not (= (channels ind0) 1)) 
		(snd-display #__line__ ";save-sound-as :channel 1 (1) chans: ~A" (channels ind0)))
	    (if (not (= (data-format ind0) (data-format ind)))
		(snd-display #__line__ ";save-sound-as :channel 1 (1) data-format: ~A ~A" (data-format ind0) (mus-data-format-name (data-format ind0))))
	    (if (not (= (header-type ind0) (header-type ind)))
		(snd-display #__line__ ";save-sound-as :channel 1 (1) header-type: ~A ~A" (header-type ind0) (mus-header-type-name (header-type ind0))))
	    (if (not (= (srate ind0) (srate ind)))
		(snd-display #__line__ ";save-sound-as :channel 1 (1) srates: ~A ~A" (srate ind0) (srate ind)))    
	    (if (not (= (frames ind0) (frames ind 1)))
		(snd-display #__line__ ";save-sound-as :channel 1 (1) frames: ~A ~A" (frames ind0) (frames ind 1)))
	    (if (fneq (maxamp ind0 0) (maxamp ind 1))
		(snd-display #__line__ ";save-sound-as :channel 1 (1) maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 1)))
	    (if (not (string=? (comment ind0) "this is a test"))
		(snd-display #__line__ ";save-sound-as :channel 0 (1) comment: ~A" (comment ind0)))
	    (close-sound ind0))
	  (close-sound ind))
	
	(let ((fsnd (string-append sf-dir "t15.aiff")))
	  (if (file-exists? fsnd)
	      (let ((ind (open-sound fsnd)))
		(if (or (fneq (sample 132300 ind 0) .148)
			(fneq (sample 132300 ind 1) .126))
		    (snd-display #__line__ ";aifc sowt trouble: ~A ~A" (sample 132300 ind 0) (sample 132300 ind 1)))
		(close-sound ind))))
	(let ((fsnd (string-append sf-dir "M1F1-float64C-AFsp.aif")))
	  (if (file-exists? fsnd)
	      (let ((ind (open-sound fsnd)))
		(if (or (fneq (sample 8000 ind 0) -0.024)
			(fneq (sample 8000 ind 1) 0.021))
		    (snd-display #__line__ ";aifc fl64 trouble: ~A ~A" (sample 8000 ind 0) (sample 8000 ind 1)))
		(close-sound ind))))
	
	(for-each (lambda (n vals)
		    (let ((val (catch #t (lambda () 
					   (list (mus-sound-chans n)
						 (mus-sound-srate n)
						 (mus-sound-frames n)))
				      (lambda args (car args)))))
		      (if (and (not (equal? val vals))
			       (not (eq? val 'mus-error)))
			  (snd-display #__line__ ";~A: ~A ~A" n val vals))))
		  (list (string-append sf-dir "bad_chans.snd")
			(string-append sf-dir "bad_srate.snd")
			(string-append sf-dir "bad_data_format.snd")
			(string-append sf-dir "bad_chans.aifc")
			(string-append sf-dir "bad_srate.aifc")
			(string-append sf-dir "bad_length.aifc")
			(string-append sf-dir "bad_chans.riff")
			(string-append sf-dir "bad_srate.riff")
			(string-append sf-dir "bad_chans.nist")
			(string-append sf-dir "bad_srate.nist")
			(string-append sf-dir "bad_length.nist"))
		  (list (list 0 22050 0)
			(list 1 0 0)
			(list 1 22050 4411)
			(list 0 22050 0)
			(list 1 0 0)
			(list 1 22050 -10)
			(list 0 22050 0)
			(list 1 0 0)
			(list 0 22050 0)
			(list 1 0 0)
			(list 1 22050 -10)))
	
	(let ((ind (open-sound (string-append "/usr/include/sys/" home-dir "/cl/oboe.snd"))))
	  (if (or (not (sound? ind))
		  (not (string=? (short-file-name ind) "oboe.snd")))
	      (snd-display #__line__ ";open-sound with slashes: ~A ~A" ind (and (sound? ind) (short-file-name ind))))
	  (add-hook! bad-header-hook (lambda (n) #t))
	  (for-each (lambda (n)
		      (begin
			(catch #t (lambda () 
				    (insert-sound n))
			       (lambda args (car args)))
			(catch #t (lambda () 
				    (convolve-with n))
			       (lambda args (car args)))
			(catch #t (lambda () 
				    (mix n))
			       (lambda args (car args)))
			(catch #t (lambda () 
				    (let ((ind (open-sound n)))
				      (if (and (number? ind)
					       (sound? ind))
					  (close-sound ind))))
			       (lambda args (car args)))))
		    (list (string-append sf-dir "bad_chans.snd")
			  (string-append sf-dir "bad_srate.snd")
			  (string-append sf-dir "bad_chans.aifc")
			  (string-append sf-dir "bad_srate.aifc")
			  (string-append sf-dir "bad_length.aifc")
			  (string-append sf-dir "bad_chans.riff")
			  (string-append sf-dir "bad_srate.riff")
			  (string-append sf-dir "bad_chans.nist")
			  (string-append sf-dir "bad_location.nist")
			  (string-append sf-dir "bad_field.nist")
			  (string-append sf-dir "bad_srate.nist")
			  (string-append sf-dir "bad_length.nist")))
	  (close-sound ind))
	
	(map close-sound (sounds))
	
	(let* ((ob (open-sound (string-append "~/baddy/" home-dir "/cl/oboe.snd")))
	       (sd (samples->sound-data))
	       (mx (sound-data-maxamp sd)))
	  (if (not (= (sound-data-length sd) 50828)) (snd-display #__line__ ";oboe->sd: len ~A?" (sound-data-length sd)))
	  (if (fneq (sound-data-ref sd 0 1000) .0328369) (snd-display #__line__ ";oboe->sd[1000]: ~A?" (sound-data-ref sd 0 1000)))
	  (if (not (= (length mx) 1)) (snd-display #__line__ ";sound-data-maxamp oboe.snd: ~A?" mx))
	  (if (not (= (maxamp ob 0) (car mx))) (snd-display #__line__ ";sound-data-maxamp oboe.snd: ~A ~A?" mx (maxamp ob 0)))
	  (if (fneq (sound-data-peak sd) (car mx)) (snd-display #__line__ ";sound-data-peak oboe.snd: ~A ~A" (sound-data-peak sd) mx))
	  
	  (let ((var (catch #t (lambda () (set! (selected-channel) 1)) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-channel))
		(snd-display #__line__ ";set selected-channel bad chan: ~A" var)))
	  (let ((var (catch #t (lambda () (set! (selected-channel 123456) 1)) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-sound))
		(snd-display #__line__ ";set selected-channel bad snd: ~A" var)))
	  (let ((var (catch #t (lambda () (sound-data-ref sd 2 1000)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";sound-data-ref bad chan: ~A" var)))
	  (let ((var (catch #t (lambda () (sound-data-ref sd -1 1000)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";sound-data-ref bad chan -1: ~A" var)))
	  (let ((var (catch #t (lambda () (sound-data-ref sd 0 -1)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";sound-data-ref bad frame: ~A" var)))
	  (let ((var (catch #t (lambda () (sound-data-ref sd 0 10000000)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";sound-data-ref bad frame high: ~A" var)))
	  (let ((var (catch #t (lambda () (sound-data-set! sd 2 1000 1)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";sound-data-set! bad chan: ~A" var)))
	  (let ((var (catch #t (lambda () (sound-data-set! sd 0 10000000 1)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";sound-data-set! bad frame: ~A" var)))
	  (let* ((v (make-vct 3))
		 (var (catch #t (lambda () (vct->sound-data v sd 2)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct->sound-data-set! bad chan: ~A" var)))
	  (close-sound ob))
	(if (selected-sound)
	    (snd-display #__line__ ";selected-sound ~A ~A" (selected-sound) (sounds)))
	
	(if (file-exists? (string-append (or sf-dir "") "a.sf2"))
	    (let ((fil (open-sound (string-append (or sf-dir "") "a.sf2"))))
	      (if fil
		  (let ((loops (and fil (soundfont-info))))
		    (if (or (null? loops)
			    (not (= (caddar loops) 65390))
			    (not (= (cadadr loops) 65490)))
			(snd-display #__line__ ";soundfont-info: ~A?" loops))
		    (close-sound fil)))))
	
	(if (file-exists? "fmv5.snd") (delete-file "fmv5.snd"))
	(set! (print-length) 12)
	(let ((fd (mus-sound-open-output "fmv5.snd" 22050 1 mus-bshort mus-aiff "no comment"))
	      (sdata (make-sound-data 1 100)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 100))
	    (sound-data-set! sdata 0 i (* i .01)))
	  (if (not (string-=? "#<sound-data[chans=1, length=100]:\n    (0.000 0.010 0.020 0.030 0.040 0.050 0.060 0.070 0.080 0.090 0.100 0.110 ...)>"
			      (format #f "~A" sdata)))
	      (snd-display #__line__ ";print sound-data: ~A?" (format #f "~A" sdata)))
	  (let ((edat sdata)
		(edat1 (make-sound-data 1 100))
		(edat2 (make-sound-data 2 100)))
	    (if (not (eq? sdata edat)) (snd-display #__line__ ";sound-data not eq? ~A ~A" sdata edat))
	    (if (not (equal? sdata edat)) (snd-display #__line__ ";sound-data not equal? ~A ~A" sdata edat))
	    (if (equal? sdata edat1) (snd-display #__line__ ";sound-data 1 equal? ~A ~A" sdata edat1))
	    (if (equal? edat2 edat1) (snd-display #__line__ ";sound-data 2 equal? ~A ~A" edat2 edat1))
	    (do ((i 0 (+ 1 i)))
		((= i 100))
	      (set! (sound-data-ref edat1 0 i) (sound-data-ref sdata 0 i)))
	    (if (not (equal? sdata edat1)) (snd-display #__line__ ";sound-data 3 not equal? ~A ~A" sdata edat1)))
	  (let ((v0 (make-vct 100))
		(v1 (make-vct 3)))
	    (sound-data->vct sdata 0 v0) 
	    (if (fneq (vct-ref v0 10) .1) (snd-display #__line__ ";sound-data->vct: ~A?" v0))
	    (sound-data->vct sdata 0 v1) 
	    (if (fneq (vct-ref v1 1) .01) (snd-display #__line__ ";sound-data->(small)vct: ~A?" v1))
	    (vct->sound-data v0 sdata 0) 
	    (if (fneq (sound-data-ref sdata 0 10) .1) (snd-display #__line__ ";vct->sound-data: ~A?" (sound-data-ref sdata 0 10)))
	    (if (fneq (sdata 0 10) .1) (snd-display #__line__ ";vct->sound-data applied: ~A?" (sdata 0 10)))
	    (let ((var (catch #t (lambda () (sound-data->vct sdata 2 v0)) (lambda args args))))
	      (if (not (eq? (car var) 'out-of-range))
		  (snd-display #__line__ ";sound-data->vct bad chan: ~A" var)))
	    (let ((var (catch #t (lambda () (mus-audio-write 1 (make-sound-data 3 3) 123)) (lambda args args))))
	      (if (not (eq? (car var) 'out-of-range))
		  (snd-display #__line__ ";mus-audio-write bad frames: ~A" var))))
	  
	  (let ((v0 (make-vct 10))
		(vx (make-vct 3))
		(sdata2 (make-sound-data 2 10)))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sdata2 0 i 0.1)
	      (sound-data-set! sdata2 1 i 0.2))
	    (sound-data->vct sdata2 0 v0) 
	    (sound-data->vct sdata2 0 vx)
	    (if (fneq (vct-ref v0 1) .1) (snd-display #__line__ ";sound-data->vct[1]: ~A?" v0))
	    (sound-data->vct sdata2 1 v0) 
	    (if (fneq (vct-ref v0 1) .2) (snd-display #__line__ ";sound-data->vct[2]: ~A?" v0))
	    (vct->sound-data v0 sdata2 0) 
	    (if (fneq (sound-data-ref sdata2 0 1) .2) 
		(snd-display #__line__ ";vct->sound-data[2]: ~A?" (sound-data-ref sdata2 0 1)))
	    (vct-fill! v0 .3)
	    (vct->sound-data v0 sdata2 1) 
	    (if (fneq (sound-data-ref sdata2 1 1) .3) 
		(snd-display #__line__ ";vct->sound-data[3]: ~A?" (sound-data-ref sdata2 1 1)))
	    (vct->sound-data vx sdata2 0))
	  (mus-sound-write fd 0 99 1 sdata)
	  (mus-sound-close-output fd (* 100 (mus-bytes-per-sample mus-bshort))) ; bshort chosen at open
	  (set! fd (mus-sound-reopen-output "fmv5.snd" 1 mus-bshort mus-aiff (mus-sound-data-location "fmv5.snd")))
	  (mus-sound-close-output fd (* 100 (mus-bytes-per-sample mus-bshort)))
	  (set! fd (mus-sound-open-input "fmv5.snd"))
	  (mus-sound-read fd 0 99 1 sdata)
	  (if (fneq (sound-data-ref sdata 0 10) .1) (snd-display #__line__ ";mus-sound-write: ~A?" (sound-data-ref sdata 0 10)))
	  (let ((pos (mus-sound-seek-frame fd 20)))
	    (if (not (= pos (ftell fd))) 
		(snd-display #__line__ ";1 mus-sound-seek-frame: ~A ~A?" pos (ftell fd)))
	    (if (not (= pos (frame->byte "fmv5.snd" 20)))
		(snd-display #__line__ ";2 mus-sound-seek-frame(2): ~A ~A?" pos (frame->byte "fmv5.snd" 20))))
	  (mus-sound-read fd 0 10 1 sdata)
	  (if (fneq (sound-data-ref sdata 0 0) .2) (snd-display #__line__ ";2 mus-sound-seek: ~A?" (sound-data-ref sdata 0 0)))
	  (mus-sound-close-input fd))
	
	(let ((sd (make-sound-data 2 10)))
	  (vct->sound-data (make-vct 10 .25) sd 0)  
	  (vct->sound-data (make-vct 10 .5) sd 1)
	  (sound-data-scale! sd 2.0)
	  (if (not (vequal (sound-data->vct sd 0) (make-vct 10 .5)))
	      (snd-display #__line__ ";sound-data-scale! chan 0: ~A" (sound-data->vct sd 0)))
	  (if (not (vequal (sound-data->vct sd 1) (make-vct 10 1.0)))
	      (snd-display #__line__ ";sound-data-scale! chan 1: ~A" (sound-data->vct sd 1))))
	
	(let ((sd (make-sound-data 2 10)))
	  (sound-data-fill! sd 2.0)
	  (if (not (vequal (sound-data->vct sd 0) (make-vct 10 2.0)))
	      (snd-display #__line__ ";sound-data-fill! chan 0: ~A" (sound-data->vct sd 0)))
	  (if (not (vequal (sound-data->vct sd 1) (make-vct 10 2.0)))
	      (snd-display #__line__ ";sound-data-fill! chan 1: ~A" (sound-data->vct sd 1))))
	
	(let ((var (catch #t (lambda () (mus-sound-open-output "fmv.snd" 22050 -1 mus-bshort mus-aiff "no comment")) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";mus-sound-open-output bad chans: ~A" var)))
	(let ((var (catch #t (lambda () (mus-sound-open-output "fmv.snd" 22050 1 -1 mus-aiff "no comment")) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";mus-sound-open-output bad format: ~A" var)))
	(let ((var (catch #t (lambda () (mus-sound-open-output "fmv.snd" 22050 1 mus-bshort -1 "no comment")) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";mus-sound-open-output bad type: ~A" var)))
	
	(let ((var (catch #t (lambda () (mus-sound-reopen-output "fmv.snd" -1 mus-bshort mus-aiff #f)) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";mus-sound-reopen-output bad chans: ~A" var)))
	(let ((var (catch #t (lambda () (mus-sound-reopen-output "fmv.snd" 1 -1 mus-aiff #f)) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";mus-sound-reopen-output bad format: ~A" var)))
	(let ((var (catch #t (lambda () (mus-sound-reopen-output "fmv.snd" 1 mus-bshort -1 #f)) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";mus-sound-reopen-output bad type: ~A" var)))
	
	(let ((sd (make-sound-data 2 10)))
	  (fill! sd 1.0)
	  (if (not (vequal (sound-data->vct sd 0) (make-vct 10 1.0)))
	      (snd-display #__line__ ";fill! sd chan 0: ~A" (sound-data->vct sd 0)))
	  (if (not (vequal (sound-data->vct sd 1) (make-vct 10 1.0)))
	      (snd-display #__line__ ";fill! sd chan 1: ~A" (sound-data->vct sd 1)))
	  (let ((sd1 (copy sd)))
	    (if (not (equal? sd sd1)) (snd-display #__line__ ";copy sd: ~A ~A"))))
	
	(for-each
	 (lambda (file)
	   (let ((tag (catch #t
			     (lambda () (open-sound (string-append sf-dir file)))
			     (lambda args args))))
	     (if (not (eq? (car tag) 'mus-error))
		 (snd-display #__line__ ";open-sound ~A: ~A" file tag))))
	 (list "trunc.snd" "trunc.aiff" "trunc.wav" "trunc.sf" "trunc.voc" "trunc.nist" "bad.wav" 
	       "trunc1.aiff" "badform.aiff"))
	(add-hook! open-raw-sound-hook (lambda (file choice) (list 1 22050 mus-bshort)))
	(let ((ind (open-sound (string-append sf-dir "empty.snd"))))
	  (if (or (not (= (data-format ind) mus-bshort))
		  (not (= (chans ind) 1))
		  (not (= (srate ind) 22050))
		  (not (= (data-location ind) 0))
		  (not (= (frames ind) 0)))
	      (snd-display #__line__ ";open raw: ~A ~A ~A ~A ~A" (data-format ind) (chans ind) (srate ind) (data-location ind) (frames ind)))
	  (reset-hook! open-raw-sound-hook)
	  (close-sound ind))
	
	(let* ((ind (open-sound (string-append "/usr/local/" (getcwd) "/2.snd"))) ; check the "//" path reset case
	       (sd1 (samples->sound-data 12000 10 ind 0))
	       (vc1 (sound-data->vct sd1))
	       (vc2 (samples->vct 12000 10 ind 0))
	       (sd2 (vct->sound-data vc2)))
	  (if (not (equal? vc1 vc2)) (snd-display #__line__ ";samples->sound-data->vct: ~A ~A" vc1 vc2))
	  (if (not (equal? sd1 sd2)) (snd-display #__line__ ";sound-data->vct->sound-data: ~A ~A" sd1 sd2))
	  (scale-by 2.0 ind 0)
	  (set! sd1 (samples->sound-data 12000 10 ind 0 #f 0))
	  (set! vc1 (sound-data->vct sd1))
	  (set! vc2 (samples->vct 12000 10 ind 0 #f 0))
	  (set! sd2 (vct->sound-data vc2))
	  (if (not (equal? vc1 vc2)) (snd-display #__line__ ";edpos samples->sound-data->vct: ~A ~A" vc1 vc2))
	  (if (not (equal? sd1 sd2)) (snd-display #__line__ ";edpos sound-data->vct->sound-data: ~A ~A" sd1 sd2))
	  (set! sd1 (samples->sound-data 12000 10 ind 1))
	  (set! vc1 (sound-data->vct sd1))
	  (set! vc2 (samples->vct 12000 10 ind 1))
	  (set! sd2 (vct->sound-data vc2))
	  (if (not (equal? vc1 vc2)) (snd-display #__line__ ";1 samples->sound-data->vct: ~A ~A" vc1 vc2))
	  (if (not (equal? sd1 sd2)) (snd-display #__line__ ";1 sound-data->vct->sound-data: ~A ~A" sd1 sd2))
	  (scale-by 2.0 ind 1)
	  (set! sd1 (samples->sound-data 12000 10 ind 1))
	  (set! vc1 (sound-data->vct sd1))
	  (set! vc2 (samples->vct 12000 10 ind 1))
	  (set! sd2 (vct->sound-data vc2))
	  (if (not (equal? vc1 vc2)) (snd-display #__line__ ";1 scaled samples->sound-data->vct: ~A ~A" vc1 vc2))
	  (if (not (equal? sd1 sd2)) (snd-display #__line__ ";1 scaled sound-data->vct->sound-data: ~A ~A" sd1 sd2))
	  (close-sound ind))
	
	(let ((sd1 (make-sound-data 1 32))
	      (sd2 (make-sound-data 2 64)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 32))
	    (sound-data-set! sd1 0 i (* .01 i)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 64))
	    (sound-data-set! sd2 0 i (* .1 i))
	    (sound-data-set! sd2 1 i (* .2 i)))
	  (sound-data->sound-data sd2 sd1 3 6 32)
	  (if (fneq (sound-data-ref sd1 0 0) 0.0) (snd-display #__line__ ";sound-data->sound-data 0: ~A" (sound-data-ref sd1 0 0)))
	  (if (fneq (sound-data-ref sd1 0 2) 0.02) (snd-display #__line__ ";sound-data->sound-data 2: ~A" (sound-data-ref sd1 0 2)))
	  (if (fneq (sound-data-ref sd1 0 3) 0.0) (snd-display #__line__ ";sound-data->sound-data 3: ~A" (sound-data-ref sd1 0 3)))
	  (if (fneq (sound-data-ref sd1 0 6) 0.3) (snd-display #__line__ ";sound-data->sound-data 6: ~A" (sound-data-ref sd1 0 6)))
	  (if (fneq (sound-data-ref sd1 0 10) 0.1) (snd-display #__line__ ";sound-data->sound-data 10: ~A" (sound-data-ref sd1 0 10)))
	  (sound-data->sound-data sd1 sd2 0 10 32)
	  (if (fneq (sound-data-ref sd2 0 5) 0.2) (snd-display #__line__ ";sound-data->sound-data 2 5: ~A" (sound-data-ref sd2 0 5))))
	(let ((sdi (make-sound-data 1 32))
	      (sdo (make-sound-data 1 32)))
	  (let ((j (sound-data->sound-data sdi sdo 10 32 10)))
	    (if (not (= j 2)) (snd-display #__line__ ";sound-data->sound-data wrap around 2: ~A" j)))
	  (let ((j (sound-data->sound-data sdi sdo 10 32 32)))
	    (if (not (= j 10)) (snd-display #__line__ ";sound-data->sound-data wrap around 10: ~A" j)))
	  (let ((tag (catch #t
			    (lambda () (sound-data->sound-data sdi sdo -1 10 10))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'out-of-range))
		(snd-display #__line__ ";sound-data->sound-data start: ~A" tag)))
	  (let ((tag (catch #t
			    (lambda () (sound-data->sound-data sdi sdo 0 -1 10))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'out-of-range))
		(snd-display #__line__ ";sound-data->sound-data frames: ~A" tag)))
	  (let ((tag (catch #t
			    (lambda () (sound-data->sound-data sdi sdo 0 128 10))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'out-of-range))
		(snd-display #__line__ ";sound-data->sound-data frames: ~A" tag))))
	
	
	(let ((sd (make-sound-data 1 1)))
	  (if (fneq (sd 0 0) 0.0) (snd-display #__line__ ";sound-data ref: ~A" (sd 0 0)))
	  (set! (sd 0 0) 1.0)
	  (if (fneq (sd 0 0) 1.0) (snd-display #__line__ ";sound-data set: ~A" (sd 0 0)))
	  (if (not (equal? sd (let ((sd1 (make-sound-data 1 1))) (sound-data-set! sd1 0 0 1.0) sd1)))
	      (snd-display #__line__ ";sound-data set not equal: ~A" sd)))
	
	(let ((sd (make-sound-data 2 3)))
	  (if (fneq (sd 0 0) 0.0) (snd-display #__line__ ";sound-data ref (1): ~A" (sd 0 0)))
	  (set! (sd 1 0) 1.0)
	  (if (fneq (sd 1 0) 1.0) (snd-display #__line__ ";sound-data set (1 0): ~A" (sd 1 0)))
	  (set! (sd 1 2) 2.0)
	  (if (fneq (sd 1 2) 2.0) (snd-display #__line__ ";sound-data set (1 2): ~A" (sd 1 2)))
	  (if (not (equal? sd (let ((sd1 (make-sound-data 2 3)))
				(sound-data-set! sd1 1 0 1.0)
				(sound-data-set! sd1 1 2 2.0)
				sd1)))
	      (snd-display #__line__ ";sound-data set (3) not equal: ~A" sd)))
	
	
	(for-each 
	 (lambda (chans)
	   (for-each 
	    (lambda (df-ht)
	      (let ((samps (if (= chans 1) 100000
			       (if (= chans 2) 50000
				   1000))))
		(if (file-exists? "fmv5.snd") (delete-file "fmv5.snd"))
		(let ((fd (mus-sound-open-output "fmv5.snd" 22050 chans (car df-ht) (cadr df-ht) "no comment"))
		      (sdata (make-sound-data chans samps))
		      (ndata (make-sound-data chans samps)))
		  (run 
		   (do ((k 0 (+ 1 k)))
		       ((= k chans))
		     (do ((i 0 (+ 1 i)))
			 ((= i samps))
		       (sound-data-set! sdata k i (- (random 2.0) 1.0)))))
		  (mus-sound-write fd 0 (- samps 1) chans sdata)
		  (mus-sound-close-output fd (* samps chans (mus-bytes-per-sample (car df-ht))))
		  (set! fd (mus-sound-open-input "fmv5.snd"))
		  (mus-sound-read fd 0 (- samps 1) chans ndata)
		  (let ((pos (mus-sound-seek-frame fd 100)))
		    (if (not (= pos (ftell fd))) 
			(snd-display #__line__ ";mus-sound-seek-frame[~A]: chans ~A ~A (~A ~A)?" 
				     pos chans (ftell fd) (mus-header-type-name (cadr df-ht)) (mus-data-format-name (car df-ht))))
		    (if (not (= pos (frame->byte "fmv5.snd" 100))) 
			(snd-display #__line__ ";mus-sound-seek-frame(100): ~A ~A (~A ~A ~A)?" 
				     pos (frame->byte "fmv5.snd" 100) chans (mus-header-type-name (cadr df-ht)) (mus-data-format-name (car df-ht)))))
		  (mus-sound-close-input fd)
		  (let ((v0 0.0)
			(v1 0.0))
		    (catch 'read-write-error
			   (lambda ()
			     (run
			      (do ((k 0 (+ 1 k)))
				  ((= k chans))
				(do ((i 0 (+ 1 i)))
				    ((= i samps))
				  (if (fneq (sound-data-ref sdata k i) (sound-data-ref ndata k i))
				      (begin
					(set! v0 (sound-data-ref sdata k i))
					(set! v1 (sound-data-ref ndata k i))
					;(snd-display #__line__ ";v0: ~A, v1: ~A, diff: ~A, k: ~A, i: ~A" v0 v1 (- v1 v0) k i)
					(throw 'read-write-error)))))))
			   (lambda args 
			     (begin 
			       (snd-display #__line__ ";read-write trouble: ~A ~A (~A != ~A): ~A"
					    (mus-data-format-name (car df-ht))
					    (mus-header-type-name (cadr df-ht))
					    v0 v1 args)
			       (car args))))))))
	    (list (list mus-bshort mus-next)
		  (list mus-bfloat mus-aifc)
		  (list mus-lshort mus-aifc)
		  (list mus-lfloat mus-riff)
		  (list mus-lshort mus-nist)
		  (list mus-bint mus-aiff)
		  (list mus-lint mus-next)
		  (list mus-bintn mus-next)
		  (list mus-lintn mus-next)
		  (list mus-b24int mus-aifc)
		  (list mus-l24int mus-riff)
		  (list mus-bfloat mus-ircam)
		  (list mus-bfloat-unscaled mus-next)
		  (list mus-lfloat-unscaled mus-next)
		  (list mus-bdouble-unscaled mus-next)
		  (list mus-ldouble-unscaled mus-next)
		  (list mus-bdouble mus-next)
		  (list mus-ldouble mus-next)
		  (list mus-ulshort mus-next)
		  (list mus-ubshort mus-next))))
	 (list 1 2 4 8))
	
#|
	;; big sound-data objects (needs 32 Gbytes):
	(if (and (string? (getenv "HOSTNAME"))
		 (string=? (getenv "HOSTNAME") "fatty8"))
	    (let ((size (+ 2 (expt 2 31))))
	      (if (not (= size 2147483650))
		  (snd-display #__line__ ";big sd, size: ~A (~A ~A)" size 2147483650 (- 2147483650 size)))
	      (set! (mus-max-malloc) (expt 2 40))
	      (if (not (= (mus-max-malloc) 1099511627776))
		  (snd-display #__line__ ";big sd, mus-max-malloc: ~A" (mus-max-malloc)))
	      (let ((hi (make-sound-data 1 size)))
		(if (not (sound-data? hi))
		    (snd-display #__line__ ";big sd, not a sound-data?? ~A" hi))
		(if (fneq (sound-data-ref hi 0 (expt 2 31)) 0.0)
		    (snd-display #__line__ ";big sd, created at end: ~A" (sound-data-ref hi 0 (expt 2 31))))
		(if (not (= (sound-data-chans hi) 1))
		    (snd-display #__line__ ";big sd, sound-data-chans: ~A" (sound-data-chans hi)))
		(sound-data+ hi .1)
		(if (fneq (sound-data-ref hi 0 (expt 2 31)) 0.1)
		    (snd-display #__line__ ";big sd, add .1 at end: ~A" (sound-data-ref hi 0 (expt 2 31))))
		(let ((pk (sound-data-peak hi)))
		  (if (fneq pk .1)
		      (snd-display #__line__ ";big sd, sound-data-peak: ~A" pk)))
		(let ((len (sound-data-length hi)))
		  (if (not (= len size))
		      (snd-display #__line__ ";big sd, len: ~A" len)))
		(sound-data-scale! hi 2.0)
		(if (fneq (sound-data-ref hi 0 (+ 1 (expt 2 31))) .2)
		    (snd-display #__line__ ";big sd, scale: ~A ~A" (sound-data-ref hi 0 (+ 1 (expt 2 31))) hi))
		(sound-data-set! hi 0 (expt 2 31) 1.0)
		(if (fneq (sound-data-ref hi 0 (expt 2 31)) 1.0)
		    (snd-display #__line__ ";big sd, set at end: ~A" (sound-data-ref hi 0 (expt 2 31))))
		(sound-data-offset! hi .2)
		(if (fneq (sound-data-ref hi 0 (expt 2 31)) 1.2)
		    (snd-display #__line__ ";big sd, offset: ~A" (sound-data-ref hi 0 (expt 2 31))))
		(let ((pk (sound-data-maxamp hi)))
		  (if (fneq (car pk) 1.2)
		      (snd-display #__line__ ";big sd, subtract sound-data-maxamp: ~A ~A" pk hi)))
		(let ((pk (sound-data-peak hi)))
		  (if (fneq pk 1.2)
		      (snd-display #__line__ ";big sd, sound-data-peak: ~A ~A" pk hi)))
		(sound-data-fill! hi 1.0)
		(if (fneq (sound-data-ref hi 0 (expt 2 31)) 1.0)
		    (snd-display #__line__ ";big sd, fill: ~A ~A" (sound-data-ref hi 0 (expt 2 31)) hi))
		(sound-data-reverse! hi)
		(let ((v (sound-data->vct hi 0)))
		  (if (not (= (vct-length v) size))
		      (snd-display #__line__ ";big sd, sound-data->vct length: ~A" (vct-length v)))
		  (if (fneq (vct-ref v (expt 2 31)) 1.0)
		      (snd-display #__line__ ";big sd, sd->v ref: ~A" (vct-ref v (expt 2 31)))))
		)))
|#
	
	(let ((ind (open-sound (string-append "/usr//usr/include/" home-dir "/cl/oboe.snd"))))
	  (show-input-1)
	  (close-sound ind))
	
	(let ((fd (mus-sound-open-output "fmv.snd" 22050 1 mus-bshort mus-next "no comment"))
	      (sdata (make-sound-data 1 10)))
	  (define (sound-data-channel->list sd chan)
	    (let ((ls '()))
	      (do ((i (- (sound-data-length sd) 1) (- i 1)))
		  ((< i 0) ls)
		(set! ls (cons (sound-data-ref sd chan i) ls)))))
	  (define (sound-data->list sd)
	    (let ((lst '()))
	      (do ((i (- (sound-data-chans sd) 1) (- i 1)))
		  ((< i 0) lst)
		(set! lst (cons (sound-data-channel->list sd i) lst)))))
	  (sound-data-set! sdata 0 1 .1)
	  (mus-sound-write fd 0 9 1 sdata)
	  (mus-sound-close-output fd 20)
	  (set! fd (mus-sound-open-input "fmv.snd"))
	  (mus-sound-read fd 0 9 1 sdata)
	  (if (or (fneq (sound-data-ref sdata 0 0) 0.0)
		  (fneq (sound-data-ref sdata 0 1) 0.1)
		  (fneq (sound-data-ref sdata 0 2) 0.0)
		  (fneq (sound-data-ref sdata 0 6) 0.0))
	      (snd-display #__line__ ";read/write: ~A?" (sound-data->list sdata)))
	  (mus-sound-close-input fd)  
	  (set! fd (mus-sound-reopen-output "fmv.snd" 1 mus-bshort mus-next (mus-sound-data-location "fmv.snd")))
	  (mus-sound-seek-frame fd 0)
	  (sound-data-set! sdata 0 2 .1)
	  (sound-data-set! sdata 0 3 .1)
	  (mus-sound-write fd 0 9 1 sdata)
	  (mus-sound-close-output fd 20)
	  (set! fd (mus-sound-open-input "fmv.snd"))
	  (let ((sdata1 (make-sound-data 1 10)))
	    (mus-sound-read fd 0 9 1 sdata1)
	    (if (or (fneq (sound-data-ref sdata1 0 0) 0.0)
		    (fneq (sound-data-ref sdata1 0 1) 0.1)
		    (fneq (sound-data-ref sdata1 0 2) 0.1)
		    (fneq (sound-data-ref sdata1 0 3) 0.1)
		    (fneq (sound-data-ref sdata1 0 6) 0.0))
		(snd-display #__line__ ";re-read/write: ~A ~A?" (sound-data->list sdata1) (sound-data->lisp sdata))))
	  (mus-sound-close-input fd)
	  
	  ;; check clipping choices
	  (let ((ind (view-sound "oboe.snd")))
	    (set! (clipping) #f)
	    (map-channel (lambda (y) (* y 10.0)) 0 (frames) ind 0)
	    (save-sound-as "test.snd" ind mus-next mus-bfloat)
	    (undo 1 ind 0)
	    (let ((ind1 (open-sound "test.snd")))
	      (if (fneq (maxamp ind1 0) (* 10 (maxamp ind 0)))
		  (snd-display #__line__ ";clipping 0: ~A ~A" (maxamp ind1 0) (maxamp ind 0)))
	      (close-sound ind1))
	    (delete-file "test.snd")
	    (set! (clipping) #t)
	    (map-channel (lambda (y) (* y 10.0)) 0 (frames) ind 0)
	    (save-sound-as "test.snd" ind mus-next mus-bfloat)
	    (undo 1 ind 0)
	    (let ((ind1 (open-sound "test.snd")))
	      (if (fneq (maxamp ind1 0) 1.0)
		  (snd-display #__line__ ";clipping 1: ~A ~A" (maxamp ind1 0) (maxamp ind 0)))
	      (close-sound ind1))
	    (delete-file "test.snd")
	    (set! (clipping) #f)
	    (let ((mx (maxamp ind)))
	      (map-channel (lambda (y) (+ y (- 1.001 mx))) 0 (frames) ind 0)
	      (save-sound-as "test.snd" ind mus-next mus-bshort)
	      (let* ((ind1 (open-sound "test.snd"))
		     (baddy (scan-channel (lambda (y) (< y 0.0)))))
		(if (not (list-p baddy))
		    (snd-display #__line__ ";clipping 2: ~A" baddy))
		(close-sound ind1))
	      (delete-file "test.snd")
	      (set! (clipping) #t)
	      (save-sound-as "test.snd" ind mus-next mus-bshort)
	      (let* ((ind1 (open-sound "test.snd"))
		     (baddy (scan-channel (lambda (y) (< y 0.0)))))
		(if (list-p baddy)
		    (snd-display #__line__ ";clipping 3: ~A" baddy))
		(close-sound ind1))
	      (delete-file "test.snd")
	      (set! (clipping) #f))
	    (close-sound ind))
	  (delete-file "fmv.snd")
	  
	  (set! (clipping) #f)
	  (let ((snd (new-sound "test.snd" :data-format mus-lshort)))
	    (pad-channel 0 10)
	    (set! (sample 1) 1.0)
	    (set! (sample 2) -1.0)
	    (set! (sample 3) 0.9999)
	    (set! (sample 4) 2.0)
	    (set! (sample 5) -2.0)
	    (set! (sample 6) 1.3)
	    (set! (sample 7) -1.3)
	    (set! (sample 8) 1.8)
	    (set! (sample 9) -1.8)
	    (save-sound snd)
	    (close-sound snd))
	  (let ((snd (open-sound "test.snd")))
	    (let ((data (channel->vct 0 10)))
	      (if (not (vequal data (vct 0.000 1.000 -1.000 1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000)))
		  (snd-display #__line__ ";unclipped 1: ~A" data)))
	    (close-sound snd))
	  (mus-sound-forget "test.snd")
	  
	  (set! (clipping) #t)
	  (let ((snd (new-sound "test.snd" :data-format mus-lshort)))
	    (pad-channel 0 10)
	    (set! (sample 1) 1.0)
	    (set! (sample 2) -1.0)
	    (set! (sample 3) 0.9999)
	    (set! (sample 4) 2.0)
	    (set! (sample 5) -2.0)
	    (set! (sample 6) 1.3)
	    (set! (sample 7) -1.3)
	    (set! (sample 8) 1.8)
	    (set! (sample 9) -1.8)
	    (save-sound snd)
	    (close-sound snd))
	  (let ((snd (open-sound "test.snd")))
	    (let ((data (channel->vct 0 10)))
	      (if (not (vequal data (vct 0.000 1.000 -1.000 1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000)))
		  (snd-display #__line__ ";clipped: ~A" data)))
	    (close-sound snd))
	  
	  (let* ((data (vct 0.0 1.0 -1.0 0.9999 2.0 -2.0 1.3 -1.3 1.8 -1.8))
		 (sdata (vct->sound-data data))
		 (snd (mus-sound-open-output "test.snd" 22050 1 mus-lshort mus-riff "a comment")))
	    (set! (mus-file-clipping snd) #f)
	    (mus-sound-write snd 0 9 1 sdata)
	    (mus-sound-close-output snd 40))
	  
	  (let ((snd (open-sound "test.snd")))
	    (let ((data (channel->vct 0 10)))
	      (if (not (vequal data (vct 0.000 -1.000 -1.000 1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000)))
		  (snd-display #__line__ ";unclipped 2: ~A" data)))
	    (close-sound snd))
	  (mus-sound-forget "test.snd")
	  
	  (let* ((data (vct 0.0 1.0 -1.0 0.9999 2.0 -2.0 1.3 -1.3 1.8 -1.8))
		 (sdata (vct->sound-data data))
		 (snd (mus-sound-open-output "test.snd" 22050 1 mus-lshort mus-riff "a comment")))
	    (set! (mus-file-clipping snd) #t)
	    (mus-sound-write snd 0 9 1 sdata)
	    (set! (mus-file-clipping snd) #f)
	    (mus-sound-close-output snd 40))
	  
	  (let ((snd (open-sound "test.snd")))
	    (let ((data (channel->vct 0 10)))
	      (if (not (vequal data (vct 0.000 1.000 -1.000 1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000)))
		  (snd-display #__line__ ";clipped 1: ~A" data)))
	    (close-sound snd))
	  
	  (set! (mus-clipping) #f)
	  (let* ((data (vct 0.0 1.0 -1.0 0.9999 2.0 -2.0 1.3 -1.3 1.8 -1.8))
		 (sdata (vct->sound-data data))
		 (snd (mus-sound-open-output "test.snd" 22050 1 mus-lshort mus-riff "a comment")))
	    (mus-sound-write snd 0 9 1 sdata)
	    (mus-sound-close-output snd 40))
	  
	  (let ((snd (open-sound "test.snd")))
	    (let ((data (channel->vct 0 10)))
	      (if (not (vequal data (vct 0.000 -1.000 -1.000 1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000)))
		  (snd-display #__line__ ";unclipped 3: ~A" data)))
	    (close-sound snd))
	  (mus-sound-forget "test.snd")
	  
	  (set! (mus-clipping) #t)
	  (let* ((data (vct 0.0 1.0 -1.0 0.9999 2.0 -2.0 1.3 -1.3 1.8 -1.8))
		 (sdata (vct->sound-data data))
		 (snd (mus-sound-open-output "test.snd" 22050 1 mus-lshort mus-riff "a comment")))
	    (mus-sound-write snd 0 9 1 sdata)
	    (mus-sound-close-output snd 40))
	  
	  (let ((snd (open-sound "test.snd")))
	    (let ((data (channel->vct 0 10)))
	      (if (not (vequal data (vct 0.000 1.000 -1.000 1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000)))
		  (snd-display #__line__ ";clipped 2: ~A" data)))
	    (close-sound snd))
	  
	  (set! (mus-clipping) #t)
	  (let* ((data (vct 0.0 1.0 -1.0 0.9999 2.0 -2.0 1.3 -1.3 1.8 -1.8))
		 (sdata (vct->sound-data data))
		 (snd (mus-sound-open-output "test.snd" 22050 1 mus-lshort mus-riff "a comment")))
	    (let ((tag (catch #t
			      (lambda () (mus-sound-write snd 0 10 1 sdata))
			      (lambda args args))))
	      (if (or (not (list? tag)) (not (eq? (car tag) 'out-of-range))) (snd-display #__line__ ";mus-sound-write too many bytes: ~A" tag)))
	    (let ((tag (catch #t
			      (lambda () (mus-sound-read snd 0 10 1 sdata))
			      (lambda args args))))
	      (if (or (not (list? tag)) (not (eq? (car tag) 'out-of-range))) (snd-display #__line__ ";mus-sound-read too many bytes: ~A" tag)))
	    (mus-sound-close-output snd 0))
	  (delete-file "test.snd")
	  (mus-sound-forget "test.snd")
	  
	  (set! (mus-clipping) #f) ; this is the default
	  (set! (clipping) #f)
	  
	  (let ((com "this is a comment which we'll repeat enough times to trigger an internal loop"))
	    (do ((i 0 (+ 1 i)))
		((= i 3))
	      (set! com (string-append com com)))
	    (set! fd (mus-sound-open-output "fmv.snd" 22050 4 mus-lshort mus-riff com)))
	  (set! sdata (make-sound-data 4 10))
	  (do ((i 0 (+ 1 i)))
	      ((= i 4))
	    (sound-data-set! sdata i 1 .1))
	  (mus-sound-write fd 0 9 4 sdata)
	  (mus-sound-close-output fd 80)
	  (set! fd (mus-sound-open-input "fmv.snd"))
	  (mus-sound-read fd 0 9 4 sdata)
	  (do ((i 0 (+ 1 i)))
	      ((= i 4))
	    (if (or (fneq (sound-data-ref sdata i 0) 0.0)
		    (fneq (sound-data-ref sdata i 1) 0.1)
		    (fneq (sound-data-ref sdata i 2) 0.0)
		    (fneq (sound-data-ref sdata i 6) 0.0))
		(snd-display #__line__ ";1 read/write[~A]: ~A?" i (sound-data-channel->list sdata i))))
	  (mus-sound-close-input fd)  
	  (set! fd (mus-sound-reopen-output "fmv.snd" 4 mus-lshort mus-riff (mus-sound-data-location "fmv.snd")))
	  (mus-sound-seek-frame fd 0)
	  (do ((i 0 (+ 1 i)))
	      ((= i 4))
	    (sound-data-set! sdata i 2 .1)
	    (sound-data-set! sdata i 3 .1))
	  (mus-sound-write fd 0 9 4 sdata)
	  (mus-sound-close-output fd 80)
	  (set! fd (mus-sound-open-input "fmv.snd"))
	  (let ((sdata1 (make-sound-data 4 10)))
	    (mus-sound-read fd 0 9 4 sdata1)
	    (do ((i 0 (+ 1 i)))
		((= i 4))
	      (if (or (fneq (sound-data-ref sdata1 i 0) 0.0)
		      (fneq (sound-data-ref sdata1 i 1) 0.1)
		      (fneq (sound-data-ref sdata1 i 2) 0.1)
		      (fneq (sound-data-ref sdata1 i 3) 0.1)
		      (fneq (sound-data-ref sdata1 i 6) 0.0))
		  (snd-display #__line__ ";2 re-read/write[~A]: ~A ~A?" i (sound-data-channel->list sdata1 i) (sound-data-channel->list sdata i)))))
	  (mus-sound-close-input fd))
	
	(if (file-exists? (string-append sf-dir "32bit.sf"))
	    (let ((ind (open-sound (string-append sf-dir "32bit.sf"))))
	      (if (fneq (maxamp ind 0) .228) (snd-display #__line__ ";32bit max: ~A" (maxamp ind 0)))
	      (close-sound ind)))
	
	(let ((test-data (lambda (file beg dur data)
			   (catch #t
				  (lambda ()
				    (let* ((ind (open-sound file))
					   (ndata (samples->vct beg dur ind 0)))
				      (if (not (vequal data ndata))
					  (snd-display #__line__ ";~A: ~A != ~A" file data ndata))
				      (close-sound ind)))
				  (lambda args args)))))
	  (test-data (string-append sf-dir "next-dbl.snd") 10 10 (vct 0.475 0.491 0.499 0.499 0.492 0.476 0.453 0.423 0.387 0.344))
	  (test-data (string-append sf-dir "oboe.ldbl") 1000 10 (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004))
	  
	  (test-data (string-append sf-dir "next-flt.snd") 10 10 (vct 0.475 0.491 0.499 0.499 0.492 0.476 0.453 0.423 0.387 0.344))
	  (test-data (string-append sf-dir "clbonef.wav") 1000 10 (vct 0.111 0.101 0.070 0.032 -0.014 -0.060 -0.085 -0.108 -0.129 -0.152))
	  
	  (test-data (string-append sf-dir "next-8.snd") 10 10 (vct 0.898 0.945 0.977 0.992 0.992 0.977 0.945 0.906 0.844 0.773))
	  (test-data (string-append sf-dir "o2_u8.wave") 1000 10 (vct -0.164 -0.219 -0.258 -0.242 -0.180 -0.102 -0.047 0.000 0.039 0.055))
	  
	  (test-data (string-append sf-dir "next-16.snd") 1000 10 (vct -0.026 -0.022 -0.024 -0.030 -0.041 -0.048 -0.050 -0.055 -0.048 -0.033))
	  (test-data (string-append sf-dir "o2.wave") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  
	  (test-data (string-append sf-dir "o2_18bit.aiff") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  (test-data (string-append sf-dir "o2_12bit.aiff") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  
	  (test-data (string-append sf-dir "next24.snd") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  (test-data (string-append sf-dir "mono24.wav") 1000 10 (vct 0.005 0.010 0.016 0.008 -0.007 -0.018 -0.025 -0.021 -0.005 0.001))
	  
	  (test-data (string-append sf-dir "o2_711u.wave") 1000 10 (vct -0.164 -0.219 -0.254 -0.242 -0.172 -0.103 -0.042 0.005 0.042 0.060))
	  (test-data (string-append sf-dir "alaw.wav") 1000 10 (vct -0.024 -0.048 -0.024 0.000 0.008 0.008 0.000 -0.040 -0.064 -0.024))
	  
	  ;; it is not a bug if these don't match if MUS_SAMPLE_BITS is not 24
	  (test-data (string-append sf-dir "b32.pvf") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  (test-data (string-append sf-dir "b32.wave") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  (test-data (string-append sf-dir "b32.snd") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  (test-data (string-append sf-dir "32bit.sf") 1000 10 (vct 0.016 0.014 0.013 0.011 0.010 0.010 0.010 0.010 0.012 0.014))
	  
	  (test-data (string-append sf-dir "nist-shortpack.wav") 10000 10 (vct 0.021 0.018 0.014 0.009 0.004 -0.001 -0.004 -0.006 -0.007 -0.008))
	  (test-data (string-append sf-dir "wood.sds") 1000 10 (vct -0.160 -0.216 -0.254 -0.239 -0.175 -0.102 -0.042 0.005 0.041 0.059))
	  (test-data (string-append sf-dir "oboe.g721") 1000 10 (vct -0.037 -0.040 -0.040 -0.041 -0.042 -0.038 -0.028 -0.015 -0.005 0.002))
	  (test-data (string-append sf-dir "oboe.g723_40") 1000 10 (vct -0.037 -0.040 -0.041 -0.041 -0.041 -0.038 -0.028 -0.015 -0.005 0.003))
	  (test-data (string-append sf-dir "mus10.snd") 10000 10 (vct 0.004 0.001 0.005 0.009 0.017 0.015 0.008 0.011 0.009 0.012))
	  (test-data (string-append sf-dir "ieee-text-16.snd") 1000 10 (vct -0.052 -0.056 -0.069 -0.077 -0.065 -0.049 -0.054 -0.062 -0.066 -0.074))
	  (test-data (string-append sf-dir "hcom-16.snd") 10000 10 (vct 0.000 0.000 0.000 0.008 0.000 -0.016 -0.016 -0.016 -0.008 0.000))
	  (test-data (string-append sf-dir "ce-c3.w02") 1000 10 (vct 0.581 0.598 0.596 0.577 0.552 0.530 0.508 0.479 0.449 0.425))
	  (test-data (string-append sf-dir "nasahal.avi") 20000 10 (vct 0.390 0.120 -0.399 -0.131 0.464 0.189 -0.458 -0.150 0.593 0.439))
	  (test-data (string-append sf-dir "oki.wav") 100 10 (vct 0.396 0.564 0.677 0.779 0.761 0.540 0.209 -0.100 -0.301 -0.265))
	  
	  (test-data (string-append sf-dir "trumps22.adp") 5000 10 (vct 0.267 0.278 0.309 0.360 0.383 0.414 0.464 0.475 0.486 0.495))
	  )
	
	(let ((errs (list "no error" "no frequency method" "no phase method" "null gen arg to method" "no length method"
			  "no free method" "no describe method" "no data method" "no scaler method"
			  "memory allocation failed" "unstable two pole error"
			  "can't open file" "no sample input" "no sample output"
			  "no such channel" "no file name provided" "no location method" "no channel method"
			  "no such fft window" "unsupported data format" "header read failed"
			  "unsupported header type" "file descriptors not initialized" "not a sound file" "file closed" "write error"
			  "header write failed" "can't open temp file" "interrupted" "bad envelope"
			  "audio channels not available" "audio srate not available" "audio format not available"
			  "no audio input available" "audio configuration not available" 
			  "audio write error" "audio size not available" "audio device not available"
			  "can't close audio" "can't open audio" "audio read error"
			  "can't write audio" "can't read audio" "no audio read permission" 
			  "can't close file" "arg out of range" "wrong type arg"
			  "no channels method" "no hop method" "no width method" "no file-name method" "no ramp method" "no run method"
			  "no increment method" "no offset method"
			  "no xcoeff method" "no ycoeff method" "no xcoeffs method" "no ycoeffs method" "no reset" "bad size" "can't convert"
			  "read error" "no safety method"
			  "can't translate"
			  )))
	  (let ((happy #t)
		(len (length errs)))
	    (do ((i 0 (+ 1 i)))
		((or (not happy) (= i len)))
	      (if (not (string-=? (list-ref errs i) (mus-error-type->string i)))
		  (begin
		    (snd-display #__line__ ";mus-error-type->string ~D: ~A ~A" i (list-ref errs i) (mus-error-type->string i))
		    (set! happy #f))))))
	
					;	  (let ((new-id (mus-make-error "hiho all messed up")))
					;	    (if (not (string=? (mus-error-type->string new-id) "hiho all messed up"))
					;		(snd-display #__line__ ";mus-make-error :~A ~A" new-id (mus-error-type->string new-id))))
	
	(let ((cur-srate (mus-sound-srate "oboe.snd"))
	      (cur-chans (mus-sound-chans "oboe.snd"))
	      (cur-format (mus-sound-data-format "oboe.snd"))
	      (cur-type (mus-sound-header-type "oboe.snd"))
	      (cur-loc (mus-sound-data-location "oboe.snd"))
	      (cur-samps (mus-sound-samples "oboe.snd")))
	  (set! (mus-sound-srate "oboe.snd") (* cur-srate 2))
	  (if (not (= (* cur-srate 2) (mus-sound-srate "oboe.snd"))) 
	      (snd-display #__line__ ";set mus-sound-srate: ~A -> ~A" cur-srate (mus-sound-srate "oboe.snd")))
	  (set! (mus-sound-samples "oboe.snd") (* cur-samps 2))
	  (if (not (= (* cur-samps 2) (mus-sound-samples "oboe.snd"))) 
	      (snd-display #__line__ ";set mus-sound-samples: ~A -> ~A" cur-samps (mus-sound-samples "oboe.snd")))
	  (set! (mus-sound-chans "oboe.snd") (* cur-chans 2))
	  (if (not (= (* cur-chans 2) (mus-sound-chans "oboe.snd"))) 
	      (snd-display #__line__ ";set mus-sound-chans: ~A -> ~A" cur-chans (mus-sound-chans "oboe.snd")))
	  (set! (mus-sound-data-location "oboe.snd") (* cur-loc 2))
	  (if (not (= (* cur-loc 2) (mus-sound-data-location "oboe.snd"))) 
	      (snd-display #__line__ ";set mus-sound-data-location: ~A -> ~A" cur-loc (mus-sound-data-location "oboe.snd")))
	  (set! (mus-sound-header-type "oboe.snd") mus-nist)
	  (if (not (= mus-nist (mus-sound-header-type "oboe.snd"))) 
	      (snd-display #__line__ ";set mus-sound-header-type: ~A -> ~A" cur-type (mus-sound-header-type "oboe.snd")))
	  (set! (mus-sound-data-format "oboe.snd") mus-lintn)
	  (if (not (= mus-lintn (mus-sound-data-format "oboe.snd"))) 
	      (snd-display #__line__ ";set mus-sound-data-format: ~A -> ~A" cur-format (mus-sound-data-format "oboe.snd")))
	  (set! (mus-sound-srate "oboe.snd") cur-srate)
	  (set! (mus-sound-samples "oboe.snd") cur-samps)
	  (set! (mus-sound-chans "oboe.snd") cur-chans)
	  (set! (mus-sound-data-location "oboe.snd") cur-loc)
	  (set! (mus-sound-header-type "oboe.snd") cur-type)
	  (set! (mus-sound-data-format "oboe.snd") cur-format))
	
	(let ((ind (open-sound "oboe.snd")))
	  (save-sound-as "test.wave" ind mus-riff)
	  (save-sound-as "test.rf64" ind mus-rf64)
	  (save-sound-as "test.aifc" ind mus-aifc)
	  (close-sound ind)
	  
	  (for-each
	   (lambda (file)
	     (let ((cur-srate (mus-sound-srate file))
		   (cur-chans (mus-sound-chans file))
		   (cur-format (mus-sound-data-format file))
		   (cur-type (mus-sound-header-type file))
		   (cur-loc (mus-sound-data-location file))
		   (cur-samps (mus-sound-samples file)))
	       (set! (mus-sound-srate file) (* cur-srate 2))
	       (if (not (= (* cur-srate 2) (mus-sound-srate file))) 
		   (snd-display #__line__ ";~A: set mus-sound-srate: ~A -> ~A" file cur-srate (mus-sound-srate file)))
	       (set! (mus-sound-samples file) (* cur-samps 2))
	       (if (not (= (* cur-samps 2) (mus-sound-samples file))) 
		   (snd-display #__line__ ";~A: set mus-sound-samples: ~A -> ~A" file cur-samps (mus-sound-samples file)))
	       (set! (mus-sound-chans file) (* cur-chans 2))
	       (if (not (= (* cur-chans 2) (mus-sound-chans file))) 
		   (snd-display #__line__ ";~A: set mus-sound-chans: ~A -> ~A" file cur-chans (mus-sound-chans file)))
	       (set! (mus-sound-data-location file) (* cur-loc 2))
	       (if (not (= (* cur-loc 2) (mus-sound-data-location file))) 
		   (snd-display #__line__ ";~A: set mus-sound-data-location: ~A -> ~A" file cur-loc (mus-sound-data-location file)))
	       (set! (mus-sound-header-type file) mus-nist)
	       (if (not (= mus-nist (mus-sound-header-type file))) 
		   (snd-display #__line__ ";~A: set mus-sound-header-type: ~A -> ~A" file cur-type (mus-sound-header-type file)))
	       (set! (mus-sound-data-format file) mus-lintn)
	       (if (not (= mus-lintn (mus-sound-data-format file))) 
		   (snd-display #__line__ ";~A: set mus-sound-data-format: ~A -> ~A" file cur-format (mus-sound-data-format file)))
	       (set! (mus-sound-srate file) cur-srate)
	       (set! (mus-sound-samples file) cur-samps)
	       (set! (mus-sound-chans file) cur-chans)
	       (set! (mus-sound-data-location file) cur-loc)
	       (set! (mus-sound-header-type file) cur-type)
	       (set! (mus-sound-data-format file) cur-format)))
	   (list "test.wave" "test.rf64" "test.aifc"))
	  
	  (for-each 
	   (lambda (file)
	     (let ((ind (open-sound file)))
	       (let ((cur-srate (srate ind))
		     (cur-chans (chans ind))
		     (cur-format (data-format ind))
		     (cur-type (header-type ind))
		     (cur-loc (data-location ind))
		     (cur-samps (frames ind)))
		 (set! (srate ind) (* cur-srate 2))
		 (if (not (= (* cur-srate 2) (srate ind))) 
		     (snd-display #__line__ ";~A: set srate: ~A -> ~A" file cur-srate (srate ind)))
		 (set! (frames ind) (* cur-samps 2))
		 (if (not (= (* cur-samps 2) (frames ind))) 
		     (snd-display #__line__ ";~A: set frames: ~A -> ~A" file cur-samps (frames ind)))
		 (set! (chans ind) (* cur-chans 2)) ; this can change the index
		 (let ((xind (find-sound file)))
		   (if (not (equal? ind xind))
		       (set! ind xind)))
		 (if (not (= (* cur-chans 2) (chans ind))) 
		     (snd-display #__line__ ";~A: set chans: ~A -> ~A" file cur-chans (chans ind)))
		 (set! (data-location ind) (* cur-loc 2))
		 (if (not (= (* cur-loc 2) (data-location ind))) 
		     (snd-display #__line__ ";~A: set data-location: ~A -> ~A" file cur-loc (data-location ind)))
		 (set! (header-type ind) mus-nist)
		 (if (not (= mus-nist (header-type ind))) 
		     (snd-display #__line__ ";~A: set header-type: ~A -> ~A" file cur-type (header-type ind)))
		 (set! (data-format ind) mus-lintn)
		 (if (not (= mus-lintn (data-format ind))) 
		     (snd-display #__line__ ";~A: set data-format: ~A -> ~A" file cur-format (data-format ind)))
		 (set! (srate ind) cur-srate)
		 (set! (frames ind) cur-samps)
		 (set! (chans ind) cur-chans)
		 (set! (data-location ind) cur-loc)
		 (set! (header-type ind) cur-type)
		 (set! (data-format ind) cur-format))
	       (close-sound ind))
	     (if (file-exists? file)
		 (delete-file file)))
	   (list "test.wave" "test.rf64" "test.aifc")))
	
	;;	  (with-sound (:output big-file-name :srate 44100 :play #f)
	;;	    (do ((i 0 (+ 1 i))) ((= i 72000))
	;;	      (fm-violin i .1 440 (+ .01 (* (/ i 72000.0) .9)))))
	
	(if with-big-file
	    (let ((probable-frames (floor (* 44100 71999.1)))) ; silence as last .9 secs, so it probably wasn't written
	      (if (not (= (mus-sound-samples big-file-name) 3175160310))
		  (snd-display #__line__ ";bigger samples: ~A" (mus-sound-samples big-file-name)))
	      (if (not (= (mus-sound-frames big-file-name) 3175160310))
		  (snd-display #__line__ ";bigger frames: ~A" (mus-sound-frames big-file-name)))
	      (if (not (= (mus-sound-frames big-file-name) probable-frames))
		  (snd-display #__line__ ";bigger frames: ~A (probable: ~A)" (mus-sound-frames big-file-name) probable-frames))
	      (if (not (= (mus-sound-length big-file-name) 6350320648))
		  (snd-display #__line__ ";bigger bytes: ~A" (mus-sound-length big-file-name)))
	      (if (fneq (mus-sound-duration big-file-name) 71999.1015)
		  (snd-display #__line__ ";bigger dur: ~A" (mus-sound-duration big-file-name)))
	      (let ((ind (open-sound big-file-name)))
		(if (not (= (frames ind) 3175160310)) (snd-display #__line__ ";bigger frames: ~A" (frames ind)))
		(set! big-file-frames (frames ind))
		(if (not (= (frames ind) probable-frames)) (snd-display #__line__ ";bigger frames: ~A (probable: ~A)" (frames ind) probable-frames))
		(if (not (= (frames ind 0 0) big-file-frames)) (snd-display #__line__ ";bigger edpos-frames: ~A" (frames ind)))
		(let ((m1 (add-mark (* 44100 50000) ind)))
		  (if (not (= (mark-sample m1) (* 44100 50000))) (snd-display #__line__ ";bigger mark at: ~A" (mark-sample m1)))
		  (set! (mark-sample m1) (* 44100 66000))
		  (if (not (= (mark-sample m1) (* 44100 66000))) (snd-display #__line__ ";bigger mark to: ~A" (mark-sample m1))))
		(let ((mx (mix-sound "oboe.snd" (* 44100 60000))))
		  (if (mix? mx)
		      (begin
			(if (not (= (mix-position mx) (* 44100 60000))) (snd-display #__line__ ";bigger mix at: ~A" (mix-position mx)))
			(set! (mix-position mx) (* 44100 61000))
			(if (not (= (mix-position mx) (* 44100 61000))) (snd-display #__line__ ";bigger mix to: ~A" (mix-position mx))))
		      (snd-display #__line__ ";no mix tag from mix-sound"))
		  (undo 2))
		(let ((res (find-channel (lambda (y) (not (= y 0.0))))))
		  (if (or (not res)
			  (> (cadr res) 100))
		      (snd-display #__line__ ";bigger find not 0.0: ~A" res)))
		(let ((old-select (selection-creates-region)))
		  (set! (selection-creates-region) #f)
		  (select-all ind)
		  (if (not (= (selection-frames) (frames ind))) (snd-display #__line__ ";bigger select all: ~A ~A" (selection-frames) (frames)))
		  (set! (selection-position) (* 44100 50000))
		  (if (not (= (selection-position) (* 44100 50000))) (snd-display #__line__ ";bigger select pos: ~A" (selection-position)))
		  (set! (selection-position) 0)
		  (set! (selection-frames) (* 44100 65000))
		  (if (not (= (selection-frames) (* 44100 65000))) (snd-display #__line__ ";bigger select len: ~A" (selection-frames)))
		  (set! (selection-creates-region) old-select))
		(set! (cursor ind) (* 44100 50000))
		(if (not (= (cursor ind) (* 44100 50000))) (snd-display #__line__ ";bigger cursor: ~A" (cursor ind)))
		(let ((m1 (add-mark (* 44123 51234) ind)))
		  (if (not (= (mark-sample m1) (* 44123 51234))) (snd-display #__line__ ";bigger mark at: ~A" (mark-sample m1)))
		  (let ((mid (find-mark (* 44123 51234))))
		    (if (or (not (number? mid)) (not (= mid m1))) (snd-display #__line__ ";bigger mark seach: ~A ~A" mid m1))))
		(let ((mx (mix-sound "oboe.snd" (* 44123 61234))))
		  (let ((mxd (find-mix (* 44123 61234))))
		    (if (or (not (number? mxd)) (not (= mxd mx))) (snd-display #__line__ ";bigger find-mix ~A ~A" mxd mx))))
		(set! (cursor ind) (* 44123 51234))
		(if (not (= (cursor ind) (* 44123 51234))) (snd-display #__line__ ";bigger cursor 123: ~A" (cursor ind)))
		(close-sound ind))))
	
	(let ((ind (new-sound "tmp.snd" mus-riff mus-l24int 22050 1 :size 100000))
	      (old-selection-creates-region (selection-creates-region)))
	  (set! (selection-creates-region) #t)
	  (let ((x -0.5) 
		(incr (/ 1.0 (frames)))) 
	    (map-channel (lambda (n) 
			   (let ((val x)) 
			     (set! x (+ x incr)) 
			     val))))
	  (save-sound)
	  (close-sound ind)
	  (set! ind (open-sound "tmp.snd"))
	  (let ((reg (select-all)))
	    (save-selection "tmp1.snd" mus-next mus-l24int)
	    (let ((ind1 (open-sound "tmp1.snd")))
	      (let* ((x -0.5) 
		     (incr (/ 1.0 (frames))) 
		     (err (scan-channel 
			   (lambda (n) 
			     (let ((val x)) 
			       (set! x (+ x incr)) 
			       (fneq val n)))
			   0 100000 ind1)))
		(if err (snd-display #__line__ ";l24 (next) selection not saved correctly? ~A" err)))
	      (close-sound ind1))
	    (save-selection "tmp1.snd" mus-aifc mus-l24int)
	    (let ((ind1 (open-sound "tmp1.snd")))
	      (let* ((x -0.5) 
		     (incr (/ 1.0 (frames))) 
		     (err (scan-channel 
			   (lambda (n) 
			     (let ((val x)) 
			       (set! x (+ x incr)) 
			       (fneq val n)))
			   0 100000 ind1)))
		(if err (snd-display #__line__ ";l24 (aifc) selection not saved correctly? ~A" err)))
	      (close-sound ind1))
	    (save-region reg "tmp1.snd" mus-next mus-l24int)
	    (let ((ind1 (open-sound "tmp1.snd")))
	      (let* ((x -0.5) 
		     (incr (/ 1.0 (frames))) 
		     (err (scan-channel 
			   (lambda (n) 
			     (let ((val x)) 
			       (set! x (+ x incr)) 
			       (fneq val n)))
			   0 100000 ind1)))
		(if err (snd-display #__line__ ";l24 (next) region not saved correctly? ~A" err)))
	      (close-sound ind1))
	    (delete-file "tmp1.snd")
	    (close-sound ind)
	    (delete-file "tmp.snd"))
	  (set! (selection-creates-region) old-selection-creates-region))
	
	(let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1 :size 10 :comment #f)))
	  (map-channel (lambda (y) 1.0))
	  (env-channel '(0 0 .1 .1 .2 .2 .3 .3 .4 .4 .5 .5 .6 .6 .7 .7 .8 .8 .9  .9))
	  (if (not (vequal (channel->vct) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	      (snd-display #__line__ ";ramp env by .1: ~A" (channel->vct)))
	  (close-sound ind))
	))
    
    (reset-hook! open-raw-sound-hook)
    (add-hook! open-raw-sound-hook (lambda (a b) #t))
    (reset-hook! bad-header-hook)
    (add-hook! bad-header-hook (lambda (n) #t))
    (if (hook-empty? open-raw-sound-hook) (snd-display #__line__ ";add-hook open-raw-sound-hook failed??"))
    (if (hook-empty? bad-header-hook) (snd-display #__line__ ";add-hook bad-header-hook failed??"))
    (let* ((magic-words (list ".snd" "FORM" "AIFF" "AIFC" "COMM" "COMT" "INFO" "INST" "inst" "MARK" "SSND"
			      "FVER" "NONE" "ULAW" "ulaw" "ima4" "raw " "sowt" "in32" "in24" "ni23" "fl32"
			      "FL32" "fl64" "twos" "ALAW" "alaw" "APPL" "CLM " "RIFF" "RIFX" "WAVE" "fmt "
			      "data" "fact" "clm " "NIST" "8SVX" "16SV" "Crea" "tive" "SOUN" "D SA" "MPLE"
			      "BODY" "VHDR" "CHAN" "ANNO" "NAME" "2BIT" "HCOM" "FSSD" "%//\n" "%---" "ALaw"
			      "Soun" "MAUD" "MHDR" "MDAT" "mdat" "MThd" "sfbk" "sdta" "shdr" "pdta"
			      "LIST" "GF1P" "ATCH" "$SIG" "NAL_" "GOLD" " SAM" "SRFS" "Diam" "ondW" "CSRE"
			      "SND " "SNIN" "SNDT" "DDSF" "FSMu" "UWFD" "LM89" "SY80" "SY85" "SCRS" "DSPL"
			      "AVI " "strf" "movi" "PRAM" " paf" "fap " "DS16" "HEDR" "HDR8" "SDA_" "SDAB"
			      "SD_B" "NOTE" "file" "=sam" "SU7M" "SU7R" "PVF1" "PVF2" "AUTH" "riff" "TWIN"
			      "IMPS" "SMP1" "Maui" "SDIF" "NVF "))
	   (len (length magic-words))
	   (ctr 0))
      (for-each
       (lambda (magic)
	 (if (hook-empty? open-raw-sound-hook) (snd-display #__line__ ";open-raw-sound-hook cleared??"))
	 (if (hook-empty? bad-header-hook) (snd-display #__line__ ";bad-header-hook cleared??"))
	 (if (file-exists? "test.snd")
	     (delete-file "test.snd"))
	 (mus-sound-forget "test.snd")
	 ;; try random garbage
	 (with-output-to-file "test.snd"
	   (lambda ()
	     (display magic)
	     (do ((i 0 (+ 1 i)))
		 ((= i 128))
	       (write (random 1.0)))))
	 (let ((tag (catch #t
			   (lambda ()
			     (open-sound "test.snd"))
			   (lambda args (car args)))))
	   (if (and (number? tag)
		    (sound? tag))
	       (begin
		 (snd-display #__line__ ";open-sound garbage ~A: ~A -> ~A?" magic tag (file->string "test.snd"))
		 (if (sound? tag) (close-sound tag)))))
	 (delete-file "test.snd")
	 (mus-sound-forget "test.snd")
	 ;; try plausible garbage
	 (with-output-to-file "test.snd"
	   (lambda ()
	     (display magic)
	     (do ((i 0 (+ 1 i)))
		 ((= i 128))
	       (write (random 128)))))
	 (let ((tag (catch #t
			   (lambda ()
			     (open-sound "test.snd"))
			   (lambda args (car args)))))
	   (if (and (number? tag)
		    (sound? tag))
	       (begin
		 (snd-display #__line__ ";open-sound plausible garbage ~A: ~A?" magic tag)
		 (if (sound? tag) (close-sound tag)))))
	 (delete-file "test.snd")
	 (mus-sound-forget "test.snd")
	 ;; write very plausible garbage
	 (with-output-to-file "test.snd"
	   (lambda ()
	     (display magic)
	     (do ((i 1 (+ 1 i)))
		 ((= i 12))
	       (if (< (+ ctr i) len)
		   (display (list-ref magic-words (+ ctr i)))
		   (display (list-ref magic-words i))))))
	 (let ((tag (catch #t
			   (lambda ()
			     (open-sound "test.snd"))
			   (lambda args (car args)))))
	   (if (and (number? tag)
		    (sound? tag))
	       (begin
		 (snd-display #__line__ ";open-sound very plausible garbage ~A: ~A?" magic tag)
		 (if (sound? tag) (close-sound tag)))))
	 (set! ctr (+ 1 ctr)))
       magic-words))
    (if (file-exists? "test.snd") (delete-file "test.snd"))
    (mus-sound-forget "test.snd")
    
    (with-output-to-file "test.snd"
      (lambda ()
	(display ".snd")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o034) ; location
	(write-byte #o000) (write-byte #o001) (write-byte #o215) (write-byte #o030) ; nominal size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o022) ; format
	(write-byte #o000) (write-byte #o000) (write-byte #o126) (write-byte #o042) ; srate
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o001) ; chans
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; comment
	(write-byte #o000) (write-byte #o001) ; samp 1
	))
    (if (not (= (mus-sound-data-format "test.snd") mus-bshort))
	(snd-display #__line__ ";next 18: ~A" (mus-sound-data-format "test.snd")))
    (delete-file "test.snd")
    (mus-sound-forget "test.snd")
    (with-output-to-file "test.snd"
      (lambda ()
	(display ".snd")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; location
	(write-byte #o000) (write-byte #o001) (write-byte #o215) (write-byte #o030) ; nominal size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o022) ; format
	(write-byte #o000) (write-byte #o000) (write-byte #o126) (write-byte #o042) ; srate
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o001) ; chans
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; comment
	(write-byte #o000) (write-byte #o001) ; samp 1
	))
    (let ((tag (catch #t
		      (lambda ()
			(open-sound "test.snd"))
		      (lambda args (car args)))))
      (if (and (number? tag)
	       (sound? tag))
	  (begin
	    (snd-display #__line__ ";open-sound next bad location ~A: ~A?" (data-location tag) tag)
	    (close-sound tag))))
    (delete-file "test.snd")
    (mus-sound-forget "test.snd")
    (with-output-to-file "test.snd"
      (lambda ()
	(display ".snd")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o034) ; location
	(write-byte #o000) (write-byte #o001) (write-byte #o215) (write-byte #o030) ; nominal size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o122) ; format
	(write-byte #o000) (write-byte #o000) (write-byte #o126) (write-byte #o042) ; srate
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o001) ; chans
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; comment
	(write-byte #o000) (write-byte #o001) ; samp 1
	))
    
    (let ((tag (catch #t
		      (lambda ()
			(open-sound "test.snd"))
		      (lambda args (car args)))))
      (if (and (number? tag)
	       (sound? tag))
	  (begin
	    (snd-display #__line__ ";open-sound next bad format ~A: ~A?" (data-format tag) tag)
	    (close-sound tag))))
    (delete-file "test.snd")
    (mus-sound-forget "test.snd")
    
    (letrec ((make-aifc-file 
	      (lambda (frames auth-lo bits)
		(with-output-to-file "test.aif"
		  (lambda ()
		    (display "FORM")
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o146) ; len
		    (display "AIFCFVER")
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; version chunk size
		    (write-byte #o242) (write-byte #o200) (write-byte #o121) (write-byte #o100) ; version  
		    (display "COMM")
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
		    (write-byte #o000) (write-byte #o001) ; 1 chan
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte frames) ; frames
		    (write-byte #o000) (write-byte bits) ; bits
		    (write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ;
		    ;; srate as 80-bit float (sheesh)
		    (display "NONE") ; compression
		    (write-byte #o016) ; pascal string len
		    (display "not compressed")
		    (write-byte #o000)
		    (display "AUTH")
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte auth-lo) ; AUTH chunk size
		    (display "bil")
		    (write-byte #o000)
		    (display "SSND")
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
		    (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
		    (write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
		    )))))
      (if (file-exists? "test.aif") (delete-file "test.aif"))
      (mus-sound-forget "test.aif")
      ;;correct (make-aifc-file #o002 #o004 #o020)
      (make-aifc-file #o102 #o004 #o020)
      (catch #t
	     (lambda ()
	       (let ((ind (open-sound "test.aif")))
		 (if (not (= (frames ind) 2)) (snd-display #__line__ ";bad frames in header: ~A" (frames ind)))
		 (close-sound ind)))
	     (lambda args (snd-display #__line__ args)))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif")
      (make-aifc-file #o002 #o150 #o020)
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.aif"))
			(lambda args (car args)))))
	(if (and (number? tag)
		 (sound? tag))
	    (begin
	      (snd-display #__line__ ";open-sound aifc no ssnd chunk ~A: ~A?" (data-location tag) tag)
	      (close-sound tag))))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif")
      (make-aifc-file #o002 #o000 #o020)
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.aif"))
			(lambda args (car args)))))
	(if (and (number? tag)
		 (sound? tag))
	    (begin
	      (snd-display #__line__ ";open-sound aifc 0-len auth chunk ~A: ~A?" (data-location tag) tag)
	      (close-sound tag))))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif")
      (make-aifc-file #o002 #o150 #o120)
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.aif"))
			(lambda args (car args)))))
	(if (and (number? tag)
		 (sound? tag))
	    (begin
	      (snd-display #__line__ ";open-sound bits 80 ~A: ~A?" (data-format tag) tag)
	      (close-sound tag))))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif"))
    (with-output-to-file "test.aif"
      (lambda ()
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o176) ; len
	(display "AIFCFVER")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; version chunk size
	(write-byte #o242) (write-byte #o200) (write-byte #o121) (write-byte #o100) ; version  
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o001) ; 1 chan
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o002) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "AUTH")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; AUTH chunk size
	(display "bil")
	(write-byte #o000)
	(display "ANNO")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; AUTH chunk size
	(display "cat")
	(write-byte #o000)
	(display "NAME")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; AUTH chunk size
	(display "dog")
	(write-byte #o000)
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
	))
    (catch #t
	   (lambda ()
	     (if (not (= (string-length (mus-sound-comment "test.aif")) 15))
		 (snd-display #__line__ ";aifc 3 aux comments: ~A?" (mus-sound-comment "test.aif"))))
	   (lambda args (snd-display #__line__ args)))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    (with-output-to-file "test.aif"
      (lambda ()
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o142) ; len
	(display "AIFC")
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o001) ; 1 chan
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o002) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "COMT")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) 
	(display "bil")
	(write-byte #o000)
	))
    (catch #t
	   (lambda ()
	     (if (not (string=? (substring (mus-sound-comment "test.aif") 0 3) "bil"))
		 (snd-display #__line__ ";aifc trailing comt comment: ~A?" (mus-sound-comment "test.aif"))))
	   (lambda args (snd-display #__line__ args)))
    (if (not (= (mus-sound-frames "test.aif") 2))
	(snd-display #__line__ ";aifc trailing comt frames: ~A?" (mus-sound-frames "test.aif")))
    (catch #t
	   (lambda ()
	     (let ((ind (open-sound "test.aif")))
	       (if (or (fneq (sample 0) 0.00198)
		       (fneq (sample 1) 0.00195)
		       (fneq (sample 2) 0.0)
		       (fneq (sample 3) 0.0))
		   (snd-display #__line__ ";aifc trailing comt samps: ~A ~A ~A ~A" (sample 0) (sample 1) (sample 2) (sample 3)))
	       (close-sound ind)))
	   (lambda args (snd-display #__line__ args)))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    (with-output-to-file "test.aif"
      (lambda ()
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o142) ; len
	(display "AIFC")
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o001) ; 1 chan
	(write-byte #o000) (write-byte #o000) (write-byte #o100) (write-byte #o102) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "COMT")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) 
	(display "bil")
	(write-byte #o000)
	))
    (if (or (not (string? (mus-sound-comment "test.aif")))
	    (not (string=? (substring (mus-sound-comment "test.aif") 0 3) "bil")))
	(snd-display #__line__ ";aifc trailing comt comment: ~A?" (mus-sound-comment "test.aif")))
    (if (not (= (mus-sound-frames "test.aif") 2))
	(snd-display #__line__ ";aifc trailing comt (bogus) frames: ~A?" (mus-sound-frames "test.aif")))
    (catch #t
	   (lambda ()
	     (let ((ind (open-sound "test.aif")))
	       (if (or (fneq (sample 0) 0.00198)
		       (fneq (sample 1) 0.00195)
		       (fneq (sample 2) 0.0)
		       (fneq (sample 3) 0.0))
		   (snd-display #__line__ ";aifc trailing comt samps (bogus frame setting): ~A ~A ~A ~A" (sample 0) (sample 1) (sample 2) (sample 3)))
	       (close-sound ind)))
	   (lambda args (snd-display #__line__ args)))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    (with-output-to-file "test.aif"
      (lambda ()
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o142) ; len
	(display "AIFC")
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o001) ; 1 chan
	(write-byte #o000) (write-byte #o000) (write-byte #o100) (write-byte #o102) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
	))
    (let ((tag (catch #t
		      (lambda ()
			(open-sound "test.aif"))
		      (lambda args (car args)))))
      (if (and (number? tag)
	       (sound? tag))
	  (begin
	    (snd-display #__line__ ";open-sound aifc 2 ssnd chunks ~A: ~A?" (data-location tag) tag)
	    (close-sound tag))))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    
    (with-output-to-file "test.aif"
      (lambda ()
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o040) ; len
	(display "AIFC")
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o000) (write-byte #o101) (write-byte #o000) (write-byte #o100) ; two samples
	))
    (let ((tag (catch #t
		      (lambda ()
			(open-sound "test.aif"))
		      (lambda args (car args)))))
      (if (not (eq? tag 'mus-error))
	  (begin
	    (snd-display #__line__ ";open-sound aifc no comm chunk ~A?" tag)
	    (if (and (number? tag)
		     (sound? tag))
		(close-sound tag)))))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    
    (with-output-to-file "test.aif"
      (lambda ()
					;write AIFC with trailing chunks to try to confuse file->sample
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o176) ; len
	(display "AIFCFVER")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; version chunk size
	(write-byte #o242) (write-byte #o200) (write-byte #o121) (write-byte #o100) ; version  
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o001) ; 1 chan
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o002) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o170) (write-byte #o101) (write-byte #o100) (write-byte #o100) ; two samples
	(display "AUTH")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; AUTH chunk size
	(display "bil")
	(write-byte #o000)
	(display "ANNO")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; AUTH chunk size
	(display "cat")
	(write-byte #o000)
	(display "NAME")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; AUTH chunk size
	(display "dog")
	(write-byte #o000)
	))
    (catch #t
	   (lambda ()
	     (let ((gen (make-file->sample "test.aif")))
	       (if (fneq (gen 0) 0.93948) (snd-display #__line__ ";file->sample chunked 0: ~A" (gen 0)))
	       (if (fneq (gen 1) 0.50195) (snd-display #__line__ ";file->sample chunked 1: ~A" (gen 1)))
	       (if (fneq (gen 2) 0.0) (snd-display #__line__ ";file->sample chunked eof: ~A" (gen 2)))
	       (if (fneq (gen 3) 0.0) (snd-display #__line__ ";file->sample chunked eof+1: ~A" (gen 3))))
	     (let ((file (open-sound "test.aif")))
	       (if (not (= (frames file) 2)) (snd-display #__line__ ";chunked frames: ~A" (frames file)))
	       (if (fneq (sample 0) 0.93948) (snd-display #__line__ ";file chunked 0: ~A" (sample 0)))
	       (if (fneq (sample 1) 0.50195) (snd-display #__line__ ";file chunked 1: ~A" (sample 1)))
	       (if (fneq (sample 2) 0.0) (snd-display #__line__ ";file chunked eof: ~A" (sample 2)))
	       (if (fneq (sample 3) 0.0) (snd-display #__line__ ";file chunked eof+1: ~A" (sample 3)))
	       (close-sound file)))
	   (lambda args (snd-display #__line__ args)))
    (catch #t
	   (lambda ()
	     (if (not (= (mus-sound-frames "test.aif") 2)) (snd-display #__line__ ";chunked mus-sound-frames: ~A" (mus-sound-frames "test.aif"))))
	   (lambda args (snd-display #__line__ args)))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    
    (with-output-to-file "test.aif"
      (lambda ()
					;write AIFC with trailing chunks to try to confuse file->sample
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o176) ; len
	(display "AIFCFVER")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; version chunk size
	(write-byte #o242) (write-byte #o200) (write-byte #o121) (write-byte #o100) ; version  
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o170) (write-byte #o101) (write-byte #o100) (write-byte #o100) ; two samples
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o001) ; 1 chan
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o002) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "APPL")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte (char->integer #\h))
	(display "CLM ;Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98")
	(write-byte #o000)
	))
    (catch #t
	   (lambda ()
	     (let ((gen (make-file->sample "test.aif")))
	       (if (fneq (gen 0) 0.93948) (snd-display #__line__ ";file->sample chunked 0: ~A" (gen 0)))
	       (if (fneq (gen 1) 0.50195) (snd-display #__line__ ";file->sample chunked 1: ~A" (gen 1)))
	       (if (fneq (gen 2) 0.0) (snd-display #__line__ ";file->sample chunked eof: ~A" (gen 2)))
	       (if (fneq (gen 3) 0.0) (snd-display #__line__ ";file->sample chunked eof+1: ~A" (gen 3))))
	     (let ((file (open-sound "test.aif")))
	       (if (not (= (frames file) 2)) (snd-display #__line__ ";chunked frames: ~A" (frames file)))
	       (if (fneq (sample 0) 0.93948) (snd-display #__line__ ";file chunked 0: ~A" (sample 0)))
	       (if (fneq (sample 1) 0.50195) (snd-display #__line__ ";file chunked 1: ~A" (sample 1)))
	       (if (fneq (sample 2) 0.0) (snd-display #__line__ ";file chunked eof: ~A" (sample 2)))
	       (if (fneq (sample 3) 0.0) (snd-display #__line__ ";file chunked eof+1: ~A" (sample 3)))
	       (if (or (not (string? (comment)))
		       (not (string=? (comment) ";Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98")))
		   (snd-display #__line__ ";chunked appl comment: ~A" (comment)))
	       (close-sound file)))
	   (lambda args (snd-display #__line__ args)))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    
    (with-output-to-file "test.aif"
      (lambda ()
					;write AIFC with trailing chunks to try to confuse file->sample
	(display "FORM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o176) ; len
	(display "AIFCFVER")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o004) ; version chunk size
	(write-byte #o242) (write-byte #o200) (write-byte #o121) (write-byte #o100) ; version  
	(display "SSND")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o014) ; SSND chunk size
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; SSND data loc
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; block size?
	(write-byte #o170) (write-byte #o101) (write-byte #o100) (write-byte #o100) ; two samples (one frame)
	(display "COMM")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o046) ; COMM chunk size
	(write-byte #o000) (write-byte #o002) ; 2 chans
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o001) ; frames
	(write-byte #o000) (write-byte #o020) ; bits
	(write-byte #o100) (write-byte #o016) (write-byte #o254) (write-byte #o104) (write-byte #o000) 
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte #o000) ; srate as 80-bit float (sheesh)
	(display "NONE") ; compression
	(write-byte #o016) ; pascal string len
	(display "not compressed")
	(write-byte #o000)
	(display "APPL")
	(write-byte #o000) (write-byte #o000) (write-byte #o000) (write-byte (char->integer #\h))
	(display "CLM ;Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98")
	(write-byte #o000)
	))
    (catch #t
	   (lambda ()
	     (let ((gen (make-file->sample "test.aif")))
	       (if (fneq (gen 0 0) 0.93948) (snd-display #__line__ ";file->sample chunked 0 0: ~A" (gen 0 0)))
	       (if (fneq (gen 0 1) 0.50195) (snd-display #__line__ ";file->sample chunked 0 1: ~A" (gen 0 1)))
	       (if (fneq (gen 1 0) 0.0) (snd-display #__line__ ";file->sample chunked eof(stereo): ~A" (gen 1 0)))
	       (if (fneq (gen 1 1) 0.0) (snd-display #__line__ ";file->sample chunked eof+1 (stereo): ~A" (gen 1 1))))
	     (let ((file (open-sound "test.aif")))
	       (if (not (= (frames file) 1)) (snd-display #__line__ ";chunked frames (1): ~A" (frames file)))
	       (if (fneq (sample 0 file 0) 0.93948) (snd-display #__line__ ";file chunked 0 0: ~A" (sample 0 file 0)))
	       (if (fneq (sample 0 file 1) 0.50195) (snd-display #__line__ ";file chunked 0 1: ~A" (sample 0 file 1)))
	       (if (fneq (sample 1 file 0) 0.0) (snd-display #__line__ ";file chunked eof (stereo): ~A" (sample 1 file 0)))
	       (if (fneq (sample 1 file 1) 0.0) (snd-display #__line__ ";file chunked eof+1 (stereo): ~A" (sample 1 file 1)))
	       (if (or (not (string? (comment)))
		       (not (string=? (comment) ";Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98")))
		   (snd-display #__line__ ";chunked appl comment (stereo): ~A" (comment)))
	       (close-sound file)))
	   (lambda args (snd-display #__line__ args)))
    (delete-file "test.aif")
    (mus-sound-forget "test.aif")
    
    (let ((files (sound-files-in-directory cwd)))
      (if (null? files) (snd-display #__line__ ";no sound files in ~A?" cwd))
      (let ((files1 (sound-files-in-directory)))
	(if (not (equal? files files1)) (snd-display #__line__ ";different sound files in ~A and default?" cwd))
	(let ((files2 (sound-files-in-directory ".")))
	  (if (or (not (equal? files1 files2))
		  (not (equal? files files2)))
	      (snd-display #__line__ ";sound-files-in-directory dot: ~A but ~A" files2 files)))))
    
    (reset-hook! bad-header-hook)
    (reset-hook! open-raw-sound-hook)
    (if (not (null? (sounds))) (for-each close-sound (sounds)))
    
    (let ((ind (new-sound :size 0)))
      (if (not (= (frames ind) 0)) (snd-display #__line__ ";new-sound :size 0 -> ~A frames" (frames ind)))
      (if (fneq (sample 0) 0.0) (snd-display #__line__ ";new-sound :size 0 sample 0: ~A" (sample 0)))
      (let ((new-file-name (file-name ind)))
	(close-sound ind)
	(if (file-exists? new-file-name) (delete-file new-file-name))))
    (let ((ind (new-sound :size 1)))
      (if (not (= (frames ind) 1)) (snd-display #__line__ ";new-sound :size 1 -> ~A frames" (frames ind)))
      (if (fneq (sample 0) 0.0) (snd-display #__line__ ";new-sound :size 1 sample 0: ~A" (sample 0)))
      (let ((new-file-name (file-name ind)))
	(close-sound ind)
	(if (file-exists? new-file-name) (delete-file new-file-name))))
    (let ((tag (catch #t
		      (lambda () (new-sound :size -1))
		      (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range))
	  (begin
	    (snd-display #__line__ ";new-sound :size -1: ~A" tag)
	    (if (not (null? (sounds))) (for-each close-sound (sounds))))))
    
    (let ((ind (read-ascii (string-append sf-dir "caruso.asc"))))
      (if (not (sound? ind)) 
	  (snd-display #__line__ ";read-ascii can't find ~A (~A)" (string-append sf-dir "caruso.asc") (map file-name (sounds)))
	  (begin
	    (if (fneq (maxamp ind 0) 0.723) (snd-display #__line__ ";read-ascii maxamp: ~A" (maxamp ind 0)))
	    (if (not (= (frames ind 0) 50000)) (snd-display #__line__ ";read-ascii frames: ~A" (frames ind 0)))
	    (if (not (= (srate ind) 44100)) (snd-display #__line__ ";read-ascii srate: ~A" (srate ind)))
	    (set! (srate ind) 8000)
	    (if (or (not (= (frames ind 0) 50000))
		    (fneq (maxamp ind 0) .723))
		(snd-display #__line__ ";set srate clobbered new sound: ~A ~A (~A)" (frames ind 0) (maxamp ind 0) (srate ind)))
	    
	    (close-sound ind))))
    
    (let ((ind (open-sound "oboe.snd")))
      (save-sound-as "test space.snd")
      (close-sound ind)
      (set! ind (open-sound "test space.snd"))
      (if (not (string=? (short-file-name ind) "test space.snd"))
	  (snd-display #__line__ ";file name with space: ~A" (short-file-name ind)))
      (let ((len (frames ind))
	    (slen (mus-sound-frames "test space.snd")))
	(if (not (= len slen)) (snd-display #__line__ ";spaced filename frames: ~A ~A" len slen)))
      (add-mark 1234 ind 0)
      (save-marks ind) ; should write "test space.marks"
      (close-sound ind)
      (set! ind (open-sound "test space.snd"))
      (load (string-append cwd "test space.marks"))
      (if (not (find-mark 1234 ind))
	  (snd-display #__line__ ";space file name save marks: ~A" (marks ind)))
      (let ((rd (make-readin :file "test space.snd")))
	(if (not (string=? (mus-file-name rd) "test space.snd"))
	    (snd-display #__line__ ";file name with space readin: ~A" (mus-file-name rd))))
      (close-sound ind)
      (if (file-exists? "test space.snd")
	  (delete-file "test space.snd"))
      (if (file-exists? "test space.marks")
	  (delete-file "test space.marks")))
    
    (if (provided? 'snd-threads)
	(let ((old-file-buffer-size *clm-file-buffer-size*))
	  
	  (let* ((result (with-threaded-sound ()
					      (outa 0 0.5)
					      (outa 1 0.25)
					      (outa 2 0.125)
					      (outa 3 -0.5)))
		 (snd (find-sound result)))
	    (if (not (sound? snd)) 
		(snd-display #__line__ ";with-threaded-sound 0 no output: ~A ~A" result snd)
		(let ((samps (channel->vct 0 (frames snd) snd 0)))
		  (if (not (vequal samps (vct 0.5 0.25 0.125 -0.5)))
		      (snd-display #__line__ ";with-threaded-sound 0 output: ~A" samps)))))
	  
	  (let* ((result (with-threaded-sound ()
					      (outa 0 0.5)
					      (outa 1 0.25)
					      (outa 2 0.125)
					      (outa 3 -0.5)
					      (outa 4 -0.25)
					      (outa 5 -0.125)))
		 (snd (find-sound result)))
	    (if (not (sound? snd)) 
		(snd-display #__line__ ";with-threaded-sound 0a no output: ~A ~A" result snd)
		(let ((samps (channel->vct 0 (frames snd) snd 0)))
		  (if (not (vequal samps (vct 0.5 0.25 0.125 -0.5 -0.25 -0.125)))
		      (snd-display #__line__ ";with-threaded-sound 0a output: ~A" samps)))))
	  
	  (let* ((result (with-threaded-sound ()
					      (outa 0 0.5)
					      (outa 1 0.25)
					      (outa 1 -0.5)))
		 (snd (find-sound result)))
	    (if (not (sound? snd)) 
		(snd-display #__line__ ";with-threaded-sound 0b no output: ~A ~A" result snd)
		(let ((samps (channel->vct 0 (frames snd) snd 0)))
		  (if (not (vequal samps (vct 0.5 -0.25)))
		      (snd-display #__line__ ";with-threaded-sound 0b output: ~A" samps)))))
	  
	  (let ((samps (make-vct 512)))
	    (run 
	     (do ((i 0 (+ 1 i)))
		 ((= i 512))
	       (vct-set! samps i (- (random 2.0) 1.0))))
	    (let* ((result (with-threaded-sound (:channels 2)
						(out-samps 0 0 samps)
						(out-samps 0 1 samps)))
		   (snd (find-sound result)))
	      (if (not (sound? snd)) 
		  (snd-display #__line__ ";with-threaded-sound 1 no output: ~A ~A" result snd)
		  (let ((new-samps-0 (channel->vct 0 (frames snd) snd 0))
			(new-samps-1 (channel->vct 0 (frames snd) snd 1)))
		    (if (not (vequal samps new-samps-0))
			(snd-display #__line__ ";with-threaded-sound 1 chan 0 output differs"))
		    (if (not (vequal samps new-samps-1))
			(snd-display #__line__ ";with-threaded-sound 1 chan 1 output differs"))))))
	  
	  (for-each
	   (lambda (buflen)
	     (set! *clm-file-buffer-size* buflen)
	     (let* ((len 1000000)
		    (samps (make-vct len)))
	       (run 
		(do ((i 0 (+ 1 i)))
		    ((= i len))
		  (vct-set! samps i (- (random 2.0) 1.0))))
	       (let* ((result (with-threaded-sound (:channels 2)
						   (out-samps 0 0 samps)
						   (out-samps 0 1 samps)))
		      (snd (find-sound result)))
		 (if (not (sound? snd)) 
		     (snd-display #__line__ ";with-threaded-sound 2 (~D) no output: ~A ~A" buflen result snd)
		     (let ((new-samps-0 (channel->vct 0 (frames snd) snd 0))
			   (new-samps-1 (channel->vct 0 (frames snd) snd 1)))
		       (if (not (vequal samps new-samps-0))
			   (snd-display #__line__ ";with-threaded-sound 2 (~D) chan 0 output differs" buflen))
		       (if (not (vequal samps new-samps-1))
			   (snd-display #__line__ ";with-threaded-sound 2 (~D) chan 1 output differs" buflen)))))))
	   (list 65536 8192 1024 256 1234))
	  (set! *clm-file-buffer-size* old-file-buffer-size)
	  (set! (mus-file-buffer-size) old-file-buffer-size)	  
	  
	  (let ((samps (make-vct 512)))
	    (run
	     (do ((i 0 (+ 1 i)))
		 ((= i 512))
	       (vct-set! samps i (- (random 2.0) 1.0))))
	    (with-threaded-sound (:channels 1 :output "thread-test.snd")
				 (out-samps 0 0 samps))
	    (let* ((inp (make-file->sample "thread-test.snd"))
		   (inres (make-vct 512))
		   (result (with-threaded-sound ()
						(do ((i 0 (+ 1 i)))
						    ((= i 512))
						  (let ((val (ina i inp)))
						    (vct-set! inres i val)
						    (outa i val)))))
		   (snd (find-sound result)))
	      (if (not (sound? snd)) 
		  (snd-display #__line__ ";with-threaded-sound 3 no output: ~A ~A" result snd)
		  (let ((new-samps-0 (channel->vct 0 (frames snd) snd 0)))
		    (if (not (vequal samps new-samps-0))
			(snd-display #__line__ ";with-threaded-sound 3 output differs"))
		    (if (not (vequal samps inres))
			(snd-display #__line__ ";with-threaded-sound 3 input differs"))))
	      (close-sound snd)
	      (set! snd (find-sound "thread-test.snd"))
	      (if (sound? snd) (close-sound snd))
	      (delete-file "thread-test.snd")))
	  
	  (let ((samps (make-vct 512)))
	    (run
	     (do ((i 0 (+ 1 i)))
		 ((= i 512))
	       (vct-set! samps i (- (random 2.0) 1.0))))
	    (let* ((result (with-threaded-sound (:channels 1)
						(out-samps 0 0 samps)
						(out-samps-invert 0 0 samps)))
		   (snd (find-sound result)))
	      (if (not (sound? snd)) 
		  (snd-display #__line__ ";with-threaded-sound 4 no output: ~A ~A" result snd)
		  (let ((new-samps-0 (channel->vct 0 (frames snd) snd 0)))
		    (if (fneq (vct-peak new-samps-0) 0.0)
			(snd-display #__line__ ";with-threaded-sound 4 chan 1 output differs"))))))
	  
	  (for-each
	   (lambda (buflen)
	     (set! *clm-file-buffer-size* buflen)
	     (let* ((len 1000000)
		    (samps (make-vct len)))
	       (run
		(do ((i 0 (+ 1 i)))
		    ((= i len))
		  (vct-set! samps i (- (random 2.0) 1.0))))
	       (let* ((result (with-threaded-sound (:channels 1)
						   (out-samps 0 0 samps)
						   (out-samps-invert 0 0 samps)))
		      (snd (find-sound result)))
		 (if (not (sound? snd)) 
		     (snd-display #__line__ ";with-threaded-sound 5 (~D) no output: ~A ~A" buflen result snd)
		     (let ((new-samps-0 (channel->vct 0 (frames snd) snd 0)))
		       (if (fneq (vct-peak new-samps-0) 0.0)
			   (snd-display #__line__ ";with-threaded-sound 5 chan 1 output differs")))))))
	   (list 65536 8192 1024 256 1234))
	  (set! *clm-file-buffer-size* old-file-buffer-size)
	  (set! (mus-file-buffer-size) old-file-buffer-size)
	  (for-each (lambda (snd) (close-sound snd)) (sounds))
	  ))
    
    (if (file-is-directory? "oboe.snd") (snd-display #__line__ ";file-is-directory? oboe.snd!"))
    (if (not (file-is-directory? ".")) (snd-display #__line__ ";file-is-directory? . #f!"))
    (if (not (getenv "PATH")) (snd-display #__line__ ";getenv: no PATH?"))
    (if (not (number? (getpid))) (snd-display #__line__ ";getpid: ~A" (getpid)))
    
    (if (not (list? (global-environment))) (snd-display #__line__ ";global-environment not a list?: ~A" (global-environment)))
    
    (let ((ip (current-input-port)))
      (let ((tag (catch #t (lambda () (set-current-input-port "hiho!")) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";set-current-input-port tag: ~A" tag))
	(if (not (equal? ip (current-input-port))) (snd-display #__line__ ";set-current-input-port clobbered port? ~A ~A" ip (current-input-port)))))
    
    (let ((ip (current-output-port)))
      (let ((tag (catch #t (lambda () (set-current-output-port "hiho!")) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";set-current-output-port tag: ~A" tag))
	(if (not (equal? ip (current-output-port))) (snd-display #__line__ ";set-current-output-port clobbered port? ~A ~A" ip (current-output-port)))))
    
    (let ((ip (current-error-port)))
      (let ((tag (catch #t (lambda () (set-current-error-port "hiho!")) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";set-current-error-port tag: ~A" tag))
	(if (not (equal? ip (current-error-port))) (snd-display #__line__ ";set-current-error-port clobbered port? ~A ~A" ip (current-error-port)))))
    
    (if (not (provided? 'gmp))
	(let* ((LONG_MAX 2147483647)
	       (LONG_MIN -2147483648)
	       (LLONG_MAX most-positive-fixnum)
	       (LLONG_MIN most-negative-fixnum)
	       (ints (list 0 1 -1 10 -10 1234 -1234 LONG_MAX LONG_MIN 65536 -65536))
	       (shorts (list 0 1 -1 10 -10 1234 -1234 32767 -32768 8191 -8191))
	       (longs (list 0 1 -1 11 -11 LONG_MAX LONG_MIN LLONG_MAX LLONG_MIN 1000 -1000))
	       (floats (list 0.0 1.0 -1.0 0.1 -0.1 10.0 -10.0 1234.0 65536.0 -1234.0 -0.003))
	       (doubles (list 0.0 1.0 -1.0 0.1 -0.1 10.0 -10.0 1234.0 65536.0 -1234.0 -0.003)))
	  (load "binary-io.scm")
	  
	  (with-output-to-file "idf1.data"
	    (lambda ()
	      
	      (write-lint32 123)
	      (write-bint32 321)
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(write-lint32 (list-ref ints i))
		(write-bint32 (list-ref ints i)))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(write-lint16 (list-ref shorts i))
		(write-bint16 (list-ref shorts i)))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(write-lint64 (list-ref longs i))
		(write-bint64 (list-ref longs i)))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(write-lfloat32 (list-ref floats i))
		(write-bfloat32 (list-ref floats i)))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(write-lfloat64 (list-ref doubles i))
		(write-bfloat64 (list-ref doubles i)))
	      ))
	  
	  (with-input-from-file "idf1.data" 
	    (lambda ()
	      
	      (define (testf val1 val2 name)
		(if (not (= val1 val2))
		    (if (and (not (eq? name 'lfloat32))
			     (not (eq? name 'bfloat32)))
			(format #t ";~A: ~A != ~A~%" name val1 val2)
			(if (> (abs (- val1 val2)) 1.0e-6)
			    (format #t ";~A: ~A != ~A (~A)~%" name val1 val2 (abs (- val1 val2)))))))
	      
	      (testf (read-lint32) 123 'lint32)
	      (testf (read-bint32) 321 'bint32)
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(testf (read-lint32) (list-ref ints i) 'lint32)
		(testf (read-bint32) (list-ref ints i) 'bint32))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(testf (read-lint16) (list-ref shorts i) 'lint16)
		(testf (read-bint16) (list-ref shorts i) 'bint16))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(testf (read-lint64) (list-ref longs i) 'lint64)
		(testf (read-bint64) (list-ref longs i) 'bint64))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(testf (read-lfloat32) (list-ref floats i) 'lfloat32)
		(testf (read-bfloat32) (list-ref floats i) 'bfloat32))
	      
	      (do ((i 0 (+ i 1)))
		  ((= i 11))
		(testf (read-lfloat64) (list-ref doubles i) 'lfloat64)
		(testf (read-bfloat64) (list-ref doubles i) 'bfloat64))
	      ))
	  ))
    ))



;;; ---------------- test 5: simple overall checks ----------------

(if (not (provided? 'snd-selection.scm)) (load "selection.scm"))
(if (not (provided? 'snd-extensions.scm)) (load "extensions.scm"))
(if (not (provided? 'snd-selection.scm)) (load "selection.scm"))
(if (not (provided? 'snd-dsp.scm)) (load "dsp.scm"))
(if (not (provided? 'snd-pvoc.scm)) (load "pvoc.scm"))
(if (and with-gui (not (provided? 'snd-edit-menu.scm))) (load "edit-menu.scm"))

(define* (cosine-channel-via-ptree (beg 0) dur snd chn edpos)
  ;; vct: angle increment
  (ptree-channel
   (lambda (y data forward)
     (let* ((angle (vct-ref data 0))
	    (incr (vct-ref data 1))
	    (val (* y (cos angle))))
       (if forward
	   (vct-set! data 0 (+ angle incr))
	   (vct-set! data 0 (- angle incr)))
       val))
   beg dur snd chn edpos #t
   (lambda (frag-beg frag-dur)
     (let ((incr (/ pi frag-dur)))
       (vct (+ (* -0.5 pi) (* frag-beg incr))
	    incr)))))

(define old-opt-val (optimization))

(define (snd_test_5)
  (define a-ctr 0)
  (define g-init-val 0)
  
  (define (append-sound filename)
    (insert-sound filename (frames)))
  
  (define (test-edpos test-func func-name change-thunk ind1)
    (let ((fr1 (test-func ind1 0))
	  (fr2 (test-func ind1 0 0))
	  (fr3 (test-func ind1 0 current-edit-position))
	  (fr4 (test-func ind1 0 (lambda (snd chn) 0))))
      (if (not (and (= fr1 fr2)
		    (= fr1 fr3)
		    (= fr1 fr4)))
	  (snd-display #__line__ ";initial ~A: ~A ~A ~A ~A?" func-name fr1 fr2 fr3 fr4))
      (change-thunk)
      (let ((fr5 (test-func ind1 0))
	    (fr6 (test-func ind1 0 1))
	    (fr7 (test-func ind1 0 current-edit-position))
	    (fr8 (test-func ind1 0 (lambda (snd chn) (edit-position snd chn)))))
	(if (not (and (= fr5 fr6)
		      (= fr5 fr7)
		      (= fr5 fr8)))
	    (snd-display #__line__ ";~A (edpos 1): ~A ~A ~A ~A?" func-name fr5 fr6 fr7 fr8))
	(set! fr5 (test-func ind1 0 0))
	(set! fr6 (test-func ind1 0 (lambda (snd chn) 0)))
	(if (not (and (= fr1 fr5)
		      (= fr1 fr6)))
	    (snd-display #__line__ ";~A (edpos -1): ~A ~A ~A?" func-name fr1 fr5 fr6))))
    (revert-sound ind1))
  
  (define (test-edpos-1 test-func func-name ind1)
    (let ((v0 (samples->vct 12000 10 ind1 0)))
      (test-func ind1 0)
      (let ((v1 (samples->vct 12000 10 ind1 0)))
	(if (vequal v0 v1)
	    (snd-display #__line__ ";~A (0) no change! ~A ~A" func-name v0 v1))
	(test-func ind1 0)
	(let ((v2 (samples->vct 12000 10 ind1 0)))
	  (if (not (vequal v1 v2))
	      (snd-display #__line__ ";~A (1) ~A ~A" func-name v1 v2))
	  (test-func ind1 (lambda (snd chn) 0))
	  (set! v2 (samples->vct 12000 10 ind1 0))
	  (if (not (vequal v1 v2))
	      (snd-display #__line__ ";~A (2) ~A ~A" func-name v1 v2)))))
    (revert-sound ind1))
  
  (define (vfequal v0 v1)
    (define (dequal ctr len)
      (if (= ctr len)
	  #t
	  (and (< (abs (- (vct-ref v0 ctr) (vct-ref v1 ctr))) .01)
	       (dequal (+ 1 ctr) len))))
    (let ((len (vct-length v0)))
      (and (= len (vct-length v1))
	   (dequal 0 len))))
  
  (define (test-orig func0 func1 func-name ind1)
    (let ((v0 (samples->vct 12000 10 ind1 0)))
      (func0 ind1)
      (let ((v1 (samples->vct 12000 10 ind1 0)))
	(if (vfequal v0 v1)
	    (snd-display #__line__ ";~A (orig: 0) no change! ~A ~A" func-name v0 v1))
	(func1 ind1)
	(let ((v2 (samples->vct 12000 10 ind1 0)))
	  (if (not (vfequal v0 v2))
	      (snd-display #__line__ ";~A (orig: 1) ~A ~A" func-name v0 v2))))
      (revert-sound ind1)))
  
  (define* (make-bandpass-2 flo1 fhi1 flo2 fhi2 (len 30))
    (let* ((f1 (make-bandpass flo1 fhi1 len))
	   (f2 (make-bandpass flo2 fhi2 len)))
      (vct-add! (mus-xcoeffs f1) (mus-xcoeffs f2))
      f1))
  
  (define* (cosine-channel (beg 0) dur snd chn edpos)
    (let ((old-opt (optimization))
	  (samps (or dur (frames snd chn))))
      (set! (optimization) 0)
      (map-channel
       (let* ((incr (/ pi samps))
	      (angle (* -0.5 pi)))
	 (lambda (y)
	   (let ((val (* y (cos angle))))
	     (set! angle (+ angle incr))
	     val)))
       beg dur snd chn edpos)
      (set! (optimization) old-opt)))
  
  (define (check-maxamp ind val name)
    (if (fneq (maxamp ind 0) val) (snd-display #__line__ ";maxamp amp-env ~A: ~A should be ~A" name (maxamp ind) val))
    (let ((pos (find-channel (lambda (y) (>= (abs y) (- val .0001)))))
	  (maxpos (maxamp-position ind 0)))
      (if (not pos) 
	  (snd-display #__line__ ";actual maxamp ~A vals not right" name)
	  (if (not (= maxpos (cadr pos)))
	      (snd-display #__line__ ";~A: find and maxamp-position disagree: ~A (~A) ~A (~A)" 
			   name pos (sample (cadr pos) ind 0) maxpos (sample maxpos ind 0))))
      (let ((mx 0.0)
	    (ctr 0)
	    (mpos 0))
	(scan-chan (lambda (y) 
		     (if (> (abs y) mx)
			 (begin
			   (set! mpos ctr)
			   (set! mx (abs y))))
		     (set! ctr (+ 1 ctr))
		     #f))
	(if (not (= mpos maxpos))
	    (snd-display #__line__ ";scan-chan and maxamp-position disagree: ~A ~A" mpos maxpos))
	(if (fneq mx val) (snd-display #__line__ ";actual ~A max: ~A (correct: ~A)" name mx val)))))
  
  (define (check-env-vals name gen)
    (let ((ctr -1))
      (scan-chan (lambda (y)
		   (let ((val (env gen)))
		     (set! ctr (+ 1 ctr))
		     (if (fneq val y)
			 (begin
			   (display (format #f "~%;check-env-vals ~A at ~D: ~A ~A" name ctr val y))
			   #t)
			 #f))))))
  
  (define (our-x->position ind x) 
    (let ((ax (axis-info ind 0)))
      (list
       (+ (list-ref ax 10) 
	  (/ (* (- x (list-ref ax 2))
		(- (list-ref ax 12) (list-ref ax 10)))
	     (- (list-ref ax 4) (list-ref ax 2))))
       (x->position x ind))))
  
  (define (region-to-vct r c len)
    (let* ((rs (make-region-sampler r 0 c))
	   (v (make-vct len)))
      (do ((i 0 (+ 1 i)))
	  ((= i len) v)
	(vct-set! v i (next-sample rs)))))
  
  (define (region2vct r c len)
    (region->vct r 0 len c))
  
  ;; extensions.scm (commented out)
  (define* (delay-channel dly (beg 0) dur snd chn edpos)
    (let ((cur-edpos (if (or (not edpos)
			     (= edpos current-edit-position))
			 (edit-position snd chn)
			 edpos)))
      (ptree-channel (lambda (y data dir)
		       (let* ((pos (floor (vct-ref data 0)))
			      (len (floor (vct-ref data 1)))
			      (val (vct-ref data (+ pos 2))))
			 (vct-set! data (+ pos 2) y)
			 (set! pos (+ 1 pos))
			 (if (>= pos len) (vct-set! data 0 0) (vct-set! data 0 pos))
			 val))
		     beg dur snd chn edpos #f
		     (lambda (fpos fdur)
		       (let ((data (make-vct (+ dly 2))))
			 (vct-set! data 0 0.0)
			 (vct-set! data 1 dly)
			 (if (= fpos 0)
			     data
			     (let* ((reader (make-sampler (- fpos 1) snd chn -1 cur-edpos)))
			       (do ((i (- dly 1) (- i 1)))
				   ((< i 0))
				 (vct-set! data (+ i 2) (reader)))
			       data)))))))
  
  (begin
    
    (set! (optimization) max-optimization) ; these trees assume optimization is on
    
    (if (playing) (snd-display #__line__ ";dac is running??"))
    (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests)) 
      (log-mem clmtest)
      
      (let ((ind (open-sound "oboe.snd")))
	(set! (transform-graph? ind 0) #t)
	(set! (transform-graph-type ind 0) graph-as-sonogram)
	(catch 'no-such-axis
	       (lambda ()
		 (set! (y-axis-label ind 0 1) "hiho"))
	       (lambda args
		 (snd-display #__line__ ";no fft axis: ~A" args)))
	(set! (fft-log-frequency ind 0) #t) ; segfault here originally
	(update-transform-graph ind 0)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd" :size 10)))
	(vct->channel (make-vct 10 1.0))
	(env-channel '(0 0 1 1 2 0))
	(let ((data (channel->vct)))
	  (if (not (vequal data (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	      (snd-display #__line__ ";pyr 10: ~A" data)))
	(undo)
	(env-channel '((0 0) (1 1) (2 0)))
	(let ((data (channel->vct)))
	  (if (not (vequal data (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	      (snd-display #__line__ ";pyr 10: ~A" data)))
	(undo)
	(env-channel (make-env '(0 0 1 1 2 0) :length 10))
	(let ((data (channel->vct)))
	  (if (not (vequal data (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	      (snd-display #__line__ ";pyr 10: ~A" data)))
	(undo)
	(close-sound ind))
      
      (for-each
       (lambda (size)
	 (let ((ind (new-sound "test.snd" :size size))
	       (incr (/ 1.0 (- size 1)))
	       (e (make-env '(0 0 1 1) :length size)))
	   (vct->channel (make-vct size 1.0))
	   
	   (ramp-channel 0.0 1.0)
	   (let ((data (channel->vct)))
	     (if (or (fneq (vct-ref data 0) 0.0)
		     (fneq (vct-ref data (- size 1)) 1.0))
		 (snd-display #__line__ ";ramp-channel ~A end points: ~A ~A" size (vct-ref data 0) (vct-ref data (- size 1))))
	     (do ((i 0 (+ 1 i)))
		 ((= i size))
	       (let ((val (envelope-interp (* i incr) '(0.0 0.0 1.0 1.0)))
		     (segval (env e)))
		 (if (or (fneq segval val)
			 (fneq (vct-ref data i) val))
		     (snd-display #__line__ ";ramp-channel ~A of ~A: ramp: ~A, interp: ~A, env: ~A" i size (vct-ref data i) val segval)))))
	   (undo)
	   (xramp-channel 0.0 1.0 32.0)
	   (let ((e (make-env '(0 0 1 1) :length size :base 32.0)))
	     (let ((data (channel->vct)))
	       (if (or (fneq (vct-ref data 0) 0.0)
		       (fneq (vct-ref data (- size 1)) 1.0))
		   (snd-display #__line__ ";xramp-channel 32 ~A end points: ~A ~A" size (vct-ref data 0) (vct-ref data (- size 1))))
	       (do ((i 0 (+ 1 i)))
		   ((= i size))
		 (let ((val (envelope-interp (* i incr) '(0.0 0.0 1.0 1.0) 32.0))
		       (segval (env e)))
		   (if (or (fneq segval val)
			   (fneq (vct-ref data i) val))
		       (snd-display #__line__ ";xramp-channel 32 ~A of ~A: ramp: ~A, interp: ~A, env: ~A" i size (vct-ref data i) val segval))))))
	   (undo)
	   (xramp-channel 0.0 1.0 0.4)
	   (let ((e (make-env '(0 0 1 1) :length size :base 0.4)))
	     (let ((data (channel->vct)))
	       (if (or (fneq (vct-ref data 0) 0.0)
		       (fneq (vct-ref data (- size 1)) 1.0))
		   (snd-display #__line__ ";xramp-channel .4 ~A end points: ~A ~A" size (vct-ref data 0) (vct-ref data (- size 1))))
	       (do ((i 0 (+ 1 i)))
		   ((= i size))
		 (let ((val (envelope-interp (* i incr) '(0.0 0.0 1.0 1.0) 0.4))
		       (segval (env e)))
		   (if (or (fneq segval val)
			   (fneq (vct-ref data i) val))
		       (snd-display #__line__ ";xramp-channel .4 ~A of ~A: ramp: ~A, interp: ~A, env: ~A" i size (vct-ref data i) val segval))))))
	   (undo)
	   (xramp-channel 1.0 -1.0 8.0)
	   (let ((e (make-env '(0 1 1 -1) :length size :base 8.0)))
	     (let ((data (channel->vct)))
	       (if (or (fneq (vct-ref data 0) 1.0)
		       (fneq (vct-ref data (- size 1)) -1.0))
		   (snd-display #__line__ ";xramp-channel 1 -1 8 ~A end points: ~A ~A" size (vct-ref data 0) (vct-ref data (- size 1))))
	       (do ((i 0 (+ 1 i)))
		   ((= i size))
		 (let ((segval (env e)))
		   (if (fneq segval (vct-ref data i))
		       (snd-display #__line__ ";xramp-channel 1 -1 8 ~A of ~A: ramp: ~A, env: ~A" i size (vct-ref data i) segval))))))
	   (undo)
	   (close-sound ind)))
       (list 10 100 1000))
      
      ;; basic edit tree cases
      (let ((ind (new-sound "test.snd")))
	(if (not (= (redo) 0)) (snd-display #__line__ ";redo with no ops: ~A" (redo)))
	(if (not (= (undo) 0)) (snd-display #__line__ ";undo with no ops: ~A" (undo)))
	
	(if (not (string-=? (display-edits) (string-append "
EDITS: 0

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)
")))
	    (snd-display #__line__ ";new 0: ~A" (display-edits)))
	(insert-samples 10 10 (make-vct 10))
	(if (not (= (frames) 20)) (snd-display #__line__ ";new 1 frames: ~A" (frames)))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)

 (insert 1 20) ; insert-samples [1:4]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, cp->sounds[-1][0:8, 0.000])
   (at 10, cp->sounds[1][0:9, 1.000]) [buf: 10] 
   (at 20, end_mark)
")))
	    (snd-display #__line__ ";new 1: ~A" (display-edits)))
	(undo)
	(insert-samples 0 10 (make-vct 10))
	(if (not (= (frames) 11)) (snd-display #__line__ ";new 2 frames: ~A" (frames))) ; 11 because there was 1 sample when new-sound created 
	(if (not (string-=? (display-edits) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)

 (insert 0 10) ; insert-samples [1:3]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 10] 
   (at 10, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 11, end_mark)
")))
	    (snd-display #__line__ ";new 2: ~A" (display-edits)))
	(let ((eds (undo 2)))
	  (if (not (= eds 2)) (snd-display #__line__ ";new 3 undo: ~A" eds)))
	(insert-samples 0 10 (make-vct 10))
	(if (not (= (frames) 11)) (snd-display #__line__ ";new 3 frames: ~A" (frames)))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)

 (insert 0 10) ; insert-samples [1:3]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 10] 
   (at 10, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 11, end_mark)
")))
	    (snd-display #__line__ ";new 3: ~A" (display-edits)))
	(undo)
	(set! (sample 0) .5)
	(if (not (= (frames) 1)) (snd-display #__line__ ";new 4 frames: ~A" (frames)))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)

 (set 0 1) ; set-sample 0 0.5000 [1:2]:
   (at 0, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 1, end_mark)
")))
	    (snd-display #__line__ ";new 4: ~A" (display-edits)))      
	(undo)
	
	(set! (samples 0 10) (make-vct 10))
	(if (not (= (frames) 10)) (snd-display #__line__ ";new 5 frames: ~A" (frames)))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)

 (set 0 10) ; set-samples [1:2]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
")))
	    (snd-display #__line__ ";new 5: ~A" (display-edits)))
	
	(delete-samples 3 4)
	(if (not (= (frames) 6)) (snd-display #__line__ ";new 6 frames: ~A" (frames)))
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (delete 3 4) ; delete-samples 3 4 [2:3]:
   (at 0, cp->sounds[1][0:2, 1.000]) [buf: 10] 
   (at 3, cp->sounds[1][7:9, 1.000]) [buf: 10] 
   (at 6, end_mark)
"))
	    (snd-display #__line__ ";new 6: ~A" (safe-display-edits ind 0 2)))
	
	(set! (samples 1 4) (make-vct 4))
	(if (not (= (frames) 6)) (snd-display #__line__ ";new 7 frames: ~A" (frames)))
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (set 1 4) ; set-samples [3:4]:
   (at 0, cp->sounds[1][0:0, 1.000]) [buf: 10] 
   (at 1, cp->sounds[2][0:3, 1.000]) [buf: 4] 
   (at 5, cp->sounds[1][9:9, 1.000]) [buf: 10] 
   (at 6, end_mark)
"))
	    (snd-display #__line__ ";new 7: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	(insert-samples 2 3 (make-vct 3))
	(insert-samples 2 1 (make-vct 1))
	(insert-samples 4 1 (make-vct 1))
	(insert-samples 15 1 (make-vct 1))
	(if (not (= (frames) 16)) (snd-display #__line__ ";new 8 frames: ~A" (frames)))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 5

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:0, 0.000]) [file: " cwd "test.snd[0]]
   (at 1, end_mark)

 (set 0 10) ; set-samples [1:2]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 10] 
   (at 10, end_mark)

 (insert 2 3) ; insert-samples [2:4]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[2][0:2, 1.000]) [buf: 3] 
   (at 5, cp->sounds[1][2:9, 1.000]) [buf: 10] 
   (at 13, end_mark)

 (insert 2 1) ; insert-samples [3:5]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[3][0:0, 1.000]) [buf: 1] 
   (at 3, cp->sounds[2][0:2, 1.000]) [buf: 3] 
   (at 6, cp->sounds[1][2:9, 1.000]) [buf: 10] 
   (at 14, end_mark)

 (insert 4 1) ; insert-samples [4:7]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[3][0:0, 1.000]) [buf: 1] 
   (at 3, cp->sounds[2][0:0, 1.000]) [buf: 3] 
   (at 4, cp->sounds[4][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[2][1:2, 1.000]) [buf: 3] 
   (at 7, cp->sounds[1][2:9, 1.000]) [buf: 10] 
   (at 15, end_mark)

 (insert 15 1) ; insert-samples [5:8]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[3][0:0, 1.000]) [buf: 1] 
   (at 3, cp->sounds[2][0:0, 1.000]) [buf: 3] 
   (at 4, cp->sounds[4][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[2][1:2, 1.000]) [buf: 3] 
   (at 7, cp->sounds[1][2:9, 1.000]) [buf: 10] 
   (at 15, cp->sounds[5][0:0, 1.000]) [buf: 1] 
   (at 16, end_mark)
")))
	    (snd-display #__line__ ";new 8: ~A" (display-edits)))
	(delete-samples 2 1)
	(if (not (string-=? (safe-display-edits ind 0 6) "
 (delete 2 1) ; delete-samples 2 1 [6:7]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[2][0:0, 1.000]) [buf: 3] 
   (at 3, cp->sounds[4][0:0, 1.000]) [buf: 1] 
   (at 4, cp->sounds[2][1:2, 1.000]) [buf: 3] 
   (at 6, cp->sounds[1][2:9, 1.000]) [buf: 10] 
   (at 14, cp->sounds[5][0:0, 1.000]) [buf: 1] 
   (at 15, end_mark)
"))
	    (snd-display #__line__ ";new 9: ~A" (safe-display-edits ind 0 6)))
	(delete-samples 0 5)
	(if (not (string-=? (safe-display-edits ind 0 7) "
 (delete 0 5) ; delete-samples 0 5 [7:4]:
   (at 0, cp->sounds[2][2:2, 1.000]) [buf: 3] 
   (at 1, cp->sounds[1][2:9, 1.000]) [buf: 10] 
   (at 9, cp->sounds[5][0:0, 1.000]) [buf: 1] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";new 10: ~A" (safe-display-edits ind 0 7)))
	(delete-samples 6 4)
	(if (not (string-=? (safe-display-edits ind 0 8) "
 (delete 6 4) ; delete-samples 6 4 [8:3]:
   (at 0, cp->sounds[2][2:2, 1.000]) [buf: 3] 
   (at 1, cp->sounds[1][2:6, 1.000]) [buf: 10] 
   (at 6, end_mark)
"))
	    (snd-display #__line__ ";new 11: ~A" (safe-display-edits ind 0 8)))
	(delete-samples 0 1)
	(if (not (string-=? (safe-display-edits ind 0 9) "
 (delete 0 1) ; delete-samples 0 1 [9:2]:
   (at 0, cp->sounds[1][2:6, 1.000]) [buf: 10] 
   (at 5, end_mark)
"))
	    (snd-display #__line__ ";new 12: ~A" (safe-display-edits ind 0 9)))
	
	(delete-samples 0 5)
	(if (not (string-=? (safe-display-edits ind 0 10) "
 (delete 0 5) ; delete-samples 0 5 [10:1]:
   (at 0, end_mark)
"))
	    (snd-display #__line__ ";new 13: ~A" (safe-display-edits ind 0 10)))
	(delete-samples 0 10)
	(if (not (= (edit-position) 10))
	    (snd-display #__line__ ";no-op delete deleted something! ~A" (display-edits)))
	(insert-samples 0 3 (make-vct 3))
	(if (not (string-=? (safe-display-edits ind 0 11) "
 (insert 0 3) ; insert-samples [11:2]:
   (at 0, cp->sounds[6][0:2, 1.000]) [buf: 3] 
   (at 3, end_mark)
"))
	    (snd-display #__line__ ";new 14: ~A" (safe-display-edits ind 0 11)))
	(delete-samples 2 1)
	(if (not (string-=? (safe-display-edits ind 0 12) "
 (delete 2 1) ; delete-samples 2 1 [12:2]:
   (at 0, cp->sounds[6][0:1, 1.000]) [buf: 3] 
   (at 2, end_mark)
"))
	    (snd-display #__line__ ";new 15: ~A" (safe-display-edits ind 0 12)))
	(set! (sample 0) .5)
	(if (not (string-=? (safe-display-edits ind 0 13) "
 (set 0 1) ; set-sample 0 0.5000 [13:3]:
   (at 0, cp->sounds[7][0:0, 1.000]) [buf: 1] 
   (at 1, cp->sounds[6][1:1, 1.000]) [buf: 3] 
   (at 2, end_mark)
"))
	    (snd-display #__line__ ";new 16: ~A" (safe-display-edits ind 0 13)))
	(set! (sample 1) .5)
	(if (not (string-=? (safe-display-edits ind 0 14) "
 (set 1 1) ; set-sample 1 0.5000 [14:3]:
   (at 0, cp->sounds[7][0:0, 1.000]) [buf: 1] 
   (at 1, cp->sounds[8][0:0, 1.000]) [buf: 1] 
   (at 2, end_mark)
"))
	    (snd-display #__line__ ";new 17: ~A" (safe-display-edits ind 0 14)))  
	(map-channel (lambda (y) 1.0) 0 10)
	(if (not (string-=? (safe-display-edits ind 0 15) "
 (set 0 10) ; map-channel [15:2]:
   (at 0, cp->sounds[9][0:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";new 18: ~A" (safe-display-edits ind 0 15)))  
	(insert-samples 0 10 (make-vct 10))
	(if (not (string-=? (safe-display-edits ind 0 16) "
 (insert 0 10) ; insert-samples [16:3]:
   (at 0, cp->sounds[10][0:9, 1.000]) [buf: 10] 
   (at 10, cp->sounds[9][0:9, 1.000]) [buf: 10] 
   (at 20, end_mark)
"))
	    (snd-display #__line__ ";new 19: ~A" (safe-display-edits ind 0 16)))
	(set! (samples 2 3) (make-vct 3))
	(if (not (string-=? (safe-display-edits ind 0 17) "
 (set 2 3) ; set-samples [17:5]:
   (at 0, cp->sounds[10][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[11][0:2, 1.000]) [buf: 3] 
   (at 5, cp->sounds[10][5:9, 1.000]) [buf: 10] 
   (at 10, cp->sounds[9][0:9, 1.000]) [buf: 10] 
   (at 20, end_mark)
"))
	    (snd-display #__line__ ";new 20: ~A" (safe-display-edits ind 0 17)))
	(set! (samples 0 12) (make-vct 12))
	(if (not (string-=? (safe-display-edits ind 0 18) "
 (set 0 12) ; set-samples [18:3]:
   (at 0, cp->sounds[12][0:11, 1.000]) [buf: 12] 
   (at 12, cp->sounds[9][2:9, 1.000]) [buf: 10] 
   (at 20, end_mark)
"))
	    (snd-display #__line__ ";new 21: ~A" (safe-display-edits ind 0 18)))
	(set! (samples 30 10) (make-vct 10))
	(if (not (string-=? (safe-display-edits ind 0 19) "
 (set 20 21) ; set-samples [19:5]:
   (at 0, cp->sounds[12][0:11, 1.000]) [buf: 12] 
   (at 12, cp->sounds[9][2:9, 1.000]) [buf: 10] 
   (at 20, cp->sounds[-1][0:9, 0.000])
   (at 30, cp->sounds[13][0:9, 1.000]) [buf: 10] 
   (at 40, end_mark)
"))
	    (snd-display #__line__ ";new 21: ~A" (safe-display-edits ind 0 19)))
	(close-sound ind))
      
      ;; scale/ramp
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 10)
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (scale 0 10) ; scale-channel 0.500 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 0.500]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 0: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 0 3)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (scale 0 3) ; scale-channel 0.500 0 3 [2:3]:
   (at 0, cp->sounds[1][0:2, 0.500]) [buf: 10] 
   (at 3, cp->sounds[1][3:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 1: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 5 5)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (scale 5 5) ; scale-channel 0.500 5 5 [2:3]:
   (at 0, cp->sounds[1][0:4, 1.000]) [buf: 10] 
   (at 5, cp->sounds[1][5:9, 0.500]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 2: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (scale 2 4) ; scale-channel 0.500 2 4 [2:4]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:5, 0.500]) [buf: 10] 
   (at 6, cp->sounds[1][6:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 2a: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 10 10)
	(if (not (= (edit-position) 1))
	    (snd-display #__line__ ";scale beyond end edited? ~A" (display-edits)))
	(scale-channel 0.5 100 10)
	(if (not (= (edit-position) 1))
	    (snd-display #__line__ ";scale way beyond end edited? ~A" (display-edits)))
	(scale-channel 0.5 5 10)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (scale 5 5) ; scale-channel 0.500 5 5 [2:3]:
   (at 0, cp->sounds[1][0:4, 1.000]) [buf: 10] 
   (at 5, cp->sounds[1][5:9, 0.500]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 3: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (set 4 1) ; set-sample 4 0.5000 [2:4]:
   (at 0, cp->sounds[1][0:3, 1.000]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 4: ~A" (safe-display-edits ind 0 2)))
	(scale-channel 0.5 0 4)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 4) ; scale-channel 0.500 0 4 [3:4]:
   (at 0, cp->sounds[1][0:3, 0.500]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 5: ~A" (safe-display-edits ind 0 3)))
	(scale-channel 0.5 4 1)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 4 1) ; scale-channel 0.500 4 1 [4:4]:
   (at 0, cp->sounds[1][0:3, 0.500]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 0.500]) [buf: 1] 
   (at 5, cp->sounds[1][5:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 6: ~A" (safe-display-edits ind 0 4)))
	(scale-channel 0.5 0 7)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 7) ; scale-channel 0.500 0 7 [5:5]:
   (at 0, cp->sounds[1][0:3, 0.250]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 0.250]) [buf: 1] 
   (at 5, cp->sounds[1][5:6, 0.500]) [buf: 10] 
   (at 7, cp->sounds[1][7:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 7: ~A" (safe-display-edits ind 0 5)))
	(scale-channel 0.5 1 4)
	(if (not (string-=? (safe-display-edits ind 0 6) "
 (scale 1 4) ; scale-channel 0.500 1 4 [6:6]:
   (at 0, cp->sounds[1][0:0, 0.250]) [buf: 10] 
   (at 1, cp->sounds[1][1:3, 0.125]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 0.125]) [buf: 1] 
   (at 5, cp->sounds[1][5:6, 0.500]) [buf: 10] 
   (at 7, cp->sounds[1][7:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 8: ~A" (safe-display-edits ind 0 6)))
	(undo 4)
	(scale-channel 0.5 1 8)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 1 8) ; scale-channel 0.500 1 8 [3:6]:
   (at 0, cp->sounds[1][0:0, 1.000]) [buf: 10] 
   (at 1, cp->sounds[1][1:3, 0.500]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 0.500]) [buf: 1] 
   (at 5, cp->sounds[1][5:8, 0.500]) [buf: 10] 
   (at 9, cp->sounds[1][9:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";scl 9: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 0 10) ; ramp-channel 0.000 1.000 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]-0.000 -> 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 0: ~A" (safe-display-edits ind 0 2)))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 10) ; scale-channel 0.500 0 #f [3:2]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]-0.000 -> 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 1: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 5) ; scale-channel 0.500 0 5 [3:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]-0.000 -> 0.444]) [buf: 10] 
   (at 5, cp->sounds[1][5:9, 1.000, [1]0.556 -> 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 2: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 2 4) ; scale-channel 0.500 2 4 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.111]) [buf: 10] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.222 -> 0.556]) [buf: 10] 
   (at 6, cp->sounds[1][6:9, 1.000, [1]0.667 -> 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 3: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 5 5)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 5 5) ; scale-channel 0.500 5 5 [3:3]:
   (at 0, cp->sounds[1][0:4, 1.000, [1]-0.000 -> 0.444]) [buf: 10] 
   (at 5, cp->sounds[1][5:9, 0.500, [1]0.556 -> 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 4: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 2 6) ; ramp-channel 0.200 0.600 2 6 [2:4]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 5: ~A" (safe-display-edits ind 0 2)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 5) ; scale-channel 0.500 0 5 [3:5]:
   (at 0, cp->sounds[1][0:1, 0.500]) [buf: 10] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.360]) [buf: 10] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 6: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 2 6)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 2 6) ; scale-channel 0.500 2 6 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:7, 0.500, [1]0.200 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 7: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 5 4)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 5 4) ; scale-channel 0.500 5 4 [3:6]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:4, 1.000, [1]0.200 -> 0.360]) [buf: 10] 
   (at 5, cp->sounds[1][5:7, 0.500, [1]0.440 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:8, 0.500]) [buf: 10] 
   (at 9, cp->sounds[1][9:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 8: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (set 4 1) ; set-sample 4 0.5000 [3:6]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 9: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 4 1)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 4 1) ; scale-channel 0.500 4 1 [3:6]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][4:4, 0.500, [1]0.360 -> 0.360]) [buf: 10] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 10: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(delete-sample 4)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 1) ; delete-samples 4 1 [3:5]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600]) [buf: 10] 
   (at 7, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 9, end_mark)
"))
	    (snd-display #__line__ ";ramp 11: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(delete-samples 4 2)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 2) ; delete-samples 4 2 [3:5]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][6:7, 1.000, [1]0.520 -> 0.600]) [buf: 10] 
   (at 6, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 8, end_mark)
"))
	    (snd-display #__line__ ";ramp 12: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(delete-samples 4 3)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 3) ; delete-samples 4 3 [3:5]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][7:7, 1.000, [1]0.600 -> 0.600]) [buf: 10] 
   (at 5, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 7, end_mark)
"))
	    (snd-display #__line__ ";ramp 13: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(delete-samples 4 4)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 4) ; delete-samples 4 4 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 6, end_mark)
"))
	    (snd-display #__line__ ";ramp 14: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(delete-samples 4 5)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 5) ; delete-samples 4 5 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][9:9, 1.000]) [buf: 10] 
   (at 5, end_mark)
"))
	    (snd-display #__line__ ";ramp 15: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 4 2)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 4 2) ; scale-channel 0.500 4 2 [3:6]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[1][4:5, 0.500, [1]0.360 -> 0.440]) [buf: 10] 
   (at 6, cp->sounds[1][6:7, 1.000, [1]0.520 -> 0.600]) [buf: 10] 
   (at 8, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";ramp 16: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(pad-channel 4 1)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (silence 4 1) ; pad-channel [3:6]:
   (at 0, cp->sounds[1][0:1, 1.000]) [buf: 10] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280]) [buf: 10] 
   (at 4, cp->sounds[-1][0:0, 0.000])
   (at 5, cp->sounds[1][4:7, 1.000, [1]0.360 -> 0.600]) [buf: 10] 
   (at 9, cp->sounds[1][8:9, 1.000]) [buf: 10] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp 17: ~A" (safe-display-edits ind 0 3)))
	(close-sound ind))
      
      ;; xramp
      (let ((ind (new-sound "test.snd"))) ; 2nd main let
	(map-channel (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 0 10) ; xramp-channel 0.000 1.000 32.000 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";xramp 1: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.0 1.0 0.325)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 0 10) ; xramp-channel 0.000 1.000 0.325 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 1.000, off: 1.481, scl: -1.481]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";xramp 2: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.0 1.0 0.0)
	(if (not (string-=? (safe-display-edits ind 0 2) (string-append "
 (scale 0 10) ; scale-channel 0.000 0 #f [2:2]:
   (at 0, cp->sounds[0][0:9, 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 10, end_mark)
")))
	    (snd-display #__line__ ";xramp 3: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.0 1.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 0 10) ; ramp-channel 0.000 1.000 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]-0.000 -> 1.000]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";xramp 4: ~A" (safe-display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.5 1.5 32.0)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 0 10) ; xramp-channel 0.500 1.500 32.000 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]0.500 -> 1.500, off: 0.468, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";xramp 5: ~A" (safe-display-edits ind 0 2)))
	(if (or (fneq (maxamp) 1.5) (fneq (sample 0) 0.5))
	    (snd-display #__line__ ";xramp 5 vals: ~A ~A" (maxamp) (sample 0)))
	(undo)
	(xramp-channel -0.5 1.5 32.0)
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ramp 0 10) ; xramp-channel -0.500 1.500 32.000 0 #f [2:2]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]-0.500 -> 1.500, off: -0.565, scl: 0.065]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display #__line__ ";xramp 6: ~A" (safe-display-edits ind 0 2)))
	(if (or (fneq (maxamp) 1.5) (fneq (sample 0) -0.5))
	    (snd-display #__line__ ";xramp 6 vals: ~A ~A" (maxamp) (sample 0)))
	(undo)
	(xramp-channel 0.0 1.0 32.0)
	(let ((vals (channel->vct))
	      (ctr 0))
	  (scale-channel 0.5)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 10) ; scale-channel 0.500 0 #f [3:2]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display #__line__ ";xramp 7: ~A" (safe-display-edits ind 0 3)))
	  (set! ctr 0)
	  (let ((baddy (scan-chan (lambda (y) (if (fneq y (* 0.5 (vct-ref vals ctr))) #t (begin (set! ctr (+ 1 ctr)) #f))))))
	    (if baddy (snd-display #__line__ ";trouble in xramp 7: ~A" baddy)))
	  (undo)
	  (delete-sample 0)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 0 1) ; delete-samples 0 1 [3:2]:
   (at 0, cp->sounds[1][1:9, 1.000, [1]0.015 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 9, end_mark)
"))
	      (snd-display #__line__ ";xramp 8: ~A" (safe-display-edits ind 0 3)))
	  (set! ctr 1)
	  (let ((baddy (scan-chan (lambda (y) (if (fneq y (vct-ref vals ctr)) #t (begin (set! ctr (+ 1 ctr)) #f))))))
	    (if baddy (snd-display #__line__ ";trouble in xramp 8: ~A" baddy)))
	  (undo)
	  (delete-samples 0 2)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 0 2) ; delete-samples 0 2 [3:2]:
   (at 0, cp->sounds[1][2:9, 1.000, [1]0.037 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 8, end_mark)
"))
	      (snd-display #__line__ ";xramp 9: ~A" (safe-display-edits ind 0 3)))
	  (set! ctr 2)
	  (let ((baddy (scan-chan (lambda (y) (if (fneq y (vct-ref vals ctr)) #t (begin (set! ctr (+ 1 ctr)) #f))))))
	    (if baddy (snd-display #__line__ ";trouble in xramp 9: ~A" baddy)))
	  (undo)
	  (delete-sample 0)
	  (delete-sample 0)
	  (if (not (string-=? (safe-display-edits ind 0 4) "
 (delete 0 1) ; delete-samples 0 1 [4:2]:
   (at 0, cp->sounds[1][2:9, 1.000, [1]0.037 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 8, end_mark)
"))
	      (snd-display #__line__ ";xramp 10: ~A" (safe-display-edits ind 0 4)))
	  (undo 2)
	  (delete-sample 4)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 1) ; delete-samples 4 1 [3:3]:
   (at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[1][5:9, 1.000, [1]0.189 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 9, end_mark)
"))
	      (snd-display #__line__ ";xramp 11: ~A" (safe-display-edits ind 0 3)))
	  (undo)
	  (delete-samples 4 2)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (delete 4 2) ; delete-samples 4 2 [3:3]:
   (at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[1][6:9, 1.000, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 8, end_mark)
"))
	      (snd-display #__line__ ";xramp 12: ~A" (safe-display-edits ind 0 3)))
	  (undo)
	  (scale-channel 0.5 4 2)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 4 2) ; scale-channel 0.500 4 2 [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[1][4:5, 0.500, [1]0.118 -> 0.189, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 6, cp->sounds[1][6:9, 1.000, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display #__line__ ";xramp 13: ~A" (safe-display-edits ind 0 3)))
	  (set! ctr 0)
	  (let ((baddy (scan-chan (lambda (y)
				    (if (or (and (> ctr 5) (fneq y (vct-ref vals ctr)))
					    (and (< ctr 4) (fneq y (vct-ref vals ctr)))
					    (and (or (= ctr 4) (= ctr 5)) (fneq y (* 0.5 (vct-ref vals ctr)))))
					#t
					(begin (set! ctr (+ 1 ctr)) #f))))))
	    (if baddy (snd-display #__line__ ";trouble in xramp 8: ~A" baddy)))
	  (undo)
	  (scale-channel 0.5 0 2)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 2) ; scale-channel 0.500 0 2 [3:3]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]0.000 -> 0.015, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 2, cp->sounds[1][2:9, 1.000, [1]0.037 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display #__line__ ";xramp 14: ~A" (safe-display-edits ind 0 3)))
	  (undo)
	  (pad-channel 4 2)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (silence 4 2) ; pad-channel [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[-1][0:1, 0.000])
   (at 6, cp->sounds[1][4:9, 1.000, [1]0.118 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 12, end_mark)
"))
	      (snd-display #__line__ ";xramp 15: ~A" (safe-display-edits ind 0 3)))
	  (undo)
	  (set! (sample 4) 1.0)
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (set 4 1) ; set-sample 4 1.0000 [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:9, 1.000, [1]0.189 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display #__line__ ";xramp 16: ~A" (safe-display-edits ind 0 3)))
	  (undo)
	  (set! (samples 4 2) (make-vct 2))
	  (if (not (string-=? (safe-display-edits ind 0 3) "
 (set 4 2) ; set-samples [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[2][0:1, 1.000]) [buf: 2] 
   (at 6, cp->sounds[1][6:9, 1.000, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display #__line__ ";xramp 17: ~A" (safe-display-edits ind 0 3)))
	  (undo)
	  (scale-channel 0.5)
	  (set! (samples 4 2) (make-vct 2))
	  (if (not (string-=? (safe-display-edits ind 0 4) "
 (set 4 2) ; set-samples [4:4]:
   (at 0, cp->sounds[1][0:3, 0.500, [1]0.000 -> 0.070, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[2][0:1, 1.000]) [buf: 2] 
   (at 6, cp->sounds[1][6:9, 0.500, [1]0.293 -> 1.000, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display #__line__ ";xramp 18: ~A" (safe-display-edits ind 0 4)))
	  )
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd"))) ; 3rd
	(map-channel (lambda (y) 1.0) 0 100)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(ramp-channel 0.0 1.0)
	(if (not (string=? (safe-display-edits ind 0 12) "
 (ramp 0 100) ; ramp-channel 0.000 1.000 0 #f [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp 1: ~A" (safe-display-edits ind 0 12)))
	(if (fneq (maxamp) 0.5) (snd-display #__line__ ";multi ramp 1 maxamp: ~A" (maxamp)))
	(undo)
	(ramp-channel 0.1 1.0 10 90)
	(if (not (string=? (safe-display-edits ind 0 12) "
 (ramp 10 90) ; ramp-channel 0.100 1.000 10 90 [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.100 -> 0.191]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.201 -> 0.292]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.302 -> 0.393]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.403 -> 0.494]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.504 -> 0.596]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp 2: ~A" (safe-display-edits ind 0 12)))
	(if (fneq (maxamp) 0.5) (snd-display #__line__ ";multi ramp 2 maxamp: ~A" (maxamp)))
	(undo)
	(ramp-channel 0.0 0.9 0 90)
	(if (not (string=? (safe-display-edits ind 0 12) "
 (ramp 0 90) ; ramp-channel 0.000 0.900 0 90 [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.496]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.506 -> 0.597]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.607 -> 0.698]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.708 -> 0.799]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.809 -> 0.900]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp 3: ~A" (safe-display-edits ind 0 12)))
	(if (fneq (maxamp) 0.5) (snd-display #__line__ ";multi ramp 3 maxamp: ~A" (maxamp)))
	(if (fneq (sample 89) 0.45) (snd-display #__line__ ";multi ramp 3 sample 89: ~A" (sample 89)))
	(if (fneq (sample 90) 0.5) (snd-display #__line__ ";multi ramp 3 sample 90: ~A" (sample 90)))
	(undo)
	(ramp-channel 0.1 0.9 10 80)
	(if (not (string=? (safe-display-edits ind 0 12) "
 (ramp 10 80) ; ramp-channel 0.100 0.900 10 80 [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.100 -> 0.191]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.201 -> 0.292]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.708 -> 0.799]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.809 -> 0.900]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp 4: ~A" (safe-display-edits ind 0 12)))
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(ramp-channel 0.0 1.0)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(if (not (string=? (safe-display-edits ind 0 12) "
 (scale 90 10) ; scale-channel 0.500 90 10 [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp 5: ~A" (safe-display-edits ind 0 12)))
	(close-sound ind))
      
      
      (let ((ind (new-sound "test.snd")))
	
	;; ptree+scale
	(map-channel (lambda (y) 1.0) 0 100)
	(cosine-channel 0 100)
	(let ((map-data (channel->vct)))
	  (undo)
	  (cosine-channel-via-ptree 0 100)
	  (let ((tree-data (channel->vct)))
	    (if (not (vequal map-data tree-data))
		(snd-display #__line__ ";map and ptree cosine disagree: ~A ~A" map-data tree-data)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (if (not (string=? (safe-display-edits ind 0 12 #f) "
 (scale 90 10) ; scale-channel 0.500 90 10 [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, loc: 0, pos: 10, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, loc: 0, pos: 20, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, loc: 0, pos: 30, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, loc: 0, pos: 40, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, loc: 0, pos: 50, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, loc: 0, pos: 60, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, loc: 0, pos: 70, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, loc: 0, pos: 80, scl: 1.000]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, loc: 0, pos: 90, scl: 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 0: ~A" (safe-display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and ptree->scl cosine disagree: ~%  ~A~%  ~A" map-data scl-data)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (cosine-channel-via-ptree 0 100)
	  (if (not (string=? (safe-display-edits ind 0 12 #f) "
 (ptree[0] 0 100) ; ptree-channel [12:11]:
   (at 0, cp->sounds[1][0:9, 1.000, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, loc: 0, pos: 80, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 1.000, loc: 0, pos: 90, scl: 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 1: ~A" (safe-display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and scl->ptree cosine disagree: ~A ~A" map-data scl-data)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (cosine-channel 10 90)
	  (set! map-data (channel->vct))
	  
	  (undo)
	  (cosine-channel-via-ptree 10 90)
	  (let ((tree-data (channel->vct)))
	    (if (not (vequal map-data tree-data))
		(snd-display #__line__ ";map and ptree 10:90 cosine disagree: ~A ~A" map-data tree-data)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (if (not (string-=? (safe-display-edits ind 0 12 #f) "
 (scale 90 10) ; scale-channel 0.500 90 10 [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, loc: 0, pos: 10, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, loc: 0, pos: 20, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, loc: 0, pos: 30, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, loc: 0, pos: 40, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, loc: 0, pos: 50, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, loc: 0, pos: 60, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, loc: 0, pos: 70, scl: 1.000]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, loc: 0, pos: 80, scl: 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 2: ~A" (safe-display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and scl->ptree 10:90 cosine disagree: ~A ~A" map-data scl-data)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (cosine-channel 10 80)
	  (set! map-data (channel->vct))
	  (undo)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (cosine-channel-via-ptree 10 80)
	  (let ((tree-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data tree-data))
		(snd-display #__line__ ";map and ptree 10:80 cosine disagree: ~A ~A" map-data tree-data)))
	  (if (not (string-=? (safe-display-edits ind 0 12 #f) "
 (ptree[0] 10 80) ; ptree-channel [12:11]:
   (at 0, cp->sounds[1][0:9, 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 3: ~A" (safe-display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and scl->ptree 10:80 cosine disagree: ~A ~A" map-data scl-data)))
	  
	  ;; ptree + ramp
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (env-channel '(0 0 1 1))
	  (cosine-channel 0 100)
	  (set! map-data (channel->vct))
	  (undo)
	  (cosine-channel-via-ptree 0 100)
	  (let ((tree-data (channel->vct)))
	    (if (not (vequal map-data tree-data))
		(snd-display #__line__ ";ptree->ramp cosine disagree: ~A ~A" map-data tree-data)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (scale 90 10) ; scale-channel 0.500 90 10 [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, loc: 0, pos: 10, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, loc: 0, pos: 20, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, loc: 0, pos: 30, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, loc: 0, pos: 40, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, loc: 0, pos: 50, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, loc: 0, pos: 60, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, loc: 0, pos: 70, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, loc: 0, pos: 80, scl: 1.000]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, loc: 0, pos: 90, scl: 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 4: ~A" (safe-display-edits ind 0 13 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and (scl) ptree->ramp cosine disagree: ~A ~A" map-data scl-data)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (env-channel '((0 0) (1 1)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (cosine-channel-via-ptree 0 100)
	  (if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (ptree[0] 0 100) ; ptree-channel [13:11]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 0.091, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [1]0.101 -> 0.192, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [1]0.202 -> 0.293, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [1]0.303 -> 0.394, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [1]0.404 -> 0.495, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.505 -> 0.596, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [1]0.606 -> 0.697, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [1]0.707 -> 0.798, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [1]0.808 -> 0.899, loc: 0, pos: 80, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 1.000, [1]0.909 -> 1.000, loc: 0, pos: 90, scl: 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 5: ~A" (safe-display-edits ind 0 13 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and ptree->ramp (scl) cosine disagree: ~A ~A" map-data scl-data)))
	  
	  (scale-channel 0.5)
	  (if (not (string-=? (safe-display-edits ind 0 14 #f) "
 (scale 0 100) ; scale-channel 0.500 0 #f [14:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, loc: 0, pos: 80, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, loc: 0, pos: 90, scl: 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 5 + scl: ~A" (safe-display-edits ind 0 14 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 4.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";map and ptree->ramp (scl twice) cosine disagree: ~A ~A" map-data scl-data)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (env-channel '(0 0 1 1))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (cosine-channel-via-ptree 10 80)
	  (set! map-data (channel->vct))
	  (if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (ptree[0] 10 80) ; ptree-channel [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [1]0.101 -> 0.192, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [1]0.202 -> 0.293, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [1]0.303 -> 0.394, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [1]0.404 -> 0.495, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.505 -> 0.596, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [1]0.606 -> 0.697, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [1]0.707 -> 0.798, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [1]0.808 -> 0.899, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 6: ~A" (safe-display-edits ind 0 13 #f)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (env-channel '(0 0 1 1))
	  (cosine-channel-via-ptree 10 80)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (let ((scl-data (channel->vct)))
	    (if (not (vequal map-data scl-data))
		(snd-display #__line__ ";ptree+ramp order matters? ~A ~A" map-data scl-data)))
	  
	  (revert-sound)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (env-channel '(0 0 1 1))
	  (cosine-channel-via-ptree 15 70)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (scale 90 10) ; scale-channel 0.500 90 10 [13:13]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091]) [buf: 100] 
   (at 10, cp->sounds[1][10:14, 0.500, [1]0.101 -> 0.141]) [buf: 100] 
   (at 15, cp->sounds[1][15:19, 0.500, [1]0.152 -> 0.192, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, loc: 0, pos: 5, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, loc: 0, pos: 15, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, loc: 0, pos: 25, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, loc: 0, pos: 35, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, loc: 0, pos: 45, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, loc: 0, pos: 55, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:84, 0.500, [1]0.808 -> 0.848, loc: 0, pos: 65, scl: 1.000]) [buf: 100] 
   (at 85, cp->sounds[1][85:89, 0.500, [1]0.859 -> 0.899]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";multi-tree 7: ~A" (safe-display-edits ind 0 13 #f)))
	  (close-sound ind)))
      
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 100)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.75 (* i 10) 10))
	(ptree-channel (lambda (y data forward)
			 (* y (vct-ref data 0)))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct 0.5)))
	(ptree-channel (lambda (y data forward)
			 (* y (vct-ref data 0)))
		       20 45 ind 0 #f #f
		       (lambda (pos dur)
			 (vct 0.25)))
	(let ((data (channel->vct))
	      (orig (make-vct 100 1.0)))
	  (vct-scale! orig 0.75) ; scale-channel
	  (vct-scale! orig 0.5)  ; ptree-channel
	  (do ((i 20 (+ 1 i)))
	      ((= i 65))
	    (vct-set! orig i (* (vct-ref orig i) .25)))
	  (if (not (vvequal orig data))
	      (snd-display #__line__ ";p2 pos test data: ~A" data))
	  (if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (ptree[1] 20 45) ; ptree-channel [13:12]:
   (at 0, cp->sounds[1][0:9, 1.000, loc: 0, pos: 0, scl: 0.750]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, loc: 0, pos: 10, scl: 0.750]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 20, scl: 0.750]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, loc2: 1, pos2: 10, scl2: 1.000, loc: 0, pos: 30, scl: 0.750]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, loc2: 1, pos2: 20, scl2: 1.000, loc: 0, pos: 40, scl: 0.750]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, loc2: 1, pos2: 30, scl2: 1.000, loc: 0, pos: 50, scl: 0.750]) [buf: 100] 
   (at 60, cp->sounds[1][60:64, 1.000, loc2: 1, pos2: 40, scl2: 1.000, loc: 0, pos: 60, scl: 0.750]) [buf: 100] 
   (at 65, cp->sounds[1][65:69, 1.000, loc: 0, pos: 65, scl: 0.750]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, loc: 0, pos: 70, scl: 0.750]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, loc: 0, pos: 80, scl: 0.750]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 1.000, loc: 0, pos: 90, scl: 0.750]) [buf: 100] 
   (at 100, end_mark)
"))
	      (snd-display #__line__ ";p2 pos multi: ~A" (safe-display-edits ind 0 13 #f)))
	  (close-sound ind)))
      
      (let ((ind (new-sound "test.snd"))
	    (map-data #f))
	
	;; ptree + xramp
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(env-sound '(0 0 1 1) 0 100 32.0)
	(cosine-channel 0 100)
	(set! map-data (channel->vct))
	(undo)
	(cosine-channel-via-ptree 0 100)
	(let ((tree-data (channel->vct)))
	  (if (not (vequal map-data tree-data))
	      (snd-display #__line__ ";ptree->xramp cosine disagree: ~A ~A" map-data tree-data)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (scale 90 10) ; scale-channel 0.500 90 10 [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.012, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.014 -> 0.030, off: -0.032, scl: 0.032, loc: 0, pos: 10, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.033 -> 0.057, off: -0.032, scl: 0.032, loc: 0, pos: 20, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.060 -> 0.094, off: -0.032, scl: 0.032, loc: 0, pos: 30, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.099 -> 0.147, off: -0.032, scl: 0.032, loc: 0, pos: 40, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.153 -> 0.222, off: -0.032, scl: 0.032, loc: 0, pos: 50, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.231 -> 0.329, off: -0.032, scl: 0.032, loc: 0, pos: 60, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.342 -> 0.480, off: -0.032, scl: 0.032, loc: 0, pos: 70, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.499 -> 0.695, off: -0.032, scl: 0.032, loc: 0, pos: 80, scl: 1.000]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.721 -> 1.000, off: -0.032, scl: 0.032, loc: 0, pos: 90, scl: 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-tree 9: ~A" (safe-display-edits ind 0 13 #f)))
	(let ((scl-data (vct-scale! (channel->vct) 2.0)))
	  (if (not (vequal map-data scl-data))
	      (snd-display #__line__ ";map and (scl) ptree->xramp cosine disagree: ~A ~A" map-data scl-data)))
	
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(env-sound '(0 0 1 1) 0 100 32.0)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(cosine-channel-via-ptree 0 100)
	(if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (ptree[0] 0 100) ; ptree-channel [13:11]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 0.012, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [1]0.014 -> 0.030, off: -0.032, scl: 0.032, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [1]0.033 -> 0.057, off: -0.032, scl: 0.032, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [1]0.060 -> 0.094, off: -0.032, scl: 0.032, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [1]0.099 -> 0.147, off: -0.032, scl: 0.032, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.153 -> 0.222, off: -0.032, scl: 0.032, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [1]0.231 -> 0.329, off: -0.032, scl: 0.032, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [1]0.342 -> 0.480, off: -0.032, scl: 0.032, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [1]0.499 -> 0.695, off: -0.032, scl: 0.032, loc: 0, pos: 80, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 1.000, [1]0.721 -> 1.000, off: -0.032, scl: 0.032, loc: 0, pos: 90, scl: 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-tree 10: ~A" (safe-display-edits ind 0 13 #f)))
	(let ((scl-data (vct-scale! (channel->vct) 2.0)))
	  (if (not (vequal map-data scl-data))
	      (snd-display #__line__ ";map and ptree->xramp (scl) cosine disagree: ~A ~A" map-data scl-data)))
	
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(env-sound '(0 0 1 1) 0 100 32.0)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(cosine-channel-via-ptree 10 80)
	(set! map-data (channel->vct))
	(if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (ptree[0] 10 80) ; ptree-channel [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.012, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [1]0.014 -> 0.030, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [1]0.033 -> 0.057, off: -0.032, scl: 0.032, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [1]0.060 -> 0.094, off: -0.032, scl: 0.032, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [1]0.099 -> 0.147, off: -0.032, scl: 0.032, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.153 -> 0.222, off: -0.032, scl: 0.032, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [1]0.231 -> 0.329, off: -0.032, scl: 0.032, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [1]0.342 -> 0.480, off: -0.032, scl: 0.032, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [1]0.499 -> 0.695, off: -0.032, scl: 0.032, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.721 -> 1.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-tree 11: ~A" (safe-display-edits ind 0 13 #f)))
	
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(env-sound '(0 0 1 1) 0 100 32.0)
	(cosine-channel-via-ptree 10 80)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(let ((scl-data (channel->vct)))
	  (if (not (vequal map-data scl-data))
	      (snd-display #__line__ ";ptree+xramp order matters? ~A ~A" map-data scl-data)))
	
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(env-sound '(0 0 1 1) 0 100 32.0)
	(cosine-channel-via-ptree 15 70)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(if (not (string-=? (safe-display-edits ind 0 13 #f) "
 (scale 90 10) ; scale-channel 0.500 90 10 [13:13]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.012, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:14, 0.500, [1]0.014 -> 0.020, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 15, cp->sounds[1][15:19, 0.500, [1]0.022 -> 0.030, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.033 -> 0.057, off: -0.032, scl: 0.032, loc: 0, pos: 5, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.060 -> 0.094, off: -0.032, scl: 0.032, loc: 0, pos: 15, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.099 -> 0.147, off: -0.032, scl: 0.032, loc: 0, pos: 25, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.153 -> 0.222, off: -0.032, scl: 0.032, loc: 0, pos: 35, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.231 -> 0.329, off: -0.032, scl: 0.032, loc: 0, pos: 45, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.342 -> 0.480, off: -0.032, scl: 0.032, loc: 0, pos: 55, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:84, 0.500, [1]0.499 -> 0.578, off: -0.032, scl: 0.032, loc: 0, pos: 65, scl: 1.000]) [buf: 100] 
   (at 85, cp->sounds[1][85:89, 0.500, [1]0.600 -> 0.695, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.721 -> 1.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-tree 12: ~A" (safe-display-edits ind 0 13 #f)))
	(close-sound ind))
      
      ;; ptree2
      (let ((ind (new-sound "test.snd")) ;4th
	    (case1 #f)
	    (case2 #f))
	(map-chan (lambda (y) 1.0) 0 10)
	(ptree-channel (lambda (y) (* y 0.5)))
	(if (not (vequal (channel->vct) (make-vct 11 0.5)))
	    (snd-display #__line__ ";ptree2 0: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 2) "
 (ptree[0] 0 11) ; ptree-channel [2:2]:
   (at 0, cp->sounds[1][0:10, 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* y 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2 3: ~A" (safe-display-edits ind 0 2)))
	(ptree-channel (lambda (y) (* y 1.5)))
	(if (not (vequal (channel->vct) (make-vct 11 0.75)))
	    (snd-display #__line__ ";ptree2 1: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ptree[1] 0 11) ; ptree-channel [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* y 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2 4: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(scale-by (vct 1.5))
	(if (not (vequal (channel->vct) (make-vct 11 0.75)))
	    (snd-display #__line__ ";ptree2 5: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (scale 0 11) ; scale-channel 1.500 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.500, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* y 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2 6: ~A" (safe-display-edits ind 0 3)))
	(ptree-channel (lambda (y) (* y 0.1)))
	(if (not (vequal (channel->vct) (make-vct 11 0.075)))
	    (snd-display #__line__ ";ptree2 7: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ptree[1] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, loc2: 1, pos2: 0, scl2: 1.500, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* y 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2 8: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	(scale-by '(0.5))
	(ptree-channel (lambda (y) (* y 1.5)))
	(scale-by 2.0)
	(ptree-channel (lambda (y) (* y 0.1)))
	(scale-by 3.0)
	(if (not (vequal (channel->vct) (make-vct 11 0.45)))
	    (snd-display #__line__ ";ptree2 9: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 6) "
 (scale 0 11) ; scale-channel 3.000 0 #f [6:2]:
   (at 0, cp->sounds[1][0:10, 3.000, loc2: 1, pos2: 0, scl2: 2.000, loc: 0, pos: 0, scl: 0.500, code: (lambda (y) (* y 1.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2 10: ~A" (safe-display-edits ind 0 6)))
	(undo 2)
	(ptree-channel (lambda (y) (* y 0.1)) 2 4)
	(scale-by 3.0)
	(if (not (vequal (channel->vct) (vct 4.500 4.500 0.450 0.450 0.450 0.450 4.500 4.500 4.500 4.500 4.500)))
	    (snd-display #__line__ ";ptree2 11: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 6) "
 (scale 0 11) ; scale-channel 3.000 0 #f [6:4]:
   (at 0, cp->sounds[1][0:1, 6.000, loc: 0, pos: 0, scl: 0.500, code: (lambda (y) (* y 1.5))]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 3.000, loc2: 1, pos2: 0, scl2: 2.000, loc: 0, pos: 2, scl: 0.500, code: (lambda (y) (* y 1.5))]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 6.000, loc: 0, pos: 6, scl: 0.500, code: (lambda (y) (* y 1.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2 12: ~A" (safe-display-edits ind 0 6)))
	(close-sound ind))
      
      ;; ptree2-zero
      (let ((ind (new-sound "test.snd"))
	    (case1 #f)
	    (case2 #f))
	(map-chan (lambda (y) 1.0) 0 10)
	(scale-by 0.0)
	(ptree-channel (lambda (y) (+ y 0.5)))
	(if (not (vequal (channel->vct) (make-vct 11 0.5)))
	    (snd-display #__line__ ";ptree2-zero 0: ~A" (channel->vct)))
	(ptree-channel (lambda (y) (+ y 0.25)))
	(if (not (vequal (channel->vct) (make-vct 11 0.75)))
	    (snd-display #__line__ ";ptree2-zero 1: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 4) (string-append "
 (ptree[1] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[0][0:10, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 0.000, code: (lambda (y) (+ y 0.5))]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	    (snd-display #__line__ ";ptree2-zero 2: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	(scale-channel 0.0 2 4)
	(ptree-channel (lambda (y) (+ y 0.5)))
	(ptree-channel (lambda (y) (+ y 0.25)))
	(if (not (vequal (channel->vct) (vct 1.750 1.750 0.750 0.750 0.750 0.750 1.750 1.750 1.750 1.750 1.750)))
	    (snd-display #__line__ ";ptree2-zero 3: ~A" (channel->vct)))
	
	;; ptree2-ramp
	(revert-sound)
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y .5)))
	(ptree-channel (lambda (y) (+ y .25)))
	(if (not (vequal (channel->vct) (vct 0.250 0.300 0.350 0.400 0.450 0.500 0.550 0.600 0.650 0.700 0.750)))
	    (snd-display #__line__ ";ptree2-ramp 1: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ptree[1] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* y 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2-ramp 2: ~A" (safe-display-edits ind 0 4)))
	(scale-by 0.5)
	(if (not (vequal (channel->vct) (vct 0.125 0.150 0.175 0.200 0.225 0.250 0.275 0.300 0.325 0.350 0.375)))
	    (snd-display #__line__ ";ptree2-ramp 3: ~A" (channel->vct)))
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 11) ; scale-channel 0.500 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]-0.000 -> 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* y 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree2-ramp 4: ~A" (safe-display-edits ind 0 5)))
	
	;; ptree+ramp3
	(revert-sound)
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y .5)))
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ptree[0] 0 11) ; ptree-channel [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp3: ~A" (safe-display-edits ind 0 5 #f)))
	(undo 1)
	(ptree-channel (lambda (y data forward)
			 (* y (vct-ref data 0)))
		       0 (frames) ind 0 #f #t
		       (lambda (pos dur)
			 (vct 0.5)))
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ptree[0] 0 11) ; ptree-channel [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptreec-ramp3: ~A" (safe-display-edits ind 0 5 #f)))
	(undo 4)
	(xramp-channel 0.0 1.0 32.0)
	(xramp-channel 0.0 1.0 32.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp2: ~A" (safe-display-edits ind 0 4)))
	(close-sound ind))
      
      ;; ramp2
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 0: ~A" (safe-display-edits ind 0 3)))
	(if (not (vequal (channel->vct) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ramp2 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 11) ; scale-channel 0.500 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 1: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]-0.000 -> 0.400, [2]-0.000 -> 0.400]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [2]0.500 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 2: ~A" (safe-display-edits ind 0 4)))
	(if (not (vequal (channel->vct) (vct 0.000 0.005 0.020 0.045 0.080 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ramp2 (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 2 4) ; scale-channel 0.500 2 4 [4:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.100, [2]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [2]0.200 -> 0.500]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [2]0.600 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 3: ~A" (safe-display-edits ind 0 4)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; ramp-channel 0.750 0.250 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]0.750 -> 0.250]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 4: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 2 6) ; ramp-channel 0.200 0.600 2 6 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.700, [2]0.200 -> 0.600]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 5: ~A" (safe-display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:5]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.400, [2]0.200 -> 0.360]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.440 -> 0.600]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 6: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (set 4 1) ; set-sample 4 0.5000 [4:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.300, [2]0.200 -> 0.280]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.440 -> 0.600]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 7: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 100)
	
	;; multi-ramp2
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(ramp-channel 0.0 1.0)
	(ramp-channel 1.0 0.0)
	(if (not (string-=? (safe-display-edits ind 0 13) "
 (ramp 0 100) ; ramp-channel 1.000 0.000 0 #f [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, [2]1.000 -> 0.909]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [2]0.899 -> 0.808]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [2]0.798 -> 0.707]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [2]0.697 -> 0.606]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [2]0.596 -> 0.505]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [2]0.495 -> 0.404]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [2]0.394 -> 0.303]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [2]0.293 -> 0.202]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [2]0.192 -> 0.101]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [2]0.091 -> -0.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp2 1: ~A" (safe-display-edits ind 0 13)))
	(undo 12)
	(ramp-channel 0.0 1.0 10 20)
	(ramp-channel 0.0 1.0 50 10)
	(ramp-channel 0.0 1.0 25 10)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 25 10) ; ramp-channel 0.000 1.000 25 10 [4:8]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:24, 1.000, [1]-0.000 -> 0.737]) [buf: 100] 
   (at 25, cp->sounds[1][25:29, 1.000, [1]0.789 -> 1.000, [2]-0.000 -> 0.444]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [1]0.556 -> 1.000]) [buf: 100] 
   (at 35, cp->sounds[1][35:49, 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]-0.000 -> 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:99, 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp2 2: ~A" (safe-display-edits ind 0 4)))
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	;; ramp ptree cases
	(for-each
	 (lambda (func func-zero name)
	   (func)
	   (ramp-channel 0 1)
	   (if (not (string-=? (safe-display-edits ind 0 3 #f) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	       (snd-display #__line__ ";~A 1: ~A" name (safe-display-edits ind 0 3 #f)))
	   (if (not (vequal (channel->vct) (vct 0.000 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 0.500)))
	       (snd-display #__line__ ";~A 1: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (safe-display-edits ind 0 4 #f) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	       (snd-display #__line__ ";~A 2: ~A" name (safe-display-edits ind 0 4 #f)))
	   (if (not (vequal (channel->vct) (vct 0.000 0.005 0.020 0.045 0.080 0.125 0.180 0.245 0.320 0.405 0.500)))
	       (snd-display #__line__ ";~A 2: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	       (snd-display #__line__ ";~A 3: ~A" name (safe-display-edits ind 0 5 #f)))
	   (if (not (vequal (channel->vct) (vct 0.000 0.000 0.004 0.013 0.032 0.062 0.108 0.171 0.256 0.364 0.500)))
	       (snd-display #__line__ ";~A 3: ~A" name (channel->vct)))
	   
	   (undo 4)
	   (scale-by 0.0)
	   (func-zero)
	   (ramp-channel 0 1)
	   (if (not (string-=? (safe-display-edits ind 0 4 #f) (string-append "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[0][0:10, 1.000, [1]-0.000 -> 1.000, loc: 0, pos: 0, scl: 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	       (snd-display #__line__ ";~A-zero 1: ~A" name (safe-display-edits ind 0 4 #f)))
	   (if (not (vequal (channel->vct) (vct 0.000 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 0.500)))
	       (snd-display #__line__ ";~A-zero 1: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (safe-display-edits ind 0 5 #f) (string-append "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [5:2]:
   (at 0, cp->sounds[0][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, loc: 0, pos: 0, scl: 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	       (snd-display #__line__ ";~A-zero 2: ~A" name (safe-display-edits ind 0 5 #f)))
	   (if (not (vequal (channel->vct) (vct 0.000 0.005 0.020 0.045 0.080 0.125 0.180 0.245 0.320 0.405 0.500)))
	       (snd-display #__line__ ";~A-zero 2: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (safe-display-edits ind 0 6 #f) (string-append "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [6:2]:
   (at 0, cp->sounds[0][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	       (snd-display #__line__ ";~A-zero 3: ~A" name (safe-display-edits ind 0 6 #f)))
	   (if (not (vequal (channel->vct) (vct 0.000 0.000 0.004 0.013 0.032 0.062 0.108 0.171 0.256 0.364 0.500)))
	       (snd-display #__line__ ";~A-zero 3: ~A" name (channel->vct)))
	   (undo 5)
	   )
	 (list 
	  (lambda () (ptree-channel (lambda (y) (* y 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(* y (vct-ref data 0)))
		      0 (frames) ind 0 #f #f (lambda (p d) (vct 0.5)))))
	 (list 
	  (lambda () (ptree-channel (lambda (y) (+ y 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(+ y (vct-ref data 0)))
		      0 (frames) ind 0 #f #f (lambda (p d) (vct 0.5)))))
	 (list "ramp-ptree" "ramp-ptreec"))
	
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	;; xramp ptree cases
	(for-each
	 (lambda (func func-zero name twice)
	   (func)
	   (xramp-channel 0 1 32)
	   (if (not (vequal (channel->vct) (vct 0.000 0.007 0.016 0.029 0.048 0.075 0.113 0.166 0.242 0.349 0.500)))
	       (snd-display #__line__ ";~A 1: ~A" name (channel->vct)))
	   (if twice
	       (begin
		 (xramp-channel 0 1 32)
		 (if (not (vequal (channel->vct) (vct 0.000 0.000 0.001 0.002 0.005 0.011 0.025 0.055 0.117 0.243 0.500)))
		     (snd-display #__line__ ";~A 2: ~A" name (channel->vct)))
		 (undo 1)))
	   (undo 2)
	   (scale-by 0.0)
	   (func-zero)
	   (xramp-channel 0 1 32)
	   (if (not (vequal (channel->vct) (vct 0.000 0.007 0.016 0.029 0.048 0.075 0.113 0.166 0.242 0.349 0.500)))
	       (snd-display #__line__ ";~A-zero 1: ~A" name (channel->vct)))
	   (if twice
	       (begin
		 (xramp-channel 0 1 32)
		 (if (not (vequal (channel->vct) (vct 0.000 0.000 0.001 0.002 0.005 0.011 0.025 0.055 0.117 0.243 0.500)))
		     (snd-display #__line__ ";~A-zero 2: ~A" name (channel->vct)))
		 (undo 1)))
	   (undo 3))
	 (list 
	  (lambda () (ptree-channel (lambda (y) (* y 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(* y (vct-ref data 0)))
		      0 (frames) ind 0 #f #f (lambda (p d) (vct 0.5)))))
	 (list 
	  (lambda () (ptree-channel (lambda (y) (+ y 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(+ y (vct-ref data 0)))
		      0 (frames) ind 0 #f #f (lambda (p d) (vct 0.5)))))
	 (list "xramp-ptree" "xramp-ptreec")
	 (list #t #t))
	
	(close-sound ind))
      
      ;; ramp-xramp, xramp-ramp
      (let ((ind (new-sound "test.snd"))
	    (case1 #f)
	    (case2 #f))
	(map-chan (lambda (y) 1.0) 0 10)
	
	(ramp-channel 0.0 1.0)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 0: ~A" (safe-display-edits ind 0 3)))
	(set! case1 (channel->vct))
	(if (not (vequal case1 (vct 0.000 0.001 0.006 0.018 0.039 0.075 0.135 0.233 0.387 0.628 1.000)))
	    (snd-display #__line__ ";ramp-xramp (1): ~A" case1))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 11) ; scale-channel 0.500 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 1: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]0.000 -> 0.400, [2]0.000 -> 0.097, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [2]0.150 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 2: ~A" (safe-display-edits ind 0 4)))
	(set! case2 (channel->vct))
	(if (not (vequal case2 (vct 0.000 0.001 0.003 0.009 0.019 0.075 0.135 0.233 0.387 0.628 1.000)))
	    (snd-display #__line__ ";ramp-xramp (2): ~A" case2))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 2 4) ; scale-channel 0.500 2 4 [4:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100, [2]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [2]0.032 -> 0.150, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [2]0.226 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 3: ~A" (safe-display-edits ind 0 4)))
	(undo 2)
	(xramp-channel 0.75 0.25 32.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; xramp-channel 0.750 0.250 32.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.750 -> 0.250, off: 0.234, scl: 0.016]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 4: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(xramp-channel .2 .6 3.0 2 6)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 2 6) ; xramp-channel 0.200 0.600 3.000 2 6 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.700, [2]0.200 -> 0.600, off: -0.000, scl: 0.200]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 5: ~A" (safe-display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:5]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.400, [2]0.200 -> 0.310, off: -0.000, scl: 0.200]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.387 -> 0.600, off: -0.000, scl: 0.200]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 6: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (set 4 1) ; set-sample 4 0.5000 [4:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.300, [2]0.200 -> 0.249, off: -0.000, scl: 0.200]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.387 -> 0.600, off: -0.000, scl: 0.200]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp-xramp 7: ~A" (safe-display-edits ind 0 4)))
	(revert-sound)
	(map-chan (lambda (y) 1.0) 0 10)
	
	(xramp-channel 0.0 1.0 32.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 0: ~A" (safe-display-edits ind 0 3)))
	(if (not (vequal case1 (channel->vct)))
	    (snd-display #__line__ ";xramp-ramp (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 11) ; scale-channel 0.500 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 1: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]0.000 -> 0.400, [2]0.000 -> 0.097, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [2]0.150 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 2: ~A" (safe-display-edits ind 0 4)))
	(if (not (vequal case2 (channel->vct)))
	    (snd-display #__line__ ";xramp-ramp (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (scale 2 4) ; scale-channel 0.500 2 4 [4:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100, [2]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [2]0.032 -> 0.150, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [2]0.226 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 3: ~A" (safe-display-edits ind 0 4)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; ramp-channel 0.750 0.250 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.750 -> 0.250, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 4: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string=? (safe-display-edits ind 0 3) "
 (ramp 2 6) ; ramp-channel 0.200 0.600 2 6 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.600, [2]0.032 -> 0.333, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.484 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 5: ~A" (safe-display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:5]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.360, [2]0.032 -> 0.097, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600, [2]0.150 -> 0.333, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.484 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 6: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (set 4 1) ; set-sample 4 0.5000 [4:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280, [2]0.032 -> 0.059, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600, [2]0.150 -> 0.333, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.484 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp-ramp 7: ~A" (safe-display-edits ind 0 4)))
	(close-sound ind))
      
      ;; ramp2+xramp
      (let ((ind (new-sound "test.snd"))
	    (case1 #f)
	    (case2 #f))
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 32.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 0: ~A" (safe-display-edits ind 0 4)))
	(set! case1 (channel->vct))
	(if (not (vequal case1 (vct 0.000 0.000 0.001 0.005 0.015 0.038 0.081 0.163 0.310 0.565 1.000)))
	    (snd-display #__line__ ";ramp2+xramp (1): ~A" case1))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 11) ; scale-channel 0.500 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]0.000 -> 1.000, [2]0.000 -> 1.000, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 1: ~A" (safe-display-edits ind 0 5)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 5) ; scale-channel 0.500 0 5 [5:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]0.000 -> 0.400, [2]0.000 -> 0.400, [3]0.000 -> 0.097, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [2]0.500 -> 1.000, [3]0.150 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 2: ~A" (safe-display-edits ind 0 5)))
	(set! case2 (channel->vct))
	(if (not (vequal case2 (vct 0.000 0.000 0.001 0.003 0.008 0.038 0.081 0.163 0.310 0.565 1.000)))
	    (snd-display #__line__ ";ramp2+xramp (2): ~A" case2))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 2 4) ; scale-channel 0.500 2 4 [5:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100, [2]0.000 -> 0.100, [3]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [2]0.200 -> 0.500, [3]0.032 -> 0.150, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [2]0.600 -> 1.000, [3]0.226 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 3: ~A" (safe-display-edits ind 0 5)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; ramp-channel 0.750 0.250 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.750 -> 0.250, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 4: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 2 6) ; ramp-channel 0.200 0.600 2 6 [4:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100, [2]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.700, [2]0.200 -> 0.600, [3]0.032 -> 0.333, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [2]0.484 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 5: ~A" (safe-display-edits ind 0 4)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 5) ; scale-channel 0.500 0 5 [5:5]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]0.000 -> 0.100, [2]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.400, [2]0.200 -> 0.360, [3]0.032 -> 0.097, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.440 -> 0.600, [3]0.150 -> 0.333, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [2]0.484 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 6: ~A" (safe-display-edits ind 0 5)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (set 4 1) ; set-sample 4 0.5000 [5:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.100, [2]0.000 -> 0.013, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.300, [2]0.200 -> 0.280, [3]0.032 -> 0.059, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.440 -> 0.600, [3]0.150 -> 0.333, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [2]0.484 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2+xramp 7: ~A" (safe-display-edits ind 0 5)))
	(revert-sound)
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp+ramp2 0: ~A" (safe-display-edits ind 0 4)))
	(if (not (vequal case1 (channel->vct)))
	    (snd-display #__line__ ";xramp+ramp2 (1): ~A" (channel->vct)))
	
	(revert-sound ind)
	(map-channel (lambda (y) 1.0) 0 100)
	(scale-channel 0.75)
	(ramp-channel .5 1)
	(ptree-channel (lambda (y) (* y (/ 1.0 0.75))))
	(scale-channel 2.0)
	(ramp-channel 1 .5)
	(ptree-channel (lambda (y) (* y .25)))
	(scale-channel 4.0)
	(ramp-channel 0 1)
	(if (fneq (maxamp) 1.0)
	    (snd-display #__line__ ";rprpr max: ~A" (maxamp)))
	
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd"))
	    (case3 #f))
	(map-channel (lambda (y) 1.0) 0 100)
	(scale-channel 0.5)
	(xramp-channel 1.0 0.0 32.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(set! case3 (channel->vct))
	(undo 4)
	
	;; multi-ramp2+xramp
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(xramp-channel 1.0 0.0 32.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 14) "
 (ramp 0 100) ; ramp-channel 0.000 1.000 0 #f [14:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, [2]0.000 -> 0.091, [3]1.000 -> 0.721, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [2]0.101 -> 0.192, [3]0.695 -> 0.499, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [2]0.202 -> 0.293, [3]0.480 -> 0.342, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [2]0.303 -> 0.394, [3]0.329 -> 0.231, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [2]0.404 -> 0.495, [3]0.222 -> 0.153, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [2]0.505 -> 0.596, [3]0.147 -> 0.099, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [2]0.606 -> 0.697, [3]0.094 -> 0.060, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [2]0.707 -> 0.798, [3]0.057 -> 0.033, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [2]0.808 -> 0.899, [3]0.030 -> 0.014, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [2]0.909 -> 1.000, [3]0.012 -> 0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp2+xramp 1: ~A" (safe-display-edits ind 0 14)))
	(if (not (vequal case3 (channel->vct)))
	    (snd-display #__line__ ";multi-ramp2+xramp:~%;  ~A~%;  ~A" 
			 case3 (channel->vct)))
	(revert-sound)
	(map-channel (lambda (y) 1.0) 0 100)
	(xramp-channel 1.0 0.0 32.0)
	
	(ramp-channel 0.0 1.0 10 20)
	(ramp-channel 0.0 1.0 50 10)
	(ramp-channel 0.0 1.0 25 10)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (ramp 25 10) ; ramp-channel 0.000 1.000 25 10 [5:8]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]1.000 -> 0.721, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:24, 1.000, [1]0.000 -> 0.737, [2]0.695 -> 0.413, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 25, cp->sounds[1][25:29, 1.000, [1]0.789 -> 1.000, [2]0.000 -> 0.444, [3]0.398 -> 0.342, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [1]0.556 -> 1.000, [2]0.329 -> 0.282, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 35, cp->sounds[1][35:49, 1.000, [1]0.271 -> 0.153, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.000 -> 1.000, [2]0.147 -> 0.099, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:99, 1.000, [1]0.094 -> 0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp2+xramp 2: ~A" (safe-display-edits ind 0 5)))
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd"))
	    (case3 #f))
	(map-channel (lambda (y) 1.0) 0 100)
	(scale-channel 0.5)
	(ramp-channel 0.0 1.0)
	(xramp-channel 1.0 0.0 32.0)
	(set! case3 (channel->vct))
	(undo 3)
	
	;; multi-ramp-xramp
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(ramp-channel 0.0 1.0)
	(xramp-channel 1.0 0.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 13) "
 (ramp 0 100) ; xramp-channel 1.000 0.000 32.000 0 #f [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, [2]1.000 -> 0.721, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [2]0.695 -> 0.499, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [2]0.480 -> 0.342, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [2]0.329 -> 0.231, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [2]0.222 -> 0.153, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [2]0.147 -> 0.099, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [2]0.094 -> 0.060, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [2]0.057 -> 0.033, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [2]0.030 -> 0.014, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [2]0.012 -> 0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp-xramp 1: ~A" (safe-display-edits ind 0 13)))
	(if (not (vequal case3 (channel->vct)))
	    (snd-display #__line__ ";multi-ramp-xramp: ~A" (channel->vct)))
	(undo 12)
	(xramp-channel 0.0 1.0 3.0 10 20)
	(xramp-channel 0.0 1.0 3.0 50 10)
	(xramp-channel 0.0 1.0 3.0 25 10)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 25 10) ; xramp-channel 0.000 1.000 3.000 25 10 [4:8]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:24, 1.000, [1]0.000 -> 0.623, off: -0.500, scl: 0.500]) [buf: 100] 
   (at 25, cp->sounds[1][25:29, 1.000, [1]0.690 -> 1.000, off: -0.500, scl: 0.500, [2]0.000 -> 0.315, off: -0.500, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [1]0.421 -> 1.000, off: -0.500, scl: 0.500]) [buf: 100] 
   (at 35, cp->sounds[1][35:49, 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.000 -> 1.000, off: -0.500, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:99, 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp-xramp 2: ~A" (safe-display-edits ind 0 4)))
	(revert-sound)
	
	(map-channel (lambda (y) 1.0) 0 100)
	;; multi-xramp-ramp
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(xramp-channel 1.0 0.0 32.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 13) "
 (ramp 0 100) ; ramp-channel 0.000 1.000 0 #f [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, [2]1.000 -> 0.721, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [2]0.695 -> 0.499, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [2]0.480 -> 0.342, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [2]0.329 -> 0.231, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [2]0.222 -> 0.153, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [2]0.147 -> 0.099, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [2]0.094 -> 0.060, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [2]0.057 -> 0.033, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [2]0.030 -> 0.014, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [2]0.012 -> 0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-xramp-ramp 3: ~A" (safe-display-edits ind 0 13)))
	(if (not (vequal case3 (channel->vct)))
	    (snd-display #__line__ ";case3 xramp-ramp 3: ~A" (channel->vct)))
	(undo 12)
	(ramp-channel 0.0 1.0 10 20)
	(ramp-channel 0.0 1.0 50 10)
	(ramp-channel 0.0 1.0 25 10)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 25 10) ; ramp-channel 0.000 1.000 25 10 [4:8]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:24, 1.000, [1]-0.000 -> 0.737]) [buf: 100] 
   (at 25, cp->sounds[1][25:29, 1.000, [1]0.789 -> 1.000, [2]-0.000 -> 0.444]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [1]0.556 -> 1.000]) [buf: 100] 
   (at 35, cp->sounds[1][35:49, 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]-0.000 -> 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:99, 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-xramp-ramp 2: ~A" (safe-display-edits ind 0 4)))
	(close-sound ind))
      
      ;; xramp2
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	(xramp-channel 0.0 1.0 2.0)
	(xramp-channel 0.0 1.0 2.0)
	(if (not (string=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 2.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, off: -1.000, scl: 1.000, [2]0.000 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 0: ~A" (safe-display-edits ind 0 3)))
	(if (not (vequal (channel->vct) (vct 0.000 0.005 0.022 0.053 0.102 0.172 0.266 0.390 0.549 0.750 1.000)))
	    (snd-display #__line__ ";xramp2 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (scale 0 11) ; scale-channel 0.500 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]0.000 -> 1.000, off: -1.000, scl: 1.000, [2]0.000 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 1: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]0.000 -> 0.320, off: -1.000, scl: 1.000, [2]0.000 -> 0.320, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.414 -> 1.000, off: -1.000, scl: 1.000, [2]0.414 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 2: ~A" (safe-display-edits ind 0 4)))
	(if (not (vequal (channel->vct) (vct 0.000 0.003 0.011 0.027 0.051 0.172 0.266 0.390 0.549 0.750 1.000)))
	    (snd-display #__line__ ";xramp2 (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (scale 2 4) ; scale-channel 0.500 2 4 [4:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.072, off: -1.000, scl: 1.000, [2]0.000 -> 0.072, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.149 -> 0.414, off: -1.000, scl: 1.000, [2]0.149 -> 0.414, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.516 -> 1.000, off: -1.000, scl: 1.000, [2]0.516 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 3: ~A" (safe-display-edits ind 0 4)))
	(undo 2)
	(xramp-channel 0.75 0.25 0.3)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; xramp-channel 0.750 0.250 0.300 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, off: -1.000, scl: 1.000, [2]0.750 -> 0.250, off: 0.964, scl: -0.714]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 4: ~A" (safe-display-edits ind 0 3)))
	(undo)
	(xramp-channel .2 .6 32.0 2 6)
	(if (not (string=? (safe-display-edits ind 0 3) "
 (ramp 2 6) ; xramp-channel 0.200 0.600 32.000 2 6 [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.072, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.149 -> 0.625, off: -1.000, scl: 1.000, [2]0.200 -> 0.600, off: 0.187, scl: 0.013]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.741 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 5: ~A" (safe-display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (scale 0 5) ; scale-channel 0.500 0 5 [4:5]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]0.000 -> 0.072, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.149 -> 0.320, off: -1.000, scl: 1.000, [2]0.200 -> 0.239, off: 0.187, scl: 0.013]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.414 -> 0.625, off: -1.000, scl: 1.000, [2]0.290 -> 0.600, off: 0.187, scl: 0.013]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.741 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 6: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (set 4 1) ; set-sample 4 0.5000 [4:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.072, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.149 -> 0.231, off: -1.000, scl: 1.000, [2]0.200 -> 0.213, off: 0.187, scl: 0.013]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.414 -> 0.625, off: -1.000, scl: 1.000, [2]0.290 -> 0.600, off: 0.187, scl: 0.013]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.741 -> 1.000, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp2 7: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 100)
	
	;; multi-xramp2
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(xramp-channel 0.0 1.0 3.0)
	(xramp-channel 1.0 0.0 0.3)
	(if (not (string-=? (safe-display-edits ind 0 13) "
 (ramp 0 100) ; xramp-channel 1.000 0.000 0.300 0 #f [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.053, off: -0.500, scl: 0.500, [2]1.000 -> 0.950, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.059 -> 0.117, off: -0.500, scl: 0.500, [2]0.945 -> 0.889, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.124 -> 0.190, off: -0.500, scl: 0.500, [2]0.882 -> 0.819, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.198 -> 0.271, off: -0.500, scl: 0.500, [2]0.811 -> 0.740, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.279 -> 0.361, off: -0.500, scl: 0.500, [2]0.731 -> 0.651, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.371 -> 0.462, off: -0.500, scl: 0.500, [2]0.641 -> 0.550, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.473 -> 0.575, off: -0.500, scl: 0.500, [2]0.540 -> 0.437, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.587 -> 0.701, off: -0.500, scl: 0.500, [2]0.425 -> 0.308, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.715 -> 0.842, off: -0.500, scl: 0.500, [2]0.295 -> 0.164, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.857 -> 1.000, off: -0.500, scl: 0.500, [2]0.148 -> 0.000, off: 1.429, scl: -1.429]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-xramp2 1: ~A" (safe-display-edits ind 0 13)))
	(close-sound ind))
      
      ;; ptree+ramp2
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) y))
	(if (not (string-=? (safe-display-edits ind 0 4 #f) "
 (ptree[0] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp2 0: ~A" (safe-display-edits ind 0 4 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ptree-ramp2 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (scale 0 11) ; scale-channel 0.500 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp2 1: ~A" (safe-display-edits ind 0 5 #f)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (scale 0 5) ; scale-channel 0.500 0 5 [5:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]-0.000 -> 0.400, [2]-0.000 -> 0.400, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [2]0.500 -> 1.000, loc: 0, pos: 5, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp2 2: ~A" (safe-display-edits ind 0 5 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.005 0.020 0.045 0.080 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ptree-ramp2 (2): ~A" (channel->vct)))
	(undo 4)
	
	(scale-channel .5)
	(env-channel '(0 0 1 1 2 0))
	(ramp-channel 0 1 2 3)
	(ptree-channel (lambda (y) y))
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ptree[0] 0 11) ; ptree-channel [5:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]0.000 -> 0.200, loc: 0, pos: 0, scl: 0.500]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 1.000, [1]0.400 -> 0.800, [2]0.000 -> 1.000, loc: 0, pos: 2, scl: 0.500]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]1.000 -> -0.000, loc: 0, pos: 5, scl: 0.500]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp2 4: ~A" (safe-display-edits ind 0 5 #f)))
	
	(undo 4)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y data forward)
			 (* y (vct-ref data 0)))
		       0 (frames) ind 0 #f #t
		       (lambda (pos dur)
			 (vct 0.5)))
	(if (not (string-=? (safe-display-edits ind 0 4 #f) "
 (ptree[0] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp2 5: ~A" (safe-display-edits ind 0 4 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.005 0.020 0.045 0.080 0.125 0.180 0.245 0.320 0.405 0.500)))
	    (snd-display #__line__ ";ptree+closure+ramp2: ~A" (channel->vct)))
	
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 100)
	
	;; multi-ramp2
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(ramp-channel 0.0 1.0)
	(ramp-channel 1.0 0.0)
	(ptree-channel (lambda (y) y))
	(if (not (string-=? (safe-display-edits ind 0 14 #f) "
 (ptree[0] 0 100) ; ptree-channel [14:11]:
   (at 0, cp->sounds[1][0:9, 1.000, [1]0.000 -> 0.091, [2]1.000 -> 0.909, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [1]0.101 -> 0.192, [2]0.899 -> 0.808, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [1]0.202 -> 0.293, [2]0.798 -> 0.707, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [1]0.303 -> 0.394, [2]0.697 -> 0.606, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [1]0.404 -> 0.495, [2]0.596 -> 0.505, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]0.505 -> 0.596, [2]0.495 -> 0.404, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [1]0.606 -> 0.697, [2]0.394 -> 0.303, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [1]0.707 -> 0.798, [2]0.293 -> 0.202, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [1]0.808 -> 0.899, [2]0.192 -> 0.101, loc: 0, pos: 80, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 1.000, [1]0.909 -> 1.000, [2]0.091 -> -0.000, loc: 0, pos: 90, scl: 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";ptree multi-ramp2 1: ~A" (safe-display-edits ind 0 14 #f)))
	(undo 12)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (+ y .1)))
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ptree[0] 0 11) ; ptree-channel [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp3 0: ~A" (safe-display-edits ind 0 5 #f)))
	(if (not (vequal (channel->vct) (vct 0.100 0.101 0.108 0.127 0.164 0.225 0.316 0.443 0.612 0.829 1.100)))
	    (snd-display #__line__ ";ptree-ramp3 1: ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 6 #f) "
 (scale 0 11) ; scale-channel 0.500 0 #f [6:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp3 2: ~A" (safe-display-edits ind 0 6 #f)))
	
	(undo 5)
	(ramp-channel 0 1)
	(ramp-channel 0 1 5 5)
	(ramp-channel 0 1 7 3)
	(ptree-channel (lambda (y) (+ y .1)))
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ptree[0] 0 11) ; ptree-channel [5:5]:
   (at 0, cp->sounds[1][0:4, 1.000, [1]-0.000 -> 0.400, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 5, cp->sounds[1][5:6, 1.000, [1]0.500 -> 0.600, [2]0.000 -> 0.250, loc: 0, pos: 5, scl: 1.000]) [buf: 11] 
   (at 7, cp->sounds[1][7:9, 1.000, [1]0.700 -> 0.900, [2]0.500 -> 1.000, [3]0.000 -> 1.000, loc: 0, pos: 7, scl: 1.000]) [buf: 11] 
   (at 10, cp->sounds[1][10:10, 1.000, [1]1.000 -> 1.000, loc: 0, pos: 10, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree-ramp3 3: ~A" (safe-display-edits ind 0 5 #f)))
	(if (not (vequal (channel->vct) (vct 0.100 0.200 0.300 0.400 0.500 0.100 0.250 0.100 0.400 1.000 1.100)))
	    (snd-display #__line__ ";ptree-ramp3 4: ~A" (channel->vct)))
	(close-sound ind))
      
      ;; ramp3
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 0: ~A" (safe-display-edits ind 0 4)))
	(if (not (vequal (channel->vct) (vct 0.000 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1.000)))
	    (snd-display #__line__ ";ramp3 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 11) ; scale-channel 0.500 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 0.500, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 1: ~A" (safe-display-edits ind 0 5)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 5) ; scale-channel 0.500 0 5 [5:3]:
   (at 0, cp->sounds[1][0:4, 0.500, [1]-0.000 -> 0.400, [2]-0.000 -> 0.400, [3]-0.000 -> 0.400]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [2]0.500 -> 1.000, [3]0.500 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 2: ~A" (safe-display-edits ind 0 5)))
	(if (not (vequal (channel->vct) (vct 0.000 0.001 0.004 0.014 0.032 0.125 0.216 0.343 0.512 0.729 1.000)))
	    (snd-display #__line__ ";ramp3 (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 2 4) ; scale-channel 0.500 2 4 [5:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.100, [2]-0.000 -> 0.100, [3]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [2]0.200 -> 0.500, [3]0.200 -> 0.500]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [2]0.600 -> 1.000, [3]0.600 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 3: ~A" (safe-display-edits ind 0 5)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; ramp-channel 0.750 0.250 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]0.750 -> 0.250]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 4: ~A" (safe-display-edits ind 0 4)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 2 6) ; ramp-channel 0.200 0.600 2 6 [4:4]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.100, [2]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.700, [2]0.200 -> 0.700, [3]0.200 -> 0.600]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [2]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 5: ~A" (safe-display-edits ind 0 4)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (scale 0 5) ; scale-channel 0.500 0 5 [5:5]:
   (at 0, cp->sounds[1][0:1, 0.500, [1]-0.000 -> 0.100, [2]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.400, [2]0.200 -> 0.400, [3]0.200 -> 0.360]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.500 -> 0.700, [3]0.440 -> 0.600]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [2]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 6: ~A" (safe-display-edits ind 0 5)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (set 4 1) ; set-sample 4 0.5000 [5:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [1]-0.000 -> 0.100, [2]-0.000 -> 0.100]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.300, [2]0.200 -> 0.300, [3]0.200 -> 0.280]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [2]0.500 -> 0.700, [3]0.440 -> 0.600]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [2]0.800 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3 7: ~A" (safe-display-edits ind 0 5)))
	(undo 3)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 100)
	
	;; multi-ramp3
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (scale-channel 0.5 (* i 10) 10))
	(ramp-channel 0.0 1.0)
	(ramp-channel 1.0 -0.5)
	(ramp-channel -0.5 1.5)
	(if (not (string=? (safe-display-edits ind 0 14) "
 (ramp 0 100) ; ramp-channel -0.500 1.500 0 #f [14:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [1]0.000 -> 0.091, [2]1.000 -> 0.864, [3]-0.500 -> -0.318]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [2]0.848 -> 0.712, [3]-0.298 -> -0.116]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [2]0.697 -> 0.561, [3]-0.096 -> 0.086]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [2]0.545 -> 0.409, [3]0.106 -> 0.288]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [2]0.394 -> 0.258, [3]0.308 -> 0.490]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [2]0.242 -> 0.106, [3]0.510 -> 0.692]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [2]0.091 -> -0.045, [3]0.712 -> 0.894]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [2]-0.061 -> -0.197, [3]0.914 -> 1.096]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [2]-0.212 -> -0.348, [3]1.116 -> 1.298]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [2]-0.364 -> -0.500, [3]1.318 -> 1.500]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp3 1: ~A" (safe-display-edits ind 0 14)))
	(undo 13)
	(ramp-channel 0.0 1.0 10 30)
	(ramp-channel 0.0 1.0 50 20)
	(ramp-channel 0.0 1.0 20 15)
	(ramp-channel 0.0 1.0 30 30)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (ramp 30 30) ; ramp-channel 0.000 1.000 30 30 [5:10]:
   (at 0, cp->sounds[1][0:9, 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [1]0.000 -> 0.310]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [1]0.345 -> 0.655, [2]-0.000 -> 0.643]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [1]0.690 -> 0.828, [2]0.714 -> 1.000, [3]0.000 -> 0.138]) [buf: 100] 
   (at 35, cp->sounds[1][35:39, 1.000, [1]0.862 -> 1.000, [2]0.172 -> 0.310]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [1]0.345 -> 0.655]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]-0.000 -> 0.474, [2]0.690 -> 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [1]0.526 -> 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:99, 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display #__line__ ";multi-ramp3 2: ~A" (safe-display-edits ind 0 5)))
	
	(let ((vals (channel->vct)))
	  (undo 4)
	  (ptree-channel (lambda (y) y))
	  (ramp-channel 0.0 1.0 10 30)
	  (ptree-channel (lambda (y) y))
	  (ramp-channel 0.0 1.0 50 20)
	  (ptree-channel (lambda (y) y))
	  (ramp-channel 0.0 1.0 20 15)
	  (ptree-channel (lambda (y) y))
	  (ramp-channel 0.0 1.0 30 30)
	  (if (not (vequal vals (channel->vct)))
	      (snd-display #__line__ ";ramp3 opt vs unopt: ~A ~A" vals (channel->vct))))
	
	(close-sound ind))
      
      ;; various cases not optimized, presumably
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	;; ramp+xramp (now optimized)
	(ramp-channel 0.0 1.0)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp+xramp: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	
	;; xramp+xramp -- this one now optimized
	(xramp-channel 0.0 1.0 0.32)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, off: 1.471, scl: -1.471, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp+xramp: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	
	;; xramp+xramp+xramp
	(xramp-channel 0.0 1.0 0.32)
	(xramp-channel 0.0 1.0 32.0)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, off: 1.471, scl: -1.471, [2]0.000 -> 1.000, off: -0.032, scl: 0.032, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp+xramp+xramp (maxed): ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	
	;; xramp+xramp+ramp (now optimized)
	(xramp-channel 0.0 1.0 0.32)
	(xramp-channel 0.0 1.0 32.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: 1.471, scl: -1.471, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp+xramp+ramp: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	
	;; xramp+ramp (now optimized)
	(xramp-channel 0.0 1.0 32.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp+ramp: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	
	;; ramp+ramp+xramp
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, [3]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp+ramp+xramp: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	
	;; ramp+ramp+ramp+ramp
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, [4]-0.000 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp+ramp+ramp+ramp: ~A" (safe-display-edits ind 0 5)))
	(undo 4)
	
	;; ramp+ramp+ramp+xramp
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, [3]0.000 -> 1.000, [4]0.000 -> 1.000, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp+ramp+ramp+xramp: ~A" (safe-display-edits ind 0 5)))
	(undo 4)
	
	;; ptree+ramp (now optimized)
	(ptree-channel (lambda (y) y))
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (safe-display-edits ind 0 3) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) y)]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree+ramp: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	
	;; ramp+xramp+ptree (now optimized)
	(ramp-channel 0.0 1.0)
	(xramp-channel 0.0 1.0 32.0)
	(ptree-channel (lambda (y) y))
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ptree[0] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) y)]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp+xramp+ptree: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	
	;; xramp+ramp+ptree (now optimized)
	(xramp-channel 0.0 1.0 32.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) y))
	(if (not (string-=? (safe-display-edits ind 0 4) "
 (ptree[0] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, [2]0.000 -> 1.000, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) y)]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp+ramp+ptree: ~A" (safe-display-edits ind 0 4)))
	(undo 3)
	
	;; ramp3+ptree (now optimized)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) y))
	(if (not (string-=? (safe-display-edits ind 0 5) "
 (ptree[0] 0 11) ; ptree-channel [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, [3]-0.000 -> 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) y)]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp3+ptree: ~A" (safe-display-edits ind 0 5)))
	(undo 4)
	
	;; ptree+ptree (now optimized)
	(ptree-channel (lambda (y) y))
	(ptree-channel (lambda (y) y))
	(if (not (string=? (safe-display-edits ind 0 3) "
 (ptree[1] 0 11) ; ptree-channel [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) y)]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ptree+ptree: ~A" (safe-display-edits ind 0 3)))
	(undo 2)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd")))
	(map-chan (lambda (y) 1.0) 0 10)
	
	;; ramp ptree2 cases
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(ramp-channel 0 1)
	(if (not (string-=? (safe-display-edits ind 0 4 #f) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp ptree2: ~A" (safe-display-edits ind 0 4 #f)))
	(if (not (vequal (channel->vct) (vct 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0)))
	    (snd-display #__line__ ";ramp ptree2: ~A" (channel->vct)))
	(ramp-channel 0 1)
	(if (not (string-=? (safe-display-edits ind 0 5 #f) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [5:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]-0.000 -> 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";ramp2 ptree2: ~A" (safe-display-edits ind 0 5 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ramp2 ptree2: ~A" (channel->vct)))
	(undo 2)
	(xramp-channel 0 1 32)
	(if (not (string=? (safe-display-edits ind 0 4 #f) "
 (ramp 0 11) ; xramp-channel 0.000 1.000 32.000 0 #f [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]0.000 -> 1.000, off: -0.032, scl: 0.032, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display #__line__ ";xramp ptree2: ~A" (safe-display-edits ind 0 4 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.013 0.032 0.059 0.097 0.150 0.226 0.333 0.484 0.698 1.000)))
	    (snd-display #__line__ ";xramp ptree2: ~A" (channel->vct)))
	
	(undo 3)
	(scale-channel 0.0)
	
	(ptree-channel (lambda (y) (+ y 0.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(ramp-channel 0 1)
	(if (not (string=? (safe-display-edits ind 0 4 #f) (string-append "
 (ptree[1] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[0][0:10, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	    (snd-display #__line__ ";ramp ptree2 zero: ~A" (safe-display-edits ind 0 4 #f)))
	(if (not (vequal (channel->vct) (vct 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0)))
	    (snd-display #__line__ ";ramp ptree2 zero: ~A" (channel->vct)))
	(ramp-channel 0 1)
	(if (not (string-=? (safe-display-edits ind 0 5 #f) (string-append "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [5:2]:
   (at 0, cp->sounds[0][0:10, 1.000, [1]-0.000 -> 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	    (snd-display #__line__ ";ramp2 ptree2 zero: ~A" (safe-display-edits ind 0 5 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ramp2 ptree2 zero: ~A" (channel->vct)))
	(undo 2)
	(xramp-channel 0 1 32)
	(if (not (string=? (safe-display-edits ind 0 4 #f) (string-append "
 (ptree[1] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[0][0:10, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 0.000]) [file: " (getcwd) "/test.snd[0]]
   (at 11, end_mark)
")))
	    (snd-display #__line__ ";xramp ptree2 zero: ~A" (safe-display-edits ind 0 4 #f)))
	(if (not (vequal (channel->vct) (vct 0.000 0.013 0.032 0.059 0.097 0.150 0.226 0.333 0.484 0.698 1.000)))
	    (snd-display #__line__ ";xramp ptree2 zero: ~A" (channel->vct)))
	
	(close-sound ind))
      
      ;; ptree3 + ramps
      (let ((ind (new-sound "test.snd"))
	    (case1 #f)
	    (case2 #f))
	(map-chan (lambda (y) 1.0) 0 10)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (make-vct 11 4.0)))
	    (snd-display #__line__ ";ptree3 1: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.0 16)))
	    (snd-display #__line__ ";ptree3 2: ~A" (edit-tree)))
	
	(scale-channel 0.25)
	(if (not (vequal (channel->vct) (make-vct 11 1.0)))
	    (snd-display #__line__ ";ptree3 3: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.250 0.0 0.0 16)))
	    (snd-display #__line__ ";ptree3 4: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000)))
	    (snd-display #__line__ ";ptree3 5: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.25 0.0 0.1 26)))
	    (snd-display #__line__ ";ptree3 6: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ptree3 7: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.25 0.0 0.1 26)))
	    (snd-display #__line__ ";ptree3 8: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1.000)))
	    (snd-display #__line__ ";ptree3 9: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.25 0.0 0.1 26)))
	    (snd-display #__line__ ";ptree3 10: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.000 0.002 0.008 0.026 0.062 0.130 0.240 0.410 0.656 1.000)))
	    (snd-display #__line__ ";ptree3 11: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.25 0.0 0.1 26)))
	    (snd-display #__line__ ";ptree3 12: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.25 0.0 0.1 26)))
	    (snd-display #__line__ ";ptree3 13: ~A" (edit-tree)))
	
	;; ptree3-zero + ramps
	(revert-sound ind)
	(map-chan (lambda (y) 1.0) 0 10)
	(scale-by 0.0)
	
	(ptree-channel (lambda (y) (+ y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (make-vct 11 4.0)))
	    (snd-display #__line__ ";ptree3 14: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 1.0 0.0 0.0 18)))
	    (snd-display #__line__ ";ptree3 15: ~A" (edit-tree)))
	
	(scale-channel 0.25)
	(if (not (vequal (channel->vct) (make-vct 11 1.0)))
	    (snd-display #__line__ ";ptree3 16: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 0.250 0.0 0.0 18)))
	    (snd-display #__line__ ";ptree3 17: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000)))
	    (snd-display #__line__ ";ptree3 18: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 0.25 0.0 0.1 28)))
	    (snd-display #__line__ ";ptree3 19: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000)))
	    (snd-display #__line__ ";ptree3 20: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 0.25 0.0 0.1 28)))
	    (snd-display #__line__ ";ptree3 21: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1.000)))
	    (snd-display #__line__ ";ptree3 22: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 0.25 0.0 0.1 28)))
	    (snd-display #__line__ ";ptree3 23: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.000 0.002 0.008 0.026 0.062 0.130 0.240 0.410 0.656 1.000)))
	    (snd-display #__line__ ";ptree3 24: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 0.25 0.0 0.1 28)))
	    (snd-display #__line__ ";ptree3 25: ~A" (edit-tree)))
	
	(revert-sound ind)
	
	;; ptree3 + various scalers
	(map-chan (lambda (y) 1.0) 0 10)
	(scale-channel 0.5)
	(ptree-channel (lambda (y) (+ y 0.5)))
	(scale-channel 2.0)
	(ptree-channel (lambda (y) (+ y 1.5)))
	(scale-channel 0.25)
	(ptree-channel (lambda (y) (+ y 1.0)))
	(scale-channel 0.1)
	(if (not (vequal (channel->vct) (vct 0.188 0.188 0.188 0.188 0.188 0.188 0.188 0.188 0.188 0.188 0.188)))
	    (snd-display #__line__ ";ptree3 26: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 0.100000001490116 0.0 0.0 16)))
	    (snd-display #__line__ ";ptree3 27: ~A" (edit-tree)))
	(revert-sound ind)
	
	;; ramps + ptree3
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.100 3.200 3.300 3.400 3.500 3.600 3.700 3.800 3.900 4.000)))
	    (snd-display #__line__ ";ptree3 28: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 20)))
	    (snd-display #__line__ ";ptree3 29: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.010 3.040 3.090 3.160 3.250 3.360 3.490 3.640 3.810 4.000)))
	    (snd-display #__line__ ";ptree3 30: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 20)))
	    (snd-display #__line__ ";ptree3 31: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.001 3.008 3.027 3.064 3.125 3.216 3.343 3.512 3.729 4.000)))
	    (snd-display #__line__ ";ptree3 32: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 20)))
	    (snd-display #__line__ ";ptree3 33: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.000 3.002 3.008 3.026 3.062 3.130 3.240 3.410 3.656 4.000)))
	    (snd-display #__line__ ";ptree3 34: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 20)))
	    (snd-display #__line__ ";ptree3 35: ~A" (edit-tree)))
	(revert-sound ind)
	
	
	;; xramps+ptree3 and vice-versa
	(map-chan (lambda (y) 1.0) 0 10)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(xramp-channel 0.0 1.0 10.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.115 0.260 0.442 0.672 0.961 1.325 1.783 2.360 3.086 4.000)))
	    (snd-display #__line__ ";ptree3 36: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.0 30)))
	    (snd-display #__line__ ";ptree3 37: ~A" (edit-tree)))
	
	(xramp-channel 0.0 1.0 10.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.003 0.017 0.049 0.113 0.231 0.439 0.795 1.392 2.381 4.000)))
	    (snd-display #__line__ ";ptree3 38: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.0 30)))
	    (snd-display #__line__ ";ptree3 39: ~A" (edit-tree)))
	
	(undo)
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.012 0.052 0.133 0.269 0.481 0.795 1.248 1.888 2.777 4.000)))
	    (snd-display #__line__ ";ptree3 40: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 34)))
	    (snd-display #__line__ ";ptree3 41: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.001 0.010 0.040 0.108 0.240 0.477 0.874 1.510 2.500 4.000)))
	    (snd-display #__line__ ";ptree3 42: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 34)))
	    (snd-display #__line__ ";ptree3 43: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.000 0.002 0.012 0.043 0.120 0.286 0.612 1.208 2.250 4.000)))
	    (snd-display #__line__ ";ptree3 44: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 34)))
	    (snd-display #__line__ ";ptree3 45: ~A" (edit-tree)))
	
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(scale-channel 0.0)
	(ptree-channel (lambda (y) (+ y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(xramp-channel 0.0 1.0 10.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.115 0.260 0.442 0.672 0.961 1.325 1.783 2.360 3.086 4.000)))
	    (snd-display #__line__ ";ptree3 46: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 1.0 0.0 0.0 32)))
	    (snd-display #__line__ ";ptree3 47: ~A" (edit-tree)))
	
	(xramp-channel 0.0 1.0 10.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.003 0.017 0.049 0.113 0.231 0.439 0.795 1.392 2.381 4.000)))
	    (snd-display #__line__ ";ptree3 48: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 1.0 0.0 0.0 32)))
	    (snd-display #__line__ ";ptree3 49: ~A" (edit-tree)))
	
	(undo)
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.012 0.052 0.133 0.269 0.481 0.795 1.248 1.888 2.777 4.000)))
	    (snd-display #__line__ ";ptree3 50: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 1.0 0.0 0.1 36)))
	    (snd-display #__line__ ";ptree3 51: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.001 0.010 0.040 0.108 0.240 0.477 0.874 1.510 2.500 4.000)))
	    (snd-display #__line__ ";ptree3 52: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 1.0 0.0 0.1 36)))
	    (snd-display #__line__ ";ptree3 53: ~A" (edit-tree)))
	
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.000 0.002 0.012 0.043 0.120 0.286 0.612 1.208 2.250 4.000)))
	    (snd-display #__line__ ";ptree3 54: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 0 0 10 1.0 0.0 0.1 36)))
	    (snd-display #__line__ ";ptree3 55: ~A" (edit-tree)))
	
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 10.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.029 3.065 3.111 3.168 3.240 3.331 3.446 3.590 3.771 4.000)))
	    (snd-display #__line__ ";ptree3 56: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.0 22)))
	    (snd-display #__line__ ";ptree3 57: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 10.0)
	(ramp-channel 0.0 1.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.003 3.013 3.033 3.067 3.120 3.199 3.312 3.472 3.694 4.000)))
	    (snd-display #__line__ ";ptree3 58: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 24)))
	    (snd-display #__line__ ";ptree3 59: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 10.0)
	(xramp-channel 0.0 1.0 10.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(if (not (vequal (channel->vct) (vct 3.000 3.001 3.004 3.012 3.028 3.058 3.110 3.199 3.348 3.595 4.000)))
	    (snd-display #__line__ ";ptree3 60: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.0 22)))
	    (snd-display #__line__ ";ptree3 61: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 10.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.303 0.613 0.933 1.267 1.620 1.999 2.412 2.872 3.394 4.000)))
	    (snd-display #__line__ ";ptree3 62: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 39)))
	    (snd-display #__line__ ";ptree3 63: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 10.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.030 0.123 0.280 0.507 0.810 1.199 1.688 2.298 3.055 4.000)))
	    (snd-display #__line__ ";ptree3 64: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 39)))
	    (snd-display #__line__ ";ptree3 65: ~A" (edit-tree)))
	(revert-sound ind)
	
	
	(map-chan (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 10.0)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(if (not (vequal (channel->vct) (vct 0.000 0.003 0.025 0.084 0.203 0.405 0.720 1.182 1.838 2.749 4.000)))
	    (snd-display #__line__ ";ptree3 66: ~A" (channel->vct)))
	(if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.1 39)))
	    (snd-display #__line__ ";ptree3 67: ~A" (edit-tree)))
	(revert-sound ind)
	
	(map-chan (lambda (y) 1.0) 0 10)
	(ptree-channel (lambda (y) (* y 0.5)))
	(ptree-channel (lambda (y) (+ y 1.5)))
	(ptree-channel (lambda (y) (* y 2.0)))
	(ptree-channel (lambda (y) (* y 0.1)))
	(if (not (vequal (channel->vct) (make-vct 11 0.4)))
	    (snd-display #__line__ ";ptree4: ~A" (channel->vct)))
	(if (< (max-virtual-ptrees) 4)
	    (if (not (feql (car (edit-tree)) (list 0 2 0 10 1.0 0.0 0.0 0)))
		(snd-display #__line__ ";ptree4: ~A" (edit-tree)))
	    (if (not (feql (car (edit-tree)) (list 0 1 0 10 1.0 0.0 0.0 16)))
		(snd-display #__line__ ";ptree4 (maxed): ~A" (edit-tree))))
	
	(close-sound ind))
      
      (let ((old-pmax (max-virtual-ptrees)))
	
	(set! (max-virtual-ptrees) 10)
	
	(let ((ind (new-sound "test.snd" :size 20)))
	  (vct->channel (make-vct 20 1.0))
	  
	  (env-channel '(0 0 1 1 2 1 3 0))
	  (let ((ramp-to-1 (channel->vct)))
	    (undo)
	    (xramp-channel 0 1 8)
	    (let ((xramp-to-1 (channel->vct)))
	      (undo)
	      (ptree-channel (lambda (y) (* y 2.5)))
	      (let ((pdata (channel->vct)))
		(undo)
		
		;; -------- ramp-ptree-ramp -------- 
		
		(set! (edit-position) 1)
		(env-channel '(0 0 1 1 2 1 3 0))
		(ptree-channel (lambda (y) (* y 2.5)))
		(env-channel '(0 0 1 1 2 1 3 0))
		(let ((rpr (channel->vct)))
		  (let ((nrpr (vct-multiply! 
			       (vct-multiply! 
				(vct-multiply! (make-vct 20 1.0) ramp-to-1)
				pdata)
			       ramp-to-1)))
		    (if (not (vequal rpr nrpr))
			(snd-display #__line__ ";simple rpr:~%; ~A~%; ~A" rpr nrpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by -1.234)
		(let ((rpr (channel->vct)))
		  (let ((nrpr (vct-scale!
			       (vct-multiply! 
				(vct-scale! 
				 (vct-multiply! 
				  (vct-scale! 
				   (vct-multiply! (make-vct 20 3.0) ramp-to-1) 
				   1.25)
				  pdata)
				 -0.8)
				ramp-to-1)
			       -1.234)))
		    (if (not (vequal rpr nrpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * rpr:~%; ~A~%; ~A" rpr nrpr))))
		
		
		;; -------- ramp-ptree-xramp -------- 
		
		(set! (edit-position) 1)
		(xramp-channel 0 1 8)
		(ptree-channel (lambda (y) (* y 2.5)))
		(env-channel '(0 0 1 1 2 1 3 0))
		(let ((rpr (channel->vct)))
		  (let ((nrpr (vct-multiply! 
			       (vct-multiply! 
				(vct-multiply! (make-vct 20 1.0) xramp-to-1)
				pdata)
			       ramp-to-1)))
		    (if (not (vequal rpr nrpr))
			(snd-display #__line__ ";simple rpx:~%; ~A~%; ~A" rpr nrpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(xramp-channel 0 1 8)
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by -1.234)
		(let ((rpr (channel->vct)))
		  (let ((nrpr (vct-scale!
			       (vct-multiply! 
				(vct-scale! 
				 (vct-multiply! 
				  (vct-scale! 
				   (vct-multiply! (make-vct 20 3.0) xramp-to-1) 
				   1.25)
				  pdata)
				 -0.8)
				ramp-to-1)
			       -1.234)))
		    (if (not (vequal rpr nrpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * rpx:~%; ~A~%; ~A" rpr nrpr))))
		
		
		;; -------- ramp-ptree-xramp-ramp -------- 
		
		(set! (edit-position) 1)
		(xramp-channel 0 1 8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(ptree-channel (lambda (y) (* y 2.5)))
		(env-channel '(0 0 1 1 2 1 3 0))
		(let ((rpr (channel->vct)))
		  (let ((nrpr (vct-multiply! 
			       (vct-multiply! 
				(vct-multiply! 
				 (vct-multiply! (make-vct 20 1.0) ramp-to-1)
				 xramp-to-1)
				pdata)
			       ramp-to-1)))
		    (if (not (vequal rpr nrpr))
			(snd-display #__line__ ";simple rpxr:~%; ~A~%; ~A" rpr nrpr))))
		
		(set! (edit-position) 1)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by 3.0)
		(xramp-channel 0 1 8)
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by -1.0)
		(let ((rpr (channel->vct)))
		  (let ((nrpr (vct-scale!
			       (vct-multiply! 
				(vct-scale! 
				 (vct-multiply! 
				  (vct-scale! 
				   (vct-multiply!
				    (vct-multiply! (make-vct 20 3.0) ramp-to-1)
				    xramp-to-1) 
				   1.25)
				  pdata)
				 -0.8)
				ramp-to-1)
			       -1.0)))
		    (if (not (vequal rpr nrpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * rpxr:~%; ~A~%; ~A" rpr nrpr))))
		
		
		;; -------- xramp-ptree-ramp -------- 
		
		(set! (edit-position) 1)
		(env-channel '(0 0 1 1 2 1 3 0))
		(ptree-channel (lambda (y) (* y 2.5)))
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply! 
			       (vct-multiply! 
				(vct-multiply! (make-vct 20 1.0) ramp-to-1)
				pdata)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";simple xpr:~%; ~A~%; ~A" xpr nxpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(xramp-channel 0 1 8)
		(scale-by -1.234)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-scale!
			       (vct-multiply! 
				(vct-scale! 
				 (vct-multiply! 
				  (vct-scale! 
				   (vct-multiply! (make-vct 20 3.0) ramp-to-1) 
				   1.25)
				  pdata)
				 -0.8)
				xramp-to-1)
			       -1.234)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * xpr:~%; ~A~%; ~A" xpr nxpr))))
		
		
		;; -------- xramp-ptree-xramp -------- 
		
		(set! (edit-position) 1)
		(xramp-channel 0 1 8)
		(ptree-channel (lambda (y) (* y 2.5)))
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply! 
			       (vct-multiply! 
				(vct-multiply! (make-vct 20 1.0) xramp-to-1)
				pdata)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";simple xpx:~%; ~A~%; ~A" xpr nxpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(xramp-channel 0 1 8)
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(xramp-channel 0 1 8)
		(scale-by -1.234)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-scale!
			       (vct-multiply! 
				(vct-scale! 
				 (vct-multiply! 
				  (vct-scale! 
				   (vct-multiply! (make-vct 20 3.0) xramp-to-1) 
				   1.25)
				  pdata)
				 -0.8)
				xramp-to-1)
			       -1.234)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * xpx:~%; ~A~%; ~A" xpr nxpr))))
		
		
		;; -------- xramp-ptree-xramp-ramp --------
		
		(set! (edit-position) 1)
		(env-channel '(0 0 1 1 2 1 3 0))
		(xramp-channel 0 1 8)
		(ptree-channel (lambda (y) (* y 2.5)))
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply! 
			       (vct-multiply! 
				(vct-multiply! 
				 (vct-multiply! (make-vct 20 1.0) ramp-to-1)
				 xramp-to-1)
				pdata)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";simple xpxr:~%; ~A~%; ~A" xpr nxpr))))
		
		(set! (edit-position) 1)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by 3.0)
		(xramp-channel 0 1 8)
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(xramp-channel 0 1 8)
		(scale-by -1.234)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-scale!
			       (vct-multiply! 
				(vct-scale! 
				 (vct-multiply! 
				  (vct-scale! 
				   (vct-multiply!
				    (vct-multiply! (make-vct 20 3.0) ramp-to-1)
				    xramp-to-1) 
				   1.25)
				  pdata)
				 -0.8)
				xramp-to-1)
			       -1.234)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * xpxr:~%; ~A~%; ~A" xpr nxpr))))
		
		
		;; -------- xramp-ramp-ptree-ramp -------- 
		
		(set! (edit-position) 1)
		(env-channel '(0 0 1 1 2 1 3 0))
		(ptree-channel (lambda (y) (* y 2.5)))
		(env-channel '(0 0 1 1 2 1 3 0))
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply!
			       (vct-multiply! 
				(vct-multiply! 
				 (vct-multiply! (make-vct 20 1.0) ramp-to-1)
				 pdata)
				ramp-to-1)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";simple xrpr:~%; ~A~%; ~A" xpr nxpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by -1.234)
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply!
			       (vct-scale!
				(vct-multiply! 
				 (vct-scale! 
				  (vct-multiply! 
				   (vct-scale! 
				    (vct-multiply! (make-vct 20 3.0) ramp-to-1) 
				    1.25)
				   pdata)
				  -0.8)
				 ramp-to-1)
				-1.234)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * xrpr:~%; ~A~%; ~A" xpr nxpr))))
		
		;; -------- xramp-ramp-ptree-xramp -------- 
		
		(set! (edit-position) 1)
		(xramp-channel 0 1 8)
		(ptree-channel (lambda (y) (* y 2.5)))
		(env-channel '(0 0 1 1 2 1 3 0))
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply!
			       (vct-multiply! 
				(vct-multiply! 
				 (vct-multiply! (make-vct 20 1.0) xramp-to-1)
				 pdata)
				ramp-to-1)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";simple xrpx:~%; ~A~%; ~A" xpr nxpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(xramp-channel 0 1 8)
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by -1.234)
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply!
			       (vct-scale!
				(vct-multiply! 
				 (vct-scale! 
				  (vct-multiply! 
				   (vct-scale! 
				    (vct-multiply! (make-vct 20 3.0) xramp-to-1) 
				    1.25)
				   pdata)
				  -0.8)
				 ramp-to-1)
				-1.234)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * xrpx:~%; ~A~%; ~A" xpr nxpr))))
		
		
		
		;; -------- xramp-ramp-ptree-xramp-ramp -------- 
		
		(set! (edit-position) 1)
		(xramp-channel 0 1 8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(ptree-channel (lambda (y) (* y 2.5)))
		(env-channel '(0 0 1 1 2 1 3 0))
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply!
			       (vct-multiply! 
				(vct-multiply! 
				 (vct-multiply! (vct-multiply! (make-vct 20 1.0) xramp-to-1) ramp-to-1)
				 pdata)
				ramp-to-1)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";simple xrpxr:~%; ~A~%; ~A" xpr nxpr))))
		
		(set! (edit-position) 1)
		(scale-by 3.0)
		(xramp-channel 0 1 8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by 1.25)
		(ptree-channel (lambda (y) (* y 2.5)))
		(scale-by -0.8)
		(env-channel '(0 0 1 1 2 1 3 0))
		(scale-by -1.234)
		(xramp-channel 0 1 8)
		(let ((xpr (channel->vct)))
		  (let ((nxpr (vct-multiply!
			       (vct-scale!
				(vct-multiply! 
				 (vct-scale! 
				  (vct-multiply! 
				   (vct-scale! 
				    (vct-multiply! (vct-multiply! (make-vct 20 3.0) xramp-to-1) ramp-to-1)
				    1.25)
				   pdata)
				  -0.8)
				 ramp-to-1)
				-1.234)
			       xramp-to-1)))
		    (if (not (vequal xpr nxpr))
			(snd-display #__line__ ";3.0 1.25 -0.8 -1.234 * xrpxr:~%; ~A~%; ~A" xpr nxpr))))
		
		(close-sound ind)))))
	(set! (max-virtual-ptrees) old-pmax))
      
      (let ((data (make-vct 101 1.0))
	    (rto1-data (make-vct 101))
	    (xto1-data (make-vct 101))
	    (cos-data (make-vct 101))
	    (ind (new-sound "test.snd")))
	;; test-ops.scm for 7 and 8 cases (40 min per branch)
	
	(define (set-to-1) (map-chan (lambda (y) 1.0) 0 100))
	(define (cset-to-1 dat) (do ((i 0 (+ 1 i))) ((= i 101)) (vct-set! dat i 1.0)))
	(define (ramp-to-1) (ramp-channel 0.0 1.0))
	(define (cramp-to-1 dat) (vct-multiply! dat rto1-data))
	(define (scale-by-half) (scale-channel 0.5))
	(define (cscale-by-half dat) (vct-scale! dat 0.5000))
	(define (scale-by-two) (scale-channel 2.0 30 40))
	(define (cscale-by-two dat) (do ((i 30 (+ 1 i))) ((= i 70)) (vct-set! dat i (* (vct-ref dat i) 2.0))))
	(define (xramp-to-1) (xramp-channel 0.0 1.0 32.0))
	(define (cxramp-to-1 dat) (vct-multiply! dat xto1-data))
	(define (scale-mid) (scale-channel 0.125 30 30))
	(define (cscale-mid dat) (do ((i 30 (+ 1 i))) ((= i 60)) (vct-set! dat i (* (vct-ref dat i) 0.125))))
	(define (on-air) (scale-channel 0.0 10 30))
	(define (con-air dat) (do ((i 10 (+ 1 i))) ((= i 40)) (vct-set! dat i 0.0)))
	(define (ptree) (ptree-channel (lambda (y) (* y 0.75)) 20 20))
	(define (cptree dat) (do ((i 20 (+ 1 i))) ((= i 40)) (vct-set! dat i (* (vct-ref dat i) .75))))
	(define (ptreec) (cosine-channel-via-ptree))
	(define (cptreec dat) (vct-multiply! dat cos-data))
	(define (xen) (ptree-channel (lambda (y) (* y 0.25)) 0 (frames) ind 0))
	(define (cxen dat) (vct-scale! dat 0.25))
	(define (rev-channel->vct)
	  (let* ((l (vct-length data))
		 (r (make-sampler (- l 1) ind 0 -1))
		 (d (make-vct l)))
	    (do ((i (- l 1) (- i 1)))
		((< i 0))
	      (vct-set! d i (r)))
	    d))
	(define (ptreec1)
	  (ptree-channel (lambda (y data forward)
			   (* y (vct-ref data 0)))
			 10 50 ind 0 #f #f
			 (lambda (pos dur)
			   (vct 0.625))))
	(define (cptreec1 dat) (do ((i 10 (+ 1 i))) ((= i 60)) (vct-set! dat i (* (vct-ref dat i) 0.625))))
	
	(let ((xe (make-env '(0 0 1 1) :length 101 :base 32.0)))
	  (do ((i 0 (+ 1 i))
	       (incr (/ pi 101.0))
	       (ang (* -0.5 pi)))
	      ((= i 101))
	    (vct-set! rto1-data i (* i .01))
	    (vct-set! xto1-data i (env xe))
	    (vct-set! cos-data i (cos ang))
	    (set! ang (+ ang incr))))
	
	(set! (squelch-update ind) #t)
	
	;; 0 case
	(set-to-1)
	(if (not (vvequal data (channel->vct)))
	    (snd-display #__line__ ";0 case! ~A" (channel->vct)))
	(if (not (vvequal data (rev-channel->vct)))
	    (snd-display #__line__ ";0 case rev! ~A" (rev-channel->vct)))
	
	;; 1 case
	(for-each
	 (lambda (func check)
	   (revert-sound)
	   (set-to-1)
	   (cset-to-1 data)
	   (func)
	   (check data)
	   (if (not (vvequal data (channel->vct)))
	       (snd-display #__line__ ";1 case: ~A ~A" (procedure-name func) (channel->vct)))
	   (if (not (vvequal data (rev-channel->vct)))
	       (snd-display #__line__ ";1 rev case: ~A ~A" (procedure-name func) (rev-channel->vct))))
	 (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	 (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen))
	
	;; 2 case
	(for-each
	 (lambda (func check)
	   (for-each
	    (lambda (func1 check1)
	      (revert-sound)
	      (set-to-1)
	      (cset-to-1 data)
	      (func)
	      (check data)
	      (func1)
	      (check1 data)
	      (if (not (vvequal data (channel->vct)))
		  (snd-display #__line__ ";2 case: ~A(~A): ~A" (procedure-name func1) (procedure-name func) (channel->vct)))
	      (if (not (vvequal data (rev-channel->vct)))
		  (snd-display #__line__ ";2 rev case: ~A(~A): ~A" (procedure-name func1) (procedure-name func) (rev-channel->vct))))
	    (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	    (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
	 (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	 (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen))
	
	(set! (print-length) 200)
	
	;; 3 case
	(for-each
	 (lambda (func check)
	   (for-each
	    (lambda (func1 check1)
	      (for-each
	       (lambda (func2 check2)
		 (revert-sound)
		 (set-to-1)
		 (cset-to-1 data)
		 (func)
		 (check data)
		 (func1)
		 (check1 data)
		 (func2)
		 (check2 data)
		 (if (not (vvequal data (channel->vct)))
		     (snd-display #__line__ ";3 case: ~A(~A(~A)): off by ~A~%; calc: ~A~%; chan: ~A" 
				  (procedure-name func2) (procedure-name func1) (procedure-name func) 
				  (vmaxdiff data (channel->vct)) data (channel->vct)))
		 (if (not (vvequal data (rev-channel->vct)))
		     (snd-display #__line__ ";3 rev case: ~A(~A(~A)) off by ~A:~%; calc: ~A~%; chan: ~A" 
				  (procedure-name func2) (procedure-name func1) (procedure-name func) 
				  (vmaxdiff data (rev-channel->vct)) data (rev-channel->vct))))
	       (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	       (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
	    (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	    (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
	 (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	 (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen))
	
	(if all-args
	    (begin
	      ;; 4 case
	      (for-each
	       (lambda (func check)
		 (for-each
		  (lambda (func1 check1)
		    (for-each
		     (lambda (func2 check2)
		       (for-each
			(lambda (func3 check3)
			  (revert-sound)
			  (set-to-1)
			  (cset-to-1 data)
			  (func)
			  (check data)
			  (func1)
			  (check1 data)
			  (func2)
			  (check2 data)
			  (func3)
			  (check3 data)
			  (if (not (vvequal data (channel->vct)))
			      (snd-display #__line__ ";4 case: ~A(~A(~A(~A))): ~A" 
					   (procedure-name func3) (procedure-name func2) (procedure-name func1) (procedure-name func) 
					   (channel->vct)))
			  (if (not (vvequal data (rev-channel->vct)))
			      (snd-display #__line__ ";4 rev case: ~A(~A(~A(~A))): ~A" 
					   (procedure-name func3) (procedure-name func2) (procedure-name func1) (procedure-name func) 
					   (rev-channel->vct))))
			(list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
			(list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
		     (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
		     (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
		  (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
		  (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
	       (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
	       (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen))
	      
	      ;; 5 case
	      (for-each
	       (lambda (func check)
		 (for-each
		  (lambda (func1 check1)
		    (for-each
		     (lambda (func2 check2)
		       (for-each
			(lambda (func3 check3)
			  (for-each
			   (lambda (func4 check4)
			     (revert-sound)
			     (set-to-1)
			     (cset-to-1 data)
			     (func)
			     (check data)
			     (func1)
			     (check1 data)
			     (func2)
			     (check2 data)
			     (func3)
			     (check3 data)
			     (func4)
			     (check4 data)
			     (if (not (vvequal data (channel->vct)))
				 (snd-display #__line__ ";5 case: ~A(~A(~A(~A(~A)))): ~A" 
					      (procedure-name func4) (procedure-name func3) (procedure-name func2) 
					      (procedure-name func1) (procedure-name func) 
					      (channel->vct))))
			   (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
			   (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
			(list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
			(list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
		     (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
		     (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
		  (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1)
		  (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1)))
	       (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1)
	       (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1))
	      
	      ;; 6 case
	      (for-each
	       (lambda (func check)
		 (for-each
		  (lambda (func1 check1)
		    (for-each
		     (lambda (func2 check2)
		       (for-each
			(lambda (func3 check3)
			  (for-each
			   (lambda (func4 check4)
			     (for-each
			      (lambda (func5 check5)
				(revert-sound)
				(set-to-1)
				(cset-to-1 data)
				(func)
				(check data)
				(func1)
				(check1 data)
				(func2)
				(check2 data)
				(func3)
				(check3 data)
				(func4)
				(check4 data)
				(func5)
				(check5 data)
				(if (not (vvequal data (channel->vct)))
				    (snd-display #__line__ ";6 case: ~A(~A(~A(~A(~A(~A))))): ~A" 
						 (procedure-name func5) (procedure-name func4) (procedure-name func3) 
						 (procedure-name func2) (procedure-name func1) (procedure-name func) 
						 (channel->vct))))
			      (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
			      (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
			   (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
			   (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
			(list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1 xen)
			(list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1 cxen)))
		     (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air ptree ptreec ptreec1)
		     (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air cptree cptreec cptreec1)))
		  (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air)
		  (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air)))
	       (list scale-by-two ramp-to-1 xramp-to-1 scale-by-half scale-mid on-air)
	       (list cscale-by-two cramp-to-1 cxramp-to-1 cscale-by-half cscale-mid con-air))
	      ))
	(close-sound ind))
      
      (set! (optimization) old-opt-val)
      
      (let ((ind (open-sound "oboe.snd")))
	(if (not (= (redo 1 ind 0) 0)) (snd-display #__line__ ";open redo with no ops: ~A" (redo)))
	(if (not (= (undo 1 ind 0) 0)) (snd-display #__line__ ";open undo with no ops: ~A" (undo)))
	(set! (cursor) 1000)
	(delete-sample 321)
	(if (not (= (cursor) 999)) (snd-display #__line__ ";delete-sample before cursor: ~A" (cursor)))
	(if (not (= (cursor ind 0 0) 1000)) (snd-display #__line__ ";delete-sample before cursor (0): ~A" (cursor ind 0 0)))
	(undo)
	(if (not (= (cursor) 1000)) (snd-display #__line__ ";delete-sample after cursor undo: ~A" (cursor)))
	(undo -1)
	(if (not (= (cursor) 999)) (snd-display #__line__ ";delete-sample before cursor redo: ~A" (cursor)))
	(redo -1)
	(delete-sample 1321)
	(if (not (= (cursor) 1000)) (snd-display #__line__ ";delete-sample after cursor: ~A" (cursor)))
	(undo)
	(delete-samples 0 100)
	(if (not (= (cursor) 900)) (snd-display #__line__ ";delete-samples before cursor: ~A" (cursor)))
	(undo)
	(delete-samples 1100 100)
	(if (not (= (cursor) 1000)) (snd-display #__line__ ";delete-samples after cursor: ~A" (cursor)))
	(undo)
	(insert-samples 100 100 (make-vct 100))
	(if (not (= (cursor) 1100)) (snd-display #__line__ ";insert-samples before cursor: ~A" (cursor)))
	(undo)
	(insert-samples 1100 100 (make-vct 100))
	(if (not (= (cursor) 1000)) (snd-display #__line__ ";insert-samples after cursor: ~A" (cursor)))
	(undo)
	(set! (samples 0 100) (make-vct 100))
	(if (not (= (cursor) 1000)) (snd-display #__line__ ";set-samples cursor: ~A" (cursor)))
	(set! (show-axes ind 0) show-x-axis-unlabelled)
	(update-time-graph)
	(set! (show-axes ind 0) show-all-axes-unlabelled)
	(update-time-graph)
	(close-sound ind))
      
      (let ((ind (new-sound "test.snd" :size 100)))
	(vct->channel (make-vct 3 1.0) 10 8)
	(if (fneq (maxamp ind 0) 1.0)
	    (snd-display #__line__ ";vct->channel size mismatch maxamp: ~A" (maxamp ind 0)))
	(if (not (vequal (channel->vct 0 20 ind 0)
			 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
	    (snd-display #__line__ ";vct->channel size mismatch: ~A" (channel->vct 0 20 ind 0)))
	(revert-sound ind)
	(set! (samples 10 5) (make-vct 3 1.0))
	(if (fneq (maxamp ind 0) 1.0)
	    (snd-display #__line__ ";set samples size mismatch maxamp: ~A" (maxamp ind 0)))
	(if (not (vequal (channel->vct 0 20 ind 0)
			 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
	    (snd-display #__line__ ";set samples size mismatch: ~A" (channel->vct 0 20 ind 0)))
	(revert-sound ind)
	(insert-samples 10 8 (make-vct 3 1.0) ind 0)
	(if (fneq (maxamp ind 0) 1.0)
	    (snd-display #__line__ ";insert samples size mismatch maxamp: ~A" (maxamp ind 0)))
	(if (not (vequal (channel->vct 0 20 ind 0)
			 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
	    (snd-display #__line__ ";insert samples size mismatch: ~A" (channel->vct 0 20 ind 0)))
	(close-sound ind))
      
      (let* ((index (open-sound "oboe.snd"))
	     (bnds (x-bounds index))
	     (xp (x-position-slider))
	     (yp (y-position-slider))
	     (xz (x-zoom-slider))
	     (yz (y-zoom-slider)))
	(if (not (string=? (snd-completion " open-so") " open-sound"))
	    (snd-display #__line__ ";completion: ~A" (snd-completion " open-so")))
					;	(if (not (string=? (snd-completion " open-sound") " open-sound"))
					;	    (snd-display #__line__ ";completion: ~A" (snd-completion " open-so")))
	(if (not (string=? (snd-completion " zoom-focus-r") " zoom-focus-right"))
	    (snd-display #__line__ ";completion: ~A" (snd-completion " zoom-focus-r")))
	(play "oboe.snd" :wait #t)
	(play "oboe.snd" :start 12000 :wait #t)
	(play "oboe.snd" :start 12000 :end 15000 :wait #t)
	(play :edit-position (- (edit-position) 1) :wait #t)
	(let ((old-speed (speed-control index))
	      (old-style (speed-control-style))
	      (old-open (show-controls index)))
	  (set! (show-controls index) #t)
	  (set! (speed-control index) -2.0)
	  (play index :start 12345 :wait #t)
	  (set! (speed-control-style) speed-control-as-semitone)
	  (set! (speed-control index) 0.5)
	  (set! (speed-control-style) speed-control-as-ratio)
	  (set! (speed-control index) 0.25)
	  (set! (speed-control index) old-speed)
	  (set! (speed-control-style) old-style)
	  (set! (show-controls index) old-open))
	(bomb index #t)
	(let ((k (disk-kspace "oboe.snd")))
	  (if (or (not (number? k))
		  (<= k 0))
	      (snd-display #__line__ ";disk-kspace = ~A" (disk-kspace "oboe.snd")))
	  (set! k (disk-kspace "/baddy/hiho"))
	  (if (not (= k -1))
	      (snd-display #__line__ ";disk-kspace of bogus file = ~A" (disk-kspace "/baddy/hiho"))))
	(if (not (= (transform-frames) 0)) (snd-display #__line__ ";transform-frames ~A?" (transform-frames)))
	(set! (transform-size) 512)
	
	(set! (transform-graph?) #t)
	(let ((pk (fft-peak index 0 1.0)))
	  (if (not pk) (snd-display #__line__ ";fft-peak? ")))
	(set! (time-graph?) #t)
	
	(catch #t
	       (lambda ()
		 (if (not (string=? (x-axis-label) "time")) (snd-display #__line__ ";def time x-axis-label: ~A" (x-axis-label)))
		 (set! (x-axis-label index 0 time-graph) "no time")
		 (if (not (string=? (x-axis-label) "no time")) (snd-display #__line__ ";time x-axis-label: ~A" (x-axis-label index 0 time-graph)))
		 
		 (update-transform-graph)
		 (if (not (string=? (x-axis-label index 0 transform-graph) "frequency")) (snd-display #__line__ ";get fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
		 (set! (x-axis-label index 0 transform-graph) "hiho")
		 (update-transform-graph)
		 (if (not (string=? (x-axis-label index 0 transform-graph) "hiho")) (snd-display #__line__ ";set set fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
		 (set! (x-axis-label index 0 transform-graph) "frequency") ; for later test
		 
		 (graph '(0 0 1 1 2 0) "lisp")
		 (update-lisp-graph)
		 (if (not (string=? (x-axis-label index 0 lisp-graph) "lisp")) (snd-display #__line__ ";def lisp x-axis-label: ~A" (x-axis-label index 0 lisp-graph)))
		 (set! (x-axis-label index 0 lisp-graph) "no lisp")
		 (if (not (string=? (x-axis-label index 0 lisp-graph) "no lisp")) (snd-display #__line__ ";lisp x-axis-label: ~A" (x-axis-label index 0 lisp-graph)))
		 
		 (set! (y-axis-label index 0 time-graph) "no amp")
		 (if (not (string=? (y-axis-label) "no amp")) (snd-display #__line__ ";time y-axis-label: ~A" (y-axis-label index 0 time-graph)))
		 (set! (y-axis-label index 0 lisp-graph) "no lamp")
		 (if (not (string=? (y-axis-label index 0 lisp-graph) "no lamp")) (snd-display #__line__ ";lisp y-axis-label: ~A" (y-axis-label index 0 lisp-graph)))
		 (set! (y-axis-label) #f)
		 (set! (y-axis-label index 0) "no amp")
		 (if (not (string=? (y-axis-label) "no amp")) (snd-display #__line__ ";time y-axis-label (time): ~A" (y-axis-label index 0 time-graph)))
		 (set! (y-axis-label index) #f))
	       (lambda args (snd-display #__line__ ";axis label error: ~A" args)))
	
	(graph-data (make-vct 4))
	(update-lisp-graph)
	(graph (vct 0 0 1 1 2 0))
	(do ((i 0 (+ 1 i))) 
	    ((= i 32)) 
	  (graph (vct 0 1 2)) 
	  (graph (list (vct 0 1 2) (vct 3 2 1) (vct 1 2 3)))
	  (graph (list (vct 0 1 2) (vct 3 2 1))))
	(set! (x-bounds) (list 0.0 0.01))
	(let ((data (make-graph-data)))
	  (if (vct? data)
	      (let ((mid (round (* .5 (vct-length data)))))
		(if (not (= (vct-length data) (+ 1 (- (right-sample) (left-sample)))))
		    (snd-display #__line__ ";make-graph-data bounds: ~A ~A -> ~A" (left-sample) (right-sample) (vct-length data)))
		(if (fneq (vct-ref data mid)
			  (sample (+ (left-sample) mid)))
		    (snd-display #__line__ ";make-graph-data[~D]: ~A ~A" mid (vct-ref data mid) (sample (+ (left-sample) mid)))))))
	(let ((data (make-graph-data index 0 0 100 199)))
	  (if (vct? data)
	      (begin
		(if (not (= (vct-length data) 100))
		    (snd-display #__line__ ";make-graph-data 100:199: ~A" (vct-length data)))
		(if (fneq (vct-ref data 50) (sample 50))
		    (snd-display #__line__ ";make-graph-data 50: ~A ~A" (vct-ref data 50) (sample 50))))))
	(set! (x-bounds) (list 0.0 0.1))
	(update-transform-graph)
	(catch 'no-such-axis
	       (lambda ()
		 (if (not (string=? (x-axis-label index 0 transform-graph) "frequency")) 
		     (snd-display #__line__ ";def fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
		 (set! (x-axis-label index 0 transform-graph) "fourier")
		 (if (not (string=? (x-axis-label index 0 transform-graph) "fourier")) 
		     (snd-display #__line__ ";fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
		 (set! (x-axis-label) "hiho")
		 
		 (set! (y-axis-label index 0 transform-graph) "spectra")
		 (let ((val (y-axis-label index 0 transform-graph)))
		   (if (or (not (string? val))
			   (not (string=? val "spectra")))
		       (snd-display #__line__ ";fft y-axis-label: ~A" val)))
		 (set! (y-axis-label) "hiho"))
	       (lambda args (snd-display #__line__ ";transform axis not displayed?")))
	
	(if (and (number? (transform-frames))
		 (= (transform-frames) 0))
	    (snd-display #__line__ ";transform-graph? transform-frames ~A?" (transform-frames)))
	(update-transform-graph)
	(let ((tag (catch #t (lambda () (peaks "/baddy/hiho")) (lambda args (car args)))))
	  (if (not (eq? tag 'cant-open-file)) (snd-display #__line__ ";peaks bad file: ~A" tag)))
	(peaks "tmp.peaks")
	(if (defined? 'read-line)
	    (let ((p (open-input-file "tmp.peaks")))
	      (if (not p)
		  (snd-display #__line__ ";peaks->tmp.peaks failed?")
		  (let ((line (read-line p)))
		    (if (or (not (string? line))
			    (not (string=? "Snd: fft peaks" (substring line 0 14))))
			(snd-display #__line__ ";peaks 1: ~A?" line))
		    (set! line (read-line p))
		    (set! line (read-line p))
		    (if (or (not (string? line))
			    (and (not (string=? "oboe.snd, fft 512 points beginning at sample 0 (0.000 secs), Blackman2" line))
				 (not (string=? (string-append "oboe.snd, fft 512 points beginning at sample 0 (0.000 secs), Blackman2" (string #\newline)) line))))
			(snd-display #__line__ ";peaks 2: ~A?" line))
		    (set! line (read-line p))
		    (set! line (read-line p))
		    (close-input-port p)))))
	(delete-file "tmp.peaks")
	(peaks)
	(if (and (provided? 'xm) 
		 (or (not (list-ref (dialog-widgets) 20))
		     (not (XtIsManaged (list-ref (dialog-widgets) 20)))))
	    (snd-display #__line__ ";peaks but no help?"))
	(dismiss-all-dialogs)
	(let* ((num-transforms 6)
	       (num-transform-graph-types 3))
	  (set! (transform-graph? index 0) #t)
	  (set! (transform-size index 0) 64)
	  (do ((i 0 (+ 1 i)))
	      ((= i num-transforms))
	    (set! (transform-type) (integer->transform i))
	    (if (not (transform? (integer->transform i))) (snd-display #__line__ ";transform? ~A?" i))
	    (do ((j 0 (+ 1 j)))
		((= j num-transform-graph-types))
	      (set! (transform-graph-type index 0) j)
	      (update-transform-graph index 0))))
	(set! (transform-type) fourier-transform)
	(if (not (transform? (transform-type))) (snd-display #__line__ ";transform? ~A ~A?" (transform-type) fourier-transform))
	(if (not (transform? autocorrelation)) (snd-display #__line__ ";transform? autocorrelation"))
	
	(if (read-only index) (snd-display #__line__ ";read-only open-sound: ~A?" (read-only index)))
	(set! (read-only index) #t)
	(if (not (read-only index)) (snd-display #__line__ ";set-read-only: ~A?" (read-only index)))
	(bind-key #\a 0 (lambda () (set! a-ctr 3)))
	(key (char->integer #\a) 0) 
	(if (not (= a-ctr 3)) (snd-display #__line__ ";bind-key: ~A?" a-ctr))
	(let ((str (with-output-to-string (lambda () (display (procedure-source (key-binding (char->integer #\a) 0)))))))
	  (if (not (string=? str "(lambda () (set! a-ctr 3))"))
	      (snd-display #__line__ ";key-binding: ~A?" str)))
	(unbind-key (char->integer #\a) 0)
	(set! a-ctr 0)
	(key (char->integer #\a) 0) 
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (let ((psf (eps-file)))
	    (if (and psf (string? psf))
		(begin
		  (if (file-exists? psf) (delete-file psf))
		  (set! (graph-style) i)
		  (graph->ps)
		  (if (not (file-exists? psf)) 
		      (snd-display #__line__ ";graph->ps: ~A?" psf)
		      (delete-file psf))))))
	(let ((err (catch 'cannot-print 
			  (lambda () 
			    (graph->ps "/bad/bad.eps"))
			  (lambda args 12345))))
	  (if (not (= err 12345)) (snd-display #__line__ ";graph->ps err: ~A?" err)))
	(let ((n2 (or (open-sound "2.snd") (open-sound "4.aiff"))))
	  (set! (transform-graph? n2) #t)
	  (set! (channel-style n2) channels-superimposed)
	  (if (not (= (channel-style n2) channels-superimposed)) (snd-display #__line__ ";channel-style->~D: ~A?" channels-superimposed (channel-style n2)))
	  (graph->ps "aaa.eps")
	  (set! (channel-style n2) channels-combined)
	  (if (not (= (channel-style n2) channels-combined)) (snd-display #__line__ ";channel-style->~D: ~A?" channels-combined (channel-style n2)))
	  (graph->ps "aaa.eps")
	  (set! (channel-style n2) channels-separate)
	  (if (not (= (channel-style n2) channels-separate)) (snd-display #__line__ ";channel-style->~D: ~A?" channels-separate (channel-style n2)))
	  (graph->ps "aaa.eps")
	  (close-sound n2))
	(if (= (channels index) 1)
	    (begin
	      (set! (channel-style index) channels-superimposed)
	      (if (not (= (channel-style index) channels-separate)) (snd-display #__line__ ";channel-style[0]->~D: ~A?" channels-separate (channel-style index)))))
	(set! (sync index) 32)
	(if (not (= (sync index) 32)) (snd-display #__line__ ";sync->32: ~A?" (sync index)))
	(if (not (>= (sync-max) 32)) (snd-display #__line__ ";sync-max 32: ~A" (sync-max)))
	(set! (sync index) 0)
	(set! (channel-sync index 0) 12)
	(if (not (= (channel-sync index 0) 12)) (snd-display #__line__ ";sync-chn->12: ~A?" (channel-sync index 0)))
	(set! (channel-sync index 0) 0)
	(if (not (= a-ctr 0)) (snd-display #__line__ ";unbind-key: ~A?" a-ctr))
	(if (fneq xp 0.0) (snd-display #__line__ ";x-position-slider: ~A?" xp))
	(if (fneq yp 0.0) (snd-display #__line__ ";y-position-slider: ~A?" yp))
	(if (and (fneq xz 0.04338) (fneq xz 1.0)) (snd-display #__line__ ";x-zoom-slider: ~A?" xz))
	(if (fneq yz 1.0) (snd-display #__line__ ";y-zoom-slider: ~A?" yz))
	(if (and (or (fneq (car bnds) 0.0) (fneq (cadr bnds) 0.1)) 
		 (or (fneq (car bnds) 0.0) (fneq (cadr bnds) 2.305))) ; open-hook from ~/.snd*
	    (snd-display #__line__ ";x-bounds: ~A?" bnds))
	(if (not (equal? (find-sound "oboe.snd") index)) (snd-display #__line__ ";oboe: index ~D /= ~D?" (find-sound "oboe.snd") index))
	(if (not (sound? index)) (snd-display #__line__ ";oboe: ~D not ok?" index))
	(if (not (= (chans index) 1)) (snd-display #__line__ ";oboe: chans ~D?" (chans index)))
	(if (not (= (channels index) 1)) (snd-display #__line__ ";oboe: channels ~D?" (channels index)))
	(if (not (= (frames index) 50828)) (snd-display #__line__ ";oboe: frames ~D?" (frames index)))
	(if (not (= (srate index) 22050)) (snd-display #__line__ ";oboe: srate ~D?" (srate index)))
	(if (not (= (data-location index) 28)) (snd-display #__line__ ";oboe: location ~D?" (data-location index)))
	(if (not (= (data-size index) (* 50828 2))) (snd-display #__line__ ";oboe: size ~D?" (data-size index)))
	(if (not (= (data-format index) mus-bshort)) (snd-display #__line__ ";oboe: format ~A?" (data-format index)))
	(if (fneq (maxamp index) .14724) (snd-display #__line__ ";oboe: maxamp ~F?" (maxamp index)))
	(if (not (= (maxamp-position index) 24971)) (snd-display #__line__ ";oboe: maxamp-position ~A?" (maxamp-position index)))
	(if (comment index) (snd-display #__line__ ";oboe: comment ~A?" (comment index)))
	(if (not (= (string-length "asdf") 4)) (snd-display #__line__ ";string-length: ~A?" (string-length "asdf")))
	(if (not (string=? (short-file-name index) "oboe.snd")) (snd-display #__line__ ";oboe short name: ~S?" (short-file-name index)))
	(let ((matches (count-matches (lambda (a) (> a .125)))))
	  (if (not (= matches 1313)) (snd-display #__line__ ";count-matches: ~A?" matches)))
	(let ((matches (count-matches (lambda (y) (let ((a (list .1 .2))) (> y (car a))))))) ; force xen not ptree
	  (if (not (= matches 2851)) (snd-display #__line__ ";unopt count-matches: ~A?" matches)))
	(let ((spot (find-channel (lambda (a) (> a .13)))))
	  (if (or (null? spot) (not (= (cadr spot) 8862))) (snd-display #__line__ ";find: ~A?" spot)))
	(set! (right-sample) 3000) 
	(let ((samp (right-sample)))
	  (if (> (abs (- samp 3000)) 1) (snd-display #__line__ ";right-sample: ~A?" samp)))
	(set! (left-sample) 1000) 
	(let ((samp (left-sample)))
	  (if (> (abs (- samp 1000)) 1) (snd-display #__line__ ";left-sample: ~A?" samp)))
	(let ((eds (edits)))
	  (if (or (not (= (car eds) 0)) (not (= (cadr eds) 0)))
	      (snd-display #__line__ ";edits: ~A?" eds))
	  (if (not (= (edit-position) (car eds)))
	      (snd-display #__line__ ";edit-position: ~A ~A?" (edit-position) eds)))
	(play index :channel 0 :wait #t)
	
	(bomb index #f)
	(if (not (selection-creates-region)) (set! (selection-creates-region) #t))
	(select-all index 0) 
	(let ((r0 (car (regions)))
	      (sel (selection)))
	  (if (not (selection?)) (snd-display #__line__ ";selection?"))
	  (if (not (selection? sel)) (snd-display #__line__ ";selection? sel"))
	  (if (not (region? r0)) (snd-display #__line__ ";region?"))
	  (if (not (= (selection-chans) 1)) (snd-display #__line__ ";selection-chans(1): ~A" (selection-chans)))
	  (if (not (= (channels sel) 1)) (snd-display #__line__ ";generic selection-chans(1): ~A" (channels sel)))
	  (if (not (= (selection-srate) (srate index))) (snd-display #__line__ ";selection-srate: ~A ~A" (selection-srate) (srate index)))
	  (if (not (= (srate sel) (srate index))) (snd-display #__line__ ";generic selection-srate: ~A ~A" (srate sel) (srate index)))
	  (if (fneq (region-maxamp r0) (maxamp index)) (snd-display #__line__ ";region-maxamp (1): ~A?" (region-maxamp r0)))
	  (if (not (= (region-maxamp-position r0) (maxamp-position index)))
	      (snd-display #__line__ ";region-maxamp-position (1): ~A ~A?" (region-maxamp-position r0) (maxamp-position index)))
	  (if (fneq (selection-maxamp index 0) (maxamp index)) (snd-display #__line__ ";selection-maxamp (1): ~A?" (selection-maxamp index 0)))
	  (if (fneq (maxamp sel index 0) (maxamp index)) (snd-display #__line__ ";generic selection-maxamp (1): ~A?" (maxamp sel index 0)))
	  (if (not (= (selection-maxamp-position index 0) (maxamp-position index)))
	      (snd-display #__line__ ";selection-maxamp-position (1): ~A ~A?" (selection-maxamp-position index 0) (maxamp-position index)))
	  (save-region r0 "temp.dat")
	  (if (file-exists? "temp.dat")
	      (delete-file "temp.dat")
	      (snd-display #__line__ ";save-region file disappeared?"))
	  (play r0 :wait #t) ;needs to be #t here or it never gets run
	  (if (not (= (length (regions)) 1)) (snd-display #__line__ ";regions: ~A?" (regions)))
	  (if (not (selection-member? index)) (snd-display #__line__ ";selection-member?: ~A" (selection-member? index)))
	  (if (not (= (region-srate r0) 22050)) (snd-display #__line__ ";region-srate: ~A?" (region-srate r0)))
	  (if (not (= (region-chans r0) 1)) (snd-display #__line__ ";region-chans: ~A?" (region-chans r0)))
	  (if (not (equal? (region-home r0) (list "oboe.snd" 0 50827))) (snd-display #__line__ ";region-home: ~A" (region-home r0)))
	  (if (not (= (region-frames r0) 50828)) (snd-display #__line__ ";region-frames: ~A?" (region-frames r0)))
	  (if (not (= (selection-frames) 50828)) (snd-display #__line__ ";selection-frames: ~A?" (selection-frames 0)))
	  (if (not (= (frames sel) 50828)) (snd-display #__line__ ";generic selection-frames: ~A?" (frames sel)))
	  (if (not (= (length sel) 50828)) (snd-display #__line__ ";generic length selection-frames: ~A?" (length sel)))
	  (if (not (= (selection-position) 0)) (snd-display #__line__ ";selection-position: ~A?" (selection-position)))
	  (if (not (= (region-position r0 0) 0)) (snd-display #__line__ ";region-position: ~A?" (region-position r0 0)))
	  (if (fneq (region-maxamp r0) (maxamp index)) (snd-display #__line__ ";region-maxamp: ~A?" (region-maxamp r0)))
	  (if (fneq (selection-maxamp index 0) (maxamp index)) (snd-display #__line__ ";selection-maxamp: ~A?" (selection-maxamp index 0)))
	  (let ((samps1 (samples->vct 0 50827 index 0))
		(samps2 (region->vct r0 0 50828 0))
		(vr (make-sampler 0 index 0 1)))
	    (if (not (sampler? vr)) (snd-display #__line__ ";~A not sampler?" vr))
	    (if (not (= (sampler-position vr) 0)) (snd-display #__line__ ";initial sampler-position: ~A" (sampler-position vr)))
	    (if (not (equal? (sampler-home vr) (list index 0))) 
		(snd-display #__line__ ";sampler-home: ~A ~A?" (sampler-home vr) (list index 0)))
	    (if (sampler-at-end? vr) (snd-display #__line__ ";~A init at end?" vr))
	    (let ((err (catch #t
			      (lambda ()
				(region->vct r0 -1 1233))
			      (lambda args (car args)))))
	      (if (not (eq? err 'no-such-sample)) (snd-display #__line__ ";region->vct -1: ~A" err)))
	    (let ((err (catch #t
			      (lambda ()
				(region->vct r0 12345678 1))
			      (lambda args (car args)))))
	      ;; should this return 'no-such-sample?
	      (if err (snd-display #__line__ ";region->vct 12345678: ~A" err)))
	    (let ((reader-string (format #f "~A" vr)))
	      (if (not (string=? reader-string "#<sampler: oboe.snd[0: 0] from 0, at 0, forward>"))
		  (snd-display #__line__ ";sampler actually got: [~S]" reader-string)))
	    (let ((evr vr))
	      (if (not (equal? evr vr)) (snd-display #__line__ ";sampler equal? ~A ~A" vr evr)))
	    (catch 'break
		   (lambda ()
		     (do ((i 0 (+ 1 i)))
			 ((= i 50827))
		       (if (not (= (if (odd? i) (next-sample vr) (read-sample vr)) (vct-ref samps1 i) (vct-ref samps2 i)))
			   (begin
			     (snd-display #__line__ ";readers disagree at ~D" i)
			     (throw 'break)))))
		   (lambda args (car args)))
	    (free-sampler vr)))
	(let ((var (catch #t (lambda () (make-sampler 0 index -1)) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display #__line__ ";make-sampler bad chan (-1): ~A" var)))
	(let ((var (catch #t (lambda () (make-sampler 0 index 1)) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display #__line__ ";make-sampler bad chan (1): ~A, ~A" var index)))
	(let ((fd (make-sampler 0)))
	  (if (mix-sampler? fd) (snd-display #__line__ ";sampler: mix ~A" fd))
	  (if (region-sampler? fd) (snd-display #__line__ ";sampler: region ~A" fd))
	  (if (not (sampler? fd)) (snd-display #__line__ ";sampler: normal ~A" fd))
	  (if (not (= (sampler-position fd) 0)) (snd-display #__line__ ";sampler: position: ~A" fd))
	  (free-sampler fd)
	  (let ((str (format #f "~A" fd)))
	    (if (not (string=? (my-substring str (- (string-length str) 16)) "at eof or freed>"))
		(snd-display #__line__ ";freed sampler: ~A [~A]?" str (my-substring str (- (string-length str) 16))))))
	(let* ((reg (car (regions)))
	       (chns (region-chans reg))
	       (var (catch #t (lambda () (make-region-sampler reg 0 (+ chns 1))) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display #__line__ ";make-region-sampler bad chan (2): ~A ~A" var (regions)))
	  (let ((tag (catch #t (lambda () (make-region-sampler reg 0 0 -2)) (lambda args args))))
	    (if (not (eq? (car tag) 'no-such-direction))
		(snd-display #__line__ ";make-region-sampler bad dir (-2): ~A" tag))))
	
	(revert-sound index)
	(insert-sample 100 .5 index) 
	(let ((var (catch #t (lambda () (insert-sound "oboe.snd" 0 1)) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display #__line__ ";insert-sound bad chan (1): ~A" var)))
	(let ((var (catch #t (lambda () (insert-sample -12 1.0)) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-sample))
	      (snd-display #__line__ ";insert-sample bad pos: ~A" var)))
	(set! (show-axes index 0) show-no-axes)
	(update-transform-graph index) 
	(update-time-graph index) 
	(if (or (fneq (sample 100) .5)
		(not (= (frames index) 50829)))
	    (snd-display #__line__ ";insert-sample: ~A ~A?" (sample 100) (frames index)))
	(let ((v0 (make-vector 3))
	      (v1 (make-vct 3)))
	  (vct-fill! v1 .75)
	  (do ((i 0 (+ 1 i))) ((= i 3)) (vector-set! v0 i .25))
	  (insert-samples 200 3 v0 index) 
	  (insert-samples 300 3 v1 index) 
	  (if (or (fneq (sample 201) .25)
		  (fneq (sample 301) .75)
		  (not (= (frames index) 50835)))
	      (snd-display #__line__ ";insert-samples: ~A ~A ~A?" (sample 201) (sample 301) (frames index))))
	(save-sound-as "hiho.snd" index mus-next mus-bshort :srate 22050)
	(let ((nindex (view-sound "hiho.snd")))
	  (if (fneq (sample 101 nindex) (sample 101 index))
	      (snd-display #__line__ ";save-sound-as: ~A ~A?" (sample 101 nindex) (sample 101 index)))
	  (if (not (read-only nindex)) (snd-display #__line__ ";read-only view-sound: ~A?" (read-only nindex)))
	  
	  (set! (speed-control-style nindex) speed-control-as-semitone)
	  (if (not (= (speed-control-style nindex) speed-control-as-semitone))
	      (snd-display #__line__ ";speed-control-style set semi: ~A" (speed-control-style nindex)))
	  (set! (speed-control-tones nindex) -8)
	  (if (not (= (speed-control-tones nindex) 12))
	      (snd-display #__line__ ";speed-control-tones -8: ~A" (speed-control-tones nindex)))
	  (set! (speed-control-tones nindex) 18)
	  (if (not (= (speed-control-tones nindex) 18))
	      (snd-display #__line__ ";speed-control-tones 18: ~A" (speed-control-tones nindex)))
	  (graph->ps "aaa.eps")
	  (close-sound nindex))
	(revert-sound index)
	(set! (sample 50 index) .5) 
	(if (fneq (sample 50) .5) (snd-display #__line__ ";set-sample: ~A?" (sample 50)))
	(let ((v0 (make-vector 3)))
	  (do ((i 0 (+ 1 i))) ((= i 3)) (vector-set! v0 i .25))
	  (set! (samples 60 3 index) v0) 
	  (if (or (fneq (sample 60) .25) (fneq (sample 61) .25))
	      (snd-display #__line__ ";set-samples: ~A ~A ~A?" (sample 60) (sample 61) (sample 62))))
	(set! (samples 10 3 index) (list 0.1 0.2 0.3))
	(if (not (vequal (samples->vct 10 3 index) (vct 0.1 0.2 0.3)))
	    (snd-display #__line__ ";set-samples via list: ~A" (samples->vct 10 3 index)))
	(revert-sound index)
	(save-sound-as "temporary.snd" index)
	(set! (samples 100000 20000 index) "temporary.snd")
	(if (not (vequal (samples->vct 110000 10) (samples->vct 10000 10)))
	    (snd-display #__line__ ";set samples to self: ~A ~A" (samples->vct 110000 10) (samples->vct 10000 10)))
	(revert-sound index)
	(delete-sample 100 index) 
	(if (not (file-exists? "temporary.snd"))
	    (snd-display #__line__ ";set-samples temp deleted?"))
	(delete-file "temporary.snd")
	(if (not (= (frames index) 50827)) (snd-display #__line__ ";delete-sample: ~A?" (frames index)))
	(delete-samples 0 100 index) 
	(if (not (= (frames index) 50727)) (snd-display #__line__ ";delete-samples: ~A?" (frames index)))
	(revert-sound index)
	(let ((maxa (maxamp index)))
	  (scale-to .5 index) 
	  (let ((newmaxa (maxamp index)))
	    (if (fneq newmaxa .5) (snd-display #__line__ ";scale-to: ~A?" newmaxa))
	    (undo 1 index) 
	    (scale-by 2.0 index) 
	    (set! newmaxa (maxamp index))
	    (if (fneq newmaxa (* 2.0 maxa)) (snd-display #__line__ ";scale-by: ~A?" newmaxa))
	    (revert-sound index)
	    (scale-by -1 index)
	    (mix "oboe.snd")
	    (if (fneq (maxamp index 0) 0.0) (snd-display #__line__ ";invert+mix->~A" (maxamp)))
	    (revert-sound index)
	    (select-all index) 
	    (if (not (= (length (regions)) 2)) (snd-display #__line__ ";regions(2): ~A?" (regions)))
	    (scale-selection-to .5) 
	    (set! newmaxa (maxamp index))
	    (if (fneq newmaxa .5) (snd-display #__line__ ";scale-selection-to: ~A?" newmaxa))
	    (revert-sound index)
	    (select-all index) 
	    (scale-selection-by 2.0) 
	    (set! newmaxa (maxamp index))
	    (if (fneq newmaxa (* 2.0 maxa)) (snd-display #__line__ ";scale-selection-by: ~A?" newmaxa))
	    (revert-sound index)
	    (with-temporary-selection (lambda () (scale-selection-by 2.0)) 0 (frames) index 0)
	    (set! newmaxa (maxamp index))
	    (if (fneq newmaxa (* 2.0 maxa)) (snd-display #__line__ ";with-temporary-selection: ~A?" newmaxa))
	    (revert-sound index)
	    (let ((samp999 (sample 999 index 0))
		  (samp1001 (sample 1001 index 0)))
	      (with-temporary-selection (lambda () (scale-selection-to 2.0)) 1000 1 index 0)
	      (if (fneq (sample 1000 index 0) 2.0) (snd-display #__line__ ";with-temporary-selection 1000: ~A" (sample 1000 index 0)))
	      (if (fneq (sample 999 index 0) samp999) (snd-display #__line__ ";with-temporary-selection 999: ~A from ~A" (sample 999 index 0) samp999))
	      (if (fneq (sample 1001 index 0) samp1001) (snd-display #__line__ ";with-temporary-selection 1001: ~A from ~A" (sample 1001 index 0) samp1001)))
	    (revert-sound index)
	    (make-selection 100 199 index 0)
	    (let ((old-start (selection-position index 0))
		  (old-len (selection-frames index 0)))
	      (with-temporary-selection (lambda () (scale-selection-to 2.0)) 1000 1 index 0)
	      (if (not (selection?)) (snd-display #__line__ ";with-temporary-selection restore?"))
	      (if (not (selection-member? index 0)) (snd-display #__line__ ";with-temporary-selection not member?"))
	      (if (not (= (selection-position index 0) old-start)) (snd-display #__line__ ";with-temporary-selection start: ~A" (selection-position index 0)))
	      (if (not (= (selection-frames index 0) old-len)) (snd-display #__line__ ";with-temporary-selection len: ~A" (selection-frames index 0))))
	    (revert-sound index)
	    (select-all index) 
	    (let ((rread (make-region-sampler (car (regions)) 0))
		  (sread (make-sampler 0 index))
		  (rvect (region->vct (car (regions)) 0 100))
		  (svect (samples 0 100 index)))
	      (if (fneq (vct-ref rvect 1) (region-sample (car (regions)) 1))
		  (snd-display #__line__ ";region-sample: ~A ~A?" (region-sample (car (regions)) 1) (vct-ref rvect 1)))
	      (do ((i 0 (+ 1 i)))
		  ((= i 100))
		(let ((rval (next-sample rread))
		      (sval (next-sample sread)))
		  (if (fneq rval sval) (snd-display #__line__ ";sample-read: ~A ~A?" rval sval))
		  (if (fneq rval (vct-ref rvect i)) (snd-display #__line__ ";region-samples: ~A ~A?" rval (vct-ref rvect i)))
		  (if (fneq sval (vct-ref svect i)) (snd-display #__line__ ";samples: ~A ~A?" sval (vct-ref svect i)))))
	      (free-sampler rread) 
	      (let ((val0 (next-sample sread)))
		(if (sampler-at-end? sread) (snd-display #__line__ ";premature end?"))
		(previous-sample sread)
		(let ((val1 (previous-sample sread)))
		  (if (fneq val0 val1) (snd-display #__line__ ";previous-sample: ~A ~A?" val0 val1))))
	      (free-sampler sread))))
	(revert-sound index)
	(let ((s100 (sample 100))
	      (s40 (sample 40))
	      (len (frames))
	      (addlen (mus-sound-frames "fyow.snd")))
	  (set! (cursor-style) cursor-line)
	  (set! (cursor-size) 25)
	  (set! (cursor index) 50) 
	  (if (not (= (cursor-style) cursor-line))
	      (snd-display #__line__ ";cursor-style: ~A? " (cursor-style)))
	  (if (not (= (cursor-size) 25))
	      (snd-display #__line__ ";cursor-size: ~A? " (cursor-size)))
	  (set! (cursor-style) cursor-cross)
	  (set! (cursor-size) 15)
	  (set! (cursor index 0) 30) 
	  (set! (cursor-style) cursor-line)
	  (set! (cursor index 0) 20) 
	  (if with-gui
	      (begin
		(set! (cursor-style index 0)
		      (lambda (snd chn ax)
			(let* ((point (cursor-position))
			       (x (car point))
			       (y (cadr point))
			       (size (floor (/ (cursor-size) 2))))
			  (draw-line (- x size) (- y size) (+ x size) (+ y size) snd chn cursor-context)    
			  (draw-line (- x size) (+ y size) (+ x size) (- y size) snd chn cursor-context))))
		(if (not (procedure? (cursor-style index 0))) (snd-display #__line__ ";set cursor-style to proc: ~A" (cursor-style index 0)))))
	  (set! (cursor index) 50)
	  (insert-sound "fyow.snd" (cursor) 0 index 0) 
	  (if (or (fneq (sample 40) s40) (not (fneq (sample 100) s100)) (fneq (sample 100) 0.001831))
	      (snd-display #__line__ ";insert-sound: ~A?" (sample 100)))
	  (if (not (= (frames) (+ len addlen))) (snd-display #__line__ ";insert-sound len: ~A?" (frames)))
	  (save-sound-as "not-temporary.snd")
	  (insert-samples 0 100 "not-temporary.snd")
	  (set! (cursor index 0 0) (- (frames index 0 0) 2))
	  (revert-sound)
	  (if (not (= (cursor index 0) (- (frames index 0) 2)))
	      (snd-display #__line__ ";set edpos cursor: ~A ~A ~A" (cursor) (cursor index 0 0) (- (frames index 0 0) 2)))
	  (if (not (file-exists? "not-temporary.snd"))
	      (snd-display #__line__ ";insert-samples deleted its file?")
	      (delete-file "not-temporary.snd"))
	  (let ((id (make-region 0 99)))
	    (insert-region id 60 index) 
	    (if (not (= (frames) (+ len 100))) (snd-display #__line__ ";insert-region len: ~A?" (frames)))
	    (if (fneq (sample 100) s40) (snd-display #__line__ ";insert-region: ~A ~A?" (sample 100) s40))
	    (let ((var (catch #t (lambda () (insert-region (integer->region (+ 1000 (apply max (map region->integer (regions))))) 0)) (lambda args args))))
	      (if (not (eq? (car var) 'no-such-region))
		  (snd-display #__line__ ";insert-region bad id: ~A" var)))
	    (save-region id "fmv.snd")
	    (if (not (= (mus-sound-header-type "fmv.snd") mus-next))
		(snd-display #__line__ ";save-region header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
	    (if (not (= (mus-sound-data-format "fmv.snd") mus-out-format))
		(snd-display #__line__ ";save-region format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
	    (if (not (= (mus-sound-srate "fmv.snd") (region-srate id)))
		(snd-display #__line__ ";save-region srate: ~A (~A)" (mus-sound-srate "fmv.snd") (region-srate id)))
	    (if (not (= (mus-sound-chans "fmv.snd") (region-chans id)))
		(snd-display #__line__ ";save-region chans: ~A (~A)" (mus-sound-chans "fmv.snd") (region-chans id)))
	    (if (not (= (mus-sound-frames "fmv.snd") (region-frames id)))
		(snd-display #__line__ ";save-region length: ~A (~A)" (mus-sound-frames "fmv.snd") (region-frames id)))
	    (if (not (= (region-position id 0) 0))
		(snd-display #__line__ ";save-region position: ~A" (region-position id 0)))
	    (delete-file "fmv.snd")
	    (save-region id "fmv.snd" mus-riff mus-lshort "this is a comment")
	    (if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
		(snd-display #__line__ ";save-region riff header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
	    (if (not (= (mus-sound-data-format "fmv.snd") mus-lshort))
		(snd-display #__line__ ";save-region lshort format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
	    (if (not (= (mus-sound-frames "fmv.snd") (region-frames id)))
		(snd-display #__line__ ";save-region length: ~A (~A)" (mus-sound-frames "fmv.snd") (region-frames id)))
	    (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
		(snd-display #__line__ ";save-region comment: ~A" (mus-sound-comment "fmv.snd")))
	    (delete-file "fmv.snd")
	    (save-region id :file "fmv.snd" :header-type mus-riff :data-format mus-lshort :comment "this is a comment")
	    (if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
		(snd-display #__line__ ";save-region opt riff header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
	    (if (not (= (mus-sound-data-format "fmv.snd") mus-lshort))
		(snd-display #__line__ ";save-region opt lshort format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
	    (if (not (= (mus-sound-frames "fmv.snd") (region-frames id)))
		(snd-display #__line__ ";save-region opt length: ~A (~A)" (mus-sound-frames "fmv.snd") (region-frames id)))
	    (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
		(snd-display #__line__ ";save-region opt comment: ~A" (mus-sound-comment "fmv.snd")))
	    (delete-file "fmv.snd")
	    (save-region id :comment "this is a comment" :file "fmv.snd" :data-format mus-lshort :header-type mus-riff)
	    (if (not (= (mus-sound-header-type "fmv.snd") mus-riff))
		(snd-display #__line__ ";save-region opt1 riff header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
	    (if (not (= (mus-sound-data-format "fmv.snd") mus-lshort))
		(snd-display #__line__ ";save-region opt1 lshort format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
	    (if (not (= (mus-sound-frames "fmv.snd") (region-frames id)))
		(snd-display #__line__ ";save-region opt1 length: ~A (~A)" (mus-sound-frames "fmv.snd") (region-frames id)))
	    (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
		(snd-display #__line__ ";save-region opt1 comment: ~A" (mus-sound-comment "fmv.snd")))
	    (delete-file "fmv.snd")
	    (save-region id "fmv.snd" :data-format mus-bshort)
	    (if (not (= (mus-sound-header-type "fmv.snd") mus-next))
		(snd-display #__line__ ";save-region opt2 next header: ~A?" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
	    (if (not (= (mus-sound-data-format "fmv.snd") mus-bshort))
		(snd-display #__line__ ";save-region opt2 bshort format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
	    (delete-file "fmv.snd")
	    ))
	(close-sound index)
	(let ((var (catch #t (lambda () (new-sound "hi.snd" 0 1 100 0)) (lambda args args))))
	  (if (not (eq? (car var) 'out-of-range))
	      (snd-display #__line__ ";new-sound bad chan: ~A" var)))
	(set! index (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "unequal lens"))
	(insert-silence 0 1000 index 1)
	(if (or (not (= (frames index 0) 1))
		(not (= (frames index 1) 1001)))
	    (snd-display #__line__ ";silence 1: ~A ~A" (frames index 0) (frames index 1)))
	(save-sound index)
	(if (or (not (= (frames index 0) 1001))
		(not (= (frames index 1) 1001)))
	    (snd-display #__line__ ";saved silence 1: ~A ~A" (frames index 0) (frames index 1)))
	(if (not (= (mus-sound-frames "fmv.snd") 1001))
	    (snd-display #__line__ ";saved framers silence 1: ~A" (mus-sound-frames "fmv.snd")))
	(let ((v0 (samples->vct 0 1000 index 0))
	      (v1 (samples->vct 0 1000 index 1)))
	  (if (fneq (vct-peak v0) 0.0)
	      (snd-display #__line__ ";auto-pad 0: ~A" (vct-peak v0)))
	  (if (fneq (vct-peak v1) 0.0)
	      (snd-display #__line__ ";silence 0: ~A" (vct-peak v1))))
	(close-sound index)
	(delete-file "fmv.snd")
	
	(set! index (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "unequal lens"))
	(pad-channel 0 1000 index 1)
	(if (or (not (= (frames index 0) 1))
		(not (= (frames index 1) 1001)))
	    (snd-display #__line__ ";pad-channel 1: ~A ~A" (frames index 0) (frames index 1)))
	(let ((v0 (samples->vct 0 1000 index 0))
	      (v1 (samples->vct 0 1000 index 1)))
	  (if (fneq (vct-peak v0) 0.0)
	      (snd-display #__line__ ";pad 0: ~A" (vct-peak v0)))
	  (if (fneq (vct-peak v1) 0.0)
	      (snd-display #__line__ ";pad 1: ~A" (vct-peak v1))))
	(map-channel (lambda (n) 1.0) 0 2 index 0)
	(map-channel (lambda (n) 1.0) 0 1002 index 1)
	(pad-channel 0 1000 index 0 1)
	(if (not (= (frames index 1) 1002))
	    (snd-display #__line__ ";pad-channel ed 1: ~A ~A" (frames index 0) (frames index 1)))
	(close-sound index)
	(delete-file "fmv.snd")
	
	(let ((ind (open-sound "1a.snd")))
	  (scale-to 1.0 ind 0)
	  (make-selection 1000 2000 ind 0)
	  (filter-selection-and-smooth .01 (vct .25 .5 .5 .5 .25))
					;	  (if (fneq (sample 1500 ind 0) -0.0045776) (snd-display #__line__ ";filter-selection-and-smooth: ~A" (sample 1500 ind 0)))
	  (revert-sound ind)
	  (close-sound ind))
	
	(set! index (new-sound "fmv.snd" mus-ircam mus-bshort 22050 1 "this is a comment"))
	(let ((v0 (make-vct 128)))
	  (vct-set! v0 64 .5)
	  (vct-set! v0 127 .5)
	  (vct->samples 0 128 v0 index 0)
	  (make-selection 0 126) 
	  (smooth-selection) 
	  (set! v0 (samples->vct 0 128 index 0 v0))
	  (if (or (fneq (sample 127) .5) (fneq (sample 120) .4962) (fneq (sample 32) 0.07431) (fneq (sample 64) 0.25308))
	      (snd-display #__line__ ";smooth-selection: ~A?" v0))
	  (revert-sound index)
	  (vct-fill! v0 0.0)
	  (vct-set! v0 10 .5)
					;(vct->samples 0 128 v0 index 0) 
	  (vct->channel v0)
	  (select-all) 
	  (set! (sinc-width) 40)
	  (src-selection 0.5) 
	  (set! v0 (samples->vct 0 128 index 0 v0))
	  (if (or (fneq (sample 20) .5) (fneq (sample 30) 0.0) (fneq (sample 17) -.1057) )
	      (snd-display #__line__ ";src-selection: ~A?" v0))
	  (revert-sound index)
	  (vct-fill! v0 0.0)
	  (vct-set! v0 10 .5)
					;(vct->samples 0 128 v0 index 0) 
	  (vct->channel v0 0)
	  (select-all) 
	  (filter-selection '(0 0 .1 1 1 0) 40) 
	  (set! v0 (samples->vct 0 128 index 0 v0)) 
	  (if (or (fneq (sample 29) .1945) (fneq (sample 39) -.0137) (fneq (sample 24) -0.01986))
	      (snd-display #__line__ ";filter-selection: ~A?" v0))
	  (revert-sound index)
	  (vct-fill! v0 1.0)
	  (vct->samples 0 128 v0 index 0) 
	  (select-all) 
	  (filter-selection (make-one-zero :a0 .5 :a1 0.0))
	  (set! v0 (samples->vct 0 128 index 0 v0)) 
	  (if (or (fneq (sample 29) .5) (fneq (sample 39) .5) (fneq (sample 24) 0.5))
	      (snd-display #__line__ ";filter-selection one-zero: ~A?" v0))
	  (revert-sound index)
	  (vct-fill! v0 1.0)
	  (vct->samples 0 128 v0 index 0) 
	  (if (file-exists? "fmv5.snd") (delete-file "fmv5.snd"))
	  (select-all) 
	  (env-selection '(0 0 1 1 2 0) 1.0) 
	  (set! v0 (samples->vct 0 128 index 0 v0)) 
	  (if (or (fneq (sample 64) 1.0) (fneq (sample 20) .3125) (fneq (sample 119) 0.127))
	      (snd-display #__line__ ";env-selection [len: ~A]: ~A ~A ~A ~A?" (selection-frames) (sample 64) (sample 20) (sample 119) v0))
	  (save-selection "fmv5.snd" mus-next mus-bint 22050 "") ;1.0->-1.0 if short
	  (revert-sound index)
	  (let ((tag (catch #t (lambda () (file->array "/baddy/hiho" 0 0 128 v0)) (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-file)) (snd-display #__line__ ";file->array w/o file: ~A" tag)))
	  (let ((tag (catch #t (lambda () (file->array "fmv5.snd" 123 0 128 v0)) (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-channel)) (snd-display #__line__ ";file->array w/o channel: ~A" tag)))
	  (file->array "fmv5.snd" 0 0 128 v0) 
	  (if (or (fneq (vct-ref v0 64) 1.0) (fneq (vct-ref v0 20) .3125) (fneq (vct-ref v0 119) 0.127))
	      (snd-display #__line__ ";save-selection: ~A ~A ~A ~A?" (vct-ref v0 64) (vct-ref v0 20) (vct-ref v0 119) v0))
	  (if (not (= (mus-sound-header-type "fmv5.snd") mus-next))
	      (snd-display #__line__ ";save-selection type: ~A?" (mus-header-type-name (mus-sound-header-type "fmv5.snd"))))
	  (if (not (= (mus-sound-data-format "fmv5.snd") mus-bint))
	      (snd-display #__line__ ";save-selection format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv5.snd"))))
	  (if (not (= (mus-sound-srate "fmv5.snd") 22050))
	      (snd-display #__line__ ";save-selection srate: ~A?" (mus-sound-srate "fmv5.snd")))
	  (vct-fill! v0 0.0)
	  (vct-set! v0 100 .5)
	  (vct-set! v0 2 -.5)
	  (vct->samples 0 128 v0 index 0) 
	  (select-all) 
	  (without-errors (reverse-selection)) 
	  (save-selection "fmv4.snd" mus-riff mus-lfloat 44100 "this is a comment")
	  (set! v0 (samples->vct 0 128 index 0 v0)) 
	  (if (or (fneq (sample 27) 0.5) (fneq (sample 125) -.5))
	      (snd-display #__line__ ";reverse-selection: ~A?" v0))
	  (file->array "fmv4.snd" 0 0 128 v0) 
	  (if (or (fneq (sample 27) 0.5) (fneq (sample 125) -.5))
	      (snd-display #__line__ ";save reverse-selection: ~A?" v0))
	  (if (not (= (mus-sound-header-type "fmv4.snd") mus-riff))
	      (snd-display #__line__ ";save-selection type 1: ~A?" (mus-header-type-name (mus-sound-header-type "fmv4.snd"))))
	  (if (not (= (mus-sound-data-format "fmv4.snd") mus-lfloat))
	      (snd-display #__line__ ";save-selection format 1: ~A?" (mus-data-format-name (mus-sound-data-format "fmv4.snd"))))
	  (if (not (= (mus-sound-srate "fmv4.snd") 44100))
	      (snd-display #__line__ ";save-selection srate 1: ~A?" (mus-sound-srate "fmv4.snd")))
	  (if (not (string=? (mus-sound-comment "fmv4.snd") "this is a comment"))
	      (snd-display #__line__ ";save-selection comment: ~A?" (mus-sound-comment "fmv4.snd")))
	  (delete-file "fmv4.snd")
	  (save-selection :file "fmv4.snd" :header-type mus-riff :data-format mus-lfloat :srate 44100 :comment "this is a comment")
	  (if (not (= (mus-sound-header-type "fmv4.snd") mus-riff))
	      (snd-display #__line__ ";save-selection opt type 1: ~A?" (mus-header-type-name (mus-sound-header-type "fmv4.snd"))))
	  (if (not (= (mus-sound-data-format "fmv4.snd") mus-lfloat))
	      (snd-display #__line__ ";save-selection opt format 1: ~A?" (mus-data-format-name (mus-sound-data-format "fmv4.snd"))))
	  (if (not (= (mus-sound-srate "fmv4.snd") 44100))
	      (snd-display #__line__ ";save-selection opt srate 1: ~A?" (mus-sound-srate "fmv4.snd")))
	  (if (not (string=? (mus-sound-comment "fmv4.snd") "this is a comment"))
	      (snd-display #__line__ ";save-selection opt comment: ~A?" (mus-sound-comment "fmv4.snd")))
	  (delete-file "fmv4.snd")
	  (save-selection :file "fmv4.snd" :data-format mus-bfloat :channel 0)
	  (if (and (not (= (mus-sound-header-type "fmv4.snd") mus-next))
		   (not (= (mus-sound-header-type "fmv4.snd") mus-ircam)))
	      (snd-display #__line__ ";save-selection opt1 type 1: ~A?" (mus-header-type-name (mus-sound-header-type "fmv4.snd"))))
	  (if (not (= (mus-sound-data-format "fmv4.snd") mus-bfloat))
	      (snd-display #__line__ ";save-selection opt1 format 1: ~A?" (mus-data-format-name (mus-sound-data-format "fmv4.snd"))))
	  (if (not (= (mus-sound-chans "fmv4.snd") 1))
	      (snd-display #__line__ ";save-selection opt1 chans: ~A?" (mus-sound-chans "fmv4.snd")))
	  (delete-file "fmv4.snd")
	  (revert-sound index)
	  (vct-fill! v0 0.0)
	  (vct-set! v0 2 1.0)
	  (let ((v1 (make-vct 256)))
	    (do ((i 0 (+ 1 i)))
		((= i 128))
	      (vct-set! v1 i (vct-ref v0 i)))
	    (vct->samples 0 128 v1 index 0))
	  (select-all)
	  (if (mus-clipping) (set! (mus-clipping) #f))
	  (if (clipping) (set! (clipping) #f))
	  (convolve-selection-with "fmv5.snd" .5) 
	  (set! v0 (samples->vct 0 128 index 0 v0))
	  (if (fneq (sample 66) -.5) (snd-display #__line__ ";convolve-selection-with: ~A ~A ~A?" (vct-ref v0 66) (sample 66) v0))
	  (close-sound index))
	(let* ((obind (open-sound "oboe.snd"))
	       (vol (maxamp obind))
	       (dur (frames)))
	  (set! (amp-control obind) 2.0)
	  (if (fffneq (amp-control obind) 2.0) (snd-display #__line__ ";set amp-control ~A" (amp-control obind)))
	  (reset-controls obind)
	  (if (ffneq (amp-control obind) 1.0) (snd-display #__line__ ";reset amp-control ~A" (amp-control obind)))
	  (set! (amp-control-bounds obind) (list 0.0 4.0))
	  (if (not (equal? (amp-control-bounds obind) (list 0.0 4.0))) (snd-display #__line__ ";amp-control-bounds: ~A" (amp-control-bounds)))
	  (set! (amp-control obind) 2.0)
	  (if (eq? (without-errors (apply-controls obind)) 'no-such-sound) (snd-display #__line__ ";apply-controls can't find oboe.snd?"))
	  (let ((newamp (maxamp obind)))
	    (if (> (abs (- (* 2.0 vol) newamp)) .05) (snd-display #__line__ ";apply amp: ~A -> ~A?" vol newamp))
	    (set! (amp-control-bounds obind) (list 0.0 8.0))
	    (set! (speed-control-bounds obind) (list 1.0 5.0))
	    (if (not (equal? (speed-control-bounds obind) (list 1.0 5.0))) (snd-display #__line__ ";speed-control-bounds: ~A" (speed-control-bounds)))
	    (set! (speed-control obind) 0.5)
	    (set! (speed-control-bounds obind) (list .05 20.0))
	    (add-mark 1234)
	    (apply-controls obind)
	    (let ((newdur (frames obind)))
	      (set! (speed-control obind) 1.0)
	      (if (not (< (- newdur (* 2.0 dur)) 256)) (snd-display #__line__ ";apply speed: ~A -> ~A?" dur newdur))
	      ;; within 256 which is apply's buffer size (it always flushes full buffers) 
	      (set! (contrast-control? obind) #t)
	      (set! (contrast-control-bounds obind) (list 0.5 2.5))
	      (if (not (equal? (contrast-control-bounds obind) (list 0.5 2.5))) (snd-display #__line__ ";contrast-control-bounds: ~A" (contrast-control-bounds)))
	      (set! (contrast-control obind) 1.0)
	      (apply-controls obind)
	      (set! (contrast-control-bounds obind) (list 0.0 10.0))
	      (if (not (equal? (contrast-control-bounds obind) (list 0.0 10.0))) (snd-display #__line__ ";contrast-control-bounds (2): ~A" (contrast-control-bounds)))
	      (let ((secamp (maxamp obind))
		    (secdur (frames obind)))
		(if (fneq secamp .989) (snd-display #__line__ ";apply contrast: ~A?" secamp))
		(if (not (= secdur newdur)) (snd-display #__line__ ";apply contrast length: ~A -> ~A?" newdur secdur))
		(undo 3 obind)
		(set! (reverb-control? obind) #t)
		(set! (reverb-control-scale-bounds obind) (list 0.0 1.0))
		(if (not (equal? (reverb-control-scale-bounds obind) (list 0.0 1.0))) 
		    (snd-display #__line__ ";reverb-control-scale-bounds: ~A" (reverb-control-scale-bounds)))
		(set! (reverb-control-length-bounds obind) (list 0.0 2.0))
		(if (not (equal? (reverb-control-length-bounds obind) (list 0.0 2.0))) 
		    (snd-display #__line__ ";reverb-control-length-bounds: ~A" (reverb-control-length-bounds)))
		(set! (reverb-control-scale obind) .2)
		(apply-controls obind)
		(let ((revamp (maxamp obind))
		      (revdur (frames obind)))
		  (if (ffneq revamp .214) (snd-display #__line__ ";apply reverb scale: ~A?" revamp))
		  (if (not (< (- revdur (+ 50828 (round (* (reverb-control-decay) 22050)))) 256)) 
		      (snd-display #__line__ ";apply reverb length: ~A?" revdur))
		  (undo 1 obind)
		  (set! (expand-control? obind) #t)
		  (set! (expand-control-bounds obind) (list 1.0 3.0))
		  (if (not (equal? (expand-control-bounds obind) (list 1.0 3.0))) (snd-display #__line__ ";expand-control-bounds: ~A" (expand-control-bounds)))
		  (set! (expand-control obind) 1.5)
		  (apply-controls obind)
		  (let ((expamp (maxamp obind))
			(expdur (frames obind)))
		    (if (> (abs (- expamp .152)) .05) (snd-display #__line__ ";apply expand-control scale: ~A?" expamp))
		    (if (not (> expdur (* 1.25 50828))) (snd-display #__line__ ";apply expand-control length: ~A?" expdur))
		    (set! (expand-control-bounds obind) (list 0.001 20.0))
		    (undo 1 obind)
		    (set! (filter-control? obind) #t)
		    (set! (filter-control-order obind) 40)
		    (set! (filter-control-envelope obind) '(0 0 1 .5 2 0))
		    (apply-controls obind)
		    (let ((fltamp (maxamp obind))
			  (fltdur (frames obind)))
		      (if (> (abs (- fltamp .02)) .005) (snd-display #__line__ ";apply filter scale: ~A?" fltamp))
		      (if (> (- fltdur (+ 40 50828)) 256) (snd-display #__line__ ";apply filter length: ~A?" fltdur))
		      (undo 1 obind)))))))
	  (revert-sound obind)
	  (make-selection 1000 1000)
	  (scale-selection-to .1)
	  (scale-selection-by 2.0)
	  (make-selection 2000 2001)
	  (scale-selection-by 2.0)
	  (scale-selection-to .5)
	  (make-selection 1000 2001)
	  (scale-selection-to .5)
	  (scale-selection-by .5)
	  (make-selection 2000 2000)
	  (scale-selection-by 2.0)
	  (scale-selection-to .5)
	  (make-selection 1000 1001)
	  (scale-selection-to .1)
	  (scale-selection-by 2.0)
	  (make-selection 999 2002)
	  (scale-selection-to 1.0)
	  (scale-selection-by .5)
	  (let ((tree (edit-tree))
		(true-tree '((0 0 0 998 1.0 0.0 0.0 0) 
			     (999 0 999 999 0.999969720840454 0.0 0.0 0) 
			     (1000 0 1000 1000 6.09052181243896 0.0 0.0 0) 
			     (1001 0 1001 1001 0.999969720840454 0.0 0.0 0) 
			     (1002 0 1002 1999 0.499984979629517 0.0 0.0 0) 
			     (2000 0 2000 2000 7.54652404785156 0.0 0.0 0) 
			     (2001 0 2001 2001 3.7732629776001 0.0 0.0 0) 
			     (2002 0 2002 2002 0.999969720840454 0.0 0.0 0) 
			     (2003 0 2003 50827 1.0 0.0 0.0 0) 
			     (50828 -2 0 0 0.0 0.0 0.0 0))))
	    (if (not (= (length tree) (length true-tree)))
		(snd-display #__line__ ";edit trees are not same length: ~A ~A?" (length tree) (length true-tree))
		(let ((len (length tree)))
		  (do ((i 0 (+ 1 i)))
		      ((= i len))
		    (let ((branch (list-ref tree i))
			  (true-branch (list-ref true-tree i)))
		      (if (or (not (= (car branch) (car true-branch)))
			      (not (= (cadr branch) (cadr true-branch)))
			      (not (= (caddr branch) (caddr true-branch)))
			      (not (= (cadddr branch) (cadddr true-branch)))
			      (fneq (list-ref branch 4) (list-ref true-branch 4)))
			  (snd-display #__line__ ";edit trees disagree at ~D: ~A ~A" i branch true-branch)))))))
	  (insert-silence 1001 8)
	  (insert-silence 900 50)
	  (insert-silence 2005 1)
	  (insert-silence 999 2)
	  (let ((tree (edit-tree))
		(true-tree '((0 0 0 899 1.0 0.0 0.0 0) 
			     (900 -1 0 49 0.0 0.0 0.0 0) 
			     (950 0 900 948 1.0 0.0 0.0 0) 
			     (999 -1 0 1 0.0 0.0 0.0 0) 
			     (1001 0 949 998 1.0 0.0 0.0 0) 
			     (1051 0 999 999 0.999969720840454 0.0 0.0 0) 
			     (1052 0 1000 1000 6.09052181243896 0.0 0.0 0) 
			     (1053 -1 0 7 0.0 0.0 0.0 0) 
			     (1061 0 1001 1001 0.999969720840454 0.0 0.0 0)
			     (1062 0 1002 1946 0.499984979629517 0.0 0.0 0) 
			     (2007 -1 0 0 0.0 0.0 0.0 0) 
			     (2008 0 1947 1999 0.499984979629517 0.0 0.0 0) 
			     (2061 0 2000 2000 7.54652404785156 0.0 0.0 0) 
			     (2062 0 2001 2001 3.7732629776001 0.0 0.0 0) 
			     (2063 0 2002 2002 0.999969720840454 0.0 0.0 0) 
			     (2064 0 2003 50827 1.0 0.0 0.0 0) 
			     (50889 -2 0 0 0.0 0.0 0.0 0))))
	    (if (not (= (length tree) (length true-tree)))
		(snd-display #__line__ ";silenced edit trees are not same length: ~A ~A?" (length tree) (length true-tree))
		(let ((len (length tree)))
		  (do ((i 0 (+ 1 i)))
		      ((= i len))
		    (let ((branch (list-ref tree i))
			  (true-branch (list-ref true-tree i)))
		      (if (or (not (= (car branch) (car true-branch)))
			      (not (= (cadr branch) (cadr true-branch)))
			      (not (= (caddr branch) (caddr true-branch)))
			      (not (= (cadddr branch) (cadddr true-branch)))
			      (fneq (list-ref branch 4) (list-ref true-branch 4)))
			  (snd-display #__line__ ";silenced edit trees disagree at ~D: ~A ~A" i branch true-branch)))))))
	  (if (or (fneq (sample 998) -.03)
		  (fneq (sample 999) 0.0)
		  (fneq (sample 1000) 0.0)
		  (fneq (sample 1001) -.03))
	      (snd-display #__line__ ";insert-silence [999 for 2]: ~A ~A ~A ~A?" (sample 998) (sample 999) (sample 1000) (sample 1001) ))
	  (if (or (fneq (sample 2006) -.033)
		  (fneq (sample 2007) 0.0)
		  (fneq (sample 2008) -.033))
	      (snd-display #__line__ ";insert-silence [2007 for 1]: ~A ~A ~A?" (sample 2006) (sample 2007) (sample 2008)))
	  (revert-sound obind)
	  (add-mark 1200 obind 0)
	  (let ((mark-num (length (marks obind 0))))
	    (scale-by 2.0 obind 0)
	    (let ((mark-now (length (marks obind 0))))
	      (if (not (= mark-num mark-now))
		  (snd-display #__line__ ";mark lost after scaling?"))
	      (set! (selection-position) 0)
	      (set! (selection-frames) 100)
	      (scale-selection-to .5)
	      (set! mark-now (length (marks obind 0)))
	      (if (not (= mark-num mark-now))
		  (snd-display #__line__ ";mark lost after selection scaling?")))
	    (let ((m1 (add-mark 1000)))
	      (set! (cursor obind 0) 100)
	      (key (char->integer #\u) 4 obind)
	      (key (char->integer #\1) 0 obind)
	      (key (char->integer #\0) 0 obind)
	      (key (char->integer #\0) 0 obind)
	      (key (char->integer #\o) 4 obind)
	      (if (not (= (mark-sample m1) 1100))
		  (snd-display #__line__ ";mark after zeros: ~D (1100)? " (mark-sample m1)))
	      (set! (cursor obind) 0)
	      (key (char->integer #\j) 4 obind)
	      (if (not (= (cursor obind) 1100)) (snd-display #__line__ ";c-j to ~A" (cursor obind)))
	      (add-mark 100)
	      (set! (cursor obind) 0)
	      (key (char->integer #\u) 4 obind)
	      (key (char->integer #\2) 0 obind)
	      (key (char->integer #\j) 4 obind)
	      (if (not (= (cursor obind) 1100)) (snd-display #__line__ ";c-u 2 c-j ~A" (cursor obind)))
	      (key (char->integer #\-) 4 obind)
	      (key (char->integer #\j) 4 obind)
	      (if (not (= (cursor obind) 100)) (snd-display #__line__ ";c-- c-j ~A" (cursor obind)))))
	  (revert-sound obind)
	  (let ((frs (frames obind)))
	    (make-region 0 999 obind 0)
	    (if (not (selection?)) (snd-display #__line__ ";make-region but no selection? ~A" (selection?)))
	    (delete-selection)
	    (if (not (= (frames obind) (- frs 1000)))
		(snd-display #__line__ ";delete-selection: ~A?" (frames obind)))
	    (let ((val (sample 0 obind 0)))
	      (undo)
	      (if (fneq (sample 1000) val)
		  (snd-display #__line__ ";delete-selection val: ~A ~A" val (sample 1000)))
	      (insert-selection)
	      (let ((var (catch #t (lambda () (insert-selection 0 obind 123)) (lambda args args))))
		(if (not (eq? (car var) 'no-such-channel))
		    (snd-display #__line__ ";insert-selection bad chan: ~A" var)))
	      (let ((var (catch #t (lambda () (mix-selection 0 obind 123)) (lambda args args))))
		(if (not (eq? (car var) 'no-such-channel))
		    (snd-display #__line__ ";mix-selection bad chan: ~A" var)))
	      (if (not (= (frames obind) (+ frs 1000)))
		  (snd-display #__line__ ";insert-selection: ~A?" (frames obind)))
	      (if (fneq (sample 2000) val)
		  (snd-display #__line__ ";insert-selection val: ~A ~A" val (sample 2000)))
	      (set! val (sample 900))
	      (mix-selection)
	      (if (fneq (sample 900) (* 2 val))
		  (snd-display #__line__ ";mix-selection val: ~A ~A" (* 2 val) (sample 900)))
	      (if (not (= (frames obind) (+ frs 1000)))
		  (snd-display #__line__ ";mix-selection len: ~A?" (frames obind)))))
	  (close-sound obind))
	
	(let* ((ind (open-sound "2.snd"))
	       (apply-to-sound 0)
	       (apply-to-channel 1)
	       (apply-to-selection 2)
	       (len (frames ind)))
	  (set! (sync ind) 1)
	  (set! (speed-control ind) .5)
	  (apply-controls ind apply-to-sound) ; temp 1
	  (if (> (abs (- (frames) (* 2 len))) 256)
	      (snd-display #__line__ ";apply srate .5: ~A ~A" (frames) (* 2 len)))
	  (make-selection 0 (frames))
	  (set! (speed-control ind) .5)
	  (apply-controls ind apply-to-selection) ; temp 2
	  (if (> (abs (- (frames) (* 4 len))) 256)
	      (snd-display #__line__ ";apply srate .5 to selection: ~A ~A" (frames) (* 4 len)))
	  (env-sound '(0 0 1 1) 0 (frames) 32.0) ; temp 3
	  (let ((reg (select-all))) ; make multi-channel region
	    (insert-region reg 0) ; temp 4
	    (insert-selection 0))  ; temp 5
	  (revert-sound ind)
	  (set! (speed-control) .5)
	  (set! (sync ind) 0)
	  (set! (selected-channel ind) 1)
	  (apply-controls ind apply-to-channel)
	  (if (> (abs (- (frames ind 1) (* 2 len))) 256)
	      (snd-display #__line__ ";apply srate .5 to chan 1: ~A ~A" (frames ind 1) (* 2 len)))
	  (if (not (= (frames ind 0) len))
	      (snd-display #__line__ ";apply srate .5 but chan 0: ~A ~A" (frames ind 0) len))
	  (set! (speed-control ind) .5)
	  (apply-controls ind apply-to-sound 1000)
	  (make-selection 2000 4000)
	  (set! (speed-control ind) .5)
	  (apply-controls ind apply-to-selection)
	  (set! (selected-channel ind) #f)
	  (if (selected-channel ind) (snd-display #__line__ ";selected-channel #f: ~A" (selected-channel ind)))
	  (close-sound ind))
	
	(let* ((ind1 (open-sound "oboe.snd"))
	       (mx1 (maxamp ind1 0))
	       (ind2 (open-sound "2.snd"))
	       (mx20 (maxamp ind2 0))
	       (mx21 (maxamp ind2 1)))
	  (select-sound ind1)
	  (scale-sound-by 2.0)
	  (let ((nmx (maxamp ind1 0)))
	    (if (fneq (* 2 mx1) nmx) (snd-display #__line__ ";scale-sound-by 2.0: ~A ~A?" mx1 nmx))
	    (if (not (equal? (edit-fragment 1 ind1 0) (list "scale-channel 2.000 0 #f" "scale" 0 50828)))
		(snd-display #__line__ ";scale-sound-by: ~A?" (edit-fragment 1 ind1 0))))
	  (scale-sound-to 0.5)
	  (let ((nmx (maxamp ind1 0)))
	    (if (fneq nmx 0.5) (snd-display #__line__ ";scale-sound-to 0.5: ~A?" nmx))
	    (if (not (equal? (edit-fragment 2 ind1 0) (list "scale-channel 1.698 0 #f" "scale" 0 50828)))
		(snd-display #__line__ ";scale-sound-to: ~A?" (edit-fragment 2 ind1 0))))
	  (scale-sound-by 0.0 0 1000 ind1 0)
	  (let ((nmx (maxamp ind1 0)))
	    (if (fneq 0.5 nmx) (snd-display #__line__ ";scale-sound-by 0.0: ~A ~A?" mx1 nmx))
	    (if (not (equal? (edit-fragment 3 ind1 0) (list "scale-channel 0.000 0 1000" "scale" 0 1000)))
		(snd-display #__line__ ";scale-sound-by 0.0: ~A?" (edit-fragment 3 ind1 0))))
	  (let* ((v (samples->vct 0 1000 ind1 0))
		 (pk (vct-peak v)))
	    (if (fneq pk 0.0) (snd-display #__line__ ";scale-sound-by 0.0 [0:1000]: ~A?" pk)))
	  (revert-sound ind1)
	  (let ((oldv (samples->vct 12000 10 ind1 0)))
	    (scale-sound-by 2.0 12000 10 ind1 0)
	    (let ((newv (samples->vct 12000 10 ind1 0)))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(if (fneq (* 2.0 (vct-ref oldv i)) (vct-ref newv i))
		    (snd-display #__line__ ";scale ~D: ~A ~A?" i (vct-ref oldv i) (vct-ref newv i)))))
	    (if (not (equal? (edit-fragment 1 ind1 0) (list "scale-channel 2.000 12000 10" "scale" 12000 10)))
		(snd-display #__line__ ";scale-sound-by 2.0 [12000:10]: ~A?" (edit-fragment 1 ind1 0))))
	  (revert-sound ind1)
	  (select-sound ind2)
	  (scale-sound-by 2.0)
	  (let ((nmx (maxamp ind2 0)))
	    (if (fneq (* 2 mx20) nmx) (snd-display #__line__ ";2:0 scale-sound-by 2.0: ~A ~A?" mx20 nmx)))
	  (let ((nmx (maxamp ind2 1)))
	    (if (fneq (* 2 mx21) nmx) (snd-display #__line__ ";2:1 scale-sound-by 2.0: ~A ~A?" mx21 nmx)))
	  (scale-sound-to 0.5)
	  (let ((nmx (max (maxamp ind2 0) (maxamp ind2 1))))
	    (if (fneq nmx 0.5) (snd-display #__line__ ";2 scale-sound-to 0.5: ~A (~A)?" nmx (maxamp ind2))))
	  (scale-sound-by 0.0 0 1000 ind2 1)
	  (if (not (equal? (edit-fragment 3 ind2 1) (list "scale-channel 0.000 0 1000" "scale" 0 1000)))
	      (snd-display #__line__ ";2:1 scale-sound-by 0.0: ~A?" (edit-fragment 3 ind2 1)))
	  (let* ((v (samples->vct 0 1000 ind2 1))
		 (pk (vct-peak v)))
	    (if (fneq pk 0.0) (snd-display #__line__ ";2:1 scale-sound-by 0.0 [0:1000]: ~A?" pk)))
	  (revert-sound ind2)
	  (let ((oldv (samples->vct 12000 10 ind2 0)))
	    (scale-sound-by 2.0 12000 10 ind2 0)
	    (let ((newv (samples->vct 12000 10 ind2 0)))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(if (fneq (* 2.0 (vct-ref oldv i)) (vct-ref newv i))
		    (snd-display #__line__ ";2 scale ~D: ~A ~A?" i (vct-ref oldv i) (vct-ref newv i))))))
	  (revert-sound ind2)
	  (set! (sync ind2) 3)
	  (set! (sync ind1) 3)
	  (scale-sound-by 2.0)
	  (let ((nmx (maxamp ind1 0)))
	    (if (fneq mx1 nmx) (snd-display #__line__ ";sync scale-sound-by 2.0: ~A ~A?" mx1 nmx)))
	  (let ((nmx (maxamp ind2 0)))
	    (if (fneq (* 2 mx20) nmx) (snd-display #__line__ ";2:0 sync scale-sound-by 2.0: ~A ~A?" mx20 nmx)))
	  (let ((nmx (maxamp ind2 1)))
	    (if (fneq (* 2 mx21) nmx) (snd-display #__line__ ";2:1 sync scale-sound-by 2.0: ~A ~A?" mx21 nmx)))
	  (scale-sound-to 1.0 20000 40000 ind2 1)
	  (let ((nmx (maxamp ind1 0)))
	    (if (fneq mx1 nmx) (snd-display #__line__ ";sync scale-sound-to 1.0: ~A ~A?" mx1 nmx)))
	  (let ((nmx (maxamp ind2 0)))
	    (if (fneq (* 2 mx20) nmx) (snd-display #__line__ ";2:0 sync scale-sound-to 1.0: ~A ~A?" mx20 nmx)))
	  (let ((nmx (maxamp ind2 1)))
	    (if (fneq nmx 1.0) (snd-display #__line__ ";2:1 sync scale-sound-to 1.0: ~A?" nmx)))
	  
	  (close-sound ind1)
	  (close-sound ind2))
	
	(let* ((ind (open-sound "now.snd")))
	  (set! (amp-control ind) .5)
	  (if (ffneq (amp-control ind) .5) (snd-display #__line__ ";amp-control (.5): ~A?" (amp-control ind)))
	  (set! (amp-control ind 0) .25)
	  (if (ffneq (amp-control ind) .5) (snd-display #__line__ ";amp-control after local set (.5): ~A?" (amp-control ind)))
	  (if (ffneq (amp-control ind 0) .25) (snd-display #__line__ ";amp-control 0 (.25): ~A?" (amp-control ind 0)))
	  (set! (amp-control ind) 1.0)
	  (if (ffneq (amp-control ind) 1.0) (snd-display #__line__ ";amp-control (1.0): ~A?" (amp-control ind)))
	  (if (ffneq (amp-control ind 0) .25) (snd-display #__line__ ";amp-control 0 after set (.25): ~A?" (amp-control ind 0)))
	  (set! (transform-graph? ind 0) #t)
	  (set! (transform-graph-type ind 0) graph-as-sonogram)
	  (update-transform-graph ind 0)
	  (let ((val (transform-frames ind 0)))
	    (if (or (not (list? val))
		    (fneq (car val) 1.0)
		    (not (= (caddr val) 256)))
		(snd-display #__line__ ";transform-frames: ~A (~A)" val (transform-size ind 0))))
	  (close-sound ind)
	  (set! ind (open-sound "4.aiff"))
	  (if (ffneq (amp-control ind) 1.0) (snd-display #__line__ ";amp-control upon open (1.0): ~A?" (amp-control ind)))
	  (if (ffneq (amp-control ind 2) 1.0) (snd-display #__line__ ";amp-control 2 upon open (1.0): ~A?" (amp-control ind 2)))
	  (set! (amp-control ind) .5)
	  (if (ffneq (amp-control ind 2) .5) (snd-display #__line__ ";amp-control 2 after global set (.5): ~A?" (amp-control ind 2)))
	  (set! (amp-control ind 2) .25)
	  (if (ffneq (amp-control ind 2) .25) (snd-display #__line__ ";amp-control 2 (.25): ~A?" (amp-control ind 2)))
	  (if (ffneq (amp-control ind 1) .5) (snd-display #__line__ ";amp-control 1 after local set (.5): ~A?" (amp-control ind 1)))
	  (let ((after-ran #f))
	    (reset-hook! after-apply-controls-hook)
	    (add-hook! after-apply-controls-hook (lambda (snd) (set! after-ran snd)))
	    (apply-controls ind)
	    (if (not (equal? ind after-ran)) (snd-display #__line__ ";after-apply-controls-hook: ~A?" after-ran))
	    (reset-hook! after-apply-controls-hook))
	  (revert-sound ind)
	  (set! (sync ind) 1)
	  (scale-to (vct .1 .2))
	  (let ((mx (maxamp ind #t)))
	    (if (or (fneq (list-ref mx 0) .1)
		    (fneq (list-ref mx 1) .2)
		    (fneq (list-ref mx 2) .2)
		    (fneq (list-ref mx 3) .2))
		(snd-display #__line__ ";scale to with vector: ~A" mx)))
	  (set! (filter-control-envelope ind) '(0 0 1 1))
	  (if (not (feql '(0.0 0.0 1.0 1.0) (filter-control-envelope ind))) 
	      (snd-display #__line__ ";set filter-control-envelope: ~A?" (filter-control-envelope ind)))
	  (set! (filter-control-order ind) 20)
	  (if (not (vequal (filter-control-coeffs ind)
			   (vct -0.007 0.010 -0.025 0.029 -0.050 0.055 -0.096 0.109 -0.268 0.241 
				0.241 -0.268 0.109 -0.096 0.055 -0.050 0.029 -0.025 0.010 -0.007)))
	      (snd-display #__line__ ";highpass coeffs: ~A" (filter-control-coeffs ind)))
	  (set! (filter-control-envelope ind) (filter-control-envelope ind))
	  (if (not (feql '(0.0 0.0 1.0 1.0) (filter-control-envelope ind))) 
	      (snd-display #__line__ ";set filter-control-envelope to self: ~A?" (filter-control-envelope ind)))
	  (set! (filter-control-envelope ind) '(0 1 1 0))
	  (if (not (vequal (filter-control-coeffs ind)
			   (vct 0.003 0.002 0.004 0.002 0.007 0.003 0.014 0.012 0.059 0.394 
				0.394 0.059 0.012 0.014 0.003 0.007 0.002 0.004 0.002 0.003)))
	      (snd-display #__line__ ";lowpass coeffs: ~A" (filter-control-coeffs ind)))
	  (close-sound ind))
	
	(let* ((obind (open-sound "4.aiff"))
	       (amps (maxamp obind #t))
	       (times (maxamp-position obind #t)))
	  (if (not (equal? times (list 810071 810071 810071 810071)))
	      (snd-display #__line__ ";4.aiff times: ~A" times))
	  (if (< (window-width) 600) 
	      (set! (window-width) 600))
	  (if (< (window-height) 600)
	      (set! (window-height) 600))
	  (set! (x-bounds obind 0) (list 0.0 0.1))
	  (set! (show-axes obind 0) show-x-axis)
	  (update-time-graph)
	  (set! (amp-control obind) 0.1)
	  (select-channel 2)
	  (if (eq? (without-errors (apply-controls obind 1)) 'no-such-sound) (snd-display #__line__ ";apply-controls can't find 4.aiff?"))
	  (let ((newamps (maxamp obind #t)))
	    (if (or (fneq (car amps) (car newamps))
		    (fneq (cadr amps) (cadr newamps))
		    (> (abs (- (* 0.1 (caddr amps)) (caddr newamps))) .05)
		    (fneq (cadddr amps) (cadddr newamps)))
		(snd-display #__line__ ";apply amps:~%  ~A ->~%  ~A?" amps newamps))
	    (undo 1 obind 2)
	    (set! (amp-control obind) 0.1)
	    (make-region 0 (frames obind) obind 1)
	    (without-errors (apply-controls obind 2))
	    (set! newamps (maxamp obind #t))
	    (if (or (fneq (car amps) (car newamps))
		    (> (abs (- (* 0.1 (cadr amps)) (cadr newamps))) .05)
		    (fneq (caddr amps) (caddr newamps))
		    (fneq (cadddr amps) (cadddr newamps)))
		(snd-display #__line__ ";apply selection amp:~%  ~A ->~%  ~A?" amps newamps))
	    (if with-gui
		(let* ((axinfo (axis-info obind 0 time-graph))
		       (losamp (car axinfo))
		       (hisamp (cadr axinfo))
		       (x0 (list-ref axinfo 2))
		       (y0 (list-ref axinfo 3))
		       (x1 (list-ref axinfo 4))
		       (y1 (list-ref axinfo 5))
		       (xpos (+ x0 (* .5 (- x1 x0))))
		       (ypos (+ y0 (* .75 (- y1 y0)))))
		  (define (cp-x x) (floor (+ (list-ref axinfo 10) 
					     (* (- x x0) (/ (- (list-ref axinfo 12) (list-ref axinfo 10)) 
							    (- x1 x0))))))
		  (define (cp-y y) (floor (+ (list-ref axinfo 13) 
					     (* (- y1 y) (/ (- (list-ref axinfo 11) (list-ref axinfo 13)) 
							    (- y1 y0))))))
		  (select-channel 0)
		  (set! (cursor obind) 100)
		  (let ((xy (cursor-position obind)))
		    (if (fneq (position->x (car xy)) (/ (cursor obind) (srate obind)))
			(snd-display #__line__ ";cursor-position: ~A ~A ~A?" (car xy) (position->x (car xy)) (/ (cursor obind) (srate obind)))))
		  (if (fneq (position->x (x->position xpos)) xpos)
		      (snd-display #__line__ ";x<->position: ~A ~A?" (position->x (x->position xpos)) xpos))
		  (if (> (abs (- (position->y (y->position ypos)) ypos)) .5)
		      (snd-display #__line__ ";y<->position: ~A ~A?" (position->y (y->position ypos)) ypos))
		  (if (not (= losamp (left-sample obind 0)))
		      (snd-display #__line__ ";axis-info[0 losamp]: ~A ~A?" losamp (left-sample obind 0)))
		  (if (not (= hisamp (right-sample obind 0)))
		      (snd-display #__line__ ";axis-info[1 hisamp]: ~A ~A?" hisamp (right-sample obind 0)))
		  (if (fneq (list-ref axinfo 6) 0.0)
		      (snd-display #__line__ ";axis-info[6 xmin]: ~A?" (list-ref axinfo 6)))
		  (if (fneq (list-ref axinfo 7) -1.0)
		      (snd-display #__line__ ";axis-info[7 ymin]: ~A?" (list-ref axinfo 7)))
		  (if (fneq (list-ref axinfo 9) 1.0)
		      (snd-display #__line__ ";axis-info[9 ymax]: ~A?" (list-ref axinfo 9)))
		  (if (> (abs (apply - (our-x->position obind x0))) 1) 
		      (snd-display #__line__ ";x0->position: ~A?" (our-x->position obind x0)))
		  (if (> (abs (apply - (our-x->position obind x1))) 1) 
		      (snd-display #__line__ ";x1->position: ~A?" (our-x->position obind x1)))
		  (if (> (abs (apply - (our-x->position obind (* 0.5 (+ x0 x1))))) 1)
		      (snd-display #__line__ ";xmid->position: ~A?" (our-x->position obind (* 0.5 (+ x0 x1)))))
		  (if (not full-test)
		      (begin
			(if (> (abs (- (x->position xpos) (cp-x xpos))) 1)
			    (snd-display #__line__ ";cp-x .5: ~A ~A?" (x->position xpos) (cp-x xpos)))
			(if (> (abs (- (y->position ypos) (cp-y ypos))) 1)
			    (snd-display #__line__ ";cp-y .75: ~A ~A?" (y->position ypos) (cp-y ypos)))
			(do ((i 0 (+ 1 i)))
			    ((= i 10))
			  (let ((xpos (+ x0 (random (- x1 x0))))
				(ypos (+ y0 (random (- y1 y0)))))
			    (if (> (abs (- (x->position xpos) (cp-x xpos))) 1)
				(snd-display #__line__ ";cp-x[~A] ~A: ~A ~A?" i xpos (x->position xpos) (cp-x xpos)))
			    (if (> (abs (- (y->position ypos) (cp-y ypos))) 1)
				(snd-display #__line__ ";cp-y[~A] ~A: ~A ~A?" i ypos (y->position ypos) (cp-y ypos)))
			    (if (fneq (position->x (cp-x xpos)) xpos)
				(snd-display #__line__ ";x->position cp-x ~A ~A" xpos (position->x (cp-x xpos))))
			    (if (fffneq (position->y (cp-y ypos)) ypos)
				(snd-display #__line__ ";y->position cp-y ~A ~A" ypos (position->y (cp-y ypos))))))))
		  (set! (left-sample obind 0) 1234)
		  (if (not (= 1234 (car (axis-info obind 0))))
		      (snd-display #__line__ ";axis-info[0 losamp at 1234]: ~A ~A?" (car (axis-info obind 0)) (left-sample obind 0)))
		  (set! axinfo (axis-info obind 0))
		  (set! x0 (list-ref axinfo 2))
		  (set! x1 (list-ref axinfo 4))
		  (if (> (abs (apply - (our-x->position obind x0))) 1) 
		      (snd-display #__line__ ";x0a->position: ~A?" (our-x->position obind x0)))
		  (if (> (abs (apply - (our-x->position obind x1))) 1) 
		      (snd-display #__line__ ";x1a->position: ~A?" (our-x->position obind x1)))
		  (if (> (abs (apply - (our-x->position obind (* 0.5 (+ x0 x1))))) 1)
		      (snd-display #__line__ ";xmida->position: ~A?" (our-x->position obind (* 0.5 (+ x0 x1)))))
		  (set! (y-bounds obind 0) (list -2.0 3.0))
		  (if (fneq (list-ref (axis-info obind 0) 7) -2.0)
		      (snd-display #__line__ ";axis-info[7 ymin -2.0]: ~A?" (list-ref (axis-info obind 0) 7)))
		  (if (fneq (list-ref (axis-info obind 0) 9) 3.0)
		      (snd-display #__line__ ";axis-info[9 ymax 3.0]: ~A?" (list-ref (axis-info obind 0) 9)))
		  
		  ))
	    (close-sound obind)))
	
	(let ((ind1 (open-sound "oboe.snd")))
	  (test-orig (lambda (snd) (src-sound 2.0 1.0 ind1)) (lambda (snd) (src-sound 0.5 1.0 ind1)) 'src-sound ind1)
	  (test-orig (lambda (snd) (src-channel 2.0)) (lambda (snd) (src-channel 0.5)) 'src-channel ind1)
	  (test-orig (lambda (snd) (scale-by 2.0 ind1)) (lambda (snd) (scale-by 0.5 ind1)) 'scale-by ind1)
	  (test-orig (lambda (snd) (scale-sound-by 2.0)) (lambda (snd) (scale-sound-by 0.5)) 'scale-sound-by ind1)
	  (test-orig (lambda (snd) (scale-channel 2.0)) (lambda (snd) (scale-channel 0.5)) 'scale-channel ind1)
	  (test-orig (lambda (snd) (reverse-sound ind1)) (lambda (snd) (reverse-sound ind1)) 'reverse-sound ind1)
	  (test-orig (lambda (snd) (reverse-channel)) (lambda (snd) (reverse-channel)) 'reverse-channel ind1)
	  (test-orig (lambda (snd) (env-sound '(0 1.0 1 2.0))) (lambda (snd) (env-sound '(0 1.0 1 0.5))) 'env-sound ind1)
	  (test-orig (lambda (snd) (env-sound '(0 1.0 1 2.0 2 1.0))) (lambda (snd) (env-sound '(0 1.0 1 0.5 2 1.0))) 'env-sound ind1)
	  (test-orig (lambda (snd) (env-channel (make-env :envelope '(0 1.0 1 2.0) :length (frames))))
		     (lambda (snd) (env-channel (make-env :envelope '((0 1.0) (1 0.5)) :length (frames)))) 'env-channel ind1)
	  (test-orig (lambda (snd) (env-channel '(0 1.0 1 2.0)))
		     (lambda (snd) (env-channel '(0 1.0 1 0.5))) 'env-channel ind1)
	  (test-orig (lambda (snd) (env-channel (make-env :envelope '(0 2 1 2 2 0.5 3 0.5) :base 0 :length (frames))))
		     (lambda (snd) (env-channel (make-env :envelope '(0 0.5 1 0.5 2 2 3 2) :base 0 :length (frames)))) 'env-channel ind1)
	  (test-orig (lambda (snd) (map-channel (lambda (n) (* n 2)))) (lambda (snd) (map-channel (lambda (n) (* n 0.5)))) 'map-channel ind1)
	  (test-orig (lambda (snd) (map-channel (lambda (n) (* n 2)) 1234)) (lambda (snd) (map-channel (lambda (n) (* n 0.5)) 1234)) 'map-channel ind1)
	  (test-orig (lambda (snd) (map-channel (lambda (n) (* n 2)) 12005 10)) (lambda (snd) (map-channel (lambda (n) (* n 0.5)) 12005 10)) 'map-channel ind1)
	  (test-orig (lambda (snd) (map-channel (let ((vect (make-vct 1 0.0))) (lambda (y) (vct-set! vect 0 (* y 2)) vect))))
		     (lambda (snd) (old-map-channel (lambda (y) (list (* y 0.5))))) 'old-map-channel ind1)
	  (test-orig (lambda (snd) (map-channel 
				    (let ((vect (make-vct 2 0.0))) 
				      (lambda (y) 
					(vct-set! vect 0 (* y 2))
					(vct-set! vect 1 (* y 2))
					vect))))
		     (lambda (snd) (map-channel
				    (let ((outp #f))
				      (lambda (y) 
					(if outp
					    (set! outp #f)
					    (set! outp (* y 0.5)))
					outp))))
		     'map-channel ind1)
	  (test-orig (lambda (snd) (map-chan (lambda (n) (* n 2)))) (lambda (snd) (map-chan (lambda (n) (* n 0.5)))) 'map-chan ind1)
	  (test-orig (lambda (snd) (pad-channel 1000 2000 ind1)) (lambda (snd) (delete-samples 1000 2000 ind1)) 'pad-channel ind1)
	  (test-orig (lambda (snd) (clm-channel (make-one-zero :a0 2.0 :a1 0.0)))
		     (lambda (snd) (clm-channel (make-one-zero :a0 0.5 :a1 0.0))) 'clm-channel ind1)
	  (test-orig (lambda (snd) (clm-channel (make-one-pole :a0 2.0 :b1 0.0)))
		     (lambda (snd) (clm-channel (make-one-pole :a0 0.5 :b1 0.0))) 'clm-channel ind1)
	  (test-orig (lambda (snd) (filter-sound (make-one-zero :a0 2.0 :a1 0.0) 2 ind1 0)) 
		     (lambda (snd) (filter-sound (make-one-zero :a0 0.5 :a1 0.0)) 2 ind1 0) 'filter-sound ind1)
	  
	  (let ((var (catch #t (lambda () (src-sound '(0 0 1 1))) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";src-sound env at 0: ~A" var)))
	  (let ((var (catch #t (lambda () (src-sound '(0 1 1 -1))) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";src-sound env through 0: ~A" var)))
	  
	  (scale-to 1.0 ind1)
	  (let ((v0 (make-vct 10))
		(v1 (samples->vct 12000 10 ind1 0)))
	    (vct-set! v0 0 1.0)
	    (array->file "fmv3.snd" v0 10 22050 1)
	    (copy-file "oboe.snd" "fmv4.snd")
	    (convolve-with "fmv3.snd" 1.0 ind1)
	    (convolve-files "fmv4.snd" "fmv3.snd" 1.0 "fmv5.snd")
	    (let ((v2 (samples->vct 12000 10 ind1 0)))
	      (if (not (vfequal v1 v2))
		  (snd-display #__line__ ";~A (orig: 0) ~A ~A" 'convolve-with v1 v2))
	      (file->array "fmv5.snd" 0 12000 10 v2)
	      (if (not (vfequal v1 v2))
		  (snd-display #__line__ ";convolve-files: (orig: 0) ~A ~A" v1 v2)))
	    (delete-file "fmv3.snd")
	    (delete-file "fmv5.snd"))
	  (convolve-files "2.snd" "oboe.snd" 0.5 "fmv5.snd")
	  (if (or (fneq (cadr (mus-sound-maxamp "fmv5.snd")) 0.25)
		  (fneq (cadddr (mus-sound-maxamp "fmv5.snd")) 0.5))
	      (snd-display #__line__ ";convolve-files stereo: ~A" (mus-sound-maxamp "fmv5.snd")))
	  (delete-file "fmv5.snd")
	  (scale-to .25 ind1)
	  (set! (y-bounds ind1) '())
	  (if (not (equal? (y-bounds ind1) (list -.25 .25)))
	      (snd-display #__line__ ";y-bounds '(): ~A?" (y-bounds ind1)))
	  (revert-sound ind1)
	  
	  (scale-to 1.0 ind1)
	  (let ((v0 (make-vct 10))
		(v1 (samples->vct 12000 10 ind1 0)))
	    (vct-set! v0 5 1.0)
	    (array->file "fmv3.snd" v0 10 22050 1)
	    (convolve-with "fmv3.snd" 1.0 ind1)
	    (convolve-files "fmv4.snd" "fmv3.snd" 1.0 "fmv5.snd")
	    (let ((v2 (samples->vct 12005 10 ind1 0)))
	      (if (not (vfequal v1 v2))
		  (snd-display #__line__ ";~A (orig: 2) ~A ~A" 'convolve-with v1 v2))
	      (file->array "fmv5.snd" 0 12005 10 v2)
	      (if (not (vfequal v1 v2))
		  (snd-display #__line__ ";convolve-files: (orig: 2) ~A ~A" v1 v2)))
	    (delete-file "fmv3.snd")
	    (delete-file "fmv4.snd")
	    (delete-file "fmv5.snd"))
	  
	  (revert-sound ind1)
	  (let ((old-val (selection-creates-region))
		(old-regions (regions)))
	    (set! (selection-creates-region) #f)
	    (select-all ind1)
	    (set! (selection-creates-region) old-val)
	    (if (not (equal? old-regions (regions)))
		(snd-display #__line__ ";selection-create-region: ~A -> ~A?" old-regions (regions))))
	  (convolve-selection-with "pistol.snd" (maxamp))
	  (let ((data (samples->vct 12000 10 ind1 0)))
	    (convolve-with "pistol.snd" (maxamp ind1 0 0) ind1 0 0)
	    (let ((new-data (samples->vct 12000 10 ind1 0)))
	      (if (not (vfequal data new-data))
		  (snd-display #__line__ ";convolve-selection-with: ~A ~A?" data new-data))))
	  (revert-sound ind1)
	  (make-selection 1000 2000 ind1)
	  (let ((ma (maxamp ind1)))
	    (convolve-selection-with "pistol.snd" ma)
	    (if (fneq (maxamp ind1) ma) (snd-display #__line__ ";convolve-selection-with 1000: ~A ~A?" ma (maxamp ind1))))
	  (make-selection 1000 2000 ind1)
	  (let ((id (make-region)))
	    (if (not (region? id))
		(snd-display #__line__ ";make-region argless: ~A" id))
	    (if (not (= (region-frames id 0) (selection-frames)))
		(snd-display #__line__ ";region/selection-frames: ~A ~A (~A)?" (region-frames id 0) (selection-frames) (region-frames id)))
	    (if (fneq (region-sample id 0) (sample 1000 ind1))
		(snd-display #__line__ ";region-sample from make-region: ~A ~A?" (region-sample id 0) (sample 1000 ind1))))
	  (close-sound ind1))
	(let* ((ind (open-sound "2.snd"))
	       (reg (make-region 0 100 ind #t)))
	  (if (not (equal? (region-home reg) (list "2.snd" 0 100))) 
	      (snd-display #__line__ ";make + region-home: ~A" (region-home reg)))
	  (if (not (= (region-chans reg) 2))
	      (snd-display #__line__ ";make-region chan #t: ~A" (region-chans reg)))
	  (close-sound ind))
	
	(let ((ind1 (open-sound "2.snd")))
	  (let ((v0 (samples->vct 12000 10 ind1 0))
		(v1 (samples->vct 12000 10 ind1 1)))
	    (swap-channels ind1)
	    (let ((v2 (samples->vct 12000 10 ind1 0))
		  (v3 (samples->vct 12000 10 ind1 1)))
	      (if (or (vequal v0 v2)
		      (vequal v1 v3))
		  (snd-display #__line__ ";swap-channels 0: no change! ~A ~A ~A ~A" v0 v2 v1 v3)))
	    (swap-channels ind1)
	    (let ((v2 (samples->vct 12000 10 ind1 0))
		  (v3 (samples->vct 12000 10 ind1 1)))
	      (if (or (not (vequal v0 v2))
		      (not (vequal v1 v3)))
		  (snd-display #__line__ ";swap-channels 1: ~A ~A ~A ~A" v0 v2 v1 v3)))
	    ;; as long as we're here...
	    (set! (cursor ind1 0) 100)
	    (set! (cursor ind1 1) 200)
	    (if (or (not (= (cursor ind1 0) 100)) 
		    (not (= (cursor ind1 1) 200)))
		(snd-display #__line__ ";cursor: ~A ~A?" (cursor ind1 0) (cursor ind1 1)))
	    (set! (sync ind1) 1)
	    (scale-by (list .5 .25) ind1)
	    (scale-by (vct 2.0 4.0) ind1)
	    (revert-sound ind1)
	    (let ((amps (maxamp ind1 #t)))
	      (swap-channels ind1 0 ind1)
	      (let ((newamps (maxamp ind1 #t)))
		(if (or (fneq (car amps) (cadr newamps))
			(fneq (cadr amps) (car newamps)))
		    (snd-display #__line__ ";swap-channels with cp def: ~A ~A" amps newamps)))
	      (swap-channels ind1 1)
	      (let ((newamps (maxamp ind1 #t)))
		(if (or (fneq (car amps) (car newamps))
			(fneq (cadr amps) (cadr newamps)))
		    (snd-display #__line__ ";swap-channels with cp def 0: ~A ~A" amps newamps))))
	    (close-sound ind1)))
	
	(let ((ind1 (open-sound "oboe.snd"))
	      (ind2 (open-sound "2.snd")))
	  (let ((ups1 (count-matches (lambda (n) (> n .1)) 0 ind1 0))
		(ups2 (let ((count 0))
			(scan-chan (lambda (n)
				     (if (> n .1)
					 (set! count (+ count 1)))
				     #f)
				   0 (frames ind1) ind1 0)
			count)))
	    (if (not (= ups1 ups2))
		(snd-display #__line__ ";scan-chan: ~A ~A?" ups1 ups2))
	    (set! ups1 (count-matches (lambda (n) (> n .03)) 0 ind2 0))
	    (set! ups2 (count-matches (lambda (n) (> n .03)) 0 ind2 1))
	    (let ((ups3 (let ((count 0))
			  (scan-chan (lambda (n)
				       (if (> n .03)
					   (set! count (+ count 1)))
				       #f)
				     0 (frames ind2) ind2 0)
			  count))
		  (ups4 (let ((count 0))
			  (scan-chan (lambda (n)
				       (if (> n .03)
					   (set! count (+ count 1)))
				       #f)
				     0 (frames ind2) ind2 1)
			  count)))
	      (if (not (= ups1 ups3))
		  (snd-display #__line__ ";2[0] scan-chan: ~A ~A?" ups1 ups3))
	      (if (not (= ups2 ups4))
		  (snd-display #__line__ ";2[1] scan-chan: ~A ~A?" ups2 ups4))))
	  (select-sound ind1)
	  (forward-graph)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 0)))
	      (snd-display #__line__ ";forward from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (forward-graph)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display #__line__ ";forward from ~A 0 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (forward-graph 1)
	  (if (or (not (equal? (selected-sound) ind1))
		  (not (= (selected-channel) 0)))
	      (snd-display #__line__ ";forward from ~A 1 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (forward-graph 2)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display #__line__ ";forward from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (forward-graph 0)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display #__line__ ";forward 0 from ~A 1 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (backward-graph 2)
	  (if (or (not (equal? (selected-sound) ind1))
		  (not (= (selected-channel) 0)))
	      (snd-display #__line__ ";backward 2 from ~A 1 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (backward-graph)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display #__line__ ";backward 2 from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (forward-graph -1)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 0)))
	      (snd-display #__line__ ";forward -1 from ~A 1 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (backward-graph -1)
	  (if (or (not (equal? (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display #__line__ ";backward -1 from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  
	  (close-sound ind1)
	  (close-sound ind2))
	
	(let* ((ind1 (open-sound "oboe.snd"))
	       (len (frames ind1))
	       (ctr 0))
	  (map-chan (lambda (n)
		      (if (= ctr 1) (set! ctr 0) (set! ctr 1))
		      (if (= ctr 0)
			  (* n 2.0)
			  #f))
		    0 (frames ind1) "ignore: cut 2" ind1 0)
	  (if (> (frames ind1) (+ (* len 2) 1))
	      (snd-display #__line__ ";map-chan cut: ~A ~A?" len (frames ind1)))
	  (revert-sound ind1)
	  (set! ctr 0)
	  (map-chan (lambda (n)
		      (set! ctr (+ 1 ctr))
		      (if (> ctr 3)
			  #t
			  n))
		    0 (frames ind1) "ignore: cut none" ind1 0)
	  (if (> ctr 4)
	      (snd-display #__line__ ";map-chan no-edit count: ~A?" ctr))
	  (revert-sound ind1)
	  (let ((v1 (make-vct 2)))
	    (map-chan (lambda (n)
			(vct-set! v1 0 n)
			(vct-set! v1 1 (* n 3))
			v1)
		      0 (frames ind1) "ignore: cut 2" ind1 0))
	  (if (> (abs (- (frames ind1) (* len 2))) 3)
	      (snd-display #__line__ ";map-chan double: ~A ~A?" len (frames ind1)))
	  (revert-sound ind1)
	  (let ((otime (maxamp-position ind1)))
	    (set! (sample 1234) .9)
	    (let* ((ntime (maxamp-position ind1))
		   (nval (maxamp ind1))
		   (npos (edit-position ind1 0)))
	      (if (not (= ntime 1234)) (snd-display #__line__ ";maxamp-position 1234: ~A" ntime))
	      (let ((ootime (maxamp-position ind1 0 0)))
		(if (not (= ootime otime)) (snd-display #__line__ ";maxamp-position edpos 0: ~A ~A" otime ootime)))
	      (let ((nntime (maxamp-position ind1 0 npos)))
		(if (not (= nntime ntime)) (snd-display #__line__ ";maxamp-position edpos ~D: ~A ~A" npos ntime nntime)))
	      (if (fneq nval .9) (snd-display #__line__ ";maxamp .9: ~A" nval)))
	    (set! (sample 1234) 0.0)
	    (env-channel '(0 0 1 1))
	    (if (not (= (maxamp-position) 35062)) (snd-display #__line__ ";env-channel maxamp-position: ~A" (maxamp-position)))
	    (let ((ootime (maxamp-position ind1 0 0)))
	      (if (not (= ootime otime)) (snd-display #__line__ ";maxamp-position edpos 0(1): ~A ~A" otime ootime)))
	    (let ((nntime (maxamp-position ind1 0 1)))
	      (if (not (= nntime 1234)) (snd-display #__line__ ";maxamp-position edpos 1(1): ~A ~A" 1234 nntime)))
	    (let ((nntime (maxamp-position ind1 0 current-edit-position)))
	      (if (not (= nntime 35062)) (snd-display #__line__ ";maxamp-position edpos current: ~A ~A" 35062 nntime))))
	  (revert-sound ind1)
	  (make-selection 24000 25000)
	  (if (not (= (selection-maxamp-position) 971))
	      (snd-display #__line__ ";selection maxamp position: ~A" (selection-maxamp-position)))
	  (let ((reg (make-region 24000 25000)))
	    (if (not (= (region-maxamp-position reg) 971))
		(snd-display #__line__ ";region maxamp position: ~A" (region-maxamp-position))))
	  (close-sound ind1))
	(let* ((ind1 (open-sound "oboe.snd")))
	  (test-edpos maxamp 'maxamp (lambda () (scale-by 2.0 ind1 0)) ind1)
	  (test-edpos frames 'frames (lambda () (src-sound 2.0 1.0 ind1 0)) ind1)
	  (test-edpos 
	   (lambda* ((snd 0) (chn 0) (edpos current-edit-position)) (count-matches (lambda (n1) (> n1 .1)) 0 snd chn edpos)) 
	   'count-matches
	   (lambda () (scale-by 2.0 ind1 0)) 
	   ind1)
	  (test-edpos 
	   (lambda* ((snd 0) (chn 0) (edpos current-edit-position)) (cadr (find-channel (lambda (n2) (> n2 .1)) 0 snd chn edpos)))
	   'find
	   (lambda () (delete-samples 0 100 ind1 0))
	   ind1)
	  (test-edpos 
	   (lambda* ((snd 0) (chn 0) (edpos current-edit-position)) 
		    (let ((samp 0)) 
		      (scan-chan (lambda (n3) 
				   (or (> n3 .1) 
				       (begin 
					 (set! samp (+ 1 samp)) 
					 #f)))
				 0 (frames snd chn) snd chn edpos)
		      samp))
	   'scan-chan
	   (lambda () (delete-samples 0 100 ind1 0))
	   ind1)
	  
	  (src-sound 2.0 1.0 ind1 0)
	  (undo 1 ind1 0)
	  
	  (delete-samples 0 10000 ind1 0)
	  (save-sound-as "fmv.snd" ind1 :edit-position 0)
	  (save-sound-as "fmv1.snd" ind1 :edit-position (lambda (snd chn) 1))
	  (let ((var (catch #t (lambda () (save-sound-as "fmv2.snd" ind1 :channel 1234)) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-channel))
		(snd-display #__line__ ";save-sound-as bad chan: ~A" var)))
	  (if (not (= (mus-sound-frames "fmv.snd") (frames ind1 0 0)))
	      (snd-display #__line__ ";save-sound-as (edpos): ~A ~A?" (mus-sound-frames "fmv.snd") (frames ind1 0 0)))
	  (if (not (= (mus-sound-frames "fmv1.snd") (frames ind1 0 1)))
	      (snd-display #__line__ ";save-sound-as (edpos 1): ~A ~A?" (mus-sound-frames "fmv.snd") (frames ind1 0 1)))
	  (if (= (mus-sound-frames "fmv.snd") (frames ind1 0 1))
	      (snd-display #__line__ ";save-sound-as (edpos 1)(2): ~A ~A?" (mus-sound-frames "fmv.snd") (frames ind1 0 1)))
	  (let ((ind2 (open-sound "fmv.snd"))
		(ind3 (open-sound "fmv1.snd")))
	    (if (not (vequal (samples->vct 12000 10 ind1 0 #f 0) (samples->vct 12000 10 ind2 0)))
		(snd-display #__line__ ";save-sound-as (edpos 3): ~A ~A?" (samples->vct 12000 10 ind1 0 #f 0) (samples->vct 12000 10 ind2 0)))
	    (if (not (vequal (samples->vct 12000 10 ind1 0 #f 1) (samples->vct 12000 10 ind3 0)))
		(snd-display #__line__ ";save-sound-as (edpos 4): ~A ~A?" (samples->vct 12000 10 ind1 0 #f 1) (samples->vct 12000 10 ind3 0)))
	    (if (vequal (samples->vct 12000 10 ind2 0) (samples->vct 12000 10 ind3 0))
		(snd-display #__line__ ";save-sound-as (edpos 5): ~A ~A?" (samples->vct 12000 10 ind2 0) (samples->vct 12000 10 ind3 0)))
	    (select-sound ind3)
	    (set! (comment) "hiho")
	    (if (not (string=? (comment) "hiho")) (snd-display #__line__ ";set! comment no index: ~A" (comment)))
	    (close-sound ind2)
	    (close-sound ind3))
	  (delete-file "fmv.snd")
	  (delete-file "fmv1.snd")
	  
	  (test-edpos-1 (lambda (snd pos) (reverse-sound snd 0 pos)) 'reverse-sound ind1)
	  (test-edpos-1 (lambda (snd pos) (env-sound '(0 0 1 1 2 0) 0 20000 1.0 snd 0 pos)) 'env-sound ind1)
	  (test-edpos-1 (lambda (snd pos) (src-sound 0.5 1.0 snd 0 pos)) 'src-sound ind1)
	  (test-edpos-1 (lambda (snd pos) (filter-sound (make-fir-filter 6 (list->vct '(.1 .2 .3 .3 .2 .1))) 6 snd 0 pos)) 'filter-sound ind1)
	  (test-edpos-1 (lambda (snd pos) (convolve-with "pistol.snd" .5 snd 0 pos)) 'convolve-with ind1)
	  
	  (let ((ind (new-sound "fmv.snd"))
		(v (make-vct 2000))
		(ctr 0))
	    (vct-map! v (lambda ()
			  (let ((val (sin (* ctr 2.0 (/ pi 10.0)))))
			    (set! ctr (+ 1 ctr))
			    val)))
	    (vct->channel v 0 2000 ind 0)
	    (filter-sound '(0 0 .09 0 .1 1 .11 0 1 0) 1024)
	    (if (> (maxamp) .025) (snd-display #__line__ ";filter-sound maxamp 1: ~A" (maxamp)))
	    (undo)
	    (filter-sound '(0 0 .19 0 .2 1 .21 0 1 0) 1024)  
	    (if (< (maxamp) .9) (snd-display #__line__ ";filter-sound maxamp 2: ~A" (maxamp)))
	    (undo)
	    (filter-sound '(0 0 .29 0 .3 1 .31 0 1 0) 1024)  
	    (if (> (maxamp) .02) (snd-display #__line__ ";filter-sound maxamp 3: ~A" (maxamp)))
	    
	    (set! (show-sonogram-cursor) #t) 
	    (set! (cursor-follows-play) #t) 
	    (if (not (cursor-follows-play)) (snd-display #__line__ ";cursor-follows-play set to #t: ~A" (cursor-follows-play)))
	    
	    (set! (transform-graph-type) graph-as-sonogram) 
	    (play :wait #t)
	    (set! (transform-graph?) #t) 
	    
	    (close-sound ind))
	  (close-sound ind1))
	
	(let* ((ind (open-sound "oboe.snd"))
	       (mx (maxamp ind 0))
	       (e0 (channel-amp-envs ind 0)))
	  
	  (define (peak-env-equal? name index e diff)
	    (let* ((reader (make-sampler 0 index 0))
		   (e-size (vct-length (car e)))
		   (samps-per-bin (ceiling (/ (frames index) e-size)))
		   (mins (car e))
		   (maxs (cadr e))
		   (max-diff 0.0)
		   (happy #t))
	      (do ((e-bin 0)
		   (samp 0 (+ 1 samp))
		   (mx -10.0)
		   (mn 10.0))
		  ((or (not happy) (= e-bin e-size))
		   happy)
		(if (>= samp (floor samps-per-bin))
		    (let ((mxdiff (abs (- mx (vct-ref maxs e-bin))))
			  (mndiff (abs (- mn (vct-ref mins e-bin)))))
		      (if (> mxdiff max-diff)
			  (set! max-diff mxdiff))
		      (if (> mndiff max-diff)
			  (set! max-diff mndiff))
		      (if (or (> mxdiff diff)
			      (> mndiff diff))
			  (begin
			    (snd-display #__line__ ";~A: peak-env-equal? [bin ~D of ~D]: (~,4F to ~,4F), diff: ~,5F" 
					 name
					 e-bin e-size
					 mn mx
					 (max mxdiff mndiff))
			    (set! happy #f)))
		      (set! samp 0)
		      (set! mx -10.0)
		      (set! mn 10.0)
		      (set! e-bin (+ e-bin 1))))
		(let ((val (next-sample reader)))
		  (if (< val mn)
		      (set! mn val))
		  (if (> val mx)
		      (set! mx val))))))
	  
	  (if (null? e0)
	      (snd-display #__line__ ";no amp env data")
	      (let ((mx1 (vct-peak (car e0)))
		    (mx2 (vct-peak (cadr e0))))
		(if (fneq mx (max mx1 mx2))
		    (snd-display #__line__ ";amp env max: ~A ~A ~A" mx mx1 mx2))
		(peak-env-equal? "straight peak" ind e0 .0001)
		(scale-by 3.0)
		(let* ((e1 (channel-amp-envs ind 0 1))
		       (mx3 (vct-peak (car e1)))
		       (mx4 (vct-peak (cadr e1))))
		  (if (or (fneq (* 3.0 mx1) mx3)
			  (fneq (* 3.0 mx2) mx4))
		      (snd-display #__line__ ";3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (peak-env-equal? "scaled peak" ind e1 .0001))
		(if (fneq (maxamp ind 0) (* 3 mx)) 
		    (snd-display #__line__ ";maxamp after scale: ~A ~A" mx (maxamp ind 0)))
		(undo)
		(set! (selection-member? #t) #f)
		(set! (selection-member? ind 0) #t)
		(set! (selection-position ind 0) 20000)
		(set! (selection-frames ind 0) 12000)
		(scale-selection-by 3.0)
		(let* ((e1 (channel-amp-envs ind 0 1))
		       (mx3 (vct-peak (car e1)))
		       (mx4 (vct-peak (cadr e1))))
		  (if (or (fneq (* 3.0 mx1) mx3)
			  (fneq (* 3.0 mx2) mx4))
		      (snd-display #__line__ ";selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (if (fneq (maxamp ind 0) (* 3 mx)) 
		      (snd-display #__line__ ";maxamp after selection scale: ~A ~A" mx (maxamp ind 0)))
		  (peak-env-equal? "selection peak" ind e1 .0001))
		(map-chan abs 0 #f "test" ind 0)
		(let* ((e1 (channel-amp-envs ind 0 2))
		       (mx3 (vct-peak (car e1)))
		       (mx4 (vct-peak (cadr e1))))
		  (if (fneq (* 3.0 mx2) mx4)
		      (snd-display #__line__ ";abs selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (if (fneq (maxamp ind 0) (* 3 mx)) 
		      (snd-display #__line__ ";maxamp after abs selection scale: ~A ~A" mx (maxamp ind 0)))
		  (if (ffneq mx3 0.03)
		      (snd-display #__line__ ";abs max: ~A ~A" mx3 mx4))
		  (peak-env-equal? "map-chan peak" ind e1 .0001))
		(delete-samples 10000 5000)
		(let* ((e1 (channel-amp-envs ind 0))
		       (mx3 (vct-peak (car e1)))
		       (mx4 (vct-peak (cadr e1))))
		  (if (fneq (* 3.0 mx2) mx4)
		      (snd-display #__line__ ";abs selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (if (fneq (maxamp ind 0) (* 3 mx)) 
		      (snd-display #__line__ ";maxamp after abs selection scale: ~A ~A" mx (maxamp ind 0)))
		  (if (ffneq mx3 0.03)
		      (snd-display #__line__ ";abs max: ~A ~A" mx3 mx4))
		  (peak-env-equal? "delete peak" ind e1 .0001))
		(scale-selection-by -.333)
		(let* ((e1 (channel-amp-envs ind 0 4))
		       (mx3 (vct-peak (car e1))))
		  (if (fneq (maxamp ind 0) mx)
		      (snd-display #__line__ ";maxamp after minus abs selection scale: ~A ~A" mx (maxamp ind 0)))
		  (if (fneq (maxamp ind 0) mx3)
		      (snd-display #__line__ ";mx3 maxamp after minus abs selection scale: ~A ~A" mx mx3))
		  (peak-env-equal? "scale-selection peak" ind e1 .0001))
		
		(revert-sound ind)
		(ramp-channel 0.0 1.0)
		(peak-env-equal? "ramp-channel peak" ind (channel-amp-envs ind 0 1) .001)
		(undo)
		(env-channel '(0 0 1 1 2 0))
		(peak-env-equal? "env-channel peak" ind (channel-amp-envs ind 0 1) .002)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :length (frames)))
		(peak-env-equal? "scaled env-channel peak" ind (channel-amp-envs ind 0 1) .002)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) 0.5 :length (frames)))
		(peak-env-equal? "scaled nokey env-channel peak" ind (channel-amp-envs ind 0 1) .001)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :offset 0.5 :length (frames)))
		(peak-env-equal? "scaled and offset env-channel peak" ind (channel-amp-envs ind 0 1) .001)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 .5 3 0) :base 0.0 :length (frames)))
		(peak-env-equal? "env-channel base 0.0 peak" ind (channel-amp-envs ind 0 1) .001)
		(undo)
		(xramp-channel 0.0 1.0 32.0)
		(peak-env-equal? "xramp 32.0 peak" ind (channel-amp-envs ind 0 1) .008)
		(undo)
		(xramp-channel 0.0 1.0 .032)
		(peak-env-equal? "xramp .032 peak" ind (channel-amp-envs ind 0 1) .004)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 .5 3 0) :base 10.0 :length (frames)))
		(peak-env-equal? "env-channel base 10.0 peak" ind (channel-amp-envs ind 0 1) .003)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) :base .10 :length (frames)))
		(peak-env-equal? "env-channel base .1 peak" ind (channel-amp-envs ind 0 1) .003)
		(undo)
		(ptree-channel (lambda (y) (* y 2)) 0 (frames) ind 0 #f #t)
		(peak-env-equal? "ptree-channel peak" ind (channel-amp-envs ind 0 1) .0001)
		(undo)
		(ramp-channel 0.0 1.0)
		(ptree-channel (lambda (y) (* y 2)) 0 (frames) ind 0 #f #t)
		(peak-env-equal? "ptree+ramp peak" ind (channel-amp-envs ind 0 2) .01)
		(undo 2)
		(xramp-channel 0.0 1.0 3.0)
		(ptree-channel (lambda (y) (* y 2)) 0 (frames) ind 0 #f #t)
		(peak-env-equal? "ptree+xramp peak" ind (channel-amp-envs ind 0 2) .004)
		(undo 2)
		(ptree-channel (lambda (y data forward)
				 (* y (vct-ref data 0)))
			       0 (frames) ind 0 #f #t
			       (lambda (pos dur)
				 (vct 0.5)))
		(peak-env-equal? "ptree+closure peak" ind (channel-amp-envs ind 0 1) .009)
		(undo)
		(ramp-channel 0.0 1.0)
		(ptree-channel (lambda (y data forward)
				 (* y (vct-ref data 0)))
			       0 (frames) ind 0 #f #t
			       (lambda (pos dur)
				 (vct 0.5)))
		(peak-env-equal? "ptree+ramp+closure peak" ind (channel-amp-envs ind 0 2) .01)
		(undo 2)
		(xramp-channel 0.0 1.0 3.0)
		(ptree-channel (lambda (y data forward)
				 (* y (vct-ref data 0)))
			       0 (frames) ind 0 #f #t
			       (lambda (pos dur)
				 (vct 0.5)))
		(peak-env-equal? "ptree+xramp+closure peak" ind (channel-amp-envs ind 0 2) .001)
		(undo 2)
		(insert-samples 1000 5000 (make-vct 5000 .5))
		(peak-env-equal? "insert-samples peak" ind (channel-amp-envs ind 0 1) .0001)
		(undo)
		(set! (samples 500 100) (make-vct 100 .1))
		(peak-env-equal? "set-samples peak" ind (channel-amp-envs ind 0) .0001)
		(undo)
		
		(revert-sound ind)
		(ramp-channel 0.0 1.0)
		(ramp-channel 1.0 0.0)
		(peak-env-equal? "ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
		
		(revert-sound ind)
		(env-channel '(0 0 1 1))
		(env-channel '(0 0 1 1 2 0))
		(peak-env-equal? "env ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
		
		(revert-sound ind)
		(env-channel '(0 0 1 1))
		(env-channel '(0 0 1 1 2 0))
		(ptree-channel (lambda (y) (* y 2.0)))
		(peak-env-equal? "ptree-ramp20 peak" ind (channel-amp-envs ind 0 3) .0001)
		
		(revert-sound ind)
		(ramp-channel 0.0 1.0 12000 5000)
		(peak-env-equal? "ramp-channel peak" ind (channel-amp-envs ind 0 1) .002)
		(undo)
		(env-channel '(0 0 1 1 2 0) 12000 5000)
		(peak-env-equal? "env-channel peak" ind (channel-amp-envs ind 0 1) .003)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 5000) 12000 5000)
		(peak-env-equal? "scaled env-channel peak" ind (channel-amp-envs ind 0 1) .004)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) 0.5 :length 5000) 12000 5000)
		(peak-env-equal? "scaled nokey env-channel peak" ind (channel-amp-envs ind 0 1) .004)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 0) :scaler 0.5 :offset 0.5 :length 5000) 12000 5000)
		(peak-env-equal? "scaled and offset env-channel peak" ind (channel-amp-envs ind 0 1) .002)
		(undo)
		(xramp-channel 0.0 1.0 32.0 2000 1000)
		(peak-env-equal? "xramp 32.0 peak (1)" ind (channel-amp-envs ind 0 1) .009)
		(undo)
		(xramp-channel 0.0 1.0 .032 2000 1000)
		(peak-env-equal? "xramp .032 peak (1)" ind (channel-amp-envs ind 0 1) .009)
		(undo)
		(env-channel (make-env '(0 0 1 1 2 .5 3 0) :base 10.0 :length 5000) 12000 5000)
		(peak-env-equal? "env-channel base 10.0 peak" ind (channel-amp-envs ind 0 1) .1)
		;; this can be way off because the envelope is not very closely sampled in this case
		(undo)
		(ptree-channel (lambda (y) (* y 2)) 2000 1000 ind 0 #f #t)
		(peak-env-equal? "ptree-channel peak" ind (channel-amp-envs ind 0 1) .0001)
		(undo)
		(ramp-channel 0.0 1.0)
		(ptree-channel (lambda (y) (* y 2)) 2000 1000 ind 0 #f #t)
		(peak-env-equal? "ptree+ramp peak" ind (channel-amp-envs ind 0 2) .001)
		(undo 2)
		(xramp-channel 0.0 1.0 3.0)
		(ptree-channel (lambda (y) (* y 2)) 2000 1000 ind 0 #f #t)
		(peak-env-equal? "ptree+xramp peak" ind (channel-amp-envs ind 0 2) .001)
		(undo 2)
		(ptree-channel (lambda (y data forward)
				 (* y (vct-ref data 0)))
			       2000 1000 ind 0 #f #t
			       (lambda (pos dur)
				 (vct 0.5)))
		(peak-env-equal? "ptree+closure peak" ind (channel-amp-envs ind 0 1) .0001)
		(undo)
		(ramp-channel 0.0 1.0)
		(ptree-channel (lambda (y data forward)
				 (* y (vct-ref data 0)))
			       2000 1000 ind 0 #f #t
			       (lambda (pos dur)
				 (vct 0.5)))
		(peak-env-equal? "ptree+ramp+closure peak" ind (channel-amp-envs ind 0 2) .001)
		
		(revert-sound ind)
		(ramp-channel 0.0 1.0)
		(ramp-channel 1.0 0.0 2000 1000)
		(peak-env-equal? "ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
		
		(revert-sound ind)
		(env-channel '(0 0 1 1))
		(env-channel '(0 0 1 1 2 0) 2000 1000)
		(peak-env-equal? "env ramp2 peak" ind (channel-amp-envs ind 0 2) .002)
		
		(revert-sound ind)
		(env-channel '(0 0 1 1))
		(env-channel '(0 0 1 1 2 0))
		(ptree-channel (lambda (y) (* y 2.0)) 2000 1000)
		(peak-env-equal? "ptree-ramp21 peak" ind (channel-amp-envs ind 0 3) .002)
		
		(revert-sound ind)
		(env-channel '(0 0 1 1))
		(env-channel '(0 0 1 1 2 0))
		(env-channel '(0 0 1 1) 12000 5000)
		(peak-env-equal? "ptree-ramp3 peak" ind (channel-amp-envs ind 0 3) .01)
		
		(revert-sound ind)
		
		))
	  (close-sound ind))
	
	;; ptree-channel init-func state cases
	(let ((ind (new-sound "test.snd" :size 10 :comment "ptree-channel state tests")))
	  (set! (sample 5) 1.0)
	  (set! (sample 4) -0.5)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val float) (dir boolean))
			   (* y val))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   0.5)
			 "ptree channel float arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -0.250 0.500 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with float state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val int) (dir boolean))
			   (* y val))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   3)
			 "ptree channel int arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -1.500 3.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with int state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val boolean) (dir boolean))
			   (if val y (* y 100)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   #t)
			 "ptree channel boolean arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -0.500 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with boolean state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val char) (dir boolean))
			   (if (char=? val #\f) y (* 10 y)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   #\f)
			 "ptree channel char arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -.500 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with char state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val string) (dir boolean))
			   (if (string=? val "hiho") y (* 10 y)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   "hiho")
			 "ptree channel string arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -.500 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with string state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val vct) (dir boolean))
			   (* y (vct-ref val 0)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   (make-vct 1 2.0))
			 "ptree channel vct arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -1.000 2.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with vct state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val sound-data) (dir boolean))
			   (* y (sound-data-ref val 0 0)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   (let ((sd (make-sound-data 1 2)))
			     (sound-data-set! sd 0 0 4.0)
			     sd))
			 "ptree channel sound-data arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -2.000 4.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with sound-data state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val symbol) (dir boolean))
			   (if (eq? val 'hiho) y (* y 100)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   'hiho)
			 "ptree channel symbol arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -0.500 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with symbol state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val keyword) (dir boolean))
			   (if (eq? val :hiho) y (* y 100)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   :hiho)
			 "ptree channel keyword arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -0.500 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with keyword state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  ;; this works, but can't currently be optimized:
	  ;;  (ptree-channel (lambda (y val dir)
	  ;;		       (declare (y real) (val list) (dir boolean))
	  ;;		       (* y (car val)))
	  ;;		     0 10 ind 0 -1 #t
	  ;;		     (lambda (beg dur)
	  ;;		       (list 2.0 100.0)))
	  ;;  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -1.000 2.000 0.000 0.000 0.000 0.000)))
	  ;;      (snd-display #__line__ ";ptree-channel with list state: ~A" (channel->vct 0 10 ind 0)))
	  ;;  (undo)
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val sampler) (dir boolean))
			   (let ((n (read-sample val)))
			     (* y n)))
			 0 10 ind 0 -1 #f
			 (lambda (beg dur)
			   (make-sampler beg ind 0 1 2)) ; beg here is vital! as is "2" for edpos
			 "ptree channel sampler arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 0.250 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with reader state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  
	  ;; this can't work because it needs access to previous samples (the generator has internal state)
					;	  (ptree-channel (lambda (y val dir)
					;			   (declare (y real) (val clm) (dir boolean))
					;			   (one-zero val y))
					;			 0 10 ind 0 -1 #t
					;			 (lambda (beg dur)
					;			   (make-one-zero .5 .5))
					;			 "ptree channel clm arg")
					;	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -0.250 0.250 0.500 0.000 0.000 0.000)))
					;	      (snd-display #__line__ ";ptree-channel with clm state: ~A from ~A"
					;			   (channel->vct 0 10 ind 0) 
					;			   (channel->vct 0 10 ind 0 (- (edit-position ind 0) 1))))
					;	  (undo)
	  (let ((mx (mix-vct (vct .2 .3 .4) 2 ind 0 #t)))
	    (ptree-channel (lambda (y val dir)
			     (declare (y real) (val mix-sampler) (dir boolean))
			     (let ((n (read-mix-sample val)))
			       (+ y n)))
			   0 10 ind 0 -1 #f
			   (lambda (beg dur)
			     (make-mix-sampler mx beg))
			   "ptree channel mix-sampler arg"))
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.200 0.300 0.600 0.300 -0.100 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with mix reader state: ~A" (channel->vct 0 10 ind 0)))
	  (set! (edit-position ind 0) 2)
	  
	  ;; now check error handling...
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val vct) (dir boolean))
			   (* y 2.0))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   (make-vct 1 2.0))
			 "ptree channel vct unrefd arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -1.000 2.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with unrefd vct state: ~A" (channel->vct 0 10 ind 0)))
	  (undo)
	  
	  ;; this does print an error message, but trying to halt execution leads to a segfault
	  ;;	  (let ((tag (catch #t
	  ;;			    (lambda ()
	  ;;			      (ptree-channel (lambda (y val dir)
	  ;;					       (declare (y real) (val float-vector) (dir boolean))
	  ;;					       (* y (vector-ref val 0)))
	  ;;					     0 10 ind 0 -1 #t
	  ;;					     (lambda (beg dur)
	  ;;					       (make-vector 1 2.0))
	  ;;					     "ptree channel vector arg"))
	  ;;			    (lambda args (car args)))))
	  ;;	    (if (not (eq? tag 'snd-error))
	  ;;		(snd-display #__line__ ";ptree-channel vector arg: ~A" tag)))
	  
	  ;; now check 3 ptrees with different types
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val float) (dir boolean))
			   (* y val))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   0.5)
			 "ptree channel float arg")
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val int) (dir boolean))
			   (* y val))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   2)
			 "ptree channel int arg")
	  (ptree-channel (lambda (y val dir)
			   (declare (y real) (val boolean) (dir boolean))
			   (if val y (* y 100)))
			 0 10 ind 0 -1 #t
			 (lambda (beg dur)
			   #t)
			 "ptree channel boolean arg")
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.000 0.000 0.000 0.000 -0.500 1.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";ptree-channel with 3 states: ~A" (channel->vct 0 10 ind 0)))
	  
	  (close-sound ind)
	  (if (file-exists? "test.snd") (delete-file "test.snd")))
	
	(let ((ind (new-sound "test.snd")))
	  (map-chan (lambda (y) 1.0) 0 50000)
	  (ramp-channel 0.5 1.0 1000 4000)
	  (let* ((peaks (channel-amp-envs ind 0))
		 (mx (cadr peaks))
		 (mn (car peaks)))
	    (call-with-current-continuation
	     (lambda (break)
	       (if (not (continuation? break)) (snd-display #__line__ ";not a continuation: ~A" break))
	       (if (continuation? abs) (snd-display #__line__ ";abs is a continuation?"))
	       (if (continuation? open-sound) (snd-display #__line__ ";open-sound is a continuation?"))
	       (if (continuation? 32) (snd-display #__line__ ";32 is a continuation?"))
	       (if (continuation? (let ((hi 1)) (lambda () hi))) (snd-display #__line__ ";closure is a continuation?"))
	       (do ((i 0 (+ 1 i)))
		   ((= i (- (vct-length mn) 4)))
		 (if (< (vct-ref mn i) 0.5) (begin (snd-display #__line__ ";peak min: ~A ~A" (vct-ref mn i) i) (break #f)))
		 (if (< (vct-ref mx i) 0.5) (begin (snd-display #__line__ ";peak max: ~A ~A" (vct-ref mx i) i) (break #f)))))))
	  (undo 2)
	  (map-chan (lambda (y) -1.0) 0 50000)
	  (ramp-channel 0.5 1.0 1000 4000)
	  (let* ((peaks (channel-amp-envs ind 0))
		 (mx (cadr peaks))
		 (mn (car peaks))
		 (happy #t))
	    (do ((i 0 (+ 1 i)))
		((or (not happy) 
		     (= i (- (vct-length mn) 4))))
	      (if (> (vct-ref mn i) -0.5) (begin (snd-display #__line__ ";1 peak min: ~A ~A" (vct-ref mn i) i) (set! happy #f)))
	      (if (> (vct-ref mx i) -0.5) (begin (snd-display #__line__ ";1 peak max: ~A ~A" (vct-ref mx i) i) (set! happy #f)))))
	  (close-sound ind))
	
	(let ((index (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "channel tests")))
	  (define (test-channel-func func val-func init-val)
	    (let* ((len (frames index))
		   (chns (chans index))
		   (val #f))
	      (set! g-init-val init-val)
	      (do ((k 0 (+ 1 k)))
		  ((= k 2))
		(set! val (val-func len))
		(set! (sync index) k)
		(do ((i 0 (+ 1 i)))
		    ((= i chns))
		  (map-channel (lambda (n) 0.0) 0 len index i)
		  (if (scan-channel (lambda (n) (> (abs n) .001)) 0 len index i)
		      (snd-display #__line__ ";init scan: ~A?" (scan-channel (lambda (n) (> (abs n) 0.001))))))
		;; now it's cleared
		(do ((i 0 (+ 1 i)))
		    ((= i chns))
		  (map-channel (lambda (n) g-init-val) 0 len index i)
		  (func 0 len index i)
		  (do ((j 0 (+ 1 j)))
		      ((= j chns))
		    (let ((vi (channel->vct 0 len index j)))
		      (if (= j i)
			  (if (not (vequal vi val))
			      (snd-display #__line__ ";chan func: ~A ~A" vi val))
			  (if (scan-channel (lambda (n) (> (abs n) .001)) 0 len index j)
			      (snd-display #__line__ ";chan func leaks? ~A ~A: ~A" i j (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j))))))
		  (map-channel (lambda (n) 0.0) 0 len index i))
		(do ((i 0 (+ 1 i)))
		    ((= i chns))
		  (map-channel (lambda (n) g-init-val) 0 len index i)
		  (let ((ed (edit-position index i)))
		    (map-channel (lambda (n) (+ g-init-val 1.0)) 0 len index i)
		    (func 0 len index i ed)
		    (do ((j 0 (+ 1 j)))
			((= j chns))
		      (let ((vi (channel->vct 0 len index j)))
			(if (= j i)
			    (if (not (vequal vi val))
				(snd-display #__line__ ";ed chan func: ~A ~A" vi val))
			    (if (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j)
				(snd-display #__line__ ";ed chan func leaks? ~A ~A ~A: ~A" i j ed (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j))))))
		    (map-channel (lambda (n) 0.0) 0 len index i)))
		(let* ((beg (floor (/ len 3)))
		       (dur beg)
		       (nv (val-func dur)))
		  (vct-fill! val 0.0)
		  (do ((i beg (+ 1 i))
		       (j 0 (+ 1 j)))
		      ((= j dur))
		    (vct-set! val i (vct-ref nv j)))
		  (do ((i 0 (+ 1 i)))
		      ((= i chns))
		    (map-channel (lambda (n) g-init-val) beg dur index i)
		    (func beg dur index i)
		    (add-mark beg index i)
		    (do ((j 0 (+ 1 j)))
			((= j chns))
		      (let ((vi (channel->vct 0 len index j)))
			(if (= j i)
			    (if (not (vequal vi val))
				(snd-display #__line__ ";chan func n: ~A ~A" vi val))
			    (if (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j)
				(snd-display #__line__ ";dur chan func leaks? ~A ~A: ~A" i j (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j))))))
		    (map-channel (lambda (n) 0.0) 0 len index i))))))
	  
	  (insert-silence 0 10 index 0)
	  (insert-silence 0 10 index 1)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (clm-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 0 1 1) :length dur))
				     (v (make-vct dur)))
				 (do ((i 0 (+ 1 i)))
				     ((= i dur))
				   (vct-set! v i (env e)))
				 v))
			     0.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (clm-channel (make-oscil :frequency 0.0 :initial-phase (/ pi 2)) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((v (make-vct dur)))
				 (vct-fill! v 1.0)
				 v))
			     0.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (scale-channel 0.5 beg dur index chan edpos))
			     (lambda (dur)
			       (let ((v (make-vct dur)))
				 (vct-fill! v 0.5)
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (env-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 0 1 1) :length dur))
				     (v (make-vct dur)))
				 (do ((i 0 (+ 1 i)))
				     ((= i dur))
				   (vct-set! v i (env e)))
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (env-channel '(0 0 1 1) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 0 1 1) :length dur))
				     (v (make-vct dur)))
				 (do ((i 0 (+ 1 i)))
				     ((= i dur))
				   (vct-set! v i (env e)))
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (let ((v (make-vct dur)))
					(vct-fill! v -1.0)
					(vct->channel v beg dur index chan)))
			     (lambda (dur)
			       (let ((v (make-vct dur)))
				 (vct-fill! v -1.0)
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (delete-samples beg dur index chan edpos)
				      (pad-channel beg dur index chan edpos))
			     (lambda (dur)
			       (make-vct dur))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (let ((v (make-vct dur)))
					(vct-fill! v -1.0)
					(delete-samples beg dur index chan edpos)
					(insert-samples beg dur v index chan edpos)))
			     (lambda (dur)
			       (let ((v (make-vct dur)))
				 (vct-fill! v -1.0)
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (let ((v (make-vct dur)))
					(vct-fill! v -1.0)
					(set! (samples beg dur index chan #f "test-channel" 0 edpos) v)))
			     (lambda (dur)
			       (let ((v (make-vct dur)))
				 (vct-fill! v -1.0)
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (env-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos)
				      (reverse-channel beg dur index chan))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 1 1 0) :length dur))
				     (v (make-vct dur)))
				 (do ((i 0 (+ 1 i)))
				     ((= i dur))
				   (vct-set! v i (env e)))
				 v))
			     1.0)
	  
	  (test-channel-func (lambda* (beg dur index chan edpos)
				      (env-channel (make-env :envelope '(0 0 1 1) :length dur) beg dur index chan edpos)
				      (set! (sample (+ beg dur) index chan) 1.0)
				      (smooth-channel beg dur index chan)
				      (if (not (= beg 0))
					  (set! (sample (+ beg dur) index chan) 0.0)))
			     (lambda (dur)
			       (let ((v (make-vct dur)))
				 (do ((i 0 (+ 1 i)))
				     ((= i dur))
				   (vct-set! v i (+ 0.5 (* 0.5 (cos (+ pi (/ (* pi i) dur)))))))
				 v))
			     1.0)
	  
	  (let ((old-max (maxamp index #t))
		(regdata (map (lambda (n)
				(region->vct n 0 10))
			      (regions)))
		;; (old-pos0 (edit-position index 0))
		;; (old-pos1 (edit-position index 1))
		(old-reglen (map region-frames (regions)))
		(s61-files '()))
	    (add-hook! save-state-hook
		       (lambda (file)
			 (set! s61-files (cons file s61-files))
			 #f))
	    (if (file-exists? "s61.scm") (delete-file "s61.scm"))
	    (save-state "s61.scm")
	    (close-sound index)
	    (for-each forget-region (regions))
	    (load (string-append cwd "s61.scm"))
	    (if (not (equal? old-reglen (map region-frames (regions))))
		(snd-display #__line__ ";region-frames after save: ~A ~A" old-reglen (map region-frames (regions))))
	    (for-each (lambda (n data)
			(if (not (vequal data (region->vct n 0 10)))
			    (snd-display #__line__ ";region after save ~A: ~A ~A" n data (region->vct n 0 10))))
		      (regions)
		      regdata)
	    (set! index (find-sound "fmv.snd"))
	    (if (not (equal? (maxamp index #t) old-max))
		(snd-display #__line__ ";maxes: ~A ~A" (maxamp index #t) old-max))
	    (if (not (equal? (edits index) (list 275 0)))
		(snd-display #__line__ ";saved channel edits: ~A" (edits index)))
	    
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (let ((pos (random (car (edits index)))))
		(scale-channel (random 2.0) (random 5) (random 5) index 0 pos)
		(set! (edit-position index) (floor (* (car (edits index)) .7)))))
	    
	    (close-sound index)
	    (for-each
	     (lambda (n)
	       (forget-region n))
	     (regions))
	    (for-each
	     (lambda (file)
	       (if (file-exists? file) 
		   (delete-file file)))
	     s61-files)
	    (delete-file "s61.scm")
	    (reset-hook! save-state-hook)
	    ))
	
	(let ((index (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "channel tests"))
	      (v (make-vct 10))
	      (sw (sinc-width)))
	  (set! (sinc-width) 10)
	  (vct-set! v 0 1.0)
	  (vct->channel v 0 10 index 0)
	  (src-channel 0.5 0 10 index 0)
	  (let ((v (make-vct 10))
		(s (make-src :srate 0.5
			     :input (let ((val 1.0))
				      (lambda (dir)
					(let ((rtn val))
					  (set! val 0.0)
					  rtn))))))
	    (vct-set! v 0 (src s))
	    (do ((i 1 (+ 1 i)))
		((= i 10))
	      (vct-set! v i (src s)))
	    (if (not (vequal v (channel->vct 0 10 index 0)))
		(snd-display #__line__ ";src-channel: ~A ~A" v (channel->vct 0 10 index 0)))
	    (if (not (vequal (make-vct 10) (channel->vct 0 10 index 1)))
		(snd-display #__line__ ";src-channel leaks: ~A" (channel->vct 0 10 index 1)))
	    (let ((tag (catch #t (lambda () (src s 1.0 (lambda (a b) a))) (lambda args (car args)))))
	      (if (not (eq? tag 'bad-arity)) 
		  (snd-display #__line__ ";src bad func: ~A" tag))))
	  (let ((tag (catch #t (lambda () (src-channel 120000.0)) (lambda args args))))
	    (if (not (eq? (car tag) 'mus-error)) (snd-display #__line__ ";src-channel crazy srate: ~A" tag)))
	  (let ((tag (catch #t (lambda () (filter-sound (make-snd->sample))) (lambda args args))))
	    (if (not (eq? (car tag) 'mus-error)) (snd-display #__line__ ";filter-sound + un-run gen: ~A" tag)))
	  (revert-sound index)
	  (vct->channel v 0 10 index 1)
	  (vct->channel v 10 10 index 1)
	  (src-channel (make-env :envelope '(1 1 2 2) :length 21) 0 20 index 1)
	  (if (not (vequal (channel->vct 0 10 index 1) (vct 1.000 -0.000 -0.048 0.068 -0.059 0.022 0.030 -0.100 0.273 0.606)))
	      (snd-display #__line__ ";src-channel env: ~A" (channel->vct 0 10 index 1)))
	  (if (not (vequal (make-vct 10) (channel->vct 0 10 index 0)))
	      (snd-display #__line__ ";src-channel env leaks: ~A" (channel->vct 0 10 index 0)))
	  (revert-sound index)
	  (vct->channel v 0 10 index 1)
	  (vct->channel v 10 10 index 1)
	  (src-channel '(1 1 2 2) 0 20 index 1) ; end is off above -- should be 19 I think
	  (if (not (vequal (channel->vct 0 10 index 1) (vct 1.000 -0.000 -0.051 0.069 -0.056 0.015 0.042 -0.117 0.320 0.568)))
	      (snd-display #__line__ ";src-channel lst: ~A" (channel->vct 0 10 index 1)))
	  (if (not (vequal (make-vct 10) (channel->vct 0 10 index 0)))
	      (snd-display #__line__ ";src-channel lst leaks: ~A" (channel->vct 0 10 index 0)))
	  (set! (sinc-width) sw)
	  (close-sound index))
	
	(if (< (max-regions) 8) (set! (max-regions) 8))
	(let* ((ind (open-sound "oboe.snd"))
	       (rid0 (make-region 2000 2020 ind 0))
	       (rid0-data (region2vct rid0 0 20)))
	  (scale-sound-by 2.0)
	  (play rid0 :wait #t)
	  (let ((nv (region2vct rid0 0 20)))
	    (if (not (vequal rid0-data nv)) (snd-display #__line__ ";deferred region after scaling:~%  ~A~%  ~A" rid0-data nv)))
	  (let ((nv (region-to-vct rid0 0 20)))
	    (if (not (vequal rid0-data nv)) (snd-display #__line__ ";deferred region after scaling (rs):~%  ~A~%  ~A" rid0-data nv)))
	  (undo)
	  (scale-by 4.0)
	  (play rid0 :wait #t)
	  (let ((nv (region2vct rid0 0 20)))
	    (if (not (vequal rid0-data nv)) (snd-display #__line__ ";file region after scaling:~%  ~A~%  ~A" rid0-data nv)))
	  (let ((nv (region-to-vct rid0 0 20)))
	    (if (not (vequal rid0-data nv)) (snd-display #__line__ ";file region after scaling (rs):~%  ~A~%  ~A" rid0-data nv)))
	  (let* ((rid1 (make-region 2000 2020 ind 0))
		 (rid1-data (region2vct rid1 0 20)))
	    (scale-to .5)
	    (let ((nv (region2vct rid1 0 20)))
	      (if (not (vequal rid1-data nv)) (snd-display #__line__ ";deferred region after scale-to:~%  ~A~%  ~A" rid1-data nv)))
	    (close-sound ind)
	    (play rid0 :wait #t)
	    (play rid1 :wait #t)
	    (let ((nv (region2vct rid1 0 20)))
	      (if (not (vequal rid1-data nv)) (snd-display #__line__ ";deferred region after close:~%  ~A~%  ~A" rid1-data nv)))
	    (let ((nv (region2vct rid0 0 20)))
	      (if (not (vequal rid0-data nv)) (snd-display #__line__ ";file region after close:~%  ~A~%  ~A" rid0-data nv))))
	  
	  (for-each
	   (lambda (s1 l1 s2 l2)
	     (set! ind (open-sound "2.snd"))
	     (set! (selection-member? #t) #f)
	     (set! (selection-member? ind 0) #t)
	     (set! (selection-position ind 0) s1)
	     (set! (selection-frames ind 0) l1)
	     (set! (selection-member? ind 1) #t)
	     (set! (selection-position ind 1) s2)
	     (set! (selection-frames ind 1) l2)
	     (let* ((rid2 (make-region))
		    (rid20-data (region2vct rid2 0 l1))
		    (rid21-data (region2vct rid2 1 l2)))
	       (if (not (= (region-chans rid2) 2)) (snd-display #__line__ ";region-chans of sync'd sound: ~A?" (region-chans rid2)))
	       (swap-channels ind 0 ind 1)
	       (let ((nv (region2vct rid2 0 l1)))
		 (if (not (vequal rid20-data nv)) (snd-display #__line__ ";deferred region after scaling (20):~%  ~A~%  ~A" rid20-data nv)))
	       (let ((nv (region-to-vct rid2 0 l1)))
		 (if (not (vequal rid20-data nv)) (snd-display #__line__ ";deferred region after scaling (20 rs):~%  ~A~%  ~A" rid20-data nv)))
	       (let ((nv (region2vct rid2 1 l2)))
		 (if (not (vequal rid21-data nv)) (snd-display #__line__ ";deferred region after scaling (21):~%  ~A~%  ~A" rid21-data nv)))
	       (let ((nv (region-to-vct rid2 1 l2)))
		 (if (not (vequal rid21-data nv)) (snd-display #__line__ ";deferred region after scaling (21 rs):~%  ~A~%  ~A" rid21-data nv)))
	       (close-sound ind)
	       (let ((nv (region2vct rid2 0 l1)))
		 (if (not (vequal rid20-data nv)) (snd-display #__line__ ";deferred region after scaling (20):~%  ~A~%  ~A" rid20-data nv)))
	       (let ((nv (region-to-vct rid2 0 l1)))
		 (if (not (vequal rid20-data nv)) (snd-display #__line__ ";deferred region after scaling (20 rs):~%  ~A~%  ~A" rid20-data nv)))
	       (let ((nv (region2vct rid2 1 l2)))
		 (if (not (vequal rid21-data nv)) (snd-display #__line__ ";deferred region after scaling (21):~%  ~A~%  ~A" rid21-data nv)))
	       (let ((nv (region-to-vct rid2 1 l2)))
		 (if (not (vequal rid21-data nv)) (snd-display #__line__ ";deferred region after scaling (21 rs):~%  ~A~%  ~A" rid21-data nv)))
	       ))
	   (list 2000 2000 2000 0 2000 0 2000)
	   (list 20 10 20 20 20 10 20)
	   (list 2000 2000 2000 2000 0 2000 0)
	   (list 20 20 10 20 20 20 10)))
	
	(let ((ind (open-sound "obtest.snd")))
	  (set! (read-only ind) #t)
	  (delete-samples 0 1000 ind 0)
	  (let ((val (catch #t
			    (lambda ()
			      (save-sound ind))
			    (lambda args args))))
	    (if (sound? val) (snd-display #__line__ ";save-sound read-only: ~A" val))
	    (if (not (equal? (edits ind) (list 1 0))) (snd-display #__line__ ";read-only ignored? ~A" (edits ind))))
	  (set! (read-only ind) #f)
	  (revert-sound ind)
	  (let ((tag (catch #t
			    (lambda () (save-sound ind))
			    (lambda args args))))
	    (if (not (sound? tag)) (snd-display #__line__ ";save-sound read-write: ~A" tag)))
	  (key (char->integer #\j) 4)
	  (if with-gui
	      (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		(if (and (not (string=? str "no marks"))
			 (not (string=? str "no such mark")))
		    (snd-display #__line__ ";C-j w/o marks: ~A?" str))))
	  (key (char->integer #\-) 4)
	  (key (char->integer #\j) 4)
	  (key (char->integer #\j) 4)
	  (key (char->integer #\x) 4)
	  (key (char->integer #\c) 0)
	  (if with-gui
	      (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		(if (widget-text (cadr (main-widgets))) 
		    (snd-display #__line__ ";widget-text of non-text widget: ~A" (widget-text (cadr (main-widget)))))
		(set! (widget-text (list-ref (channel-widgets ind 0) 2)) "F")
		(if (not (string=? (widget-text (list-ref (channel-widgets ind 0) 2)) "F"))
		    (snd-display #__line__ ";set button label to F: ~A" (widget-text (list-ref (channel-widgets ind 0) 2)) "F"))
		(if (and (not (string=? str "no marks"))
			 (not (string=? str "no such mark")))
		    (snd-display #__line__ ";C-x c w/o marks: ~A?" str))))
	  (add-mark 123)
	  (key (char->integer #\u) 4)
	  (key (char->integer #\6) 4)
	  (key (char->integer #\j) 4)
	  (if with-gui
	      (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		(if (not (string=? str "no such mark"))
		    (snd-display #__line__ ";C-u 6 C-j: ~A?" str))))
	  (key (char->integer #\u) 4)
	  (key (char->integer #\6) 4)
	  (key (char->integer #\x) 4)
	  (key (char->integer #\c) 0)
	  (if with-gui
	      (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		(if (not (string=? str "no such mark"))
		    (snd-display #__line__ ";C-u 6 C-x c: ~A?" str))))
	  (close-sound ind))
	
	(let ((ind (view-sound "obtest.snd")))
	  (delete-samples 0 1000 ind 0)
	  (let ((tag (catch #t
			    (lambda () (save-sound ind))
			    (lambda args args))))
	    (if (integer? tag) (snd-display #__line__ ";save-viewed-sound: ~A" tag))
	    (if (not (equal? (edits ind) (list 1 0))) (snd-display #__line__ ";view read-only ignored? ~A" (edits ind))))
	  (close-sound ind))
	
	(let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1)))
	  (insert-silence 0 150000)
	  (map-channel (lambda (y) 0.5))
	  (env-sound '(0 0 1 1 2 0))
	  (fp 1.0 0.3 20)
	  (let ((old-curse (with-tracking-cursor)))
	    (set! (with-tracking-cursor) #t)
	    (play :wait #t)
	    (set! (with-tracking-cursor) old-curse))
	  (close-sound ind))
	(let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1)))
	  (for-each
	   (lambda (dur)
	     (insert-silence 0 dur)
	     (map-channel (lambda (y) 1.0))
	     (env-sound '(0 0 1 1 2 0))
	     (let ((reader (make-sampler (- (frames) 1) ind 0 -1)))
	       (if (not (= (sampler-position reader) (- (frames) 1))) (snd-display #__line__ ";sampler-position: ~A" (sampler-position reader)))
	       (map-channel (lambda (y) (read-sample reader))))
	     (scan-channel (let ((pos 0)
				 (e (make-env '(0 0 1 1 2 0) :length (+ 1 dur))))
			     (lambda (y)
			       (let ((val (env e)))
				 (if (fneq val y) 
				     (begin
				       (display (format #f "~%;trouble in reverse read at ~D ~A ~A" pos val y))
				       #t)
				     (begin
				       (set! pos (+ 1 pos))
				       #f))))))
	     (revert-sound))
	   (list 150 1500 150000))
	  (close-sound ind))
	(let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1)))
	  (insert-silence 0 1000)
	  (map-channel (lambda (y) 1.0))
	  (env-sound '(0 0 1 1 2 0))
	  (scale-channel 0.0 100 200)
	  (let ((reader (make-sampler (- (frames) 1) ind 0 -1)))
	    (map-channel (lambda (y) (read-sample reader))))
	  (scan-channel (let ((pos 0)
			      (e (make-env '(0 0 1 1 2 0) :length 1001)))
			  (lambda (y)
			    (let ((val (env e)))
			      (if (or (and (or (> pos 900) (<= pos 700))
					   (fneq val y))
				      (and (> pos 700) (<= pos 900)
					   (fneq y 0.0)))
				  (begin
				    (display (format #f "~%;trouble in reverse read 2 at ~D ~A ~A" pos val y))
				    #t)
				  (begin
				    (set! pos (+ 1 pos))
				    #f))))))
	  (close-sound ind))
	(let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1)))
	  (insert-silence 0 150000)
	  (map-channel (lambda (y) 1.0))
	  (let ((edpos (edit-position)))
	    (do ((i 0 (+ 1 i)))
		((= i 7))
	      (if (= i 5)
		  (scale-channel 0.5 1000 12345))
	      (env-sound '(0 0 1 1 2.5 0 3 1 4 0))
	      (if (= i 1)
		  (delete-samples 50 100)
		  (if (= i 2)
		      (insert-samples 300 100 (vct-fill! (make-vct 100) 0.5))
		      (if (= i 3)
			  (scale-channel 0.0 1000 1000)
			  (if (= i 4)
			      (vct->channel (vct-fill! (make-vct 100) .5) 500 100)
			      (if (= i 6)
				  (env-sound '(0 1 1 0) 10000 2000))))))
	      (let ((reader (make-sampler (- (frames) 1) ind 0 -1)))
		(map-channel (lambda (y) (read-sample reader))))
	      (let ((reader (make-sampler (- (frames) 1) ind 0 -1)))
		(map-channel (lambda (y) (read-sample reader))))
	      (scan-channel (let ((old-reader (make-sampler 0 ind 0 1 (- (edit-position ind 0) 2)))
				  (pos 0))
			      (lambda (y)
				(let ((val (read-sample old-reader)))
				  (if (fneq y val)
				      (begin
					(display (format #f "~%;trouble in reverse (~D) read at ~D ~A ~A" i pos val y))
					#t)
				      (begin
					(set! pos (+ 1 pos))
					#f))))))
	      (set! (edit-position ind 0) edpos)))
	  (close-sound ind))
	(let ((reader #f)
	      (last-proc #f))
	  (define (scan-again)
	    (if (sampler-at-end? reader)
		#f
		(let ((val (last-proc (reader))))
		  (if val 
		      (list val (- (sampler-position reader) 1))
		      (scan-again)))))
	  (define* (my-scan-chan proc)
	    (if proc 
		(begin
		  (set! last-proc proc)
		  (set! reader (make-sampler 0))))
	    (scan-again))
	  (let ((ind (open-sound "oboe.snd"))
		(val #f))
	    (let ((samp (sample 1000)))
	      (set! (cursor ind 0) 1000)
	      (if (fneq (sample) samp)
		  (snd-display #__line__ ";sample no args: ~A ~A" (sample) samp)))
	    (set! val (my-scan-chan (lambda (y) (> y .1))))
	    (if (not (equal? val (list #t 4423)))
		(snd-display #__line__ ";my-scan-chan: ~A" val))
	    (set! val (scan-again))
	    (if (not (equal? val (list #t 4463)))
		(snd-display #__line__ ";scan-again: ~A" val))
	    (let ((val (find-channel (lambda (y)
				       (let ((val (find-channel (lambda (y) (> y .1)))))
					 val)))))
	      (if (not (equal? val (list (list #t 4423) 0)))
		  (snd-display #__line__ ";find twice: ~A" val)))
	    (let ((val (find-channel (lambda (y)
				       (count-matches (lambda (y) (> y .1)))))))
	      (if (not (equal? val (list 2851 0)))
		  (snd-display #__line__ ";find+count: ~A" val)))
	    (set! (cursor) 1000)
	    (set! (sample) .5)
	    (if (fneq (sample 1000) .5)
		(snd-display #__line__ ";set sample no arg: ~A ~A" (sample 1000) (sample 0)))
	    (close-sound ind)))
	
	;; edit-menu.scm tests
	(if (defined? 'selection->new)
	    (let ((ind (view-sound "oboe.snd")))
	      (make-selection 1000 1999 ind 0)
	      (let ((newsnd (selection->new)))
		(if (not (sound? newsnd)) (snd-display #__line__ ";selection->new -> ~A" newsnd))
		(if (not (= (frames newsnd 0) 1000)) (snd-display #__line__ ";selection->new frames: ~A" (frames newsnd 0)))
		(if (not (equal? (edits ind 0) (list 0 0))) (snd-display #__line__ ";selection->new edited original? ~A" (edits ind 0)))
		(let ((newfile (file-name newsnd)))
		  (close-sound newsnd)
		  (delete-file newfile)
		  (mus-sound-forget newfile)))
	      (make-selection 1000 1999 ind 0)
	      (let ((newsnd (cut-selection->new)))
		(if (not (sound? newsnd)) (snd-display #__line__ ";cut-selection->new -> ~A" newsnd))
		(if (not (= (frames newsnd 0) 1000)) (snd-display #__line__ ";cut-selection->new frames: ~A" (frames newsnd 0)))
		(if (not (equal? (edits ind 0) (list 1 0))) (snd-display #__line__ ";cut-selection->new did not edit original? ~A" (edits ind 0)))
		(if (not (= (frames ind 0) (- (frames ind 0 0) 1000))) 
		    (snd-display #__line__ ";cut-selection->new cut: ~A ~A" (frames ind 0) (- (frames ind 0 0) 1000)))
		(undo 1 ind 0)
		(let ((newfile (file-name newsnd)))
		  (close-sound newsnd)
		  (delete-file newfile)
		  (mus-sound-forget newfile)))
	      (make-selection 1000 1999 ind 0)
	      (append-selection)
	      (if (not (= (frames ind 0) (+ (frames ind 0 0) 1000)))
		  (snd-display #__line__ ";append-selection: ~A ~A" (frames ind 0) (frames ind 0 0)))
	      (append-sound "oboe.snd")
	      (if (not (= (frames ind 0) (+ (* 2 (frames ind 0 0)) 1000)))
		  (snd-display #__line__ ";append-sound: ~A ~A" (frames ind 0) (frames ind 0 0)))
	      (revert-sound ind)
	      (let ((m1 (add-mark 1000))
		    (m2 (add-mark 12000)))
		(trim-front)
		(if (not (equal? (edits ind 0) (list 1 0))) (snd-display #__line__ ";time-front did not edit original? ~A" (edits ind 0)))
		(if (not (= (frames ind 0) (- (frames ind 0 0) 1000))) 
		    (snd-display #__line__ ";trim-front: ~A ~A" (frames ind 0) (- (frames ind 0 0) 1000)))
		(if (not (= (mark-sample m2) 11000)) (snd-display #__line__ ";trim-front m2: ~A" (mark-sample m2)))
		(undo 1 ind 0)
		(trim-back)
		(if (not (equal? (edits ind 0) (list 1 0))) (snd-display #__line__ ";time-back did not edit original? ~A" (edits ind 0)))
		(if (not (= (frames ind 0) 12001)) (snd-display #__line__ ";trim-back: ~A" (frames ind 0)))
		(if (not (= (mark-sample m1) 1000)) (snd-display #__line__ ";trim-back m1: ~A" (mark-sample m1)))
		(undo 1 ind 0)
		(add-mark 22000)
		(crop)
		(if (not (equal? (edits ind 0) (list 1 0))) (snd-display #__line__ ";crop did not edit original? ~A" (edits ind 0)))
		(if (not (= (frames ind 0) 21001)) (snd-display #__line__ ";crop: ~A" (frames ind 0)))
		(undo 1 ind 0)
		(close-sound ind))))
	
	(let ((ind (new-sound "test.snd")))
	  (map-chan (lambda (y) 1.0) 0 1000)
	  (env-channel (make-env '(0 1 1 1) :scaler .5 :length 1001))
	  (check-maxamp ind .5 "simple scaler")
	  (check-env-vals "simple scaler" (make-env '(0 1 1 1) :scaler .5 :length 1001))
	  (if (= (edit-position) 2)
	      (undo)
	      (snd-display #__line__ ";env+scl was no-op"))
	  (env-channel (make-env '(0 1 1 1) :offset .5 :length 1001))
	  (check-maxamp ind 1.5 "simple offset")
	  (check-env-vals "simple offset" (make-env '(0 1 1 1) :offset .5 :length 1001))
	  (if (= (edit-position) 2)
	      (undo)
	      (snd-display #__line__ ";env+offset was no-op"))
	  (env-channel (make-env '(0 0 1 1 2 0) :offset .5 :scaler 2.0 :length 1001))
	  (check-maxamp ind 2.5 "off+scl")
	  (check-env-vals "off+scl" (make-env '(0 0 1 1 2 0) :offset .5 :scaler 2.0 :length 1001))
	  (undo)
	  (env-channel (make-env '(0 -0.5 1 0 2 -1) :offset .5 :scaler 2.0 :length 1001))
	  (check-maxamp ind 1.5 "off+scl #2")
	  (let ((mx -12.0))
	    (scan-chan (lambda (y) 
			 (if (> y mx) 
			     (set! mx y))
			 #f))
	    (if (fneq mx 0.5) (snd-display #__line__ ";non abs max: ~A (correct: 0.5)" mx)))
	  (check-env-vals "off+scl #2" (make-env '(0 -0.5 1 0 2 -1) :offset .5 :scaler 2.0 :length 1001))
	  (undo)
	  (env-sound '(0 .5 1 .75 2 .25) 0 (frames) 32.0)
	  (check-maxamp ind 0.75 "xramp")
	  (check-env-vals "xramp" (make-env '(0 .5 1 .75 2 .25) :base 32.0 :length 1001))
	  (undo)
	  (env-channel-with-base '(0 .5 1 .75 2 .25) 32.0)
	  (check-maxamp ind 0.75 "xramp1")
	  (check-env-vals "xramp1" (make-env '(0 .5 1 .75 2 .25) :base 32.0 :length 1001))
	  
	  (close-sound ind))
	
	(let ((hlb (make-hilbert-transform 8))
	      (data (make-vct 20)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 20))
	    (vct-set! data i (hilbert-transform hlb (if (= i 0) 1.0 0.0))))
	  (if (not (vequal data (vct 0.0 -0.010 0.0 -0.046 0.0 -0.152 0.0 -0.614 0.0 0.614 0.0 0.152 0.0 0.046 0.0 0.010 0.0 0.0 0.0 0.0)))
	      (snd-display #__line__ ";hilbert-transform 8 impulse response: ~A" data)))
	
	(let ((hlb (make-hilbert-transform 7))
	      (data (make-vct 20)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 20))
	    (vct-set! data i (hilbert-transform hlb (if (= i 0) 1.0 0.0))))
	  (if (not (vequal data (vct -0.007 0.0 -0.032 0.0 -0.136 0.0 -0.608 0.0 0.608 0.0 0.136 0.0 0.032 0.0 0.007 0.0 0.0 0.0 0.0 0.0)))
	      (snd-display #__line__ ";hilbert-transform 7 impulse response: ~A" data)))
	
	(let ((ind (new-sound "test.snd")))
	  (pad-channel 0 1000)
	  (set! (sample 100) 1.0)
	  (let ((h (make-hilbert-transform 100)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    ;; now ideally we'd be back to an impulse
	    (if (> (abs (- (sample 500) .98)) .01)
		(snd-display #__line__ ";hilbert impulse: ~A" (sample 500)))
	    (set! (sample 500) 0.0)
	    (if (> (maxamp ind 0) .02)
		(snd-display #__line__ ";hilbert sidelobes: ~A" (maxamp ind 0)))
	    (scale-channel 0.0)
	    (set! (sample 100) 1.0)
	    (set! h (make-hilbert-transform 101))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (map-channel (lambda (y) (hilbert-transform h y)))
	    (if (> (abs (- (sample 504) .98)) .01)
		(snd-display #__line__ ";hilbert 101 impulse: ~A: ~A" (sample 504) (channel->vct 498 10)))
	    (set! (sample 504) 0.0)
	    (if (> (maxamp ind 0) .02)
		(snd-display #__line__ ";hilbert 101 sidelobes: ~A" (maxamp ind 0)))
	    (revert-sound))
	  (pad-channel 0 1000)
	  (set! (sample 100) 1.0)
	  (let ((lo (make-lowpass (* .1 pi) 20))
		(hi (make-highpass (* .1 pi) 20)))
	    (map-channel (lambda (y) (+ (lowpass lo y) (highpass hi y))))
	    (if (fneq (sample 120) 1.0)
		(snd-display #__line__ ";lowpass+highpass impulse: ~A" (sample 120)))
	    (set! (sample 120) 0.0)
	    (if (fneq (maxamp ind 0) 0.0)
		(snd-display #__line__ ";lowpass+highpass sidelobes: ~A" (maxamp ind 0))))
	  (undo 2)
	  (let ((lo (make-bandpass (* .1 pi) (* .2 pi) 20))
		(hi (make-bandstop (* .1 pi) (* .2 pi) 20)))
	    (map-channel (lambda (y) (+ (bandpass lo y) (bandstop hi y))))
	    (if (fneq (sample 120) 1.0)
		(snd-display #__line__ ";bandpass+bandstop impulse: ~A" (sample 120)))
	    (set! (sample 120) 0.0)
	    (if (fneq (maxamp ind 0) 0.0)
		(snd-display #__line__ ";bandpass+bandstop sidelobes: ~A" (maxamp ind 0))))
	  (close-sound ind))
	
	(let ((ind (new-sound "test.snd")))
	  (map-channel (lambda (y) (- 1.0 (random 2.0))) 0 10000)
	  (let ((f2 (make-bandpass-2 (* .12 pi) (* .15 pi) (* .22 pi) (* .25 pi) 100)))
	    (map-channel (lambda (y) (fir-filter f2 y)))
	    (let ((data (channel->vct)))
	      (undo)
	      (let* ((f1 (make-bandpass (* .12 pi) (* .15 pi) 100))
		     (f2 (make-bandpass (* .22 pi) (* .25 pi) 100)))
		(map-channel (lambda (y) (+ (fir-filter f1 y) (fir-filter f2 y))))
		(let ((data1 (channel->vct)))
		  (vct-subtract! data data1)
		  (if (> (vct-peak data) .00001)
		      (snd-display #__line__ ";fir-filter 2: ~A" (vct-peak data))))
		(undo))))
	  (close-sound ind))
	
	(reset-almost-all-hooks)
	
	(let ((ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "1st ramp re-order tests" 100)))
	  (map-channel (lambda (y) 1.0))
	  (for-each
	   (lambda (lst)
	     (let ((name (car lst))
		   (try-scale (cadr lst))
		   (f1 (caddr lst))
		   (f2 (cadddr lst))
		   (edpos (edit-position ind 0)))
	       (f1)
	       (let ((v1 (channel->vct 0 100 ind 0)))
		 (set! (edit-position ind 0) edpos)
		 (f2)
		 (let ((v2 (channel->vct 0 100 ind 0)))
		   (if (not (vequal v1 v2))
		       (snd-display #__line__ ";env reordering test ~A:~%; ~A~%; ~A" name v1 v2))
		   (set! (edit-position ind 0) edpos)))
	       (if try-scale
		   (begin
		     (scale-by 2.0)
		     (f1)
		     (let ((v1 (channel->vct 0 100 ind 0)))
		       (set! (edit-position ind 0) edpos)
		       (f2)
		       (scale-by 2.0)
		       (let ((v2 (channel->vct 0 100 ind 0)))
			 (if (not (vequal v1 v2))
			     (snd-display #__line__ ";scaled (2) env reordering test ~A:~%; ~A~%; ~A" name v1 v2))
			 (set! (edit-position ind 0) edpos)))
		     (f1)
		     (scale-by .5)
		     (let ((v1 (channel->vct 0 100 ind 0)))
		       (set! (edit-position ind 0) edpos)
		       (scale-by .5)
		       (f2)
		       (let ((v2 (channel->vct 0 100 ind 0)))
			 (if (not (vequal v1 v2))
			     (snd-display #__line__ ";scaled (.5) env reordering test ~A:~%; ~A~%; ~A" name v1 v2))
			 (set! (edit-position ind 0) edpos)))))))
	   
	   (list (list "ramp-xramp" #t
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1) 0 100 2.0))
		       (lambda ()
			 (env-sound '(0 0 1 1) 0 100 2.0)
			 (env-sound '(0 0 1 1 2 0))))
		 (list "ramp2-xramp (1)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1 3 0))
			 (env-sound '(0 0 1 1) 0 100 2.0))
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1) 0 100 2.0)
			 (env-sound '(0 0 1 1 3 0))))
		 (list "ramp2-xramp (2)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 3 0) 0 100 2.0))
		       (lambda ()
			 (env-sound '(0 0 1 1 3 0) 0 100 2.0)
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1))))
		 (list "xramp2-ramp (1)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 3 0) 0 100 3.0))
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1 3 0) 0 100 3.0)
			 (env-sound '(0 0 1 1))))
		 (list "xramp2-ramp (2)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1 3 0))
			 (env-sound '(0 0 1 1) 0 100 3.0))
		       (lambda ()
			 (env-sound '(0 0 1 1 3 0))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1) 0 100 3.0)))
		 (list "ptree-ramp" #t
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (ptree-channel (lambda (y) (* y 2.0))))
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1))))
		 (list "ptree-xramp" #t
		       (lambda ()
			 (env-sound '(0 0 1 1) 0 100 2.0)
			 (ptree-channel (lambda (y) (* y 2.0))))
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1) 0 100 2.0)))
		 (list "ptree-ramp2 (1)" #t
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0)))
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1 2 0))))
		 (list "ptree-ramp2 (2)" #t
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0)))
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0))
			 (ptree-channel (lambda (y) (* y 2.0)))))
		 (list "xramp-ptree-ramp (1)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1)))
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1))))
		 (list "xramp-ptree-ramp (2)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0))
		       (lambda ()
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1))
			 (ptree-channel (lambda (y) (* y 2.0)))))
		 (list "xramp-ptree-ramp (3)" #t
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0))
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (ptree-channel (lambda (y) (* y 2.0)))))
		 (list "xramp-ptree-ramp-zero" #f
		       (lambda ()
			 (scale-by 0.0)
			 (ptree-channel (lambda (y) 1.0))
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0))
		       (lambda ()
			 (scale-by 0.0)
			 (ptree-channel (lambda (y) 1.0))
			 (env-sound '(0 0 1 1 2 0) 0 100 2.0)
			 (env-sound '(0 0 1 1))))
		 (list "ptree-ramp3 (1)" #t
		       (lambda ()
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1 3 0)))
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1 3 0))))
		 (list "ptree-ramp3 (2)" #t
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0))
			 (ptree-channel (lambda (y) (* y 2.0)))
			 (env-sound '(0 0 1 1 3 0)))
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1 3 0))
			 (ptree-channel (lambda (y) (* y 2.0)))))
		 (list "ramp4" #t
		       (lambda ()
			 (env-sound '(0 0 1 1))
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1 3 0))
			 (env-sound '(0 0 1 1 4 0)))
		       (lambda ()
			 (env-sound '(0 0 1 1 4 0))
			 (env-sound '(0 0 1 1 2 0))
			 (env-sound '(0 0 1 1 3 0))
			 (env-sound '(0 0 1 1))))
		 
		 ))
	  (close-sound ind))
	
	(let ((ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "2nd ramp re-order tests" 100))
	      (oldopt (optimization)))
	  
	  (define (reversed-channel->vct start dur snd chn)
	    (let* ((data (make-vct dur))
		   (sf (make-sampler (+ start dur -1) snd chn -1)))
	      (do ((i (+ start dur -1) (- i 1)))
		  ((< i start))
		(vct-set! data i (read-sample sf)))
	      data))
	  
	  (if (and (provided? 'snd-motif)
		   (provided? 'xm))
	      (let* ((edhist (list-ref (channel-widgets ind 0) 7))
		     (edp (XtParent edhist))
		     (pmax (cadr (XtVaGetValues edp (list XmNpaneMaximum 0)))))
		(XtUnmanageChild edp) 
		(XtVaSetValues edp (list XmNpaneMinimum 100)) 
		(XtManageChild edp)))
	  
	  (set! (squelch-update ind) #t)
	  
	  (do ((k 0 (+ 1 k)))
	      ((= k 2))
	    (revert-sound ind)
	    (if (= k 0)
		(map-channel (lambda (y) 1.0))
		(begin
		  (scale-by 0.0)
		  (ptree-channel (lambda (y) 1.0))))
	    (let* ((ramp1 (lambda () (env-sound '(0 0 1 1))))
		   (ramp2 (lambda () (env-sound '(0 0 1 1 2 0))))
		   (ramp3 (lambda () (env-sound '(0 1 1 0 2 0 3 1))))
		   (ramp4 (lambda () (env-sound '(0 1 1 0 2 1))))
		   (xramp1 (lambda () (env-sound '(0 0 1 1) 0 100 2.0)))
		   (xramp2 (lambda () (env-sound '(0 1 1 0 2 0 3 1) 0 100 .6)))
		   (ptree1 (lambda () (ptree-channel (lambda (y) (+ y .2)))))
		   (ptree2 (lambda () (ptree-channel (lambda (y) (- y .1)))))
		   (map1 (lambda () (map-channel (lambda (y) (+ y .2)))))
		   (map2 (lambda () (map-channel (lambda (y) (- y .1)))))
		   (ops (list ramp1 ramp2 ramp3 xramp1 xramp2 ptree1 ptree2 ramp4))
		   (op-names (list "ramp1" "ramp2" "ramp3" "xramp1" "xramp2" "ptree1" "ptree2" "ramp4"))
		   (op (lambda (which) ((list-ref ops which))))
		   (op-name (lambda (which) (list-ref op-names which)))
		   (vals1 #f)
		   (vals2 #f)
		   (scl 1.0)
		   (scalers '())
		   (saved-scalers '())
		   (edpos (edit-position ind 0)))
	      
	      (let ((op1 (list 0 3 5))
		    (op2 (list 1 4 6)))
		(for-each
		 (lambda (first)
		   (for-each 
		    (lambda (second)
		      (if (and (not (= first second))
			       (let ((val (+ k
					     (if (> first 4) 1 0)
					     (if (> second 4) 1 0))))
				 (not (> val 2))))
			  (begin
			    (set! scalers '())
			    (set! scl (+ .5 (random 1.0)))
			    (scale-by scl)
			    (set! scalers (cons scl scalers))
			    (op first)
			    (set! scl (+ .5 (random 1.0)))
			    (scale-by scl)
			    (set! scalers (cons scl scalers))
			    (op second)
			    (set! scl (+ .5 (random 1.0)))
			    (scale-by scl)
			    (set! scalers (cons scl scalers))
			    (set! vals1 (channel->vct 0 100 ind 0))
			    (let ((rvals (reversed-channel->vct 0 100 ind 0)))
			      (if (not (vequal rvals vals1))
				  (snd-display #__line__ ";1 virtual op reversed tests: ~A(~A~A) * ~A:~%; ~A~%; ~A => ~A"
					       (op-name second) (op-name first)
					       (if (= k 1) "(ptree_zero)" "")
					       scalers vals1 rvals
					       (vct-peak (vct-subtract! (vct-copy vals1) rvals)))))
			    (set! (edit-position ind 0) edpos)
			    (set! (optimization) 0)
			    (set! scalers (reverse scalers))
			    (set! saved-scalers scalers)
			    (scale-by (car scalers)) (set! scalers (cdr scalers))
			    (if (= first 5) (map1) (if (= first 6) (map2) (op first)))
			    (scale-by (car scalers)) (set! scalers (cdr scalers))
			    (if (= second 5) (map1) (if (= second 6) (map2) (op second)))
			    (scale-by (car scalers)) (set! scalers (cdr scalers))
			    (set! (optimization) oldopt)
			    (set! vals2 (channel->vct 0 100 ind 0))
			    (if (not (vequal vals1 vals2)) 
				(snd-display #__line__ ";1 virtual op tests: ~A(~A~A) * ~A:~%; ~A~%; ~A => ~A at ~A"
					     (op-name second) (op-name first)
					     (if (= k 1) "(ptree_zero)" "")
					     saved-scalers vals1 vals2
					     (vct-peak (vct-subtract! (vct-copy vals1) vals2))
					     (let* ((pks (vct-subtract! (vct-copy vals1) vals2))
						    (pk (abs (vct-ref pks 0)))
						    (loc 0))
					       (do ((i 1 (+ 1 i)))
						   ((= i 100) (list loc (vct-ref pks loc) (vct-ref vals1 loc) (vct-ref vals2 loc)))
						 (if (> (abs (vct-ref pks i)) pk)
						     (begin
						       (set! loc i)
						       (set! pk (abs (vct-ref pks i)))))))
					     ))
			    (let ((rvals (reversed-channel->vct 0 100 ind 0)))
			      (if (not (vequal rvals vals2))
				  (snd-display #__line__ ";1 virtual op reversed tests (2): ~A(~A~A) * ~A:~%; ~A~%; ~A => ~A"
					       (op-name second) (op-name first)
					       (if (= k 1) "(ptree_zero)" "")
					       saved-scalers vals2 rvals
					       (vct-peak (vct-subtract! (vct-copy vals2) rvals)))))
			    (set! (edit-position ind 0) edpos))))
		    op2))
		 op1))
	      (let ((op1 (list 0 3 5))
		    (op2 (list 1 4 6))
		    (op3 (list 2 3 4 5 6)))
		(for-each
		 (lambda (first)
		   (for-each 
		    (lambda (second)
		      (if (not (= first second))
			  (for-each
			   (lambda (third)
			     (if (and (not (= first third))
				      (not (= second third))
				      (let ((val (+ k
						    (if (or (= first 5) (= first 6)) 1 0)
						    (if (or (= second 5) (= second 6)) 1 0)
						    (if (or (= third 5) (= third 6)) 1 0))))
					(not (> val 2))))
				 (begin
				   (set! scalers '())
				   (set! scl (+ .5 (random 1.0)))
				   (scale-by scl)
				   (set! scalers (cons scl scalers))
				   (op first)
				   (set! scl (+ .5 (random 1.0)))
				   (scale-by scl)
				   (set! scalers (cons scl scalers))
				   (op second)
				   (set! scl (+ .5 (random 1.0)))
				   (scale-by scl)
				   (set! scalers (cons scl scalers))
				   (op third)
				   (set! scl (+ .5 (random 1.0)))
				   (scale-by scl)
				   (set! scalers (cons scl scalers))
				   (set! vals1 (channel->vct 0 100 ind 0))
				   (let ((rvals (reversed-channel->vct 0 100 ind 0)))
				     (if (not (vequal rvals vals1))
					 (snd-display #__line__ ";2 virtual op reversed tests: ~A(~A(~A~A)) * ~A:~%; ~A~%; ~A => ~A"
						      (op-name third) (op-name second) (op-name first)
						      (if (= k 1) "(ptree_zero)" "")
						      scalers vals1 rvals
						      (vct-peak (vct-subtract! (vct-copy vals1) rvals)))))
				   (set! (edit-position ind 0) edpos)
				   (set! (optimization) 0)
				   (set! scalers (reverse scalers))
				   (set! saved-scalers scalers)				     
				   (scale-by (car scalers)) (set! scalers (cdr scalers))
				   (if (= first 5) (map1) (if (= first 6) (map2) (op first)))
				   (scale-by (car scalers)) (set! scalers (cdr scalers))
				   (if (= second 5) (map1) (if (= second 6) (map2) (op second)))
				   (scale-by (car scalers)) (set! scalers (cdr scalers))
				   (if (= third 5) (map1) (if (= third 6) (map2) (op third)))
				   (scale-by (car scalers)) (set! scalers (cdr scalers))
				   (set! (optimization) oldopt)
				   (set! vals2 (channel->vct 0 100 ind 0))
				   (if (not (vequal vals1 vals2)) 
				       (snd-display #__line__ ";2 virtual op tests: ~A * ~A(~A(~A~A)): ~A ~A => ~A at ~A"
						    saved-scalers (op-name third) (op-name second) (op-name first) 
						    (if (= k 1) "(ptree_zero)" "")
						    vals1 vals2
						    (vct-peak (vct-subtract! (vct-copy vals1) vals2))
						    (let* ((pks (vct-subtract! (vct-copy vals1) vals2))
							   (pk (abs (vct-ref pks 0)))
							   (loc 0))
						      (do ((i 1 (+ 1 i)))
							  ((= i 100) (list loc (vct-ref pks loc) (vct-ref vals1 loc) (vct-ref vals2 loc)))
							(if (> (abs (vct-ref pks i)) pk)
							    (begin
							      (set! loc i)
							      (set! pk (abs (vct-ref pks i)))))))
						    ))
				   (let ((rvals (reversed-channel->vct 0 100 ind 0)))
				     (if (not (vequal rvals vals2))
					 (snd-display #__line__ ";2 virtual op reversed tests (2): ~A(~A(~A~A)) * ~A:~%; ~A~%; ~A => ~A"
						      (op-name third) (op-name second) (op-name first)
						      (if (= k 1) "(ptree_zero)" "")
						      saved-scalers vals2 rvals
						      (vct-peak (vct-subtract! (vct-copy vals2) rvals)))))
				   (set! (edit-position ind 0) edpos))))
			   op3)))
		    op2))
		 op1))
	      (let ((op1 (list 0 3 5))
		    (op2 (list 0 1 3 4 5 6))
		    (op3 (list 0 1 2 3 4 5 6))
		    (op4 (list 0 1 2 3 4 5 6)))
		(for-each
		 (lambda (first)
		   (for-each 
		    (lambda (second)
		      (if (not (= first second))
			  (for-each
			   (lambda (third)
			     (if (and (not (= first third))
				      (not (= second third)))
				 (for-each
				  (lambda (fourth)
				    (if (and (not (= first fourth))
					     (not (= second fourth))
					     (not (= third fourth))
					     (let ((val (+ k
							   (if (or (= first 5) (= first 6)) 1 0)
							   (if (or (= second 5) (= second 6)) 1 0)
							   (if (or (= third 5) (= third 6)) 1 0)
							   (if (or (= fourth 5) (= fourth 6)) 1 0))))
					       (not (> val 2))))
					(begin
					  (set! scalers '())
					  (set! scl (+ .5 (random 1.0)))
					  (scale-by scl)
					  (set! scalers (cons scl scalers))
					  (op first)
					  (set! scl (+ .5 (random 1.0)))
					  (scale-by scl)
					  (set! scalers (cons scl scalers))
					  (op second)
					  (set! scl (+ .5 (random 1.0)))
					  (scale-by scl)
					  (set! scalers (cons scl scalers))
					  (op third)
					  (set! scl (+ .5 (random 1.0)))
					  (scale-by scl)
					  (set! scalers (cons scl scalers))
					  (op fourth)
					  (set! scl (+ .5 (random 1.0)))
					  (scale-by scl)
					  (set! scalers (cons scl scalers))
					  (set! vals1 (channel->vct 0 100 ind 0))
					  (let ((rvals (reversed-channel->vct 0 100 ind 0)))
					    (if (not (vequal rvals vals1))
						(snd-display #__line__ ";3 virtual op reversed tests: ~A(~A(~A(~A~A))) * ~A:~%; ~A~%; ~A => ~A"
							     (op-name fourth) (op-name third) (op-name second) (op-name first)
							     (if (= k 1) "(ptree_zero)" "")
							     scalers vals1 rvals
							     (vct-peak (vct-subtract! (vct-copy vals1) rvals)))))
					  (set! (edit-position ind 0) edpos)
					  (set! (optimization) 0)
					  (set! scalers (reverse scalers))
					  (set! saved-scalers scalers)
					  (scale-by (car scalers)) (set! scalers (cdr scalers))
					  (if (= first 5) (map1) (if (= first 6) (map2) (op first)))
					  (scale-by (car scalers)) (set! scalers (cdr scalers))
					  (if (= second 5) (map1) (if (= second 6) (map2) (op second)))
					  (scale-by (car scalers)) (set! scalers (cdr scalers))
					  (if (= third 5) (map1) (if (= third 6) (map2) (op third)))
					  (scale-by (car scalers)) (set! scalers (cdr scalers))
					  (if (= fourth 5) (map1) (if (= fourth 6) (map2) (op fourth)))
					  (scale-by (car scalers)) (set! scalers (cdr scalers))
					  (set! (optimization) oldopt)
					  (set! vals2 (channel->vct 0 100 ind 0))
					  (if (not (vequal vals1 vals2)) 
					      (snd-display #__line__ ";3 virtual op tests: ~A * ~A(~A(~A(~A~A))):~%  opt vals:   ~A~%  unopt vals: ~A~%  => ~A at ~A"
							   saved-scalers
							   (op-name fourth) (op-name third) (op-name second) (op-name first)
							   (if (= k 1) "(ptree_zero)" "") 
							   vals1 vals2
							   (vct-peak (vct-subtract! (vct-copy vals1) vals2))
							   (let* ((pks (vct-subtract! (vct-copy vals1) vals2))
								  (pk (abs (vct-ref pks 0)))
								  (loc 0))
							     (do ((i 1 (+ 1 i)))
								 ((= i 100) (list loc (vct-ref pks loc) (vct-ref vals1 loc) (vct-ref vals2 loc)))
							       (if (> (abs (vct-ref pks i)) pk)
								   (begin
								     (set! loc i)
								     (set! pk (abs (vct-ref pks i)))))))
							   ))
					  (let ((rvals (reversed-channel->vct 0 100 ind 0)))
					    (if (not (vequal rvals vals2))
						(snd-display #__line__ ";3 virtual op reversed tests (2): ~A(~A(~A(~A~A))) * ~A: ~A ~A => ~A"
							     (op-name fourth) (op-name third) (op-name second) (op-name first)
							     (if (= k 1) "(ptree_zero)" "")
							     saved-scalers vals2 rvals
							     (vct-peak (vct-subtract! (vct-copy vals2) rvals)))))
					  (set! (edit-position ind 0) edpos))))
				  op4)))
			   op3)))
		    op2))
		 op1))
	      
	      (if all-args
		  (let ((op1 (list 0 3 5))
			(op2 (list 0 1 3 4 5 6))
			(op3 (list 0 1 2 3 4 5 6))
			(op4 (list 0 1 2 3 4 5 6 7))
			(op5 (list 7 3 5)))
		    (for-each
		     (lambda (first)
		       (for-each 
			(lambda (second)
			  (if (not (= first second))
			      (for-each
			       (lambda (third)
				 (if (and (not (= first third))
					  (not (= second third)))
				     (for-each
				      (lambda (fourth)
					(if (and (not (= first fourth))
						 (not (= second fourth))
						 (not (= third fourth)))
					    (for-each
					     (lambda (fifth)
					       (if (and (not (= first fifth))
							(not (= second fifth))
							(not (= third fifth))
							(not (= fourth fifth))
							(let ((val (+ k
								      (if (or (= first 5) (= first 6)) 1 0)
								      (if (or (= second 5) (= second 6)) 1 0)
								      (if (or (= third 5) (= third 6)) 1 0)
								      (if (or (= fourth 5) (= fourth 6)) 1 0)
								      (if (or (= fifth 5) (= fifth 6)) 1 0))))
							  (not (> val 2))))
						   (begin
						     (set! scalers '())
						     (set! scl (+ .5 (random 1.0)))
						     (scale-by scl)
						     (set! scalers (cons scl scalers))
						     (op first)
						     (set! scl (+ .5 (random 1.0)))
						     (scale-by scl)
						     (set! scalers (cons scl scalers))
						     (op second)
						     (set! scl (+ .5 (random 1.0)))
						     (scale-by scl)
						     (set! scalers (cons scl scalers))
						     (op third)
						     (set! scl (+ .5 (random 1.0)))
						     (scale-by scl)
						     (set! scalers (cons scl scalers))
						     (op fourth)
						     (set! scl (+ .5 (random 1.0)))
						     (scale-by scl)
						     (set! scalers (cons scl scalers))
						     (op fifth)
						     (set! scl (+ .5 (random 1.0)))
						     (scale-by scl)
						     (set! scalers (cons scl scalers))
						     (set! vals1 (channel->vct 0 100 ind 0))
						     (let ((rvals (reversed-channel->vct 0 100 ind 0)))
						       (if (not (vequal rvals vals1))
							   (snd-display #__line__ ";4 virtual op reversed tests: ~A(~A(~A(~A(~A~A)))) * ~A: ~A ~A => ~A"
									(op-name fifth) (op-name fourth) (op-name third) (op-name second) (op-name first)
									(if (= k 1) "(ptree_zero)" "")
									scalers vals1 rvals
									(vct-peak (vct-subtract! (vct-copy vals1) rvals)))))
						     (set! (edit-position ind 0) edpos)
						     (set! (optimization) 0)
						     (set! scalers (reverse scalers))
						     (set! saved-scalers scalers)
						     (scale-by (car scalers)) (set! scalers (cdr scalers))
						     (if (= first 5) (map1) (if (= first 6) (map2) (op first)))
						     (scale-by (car scalers)) (set! scalers (cdr scalers))
						     (if (= second 5) (map1) (if (= second 6) (map2) (op second)))
						     (scale-by (car scalers)) (set! scalers (cdr scalers))
						     (if (= third 5) (map1) (if (= third 6) (map2) (op third)))
						     (scale-by (car scalers)) (set! scalers (cdr scalers))
						     (if (= fourth 5) (map1) (if (= fourth 6) (map2) (op fourth)))
						     (scale-by (car scalers)) (set! scalers (cdr scalers))
						     (if (= fifth 5) (map1) (if (= fifth 6) (map2) (op fifth)))
						     (scale-by (car scalers)) (set! scalers (cdr scalers))
						     (set! (optimization) oldopt)
						     (set! vals2 (channel->vct 0 100 ind 0))
						     (if (not (vequal vals1 vals2)) 
							 (snd-display #__line__ ";4 virtual op tests: ~A * ~A(~A(~A(~A(~A~A)))): ~A ~A => ~A at ~A"
								      saved-scalers
								      (op-name fifth) (op-name fourth) (op-name third) (op-name second) (op-name first)
								      (if (= k 1) "(ptree_zero)" "") 
								      vals1 vals2
								      (vct-peak (vct-subtract! (vct-copy vals1) vals2))
								      (let* ((pks (vct-subtract! (vct-copy vals1) vals2))
									     (pk (abs (vct-ref pks 0)))
									     (loc 0))
									(do ((i 1 (+ 1 i)))
									    ((= i 100) (list loc (vct-ref pks loc) (vct-ref vals1 loc) (vct-ref vals2 loc)))
									  (if (> (abs (vct-ref pks i)) pk)
									      (begin
										(set! loc i)
										(set! pk (abs (vct-ref pks i)))))))
								      ))
						     (let ((rvals (reversed-channel->vct 0 100 ind 0)))
						       (if (not (vequal rvals vals2))
							   (snd-display #__line__ ";4 virtual op reversed tests (2): ~A(~A(~A(~A(~A~A)))) * ~A: ~A ~A => ~A"
									(op-name fifth) (op-name fourth) (op-name third) (op-name second) (op-name first)
									(if (= k 1) "(ptree_zero)" "")
									saved-scalers vals2 rvals
									(vct-peak (vct-subtract! (vct-copy vals2) rvals)))))
						     (set! (edit-position ind 0) edpos))))
					     op5)))
				      op4)))
			       op3)))
			op2))
		     op1)))
	      
	      (if all-args
		  (let ((op1 (list 0 3 5))
			(op2 (list 0 1 3 4 5 6))
			(op3 (list 0 1 2 3 4 5 6))
			(op4 (list 0 1 2 3 4 5 6))
			(op5 (list 7 3 5))
			(op6 (list 0 1 2 3 4 5 6 7)))
		    (for-each
		     (lambda (first)
		       (for-each 
			(lambda (second)
			  (if (not (= first second))
			      (for-each
			       (lambda (third)
				 (if (and (not (= first third))
					  (not (= second third)))
				     (for-each
				      (lambda (fourth)
					(if (and (not (= first fourth))
						 (not (= second fourth))
						 (not (= third fourth)))
					    (for-each
					     (lambda (fifth)
					       (if (and (not (= first fifth))
							(not (= second fifth))
							(not (= third fifth))
							(not (= fourth fifth)))
						   (for-each
						    (lambda (sixth)
						      (if (and (not (= first sixth))
							       (not (= second sixth))
							       (not (= third sixth))
							       (not (= fourth sixth))
							       (not (= fifth sixth))
							       (let ((val (+ k
									     (if (or (= first 5) (= first 6)) 1 0)
									     (if (or (= second 5) (= second 6)) 1 0)
									     (if (or (= third 5) (= third 6)) 1 0)
									     (if (or (= fourth 5) (= fourth 6)) 1 0)
									     (if (or (= fifth 5) (= fifth 6)) 1 0)
									     (if (or (= sixth 5) (= sixth 6)) 1 0))))
								 (not (> val 2)))
							       (let ((val (+ (if (member first (list 0 1 2 3 4 7)) 1 0)
									     (if (member second (list 0 1 2 3 4 7)) 1 0)
									     (if (member third (list 0 1 2 3 4 7)) 1 0)
									     (if (member fourth (list 0 1 2 3 4 7)) 1 0)
									     (if (member fifth (list 0 1 2 3 4 7)) 1 0)
									     (if (member sixth (list 0 1 2 3 4 7)) 1 0))))
								 (not (> val 4))))
							  (begin
							    (set! scalers '())
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (op first)
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (op second)
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (op third)
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (op fourth)
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (op fifth)
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (op sixth)
							    (set! scl (+ .5 (random 1.0)))
							    (scale-by scl)
							    (set! scalers (cons scl scalers))
							    (set! vals1 (channel->vct 0 100 ind 0))
							    (let ((rvals (reversed-channel->vct 0 100 ind 0)))
							      (if (not (vequal rvals vals1))
								  (snd-display #__line__ ";5 virtual op reversed tests: ~A(~A(~A(~A(~A(~A~A))))) * ~A: ~A ~A => ~A"
									       (op-name sixth) (op-name fifth) (op-name fourth) 
									       (op-name third) (op-name second) (op-name first)
									       (if (= k 1) "(ptree_zero)" "")
									       scalers vals1 rvals
									       (vct-peak (vct-subtract! (vct-copy vals1) rvals)))))
							    (set! (edit-position ind 0) edpos)
							    (set! (optimization) 0)
							    (set! scalers (reverse scalers))
							    (set! saved-scalers scalers)
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (if (= first 5) (map1) (if (= first 6) (map2) (op first)))
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (if (= second 5) (map1) (if (= second 6) (map2) (op second)))
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (if (= third 5) (map1) (if (= third 6) (map2) (op third)))
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (if (= fourth 5) (map1) (if (= fourth 6) (map2) (op fourth)))
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (if (= fifth 5) (map1) (if (= fifth 6) (map2) (op fifth)))
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (if (= sixth 5) (map1) (if (= sixth 6) (map2) (op sixth)))
							    (scale-by (car scalers)) (set! scalers (cdr scalers))
							    (set! (optimization) oldopt)
							    (set! vals2 (channel->vct 0 100 ind 0))
							    (if (not (vequal vals1 vals2)) 
								(snd-display #__line__ ";5 virtual op tests: ~A * ~A(~A(~A(~A(~A(~A~A))))): ~A ~A => ~A at ~A"
									     saved-scalers
									     (op-name sixth) (op-name fifth) (op-name fourth) 
									     (op-name third) (op-name second) (op-name first)
									     (if (= k 1) "(ptree_zero)" "") 
									     vals1 vals2
									     (vct-peak (vct-subtract! (vct-copy vals1) vals2))
									     (let* ((pks (vct-subtract! (vct-copy vals1) vals2))
										    (pk (abs (vct-ref pks 0)))
										    (loc 0))
									       (do ((i 1 (+ 1 i)))
										   ((= i 100) (list loc (vct-ref pks loc) (vct-ref vals1 loc) (vct-ref vals2 loc)))
										 (if (> (abs (vct-ref pks i)) pk)
										     (begin
										       (set! loc i)
										       (set! pk (abs (vct-ref pks i)))))))
									     ))
							    (let ((rvals (reversed-channel->vct 0 100 ind 0)))
							      (if (not (vequal rvals vals2))
								  (snd-display #__line__ ";5 virtual op reversed tests (2): ~A(~A(~A(~A(~A(~A~A))))) * ~A: ~A ~A => ~A"
									       (op-name sixth) (op-name fifth) (op-name fourth) 
									       (op-name third) (op-name second) (op-name first)
									       (if (= k 1) "(ptree_zero)" "")
									       saved-scalers vals2 rvals
									       (vct-peak (vct-subtract! (vct-copy vals2) rvals)))))
							    (set! (edit-position ind 0) edpos))))
						    op6)))
					     op5)))
				      op4)))
			       op3)))
			op2))
		     op1)))))
	  (close-sound ind))
	
	(if all-args ; include mix in cycling tests
	    (let ((old-ptrees (max-virtual-ptrees)))
	      
	      (set! (max-virtual-ptrees) 10)
	      
	      (letrec ((local-vequal (lambda (v0 v1 n)
				       (let ((old-fudge (mus-float-equal-fudge-factor)))
					 (set! (mus-float-equal-fudge-factor) (* n .001))
					 (let ((result (equal? v0 v1)))
					   (set! (mus-float-equal-fudge-factor) old-fudge)
					   result))))
		       
		       (add-1 (lambda (ind)
				(ptree-channel (lambda (y) (+ y 1.0)) 0 20 ind 0)
				(let ((data (channel->vct 0 20 ind 1)))
				  (vct-offset! data 1.0)
				  (vct->channel data 0 20 ind 1))))
		       
		       (ramp-1 (lambda (ind)
				 (ramp-channel 0 1.0 0 21 ind 0)
				 (let ((data (channel->vct 0 20 ind 1)))
				   (do ((i 0 (+ 1 i))
					(val 0 (+ val .05)))
				       ((= i 20))
				     (vct-set! data i (* (vct-ref data i) val)))
				   (vct->channel data 0 20 ind 1))))
		       
		       (mix-1 (lambda (ind)
				(let ((mdata (vct 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 -0.5)))
				  (mix-vct mdata 5 ind 0 #t)
				  (let ((data (channel->vct 5 10 ind 1)))
				    (vct-add! data mdata)
				    (vct->channel data 5 10 ind 1)))))
		       
		       (env-1 (lambda (ind)
				(env-channel '(0 0 1 1 2 1 3 0) 0 20 ind 0)
				(let ((e1 (vct 0.0 0.166667 0.333333 0.5 0.666667 0.833333 1.0 1.0 1.0 1.0 
					       1.0 1.0 1.0 1.0 0.833333 0.666667 0.5 0.333333 0.166667 0.0))
				      (data (channel->vct 0 20 ind 1)))
				  (vct-multiply! data e1)
				  (vct->channel data 0 20 ind 1))))
		       
		       (env-2 (lambda (ind)
				(env-channel-with-base '(0 0 1 1 2 1 3 0) 8.0 0 20 ind 0)
				(let ((e1 (vct 0.0 0.059173 0.142857 0.261204 0.428571 0.665265 1.0 1.0 1.0 
					       1.0 1.0 1.0 1.0 1.0 0.665265 0.428571 0.261204 0.142857 0.059173 0.0))
				      (data (channel->vct 0 20 ind 1)))
				  (vct-multiply! data e1)
				  (vct->channel data 0 20 ind 1))))
		       
		       (env-3 (lambda (ind)
				(env-channel '(0 1 1 0 2 0 3 1) 0 20 ind 0)
				(let ((e1 (vct 1.0 0.833333 0.666667 0.5 0.333333 0.166667 0.0 0.0 0.0 0.0 
					       0.0 0.0 0.0 0.0 0.166667 0.333333 0.5 0.666667 0.833333 1.0))
				      (data (channel->vct 0 20 ind 1)))
				  (vct-multiply! data e1)
				  (vct->channel data 0 20 ind 1))))
		       
		       (env-4 (lambda (ind)
				(env-channel-with-base '(0 1 1 0 2 0 3 1) 8.0 0 20 ind 0)
				(let ((e1 (vct 1.0 0.665265 0.428571 0.261204 0.142857 0.059173 0.0 0.0 0.0 
					       0.0 0.0 0.0 0.0 0.0 0.059173 0.142857 0.261204 0.428571 0.665265 1.0))
				      (data (channel->vct 0 20 ind 1)))
				  (vct-multiply! data e1)
				  (vct->channel data 0 20 ind 1))))
		       
		       (env-5 (lambda (ind)
				(env-channel '(0 1 1 .5 2 .5 3 1) 0 20 ind 0)
				(let ((e1 (vct 1.0 0.916667 0.833333 0.750000 0.666667 0.583333 0.5 0.5 0.5 
					       0.5 0.5 0.5 0.5 0.5 0.583333 0.666667 0.750000 0.833333 0.916667 1.0))
				      (data (channel->vct 0 20 ind 1)))
				  (vct-multiply! data e1)
				  (vct->channel data 0 20 ind 1))))
		       
		       (env-6 (lambda (ind)
				(env-channel-with-base '(0 1 1 .5 2 .5 3 1) 8.0 0 20 ind 0)
				(let ((e1 (vct 1.0 0.832632 0.714286 0.630602 0.571429 0.529587 0.5 0.5 0.5 
					       0.5 0.5 0.5 0.5 0.5 0.529587 0.571429 0.630602 0.714286 0.832632 1.0))
				      (data (channel->vct 0 20 ind 1)))
				  (vct-multiply! data e1)
				  (vct->channel data 0 20 ind 1))))
		       
		       (set-1 (lambda (ind)
				(set! (sample 10 ind 0) -0.5)
				(let ((data (channel->vct 0 20 ind 1)))
				  (vct-set! data 10 -0.5)
				  (vct->channel data 0 20 ind 1))))
		       
		       (scl-1 (lambda (ind)
				(ptree-channel (lambda (y data forward)
						 (* y (vct-ref data 0)))
					       0 20 ind 0 #f #f
					       (lambda (pos dur)
						 (vct 0.625)))
				(scale-channel 0.625 0 20 ind 1)))
		       
		       (rvequal (lambda (ind name n)
				  (let ((r1 (make-sampler 19 ind 0 -1))
					(r2 (make-sampler 19 ind 1 -1))
					(v1 (make-vct 20))
					(v2 (make-vct 20)))
				    (do ((i 0 (+ 1 i)))
					((= i 20))
				      (vct-set! v1 i (r1))
				      (vct-set! v2 i (r2)))
				    (if (not (local-vequal v1 v2 n))
					(snd-display #__line__ ";!~A reversed: ~A ~A" name v1 v2))
				    (free-sampler r1)
				    (free-sampler r2)))))
		
		(let ((all-ops (list add-1 ramp-1 mix-1 env-1 env-2 env-3 env-4 env-5 env-6 set-1 scl-1))
		      (all-op-names (list 'add-1 'ramp-1 'mix-1 'env-1 'env-2 'env-3 'env-4 'env-5 'env-6 'set-1 'scl-1))
		      (two-ops (list add-1 ramp-1))
		      (two-op-names (list 'add-1 'ramp-1)))
		  
		  (let ((ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat)))
		    
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    (for-each ; check that they are the same
		     (lambda (op op-name)
		       (do ((k 0 (+ 1 k)))
			   ((= k 2))
			 (if (= k 1)
			     (vct->channel (make-vct 20 0.0) 0 20 ind 1)
			     (begin
			       (vct->channel (make-vct 20 1.0) 0 20 ind 0)
			       (vct->channel (make-vct 20 1.0) 0 20 ind 1)))
			 (op ind)
			 (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
			     (snd-display #__line__ ";unequal: ~A by ~A (~A, ~A, ~A):~%; ~A~%; ~A~%;  ~A~%;  ~A" 
					  op-name 
					  (vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) 
					  (mus-float-equal-fudge-factor) (mus-clipping) (mus-file-clipping ind)
					  (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 
					  (display-edits ind 0) (display-edits ind 1))
			     (rvequal ind op-name 1))
			 (revert-sound ind)))
		     all-ops all-op-names)
		    
		    (close-sound ind)
		    (set! ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat))
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    ;; 2 ops
		    (for-each
		     (lambda (op2 op2-name)
		       (for-each
			(lambda (op1 op1-name)
			  (let ((op-name (format #f "~A(~A)" op2-name op1-name)))
			    (do ((k 0 (+ 1 k)))
				((= k 2))
			      (if (= k 1)
				  (vct->channel (make-vct 20 0.0) 0 20 ind 1)
				  (begin
				    (vct->channel (make-vct 20 1.0) 0 20 ind 0)
				    (vct->channel (make-vct 20 1.0) 0 20 ind 1)))
			      (op1 ind)
			      (op2 ind)
			      (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
				  (snd-display #__line__ ";unequal: ~A~A by ~A (~A):~%; ~A~%; ~A~%;  ~A~%;  ~A"
					       op-name (if (= k 0) "[0]" "") 
					       (vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) (mus-float-equal-fudge-factor)
					       (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)
					       (display-edits ind 0) (display-edits ind 1))
				  (rvequal ind op-name 1))
			      (revert-sound ind))))
			all-ops all-op-names))
		     all-ops all-op-names)
		    
		    (close-sound ind)
		    (set! ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat))
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    ;; 3 ops
		    (for-each
		     (lambda (op3 op3-name)
		       (for-each
			(lambda (op2 op2-name)
			  (for-each
			   (lambda (op1 op1-name)
			     (let ((op-name (format #f "~A(~A(~A))" op3-name op2-name op1-name)))
			       (do ((k 0 (+ 1 k)))
				   ((= k 2))
				 (if (= k 1)
				     (vct->channel (make-vct 20 0.0) 0 20 ind 1)
				     (begin
				       (vct->channel (make-vct 20 1.0) 0 20 ind 0)
				       (vct->channel (make-vct 20 1.0) 0 20 ind 1)))
				 (op1 ind)
				 (op2 ind)
				 (op3 ind)
				 (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
				     (snd-display #__line__ ";unequal: ~A by ~A (~A):~%; ~A~%; ~A~%;  ~A~%;  ~A"
						  op-name 
						  (vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) (mus-float-equal-fudge-factor)
						  (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)
						  (display-edits ind 0) (display-edits ind 1))
				     (rvequal ind op-name 1))
				 (revert-sound ind))))
			   all-ops all-op-names))
			all-ops all-op-names))
		     all-ops all-op-names)
		    
		    (close-sound ind)
		    (set! ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat))
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    ;; 4 ops
		    (for-each
		     (lambda (op4 op4-name)
		       (for-each
			(lambda (op3 op3-name)
			  (for-each
			   (lambda (op2 op2-name)
			     (for-each
			      (lambda (op1 op1-name)
				(let ((op-name (format #f "~A(~A(~A(~A)))" op4-name op3-name op2-name op1-name)))
				  (do ((k 0 (+ 1 k)))
				      ((= k 2))
				    (if (= k 1)
					(vct->channel (make-vct 20 0.0) 0 20 ind 1)
					(begin
					  (vct->channel (make-vct 20 1.0) 0 20 ind 0)
					  (vct->channel (make-vct 20 1.0) 0 20 ind 1)))
				    (op1 ind)
				    (op2 ind)
				    (op3 ind)
				    (op4 ind)
				    (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
					(snd-display #__line__ ";unequal: ~A~A by ~A (~A):~%; ~A~%; ~A"
						     op-name (if (= k 0) "[0]" "") 
						     (vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) (mus-float-equal-fudge-factor)
						     (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1))
					(rvequal ind op-name 1))
				    (revert-sound ind))))
			      all-ops all-op-names))
			   all-ops all-op-names))
			all-ops all-op-names))
		     all-ops all-op-names)
		    
		    (close-sound ind)
		    (set! ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat))
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    ;; 5 ops
		    (for-each
		     (lambda (op5 op5-name)
		       (for-each
			(lambda (op4 op4-name)
			  (for-each
			   (lambda (op3 op3-name)
			     (for-each
			      (lambda (op2 op2-name)
				(for-each
				 (lambda (op1 op1-name)
				   (let ((op-name (format #f "~A(~A(~A(~A(~A))))" op5-name op4-name op3-name op2-name op1-name)))
				     (do ((k 0 (+ 1 k)))
					 ((= k 2))
				       (if (= k 1)
					   (vct->channel (make-vct 20 0.0) 0 20 ind 1)
					   (begin
					     (vct->channel (make-vct 20 1.0) 0 20 ind 0)
					     (vct->channel (make-vct 20 1.0) 0 20 ind 1)))
				       (op1 ind)
				       (op2 ind)
				       (op3 ind)
				       (op4 ind)
				       (op5 ind)
				       (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
					   (snd-display #__line__ ";unequal: ~A by ~A (~A),  ~A in ~A:~%; ~A~%; ~A" 
							op-name
							(vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) (mus-float-equal-fudge-factor) 
							(map (lambda (lst) (edit-fragment-type-name (list-ref lst 7))) (edit-tree ind 0))
							(edit-tree ind 0)
							(channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1))
					   (rvequal ind op-name 1))
				       (revert-sound ind))))
				 all-ops all-op-names))
			      all-ops all-op-names))
			   all-ops all-op-names))
			all-ops all-op-names))
		     all-ops all-op-names)
		    
		    (close-sound ind)
		    (set! ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat))
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    ;; 6 ops
		    (for-each
		     (lambda (op6 op6-name)
		       (for-each
			(lambda (op5 op5-name)
			  (for-each
			   (lambda (op4 op4-name)
			     (for-each
			      (lambda (op3 op3-name)
				(for-each
				 (lambda (op2 op2-name)
				   (for-each
				    (lambda (op1 op1-name)
				      (let ((op-name (format #f "~A(~A(~A(~A(~A(~A)))))" op6-name op5-name op4-name op3-name op2-name op1-name)))
					(do ((k 0 (+ 1 k)))
					    ((= k 2))
					  (if (= k 1)
					      (vct->channel (make-vct 20 0.0) 0 20 ind 1)
					      (begin
						(vct->channel (make-vct 20 1.0) 0 20 ind 0)
						(vct->channel (make-vct 20 1.0) 0 20 ind 1)))
					  (op1 ind)
					  (op2 ind)
					  (op3 ind)
					  (op4 ind)
					  (op5 ind)
					  (op6 ind)
					  (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
					      (snd-display #__line__ ";unequal: ~A by ~A (~A):~%; ~A~%; ~A" 
							   op-name 
							   (vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) (mus-float-equal-fudge-factor) 
							   (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1))
					      (rvequal ind op-name 1))
					  (revert-sound ind))))
				    two-ops two-op-names))
				 all-ops all-op-names))
			      all-ops all-op-names))
			   all-ops all-op-names))
			all-ops all-op-names))
		     two-ops two-op-names)
		    
		    (close-sound ind)
		    (set! ind (new-sound "test.snd" :size 20 :channels 2 :data-format mus-lfloat))
		    (set! (squelch-update ind 0) #t)
		    (set! (squelch-update ind 1) #t)
		    
		    ;; 7 ops
		    (for-each
		     (lambda (op7 op7-name)
		       (for-each
			(lambda (op6 op6-name)
			  (for-each
			   (lambda (op5 op5-name)
			     (for-each
			      (lambda (op4 op4-name)
				(for-each
				 (lambda (op3 op3-name)
				   (for-each
				    (lambda (op2 op2-name)
				      (for-each
				       (lambda (op1 op1-name)
					 (let ((op-name (format #f "~A(~A(~A(~A(~A(~A(~A))))))" op7-name op6-name op5-name op4-name op3-name op2-name op1-name)))
					   (do ((k 0 (+ 1 k)))
					       ((= k 2))
					     (if (= k 1)
						 (vct->channel (make-vct 20 0.0) 0 20 ind 1)
						 (begin
						   (vct->channel (make-vct 20 1.0) 0 20 ind 0)
						   (vct->channel (make-vct 20 1.0) 0 20 ind 1)))
					     (op1 ind)
					     (op2 ind)
					     (op3 ind)
					     (op4 ind)
					     (op5 ind)
					     (op6 ind)
					     (op7 ind)
					     (if (not (local-vequal (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1) 1))
						 (snd-display #__line__ ";unequal: ~A by ~A (~A):~%; ~A~%; ~A" 
							      op-name 
							      (vmaxdiff (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1)) (mus-float-equal-fudge-factor) 
							      (channel->vct 0 20 ind 0) (channel->vct 0 20 ind 1))
						 (rvequal ind op-name 1))
					     (revert-sound ind))))
				       two-ops two-op-names))
				    all-ops all-op-names))
				 all-ops all-op-names))
			      all-ops all-op-names))
			   two-ops two-op-names))
			two-ops two-op-names))
		     two-ops two-op-names)
		    
		    (set! (squelch-update ind 0) #f)
		    (set! (squelch-update ind 1) #f)
		    (set! (max-virtual-ptrees) old-ptrees)
		    
		    (if (and (provided? 'snd-motif)
			     (provided? 'xm))
			(let* ((edhist (list-ref (channel-widgets ind 0) 7))
			       (edp (XtParent edhist)))
			  (XtUnmanageChild edp) 
			  (XtVaSetValues edp (list XmNpaneMinimum 1))  ; not 0 here -- Xt warnings
			  (XtManageChild edp)))
		    
		    (close-sound ind)))
		)))))
    
    (let ((ind (open-sound "oboe.snd")))
      
      ;; simple cases
      
      (as-one-edit
       (lambda ()
	 (set! (sample 10) 1.0)))
      (if (fneq (sample 10) 1.0) (snd-display #__line__ ";as-one-edit 1: ~A" (sample 10)))
      (if (not (= (edit-position ind 0) 1)) 
	  (snd-display #__line__ ";as-one-edit 1 edpos: ~A" (edit-position ind 0))
	  (begin
	    (if (not (equal? (edit-fragment 1 ind 0) (list "set-sample 10 1.0000" "set" 10 1)))
		(snd-display #__line__ ";as-one-edit 1 edlist: ~A" (edit-fragment 1 ind 0)))
	    (if (not (equal? (edit-fragment 0 ind 0) (list #f "init" 0 50828)))
		(snd-display #__line__ ";as-one-edit 1 original edlist: ~A" (edit-fragment 0 ind 0)))))
      
      (revert-sound ind)
      (as-one-edit
       (lambda ()
	 (set! (sample 10) 1.0)
	 (map-channel (lambda (y) (* y 2.0)) 0 20 ind 0 #f "map-channel as-one-edit")
	 (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";as-one-edit 2 edpos internal: ~A" (edit-position ind 0))))
       "as-one-edit test-2")
      (if (fneq (sample 10) 2.0) (snd-display #__line__ ";as-one-edit 2: ~A" (sample 10)))
      (if (not (= (edit-position ind 0) 1)) 
	  (snd-display #__line__ ";as-one-edit 2 edpos: ~A" (edit-position ind 0))
	  (begin
	    (if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit test-2" "set" 0 21)))
		(snd-display #__line__ ";as-one-edit 2 edlist: ~A" (edit-fragment 1 ind 0)))
	    (if (not (equal? (edit-fragment 0 ind 0) (list #f "init" 0 50828)))
		(snd-display #__line__ ";as-one-edit 2 original edlist: ~A" (edit-fragment 0 ind 0)))))
      
      (revert-sound ind)
      (let ((ind2 (open-sound "2a.snd")))
	(set! (sample 1 ind2 0) 1.0)
	(set! (sample 2 ind2 1) 0.5)
	(set! (selected-sound) ind)
	
	(as-one-edit
	 (lambda ()
	   (set! (sample 10 ind 0) 1.0)))
	(if (fneq (sample 10 ind 0) 1.0) (snd-display #__line__ ";as-one-edit 3: ~A" (sample 10 ind 0)))
	(if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";as-one-edit 3 edpos: ~A" (edit-position ind 0)))
	(if (not (= (edit-position ind2 0) 1)) (snd-display #__line__ ";as-one-edit 3 2 edpos: ~A" (edit-position ind2 0)))
	(if (not (= (edit-position ind2 1) 1)) (snd-display #__line__ ";as-one-edit 3 2 1 edpos: ~A" (edit-position ind2 1)))
	(if (not (equal? (edit-fragment 1 ind 0) (list "set-sample 10 1.0000" "set" 10 1)))
	    (snd-display #__line__ ";as-one-edit 3 edlist: ~A" (edit-fragment 1 ind 0)))
	(if (not (equal? (edit-fragment 1 ind2 0) (list "set-sample 1 1.0000" "set" 1 1)))
	    (snd-display #__line__ ";as-one-edit 3 2 edlist: ~A" (edit-fragment 1 ind2 0)))
	(if (not (equal? (edit-fragment 1 ind2 1) (list "set-sample 2 0.5000" "set" 2 1)))
	    (snd-display #__line__ ";as-one-edit 3 2 1 edlist: ~A" (edit-fragment 1 ind2 1)))
	
	(revert-sound ind)
	
	(as-one-edit    
	 (lambda ()
	   (set! (sample 10 ind 0) 1.0)
	   (map-channel (lambda (y) (* y 2.0)) 0 20 ind 0 #f "map-channel as-one-edit 2")
	   (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";as-one-edit 4 edpos internal: ~A" (edit-position ind 0))))
	 "as-one-edit test-4")
	(if (fneq (sample 10) 2.0) (snd-display #__line__ ";as-one-edit 4: ~A" (sample 10 ind 0)))
	(if (not (= (edit-position ind 0) 1)) 
	    (snd-display #__line__ ";as-one-edit 4 edpos: ~A" (edit-position ind 0))
	    (if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit test-4" "set" 0 21)))
		(snd-display #__line__ ";as-one-edit 4 edlist: ~A" (edit-fragment 1 ind 0))))
	(if (not (equal? (edit-fragment 1 ind2 0) (list "set-sample 1 1.0000" "set" 1 1)))
	    (snd-display #__line__ ";as-one-edit 3 2 edlist: ~A" (edit-fragment 1 ind2 0)))
	(if (not (equal? (edit-fragment 1 ind2 1) (list "set-sample 2 0.5000" "set" 2 1)))
	    (snd-display #__line__ ";as-one-edit 3 2 1 edlist: ~A" (edit-fragment 1 ind2 1)))
	
	(revert-sound ind)
	(set! (sample 3 ind 0) 1.0)
	
	(as-one-edit
	 (lambda ()
	   (set! (sample 10 ind 0) 1.0)
	   (set! (sample 10 ind2 0) 0.5)
	   (set! (sample 10 ind2 1) 0.4)))
	(if (fneq (sample 3 ind 0) 1.0) (snd-display #__line__ ";as-one-edit 5 (3): ~A" (sample 3 ind 0)))
	(if (fneq (sample 10 ind 0) 1.0) (snd-display #__line__ ";as-one-edit 5 (10): ~A" (sample 10 ind 0)))
	(if (fneq (sample 10 ind2 0) 0.5) (snd-display #__line__ ";as-one-edit 5 (2 10): ~A" (sample 10 ind2 0)))
	(if (fneq (sample 10 ind2 1) 0.4) (snd-display #__line__ ";as-one-edit 5 (2 1 10): ~A" (sample 10 ind2 1)))
	(if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";as-one-edit 5 edpos: ~A" (edit-position ind 0)))
	(if (not (= (edit-position ind2 0) 2)) (snd-display #__line__ ";as-one-edit 5 2 edpos: ~A" (edit-position ind2 0)))
	(if (not (= (edit-position ind2 1) 2)) (snd-display #__line__ ";as-one-edit 5 2 1 edpos: ~A" (edit-position ind2 1)))
	
	(if (not (equal? (edit-fragment 2 ind 0) (list "set-sample 10 1.0000" "set" 10 1)))
	    (snd-display #__line__ ";as-one-edit 5 edlist 2: ~A" (edit-fragment 1 ind 0)))
	(if (not (equal? (edit-fragment 1 ind 0) (list "set-sample 3 1.0000" "set" 3 1)))
	    (snd-display #__line__ ";as-one-edit 5 edlist 1: ~A" (edit-fragment 1 ind 0)))
	(if (not (equal? (edit-fragment 0 ind 0) (list #f "init" 0 50828)))
	    (snd-display #__line__ ";as-one-edit 5 original edlist: ~A" (edit-fragment 0 ind 0)))
	(if (not (equal? (edit-fragment 2 ind2 0) (list "set-sample 10 0.5000" "set" 10 1)))
	    (snd-display #__line__ ";as-one-edit 5 edlist 2 1: ~A" (edit-fragment 1 ind2 0)))
	
	(as-one-edit
	 (lambda ()
	   (map-channel (lambda (y) (* y 2.0)) 0 20 ind 0 #f "map-channel as-one-edit 6")
	   (map-channel (lambda (y) (* y 2.0)) 0 20 ind2 1 #f "map-channel as-one-edit 6 2 1"))
	 "as-one-edit test-6")
	
	
	(if (fneq (sample 3 ind 0) 2.0) (snd-display #__line__ ";as-one-edit 6 (3): ~A" (sample 3 ind 0)))
	(if (fneq (sample 10 ind 0) 2.0) (snd-display #__line__ ";as-one-edit 6 (10): ~A" (sample 10 ind 0)))
	(if (fneq (sample 10 ind2 0) 0.5) (snd-display #__line__ ";as-one-edit 6 (2 10): ~A" (sample 10 ind2 0)))
	(if (fneq (sample 10 ind2 1) 0.8) (snd-display #__line__ ";as-one-edit 6 (2 1 10): ~A" (sample 10 ind2 1)))
	(if (not (= (edit-position ind 0) 3)) (snd-display #__line__ ";as-one-edit 6 edpos: ~A" (edit-position ind 0)))
	(if (not (= (edit-position ind2 0) 2)) (snd-display #__line__ ";as-one-edit 6 2 edpos: ~A" (edit-position ind2 0)))
	(if (not (= (edit-position ind2 1) 3)) (snd-display #__line__ ";as-one-edit 6 2 1 edpos: ~A" (edit-position ind2 1)))
	
	(if (not (equal? (edit-fragment 2 ind 0) (list "set-sample 10 1.0000" "set" 10 1)))
	    (snd-display #__line__ ";as-one-edit 5 edlist 2: ~A" (edit-fragment 1 ind 0)))
	(if (not (equal? (edit-fragment 2 ind2 0) (list "set-sample 10 0.5000" "set" 10 1)))
	    (snd-display #__line__ ";as-one-edit 5 edlist 2 1: ~A" (edit-fragment 1 ind2 0)))
	(if (not (equal? (edit-fragment 3 ind 0) (list "as-one-edit test-6" "set" 0 20)))
	    (snd-display #__line__ ";as-one-edit 6 edlist: ~A" (edit-fragment 1 ind 0)))
	(if (not (equal? (edit-fragment 3 ind2 1) (list "as-one-edit test-6" "set" 0 20)))
	    (snd-display #__line__ ";as-one-edit 6 edlist 2 1: ~A" (edit-fragment 1 ind2 1)))
	(close-sound ind2))
      
      ;; nested cases
      (revert-sound ind)
      
      (as-one-edit
       (lambda ()
	 (set! (sample 100) .9)
	 (as-one-edit
	  (lambda ()
	    (set! (sample 200) .8)
	    (set! (sample 300) .7)))
	 (set! (sample 300) .6)))
      (if (or (fneq (sample 100) .9)
	      (fneq (sample 200) .8)
	      (fneq (sample 300) .6))
	  (snd-display #__line__ ";nested as-one-edit 7: ~A ~A ~A" (sample 100) (sample 200) (sample 300)))
      (if (not (= (edit-position ind 0) 1))
	  (snd-display #__line__ ";nested as-one-edit 7 edpos: ~A" (edit-position ind 0)))
      (if (squelch-update ind 0)
	  (begin
	    (snd-display #__line__ ";nested as-one-edit 7 squelch is on")
	    (set! (squelch-update) #f)))
      (if (not (equal? (edit-fragment 1 ind 0) (list "set-sample 300 0.6000" "set" 100 204)))
	  (snd-display #__line__ ";as-one-edit 7 edlist: ~A" (edit-fragment 1 ind 0)))
      
      (revert-sound ind)
      (as-one-edit
       (lambda ()
	 (set! (sample 100) .9)
	 (as-one-edit
	  (lambda ()
	    (set! (sample 200) .8)
	    (set! (sample 300) .7)))
	 (set! (sample 300) .6))
       "as-one-edit test-8")
      (if (or (fneq (sample 100) .9)
	      (fneq (sample 200) .8)
	      (fneq (sample 300) .6))
	  (snd-display #__line__ ";nested as-one-edit 8: ~A ~A ~A" (sample 100) (sample 200) (sample 300)))
      (if (not (= (edit-position ind 0) 1))
	  (snd-display #__line__ ";nested as-one-edit 8 edpos: ~A" (edit-position ind 0)))
      (if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit test-8" "set" 100 204)))
	  (snd-display #__line__ ";as-one-edit 8 edlist: ~A" (edit-fragment 1 ind 0)))
      
      (revert-sound ind)
      (as-one-edit
       (lambda ()
	 (set! (sample 100) .9)
	 (as-one-edit
	  (lambda ()
	    (set! (sample 200) .8)
	    (set! (sample 300) .7))
	  "as-one-edit 9 internal")
	 (set! (sample 300) .6))
       "as-one-edit test-9")
      (if (or (fneq (sample 100) .9)
	      (fneq (sample 200) .8)
	      (fneq (sample 300) .6))
	  (snd-display #__line__ ";nested as-one-edit 9: ~A ~A ~A" (sample 100) (sample 200) (sample 300)))
      (if (not (= (edit-position ind 0) 1))
	  (snd-display #__line__ ";nested as-one-edit 9 edpos: ~A" (edit-position ind 0)))
      (if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit test-9" "set" 100 204)))
	  (snd-display #__line__ ";as-one-edit 9 edlist: ~A" (edit-fragment 1 ind 0)))
      
      (revert-sound ind)
      (as-one-edit
       (lambda ()
	 (set! (sample 100) .9)
	 (as-one-edit
	  (lambda ()
	    (set! (sample 200) .8)
	    (as-one-edit
	     (lambda ()
	       (set! (sample 400) .3))
	     "not a name")
	    (set! (sample 300) .7))
	  "as-one-edit 10 internal")
	 (set! (sample 300) .6))
       "as-one-edit test-10")
      (if (or (fneq (sample 100) .9)
	      (fneq (sample 200) .8)
	      (fneq (sample 300) .6)
	      (fneq (sample 400) .3))
	  (snd-display #__line__ ";nested as-one-edit 10: ~A ~A ~A ~A" (sample 100) (sample 200) (sample 300) (sample 400)))
      (if (not (= (edit-position ind 0) 1))
	  (snd-display #__line__ ";nested as-one-edit 10 edpos: ~A" (edit-position ind 0)))
      (if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit test-10" "set" 100 305)))
	  (snd-display #__line__ ";as-one-edit 10 edlist: ~A" (edit-fragment 1 ind 0)))
      
      ;; try implicit as-one-edits nested
      (revert-sound ind)
      (env-channel-with-base '(0 0 1 1 2 .5 3 .25 4 0) 0.0 0 #f ind 0)
      (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";as-one-edit 11 edpos: ~A" (edit-position ind 0)))
      (if (not (equal? (edit-fragment 1 ind 0) 
		       (list "env-channel-with-base '(0.000 0.000 1.000 1.000 2.000 0.500 3.000 0.250 4.000 0.000) 0.0000 0 #f" "scale" 0 50830)))
	  (snd-display #__line__ ";as-one-edit 11: ~A" (edit-fragment 1 ind 0)))
      
      (revert-sound ind)
      (as-one-edit
       (lambda ()
	 (env-channel-with-base '(0 0 1 1 2 .5 3 .25 4 0) 0.0 0 #f ind 0))
       "as-one-edit 12")
      (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";as-one-edit 12 edpos: ~A" (edit-position ind 0)))
      (if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit 12" "scale" 0 50830)))
	  (snd-display #__line__ ";as-one-edit 12: ~A" (edit-fragment 1 ind 0)))
      
      (revert-sound ind)
      (let ((m1 #f)
	    (m2 #f)
	    (m3 #f)
	    (m4 #f))
	(as-one-edit
	 (lambda ()
	   (set! m1 (add-mark 1234 ind 0))
	   (set! (sample 1236 ind 0) .6)
	   (as-one-edit
	    (lambda ()
	      (set! (sample 123 ind 0) .3)
	      (set! m2 (add-mark 1235 ind 0)))
	    "as-one-edit inner 1")
	   (if (not (mark? m1)) (snd-display #__line__ ";as-one-edit stepped on m1: ~A" m1))
	   (if (not (mark? m2)) (snd-display #__line__ ";as-one-edit stepped on m2: ~A" m2))
	   (as-one-edit
	    (lambda ()
	      (set! m3 (add-mark 1238 ind 0))
	      (set! (sample 1238 ind 0) .8))
	    "as-one-edit inner 2")
	   (set! (sample 1239 ind 0) .9)
	   (set! m4 (add-mark 1237 ind 0)))
	 "outer as-one-edit")
	(if (not (mark? m1)) (snd-display #__line__ ";2nd as-one-edit stepped on m1: ~A" m1))
	(if (not (mark? m2)) (snd-display #__line__ ";2nd as-one-edit stepped on m2: ~A" m2))
	(if (not (mark? m3)) (snd-display #__line__ ";2nd as-one-edit stepped on m3: ~A" m3))
	(if (not (mark? m4)) (snd-display #__line__ ";2nd as-one-edit stepped on m4: ~A" m4))
	(if (not (= (mark-sample m1) 1234)) (snd-display #__line__ ";as-one-edit m1 sample: ~A (1234)" (mark-sample m1)))
	(if (not (= (mark-sample m2) 1235)) (snd-display #__line__ ";as-one-edit m2 sample: ~A (1235)" (mark-sample m2)))
	(if (not (= (mark-sample m3) 1238)) (snd-display #__line__ ";as-one-edit m3 sample: ~A (1238)" (mark-sample m3)))
	(if (not (= (mark-sample m4) 1237)) (snd-display #__line__ ";as-one-edit m4 sample: ~A (1237)" (mark-sample m4)))
	(if (not (string=? (display-edits ind 0) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (set 123 1120) ; outer as-one-edit [1:9]:
   (at 0, cp->sounds[0][0:122, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 123, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 124, cp->sounds[0][124:1235, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 1236, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 1237, cp->sounds[0][1237:1237, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 1238, cp->sounds[3][0:0, 1.000]) [buf: 1] 
   (at 1239, cp->sounds[4][0:0, 1.000]) [buf: 1] 
   (at 1240, cp->sounds[0][1240:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
")))
	    (snd-display #__line__ ";as-one-edit edits: ~A" (display-edits ind 0)))
	
	(revert-sound ind))
      
      (let ((m1 #f)
	    (m2 #f)
	    (m3 #f)
	    (m4 #f))
	(as-one-edit
	 (lambda ()
	   (set! m1 (mix-vct (vct .1 .2 .3) 1234 ind 0))
	   (set! (sample 1236 ind 0) .6)
	   (as-one-edit
	    (lambda ()
	      (set! (sample 123 ind 0) .3)
	      (set! m2 (mix-vct (vct .1 .2 .3) 1235 ind 0)))
	    "as-one-edit inner 1")
	   (if (not (mix? m1)) (snd-display #__line__ ";as-one-edit stepped on m1: ~A" m1))
	   (if (not (mix? m2)) (snd-display #__line__ ";as-one-edit stepped on m2: ~A" m2))
	   (as-one-edit
	    (lambda ()
	      (set! m3 (mix-vct (vct .1 .2 .3) 1238 ind 0))
	      (set! (sample 1238 ind 0) .8))
	    "as-one-edit inner 2")
	   (set! (sample 1239 ind 0) .9)
	   (set! m4 (mix-vct (vct .1 .2 .3) 1237 ind 0)))
	 "outer as-one-edit")
	(if (not (mix? m1)) (snd-display #__line__ ";2nd as-one-edit stepped on mx1: ~A" m1))
	(if (not (mix? m2)) (snd-display #__line__ ";2nd as-one-edit stepped on mx2: ~A" m2))
	(if (not (mix? m3)) (snd-display #__line__ ";2nd as-one-edit stepped on mx3: ~A" m3))
	(if (not (mix? m4)) (snd-display #__line__ ";2nd as-one-edit stepped on mx4: ~A" m4))
	(revert-sound ind))
      
      (let ((ind2 #f))
	(as-one-edit
	 (lambda ()
	   (set! ind2 (open-sound "pistol.snd"))
	   (set! (sample 100 ind 0) .5)
	   (set! (sample 200 ind2 0) .6))
	 "as-one-edit+open")
	(if (not (sound? ind2)) (snd-display #__line__ ";as-one-edit didn't open sound? ~A ~A" ind2 (sounds)))
	(if (not (= (edit-position ind2 0) 1)) (snd-display #__line__ ";edpos as-one-edit opened sound: ~A" (edit-position ind2 0)))
	(if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";edpos as-one-edit original sound: ~A" (edit-position ind 0)))
	(if (not (equal? (edit-fragment 1 ind 0) (list "as-one-edit+open" "set" 100 1)))
	    (snd-display #__line__ ";as-one-edit open sound edlist orig: ~A" (edit-fragment 1 ind 0)))
	(if (not (equal? (edit-fragment 1 ind2 0) (list "set-sample 200 0.6000" "set" 200 1)))
	    (snd-display #__line__ ";as-one-edit open sound edlist new: ~A" (edit-fragment 1 ind2 0)))
	
	(as-one-edit
	 (lambda ()
	   (set! (sample 200 ind 0) .7)
	   (close-sound ind2))
	 "as-one-edit+close")
	(if (sound? ind2) 
	    (begin
	      (snd-display #__line__ ";as-one-edit didn't close sound? ~A ~A" ind2 (sounds))
	      (close-sound ind2)))
	(if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";edpos as-one-edit close original sound: ~A" (edit-position ind 0)))
	(if (not (string=? (display-edits ind 0) (string-append "
EDITS: 2

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (set 100 1) ; as-one-edit+open [1:4]:
   (at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 101, cp->sounds[0][101:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (set 200 1) ; as-one-edit+close [2:6]:
   (at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 101, cp->sounds[0][101:199, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 200, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 201, cp->sounds[0][201:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
")))
	    (snd-display #__line__ ";as-one-edit open+close: ~A" (display-edits ind 0))))
      
      (close-sound ind))  
    
    (let ((ind1 (open-sound "oboe.snd"))
	  (ind2 #f))
      (as-one-edit 
       (lambda ()
	 (set! (sample 100 ind1 0) .5)
	 (set! ind2 (open-sound "pistol.snd"))
	 (as-one-edit
	  (lambda ()
	    (set! (sample 200 ind2 0) .5)
	    (close-sound ind1))
	  "inner edit")
	 (set! (sample 300 ind2 0) .6))
       "outer edit")
      (if (sound? ind1) (snd-display #__line__ ";as-one-edit close inner: ~A ~A" ind1 (sounds)))
      (if (not (sound? ind2)) (snd-display #__line__ ";as-one-edit open inner: ~A ~A" ind2 (sounds)))
      
      (revert-sound ind2)
      (as-one-edit
       (lambda ()
	 (set! ind1 (open-sound "oboe.snd"))
	 (as-one-edit
	  (lambda ()
	    (set! (sample 200 ind1 0) .5))
	  "inner edit")
	 (set! (sample 100 ind2 0) .4))
       "outer edit")
      (close-sound ind1)
      (close-sound ind2))
    
    (let* ((ind (open-sound "oboe.snd"))
	   (mx (maxamp ind 0)))
      (as-one-edit
       (lambda ()
	 (ptree-channel (lambda (y) (* y 2)))
	 (env-sound '(0 0 1 1))))
      (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";as-one-edit env+ptree pos: ~A" (edit-position ind 0)))
      (if (fneq (maxamp ind 0) .1825) (snd-display #__line__ ";as-one-edit env+ptree max: ~A" (maxamp ind 0)))
      (undo)
      (let ((tag (catch #t
			(lambda () (as-one-edit (lambda (oops) #f)))
			(lambda args (car args)))))
	(if (not (eq? tag 'bad-arity))
	    (snd-display #__line__ ";as-one-edit arg? ~A" tag)))
      (let ((tag (catch #t
			(lambda () (as-one-edit (lambda* (oops) #f)))
			(lambda args (car args)))))
	(if (not (eq? tag 'bad-arity))
	    (snd-display #__line__ ";as-one-edit arg? ~A" tag)))
      (as-one-edit
       (lambda ()
	 (ptree-channel (lambda (y) (* y 2)))
	 (ptree-channel (lambda (y) (* y 2)))))
      (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";as-one-edit ptree+ptree pos: ~A" (edit-position ind 0)))
      (if (fneq (maxamp ind 0) (* 4 mx)) (snd-display #__line__ ";as-one-edit ptree+ptree max: ~A ~A" (maxamp ind 0) (* 4 mx)))
      (close-sound ind))
    (let ((ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "ptree tests" 10)))
      ;; offset-channel
      (offset-channel .1)
      (if (not (vequal (channel->vct 0 10) (make-vct 10 .1)))
	  (snd-display #__line__ ";offset-channel (.1): ~A" (channel->vct 0 10)))
      (offset-channel -.2 5 5)
      (if (not (vequal (channel->vct 0 10) (vct .1 .1 .1 .1 .1 -.1 -.1 -.1 -.1 -.1)))
	  (snd-display #__line__ ";offset-channel (-.1): ~A" (channel->vct 0 10)))
      (undo)
      (offset-channel .9 0 10 ind 0)
      (if (not (vequal (channel->vct 0 10) (make-vct 10 1.0)))
	  (snd-display #__line__ ";offset-channel (1): ~A" (channel->vct 0 10)))
      ;; sine-env and sine-ramp...
      (revert-sound ind)
      (map-channel (lambda (y) 1.0))
      (sine-ramp 0.0 1.0)
      (if (not (vequal (channel->vct) (vct 0.000 0.024 0.095 0.206 0.345 0.500 0.655 0.794 0.905 0.976)))
	  (snd-display #__line__ ";sine-ramp 0 1: ~A" (channel->vct)))
      (revert-sound ind)
      (offset-channel 1.0)
      (sine-ramp 1.0 0.0)
      (if (not (vequal (channel->vct) (vct 1.000 0.976 0.905 0.794 0.655 0.500 0.345 0.206 0.095 0.024)))
	  (snd-display #__line__ ";sine-ramp 1 0: ~A" (channel->vct)))
      (if (> (optimization) 0)
	  (if (not (string=? (edit-fragment-type-name (list-ref (car (edit-tree)) 7)) "ed_ptree_zero"))
	      (snd-display #__line__ ";sine-ramp tree op: ~A ~A" (edit-fragment-type-name (list-ref (car (edit-tree)) 7)) (edit-tree))))
      (close-sound ind)
      (set! ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "sine-env tests" 100))
      (map-channel (lambda (y) 1.0))
      (sine-env-channel '(0 0 1 1 2 -.5 3 1))
      (if (or (not (vequal (channel->vct 20 10) (vct 0.664 0.708 0.750 0.790 0.827 0.862 0.893 0.921 0.944 0.964)))
	      (not (vequal (channel->vct 60 10) (vct -0.381 -0.417 -0.446 -0.470 -0.486 -0.497 -0.500 -0.497 -0.486 -0.470))))
	  (snd-display #__line__ ";sine-env-channel 0: ~A ~A" (channel->vct 20 10) (channel->vct 60 10)))
      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";as-one-edit sine-env-channel: ~A" (edit-position ind 0)))
      (revert-sound ind)
      (offset-channel -1.0)
      (sine-env-channel '(0 0 1 1 2 1 3 0) 40 20)
      (if (or (not (vequal (channel->vct 40 20) (vct -0.000 -0.050 -0.188 -0.389 -0.611 -0.812 -0.950 -1.000 -1.000 -1.000
						     -1.000 -1.000 -1.000 -1.000 -1.000 -0.950 -0.812 -0.611 -0.389 -0.188)))
	      (not (vequal (channel->vct 30 10) (make-vct 10 -1.0))))
	  (snd-display #__line__ ";off+sine-env: ~A ~A" (channel->vct 40 20) (channel->vct 30 10)))
      (revert-sound ind)
      (ptree-channel (lambda (y d f) (* y 2)) 0 (frames) ind 0 #f #f (lambda (p d) (vct 1.0)))
      (revert-sound ind)
      (scale-by 0.0)
      (dither-channel)
      (let ((mx (maxamp)))
	(if (or (< mx .00003) (> mx .0001))
	    (snd-display #__line__ ";dithering: ~A" mx)))
      (revert-sound ind)
      (map-channel (ring-mod 10 (list 0 0 1 (hz->radians 100))))
      (osc-formants .99 (vct 400.0 800.0 1200.0) (vct 400.0 800.0 1200.0) (vct 4.0 2.0 3.0))
      (map-channel (zecho .5 .75 6 10.0))
      (map-channel (flecho .5 .9))
      (filtered-env '(0 0 1 1 2 0))
      (map-channel (formant-filter .99 2400))
      (map-channel (comb-filter .8 32))
      (map-channel (zcomb .8 32 '(0 0 1 10)))
      (map-channel (notch-filter .8 32))
      (let ((ind1 (open-sound "now.snd")))
	(select-sound ind1)
	(if (fneq (maxamp) .309) (snd-display #__line__ ";squelch-vowels init: ~A" (maxamp)))
	(squelch-vowels)
	(if (fneq (maxamp) .047) (snd-display #__line__ ";squelch-vowels maxamp: ~A" (maxamp)))
	(select-sound ind)
	(map-channel (cross-synthesis ind1 .5 128 6.0))
	(revert-sound ind1)
	(fft-edit 40 8000)
	(fft-squelch .1)
	(close-sound ind)
	(revert-sound ind1)
	(scramble-channel .01)
	(revert-sound ind1)
	(close-sound ind1)))
    
    (let ((ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "special env tests" 100)))
      (map-channel (lambda (y) 1.0))
      
      (blackman4-ramp 0.0 1.0)
      (let ((vals (channel->vct)))
	(undo)
	(blackman4-env-channel '(0 0 1 1))
	(let ((new-vals (channel->vct)))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";blackman4-env-channel/ramp: ~A ~A" vals new-vals))
	  (undo)
	  (blackman4-ramp 0.0 1.0 0 50)
	  (set! vals (channel->vct))
	  (undo)
	  (blackman4-env-channel '(0 0 1 1 2 1))
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";blackman4-env-channel/ramp 1: ~A ~A" vals new-vals))
	  (undo)
	  (blackman4-env-channel '(0 0 1 1 2 -.5 3 0))
	  (if (not (vequal (channel->vct 60 10) (vct -0.109 -0.217 -0.313 -0.392 -0.451 -0.488 -0.499 -0.499 -0.499 -0.499)))
	      (snd-display #__line__ ";blackman4 to -.5: ~A" (channel->vct 60 10)))
	  (undo)
	  
	  (ramp-squared 0.0 1.0)
	  (set! vals (channel->vct))
	  (undo)
	  (env-squared-channel '(0 0 1 1))
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-squared/ramp: ~A ~A" vals new-vals))
	  (undo)
	  (ramp-squared 0.0 1.0 #t 0 50)
	  (set! vals (channel->vct))
	  (undo)
	  (env-squared-channel '(0 0 1 1 2 1))
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-squared/ramp 1: ~A ~A" vals new-vals))
	  (undo)
	  (env-squared-channel '(0 0 1 1 2 -.5 3 0))
	  (if (not (vequal (channel->vct 60 10) (vct -0.450 -0.466 -0.478 -0.488 -0.494 -0.499 -0.500 -0.500 -0.498 -0.496)))
	      (snd-display #__line__ ";env-squared to -.5: ~A" (channel->vct 60 10)))
	  (undo)
	  (env-squared-channel '(0 0 1 1 2 -.5 3 0) #f)
	  (if (not (vequal (channel->vct 60 10) (vct -0.004 -0.080 -0.158 -0.240 -0.324 -0.410 -0.500 -0.500 -0.498 -0.496)))
	      (snd-display #__line__ ";env-squared unsymmetric to -.5: ~A" (channel->vct 60 10)))
	  (undo)
	  
	  (ramp-squared 0.0 1.0)
	  (set! vals (channel->vct))
	  (undo)
	  (env-expt-channel '(0 0 1 1) 2)
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-expt2/ramp: ~A ~A" vals new-vals))
	  (undo)
	  (env-squared-channel '(0 0 1 1 2 -.5 3 0))
	  (set! vals (channel->vct))
	  (undo)
	  (env-expt-channel '(0 0 1 1 2 -.5 3 0) 2.0)
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-expt2/env-squared: ~A ~A" vals new-vals))
	  (undo)
	  (env-squared-channel '(0 0 1 1 2 -.5 3 0) #f)
	  (set! vals (channel->vct))
	  (undo)
	  (env-expt-channel '(0 0 1 1 2 -.5 3 0) 2.0 #f)
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-expt2/env-squared unsymmetric: ~A ~A" vals new-vals))
	  (undo)
	  
	  (ramp-expt 0.0 1.0 32.0)
	  (set! vals (channel->vct))
	  (undo)
	  (env-expt-channel '(0 0 1 1) 32.0)
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-expt/ramp 32: ~A ~A" vals new-vals))
	  (undo)
	  (ramp-expt 0.0 1.0 32.0 #f 0 50)
	  (set! vals (channel->vct))
	  (undo)
	  (env-expt-channel '(0 0 1 1 2 1) 32.0)
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-expt/ramp 1 32: ~A ~A" vals new-vals))
	  (undo)
	  (ramp-expt 0.0 1.0 .1)
	  (set! vals (channel->vct))
	  (undo)
	  (env-expt-channel '(0 0 1 1) .1)
	  (set! new-vals (channel->vct))
	  (if (not (vequal vals new-vals))
	      (snd-display #__line__ ";env-expt/ramp .1: ~A ~A" vals new-vals))
	  (undo)
	  
	  (env-expt-channel '(0 0 1 1 2 -.5 3 0) 12.0)
	  (if (not (vequal (channel->vct 30 10) (vct 0.319 0.472 0.691 1.000 0.537 0.208 -0.022 -0.182 -0.291 -0.365)))
	      (snd-display #__line__ ";env-expt to -.5 12.0: ~A" (channel->vct 30 10)))
	  (undo)
	  (env-expt-channel '(0 0 1 1 2 -.5 3 0) 12.0 #f)
	  (if (not (vequal (channel->vct 30 10) (vct 0.319 0.472 0.691 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
	      (snd-display #__line__ ";env-expt to -.5 12.0 unsymmetric: ~A" (channel->vct 30 10)))
	  (undo)
	  (close-sound ind))))
    
    (let ((ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "3rd ramp re-order tests" 101)))
      (offset-channel 1.0)
      (env-sound '(0 0 1 1))
      (contrast-channel 1.0)
      (let ((reader (make-sampler 0))
	    (happy #t))
	(do ((i 0 (+ 1 i))
	     (val 0.0 (+ val .01)))
	    ((or (not happy) (= i 100)))
	  (let ((y (reader))
		(ny (sin (+ (* val 0.5 pi) (* 1.0 (sin (* val 2.0 pi)))))))
	    (if (fneq y ny)
		(begin
		  (snd-display #__line__ ";contrast-channel: ~A ~A ~A" val y ny)
		  (set! happy #f))))))
      (undo)
      (compand-channel)
      (let ((reader (make-sampler 0))
	    (happy #t))
	(do ((i 0 (+ 1 i))
	     (val 0.0 (+ val .01)))
	    ((or (not happy) (= i 100)))
	  (let ((y (reader))
		(ny (array-interp compand-table (+ 8.0 (* 8.0 val)) 17)))
	    (if (fneq y ny)
		(begin
		  (snd-display #__line__ ";compand-channel: ~A ~A ~A" val y ny)
		  (set! happy #f))))))
      (undo 2)
      (ring-modulate-channel 1000)
      (let ((reader (make-sampler 0))
	    (incr (/ (* 2 pi 1000) (srate)))
	    (happy #t))
	(do ((i 0 (+ 1 i))
	     (val 0.0 (+ val incr)))
	    ((or (not happy) (= i 100)))
	  (let ((y (reader))
		(ny (sin val)))
	    (if (fneq y ny)
		(begin
		  (snd-display #__line__ ";ring-modulate-channel: ~A ~A ~A" val y ny)
		  (set! happy #f))))))
      (undo)
      (env-sound '(0 0 1 1))
      (smooth-channel-via-ptree)
      (let ((reader (make-sampler 0))
	    (incr (/ pi 101))
	    (happy #t))
	(do ((i 0 (+ 1 i))
	     (val pi (+ val incr)))
	    ((or (not happy) (= i 100)))
	  (let ((y (reader))
		(ny (+ 0.5 (* 0.5 (cos val)))))
	    (if (fneq y ny)
		(begin
		  (snd-display #__line__ ";smooth-channel-via-ptree: ~A ~A ~A" val y ny)
		  (set! happy #f))))))
      (undo 2)
      (env-channel '(0 1 1 0 2 1) 10 11)
      (if (not (vequal (channel->vct 0 30) (vct 1 1 1 1 1 1 1 1 1 1 1.000 0.800 0.600 0.400 0.200 0.000 0.200 0.400 0.600 0.800 1 1 1 1 1 1 1 1 1 1)))
	  (snd-display #__line__ ";env+ptree: ~A ~A ~A" (channel->vct 0 10) (channel->vct 10 10) (channel->vct 20 10)))
      (close-sound ind))
    
    (let ((ind0 (open-sound "oboe.snd"))
	  (ind1 (open-sound "pistol.snd")))
      
      (let ((clip (channel-clipped? ind0 0)))
	(if clip (snd-display #__line__ ";channel-clipped? oboe.snd -> ~A" clip)))
      (scale-to 1.5 ind0 0)
      (let ((clip (channel-clipped? ind0 0)))
	(if (not (equal? clip (list #t 4503))) (snd-display #__line__ ";channel-clipped after scale: ~A" clip)))
      (revert-sound ind0)
      
      (ramp-channel 0.0 1.0 0 #f ind1 0)
      (ramp-channel 0.0 1.0 0 #f ind1 0)
      (ramp-channel 0.0 1.0 0 #f ind1 0)
      (ramp-channel 0.0 1.0 0 #f ind1 0)
      (make-selection 1000 2000 ind1 0)
      (set! (sync ind0) 1)
      (set! (selected-sound) ind0)
      (env-selection '(0 0 1 1))
      (if (or (not (= (edit-position ind0 0) 0))
	      (not (= (edit-position ind1 0) 5)))
	  (snd-display #__line__ ";selection override of sync field: ~A ~A" (edit-position ind0 0) (edit-position ind1 0)))
      (env-sound '(0 0 1 1 2 0))
      (if (or (not (= (edit-position ind0 0) 1))
	      (not (= (edit-position ind1 0) 5)))
	  (snd-display #__line__ ";sync field over selection: ~A ~A" (edit-position ind0 0) (edit-position ind1 0)))
      
      (close-sound ind1)
      (revert-sound ind0)
      (let ((val (sample 1990)))
	(delay-channel 10)
	(if (fneq (sample 2000) val) (snd-display #__line__ ";delay-channel: ~A ~A" val (sample 2000))))
      (close-sound ind0))
    
    (let ((ind (new-sound "test.snd" :size 20)))
      
      (vct->channel (make-vct 20 1.0))
      (ramp-channel 0 1)
      (env-sound '(0 1 1 .5 2 .5 3 1) 0 20 .6)
      (let ((data (channel->vct)))
	(if (not (vequal data (vct 0.000 0.049 0.091 0.123 0.146 0.158 0.158 0.184 0.211 0.237 0.263 0.289 0.316 0.342 0.444 0.549 0.658 0.770 0.884 1.000)))
	    (snd-display #__line__ ";env-sound xramp with flat segment: ~A" data)))
      (ptree-channel (lambda (y) (+ y .5)))
      (xramp-channel .1 .2 32.0)
      (let ((data (channel->vct)))
	(if (not (vequal data (vct 0.050 0.055 0.060 0.064 0.067 0.069 0.070 0.074 0.079 0.084 0.089 0.095 0.102 0.111 0.130 0.154 0.181 0.214 0.253 0.300)))
	    (snd-display #__line__ ";ramp->xramp->ptree->xramp: ~A" data)))
      
      (set! (edit-position) 1)
      (ramp-channel 0 1)
      (env-sound '(0 1 1 0.0 2 0.0 3 1) 0 20 .6)
      (ptree-channel (lambda (y) (+ y .5)))
      (xramp-channel .1 .2 32.0)
      (let ((data (channel->vct)))
	(if (not (vequal data (vct 0.050 0.055 0.058 0.060 0.060 0.058 0.053 0.054 0.055 0.057 0.058 0.060 0.063 0.066 0.090 0.119 0.153 0.193 0.241 0.300)))
	    (snd-display #__line__ ";1 ramp->xramp->ptree->xramp: ~A" data)))
      
      (set! (edit-position) 1)
      (env-sound '(0 1 1 0.5 2 0.5 3 1) 0 20 .6)
      (env-sound '(0 1 1 0 2 0 3 1) 0 20)
      (ptree-channel (lambda (y) (+ y .5)))
      (xramp-channel .1 .2 32.0)
      (let ((data (channel->vct)))
	(if (not (vequal data (vct 0.150 0.129 0.109 0.091 0.076 0.063 0.053 0.054 0.055 0.057 0.058 0.060 0.063 0.066 0.083 0.107 0.139 0.181 0.234 0.300)))
	    (snd-display #__line__ ";2 ramp->xramp->ptree->xramp: ~A" data)))
      
      (close-sound ind))
    
    (let ((s1 (open-sound "oboe.snd")))
      (let ((s2 (copy s1)))
	(if (not (sound? s2))
	    (snd-display #__line__ ";copy sound oboe -> ~A" s2)
	    (begin
	      (if (not (= (srate s1) (srate s2))) (snd-display #__line__ ";copy sounds srates: ~A ~A" (srate s1) (srate s2)))
	      (if (not (= (frames s1) (frames s2))) (snd-display #__line__ ";copy sounds frames: ~A ~A" (frames s1) (frames s2)))
	      (if (not (= (chans s1) (chans s2) 1)) (snd-display #__line__ ";copy sounds chans: ~A ~A" (chans s1) (chans s2)))
	      (let ((r1 (make-sampler 0 s1))
		    (r2 (make-sampler 0 s2))
		    (happy #t))
		(do ((i 0 (+ i 1)))
		    ((or (not happy)
			 (= i (frames s1))))
		  (let ((v1 (r1))
			(v2 (r2)))
		    (if (> (abs (- v1 v2)) .0001)
			(begin
			  (set! happy #f)
			  (snd-display #__line__ ";copied sound not equal? pos: ~A, ~A ~A" i v1 v2))))))
	      (close-sound s2))))
      (fill! s1 0.0)
      (if (fneq (maxamp s1) 0.0) (snd-display #__line__ ";fill 1 with 0: ~A" (maxamp s1)))
      (fill! s1 0.3)
      (if (fneq (maxamp s1) 0.3) (snd-display #__line__ ";fill 1 with 0.3: ~A" (maxamp s1)))
      (close-sound s1))
    
    (let ((s1 (open-sound "2a.snd")))
      (let ((s2 (copy s1)))
	(if (not (sound? s2))
	    (snd-display #__line__ ";copy sound 2a -> ~A" s2)
	    (begin
	      (if (not (= (srate s1) (srate s2))) (snd-display #__line__ ";copy sounds srates 2: ~A ~A" (srate s1) (srate s2)))
	      (if (not (= (frames s1) (frames s2))) (snd-display #__line__ ";copy sounds frames 2: ~A ~A" (frames s1) (frames s2)))
	      (if (not (= (chans s1) (chans s2) 2)) (snd-display #__line__ ";copy sounds chans 2: ~A ~A" (chans s1) (chans s2)))
	      (let ((r10 (make-sampler 0 s1 0))
		    (r11 (make-sampler 0 s1 1))
		    (r20 (make-sampler 0 s2 0))
		    (r21 (make-sampler 0 s2 1))
		    (happy #t))
		(do ((i 0 (+ i 1)))
		    ((or (not happy)
			 (= i (frames s1))))
		  (let ((v1 (r10))
			(v2 (r20)))
		    (if (> (abs (- v1 v2)) .0001)
			(begin
			  (set! happy #f)
			  (snd-display #__line__ ";copied sound 2 (0) not equal? pos: ~A, ~A ~A" i v1 v2))))
		  (let ((v1 (r11))
			(v2 (r21)))
		    (if (> (abs (- v1 v2)) .0001)
			(begin
			  (set! happy #f)
			  (snd-display #__line__ ";copied sound 2 (1) not equal? pos: ~A, ~A ~A" i v1 v2))))))
	      (close-sound s2))))
      (fill! s1 0.0)
      (if (fneq (maxamp s1) 0.0) (snd-display #__line__ ";fill 2 with 0: ~A" (maxamp s1)))
      (fill! s1 0.3)
      (if (fneq (maxamp s1) 0.3) (snd-display #__line__ ";fill 2 with 0.3: ~A" (maxamp s1)))
      (close-sound s1))
    
    (for-each close-sound (sounds))
    (let ((snd (open-sound "oboe.snd")))
      (make-selection 1000 2000 snd 0)
      (if (not (selection?)) (snd-display #__line__ ";make-selection for copy failed?"))
      (copy (selection))
      (let* ((r1 (make-sampler 1000 snd 0))
	     (snds (sounds))
	     (sel (if (equal? (car snds) snd) (cadr snds) (car snds)))
	     (r2 (make-sampler 0 sel 0))
	     (happy #t))
	(if (equal? sel snd)
	    (snd-display #__line__ ";very weird: ~A equal? ~A from ~A (~A ~A ~A)" sel snd snds (car snds) (cadr snds) (equal? (car snds) snd)))
	(do ((i 0 (+ i 1)))
	    ((or (not happy)
		 (= i 1000)))
	  (let ((v1 (r1))
		(v2 (r2)))
	    (if (> (abs (- v1 v2)) .0001)
		(begin
		  (set! happy #f)
		  (snd-display #__line__ ";copied selection not equal? pos: ~A, ~A ~A (~A ~A from ~A)" i v1 v2 sel snd snds)))))
	(close-sound sel)
	(if (not (selection?))
	    (snd-display #__line__ ";copy selection unselected? ~A" (sounds))
	    (begin
	      (fill! (selection) 0.0)
	      (let ((r1 (make-sampler 1000 snd 0))
		    (happy #t))
		(do ((i 0 (+ i 1)))
		    ((or (not happy)
			 (= i 1000)))
		  (let ((v1 (r1)))
		    (if (not (= v1 0.0))
			(begin
			  (set! happy #f)
			  (snd-display #__line__ ";fill! selection not 0.0? pos: ~A, ~A" i v1))))))
	      (revert-sound snd)
	      (if (not (selection?))
		  (snd-display #__line__ ";revert-sound selection unselected?")
		  (begin
		    (fill! (selection) 0.3)
		    (let ((r1 (make-sampler 1000 snd 0))
			  (happy #t))
		      (do ((i 0 (+ i 1)))
			  ((or (not happy)
			       (= i 1000)))
			(let ((v1 (r1)))
			  (if (not (= v1 0.3))
			      (begin
				(set! happy #f)
				(snd-display #__line__ ";fill! selection not 0.3? pos: ~A, ~A" i v1)))))))))))
      (for-each close-sound (sounds)))
    
    (let ((snd (open-sound "oboe.snd")))
      (make-selection 1000 2000 snd 0)
      (if (not (selection?)) 
	  (snd-display #__line__ ";make-selection failed?")
	  (let ((sel-max (maxamp (selection)))
		(sel-len (length (selection))))
	    (let ((mx (car (selection->mix))))
	      (if (not (mix? mx))
		  (snd-display #__line__ ";selection->mix: ~A" mx)
		  (let ((mx-rd (make-mix-sampler mx 0))
			(snd-rd (make-sampler 1000 snd 0))
			(orig-rd (make-sampler 1000 snd 0 1 0)))
		    (let ((happy #t))
		      (do ((i 0 (+ i 1)))
			  ((or (not happy) 
			       (= i 1000)))
			(let ((mx-val (mx-rd))
			      (snd-val (snd-rd))
			      (orig-val (orig-rd)))
			  (if (or (fneq mx-val snd-val)
				  (fneq snd-val orig-val))
			      (begin
				(set! happy #f)
				(snd-display #__line__ ";selection->mix at ~A: ~A ~A ~A" (+ i 1000) mx-val snd-val orig-val))))))
		    (if (not (= (length mx) sel-len 1001)) (snd-display #__line__ ";selection->mix mix length: ~A (~A)" (length mx) sel-len))
		    (if (fneq (maxamp mx) sel-max) (snd-display #__line__ ";selection->mix maxamps: ~A ~A" (maxamp mx) sel-max)))))))
      (for-each close-sound (sounds)))
    
    (let ((snd (open-sound "2.snd")))
      (set! (sync snd) 1)
      ;; make-selection claims it follows the sync field
      (make-selection 2000 3000 snd)
      (if (not (selection?)) 
	  (snd-display #__line__ ";make-selection (2) failed?")
	  (let ((sel-max (maxamp (selection)))
		(sel-len (length (selection)))
		(sel-chns (channels (selection))))
	    (if (not (= sel-chns 2)) (snd-display #__line__ ";make-selection stereo syncd chans: ~A" sel-chns))
	    (if (not (= sel-len 1001)) (snd-display #__line__ ";make-selection stereo length: ~A" sel-len))
	    (let* ((mx-list (selection->mix))
		   (mx0 (car mx-list))
		   (mx1 (cadr mx-list)))
	      (if (or (not (mix? mx0))
		      (not (mix? mx1)))
		  (snd-display #__line__ ";selection->mix stereo: ~A ~A" mx0 mx1)
		  (let ((mx0-rd (make-mix-sampler mx0 0))
			(mx1-rd (make-mix-sampler mx1 0))
			(snd0-rd (make-sampler 2000 snd 0))
			(snd1-rd (make-sampler 2000 snd 1))
			(orig0-rd (make-sampler 2000 snd 0 1 0))
			(orig1-rd (make-sampler 2000 snd 1 1 0)))
		    (let ((happy #t))
		      (do ((i 0 (+ i 1)))
			  ((or (not happy) 
			       (= i 1000)))
			(let ((mx0-val (mx0-rd))
			      (mx1-val (mx1-rd))
			      (snd0-val (snd0-rd))
			      (snd1-val (snd1-rd))
			      (orig0-val (orig0-rd))
			      (orig1-val (orig1-rd)))
			  (if (or (fneq mx0-val snd0-val)
				  (fneq snd0-val orig0-val))
			      (begin
				(set! happy #f)
				(snd-display #__line__ ";selection->mix stereo 0 at ~A: ~A ~A ~A" (+ i 2000) mx0-val snd0-val orig0-val)))
			  (if (or (fneq mx1-val snd1-val)
				  (fneq snd1-val orig1-val))
			      (begin
				(set! happy #f)
				(snd-display #__line__ ";selection->mix stereo 1 at ~A: ~A ~A ~A" (+ i 2000) mx1-val snd1-val orig1-val))))))))
	      
	      (if (not (= (length mx0) (length mx1) sel-len 1001))
		  (snd-display #__line__ ";selection->mix stereo mix length: ~A ~A (~A)" (length mx0) (length mx1) sel-len))
	      (if (fneq (max (maxamp mx0) (maxamp mx1)) sel-max) 
		  (snd-display #__line__ ";selection->mix stereo maxamps: ~A ~A ~A" (maxamp mx0) (maxamp mx1) sel-max)))))
      (for-each close-sound (sounds)))
    
    (clear-save-state-files)))


;;; ---------------- test 6: vcts ----------------

(define (snd_test_6)
  (begin 
    
    (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests)) 
      (log-mem clmtest)
      (let ((v0 (make-vct 10))
	    (v1 (make-vct 10))
	    (vlst (make-vct 3)))
	(if (not (vct? v0)) (snd-display #__line__ ";v0 isn't a vct?!?"))
	(if (equal? v0 10) (snd-display #__line__ ";v0 is 10!?"))
	(if (vct? 10) (snd-display #__line__ ";10 is a vct?"))
	(if (not (= (vct-length v0) 10)) (snd-display #__line__ ";v0 length = ~D?" (vct-length v0)))
	(vct-fill! v0 1.0)
	(vct-fill! v1 0.5)
	(if (equal? v0 v1) (snd-display #__line__ ";vct equal? ~A ~A" v0 v1))
	(if (eq? v0 v1) (snd-display #__line__ ";vct eq? ~A ~A" v0 v1))
	(let ((v2 v1)
	      (v3 (make-vct 10))
	      (v4 (make-vct 3)))
	  (if (not (eq? v1 v2)) (snd-display #__line__ ";vct not eq? ~A ~A" v1 v2))
	  (vct-fill! v3 0.5) 
	  (if (not (equal? v3 v1)) (snd-display #__line__ ";vct not equal? ~A ~A" v3 v1))
	  (if (equal? v4 v1) (snd-display #__line__ ";len diff vct equal? ~A ~A" v4 v1))
	  (set! (vct-ref v3 0) 1.0)
	  (if (fneq (vct-ref v3 0) 1.0) (snd-display #__line__ ";set! vct-ref: ~A" (vct-ref v3 0))))
	(vct-set! vlst 1 .1)
	(if (not (feql (vct->list vlst) (list 0.0 0.1 0.0))) (snd-display #__line__ ";vct->list: ~A?" (vct->list vlst)))
	(let* ((vect '#(0.0 1.0 2.0 3.0))
	       (v123 (vct 0.0 1.0 2.0 3.0))
	       (v2 (vector->vct vect))
	       (v3 v2)
	       (str (format #f "~A" v2))
	       (str1 (format #f "~A" (make-vct 32))))
	  (if (not (eq? #f (vector->vct (make-vector 0)))) (snd-display #__line__ ";vector->vct empty vect: ~A" (vector->vct (make-vector 0))))
	  (if (not (string=? str "#<vct[len=4]: 0.000 1.000 2.000 3.000>"))
	      (snd-display #__line__ ";vct print: ~%  ~A~%  ~A?" str v2))
	  (if (and (= (print-length) 12)
		   (not (string=? str1 "#<vct[len=32]: 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ...>")))
	      (snd-display #__line__ ";vct(32) print: ~%  ~A~%" str1))
	  (if (not (vequal v123 v2)) (snd-display #__line__ ";vector->vct: ~A" v2))
	  (if (not (equal? (vct->vector v123) vect)) (snd-display #__line__ ";vct->vector: ~A ~A" vect (vct->vector v123)))
	  (if (not (equal? v3 v2)) (snd-display #__line__ ";vct=? ~A ~A?" v2 v3))
	  (if (not (= (vct-length v2) 4)) (snd-display #__line__ ";vector->vct length: ~A?" (vct-length v2)))
	  (if (fneq (vct-ref v2 2) 2.0) (snd-display #__line__ ";vector->vct: ~A?" v2))
	  (vct-move! v2 0 2)
	  (if (fneq (vct-ref v2 0) 2.0) (snd-display #__line__ ";vct-move!: ~A?" v2)))
	(let ((v2 (make-vct 4)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 4))
	    (vct-set! v2 i i))
	  (vct-move! v2 3 2 #t)
	  (if (or (fneq (vct-ref v2 3) 2.0) (fneq (vct-ref v2 2) 1.0))
	      (snd-display #__line__ ";vct-move! back: ~A?" v2)))
	
	(if (not (string=? (vct->string (vct 1.0 2.0)) "(vct 1.000 2.000)")) 
	    (snd-display #__line__ ";vct->string: ~A" (vct->string (vct 1.0 2.0))))
	
	(if (not (vequal (vct 4 3 2 1) (vct-reverse! (vct 1 2 3 4)))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1 2 3 4))))
	(if (not (vequal (vct 3 2 1) (vct-reverse! (vct 1 2 3)))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1 2 3))))
	(if (not (vequal (vct 2 1) (vct-reverse! (vct 1 2)))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1 2))))
	(if (not (vequal (vct 1) (vct-reverse! (vct 1)))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1))))
	(if (not (vequal (vct 4 3 2 1) (vct-reverse! (vct 1 2 3 4) 4))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1 2 3 4))))
	(if (not (vequal (vct 3 2 1) (vct-reverse! (vct 1 2 3) 3))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1 2 3))))
	(if (not (vequal (vct 2 1) (vct-reverse! (vct 1 2) 2))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1 2))))
	(if (not (vequal (vct 1) (vct-reverse! (vct 1) 1))) (snd-display #__line__ ";vct-reverse: ~A" (vct-reverse! (vct 1))))
	
	(let ((v0 (make-vct 3)))
	  (let ((var (catch #t (lambda () (vct-ref v0 10)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-ref high index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-ref v0 -1)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-ref low index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-set! v0 10 1.0)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-set! high index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-set! v0 -1 1.0)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-set! low index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-move! v0 10 0 #t)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-move! high index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-move! v0 0 10 #t)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-move! high 2 index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-move! v0 -10 0 #f)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-move! back high index: ~A" var)))
	  (let ((var (catch #t (lambda () (vct-move! v0 0 -10 #f)) (lambda args args))))
	    (if (not (eq? (car var) 'out-of-range))
		(snd-display #__line__ ";vct-move! back high 2 index: ~A" var))))
	
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (if (fneq (vct-ref v0 i) 1.0) (snd-display #__line__ ";fill v0[~D] = ~F?" i (vct-ref v0 i)))
	  (if (fneq (vct-ref v1 i) 0.5) (snd-display #__line__ ";preset v1[~D] = ~F?" i (vct-ref v1 i))))
	(vct-add! v0 v1)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (if (fneq (vct-ref v0 i) 1.5) (snd-display #__line__ ";add v0[~D] = ~F?" i (vct-ref v0 i))))
	(vct-subtract! v0 v1)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (if (fneq (vct-ref v0 i) 1.0) (snd-display #__line__ ";subtract v0[~D] = ~F?" i (vct-ref v0 i))))
	(let ((v2 (vct-copy v0)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (if (fneq (vct-ref v2 i) 1.0) (snd-display #__line__ ";copy v0[~D] = ~F?" i (vct-ref v2 i))))
	  (vct-scale! v2 5.0)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (if (fneq (vct-ref v2 i) 5.0) (snd-display #__line__ ";scale v2[~D] = ~F?" i (vct-ref v2 i))))
	  (vct-offset! v0 -1.0)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (if (fneq (vct-ref v0 i) 0.0) (snd-display #__line__ ";offset v0[~D] = ~F?" i (vct-ref v0 i))))
	  (vct-multiply! v2 v1)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (if (fneq (vct-ref v2 i) 2.5) (snd-display #__line__ ";multiply v2[~D] = ~F?" i (vct-ref v2 i))))
	  (if (fneq (vct-peak v2) 2.5) (snd-display #__line__ ";v2's peak is ~F?" (vct-peak v2)))
	  (vct-set! v2 5 123.0)
	  (if (fneq (vct-peak v2) 123.0) (snd-display #__line__ ";v2's set peak is ~F?" (vct-peak v2)))
	  (let ((vn (make-vct 32))
		(vb (make-vct 64))
		(vs (make-vct 3))
		(vss (make-vct 1)))
	    (do ((i 0 (+ 1 i)))
		((= i 32))
	      (vct-set! vn i i))
	    (let ((vnew (vct-subseq vn 3)))
	      (if (fneq (vct-ref vnew 0) 3.0) (snd-display #__line__ ";vct-subseq[3:] ~A?" (vct-ref vnew 0)))
	      (if (not (= (vct-length vnew) 29)) (snd-display #__line__ ";vct-subseq[3:] length: ~A?" (vct-length vnew))))
	    (let ((vnew (vct-subseq vn 3 8)))
	      (if (fneq (vct-ref vnew 0) 3.0) (snd-display #__line__ ";vct-subseq[3:8] ~A?" (vct-ref vnew 0)))
	      (if (not (= (vct-length vnew) 6)) (snd-display #__line__ ";vct-subseq[3:8] length: ~A?" (vct-length vnew))))
	    (vct-subseq vn 3 3 vs)
	    (if (or (fneq (vct-ref vs 0) 3.0)
		    (fneq (vct-ref vs 1) 0.0)
		    (fneq (vct-ref vs 2) 0.0))
		(snd-display #__line__ ";vct-subseq[3:3->vs] ~A?" vs))
	    (vct-subseq vn 0 32 vs)
	    (if (not (= (vct-length vs) 3)) (snd-display #__line__ ";vct-subseq[0:32->vs] length: ~A?" (vct-length vs)))
	    (vct-subseq vn 2 3 vss)
	    (if (fneq (vct-ref vss 0) 2.0) (snd-display #__line__ ";vct-subseq[2:3->vss] ~A?" (vct-ref vss 0)))
	    (vct-set! vb 8 123.0)
	    (vct-subseq vn 1 8 vb)
	    (if (fneq (vct-ref vb 0) 1.0) (snd-display #__line__ ";vct-subseq[1:8->vb] ~A?" (vct-ref vb 0)))
	    (if (fneq (vct-ref vb 8) 123.0) (snd-display #__line__ ";vct-subseq[1:8->vb][8] ~A?" (vct-ref vb 8))))
	  
	  (let ((v1 (make-vct 3 .1))
		(v2 (make-vct 4 .2)))
	    (let ((val (vct+ (vct-copy v1) v2)))
	      (if (not (vequal val (vct .3 .3 .3))) (snd-display #__line__ ";vct+ .1 .2: ~A" val)))
	    (vct-set! v1 1 .3)
	    (let ((val (vct+ (vct-copy v1) v2)))
	      (if (not (vequal val (vct .3 .5 .3))) (snd-display #__line__ ";vct+ .1 .2 (1): ~A" val)))
	    (let ((val (vct+ (vct-copy v1) 2.0)))
	      (if (not (vequal val (vct 2.1 2.3 2.1))) (snd-display #__line__ ";vct+ .1 2.0: ~A" val)))
	    (let ((val (vct+ 2.0 (vct-copy v1))))
	      (if (not (vequal val (vct 2.1 2.3 2.1))) (snd-display #__line__ ";vct+ .1 2.0 (1): ~A" val)))
	    (let ((val (vct* 2.0 (vct-copy v1))))
	      (if (not (vequal val (vct .2 .6 .2))) (snd-display #__line__ ";vct* 2.0: ~A" val)))
	    (let ((val (vct* (vct-copy v1) 2.0)))
	      (if (not (vequal val (vct .2 .6 .2))) (snd-display #__line__ ";vct* 2.0 (1): ~A" val)))
	    (let ((val (vct* (vct-copy v1) v2)))
	      (if (not (vequal val (vct .02 .06 .02))) (snd-display #__line__ ";vct* v1 v2: ~A" val))))
	  
	  (vct-map! v0 (lambda () 1.0))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (if (fneq (vct-ref v0 i) 1.0) (snd-display #__line__ ";map v0[~D] = ~F?" i (vct-ref v0 i)))))
	
	(if (fneq ((vct 1.0 2.0 3.0) 1) 2.0)
	    (snd-display #__line__ ";(vct...) = ~A?" ((vct 1.0 2.0 3.0) 1)))
	(let ((v1 (vct 1 2 3 4)))
	  (if (fneq (v1 1) 2.0)
	      (snd-display #__line__ ";(v1 1) = ~A?" (v1 1))))
	
	(let ((ind (open-sound "oboe.snd"))
	      (ctr 0))
	  (set! (speed-control ind) .5)
	  (play :wait #t)
	  (apply-controls)
	  (revert-sound)
	  (reset-controls ind)
	  ;; try some special cases
	  (apply-controls)
	  (if (not (= (edit-position ind) 0))
	      (snd-display #__line__ ";apply-controls with no:change: ~A: ~A" (edits ind) (edit-tree ind)))
	  (set! (speed-control ind) -1.0)
	  (apply-controls)
	  (if (not (= (edit-position ind) 1))
	      (snd-display #__line__ ";apply-controls with srate -1.0: ~A ~A" (edits ind) (edit-tree ind)))
	  (if (> (abs (- (frames ind 0) (frames ind 0 0))) 2)
	      (snd-display #__line__ ";apply-controls srate -1.0 lengths: ~A ~A" (frames ind 0) (frames ind 0 0)))
	  (if (or (fneq (maxamp) .147)
		  (< (abs (sample 9327)) .01))
	      (snd-display #__line__ ";apply-controls srate -1.0 samples: ~A ~A" (maxamp) (sample 9327)))
	  (if (fneq (speed-control ind) 1.0) (snd-display #__line__ ";apply-controls -1.0 -> ~A?" (speed-control ind)))
	  
	  (add-hook! dac-hook (lambda (data) 
				(set! ctr (+ 1 ctr))
				(if (>= ctr 3) (c-g!))))
	  (play :wait #t)
	  (if (not (= ctr 3)) (snd-display #__line__ ";ctr after dac-hook: ~A" ctr))
	  (set! ctr 0)
	  (set! (speed-control) 1.5)
	  (apply-controls)
					;		(if (fneq (sample 28245) 0.0) (snd-display #__line__ ";dac-hook stop apply-controls? ~A" (sample 28245)))
	  (reset-hook! dac-hook)
	  (revert-sound)
	  (set! (speed-control) 1.5)
	  (set! ctr 0)
	  (add-hook! dac-hook (lambda (data) 
				(set! ctr (+ 1 ctr))
				(if (= ctr 3) (apply-controls))))
	  (play :wait #t)
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";apply-controls from hook: ~A ~A" (edits ind) (edit-tree ind)))
	  (revert-sound)
	  (reset-hook! dac-hook)
	  (set! (speed-control) 1.5)
	  (stop-playing)
	  (add-hook! after-apply-controls-hook (lambda (s) 
						 (let ((tag (catch #t 
								   (lambda () (apply-controls)) 
								   (lambda args args))))
						   (if (not (eq? (car tag) 'cannot-apply-controls))
						       (snd-display #__line__ ";after-apply-controls-hook: recursive attempt apply-controls: ~A" tag)))))
	  (apply-controls)
	  (reset-hook! after-apply-controls-hook)
	  (add-hook! dac-hook (lambda (s) 
				(let ((tag (catch #t 
						  (lambda () (apply-controls)) 
						  (lambda args args))))
				  (if (not (eq? (car tag) 'cannot-apply-controls))
				      (snd-display #__line__ ";dac-hook: recursive attempt apply-controls: ~A" tag)))))
	  (reset-hook! dac-hook)
	  
	  (revert-sound)
	  (close-sound ind))
	
	(let ((v1 (make-vct 32)))
	  (vct-map! v1
		    (lambda ()
		      (let ((v2 (make-vct 3)))
			(vct-map! v2 (lambda () .1))
			(vct-ref v2 0))))
	  (if (fneq (vct-ref v1 12) .1) (snd-display #__line__ ";vct-map! twice: ~A" (vct-ref v1 12))))
	(let ((hi (make-vct 3)))
	  (let ((tag (catch #t
			    (lambda () (vct-subseq hi 1 0))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'out-of-range))
		(snd-display #__line__ ";vct-subseq 1 0: ~A" tag)))
	  (if (vct) (snd-display #__line__ ";(vct) -> ~A" (vct)))
	  (let ((tag (catch #t (lambda () (make-vct 0)) (lambda args (car args)))))
	    (if (not (eq? tag 'out-of-range)) (snd-display #__line__ ";make-vct 0 -> ~A" tag)))
	  (let ((ho (make-vct 3)))
	    (vct-add! hi ho 4)))
	(let ((v0 (make-vct 5 .1))
	      (v1 (make-vct 6 .2)))
	  (vct-add! v0 v1 2)
	  (if (not (vequal v0 (vct .1 .1 .3 .3 .3)))
	      (snd-display #__line__ ";vct-add + offset: ~A" v0)))
	
	;; test local var gc protection in vct.h vct_to_vector
	(let ((v1 (vct-map! 
		   (make-vct 44100 0.0) 
		   (make-oscil 1)))) 
	  (vct->vector v1) 
	  (vct->vector v1)
	  (let ((vect (vct->vector v1)))
	    (vector->vct vect)
	    (vector->vct vect)
	    (set! v1 (vector->vct vect))))
	
#|
	;; a test of big vcts (needs 16 Gbytes):
	(if (and (string? (getenv "HOSTNAME"))
		 (string=? (getenv "HOSTNAME") "fatty8"))
	    (let ((size (+ 2 (expt 2 31))))
	      (if (not (= size 2147483650))
		  (snd-display #__line__ ";big vct, size: ~A (~A ~A)" size 2147483650 (- 2147483650 size)))
	      (set! (mus-max-malloc) (expt 2 40))
	      (if (not (= (mus-max-malloc) 1099511627776))
		  (snd-display #__line__ ";big vct, mus-max-malloc: ~A" (mus-max-malloc)))
	      (let ((hi (make-vct size)))
		(if (not (vct? hi))
		    (snd-display #__line__ ";big vct, not a vct?? ~A" hi))
		(if (fneq (vct-ref hi (expt 2 31)) 0.0)
		    (snd-display #__line__ ";big vct, created at end: ~A" (vct-ref hi (expt 2 31))))
		(vct+ hi .1)
		(if (fneq (vct-ref hi (expt 2 31)) 0.1)
		    (snd-display #__line__ ";big vct, add .1 at end: ~A" (vct-ref hi (expt 2 31))))
		(let ((pk (vct-peak hi)))
		  (if (fneq pk .1)
		      (snd-display #__line__ ";big vct, vct-peak: ~A" pk)))
		(let ((len (vct-length hi)))
		  (if (not (= len size))
		      (snd-display #__line__ ";big vct, len: ~A" len)))
		(vct-scale! hi 2.0)
		(if (fneq (vct-ref hi (+ 1 (expt 2 31))) .2)
		    (snd-display #__line__ ";big vct, scale: ~A ~A" (vct-ref hi (+ 1 (expt 2 31))) hi))
		(vct-set! hi (expt 2 31) 1.0)
		(if (fneq (vct-ref hi (expt 2 31)) 1.0)
		    (snd-display #__line__ ";big vct, set at end: ~A" (vct-ref hi (expt 2 31))))
		(vct-offset! hi .2)
		(if (fneq (vct-ref hi (expt 2 31)) 1.2)
		    (snd-display #__line__ ";big vct, offset: ~A" (vct-ref hi (expt 2 31))))
		(vct-subtract! hi hi)
		(let ((pk (vct-peak hi)))
		  (if (fneq pk 0.0)
		      (snd-display #__line__ ";big vct, subtract vct-peak: ~A ~A" pk hi)))
		(vct-fill! hi 1.0)
		(if (fneq (vct-ref hi (expt 2 31)) 1.0)
		    (snd-display #__line__ ";big vct, fill: ~A ~A" (vct-ref hi (expt 2 31)) hi))
		(vct-set! hi (expt 2 31) 0.0)
		(let ((ho (vct-subseq hi (- (expt 2 31) 3) (+ (expt 2 31) 1))))
		  (if (not (vequal ho (vct 1.0 1.0 1.0 0.0 1.0)))
		      (snd-display #__line__ ";big vct, subseq: ~A" ho)))
		(vct-reverse! hi)
		(let ((ho (vct-subseq hi 0 5)))
		  (if (not (vequal ho (vct 1.0 0.0 1.0 1.0 1.0 1.0)))
		      (snd-display #__line__ ";big vct, reverse: ~A" ho)))
		(vct-set! hi (expt 2 31) 10.0)
		(vct-move! hi (- (expt 2 31) 3) (expt 2 31))
		(let ((ho (vct-subseq hi (- (expt 2 31) 3) (+ (expt 2 31) 1))))
		  (if (not (vequal ho (vct 10.0 1.0 1.0 10.0 1.0)))
		      (snd-display #__line__ ";big vct, subseq: ~A" ho)))
		)
	      
	      ;; big vectors/hash-tables also
	      
	      
	      (let ((size (+ 2 (expt 2 31))))
		(if (not (= size 2147483650))
		    (snd-display #__line__ ";big vector size: ~A (~A ~A)" size 2147483650 (- 2147483650 size)))
		(let ((hi (make-vector size '())))
		  (if (not (vector? hi))
		      (snd-display #__line__ ";big vector not a vector?? ~A" hi))
		  (if (not (null? (vector-ref hi (expt 2 31))))
		      (snd-display #__line__ ";big vector created at end: ~A" (vector-ref hi (expt 2 31))))
		  (set! (hi (expt 2 31)) 100)
		  (if (not (= (vector-ref hi (expt 2 31)) 100))
		      (snd-display #__line__ ";big vector set to 100 at end: ~A" (vector-ref hi (expt 2 31))))
		  (let ((len (vector-length hi)))
		    (if (not (= len size))
			(snd-display #__line__ ";big vector len: ~A" len)))
		  (vector-fill! hi 2)
		  (if (not (= (vector-ref hi (expt 2 31)) 2))
		      (snd-display #__line__ ";big vector fill: ~A" (vector-ref hi (expt 2 31))))))
	      
	      
	      
	      (let ((hi (make-vector (list (+ 2 (expt 2 30)) 2) '())))
		(if (not (= (vector-length hi) (* 2 (+ 2 (expt 2 30)))))
		    (snd-display #__line__ ";big vector 2dim size: ~A ~A" (vector-length hi) (* 2 (+ 2 (expt 2 30)))))
		(if (not (null? (vector-ref hi (expt 2 30) 0)))
		    (snd-display #__line__ ";big vector 2dim created at end (0): ~A" (vector-ref hi (expt 2 30) 0)))
		(if (not (null? (vector-ref hi (expt 2 30) 1)))
		    (snd-display #__line__ ";big vector 2dim created at end (1): ~A" (vector-ref hi (expt 2 30) 1)))
		(set! (hi (expt 2 30) 1) 100)
		(if (not (= (vector-ref hi (expt 2 30) 1) 100))
		    (snd-display #__line__ ";big vector 2dim set to 100 at end: ~A" (vector-ref hi (expt 2 30) 1)))
		(vector-fill! hi 2)
		(if (not (= (vector-ref hi (expt 2 30) 0) 2))
		    (snd-display #__line__ ";big vector 2dim fill: ~A" (vector-ref hi (expt 2 30) 0))))
	      
	      
	      
	      (let ((hi (make-hash-table (+ 2 (expt 2 31)))))
		(if (not (= (hash-table-size hi) (+ 2 (expt 2 31))))
		    (snd-display #__line__ ";big hash size: ~A ~A" (hash-table-size hi) (+ 2 (expt 2 31))))
		(if (fneq (let () (hash-table-set! hi 'key 3.14) (hash-table-ref hi 'key)) 3.14)
		    (snd-display #__line__ ";big hash 3.14: ~A" (hash-table-ref hi 'key)))
		(if (not (equal? (let () (hash-table-set! hi 123 "hiho") (hash-table-ref hi 123)) "hiho"))
		    (snd-display #__line__ ";big hash 123: ~A" (hash-table-ref hi 123)))
		(if (not (equal? (let () 
				   (hash-table-set! hi 'hiho-this-is-a-big-name-to-overflow-32-bits-I-hope "hiho")
				   (hash-table-ref hi 'hiho-this-is-a-big-name-to-overflow-32-bits-I-hope))
				 "hiho"))
		    (snd-display #__line__ ";big hash big symbol: ~A" (hash-table-ref hi 'hiho-this-is-a-big-name-to-overflow-32-bits-I-hope)))
		(if (not (equal? (let () 
				   (hash-table-set! hi 12345678912345 "hiho")
				   (hash-table-ref hi 12345678912345))
				 "hiho"))
		    (snd-display #__line__ ";big hash big symbol: ~A" (hash-table-ref hi 12345678912345))))
	      
	      
	      ))
|#
	
	(let ((sum 0)) 
	  (for-each (lambda (n) (set! sum (+ sum n))) (vct 1 2 3))
	  (if (not (= sum 6.0))
	      (snd-display #__line__ ";object for-each (vct): ~A" sum)))
	
	))))


;;; ---------------- test 7: colors ----------------

(if (not (provided? 'snd-rgb.scm)) (load "rgb.scm"))

(define (snd_test_7)
  (define colormap-error-max 0.0)
  (define cfneq (lambda (a b) (> (abs (- a b)) colormap-error-max)))
  (define old-colormap-size (colormap-size))
  
  (if (or (provided? 'snd-gtk)
	  (provided? 'snd-motif))
      (letrec ((test-color
		(lambda (lst)
		  (if (not (null? lst))
		      (let* ((name (list-ref (car lst) 0))
			     (getfnc (list-ref (car lst) 1))
			     (setfnc (lambda (val) (set! (getfnc) val)))
			     (initval (list-ref (car lst) 2)))
			(if (not (color? initval)) (snd-display #__line__ ";~A not color?" initval))
			;; we'll get warnings here if the cell chosen didn't exactly match the one requested -- not a bug
			;; (if (not (equal? (getfnc) initval))
			;;	  (snd-display #__line__ ";~A /= ~A (~A)?" name initval (getfnc)))
			(setfnc beige)
			(if (not (equal? (getfnc) beige))
			    (snd-display #__line__ ";set-~A /= beige (~A)?" name (getfnc)))
			(setfnc initval)
			(test-color (cdr lst)))))))
	
	(let* ((c1 (catch 'no-such-color
			  (lambda () (make-color 0 0 1))
			  (lambda args #f)))
	       (c2 c1)
	       (c3 (catch 'no-such-color
			  (lambda () (make-color 0 0 1))
			  (lambda args #f))))
	  (if (not (equal? c1 c2)) (snd-display #__line__ ";color equal? ~A ~A?" c1 c2))
	  (if (not (eq? c1 c2)) (snd-display #__line__ ";color eq? ~A ~A?" c1 c2))
	  (if (provided? 'snd-motif) (if (not (equal? c1 c3)) (snd-display #__line__ ";diff color equal? ~A ~A?" c1 c3)))
	  (if (eq? c1 c3) (snd-display #__line__ ";diff color eq? ~A ~A?" c1 c3))
	  (if (not (equal? (color->list c1) (list 0.0 0.0 1.0)))
	      (snd-display #__line__ ";color->list: ~A ~A?" c1 (color->list c1))))
	(do ((i 0 (+ 1 i))) 
	    ((not (colormap? (integer->colormap i))))
	  (let ((val (colormap-ref (integer->colormap i) 0))
		(true-val (list-ref (list '(0.0 0.0 0.0) '(0.0 0.0 0.0) '(0.0 0.0 0.0) '(0.0 1.0 1.0)
					  '(0.0 0.0 7.01915007248035e-4) '(0.0 0.0 0.0) '(0.0 0.0 0.0)
					  '(0.0 0.0 0.49999) '(1.0 0.0 0.0) '(1.0 0.0 0.0) '(0.0 0.0 1.0)
					  '(1.0 0.0 1.0) '(0.0 0.500007629510948 0.4) '(1.0 0.0 0.0)
					  '(1.0 0.0 0.0) '(0.0 0.0 1.0))
				    i)))
	    (if (not (feql val true-val))
		(snd-display #__line__ ";colormap-ref ~A: ~A (~A)" i val true-val))))
	(catch #t ; might be undefined var as well as no-such-color
	       (lambda () 
		 (test-color
		  (list
		   (list 'basic-color basic-color ivory2)
		   (list 'cursor-color cursor-color red)
		   (list 'data-color data-color black)
		   (list 'enved-waveform-color enved-waveform-color blue)
		   (list 'filter-control-waveform-color filter-control-waveform-color blue)
		   (list 'graph-color graph-color white)
		   (list 'highlight-color highlight-color ivory1)
		   (list 'listener-color listener-color alice-blue)
		   (list 'listener-text-color listener-text-color black)
		   (list 'mark-color mark-color red)
		   (list 'mix-color mix-color dark-gray)
		   (list 'position-color position-color ivory3)
		   (list 'pushed-button-color pushed-button-color lightsteelblue1)
		   (list 'sash-color sash-color light-green)
		   (list 'selected-data-color selected-data-color black)
		   (list 'selected-graph-color selected-graph-color white)
		   (list 'selection-color selection-color lightsteelblue1)
		   (list 'text-focus-color text-focus-color white)
		   (list 'zoom-color zoom-color ivory4)
		   
		   (list 'quit-button-color quit-button-color indian-red)
		   (list 'help-button-color help-button-color lightsteelblue2)
		   (list 'reset-button-color reset-button-color goldenrod1)
		   (list 'doit-button-color doit-button-color palegreen2)
		   (list 'doit-again-button-color doit-again-button-color darkolivegreen1)
		   ))
		 
		 (let ((ind (open-sound "oboe.snd")))
		   (set! (selected-data-color) light-green)
		   (set! (data-color) blue)
		   (set! (selected-graph-color) black)
		   (let ((red (make-color-with-catch 1.0 0.0 0.0)))
		     (set! (foreground-color ind 0 cursor-context) red)
		     (let ((col (foreground-color ind 0 cursor-context)))
		       (if (not (feql (color->list col) (color->list red)))
			   (snd-display #__line__ ";set foreground cursor color: ~A ~A" (color->list col) (color->list red))))
		     (set! (foreground-color) blue)
		     (let ((col (foreground-color)))
		       (if (not (feql (color->list col) (color->list blue)))
			   (snd-display #__line__ ";set foreground-color: ~A ~A" (color->list col) (color->list blue))))
		     (set! (foreground-color ind) red)
		     (let ((col (foreground-color ind)))
		       (if (not (feql (color->list col) (color->list red)))
			   (snd-display #__line__ ";set foreground-color with ind (red): ~A ~A" (color->list col) (color->list red))))
		     (set! (foreground-color ind) black)
		     (let ((col (foreground-color ind)))
		       (if (not (feql (color->list col) (color->list black)))
			   (snd-display #__line__ ";set foreground-color with ind (black): ~A ~A" (color->list col) (color->list black)))))
		   (set! (selected-graph-color) (make-color-with-catch 0.96 0.96 0.86))
		   (set! (data-color) black)
		   (set! (selected-data-color) blue)
		   (set! (graph-color) white)
		   (close-sound ind)))
	       (lambda args args))
	
	(if (not (= (length jet-colormap) (colormap-size)))
	    (snd-display #__line__ ";jet-colormap length: ~A ~A" (length jet-colormap) (colormap-size)))
	
	(for-each 
	 (lambda (n err)
	   (set! (colormap-size) n)
	   (set! colormap-error-max err)
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r (if (< x 3/4)
			   (* 7/8 x)
			   (- (* 11/8 x) 3/8)))
		    (g (if (< x 3/8)
			   (* 7/8 x)
			   (if (< x 3/4)
			       (- (* 29/24 x) 1/8)
			       (+ (* 7/8 x) 1/8))))
		    (b (if (< x 3/8)
			   (* 29/24 x)
			   (+ (* 7/8 x) 1/8)))
		    (rgb (colormap-ref bone-colormap x))
		    (rgb1 (bone-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2))
		    (r2 (list-ref rgb1 0))
		    (g2 (list-ref rgb1 1))
		    (b2 (list-ref rgb1 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) 
			(or (cfneq r r1) 
			    (cfneq g g1) 
			    (cfneq b b1)
			    (cfneq r2 r1) 
			    (cfneq g2 g1) 
			    (cfneq b2 b1)))
		   (snd-display #__line__ ";bone ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r (if (< x 4/5)
			   (* 5/4 x)
			   1.0))
		    (g (* 4/5 x))
		    (b (* 1/2 x))
		    (rgb (colormap-ref copper-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";copper ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r 0.0)
		    (g x)
		    (b (- 1.0 (/ g 2.0)))
		    (rgb (colormap-ref winter-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";winter ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r 1.0)
		    (g x)
		    (b 0.0)
		    (rgb (colormap-ref autumn-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";autumn ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r x)
		    (g (- 1.0 r))
		    (b 1.0)	     
		    (rgb (colormap-ref cool-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";cool ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r (if (< x 3/8)
			   (* 8/3 x)
			   1.0))
		    (g (if (< x 3/8)
			   0.0
			   (if (< x 3/4)
			       (- (* 8/3 x) 1.0)
			       1.0)))
		    (b (if (< x 3/4)
			   0.0
			   (- (* 4 x) 3)))
		    (rgb (colormap-ref hot-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";hot ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r (if (< x 3/8)
			   0.0
			   (if (< x 5/8)
			       (- (* 4 x) 3/2)
			       (if (< x 7/8)
				   1.0
				   (+ (* -4 x) 9/2)))))
		    (g (if (< x 1/8)
			   0.0
			   (if (< x 3/8)
			       (- (* 4 x) 1/2)
			       (if (< x 5/8)
				   1.0
				   (if (< x 7/8)
				       (+ (* -4 x) 7/2)
				       0.0)))))
		    (b (if (< x 1/8)
			   (+ (* 4 x) 1/2)
			   (if (< x 3/8)
			       1.0
			       (if (< x 5/8)
				   (+ (* -4 x) 5/2)
				   0.0))))
		    (rgb (colormap-ref jet-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";jet ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (if (colormap? pink-colormap)
	       (do ((i 0 (+ 1 i))) ((= i 10))
		 (let* ((x (random 1.0))
			(r (if (< x 3/8)
			       (* 14/9 x)
			       (+ (* 2/3 x) 1/3)))
			(g (if (< x 3/8)
			       (* 2/3 x)
			       (if (< x 3/4)
				   (- (* 14/9 x) 1/3)
				   (+ (* 2/3 x) 1/3))))			
			(b (if (< x 3/4)
			       (* 2/3 x)
			       (- (* 2 x) 1)))
			(rgb (colormap-ref pink-colormap x))
			(r1 (list-ref rgb 0))
			(g1 (list-ref rgb 1))
			(b1 (list-ref rgb 2)))
		   (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		       (snd-display #__line__ ";pink ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				    x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r 1.0)
		    (g x)
		    (b (- 1.0 g))
		    (rgb (colormap-ref spring-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";spring ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r x)
		    (g x)
		    (b x)
		    (rgb (colormap-ref gray-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";gray ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r 0.0)
		    (g 0.0)
		    (b 0.0)
		    (rgb (colormap-ref black-and-white-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";black-and-white ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r x)
		    (g (+ 0.5 (/ r 2)))
		    (b 0.4)
		    (rgb (colormap-ref summer-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";summer ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (r (if (< x 2/5)
			   1.0
			   (if (< x 3/5)
			       (+ (* -5 x) 3)
			       (if (< x 4/5)
				   0.0
				   (- (* 10/3 x) 8/3)))))
		    (g (if (< x 2/5)
			   (* 5/2 x)
			   (if (< x 3/5)
			       1.0
			       (if (< x 4/5)
				   (+ (* -5 x) 4)
				   0.0))))
		    (b (if (< x 3/5)
			   0.0
			   (if (< x 4/5)
			       (- (* 5 x) 3)
			       1.0)))
		    (rgb (colormap-ref rainbow-colormap x))
		    (r1 (list-ref rgb 0))
		    (g1 (list-ref rgb 1))
		    (b1 (list-ref rgb 2)))
	       (if (and (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		   (snd-display #__line__ ";rainbow ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1)))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (rgb (colormap-ref prism-colormap x)))
	       (if (and (< x (- 1.0 (/ 1.0 n)))
			(not (feql rgb '(1 0 0)))
			(not (feql rgb '(1 0.5 0)))
			(not (feql rgb '(1 1 0)))
			(not (feql rgb '(0 1 0)))
			(not (feql rgb '(0 0 1)))
			(not (feql rgb '(.6667 0 1))))
		   (snd-display #__line__ ";prism ~A" rgb))))
	   
	   (do ((i 0 (+ 1 i))) ((= i 10))
	     (let* ((x (random 1.0))
		    (rgb (colormap-ref flag-colormap x)))
	       (if (and (< x (- 1.0 (/ 1.0 n)))
			(not (feql rgb '(1 0 0)))
			(not (feql rgb '(1 1 1)))
			(not (feql rgb '(0 0 1)))
			(not (feql rgb '(0 0 0))))
		   (snd-display #__line__ ";flag: ~A" rgb))))
	   )
	 (list 512 64)
	 (list 0.005 0.04))
	
	(let ((ind (add-colormap "white" (lambda (size) (list (make-vct size 1.0) (make-vct size 1.0) (make-vct size 1.0))))))
	  (if (not (colormap? ind))
	      (snd-display #__line__ ";add-colormap ~A: ~A" ind (colormap? ind)))
	  (if (not (feql (colormap-ref ind 0.5) '(1.0 1.0 1.0)))
	      (snd-display #__line__ ";white colormap: ~A" (colormap-ref ind 0.5)))
	  (let ((tag (catch #t (lambda () (set! (colormap) ind)) (lambda args args))))
	    (if (or (eq? tag 'no-such-colormap)
		    (not (equal? (colormap) ind))
		    (not (= (colormap->integer (colormap)) (colormap->integer ind))))
		(snd-display #__line__ ";colormap white: ~A ~A ~A" tag ind (colormap))))
	  (if (not (string=? (colormap-name ind) "white"))
	      (snd-display #__line__ ";white colormap name: ~A" (colormap-name ind))))
	
	(let ((tag (catch #t (lambda () (delete-colormap (integer->colormap 1234))) (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-colormap))
	      (snd-display #__line__ ";delete-colormap 1234: ~A" tag)))
	(let ((tag (catch #t (lambda () (colormap-ref (integer->colormap 1234) 0.5)) (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-colormap))
	      (snd-display #__line__ ";colormap-ref 1234: ~A" tag)))
	(let ((tag (catch #t (lambda () (colormap-ref (integer->colormap -1) 0.5)) (lambda args (car args)))))
	  (if (and (not (eq? tag 'no-such-colormap))
		   (not (eq? tag 'wrong-type-arg)))
	      (snd-display #__line__ ";colormap-ref -1: ~A" tag)))
	(let ((tag (catch #t (lambda () (set! (colormap) (integer->colormap 1234))) (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-colormap))
	      (snd-display #__line__ "; set colormap 1234: ~A" tag)))
	(let ((tag (catch #t (lambda () (set! (colormap) (integer->colormap -1))) (lambda args (car args)))))
	  (if (and (not (eq? tag 'no-such-colormap))
		   (not (eq? tag 'wrong-type-arg)))
	      (snd-display #__line__ "; set colormap -1: ~A" tag)))
	(let ((tag (catch #t (lambda () (colormap-ref copper-colormap 2.0)) (lambda args (car args)))))
	  (if (not (eq? tag 'out-of-range))
	      (snd-display #__line__ ";colormap-ref 2.0: ~A" tag)))
	
	(set! (colormap-size) old-colormap-size)
	(if (not (= (colormap-size) old-colormap-size))
	    (snd-display #__line__ ";set colormap-size: ~A ~A" (colormap-size) old-colormap-size))
	
	(if (not (string=? (colormap-name black-and-white-colormap) "black-and-white"))
	    (snd-display #__line__ ";black-and-white: ~A" (colormap-name black-and-white-colormap)))
	(if (not (string=? (colormap-name gray-colormap) "gray"))
	    (snd-display #__line__ ";gray: ~A" (colormap-name gray-colormap)))
	(if (not (string=? (colormap-name rainbow-colormap) "rainbow"))
	    (snd-display #__line__ ";rainbow: ~A" (colormap-name rainbow-colormap)))
	
	(let ((purple-cmap (add-colormap "purple" 
					 (lambda (size) 
					   (let ((r (make-vct size))
						 (g (make-vct size))
						 (b (make-vct size))
						 (incr (exact->inexact (/ 256.0 size)))
						 (er (list 0 60 60 116 128 252 192 252 256 60))
						 (eg (list 0 0  64 0   128 252 192 252 256 0))
						 (eb (list 0 80        128 252 192 0   256 80)))
					     (do ((i 0 (+ 1 i))
						  (x 0.0 (+ x incr)))
						 ((= i size))
					       (vct-set! r i (exact->inexact (/ (envelope-interp x er) 256.0)))
					       (vct-set! g i (exact->inexact (/ (envelope-interp x eg) 256.0)))
					       (vct-set! b i (exact->inexact (/ (envelope-interp x eb) 256.0))))
					     (list r g b)))))
	      (sin-cmap (add-colormap "sin" 
				      (lambda (size) 
					(let ((r (make-vct size))
					      (g (make-vct size))
					      (b (make-vct size))
					      (incr (exact->inexact (/ (* 2 pi) size))))
					  (do ((i 0 (+ 1 i))
					       (x 0.0 (+ x incr)))
					      ((= i size))
					    (vct-set! r i (abs (sin (* 1.5 x))))
					    (vct-set! g i (abs (sin (* 3.5 x))))
					    (vct-set! b i (abs (sin (* 2.5 x)))))
					  (list r g b)))))
	      (another-sin-cmap (add-colormap "another-sin" 
					      (lambda (size) 
						(let ((r (make-vct size))
						      (g (make-vct size))
						      (b (make-vct size))
						      (incr (exact->inexact (/ (* 2 pi) size))))
						  (do ((i 0 (+ 1 i))
						       (x 0.0 (+ x incr)))
						      ((= i size))
						    (vct-set! r i (abs (sin (* 2.5 x))))
						    (vct-set! g i (abs (sin (* 3.5 x))))
						    (vct-set! b i (abs (sin (* 4.5 x)))))
						  (list r g b))))))
	  (delete-colormap pink-colormap)
	  (if (colormap? pink-colormap)
	      (snd-display #__line__ ";delete-colormap ~A: ~A" pink-colormap (colormap? pink-colormap)))
	  (let ((tag (catch #t (lambda () (set! (colormap) pink-colormap)) (lambda args args))))
	    (if (or (not (eq? (car tag) 'no-such-colormap))
		    (equal? (colormap) pink-colormap))
		(snd-display #__line__ ";delete pink colormap: ~A ~A ~A" tag pink-colormap (colormap))))
	  
	  (for-each
	   (lambda (n)
	     (set! (colormap-size) n)
	     (do ((i 0 (+ 1 i))) 
		 ((= i 10))
	       (let* ((x (random 1.0))
		      (r (if (< x 4/5) (* 5/4 x) 1.0))
		      (g (* 4/5 x))
		      (b (* 1/2 x))
		      (rgb (colormap-ref copper-colormap x))
		      (r1 (list-ref rgb 0))
		      (g1 (list-ref rgb 1))
		      (b1 (list-ref rgb 2)))
		 (if (and (> n 2) (< x (- 1.0 (/ 1.0 n))) (or (cfneq r r1) (cfneq g g1) (cfneq b b1)))
		     (snd-display #__line__ ";copper size reset ~A: ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				  n x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	   (list 1024 256 2 512))
	  (set! (colormap-size) 512))
	
	(reset-hook! graph-hook)
	(clear-sincs)
	
	)))



;;; ---------------- test 8: clm ----------------

(if (not (provided? 'snd-moog.scm)) (load "moog.scm"))
(if (not (provided? 'snd-mixer.scm)) (load "mixer.scm"))
(if (not (provided? 'snd-frame.scm)) (load "frame.scm"))
(if (not (provided? 'snd-poly.scm)) (load "poly.scm"))
(if (not (provided? 'snd-analog-filter.scm)) (if (defined? 'gsl-roots) (load "analog-filter.scm")))
(if (not (provided? 'snd-bird.scm)) (load "bird.scm"))
(if (not (provided? 'snd-v.scm)) (load "v.scm"))
(if (not (provided? 'snd-numerics.scm)) (load "numerics.scm"))
(if (not (provided? 'snd-generators.scm)) (load "generators.scm"))

(def-clm-struct sa1 (freq 0.0 :type float) (coscar #f :type clm) (sincar #f :type clm) (dly #f :type clm) (hlb #f :type clm))

(define (snd-test-jc-reverb decay-dur low-pass volume amp-env)
  "(jc-reverb decay-dur low-pass volume amp-env) is the old Chowning reverberator: (jc-reverb 2.0 #f .1 #f)"
  (let* ((allpass1 (make-all-pass -0.700 0.700 1051))
	 (allpass2 (make-all-pass -0.700 0.700  337))
	 (allpass3 (make-all-pass -0.700 0.700  113))
	 (comb1 (make-comb 0.742 4799))
	 (comb2 (make-comb 0.733 4999))
	 (comb3 (make-comb 0.715 5399))
	 (comb4 (make-comb 0.697 5801))
	 (outdel1 (make-delay (round (* .013 (srate)))))
	 (dur (+ decay-dur (/ (frames) (srate))))
	 (envA (if amp-env (make-env :envelope amp-env :scaler volume :duration dur) #f)))
    (map-chan
     (let ((comb-sum 0.0)
	   (comb-sum-1 0.0)
	   (comb-sum-2 0.0)
	   (all-sums 0.0))
       (lambda (inval)
	 (let ((allpass-sum (all-pass allpass3 (all-pass allpass2 (all-pass allpass1 inval)))))
	   (set! comb-sum-2 comb-sum-1)
	   (set! comb-sum-1 comb-sum)
	   (set! comb-sum 
		 (+ (comb comb1 allpass-sum)
		    (comb comb2 allpass-sum)
		    (comb comb3 allpass-sum)
		    (comb comb4 allpass-sum)))
	   (if low-pass
	       (set! all-sums (+ (* .25 (+ comb-sum comb-sum-2)) (* .5 comb-sum-1)))
	       (set! all-sums comb-sum))
	   (+ inval
	      (if envA
		  (* (env envA) (delay outdel1 all-sums))
		  (* volume (delay outdel1 all-sums)))))))
     0 (round (* dur (srate))))))

;;; -------- scissor-tailed flycatcher
;;;
;;; mix a scissor-tailed flycatcher call into the current sound
;;; see bird.scm for lots more birds


(define (scissor begin-time) ; test 23 also
  "(scissor beg) is the scissor-tailed flycatcher"
  (let ((scissorf '(0 0  40 1  60 1  100 0)))
    (bigbird begin-time 0.05 1800 1800 .2 
	     scissorf 
	     '(0 0  25 1  75 1  100 0) 
	     '(1 .5  2 1  3 .5  4 .1  5 .01))))


(define (snd_test_8)
  
  ;; ----------------
  (define (bumpy)
    (let* ((x 0.0) 
	   (xi (/ 1.0 (frames)))
	   (start 0)
	   (end 1)
	   (scl (exp (/ 4.0 (- end start))))) ; normalize it
      (map-channel (lambda (y) 
		     (let ((val (if (or (<= x start) ; don't divide by zero
					(>= x end))
				    0.0
				    (* (exp (/ -1.0 (- x start))) 
				       (exp (/ -1.0 (- end x)))))))
		       (set! x (+ x xi))
		       (* scl val))))))
  
  ;; ----------------
  (define test-scanned-synthesis
    ;; check out scanned-synthesis
    (lambda (amp dur mass xspring damp)
      (let* ((size 256)
	     (x0 (make-vct size))	   
	     (x1 (make-vct size))	   
	     (x2 (make-vct size)))
	(do ((i 0 (+ 1 i)))
	    ((= i 12))
	  (let ((val (sin (/ (* 2 pi i) 12.0))))
	    (vct-set! x1 (+ i (- (/ size 4) 6)) val)))
	(let* ((gen1 (make-table-lookup 440.0 :wave x1))
	       (gen2 (make-table-lookup 440.0 :wave x2))
	       (recompute-samps 30) ;just a quick guess
	       (data (make-vct dur)))
	  (do ((i 0 (+ 1 i))
	       (k 0.0)
	       (kincr (/ 1.0 recompute-samps)))
	      ((or (c-g?) 
		   (= i dur)))
	    (if (>= k 1.0)
		(begin
		  (set! k 0.0)
		  (compute-uniform-circular-string size x0 x1 x2 mass xspring damp))
		(set! k (+ k kincr)))
	    (let ((g1 (table-lookup gen1))
		  (g2 (table-lookup gen2)))
	      (vct-set! data i (+ g2 (* k (- g1 g2))))))
	  (let ((curamp (vct-peak data)))
	    (vct-scale! data (/ amp curamp)))
	  (vct->channel data 0 dur)))))
  
  ;; (test-scanned-synthesis .1 10000 1.0 0.1 0.0)
  
  ;; ----------------
  (define* (array-interp-sound-diff snd chn)
    
    (define (envelope->vct e len)
      (let ((v (make-vct len))
	    (e (make-env e :length len)))
	(do ((i 0 (+ 1 i)))
	    ((= i len))
	  (vct-set! v i (env e)))
	v))
    
    (let ((tbl (envelope->vct (list 0.0 -1.0 1.0 1.0) 1001))
	  (curpos (edit-position snd chn)))
      (map-channel (lambda (y)
		     (let ((pos (+ 500 (* 500 y))))
		       (array-interp tbl pos 1000)))
		   0 #f snd chn)
      
      (let ((r (make-sampler 0 snd chn 1 curpos))
	    (mx 0.0))
	(scan-channel (lambda (y) 
			(set! mx (max mx (abs (- y (r))))))
		      0 #f snd chn)
	mx)))
  
  ;; ----------------
  (define (make-papoulis-window n)
    "(make-papoulis-window size) returns a papoulis window os the given size"
    (let ((v (make-vct n))
	  (n2 (/ n 2)))
      (do ((i (- n2) (+ i 1)))
	  ((= i n2))
	(let* ((ratio (/ i n))
	       (pratio (* 2 pi ratio)))
	  (vct-set! v (+ i n2) (+ (/ (abs (sin pratio)) pi)
				  (* (- 1.0 (* 2 (abs ratio)))
				     (cos pratio))))))
      v))
  
  ;; ----------------
  (define (make-dpss-window n w)
    "(make-dpss-window size w) returns a prolate spheriodal (slepian) window of the given size"
    ;; from Verma, Bilbao, Meng, "The Digital Prolate Spheroidal Window"
    ;; output checked using Julius Smith's dpssw.m, although my "w" is different
    (let* ((mat (make-mixer! n))
	   (cw (cos (* 2 pi w))))
      (do ((i 0 (+ i 1)))
	  ((= i n))
	(let ((n2 (- (* 0.5 (- n 1)) i))) 
	  (mixer-set! mat i i (* cw n2 n2))
	  (if (< i (- n 1))
	      (mixer-set! mat i (+ i 1) (* 0.5 (+ i 1) (- n 1 i))))
	  (if (> i 0)
	      (mixer-set! mat i (- i 1) (* 0.5 i (- n i))))))
      (let ((v (vector->vct (vector-ref (cadr (gsl-eigenvectors mat)) 0)))
	    (pk 0.0))
	;; sign of eigenvalue is arbitrary, and eigenvector is scaled to sum to 1.0
	;;   but we want peak of 1.0 to serve as fft window
	(do ((i 0 (+ i 1)))
	    ((= i n))
	  (if (> (abs (vct-ref v i)) (abs pk))
	      (set! pk (vct-ref v i)))) 
	(vct-scale! v (/ 1.0 pk)))))
  
  ;; ----------------
  (define (test-lpc)
    (define (make-sine n) 
      (let ((data (make-vct n 0.0))) 
	(do ((i 0 (+ 1 i))) 
	    ((= i n) data) 
	  (vct-set! data i (sin (* 2 pi (/ i n)))))))
    (define (make-sines n) 
      (let ((data (make-vct n 0.0))) 
	(do ((i 0 (+ 1 i))) 
	    ((= i n) data) 
	  (vct-set! data i (+ (sin (* 2 pi (/ i n)))
			      (* .25 (sin (* 4 pi (/ i n))))
			      (* .125 (sin (* 8 pi (/ i n)))))))))
    
    (let ((vals (lpc-predict (vct 0 1 2 3 4 5 6 7) 8 (lpc-coeffs (vct 0 1 2 3 4 5 6 7) 8 4) 4 2)))
      (if (not (vequal vals (vct 7.906 8.557)))
	  (snd-display #__line__ ";predict ramp: ~A" vals)))
    (let ((vals (lpc-predict (vct 0 1 2 3 4 5 6 7) 8 (lpc-coeffs (vct 0 1 2 3 4 5 6 7) 8 7) 7 2)))
      (if (not (vequal vals (vct 7.971 8.816))) 
	  (snd-display #__line__ ";predict ramp 1: ~A" vals)))
    (let ((vals (lpc-predict (vct 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15 
			     (lpc-coeffs (vct 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15 7) 7 5)))
      (if (not (vequal vals (vct 14.999 15.995 16.980 17.940 18.851)))
	  (snd-display #__line__ ";predict ramp 2: ~A" vals)))
    (let ((vals (lpc-predict (vct 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15 
			     (lpc-coeffs (vct 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) 15 14) 14 5)))
      (if (not (vequal vals (vct 15.000 16.000 16.998 17.991 18.971)))
	  (snd-display #__line__ ";predict ramp 3: ~A" vals)))
    (let ((vals (lpc-predict (make-sine 16) 16 (lpc-coeffs (make-sine 16) 16 8) 8 2)))
      (if (not (vequal vals (vct 0.000 0.383)))
	  (snd-display #__line__ ";predict sine: ~A" vals)))
    (let ((vals (lpc-predict (make-sine 16) 16 (lpc-coeffs (make-sine 16) 16 8) 8 8)))
      (if (not (vequal vals (vct 0.000 0.383 0.707 0.924 1.000 0.924 0.707 0.383)))
	  (snd-display #__line__ ";predict sine 1: ~A" vals)))
    (let ((vals (lpc-predict (make-sines 32) 32 (lpc-coeffs (make-sines 32) 32 8) 8 8)))
      (if (not (vequal vals (vct 0.000 0.379 0.686 0.880 0.970 1.001 1.022 1.053)))
	  (snd-display #__line__ ";predict sines: ~A" vals)))
    (let ((vals (lpc-predict (make-sines 32) 32 (lpc-coeffs (make-sines 32) 32 16) 16 8)))
      (if (and (not (vequal vals (vct 0.000 0.379 0.684 0.876 0.961 0.987 1.006 1.046)))
	       (not (vequal vals (vct 0.000 0.379 0.685 0.876 0.961 0.985 0.998 1.029)))) ; if --with-doubles
	  (snd-display #__line__ ";predict sines 1: ~A" vals)))
    (let ((vals (lpc-predict (make-sines 32) 32 (lpc-coeffs (make-sines 32) 32 30) 30 4)))
      (if (and (not (vequal vals (vct 0.000 0.379 0.685 0.878)))
	       (not (vequal vals (vct 0.000 0.379 0.684 0.875)))) ; double vcts
	  (snd-display #__line__ ";predict sines 2: ~A" vals)))
    (let ((vals (lpc-predict (make-sines 64) 64 (lpc-coeffs (make-sines 64) 64 32) 32 8)))
      (if (not (vequal vals (vct 0.000 0.195 0.379 0.545 0.684 0.795 0.875 0.927)))
	  (snd-display #__line__ ";predict sines 3: ~A" vals))))
  
  ;; ----------------
  (define (test-unclip-channel)
    (let ((ind (new-sound "test.snd" mus-next mus-lfloat 22050 2 "unclip-channel test" 1)))
      (set! (sync ind) 1)
      
      (mix "oboe.snd" 0 0 ind 0 #f)
      (mix "oboe.snd" 0 0 ind 1 #f)
      (let ((scl (/ 1.01 (maxamp ind 0)))
	    (dur (frames ind 0)))
	(scale-channel scl 0 dur ind 0)
	(scale-channel scl 0 dur ind 1))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 20)) (snd-display #__line__ ";unclip-channel 0 oboe clips: ~A" clips))
	(if (not (= lmax 1)) (snd-display #__line__ ";unclip-channel 0 oboe max len: ~A" lmax))
	(if (fneq umax .999) (snd-display #__line__ ";unclip-channel 0 oboe maxamp: ~A" umax)))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (e (make-env '(0 0 1 .8 1.5 1.0 2.0 1.0 2.5 .8 3.5 0) :length 101))
	    (o (make-oscil 1000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* 1.05 (env e) (oscil o))))
	(vct->channel data 0 100 ind 0)
	(vct->channel data 0 100 ind 1))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 1 sine clips: ~A" clips))
	(if (not (= lmax 2)) (snd-display #__line__ ";unclip-channel 1 sine max len: ~A" lmax))
	(if (fneq umax .999) (snd-display #__line__ ";unclip-channel 1 sine maxamp: ~A" umax)))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (e (make-env '(0 0 1 .8 1.75 1.0 2.0 1.0 2.25 .8 3.5 0) :length 101))
	    (o (make-oscil 1000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* 1.1 (env e) (oscil o))))
	(vct->channel data 0 100 ind 0)
	(vct->channel data 0 100 ind 1))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 2 sine clips: ~A" clips))
	(if (not (= lmax 3)) (snd-display #__line__ ";unclip-channel 2 sine max len: ~A" lmax))
	(if (fneq umax .999) (snd-display #__line__ ";unclip-channel 2 sine maxamp: ~A" umax)))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (e (make-env '(0 0 1 .8 1.85 1.0 2.0 1.0 2.15 .8 3.5 0) :length 101))
	    (o1 (make-oscil 1000))
	    (o2 (make-oscil 2000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* 1.2 (env e) (+ (* .75 (oscil o1)) (* .25 (oscil o2))))))
	(vct->channel data 0 100 ind 0)
	(vct->channel data 0 100 ind 1))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 3 sine clips: ~A" clips))
	(if (not (= lmax 1)) (snd-display #__line__ ";unclip-channel 3 sine max len: ~A" lmax))
	(if (fneq umax .999) (snd-display #__line__ ";unclip-channel 3 sine maxamp: ~A" umax)))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (e (make-env '(0 0 40 .75 45 1.0 50 1.25 55 1.0 60 .75 100 0.0) :length 101))
	    (o1 (make-oscil 1000))
	    (o2 (make-oscil 2000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* 1.5 (env e) (+ (* .75 (oscil o1)) (* .25 (oscil o2))))))
	(vct->channel data 0 100 ind 0)
	(vct->channel data 0 100 ind 1))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 4 sine clips: ~A" clips))
	(if (not (= lmax 4)) (snd-display #__line__ ";unclip-channel 4 sine max len: ~A" lmax))
	(if (fneq umax .999) (snd-display #__line__ ";unclip-channel 4 sine maxamp: ~A" umax)))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (o1 (make-oscil 1000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* .25 (oscil o1))))
	(let ((true-max (vct-peak data)))
	  (vct-set! data 50 (+ (vct-ref data 50) 1.25))
	  (vct->channel data 0 100 ind 0)
	  (vct->channel data 0 100 ind 1)
	  
	  (let* ((vals (unclip-channel ind 1))
		 (umax (list-ref vals 1))
		 (clips (list-ref vals 3))
		 (lmax (list-ref vals 5)))
	    (if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 5 click clips: ~A" clips))
	    (if (not (= lmax 1)) (snd-display #__line__ ";unclip-channel 5 click max len: ~A" lmax))
	    (if (fneq umax true-max) (snd-display #__line__ ";unclip-channel 5 click maxamp: ~A ~A" umax true-max)))))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (o1 (make-oscil 1000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* .25 (oscil o1))))
	(let ((true-max (vct-peak data)))
	  (do ((i 49 (+ 1 i)))
	      ((= i 51))
	    (vct-set! data i (+ (vct-ref data i) 1.25)))
	  (vct->channel data 0 100 ind 0)
	  (vct->channel data 0 100 ind 1)
	  
	  (let* ((vals (unclip-channel ind 1))
		 (umax (list-ref vals 1))
		 (clips (list-ref vals 3))
		 (lmax (list-ref vals 5)))
	    (if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 6 click clips: ~A" clips))
	    (if (not (= lmax 2)) (snd-display #__line__ ";unclip-channel 6 click max len: ~A" lmax))
	    (if (fneq umax true-max) (snd-display #__line__ ";unclip-channel 6 click maxamp: ~A ~A" umax true-max)))))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (o1 (make-oscil 1000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* .25 (oscil o1))))
	(let ((true-max (vct-peak data)))
	  (do ((i 45 (+ 1 i)))
	      ((= i 55))
	    (vct-set! data i (+ (vct-ref data i) 1.25)))
	  (vct->channel data 0 100 ind 0)
	  (vct->channel data 0 100 ind 1)
	  
	  (let* ((vals (unclip-channel ind 1))
		 (umax (list-ref vals 1))
		 (clips (list-ref vals 3))
		 (lmax (list-ref vals 5)))
	    (if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 7 click clips: ~A" clips))
	    (if (not (= lmax 10)) (snd-display #__line__ ";unclip-channel 7 click max len: ~A" lmax))
	    (if (fneq umax true-max) (snd-display #__line__ ";unclip-channel 7 click maxamp: ~A ~A" umax true-max)))))
      
      (revert-sound ind)
      (let ((data (make-vct 100 0.0))
	    (o1 (make-oscil 1000))
	    (o2 (make-oscil 2000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 100) data) 
	  (vct-set! data i (* .25 (+ (oscil o1) (oscil o2)))))
	(let ((true-max (vct-peak data)))
	  (do ((i 45 (+ 1 i)))
	      ((= i 55))
	    (vct-set! data i (+ (vct-ref data i) 1.25)))
	  (vct->channel data 0 100 ind 0)
	  (vct->channel data 0 100 ind 1)
	  
	  (let* ((vals (unclip-channel ind 1))
		 (umax (list-ref vals 1))
		 (clips (list-ref vals 3))
		 (lmax (list-ref vals 5)))
	    (if (not (= clips 1)) (snd-display #__line__ ";unclip-channel 8 click clips: ~A" clips))
	    (if (not (= lmax 10)) (snd-display #__line__ ";unclip-channel 8 click max len: ~A" lmax))
	    (if (fneq umax true-max) (snd-display #__line__ ";unclip-channel 8 click maxamp: ~A ~A" umax true-max)))))
      
      (revert-sound ind)
      (let ((data (make-vct 200 0.0))
	    (o1 (make-oscil 1000))
	    (o2 (make-oscil 2000)))
	(do ((i 0 (+ 1 i))) 
	    ((= i 200) data) 
	  (vct-set! data i (* .25 (+ (oscil o1) (oscil o2)))))
	(let ((true-max (vct-peak data)))
	  (do ((i 45 (+ 1 i)))
	      ((= i 55))
	    (vct-set! data i (+ (vct-ref data i) 2.0)))
	  (do ((i 75 (+ 1 i)))
	      ((= i 85))
	    (vct-set! data i (+ (vct-ref data i) 2.0)))
	  (vct->channel data 0 200 ind 0)
	  (vct->channel data 0 200 ind 1)
	  
	  (let* ((vals (unclip-channel ind 1))
		 (umax (list-ref vals 1))
		 (clips (list-ref vals 3))
		 (lmax (list-ref vals 5)))
	    (if (not (= clips 2)) (snd-display #__line__ ";unclip-channel 9 collision clips: ~A" clips))
	    (if (not (= lmax 10)) (snd-display #__line__ ";unclip-channel 9 collision max len: ~A" lmax))
	    (if (fneq umax true-max) (snd-display #__line__ ";unclip-channel 9 collision maxamp: ~A ~A" umax true-max)))))
      
      (revert-sound ind)
      (mix "oboe.snd" 0 0 ind 0 #f)
      (mix "oboe.snd" 0 0 ind 1 #f)
      (let ((scl (/ 1.01 (maxamp ind 0)))
	    (dur (frames ind 0)))
	(do ((i 0 (+ 1 i))) ((= i 2))
	  (map-channel (lambda (uy) (let ((y (* uy scl))) (if (> y 1.0) 1.0 (if (< y -1.0) -1.0 y)))) 0 dur ind i)))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 20)) (snd-display #__line__ ";unclip-channel 10 oboe clips: ~A" clips))
	(if (not (= lmax 1)) (snd-display #__line__ ";unclip-channel 10 oboe max len: ~A" lmax))
	(if (fneq umax 0.999) (snd-display #__line__ ";unclip-channel 10 oboe maxamp: ~A" umax)))
      
      (revert-sound ind)
      (mix "oboe.snd" 0 0 ind 0 #f)
      (mix "oboe.snd" 0 0 ind 1 #f)
      (let ((scl (/ 1.05 (maxamp ind 0)))
	    (dur (frames ind 0)))
	(do ((i 0 (+ 1 i))) ((= i 2))
	  (map-channel (lambda (uy) (let ((y (* uy scl))) (if (> y 1.0) 1.0 (if (< y -1.0) -1.0 y)))) 0 dur ind i)))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 217)) (snd-display #__line__ ";unclip-channel 11 oboe clips: ~A" clips))
	(if (not (= lmax 2)) (snd-display #__line__ ";unclip-channel 11 oboe max len: ~A" lmax))
	(if (fneq umax 0.999) (snd-display #__line__ ";unclip-channel 11 oboe maxamp: ~A" umax)))
      
      (revert-sound ind)
      (mix "oboe.snd" 0 0 ind 0 #f)
      (mix "oboe.snd" 0 0 ind 1 #f)
      (let* ((scl (/ 1.2 (maxamp ind 0)))
	     (dur (frames ind 0)))
	(do ((i 0 (+ 1 i))) ((= i 2))
	  (let ((e (make-env (list 0 0 .48 (/ scl 2) .5 scl .52 (/ scl 2) 1.0 0) :length dur)))
	    (map-channel (lambda (uy) (let ((y (* uy (env e)))) (if (> y 1.0) 1.0 (if (< y -1.0) -1.0 y)))) 0 dur ind i))))
      
      (let* ((vals (unclip-channel ind 1))
	     (umax (list-ref vals 1))
	     (clips (list-ref vals 3))
	     (lmax (list-ref vals 5)))
	(if (not (= clips 28)) (snd-display #__line__ ";unclip-channel 12 oboe clips: ~A" clips))
	(if (not (= lmax 3)) (snd-display #__line__ ";unclip-channel 12 oboe max len: ~A" lmax))
	(if (fneq umax 0.999) (snd-display #__line__ ";unclip-channel 12 oboe maxamp: ~A" umax)))
      
      (close-sound ind)))
  
  ;; ----------------
  (define (analog-filter-tests)
    
    (define (sweep->bins flt bins)
      (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 #f 22050)))
	(let ((phase 0.0)
	      (freq 0.0)
	      (incr (/ pi 22050)))
	  (map-channel 
	   (lambda (y)
	     (let ((val (sin phase))) 
	       (set! phase (+ phase freq)) 
	       (set! freq (+ freq incr))
	       (* .5 val)))))
	(map-channel flt)
	(let* ((mx (maxamp))
	       (resp (make-vct bins))
	       (size (round (/ 22050 bins))))
	  (do ((i 0 (+ 1 i)))
	      ((= i bins))
	    (let ((data (channel->vct (* i size) size)))
	      (vct-set! resp i (vct-peak data))))
	  (close-sound ind)
	  (list mx resp))))
    
    (define (filter-response-max f1)
      (let ((mx 0.0)
	    (signal 1.0))
	(do ((i 0 (+ 1 i)))
	    ((= i 1000))
	  (set! mx (max mx (abs (f1 signal))))
	  (set! signal 0.0))
	mx))
    
    (define (filter-equal? f1 f2) ; equalp in clm2xen is too restrictive
      (and (= (mus-order f1) (mus-order f2))
	   (vequal (mus-xcoeffs f1) (mus-xcoeffs f2))
	   (vequal (mus-ycoeffs f1) (mus-ycoeffs f2))))
    
    ;; ---------------- butterworth tests ----------------
    
    (let ((poles (list (vct 1.000 1.414 1.000) ; numerous references provide these tables (y[0] is ignored)
		       (vct 1.000 1.848 1.000 1.000 0.765 1.000)
		       (vct 1.000 1.932 1.000 1.000 1.414 1.000 1.000 0.518 1.000)
		       (vct 1.000 1.962 1.000 1.000 1.663 1.000 1.000 1.111 1.000 1.000 0.390 1.000)
		       (vct 1.000 1.975 1.000 1.000 1.782 1.000 1.000 1.414 1.000 1.000 0.908 1.000 1.000 0.313 1.000))))
      (do ((i 2 (+ i 2))
	   (k 0 (+ 1 k)))
	  ((>= i 12))
	(let ((vals (butterworth-prototype i)))
	  (if (not (vequal (cadr vals) (list-ref poles k)))
	      (snd-display #__line__ ";butterworth prototype poles ~A: ~A (~A)" i (cadr vals) (list-ref poles k)))
	  (let ((zeros (make-vct (* (+ k 1) 3))))
	    (do ((j 2 (+ j 3)))
		((>= j (* (+ k 1) 3)))
	      (vct-set! zeros j 1.0))
	    (if (not (vequal (car vals) zeros))
		(snd-display #__line__ ";butterworth prototype zeros ~A: ~A (~A)" i (car vals) zeros)))))
      (do ((cutoff .1 (+ cutoff .1))
	   (m 0 (+ 1 m)))
	  ((= m 3))
	(do ((i 2 (+ i 2))
	     (k 1 (+ k 1)))
	    ((= i 16))
	  (let ((local (make-butterworth-lowpass i cutoff))
		(dsp (make-butter-lp k (* (mus-srate) cutoff))))
	    (if (not (filter-equal? local dsp))
		(snd-display #__line__ ";butterworth lowpass ~A ~A ~A" cutoff local dsp)))
	  (let ((local (make-butterworth-highpass i cutoff))
		(dsp (make-butter-hp k (* (mus-srate) cutoff))))
	    (if (not (filter-equal? local dsp))
		(snd-display #__line__ ";butterworth highpass ~A ~A ~A" cutoff local dsp)))))
      
      (let ((ind (open-sound "oboe.snd")))
	(let ((hummer (make-eliminate-hum 550))) 
	  (map-channel (lambda (x) (eliminate-hum hummer x))))
	(let ((peaker (make-peaking-2 500 1000 1.0)))
	  (map-channel peaker))
	(map-channel (chordalize))
	(close-sound ind))
      
      (let* ((f1 (make-butterworth-lowpass 8 .1))
	     (vals (sweep->bins f1 10)))
	(if (fneq (car vals) .5) (snd-display #__line__ ";butterworth lp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.500 0.500 0.359 0.014 0.001 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";butterworth lp 8 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-lowpass 12 .25))
	     (vals (sweep->bins f1 10)))
	(if (fneq (car vals) .5) (snd-display #__line__ ";butterworth lp 12 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.499 0.358 0.010 0.000 0.000 0.000)))
	    (snd-display #__line__ ";butterworth lp 12 .25 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-lowpass 10 .4))
	     (vals (sweep->bins f1 10)))
	(if (fneq (car vals) .5) (snd-display #__line__ ";butterworth lp 10 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.499 0.361 0.001)))
		 (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.499 0.360 0.002))))
	    (snd-display #__line__ ";butterworth lp 10 .4 spect: ~A" (cadr vals))))
      
      (do ((i 2 (+ i 2)))
	  ((= i 12))
	(do ((j .1 (+ j .1)))
	    ((>= j .45))
	  (let* ((f1 (make-butterworth-lowpass i j))
		 (mx (filter-response-max f1)))
	    (if (> mx 1.0)
		(snd-display #__line__ ";butter low max ~A ~A: ~A" i j mx)))))
      
      (let* ((f1 (make-butterworth-highpass 8 .1))
	     (vals (sweep->bins f1 10)))
	(if (fneq (car vals) .5) (snd-display #__line__ ";butterworth hp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.001 0.348 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.500)))
	    (snd-display #__line__ ";butterworth hp 8 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-highpass 12 .25))
	     (vals (sweep->bins f1 10)))
	(if (fneq (car vals) .5) (snd-display #__line__ ";butterworth hp 12 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.011 0.348 0.500 0.500 0.500 0.500 0.500)))
	    (snd-display #__line__ ";butterworth hp 12 .25 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-highpass 10 .4))
	     (vals (sweep->bins f1 10)))
	(if (fneq (car vals) .5) (snd-display #__line__ ";butterworth hp 10 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.005 0.343 0.501 0.501)))
	    (snd-display #__line__ ";butterworth hp 10 .4 spect: ~A" (cadr vals))))
      
      (let* ((f1 (make-butterworth-bandpass 4 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";butterworth bp 4 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.028 0.350 0.481 0.479 0.346 0.132 0.038 0.009 0.002 0.000)))
	    (snd-display #__line__ ";butterworth bp 4 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-bandpass 12 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";butterworth bp 12 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.006 0.317 0.501 0.500 0.358 0.009 0.000 0.000 0.000 0.000)))
		 (not (vequal1 (cadr vals) (vct 0.012 0.319 0.501 0.500 0.358 0.009 0.000 0.000 0.000 0.000)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.323 0.501 0.500 0.358 0.009 0.000 0.000 0.000 0.000))))
	    (snd-display #__line__ ";butterworth bp 12 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-bandpass 8 .3 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";butterworth bp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.003 0.034 0.344 0.499 0.499 0.353 0.002)))
	    (snd-display #__line__ ";butterworth bp 8 .3 .4 spect: ~A" (cadr vals))))
      
      (do ((i 2 (+ i 2)))
	  ((= i 12))
	(do ((j .1 (+ j .1)))
	    ((>= j .45))
	  (let* ((f1 (make-butterworth-highpass i j))
		 (mx (filter-response-max f1)))
	    (if (> mx 1.0)
		(snd-display #__line__ ";butter high max ~A ~A: ~A" i j mx)))))
      
      (let* ((f1 (make-butterworth-bandstop 4 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";butterworth bs 4 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.500 0.500 0.347 0.339 0.481 0.499 0.500 0.500 0.500 0.500)))
	    (snd-display #__line__ ";butterworth bs 4 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-bandstop 12 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";butterworth bs 12 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.503 0.503 0.364 0.334 0.500 0.500 0.500 0.500 0.500 0.500)))
		 (not (vequal1 (cadr vals) (vct 0.502 0.503 0.365 0.334 0.500 0.500 0.500 0.500 0.500 0.500)))
		 (not (vequal1 (cadr vals) (vct 0.500 0.500 0.365 0.334 0.500 0.500 0.500 0.500 0.500 0.500))))
	    (snd-display #__line__ ";butterworth bs 12 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-butterworth-bandstop 8 .3 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";butterworth bs 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.500 0.498 0.354 0.332 0.500 0.500)))
	    (snd-display #__line__ ";butterworth bs 8 .3 .4 spect: ~A" (cadr vals))))
      
      
      ;; ---------------- Chebyshev ----------------
      
      ;; ripple .01 .1 1 for 2..10 even
      
      (let ((poles-01 (list (vct 1.000 4.456 10.426)
			    (vct 1.000 0.822 2.006 1.000 1.984 1.299)
			    (vct 1.000 0.343 1.372 1.000 0.937 0.939 1.000 1.280 0.506)
			    (vct 1.000 0.189 1.196 1.000 0.537 0.925 1.000 0.804 0.542 1.000 0.948 0.272)
			    (vct 1.000 0.119 1.121 1.000 0.347 0.940 1.000 0.540 0.646 1.000 0.680 0.352 1.000 0.754 0.170)))
	    (zeros    (list (vct 0.000 0.000 1.000)
			    (vct 0.000 0.000 0.250 0.000 0.000 1.000)
			    (vct 0.000 0.000 0.062 0.000 0.000 1.000 0.000 0.000 1.000)
			    (vct 0.000 0.000 0.016 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 1.000)
			    (vct 0.000 0.000 0.004 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 1.000)))
	    (poles-1  (list (vct 1.000 2.372 3.314)
			    (vct 1.000 0.528 1.330 1.000 1.275 0.623)
			    (vct 1.000 0.229 1.129 1.000 0.627 0.696 1.000 0.856 0.263)
			    (vct 1.000 0.128 1.069 1.000 0.364 0.799 1.000 0.545 0.416 1.000 0.643 0.146)
			    (vct 1.000 0.082 1.044 1.000 0.237 0.862 1.000 0.369 0.568 1.000 0.465 0.274 1.000 0.515 0.092)))
	    (poles-10 (list (vct 1.000 1.098 1.103)
			    (vct 1.000 0.279 0.987 1.000 0.674 0.279)
			    (vct 1.000 0.124 0.991 1.000 0.340 0.558 1.000 0.464 0.125)
			    (vct 1.000 0.070 0.994 1.000 0.199 0.724 1.000 0.298 0.341 1.000 0.352 0.070)
			    (vct 1.000 0.045 0.996 1.000 0.130 0.814 1.000 0.203 0.521 1.000 0.255 0.227 1.000 0.283 0.045))))
	(do ((i 2 (+ i 2))
	     (k 0 (+ 1 k)))
	    ((>= i 12))
	  (let ((vals (chebyshev-prototype i .01)))
	    (if (not (vequal1 (cadr vals) (list-ref poles-01 k)))
		(snd-display #__line__ ";chebyshev prototype .01 poles ~A: ~A (~A)" i (cadr vals) (list-ref poles-01 k))))
	  (let ((vals (chebyshev-prototype i .1)))
	    (if (not (vequal1 (cadr vals) (list-ref poles-1 k)))
		(snd-display #__line__ ";chebyshev prototype .1 poles ~A: ~A (~A)" i (cadr vals) (list-ref poles-1 k))))
	  (let ((vals (chebyshev-prototype i)))
	    (if (not (vequal1 (cadr vals) (list-ref poles-10 k)))
		(snd-display #__line__ ";chebyshev prototype 1 poles ~A: ~A (~A)" i (cadr vals) (list-ref poles-10 k)))
	    (if (not (vequal (car vals) (list-ref zeros k)))
		(snd-display #__line__ ";chebyshev prototype .01 zeros ~A: ~A (~A)" i (car vals) (list-ref zeros k))))))
      
      (let* ((f1 (make-chebyshev-lowpass 8 .1))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";chebyshev lp 8 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.508 0.512 0.468 0.001 0.000 0.000 0.000 0.000 0.000 0.000)))
		 (not (vequal1 (cadr vals) (vct 0.507 0.512 0.467 0.001 0.000 0.000 0.000 0.000 0.000 0.000)))
		 (not (vequal1 (cadr vals) (vct 0.508 0.513 0.469 0.001 0.000 0.000 0.000 0.000 0.000 0.000)))
                 (not (vequal1 (cadr vals) (vct 0.509 0.508 0.465 0.001 0.000 0.000 0.000 0.000 0.000 0.000))))
	    (snd-display #__line__ ";chebyshev lp 8 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-lowpass 12 .25))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";chebyshev lp 12 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.509 0.500 0.508 0.508 0.507 0.413 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";chebyshev lp 12 .25 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-lowpass 10 .4))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";chebyshev lp 10 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.465 0.493 0.509 0.508 0.477 0.507 0.508 0.507 0.431 0.000)))
	    (snd-display #__line__ ";chebyshev lp 10 .4 spect: ~A" (cadr vals))))
      
      (do ((i 2 (+ i 2)))
	  ((= i 10))
	(do ((j .1 (+ j .1)))
	    ((>= j .45))
	  (let* ((f1 (make-chebyshev-lowpass i j))
		 (mx (filter-response-max f1)))
	    (if (> mx 1.0)
		(snd-display #__line__ ";cheby low max ~A ~A: ~A" i j mx)))))
      
      (let* ((f1 (make-chebyshev-lowpass 8 .1 .01))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .49) (snd-display #__line__ ";chebyshev lp 8 .1 .01 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.492 0.491 0.483 0.006 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";chebyshev lp 8 .1 .01 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-lowpass 12 .25 .1))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .49) (snd-display #__line__ ";chebyshev lp 12 .1 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.488 0.488 0.488 0.488 0.487 0.403 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";chebyshev lp 12 .25 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-lowpass 10 .4 .001))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .49) (snd-display #__line__ ";chebyshev lp 10 .001 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.497 0.497 0.497 0.497 0.497 0.497 0.497 0.497 0.488 0.000)))
	    (snd-display #__line__ ";chebyshev lp 10 .4 .001 spect: ~A" (cadr vals))))
      
      (let* ((f1 (make-chebyshev-highpass 8 .1))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .55) (snd-display #__line__ ";chebyshev hp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.341 0.551 0.509 0.466 0.501 0.509 0.505 0.481 0.461)))
	    (snd-display #__line__ ";chebyshev hp 8 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-highpass 12 .25))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .55) (snd-display #__line__ ";chebyshev hp 12 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.299 0.554 0.509 0.509 0.500 0.509)))
	    (snd-display #__line__ ";chebyshev hp 12 .25 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-highpass 10 .4))
	     (vals (sweep->bins f1 10)))
	(if (and (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.297 0.786 0.677)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.301 0.788 0.660)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.322 0.861 0.724)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.262 0.571 0.509))))
	    (snd-display #__line__ ";chebyshev hp 10 .4 spect: ~A" (cadr vals))))
      
      (let* ((f1 (make-chebyshev-highpass 8 .1 .01))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .49) (snd-display #__line__ ";chebyshev hp 8 .1 .01 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.498 0.498 0.492 0.491 0.492 0.492 0.492 0.491 0.491)))
	    (snd-display #__line__ ";chebyshev hp 8 .1 .01 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-highpass 12 .25 .1))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";chebyshev hp 12 .1 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.453 0.516 0.489 0.489 0.488 0.488)))
	    (snd-display #__line__ ";chebyshev hp 12 .25 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-highpass 10 .4 .001))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .5) (snd-display #__line__ ";chebyshev hp 10 .001 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.002 0.501 0.504 0.504)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.002 0.503 0.505 0.504)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.002 0.503 0.501 0.497))))
	    (snd-display #__line__ ";chebyshev hp 10 .4 .001 spect: ~A" (cadr vals))))
      
      (do ((i 2 (+ i 2)))
	  ((= i 10))
	(do ((j .1 (+ j .1)))
	    ((>= j .45))
	  (let* ((f1 (make-chebyshev-highpass i j))
		 (mx (filter-response-max f1)))
	    (if (> mx 1.0)
		(snd-display #__line__ ";cheby high max ~A ~A: ~A" i j mx)))))
      
      (let* ((f1 (make-chebyshev-bandpass 4 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";chebyshev bp 4 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.009 0.449 0.509 0.505 0.442 0.065 0.013 0.003 0.000 0.000)))
	    (snd-display #__line__ ";chebyshev bp 4 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-bandpass 6 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";chebyshev bp 6 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.001 0.376 0.505 0.498 0.412 0.011 0.001 0.000 0.000 0.000)))
	    (snd-display #__line__ ";chebyshev bp 6 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-bandpass 8 .3 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";chebyshev bp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.002 0.363 0.517 0.513 0.433 0.000)))
	    (snd-display #__line__ ";chebyshev bp 8 .3 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-bandpass 8 .2 .2 .01))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";chebyshev bp 10 .2 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.015 0.483 0.482 0.021 0.001 0.000 0.000 0.000)))
	    (snd-display #__line__ ";chebyshev bp 10 .2 spect: ~A" (cadr vals))))
      
      (let* ((f1 (make-chebyshev-bandstop 4 .1 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";chebyshev bs 4 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.509 0.505 0.447 0.033 0.006 0.006 0.033 0.445 0.512 0.509)))
	    (snd-display #__line__ ";chebyshev bs 4 .1 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-bandstop 8 .1 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .51)) .05) (snd-display #__line__ ";chebyshev bs 8 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.508 0.512 0.468 0.001 0.000 0.000 0.001 0.345 0.551 0.507)))
		 (not (vequal1 (cadr vals) (vct 0.507 0.512 0.467 0.001 0.000 0.000 0.001 0.344 0.549 0.508)))
		 (not (vequal1 (cadr vals) (vct 0.508 0.513 0.469 0.001 0.000 0.000 0.001 0.345 0.552 0.508)))
		 (not (vequal1 (cadr vals) (vct 0.509 0.508 0.465 0.001 0.000 0.000 0.001 0.343 0.548 0.508))))
	    (snd-display #__line__ ";chebyshev bs 8 .1 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-chebyshev-bandstop 8 .1 .4 .01))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";chebyshev bs 8 .01 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.492 0.491 0.483 0.006 0.000 0.000 0.006 0.494 0.495 0.492)))
	    (snd-display #__line__ ";chebyshev bs 8 .1 .4 .01 spect: ~A" (cadr vals))))
      
      
      ;; ---------------- inverse-chebyshev ----------------
      
      (let* ((f1 (make-inverse-chebyshev-lowpass 8 .1))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev lp 8 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.501 0.496 0.001 0.000 0.001 0.000 0.000 0.000 0.000 0.001)))
		 (not (vequal1 (cadr vals) (vct 0.500 0.498 0.001 0.000 0.001 0.000 0.000 0.000 0.000 0.001))))
	    (snd-display #__line__ ";inverse-chebyshev lp 8 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-lowpass 12 .25))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev lp 12 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.496 0.001 0.001 0.001 0.001 0.001)))
	    (snd-display #__line__ ";inverse-chebyshev lp 12 .25 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-lowpass 10 .4))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev lp 10 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.497 0.001 0.001)))
		 (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.497 0.002 0.002))))
	    (snd-display #__line__ ";inverse-chebyshev lp 10 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-lowpass 10 .4 120))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev lp 10 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.501 0.501 0.501 0.501 0.501 0.500 0.345 0.007 0.000 0.000)))
	    (snd-display #__line__ ";inverse-chebyshev lp 10 .4 120 spect: ~A" (cadr vals))))
      
      (do ((i 2 (+ i 2)))
	  ((= i 10))
	(do ((j .1 (+ j .1)))
	    ((>= j .45))
	  (let* ((f1 (make-inverse-chebyshev-lowpass i j))
		 (mx (filter-response-max f1)))
	    (if (> mx 1.0)
		(snd-display #__line__ ";inv cheby low max ~A ~A: ~A" i j mx)))))
      
      (let* ((f1 (make-inverse-chebyshev-highpass 8 .1))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev hp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.001 0.001 0.440 0.505 0.505 0.503 0.502 0.501 0.501 0.501)))
	    (snd-display #__line__ ";inverse-chebyshev hp 8 .1 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-highpass 12 .25))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev hp 12 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.001 0.001 0.001 0.001 0.001 0.505 0.506 0.503 0.501 0.501)))
	    (snd-display #__line__ ";inverse-chebyshev hp 12 .25 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-highpass 10 .4))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev hp 10 .4 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.001 0.001 0.001 0.001 0.001 0.503 0.503)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.001 0.001 0.001 0.001 0.001 0.505 0.503)))
		 (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.001 0.001 0.001 0.001 0.001 0.509 0.504))))
	    (snd-display #__line__ ";inverse-chebyshev hp 10 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-highpass 10 .1 120))
	     (vals (sweep->bins f1 10)))
	(if (ffneq (car vals) .51) (snd-display #__line__ ";inverse-chebyshev hp 10 .1 120 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.007 0.328 0.502 0.502 0.502 0.501 0.501 0.501)))
	    (snd-display #__line__ ";inverse-chebyshev hp 10 .1 120 spect: ~A" (cadr vals))))
      
      (do ((i 2 (+ i 2)))
	  ((= i 10))
	(do ((j .1 (+ j .1)))
	    ((>= j .45))
	  (let* ((f1 (make-inverse-chebyshev-highpass i j))
		 (mx (filter-response-max f1)))
	    (if (> mx 1.0)
		(snd-display #__line__ ";inv cheby high max ~A ~A: ~A" i j mx)))))
      
      (let* ((f1 (make-inverse-chebyshev-bandpass 10 .1 .2))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bp 4 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.001 0.001 0.498 0.485 0.001 0.001 0.000 0.001 0.000 0.001)))
	    (snd-display #__line__ ";inverse-chebyshev bp 10 .1 .2 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-bandpass 10 .1 .2 30))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bp 6 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.026 0.025 0.509 0.505 0.020 0.016 0.012 0.016 0.011 0.016)))
		 (not (vequal1 (cadr vals) (vct 0.030 0.042 0.511 0.505 0.020 0.016 0.012 0.016 0.011 0.016)))
		 (not (vequal1 (cadr vals) (vct 0.022 0.017 0.511 0.505 0.020 0.016 0.012 0.016 0.011 0.016))))
	    (snd-display #__line__ ";inverse-chebyshev bp 10 .1 .2 30 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-bandpass 8 .1 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bp 8 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.001 0.001 0.440 0.506 0.505 0.503 0.502 0.434 0.001 0.001)))
	    (snd-display #__line__ ";inverse-chebyshev bp 8 .1 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-bandpass 8 .3 .4 40))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bp 10 .2 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.002 0.005 0.007 0.007 0.005 0.005 0.503 0.505 0.006 0.005)))
	    (snd-display #__line__ ";inverse-chebyshev bp 10 .2 spect: ~A" (cadr vals))))
      
      (let* ((f1 (make-inverse-chebyshev-bandstop 4 .1 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bs 4 max: ~A" (car vals)))
	(if (not (vequal1 (cadr vals) (vct 0.500 0.054 0.001 0.001 0.000 0.000 0.000 0.001 0.055 0.503)))
	    (snd-display #__line__ ";inverse-chebyshev bs 4 .1 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-bandstop 8 .1 .4))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bs 8 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.501 0.496 0.001 0.001 0.000 0.000 0.000 0.001 0.507 0.506)))
		 (not (vequal1 (cadr vals) (vct 0.506 0.328 0.000 0.000 0.000 0.000 0.000 0.000 0.268 0.511)))
		 (not (vequal1 (cadr vals) (vct 0.500 0.498 0.001 0.001 0.000 0.000 0.000 0.001 0.507 0.506))))
	    (snd-display #__line__ ";inverse-chebyshev bs 8 .1 .4 spect: ~A" (cadr vals))))
      (let* ((f1 (make-inverse-chebyshev-bandstop 8 .1 .4 90))
	     (vals (sweep->bins f1 10)))
	(if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";inverse-chebyshev bs 8 90 max: ~A" (car vals)))
	(if (and (not (vequal1 (cadr vals) (vct 0.505 0.325 0.000 0.000 0.000 0.000 0.000 0.000 0.270 0.506)))
		 (not (vequal1 (cadr vals) (vct 0.506 0.328 0.000 0.000 0.000 0.000 0.000 0.000 0.269 0.509)))
		 (not (vequal1 (cadr vals) (vct 0.501 0.327 0.000 0.000 0.000 0.000 0.000 0.000 0.268 0.506))))
	    (snd-display #__line__ ";inverse-chebyshev bs 8 .1 .4 90 spect: ~A" (cadr vals))))
      
      
      ;; ---------------- bessel ----------------
      
      ;; checked poly coeff tables, but the prototype has scaling built in
      
      (if (provided? 'gsl)
	  (begin
	    (let* ((f1 (make-bessel-lowpass 4 .1))
		   (vals (sweep->bins f1 10)))
	      (if (fneq (car vals) .5) (snd-display #__line__ ";bessel lp 4 .1 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.500 0.417 0.209 0.062 0.018 0.005 0.001 0.000 0.000 0.000)))
		  (snd-display #__line__ ";bessel lp 4 .1 spect: ~A" (cadr vals))))
	    
	    (let* ((f1 (make-bessel-lowpass 8 .1))
		   (vals (sweep->bins f1 10)))
	      (if (fneq (car vals) .5) (snd-display #__line__ ";bessel lp 8 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.499 0.365 0.116 0.010 0.001 0.000 0.000 0.000 0.000 0.000)))
		  (snd-display #__line__ ";bessel lp 8 .1 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-bessel-lowpass 12 .25))
		   (vals (sweep->bins f1 10)))
	      (if (fneq (car vals) .5) (snd-display #__line__ ";bessel lp 12 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.500 0.477 0.410 0.309 0.185 0.063 0.006 0.000 0.000 0.000)))
		  (snd-display #__line__ ";bessel lp 12 .25 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-bessel-lowpass 10 .4))
		   (vals (sweep->bins f1 10)))
	      (if (fneq (car vals) .5) (snd-display #__line__ ";bessel lp 10 max: ~A" (car vals)))
	      (if (and (not (vequal1 (cadr vals) (vct 0.500 0.498 0.491 0.479 0.458 0.423 0.364 0.259 0.086 0.001)))
		       (not (vequal1 (cadr vals) (vct 0.500 0.498 0.491 0.479 0.458 0.423 0.364 0.259 0.086 0.002))))
		  (snd-display #__line__ ";bessel lp 10 .4 spect: ~A" (cadr vals))))
	    
	    (do ((i 2 (+ i 2)))
		((= i 12))
	      (do ((j .1 (+ j .1)))
		  ((>= j .45))
		(let* ((f1 (make-bessel-lowpass i j))
		       (mx (filter-response-max f1)))
		  (if (> mx 1.0)
		      (snd-display #__line__ ";bess low max ~A ~A: ~A" i j mx)))))
	    
	    (let* ((f1 (make-bessel-highpass 8 .1))
		   (vals (sweep->bins f1 10)))
	      (if (fneq (car vals) .5) (snd-display #__line__ ";bessel hp 8 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.001 0.115 0.290 0.386 0.435 0.465 0.483 0.493 0.498 0.500)))
		  (snd-display #__line__ ";bessel hp 8 .1 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-bessel-highpass 12 .25))
		   (vals (sweep->bins f1 10)))
	      (if (fneq (car vals) .5) (snd-display #__line__ ";bessel hp 12 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.006 0.063 0.181 0.309 0.410 0.477 0.500)))
		  (snd-display #__line__ ";bessel hp 12 .25 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-bessel-highpass 10 .4))
		   (vals (sweep->bins f1 10)))
	      (if (ffneq (car vals) .5) (snd-display #__line__ ";bessel hp 10 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.004 0.084 0.343 0.499)))
		  (snd-display #__line__ ";bessel hp 10 .4 spect: ~A" (cadr vals))))
	    
	    (let* ((f1 (make-bessel-bandpass 4 .1 .2))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .245)) .05) (snd-display #__line__ ";bessel bp 4 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.023 0.176 0.245 0.244 0.179 0.085 0.031 0.008 0.001 0.000)))
		  (snd-display #__line__ ";bessel bp 4 .1 .2 spect: ~A" (cadr vals))))
	    
	    (let* ((f1 (make-bessel-bandstop 12 .1 .2))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .05) (snd-display #__line__ ";bessel bs 12 max: ~A" (car vals)))
	      (if (and (not (vequal1 (cadr vals) (vct 0.498 0.325 0.065 0.066 0.177 0.297 0.389 0.452 0.488 0.500)))
		       (not (vequal1 (cadr vals) (vct 0.499 0.324 0.065 0.066 0.177 0.297 0.389 0.452 0.488 0.500))))
		  (snd-display #__line__ ";bessel bs 12 .1 .2 spect: ~A" (cadr vals))))
	    
	    ;; ---------------- elliptic ----------------
	    
	    (let* ((f1 (make-elliptic-lowpass 8 .1))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic lp 8 max: ~A" (car vals)))
	      (if (and (not (vequal1 (cadr vals) (vct 0.500 0.515 0.379 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		       (not (vequal1 (cadr vals) (vct 0.500 0.509 0.385 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		       (not (vequal1 (cadr vals) (vct 0.499 0.498 0.373 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
		  (snd-display #__line__ ";elliptic lp 8 .1 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-lowpass 12 .25))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic lp 12 max: ~A" (car vals)))
	      (if (and (not (vequal1 (cadr vals) (vct 0.476 0.500 0.491 0.499 0.494 0.412 0.003 0.001 0.000 0.000)))
		       (not (vequal1 (cadr vals) (vct 0.476 0.500 0.491 0.499 0.494 0.561 0.004 0.000 0.000 0.000)))
		       (not (vequal1 (cadr vals) (vct 0.476 0.500 0.491 0.499 0.493 0.299 0.006 0.001 0.000 0.000))))
		  (snd-display #__line__ ";elliptic lp 12 .25 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-lowpass 4 .4))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic lp 4 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.447 0.453 0.462 0.477 0.494 0.500 0.497 0.496 0.445 0.003)))
		  (snd-display #__line__ ";elliptic lp 4 .4 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-lowpass 8 .1 .1))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic lp 8 .1 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.500 0.499 0.475 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		  (snd-display #__line__ ";elliptic lp 8 .1 .1 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-lowpass 8 .1 .1 90))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic lp 8 .1 90 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.500 0.499 0.475 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		  (snd-display #__line__ ";elliptic lp 8 .1 .1 90 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-lowpass 8 .25 .01 90))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic lp 8 .25 90 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.500 0.500 0.500 0.500 0.499 0.495 0.001 0.000 0.000 0.000)))
		  (snd-display #__line__ ";elliptic lp 8 .25 .1 90 spect: ~A" (cadr vals))))
	    
	    (let* ((f1 (make-elliptic-highpass 4 .1))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 4 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.004 0.438 0.516 0.499 0.502 0.495 0.478 0.463 0.453 0.447)))
		  (snd-display #__line__ ";elliptic hp 4 .1 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-highpass 12 .25))
		   (vals (sweep->bins f1 10)))
					;(if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 12 max: ~A" (car vals)))
	      (if (and (not (vequal1 (cadr vals) (vct 0.000 0.001 0.001 0.001 0.026 0.934 0.518 0.495 0.503 0.477)))
		       (not (vequal1 (cadr vals) (vct 0.000 0.001 0.001 0.001 0.033 1.185 0.519 0.495 0.503 0.477)))
		       (not (vequal1 (cadr vals) (vct 0.000 0.001 0.001 0.001 0.018 0.788 0.520 0.495 0.503 0.477))))
		  (snd-display #__line__ ";elliptic hp 12 .25 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-highpass 12 .25 .01 90))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 12 90 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.000 0.499 0.517 0.503 0.501 0.500 0.500)))
		  (snd-display #__line__ ";elliptic hp 12 .25 90 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-highpass 4 .4))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 4 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.001 0.001 0.002 0.023 0.447 0.515 0.502)))
		  (snd-display #__line__ ";elliptic hp 4 .4 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-highpass 8 .1 .1))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 8 .1 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.478 0.553 0.506 0.499 0.501 0.501 0.499 0.497 0.495)))
		  (snd-display #__line__ ";elliptic hp 8 .1 .1 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-highpass 8 .1 .1 90))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 8 .1 90 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.478 0.554 0.506 0.499 0.501 0.501 0.499 0.497 0.495)))
		  (snd-display #__line__ ";elliptic hp 8 .1 .1 90 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-highpass 8 .25 .01 90))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic hp 8 .25 90 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.000 0.000 0.000 0.001 0.516 0.517 0.507 0.503 0.501 0.500)))
		  (snd-display #__line__ ";elliptic hp 8 .25 .1 90 spect: ~A" (cadr vals))))
	    
	    (let* ((f1 (make-elliptic-bandpass 4 .1 .2 .1))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic bp 4 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.036 0.546 0.550 0.510 0.501 0.032 0.024 0.009 0.021 0.024)))
		  (snd-display #__line__ ";elliptic bp 4 .1 .2 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-bandpass 6 .1 .2 .1 90))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic bp 6 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.002 0.511 0.532 0.503 0.492 0.003 0.001 0.001 0.001 0.001)))
		  (snd-display #__line__ ";elliptic bp 6 .1 .2 90 spect: ~A" (cadr vals))))
	    
	    (let* ((f1 (make-elliptic-bandstop 4 .1 .3 .1))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic bs 4 max: ~A" (car vals)))
	      (if (not (vequal1 (cadr vals) (vct 0.499 0.502 0.498 0.037 0.050 0.540 0.544 0.527 0.526 0.521)))
		  (snd-display #__line__ ";elliptic bs 4 .1 .2 spect: ~A" (cadr vals))))
	    (let* ((f1 (make-elliptic-bandstop 8 .1 .3 .1 120))
		   (vals (sweep->bins f1 10)))
	      (if (> (abs (- (car vals) .5)) .1) (snd-display #__line__ ";elliptic bs 8 max: ~A" (car vals)))
	      (if (and (not (vequal1 (cadr vals) (vct 0.500 0.499 0.476 0.000 0.000 0.495 0.526 0.505 0.501 0.501)))
		       (not (vequal1 (cadr vals) (vct 0.500 0.499 0.475 0.000 0.000 0.495 0.526 0.505 0.501 0.501))))
		  (snd-display #__line__ ";elliptic bs 8 .1 .2 spect: ~A" (cadr vals))))
	    ))))
  
  (define (test-polyoid n)
    (let* ((res (with-sound (:channels 2 :clipped #f)
			    (let ((angle 0.0)
				  (incr (hz->radians 1.0))
				  (cur-phases (make-vct (* 3 n))))
			      (do ((i 0 (+ i 1))
				   (j 0 (+ j 3)))
				  ((= i n))
				(vct-set! cur-phases j (+ i 1))
				(vct-set! cur-phases (+ j 1) (/ 1.0 n))
				(vct-set! cur-phases (+ j 2) (random (* 2 pi))))
			      (let ((gen (make-polyoid 1.0 cur-phases)))
				(do ((i 0 (+ 1 i)))
				    ((= i 88200))
				  (let ((poly-sum 0.0)
					(sin-sum 0.0))
				    (do ((k 0 (+ 1 k)))
					((= k n))
				      (set! sin-sum (+ sin-sum (sin (+ (* (+ k 1) angle) (vct-ref cur-phases (+ (* 3 k) 2)))))))
				    (set! poly-sum (polyoid gen 0.0))
				    (set! angle (+ angle incr))
				    (outa i (/ sin-sum n))
				    (outb i poly-sum)))))))
	   (snd (find-sound res)))
      (channel-distance snd 0 snd 1)))
  
  (define (test-polyoid-run n)
    (let* ((res (with-sound (:channels 2 :clipped #f)
			    (let ((angle 0.0)
				  (incr (hz->radians 1.0))
				  (cur-phases (make-vct (* 3 n))))
			      (do ((i 0 (+ i 1))
				   (j 0 (+ j 3)))
				  ((= i n))
				(vct-set! cur-phases j (+ i 1))
				(vct-set! cur-phases (+ j 1) (/ 1.0 n))
				(vct-set! cur-phases (+ j 2) (random (* 2 pi))))
			      (let ((gen (make-polyoid 1.0 cur-phases)))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 88200))
				   (let ((poly-sum 0.0)
					 (sin-sum 0.0))
				     (do ((k 0 (+ 1 k)))
					 ((= k n))
				       (set! sin-sum (+ sin-sum (sin (+ (* (+ k 1) angle) (vct-ref cur-phases (+ (* 3 k) 2)))))))
				     (set! poly-sum (polyoid gen 0.0))
				     (set! angle (+ angle incr))
				     (outa i (/ sin-sum n))
				     (outb i poly-sum))))))))
	   (snd (find-sound res)))
      (channel-distance snd 0 snd 1)))
  
  ;; ----------------
  (define (poly-roots-tests)
    (letrec ((ceql (lambda (a b)
		     (if (null? a)
			 (null? b)
			 (if (null? b)
			     #f
			     (if (or (fneq (real-part (car a)) (real-part (car b)))
				     (fneq (imag-part (car a)) (imag-part (car b))))
				 #f
				 (ceql (cdr a) (cdr b))))))))
      
      ;; degree=0
      (let ((val (poly-roots (vct 0.0))))
	(if (not (null? val)) (snd-display #__line__ ";poly-roots 0.0: ~A" val)))
      (let ((val (poly-roots (vct 12.3))))
	(if (not (null? val)) (snd-display #__line__ ";poly-roots 12.3: ~A" val)))
      
      ;; degree 0 + x=0
      (let ((val (poly-roots (vct 0.0 1.0))))
	(if (not (ceql val (list 0.0))) (snd-display #__line__ ";poly-roots 0.0 1.0: ~A" val)))
      (let ((val (poly-roots (vct 0.0 0.0 0.0 121.0))))
	(if (not (ceql val (list 0.0 0.0 0.0))) (snd-display #__line__ ";poly-roots 0.0 0.0 0.0 121.0: ~A" val)))
      
      ;; degree=1
      (let ((val (poly-roots (vct -1.0 1.0))))
	(if (not (ceql val (list 1.0))) (snd-display #__line__ ";poly-roots -1.0 1.0: ~A" val)))
      (let ((val (poly-roots (vct -2.0 4.0))))
	(if (not (ceql val (list 0.5))) (snd-display #__line__ ";poly-roots -2.0 4.0: ~A" val)))
      (let ((val (poly-as-vector-roots (vector 0.0-i 1))))
	(if (not (ceql val (list -0.0+1.0i))) (snd-display #__line__ ";poly-roots: -i 1: ~A" val)))
      
      ;; linear x^n
      (let ((val (poly-roots (vct -1.0 0.0 0.0 0.0 1.0))))
	(if (and (not (ceql val (list 0.0-1.0i -1.0 0.0+1.0i 1.0)))
		 (not (ceql val (list 1.0 -1.0 0.0+1.0i -0.0-1.0i))))
	    (snd-display #__line__ ";poly-roots -1.0 0.0 0.0 0.0 1.0: ~A" val)))
      (let ((val (poly-roots (vct -16.0 0.0 0.0 0.0 1.0))))
	(if (and (not (ceql val (list 0.0-2.0i -2.0 0.0+2.0i 2.0)))
		 (not (ceql val (list 2.0 -2.0 0.0+2.0i -0.0-2.0i))))
	    (snd-display #__line__ ";poly-roots -16.0 0.0 0.0 0.0 1.0: ~A" val)))
      (let ((val (poly-roots (vct -32.0 0 0 0 0 0 0.5))))
	(if (not (ceql val (list 1.0-1.7320i -1.0-1.7320i -2.0 -1.0+1.7320i 1.0+1.7320i 2.0))) (snd-display #__line__ ";poly-roots 32 0 0 0 0 0 0.5: ~A" val)))
      
      ;; linear + x=0
      (let ((val (poly-roots (vct 0.0 -2.0 4.0))))
	(if (not (ceql val (list 0.0 0.5))) (snd-display #__line__ ";poly-roots 0.0 -2.0 4.0: ~A" val)))
      
      ;; degree=2
      (let ((val (poly-roots (vct -1.0 0.0 1.0))))
	(if (not (ceql val (list 1.0 -1.0))) (snd-display #__line__ ";poly-roots -1.0 0.0 1.0: ~A" val)))
      (let ((val (poly-roots (vct 15.0 -8.0 1.0))))
	(if (not (ceql val (list 5.0 3.0))) (snd-display #__line__ ";poly-roots 15.0 -8.0 1.0: ~A" val)))
      (let ((val (poly-roots (vct 1 -2 1))))
	(if (not (ceql val (list 1.0 1.0))) (snd-display #__line__ ";poly-roots 1 -2 1: ~A" val)))
      (let ((val (poly-as-vector-roots (vector -1 0.0+2i 1))))
	(if (not (ceql val (list 0.0-1.0i 0.0-1.0i))) (snd-display #__line__ ";poly-roots -1 2i 1: ~A" val)))
      (let ((val (poly-roots (vct 1 1 5))))
	(if (not (ceql val (list -0.1+0.43589i -0.1-0.43589i))) (snd-display #__line__ ";poly-roots 1 1 5: ~A" val)))
      
      ;; 2 + x=0
      (let ((val (poly-roots (vct 0.0 0.0 -1.0 0.0 1.0))))
	(if (not (ceql val (list 0.0 0.0 1.0 -1.0))) (snd-display #__line__ ";poly-roots 0.0 0.0 -1.0 0.0 1.0: ~A" val)))
      
      ;; quadratic in x^(n/2)
      (let ((vals (poly-roots (vct 1.0 0.0 -2.0 0.0 1.0))))
	(if (and (not (ceql vals (list -1.0 1.0 -1.0 1.0)))
		 (not (ceql vals (list 1.0 1.0 -1.0 -1.0))))
	    (snd-display #__line__ ";poly-roots 1 0 -2 0 1: ~A" vals)))
      (let ((vals (poly-roots (vct 64.0 0.0 0.0 -16.0 0.0 0.0 1.0))))
	(if (not (ceql vals (list -1.0-1.73205i -1.0+1.73205i 2.0 -1.0-1.73205i -1.0+1.73205i 2.0)))
	    (snd-display #__line__ ";poly-roots 64 0 0 -16 0 0 1: ~A" vals)))
      
      ;; degree=3
      (let ((val (poly-roots (vct -15.0 23.0 -9.0 1.0))))
	(if (not (ceql val (list 5.0 1.0 3.0))) (snd-display #__line__ ";poly-roots 5 1 3: ~A" val)))
      (let ((val (poly-roots (vct -126 -15 0 1))))
	(if (not (ceql val (list 6.0 -3.0+3.46410i -3.0-3.46410i))) (snd-display #__line__ ";poly-roots -126 -15 0 1: ~A" val)))
      
      (let ((val (poly-roots (vct -1 3 -3 1))))
	(if (not (ceql val (list 1.0 1.0 1.0))) (snd-display #__line__ ";poly-roots -1 3 -3 1: ~A" val))) 
      (let ((val (poly-roots (vct 1 -1 -1 1))))
	(if (and (not (ceql val (list 1.0 -1.0 1.0))) 
		 (not (ceql val (list -1.0 1.0 1.0))))
	    (snd-display #__line__ ";poly-roots 1 -1 1: ~A" val)))
      (let ((val (poly-roots (vct 2 -2 -2 2))))
	(if (and (not (ceql val (list 1.0 -1.0 1.0))) 
		 (not (ceql val (list -1.0 1.0 1.0))))
	    (snd-display #__line__ ";poly-roots 2 -2 -2 2: ~A" val)))
      
      ;; degree=4
					;      (let ((vals (poly-roots (vct -15 8 14 -8 1))))
					;	(if (not (ceql vals (list 5.0 3.0 1.0 -1.0))) (snd-display #__line__ ";poly-roots -15 8 14 -8 1: ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (poly* (vct 2 1) (vct -3 1)) (poly* (vct 8 1) (vct -9 1)))))))
					;	(if (not (ceql vals (list 9.0 3.0 -2.0 -8.0))) (snd-display #__line__ ";poly-roots 4(1): ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (poly* (vct .2 1) (vct -3 1)) (poly* (vct .8 1) (vct -9 1)))))))
					;	(if (not (ceql vals (list 9.0 3.0 -0.2 -0.8))) (snd-display #__line__ ";poly-roots 4(2): ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (poly* (vct .02 1) (vct -32 1)) (poly* (vct .8 1) (vct -9 1)))))))
					;	(if (not (ceql vals (list 32.0 9.0 -0.02 -0.8))) (snd-display #__line__ ";poly-roots 4(3): ~A" vals)))
      
      ;; degree>4
					;      (let ((vals (poly-roots (poly-reduce (poly* (vct 1 1) (poly* (poly* (vct 2 1) (vct -3 1)) (poly* (vct -1 1) (vct -2 1))))))))
					;	(if (not (ceql vals (list 3.0 2.0 -1.0 -2.0 1.0))) 
					;	    (snd-display #__line__ ";poly-roots n(1): ~A from ~A ~A ~A" 
					;			 vals 
					;			 (poly-reduce (poly* (vct 1 1) (poly* (poly* (vct 2 1) (vct -3 1)) (poly* (vct -1 1) (vct -2 1)))))
					;			 (mus-float-equal-fudge-factor) 
					;			 poly-roots-epsilon)))
      
					;      (let ((vals (poly-roots (poly-reduce (poly* (vct 1 1) (poly* (poly* (vct 2 1) (vct -3 1)) (poly* (vct 8 1) (vct -9 1))))))))
					;	(if (not (ceql vals (list 9.0 3.0 -2.0 -8.0 -1.0))) (snd-display #__line__ ";poly-roots n(2): ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (vct -1 0 1) (poly* (poly* (vct 9 1) (vct -3 1)) (poly* (vct -10 1) (vct -2 1))))))))
					;	(if (not (ceql vals (list 10.0 3.0 -1.0 -9.0 2.0 1.0))) (snd-display #__line__ ";poly-roots n(3): ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (vct -1 0 1) (poly* (poly* (vct -4 0 1) (vct -3 1)) (poly* (vct -10 1) (vct -9 0 1))))))))
					;	(if (not (ceql vals (list 10.0 3.0 -2.0 -3.0 -1.0 3.0 2.0 1.0))) (snd-display #__line__ ";poly-roots n(4): ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (vct -1 0 1) (poly* (poly* (vct -4 0 1) (vct -16 0 1)) (poly* (vct -25 0 1) (vct -9 0 1))))))))
					;	(if (not (ceql vals (list 5.0 -3.0 -4.0 -5.0 4.0 -2.0 3.0 -1.0 2.0 1.0))) (snd-display #__line__ ";poly-roots n(5): ~A" vals)))
					;      (let ((vals (poly-roots (poly-reduce (poly* (vct 1 1) (poly* (poly* (vct 2 1) (vct -3 1)) (poly* (vct 1 1) (vct -2 1))))))))
					;	(if (not (ceql vals (list 3.0 -1.0 -1.0 -2.0 2.0))) (snd-display #__line__ ";poly-roots n(6): ~A" vals)))
      (let ((vals (poly-roots (vct -64 0 0 0 0 0 1))))
	(if (not (ceql vals (list 0.999999999999999-1.73205080756888i -1.0-1.73205080756888i -2.0 -1.0+1.73205080756888i 1.0+1.73205080756888i 2.0)))
	    (snd-display #__line__ ";poly-roots 64 6: ~A" vals)))
      (let ((vals (poly-roots (vct 64 0 0 -16 0 0 1))))
	(if (not (ceql vals (list -1.0-1.73205080756888i -1.0+1.73205080756888i 2.0 -1.0-1.73205080756888i -1.0+1.73205080756888i 2.0)))
	    (snd-display #__line__ ";poly-roots 64 16 6: ~A" vals)))
      (do ((i 0 (+ 1 i))) ((= i 10)) (poly-roots (vct (random 1.0) (random 1.0) (random 1.0))))
      (do ((i 0 (+ 1 i))) ((= i 10)) (poly-roots (vct (mus-random 1.0) (mus-random 1.0) (mus-random 1.0))))
      
      (let ((vals1 (convolution (vct 1 2 3 0 0 0 0 0) (vct 1 2 3 0 0 0 0 0) 8))
	    (vals2 (poly* (vct 1 2 3 0) (vct 1 2 3 0))))
	(if (not (vequal vals1 vals2))
	    (snd-display #__line__ ";poly* convolve: ~A ~A" vals1 vals2)))
      
      
      (do ((i 0 (+ 1 i))) ((= i 10)) 
	(poly-as-vector-roots (vector (make-rectangular (mus-random 1.0) (mus-random 1.0)) 
				      (make-rectangular (mus-random 1.0) (mus-random 1.0)))))
      (do ((i 0 (+ 1 i))) ((= i 10)) 
	(poly-as-vector-roots (vector (make-rectangular (mus-random 1.0) (mus-random 1.0)) 
				      (make-rectangular (mus-random 1.0) (mus-random 1.0))
				      (make-rectangular (mus-random 1.0) (mus-random 1.0)))))
      
      (do ((i 0 (+ 1 i))) ((= i 10)) 
	(poly-roots (vct (mus-random 1.0) (mus-random 1.0) (mus-random 1.0) (mus-random 1.0))))
      
      (do ((i 0 (+ 1 i))) ((= i 10)) 
	(poly-as-vector-roots (vector (make-rectangular (mus-random 1.0) (mus-random 1.0)) 
				      (make-rectangular (mus-random 1.0) (mus-random 1.0))
				      (make-rectangular (mus-random 1.0) (mus-random 1.0))
				      (make-rectangular (mus-random 1.0) (mus-random 1.0)))))
      
					;      (do ((i 0 (+ 1 i))) ((= i 10)) 
					;	(poly-roots (vct (mus-random 1.0) (mus-random 1.0) (mus-random 1.0) (mus-random 1.0) (mus-random 1.0))))
					;      
					;      (do ((i 0 (+ 1 i))) ((= i 10)) 
					;	(poly-as-vector-roots (vector (make-rectangular (mus-random 1.0) (mus-random 1.0)) 
					;				      (make-rectangular (mus-random 1.0) (mus-random 1.0))
					;				      (make-rectangular (mus-random 1.0) (mus-random 1.0))
					;				      (make-rectangular (mus-random 1.0) (mus-random 1.0))
					;				      (make-rectangular (mus-random 1.0) (mus-random 1.0)))))
      
      (do ((i 3 (+ 1 i))) ((= i 20)) 
	(let ((v (make-vct i 0.0)))
	  (vct-set! v 0 (mus-random 1.0))
	  (vct-set! v (- i 1) 1.0)
	  (poly-roots v)))
      
      (do ((i 3 (+ i 2))) ((= i 21)) 
	(let ((v (make-vct i 0.0)))
	  (vct-set! v 0 (mus-random 1.0))
	  (vct-set! v (- i 1) 1.0)
	  (vct-set! v (/ (- i 1) 2) 1.0)
	  (poly-roots v)))
      
      (let ((vals (poly-roots (vct 1 -1 -1 1))))
	(if (and (not (ceql vals (list 1.0 -1.0 1.0))) 
		 (not (ceql vals (list -1.0 1.0 1.0))))
	    (snd-display #__line__ ";poly-roots 1-1-11: ~A" vals)))
      (let ((vals (poly-roots (vct 2 -1 -2 1))))
	(if (not (ceql vals (list 2.0 -1.0 1.0))) (snd-display #__line__ ";poly-roots 2-1-21: ~A" vals)))
      (let ((vals (poly-roots (vct -1 1 1 1))))
	(if (not (ceql vals (list 0.543689012692076 -0.771844506346038+1.11514250803994i -0.771844506346038-1.11514250803994i)))
	    (snd-display #__line__ ";poly-roots -1111: ~A" vals)))
      (let ((vals (poly-roots (vct -1 3 -3 1))))
	(if (not (ceql vals (list 1.0 1.0 1.0))) (snd-display #__line__ ";poly-roots -13-31: ~A" vals)))
					;      (let ((vals (poly-roots (vct 1 -4 6 -4 1))))
					;	(if (not (ceql vals (list 1.0 1.0 1.0 1.0))) (snd-display #__line__ ";poly-roots 1-46-41: ~A" vals)))
      (let ((vals (poly-roots (vct 0.5 0 0 1.0))))
	(if (and (not (ceql vals (list 0.396850262992049-0.687364818499302i -0.7937005259841 0.39685026299205+0.687364818499301i)))
		 (not (ceql vals (list 0.39685026299205+0.687364818499301i 0.39685026299205-0.687364818499301i -0.7937005259841)))
		 (not (ceql vals (list -7.9370052598409979172089E-1 3.968502629920498958E-1+6.873648184993013E-1i 3.96850262992049E-1-6.873648184993E-1i))))
	    (snd-display #__line__ ";poly-roots 0..5 3: ~A" vals)))
      (let ((vals (poly-roots (poly* (poly* (poly* (vct -1 1) (vct 1 1)) (poly* (vct -2 1) (vct 2 1))) (poly* (vct -3 1) (vct 3 1))))))
	(if (not (ceql vals (list -3.0 3.0 -1.0 1.0 -2.0 2.0)))
	    (snd-display #__line__ ";cube in 2: ~A" vals)))
      ))
  
  ;; ----------------
  (define (fltit)
    "(fltit) returns a time-varying filter: (map-chan (fltit))"
    (let* ((coeffs (list .1 .2 .3 .4 .4 .3 .2 .1))
	   (flt (make-fir-filter 8 (list->vct coeffs)))
	   (es (make-vector 8)))
      (do ((i 0 (+ 1 i)))
	  ((= i 8))
	(vector-set! es i (make-env (list 0 (list-ref coeffs i) 1 0) :length 101)))
      (vector-set! es 5 (make-env '(0 .4 1 1) :duration 1.0))
      (lambda (x)
	(let ((val (fir-filter flt x))
	      (xcof (mus-xcoeffs flt)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 8))
	    (vct-set! xcof i (env (vector-ref es i))))
	  val))))
  
  ;; ----------------
  (define (freq-sweep dur)
    (let ((phase 0.0)
	  (freq 0.0)
	  (incr (/ pi (* dur 1.05 (mus-srate)))))
      (map-channel 
       (lambda (y)
	 (let ((val (sin phase))) 
	   (set! phase (+ phase freq)) 
	   (set! freq (+ freq incr))
	   (* .5 val))))))
  
  ;; ----------------
  (define* (make-ssb-am-1 freq (order 40))
    (if (even? order) (set! order (+ 1 order)))
    (make-sa1 :freq (abs freq)
	      :coscar (make-oscil freq (* .5 pi))
	      :sincar (make-oscil freq)
	      :dly (make-delay order)
	      :hlb (make-hilbert-transform order)))
  
  ;; ----------------
  (define* (ssb-am-1 gen y (fm-1 0.0))
    (let* ((fm fm-1)
	   (ccos (oscil (sa1-coscar gen) fm))
	   (csin (oscil (sa1-sincar gen) fm))
	   (yh (hilbert-transform (sa1-hlb gen) y))
	   (yd (delay (sa1-dly gen) y)))
      (if (> (sa1-freq gen) 0.0)
	  (- (* ccos yd) ; shift up
	     (* csin yh))
	  (+ (* ccos yd) ; shift down
	     (* csin yh)))))
  
  ;; ----------------
  (define (rough-spectrum ind)
    (let ((r (make-sampler 0 ind 0))
	  (spect (make-vct 10))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((sum 0.0))
	  (do ((j 0 (+ 1 j)))
	      ((= j 1000))
	    (let ((val (r)))
	      (set! sum (+ sum (* val val)))))
	  (if (> sum mx) (set! mx sum))
	  (vct-set! spect i sum)))
      (vct-scale! spect (/ 1.0 mx))))
  
  ;; ----------------
  (define* (print-and-check gen name desc (desc1 "") (desc2 ""))
    
    (if (not (string=? (mus-name gen) name))
	(snd-display #__line__ ";mus-name ~A: ~A?" name (mus-name gen)))
    (if (and (not (string=? (mus-describe gen) desc))
	     (not (string=? (mus-describe gen) desc1))
	     (not (string=? (mus-describe gen) desc2)))
	(snd-display #__line__ ";mus-describe ~A: ~A?" (mus-name gen) (mus-describe gen)))
    (let ((egen gen))
      (if (not (equal? egen gen))
	  (snd-display #__line__ ";equal? ~A: ~A?" gen egen))))
  
  ;; ----------------
  (define (test-gen-equal g0 g1 g2)
    ;; g0 = g1 at start != g2
    
    (let ((g3 g0)
	  (gad (make-frame 2)))
      (if (not (eq? g0 g3))
	  (snd-display #__line__ ";let ~A not eq? ~A ~A" (mus-name g0) g0 g3))
      (if (eq? g0 g1)
	  (snd-display #__line__ ";arg ~A eq? ~A ~A" (mus-name g0) g0 g1))
      (if (not (equal? g0 g1))
	  (snd-display #__line__ ";~A not equal? ~A ~A" (mus-name g0) g0 g1))
      (if (equal? g0 g2)
	  (snd-display #__line__ ";~A equal? ~A ~A" (mus-name g0) g0 g2))
      (if (equal? g0 gad)
	  (snd-display #__line__ ";~A equal frame? ~A ~A" (mus-name g0) g0 gad))
      (g0)
      (g3)
      (g3)
      (if (not (eq? g0 g3))
	  (snd-display #__line__ ";run let ~A not eq? ~A ~A" (mus-name g0) g0 g3))
      (if (eq? g0 g1)
	  (snd-display #__line__ ";arg ~A eq? ~A ~A" (mus-name g0) g0 g1))
      (if (equal? g0 g1)
	  (snd-display #__line__ ";run ~A equal? ~A ~A" (mus-name g0) g0 g1))
      (if (equal? g0 g2)
	  (snd-display #__line__ ";run ~A equal? ~A ~A" (mus-name g0) g0 g2))))
  
  ;; ----------------
  (define (fm-test gen)
    (if (not (mus-generator? gen)) (snd-display #__line__ ";~A not a gen?" gen))
    (set! (mus-frequency gen) 0.0)
    (set! (mus-phase gen) 0.0)
    (gen 0.0)
    (if (fneq (mus-phase gen) 0.0) (snd-display #__line__ ";~A phase(0): ~A" gen (mus-phase gen)))
    (gen 1.0)
    (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";~A phase(1): ~A" gen (mus-phase gen)))
    (gen 0.0)
    (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";~A phase(1, 0): ~A" gen (mus-phase gen)))
    (set! (mus-frequency gen) (radians->hz 2.0))
    (if (fneq (mus-increment gen) 2.0) (snd-display #__line__ ";~A increment: ~A" gen (mus-increment gen)))
    (set! (mus-increment gen) 2.0)
    (if (fneq (mus-frequency gen) (radians->hz 2.0)) (snd-display #__line__ ";~A set increment: ~A ~A" gen (mus-increment gen) (hz->radians (mus-frequency gen))))
    (gen 0.0)
    (if (fneq (mus-phase gen) 3.0) (snd-display #__line__ ";~A phase(1, 2): ~A ~A" gen (mus-phase gen) (mus-frequency gen)))
    (gen 1.0)
    (if (fneq (mus-phase gen) 6.0) (snd-display #__line__ ";~A phase(3, 2, 1): ~A ~A" gen (mus-phase gen) (mus-frequency gen)))
    (do ((i 0 (+ 1 i))) ((= i 10)) (gen 10.0))
    (if (fneq (mus-phase gen) (+ 26 (- 100 (* 2 pi 20)))) (snd-display #__line__ ";~A phase (over): ~A ~A" gen (mus-phase gen) (mus-frequency gen)))
    (set! (mus-frequency gen) 0.0)
    (set! (mus-phase gen) 0.0)
    (gen 1234567812345678)
    (gen -1234567812345678)
    (set! (mus-frequency gen) 0.0)
    (set! (mus-phase gen) 0.0)
    (gen -2.0)
    (if (and (fneq (mus-phase gen) -2.0)
	     (fneq (mus-phase gen) (- (* 2 pi) 2.0)))
	(snd-display #__line__ ";phase: ~A freq: ~A" (mus-phase gen))))
  
  ;; ----------------
  ;; from mixer.scm (commented out)
  (define (frame-cross m1 m2)
    (if (or (not (= (mus-length m1) 3))
	    (not (= (mus-length m2) 3)))
	(snd-print "cross product only in 3 dimensions")
	(make-frame 3 
		    (- (* (frame-ref m1 1) (frame-ref m2 2)) 
		       (* (frame-ref m1 2) (frame-ref m2 1)))
		    (- (* (frame-ref m1 2) (frame-ref m2 0)) 
		       (* (frame-ref m1 0) (frame-ref m2 2)))
		    (- (* (frame-ref m1 0) (frame-ref m2 1)) 
		       (* (frame-ref m1 1) (frame-ref m2 0))))))
  
  ;; ----------------
  (define (frame-normalize f)
    (let ((mag (sqrt (dot-product (mus-data f) (mus-data f)))))
      (if (> mag 0.0)
	  (frame* f (/ 1.0 mag))
	  f)))
  
  ;; ----------------
  (define* (agc (ramp-speed .001) (window-size 512))
    (let ((maxer (make-moving-max window-size))
	  (mult 1.0))
      (map-channel
       (lambda (y)
	 (let* ((curmax (moving-max maxer y))
		(diff (- 0.5 (* mult curmax)))
		(this-incr (* diff ramp-speed)))
	   (set! mult (+ mult this-incr))
	   (* y mult))))))
  
  ;; ----------------
  (define (numerical-reality-checks)
    ;; a few reality checks from John Burkardt test_values.C
    
    (let ((vals (vector 1.6709637479564564156 1.5707963267948966192 1.4706289056333368229 1.3694384060045658278 1.2661036727794991113 
			1.1592794807274085998 1.0471975511965977462 0.92729521800161223243 0.79539883018414355549 0.64350110879328438680 
			0.45102681179626243254 0.00000000000000000000))
	  (args (vector -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 12))
	(let* ((nval (acos (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) (set! max-bad diff))))
      (if (> max-bad 1.0e-15)
	  (snd-display #__line__ ";acos: ~A" max-bad)))
    
    (let ((vals (vector 0.0000000000000000000 0.14130376948564857735 0.44356825438511518913 0.62236250371477866781 0.75643291085695958624 
			0.86701472649056510395 0.96242365011920689500 1.3169578969248167086 1.7627471740390860505 1.8115262724608531070 
			2.0634370688955605467 2.2924316695611776878 2.9932228461263808979 5.2982923656104845907 7.6009022095419886114))
	  (args (vector 1.0 1.01 1.1 1.2 1.3 1.4 1.5 2.0 3.0 3.1415926535897932385 4.0 5.0 10.0 100.0 1000.0))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 15))
	(let* ((nval (acosh (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) (set! max-bad diff))))
      (if (> max-bad 1.0e-15)
	  (snd-display #__line__ ";acosh: ~A" max-bad)))
    
    (let ((vals (vector -0.10016742116155979635 0.00000000000000000000 0.10016742116155979635 0.20135792079033079146 0.30469265401539750797 
			0.41151684606748801938 0.52359877559829887308 0.64350110879328438680 0.77539749661075306374 0.92729521800161223243 
			1.1197695149986341867 1.5707963267948966192))
	  (args (vector -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 12))
	(let* ((nval (asin (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) (set! max-bad diff))))
      (if (> max-bad 1.0e-15)
	  (snd-display #__line__ ";asin: ~A" max-bad)))
    
    (let ((vals (vector -2.3124383412727526203 -0.88137358701954302523 0.00000000000000000000 0.099834078899207563327 0.19869011034924140647 
			0.29567304756342243910 0.39003531977071527608 0.48121182505960344750 0.56882489873224753010 0.65266656608235578681 
			0.73266825604541086415 0.80886693565278246251 0.88137358701954302523 1.4436354751788103425 1.8184464592320668235 
			2.0947125472611012942 2.3124383412727526203 2.9982229502979697388 5.2983423656105887574 7.6009027095419886115))
	  (args (vector -5.0 -1.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 4.0 5.0 10.0 100.0 1000.0))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 20))
	(let* ((nval (asinh (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) (set! max-bad diff))
	  (if (> max-bad 1.0e-14)
	      (snd-display #__line__ ";asinh(~A): ~A ~A -> ~A" (vector-ref args i) nval (vector-ref vals i) max-bad)))))
    
    (let ((vals (vector 0.00000000000000000000 0.24497866312686415417 0.32175055439664219340 0.46364760900080611621 0.78539816339744830962 
			1.1071487177940905030 1.2490457723982544258 1.3258176636680324651 1.3734007669450158609 1.4711276743037345919 1.5208379310729538578))
	  (args (vector 0.00000000000000000000 0.25000000000000000000 0.33333333333333333333 0.50000000000000000000 1.0000000000000000000 
			2.0000000000000000000 3.0000000000000000000 4.0000000000000000000 5.0000000000000000000 10.000000000000000000 20.000000000000000000))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(let* ((nval (atan (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) (set! max-bad diff))))
      (if (> max-bad 1.0e-15)
	  (snd-display #__line__ ";atan: ~A" max-bad)))
    
    (let ((vals (vector -0.54930614433405484570 0.00000000000000000000 0.0010000003333335333335 0.10033534773107558064 0.20273255405408219099 
			0.30951960420311171547 0.42364893019360180686 0.54930614433405484570 0.69314718055994530942 0.86730052769405319443 
			1.0986122886681096914 1.4722194895832202300 2.6466524123622461977 3.8002011672502000318 7.2543286192620472067))
	  (args (vector -0.5 0.0 0.001 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.99 0.999 0.999999))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 15))
	(let* ((nval (atanh (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-10) ; one is > e-11
	      (snd-display #__line__ ";atanh(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector 0.1000000000000000E+01 0.1010025027795146E+01 0.1040401782229341E+01 0.1092045364317340E+01 0.1166514922869803E+01 
			0.1266065877752008E+01 0.1393725584134064E+01 0.1553395099731217E+01 0.1749980639738909E+01 0.1989559356618051E+01 
			0.2279585302336067E+01 0.3289839144050123E+01 0.4880792585865024E+01 0.7378203432225480E+01 0.1130192195213633E+02 
			0.1748117185560928E+02 0.2723987182360445E+02 0.6723440697647798E+02 0.4275641157218048E+03 0.2815716628466254E+04))
	  (args (vector 0.00E+00 0.20E+00 0.40E+00 0.60E+00 0.80E+00 0.10E+01 0.12E+01 0.14E+01 0.16E+01 0.18E+01 0.20E+01 0.25E+01 0.30E+01 
			0.35E+01 0.40E+01 0.45E+01 0.50E+01 0.60E+01 0.80E+01 
			0.10E+02))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 20))
	(let* ((nval (bes-i0 (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-4)
	      (snd-display #__line__ ";bes-i0(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector -0.1775967713143383E+00 -0.3971498098638474E+00 -0.2600519549019334E+00 0.2238907791412357E+00 0.7651976865579666E+00 
			0.1000000000000000E+01 0.7651976865579666E+00 0.2238907791412357E+00 -0.2600519549019334E+00 -0.3971498098638474E+00 
			-0.1775967713143383E+00 0.1506452572509969E+00 0.3000792705195556E+00 0.1716508071375539E+00 -0.9033361118287613E-01 
			-0.2459357644513483E+00 -0.1711903004071961E+00 0.4768931079683354E-01 0.2069261023770678E+00 0.1710734761104587E+00 -0.1422447282678077E-01))
	  (args (vector -5.0E+00 -4.0E+00 -3.0E+00 -2.0E+00 -1.0E+00 0.0E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00 
			9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 21))
	(let* ((nval (bes-j0 (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-15)
	      (snd-display #__line__ ";bes-j0(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector 0.3275791375914652E+00 0.6604332802354914E-01 -0.3390589585259365E+00 -0.5767248077568734E+00 -0.4400505857449335E+00 
			0.0000000000000000E+00 0.4400505857449335E+00 0.5767248077568734E+00 0.3390589585259365E+00 -0.6604332802354914E-01 
			-0.3275791375914652E+00 -0.2766838581275656E+00 -0.4682823482345833E-02 0.2346363468539146E+00 0.2453117865733253E+00 
			0.4347274616886144E-01 -0.1767852989567215E+00 -0.2234471044906276E+00 -0.7031805212177837E-01 0.1333751546987933E+00 0.2051040386135228E+00))
	  (args (vector -5.0E+00 -4.0E+00 -3.0E+00 -2.0E+00 -1.0E+00 0.0E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00 
			9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 21))
	(let* ((nval (bes-j1 (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-15)
	      (snd-display #__line__ ";bes-j1(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector 0.1149034849319005E+00 0.3528340286156377E+00 0.4656511627775222E-01 0.2546303136851206E+00 -0.5971280079425882E-01 
			0.2497577302112344E-03 0.7039629755871685E-02 0.2611405461201701E+00 -0.2340615281867936E+00 -0.8140024769656964E-01 
			0.2630615123687453E-09 0.2515386282716737E-06 0.1467802647310474E-02 0.2074861066333589E+00 -0.1138478491494694E+00 
			0.3873503008524658E-24 0.3918972805090754E-18 0.2770330052128942E-10 0.1151336924781340E-04 -0.1167043527595797E+00))
	  (ns (vector 2 2 2 2 2 5 5 5 5 5 10 10 10 10 10 20 20 20 20 20)) 
	  (args (vector 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 
			50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 20))
	(let* ((nval (bes-jn (vector-ref ns i) (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-15)
	      (snd-display #__line__ ";bes-jn(~A ~A): ~A ~A -> ~A" (vector-ref ns i) (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector -0.1534238651350367E+01 0.8825696421567696E-01 0.5103756726497451E+00 0.3768500100127904E+00 -0.1694073932506499E-01 
			-0.3085176252490338E+00 -0.2881946839815792E+00 -0.2594974396720926E-01 0.2235214893875662E+00 0.2499366982850247E+00 
			0.5567116728359939E-01 -0.1688473238920795E+00 -0.2252373126343614E+00 -0.7820786452787591E-01 0.1271925685821837E+00 0.2054642960389183E+00))
	  (args (vector 0.1E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00 9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(let* ((nval (bes-y0 (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-15)
	      (snd-display #__line__ ";bes-y0(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector -0.6458951094702027E+01 -0.7812128213002887E+00 -0.1070324315409375E+00 0.3246744247918000E+00 0.3979257105571000E+00 
			0.1478631433912268E+00 -0.1750103443003983E+00 -0.3026672370241849E+00 -0.1580604617312475E+00 0.1043145751967159E+00 
			0.2490154242069539E+00 0.1637055374149429E+00 -0.5709921826089652E-01 -0.2100814084206935E+00 -0.1666448418561723E+00 0.2107362803687351E-01))
	  (args (vector 0.1E+00 1.0E+00 2.0E+00 3.0E+00 4.0E+00 5.0E+00 6.0E+00 7.0E+00 8.0E+00 9.0E+00 10.0E+00 11.0E+00 12.0E+00 13.0E+00 14.0E+00 15.0E+00))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(let* ((nval (bes-y1 (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (> diff 1.0e-14)
	      (snd-display #__line__ ";bes-y1(~A): ~A ~A -> ~A" (vector-ref args i) (vector-ref vals i) nval diff)))))
    
    (let ((vals (vector -0.1650682606816254E+01 -0.6174081041906827E+00 0.3676628826055245E+00 -0.5868082442208615E-02 0.9579316872759649E-01 
			-0.2604058666258122E+03 -0.9935989128481975E+01 -0.4536948224911019E+00 0.1354030476893623E+00 -0.7854841391308165E-01 
			-0.1216180142786892E+09 -0.1291845422080393E+06 -0.2512911009561010E+02 -0.3598141521834027E+00 0.5723897182053514E-02 
			-40816513889983664.0 -0.5933965296914321E+09 -0.1597483848269626E+04 0.1644263394811578E-01))
	  
	  ;; yn(20, 2.0) prints -40816513889983664.0 but I guess due to float inaccuracies (bes-yn 20 2.0) is -40816513889983672.0?
	  
	  (ns (vector 2 2 2 2 2 5 5 5 5 5 10 10 10 10 10 20 20 20 20))
	  (args (vector 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00 1.0E+00 2.0E+00 5.0E+00 10.0E+00 
			50.0E+00 2.0E+00 5.0E+00 10.0E+00 50.0E+00))
	  (max-bad 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 19))
	(let* ((nval (bes-yn (vector-ref ns i) (vector-ref args i)))
	       (diff (abs (- nval (vector-ref vals i)))))
	  (if (> diff max-bad) 
	      (set! max-bad diff))
	  (if (and (> diff 1.0e-6)
		   (not (= i 15))) ; see above
	      (snd-display #__line__ ";bes-yn(~A ~A): ~A ~A -> ~A" (vector-ref ns i) (vector-ref args i) (vector-ref vals i) nval diff)))))
    ;; one (20 1.0) is off by a lot but the val is 1e22 
    
    ;; numerics stuff
    (let ((ns (vector 1 6 6 6 15 15 15 15 15 15 15))
	  (ks (vector 0 1 3 5 1  3  5  7  9  11 13))
	  (vals (vector 1 6 20 6 15 455 3003 6435 5005 1365 105)))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(let* ((nval (binomial-direct (vector-ref ns i) (vector-ref ks i)))
	       (mval (n-choose-k (vector-ref ns i) (vector-ref ks i))))
	  (if (or (not (= nval (vector-ref vals i)))
		  (not (= mval (vector-ref vals i))))
	      (snd-display #__line__ ";binomial(~A ~A): ~A ~A ~A" (vector-ref ns i) (vector-ref ks i) nval mval (vector-ref vals i))))))
    
    (let ((ls (vector 1 1 1 1 1 2 2 2 3 3 3 3 4 5 6 7 8 9 10))
	  (ms (vector 0 0 0 0 1 0 1 2 0 1 2 3 2 2 3 3 4 4 5))
	  (vals (vector 0.000000 0.500000 0.707107 1.000000 -0.866025 -0.125000 -1.29904  2.25000 -0.437500 -0.324759 5.62500 -9.74278 
			4.21875 -4.92187  12.7874  116.685 -1050.67 -2078.49  30086.2))
	  (xs (vector 0.0 0.5 0.7071067 1.0  0.5 0.5 0.5 0.5  0.5 0.5 0.5 0.5  0.5 0.5 0.5 0.5  0.5 0.5 0.5)))
      (do ((i 0 (+ 1 i)))
	  ((= i 19))
	(let ((val (plgndr (vector-ref ls i) (vector-ref ms i) (vector-ref xs i))))
	  (if (or (not (real? val))
		  (not (real? (vector-ref vals i)))
		  (> (abs (- val (vector-ref vals i))) 0.1))
	      (snd-display #__line__ ";plgndr(~A ~A ~A) = ~A (~A)" (vector-ref ls i) (vector-ref ms i) (vector-ref xs i) val (vector-ref vals i))))))
    
    (let ((vals (vector  1.0000000000  0.8000000000  0.2800000000  -0.3520000000 -0.8432000000 -0.9971200000 
			 -0.7521920000 -0.2063872000  0.4219724800  0.8815431680  0.9884965888  0.7000513741  0.1315856097))
	  (ns (vector  0  1  2   3  4  5   6  7  8   9 10 11 	   12))
	  (xs (vector    0.8  0.8  0.8     0.8  0.8  0.8     0.8  0.8  0.8     0.8  0.8  0.8     0.8)))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 13))
	(let ((val (chebyshev (vector-ref ns i) (vector-ref xs i))))
	  (if (fneq val (vector-ref vals i))
	      (snd-display #__line__ ";chebyshev ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) val (vector-ref vals i)))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let* ((x (random 10.0))
	       (order (random 10))
	       (val1 (gegenbauer order x 1.0))
	       (val2 (chebyshev order x 2)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";gegenbauer/chebyshev (alpha=1) ~A ~A: ~A ~A" order x val1 val2)))))
    
    (let ((as (vector      0.5  0.5  0.5      0.5  0.5  0.5      0.5  0.5  0.5      0.5  0.5  0.0      1.0  2.0  3.0 
			   4.0  5.0  6.0      7.0  8.0  9.0     10.0  3.0  3.0      3.0  3.0  3.0      3.0  3.0  3.0      3.0  3.0  3.0 
			   3.0  3.0  3.0      3.0  3.0))
	  (vals (vector    1.0000000000   0.2000000000  -0.4400000000    -0.2800000000   0.2320000000   0.3075200000 
			   -0.0805760000  -0.2935168000  -0.0395648000     0.2459712000   0.1290720256   0.696706 ; was 0 but explicit formula says 2/n cos(nx)
			   -0.3600000000  -0.0800000000   0.8400000000     2.4000000000   4.6000000000   7.4400000000    10.9200000000  15.0400000000  19.8000000000 
			   25.2000000000  9.0000000000  -0.1612800000 ; was -9 but that is wrong (see G&R explicit formula)
			   -6.6729600000  -8.3750400000  -5.5267200000     0.0000000000   5.5267200000   8.3750400000     6.6729600000   0.1612800000  -9.0000000000  
			   -15.4252800000  -9.6969600000  22.4409600000   100.8892800000 252.0000000000))
	  (ns (vector     0  1  2      3  4  5      6  7  8      9 10  2      2  2  2      2  2  2      2  2  2      2  5  5      5  5  5 
			  5  5  5      5  5  5      5  5  5      5  5))
	  (xs (vector    0.20  0.20  0.20     0.20  0.20  0.20     0.20  0.20  0.20     0.20  0.20  0.40     0.40  0.40  0.40 
			 0.40  0.40  0.40     0.40  0.40  0.40     0.40 -0.50 -0.40    -0.30 -0.20 -0.10     0.00  0.10  0.20 
			 0.30  0.40  0.50     0.60  0.70  0.80     0.90  1.00)))
      
      (define (g3 x alpha)
	(- (* 1/3 alpha x x x (+ (* 4 alpha alpha) (* 12 alpha) 8))
	   (* 2 alpha x (+ alpha 1))))
      
      (define (g5 x alpha)
	(+ (* 1/15 alpha x x x x x (+ (* 4 alpha alpha alpha alpha) 
				      (* 40 alpha alpha alpha)
				      (* 140 alpha alpha)
				      (* 200 alpha)
				      96))
	   (* -1/3 alpha x x x (+ (* 4 alpha alpha alpha)
				  (* 24 alpha alpha)
				  (* 44 alpha)
				  24))
	   (* alpha x (+ (* alpha alpha) (* 3 alpha) 2))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 38))
	(let ((val (gegenbauer (vector-ref ns i) (vector-ref xs i) (vector-ref as i))))
	  (if (fneq val (vector-ref vals i))
	      (snd-display #__line__ ";gegenbauer ~A ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) (vector-ref as i) val (vector-ref vals i)))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let* ((x (random 10.0))
	       (alpha (random 3.0))
	       (val1 (gegenbauer 3 x alpha))
	       (val2 (g3 x alpha)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";gegenbauer 3 ~A ~A: ~A ~A" x alpha val1 val2))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let* ((x (random 10.0))
	       (alpha (random 3.0))
	       (val1 (gegenbauer 5 x alpha))
	       (val2 (g5 x alpha)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";gegenbauer 5 ~A ~A: ~A ~A" x alpha val1 val2))))
      )
    
    (let ((vals (vector     1.0000000000  0.0000000000 -0.5000000000     -0.6666666667 -0.6250000000 -0.4666666667 
			    -0.2569444444 -0.0404761905  0.1539930556      0.3097442681  0.4189459325  0.4801341791 
			    0.4962122235 -0.4455729167  0.8500000000     -3.1666666667 34.3333333333))
	  (ns (vector     0  1  2      3  4  5      6  7  8      9 10 11     12  5  5      5  5))
	  (xs (vector    1.0  1.0  1.0     1.0  1.0  1.0     1.0  1.0  1.0     1.0  1.0  1.0     1.0  0.5  3.0     5.0 10.0)))
      (do ((i 0 (+ 1 i)))
	  ((= i 17))
	(let ((val (laguerre (vector-ref ns i) (vector-ref xs i))))
	  (if (fneq val (vector-ref vals i))
	      (snd-display #__line__ ";laguerre ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) val (vector-ref vals i)))))
      )
    
    (let ((vals (vector     1.0            10.0           98.0      940.0          8812.0         80600.0 
			    717880.0       6211600.0      52065680.0 ; was off by factor of 10?
			    421271200      3275529760.0   24329873600.0      171237081280.0 41.0          -8.0      3816.0         3041200.0))
	  (ns (vector     0  1  2      3  4  5      6  7  8      9 10 11     12  5  5      5  5))
	  (xs (vector    5.0  5.0  5.0     5.0  5.0  5.0     5.0  5.0  5.0     5.0  5.0  5.0     5.0  0.5  1.0     3.0 10.0)))
      (do ((i 0 (+ 1 i)))
	  ((= i 13))
	(let ((val (hermite (vector-ref ns i) (vector-ref xs i))))
	  (if (fneq val (vector-ref vals i))
	      (snd-display #__line__ ";hermite ~A ~A -> ~A ~A" (vector-ref ns i) (vector-ref xs i) val (vector-ref vals i)))))
      )
    
    (do ((i 0 (+ 1 i))) 
	((= i 10))
      (let ((lv (legendre-polynomial (let ((v (make-vector 10 0.0))) 
				       (vector-set! v i 1.0) 
				       v) 
				     0.5))
	    (pv (plgndr i 0 0.5)))
	(if (fneq lv pv)
	    (snd-display #__line__ ";lv: ~A, pv: ~A (~A)" lv pv i))))
    
    (let ((pow-x (lambda (pow x)
		   ;; A&S p798
		   (if (= pow 0)
		       (legendre-polynomial (vector 1) x)
		       (if (= pow 1)
			   (legendre-polynomial (vector 0 1) x)
			   (if (= pow 2)
			       (* (/ 1.0 3.0) (legendre-polynomial (vector 1 0 2) x))
			       (if (= pow 3)
				   (* (/ 1.0 5.0) (legendre-polynomial (vector 0 3 0 2) x))
				   (if (= pow 4)
				       (* (/ 1.0 35.0) (legendre-polynomial (vector 7 0 20 0 8) x))
				       (if (= pow 5)
					   (* (/ 1.0 63.0) (legendre-polynomial (vector 0 27 0 28 0 8) x))
					   (if (= pow 6) 
					       (* (/ 1.0 231.0) (legendre-polynomial (vector 33 0 110 0 72 0 16) x))
					       'oops))))))))))
      (for-each
       (lambda (x)
	 (for-each
	  (lambda (pow)
	    (let ((lv (pow-x pow x))
		  (sv (expt x pow)))
	      (if (fneq lv sv)
		  (snd-display #__line__ ";~A ^ ~A = ~A ~A?" x pow lv sv))))
	  (list 0 1 2 3 4 5 6)))
       (list 2.0 0.5 0.1 -0.5 3.0 0.8)))
    
    (let ((snd (with-sound (:scaled-to 0.5) 
			   (do ((i 0 (+ 1 i)) 
				(x 0.0 (+ x .02))) 
			       ((= i 100)) 
			     (outa i (legendre 20 (cos x)))))))
      (let ((index (find-sound snd)))
	(if (fneq (sample 0 index 0) 0.5) (snd-display #__line__ ";legendre(cos(x)) 0: ~A" (sample 0 index 0)))
	(if (fneq (sample 50 index 0) 0.062572978) (snd-display #__line__ ";legendre(cos(x)) 50: ~A" (sample 50 index 0)))
	(close-sound index)))
    
    
    (let ((h0 (lambda (x) 1.0))
	  (h1 (lambda (x) (* 2 x)))
	  (h2 (lambda (x) (- (* 4 x x) 2)))
	  (h3 (lambda (x) (- (* 8 x x x) (* 12 x))))
	  (h4 (lambda (x) (+ (* 16 x x x x) (* -48 x x) 12)))
	  (h5 (lambda (x) (+ (* 32 x x x x x) (* -160 x x x) (* 120 x))))
	  (h6 (lambda (x) (+ (* 64 x x x x x x) (* -480 x x x x) (* 720 x x) -120))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 20))
	(let ((x (random 10.0)))
	  (let ((v1 (h1 x))
		(v11 (hermite 1 x))
		(v2 (h2 x))
		(v22 (hermite 2 x))
		(v3 (h3 x))
		(v33 (hermite 3 x))
		(v4 (h4 x))
		(v44 (hermite 4 x))
		(v5 (h5 x))
		(v55 (hermite 5 x))
		(v6 (h6 x))
		(v66 (hermite 6 x)))
	    (if (fneq v1 v11) (snd-display #__line__ ";hermite 1 ~A: ~A ~A" x v1 v11)
		(if (fneq v2 v22) (snd-display #__line__ ";hermite 2 ~A: ~A ~A" x v2 v22)
		    (if (fneq v3 v33) (snd-display #__line__ ";hermite 3 ~A: ~A ~A" x v3 v33)
			(if (fneq v4 v44) (snd-display #__line__ ";hermite 4 ~A: ~A ~A" x v4 v44)
			    (if (fneq v5 v55) (snd-display #__line__ ";hermite 5 ~A: ~A ~A" x v5 v55)
				(if (fneq v6 v66) (snd-display #__line__ ";hermite 6 ~A: ~A ~A" x v6 v66)))))))))))
    
    (let ((lg1 (lambda (x) (- 1 x)))
	  (lg2 (lambda (x) (+ 1 (* 0.5 x x) (* -2 x))))
	  (lag1 (lambda (x a) (+ 1 a (- x))))
	  (lag2 (lambda (x a) (* 0.5 (+ (* x x) 
					(* -2 x (+ a 2))
					(* (+ a 1) (+ a 2))))))
	  (lag3 (lambda (x a) (* (/ -1.0 6.0) (+ (* x x x)
						 (* -3 x x (+ a 3))
						 (* 3 x (+ a 2) (+ a 3))
						 (* -1 (+ a 1) (+ a 2) (+ a 3)))))))
      (let ((x (random 10.0))
	    (a (random 1.0)))
	(let ((v1 (laguerre 1 x))
	      (v11 (lg1 x))
	      (v2 (laguerre 2 x))
	      (v22 (lg2 x))
	      (va1 (lag1 x a))
	      (va11 (laguerre 1 x a))
	      (va2 (lag2 x a))
	      (va22 (laguerre 2 x a))
	      (va3 (lag3 x a))
	      (va33 (laguerre 3 x a)))
	  (if (fneq v1 v11) (snd-display #__line__ ";laguerre 1 ~A: ~A ~A" x v1 v11)
	      (if (fneq v2 v22) (snd-display #__line__ ";laguerre 2 ~A: ~A ~A" x v2 v22)
		  (if (fneq va1 va11) (snd-display #__line__ ";laguerre 1a ~A ~A: ~A ~A" x alpha va1 va11)
		      (if (fneq va2 va22) (snd-display #__line__ ";laguerre 2a ~A ~A: ~A ~A" x alpha va2 va22)
			  (if (fneq va3 va33) (snd-display #__line__ ";laguerre 3a ~A ~A: ~A ~A" x alpha va3 va33)))))))))
    )
  
  ;; ----------------
  ;; start of test
  
  (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
    
    (log-mem clmtest)
    (numerical-reality-checks)
    
    (if (mus-generator? 321) (snd-display #__line__ ";123 is a gen?"))
    (if (mus-generator? (list 321)) (snd-display #__line__ ";(123) is a gen?"))
    (if (mus-generator? (list 'hi 321)) (snd-display #__line__ ";(hi 123) is a gen?"))
    (set! (mus-srate) 22050)
    (let ((samps (seconds->samples 1.0))
	  (secs (samples->seconds 22050)))
      (if (not (= samps 22050)) (snd-display #__line__ ";seconds->samples: ~A" samps))
      (if (fneq secs 1.0) (snd-display #__line__ ";samples->seconds: ~A" secs)))
    (if (and (= clmtest 0)
	     (not (= (mus-file-buffer-size) default-file-buffer-size)))
	(snd-display #__line__ ";mus-file-buffer-size: ~D?" (mus-file-buffer-size)))
    (let ((var (catch #t (lambda () (set! (mus-file-buffer-size) #f)) (lambda args args))))
      (if (not (eq? (car var) 'wrong-type-arg))
	  (snd-display #__line__ ";mus-file-buffer-size bad size: ~A" var)))
    (set! (mus-file-buffer-size) 128)
    (if (not (= (mus-file-buffer-size) 128)) (snd-display #__line__ ";mus-file-buffer-size: ~D?" (mus-file-buffer-size)))
    (set! (mus-file-buffer-size) default-file-buffer-size)
    
    (if (and (not (= (mus-array-print-length) 8)) 
	     (not (= (mus-array-print-length) 32)))
	(snd-display #__line__ ";mus-array-print-length: ~D?" (mus-array-print-length)))
    (set! (mus-array-print-length) 32)
    (if (not (= (mus-array-print-length) 32)) (snd-display #__line__ ";set mus-array-print-length: ~D?" (mus-array-print-length)))
    (set! (mus-array-print-length) 8)
    
    (let ((fudge (mus-float-equal-fudge-factor)))
      (if (> (abs (- (mus-float-equal-fudge-factor) 0.0000001)) 0.00000001)
	  (snd-display #__line__ ";mus-float-equal-fudge-factor: ~A?" (mus-float-equal-fudge-factor)))
      (set! (mus-float-equal-fudge-factor) .1)
      (if (fneq (mus-float-equal-fudge-factor) .1) 
	  (snd-display #__line__ ";set mus-float-equal-fudge-factor: ~A?" (mus-float-equal-fudge-factor)))
      (set! (mus-float-equal-fudge-factor) fudge))
    
    (if (fneq (mus-srate) 22050.0) (snd-display #__line__ ";mus-srate: ~F?" (mus-srate)))
    (if (fneq (hz->radians 1.0) 2.84951704088598e-4) (snd-display #__line__ ";hz->radians: ~F?" (hz->radians 1.0)))
    (if (fneq (radians->hz 2.84951704088598e-4) 1.0) (snd-display #__line__ ";radians->hz: ~F?" (radians->hz 2.84951704088598e-4)))
    (if (fneq (radians->degrees 1.0) 57.2957801818848) (snd-display #__line__ ";radians->degrees: ~F?" (radians->degrees 1.0)))
    (if (fneq (degrees->radians 57.2957801818848) 1.0) (snd-display #__line__ ";degrees->radians: ~F?" (degrees->radians 57.2957801818848)))
    (if (fneq (linear->db .25) -12.0411996841431) (snd-display #__line__ ";linear->db: ~F?" (linear->db .25)))
    (if (fneq (db->linear -12.0411996841431) .25) (snd-display #__line__ ";db->linear: ~F?" (db->linear -12.0411996841431)))
    (if (fneq (ring-modulate .4 .5) .2) (snd-display #__line__ ";ring-modulate: ~F?" (ring-modulate .4 .5)))
    (if (fneq (amplitude-modulate 1.0 .5 .4) .7) (snd-display #__line__ ";amplitude-modulate: ~F?" (amplitude-modulate 1.0 .5 .4)))
    (if (fneq (contrast-enhancement 0.1 0.75) (sin (+ (* 0.1 (/ pi 2)) (* .75 (sin (* 0.1 2.0 pi))))))
	(snd-display #__line__ ";contrast-enhancement: ~F (0.562925306221587)" (contrast-enhancement 0.1 0.75)))
    (if (fneq (contrast-enhancement 1.0) 1.0) (snd-display #__line__ ";contrast-enhancement opt: ~A" (contrast-enhancement 1.0)))
    (let ((lv0 (partials->polynomial (vct 1 1 2 1) mus-chebyshev-first-kind))
	  (lv1 (partials->polynomial '(1 1 2 1) mus-chebyshev-second-kind))
	  (lv2 (partials->polynomial '(1 1 2 1 3 1 5 1) mus-chebyshev-first-kind))
	  (lv3 (partials->polynomial '(1 1 2 1 3 1 5 1) mus-chebyshev-second-kind))
	  (lv4 (partials->polynomial '(1 1 2 .5 3 .1 6 .01) mus-chebyshev-first-kind))
	  (lv5 (partials->polynomial (list 1 1 2 .5 3 .1 6 .01) mus-chebyshev-second-kind))
	  (lv6 (partials->polynomial (vct 1 9 2 3 3 5 4 7 5 1))) ; MLB
	  (lv7 (partials->polynomial '(7 1)))
	  (lv7a (partials->polynomial '(7 1) mus-chebyshev-first-kind))
	  (lv8 (partials->polynomial '(7 1) mus-chebyshev-second-kind))
	  )
      (if (not (fveql lv0 '(-1.000 1.000 2.000) 0)) (snd-display #__line__ ";partials->polynomial(1): ~A?" lv0))
      (if (not (fveql lv1 '(1.000 2.000 0.0) 0)) (snd-display #__line__ ";partials->polynomial(2): ~A?" lv1))
      (if (not (fveql lv2 '(-1.000 3.000 2.000 -16.000 0.000 16.000) 0)) (snd-display #__line__ ";partials->polynomial(3): ~A?" lv2))
      (if (not (fveql lv3 '(1.000 2.000 -8.000 0.000 16.000 0.000) 0)) (snd-display #__line__ ";partials->polynomial(4): ~A?" lv3))
      (if (not (fveql lv4 '(-0.510 0.700 1.180 0.400 -0.480 0.000 0.320) 0)) (snd-display #__line__ ";partials->polynomial(5): ~A?" lv4))
      (if (not (fveql lv5 '(0.900 1.060 0.400 -0.320 0.000 0.320 0.000) 0)) (snd-display #__line__ ";partials->polynomial(6): ~A?" lv5))
      (if (not (vequal lv6 (vct 4.000 -1.000 -50.000 0.000 56.000 16.000))) (snd-display #__line__ ";partials->polynomial(7): ~A?" lv6))
      (if (not (vequal lv7 (vct 0.000 -7.000 0.000 56.000 0.000 -112.000 0.000 64.000))) (snd-display #__line__ ";partials->polynomial(8): ~A?" lv7))
      (if (not (vequal lv8 (vct -1.000 0.000 24.000 0.000 -80.000 0.000 64.000 0.000))) (snd-display #__line__ ";partials->polynomial(9): ~A?" lv8))
      (if (not (vequal lv7 lv7a)) (snd-display #__line__ ";partials->polynomial kind=1? ~A ~A" lv7 lv7a))
      
      (if (not (vequal (normalize-partials (list 1 1 2 1)) (vct 1.000 0.500 2.000 0.500)))
	  (snd-display #__line__ ";normalize-partials 1: ~A" (normalize-partials (list 1 1 2 1))))
      (if (not (vequal (normalize-partials (vct 1 1 2 1)) (vct 1.000 0.500 2.000 0.500)))
	  (snd-display #__line__ ";normalize-partials 2: ~A" (normalize-partials (vct 1 1 2 1))))
      (if (not (vequal (normalize-partials (vct 1 1 2 -1)) (vct 1.000 0.500 2.000 -0.500)))
	  (snd-display #__line__ ";normalize-partials 3: ~A" (normalize-partials (vct 1 1 2 -1))))
      (if (not (vequal (normalize-partials (vct 1 -.1 2 -.1)) (vct 1.000 -0.500 2.000 -0.500)))
	  (snd-display #__line__ ";normalize-partials 4: ~A" (normalize-partials (vct 1 -.1 2 -.1))))
      (if (not (vequal (normalize-partials (vct 0 2 1 1 4 1)) (vct 0.000 0.500 1.000 0.250 4.000 0.250)))
	  (snd-display #__line__ ";normalize-partials 4: ~A" (normalize-partials (vct 0 2 1 1 4 1))))
      
      (if (fneq (polynomial lv7 1.0) (cosh (* 7 (acosh 1.0)))) 
	  (snd-display #__line__ ";ccosh cheb 7 1.0: ~A ~A" (polynomial lv7 1.0) (cosh (* 7 (acosh 1.0)))))
      (if (fneq (polynomial lv7 1.0) (cos (* 7 (acos 1.0)))) 
	  (snd-display #__line__ ";cos cheb 7 1.0: ~A ~A" (polynomial lv7 1.0) (cos (* 7 (acos 1.0)))))
      (if (fneq (polynomial lv8 0.5) (/ (sin (* 7 (acos 0.5))) (sin (acos 0.5))))
	  (snd-display #__line__ ";acos cheb 7 1.0: ~A ~A" (polynomial lv8 0.5) (/ (sin (* 7 (acos 0.5))) (sin (acos 0.5)))))
      ;; G&R 8.943 p 984 uses n+1 where we use n in Un? (our numbering keeps harmonics aligned between Tn and Un)
      
      (do ((i 0 (+ 1 i)))
	  ((+ i 10))
	(let ((val (mus-random 1.0)))
	  (if (fneq (polynomial lv7 val) (cosh (* 7 (acosh val)))) 
	      (snd-display #__line__ ";ccosh cheb 7 ~A: ~A ~A" val (polynomial lv7 val) (cosh (* 7 (acosh val)))))
	  (if (fneq (polynomial lv7 val) (cos (* 7 (acos val)))) 
	      (snd-display #__line__ ";cos cheb 7 ~A: ~A ~A" (polynomial lv7 val) (cos (* 7 (acos val)))))
	  (if (fneq (polynomial lv8 val) (/ (sin (* 7 (acos val))) (sin (acos val))))
	      (snd-display #__line__ ";acos cheb 7 ~A: ~A ~A" val (polynomial lv8 val) (/ (sin (* 7 (acos val))) (sin (acos val)))))))
      )
    
    ;; check phase-quadrature cancellations
    (let ((cos-coeffs (partials->polynomial '(1 1 2 1) mus-chebyshev-first-kind))
	  (sin-coeffs (partials->polynomial (vct 1 1 2 1) mus-chebyshev-second-kind)))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 440.0) 22050.0))))
	  ((= i 1100))
	(let* ((x (cos a))
	       (y (sin a))
	       (cax (polynomial cos-coeffs x))
	       (sax (polynomial sin-coeffs x))
	       (upper (- (* (cos (* 2 a)) cax) (* (sin (* 2 a)) (* y sax))))
	       (lower (+ (* (cos (* 2 a)) cax) (* (sin (* 2 a)) (* y sax))))
	       (upper2 (+ (cos (* a 3)) (cos (* a 4))))
	       (lower2 (+ 1.0 (cos a))))
	  (if (or (fneq upper upper2)
		  (fneq lower lower2))
	      (snd-display #__line__ ";~A ~A, ~A ~A" upper upper2 lower lower2)))))
    
    (let ((tag (catch #t (lambda () (harmonicizer 550.0 (list .5 .3 .2) 10)) (lambda args (car args)))))
      (if (not (eq? tag 'no-data)) (snd-display #__line__ ";odd length arg to partials->polynomial: ~A" tag)))
    
    (let* ((amps (list->vct '(1.0)))
	   (phases (list->vct '(0.0)))
	   (val (sine-bank amps phases)))
      (if (fneq val 0.0) (snd-display #__line__ ";sine-bank: ~A 0.0?" val))
      (vct-set! phases 0 (/ pi 2))
      (set! val (sine-bank amps phases))
      (if (fneq val 1.0) (snd-display #__line__ ";sine-bank: ~A 1.0?" val))
      (set! amps (list->vct '(0.5 0.25 1.0)))
      (set! phases (list->vct '(1.0 0.5 2.0)))
      (set! val (sine-bank amps phases))
      (if (fneq val 1.44989) (snd-display #__line__ ";sine-bank: ~A 1.449?" val))
      (set! val (sine-bank amps phases 3))
      (if (fneq val 1.44989) (snd-display #__line__ ";sine-bank (3): ~A 1.449?" val))
      (set! val (sine-bank amps phases 1))
      (if (fneq val 0.4207) (snd-display #__line__ ";sine-bank (1): ~A 1.449?" val)))
    
    (let* ((amps (list->vct '(1.0)))
	   (oscs (make-vector 1 #f)))
      (vector-set! oscs 0 (make-oscil 440.0))
      (let ((val (oscil-bank amps oscs #f)))
	(if (fneq val 0.0) (snd-display #__line__ ";oscil-bank: ~A 0.0?" val))
	(set! (mus-phase (vector-ref oscs 0)) (/ pi 2))
	(set! val (oscil-bank amps oscs #f))
	(if (fneq val 1.0) (snd-display #__line__ ";oscil-bank: ~A 1.0?" val))))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (vdat (make-vct 16)))
      (vct-set! rdat 0 1.0)
      (vct-set! vdat 0 1.0)
      (let ((v0 (spectrum rdat idat (make-fft-window rectangular-window 16) 1)) ;rectangular here to avoid clobbering 0-th data point
	    (v1 (snd-spectrum vdat rectangular-window 16 #t)))
	(do ((i 0 (+ 1 i)))
	    ((= i 8)) ;should all be 1.0 (impulse in)
	  (if (fneq (vct-ref v0 i) (vct-ref v1 i))
	      (snd-display #__line__ ";spectra not equal 1: ~A ~A" v0 v1))))
      (vct-scale! idat 0.0)
      (vct-scale! rdat 0.0)
      (vct-set! rdat 0 1.0)
      (let ((v0 (spectrum rdat idat (make-fft-window rectangular-window 17) 1)) ;rectangular here to avoid clobbering 0-th data point
	    (v1 (snd-spectrum vdat rectangular-window 16 #t)))
	(do ((i 0 (+ 1 i)))
	    ((= i 8)) ;should all be 1.0 (impulse in)
	  (if (fneq (vct-ref v0 i) (vct-ref v1 i))
	      (snd-display #__line__ ";spectra not equal 0: ~A ~A" v0 v1))))
      (let ((var (catch #t (lambda () (spectrum rdat idat #f -1)) (lambda args args))))
	(if (or (vct? var) 
		(not (eq? (car var) 'out-of-range)))
	    (snd-display #__line__ ";spectrum bad type: ~A" var))))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (xdat (make-vct 16))
	  (ydat (make-vct 16))
	  (rvec (make-vector 16 0.0))
	  (ivec (make-vector 16 0.0)))
      (vct-set! rdat 0 1.0)
      (vct-set! idat 1 1.0)
      (vct-set! xdat 0 1.0)
      (vct-set! ydat 1 1.0)
      (vector-set! rvec 0 1.0)
      (vector-set! ivec 1 1.0)
      (let ((v0 (convolution rdat idat 8))
	    (v1 (vct-convolve! xdat ydat)))
	(if (or (fneq (vct-ref v0 0) 0.0) (fneq (vct-ref v0 1) 1.0)) (snd-display #__line__ ";vct convolution: ~A?" v0))
	(if (or (fneq (vct-ref v1 0) 0.0) (fneq (vct-ref v1 1) 1.0)) (snd-display #__line__ ";vct-convolve!: ~A?" v1))
	(do ((i 0 (+ 1 i)))
	    ((= i 8)) 
	  (if (fneq (vct-ref v0 i) (vct-ref v1 i))
	      (snd-display #__line__ ";convolutions not equal: ~A ~A" v0 v1))))
      (let ((var (catch #t (lambda () (convolution rdat idat -1)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display #__line__ ";convolution bad len: ~A" var)))
      (convolution rdat idat 20)
      (set! idat (make-vct 8))
      (convolution rdat idat 20))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (xdat (make-vct 16))
	  (ydat (make-vct 16)))
      (vct-set! rdat 3 1.0)
      (vct-set! xdat 3 1.0)
      (fft rdat idat 1)
      (mus-fft xdat ydat 16 1)
      (if (fneq (vct-ref rdat 0) (vct-ref xdat 0)) (snd-display #__line__ ";ffts: ~A ~A?" rdat xdat))
      (fft rdat idat -1)
      (mus-fft xdat ydat 17 -1) ; mistake is deliberate
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(if (or (and (= i 3) (or (fneq (vct-ref rdat i) 16.0) (fneq (vct-ref xdat i) 16.0)))
		(and (not (= i 3)) (or (fneq (vct-ref rdat i) 0.0) (fneq (vct-ref xdat i) 0.0))))
	    (snd-display #__line__ ";fft real[~D]: ~A ~A?" i (vct-ref rdat i) (vct-ref xdat i)))
	(if (or (fneq (vct-ref idat i) 0.0) (fneq (vct-ref ydat i) 0.0))
	    (snd-display #__line__ ";fft imag[~D]: ~A ~A?" i (vct-ref idat i) (vct-ref ydat i))))
      (let ((var (catch #t (lambda () (mus-fft xdat ydat -1 0)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display #__line__ ";mus-fft bad len: ~A" var))))
    
    (let ((rdat (make-vct 20))
	  (idat (make-vct 19)))
      (vct-set! rdat 3 1.0)
      (mus-fft rdat idat)
      (convolution rdat idat)
      (spectrum rdat idat #f))
    
    (let ((v0 (make-vct 10))
	  (v1 (make-vct 10)))
      (vct-fill! v0 1.0)
      (multiply-arrays v0 v1 1)
      (if (not (vequal v0 (vct 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)))
	  (snd-display #__line__ ";multiply-arrays[0]: ~A?" v0))
      (multiply-arrays v0 v1 100)
      (if (fneq (vct-peak v0) 0.0)
	  (snd-display #__line__ ";multiply-arrays[100]: ~A?" v0))
      (vct-fill! v0 1.0)
      (vct-fill! v1 0.5)
      (multiply-arrays v0 v1)
      (if (fneq (vct-ref v0 0) 0.5) (snd-display #__line__ ";multiple-arrays: ~F?" (vct-ref v0 0)))
      (let ((sum (dot-product v0 v1)))
	(if (fneq sum 2.5) (snd-display #__line__ ";dot-product: ~F?" sum)))
      (let ((sum (dot-product v0 v1 10)))
	(if (fneq sum 2.5) (snd-display #__line__ ";dot-product (10): ~F?" sum)))
      (let ((sum (dot-product v0 v1 3)))
	(if (fneq sum 0.75) (snd-display #__line__ ";dot-product (3): ~F?" sum)))
      (clear-array v0)
      (if (fneq (vct-ref v0 3) 0.0) (snd-display #__line__ ";clear-array: ~A?" v0))
      (vct-fill! v0 1.0)
      (vct-fill! v1 0.5)
      (let ((v2 (rectangular->polar v0 v1)))
	(if (fneq (vct-ref v2 0) 1.118) (snd-display #__line__ ";rectangular->polar: ~A?" v2)))
      (vct-set! v0 0 1.0)
      (vct-set! v1 0 1.0)
      (rectangular->polar v0 v1)
      (if (or (fneq (vct-ref v0 0) (sqrt 2.0))
	      (fneq (vct-ref v1 0) (- (atan 1.0 1.0)))) ;(tan (atan 1.0 1.0)) -> 1.0 
	  (snd-display #__line__ ";rectangular->polar (~A ~A): ~A ~A?" (sqrt 2.0) (- (atan 1.0 1.0)) (vct-ref v0 0) (vct-ref v1 0)))
      (polar->rectangular v0 v1)
      (if (or (fneq (vct-ref v0 0) 1.0)
	      (fneq (vct-ref v1 0) 1.0))
	  (snd-display #__line__ ";polar->rectangular (1 1): ~A ~A?" (vct-ref v0 0) (vct-ref v1 0)))
      
      (let ((v0 (make-vct 1))
	    (v1 (make-vct 1))
	    (v (make-vct 1))
	    (val .123))
	(vct-set! v0 0 1.0)
	(vct-set! v1 0 1.0)
	(vct-map! v (lambda ()
		      (rectangular->polar v0 v1)
		      (set! val (vct-ref v0 0))
		      (polar->rectangular v0 v1)
		      (vct-ref v1 0)))
	(if (fneq (vct-ref v 0) 1.0) (snd-display #__line__ ";run r->p not inverted: ~A" v))
	(if (fneq val (sqrt 2.0)) (snd-display #__line__ ";r->p: ~A" val)))
      
      (let* ((ind (open-sound "oboe.snd"))
	     (rl (samples->vct 1200 512))
	     (im (make-vct 512)))
	(fft rl im 512)
	(let ((rl-copy (vct-copy rl))
	      (im-copy (vct-copy im)))
	  (rectangular->polar rl im)
	  (polar->rectangular rl im)
	  (do ((i 0 (+ 1 i)))
	      ((= i 512))
	    (if (or (fneq (vct-ref rl i) (vct-ref rl-copy i))
		    (fneq (vct-ref im i) (vct-ref im-copy i)))
		(snd-display #__line__ ";polar->rectangular[~D]: ~A ~A ~A ~A" 
			     i 
			     (vct-ref rl i) (vct-ref rl-copy i)
			     (vct-ref im i) (vct-ref im-copy i)))))
	(close-sound ind)))
    
    (let ((v0 (make-vct 8))
	  (v1 (make-vct 8)))
      (do ((i 0 (+ i 1))) ((= i 8)) (vct-set! v0 i i) (vct-set! v1 i (/ (+ i 1))))
      (rectangular->magnitudes v0 v1)
      (if (not (vequal v0 (vct 1.000 1.118 2.028 3.010 4.005 5.003 6.002 7.001)))
	  (snd-display #__line__ ";rectangular->magnitudes v0: ~A" v0)))
    
    (let ((v0 (make-vct 8))
	  (v1 (make-vct 8))
	  (v2 (make-vct 8))
	  (v3 (make-vct 8)))
      (do ((i 0 (+ i 1)))
	  ((= i 8))
	(let ((val1 (random 1.0))
	      (val2 (random 1.0)))
	  (vct-set! v0 i val1)
	  (vct-set! v2 i val1)
	  (vct-set! v1 i val2)
	  (vct-set! v3 i val2)))
      (rectangular->magnitudes v0 v1)
      (rectangular->polar v2 v3)
      (if (not (vequal v0 v2))
	  (snd-display #__line__ ";rectangular->magnitudes|polar: ~A ~A" v0 v2)))
    
    (if (defined? 'edot-product) ; needs complex numbers in C
	(let* ((vals (make-vct 1 1.0))
	       (v1 (edot-product 0.0 vals)))
	  (if (fneq v1 1.0) ; exp 0.0 * 1.0
	      (snd-display #__line__ ";edot a 1.0: ~A" v1))
	  (vct-set! vals 0 0.0)
	  (set! v1 (edot-product 0.0 vals))
	  (if (fneq v1 0.0) ; exp 0.0 * 0.0
	      (snd-display #__line__ ";edot b 0.0: ~A" v1))
	  (set! vals (make-vector 1 1.0))
	  (set! v1 (edot-product 0.0 vals))  
	  (if (fneq v1 1.0) ; exp 0.0 * 1.0
	      (snd-display #__line__ ";edot c 1.0: ~A" v1))
	  (vector-set! vals 0 0.0+i)
	  (set! v1 (edot-product 0.0 vals))
	  (if (cneq v1 0.0+i)
	      (snd-display #__line__ ";edot i: ~A" v1))
	  (set! vals (make-vct 4 1.0))
	  (set! v1 (edot-product (* 0.25 2 pi) vals))
	  (let ((v2 (+ (exp (* 0 2 pi))
		       (exp (* 0.25 2 pi))
		       (exp (* 0.5 2 pi))
		       (exp (* 0.75 2 pi)))))
	    (if (fneq v1 v2) (snd-display #__line__ ";edot 4: ~A ~A" v1 v2)))
	  (set! vals (make-vector 4 0.0))  
	  (do ((i 0 (+ 1 i)))
	      ((= i 4))
	    (vector-set! vals i (+ i 1.0)))
	  (set! v1 (edot-product (* 0.25 2 pi 0.0-i) vals))
	  (let ((v2 (+ (* 1 (exp (* 0 2 pi 0.0-i)))
		       (* 2 (exp (* 0.25 2 pi 0.0-i)))
		       (* 3 (exp (* 0.5 2 pi 0.0-i)))
		       (* 4 (exp (* 0.75 2 pi 0.0-i))))))
	    (if (cneq v1 v2) (snd-display #__line__ ";edot 4 -i: ~A ~A" v1 v2)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 4))
	    (vector-set! vals i (+ i 1.0+i)))
	  (set! v1 (edot-product (* 0.25 2 pi 0.0-i) vals))
	  (let ((v2 (+ (* 1+i (exp (* 0 2 pi 0.0-i)))
		       (* 2+i (exp (* 0.25 2 pi 0.0-i)))
		       (* 3+i (exp (* 0.5 2 pi 0.0-i)))
		       (* 4+i (exp (* 0.75 2 pi 0.0-i))))))
	    (if (cneq v1 v2) (snd-display #__line__ ";edot 4 -i * i: ~A ~A" v1 v2)))))
    
    (let ((v0 (make-vct 3)))
      (vct-set! v0 0 1.0)
      (vct-set! v0 1 0.5)
      (vct-set! v0 2 0.1)
      (if (or (fneq (polynomial v0 0.0) 1.0)
	      (fneq (polynomial v0 1.0) 1.6)
	      (fneq (polynomial v0 2.0) 2.4))
	  (snd-display #__line__ ";polynomial: ~A ~A ~A?"
		       (polynomial v0 0.0)
		       (polynomial v0 1.0)
		       (polynomial v0 2.0))))
    (if (fneq (polynomial (vct 0.0 2.0) 0.5) 1.0) 
	(snd-display #__line__ ";polynomial 2.0 * 0.5: ~A" (polynomial (vct 2.0) 0.5)))
    (let ((var (catch #t (lambda () (polynomial #f 1.0)) (lambda args args))))
      (if (not (eq? (car var) 'wrong-type-arg))
	  (snd-display #__line__ ";polynomial empty coeffs: ~A" var)))
    
    (do ((i 0 (+ i 1)))
	((= i 100))
      (let ((arg1 (- (random 100.0) 50.0))
	    (arg2 (- (random 100.0) 50.0)))
	(let ((val1 (fmod arg1 arg2))
	      (val2 (modulo arg1 arg2)))
	  (if (and (> (abs (- val1 val2)) 1e-8)
		   (> (abs (- (abs (- val1 val2)) (abs arg2))) 1e-8))
	      (format #t "~A ~A: ~A ~A -> ~A~%" arg1 arg2 val1 val2 (abs (- val1 val2)))))))
    
    (let ((err 0.0)
	  (coeffs (vct 1.0 0.0 -.4999999963 0.0 .0416666418 0.0 -.0013888397 0.0 .0000247609 0.0 -.0000002605))
	  (pi2 (* pi 0.5)))
      (letrec ((new-cos
		(lambda (x)
		  (let ((xx (abs x)))
		    (if (<= xx pi2)
			(polynomial coeffs xx)
			(let ((nxx (fmod xx (* 2 pi))))
			  (if (<= nxx pi2)
			      (polynomial coeffs nxx)
			      (if (<= nxx pi)
				  (- (polynomial coeffs (- pi nxx)))
				  (if (< nxx (* 1.5 pi))
				      (- (polynomial coeffs (- nxx pi)))
				      (polynomial coeffs (- (* 2 pi) nxx)))))))))))
	(do ((i 0 (+ 1 i))
	     (x -10.0 (+ x .01)))
	    ((= i 2000))
	  (let ((diff (abs (- (cos x) (new-cos x)))))
	    (if (> diff err)
		(set! err diff))))
	(if (> err 1.1e-7) (snd-display #__line__ ";new-cos poly err: ~A" err))))
    
    (let ((val (poly+ (vct .1 .2 .3) (vct 0.0 1.0 2.0 3.0 4.0))))
      (if (not (vequal val (vct 0.100 1.200 2.300 3.000 4.000))) (snd-display #__line__ ";poly+ 1: ~A" val)))
    
    (let ((val (poly+ (vct .1 .2 .3) .5)))
      (if (not (vequal val (vct 0.600 0.200 0.300))) (snd-display #__line__ ";poly+ 2: ~A" val)))
    (let ((val (poly+ .5 (vct .1 .2 .3))))
      (if (not (vequal val (vct 0.600 0.200 0.300))) (snd-display #__line__ ";poly+ 3: ~A" val)))
    
    (let ((val (poly* (vct 1 1) (vct -1 1))))
      (if (not (vequal val (vct -1.000 0.000 1.000 0.000))) (snd-display #__line__ ";poly* 1: ~A" val)))
    (let ((val (poly* (vct -5 1) (vct 3 7 2))))
      (if (not (vequal val (vct -15.000 -32.000 -3.000 2.000 0.000))) (snd-display #__line__ ";poly* 2: ~A" val)))
    (let ((val (poly* (vct -30 -4 2) (vct 0.5 1))))
      (if (not (vequal val (vct -15.000 -32.000 -3.000 2.000 0.000))) (snd-display #__line__ ";poly* 3: ~A" val)))
    (let ((val (poly* (vct -30 -4 2) 0.5)))
      (if (not (vequal val (vct -15.000 -2.000 1.000))) (snd-display #__line__ ";poly* 4: ~A" val)))
    (let ((val (poly* 2.0 (vct -30 -4 2))))
      (if (not (vequal val (vct -60.000 -8.000 4.000))) (snd-display #__line__ ";poly* 5: ~A" val)))
    
    (let ((val (poly/ (vct -1.0 -0.0 1.0) (vct 1.0 1.0))))
      (if (or (not (vequal (car val) (vct -1.000 1.000 0.000)))
	      (not (vequal (cadr val) (vct 0.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 1: ~A" val)))
    (let ((val (poly/ (vct -15 -32 -3 2) (vct -5 1))))
      (if (or (not (vequal (car val) (vct 3.000 7.000 2.000 0.000)))
	      (not (vequal (cadr val) (vct 0.000 0.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 2: ~A" val)))
    (let ((val (poly/ (vct -15 -32 -3 2) (vct 3 1))))
      (if (or (not (vequal (car val) (vct -5.000 -9.000 2.000 0.000)))
	      (not (vequal (cadr val) (vct 0.000 0.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 3: ~A" val)))
    (let ((val (poly/ (vct -15 -32 -3 2) (vct .5 1))))
      (if (or (not (vequal (car val) (vct -30.000 -4.000 2.000 0.000)))
	      (not (vequal (cadr val) (vct 0.000 0.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 4: ~A" val)))
    (let ((val (poly/ (vct -15 -32 -3 2) (vct 3 7 2))))
      (if (or (not (vequal (car val) (vct -5.000 1.000 0.000 0.000)))
	      (not (vequal (cadr val) (vct 0.000 0.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 5: ~A" val)))
    (let ((val (poly/ (vct -15 -32 -3 2) 2.0)))
      (if (not (vequal (car val) (vct -7.500 -16.000 -1.500 1.000)))
	  (snd-display #__line__ ";poly/ 6: ~A" val)))
    (let ((val (poly/ (vct -1.0 0.0 0.0 0.0 1.0) (vct 1.0 0.0 1.0))))
      (if (or (not (vequal (car val) (vct -1.0 0.0 1.0 0.0 0.0)))
	      (not (vequal (cadr val) (make-vct 5))))
	  (snd-display #__line__ ";poly/ 7: ~A" val)))
    (let ((val (poly/ (vct -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0) (vct 1.0 0.0 0.0 0.0 1.0))))
      (if (or (not (vequal (car val) (vct -1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0)))
	      (not (vequal (cadr val) (make-vct 9))))
	  (snd-display #__line__ ";poly/ 8: ~A" val)))
    (let ((val (poly/ (vct -1.0 0.0 1.0) (vct -1.0 0.0 1.0))))
      (if (or (not (vequal (car val) (vct 1.0 0.0 0.0)))
	      (not (vequal (cadr val) (make-vct 3))))
	  (snd-display #__line__ ";poly/ 9: ~A" val)))
    (let ((val (poly/ (vct -1.0 0.0 1.0) (vct 2.0 1.0))))
      (if (or (not (vequal (car val) (vct -2.000 1.000 0.000)))
	      (not (vequal (cadr val) (vct 3.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 10: ~A" val)))
    (let ((val (poly/ (vct 2 1) (vct -1.0 0.0 1.0))))
      (if (or (not (vequal (car val) (vct 0.0)))
	      (not (vequal (cadr val) (vct -1.000 0.000 1.000))))
	  (snd-display #__line__ ";poly/ 11: ~A" val)))
    (let ((val (poly/ (vct 1 2 3 0 1) (vct 0 0 0 1))))
      (if (or (not (vequal (car val) (vct 0.000 1.000 0.000 0.000 0.000)))
	      (not (vequal (cadr val) (vct 1.000 2.000 3.000 0.000 0.000))))
	  (snd-display #__line__ ";poly/ 12: ~A" val)))
    
    (let ((ind (open-sound "1a.snd")))
      (let ((v1 (channel->vct 0 100 ind 0))
	    (v2 (channel->vct 0 100 ind 0)))
	(let ((vals (car (poly/ v1 v2)))
	      (res (make-vct 100)))
	  (vct-set! res 0 1.0)
	  (if (not (vequal vals res))
	      (snd-display #__line__ ";poly1 1a: ~A" vals))))
      (close-sound ind))
    
    (let ((val (poly-derivative (vct 0.5 1.0 2.0 4.0))))
      (if (not (vequal val (vct 1.000 4.000 12.000))) (snd-display #__line__ ";poly-derivative: ~A" val)))
    
    (let ((val (poly-reduce (vct 1 2 3))))
      (if (not (vequal val (vct 1.000 2.000 3.000))) (snd-display #__line__ ";poly-reduce 1: ~A" val)))
    (let ((val (poly-reduce (vct 1 2 3 0 0 0))))
      (if (not (vequal val (vct 1.000 2.000 3.000))) (snd-display #__line__ ";poly-reduce 2: ~A" val)))
    (let ((val (poly-reduce (vct 0 0 0 0 1 0))))
      (if (not (vequal val (vct 0.000 0.000 0.000 0.000 1.000))) (snd-display #__line__ ";poly-reduce 3: ~A" val)))
    
    (let ((vals (poly-gcd (poly-reduce (poly* (vct 2 1) (vct -3 1))) (vct 2 1))))
      (if (not (vequal vals (vct 2.000 1.000))) (snd-display #__line__ ";poly-gcd 1: ~A" vals)))
    (let ((vals (poly-gcd (poly-reduce (poly* (vct 2 1) (vct -3 1))) (vct 3 1))))
      (if (not (vequal vals (vct 0.000))) (snd-display #__line__ ";poly-gcd 2: ~A" vals)))
    (let ((vals (poly-gcd (poly-reduce (poly* (vct 2 1) (vct -3 1))) (vct -3 1))))
      (if (not (vequal vals (vct -3.000 1.000))) (snd-display #__line__ ";poly-gcd 2: ~A" vals)))
    (let ((vals (poly-gcd (poly-reduce (poly* (vct 8 1) (poly* (vct 2 1) (vct -3 1)))) (vct -3 1))))
      (if (not (vequal vals (vct -3.000 1.000))) (snd-display #__line__ ";poly-gcd 3: ~A" vals)))
    (let ((vals (poly-gcd (poly-reduce (poly* (vct 8 1) (poly* (vct 2 1) (vct -3 1)))) (poly-reduce (poly* (vct 8 1) (vct -3 1))))))
      (if (not (vequal vals (vct -24.000 5.000 1.000))) (snd-display #__line__ ";poly-gcd 4: ~A" vals)))
    (let ((vals (poly-gcd (vct -1 0 1) (vct 2 -2 -1 1))))
      (if (not (vequal vals (vct 0.000))) (snd-display #__line__ ";poly-gcd 5: ~A" vals)))
    (let ((vals (poly-gcd (vct 2 -2 -1 1) (vct -1 0 1))))
      (if (not (vequal vals (vct 1.000 -1.000))) (snd-display #__line__ ";poly-gcd 6: ~A" vals)))
    (let ((vals (poly-gcd (vct 2 -2 -1 1) (vct -2.5 1))))
      (if (not (vequal vals (vct 0.000))) (snd-display #__line__ ";poly-gcd 7: ~A" vals)))
    
    (poly-roots-tests)
    
    (let ((val (poly-as-vector-resultant (vector -1 0 1) (vector 1 -2 1))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-resultant 0: ~A" val)))
    (let ((val (poly-as-vector-resultant (vector -1 0 2) (vector 1 -2 1))))
      (if (fneq val 1.0) (snd-display #__line__ ";poly-resultant 1: ~A" val)))
    (let ((val (poly-as-vector-resultant (vector -1 0 1) (vector 1 1))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-resultant 2: ~A" val)))
    (let ((val (poly-as-vector-resultant (vector -1 0 1) (vector 2 1))))
      (if (fneq val 3.0) (snd-display #__line__ ";poly-resultant 3: ~A" val)))
    (let ((val (poly-resultant (vct -1 0 1) (vct 1 -2 1))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-resultant 0: ~A" val)))
    
    (let ((val (poly-as-vector-discriminant (vector -1 0 1))))
      (if (fneq val -4.0) (snd-display #__line__ ";poly-discriminant 0: ~A" val)))
    (let ((val (poly-as-vector-discriminant (vector 1 -2 1))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-discriminant 1: ~A" val)))
    (let ((val (poly-discriminant (poly-reduce (poly* (poly* (vct -1 1) (vct -1 1)) (vct 3 1))))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-discriminant 2: ~A" val)))
    (let ((val (poly-discriminant (poly-reduce (poly* (poly* (poly* (vct -1 1) (vct -1 1)) (vct 3 1)) (vct 2 1))))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-discriminant 3: ~A" val)))
    (let ((val (poly-discriminant (poly-reduce (poly* (poly* (poly* (vct 1 1) (vct -1 1)) (vct 3 1)) (vct 2 1))))))
      (if (fneq val 2304.0) (snd-display #__line__ ";poly-discriminant 4: ~A" val)))
    (let ((val (poly-discriminant (poly-reduce (poly* (poly* (poly* (vct 1 1) (vct -1 1)) (vct 3 1)) (vct 3 1))))))
      (if (fneq val 0.0) (snd-display #__line__ ";poly-discriminant 5: ~A" val)))
    
    
    (let ((v0 (make-vct 10)))
      (do ((i 0 (+ 1 i))) ((= i 10))
	(vct-set! v0 i i))
      (if (fneq (array-interp v0 3.5) 3.5) (snd-display #__line__ ";array-interp: ~F?" (array-interp v0 3.5)))
      (if (fneq (array-interp v0 13.5) 3.5) (snd-display #__line__ ";array-interp(13.5): ~F?" (array-interp v0 13.5)))
      (if (fneq (array-interp v0 -6.5) 3.5) (snd-display #__line__ ";array-interp(-6.5): ~F?" (array-interp v0 -6.5)))
      (if (fneq (array-interp v0 103.6) 3.6) (snd-display #__line__ ";array-interp(103.5): ~F?" (array-interp v0 103.6)))
      (if (fneq (array-interp v0 -106.6) 3.4) (snd-display #__line__ ";array-interp(-106.6): ~F?" (array-interp v0 -106.6)))
      (if (fneq (array-interp v0 -0.5) 4.5) (snd-display #__line__ ";array-interp(-0.5): ~F?" (array-interp v0 -0.5)))
      ;; interpolating between 9 and 0 here (confusing...)
      (if (fneq (array-interp v0 -0.9) 8.1) (snd-display #__line__ ";array-interp(-0.9): ~F?" (array-interp v0 -0.9)))
      (if (fneq (array-interp v0 -0.1) 0.9) (snd-display #__line__ ";array-interp(-0.1): ~F?" (array-interp v0 -0.1)))
      (if (fneq (array-interp v0 9.1) 8.1) (snd-display #__line__ ";array-interp(9.1): ~F?" (array-interp v0 9.1)))
      (if (fneq (array-interp v0 9.9) 0.9) (snd-display #__line__ ";array-interp(9.9): ~F?" (array-interp v0 9.9)))
      (if (fneq (array-interp v0 10.1) 0.1) (snd-display #__line__ ";array-interp(10.1): ~F?" (array-interp v0 10.1)))
      (let ((var (catch #t (lambda () (array-interp v0 1 -10)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display #__line__ ";array-interp bad index: ~A" var))))
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((diff (array-interp-sound-diff ind 0)))
	(if (> diff .00001) (snd-display #__line__ ";array-interp-sound-diff: ~A" diff)))
      (close-sound ind))
    
    (let ((v0 (make-vct 10)))
      (do ((i 0 (+ 1 i))) ((= i 10))
	(vct-set! v0 i i))
      (let ((val (mus-interpolate mus-interp-linear 1.5 v0)))
	(if (fneq val 1.5) (snd-display #__line__ ";mus-interpolate linear: ~A" val))
	(set! val (mus-interpolate mus-interp-all-pass 1.5 v0))
	(if (fneq val 1.5) (snd-display #__line__ ";mus-interpolate all-pass: ~A" val))
	(set! val (mus-interpolate mus-interp-none 1.5 v0))
	(if (fneq val 1.0) (snd-display #__line__ ";mus-interpolate none: ~A" val))
	(set! val (mus-interpolate mus-interp-hermite 1.5 v0))
	(if (fneq val 1.5) (snd-display #__line__ ";mus-interpolate hermite: ~A" val))
	(set! val (mus-interpolate mus-interp-bezier 1.5 v0))
	(if (fneq val 1.5) (snd-display #__line__ ";mus-interpolate bezier: ~A" val))
	(set! val (mus-interpolate mus-interp-lagrange 1.5 v0))
	(if (fneq val 1.5) (snd-display #__line__ ";mus-interpolate lagrange: ~A" val))
	(do ((i 0 (+ 1 i))) ((= i 10)) (vct-set! v0 i (sin (* pi (/ i 5)))))
	(set! val (mus-interpolate mus-interp-linear 1.5 v0))
	(if (fneq val 0.7694) (snd-display #__line__ ";mus-interpolate linear sin: ~A" val))
	(set! val (mus-interpolate mus-interp-all-pass 1.5 v0))
	(if (fneq val 0.7694) (snd-display #__line__ ";mus-interpolate all-pass sin: ~A" val))
	(set! val (mus-interpolate mus-interp-none 1.5 v0))
	(if (fneq val 0.5877) (snd-display #__line__ ";mus-interpolate none sin: ~A" val))
	(set! val (mus-interpolate mus-interp-hermite 1.5 v0))
	(if (fneq val 0.8061) (snd-display #__line__ ";mus-interpolate hermite sin: ~A" val))
	(set! val (mus-interpolate mus-interp-bezier 1.5 v0))
	(if (fneq val 0.6959) (snd-display #__line__ ";mus-interpolate bezier sin: ~A" val))
	(set! val (mus-interpolate mus-interp-lagrange 1.5 v0))
	(if (fneq val 0.7975) (snd-display #__line__ ";mus-interpolate lagrange sin: ~A" val))))
    
    (let ((tag (catch #t (lambda () (mus-interpolate 1234 1.0 (make-vct 3))) (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range))
	  (snd-display #__line__ ";mus-interpolate 1234: ~A" tag)))
    (let ((tag (catch #t (lambda () (mus-interpolate mus-interp-linear 1.0 (make-vct 3) -1)) (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range))
	  (snd-display #__line__ ";mus-interpolate size -1: ~A" tag)))
    
    (let ((gen (make-delay 3))
	  (gen2 (make-delay 3))
	  (gen1 (make-delay 4 :initial-contents '(1.0 0.5 0.25 0.0)))
	  (gen3 (make-delay 4 :initial-contents (vct 1.0 0.5 0.25 0.0)))
	  (v0 (make-vct 10))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "delay" 
		       "delay line[3, step]: [0.000 0.000 0.000]")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (delay gen i)))
      (vct-map! v1 (let ((i 0)) (lambda () (let ((val (if (delay? gen2) (delay gen2 i) -1.0))) (set! i (+ 1 i)) val))))
      (if (not (vequal v1 v0)) (snd-display #__line__ ";map delay: ~A ~A" v0 v1))
      (if (not (delay? gen)) (snd-display #__line__ ";~A not delay?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";delay length: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) 0.0) (fneq (vct-ref v0 4) 1.0) (fneq (vct-ref v0 8) 5.0))
	  (snd-display #__line__ ";delay output: ~A" v0))
      (if (or (fneq (delay gen1) 1.0) 
	      (fneq (delay gen1) 0.5)
	      (fneq (delay gen1) 0.25)
	      (fneq (delay gen1) 0.0)
	      (fneq (delay gen1) 0.0))
	  (snd-display #__line__ ";delay with list initial-contents confused"))
      (if (or (fneq (delay gen3) 1.0) 
	      (fneq (delay gen3) 0.5)
	      (fneq (delay gen3) 0.25)
	      (fneq (delay gen3) 0.0)
	      (fneq (delay gen3) 0.0))
	  (snd-display #__line__ ";delay with vct initial-contents confused"))
      (let ((var (catch #t (lambda () (make-delay :size #f)) (lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display #__line__ ";make-delay bad size #f: ~A" var)))
      (let ((var (catch #t (lambda () (make-delay 3 :initial-element (make-oscil))) (lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display #__line__ ";make-delay bad initial element: ~A" var)))
      (let ((var (catch #t (lambda () (make-delay -3)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display #__line__ ";make-delay bad size: ~A" var))))
    
    (test-gen-equal (let ((d1 (make-delay 3))) (delay d1 1.0) d1) 
		    (let ((d2 (make-delay 3))) (delay d2 1.0) d2)
		    (let ((d3 (make-delay 4))) (delay d3 1.0) d3))
    (test-gen-equal (make-delay 3 :initial-element 1.0) (make-delay 3 :initial-element 1.0) (make-delay 3 :initial-element 0.5))
    (test-gen-equal (make-delay 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-delay 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-delay 3 :initial-contents '(1.0 1.0 1.0)))
    
    (let ((gen (make-delay 5)))
      (delay gen 1.0)
      (delay gen 0.0)
      (delay gen 0.5)
      (let ((data (vct-copy (mus-data gen))))
	(vct-set! (mus-data gen) 0 0.3)
	(if (fneq (vct-ref (mus-data gen) 0) 0.3)
	    (snd-display #__line__ ";delay data 0: ~A" (vct-ref (mus-data gen) 0)))
	(vct-set! data 0 .75)
	(set! (mus-data gen) data)
	(if (fneq (vct-ref (mus-data gen) 0) 0.75)
	    (snd-display #__line__ ";delay set data 0: ~A" (vct-ref (mus-data gen) 0)))
	(delay gen 0.0)
	(delay gen 0.0)
	(let ((val (delay gen 0.0)))
	  (if (fneq val 0.75)
	      (snd-display #__line__ ";set delay data: ~A ~A" val (mus-data gen)))))
      (if (mus-data (make-oscil))
	  (snd-display #__line__ ";mus-data osc: ~A" (mus-data (make-oscil)))))
    
    (let* ((del (make-delay 5 :max-size 8)))
      (delay del 1.0)
      (do ((i 0 (+ 1 i))) ((= i 4)) (delay del 0.0))
      (let ((v0 (make-vct 5)))
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (vct-set! v0 i (delay del 0.0 0.4)))
	(if (not (vequal v0 (vct 0.600 0.400 0.000 0.000 0.000)))
	    (snd-display #__line__ ";zdelay: ~A" v0))
	(delay del 1.0)
	(delay del 0.0 0.4)
	(if (not (string=? (mus-describe del) "delay line[5,8, linear]: [0.000 0.000 1.000 0.000 0.000]"))
	    (snd-display #__line__ ";describe zdelay: ~A" (mus-describe del)))))
    (let ((tag (catch #t (lambda () 
			   (let ((gen (make-oscil)))
			     (tap gen)))
		      (lambda args (car args)))))
      (if (not (eq? tag 'wrong-type-arg))
	  (snd-display #__line__ ";tap of oscil: ~A" tag)))
    
    (let ((dly (make-delay 3))
	  (flt (make-one-zero .5 .4))
	  (v (make-vct 20))
	  (inval 1.0))
      (vct-map! v (lambda ()
		    (let ((res (delay dly (+ inval (* (one-zero flt (tap dly)) .6)))))
		      (set! inval 0.0)
		      res)))
      (if (not (vequal v (vct 0.0 0.0 0.0 1.0 0.0 0.0 0.300 0.240 0.0 0.090 0.144 0.058 0.027 0.065 0.052 0.022 0.026 0.031 0.019 0.013)))
	  (snd-display #__line__ ";tap with low pass: ~A" v)))
    
    (let ((dly (make-delay 3))
	  (v (make-vct 20))
	  (inval 1.0))
      (vct-map! v (lambda ()
		    (let ((res (delay dly (+ inval (tap dly)))))
		      (set! inval 0.0)
		      res)))
      (if (not (vequal v (vct 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0)))
	  (snd-display #__line__ ";simple tap: ~A" v)))
    
    (let ((dly (make-delay 6))
	  (v (make-vct 20))
	  (inval 1.0))
      (vct-map! v (lambda ()
		    (let ((res (delay dly (+ inval (tap dly -2.0)))))
		      (set! inval 0.0)
		      res)))
      (set! (print-length) (max 20 (print-length)))
      (if (not (vequal v (vct 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0)))
	  (snd-display #__line__ ";tap back 2: ~A" v)))
    
    (let ((dly (make-delay 3))
	  (flt (make-one-zero .5 .4))
	  (v (make-vct 20))
	  (inval 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 20))
	(vct-set! v i (let ((res (delay dly (+ inval (* (one-zero flt (tap dly)) .6)))))
			(set! inval 0.0)
			res)))
      (if (not (vequal v (vct 0.0 0.0 0.0 1.0 0.0 0.0 0.300 0.240 0.0 0.090 0.144 0.058 0.027 0.065 0.052 0.022 0.026 0.031 0.019 0.013)))
	  (snd-display #__line__ ";tap with low pass: ~A" v)))
    
    (let ((dly (make-delay 3 :initial-element 32.0)))
      (if (not (vct? (mus-data dly))) 
	  (snd-display #__line__ ";delay data not vct?")
	  (if (not (= (vct-length (mus-data dly)) 3))
	      (snd-display #__line__ ";delay data len not 3: ~A (~A)" (vct-length (mus-data dly)) (mus-data dly))
	      (if (fneq (vct-ref (mus-data dly) 1) 32.0) (snd-display #__line__ ";delay [1] 32: ~A" (vct-ref (mus-data dly) 1)))))
      (let ((tag (catch #t (lambda () (set! (mus-length dly) -1)) (lambda args (car args)))))
	(if (not (equal? tag 'out-of-range)) (snd-display #__line__ ";len to -1 -> ~A" tag)))
      (let ((tag (catch #t (lambda () (set! (mus-length dly) 0)) (lambda args (car args)))))
	(if (not (equal? tag 'out-of-range)) (snd-display #__line__ ";len to 0 -> ~A" tag)))
      (let ((tag (catch #t (lambda () (set! (mus-length dly) 100)) (lambda args (car args)))))
	(if (not (equal? tag 'out-of-range)) (snd-display #__line__ ";len to 100 -> ~A" tag)))
      (let ((tag (catch #t (lambda () (set! (vct-ref (mus-data dly) 100) .1)) (lambda args (car args)))))
	(if (not (equal? tag 'out-of-range)) (snd-display #__line__ ";data 100 to .1 -> ~A" tag)))
      (let ((data (make-vct 32 1.0)))
	(set! (mus-data dly) data)
	(if (not (vct? (mus-data dly))) (snd-display #__line__ ";set delay data not vct?"))
	(if (fneq (vct-ref (mus-data dly) 1) 1.0) (snd-display #__line__ ";set delay [1] 1: ~A" (vct-ref (mus-data dly) 1)))
	(if (not (= (vct-length (mus-data dly)) 32)) (snd-display #__line__ ";set delay data len(32): ~A" (vct-length (mus-data dly))))
	(let ((tag (catch #t (lambda () (set! (mus-length dly) 100)) (lambda args (car args)))))
	  (if (not (equal? tag 'out-of-range)) (snd-display #__line__ ";set len to 100 -> ~A" tag)))
	(let ((tag (catch #t (lambda () (set! (vct-ref (mus-data dly) 100) .1)) (lambda args (car args)))))
	  (if (not (equal? tag 'out-of-range)) (snd-display #__line__ ";set data 100 to .1 -> ~A" tag)))))
    
    (let ((d1 (make-delay 4))
	  (d2 (make-delay 4 :max-size 5 :type mus-interp-linear))
	  (d3 (make-delay 4 :max-size 5 :type mus-interp-all-pass))
	  (d4 (make-delay 4 :max-size 5 :type mus-interp-none))
	  (d5 (make-delay 4 :max-size 4 :type mus-interp-lagrange))
	  (d6 (make-delay 4 :max-size 4 :type mus-interp-hermite))
	  (d7 (make-delay 4 :max-size 4 :type mus-interp-linear))
	  (v1 (make-vct 20))
	  (v2 (make-vct 20))
	  (v3 (make-vct 20))
	  (v4 (make-vct 20))
	  (v5 (make-vct 20))
	  (v6 (make-vct 20))
	  (v7 (make-vct 20)))
      (if (not (= (mus-interp-type d1) mus-interp-none)) (snd-display #__line__ ";d1 interp type: ~A" (mus-interp-type d1)))
      (if (not (= (mus-interp-type d2) mus-interp-linear)) (snd-display #__line__ ";d2 interp type: ~A" (mus-interp-type d2)))
      (if (not (= (mus-interp-type d3) mus-interp-all-pass)) (snd-display #__line__ ";d3 interp type: ~A" (mus-interp-type d3)))
      (if (not (= (mus-interp-type d4) mus-interp-none)) (snd-display #__line__ ";d4 interp type: ~A" (mus-interp-type d4)))
      (if (not (= (mus-interp-type d5) mus-interp-lagrange)) (snd-display #__line__ ";d5 interp type: ~A" (mus-interp-type d5)))
      (if (not (= (mus-interp-type d6) mus-interp-hermite)) (snd-display #__line__ ";d6 interp type: ~A" (mus-interp-type d6)))
      (if (not (= (mus-interp-type d7) mus-interp-linear)) (snd-display #__line__ ";d7 interp type: ~A" (mus-interp-type d7)))
      (vct-set! v1 0 (delay d1 1.0))
      (vct-set! v2 0 (delay d2 1.0))
      (vct-set! v3 0 (delay d3 1.0))
      (vct-set! v4 0 (delay d4 1.0))
      (vct-set! v5 0 (delay d5 1.0))
      (vct-set! v6 0 (delay d6 1.0))
      (vct-set! v7 0 (delay d7 1.0))
      (delay-tick d1 0.0)
      (delay-tick d2 0.0)
      (delay-tick d3 0.0)
      (delay-tick d4 0.0)
      (delay-tick d5 0.0)
      (delay-tick d6 0.0)
      (delay-tick d7 0.0)
      (do ((i 1 (+ 1 i))
	   (j -0.2 (- j 0.2)))
	  ((= i 20))
	(vct-set! v1 i (tap d1 j))
	(vct-set! v2 i (tap d2 j))
	(vct-set! v3 i (tap d3 j))
	(vct-set! v4 i (tap d4 j))
	(vct-set! v5 i (tap d5 j))
	(vct-set! v6 i (tap d6 j))
	(vct-set! v7 i (tap d7 j)))
      (set! (print-length) (max 20 (print-length)))
      (if (and (not (vequal v1 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0)))
	       (not (vequal v1 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0))))
	  (snd-display #__line__ ";delay interp none (1): ~A" v1))
      (if (not (vequal v2 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.200 0.400 0.600 0.800 1.0 0.800 0.600 0.400 0.200 0.0 0.0 0.0 0.0 0.0)))
	  (snd-display #__line__ ";delay interp linear (2): ~A" v2))
      (if (not (vequal v3 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.600 0.160 0.168 -0.168 0.334 0.199 0.520 0.696 -0.696 0.557 -0.334 0.134 -0.027)))
	  (snd-display #__line__ ";delay interp all-pass (3): ~A" v3))
      (if (and (not (vequal v4 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0)))
	       (not (vequal v4 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0))))
	  (snd-display #__line__ ";delay interp none (4): ~A" v4))
      (if (not (vequal v5 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.120 0.280 0.480 0.720 1.000 0.960 0.840 0.640 0.360 0.000 -0.080 -0.120 -0.120 -0.080)))
	  (snd-display #__line__ ";delay interp lagrange (5): ~A" v5))
      (if (not (vequal v6 (vct 0.0 -0.016 -0.048 -0.072 -0.064 0.0 0.168 0.424 0.696 0.912 1.0 0.912 0.696 0.424 0.168 0.0 -0.064 -0.072 -0.048 -0.016)))
	  (snd-display #__line__ ";delay interp hermite (6): ~A" v6))
      (if (not (vequal v7 (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.200 0.400 0.600 0.800 1.0 0.800 0.600 0.400 0.200 0.0 0.0 0.0 0.0 0.0)))
	  (snd-display #__line__ ";delay interp linear (7): ~A" v7)))
    
    (let ((dly1 (make-delay :size 2 :max-size 3))
	  (data (make-vct 5))
	  (impulse 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 5))
	(vct-set! data i (delay dly1 impulse 0.4)) ; longer line
	(set! impulse 0.0))
      (if (not (vequal data (vct 0.0 0.0 0.6 0.4 0.0)))
	  (snd-display #__line__ ";delay size 2, max 3, off 0.4: ~A" data))
      
      (set! dly1 (make-delay :size 2 :max-size 3))
      (set! impulse 1.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 5))
	(vct-set! data i (delay dly1 impulse -0.4)) ; shorter line
	(set! impulse 0.0))
      (if (not (vequal data (vct 0.0 0.4 0.6 0.0 0.0)))
	  (snd-display #__line__ ";delay size 2, max 3, off -0.4: ~A" data))
      
      (set! dly1 (make-delay :size 1 :max-size 2))
      (set! impulse 1.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 5))
	(vct-set! data i (delay dly1 impulse 0.4))
	(set! impulse 0.0))
      (if (not (vequal data (vct 0.0 0.6 0.4 0.0 0.0)))
	  (snd-display #__line__ ";delay size 1, max 2, off 0.4: ~A" data))
      
      (set! dly1 (make-delay :size 0 :max-size 1))
      (set! impulse 1.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 5))
	(vct-set! data i (delay dly1 impulse 0.4))
	(set! impulse 0.0))
      (if (not (vequal data (vct 0.6 0.0 0.0 0.0 0.0)))
	  (snd-display #__line__ ";delay size 0, max 1, off 0.4: ~A" data))
      
      (set! dly1 (make-delay :size 0 :max-size 1))
      (let ((val (delay dly1 0.0)))
	(if (fneq val 0.0) (snd-display #__line__ ";initial delay 0 size val: ~A" val)))
      
      (set! dly1 (make-delay :size 0 :max-size 1))
      (set! impulse 1.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 5))
	(vct-set! data i (delay dly1 impulse -0.4)) ; shorter than 0? should this be an error?
	(set! impulse 0.0))
      (if (not (vequal data (vct 1.4 0.0 0.0 0.0 0.0))) ; hmmm -- they're asking for undefined values here 
	  (snd-display #__line__ ";delay size 0, max 1, off -0.4: ~A" data))
      
      (set! dly1 (make-delay 0))
      (set! impulse 1.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 5))
	(vct-set! data i (delay dly1 impulse)) 
	(set! impulse 0.0))
      (if (not (vequal data (vct 1 0 0 0 0)))
	  (snd-display #__line__ ";delay size 0: ~A" data))
      
      (if (fneq (delay dly1 0.5) 0.5)
	  (snd-display #__line__ ";delay size 0 0.5: ~A" (delay dly 0.5)))
      )
    
    (let ((gen (make-delay :size 0 :max-size 100))
	  (v (make-vct 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v i (delay gen 0.5 i)))
      (if (not (vequal v (vct 0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";delay 0 -> 100: ~A" v))
      (do ((i 9 (- i 1)))
	  ((< i 0))
	(vct-set! v i (delay gen 0.5 i)))
      (if (not (vequal v (vct 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.500 0.000)))
	  (snd-display #__line__ ";delay 100 -> 0: ~A" v))
      (mus-reset gen)
      (if (not (vequal (mus-data gen) (make-vct 100 0.0)))
	  (snd-display #__line__ ";after reset mus-data delay peak: ~A" (vct-peak (mus-data gen))))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v i (delay gen (if (odd? i) 1.0 0.0) (* i .1))))
      (if (not (vequal v (vct 0.000 0.900 0.000 0.700 0.000 0.500 0.000 0.300 0.000 0.100)))
	  (snd-display #__line__ ";delay 0 -> 100 .1: ~A (~A)" v gen))
      (mus-reset gen)
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v i (delay gen (if (odd? i) 1.0 0.0) (+ 1.0 (* i .1)))))
      (if (not (vequal v (vct 0.000 0.000 0.800 0.300 0.600 0.500 0.400 0.700 0.200 0.900)))
	  (snd-display #__line__ ";delay 0 -> 100 1.1: ~A" v)))
    
    
    (let ((gen (make-all-pass .4 .6 3))
	  (v0 (make-vct 10))
	  (gen1 (make-all-pass .4 .6 3))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "all-pass"
		       "all-pass feedback: 0.400, feedforward: 0.600, line[3, step]:[0.000 0.000 0.000]")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (all-pass gen 1.0)))
      (vct-map! v1 (lambda () (if (all-pass? gen1) (all-pass gen1 1.0) -1.0)))
      (if (not (vequal v1 v0)) (snd-display #__line__ ";map all-pass: ~A ~A" v0 v1))
      (if (not (all-pass? gen)) (snd-display #__line__ ";~A not all-pass?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";all-pass length: ~D?" (mus-length gen)))
      (if (not (= (mus-order gen) 3)) (snd-display #__line__ ";all-pass order: ~D?" (mus-order gen)))
      (if (fneq (mus-feedback gen) .4) (snd-display #__line__ ";all-pass feedback: ~F?" (mus-feedback gen)))
      (if (fneq (mus-feedforward gen) .6) (snd-display #__line__ ";all-pass feedforward: ~F?" (mus-feedforward gen)))
      (if (or (fneq (vct-ref v0 1) 0.6) (fneq (vct-ref v0 4) 1.84) (fneq (vct-ref v0 8) 2.336))
	  (snd-display #__line__ ";all-pass output: ~A" v0))
      (set! (mus-feedback gen) 0.5) 
      (if (fneq (mus-feedback gen) .5) (snd-display #__line__ ";all-pass set-feedback: ~F?" (mus-feedback gen)))
      (set! (mus-feedforward gen) 0.5) 
      (if (fneq (mus-feedforward gen) .5) (snd-display #__line__ ";all-pass set-feedforward: ~F?" (mus-feedforward gen))))
    
    (test-gen-equal (let ((d1 (make-all-pass 0.7 0.5 3))) (all-pass d1 1.0) d1)
		    (let ((d2 (make-all-pass 0.7 0.5 3))) (all-pass d2 1.0) d2) 
		    (let ((d3 (make-all-pass 0.7 0.5 4))) (all-pass d3 1.0) d3))
    (test-gen-equal (make-all-pass 0.7 0.5 3 :initial-element 1.0) 
		    (make-all-pass 0.7 0.5 3 :initial-element 1.0) 
		    (make-all-pass 0.7 0.5 3 :initial-element 0.5))
    (test-gen-equal (make-all-pass 0.7 0.5 3 :initial-element 1.0) 
		    (make-all-pass 0.7 0.5 3 :initial-element 1.0) 
		    (make-all-pass 0.5 0.5 3 :initial-element 1.0))
    (test-gen-equal (make-all-pass 0.7 0.5 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-all-pass 0.7 0.5 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-all-pass 0.7 0.5 3 :initial-contents '(1.0 1.0 1.0)))
    (let ((err (catch #t (lambda () (make-all-pass :feedback .2 :feedforward .1 :size -1)) (lambda args args))))
      (if (not (eq? (car err) 'out-of-range))
	  (snd-display #__line__ ";make-all-pass bad size error message: ~A" err)))
    
    (let ((gen (make-moving-average 4))
	  (v0 (make-vct 10))
	  (gen1 (make-moving-average 4))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "moving-average"
		       "moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (moving-average gen 1.0)))
      (vct-map! v1 (lambda () (if (moving-average? gen1) (moving-average gen1 1.0) -1.0)))
      (if (not (vequal v1 v0)) (snd-display #__line__ ";map average: ~A ~A" v0 v1))
      (if (not (moving-average? gen)) (snd-display #__line__ ";~A not average?" gen))
      (if (not (= (mus-length gen) 4)) (snd-display #__line__ ";average length: ~D?" (mus-length gen)))
      (if (not (= (mus-order gen) 4)) (snd-display #__line__ ";average order: ~D?" (mus-order gen)))
      (if (or (fneq (vct-ref v0 1) 0.5) (fneq (vct-ref v0 4) 1.0) (fneq (vct-ref v0 8) 1.0))
	  (snd-display #__line__ ";average output: ~A" v0)))
    
    (let* ((gen (make-moving-average 8))
	   (val (moving-average gen)))
      (if (fneq val 0.0) (snd-display #__line__ ";empty average: ~A" val))
      (set! val (moving-average gen 1.0))
      (if (fneq val 0.125) (snd-display #__line__ ";average 1: ~A" val))
      (set! val (moving-average gen 1.0))
      (if (fneq val 0.25) (snd-display #__line__ ";average 2: ~A" val))
      (set! val (moving-average gen 0.5))
      (if (fneq val 0.3125) (snd-display #__line__ ";average 2: ~A" val))
      (do ((i 0 (+ 1 i))) ((= i 5)) (set! val (moving-average gen 0.0))) 
      (if (fneq val 0.3125) (snd-display #__line__ ";average 6: ~A" val))
      (set! val (moving-average gen 0.0))
      (if (fneq val 0.1875) (snd-display #__line__ ";average 7: ~A" val))
      (set! val (moving-average gen 0.0))
      (if (fneq val 0.0625) (snd-display #__line__ ";average 8: ~A" val))
      (set! val (moving-average gen 0.0))
      (if (fneq val 0.0) (snd-display #__line__ ";average 9: ~A" val))
      )
    (let* ((gen (make-moving-average 10 :initial-element .5))
	   (val (moving-average gen 0.5)))
      (if (fneq val 0.5) (snd-display #__line__ ";average initial-element: ~A" val)))
    (let* ((gen (make-moving-average 3 :initial-contents '(1.0 1.0 1.0)))
	   (val (moving-average gen 1.0)))
      (if (fneq val 1.0) (snd-display #__line__ ";average initial-contents: ~A" val)))
    
    (test-gen-equal (let ((d1 (make-moving-average 3 :initial-contents '(0.7 0.5 3)))) (moving-average d1 1.0) d1)
		    (let ((d2 (make-moving-average 3 :initial-contents (vct 0.7 0.5 3)))) (moving-average d2 1.0) d2) 
		    (let ((d3 (make-moving-average 4 :initial-contents '(0.7 0.5 0.1 4)))) (moving-average d3 1.0) d3))
    (test-gen-equal (make-moving-average 3 :initial-element 1.0) 
		    (make-moving-average 3 :initial-element 1.0) 
		    (make-moving-average 3 :initial-element 0.5))
    (test-gen-equal (make-moving-average 3 :initial-element 1.0) 
		    (make-moving-average 3 :initial-element 1.0) 
		    (make-moving-average 4 :initial-element 1.0))
    (test-gen-equal (make-moving-average 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-moving-average 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-moving-average 3 :initial-contents '(1.0 1.0 1.0)))
    (let ((err (catch #t (lambda () (make-moving-average :size -1)) (lambda args args))))
      (if (not (eq? (car err) 'out-of-range))
	  (snd-display #__line__ ";make-average bad size error message: ~A" err)))
    
    (let ((gen (make-comb .4 3))
	  (v0 (make-vct 10))
	  (gen1 (make-comb .4 3))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "comb"
		       "comb scaler: 0.400, line[3, step]: [0.000 0.000 0.000]")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (comb gen 1.0)))
      (vct-map! v1 (lambda () (if (comb? gen1) (comb gen1 1.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map comb: ~A ~A" v0 v1))
      (if (not (comb? gen)) (snd-display #__line__ ";~A not comb?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";comb length: ~D?" (mus-length gen)))
      (if (not (= (mus-order gen) 3)) (snd-display #__line__ ";comb order: ~D?" (mus-order gen)))
      (if (fneq (mus-feedback gen) .4) (snd-display #__line__ ";comb feedback: ~F?" (mus-feedback gen)))
      (if (or (fneq (vct-ref v0 1) 0.0) (fneq (vct-ref v0 4) 1.0) (fneq (vct-ref v0 8) 1.4))
	  (snd-display #__line__ ";comb output: ~A" v0)))
    
    (test-gen-equal (let ((d1 (make-comb 0.7 3))) (comb d1 1.0) d1) 
		    (let ((d2 (make-comb 0.7 3))) (comb d2 1.0) d2) 
		    (let ((d3 (make-comb 0.7 4))) (comb d3 1.0) d3))
    (test-gen-equal (make-comb 0.7 3 :initial-element 1.0) 
		    (make-comb 0.7 3 :initial-element 1.0) 
		    (make-comb 0.7 3 :initial-element 0.5))
    (test-gen-equal (make-comb 0.7 3 :initial-element 1.0) 
		    (make-comb 0.7 3 :initial-element 1.0) 
		    (make-comb 0.5 3 :initial-element 1.0))
    (test-gen-equal (make-comb 0.7 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-comb 0.7 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-comb 0.7 3 :initial-contents '(1.0 1.0 1.0)))
    
    (let* ((del (make-comb 0.0 5 :max-size 8)))
      (comb del 1.0)
      (do ((i 0 (+ 1 i))) ((= i 4)) (comb del 0.0))
      (let ((v0 (make-vct 5)))
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (vct-set! v0 i (comb del 0.0 0.4)))
	(if (not (vequal v0 (vct 0.600 0.400 0.000 0.000 0.000))) ; this is assuming interpolation in the delay...
	    (snd-display #__line__ ";zcomb: ~A" v0))
	(comb del 1.0)
	(comb del 0.0 0.4)
	(if (not (string=? (mus-describe del) "comb scaler: 0.000, line[5,8, linear]: [0.000 0.000 1.000 0.000 0.000]"))
	    (snd-display #__line__ ";describe zcomb: ~A" (mus-describe del))))
      (set! (mus-feedback del) 1.0)
      (if (fneq (mus-feedback del) 1.0)
	  (snd-display #__line__ ";comb feedback set: ~A" (mus-feedback del))))
    
    
    (let ((gen (make-filtered-comb .4 5 :filter (make-one-zero .3 .7)))
	  (v0 (make-vct 20)))
      (print-and-check gen 
		       "filtered-comb"
		       "filtered-comb scaler: 0.400, line[5, step]: [0.000 0.000 0.000 0.000 0.000], filter: [one-zero a0: 0.300, a1: 0.700, x1: 0.000]")
      (let ((val 1.0))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v0 i (filtered-comb gen val))
	  (set! val 0.0)))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.120 0.280 0.000 0.000 0.000 0.014 0.067 0.078 0.000 0.000)))
	  (snd-display #__line__ ";filtered-comb: ~A" v0))
      (if (not (filtered-comb? gen)) (snd-display #__line__ ";~A not filtered-comb?" gen))
      (if (not (= (mus-length gen) 5)) (snd-display #__line__ ";filtered-comb length: ~D?" (mus-length gen)))
      (if (not (= (mus-order gen) 5)) (snd-display #__line__ ";filtered-comb order: ~D?" (mus-order gen)))
      (if (fneq (mus-feedback gen) .4) (snd-display #__line__ ";filtered-comb feedback: ~F?" (mus-feedback gen))))
    
    (let ((gen (make-filtered-comb .9 5 :filter (make-one-zero .5 .5)))
	  (v0 (make-vct 20)))
      (print-and-check gen 
		       "filtered-comb"
		       "filtered-comb scaler: 0.900, line[5, step]: [0.000 0.000 0.000 0.000 0.000], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]")
      (let ((val 1.0))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v0 i (filtered-comb gen val))
	  (set! val 0.0)))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.450 0.450 0.000 0.000 0.000 0.202 0.405 0.202 0.000 0.000)))
	  (snd-display #__line__ ";filtered-comb .5 .5: ~A" v0)))
    
    (let ((gen (make-filtered-comb .9 5 :filter (make-fir-filter 5 (vct .1 .2 .3 .2 .1))))
	  (v0 (make-vct 20)))
      (print-and-check gen 
		       "filtered-comb"
		       "filtered-comb scaler: 0.900, line[5, step]: [0.000 0.000 0.000 0.000 0.000], filter: [fir-filter order: 5, xs: [0.100 0.200 0.300 0.200 0.100]]")
      (let ((val 1.0))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v0 i (filtered-comb gen val))
	  (set! val 0.0)))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.090 0.180 0.270 0.180 0.090 0.008 0.032 0.081 0.130 0.154)))
	  (snd-display #__line__ ";filtered-comb fir: ~A" v0)))
    
    (test-gen-equal (let ((d1 (make-filtered-comb 0.7 3 :filter (make-one-pole .3 .7)))) (filtered-comb d1 1.0) d1) 
		    (let ((d2 (make-filtered-comb 0.7 3 :filter (make-one-pole .3 .7)))) (filtered-comb d2 1.0) d2) 
		    (let ((d3 (make-filtered-comb 0.7 4 :filter (make-one-pole .3 .7)))) (filtered-comb d3 1.0) d3))
    (test-gen-equal (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5)) 
		    (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5)) 
		    (make-filtered-comb 0.7 3 :initial-element 0.5 :filter (make-one-zero .5 .5)))
    (test-gen-equal (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5)) 
		    (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .5 .5)) 
		    (make-filtered-comb 0.7 3 :initial-element 1.0 :filter (make-one-zero .25 .75)))
    (test-gen-equal (make-filtered-comb 0.7 3 :initial-contents '(1.0 0.0 0.0) :filter (make-one-zero .5 .5)) 
		    (make-filtered-comb 0.7 3 :initial-contents '(1.0 0.0 0.0) :filter (make-one-zero .5 .5)) 
		    (make-filtered-comb 0.7 3 :initial-contents '(1.0 1.0 1.0) :filter (make-one-zero .5 .5)))
    
    (let* ((del (make-filtered-comb 0.0 5 :max-size 8 :filter (make-one-zero .5 .5))))
      (filtered-comb del 1.0)
      (do ((i 0 (+ 1 i))) ((= i 4)) (filtered-comb del 0.0))
      (let ((v0 (make-vct 5)))
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (vct-set! v0 i (filtered-comb del 0.0 0.4)))
	(if (not (vequal v0 (vct 0.600 0.400 0.000 0.000 0.000))) ; this is assuming interpolation in the delay...
	    (snd-display #__line__ ";zfiltered-comb: ~A" v0))
	(filtered-comb del 1.0)
	(filtered-comb del 0.0 0.4)
	(if (not (string=? (mus-describe del)
			   "filtered-comb scaler: 0.000, line[5,8, linear]: [0.000 0.000 1.000 0.000 0.000], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]"))
	    (snd-display #__line__ ";describe zfiltered-comb: ~A" (mus-describe del))))
      (set! (mus-feedback del) 1.0)
      (if (fneq (mus-feedback del) 1.0)
	  (snd-display #__line__ ";filtered-comb feedback set: ~A" (mus-feedback del))))
    
    
    (let ((gen (make-notch .4 3))
	  (v0 (make-vct 10))
	  (gen1 (make-notch .4 3))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "notch"
		       "notch scaler: 0.400, line[3, step]: [0.000 0.000 0.000]")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (notch gen 1.0)))
      (vct-map! v1 (lambda () (if (notch? gen1) (notch gen1 1.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map notch: ~A ~A" v0 v1))
      (if (not (notch? gen)) (snd-display #__line__ ";~A not notch?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";notch length: ~D?" (mus-length gen)))
      (if (not (= (mus-order gen) 3)) (snd-display #__line__ ";notch order: ~D?" (mus-order gen)))
      (if (fneq (mus-feedforward gen) .4) (snd-display #__line__ ";notch feedforward: ~F?" (mus-feedforward gen)))
      (if (or (fneq (vct-ref v0 1) 0.4) (fneq (vct-ref v0 4) 1.4) (fneq (vct-ref v0 8) 1.4))
	  (snd-display #__line__ ";notch output: ~A" v0))
      (set! (mus-feedforward gen) 1.0)
      (if (fneq (mus-feedforward gen) 1.0)
	  (snd-display #__line__ ";notch feedforward set: ~A" (mus-feedforward gen))))
    
    (test-gen-equal (let ((d1 (make-notch 0.7 3))) (notch d1 1.0) d1)
		    (let ((d2 (make-notch 0.7 3))) (notch d2 1.0) d2)
		    (let ((d3 (make-notch 0.7 4))) (notch d3 1.0) d3))
    (test-gen-equal (make-notch 0.7 3 :initial-element 1.0) 
		    (make-notch 0.7 3 :initial-element 1.0) 
		    (make-notch 0.7 3 :initial-element 0.5))
    (test-gen-equal (make-notch 0.7 3 :initial-element 1.0) 
		    (make-notch 0.7 3 :initial-element 1.0) 
		    (make-notch 0.5 3 :initial-element 1.0))
    (test-gen-equal (make-notch 0.7 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-notch 0.7 3 :initial-contents '(1.0 0.0 0.0)) 
		    (make-notch 0.7 3 :initial-contents '(1.0 1.0 1.0)))
    
    ;; make sure all-pass is the same as comb/notch given the appropriate feedback/forward settings
    
    (let ((gen (make-comb 0.5 5))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (comb gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
	  (snd-display #__line__ ";comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (all-pass gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
	  (snd-display #__line__ ";all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (notch gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (all-pass gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";all-pass (5 .5 0): ~A" v0)))
    
    ;; make sure zall-pass is the same as zcomb/znotch given the appropriate feedback/forward and "pm" settings
    
    (let ((gen (make-comb 0.5 5 :max-size 20))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (comb gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
	  (snd-display #__line__ ";1comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (all-pass gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.500)))
	  (snd-display #__line__ ";1all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5 :max-size 20))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (notch gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";1notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
	  (v0 (make-vct 11))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 11))
	(vct-set! v0 i (all-pass gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";1all-pass (5 .5 0): ~A" v0)))
    
    ;; now actually use the size difference
    
    (let ((gen (make-comb 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .2)))
	  ((= i 20))
	(vct-set! v0 i (comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.160 0.360 0.200 0.040 0.000 0.000 0.000)))
	  (snd-display #__line__ ";2comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .2)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.160 0.360 0.200 0.040 0.000 0.000 0.000)))
	  (snd-display #__line__ ";2all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .2)))
	  ((= i 20))
	(vct-set! v0 i (notch gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";2notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .2)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";2all-pass (5 .5 0): ~A" v0)))
    
    (let ((gen (make-comb 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .2)))
	  ((= i 20))
	(vct-set! v0 i (comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.800 0.000 0.000 0.160 0.160 0.000 0.080 0.064 0.016 0.035 0.013 0.018 0.007 0.007 0.003 0.002)))
	  (snd-display #__line__ ";3comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .2)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.800 0.000 0.000 0.160 0.160 0.000 0.080 0.064 0.016 0.035 0.013 0.018 0.007 0.007 0.003 0.002)))
	  (snd-display #__line__ ";3all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .2)))
	  ((= i 20))
	(vct-set! v0 i (notch gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.800 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";3notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .2)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.800 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";3all-pass (5 .5 0): ~A" v0)))
    
    (let ((gen (make-comb 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .01)))
	  ((= i 20))
	(vct-set! v0 i (comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.428 0.079 0.004 0.000 0.000 0.182 0.067 0.008 0.000 0.000)))
	  (snd-display #__line__ ";4comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .01)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.428 0.079 0.004 0.000 0.000 0.182 0.067 0.008 0.000 0.000)))
	  (snd-display #__line__ ";4all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .01)))
	  ((= i 20))
	(vct-set! v0 i (notch gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";4notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5 :max-size 20))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .01)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";4all-pass (5 .5 0): ~A" v0)))
    
    ;; now run off either end of the delay line "by accident"
    
    (let ((gen (make-comb 0.5 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .5)))
	  ((= i 20))
	(vct-set! v0 i (comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.250 0.125 0.094 0.062 0.055 0.047 0.039 0.031 0.029)))
	  (snd-display #__line__ ";5comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .5)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.250 0.125 0.094 0.062 0.055 0.047 0.039 0.031 0.029)))
	  (snd-display #__line__ ";5all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .5)))
	  ((= i 20))
	(vct-set! v0 i (notch gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";5notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .5)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.500 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";5all-pass (5 .5 0): ~A" v0)))
    
    
    (let ((gen (make-comb 0.5 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .5)))
	  ((= i 20))
	(vct-set! v0 i (comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.500 0.000 0.125 0.000 0.031 0.016 0.004 1.000 0.000 0.250 0.031 0.000 0.012 0.002 0.250 0.125 0.008)))
	  (snd-display #__line__ ";6comb (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.5 0.0 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .5)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.500 0.000 0.125 0.000 0.031 0.016 0.004 1.000 0.000 0.250 0.031 0.000 0.012 0.002 0.250 0.125 0.008)))
	  (snd-display #__line__ ";6all-pass (5 0 .5): ~A" v0)))
    
    (let ((gen (make-notch 0.5 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .5)))
	  ((= i 20))
	(vct-set! v0 i (notch gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.500 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";6notch (5 .5): ~A" v0)))
    
    (let ((gen (make-all-pass 0.0 0.5 5 :max-size 10))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .5)))
	  ((= i 20))
	(vct-set! v0 i (all-pass gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.500 0.000 0.000 0.500 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";6all-pass (5 .5 0): ~A" v0)))
    
    (let ((gen (make-filtered-comb 0.5 5 :filter (make-one-zero .5 .5)))
	  (v0 (make-vct 21))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 21))
	(vct-set! v0 i (filtered-comb gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.250 0.250 
			       0.000 0.000 0.000 0.062 0.125 0.062 0.000 0.000 0.016)))
	  (snd-display #__line__ ";filtered-comb (5 .5): ~A" v0)))
    
    (let ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .25 .75)))
	  (v0 (make-vct 21))
	  (in1 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 21))
	(vct-set! v0 i (filtered-comb gen in1))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.125 0.375 
			       0.000 0.000 0.000 0.016 0.094 0.141 0.000 0.000 0.002)))
	  (snd-display #__line__ ";1filtered-comb (5 .5): ~A" v0)))
    
    (let ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .5 .5)))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .2)))
	  ((= i 20))
	(vct-set! v0 i (filtered-comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.800 0.400 0.000 0.000 0.000 0.000 0.000 0.080 0.220 0.300 0.140 0.040 0.000 0.000)))
	  (snd-display #__line__ ";2filtered-comb (5 .5): ~A" v0)))
    
    (let ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .5 .5)))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (- angle .2)))
	  ((= i 20))
	(vct-set! v0 i (filtered-comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.800 0.000 0.000 0.080 0.200 0.040 0.020 0.068 0.042 0.019 0.026 0.015 0.011 0.009 0.006 0.004)))
	  (snd-display #__line__ ";3filtered-comb (5 .5): ~A" v0)))
    
    (let ((gen (make-filtered-comb 0.5 5 :max-size 20 :filter (make-one-zero .5 .5)))
	  (v0 (make-vct 20))
	  (in1 1.0))
      (do ((i 0 (+ 1 i))
	   (angle 0.0 (+ angle .01)))
	  ((= i 20))
	(vct-set! v0 i (filtered-comb gen in1 angle))
	(set! in1 0.0))
      (if (not (vequal v0 (vct 0.000 0.000 0.000 0.000 0.000 0.950 0.060 0.000 0.000 0.000 0.214 0.251 0.043 0.002 0.000 0.045 0.106 0.081 0.023 0.003)))
	  (snd-display #__line__ ";4filtered-comb (5 .5): ~A" v0)))
    
    
    (let ((gen (make-one-pole .4 .7))
	  (v0 (make-vct 10))
	  (gen1 (make-one-pole .4 .7))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "one-pole"
		       "one-pole a0: 0.400, b1: 0.700, y1: 0.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (one-pole gen 1.0)))
      (vct-map! v1 (lambda () (if (one-pole? gen) (one-pole gen1 1.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map one-pole: ~A ~A" v0 v1))
      (if (not (one-pole? gen)) (snd-display #__line__ ";~A not one-pole?" gen))
      (if (not (= (mus-order gen) 1)) (snd-display #__line__ ";one-pole order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) .4) (snd-display #__line__ ";one-pole a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-b1 gen) .7) (snd-display #__line__ ";one-pole b1: ~F?" (mus-b1 gen)))
      (if (or (fneq (vct-ref v0 1) 0.120) (fneq (vct-ref v0 4) 0.275) (fneq (vct-ref v0 8) 0.245))
	  (snd-display #__line__ ";one-pole output: ~A" v0))
      (if (fneq (mus-ycoeff gen 1) .7) (snd-display #__line__ ";1p ycoeff 1 .7: ~A" gen))
      (set! (mus-ycoeff gen 1) .1)
      (if (fneq (mus-ycoeff gen 1) .1) (snd-display #__line__ ";1p set ycoeff 1 .1: ~A" gen))
      (if (fneq (mus-xcoeff gen 0) .4) (snd-display #__line__ ";1p xcoeff 0 .4: ~A" gen))
      (set! (mus-xcoeff gen 0) .3)
      (if (fneq (mus-xcoeff gen 0) .3) (snd-display #__line__ ";1p set xcoeff 0 .3: ~A" gen)))
    
    
    (let ((gen (make-one-zero .4 .7))
	  (v0 (make-vct 10))
	  (gen1 (make-one-zero .4 .7))
	  (v1 (make-vct 10)))
      (print-and-check gen
		       "one-zero"
		       "one-zero a0: 0.400, a1: 0.700, x1: 0.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (one-zero gen 1.0)))
      (vct-map! v1 (lambda () (if (one-zero? gen) (one-zero gen1 1.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map one-zero: ~A ~A" v0 v1))
      (if (not (one-zero? gen)) (snd-display #__line__ ";~A not one-zero?" gen))
      (if (not (= (mus-order gen) 1)) (snd-display #__line__ ";one-zero order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) .4) (snd-display #__line__ ";one-zero a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-a1 gen) .7) (snd-display #__line__ ";one-zero a1: ~F?" (mus-a1 gen)))
      (if (fneq (vct-ref v0 1) 1.1) (snd-display #__line__ ";one-zero output: ~A" v0))
      (if (fneq (mus-xcoeff gen 0) .4) (snd-display #__line__ ";1z xcoeff 0 .4: ~A" gen))
      (set! (mus-xcoeff gen 0) .1)
      (if (fneq (mus-xcoeff gen 0) .1) (snd-display #__line__ ";1z set xcoeff 0 .1: ~A" gen)))
    
    (let ((gen (make-two-zero .4 .7 .3))
	  (v0 (make-vct 10))
	  (gen1 (make-two-zero .4 .7 .3))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "two-zero"
		       "two-zero a0: 0.400, a1: 0.700, a2: 0.300, x1: 0.000, x2: 0.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (two-zero gen 1.0)))
      (vct-map! v1 (lambda () (if (two-zero? gen1) (two-zero gen1 1.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map two-zero: ~A ~A" v0 v1))
      (if (not (two-zero? gen)) (snd-display #__line__ ";~A not two-zero?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";two-zero order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) .4) (snd-display #__line__ ";two-zero a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-a1 gen) .7) (snd-display #__line__ ";two-zero a1: ~F?" (mus-a1 gen)))
      (if (fneq (mus-a2 gen) .3) (snd-display #__line__ ";two-zero a2: ~F?" (mus-a2 gen)))
      (if (or (fneq (vct-ref v0 1) 1.1) (fneq (vct-ref v0 8) 1.4)) (snd-display #__line__ ";two-zero output: ~A" v0))
      (if (fneq (mus-xcoeff gen 0) .4) (snd-display #__line__ ";2z xcoeff 0 .4: ~A" gen))
      (set! (mus-xcoeff gen 0) .1)
      (if (fneq (mus-xcoeff gen 0) .1) (snd-display #__line__ ";2z set xcoeff 0 .1: ~A" gen))
      (set! (mus-xcoeff gen 0) 1.0)
      (let ((r (mus-scaler gen)))
	(set! (mus-frequency gen) 500.0)
	(if (ffneq (mus-frequency gen) 500.0) (snd-display #__line__ ";set mus-frequency two-zero: ~A" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) r) (snd-display #__line__ ";set mus-frequency two-zero hit r: ~A" (mus-scaler gen)))
	(set! (mus-scaler gen) .99)
	(if (fneq (mus-scaler gen) .99) (snd-display #__line__ ";set mus-scaler two-zero: ~A" (mus-scaler gen)))
	(if (ffneq (mus-frequency gen) 500.0) (snd-display #__line__ ";set mus-scaler hit freq two-zero: ~A" (mus-frequency gen)))
	(let ((g3 (make-two-zero :radius .99 :frequency 500.0)))
	  (if (or (fneq (mus-a0 gen) (mus-a0 g3))
		  (fneq (mus-a1 gen) (mus-a1 g3))
		  (fneq (mus-a2 gen) (mus-a2 g3)))
	      (snd-display #__line__ ";two-zero setters: ~A ~A" gen g3)))))
    
    (let ((gen (make-two-zero .4 .7 .3)))
      (let ((val (gen 1.0)))
	(if (fneq val .4) (snd-display #__line__ ";2zero->0.4: ~A" val))
	(set! val (gen 0.5))
	(if (fneq val .9) (snd-display #__line__ ";2zero->0.9: ~A" val))
	(set! val (gen 1.0))
	(if (fneq val 1.05) (snd-display #__line__ ";2zero->1.05: ~A" val))))
    
    (let ((gen (make-two-pole .4 .7 .3))
	  (v0 (make-vct 10))
	  (gen1 (make-two-pole .4 .7 .3))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "two-pole"
		       "two-pole a0: 0.400, b1: 0.700, b2: 0.300, y1: 0.000, y2: 0.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (two-pole gen 1.0)))
      (vct-map! v1 (lambda () (if (two-pole? gen1) (two-pole gen1 1.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map two-pole: ~A ~A" v0 v1))
      (if (not (two-pole? gen)) (snd-display #__line__ ";~A not two-pole?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";two-pole order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) .4) (snd-display #__line__ ";two-pole a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-b1 gen) .7) (snd-display #__line__ ";two-pole b1: ~F?" (mus-b1 gen)))
      (if (fneq (mus-b2 gen) .3) (snd-display #__line__ ";two-pole b2: ~F?" (mus-b2 gen)))
      (if (or (fneq (vct-ref v0 1) 0.12) (fneq (vct-ref v0 8) 0.201)) (snd-display #__line__ ";two-pole output: ~A" v0))
      (if (fneq (mus-ycoeff gen 1) .7) (snd-display #__line__ ";2p ycoeff 1 .7: ~A" gen))
      (set! (mus-ycoeff gen 1) .1)
      (if (fneq (mus-ycoeff gen 1) .1) (snd-display #__line__ ";2p set ycoeff 1 .1: ~A" gen))
      (if (fneq (mus-xcoeff gen 0) .4) (snd-display #__line__ ";2p xcoeff 0 .4: ~A" gen))
      (set! (mus-xcoeff gen 0) .3)
      (if (fneq (mus-xcoeff gen 0) .3) (snd-display #__line__ ";2p set xcoeff 0 .3: ~A" gen))
      (set! (mus-xcoeff gen 0) 1.0)
      (let ((r (mus-scaler gen)))
	(set! (mus-frequency gen) 500.0)
	(if (ffneq (mus-frequency gen) 500.0) (snd-display #__line__ ";set mus-frequency two-pole: ~A" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) r) (snd-display #__line__ ";set mus-frequency two-pole hit r: ~A" (mus-scaler gen)))
	(set! (mus-scaler gen) .99)
	(if (fneq (mus-scaler gen) .99) (snd-display #__line__ ";set mus-scaler two-pole: ~A" (mus-scaler gen)))
	(if (ffneq (mus-frequency gen) 500.0) (snd-display #__line__ ";set mus-scaler hit freq two-pole: ~A" (mus-frequency gen)))
	(let ((g3 (make-two-pole :radius .99 :frequency 500.0)))
	  (if (or (fneq (mus-a0 gen) (mus-a0 g3))
		  (fneq (mus-b1 gen) (mus-b1 g3))
		  (fneq (mus-b2 gen) (mus-b2 g3)))
	      (snd-display #__line__ ";two-pole setters: ~A ~A" gen g3)))))
    
    (let ((gen (make-two-pole .4 .7 .3)))
      (let ((val (gen 1.0)))
	(if (fneq val .4) (snd-display #__line__ ";a0->out 2pole: ~A" val))
	(set! val (gen 0.5))
	(if (fneq val -.08) (snd-display #__line__ ";a0->out 2pole (-0.08): ~A" val))
	(set! val (gen 1.0))
	(if (fneq val 0.336) (snd-display #__line__ ";a0->out 2pole (0.336): ~A" val))))
    
    (let ((var (catch #t (lambda () (make-two-pole :b1 3.0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-two-pole bad b1: ~A" var)))
    (let ((var (catch #t (lambda () (make-two-pole :b2 2.0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-two-pole bad b2: ~A" var)))
    (let ((var (catch #t (lambda () (make-two-pole :b2 2.0 :b1)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-two-pole bad keys: ~A" var)))
    (let ((var (catch #t (lambda () (make-two-pole :b2 2.0 3.0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-two-pole bad args: ~A" var)))
    
    (let ((gen (make-oscil 440.0))
	  (gen1 (make-oscil 440.0))
	  (gen2 (make-oscil 440.0))
	  (v0 (make-vct 10))
	  (v1 (make-vct 10))
	  (v2 (make-vct 10)))
      (print-and-check gen 
		       "oscil"
		       "oscil freq: 440.000Hz, phase: 0.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (oscil gen 0.0))
	(vct-set! v1 i (mus-apply gen1 0.0 0.0)))
      (vct-map! v2 (lambda () (if (oscil? gen2) (oscil gen2 0.0) -1.0)))
      (if (not (vequal v0 v2)) (snd-display #__line__ ";map oscil: ~A ~A" v0 v2))
      (if (not (oscil? gen)) (snd-display #__line__ ";~A not oscil?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";oscil phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";oscil frequency: ~F?" (mus-frequency gen)))
      (if (not (= (mus-length gen) 1)) (snd-display #__line__ ";oscil cosines: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) 0.125) (fneq (vct-ref v0 8) 0.843)) (snd-display #__line__ ";oscil output: ~A" v0))
      (set! (mus-phase gen) 0.0)
      (if (fneq (mus-phase gen) 0.0) (snd-display #__line__ ";oscil set-phase: ~F?" (mus-phase gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";oscil set-frequency: ~F?" (mus-frequency gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (fneq (vct-ref v0 i) (vct-ref v1 i))
	    (snd-display #__line__ ";mus-apply oscil at ~D: ~A ~A?" i (vct-ref v0 i) (vct-ref v1 i))))
      (if (fneq (mus-apply) 0.0)
	  (snd-display #__line__ ";(mus-apply): ~A" (mus-apply))))
    
    (let ((gen1 (make-oscil 100.0))
	  (gen2 (make-oscil -100.0))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(set! mx (max mx (abs (+ (gen1) (gen2))))))
      (if (fneq mx 0.0)
	  (snd-display #__line__ ";oscil +-: ~A" mx)))
    
    (let ((gen1 (make-oscil 100.0 (* pi 0.5)))
	  (gen2 (make-oscil -100.0 (* pi 0.5)))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(set! mx (max mx (abs (- (gen1) (gen2))))))
      (if (fneq mx 0.0)
	  (snd-display #__line__ ";cosil +-: ~A" mx)))
    
    (fm-test (make-oscil))
    (fm-test (make-nrxysin))
    (fm-test (make-nrxycos))
    (fm-test (make-square-wave))
    (fm-test (make-triangle-wave))
    (fm-test (make-ncos))
    (fm-test (make-nsin))
    (fm-test (make-sawtooth-wave))
    (fm-test (make-rand))
    (fm-test (make-rand-interp))
    (fm-test (make-pulse-train))
    
    (let ((gen (make-oscil 440.0))
	  (gen1 (make-oscil 440.0)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((oval (oscil gen .1))
	      (mval (mus-run gen1 .1)))
	  (if (fneq oval mval)
	      (snd-display #__line__ ";mus-run ~A but oscil ~A?" mval oval)))))
    
    (let ((gen (make-oscil 440.0))
	  (gen1 (make-oscil 440.0))
	  (gen2 (make-oscil 440.0))
	  (gen3 (make-oscil 440.0))
	  (fm-index (hz->radians 440.0))
	  (v0 (make-vct 10))
	  (v1 (make-vct 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (oscil gen (* fm-index (oscil gen1 0.0))))
	(vct-set! v1 i (mus-apply gen2 (* fm-index (mus-apply gen3 0.0 0.0)) 0.0)))
      (if (or (fneq (vct-ref v0 1) 0.125) (fneq (vct-ref v0 6) 0.830) (fneq (vct-ref v0 8) 0.987))
	  (snd-display #__line__ ";oscil fm output: ~A" v0))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (fneq (vct-ref v0 i) (vct-ref v1 i))
	    (snd-display #__line__ ";mus-apply fm oscil at ~D: ~A ~A?" i (vct-ref v0 i) (vct-ref v1 i)))))
    
    (test-gen-equal (make-oscil 440.0) (make-oscil 440.0) (make-oscil 100.0))
    (test-gen-equal (make-oscil 440.0) (make-oscil 440.0) (make-oscil 440.0 1.0))
    
    (let ((gen (make-oscil 440.0))
	  (gen1 (make-oscil 440.0))
	  (pm-index 2.0)
	  (v0 (make-vct 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (gen 0.0 (* pm-index (gen1 0.0)))))
      (if (or (fneq (vct-ref v0 1) 0.367) (fneq (vct-ref v0 6) 0.854) (fneq (vct-ref v0 8) 0.437))
	  (snd-display #__line__ ";oscil pm output: ~A" v0)))
    
    (let ((gen (make-oscil 440.0)))
      (do ((i 0 (+ 1 i)))
	  ((= i 1100))
	(let* ((val1 (sin (mus-phase gen)))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";oscil: ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen (make-oscil 440.0 :initial-phase (* pi 0.5))))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 440.0) 22050.0))))
	  ((= i 900))
	(let* ((val1 (cos a))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";oscil (cos): ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen (make-oscil 0.0))
	  (gen1 (make-oscil 40.0)))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 40.0) 22050.0))))
	  ((= i 1100))
	(let* ((val1 (sin (sin a)))
	       (val2 (oscil gen 0.0 (oscil gen1 0.0))))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";oscil pm: ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen (make-oscil 0.0))
	  (gen1 (make-oscil 40.0))
	  (a1 0.0))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 40.0) 22050.0))))
	  ((= i 100))
	(let* ((fm (sin a))
	       (val1 (sin a1))
	       (val2 (oscil gen (oscil gen1 0.0))))
	  (set! a1 (+ a1 fm))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";oscil fm: ~A: ~A ~A" i val1 val2)))))
    
    (let ((var (catch #t (lambda () (mus-location (make-oscil))) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";mus-location bad gen: ~A" var)))
    (let ((var (catch #t (lambda () (set! (mus-location (make-oscil)) 0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";set mus-location bad gen: ~A" var)))
    (let ((var (catch #t (lambda () (set! (mus-scaler (make-oscil)) 0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";set mus-scaler bad gen: ~A" var)))
    (let ((var (catch #t (lambda () (mus-frequency (make-one-pole))) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";mus-frequency bad gen: ~A" var)))
    (let ((var (catch #t (lambda () (set! (mus-frequency (make-one-pole)) 0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";set mus-frequency bad gen: ~A" var)))
    (let ((var (catch #t (lambda () (make-delay (* 1024 1024 40))) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-delay huge line: ~A" var)))
    (let ((var (catch #t (lambda () (make-delay 32 :max-size (* 1024 1024 40))) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-delay huge line: ~A" var)))
    
    (let ((amps (make-vector 3))
	  (oscils (make-vector 3))
	  (fms (make-vector 3))
	  (results (make-vector 10)))
      (do ((i 0 (+ 1 i))) ((= i 3))
	(vector-set! amps i (* (+ i 1) .1))
	(vector-set! oscils i (make-oscil :frequency (* (+ i 1) 220.0)))
	(vector-set! fms i (* i .05)))
      (do ((i 0 (+ 1 i))) ((= i 10))
	(vector-set! results i (oscil-bank amps oscils fms)))
      (if (or (fneq (vector-ref results 1) 0.12639)
	      (fneq (vector-ref results 5) 0.48203)
	      (fneq (vector-ref results 9) 0.41001))
	  (snd-display #__line__ ";oscil-bank: ~A?" results)))
    
    (let ((size 1000))
      
      (define (test-pm beg end freq amp mc-ratio index)
	(let ((pm (make-oscil (* freq mc-ratio)))
	      (carrier (make-oscil freq)))
	  (do ((i beg (+ 1 i)))
	      ((= i end))
	    (outa i (* amp (oscil carrier 0.0 (* index (oscil pm))))))))
      
      (define (test-fm beg end freq amp mc-ratio index)
	(let ((fm (make-oscil (* freq mc-ratio) :initial-phase (/ pi 2.0)))
	      (carrier (make-oscil freq))
	      (fm-index (* (hz->radians freq) mc-ratio index)))
	  (do ((i beg (+ 1 i)))
	      ((= i end))
	    (outa i (* amp (oscil carrier (* fm-index (oscil fm))))))))
      
      ;; there's an initial-phase confusion here, so by making the srate high and freq low, we minimize uninteresting off-by-1 troubles
      
      (let ((v1 (with-sound (:output (make-vct size) :srate 441000) (test-pm 0 size 20 1 1 1)))
	    (v2 (with-sound (:output (make-vct size) :srate 441000) (test-fm 0 size 20 1 1 1))))
	(if (not (vequal v1 v2))
	    (snd-display #__line__ ";fm/pm peak diff (1 1): ~A" (vct-peak (vct-subtract! v1 v2)))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((ratio (+ 1 (random 4)))
	      (index (random 2.0)))
	  (let ((v1 (with-sound (:output (make-vct size) :srate 441000) (test-pm 0 size 20 1 ratio index)))
		(v2 (with-sound (:output (make-vct size) :srate 441000) (test-fm 0 size 20 1 ratio index))))
	    (if (not (vequal v1 v2))
		(snd-display #__line__ ";fm/pm peak diff ~A ~A: ~A" ratio index (vct-peak (vct-subtract! v1 v2))))))))
    
    (let ((gen (make-ncos 440.0 10))
	  (v0 (make-vct 10))
	  (gen1 (make-ncos 440.0 10))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "ncos"
		       "ncos freq: 440.000Hz, phase: 0.000, n: 10")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (ncos gen 0.0)))
      (vct-map! v1 (lambda () (if (ncos? gen1) (ncos gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map ncos: ~A ~A" v0 v1))
      (if (not (ncos? gen)) (snd-display #__line__ ";~A not ncos?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";ncos phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";ncos frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) .1) (snd-display #__line__ ";ncos scaler: ~F?" (mus-scaler gen)))
      (if (not (= (mus-length gen) 10)) (snd-display #__line__ ";ncos n: ~D?" (mus-length gen)))
      (if (not (= (mus-length gen) 10)) (snd-display #__line__ ";ncos length: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) 0.722) (fneq (vct-ref v0 8) -0.143)) (snd-display #__line__ ";ncos output: ~A" v0))
      (set! (mus-scaler gen) .5) (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";ncos set-scaler: ~F?" (mus-scaler gen)))
      (set! (mus-length gen) 5) (if (not (= (mus-length gen) 5)) (snd-display #__line__ ";set ncos n: ~D?" (mus-length gen)))
      (if (fneq (mus-scaler gen) .2) (snd-display #__line__ ";set n->scaler: ~A" (mus-scaler gen))))
    
    (test-gen-equal (make-ncos 440.0 3) (make-ncos 440.0 3) (make-ncos 440.0 5))
    (test-gen-equal (make-ncos 440.0 3) (make-ncos 440.0 3) (make-ncos 400.0 3))
    
    (let ((gen (make-ncos 440 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 1100))
	(let* ((den (sin (* (mus-phase gen) 0.5)))
	       (val1 (if (= 0.0 den)
			 1.0
			 (min 1.0 (* (mus-scaler gen)
				     (- (/ (sin (* (mus-phase gen)
						   (+ (mus-length gen) 0.5)))
					   (* 2.0 den))
					0.5)))))
	       (val2 (gen 0.0)))
	  (if (> (abs (- val1 val2)) .002)
	      (snd-display #__line__ ";ncos: ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen1 (make-ncos 100.0 10))
	  (gen2 (make-ncos -100.0 10))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(set! mx (max mx (abs (- (gen1) (gen2))))))
      (if (fneq mx 0.0)
	  (snd-display #__line__ ";ncos +-: ~A" mx)))
    
    (let ((gen (make-nsin 440.0 10))
	  (v0 (make-vct 10))
	  (gen1 (make-nsin 440.0 10))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "nsin"
		       "nsin freq: 440.000Hz, phase: 0.000, n: 10")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (nsin gen 0.0)))
      (vct-map! v1 (lambda () (if (nsin? gen1) (nsin gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map nsin: ~A ~A" v0 v1))
      (if (not (nsin? gen)) (snd-display #__line__ ";~A not nsin?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";nsin phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";nsin frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) .1315) (snd-display #__line__ ";nsin scaler: ~F?" (mus-scaler gen)))
      (if (not (= (mus-length gen) 10)) (snd-display #__line__ ";nsin n: ~D?" (mus-length gen)))
      (if (not (= (mus-length gen) 10)) (snd-display #__line__ ";nsin length: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) 0.784) (fneq (vct-ref v0 8) 0.181)) (snd-display #__line__ ";nsin output: ~A" v0))
      (set! (mus-scaler gen) .5) (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";nsin set-scaler: ~F?" (mus-scaler gen)))
      (set! (mus-length gen) 5) (if (not (= (mus-length gen) 5)) (snd-display #__line__ ";set nsin n: ~D?" (mus-length gen)))
      (if (fneq (mus-scaler gen) .2525) (snd-display #__line__ ";set sines->scaler: ~A" (mus-scaler gen))))
    
    (test-gen-equal (make-nsin 440.0 3) (make-nsin 440.0 3) (make-nsin 440.0 5))
    (test-gen-equal (make-nsin 440.0 3) (make-nsin 440.0 3) (make-nsin 400.0 3))
    
    (let ((gen (make-nsin 440 5)))
      (do ((i 0 (+ 1 i)))
	  ((= i 1100))
	(let* ((val1 (* (sum-of-n-sines (mus-phase gen) 5) (mus-scaler gen)))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";nsin: ~A ~A" val1 val2)))))
    
    (let ((gen1 (make-nsin 100.0 10))
	  (gen2 (make-nsin -100.0 10))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(set! mx (max mx (abs (+ (gen1) (gen2))))))
      (if (fneq mx 0.0)
	  (snd-display #__line__ ";nsin +-: ~A" mx)))
    
    
    (let ((gen (make-nrxysin 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-nrxysin 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "nrxysin"
                       "nrxysin frequency: 440.000, ratio: 1.000, phase: 0.000, n: 1, r: 0.500")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (nrxysin gen 0.0)))
      (vct-map! v1 (lambda () (if (nrxysin? gen1) (nrxysin gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map nrxysin: ~A ~A" v0 v1))
      (if (not (nrxysin? gen)) (snd-display #__line__ ";~A not nrxysin?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";nrxysin phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";nrxysin frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";mus-scaler (a) nrxysin: ~A" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.75)
      (if (fneq (mus-scaler gen) 0.75) (snd-display #__line__ ";mus-scaler (set a) nrxysin: ~A" (mus-scaler gen)))
      (if (not (= (mus-length gen) 1)) (snd-display #__line__ ";mus-length nrxysin: ~A" (mus-length gen)))
      (if (fneq (mus-offset gen) 1.0) (snd-display #__line__ ";mus-offset nrxysin: ~A" (mus-offset gen))))
    
    (test-gen-equal (make-nrxysin 440.0) (make-nrxysin 440.0) (make-nrxysin 100.0))
    (test-gen-equal (make-nrxysin 440.0) (make-nrxysin 440.0) (make-nrxysin 440.0 1.5))
    (test-gen-equal (make-nrxysin 440.0) (make-nrxysin 440.0) (make-nrxysin 440.0 :n 3))
    
    (let ((v1 (make-vct 10)))
      (with-sound (:output v1 :srate 44100)
		  (let ((gen (make-nrxysin 1000 :n 10 :r .99)))
		    (do ((i 0 (+ 1 i)))
			((= i 10))
		      (outa i (nrxysin gen)))))
      (if (not (vequal v1 (vct 0.000 0.671 0.637 0.186 0.017 0.169 0.202 0.048 0.007 0.105)))
	  (snd-display #__line__ ";ws nrxysin output: ~A" v1)))
    
    
    (let ((gen (make-nrxycos 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-nrxycos 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "nrxycos"
                       "nrxycos frequency: 440.000, ratio: 1.000, phase: 0.000, n: 1, r: 0.500")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (nrxycos gen 0.0)))
      (vct-map! v1 (lambda () (if (nrxycos? gen1) (nrxycos gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map nrxycos: ~A ~A" v0 v1))
      (if (not (nrxycos? gen)) (snd-display #__line__ ";~A not nrxycos?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";nrxycos phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";nrxycos frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";mus-scaler (a) nrxycos: ~A" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.75)
      (if (fneq (mus-scaler gen) 0.75) (snd-display #__line__ ";mus-scaler (set a) nrxycos: ~A" (mus-scaler gen)))
      (if (not (= (mus-length gen) 1)) (snd-display #__line__ ";mus-length nrxycos: ~A" (mus-length gen)))
      (if (fneq (mus-offset gen) 1.0) (snd-display #__line__ ";mus-offset nrxycos: ~A" (mus-offset gen))))
    
    (test-gen-equal (make-nrxycos 440.0) (make-nrxycos 440.0) (make-nrxycos 100.0))
    (test-gen-equal (make-nrxycos 440.0) (make-nrxycos 440.0) (make-nrxycos 440.0 1.5))
    (test-gen-equal (make-nrxycos 440.0) (make-nrxycos 440.0) (make-nrxycos 440.0 :n 3))
    
    (let ((v1 (with-sound (:output (make-vct 10) :srate 44100)
			  (let ((gen (make-nrxycos 1000 :n 10 :r .99)))
			    (do ((i 0 (+ 1 i)))
				((= i 10))
			      (outa i (nrxycos gen)))))))
      (if (not (vequal v1 (vct 1.000 0.602 -0.067 -0.242 -0.007 0.071 -0.087 -0.128 -0.007 0.012)))
	  (snd-display #__line__ ";ws nrxycos output: ~A" v1)))
    
    
    (let ((ind (new-sound "test.snd" mus-next mus-bfloat)))
      (pad-channel 0 1000)
      (let ((gen (make-cosine-summation 100.0)))
	(map-channel (lambda (y) (* .2 (cosine-summation gen 0.5))))
	(let ((vals (channel->vct 280 10)))
	  (if (not (vequal vals (vct 0.191 0.187 0.181 0.176 0.169 0.163 0.156 0.148 0.141 0.133)))
	      (snd-display #__line__ ";cosine-summation: ~A" vals)))
	(undo))
      
      (let ((gen (make-kosine-summation 100.0)))
	(map-channel (lambda (y) (* .2 (kosine-summation gen 0.5 1.0))))
	(let ((vals (channel->vct 280 10)))
	  (if (not (vequal vals (vct 0.194 0.191 0.188 0.184 0.180 0.175 0.170 0.166 0.160 0.155)))
	      (snd-display #__line__ ";kosine-summation 1: ~A" vals)))
	(undo))
      (let ((gen (make-kosine-summation 100.0)))
	(map-channel (lambda (y) (* .2 (kosine-summation gen 0.5 3.0))))
	(let ((vals (channel->vct 280 10)))
	  (if (not (vequal vals (vct 0.182 0.174 0.165 0.155 0.145 0.134 0.124 0.113 0.103 0.094)))
	      (snd-display #__line__ ";kosine-summation 3: ~A" vals)))
	(undo))
      
      (let ((angle 0.0)
	    (v (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v i (fejer-sum angle 3))
	  (set! angle (+ angle .1)))
	(if (not (vequal v (vct 1.000 0.988 0.951 0.892 0.815 0.723 0.622 0.516 0.412 0.313 0.225 0.150 0.089 0.045 0.017 0.003 0.000 0.007 0.020 0.035)))
	    (snd-display #__line__ ";fejer-sum: ~A" v)))
      
      (for-each
       (lambda (n)
	 (let ((mx 0.0)
	       (angle 0.0))
	   (do ((i 0 (+ 1 i)))
	       ((= i 300))
	     (set! mx (max mx (fejer-sum angle n)))
	     (set! angle (+ angle .01)))
	   (if (fneq mx 1.0) (snd-display #__line__ ";fejer-sum maxamp ~D: ~A" n mx))))
       (list 1 4 9 16 32 100))
      
      (let ((angle 0.0)
	    (v (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v i (poussin-sum angle 3))
	  (set! angle (+ angle .1)))
	(if (not (vequal v (vct 1.000 0.910 0.663 0.323 -0.024 -0.301 -0.458 -0.486 -0.411 -0.281 -0.147 -0.046 0.008 0.021 0.013 0.003 0.000 0.006 0.012 0.009)))
	    (snd-display #__line__ ";poussin-sum: ~A" v)))
      
      (for-each
       (lambda (n)
	 (let ((mx 0.0)
	       (angle 0.0))
	   (do ((i 0 (+ 1 i)))
	       ((= i 300))
	     (set! mx (max mx (poussin-sum angle n)))
	     (set! angle (+ angle .01)))
	   (if (fneq mx 1.0) (snd-display #__line__ ";poussin-sum maxamp ~D: ~A" n mx))))
       (list 1 4 9 16 32 100))
      
      (let ((angle 0.0)
	    (v (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v i (jackson-sum angle 3))
	  (set! angle (+ angle .1)))
	(if (not (vequal v (vct 1.000 0.975 0.904 0.796 0.664 0.523 0.386 0.266 0.170 0.098 0.051 0.022 0.008 0.002 0.000 0.000 0.000 0.000 0.000 0.001)))
	    (snd-display #__line__ ";jackson-sum: ~A" v)))
      
      (for-each
       (lambda (n)
	 (let ((mx 0.0)
	       (angle 0.0))
	   (do ((i 0 (+ 1 i)))
	       ((= i 300))
	     (set! mx (max mx (jackson-sum angle n)))
	     (set! angle (+ angle .01)))
	   (if (fneq mx 1.0) (snd-display #__line__ ";jackson-sum maxamp ~D: ~A" n mx))))
       (list 1 4 9 16 32 100))
      
      (let ((angle 0.0)
	    (v (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v i (legendre-sum angle 3))
	  (set! angle (+ angle .1)))
	(if (not (vequal v (vct 1.000 0.961 0.850 0.688 0.502 0.323 0.174 0.071 0.015 0.000 0.011 0.032 0.049 0.054 0.047 0.032 0.016 0.004 0.000 0.004)))
	    (snd-display #__line__ ";legendre-sum: ~A" v)))
      
      (for-each
       (lambda (n)
	 (let ((mx 0.0)
	       (angle 0.0))
	   (do ((i 0 (+ 1 i)))
	       ((= i 300))
	     (set! mx (max mx (legendre-sum angle n)))
	     (set! angle (+ angle .01)))
	   (if (fneq mx 1.0) (snd-display #__line__ ";legendre-sum maxamp ~D: ~A" n mx))))
       (list 1 4 9 16 32 100))
      
      
      (let ((angle 0.0)) 
	(map-channel (lambda (y) 
		       (let ((val (band-limited-sawtooth angle 0.5 8 .2))) 
			 (set! angle (+ angle .2)) 
			 val))))
      (let ((vals (channel->vct 10 10)))
	(if (not (vequal vals (vct -0.118 -0.073 -0.035 0.012 0.062 0.106 0.142 0.185 0.237 0.288)))
	    (snd-display #__line__ ";band-limited-sawtooth: ~A" vals)))
      (undo)
      
      (let ((angle 0.0)) 
	(map-channel (lambda (y) 
		       (let ((val (band-limited-square-wave angle 10))) 
			 (set! angle (+ angle .2)) 
			 val))))
      (let ((vals (channel->vct 10 10)))
	(if (not (vequal vals (vct 1.000 1.000 1.000 1.000 0.998 0.888 -0.525 -0.988 -1.000 -1.000)))
	    (snd-display #__line__ ";band-limited-square-wave: ~A" vals)))
      (undo)
      
      (let ((angle 0.0)) 
	(map-channel (lambda (y) (let ((val (sum-of-n-sines angle 3))) (set! angle (+ angle .1)) (* .1 val))))
	(let ((vals (channel->vct 260 10)))
	  (if (not (vequal vals (vct 0.226 0.200 0.166 0.129 0.091 0.056 0.025 0.001 -0.015 -0.023)))
	      (snd-display #__line__ ";sum-of-n-sines: ~A" vals)))
	(undo))
      (let ((angle 0.0)) 
	(map-channel (lambda (y) (let ((val (sum-of-n-odd-sines angle 3))) (set! angle (+ angle .1)) (* .1 val))))
	(let ((vals (channel->vct 260 10)))
	  (if (not (vequal vals (vct 0.035 0.007 0.000 0.014 0.039 0.069 0.091 0.100 0.092 0.070)))
	      (snd-display #__line__ ";sum-of-n-odd-sines: ~A" vals)))
	(undo))
      (let ((angle 0.0)) 
	(map-channel (lambda (y) (let ((val (sum-of-n-odd-cosines angle 3))) (set! angle (+ angle .1)) (* .1 val))))
	(let ((vals (channel->vct 250 10)))
	  (if (not (vequal vals (vct 0.270 0.298 0.292 0.253 0.189 0.112 0.037 -0.024 -0.061 -0.072)))
	      (snd-display #__line__ ";sum-of-n-odd-cosines: ~A" vals)))
	(undo))
      (close-sound ind))
    
    (let ((gen (make-asymmetric-fm 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-asymmetric-fm 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "asymmetric-fm"
		       "asymmetric-fm freq: 440.000Hz, phase: 0.000, ratio: 1.000, r: 1.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (asymmetric-fm gen 0.0)))
      (vct-map! v1 (lambda () (if (asymmetric-fm? gen1) (asymmetric-fm gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map asymmetric-fm: ~A ~A" v0 v1))
      (if (not (asymmetric-fm? gen)) (snd-display #__line__ ";~A not asymmetric-fm?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";asymmetric-fm phase: ~F?" (mus-phase gen)))
      (set! (mus-phase gen) 1.0)
      (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";set! asymmetric-fm phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";asymmetric-fm frequency: ~F?" (mus-frequency gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";set! asymmetric-fm frequency: ~F?" (mus-frequency gen)))
      (if (or (fneq (vct-ref v0 2) 0.969) (fneq (vct-ref v0 8) .538)) (snd-display #__line__ ";asymmetric-fm output: ~A" v0))
      (if (fneq (mus-scaler gen) 1.0) (snd-display #__line__ ";mus-scaler (r) asymmetric-fm: ~A" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";mus-scaler (set r) asymmetric-fm: ~A" (mus-scaler gen)))
      (if (fneq (mus-offset gen) 1.0) (snd-display #__line__ ";mus-offset asymmetric-fm: ~A" (mus-offset gen))))
    
    (test-gen-equal (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0) (make-asymmetric-fm 100.0))
    (test-gen-equal (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0 1.0))
    (test-gen-equal (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0) (make-asymmetric-fm 440.0 0.0 3))
    
    (let ((gen1 (make-asymmetric-fm 1000 0 1.0 0.1))
	  (gen2 (make-oscil 1000 :initial-phase (* 0.5 pi)))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 100)))
	(let ((ss (asymmetric-fm gen1 0.0 0.0))
	      (os (oscil gen2 0.0)))
	  (if (fneq ss os)
	      (begin
		(snd-display #__line__ ";asymmetric-fm 1: ~A: os: ~A ss: ~A" i os ss)
		(set! happy #f))))))
    
    (for-each
     (lambda (index)
       (for-each
	(lambda (r)
	  (let ((peak (vct-peak (with-sound (:clipped #f :output (make-vct 1000))
					    (let ((gen (make-asymmetric-fm 2000.0 :ratio .1 :r r)))
					      (run 
					       (do ((i 0 (+ 1 i)))
						   ((= i 1000))
						 (outa i (asymmetric-fm gen index)))))))))
	    (if (> (abs (- peak 1.0)) .1)
		(snd-display #__line__ ";asymmetric-fm peak: ~A, index: ~A, r: ~A" peak index r))))
	(list -10.0 -1.5 -0.5 0.5 1.0 1.5 10.0)))
     (list 1.0 3.0 10.0))
    
    (let ((vct0 (make-vct 2048))
	  (vct1 (make-vct 2048))
	  (gen3 (make-asymmetric-fm 1000 0 1.0 0.2))
	  (gen4 (make-oscil 1000 (* 0.5 pi)))
	  (gen5 (make-oscil 200))
	  (fm1 (hz->radians (* 1.0 .2 1000)))) ; make notions of "index" match
      (do ((i 0 (+ 1 i)))
	  ((= i 2048))
	(vct-set! vct0 i (asymmetric-fm gen3 1.0 0.0))
	(vct-set! vct1 i (oscil gen4 (* fm1 (oscil gen5)))))
      (let* ((spectr1 (snd-spectrum vct0 rectangular-window 2048 #t))
	     (spectr2 (snd-spectrum vct1 rectangular-window 2048 #t))
	     (happy #t))
	(do ((i 1 (+ 1 i)))
	    ((or (not happy)
		 (= i 512)))
	  (if (> (abs (- (vct-ref spectr1 i) (vct-ref spectr2 i))) .02)
	      (begin
		(snd-display #__line__ ";asymmetric-fm 2: ~A: ~A ~A" i (vct-ref spectr1 i) (vct-ref spectr2 i))
		(set! happy #f))))))
    
    (let ((gen (make-asymmetric-fm 40.0 0.0 1.0 0.1))
	  (gen1 (make-asyfm :frequency 40.0 :ratio .1 :index 2.0)))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 40.0) (mus-srate))))) ;22050.0))))
	  ((= i 1100))
	(let* ((val1 (asymmetric-fm gen 2.0)) ; 1.0=index
	       (val3 (asyfm-J gen1 0.0))
	       (r 1.0)
	       (ratio 0.1)
	       (index 2.0)
	       ;; (freq (hz->radians 40.0))
	       ;; (phase a)
	       (cr (* 0.5 (- r (/ 1.0 r))))
	       (sr (* 0.5 (+ r (/ 1.0 r))))
	       (th a)
	       (mth (* ratio th))
	       (val2 (* (exp (* index cr (+ 1.0 (cos mth))))
			(cos (+ th (* index sr (sin mth)))))))
	  (if (or (fneq val1 val2)
		  (fneq val1 val3))
	      (snd-display #__line__ ";asyfm by hand: ~A: ~A ~A ~A" i val1 val2 val3)))))
    
    (let ((vct0 (make-vct 2048))
	  (vct1 (make-vct 2048))
	  (gen3 (make-asymmetric-fm 1000 0 2.0 0.1))
	  (gen4 (make-asymmetric-fm 1000 0 0.5 0.1)))
      (do ((i 0 (+ 1 i)))
	  ((= i 2048))
	(vct-set! vct0 i (asymmetric-fm gen3 2.0 0.0))
	(vct-set! vct1 i (asymmetric-fm gen4 2.0 0.0)))
      (let* ((spectr1 (snd-spectrum vct0 rectangular-window 2048 #t))
	     (spectr2 (snd-spectrum vct1 rectangular-window 2048 #t))
	     (s1-loc 0)
	     (s2-loc 0))
	(do ((i 1 (+ 1 i)))
	    ((= i 256))
	  (if (< (abs (- 1.0 (vct-ref spectr1 i))) .01) (set! s1-loc i))
	  (if (< (abs (- 1.0 (vct-ref spectr2 i))) .01) (set! s2-loc i)))
	(if (> s2-loc s1-loc) (snd-display #__line__ ";asymmetric-fm peaks: ~A ~A" s1-loc s2-loc))
	(let ((center (* (/ 22050 2048) (* .5 (+ s1-loc s2-loc)))))
	  (if (> (abs (- 1000 center)) 60) (snd-display #__line__ ";asymmetric-fm center: ~A" center)))
	(set! (mus-scaler gen3) 0.5)
	(do ((i 0 (+ 1 i)))
	    ((= i 2048))
	  (vct-set! vct0 i (asymmetric-fm gen3 2.0 0.0)))
	(set! spectr1 (snd-spectrum vct0 rectangular-window 2048 #t))
	(do ((i 1 (+ 1 i)))
	    ((= i 256))
	  (if (< (abs (- 1.0 (vct-ref spectr1 i))) .01) (set! s1-loc i)))
	(if (not (= s2-loc s1-loc)) (snd-print (format #f "asymmetric-fm set r peaks: ~A ~A" s1-loc s2-loc)))
	(do ((i 0 (+ 1 i)))
	    ((= i 2048))
	  (vct-set! vct0 i (asymmetric-fm gen3 2.0 0.0)))
	(snd-spectrum vct0 rectangular-window 2048 #t 0.0 #t)
	(do ((i 1 (+ 1 i)))
	    ((= i 256))
	  (if (< (abs (- 1.0 (vct-ref vct0 i))) .01) (set! s1-loc i)))
	(if (not (= s2-loc s1-loc)) (snd-print (format #f "asymmetric-fm set r in place peaks: ~A ~A" s1-loc s2-loc)))))
    
    (let ((gen (make-asyfm :frequency 2000 :ratio .1))) 
      (asyfm-I gen 0.0))
    
    (let ((gen (make-fir-filter 3 (list->vct '(.5 .25 .125))))
	  (v0 (make-vct 10))
	  (gen1 (make-fir-filter 3 (list->vct '(.5 .25 .125))))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "fir-filter"
		       "fir-filter order: 3, xs: [0.500 0.250 0.125]"
		       )
      (vct-set! v0 0 (fir-filter gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (fir-filter gen 0.0)))
      (vct-map! v1 (let ((inp 1.0))
		     (lambda () 
		       (let ((val (if (fir-filter? gen1) (fir-filter gen1 inp) -1.0)))
			 (set! inp 0.0)
			 val))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map fir-filter: ~A ~A" v0 v1))
      (if (not (fir-filter? gen)) (snd-display #__line__ ";~A not fir-filter?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";fir-filter length: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) 0.25) (fneq (vct-ref v0 2) .125)) (snd-display #__line__ ";fir-filter output: ~A" v0))
      (let ((data (mus-xcoeffs gen)))
	(if (fneq (vct-ref data 1) .25) (snd-display #__line__ ";fir-filter xcoeffs: ~A?" data)))
      (let ((tag (catch #t (lambda () (mus-xcoeff gen 123)) (lambda args (car args)))))
	(if (not (eq? tag 'mus-error))
	    (snd-display #__line__ ";xcoeff 123: ~A" tag)))
      (let ((tag (catch #t (lambda () (mus-ycoeff gen 123)) (lambda args (car args)))))
	(if (not (eq? tag 'mus-error))
	    (snd-display #__line__ ";fir ycoeff 123: ~A" tag))))
    
    (test-gen-equal (let ((f1 (make-fir-filter 3 (list->vct '(.5 .25 .125))) )) (fir-filter f1 1.0) f1)
		    (let ((f2 (make-fir-filter 3 (list->vct '(.5 .25 .125))) )) (fir-filter f2 1.0) f2)
		    (let ((f3 (make-fir-filter 3 (list->vct '(.75 .25 .125))))) (fir-filter f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-fir-filter 3 (list->vct '(.5 .25 .125))) )) (fir-filter f1 1.0) f1)
		    (let ((f2 (make-fir-filter 3 (list->vct '(.5 .25 .125))) )) (fir-filter f2 1.0) f2)
		    (let ((f3 (make-fir-filter 2 (list->vct '(.5 .25))))) (fir-filter f3 1.0) f3))
    
    (let* ((coeffs (list .1 .2 .3 .4 .4 .3 .2 .1))
	   (flt (make-fir-filter 8 (list->vct coeffs)))
	   (es (make-vector 8)))
      (do ((i 0 (+ 1 i)))
	  ((= i 8))
	(vector-set! es i (make-env (list 0 (list-ref coeffs i) 1 0) :length 102)))
      (vector-set! es 5 (make-env '(0 .4 1 1) :length 102))
      (let ((data (make-vct 100)))
	(do ((k 0 (+ 1 k)))
	    ((= k 100))
	  (let ((val (fir-filter flt (if (= (modulo k 12) 0) 1.0 0.0)))
		(xcof (mus-xcoeffs flt)))
	    (do ((i 0 (+ 1 i)))
		((= i 8))
	      (vct-set! xcof i (env (vector-ref es i))))
	    (vct-set! data k val)))
	(if (or (fneq (vct-ref data 1) .2)
		(fneq (vct-ref data 10) 0.0)
		(fneq (vct-ref data 18) 0.166)
		(fneq (vct-ref data 89) 0.923))
	    (snd-display #__line__ ";filter xcoeffs: ~A?" data))))
    
    (letrec ((make-f-filter (lambda (coeffs)
			      (list coeffs (make-vct (vct-length coeffs)))))
	     (f-filter (lambda (flt x)
			 (let* ((coeffs (car flt))
				(xs (cadr flt))
				(xlen (vct-length xs)))
			   (vct-move! xs (- xlen 1) (- xlen 2) #t)
			   (vct-set! xs 0 x)
			   (dot-product coeffs xs xlen)))))
      (let ((fir1 (make-fir-filter 3 (vct 1.0 0.4 0.1)))
	    (fir2 (make-f-filter (vct 1.0 0.4 0.1)))
	    (x 1.0)
	    (happy #t))
	(do ((i 0 (+ 1 i)))
	    ((or (not happy) (= i 10)))
	  (let ((val1 (fir-filter fir1 x))
		(val2 (f-filter fir2 x)))
	    (set! x 0.0)
	    (if (fneq val1 val2)
		(begin
		  (snd-display #__line__ ";f-filter ~A -> ~A ~A" i val1 val2)
		  (set! happy #f)))))))
    
    (let ((gen (make-spencer-filter)))
      (if (not (fir-filter? gen)) 
	  (snd-display #__line__ ";make-spencer-filter returns ~A?" gen)
	  (begin
	    (if (not (= (mus-order gen) 15)) (snd-display #__line__ ";make-spencer-filter order ~A?" (mus-order gen)))
	    (if (not (vequal (mus-xcoeffs gen) (vct -0.009 -0.019 -0.016 0.009 0.066 0.144 0.209 0.231 0.209 0.144 0.066 0.009 -0.016 -0.019 -0.009)))
		(snd-display #__line__ ";make-spencer-filter coeffs: ~A" (mus-xcoeffs gen))))))
    
    (let ((flt (make-savitzky-golay-filter 5 2)))
      (if (not (vequal (mus-xcoeffs flt) (vct -0.086 0.343 0.486 0.343 -0.086)))
	  (snd-display #__line__ ";sg 5 2: ~A" (mus-xcoeffs flt))))
    (let ((flt (make-savitzky-golay-filter 11 2)))
      (if (not (vequal (mus-xcoeffs flt) (vct -0.084 0.021 0.103 0.161 0.196 0.207 0.196 0.161 0.103 0.021 -0.084)))
	  (snd-display #__line__ ";sg 11 2: ~A" (mus-xcoeffs flt))))
    (let ((flt (make-savitzky-golay-filter 11 4)))
      (if (not (vequal (mus-xcoeffs flt) (vct 0.042 -0.105 -0.023 0.140 0.280 0.333 0.280 0.140 -0.023 -0.105 0.042)))
	  (snd-display #__line__ ";sg 11 4: ~A" (mus-xcoeffs flt))))
    (let ((flt (make-savitzky-golay-filter 25 2)))
      (if (not (vequal (mus-xcoeffs flt) (vct -0.049 -0.027 -0.006 0.012 0.028 0.043 0.055 0.066 0.075 0.082 0.086 
					      0.089 0.090 0.089 0.086 0.082 0.075 0.066 0.055 0.043 
					      0.028 0.012 -0.006 -0.027 -0.049)))
	  (snd-display #__line__ ";sg 25 2: ~A" (mus-xcoeffs flt))))
    
    (let ((gen (make-iir-filter 3 (list->vct '(.5 .25 .125))))
	  (v0 (make-vct 10))
	  (gen1 (make-iir-filter 3 (list->vct '(.5 .25 .125))))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "iir-filter"
		       "iir-filter order: 3, ys: [0.500 0.250 0.125]"
		       )
      (vct-set! v0 0 (iir-filter gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (iir-filter gen 0.0)))
      (vct-map! v1 (let ((inp 1.0))
		     (lambda ()
		       (let ((val (if (iir-filter? gen1) (iir-filter gen1 inp) -1.0)))
			 (set! inp 0.0)
			 val))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map iir-filter: ~A ~A" v0 v1))
      (if (not (iir-filter? gen)) (snd-display #__line__ ";~A not iir-filter?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";iir-filter length: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) -0.25) (fneq (vct-ref v0 2) -.062)) (snd-display #__line__ ";iir-filter output: ~A" v0))
      (let ((data (mus-ycoeffs gen)))
	(if (fneq (vct-ref data 1) .25) (snd-display #__line__ ";iir-filter ycoeffs: ~A?" data)))
      (let ((tag (catch #t (lambda () (mus-ycoeff gen 123)) (lambda args (car args)))))
	(if (not (eq? tag 'mus-error))
	    (snd-display #__line__ ";ycoeff 123: ~A" tag)))
      (let ((tag (catch #t (lambda () (mus-xcoeff gen 123)) (lambda args (car args)))))
	(if (not (eq? tag 'mus-error))
	    (snd-display #__line__ ";iir xcoeff 123: ~A" tag))))
    
    (test-gen-equal (let ((f1 (make-iir-filter 3 (list->vct '(.5 .25 .125))))) (iir-filter f1 1.0) f1)
		    (let ((f2 (make-iir-filter 3 (list->vct '(.5 .25 .125))) )) (iir-filter f2 1.0) f2)
		    (let ((f3 (make-iir-filter 3 (list->vct '(.75 .25 .125))))) (iir-filter f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-iir-filter 3 (list->vct '(.5 .25 .125))) )) (iir-filter f1 1.0) f1)
		    (let ((f2 (make-iir-filter 3 (list->vct '(.5 .25 .125))) )) (iir-filter f2 1.0) f2)
		    (let ((f3 (make-iir-filter 2 (list->vct '(.5 .25))))) (iir-filter f3 1.0) f3))
    
    (let ((gen (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .25 .125))))
	  (v0 (make-vct 10))
	  (gen1 (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .25 .125))))
	  (v1 (make-vct 10))
	  (gen2 (make-biquad .1 .2 .3 .4 .5)))
      (print-and-check gen 
		       "filter"
		       "filter order: 3, xs: [0.500 0.250 0.125], ys: [0.500 0.250 0.125]"
		       )
      (vct-set! v0 0 (filter gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (filter gen 0.0)))
      (vct-map! v1 (let ((inp 1.0))
		     (lambda () 
		       (let ((val (if (filter? gen1) (filter gen1 inp) -1.0)))
			 (set! inp 0.0)
			 val))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map filter: ~A ~A" v0 v1))
      (if (not (filter? gen)) (snd-display #__line__ ";~A not filter?" gen))
      (if (not (= (mus-length gen) 3)) (snd-display #__line__ ";filter length: ~D?" (mus-length gen)))
      (if (or (fneq (vct-ref v0 1) 0.125) (fneq (vct-ref v0 2) .031)) (snd-display #__line__ ";filter output: ~A" v0))
      (if (not (filter? gen2)) (snd-display #__line__ ";make-biquad: ~A" gen2))
      (let ((xs (mus-xcoeffs gen))
	    (ys (mus-ycoeffs gen)))
	(if (or (not (equal? xs (list->vct '(.5 .25 .125))))
		(not (equal? xs ys)))
	    (snd-display #__line__ ";mus-xcoeffs: ~A ~A?" xs ys))))
    
    (let ((var (catch #t (lambda () (make-filter :order 2 :xcoeffs (vct 1.0 0.5) :ycoeffs (vct 2.0 1.0 0.5))) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-filter bad coeffs: ~A" var)))
    (let ((var (catch #t (lambda () (make-filter :order 0 :xcoeffs (vct 1.0 0.5))) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-filter bad order: ~A" var)))
    (let ((var (catch #t (lambda () (make-fir-filter :order 22 :xcoeffs (vct 1.0 0.5))) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-fir-filter bad coeffs: ~A" var)))
    (let ((var (catch #t (lambda () (make-iir-filter :order 22 :ycoeffs (vct 1.0 0.5))) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-iir-filter bad coeffs: ~A" var)))
    (let ((var (catch #t (lambda () (make-fir-filter -1)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-fir-filter bad order: ~A" var)))
    (let ((var (make-filter :order 2 :ycoeffs (vct 1.0 0.5))))
      (if (not (iir-filter? var))
	  (snd-display #__line__ ";make-filter with only y: ~A" var)))
    
    (test-gen-equal (let ((f1 (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .25 .125))))) (filter f1 1.0) f1)
		    (let ((f2 (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .25 .125))))) (filter f2 1.0) f2)
		    (let ((f3 (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .5 .5))))) (filter f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .25 .125))))) (filter f1 1.0) f1)
		    (let ((f2 (make-filter 3 (list->vct '(.5 .25 .125)) (list->vct '(.5 .25 .125))))) (filter f2 1.0) f2)
		    (let ((f3 (make-filter 3 (list->vct '(.5 .5 .125)) (list->vct '(.5 .25 .0625))))) (filter f3 1.0) f3))
    
    (let ((fr (make-fir-filter 6 (vct 0 1 2 3 4 5))))
      (if (not (= (mus-length fr) 6)) (snd-display #__line__ ";filter-length: ~A" (mus-length fr))))
    
    (let ((val (cascade->canonical (list (vct 1.0 0.0 0.0) (vct 1.0 0.5 0.25)))))
      (if (not (vequal val (vct 1.000 0.500 0.250 0.000 0.000)))
	  (snd-display #__line__ ";cas2can 0: ~A" val)))
    (let ((val (cascade->canonical (list (vct 1.0 1.0 0.0) (vct 1.0 0.5 0.25)))))
      (if (not (vequal val (vct 1.000 1.500 0.750 0.250 0.000)))
	  (snd-display #__line__ ";cas2can 1: ~A" val)))
    
    (let ((val (cascade->canonical (list (vct 1 0.8 0) (vct 1 1.4 0.65) (vct 1 0 0)))))
      (if (not (vequal val (vct 1.000 2.200 1.770 0.520 0.000 0.000 0.000)))
	  (snd-display #__line__ ";cascade->canonical: ~A" val)))
    (let ((val (cascade->canonical (list (vct 1 -0.9 0) (vct 1 1 0.74) (vct 1 -1.6 0.8)))))
      (if (not (vequal val (vct 1.000 -1.500 0.480 -0.330 0.938 -0.533 0.000)))
	  (snd-display #__line__ ";cascade->canonical 1: ~A" val)))
    
    (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050)))
      (pad-channel 0 10000)
      (freq-sweep .45)
      (let ((sp (rough-spectrum ind)))
	(if (and (not (vequal sp (vct 0.962 0.998 0.998 0.998 0.998 0.999 0.999 0.998 0.997 1.000)))
		 (not (vequal sp (vct 0.963 0.999 0.999 0.999 0.999 0.999 1.000 1.000 0.998 0.997))))
	    (snd-display #__line__ ";initial rough spectrum: ~A" sp)))
      
      (let ((b (make-butter-high-pass 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.915 -0.162 -0.146 -0.131 -0.117 -0.103 -0.090 -0.078 -0.066 -0.056)))
	    (snd-display #__line__ ";butter high: ~A" v))
	(set! b (make-butter-high-pass 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.150 0.833 0.980 0.994 0.997 0.998 0.999 0.998 0.997 1.000)))
		   (not (vequal sp (vct 0.150 0.833 0.981 0.995 0.998 0.999 1.000 1.000 0.998 0.997))))
	      (snd-display #__line__ ";hp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-butter-low-pass 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.004 0.014 0.026 0.035 0.043 0.049 0.053 0.055 0.057 0.057)))
	    (snd-display #__line__ ";butter low: ~A" v))
	(set! b (make-butter-low-pass 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 1.000 0.212 0.024 0.005 0.001 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";lp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-butter-band-pass 440.0 50.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.007 0.014 0.013 0.013 0.012 0.011 0.009 0.008 0.007 0.005)))
	    (snd-display #__line__ ";butter bandpass: ~A" v))
	(set! b (make-butter-band-pass 1000.0 500.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 0.888 1.000 0.144 0.056 0.027 0.014 0.008 0.004 0.002 0.000)))
	      (snd-display #__line__ ";bp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-butter-band-reject 440.0 50.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.993 -0.014 -0.013 -0.013 -0.012 -0.011 -0.009 -0.008 -0.007 -0.005)))
	    (snd-display #__line__ ";butter bandstop: ~A" v))
	(set! b (make-butter-band-reject 1000.0 500.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.662 0.687 0.953 0.980 0.989 0.994 0.997 0.997 0.997 1.000)))
		   (not (vequal sp (vct 0.664 0.689 0.955 0.982 0.992 0.996 0.999 1.000 0.999 0.998))))
	      (snd-display #__line__ ";bs rough spectrum: ~A" sp)))
	(undo))
      
      (if (defined? 'gsl-roots) (analog-filter-tests))
      (test-lpc)
      (test-unclip-channel)
      
      (let ((v (spectrum->coeffs 10 (vct 0 1.0 0 0 0 0 0 0 1.0 0)))
	    (v1 (make-fir-coeffs 10 (vct 0 1.0 0 0 0 0 0 0 1.0 0))))
	(if (not (vequal v (vct -0.190 -0.118 0.000 0.118 0.190 0.190 0.118 0.000 -0.118 -0.190)))
	    (snd-display #__line__ ";spectrum->coeffs: ~A" v))
	(if (not (vequal v v1))
	    (snd-display #__line__ ";spectrum->coeffs v make-fir-coeffs: ~A ~A" v v1)))
      
      (let ((notched-spectr (make-vct 20)))
	(vct-set! notched-spectr 2 1.0) 
	(let ((v (spectrum->coeffs 20 notched-spectr))
	      (v1 (make-fir-coeffs 20 notched-spectr)))
	  (if (not (vequal v (vct 0.095 0.059 -0.000 -0.059 -0.095 -0.095 -0.059 0.000 0.059 0.095 
				  0.095 0.059 0.000 -0.059 -0.095 -0.095 -0.059 -0.000 0.059 0.095)))
	      (snd-display #__line__ ";spectrum->coeffs (notch): ~A" v))
	  (if (not (vequal v v1))
	      (snd-display #__line__ ";spectrum->coeffs v(2) make-fir-coeffs: ~A ~A" v v1))
	  (let ((flt (make-fir-filter 20 v)))
	    (map-channel (lambda (y) (fir-filter flt y)))))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 0.007 0.493 1.000 0.068 0.030 0.019 0.014 0.011 0.009 0.009)))
	      (snd-display #__line__ ";sp->coeff rough spectrum: ~A" sp)))
	(undo))
      
      (let ((rspect (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! rspect i (random 1.0)))
	(let ((v (spectrum->coeffs 20 rspect))
	      (v1 (make-fir-coeffs 20 rspect)))
	  (if (not (vequal v v1))
	      (snd-display #__line__ ";spectrum->coeffs v(3) make-fir-coeffs: ~A ~A" v v1))))
      
      (let ((b (make-highpass (hz->radians 1000.0) 10))
	    (v (make-vct 20))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (fir-filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct -0.001 -0.002 -0.005 -0.011 -0.021 -0.034 -0.049 -0.065 -0.078 -0.087 
				0.909 -0.087 -0.078 -0.065 -0.049 -0.034 -0.021 -0.011 -0.005 -0.002)))
	    (snd-display #__line__ ";dsp.scm high: ~A" v))
	(set! b (make-highpass (hz->radians 1000.0) 20))
	(map-channel (lambda (y) (fir-filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.053 0.774 0.998 0.997 0.997 0.996 0.996 0.996 0.997 1.000)))
		   (not (vequal sp (vct 0.053 0.776 1.000 0.998 0.998 0.998 0.998 0.998 0.998 1.000))))
	      (snd-display #__line__ ";dsp hp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-lowpass (hz->radians 1000.0) 10))
	    (v (make-vct 20))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (fir-filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.001 0.002 0.005 0.011 0.021 0.034 0.049 0.065 0.078 0.087 0.091 0.087 0.078 0.065
				0.049 0.034 0.021 0.011 0.005 0.002)))
	    (snd-display #__line__ ";dsp.scm low: ~A" v))
	(set! b (make-lowpass (hz->radians 1000.0) 20))
	(map-channel (lambda (y) (fir-filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 1.000 0.054 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";dsp lp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-bandpass (hz->radians 1500.0) (hz->radians 2000.0) 10))
	    (v (make-vct 20))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (fir-filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.001 -0.001 -0.005 -0.011 -0.017 -0.019 -0.013 0.003 0.022 0.039 0.045
				0.039 0.022 0.003 -0.013 -0.019 -0.017 -0.011 -0.005 -0.001)))
	    (snd-display #__line__ ";dsp.scm bp: ~A" v))
	(set! b (make-bandpass (hz->radians 1500.0) (hz->radians 2000.0) 20))
	(map-channel (lambda (y) (fir-filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 0.010 1.000 0.154 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";dsp bp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-bandstop (hz->radians 1500.0) (hz->radians 2000.0) 10))
	    (v (make-vct 20))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (fir-filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct -0.001 0.001 0.005 0.011 0.017 0.019 0.013 -0.003 -0.022 -0.039 0.955
				-0.039 -0.022 -0.003 0.013 0.019 0.017 0.011 0.005 0.001)))
	    (snd-display #__line__ ";dsp.scm bs: ~A" v))
	(set! b (make-bandstop (hz->radians 1500.0) (hz->radians 2000.0) 20))
	(map-channel (lambda (y) (fir-filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.904 0.425 0.821 0.998 0.997 0.996 0.996 0.996 0.997 1.000)))
		   (not (vequal sp (vct 0.906 0.425 0.822 1.000 0.999 0.998 0.998 0.998 0.998 1.000))))
	      (snd-display #__line__ ";dsp bs rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-differentiator 10))
	    (v (make-vct 20))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (fir-filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct -0.008 0.011 -0.021 0.039 -0.066 0.108 -0.171 0.270 -0.456 0.977
				0.000 -0.977 0.456 -0.270 0.171 -0.108 0.066 -0.039 0.021 -0.011)))
	    (snd-display #__line__ ";dsp.scm df: ~A" v))
	(set! b (make-differentiator 20))
	(map-channel (lambda (y) (fir-filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 0.004 0.027 0.075 0.147 0.242 0.362 0.506 0.674 0.864 1.000)))
	      (snd-display #__line__ ";dsp df rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-iir-high-pass-1 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.941 -0.111 -0.098 -0.086 -0.076 -0.067 -0.059 -0.052 -0.046 -0.041)))
	    (snd-display #__line__ ";iir-1 high: ~A" v))
	(set! b (make-iir-high-pass-1 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.228 0.706 0.879 0.940 0.967 0.982 0.990 0.994 0.996 1.000)))
		   (not (vequal sp (vct 0.229 0.709 0.883 0.944 0.971 0.986 0.994 0.999 1.000 1.000))))
	      (snd-display #__line__ ";iir-1 hp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-iir-low-pass-1 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.059 0.111 0.098 0.086 0.076 0.067 0.059 0.052 0.046 0.041)))
	    (snd-display #__line__ ";iir-1 low: ~A" v))
	(set! b (make-iir-low-pass-1 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 1.000 0.402 0.164 0.080 0.043 0.023 0.013 0.006 0.003 0.001)))
	      (snd-display #__line__ ";iir-1 lp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-iir-high-pass-2 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.915 -0.162 -0.146 -0.131 -0.117 -0.103 -0.090 -0.078 -0.066 -0.056)))
	    (snd-display #__line__ ";iir-2 high: ~A" v))
	(set! b (make-iir-high-pass-2 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.150 0.833 0.980 0.994 0.997 0.998 0.999 0.998 0.997 1.000)))
		   (not (vequal sp (vct 0.150 0.833 0.981 0.995 0.998 0.999 1.000 1.000 0.998 0.997))))
	      (snd-display #__line__ ";iir-2 hp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-iir-low-pass-2 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (butter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.004 0.014 0.026 0.035 0.043 0.049 0.053 0.055 0.057 0.057)))
	    (snd-display #__line__ ";iir-2 low: ~A" v))
	(set! b (make-iir-low-pass-2 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 1.000 0.212 0.024 0.005 0.001 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";iir-2 lp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-iir-band-pass-2 440.0 490.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.007 0.014 0.013 0.013 0.012 0.010 0.009 0.008 0.006 0.004)))
	    (snd-display #__line__ ";iir bp-2 bandpass: ~A" v))
	(set! b (make-iir-band-pass-2 1000.0 1500.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (not (vequal sp (vct 0.239 1.000 0.117 0.041 0.019 0.010 0.005 0.003 0.001 0.000)))
	      (snd-display #__line__ ";iir bp-2 rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-iir-band-stop-2 440.0 500.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.992 -0.017 -0.016 -0.015 -0.014 -0.012 -0.011 -0.009 -0.007 -0.005)))
	    (snd-display #__line__ ";iir-2 bandstop: ~A" v))
	(set! b (make-iir-band-stop-2 1000.0 1500.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.836 0.525 0.943 0.979 0.989 0.994 0.997 0.997 0.997 1.000)))
		   (not (vequal sp (vct 0.838 0.527 0.945 0.981 0.991 0.996 0.999 1.000 0.999 0.998))))
	      (snd-display #__line__ ";iir bs-2 rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-butter-hp 4 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (filter b inv))) (set! inv 0.0) val)))
	(if (and (not (vequal v (vct 0.725 -0.466 -0.315 -0.196 -0.104 -0.036 0.014 0.047 0.0685 0.0775)))
		 (not (vequal v (vct 0.725 -0.466 -0.315 -0.196 -0.104 -0.035 0.015 0.049 0.070 0.081)))
		 (not (vequal v (vct 0.725 -0.466 -0.315 -0.196 -0.104 -0.035 0.014 0.049 0.069 0.079))))
	    (snd-display #__line__ ";butter hp: ~A" v))
	(set! b (make-butter-hp 4 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 0.0505 0.982 1.000 1.000 0.998 0.998 0.999 0.998 0.996 0.999)))
		   (not (vequal sp (vct 0.051 0.982 1.000 1.000 0.998 0.998 0.998 0.999 0.997 0.995)))
		   (not (vequal sp (vct 0.051 0.991 1.000 1.000 0.998 0.998 0.999 0.999 0.997 0.995)))
		   (not (vequal sp (vct 0.045 0.970 1.000 1.000 0.998 0.998 0.999 0.999 0.997 0.995)))
		   (not (vequal sp (vct 0.052 0.971 1.000 1.000 0.998 0.998 0.999 0.999 0.997 0.995))))
	      (snd-display #__line__ ";bhp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-butter-lp 4 440.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))) ;; ???
	    (snd-display #__line__ ";butter lp: ~A" v))
	(set! b (make-butter-lp 4 1000.0))
	(map-channel (lambda (y) (filter b y)))
	(let ((sp (rough-spectrum ind)))
	  (if (and (not (vequal sp (vct 1.000 0.035 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		   (not (vequal sp (vct 1.000 0.038 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
	      (snd-display #__line__ ";blp rough spectrum: ~A" sp)))
	(undo))
      
      (let ((b (make-butter-bp 4 440.0 500.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (filter b inv))) (set! inv 0.0) val)))
	(if (not (vequal v (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";butter bp: ~A" v))
	(set! b (make-butter-bp 4 1000.0 1500.0))
	(map-channel (lambda (y) (filter b y)))
	(undo))
      
      (let ((b (make-butter-bs 4 440.0 500.0))
	    (v (make-vct 10))
	    (inv 1.0))
	(vct-map! v (lambda () (let ((val (filter b inv))) (set! inv 0.0) val)))
	(if (and (not (vequal v (vct 0.978 -0.043 -0.041 -0.038 -0.035 -0.031 -0.026 -0.0225 -0.015 -0.0085)))
		 (not (vequal v (vct 0.978 -0.043 -0.041 -0.038 -0.035 -0.031 -0.027 -0.022 -0.017 -0.011)))
		 (not (vequal v (vct 0.978 -0.043 -0.041 -0.038 -0.035 -0.031 -0.027 -0.021 -0.014 -0.011))))
	    (snd-display #__line__ ";butter bs: ~A" v))
	(set! b (make-butter-bs 4 1000.0 1500.0))
	(map-channel (lambda (y) (filter b y)))
	(undo))
      
      (revert-sound)
      (test-scanned-synthesis .1 10000 1.0 0.1 0.0)
      
      (close-sound ind))
    
    (let ((gen (make-sawtooth-wave 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-sawtooth-wave 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "sawtooth-wave"
		       "sawtooth-wave freq: 440.000Hz, phase: 3.142, amp: 1.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (sawtooth-wave gen 0.0)))
      (vct-map! v1 (lambda () (if (sawtooth-wave? gen1) (sawtooth-wave gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map sawtooth: ~A ~A" v0 v1))
      (if (not (sawtooth-wave? gen)) (snd-display #__line__ ";~A not sawtooth-wave?" gen))
      (if (fneq (mus-phase gen) 4.39538) (snd-display #__line__ ";sawtooth-wave phase: ~F?" (mus-phase gen))) ;starts at pi
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";sawtooth-wave frequency: ~F?" (mus-frequency gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";set! sawtooth-wave frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 1.0) (snd-display #__line__ ";sawtooth-wave scaler: ~F?" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";set! sawtooth-wave scaler: ~F?" (mus-scaler gen)))
      (if (or (fneq (vct-ref v0 1) 0.04) (fneq (vct-ref v0 8) .319)) (snd-display #__line__ ";sawtooth-wave output: ~A" v0)))
    
    (test-gen-equal (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0) (make-sawtooth-wave 120.0))
    (test-gen-equal (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0 1.0 1.0))
    (test-gen-equal (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0) (make-sawtooth-wave 440.0 0.5))
    
    (let ((gen1 (make-sawtooth-wave 100.0))
	  (gen2 (make-sawtooth-wave -100.0))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(set! mx (max mx (abs (+ (gen1) (gen2))))))
      (if (fneq mx 0.0)
	  (snd-display #__line__ ";sawtooth +-: ~A" mx)))
    
    (let ((gen (make-square-wave 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-square-wave 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "square-wave"
		       "square-wave freq: 440.000Hz, phase: 0.000, amp: 1.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (square-wave gen 0.0)))
      (let ((w 1.0))
	(vct-map! v1 (lambda () 
		       (set! w (mus-width gen1))
		       (if (square-wave? gen1) (square-wave gen1 0.0) -1.0)))
	(if (fneq w 0.5) (snd-display #__line__ ";mus-width opt: ~A" w)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map square-wave: ~A ~A" v0 v1))
      (if (not (square-wave? gen)) (snd-display #__line__ ";~A not square-wave?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";square-wave phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";square-wave frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 1.0) (snd-display #__line__ ";square-wave scaler: ~F?" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";set! square-wave scaler: ~F?" (mus-scaler gen)))
      (if (fneq (mus-width gen) 0.5) (snd-display #__line__ ";square-wave width: ~A" (mus-width gen)))
      (set! (mus-width gen) 0.75)
      (if (fneq (mus-width gen) 0.75) (snd-display #__line__ ";set! square-wave width: ~A" (mus-width gen)))
      (if (or (fneq (vct-ref v0 1) 1.0) (fneq (vct-ref v0 8) 1.0)) (snd-display #__line__ ";square-wave output: ~A" v0)))
    
    (test-gen-equal (make-square-wave 440.0) (make-square-wave 440.0) (make-square-wave 120.0))
    (test-gen-equal (make-square-wave 440.0) (make-square-wave 440.0) (make-square-wave 440.0 1.0 1.0))
    (test-gen-equal (make-square-wave 440.0) (make-square-wave 440.0) (make-square-wave 440.0 0.5))
    
    (let ((old-srate (mus-srate)))
      (set! (mus-srate) 500.0)
      (let ((gen (make-square-wave 100.0 -0.5 (* pi 0.5)))
	    (v0 (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v0 i (gen)))
	(if (not (vequal v0 (vct -0.5 -0.5 0.0 0.0 -0.5 -0.5 -0.5 0.0 0.0 -0.5 -0.5 -0.5 0.0 0.0 -0.5 -0.5 -0.5 0.0 0.0 -0.5)))
	    (snd-display #__line__ ";square-wave -.5: ~A " v0)))
      (set! (mus-srate) old-srate))
    
    (let ((gen (make-triangle-wave 440.0))
	  (gen1 (make-triangle-wave 440.0 1.0 pi))
	  (v0 (make-vct 10))
	  (gen2 (make-triangle-wave 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "triangle-wave"
		       "triangle-wave freq: 440.000Hz, phase: 0.000, amp: 1.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (triangle-wave gen 0.0)))
      (vct-map! v1 (lambda () (if (triangle-wave? gen2) (triangle-wave gen2 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map triangle-wave: ~A ~A" v0 v1))
      (if (not (triangle-wave? gen)) (snd-display #__line__ ";~A not triangle-wave?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";triangle-wave phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-phase gen1) pi) (snd-display #__line__ ";init triangle-wave phase: ~F?" (mus-phase gen1)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";triangle-wave frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 1.0) (snd-display #__line__ ";triangle-wave scaler: ~F?" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";set! triangle-wave scaler: ~F?" (mus-scaler gen)))
      (if (or (fneq (vct-ref v0 1) 0.080) (fneq (vct-ref v0 8) 0.639)) (snd-display #__line__ ";triangle-wave output: ~A" v0)))
    
    (let ((gen1 (make-triangle-wave 100.0))
	  (gen2 (make-triangle-wave -100.0))
	  (mx 0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(set! mx (max mx (abs (+ (gen1) (gen2))))))
      (if (fneq mx 0.0)
	  (snd-display #__line__ ";triangle +-: ~A" mx)))
    
    (test-gen-equal (make-triangle-wave 440.0) (make-triangle-wave 440.0) (make-triangle-wave 120.0))
    (test-gen-equal (make-triangle-wave 440.0) (make-triangle-wave 440.0) (make-triangle-wave 440.0 1.0 1.0))
    (test-gen-equal (make-triangle-wave 440.0) (make-triangle-wave 440.0) (make-triangle-wave 440.0 0.5))
    
    (let ((gen (make-pulse-train 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-pulse-train 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "pulse-train"
		       "pulse-train freq: 440.000Hz, phase: 0.000, amp: 1.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (pulse-train gen 0.0)))
      (vct-map! v1 (lambda () (if (pulse-train? gen1) (pulse-train gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map pulse-train: ~A ~A" v0 v1))
      (if (not (pulse-train? gen)) (snd-display #__line__ ";~A not pulse-train?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";pulse-train phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";pulse-train frequency: ~F?" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 1.0) (snd-display #__line__ ";pulse-train scaler: ~F?" (mus-scaler gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";set! pulse-train scaler: ~F?" (mus-scaler gen)))
      (if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 8) 0.0)) (snd-display #__line__ ";pulse-train output: ~A" v0)))
    
    (test-gen-equal (make-pulse-train 440.0) (make-pulse-train 440.0) (make-pulse-train 120.0))
    (test-gen-equal (make-pulse-train 440.0) (make-pulse-train 440.0) (make-pulse-train 440.0 1.0 1.0))
    (test-gen-equal (make-pulse-train 440.0) (make-pulse-train 440.0) (make-pulse-train 440.0 0.5))
    
    (let ((old-srate (mus-srate)))
      (set! (mus-srate) 500.0)
      (let ((gen (make-pulse-train 100.0 -0.5 (* pi 0.5)))
	    (v0 (make-vct 20)))
	(do ((i 0 (+ 1 i)))
	    ((= i 20))
	  (vct-set! v0 i (gen)))
	(if (not (vequal v0 (vct  0.0 0.0 0.0 0.0 -0.5 0.0 0.0 0.0 0.0 -0.5 0.0 0.0 0.0 0.0 -0.5 0.0 0.0 0.0 0.0 -0.5)))
	    (snd-display #__line__ ";pulse-train -.5: ~A " v0)))
      (set! (mus-srate) old-srate))
    
    
    (let ((gen (make-ppolar .1 1200.0))
	  (v0 (make-vct 10)))
      (vct-set! v0 0 (two-pole gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (two-pole gen 0.0)))
      (if (not (two-pole? gen)) (snd-display #__line__ ";~A not ppolar?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";ppolar order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) 1.0) (snd-display #__line__ ";ppolar a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-b1 gen) -.188) (snd-display #__line__ ";ppolar b1: ~F?" (mus-b1 gen)))
      (if (fneq (mus-b2 gen) .01) (snd-display #__line__ ";ppolar b2: ~F?" (mus-b2 gen)))
      (if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 1) .188)) (snd-display #__line__ ";ppolar output: ~A" v0))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";freq ppolar: ~A" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.1) (snd-display #__line__ ";scaler ppolar: ~A" (mus-scaler gen))))
    
    (test-gen-equal (let ((z1 (make-ppolar .1 600.0))) (two-pole z1 1.0) z1)
		    (let ((z2 (make-ppolar .1 600.0))) (two-pole z2 1.0) z2)
		    (let ((z3 (make-ppolar .1 1200.0))) (two-pole z3 1.0) z3))
    (test-gen-equal (let ((z1 (make-ppolar :radius .1 :frequency 600.0))) (two-pole z1 1.0) z1)
		    (let ((z2 (make-ppolar :radius .1 :frequency 600.0))) (two-pole z2 1.0) z2)
		    (let ((z3 (make-ppolar :radius .2 :frequency 1200.0))) (two-pole z3 1.0) z3))
    (test-gen-equal (let ((z1 (make-ppolar .1 600.0))) (two-pole z1 1.0) z1)
		    (let ((z2 (make-ppolar .1 600.0))) (two-pole z2 1.0) z2)
		    (let ((z3 (make-ppolar .1 600.0))) (two-pole z3 0.5) z3))
    
    (let ((gen (make-two-pole 1200.0 .1)))
      (if (not (two-pole? gen)) (snd-display #__line__ ";~A not 2ppolar?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";2ppolar order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) 1.0) (snd-display #__line__ ";2ppolar a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-b1 gen) -.188) (snd-display #__line__ ";2ppolar b1: ~F?" (mus-b1 gen)))
      (if (fneq (mus-b2 gen) .01) (snd-display #__line__ ";2ppolar b2: ~F?" (mus-b2 gen)))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";freq 2ppolar: ~A" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.1) (snd-display #__line__ ";scaler 2ppolar: ~A" (mus-scaler gen))))
    
    (let ((gen (make-two-pole :frequency 1200.0 :radius .1)))
      (if (not (two-pole? gen)) (snd-display #__line__ ";~A not f2ppolar?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";f2ppolar order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) 1.0) (snd-display #__line__ ";f2ppolar a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-b1 gen) -.188) (snd-display #__line__ ";f2ppolar b1: ~F?" (mus-b1 gen)))
      (if (fneq (mus-b2 gen) .01) (snd-display #__line__ ";f2ppolar b2: ~F?" (mus-b2 gen)))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";freq f2ppolar: ~A" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.1) (snd-display #__line__ ";scaler f2ppolar: ~A" (mus-scaler gen))))
    
    (let ((gen (make-zpolar :radius .1 :frequency 1200.0))
	  (v0 (make-vct 10)))
      (vct-set! v0 0 (two-zero gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (two-zero gen 0.0)))
      (if (not (two-zero? gen)) (snd-display #__line__ ";~A not zpolar?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";zpolar order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) 1.0) (snd-display #__line__ ";zpolar a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-a1 gen) -.188) (snd-display #__line__ ";zpolar a1: ~F?" (mus-a1 gen)))
      (if (fneq (mus-a2 gen) .01) (snd-display #__line__ ";zpolar a2: ~F?" (mus-a2 gen)))
      (if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 1) -.188)) (snd-display #__line__ ";zpolar output: ~A" v0))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";freq zpolar: ~A" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.1) (snd-display #__line__ ";scaler zpolar: ~A" (mus-scaler gen))))
    
    (let ((gen (make-two-zero :radius .1 :frequency 1200.0)))
      (if (not (two-zero? gen)) (snd-display #__line__ ";~A not 2zpolar?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";2zpolar order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) 1.0) (snd-display #__line__ ";2zpolar a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-a1 gen) -.188) (snd-display #__line__ ";2zpolar a1: ~F?" (mus-a1 gen)))
      (if (fneq (mus-a2 gen) .01) (snd-display #__line__ ";2zpolar a2: ~F?" (mus-a2 gen)))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";freq 2zpolar: ~A" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.1) (snd-display #__line__ ";scaler 2zpolar: ~A" (mus-scaler gen))))
    
    (let ((gen (make-two-zero 1200.0 .1)))
      (if (not (two-zero? gen)) (snd-display #__line__ ";~A not f2zpolar?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";f2zpolar order: ~D?" (mus-order gen)))
      (if (fneq (mus-a0 gen) 1.0) (snd-display #__line__ ";f2zpolar a0: ~F?" (mus-a0 gen)))
      (if (fneq (mus-a1 gen) -.188) (snd-display #__line__ ";f2zpolar a1: ~F?" (mus-a1 gen)))
      (if (fneq (mus-a2 gen) .01) (snd-display #__line__ ";f2zpolar a2: ~F?" (mus-a2 gen)))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";freq f2zpolar: ~A" (mus-frequency gen)))
      (if (fneq (mus-scaler gen) 0.1) (snd-display #__line__ ";scaler f2zpolar: ~A" (mus-scaler gen))))
    
    (test-gen-equal (let ((z1 (make-zpolar .1 600.0))) (two-zero z1 1.0) z1)
		    (let ((z2 (make-zpolar .1 600.0))) (two-zero z2 1.0) z2)
		    (let ((z3 (make-zpolar .1 1200.0))) (two-zero z3 1.0) z3))
    (test-gen-equal (let ((z1 (make-zpolar :radius .1 :frequency 600.0))) (two-zero z1 1.0) z1)
		    (let ((z2 (make-zpolar :radius .1 :frequency 600.0))) (two-zero z2 1.0) z2)
		    (let ((z3 (make-zpolar :radius .2 :frequency 1200.0))) (two-zero z3 1.0) z3))
    (test-gen-equal (let ((z1 (make-zpolar .1 600.0))) (two-zero z1 1.0) z1)
		    (let ((z2 (make-zpolar .1 600.0))) (two-zero z2 1.0) z2)
		    (let ((z3 (make-zpolar .1 600.0))) (two-zero z3 0.5) z3))
    
    (let ((gen (make-formant 1200.0 0.9))
	  (v0 (make-vct 10))
	  (gen1 (make-formant 1200.0 0.9))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "formant"
		       "formant frequency: 1200.000, radius: 0.900")
      (vct-set! v0 0 (formant gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (formant gen 0.0)))
      (vct-map! v1 (let ((inp 1.0))
		     (lambda () 
		       (let ((val (if (formant? gen1) (formant gen1 inp) -1.0)))
			 (set! inp 0.0)
			 val))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map formant: ~A ~A" v0 v1))
      (if (not (formant? gen)) (snd-display #__line__ ";~A not formant?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";formant order: ~D?" (mus-order gen)))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";formant frequency: ~F?" (mus-frequency gen)))
      (if (or (fneq (vct-ref v0 0) .095) (fneq (vct-ref v0 1) .161)) (snd-display #__line__ ";formant output: ~A" v0))
      (if (fneq (mus-scaler gen) 0.9) (snd-display #__line__ ";formant gain: ~F?" (mus-scaler gen)))
      
      (set! (mus-scaler gen) 2.0)
      (if (fneq (mus-scaler gen) 2.0) (snd-display #__line__ ";formant set gain: ~F?" (mus-scaler gen))))
    
    (test-gen-equal (let ((f1 (make-formant 1200.0 0.9))) (formant f1 1.0) f1)
		    (let ((f2 (make-formant 1200.0 0.9))) (formant f2 1.0) f2)
		    (let ((f3 (make-formant 600.0 0.9))) (formant f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-formant 1200.0 0.9))) (formant f1 1.0) f1)
		    (let ((f2 (make-formant 1200.0 0.9))) (formant f2 1.0) f2)
		    (let ((f3 (make-formant 1200.0 0.99))) (formant f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-formant 1200.0 0.9))) (formant f1 1.0) f1)
		    (let ((f2 (make-formant 1200.0 0.9))) (formant f2 1.0) f2)
		    (let ((f3 (make-formant 1200.0 0.5))) (formant f3 1.0) f3))
    
    (let ((frm (old-make-formant .1 440.0)))
      (mus-set-formant-radius-and-frequency frm 2.0 100.0)
      (if (fneq (mus-scaler frm) 2.0) (snd-display #__line__ ";set-formant-radius-etc: ~A" (mus-scaler frm)))
      (if (fneq (mus-frequency frm) 100.0) (snd-display #__line__ ";set-radius-etc (frq): ~A" (mus-frequency frm))))
    
    (let ((fs (make-vector 1))
	  (f0 (old-make-formant .1 1000.0))
	  (amps (make-vector 1 1.0))
	  (val 1.0)
	  (v0 (make-vct 10))
	  (v1 (make-vct 10)))
      (vector-set! fs 0 (old-make-formant .1 1000.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (formant f0 val))
	(vct-set! v1 i (old-formant-bank amps fs val))
	(set! val 0.0))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";formant bank: ~A ~A" v0 v1)))
    
    (let ((fs (make-vector 2))
	  (f0 (make-formant 1000.0 .1))
	  (f1 (make-formant 100.0 .2))
	  (amps (make-vector 2 1.0))
	  (val 1.0)
	  (v0 (make-vct 10))
	  (v1 (make-vct 10)))
      (vector-set! fs 0 (make-formant 1000.0 .1))
      (vector-set! fs 1 (make-formant 100.0 .2))
      (vector-set! amps 0 0.5)
      (vector-set! amps 1 0.25)
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (+ (* 0.5 (formant f0 val)) (* 0.25 (formant f1 val))))
	(vct-set! v1 i (old-formant-bank amps fs val))
	(set! val 0.0))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";formant bank 1: ~A ~A" v0 v1)))
    
    (let ((fs (make-vector 2))
	  (amps (make-vct 2 1.0))
	  (val 1.0)
	  (v (make-vct 5)))
      (vector-set! fs 0 (make-formant 1000.0 .1))
      (vector-set! fs 1 (make-formant 100.0 .2))
      (vct-set! amps 0 0.5)
      (vct-set! amps 1 0.25)
      (vct-map! v (lambda () (let ((res (formant-bank amps fs val))) (set! val 0.0) res)))
      (if (not (vequal v (vct 0.368 0.095 -0.346 -0.091 -0.020))) (snd-display #__line__ ";run formant-bank: ~A" v)))
    
    (let ((fs (make-vector 1))
	  (amps (make-vct 1 1.0)))
      (vector-set! fs 0 (make-oscil 440.0))
      (let ((tag (catch #t
			(lambda () (formant-bank amps fs 1.0))
			(lambda args (car args)))))
	(if (not (equal? tag 'wrong-type-arg)) (snd-display #__line__ ";formant-bank gets oscil: ~A" tag))))
    
    (let ((ob (open-sound "oboe.snd")))
      (define (poltergeist frek amp R gain frek-env R-env)
	;; test courtesy of Anders Vinjar
	(let ((filt (make-formant frek R))
	      (fe (make-env :envelope frek-env :length (frames) :offset frek))
	      (re (make-env :envelope R-env :length (frames) :offset R)))
	  (lambda (y)
	    (let ((outval (* gain (formant filt (* amp y)))))
	      (mus-set-formant-radius-and-frequency filt (env re) (env fe))
	      outval))))
      (map-chan (poltergeist 300 0.1 0.0 30.0 '(0 100 1 4000.0) '(0 0.99 1 .9)))  ;; should sound like "whyieee?"
      (play ob :wait #t)
      (close-sound ob))
    
    (let ((gen (make-firmant 1200.0 0.9))
	  (v0 (make-vct 10))
	  (gen1 (make-firmant 1200.0 0.9))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "firmant"
		       "firmant frequency: 1200.000, radius: 0.900")
      (vct-set! v0 0 (firmant gen 1.0))
      (do ((i 1 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (firmant gen 0.0)))
      (vct-map! v1 (let ((inp 1.0))
		     (lambda () 
		       (let ((val (if (firmant? gen1) (firmant gen1 inp) -1.0)))
			 (set! inp 0.0)
			 val))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map firmant: ~A ~A" v0 v1))
      (if (not (firmant? gen)) (snd-display #__line__ ";~A not firmant?" gen))
      (if (not (= (mus-order gen) 2)) (snd-display #__line__ ";firmant order: ~D?" (mus-order gen)))
      (if (fneq (mus-frequency gen) 1200.0) (snd-display #__line__ ";firmant frequency: ~F?" (mus-frequency gen)))
      (if (or (fneq (vct-ref v0 0) .058) (fneq (vct-ref v0 1) .099)) (snd-display #__line__ ";firmant output: ~A" v0))
      (if (fneq (mus-scaler gen) 0.9) (snd-display #__line__ ";firmant gain: ~F?" (mus-scaler gen)))
      
      (set! (mus-scaler gen) .20)
      (if (fneq (mus-scaler gen) .20) (snd-display #__line__ ";firmant set gain: ~F?" (mus-scaler gen))))
    
    (test-gen-equal (let ((f1 (make-firmant 1200.0 0.9))) (firmant f1 1.0) f1)
		    (let ((f2 (make-firmant 1200.0 0.9))) (firmant f2 1.0) f2)
		    (let ((f3 (make-firmant 600.0 0.9))) (firmant f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-firmant 1200.0 0.9))) (firmant f1 1.0) f1)
		    (let ((f2 (make-firmant 1200.0 0.9))) (firmant f2 1.0) f2)
		    (let ((f3 (make-firmant 1200.0 0.99))) (firmant f3 1.0) f3))
    (test-gen-equal (let ((f1 (make-firmant 1200.0 0.9))) (firmant f1 1.0) f1)
		    (let ((f2 (make-firmant 1200.0 0.9))) (firmant f2 1.0) f2)
		    (let ((f3 (make-firmant 1200.0 0.5))) (firmant f3 1.0) f3))
    
    
    (let ((gen (make-mixer 2 .5 .25 .125 1.0))
	  (fr0 (make-frame 2 1.0 1.0))
	  (fr1 (make-frame 2 0.0 0.0)))
      (print-and-check gen 
		       "mixer"
		       "mixer chans: 2, [
 0.500 0.250
 0.125 1.000
]")
      
      (let ((ap (mus-array-print-length))
	    (mx (make-mixer 8)))
	(set! (mus-array-print-length) 4)
	(do ((i 0 (+ 1 i)))
	    ((= i 8))
	  (do ((j 0 (+ 1 j)))
	      ((= j 8))
	    (mixer-set! mx i j (+ j (* i 8)))))
	(print-and-check mx
			 "mixer"
			 "mixer chans: 8, [
 0.000 1.000 2.000 3.000...
 8.000 9.000 10.000 11.000...
 16.000 17.000 18.000 19.000...
 24.000 25.000 26.000 27.000...
]")
	(set! (mus-array-print-length) 12)
	(print-and-check mx
			 "mixer"
			 "mixer chans: 8, [
 0.000 1.000 2.000 3.000 4.000 5.000 6.000 7.000
 8.000 9.000 10.000 11.000 12.000 13.000 14.000 15.000
 16.000 17.000 18.000 19.000 20.000 21.000 22.000 23.000
 24.000 25.000 26.000 27.000 28.000 29.000 30.000 31.000
 32.000 33.000 34.000 35.000 36.000 37.000 38.000 39.000
 40.000 41.000 42.000 43.000 44.000 45.000 46.000 47.000
 48.000 49.000 50.000 51.000 52.000 53.000 54.000 55.000
 56.000 57.000 58.000 59.000 60.000 61.000 62.000 63.000
]")
	(set! (mus-array-print-length) ap))
      (print-and-check fr0 
		       "frame"
		       "frame[2]: [1.000 1.000]")
      (if (not (frame? fr0)) (snd-display #__line__ ";~A not a frame?" fr0))
      (if (not (mixer? gen)) (snd-display #__line__ ";~A not a mixer?" gen))
      (if (equal? fr0 fr1) (snd-display #__line__ ";frame=? ~A ~A?" fr0 fr1))
      (if (not (= (mus-channels fr0) 2)) (snd-display #__line__ ";frame channels: ~D?" (mus-channels fr0)))
      (if (not (= (mus-length fr1) 2)) (snd-display #__line__ ";frame length: ~D?" (mus-length fr0)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";mixer channels: ~D?" (mus-channels gen)))
      (frame->frame fr0 gen fr1)
      (if (or (fneq (frame-ref fr0 0) 1.0)
	      (fneq (frame-ref fr1 1) 1.25)
	      (fneq (mixer-ref gen 0 0) .5))
	  (snd-display #__line__ ";fr0: ~A" fr0))
      (frame-set! fr1 0 1.0)
      (let ((fr3 (frame+ fr0 fr1))
	    (fr4 (frame* fr0 fr1))
	    (fr5 (sample->frame fr1 .5)))
	(if (or (fneq (frame-ref fr3 0) 2.0)
		(fneq (frame-ref fr4 0) 1.0))
	    (snd-display #__line__ ";fr+*: ~A ~A" fr3 fr4))
	(if (fneq (frame-ref fr5 0) .5) 
	    (snd-display #__line__ ";sample->frame: ~A?" (frame-ref fr5 0)))
	(sample->frame fr1 .5 fr5)
	(if (fneq (frame-ref fr5 0) .5) 
	    (snd-display #__line__ ";repeat sample->frame: ~A?" (frame-ref fr5 0))))
      (let ((fr3 (make-frame 2))
	    (fr4 (make-frame 4)))
	(frame-set! fr3 0 1.0)
	(set! (frame-ref fr4 0) 0.5)
	(frame-set! fr4 2 1.0)
	(if (not (feql (frame->list (frame+ fr3 fr4)) (list 1.5 0.0)))
	    (snd-display #__line__ ";frame+ unequal chans: ~A?" (frame+ fr3 fr4)))
	(mus-reset fr3)
	(if (fneq (frame-ref fr3 0) 0.0) (snd-display #__line__ ";reset frame: ~A" fr3)))
      (let ((fr3 (make-frame 2))
	    (fr4 (make-frame 4)))
	(frame-set! fr3 0 1.0)
	(frame-set! fr4 0 0.5)
	(frame-set! fr4 2 1.0)
	(if (not (feql (frame->list (frame* fr3 fr4)) (list 0.5 0.0)))
	    (snd-display #__line__ ";frame* unequal chans: ~A?" (frame* fr3 fr4))))
      (let* ((mx1 (make-mixer 2 1.0 0.0 0.0 1.0))
	     (mx2 (mixer* gen mx1))
	     (fr4 (make-frame 2 1.0 1.0))
	     (fr5 (make-frame 2 1.0 1.0))
	     (val (frame->sample mx1 fr1)))
	(if (fneq val 1.0) (snd-display #__line__ ";frame->sample: ~A?" val))
	(if (fneq (frame->sample fr5 fr4) 2.0) (snd-display #__line__ ";frame->sample ~A" (frame->sample fr5 fr4)))
	(if (not (equal? (frame->list fr1) (list 1.0 1.25))) (snd-display #__line__ ";frame->list: ~A?" (frame->list fr1)))
	(if (or (fneq (mixer-ref mx2 0 1) .25) (fneq (mixer-ref mx2 1 0) .125)) (snd-display #__line__ ";mixer*: ~A?" mx2))
	(if (not (equal? mx2 gen)) (snd-display #__line__ ";mixer=? ~A ~A?" gen mx2))
	(if (equal? mx2 mx1) (snd-display #__line__ ";mixer/=? ~A ~A?" mx1 mx2))
	;; mus-data doesn't apply from scheme level here
					;(if (not (vct? (mus-data fr4))) (snd-display #__line__ ";mus-data frame: ~A" (mus-data fr4)))
					;(if (not (vct? (mus-data mx1))) (snd-display #__line__ ";mus-data mixer: ~A" (mus-data mx1)))
	(mixer-set! mx2 0 0 2.0)
	(if (fneq (mixer-ref mx2 0 0) 2.0) (snd-display #__line__ ";mixer-set: ~A?" mx2))
	(set! fr0 (sample->frame mx2 1.0))
	(if (or (fneq (frame-ref fr0 0) 2.0) (fneq (frame-ref fr0 1) .25)) (snd-display #__line__ ";sample->frame: ~A?" fr0))
	(let ((tag (catch #t (lambda () (mixer* fr4 fr5)) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";mixer* of 2 frames: ~A" tag)))
	(let ((frout (make-frame 2)))
	  (sample->frame mx2 1.0 frout)
	  (if (not (equal? frout fr0)) (snd-display #__line__ ";sample->frame via frout: ~A ~A?" frout fr0)))))
    
    (let ((fr1 (make-frame 2 .1 .2)))
      (let ((val (frame+ fr1 1.0)))
	(if (or (fneq (frame-ref val 0) 1.1)
		(fneq (frame-ref val 1) 1.2))
	    (snd-display #__line__ ";8 frame-offset: ~A" val)))
      (let ((val (frame+ 1.0 fr1)))
	(if (or (fneq (frame-ref val 0) 1.1)
		(fneq (frame-ref val 1) 1.2))
	    (snd-display #__line__ ";8 frame-offset a: ~A" val)))
      (let ((val (frame* fr1 2.0)))
	(if (or (fneq (frame-ref val 0) 0.2)
		(fneq (frame-ref val 1) 0.4))
	    (snd-display #__line__ ";8 frame-scale: ~A" val)))
      (let ((val (frame* 2.0 fr1)))
	(if (or (fneq (frame-ref val 0) 0.2)
		(fneq (frame-ref val 1) 0.4))
	    (snd-display #__line__ ";8 frame-scale a: ~A" val)))
      (let ((val (frame-copy fr1)))
	(if (or (fneq (frame-ref val 0) 0.1)
		(fneq (frame-ref val 1) 0.2))
	    (snd-display #__line__ ";8 frame-copy a: ~A" val))))
    
    (let ((fr (make-frame! 3))
	  (fr1 (make-frame 3)))
      (if (not (equal? fr fr1)) (snd-display #__line__ ";make-frame!: ~A ~A" fr fr1)))
    (let ((fr (make-frame! 3 .1 .2 .3))
	  (fr1 (make-frame 3 .1 .2 .3)))
      (if (not (equal? fr fr1)) (snd-display #__line__ ";make-frame! (args): ~A ~A" fr fr1)))
    
    (let ((fr (frame .1 .2 .3)))
      (let ((fr1 (copy fr)))
	(if (not (equal? fr fr1)) (snd-display #__line__ ";copy frame: ~A ~A" fr fr1)))
      (fill! fr 0.0)
      (if (not (equal? fr (frame 0.0 0.0 0.0)))
	  (snd-display #__line__ ";fill! frame 0.0: ~A" fr)))
    
    
    (let* ((mx1 (make-mixer 2 1 2 3 4))
	   (mx2 (mixer* mx1 2.0)))
      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
	  (snd-display #__line__ ";8 mixer-scale 2: ~A" mx2))
      (set! mx2 (mixer* 2.0 mx1))
      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
	  (snd-display #__line__ ";8 mixer-scale 2a: ~A" mx2))
      (set! mx2 (mixer+ 2.0 mx1))
      (if (not (equal? mx2 (make-mixer 2 3 4 5 6)))
	  (snd-display #__line__ ";8 mixer-offset 2: ~A" mx2))
      (set! mx2 (mixer+ mx1 2.0))
      (if (not (equal? mx2 (make-mixer 2 3 4 5 6)))
	  (snd-display #__line__ ";8 mixer-offset 2a: ~A" mx2)))
    
    (let ((mx1 (make-scalar-mixer 2 2.0))
	  (mx2 (make-mixer 2 .1 .2 .3 .4)))
      (let ((nmx (mixer+ mx1 mx2)))
	(if (or (fneq (mixer-ref mx1 0 0) 2.0)
		(fneq (mixer-ref mx1 0 1) 0.0)
		(fneq (mixer-ref mx1 1 0) 0.0)
		(fneq (mixer-ref mx1 1 1) 2.0))
	    (snd-display #__line__ ";make-scalar-mixer 2: ~A" mx1))
	(if (or (fneq (mixer-ref mx2 0 0) .1)
		(fneq (mixer-ref mx2 0 1) .2)
		(fneq (mixer-ref mx2 1 0) .3)
		(fneq (mixer-ref mx2 1 1) .4))
	    (snd-display #__line__ ";make-mixer .1 .2 .3 .4: ~A" mx2))
	(if (or (fneq (mixer-ref nmx 0 0) 2.1)
		(fneq (mixer-ref nmx 0 1) 0.2)
		(fneq (mixer-ref nmx 1 0) 0.3)
		(fneq (mixer-ref nmx 1 1) 2.4))
	    (snd-display #__line__ ";mixer add ~A ~A: ~A" mx1 mx2 nmx))
	(set! mx1 (mixer-scale mx1 .5))
	(if (or (fneq (mixer-ref mx1 0 0) 1.0)
		(fneq (mixer-ref mx1 0 1) 0.0)
		(fneq (mixer-ref mx1 1 0) 0.0)
		(fneq (mixer-ref mx1 1 1) 1.0))
	    (snd-display #__line__ ";make-scale (identity): ~A" mx1)))
      (mus-reset mx1)
      (if (fneq (mixer-ref mx1 0 0) 0.0) (snd-display #__line__ ";reset mixer: ~A" mx1)))
    
    (let ((mx (mixer .1 .2 .3 .4)))
      (let ((mx1 (copy mx)))
	(if (not (equal? mx mx1)) (snd-display #__line__ ";mixer copy not equal? ~A ~A" mx mx1)))
      (fill! mx 0.1)
      (if (not (equal? mx (mixer .1 .1 .1 .1))) 
	  (snd-display #__line__ ";fill! mixer: ~A" mx)))
    
    (let ((var (catch #t (lambda () (make-mixer 2 0.0 0.0 0.0 0.0 0.0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-mixer extra args: ~A" var)))
    (let ((var (catch #t (lambda () (let ((fr1 (make-frame 2 1.0 0.0))) (frame->sample (make-oscil) fr1))) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";frame->sample bad arg: ~A" var)))
    (let* ((hi (make-mixer 1 1))
	   (tag (catch #t (lambda () (mixer-set! hi 1 1 1.0)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error)) (snd-display #__line__ ";mixer-set! 1 1 of 0: ~A (~A)" tag hi)))
    (let* ((hi (make-mixer 1 1))
	   (tag (catch #t (lambda () (set! (mixer-ref hi 1 1) 1.0)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error)) (snd-display #__line__ ";set! mixer-ref 1 1 of 0: ~A (~A)" tag hi)))
    (let* ((hi (make-mixer 1))
	   (tag (catch #t (lambda () (mixer-set! hi 1 0 1.0)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error)) (snd-display #__line__ ";mixer-set! 1 0 of 0: ~A (~A)" tag hi)))
    (let* ((hi (make-mixer 1))
	   (tag (catch #t (lambda () (mixer-set! hi 0 1 1.0)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error)) (snd-display #__line__ ";mixer-set! 0 1 of 0: ~A (~A)" tag hi)))
    (let* ((hi (make-frame 1))
	   (tag (catch #t (lambda () (frame-set! hi 1 1.0)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error)) (snd-display #__line__ ";frame-set! 1 of 0: ~A (~A)" tag hi)))
    (let* ((hi (make-frame 1))
	   (tag (catch #t (lambda () (set! (frame-ref hi 1) 1.0)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error)) (snd-display #__line__ ";set! frame-ref 1 of 0: ~A (~A)" tag hi)))
    (let* ((tag (catch #t (lambda () (make-frame 0)) (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range)) (snd-display #__line__ ";make-frame 0: ~A" tag)))
    (let* ((tag (catch #t (lambda () (make-mixer 0)) (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range)) (snd-display #__line__ ";make-mixer 0: ~A" tag)))
    
    (let ((fr1 (make-frame 1 1))
	  (fr2 (make-frame 2 1 2))
	  (fr4 (make-frame 4 1 2 3 4)) 
	  (fr8 (make-frame 8 1 2 3 4 5 6 7 8))
	  (mx1 (make-mixer 1 5))
	  (mx1id (make-mixer 1 1))
	  (mx2 (make-mixer 2 1 2 3 4))
	  (mx2id (make-mixer 2 1 0 0 1))
	  (mx4 (make-mixer 4))
	  (mx4id (make-mixer 4))
	  (mx8 (make-mixer 8))
	  (mx8id (make-mixer 8)))
      (do ((i 0 (+ 1 i)))
	  ((= i 4))
	(mixer-set! mx4id i i 1)
	(set! (mixer-ref mx4 0 i) 1))
      (do ((i 0 (+ 1 i)))
	  ((= i 8))
	(mixer-set! mx8id i i 1)
	(mixer-set! mx8 i 0 1))
      (if (not (equal? (frame->frame fr1 mx1id) (make-frame 1 1))) (snd-display #__line__ ";frame->frame 1 id: ~A?"            (frame->frame fr1 mx1id)))
      (if (not (equal? (frame->frame fr1 mx1) (make-frame 1 5))) (snd-display #__line__ ";frame->frame 1: ~A?"                 (frame->frame fr1 mx1)))  
      (if (not (equal? (frame->frame fr1 mx2id) (make-frame 2 1 0))) (snd-display #__line__ ";frame->frame 2 1 id: ~A?"        (frame->frame fr1 mx2id)))  
      (if (not (equal? (frame->frame fr1 mx2) (make-frame 2 1 2))) (snd-display #__line__ ";frame->frame 2 1: ~A?"             (frame->frame fr1 mx2)))  
      (if (not (equal? (frame->frame fr1 mx4) (make-frame 4 1 1 1 1))) (snd-display #__line__ ";frame->frame 4 1: ~A?"         (frame->frame fr1 mx4)))  
      (if (not (equal? (frame->frame fr1 mx8) (make-frame 8 1 0 0 0 0 0 0 0))) (snd-display #__line__ ";frame->frame 8 1: ~A?" (frame->frame fr1 mx8))) 
      (if (not (equal? (frame->frame fr2 mx1) (make-frame 1 5))) (snd-display #__line__ ";frame->frame 1 2: ~A?"               (frame->frame fr2 mx1)))   
      (if (not (equal? (frame->frame fr2 mx2id) (make-frame 2 1 2))) (snd-display #__line__ ";frame->frame 2id 2: ~A?"         (frame->frame fr2 mx2id)))  
      (if (not (equal? (frame->frame fr2 mx2) (make-frame 2 7 10))) (snd-display #__line__ ";frame->frame 2 2: ~A?"            (frame->frame fr2 mx2)))  
      (if (not (equal? (frame->frame fr2 mx4id) (make-frame 4 1 2 0 0))) (snd-display #__line__ ";frame->frame 4id 2: ~A?"     (frame->frame fr2 mx4id)))  
      (if (not (equal? (frame->frame fr2 mx8id) (make-frame 8 1 2 0 0 0 0 0 0))) (snd-display #__line__ ";frame->frame 8id 2: ~A?" (frame->frame fr2 mx8id)))  
      (if (not (equal? (frame->frame fr2 mx4) (make-frame 4 1 1 1 1))) (snd-display #__line__ ";frame->frame 4 2: ~A?"         (frame->frame fr2 mx4)))  
      (if (not (equal? (frame->frame fr2 mx8) (make-frame 8 3 0 0 0 0 0 0 0))) (snd-display #__line__ ";frame->frame 8 2: ~A?" (frame->frame fr2 mx8))) 
      (if (not (equal? (frame->frame fr4 mx1) (make-frame 1 5))) (snd-display #__line__ ";frame->frame 1 4: ~A?"               (frame->frame fr4 mx1))) 
      (if (not (equal? (frame->frame fr8 mx1) (make-frame 1 5))) (snd-display #__line__ ";frame->frame 1 8: ~A?"               (frame->frame fr8 mx1))) 
      (if (not (equal? (frame->frame fr2 mx8id) (make-frame 8 1 2 0 0 0 0 0 0))) (snd-display #__line__ ";frame->frame 8id 2: ~A?" (frame->frame fr2 mx8id)))
      (if (not (equal? (frame->frame fr2 mx4id) (make-frame 4 1 2 0 0))) (snd-display #__line__ ";frame->frame 4id 2: ~A?"     (frame->frame fr2 mx4id)))  
      (if (not (equal? (frame->frame fr4 mx8) (make-frame 8 10 0 0 0 0 0 0 0))) (snd-display #__line__ ";frame->frame 8 4: ~A?" (frame->frame fr4 mx8))) 
      (if (not (equal? (frame->frame fr4 mx4) (make-frame 4 1 1 1 1))) (snd-display #__line__ ";frame->frame 4 4: ~A?"         (frame->frame fr4 mx4))))
    
    (let ((fr1 (make-frame 2))
	  (fr2 (make-frame 2))
	  (mx1 (make-mixer 2))
	  (mx2 (make-mixer 2)))
      (frame-set! fr1 0 .1)
      (let ((fradd (frame+ fr1 fr1 fr2)))
	(if (not (equal? fr2 fradd)) (snd-display #__line__ ";frame+ with res frame: ~A ~A" fr2 fradd))
	(if (not (equal? fr2 (make-frame 2 0.2 0.0))) (snd-display #__line__ ";frame+ res: ~A" fr2))
	(set! fradd (frame* fr1 fr1 fr2))
	(if (not (equal? fr2 fradd)) (snd-display #__line__ ";frame* with res frame: ~A ~A" fr2 fradd))
	(if (or (fneq (frame-ref fr2 0) .01) (fneq (frame-ref fr2 1) 0.0)) (snd-display #__line__ ";frame* res: ~A" fr2)))
      (set! (mixer-ref mx1 0 0) .1)
      (let ((mxadd (mixer* mx1 mx1 mx2)))
	(if (not (equal? mx2 mxadd)) (snd-display #__line__ ";mixer* with res frame: ~A ~A" mx2 mxadd))
	(if (fneq (mixer-ref mx2 0 0) .01) (snd-display #__line__ ";mixer* res: ~A" mx2))))
    
    
    (let ((fr1 (frame .1 .2))
	  (fr2 (make-frame 2 .1 .2)))
      (if (not (equal? fr1 fr2))
	  (snd-display #__line__ ";frame...: ~A ~A" fr1 fr2)))
    
    (let ((fr1 (frame .1)))
      (if (fneq (fr1 0) .1) (snd-display #__line__ ";frame gen ref (.1): ~A" (fr1 0)))
      (set! (fr1 0) .2)
      (if (fneq (fr1 0) .2) (snd-display #__line__ ";frame gen ref (.2): ~A" (fr1 0)))
      (if (not (equal? fr1 (frame .2)))
	  (snd-display #__line__ ";frame gen set! (.2): ~A" fr1)))
    
    (let ((fr1 (frame .1 .2 .3 .4)))
      (set! (fr1 2) (+ (fr1 1) (fr1 2)))
      (if (fneq (fr1 2) .5) (snd-display #__line__ ";frame gen ref/set (.5): ~A" (fr1 2))))
    
    (let ((fr1 (frame)))
      (if (or (not (frame? fr1))
	      (not (equal? fr1 (make-frame 1 0.0))))
	  (snd-display #__line__ ";frame no args: ~A" fr1))
      (set! (fr1 0) .5)
      (if (fneq (fr1 0) .5) (snd-display #__line__ ";frame ref/set no args: ~A" (fr1 0))))
    
    (let ((fr1 (make-frame 2 .1)))
      (if (not (equal? fr1 (frame .1 0.0)))
	  (snd-display #__line__ ";make-frame missing arg: ~A" fr1)))
    
    
    (let ((mx (mixer .1 .2 .3 .4)))
      (if (fneq (mx 0 0) .1) (snd-display #__line__ ";mixer gen ref (.1): ~A" (mx 0 0)))
      (if (not (equal? mx (make-mixer 2 .1 .2 .3 .4))) (snd-display #__line__ ";mixer...: ~A" mx))
      (set! (mx 0 0) .5)
      (if (fneq (mx 0 0) .5) (snd-display #__line__ ";mixer gen set (.5): ~A" (mx 0 0)))
      (if (not (equal? mx (make-mixer 2 .5 .2 .3 .4))) (snd-display #__line__ ";mixer... (after set): ~A" mx))
      (if (fneq (mx 1 0) .3) (snd-display #__line__ ";mixer gen ref (.3): ~A" (mx 1 0)))
      (set! (mx 0 1) .5)
      (if (fneq (mx 0 1) .5) (snd-display #__line__ ";mixer (0 1) gen set (.5): ~A" (mx 0 1)))
      (if (not (equal? mx (make-mixer 2 .5 .5 .3 .4))) (snd-display #__line__ ";mixer... (after set 1): ~A" mx)))
    
    (let ((mx (mixer .1)))
      (if (not (equal? mx (make-mixer 1 .1))) (snd-display #__line__ ";mixer .1: ~A" mx))
      (if (fneq (mx 0 0) .1) (snd-display #__line__ ";mixer (1) gen ref (.1): ~A" (mx 0 0)))  
      (set! (mx 0 0) .5)
      (if (fneq (mx 0 0) .5) (snd-display #__line__ ";mixer (1) gen set (.5): ~A" (mx 0 0))))
    
    (let ((mx (mixer .1 .2 .3)))
      (if (not (equal? mx (make-mixer 2 .1 .2 .3 0.0))) (snd-display #__line__ ";mixer .1 .2 .3: ~A" mx))
      (set! (mx 1 1) .5)
      (if (fneq (mx 1 1) .5) (snd-display #__line__ ";mixer (1 1) gen set (.5): ~A" (mx 1 1))))
    
    (let ((mx (mixer)))
      (if (not (equal? mx (make-mixer 1 0.0))) (snd-display #__line__ ";(mixer): ~A" mx)))
    
    
    (for-each 
     (lambda (chans)
       (let ((m1 (make-mixer chans)))
	 (if (or (not (= (mus-channels m1) chans))
		 (not (= (mus-length m1) chans)))
	     (snd-display #__line__ ";mixer ~A chans but: ~A ~A" chans (mus-channels m1) (mus-length m1)))
	 (do ((i 0 (+ 1 i)))
	     ((= i chans))
	   (do ((j 0 (+ 1 j)))
	       ((= j chans))
	     (mixer-set! m1 i j (+ (* i .01) (* j .1)))))
	 (do ((i 0 (+ 1 i)))
	     ((= i chans))
	   (do ((j 0 (+ 1 j)))
	       ((= j chans))
	     (if (fneq (mixer-ref m1 i j) (+ (* i .01) (* j .1)))
		 (snd-display #__line__ ";mixer[~A ~A] = ~A (~A)?" i j (mixer-ref m1 i j) (+ (* i .01) (* j .1))))))
	 (let ((mempty (make-mixer chans))
	       (midentity (make-mixer chans))
	       (mpick (make-mixer chans)))
	   (do ((i 0 (+ 1 i)))
	       ((= i chans))
	     (mixer-set! midentity i i 1.0))
	   (mixer-set! mpick (- chans 1) (- chans 1) 1.0)
	   (let ((mzero (mixer* m1 mempty))
		 (msame (mixer* m1 midentity))
		 (mone (mixer* m1 mpick)))
	     (do ((i 0 (+ 1 i)))
		 ((= i chans))
	       (do ((j 0 (+ 1 j)))
		   ((= j chans))
		 (if (fneq (mixer-ref mzero i j) 0.0) (snd-display #__line__ ";mzero ~A ~A = ~A?" i j (mixer-ref mzero i j)))
		 (if (fneq (mixer-ref m1 i j) (mixer-ref msame i j)) (snd-display #__line__ ";msame ~A ~A?" (mixer-ref msame i j) (mixer-ref m1 i j)))
		 (if (and (fneq (mixer-ref mone i j) 0.0)
			  (not (= i (- chans 1)))
			  (not (= j (- chans 1))))
		     (snd-display #__line__ ";mone ~A ~A = ~A?" i j (mixer-ref mone i j)))))))))
     (list 1 2 4 8))
    
    (let ((mx (make-mixer 4 4)))
      (let ((tag (catch #t (lambda () (set! (mus-length mx) 2)) (lambda args (car args)))))
	(if (not (eq? tag 'mus-error)) (snd-display #__line__ ";set mixer-length: ~A ~A" tag (mus-length mx)))))
    
    (letrec ((mixer-equal? (lambda (m1 m2) 
			     ;; this is less demanding than the built-in function
			     (let ((len (mus-length m1))
				   (happy #t))
			       (and (= len (mus-length m2))
				    (do ((i 0 (+ 1 i)))
					((or (not happy) (= i len)) 
					 happy)
				      (do ((j 0 (+ 1 j)))
					  ((or (not happy) (= j len)))
					(if (> (abs (- (mat m1 i j) (mat m2 i j))) .001)
					    (set! happy #f))))))))
	     (mixer-normal? (lambda (mx)
			      (mixer-equal? (mixer* mx (mixer-transpose mx)) ; conjugate transpose (hermitian) if complex
					    (mixer* (mixer-transpose mx) mx))))
	     (mixer-orthogonal? (lambda (mx)
				  (mixer-equal? (mixer-transpose mx) 
						(mixer-inverse mx))))
	     (mixer-unitary? (lambda (mx) (mixer-orthogonal? mx))) ; reals
	     (mixer-symmetric? (lambda (m1) (mixer-equal? m1 (mixer-transpose m1))))
	     (mixer-hermitian? (lambda (mx) (mixer-symmetric? mx))) ; assuming reals	   
	     (frame-equal? (lambda (f1 f2)
			     (let ((len (mus-length f1))
				   (happy #t))
			       (and (= len (mus-length f2))
				    (do ((i 0 (+ 1 i)))
					((or (not happy) (= i len))
					 happy)
				      (if (> (abs (- (frame-ref f1 i) (frame-ref f2 i))) .001)
					  (set! happy #f)))))))
	     (slow-mixer-inverse (lambda (mx)
				   (let ((n (mus-length mx))
					 (det (mixer-determinant mx)))
				     (if (not (= det 0.0))
					 (let ((nmx (make-zero-mixer n)))
					   (do ((i 0 (+ 1 i)))
					       ((= i n))
					     (do ((j 0 (+ 1 j)))
						 ((= j n))
					       (mixer-set! nmx j i (* (if (odd? (+ i j)) -1 1) 
								      (/ (mixer-determinant (sub-matrix mx i j)) 
									 det)))))
					   nmx)
					 #f))))
	     (slow-mixer-solve (lambda (A b) ; Ax=b where A is mixer and b is frame, returns frame
				 (if (= (mus-length A) 1)
				     (if (not (= (mixer-ref A 0 0) 0.0))
					 (make-frame 1 (/ (frame-ref b 0) (mixer-ref A 0 0)))
					 #f)
				     (let ((imx (slow-mixer-inverse A)))
				       (if (mixer? imx) ; else determinant = 0
					   (frame->frame imx b)
					   #f)))))
	     (make-random-frame (lambda (size)
				  (let ((fr (make-frame size)))
				    (do ((i 0 (+ 1 i)))
					((= i size))
				      (frame-set! fr i (- 1.0 (random 2.0))))
				    fr)))
	     (make-random-mixer (lambda (size)
				  (let ((mx (make-mixer size)))
				    (do ((i 0 (+ 1 i)))
					((= i size))
				      (do ((j 0 (+ 1 j)))
					  ((= j size))
					(mixer-set! mx i j (- 1.0 (random 2.0)))))
				    mx)))
	     )
      (if (fneq (mixer-determinant (make-mixer 2 1 2 3 4)) -2.0)
	  (snd-display #__line__ ";mixer-determinant -2: ~A" (mixer-determinant (make-mixer 2 1 2 3 4))))
      (if (fneq (mixer-determinant (make-mixer 3 1 2 3 4 5 6 7 8 9)) 0.0)
	  (snd-display #__line__ ";mixer-determinant 0: ~A" (mixer-determinant (make-mixer 3 1 2 3 4 5 6 7 8 9))))
      (if (fneq (mixer-determinant (make-mixer 4 1 2 3 4 8 7 6 5 1 8 2 7 3 6 4 5)) -144.0) ; Eves Elementary Matrix Theory
	  (snd-display #__line__ ";mixer-determinant -144: ~A" (mixer-determinant (make-mixer 4 1 2 3 4 8 7 6 5 1 8 2 7 3 6 4 5))))
      (if (fneq (mixer-determinant (make-mixer 5  2 3 5 7 11  13 17 19 23 29  31 37 41 43 47  53 59 61 67 71  73 79 83 89 97)) -4656.0)
	  (snd-display #__line__ ";mixer-determinant -4656: ~A" (mixer-determinant (make-mixer 5  2 3 5 7 11  13 17 19 23 29  31 37 41 43 47  
											       53 59 61 67 71  73 79 83 89 97))))
      (if (fneq (mixer-determinant (make-mixer 6  2 3 5 7 11 13   17 19 23 29 31 37  41 43 47 53 59 61  67 71 73 79 83 89  
					       97 101 103 107 109 113  127 131 137 139 149 151)) -14304.0)
	  (snd-display #__line__ ";mixer-determinant -14304: ~A" 
		       (mixer-determinant (make-mixer 6  2 3 5 7 11 13   17 19 23 29 31 37  41 43 47 53 59 61  67 71 73 79 83 89  
						      97 101 103 107 109 113  127 131 137 139 149 151))))
      (if (not (mixer-equal? (mixer-transpose (make-mixer 2 1 2 3 4)) 
			     (make-mixer 2 1.000 3.000 2.000 4.000)))
	  (snd-display #__line__ ";mixer-transpose 1: ~A" (mixer-transpose (make-mixer 2 1 2 3 4))))
      (if (not (mixer-equal? (mixer-transpose (make-mixer 3 1 2 3 4 5 6 7 8 9)) 
			     (make-mixer 3 1.000 4.000 7.000 2.000 5.000 8.000 3.000 6.000 9.000)))
	  (snd-display #__line__ ";mixer-transpose 2: ~A" (mixer-transpose (make-mixer 3 1 2 3 4 5 6 7 8 9))))
      (if (not (mixer-equal? (mixer* (make-mixer 2 1 0 0 1) (make-mixer 2 2 0 0 2)) 
			     (make-mixer 2 2.000 0.000 0.000 2.000)))
	  (snd-display #__line__ ";mixer* 1: ~A" (mixer* (make-mixer 2 1 0 0 1) (make-mixer 2 2 0 0 2))))
      (if (not (mixer-equal? (mixer* (make-mixer 3 2 3 5 7 11 13 19 23 29) (make-mixer 3 41 43 47 53 59 61 67 71 73))
			     (make-mixer 3 576.000 618.000 642.000 1741.000 1873.000 1949.000 3941.000 4233.000 4413.000)))
	  (snd-display #__line__ ";mixer* 2: ~A" (mixer* (make-mixer 3 2 3 5 7 11 13 19 23 29) (make-mixer 3 41 43 47 53 59 61 67 71 73))))
      (if (not (mixer-equal? (slow-mixer-inverse (make-mixer 2 1 0 0 1)) 
			     (make-mixer 2 1.000 0.000 0.000 1.000)))
	  (snd-display #__line__ ";slow-mixer-inverse 1: ~A" (slow-mixer-inverse (make-mixer 2 1 0 0 1))))
      (if (not (mixer-equal? (slow-mixer-inverse (make-mixer 2 2 3 5 8))
			     (make-mixer 2 8.000 -3.000 -5.000 2.000)))
	  (snd-display #__line__ ";slow-mixer-inverse 2: ~A" (slow-mixer-inverse (make-mixer 2 2 3 5 8))))
      (if (not (mixer-equal? (slow-mixer-inverse (make-mixer 3  2 3 5  7 11 13  17 19 23))
			     (make-mixer 3 -0.077 -0.333 0.205 -0.769 0.500 -0.115 0.692 -0.167 -0.013)))
	  (snd-display #__line__ ";slow-mixer-inverse 3: ~A" (slow-mixer-inverse (make-mixer 3 2 3 5 7 11 13 17 19 23))))
      (if (not (mixer-equal? (slow-mixer-inverse (make-mixer 4 2 3 5 7  17 19 23 29 41 43 47 53 67 71 73 97))
			     (make-mixer 4 -7.000 4.708 -1.042 -0.333 9.000 -6.396 1.396 0.500 
					 -1.000 0.875 -0.042 -0.167 -1.000 0.771 -0.271 0.000)))
	  (snd-display #__line__ ";slow-mixer-inverse 4: ~A" (slow-mixer-inverse (make-mixer 4 2 3 5 7  17 19 23 29 41 43 47 53 67 71 73 97))))
      (if (not (mixer-equal? (slow-mixer-inverse (make-mixer 6  2 3 5 7 11 13   17 -19 23 29 31 37  41 43 47 53 59 61  
							     67 71 73 79 83 89  97 101 103 107 109 113  127 131 137 139 149 151))
			     (make-mixer 6 -1.355 0.020 -0.000 1.090 -1.153 0.333 0.092 -0.025 0.000 -0.042 0.070 -0.029 
					 1.612 0.006 -0.250 -1.205 1.249 -0.264 0.079 0.002 0.250 -0.314 0.425 -0.241 
					 -0.551 -0.011 0.250 0.200 -0.476 0.188 0.068 0.009 -0.250 0.306 -0.145 0.028)))
	  (snd-display #__line__ ";slow-mixer-inverse 5: ~A" (slow-mixer-inverse (make-mixer 6  2 3 5 7 11 13   17 -19 23 29 31 37  41 43 47 53 59 61  
											     67 71 73 79 83 89  97 101 103 107 109 113  127 131 137 139 149 151))))
      (if (not (mixer-equal? (mixer* (make-mixer 2 2 3 5 8) (slow-mixer-inverse (make-mixer 2 2 3 5 8)))
			     (make-scalar-mixer 2 1.0)))
	  (snd-display #__line__ ";slow-mixer-inverse 6: ~A" (mixer* (make-mixer 2 2 3 5 8) (slow-mixer-inverse (make-mixer 2 2 3 5 8)))))
      (if (not (mixer-equal? (mixer* (make-mixer 3 2 3 5 7 11 13 17 19 23) (slow-mixer-inverse (make-mixer 3 2 3 5 7 11 13 17 19 23)))
			     (make-scalar-mixer 3 1.0)))
	  (snd-display #__line__ ";slow-mixer-inverse 7: ~A" 
		       (mixer* (make-mixer 3 2 3 5 7 11 13 17 19 23) (slow-mixer-inverse (make-mixer 3 2 3 5 7 11 13 17 19 23)))))
      
      (if (not (mixer-equal? (mixer-inverse (make-mixer 2 1 0 0 1)) 
			     (make-mixer 2 1.000 0.000 0.000 1.000)))
	  (snd-display #__line__ ";mixer-inverse 1: ~A" (mixer-inverse (make-mixer 2 1 0 0 1))))
      (if (not (mixer-equal? (mixer-inverse (make-mixer 2 2 3 5 8))
			     (make-mixer 2 8.000 -3.000 -5.000 2.000)))
	  (snd-display #__line__ ";mixer-inverse 2: ~A" (mixer-inverse (make-mixer 2 2 3 5 8))))
      (if (not (mixer-equal? (mixer-inverse (make-mixer 3  2 3 5  7 11 13  17 19 23))
			     (make-mixer 3 -0.077 -0.333 0.205 -0.769 0.500 -0.115 0.692 -0.167 -0.013)))
	  (snd-display #__line__ ";mixer-inverse 3: ~A" (mixer-inverse (make-mixer 3 2 3 5 7 11 13 17 19 23))))
      (if (not (mixer-equal? (mixer-inverse (make-mixer 4 2 3 5 7  17 19 23 29 41 43 47 53 67 71 73 97))
			     (make-mixer 4 -7.000 4.708 -1.042 -0.333 9.000 -6.396 1.396 0.500 
					 -1.000 0.875 -0.042 -0.167 -1.000 0.771 -0.271 0.000)))
	  (snd-display #__line__ ";mixer-inverse 4: ~A" (mixer-inverse (make-mixer 4 2 3 5 7  17 19 23 29 41 43 47 53 67 71 73 97))))
      (if (not (mixer-equal? (mixer-inverse (make-mixer 6  2 3 5 7 11 13   17 -19 23 29 31 37  41 43 47 53 59 61  
							67 71 73 79 83 89  97 101 103 107 109 113  127 131 137 139 149 151))
			     (make-mixer 6 -1.355 0.020 -0.000 1.090 -1.153 0.333 0.092 -0.025 0.000 -0.042 0.070 -0.029 
					 1.612 0.006 -0.250 -1.205 1.249 -0.264 0.079 0.002 0.250 -0.314 0.425 -0.241 
					 -0.551 -0.011 0.250 0.200 -0.476 0.188 0.068 0.009 -0.250 0.306 -0.145 0.028)))
	  (snd-display #__line__ ";mixer-inverse 5: ~A" (mixer-inverse (make-mixer 6  2 3 5 7 11 13   17 -19 23 29 31 37  41 43 47 53 59 61  
										   67 71 73 79 83 89  97 101 103 107 109 113  127 131 137 139 149 151))))
      (if (not (mixer-equal? (mixer* (make-mixer 2 2 3 5 8) (mixer-inverse (make-mixer 2 2 3 5 8)))
			     (make-scalar-mixer 2 1.0)))
	  (snd-display #__line__ ";mixer-inverse 6: ~A" (mixer* (make-mixer 2 2 3 5 8) (mixer-inverse (make-mixer 2 2 3 5 8)))))
      (if (not (mixer-equal? (mixer* (make-mixer 3 2 3 5 7 11 13 17 19 23) (mixer-inverse (make-mixer 3 2 3 5 7 11 13 17 19 23)))
			     (make-scalar-mixer 3 1.0)))
	  (snd-display #__line__ ";mixer-inverse 7: ~A" 
		       (mixer* (make-mixer 3 2 3 5 7 11 13 17 19 23) (mixer-inverse (make-mixer 3 2 3 5 7 11 13 17 19 23)))))
      (if (invert-matrix (make-mixer 3 1 2 3 4 5 6 7 8 9))
	  (snd-display #__line__ ";invert-matrix missed singular case? ~A" (invert-matrix (make-mixer 3 1 2 3 4 5 6 7 8 9))))
      (if (fneq (mixer-trace (make-mixer 3 1 0 0 0 2 0 0 0 3)) 6.0)
	  (snd-display #__line__ ";mixer-trace (6): ~A" (mixer-trace (make-mixer 3 1 0 0 0 2 0 0 0 3))))
      
      (if (not (mixer-diagonal? (make-scalar-mixer 2 2.0))) (snd-display #__line__ ";mixer-diagonal 1"))
      (if (not (mixer-diagonal? (make-mixer 3 1 0 0 0 1 0 0 0 1))) (snd-display #__line__ ";mixer-diagonal 2"))
      (if (mixer-diagonal? (make-mixer 3 1 0 0 0 1 1 0 0 1)) (snd-display #__line__ ";mixer-diagonal 3"))
      (if (not (mixer-diagonal? (make-mixer 3 0 0 0 0 1 0 0 0 1))) (snd-display #__line__ ";mixer-diagonal 4"))
      (if (not (mixer-symmetric? (make-mixer 3 0 0 0 0 1 0 0 0 1))) (snd-display #__line__ ";mixer-symmetric 1"))
      (if (not (mixer-symmetric? (make-mixer 3 1 2 0 2 1 0 0 0 1))) (snd-display #__line__ ";mixer-symmetric 2"))
      (if (mixer-symmetric? (make-mixer 3 1 2 0 2 1 0 0 2 1)) (snd-display #__line__ ";mixer-symmetric 3"))
      (if (not (mixer-equal? (make-scalar-mixer 2 2.0) (make-mixer 2 2.0 0 0 2.0))) (snd-display #__line__ ";mixer-equal 1"))
      (if (mixer-equal? (make-mixer 2 1 2 3 4) (make-mixer 3 1 2 3 4 5 6 7 8 9)) (snd-display #__line__ ";mixer-equal 2"))
      (if (mixer-equal? (make-mixer 2 1 2 3 4) (make-mixer 2 1 2 3 5)) (snd-display #__line__ ";mixer-equal 3"))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 0 0 1) 1.0 1.0) (make-mixer 2 2.0 0.0 0.0 2.0)))
	  (snd-display #__line__ ";mixer-poly 1: ~A" (mixer-poly (make-mixer 2 1 0 0 1) 1.0 1.0)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 1 1) 1) (make-mixer 1 1.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 1 1) 1)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 0 0 1) 1 0 0) (make-mixer 2 1.0 0.0 0.0 1.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 0 0 1) 1 0 0)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 2 4 3) 1 0 0) (make-mixer 2 9.0 8.0 16.0 17.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 2 4 3) 1 0 0)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 2 4 3) 1 1 0) (make-mixer 2 10.0 10.0 20.0 20.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 2 4 3) 1 1 0)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 2 4 3) 1 1 2) (make-mixer 2 12.0 10.0 20.0 22.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 2 4 3) 1 1 2)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 2 4 3) 1 0 0 0) (make-mixer 2 41.0 42.0 84.0 83.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 2 4 3) 1 0 0 0)))
      (if (not (mixer-equal? (mixer-poly (make-mixer 2 1 2 4 3) 1 0 1 0) (make-mixer 2 42.0 44.0 88.0 86.0)))
	  (snd-display #__line__ ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 2 4 3) 1 0 1 0)))
      
      (let ((fr (slow-mixer-solve (make-mixer 2 1 0 0 2) (make-frame 2 2 3))))
	(if (not (frame-equal? fr (make-frame 2 2.000 1.500))) (snd-display #__line__ ";slow-mixer-solve 1: ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 2 1 1 0 1) (make-frame 2 2 3))))
	(if (not (frame-equal? fr (make-frame 2 -1.000 3.000))) (snd-display #__line__ ";slow-mixer-solve 2: ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 3 2 1 3 1 -1 0 1 1 2) (make-frame 3 1 1 1))))
	(if fr (snd-display #__line__ ";slow-mixer-solve 3 (#f): ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 3 2 1 3 1 -1 0 1 1 2) (make-frame 3 1 1 .333))))
	(if fr (snd-display #__line__ ";slow-mixer-solve 4 (#f): ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 3 2 1 3 1 -1 1 1 1 2) (make-frame 3 1 1 1))))
	(if (not (frame-equal? fr (make-frame 3 -2.000 -1.000 2.000))) (snd-display #__line__ ";slow-mixer-solve 5: ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 3 1 -1 -1 3 -3 2 2 -1 1) (make-frame 3 2 16 9))))
	(if (not (frame-equal? fr (make-frame 3 3.000 -1.000 2.000))) (snd-display #__line__ ";slow-mixer-solve 6: ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 3 1 1 1 2 3 1 1 -1 -2) (make-frame 3 3 5 -5))))
	(if (not (frame-equal? fr (make-frame 3 0.000 1.000 2.000))) (snd-display #__line__ ";slow-mixer-solve 7: ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 1 .5) (make-frame 1 2))))
	(if (not (frame-equal? fr (make-frame 1 4.000))) (snd-display #__line__ ";slow-mixer-solve 8: ~A" fr)))
      (let ((fr (slow-mixer-solve (make-mixer 4 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5) (make-frame 4 1 1 1 1))))
	(if (not (frame-equal? fr (make-frame 4 0.500 0.333 0.250 0.200))) (snd-display #__line__ ";slow-mixer-solve 9: ~A" fr)))
      
      (let ((fr (mixer-solve (make-mixer 2 1 0 0 2) (make-frame 2 2 3))))
	(if (not (frame-equal? fr (make-frame 2 2.000 1.500))) (snd-display #__line__ ";mixer-solve 1: ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 2 1 1 0 1) (make-frame 2 2 3))))
	(if (not (frame-equal? fr (make-frame 2 -1.000 3.000))) (snd-display #__line__ ";mixer-solve 2: ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 3 2 1 3 1 -1 0 1 1 2) (make-frame 3 1 1 1))))
	(if fr (snd-display #__line__ ";mixer-solve 3 (#f): ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 3 2 1 3 1 -1 0 1 1 2) (make-frame 3 1 1 .333))))
	(if fr (snd-display #__line__ ";mixer-solve 4 (#f): ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 3 2 1 3 1 -1 1 1 1 2) (make-frame 3 1 1 1))))
	(if (not (frame-equal? fr (make-frame 3 -2.000 -1.000 2.000))) (snd-display #__line__ ";mixer-solve 5: ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 3 1 -1 -1 3 -3 2 2 -1 1) (make-frame 3 2 16 9))))
	(if (not (frame-equal? fr (make-frame 3 3.000 -1.000 2.000))) (snd-display #__line__ ";mixer-solve 6: ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 3 1 1 1 2 3 1 1 -1 -2) (make-frame 3 3 5 -5))))
	(if (not (frame-equal? fr (make-frame 3 0.000 1.000 2.000))) (snd-display #__line__ ";mixer-solve 7: ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 1 .5) (make-frame 1 2))))
	(if (not (frame-equal? fr (make-frame 1 4.000))) (snd-display #__line__ ";mixer-solve 8: ~A" fr)))
      (let ((fr (mixer-solve (make-mixer 4 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5) (make-frame 4 1 1 1 1))))
	(if (not (frame-equal? fr (make-frame 4 0.500 0.333 0.250 0.200))) (snd-display #__line__ ";mixer-solve 9: ~A" fr)))
      
      ;; try random input to mixer-inverse
      (do ((k 2 (+ 1 k)))
	  ((= k 20))
	(let* ((mx (make-random-mixer k))
	       (imx (mixer-inverse (mixer-copy mx)))
	       (mmx (mixer* mx imx)))
	  (if (not (mixer-equal? mmx (make-scalar-mixer k 1.0)))
	      (snd-display #__line__ ";mixer-inverse r~D: ~A * ~A -> ~A" k mx imx mmx))))
      
      (let ((fr (frame-reverse! (make-frame 2 .5 2.0))))
	(if (not (frame-equal? fr (make-frame 2 2.0 0.5)))
	    (snd-display #__line__ ";frame-reverse! 2: ~A" fr)))
      (let ((fr (frame-reverse! (make-frame 3 .5 1.0 2.0))))
	(if (not (frame-equal? fr (make-frame 3 2.0 1.0 0.5)))
	    (snd-display #__line__ ";frame-reverse! 3: ~A" fr)))
      
      (let ((hi (make-mixer 3 10 5 1 1 20 5 1 3 7))
	    (ho (make-mixer 3 10 5 2 1 3 2 1 3 2)))
	;; these adapted from gsl linalg tests
	(let ((val (mixer* hi ho)))
	  (if (not (mixer-equal? val (make-mixer 3 106.000 68.000 32.000  35.000 80.000 52.000  20.000 35.000 22.000)))
	      (snd-display #__line__ ";mixer* 3x3 1: ~A" val)))
	
	(let ((val (mixer* hi (mixer-transpose ho))))
	  (if (not (mixer-equal? val (make-mixer 3  127.000 27.000 27.000  120.000 71.000 71.000  39.000 24.000 24.000)))
	      (snd-display #__line__ ";mixer* 3x3 2: ~A" val)))
	
	(let ((val (mixer* (mixer-transpose hi) (mixer-transpose ho))))
	  (if (not (mixer-equal? val (make-mixer 3 107.000 15.000 15.000  156.000 71.000 71.000  49.000 30.000 30.000)))
	      (snd-display #__line__ ";mixer* 3x3 2: ~A" val))))
      
      ;; from Golub and van Loan:
      (let ((val (mixer-solve (make-mixer 2 .001 1.0 1.0 2.0) (make-frame 2 1.0 3.0))))
	(if (not (frame-equal? val (make-frame 2 1.002 0.999)))
	    (snd-display #__line__ ";mixer-solve G1: ~A" val)))
      (let ((val (mixer-solve (make-mixer 2 .0001 1.0 1.0 1.0) (make-frame 2 1.0 3.0))))
	(if (not (frame-equal? val (make-frame 2 2.000 1.000)))
	    (snd-display #__line__ ";mixer-solve G2: ~A" val)))
      (let ((val (mixer-solve (make-mixer 2 .986 .579 .409 .237) (make-frame 2 .235 .107))))
	(if (not (frame-equal? val (make-frame 2 2.000 -3.000)))
	    (snd-display #__line__ ";mixer-solve G3: ~A" val)))
      (let ((val (invert-matrix (make-mixer 3 2 -1 1  -1 1.0e-6 1.0e-6  1 1.0e-6 1.0e-6) (make-frame 3 (* 2 (+ 1 1.0e-6)) -1.0e-6 1.0e-6))))
	(if (or (not val)
		(not (frame-equal? (cadr val) (make-frame 3 0.000 -1.000 1.000))))
	    (snd-display #__line__ ";mixer-solve G4: ~A" val)))
      (let ((val (invert-matrix (make-mixer 3 2 -1 1  -1 1.0e-7 1.0e-7  1 1.0e-7 1.0e-7) (make-frame 3 (* 2 (+ 1 1.0e-7)) -1.0e-7 1.0e-7))))
	(if (or (not val)
		(not (frame-equal? (cadr val) (make-frame 3 0.000 -1.000 1.000))))
	    (snd-display #__line__ ";mixer-solve G5: ~A" val)))
      (let ((val (mixer-solve (make-mixer 3 1 4 7 2 5 8 3 6 10) (make-frame 3 1 1 1))))
	(if (not (frame-equal? val (make-frame 3 -0.333 0.333 -0.000)))
	    (snd-display #__line__ ";mixer-solve G6: ~A" val)))
      (let ((val (mixer-solve (make-mixer 2 1 0 0 1.0e-6) (make-frame 2 1 1.0e-6))))
	(if (not (frame-equal? val (make-frame 2 1.000 1.000)))
	    (snd-display #__line__ ";mixer-solve G7: ~A" val)))
      (let ((val (invert-matrix (make-mixer 2 1 0 0 1.0e-8) (make-frame 2 1 1.0e-8) 1.0e-10)))
	(if (or (not val)
		(not (frame-equal? (cadr val) (make-frame 2 1.000 1.000))))
	    (snd-display #__line__ ";mixer-solve G8: ~A" val)))
      (let ((val (invert-matrix (make-mixer 2 1 0 0 1.0e-12) (make-frame 2 1 1.0e-12) 1.0e-14)))
	(if (or (not val) 
		(not (frame-equal? (cadr val) (make-frame 2 1.000 1.000))))
	    (snd-display #__line__ ";mixer-solve G9: ~A" val)))
      (let ((val (mixer-solve (make-mixer 2 10 100000 1 1) (make-frame 2 100000 2))))
	(if (not (frame-equal? val (make-frame 2 1.000 1.000)))
	    (snd-display #__line__ ";mixer-solve G10: ~A" val)))
      
      (let ((val (frame-cross (make-frame 3 0 0 1) (make-frame 3 0 -1 0))))
	(if (not (frame-equal? val (make-frame 3 1.000 0.000 0.000)))
	    (snd-display #__line__ ";frame-cross: ~A" val)))
      
      (let ((val (frame-normalize (make-frame 3 4 3 0))))
	(if (not (frame-equal? val (make-frame 3 0.800 0.600 0.000)))
	    (snd-display #__line__ ";frame-normalize: ~A" val)))
      )
    
    (let ((gen (make-fft-window hamming-window 16)))
      (if (not (vequal gen (vct 0.080 0.115 0.215 0.364 0.540 0.716 0.865 1.000 1.000 0.865 0.716 0.540 0.364 0.215 0.115 0.080)))
	  (snd-display #__line__ ";hamming window: ~A" gen)))
    (let ((gen (make-fft-window rectangular-window 16)))
      (if (not (vequal gen (vct 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
	  (snd-display #__line__ ";rectangular window: ~A" gen)))
    (let ((gen (make-fft-window hann-window 16)))
      (if (not (vequal gen (vct 0.000 0.038 0.146 0.309 0.500 0.691 0.854 1.000 1.000 0.854 0.691 0.500 0.309 0.146 0.038 0.000)))
	  (snd-display #__line__ ";hann window: ~A" gen)))
    (let ((gen (make-fft-window welch-window 16)))
      (if (not (vequal gen (vct 0.000 0.234 0.438 0.609 0.750 0.859 0.938 1.000 1.000 0.938 0.859 0.750 0.609 0.438 0.234 0.000)))
	  (snd-display #__line__ ";welch window: ~A" gen)))
    (let ((gen (make-fft-window connes-window 16)))
      (if (not (vequal gen (vct 0.000 0.055 0.191 0.371 0.562 0.739 0.879 1.000 1.000 0.879 0.739 0.562 0.371 0.191 0.055 0.000)))
	  (snd-display #__line__ ";connes window: ~A" gen)))
    (let ((gen (make-fft-window parzen-window 16)))
      (if (not (vequal gen (vct 0.000 0.125 0.250 0.375 0.500 0.625 0.750 1.000 1.000 0.750 0.625 0.500 0.375 0.250 0.125 0.000)))
	  (snd-display #__line__ ";parzen window: ~A" gen)))
    (let ((gen (make-fft-window bartlett-window 16)))
      (if (not (vequal gen (vct 0.000 0.125 0.250 0.375 0.500 0.625 0.750 1.000 1.000 0.750 0.625 0.500 0.375 0.250 0.125 0.000)))
	  (snd-display #__line__ ";bartlett window: ~A" gen)))
    (let ((gen (make-fft-window blackman2-window 16)))
      (if (not (vequal gen (vct 0.005 0.020 0.071 0.177 0.344 0.558 0.775 1.000 1.000 0.775 0.558 0.344 0.177 0.071 0.020 0.005)))
	  (snd-display #__line__ ";blackman2 window: ~A" gen)))
    (let ((gen (make-fft-window blackman3-window 16)))
      (if (not (vequal gen (vct 0.000 0.003 0.022 0.083 0.217 0.435 0.696 1.000 1.000 0.696 0.435 0.217 0.083 0.022 0.003 0.000)))
	  (snd-display #__line__ ";blackman3 window: ~A" gen)))
    (let ((gen (make-fft-window blackman4-window 16)))
      (if (not (vequal gen (vct 0.002 0.002 0.003 0.017 0.084 0.263 0.562 1.000 1.000 0.562 0.263 0.084 0.017 0.003 0.002 0.002)))
	  (snd-display #__line__ ";blackman4 window: ~A" gen)))
    
    (let ((gen (make-fft-window blackman5-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.003 0.022 0.097 0.280 0.574 1.000 1.000 0.574 0.280 0.097 0.022 0.003 0.000 0.000)))
	  (snd-display #__line__ ";blackman5 window: ~A" gen)))
    (let ((gen (make-fft-window blackman6-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.001 0.011 0.064 0.223 0.520 1.000 1.000 0.520 0.223 0.064 0.011 0.001 0.000 0.000)))
	  (snd-display #__line__ ";blackman6 window: ~A" gen)))
    (let ((gen (make-fft-window blackman7-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.000 0.006 0.042 0.177 0.471 1.000 1.000 0.471 0.177 0.042 0.006 0.000 0.000 0.000)))
	  (snd-display #__line__ ";blackman7 window: ~A" gen)))
    (let ((gen (make-fft-window blackman8-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.000 0.003 0.028 0.141 0.426 1.000 1.000 0.426 0.141 0.028 0.003 0.000 0.000 0.000)))
	  (snd-display #__line__ ";blackman8 window: ~A" gen)))
    (let ((gen (make-fft-window blackman9-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.000 0.001 0.018 0.112 0.385 1.000 1.000 0.385 0.112 0.018 0.001 0.000 0.000 -0.000)))
	  (snd-display #__line__ ";blackman9 window: ~A" gen)))
    (let ((gen (make-fft-window blackman10-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.000 0.001 0.012 0.089 0.349 1.000 1.000 0.349 0.089 0.012 0.001 0.000 0.000 -0.000)))
	  (snd-display #__line__ ";blackman10 window: ~A" gen)))
    (let ((gen (make-fft-window rv2-window 16)))
      (if (not (vequal gen (vct 0.000 0.001 0.021 0.095 0.250 0.478 0.729 1.000 1.000 0.729 0.478 0.250 0.095 0.021 0.001 0.000)))
	  (snd-display #__line__ ";rv2 window: ~A" gen)))
    (let ((gen (make-fft-window rv3-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.003 0.029 0.125 0.330 0.622 1.000 1.000 0.622 0.330 0.125 0.029 0.003 0.000 0.000)))
	  (snd-display #__line__ ";rv3 window: ~A" gen)))
    (let ((gen (make-fft-window rv4-window 16)))
      (if (not (vequal gen (vct 0.000 0.000 0.000 0.009 0.062 0.228 0.531 1.000 1.000 0.531 0.228 0.062 0.009 0.000 0.000 0.000)))
	  (snd-display #__line__ ";rv4 window: ~A" gen)))
    
    (let ((gen (make-fft-window exponential-window 16)))
      (if (not (vequal gen (vct 0.000 0.087 0.181 0.283 0.394 0.515 0.646 0.944 0.944 0.646 0.515 0.394 0.283 0.181 0.087 0.000)))
	  (snd-display #__line__ ";exponential window: ~A" gen)))
    (let ((gen (make-fft-window riemann-window 16)))
      (if (not (vequal gen (vct 0.000 0.139 0.300 0.471 0.637 0.784 0.900 1.000 1.000 0.900 0.784 0.637 0.471 0.300 0.139 0.000)))
	  (snd-display #__line__ ";riemann window: ~A" gen)))
    (let ((gen (make-fft-window kaiser-window 16 2.5)))
      (if (not (vequal gen (vct 0.304 0.426 0.550 0.670 0.779 0.871 0.941 1.000 1.000 0.941 0.871 0.779 0.670 0.550 0.426 0.304)))
	  (snd-display #__line__ ";kaiser window: ~A" gen)))
    (let ((gen (make-fft-window cauchy-window 16 2.5)))
      (if (not (vequal gen (vct 0.138 0.173 0.221 0.291 0.390 0.532 0.719 1.000 1.000 0.719 0.532 0.390 0.291 0.221 0.173 0.138)))
	  (snd-display #__line__ ";cauchy window: ~A" gen)))
    (let ((gen (make-fft-window poisson-window 16 2.5)))
      (if (not (vequal gen (vct 0.082 0.112 0.153 0.210 0.287 0.392 0.535 1.000 1.000 0.535 0.392 0.287 0.210 0.153 0.112 0.082)))
	  (snd-display #__line__ ";poisson window: ~A" gen)))
    (let ((gen (make-fft-window gaussian-window 16 1.0)))
      (if (not (vequal gen (vct 0.607 0.682 0.755 0.823 0.882 0.932 0.969 1.000 1.000 0.969 0.932 0.882 0.823 0.755 0.682 0.607)))
	  (snd-display #__line__ ";gaussian window: ~A" gen)))
    (let ((gen (make-fft-window tukey-window 16)))
      (if (not (vequal gen (vct 0.000 0.038 0.146 0.309 0.500 0.691 0.854 1.000 1.000 0.854 0.691 0.500 0.309 0.146 0.038 0.000)))
	  (snd-display #__line__ ";tukey window: ~A" gen)))
    (let ((gen (make-fft-window hann-poisson-window 16)))
      (if (not (vequal gen (vct 0.000 0.038 0.146 0.309 0.500 0.691 0.854 1.000 1.000 0.854 0.691 0.500 0.309 0.146 0.038 0.000)))
	  (snd-display #__line__ ";tukey window: ~A" gen)))
    (let ((gen (make-fft-window bohman-window 16)))
      (if (not (vequal gen (vct 0.000 0.006 0.048 0.151 0.318 0.533 0.755 1.000 1.000 0.755 0.533 0.318 0.151 0.048 0.006 0.000)))
	  (snd-display #__line__ ";bohman window: ~A" gen)))
    
    (for-each
     (lambda (window-data)
       (let ((window (car window-data))
	     (func (caddr window-data))
	     (name (cadr window-data)))
	 (let ((v1 (make-fft-window window 16))
	       (v2 (make-vct 16)))
	   (do ((i 0 (+ 1 i))
		(j 15 (- j 1))
		(ang 0.0 (+ ang (/ (* 2 pi) 16.0))))
	       ((> i 8)) ; yikes -- even size + smallness = questionable code...
	     (let ((val (func ang)))
	       (vct-set! v2 i val)
	       (vct-set! v2 j val)))
	   (if (not (vequal v1 v2)) 
	       (snd-display #__line__ ";~A by hand:~%;  mus: ~A~%;  loc: ~A" name v1 v2)))))
     
     (list 
      (list hann-window "hann" (lambda (ang) 
				 (- 0.5 
				    (* 0.5 (cos ang)))))
      
      (list rv2-window "rv2" (lambda (ang) 
			       (+ .375 
				  (* -0.5 (cos ang)) 
				  (* .125 (cos (* 2 ang))))))
      
      (list rv3-window "rv3" (lambda (ang) 
			       (+ (/ 10.0 32.0) 
				  (* (/ -15.0 32.0) (cos ang)) 
				  (* (/ 6.0 32.0) (cos (* 2 ang))) 
				  (* (/ -1.0 32.0) (cos (* 3 ang))))))
      
      (list rv4-window "rv4" (lambda (ang) 
			       (+ (/ 35.0 128.0)
				  (* (/ -56.0 128.0) (cos ang)) 
				  (* (/ 28.0 128.0) (cos (* 2 ang))) 
				  (* (/ -8.0 128.0) (cos (* 3 ang)))
				  (* (/ 1.0 128.0) (cos (* 4 ang))))))
      
      (list hamming-window "hamming" (lambda (ang)
				       (- 0.54
					  (* 0.46 (cos ang)))))
      
      (list blackman2-window "blackman2" (lambda (ang)
					   (+ 0.42323 
					      (* -0.49755 (cos ang)) 
					      (* 0.07922 (cos (* 2 ang))))))
      
      (list blackman3-window "blackman3" (lambda (ang)
					   (+ 0.35875 
					      (* -0.48829 (cos ang)) 
					      (* 0.14128 (cos (* 2 ang))) 
					      (* -0.01168 (cos (* 3 ang))))))
      
      (list blackman4-window "blackman4" (lambda (ang)
					   (+ 0.287333 
					      (* -0.44716 (cos ang))
					      (* 0.20844 (cos (* 2 ang)))
					      (* -0.05190 (cos (* 3 ang)))
					      (* 0.005149 (cos (* 4 ang))))))
      
      (list blackman5-window "blackman5" (lambda (ang)
					   (+ .293557 
					      (* -.451935 (cos ang))
					      (* .201416 (cos (* 2 ang)))
					      (* -.047926 (cos (* 3 ang)))
					      (* .00502619 (cos (* 4 ang)))
					      (* -.000137555 (cos (* 5 ang))))))
      
      (list blackman6-window "blackman6" (lambda (ang)
					   (+ .271220 
					      (* -.433444 (cos ang))
					      (* .218004 (cos (* 2 ang)))
					      (* -.065785 (cos (* 3 ang)))
					      (* .01076186 (cos (* 4 ang)))
					      (* -.000770012 (cos (* 5 ang)))
					      (* .0000136808 (cos (* 6 ang)))))) 
      
      (list blackman7-window "blackman7" (lambda (ang)
					   (+ .253317 
					      (* -.416327 (cos ang))
					      (* .228839 (cos (* 2 ang)))
					      (* -.081575 (cos (* 3 ang)))
					      (* .01773592 (cos (* 4 ang)))
					      (* -.002096702 (cos (* 5 ang)))
					      (* .0001067741 (cos (* 6 ang)))
					      (* -.0000012807(cos (* 7 ang))))))
      
      (list blackman8-window "blackman8" (lambda (ang)
					   (+ .238433 
					      (* -.400554 (cos ang))
					      (* .235824 (cos (* 2 ang)))
					      (* -.095279 (cos (* 3 ang)))
					      (* .02537395 (cos (* 4 ang)))
					      (* -.00415243  (cos (* 5 ang)))
					      (* .0003685604 (cos (* 6 ang)))
					      (* -.0000138435 (cos (* 7 ang)))
					      (* .000000116180(cos (* 8 ang))))))
      
      (list blackman9-window "blackman9" (lambda (ang)
					   (+ .225734 
					      (* -.386012 (cos ang))
					      (* .240129 (cos (* 2 ang)))
					      (* -.107054 (cos (* 3 ang)))
					      (* .03325916 (cos (* 4 ang)))
					      (* -.00687337  (cos (* 5 ang)))
					      (* .0008751673 (cos (* 6 ang)))
					      (* -.0000600859 (cos (* 7 ang)))
					      (* .000001710716 (cos (* 8 ang)))
					      (* -.00000001027272(cos (* 9 ang))))))
      
      (list blackman10-window "blackman10" (lambda (ang)
					     (+ .215153 
						(* -.373135 (cos ang))
						(* .242424 (cos (* 2 ang)))
						(* -.1166907 (cos (* 3 ang)))
						(* .04077422 (cos (* 4 ang)))
						(* -.01000904 (cos (* 5 ang)))
						(* .0016398069 (cos (* 6 ang)))
						(* -.0001651660 (cos (* 7 ang)))
						(* .000008884663 (cos (* 8 ang)))
						(* -.000000193817 (cos (* 9 ang)))
						(* .000000000848248(cos (* 10 ang))))))
      
      (list rectangular-window "rectangular" (lambda (ang) 1.0))
      
      (list bartlett-window "bartlett" (let ((val 0.0)) 
					 (lambda (ang)
					   (let ((result val))
					     (set! val (+ val (/ 1.0 8)))
					     result))))
      
      (list parzen-window "parzen" (let ((i 0))
				     (lambda (ang)
				       (let ((result (- 1.0 (abs (/ (- i 8) 8.0)))))
					 (set! i (+ i 1))
					 result))))
      
      (list welch-window "welch" (let ((i 0)
				       (sqr (lambda (x) (* x x))))
				   (lambda (ang)
				     (let ((result (- 1.0 (sqr (/ (- i 8) 8.0)))))
				       (set! i (+ i 1))
				       result))))
      
      (list flat-top-window "flat-top" (lambda (ang)
					 (+ 0.2156 
					    (* -0.4160 (cos ang))
					    (* 0.2781 (cos (* 2 ang)))
					    (* -0.0836 (cos (* 3 ang)))
					    (* 0.0069 (cos (* 4 ang))))))
      
      (list bohman-window "bohman" (let ((i 0))
				     (lambda (ang)
				       (let* ((r (/ (- 8 i) 8))
					      (result (+ (* (- 1.0 r) (cos (* pi r)))
							 (* (/ 1.0 pi) (sin (* pi r))))))
					 (set! i (+ i 1))
					 result))))
      
      (list bartlett-hann-window "bartlett-hann" (let ((i 0))
						   (lambda (ang)
						     (let ((result (+ 0.62 
								      (* -0.48 (abs (- (/ i 16.0) 0.5))) 
								      (* 0.38 (cos (* 2 pi (- (/ i 16.0) 0.5)))))))
						       (set! i (+ i 1))
						       result))))
      
      (list connes-window "connes" (let ((i 0)
					 (sqr (lambda (x) (* x x))))
				     (lambda (ang)
				       (let ((result (sqr (- 1.0 (sqr (/ (- i 8) 8.0))))))
					 (set! i (+ i 1))
					 result))))
      
      (list riemann-window "riemann" (let ((i 0))
				       (lambda (ang)
					 (let ((result (if (= 8 i) 
							   1.0
							   (/ (sin (* (/ (* 2 pi) 16.) (- 8 i))) (* (/ (* 2 pi) 16.0) (- 8 i))))))
					   (set! i (+ i 1))
					   result))))
      
      (list exponential-window "exponential" (let ((expsum 1.0))
					       (lambda (ang)
						 (let ((result (- expsum 1.0))) 
						   (set! expsum (* expsum (+ 1.0 (/ (log 2) 8.0))))
						   result))))
      ))
    
    (let ((win (make-fft-window bartlett-hann-window 32))
	  (unhappy #f))
      (do ((i 0 (+ 1 i))) 
	  ((or unhappy (= i 32)))
	(let ((val (+ 0.62 (* -0.48 (abs (- (/ i 31) 0.5))) (* 0.38 (cos (* 2 pi (- (/ i 31) 0.5)))))))
	  (if (> (abs (- val (vct-ref win i))) .03)
	      (begin
		(set! unhappy #t)
		(snd-display #__line__ ";bartlett-hann at ~D: ~A ~A" i val (vct-ref win i)))))))
    (let ((win (make-fft-window flat-top-window 32))
	  (unhappy #f))
      (do ((i 0 (+ 1 i))) 
	  ((or unhappy (= i 32)))
	(let ((val (+ 0.2156 
		      (* -0.4160 (cos (/ (* 2 pi i) 31))) 
		      (* 0.2781 (cos (/ (* 4 pi i) 31))) 
		      (* -0.0836 (cos (/ (* 6 pi i) 31))) 
		      (* 0.0069 (cos (/ (* 8 pi i) 31))))))
	  (if (> (abs (- val (vct-ref win i))) .1) ; error is much less, of course, in a bigger window
	      (begin
		(set! unhappy #t)
		(snd-display #__line__ ";flat-top at ~D: ~A ~A" i val (vct-ref win i)))))))
    (catch #t
	   (lambda ()
	     (let ((gen (make-fft-window samaraki-window 16)))
	       (if (not (vequal gen (vct 1.000 0.531 0.559 0.583 0.604 0.620 0.631 0.638 0.640 0.638 0.631 0.620 0.604 0.583 0.559 0.531)))
		   (snd-display #__line__ ";samaraki window: ~A" gen)))
	     (let ((gen (make-fft-window ultraspherical-window 16)))
	       (if (not (vequal gen (vct 1.000 0.033 0.034 0.035 0.036 0.036 0.037 0.037 0.037 0.037 0.037 0.036 0.036 0.035 0.034 0.033)))
		   (snd-display #__line__ ";ultraspherical window: ~A" gen)))
	     (let ((gen (make-fft-window dolph-chebyshev-window 16)))
	       (if (not (vequal gen (vct 1.000 0.033 0.034 0.035 0.036 0.036 0.037 0.037 0.037 0.037 0.037 0.036 0.036 0.035 0.034 0.033)))
		   (snd-display #__line__ ";dolph-chebyshev window: ~A" gen)))
	     
	     (without-errors
	      (let ((gen (make-fft-window dolph-chebyshev-window 16 1.0)))
		(if (not (vequal gen (vct 1.000 0.274 0.334 0.393 0.446 0.491 0.525 0.546 0.553 0.546 0.525 0.491 0.446 0.393 0.334 0.274)))
		    (snd-display #__line__ ";dolph-chebyshev window: ~A" gen))))
	     
	     (let ((multra (lambda (N gamma xmu)
			     (let* ((alpha (cosh (/ (acosh (expt 10.0 gamma)) N)))
				    (freq (/ pi N))
				    (rl (make-vct N))
				    (im (make-vct N)))
			       (do ((i 0 (+ 1 i))
				    (phase 0.0 (+ phase freq)))
				   ((= i N))
				 (let ((val (gsl-gegenbauer N xmu (* alpha (cos phase)))))  ;(cos (* N (acos (* alpha (cos phase)))))
				   (vct-set! rl i (real-part val))
				   (vct-set! im i (imag-part val))))
			       (fft rl im -1)
			       (let ((pk (vct-peak rl)))
				 (vct-scale! rl (/ 1.0 pk)))
			       (do ((i 0 (+ 1 i))
				    (j (/ N 2)))
				   ((= i N))
				 (vct-set! im i (vct-ref rl j))
				 (set! j (+ j 1))
				 (if (= j N) (set! j 0)))
			       im))))
	       (let ((val1 (make-fft-window ultraspherical-window 16 0.0 0.0))
		     (val2 (make-fft-window dolph-chebyshev-window 16 0.0)))
		 (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/dolph 0: ~A ~A" val1 val2)))  
	       (let ((val1 (make-fft-window ultraspherical-window 16 0.0 1.0))
		     (val2 (make-fft-window samaraki-window 16 0.0)))
		 (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/sam 0: ~A ~A" val1 val2)))
	       (let ((val1 (make-fft-window ultraspherical-window 16 0.5 0.0))
		     (val2 (make-fft-window dolph-chebyshev-window 16 0.5)))
		 (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/dolph 5: ~A ~A" val1 val2)))  
	       (let ((val1 (make-fft-window ultraspherical-window 16 0.5 1.0))
		     (val2 (make-fft-window samaraki-window 16 0.5)))
		 (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/sam 5: ~A ~A" val1 val2)))
	       (let ((val1 (dolph 16 1.0))
		     (val2 (make-fft-window dolph-chebyshev-window 16 1.0)))
		 (if (not (vequal val1 val2)) (snd-display #__line__ ";dolph/dolph 1: ~A ~A" val1 val2)))  
	       (let ((val1 (vector->vct (dolph-1 16 1.0)))
		     (val2 (make-fft-window dolph-chebyshev-window 16 1.0)))
		 (if (not (vequal val1 val2)) (snd-display #__line__ ";dolph-1/dolph 1: ~A ~A" val1 val2)))
	       (if (and (provided? 'gsl)
			(defined? 'gsl-gegenbauer))
		   (begin
		     (let ((val1 (multra 16 1.0 1.0))
			   (val2 (make-fft-window samaraki-window 16 1.0)))
		       (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/sam 0: ~A ~A" val1 val2)))
		     (let ((val1 (multra 16 0.5 1.0))
			   (val2 (make-fft-window samaraki-window 16 0.5)))
		       (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/sam 5: ~A ~A" val1 val2)))
		     (let ((val1 (multra 16 0.5 0.5))
			   (val2 (make-fft-window ultraspherical-window 16 0.5 0.5)))
		       (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/ultra 5: ~A ~A" val1 val2)))
		     (let ((val1 (multra 16 0.5 2.5))
			   (val2 (make-fft-window ultraspherical-window 16 0.5 2.5)))
		       (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/ultra 5: ~A ~A" val1 val2)))
		     (let ((val1 (multra 16 2.5 2.5))
			   (val2 (make-fft-window ultraspherical-window 16 2.5 2.5)))
		       (if (not (vequal val1 val2)) (snd-display #__line__ ";ultra/ultra 5: ~A ~A" val1 val2)))
		     ))))
	   (lambda args (snd-display #__line__ ";new windows: ~A" args)))
    
    (if (defined? 'gsl-eigenvectors)
	(begin
	  (let ((win (make-dpss-window 16 .01)))
	    (if (not (vequal win (vct 0.964 0.973 0.981 0.987 0.992 0.996 0.999 1.000 1.000 0.999 0.996 0.992 0.987 0.981 0.973 0.964)))
		(snd-display #__line__ ";make-dpss-window 16 .01: ~A" win)))
	  (let ((win (make-dpss-window 16 .1)))
	    (if (not (vequal win (vct 0.090 0.193 0.332 0.494 0.664 0.818 0.936 1.000 1.000 0.936 0.818 0.664 0.494 0.332 0.193 0.090)))
		(snd-display #__line__ ";make-dpss-window 16 .1: ~A" win)))
	  (let ((win (make-dpss-window 32 .09)))
	    (if (not (vequal win (vct 0.004 0.011 0.025 0.050 0.086 0.138 0.206 0.290 0.388 0.496 0.610 0.722 0.823 0.908 0.968 1.000 
				      1.000 0.968 0.908 0.823 0.722 0.610 0.496 0.388 0.290 0.206 0.138 0.086 0.050 0.025 0.011 0.004)))
		(snd-display #__line__ ";make-dpss-window 32 .09: ~A" win)))
	  
	  (for-each
	   (lambda (n)
	     (for-each
	      (lambda (beta)
		(let ((win1 (make-dpss-window n beta))
		      (win2 (make-fft-window dpss-window n beta)))
		  (if (not (vequal win1 win2))
		      (snd-display #__line__ ";dpss-windows:~%    ~A~%    ~A" win1 win2))))
	      (list .01 .07 .12 .2)))
	   (list 16 32))))
    
    (let ((win (make-papoulis-window 32)))
      (if (not (vequal win (vct 0.000 0.001 0.006 0.021 0.048 0.091 0.151 0.227 0.318 0.422 0.533 0.647 0.755 0.852 0.930 0.982 
				1.000 0.982 0.930 0.852 0.755 0.647 0.533 0.422 0.318 0.227 0.151 0.091 0.048 0.021 0.006 0.001)))
	  (snd-display #__line__ ";make-papoulis-window 32: ~A" win)))
    
    (for-each
     (lambda (n)
       (let ((win1 (make-papoulis-window n))
	     (win2 (make-fft-window papoulis-window n)))
	 (if (not (vequal win1 win2))
	     (snd-display #__line__ ";papoulis-windows:~%    ~A~%    ~A" win1 win2))))
     (list 32 64 256))
    
    
    (let ((v0 (make-vct 10))
	  (gen (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 11))
	  (v1 (make-vct 10))
	  (gen1 (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 11)))
      (print-and-check gen 
		       "env"
		       "env linear, pass: 0 (dur: 11), index: 0, scaler: 0.5000, offset: 0.0000, data: [0.000 0.000 1.000 1.000 2.000 0.000]")
      (if (not (env? gen)) (snd-display #__line__ ";~A not env?" gen))
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";env scaler ~F?" (mus-scaler gen)))
      (if (fneq (mus-increment gen) 1.0) (snd-display #__line__ ";env base (1.0): ~A?" (mus-increment gen)))
      (if (not (= (mus-length gen) 11)) (snd-display #__line__ ";env length: ~A" (mus-length gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (env gen)))
      (let ((off 123.0))
	(vct-map! v1 (lambda () 
		       (set! off (mus-offset gen1))
		       (if (env? gen1) (env gen1) -1.0)))
	(if (fneq off 0.0) (snd-display #__line__ ";mus-offset opt: ~A" off)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map env: ~A ~A" v0 v1))
      (if (or (fneq (vct-ref v0 0) 0.0) (fneq (vct-ref v0 1) .1) (fneq (vct-ref v0 6) .4))
	  (snd-display #__line__ ";~A output: ~A" gen v0))
      (if (fneq (env-interp 1.6 gen) 0.2) (snd-display #__line__ ";env-interp ~A at 1.6: ~F?" gen (env-interp 1.5 gen)))
      (set! gen (make-env :envelope '(0 1 1 0) :base 32.0 :length 11))
      (if (fneq (mus-increment gen) 32.0) (snd-display #__line__ ";env base (32.0): ~A?" (mus-increment gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (env gen)))
      (if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 1) .698) (fneq (vct-ref v0 8) .032))
	  (snd-display #__line__ ";~A output: ~A" gen v0))
      (set! gen (make-env :envelope '(0 1 1 0) :base .0325 :length 11))
      (if (fneq (mus-increment gen) .0325) (snd-display #__line__ ";env base (.0325): ~A?" (mus-increment gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (env gen)))
      (if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 1) .986) (fneq (vct-ref v0 8) .513))
	  (snd-display #__line__ ";~A output: ~A" gen v0))
      (set! gen (make-env :envelope '(0 1 1 .5 2 0) :base 0.0 :length 11 :offset 1.0))
      (if (fneq (mus-offset gen) 1.0) (snd-display #__line__ ";mus-offset: ~A" (mus-offset gen)))
      (if (fneq (mus-increment gen) 0.0) (snd-display #__line__ ";env base (0.0): ~A?" (mus-increment gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (= i 3)
	    (if (not (= (mus-location gen) 3))
		(snd-display #__line__ ";env location: ~A?" (mus-location gen))))
	(vct-set! v0 i (env gen)))
      (if (or (fneq (vct-ref v0 0) 2.0) (fneq (vct-ref v0 6) 1.5) (fneq (vct-ref v0 8) 1.5))
	  (snd-display #__line__ ";~A output: ~A" gen v0))
      (if (fneq (env-interp 1.5 gen) 1.5) (snd-display #__line__ ";env-interp ~A at 1.5: ~F?" gen (env-interp 1.5 gen)))
      (set! (mus-location gen) 6)
      (if (not (= (mus-location gen) 6)) (snd-display #__line__ ";set! mus-location ~A (6)?" (mus-location gen)))
      (let ((val (env gen)))
	(if (fneq val 1.5) (snd-display #__line__ ";set! mus-location 6 -> ~A (1.5)?" val)))
      (set! (mus-location gen) 0)
      (let ((val (env gen)))
	(if (fneq val 2.0) (snd-display #__line__ ";set! mus-location 0 -> ~A (2.0)?" val)))
      (let ((gen (make-env '(0 0 1 -1 2 0) :length 11)))
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (let ((val (env gen)))
	    (if (fneq val (/ i -5.0)) (snd-display #__line__ ";neg env: ~D ~A" i val))))
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (let ((val (env gen)))
	    (if (fneq val (+ -1.0 (/ i 5.0))) (snd-display #__line__ ";neg env: ~D ~A" (+ i 5) val)))))
      (let ((gen (make-env '(0 0 1 -1 2 0) :length 11 :base 0.5))
	    (v (vct 0.0 -0.14869 -0.31950 -0.51571 -0.74110 -1.0 -0.74110 -0.51571 -0.31950 -0.14869)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (let ((val (env gen)))
	    (if (fneq val (vct-ref v i)) (snd-display #__line__ ";neg exp env: ~D ~A" i val))))
	(mus-apply gen))
      
      (let ((v (make-vct 10)))
	(let ((e (make-env '(0 0 1 1) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
	      (snd-display #__line__ ";simple ramp: ~A" v)))
	(let ((v (make-vct 10)))
	  (let ((e (make-env '(0 0 1 1) :base 0 :length 8)))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (vct-set! v i (env e)))
	    (if (not (vequal v (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 1.000)))
		(snd-display #__line__ ";simple ramp, base 0: ~A" v))))
	(let ((v (make-vct 10)))
	  (let ((e (make-env '(0 0 1 1 2 .5) :base 0 :length 8)))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (vct-set! v i (env e)))
	    (if (not (vequal v (vct 0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 0.500 0.500)))
		(snd-display #__line__ ";two-step, base 0: ~A" v))))
	(let ((e (make-env '((0 0) (1 1)) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
	      (snd-display #__line__ ";simple ramp embedded: ~A" v)))
	(let ((e (make-env '(0 1 1 0) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 1.000 0.889 0.778 0.667 0.556 0.444 0.333 0.222 0.111 0.000)))
	      (snd-display #__line__ ";simple ramp down: ~A" v)))
	(let ((e (make-env '(0 0 1 1 2 0) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	      (snd-display #__line__ ";simple pyr: ~A" v)))
	(let ((e (make-env '((0 0) (1 1) (2 0)) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	      (snd-display #__line__ ";simple pyr embedded: ~A" v)))
	(let ((e (make-env '(0 0 1 1 2 -.5) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
	      (snd-display #__line__ ";simple pyr -.5: ~A" v)))
	(let ((e (make-env '((0 0) (1 1) (2 -.5)) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
	      (snd-display #__line__ ";simple pyr -.5 embedded: ~A" v)))
	(let ((e (make-env '(0 0 1 1 2 -.5) :length 10)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! v i (env e)))
	  (if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.625 0.250 -0.125 -0.500)))
	      (snd-display #__line__ ";simple pyr -.5: ~A" v))))
      
      (let ((e (make-env '(0 0 1 1) :length 10)))
	(if (fneq (env-interp 1.0 e) 1.0) (snd-display #__line__ ";env-interp 0011 at 1: ~A" (env-interp 1.0 e)))
	(if (fneq (env-interp 2.0 e) 1.0) (snd-display #__line__ ";env-interp 0011 at 2: ~A" (env-interp 2.0 e)))
	(if (fneq (env-interp 0.0 e) 0.0) (snd-display #__line__ ";env-interp 0011 at 0: ~A" (env-interp 0.0 e)))
	(if (fneq (env-interp 0.444 e) 0.444) (snd-display #__line__ ";env-interp 0011 at .444: ~A" (env-interp 0.45 e)))
	(mus-reset e)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (let ((val (env e)))
	    (if (fneq val (* i .111111)) (snd-display #__line__ ";ramp env over 10: ~A at ~A" val i)))))
      (let ((e (make-env '(0 0 .5 .5 1 1) :base 32 :length 10))
	    (v (vct 0.0 0.0243 0.0667 0.1412 0.2716 0.5000 0.5958 0.7090 0.8425 1.0)))
	(do ((i 0 (+ 1 i))
	     (x 0.0 (+ x 0.11111)))
	    ((= i 10))
	  (let ((val (env-interp x e)))
	    (if (fneq val (vct-ref v i)) (snd-display #__line__ ";(0 .5 1) env-interp over 10: ~A at ~A (~A)" val i (vct-ref v i))))))
      (let ((e (make-env '(0 -1.0 1 1) :base 32 :length 10))
	    (v (vct -1.0 -0.9697 -0.9252 -0.8597 -0.7635 -0.6221 -0.4142 -0.1088 0.34017 1.0)))
	(do ((i 0 (+ 1 i))
	     (x 0.0 (+ x 0.11111)))
	    ((= i 10))
	  (let ((val (env-interp x e)))
	    (if (fneq val (vct-ref v i)) (snd-display #__line__ ";(-1 1) env-interp over 10: ~A at ~A (~A)" val i (vct-ref v i))))))
      (let ((e (make-env '(0 -1.0 .5 .5 1 0) :base 32 :length 10))
	    (v (vct -1.0 -0.952 -0.855 -0.661 -0.274 0.5 0.356 0.226 0.107 0.0)))
	(do ((i 0 (+ 1 i))
	     (x 0.0 (+ x 0.11111)))
	    ((= i 10))
	  (let ((val (env-interp x e)))
	    (if (fneq val (vct-ref v i)) (snd-display #__line__ ";(-1 .5 0) env-interp over 10: ~A at ~A (~A)" val i (vct-ref v i))))))
      (let ((e (make-env '(0 0.0 .5 .5 1 -1.0) :base 32 :length 10))
	    (v (vct 0.0 0.085 0.177 0.276 0.384 0.5 -0.397 -0.775 -0.933 -1.0)))
	(do ((i 0 (+ 1 i))
	     (x 0.0 (+ x 0.11111)))
	    ((= i 10))
	  (let ((val (env-interp x e)))
	    (if (fneq val (vct-ref v i)) (snd-display #__line__ ";(0 .5 -1) env-interp over 10: ~A at ~A (~A)" val i (vct-ref v i))))))
      (let ((e (make-env '(0 0 1 1) :length 10 :base 4.0)))
	(if (fneq (env-interp 1.0 e) 1.0) (snd-display #__line__ ";env-interp 0011 4 at 1: ~A" (env-interp 1.0 e)))
	(if (fneq (env-interp 0.0 e) 0.0) (snd-display #__line__ ";env-interp 0011 4 at 0: ~A" (env-interp 0.0 e)))
	(if (fneq (env-interp 0.45 e) 0.2839) (snd-display #__line__ ";env-interp 0011 4 at .45: ~A" (env-interp 0.45 e))))
      (let ((e (make-env '(0 0 1 1) :length 10 :base 0.2)))
	(if (fneq (env-interp 1.0 e) 1.0) (snd-display #__line__ ";env-interp 0011 2 at 1: ~A" (env-interp 1.0 e)))
	(if (fneq (env-interp 0.0 e) 0.0) (snd-display #__line__ ";env-interp 0011 2 at 0: ~A" (env-interp 0.0 e)))
	(if (fneq (env-interp 0.45 e) 0.6387) (snd-display #__line__ ";env-interp 0011 2 at .45: ~A" (env-interp 0.45 e))))
      
      (let ((val (let ((e (make-env '(0 0 1 1) :offset 2.0))) (set! (mus-offset e) 3.0) (mus-offset e))))
	(if (fneq val 3.0) (snd-display #__line__ ";set mus-offset env: ~A" val)))
      
      (let ((e (make-env '(0 0 1 1 2 0) :length 10))
	    (v (make-vct 10 0.0)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v i (env e)))
	(if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	    (snd-display #__line__ ";e set off 0: ~A" v))
	(if (not (= (mus-length e) 10)) (snd-display #__line__ ";e set off 0 len: ~A" (mus-length e)))
	(if (fneq (mus-scaler e) 1.0) (snd-display #__line__ ";e set off 0 scl: ~A" (mus-scaler e)))
	(if (fneq (mus-offset e) 0.0) (snd-display #__line__ ";e set off 0 off: ~A" (mus-offset e)))
	(set! (mus-scaler e) 2.0)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v i (env e)))
	(if (not (vequal v (vct 0.000 0.400 0.800 1.200 1.600 2.000 1.500 1.000 0.500 0.000)))
	    (snd-display #__line__ ";e set off 1: ~A" v))
	(if (not (= (mus-length e) 10)) (snd-display #__line__ ";e set off 1 len: ~A" (mus-length e)))
	(if (fneq (mus-scaler e) 2.0) (snd-display #__line__ ";e set off 1 scl: ~A" (mus-scaler e)))
	(if (fneq (mus-offset e) 0.0) (snd-display #__line__ ";e set off 1 off: ~A" (mus-offset e)))
	(set! (mus-offset e) 1.0)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v i (env e)))
	(if (not (vequal v (vct 1.000 1.400 1.800 2.200 2.600 3.000 2.500 2.000 1.500 1.000)))
	    (snd-display #__line__ ";e set off 2: ~A" v))
	(if (not (= (mus-length e) 10)) (snd-display #__line__ ";e set off 2 len: ~A" (mus-length e)))
	(if (fneq (mus-scaler e) 2.0) (snd-display #__line__ ";e set off 2 scl: ~A" (mus-scaler e)))
	(if (fneq (mus-offset e) 1.0) (snd-display #__line__ ";e set off 2 off: ~A" (mus-offset e)))
	(set! (mus-length e) 19)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v i (env e)))
	(if (not (vequal v (vct 1.000 1.222 1.444 1.667 1.889 2.111 2.333 2.556 2.778 3.000)))
	    (snd-display #__line__ ";e set off 3: ~A" v))
	(if (not (= (mus-length e) 19)) (snd-display #__line__ ";e set off 3 len: ~A" (mus-length e)))
	(if (fneq (mus-scaler e) 2.0) (snd-display #__line__ ";e set off 3 scl: ~A" (mus-scaler e)))
	(if (fneq (mus-offset e) 1.0) (snd-display #__line__ ";e set off 3 off: ~A" (mus-offset e))))
      
      (let ((e (make-env (vct 0 0 1 1 2 0) :length 10))
	    (v (make-vct 10 0.0)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v i (env e)))
	(if (not (vequal v (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
	    (snd-display #__line__ ";e from vct: ~A" v)))
      
      (let ((e1 (make-env '(0 0 1 1) :base 32.0 :length 11))
	    (v (vct 0.000 0.013 0.032 0.059 0.097 0.150 0.226 0.333 0.484 0.698 1.00)))
	(do ((i 0 (+ 1 i)))
	    ((> i 10))
	  (let ((val (env e1)))
	    (if (fneq val (vct-ref v i))
		(snd-display #__line__ ";exp env direct (32.0): ~A ~A" val (vct-ref v i))))))
      
      (let ((e1 (make-env '(0 1 1 2) :base 32.0 :length 11))
	    (v (vct 1.000 1.013 1.032 1.059 1.097 1.150 1.226 1.333 1.484 1.698 2.00)))
	(do ((i 0 (+ 1 i)))
	    ((> i 10))
	  (let ((val (env e1)))
	    (if (fneq val (vct-ref v i))
		(snd-display #__line__ ";exp env direct (32.0) offset: ~A ~A" val (vct-ref v i))))))
      (let ((e1 (make-env '((0 1) (1 2)) :base 32.0 :length 11))
	    (v (vct 1.000 1.013 1.032 1.059 1.097 1.150 1.226 1.333 1.484 1.698 2.00)))
	(do ((i 0 (+ 1 i)))
	    ((> i 10))
	  (let ((val (env e1)))
	    (if (fneq val (vct-ref v i))
		(snd-display #__line__ ";exp env direct (32.0) offset embedded: ~A ~A" val (vct-ref v i))))))
      (let ((e1 (make-env '(0 1 1 2) :base 32.0 :length 11))
	    (v (vct 1.000 1.013 1.032 1.059 1.097 1.150 1.226 1.333 1.484 1.698 2.00)))
	(do ((i 0 (+ 1 i)))
	    ((> i 10))
	  (let ((val (env e1)))
	    (if (fneq val (vct-ref v i))
		(snd-display #__line__ ";exp env direct (32.0) offset (and dur): ~A ~A" val (vct-ref v i))))))
      
      (let ((e1 (make-env '(0 0 1 1) :base 0.032 :length 11))
	    (v (vct 0.000 0.301 0.514 0.665 0.772 0.848 0.902 0.940 0.967 0.986 1.0)))
	(do ((i 0 (+ 1 i)))
	    ((> i 10))
	  (let ((val (env e1)))
	    (if (fneq val (vct-ref v i))
		(snd-display #__line__ ";exp env direct (.032): ~A ~A" val (vct-ref v i))))))
      
      (let ((e1 (make-env '(0 0 1 1) :base .03125 :length 11))
	    (e2 (make-env '(0 0 1 1 2 0) :base 32.0 :length 11))
	    (e3 (make-env '(0 0 .1 1 2 0) :base 1.1 :length 101)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (let ((lv1 (env-interp (* i .1) e1))
		(lv2 (env e1))
		(lv3 (env-interp (* i .2) e2))
		(lv4 (env e2)))
	    (if (ffneq lv1 lv2) (snd-display #__line__ ";env-interp[rmp ~F]: ~A (~A)?" (* .1 i) lv1 lv2))
	    (if (ffneq lv3 lv4) (snd-display #__line__ ";env-interp[pyr ~F]: ~A (~A)?" (* .2 i) lv3 lv4))))
	(do ((i 0 (+ 1 i)))
	    ((= i 100))
	  (let ((lv5 (env-interp (* i .02) e3))
		(lv6 (env e3)))
	    (if (ffneq lv5 lv6) (snd-display #__line__ ";env-interp[tri ~F]: ~A (~A)?" (* .02 i) lv5 lv6)))))
      
      (let ((e1 (make-env '(0 0 1 1 2 0) :length 10))
	    (lv1 (make-vct 11))
	    (lv2 (make-vct 11))
	    (lv3 (make-vct 11)))
	(do ((i 0 (+ 1 i))) ((= i 11)) (vct-set! lv1 i (env e1)))
	(do ((i 0 (+ 1 i))) ((= i 11)) (vct-set! lv2 i (env e1)))
	(mus-reset e1)
	(do ((i 0 (+ 1 i))) ((= i 11)) (vct-set! lv3 i (env e1)))
	(if (not (vequal lv1 lv3)) (snd-display #__line__ ";mus-reset: ~A ~A?" lv1 lv3))
	(if (not (vequal lv2 (make-vct 11))) (snd-display #__line__ ";mus-reset 1: ~A?" lv2)))
      
      (set! gen (make-env '(0 0 1 1 2 0) :length 11))
      (do ((i 0 (+ 1 i))) ((= i 4)) (env gen))
      (let ((val (env gen)))
	(if (fneq val .8) (snd-display #__line__ ";env(5): ~A?" val))
	(mus-reset gen)
	(do ((i 0 (+ 1 i))) ((= i 4)) (env gen))
	(set! val (env gen))
	(if (fneq val .8) (snd-display #__line__ ";mus-reset (via reset): ~A?" val))
	(set! (mus-location gen) 6)
	(let ((val (env gen)))
	  (if (fneq val 0.8) (snd-display #__line__ ";set! mus-location 6 -> ~A (0.8)?" val)))))
    
    (let ((gen (make-env '(0 0 1 1) :base .032 :length 12)))
      (set! (mus-location gen) 5)
      (let ((val (env gen)))
	(if (fneq val 0.817)
	    (snd-display #__line__ ";set env location with base: ~A ~A" val gen))))
    (let ((gen (make-env '(0 0 1 1) :base .032 :length 12)))
      (set! (mus-location gen) 5)
      (let ((val (env gen)))
	(if (fneq val 0.817)
	    (snd-display #__line__ ";set env location with base and dur: ~A ~A" val gen))))
    
    (test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.25 :length 10))
    (test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 11))
    (test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '(0 0 1 1 3 0) :scaler 0.5 :length 10))
    (test-gen-equal (make-env '((0 0) (1 1) (2 0)) :scaler 0.5 :length 10) (make-env '(0 0 1 1 2 0) :scaler 0.5 :length 10) (make-env '((0 0) (1 1) (3 0)) :scaler 0.5 :length 10))
    
    (let ((var (catch #t (lambda () (make-env :envelope '())) (lambda args args))))
      (if (not (eq? (car var) 'no-data))
	  (snd-display #__line__ ";make-env null env: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :length 1)) (lambda args args))))
      (if (not (eq? (car var) 'no-data))
	  (snd-display #__line__ ";make-env no env: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(0 0) :length -1)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-env bad dur: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(0 0) :duration -1.0)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-env bad duration: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(0 0) :base -1.0)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-env bad base: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(1 1 0 0) :length 11)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-env bad env 1 1 0 0: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(0 1 -1 0) :length 11)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-env bad env 0 1 -1 0: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(0 1 1 0) :length 11 :length 10)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-env bad end/dur: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope '(0 0 1 1 2 0 1) :duration 1.0)) (lambda args args))))
      (if (not (eq? (car var) 'bad-type))
	  (snd-display #__line__ ";make-env odd length env: ~A" var)))
    (let ((var (catch #t (lambda () (make-env :envelope (list "hi" 0 1 1 2 0) :duration 1.0)) (lambda args args))))
      (if (not (eq? (car var) 'wrong-type-arg))
	  (snd-display #__line__ ";make-env env of non-number: ~A" var)))
    
    ;; env-any
    (let* ((env-any-1 (lambda (e func)
			(let* ((pts (mus-data e))
			       (mus-position mus-channels)
			       (pt (min (* 2 (mus-position e)) (- (vct-length pts) 4)))
			       (val (/ (- (env e) (mus-offset e)) (mus-scaler e)))
			       (y0 (min (vct-ref pts (+ pt 1)) (vct-ref pts (+ pt 3))))
			       (y1 (max (vct-ref pts (+ pt 1)) (vct-ref pts (+ pt 3))))
			       (new-val (func (/ (- val y0) (- y1 y0)))))
			  (+ (mus-offset e)
			     (* (mus-scaler e)
				(+ y0
				   (* (- y1 y0) new-val)))))))
	   (sine-env-1 (lambda (e)
			 (env-any-1 e (lambda (y)
					(* 0.5 (+ 1.0 (sin (+ (* -0.5 pi) 
							      (* pi y)))))))))
	   (square-env-1 (lambda (e)
			   (env-any-1 e (lambda (y)
					  (* y y)))))
	   
	   (blackman4-env-1 (lambda (e)
			      (env-any-1 e (lambda (y)
					     (let ((cx (cos (* pi y))))
					       (+ 0.084037 (* cx (+ -.29145 (* cx (+ .375696 (* cx (+ -.20762 (* cx .041194)))))))))))))
	   
	   (multi-expt-env-1 (lambda (e expts)
			       (env-any-1 e (lambda (y)
					      (let ((b (vct-ref expts (modulo (mus-channels e) (vct-length expts)))))
						(/ (- (expt b y) 1.0) (- b 1.0))))))))
      
      
      
      ;; assume sine-env square-env blackman4-env and multi-exp-env are available from generators.scm (8)
      
      (let ((val1 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (sine-env e))))))
	    
	    (val2 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 20))
				   (outa i (sine-env e)))))))
	    
	    (val3 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (sine-env-1 e)))))))
	(if (not (vequal val1 val2))
	    (snd-display #__line__ ";sine-env straight and run: ~%;  ~A~%;  ~A" val1 val2))
	(if (not (vequal val1 val3))
	    (snd-display #__line__ ";sine-env straight and scm: ~%;  ~A~%;  ~A" val1 val3)))
      
      
      (let ((val1 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (square-env e))))))
	    
	    (val2 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 20))
				   (outa i (square-env e)))))))
	    
	    (val3 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (square-env-1 e)))))))
	(if (not (vequal val1 val2))
	    (snd-display #__line__ ";square-env straight and run: ~%;  ~A~%;  ~A" val1 val2))
	(if (not (vequal val1 val3))
	    (snd-display #__line__ ";square-env straight and scm: ~%;  ~A~%;  ~A" val1 val3)))
      
      (let ((val1 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (blackman4-env e))))))
	    
	    (val2 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(run
				 (lambda ()
				   (do ((i 0 (+ 1 i)))
				       ((= i 20))
				     (outa i (blackman4-env e))))))))
	    
	    (val3 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (blackman4-env-1 e)))))))
	(if (not (vequal val1 val2))
	    (snd-display #__line__ ";blackman4-env straight and run: ~%;  ~A~%;  ~A" val1 val2))
	(if (not (vequal val1 val3))
	    (snd-display #__line__ ";blackman4-env straight and scm: ~%;  ~A~%;  ~A" val1 val3)))
      
      
      (let ((val1 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20))
				    (bases (vct 32.0 0.3 1.5)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (multi-expt-env e bases))))))
	    
	    (val2 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20))
				    (bases (vct 32.0 0.3 1.5)))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 20))
				   (outa i (multi-expt-env e bases)))))))
	    
	    (val3 (with-sound (:output (make-vct 20))
			      (let ((e (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 20))
				    (bases (vct 32.0 0.3 1.5)))
				(do ((i 0 (+ 1 i)))
				    ((= i 20))
				  (outa i (multi-expt-env-1 e bases)))))))
	(if (not (vequal val1 val2))
	    (snd-display #__line__ ";multi-expt-env straight and run: ~%;  ~A~%;  ~A" val1 val2))
	(if (not (vequal val1 val3))
	    (snd-display #__line__ ";multi-expt-env straight and scm: ~%;  ~A~%;  ~A" val1 val3)))
      
      (let ((val1 (with-sound (:output (make-vct 220))
			      (let ((e1 (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 220))
				    (e2 (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 220)))
				(do ((i 0 (+ 1 i)))
				    ((= i 220))
				  (outa i (env-any e1
						   (lambda (y1)
						     (declare (y1 float))
						     (* y1 (env-any e2
								    (lambda (y2)
								      (declare (y2 float))
								      y2))))))))))
	    (val2 (with-sound (:output (make-vct 220))
			      (let ((e1 (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 220))
				    (e2 (make-env '(0 0 1 1 2 .25 3 1 4 0) :length 220)))
				(run 
				 (do ((i 0 (+ 1 i)))
				     ((= i 220))
				   (outa i (env-any e1 ; try it with and without "declare"
						    (lambda (y1)
						      (* y1 (env-any e2
								     (lambda (y2)
								       (declare (y2 float))
								       y2))))))))))))
	(if (not (vequal val1 val2))
	    (snd-display #__line__ ";env-any recursive: ~%;  ~A~%;  ~A" val1 val2))))
    
    (let ((ind (new-sound :size 20)))
      (select-sound ind)
      (map-channel (lambda (y) 1.0))
      (bumpy)
      (let ((vals (channel->vct)))
	(if (not (vequal vals (vct 0.0 0.0 0.001 0.021 0.105 0.264 0.467 0.673 0.846 0.960 1.000 0.960 0.846 0.673 0.467 0.264 0.105 0.021 0.001 0.0)))
	    (snd-display #__line__ ";bumpy: ~A" vals)))
      (if (fneq (channel-lp-inf) 1.0) ; just a fancy name for maxamp
	  (snd-display #__line__ ";channel-lp-inf: ~A" (channel-lp-inf)))
      (linear-src-channel 2.0)
      (let ((vals (channel->vct)))
	(if (not (vequal vals (vct 0.000 0.001 0.105 0.467 0.846 1.000 0.846 0.467 0.105 0.001)))
	    (snd-display #__line__ ";linear-src-channel: ~A" vals)))
      (let ((old-clip (clipping)))
	(set! (clipping) #t)
	(save-sound-as "tst.snd")
	(let ((fvals (file->vct "tst.snd")) ; in frame.scm
	      (vals (channel->vct)))
	  (if (not (vequal vals fvals))
	      (snd-display #__line__ ";file->vct: ~A ~A" vals fvals)))
	(mus-sound-forget "tst.snd")
	(delete-file "tst.snd")
	(set! (clipping) old-clip))
      (let ((hp (make-differentiator)))
	(map-channel (lambda (y)
		       (differentiator hp y))))
      (if (fneq (maxamp) .0013)
	  (snd-display #__line__ ";differentiator: ~A" (maxamp)))
      (revert-sound ind)
      (let ((val (window-rms)))
	(if (fneq val 0.0) (snd-display #__line__ ";window-rms empty: ~A" val))
	(set! (sample 10) 1.0)
	(set! val (window-rms))
	(if (fneq val .218) (snd-display #__line__ ";window-rms 1: ~A" val))
	(let ((vals (window-samples)))
	  (if (or (not (vct? vals))
		  (not (= (vct-length vals) 21))
		  (fneq (vct-ref vals 10) 1.0))
	      (snd-display #__line__ ";window-samples: ~A" vals))))
      (revert-sound ind)
      (let ((new-file-name (file-name ind)))
	(close-sound ind)
	(if (file-exists? new-file-name) (delete-file new-file-name))))
    
    (let ((gen (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1))))
	  (gen1 (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1) (make-vct 512))))
	  (gen2 (partials->wave '(1 1 2 1 3 1 4 1) #f #t))
	  (gen3 (make-table-lookup))
	  (v0 (make-vct 10))
	  (v1 (make-vct 10))
	  (gen4 (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1))))
	  (v2 (make-vct 10)))
      (print-and-check gen 
		       "table-lookup"
		       "table-lookup freq: 440.000Hz, phase: 0.000, length: 512, interp: linear")
      (if (not (= (mus-length gen) 512)) (snd-display #__line__ ";table-lookup length: ~A?" (mus-length gen)))
      (if (not (= (mus-length gen3) 512)) (snd-display #__line__ ";default table-lookup length: ~A?" (mus-length gen3)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (table-lookup gen 0.0))
	(vct-set! v1 i (mus-apply gen1 0.0)))
      (vct-map! v2 (lambda () (if (table-lookup? gen4) (table-lookup gen4 0.0) -1.0)))
      (if (not (vequal v0 v2)) (snd-display #__line__ ";map table-lookup: ~A ~A" v0 v2))
      (set! gen4 (make-table-lookup 440.0 :wave (partials->wave (vct 1 1 2 1))))
      (vct-map! v2 (lambda () (table-lookup gen4)))
      (if (not (vequal v0 v2)) (snd-display #__line__ ";map table-lookup (no fm): ~A ~A" v0 v2))
      (if (not (table-lookup? gen)) (snd-display #__line__ ";~A not table-lookup?" gen))
      (if (not (vct? (mus-data gen))) (snd-display #__line__ ";mus-data table-lookup: ~A" (mus-data gen)))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";table-lookup phase: ~F?" (mus-phase gen)))
      (set! (mus-phase gen) 1.0)
      (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";set! table-lookup phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";table-lookup frequency: ~F?" (mus-frequency gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";set! table-lookup frequency: ~F?" (mus-frequency gen)))
      (if (or (fneq (vct-ref v0 1) 0.373) (fneq (vct-ref v0 8) 1.75)) (snd-display #__line__ ";table-lookup output: ~A" v0))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (fneq (vct-ref v0 i) (vct-ref v1 i))
	    (snd-display #__line__ ";mus-apply table-lookup at ~D: ~A ~A?" i (vct-ref v0 i) (vct-ref v1 i))))
      (set! gen (make-table-lookup 440.0 :wave (phase-partials->wave (list 1 1 0 2 1 (* pi .5)))))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (table-lookup gen 0.0)))
      (if (or (fneq (vct-ref v0 1) 1.094) (fneq (vct-ref v0 8) .421)) (snd-display #__line__ ";table-lookup phase output: ~A" v0))
      (if (or (fneq (vct-peak (partials->wave '(1 1 2 1))) 1.76035475730896)
	      (fneq (vct-peak (partials->wave '(1 1 2 1) #f #t)) 1.0)
	      (fneq (vct-peak (partials->wave '(1 1 2 1 3 1 4 1) #f #t)) 1.0))
	  (snd-display #__line__ ";normalized partials?"))
      (set! (mus-data gen) (phase-partials->wave (list 1 1 0 2 1 (* pi .5)) #f #t)))
    
    (let ((tag (catch #t (lambda () (phase-partials->wave (list 1 .3 2 .2))) (lambda args (car args)))))
      (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";bad length arg to phase-partials->wave: ~A" tag)))
    (let ((tag (catch #t (lambda () (phase-partials->wave (list "hiho" .3 2 .2))) (lambda args (car args)))))
      (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";bad harmonic arg to phase-partials->wave: ~A" tag)))
    (let ((tag (catch #t (lambda () (phase-partials->wave (list))) (lambda args (car args)))))
      (if (not (eq? tag 'no-data)) (snd-display #__line__ ";nil list to phase-partials->wave: ~A" tag)))
    
    (let ((vals (phase-partials->wave (list 1 1 0) (make-vct 16) #f)))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(if (fneq (vct-ref vals i) (sin (/ (* 2 pi i) 16)))
	    (snd-display #__line__ ";phase-partials->wave 1 1 0 at ~D: ~A ~A" i (vct-ref vals i) (sin (/ (* 2 pi i) 16))))))
    
    (let ((vals (phase-partials->wave (list 1 1 (* .25 pi)) (make-vct 16) #f)))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(if (fneq (vct-ref vals i) (sin (+ (* .25 pi) (/ (* 2 pi i) 16))))
	    (snd-display #__line__ ";phase-partials->wave 1 1 .25 at ~D: ~A ~A" i (vct-ref vals i) (sin (+ (* .25 pi) (/ (* 2 pi i) 16)))))))
    
    (let ((vals (phase-partials->wave (vct 1 1 0 2 1 0) (make-vct 16) #f)))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(if (fneq (vct-ref vals i) (+ (sin (/ (* 2 pi i) 16)) (sin (/ (* 4 pi i) 16))))
	    (snd-display #__line__ ";phase-partials->wave 1 1 0 2 1 0 at ~D: ~A ~A" i (vct-ref vals i) 
			 (+ (sin (/ (* 2 pi i) 16)) (sin (/ (* 4 pi i) 16)))))))
    
    (let ((vals (phase-partials->wave (vct 1 1 0 2 1 (* .5 pi)) (make-vct 16) #f)))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(if (fneq (vct-ref vals i) (+ (sin (/ (* 2 pi i) 16)) (sin (+ (* .5 pi) (/ (* 4 pi i) 16)))))
	    (snd-display #__line__ ";phase-partials->wave 1 1 0 2 1 .5 at ~D: ~A ~A" i (vct-ref vals i) 
			 (+ (sin (/ (* 2 pi i) 16)) (sin (+ (* .5 pi) (/ (* 4 pi i) 16))))))))
    
    (test-gen-equal (make-table-lookup 440.0 :wave (partials->wave (vct 1 1 2 1)))
		    (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))
		    (make-table-lookup 100.0 :wave (partials->wave '(1 1 2 1))))
    (test-gen-equal (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))
		    (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1)))
		    (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 .5))))
    (test-gen-equal (make-table-lookup-with-env 440.0 '(0 0 1 1))
		    (make-table-lookup-with-env 440.0 (list 0 0 1 1))
		    (make-table-lookup-with-env 440.0 '(0 0 1 1 2 0)))
    (let ((tag (catch #t (lambda () (partials->wave (list .5 .3 .2))) (lambda args (car args)))))
      (if (not (eq? tag 'bad-type)) (snd-display #__line__ ";odd length arg to partials->wave: ~A" tag)))
    
    (let ((hi (make-table-lookup :size 256)))
      (if (not (= (mus-length hi) 256)) (snd-display #__line__ ";table-lookup set length: ~A?" (mus-length hi))))
    (let ((tag (catch #t (lambda () (make-table-lookup :size 0)) (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range)) (snd-display #__line__ ";table-lookup size 0: ~A" tag)))
    
    (let ((gen (make-table-lookup 440.0 :wave (partials->wave '(1 1)))))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 440.0) 22050.0))))
	  ((= i 1100))
	(let* ((val1 (sin a))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";table lookup (1 1): ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen (make-table-lookup 4.0 :wave (partials->wave '(1 1)))))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 4.0) 22050.0))))
	  ((= i 1100))
	(let* ((val1 (sin a))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";table lookup (1 1) 4: ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen (make-table-lookup 440.0 :wave (partials->wave '(1 .75 3 .25)))))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 440.0) 22050.0))))
	  ((= i 1100))
	(let* ((val1 (+ (* .75 (sin a)) (* .25 (sin (* 3 a)))))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";table lookup (1 .75 3 .25): ~A: ~A ~A" i val1 val2)))))
    
    (let ((gen (make-table-lookup 0.0 :wave (partials->wave '(1 1))))
	  (gen1 (make-table-lookup 40.0 :wave (partials->wave '(1 1))))
	  (a1 0.0))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 40.0) 22050.0))))
	  ((= i 100))
	(let* ((fm (sin a))
	       (val1 (sin a1))
	       (val2 (table-lookup gen (table-lookup gen1 0.0))))
	  (set! a1 (+ a1 fm))
	  (if (fneq val1 val2)
	      (snd-display #__line__ ";lookup/lookup fm: ~A: ~A ~A" i val1 val2)))))
    
    (for-each 
     (lambda (args)
       (let ((type (car args))
	     (vals (cadr args)))
	 (let* ((tbl1 (make-table-lookup :frequency 0.0 :size 4 :type type)))
	   (vct-set! (mus-data tbl1) 1 1.0)
	   (let ((v (make-vct 10)))
	     (do ((i 0 (+ 1 i)))
		 ((= i 10))
	       (vct-set! v i (table-lookup tbl1 (/ (* 2 pi .2) 4))))
	     (if (and (not (vequal v vals))
		      (not (= type mus-interp-all-pass))
		      (or (not (= type mus-interp-none))
			  (not (vequal v (vct 0.000 0.000 0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000)))))
		 (snd-display #__line__ ";tbl interp ~A: ~A" type v))
	     (if (not (= (mus-interp-type tbl1) type)) (snd-display #__line__ ";tbl interp-type (~A): ~A" type (mus-interp-type tbl1)))))))
     (list 
      (list mus-interp-none (vct 0.000 0.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 1.000))
      (list mus-interp-linear (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200))
      (list mus-interp-lagrange (vct 0.000 0.120 0.280 0.480 0.720 1.000 0.960 0.840 0.640 0.360))
      (list mus-interp-all-pass (vct 1.000 0.000 0.429 0.143 0.095 0.905 0.397 0.830 0.793 0.912))
      (list mus-interp-hermite (vct 0.000 0.168 0.424 0.696 0.912 1.000 0.912 0.696 0.424 0.168))))
    ;; this is different if doubles -- not sure whether it's a bug or not
    
    (let ((size 1000)
	  (tbl-size 1024))
      
      (define (test-tbl beg end freq amp mc-ratio index)
	(let* ((sine (let ((v (make-vct tbl-size)))
		       (do ((i 0 (+ 1 i))
			    (x 0.0 (+ x (/ (* 2 pi) tbl-size))))
			   ((= i tbl-size) v)
			 (vct-set! v i (sin x)))))
	       (fm (make-table-lookup (* mc-ratio freq) :wave sine))
	       (carrier (make-table-lookup freq :wave sine)))
	  (do ((i beg (+ 1 i)))
	      ((= i end))
	    (outa i (* amp (table-lookup carrier (* index (table-lookup fm))))))))
      
      (define (test-fm1 beg end freq amp mc-ratio index)
	(let ((fm (make-oscil (* mc-ratio freq)))
	      (carrier (make-oscil freq)))
	  (do ((i beg (+ 1 i)))
	      ((= i end))
	    (outa i (* amp (oscil carrier (* index (oscil fm))))))))
      
      (let ((v1 (with-sound (:output (make-vct size) :srate 44100) (test-tbl 0 size 200 1 1 1)))
	    (v2 (with-sound (:output (make-vct size) :srate 44100) (test-fm1 0 size 200 1 1 1))))
	(if (and (not (vequal v1 v2))
		 (> (vct-peak (vct-subtract! v1 v2)) .002))
	    (snd-display #__line__ ";fm/tbl peak diff (1 1): ~A" (vct-peak (vct-subtract! v1 v2)))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((ratio (+ 1 (random 4)))
	      (index (random 0.1)))
	  (let ((v1 (with-sound (:output (make-vct size) :srate 44100) (test-tbl 0 size 20 1 ratio index)))
		(v2 (with-sound (:output (make-vct size) :srate 44100) (test-fm1 0 size 20 1 ratio index))))
	    (if (and (not (vequal v1 v2))
		     (> (vct-peak (vct-subtract! v1 v2)) .002))
		(snd-display #__line__ ";fm/tbl peak diff ~A ~A: ~A" ratio index (vct-peak (vct-subtract! v1 v2))))))))
    
    
    (let ((gen0 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1))))
	  (gen (make-polyshape 440.0 :partials '(1 1) :kind mus-chebyshev-first-kind))
	  (v0 (make-vct 10))
	  (gen1 (make-polyshape 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "polyshape"
		       "polyshape freq: 440.000Hz, phase: 0.000, coeffs[2]: [0.000 1.000]")
      (if (not (= (mus-length gen) 2)) (snd-display #__line__ ";polyshape length: ~A?" (mus-length gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((val0 (polyshape gen0 1.0 0.0))
	      (val (polyshape gen 1.0 0.0)))
	  (if (fneq val val0) (snd-display #__line__ ";polyshape: ~A /= ~F?" val val0))
	  (vct-set! v0 i val)))
      (vct-map! v1 (lambda () (if (polyshape? gen1) (polyshape gen1 1.0 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map polyshape: ~A ~A" v0 v1))
      (set! gen1 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1))))
      (vct-map! v1 (lambda () (polyshape gen1 1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";1 map polyshape: ~A ~A" v0 v1))
      (if (not (polyshape? gen)) (snd-display #__line__ ";~A not polyshape?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";polyshape phase: ~F?" (mus-phase gen)))
      (set! (mus-phase gen) 1.0)
      (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";set! polyshape phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";polyshape frequency: ~F?" (mus-frequency gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";polyshape frequency: ~F?" (mus-frequency gen)))
      (if (not (vct? (mus-data gen))) (snd-display #__line__ ";mus-data polyshape: ~A" (mus-data gen)))
      (if (or (fneq (vct-ref v0 1) 0.992) (fneq (vct-ref v0 8) 0.538)) (snd-display #__line__ ";polyshape output: ~A" v0))
      (set! (mus-data gen0) (make-vct 32))
      (set! (mus-length gen0) 32)
      (if (not (= (mus-length gen0) 32)) (snd-display #__line__ ";set mus-length polyshape: ~A" (mus-length gen0))))
    
    (test-gen-equal (make-polyshape 440.0 :partials '(1 1)) 
		    (make-polyshape 440.0) 
		    (make-polyshape 100.0 :partials '(1 1)))
    (test-gen-equal (make-polyshape 440.0 :partials '(1 1)) 
		    (make-polyshape 440.0)
		    (make-polyshape 440.0 :partials '(1 1 2 .5)))
    (test-gen-equal (make-polyshape 440.0 :partials '(1 1)) 
		    (make-polyshape 440.0 :partials (vct 1 1))
		    (make-polyshape 440.0 :partials '(1 .5)))
    (test-gen-equal (make-polyshape 440.0 :partials (list 1 .1 2 1 3 .5))
		    (make-polyshape 440.0 :partials (vct 1 .1 2 1 3 .5))
		    (make-polyshape 440.0 :partials '(1 .1 2 .1 3 .5)))
    
    (let ((gen (make-polyshape 440.0 :partials '(1 1)))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 1100)))
	(let* ((a (mus-phase gen))
	       (val1 (cos a))
	       (val2 (gen 1.0 0.0)))
	  (if (fneq val1 val2)
	      (begin
		(snd-display #__line__ ";polyshaper (1 1) ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (let ((gen (make-polyshape 440.0)) ; check default for partials: '(1 1)
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy)
	       (= i 1100)))
	(let* ((a (mus-phase gen))
	       (val1 (cos a))
	       (val2 (gen 1.0 0.0)))
	  (if (fneq val1 val2)
	      (begin
		(snd-display #__line__ ";polyshaper default: '(1 1) ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (let ((gen (make-polyshape 440.0 :partials (vct 1 1)))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 1100)))
	(let* ((a (mus-phase gen))
	       (val1 (* .5 (cos a)))
	       (val2 (gen 0.5 0.0)))
	  (if (fneq val1 val2)
	      (begin
		(snd-display #__line__ ";polyshaper (1 1) .5 index ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (let ((var (catch #t (lambda () (make-polyshape 440.0 :coeffs 3.14)) (lambda args args))))
      (if (not (eq? (car var) 'wrong-type-arg))
	  (snd-display #__line__ ";make-polyshape bad coeffs: ~A" var)))
    
    (let ((gen (make-polyshape 0.0 :coeffs (partials->polynomial '(1 1))))
	  (gen1 (make-polyshape 40.0 :coeffs (partials->polynomial '(1 1))))
	  (a1 0.0)
	  (happy #t))
      (do ((i 0 (+ 1 i))
	   (a 0.0 (+ a (/ (* 2 pi 40.0) 22050.0))))
	  ((or (not happy) (= i 400)))
	(let* ((fm (cos a))
	       (val1 (cos a1))
	       (val2 (polyshape gen 1.0 (polyshape gen1 1.0))))
	  (set! a1 (+ a1 fm))
	  (if (> (abs (- val1 val2)) .002)
	      (begin
		(snd-display #__line__ ";polyshape fm: ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (for-each 
     (lambda (amps name)
       (let* ((n (vct-length amps))
	      (angle 0.0)
	      (incr (hz->radians 1.0))
	      (happy #t))
	 (do ((i 0 (+ 1 i)))
	     ((or (not happy) (= i 100)))
	   (let ((sum (vct-ref amps 0))
		 (cval (mus-chebyshev-t-sum angle amps)))
	     (do ((k 1 (+ 1 k)))
		 ((= k n))
	       (set! sum (+ sum (* (vct-ref amps k) (cos (* k angle))))))
	     (set! angle (+ angle incr))
	     (if (fneq cval sum)
		 (begin
		   (snd-display #__line__ ";cheb-t-sum ~A: [~D] ~A ~A" name i cval sum)
		   (set! happy #f)))))))
     (list (vct 0.0 1.0)
	   (vct 0.0 0.5 0.25 0.25)
	   (make-vct 100 0.01)
	   (make-vct 1000 0.001))
     (list 'one-cos
	   'three-cos
	   'hundred-cos
	   'thousand-cos))
    
    (for-each 
     (lambda (amps name)
       (let* ((n (vct-length amps))
	      (angle 0.0)
	      (incr (hz->radians 1.0))
	      (happy #t))
	 (do ((i 0 (+ 1 i)))
	     ((or (not happy) (= i 100)))
	   (let ((sum 0.0)
		 (cval (mus-chebyshev-u-sum angle amps))) ; * sin is embedded in func
	     (do ((k 1 (+ 1 k)))
		 ((= k n))
	       (set! sum (+ sum (* (vct-ref amps k) (sin (* k angle))))))
	     (set! angle (+ angle incr))
	     (if (fneq cval sum)
		 (begin
		   (snd-display #__line__ ";cheb-u-sum ~A: [~D] ~A ~A" name i cval sum)
		   (set! happy #f)))))))
     (list (vct 0.0 1.0)
	   (vct 0.0 0.5 0.25 0.25)
	   (make-vct 100 0.01)
	   (make-vct 1000 0.001))
     (list 'one-cos
	   'three-cos
	   'hundred-cos
	   'thousand-cos))
    
    (for-each 
     (lambda (camps samps name)
       (let* ((n (vct-length camps))
	      (angle 0.0)
	      (incr (hz->radians 1.0))
	      (happy #t))
	 (do ((i 0 (+ 1 i)))
	     ((or (not happy) (= i 100)))
	   (let ((sum (vct-ref camps 0))
		 (cval (mus-chebyshev-tu-sum angle camps samps)))
	     (do ((k 1 (+ 1 k)))
		 ((= k n))
	       (set! sum (+ sum (+ (* (vct-ref samps k) (sin (* k angle)))
				   (* (vct-ref camps k) (cos (* k angle)))))))
	     (set! angle (+ angle incr))
	     (if (fneq cval sum)
		 (begin
		   (snd-display #__line__ ";cheb-tu-sum ~A: [~D] ~A ~A" name i cval sum)
		   (set! happy #f)))))))
     (list (vct 0.0 1.0)
	   (vct 0.0 0.25 0.0 0.25)
	   (make-vct 100 .004)
	   (make-vct 1000 0.0005))
     (list (vct 0.0 0.0)
	   (vct 0.0 0.25 0.25 0.0)
	   (make-vct 100 .006)
	   (make-vct 1000 0.0005))
     (list 'one-tu
	   'three-tu
	   'hundred-tu
	   'thousand-tu))
    
    (for-each
     (lambda (n)
       (let ((distance (test-polyoid n)))
	 (if (fneq distance 0.0)
	     (snd-display #__line__ ";test polyoid ~A ~A" n distance))))
     (list 1 3 10))
    
    (for-each
     (lambda (n)
       (let ((distance (test-polyoid-run n)))
	 (if (fneq distance 0.0)
	     (snd-display #__line__ ";test polyoid run ~A ~A" n distance))))
     (list 1 8 32 100))
    
    ;; polywave
    (let ((gen0 (make-polywave 440.0 '(1 1)))
	  (gen (make-polywave 440.0 :partials '(1 1) :type mus-chebyshev-first-kind))
	  (v0 (make-vct 10))
	  (gen1 (make-polywave 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "polywave"
		       "polywave freq: 440.000Hz, phase: 0.000, coeffs[2]: [0.000 1.000]")
      (if (not (= (mus-length gen) 2)) (snd-display #__line__ ";polywave length: ~A?" (mus-length gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((val0 (polywave gen0 0.0))
	      (val (polywave gen 0.0)))
	  (if (fneq val val0) (snd-display #__line__ ";polywave: ~A /= ~F?" val val0))
	  (vct-set! v0 i val)))
      (vct-map! v1 (lambda () (if (polywave? gen1) (polywave gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map polywave: ~A ~A" v0 v1))
      (set! gen1 (make-polywave 440.0 (vct 1 1)))
      (vct-map! v1 (lambda () (polywave gen1)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";1 map polywave: ~A ~A" v0 v1))
      (if (not (polywave? gen)) (snd-display #__line__ ";~A not polywave?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";polywave phase: ~F?" (mus-phase gen)))
      (set! (mus-phase gen) 1.0)
      (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";set! polywave phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";polywave frequency: ~F?" (mus-frequency gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";polywave frequency: ~F?" (mus-frequency gen)))
      (if (not (vct? (mus-data gen))) (snd-display #__line__ ";mus-data polywave: ~A" (mus-data gen)))
      (if (or (fneq (vct-ref v0 1) 0.992) (fneq (vct-ref v0 8) 0.538)) (snd-display #__line__ ";polywave output: ~A" v0)))
    
    (test-gen-equal (make-polywave 440.0 :partials '(1 1)) 
		    (make-polywave 440.0) 
		    (make-polywave 100.0 :partials '(1 1)))
    (test-gen-equal (make-polywave 440.0 '(1 1)) 
		    (make-polywave 440.0)
		    (make-polywave 440.0 '(1 1 2 .5)))
    (test-gen-equal (make-polywave 440.0 '(1 1)) 
		    (make-polywave 440.0 (vct 1 1))
		    (make-polywave 440.0 '(1 .5)))
    (test-gen-equal (make-polywave 440.0 (list 1 .1 2 1 3 .5))
		    (make-polywave 440.0 (vct 1 .1 2 1 3 .5))
		    (make-polywave 440.0 '(1 .1 2 .1 3 .5)))
    
    (let ((gen (make-polywave 440.0 '(1 1)))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 1100)))
	(let* ((a (mus-phase gen))
	       (val1 (cos a))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (begin
		(snd-display #__line__ ";polywaver (1 1) ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (let ((gen (make-polywave 440.0)) ; check default for partials: '(1 1)
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 1100)))
	(let* ((a (mus-phase gen))
	       (val1 (cos a))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (begin
		(snd-display #__line__ ";polywaver default: '(1 1) ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (let ((gen (make-polywave 440.0 (vct 1 1)))
	  (happy #t))
      (set! (mus-scaler gen) 0.5)
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 1100)))
	(let* ((a (mus-phase gen))
	       (val1 (* .5 (cos a)))
	       (val2 (gen 0.0)))
	  (if (fneq val1 val2)
	      (begin
		(snd-display #__line__ ";polywaver (1 1) .5 index ~A: ~A ~A" i val1 val2)
		(set! happy #f))))))
    
    (let ((old-srate (mus-srate)))
      (set! (mus-srate) 44100)
      (for-each
       (lambda (k)
	 (let ((gen (make-polywave 100.0 (list 1 0.5 k 0.5))))
	   (let ((err 0.0)
		 (err-max 0.0)
		 (err-max-loc -1))
	     (do ((i 0 (+ 1 i)))
		 ((>= i 44100))
	       (let* ((ph (mus-phase gen))
		      (gval (polywave gen))
		      (sval (* 0.5 (+ (cos ph)
				      (cos (* k ph)))))
		      (err-local (abs (- sval gval))))
		 (if (> err-local err-max)
		     (begin
		       (set! err-max-loc i)
		       (set! err-max err-local)))
		 (set! err (+ err err-local))))
	     (if (> err-max 2.0e-3)
		 (snd-display #__line__ ";polywave vs sin: ~D: ~A ~A ~A" k err err-max err-max-loc)))))
       (list 2 19 20 29 30 39 40 60 100))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polywave 100.0 (list n 1.0)))
	       (gen2 (make-oscil (* n 100.0) (/ pi 2)))
	       (happy #t))
	   (do ((i 0 (+ 1 i)))
	       ((or (not happy) (= i 1000)))
	     (let ((val1 (polywave gen1))
		   (val2 (oscil gen2)))
	       (if (fneq val1 val2)
		   (begin
		     (set! happy #f)
		     (snd-display #__line__ ";polywave ~A at ~A: ~A ~A" n i val1 val2)))))))
       (list 1 8 50 128))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polywave 100.0 (list n 1.0) mus-chebyshev-second-kind))
	       (gen2 (make-oscil (* n 100.0)))
	       (happy #t))
	   (do ((i 0 (+ 1 i)))
	       ((or (not happy) (= i 1000)))
	     (let ((val1 (polywave gen1))
		   (val2 (oscil gen2)))
	       (if (fneq val1 val2)
		   (begin
		     (set! happy #f)
		     (snd-display #__line__ ";polywave 2nd ~A at ~A: ~A ~A" n i val1 val2)))))))
       (list 1 8 50 128))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polyshape 100.0 :partials (list n 1.0)))
	       (gen2 (make-oscil (* n 100.0) (/ pi 2)))
	       (happy #t))
	   (do ((i 0 (+ 1 i)))
	       ((or (not happy) (= i 1000)))
	     (let ((val1 (polyshape gen1))
		   (val2 (oscil gen2)))
	       (if (fneq val1 val2)
		   (begin
		     (set! happy #f)
		     (snd-display #__line__ ";polyshape ~A at ~A: ~A ~A" n i val1 val2)))))))
       (list 1 8 16))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polyshape 100.0 :partials (list n 1.0) :kind mus-chebyshev-second-kind))
	       (gen2 (make-oscil (* n 100.0)))
	       (happy #t))
	   (do ((i 0 (+ 1 i)))
	       ((or (not happy) (= i 1000)))
	     (let ((val1 (polyshape gen1))
		   (val2 (oscil gen2)))
	       (if (fneq val1 val2)
		   (begin
		     (set! happy #f)
		     (snd-display #__line__ ";polyshape 2nd ~A at ~A: ~A ~A" n i val1 val2)))))))
       (list 1 8 16))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polywave 100.0 (list n 1.0) mus-chebyshev-first-kind))
	       (gen2 (make-oscil (* n 100.0) (/ pi 2)))
	       (max-dist 0.0))
	   (run 
	    (do ((i 0 (+ 1 i)))
		((= i 1000))
	      (let ((val1 (polywave gen1))
		    (val2 (oscil gen2)))
		(set! max-dist (max max-dist (abs (- val1 val2)))))))
	   (if (fneq max-dist 0.0)
	       (snd-display #__line__ ";polywave run ~A: ~A ~A" n val1 val2))))
       (list 1 3 30 200))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polywave 100.0 (list n 1.0) mus-chebyshev-second-kind))
	       (gen2 (make-oscil (* n 100.0)))
	       (max-dist 0.0))
	   (run 
	    (do ((i 0 (+ 1 i)))
		((= i 1000))
	      (let ((val1 (polywave gen1))
		    (val2 (oscil gen2)))
		(set! max-dist (max max-dist (abs (- val1 val2)))))))
	   (if (fneq max-dist 0.0)
	       (snd-display #__line__ ";polywave 2nd run ~A: ~A ~A" n val1 val2))))
       (list 1 3 30 200))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polyshape 100.0 :partials (list n 1.0) :kind mus-chebyshev-first-kind))
	       (gen2 (make-oscil (* n 100.0) (/ pi 2)))
	       (max-dist 0.0))
	   (run
	    (do ((i 0 (+ 1 i)))
		((= i 1000))
	      (let ((val1 (polyshape gen1))
		    (val2 (oscil gen2)))
		(set! max-dist (max max-dist (abs (- val1 val2)))))))
	   (if (fneq max-dist 0.0)
	       (snd-display #__line__ ";polyshape run ~A: ~A ~A" n val1 val2))))
       (list 1 3 25))
      
      (for-each
       (lambda (n)
	 (let ((gen1 (make-polyshape 100.0 :partials (list n 1.0) :kind mus-chebyshev-second-kind))
	       (gen2 (make-oscil (* n 100.0)))
	       (max-dist 0.0))
	   (run
	    (do ((i 0 (+ 1 i)))
		((= i 1000))
	      (let ((val1 (polyshape gen1))
		    (val2 (oscil gen2)))
		(set! max-dist (max max-dist (abs (- val1 val2)))))))
	   (if (fneq max-dist 0.0)
	       (snd-display #__line__ ";polyshape 2nd run ~A: ~A ~A" n val1 val2))))
       (list 1 3 25))
      
      (let ((gen (make-polywave 100.0 (list 1 .9 3 .1))))
	(let ((vals (mus-data gen)))
	  (if (or (not (vct? vals))
		  (not (vequal vals (vct 0.000 0.900 0.000 0.100))))
	      (snd-display #__line__ ";polywave mus-data: ~A" vals)
	      (begin
		(vct-set! (mus-data gen) 2 .1)
		(vct-set! (mus-data gen) 3 0.0)
		(let ((happy #t)
		      (gen1 (make-oscil 100.0 (/ pi 2)))
		      (gen2 (make-oscil 200.0 (/ pi 2))))
		  (do ((i 0 (+ 1 i)))
		      ((or (not happy) (= i 1000)))
		    (let ((val1 (polywave gen))
			  (val2 (+ (* .9 (oscil gen1))
				   (* .1 (oscil gen2)))))
		      (if (fneq val1 val2)
			  (begin
			    (set! happy #f)
			    (snd-display #__line__ ";polywave set mus-data at ~A: ~A ~A" i val1 val2))))))))))
      (set! (mus-srate) old-srate))
    
    (let ((var (catch #t (lambda () (make-polywave 440.0 3.14)) (lambda args args))))
      (if (not (eq? (car var) 'wrong-type-arg))
	  (snd-display #__line__ ";make-polywave bad coeffs: ~A" var)))
    
    (let ((gen (make-wave-train 440.0 0.0 (make-vct 20)))
	  (v0 (make-vct 10))
	  (gen1 (make-wave-train 440.0 0.0 (make-vct 20)))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "wave-train"
		       "wave-train freq: 440.000Hz, phase: 0.000, size: 20, interp: linear")
      (do ((i 0 (+ 1 i)))
	  ((= i 20))
	(vct-set! (mus-data gen) i (* i .5))
	(vct-set! (mus-data gen1) i (vct-ref (mus-data gen) i)))
      (if (not (= (vct-length (mus-data gen)) 20)) (snd-display #__line__ ";wave-train data length: ~A?" (vct-length (mus-data gen))))
      (if (not (= (mus-length gen) 20)) (snd-display #__line__ ";wave-train length: ~A?" (mus-length gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (wave-train gen 0.0)))
      (vct-map! v1 (lambda () (if (wave-train? gen1) (wave-train gen1) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map wave-train: ~A ~A" v0 v1))
      (if (not (wave-train? gen)) (snd-display #__line__ ";~A not wave-train?" gen))
      (if (fneq (mus-phase gen) 0.0) (snd-display #__line__ ";wave-train phase: ~F?" (mus-phase gen)))
      (set! (mus-phase gen) 1.0)
      (if (fneq (mus-phase gen) 1.0) (snd-display #__line__ ";set wave-train phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";wave-train frequency: ~F?" (mus-frequency gen)))
      (set! (mus-frequency gen) 100.0)
      (if (fneq (mus-frequency gen) 100.0) (snd-display #__line__ ";set wave-train freq: ~A" (mus-frequency gen)))
      (if (or (fneq (vct-ref v0 1) 0.5) (fneq (vct-ref v0 8) 4.0)) (snd-display #__line__ ";wave-train output: ~A" v0))
      (mus-reset gen)
      (if (fneq (mus-phase gen) 0.0) (snd-display #__line__ ";wt reset phase: ~A" (mus-phase gen)))
      (let ((val (wave-train gen 0.0)))
	(if (fneq val 0.0) (snd-display #__line__ ";wt reset data: ~A" val)))
      (if (not (vct? (mus-data gen))) (snd-display #__line__ ";mus-data wave-train: ~A" (mus-data gen)))
      (set! (mus-data gen) (make-vct 3)))
    (set! (mus-data (make-oscil)) (make-vct 3))
    
    (test-gen-equal (make-wave-train 440.0 0.0 (make-vct 20)) (make-wave-train 440.0 0.0 (make-vct 20)) (make-wave-train 100.0 0.0 (make-vct 20)))
    (test-gen-equal (make-wave-train 440.0 0.0 (make-vct 20)) (make-wave-train 440.0 0.0 (make-vct 20)) (make-wave-train 440.0 1.0 (make-vct 20)))
    
    (test-gen-equal (make-wave-train-with-env 440.0 '(0 0 1 1))
		    (make-wave-train-with-env 440.0 (list 0 0 1 1))
		    (make-wave-train-with-env 440.0 '(0 0 1 1 2 0)))
    
    (let ((hi (make-wave-train :size 256)))
      (if (not (= (mus-length hi) 256)) (snd-display #__line__ ";wave-train set length: ~A?" (mus-length hi)))
      (set! (mus-length hi) 128)
      (if (not (= (mus-length hi) 128)) (snd-display #__line__ ";set wave-train set length: ~A?" (mus-length hi))))
    
    (for-each 
     (lambda (args)
       (let ((type (car args))
	     (vals (cadr args)))
	 (let* ((tbl1 (make-wave-train :frequency 3000.0 :initial-phase (/ (* 2.0 pi .2) 4) :size 4 :type type)))
	   (vct-set! (mus-data tbl1) 1 1.0)
	   (let ((v (make-vct 10)))
	     (do ((i 0 (+ 1 i)))
		 ((= i 10))
	       (vct-set! v i (wave-train tbl1 0.0))) ;(wave-train tbl1 (/ (* 2 pi .2) 4))))
	     (if (not (vequal v vals))
		 (snd-display #__line__ ";wt tbl interp ~A: ~A ~A" type v (mus-describe tbl1)))
	     (if (not (= (mus-interp-type tbl1) type)) (snd-display #__line__ ";wt tbl interp-type (~A): ~A" type (mus-interp-type tbl1)))))))
     (list 
      (list mus-interp-none (vct 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000))
      (list mus-interp-linear (vct 0.200 0.800 0.000 0.000 0.000 0.000 0.000 0.000 0.200 0.800))
      (list mus-interp-lagrange (vct 0.120 0.960 -0.080 0.000 0.000 0.000 0.000 0.000 0.120 0.960))
      (list mus-interp-hermite (vct 0.168 0.912 -0.064 -0.016 0.000 0.000 0.000 0.000 0.168 0.912))))
    
    (let ((tag (catch #t (lambda () (make-wave-train :size 0)) (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range)) (snd-display #__line__ ";wave-train size 0: ~A" tag)))
    
    (let ((ind (new-sound "fmv.snd" :size 10 :comment "line 20501")))
      (if (not (= (frames) 10)) (snd-display #__line__ ";new-sound size(10): ~A" (frames)))
      (map-channel (lambda (y) 1.0) 7 8)
      (if (not (= (frames) 15)) (snd-display #__line__ ";map-channel 7 8: ~A" (frames)))
      (map-channel (lambda (y) 1.0))
      (if (not (= (frames) 15)) (snd-display #__line__ ";map-channel (no dur): ~A" (frames)))
      (revert-sound ind)
      (map-channel (lambda (y) 1.0) 9 10)
      (if (not (= (frames) 19)) (snd-display #__line__ ";map-channel 9 10: ~A" (frames)))
      (if (> (edit-position ind 0) 2) (snd-display #__line__ ";map-channel pad edits: ~A" (edit-position ind 0)))
      (revert-sound ind)
      (map-channel (lambda (y) 1.0) 10 10)
      (if (not (= (frames) 20)) (snd-display #__line__ ";map-channel 10 10: ~A" (frames)))
      (if (> (edit-position ind 0) 2) (snd-display #__line__ ";map-channel pad edits (2): ~A" (edit-position ind 0)))
      (revert-sound ind)
      (map-channel (lambda (y) 1.0) 20 10)
      (if (not (= (frames) 30)) (snd-display #__line__ ";map-channel 20 10: ~A" (frames)))
      (if (> (edit-position ind 0) 2) (snd-display #__line__ ";map-channel pad edits (3): ~A" (edit-position ind 0)))
      (revert-sound ind)
      (if (scan-channel (lambda (y) #f) 30 10) (snd-display #__line__ ";scan-channel past end?"))
      (ptree-channel (lambda (y) 1.0) 7 8)
      (if (not (= (frames) 15)) (snd-display #__line__ ";ptree-channel 7 8: ~A" (frames)))
      (ptree-channel (lambda (y) 1.0))
      (if (not (= (frames) 15)) (snd-display #__line__ ";ptree-channel (no dur): ~A" (frames)))
      (revert-sound ind)
      (ptree-channel (lambda (y) 1.0) 9 10)
      (if (not (= (frames) 19)) (snd-display #__line__ ";ptree-channel 9 10: ~A" (frames)))
      (if (> (edit-position ind 0) 2) (snd-display #__line__ ";ptree-channel pad edits: ~A" (edit-position ind 0)))
      (revert-sound ind)
      (ptree-channel (lambda (y) 1.0) 10 10)
      (if (not (= (frames) 20)) (snd-display #__line__ ";ptree-channel 10 10: ~A" (frames)))
      (if (> (edit-position ind 0) 2) (snd-display #__line__ ";ptree-channel pad edits (2): ~A" (edit-position ind 0)))
      (revert-sound ind)
      (ptree-channel (lambda (y) 1.0) 20 10)
      (if (not (= (frames) 30)) (snd-display #__line__ ";ptree-channel 20 10: ~A" (frames)))
      (if (> (edit-position ind 0) 2) (snd-display #__line__ ";ptree-channel pad edits (3): ~A" (edit-position ind 0)))
      (let ((new-file-name (file-name ind)))
	(close-sound ind)
	(if (file-exists? new-file-name) (delete-file new-file-name))))
    
    (let ((ind (new-sound :size 1000)))
      (let* ((table (vct 0.0 .1 .2 .3 .4 .5 .6))
	     (gen (make-wave-train 1000.0 :wave table)))
	(map-channel (lambda (y) (wave-train gen)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.6) (snd-display #__line__ ";wt 0 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.600)))
	    (snd-display #__line__ ";wt 0 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300)))
	    (snd-display #__line__ ";wt 0 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let* ((table (make-vct 10 .1))
	     (gen (make-wave-train 1000.0 :initial-phase pi :wave table))) ; initial-phase is confusing in this context!
	(map-channel (lambda (y) (wave-train gen)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";wt 1 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000)))
	    (let ((op (print-length)))
	      (set! (print-length) 32)
	      (snd-display #__line__ ";wt 1 data: ~A" (channel->vct 0 30))
	      (set! (print-length) op)))
	(undo))
      
      (let* ((table (make-vct 10 .1))
	     (gen (make-wave-train 2000.0 :wave table)))
	(map-channel (lambda (y) (wave-train gen)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";wt 2 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.100 0.100 0.100 
			      0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100)))
	    (snd-display #__line__ ";wt 2 data: ~A" (channel->vct 0 30)))
	(if (and (not (vequal (channel->vct 440 30) 
			      (vct 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.100 0.100 
				   0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 0.100 0.100 0.100 0.100)))
		 ;; if double, round off is just enough different to cause an off-by-1 problem here (and below)
		 (not (vequal (channel->vct 440 30) 
			      (vct 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 
				   0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 0.100 0.100 0.100 0.100 0.100))))
	    (snd-display #__line__ ";wt 2 data 440: ~A" (channel->vct 440 30)))
	(undo))
      
      (let* ((table (make-vct 10 .1))
	     (gen (make-wave-train 3000.0 :wave table)))
	(map-channel (lambda (y) (wave-train gen)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.2) (snd-display #__line__ ";wt 3 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100 0.100 
			      0.200 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100 0.100)))
	    (snd-display #__line__ ";wt 3 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 440 30) 
			 (vct 0.100 0.200 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100 
			      0.100 0.200 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.100 0.100 0.100 0.100)))
	    (snd-display #__line__ ";wt 3 data 440: ~A" (channel->vct 440 30)))
	(undo))
      
      (let* ((table (make-vct 10 .1))
	     (gen (make-wave-train 5000.0 :wave table)))
	(map-channel (lambda (y) (wave-train gen)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.3) (snd-display #__line__ ";wt 4 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.200 0.300 
			      0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.200 0.200)))
	    (snd-display #__line__ ";wt 4 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 440 30) 
			 (vct 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.300 0.200 0.200 0.200 
			      0.300 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.200 0.300 0.200 0.200 0.200 0.300 0.200)))
	    (snd-display #__line__ ";wt 4 data 440: ~A" (channel->vct 440 30)))
	(undo))
      
      (let* ((table (make-vct 10 .1))
	     (gen (make-wave-train 1000.0 :wave table))
	     (e (make-env '(0 1 1 2) :length 1001))
	     (base-freq (mus-frequency gen)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (wave-train gen)))
	     (set! (mus-frequency gen) (* base-freq (env e)))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";wt 5 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100)))
	    (snd-display #__line__ ";wt 5 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 440 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.100 
			      0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.100)))
	    (snd-display #__line__ ";wt 5 data 440: ~A" (channel->vct 440 30)))
	(if (not (vequal (channel->vct 900 30) 
			 (vct 0.100 0.000 0.000 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.100 
			      0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.100 0.100 0.100 0.100)))
	    (snd-display #__line__ ";wt 5 data 900: ~A" (channel->vct 900 30)))
	(undo))
      
      (let* ((table (make-vct 10 .1))
	     (gen (make-wave-train 500.0 :wave table))
	     (ctr 0))
	(map-channel 
	 (lambda (y) 
	   (let ((result (wave-train gen)))
	     (if (> ctr 22)
		 (begin
		   (set! ctr 0)
		   (vct-scale! (mus-data gen) 1.05))
		 (set! ctr (+ 1 ctr)))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.704) (snd-display #__line__ ";wt 6 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";wt 6 data: ~A" (channel->vct 0 30)))
	(if (and (not (vequal (channel->vct 440 30) 
			      (vct 0.000 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.000 0.000 0.000 0.000
				   0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		 (not (vequal (channel->vct 440 30) 
			      (vct 0.000 0.000 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.241 0.000 0.000 0.000 0.000
				   0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
	    (snd-display #__line__ ";wt 6 data 440: ~A" (channel->vct 440 30)))
	(if (not (vequal (channel->vct 900 30) 
			 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.639 0.639 0.639)))
	    (snd-display #__line__ ";wt 6 data 900: ~A" (channel->vct 900 30)))
	(undo))
      (let ((fname (file-name ind)))
	(close-sound ind)
	(delete-file fname)))
    
    (let ((gen (make-readin "oboe.snd" 0 1490))
	  (v0 (make-vct 10))
	  (gen1 (make-readin "oboe.snd" 0 1490))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "readin"
		       "readin oboe.snd[chan 0], loc: 1490, dir: 1")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (readin gen)))
      (vct-map! v1 (lambda () 
		     (if (readin? gen1) 
			 (if (= (mus-channel gen1) 0) 
			     (readin gen1) 
			     1.0) 
			 (if (string=? (mus-file-name gen1) "oboe.snd")
			     -1.0
			     -1.0))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map readin: ~A ~A" v0 v1))
      (if (not (readin? gen)) (snd-display #__line__ ";~A not readin?" gen))
      (if (not (mus-input? gen)) (snd-display #__line__ ";~A not input?" gen))
      (if (not (= (mus-length gen) 50828)) (snd-display #__line__ ";readin length: ~A?" (mus-length gen)))
      (if (not (= (mus-channel gen) 0)) (snd-display #__line__ ";readin chan: ~A?" (mus-channel gen)))
      (if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display #__line__ ";readin mus-file-name: ~A" (mus-file-name gen)))
      (if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display #__line__ ";readin output: ~A" v0))
      (set! (mus-location gen) 1000)
      (if (not (= (mus-location gen) 1000)) (snd-display #__line__ ";set! mus-location: ~A?" (mus-location gen)))
      (let ((val (readin gen)))
	(if (fneq val 0.033) (snd-display #__line__ ";set! mus-location readin: ~A?" val)))
      (set! (mus-increment gen) -1)
      (if (fneq (mus-increment gen) -1.0) (snd-display #__line__ ";set increment readin: ~A" (mus-increment gen))))
    (let ((tag (catch #t (lambda () (make-readin "/baddy/hiho" 0 124)) (lambda args args))))
      (if (not (eq? (car tag) 'no-such-file)) (snd-display #__line__ ";make-readin w/o file: ~A" tag)))
    (let ((tag (catch #t (lambda () (make-readin "oboe.snd" 123 124)) (lambda args args))))
      (if (not (eq? (car tag) 'out-of-range)) (snd-display #__line__ ";make-readin with bad chan: ~A" tag)))
    
    (test-gen-equal (make-readin "oboe.snd" 0) (make-readin "oboe.snd" 0) (make-readin "oboe.snd" 0 1230))
    (test-gen-equal (make-readin "oboe.snd" 0 :size 512) (make-readin "oboe.snd" 0 :size 512) (make-readin "pistol.snd" 0 :size 512))
    (test-gen-equal (make-readin "2.snd" 1) (make-readin "2.snd" 1) (make-readin "2.snd" 0))
    
    (let ((gen (make-readin "2.snd" 1 :size 1024))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "readin"
		       "readin 2.snd[chan 1], loc: 0, dir: 1")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (readin gen)))
      (if (not (= (mus-channel gen) 1)) (snd-display #__line__ ";readin chan 1: ~A?" (mus-channel gen)))
      (if (or (fneq (vct-ref v0 1) 0.010) (fneq (vct-ref v0 7) -.006)) (snd-display #__line__ ";readin 1 output: ~A" v0))
      (print-and-check gen 
		       "readin"
		       "readin 2.snd[chan 1], loc: 10, dir: 1"))
    
    (let ((gen (make-file->sample "oboe.snd"))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "file->sample"
		       "file->sample oboe.snd")
      (if (not (mus-input? gen)) (snd-display #__line__ ";~A not input?" gen))
      (if (not (= (mus-length gen) 50828)) (snd-display #__line__ ";file->sample length: ~A?" (mus-length gen)))
      (if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display #__line__ ";file->sample mus-file-name: ~A" (mus-file-name gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (file->sample gen (+ 1490 i))))
      (if (not (file->sample? gen)) (snd-display #__line__ ";~A not file->sample?" gen))
      (if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display #__line__ ";file->sample output: ~A" v0))
      (if (fneq (mus-increment gen) 0.0) (snd-display #__line__ ";file->sample increment: ~A" (mus-increment gen)))
      (set! (mus-increment gen) 1.0)
      (if (fneq (mus-increment gen) 1.0) (snd-display #__line__ ";file->sample set increment: ~A" (mus-increment gen)))
      (mus-reset gen)) ; a no-op I hope
    
    (let* ((ind (open-sound "oboe.snd"))
	   (gen (make-snd->sample ind))
	   (gen1 (make-snd->sample ind))
	   (v0 (make-vct 10)))
      (print-and-check gen 
		       "snd->sample"
		       "snd->sample reading oboe.snd (1 chan) at 0:[no readers]")
      (if (not (equal? gen gen)) (snd-display #__line__ ";snd->sample not eq? itself?"))
      (if (equal? gen gen1) (snd-display #__line__ ";snd->sample eq? not itself?"))
      (if (not (mus-input? gen)) (snd-display #__line__ ";snd->sample ~A not input?" gen))
      (if (not (= (frames ind) (mus-length gen))) (snd-display #__line__ ";snd->sample len: ~A ~A" (frames ind) (mus-length gen)))
      (if (not (string=? (mus-file-name gen) (string-append cwd "oboe.snd")))
	  (snd-display #__line__ ";snd->sample mus-file-name: ~A ~A" (mus-file-name gen) (string-append cwd "oboe.snd")))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (snd->sample gen (+ 1490 i))))
      (if (not (snd->sample? gen)) (snd-display #__line__ ";~A not snd->sample?" gen))
      (if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display #__line__ ";snd->sample output: ~A" v0))
      (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";snd->sample channels: ~A" (mus-channels gen)))
      (if (not (= (mus-location gen) 1499)) (snd-display #__line__ ";snd->sample location: ~A" (mus-location gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (ina (+ 1490 i) gen)))
      (if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display #__line__ ";snd->sample ina output: ~A" v0))
      (close-sound ind))
    
    (let* ((ind (open-sound "2.snd"))
	   (gen (make-snd->sample ind))
	   (v0 (make-vct 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (snd->sample gen (+ 1490 i) 0))
	(vct-set! v0 i (snd->sample gen (+ 1490 i) 1)))
      (print-and-check gen 
		       "snd->sample"
		       "snd->sample reading 2.snd (2 chans) at 1499:[#<sampler: 2.snd[0: 0] from 1490, at 1500, forward>, #<sampler: 2.snd[1: 0] from 1490, at 1500, forward>]")
      (if (not (mus-input? gen)) (snd-display #__line__ ";snd->sample ~A not input?" gen))
      (if (not (string=? (mus-file-name gen) (string-append cwd "2.snd")))
	  (snd-display #__line__ ";snd->sample mus-file-name: ~A ~A" (mus-file-name gen) (string-append cwd "2.snd")))
      (if (not (snd->sample? gen)) (snd-display #__line__ ";~A not snd->sample?" gen))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";snd->sample channels (2): ~A" (mus-channels gen)))
      (if (not (= (mus-location gen) 1499)) (snd-display #__line__ ";snd->sample location (2): ~A" (mus-location gen)))
      (close-sound ind))
    
    (let ((gen (make-file->frame "oboe.snd"))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "file->frame"
		       "file->frame oboe.snd")
      (if (not (mus-input? gen)) (snd-display #__line__ ";~A not input?" gen))
      (if (not (= (mus-length gen) 50828)) (snd-display #__line__ ";file->frame length: ~A?" (mus-length gen)))
      (if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display #__line__ ";file->frame mus-file-name: ~A" (mus-file-name gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (frame-ref (file->frame gen (+ 1490 i)) 0)))
      (if (not (file->frame? gen)) (snd-display #__line__ ";~A not file->frame?" gen))
      (if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display #__line__ ";file->frame output: ~A" v0)))
    
    (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
    (if (file-exists? "fmv1.snd") (delete-file "fmv1.snd"))
    (if (file-exists? "fmv2.snd") (delete-file "fmv2.snd"))
    (if (file-exists? "fmv3.snd") (delete-file "fmv3.snd"))
    (let ((gen (make-sample->file "fmv.snd" 2 mus-lshort mus-riff)))
      (print-and-check gen 
		       "sample->file"
		       "sample->file fmv.snd")
      (if (not (mus-output? gen)) (snd-display #__line__ ";~A not output?" gen))
      (if (not (sample->file? gen)) (snd-display #__line__ ";~A not sample->file?" gen))
      (if (not (= (mus-length gen) (mus-file-buffer-size))) (snd-display #__line__ ";sample->file length: ~A?" (mus-length gen)))
      (let ((genx gen))
	(if (not (equal? genx gen)) (snd-display #__line__ ";sample->file equal? ~A ~A" genx gen)))
      (if (not (string=? (mus-file-name gen) "fmv.snd")) (snd-display #__line__ ";sample->file mus-file-name: ~A" (mus-file-name gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(sample->file gen i 0 (* i .001))
	(sample->file gen i 1 (* i .01)))
      (outa 50 .015 gen)
      (outb 50 .15 gen)
      (out-any 60 .015 0 gen)
      (out-any 60 .15 1 gen)
      (mus-close gen))
    (let* ((gen (make-file->sample "fmv.snd"))
	   (val0 (in-any 20 0 gen))
	   (val1 (in-any 20 1 gen))
	   (val2 (ina 30 gen))
	   (val3 (inb 30 gen))
	   (val4 (file->sample gen 40 0))
	   (val5 (file->sample gen 40 1))
	   (val6 (in-any 50 0 gen))
	   (val7 (in-any 50 1 gen))
	   (val8 (in-any 60 0 gen))
	   (val9 (in-any 60 1 gen)))
      (print-and-check gen 
		       "file->sample"
		       "file->sample fmv.snd")
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";make-sample->file chans: ~A?" (mus-channels gen)))
      (if (not (mus-input? gen)) (snd-display #__line__ ";~A not input?" gen))
      (if (or (fneq val0 .02) (fneq val1 .2)) (snd-display #__line__ ";in-any: ~A ~A?" val0 val1))
      (if (or (fneq val2 .03) (fneq val3 .3)) (snd-display #__line__ ";inab: ~A ~A?" val2 val3))
      (if (or (fneq val4 .04) (fneq val5 .4)) (snd-display #__line__ ";sample->file: ~A ~A?" val4 val5))
      (if (or (fneq val6 .065) (fneq val7 .65)) (snd-display #__line__ ";outab: ~A ~A?" val6 val7))
      (if (or (fneq val8 .075) (fneq val9 .75)) (snd-display #__line__ ";out-any: ~A ~A?" val8 val9)))
    
    (let ((gen (make-vct 10)))
      (do ((i 0 (+ 1 i))
	   (x 0.0 (+ x 0.1)))
	  ((= i 10))
	(outa i x gen))
      (if (not (vequal gen (vct 0 .1 .2 .3 .4 .5 .6 .7 .8 .9)))
	  (snd-display #__line__ ";outa->vct ramp: ~A" gen))
      (do ((i 0 (+ 1 i))
	   (x 0.0 (+ x 0.1)))
	  ((= i 10))
	(outa i x gen))
      (if (not (vequal gen (vct-scale! (vct 0 .1 .2 .3 .4 .5 .6 .7 .8 .9) 2.0)))
	  (snd-display #__line__ ";outa->vct ramp 2: ~A" gen))
      (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";mus-channels vct: ~A" (mus-channels gen))))
    
    (let ((gen (make-sound-data 4 100)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(outa i .1 gen)
	(outb i .2 gen)
	(outc i .3 gen)
	(outd i .4 gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(outa i .01 gen)
	(outb i .02 gen)
	(outc i .03 gen)
	(outd i .04 gen))
      (mus-close gen) ; should be a no-op
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (or (fneq (ina i gen) .11)
		(fneq (inb i gen) .22)
		(fneq (in-any i 2 gen) .33)
		(fneq (in-any i 3 gen) .44))
	    (snd-display #__line__ ";4-chan sd out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen))))  
      (if (not (= (mus-channels gen) 4)) (snd-display #__line__ ";mus-channels sd 4: ~A" (mus-channels gen))))
    
    (let ((gen (make-sound-data 4 100)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(out-any i .1 0 gen)
	(out-any i .2 1 gen)
	(out-any i .3 2 gen)
	(out-any i .4 3 gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(out-any i .01 0 gen)
	(out-any i .02 1 gen)
	(out-any i .03 2 gen)
	(out-any i .04 3 gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (or (fneq (in-any i 0 gen) .11)
		(fneq (in-any i 1 gen) .22)
		(fneq (in-any i 2 gen) .33)
		(fneq (in-any i 3 gen) .44))
	    (snd-display #__line__ ";4-chan sd out/in-any[~A]: ~A ~A ~A ~A?" i (in-any i 0 gen) (in-any i 1 gen) (in-any i 2 gen) (in-any i 3 gen)))))
    
    (let ((gen (make-oscil 440.0)))
      (let ((tag (catch #t (lambda () (outa 0 .1 gen)) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";outa -> oscil: ~A" tag)))
      (let ((val (catch #t (lambda () (outa 0 .1 #f)) (lambda args (car args)))))
	(if (or (not (number? val)) (fneq val .1)) (snd-display #__line__ ";outa -> #f: ~A" val))))
    
    (let ((gen (make-sample->file "fmv.snd" 4 mus-lshort mus-riff)))
      (print-and-check gen 
		       "sample->file"
		       "sample->file fmv.snd")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(outa i .1 gen)
	(outb i .2 gen)
	(outc i .3 gen)
	(outd i .4 gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(outa i .01 gen)
	(outb i .02 gen)
	(outc i .03 gen)
	(outd i .04 gen))
      (mus-close gen))
    (let* ((gen (make-file->sample "fmv.snd")))
      (print-and-check gen 
		       "file->sample"
		       "file->sample fmv.snd")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (or (fneq (ina i gen) .11)
		(fneq (inb i gen) .22)
		(fneq (in-any i 2 gen) .33)
		(fneq (in-any i 3 gen) .44))
	    (snd-display #__line__ ";4-chan out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen)))))
    
    (let ((gen (make-sample->file "fmv.snd" 4 mus-lshort mus-riff)))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= i 10))
	 (outa i .1 gen)
	 (outb i .2 gen)
	 (outc i .3 gen)
	 (outd i .4 gen))
       (do ((i 0 (+ 1 i)))
	   ((= i 10))
	 (outa i .01 gen)
	 (outb i .02 gen)
	 (outc i .03 gen)
	 (outd i .04 gen)))
      (mus-close gen))
    (let* ((gen (make-file->sample "fmv.snd")))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (or (fneq (ina i gen) .11)
		(fneq (inb i gen) .22)
		(fneq (in-any i 2 gen) .33)
		(fneq (in-any i 3 gen) .44))
	    (snd-display #__line__ ";4-chan out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen)))))
    
    (let ((var (catch #t (lambda () (make-sample->file "fmv.snd" -1 mus-lshort mus-next)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-sample->file bad chans: ~A" var)))
    (let ((var (catch #t (lambda () (mus-location (make-oscil))) (lambda args args))))
      (if (or (not (list? var)) (not (eq? (car var) 'mus-error)))
	  (snd-display #__line__ ";mus-location oscil: ~A" var)))
    (let ((var (catch #t (lambda () (make-sample->file "fmv.snd" 1 -1 mus-next)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-sample->file bad format: ~A" var)))
    (let ((var (catch #t (lambda () (make-sample->file "fmv.snd" 1 mus-lshort -1)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-sample->file bad type: ~A" var)))
    
    (let ((v (vector 1.0 0.5 0.25 0.125 0.0))
	  (v1 (make-vct 5 0.0)))
      (do ((i 0 (+ i 1)))
	  ((= i 5))
	(set! (v1 i) (in-any i 0 v)))
      (if (not (vequal v1 (vct 1.0 0.5 0.25 0.125 0.0)))
	  (snd-display #__line__ ";vector in-any -> ~A?" v1)))
    
    (let ((sum 0.0))
      (let ((result (with-sound (:output (make-vct 10))
				(do ((i 0 (+ 1 i)))
				    ((= i 10))
				  (outa i (ina i (lambda (loc chn)
						   (set! sum (+ sum (* loc 0.1)))
						   sum)))))))
	(if (not (vequal result (vct 0.000 0.100 0.300 0.600 1.000 1.500 2.100 2.800 3.600 4.500)))
	    (snd-display #__line__ ";ina function: ~A" result))))
    
    (let ((sum 0.0))
      (let ((result (with-sound (:output (make-vct 10))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 10))
				   (outa i (ina i (lambda (loc chn)
						    (set! sum (+ sum (* loc 0.1)))
						    sum))))))))
	(if (not (vequal result (vct 0.000 0.100 0.300 0.600 1.000 1.500 2.100 2.800 3.600 4.500)))
	    (snd-display #__line__ ";run ina function: ~A" result))))
    
    (let ((invals (make-vct 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! invals i (* i 0.1)))
      (let ((result (with-sound (:output (make-vct 10))
				(do ((i 0 (+ 1 i)))
				    ((= i 10))
				  (outa i (ina i invals))))))
	(if (not (vequal result (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	    (snd-display #__line__ ";ina from vct: ~A" result))))
    
    (let ((invals (make-vct 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! invals i (* i 0.1)))
      (let ((result (with-sound (:output (make-vct 10))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 10))
				   (outa i (ina i invals)))))))
	(if (not (vequal result (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	    (snd-display #__line__ ";run ina from vct: ~A" result))))
    
    (let ((old-buffer-size (mus-file-buffer-size))
	  (old-clm-buffer-size *clm-file-buffer-size*))
      (set! (mus-file-buffer-size) 1024)
      (set! *clm-file-buffer-size* 1024)
      
      (let ((input (make-readin "oboe.snd" :start 1000)))
	(let ((result (with-sound (:output (make-vct 10))
				  (do ((i 0 (+ 1 i)))
				      ((= i 10))
				    (outa i (ina i (lambda (loc chn)
						     (readin input))))))))
	  (if (not (vequal result (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004)))
	      (snd-display #__line__ ";ina function readin: ~A" result)))
	(mus-close input))
      
      (let ((input (make-readin "oboe.snd" :start 1000)))
	(let ((result (with-sound (:output (make-vct 10))
				  (run
				   (do ((i 0 (+ 1 i)))
				       ((= i 10))
				     (outa i (ina i (lambda (loc chn)
						      (readin input)))))))))
	  (if (not (vequal result (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004)))
	      (snd-display #__line__ ";run ina function readin: ~A" result)))
	(mus-close input))
      
      (let ((input (make-file->sample "oboe.snd")))
	(let ((result (with-sound (:output (make-vct 10))
				  (do ((i 0 (+ 1 i)))
				      ((= i 10))
				    (outa i (ina (+ i 1000) (lambda (loc chn)
							      (in-any loc chn input))))))))
	  (if (not (vequal result (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004)))
	      (snd-display #__line__ ";ina function in-any: ~A" result)))
	(mus-close input))
      
      (let ((input (make-file->sample "oboe.snd")))
	(let ((result (with-sound (:output (make-vct 10))
				  (run
				   (do ((i 0 (+ 1 i)))
				       ((= i 10))
				     (outa i (ina (+ i 1000) (lambda (loc chn)
							       (in-any loc chn input)))))))))
	  (if (not (vequal result (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004)))
	      (snd-display #__line__ ";run ina function in-any: ~A" result)))
	(mus-close input))
      
      (set! *clm-file-buffer-size* old-clm-buffer-size)
      (set! (mus-file-buffer-size) old-buffer-size))
    
    (let ((invals (make-sound-data 2 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(sound-data-set! invals 0 i (* i 0.1))
	(sound-data-set! invals 1 i (* i 0.2)))
      (let ((result (with-sound (:output (make-sound-data 2 10))
				(do ((i 0 (+ 1 i)))
				    ((= i 10))
				  (outa i (inb i (lambda (loc chn)
						   (sound-data-ref invals chn loc))))
				  (outb i (ina i (lambda (loc chn)
						   (sound-data-ref invals chn loc))))))))
	(if (not (vequal (sound-data->vct result 0) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	    (snd-display #__line__ ";inb from sound-data function: ~A" (sound-data->vct result 0)))
	(if (not (vequal (sound-data->vct result 1) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	    (snd-display #__line__ ";ina from sound-data function: ~A" (sound-data->vct result 1)))))
    
    (let ((invals (make-sound-data 2 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(sound-data-set! invals 0 i (* i 0.1))
	(sound-data-set! invals 1 i (* i 0.2)))
      (let ((result (with-sound (:output (make-sound-data 2 10))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 10))
				   (outa i (inb i (lambda (loc chn)
						    (sound-data-ref invals chn loc))))
				   (outb i (ina i (lambda (loc chn)
						    (sound-data-ref invals chn loc)))))))))
	(if (not (vequal (sound-data->vct result 0) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	    (snd-display #__line__ ";run inb from sound-data function: ~A" (sound-data->vct result 0)))
	(if (not (vequal (sound-data->vct result 1) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	    (snd-display #__line__ ";run ina from sound-data function: ~A" (sound-data->vct result 1)))))
    
    (let ((invals (make-sound-data 2 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(sound-data-set! invals 0 i (* i 0.1))
	(sound-data-set! invals 1 i (* i 0.2)))
      (let ((result (with-sound (:output (make-sound-data 2 10))
				(do ((i 0 (+ 1 i)))
				    ((= i 10))
				  (outa i (in-any i 1 (lambda (loc chn)
							(in-any loc chn invals))))
				  (outb i (in-any i 0 (lambda (loc chn)
							(in-any loc chn invals))))))))
	(if (not (vequal (sound-data->vct result 0) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	    (snd-display #__line__ ";in-any 1 from sound-data function: ~A" (sound-data->vct result 0)))
	(if (not (vequal (sound-data->vct result 1) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	    (snd-display #__line__ ";in-any 0 from sound-data function: ~A" (sound-data->vct result 1)))))
    
    (let ((invals (make-sound-data 2 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(sound-data-set! invals 0 i (* i 0.1))
	(sound-data-set! invals 1 i (* i 0.2)))
      (let ((result (with-sound (:output (make-sound-data 2 10))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 10))
				   (outa i (in-any i 1 (lambda (loc chn)
							 (in-any loc chn invals))))
				   (outb i (in-any i 0 (lambda (loc chn)
							 (in-any loc chn invals)))))))))
	(if (not (vequal (sound-data->vct result 0) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	    (snd-display #__line__ ";run in-any 1 from sound-data function: ~A" (sound-data->vct result 0)))
	(if (not (vequal (sound-data->vct result 1) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	    (snd-display #__line__ ";run in-any 0 from sound-data function: ~A" (sound-data->vct result 1)))))
    
    (let ((input (make-file->sample "oboe.snd")))
      (let ((result (with-sound (:output (make-vct 10))
				(do ((i 0 (+ 1 i)))
				    ((= i 10))
				  (outa i (in-any (+ i 1000) 0 (lambda (loc chn)
								 (in-any loc chn input))))))))
	(if (not (vequal result (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004)))
	    (snd-display #__line__ ";in-any file->sample in-any: ~A" result))))
    
    (let ((input (make-file->sample "oboe.snd")))
      (let ((result (with-sound (:output (make-vct 10))
				(run
				 (do ((i 0 (+ 1 i)))
				     ((= i 10))
				   (outa i (in-any (+ i 1000) 0 (lambda (loc chn)
								  (in-any loc chn input)))))))))
	(if (not (vequal result (vct 0.033 0.035 0.034 0.031 0.026 0.020 0.013 0.009 0.005 0.004)))
	    (snd-display #__line__ ";run in-any file->sample in-any: ~A" result))))
    
    
    (let ((avg 0.0)
	  (samps 0))
      (with-sound (:output (lambda (frame val chan)
			     (set! avg (+ avg val))
			     (set! samps (+ 1 samps))
			     val))
		  (do ((i 0 (+ 1 i)))
		      ((> i 10))
		    (outa i (* i .1))))
      (let ((result (/ avg samps)))
	(if (fneq result 0.5)
	    (snd-display #__line__ ";output as avg: ~A" result))))
    
    (let ((avg 0.0)
	  (samps 0))
      (with-sound (:output (lambda (frame val chan)
			     (declare (frame integer) (val real) (chan integer))
			     (set! avg (+ avg val))
			     (set! samps (+ 1 samps))
			     val))
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((> i 10))
		     (outa i (* i .1)))))
      (let ((result (/ avg samps)))
	(if (fneq result 0.5)
	    (snd-display #__line__ ";run output as avg: ~A" result))))
    
    (let ((outv (make-vct 10)))
      (with-sound ()
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (outa i (* i .1) (lambda (loc val chan)
				       (vct-set! outv loc val)))))
      (if (not (vequal outv (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";outa func vct: ~A" outv)))
    
    (let ((outv (make-vct 10)))
      (with-sound ()
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (outa i (* i .1) (lambda (loc val chan)
					(vct-set! outv loc val))))))
      (if (not (vequal outv (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run outa func vct: ~A" outv)))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4)
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (outa i (* i .1) (lambda (loc val chan)
				       (sound-data-set! outv chan loc val)))
		    (outb i (* i .2) (lambda (loc val chan)
				       (sound-data-set! outv chan loc val)))
		    (outc i (* i .3) (lambda (loc val chan)
				       (sound-data-set! outv chan loc val)))
		    (outd i (* i .4) (lambda (loc val chan)
				       (sound-data-set! outv chan loc val)))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";outa 1 to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";outb 1 to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";outc 1 to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";outd 1 to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4)
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (outa i (* i .1) (lambda (loc val chan)
					(sound-data-set! outv chan loc val)))
		     (outb i (* i .2) (lambda (loc val chan)
					(sound-data-set! outv chan loc val)))
		     (outc i (* i .3) (lambda (loc val chan)
					(sound-data-set! outv chan loc val)))
		     (outd i (* i .4) (lambda (loc val chan)
					(sound-data-set! outv chan loc val))))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run outa 1 to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";run outb 1 to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";run outc 1 to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";run outd 1 to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-vct 10)))
      (with-sound ()
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (out-any i (* i .1) 0 (lambda (loc val chan)
					    (vct-set! outv loc val)))))
      (if (not (vequal outv (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";out-any func to vct: ~A" outv)))
    
    (let ((outv (make-vct 10)))
      (with-sound ()
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (out-any i (* i .1) 0 (lambda (loc val chan)
					     (vct-set! outv loc val))))))
      (if (not (vequal outv (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run out-any func to vct: ~A" outv)))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4)
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (do ((k 0 (+ 1 k)))
			((= k 4))
		      (out-any i (* i .1 (+ 1 k)) k (lambda (loc val chan)
						      (sound-data-set! outv chan loc val))))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";out-any 0 to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";out-any 1 to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";out-any 2 to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";out-any 3 to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4)
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (do ((k 0 (+ 1 k)))
			 ((= k 4))
		       (out-any i (* i .1 (+ 1 k)) k (lambda (loc val chan)
						       (sound-data-set! outv chan loc val)))))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run out-any 0 to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";run out-any 1 to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";run out-any 2 to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";run out-any 3 to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-vct 10)))
      (with-sound (:output (lambda (loc val chan)
			     (vct-set! outv loc val)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (outa i (* i .1))))
      (if (not (vequal outv (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";outa output func to vct: ~A" outv)))
    
    (let ((outv (make-vct 10)))
      (with-sound (:output (lambda (loc val chan)
			     (declare (loc integer) (val real) (chan integer))
			     (vct-set! outv loc val)))
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (outa i (* i .1)))))
      (if (not (vequal outv (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run outa output func to vct: ~A" outv)))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4 :output (lambda (loc val chan)
					 (sound-data-set! outv chan loc val)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (outa i (* i .1))
		    (outb i (* i .2))
		    (outc i (* i .3))
		    (outd i (* i .4))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";outa output to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";outb output to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";outc output to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";outd output to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4 :output (lambda (loc val chan)
					 (declare (loc integer) (val real) (chan integer))
					 (sound-data-set! outv chan loc val)))
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (outa i (* i .1))
		     (outb i (* i .2))
		     (outc i (* i .3))
		     (outd i (* i .4)))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run outa output to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";run outb output to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";run outc output to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";run outd output to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4 :output (lambda (loc val chan)
					 (sound-data-set! outv chan loc val)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (do ((k 0 (+ 1 k)))
			((= k 4))
		      (out-any i (* i .1 (+ 1 k)) k))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";out-any 0 output to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";out-any 1 output to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";out-any 2 output to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";out-any 3 output to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (let ((outv (make-sound-data 4 10)))
      (with-sound (:channels 4 :output (lambda (loc val chan)
					 (declare (loc integer) (val real) (chan integer))
					 (sound-data-set! outv chan loc val)))
		  (run
		   (do ((i 0 (+ 1 i)))
		       ((= i 10))
		     (do ((k 0 (+ 1 k)))
			 ((= k 4))
		       (out-any i (* i .1 (+ 1 k)) k)))))
      (if (not (vequal (sound-data->vct outv 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900)))
	  (snd-display #__line__ ";run out-any 0 output to sound-data function: ~A" (sound-data->vct outv 0)))
      (if (not (vequal (sound-data->vct outv 1) (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800)))
	  (snd-display #__line__ ";run out-any 1 output to sound-data function: ~A" (sound-data->vct outv 1)))
      (if (not (vequal (sound-data->vct outv 2) (vct 0.000 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700)))
	  (snd-display #__line__ ";run out-any 2 output to sound-data function: ~A" (sound-data->vct outv 2)))
      (if (not (vequal (sound-data->vct outv 3) (vct 0.000 0.400 0.800 1.200 1.600 2.000 2.400 2.800 3.200 3.600)))
	  (snd-display #__line__ ";run out-any 3 output to sound-data function: ~A" (sound-data->vct outv 3))))
    
    (for-each close-sound (sounds))
    
    (let ((vals (with-sound (:output (make-vct 4410))
			    (fm-violin 0 .1 440 .1))))
      (if (fneq (vct-peak vals) .1)
	  (snd-display #__line__ ";locsig to vct fm-violin peak: ~A" (vct-peak vals))))
    
    ;; TODO: get vector with-sound output to work in run 
    
    (let ((vals (with-sound (:output (make-sound-data 2 4410))
			    (fm-violin 0 .1 440 .1 :degree 30))))
      (let ((mxs (sound-data-maxamp vals)))
	(if (or (fneq (car mxs) 0.0666)
		(fneq (cadr mxs) 0.0333))
	    (snd-display #__line__ ";locsig to sound-data fm-violin peak: ~A" mxs))))
    
    (let ((data (make-vct 4410)))
      (with-sound (:output (lambda (loc val chan)
			     (vct-set! data loc val)))
		  (fm-violin 0 .1 440 .1))
      (if (fneq (vct-peak data) .1)
	  (snd-display #__line__ ";locsig to func fm-violin peak: ~A" (vct-peak data))))
    
    
    (let ((gen (make-frame->file "fmv1.snd" 2 mus-bshort mus-next)))
      (print-and-check gen 
		       "frame->file"
		       "frame->file fmv1.snd")
      (if (not (mus-output? gen)) (snd-display #__line__ ";~A not output?" gen))
      (if (not (frame->file? gen)) (snd-display #__line__ ";~A not frame->file?" gen))
      (if (not (= (mus-length gen) (mus-file-buffer-size))) (snd-display #__line__ ";frame->file length: ~A?" (mus-length gen)))
      (if (not (string=? (mus-file-name gen) "fmv1.snd")) (snd-display #__line__ ";frame->file mus-file-name: ~A" (mus-file-name gen)))
      (set! (mus-length gen) 4096)
      (if (not (= (mus-length gen) 4096)) (snd-display #__line__ ";frame->file length (1): ~A?" (mus-length gen)))
      (set! (mus-length gen) 8192)
      (let ((fr0 (make-frame 2 0.0 0.0)))
	(do ((i 0 (+ 1 i)))
	    ((= i 100))
	  (frame-set! fr0 0 (* i .001))
	  (frame-set! fr0 1 (* i .01))
	  (frame->file gen i fr0)))
      (mus-close gen))
    (let* ((gen (make-file->frame "fmv1.snd" 1024))
	   (val4 (file->frame gen 40))
	   (frout (make-frame 2)))
      (if (or (fneq (frame-ref val4 0) .04) (fneq (frame-ref val4 1) .4))
	  (snd-display #__line__ ";frame->file output: ~A?" val4))
      (file->frame gen 40 frout)
      (if (not (equal? frout val4))
	  (snd-display #__line__ ";frame->file output via frame: ~A ~A?" frout val4)))
    
    (let ((gen (make-sample->file "fmv2.snd" 4 mus-bshort mus-aifc)))
      (print-and-check gen 
		       "sample->file"
		       "sample->file fmv2.snd")
      (if (not (mus-output? gen)) (snd-display #__line__ ";~A not output?" gen))
      (if (not (sample->file? gen)) (snd-display #__line__ ";~A not sample->file?" gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(sample->file gen i 0 (* i .001))
	(sample->file gen i 1 (* i .01))
	(sample->file gen i 2 (* i .002))
	(sample->file gen i 3 (* i .003)))
      (outa 50 .015 gen)
      (outb 50 .15 gen)
      (outc 50 .02 gen)
      (outd 50 .03 gen)
      (out-any 60 .015 0 gen)
      (out-any 60 .15 1 gen)
      (out-any 60 .02 2 gen)
      (out-any 60 .03 3 gen)
      (mus-close gen))
    (let* ((gen (make-file->sample "fmv2.snd"))
	   (val0 (in-any 20 2 gen))
	   (val1 (in-any 20 3 gen))
	   (val2 (file->sample gen 50 2))
	   (val3 (file->sample gen 50 3))
	   (val4 (file->sample gen 60 2))
	   (val5 (file->sample gen 60 3)))
      (if (not (= (mus-channels gen) 4)) (snd-display #__line__ ";make-file->sample (4) chans: ~A?" (mus-channels gen)))
      (if (not (= (mus-increment gen) 0.0)) (snd-display #__line__ ";file->sample increment: ~A" (mus-increment gen))) ; dir never set in this case
      (if (or (fneq val0 .04) (fneq val1 .06)) (snd-display #__line__ ";in-any(0, 4): ~A ~A?" val0 val1))
      (if (or (fneq val2 .12) (fneq val3 .18)) (snd-display #__line__ ";file->sample(4): ~A ~A?" val2 val3))
      (if (or (fneq val4 .14) (fneq val5 .21)) (snd-display #__line__ ";in-any(4, 4): ~A ~A?" val4 val5)))
    
    (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
    (mus-sound-forget "fmv.snd")
    (let ((sf (make-sample->file "fmv.snd" 2 mus-bshort mus-next "this is a comment")))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(sample->file sf i 0 (* i .1))
	(sample->file sf i 1 (* i .01)))
      (mus-close sf)
      (if (not (= (mus-sound-chans "fmv.snd") 2)) 
	  (snd-display #__line__ ";sample->file chans: ~A" (mus-sound-chans "fmv.snd")))
      (if (not (= (mus-sound-frames "fmv.snd") 10)) 
	  (snd-display #__line__ ";sample->file frames: ~A" (mus-sound-frames "fmv.snd")))
      (if (not (= (mus-sound-samples "fmv.snd") 20)) 
	  (snd-display #__line__ ";sample->file samples: ~A" (mus-sound-samples "fmv.snd")))
      (if (not (= (mus-sound-header-type "fmv.snd") mus-next)) 
	  (snd-display #__line__ ";sample->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
      (if (not (= (mus-sound-data-format "fmv.snd") mus-bshort)) 
	  (snd-display #__line__ ";sample->file format: ~A" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
      (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
	  (snd-display #__line__ ";sample->file comment: ~A" (mus-sound-comment "fmv.snd")))
      (let ((rd (make-file->sample "fmv.snd"))
	    (happy #t))
	(do ((i 0 (+ 1 i)))
	    ((or (not happy) (= i 10)))
	  (let ((c0 (file->sample rd i 0))
		(c1 (file->sample rd i 1)))
	    (if (or (fneq c0 (* i .1))
		    (fneq c1 (* i .01)))
		(begin
		  (snd-display #__line__ ";sample->file->sample at ~A: ~A ~A" i c0 c1)
		  (set! happy #f)))))
	(mus-close rd))
      (set! sf (continue-sample->file "fmv.snd"))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(sample->file sf (+ i 5) 0 (* i -.02))
	(sample->file sf (+ i 5) 1 (* i -.01)))
      (mus-close sf)
      (mus-sound-forget "fmv.snd")
      (if (not (= (mus-sound-chans "fmv.snd") 2)) 
	  (snd-display #__line__ ";continue-sample->file chans: ~A" (mus-sound-chans "fmv.snd")))
      (if (not (= (mus-sound-frames "fmv.snd") 15)) 
	  (snd-display #__line__ ";continue-sample->file frames: ~A" (mus-sound-frames "fmv.snd")))
      (if (not (= (mus-sound-samples "fmv.snd") 30)) 
	  (snd-display #__line__ ";continue-sample->file samples: ~A" (mus-sound-samples "fmv.snd")))
      (if (not (= (mus-sound-header-type "fmv.snd") mus-next)) 
	  (snd-display #__line__ ";continue-sample->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
      (if (not (= (mus-sound-data-format "fmv.snd") mus-bshort)) 
	  (snd-display #__line__ ";continue-sample->file format: ~A" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
      (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
	  (snd-display #__line__ ";continue-sample->file comment: ~A" (mus-sound-comment "fmv.snd")))
      (let ((ind (open-sound "fmv.snd")))
	(let ((c0 (channel->vct 0 15 ind 0))
	      (c1 (channel->vct 0 15 ind 1)))
	  (if (not (vequal c0 (vct 0.0 0.1 0.2 0.3 0.4 0.5 0.58 0.66 0.74 0.82 -0.1 -0.12 -0.14 -0.16 -0.18)))
	      (snd-display #__line__ ";continue-sample->file (0): ~A" c0))
	  (if (not (vequal c1 (vct 0.0 0.01 0.02 0.03 0.04 0.05 0.05 0.05 0.05 0.05 -0.05 -0.06 -0.07 -0.08 -0.09)))
	      (snd-display #__line__ ";continue-sample->file (1): ~A" c1)))
	(close-sound ind))
      (delete-file "fmv.snd")
      (mus-sound-forget "fmv.snd"))
    
    (let ((sf (make-frame->file "fmv.snd" 2 mus-lfloat mus-riff "this is a comment")))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(frame->file sf i (make-frame 2 (* i .1) (* i .01))))
      (mus-close sf)
      (if (not (= (mus-sound-chans "fmv.snd") 2)) 
	  (snd-display #__line__ ";frame->file chans: ~A" (mus-sound-chans "fmv.snd")))
      (if (not (= (mus-sound-frames "fmv.snd") 10)) 
	  (snd-display #__line__ ";frame->file frames: ~A" (mus-sound-frames "fmv.snd")))
      (if (not (= (mus-sound-samples "fmv.snd") 20)) 
	  (snd-display #__line__ ";frame->file samples: ~A" (mus-sound-samples "fmv.snd")))
      (if (not (= (mus-sound-header-type "fmv.snd") mus-riff)) 
	  (snd-display #__line__ ";frame->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
      (if (not (= (mus-sound-data-format "fmv.snd") mus-lfloat)) 
	  (snd-display #__line__ ";frame->file format: ~A" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
      (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
	  (snd-display #__line__ ";frame->file comment: ~A" (mus-sound-comment "fmv.snd")))
      (let ((rd (make-file->frame "fmv.snd"))
	    (happy #t))
	(do ((i 0 (+ 1 i)))
	    ((or (not happy) (= i 10)))
	  (let ((f0 (file->frame rd i)))
	    (if (or (not (= (mus-length f0) 2))
		    (fneq (frame-ref f0 0) (* i .1))
		    (fneq (frame-ref f0 1) (* i .01)))
		(begin
		  (snd-display #__line__ ";frame->file->frame at ~A: ~A" i f0)
		  (set! happy #f)))))
	(mus-close rd))
      (set! sf (continue-frame->file "fmv.snd"))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(frame->file sf (+ i 5) (make-frame 2 (* i -.02) (* i -.01))))
      (mus-close sf)
      (mus-sound-forget "fmv.snd")
      (if (not (= (mus-sound-chans "fmv.snd") 2)) 
	  (snd-display #__line__ ";continue-frame->file chans: ~A" (mus-sound-chans "fmv.snd")))
      (if (not (= (mus-sound-frames "fmv.snd") 15)) 
	  (snd-display #__line__ ";continue-frame->file frames: ~A" (mus-sound-frames "fmv.snd")))
      (if (not (= (mus-sound-samples "fmv.snd") 30)) 
	  (snd-display #__line__ ";continue-frame->file samples: ~A" (mus-sound-samples "fmv.snd")))
      (if (not (= (mus-sound-header-type "fmv.snd") mus-riff)) 
	  (snd-display #__line__ ";continue-frame->file type: ~A" (mus-header-type-name (mus-sound-header-type "fmv.snd"))))
      (if (not (= (mus-sound-data-format "fmv.snd") mus-lfloat)) 
	  (snd-display #__line__ ";continue-frame->file format: ~A" (mus-data-format-name (mus-sound-data-format "fmv.snd"))))
      (if (not (string=? (mus-sound-comment "fmv.snd") "this is a comment"))
	  (snd-display #__line__ ";continue-frame->file comment: ~A" (mus-sound-comment "fmv.snd")))
      (let ((ind (open-sound "fmv.snd")))
	(let ((c0 (channel->vct 0 15 ind 0))
	      (c1 (channel->vct 0 15 ind 1)))
	  (if (not (vequal c0 (vct 0.0 0.1 0.2 0.3 0.4 0.5 0.58 0.66 0.74 0.82 -0.1 -0.12 -0.14 -0.16 -0.18)))
	      (snd-display #__line__ ";continue-frame->file (0): ~A" c0))
	  (if (not (vequal c1 (vct 0.0 0.01 0.02 0.03 0.04 0.05 0.05 0.05 0.05 0.05 -0.05 -0.06 -0.07 -0.08 -0.09)))
	      (snd-display #__line__ ";continue-frame->file (1): ~A" c1)))
	(close-sound ind))
      (delete-file "fmv.snd")
      (mus-sound-forget "fmv.snd"))
    
    (let ((v0 (make-vct 1000))
	  (os (make-oscil 440.0)))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(vct-set! v0 i (* .1 (oscil os))))
      (array->file "fmv3.snd" v0 10000 22050 1) ; 10000 deliberate
      (let ((v1 (make-vct 1000)))
	(file->array "fmv3.snd" 0 0 1000 v1)
	(do ((i 0 (+ 1 i)))
	    ((= i 1000))
	  (if (fneq (vct-ref v0 i) (vct-ref v1 i)) 
	      (snd-display #__line__ ";array->file->array: ~A ~A ~A?" i (vct-ref v0 i) (vct-ref v1 i)))))
      
      (let ((var (catch #t (lambda () (array->file "fmv3.snd" v0 -1 1000 1)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display #__line__ ";array->file bad samps: ~A" var)))
      (let ((var (catch #t (lambda () (array->file "/bad/baddy/fmv3.snd" v0 1 1000 1)) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display #__line__ ";array->file bad file: ~A" var)))
      (let ((var (catch #t (lambda () (file->array "fmv3.snd" -1 0 -1 v0)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display #__line__ ";file->array bad samps: ~A" var))))
    
    (let ((gen (make-rand 10000.0))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "rand"
		       "rand freq: 10000.000Hz, phase: 0.000, amp: 1.000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (rand gen 0.0)))
      (if (not (rand? gen)) (snd-display #__line__ ";~A not rand?" gen))
      (if (fneq (mus-phase gen) 3.3624296) (snd-display #__line__ ";rand phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 10000.0) (snd-display #__line__ ";rand frequency: ~F?" (mus-frequency gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";set! mus-scaler rand: ~A" (mus-scaler gen)))
      (if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display #__line__ ";rand output: ~A" v0)))
    
    (let ((gen (make-rand 10000.0 :envelope '(0 0 1 1)))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "rand"
		       "rand freq: 10000.000Hz, phase: 0.000, amp: 1.000, with distribution envelope")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (rand gen 0.0)))
      (if (not (rand? gen)) (snd-display #__line__ ";(dist) ~A not rand?" gen))
      (if (fneq (mus-frequency gen) 10000.0) (snd-display #__line__ ";(dist) rand frequency: ~F?" (mus-frequency gen)))
      (if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display #__line__ ";(dist) rand output: ~A" v0))
      (if (or (not (vct? (mus-data gen)))
	      (not (= (mus-length gen) (vct-length (mus-data gen))))
	      (not (= (mus-length gen) 512)))
	  (snd-display #__line__ ";(dist) rand data: ~A ~A" (mus-length gen) (mus-data gen))))
    
    (let ((gen1 (make-rand 10000.0 :envelope '(0 0 1 1)))
	  (gen2 (make-rand 10000.0 :envelope '(0 1 1 0)))
	  (up1 0)
	  (down1 0)
	  (bad1 0)
	  (up2 0)
	  (down2 0)
	  (bad2 0))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(let ((val1 (rand gen1))
	      (val2 (rand gen2)))
	  (if (>= val1 .5)
	      (set! up1 (+ 1 up1))
	      (if (>= val1 0.0)
		  (set! down1 (+ 1 down1))
		  (set! bad1 (+ 1 bad1))))
	  (if (>= val2 .5)
	      (set! up2 (+ 1 up2))
	      (if (>= val2 0.0)
		  (set! down2 (+ 1 down2))
		  (set! bad2 (+ 1 bad2))))))
      (if (or (not (= bad1 0))
	      (not (= bad2 0))
	      (> (* 2 down1) up1)
	      (> (* 2 up2) down2))
	  (snd-display #__line__ "; rand dist: ~A ~A ~A, ~A ~A ~A" down1 up1 bad1 down2 up2 bad2)))
    
					;      (test-gen-equal (make-rand 1000) (make-rand 1000) (make-rand 500))
					;      (test-gen-equal (make-rand 1000) (make-rand 1000) (make-rand 1000 0.5))
    
    (let ((gen (make-rand-interp 4000.0))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "rand-interp"
		       (mus-describe gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (rand-interp gen 0.0)))
      (if (not (rand-interp? gen)) (snd-display #__line__ ";~A not rand-interp?" gen))
      (if (fneq (mus-phase gen) 5.114882) (snd-display #__line__ ";rand-interp phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 4000.0) (snd-display #__line__ ";rand-interp frequency: ~F?" (mus-frequency gen)))
      (set! (mus-scaler gen) 0.5)
      (if (fneq (mus-scaler gen) 0.5) (snd-display #__line__ ";set! mus-scaler rand-interp: ~A" (mus-scaler gen)))
      (if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display #__line__ ";rand-interp output: ~A" v0)))
    
    (let ((gen (make-rand-interp 4000.0 :envelope '(-1 1 0 0 1 1)))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "rand-interp"
		       (mus-describe gen))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (rand-interp gen 0.0)))
      (if (not (rand-interp? gen)) (snd-display #__line__ ";(dist) ~A not rand-interp?" gen))
      (if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display #__line__ ";(dist) rand-interp output: ~A" v0))
      (if (or (not (vct? (mus-data gen)))
	      (not (= (mus-length gen) (vct-length (mus-data gen))))
	      (not (= (mus-length gen) 512)))
	  (snd-display #__line__ ";(dist) rand-interp data: ~A ~A" (mus-length gen) (mus-data gen))))
    
    (let ((gen (make-rand 10000.0 1.0))
	  (gen1 (make-rand-interp 10000.0 1.0)))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(let* ((val1 (gen 0.0))
	       (val2 (gen1 0.0)))
	  (if (or (> val1 1.0)
		  (< val1 -1.0))
	      (snd-display #__line__ ";rand: ~A ~A" val1 gen))
	  (if (or (> val2 1.0)
		  (< val2 -1.0))
	      (snd-display #__line__ ";rand-interp: ~A ~A" val2 gen1)))))
    
    (let ((gen (make-rand 10000.0 :distribution (inverse-integrate '(0 0 1 1))))
	  (v0 (make-vct 10)))
      (print-and-check gen 
		       "rand"
		       "rand freq: 10000.000Hz, phase: 0.000, amp: 1.000, with distribution envelope")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (rand gen 0.0)))
      (if (not (rand? gen)) (snd-display #__line__ ";(dist 2) ~A not rand?" gen))
      (if (fneq (mus-frequency gen) 10000.0) (snd-display #__line__ ";(dist 2) rand frequency: ~F?" (mus-frequency gen)))
      (if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display #__line__ ";(dist 2) rand output: ~A" v0))
      (if (or (not (vct? (mus-data gen)))
	      (not (= (mus-length gen) (vct-length (mus-data gen))))
	      (not (= (mus-length gen) 512)))
	  (snd-display #__line__ ";(dist 2) rand data: ~A ~A" (mus-length gen) (mus-data gen))))
    
    (let ((gen1 (make-rand 10000.0 :distribution (inverse-integrate '(0 0 1 1))))
	  (gen2 (make-rand 10000.0 :distribution (inverse-integrate '(0 1 1 0))))
	  (up1 0)
	  (down1 0)
	  (bad1 0)
	  (up2 0)
	  (down2 0)
	  (bad2 0))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(let ((val1 (rand gen1))
	      (val2 (rand gen2)))
	  (if (>= val1 .5)
	      (set! up1 (+ 1 up1))
	      (if (>= val1 0.0)
		  (set! down1 (+ 1 down1))
		  (set! bad1 (+ 1 bad1))))
	  (if (>= val2 .5)
	      (set! up2 (+ 1 up2))
	      (if (>= val2 0.0)
		  (set! down2 (+ 1 down2))
		  (set! bad2 (+ 1 bad2))))))
      (if (or (not (= bad1 0))
	      (not (= bad2 0))
	      (> (* 2.5 down1) up1)
	      (> (* 2.0 up2) down2))
	  (snd-display #__line__ "; rand dist 2: ~A ~A ~A, ~A ~A ~A" down1 up1 bad1 down2 up2 bad2))) ; 234 766 0, 705 295 0
    
    (let ((ind (new-sound :size 100)))
      (select-sound ind)
      (map-channel (lambda (y) (any-random 1.0 '(0 1 1 1))))
      (let ((place (scan-channel (lambda (y) (or (< y 0.0) (> y 1.0))))))
	(if place (snd-display #__line__ ";any-random 0 to 1: ~A" place)))
      (if (< (maxamp) .5) (snd-display #__line__ ";any-random maxamp: ~A" (maxamp))) ; possible, but extremely unlikely
      (let ((avg 0.0))
	(scan-channel (lambda (y) (set! avg (+ avg y)) #f))
	(if (> (abs (- (/ avg (frames)) .5)) .2) (snd-display #__line__ ";any-random skewed?")))
      (let ((g (gaussian-distribution 1.0))) 
	(map-channel (lambda (y) (any-random 1.0 g))))
      (let ((g (pareto-distribution 1.0))) 
	(map-channel (lambda (y) (any-random 1.0 g))))
      (let ((new-file-name (file-name ind)))
	(close-sound ind)
	(if (file-exists? new-file-name) (delete-file new-file-name))))
    
    (let ((v1 (inverse-integrate '(-1 1 1 1))))
      (if (fneq (vct-ref v1 4) -0.984)
	  (snd-display #__line__ ";inverse-integrate -1 to 1 uniform: ~A" v1)))
    (let ((v1 (inverse-integrate '(0 1 1 1))))
      (if (fneq (vct-ref v1 4) .008)
	  (snd-display #__line__ ";inverse-integrate 0 to 1 uniform: ~A" v1)))
    (let ((v1 (inverse-integrate '(0 1 1 0))))
      (if (fneq (vct-ref v1 4) .004)
	  (snd-display #__line__ ";inverse-integrate 0 to 1 1 to 0: ~A" v1)))
    (let ((v1 (inverse-integrate '(0 0 .5 1 1 0))))
      (if (fneq (vct-ref v1 4) .073)
	  (snd-display #__line__ ";inverse-integrate triangle: ~A" v1)))
    (let ((v1 (inverse-integrate (gaussian-envelope 1.0))))
      (if (fneq (vct-ref v1 4) -0.593)
	  (snd-display #__line__ ";inverse-integrate gaussian: ~A" v1)))
    
    (let ((minp 1.0)
	  (maxp -1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 1100))
	(let ((val1 (mus-random 1.0)))
	  (if (< val1 minp) (set! minp val1))
	  (if (> val1 maxp) (set! maxp val1))
	  (if (or (> val1 1.0)
		  (< val1 -1.0))
	      (snd-display #__line__ ";mus-random: ~A" val1))))
      (if (or (< maxp .9)
	      (> minp -.9))
	  (snd-display #__line__ ";mus-random: ~A ~A" minp maxp))
      (set! minp 12.0)
      (set! maxp -12.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 1100))
	(let ((val1 (mus-random 12.0)))
	  (if (< val1 minp) (set! minp val1))
	  (if (> val1 maxp) (set! maxp val1))
	  (if (or (> val1 12.0)
		  (< val1 -12.0))
	      (snd-display #__line__ ";mus-random (12): ~A" val1))))
      (if (or (< maxp 11.0)
	      (> minp -11.0))
	  (snd-display #__line__ ";mus-random (12): ~A ~A" minp maxp)))
    
    (let ((v (lambda (n) ; chi^2 or mus-random
	       (let ((hits (make-vector 10 0)))
		 (do ((i 0 (+ 1 i )))
		     ((= i n))
		   (let ((y (floor (+ 5 (mus-random 5.0)))))
		     (vector-set! hits y (+ 1 (vector-ref hits y)))))
		 (let ((sum 0.0)
		       (p (/ n 10.0)))
		   (do ((i 0 (+ 1 i)))
		       ((= i 10) sum)
		     (let ((num (- (vector-ref hits i) p)))
		       (set! sum (+ sum (/ (* num num) p))))))))))
      
      ;;:(v 10000)
      ;;#(999 1017 1002 1024 1048 971 963 1000 980 996) 5.8
      ;; if less than 4 complain
      
      (let ((vr (v 10000)))
	(if (< vr 4.0)
	    (snd-display #__line__ ";mus-random not so random? ~A (chi)" vr))))
    
    (let ((v1 (lambda (n)
		(let ((hits (make-vector 10 0))
		      (gen (make-rand 22050.0)))
		  (do ((i 0 (+ 1 i )))
		      ((= i n))
		    (let ((y (floor (+ 5 (* 5 (rand gen 0.0))))))
		      (vector-set! hits y (+ 1 (vector-ref hits y)))))
		  (let ((sum 0.0)
			(p (/ n 10.0)))
		    (do ((i 0 (+ 1 i)))
			((= i 10) sum)
		      (let ((num (- (vector-ref hits i) p)))
			(set! sum (+ sum (/ (* num num) p))))))))))
      
      ;;:(v1 10000)
      ;;#(979 1015 977 1008 954 1049 997 1020 1015 986) 6.606
      
      (let ((vr (v1 10000)))
	(if (< vr 4.0)
	    (snd-display #__line__ ";rand not so random? ~A (chi)" vr))))
    
    (let ((data (make-vct 65536)))
      (do ((i 0 (+ 1 i)))
	  ((= i 65536))
	(vct-set! data i (mus-random 1.0)))
      (let* ((ndat (snd-spectrum data rectangular-window 65536 #t 0.0 #f #f))
	     (peak (vct-peak ndat))
	     (sum 0.0))
	(if (> peak 1000.0)
	    (snd-display #__line__ ";mus-random spectral peak: ~A" peak))
	(do ((i 0 (+ 1 i)))
	    ((= i 32768))
	  (set! sum (+ sum (vct-ref ndat i))))
	(if (> (/ sum 32768.0) 200.0)
	    (snd-display #__line__ ";random average: ~A ~A" (/ sum 32768.0) (vct-ref ndat 0)))
	(do ((i 0 (+ 1 i)))
	    ((= i 65536))
	  (vct-set! data i (mus-random 1.0)))
	(autocorrelate data)
	(vct-set! data 0 0.0)
	(let ((pk (vct-peak data)))
	  (if (> pk 1000)
	      (snd-display #__line__ ";random autocorrelate peak: ~A" (vct-peak data)))
	  (set! sum 0.0)
	  (do ((i 0 (+ 1 i)))
	      ((= i 32768))
	    (set! sum (+ sum (abs (vct-ref data i)))))
	  (if (> (/ sum 32768.0) 200.0)
	      (snd-display #__line__ ";random autocorrelate average: ~A" (/ sum 32768.0))))))
    
    (set! (locsig-type) mus-interp-linear)
    (let* ((gen (make-locsig 30.0 :channels 2))
	   (gen1 (make-locsig 60.0 :channels 2))
	   (gen2 (make-locsig 60.0 :channels 4))
	   (gen200 (make-locsig 200.0 :channels 4))
	   (gen3 gen1)
	   (fr0 (locsig gen 0 1.0)))
      (print-and-check gen 
		       "locsig"
		       "locsig chans 2, outn: [0.667 0.333], interp: linear")
      (if (not (locsig? gen)) (snd-display #__line__ ";~A not locsig?" gen))
      (if (not (eq? gen1 gen3)) (snd-display #__line__ ";locsig eq? ~A ~A" gen1 gen3))
      (if (not (equal? gen1 gen3)) (snd-display #__line__ ";locsig equal? ~A ~A" gen1 gen3))
      (if (eq? gen1 gen2) (snd-display #__line__ ";locsig 1 eq? ~A ~A" gen1 gen2))
      (if (equal? gen gen1) (snd-display #__line__ ";locsig 2 equal? ~A ~A" gen gen1))
      (if (equal? gen gen2) (snd-display #__line__ ";locsig 3 equal? ~A ~A" gen gen2))
      (if (or (fneq (locsig-ref gen 0) .667) (fneq (locsig-ref gen 1) .333))
	  (snd-display #__line__ ";locsig ref: ~F ~F?" (locsig-ref gen 0) (locsig-ref gen 1)))
      (if (not (vequal (mus-data gen) (vct 0.667 0.333)))
	  (snd-display #__line__ ";locsig gen outn: ~A" (mus-data gen)))
      (if (not (vequal (mus-data gen1) (vct 0.333 0.667)))
	  (snd-display #__line__ ";locsig gen2 outn: ~A" (mus-data gen1)))
      (if (not (vequal (mus-data gen2) (vct 0.333 0.667 0.000 0.000)))
	  (snd-display #__line__ ";locsig gen2 outn: ~A" (mus-data gen2)))
      (if (not (vequal (mus-data gen200) (vct 0.000 0.000 0.778 0.222)))
	  (snd-display #__line__ ";locsig gen200 outn: ~A" (mus-data gen200)))
      (set! (locsig-ref gen 0) .25)
      (if (not (vequal (mus-data gen) (vct 0.250 0.333)))
	  (snd-display #__line__ ";locsig gen .25 outn: ~A" (mus-data gen)))
      (set! fr0 (locsig gen 0 1.0))
      (locsig-set! gen 0 .5)
      (if (not (vequal (mus-data gen) (vct 0.500 0.333)))
	  (snd-display #__line__ ";locsig gen .5 outn: ~A" (mus-data gen)))
      (set! fr0 (locsig gen 0 1.0))
      (set! gen (make-locsig 120.0 2.0 .1 :channels 4))
      (if (not (vequal (mus-data gen) (vct 0.000 0.333 0.167 0.000)))
	  (snd-display #__line__ ";locsig gen 120 outn: ~A" (mus-data gen)))
      (set! fr0 (locsig gen 0 1.0))
      (set! gen (make-locsig 300.0 2.0 .1 :channels 4))
      (if (not (vequal (mus-data gen) (vct 0.167 0.000 0.000 0.333)))
	  (snd-display #__line__ ";locsig gen 300 outn: ~A" (mus-data gen)))
      (set! fr0 (locsig gen 0 1.0))
      (move-locsig gen1 90.0 1.0)
      (if (not (vequal (mus-data gen1) (vct 0.000 1.000)))
	  (snd-display #__line__ ";locsig gen1 90 outn: ~A" (mus-data gen)))
      (move-locsig gen1 0.0 1.0)
      (if (not (vequal (mus-data gen1) (vct 1.000 0.000)))
	  (snd-display #__line__ ";locsig gen1 0 outn: ~A" (mus-data gen)))
      (move-locsig gen1 45.0 1.0)
      (if (not (vequal (mus-data gen1) (vct 0.500 0.500)))
	  (snd-display #__line__ ";locsig gen1 45 outn: ~A" (mus-data gen)))
      (move-locsig gen1 135.0 2.0)
      (if (not (vequal (mus-data gen1) (vct 0.000 0.500)))
	  (snd-display #__line__ ";locsig gen1 135 outn: ~A" (mus-data gen)))
      (move-locsig gen1 -270.0 3.0)
      (if (not (vequal (mus-data gen1) (vct 0.000 0.333)))
	  (snd-display #__line__ ";locsig gen1 -270 outn: ~A" (mus-data gen))))
    
    (for-each 
     (lambda (chans)
       (let ((m1 (make-locsig :channels chans)))
	 (if (or (not (= (mus-channels m1) chans))
		 (not (= (mus-length m1) chans)))
	     (snd-display #__line__ ";locsig ~A chans but: ~A ~A" chans (mus-channels m1) (mus-length m1)))
	 (do ((i 0 (+ 1 i)))
	     ((= i chans))
	   (locsig-set! m1 i (* i .1)))
	 (do ((i 0 (+ 1 i)))
	     ((= i chans))
	   (if (fneq (locsig-ref m1 i) (* i .1))
	       (snd-display #__line__ ";locsig[~A] = ~A (~A)?" i (locsig-ref m1 i) (* i .1))))))
     (list 1 2 4 8))
    
    (let ((var (catch #t (lambda () (make-locsig :channels 0)) (lambda args args))))
      (if (not (eq? (car var) 'mus-error))
	  (snd-display #__line__ ";make-locsig bad (0) chans: ~A" var)))
    (let ((var (catch #t (lambda () (make-locsig :channels -2)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-locsig bad (-2) chans: ~A" var)))
    (let ((var (catch #t (lambda () (make-locsig :output 1)) (lambda args args))))
      (if (not (eq? (car var) 'wrong-type-arg))
	  (snd-display #__line__ ";make-locsig bad output: ~A" var)))
    (let ((var (catch #t (lambda () (locsig-ref (make-locsig) 1)) (lambda args args))))
      (if (and (pair? var)
	       (not (eq? (car var) 'mus-error)))
	  (snd-display #__line__ ";locsig-ref bad chan: ~A" var)))
    (let ((var (catch #t (lambda () (make-locsig :revout 1)) (lambda args args))))
      (if (and (pair? var)
	       (not (eq? (car var) 'wrong-type-arg)))
	  (snd-display #__line__ ";make-locsig bad revout: ~A" var)))
    (let ((var (catch #t (lambda () (let ((locs (make-locsig 200 :channels 2))) (locsig-ref locs -1))) (lambda args args))))
      (if (and (pair? var)
	       (not (eq? (car var) 'mus-error)))
	  (snd-display #__line__ ";locsig-ref bad chan: ~A" var)))
    (let ((var (catch #t (lambda () (let ((locs (make-locsig))) (locsig-set! locs 2 .1))) (lambda args args))))
      (if (and (pair? var)
	       (not (eq? (car var) 'mus-error)))
	  (snd-display #__line__ ";locsig-set! bad chan (2): ~A" var)))
    (let ((var (catch #t (lambda () (let ((locs (make-locsig :reverb .1))) (locsig-reverb-ref locs 2))) (lambda args args))))
      (if (and (pair? var)
	       (not (eq? (car var) 'mus-error)))
	  (snd-display #__line__ ";locsig-reverb-ref bad reverb chan (2): ~A" var)))
    (let ((var (catch #t (lambda () (let ((locs (make-locsig :reverb .1))) (locsig-reverb-set! locs 2 .1))) (lambda args args))))
      (if (and (pair? var)
	       (not (eq? (car var) 'mus-error)))
	  (snd-display #__line__ ";locsig-reverb-set! bad reverb chan (2): ~A" var)))
    
    (let ((locs (make-locsig :channels 8 :degree 0)))
      (move-locsig locs 180 1.0)
      (if (fneq (locsig-ref locs 0) 0.0) (snd-display #__line__ ";move-locsig by jump: ~A" (mus-data locs)))
      (if (not (vequal (mus-data locs) (vct 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";move-locsig by jump data: ~A" (mus-data locs)))
      (move-locsig locs 120.0 1.0)
      (if (not (vequal (mus-data locs) (vct 0.000 0.000 0.333 0.667 0.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";move-locsig by jump 120 data: ~A" (mus-data locs)))
      (move-locsig locs -20.0 1.0)
      (if (not (vequal (mus-data locs) (vct 0.556 0.000 0.000 0.000 0.000 0.000 0.000 0.444)))
	  (snd-display #__line__ ";move-locsig by jump -20 data: ~A" (mus-data locs))))
    
    (let ((sf (make-sample->file "fmv4.snd" 8 mus-bshort mus-next "this is a comment"))
	  (sfrev (make-sample->file "fmv4.reverb" 8 mus-bshort mus-next "this is a comment")))
      (let ((locs (make-locsig :channels 8 :degree 0 :distance 1.0 :reverb 0.1 
			       :output sf :revout sfrev :type mus-interp-linear)))
	(if (not (vequal (mus-data locs) (vct 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";ws not move-locsig by jump data: ~A" (mus-data locs)))
	(if (not (vequal (mus-xcoeffs locs) (vct 0.100 0.000 0.000 0.000 0.0 0.0 0.0 0.0)))
	    (snd-display #__line__ ";ws not move-locsig by jump rev data: ~A" (mus-xcoeffs locs)))
	(move-locsig locs 180 2.0)
	(if (fneq (locsig-ref locs 0) 0.0) (snd-display #__line__ ";ws move-locsig by jump: ~A" (mus-data locs)))
	(if (not (vequal (mus-data locs) (vct 0.000 0.000 0.000 0.000 0.500 0.000 0.000 0.000)))
	    (snd-display #__line__ ";ws move-locsig by jump data: ~A" (mus-data locs)))
	(if (not (vequal (mus-xcoeffs locs) (vct 0.000 0.000 0.000 0.000 0.071 0.000 0.000 0.000)))
	    (snd-display #__line__ ";ws move-locsig by jump rev data: ~A" (mus-xcoeffs locs)))
	(move-locsig locs 120.0 3.0)
	(if (not (vequal (mus-data locs) (vct 0.000 0.000 0.111 0.222 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";ws move-locsig by jump 120 data: ~A" (mus-data locs)))
	(if (not (vequal (mus-xcoeffs locs) (vct 0.000 0.000 0.019 0.038 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";ws move-locsig by jump 120 rev data: ~A" (mus-xcoeffs locs)))
	(move-locsig locs -20.0 4.0)
	(if (not (vequal (mus-data locs) (vct 0.139 0.000 0.000 0.000 0.000 0.000 0.000 0.111)))
	    (snd-display #__line__ ";ws move-locsig by jump -20 data: ~A" (mus-data locs)))
	(if (not (vequal (mus-xcoeffs locs) (vct 0.028 0.000 0.000 0.000 0.000 0.000 0.000 0.022)))
	    (snd-display #__line__ ";ws move-locsig by jump -20 rev data: ~A" (mus-xcoeffs locs))))
      (mus-close sf)
      (mus-close sfrev))
    
    (if (file-exists? "fmv4.snd") (delete-file "fmv4.snd"))
    (if (file-exists? "fmv4.reverb") (delete-file "fmv4.reverb"))
    (mus-sound-prune)
    
    (for-each
     (lambda (ht)
       (let ((ind (find-sound (with-sound (:channels 8)
					  (do ((i 0 (+ 1 i)))
					      ((= i 8))
					    (locsig (make-locsig :degree (* i 45) :output *output*) i 0.5))))))
	 (do ((i 0 (+ 1 i)))
	     ((= i 8))
	   (let ((samps (channel->vct 0 8 ind i)))
	     (do ((k 0 (+ 1 k)))
		 ((= k 8))
	       (if (and (= k i) (fneq (vct-ref samps k) 0.5))
		   (snd-display #__line__ ";8 out ~A chan ~A samp ~A (0.5): ~A" (mus-header-type->string ht) i k (vct-ref samps k)))
	       (if (and (not (= i k)) (fneq (vct-ref samps k) 0.0))
		   (snd-display #__line__ ";8 out ~A chan ~A samp ~A (0.0): ~A" (mus-header-type->string ht) i k (vct-ref samps k))))))
	 (close-sound ind)))
     (list mus-caff mus-aifc mus-next mus-riff mus-rf64))
    
    (let* ((gen (make-frame->file "fmv4.snd" 2 mus-bshort mus-next))
	   (rev (make-frame->file "fmv4.reverb" 1 mus-bshort mus-next))
	   (lc (make-locsig 60.0 :reverb .1 :channels 2 :output gen :revout rev)))
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(locsig lc i 1.0))
      (if (fneq (locsig-reverb-ref lc 0) .1) (snd-display #__line__ ";locsig reverb ref: ~A?" (locsig-reverb-ref lc 0)))
      (set! (locsig-reverb-ref lc 0) .3)
      (if (fneq (locsig-reverb-ref lc 0) .3) (snd-display #__line__ ";set locsig reverb ref: ~A?" (locsig-reverb-ref lc 0)))
      (locsig-reverb-set! lc 0 .2)
      (if (fneq (locsig-reverb-ref lc 0) .2) (snd-display #__line__ ";locsig reverb set: ~A?" (locsig-reverb-ref lc 0)))
      (mus-close gen)
      (mus-close rev)
      (let ((v0 (make-vct 100))
	    (v1 (make-vct 100))
	    (v2 (make-vct 100)))
	(file->array "fmv4.snd" 0 0 100 v0)
	(file->array "fmv4.snd" 1 0 100 v1)
	(file->array "fmv4.reverb" 0 0 100 v2)
	(if (fneq (vct-ref v2 0) .1) (snd-display #__line__ ";locsig reverb: ~A?" v2))
	(if (fneq (* 2 (vct-ref v0 0)) (vct-ref v1 0)) (snd-display #__line__ ";locsig direct: ~A ~A?" (vct-ref v0 0) (vct-ref v1 0)))))
    
    (let* ((gen (make-frame->file "fmv4.snd" 4 mus-bshort mus-next))
	   (rev (make-frame->file "fmv4.reverb" 4 mus-bshort mus-next))
	   (lc (make-locsig 60.0 :reverb .1 :channels 4 :distance 4.0 :output gen :revout rev)))
      (print-and-check lc
		       "locsig"
		       "locsig chans 4, outn: [0.083 0.167 0.000 0.000], revn: [0.017 0.033 0.000 0.000], interp: linear")
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(locsig lc i 1.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 4))
	(locsig-reverb-set! lc i (* i .1))
	(if (fneq (locsig-reverb-ref lc i) (* i .1))
	    (snd-display #__line__ ";locsig reverb set![~A]: ~A?" i (locsig-reverb-ref lc i))))
      (print-and-check lc
		       "locsig"
		       "locsig chans 4, outn: [0.083 0.167 0.000 0.000], revn: [0.000 0.100 0.200 0.300], interp: linear")
      (if (not (vct? (mus-data lc))) (snd-display #__line__ ";out data locsig: ~A" (mus-data lc)))
      (if (not (vct? (mus-xcoeffs lc))) (snd-display #__line__ ";rev data locsig: ~A" (mus-xcoeffs lc)))
      (let ((xcs (mus-xcoeffs lc)))
	(if (fneq (mus-xcoeff lc 0) (vct-ref xcs 0)) (snd-display #__line__ ";locsig xcoeff: ~A ~A" (mus-xcoeff lc 0) (vct-ref xcs 0)))
	(if (fneq (mus-xcoeff lc 1) .1) (snd-display #__line__ ";locsig xcoeff 1: ~A ~A (.1)" (mus-xcoeff lc 0) (vct-ref xcs 0))))
      (mus-close gen)
      (mus-close rev))
    
    (print-and-check (make-locsig 160 :channels 4)
		     "locsig"
		     "locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
    (print-and-check (make-locsig -200 :channels 4)
		     "locsig"
		     "locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
    (print-and-check (make-locsig 160 :channels 4 :distance .5)
		     "locsig"
		     "locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
    (print-and-check (make-locsig 320 :channels 4)
		     "locsig"
		     "locsig chans 4, outn: [0.556 0.000 0.000 0.444], interp: linear")
    (print-and-check (make-locsig -40 :channels 4)
		     "locsig"
		     "locsig chans 4, outn: [0.556 0.000 0.000 0.444], interp: linear")
    (print-and-check (make-locsig 320 :channels 2)
		     "locsig"
		     "locsig chans 2, outn: [0.000 1.000], interp: linear")
    (print-and-check (make-locsig -40 :channels 2)
		     "locsig"
		     "locsig chans 2, outn: [0.000 1.000], interp: linear")
    (print-and-check (make-locsig 160 :channels 4 :output (make-sound-data 4 10))
		     "locsig"
		     "locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
    (print-and-check (make-locsig 0 :channels 1 :output (make-vct 10))
		     "locsig"
		     "locsig chans 1, outn: [1.000], interp: linear")
    (letrec ((locsig-data
	      (lambda (gen)
		(let* ((chans (mus-channels gen))
		       (dat (make-vct chans)))
		  (do ((i 0 (+ 1 i)))
		      ((= i chans))
		    (vct-set! dat i (locsig-ref gen i)))
		  dat))))
      (let ((gen (make-locsig -.1 :channels 8)))
	(if (not (vequal (locsig-data gen) (vct 0.998 0.000 0.000 0.000 0.000 0.000 0.000 0.002)))
	    (snd-display #__line__ ";locsig -.1(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig -359.9 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.998 0.002 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";locsig -359.9(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig -359.9 :channels 4))
	(if (not (vequal (locsig-data gen) (vct 0.999 0.001 0.000 0.000)))
	    (snd-display #__line__ ";locsig -359.9(4): ~A" (locsig-data gen)))
	(set! gen (make-locsig -360.1 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.998 0.000 0.000 0.000 0.000 0.000 0.000 0.002)))
	    (snd-display #__line__ ";locsig -360.1(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig -700 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.556 0.444 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";locsig -700(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig -700 :channels 2))
	(if (not (vequal (locsig-data gen) (vct 0.778 0.222)))
	    (snd-display #__line__ ";locsig -700(2): ~A" (locsig-data gen)))
	(set! gen (make-locsig 20 :channels 2))
	(if (not (vequal (locsig-data gen) (vct 0.778 0.222)))
	    (snd-display #__line__ ";locsig 20(2): ~A" (locsig-data gen)))
	(set! gen (make-locsig 123456.0 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.467 0.000 0.000 0.000 0.000 0.000 0.000 0.533)))
	    (snd-display #__line__ ";locsig 123456(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig 336.0 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.467 0.000 0.000 0.000 0.000 0.000 0.000 0.533)))
	    (snd-display #__line__ ";locsig 336(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig -123456.0 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.467 0.533 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";locsig -123456(8): ~A" (locsig-data gen)))
	(set! gen (make-locsig 24.0 :channels 8))
	(if (not (vequal (locsig-data gen) (vct 0.467 0.533 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";locsig 24(8): ~A" (locsig-data gen)))))
    
    (for-each 
     (lambda (rev-chans)
       
       (define (locsig-scalers chans degree type)
	 (define (fmod a b)
	   (let ((pos (floor (/ a b))))
	     (- a (* pos b))))
	 (if (= chans 1)
	     (vct 1.0)
	     (let* ((deg (if (= chans 2)
			     (max 0.0 (min 90.0 degree))
			     (fmod degree 360.0)))
		    (degs-per-chan (if (= chans 2)
				       90.0
				       (/ 360.0 chans)))
		    (pos (/ deg degs-per-chan))
		    (left (floor pos))
		    (right (modulo (+ left 1) chans))
		    (frac (- pos left))
		    (v (make-vct chans)))
	       (if (= type mus-interp-linear)
		   (begin
		     (vct-set! v left (- 1.0 frac))
		     (vct-set! v right frac))
		   (let* ((ldeg (* (/ pi 2) (- 0.5 frac)))
			  (norm (/ (sqrt 2.0) 2.0))
			  (c (cos ldeg))
			  (s (sin ldeg)))
		     (vct-set! v left (* norm (+ c s)))
		     (vct-set! v right (* norm (- c s)))))
	       v)))
       
       (if (file-exists? "test.reverb") (delete-file "test.reverb"))
       (let ((revfile (if (> rev-chans 0)
			  (make-frame->file "test.reverb" rev-chans mus-bshort mus-next)
			  #f))
	     (happy #t))
	 (for-each
	  (lambda (type)
	    ;; global type def as well as local par override etc
	    
	    (if happy
		(begin
		  (set! (locsig-type) type)
		  (if (not (= (locsig-type) type)) (snd-display #__line__ ";locsig-type: ~A ~A" type (locsig-type)))
		  
		  (for-each 
		   (lambda (deg)
		     (let ((gen (make-locsig deg :channels 1 :revout revfile :reverb .1 :distance 2.0))
			   (revs (if revfile (locsig-scalers rev-chans deg type))))
		       (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";locsig ~A: ~A" deg gen))
		       (if (fneq (locsig-ref gen 0) 0.5) (snd-display #__line__ ";locsig scaler[~A] ~A: ~A" type deg (locsig-ref gen 0)))
		       (if revfile
			   (do ((i 0 (+ 1 i)))
			       ((or (not happy) (= i rev-chans)))
			     (if (fneq (locsig-reverb-ref gen i) (* (/ .1 (sqrt 2.0)) (vct-ref revs i)))
				 (begin 
				   (snd-display #__line__ ";mono locrev[~A] ~A at ~A: ~A ~A" 
						type gen deg 
						(locsig-reverb-ref gen i) 
						(* (/ .1 (sqrt 2.0)) (vct-ref revs i)))
				   (set! happy #f)))))))
		   (list 0.0 45.0 90.0 1234.0))
		  
		  (for-each
		   (lambda (ltype)
		     (for-each 
		      (lambda (deg)
			(let ((gen (make-locsig deg :channels 1 :type ltype)))
			  (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";locsig ~A: ~A" deg gen))
			  (if (fneq (locsig-ref gen 0) 1.0) (snd-display #__line__ ";locsig[~A] scaler ~A: ~A" ltype deg (locsig-ref gen 0)))))
		      (list 0.0 45.0 90.0 1234.0)))
		   (list mus-interp-linear mus-interp-sinusoidal))
		  
		  (for-each
		   (lambda (chans)
		     (for-each 
		      (lambda (deg)
			(let ((gen (make-locsig deg :channels chans :revout revfile :reverb .1)))
			  (if (not (= (mus-channels gen) chans)) (begin (snd-display #__line__ ";multi locsig ~A: ~A" deg gen) (quit)))
			  (let ((scalers (locsig-scalers chans deg type))
				(revs (if revfile (locsig-scalers rev-chans deg type))))
			    (do ((i 0 (+ 1 i)))
				((or (not happy) (= i chans)))
			      (if (fneq (locsig-ref gen i) (vct-ref scalers i)) 
				  (begin 
				    (snd-display #__line__ ";locsig[~A] ~A at ~A: ~A ~A" type gen deg (locsig-ref gen i) (vct-ref scalers i)) 
				    (set! happy #f))))
			    (if revfile
				(do ((i 0 (+ 1 i)))
				    ((or (not happy) (= i rev-chans)))
				  (if (fneq (locsig-reverb-ref gen i) (* .1 (vct-ref revs i)))
				      (begin 
					(snd-display #__line__ ";locrev[~A] ~A at ~A: ~A ~A" 
						     type gen deg 
						     (locsig-reverb-ref gen i) 
						     (* .1 (vct-ref revs i)))
					(set! happy #f))))))))
		      (list 0.0 45.0 90.0 120.0 180.0 275.0 315.0 300.0 15.0 1234.0)))
		   (list 2 3 4 5 8 12 16 24))
		  
		  (for-each
		   (lambda (chans)
		     (for-each 
		      (lambda (ltype)
			(for-each
			 (lambda (deg)
			   (let ((gen (make-locsig deg :channels chans :type ltype :revout revfile :reverb .1)))
			     (if (not (= (mus-channels gen) chans)) (begin (snd-display #__line__ ";stereo locsig ~A: ~A" deg gen) (quit)))
			     (let ((scalers (locsig-scalers chans deg ltype))
				   (revs (if revfile (locsig-scalers rev-chans deg ltype))))
			       (do ((i 0 (+ 1 i)))
				   ((or (not happy) (= i chans)))
				 (if (fneq (locsig-ref gen i) (vct-ref scalers i)) 
				     (begin
				       (snd-display #__line__ ";locsig[~A] ~A at ~A: ~A ~A" ltype gen deg (locsig-ref gen i) (vct-ref scalers i))
				       (set! happy #f))))
			       (if revfile
				   (do ((i 0 (+ 1 i)))
				       ((or (not happy) (= i rev-chans)))
				     (if (fneq (locsig-reverb-ref gen i) (* .1 (vct-ref revs i)))
					 (begin 
					   (snd-display #__line__ ";locrev[~A] ~A at ~A: ~A ~A" 
							type gen deg 
							(locsig-reverb-ref gen i) 
							(* .1 (vct-ref revs i)))
					   (set! happy #f))))))))
			 (list 0.0 45.0 90.0 120.0 180.0 275.0 315.0 300.0 15.0 1234.0)))
		      (list mus-interp-linear mus-interp-sinusoidal)))
		   (list 2 3 4 5 8 12 16 24))
		  )))
	  (list mus-interp-linear mus-interp-sinusoidal))
	 (if revfile (mus-close revfile))))
     (list 0 1 2 4))
    
    (set! (locsig-type) mus-interp-linear)
    (let* ((outp (make-sound-data 1 10))
	   (gen (make-locsig 0.0 :output outp)))
      (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";make-locsig->sd chans (1): ~A" (mus-channels gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 1.0))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 1.0)))
	  (snd-display #__line__ ";locsig->sd chan 0: ~A" (sound-data->vct outp 0))))
    
    (let* ((outp (make-sound-data 2 10))
	   (gen (make-locsig 0.0 :output outp)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";make-locsig->sd chans: ~A" (mus-channels gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 1.0))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 1.0)))
	  (snd-display #__line__ ";locsig->sd chan 0: ~A" (sound-data->vct outp 0)))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.0)))
	  (snd-display #__line__ ";locsig->sd chan 1: ~A" (sound-data->vct outp 1))))
    
    (let* ((outp (make-sound-data 2 10))
	   (gen (make-locsig 45.0 :output outp)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";make-locsig->sd chans: ~A" (mus-channels gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 1.0))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 0.5)))
	  (snd-display #__line__ ";locsig->sd chan 0 (0.5): ~A (~A)" (sound-data->vct outp 0) gen))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.5)))
	  (snd-display #__line__ ";locsig->sd chan 1 (0.5): ~A" (sound-data->vct outp 1)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 0.5))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 0.75)))
	  (snd-display #__line__ ";locsig->sd chan 0 (0.75) (~A): ~A" (sound-data->vct outp 0) gen))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.75)))
	  (snd-display #__line__ ";locsig->sd chan 1 (0.75): ~A" (sound-data->vct outp 1))))
    
    (let* ((outp (make-vct 10))
	   (gen (make-locsig 0.0 :output outp)))
      (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";make-locsig->vct chans: ~A" (mus-channels gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 1.0))
      (if (not (vequal outp (make-vct 10 1.0)))
	  (snd-display #__line__ ";locsig->vct chan 0: ~A" outp))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 0.5))
      (if (not (vequal outp (make-vct 10 1.5)))
	  (snd-display #__line__ ";locsig->vct chan 0: ~A" outp)))
    
    (let* ((outp (make-vct 10))
	   (gen (make-locsig 45.0 :channels 2 :output outp)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";make-locsig->vct chans (2): ~A" (mus-channels gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 1.0))
      (if (not (vequal outp (make-vct 10 0.5)))
	  (snd-display #__line__ ";locsig(2)->vct chan 0: ~A" outp))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 0.5))
      (if (not (vequal outp (make-vct 10 0.75)))
	  (snd-display #__line__ ";locsig(2)->vct chan 0: ~A" outp)))
    
    (let* ((outp (make-sound-data 4 10))
	   (gen (make-locsig 135.0 :output outp)))
      (if (not (= (mus-channels gen) 4)) (snd-display #__line__ ";make-locsig->sd chans (4): ~A" (mus-channels gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(locsig gen i 1.0))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 0.0)))
	  (snd-display #__line__ ";locsig(4)->sd chan 0 (0.5): ~A" (sound-data->vct outp 0)))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.5)))
	  (snd-display #__line__ ";locsig(4)->sd chan 1 (0.5) (~A): ~A" (sound-data->vct outp 1) gen))
      (if (not (vequal (sound-data->vct outp 2) (make-vct 10 0.5)))
	  (snd-display #__line__ ";locsig(4)->sd chan 2 (0.5): ~A" (sound-data->vct outp 2)))
      (if (not (vequal (sound-data->vct outp 3) (make-vct 10 0.0)))
	  (snd-display #__line__ ";locsig(4)->sd chan 3 (0.5): ~A" (sound-data->vct outp 3))))
    
    
    (set! (mus-array-print-length) 8)
    (let* ((outf1 (make-frame->file "fmv.snd" 1 mus-bshort mus-next))
	   (outf4 (make-frame->file "fmv1.snd" 4 mus-bshort mus-next))
	   (revf (make-frame->file "fmv2.snd" 1 mus-bshort mus-next))
	   (start 0)
	   (end 1000)
	   (dur 1.0)
	   (gen1 (make-move-sound (list 0 1000 1 0
					(make-delay 32) 
					(make-env '(0 0 1 1) :length 1001) 
					(make-env '(0 0 1 1) :length 1001)
					(vector (make-delay 32)) 
					(vector (make-env '(0 0 1 1) :length 1001)) 
					#f
					(vector 0 1))
				  outf1))
	   (gen2 (make-move-sound (list start end 4 0
					(make-delay 12) 
					(make-env '(0 0 10 1) :duration dur)
					#f
					(make-vector 4 #f)
					(vector (make-env '(0 0 1 1 2 0 3 0 4 0) :duration dur)
						(make-env '(0 0 1 0 2 1 3 0 4 0) :duration dur)
						(make-env '(0 0 1 0 2 0 3 1 4 0) :duration dur)
						(make-env '(0 0 1 0 2 0 3 0 4 1) :duration dur))
					#f
					(vector 0 1 2 3))
				  outf4))
	   (gen3 (make-move-sound (list 0 1000 1 1
					(make-delay 32) 
					(make-env '(0 0 1 1) :length 1001) 
					(make-env '(0 0 1 1) :length 1001)
					(vector (make-delay 32)) 
					(vector (make-env '(0 0 1 1) :length 1001)) 
					(vector (make-env '(0 1 1 1) :length 1001))
					(vector 0 1))
				  outf1 revf)))
      
      (print-and-check gen1
		       "move-sound"
		       "move-sound start: 0, end: 1000, out chans 1, rev chans: 0
  doppler delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
  doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
  global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
  out_delays[1]:
    [0]: delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
  out_envs[1]:
    [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
  rev_envs: nil
  out_map[1]: (0)
  free: arrays: true, gens: false
")
      
      (print-and-check gen2
		       "move-sound"
		       "move-sound start: 0, end: 1000, out chans 4, rev chans: 0
  doppler delay line[12, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
  doppler env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 10.000 1.000]
  global reverb null
  out_delays[4]:
    [0]: nil
    [1]: nil
    [2]: nil
    [3]: nil
  out_envs[4]:
    [0]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000 2.000 0.000 3.000 0.000...(0: 0.000, 8: 4.000)]
    [1]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 0.000 2.000 1.000 3.000 0.000...(0: 0.000, 8: 4.000)]
    [2]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 0.000 2.000 0.000 3.000 1.000...(0: 0.000, 8: 4.000)]
    [3]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 0.000 2.000 0.000 3.000 0.000...(0: 0.000, 8: 4.000)]
  rev_envs: nil
  out_map[4]: (0 1 2 3)
  free: arrays: true, gens: false
")
      
      (print-and-check gen3
		       "move-sound"
		       "move-sound start: 0, end: 1000, out chans 1, rev chans: 1
  doppler delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
  doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
  global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
  out_delays[1]:
    [0]: delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
  out_envs[1]:
    [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
  rev_envs[1]:
    [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 1.000 1.000 1.000]
  out_map[1]: (0)
  free: arrays: true, gens: false
")
      
      (if (not (move-sound? gen1)) (snd-display #__line__ ";move-sound?"))
      (if (equal? gen1 gen2) (snd-display #__line__ ";move-sounds are equal?"))
      (if (not (= (mus-channels gen1) 1)) (snd-display #__line__ ";mus-channels move-sound (1): ~A" (mus-channels gen1)))
      (if (not (= (mus-channels gen2) 4)) (snd-display #__line__ ";mus-channels move-sound (4): ~A" (mus-channels gen2)))
      (mus-reset gen1) ; a no-op
      
      (let ((v (make-vct 10 0.0)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v i (+ (move-sound gen1 i 0.5)
			   (gen2 i 0.25)
			   (move-sound gen3 i 0.125))))
	(if (not (vequal v (make-vct 10 0.875)))
	    (snd-display #__line__ ";move-sound output: ~A" v)))
      
      (let ((var (catch #t (lambda () (make-move-sound (list 0 1000 1 0 (make-oscil 32) (make-env '(0 0 1 1) :length 1001) 
							     (make-env '(0 0 1 1) :length 1001) (vector (make-delay 32)) 
							     (vector (make-env '(0 0 1 1) :length 1001)) #f (vector 0 1))
						       outf1))
			(lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display #__line__ ";make-move-sound bad doppler delay: ~A" var)))
      (let ((var (catch #t (lambda () (make-move-sound (list 0 1000 1 0 (make-oscil 32) (make-env '(0 0 1 1) :length 1001) 
							     (make-env '(0 0 1 1) :length 1001) (vector (make-delay 32)))
						       outf1))
			(lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display #__line__ ";make-move-sound truncated list: ~A" var)))
      (let ((var (catch #t (lambda () (make-move-sound (list 0 1000 1 0 (make-delay 32) (make-env '(0 0 1 1) :length 1001) 
							     #f (vector #f)
							     (vector (make-env '(0 0 1 1) :length 1001)) #f #f)
						       outf1))
			(lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display #__line__ ";make-move-sound no out map: ~A" var)))
      
      
      (mus-close outf1) 
      (mus-close outf4) 
      (mus-close revf)
      
      (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
      (if (file-exists? "fmv1.snd") (delete-file "fmv1.snd"))
      (if (file-exists? "fmv2.snd") (delete-file "fmv2.snd"))
      (mus-sound-prune))
    
    (let* ((vo (make-vct 1000))
	   (gen1 (make-move-sound (list 0 1000 1 0
					(make-delay 32) 
					(make-env '(0 0 1 1) :length 1001) 
					(make-env '(0 0 1 1) :length 1001)
					(vector (make-delay 32)) 
					(vector (make-env '(0 0 1 1) :length 1001)) 
					#f
					(vector 0 1))
				  vo))
	   (start -1))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(move-sound gen1 i 0.5)
	(if (and (< start 0)
		 (fneq (vct-ref vo i) 0.0))
	    (set! start i)))
      (if (not (= start 64))
	  (snd-display #__line__ ";move-sound vct output start: ~A" start))
      (if (fneq (vct-peak vo) 0.484)
	  (snd-display #__line__ ";move-sound vct output: ~A" (vct-peak vo))))
    
    (let* ((vo (make-sound-data 1 1000))
	   (gen1 (make-move-sound (list 0 1000 1 0
					(make-delay 32) 
					(make-env '(0 0 1 1) :length 1001) 
					(make-env '(0 0 1 1) :length 1001)
					(vector (make-delay 32)) 
					(vector (make-env '(0 0 1 1) :length 1001)) 
					#f
					(vector 0 1))
				  vo))
	   (start -1))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(move-sound gen1 i 0.5)
	(if (and (< start 0)
		 (fneq (sound-data-ref vo 0 i) 0.0))
	    (set! start i)))
      (if (not (= start 64))
	  (snd-display #__line__ ";move-sound sd output start: ~A" start))
      (if (fneq (sound-data-peak vo) 0.484)
	  (snd-display #__line__ ";move-sound sd peak output: ~A" (sound-data-peak vo)))
      (if (fneq (apply max (sound-data-maxamp vo)) 0.484)
	  (snd-display #__line__ ";move-sound sd output: ~A" (sound-data-maxamp vo))))
    
    (let* ((vo (make-vct 1000))
	   (gen1 (make-move-sound (list 0 1000 1 0
					(make-delay 32) 
					(make-env '(0 0 1 1) :length 1001) 
					(make-env '(0 0 1 1) :length 1001)
					(vector (make-delay 32)) 
					(vector (make-env '(0 0 1 1) :length 1001)) 
					#f
					(vector 0 1))
				  vo))
	   (start -1))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= i 1000))
	 (move-sound gen1 i 0.5)
	 (if (and (< start 0)
		  (> (abs (vct-ref vo i)) 0.001))
	     (set! start i))))
      (if (not (= start 64))
	  (snd-display #__line__ ";move-sound opt vct output start: ~A" start))
      (if (fneq (vct-peak vo) 0.484)
	  (snd-display #__line__ ";move-sound opt vct output: ~A" (vct-peak vo))))
    
    (let* ((vo (make-sound-data 1 1000))
	   (gen1 (make-move-sound (list 0 1000 1 0
					(make-delay 32) 
					(make-env '(0 0 1 1) :length 1001) 
					(make-env '(0 0 1 1) :length 1001)
					(vector (make-delay 32)) 
					(vector (make-env '(0 0 1 1) :length 1001)) 
					#f
					(vector 0 1))
				  vo))
	   (start -1))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= i 1000))
	 (move-sound gen1 i 0.5)
	 (if (and (< start 0)
		  (> (abs (sound-data-ref vo 0 i)) 0.001))
	     (set! start i))))
      (if (not (= start 64))
	  (snd-display #__line__ ";move-sound opt sd output start: ~A" start))
      (if (fneq (apply max (sound-data-maxamp vo)) 0.484)
	  (snd-display #__line__ ";move-sound opt sd output: ~A" (sound-data-maxamp vo))))
    
    
    (let ((gen (make-src :srate 2.0))
	  (v0 (make-vct 10))
	  (rd (make-readin "oboe.snd" 0 2000))
	  (gen1 (make-src :srate 2.0))
	  (gen2 (make-src :srate 0.0)) ; make sure this is allowed
	  (v1 (make-vct 10))
	  (rd1a (make-readin "oboe.snd" 0 2000)))
      (print-and-check gen 
		       "src"
		       "src width: 10, x: 0.000, incr: 2.000, sinc table len: 10000")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (src gen 0.0 (lambda (dir) (readin rd)))))
      (vct-map! v1 (lambda () (if (src? gen1) (src gen1 0.0 (lambda (dir) (readin rd1a))))))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";run src: ~A ~A" v0 v1))
      (if (not (src? gen)) (snd-display #__line__ ";~A not scr?" gen))
      (if (or (fneq (vct-ref v0 1) .001) (fneq (vct-ref v0 7) .021)) (snd-display #__line__ ";src output: ~A" v0))
      (if (fneq (mus-increment gen) 2.0) (snd-display #__line__ ";src increment: ~F?" (mus-increment gen)))
      (if (fneq (mus-increment gen2) 0.0) (snd-display #__line__ ";src 0.0 increment: ~F?" (mus-increment gen2)))
      (if (fneq (mus-increment rd) 1.0) (snd-display #__line__ ";readin increment: ~F?" (mus-increment rd)))
      (if (not (= (mus-length gen) 10)) (snd-display #__line__ ";src length: ~A" (mus-length gen)))
      (let ((gold gen))
	(set! gen (make-src (lambda (dir)
			      0.0)))
	(if (equal? gen gold) (snd-display #__line__ ";src eqaul? ~A ~A" gen gold))))
    
    (let ((var (catch #t (lambda () (make-src :width -1)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-src bad width: ~A" var)))
    
    (let ((s1 (make-src (lambda (y) 1.0) 2.0)))
      (src s1 25.0) ; try to tickle segfault
      (src s1 25.0)
      (src s1 125.0)
      (src s1 -25.0)
      (src s1 -125.0))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (make-src (lambda (y) 1.0) 1.5 :width (+ 5 (* i 10))))
    (clear-sincs)
    
    (let ((ctr 0.0))
      (let ((gen (make-src :srate 2.0 :input (lambda (dir) (let ((val ctr)) (set! ctr (+ 1 ctr)) val))))
	    (v0 (make-vct 10)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! v0 i (src gen 0.0)))
	(set! ctr 0.0) ; will be accessed within reset
	(mus-reset gen)
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (let ((old-val (vct-ref v0 i))
		(new-val (src gen 0.0)))
	    (if (fneq old-val new-val)
		(snd-display #__line__ ";reset src ~A ~A ~A" i old-val new-val))))))
    
    (let ((gen (make-granulate :expansion 2.0))
	  (v0 (make-vct 1000))
	  (rd (make-readin "oboe.snd" 0 4000 1 2048))
	  (gen1 (make-granulate :expansion 2.0))
	  (v1 (make-vct 1000))
	  (rd1b (make-readin :file "oboe.snd" :channel 0 :start 4000 :direction 1 :size (mus-file-buffer-size))))
      (print-and-check gen 
		       "granulate"
		       "granulate expansion: 2.000 (551/1102), scaler: 0.600, length: 0.150 secs (3308 samps), ramp: 0.060")
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(vct-set! v0 i (granulate gen (lambda (dir) (readin rd)))))
      (vct-map! v1 (lambda () (if (granulate? gen1) (granulate gen1 (lambda (dir) (readin rd1b))))))
      (let ((worst (abs (- (vct-peak v0) (vct-peak v1)))))
	(if (> worst .01) (snd-display #__line__ ";run granulate: ~A" worst)))
      (let ((genx gen1))
	(if (not (equal? genx gen1))
	    (snd-display #__line__ ";granulate equal? ~A ~A ~A" genx gen1 (equal? genx gen1))))
      (if (equal? gen gen1) (snd-display #__line__ ";granulate equal? ~A ~A" gen gen1))
      (if (= (vct-peak v0) 0.0) (snd-display #__line__ ";granulate output peak: ~F?" (vct-peak v0)))
      (if (not (granulate? gen)) (snd-display #__line__ ";~A not granulate?" gen))
      (if (fneq (mus-increment gen) 2.0) (snd-display #__line__ ";granulate increment: ~F?" (mus-increment gen)))
      (if (fneq (mus-scaler gen) 0.6) (snd-display #__line__ ";granulate scaler: ~F?" (mus-scaler gen)))
      (if (ffneq (mus-frequency gen) 0.05) (snd-display #__line__ ";granulate frequency: ~F?" (mus-frequency gen)))
      (if (not (= (mus-ramp gen) 1323)) (snd-display #__line__ ";granulate ramp: ~F?" (mus-ramp gen)))
      (if (not (= (mus-length gen) 3308)) (snd-display #__line__ ";granulate length: ~A?" (mus-length gen)))
      (if (not (= (mus-hop gen) 1102)) (snd-display #__line__ ";granulate hop: ~A?" (mus-hop gen)))
      (set! (mus-hop gen) 1000) (if (not (= (mus-hop gen) 1000)) (snd-display #__line__ ";granulate set-hop: ~A?" (mus-hop gen)))
      (set! (mus-ramp gen) 1000) (if (not (= (mus-ramp gen) 1000)) (snd-display #__line__ ";granulate set-ramp: ~A?" (mus-ramp gen)))
      (set! (mus-length gen) 3000) (if (not (= (mus-length gen) 3000)) (snd-display #__line__ ";granulate set-length: ~A?" (mus-length gen)))
      (set! (mus-increment gen) 3.0)
      (if (> (abs (- (mus-increment gen) 3.0)) .01) (snd-display #__line__ ";granulate set-increment: ~F?" (mus-increment gen)))
      (set! (mus-increment gen) 0.0) ; should be a no-op
      (if (> (abs (- (mus-increment gen) 3.0)) .01) (snd-display #__line__ ";granulate set-increment 0.0: ~F?" (mus-increment gen)))
      (set! (mus-location gen) 1)
      (if (not (= (mus-location gen) 1)) (snd-display #__line__ ";mus-location grn: ~A" (mus-location gen)))
      (set! (mus-frequency gen) .1)
      (if (fneq (mus-frequency gen) .1) (snd-display #__line__ ";set granulate freq: ~A" (mus-frequency gen)))
      (let ((tag (catch #t (lambda () (granulate gen (lambda (a b) a))) (lambda args (car args)))))
	(if (not (eq? tag 'bad-arity)) 
	    (snd-display #__line__ ";granulate bad func: ~A" tag))))
    (let ((var (catch #t (lambda () (make-granulate :hop 35.0 :length 35.0)) (lambda args args))))
      (if (not (eq? (car var) 'out-of-range))
	  (snd-display #__line__ ";make-granulate bad sizes: ~A" var)))
    
    (let ((ind (open-sound "oboe.snd"))
	  (mx (maxamp)))
      (let ((rd (make-sampler 0)))
	(let ((grn (make-granulate :expansion 2.0
				   :input (lambda (dir) (rd))
				   :edit (lambda (g)
					   (let ((grain (mus-data g))  ; current grain
						 (len (mus-length g))) ; current grain length
					     (do ((i 0 (+ 1 i)))
						 ((= i len) len)       ; grain length unchanged in this case
					       (vct-set! grain i (* 2 (vct-ref grain i))))
					     0)))))
	  (map-channel (lambda (y) (granulate grn)))
	  (if (or (< (/ (maxamp) mx) 1.4) (> (/ mx (maxamp)) 2.5))
	      (snd-display #__line__ ";gran edit 2* (0): ~A ~A" mx (maxamp)))
	  (undo)))
      (let ((rd (make-sampler 0)))
	(let ((grn (make-granulate :expansion 2.0
				   :input (lambda (dir) (rd))
				   :edit (lambda (g)
					   (let ((grain (mus-data g))  ; current grain
						 (len (mus-length g))) ; current grain length
					     (do ((i 0 (+ 1 i)))
						 ((= i len) len)       ; grain length unchanged in this case
					       (vct-set! grain i (* 4 (vct-ref grain i))))
					     0)))))
	  (map-channel (lambda (y) (granulate grn)))
	  (if (or (< (/ (maxamp) mx) 3.0) (> (/ mx (maxamp)) 6.0))
	      (snd-display #__line__ ";gran edit 4* (0): ~A ~A" mx (maxamp)))
	  (revert-sound ind)))
      (let ((grn (make-granulate :expansion 2.0
				 :edit (lambda (g)
					 (let ((grain (mus-data g))  ; current grain
					       (len (mus-length g))) ; current grain length
					   (do ((i 0 (+ 1 i)))
					       ((= i len) len)       ; grain length unchanged in this case
					     (vct-set! grain i (* 2 (vct-ref grain i))))
					   0))))
	    (rd (make-sampler 0)))
	(map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	(if (or (< (/ (maxamp) mx) 1.4) (> (/ mx (maxamp)) 2.5))
	    (snd-display #__line__ ";gran edit 2* (1): ~A ~A" mx (maxamp)))
	(undo)
	(let ((grn (make-granulate :expansion 2.0
				   :edit (lambda (g)
					   (let ((grain (mus-data g))  ; current grain
						 (len (mus-length g))) ; current grain length
					     (do ((i 0 (+ 1 i)))
						 ((= i len) len)       ; grain length unchanged in this case
					       (vct-set! grain i (* 4 (vct-ref grain i))))
					     0))))
	      (rd (make-sampler 0)))
	  (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	  (if (or (< (/ (maxamp) mx) 3.0) (> (/ mx (maxamp)) 6.0))
	      (snd-display #__line__ ";gran edit 4* (1): ~A ~A" mx (maxamp)))
	  (revert-sound ind)))
      (let ((grn (make-granulate :expansion 2.0))
	    (rd (make-sampler 0)))
	(map-channel (lambda (y) (granulate grn 
					    (lambda (dir) 
					      (rd))
					    (lambda (g)
					      (let ((grain (mus-data g))  ; current grain
						    (len (mus-length g))) ; current grain length
						(do ((i 0 (+ 1 i)))
						    ((= i len) len)       ; grain length unchanged in this case
						  (vct-set! grain i (* 2 (vct-ref grain i))))
						0)))))
	(if (or (< (/ (maxamp) mx) 1.4) (> (/ mx (maxamp)) 2.5))
	    (snd-display #__line__ ";gran edit 2* (2): ~A ~A" mx (maxamp)))
	(undo)
	(let ((grn (make-granulate :expansion 2.0))
	      (rd (make-sampler 0)))
	  (map-channel (lambda (y) (granulate grn 
					      (lambda (dir) 
						(rd))
					      (lambda (g)
						(let ((grain (mus-data g))  ; current grain
						      (len (mus-length g))) ; current grain length
						  (do ((i 0 (+ 1 i)))
						      ((= i len) len)       ; grain length unchanged in this case
						    (vct-set! grain i (* 4 (vct-ref grain i))))
						  0)))))
	  (if (or (< (/ (maxamp) mx) 3.0) (> (/ mx (maxamp)) 6.0))
	      (snd-display #__line__ ";gran edit 4* (2): ~A ~A" mx (maxamp)))))
      (close-sound ind))
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((grn (make-granulate :expansion 2.0 :length .01 :hop .05))
	    (rd (make-sampler 0)))
	(map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	(let ((mx (maxamp)))
	  (if (> mx .2) (snd-display #__line__ ";trouble in granulate len .01 hop .05: ~A" mx))
	  (undo)))
      (let ((grn (make-granulate :expansion 2.0 :length .04 :hop .05))
	    (rd (make-sampler 0)))
	(map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	(let ((mx (maxamp)))
	  (if (> mx .2) (snd-display #__line__ ";trouble in granulate len .04 hop .05: ~A" mx))
	  (undo)))
      (let ((grn (make-granulate :expansion 2.0 :length .01 :hop .25))
	    (rd (make-sampler 0)))
	(map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	(let ((mx (maxamp)))
	  (if (> mx .2) (snd-display #__line__ ";trouble in granulate len .01 hop .25: ~A" mx))
	  (undo)))
      (let ((grn (make-granulate :expansion 2.0 :length .4 :hop .5))
	    (rd (make-sampler 0)))
	(map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	(let ((mx (maxamp)))
	  (if (> mx .2) (snd-display #__line__ ";trouble in granulate len .4 hop .5: ~A" mx))
	  (undo)))
      (close-sound ind))
    
    (let ((ind (new-sound :size 1000)))
      (let ((gen (make-granulate :jitter 0.0 :hop .004 :length .001)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";gran 0 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 0.060 0.060 0.060 0.053 
			      0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 0 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.000 0.000 0.000 0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 0.060
			      0.060 0.060 0.053 0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 0 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";gran 1 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 0.060 0.060 0.060 0.053 
			      0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 1 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 40 30) 
			 (vct 0.000 0.000 0.000 0.000 0.000 0.007 0.013 0.020 0.027 0.033 0.040 0.047 0.053 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.053 0.047 0.040 0.033 0.027 0.020 0.013 0.007 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 1 data 40: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :ramp .1)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";gran 2 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.030 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.030 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 2 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 40 30) 
			 (vct 0.000 0.000 0.000 0.000 0.000 0.030 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.030 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 2 data 40: ~A" (channel->vct 40 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :ramp .5)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";gran 3 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060 0.055 0.049 0.044 
			      0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 3 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.000 0.000 0.000 0.000 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060 
			      0.055 0.049 0.044 0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 3 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .001 :length .001 :ramp .5)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";gran 4 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060 0.055 0.049 0.044 
			      0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.005 0.011 0.016 0.022 0.027 0.033 0.038)))
	    (snd-display #__line__ ";gran 4 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.022 0.016 0.011 0.005 0.005 0.011 0.016 0.022 0.027 0.033 0.038 0.044 0.049 0.055 0.060 0.060 
			      0.055 0.049 0.044 0.038 0.033 0.027 0.022 0.016 0.011 0.005 0.005 0.011 0.016 0.022)))
	    (snd-display #__line__ ";gran 4 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .001 :length .001 :ramp .25 :scaler 1.0)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";gran 5 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.020 0.040 0.060 0.080 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 
			      0.100 0.100 0.100 0.080 0.060 0.040 0.020 0.020 0.040 0.060 0.080 0.100 0.100 0.100)))
	    (snd-display #__line__ ";gran 5 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.080 0.060 0.040 0.020 0.020 0.040 0.060 0.080 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 
			      0.100 0.100 0.100 0.100 0.100 0.100 0.080 0.060 0.040 0.020 0.020 0.040 0.060 0.080)))
	    (snd-display #__line__ ";gran 5 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .001 :length .002 :ramp .5 :scaler 1.0)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.105) (snd-display #__line__ ";gran 6 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.005 0.009 0.014 0.018 0.023 0.027 0.032 0.036 0.041 0.045 0.050 0.055 0.059 0.064 0.068 
			      0.073 0.077 0.082 0.086 0.091 0.095 0.100 0.105 0.105 0.105 0.105 0.105 0.105 0.105)))
	    (snd-display #__line__ ";gran 6 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 
			      0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105 0.105)))
	    (snd-display #__line__ ";gran 6 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .001 :length .005 :ramp .5 :scaler 1.0)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.264) (snd-display #__line__ ";gran 7 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.002 0.004 0.005 0.007 0.009 0.011 0.013 0.015 0.016 0.018 0.020 0.022 0.024 0.025 0.027 
			      0.029 0.031 0.033 0.035 0.036 0.038 0.040 0.044 0.047 0.051 0.055 0.058 0.062 0.065)))
	    (snd-display #__line__ ";gran 7 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 85 30) 
			 (vct 0.244 0.244 0.244 0.244 0.245 0.247 0.249 0.251 0.253 0.255 0.256 0.258 0.260 0.262 0.264 0.264 
			      0.262 0.260 0.258 0.256 0.255 0.253 0.251 0.249 0.247 0.245 0.245 0.247 0.249 0.251)))
	    (snd-display #__line__ ";gran 7 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 2.0)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";gran 8 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073 
			      0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 8 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 220 30) 
			 (vct 0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073 
			      0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 8 data 220: ~A" (channel->vct 220 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";gran 9 max: ~A" mx))) ; same as 8 because expansion hits the input counter
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073 
			      0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 9 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 220 30) 
			 (vct 0.000 0.009 0.018 0.027 0.036 0.045 0.055 0.064 0.073 0.082 0.091 0.100 0.100 0.091 0.082 0.073 
			      0.064 0.055 0.045 0.036 0.027 0.018 0.009 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 9 data 220: ~A" (channel->vct 220 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .001 :length .005 :ramp .5 :scaler 1.0)))
	(map-channel (lambda (y) (granulate gen 
					    (lambda (dir) .1)
					    (lambda (g)
					      (let ((grain (mus-data g))  ; current grain
						    (len (mus-length g))) ; current grain length
						(do ((i 0 (+ 1 i)))
						    ((= i len) len)       ; grain length unchanged in this case
						  (vct-set! grain i (* 2 (vct-ref grain i)))))
					      0))))
	(let ((mx (maxamp)))
	  (if (fneq mx (* 2 0.264)) (snd-display #__line__ ";gran 10 max: ~A" mx)))
	(if (not (vequal (vct-scale! (channel->vct 0 30) 0.5)
			 (vct 0.000 0.002 0.004 0.005 0.007 0.009 0.011 0.013 0.015 0.016 0.018 0.020 0.022 0.024 0.025 0.027 
			      0.029 0.031 0.033 0.035 0.036 0.038 0.040 0.044 0.047 0.051 0.055 0.058 0.062 0.065)))
	    (snd-display #__line__ ";gran 10 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (vct-scale! (channel->vct 85 30) 0.5)
			 (vct 0.244 0.244 0.244 0.244 0.245 0.247 0.249 0.251 0.253 0.255 0.256 0.258 0.260 0.262 0.264 0.264 
			      0.262 0.260 0.258 0.256 0.255 0.253 0.251 0.249 0.247 0.245 0.245 0.247 0.249 0.251)))
	    (snd-display #__line__ ";gran 10 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .005 :length .002 :ramp 0.0 :scaler 1.0))
	    (forward #t)
	    (ctr -0.5)
	    (incr .001))
	(map-channel (lambda (y) (granulate gen 
					    (lambda (dir) (set! ctr (+ ctr incr)) ctr)
					    (lambda (g)
					      (let ((grain (mus-data g))
						    (len (mus-length g)))
						(if forward ; no change to data
						    (set! forward #f)
						    (begin
						      (set! forward #t)
						      (vct-reverse! grain len))) ; should get ramps going up then down across overall rising ramp
						len)))))
	(let ((mx (maxamp)))
	  (if (> mx 0.6) (snd-display #__line__ ";gran 11 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30)
			 (vct -0.499 -0.498 -0.497 -0.496 -0.495 -0.494 -0.493 -0.492 -0.491 -0.490 -0.489 -0.488 -0.487 -0.486 
			      -0.485 -0.484 -0.483 -0.482 -0.481 -0.480 -0.479 -0.478 -0.477 -0.476 -0.475 -0.474 -0.473 -0.472 -0.471 -0.470)))
	    (snd-display #__line__ ";gran 11 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 100 30)
			 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -0.345 -0.346 -0.347 -0.348 -0.349 
			      -0.350 -0.351 -0.352 -0.353 -0.354 -0.355 -0.356 -0.357 -0.358 -0.359 -0.360 -0.361 -0.362 -0.363 -0.364)))
	    (snd-display #__line__ ";gran 11 data 100: ~A" (channel->vct 100 30)))
	(undo))
      
      (let* ((forward #t)
	     (ctr -0.5)
	     (incr .001)
	     (gen (make-granulate :jitter 0.0 :hop .005 :length .002 :ramp 0.0 :scaler 1.0
				  :input (lambda (dir) (set! ctr (+ ctr incr)) ctr))))
	(map-channel (lambda (y) (granulate gen)))
	(let ((mx (maxamp)))
	  (if (> mx 0.6) (snd-display #__line__ ";gran 12 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30)
			 (vct -0.499 -0.498 -0.497 -0.496 -0.495 -0.494 -0.493 -0.492 -0.491 -0.490 -0.489 -0.488 -0.487 -0.486 
			      -0.485 -0.484 -0.483 -0.482 -0.481 -0.480 -0.479 -0.478 -0.477 -0.476 -0.475 -0.474 -0.473 -0.472 -0.471 -0.470)))
	    (snd-display #__line__ ";gran 12 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 100 30)
			 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -0.389 -0.388 -0.387 -0.386 -0.385 
			      -0.384 -0.383 -0.382 -0.381 -0.380 -0.379 -0.378 -0.377 -0.376 -0.375 -0.374 -0.373 -0.372 -0.371 -0.370)))
	    (snd-display #__line__ ";gran 12 data 100: ~A" (channel->vct 100 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .001 :length .005 :ramp .5 :scaler 1.0
				 :input (lambda (dir) .1)
				 :edit (lambda (g)
					 (let ((grain (mus-data g))  ; current grain
					       (len (mus-length g))) ; current grain length
					   (do ((i 0 (+ 1 i)))
					       ((= i len) len)       ; grain length unchanged in this case
					     (vct-set! grain i (* 2 (vct-ref grain i)))))
					 0))))
	(map-channel (lambda (y) (granulate gen)))
	(let ((mx (maxamp)))
	  (if (> mx .6) (snd-display #__line__ ";gran 13 max: ~A" mx)))
	(if (not (vequal (vct-scale! (channel->vct 0 30) 0.5)
			 (vct 0.000 0.002 0.004 0.005 0.007 0.009 0.011 0.013 0.015 0.016 0.018 0.020 0.022 0.024 0.025 0.027 
			      0.029 0.031 0.033 0.035 0.036 0.038 0.040 0.044 0.047 0.051 0.055 0.058 0.062 0.065)))
	    (snd-display #__line__ ";gran 13 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (vct-scale! (channel->vct 85 30) 0.5)
			 (vct 0.244 0.244 0.244 0.244 0.245 0.247 0.249 0.251 0.253 0.255 0.256 0.258 0.260 0.262 0.264 0.264 
			      0.262 0.260 0.258 0.256 0.255 0.253 0.251 0.249 0.247 0.245 0.245 0.247 0.249 0.251)))
	    (snd-display #__line__ ";gran 13 data 85: ~A" (channel->vct 85 30)))
	(undo))
      
      (let* ((forward #t)
	     (ctr -0.5)
	     (incr .001)
	     (gen (make-granulate :jitter 0.0 :hop .005 :length .002 :ramp 0.0 :scaler 1.0
				  :input (lambda (dir) (set! ctr (+ ctr incr)) ctr)
				  :edit (lambda (g)
					  (let ((grain (mus-data g))
						(len (mus-length g)))
					    (if forward
						(set! forward #f)
						(begin
						  (set! forward #t)
						  (vct-reverse! grain len)))
					    len)))))
	(map-channel (lambda (y) (granulate gen)))
	(let ((mx (maxamp)))
	  (if (> mx 0.6) (snd-display #__line__ ";gran 14 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30)
			 (vct -0.499 -0.498 -0.497 -0.496 -0.495 -0.494 -0.493 -0.492 -0.491 -0.490 -0.489 -0.488 -0.487 -0.486 
			      -0.485 -0.484 -0.483 -0.482 -0.481 -0.480 -0.479 -0.478 -0.477 -0.476 -0.475 -0.474 -0.473 -0.472 -0.471 -0.470)))
	    (snd-display #__line__ ";gran 14 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 100 30)
			 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -0.345 -0.346 -0.347 -0.348 -0.349 
			      -0.350 -0.351 -0.352 -0.353 -0.354 -0.355 -0.356 -0.357 -0.358 -0.359 -0.360 -0.361 -0.362 -0.363 -0.364)))
	    (snd-display #__line__ ";gran 14 data 100: ~A" (channel->vct 100 30)))
	(undo))
      
      (let* ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0))
	     (e (make-env '(0 0 1 .5) :length 1001))
	     (base-ramp-len (mus-length gen)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (granulate gen (lambda (dir) .1))))
	     (set! (mus-ramp gen) (round (* base-ramp-len (env e))))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";granf 0 max: ~A" mx)))
	(if (> (abs (- (mus-ramp gen) (* .5 (mus-length gen)))) 1)
	    (snd-display #__line__ ";granf 0 ramp: ~A ~A" (mus-ramp gen) (mus-length gen)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 0 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 440 30) 
			 (vct 0.000 0.012 0.024 0.036 0.048 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.048 0.036 0.024 0.012 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 0 data 440: ~A" (channel->vct 440 30)))
	(if (not (vequal (channel->vct 880 30) 
			 (vct 0.000 0.006 0.012 0.018 0.024 0.030 0.036 0.042 0.048 0.054 0.060 0.060 0.060 0.060 
			      0.054 0.048 0.042 0.036 0.030 0.024 0.018 0.012 0.006 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 0 data 880: ~A" (channel->vct 880 30)))
	(undo))
      
      
      (let* ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0))
	     (e (make-env '(0 1 1 .25) :length 1001))
	     (base-hop-len (mus-hop gen)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (granulate gen (lambda (dir) .1))))
	     (set! (mus-hop gen) (round (* base-hop-len (env e))))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";granf 1 max: ~A" mx)))
	(if (> (abs (- (mus-hop gen) (* .001 (mus-srate)))) 1)
	    (snd-display #__line__ ";granf 1 hop: ~A ~A, ~A ~A" (mus-hop gen) (abs (- (mus-hop gen) (* .001 (srate)))) (srate) (mus-srate)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 1 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 900 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060)))
	    (snd-display #__line__ ";granf 1 data 900: ~A" (channel->vct 900 30)))
	(undo))
      
      (let* ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0))
	     (e (make-env '(0 1 1 .25) :length 1001))
	     (base-freq (mus-frequency gen)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (granulate gen (lambda (dir) .1))))
	     (set! (mus-frequency gen) (* base-freq (env e)))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";granf 2 max: ~A" mx)))
	(if (> (abs (- (mus-hop gen) (* .001 (mus-srate)))) 1)
	    (snd-display #__line__ ";granf 2 hop: ~A" (mus-hop gen)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 2 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 900 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060)))
	    (snd-display #__line__ ";granf 2 data 900: ~A" (channel->vct 900 30)))
	(undo))
      
      (let ((gen (make-granulate :jitter 0.0 :hop .002 :length .001 :ramp 0.0 :scaler 1.0)))
	(map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";granf 3 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 
			      0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";gran 3 data: ~A" (channel->vct 0 30)))
	(undo))
      
      (let* ((gen (make-granulate :jitter 0.0 :hop .004 :length .001 :ramp 0.0 :scaler 1.0))
	     (e (make-env '(0 1 1 0.0) :length 1001)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (granulate gen (lambda (dir) .1))))
	     (set! (mus-scaler gen) (env e))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.1) (snd-display #__line__ ";granf 4 max: ~A" mx)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 
			      0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.100 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 4 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 440 30) 
			 (vct 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 
			      0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.056 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 4 data 440: ~A" (channel->vct 440 30)))
	(if (not (vequal (channel->vct 900 30) 
			 (vct 0.012 0.012 0.012 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 4 data 900: ~A" (channel->vct 900 30)))
	(undo))
      
      (let* ((gen (make-granulate :jitter 0.0 :hop .006 :length .001 :ramp 0.0 :max-size 2200))
	     (e (make-env '(0 1 1 5) :length 1001))
	     (base-len (mus-length gen)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (granulate gen (lambda (dir) .1))))
	     (set! (mus-length gen) (round (* base-len (env e))))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";granf 5 max: ~A" mx)))
	(if (> (abs (- (mus-length gen) (* 5 base-len))) 10)
	    (snd-display #__line__ ";granf 5 length: ~A ~A" (mus-length gen) (* 5 base-len)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 5 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 440 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 5 data 440: ~A" (channel->vct 440 30)))
	(if (not (vequal (channel->vct 800 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060)))
	    (snd-display #__line__ ";granf 5 data 800: ~A" (channel->vct 800 30)))
	(undo))
      
      (let* ((gen (make-granulate :jitter 0.0 :hop .006 :length .005 :ramp 0.0 :max-size 2200))
	     (e (make-env '(0 1 1 .2) :length 1001))
	     (base-len (mus-length gen)))
	(map-channel 
	 (lambda (y) 
	   (let ((result (granulate gen (lambda (dir) .1))))
	     (set! (mus-length gen) (round (* base-len (env e))))
	     result)))
	(let ((mx (maxamp)))
	  (if (fneq mx 0.06) (snd-display #__line__ ";granf 6 max: ~A" mx)))
	(if (> (abs (- (mus-length gen) (* .2 base-len))) 4)
	    (snd-display #__line__ ";granf 6 length: ~A ~A" (mus-length gen) (* .2 base-len)))
	(if (not (vequal (channel->vct 0 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 
			      0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060)))
	    (snd-display #__line__ ";granf 6 data: ~A" (channel->vct 0 30)))
	(if (not (vequal (channel->vct 820 30) 
			 (vct 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.060 0.000 0.000 
			      0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";granf 6 data 820: ~A" (channel->vct 820 30)))
	(undo))
      
      (let ((max-list (lambda ()
			(let ((pts '()) 
			      (samp 0)
			      (lasty 0.0))
			  (scan-channel (lambda (y) 
					  (if (and (not (>= lasty 0.1))
						   (>= y .1))
					      (set! pts (cons samp pts)))
					  (set! lasty y)
					  (set! samp (+ 1 samp))
					  #f)) 
			  (reverse pts)))))
	(let ((gen (make-granulate :jitter 0.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5)))
	  (map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	  (let ((vals (max-list)))
	    (if (not (equal? vals (list 11 231 451 671 891)))
		(snd-display #__line__ ";grn jitter 0 max: ~A" vals)))
	  (undo))
	
	(let ((oldvals #f))
	  (let ((gen (make-granulate :jitter 0.3 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5)))
	    (map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	    ;; (11 232 490 736 982) or whatever
	    (let ((vals (max-list)))
	      (if (equal? vals (list 11 231 451 671 891))
		  (snd-display #__line__ ";grn jitter 0.3 max: ~A" vals))
	      (set! oldvals vals))
	    (undo))
	  
	  (let ((gen (make-granulate :jitter 0.3 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5)))
	    (map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	    (let ((vals (max-list)))
	      (if (equal? vals oldvals)
		  (snd-display #__line__ ";grn jitter 0.3 max: ~A ~A" vals oldvals)))
	    (undo)))
	
	(let ((oldvals #f)
	      (seed 0))
	  (let ((gen (make-granulate :jitter 1.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5)))
	    (set! seed (mus-location gen))
	    (map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	    (set! oldvals (max-list))
	    (undo))
	  
	  (let ((gen (make-granulate :jitter 1.0 :hop .01 :length .001 :ramp .5 :scaler 1.0 :expansion 0.5)))
	    (set! (mus-location gen) seed)
	    (map-channel (lambda (y) (granulate gen (lambda (dir) .1))))
	    (let ((vals (max-list)))
	      (if (not (equal? vals oldvals))
		  (snd-display #__line__ ";grn jitter 1.0 max with seed: ~A ~A" vals oldvals)))
	    (undo))))
      
      (let ((fname (file-name ind)))
	(close-sound ind)
	(delete-file fname)
	(if (view-files-dialog #f)
	    (begin
	      (set! (view-files-files (view-files-dialog #f)) '())
	      (if (not (null? (view-files-files (view-files-dialog #f))))
		  (snd-display #__line__ ";set vf files list null: ~A" (view-files-files (view-files-dialog #f)))))))
      )
    
    ;; granulate with jitter=0, small hop (comb filter effect)
    (let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1 :size 10000)))
      (let ((gen (make-granulate :expansion 20.0
				 :input (lambda (dir) .01)
				 :length .00995
				 :hop .01
				 :ramp 0.0
				 :scaler 1.0
				 :jitter 0.0)))
	(clm-channel gen) ; -> .01 max (stable)
	(if (fneq (maxamp) .01) (snd-display #__line__ ";granulate stable 1: ~A" (maxamp)))
	(let ((minval (scan-channel (lambda (y) (< y .0099)))))
	  (if minval (snd-display #__line__ ";granulate stable 1 min: ~A" minval)))
	(undo)
	(set! gen (make-granulate :expansion 20.0
				  :input (lambda (dir) .1)
				  :length .00995
				  :hop .01
				  :ramp 0.0
				  :scaler 0.5
				  :jitter 0.0))
	(clm-channel gen) ; -> .05 max (stable)
	(if (fneq (maxamp) .05) (snd-display #__line__ ";granulate stable 2: ~A" (maxamp)))
	(let ((minval (scan-channel (lambda (y) (< y .0499)))))
	  (if minval (snd-display #__line__ ";granulate stable 2 min: ~A" minval)))
	(undo)
	
	(set! gen (make-granulate :expansion 10.0
				  :input (lambda (dir) .05)
				  :length .099975
				  :hop .1
				  :ramp 0.0
				  :scaler 1.0
				  :jitter 0.0))
	(clm-channel gen) ; -> .05 max (stable)
	(if (fneq (maxamp) .05) (snd-display #__line__ ";granulate stable 3: ~A" (maxamp)))
	(let ((minval (scan-channel (lambda (y) (< y .0499)))))
	  (if minval (snd-display #__line__ ";granulate stable 3 min: ~A ~A" minval (sample (cadr minval)))))
	(undo)
	
	(let ((ctr 0))
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .01
				    :hop .1
				    :ramp 0.0
				    :scaler 1.0
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .462) (snd-display #__line__ ";granulate ramped 4: ~A" (maxamp)))
	  (let ((vals (count-matches (lambda (y) (not (= y 0.0))))))
	    (if (> (abs (- vals 1104)) 10) (snd-display #__line__ ";granulate ramped 4 not 0.0: ~A" vals)))
	  (if (or (not (vequal (channel->vct 2203 10)
			       (vct 0.000 0.000 0.110 0.110 0.110 0.111 0.111 0.111 0.111 0.111)))
		  (not (vequal (channel->vct 4523 10)
			       (vct 0.232 0.232 0.232 0.232 0.232 0.232 0.232 0.232 0.233 0.233)))
		  (not (vequal (channel->vct 8928 10)
			       (vct 0.452 0.452 0.452 0.452 0.452 0.452 0.452 0.452 0.452 0.452))))
	      (snd-display #__line__ ";granulate ramped 4 data off: ~A ~A ~A" 
			   (channel->vct 2203 10) (channel->vct 4523 10) (channel->vct 8928 10)))
	  (undo)
	  
	  (set! ctr 0)
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .00995
				    :hop .01
				    :ramp 0.0
				    :scaler 1.0
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .505) (snd-display #__line__ ";granulate ramped 5: ~A" (maxamp)))
	  (let* ((mxoff 0.0)
		 (mx (maxamp))
		 (len (frames))
		 (cur 0.0)
		 (incr (/ mx len)))
	    (scan-channel (lambda (y) 
			    (let ((diff (abs (- cur y)))) 
			      (if (> diff mxoff) (set! mxoff diff))
			      (set! cur (+ cur incr))
			      #f)))
	    (if (> mxoff .02) (snd-display #__line__ ";granulate ramped 5 mxoff: ~A" mxoff))) ; .0108 actually
	  (undo)
	  
	  (set! ctr 0)
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .00995
				    :hop .01
				    :ramp 0.5
				    :scaler 1.0
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .495) (snd-display #__line__ ";granulate ramped 6: ~A" (maxamp)))
	  (if (or (not (vequal (channel->vct 2000 10)
			       (vct 0.018 0.019 0.020 0.021 0.022 0.023 0.024 0.025 0.026 0.027)))
		  (not (vequal (channel->vct 8000 10)
			       (vct 0.294 0.298 0.301 0.305 0.309 0.313 0.316 0.320 0.324 0.328))))
	      (snd-display #__line__ ";granulate ramped 6 data: ~A ~A"
			   (channel->vct 2000 10) (channel->vct 8000 10)))
	  (undo)
	  
	  (set! ctr 0)
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .00995
				    :hop .01
				    :ramp 0.25
				    :scaler 1.0
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .505) (snd-display #__line__ ";granulate ramped 7: ~A" (maxamp)))
	  (if (or (not (vequal (channel->vct 2000 10)
			       (vct 0.037 0.039 0.040 0.042 0.044 0.046 0.048 0.050 0.052 0.054)))
		  (not (vequal (channel->vct 8000 10)
			       (vct 0.404 0.404 0.404 0.404 0.404 0.405 0.405 0.405 0.405 0.405))))
	      (snd-display #__line__ ";granulate ramped 7 data: ~A ~A"
			   (channel->vct 2000 10) (channel->vct 8000 10)))
	  (undo)
	  
	  (set! ctr 0)
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .05
				    :hop .01
				    :ramp 0.25
				    :scaler 0.1
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .201) (snd-display #__line__ ";granulate ramped 7: ~A" (maxamp)))
	  (let* ((mxoff 0.0)
		 (mx (maxamp))
		 (len (frames))
		 (cur 0.0)
		 (incr (/ mx len)))
	    (scan-channel (lambda (y) 
			    (let ((diff (abs (- cur y)))) 
			      (if (> diff mxoff) (set! mxoff diff))
			      (set! cur (+ cur incr))
			      #f)))
	    (if (> mxoff .01) (snd-display #__line__ ";granulate ramped 7 mxoff: ~A" mxoff))) ; .0097 actually
	  (undo)
	  
	  (set! ctr 0)
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .1
				    :hop .01
				    :ramp 0.1
				    :scaler 0.1
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .501) (snd-display #__line__ ";granulate ramped 8: ~A" (maxamp)))
	  (let* ((mxoff 0.0)
		 (mx (maxamp))
		 (len (- (frames) 2000))
		 (cur (sample 2000))
		 (incr (/ (- mx cur) len)))
	    (scan-channel (lambda (y) 
			    (let ((diff (abs (- cur y)))) 
			      (if (> diff mxoff) (set! mxoff diff))
			      (set! cur (+ cur incr))
			      #f))
			  2000)
	    (if (> mxoff .001) (snd-display #__line__ ";granulate ramped 8 mxoff: ~A" mxoff)))
	  (undo)
	  
	  
	  (set! ctr 0)
	  (set! gen (make-granulate :expansion 2.0
				    :input (lambda (dir)
					     (let ((val (* ctr .0001)))
					       (set! ctr (+ 1 ctr))
					       val))
				    :length .4
				    :hop .01
				    :ramp 0.4
				    :scaler 0.025
				    :jitter 0.0))
	  (clm-channel gen)
	  (if (fneq (maxamp) .433) (snd-display #__line__ ";granulate ramped 9: ~A" (maxamp)))
	  (undo)
	  (close-sound ind))))
    
    (let* ((v0 (make-vct 32))
	   (v1 (make-vct 256))
	   (v2 (make-vct 256))
	   (v01 (make-vct 32))
	   (v11 (make-vct 256))
	   (v21 (make-vct 256)))
      (do ((i 1 (+ 1 i)))
	  ((= i 16))
	(vct-set! v0 i (/ 1.0 i))
	(vct-set! v01 i (/ 1.0 i)))
      (vct-set! v1 0 1.0)
      (vct-set! v11 0 1.0)
      (let ((gen (make-convolve :filter v0))
	    (n -1)
	    (gen1 (make-convolve :filter v01))
	    (n1 -1))
	(print-and-check gen 
			 "convolve"
			 "convolve size: 64")
	(if (not (convolve? gen)) (snd-display #__line__ ";~A not convolve?" gen))
	(let ((genx gen1))
	  (if (not (equal? genx gen1)) (snd-display #__line__ ";convolve equal?: ~A ~A ~A" genx gen1 (equal? genx gen1))))
	(if (equal? gen gen1) (snd-display #__line__ ";convolve equal? ~A ~A" gen gen1))
	(if (not (= (mus-length gen) 64)) (snd-display #__line__ ";convolve fft len: ~D?" (mus-length gen)))
	(do ((i 0 (+ 1 i)))
	    ((= i 128))
	  (vct-set! v2 i (convolve gen (lambda (dir) (set! n (+ n 1)) (vct-ref v1 n)))))
	(vct-map! v21 (lambda () (if (convolve? gen1) (convolve gen1 (lambda (dir) (set! n1 (+ n1 1)) (vct-ref v11 n1))))))
	(if (not (vequal v2 v21)) (snd-display #__line__ ";run gran: ~A ~A" v2 v21))
	(if (or (fneq (vct-ref v2 0) 0.0)
		(fneq (vct-ref v2 1) 1.0)
		(fneq (vct-ref v2 4) 0.25)
		(fneq (vct-ref v2 7) 0.143))
	    (snd-display #__line__ ";convolve output: ~A?" v2))
	(let ((tag (catch #t (lambda () (convolve gen (lambda (a b) a))) (lambda args (car args)))))
	  (if (not (eq? tag 'bad-arity)) 
	      (snd-display #__line__ ";convolve bad func: ~A" tag))))
      
      (convolve-files "oboe.snd" "fyow.snd" .5 "fmv.snd")
      (if (fneq (cadr (mus-sound-maxamp "fmv.snd")) .5) 
	  (snd-display #__line__ ";convolve-files: ~A /= .5?" (cadr (mus-sound-maxamp "fmv.snd"))))
      (play-sound-1 "fmv.snd"))
    
    (let* ((fd (mus-sound-open-input "oboe.snd"))
	   (chans (mus-sound-chans "oboe.snd"))
	   (data (make-sound-data chans 2000)))
      (if (not (sound-data? data)) (snd-display #__line__ ";~A not sound-data?" data))
      (if (not (= (sound-data-chans data) 1)) (snd-display #__line__ ";sound-data chans: ~A?" (sound-data-chans data)))
      (if (not (= (sound-data-length data) 2000)) (snd-display #__line__ ";sound-data length: ~A?" (sound-data-length data)))
      (mus-sound-read fd 0 1999 chans data)
      (let ((val (sound-data-ref data 0 1497)))
	(mus-sound-close-input fd)
	(if (fneq val 0.02893066) (snd-display #__line__ ";mus-sound-read: ~F?" val))))
    
    (let ((ind (new-sound "fmv.snd")))
      (set! (sample 1) .1)
      (save-sound ind)
      (if (not (equal? (edits ind 0) (list 0 0)))
	  (snd-display #__line__ ";weird: edits not cleared after save-sound?: ~A" (edits ind 0)))
      (close-sound ind)
      (set! ind (open-sound "fmv.snd"))
      (if (not (= (frames ind 0) 2))
	  (snd-display #__line__ ";save-sound 2 samps: ~A?" (frames ind 0)))
      (if (or (fneq (sample 0) 0.0)
	      (fneq (sample 1) 0.1))
	  (snd-display #__line__ ";save-sound: ~A ~A?" (sample 0) (sample 1)))
      (do ((i 3 (+ 1 i)))
	  ((= i 6))
	(set! (sample i) (* i .1))
	(save-sound ind)
	(if (not (equal? (edits ind 0) (list 0 0)))
	    (snd-display #__line__ ";weird: edits not cleared after save-sound ~A?: ~A" i (edits ind 0)))
	(close-sound ind)
	(set! ind (open-sound "fmv.snd"))
	(if (not (= (frames ind 0) (+ i 1)))
	    (snd-display #__line__ ";save-sound ~A samps: ~A?" (+ i 1) (frames ind 0)))
	(if (or (fneq (sample 0) 0.0)
		(fneq (sample 1) 0.1)
		(fneq (sample i) (* i 0.1)))
	    (snd-display #__line__ ";save-sound ~A: ~A ~A ~A?" i (sample 0) (sample 1) (sample i))))
      (close-sound ind))
    
    (let ((ind (new-sound "test.snd" :srate 22050 :channels 1 :size 1000))
	  (gen (make-ssb-am 100.0)))
      (map-channel (lambda (y) (ssb-am gen 0.0)))
      (if (fneq (maxamp) 0.0) (snd-display #__line__ ";ssb-am 0.0: ~A" (maxamp)))
      (let ((gen1 (make-oscil 220.0)))
	(map-channel (lambda (y) (* 0.5 (oscil gen1))))
	(set! gen (make-ssb-am 100.0 100))
	(map-channel (lambda (y) (ssb-am gen y)))
	(delete-samples 0 200)
	(set! gen1 (make-oscil 320.0 :initial-phase (asin (* 2 (sample 0))))) ; depends on rising side
	(map-channel (lambda (y) (- y (* 0.5 (oscil gen1)))))
	(if (> (maxamp) .004) (snd-display #__line__ ";ssb-am cancelled: ~A" (maxamp)))
	(undo 3)
	(set! gen (make-ssb-am 100.0 100))
	(map-channel (lambda (y) (ssb-am gen y (hz->radians 50.0))))
	(delete-samples 0 180)
	(set! gen1 (make-oscil 370.0 :initial-phase (asin (* 2 (sample 0))))) ; depends on rising side
	(map-channel (lambda (y) (- y (* 0.5 (oscil gen1)))))
	(if (> (maxamp) .004) (snd-display #__line__ ";ssb-am fm cancelled: ~A" (maxamp)))
	(close-sound ind)))
    
    (if (defined? 'mus-ssb-bank)
	(let ((bands (make-vector 3))
	      (ssbs (make-vector 3)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 3))
	    (vector-set! ssbs i (make-ssb-am (+ 100.0 (random 400))))
	    (vector-set! bands i (make-bandpass (hz->radians 500.0) (hz->radians 600.0) 10)))
	  (mus-ssb-bank ssbs bands .1 3)))
    
    (let ((ind (new-sound "test.snd" :srate 22050 :channels 1 :size 1000))
	  (ctr 0))
      (map-channel (lambda (y) (let ((val (sin (/ (* 2 pi ctr) 50)))) (set! ctr (+ ctr 1)) val)))
      ;; 441 Hz 
      (ssb-bank 441 882 1 100)
      (delete-samples 0 217)
      (let ((gen1 (make-oscil 882.0 :initial-phase (asin (sample 0)))))
	(map-channel (lambda (y) (- y (oscil gen1))))
	(if (> (maxamp) .04) (snd-display #__line__ ";ssb-bank cancelled: ~A" (maxamp))))
      (close-sound ind))
    
    (if *output* 
	(begin
	  (snd-display #__line__ ";*output* ~A")
	  (set! *output* #f)))
    
    (let ((nind (new-sound "fmv.snd" mus-aifc mus-bshort 22050 1 "this is a comment")))
      (time (mix-vct (with-temp-sound (:output (make-vct 22050)) (fm-violin 0 1 440 .1)) 0 nind 0))
      (play nind :wait #t)
      (save-sound nind)
      (if (not (sound? nind)) (snd-display #__line__ ";save sound clobbered ~A?" nind))
      (let ((oboe-index (or (find-sound "oboe.snd") (open-sound "oboe.snd"))))
	(if (equal? oboe-index nind) (snd-display #__line__ ";find-sound found bogus case: ~A" oboe-index))
	(cnvtest oboe-index nind .1) 
	(select-sound nind)
	(select-channel 0)
	(if (not (equal? (selected-sound) nind)) (snd-display #__line__ ";selected-sound: ~A?" (selected-sound)))
	(if (not (= (selected-channel) 0)) (snd-display #__line__ ";selected-channel: ~A?" (selected-channel)))
	(snd-test-jc-reverb 1.0 #f .1 #f) 
	(play nind :wait #t)
	(voiced->unvoiced 1.0 256 2.0 2.0) 
	(pulse-voice 80 20.0 1.0 1024 0.01)
	(map-chan (fltit))
	(close-sound oboe-index))
      (if (not (sound? nind)) (snd-display #__line__ ";close sound clobbered ~A?" nind))
      (let ((fr (frames nind 0)))
	(do ((k 0 (+ 1 k)))
	    ((= k 10))
	  (delete-samples 10 100 nind 0)
	  (save-sound nind)) ;flush out memory leaks here
	(if (not (= (frames nind 0) (- fr 1000)))
	    (snd-display #__line__ ";delete-samples: ~A ~A" fr (frames nind 0))))
      (revert-sound nind)
      (close-sound nind))
    (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
    
    (let ((nind (new-sound "fmv.snd")))
      (if (not (= (header-type nind) (default-output-header-type)))
	  (snd-display #__line__ ";new-sound default header-type: ~A ~A?"
		       (mus-header-type-name (header-type nind))
		       (mus-header-type-name (default-output-header-type))))
      (if (not (= (data-format nind) (default-output-data-format)))
	  (snd-display #__line__ ";new-sound default data-format: ~A ~A?"
		       (mus-data-format-name (data-format nind))
		       (mus-data-format-name (default-output-data-format))))
      (if (not (= (chans nind) (default-output-chans)))
	  (snd-display #__line__ ";new-sound default chans: ~A ~A?" (chans nind) (default-output-chans)))
      (if (not (= (srate nind) (default-output-srate)))
	  (snd-display #__line__ ";new-sound default srate: ~A ~A?" (srate nind) (default-output-srate)))
      (close-sound nind)
      (if (file-exists? "fmv.snd") (delete-file "fmv.snd")))
    (let ((nind (new-sound "fmv.snd" mus-nist mus-bshort 22050 1 "this is a comment")))
      (set! (sample 0 nind) 1.0) 
      (start-progress-report nind)
      (convolve-with "oboe.snd") 
      (progress-report .1 nind)
      (if (fneq (sample 1000) 0.223) (snd-display #__line__ ";convolve-with: ~A?" (sample 1000)))
      (progress-report .3 nind)
      (revert-sound nind)
      (progress-report .5 nind)
      (set! (sample 200) .0001) 
      (set! (sample 100) 1.0) 
      (progress-report .8 nind)
      (smooth-sound 0 100) 
      (finish-progress-report nind)
      (if (or (fneq (sample 50) .5) (fneq (sample 30) 0.20608) (fneq (sample 90) 0.9755))
	  (snd-display #__line__ ";smooth: ~A ~A ~A?" (sample 50) (sample 30) (sample 90)))
      (undo) 
      (set! (sinc-width) 40) 
      (set! (sample 100) 0.5) 
      (if (fneq (sample 100) 0.5) (snd-display #__line__ ";set-sample 100: ~A?" (sample 100)))
      (src-sound .1) 
      (if (or (fneq (sample 1000) 0.5) (fneq (sample 1024) 0.0625) (fneq (sample 1010) 0.0))
	  (snd-display #__line__ ";src-sound: ~A ~A ~A?" (sample 1000) (sample 1024) (sample 1010)))
      (revert-sound)
      (close-sound nind))
    (let ((nind (new-sound "fmv.snd" mus-riff mus-lshort 22050 1 "this is a comment" 22050)))
      (if (not (= (frames nind) 22050)) (snd-display #__line__ "; new-sound initial-length: ~A" (frames nind)))
      (mix "pistol.snd") 
      (map-chan (expsrc 2.0 nind)) 
      (undo) 
      (let ((eds (edits)))
	(if (or (not (= (car eds) 1)) (not (= (cadr eds) 1)))
	    (snd-display #__line__ ";undo edits: ~A?" eds))
	(if (not (= (edit-position) (car eds)))
	    (snd-display #__line__ ";undo edit-position: ~A ~A?" (edit-position) eds)))
      (expsnd '(0 1 2 .4)) 
      (map-chan (comb-chord .95 100 .3)) 
      (map-chan (formants .99 900 .02 1800 .01 2700)) 
      (map-chan (moving-formant .99 '(0 1200 1 2400))) 
      (scale-to .3) 
      (let ((eds (edits)))
	(if (or (not (= (car eds) 6)) (not (= (cadr eds) 0)))
	    (snd-display #__line__ ";edits(6): ~A?" eds))
	(if (not (= (edit-position) (car eds)))
	    (snd-display #__line__ ";edit-position(6): ~A ~A?" (edit-position) eds)))
      (set! (edit-position) 1)
      (if (not (= (edit-position) 1))
	  (snd-display #__line__ ";set edit-position(1) ~A?" (edit-position)))
      (set! (edit-position) 4)
      (if (not (= (edit-position) 4))
	  (snd-display #__line__ ";set edit-position(4): ~A?" (edit-position)))
      (revert-sound nind)
      (mix "pistol.snd") 
      (map-chan (zecho .5 .75 6 10.0) 0 65000) 
      (map-chan (am 440)) 
      (add-mark 1200)
      (add-mark 2300)
      (key (char->integer #\x) 4)
      (key (char->integer #\c) 0) ; trigger mark-define-region
      (reverse-sound nind) 
      (revert-sound nind)
      (let ((mid (mix-sound "pistol.snd" 0)))
	(if (and (mix? mid)
		 (not (equal? (mix-home mid) (list (selected-sound) 0 #f 0))))
	    (snd-display #__line__ ";mix-sound mix-home: ~A" (mix-home mid))))
      (hello-dentist 40.0 .1) 
      (fp 1.0 .3 20) 
      (revert-sound nind)
      (enveloped-mix "oboe.snd" 0 '(0 0 1 1 2 0)) 
      (if all-args (pvoc :pitch 0.5 :time 1.0 :snd nind))
      (revert-sound nind)
      (close-sound nind))
    
    (if (and all-args (defined? 'edot-product))
	(let* ((ind (open-sound "1a.snd"))
	       (len (frames ind 0)))
	  (stretch-sound-via-dft 2.0 ind 0)
	  (let ((new-len (frames ind 0)))
	    (if (> (abs (- (* 2 len) new-len)) 10)
		(snd-display #__line__ ";stretch-sound-via-dft: ~A ~A" len new-len)))
	  (close-sound ind)))
    
    (let ((make-mix-output (lambda (name i)
			     (if (or (= i 0) (= i 1)) 
				 name
				 (continue-sample->file name))))
	  (make-mix-input (lambda (name i)
			    (if (or (= i 0) (= i 2))
				name
				(make-file->frame name)))))
      (define* (mus-mix-1 outf inf outloc frames inloc mixer envs)
	(if envs
	    (mus-mix outf inf outloc frames inloc mixer envs)
	    (if mixer
		(mus-mix outf inf outloc frames inloc mixer)
		(if inloc
		    (mus-mix outf inf outloc frames inloc)
		    (if frames
			(mus-mix outf inf outloc frames)
			(if outloc
			    (mus-mix outf inf outloc)
			    (mus-mix outf inf))))))
	(if (not (string? outf))
	    (mus-close outf)))
      
      (do ((k 0 (+ 1 k)))
	  ((= k 4))
	(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
	(if (file-exists? "fmv1.snd") (delete-file "fmv1.snd"))
	(if (file-exists? "fmv2.snd") (delete-file "fmv2.snd"))
	(if (file-exists? "fmv3.snd") (delete-file "fmv3.snd"))
	(let ((v0 (make-vct 12)))
	  (vct-fill! v0 0.1)
	  (array->file "fmv1.snd" v0 12 22050 1)
	  (vct-fill! v0 0.2)
	  (array->file "fmv2.snd" v0 12 22050 2) ; who knows what this intends...
	  (file->array "fmv2.snd" 0 0 12 v0)     ; check deleted here because multichannel array->file is a mistake
	  (vct-fill! v0 0.3)
	  (array->file "fmv3.snd" v0 12 22050 4)
	  (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! v0 i (* i .01)))
	  (array->file "fmv.snd" v0 12 22050 1)
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv1.snd" k))
	  (file->array "fmv.snd" 0 0 12 v0)
	  (let ((happy #t))
	    (do ((i 0 (+ 1 i))) 
		((or (not happy) (= i 12)))
	      (if (fneq (vct-ref v0 i) (+ 0.1 (* i .01))) 
		  (begin
		    (snd-display #__line__ ";~D mus-mix(1->1): ~A?" k v0)
		    (set! happy #f)))))
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv2.snd" k) 3 9 0 (make-mixer 2 0.3 0.0 0.7 0.0))
	  (file->array "fmv.snd" 0 0 12 v0)
	  (if (or (fneq (vct-ref v0 0) .1) (fneq (vct-ref v0 3) .33) (fneq (vct-ref v0 9) .19)) (snd-display #__line__ ";~D mus-mix(2->1): ~A?" k v0))
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv3.snd" k))
	  (file->array "fmv.snd" 0 0 12 v0)
	  (if (or (fneq (vct-ref v0 0) .4) (fneq (vct-ref v0 3) .33)) (snd-display #__line__ ";~D mus-mix(4->1): ~A?" k v0))
	  (let ((e0 (make-env '(0 0 1 1) :length 11))
		(vf (make-vector 1))
		(vf1 (make-vector 1)))
	    (vector-set! vf 0 vf1)
	    (vector-set! vf1 0 e0)
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv1.snd" k) 0 12 0 (make-mixer 1 1.0) vf)
	    (file->array "fmv.snd" 0 0 12 v0)
	    (if (or (fneq (vct-ref v0 0) .4) (fneq (vct-ref v0 3) .360) (fneq (vct-ref v0 9) .28)) (snd-display #__line__ ";~D mus-mix(env): ~A?" k v0))
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv2.snd" k) 0 12 0 (make-mixer 2 1.0 1.0 1.0 1.0) vf)) 
	  ;; clm2xen should protect us here
	  (let ((vf (make-vector 2))
		(vf1 (make-vector 2))
		(vf2 (make-vector 2)))
	    (vector-set! vf 0 vf1)
	    (vector-set! vf 1 vf2)
	    (vector-set! vf1 0 (make-env '(0 0 1 1) :length 10))
	    (vector-set! vf2 1 (make-env '(0 0 1 1) :length 10))
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv2.snd" k) 0 12 0 (make-mixer 2 1.0 1.0 1.0 1.0) vf)
	    (let ((tag (catch #t
			      (lambda ()
				(vector-set! vf 0 (make-oscil))
				(mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv2.snd" k) 0 12 0 (make-mixer 2 1.0 1.0 1.0 1.0) vf))
			      (lambda args (car args)))))
	      (if (not (eq? tag 'bad-type))
		  (snd-display #__line__ ";~D mix w oscil-vect: ~A" k tag)))
	    (vector-set! vf 0 vf1)
	    (vector-set! vf 1 vf2)
	    (let ((tag (catch #t
			      (lambda ()
				(vector-set! vf1 0 (make-oscil))
				(vector-set! vf2 1 (sqrt -1.0))
				(mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv2.snd" k) 0 12 0 (make-mixer 2 1.0 1.0 1.0 1.0) vf))
			      (lambda args (car args)))))
	      (if (not (eq? tag 'bad-type))
		  (snd-display #__line__ ";~D mix w oscil-env: ~A" k tag))))
	  (delete-file "fmv.snd")
	  (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! v0 i (* i .01)))
	  (array->file "fmv.snd" v0 12 22050 4)
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv1.snd" k))
	  (file->array "fmv.snd" 0 0 3 v0) ; chan 0 start 0 len 3
	  (if (or (fneq (vct-ref v0 0) .1) (fneq (vct-ref v0 2) .18)) (snd-display #__line__ ";~D mus-mix(1->4): ~A?" k v0))
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv2.snd" k)  0 3 0 (make-mixer 2 0.3 0.0 0.7 0.0))
	  (file->array "fmv.snd" 0 0 3 v0)
	  (if (or (fneq (vct-ref v0 0) .3) (fneq (vct-ref v0 2) .38)) (snd-display #__line__ ";~D mus-mix(2->4): ~A?" k v0))
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "fmv3.snd" k) 0 2 0)
	  (file->array "fmv.snd" 0 0 3 v0)
	  (if (or (fneq (vct-ref v0 0) .6) (fneq (vct-ref v0 2) .38)) (snd-display #__line__ ";~D mus-mix(4->4): ~A?" k v0)))
	
	(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
	(let ((v0 (make-vct 12))
	      (len (mus-sound-frames "oboe.snd")))
	  (array->file "fmv.snd" v0 12 22050 1)
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "oboe.snd" k))
	  (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "oboe.snd" k) 0 len 0 (make-mixer 1 0.5))
	  (let* ((egen (make-vector 1))
		 (outv (make-vector 1)))
	    (vector-set! outv 0 egen)
	    (vector-set! egen 0 (make-env :envelope '(0 0 1 1) :length len))
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "oboe.snd" k) 0 len 0 #f outv)
	    (vector-set! egen 0 (make-env :envelope '(0 1 1 0) :length len))
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "oboe.snd" k) 0 len 0 (make-mixer 1 1.0) outv))
	  (let ((ind-oboe (open-sound "oboe.snd"))
		(ind-mix (open-sound "fmv.snd")))
	    (if (not (vequal (samples->vct 1000 10 ind-oboe)
			     (vct-scale! (samples->vct 1000 10 ind-mix) (/ 1.0 2.5))))
		(snd-display #__line__ ";~D mus-mix 1 chan: ~A ~A" k
			     (samples->vct 1000 10 ind-oboe)
			     (samples->vct 1000 10 ind-mix)))
	    (close-sound ind-oboe)
	    (close-sound ind-mix))
	  (delete-file "fmv.snd")
	  (let ((v0 (make-vct 12))
		(len (mus-sound-frames "2.snd")))
	    (array->file "fmv.snd" v0 12 22050 2)
	    (if (not (= (mus-sound-chans "fmv.snd") 2))
		(snd-display #__line__ ";~D array->file chans? ~A" k (mus-sound-chans "fmv.snd")))
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "2.snd" k))
	    (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "2.snd" k) 0 len 0 (make-mixer 2 0.5 0.0 0.0 0.5))
	    (let* ((egen0 (make-vector 2))
		   (egen1 (make-vector 2))
		   (outv (make-vector 2)))
	      (vector-set! outv 0 egen0)
	      (vector-set! outv 1 egen1)
	      (vector-set! egen0 0 (make-env :envelope '(0 0 1 1) :length len))
	      (vector-set! egen1 1 (make-env :envelope '(0 0 1 1) :length len))
	      (mus-mix-1 (make-mix-output "fmv.snd" k) (make-mix-input "2.snd" k) 0 len 0 #f outv))
	    (let ((ind-mix (open-sound "fmv.snd")))
	      (if (not (= (channels ind-mix) 2))
		  (snd-display #__line__ ";~D fmv re-read chans? ~A ~A" k (mus-sound-chans "fmv.snd") (channels ind-mix)))
	      (if (not (vequal (samples->vct 1000 10 ind-mix 0)
			       (vct 0.003 0.010 0.012 0.011 0.008 0.004 0.002 0.002 0.007 0.017)))
		  (snd-display #__line__ ";~D mus-mix 2 chan (2.snd written: ~A): ~A ~A" k
			       (strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "2.snd")))
			       (samples->vct 1000 10 ind-mix 0)
			       (samples->vct 1000 10 ind-mix 1)))
	      (close-sound ind-mix)
	      (delete-file "fmv.snd"))))
	); end do loop
      ); end let
    
    (let* ((gen (make-phase-vocoder #f 512 4 256 1.0 #f #f #f))
	   (val (catch #t (lambda () (phase-vocoder gen)) (lambda args (car args)))))
      (if (fneq val 0.0) (snd-display #__line__ ";simple no-in pv call: ~A" val))
      (set! val (catch #t (lambda () (set! gen (make-phase-vocoder :fft-size 1234))) (lambda args (car args))))
      (if (not (equal? val 'out-of-range)) (snd-display #__line__ ";pv bad fft: ~A" val))
      )
    
    (let* ((ind (open-sound "oboe.snd"))
	   (pi2 (* 2.0 pi))
	   (pv (make-phase-vocoder #f
				   512 4 128 1.0
				   #f ;no change to analysis
				   #f ;no change to edits
				   #f ;no change to synthesis
				   ))
	   (reader (make-sampler 0)))
      (if (not (phase-vocoder? pv)) (snd-display #__line__ ";~A not phase-vocoder?" pv))
      (print-and-check pv 
		       "phase-vocoder"
		       "phase-vocoder outctr: 128, interp: 128, filptr: 0, N: 512, D: 128, in_data: nil")
      (let ((val (let ((pv (make-phase-vocoder))) (set! (mus-location pv) 120) (mus-location pv))))
	(if (not (= val 120)) (snd-display #__line__ ";pv set outctr: ~A" val)))
      
      (select-sound ind)
      (map-chan (lambda (val)
		  (phase-vocoder pv (lambda (dir) 
				      (next-sample reader)))))
      (vct-set! (phase-vocoder-amp-increments pv) 0 .1)
      (if (fneq (vct-ref (phase-vocoder-amp-increments pv) 0) .1)
	  (snd-display #__line__ ";set phase-vocoder-amp-increments: ~A?" (vct-ref (phase-vocoder-amp-increments pv) 0)))
      (vct-set! (phase-vocoder-amps pv) 0 .1)
      (if (fneq (vct-ref (phase-vocoder-amps pv) 0) .1)
	  (snd-display #__line__ ";set phase-vocoder-amps: ~A?" (vct-ref (phase-vocoder-amps pv) 0)))
      (vct-set! (phase-vocoder-phases pv) 0 .1)
      (if (fneq (vct-ref (phase-vocoder-phases pv) 0) .1)
	  (snd-display #__line__ ";set phase-vocoder-phases: ~A?" (vct-ref (phase-vocoder-phases pv) 0)))
      (vct-set! (phase-vocoder-phase-increments pv) 0 .1)
      (if (fneq (vct-ref (phase-vocoder-phase-increments pv) 0) .1)
	  (snd-display #__line__ ";set phase-vocoder-phase-increments: ~A?" (vct-ref (phase-vocoder-phase-increments pv) 0)))
      (vct-set! (phase-vocoder-freqs pv) 0 .1)
      (if (fneq (vct-ref (phase-vocoder-freqs pv) 0) .1)
	  (snd-display #__line__ ";set phase-vocoder-freqs: ~A?" (vct-ref (phase-vocoder-freqs pv) 0)))
      (undo 1)
      (free-sampler reader)
      (let ((lastphases (make-vct 512)))
	(set! pv (make-phase-vocoder #f
				     512 4 128 1.0
				     #f ;no change to analysis
				     (lambda (v)
					; new editing func changes pitch
				       (run
					(let* ((N (mus-length v)) ;mus-increment => interp, mus-data => in-data
					       (D (mus-hop v))
					       (freqs (phase-vocoder-freqs v)))
					  (do ((k 0 (+ 1 k))
					       (pscl (/ 1.0 D))
					       (kscl (/ pi2 N)))
					      ((= k (floor (/ N 2))))
					    (let ((phasediff (- (vct-ref freqs k) (vct-ref lastphases k))))
					      (vct-set! lastphases k (vct-ref freqs k))
					      (if (> phasediff pi) (do () ((<= phasediff pi)) (set! phasediff (- phasediff pi2))))
					      (if (< phasediff (- pi)) (do () ((>= phasediff (- pi))) (set! phasediff (+ phasediff pi2))))
					      (vct-set! freqs k 
							(* 0.5
							   (+ (* pscl phasediff)
							      (* k kscl))))))
					  #f)))
				     #f ; no change to synthesis
				     ))
	(set! reader (make-sampler 0))
	(map-chan (lambda (val)
		    (phase-vocoder pv (lambda (dir) 
					(next-sample reader))))))
      (undo 1)
      (free-sampler reader)
      (set! pv (make-phase-vocoder #f
				   512 4 (* 128 2) 1.0
				   #f ;no change to analysis
				   #f ;no change to edits
				   #f ;no change to synthesis
				   ))
      (set! reader (make-sampler 0))
      (let* ((len (* 2 (frames ind)))
	     (data (make-vct len)))
	(vct-map! data
		  (lambda ()
		    (phase-vocoder pv (lambda (dir) (next-sample reader)))))
	(set! (samples 0 len) data))
      (undo 1)
      (free-sampler reader)
      
      (let ((incalls 0)
	    (outcalls 0))
	(set! pv (make-phase-vocoder #f
				     512 4 (* 128 2) 1.0
				     (lambda (v infunc)
				       (set! incalls (+ incalls 1))
				       #t)
				     #f ;no change to edits
				     (lambda (v)
				       (set! outcalls (+ outcalls 1))
				       0.0)
				     ))
	(set! reader (make-sampler 0))
	(let* ((len (* 2 (frames ind)))
	       (data (make-vct len)))
	  (vct-map! data
		    (lambda ()
		      (phase-vocoder pv (lambda (dir) (next-sample reader)))))
	  (set! (samples 0 len) data))
	(undo 1)
	(free-sampler reader)
	(if (or (= incalls 0)
		(= outcalls 0))
	    (snd-display #__line__ ";phase-vocoder incalls: ~A, outcalls: ~A" incalls outcalls))
	(set! (mus-location pv) (mus-location pv))
	(let ((tag (catch #t (lambda () (phase-vocoder pv (lambda (a b) a))) (lambda args (car args)))))
	  (if (not (eq? tag 'bad-arity)) 
	      (snd-display #__line__ ";phase-vocoder bad func: ~A" tag))))
      (let ((tag (catch #t 
			(lambda () (make-phase-vocoder #f 512 4 256 1.0 (lambda (a b c) #f) #f #f)) 
			(lambda args args))))
	(if (not (eq? (car tag) 'bad-arity)) (snd-display #__line__ ";make-phase-vocoder bad analyze func: ~A" tag)))
      (let ((tag (catch #t
			(lambda () (make-phase-vocoder #f 512 4 256 1.0 (lambda (a b) 0.0) (lambda (a b c) #f) #f)) 
			(lambda args args))))
	(if (not (eq? (car tag) 'bad-arity)) (snd-display #__line__ ";make-phase-vocoder bad edit func: ~A" tag)))
      (let ((tag (catch #t 
			(lambda () (make-phase-vocoder #f 512 4 256 1.0 (lambda (a b) 0.0) (lambda (a) #f) (lambda (a b) 0)))
			(lambda args args))))
	(if (not (eq? (car tag) 'bad-arity)) (snd-display #__line__ ";make-phase-vocoder bad synthesize func: ~A" tag)))
      (let ((geno (make-phase-vocoder (lambda (dir) 0.0))))
	(let ((genx (make-phase-vocoder :input (lambda (dir) 0.0))))
	  (if (equal? geno genx) (snd-display #__line__ ";phase-vocoder equal? ~A ~A" geno genx))
	  (if (fneq (mus-frequency genx) 1.0) (snd-display #__line__ ";mus-frequency phase-vocoder: ~A" (mus-frequency genx)))
	  (set! (mus-frequency genx) 2.0)
	  (if (fneq (mus-frequency genx) 2.0) (snd-display #__line__ ";set mus-frequency phase-vocoder: ~A" (mus-frequency genx)))
	  (if (fneq (mus-increment genx) 128) (snd-display #__line__ ";mus-increment phase-vocoder: ~A" (mus-increment genx)))
	  (set! (mus-increment genx) 256)
	  (if (fneq (mus-increment genx) 256) (snd-display #__line__ ";set mus-increment phase-vocoder: ~A" (mus-increment genx)))
	  (if (not (= (mus-hop genx) 128)) (snd-display #__line__ ";phase vocoder hop: ~A" (mus-hop genx)))
	  (set! (mus-hop genx) 64)
	  (if (not (= (mus-hop genx) 64)) (snd-display #__line__ ";set phase vocoder hop: ~A" (mus-hop genx)))
	  (if (not (= (mus-length genx) 512)) (snd-display #__line__ ";phase vocoder length: ~A" (mus-length genx)))
	  (let ((genxx genx))
	    (if (not (equal? genx genxx)) (snd-display #__line__ ";phase-vocoder equal: ~A ~A" genxx genx)))))
      (close-sound ind))
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((gen (make-moog-filter 500.0 .1)))
	(if (fneq 500.0 (moog-frequency gen)) (snd-display #__line__ ";moog freq: ~A" (moog-frequency gen)))
	(if (fneq .1 (moog-Q gen)) (snd-display #__line__ ";moog Q: ~A" (moog-Q gen)))
	(if (not (vct? (moog-s gen))) (snd-display #__line__ ";moog state: ~A" (moog-s gen)))
	(if (fneq 0.0 (moog-y gen)) (snd-display #__line__ ";moog A? ~A" (moog-y gen)))
	(if (fneq -0.861 (moog-fc gen)) (snd-display #__line__ ";moog freqtable: ~A" (moog-fc gen)))
	(let ((vals (make-vct 20)))
	  (vct-set! vals 0 (moog-filter gen 1.0))
	  (do ((i 1 (+ 1 i)))
	      ((= i 20))
	    (vct-set! vals i (moog-filter gen 0.0)))
	  (if (not (vequal vals (vct 0.0    0.0    0.0025 0.0062 0.0120 0.0198 0.0292 0.0398 0.0510 0.0625
				     0.0739 0.0847 0.0946 0.1036 0.1113 0.1177 0.1228 0.1266 0.1290 0.1301)))
	      (snd-display #__line__ ";moog output: ~A" vals))))
      (close-sound ind))
    
    (let ((gen (make-ssb-am 440.0))
	  (v0 (make-vct 10))
	  (gen1 (make-ssb-am 440.0))
	  (v1 (make-vct 10)))
      (print-and-check gen 
		       "ssb-am"
		       "ssb-am shift: up, sin/cos: 439.999975 Hz (0.000000 radians), order: 41"
		       "ssb-am shift: up, sin/cos: 440.000000 Hz (0.000000 radians), order: 41"
		       "ssb-am shift: up, sin/cos: 439.999969 Hz (0.000000 radians), order: 41")
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! v0 i (ssb-am gen 0.0)))
      (vct-map! v1 (lambda () (if (ssb-am? gen1) (ssb-am gen1 0.0) -1.0)))
      (if (not (vequal v0 v1)) (snd-display #__line__ ";map ssb-am: ~A ~A" v0 v1))
      (if (not (ssb-am? gen)) (snd-display #__line__ ";~A not ssb-am?" gen))
      (if (fneq (mus-phase gen) 1.253787) (snd-display #__line__ ";ssb-am phase: ~F?" (mus-phase gen)))
      (if (fneq (mus-frequency gen) 440.0) (snd-display #__line__ ";ssb-am frequency: ~F?" (mus-frequency gen)))
      (if (not (= (mus-order gen) 41)) (snd-display #__line__ ";ssb-am order: ~F?" (mus-order gen)))
      (if (not (= (mus-length gen) 41)) (snd-display #__line__ ";ssb-am length: ~D?" (mus-length gen)))
      (if (not (= (mus-interp-type gen) mus-interp-none)) (snd-display #__line__ ";ssb-am interp type: ~D?" (mus-interp-type gen)))
      (if (fneq (mus-xcoeff gen 0) -0.00124) (snd-display #__line__ ";ssb-am xcoeff 0: ~A" (mus-xcoeff gen 0)))
      (if (fneq (mus-xcoeff gen 1) 0.0) (snd-display #__line__ ";ssb-am xcoeff 1: ~A" (mus-xcoeff gen 1)))
					;	(if (not (vct? (mus-data gen))) (snd-display #__line__ ";mus-data ssb-am: ~A" (mus-data gen)))
					;	(if (not (vct? (mus-xcoeffs gen))) (snd-display #__line__ ";mus-xcoeffs ssb-am: ~A" (mus-xcoeffs gen)))
      ;; these apparently aren't handled in clm2xen
      )
    
    (test-gen-equal (make-ssb-am 440.0) (make-ssb-am 440.0) (make-ssb-am 500.0))
    
    (let ((o1 (make-ssb-am 400.0))
	  (o2 (make-ssb-am-1 400.0))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 100)))
	(let* ((inval (sin (* .1 i)))
	       (o1o (ssb-am o1 inval))
	       (o2o (ssb-am-1 o2 inval)))
	  (if (fneq o1o o2o)
	      (begin
		(snd-display #__line__ ";ssb-am (up): ~A ~A at ~A" o1o o2o i)
		(set! happy #f))))))
    
    (let ((o1 (make-ssb-am 400.0))
	  (o2 (make-ssb-am-1 400.0))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 100)))
	(let* ((inval (sin (* .1 i)))
	       (fmval (sin (* .2 i)))
	       (o1o (ssb-am o1 inval fmval))
	       (o2o (ssb-am-1 o2 inval fmval)))
	  (if (fneq o1o o2o)
	      (begin
		(snd-display #__line__ ";ssb-am + fm (up): ~A ~A at ~A" o1o o2o i)
		(set! happy #f))))))
    
    (let ((o1 (make-ssb-am -100.0))
	  (o2 (make-ssb-am-1 -100.0))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 100)))
	(let* ((inval (random 1.0))
	       (o1o (ssb-am o1 inval))
	       (o2o (ssb-am-1 o2 inval)))
	  (if (fneq o1o o2o)
	      (begin
		(snd-display #__line__ ";ssb-am (down): ~A ~A at ~A" o1o o2o i)
		(set! happy #f))))))
    
    (let ((o1 (make-ssb-am 1000.0 100))
	  (o2 (make-ssb-am-1 1000.0 100))
	  (happy #t))
      (do ((i 0 (+ 1 i)))
	  ((or (not happy) (= i 100)))
	(let* ((inval (random 1.0))
	       (o1o (ssb-am o1 inval))
	       (o2o (ssb-am-1 o2 inval)))
	  (if (fneq o1o o2o)
	      (begin
		(snd-display #__line__ ";ssb-am (down): ~A ~A at ~A" o1o o2o i)
		(set! happy #f))))))
    
    (let ((index (open-sound "pistol.snd"))
	  (data (samples->vct 0 100)))
      (convolve-with "oboe.snd" #f)
      (let ((scl (maxamp)))
	(convolve-with "oboe.snd" scl index 0 0)
	(if (ffneq (maxamp) scl)
	    (snd-display #__line__ ";convolve-with amps: ~A ~A" (maxamp) scl)))
      (revert-sound index)
      (agc)
      (if (fneq (maxamp index 0) 1.29) (snd-display #__line__ ";agc: ~A" (maxamp index 0)))
      (close-sound index)
      (let ((reader (make-sampler 0 "pistol.snd")))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (if (fneq (vct-ref data i) (next-sample reader))
	      (snd-display #__line__ ";external reader trouble")))
	(free-sampler reader)))
    
    (let ((make-procs (list
		       make-all-pass make-asymmetric-fm make-moving-average
		       make-comb (lambda () (make-convolve :filter (vct 0 1 2))) make-delay (lambda () (make-env '(0 1 1 0)))
		       (lambda () (make-filter :xcoeffs (vct 0 1 2))) (lambda () (make-fir-filter :xcoeffs (vct 0 1 2))) 
		       (lambda () (make-filtered-comb :filter (make-one-zero .5 .5)))
		       make-formant (lambda () (make-frame 3)) make-granulate
		       (lambda () (make-iir-filter :xcoeffs (vct 0 1 2))) make-locsig (lambda () (make-mixer 3 3)) 
		       make-notch make-one-pole make-one-zero make-oscil make-ppolar
		       make-pulse-train make-rand make-rand-interp make-sawtooth-wave
		       make-square-wave make-src make-table-lookup make-triangle-wave
		       make-two-pole make-two-zero make-wave-train make-polyshape make-zpolar make-phase-vocoder make-ssb-am
		       (lambda () (make-filter :ycoeffs (vct 0 1 2)))
		       (lambda () (make-filter :xcoeffs (vct 1 2 3) :ycoeffs (vct 0 1 2)))))
	  (run-procs (list all-pass asymmetric-fm moving-average
			   comb convolve delay env 
			   filter fir-filter filtered-comb formant (lambda (gen ind) (frame-ref gen ind)) granulate
			   iir-filter (lambda (gen a) (locsig gen 0 a)) (lambda (gen a) (mixer-ref gen a 0)) notch one-pole one-zero oscil two-pole
			   pulse-train rand rand-interp sawtooth-wave
			   square-wave (lambda (gen a) (src gen 0.0 a)) table-lookup triangle-wave
			   two-pole two-zero wave-train polyshape two-zero phase-vocoder ssb-am
			   filter filter))
	  (ques-procs (list all-pass? asymmetric-fm? moving-average?
			    comb? convolve? delay? env? 
			    filter? fir-filter? filtered-comb? formant? frame? granulate?
			    iir-filter? locsig? mixer? notch? one-pole? one-zero? oscil? two-pole?
			    pulse-train? rand? rand-interp? sawtooth-wave?
			    square-wave? src? table-lookup? triangle-wave?
			    two-pole? two-zero? wave-train? polyshape? two-zero? phase-vocoder? ssb-am?
			    filter? filter?))
	  (func-names (list 'all-pass 'asymmetric-fm 'moving-average
			    'comb 'convolve 'delay 'env 
			    'filter-x 'fir-filter 'filtered-comb 'formant 'frame 'granulate
			    'iir-filter 'locsig 'mixer 'notch 'one-pole 'one-zero 'oscil 'two-pole
			    'pulse-train 'rand 'rand-interp 'sawtooth-wave
			    'square-wave 'src 'table-lookup 'triangle-wave
			    'two-pole 'two-zero 'wave-train 'polyshape 'two-zero 'phase-vocoder 'ssb-am
			    'filter-y 'filter-xy))
	  (gen-args (list 0.0 0.0 1.0
			  0.0 (lambda (dir) 0.0) 0.0 #f
			  0.0 0.0 0.0 0.0 0 (lambda (dir) 0.0)
			  0.0 0.0 0 0.0 0.0 0.0 0.0 0.0
			  0.0 0.0 0.0 0.0
			  0.0 (lambda (dir) 0.0) 0.0 0.0
			  0.0 0.0 0.0 0.0 0.0 (lambda (dir) 0.0) 0.0
			  0.0 0.0))
	  (generic-procs (list mus-a0 mus-a1 mus-a2 mus-b1 mus-b2 mus-channel mus-channels mus-data
			       mus-feedback mus-feedforward mus-frequency mus-hop mus-increment mus-length
			       mus-location mus-order mus-phase mus-ramp mus-scaler mus-xcoeffs mus-ycoeffs))
	  (generic-names (list 'mus-a0 'mus-a1 'mus-a2 'mus-b1 'mus-b2 'mus-channel 'mus-channels 'mus-data
			       'mus-feedback 'mus-feedforward 'mus-frequency 'mus-hop 'mus-increment 'mus-length
			       'mus-location 'mus-order 'mus-phase 'mus-ramp 'mus-scaler 'mus-xcoeffs 'mus-ycoeffs)))
      (for-each
       (lambda (make runp ques arg name)
	 (let ((gen (make)))
	   (if (not (ques gen)) (snd-display #__line__ ";~A: ~A -> ~A?" name make gen))
	   (let ((tag (catch #t (lambda () (if arg (runp gen arg) (runp gen))) (lambda args args))))
	     (if (and (not (number? tag)) 
		      (not (frame? tag)))
		 (snd-display #__line__ ";~A: ~A ~A ~A: ~A" name runp gen arg tag)))
	   (for-each
	    (lambda (func genname)
	      (let ((tag (catch #t (lambda () (func #f)) (lambda args (car args)))))
		(if (not (eq? tag 'wrong-type-arg))
		    (snd-display #__line__ ";generic func with #f: (~A #f) -> ~A" genname tag)))
	      (let ((g1 (make-oscil))
		    (g2 (make-one-pole .1 .9)))
		(let ((tag (catch #t (lambda () (func g1)) (lambda args (car args)))))
		  (if (and (symbol? tag)
			   (not (eq? tag 'wrong-type-arg))
			   (not (eq? tag 'mus-error)))
		      (snd-display #__line__ ";generic ~A of oscil: ~A" genname tag)))
		(let ((tag (catch #t (lambda () (func g2)) (lambda args (car args)))))
		  (if (and (symbol? tag)
			   (not (eq? tag 'wrong-type-arg))
			   (not (eq? tag 'mus-error)))
		      (snd-display #__line__ ";generic ~A of delay: ~A" genname tag))))
	      (let ((tag (catch #t (lambda () (func gen)) (lambda args (car args)))))
		(if (and (not (symbol? tag))
			 (procedure-with-setter? func)
			 (or (not (eq? genname 'mus-data))
			     (vct? tag)))
		    (let ((tag1 (catch #t (lambda () (set! (func gen) tag)) (lambda args (car args)))))
		      (if (and (symbol? tag1)
			       (not (eq? tag1 'mus-error))
			       (not (eq? tag1 'out-of-range)))
			  (snd-display #__line__ ";~A set ~A ~A ~A -> ~A" name genname gen tag tag1))))))
	    generic-procs generic-names)
	   (mus-reset gen)))
       make-procs run-procs ques-procs gen-args func-names)
      
      (let ((make-procs (list
			 make-all-pass make-asymmetric-fm make-moving-average
			 make-comb 
			 (lambda () (make-filtered-comb :filter (make-one-zero .5 .5)))
			 (lambda () (make-convolve :filter (vct 0 1 2) :input (lambda (dir) 1.0))) 
			 make-delay 
			 (lambda () (make-env :length 11 :envelope '(0 1 1 0)))
			 (lambda () (make-filter :xcoeffs (vct 0 1 2))) 
			 (lambda () (make-fir-filter :xcoeffs (vct 0 1 2))) 
			 (lambda () (make-formant :radius .1 :frequency 440.0)) 
			 (lambda () (make-granulate (lambda (dir) 1.0)))
			 (lambda () (make-iir-filter :xcoeffs (vct 0 1 2))) 
			 make-locsig 
			 make-notch 
			 (lambda () (make-one-pole .3 .7))
			 (lambda () (make-one-zero .5 .5))
			 make-oscil 
			 make-pulse-train make-sawtooth-wave
			 make-square-wave 
			 (lambda () (make-table-lookup :wave (make-vct 128 .1))) 
			 make-triangle-wave
			 (lambda () (make-two-pole .1 .3 .6)) 
			 (lambda () (make-two-zero .1 .3 .5)) 
			 (lambda () (make-polyshape 440.0 :partials '(1 1)))
			 (lambda () (make-phase-vocoder (lambda (dir) 1.0)))
			 make-ssb-am
			 (lambda () (make-filter :ycoeffs (vct 0 1 2)))
			 (lambda () (make-filter :xcoeffs (vct 1 2 3) :ycoeffs (vct 0 1 2)))))
	    (run-procs (list all-pass asymmetric-fm moving-average
			     comb filtered-comb convolve delay 
			     (lambda (gen ignored) (env gen))
			     filter fir-filter formant 
			     granulate
			     iir-filter 
			     (lambda (gen a) (locsig gen 0 1.0))
			     notch one-pole one-zero oscil 
			     pulse-train sawtooth-wave
			     square-wave table-lookup triangle-wave
			     two-pole two-zero polyshape phase-vocoder ssb-am
			     filter filter))
	    (func-names (list 'all-pass 'asymmetric-fm 'moving-average
			      'comb 'filtered-comb 'convolve 'delay 'env 
			      'filter-x 'fir-filter 'formant 'granulate
			      'iir-filter 'locsig 'notch 'one-pole 'one-zero 'oscil 
			      'pulse-train 'sawtooth-wave
			      'square-wave 'table-lookup 'triangle-wave
			      'two-pole 'two-zero 'polyshape 'phase-vocoder 'ssb-am
			      'filter-y 'filter-xy)))
	(for-each
	 (lambda (make runp name)
	   (let ((gen (make))
		 (data (make-vct 10)))
	     (vct-set! data 0 (runp gen 1.0))
	     (do ((i 1 (+ 1 i)))
		 ((= i 10))
	       (vct-set! data i (runp gen 0.0)))
	     (do ((k 0 (+ 1 k)))
		 ((= k 2))
	       (mus-reset gen)
	       (if (and (not (eq? name 'env))
			(not (eq? name 'locsig)))
		   (let ((not-zero #f))
		     (let ((first-val (if (= k 0) (runp gen 1.0) (mus-apply gen 1.0 0.0))))
		       (if (not (= (vct-ref data 0) 0.0)) (set! not-zero #t))
		       (if (fneq (vct-ref data 0) first-val)
			   (snd-display #__line__ ";[~A] ~A: ~A ~A ~A" (if (= k 0) 'run 'apply) name 0 (vct-ref data 0) first-val)))
		     (do ((i 1 (+ 1 i)))
			 ((= i 10))
		       (let ((old-val (vct-ref data i))
			     (new-val (if (= k 0) (runp gen 0.0) (mus-apply gen 0.0 0.0))))
			 (if (not (= old-val 0.0)) (set! not-zero #t))
			 (if (fneq old-val new-val)
			     (snd-display #__line__ ";[~A] ~A: ~A ~A ~A" (if (= k 0) 'run 'apply) name i old-val new-val))))
		     (if (and (not (eq? name 'polyshape))
			      (not (eq? name 'ssb-am))
			      (not not-zero))
			 (snd-display #__line__ ";~A not much of a reset test!" name)))))))
	 make-procs run-procs func-names))
      
      (if (and all-args (= clmtest 0))
	  (begin
	    (for-each
	     (lambda (make runp)
	       (let ((gen (make)))
		 ;; run args
		 (for-each 
		  (lambda (arg1)
		    (catch #t (lambda () (runp gen arg1)) (lambda args (car args)))
		    (for-each
		     (lambda (arg2)
		       (catch #t (lambda () (runp gen arg1 arg2)) (lambda args (car args))))
		     (list 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color-with-catch .95 .95 .95)  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
			   (lambda () #t) (current-environment) (make-sound-data 2 3) :order 0 1 -1 (make-hook 2) #f #t #\c 0.0 1.0 -1.0 
			   '() '3 4 2 8 16 32 64 (make-vector 0) '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0)
			   )))
		  (list 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color-with-catch .95 .95 .95)  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
			(lambda () #t) (current-environment) (make-sound-data 2 3) :order 0 1 -1 (make-hook 2) #f #t #\c 0.0 1.0 -1.0 
			'() '3 4 2 8 16 32 64 (make-vector 0) '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0)
			))
		 ;; generic args
		 (for-each
		  (lambda (func name)
		    (catch #t
			   (lambda ()
			     (let ((default-value (func gen)))
			       (for-each
				(lambda (arg1)
				  (catch #t
					 (lambda ()
					   (let ((old-val (func gen)))
					     (set! (func gen) arg1)))
					 (lambda args #f)))
				(list 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) '#(0 1) 3/4 'mus-error (sqrt -1.0)
				      (lambda () #t) (make-sound-data 2 3) :order 0 1 -1 #f #t #\c 0.0 1.0 -1.0 
				      '() '3 4 64 -64 (make-vector 0) '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0)
				      (lambda (a) a)))
			       (if (not (equal? (func gen) default-value))
				   (catch #t
					  (lambda ()
					    (set! (func gen) default-value))
					  (lambda args #f)))))
			   (lambda args #f)))
		  generic-procs generic-names)
		 (mus-reset gen)))
	     make-procs run-procs)
	    
	    (let ((new-wave (make-vct 1)))
	      (for-each 
	       (lambda (g g1)
		 (let ((gen (g :wave new-wave)))
		   (g1 gen 1.0)))
	       (list make-table-lookup)
	       (list table-lookup)))
	    
	    (let ((old-srate (mus-srate))
		  (old-clm-srate *clm-srate*))
	      (for-each
	       (lambda (n)
		 (set! (mus-srate) n)
		 (set! *clm-srate* n)
		 (for-each 
		  (lambda (g name)
		    (let ((tag (catch #t (lambda () (g :frequency 440.0)) (lambda args (car args)))))
		      (if (not (eq? tag 'out-of-range))
			  (snd-display #__line__ ";srate ~A: ~A -> ~A" n name tag))))
		  (list make-oscil make-asymmetric-fm 
			make-triangle-wave make-square-wave make-pulse-train make-sawtooth-wave
			make-rand make-rand-interp)
		  (list 'oscil 'asymmetric-fm 
			'triangle-wave 'square-wave 'pusle-train 'sawtooth-wave
			'rand 'rand-interp)))
	       (list 100 1))
	      
	      (set! (mus-srate) old-srate)
	      (set! *clm-srate* old-clm-srate))
	    
	    (let ((random-args (list 
				(expt 2.0 21.5) (expt 2.0 -18.0)
				1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color-with-catch .1 .2 .3)  '#(0 1) 3/4 (sqrt -1.0) (make-delay 32)
				(lambda () 0.0) (lambda (dir) 1.0) (lambda (a b c) 1.0) 0 1 -1 #f #t #\c 0.0 1.0 -1.0 '() 32 '(1 . 2)
				))
		  (gen-make-procs (list make-all-pass make-asymmetric-fm make-moving-average make-table-lookup make-triangle-wave
					make-comb ;make-convolve
					make-delay make-env make-fft-window
					make-filter make-filtered-comb make-fir-filter make-formant make-frame ;make-granulate
					make-iir-filter make-locsig make-mixer make-notch make-one-pole make-one-zero make-oscil make-ppolar
					make-pulse-train make-rand make-rand-interp make-sawtooth-wave make-polyshape make-polywave
					make-square-wave ;make-src
					make-two-pole make-two-zero make-wave-train make-zpolar ;make-phase-vocoder 
					make-ssb-am)))
	      
	      (define (random-gen args)
		(for-each
		 (lambda (n)
		   (let ((gen (catch #t
				     (lambda () (apply n args))
				     (lambda args (car args)))))
		     (if (mus-generator? gen)
			 (begin
			   (for-each
			    (lambda (arg)
			      (catch #t
				     (lambda () (gen arg))
				     (lambda args (car args))))
			    random-args)))))
		 gen-make-procs))
	      
	      (random-gen '())
	      (for-each
	       (lambda (arg1)
		 (random-gen (list arg1))
		 (for-each 
		  (lambda (arg2)
		    (random-gen (list arg1 arg2))
		    (for-each 
		     (lambda (arg3)
		       (random-gen (list arg1 arg2 arg3))
		       (for-each 
			(lambda (arg4)
			  (random-gen (list arg1 arg2 arg3 arg4)))
			random-args))
		     random-args))
		  random-args))
	       random-args)))))
    
    
    (let ((gen (make-moving-max 4)))
      (let ((descr (mus-describe gen)))
	(if (and (not (string=? descr "moving-max n: 4, gen: #<delay line[4, step]: [0.000 0.000 0.000 0.000]>"))
		 (not (string=? descr "moving-max n: 4, gen: delay line[4, step]: [0.000 0.000 0.000 0.000]")))
	    (snd-display #__line__ ";moving-max mus-describe: ~A" descr))
	(if (not (string=? (mus-name gen) "moving-max")) (snd-display #__line__ ";moving-max mus-name: ~A" (mus-name gen))))
      (let ((ov (make-vct 10))
	    (iv (vct .1 .05 -.2 .15 -1.5 0.1 0.01 0.001 0.0 0.0))
	    (tv (vct .1 .1 .2 .2 1.5 1.5 1.5 1.5 0.1 0.01)))
	(do ((i 0 (+ 1 i)))
	    ((= i 10))
	  (vct-set! ov i (moving-max gen (vct-ref iv i))))
	(if (not (vequal tv ov))
	    (snd-display #__line__ ";moving-max: ~A ~A" ov tv))))
    
    (let ((g1 (make-moving-max 10)))
      (do ((i 0 (+ 1 i)))
	  ((= i 1000))
	(let ((val (moving-max g1 (random 1.0))))
	  (let ((pk (vct-peak (mus-data g1))))
	    (if (not (= pk val)) 
		(snd-display #__line__ ";moving-max ~A ~A" pk val))))))
    
    (let ((odata (make-vct 15 0.0))
	  (data (vct 1.0 0.0 -1.1 1.1001 0.1 -1.1 1.0 1.0 0.5 -0.01 0.02 0.0 0.0 0.0 0.0))
	  (g (make-moving-max 3)))
      (do ((i 0 (+ 1 i))) ((= i 15)) (vct-set! odata i (moving-max g (vct-ref data i))))
      (if (not (vequal odata (vct 1.000 1.000 1.100 1.100 1.100 1.100 1.100 1.100 1.000 1.000 0.500 0.020 0.020 0.000 0.000)))
	  (snd-display #__line__ ";moving max odata: ~A" odata))
      (if (= (vct-ref odata 4) (vct-ref odata 7))
	  (snd-display #__line__ ";moving-max .0001 offset?"))
      
      (set! odata (make-vct 15 0.0))
      (set! data (vct 0.1 -0.2 0.3 0.4 -0.5 0.6 0.7 0.8 -0.9 1.0 0.0 0.0))
      (set! g (make-moving-sum 3))
      (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! odata i (moving-sum g (vct-ref data i))))
      (if (not (vequal odata (vct 0.100 0.300 0.600 0.900 1.200 1.500 1.800 2.100 2.400 2.700 1.900 1.000 0.000 0.000 0.000)))
	  (snd-display #__line__ ";moving-sum odata: ~A" odata))
      
      (set! odata (make-vct 15 0.0))
      (set! g (make-moving-rms 4))
      (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! odata i (moving-rms g (vct-ref data i))))
      (if (not (vequal odata (vct 0.050 0.112 0.187 0.274 0.367 0.464 0.561 0.660 0.758 0.857 0.783 0.673 0.000 0.000 0.000)))
	  (snd-display #__line__ ";moving-rms odata: ~A" odata))
      
      (set! odata (make-vct 15 0.0))
      (set! g (make-moving-length 4))
      (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! odata i (moving-length g (vct-ref data i))))
      (if (not (vequal odata (vct 0.100 0.224 0.374 0.548 0.735 0.927 1.122 1.319 1.517 1.715 1.565 1.345 0.000 0.000 0.000)))
	  (snd-display #__line__ ";moving-length odata: ~A" odata))
      
      (let ((ind (new-sound "test.snd" :size 20)))
	(set! (sample 3) 1.0)
	(let ((gen1 (make-weighted-moving-average 4))
	      (gen2 (make-fir-filter 4 (vct 0.4 0.3 0.2 0.1))))
	  (map-channel (lambda (y) (weighted-moving-average gen1 y)))
	  (let ((data1 (channel->vct)))
	    (undo)
	    (map-channel (lambda (y) (fir-filter gen2 y)))
	    (let ((data2 (channel->vct)))
	      (if (not (vequal data1 data2))
		  (snd-display #__line__ ";weighted-moving-average and fir:~%;  ~A~%:   ~A" data1 data2)))
	    (undo)))
	(close-sound ind))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! data i (- 0.5 (random 1.0))))
      (set! g (make-moving-length 4))
      (let ((descr (mus-describe g)))
	(if (and (not (string=? descr "moving-length n: 4, gen: #<moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]>"))
		 (not (string=? descr "moving-length n: 4, gen: moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]")))
	    (snd-display #__line__ ";moving-length mus-describe: ~A" descr))
	(if (not (string=? (mus-name g) "moving-length")) (snd-display #__line__ ";moving-length mus-name: ~A" (mus-name g))))
      (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! odata i (moving-length g (vct-ref data i))))
      (do ((i -3 (+ 1 i))
	   (k 0 (+ 1 k)))
	  ((= i 8))
	(let ((sum 0.0))
	  (do ((j 0 (+ 1 j)))
	      ((= j 4))
	    (if (>= (+ i j) 0)
		(set! sum (+ sum (* (vct-ref data (+ i j)) (vct-ref data (+ i j)))))))
	  (if (fneq (vct-ref odata k) (sqrt sum)) (snd-display #__line__ ";moving length ran: ~A ~A" (vct-ref odata k) (sqrt sum)))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! data i (- 0.5 (random 1.0))))
      (set! g (make-moving-sum 4))
      (let ((descr (mus-describe g)))
	(if (and (not (string=? descr "moving-sum n: 4, gen: #<moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]>"))
		 (not (string=? descr "moving-sum n: 4, gen: moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]")))
	    (snd-display #__line__ ";moving-sum mus-describe: ~A" descr))
	(if (not (string=? (mus-name g) "moving-sum")) (snd-display #__line__ ";moving-sum mus-name: ~A" (mus-name g))))
      (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! odata i (moving-sum g (vct-ref data i))))
      (do ((i -3 (+ 1 i))
	   (k 0 (+ 1 k)))
	  ((= i 8))
	(let ((sum 0.0))
	  (do ((j 0 (+ 1 j)))
	      ((= j 4))
	    (if (>= (+ i j) 0)
		(set! sum (+ sum (abs (vct-ref data (+ i j)))))))
	  (if (fneq (vct-ref odata k) sum) (snd-display #__line__ ";moving sum ran: ~A ~A" (vct-ref odata k) sum))))
      
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(vct-set! data i (- 0.5 (random 1.0))))
      (set! g (make-moving-rms 4))
      (let ((descr (mus-describe g)))
	(if (and (not (string=? descr "moving-rms n: 4, gen: #<moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]>"))
		 (not (string=? descr "moving-rms n: 4, gen: moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]")))
	    (snd-display #__line__ ";moving-rms mus-describe: ~A" descr))
	(if (not (string=? (mus-name g) "moving-rms")) (snd-display #__line__ ";moving-rms mus-name: ~A" (mus-name g))))
      (do ((i 0 (+ 1 i))) ((= i 12)) (vct-set! odata i (moving-rms g (vct-ref data i))))
      (do ((i -3 (+ 1 i))
	   (k 0 (+ 1 k)))
	  ((= i 8))
	(let ((sum 0.0))
	  (do ((j 0 (+ 1 j)))
	      ((= j 4))
	    (if (>= (+ i j) 0)
		(set! sum (+ sum (* (vct-ref data (+ i j)) (vct-ref data (+ i j)))))))
	  (if (fneq (vct-ref odata k) (sqrt (/ sum 4))) (snd-display #__line__ ";moving rms ran: ~A ~A" (vct-ref odata k) (sqrt (/ sum 4)))))))
    
    (let ((ind (open-sound "oboe.snd")))
      (harmonicizer 550.0 (list 1 .5 2 .3 3 .2) 10)
      (close-sound ind))
    
    (let ((arglist '()))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(set! arglist (cons 440.0 (cons :frequency arglist))))
      (set! arglist (reverse arglist))
      (for-each
       (lambda (make name)
	 (let ((tag (catch #t
			   (lambda () (apply make arglist))
			   (lambda args (car args)))))
	   (if (not (eq? tag 'mus-error))
	       (snd-display #__line__ ";long arglist to ~A: ~A" name tag))))
       (list make-wave-train make-polyshape make-delay make-moving-average make-comb make-filtered-comb make-notch
	     make-rand make-rand-interp make-table-lookup make-env
	     make-readin make-locsig make-granulate make-convolve make-phase-vocoder)
       (list 'make-wave-train 'make-polyshape 'make-delay 'make-moving-average 'make-comb 'make-filtered-comb 'make-notch
	     'make-rand 'make-rand-interp 'make-table-lookup 'make-env
	     'make-readin 'make-locsig 'make-granulate 'make-convolve 'make-phase-vocoder)))
    
    (let ((v1 (make-vct 10 .1)))
      
      (let ((g1 (make-table-lookup :wave v1)))
	(if (not (eq? v1 (mus-data g1))) (snd-display #__line__ ";table-lookup data not eq?: ~A ~A" v1 (mus-data g1)))
	(if (not (eqv? v1 (mus-data g1))) (snd-display #__line__ ";table-lookup data not eqv?: ~A ~A" v1 (mus-data g1)))
	(if (not (equal? v1 (mus-data g1))) (snd-display #__line__ ";table-lookup data not equal?: ~A ~A" v1 (mus-data g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-data g1) 1) .3) (snd-display #__line__ ";table-lookup vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1)))
	(vct-set! (mus-data g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";table-lookup vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1))))
      
      (let ((g1 (make-wave-train :wave v1)))
	(if (not (eq? v1 (mus-data g1))) (snd-display #__line__ ";wave-train data not eq?: ~A ~A" v1 (mus-data g1)))
	(if (not (eqv? v1 (mus-data g1))) (snd-display #__line__ ";wave-train data not eqv?: ~A ~A" v1 (mus-data g1)))
	(if (not (equal? v1 (mus-data g1))) (snd-display #__line__ ";wave-train data not equal?: ~A ~A" v1 (mus-data g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-data g1) 1) .3) (snd-display #__line__ ";wave-train vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1)))
	(vct-set! (mus-data g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";wave-train vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1))))
      
      (let ((g1 (make-polyshape :coeffs v1)))
	(if (not (eq? v1 (mus-data g1))) (snd-display #__line__ ";polyshape data not eq?: ~A ~A" v1 (mus-data g1)))
	(if (not (eqv? v1 (mus-data g1))) (snd-display #__line__ ";polyshape data not eqv?: ~A ~A" v1 (mus-data g1)))
	(if (not (equal? v1 (mus-data g1))) (snd-display #__line__ ";polyshape data not equal?: ~A ~A" v1 (mus-data g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-data g1) 1) .3) (snd-display #__line__ ";polyshape vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1)))
	(vct-set! (mus-data g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";polyshape vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1))))
      
      (let ((g1 (make-delay :initial-contents v1)))
	(if (not (eq? v1 (mus-data g1))) (snd-display #__line__ ";delay data not eq?: ~A ~A" v1 (mus-data g1)))
	(if (not (eqv? v1 (mus-data g1))) (snd-display #__line__ ";delay data not eqv?: ~A ~A" v1 (mus-data g1)))
	(if (not (equal? v1 (mus-data g1))) (snd-display #__line__ ";delay data not equal?: ~A ~A" v1 (mus-data g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-data g1) 1) .3) (snd-display #__line__ ";delay vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1)))
	(vct-set! (mus-data g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";delay vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1))))
      
      (let ((g1 (make-filtered-comb :scaler .5 :initial-contents v1 :filter (make-one-zero .1 .2))))
	(if (not (eq? v1 (mus-data g1))) (snd-display #__line__ ";filtered-comb data not eq?: ~A ~A" v1 (mus-data g1)))
	(if (not (eqv? v1 (mus-data g1))) (snd-display #__line__ ";filtered-comb data not eqv?: ~A ~A" v1 (mus-data g1)))
	(if (not (equal? v1 (mus-data g1))) (snd-display #__line__ ";filtered-comb data not equal?: ~A ~A" v1 (mus-data g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-data g1) 1) .3) (snd-display #__line__ ";filtered-comb vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1)))
	(vct-set! (mus-data g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";filtered-comb vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1))))
      
      (let ((g1 (make-rand :distribution v1)))
	(if (not (eq? v1 (mus-data g1))) (snd-display #__line__ ";rand data not eq?: ~A ~A" v1 (mus-data g1)))
	(if (not (eqv? v1 (mus-data g1))) (snd-display #__line__ ";rand data not eqv?: ~A ~A" v1 (mus-data g1)))
	(if (not (equal? v1 (mus-data g1))) (snd-display #__line__ ";rand data not equal?: ~A ~A" v1 (mus-data g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-data g1) 1) .3) (snd-display #__line__ ";rand vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1)))
	(vct-set! (mus-data g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";rand vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-data g1) 1))))
      
      (let ((g1 (make-fir-filter :xcoeffs v1)))
	(if (not (eq? v1 (mus-xcoeffs g1))) (snd-display #__line__ ";fir-filter xcoeffs not eq?: ~A ~A" v1 (mus-xcoeffs g1)))
	(if (not (eqv? v1 (mus-xcoeffs g1))) (snd-display #__line__ ";fir-filter xcoeffs not eqv?: ~A ~A" v1 (mus-xcoeffs g1)))
	(if (not (equal? v1 (mus-xcoeffs g1))) (snd-display #__line__ ";fir-filter xcoeffs not equal?: ~A ~A" v1 (mus-xcoeffs g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-xcoeffs g1) 1) .3) (snd-display #__line__ ";fir-filter vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-xcoeffs g1) 1)))
	(vct-set! (mus-xcoeffs g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";fir-filter vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-xcoeffs g1) 1))))
      
      (let ((g1 (make-iir-filter :ycoeffs v1)))
	(if (not (eq? v1 (mus-ycoeffs g1))) (snd-display #__line__ ";iir-filter ycoeffs not eq?: ~A ~A" v1 (mus-ycoeffs g1)))
	(if (not (eqv? v1 (mus-ycoeffs g1))) (snd-display #__line__ ";iir-filter ycoeffs not eqv?: ~A ~A" v1 (mus-ycoeffs g1)))
	(if (not (equal? v1 (mus-ycoeffs g1))) (snd-display #__line__ ";iir-filter ycoeffs not equal?: ~A ~A" v1 (mus-ycoeffs g1)))
	(vct-set! v1 1 .3)
	(if (fneq (vct-ref (mus-ycoeffs g1) 1) .3) (snd-display #__line__ ";iir-filter vctset: ~A ~A" (vct-ref v1 1) (vct-ref (mus-ycoeffs g1) 1)))
	(vct-set! (mus-ycoeffs g1) 1 .5)
	(if (fneq (vct-ref v1 1) .5) (snd-display #__line__ ";iir-filter vctref: ~A ~A" (vct-ref v1 1) (vct-ref (mus-ycoeffs g1) 1))))
      
      (let ((f1 (make-frame 2 .1 .2))
	    (f2 (make-frame 2 .3 .5))
	    (f3 (make-frame 2 0 0)))
	(let ((f4 (frame+ f1 f2 f3)))
	  (if (not (eq? f3 f4)) (snd-display #__line__ ";frame+ data not eq?: ~A ~A" f3 f4))
	  (set! f4 (frame* f1 f2 f3))
	  (if (not (eq? f3 f4)) (snd-display #__line__ ";frame* data not eq?: ~A ~A" f3 f4)))))
    
    (let ((tanh-1 (lambda (x)
		    (+ x
		       (* -1/3 x x x)
		       (* 2/15 x x x x x)
		       (* -17/315 x x x x x x x)
		       (* 62/2835 x x x x x x x x x)
		       (* -1382/155925 x x x x x x x x x x x))))
	  (tanh-2 (lambda (y)
		    (let ((x (sin y))
			  (x3 (sin (* 3 y)))
			  (x5 (sin (* 5 y)))
			  (x7 (sin (* 7 y)))
			  (x9 (sin (* 9 y)))
			  (x11 (sin (* 11 y))))
		      (+ (* 140069/172800 x)
			 (* 13319/241920 x3)
			 (* 1973/483840 x5)
			 (* 799/1451520 x7)
			 (* -71/7257600 x9)
			 (* 691/79833600 x11))))))
      (for-each
       (lambda (x)
	 (let ((val (tanh (sin x)))
	       (val1 (tanh-1 (sin x)))
	       (val2 (tanh-2 x)))
	   (if (or (fneq val val1)
		   (fneq val1 val2))
	       (snd-display #__line__ ";tanh(~A): ~A ~A ~A" x val val1 val2))))
       (list 1.0 0.1 0.1 0.333)))
    
    (if all-args
	(let ((maxerr 0.0)
	      (max-case #f)
	      (cases 0))
	  (do ((n 1 (+ n 1)))
	      ((= n 100))
	    (do ((m 1 (+ m 1)))
		((= m 4))
	      (let ((val (sin (/ (* m pi) n)))
		    (expr (sin-m*pi/n m n)))
		(if expr 
		    (let ((err (magnitude (- val (eval expr)))))
		      (set! cases (+ cases 1))
		      (if (> err maxerr)
			  (begin
			    (set! maxerr err)
			    (set! max-case (/ m n)))))))))
	  (if (> maxerr 1e-12)
	      (format #t "sin-m*pi/n (~A cases) max err ~A at ~A~%" cases maxerr max-case))))
    
    (let ((tag (catch #t
		      (lambda () (with-sound () (outa -1 .1)))
		      (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range))
	  (snd-display #__line__ ";outa -1 -> ~A" tag)))
    
    (let ((tag (catch #t
		      (lambda () (let ((v (with-sound (:output (make-vct 10)) (outa -1 .1)))) v))
		      (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range))
	  (snd-display #__line__ ";outa (vct) -1 -> ~A" tag)))
    
    (let ((tag (catch #t
		      (lambda () (let ((v (with-sound (:output (make-sound-data 1 10)) (outa -1 .1)))) v))
		      (lambda args (car args)))))
      (if (not (eq? tag 'out-of-range))
	  (snd-display #__line__ ";outa (sound-data) -1 -> ~A" tag)))
    
    (let ((v (with-sound () (run (outa -1 .1)))))
      (if (file-exists? v)
	  (begin
	    (if (> (cadr (mus-sound-maxamp v)) 0.0) 
		(snd-display #__line__ ";outa to file at -1: ~A" v))
	    (if (> (mus-sound-chans v) 1)
		(snd-display #__line__ ";outa to file at -1 chans: ~A" (mus-sound-chans v)))
	    (if (find-sound v) (close-sound (find-sound v)))
	    (delete-file v))))
    (let ((v (with-sound (:output (make-vct 10)) (run (outa -1 .1)))))
      (if (> (vct-peak v) 0.0) (snd-display #__line__ ";outa to vct at -1: ~A" v)))
    (let ((v (with-sound (:output (make-sound-data 1 10)) (run (outa -1 .1)))))
      (if (> (sound-data-peak v) 0.0) (snd-display #__line__ ";outa to sound-data at -1: ~A" v)))
    
    ))



;;; ---------------- test 9: mix ----------------

(define (snd_test_9)
  
  (define (make-waltz)
    
    (define (frequency->tag-y freq lo octs) ; tag height dependent on freq
      (round (* 100 (- 1.0 (/ (log (/ freq lo)) (* (log 2.0) octs))))))
    
    (let ((oldie (find-sound "test.snd")))
      (if (sound? oldie)
	  (close-sound oldie)))
    
    (let ((violin-sync 1)
	  (violin-color (make-color 0 0 1)) ; blue
	  (cello-sync 2)
	  (cello-color (make-color 0 1 0)) ; green
	  (index (new-sound "test.snd" :channels 1 :size (* 22050 22))))
      
      (define (violin beg dur freq amp)
	(let ((id (car (mix (with-temp-sound ()                            ; write instrument output to temp sound
					     (fm-violin 0 dur (->frequency freq #t) amp)) ; our favorite FM instrument
			    (->sample beg) 0 index 0   ; mix start, file in-chan, sound, channel
			    #t #t))))                  ; mix with tag and auto-delete
	  (if (symbol? freq)
	      (set! (mix-name id) (symbol->string freq)))
	  (set! (mix-sync id) violin-sync)
	  (set! (mix-color id) violin-color)
	  (set! (mix-tag-y id) (frequency->tag-y (->frequency freq #t) (->frequency 'c2) 3))))
      
      (define (cello beg dur freq amp)
	(let ((id (car (mix (with-temp-sound ()
					     (fm-violin 0 dur (->frequency freq #t) amp :fm-index 1.5))
			    (->sample beg) 0 index 0
			    #t #t))))
	  (if (symbol? freq)
	      (set! (mix-name id) (symbol->string freq)))
	  (set! (mix-sync id) cello-sync)
	  (set! (mix-color id) cello-color)
	  (set! (mix-tag-y id) (frequency->tag-y (->frequency freq #t) (->frequency 'c2) 3))))
      
      (as-one-edit
       (lambda ()
	 (violin 0 1 'e4 .2)  (violin 1 1.5 'g4 .2)  (violin 2.5 .5 'g3 .2)
	 (cello  0 1 'c3 .2)  (cello  1 1.5 'e3 .2)  (cello  2.5 .5 'g2 .2)
	 
	 (violin 3 3 'f4 .2)
	 (cello  3 3 'd3 .2)
	 
	 (violin 6 1 'e4 .2)   (violin 7 1 'g3 .2)   (violin 8 1 'e4 .2)
	 (cello  6 1 'c3 .2)   (cello  7 1 'g2 .2)   (cello  8 1 'c3 .2)
	 
	 (violin 9 3 'd4 .2)
	 (cello  9 3 'b2 .2)
	 
	 (violin 12 1 'f4 .2)  (violin 13 1.5 'a4 .2)  (violin 14.5 .5 'g3 .2)
	 (cello  12 1 'd3 .2)  (cello  13 1.5 'f3 .2)  (cello  14.5 .5 'g2 .2)
	 
	 (violin 15 3 'g4 .2)
	 (cello  15 3 'e3 .2)
	 
	 (violin 18 1 'f4 .2)  (violin 19 1 'g3 .2)  (violin 20 1 'f4 .2)
	 (cello  18 1 'd3 .2)  (cello  19 1 'g2 .2)  (cello  20 1 'd3 .2)
	 
	 (violin 21 3 'e4 .2)
	 (cello  21 3 'c3 .2)
	 
	 index))))
  
  (define (make-bagatelle)
    ;; Columbia, Gem of the Ocean
    
    (define (seg data)			; SEG functions expected data in (y x) pairs.
      (let ((unseg '())
	    (len (length data)))
	(do ((i 0 (+ i 2)))
	    ((>= i len))
	  (let ((x (list-ref data (+ 1 i)))
		(y (list-ref data i)))
	    (set! unseg (cons x unseg))
	    (set! unseg (cons y unseg))))
	(reverse unseg)))
    
    (let ((oldie (find-sound "test.snd")))
      (if (sound? oldie)
	  (close-sound oldie)))
    
    (let* ((soprano '())
	   (alto '())
	   (tenor '())
	   (bass '())
	   
	   (ind (new-sound "test.snd" :channels 1))
	   
	   (f1 (seg '(0 0 1 25 1 75 0 100)))
	   (f5 (seg '(-1 0 .25 10 0 20 0 100)))
	   ;; (grc1 (seg '(1 0 .5 10 0 20 0 50 0 100)))
	   ;; (grc2 (seg '(0 0 1 10 0 20 0 50 0 100)))
	   ;; (grc3 (seg '(.5 0 1 10 0 20 0 50 0 100)))
	   ;; (grc4 (seg '(1 0 0 10 1 20 0 30 1 40 0 50 1 60 0 70 1 80 0 90 1 100)))
	   ;; (grc5 (seg '(1 0 .5 10  1 20  0 30  1 40  .5 50  1 60  0 70  1 80  .5 90  1 100)))
	   ;; (grc6 (seg '(1 0  .5 10  0 20  -.5 30  -1 40  -.5 50  0 60  .5 70  1 80  .5 90  0 100)))
	   (f6 (seg '(1 1  .5 10  .75 50  .4 75  .6 90  0 100)))
	   (f7 (seg '(0 1  .5 10  .25 25  .75 50  .5 75  1 90  0 100)))
	   ;; (f2 (seg '(0 1  .5 10  .4 90  0 100)))
	   ;; (f3 (seg '(1 0  .5 10  .75 90 0 100)))
	   ;; (ramp (seg '(0 0 1 2.5  1 7.5  0 10  1 12.5  1 17.5  0 20  1 22.5  1 27.5  0 30  1 32.5  1 37.5
	   ;;		0 40  1 42.5  1 47.5  0 50  1 52.5  1 57.5  0 60  1 62.5  1 67.5  0 70  1 72.5  1 77.5
	   ;;		0 80  1 82.5  1 87.5  0 90  1 92.5  1 97.5  0 100)))
	   ;; (str (seg '(1 1  1 100)))
	   )
      
      (define (mix-fmsimp beg dur freq amp ampfunc freqfunc rat1 indx1 rat2 indx2 ignored)
	(let* ((freq1 (if (> freq (/ (mus-srate) 8)) (/ freq 8) freq))
	       (amp1 (* amp .175)))
	  (let ((id (car (mix (with-temp-sound () 
					       (fm-violin 0 dur freq1 amp1
							  :fm1-rat (* 1.002 rat1)
							  :fm1-index (* .5 rat1 indx1 (hz->radians freq))
							  :fm1-env f6
							  :fm2-rat (* 1.003 rat2)
							  :fm2-index (* .5 indx2 rat2 (hz->radians freq))
							  :fm2-env f7
							  :fm3-index 0.0
							  :reverb-amount 1.0
							  :amp-env ampfunc))
			      (->sample beg) 0 ind 0 #t #t))))  ; with tag and auto-delete
	    (set! (mix-name id) (number->string (floor freq)))
	    (if (> freq 700) (set! soprano (cons id soprano))
		(if (> freq 500) (set! alto (cons id alto))
		    (if (> freq 300) (set! tenor (cons id tenor))
			(set! bass (cons id bass))))))))
      
      (as-one-edit
       (lambda ()
	 (mix-fmsimp   .000  2.488  659.255   .500  f1  f5  5.000  1.260  2.000   .501   .000 )
	 (mix-fmsimp   .750  1.988  654.084   .167  f1  f5  3.000  1.260  1.000   .710   .000 )
	 (mix-fmsimp  1.000  2.738  880.000   .500  f1  f5  5.000  1.260  1.000   .140   .001 )
	 (mix-fmsimp  2.000  2.488  880.000   .500  f1  f5  1.000  1.671  2.000   .745   .001 )
	 (mix-fmsimp  2.750  1.969  871.429   .495  f1  f5  5.000  1.312  1.000   .447   .001 )
	 (mix-fmsimp  3.000  2.750  493.883   .100  f1  f5  1.000  1.260  2.000  1.069   .002 )
	 (mix-fmsimp  4.000  2.488  654.568   .500  f1  f5  3.000  1.671  5.000   .793   .002 )
	 (mix-fmsimp  4.750  1.988  590.042   .241  f1  f5  2.000  1.671  5.000  1.046   .002 )
	 (mix-fmsimp  5.000  2.238  551.574   .500  f1  f5  4.000  1.671  1.000   .073   .003 )
	 (mix-fmsimp  5.500  2.238  664.174   .504  f1  f5  3.000  1.671  4.000   .791   .003 )
	 (mix-fmsimp  6.000  1.988  659.255   .400  f1  f5  2.000  1.671  2.000   .955   .003 )
	 (mix-fmsimp  6.250  2.738  880.000   .400  f1  f5  5.000  1.260  5.000   .645   .003 )
	 (mix-fmsimp  7.250  2.505  885.724   .336  f1  f5  5.000  1.260  4.000   .302   .004 )
	 (mix-fmsimp  8.000  1.988  880.000   .500  f1  f5  3.000  1.260  2.000   .672   .004 )
	 (mix-fmsimp  8.250  2.738  493.883   .100  f1  f5  4.000  1.671  1.000   .013   .004 )
	 (mix-fmsimp  9.250  2.488  659.255   .250  f1  f5  3.000  1.671  3.000  1.167   .005 )
	 (mix-fmsimp  10.000  1.988  587.330   .240  f1  f5  2.000  1.314  5.000   .423   .005 )
	 (mix-fmsimp  10.250  2.238  554.365   .500  f1  f5  1.000  1.671  2.000   .078   .005 )
	 (mix-fmsimp  10.750  2.238  659.255   .500  f1  f5  1.000  1.260  5.000   .797   .005 )
	 (mix-fmsimp  11.250  1.988  651.332   .400  f1  f5  5.000  1.671  1.000   .883   .006 )
	 (mix-fmsimp  11.500  1.926  878.372   .200  f1  f5  1.000  1.434  4.000   .322   .006 )
	 (mix-fmsimp  11.688  2.497  880.000   .335  f1  f5  2.000  1.671  4.000   .879   .006 )
	 (mix-fmsimp  12.438  2.006  887.764   .288  f1  f5  1.000  1.671  4.000   .652   .006 )
	 (mix-fmsimp  12.688  2.738  493.883   .100  f1  f5  1.000  1.671  4.000   .521   .006 )
	 (mix-fmsimp  13.688  2.488  659.255   .250  f1  f5  2.000  1.671  2.000  1.247   .007 )
	 (mix-fmsimp  14.438  1.988  587.330   .240  f1  f5  1.000  1.260  2.000  1.182   .007 )
	 (mix-fmsimp  14.688  2.238  547.848   .494  f1  f5  4.000  1.671  2.000   .432   .007 )
	 (mix-fmsimp  15.188  3.238  867.651   .500  f1  f5  4.000  1.671  1.000   .571   .008 )
	 (mix-fmsimp  16.688  2.238  659.255   .400  f1  f5  4.000  1.671  4.000   .477   .008 )
	 (mix-fmsimp  17.188  1.988  652.468   .495  f1  f5  3.000  1.671  2.000   .438   .009 )
	 (mix-fmsimp  17.438  1.926  880.000   .200  f1  f5  2.000  1.671  4.000  1.107   .009 )
	 (mix-fmsimp  17.625  2.523  880.000   .500  f1  f5  5.000  1.671  1.000   .830   .009 )
	 (mix-fmsimp  18.375  1.988  880.000   .400  f1  f5  4.000  1.671  3.000   .186   .009 )
	 (mix-fmsimp  18.625  2.738  493.883   .100  f1  f5  1.000  1.260  5.000   .407   .009 )
	 (mix-fmsimp  19.625  2.488  657.231   .166  f1  f5  5.000  1.260  2.000   .389   .010 )
	 (mix-fmsimp  20.375  1.976  587.330   .238  f1  f5  2.000  1.671  1.000   .712   .010 )
	 (mix-fmsimp  20.625  2.238  554.365   .500  f1  f5  3.000  1.260  5.000   .171   .010 )
	 (mix-fmsimp  21.125  3.238  880.000   .500  f1  f5  4.000  1.671  1.000   .507   .011 )
	 (mix-fmsimp  22.625  2.238  650.838   .395  f1  f5  3.000  1.671  4.000   .160   .011 )
	 (mix-fmsimp  23.125  1.978  659.255   .497  f1  f5  1.000  1.671  1.000   .867   .012 )
	 (mix-fmsimp  23.375  1.926  885.243   .333  f1  f5  2.000  1.412  4.000   .811   .012 )
	 (mix-fmsimp  23.563  2.488  880.000   .500  f1  f5  4.000  1.671  3.000   .439   .012 )
	 (mix-fmsimp  24.313  1.995  882.799   .401  f1  f5  1.000  1.671  4.000  1.089   .012 )
	 (mix-fmsimp  24.563  2.730  246.942   .100  f1  f5  2.000  1.671  1.000   .092   .012 )
	 (mix-fmsimp  25.563  2.488  329.628   .167  f1  f5  2.000  1.671  2.000  1.149   .012 )
	 (mix-fmsimp  26.313  2.007  587.330   .242  f1  f5  3.000  1.671  3.000   .472   .011 )
	 (mix-fmsimp  26.563  2.238  548.468   .495  f1  f5  2.000  1.671  1.000   .259   .011 )
	 (mix-fmsimp  27.063  3.238  439.221   .500  f1  f5  3.000  1.260  3.000  1.014   .011 )
	 (mix-fmsimp  28.563  2.493  441.603   .401  f1  f5  3.000  1.671  5.000   .056   .010 )
	 (mix-fmsimp  29.313  2.220  659.255   .500  f1  f5  3.000  1.260  3.000  1.108   .010 )
	 (mix-fmsimp  29.813  1.960  329.628   .500  f1  f5  1.000  1.671  1.000   .944   .010 )
	 (mix-fmsimp  30.063  1.894  440.000   .333  f1  f5  1.000  1.260  4.000   .602   .009 )
	 (mix-fmsimp  30.250  2.453  443.160   .400  f1  f5  1.000  1.260  3.000   .750   .009 )
	 (mix-fmsimp  31.000  1.938  441.168   .333  f1  f5  5.000  1.671  3.000   .522   .009 )
	 (mix-fmsimp  31.250  2.684  246.942   .100  f1  f5  5.000  1.654  1.000  1.020   .009 )
	 (mix-fmsimp  32.250  2.415  325.263   .167  f1  f5  4.000  1.671  3.000   .014   .008 )
	 (mix-fmsimp  33.000  1.901  587.330   .240  f1  f5  4.000  1.671  5.000  1.106   .008 )
	 (mix-fmsimp  33.250  2.149  554.936   .501  f1  f5  2.000  1.260  2.000  1.159   .008 )
	 (mix-fmsimp  33.750  3.137  440.000   .500  f1  f5  2.000  1.671  1.000   .647   .008 )
	 (mix-fmsimp  35.250  2.359  440.000   .400  f1  f5  5.000  1.671  4.000  1.149   .007 )
	 (mix-fmsimp  36.000  2.101  661.109   .501  f1  f5  4.000  1.377  2.000  1.121   .006 )
	 (mix-fmsimp  36.500  1.836  329.628   .500  f1  f5  2.000  1.671  4.000  1.459   .006 )
	 (mix-fmsimp  36.750  1.768  440.000   .250  f1  f5  5.000  1.671  5.000   .601   .006 )
	 (mix-fmsimp  36.938  2.327  442.815   .400  f1  f5  2.000  1.671  3.000   .354   .006 )
	 (mix-fmsimp  37.688  1.813  440.000   .400  f1  f5  4.000  1.671  2.000   .205   .006 )
	 (mix-fmsimp  37.938  2.559  246.712   .100  f1  f5  4.000  1.671  2.000  1.044   .006 )
	 (mix-fmsimp  38.938  2.290  329.628   .167  f1  f5  1.000  1.260  2.000  1.316   .005 )
	 (mix-fmsimp  39.688  1.781  587.330   .240  f1  f5  1.000  1.671  3.000   .524   .005 )
	 (mix-fmsimp  39.938  2.021  554.365   .500  f1  f5  1.000  1.671  2.000   .522   .005 )
	 (mix-fmsimp  40.438  2.998  438.022   .498  f1  f5  3.000  1.260  4.000   .264   .004 )
	 (mix-fmsimp  41.938  2.253  443.810   .403  f1  f5  1.000  1.671  4.000  1.157   .004 )
	 (mix-fmsimp  42.688  1.720  414.691   .319  f1  f5  4.000  1.671  1.000   .612   .003 )
	 (mix-fmsimp  42.938  1.965  659.255   .500  f1  f5  2.000  1.671  2.000   .559   .003 )
	 (mix-fmsimp  43.438  1.690  329.628   .496  f1  f5  5.000  1.671  2.000  1.457   .003 )
	 (mix-fmsimp  43.688  1.630  440.000   .249  f1  f5  2.000  1.671  5.000   .505   .003 )
	 (mix-fmsimp  43.875  2.197  440.000   .400  f1  f5  3.000  1.260  3.000   .843   .003 )
	 (mix-fmsimp  44.625  1.678  440.000   .332  f1  f5  2.000  1.671  5.000  1.165   .002 )
	 (mix-fmsimp  44.875  2.405  246.942   .100  f1  f5  4.000  1.671  3.000   .105   .002 )
	 (mix-fmsimp  45.875  2.160  332.580   .168  f1  f5  1.000  1.260  5.000  1.107   .002 )
	 (mix-fmsimp  46.625  1.646  583.584   .238  f1  f5  4.000  1.673  5.000   .201   .001 )
	 (mix-fmsimp  46.875  1.891  553.184   .492  f1  f5  1.000  1.304  2.000  1.230   .001 )
	 (mix-fmsimp  47.375  2.882  438.012   .489  f1  f5  5.000  1.737  4.000   .024   .001 )
	 (mix-fmsimp  48.875  2.104  440.000   .487  f1  f5  2.000  1.770  2.000   .308   .000 )
	 (mix-fmsimp  49.625  1.590  414.068   .319  f1  f5  4.000  1.866  3.000   .415   .001 )
	 (mix-fmsimp  49.875  1.835  659.255   .467  f1  f5  1.000  1.914  3.000   .477   .001 )
	 (mix-fmsimp  50.375  1.592  333.127   .470  f1  f5  5.000  1.930  2.000   .230   .001 )
	 (mix-fmsimp  50.625  1.509  440.000   .250  f1  f5  5.000  1.963  1.000   .829   .001 )
	 (mix-fmsimp  50.813  2.068  440.000   .400  f1  f5  3.000  1.979  1.000  1.450   .001 )
	 (mix-fmsimp  51.563  1.536  434.964   .330  f1  f5  4.000  1.991  2.000   .308   .002 )
	 (mix-fmsimp  51.813  2.299  246.942   .088  f1  f5  4.000  1.581  5.000  1.149   .002 )
	 (mix-fmsimp  52.813  2.030  329.628   .167  f1  f5  5.000  1.916  5.000  1.234   .002 )
	 (mix-fmsimp  53.563  1.524  590.360   .241  f1  f5  4.000  2.119  4.000   .374   .003 )
	 (mix-fmsimp  53.813  1.761  554.365   .433  f1  f5  3.000  2.168  3.000   .269   .003 )
	 (mix-fmsimp  54.313  2.720  434.908   .425  f1  f5  3.000  2.184  1.000  1.209   .003 )
	 (mix-fmsimp  55.813  1.966  440.000   .426  f1  f5  4.000  2.196  2.000  1.493   .004 )
	 (mix-fmsimp  56.563  1.446  415.305   .316  f1  f5  4.000  2.312  1.000   .753   .004 )
	 (mix-fmsimp  56.813  2.205  369.994   .406  f1  f5  2.000  2.361  1.000   .292   .004 )
	 (mix-fmsimp  57.813  1.668  329.628   .400  f1  f5  4.000  2.377  1.000   .179   .005 )
	 (mix-fmsimp  58.313  1.422  329.628   .394  f1  f5  4.000  2.441  3.000  1.117   .005 )
	 (mix-fmsimp  58.563  1.360  435.856   .250  f1  f5  1.000  1.960  5.000   .811   .005 )
	 (mix-fmsimp  58.750  1.919  440.000   .389  f1  f5  2.000  2.489  3.000   .242   .005 )
	 (mix-fmsimp  59.500  1.405  439.947   .387  f1  f5  3.000  2.501  4.000  1.265   .006 )
	 (mix-fmsimp  59.750  2.173  249.594   .073  f1  f5  2.000  2.550  2.000   .351   .006 )
	 (mix-fmsimp  60.750  1.881  329.628   .200  f1  f5  2.000  2.566  2.000  1.431   .006 )
	 (mix-fmsimp  61.500  1.367  293.665   .240  f1  f5  1.000  2.096  1.000  1.378   .007 )
	 (mix-fmsimp  61.750  1.613  554.365   .363  f1  f5  1.000  2.678  1.000   .201   .007 )
	 (mix-fmsimp  62.250  2.603  433.901   .356  f1  f5  2.000  2.694  5.000   .950   .007 )
	 (mix-fmsimp  63.750  1.809  440.000   .354  f1  f5  4.000  2.727  4.000   .459   .008 )
	 (mix-fmsimp  64.500  1.314  415.305   .320  f1  f5  3.000  2.265  1.000  1.059   .008 )
	 (mix-fmsimp  64.750  2.057  374.139   .341  f1  f5  2.000  2.307  3.000   .054   .008 )
	 (mix-fmsimp  65.750  1.538  329.628   .335  f1  f5  4.000  2.887  3.000  1.281   .009 )
	 (mix-fmsimp  66.250  1.278  329.628   .326  f1  f5  3.000  2.952  4.000   .363   .009 )
	 (mix-fmsimp  66.500  1.211  440.000   .322  f1  f5  5.000  2.405  4.000   .361   .009 )
	 (mix-fmsimp  66.688  1.769  440.000   .319  f1  f5  4.000  2.419  3.000   .190   .009 )
	 (mix-fmsimp  67.438  1.256  437.237   .316  f1  f5  1.000  2.430  2.000  1.121   .010 )
	 (mix-fmsimp  67.688  1.979  246.942   .056  f1  f5  2.000  2.472  4.000  1.172   .010 )
	 (mix-fmsimp  68.688  1.736  330.174   .250  f1  f5  4.000  2.486  3.000   .893   .010 )
	 (mix-fmsimp  69.438  1.213  292.204   .238  f1  f5  5.000  2.732  1.000  1.265   .011 )
	 (mix-fmsimp  69.688  1.462  553.724   .294  f1  f5  3.000  3.189  3.000   .427   .011 )
	 (mix-fmsimp  70.188  2.455  440.000   .292  f1  f5  2.000  2.598  5.000   .489   .011 )
	 (mix-fmsimp  71.688  1.654  440.000   .284  f1  f5  5.000  3.237  2.000  1.299   .012 )
	 (mix-fmsimp  72.438  1.175  415.305   .277  f1  f5  3.000  2.995  4.000   .916   .012 )
	 (mix-fmsimp  72.688  1.933  369.994   .271  f1  f5  1.000  3.382  1.000   .886   .012 )
	 (mix-fmsimp  73.688  1.639  440.000   .046  f1  f5  4.000  3.398  5.000   .993   .012 )
	 (mix-fmsimp  74.438  15.942  329.628   .257  f1  f5  1.000  2.822  1.000   .402   .011 )
	 (mix-fmsimp  74.938  (- 45.394 20)  329.628   .249  f1  f5  1.000  2.864  2.000  1.093   .011 )
	 (mix-fmsimp  75.438  (- 45.063 20)  440.000   .246  f1  f5  3.000  3.543  2.000   .978   .011 )
	 (mix-fmsimp  75.625  (- 45.335 20)  444.508   .244  f1  f5  2.000  2.920  4.000   .563   .011 )
	 (mix-fmsimp  76.375  (- 44.125 20)  445.106   .240  f1  f5  3.000  2.931  2.000   .768   .010 )
	 (mix-fmsimp  76.625  (- 43.875 20)  248.294   .038  f1  f5  2.000  2.973  2.000   .155   .010 )
	 (mix-fmsimp  77.625  (- 43.455 20)  334.084   .234  f1  f5  3.000  2.987  4.000   .047   .010 )
	 (mix-fmsimp  78.375  (- 41.938 20)  292.359   .222  f1  f5  3.000  3.521  5.000  1.140   .009 )
	 (mix-fmsimp  78.625  (- 41.605 20)  554.365   .215  f1  f5  2.000  3.085  4.000   .595   .009 )
	 (mix-fmsimp  79.125  (- 41.769 20)  440.000   .214  f1  f5  3.000  3.780  3.000   .541   .009 )
	 (mix-fmsimp  80.625  (- 39.875 20)  440.000   .200  f1  f5  3.000  3.812  2.000  1.111   .008 )
	 (mix-fmsimp  91.130  (- 29.335 20)  415.305   .111  f1  f5  3.000  3.759  2.000   .490   .003 )
	 
	 ind))))
  
  (if with-gui
      (begin
	
	(do ((test-ctr 0 (+ 1 test-ctr)))
	    ((= test-ctr tests))
	  
	  (let ((ind (new-sound "test.snd" :size 10)))
	    (let ((v (vct .1 .2 .3)))
	      (let ((id (mix-vct v 0)))
		(let ((nv (channel->vct)))
		  (if (not (vequal nv (vct .1 .2 .3 0 0 0 0 0 0 0)))
		      (snd-display #__line__ ";mix v at 0: ~A" nv)))
		(let ((eds (edit-tree ind 0)))
		  (if (not (feql eds '((0 0 0 2 0.0 0.0 0.0 3) (3 0 3 9 0.0 0.0 0.0 2) (10 -2 0 0 0.0 0.0 0.0 0))))
		      (snd-display #__line__ ";mix v at 0 eds: ~A" eds)))
		(if (not (mix? id))
		    (snd-display #__line__ ";mix v at 0 id from mix?: ~A" id))
		(if (fneq (mix-amp id) 1.0) (snd-display #__line__ ";mix v at 0 amp: ~A" (mix-amp id)))
		(if (fneq (mix-speed id) 1.0) (snd-display #__line__ ";mix v at 0 speed: ~A" (mix-speed id)))
		(if (not (= (mix-sync id) 0)) (snd-display #__line__ ";mix v at 0 sync: ~A" (mix-sync id)))
		(if (not (equal? (mix-amp-env id) '())) (snd-display #__line__ ";mix v at 0 amp-env: ~A" (mix-amp-env id)))
		(if (not (= (mix-position id) 0)) (snd-display #__line__ ";mix v at 0 beg: ~A" (mix-position id)))
		(if (not (= (mix-length id) 3)) (snd-display #__line__ ";mix v at 0 length: ~A" (mix-length id)))
		(if (not (equal? (mix-name id) #f)) (snd-display #__line__ ";mix v at 0 name: ~A" (mix-name id)))
		(if (not (equal? (mix-properties id) '())) (snd-display #__line__ ";mix v at 0 properties: ~A" (mix-properties id)))
		(if (not (equal? (mix-color id) (mix-color))) (snd-display #__line__ ";mix v at 0 color: ~A" (mix-color id)))
		(if (not (= (mix-tag-y id) 0)) (snd-display #__line__ ";mix v at 0 tag-y: ~A" (mix-tag-y id)))
		(let ((sf (make-mix-sampler id))
		      (data (make-vct 10)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (read-mix-sample sf)))
		  (if (not (vequal data (channel->vct)))
		      (snd-display #__line__ ";mix v at 0 read mix samples: ~A" data))
		  (if (not (sampler-at-end? sf)) (snd-display #__line__ ";mix v at 0 reader not at end?"))
		  (free-sampler sf))
		(if (not (equal? (mixes ind 0) (list id))) (snd-display #__line__ ";mix v at 0 mixes: ~A" (mixes ind 0)))
		(if (not (equal? (mix-home id) (list ind 0 #f 0))) (snd-display #__line__ ";mix v at 0 home: ~A" (mix-home id)))
		(undo))
	      (let ((id (mix-vct v 8)))
		(if (not (= (frames ind 0) 11)) (snd-display #__line__ ";mix v at 8 new len: ~A" (frames ind 0)))
		(let ((nv (channel->vct)))
		  (if (not (vequal nv (vct 0 0 0 0 0 0 0 0 .1 .2 .3)))
		      (snd-display #__line__ ";mix v at 8: ~A" nv)))
		(undo))
	      (let ((id (mix-vct v 3)))
		(if (not (= (frames ind 0) 10)) (snd-display #__line__ ";mix v at 3 new len: ~A" (frames ind 0)))
		(let ((nv (channel->vct)))
		  (if (not (vequal nv (vct 0 0 0 .1 .2 .3 0 0 0 0)))
		      (snd-display #__line__ ";mix v at 3: ~A" nv)))
		(undo)))
	    (let ((v (make-vct 20 .5)))
	      (let ((id (mix-vct v 0)))
		(if (not (= (frames ind 0) 20)) (snd-display #__line__ ";mix v20 at 0 new len: ~A" (frames ind 0)))))
	    (close-sound ind))
	  
	  (let ((ind (new-sound "test.snd" :size 100000)))
	    (let ((id (car (mix "oboe.snd" 0))))
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix oboe at 0 id from mix?: ~A" id))
	      (if (fneq (mix-amp id) 1.0) (snd-display #__line__ ";mix oboe at 0 amp: ~A" (mix-amp id)))
	      (if (fneq (mix-speed id) 1.0) (snd-display #__line__ ";mix oboe at 0 speed: ~A" (mix-speed id)))
	      (if (not (= (mix-sync id) 0)) (snd-display #__line__ ";mix oboe at 0 sync: ~A" (mix-sync id)))
	      (if (not (equal? (mix-amp-env id) '())) (snd-display #__line__ ";mix oboe at 0 amp-env: ~A" (mix-amp-env id)))
	      (if (not (= (mix-position id) 0)) (snd-display #__line__ ";mix oboe at 0 beg: ~A" (mix-position id)))
	      (if (not (= (mix-length id) 50828)) (snd-display #__line__ ";mix oboe at 0 length: ~A" (mix-length id)))
	      (if (not (equal? (mix-name id) #f)) (snd-display #__line__ ";mix oboe at 0 name: ~A" (mix-name id)))
	      (if (not (equal? (mix-properties id) '())) (snd-display #__line__ ";mix oboe at 0 properties: ~A" (mix-properties id)))
	      (if (not (equal? (mix-color id) (mix-color))) (snd-display #__line__ ";mix oboe at 0 color: ~A" (mix-color id)))
	      (if (not (= (mix-tag-y id) 0)) (snd-display #__line__ ";mix oboe at 0 tag-y: ~A" (mix-tag-y id)))
	      
	      (if (fneq (maxamp ind 0) .14724) (snd-display #__line__ ";mix oboe maxamp: ~A" (maxamp ind 0)))
	      (if (not (equal? (mixes ind 0) (list id))) (snd-display #__line__ ";mix oboe at 0 mixes: ~A" (mixes ind 0)))
	      (if (not (equal? (mix-home id) (list ind 0 "/home/bil/cl/oboe.snd" 0))) (snd-display #__line__ ";mix oboe at 0 home: ~A" (mix-home id))))
	    (undo)
	    (let ((id (car (mix "oboe.snd" 70000))))
	      (if (not (= (frames ind 0) (+ 70000 50828))) (snd-display #__line__ ";mix oboe at 70k frames: ~A" (frames ind 0))))
	    (close-sound ind))
	  
	  (let ((ind (new-sound "test.snd" :size 10)))
	    (let ((v (vct .1 .2 .3)))
	      (let ((id (mix-vct v 0)))
		(scale-by 2.0)
		(if (not (mix? id)) (snd-display #__line__ ";scaled (2) mix not active?"))
		(let ((nv (channel->vct)))
		  (if (not (vequal nv (vct-scale! (vct .1 .2 .3 0 0 0 0 0 0 0) 2.0)))
		      (snd-display #__line__ ";mix v at 0 scale-by 2: ~A" nv)))
		(if (fneq (mix-amp id) 2.0) (snd-display #__line__ ";mix then scale mix amp: ~A" (mix-amp id)))
		(undo)
		(delete-sample 1)
		(if (not (mix? id)) (snd-display #__line__ ";delete hit mix: ~A" (mix? id)))
		(let ((nv (channel->vct)))
		  (if (not (vequal nv (vct .1 .3 0 0 0 0 0 0 0)))
		      (snd-display #__line__ ";mix v at 0 delete .2: ~A" nv)))
		(revert-sound ind))
	      (let ((id (mix-vct v 0)))
		(delete-sample 7)
		(reverse-sound ind 0)
		(if (not (mix? id)) (snd-display #__line__ ";reversed mix: ~A" (mix? id)))
		(let ((nv (channel->vct)))
		  (if (not (vequal nv (vct-reverse! (vct .1 .2 .3 0 0 0 0 0 0))))
		      (snd-display #__line__ ";mix v at 0 reversed: ~A" nv)))
		(undo)
		(if (not (mix? id)) (snd-display #__line__ ";revert reverse mix: ~A" (mix? id)))
		(map-channel (lambda (y) .1))
		(if (not (mix? id)) (snd-display #__line__ ";clobbered mix: ~A" (mixes)))
		(scale-by 2.0)
		(let ((id (mix-vct v 0)))
		  (if (not (mix? id)) (snd-display #__line__ ";mix on scale (2) not active?"))
		  (scale-by 3.0)
		  (if (not (mix? id)) (snd-display #__line__ ";scaled (3) mix not active?"))
		  (let ((nv (channel->vct)))
		    (if (not (vequal nv (vct-scale! (vct-add! (make-vct 9 .2) (vct .1 .2 .3)) 3.0)))
			(snd-display #__line__ ";mix v at 0 scale-by 2 and 3: ~A" nv))))
		(revert-sound ind)
		(map-channel (lambda (y) 1.0))
		(env-channel '(0 0 1 1 2 0) 0 11)
		(let ((v (vct .1 .2 .3)))
		  (let ((id (mix-vct v 3)))
		    (let ((nv (channel->vct)))
		      (if (not (vequal nv (vct 0.000 0.200 0.400 0.700 1.000 1.300 0.800 0.600 0.400 0.200)))
			  (snd-display #__line__ ";mix v at 3 after env: ~A" nv)))))
		(close-sound ind))))
	  
	  (let ((ind (new-sound "test.snd" :size 100)))
	    (let ((v (vct .1 .2 .3)))
	      (let ((id (mix-vct v 10)))
		(pad-channel 0 10)
		(if (not (mix? id)) (snd-display #__line__ ";padded mix not active?"))
		(if (not (= (mix-position id) 20)) (snd-display #__line__ ";after pad mix pos: ~A" (mix-position id)))
		(set! (mix-sync id) 2)
		(if (not (= (mix-sync id) 2)) (snd-display #__line__ ";set mix sync 2: ~A" (mix-sync id)))
		(if (and full-test (< (mix-sync-max) 2)) (snd-display #__line__ ";mix-sync-max: ~A" (mix-sync-max)))
		(pad-channel 50 10)
		(if (not (mix? id)) (snd-display #__line__ ";padded 50 mix not active?"))
		(if (not (= (mix-position id) 20)) (snd-display #__line__ ";after pad 50 mix pos: ~A" (mix-position id)))
		(undo 1)
		(let ((id1 (mix-vct v 22))
		      (id2 (mix-vct v 21)))
		  (let ((vals (channel->vct 18 10)))
		    (if (not (vequal vals (vct 0.000 0.000 0.100 0.300 0.600 0.500 0.300 0.000 0.000 0.000)))
			(snd-display #__line__ ";mix 3 vs: ~A" vals))
		    (if (not (mix? id)) (snd-display #__line__ ";mix 3vs 1 not active?"))
		    (if (not (mix? id1)) (snd-display #__line__ ";mix 3vs 2 not active?"))
		    (if (not (mix? id2)) (snd-display #__line__ ";mix 3vs 3 not active?"))
		    (set! (mix-position id) 10)
		    (set! vals (channel->vct 18 10))
		    (if (not (vequal vals (vct 0.000 0.000 0.000 0.100 0.300 0.500 0.300 0.000 0.000 0.000)))
			(snd-display #__line__ ";mix 3 vs then move 1st: ~A" vals))
		    (set! (mix-position id2) 30)
		    (set! vals (channel->vct 18 10))
		    (if (not (vequal vals (vct 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.000 0.000 0.000)))
			(snd-display #__line__ ";mix 3 vs then move 2: ~A" vals))
		    (scale-by 2.0)
		    (if (not (mix? id)) (snd-display #__line__ ";mix 3vs 1 scl not active?"))
		    (if (not (mix? id1)) (snd-display #__line__ ";mix 3vs 2 scl not active?"))
		    (if (not (mix? id2)) (snd-display #__line__ ";mix 3vs 3 scl not active?"))
		    (set! vals (channel->vct 18 10))
		    (if (not (vequal vals (vct 0.000 0.000 0.000 0.000 0.200 0.400 0.600 0.000 0.000 0.000)))
			(snd-display #__line__ ";mix 3 vs then move 2 scl: ~A" vals))
		    (delete-sample 15)
		    (if (not (mix? id)) (snd-display #__line__ ";mix 3vs 1 scl del not active?"))
		    (if (not (mix? id1)) (snd-display #__line__ ";mix 3vs 2 scl del not active?"))
		    (if (not (mix? id2)) (snd-display #__line__ ";mix 3vs 3 scl del not active?"))
		    (if (not (= (mix-position id) 10)) (snd-display #__line__ ";mix 3vs etc pos: ~A" (mix-position id)))
		    (if (not (= (mix-position id1) 21)) (snd-display #__line__ ";mix 3vs etc pos 1: ~A" (mix-position id1)))
		    (if (not (= (mix-position id2) 29)) (snd-display #__line__ ";mix 3vs etc pos 2: ~A" (mix-position id2)))
		    ))))
	    (close-sound ind))
	  
	  (let ((ind (new-sound "test.snd" :size 15)))
	    (let ((id (mix-vct (make-vct 11 1.0) 2)))
	      (set! (mix-amp-env id) '(0 0 1 1))
	      (let ((vals (channel->vct)))
		(if (not (vequal vals (vct 0 0 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 0 0)))
		    (snd-display #__line__ ";ramp mix amp env: ~A" vals)))
	      (set! (mix-amp-env id) #f)
	      (if (not (null? (mix-amp-env id))) (snd-display #__line__ ";set mix-amp-env to null: ~A" (mix-amp-env id)))
	      (set! (mix-speed id) 0.5)
	      (if (not (= (frames) 24)) (snd-display #__line__ ";mix speed lengthens 24: ~A" (frames)))
	      (set! (mix-speed id) 1.0)
	      (let ((vals (channel->vct)))
		(if (not (vequal vals (vct 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0)))
		    (snd-display #__line__ ";return to mix original index: ~A" vals)))
	      (set! (mix-amp-env id) '(0 0 1 1 2 1 3 0))
	      (set! (mix-speed id) 0.5)
	      (set! (mix-amp-env id) #f)
	      (set! (mix-speed id) 1.0)
	      (let ((vals (channel->vct)))
		(if (not (vequal vals (vct 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0)))
		    (snd-display #__line__ ";return again to mix original index: ~A" vals)))
	      (close-sound ind)))
	  
	  
	  (let ((id (open-sound "oboe.snd")))
	    (make-selection 1000 2000 id 0)
	    (let ((mix-id (car (mix-selection 3000 id 0))))
	      (set! (mix-amp mix-id) .5)
	      (if (fneq (mix-amp mix-id) .5)
		  (snd-display #__line__ ";mix-amp .5: ~A" (mix-amp mix-id)))
	      (scale-by .5)
	      (undo)
	      (close-sound id)))
	  (set! (print-length) 30)
	  
	  (let* ((ind (open-sound "2.snd"))
		 (md (car (mix "1a.snd" 1000 0 ind 1 #t))))
	    (if (fneq (maxamp ind 1) .1665) (snd-display #__line__ ";maxamp after mix into chan 2: ~A" (maxamp ind 1)))
	    (set! (mix-amp md) 0.0)
	    (if (or (not (equal? (edits ind 0) (list 0 0)))
		    (not (equal? (edits ind 1) (list 2 0))))
		(snd-display #__line__ ";mix into chan2 zeroed: ~A ~A" (edits ind 0) (edits ind 1)))
	    (if (fneq (maxamp ind 1) .066) (snd-display #__line__ ";maxamp after mix zeroed into chan 2: ~A" (maxamp ind 1)))
	    (set! (mix-amp md) 0.5)
	    (if (fneq (maxamp ind 1) .116) (snd-display #__line__ ";maxamp after mix 0.5 into chan 2: ~A" (maxamp ind 1)))
	    (set! (mix-speed md) 2.0)
	    (if (fneq (/ (mix-length md) (mus-sound-frames "1a.snd")) 0.5)
		(snd-display #__line__ ";mix srate chan 2: ~A ~A" (mix-length md) (mus-sound-frames "1a.snd")))
	    (update-time-graph)
	    (set! (mix-speed md) 0.5)
	    (update-time-graph)
	    (set! (mix-amp md) 1.0)
	    (if (fneq (maxamp ind 1) .166)
		(snd-display #__line__ ";non-sync mix-speed maxamp: ~A" (maxamp ind 1)))
	    (set! (mix-amp-env md) '(0 0 1 1 2 0))
	    (update-time-graph)
	    (set! (mix-speed md) 1.0)
	    (update-time-graph)
	    (revert-sound ind)
	    (set! (sync ind) 1)
	    (let ((m0 (maxamp ind 0))
		  (m1 (maxamp ind 1))
		  (len (frames ind 0)))
	      (set! md (mix "2.snd" 0 #t)) ; should double both chans, no len change
	      (if (or (not (= (frames ind 0) len))
		      (fneq (maxamp ind 0) (* 2 m0))
		      (fneq (maxamp ind 1) (* 2 m1)))
		  (snd-display #__line__ ";mix twice syncd: 0: ~A -> ~A, m1: ~A -> ~A, len: ~A -> ~A"
			       m0 (maxamp ind 0) m1 (maxamp ind 1) len (frames ind 0)))
	      (reset-hook! mix-release-hook)
	      (close-sound ind)))
	  
	  (let ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "mix tests")))
	    (insert-silence 0 20 ind)
	    (let ((indout (new-sound "test.snd" mus-next mus-bshort 22050 1 "mix tests")))
	      (insert-silence 0 10 indout)
	      (set! (sample 2 indout 0) .5)
	      (set! (sample 5 indout 0) .25)
	      (save-sound indout)
	      (close-sound indout))
	    (let ((tag (car (mix "test.snd"))))
	      (let ((samps (channel->vct 0 20))
		    (v (make-vct 20 0.0)))
		(vct-set! v 2 .5)
		(vct-set! v 5 .25)
		(if (not (vequal samps v))
		    (snd-display #__line__ ";mix 1->1: ~A ~A" samps v)))
	      (if (not (mix? tag)) (snd-display #__line__ ";mix 1->1 tag: ~A" tag))
	      (undo))
	    (let ((tag (car (mix "test.snd" 5))))
	      (let ((samps (channel->vct 0 20))
		    (v (make-vct 20 0.0)))
		(vct-set! v 7 .5)
		(vct-set! v 10 .25)
		(if (not (vequal samps v))
		    (snd-display #__line__ ";mix 1->1 at 5: ~A ~A" samps v)))
	      (if (not (mix? tag)) (snd-display #__line__ ";mix 1->1 at 5 tag: ~A" tag))
	      (undo))
	    (let ((tag (mix "test.snd" 0 0 ind 0 #f)))
	      (let ((samps (channel->vct 0 20))
		    (v (make-vct 20 0.0)))
		(vct-set! v 2 .5)
		(vct-set! v 5 .25)
		(if (not (vequal samps v))
		    (snd-display #__line__ ";mix 1->1 at 0 #f: ~A ~A" samps v)))
	      (if (mix? tag) (snd-display #__line__ ";mix 1->1 at 5 #f tag: ~A" tag))
	      (undo))
	    (let ((indout (new-sound "test.snd" mus-next mus-bshort 22050 2 "mix tests")))
	      (insert-silence 0 10 indout 0)
	      (insert-silence 0 10 indout 1)
	      (set! (sample 2 indout 0) .5)
	      (set! (sample 5 indout 0) .25)
	      (set! (sample 2 indout 1) .95)
	      (set! (sample 5 indout 1) .125)
	      (save-sound indout)
	      (close-sound indout))
	    (let ((tag (car (mix "test.snd" 0 1))))
	      (let ((samps (channel->vct 0 20))
		    (v (make-vct 20 0.0)))
		(vct-set! v 2 .95)
		(vct-set! v 5 .125)
		(if (not (vequal samps v))
		    (snd-display #__line__ ";mix 2->1: ~A ~A" samps v)))
	      (if (not (mix? tag)) (snd-display #__line__ ";mix 2->1 tag: ~A" tag))
	      (undo))
	    (let ((tag (car (mix "test.snd" 5 1))))
	      (let ((samps (channel->vct 0 20))
		    (v (make-vct 20 0.0)))
		(vct-set! v 7 .95)
		(vct-set! v 10 .125)
		(if (not (vequal samps v))
		    (snd-display #__line__ ";mix 2->1 at 5: ~A ~A" samps v)))
	      (if (not (mix? tag)) (snd-display #__line__ ";mix 2->1 at 5 tag: ~A" tag))
	      (undo))
	    (close-sound ind)
	    (set! ind (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "mix tests"))
	    (insert-silence 0 20 ind 0)
	    (insert-silence 0 20 ind 1)
	    (let ((tag (car (mix "test.snd" 0 #t))))
	      (let ((samps0 (channel->vct 0 20 ind 0))
		    (samps1 (channel->vct 0 20 ind 1))
		    (v (make-vct 20 0.0)))
		(vct-set! v 2 .95) 
		(vct-set! v 5 .125)
		(if (not (vequal samps1 v))
		    (snd-display #__line__ ";mix 1->1 (2): ~A ~A" samps1 v))
		(vct-set! v 2 .5)
		(vct-set! v 5 .25)
		(if (not (vequal samps0 v))
		    (snd-display #__line__ ";mix 1->1 (3): ~A ~A" samps0 v)))
	      (if (not (mix? tag)) (snd-display #__line__ ";mix 1->1 tag: ~A" tag))
	      (undo 1 ind 0)
	      (undo 1 ind 1))
	    (let ((tag (mix "test.snd" 0 1 ind 1 #f))) ; samp:0, in-chan: 1
	      (let ((samps0 (channel->vct 0 20 ind 0))
		    (samps1 (channel->vct 0 20 ind 1))
		    (v (make-vct 20 0.0)))
		(if (not (vequal samps0 v))
		    (snd-display #__line__ ";mix 1->1 (4): ~A ~A" samps0 v))
		(vct-set! v 2 .95)
		(vct-set! v 5 .125)
		(if (not (vequal samps1 v))
		    (snd-display #__line__ ";mix 1->1 (5): ~A ~A" samps1 v)))
	      (if (mix? tag) (snd-display #__line__ ";mix 1->1 tag (5): ~A" tag))
	      (undo 1 ind 1))
	    (set! (sync ind) 1)
	    (let ((tag (car (mix "test.snd" 0 #t))))
	      (let ((samps0 (channel->vct 0 20 ind 0))
		    (samps1 (channel->vct 0 20 ind 1))
		    (v (make-vct 20 0.0)))
		(vct-set! v 2 .5)
		(vct-set! v 5 .25)
		(if (not (vequal samps0 v))
		    (snd-display #__line__ ";mix 1->1 (6): ~A ~A" samps0 v))
		(vct-set! v 2 .95)
		(vct-set! v 5 .125)
		(if (not (vequal samps1 v))
		    (snd-display #__line__ ";mix 1->1 (7): ~A ~A" samps1 v)))
	      (undo))
	    (set! (cursor ind) 5)
	    (let ((tag (car (mix "test.snd" (cursor) #t))))
	      (let ((samps0 (channel->vct 0 20 ind 0))
		    (samps1 (channel->vct 0 20 ind 1))
		    (v (make-vct 20 0.0)))
		(vct-set! v 7 .5)
		(vct-set! v 10 .25)
		(if (not (vequal samps0 v))
		    (snd-display #__line__ ";mix 1->1 (8): ~A ~A" samps0 v))
		(vct-set! v 7 .95)
		(vct-set! v 10 .125)
		(if (not (vequal samps1 v))
		    (snd-display #__line__ ";mix 1->1 (9): ~A ~A" samps1 v)))
	      (undo))
	    (close-sound ind))
	  (delete-file "test.snd")
	  (delete-file "fmv.snd")
	  
	  ;; check ripple_mixes
	  (let* ((ind (open-sound "oboe.snd"))
		 (data (channel->vct 100 100))
		 (m1 (mix-vct data 321 ind 0 #t))
		 (m2 (mix-vct data 123 ind 0 #t)))
	    (set! (mix-position m1) 500)
	    (if (not (= (mix-position m1) 500)) (snd-display #__line__ ";mix-position m1[0]: ~A" (mix-position m1)))
	    (if (not (= (mix-position m2) 123)) (snd-display #__line__ ";mix-position m2[0]: ~A" (mix-position m2)))
	    (undo)
	    (set! (mix-position m2) 500)
	    (if (not (= (mix-position m2) 500)) (snd-display #__line__ ";mix-position m2[1]: ~A" (mix-position m2)))
	    (if (not (= (mix-position m1) 321)) (snd-display #__line__ ";mix-position m1[1]: ~A" (mix-position m1)))
	    (undo)
	    (insert-silence 0 100)
	    (if (not (= (mix-position m1) (+ 100 321))) (snd-display #__line__ ";mix-position m1[2]: ~A" (mix-position m1)))
	    (if (not (= (mix-position m2) (+ 100 123))) (snd-display #__line__ ";mix-position m2[2]: ~A" (mix-position m2)))
	    (delete-samples 0 50)
	    (if (not (= (mix-position m1) (+ 50 321))) (snd-display #__line__ ";mix-position m1[3]: ~A" (mix-position m1)))
	    (if (not (= (mix-position m2) (+ 50 123))) (snd-display #__line__ ";mix-position m2[3]: ~A" (mix-position m2)))
	    (undo 2)
	    (set! (mix-position m2) 500)
	    (undo)
	    (scale-channel 0.5 1000 100)
	    (if (not (= (mix-position m2) 123)) (snd-display #__line__ ";mix-position m2[5]: ~A" (mix-position m2)))
	    (if (not (= (mix-position m1) 321)) (snd-display #__line__ ";mix-position m1[5]: ~A" (mix-position m1)))
	    (undo)
	    (set! (mix-position m2) 500)
	    (undo)
	    (ptree-channel (lambda (y) (* y 0.5)) 2000 100)
	    (if (not (= (mix-position m2) 123)) (snd-display #__line__ ";mix-position m2[6]: ~A" (mix-position m2)))
	    (if (not (= (mix-position m1) 321)) (snd-display #__line__ ";mix-position m1[6]: ~A" (mix-position m1)))
	    (undo)
	    (set! (mix-position m2) 500)
	    (undo-edit)
	    (ramp-channel 0.0 1.0 3000 100)
	    (catch #t
		   (lambda ()
		     (if (not (= (mix-position m2) 123)) (snd-display #__line__ ";mix-position m2[7]: ~A" (mix-position m2)))
		     (if (not (= (mix-position m1) 321)) (snd-display #__line__ ";mix-position m1[7]: ~A" (mix-position m1))))
		   (lambda args (snd-display #__line__ ";mix-position trouble: ~A" args)))
	    (undo)
	    (delay-channel-mixes 200 100 ind 0)
	    (if (not (= (mix-position m2) 123)) (snd-display #__line__ ";delay-channel mixes mix-position m2: ~A" (mix-position m2)))
	    (if (not (= (mix-position m1) 421)) (snd-display #__line__ ";delay-channel-mixes mix-position m1: ~A" (mix-position m1)))
	    (check-mix-tags ind 0)
	    (close-sound ind))
	  
	  ;; check that current console is correct
	  (let ((ind (open-sound "storm.snd")))
	    (set! (x-bounds) (list 0 80.0))
	    (make-selection 1000000 1050000)
	    (let ((m1 (car (mix-selection 900000)))
		  (m2 (car (mix-selection 400000))))
	      (as-one-edit (lambda () 
			     (set! (mix-position m1) 0) 
			     (set! (mix-position m2) 1)))
	      (if (or (not (= (mix-position m1) 0))
		      (not (= (mix-position m2) 1)))
		  (snd-display #__line__ ";as-one-edit positions: ~A ~A" (mix-position m1) (mix-position m2)))
	      (undo-channel)
	      (if (or (not (= (mix-position m1) 900000))
		      (not (= (mix-position m2) 400000)))
		  (snd-display #__line__ ";as-one-edit positions after undo: (~A): ~A (~A): ~A" m1 (mix-position m1) m2 (mix-position m2)))
	      (redo-channel)
	      (if (or (not (= (mix-position m1) 0))
		      (not (= (mix-position m2) 1)))
		  (snd-display #__line__ ";as-one-edit positions after redo: ~A ~A" (mix-position m1) (mix-position m2)))
	      (close-sound ind)))
	  
	  (let ((ind (open-sound "2.snd")))
	    (make-selection 0 10000 ind)
	    (if (not (= (selection-chans) 2))
		(snd-display #__line__ ";stereo selection: ~A" (selection-chans)))
	    (set! (sync ind) #t)
	    (let ((md (car (mix-selection 500 ind))))
	      (if (not (mix? (integer->mix (+ 1 (mix->integer md)))))
		  (snd-display #__line__ ";where is 2nd mix? ~A ~A" md (mixes)))
	      (if (not (= (edit-position ind 0) 1))
		  (snd-display #__line__ ";edit-position 0 after stereo mix selection: ~A" (edit-position ind 0)))
	      (if (not (= (edit-position ind 1) 1))
		  (snd-display #__line__ ";edit-position 1 after stereo mix selection: ~A" (edit-position ind 1)))
	      (set! (sync ind) #f)
	      (undo-edit 1 ind 0)
	      (delete-sample 25 ind 0)
	      (set! (mix-position (integer->mix (+ 1 (mix->integer md)))) 750)
	      (if (not (= (edit-position ind 1) 2))
		  (snd-display #__line__ ";edit-position 1 after stereo mix selection moved: ~A" (edit-position ind 2)))
	      (revert-sound ind)
	      (close-sound ind)))
	  
	  (let ((ind (new-sound "test.snd"))
		(v (make-vct 20)))
	    (do ((i 0 (+ 1 i))) ((= i 20)) (vct-set! v i (* i .01)))
	    (vct->channel v)
	    (do ((i 0 (+ 1 i))) ((= i 20)) (vct-set! v i (* i -.01)))
	    (let ((mx (mix-vct v 10)))
	      (let ((hi (make-mix-sampler mx))
		    (ho (make-mix-sampler mx 5))
		    (happy #t))
		(do ((i 0 (+ 1 i)))
		    ((or (not happy) (= i 10)))
		  (let ((ho-val (ho))
			(hi-val (hi)))
		    (if (fneq hi-val (* i -.01))
			(begin
			  (snd-display #__line__ ";mix-reader at ~A from 0: ~A" i hi-val)
			  (set! happy #f)))
		    (if (fneq ho-val (* (+ i 5) -.01))
			(begin
			  (snd-display #__line__ ";mix-reader at ~A from 5: ~A" i ho-val)
			  (set! happy #f)))))))
	    (revert-sound ind)
	    (set! v (make-vct 21))
	    (vct-fill! v 0.5)
	    (vct->channel v)
	    (let ((mx (mix-vct v 10)))
	      (set! (mix-amp-env mx) '(0 0 1 1))
	      (let ((hi (make-mix-sampler mx 0))
		    (ho (make-mix-sampler mx 10))
		    (happy #t))
		(do ((i 0 (+ 1 i)))
		    ((or (not happy) (= i 10)))
		  (let ((ho-val (ho))
			(hi-val (hi)))
		    (if (fneq hi-val (* i .025))
			(begin
			  (snd-display #__line__ ";mix-reader env'd at ~A from 0: ~A" i hi-val)
			  (set! happy #f)))
		    (if (fneq ho-val (* (+ i 10) .025))
			(begin
			  (snd-display #__line__ ";mix-reader env'd at ~A from 10: ~A" i ho-val)
			  (set! happy #f)))))))
	    (close-sound ind))
	  
	  (let* ((ind (open-sound "oboe.snd"))
		 (id (mix-vct (make-vct 10 .1))))
	    (set! (mix-position id) 100)
	    (if (or (not (= (mix-position id) 100))
		    (not (= (edit-position ind 0) 2)))
		(snd-display #__line__ ";mix-position init: ~A ~A" (mix-position id) (edit-position ind 0)))
	    (set! (mix-position id) 100)
	    (if (or (not (= (mix-position id) (mix-position id)))
		    (not (= (edit-position ind 0) 2)))
		(snd-display #__line__ ";mix-position 2 (no-op): ~A ~A" (mix-position id) (edit-position ind 0)))
	    (set! (mix-amp id) 1.0)
	    (if (or (fneq (mix-amp id) 1.0)
		    (not (= (edit-position ind 0) 2)))
		(snd-display #__line__ ";mix-amp no-op: ~A ~A" (mix-amp id) (edit-position ind 0)))
	    (set! (mix-amp id) 0.5)
	    (if (or (fneq (mix-amp id) 0.5)
		    (not (= (edit-position ind 0) 3)))
		(snd-display #__line__ ";mix-amp .5: ~A ~A" (mix-amp id) (edit-position ind 0)))
	    (set! (mix-amp id) (mix-amp id))
	    (if (or (fneq (mix-amp id) 0.5)
		    (not (= (edit-position ind 0) 3)))
		(snd-display #__line__ ";mix-amp no-op: ~A ~A" (mix-amp id) (edit-position ind 0)))
	    (set! (mix-speed id) 1.0)
	    (if (or (fneq (mix-speed id) 1.0)
		    (not (= (edit-position ind 0) 3)))
		(snd-display #__line__ ";mix-speed no-op: ~A ~A" (mix-speed id) (edit-position ind 0)))
	    (set! (mix-speed id) .5)
	    (if (or (fneq (mix-speed id) 0.5)
		    (not (= (edit-position ind 0) 4)))
		(snd-display #__line__ ";mix-speed .5: ~A ~A" (mix-speed id) (edit-position ind 0)))
	    (set! (mix-speed id) (mix-speed id))
	    (if (or (fneq (mix-speed id) 0.5)
		    (not (= (edit-position ind 0) 4)))
		(snd-display #__line__ ";mix-speed 2 no-op: ~A ~A" (mix-speed id) (edit-position ind 0)))
	    (set! (mix-amp-env id) '(0 0 1 1))
	    (if (not (= (edit-position ind 0) 5))
		(snd-display #__line__ ";mix-amp-env init: ~A ~A" (mix-amp-env id) (edit-position ind 0)))
	    (set! (mix-amp-env id) '(0 0 1 1))
	    (if (not (= (edit-position ind 0) 5))
		(snd-display #__line__ ";mix-amp-env no-op: ~A ~A" (mix-amp-env id) (edit-position ind 0)))
	    (close-sound ind))
	  
	  (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "color-mix tests" 300))
		(old-color (mix-color)))
	    (set! (mix-color) (make-color-with-catch 1 1 0))
	    (let ((mix1 (mix-vct (make-vct 10 .5) 10)))
	      (if (or (not (equal? (color->list (mix-color)) (list 1.0 1.0 0.0)))
		      (not (equal? (color->list (mix-color mix1)) (list 1.0 1.0 0.0))))
		  (snd-display #__line__ ";set mix-color: ~A ~A ~A ~A" 
			       (color->list (mix-color)) (color->list (mix-color mix1)) (list 1.0 1.0 0.0) (color->list old-color)))
	      (set! (mix-color) old-color)
	      (save-mix mix1 "test1.snd")
	      (let ((ind1 (open-sound "test1.snd")))
		(if (not (= (frames ind1) (mix-length mix1))) (snd-display #__line__ ";save-mix frames: ~A ~A" (mix-length mix1) (frames ind1)))
		(if (not (vequal (channel->vct 0 10) (mix->vct mix1)))
		    (snd-display #__line__ ";save-mix data: ~A ~A" (mix->vct mix1) (channel->vct 0 10 ind1)))
		(close-sound ind1)
		(if (file-exists? "test1.snd") (delete-file "test1.snd"))))
	    (close-sound ind))
	  
	  (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "lock mix tests" 300))
		 (mix1 (mix-vct (make-vct 10 .5) 10)))
	    (set! (mix-amp mix1) 0.0)
	    (if (fneq (maxamp ind 0) 0.0) (snd-display #__line__ ";delete-mix maxamp: ~A" (maxamp ind 0)))
	    (undo-channel 1 ind 0)
	    (if (fneq (maxamp ind 0) 0.5) (snd-display #__line__ ";undelete-mix maxamp: ~A" (maxamp ind 0)))
	    (redo-channel 1 ind 0)
	    (if (fneq (maxamp ind 0) 0.0) (snd-display #__line__ ";redelete-mix maxamp: ~A" (maxamp ind 0)))
	    (undo 2)
					;	  (if (mix? mix1) (snd-display #__line__ ";undo 2 kept mix?"))
	    (if (fneq (maxamp ind 0) 0.0) (snd-display #__line__ ";no delete-mix maxamp: ~A" (maxamp ind 0)))
	    (redo)
	    (if (fneq (maxamp ind 0) 0.5) (snd-display #__line__ ";reundelete-mix maxamp: ~A" (maxamp ind 0)))
	    (close-sound ind))
	  
	  (let ((ind (new-sound "test.snd" :size 100)))
	    (let ((id (mix-vct (make-vct 5 .5) 11)))
	      
	      ;; pad-channel
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11: ~A" (channel->vct 10 10)))
	      (pad-channel 0 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";pad locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 21))
		  (snd-display #__line__ ";vct .5 at 21 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 20 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 21: ~A" (channel->vct 20 10)))
	      (if (not (vequal (channel->vct 10 10) (make-vct 10 0.0)))
		  (snd-display #__line__ ";vct .5 at 21 at 10: ~A" (channel->vct 10 10)))
	      (pad-channel 30 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";pad 30 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 21))
		  (snd-display #__line__ ";vct .5 at 21 position 30: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 20 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 21 30: ~A" (channel->vct 20 10)))
	      (pad-channel 150 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";pad 150 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 21))
		  (snd-display #__line__ ";vct .5 at 21 position 150: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 20 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 21 150: ~A" (channel->vct 20 10)))
	      (pad-channel 20 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";pad 20 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 31))
		  (snd-display #__line__ ";vct .5 at 31 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 30 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 31: ~A" (channel->vct 30 10)))
	      (pad-channel 32 3)
					;	    (if (mix? id) (snd-display #__line__ ";pad within mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";pad within mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 30 10) (vct 0 .5 0 0 0 .5 .5 .5 .5 0)))
		  (snd-display #__line__ ";vct .5 at 31 pad at 32: ~A" (channel->vct 30 10)))
	      
	      (set! (edit-position) 1)
	      (if (not (mix? id)) (snd-display #__line__ ";mix vct after reset edit position: ~A" (mix? id)))
	      (if (not (= (mix-position id) 11)) (snd-display #__line__ ";mix vct position after reset edit position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 after reset edit: ~A" (channel->vct 10 10)))
	      
	      ;; delete
	      (delete-samples 0 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";delete locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 1))
		  (snd-display #__line__ ";vct .5 at 1 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 0 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 1: ~A" (channel->vct 0 10)))
	      (delete-samples 30 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";delete 30 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 1))
		  (snd-display #__line__ ";vct .5 at 1 position del 30: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 0 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 1 del 30: ~A" (channel->vct 0 10)))
	      (delete-samples 3 3)
					;	    (if (mix? id) (snd-display #__line__ ";delete within mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";delete within mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 0 10) (vct 0 .5 .5 0 0 0 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 1 del at 3: ~A" (channel->vct 0 10)))
	      
	      (set! (edit-position) 1)
	      (if (not (mix? id)) (snd-display #__line__ ";mix vct after del reset edit position: ~A" (mix? id)))
	      (if (not (= (mix-position id) 11)) (snd-display #__line__ ";mix vct position after del reset edit position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 after del reset edit: ~A" (channel->vct 10 10)))
	      
	      ;; change
	      (set! (samples 0 5) (make-vct 5 .6))
	      (if (not (mix? id))
		  (snd-display #__line__ ";set locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 set position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 set: ~A" (channel->vct 10 10)))
	      (set! (samples 20 5) (make-vct 5 .7))
	      (if (not (mix? id))
		  (snd-display #__line__ ";set 20 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 set 20 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 set 20: ~A" (channel->vct 10 10)))
	      (set! (samples 12 2) (vct -.5 .8))
					;	    (if (mix? id) (snd-display #__line__ ";set within mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";set within mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 -.5 .8 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 set at 12: ~A" (channel->vct 10 10)))
	      
	      (set! (edit-position) 1)
	      (if (not (mix? id)) (snd-display #__line__ ";mix vct after set reset edit position: ~A" (mix? id)))
	      (if (not (= (mix-position id) 11)) (snd-display #__line__ ";mix vct position after set reset edit position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 after set reset edit: ~A" (channel->vct 10 10)))
	      
	      ;; scale
	      (scale-channel 2.0)
	      (if (not (mix? id))
		  (snd-display #__line__ ";scale locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 scale position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 1 1 1 1 1 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 scale: ~A" (channel->vct 10 10)))
	      (scale-channel 0.5)
	      (if (not (mix? id))
		  (snd-display #__line__ ";unscale locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 unscale position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 unscale: ~A" (channel->vct 10 10)))
	      (scale-channel -1.0 0 5)
	      (if (not (mix? id))
		  (snd-display #__line__ ";scale at 0 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 scale at 0 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 scale at 0: ~A" (channel->vct 10 10)))
	      (scale-channel -1.0 22 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";scale at 22 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 scale at 22 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 scale at 22: ~A" (channel->vct 10 10)))
	      (scale-channel 2.0 12 2)
					;	    (if (mix? id) (snd-display #__line__ ";scale within mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";scale within mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 1 1 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 scale at 12: ~A" (channel->vct 10 10)))
	      
	      (set! (edit-position) 1)
	      (if (not (mix? id)) (snd-display #__line__ ";mix vct after scale reset edit position: ~A" (mix? id)))
	      (if (not (= (mix-position id) 11)) (snd-display #__line__ ";mix vct position after scale reset edit position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 after scale reset edit: ~A" (channel->vct 10 10)))
	      
	      ;; envelopes
	      (env-channel '(0 0 1 1) 0 8)
	      (if (not (mix? id))
		  (snd-display #__line__ ";env locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 env position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 env: ~A" (channel->vct 10 10)))
	      (env-channel '(0 0 1 1) 17 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";env 17 locked mix? ~A" (mix? id)))
	      (if (not (= (mix-position id) 11))
		  (snd-display #__line__ ";vct .5 at 11 env 17 position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 env 17: ~A" (channel->vct 10 10)))
	      (env-channel '(0 0 1 1))
					;	    (if (mix? id) (snd-display #__line__ ";env over mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";env over mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0.000 0.056 0.061 0.066 0.071 0.076 0.000 0.000 0.000 0.000)))
		  (snd-display #__line__ ";vct .5 at 11 over env: ~A" (channel->vct 10 10)))
	      
	      (set! (edit-position) 1)
					;	    (if (not (mix? id)) (snd-display #__line__ ";mix vct after env reset edit position: ~A" (mix? id)))
	      (if (not (= (mix-position id) 11)) (snd-display #__line__ ";mix vct position after env reset edit position: ~A" (mix-position id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 .5 .5 .5 .5 .5 0 0 0 0)))
		  (snd-display #__line__ ";vct .5 at 11 after env reset edit: ~A" (channel->vct 10 10)))
	      
	      (ptree-channel (lambda (y) (* y 2)))
					;	    (if (mix? id) (snd-display #__line__ ";ptree over mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";ptree over mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 1 1 1 1 1 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 after ptree: ~A" (channel->vct 10 10)))
	      (undo)
	      (scale-by 0.0)
					;	    (if (mix? id) (snd-display #__line__ ";zero mix but exists?: ~A" (mix? id)))
	      (if (not (mix? id)) (snd-display #__line__ ";zero mix but no mix?: ~A" (mix? id)))
	      (if (not (vequal (channel->vct 10 10) (vct 0 0 0 0 0 0 0 0 0 0)))
		  (snd-display #__line__ ";vct 1 at 11 scale 0: ~A" (channel->vct 10 10)))
	      (undo 2)
	      
	      (let ((ids '()))
		(do ((i 0 (+ 1 i)))
		    ((= i 5))
		  (set! ids (cons (mix-vct (make-vct 5 .1) (+ i 10)) ids)))
		(let ((vals (channel->vct 8 14)))
		  (if (not (vequal vals (vct 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000 0.000 0.000)))
		      (snd-display #__line__ ";pile up mixes: ~A" vals)))
		(let ((mx (mixes-maxamp ids)))
		  (if (fneq mx .1)
		      (snd-display #__line__ ";mixes-maxamp: ~A" mx)))
		(let ((len (mixes-length ids)))
		  (if (not (= len 10))
		      (snd-display #__line__ ";mixes-length: ~A" len)))
		(sync-all-mixes 21)
		(for-each (lambda (m) (if (not (= (mix-sync m) 21)) (snd-display #__line__ ";sync-all-mixes ~A: ~A" m (mix-sync m)))) ids)
		(sync-all-mixes 0)
		(for-each (lambda (m) (if (not (= (mix-sync m) 0)) (snd-display #__line__ ";re sync-all-mixes ~A: ~A" m (mix-sync m)))) ids)
		(scale-mixes ids -2.0)
		(for-each (lambda (m) (if (fneq (mix-amp m) -2.0) (snd-display #__line__ ";scale-mixes ~A: ~A" m (mix-amp m)))) ids)
		(let ((vals (channel->vct 8 14)))
		  (if (not (vequal vals (vct 0.000 0.000 -0.200 -0.400 -0.600 -0.800 -1.000 -0.800 -0.600 -0.400 -0.200 0.000 0.000 0.000)))
		      (snd-display #__line__ ";scale piled up mixes: ~A" vals)))
		(silence-mixes ids)
		(let ((vals (channel->vct 8 14)))
		  (if (not (vequal vals (make-vct 14 0.0)))
		      (snd-display #__line__ ";silence piled up mixes: ~A" vals)))
		(undo 2)
		(let ((vals (channel->vct 8 14)))
		  (if (not (vequal vals (vct 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000 0.000 0.000)))
		      (snd-display #__line__ ";undo 2 to pile up mixes: ~A" vals)))
		(play-mixes ids)
		(set-mixes-tag-y ids 100)
		(for-each (lambda (m) (if (not (= (mix-tag-y m) 100)) (snd-display #__line__ ";set-mixes-tag-y ~A: ~A" m (mix-tag-y m)))) ids)
		(set-mixes-tag-y ids 0)
		(move-mixes ids 10)
		(let ((vals (channel->vct 18 14)))
		  (if (not (vequal vals (vct 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000 0.000 0.000)))
		      (snd-display #__line__ ";move piled up mixes: ~A" vals)))
		(let ((vals (channel->vct 8 8)))
		  (if (not (vequal vals (make-vct 8 0.0)))
		      (snd-display #__line__ ";move piled up mixes original: ~A" vals)))
		(move-mixes ids -10)
		(let ((vals (channel->vct 8 14)))
		  (if (not (vequal vals (vct 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000 0.000 0.000)))
		      (snd-display #__line__ ";move piled up mixes -10: ~A" vals)))
		(let ((vals (channel->vct 23 8)))
		  (if (not (vequal vals (make-vct 8 0.0)))
		      (snd-display #__line__ ";move piled up mixes -10: ~A" vals)))
		(for-each (lambda (m) (set! (mix-sync m) 24)) ids)
		(let ((mxs (syncd-mixes 24)))
		  (if (not (= (length mxs) (length ids)))
		      (snd-display #__line__ ";syncd-mixes: ~A ~A" mxs ids))
		  (for-each (lambda (m) (if (not (member m ids)) (snd-display #__line__ ";syncd-mixes: ~A not in ~A" m ids))) mxs))
		(sync-all-mixes 0)
		(save-mixes ids "fmv.snd")
		(let ((ind1 (open-sound "fmv.snd")))
		  (let ((data (channel->vct 0 #f ind1)))
		    (if (not (vequal data (vct 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.0)))
			(snd-display #__line__ ";save-mixes: ~A" data)))
		  (close-sound ind1)
		  (mus-sound-forget "fmv.snd")
		  (delete-file "fmv.snd"))
		(env-mixes ids '(0 0 1 1 2 0))
		(let ((vals (channel->vct 10 10)))
		  (if (not (vequal vals (vct 0.000 0.045 0.137 0.278 0.460 0.360 0.203 0.087 0.020 0.000)))
		      (snd-display #__line__ ";env-mixes: ~A" vals)))
		(undo 3)
		(let ((vals (channel->vct 8 14)))
		  (if (not (vequal vals (vct 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000 0.000 0.000)))
		      (snd-display #__line__ ";undo 3 mixes envd: ~A" vals)))
		(color-mixes ids (make-color 0 1 0))
		(scale-tempo ids 2.0)
		(let ((begs (map mix-position ids)))
		  (if (not (equal? begs (list 18 16 14 12 10)))
		      (snd-display #__line__ ";scale-tempo by 2: ~A" begs)))
		(let ((vals (channel->vct 10 15)))
		  (if (not (vequal vals (vct 0.100 0.100 0.200 0.200 0.300 0.200 0.300 0.200 0.300 0.200 0.200 0.100 0.100 0.000 0.000)))
		      (snd-display #__line__ ";scale-tempo 2 vals: ~A" vals)))
		(scale-tempo ids 0.5)
		(let ((begs (map mix-position ids)))
		  (if (not (equal? begs (list 14 13 12 11 10)))
		      (snd-display #__line__ ";scale-tempo by 0.5: ~A" begs)))
		(let ((vals (channel->vct 10 10)))
		  (if (not (vequal vals (vct 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000)))
		      (snd-display #__line__ ";scale-tempo back 0.5: ~A" vals)))
		(scale-tempo ids -1.0)
		(let ((begs (map mix-position ids)))
		  (if (not (equal? begs (list 6 7 8 9 10)))
		      (snd-display #__line__ ";scale-tempo by -1: ~A" begs)))
		(let ((vals (channel->vct 0 15)))
		  (if (not (vequal vals (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100)))
		      (snd-display #__line__ ";scale-tempo -1 vals: ~A" vals)))
		(undo 3)
		(set! (sinc-width) 10)
		(src-mixes ids 0.5)
		(if (fneq (mix-speed (car ids)) 0.5)
		    (snd-display #__line__ ";src-mixes speed: ~A" (mix-speed (car ids))))
		(if (not (= (mixes-length ids) 15))
		    (snd-display #__line__ ";src-mixes length: ~A" (mixes-length ids)))
		(let ((vals (channel->vct 10 15)))
		  (if (not (vequal vals (vct 0.100 0.211 0.311 0.408 0.508 0.505 0.495 0.505 0.508 0.460 0.362 0.262 0.152 0.052 0.000)))
		      (snd-display #__line__ ";src-mixes 0.5 vals: ~A" vals)))
		(if (not (vequal (mix->vct (car ids)) (mix->vct (cadr ids))))
		    (snd-display #__line__ ";src-mixes vals don't match: ~A ~A" (mix->vct (car ids)) (mix->vct (cadr ids))))
		(undo)
		(transpose-mixes ids -12)
		(if (fneq (mix-speed (car ids)) 0.5)
		    (snd-display #__line__ ";transpose-mixes speed: ~A" (mix-speed (car ids))))
		(if (not (= (mixes-length ids) 15))
		    (snd-display #__line__ ";transpose-mixes length: ~A" (mixes-length ids)))
		(let ((vals (channel->vct 10 15)))
		  (if (not (vequal vals (vct 0.100 0.211 0.311 0.408 0.508 0.505 0.495 0.505 0.508 0.460 0.362 0.262 0.152 0.052 0.000)))
		      (snd-display #__line__ ";transpose-mixes 0.5 vals: ~A" vals)))
		(if (not (vequal (mix->vct (car ids)) (mix->vct (cadr ids))))
		    (snd-display #__line__ ";transpose-mixes vals don't match: ~A ~A" (mix->vct (car ids)) (mix->vct (cadr ids))))
		(revert-sound))
	      (close-sound ind)))
	  
	  ;; check locks
	  (let ((ind (new-sound "test.snd" :size 100)))
	    (let ((id (mix-vct (vct .1 .2 .3) 50)))
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 0: ~A ~A" id (mix? id)))
	      (ptree-channel (lambda (y) .5) 0 20)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 1: ~A ~A" id (mix? id)))
	      (ptree-channel (lambda (y) .5) 0 20)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 2: ~A ~A" id (mix? id)))
	      (undo)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 3: ~A ~A" id (mix? id)))
	      (ptree-channel (lambda (y) .5) 25 20)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 4: ~A ~A" id (mix? id)))
	      (undo)
	      (ramp-channel 0.0 1.0 0 20)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 5: ~A ~A" id (mix? id)))
	      (undo)
	      (xramp-channel 0.0 1.0 32.0 0 20)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 6: ~A ~A" id (mix? id)))
	      (undo 2)
	      (delete-sample 52)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 7: ~A ~A" id (mix? id)))
	      (undo)
	      (delete-sample 10)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 8: ~A ~A" id (mix? id)))
	      (undo)
	      (insert-samples 51 2 (vct .1 .2))
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 9: ~A ~A" id (mix? id)))
	      (undo)
	      (insert-samples 1 2 (vct .1 .2))
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 10: ~A ~A" id (mix? id)))
	      (undo)
	      (set! (sample 51) 1.0)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 11: ~A ~A" id (mix? id)))
	      (undo)
	      (set! (sample 1) 1.0)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 12: ~A ~A" id (mix? id)))
	      (undo)
	      (xramp-channel 0 1 32 0 40)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 13: ~A ~A" id (mix? id)))
	      (xramp-channel 0 1 32 0 40)
	      (if (not (mix? id))
		  (snd-display #__line__ ";mix lock 14: ~A ~A" id (mix? id)))
	      (close-sound ind)))
	  
	  (do ((i 0 (+ 1 i)))
	      ((= i 2))
	    
	    (let ((ind (new-sound "test.snd" :size 100))
		  (tag (with-mix-tags)))
	      
	      ;; check various mix ops briefly
	      (map-channel (lambda (y) 1.0))
	      (env-channel '(0 0 1 1))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.485 0.495 0.605 0.715 0.825 0.535 0.545 0.556 0.566 0.576)))
		      (snd-display #__line__ ";mix on env: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on env: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 5)))
		    (snd-display #__line__ ";mix on env edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.485 0.495 0.605 0.715 0.825 0.535 0.545 0.556 0.566 0.576))))
		      (snd-display #__line__ ";read mix on env reversed: ~A" data)))
		(undo))
	      
	      (env-channel '(0 0 1 1))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.235 0.245 0.355 0.465 0.576 0.287 0.298 0.309 0.320 0.331)))
		      (snd-display #__line__ ";mix on env 1: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on env 1: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 7)))
		    (snd-display #__line__ ";mix on env1 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.235 0.245 0.355 0.465 0.576 0.287 0.298 0.309 0.320 0.331))))
		      (snd-display #__line__ ";read mix on env1 reversed: ~A" data)))
		(undo))
	      
	      (env-channel '(0 0 1 1))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.114 0.121 0.229 0.337 0.445 0.153 0.162 0.171 0.181 0.191)))
		      (snd-display #__line__ ";mix on env 2: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on env 2: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 11)))
		    (snd-display #__line__ ";mix on env2 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.114 0.121 0.229 0.337 0.445 0.153 0.162 0.171 0.181 0.191))))
		      (snd-display #__line__ ";read mix on env2 reversed: ~A" data)))
		(undo))
	      
	      (env-channel '(0 0 1 1))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.055 0.060 0.165 0.270 0.376 0.082 0.089 0.095 0.102 0.110)))
		      (snd-display #__line__ ";mix on env 3: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on env 3: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 11)))
		    (snd-display #__line__ ";mix on env3 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.055 0.060 0.165 0.270 0.376 0.082 0.089 0.095 0.102 0.110))))
		      (snd-display #__line__ ";read mix on env3 reversed: ~A" data)))
		(undo))
	      
	      (env-channel '(0 0 1 1))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.027 0.030 0.133 0.236 0.340 0.044 0.048 0.053 0.058 0.063)))
		      (snd-display #__line__ ";mix on env 4: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on env 4: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 11)))
		    (snd-display #__line__ ";mix on env4 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.027 0.030 0.133 0.236 0.340 0.044 0.048 0.053 0.058 0.063))))
		      (snd-display #__line__ ";read mix on env4 reversed: ~A" data)))
		(undo))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.160 0.153 0.247 0.341 0.435 0.129 0.124 0.118 0.113 0.108)))
		      (snd-display #__line__ ";mix on xramp: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 9)))
		    (snd-display #__line__ ";mix on xramp edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.160 0.153 0.247 0.341 0.435 0.129 0.124 0.118 0.113 0.108))))
		      (snd-display #__line__ ";read mix on xramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (xramp-channel 1 0 32.0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.026 0.024 0.122 0.220 0.318 0.017 0.015 0.014 0.013 0.012)))
		      (snd-display #__line__ ";mix on xramp2: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp2: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 13)))
		    (snd-display #__line__ ";mix on xramp2 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.026 0.024 0.122 0.220 0.318 0.017 0.015 0.014 0.013 0.012))))
		      (snd-display #__line__ ";read mix on xramp2 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (xramp-channel 1 0 32.0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.013 0.012 0.111 0.210 0.309 0.008 0.007 0.006 0.006 0.005)))
		      (snd-display #__line__ ";mix on xramp2_ramp: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp2_ramp: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 15)))
		    (snd-display #__line__ ";mix on xramp2_ramp edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.013 0.012 0.111 0.210 0.309 0.008 0.007 0.006 0.006 0.005))))
		      (snd-display #__line__ ";read mix on xramp2_ramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (xramp-channel 1 0 32.0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.007 0.006 0.105 0.205 0.304 0.004 0.003 0.003 0.002 0.002)))
		      (snd-display #__line__ ";mix on xramp2_ramp2: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp2_ramp2: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 15)))
		    (snd-display #__line__ ";mix on xramp2_ramp2 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.007 0.006 0.105 0.205 0.304 0.004 0.003 0.003 0.002 0.002))))
		      (snd-display #__line__ ";read mix on xramp2_ramp2 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.082 0.077 0.173 0.268 0.364 0.060 0.056 0.053 0.049 0.046)))
		      (snd-display #__line__ ";mix on xramp_ramp: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp_ramp: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 15)))
		    (snd-display #__line__ ";mix on xramp_ramp edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.082 0.077 0.173 0.268 0.364 0.060 0.056 0.053 0.049 0.046))))
		      (snd-display #__line__ ";read mix on xramp_ramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.042 0.039 0.136 0.233 0.330 0.028 0.026 0.023 0.021 0.019)))
		      (snd-display #__line__ ";mix on xramp_ramp2: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp_ramp2: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 15)))
		    (snd-display #__line__ ";mix on xramp_ramp2 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.042 0.039 0.136 0.233 0.330 0.028 0.026 0.023 0.021 0.019))))
		      (snd-display #__line__ ";read mix on xramp_ramp2 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (xramp-channel 1 0 32.0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.022 0.020 0.118 0.216 0.314 0.013 0.012 0.010 0.009 0.008)))
		      (snd-display #__line__ ";mix on xramp_ramp3: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on xramp_ramp3: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 15)))
		    (snd-display #__line__ ";mix on xramp_ramp3 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.022 0.020 0.118 0.216 0.314 0.013 0.012 0.010 0.009 0.008))))
		      (snd-display #__line__ ";read mix on xramp_ramp3 reversed: ~A" data))))
	      
	      (set! (with-mix-tags) #t)
	      (set! (optimization) 6)
	      (set! (edit-position ind 0) 1)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.500 0.500 0.600 0.700 0.800 0.500 0.500 0.500 0.500 0.500)))
		      (snd-display #__line__ ";mix on ptree: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ptree: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 17)))
		    (snd-display #__line__ ";mix on ptree edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.500 0.500 0.600 0.700 0.800 0.500 0.500 0.500 0.500 0.500))))
		      (snd-display #__line__ ";read mix on ptree reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.258 0.253 0.347 0.442 0.537 0.232 0.227 0.222 0.217 0.212)))
		      (snd-display #__line__ ";mix on ptree_ramp: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ptree_ramp: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 21)))
		    (snd-display #__line__ ";mix on ptree_ramp edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.258 0.253 0.347 0.442 0.537 0.232 0.227 0.222 0.217 0.212))))
		      (snd-display #__line__ ";read mix on ptree_ramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090)))
		      (snd-display #__line__ ";mix on ptree_ramp2: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ptree_ramp2: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 21)))
		    (snd-display #__line__ ";mix on ptree_ramp2 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090))))
		      (snd-display #__line__ ";read mix on ptree_ramp2 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038)))
		      (snd-display #__line__ ";mix on ptree_ramp3: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ptree_ramp3: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 21)))
		    (snd-display #__line__ ";mix on ptree_ramp3 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038))))
		      (snd-display #__line__ ";read mix on ptree_ramp3 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016)))
		      (snd-display #__line__ ";mix on ptree_ramp4: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ptree_ramp4: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 21)))
		    (snd-display #__line__ ";mix on ptree_ramp4 edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016))))
		      (snd-display #__line__ ";read mix on ptree_ramp4 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 0)
	      (scale-by 0.0)
	      (ptree-channel (lambda (y) 1.0))
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 1.000 1.000 1.100 1.200 1.300 1.000 1.000 1.000 1.000 1.000)))
		      (snd-display #__line__ ";mix on ptree_zero: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ptree_zero: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 19)))
		    (snd-display #__line__ ";mix on ptree_zero edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 1.000 1.000 1.100 1.200 1.300 1.000 1.000 1.000 1.000 1.000))))
		      (snd-display #__line__ ";read mix on ptree_zero reversed: ~A" data))))
	      
	      (revert-sound)
	      (map-channel (lambda (y) 1.0))
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.258 0.253 0.347 0.442 0.537 0.232 0.227 0.222 0.217 0.212)))
		      (snd-display #__line__ ";mix on ramp_ptree: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp_ptree: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 27)))
		    (snd-display #__line__ ";mix on ramp_ptree edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.258 0.253 0.347 0.442 0.537 0.232 0.227 0.222 0.217 0.212))))
		      (snd-display #__line__ ";read mix on ramp_ptree reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090)))
		      (snd-display #__line__ ";mix on ramp2_ptree: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp2_ptree: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 27)))
		    (snd-display #__line__ ";mix on ramp2_ptree edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090))))
		      (snd-display #__line__ ";read mix on ramp2_ptree reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038)))
		      (snd-display #__line__ ";mix on ramp3_ptree: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp3_ptree: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 27)))
		    (snd-display #__line__ ";mix on ramp3_ptree edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038))))
		      (snd-display #__line__ ";read mix on ramp3_ptree reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016)))
		      (snd-display #__line__ ";mix on ramp4_ptree: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp4_ptree: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 27)))
		    (snd-display #__line__ ";mix on ramp4_ptree edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016))))
		      (snd-display #__line__ ";read mix on ramp4_ptree reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (scale-by 0.0)
	      (ptree-channel (lambda (y) 0.5))
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.258 0.253 0.347 0.442 0.537 0.232 0.227 0.222 0.217 0.212)))
		      (snd-display #__line__ ";mix on ramp_ptree_zero: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp_ptree_zero: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 29)))
		    (snd-display #__line__ ";mix on ramp_ptree_zero edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.258 0.253 0.347 0.442 0.537 0.232 0.227 0.222 0.217 0.212))))
		      (snd-display #__line__ ";read mix on ramp_ptree_zero reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (scale-by 0.0)
	      (ptree-channel (lambda (y) 0.5))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090)))
		      (snd-display #__line__ ";mix on ramp2_ptree_zero: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp2_ptree_zero: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 29)))
		    (snd-display #__line__ ";mix on ramp2_ptree_zero edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090))))
		      (snd-display #__line__ ";read mix on ramp2_ptree_zero reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (scale-by 0.0)
	      (ptree-channel (lambda (y) 0.5))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038)))
		      (snd-display #__line__ ";mix on ramp3_ptree_zero: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp3_ptree_zero: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 29)))
		    (snd-display #__line__ ";mix on ramp3_ptree_zero edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038))))
		      (snd-display #__line__ ";read mix on ramp3_ptree_zero reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (scale-by 0.0)
	      (ptree-channel (lambda (y) 0.5))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016)))
		      (snd-display #__line__ ";mix on ramp4_ptree_zero: ~A" vals)))
		(if (and tag (not (mix? id)))
		    (snd-display #__line__ ";mix on ramp4_ptree_zero: ~A ~A" id (mix? id)))
		(if (and tag (not (= (list-ref (cadr (edit-tree)) 7) 29)))
		    (snd-display #__line__ ";mix on ramp4_ptree_zero edit-tree: ~A" (list-ref (cadr (edit-tree)) 7)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016))))
		      (snd-display #__line__ ";read mix on ramp4_ptree_zero reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090)))
		      (snd-display #__line__ ";mix on ramp_ptree_ramp: ~A" vals)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.133 0.128 0.222 0.318 0.413 0.108 0.103 0.099 0.094 0.090))))
		      (snd-display #__line__ ";read mix on ramp_ptree_ramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038)))
		      (snd-display #__line__ ";mix on ramp_ptree_ramp2: ~A" vals)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038))))
		      (snd-display #__line__ ";read mix on ramp_ptree_ramp2 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016)))
		      (snd-display #__line__ ";mix on ramp_ptree_ramp3: ~A" vals)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016))))
		      (snd-display #__line__ ";read mix on ramp_ptree_ramp3 reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038)))
		      (snd-display #__line__ ";mix on ramp2_ptree_ramp: ~A" vals)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.068 0.064 0.161 0.257 0.354 0.050 0.047 0.044 0.041 0.038))))
		      (snd-display #__line__ ";read mix on ramp2_ptree_ramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016)))
		      (snd-display #__line__ ";mix on ramp3_ptree_ramp: ~A" vals)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016))))
		      (snd-display #__line__ ";read mix on ramp3_ptree_ramp reversed: ~A" data))))
	      
	      (set! (edit-position ind 0) 1)
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (ptree-channel (lambda (y) (* y 0.5)))
	      (ramp-channel 1 0)
	      (ramp-channel 1 0)
	      (let ((id (mix-vct (vct .1 .2 .3) 50)))
		(let ((vals (channel->vct 48 10)))
		  (if (not (vequal vals (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016)))
		      (snd-display #__line__ ";mix on ramp2_ptree_ramp2: ~A" vals)))
		(let ((data (make-vct 10))
		      (reader (make-sampler 57 ind 0 -1)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! data i (reader)))
		  (if (not (vequal data (vct-reverse! (vct 0.035 0.033 0.130 0.228 0.325 0.023 0.021 0.020 0.018 0.016))))
		      (snd-display #__line__ ";read mix on ramp2_ptree_ramp2 reversed: ~A" data))))
	      
	      (revert-sound)
	      (mix-vct (vct .1 .2 .3) 50)
	      (reverse-sound)
	      (let ((vals (channel->vct 45 8)))
		(if (not (vequal vals (vct 0.000 0.000 0.300 0.200 0.100 0.000 0.000 0.000)))
		    (snd-display #__line__ ";reversed mix vals: ~A" vals)))
	      (close-sound ind))
	    (set! (with-mix-tags) #f))
	  (set! (with-mix-tags) #t)
	  
	  (let ((ind (open-sound "oboe.snd"))
		(mx (mix-vct (make-vct 100 .1) 1000)))
	    (for-each
	     (lambda (mtest)
	       (let ((func (car mtest))
		     (beg (cadr mtest))
		     (lock (caddr mtest))
		     (name (cadddr mtest))
		     (edpos (edit-position ind 0)))
		 (func)
		 (set! (edit-position ind 0) edpos)))
	     (list 
	      (list (lambda () (pad-channel 0 100)) 1100 #f 'pad0)
	      (list (lambda () (pad-channel 0 2000)) 3000 #f 'pad20)
	      (list (lambda () (pad-channel 800 100)) 1100 #f 'pad800)
	      (list (lambda () (pad-channel 850 100)) 1100 #f 'pad800)
	      (list (lambda () (pad-channel 990 100)) 1100 #f 'pad990)
	      (list (lambda () (pad-channel 1010 100)) 1000 #t 'pad1010)
	      (list (lambda () (pad-channel 1050 10)) 1000 #t 'pad1050)
	      (list (lambda () (pad-channel 1110 100)) 1000 #f 'pad1110)
	      (list (lambda () (pad-channel 2000 100)) 1000 #f 'pad2000)
	      
	      (list (lambda () (insert-samples 0 100 (make-vct 100 .2))) 1100 #f 'insert0)
	      (list (lambda () (insert-samples 800 100 (make-vct 100 .2))) 1100 #f 'insert800)
	      (list (lambda () (insert-samples 990 100 (make-vct 100 .2))) 1100 #f 'insert990)
	      (list (lambda () (insert-samples 1010 100 (make-vct 100 .2))) 1000 #t 'insert1010)
	      (list (lambda () (insert-samples 1050 10 (make-vct 100 .2))) 1000 #t 'insert1050)
	      (list (lambda () (insert-samples 1110 100 (make-vct 100 .2))) 1000 #f 'insert1110)
	      (list (lambda () (insert-samples 2000 100 (make-vct 100 .2))) 1000 #f 'insert2000)
	      
	      (let ((fr (mus-sound-frames "1a.snd")))
		(list (lambda () (insert-sound "1a.snd" 0)) (+ fr 1000) #f 'inserts0)
		(list (lambda () (insert-sound "1a.snd" 800)) (+ fr 1000) #f 'inserts800)
		(list (lambda () (insert-sound "1a.snd" 990)) (+ fr 1000) #f 'inserts990)
		(list (lambda () (insert-sound "1a.snd" 1010)) 1000 #t 'inserts1010)
		(list (lambda () (insert-sound "1a.snd" 1050)) 1000 #t 'inserts1050)
		(list (lambda () (insert-sound "1a.snd" 1110)) 1000 #f 'inserts1110)
		(list (lambda () (insert-sound "1a.snd" 2000)) 1000 #f 'inserts2000))
	      
	      (list (lambda () (delete-samples 0 100)) 900 #f 'delete0)
	      (list (lambda () (delete-samples 0 2000)) 1000 #t 'delete20)
	      (list (lambda () (delete-samples 800 100)) 900 #f 'delete800)
	      (list (lambda () (delete-samples 850 100)) 900 #f 'delete850)
	      (list (lambda () (delete-samples 950 40)) 960 #f 'delete950)
	      (list (lambda () (delete-samples 990 100)) 1000 #t 'delete990)
	      (list (lambda () (delete-samples 1010 100)) 1000 #t 'delete1010)
	      (list (lambda () (delete-samples 1050 10)) 1000 #t 'delete1050)
	      (list (lambda () (delete-samples 1110 100)) 1000 #f 'delete1110)
	      (list (lambda () (delete-samples 2000 100)) 1000 #f 'delete2000)
	      
	      (list (lambda () (set! (samples 0 100) (make-vct 100 .2))) 1000 #f 'set0)
	      (list (lambda () (set! (samples 0 2000) (make-vct 2000 .2))) 1000 #t 'set0)
	      (list (lambda () (set! (samples 800 100) (make-vct 100 .2))) 1000 #f 'set800)
	      (list (lambda () (set! (samples 990 100) (make-vct 100 .2))) 1000 #t 'set990)
	      (list (lambda () (set! (samples 1010 100) (make-vct 100 .2))) 1000 #t 'set1010)
	      (list (lambda () (set! (samples 1050 10) (make-vct 100 .2))) 1000 #t 'set1050)
	      (list (lambda () (set! (samples 1110 100) (make-vct 100 .2))) 1000 #f 'set1110)
	      (list (lambda () (set! (samples 2000 100) (make-vct 100 .2))) 1000 #f 'set2000)
	      
	      (list (lambda () (scale-channel 2.0 0 100)) 1000 #f 'scale0)
	      (list (lambda () (scale-channel 2.0 0 2000)) 1000 #t 'scale20)
	      (list (lambda () (scale-channel 2.0 800 100)) 1000 #f 'scale800)
	      (list (lambda () (scale-channel 2.0 850 100)) 1000 #f 'scale850)
	      (list (lambda () (scale-channel 2.0 950 40)) 1000 #f 'scale950)
	      (list (lambda () (scale-channel 2.0 990 100)) 1000 #t 'scale990)
	      (list (lambda () (scale-channel 2.0 1010 100)) 1000 #t 'scale1010)
	      (list (lambda () (scale-channel 2.0 1050 10)) 1000 #t 'scale1050)
	      (list (lambda () (scale-channel 2.0 1110 100)) 1000 #f 'scale1110)
	      (list (lambda () (scale-channel 2.0 2000 100)) 1000 #f 'scale2000)
	      
	      (list (lambda () (env-channel '(0 0 1 1) 0 100)) 1000 #f 'env0)
	      (list (lambda () (env-channel '(0 0 1 1) 0 2000)) 1000 #t 'env20)
	      (list (lambda () (env-channel '(0 0 1 1) 800 100)) 1000 #f 'env800)
	      (list (lambda () (env-channel '(0 0 1 1) 850 100)) 1000 #f 'env850)
	      (list (lambda () (env-channel '(0 0 1 1) 950 40)) 1000 #f 'env950)
	      (list (lambda () (env-channel '(0 0 1 1) 990 100)) 1000 #t 'env990)
	      (list (lambda () (env-channel '(0 0 1 1) 1010 100)) 1000 #t 'env1010)
	      (list (lambda () (env-channel '(0 0 1 1) 1050 10)) 1000 #t 'env1050)
	      (list (lambda () (env-channel '(0 0 1 1) 1110 100)) 1000 #f 'env1110)
	      (list (lambda () (env-channel '(0 0 1 1) 2000 100)) 1000 #f 'env2000)
	      
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 0 100)) 1000 #f 'ptree0)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 0 2000)) 1000 #t 'ptree20)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 800 100)) 1000 #f 'ptree800)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 850 100)) 1000 #f 'ptree850)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 950 40)) 1000 #f 'ptree950)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 990 100)) 1000 #t 'ptree990)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 1010 100)) 1000 #t 'ptree1010)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 1050 10)) 1000 #t 'ptree1050)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 1110 100)) 1000 #f 'ptree1110)
	      (list (lambda () (ptree-channel (lambda (y) (* y 2)) 2000 100)) 1000 #f 'ptree2000)))
	    
	    (close-sound ind))
	  
	  (set! (optimization) old-opt-val)
	  
	  (let ((ind (open-sound "4.aiff"))
		(selind (open-sound "oboe.snd")))
	    (make-selection 100 500 selind 0)
	    (mix-selection 500 ind 2)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";mix-selection 0->2 0: ~A" (edit-position ind 0)))
	    (if (not (= (edit-position ind 1) 0)) (snd-display #__line__ ";mix-selection 0->2 1: ~A" (edit-position ind 1)))
	    (if (not (= (edit-position ind 2) 1)) (snd-display #__line__ ";mix-selection 0->2 2: ~A" (edit-position ind 2)))
	    (if (not (= (edit-position ind 3) 0)) (snd-display #__line__ ";mix-selection 0->2 3: ~A" (edit-position ind 3)))
	    (revert-sound ind)
	    (set! (sync ind) 1234)
	    (mix-selection 500 ind 1)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";mix-selection 1->2 0: ~A" (edit-position ind 0)))
	    (if (not (= (edit-position ind 1) 1)) (snd-display #__line__ ";mix-selection 1->2 1: ~A" (edit-position ind 1)))
	    (if (not (= (edit-position ind 2) 0)) (snd-display #__line__ ";mix-selection 1->2 2: ~A" (edit-position ind 2)))
	    (if (not (= (edit-position ind 3) 0)) (snd-display #__line__ ";mix-selection 1->2 3: ~A" (edit-position ind 3)))
	    (revert-sound ind)
	    (set! (sync ind) 0)
	    (insert-selection 500 ind 2)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";insert-selection 0->2 0: ~A" (edit-position ind 0)))
	    (if (not (= (edit-position ind 1) 0)) (snd-display #__line__ ";insert-selection 0->2 1: ~A" (edit-position ind 1)))
	    (if (not (= (edit-position ind 2) 1)) (snd-display #__line__ ";insert-selection 0->2 2: ~A" (edit-position ind 2)))
	    (if (not (= (edit-position ind 3) 0)) (snd-display #__line__ ";insert-selection 0->2 3: ~A" (edit-position ind 3)))
	    (revert-sound ind)
	    (set! (sync ind) 1234)
	    (insert-selection 500 ind 1)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";insert-selection 1->2 0: ~A" (edit-position ind 0)))
	    (if (not (= (edit-position ind 1) 1)) (snd-display #__line__ ";insert-selection 1->2 1: ~A" (edit-position ind 1)))
	    (if (not (= (edit-position ind 2) 0)) (snd-display #__line__ ";insert-selection 1->2 2: ~A" (edit-position ind 2)))
	    (if (not (= (edit-position ind 3) 0)) (snd-display #__line__ ";insert-selection 1->2 3: ~A" (edit-position ind 3)))
	    (revert-sound ind)
	    (set! (sync ind) 0)
	    (close-sound ind)
	    (close-sound selind))
	  
	  
	  (let ((new-index (new-sound "hiho.wave" mus-next mus-bshort 22050 1)))
	    (log-mem test-ctr)
	    (select-sound new-index)
	    (if (find-mix 0 new-index 0) (snd-display #__line__ ";found non-existent mix? ~A" (find-mix 0 new-index 0)))
	    (let ((mix-id (car (mix "pistol.snd" 100))))
	      (if (not (mix? mix-id)) (snd-display #__line__ ";~A not mix?" mix-id))
	      (view-mixes-dialog)
	      (let ((pos (mix-position mix-id))
		    (len (mix-length mix-id))
		    (spd (mix-speed mix-id))
		    (snd (car (mix-home mix-id)))
		    (chn (cadr (mix-home mix-id)))
		    (nam (mix-name mix-id))
		    (amp (mix-amp mix-id))
		    (mr (make-mix-sampler mix-id)))
		(if (not (mix-sampler? mr)) (snd-display #__line__ ";~A not mix-sampler?" mr))
		(if (region-sampler? mr) (snd-display #__line__ ";mix sampler: region ~A" mr))
					;		(if (sampler? mr) (snd-display #__line__ ";mix sampler: normal ~A" mr))
		(if (not (= (sampler-position mr) 0)) (snd-display #__line__ ";mix sampler position: ~A" (sampler-position mr)))
		(if (sampler-at-end? mr) (snd-display #__line__ ";mix sampler at end? ~A" mr))
		(if (not (equal? (sampler-home mr) mix-id))
		    (snd-display #__line__ ";~A home: ~A" mr (sampler-home mr)))
		(let ((reader-string (format #f "~A" mr)))
		  (if (not (string=? (substring reader-string 0 16) "#<mix-sampler mi"))
		      (snd-display #__line__ ";mix sampler actually got: [~S]" (substring reader-string 0 16))))
		(do ((i 0 (+ 1 i)))
		    ((= i 99))
		  (let ((mx (if (odd? i) (read-mix-sample mr) (read-mix-sample mr)))
			(sx (sample (+ 100 i))))
		    (if (fneq mx sx) (snd-display #__line__ ";read-mix-sample: ~A ~A?" mx sx))))
		(let ((mx (mr))
		      (sx (sample 199)))
		  (if (fneq mx sx) (snd-display #__line__ ";mix-sample 100: ~A ~A?" mx sx)))
		(free-sampler mr)
		(if (not (= pos 100)) (snd-display #__line__ ";mix-position: ~A?" pos))
		(if (not (= len 41623)) (snd-display #__line__ ";mix-length: ~A?" len))
		(if (not (equal? snd new-index)) (snd-display #__line__ ";s mix-home: ~A?" snd))		
		(if (not (= chn 0)) (snd-display #__line__ ";c mix-home: ~A?" chn))
		(if (fneq amp 1.0) (snd-display #__line__ ";mix-amp: ~A?" amp))
		(if (fneq spd 1.0) (snd-display #__line__ ";mix-speed: ~A?" spd))
		(if nam (snd-display #__line__ ";mix-name: ~A" nam))
		(catch 'mus-error
		       (lambda () (play mix-id))
		       (lambda args (snd-display #__line__ ";can't play mix: ~A" args)))
		(catch 'mus-error
		       (lambda () (play mix-id 1000))
		       (lambda args (snd-display #__line__ ";can't play mix from 1000: ~A" args)))
		(set! (mix-name mix-id) "test-mix")
		(if (or (not (string? (mix-name mix-id)))
			(not (string=? (mix-name mix-id) "test-mix")))
		    (snd-display #__line__ ";mix-name set: ~A" (mix-name mix-id)))
		(let ((id (mix-name->id "test-mix")))
		  (if (not (equal? id mix-id)) (snd-display #__line__ ";mix-name->id: ~A ~A" id mix-id)))
		(set! (mix-name mix-id) "test-mix-again") ; make sure previous name is freed
		(if (or (not (string? (mix-name mix-id)))
			(not (string=? (mix-name mix-id) "test-mix-again")))
		    (snd-display #__line__ ";mix-name set again: ~A" (mix-name mix-id)))
		(set! (mix-name mix-id) #f)
		(if (mix-name mix-id) (snd-display #__line__ ";set mix-name #f: ~A" (mix-name mix-id)))
		(set! (mix-position mix-id) 200) 
		(set! (mix-amp mix-id) 0.5) 
		(set! (mix-speed mix-id) 2.0) 
		
		(set! (mix-amp-env mix-id) '(0.0 0.0 1.0 1.0)) 
		(let ((val (mix-amp-env mix-id)))
		  (set! (mix-amp-env mix-id) (mix-amp-env mix-id))
		  (if (not (feql (mix-amp-env mix-id) val)) 
		      (snd-display #__line__ ";set mix-amp-env to self: ~A ~A" val (mix-amp-env mix-id))))
		(set! (mix-tag-y mix-id) 20) 
		(let ((pos (mix-position mix-id))
		      (spd (mix-speed mix-id))
		      (amp (mix-amp mix-id))
		      (my (mix-tag-y mix-id)))
		  (if (not (= pos 200)) (snd-display #__line__ ";set-mix-position: ~A?" pos))
		  (if (not (= my 20)) (snd-display #__line__ ";set-mix-tag-y: ~A?" my))
		  (if (fneq amp 0.5) (snd-display #__line__ ";set-mix-amp: ~A?" amp))
		  (if (fneq spd 2.0) (snd-display #__line__ ";set-mix-speed: ~A?" spd))
		  (if (not (equal? (mix-amp-env mix-id) '(0.0 0.0 1.0 1.0))) (snd-display #__line__ ";set-mix-amp-env: ~A?" (mix-amp-env mix-id))))
		))
	    (mix-vct (make-vct 3 .1) 100)
	    (set! (cursor) 0)
	    (let ((nid (forward-mix)))
	      (if (or (not (mix? nid))
		      (not (= (cursor) (mix-position nid))))
		  (snd-display #__line__ ";forward-mix ~A ~A ~A?" nid (cursor) (and (mix? nid) (mix-position nid))))
	      (let ((nid1 (forward-mix 2)))
		(if (or (not (mix? nid1))
			(not (= (cursor) (mix-position nid1))))
		    (snd-display #__line__ ";forward-mix(2) ~A ~A ~A ~A ~A?" nid nid1 (cursor) (and (mix? nid1) (mix-position nid1)) (mixes)))
		(set! nid1 (backward-mix))
		(if (or (not (mix? nid1))
			(not (= (cursor) (mix-position nid1))))
		    (snd-display #__line__ ";backward-mix(2) ~A ~A ~A?" nid1 (cursor) (and (mix? nid1) (mix-position nid1))))))
	    (let ((nid (find-mix 100)))
	      (if (or (not (mix? nid))
		      (not (= (mix-position nid) 100)))
		  (snd-display #__line__ ";find-mix(100): ~A ~A ~A?" nid (and (mix? nid) (mix-position nid)) (map mix-position (mixes new-index 0)))))
	    (let ((nid (find-mix 200)))
	      (if (or (not (mix? nid))
		      (not (= (mix-position nid) 200)))
		  (snd-display #__line__ ";find-mix(200): ~A ~A?" nid (and (mix? nid) (mix-position nid)))))
	    (let ((mix-id (car (mix "oboe.snd" 100))))
	      (set! (mix-waveform-height) 40)
	      (set! (mix-property :hiho mix-id) 123)
	      (if (not (= (mix-property :hiho mix-id) 123)) (snd-display #__line__ ";mix-property: ~A" (mix-property :hiho mix-id)))
	      (if (mix-property :not-there mix-id) (snd-display #__line__ ";mix-not-property: ~A" (mix-property :not-there mix-id)))
	      (update-time-graph)
	      (set! (mix-waveform-height) 20))
	    (close-sound new-index))
	  )
	(dismiss-all-dialogs)
	
	;; pan-mix tests
	(let ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "pan-mix tests")))
	  
	  (let ((id0 (car (pan-mix "1a.snd" 10000 '(0 0 1 1)))))
	    (if (or (fneq (mix-amp id0) 1.0)
		    (not (feql (mix-amp-env id0) '(0 1 1 0))))
		(snd-display #__line__ ";pan-mix 1->1 2: ~A ~A" (mix-amp id0) (mix-amp-env id0)))
	    (if (not (= (mix-position id0) 10000)) (snd-display #__line__ ";pan-mix 1->1 pos 2: ~A" (mix-position id0)))
	    (revert-sound ind))
	  
	  (let* ((ids (pan-mix "2a.snd" 100 '(0 0 1 1)))
		 (id0 (car ids))
		 (id1 (cadr ids)))
	    (if (or (not (mix? id0)) (not (mix? id1)))
		(snd-display #__line__ ";pan-mix 2->1: ~A ~A" id0 id1))
	    (if (not (= (mix-position id0) (mix-position id1) 100))
		(snd-display #__line__ ";pan-mix 2->1 pos: ~A ~A" (mix-position id0) (mix-position id1)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0))
		(snd-display #__line__ ";pan-mix 2->1 mix amps 3: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (not (feql (mix-amp-env id0) '(0 1 1 0)))
		(snd-display #__line__ ";pan-mix 2->1 ramp env: ~A" (mix-amp-env id0)))
	    (revert-sound ind))
	  (close-sound ind))
	
	(let ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "pan-mix tests")))
	  (let* ((ids (pan-mix "1a.snd" 100 '(0 0 1 1 2 0)))
		 (id0 (car ids))
		 (id1 (cadr ids)))
	    (if (or (not (mix? id0)) (not (mix? id1)))
		(snd-display #__line__ ";pan-mix 1->2: ~A ~A" id0 id1))
	    (if (not (= (mix-position id0) (mix-position id1) 100))
		(snd-display #__line__ ";pan-mix 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0)) 
		(snd-display #__line__ ";pan-mix 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (not (feql (mix-amp-env id0) '(0 1 1 0 2 1)))
		(snd-display #__line__ ";pan-mix 1->2 env 0: ~A" (mix-amp-env id0)))
	    (if (not (feql (mix-amp-env id1) '(0 0 1 1 2 0)))
		(snd-display #__line__ ";pan-mix 1->2 env 1: ~A" (mix-amp-env id1)))
	    (revert-sound ind))
	  
	  (let* ((ids (pan-mix "2a.snd" 100 '(0 0 1 1 2 0)))
		 (id0 (car ids))
		 (id1 (cadr ids))
		 (id2 (caddr ids))
		 (id3 (cadddr ids)))
	    
	    (if (or (not (mix? id0)) (not (mix? id1)) (not (mix? id2)) (not (mix? id3)))
		(snd-display #__line__ ";pan-mix 2->2: ~A ~A ~A ~A" id0 id1 id2 id3))
	    (if (not (= (mix-position id0) (mix-position id1) (mix-position id2) (mix-position id3) 100))
		(snd-display #__line__ ";pan-mix 2->2 pos: ~A ~A ~A ~A" (mix-position id0) (mix-position id1) (mix-position id2) (mix-position id3)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0)) 
		(snd-display #__line__ ";pan-mix 2->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (not (feql (mix-amp-env id0) '(0 1 1 0 2 1)))
		(snd-display #__line__ ";pan-mix 2->2 env 0: ~A" (mix-amp-env id0)))
	    (if (not (feql (mix-amp-env id1) '(0 0 1 1 2 0)))
		(snd-display #__line__ ";pan-mix 2->2 env 1: ~A" (mix-amp-env id1)))
	    (if (not (feql (mix-amp-env id2) '(0 1 1 0 2 1)))
		(snd-display #__line__ ";pan-mix 2->2 env 2: ~A" (mix-amp-env id2)))
	    (if (not (feql (mix-amp-env id3) '(0 0 1 1 2 0)))
		(snd-display #__line__ ";pan-mix 2->2 env 3: ~A" (mix-amp-env id3)))
	    (revert-sound ind))
	  (close-sound ind))
	
	(let ((ind (new-sound "test.snd" mus-next mus-bshort 22050 2 "pan-mix-* tests" 1000)))
	  (let* ((ids (pan-mix-vct (make-vct 100 .3) 100 '(0 0 1 1)))
		 (id0 (car ids))
		 (id1 (cadr ids)))
	    (if (or (not (mix? id0)) (not (mix? id1)))
		(snd-display #__line__ ";pan-mix-vct 1->2: ~A ~A" id0 id1))
	    (if (not (= (mix-position id0) (mix-position id1) 100))
		(snd-display #__line__ ";pan-mix-vct 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0)) 
		(snd-display #__line__ ";pan-mix-vct 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (not (feql (mix-amp-env id0) '(0 1 1 0)))
		(snd-display #__line__ ";pan-mix-vct 1->2 env 0: ~A" (mix-amp-env id0)))
	    (if (not (feql (mix-amp-env id1) '(0 0 1 1)))
		(snd-display #__line__ ";pan-mix-vct 1->2 env 1: ~A" (mix-amp-env id1)))
	    (revert-sound ind))
	  
	  (let* ((reg (make-region 0 50 ind 0))
		 (ids (pan-mix-region reg 100 '(0 0 1 1)))
		 (id0 (car ids))
		 (id1 (cadr ids)))
	    (if (or (not (mix? id0)) (not (mix? id1)))
		(snd-display #__line__ ";pan-mix-region 1->2: ~A ~A" id0 id1))
	    (if (not (= (mix-position id0) (mix-position id1) 100))
		(snd-display #__line__ ";pan-mix-region 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0)) 
		(snd-display #__line__ ";pan-mix-region 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (not (feql (mix-amp-env id0) '(0 1 1 0)))
		(snd-display #__line__ ";pan-mix-region 1->2 env 0: ~A" (mix-amp-env id0)))
	    (if (not (feql (mix-amp-env id1) '(0 0 1 1)))
		(snd-display #__line__ ";pan-mix-region 1->2 env 1: ~A" (mix-amp-env id1)))
	    (revert-sound ind))
	  
	  (select-all)
	  (let* ((ids (pan-mix-selection 100 '(0 0 1 1)))
		 (id0 (car ids))
		 (id1 (cadr ids)))
	    (if (or (not (mix? id0)) (not (mix? id1)))
		(snd-display #__line__ ";pan-mix-selection 1->2: ~A ~A" id0 id1))
	    (if (not (= (mix-position id0) (mix-position id1) 100))
		(snd-display #__line__ ";pan-mix-selection 1->2 pos: ~A ~A" (mix-position id0) (mix-position id1)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0)) 
		(snd-display #__line__ ";pan-mix-selection 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (not (feql (mix-amp-env id0) '(0 1 1 0)))
		(snd-display #__line__ ";pan-mix-selection 1->2 env 0: ~A" (mix-amp-env id0)))
	    (if (not (feql (mix-amp-env id1) '(0 0 1 1)))
		(snd-display #__line__ ";pan-mix-selection 1->2 env 1: ~A" (mix-amp-env id1)))
	    (revert-sound ind))
	  (close-sound ind))
	
	;; copy mix
	(let ((snd (new-sound "test.snd")))
	  (let ((v (make-vct 1000)))
	    (do ((i 0 (+ i 1)))
		((= i 1000))
	      (vct-set! v i (* i .001)))
	    (let ((mx (mix-vct v 0 snd 0)))
	      (let ((mx-copy (copy mx)))
		(if (not (= (length mx) (length mx-copy)))
		    (snd-display #__line__ ";copy mix lengths: ~A ~A" (length mx) (length mx-copy)))
		(if (not (= (mix-position mx) (mix-position mx-copy)))
		    (snd-display #__line__ ";copy mix positions: ~A ~A" (mix-position mx) (mix-position mx-copy)))
		(set! (mix-position mx-copy) 2000)
		(let ((rd1 (make-sampler 0))
		      (rd2 (make-sampler 2000))
		      (happy #t))
		  (do ((i 0 (+ i 1)))
		      ((or (not happy)
			   (= i 1000)))
		    (let ((x1 (rd1))
			  (x2 (rd2)))
		      (if (or (fneq x1 x2) (fneq x1 (* i .001)))
			  (begin
			    (set! happy #f)
			    (snd-display #__line__ ";copy mix at ~A: ~A ~A ~A" i x1 x2 (* i .001))))))))))
	  (close-sound snd))
	
	(let ((ind (make-waltz)))
	  ;; mix.scm stuff...
	  (close-sound ind))
	
	(let ((ind (make-bagatelle)))
	  (close-sound ind))
	
	)))


;;; ---------------- test 10: marks ----------------

(if (not (provided? 'snd-marks.scm)) (load "marks.scm"))

(define (snd_test_10)
  
  (define maxval 0.0)
  (define data-max
    (lambda (beg end)
      (set! maxval 0.0)
      (apply for-each 
	     (lambda (snd chn)
	       (scan-chan (lambda (n)
			    (set! maxval (max maxval (abs n)))
			    #f)
			  0 #f snd chn))
	     (all-chans))
      maxval))
  
  (define data-max2
    (lambda (beg end snd)
      (set! maxval 0.0)
      (do ((i 0 (+ 1 i)))
	  ((= i (chans snd)) maxval)
	(scan-chan (lambda (n)
		     (set! maxval (max maxval (abs n)))
		     #f)
		   0 #f snd i))))
  
  (define data-max1
    (lambda (beg end snd chn)
      (set! maxval 0.0)
      (scan-chan 
       (lambda (data)
	 (let ((curval (abs data)))
	   (if (> curval maxval) (set! maxval curval))
	   #f))
       beg end snd chn)
      maxval))
  
  
  ;; from marks.scm (commented out)
  
  (define (eval-header sndf)
    (and (string? (comment sndf))
	 (catch #t
		(lambda ()
		  (eval-string (comment sndf)))
		(lambda args #f))))
  
  (define (marks->string sndf)
    (let ((str (format #f "(if (not (provided? 'snd-marks.scm)) (load \"marks.scm\"))~%(let ((m #f))~%"))
	  (chan 0))
      (for-each
       (lambda (chan-marks)
	 (for-each 
	  (lambda (m)
	    (set! str 
		  (string-append str 
				 (format #f
					 "  (set! m (add-mark ~A #f ~D ~A ~D))~%" 
					 (mark-sample m)
					 chan
					 (if (and (string? (mark-name m))
						  (> (string-length (mark-name m)) 0))
					     (format #f "~S" (mark-name m))
					     #f)
					 (mark-sync m))))
	    (if (not (null? (mark-properties m)))
		(set! str
		      (string-append str 
				     (format #f
					     "  (set! (mark-properties m) '~A)~%"
					     (mark-properties m))))))
	  chan-marks)
	 (set! chan (+ 1 chan)))
       (marks sndf))
      (string-append str (format #f "  m)~%"))))
  
  
  (begin 
    (do ((test-ctr 0 (+ 1 test-ctr)))
	((= test-ctr tests))
      (clear-sincs)
      (log-mem test-ctr)
      
      (let ((ind0 (view-sound "oboe.snd"))
	    (ind1 (view-sound "pistol.snd"))
	    (v0 (make-vct 100))
	    (vc (make-vector 10)))
	(vct-fill! v0 .1)
	(vector-set! vc 0 (mix-vct v0 0 ind0))
	(vector-set! vc 1 (mix-vct v0 1000 ind0))
	(vector-set! vc 2 (mix-vct v0 2000 ind0))
	(vector-set! vc 3 (mix-vct v0 3000 ind0))
	(vector-set! vc 4 (mix-vct v0 4000 ind0))
	(vector-set! vc 5 (mix-vct v0 0 ind1))
	(vector-set! vc 6 (mix-vct v0 1000 ind1))
	(vector-set! vc 7 (mix-vct v0 2000 ind1))
	(vector-set! vc 8 (mix-vct v0 3000 ind1))
	(vector-set! vc 9 (mix-vct v0 4000 ind1))
	(close-sound ind0)
	(close-sound ind1)
	(set! ind0 (new-sound "fmv.snd" mus-aifc mus-bshort 22050 1 "this is a comment"))
	(let ((v0 (make-vector 10)))
	  (do ((i 0 (+ 1 i))) ((= i 10)) (vector-set! v0 i 1.0))
	  (insert-samples 0 10 v0 ind0) 
	  (time (env-sound '(0 0 1 1) 0 10 1.0 ind0))
	  (do ((i 0 (+ 1 i))) ((= i 10)) (if (fneq (sample i) (* i .1111)) (snd-display #__line__ ";1 env-sound[~D]: ~A?" i (sample i))))
	  (undo) 
	  (env-sound (make-env '(0 0 1 1) :length 10) 0 10 1.0 ind0) 
	  (do ((i 0 (+ 1 i))) ((= i 10)) (if (fneq (sample i) (* i .1111)) (snd-display #__line__ ";2 env-sound[~D]: ~A?" i (sample i))))
	  (undo) 
	  (env-sound '(0 0 .5 1 1 1) 0 10 0.0 ind0) 
	  (if (or (fneq (sample 3) 0.0) (fneq (sample 8) 1.0) )
	      (snd-display #__line__ ";env-sound stepped: ~A ~A?" (sample 3) (sample 8)))
	  (undo) 
	  (env-sound '(0 0 1 1) 0 10 32.0 ind0) 
	  (if (or (fneq (sample 3) 0.070) (fneq (sample 8) 0.67) )
	      (snd-display #__line__ ";env-sound exp: ~A ~A?" (sample 3) (sample 8)))
	  (undo) 
	  (env-sound (make-env '(0 0 1 1) :base 32.0 :length 10) 0 10 32.0 ind0) 
	  (if (or (fneq (sample 3) 0.070) (fneq (sample 8) 0.67) )
	      (snd-display #__line__ ";env-sound exp: ~A ~A?" (sample 3) (sample 8)))
	  (undo)
	  (env-sound '(0 2))
	  (do ((i 0 (+ 1 i))) ((= i 10)) (if (fneq (sample i) 2.0) (snd-display #__line__ ";3 env-sound[~D]: ~A?" i (sample i))))
	  (undo)
	  (env-sound '(0 2) 2 4 1.0 ind0)
	  (if (or (fneq (sample 1) 1.0) (fneq (sample 2) 2.0) (fneq (sample 5) 2.0) (fneq (sample 8) 1.0))
	      (snd-display #__line__ ";3 env-sound exp: ~A ~A ~A ~A?" (sample 1) (sample 2) (sample 5) (sample 8)))
	  (undo) 
	  (do ((i 1 (+ 1 i))) ((= i 10)) (set! (sample i) 0.0))
	  (filter-sound '(0 1 1 0) 4)
	  (if (or (fneq (sample 1) 0.3678) (fneq (sample 2) .3678) (fneq (sample 3) .132) (fneq (sample 4) 0.0))
	      (snd-display #__line__ ";filter-sound env: ~A?" (samples 0 8)))
	  (undo)
	  (filter-sound '(0 1 1 0) 1024)
	  (undo)
	  (filter-sound (make-fir-filter 6 (list->vct '(.1 .2 .3 .3 .2 .1))))
	  (undo)
	  (filter-sound (make-delay 120))
	  (undo)
	  (filter-sound (make-formant 1200 .99))
	  (undo)
	  (let ((vc0 (make-vct 4)))
	    (vct-set! vc0 0 .125) (vct-set! vc0 1 .25) (vct-set! vc0 2 .25) (vct-set! vc0 3 .125) 
	    (filter-sound vc0 4) 
	    (if (or (fneq (sample 0) 0.125) (fneq (sample 1) .25) (fneq (sample 2) .25) (fneq (sample 5) 0.0))
		(snd-display #__line__ ";filter-sound direct: ~A?" (samples 0 8)))
	    (revert-sound)))
	(close-sound ind0)
	
	(set! ind0 (new-sound "fmv.snd" mus-aifc mus-bshort 22050 2 "this is a comment"))
	(let ((v0 (make-vector 10))
	      (ind1 (new-sound "fmv1.snd" mus-aifc mus-bshort 22050 1 "this is a comment")))
	  (set! (sync ind0) 123)
	  (set! (sync ind1) 123)
	  (do ((i 0 (+ 1 i))) ((= i 10)) (vector-set! v0 i 1.0))
	  (insert-samples 0 10 v0 ind0 0)
	  (insert-samples 0 10 v0 ind0 1)
	  (insert-samples 0 10 v0 ind1 0)
	  (env-sound '(0 0 1 1) 0 10 1.0 ind0)
	  (do ((i 0 (+ 1 i))) 
	      ((= i 10)) 
	    (if (fneq (sample i ind0 0) (* i .1111)) (snd-display #__line__ ";ind0:0 1 env-sound[~D]: ~A?" i (sample i ind0 0)))
	    (if (fneq (sample i ind0 1) (* i .1111)) (snd-display #__line__ ";ind0:1 1 env-sound[~D]: ~A?" i (sample i ind0 1)))
	    (if (fneq (sample i ind1 0) (* i .1111)) (snd-display #__line__ ";ind1:0 1 env-sound[~D]: ~A?" i (sample i ind1 0))))
	  (undo) 
	  (env-sound (make-env '(0 0 1 1) :length 10) 0 10 1.0 ind0) 
	  (do ((i 0 (+ 1 i))) 
	      ((= i 10)) 
	    (if (fneq (sample i ind0 0) (* i .1111)) (snd-display #__line__ ";ind0:0 2 env-sound[~D]: ~A?" i (sample i ind0 0)))
	    (if (fneq (sample i ind0 1) (* i .1111)) (snd-display #__line__ ";ind0:1 2 env-sound[~D]: ~A?" i (sample i ind0 1)))
	    (if (fneq (sample i ind1 0) (* i .1111)) (snd-display #__line__ ";ind1:0 2 env-sound[~D]: ~A?" i (sample i ind1 0))))
	  (undo) 
	  (env-sound '(0 0 .5 1 1 1) 0 10 0.0 ind0) 
	  (if (or (fneq (sample 3 ind0 0) 0.0) (fneq (sample 8 ind0 0) 1.0) ) 
	      (snd-display #__line__ ";ind0:0 env-sound stepped: ~A ~A?" (sample 3 ind0 0) (sample 8 ind0 0)))
	  (if (or (fneq (sample 3 ind0 1) 0.0) (fneq (sample 8 ind0 1) 1.0) ) 
	      (snd-display #__line__ ";ind0:1 env-sound stepped: ~A ~A?" (sample 3 ind0 1) (sample 8 ind0 1)))
	  (if (or (fneq (sample 3 ind1 0) 0.0) (fneq (sample 8 ind1 0) 1.0) ) 
	      (snd-display #__line__ ";ind1:0 env-sound stepped: ~A ~A?" (sample 3 ind1 0) (sample 8 ind1 0)))
	  (undo)
	  (revert-sound ind0)
	  (revert-sound ind1)
	  (insert-samples 0 10 v0 ind0 0)
	  (insert-samples 0 10 v0 ind0 1)
	  (insert-samples 0 10 v0 ind1 0)
	  (filter-sound (make-one-zero :a0 0.5 :a1 0.0) 0 ind0)
	  (do ((i 0 (+ 1 i))) 
	      ((= i 10)) 
	    (if (fneq (sample i ind0 0) 0.5) (snd-display #__line__ ";ind0:0 1 filter-sound[~D]: ~A?" i (sample i ind0 0)))
	    (if (fneq (sample i ind0 1) 0.5) (snd-display #__line__ ";ind0:1 1 filter-sound[~D]: ~A?" i (sample i ind0 1)))
	    (if (fneq (sample i ind1 0) 0.5) (snd-display #__line__ ";ind1:0 1 filter-sound[~D]: ~A?" i (sample i ind1 0))))
	  
	  (close-sound ind1))
	(close-sound ind0)
	
	(set! ind0 (new-sound "fmv.snd" mus-aifc mus-bshort 22050 1 "this is a comment"))
	(let ((v0 (make-vct 10))
	      (old5 (sample 5 ind0)))
	  (vct-fill! v0 0.1)
	  (insert-samples 10 10 v0 ind0)
	  (env-sound '(0 0 1 2) 10 10 1.0 ind0)
	  (do ((i 0 (+ 1 i))) ((= i 10)) 
	    (if (fneq (sample (+ i 10) ind0) (* i .0222)) (snd-display #__line__ ";env-sound [~D]: ~A?" (+ i 10) (sample (+ i 10) ind0))))
	  (if (fneq (sample 5 ind0) old5) (snd-display #__line__ ";env-sound 5: ~A ~A?" old5 (sample 5 ind0)))
	  (undo)
	  (env-sound '(0 0 1 2) 10 10 4.0 ind0)
	  (set! v0 (samples->vct 10 10))
	  (if (or (fneq (vct-ref v0 3) 0.039) (fneq (vct-ref v0 8) .162)) (snd-display #__line__ ";env-sound 4: ~A" v0))
	  (undo)
	  (env-sound '(0 0 1 2) 10 10 .05 ind0)
	  (set! v0 (samples->vct 10 10))
	  (if (or (fneq (vct-ref v0 3) 0.133) (fneq (vct-ref v0 8) .196)) (snd-display #__line__ ";env-sound 05: ~A" v0)))
	
	(close-sound ind0)
	(set! ind0 (new-sound "fmv.snd" mus-aifc mus-bshort 22050 2 "this is a comment"))
	(set! ind1 (new-sound "fmv1.snd" mus-next mus-bshort 22050 1 "this is a comment"))
	(let ((v0 (make-vector 10)))
	  (do ((i 0 (+ 1 i))) ((= i 10)) (vector-set! v0 i 1.0))
	  (insert-samples 0 10 v0 ind0 0) 
	  (do ((i 0 (+ 1 i))) ((= i 10)) (vector-set! v0 i 0.1))
	  (insert-samples 0 10 v0 ind0 1) 
	  (do ((i 0 (+ 1 i))) ((= i 10)) (vector-set! v0 i 0.01))
	  (insert-samples 0 10 v0 ind1 0) 
	  (let ((val (data-max1 0 9 ind0 0)))
	    (if (fneq val 1.0) (snd-display #__line__ ";scan-chan[0,0]: ~A?" val)))
	  (let ((val (data-max1 0 9 ind0 1)))
	    (if (fneq val 0.1) (snd-display #__line__ ";scan-chan[0,1]: ~A?" val)))
	  (let ((val (data-max1 0 9 ind1 0)))
	    (if (fneq val 0.01) (snd-display #__line__ ";scan-chan[1,0]: ~A?" val)))
	  (let ((val (data-max1 0 9 #f #f)))
	    (if (fneq val 0.01) (snd-display #__line__ ";scan-chans: ~A?" val)))
	  (let ((val (data-max 0 9)))
	    (if (fneq val 1.0) (snd-display #__line__ ";scan-all-chans: ~A?" val)))
	  (let ((val (data-max2 0 9 ind0)))
	    (if (fneq val 1.0) (snd-display #__line__ ";scan-across-sound-chans: ~A?" val))))
	(close-sound ind0)
	(close-sound ind1)
	
	(set! ind0 (new-sound "fmv.snd" mus-aifc mus-bshort 22050 2 "this is a comment"))
	(mix "oboe.snd")
	(let ((m1 (add-mark 100)))
	  (delete-sample 10)
	  (let ((m2 (add-mark 200)))
	    (delete-sample 10)
	    (let ((m3 (add-mark 300)))
	      (undo)
	      (save-sound)
	      (if (not (= (length (marks ind0 0)) 2))
		  (snd-display #__line__ ";marks after save: ~A" (marks ind0 0)))
	      (if (or (not (mark? m1))
		      (not (= (mark-sample m1) 99)))
		  (snd-display #__line__ ";save-sound mark1: ~A" (mark-sample m1)))
	      (if (or (not (mark? m2))
		      (not (= (mark-sample m2) 200)))
		  (snd-display #__line__ ";save-sound mark2: ~A" (mark-sample m2)))
	      (if (mark? m3) (snd-display #__line__ ";save-sound mark3: ~A" m3)))))
	(close-sound ind0)
	
	(let ((fd (open-sound "oboe.snd"))
	      (m1 (add-mark 123))
	      (sync-val (+ 1 (mark-sync-max))))
	  (if (not (mark? m1)) (snd-display #__line__ ";mark?"))
	  (if (not (= (mark-sample m1) 123)) (snd-display #__line__ ";add-mark: ~A? " (mark-sample m1)))
	  (set! (mark-property :hiho m1) 123)
	  (if (not (= (mark-property :hiho m1) 123)) (snd-display #__line__ ";mark-property: ~A" (mark-property :hiho m1)))
	  (if (mark-property :not-there m1) (snd-display #__line__ ";mark-not-property: ~A" (mark-property :not-there m1)))
	  (if (not (eq? (without-errors (mark-sample (integer->mark 12345678))) 'no-such-mark)) 
	      (snd-display #__line__ ";mark-sample err: ~A?" (without-errors (mark-sample 12345678))))
	  (if (not (eq? (without-errors (add-mark 123 123)) 'no-such-sound)) 
	      (snd-display #__line__ ";add-mark err: ~A?" (without-errors (add-mark 123 123))))
	  (let ((m2 (without-errors (add-mark 12345 fd 0))))
	    (if (eq? m2 'no-such-mark) (snd-display #__line__ ";add-mark failed?"))
	    (if (not (= (mark-sample m2) 12345)) (snd-display #__line__ ";add-mark 0 0: ~A?" (mark-sample m2)))
	    (if (not (= (mark-sync m2) 0)) (snd-display #__line__ ";init mark-sync: ~A?" (mark-sync m2)))
	    (set! (mark-sync m2) sync-val)
	    (if (not (= (mark-sync m2) sync-val)) (snd-display #__line__ ";set-mark-sync (~A): ~A?" sync-val (mark-sync m2)))
	    (let* ((syncs (syncd-marks sync-val))
		   (chans (marks fd 0))
		   (samps (map mark-sample chans)))
	      (if (not (equal? syncs (list m2))) (snd-display #__line__ ";syncd-marks: ~A?" syncs))
	      (if (not (equal? chans (list m1 m2))) (snd-display #__line__ ";marks: ~A?" chans))
	      (if (not (equal? samps (list (mark-sample m1) (mark-sample m2)))) (snd-display #__line__ ";map samps: ~A?" samps))
	      (delete-samples 200 100 fd 0)
	      (set! chans (marks fd))
	      (set! samps (map mark-sample (car chans)))
	      (if (not (equal? samps (list (mark-sample m1 0) (- (mark-sample m2 0) 100)))) (snd-display #__line__ ";map samps: ~A?" samps))
	      (let ((descr (describe-mark m2)))
		(if (not (list? descr))
		    (snd-display #__line__ ";describe-mark: ~A?" descr)))
	      (set! (mark-sync m1) (mark-sync m2))
	      (move-syncd-marks sync-val 100)
	      (set! chans (marks fd))
	      (set! samps (map mark-sample (car chans)))
	      (if (not (equal? samps (list (+ (mark-sample m1 0) 100) (mark-sample m2 0)))) (snd-display #__line__ ";syncd move samps: ~A?" samps))
	      (set! (cursor) 500)
	      (backward-mark)
	      (if (not (= (cursor) (mark-sample m1))) (snd-display #__line__ ";backward-mark: ~A?" (cursor)))
	      (forward-mark 1)
	      (if (not (= (cursor) (mark-sample m2))) (snd-display #__line__ ";forward-mark: ~A?" (cursor)))
	      (set! (mark-sync m1) #t)
	      (if (not (= (mark-sync m1) 1)) (snd-display #__line__ ";mark-sync via bool: ~A" (mark-sync m1)))
	      (delete-mark m1)
	      (set! chans (marks fd 0))
	      (if (not (equal? chans (list m2))) (snd-display #__line__ ";delete-mark? ~A" chans))
	      (undo)
	      (set! chans (marks fd 0))
	      (if (not (equal? chans (list m1 m2))) (snd-display #__line__ ";delete-mark then undo? ~A" chans))
	      (redo)
	      (if (not (string=? (mark-name m2) "")) (snd-display #__line__ ";init mark-name: ~A?" (mark-name m2)))
	      (set! (mark-name m2) "hiho!")
	      (if (not (string=? (mark-name m2) "hiho!")) (snd-display #__line__ ";set-mark-name: ~A?" (mark-name m2)))
	      (undo)
	      (if (not (string=? (mark-name m2) "")) (snd-display #__line__ ";undo mark-name: ~A?" (mark-name m2)))
	      (redo)
	      (if (not (string=? (mark-name m2) "hiho!")) (snd-display #__line__ ";redo mark-name: ~A?" (mark-name m2)))
	      (let ((m3 (find-mark "hiho!"))
		    (m4 (find-mark (mark-sample m2)))
		    (m5 (find-mark "not-a-mark"))
		    (m6 (find-mark 123456787))
		    (m7 (mark-name->id "hiho!")))
		(if (or (not (equal? m2 m3)) (not (equal? m4 m7)) (not (equal? m2 m4))) (snd-display #__line__ ";find-mark: ~A ~A ~A ~A?" m2 m3 m4 m7))
		(if (or (not (equal? m5 m6)) (not (equal? m5 #f))) (snd-display #__line__ ";find-not-a-mark: ~A ~A?" m5 m6))
		(set! (mark-sample m2) 2000)
		(set! m1 (add-mark 1000))
		(set! m3 (add-mark 3000))
		(set! m4 (add-mark 4000))
		(insert-samples 2500 500 (make-vct 500) fd 0)
		(set! samps (map mark-sample (marks fd 0)))
		(if (not (equal? samps '(1000 2000 3500 4500))) (snd-display #__line__ ";insert ripple: ~A?" samps))
		(set! (mark-sample m3) 300)
		(set! (cursor) 500)
		(backward-mark)
		(if (not (= (cursor) 300)) (snd-display #__line__ ";sort marks: ~A?" (cursor)))
		(if (not (equal? (mark-home m2) (list fd 0))) (snd-display #__line__ ";mark-home: ~A?" (mark-home m2)))
		(let ((sd (open-sound "4.aiff")))
		  (set! m3 (add-mark 1000 sd 2))
		  (set! m4 (add-mark 1000 sd 3))
		  (if (not (equal? (mark-home m3) (list sd 2))) (snd-display #__line__ ";marks->sound 4: ~A?" (mark-home m3)))
		  (close-sound sd))
		(let ((file (save-marks fd)))
		  (if (or (not file)
			  (not (string=? file (string-append cwd "oboe.marks"))))
		      (snd-display #__line__ ";save-marks -> ~A?" file)))
		(let ((file (save-marks fd "hiho.marks")))
		  (if (or (not file)
			  (not (string=? file "hiho.marks")))
		      (snd-display #__line__ ";save-marks with arg -> ~A?" file))
		  (let ((val (system (format #f "diff hiho.marks ~A" (string-append cwd "oboe.marks")))))
		    (if (not (= val 0))
			(snd-display #__line__ ";save marks differs"))))
		(close-sound fd)
		(let ((s1 (open-sound "oboe.snd"))
		      (s2 (open-sound "oboe.snd")))
		  (add-mark 123 s1 0)
		  (add-mark 321 s2 0)
		  (set! (with-verbose-cursor) #t)
		  (if (file-exists? "s61.scm") (delete-file "s61.scm"))
		  (save-state "s61.scm")
		  (set! (with-verbose-cursor) #f)
		  (close-sound s1)
		  (close-sound s2))
		(load (string-append cwd "s61.scm"))
		(if (not (with-verbose-cursor)) (snd-display #__line__ ";save-state with-verbose-cursor?"))
		(let ((s1 (find-sound "oboe.snd" 0))
		      (s2 (find-sound "oboe.snd" 1)))
		  (if (or (not (sound? s1)) (not (sound? s2)))
		      (snd-display #__line__ ";can't re-open sounds? ~A ~A" s1 s2)
		      (let ((m1 (marks s1))
			    (m2 (marks s2)))
			(if (or (not (= (length m1) 1))
				(not (= (length m2) 1))
				(not (= (length (car m1)) 1))
				(not (= (length (car m2)) 1)))
			    (snd-display #__line__ ";save-marks via save-state to: ~A ~A" m1 m2)
			    (let ((samp1 (mark-sample (caar m1)))
				  (samp2 (mark-sample (caar m2))))
			      (if (or (not (= samp1 123))
				      (not (= samp2 321)))
				  (snd-display #__line__ ";save-marks via save-state positions: ~A ~A" samp1 samp2))))))
		  (if (sound? s1) (close-sound s1))
		  (if (sound? s2) (close-sound s2)))
		(let ((fd (open-sound "pistol.snd")))
		  (let ((file (save-marks)))
		    (if file
			(snd-display #__line__ ";save-marks no marks -> ~A?" file)))
		  (close-sound fd))
		(let ((fd (open-sound "oboe.snd")))
		  (load (string-append cwd "oboe.marks"))
		  (let ((mlst (marks fd 0)))
		    (if (not (= (length mlst) 4)) 
			(snd-display #__line__ ";restore oboe.marks: ~A, marks: ~A" (file->string "oboe.marks") (marks fd 0))))
		  (close-sound fd))
		(let ((fd (open-sound "oboe.snd")))
		  (let ((m1 (add-mark 1000)))
		    (let ((m2 (add-mark 2500)))
		      (let ((m3 (add-mark (- (frames) 4000))))
			(let ((ms (marks fd 0)))
			  (src-sound -.5)
			  (if (not (equal? (marks fd 0) (reverse (marks fd 0 0))))
			      (snd-display #__line__ ";src rev marks: ~A ~A" (marks fd 0) (reverse (marks fd 0 0))))
			  (let ((ms1 (map mark-sample (marks fd 0))))
			    (if (not (equal? ms1 (list 7998 96654 99654))) ; off-by-1 somewhere...
				(snd-display #__line__ ";src rev mark locs: ~A" ms1)))))))
		  (close-sound fd))
		(let ((fd (open-sound "4.aiff")))
		  (let ((m1 (add-mark 1000 fd 0))
			(m2 (add-mark 2000 fd 1))
			(m3 (add-mark 3000 fd 2))
			(m4 (add-mark 4000 fd 3)))
		    (if (= (length (marks)) 0) (snd-display #__line__ ";marks (no args): ~A" (marks)))
		    (save-marks fd)
		    (close-sound fd)
		    (set! fd (open-sound "4.aiff"))
		    (load (string-append cwd "4.marks"))
		    (delete-file "4.marks")
		    (do ((i 0 (+ 1 i)))
			((= i 4))
		      (let ((mlst (marks fd i)))
			(if (not (= (length mlst) 1))
			    (snd-display #__line__ ";save-marks[~A]: ~A?" i mlst))
			(if (not (= (mark-sample (car mlst)) (* (+ i 1) 1000)))
			    (snd-display #__line__ ";save-marks[~A] at ~A?" i (mark-sample (car mlst))))))
		    (close-sound fd)))
		
		))))
	
	(let ((fd (open-sound "oboe.snd"))
	      (m1 (add-mark 1234)))
	  (set! (mark-name m1) "1234")
	  (set! (mark-sync m1) 1234)
	  (let ((m2 (copy m1)))
	    (if (not (mark? m2)) 
		(snd-display #__line__ "; copy mark: ~A?" m2)
		(begin
		  (if (not (= (mark-sample m1) (mark-sample m2) 1234))
		      (snd-display #__line__ ";copy mark sample: ~A ~A" (mark-sample m1) (mark-sample m2)))
		  (if (not (= (mark-sync m1) (mark-sync m2) 1234))
		      (snd-display #__line__ ";copy mark sync: ~A ~A" (mark-sync m1) (mark-sync m2)))
		  (if (not (string=? (mark-name m2) "1234"))
		      (snd-display #__line__ ";copy mark name: ~A?" (mark-name m2))))))
	  (close-sound fd))
	
	(let* ((ind (open-sound "pistol.snd"))
	       (samp1 1834)
	       (samp2 8345)
	       (m1 (add-mark samp1 ind 0))
	       (m2 (add-mark samp2)))
	  (set! (mark-sync m1) 123)
	  (set! (mark-sync m2) 100)
	  (if (not (= (mark-sync-max) 1234)) (snd-display #__line__ ";mark-sync-max: ~A" (mark-sync-max)))
	  (src-sound -1)
	  (if (not (= (mark-sample m1) 39788))
	      (snd-display #__line__ ";src -1 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) 33277))
	      (snd-display #__line__ ";src -1 m2 -> ~A" (mark-sample m2)))
	  (undo)
	  (src-sound .5)
	  (if (not (= (mark-sample m1) (* 2 samp1)))
	      (snd-display #__line__ ";src .5 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) (* 2 samp2)))
	      (snd-display #__line__ ";src .5 m2 -> ~A" (mark-sample m2)))
	  (undo)
	  (delete-samples 1000 100)
	  (if (not (= (mark-sample m1) (- samp1 100)))
	      (snd-display #__line__ ";delete 100 m1 -> ~A" (mark-sample m1)))
	  (insert-silence 1000 100)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";insert 100 m1 -> ~A" (mark-sample m1)))
	  (revert-sound ind)
	  (delete-samples 2000 100)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";delete(2) 100 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) (- samp2 100)))
	      (snd-display #__line__ ";delete(2) 100 m2 -> ~A" (mark-sample m2)))
	  (insert-silence 2000 100)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";insert(2) 100 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) samp2))
	      (snd-display #__line__ ";insert(2) 100 m2 -> ~A" (mark-sample m2)))
	  (revert-sound ind)
	  (delete-samples 10000 100)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";delete(3) 100 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) samp2))
	      (snd-display #__line__ ";delete(3) 100 m2 -> ~A" (mark-sample m2)))
	  (insert-silence 10000 100)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";insert(3) 100 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) samp2))
	      (snd-display #__line__ ";insert(3) 100 m2 -> ~A" (mark-sample m2)))
	  (src-sound '(0 .5 1 .5 2 1))
	  (if (not (= (mark-sample m1) (* 2 samp1)))
	      (snd-display #__line__ ";src env .5 m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) (* 2 samp2)))
	      (snd-display #__line__ ";src env .5 m2 -> ~A" (mark-sample m2)))
	  (undo)
	  (reverse-sound)
	  (if (not (= (mark-sample m1) 39788))
	      (snd-display #__line__ ";reverse-sound m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) 33277))
	      (snd-display #__line__ ";reverse-sound m2 -> ~A" (mark-sample m2)))
	  (undo)
	  (src-sound '(0 -.5 1 -.5 2 -1))
	  (if (not (= (mark-sample m1) 68598))
	      (snd-display #__line__ ";src -env m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) 61160))
	      (snd-display #__line__ ";src -env m2 -> ~A" (mark-sample m2)))
	  (revert-sound ind)
	  (src-channel (make-env '(0 .5 1 1) :length 8001) 2000 10000)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";src-channel(1) m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) 11345))
	      (snd-display #__line__ ";src-channel(1) m2 -> ~A" (mark-sample m2)))
	  (undo)
	  (src-channel (make-env '(0 .5 1 1) :length 8001) 0 8000)
	  (if (not (= (mark-sample m1) 3303))
	      (snd-display #__line__ ";src-channel(2) m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) samp2))
	      (snd-display #__line__ ";src-channel(2) m2 -> ~A" (mark-sample m2)))
	  (undo)
	  (src-channel (make-env '(0 .5 1 1) :length 8001) 10000 8000)
	  (if (not (= (mark-sample m1) samp1))
	      (snd-display #__line__ ";src-channel(3) m1 -> ~A" (mark-sample m1)))
	  (if (not (= (mark-sample m2) samp2))
	      (snd-display #__line__ ";src-channel(3) m2 -> ~A" (mark-sample m2)))
	  (close-sound ind)
	  (set! ind (open-sound "2.snd"))
	  (set! (sync ind) #t)
	  (let ((m3 (add-mark 1000 ind 0))
		(m4 (add-mark 8000 ind 1)))
	    (swap-channels)
	    (if (or (not (equal? (mark-home m3) (list ind 1)))
		    (not (equal? (mark-home m4) (list ind 0))))
		(snd-display #__line__ ";swapped mark homes: ~A ~A?" (mark-home m3) (mark-home m4)))
	    (if (or (not (= (mark-sample m3) 1000))
		    (not (= (mark-sample m4) 8000)))
		(snd-display #__line__ ";swapped mark samples: ~A ~A?" (mark-sample m3) (mark-sample m4)))
	    (close-sound ind))
	  (set! ind (open-sound "2.snd"))
	  (set! (sync ind) #t)
	  (let ((m3 (add-mark 1000 ind 0)))
	    (delete-samples 1000 10 ind 1)
	    (swap-channels)
	    (if (not (equal? (mark-home m3) (list ind 1)))
		(snd-display #__line__ ";edited swapped mark home: ~A?" (mark-home m3)))
	    (if (not (= (mark-sample m3) 1000))
		(snd-display #__line__ ";edited swapped mark sample: ~A" (mark-sample m3)))
	    (delete-marks))
	  (close-sound ind))
	
	(let* ((ind (open-sound "oboe.snd"))
	       (m1 (add-mark 123 ind 0))
	       (m2 (add-mark 234 ind 0))
	       (sel #f))
	  (define-selection-via-marks m1 m2)
	  (set! sel (selection))
	  (if (or (not (selection?))
		  (not (selection? sel)))
	      (snd-display #__line__ ";define-selection-via-marks failed?")
	      (let ((mc (selection-members)))
		(if (not (equal? mc (list (list ind 0)))) (snd-display #__line__ ";selection-members after mark definition: ~A (should be '((~A 0)))" mc ind))
		(if (not (= (selection-position) 123)) (snd-display #__line__ ";selection-position 123: ~A" (selection-position)))
		(if (not (= (selection-frames) 112)) (snd-display #__line__ ";selection-frames 112: ~A" (selection-frames)))))
	  (set! m1 (add-mark 1000 ind 0))
	  (set! m2 (add-mark 2000 ind 0))
	  (define-selection-via-marks m1 m2)
	  (if (not (selection?))
	      (snd-display #__line__ ";define-selection-via-marks repeat failed?")
	      (let ((mc (selection-members)))
		(if (not (equal? mc (list (list ind 0)))) (snd-display #__line__ ";selection-members after 2nd mark definition: ~A (should be '((~A 0)))" mc ind))
		(if (not (= (selection-position) 1000)) (snd-display #__line__ ";selection-position 1000: ~A" (selection-position)))
		(if (not (= (selection-frames) 1001)) (snd-display #__line__ ";selection-frames 1001: ~A" (selection-frames)))))
	  (set! (selection-member? #t) #f)
	  (if (selection?) (snd-display #__line__ ";can't clear selection via selection-member?"))
	  (if (selection) (snd-display #__line__ ";(inactive) selection returns: ~A" (selection)))
	  (if (selection? sel) (snd-display #__line__ ";(obsolete) selection returns: ~A" (selection? sel)))
	  (set! (selection-member? ind 0) #t)
	  (set! (selection-position ind 0) 2000)
	  (set! (selection-frames ind 0) 1234)
	  (snap-marks)
	  (set! m1 (find-mark 2000 ind 0))
	  (if (not (mark? m1)) (snd-display #__line__ ";snap-marks start: ~A" (map mark-sample (marks ind 0))))
	  (set! m2 (find-mark (+ 2000 1234)))
	  (if (not (mark? m2)) (snd-display #__line__ ";snap-marks end: ~A" (map mark-sample (marks ind 0))))
	  (set! (selection-position ind 0) (+ (frames ind 0) 1123))
	  (if (not (= (selection-position ind 0) (- (frames ind) 1)))
	      (snd-display #__line__ ";selection position past eof: ~A ~A" (selection-position ind 0) (- (frames ind) 1)))
	  (revert-sound ind)
	  (src-sound '(0 .5 1 1.75665))
	  ;; trying to hit previous dur on the nose "by accident..."
	  
	  ;; try to hit mark_size segfault
	  (as-one-edit
	   (lambda ()
	     (add-mark 10)
	     (mix "oboe.snd")
	     (do ((i 0 (+ 1 i))) ((= i 20)) (scale-channel 1.2) (add-mark (* i 2)))))
	  (scale-channel .5)
	  
	  (close-sound ind)
	  )
	
	(let ((ind (open-sound "oboe.snd"))
	      (mtests 100))
	  (do ((i 0 (+ 1 i)))
	      ((= i mtests))
	    (let* ((current-marks (marks ind 0))
		   (current-samples (map mark-sample current-marks)))
	      
	      (if (not (null? current-marks))
		  (let ((id (list-ref current-marks (random (- (length current-marks) 1)))))
		    (if (not (equal? id (find-mark (mark-sample id)))) 
			(snd-display #__line__ ";two marks at ~A? ~A" (mark-sample id) (map mark-sample current-marks)))
		    (if (find-mark "not-a-name") (snd-display #__line__ ";find-bogus-mark: ~A" (find-mark "not-a-name")))))
	      
	      (case (random 15)
		((0) (let* ((beg (random (frames)))
			    (dur (max 1 (random 100)))
			    ;; (end (+ beg dur))
			    )
		       (insert-silence beg dur)
		       (if (not (null? current-marks))
			   (for-each
			    (lambda (id old-loc)
			      (if (> old-loc beg)
				  (begin
				    (if (not (mark? id))
					(snd-display #__line__ ";insert clobbered mark: ~A" id)
					(if (not (= (mark-sample id) (+ old-loc dur)))
					    (snd-display #__line__ ";insert, mark ~D ~D -> ~D (~D)" id old-loc (mark-sample id) dur))))))
			    current-marks
			    current-samples))))
		((1) (if (> (car (edits ind 0)) 0) (undo)))
		((2) (if (> (cadr (edits ind 0)) 0) (redo)))
		((3) (if (> (maxamp ind 0) .1) (scale-channel .5) (scale-channel 2.0))
		 (if (not (equal? (marks ind 0) current-marks))
		     (snd-display #__line__ ";scaling changed marks: ~A ~A" (marks ind 0) current-marks))
		 (if (not (equal? (map mark-sample (marks ind 0)) current-samples))
		     (snd-display #__line__ ";scaling changed mark locations: ~A ~A" (map mark-sample (marks ind 0)) current-samples)))
		((4) (set! (sample (random (- (frames) 1))) .5)
		 (if (not (equal? (marks ind 0) current-marks))
		     (snd-display #__line__ ";set-sample changed marks: ~A ~A" (marks ind 0) current-marks))
		 (if (not (equal? (map mark-sample (marks ind 0)) current-samples))
		     (snd-display #__line__ ";set-sample changed mark locations: ~A ~A" (map mark-sample (marks ind 0)) current-samples)))
		((5) (let* ((beg (random (frames)))
			    (dur (max 1 (random 100)))
			    (end (+ beg dur)))
		       (delete-samples beg dur)
		       (if (not (null? current-marks))
			   (for-each
			    (lambda (id old-loc)
			      (if (and (> old-loc beg)
				       (< old-loc end)
				       (mark? id))
				  (snd-display #__line__ ";delete did not clobber mark: ~A ~A [~A ~A]" id old-loc beg end)
				  (if (and (> old-loc end)
					   (not (= (mark-sample id) (- old-loc dur))))
				      (snd-display #__line__ ";delete ripple mark ~D ~D -> ~D (~D)" id old-loc (mark-sample id) dur)
				      (if (and (< old-loc beg)
					       (not (= (mark-sample id) old-loc)))
					  (snd-display #__line__ ";delete but mark before: ~A ~A ~A ~A" id old-loc (mark-sample id) beg)))))
			    current-marks
			    current-samples))))
		((6) (revert-sound))
		((7) (if (and (not (null? current-marks))
			      (> (length current-marks) 1))
			 (let ((id (list-ref current-marks (random (- (length current-marks) 1)))))
			   (delete-mark id)
			   (if (mark? id)
			       (snd-display #__line__ ";delete-mark failed? ~A" id))
			   (if (not (= (length (marks ind 0)) (- (length current-marks) 1)))
			       (snd-display #__line__ ";delete-mark list trouble: ~A ~A ~A" id current-marks (marks ind 0))))))
		((8) (let ((rate (if (> (frames) 200000) 2.0 0.5)))
		       (src-channel rate)
		       (if (not (null? current-marks))
			   (for-each
			    (lambda (id old-loc)
			      (if (not (mark? id))
				  (snd-display #__line__ ";src-channel clobbered mark: ~A" id)
				  (if (> (abs (- (/ old-loc rate) (mark-sample id))) 2)
				      (snd-display #__line__ ";src moved mark: ~A ~A ~A (~A -> ~A)" 
						   id old-loc (mark-sample id) rate (- (/ old-loc rate) (mark-sample id))))))
			    current-marks
			    current-samples))))
		((9) (reverse-channel)
		 (if (not (null? current-marks))
		     (for-each
		      (lambda (id old-loc)
			(if (not (mark? id))
			    (snd-display #__line__ ";reverse-channel clobbered mark: ~A" id)
			    (if (> (abs (- (- (frames) old-loc) (mark-sample id))) 2)
				(snd-display #__line__ ";reverse moved mark: ~A ~A ~A (~A)" 
					     id old-loc (- (frames) old-loc) (mark-sample id)))))
		      current-marks
		      current-samples)))
		(else (add-mark (random (- (frames) 1)))))))
	  (close-sound ind))
	
	(if (and (provided? 'snd-motif) (provided? 'xm)) (mark-sync-color "blue"))
	(let ((ind (open-sound "oboe.snd")))
	  (let ((m0 (add-mark 4321)))
	    (delete-sample 100)
	    (let ((m1 (add-mark 1234)))
	      (let ((val0 (describe-mark m0))
		    (val1 (describe-mark m1)))
		(if (or (not (equal? (list-ref (car val0) 0) m0))
			(not (equal? (list-ref (car val0) 2) ind))
			(not (= (list-ref (car val0) 5) 0))
			(not (= (list-ref val0 1) 4321))
			(not (= (list-ref val0 2) 4320)))
		    (snd-display #__line__ ";describe-mark m0: ~A" val0))
		(if (or (not (equal? (list-ref (car val1) 0) m1))
			(not (equal? (list-ref (car val1) 2) ind))
			(not (= (list-ref (car val1) 5) 0))
			(not (eq? (list-ref val1 1) #f))
			(not (= (list-ref val1 2) 1234)))
		    (snd-display #__line__ ";describe-mark m1: ~A" val1))
		(delete-mark m0)
		(delete-sample 5000)
		(set! val0 (describe-mark m0))
		(set! val1 (describe-mark m1))
		(if (or (not (equal? (list-ref (car val0) 0) m0))
			(not (equal? (list-ref (car val0) 2) ind))
			(not (= (list-ref (car val0) 5) 0))
			(not (= (list-ref val0 1) 4321))
			(not (eq? (list-ref val0 2) #f))
			(not (eq? (list-ref val0 3) #f)))
		    (snd-display #__line__ ";describe-mark m0 [1]: ~A" val0))
		(if (or (not (equal? (list-ref (car val1) 0) m1))
			(not (equal? (list-ref (car val1) 2) ind))
			(not (= (list-ref (car val1) 5) 0))
			(not (eq? (list-ref val1 1) #f))
			(not (= (list-ref val1 2) 1234))
			(not (= (list-ref val1 3) 1234)))
		    (snd-display #__line__ ";describe-mark m1 [1]: ~A" val1)))))
	  (revert-sound ind)
	  (add-hook! draw-mark-hook (lambda (id) #t))
	  (let ((m0 (add-mark 4321))
		(m1 (add-mark 1234))
		(dur (/ (frames ind) (srate ind))))
	    (pad-marks (list m0 m1) .01)
	    (if (fneq (/ (frames ind) (srate ind)) (+ dur .02))
		(snd-display #__line__ ";pad-marks: ~A ~A" dur (/ (frames ind) (srate ind))))
	    (if (and (not (= (mark-sample m0) 4763)) 
		     (not (= (mark-sample m0) 4761)))
		(snd-display #__line__ ";pad-marks m0 pos: ~A" (mark-sample m0)))
	    (if (fneq (sample 1235) 0.0) (snd-display #__line__ ";pad-marks 1235: ~A" (sample 1235))))
	  (close-sound ind))
	(reset-hook! draw-mark-hook)
	(let ((ind (open-sound "oboe.snd")))
	  (if (forward-mark) (snd-display #__line__ ";forward-mark when no marks: ~A" (forward-mark)))
	  (if (backward-mark) (snd-display #__line__ ";backward-mark when no marks: ~A" (backward-mark)))
	  (if (find-mark 12345) (snd-display #__line__ ";find-mark when no marks: ~A" (find-mark 12345)))
	  (let ((m0 (add-mark 123 ind 0)))
	    (delete-sample 0)
	    (let ((m1 (add-mark 23 ind 0)))
	      (set! (mark-name m1) "23")
	      (delete-sample 0)
	      (let ((m00 (find-mark 123 ind 0 0))
		    (m01 (find-mark "23"))
		    (m02 (find-mark 121)))
		(if (not m00) (snd-display #__line__ ";can't find 00th mark"))
		(if (not m01) (snd-display #__line__ ";can't find 01th mark"))
		(if (not m02) (snd-display #__line__ ";can't find 02th mark"))
		(delete-mark (find-mark "23"))
		(scale-by 2.0)
		(set! m1 (add-mark 1234))
		(set! (mark-name m1) "23")
		(let ((m10 (find-mark "23"))
		      (m11 (find-mark "23" ind 0 1))
		      (m12 (find-mark "23" ind 0 2)))
		  (if (not m10) (snd-display #__line__ ";can't find 10th mark")
		      (if (not (= (mark-sample m10) 1234)) (snd-display #__line__ ";mark 10th: ~A" (mark-sample m10))))
		  (if (not m11) (snd-display #__line__ ";can't find 11th mark")
		      (if (not (= (mark-sample m11 1) 23)) (snd-display #__line__ ";mark 11th: ~A" (mark-sample m11 1))))
		  (if (mark? m12) (snd-display #__line__ ";found 12th mark: ~A ~A ~A" m12 (mark-sample m12 2) (mark-name m12 2)))))
	      (set! (mark-name m1) #f)))
	  (close-sound ind))
	(if (provided? 'snd-debug)
	    (let ((ind (open-sound "oboe.snd")))
	      (let ((m0 (add-mark 1223 ind 0)))
		(internal-test-control-drag-mark ind 0 m0)
		(if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";test C-drag mark failed?")))
	      (close-sound ind)))
	(if (string? sf-dir)
	    (let ((ind (open-sound (string-append sf-dir "forest.aiff"))))
	      (mark-loops)
	      (let ((pos (map mark-sample (marks ind 0))))
		(if (not (equal? pos (list 24981 144332)))
		    (snd-display #__line__ ";forest marked loops: ~A ~A" (marks ind 0) pos)))
	      (close-sound ind)))
	
	))
    
    (let ((ind (open-sound "oboe.snd")))
      (add-mark 123)
      (add-mark 234 ind 0 "hiho" 1)
      (add-mark 345 ind 0 #f 1)
      (add-mark 456 ind 0 "a mark" 2)
      (add-mark 567 ind 0 #f 1)
      (save-marks ind "oboe.marks")
      (close-sound ind)
      (set! ind (open-sound "oboe.snd"))
      (add-mark 1 ind 0 "new mark" 1)
      (load (string-append cwd "oboe.marks"))
      (let ((m (find-mark 123 ind 0)))
	(if (not (mark? m)) 
	    (snd-display #__line__ ";save marks missed 123?")
	    (begin
	      (if (not (= (string-length (mark-name m)) 0)) (snd-display #__line__ ";saved mark 123 name: ~A" (mark-name m)))
	      (if (not (= (mark-sync m) 0)) (snd-display #__line__ ";saved mark 123 sync: ~A" (mark-sync m))))))
      (let ((m1-sync 0))
	(let ((m (find-mark 234 ind 0)))
	  (if (not (mark? m)) 
	      (snd-display #__line__ ";save marks missed 234?")
	      (begin
		(if (not (string=? (mark-name m) "hiho")) (snd-display #__line__ ";saved mark 234 name: ~A" (mark-name m)))
		(if (or (= (mark-sync m) 0) (= (mark-sync m) 1)) (snd-display #__line__ ";saved mark 234 sync: ~A" (mark-sync m)))
		(set! m1-sync (mark-sync m)))))
	(let ((m (find-mark 345 ind 0)))
	  (if (not (mark? m)) 
	      (snd-display #__line__ ";save marks missed 345?")
	      (begin
		(if (not (= (string-length (mark-name m)) 0)) (snd-display #__line__ ";saved mark 345 name: ~A" (mark-name m)))
		(if (not (= (mark-sync m) m1-sync)) (snd-display #__line__ ";saved mark 345 sync: ~A ~A" (mark-sync m) m1-sync)))))
	(let ((m (find-mark 567 ind 0)))
	  (if (not (mark? m)) 
	      (snd-display #__line__ ";save marks missed 567?")
	      (begin
		(if (not (= (string-length (mark-name m)) 0)) (snd-display #__line__ ";saved mark 567 name: ~A" (mark-name m)))
		(if (not (= (mark-sync m) m1-sync)) (snd-display #__line__ ";saved mark 567 sync: ~A ~A" (mark-sync m) m1-sync)))))
	(let ((m (find-mark 456 ind 0)))
	  (if (not (mark? m)) 
	      (snd-display #__line__ ";save marks missed 456?")
	      (begin
		(if (not (string=? (mark-name m) "a mark")) (snd-display #__line__ ";saved mark 456 name: ~A" (mark-name m)))
		(if (or (= (mark-sync m) m1-sync) 
			(= (mark-sync m) 0)
			(= (mark-sync m) 1))
		    (snd-display #__line__ ";saved mark 456 sync: ~A ~A" (mark-sync m) m1-sync)))))
	)
      (delete-file "oboe.marks")
      
      (let ((ind1 (open-sound "2a.snd")))
	(add-mark 1 ind1 0)
	(add-mark 2 ind1 1)
	(add-mark 3 ind1 0 "hi3")
	(add-mark 6 ind1 1 "hi6")
	(add-mark 4 ind1 0 #f 4)
	(add-mark 8 ind1 1 #f 5)
	(add-mark 5 ind1 0 #f 9)
	(add-mark 10 ind1 1 #f 9)
	(add-mark 20 ind1 0 #f 12)
	(add-mark 40 ind1 1 #f 12)
	(add-mark 60 ind1 1 #f 12)
	(save-marks ind1 "test.marks")
	(close-sound ind)
	(close-sound ind1))
      
      (set! ind (open-sound "2a.snd"))
      (load (string-append cwd "test.marks"))
      
      (let ((m1 (find-mark 1 ind 0))
	    (m2 (find-mark 2 ind 1)))
	(if (or (not (mark? m1)) (not (mark? m2))) 
	    (snd-display #__line__ ";save-marks 2a 1,2: ~A ~A" m1 m2)
	    (if (or (not (= (mark-sync m1) 0)) (not (= (mark-sync m2) 0)))
		(snd-display #__line__ ";save-marks 2a 1,2 syncs: ~A ~A" (mark-sync m1) (mark-sync m2)))))
      (let ((m1 (find-mark 5 ind 0))
	    (m2 (find-mark 10 ind 1)))
	(if (or (not (mark? m1)) (not (mark? m2))) 
	    (snd-display #__line__ ";save-marks 2a 5,10: ~A ~A" m1 m2)
	    (if (or (= (mark-sync m1) 0)
		    (not (= (mark-sync m1) (mark-sync m2))))
		(snd-display #__line__ ";save-marks 2a 5,10 syncs: ~A ~A" (mark-sync m1) (mark-sync m2)))))
      (let ((m1 (find-mark 4 ind 0))
	    (m2 (find-mark 8 ind 1))
	    (m3 (find-mark 5 ind 0)))
	(if (or (not (mark? m1)) (not (mark? m2))) 
	    (snd-display #__line__ ";save-marks 2a 4,8: ~A ~A" m1 m2)
	    (if (or (= (mark-sync m1) 0)
		    (= (mark-sync m2) 0)
		    (= (mark-sync m1) (mark-sync m2))
		    (= (mark-sync m1) (mark-sync m3)))
		(snd-display #__line__ ";save-marks 2a 4,8 syncs: ~A ~A ~A" (mark-sync m1) (mark-sync m2) (mark-sync m3)))))
      (let ((m1 (find-mark 3 ind 0))
	    (m2 (find-mark 6 ind 1)))
	(if (or (not (mark? m1)) (not (mark? m2))) 
	    (snd-display #__line__ ";save-marks 2a 3,6: ~A ~A" m1 m2)
	    (begin
	      (if (or (not (= (mark-sync m1) 0)) (not (= (mark-sync m2) 0)))
		  (snd-display #__line__ ";save-marks 2a 3,6 syncs: ~A ~A" (mark-sync m1) (mark-sync m2)))
	      (if (not (string=? (mark-name m1) "hi3")) (snd-display #__line__ ";save-marks 2a 3 name: ~A" (mark-name m1)))
	      (if (not (string=? (mark-name m2) "hi6")) (snd-display #__line__ ";save-marks 2a 6 name: ~A" (mark-name m2))))))
      (let ((m1 (find-mark 4 ind 0))
	    (m2 (find-mark 5 ind 0))
	    (m3 (find-mark 20 ind 0))
	    (m4 (find-mark 40 ind 1))
	    (m5 (find-mark 60 ind 1)))
	(if (or (not (mark? m3)) (not (mark? m4)) (not (mark? m5)))
	    (snd-display #__line__ ";save-marks 2a 20...: ~A ~A ~A" m3 m4 m5)
	    (if (or (= (mark-sync m3) 0)
		    (= (mark-sync m1) (mark-sync m3))
		    (= (mark-sync m2) (mark-sync m3))
		    (not (= (mark-sync m3) (mark-sync m4) (mark-sync m5))))
		(snd-display #__line__ ";save-marks 2a 10... syncs: ~A ~A ~A" (mark-sync m3) (mark-sync m4) (mark-sync m5)))))
      (delete-file "test.marks")
      (close-sound ind))
    
    (let ((ind (new-sound :size 1000)))
      (add-mark 123)
      (add-mark 234 ind 0 "hiho" 1)
      (add-mark 345 ind 0 #f 1)
      (add-mark 456 ind 0 "a mark" 2)
      (add-mark 567 ind 0 #f 1)
      
      (add-hook! output-comment-hook (lambda (str) (marks->string (selected-sound))))
      (save-sound-as "tst.snd")
      (let ((new-file-name (file-name ind)))
	(close-sound ind)
	(if (file-exists? new-file-name) (delete-file new-file-name)))
      (set! ind (open-sound "tst.snd"))
      (reset-hook! output-comment-hook)
      
      (eval-header ind)
      (let ((ms (marks ind 0)))
	(if (not (= (length ms) 5)) (snd-display #__line__ ";eval-header + marks->string: ~A" ms))
	(let ((samps (map mark-sample ms)))
	  (if (or (not (member 123 samps))
		  (not (member 567 samps)))
	      (snd-display #__line__ ";eval marked header samps: ~A" samps)))
	(if (not (find-mark 234)) (snd-display #__line__ ";eval mark header no mark at 234?"))
	(if (mark? (find-mark 456))
	    (if (not (= (mark-sync (find-mark 456)) 2)) 
		(snd-display #__line__ ";eval mark header sync: ~A" (mark-sync (find-mark 456))))
	    (snd-display #__line__ ";no mark at 456")))
      
      (close-sound ind)
      (mus-sound-forget "tst.snd")
      (delete-file "tst.snd"))
    
    ;; mark-explode
    (let ((ind (new-sound :size 31))
	  (ctr -1))
      (map-channel (lambda (y) (set! ctr (+ 1 ctr)) (if (< ctr 10) .1 (if (< ctr 20) .4 .8))))
      (add-mark 10)
      (add-mark 20)
      (add-mark 30)
      (mark-explode)
      (if (file-exists? "mark-0.snd")
	  (let ((ind1 (open-sound "mark-0.snd")))
	    (if (not (= (frames ind1 0) 10)) (snd-display #__line__ ";mark-0 frames: ~A" (frames ind1 0)))
	    (if (not (vequal (channel->vct) (make-vct 10 .1))) (snd-display #__line__ ";mark-0 vals: ~A" (channel->vct)))
	    (close-sound ind1)
	    (delete-file "mark-0.snd"))
	  (snd-display #__line__ ";mark-explode did not write mark-0.snd?"))
      (if (file-exists? "mark-1.snd")
	  (let ((ind1 (open-sound "mark-1.snd")))
	    (if (not (= (frames ind1 0) 10)) (snd-display #__line__ ";mark-1 frames: ~A" (frames ind1 0)))
	    (if (not (vequal (channel->vct) (make-vct 10 .4))) (snd-display #__line__ ";mark-1 vals: ~A" (channel->vct)))
	    (close-sound ind1)
	    (delete-file "mark-1.snd"))
	  (snd-display #__line__ ";mark-explode did not write mark-1.snd?"))
      (if (file-exists? "mark-2.snd")
	  (let ((ind1 (open-sound "mark-2.snd")))
	    (if (not (= (frames ind1 0) 10)) (snd-display #__line__ ";mark-2 frames: ~A" (frames ind1 0)))
	    (if (not (vequal (channel->vct) (make-vct 10 .8))) (snd-display #__line__ ";mark-2 vals: ~A" (channel->vct)))
	    (close-sound ind1)
	    (delete-file "mark-2.snd"))
	  (snd-display #__line__ ";mark-explode did not write mark-2.snd?"))
      (if (file-exists? "mark-3.snd") (snd-display #__line__ ";mark-explode wrote too many files?"))
      (let ((name (file-name ind)))
	(close-sound ind)
	(if (file-exists? name) (delete-file name))))
    
    ))


;;; ---------------- test 11: dialogs ----------------

(defvar env1 '(0 0 1 0))
(defvar env2 '(0 0 1 1))
(defvar ramp-up-env '(0 0 1 1))
(define-envelope env4 '(0 1 1 0))

(define (snd_test_11)
  (define (string-equal-ignoring-white-space s1 s2)
    (let ((len1 (string-length s2)))
      (define (white-space? str pos)
	(or (char=? (string-ref str pos) #\space)
	    (char=? (string-ref str pos) #\newline)))
      (call-with-exit
       (lambda (return)
	 (do ((i 0)
	      (j 0))
	     ((= i len1) (begin (while (and (< j len1) (white-space? s2 j)) (set! j (+ j 1))) (= j len1)))
	   (if (char=? (string-ref s1 i) (string-ref s2 j))
	       (begin
		 (set! i (+ i 1))
		 (set! j (+ j 1)))
	       (begin
		 (while (and (< i len1) (white-space? s1 i)) (set! i (+ i 1)))
		 (while (and (< j len1) (white-space? s2 j)) (set! j (+ j 1)))
		 (if (not (char=? (string-ref s1 i) (string-ref s2 j)))
		     (return #f)))))))))
  
  (if with-gui
      
      (begin
	
	(without-errors (peaks))
	(let ((envd (enved-dialog) ))
	  (let ((cold (color-orientation-dialog))
		(trd (transform-dialog))
		(fild (view-files-dialog))
		(regd (view-regions-dialog))
		(pd (and (not (provided? 'cairo)) (print-dialog)))
		(ehd (without-errors (edit-header-dialog))))
	    (open-file-dialog #f)
	    (mix-file-dialog #f)
	    (insert-file-dialog #f)
	    (help-dialog "Test" "snd-test here")
	    (save-envelopes "hiho.env")
	    (load (string-append cwd "hiho.env"))
	    (if (not (equal? env4 (list 0.0 1.0 1.0 0.0))) (snd-display #__line__ ";save-envelopes: ~A?" env4))
	    (delete-file "hiho.env")
	    (help-dialog "test2" "this is the next test" 
			 (list "string 1{open-sound}" "{env-sound}string2" "string{close-sound}3")
			 (list "extsnd.html#sndopen" "extsnd.html#sndenv" "extsnd.html#sndclose"))
	    (dismiss-all-dialogs)
	    ))
	
	(let ((ind (open-sound "oboe.snd")))
	  (edit-header-dialog ind)
	  (dismiss-all-dialogs)
	  (close-sound ind))
	(if (not (string=? (snd-url 'open-sound) "extsnd.html#opensound"))
	    (snd-display #__line__ ";snd-url 'open-sound: ~A" (snd-url 'open-sound)))
	(if (not (string=? (snd-url "open-sound") "extsnd.html#opensound"))
	    (snd-display #__line__ ";snd-url \"open-sound\": ~A" (snd-url "open-sound")))
	(if (not (list? (snd-urls))) (snd-display #__line__ ";snd-urls: ~A" (snd-urls)))
	(let ((str1 (snd-help open-sound))
	      (str2 (snd-help 'open-sound))
	      (str3 (snd-help "open-sound")))
	  (if (or (not (string? str1)) ; can happen if we're running -DTIMING
		  (not (string? str2))
		  (not (string? str3))
		  (not (string-equal-ignoring-white-space str2 str3)))
	      (snd-display #__line__ ";snd-help open-sound: ~A ~A ~A" str1 str2 str3)))
					;	(if (not (string? (snd-help 'open-soud)))
					;	    (snd-display #__line__ ";snd-help open-soud (misspelled on purpose) failed"))
	(if (not (string-equal-ignoring-white-space (snd-help enved-base) "(enved-base): envelope editor exponential base value (1.0)"))
	    (snd-display #__line__ ";snd-help enved-base: ~A?" (snd-help enved-base)))
	(if (not (string-equal-ignoring-white-space (snd-help 'enved-base) "(enved-base): envelope editor exponential base value (1.0)"))
	    (snd-display #__line__ ";snd-help 'enved-base: ~A?" (snd-help 'enved-base)))
	(if (not (string-equal-ignoring-white-space (snd-help "enved-base") "(enved-base): envelope editor exponential base value (1.0)"))
	    (snd-display #__line__ ";snd-help \"enved-base\": ~A?" (snd-help "enved-base")))
	(let ((old-val hamming-window))
	  (let ((str1 (snd-help 'hamming-window))
		(str2 (snd-help "hamming-window")))
	    (if (or (not (string? str1)) (not (string? str2))
		    (not (string-equal-ignoring-white-space str1 str2))
		    (not (string-equal-ignoring-white-space str1 "A raised cosine")))
		(snd-display #__line__ ";snd-help hamming-window: ~A ~A" str1 str2)))
	  (if (or (not (number? hamming-window))
		  (not (= hamming-window old-val)))
	      (snd-display #__line__ ";snd-help clobbered out-of-module variable: ~A ~A" old-value hamming-window)))
	(let ((vals (snd-urls)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 25)) ; need to cycle the 8's
	    (if (defined? (string->symbol (car (list-ref vals i))))
		(snd-help (car (list-ref vals i)) #f))))
	
	(set! (show-indices) #t)
	(let ((ind (open-sound "oboe.snd")))
	  (if (< (length (sound-widgets ind)) 4)
	      (snd-display #__line__ ";sound-widgets: ~A?" (sound-widgets ind)))
	  (report-in-minibuffer "hi there" ind)
	  (if with-gui
	      (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		(if (not (string=? str "hi there"))
		    (snd-display #__line__ ";report-in-minibuffer: ~A?" str))))
	  (if with-gui
	      (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		(if (not (string=? str "hi there"))
		    (snd-display #__line__ ";report-in-minibuffer 1: ~A?" str))
		(if (widget-text (cadr (main-widgets))) 
		    (snd-display #__line__ ";widget text should be #f: ~A" (widget-text (cadr (main-widgets)))))
		(let ((str (format #f "~A: ~A" (sound->integer ind) (short-file-name ind)))
		      (txt (widget-text (cadr (sound-widgets ind)))))
		  (if (or (not (string? txt))
			  (not (string=? str txt)))
		      (snd-display #__line__ ";name text: ~A ~A" str txt)))))
	  (clear-minibuffer)
	  (close-sound ind))
	(if (file-exists? "link-oboe.snd")
	    (let* ((ind (open-sound "link-oboe.snd"))
		   (linked-str (format #f "~A: (~A)" (sound->integer ind) (short-file-name ind))))
	      (if with-gui
		  (if (not (string=? linked-str (widget-text (cadr (sound-widgets ind)))))
		      (snd-display #__line__ ";linked name text: ~A ~A" linked-str (widget-text (cadr (sound-widgets ind))))))
	      (if (and (provided? 'xm) (provided? 'snd-debug))
		  (XtCallCallbacks (cadr (sound-widgets ind)) XmNactivateCallback (snd-sound-pointer ind)))
	      (close-sound ind)))
	(set! (show-indices) #f)
	(if (file-exists? "link-oboe.snd")
	    (let* ((ind (open-sound "link-oboe.snd"))
		   (linked-str (format #f "(~A)" (short-file-name ind))))
	      (if with-gui
		  (if (not (string=? linked-str (widget-text (cadr (sound-widgets ind)))))
		      (snd-display #__line__ ";linked name text (no index): ~A ~A" linked-str (widget-text (cadr (sound-widgets ind))))))
	      (close-sound ind)))
	
	(define-envelope test-ramp '(0 0 1 1))
	(if (not (equal? test-ramp '(0 0 1 1))) (snd-display #__line__ ";define-envelope test-ramp: ~A" test-ramp))
	(define-envelope test-ramp '(0 1 1 0))
	(if (not (equal? test-ramp '(0 1 1 0))) (snd-display #__line__ ";re-define-envelope test-ramp: ~A" test-ramp))
	
	(if (or (provided? 'xm) (provided? 'xg))
	    (begin
	      (load "oscope.scm")
	      ;; oscope exists
	      (if (not (sound-data? (cadr oscope))) (snd-display #__line__ ";oscope: ~A" oscope))
	      (if (provided? 'snd-motif)
		  (XtUnmanageChild oscope-dialog)
		  (gtk_widget_hide oscope-dialog))))
	
	(let ((dialog (view-files-dialog #f)))
	  (let ((vfamp (view-files-amp dialog))
		(vfs (view-files-speed dialog))
		(vfsort (view-files-sort))
		(vfsort1 (view-files-sort dialog))
		(vfe (view-files-amp-env dialog))
		(vffiles (view-files-files dialog))
		(vfsel (view-files-selected-files dialog))
		(selected-file #f))
	    (if (fneq vfamp 1.0) (snd-display #__line__ ";vf amp: ~A" vfamp))
	    (if (fneq vfs 1.0) (snd-display #__line__ ";vf spd: ~A" vfs))
	    (if (not (= vfsort 0)) (snd-display #__line__ ";vf sort: ~A" vfsort))
	    (if (not (= vfsort1 0)) (snd-display #__line__ ";vf sort(d): ~A" vfsort1))
	    (if (not (feql vfe (list 0.0 1.0 1.0 1.0))) (snd-display #__line__ ";vf amp env: ~A" vfe))
	    (if (not (list? vffiles)) (snd-display #__line__ ";vf files: ~A" vffiles))
	    (if (not (list? vfsel)) (snd-display #__line__ ";vf selected files: ~A" vfsel))
	    (if (not (= (view-files-speed-style dialog) (speed-control-style)))
		(snd-display #__line__ ";vf speed-style def: ~A ~A" (view-files-speed-style dialog) (speed-control-style)))
	    (set! (view-files-amp dialog) 0.5)
	    (if (fneq (view-files-amp dialog) 0.5) (snd-display #__line__ ";set vf amp: ~A" (view-files-amp dialog)))
	    (set! (view-files-speed dialog) 0.5)
	    (if (fneq (view-files-speed dialog) 0.5) (snd-display #__line__ ";set vf spd: ~A" (view-files-speed dialog)))
	    (set! (view-files-speed-style dialog) speed-control-as-ratio)
	    (if (not (= (view-files-speed-style dialog) speed-control-as-ratio))
		(snd-display #__line__ ";vf speed-style set: ~A" (view-files-speed-style dialog)))
	    (set! (view-files-sort dialog) 2)
	    (if (not (= (view-files-sort) 0)) (snd-display #__line__ ";vf global sort after local set: ~A" (view-files-sort)))
	    (if (not (= (view-files-sort dialog) 2)) (snd-display #__line__ ";vf local sort after local set: ~A" (view-files-sort dialog)))
	    (set! (view-files-sort) 4)
	    (if (not (= (view-files-sort) 4)) (snd-display #__line__ ";vf global sort after global set: ~A" (view-files-sort)))    
	    (if (not (= (view-files-sort dialog) 2)) (snd-display #__line__ ";vf local sort after global set: ~A" (view-files-sort dialog)))
	    (set! (view-files-files dialog) (list "oboe.snd" "1a.snd" "pistol.snd" "storm.snd"))
	    (let ((vf-files (view-files-files dialog)))
	      (if (or (and (not (member "1a.snd" vf-files))
			   (not (member (string-append home-dir "/cl/1a.snd") vf-files))
			   (not (member (string-append home-dir "/snd-11/1a.snd") vf-files)))
		      (and (not (member "pistol.snd" vf-files))
			   (not (member (string-append home-dir "/cl/pistol.snd") vf-files))
			   (not (member (string-append home-dir "/snd-11/pistol.snd") vf-files)))
		      (not (= (length vf-files) 4)))
		  (snd-display #__line__ ";vf files set: ~A (~A, ~A)" vf-files (string-append home-dir "/cl/1a.snd") (length vf-files))))
	    (reset-hook! view-files-select-hook)
	    (add-hook! view-files-select-hook (lambda (w file)
						(if (not (string? file))
						    (snd-display #__line__ ";vf select hook arg: ~A" file))
						(if (not w) (snd-display #__line__ ";vf select hook dialog: ~A" w))
						(set! selected-file file)))
	    (set! (view-files-selected-files dialog) (list "1a.snd"))
	    (if (or (not (string? selected-file))
		    (and (not (equal? selected-file "1a.snd"))
			 (not (equal? selected-file (string-append home-dir "/cl/1a.snd")))
			 (not (equal? selected-file (string-append home-dir "/snd-11/1a.snd")))))
		(snd-display #__line__ ";vf set selected select hook arg: ~A" selected-file))
	    (if (and (not (equal? (view-files-selected-files dialog) (list "1a.snd")))
		     (not (equal? (view-files-selected-files dialog) (list (string-append home-dir "/cl/1a.snd"))))
		     (not (equal? (view-files-selected-files dialog) (list (string-append home-dir "/snd-11/1a.snd")))))
		(snd-display #__line__ ";vf selected files set: ~A" (view-files-selected-files dialog)))
	    (hide-widget dialog)
	    ))
	
	)))

;;; ---------------- test 12: extensions ----------------

(define (snd_test_12)
  
  (define (spectral-difference snd1 snd2)
    (let* ((size (max (frames snd1) (frames snd2)))
	   (pow2 (ceiling (/ (log size) (log 2))))
	   (fftlen (expt 2 pow2))
	   (fdr1 (make-vct fftlen))
	   (fdr2 (make-vct fftlen)) )
      (samples->vct 0 fftlen snd1 0 fdr1)
      (samples->vct 0 fftlen snd2 0 fdr2)
      (let* ((spectr1 (snd-spectrum fdr1 blackman2-window fftlen #t))
	     (spectr2 (snd-spectrum fdr2 blackman2-window fftlen #t))
	     (diff 0.0)
	     (diffs (vct-subtract! spectr1 spectr2))
	     (len (vct-length diffs)))
	(do ((i 0 (+ 1 i)))
	    ((= i len) diff)
	  (set! diff (+ diff (abs (vct-ref diffs i))))))))
  
  (define (test-spectral-difference snd1 snd2 maxok)
    (let ((s1 (open-sound snd1))
	  (s2 (open-sound snd2)))
      (if (or (not (sound? s1))
	      (not (sound? s2)))
	  (snd-display #__line__ ";open-sound ~A or ~A failed?" snd1 snd2))
      (let ((diff (spectral-difference s1 s2)))
	(close-sound s1)
	(close-sound s2)
	(if (> diff maxok)
	    (snd-display #__line__ ";translate spectral difference ~A ~A: ~A > ~A?" snd1 snd2 diff maxok)))))
  
  
  (define (remove-if p l)
    (cond ((null? l) '())
	  ((p (car l)) (remove-if p (cdr l)))
	  (else (cons (car l) (remove-if p (cdr l))))))
  
  
  (if (null? (sound-file-extensions))
      (set! (sound-file-extensions) original-sound-file-extensions))
  
  (let* ((sf-dir-files
	  (if (string? sf-dir) 
	      (let ((good-files '()))
		(for-each ; omit bad headers (test cases) 
		 (lambda (file)
		   (catch 'mus-error
			  (lambda () 
			    (if (and (< (mus-sound-chans (string-append sf-dir file)) 256)
				     (> (mus-sound-chans (string-append sf-dir file)) 0)
				     (>= (mus-sound-data-format (string-append sf-dir file)) 0)
				     (> (mus-sound-srate (string-append sf-dir file)) 0)
				     (>= (mus-sound-frames (string-append sf-dir file)) 0))
				(set! good-files (cons file good-files))))
			  (lambda args 
			    (car args))))
		 (sound-files-in-directory sf-dir))
		good-files)
	      #f))
	 
	 (sf-dir-len (if sf-dir-files (length sf-dir-files) 0)))
    
    (if with-gui
	(if (> sf-dir-len 0)
	    (let ((open-files '())
		  (open-ctr 0))
	      
	      (add-sound-file-extension "wave")
	      (let ((exts (sound-file-extensions)))
		(if (not (member "wave" exts))
		    (snd-display #__line__ ";sound-file-extensions: ~A" exts))
		(set! (sound-file-extensions) (list))
		(if (not (null? (sound-file-extensions)))
		    (snd-display #__line__ ";sound-file-extesions set to '(): ~A" (sound-file-extensions)))
		(set! (sound-file-extensions) exts)
		(if (not (member "wave" exts))
		    (snd-display #__line__ ";sound-file-extensions reset: ~A" (sound-file-extensions))))
	      
	      (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests)) 
		(log-mem clmtest)
		
		(do ()
		    ((= open-ctr 32))
		  (let* ((len (length open-files))
			 (open-chance (* (- 8 len) .125))
			 (close-chance (* len .125)))
		    (if (or (= len 0) (> (random 1.0) .5))
			(let* ((choice (floor (random sf-dir-len)))
			       (name (string-append sf-dir (list-ref sf-dir-files choice)))
			       (ht (catch #t (lambda () (mus-sound-header-type name)) (lambda args 0)))
			       (df (catch #t (lambda () (mus-sound-data-format name)) (lambda args 0)))
			       (fd (if (or (= ht mus-raw)
					   (= ht mus-unsupported)
					   (= df mus-unknown))
				       -1 
				       (or (catch #t
						  (lambda () (view-sound name))
						  (lambda args
						    (snd-display #__line__ ";~A ~A ~A" name ht df)
						    -1))
					   -1))))
			  (if (not (equal? fd -1))
			      (begin
				(set! open-ctr (+ open-ctr 1))
				(set! open-files (cons fd open-files)))))
			(if (and (> len 0) (> (random 1.0) 0.3))
			    (let* ((choice (floor (random (exact->inexact (length open-files)))))
				   (fd (list-ref open-files choice)))
			      (close-sound fd)
			      (set! open-files (remove-if (lambda (a) (equal? a fd)) open-files)))))))
		(if open-files (for-each close-sound open-files))
		(set! open-files '())
		
		(if (not (= (length (sounds)) 0)) (snd-display #__line__ ";active-sounds: ~A ~A?" (sounds) (map short-file-name (sounds))))
		(let ((fd (open-raw-sound :file (string-append sf-dir "addf8.nh") :channels 1 :srate 8012 :data-format mus-mulaw)))
		  (if (not (= (data-format fd) mus-mulaw)) (snd-display #__line__ ";open-raw-sound: ~A?" (mus-data-format-name (data-format fd))))
		  (close-sound fd))
		
		(reset-hook! bad-header-hook)
		(time (test-spectral-difference "oboe.snd" (string-append sf-dir "oboe.g723_24") 20.0))
		(test-spectral-difference "oboe.snd" (string-append sf-dir "oboe.g723_40") 3.0)
		(test-spectral-difference "oboe.snd" (string-append sf-dir "oboe.g721") 6.0)
		(test-spectral-difference (string-append sf-dir "o2.wave") (string-append sf-dir "o2_dvi.wave") 10.0)
		(test-spectral-difference (string-append sf-dir "wood.riff") (string-append sf-dir "wood.sds") 4.0)
		(test-spectral-difference (string-append sf-dir "nist-10.wav") (string-append sf-dir "nist-shortpack.wav") 1.0)
		(add-hook! bad-header-hook (lambda (n) #t))
		
		;; dangling readers (overall)
		(let ((ind (open-sound "oboe.snd")))
		  (let ((hi (make-sampler 0 ind 0)))
		    (close-sound ind)
		    (if (not (sampler? hi)) (snd-display #__line__ ";dangling reader? ~A" hi))
		    (let ((name (format #f "~A" hi)))
		      (if (not (string? name)) (snd-display #__line__ ";dangling reader format: ~A" name)))
		    (let* ((val (hi))
			   (val1 (next-sample hi))
			   (val2 (previous-sample hi))
			   (val3 (read-sample hi)))
		      (if (or (fneq val 0.0) (fneq val1 0.0) (fneq val2 0.0) (fneq val3 0.0))
			  (snd-display #__line__ ";dangling read: ~A ~A ~A ~A" val val1 val2 val3))
		      (if (sampler-home hi) (snd-display #__line__ ";dangling reader home: ~A" (sampler-home hi)))
		      (if (not (= (sampler-position hi) 0)) (snd-display #__line__ ";dangling sampler-position: ~A" (sampler-position hi)))
		      (if (not (sampler-at-end? hi)) (snd-display #__line__ ";dangling reader eof: ~A" (sampler-at-end? hi)))
		      (free-sampler hi))))
		;; same (pruned edit)
		(let ((ind (open-sound "oboe.snd")))
		  (delete-samples 100 100)
		  (let ((hi (make-sampler 0 ind 0)))
		    (revert-sound)
		    (delete-samples 100 100)
		    (if (not (sampler? hi)) (snd-display #__line__ ";pruned dangling reader? ~A" hi))
		    (let ((name (format #f "~A" hi)))
		      (if (not (string? name)) (snd-display #__line__ ";pruned dangling reader format: ~A" name)))
		    (let* ((val (hi))
			   (val1 (next-sample hi))
			   (val2 (previous-sample hi))
			   (val3 (read-sample hi)))
		      (if (or (fneq val 0.0) (fneq val1 0.0) (fneq val2 0.0) (fneq val3 0.0))
			  (snd-display #__line__ ";pruned dangling read: ~A ~A ~A ~A" val val1 val2 val3))
		      (if (not (equal? (sampler-home hi) (list ind 0))) (snd-display #__line__ ";pruned dangling reader home: ~A" (sampler-home hi)))
		      (if (not (sampler-at-end? hi)) (snd-display #__line__ ";pruned dangling reader eof: ~A" (sampler-at-end? hi)))
		      (free-sampler hi)))
		  (close-sound ind))
		
		;; region reader
		(let ((ind (open-sound "2.snd")))
		  (set! (sync ind) 1)
		  (let ((reg (make-region 90 220 ind #t)))
		    (if (not (= (region-frames reg) (+ 1 (- 220 90)))) (snd-display #__line__ ";make-region frames: ~A" (region-frames reg)))
		    (if (not (= (region-chans reg) 2)) (snd-display #__line__ ";make-region chans: ~A" (region-chans reg)))
		    (if (not (= (region-frames reg 0) (+ 1 (- 220 90)))) (snd-display #__line__ ";make-region frames[0]: ~A" (region-frames reg 0)))
		    (if (not (= (region-frames reg 1) (+ 1 (- 220 90)))) (snd-display #__line__ ";make-region frames[1]: ~A" (region-frames reg 1)))
		    (if (not (= (region-position reg 0) 90)) (snd-display #__line__ ";make-region position[0]: ~A" (region-position reg 0)))
		    (if (not (= (region-position reg 1) 90)) (snd-display #__line__ ";make-region position[1]: ~A" (region-position reg 1)))
		    (if (not (= (region-position reg) 90)) (snd-display #__line__ ";make-region position[]: ~A" (region-position reg)))
		    
		    ;; beg = 0, chan 2 not highlighted
		    
		    (let ((rd1 (make-region-sampler reg 0 0))
			  (rd2 (make-region-sampler reg 100 1)))
		      (let ((rd11 (copy-sampler rd1))
			    (rd22 (copy-sampler rd2)))
			(if (or (not (region-sampler? rd11)) (not (region-sampler? rd22)))
			    (snd-display #__line__ ";copy-sampler (region): ~A ~A" rd11 rd22))
			(if (or (mix-sampler? rd11) (mix-sampler? rd22)
				(sampler? rd11) (sampler? rd22))
			    (snd-display #__line__ ";copy (region) sampler-p trouble: ~A ~A ~A ~A ~A ~A"
					 (mix-sampler? rd11) (mix-sampler? rd22)
					 (sampler? rd11) (sampler? rd22)))
			(if (or (not (equal? (sampler-home rd11) (list reg 0)))
				(not (equal? (sampler-home rd22) (list reg 1))))
			    (snd-display #__line__ ";copy region reader home: ~A ~A" (sampler-home rd11) (sampler-home rd22)))
			(if (or (sampler-at-end? rd11) (sampler-at-end? rd22))
			    (snd-display #__line__ ";copy region reader end?: ~A ~A" (sampler-at-end? rd11) (sampler-at-end? rd22)))
			(if (or (not (= (sampler-position rd11) (sampler-position rd1) 0))
				(not (= (sampler-position rd22) (sampler-position rd2) 100)))
			    (snd-display #__line__ ";copy region reader position: ~A ~A ~A ~A" 
					 (sampler-position rd11) (sampler-position rd1)
					 (sampler-position rd22) (sampler-position rd2)))
			(free-sampler rd1)
			(free-sampler rd11))))
		  (close-sound ind))
		
		(let* ((ind (open-sound "oboe.snd"))
		       (reg (make-region 1000 2000 ind 0))
		       (rd (make-region-sampler reg 0)))
		  (if (mix-sampler? rd) (snd-display #__line__ ";region sampler: mix ~A" rd))
		  (if (not (region-sampler? rd)) (snd-display #__line__ ";region sampler: region ~A" rd))
		  (if (sampler? rd) (snd-display #__line__ ";region sampler: normal ~A" rd))
					;(if (not (= (sampler-position rd) 0)) (snd-display #__line__ ";region sampler position: ~A" (sampler-position rd)))
		  (if (not (equal? (sampler-home rd) (list reg 0))) (snd-display #__line__ ";region sampler home: ~A" (sampler-home rd)))
		  (if (sampler-at-end? rd) (snd-display #__line__ ";region sampler at end?: ~A" (sampler-at-end? rd)))
		  (let ((val (rd)))
		    (if (fneq val .0328) (snd-display #__line__ ";region-sampler at start: ~A" val))
		    (if (not (string? (format #f "~A" rd))) (snd-display #__line__ ";region-sampler: ~A" (format #f "~A" rd)))
		    (close-sound ind)
		    (forget-region reg)
		    (set! val (read-sample rd))
		    (if (fneq val 0.0) (snd-display #__line__ ";region-sampler at end: ~A" val))
		    (if (not (sampler-at-end? rd)) (snd-display #__line__ ";region-sampler after deletion?"))
		    (free-sampler rd)))
		
		;; mix reader
		(let ((save-md 0))
		  (mix-click-sets-amp)
		  (let* ((ind (open-sound "oboe.snd"))
			 (reg (make-region 1000 2000 ind 0))
			 (md (car (mix-region reg 0 ind 0 0)))
			 (rd (make-mix-sampler md)))
		    (set! (mix-property :hi md) "hi")
		    (set! save-md md)
		    (if (not (string=? (mix-property :hi md) "hi")) (snd-display #__line__ ";mix(9)-property: ~A" (mix-property :hi md)))
		    (let ((val (rd)))
		      (if (fneq val .0328) (snd-display #__line__ ";mix-sampler at start: ~A" val))
		      (if (not (string? (format #f "~A" rd))) (snd-display #__line__ ";mix-sampler: ~A" (format #f "~A" rd)))
		      (close-sound ind)
		      (let ((tag (catch #t
					(lambda () (mix-property :hi md))
					(lambda args (car args)))))
			(if (not (eq? tag 'no-such-mix)) (snd-display #__line__ ";mix-property bad mix: ~A" tag)))
		      (let ((str (format #f "~A" rd)))
			(if (not (string=? str "#<mix-sampler: inactive>")) (snd-display #__line__ ";mix-sampler released: ~A" str))
			(free-sampler rd)))))
		(reset-hook! mix-click-hook)
		(reset-hook! close-hook)
		
		(let ((sfiles '())
		      (ffiles '()))
		  (for-each-sound-file 
		   (lambda (file) 
		     (if (> (mus-sound-chans file) 16)
			 (set! ffiles (cons file ffiles)))))
		  (map-sound-files
		   (lambda (file) 
		     (if (> (mus-sound-chans file) 16)
			 (set! sfiles (cons file sfiles)))))
		  (if (and (file-exists? "s24.snd")
			   (or (not (equal? ffiles (list "s24.snd")))
			       (not (equal? sfiles (list "s24.snd")))))
		      (snd-display #__line__ ";map|for-each-sound-file(s): ~A ~A" ffiles sfiles)))
		)
					;	      (if sf-dir-files
					;		  (for-each (lambda (n) (mus-sound-forget (string-append sf-dir n))) sf-dir-files))
	      
	      )))))




;;; ---------------- test 13: menus, edit lists, hooks, etc ----------------

(if (and (provided? 'snd-motif) (provided? 'xm)) (if (not (provided? 'snd-effects-utils.scm)) (load "effects-utils.scm")))
(if (and (provided? 'snd-motif) (provided? 'xm)) (if (not (provided? 'snd-new-effects.scm)) (load "new-effects.scm")))
(if (and (provided? 'snd-gtk) (provided? 'xg)) (if (not (provided? 'snd-gtk-effects.scm)) (load "gtk-effects.scm")))

(if (provided? 'snd-ladspa)
    (define (analyze-ladspa library label)
      (let* ((descriptor (ladspa-descriptor library label))
	     (data '())
	     (names (.PortNames descriptor))
	     (hints (.PortRangeHints descriptor))
	     (descriptors (.PortDescriptors descriptor))
	     (name (.Name descriptor))
	     (maker (.Maker descriptor))
	     (copy (.Copyright descriptor)))
	(for-each
	 (lambda (port ranges port-name)
	   (if (and (not (= (logand port LADSPA_PORT_CONTROL) 0))
		    (not (= (logand port LADSPA_PORT_INPUT) 0)))
	       (let ((ldata '())
		     (hint (car ranges))
		     (lo (cadr ranges))
		     (hi (caddr ranges)))
		 (if (not (= (logand hint LADSPA_HINT_TOGGLED) 0)) (set! ldata (cons "toggle" ldata)))
		 (if (not (= (logand hint LADSPA_HINT_LOGARITHMIC) 0)) (set! ldata (cons "logarithmic" ldata)))
		 (if (not (= (logand hint LADSPA_HINT_INTEGER) 0)) (set! ldata (cons "integer" ldata)))
		 (if (not (= (logand hint LADSPA_HINT_SAMPLE_RATE) 0)) (set! ldata (cons "sample_rate" ldata)))
		 (if (not (= (logand hint LADSPA_HINT_BOUNDED_ABOVE) 0)) 
		     (begin
		       (set! ldata (cons hi ldata))
		       (set! ldata (cons "maximum" ldata))))
		 (if (not (= (logand hint LADSPA_HINT_BOUNDED_BELOW) 0) )
		     (begin
		       (set! ldata (cons lo ldata))
		       (set! ldata (cons "minimum" ldata))))
		 (set! ldata (cons port-name ldata))
		 (set! data (cons ldata data)))))
	 descriptors hints names)
	(append (list name maker copy) data))))

(if (provided? 'snd-ladspa)
    (define* (ladspa-it library label :rest plugin-parameters)
      ;; (ladspa-it "delay" "delay_5s" .3 .5)
      (init-ladspa)
      (let* ((descriptor (ladspa-descriptor library label))
	     (handle (ladspa-instantiate descriptor (srate)))
	     (block-size 256)
	     (in-block (make-vct block-size))
	     (out-block (make-vct block-size))
	     (len (frames))
	     (data (make-sound-data 1 block-size))
	     (audio-port (mus-audio-open-output 0 (srate) 1 mus-lshort (* block-size 2)))
	     (ra (ladspa-run-adding descriptor handle block-size)))
	(if ra (snd-display #__line__ ";ladspa-run-adding: ~A" ra))
	(ladspa-set-run-adding-gain descriptor handle block-size)
	(dynamic-wind
	    (lambda ()
	      (let ((count 0))
		(for-each 
		 (lambda (port)
		   (if (not (= (logand port LADSPA_PORT_CONTROL) 0))
		       (let ((parameter (make-vct 1 (car plugin-parameters))))
			 (set! plugin-parameters (cdr plugin-parameters))
			 (ladspa-connect-port descriptor handle count parameter))
		       (if (not (= (logand port LADSPA_PORT_INPUT) 0))
			   (ladspa-connect-port descriptor handle count in-block)
			   (ladspa-connect-port descriptor handle count out-block)))
		   (set! count (+ 1 count)))
		 (.PortDescriptors descriptor))))
	    (lambda ()
	      (ladspa-activate descriptor handle)
	      (catch #t
		     (lambda ()
		       (do ((i 0 (+ i block-size)))
			   ((>= i len))
			 (samples->vct i block-size #f #f in-block)
			 (ladspa-run descriptor handle block-size)
			 (vct->sound-data out-block data 0)
			 (mus-audio-write audio-port data block-size)))
		     (lambda args (snd-display #__line__ ";ladspa-it: ~A" args))))
	    (lambda ()
	      (ladspa-deactivate descriptor handle)
	      (mus-audio-close audio-port)
	      (ladspa-cleanup descriptor handle))))))



(defmacro carg0 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda () 32))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(defmacro carg1 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda (n) (if (number? n) (+ n 32) n)))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(defmacro carg2 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda (n m) (if (and (number? n) (number? m)) (+ n m 32) n)))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(defmacro carg3 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda (a b c) (if (and (number? a) (number? b) (number? c)) (+ a b c 32) a)))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(defmacro carg4 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda (a b c d) (if (and (number? a) (number? b) (number? c) (number? d)) (+ a b c 32) a)))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(defmacro carg5 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda (a b c d e) (list 0 0 1 1)))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(defmacro carg6 (hook)
  `(let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list ,hook)))))))
     (if (not (string=? str "((lambda (a b c d e f) (if (and (number? a) (number? b) (number? c) (number? d) (number? e)) (+ a b c d e f 32) a)))"))
	 (snd-display #__line__ ";~A: ~A?" ',hook str))))

(define ladspa_inited #f)
(define clm_buffer_added #f)

(define (snd_test_13)
  
  (define (test-hooks)
    (define (arg0) 32)
    (define (arg1 n) (if (number? n) (+ n 32) n))
    (define (arg2 n m) (if (and (number? n) (number? m)) (+ n m 32) n))
    (define (arg3 a b c) (if (and (number? a) (number? b) (number? c)) (+ a b c 32) a))
    (define (arg4 a b c d) (if (and (number? a) (number? b) (number? c) (number? d)) (+ a b c 32) a))
    (define (arg5 a b c d e) (list 0 0 1 1))
    (define (arg6 a b c d e f) (if (and (number? a) (number? b) (number? c) (number? d) (number? e)) (+ a b c d e f 32) a))
    (reset-almost-all-hooks)
    
    (add-hook! after-graph-hook arg2) (carg2 after-graph-hook)
    (add-hook! after-lisp-graph-hook arg2) (carg2 after-lisp-graph-hook)
    (add-hook! lisp-graph-hook arg2) (carg2 lisp-graph-hook)
    (add-hook! time-graph-hook arg2) (carg2 time-graph-hook)
    (add-hook! before-transform-hook arg2) (carg2 before-transform-hook)
    (add-hook! mix-release-hook arg2) (carg2 mix-release-hook)
    (add-hook! save-hook arg2) (carg2 save-hook)
    (add-hook! mus-error-hook arg2) (carg2 mus-error-hook)
    (add-hook! mouse-enter-graph-hook arg2) (carg2 mouse-enter-graph-hook)
    (add-hook! mouse-leave-graph-hook arg2) (carg2 mouse-leave-graph-hook)
    (add-hook! open-raw-sound-hook arg2) (carg2 open-raw-sound-hook)
    (add-hook! select-channel-hook arg2) (carg2 select-channel-hook)
    (add-hook! help-hook arg2) (carg2 help-hook)
    (add-hook! view-files-select-hook arg2) (carg2 view-files-select-hook)
    (add-hook! peak-env-hook arg2) (carg2 peak-env-hook)
    
    (add-hook! save-state-hook arg1) (carg1 save-state-hook)
    (add-hook! new-sound-hook arg1) (carg1 new-sound-hook)
    (add-hook! after-open-hook arg1) (carg1 after-open-hook)
    (add-hook! update-hook arg1) (carg1 update-hook)
    (add-hook! close-hook arg1) (carg1 close-hook)
    (add-hook! before-close-hook arg1) (carg1 before-close-hook)
    (add-hook! clip-hook arg1) (carg1 clip-hook)
    (add-hook! draw-mark-hook arg1) (carg1 draw-mark-hook)
    (add-hook! drop-hook arg1) (carg1 drop-hook)
    (add-hook! mark-click-hook arg1) (carg1 mark-click-hook)
    (add-hook! listener-click-hook arg1) (carg1 listener-click-hook)
    (add-hook! mix-click-hook arg1) (carg1 mix-click-hook)
    (add-hook! after-save-state-hook arg1) (carg1 after-save-state-hook)
    (add-hook! before-save-state-hook arg1) (carg1 before-save-state-hook)
    (add-hook! mark-drag-hook arg1) (carg1 mark-drag-hook)
    (add-hook! name-click-hook arg1) (carg1 name-click-hook)
    (add-hook! after-apply-controls-hook arg1) (carg1 after-apply-controls-hook)
    (add-hook! open-hook arg1) (carg1 open-hook)
    (add-hook! output-comment-hook arg1) (carg1 output-comment-hook)
    (add-hook! play-hook arg1) (carg1 play-hook)
    (add-hook! dac-hook arg1) (carg1 dac-hook)
    (add-hook! new-widget-hook arg1) (carg1 new-widget-hook)
    (add-hook! snd-error-hook arg1) (carg1 snd-error-hook)
    (add-hook! snd-warning-hook arg1) (carg1 snd-warning-hook)
    (add-hook! start-hook arg1) (carg1 start-hook)
    (add-hook! start-playing-hook arg1) (carg1 start-playing-hook)
    (add-hook! stop-playing-hook arg1) (carg1 stop-playing-hook)
    (add-hook! mouse-enter-listener-hook arg1) (carg1 mouse-enter-listener-hook)
    (add-hook! mouse-leave-listener-hook arg1) (carg1 mouse-leave-listener-hook)
    (add-hook! window-property-changed-hook arg1) (carg1 window-property-changed-hook)
    (add-hook! select-sound-hook arg1) (carg1 select-sound-hook)
    (add-hook! print-hook arg1) (carg1 print-hook)
    (add-hook! read-hook arg1) (carg1 read-hook)
    (add-hook! bad-header-hook arg1) (carg1 bad-header-hook)
    (add-hook! output-name-hook arg1) (carg1 output-name-hook)
    
    (add-hook! before-exit-hook arg0) (carg0 before-exit-hook)
    (add-hook! exit-hook arg0) (carg0 exit-hook)
    (add-hook! stop-dac-hook arg0) (carg0 stop-dac-hook)
    (add-hook! stop-playing-selection-hook arg0) (carg0 stop-playing-selection-hook)
    (add-hook! color-hook arg0) (carg0 color-hook)
    (add-hook! orientation-hook arg0) (carg0 orientation-hook)
    (add-hook! start-playing-selection-hook arg0) (carg0 start-playing-selection-hook)
    
    (add-hook! during-open-hook arg3) (carg3 during-open-hook)
    (add-hook! after-transform-hook arg3) (carg3 after-transform-hook)
    (add-hook! mouse-enter-label-hook arg3) (carg3 mouse-enter-label-hook)
    (add-hook! mouse-leave-label-hook arg3) (carg3 mouse-leave-label-hook)
    (add-hook! initial-graph-hook arg3) (carg3 initial-graph-hook)
    (add-hook! after-save-as-hook arg3) (carg3 after-save-as-hook)
    (add-hook! mix-drag-hook arg3) (carg3 mix-drag-hook)
    
    (add-hook! graph-hook arg4) (carg4 graph-hook)
    (add-hook! key-press-hook arg4) (carg4 key-press-hook)
    (add-hook! mark-hook arg4) (carg4 mark-hook)
    (add-hook! mark-drag-triangle-hook arg4) (carg4 mark-drag-triangle-hook)
    
    (add-hook! mouse-drag-hook arg6) (carg6 mouse-drag-hook)
    (add-hook! mouse-press-hook arg6) (carg6 mouse-press-hook)
    
    (add-hook! enved-hook arg5) (carg5 enved-hook)
    (add-hook! draw-mix-hook arg5) (carg5 draw-mix-hook)
    
    (reset-almost-all-hooks)
    (for-each 
     (lambda (n) 
       (if (and (not (hook-empty? n))
		(not (eq? n optimization-hook)))
	   (snd-display #__line__ ";~A not empty?" n)))
     (snd-hooks))
    
    )
  
  (define (test-menus)
    (for-each-child
     (car (menu-widgets))
     (lambda (w)
       (if (not (XmIsRowColumn w))
	   (let ((option-holder (cadr (XtGetValues w (list XmNsubMenuId 0)))))
	     (for-each-child
	      option-holder
	      (lambda (menu)
		(if (and (XmIsPushButton menu)
			 (XtIsManaged menu)
			 (XtIsSensitive menu)
			 (not (member (XtName menu)
				      (list "Exit" "New" 
					    "Save   C-x C-s" 
					    "Close  C-x k"
					    "Close all"
					    "Save options"
					    "Record"
					    "Mixes" "clm" "fm-violin"))))
		    (XtCallCallbacks menu XmNactivateCallback (snd-global-state)))))))))
    (for-each close-sound (sounds))
    (dismiss-all-dialogs))
  
  (define (mdt-test id x time drg) #f)
  
  (reset-almost-all-hooks)
  
  (let ((fd (view-sound "oboe.snd")))
    (let ((mb #f))
      (if (not clm_buffer_added)
	  (set! mb (add-to-main-menu "clm")))
      
      (let ((var (catch #t (lambda () (add-to-menu -1 "fm-violin" (lambda () #f))) (lambda args args))))
	(if (not (eq? (car var) 'no-such-menu))
	    (snd-display #__line__ ";add-to-menu bad menu: ~A" var)))
      
      (let ((tag (catch #t (lambda () (add-to-main-menu "oops" (make-delay 11)))
			(lambda args (car args)))))
	(if (not (eq? tag 'bad-arity))
	    (snd-display #__line__ ";add-to-main-menu non-thunk: ~A" tag)))
      (let ((tag (catch #t (lambda () (add-to-menu 3 "oops" (make-delay 12)))
			(lambda args (car args)))))
	(if (and (not (eq? tag 'bad-arity))
		 (not (eq? tag 'wrong-type-arg)))
	    (snd-display #__line__ ";add-to-menu non-thunk: ~A" tag)))
      
      (set! (cursor fd) 2000)
      (set! (transform-graph-type) graph-once)
      (set! (transform-graph? fd) #t)
      (if (and with-gui
	       (not clm_buffer_added))
	  (begin
	    (add-to-menu mb "not here" (lambda () (snd-display #__line__ ";oops")))
	    (remove-from-menu mb "not here")
	    (add-to-menu 3 "Denoise" (lambda () (report-in-minibuffer "denoise")))))
      
      (set! clm_buffer_added #t))
    
    (reset-hook! help-hook)
    (let ((hi (snd-help 'cursor-position)))
      (add-hook! help-hook (lambda (a b) 
			     (if (not (string=? a "cursor-position"))
				 (snd-display #__line__ ";help-hook subject: ~A" a))
			     (if (not (string=? b "(cursor-position :optional snd chn): current cursor position (x y in pixels) in snd's channel chn"))
				 (snd-display #__line__ ";help-hook text: ~A" b))
			     (string-append "hiho:" b)))
      (let ((ho (snd-help 'cursor-position)))
	(if (not (= (string-length ho) (+ 5 (string-length hi))))
	    (snd-display #__line__ ";help-hook ~A -> ~A" hi ho))
	(reset-hook! help-hook)
	(add-hook! help-hook (lambda (a b) #f))
	(set! ho (snd-help 'cursor-position))
	(if (not (string=? hi ho))
	    (snd-display #__line__ ";help-hook #f: ~A ~A" hi ho))
	(reset-hook! help-hook)))
    (reset-hook! mark-drag-triangle-hook)
    (if (hook-member mdt-test mark-drag-triangle-hook) (snd-display #__line__ ";hook-member #t? ~A" (hook->list mark-drag-triangle-hook)))
    (add-hook! mark-drag-triangle-hook mdt-test)
    (if (not (hook-member mdt-test mark-drag-triangle-hook)) (snd-display #__line__ ";hook-member #f? ~A" (hook->list mark-drag-triangle-hook)))
    (reset-hook! mark-drag-triangle-hook)
    (set! (transform-size fd 0) 256)
    (for-each
     (lambda (dpy-type fft-type)
       (set! (transform-graph-type fd 0) dpy-type)
       (set! (transform-type fd 0) fft-type)
       (update-transform-graph fd 0)
       (let ((vals (transform->vct fd 0)))
	 (if (not vals) 
	     (snd-display #__line__ ";transform graph-type: ~A type: ~A -> data: ~A" dpy-type fft-type vals)
	     (begin
	       (if (fneq (transform-sample 0 0 fd 0) (vct-ref vals 0))
		   (snd-display #__line__ ";transform-sample ~A ~A -> ~A ~A" dpy-type fft-type (vct-ref vals 0) (transform-sample 0 0 fd 0)))
	       (if (not (>= (vct-length vals) 256))
		   (snd-display #__line__ ";transform-> vct size: ~A" (vct-length vals)))))))
     (list graph-once graph-as-sonogram graph-as-spectrogram
	   graph-once graph-as-sonogram graph-as-spectrogram)
     (list fourier-transform fourier-transform fourier-transform 
	   autocorrelation autocorrelation autocorrelation))
    (let ((tag (catch #t
		      (lambda ()
			(transform-sample 5000 0 fd 0))
		      (lambda args (car args)))))
      (if (not (eq? tag 'no-such-sample))
	  (snd-display #__line__ ";access invalid (bin) transform sample: ~A" tag)))
    (let ((tag (catch #t
		      (lambda ()
			(transform-sample 0 5000 fd 0))
		      (lambda args (car args)))))
      (if (not (eq? tag 'no-such-sample))
	  (snd-display #__line__ ";access invalid (slice) transform sample: ~A" tag)))
    (close-sound fd)
    (set! (transform-type) fourier-transform)
    
    (add-hook! after-open-hook
	       (lambda (snd)
		 (set! (x-axis-style snd #t) x-axis-in-samples)))
    (set! fd (open-sound "2.snd"))
    (close-sound fd)
    (reset-hook! after-open-hook)
    
    (add-hook! after-open-hook
	       (lambda (snd)
		 (set! (x-axis-style snd #t) x-axis-as-percentage)))
    (add-hook! initial-graph-hook
	       (lambda (snd chn dur)
		 (if (mus-sound-maxamp-exists? (file-name snd))
		     (let* ((amp-vals (mus-sound-maxamp (file-name snd)))
			    (max-val (list-ref amp-vals (+ (* chn 2) 1))))
		       (list 0.0 dur (- max-val) max-val))
		     (list 0.0 dur -1.0 1.0))))
    (reset-hook! after-open-hook)
    (reset-hook! initial-graph-hook)
    
    (add-hook! initial-graph-hook
	       (lambda (snd chn dur)
		 (list 0.0 dur -1.0 1.0 "a label" -4.0 4.0)))
    (set! fd (open-sound "2.snd"))
    (let ((ax (axis-info)))
      (if (and (list-p ax)
	       (or (fneq (list-ref ax 2) 0.0)
		   (fneq (list-ref ax 3) -1.0)
		   (fneq (list-ref ax 4) (mus-sound-duration "2.snd"))
		   (fneq (list-ref ax 5) 1.0)
		   (fneq (list-ref ax 6) 0.0)
		   (fneq (list-ref ax 7) -4.0)
		   (fneq (list-ref ax 8) (mus-sound-duration "2.snd"))
		   (fneq (list-ref ax 9) 4.0)))
	  (snd-display #__line__ ";initial-graph-hook with ymin/max: ~A" ax))
      (reset-hook! initial-graph-hook))
    (set! (selection-position fd 1) 1000)
    (set! (selection-frames fd 1) 10)
    (set! (selection-member? fd 1) #t)
    (if (selection-member? fd 0) (snd-display #__line__ ";chan 0 is selection-member?"))
    (do ((i 0 (+ 1 i))) ((= i 2))
      (set! (selection-position fd i) 1000)
      (set! (selection-frames fd i) 10)
      (set! (selection-member? fd i) #t))
    (scale-selection-to (vct .5 .25))
    (if (or (fneq (maxamp fd 0) .5)
	    (fneq (maxamp fd 1) .25))
	(snd-display #__line__ ";scale-selection-to with vector: ~A" (maxamp fd #t)))
    (close-sound fd)
    
    (set! fd (open-sound "obtest.snd"))
    
    (let ((ctr 0))
      (let ((added 0))
	(reset-hook! close-hook)
	(set! (with-background-processes) #t)
	(add-hook! new-widget-hook
		   (lambda (w)
		     (set! added (+ added 1))))
	(if (provided? 'snd-motif)
	    (without-errors
	     (test-menus)))
	(dismiss-all-dialogs)
	(reset-hook! close-hook)
	(for-each close-sound (sounds))
	(if (sound? fd) 
	    (begin 
	      (snd-display #__line__ ";close all didn't? ~A ~A ~A ~A ~A" fd (sound? fd) (short-file-name fd) (hook->list close-hook) (sounds))
	      (close-sound fd)))
	(set! fd (open-sound "obtest.snd"))	  
	(set! (with-background-processes) #f)
	(if (and (provided? 'snd-motif)
		 (= added 0))
	    (snd-display #__line__ ";no widgets added?"))
	(reset-hook! new-widget-hook))
      
      (if (and (not ladspa_inited)
	       (provided? 'snd-ladspa))
	  (if (file-exists? "/home/bil/test/ladspa/ladspa_sdk/plugins")
	      (begin
		(set! ladspa_inited #t)
		(set! (ladspa-dir) "/home/bil/test/ladspa/ladspa_sdk/plugins")
		(init-ladspa)
		(let* ((ptr (ladspa-descriptor "delay" "delay_5s"))
		       (label (.Label ptr))
		       (name (.Name ptr))
		       (copy (.Copyright ptr))
		       (maker (.Maker ptr))
		       (props (.Properties ptr))
		       (id (.UniqueID ptr))
		       (names (.PortNames ptr))
		       (hints (.PortRangeHints ptr))
		       (count (.PortCount ptr))
		       (descs (.PortDescriptors ptr)))
		  (if (not (string=? label "delay_5s")) 
		      (snd-display #__line__ ";ladspa .Label: ~A" label))
		  (if (not (string=? name "Simple Delay Line")) 
		      (snd-display #__line__ ";ladspa .Name: ~A" name))
		  (if (not (string=? maker "Richard Furse (LADSPA example plugins)"))
		      (snd-display #__line__ ";ladspa .Maker: ~A" maker))
		  (if (not (string=? copy "None"))
		      (snd-display #__line__ ";ladspa .Copyright: ~A" copy))
		  (if (not (= id 1043)) (snd-display #__line__ ";ladspa .UniqueID: ~A" id))
		  (if (not (= count 4)) (snd-display #__line__ ";ladspa .PortCount: ~A" count))
		  (if (not (= props 4)) (snd-display #__line__ ";ladspa .Properties: ~A" prop))
		  (if (not (equal? names (list "Delay (Seconds)" "Dry/Wet Balance" "Input" "Output")))
		      (snd-display #__line__ ";ladspa .PortNames: ~A" names))
		  (if (not (equal? hints (list (list 579 0.0 5.0) (list 195 0.0 1.0) (list 0 0.0 0.0) (list 0 0.0 0.0))))
		      (snd-display #__line__ ";ladspa .PortRangeHints: ~A" hints))
		  (if (not (equal? descs (list 5 5 9 10)))
		      (snd-display #__line__ ";ladspa .PortDescriptors: ~A" descs))
		  (if (not (= (logand (cadr (.PortDescriptors ptr)) LADSPA_PORT_INPUT) 1))
		      (snd-display #__line__ ";ladspa port hint: ~A" (logand (cadr (.PortDescriptors ptr)) LADSPA_PORT_INPUT))))
		(apply-ladspa (make-sampler 0) (list "delay" "delay_5s" .3 .5) 1000 "delayed")
		(if (not (equal? (analyze-ladspa "delay" "delay_5s")
				 (list "Simple Delay Line" "Richard Furse (LADSPA example plugins)" "None" (list "Dry/Wet Balance" "minimum" 0.0 "maximum" 1.0) (list "Delay (Seconds)" "minimum" 0.0 "maximum" 5.0))))
		    (snd-display #__line__ ";analyze-ladspa: ~A" (analyze-ladspa "delay" "delay_5s")))
		(ladspa-it "delay" "delay_5s" .3 .5)
		(if (provided? 'xm)
		    (let ((w (list-ref (menu-widgets) 5)))
		      (if (list? w)
			  (if (not (XmIsRowColumn w))
			      (let ((option-holder (cadr (XtGetValues w (list XmNsubMenuId 0)))))
				(for-each-child
				 option-holder
				 (lambda (menu)
				   (if (and (XmIsPushButton menu)
					    (XtIsSensitive menu)
					    (string=? (XtName menu) "Plugins"))
				       (XtCallCallbacks menu XmNactivateCallback (snd-global-state))))))))))
		(dismiss-all-dialogs)
		(let ((tag (catch #t 
				  (lambda () 
				    (apply-ladspa (make-sampler 0) (list "delay" "delay_4s" .3 .5) 1000 "delayed"))
				  (lambda args args))))
		  (if (not (eq? (car tag) 'no-such-plugin))
		      (snd-display #__line__ ";apply-ladspa bad plugin: ~A" tag)))
		(let ((tag (catch #t 
				  (lambda () 
				    (apply-ladspa (list (make-sampler 0) (make-sampler 0)) (list "delay" "delay_5s" .3 .5) 1000 "delayed"))
				  (lambda args args))))
		  (if (not (eq? (car tag) 'plugin-error))
		      (snd-display #__line__ ";apply-ladspa reader mismatch: ~A" tag)))
		(let ((vals (list-ladspa)))
		  (if (not (list-p vals))
		      (snd-display #__line__ ";ladspa list: ~A" vals))
		  (let ((descr (analyse-ladspa "delay" "delay_5s")))
		    (if (or (not (list-p descr))
			    (not (string? (car descr)))
			    (not (string=? (car descr) "Simple Delay Line")))
			(snd-display #__line__ ";analyse-ladspa: ~A" descr))))
		(let ((tag (catch #t 
				  (lambda () (analyse-ladspa "delay" "delay_no_delay"))
				  (lambda args (car args)))))
		  (if (not (eq? tag 'no-such-plugin)) (snd-display #__line__ ";analyse-ladspa tag: ~A" tag)))
		(let ((tag (catch #t
				  (lambda ()
				    (apply-ladspa (list (make-sampler 0) (make-sampler 0)) (list #f) 1000 "delayed"))
				  (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";apply-ladspa tag: ~A" tag)))
		
		(set! (ladspa-dir) "/home/bil/test/ladspa/vocoder-0.3")
		(init-ladspa)
		(if (not (equal? (list-ladspa) (list (list "vocoder" "vocoder"))))
		    (snd-display #__line__ ";list-ladspa vocoder: ~A" (list-ladspa)))
		(if (not (list? (analyze-ladspa "vocoder" "vocoder")))
		    (snd-display #__line__ ";analyze-ladspa vocoder: ~A" (analyze-ladspa "vocoder" "vocoder")))
		(let ((hi (ladspa-descriptor "vocoder" "vocoder")))
		  (if (not (string=? (.Name hi) "Vocoder"))
		      (snd-display #__line__ ";ladspa vocoder name: ~A" (.Name hi))))
		
		(let ((snd (open-sound "1a.snd")))
		  (apply-ladspa (list (make-sampler 0) (make-sampler 0)) 
				(list "vocoder" "vocoder" 12 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5) 
				(frames) "vocoder")
		  (undo)
		  
		  (set! (ladspa-dir) "/home/bil/test/ladspa/lib/ladspa")
		  (init-ladspa)
		  (for-each (lambda (plug) (apply analyse-ladspa plug)) (list-ladspa))
		  
		  (if (not (list? (analyse-ladspa "amp_1181" "amp")))
		      (snd-display #__line__ ";analyze-ladspa can't find amp_1181"))
		  
		  (apply-ladspa (make-sampler 0) (list "amp_1181" "amp" -6) (frames) "amp")
		  (apply-ladspa (make-sampler 0) (list "amp_1181" "amp" 6) (frames) "amp")
		  (close-sound snd))
		
		(let ((snd (open-sound "2a.snd")))
		  
		  (let ((tag 
			 (catch #t
				(lambda ()
				  (apply-ladspa (list (make-sampler 0 snd 0) (make-sampler 0 snd 1)) 
						(list "amp_1181" "amp" 6 -6) (frames) "amp"))
				(lambda args (car args)))))
		    (if (not (equal? tag 'plugin-error))
			(snd-display #__line__ ";apply-ladspa bad inputs: ~A" tag)))
		  
		  (apply-ladspa (list (make-sampler 0 snd 0) (make-sampler 0 snd 0)) 
				(list "ringmod_1188" "ringmod_2i1o" 1) (frames) "ringmod")
		  (apply-ladspa #f (list "analogue_osc_1416" "analogueOsc" 2 440.0 0.1 0.0) (frames) "osc")
		  (apply-ladspa #f (list "sin_cos_1881" "sinCos" 440.0 1.0) (frames) "sincos")
		  (apply-ladspa (list (make-sampler 0 snd 0) (make-sampler 0 snd 1)) 
				(list "dj_eq_1901" "dj_eq" -6 0 6) (frames) "djeq")
		  (close-sound snd)))
	      
	      (snd-display #__line__ ";ladspa loaded but can't find plugin directory: ~A" (ladspa-dir)))))
    
    (revert-sound fd)
    (close-sound fd)
    (for-each close-sound (sounds))
    
    (test-hooks)
    (add-hook! bad-header-hook (lambda (n) #t))
    (let ((ind (open-sound "oboe.snd")))
      (set! (cursor) 2000)
      (key (char->integer #\u) 4 ind)
      (key (char->integer #\1) 0 ind)
      (key (char->integer #\0) 0 ind)
      (key (char->integer #\0) 0 ind)
      (key (char->integer #\x) 4 ind)
      (key (char->integer #\z) 4 ind)
      (if (not (equal? (edit-fragment) (list "smooth-channel 2000 100" "set" 2000 100)))
	  (snd-display #__line__ ";C-x C-z fragment: ~A" (edit-fragment)))
      (if (not (vequal (samples->vct 2010 10) (vct 0.064 0.063 0.063 0.062 0.062 0.061 0.060 0.059 0.059 0.058)))
	  (snd-display #__line__ ";C-x C-z samps: ~A" (samples->vct 2010 10)))
      (set! (cursor) 0)
      (select-all)
      (key (char->integer #\x) 4 ind)
      (key (char->integer #\o) 0 ind)
      (key (char->integer #\-) 4 ind)
      (key (char->integer #\x) 4 ind)
      (key (char->integer #\o) 0 ind)
      (key (char->integer #\x) 4 ind)
      (key (char->integer #\o) 0 ind)
      (key (char->integer #\x) 4 ind)
      (key (char->integer #\p) 0 ind)
      (set! (selection-member? #t) #f)
      (revert-sound ind)
      (set! (search-procedure ind) (lambda (n4) (> n4 .1)))
      (key (char->integer #\a) 4 ind 0)
      (if (not (= (cursor ind 0) 0))
	  (snd-display #__line__ ";C-a cursor: ~D?" (cursor ind 0)))
      (key (char->integer #\s) 4 ind 0)
      (key (char->integer #\s) 4 ind 0)
      (if (not (= (cursor ind 0) 4423))
	  (snd-display #__line__ ";search-procedure C-s C-s cursor: ~D?" (cursor ind 0)))
      (let ((str (with-output-to-string (lambda () (display (procedure-source (search-procedure ind)))))))
	(if (not (string=? str "(lambda (n4) (> n4 0.1))"))
	    (snd-display #__line__ ";search-procedure: ~A?" str)))
      
      (set! (search-procedure ind) (lambda (n) (> n .2)))
      (set! (cursor ind 0) 0)
      (key (char->integer #\s) 4 ind 0)
      (key (char->integer #\s) 4 ind 0)
      (if (not (= (cursor ind 0) 0))
	  (snd-display #__line__ ";search-procedure C-s C-s cursor failed: ~D?" (cursor ind 0)))
      (let ((str (with-output-to-string (lambda () (display (procedure-source (search-procedure ind)))))))
	(if (not (string=? str "(lambda (n) (> n 0.2))"))
	    (snd-display #__line__ ";search-procedure (1): ~A?" str)))
      
      (reset-hook! (edit-hook ind 0))
      (add-hook! (edit-hook ind 0) (lambda () (+ snd chn)))
      (let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list (edit-hook ind 0))))))))
	(if (not (string=? str "((lambda () (+ snd chn)))"))
	    (snd-display #__line__ ";edit-hook: ~A?" str)))
      (reset-hook! (edit-hook ind 0))
      (reset-hook! (after-edit-hook ind 0))
      (add-hook! (after-edit-hook ind 0) (lambda () (+ snd chn)))
      (let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list (after-edit-hook ind 0))))))))
	(if (not (string=? str "((lambda () (+ snd chn)))"))
	    (snd-display #__line__ ";after-edit-hook: ~A?" str)))
      (reset-hook! (after-edit-hook ind 0))
      (reset-hook! (undo-hook ind 0))
      (add-hook! (undo-hook ind 0) (lambda () (+ snd chn)))
      (let ((str (with-output-to-string (lambda () (display (map procedure-source (hook->list (undo-hook ind 0))))))))
	(if (not (string=? str "((lambda () (+ snd chn)))"))
	    (snd-display #__line__ ";undo-hook: ~A?" str)))
      (reset-hook! (undo-hook ind 0))
      (let ((calls 0))
	(add-hook! (undo-hook ind 0) (lambda () (set! calls (+ 1 calls))))
	(delete-sample 0 ind 0)
	(undo 1)
	(redo 1)
	(revert-sound ind)
	(if (not (= calls 3)) (snd-display #__line__ ";undo-hook called ~A times" calls)))
      (reset-hook! (undo-hook ind 0))
      
      (let ((opt (optimization)))
	(set! (optimization) 0)
	(set! (search-procedure ind) (lambda (n4) (> n4 .1)))
	(key (char->integer #\a) 4 ind 0)
	(key (char->integer #\s) 4 ind 0)
	(key (char->integer #\s) 4 ind 0)
	(if (not (= (cursor ind 0) 4423))
	    (snd-display #__line__ ";unopt search-procedure C-s C-s cursor: ~D?" (cursor ind 0)))
	(set! (search-procedure ind) (lambda (n) (> n .2)))
	(set! (cursor ind 0) (- (frames) 1))
	(key (char->integer #\r) 4 ind 0)
	(key (char->integer #\r) 4 ind 0)
	(set! (optimization) opt))
      
      (set! (search-procedure ind) #f)
      (close-sound ind)
      )
    (if (not (hook-empty? open-raw-sound-hook)) (reset-hook! open-raw-sound-hook))
    (add-hook! open-raw-sound-hook (lambda (file choices) (list 1 22050 mus-bshort)))
    (let* ((ind (open-sound "../sf1/addf8.nh")))
      (play ind :wait #t)
      (reset-hook! open-raw-sound-hook)
      (if (or (not (= (chans ind) 1))
	      (not (= (srate ind) 22050))
	      (not (= (data-format ind) mus-bshort))
	      (not (= (frames ind) 23808)))
	  (snd-display #__line__ ";open-raw: ~A ~A ~A ~A" 
		       (chans ind) (srate ind) (data-format ind) (frames ind)))
      (set! (search-procedure ind) (lambda (n) (> n .2)))
      (close-sound ind))
    
    (let ((save-as-dialog #t)
	  (save-as-name "hiho")
	  (save-as-index #f))
      (reset-hook! after-save-as-hook)
      (add-hook! after-save-as-hook 
		 (lambda (ind name dial)
		   (set! save-as-index ind)
		   (set! save-as-name name)
		   (set! save-as-dialog dial)))
      (let ((ind (open-sound "oboe.snd")))
	(save-sound-as "test.snd" ind mus-raw)
	(close-sound ind)
	(reset-hook! open-raw-sound-hook)
	(reset-hook! after-save-as-hook)
	(if save-as-dialog (snd-display #__line__ ";after-save-as-hook dialog: ~A" save-as-dialog))
	(if (not (equal? ind save-as-index)) (snd-display #__line__ ";after-save-as-hook index: ~A ~A" ind save-as-index))
	(if (and (not (string=? (string-append home-dir "/cl/test.snd") save-as-name)) 
		 (not (string=? (string-append home-dir "/snd-11/test.snd") save-as-name)))
	    (snd-display #__line__ ";after-save-as-hook name: ~A (~A)" save-as-name (string-append home-dir "/cl/test.snd")))
	(add-hook! open-raw-sound-hook 
		   (lambda (file choice)
		     (if (not (string=? (my-substring file (- (string-length file) 8)) "test.snd"))
			 (snd-display #__line__ ";open-raw-sound-hook file: ~A?" (my-substring file (- (string-length file) 8))))
		     (if (not (eq? choice #f))
			 (snd-display #__line__ ";open-raw-sound-hook choice: ~A?" choice))
		     (list 2 44100 mus-mulaw)))
	(set! ind (open-sound "test.snd"))
	(if (or (not (= (header-type ind) mus-raw))
		(not (= (data-format ind) mus-mulaw))
		(not (= (chans ind) 2))
		(not (= (srate ind) 44100))
		(not (= (frames ind) 50828)))
	    (snd-display #__line__ ";open-raw-sound-hook 1: ~A ~A ~A ~A ~A" 
			 (header-type ind) (data-format ind) (chans ind) (srate ind) (frames ind)))
	(close-sound ind)
	(add-hook! open-raw-sound-hook
		   (lambda (file choice)
		     (if (not (equal? choice (list 2 44100 mus-mulaw)))
			 (snd-display #__line__ ";open-raw-sound-hook 2: ~A" choice))
		     (list 1 22050 mus-lint))
		   #t)
	
	(set! ind (open-sound "test.snd"))
	(if (or (not (= (header-type ind) mus-raw))
		(not (= (data-format ind) mus-lint))
		(not (= (chans ind) 1))
		(not (= (srate ind) 22050))
		(not (= (frames ind) (/ 50828 2))))
	    (snd-display #__line__ ";open-raw-sound-hook 3: ~A ~A ~A ~A ~A" 
			 (header-type ind) (data-format ind) (chans ind) (srate ind) (frames ind)))
	(close-sound ind)
	(reset-hook! open-raw-sound-hook)
	(add-hook! open-raw-sound-hook 
		   (lambda (file choice)
		     (list 2)))
	(set! ind (open-sound "test.snd"))
	(if (or (not (= (header-type ind) mus-raw))
		(not (= (data-format ind) mus-lint))
		(not (= (chans ind) 2))
		(not (= (srate ind) 22050)))
	    (snd-display #__line__ ";open-raw-sound-hook 4: ~A ~A ~A ~A"
			 (header-type ind) (data-format ind) (chans ind) (srate ind)))
	(close-sound ind)
	(reset-hook! open-raw-sound-hook)
	(add-hook! open-raw-sound-hook 
		   (lambda (file choice)
		     (list 1 22050 mus-bshort 120 320)))
	(set! ind (open-sound "test.snd"))
	(if (or (not (= (header-type ind) mus-raw))
		(not (= (data-format ind) mus-bshort))
		(not (= (chans ind) 1))
		(not (= (srate ind) 22050))
		(not (= (data-location ind) 120))
		(not (= (data-size ind) 320))
		(not (= (frames ind) 160)))
	    (snd-display #__line__ ";open-raw-sound-hook 5: ~A ~A ~A ~A ~A ~A ~A" 
			 (header-type ind) (data-format ind) (chans ind) (srate ind)
			 (data-location ind) (data-size ind) (/ (frames ind) 2)))
	(close-sound ind)
	(reset-hook! open-raw-sound-hook)))
    (reset-hook! during-open-hook)
    
    (let ((ind #f)
	  (op #f)
	  (sl #f)
	  (aop #f)
	  (dop #f)
	  (cl #f)
	  (ig #f)
	  (scl #f)
	  (other #f))
      (add-hook! open-hook 
		 (lambda (filename)
		   (if (not (string=? filename (mus-expand-filename "oboe.snd")))
		       (snd-display #__line__ ";open-hook: ~A?" filename))
		   (set! op #t)
		   #f))
      (add-hook! after-open-hook 
		 (lambda (snd)
		   (set! aop snd)))
      (add-hook! during-open-hook 
		 (lambda (fd filename reason)
		   (set! dop #t)
		   (if (not (string=? filename (mus-expand-filename "oboe.snd")))
		       (snd-display #__line__ ";during-open-hook filename: ~A?" filename))
		   (if (not (= reason 1))
		       (snd-display #__line__ ";during-open-hook reason: ~A?" reason))))
      (add-hook! initial-graph-hook
		 (lambda (snd chn dur)
		   (if (not (= chn 0))
		       (snd-display #__line__ ";initial-graph-hook (channel): ~A not 0?" chn))
		   (set! ig #t)
		   #f))
      
      (set! ind (open-sound "oboe.snd"))
      
      (if (not op) (snd-display #__line__ ";open-hook not called?"))
      (if (not dop) (snd-display #__line__ ";during-open-hook not called?"))
      (if (not ig) (snd-display #__line__ ";initial-graph-hook not called?"))
      (if (not (sound? aop)) (snd-display #__line__ ";after-open-hook not called?"))
      (if (not (equal? aop ind)) (snd-display #__line__ ";after-open-hook ~A but ind: ~A?" aop ind))
      (select-all)
      (reset-hook! open-hook)
      (reset-hook! during-open-hook)
      (reset-hook! after-open-hook)
      (reset-hook! initial-graph-hook)
      
      (add-hook! open-hook (lambda (filename) #t))
      (let ((pistol (open-sound "pistol.snd")))
	(if (not (eq? pistol #f))
	    (begin
	      (snd-display #__line__ ";open-hook #t, but open-sound -> ~A" pistol)
	      (if (sound? pistol) (close-sound pistol)))))
      (reset-hook! open-hook)
      
      (let ((gr #f)
	    (agr #f)
	    (gbf #f)
	    (abf #f))
	(reset-hook! before-transform-hook)
	(reset-hook! after-transform-hook)
	(reset-hook! after-graph-hook)
	(reset-hook! graph-hook)
	(add-hook! graph-hook
		   (lambda (snd chn y0 y1)
		     (if (not (equal? snd ind))
			 (snd-display #__line__ ";graph-hook: ~A not ~A?" snd ind))
		     (if (not (= chn 0))
			 (snd-display #__line__ ";graph-hook (channel): ~A not 0?" chn))
		     (set! gr #t)
		     #f))
	(add-hook! after-graph-hook
		   (lambda (snd chn)
		     (if (not (equal? snd ind))
			 (snd-display #__line__ ";after-graph-hook: ~A not ~A?" snd ind))
		     (if (not (= chn 0))
			 (snd-display #__line__ ";after-graph-hook (channel): ~A not 0?" chn))
		     (set! agr #t)))
	(add-hook! before-transform-hook
		   (lambda (snd chn)
		     (set! gbf #t)
		     (cursor)))
	(add-hook! after-transform-hook
		   (lambda (snd chn scale)
		     (set! abf #t)
		     (if (and (transform-graph? snd chn) 
			      (= (transform-graph-type snd chn) graph-once))
			 (report-in-minibuffer 
			  (number->string (/ (* 2.0 (vct-peak (transform->vct snd chn)))
					     (transform-size snd chn)))
			  snd)
			 #f)))
	(set! (transform-graph? ind 0) #t)
	(set! (time-graph? ind 0) #t)
	(update-time-graph ind 0)
	(update-transform-graph ind 0)
	
	(if (not gr)
	    (if (and (provided? 'snd-motif) (provided? 'xm))
		(do ((i 0 (+ 1 i))
		     (happy #f)
		     (app (car (main-widgets))))
		    ((or happy (= i 1000)))
		  (let ((msk (XtAppPending app)))
		    (if (= (logand msk (logior XtIMXEvent XtIMAlternateInput)) 0)
			(set! happy #t)
			(XtDispatchEvent (XtAppNextEvent app)))))))
	
	(if (not gr) (snd-display #__line__ ";graph-hook not called? ~A ~A ~A ~A" (time-graph? ind) (short-file-name ind) ind (sounds)))
	(if (not agr) (snd-display #__line__ ";after-graph-hook not called?"))
	(if (not gbf) (snd-display #__line__ ";before-transform-hook not called?"))
	(if (not abf) (snd-display #__line__ ";after-transform-hook not called?"))
	(reset-hook! before-transform-hook)
	(set! (transform-graph? ind 0) #f)
	(reset-hook! graph-hook)
	(reset-hook! after-graph-hook))
      
      (set! other (open-sound "pistol.snd"))
      
      (add-hook! select-sound-hook 
		 (lambda (snd) 
		   (if (not (equal? snd ind))
		       (snd-display #__line__ ";select-sound-hook: ~A not ~A?" snd ind))
		   (set! sl #t)))
      (add-hook! select-channel-hook 
		 (lambda (snd chn) 
		   (if (not (equal? snd ind))
		       (snd-display #__line__ ";select-channel-hook: ~A not ~A?" snd ind))
		   (if (not (= chn 0))
		       (snd-display #__line__ ";select-channel-hook (channel): ~A not 0?" chn))
		   (set! scl #t)))
      
      (select-sound ind)
      (if (not sl) (snd-display #__line__ ";select-sound-hook not called?"))
      (if (not scl) (snd-display #__line__ ";select-channel-hook not called?"))
      (reset-hook! select-sound-hook)
      (reset-hook! select-channel-hook)
      
      (let ((spl #f)
	    (stl #f)
	    (ph #f)
	    (ph1 #f))
	(add-hook! start-playing-hook
		   (lambda (snd)
		     (if (not (equal? snd ind))
			 (snd-display #__line__ ";start-playing-hook: ~A not ~A?" snd ind))
		     (set! spl #t)
		     #f))
	(add-hook! stop-playing-hook
		   (lambda (snd)
		     (if (not (equal? snd ind))
			 (snd-display #__line__ ";stop-playing-hook: ~A not ~A?" snd ind))
		     (set! stl #t)))
	(add-hook! play-hook
		   (lambda (n)
		     (if (< n 128)
			 (snd-display #__line__ ";play-hook samps: ~A?" n))
		     (set! (expand-control-hop) (expand-control-hop))
		     (set! (expand-control-length) (expand-control-length))
		     (set! (expand-control-ramp) (expand-control-ramp))
		     (set! (contrast-control-amp) (contrast-control-amp))
		     (set! (reverb-control-lowpass) (reverb-control-lowpass))
		     (set! (reverb-control-feedback) (reverb-control-feedback))
		     (set! ph #t)))
	(add-hook! dac-hook
		   (lambda (n)
		     (if (not (sound-data? n))
			 (snd-display #__line__ ";dac-hook data: ~A?" n))
		     (if (and (< (sound-data-length n) 128)
			      (not (= (sound-data-length n) 64))) ; mac case
			 (snd-display #__line__ ";dac-hook data length: ~A?" (sound-data-length n)))
		     (set! ph1 #t)))
	
	(set! (expand-control? ind) #t)
	(set! (reverb-control? ind) #t)
	(play ind :wait #t)
	(set! (reverb-control? ind) #f)
	(set! (expand-control? ind) #f)
	
	(if (not spl) (snd-display #__line__ ";start-playing-hook not called?"))
	(if (not stl) (snd-display #__line__ ";stop-playing-hook not called?"))
	(if (not ph) (snd-display #__line__ ";play-hook not called?"))
	(if (not ph1) (snd-display #__line__ ";dac-hook not called?"))
	(reset-hook! start-playing-hook)
	(reset-hook! start-playing-selection-hook)
	(reset-hook! stop-playing-hook)
	(reset-hook! play-hook)
	(reset-hook! dac-hook)
	
	(add-hook! play-hook
		   (lambda (n)
		     (set! (expand-control-hop) .02)
		     (set! (expand-control-length) .02)
		     (set! (expand-control-ramp) .2)
		     (set! (contrast-control-amp) 0.5)
		     (set! (reverb-control-lowpass) .02)
		     (set! (reverb-control-feedback) .02)))
	
	(play ind :wait #t)
	(reset-hook! play-hook)
	
	(add-hook! start-playing-hook (lambda (sp) #t))
	(play "4.aiff")
	(reset-hook! start-playing-hook)
	
	(let ((ss #f)
	      (old-reg (selection-creates-region)))
	  (set! (selection-creates-region) #t)
	  (add-hook! stop-playing-selection-hook (lambda () (set! ss #t)))
	  (let ((reg (select-all)))
	    (play (selection) :wait #t)
	    (if (region? reg) (play reg :wait #t))
	    (if (not ss) (snd-display #__line__ ";stop-playing-selection-hook: ~A" ss)))
	  (reset-hook! stop-playing-selection-hook)
	  (set! (selection-creates-region) old-reg))
	
	(let ((ctr 0))
	  (add-hook! dac-hook
		     (lambda (n)
		       (set! ctr (+ 1 ctr))
		       (stop-playing)))
	  (play ind :wait #t)
	  (if (> ctr 2) (snd-display #__line__ ";stop-playing: ~A" ctr))
	  (reset-hook! dac-hook))
	
	(let ((pl (make-player ind 0))
	      (ctr 0))
	  (if (not (player? pl)) (snd-display #__line__ ";make-player: ~A" pl))
	  (if (= (length (players)) 0) (snd-display #__line__ ";players: ~A" (players)))
	  (add-hook! dac-hook
		     (lambda (n)
		       (set! ctr (+ 1 ctr))
		       (if (player? pl)
			   (stop-player pl)
			   (if (= ctr 1)
			       (snd-display #__line__ ";player messed up")))))
	  (add-player pl)
	  (start-playing 1 22050 #f)
	  (if (> ctr 2) (snd-display #__line__ ";stop-player: ~A" ctr))
	  (reset-hook! dac-hook))
	
	(let ((pl (make-player ind 0)))
	  (free-player pl)
	  (if (player? pl) (snd-display #__line__ ";free-player: ~A" pl)))
	
	)
      (let ((e0 #f)
	    (e1 #f)
	    (u0 #f)
	    (u1 #f)
	    (a0 #f)
	    (a1 #f))
	(add-hook! (edit-hook ind 0) 
		   (lambda ()
		     (set! e0 #t)
		     #t))
	(add-hook! (edit-hook other 0) 
		   (lambda ()
		     (set! e1 #t)
		     #f))
	(add-hook! (undo-hook ind 0) 
		   (lambda ()
		     (set! u0 #t)))
	(add-hook! (undo-hook other 0) 
		   (lambda ()
		     (set! u1 #t)))
	(add-hook! (after-edit-hook ind 0)
		   (lambda ()
		     (set! a0 #t)))
	(add-hook! (after-edit-hook other 0)
		   (lambda ()
		     (set! a1 #t)))
	
	;; edit of ind should be disallowed, but not other
	(delete-sample 0 ind 0)
	(if (not (= (edit-position ind 0) 0))
	    (snd-display #__line__ ";edit-hook #t didn't disallow edit!"))
	(if (not e0) (snd-display #__line__ ";edit-hook #t not called?"))
	(if a0 (snd-display #__line__ ";after-edit-hook 0 called?"))
	(undo 1 ind 0)
	(if u0 (snd-display #__line__ ";undo-hook called?"))
	
	(delete-sample 0 other 0)
	(if (not (= (edit-position other 0) 1))
	    (snd-display #__line__ ";edit-hook #f didn't allow edit!"))
	(if (not e1) (snd-display #__line__ ";edit-hook #f not called?"))
	(if (not a1) (snd-display #__line__ ";after-edit-hook 1 not called?"))
	(undo 1 other 0)
	(if (not u1) (snd-display #__line__ ";undo-hook not called?"))
	
	(reset-hook! (edit-hook ind 0))
	(reset-hook! (edit-hook other 0))
	(reset-hook! (after-edit-hook ind 0))
	(reset-hook! (after-edit-hook other 0))
	(reset-hook! (undo-hook ind 0))
	(reset-hook! (undo-hook other 0)))
      
      (let ((se #f)
	    (sw #f)
	    (me #f))
	(add-hook! snd-error-hook
		   (lambda (msg)
		     (set! se #t)
		     #t))
	(add-hook! snd-warning-hook
		   (lambda (msg)
		     (set! sw #t)
		     #t))
	(add-hook! mus-error-hook
		   (lambda (typ msg)
		     (set! me #t)
		     #t))
	
	(snd-error "uhoh")
	(snd-warning "hiho")
	(mus-sound-samples "/bad/baddy")
	
	(if (not se) (snd-display #__line__ ";snd-error-hook not called?"))
	(if (not sw) (snd-display #__line__ ";snd-warning-hook not called?"))
	(if (not me) (snd-display #__line__ ";mus-error-hook not called?"))
	(reset-hook! snd-error-hook)
	(reset-hook! snd-warning-hook)
	(reset-hook! mus-error-hook)
	(add-hook! snd-error-hook
		   (lambda (msg)
		     (set! se msg)
		     #t))
	(snd-error "not an error")
	
	(if (or (not (string? se)) 
		(not (string=? se "not an error")))
	    (snd-display #__line__ ";snd-error-hook saw: ~A" se))
	(reset-hook! snd-error-hook))
      
      (add-hook! before-exit-hook (lambda () #f))
      (add-hook! before-exit-hook (lambda () #t))
      (add-hook! exit-hook (lambda () #f))
      (exit)
      (reset-hook! exit-hook)
      (reset-hook! before-exit-hook)
      
      (let ((sh #f))
	(if (file-exists? "baddy.snd") (delete-file "baddy.snd"))
	(add-hook! save-hook
		   (lambda (snd filename)
		     (if (or (not (string? filename))
			     (not (string=? filename (mus-expand-filename "baddy.snd"))))
			 (snd-display #__line__ ";save-hook filename: ~A?" filename))
		     (if (not (equal? snd ind))
			 (snd-display #__line__ ";save-hook snd: ~A ~A?" snd ind))
		     (set! sh #t)
		     #t))
	(save-sound-as "baddy.snd" ind)
	(if (not sh) (snd-display #__line__ ";save-hook not called?"))
	(if (file-exists? "baddy.snd")
	    (begin
	      (snd-display #__line__ ";save-hook didn't cancel save?")
	      (delete-file "baddy.snd")))
	(reset-hook! save-hook))
      
      ;; after-transform-hooks require some way to force the fft to run to completion
      ;; property-changed hook is similar (seems to happen whenever it's good and ready)
      (add-hook! close-hook
		 (lambda (snd)
		   (if (not (equal? snd ind))
		       (snd-display #__line__ ";close-hook: ~A not ~A?" snd ind))
		   (set! cl #t)))
      
      (close-sound ind)
      (if (not cl) (snd-display #__line__ ";close-hook not called?"))
      (reset-hook! close-hook)
      (close-sound other))
    
    (add-hook! print-hook (lambda (str) 
			    (if (and (char=? (string-ref str 0) #\#) 
				     (or (and (= (print-length) 30) ; test 9
					      (not (string=? str "#(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...)")))
					 (and (= (print-length) 12) ; just test 13
					      (not (string=? str "#(0 0 0 0 0 0 0 0 0 0 0 0 ...)")))))
				(snd-display #__line__ ";vector abbreviation: ~A" str))
			    #f))
    (let ((v (make-vector 128 0)))
      (snd-print v)
      (reset-hook! print-hook))
    
					;      (let ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "auto-update test"))
					;	    (ind1 (new-sound "fmv1.snd" mus-next mus-bshort 22050 1 "auto-update test"))
					;	    (old-update (auto-update)))
					;	(pad-channel 0 1000 ind 0)
					;	(pad-channel 0 1000 ind1 0)
					;	(save-sound ind)
					;	(save-sound ind1)
					;	(set! (auto-update) #t)
					;	(sleep 1) ; make sure write dates differ(!)
					;	(system "cp oboe.snd fmv1.snd") ; ind1 needs auto-update now
					;	(set-sample 100 0.55 ind 0 #f)
					;	(if (fneq (sample 100 ind 0) 0.55) (snd-display #__line__ ";set-sample: ~A" (sample 100 ind 0)))
					;	(save-sound ind) ; this should cause auto-update scan of all files
					;	(set! ind1 (find-sound "fmv1.snd")) ; hmmm auto-update can change any file's index!
					;	(if (not (= (frames ind1) (mus-sound-frames "oboe.snd")))
					;	    (snd-display #__line__ ";fmv1 after update: ~A" (frames ind1)))
					;	(set! (auto-update) old-update)
					;	(close-sound ind)
					;	(close-sound ind1)
					;	(delete-file "fmv.snd")
					;	(delete-file "fmv1.snd"))
    
    (if (not (provided? 'alsa))
	(let ((in1 (open-sound "oboe.snd"))
	      (in2 (open-sound "2.snd")))
	  (set! (sync in1) 1)
	  (set! (sync in2) 1)
	  (play :with-sync #t :wait #t)
	  (close-sound in1)
	  (close-sound in2)))
    
    (let* ((ind (open-sound "oboe.snd"))
	   (edit-hook-ctr 0)
	   (after-edit-hook-ctr 0)
	   (all-tests (list (list 'apply-controls (lambda () 
						    (set! (amp-control ind 0) .5) 
						    (apply-controls ind) 
						    (set! (amp-control ind 0) 1.0)))
			    (list 'clm-channel (lambda () 
						 (clm-channel (make-two-zero 1 -1))))
			    (list 'convolve-selection-with (lambda () 
							     (let ((reg (select-all ind 0))) 
							       (convolve-selection-with "1a.snd" .5) 
							       (if (region? reg) (forget-region reg)))))
			    (list 'convolve-with (lambda () 
						   (convolve-with "1a.snd" 0.5 ind 0)))
			    (list 'delete-mix (lambda () 
						(let ((mx (mix-vct (make-vct 3 .2) 123))) 
						  (if (mix? mx) (set! (mix-amp mx) 0.0)))))
			    (list 'delete-sample (lambda () 
						   (delete-sample 123 ind 0)))
			    (list 'delete-samples (lambda () 
						    (delete-samples 123 123 ind 0)))
			    (list 'delete-selection (lambda () 
						      (let ((reg (select-all ind 0))) 
							(delete-selection) 
							(if (region? reg) (forget-region reg)))))
			    (list 'env-channel (lambda () 
						 (env-channel '(0 0 1 1))))
			    (list 'env-selection (lambda () 
						   (let ((reg (select-all ind 0))) 
						     (env-selection '(0 0 1 1) 1.0) 
						     (if (region? reg) (forget-region reg)))))
			    (list 'env-sound (lambda () 
					       (env-sound '(0 0 1 1))))
			    (list 'filter-sound (lambda () 
						  (filter-sound '(0 1 1 0) 1024)))
			    (list 'filter-selection (lambda () 
						      (let ((reg (select-all ind 0))) 
							(filter-selection '(0 0 1 1) 6) 
							(if (region? reg) (forget-region reg)))))
			    (list 'insert-region (lambda () 
						   (let ((reg (make-region 0 100 ind 0))) 
						     (insert-region reg 123 ind 0) 
						     (if (region? reg) (forget-region reg)))))
			    (list 'insert-sample (lambda () 
						   (insert-sample 123 .5 ind 0)))
			    (list 'insert-samples (lambda () 
						    (insert-samples 123 3 (make-vct 3 1.0) ind 0)))
			    (list 'insert-selection (lambda () 
						      (let ((reg (select-all ind 0))) 
							(insert-selection 120 ind 0) 
							(if (region? reg) (forget-region reg)))))
			    (list 'insert-silence (lambda () 
						    (insert-silence 123 456 ind 0)))
			    (list 'insert-sound (lambda () 
						  (insert-sound "1a.snd" 123)))
			    (list 'map-chan (lambda () 
					      (map-chan (lambda (y) (+ y .2)))))
			    (list 'map-channel (lambda () 
						 (map-channel (lambda (y) (+ y .2)))))
			    (list 'mix (lambda () 
					 (mix "1a.snd" 123)))
			    (list 'mix-amp (lambda () 
					     (let ((mx (mix-vct (make-vct 3 1.0) 123))) 
					       (if (mix? mx) (set! (mix-amp mx) .123)))))
			    (list 'mix-amp-env (lambda () 
						 (let ((mx (mix-vct (make-vct 3 1.0) 123))) 
						   (if (mix? mx) (set! (mix-amp-env mx) '(0 0 1 1))))))
			    (list 'mix-position (lambda () 
						  (let ((mx (mix-vct (make-vct 3 1.0) 123))) 
						    (if (mix? mx) (set! (mix-position mx) 123)))))
			    (list 'mix-speed (lambda () 
					       (let ((mx (mix-vct (make-vct 3 1.0) 123))) 
						 (if (mix? mx) (set! (mix-speed mx) .123)))))
			    (list 'mix-region (lambda () 
						(let ((reg (make-region 0 100 ind 0))) 
						  (mix-region reg 123 ind 0) 
						  (if (region? reg) (forget-region reg)))))
			    (list 'mix-selection (lambda () 
						   (let ((reg (select-all ind 0))) 
						     (mix-selection 1234 ind 0) 
						     (if (region? reg) (forget-region reg)))))
			    (list 'mix-vct (lambda () 
					     (mix-vct (make-vct 10 .3) 123)))
			    (list 'pad-channel (lambda () 
						 (pad-channel 123 456 ind 0)))
			    (list 'ptree-channel (lambda () 
						   (ptree-channel (lambda (y) (+ y .2)))))
			    (list 'ramp-channel (lambda () 
						  (ramp-channel 0.0 0.5 123 456)))
			    (list 'reverse-channel (lambda () 
						     (reverse-channel 123 456 ind 0)))
			    (list 'reverse-sound (lambda () 
						   (reverse-sound ind 0)))
			    (list 'reverse-selection (lambda () 
						       (let ((reg (select-all ind 0))) 
							 (reverse-selection) 
							 (if (region? reg) (forget-region reg)))))
			    (list 'scale-by (lambda () 
					      (scale-by 2.0)))
			    (list 'scale-channel (lambda () 
						   (scale-channel .5 123 456 ind 0)))
			    (list 'scale-selection-by (lambda () 
							(let ((reg (select-all ind 0)))
							  (scale-selection-by 2.0) 
							  (if (region? reg) (forget-region reg)))))
			    (list 'scale-selection-to (lambda () 
							(let ((reg (select-all ind 0)))
							  (scale-selection-to 0.5) 
							  (if (region? reg) (forget-region reg)))))
			    (list 'scale-to (lambda () 
					      (scale-to 0.4)))
			    (list 'scale-sound-by (lambda () 
						    (scale-sound-by 2.0)))
			    (list 'scale-sound-to (lambda () 
						    (scale-sound-to 0.5)))
			    (list 'smooth-channel (lambda () 
						    (smooth-channel 123 456 ind 0)))
			    (list 'smooth-sound (lambda ()
						  (smooth-sound 123 456 ind 0)))
			    (list 'smooth-selection (lambda () 
						      (let ((reg (select-all ind 0))) 
							(smooth-selection)
							(if (region? reg) (forget-region reg)))))
			    (list 'src-channel (lambda ()
						 (src-channel .5 123 456 ind 0)))
			    (list 'src-sound (lambda () 
					       (src-sound '(0 0.5 1 1))))
			    (list 'src-selection (lambda () 
						   (let ((reg (select-all ind 0))) 
						     (src-selection 0.5) 
						     (if (region? reg) (forget-region reg)))))
			    (list 'swap-channels (lambda () 
						   (let ((ind1 (open-sound "1a.snd"))) 
						     (swap-channels ind 0 ind1 0)
						     (close-sound ind1))))
			    (list 'vct->channel (lambda () 
						  (vct->channel (make-vct 3) 123 3 ind 0)))
			    (list 'vct->samples (lambda () 
						  (vct->samples 123 3 (make-vct 3))))
			    (list 'xramp-channel (lambda () 
						   (xramp-channel .5 1.0 32.0 123 456 ind 0))))))
      
      (if (and (provided? 'snd-motif)
	       (provided? 'xm))
	  (let* ((edhist (list-ref (channel-widgets ind 0) 7))
		 (edp (XtParent edhist))
		 (pmax (cadr (XtVaGetValues edp (list XmNpaneMaximum 0)))))
	    (XtUnmanageChild edp) 
	    (XtVaSetValues edp (list XmNpaneMinimum 100)) 
	    (XtManageChild edp)))
      
      (add-hook! (edit-hook ind 0) 
		 (lambda () 
		   (set! edit-hook-ctr (+ 1 edit-hook-ctr)) 
		   #t))
      (add-hook! (after-edit-hook ind 0) 
		 (lambda () 
		   (set! after-edit-hook-ctr (+ 1 after-edit-hook-ctr)) 
		   #t))
      (for-each
       (lambda (func-and-name)
	 (let ((func (cadr func-and-name))
	       (name (car func-and-name)))
	   (func)
	   (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";~A: blocked edit: ~A" name (edit-position ind 0)))
	   (if (not (= edit-hook-ctr 1)) (snd-display #__line__ ";~A: edit hook calls: ~A" name edit-hook-ctr))
	   (if (not (= after-edit-hook-ctr 0)) (snd-display #__line__ ";~A: after edit hook calls: ~A" name after-edit-hook-ctr))
	   (set! edit-hook-ctr 0)
	   (if (not (equal? (mixes ind 0) '())) (snd-display #__line__ ";[27315] ~A: mixes: ~A" name (mixes ind 0)))))
       all-tests)
      
      (set! edit-hook-ctr 0)
      (set! after-edit-hook-ctr 0)
      (reset-hook! (edit-hook ind 0))
      (reset-hook! (after-edit-hook ind 0))
      (add-hook! (edit-hook ind 0) 
		 (lambda () 
		   (set! edit-hook-ctr (+ 1 edit-hook-ctr)) 
		   #f))
      (add-hook! (after-edit-hook ind 0) 
		 (lambda () 
		   (set! after-edit-hook-ctr (+ 1 after-edit-hook-ctr)) 
		   #t))
      (for-each
       (lambda (func-and-name)
	 (let ((func (cadr func-and-name))
	       (name (car func-and-name)))
	   (func)
	   (if (not (> (edit-position ind 0) 0)) (snd-display #__line__ ";~A: unblocked edit: ~A" name (edit-position ind 0)))
	   (if (not (> edit-hook-ctr 0)) (snd-display #__line__ ";~A: unblocked edit hook calls: ~A" name edit-hook-ctr))
	   (if (not (> after-edit-hook-ctr 0)) (snd-display #__line__ ";~A: unblocked after edit hook calls: ~A" name after-edit-hook-ctr))
	   (set! edit-hook-ctr 0)
	   (set! after-edit-hook-ctr 0)
	   (revert-sound ind)))
       all-tests)
      
      (if (and (provided? 'snd-motif)
	       (provided? 'xm))
	  (let* ((edhist (list-ref (channel-widgets ind 0) 7))
		 (edp (XtParent edhist)))
	    (XtUnmanageChild edp) 
	    (XtVaSetValues edp (list XmNpaneMinimum 1))  ; not 0 here -- Xt warnings
	    (XtManageChild edp)))
      
      (close-sound ind))
    
    (add-hook! mouse-enter-text-hook
	       (lambda (w)
		 (focus-widget w)))
    (add-hook! mouse-leave-text-hook
	       (lambda (w)
		 (focus-widget w)))
    (describe-hook mouse-enter-text-hook)
    (reset-almost-all-hooks)
    
    (let ((ind (open-sound "oboe.snd")))
      (scale-by 2.0)
      (add-hook! (edit-hook ind 0) (lambda () #t))
      (mix-vct (make-vct 10 .1) 0)
      (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";mix-vct: blocked edit: ~A" (edit-position ind 0)))
      (if (not (equal? (mixes ind 0) '())) (snd-display #__line__ ";mix-vct edit-hook: mixes: ~A" (mixes ind 0)))
      (mix "pistol.snd" 1000)
      (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";mix: blocked edit: ~A" (edit-position ind 0)))
      (if (not (equal? (mixes ind 0) '())) (snd-display #__line__ ";mix edit-hook: mixes: ~A" (mixes ind 0)))
      (reset-hook! (edit-hook ind 0))
      (let ((mx (mix-vct (make-vct 10 .1) 1000)))
	(if (mix? mx) ; might be no-gui case
	    (begin
	      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";mix-vct: unblocked edit: ~A" (edit-position ind 0)))
	      (if (not (equal? (mixes ind 0) (list mx))) (snd-display #__line__ ";mix-vct un edit-hook: mixes: ~A" (mixes ind 0)))
	      (add-hook! (edit-hook ind 0) (lambda () #t))
	      (set! (mix-amp mx) 2.0)
	      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";mix amp: blocked edit: ~A" (edit-position ind 0)))
	      (if (fneq (mix-amp mx) 1.0) (snd-display #__line__ ";mix amp: blocked edit: ~A" (mix-amp mx)))
	      (set! (mix-amp-env mx) '(0 0 1 1 2 0))
	      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";mix amp env: blocked edit: ~A" (edit-position ind 0)))
	      (if (not (null? (mix-amp-env mx))) (snd-display #__line__ ";mix amp env: blocked edit: ~A" (mix-amp-env mx)))
	      (set! (mix-speed mx) 2.0)
	      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";mix speed: blocked edit: ~A" (edit-position ind 0)))
	      (if (fneq (mix-speed mx) 1.0) (snd-display #__line__ ";mix speed: blocked edit: ~A" (mix-speed mx)))
	      (set! (mix-position mx) 2000)
	      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";mix position: blocked edit: ~A" (edit-position ind 0)))
	      (if (not (= (mix-position mx) 1000)) (snd-display #__line__ ";mix position: blocked edit: ~A" (mix-position mx)))
	      (mix-vct (make-vct 10 .2) 0)
	      (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";mix-vct 1: blocked edit: ~A" (edit-position ind 0)))
	      (if (not (equal? (mixes ind 0) (list mx))) (snd-display #__line__ ";mix-vct 1 edit-hook: mixes: ~A" (mixes ind 0)))
	      )))
      (close-sound ind))
    
    (let ((ind (open-sound "oboe.snd")))
      (if (not (hook-empty? (edit-hook ind 0))) (snd-display #__line__ ";edit-hook not cleared at close?"))
      (if (not (hook-empty? (after-edit-hook ind 0))) (snd-display #__line__ ";after-edit-hook not cleared at close?"))
      (close-sound ind))
    
    (reset-almost-all-hooks)
    
    ;; before|after-save-as-hook
    (let ((hook-called #f))
      (add-hook! before-save-as-hook ; from docs
		 (lambda (index filename selection sr type format comment)
		   (if (not (= sr (srate index)))
		       (let ((chns (chans index)))
			 (do ((i 0 (+ 1 i)))
			     ((= i chns))
			   (src-channel (exact->inexact (/ (srate index) sr)) 0 #f index i))
			 (save-sound-as filename index :header-type type :data-format format :srate sr :comment comment) 
			 ;; hook won't be invoked recursively
			 (do ((i 0 (+ 1 i)))
			     ((= i chns))
			   (undo 1 index i))
			 (set! hook-called #t)
			 #t)
		       #f)))
      (let ((ind (open-sound "2.snd")))
	(save-sound-as "test.snd" :srate 44100)
	(if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";before-save-as-hook undo: ~A" (edit-position ind 0)))
	(if (not hook-called) (snd-display #__line__ ";before-save-as-hook not called?"))
	(close-sound ind)
	(set! ind (open-sound "test.snd"))
	(if (not (= (srate ind) 44100)) (snd-display #__line__ ";before-save-as-hook src: ~A" (srate ind)))
	(close-sound ind))
      (reset-hook! before-save-as-hook))
    
    (let ((need-save-as-undo #f))
      (add-hook! before-save-as-hook
		 (lambda (index filename selection sr type format comment)
		   (set! need-save-as-undo #f)
		   (if (not (= sr (srate index)))
		       (begin
			 (src-sound (exact->inexact (/ (srate index) sr)) 1.0 index)
			 (set! need-save-as-undo #t)))
		   #f))
      (add-hook! after-save-as-hook
		 (lambda (index filename dialog)
		   (if need-save-as-undo (undo))))
      (let ((ind (open-sound "oboe.snd")))
	(save-sound-as "test.snd" :srate 44100)
	(if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";after-save-as-hook undo: ~A" (edit-position ind 0)))
	(close-sound ind)
	(set! ind (open-sound "test.snd"))
	(if (not (= (srate ind) 44100)) (snd-display #__line__ ";before|after-save-as-hook src: ~A" (srate ind)))
	(close-sound ind))
      (reset-hook! before-save-as-hook)
      (reset-hook! after-save-as-hook))
    
    (let* ((sound-changed #f)
	   (read-only-changed #f)
	   (marks-changed #f)
	   (selection-changed #f)
	   (sound-selection-changed #f)
	   (cur-sounds (sounds))
	   (cur-marks (marks))
	   (cur-read-only (map read-only (sounds)))
	   (cur-selection (selection?))
	   (cur-selected-sound (selected-sound))
	   (cur-selected-channel (and cur-selected-sound (selected-channel)))
	   (called #f))
      (let ((w1 (add-watcher (lambda ()
			       (set! called #t)
			       (if (not (equal? (sounds) cur-sounds))
				   (begin
				     (set! sound-changed #t)
				     (set! cur-sounds (sounds))))
			       (if (not (equal? cur-selection (selection?)))
				   (begin
				     (set! selection-changed #t)
				     (set! cur-selection (selection?))))
			       (if (not (equal? cur-marks (marks)))
				   (begin
				     (set! marks-changed #t)
				     (set! cur-marks (marks))))
			       (let ((rdonly (map read-only (sounds))))
				 (if (not (equal? cur-read-only rdonly))
				     (begin
				       (set! read-only-changed #t)
				       (set! cur-read-only rdonly))))
			       (if (or (not (equal? cur-selected-sound (selected-sound)))
				       (not (equal? cur-selected-channel (and cur-selected-sound (selected-channel)))))
				   (begin
				     (set! sound-selection-changed #t)
				     (set! cur-selected-sound (selected-sound))
				     (set! cur-selected-channel (and cur-selected-sound (selected-channel)))))))))
	(let ((ind (open-sound "oboe.snd")))
	  (if (not sound-changed)
	      (snd-display #__line__ ";watcher missed sound open? ")
	      (set! sound-changed #f))
	  
	  (set! (read-only ind) #t)
	  (if (not read-only-changed)
	      (snd-display #__line__ ";watcher missed read-only? ")
	      (set! read-only-changed #f))
	  
	  (let ((m1 (add-mark 123 ind 0)))
	    (if (not marks-changed)
		(snd-display #__line__ ";watcher missed add mark? ")
		(set! marks-changed #f))
	    
	    (set! called #f) ; too hard to track mark samples here
	    (set! (mark-sample m1) 321)
	    (if (not called)
		(snd-display #__line__ ";watcher missed move mark? ")
		(set! marks-changed #f))
	    (delete-mark m1)
	    (if (not marks-changed)
		(snd-display #__line__ ";watcher missed delete mark? ")
		(set! marks-changed #f)))
	  
	  (let ((ind1 (open-sound "2.snd")))
	    (if (not sound-changed)
		(snd-display #__line__ ";watcher missed 2 sound open? ")
		(set! sound-changed #f))
	    (select-sound ind)
	    (if (not sound-selection-changed)
		(snd-display #__line__ ";watcher missed select sound?")
		(set! sound-selection-changed #f))
	    (select-sound ind1)
	    (if (not sound-selection-changed)
		(snd-display #__line__ ";watcher missed select sound 1?")
		(set! sound-selection-changed #f))
	    (select-channel 1)
	    (if (not sound-selection-changed)
		(snd-display #__line__ ";watcher missed select channel?")
		(set! sound-selection-changed #f))
	    (close-sound ind1)
	    (if (not sound-changed)
		(snd-display #__line__ ";watcher missed 2 sound close? ")
		(set! sound-changed #f)))
	  
	  (select-all ind)
	  (if (not selection-changed)
	      (snd-display #__line__ ";watcher missed selection")
	      (set! selection-changed #f))
	  
	  (set! (selection-member? ind 0) #f)
	  (if (not selection-changed)
	      (snd-display #__line__ ";watcher missed selection change")
	      (set! selection-changed #f))
	  (set! sound-changed #f)
	  (delete-watcher w1)
	  (close-sound ind)
	  (if sound-changed
	      (snd-display #__line__ ";deleted watcher runs anyway?")))))
    
    (let ((old-clip (clipping))
	  (old-mus-clip (mus-clipping)))
      (set! (clipping) #t)
      (set! (mus-clipping) #t)
      (reset-hook! clip-hook)
      
      (let ((index (new-sound "test.snd" mus-next mus-bshort 22050 1 "clip-hook test" 10)))
	(map-channel (lambda (y) (mus-random 0.999))) ; -amp to amp
	(set! (sample 2) 1.0001)
	(set! (sample 4) -1.0)
	(set! (sample 6) 1.5)
	(set! (sample 8) -1.5)
	(let ((hook-called 0)
	      (vals (channel->vct 0 10 index)))
	  (add-hook! clip-hook (lambda (val)
				 (if (and (fneq val 1.0)
					  (fneq val 1.5)
					  (fneq val -1.5))
				     (snd-display #__line__ ";clip-hook called upon: ~A" val))
				 (set! hook-called (+ 1 hook-called))
				 0.0))
	  (save-sound index)
	  (reset-hook! clip-hook)
	  (if (not (= hook-called 3)) (snd-display #__line__ ";clip-hook called ~A times" hook-called))
	  (close-sound index)
	  (set! index (open-sound "test.snd"))
	  (let ((new-vals (channel->vct 0 10 index))
		(fixed-vals (vct-copy vals)))
	    (vct-set! fixed-vals 2 0.0)
	    (vct-set! fixed-vals 6 0.0)
	    (vct-set! fixed-vals 8 0.0)
	    (if (not (vequal fixed-vals new-vals))
		(snd-display #__line__ ";clip-hook results:~%    ~A~%    ~A~%    ~A" new-vals fixed-vals vals)))
	  (close-sound index)))
      (set! (clipping) old-clip)
      (set! (mus-clipping) old-mus-clip))
    ))



;;; ---------------- test 14: all together now ----------------

(define sfile 0) ; used globally by save-state stuff (... is this a bug?)

(define (safe-make-selection beg end snd) ; used in test_15 also
  "make-region with error checks"
  (let ((len (frames snd))
	(old-choice (selection-creates-region)))
    (set! (selection-creates-region) #t)
    (if (> len 1)
	(if (< end len)
	    (make-selection beg end snd)
	    (if (< beg len)
		(make-selection beg (- len 1) snd)
		(make-selection 0 (- len 1) snd))))
    (set! (selection-creates-region) old-choice)))

(define (flatten lst)
  (cond ((null? lst) '())
	((list-p lst)
	 (if (list-p (car lst))
	     (append (flatten (car lst)) (flatten (cdr lst)))
	     (cons (car lst) (flatten (cdr lst)))))
	(#t lst)))


(define (snd_test_14)
  
  (define (test-panel func name)
    (if (and (not (feql (func #t) (map func (sounds))))
	     (not (feql (func #t) (map func (reverse (sounds))))))
	(snd-display #__line__ ";test-panel ~A: ~A ~A?" name (func #t) (map func (sounds)))))
  
  (define (all-chans-reversed)
    (let ((sndlist '())
	  (chnlist '()))
      (for-each (lambda (snd)
		  (do ((i (- (channels snd) 1) (- i 1)))
		      ((< i 0))
		    (set! sndlist (cons snd sndlist))
		    (set! chnlist (cons i chnlist))))
		(reverse (sounds)))
      (list sndlist chnlist)))
  
  (define (test-channel func name)
    (if (and (not (equal? (flatten (func #t #t)) (apply map func (all-chans))))
	     (not (equal? (flatten (func #t #t)) (apply map func (all-chans-reversed)))))
	(snd-display #__line__ ";test-channel ~A: ~A ~A?" name (flatten (func #t #t)) (apply map func (all-chans)))))
  
  (define duration 
    (lambda (ind)
      (/ (frames ind) (srate ind))))
  
  (define outputs (make-vector 24))
  (define delay-line #f)
  (define delay-time 0.5)
  (define rev-funcs-set #f)
  
  (let* ((cur-dir-files (remove-if 
			 (lambda (file) (<= (catch #t 
						   (lambda () 
						     (mus-sound-frames file))
						   (lambda args 0))
					    0))
			 (sound-files-in-directory ".")))
	 (cur-dir-len (length cur-dir-files))
	 (stereo-files '())
	 (quad-files '())
	 (mono-files '())
	 (octo-files '())
	 (open-files '())
	 (s8-snd (if (file-exists? "s8.snd") "s8.snd" "oboe.snd"))
	 (open-ctr 0))
    
    (define* (clone-sound-as new-name snd)
      ;; copies any edit-sounds to save-dir!
      (let* ((tmpf (snd-tempnam))
	     (scm (string-append (substring tmpf 0 (- (string-length tmpf) 3)) "scm"))
	     (oldsnd (or snd (selected-sound))))
	(if (not (string? (save-dir))) (set! (save-dir) "/tmp"))
	(save-edit-history scm oldsnd)
	(copy-file (file-name oldsnd) new-name)
	(set! sfile (open-sound new-name))
	(load scm)
	(delete-file scm)
	sfile))
    
    
    (add-hook! after-open-hook (lambda (snd)
				 (make-player snd 0)))
    (do ((i 0 (+ 1 i)))
	((= i cur-dir-len))
      (let* ((name (list-ref cur-dir-files i))
	     (ht (mus-sound-header-type name))
	     (df (mus-sound-data-format name))
	     (len (mus-sound-frames name))
	     (chans (mus-sound-chans name)))
	(if (and (not (= ht mus-raw))
		 (not (= len 0))
		 (not (= df -1)))
	    (if (= chans 1)
		(set! mono-files (cons name mono-files))
		(if (= chans 2)
		    (set! stereo-files (cons name stereo-files))
		    (if (= chans 4)
			(set! quad-files (cons name quad-files))
			(if (= chans 8)
			    (set! octo-files (cons name octo-files)))))))))
    
    (if (not buffer-menu)
	(set! buffer-menu (add-to-main-menu "Buffers")))
    (add-hook! open-hook open-buffer)
    (add-hook! close-hook close-buffer)
    
    (do ((test-ctr 0 (+ 1 test-ctr)))
	((= test-ctr tests))
      (if (> (length open-files) 8)
	  (begin
	    (for-each close-sound open-files)
	    (set! open-files '()))
	  (if (> test-ctr 0)
	      (for-each
	       (lambda (snd)
		 (let ((mxpos (edit-position snd 0))
		       (chns (chans snd)))
		   (if (> chns 1)
		       (do ((chn 1 (+ 1 chn)))
			   ((= chn chns))
			 (set! mxpos (+ mxpos (edit-position snd chn)))))
		   (if (or (> mxpos 100) (> chns 4))
		       (begin
			 (snd-display #__line__ ";revert ~A at ~A" (file-name snd) mxpos)
			 (revert-sound snd)))))
	       (sounds))))
      (clear-sincs)      
      (log-mem test-ctr)
      
      (if (and (> test-ctr 0) (< test-ctr 10)) ; this creates too many leftover save-state sound files
	  (let ((files (length (sounds))))
	    (if (file-exists? "s61.scm") (delete-file "s61.scm"))
	    (for-each
	     (lambda (s)
	       (if (> (chans s) 4)
		   (begin
		     (set! open-files (remove-if (lambda (a) (= a s)) open-files))
		     (close-sound s))))
	     (sounds))
	    (save-state "s61.scm")
	    (for-each close-sound (sounds))
	    (for-each forget-region (regions))
	    (catch #t
		   (lambda ()
		     (load (string-append cwd "s61.scm")))
		   (lambda args args))
	    (if (not (= (length (sounds)) files))
		(snd-display #__line__ ";save state restart from ~A to ~A sounds?" files (length (sounds))))
	    (set! open-files (sounds))))
      
      (let* ((len (length open-files))
	     (open-chance (max 0.0 (* (- 8 len) .125)))
	     (close-chance (* len .125)))
	(let* ((choice (random cur-dir-len))
	       (name (list-ref cur-dir-files choice))
	       (ht (mus-sound-header-type name))
	       (df (mus-sound-data-format name))
	       (fd (if (or (= ht mus-raw) (= df -1)) -1 (view-sound name))))
	  (if (and (number? fd)
		   (not (= fd -1)))
	      (set! open-files (cons fd open-files))))
	
	(set! open-ctr (length open-files))
	(if (= open-ctr 0)
	    (let ((fd (view-sound "oboe.snd")))
	      (set! open-ctr 1)
	      (set! open-files (cons fd open-files))))
	
	(let ((choose-fd (lambda () (list-ref (sounds) (random (length (sounds)))))))
	  (let* ((frame-list (map frames open-files))
		 (curfd (choose-fd))
		 (curloc (max 0 (min 1200 (frames curfd 0))))
		 (old-marks (length (marks curfd 0))))
	    (set! test14-file (short-file-name curfd))
	    (if (> (duration curfd) 0.0)
		(begin
		  (set! (x-bounds curfd) (list 0.0 (min (duration curfd) 1.0)))
		  (let ((xb (x-bounds curfd)))
		    (if (or (fneq (car xb) 0.0) 
			    (fneq (cadr xb) (min (duration curfd) 1.0))) 
			(snd-display #__line__ ";x-bounds: ~A?" xb)))))
	    (set! (y-bounds curfd) (list -0.5 0.5))
	    (let ((yb (y-bounds curfd)))
	      (if (or (fneq (car yb) -0.5) (fneq (cadr yb) 0.5)) (snd-display #__line__ ";y-bounds: ~A?" yb)))
	    (set! (cursor curfd 0) curloc)
	    (let ((cl (cursor curfd 0)))
	      (if (and (not (= cl curloc))
		       (> (frames curfd 0) curloc))
		  (begin
		    (snd-display #__line__ ";cursor ~A /= ~A (frames: ~A)?" cl curloc (frames curfd 0))
		    (set! curloc (cursor curfd 0)))))
	    (if (>= curloc (frames curfd 0)) (set! curloc 0))
	    (let* ((id (catch #t (lambda () (add-mark curloc curfd)) (lambda args -1))))
	      (if (and (number? id) (not (= id -1)))
		  (let* ((cl (mark-sample id))
			 (new-marks (length (marks curfd 0))))
		    (if (not (= cl curloc)) (snd-display #__line__ ";mark ~A /= ~A?" cl curloc))
		    (if (not (= new-marks (+ 1 old-marks))) (snd-display #__line__ ";marks ~A ~A?" new-marks old-marks))
		    (let ((new-id (find-mark curloc curfd)))
		      (if (or (not (mark? new-id))
			      (not (= id new-id)))
			  (snd-display #__line__ ";find-mark (by sample): ~A ~A (~A for ~A ~A)?" 
				       id new-id curloc (mark-sample id) (mark-sample new-id))))
		    (set! (mark-name id) "hiho")
		    (let ((new-id (find-mark "hiho" curfd)))
		      (if (or (not (mark? new-id))
			      (not (= id new-id)))
			  (snd-display #__line__ ";find-mark (by name): ~A ~A?" id new-id)))
		    (if (not (string=? (mark-name id) "hiho")) (snd-display #__line__ ";mark name: ~A?" (mark-name id)))
		    (set! (mark-sample id) (max 0 (- curloc 100)))
		    (set! cl (mark-sample id))
		    (if (not (= cl (max 0 (- curloc 100)))) (snd-display #__line__ ";set mark ~A /= ~A?" cl curloc))
		    (delete-mark id)))
	      (if (> (duration curfd) 1.2) (set! (x-bounds curfd) '(1.0 1.1)))
	      (if (> (frames curfd) 25)
		  (begin
		    (add-mark 10 curfd)
		    (add-mark 20 curfd)
		    (key (char->integer #\m) 0 curfd)
		    (set! (cursor curfd) 0)
		    (forward-mark 1 curfd)
		    (if (and (> (frames curfd) 10)
			     (not (= (cursor curfd) 10)))
			(snd-display #__line__ ";forward-mark (10): ~A (~A)?" (cursor curfd) (frames curfd)))
		    (forward-mark 1 curfd)
		    (if (and (> (frames curfd) 20)
			     (not (= (cursor curfd) 20)))
			(snd-display #__line__ ";forward-mark (20): ~A (~A)?" (cursor curfd) (frames curfd)))
		    (set! (cursor curfd) 25)
		    (backward-mark 2 curfd)
		    (if (and (> (frames curfd) 10)
			     (not (= (cursor curfd) 10)))
			(snd-display #__line__ ";backward-mark (10): ~A (~A)?" (cursor curfd) (frames curfd)))
		    (let ((new-marks (length (marks curfd 0))))
		      (delete-marks curfd)
		      (if (> (duration curfd) 0.0)
			  (set! (x-bounds curfd) (list 0.0 (min (duration curfd) 0.1))))
		      (set! (y-bounds curfd) '(-1.0 1.0))
		      (if (or (> (length (marks curfd 0)) 0)
			      (not (= new-marks (+ old-marks 3))))
			  (snd-display #__line__ ";delete marks: ~A ~A?" new-marks old-marks)))))
	      ))
	  
	  (revert-sound)
	  (let ((old-setting (selection-creates-region)))
	    (set! (selection-creates-region) #t)
	    (let ((reg (select-all)))
	      (without-errors
	       (if (and (region? reg) 
			(selection?))
		   (let ((r1 (region-rms (car (regions))))
			 (r2 (selection-rms))
			 (r3 (selection-rms-1))
			 (r4 (region-rms-1 (car (regions)))))
		     (if (fneq r1 r4)
			 (snd-display #__line__ ";region rms: ~A ~A?" r1 r4))
		     (if (fneq r2 r3)
			 (snd-display #__line__ ";selection rms: ~A ~A?" r2 r3))))))
	    (set! (selection-creates-region) old-setting))
	  
	  (forward-graph 1)
	  (backward-graph 1)
	  
	  (without-errors (if (region? (cadr (regions))) (play (cadr (regions)) :wait #t)))
	  (without-errors (mix-region (car (regions))))
	  (if (< (frames) 100000) (play :wait #t))
	  (scale-to .1 (choose-fd))
	  (scale-by 2.0 (choose-fd))
	  (save-controls)
	  (set! (amp-control) .5)
	  (test-panel amp-control 'amp-control)
	  (restore-controls)
	  (report-in-minibuffer "hi")
	  
	  (without-errors
	   (begin
	     (let ((cfd (choose-fd)))
	       (safe-make-selection 1000 2000 cfd)
	       (src-selection .5)
	       (undo 1 cfd))
	     (let ((cfd (choose-fd)))
	       (safe-make-selection 1000 2000 cfd)
	       (src-selection -1.5)
	       (undo 1 cfd))
	     (let ((cfd (choose-fd)))
	       (safe-make-selection 1000 2000 cfd)
	       (scale-selection-by .5)
	       (undo 1 cfd))
	     (let ((cfd (choose-fd)))
	       (safe-make-selection 1000 2000 cfd)
	       (env-selection '(0 0 1 1 2 0))
	       (undo 1 cfd))
	     (let ((cfd (choose-fd)))
	       (safe-make-selection 1000 2000 cfd)
	       (scale-selection-to .5)
	       (reverse-selection)
	       (undo 2 cfd))
	     (if (> (length (regions)) 2) (forget-region (list-ref (regions) 2)))))
	  (for-each revert-sound open-files)
	  
	  (without-errors
	   (let ((cfd (car open-files)))
	     (set! (sync cfd) 1)
	     (if (not (null? (cdr open-files))) (set! (sync (cadr open-files)) 1))
	     (safe-make-selection 1000 2000 cfd)
	     (src-selection .5)
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (src-selection -1.5)
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (env-selection '(0 0 1 1 2 0))
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (reverse-selection)
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (filter-selection '(0 0 .1 1 1 0) 40)
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (convolve-selection-with "oboe.snd")
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (smooth-selection)
	     (undo 1 cfd)
	     (safe-make-selection 1000 2000 cfd)
	     (scale-selection-by .5)
	     (undo 1 cfd)
	     (scale-selection-to .5)
	     (reverse-selection)
	     (undo 2)
	     (src-selection '(0 .5 1 1))
	     (undo)
	     (revert-sound cfd)
	     (if (not (null? (cdr open-files))) (revert-sound (cadr open-files)))))
	  
	  (if (and (> (frames) 1)
		   (< (frames) 1000000))
	      (begin
		(make-region 0 (frames))
		(convolve-selection-with "fyow.snd" .5)
		(play :wait #t)))
	  (if (and (> (frames) 1)
		   (< (frames) 1000000))
	      (convolve-with "fyow.snd" .25))
	  (insert-sound "oboe.snd")
	  (reset-hook! graph-hook)
	  (reset-hook! after-transform-hook)
	  (for-each revert-sound open-files)
	  
	  (let ((ind (choose-fd)))
	    (select-sound ind)
	    (for-each
	     (lambda (func func1)
	       (pad-channel 0 100 ind 0)
	       (func 0)
	       (pad-channel 0 100 ind 0)
	       (func1 0)
	       (revert-sound ind)
	       (if (> (chans ind) 1)
		   (begin
		     (pad-channel 0 100 ind 1)
		     (func 0)
		     (pad-channel 0 100 ind 1)
		     (func1 0)
		     (revert-sound ind)))
	       (delete-samples 0 1000 ind 0)
	       (func (* 2 (frames ind 0)))
	       (delete-samples 0 10000 ind 0)
	       (func1 (* 2 (frames ind 0)))
	       (revert-sound ind)
	       (if (> (chans ind) 1)
		   (begin
		     (delete-samples 0 1000 ind 1)
		     (func (* 2 (frames ind 1)))
		     (delete-samples 0 10000 ind 1)
		     (func1 (* 2 (frames ind 1)))
		     (revert-sound ind))))
	     (list (lambda (beg) (insert-sound "2a.snd" beg))
		   (lambda (beg) (reverse-sound))
		   (lambda (beg) (scale-sound-by 2.0))
		   (lambda (beg) (convolve-with "2a.snd" 0.5))
		   (lambda (beg) (env-sound '(0 0 1 1 2 0)))
		   (lambda (beg) (smooth-sound)))
	     (list (lambda (beg) (insert-sound "4a.snd" beg))
		   (lambda (beg) (reverse-sound))
		   (lambda (beg) (scale-sound-to 0.5))
		   (lambda (beg) (src-sound 2.0))
		   (lambda (beg) (env-sound '(0 0 1 1)))
		   (lambda (beg) (insert-silence beg 100)))))
	  
	  (let ((ind (open-sound "z.snd")))
	    (if (not (= (frames ind) 0)) (snd-display #__line__ ";frames z.snd ~A" (frames ind)))
	    (if (not (eq? (samples) #f)) (snd-display #__line__ ";samples of empty file (z): ~A" (samples)))
	    (if (not (eq? (channel->vct) #f)) (snd-display #__line__ ";channel->vct of empty file (z): ~A" (channel->vct)))
	    (if (fneq (maxamp ind) 0.0) (snd-display #__line__ ";maxamp z.snd ~A" (maxamp ind)))
	    (if (fneq (sample 100 ind) 0.0) (snd-display #__line__ ";sample 100 z.snd ~A" (sample 100 ind)))
	    (scale-by 2.0)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";scale z: ~A" (edit-position ind 0)))
	    (env-sound '(0 0 1 1))
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";env z: ~A" (edit-position ind 0)))
	    (smooth-sound)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";smooth z: ~A" (edit-position ind 0)))
	    (reverse-sound)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";reverse z: ~A" (edit-position ind 0)))
	    (src-sound 2.0)
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";src z: ~A" (edit-position ind 0)))
	    (insert-sound "z.snd")
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";insert z: ~A" (edit-position ind 0)))
	    (mix "z.snd")
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";mix z: ~A" (edit-position ind 0)))
	    (filter-sound (make-one-zero :a0 2.0 :a1 0.0))
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";filter z: ~A" (edit-position ind 0)))
	    (if (not (= (mus-sound-duration "z.snd") 0.0)) (snd-display #__line__ ";duration z.snd: ~A" (mus-sound-duration "z.snd")))
	    (catch 'IO-error
		   (lambda () (convolve-with "z.snd" 1.0))
		   (lambda args args))
	    (if (not (= (edit-position ind 0) 0)) (snd-display #__line__ ";convolve z: ~A" (edit-position ind 0)))
	    (let ((tag (catch #t (lambda () (find-channel (lambda (y) *> y .1))) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-sample)) (snd-display #__line__ ";find z: ~A" tag)))
	    (let ((tag (catch #t (lambda () (count-matches (lambda (y) *> y .1))) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-sample)) (snd-display #__line__ ";count z: ~A" tag)))
	    (let* ((reader (make-sampler 0))
		   (val (next-sample reader))
		   (str (format #f "~A" reader)))
	      (if (fneq val 0.0) (snd-display #__line__ ";sampler z.snd: ~A" val))
	      (if (not (string? str)) (snd-display #__line__ ";z.snd reader: ~A" str)))
	    (if (not (equal? (cursor-position) (list 0 0))) (snd-display #__line__ ";cursor-position z: ~A" (cursor-position)))
	    (if (not (= (cursor) 0)) (snd-display #__line__ ";cursor z: ~A" (cursor)))
	    (let ((outer (make-player ind 0)))
	      (let ((pl (make-player ind 0)))
		(add-player pl)
		(start-playing 1 22050 #f))
	      (revert-sound ind)
	      (set! (transform-graph? ind 0) #t)
	      (add-hook! lisp-graph-hook display-energy)
	      (set! (x-bounds) (list 0.0 .01))
	      (set! (sample 0) 0.5)
	      (set! (x-bounds) (list 0.0 .001))
	      (close-sound ind)
	      (let ((tag (catch #t (lambda () (add-player outer)) (lambda args (car args)))))
		(if (not (eq? tag 'no-such-player))
		    (snd-display #__line__ ";dangling player: ~A" tag)))))
	  (if (channel-amp-envs "z.snd" 0 100)
	      (snd-display #__line__ ";channel-amp-envs of empty file: ~A" (channel-amp-envs "z.snd" 0 100)))
	  
	  (let ((zz (view-sound "z.snd")))
	    (select-sound zz)
	    (let ((md (mix "4.aiff")))
	      (add-mark 0)
	      (add-mark 1200)
	      (delete-marks))
	    (revert-sound zz)
	    
	    (let ((editctr (edit-position zz))
		  (old-selection-choice (selection-creates-region)))
	      (set! (selection-creates-region) #t)
	      (if (not (= (edit-position) 0)) (snd-display #__line__ ";revert-sound edit-position: ~A" (edit-position)))
	      (as-one-edit 
	       (lambda ()
		 (mix s8-snd 24000)
		 (let ((reg (select-all)))
		   (if (selection?) 
		       (begin
			 (filter-selection '(0 0 .2 1 .5 0 1 0) 40)
			 (delete-selection)
			 (mix-region reg))))))
	      (if (not (= (edit-position) 1)) (snd-display #__line__ ";as-one-edit mix zz: ~A -> ~A" editctr (edit-position)))
	      (set! (selection-creates-region) old-selection-choice))
	    (close-sound zz))
	  (let ((s8 (view-sound s8-snd)))
	    (select-sound s8)
	    (if (= (channels s8) 8)
		(begin
		  (select-channel 5)
		  (if (or (not (number? (selected-channel)))
			  (not (= (selected-channel) 5))) 
		      (snd-display #__line__ ";select-channel: ~A?" (selected-channel)))))
	    (let ((editctr (edit-position)))
	      (as-one-edit 
	       (lambda ()
		 (let ((reg (select-all)))
		   (delete-selection)
		   (mix "4.aiff")
		   (set! (sync) 1)
		   (mix "oboe.snd" 60000)
		   (scale-by .1)
		   (set! (sync) 1)
		   (if (> (channels s8) 3)
		       (select-channel 3))
		   (if (region? reg)
		       (insert-region reg 80000)))))
	      (if (not (= (edit-position) (+ 1 editctr))) (snd-display #__line__ ";as-one-edit s8: ~A -> ~A" editctr (edit-position))))
	    (revert-sound s8)
	    (close-sound s8))
	  
	  (let ((cfd (choose-fd)))
	    (if (> (chans cfd) 1)
		(let ((uval (random 3)))
		  (set! (channel-style cfd) uval)
		  (if (not (= uval (channel-style cfd))) (snd-display #__line__ ";channel-style: ~A ~A?" uval (channel-style cfd)))))
	    (src-sound 2.5 1.0 cfd)
	    (src-sound -2.5 1.0 cfd)
	    (src-sound .5 1.0 cfd)
	    (revert-sound cfd)
	    (src-sound -.5 1.0 cfd)
	    (src-sound '(0 .5 1 1.5) 1.0 cfd)
	    (if (> (frames cfd) 0) (src-sound (make-env '(0 .5 1 1.5) :length (frames cfd)) 1.0 cfd))
	    (revert-sound cfd)
	    (filter-sound '(0 1 .2 0 .5 1 1 0) 20 cfd)
	    (filter-sound '(0 0 .1 0 .11 1 .12 0 1 0) 2048 cfd)
	    (env-sound '(0 0 .5 1 1 0) 0 (frames cfd) 1.0 cfd)
	    (insert-sample 1200 .1 cfd)
	    (if (fneq (sample 1200 cfd) .1) (snd-display #__line__ ";insert-sample(looped): ~A?" (sample 1200 cfd)))
	    (revert-sound cfd))
	  
	  (let ((cfd (open-sound "obtest.snd")))
	    (select-sound cfd)
	    (let ((cfd2 (open-sound "pistol.snd")))
	      (select-sound cfd2)
	      ;; now run apply a few times
	      (set! (amp-control) .5) 
	      (set! (speed-control) 2.0) 
	      (test-panel speed-control 'speed-control)
	      (apply-controls) 
	      (if (< (frames) 100000) (play :wait #t))
	      
	      (if (fneq (reverb-control-decay cfd) (reverb-control-decay))
		  (snd-display #__line__ ";reverb-control-decay local: ~A, global: ~A" (reverb-control-decay cfd) (reverb-control-decay)))
	      (set! (reverb-control?) #t)
	      (set! (reverb-control-scale) .2) 
	      (test-panel reverb-control-scale 'reverb-control-scale)
	      (test-panel reverb-control-length 'reverb-control-length)
	      (test-panel reverb-control-lowpass 'reverb-control-lowpass)
	      (test-panel reverb-control-feedback 'reverb-control-feedback)
	      (apply-controls) 
	      (if (< (frames) 100000) (play :wait #t))
	      (set! (contrast-control?) #t)
	      (set! (contrast-control) .5) 
	      (test-panel contrast-control 'contrast-control)
	      (test-panel contrast-control-amp 'contrast-control-amp)
	      (apply-controls) 
	      (if (< (frames) 100000) (play :wait #t))
	      (set! (expand-control?) #t)
	      (set! (expand-control) 2.5) 
	      (test-panel expand-control 'expand-control)
	      (test-panel expand-control-length 'expand-control-length)
	      (test-panel expand-control-hop 'expand-control-hop)
	      (test-panel expand-control-ramp 'expand-control-ramp)
	      (apply-controls) 
	      (if (< (frames) 100000) (play :wait #t))
	      (set! (filter-control?) #t)
	      (set! (filter-control-order) 40) 
	      (test-panel filter-control-order 'filter-control-order)
	      (set! (filter-control-envelope) '(0 0 .1 1 .2 0 1 0)) 
	      (filter-control-envelope) 
	      (apply-controls) 
	      (if (< (frames) 100000) (play :wait #t))
	      (set! (amp-control) 1.5) 
	      (test-panel amp-control 'amp-control)
	      (apply-controls) 
	      (if (< (frames) 100000) (play :wait #t))
	      (swap-channels cfd 0 cfd2 0)
	      (set! (amp-control #t) .75)
	      (test-panel amp-control 'amp-control)
	      (if (> (abs (- (amp-control cfd2) .75)) .05) (snd-display #__line__ ";set-amp .75 #t -> ~A?" (amp-control cfd2)))
	      (set! (contrast-control-amp #t) .75)
	      (if (fneq (contrast-control-amp cfd2) .75) (snd-display #__line__ ";set-contrast-control-amp .75 #t -> ~A?" (contrast-control-amp cfd2)))
	      (set! (contrast-control-bounds cfd2) (list 2.0 3.0))
	      (if (not (feql (contrast-control-bounds cfd2) (list 2.0 3.0))) 
		  (snd-display #__line__ ";cfd2 contrast-control-bounds: ~A" (contrast-control-bounds cfd2)))
	      (set! (expand-control-length #t) .025)
	      (if (fneq (expand-control-length cfd2) .025) (snd-display #__line__ ";set-expand-control-length .025 #t -> ~A?" (expand-control-length cfd2)))
	      (set! (expand-control-hop #t) .025)
	      (if (fneq (expand-control-hop cfd2) .025) (snd-display #__line__ ";set-expand-control-hop .025 #t -> ~A?" (expand-control-hop cfd2)))
	      (set! (expand-control-jitter #t) .025)
	      (if (fneq (expand-control-jitter cfd2) .025) (snd-display #__line__ ";set-expand-control-jitter .025 #t -> ~A?" (expand-control-jitter cfd2)))
	      (set! (expand-control-ramp #t) .025)
	      (if (fneq (expand-control-ramp cfd2) .025) (snd-display #__line__ ";set-expand-control-ramp .025 #t -> ~A?" (expand-control-ramp cfd2)))
	      (let ((clone (clone-sound-as "/tmp/cloned.snd" cfd2)))
		(if (not (= (frames cfd2) (frames clone)))
		    (snd-display #__line__ ";clone frames: ~A ~A" (frames cfd2) (frames clone)))
		(close-sound clone))
	      (delete-file "/tmp/cloned.snd")
	      (mus-sound-forget "/tmp/cloned.snd")
	      (close-sound cfd2)
	      (close-sound cfd)))
	  (add-hook! (edit-hook) (lambda () #f))
	  (let ((editctr (edit-position)))
	    (as-one-edit (lambda () (set! (sample 200) .2) (set! (sample 300) .3)))
	    (if (not (= (edit-position) (+ 1 editctr))) (snd-display #__line__ ";as-one-edit: ~A -> ~A" editctr (edit-position)))
	    (as-one-edit (lambda () #f))
	    (if (not (= (edit-position) (+ 1 editctr))) (snd-display #__line__ ";as-one-edit nil: ~A -> ~A" editctr (edit-position))))
	  (delete-sample 250)
	  (add-hook! (undo-hook) (lambda () #f))
	  (undo)
	  (delete-sample 250)
	  (undo)
	  (as-one-edit (lambda () (set! (sample 20) .2) (set! (sample 30) .3)))
	  (undo 1)
	  (as-one-edit (lambda () (set! (sample 2) .2) (as-one-edit (lambda () (set! (sample 3) .3)))))
	  (undo 2)
	  (reset-hook! (undo-hook))
	  (reset-hook! (edit-hook))
					;	    (add-hook! snd-error-hook 
					;		       (lambda (msg) 
					;			 (if (not (string=? msg "hiho")) (snd-display #__line__ ";snd-error-hook: ~A?" msg))
					;			 #t))
					;	    (snd-error "hiho")
	  (add-hook! snd-warning-hook 
		     (lambda (msg) 
		       (if (not (string=? msg "hiho")) (snd-display #__line__ ";snd-warning-hook: ~A?" msg))
		       #t))
	  (snd-warning "hiho")
	  (reset-hook! snd-error-hook)
	  (reset-hook! snd-warning-hook)
	  (add-hook! name-click-hook 
		     (lambda (n) 
		       #t))
	  (redo 1)
	  (reset-hook! name-click-hook)
	  (set! (transform-graph?) #t)
	  (test-channel transform-graph? 'transform-graph?)
	  (test-channel time-graph? 'time-graph?)
	  (test-channel lisp-graph? 'lisp-graph?)
	  (test-channel frames 'frames)
	  (test-channel cursor 'cursor)
	  (test-channel cursor-size 'cursor-size)
	  (test-channel cursor-style 'cursor-style)
	  (test-channel tracking-cursor-style 'tracking-cursor-style)
	  (test-channel left-sample 'left-sample)
	  (test-channel right-sample 'right-sample)
	  (test-channel squelch-update 'squelch-update)
	  (test-channel x-zoom-slider 'x-zoom-slider)
	  (test-channel y-zoom-slider 'y-zoom-slider)
	  (test-channel x-position-slider 'x-position-slider)
	  (test-channel y-position-slider 'y-position-slider)
	  (test-channel edit-position 'edit-position)
	  (test-channel maxamp 'maxamp)
	  (test-channel edit-hook 'edit-hook)
	  (test-channel after-edit-hook 'after-edit-hook)
	  (test-channel undo-hook 'undo-hook)
	  (if (<= tests 2)
	      (set! (transform-type)
		    (add-transform "histogram" "bins" 0.0 1.0 
				   (lambda (len fd)
				     (let ((v (make-vct len))
					   (steps (/ len 16))
					   (step (/ 1.0 len)))
				       (vct-fill! v 0.0)
				       (do ((i 0 (+ 1 i)))
					   ((= i len) v)
					 (let* ((val (abs (next-sample fd)))
						(bin (round (* val 16.0))))
					   (if (< bin steps)
					       (do ((j 0 (+ 1 j)))
						   ((= j steps))
						 (vct-set! v (+ j bin) (+ step (vct-ref v (+ j bin)))))))))))))
	  (set! (x-bounds) '(.1 .2))
	  (set! (transform-type) fourier-transform)
	  (set! (x-bounds) '(.1 .2))
	  (add-hook! lisp-graph-hook display-energy)
	  (reset-hook! graph-hook)
	  (if (= (channels) 2)
	      (begin
		(add-hook! graph-hook display-correlation)
		(set! (x-bounds) '(.1 .12))
		(set! (x-bounds) '(.1 .2))
		(remove-hook! graph-hook display-correlation)))
	  (set! (lisp-graph?) #f)
	  (map-chan 
	   (let ((sum-of-squares 0.0)
		 (buffer (make-vct 128 0.0))
		 (position 0)
		 (current-sample 0)
		 (chan-samples (frames)))
	     (lambda (y)
	       (let ((old-y (vct-ref buffer position)))
		 (set! sum-of-squares (- (+ sum-of-squares (* y y)) (* old-y old-y)))
		 (vct-set! buffer position y)
		 (set! position (+ 1 position))
		 (if (= position 128) (set! position 0))
		 (set! current-sample (+ 1 current-sample))
		 (if (> sum-of-squares .01)
		     (if (= current-sample chan-samples)
			 ;; at end return trailing samples as long as it looks like sound
			 (let ((temp-buffer (make-vct 128 0.0)))
			   (do ((i 0 (+ 1 i)))
			       ((= i 128) temp-buffer)
			     (let ((final-y (vct-ref buffer position)))
			       (vct-set! temp-buffer i (if (> sum-of-squares .01) final-y 0.0))
			       (set! sum-of-squares (- sum-of-squares (* final-y final-y)))
			       (set! position (+ 1 position))
			       (if (= position 128) (set! position 0)))))
			 old-y)
		     #f)))))
	  
	  (let ((maxval1 (+ (maxamp) .01)))
	    (if (not (every-sample? (lambda (y) (< y maxval1)))) 
		(let ((res (scan-chan (lambda (y) (>= y maxval1)))))
		  (snd-display #__line__ ";~A, every-sample: ~A ~A [~A: ~A]?" (short-file-name) maxval1 res (cursor) (sample (cursor)))
		  (do ((i 0 (+ 1 i)))
		      ((= i (edit-position)))
		    (snd-display #__line__ ";~D: ~A ~A" i (maxamp #f 0 i) (edit-fragment i))))))
	  
	  (map-chan (echo .5 .75) 0 60000)
	  (reset-hook! after-transform-hook)
	  (reset-hook! lisp-graph-hook)
	  
	  (add-hook! lisp-graph-hook 
		     (lambda (snd chn) 
		       (if (> (random 1.0) .5) 
			   (graph (vct 0 1 2)) 
			   (graph (list (vct 0 1 2) (vct 3 2 0))))))
	  
	  (for-each
	   (lambda (snd)
	     (set! (sync snd) (floor (random 3)))
	     (update-lisp-graph snd))
	   (sounds))
	  (add-hook! graph-hook superimpose-ffts)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (for-each
	     (lambda (snd)
	       (if (> (frames snd) 0)
		   (let* ((dur (floor (/ (frames snd) (srate snd))))
			  (start (max 0.0 (min (- dur .1) (random dur)))))
		     (if (> dur 0.0) 
			 (set! (x-bounds snd 0) (list start (min (+ start .1) dur))))))
	       (update-time-graph snd)
	       (update-lisp-graph snd)
	       (update-transform-graph snd))
	     (sounds)))
	  (reset-hook! graph-hook)
	  (reset-hook! lisp-graph-hook)
	  
	  ;; new variable settings 
	  (letrec ((reset-vars
		    (lambda (lst)
		      (if (not (null? lst))
			  (let* ((name (list-ref (car lst) 0))
				 (index (if (list-ref (car lst) 2) (choose-fd) #f))
				 (getfnc (list-ref (car lst) 1))
				 (setfnc (lambda (val snd) (set! (getfnc snd) val)))
				 (setfnc-1 (lambda (val) (set! (getfnc) val)))
				 (minval (list-ref (car lst) 3))
				 (maxval (list-ref (car lst) 4)))
			    
			    (if index
				(if (equal? minval #f)
				    (setfnc #t index)
				    (if (rational? minval)
					(if (equal? name #t)
					    (setfnc (floor (expt 2 (min 31 
									(ceiling (/ (log (+ minval (floor (* (- maxval minval) (random 1.0)))))
										    (log 2))))))
						    index)
					    (setfnc (+ minval (floor (* (- maxval minval) (random 1.0)))) index))
					(setfnc (+ minval (* (- maxval minval) (random 1.0))) index)))
				(if (equal? minval #f)
				    (setfnc-1 #t)
				    (if (rational? minval)
					(if (equal? name #t)
					    (setfnc-1 (floor (expt 2 (min 31 (ceiling (/ (log (+ minval (floor (* (- maxval minval) (random 1.0)))))
											 (log 2)))))))
					    (setfnc-1 (+ minval (floor (* (- maxval minval) (random 1.0))))))
					(setfnc-1 (+ minval (* (- maxval minval) (random 1.0)))))))
			    (reset-vars (cdr lst)))))))
	    (reset-vars 
	     (list
	      (list 'amp-control amp-control #t .1 1.0)
					;(list 'ask-before-overwrite ask-before-overwrite #f #f #t)
	      (list 'auto-resize auto-resize #f #f #t)
	      (list 'auto-update auto-update #f #f #t)
	      (list 'channel-style channel-style #f 0 2)
	      (list 'color-cutoff color-cutoff #f 0.0 0.2)
	      (list 'color-inverted color-inverted #f #f #t)
	      (list 'color-scale color-scale #f 0.1 1000.0)
	      (list 'contrast-control contrast-control #t 0.0 1.0)
	      (list 'contrast-control-amp contrast-control-amp #t 0.0 1.0)
	      (list 'contrast-control? contrast-control? #t #f #t)
	      (list 'auto-update-interval auto-update-interval #f 60.0 120.0)
	      (list 'cursor-update-interval cursor-update-interval #f 0.05 .1)
	      (list 'cursor-location-offset cursor-location-offset #f 0 1024)
	      (list 'with-tracking-cursor with-tracking-cursor #f #f #t)
	      (list 'cursor-size cursor-size #f 15 25)
	      (list 'cursor-style cursor-style #f cursor-cross cursor-line)
	      (list 'tracking-cursor-style tracking-cursor-style #f cursor-cross cursor-line)
	      (list 'clipping clipping #f #f #t)
					;(list 'default-output-chans default-output-chans #f 1 8)
					;(list 'default-output-data-format default-output-data-format #f 1 12)
					;(list 'default-output-srate default-output-srate #f 22050 44100)
					;(list 'default-output-header-type default-output-header-type #f 0 2)
	      (list 'dot-size dot-size #f 1 10)
	      (list 'enved-base enved-base #f 0.01  100.0)
	      (list 'enved-clip? enved-clip? #f #f #t)
	      (list 'enved-in-dB enved-in-dB #f #f #t)
	      (list 'enved-style enved-style #f envelope-linear envelope-exponential)
	      (list 'enved-power enved-power #f 3.0 3.5)
	      (list 'enved-target enved-target #f 0 2)
	      (list 'enved-wave? enved-wave? #f #f #t)
	      (list 'expand-control expand-control #t 0.1 5.0)
	      (list 'expand-control-hop expand-control-hop #t 0.01 0.5)
	      (list 'expand-control-jitter expand-control-jitter #t 0.01 0.5)
	      (list 'expand-control-length expand-control-length #t 0.1 0.25)
	      (list 'expand-control-ramp expand-control-ramp #t 0.1 0.4)
	      (list 'expand-control? expand-control? #t #f #t)
	      (list 'fft-window-alpha fft-window-alpha #f 0.0  1.0)
	      (list 'fft-window-beta fft-window-beta #f 0.0  1.0)
	      (list 'fft-log-frequency fft-log-frequency #f #f #t)
	      (list 'fft-log-magnitude fft-log-magnitude #f #f #t)
	      (list 'fft-with-phases fft-with-phases #f #f #t)
	      (list 'transform-size transform-size #f 16 (if (<= tests 10) 4096 128))
	      (list 'transform-graph-type transform-graph-type #f graph-once graph-as-spectrogram)
	      (list 'fft-window fft-window #f 0 dolph-chebyshev-window)
	      (list 'transform-graph? transform-graph? #t #f #t)
	      (list 'filter-control-in-dB filter-control-in-dB #t #f #t)
	      (list 'filter-control-in-hz filter-control-in-hz #t #f #t)
	      (list 'filter-control-order filter-control-order #t 2 (if (<= tests 10) 400 40))
	      (list 'filter-control? filter-control? #t #f #t)
	      (list 'graph-cursor graph-cursor #f 0 35)
	      (list 'time-graph-style time-graph-style #f 0 4)
	      (list 'lisp-graph-style lisp-graph-style #f 0 4)
	      (list 'transform-graph-style transform-graph-style #f 0 4)
	      (list 'graphs-horizontal graphs-horizontal #f #f #t)
	      (list 'max-transform-peaks max-transform-peaks #f 1 100)
	      (list 'max-regions max-regions #f 1 32)
	      (list 'min-dB min-dB #f -120.0 -30.0)
	      (list 'log-freq-start log-freq-start #f 50.0 5.0)
	      (list 'selection-creates-region selection-creates-region #f #f #t)
	      (list 'transform-normalization transform-normalization #f dont-normalize normalize-globally)
	      (list 'view-files-sort view-files-sort #f 0 3)
	      (list 'print-length print-length #f 2 32)
	      (list 'region-graph-style region-graph-style #f graph-lines graph-lollipops)
	      (list 'reverb-control-decay reverb-control-decay #f 0.0 2.0)
	      (list 'reverb-control-feedback reverb-control-feedback #t 1.00 1.1)
	      (list 'reverb-control-length reverb-control-length #t 1.0 2.0)
	      (list 'reverb-control-lowpass reverb-control-lowpass #t 0.2 0.99)
	      (list 'reverb-control-scale reverb-control-scale #t 0.0 0.2)
	      (list 'reverb-control? reverb-control? #t #f #t)
	      (list 'show-axes show-axes #f 0 2)
	      (list 'show-transform-peaks show-transform-peaks #f #f #t)
	      (list 'show-indices show-indices #f #f #t)
	      (list 'show-marks show-marks #f #f #t)
	      (list 'show-mix-waveforms show-mix-waveforms #t #f #t)
	      (list 'show-selection-transform show-selection-transform #f #f #t)
	      (list 'show-y-zero show-y-zero #f #f #t)
	      (list 'show-grid show-grid #f #f #t)
	      (list 'grid-density grid-density 1.0 0.1 4.0)
	      (list 'show-sonogram-cursor show-sonogram-cursor #f #f #t)
	      (list 'sinc-width sinc-width #f 4 100)
	      (list 'spectrum-end spectrum-end #f 0.5 0.8)
	      (list 'spectro-hop spectro-hop #f 2 20)
	      (list 'spectrum-start spectrum-start #f 0.0 0.1)
	      (list 'spectro-x-angle spectro-x-angle #f 0.0 90.0)
	      (list 'spectro-x-scale spectro-x-scale #f 0.1 2.0)
	      (list 'spectro-y-angle spectro-y-angle #f 0.0 90.0)
	      (list 'spectro-y-scale spectro-y-scale #f 0.1 2.0)
	      (list 'spectro-z-angle spectro-z-angle #f 0.0 359.0)
	      (list 'spectro-z-scale spectro-z-scale #f 0.1 0.2)
	      (list 'speed-control speed-control #t 0.1 5.0)
	      (list 'speed-control-style speed-control-style #f 0 2)
	      (list 'speed-control-tones speed-control-tones #f 2 100)
	      (list 'sync sync #t 0 5)
	      (list 'with-verbose-cursor with-verbose-cursor #f #f #t)
	      (list 'wavelet-type wavelet-type #f 0 10)
	      (list 'time-graph? time-graph? #t #f #t)
	      (list 'x-axis-style x-axis-style #f 0 2)
	      (list 'beats-per-minute beats-per-minute #f 60.0 120.0)
	      (list 'beats-per-measure beats-per-measure #f 4 120)
	      (list 'zero-pad zero-pad #f 0 2)
	      (list 'zoom-focus-style zoom-focus-style #f 0 3))))
	  
	  (if (not (equal? (transform-type) fourier-transform))
	      (begin
		(set! (transform-graph? #t #t) #f)
		(set! (transform-size) (min (transform-size) 128))))
	  )))
    (if open-files (for-each close-sound open-files))
    (set! open-files '())
    (set! (mus-rand-seed) 1234)
    (if (not (= (mus-rand-seed) 1234)) (snd-display #__line__ ";mus-rand-seed: ~A (1234)!" (mus-rand-seed)))
    (let ((val (mus-random 1.0))
	  (val1 (mus-random 1.0)))
      (if (or (fneq val -0.7828) 
	      (fneq val1 -0.8804))
	  (snd-display #__line__ ";mus-random: ~A ~A?" val val1))
      (if (= (mus-rand-seed) 1234) (snd-display #__line__ ";mus-rand-seed: ~A!" (mus-rand-seed))))
    (set! (mus-rand-seed) 1234)
    (let ((val (mus-random 1.0))
	  (val1 (mus-random 1.0)))
      (if (or (fneq val -0.7828) 
	      (fneq val1 -0.8804))
	  (snd-display #__line__ ";mus-random repeated: ~A ~A?" val val1)))
    (reset-hook! after-open-hook)
    (reset-hook! close-hook)
    (reset-hook! open-hook)
    
    (set! (clipping) #f)
    (for-each close-sound (sounds))
    )
  )




;;; ---------------- test 15: chan-local vars ----------------

(if (not (provided? 'snd-rubber.scm)) (load "rubber.scm"))

(define (snd_test_15)
  (define (smoother y0 y1 num)
    (let ((v (make-vct (+ 1 num))) 
	  (angle (if (> y1 y0) pi 0.0)) 
	  (off (* .5 (+ y0 y1))) 
	  (incr (/ pi num))
	  (scale (* 0.5 (abs (- y1 y0)))))
      (do ((i 0 (+ 1 i)))
	  ((= i num) v)
	(vct-set! v i (+ off (* scale (cos (+ angle (* i incr)))))))))
  
  (define prefix-it
    (lambda (n id)
      (let* ((ns (number->string n))
	     (digits (string-length ns)))
	(key (char->integer #\u) 0 id)
	(do ((i 0 (+ 1 i)))
	    ((= i digits))
	  (key (char->integer (string-ref ns i)) 0 id)))))
  
  (define prefix-uit
    (lambda (n id)
      (let* ((ns (number->string n))
	     (digits (string-length ns)))
	(do ((i 0 (+ 1 i)))
	    ((= i digits))
	  (key (char->integer (string-ref ns i)) 0 id)))))
  
  (define funcs (list time-graph-type wavo-hop wavo-trace max-transform-peaks show-transform-peaks zero-pad transform-graph-type fft-window 
		      with-verbose-cursor fft-log-frequency fft-log-magnitude fft-with-phases min-dB
		      wavelet-type transform-size fft-window-alpha fft-window-beta transform-type 
		      transform-normalization show-mix-waveforms graph-style dot-size show-axes show-y-zero show-grid show-marks grid-density
		      spectro-x-angle spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale
		      spectro-hop spectrum-end spectrum-start graphs-horizontal x-axis-style beats-per-minute beats-per-measure
		      cursor-size cursor-style tracking-cursor-style show-sonogram-cursor
		      ))
  (define func-names (list 'time-graph-type 'wavo-hop 'wavo-trace 'max-transform-peaks 'show-transform-peaks 'zero-pad 'transform-graph-type 'fft-window
			   'with-verbose-cursor 'fft-log-frequency 'fft-log-magnitude 'fft-with-phases 'min-dB
			   'wavelet-type 'transform-size 'fft-window-alpha 'fft-window-beta 'transform-type
			   'transform-normalization 'show-mix-waveforms 'graph-style 'dot-size 'show-axes 'show-y-zero 'show-grid 'show-marks 'grid-density
			   'spectro-x-angle 'spectro-x-scale 'spectro-y-angle 'spectro-y-scale 'spectro-z-angle 'spectro-z-scale
			   'spectro-hop 'spectrum-end 'spectrum-start 'graphs-horizontal 'x-axis-style 'beats-per-minute 'beats-per-measure
			   'cursor-size 'cursor-style 'tracking-cursor-style 'show-sonogram-cursor
			   ))
  (define new-values (list graph-as-wavogram 12 512 3 #t 32 graph-as-sonogram cauchy-window
			   #t #t #t #t -120.0
			   3 32 .5 .5 autocorrelation
			   0 #t graph-lollipops 8 show-no-axes #t #t #f 1.0
			   32.0 .5 32.0 .5 32.0 .5
			   14 .3 .1 #f x-axis-in-samples 120.0 3
			   15 cursor-cross cursor-cross #t
			   ))
  
  (define (test-history-channel func name new-value snd1 snd2 snd3)
    (define test-equal
      (lambda (nv new-value)
	(if (and (number? nv)
		 (not (rational? nv)))
	    (not (fneq nv new-value))
	    (equal? nv new-value))))
    (define chan-equal? 
      (lambda (vals new-value)
	(cond ((null? vals) #t)
	      ((list-p vals) (and (chan-equal? (car vals) new-value)
				  (chan-equal? (cdr vals) new-value)))
	      (else (test-equal vals new-value)))))
    (if (and (not (equal? (flatten (func #t #t)) (apply map func (all-chans))))
	     (not (equal? (flatten (func #t #t)) (apply map func (all-chans-reversed)))))
	(snd-display #__line__ ";test-history-channel ~A[0]: ~A ~A?" name (flatten (func #t #t)) (apply map func (all-chans))))
    (let ((old-value (func))
	  (old-chan-value (func snd1 0)))
      (set! (func snd1 0) new-value)
      (let ((nv (func snd1 0)))
	(if (not (test-equal nv new-value))
	    (snd-display #__line__ ";test-history-channel set-~A[1]: ~A ~A?" name new-value (func snd1 0))))
      (set! (func snd3 2) new-value)
      (let ((nv (func snd3 2)))
	(if (not (test-equal nv new-value))
	    (snd-display #__line__ ";test-history-channel set-~A[2]: ~A ~A?" name new-value (func snd3 2))))
      (if (not (test-equal old-value new-value))
	  (let ((nv (func snd3 1)))
	    (if (test-equal nv new-value)
		(snd-display #__line__ ";test-history-channel set-~A[3]: ~A ~A?" name new-value (func snd3 1)))))
      (set! (func snd2 #t) new-value)
      (let ((nv (func snd2 1)))
	(if (not (test-equal nv new-value))
	    (snd-display #__line__ ";test-history-channel set-~A[4]: ~A ~A?" name new-value (func snd2 1))))
      (set! (func) new-value)
      (if (not (chan-equal? (flatten (func #t #t)) new-value))
	  (snd-display #__line__ ";test-history-channel ~A[5]: ~A ~A?" name (flatten (func #t #t)) (apply map func (all-chans))))
      (set! (func) old-value)
      ))
  
  ;; test src-* 
  
  (define (freq-peak beg ind size)
    (define (interpolated-peak-offset la ca ra)
      (let* ((pk (+ .001 (max la ca ra)))
	     (logla (/ (log (/ (max la .0000001) pk)) (log 10)))
	     (logca (/ (log (/ (max ca .0000001) pk)) (log 10)))
	     (logra (/ (log (/ (max ra .0000001) pk)) (log 10))))
	(/ (* 0.5 (- logla logra))
	   (- (+ logla logra)
	      (* 2 logca)))))
    (let* ((data (channel->vct beg size ind 0))
	   (spectr (snd-spectrum data blackman2-window size))
	   (peak0 0.0)
	   (pk0loc 0))
      (do ((i 0 (+ 1 i)))
	  ((= i (/ size 2)) 
	   (list (/ (* (+ pk0loc
			  (if (> pk0loc 0)
			      (interpolated-peak-offset 
			       (vct-ref spectr (- pk0loc 1))
			       (vct-ref spectr pk0loc)
			       (vct-ref spectr (+ 1 pk0loc)))
			      0.0))
		       (srate))
		    size)
		 peak0))
	(if (> (vct-ref spectr i) peak0)
	    (begin
	      (set! peak0 (vct-ref spectr i))
	      (set! pk0loc i))))))
  
  (define (test-selection ind beg len scaler)
    (set! (selection-member? ind 0) #t)
    (set! (selection-position) beg)
    (set! (selection-frames) len)
    (scale-selection-by scaler)
    (let* ((diff 0.0)
	   (pos (edit-position ind 0))
	   (old-reader (make-sampler beg ind 0 1 (- pos 1)))
	   (new-reader (make-sampler beg ind 0 1 pos)))
      (do ((i 0 (+ 1 i)))
	  ((= i len))
	(let* ((ov (* scaler (old-reader)))
	       (nv (next-sample new-reader))
	       (val (abs (- ov nv))))
	  (set! diff (+ diff val))))
      (if (> diff 0.0) (snd-display #__line__ ";diff (~D ~D): ~A" beg len diff))
      (set! diff 0.0)
      (do ((i 0 (+ 1 i)))
	  ((= i 100))
	(let* ((ov (next-sample old-reader))
	       (nv (next-sample new-reader))
	       (val (abs (- ov nv))))
	  (set! diff (+ diff val))))
      (if (> diff 0.0) (snd-display #__line__ ";zdiff (~D ~D): ~A" beg len diff))
      (free-sampler old-reader)
      (free-sampler new-reader)))
  
  (define (test-selection-to ind beg len maxval)
    (set! (selection-member? ind 0) #t)
    (set! (selection-position) beg)
    (set! (selection-frames) len)
    (scale-selection-to maxval)
    (let* ((newmax 0.0)
	   (new-reader (make-sampler beg ind 0)))
      (do ((i 0 (+ 1 i)))
	  ((= i len))
	(let* ((nv (abs (next-sample new-reader))))
	  (if (> nv newmax) (set! newmax nv))))
      (if (fneq newmax maxval)
	  (snd-display #__line__ ";scale-selection-to (~D ~D) ~A: ~A?" beg len maxval newmax))
      (free-sampler new-reader)))
  
  (define play-with-amps
    (lambda (sound . amps)
      (let ((chans (chans sound)))
	(do ((chan 0 (+ 1 chan)))
	    ((= chan chans))
	  (let ((player (make-player sound chan)))
	    (if (not (player? player)) (snd-display #__line__ ";player? ~A -> #f?" player))
	    (if (not (member player (players))) (snd-display #__line__ ";player: ~A, but players: ~A" player (players)))
	    (if (not (equal? (player-home player) (list sound chan)))
		(snd-display #__line__ ";player-home ~A ~A?" (player-home player) (list sound chan)))
	    (set! (amp-control player) (list-ref amps chan))
	    (set! (speed-control player) .5)
	    (set! (expand-control? player) #t)
	    (set! (expand-control player) 2.0)
	    (set! (contrast-control? player) #t)
	    (set! (contrast-control player) 1.0)
	    (set! (reverb-control? player) #t)
	    (set! (reverb-control-scale player) .02)
	    (add-player player)))
	(start-playing chans (srate sound) #f))))
  
  ;; examp.scm (commented out)
  (define (sound-via-sound snd1 snd2) ; "sound composition"??
    (let* ((intrp (make-sound-interp 0 snd1 0))
	   (len (- (frames snd1 0) 1))
	   (rd (make-sampler 0 snd2 0))
	   (mx (maxamp snd2 0)))
      (map-channel (lambda (val) 
		     (sound-interp intrp (floor (* len (* 0.5 (+ 1.0 (/ (read-sample rd) mx))))))))))
  
  (set! (transform-type) fourier-transform)
  
  (if with-gui
      (begin
	
	(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests)) 
	  (log-mem clmtest)
	  
	  (let ((obi (open-sound (car (match-sound-files (lambda (file) 
							   (and (not (= (mus-sound-header-type file) mus-raw))
								(= (mus-sound-chans file) 1))))))))
	    
	    (if (not (equal? (all-chans) (list (list obi) (list 0)))) (snd-display #__line__ ";all-chans: ~A?" (all-chans)))
	    (let ((s2i (open-sound (car (match-sound-files (lambda (file) (= (mus-sound-chans file) 2)))))))
	      (if (and (not (equal? (all-chans) (list (list obi s2i s2i) (list 0 0 1))))
		       (not (equal? (all-chans) (list (list s2i s2i obi) (list 0 1 0)))))
		  (snd-display #__line__ ";all-chans(2): ~A?" (all-chans)))
	      (if (not (string=? (finfo "oboe.snd") "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.305"))
		  (snd-display #__line__ ";finfo: ~A?" (finfo "oboe.snd")))
	      (close-sound s2i)
	      (close-sound obi)
	      (if (not (equal? (all-chans) '(() ()))) (snd-display #__line__ ";all-chans(0): ~A?" (all-chans)))
	      (set! obi (open-sound "oboe.snd"))
	      (set! (cursor obi) 1000)
	      (let ((tick (locate-zero .001)))
		(if (not (= tick 1050)) 
		    (snd-display #__line__ ";locate-zero: ~A = ~A (second try: ~A)?" tick (sample tick) (locate-zero .001))))
	      (add-hook! graph-hook auto-dot)
	      (add-hook! graph-hook superimpose-ffts)
	      (set! (transform-graph? obi 0) #t)
	      (update-graphs)
	      (set! s2i (open-sound (car (match-sound-files (lambda (file) (= (mus-sound-chans file) 2))))))
	      (if (not (= (chans s2i) 2)) (snd-display #__line__ ";match 2 got ~A with ~A chans" (short-file-name s2i) (chans s2i)))
	      (update-graphs)
	      (remove-hook! graph-hook auto-dot)
	      (remove-hook! graph-hook superimpose-ffts)
	      (set! (transform-graph? obi 0) #f)
	      (select-sound obi)
	      (let ((m1 (add-mark 100 obi 0)))
		(first-mark-in-window-at-left)
		(if (> (abs (- (left-sample obi 0) 100)) 1) (snd-display #__line__ ";mark-in-window: ~A ~A?" (left-sample obi 0) (mark-sample m1)))
		(delete-mark m1))
	      (close-sound s2i)
	      (safe-make-selection 1000 2000 obi)
	      (delete-selection-and-smooth)
	      (if (not (equal? (edit-fragment 0 obi 0) '(#f "init" 0 50828))) 
		  (snd-display #__line__ ";edit-fragment(0): ~S?" (edit-fragment 0 obi 0)))
	      (if (not (equal? (edit-fragment 1 obi 0) '("delete-samples 1000 1001" "delete" 1000 1001))) 
		  (snd-display #__line__ ";edit-fragment(1): ~S?" (edit-fragment 1 obi 0)))
	      (if (not (equal? (edit-fragment 2 obi 0) '("smooth-channel 984 32" "set" 984 32))) 
		  (snd-display #__line__ ";edit-fragment(2): ~S?" (edit-fragment 2 obi 0)))
	      
	      (let ((samp100 (sample 1100 obi 0)))
		(select-sound obi)
		(safe-make-selection 1000 2000 obi)
		(eval-over-selection (lambda (val) (* 2.0 val)))
		(let ((nsamp100 (sample 1100 obi 0)))
		  (if (fneq (* 2.0 samp100) nsamp100) 
		      (snd-display #__line__ ";eval-over-selection: ~A ~A [~A ~A]?" 
				   samp100 nsamp100 (selection-position) (selection-frames)))
		  (let ((m2 (add-mark 1000 obi 0))
			(m3 (add-mark 2000 obi 0)))
		    (if (not (equal? (marks obi 0) (list m2 m3))) (snd-display #__line__ ";add-mark: ~A ~A?" (marks obi 0) (list m2 m3)))
		    (set! (left-sample obi 0) 950)
		    (eval-between-marks (lambda (val) (* 2.0 val)))
		    (let ((msamp100 (sample 1100 obi 0)))
		      (if (fneq (* 2.0 nsamp100) msamp100) (snd-display #__line__ ";eval-between-marks: ~A ~A?" nsamp100 msamp100))
		      (revert-sound obi)))))
	      (let ((maxa (maxamp obi)))
		(normalized-mix "pistol.snd" 1000 0 obi 0)
		(let ((nmaxa (maxamp obi)))
		  (if (fneq maxa nmaxa) (snd-display #__line__ ";normalized-mix: ~A ~A?" maxa nmaxa)))
		(revert-sound obi))
	      (set! s2i (open-sound (car (match-sound-files (lambda (file) 
							      (and (= (mus-sound-chans file) 2)
								   (not (= (mus-sound-header-type file) mus-raw))
								   (> (mus-sound-frames file) 1000)))))))
	      (if (not (= (chans s2i) 2)) (snd-display #__line__ ";match 2+1000 got ~A with ~A chans" (short-file-name s2i) (chans s2i)))
	      (let ((o1 (sample 1000 obi 0))
		    (s1 (sample 1000 s2i 0))
		    (s2 (sample 1000 s2i 1)))
		(do-all-chans (lambda (val) (if val (* 2.0 val) #f)) "double all samples")
		(let ((o11 (sample 1000 obi 0))
		      (s11 (sample 1000 s2i 0))
		      (s21 (sample 1000 s2i 1)))
		  (if (or (fneq (* 2.0 o1) o11)
			  (fneq (* 2.0 s1) s11)
			  (fneq (* 2.0 s2) s21))
		      (snd-display #__line__ ";do-all-chans: ~A?" (list o1 s1 s2 o11 s11 s21)))))
	      (update-graphs)
	      (let ((m1 (maxamp obi 0))
		    (m2 (maxamp s2i 0))
		    (m3 (maxamp s2i 1))
		    (mc (apply map maxamp (list (list obi s2i s2i) (list 0 0 1)))))
		(if (or (fneq m1 (car mc))
			(fneq m2 (cadr mc))
			(fneq m3 (caddr mc)))
		    (snd-display #__line__ ";map maxamp all-chans: ~A ~A ~A ~A?" m1 m2 m3 mc))
		(set! (sync obi) 1)
		(set! (sync s2i) 1)
		(do-chans (lambda (val) (if val (* 2.0 val) #f)) "*2")
		(let ((mc1 (apply map maxamp (list (list obi s2i s2i) (list 0 0 1)))))
		  (if (or (fneq (* 2.0 m1) (car mc1))
			  (fneq (* 2.0 m2) (cadr mc1))
			  (fneq (* 2.0 m3) (caddr mc1)))
		      (snd-display #__line__ ";do-chans: ~A ~A?" mc mc1))
		  (set! (sync obi) 0)
		  (set! (sync s2i) 0)
		  (select-sound s2i)
		  (do-sound-chans (lambda (val) (if val (* 0.5 val) #f)) "/2")
		  (let ((mc2 (apply map maxamp (list (list obi s2i s2i) (list 0 0 1)))))
		    (if (or (fneq (* 2.0 m1) (car mc2))
			    (fneq m2 (cadr mc2))
			    (fneq m3 (caddr mc2)))
			(snd-display #__line__ ";do-sound-chans: ~A ~A ~A?" mc mc1 mc2)))
					;		  (if (every-sample? (lambda (val) (> val .5))) (snd-display #__line__ ";every-sample(0)?")) 
		  (if (not (every-sample? (lambda (val) (< val 5.0)))) (snd-display #__line__ ";every-sample(1)?")) 
		  (select-sound obi)
		  (let ((bins (sort-samples 32)))
		    (if (not (= (vector-ref bins 1) 4504)) (snd-display #__line__ ";sort-samples: ~A?" bins)))
		  ))
	      (revert-sound s2i)
	      (revert-sound obi)
	      (set! (sync obi) 3)
	      (set! (sync s2i) 3)
	      (let* ((half-way (floor (* 0.5 (frames obi))))
		     (o1 (sample half-way obi 0))
		     (s1 (sample half-way s2i 0))
		     (s2 (sample half-way s2i 1)))
		(place-sound obi s2i '(0 .5 1 .5))
		(let ((s21 (sample half-way s2i 0))
		      (s22 (sample half-way s2i 1)))
		  (revert-sound s2i)
		  (place-sound obi s2i 45.0)
		  (let ((s31 (sample half-way s2i 0))
			(s32 (sample half-way s2i 1)))
		    (if (or (fneq (+ s1 (* 0.5 o1)) s21)
			    (fneq (+ s2 (* 0.5 o1)) s22)
			    (fneq s21 s31)
			    (fneq s22 s32))
			(snd-display #__line__ ";place: ~A " (list o1 s1 s2 s21 s22 s31 s32))))))
	      (revert-sound s2i)
	      (revert-sound obi)
	      (set! (sync obi) 0)
	      (set! (sync s2i) 0)
	      (if (or (fneq ((compand) 0.0) 0.0)
		      (fneq ((compand) 1.0) 1.0)
		      (fneq ((compand) .1) .2)
		      (fneq ((compand) .99) .997)
		      (fneq ((compand) .95) .984))
		  (snd-display #__line__ ";compand: ~A?" (list ((compand) 0.0) ((compand) 1.0) ((compand) .1) ((compand) .99) ((compand) .95))))
	      
	      (close-sound obi)
	      (revert-sound s2i)
	      (let ((s1 (sample 1000 s2i 0))
		    (s2 (sample 1000 s2i 1)))
		(set! (sync s2i) 4)
		(select-all)
		(if (not (= (selection-chans) 2)) 
		    (begin
		      (snd-display #__line__ ";selection-chans(2): ~A?" (selection-chans))
		      (for-each
		       (lambda (snd)
			 (do ((i 0 (+ 1 i)))
			     ((= i (chans snd)))
			   (if (selection-member? snd i)
			       (snd-display #__line__ ";  ~A[~A] at ~A" (short-file-name snd) i (selection-position snd i)))))
		       (sounds))))
		(if (not (= (selection-srate) (srate s2i))) (snd-display #__line__ ";selection-srate: ~A ~A?" (selection-srate) (srate s2i)))
		(if (= (selection-chans) 2)
		    (begin
		      (swap-selection-channels)
		      (if (or (fneq s1 (sample 1000 s2i 1))
			      (fneq s2 (sample 1000 s2i 0)))
			  (snd-display #__line__ ";swap-selection-channels: ~A?" (list s1 s2 (sample 1000 s2i 0) (sample 1000 s2i 1)))))))
	      (revert-sound s2i)
	      (close-sound s2i)
	      
	      (set! obi (open-sound "oboe.snd"))
	      (select-all)
	      (for-each forget-region (regions))
	      (if (not (equal? (regions) '())) (snd-display #__line__ ";no regions? ~A" (regions)))
	      (let ((id (make-region 100 200 obi 0)))
		(if (not (equal? (regions) (list id))) (snd-display #__line__ ";make-region regions: ~A?" (regions))))
	      
	      (revert-sound obi)
	      (let ((oldlen (frames obi)))
		(env-sound-interp '(0 0 1 1 2 0) 2.0 obi 0)
		(let ((newlen (frames obi)))
		  (if (> (abs (- (* 2 oldlen) newlen)) 3)
		      (snd-display #__line__ ";env-sound-interp: ~A ~A?" oldlen newlen))))
	      
	      (revert-sound obi)
	      (granulated-sound-interp '(0 0 1 .1 2 1) 1.0 0.2 '(0 0 1 1 2 0))
	      (if (not (= (edit-position obi 0) 1)) (snd-display #__line__ ";granulated-sound-interp no-op 1?"))
	      (if (< (maxamp obi 0) .15) (snd-display #__line__ ";granulated-sound-interp 1 maxamp: ~A" (maxamp obi 0)))
	      (if (> (abs (- (frames obi 0) 50828)) 1000) (snd-display #__line__ ";granulated-sound-interp 1 frames: ~A" (frames obi 0)))
	      (revert-sound obi)
	      (granulated-sound-interp '(0 0 1 1) 2.0)
	      (if (not (= (edit-position obi 0) 1)) (snd-display #__line__ ";granulated-sound-interp no-op 2?"))
	      (if (< (maxamp obi 0) .15) (snd-display #__line__ ";granulated-sound-interp 2 maxamp: ~A" (maxamp obi 0)))
	      (if (> (abs (- (frames obi 0) 101656)) 1000) (snd-display #__line__ ";granulated-sound-interp 2 frames: ~A" (frames obi 0)))
	      (revert-sound obi)
	      (granulated-sound-interp '(0 0 1 .1 2 1) 1.0 0.2 '(0 0 1 1 2 0) 0.02)
	      (if (not (= (edit-position obi 0) 1)) (snd-display #__line__ ";granulated-sound-interp no-op 3?"))
	      (if (< (maxamp obi 0) .2) (snd-display #__line__ ";granulated-sound-interp 3 maxamp: ~A" (maxamp obi 0)))
	      (if (> (abs (- (frames obi 0) 50828)) 1000) (snd-display #__line__ ";granulated-sound-interp 3 frames: ~A" (frames obi 0)))
	      
	      (close-sound obi)
	      )
	    
	    (let ((old-srate (mus-srate)))
	      (set! (mus-srate) 22050)
	      (let ((ind (new-sound "test.snd" :size 20)))
		(if (< (print-length) 20) (set! (print-length) 20))
		(offset-channel 1.0)
		(env-sound '(0 0 1 1))
		(let ((osc (make-oscil :frequency 1000.0 :initial-phase (+ pi (/ pi 2))))
		      (reader (make-sound-interp 0 ind 0)) 
		      (len (- (frames ind 0) 1)))
		  (map-channel (lambda (val) 
				 (sound-interp reader (* len (+ 0.5 (* 0.5 (oscil osc)))))))
		  (if (not (vequal (channel->vct) (vct 0.000 0.020 0.079 0.172 0.291 0.427 0.569 0.706 0.825 0.919 
						       0.979 1.000 0.981 0.923 0.831 0.712 0.576 0.434 0.298 0.177)))
		      (snd-display #__line__ ";sound-interp: ~A" (channel->vct))))
		(undo)
		
		(let ((osc (make-oscil :frequency 0.5 :initial-phase (+ pi (/ pi 2))))
		      (reader (make-sound-interp 0 ind 0))
		      (len (- (frames ind 0) 1)))
		  (map-channel (lambda (val) 
				 (sound-interp reader (* len (+ 0.5 (* 0.5 (oscil osc))))))))
		(undo)
		
		(env-sound-interp '(0 0 1 1))
		(if (not (vequal (channel->vct) (vct 0.000 0.053 0.105 0.158 0.211 0.263 0.316 0.368 0.421 0.474 
						     0.526 0.579 0.632 0.684 0.737 0.789 0.842 0.895 0.947 1.000)))
		    (snd-display #__line__ ";env-sound-interp no change: ~A" (channel->vct)))
		(undo)
		(env-sound-interp '(0 0 1 .95 2 0) 2.0)
		(if (not (vequal (channel->vct) (vct 0.000 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 
						     0.500 0.550 0.600 0.650 0.700 0.750 0.800 0.850 0.900 0.950
						     1.000 0.950 0.900 0.850 0.800 0.750 0.700 0.650 0.600 0.550 
						     0.500 0.450 0.400 0.350 0.300 0.250 0.200 0.150 0.100 0.050)))
		    (snd-display #__line__ ";env-sound-interp twice len and back: ~A" (channel->vct)))
		(revert-sound ind)
		(set! (sample 10) .5)
		(remove-clicks)
		(if (fneq (sample 10) 0.0) (snd-display #__line__ ";remove-clicks: ~A" (channel->vct)))
		(undo)
		(let ((vals (scan-channel (search-for-click))))
		  (if (not (equal? vals (list #t 11)))
		      (snd-display #__line__ ";search-for-click: ~A" vals)))
		(close-sound ind))
	      (set! (mus-srate) old-srate))
	    
	    (let ((ind1 (new-sound :size 20 :comment "new-sound for sound-via-sound"))
		  (ind2 (new-sound :size 20 :comment "2nd new-sound for sound-via-sound")))
	      (let ((val -0.05)) (map-channel (lambda (y) (set! val (+ val .05)) val) 0 20 ind1))
	      (let ((val 1.1)) (map-channel (lambda (y) (set! val (- val .1)) val) 0 20 ind2))
	      (select-sound ind1)
	      (sound-via-sound ind1 ind2)
	      (let ((vals (channel->vct 0 20 ind1)))
		(if (not (vequal vals (vct 0.95 0.90 0.85 0.80 0.75 0.70 0.65 0.60 0.55 0.50 0.45 0.40 0.35 0.30 0.25 0.20 0.15 0.10 0.05 0.00)))
		    (snd-display #__line__ ";sound-via-sound: ~A" vals)))
	      (let ((new-file-name (file-name ind2)))
		(close-sound ind2)
		(if (file-exists? new-file-name) (delete-file new-file-name)))
	      (revert-sound ind1)
	      (let ((val -.5)) (map-channel (lambda (y) (set! val (+ val .05)) val)))
	      (let ((val (scan-channel (zero+))))
		(if (or (not val)
			(not (equal? val (list #t 10)))) 
		    (snd-display #__line__ ";zero+: ~A" val)))
	      (set! (sample 8) .8)
	      (let ((val (scan-channel (next-peak))))
		(if (or (not val)
			(not (equal? val (list #t 9)))) 
		    (snd-display #__line__ ";next-peak: ~A" val)))
	      (let ((val (scan-channel (search-for-click))))
		(if (or (not val)
			(not (equal? val (list #t 9))))
		    (snd-display #__line__ ";search-for-click: ~A" val)))
	      (if (not (= (find-click 0) 8)) (snd-display #__line__ ";find-click: ~A" (find-click 0)))
	      (let ((new-file-name (file-name ind1)))
		(close-sound ind1)
		(if (file-exists? new-file-name) (delete-file new-file-name))))
	    
	    (let* ((id (open-sound "oboe.snd"))
		   (fr (frames id 0))
		   (mx (maxamp id 0)))
	      (set! (frames id 0) 25000)
	      (if (not (= (frames id 0) 25000)) (snd-display #__line__ ";set-frames 25000: ~A?" (frames id 0)))
	      (if (not (= (edit-position id 0) 1)) (snd-display #__line__ ";set-frames 25000 edit: ~A?" (edit-position id 0)))
	      (set! (frames id 0) 75000)
	      (if (not (= (frames id 0) 75000)) (snd-display #__line__ ";set-frames 75000: ~A?" (frames id 0)))
	      (if (not (= (edit-position id 0) 2)) (snd-display #__line__ ";set-frames 75000 edit: ~A?" (edit-position id 0)))
	      (if (fneq (sample 30000 id 0) 0.0) (snd-display #__line__ ";set-frames 75000 zeros: ~A?" (sample 30000 id 0)))
	      (set! (frames id 0) 0)
	      (if (not (= (frames id 0) 0)) (snd-display #__line__ ";set-frames 0: ~A?" (frames id 0)))
	      (set! (frames id 0) 100)
	      (if (not (= (frames id 0) 100)) (snd-display #__line__ ";set-frames 100: ~A?" (frames id 0)))
	      (revert-sound)
	      (if (fneq (sample 30000 id 0) -0.0844) (snd-display #__line__ ";revert from set-frames: ~A?" (sample 30000 id 0)))
	      (if (not (= fr (frames id 0))) (snd-display #__line__ ";revert set-frames: ~A != ~A?" (frames id 0) fr))
	      (set! (maxamp id 0) .5)
	      (if (fneq (maxamp id 0) .5) (snd-display #__line__ ";set-maxamp: ~A?" (maxamp id 0)))
	      (if (not (= (edit-position id 0) 1)) (snd-display #__line__ ";set-maxamp edit: ~A?" (edit-position id 0)))
	      (set! (maxamp id 0) .1)
	      (if (fneq (maxamp id 0) .1) (snd-display #__line__ ";set-maxamp .1: ~A?" (maxamp id 0)))
	      (if (not (= (edit-position id 0) 2)) (snd-display #__line__ ";set-maxamp .1 edit: ~A?" (edit-position id 0)))
	      (revert-sound)
	      (if (fneq (maxamp id 0) mx) (snd-display #__line__ ";maxamp after set: ~A ~A?" (maxamp id 0) mx))
	      (set! (x-position-slider id 0) .1)
	      (if (fneq (x-position-slider id 0) .1) (snd-display #__line__ ";set x-position-slider .1: ~A?" (x-position-slider id 0)))
					;(if (> (abs (- (left-sample id 0) 5083)) 3) (snd-display #__line__ ";set x-position-slider sample 5083: ~A?" (left-sample id 0)))
	      (set! (x-zoom-slider id 0) .5)
	      (if (fneq (x-zoom-slider id 0) .5) (snd-display #__line__ ";set x-zoom-slider: ~A?" (x-zoom-slider id 0)))
	      (if (> (abs (- fr (* 2 (- (right-sample id 0) (left-sample id 0))))) 10)
		  (snd-display #__line__ ";set x-zoom-slider: ~A ~A -> ~A?" 
			       (left-sample id 0) (right-sample id 0)
			       (abs (- fr (* 2 (right-sample id 0) (left-sample id 0))))))
	      (set! (y-position-slider id 0) .1)
	      (if (fneq (y-position-slider id 0) .1) (snd-display #__line__ ";set y-position-slider .1: ~A?" (y-position-slider id 0)))
	      (set! (y-zoom-slider id 0) .5)
	      (if (fneq (y-zoom-slider id 0) .5) (snd-display #__line__ ";set y-zoom-slider: ~A?" (y-zoom-slider id 0)))
	      (let ((vals (channel-amp-envs "oboe.snd" 0 10)))
		(if (not (equal? vals
				 (list (vct -4.8828125e-4 -0.104156494140625 -0.125213623046875 -0.1356201171875 -0.138916015625 
					    -0.14093017578125 -0.14093017578125 -0.131439208984375 -0.11248779296875 -0.080047607421875)
				       (vct 0.0 0.10955810546875 0.130706787109375 0.14068603515625 0.141204833984375 0.147247314453125 
					    0.145904541015625 0.140289306640625 0.126861572265625 0.08172607421875))))
		    (snd-display #__line__ ";channel-amp-envs: ~A?" vals)))
	      
	      (let ((len (length (channel-properties id 0))))
		(if (channel-property 'hiho id 0)
		    (snd-display #__line__ ";channel-property 'hiho: ~A?" (channel-property 'hiho id 0)))
		(set! (channel-property 'hiho id 0) 123)
		(if (not (= (channel-property 'hiho id 0) 123))
		    (snd-display #__line__ ";channel-property 'hiho (123): ~A?" (channel-property 'hiho id 0)))
		(if (channel-property 'hi id 0)
		    (snd-display #__line__ ";channel-property 'hi: ~A?" (channel-property 'hi id 0)))
		(set! (channel-property 'hi id 0) pi)
		(if (fneq (channel-property 'hi id 0) pi)
		    (snd-display #__line__ ";channel-property 'hi (pi): ~A?" (channel-property 'hi id 0)))
		(if (not (= (channel-property 'hiho id 0) 123))
		    (snd-display #__line__ ";channel-property '2nd hiho (123): ~A?" (channel-property 'hiho id 0)))
		(if (not (= (length (channel-properties id 0)) (+ len 2)))
		    (snd-display #__line__ ";channel-properties: ~A?" (channel-properties id 0))))
	      
	      (let ((len (length (sound-properties id))))
		(if (sound-property 'hiho id)
		    (snd-display #__line__ ";sound-property 'hiho: ~A?" (sound-property 'hiho id)))
		(set! (sound-property 'hiho id) 123)
		(if (not (= (sound-property 'hiho id) 123))
		    (snd-display #__line__ ";sound-property 'hiho (123): ~A?" (sound-property 'hiho id)))
		(if (sound-property 'hi id)
		    (snd-display #__line__ ";sound-property 'hi: ~A?" (sound-property 'hi id)))
		(set! (sound-property 'hi id) pi)
		(if (fneq (sound-property 'hi id) pi)
		    (snd-display #__line__ ";sound-property 'hi (pi): ~A?" (sound-property 'hi id)))
		(if (not (= (sound-property 'hiho id) 123))
		    (snd-display #__line__ ";sound-property '2nd hiho (123): ~A?" (sound-property 'hiho id)))
		(if (not (= (length (sound-properties id)) (+ len 2)))
		    (snd-display #__line__ ";sound-properties: ~A?" (sound-properties id))))
	      
	      (let ((tag (catch #t (lambda () (map-channel (lambda (y) "hiho"))) (lambda args args))))
		(if (not (eq? (car tag) 'bad-type)) (snd-display #__line__ ";map-channel bad val: ~A" tag)))
	      
	      (close-sound id))
	    
	    (let ((ind (open-sound "oboe.snd")))
	      (if (not (equal? (edit-properties ind 0 0) '()))
		  (snd-display #__line__ ";initial edit-properties: ~A?" (edit-properties ind 0 0)))
	      (let ((tag (catch #t
				(lambda () (edit-properties ind 0 123))
				(lambda args (car args)))))
		(if (not (eq? tag 'no-such-edit))
		    (snd-display #__line__ ";edit-properties of non-existent edit: ~A" tag)))
	      (let ((tag (catch #t
				(lambda () (edit-properties ind 1 0))
				(lambda args (car args)))))
		(if (not (eq? tag 'no-such-channel))
		    (snd-display #__line__ ";edit-properties of non-existent channel: ~A" tag)))
	      (if (edit-property 'test-key ind 0 0)
		  (snd-display #__line__ ";edit-property never set: ~A?" (edit-property ind 0 0)))
	      (set! (edit-property 'test-key ind 0 0) 3210)
	      (let ((val (edit-property 'test-key ind 0 0)))
		(if (or (not (number? val))
			(not (= val 3210)))
		    (snd-display #__line__ ";edit-property 0: ~A" val)))
	      (pad-channel 0 10 ind 0)
	      (let ((val (edit-property 'test-key ind 0 0)))
		(if (or (not (number? val))
			(not (= val 3210)))
		    (snd-display #__line__ ";edit-property look back to 0: ~A" val)))
	      (let ((val (edit-property 'test-key ind 0 1)))
		(if val (snd-display #__line__ ";edit-property current: ~A ~A?" val val1)))
	      (undo)
	      (let ((val (edit-property 'test-key ind 0 0)))
		(if (or (not (number? val))
			(not (= val 3210)))
		    (snd-display #__line__ ";edit-property go back to 0: ~A" val)))
	      (close-sound ind)
	      (set! ind (open-sound "oboe.snd"))
	      (if (edit-property 'test-key ind 0 0)
		  (snd-display #__line__ ";edit-property not cleared: ~A?" (edit-property ind 0 0)))
	      (pad-channel 0 10 ind 0)
	      (set! (edit-property 'test-key ind 0 1) 'hiho)
	      (undo)
	      (pad-channel 0 10 ind 0)
	      (let ((val (edit-property 'test-key ind 0 1)))
		(if val (snd-display #__line__ ";edit-property not erased upon re-edit: ~A ~A?" val val1)))
	      (close-sound ind))
	    
	    (let ((id (open-sound "oboe.snd")))
	      (prefix-it 1000 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\b) 4 id)
	      (let ((left (left-sample id)))
		(if (not (= left 0)) (snd-display #__line__ ";u1000: ~A" left)))
	      (prefix-it 0 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\b) 4 id)
	      (let ((left (left-sample id)))
		(if (not (= left 0)) (snd-display #__line__ ";u0: ~A" left)))
	      (set! (cursor id) 1234)
	      (prefix-it 0 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1234)) (snd-display #__line__ ";0f: ~A" cr)))
	      (prefix-it 100 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1334)) (snd-display #__line__ ";100f: ~A" cr)))
	      (prefix-it -100 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1234)) (snd-display #__line__ ";-100f: ~A" cr)))
	      (prefix-it 1 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1235)) (snd-display #__line__ ";1f: ~A" cr)))
	      (prefix-it 1000 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\p) 4 id)
	      (let ((left (left-sample id))
		    (right (right-sample id)))
		(if (> (abs (- right left 1000)) 2) (snd-display #__line__ ";1000xp: ~A:~A" left right)))
	      (prefix-it 1 id)
	      (key (char->integer #\.) 0 id)
	      (key (char->integer #\2) 0 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\p) 4 id)
	      (let ((left (left-sample id))
		    (right (right-sample id)))
		(if (> (abs (- right left (* 22050 1.2))) 2) (snd-display #__line__ ";1.2xp: ~A:~A" left right)))
	      
	      (prefix-uit 1000 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\b) 4 id)
	      (let ((left (left-sample id)))
		(if (and (not (= left 1000)) (not (= left 1001))) (snd-display #__line__ ";uu1000: ~A" left)))
	      (prefix-uit 0 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\b) 4 id)
	      (let ((left (left-sample id)))
		(if (not (= left 0)) (snd-display #__line__ ";uu0: ~A" left)))
	      (set! (cursor id) 1234)
	      (prefix-uit 0 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1234)) (snd-display #__line__ ";u0f: ~A" cr)))
	      (prefix-uit 100 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1334)) (snd-display #__line__ ";u100f: ~A" cr)))
	      (prefix-uit -100 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1234)) (snd-display #__line__ ";u-100f: ~A" cr)))
	      (prefix-uit 1 id)
	      (key (char->integer #\f) 4 id)
	      (let ((cr (cursor id)))
		(if (not (= cr 1235)) (snd-display #__line__ ";u1f: ~A" cr)))
	      (prefix-uit 1000 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\p) 4 id)
	      (let ((left (left-sample id))
		    (right (right-sample id)))
		(if (> (abs (- right left 1000)) 2) (snd-display #__line__ ";u1000xp: ~A:~A" left right)))
	      (prefix-uit 1 id)
	      (key (char->integer #\.) 0 id)
	      (key (char->integer #\2) 0 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\p) 4 id)
	      (let ((left (left-sample id))
		    (right (right-sample id)))
		(if (> (abs (- right left (* 22050 1.2))) 2) (snd-display #__line__ ";u1.2xp: ~A:~A" left right)))
	      (close-sound id))
	    (let ((id (open-sound (car (match-sound-files (lambda (file) 
							    (and (>= (mus-sound-chans file) 2)
								 (not (= (mus-sound-header-type file) mus-raw))
								 (> (mus-sound-frames file) 1000))))))))
	      (set! (sync id) 1)
	      (select-sound id)
	      (make-region 200 500 id)
	      (select-channel 1)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\v) 0 id)
	      (let ((x0 (x-bounds id 0))
		    (x1 (x-bounds id 1)))
		(if (or (fneq (car x0) (car x1)) 
			(fneq (cadr x0) (cadr x1)))
		    (snd-display #__line__ ";C-X v: ~A ~A?" x0 x1)))
	      (key (char->integer #\u) 4 id)
	      (key (char->integer #\1) 0 id)
	      (key (char->integer #\x) 4 id)
	      (key (char->integer #\q) 0 id)
	      (close-sound id))
	    
	    (let ((snd1 (open-sound "oboe.snd"))
		  (snd2 (or (open-sound "2.snd") (open-sound "4.aiff")))
		  (snd3 (open-sound "4.aiff")))
	      (define tests-1
		(lambda (f fn nv)
		  (if (not (null? f))
		      (begin
			(test-history-channel (car f) (car fn) (car nv) snd1 snd2 snd3)
			(tests-1 (cdr f) (cdr fn) (cdr nv))))))
	      (tests-1 funcs func-names new-values)
	      (close-sound snd1)
	      (close-sound snd2)
	      
	      (set! (time-graph-style snd3 #t) graph-filled)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (time-graph-style snd3 i) graph-filled)) 
		    (snd-display #__line__ ";set time-graph-style ~A ~A: ~A" snd3 i (time-graph-style snd3 i))))
	      (set! (time-graph-style snd3 2) graph-lines)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (and (not (= i 2))
			 (not (= (time-graph-style snd3 i) graph-filled)))
		    (snd-display #__line__ ";set (2) time-graph-style ~A ~A: ~A" snd3 i (time-graph-style snd3 i))))
	      (if (not (= (time-graph-style snd3 2) graph-lines)) 
		  (snd-display #__line__ ";set time-graph-style (2): ~A" (time-graph-style snd3 2)))
	      (set! (time-graph-style snd3 #t) graph-dots)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (time-graph-style snd3 i) graph-dots)) 
		    (snd-display #__line__ ";set time-graph-style (all): ~A" (time-graph-style snd3 i))))
	      (set! (graph-style) graph-dots-and-lines)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (time-graph-style snd3 i) graph-dots-and-lines)) 
		    (snd-display #__line__ ";set time-graph-style (dal): ~A" (time-graph-style snd3 i))))
	      
	      (set! (lisp-graph-style snd3 #t) graph-filled)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (lisp-graph-style snd3 i) graph-filled)) 
		    (snd-display #__line__ ";set lisp-graph-style ~A ~A: ~A" snd3 i (lisp-graph-style snd3 i))))
	      (set! (lisp-graph-style snd3 2) graph-lines)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (and (not (= i 2))
			 (not (= (lisp-graph-style snd3 i) graph-filled)))
		    (snd-display #__line__ ";set (2) lisp-graph-style ~A ~A: ~A" snd3 i (lisp-graph-style snd3 i))))
	      (if (not (= (lisp-graph-style snd3 2) graph-lines)) 
		  (snd-display #__line__ ";set lisp-graph-style (2): ~A" (lisp-graph-style snd3 2)))
	      (set! (lisp-graph-style snd3 #t) graph-lines)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (time-graph-style snd3 i) graph-dots-and-lines)) 
		    (snd-display #__line__ ";set lisp -> time-graph-style (dal): ~A" (time-graph-style snd3 i))))
	      
	      (set! (transform-graph-style snd3 #t) graph-filled)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (transform-graph-style snd3 i) graph-filled)) 
		    (snd-display #__line__ ";set transform-graph-style ~A ~A: ~A" snd3 i (transform-graph-style snd3 i))))
	      (set! (transform-graph-style snd3 2) graph-lines)
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (and (not (= i 2))
			 (not (= (transform-graph-style snd3 i) graph-filled)))
		    (snd-display #__line__ ";set (2) transform-graph-style ~A ~A: ~A" snd3 i (transform-graph-style snd3 i))))
	      (if (not (= (transform-graph-style snd3 2) graph-lines)) 
		  (snd-display #__line__ ";set transform-graph-style (2): ~A" (transform-graph-style snd3 2)))
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (time-graph-style snd3 i) graph-dots-and-lines)) 
		    (snd-display #__line__ ";set fft and lisp -> time-graph-style (dal): ~A" (time-graph-style snd3 i))))
	      (do ((i 0 (+ 1 i))) ((= i 4)) 
		(if (not (= (lisp-graph-style snd3 i) graph-lines)) 
		    (snd-display #__line__ ";set fft and lisp -> lisp-graph-style (dal): ~A" (lisp-graph-style snd3 i))))
	      
	      (close-sound snd3))
	    
	    (let ((snd2 (open-sound "2.snd")))
	      (if (sound? snd2)
		  (play-with-amps snd2 0.2 0.1))
	      (close-sound snd2))
	    
	    (let ((old-bp (with-background-processes)))
	      (set! (with-background-processes) #f)
	      (let* ((ind (open-sound "1a.snd"))
		     (player (make-player ind 0))
		     (len (frames ind 0))
		     (incr (dac-size))
		     (e (make-env '(0 0 1 1) :length (+ 1 (floor (exact->inexact (/ len incr))))))
		     (samp 0))
		(add-player player 0 -1 -1 
			    (lambda (reason) 
			      (reset-hook! play-hook)
			      (close-sound ind)))
		(add-hook! play-hook 
			   (lambda (fr)
			     (set! (amp-control player) (env e))
			     (if (fneq (amp-control ind) 1.0) (snd-display #__line__ ";amp-control snd: ~A" (amp-control ind)))
			     (if (> (abs (- (amp-control player) (exact->inexact (/ samp len)))) 1.0)
				 (snd-display #__line__ ";amp-control player: ~A ~A" (amp-control player) (exact->inexact (/ samp len))))
			     (set! samp (+ samp incr))))
		(start-playing 1 (srate ind)))
	      (if (find-sound "1a.snd") (snd-display #__line__ ";stop proc didn't close?"))
	      (set! (with-background-processes) old-bp))
	    
	    (let ((ind (open-sound "pistol.snd")))
	      (if (selection-member? ind 0) 
		  (snd-display #__line__ ";initial selection-member? ~A ~A?" 
			       (selection-member? ind 0)
			       (selection?)))
	      (set! (selection-member? ind 0) #t)
	      (if (or (not (selection-member? ind 0))
		      (not (selection-member? ind)))
		  (snd-display #__line__ ";selection-member? ~A ~A ~A?" 
			       (selection-member? ind 0)
			       (selection-member? ind)
			       (selection?)))
	      (if (not (= (selection-frames) 1))
		  (snd-display #__line__ ";initial selection-frames: ~A?" (selection-frames)))
	      (set! (selection-frames) 1200)
	      (if (not (= (selection-frames) 1200))
		  (snd-display #__line__ ";selection-frames: 1200 ~A?" (selection-frames)))
	      (delete-selection)
	      (if (selection?) (snd-display #__line__ ";selection active after cut?"))
	      (undo)
	      (if (not (selection?)) (snd-display #__line__ ";selection inactive after undo?"))
	      (if (or (not (selection-member? ind 0))
		      (not (selection-member? ind)))
		  (snd-display #__line__ ";selection-member? after undo ~A ~A ~A?" 
			       (selection-member? ind 0)
			       (selection-member? ind)
			       (selection?)))
	      (if (or (not (= (selection-frames) 1200))
		      (not (= (selection-position) 0)))
		  (snd-display #__line__ ";selection after undo: '(0 1200) '(~A ~A)?" 
			       (selection-position) 
			       (selection-frames)))
	      (set! (selection-position) 1000)
	      (if (or (not (= (selection-frames) 200))
		      (not (= (selection-position) 1000)))
		  (snd-display #__line__ ";selection after reposition: '(1000 200) '(~A ~A)?" 
			       (selection-position) 
			       (selection-frames)))
	      (reverse-selection)
	      (if (or (not (= (selection-frames) 200))
		      (not (= (selection-position) 1000)))
		  (snd-display #__line__ ";selection after reverse: '(1000 200) '(~A ~A)?" 
			       (selection-position) 
			       (selection-frames)))
	      
	      (let ((old-frames (frames ind)))
		(src-selection .5)
		(if (or (> (abs (- (frames ind) (+ 200 old-frames))) 5)
			(> (abs (- (selection-frames) 400)) 5))
		    (snd-display #__line__ ";selection after src .5: '(1000 400) '(~A ~A)?" 
				 (selection-position) 
				 (selection-frames)))
		(undo)
		(redo)
		(if (or (> (abs (- (frames ind) (+ 200 old-frames))) 5)
			(> (abs (- (selection-frames) 400)) 5))
		    (snd-display #__line__ ";selection after src .5 with undo/redo: '(1000 400) '(~A ~A)?" 
				 (selection-position) 
				 (selection-frames)))
		(undo 3))
	      (close-sound ind))
	    
	    (set! (mus-srate) 22050)
	    (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "src-* tests" 10000))
		  (osc (make-oscil 500)))
	      
	      (define f3neq (lambda (a b) (> (abs (- a b)) 10)))
	      (define f4neq (lambda (a b) (> (abs (- a b)) 1)))
	      (define f5neq (lambda (a b) (> (abs (- a b)) (* .05 (max a b)))))
	      
	      ;; src-duration tests
	      (if (or (fneq (src-duration '(0 1 1 2)) 0.693147180559945)
		      (fneq (src-duration '(0 2 1 1)) (src-duration '(0 1 1 2)))
		      (fneq (src-duration '(0 1 .5 2)) (src-duration '(0 1 1 2)))
		      (fneq (src-duration '(.5 1 .75 2)) (src-duration '(0 1 1 2))))
		  (snd-display #__line__ ";src-duration test1 ~A ~A ~A ~A"
			       (src-duration '(0 1 1 2))
			       (src-duration '(0 2 1 1))
			       (src-duration '(0 1 .5 2))
			       (src-duration '(.5 1 .75 2))))
	      (if (or (fneq (src-duration '(0 1 1 0.5)) 1.38629436111989)
		      (fneq (src-duration '(0 0.5 1 1)) (src-duration '(0 1 1 0.5)))
		      (fneq (src-duration '(0 1 .5 0.5)) (src-duration '(0 1 1 0.5)))
		      (fneq (src-duration '(.5 1 .75 0.5)) (src-duration '(0 1 1 0.5))))
		  (snd-display #__line__ ";src-duration test2 ~A ~A ~A ~A"
			       (src-duration '(0 1 1 0.5))
			       (src-duration '(0 0.5 1 1))
			       (src-duration '(0 1 .5 0.5))
			       (src-duration '(.5 1 .75 0.5))))
	      (if (or (fneq (src-duration '(0 1 1 1)) 1.0)
		      (fneq (src-duration '(0 2 1 2)) 0.5))
		  (snd-display #__line__ ";src-duration test3: ~A ~A" (src-duration '(0 1 1 1)) (src-duration '(0 2 1 2))))
	      (if (fneq (src-duration '(0 .5 .5 3 .6 1 .7 .1 .8 1.5 1 1)) 1.02474349685432)
		  (snd-display #__line__ ";src-duration test4 ~A" (src-duration '(0 .5 .5 3 .6 1 .7 .1 .8 1.5 1 1))))
	      (if (fneq (src-duration '(0 1 1 2 2 1)) 0.693147180559945)
		  (snd-display #__line__ ";src-duration test5: ~A" (src-duration '(0 1 1 2 2 1))))
	      (if (fneq (src-duration '(0 1 1 1)) 1.0)
		  (snd-display #__line__ ";src-duration test6: ~A" (src-duration '(0 1 1 1))))
	      (if (fneq (src-duration '(0 2 1 2)) 0.5)
		  (snd-display #__line__ ";src-duration test7: ~A" (src-duration '(0 2 1 2))))
	      (if (fneq (src-duration '(0 0.5 2 0.5)) 2.0)
		  (snd-display #__line__ ";src-duration test8: ~A" (src-duration '(0 0.5 2 0.5))))
	      
	      (if (fneq (src-duration (src-fit-envelope '(0 1 1 2) 2.0)) 2.0)
		  (snd-display #__line__ ";src-fit-envelope 2.0: ~A" (src-duration (src-fit-envelope '(0 1 1 2) 2.0))))
	      (if (fneq (src-duration (src-fit-envelope '(0 1 1 2) 0.5)) 0.5)
		  (snd-display #__line__ ";src-fit-envelope 0.5: ~A" (src-duration (src-fit-envelope '(0 1 1 2) 0.5))))
	      
	      
	      (if (fneq (fm-parallel-component 100 100.0 (list 100.0 300.0 400.0) (list 1.0 0.5 0.25) '() '() #t) 0.69287)
		  (snd-display #__line__ ";fm-parallel-component 100: ~A" (fm-parallel-component 100 100.0 (list 100.0 300.0 400.0) (list 1.0 0.5 0.25) '() '() #t)))
	      (if (fneq (fm-parallel-component 500 100.0 (list 100.0 300.0 400.0) (list 1.0 0.5 0.25) '() '() #t) 0.17047)
		  (snd-display #__line__ ";fm-parallel-component 500: ~A" (fm-parallel-component 500 100.0 (list 100.0 300.0 400.0) (list 1.0 0.5 0.25) '() '() #t)))
	      
	      (if (fneq (cheby-hka 3 0.25 (vct 0 0 0 0 1.0 1.0)) -0.0732421875)
		  (snd-display #__line__ ";cheby-hka 0: ~A" (cheby-hka 3 0.25 (vct 0 0 0 0 1.0 1.0))))
	      (if (fneq (cheby-hka 2 0.25 (vct 0 0 0 0 1.0 1.0)) -0.234375)
		  (snd-display #__line__ ";cheby-hka 1: ~A" (cheby-hka 2 0.25 (vct 0 0 0 0 1.0 1.0))))
	      (if (fneq (cheby-hka 1 0.25 (vct 0 0 0 0 1.0 1.0)) 1.025390625)
		  (snd-display #__line__ ";cheby-hka 2: ~A" (cheby-hka 1 0.25 (vct 0 0 0 0 1.0 1.0))))
	      (if (fneq (cheby-hka 0 0.25 (vct 0 0 0 0 1.0 1.0)) 1.5234375)
		  (snd-display #__line__ ";cheby-hka 3: ~A" (cheby-hka 0 0.25 (vct 0 0 0 0 1.0 1.0)) 1.5234375))
	      
	      
	      (map-channel (lambda (y) (* .5 (oscil osc))))
	      (let ((vals (freq-peak 0 ind 8192)))
		(if (or (f4neq (car vals) 500.0)
			(fneq (cadr vals) 1.0))
		    (snd-display #__line__ ";src no-test: ~A" vals)))
	      (for-each
	       (lambda (sr dur)
		 (src-sound sr 1.0 ind 0)
		 (if (fneq (/ (frames ind 0) 10000.0) dur) (snd-display #__line__ ";src-sound ~A: ~A (~A)" sr (/ (frames ind 0) 10000.0) dur))
		 (let ((vals (freq-peak 0 ind 8192)))
		   (if (or (f4neq (car vals) (* 500 sr))
			   (fneq (cadr vals) 1.0))
		       (snd-display #__line__ ";src ~A freq: ~A" sr vals)))
		 (undo))
	       (list 2.0 0.5 5.0 0.2)
	       (list 0.5 2.0 0.2 5.0))
	      (for-each
	       (lambda (e f0 f1)
		 (src-sound e 1.0 ind 0)
		 (if (fneq (/ (frames ind 0) 10000.0) (src-duration e))
		     (snd-display #__line__ ";src-sound (env) ~A: ~A (~A)" 
				  e (/ (frames ind 0) 10000.0) (src-duration e)))
		 (let ((vals (freq-peak 0 ind 256)))
		   (if (f5neq (car vals) f0)
		       (snd-display #__line__ ";src (env) 0 ~A freq: ~A" f0 vals)))
		 (let ((vals (freq-peak (- (floor (* (src-duration e) 10000.0)) 256) ind 256)))
		   (if (f5neq (car vals) f1)
		       (snd-display #__line__ ";src (env) 1 ~A freq: ~A" f1 vals)))
		 (undo))
	       (list (list 0 1 1 2) (list 0 2 1 1) (list 0 1 1 2 2 1) (list 0 .5 1 1) (list 0 .5 1 2))
	       (list 500.0 1000.0 500.0 250.0 250.0)
	       (list 1000.0 500.0 500.0 500.0 1000.0))
	      (for-each
	       (lambda (e f0 f1)
		 (src-sound (make-env e :length (frames)) 1.0 ind 0)
		 (if (fneq (/ (frames ind 0) 10000.0) (src-duration e))
		     (snd-display #__line__ ";src-sound (make-env) ~A: ~A (~A)" 
				  e (/ (frames ind 0) 10000.0) (src-duration e)))
		 (let ((vals (freq-peak 0 ind 256)))
		   (if (f5neq (car vals) f0)
		       (snd-display #__line__ ";src (make-env) 0 ~A freq: ~A" f0 vals)))
		 (let ((vals (freq-peak (- (floor (* (src-duration e) 10000.0)) 256) ind 256)))
		   (if (f5neq (car vals) f1)
		       (snd-display #__line__ ";src (env) 1 ~A freq: ~A" f1 vals)))
		 (undo))
	       (list (list 0 1 1 2) (list 0 2 1 1) (list 0 1 1 2 2 1) (list 0 .5 1 1) (list 0 .5 1 2))
	       (list 500.0 1000.0 500.0 250.0 250.0)
	       (list 1000.0 500.0 500.0 500.0 1000.0))
	      
	      (for-each
	       (lambda (sr dur)
		 (src-channel sr)
		 (if (fneq (/ (frames ind 0) 10000.0) dur) (snd-display #__line__ ";src-channel ~A: ~A (~A)" sr (/ (frames ind 0) 10000.0) dur))
		 (let ((vals (freq-peak 0 ind 8192)))
		   (if (or (f4neq (car vals) (* 500 sr))
			   (fneq (cadr vals) 1.0))
		       (snd-display #__line__ ";src ~A freq: ~A" sr vals)))
		 (undo))
	       (list 2.0 0.5 5.0 0.2)
	       (list 0.5 2.0 0.2 5.0))
	      (for-each
	       (lambda (e f0 f1)
		 (src-channel e)
		 (if (fneq (/ (frames ind 0) 10000.0) (src-duration e))
		     (snd-display #__line__ ";src-channel (env) ~A: ~A (~A)" 
				  e (/ (frames ind 0) 10000.0) (src-duration e)))
		 (let ((vals (freq-peak 0 ind 256)))
		   (if (f5neq (car vals) f0)
		       (snd-display #__line__ ";src-channel (env f0) ~A: ~A" f0 vals)))
		 (let ((vals (freq-peak (- (floor (* (src-duration e) 10000.0)) 256) ind 256)))
		   (if (f5neq (car vals) f1)
		       (snd-display #__line__ ";src-channel (env f1) ~A: ~A" f1 vals)))
		 (undo))
	       (list (list 0 1 1 2) (list 0 2 1 1) (list 0 1 1 2 2 1) (list 0 .5 1 1) (list 0 .5 1 2))
	       (list 500.0 1000.0 500.0 250.0 250.0)
	       (list 1000.0 500.0 500.0 500.0 1000.0))
	      
	      (for-each
	       (lambda (sr dur)
		 (src-channel sr 1000 2500)
		 (if (f4neq (frames ind 0) (+ 7500 (* dur 2500))) 
		     (snd-display #__line__ ";src-channel section: ~A ~A" (frames) (+ 7500 (* dur 2500))))
		 (let ((vals (freq-peak 0 ind 512)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-channel section 0 ~A freq: ~A" sr vals)))
		 (let ((vals (freq-peak (- (+ 7500 (floor (* dur 2500))) 512) ind 512)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-channel section 8000 ~A freq: ~A" sr vals)))
		 (let ((vals (freq-peak 1000 ind 512)))
		   (if (f5neq (car vals) (* sr 500.0))
		       (snd-display #__line__ ";src-channel section ~A freq: ~A" sr vals)))
		 (undo))
	       (list 2.0 0.5 5.0 0.2)
	       (list 0.5 2.0 0.2 5.0))
	      
	      (for-each
	       (lambda (e)
		 (src-channel (make-env e :length 2500) 1000 2500)
		 (if (f3neq (frames ind 0) (+ 7500 (* (src-duration e) 2500)))
		     (snd-display #__line__ ";src-channel section (make-env duration) ~A: ~A (~A ~A)" 
				  e (src-duration e) (frames) (+ 7500 (* (src-duration e) 2500))))
		 (let ((vals (freq-peak 0 ind 256)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-channel section (make-env e) ~A: ~A" e vals)))
		 (let ((vals (freq-peak (- (+ 7500 (floor (* (src-duration e) 2500))) 256) ind 256)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-channel section (make-env e) ~A: ~A" e vals)))
		 (undo))
	       (list (list 0 1 1 2) (list 0 2 1 1) (list 0 1 1 2 2 1) (list 0 .5 1 1) (list 0 .5 1 2)))
	      
	      (make-selection 1000 3500 ind 0)
	      (for-each
	       (lambda (sr dur)
		 (src-selection sr)
		 (if (f3neq (frames ind 0) (+ 7500 (* dur 2500))) 
		     (snd-display #__line__ ";src-selection section: ~A ~A" (frames) (+ 7500 (* dur 2500))))
		 (let ((vals (freq-peak 0 ind 512)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-selection section 0 ~A freq: ~A" sr vals)))
		 (let ((vals (freq-peak (- (+ 7500 (floor (* dur 2500))) 512) ind 512)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-selection section 8000 ~A freq: ~A" sr vals)))
		 (let ((vals (freq-peak 1000 ind 512)))
		   (if (f5neq (car vals) (* sr 500.0))
		       (snd-display #__line__ ";src-selection section ~A freq: ~A" sr vals)))
		 (undo))
	       (list 2.0 0.5 5.0 0.2)
	       (list 0.5 2.0 0.2 5.0))
	      
	      (for-each
	       (lambda (e)
		 (src-selection (make-env e :length 2500))
		 (if (f3neq (frames ind 0) (+ 7500 (* (src-duration e) 2500)))
		     (snd-display #__line__ ";src-selection section (make-env duration) ~A: ~A (~A ~A)" 
				  e (src-duration e) (frames) (+ 7500 (* (src-duration e) 2500))))
		 (let ((vals (freq-peak 0 ind 256)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-selection section (make-env e) ~A: ~A" e vals)))
		 (let ((vals (freq-peak (- (+ 7500 (floor (* (src-duration e) 2500))) 256) ind 256)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-selection section (make-env e) ~A: ~A" e vals)))
		 (undo))
	       (list (list 0 1 1 2) (list 0 2 1 1) (list 0 1 1 2 2 1) (list 0 .5 1 1) (list 0 .5 1 2)))
	      
	      (for-each
	       (lambda (e)
		 (src-selection e)
		 (if (f3neq (frames ind 0) (+ 7500 (* (src-duration e) 2500)))
		     (snd-display #__line__ ";src-selection section (env duration) ~A: ~A (~A ~A)" 
				  e (src-duration e) (frames) (+ 7500 (* (src-duration e) 2500))))
		 (let ((vals (freq-peak 0 ind 256)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-selection section (env e) ~A: ~A" e vals)))
		 (let ((vals (freq-peak (- (+ 7500 (floor (* (src-duration e) 2500))) 256) ind 256)))
		   (if (f5neq (car vals) 500.0)
		       (snd-display #__line__ ";src-selection section (env f1) ~A: ~A" e vals)))
		 (undo))
	       (list (list 0 1 1 2) (list 0 2 1 1) (list 0 1 1 2 2 1) (list 0 .5 1 1) (list 0 .5 1 2)))
	      
	      (close-sound ind)
	      )
	    
	    (if (< (print-length) 12) (set! (print-length) 12))
	    (let ((ind (new-sound "hi.snd")))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10)) 
		(set! (sample i ind) (* i .1)))
	      (select-all ind)
	      (set! (sample 10 ind) 1.0)
	      (smooth-selection)
	      (if (not (vequal (vct-subseq (samples->vct 0 11 ind) 0 9) (vct-subseq (smoother 0.0 1.0 10) 0 9)))
		  (snd-display #__line__ ";smooth-selection: ~A ~A?" (samples->vct 0 11 ind) (smoother 0.0 1.0 10)))
	      (revert-sound)
	      (do ((i 0 (+ 1 i)))
		  ((= i 10)) 
		(set! (sample i ind) (- 1.0 (* i .1))))
	      (select-all ind)
	      (set! (sample 10 ind) 0.0)
	      (smooth-selection)
	      (if (not (vequal (vct-subseq (samples->vct 0 11 ind) 0 9) (vct-subseq (smoother 1.0 0.0 10) 0 9)))
		  (snd-display #__line__ ";smooth-selection back: ~A ~A?" (samples->vct 0 11 ind) (smoother 1.0 0.0 10)))
	      (close-sound ind))
	    
	    (let ((ind (new-sound "hi.snd")))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10)) 
		(set! (sample i ind) (* i .1)))
	      (set! (sample 10 ind) 1.0)
	      (smooth-sound 0 10 ind)
	      (if (not (vequal (vct-subseq (samples->vct 0 11 ind) 0 9) (vct-subseq (smoother 0.0 1.0 10) 0 9)))
		  (snd-display #__line__ ";smooth-sound: ~A ~A?" (samples->vct 0 11 ind) (smoother 0.0 1.0 10)))
	      (revert-sound)
	      (do ((i 0 (+ 1 i)))
		  ((= i 10)) 
		(set! (sample i ind) (- 1.0 (* i .1))))
	      (set! (sample 10 ind) 0.0)
	      (smooth-sound 0 10 ind)
	      (if (not (vequal (vct-subseq (samples->vct 0 11 ind) 0 9) (vct-subseq (smoother 1.0 0.0 10) 0 9)))
		  (snd-display #__line__ ";smooth-sound back: ~A ~A?" (samples->vct 0 11 ind) (smoother 1.0 0.0 10)))
	      (close-sound ind))
	    (if (file-exists? "hi.snd") (delete-file "hi.snd"))
	    
	    (let* ((ind (open-sound "oboe.snd"))
		   (len (frames ind)))
	      (set! (cursor ind) 1200)
	      (key (char->integer #\u) 4 ind)
	      (key (char->integer #\1) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\o) 4 ind)
	      (if (not (= (frames ind) (+ 100 len)))
		  (snd-display #__line__ ";C-o len: ~A? " (frames)))
	      (if with-gui
		  (let ((reader (make-sampler 1200 ind)))
		    (do ((i 0 (+ 1 i)))
			((= i 100))
		      (let ((val (next-sample reader)))
			(if (fneq val 0.0) (snd-display #__line__ ";C-o[~D]: ~A?" i val))))
		    (if (not (= (sampler-position reader) 1300)) (snd-display #__line__ ";reader pos: ~A" (sampler-position reader)))
		    (free-sampler reader)))
	      (revert-sound ind)
	      (set! (cursor ind) 1200)
	      (key (char->integer #\u) 4 ind)
	      (key (char->integer #\1) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\z) 4 ind)
	      (if (not (= (frames ind) len))
		  (snd-display #__line__ ";C-z len: ~A? " (frames)))
	      (if with-gui
		  (let ((reader (make-sampler 1200 ind)))
		    (do ((i 0 (+ 1 i)))
			((= i 100))
		      (let ((val (next-sample reader)))
			(if (fneq val 0.0) (snd-display #__line__ ";C-z[~D]: ~A?" i val))))
		    (free-sampler reader)))
	      (set! (cursor ind) 0)
	      (key (char->integer #\u) 4 ind)
	      (key (char->integer #\3) 0 ind)
	      (key (char->integer #\.) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\z) 4 ind)
	      (if (fneq (maxamp ind 0) 0.0) (snd-display #__line__ ";C-z full: ~A" (maxamp)))
	      (revert-sound ind)
	      (set! (cursor ind) 1200)
	      (key (char->integer #\u) 4 ind)
	      (key (char->integer #\1) 0 ind)
	      (key (char->integer #\.) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\o) 4 ind)
	      (if (not (= (frames ind) (+ (srate ind) len)))
		  (snd-display #__line__ ";C-o 1.0 len: ~A? " (frames)))
	      (if with-gui
		  (let ((reader (make-sampler 1200 ind)))
		    (do ((i 0 (+ 1 i)))
			((= i (srate ind)))
		      (let ((val (next-sample reader)))
			(if (fneq val 0.0) (snd-display #__line__ ";C-o 1.0[~D]: ~A?" i val))))
		    (free-sampler reader)))
	      (revert-sound ind)
	      (set! (cursor ind) 1200)
	      (key (char->integer #\u) 4 ind)
	      (key (char->integer #\1) 0 ind)
	      (key (char->integer #\.) 0 ind)
	      (key (char->integer #\0) 0 ind)
	      (key (char->integer #\z) 4 ind)
	      (if (not (= (frames ind) len))
		  (snd-display #__line__ ";C-z 1.0 len: ~A? " (frames)))
	      (if with-gui
		  (let ((reader (make-sampler 1200 ind)))
		    (do ((i 0 (+ 1 i)))
			((= i (srate ind)))
		      (let ((val (next-sample reader)))
			(if (fneq val 0.0) (snd-display #__line__ ";C-z 1.0[~D]: ~A?" i val))))
		    (free-sampler reader)))
	      (close-sound ind))
	    
	    (let ((ind (open-sound "2.snd")))
	      (set! (sync ind) 1)
	      (key (char->integer #\>) 4)
	      (key (char->integer #\space) 4)
	      (key (char->integer #\<) 4)
	      (if (or (not (selection-member? ind 0))
		      (not (selection-member? ind 1))
		      (not (= (selection-position ind 0) 0))
		      (not (= (selection-position ind 1) 0))
		      (not (= (selection-frames ind 0) (frames ind 0)))
		      (not (= (selection-frames ind 1) (frames ind 1))))
		  (snd-display #__line__ ";sync selection via <-: ~A ~A ~A ~A ~A ~A"
			       (selection-member? ind 0) (selection-member? ind 1)
			       (selection-position ind 0) (selection-position ind 1)
			       (selection-frames ind 0) (selection-frames ind 1)))
	      (key (char->integer #\space) 4)
	      (key (char->integer #\>) 4)
	      (if (or (not (selection-member? ind 0))
		      (not (selection-member? ind 1))
		      (not (= (selection-position ind 0) 0))
		      (not (= (selection-position ind 1) 0))
		      (not (= (selection-frames ind 0) (frames ind 0)))
		      (not (= (selection-frames ind 1) (frames ind 1))))
		  (snd-display #__line__ ";sync selection via ->: ~A ~A ~A ~A ~A ~A"
			       (selection-member? ind 0) (selection-member? ind 1)
			       (selection-position ind 0) (selection-position ind 1)
			       (selection-frames ind 0) (selection-frames ind 1)))
	      (set! (cursor ind 1) 0)
	      (set! (cursor ind 0) 1000)
	      (if (not (= (cursor ind 1) 1000)) (snd-display #__line__ ";syncd cursors: ~A ~A" (cursor ind 0) (cursor ind 1)))
	      (close-sound ind))
	    
	    (let ((ind (open-sound "2a.snd")))
	      (let ((reg (make-region 100 200 ind #t)))
		(if (not (= (region-chans reg) 2))
		    (snd-display #__line__ ";make-region #t for chan in 2a.snd: ~A chans" (region-chans reg)))
		(let ((id (mix-region reg 1000)))
		  (if (or (not (= (edit-position ind 0) 1))
			  (not (= (edit-position ind 1) 0)))
		      (snd-display #__line__ ";mix-region default mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		  (undo)
		  (set! (sync ind) 1)
		  (set! id (mix-region reg 1000))
		  (if (or (not (= (edit-position ind 0) 1))
			  (not (= (edit-position ind 1) 1)))
		      (snd-display #__line__ ";mix-region sync mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		  (undo)
		  (set! (sync ind) 0)
		  (set! id (mix-region reg 1000 ind 1))
		  (if (or (not (= (edit-position ind 0) 0))
			  (not (= (edit-position ind 1) 1)))
		      (snd-display #__line__ ";mix-region mix -> chan 1: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		  (revert-sound ind)))
	      
	      (set! (selection-member? #t #t) #f)
	      (set! (selection-member? ind 0) #t)
	      (set! (selection-member? ind 1) #t)
	      (set! (selection-position ind 0) 1000)
	      (set! (selection-position ind 1) 1000)
	      (set! (selection-frames ind 0) 100)
	      (set! (selection-frames ind 1) 100)
	      (if (not (= (selection-chans) 2))
		  (snd-display #__line__ ";laboriously make 2 chan selection: ~A" (selection-chans)))
	      
	      (let ((id (mix-selection 100)))
		(if (or (not (= (edit-position ind 0) 1))
			(not (= (edit-position ind 1) 0)))
		    (snd-display #__line__ ";mix-selection default mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		(undo)
		(set! (sync ind) 1)
		(set! id (mix-selection 100))
		(if (or (not (= (edit-position ind 0) 1))
			(not (= (edit-position ind 1) 1)))
		    (snd-display #__line__ ";mix-selection sync mix: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		(undo)
		(set! (sync ind) 0)
		(set! id (mix-selection 100 ind 1))
		(if (or (not (= (edit-position ind 0) 0))
			(not (= (edit-position ind 1) 1)))
		    (snd-display #__line__ ";mix-selection mix -> chan 1: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		
		(close-sound ind)))
	    
	    (let ((ind (open-sound "oboe.snd")))
	      (test-selection ind 1200 100 2.0)
	      (test-selection ind 600 1200 2.0)
	      (test-selection ind 0 100 2.0)
	      (test-selection ind 22500 (- 50827 22500) 0.5)
	      (test-selection ind 0 50828 0.5)
	      
	      (test-selection-to ind 1200 100 1.0)
	      (test-selection-to ind 600 1200 0.1)
	      (test-selection-to ind 0 100 0.5)
	      (test-selection-to ind 22500 (- 50827 22500) 2.0)
	      (test-selection-to ind 0 50828 0.5)
	      
	      (revert-sound ind)
	      (make-selection 1200 1200)
	      (if (not (selection?)) (snd-display #__line__ ";no selection from 1 samp region?"))
	      (if (not (= (selection-frames) 1)) (snd-display #__line__ ";1 samp selection: ~A samps?" (selection-frames)))
	      (scale-selection-to 1.0)
	      (if (fneq (sample 1200 ind 0) 1.0) (snd-display #__line__ ";scale 1 samp selection: ~A?" (sample 1200 ind 0)))
	      
	      (revert-sound ind)
	      (let ((id (make-region 500 1000)))
		(src-selection .5)
		(if (> (abs (- (region-frames id) 500)) 1) (snd-display #__line__ ";region-frames after src-selection: ~A?" (region-frames id)))
		(let ((reg-mix-id (car (mix-region id 1500 ind 0))))
		  (if (not (= (mix-length reg-mix-id) (region-frames id)))
		      (snd-display #__line__ ";mix-region: ~A != ~A?" (region-frames id) (mix-length reg-mix-id)))
		  (if (not (equal? (mix-home reg-mix-id) (list ind 0 #f 0)))
		      (snd-display #__line__ ";mix-region mix-home ~A (~A 0 #f 0)?" (mix-home reg-mix-id) ind))
		  (let ((sel-mix-id (car (mix-selection 2500 ind 0))))
		    (if (not (= (selection-frames) (mix-length sel-mix-id)))
			(snd-display #__line__ ";mix-selection frames: ~A != ~A?" (selection-frames) (mix-length sel-mix-id)))
		    (if (> (abs (- (* 2 (mix-length reg-mix-id)) (mix-length sel-mix-id))) 3)
			(snd-display #__line__ ";mix selection and region: ~A ~A (~A ~A)?" 
				     (mix-length reg-mix-id) (mix-length sel-mix-id) (region-frames id) (selection-frames)))
		    (if (not (equal? (mix-home sel-mix-id) (list ind 0 #f 0)))
			(snd-display #__line__ ";mix-selection mix-home: ~A (~A 0 #f 0)?" (mix-home sel-mix-id) ind))
		    (insert-selection 3000 ind 0)
		    (insert-selection 3000 ind)
		    (if (and (provided? 'xm) (provided? 'snd-debug))
			(begin
			  (set! (cursor ind 0) 3000)
			  (XtCallCallbacks (menu-option "Insert Selection") XmNactivateCallback (snd-global-state))))
		    (mix-selection 3000 ind)
		    (if (and (provided? 'xm) (provided? 'snd-debug))
			(begin
			  (XtCallCallbacks (menu-option "Mix Selection") XmNactivateCallback (snd-global-state))
			  (XtCallCallbacks (menu-option "Play Selection") XmNactivateCallback (snd-global-state))))
		    (delete-selection)
		    (revert-sound ind))))
	      (close-sound ind))
	    
	    (if (file-exists? "storm.snd")
		(let ((ind (open-sound "storm.snd")))
		  (set! (sinc-width) 10)
		  (time (src-sound 1.3))
		  (time (env-sound '(0 0 1 1 2 0)))
		  (time (filter-sound '(0 1 .2 0 .5 1 1 0) 20))      ; FIR direct form
		  (time (filter-sound '(0 0 .1 0 .11 1 .12 0 1 0) 2048)) ; convolution
		  (revert-sound ind)
		  (let ((reg (make-region 0 123000 ind 0))) ; force copy branch to execute
		    (region->vct reg 0 10 0 (make-vct 10)))
		  (ramp-channel 0.0 1.0)
		  (ramp-channel 0.0 1.0)
		  (ramp-channel 0.0 1.0)
		  (ramp-channel 0.0 1.0) ; force env 
		  (close-sound ind)))
	    (if (file-exists? "1a.snd")
		(let ((ind1 (open-sound "1a.snd")))
		  (time (rubber-sound 1.25))
		  (close-sound ind1)))
	    
	    (let* ((oboe (open-sound "oboe.snd"))
		   (a4 (open-sound "4.aiff"))
		   (sr (srate oboe))
		   (fr (frames oboe 0))
		   (typ (header-type oboe))
		   (frm (data-format oboe))
		   (loc (data-location oboe))
		   (com (comment oboe)))
	      (save-sound-as "test.aif" oboe mus-aifc)
	      (let ((oboe-aif (open-sound "test.aif")))
		(if (not (= (header-type oboe-aif) mus-aifc)) (snd-display #__line__ ";oboe-aif header: ~A?" (mus-header-type-name (header-type oboe-aif))))
		(set! (srate oboe-aif) (* sr 2.0))
		(if (fneq (* sr 2.0) (srate oboe-aif)) (snd-display #__line__ ";set! srate: ~A ~A" (* sr 2.0) (srate oboe-aif)))
		(set! (header-type oboe-aif) mus-next)
		(if (not (= (header-type oboe-aif) mus-next)) (snd-display #__line__ ";set! header: ~A?" (mus-header-type-name (header-type oboe-aif))))
		(set! (data-location oboe-aif) 28)
		(if (not (= (data-location oboe-aif) 28)) (snd-display #__line__ ";set! data-location: ~A?" (data-location oboe-aif)))
		(set! (data-format oboe-aif) mus-mulaw)
		(if (not (= (data-format oboe-aif) mus-mulaw)) (snd-display #__line__ ";set! format: ~A?" (mus-data-format-name (data-format oboe-aif))))
		(save-sound-as "test.aif" oboe-aif mus-aifc mus-bshort 22050 0)
		(close-sound oboe-aif)
		(delete-file "test.aif")
		(set! (selected-sound) a4)
		(if (not (equal? (selected-sound) a4)) (snd-display #__line__ ";set! selected-sound: ~A ~A?" (selected-sound) a4))
		(set! (selected-channel) 2)
		(if (not (= (selected-channel a4) 2)) (snd-display #__line__ ";set! selected-channel: ~A?" (selected-channel a4)))
		(set! (selected-channel a4) 3)
		(if (not (= (selected-channel a4) 3)) (snd-display #__line__ ";set! selected-channel a4: ~A?" (selected-channel a4)))
		(close-sound a4)
		(close-sound oboe)))
	    
	    (let ((v1 (envelope-interp 1.0 '(0 0 2.0 1.0)))
		  (v2 (envelope-interp 1.0 '(0 0.0 1 1.0 2 0.0)))
		  (v3 (envelope-interp 2.0 '(0 0.0 1 1.0)))
		  (v4 (envelope-interp 0.0 '(1 .5 2 0))))
	      (if (fneq v1 0.5) (snd-display #__line__ ";envelope-interp(1): ~F (0.5)?" v1))
	      (if (fneq v2 1.0) (snd-display #__line__ ";envelope-interp(2): ~F (1.0)?" v2))
	      (if (fneq v3 1.0) (snd-display #__line__ ";envelope-interp(3): ~F (1.0)?" v3))
	      (if (fneq v4 0.5) (snd-display #__line__ ";envelope-interp(4): ~F (0.5)?" v4)))
	    (let ((v1 (envelope-interp 0.0 '(-1 0  0 1  1 -1)))
		  (v2 (envelope-interp -0.5 '(-1 0  0 1  1 -1)))
		  (v3 (envelope-interp -0.5 '(-1 -1  0 1  1 -1)))
		  (v4 (envelope-interp -0.5 '(-1 -1  1 1)))
		  (v5 (envelope-interp -1.5 '(-1 -1  1 1)))
		  (v6 (envelope-interp 1.5 '(-1 -1  1 1))))
	      (if (fneq v1 1.0) (snd-display #__line__ ";envelope-interp(1a): ~A" v1))
	      (if (fneq v2 0.5) (snd-display #__line__ ";envelope-interp(2a): ~A" v2))
	      (if (fneq v3 0.0) (snd-display #__line__ ";envelope-interp(3a): ~A" v3))
	      (if (fneq v4 -0.5) (snd-display #__line__ ";envelope-interp(4a): ~A" v4))
	      (if (fneq v5 -1.0) (snd-display #__line__ ";envelope-interp(5a): ~A" v5))
	      (if (fneq v6 1.0) (snd-display #__line__ ";envelope-interp(6a): ~A" v6)))
	    (let ((v1 (multiply-envelopes '(0.0 0.0 2.0 0.5) '(0.0 0.0 1.0 2.0 2.0 1.0)))
		  (v2 (window-envelope 1.0 3.0 '(0.0 0.0 5.0 1.0))))
	      (if (not (feql v1 (list 0.0 0.0 0.5 0.5 1.0 0.5))) (snd-display #__line__ ";multiply-envelopes: ~A?" v1))
	      (if (not (feql v2 (list 1.0 0.2 3.0 0.6))) (snd-display #__line__ ";window-envelope: ~A?" v2)))
	    
	    (if (fneq (envelope-interp .1 '(0 0 1 1)) 0.1) 
		(snd-display #__line__ ";envelope-interp .1 -> ~A?" (envelope-interp .1 '(0 0 1 1))))
	    (if (fneq (envelope-interp .1 '(0 0 1 1) 32.0) 0.01336172) 
		(snd-display #__line__ ";envelope-interp .013 -> ~A?" (envelope-interp .1 '(0 0 1 1) 32.0)))
	    (if (fneq (envelope-interp .1 '(0 0 1 1) .012) 0.36177473) 
		(snd-display #__line__ ";envelope-interp .361 -> ~A?" (envelope-interp .1 '(0 0 1 1) .012))) 
	    (if (fneq (envelope-interp .3 '(0 0 .5 1 1 0)) .6)
		(snd-display #__line__ ";envelope-interp .3 '(0 0 .5 1 1 0)) -> ~A" (envelope-interp .3 '(0 0 .5 1 1 0))))
	    
	    (if (fneq (envelope-interp .9 '(0 0 1 1)) 0.9) 
		(snd-display #__line__ ";envelope-interp .9 -> ~A?" (envelope-interp .9 '(0 0 1 1))))
	    (if (fneq (envelope-interp .9 '(0 0 1 1) 32.0) 0.698) 
		(snd-display #__line__ ";envelope-interp .698 -> ~A?" (envelope-interp .9 '(0 0 1 1) 32.0)))
	    (if (fneq (envelope-interp .9 '(0 0 1 1) .012) 0.993) 
		(snd-display #__line__ ";envelope-interp .993 -> ~A?" (envelope-interp .9 '(0 0 1 1) .012))) 
	    
	    (if (fneq (envelope-interp 1.1 '(0 0 1 0 2 1)) 0.1) 
		(snd-display #__line__ ";envelope-interp .1 (2) -> ~A?" (envelope-interp 1.1 '(0 0 1 0 2 1))))
	    (if (fneq (envelope-interp 1.1 '(0 0 1 0 2 1) 32.0) 0.01336172) 
		(snd-display #__line__ ";envelope-interp .013 (2) -> ~A?" (envelope-interp 1.1 '(0 0 1 0 2 1) 32.0)))
	    (if (fneq (envelope-interp 1.1 '(0 0 1 0 2 1) .012) 0.36177473) 
		(snd-display #__line__ ";envelope-interp .361 (2) -> ~A?" (envelope-interp 1.1 '(0 0 1 0 2 1) .012))) 
	    
	    (if (fneq (envelope-interp 1.9 '(0 0 1 0 2 1)) 0.9) 
		(snd-display #__line__ ";envelope-interp .9 (2) -> ~A?" (envelope-interp 1.9 '(0 0 1 0 2 1))))
	    (if (fneq (envelope-interp 1.9 '(0 0 1 0 2 1) 32.0) 0.698) 
		(snd-display #__line__ ";envelope-interp .698 (2) -> ~A?" (envelope-interp 1.9 '(0 0 1 0 2 1) 32.0)))
	    (if (fneq (envelope-interp 1.9 '(0 0 1 0 2 1) .012) 0.993) 
		(snd-display #__line__ ";envelope-interp .993 (2) -> ~A?" (envelope-interp 1.9 '(0 0 1 0 2 1) .012))) 
	    
	    (if (fneq (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1)) 0.1) 
		(snd-display #__line__ ";envelope-interp .1 (3) -> ~A?" (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1))))
	    (if (fneq (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) 32.0) 0.01336172) 
		(snd-display #__line__ ";envelope-interp .013 (3) -> ~A?" (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) 32.0)))
	    (if (fneq (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) .012) 0.36177473) 
		(snd-display #__line__ ";envelope-interp .361 (3) -> ~A?" (envelope-interp 1.1 '(0 0 0.5 1 1 0 2 1) .012))) 
	    
	    (if (fneq (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1)) 0.9) 
		(snd-display #__line__ ";envelope-interp .9 (3) -> ~A?" (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1))))
	    (if (fneq (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) 32.0) 0.698) 
		(snd-display #__line__ ";envelope-interp .698 (3) -> ~A?" (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) 32.0)))
	    (if (fneq (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) .012) 0.993) 
		(snd-display #__line__ ";envelope-interp .993 (3) -> ~A?" (envelope-interp 1.9 '(0 0 0.5 1 1 0 2 1) .012))) 
	    
	    (if (not (feql (window-envelope 1.0 3.0 '(0.0 0.0 5.0 1.0)) (list 1.0 0.2 3.0 0.6))) 
		(snd-display #__line__ ";window-envelope: ~A?" (window-envelope 1.0 3.0 '(0.0 0.0 5.0 1.0))))
	    (if (not (feql (multiply-envelopes '(0 0 1 1) '(0 0 1 1 2 0)) (list 0 0 0.5 0.5 1 0))) 
		(snd-display #__line__ ";multiply-envelopes: ~A?" (multiply-envelopes '(0 0 1 1) '(0 0 1 1 2 0))))
	    (if (fneq (max-envelope '(0 0 1 1 2 3 4 0)) 3.0)
		(snd-display #__line__ ";max-envelope: ~A?" (max-envelope '(0 0 1 1 2 3 4 0))))
	    (if (fneq (max-envelope '(0 1)) 1.0)
		(snd-display #__line__ ";1 max-envelope: ~A?" (max-envelope '(0 1))))
	    (if (fneq (max-envelope '(0 1 1 1 2 2)) 2.0)
		(snd-display #__line__ ";2 max-envelope: ~A?" (max-envelope '(0 1 1 1 2 2))))
	    (if (fneq (max-envelope '(0 -1 1 -2)) -1.0)
		(snd-display #__line__ ";3 max-envelope: ~A?" (max-envelope '(0 -1 1 -2))))
	    (if (fneq (max-envelope '(0 -2 1 -1)) -1.0)
		(snd-display #__line__ ";4 max-envelope: ~A?" (max-envelope '(0 -2 1 -1))))
	    (if (fneq (min-envelope '(0 0 1 1 2 3 4 0)) 0.0)
		(snd-display #__line__ ";min-envelope: ~A?" (min-envelope '(0 0 1 1 2 3 4 0))))
	    (if (fneq (min-envelope '(0 1)) 1.0)
		(snd-display #__line__ ";1 min-envelope: ~A?" (min-envelope '(0 1))))
	    (if (fneq (min-envelope '(0 1 1 1 2 2)) 1.0)
		(snd-display #__line__ ";2 min-envelope: ~A?" (min-envelope '(0 1 1 1 2 2))))
	    (if (fneq (min-envelope '(0 -1 1 -2)) -2.0)
		(snd-display #__line__ ";3 min-envelope: ~A?" (min-envelope '(0 -1 1 -2))))
	    (if (fneq (min-envelope '(0 -2 1 -1)) -2.0)
		(snd-display #__line__ ";4 min-envelope: ~A?" (min-envelope '(0 -2 1 -1))))
	    (if (fneq (integrate-envelope '(0 0 1 1)) 0.5) 
		(snd-display #__line__ ";integrate-envelope: ~A?" (integrate-envelope '(0 0 1 1))))
	    (if (fneq (integrate-envelope '(0 1 1 1)) 1.0) 
		(snd-display #__line__ ";integrate-envelope: ~A?" (integrate-envelope '(0 1 1 1))))
	    (if (fneq (integrate-envelope '(0 0 1 1 2 .5)) 1.25) 
		(snd-display #__line__ ";integrate-envelope: ~A?" (integrate-envelope '(0 0 1 1 2 .5))))
	    (if (not (feql (stretch-envelope '(0 0 1 1) .1 .2) (list 0 0 0.2 0.1 1.0 1))) 
		(snd-display #__line__ ";stretch-envelope att: ~A?" (stretch-envelope '(0 0 1 1) .1 .2)))
	    (if (not (feql (stretch-envelope '(0 0 1 1 2 0) .1 .2 1.5 1.6) (list 0 0 0.2 0.1 1.1 1 1.6 0.5 2.0 0))) 
		(snd-display #__line__ ";stretch-envelope dec: ~A?" (stretch-envelope '(0 0 1 1 2 0) .1 .2 1.5 1.6)))
	    (if (not (feql (add-envelopes '(0 0 1 1 2 0) '(0 0 1 1)) '(0 0 0.5 1.5 1 1)))
		(snd-display #__line__ ";add-envelopes: ~A" (add-envelopes '(0 0 1 1 2 0) '(0 0 1 1))))
	    (if (not (feql (scale-envelope '(0 0 1 1) 2) '(0 0 1 2)))
		(snd-display #__line__ ";scale-envelope: ~A" (scale-envelope '(0 0 1 1) 2)))
	    (if (not (feql (scale-envelope '(0 0 1 1) 2 1) '(0 1 1 3)))
		(snd-display #__line__ ";scale-envelope off: ~A" (scale-envelope '(0 0 1 1) 2 1)))
	    (if (not (feql (reverse-envelope '(0 0 1 1)) '(0 1 1 0)))
		(snd-display #__line__ ";reverse-envelope ramp: ~A" (reverse-envelope '(0 0 1 1))))
	    (if (not (feql (reverse-envelope '(0 0 .5 1 2 0)) '(0 0 1.5 1 2 0)))
		(snd-display #__line__ ";reverse-envelope ramp 2: ~A" (reverse-envelope '(0 0 .5 1 2 0))))
	    (if (not (feql (reverse-envelope '(0 0 .5 1 2 1)) '(0 1 1.5 1 2 0)))
		(snd-display #__line__ ";reverse-envelope ramp 2: ~A" (reverse-envelope '(0 0 .5 1 2 1))))
	    (if (not (feql (concatenate-envelopes '(0 0 1 1) '(0 1 1 0)) '(0.0 0 1.0 1 2.0 0)))
		(snd-display #__line__ ";concatenate-envelopes: ~A" (concatenate-envelopes '(0 0 1 1) '(0 1 1 0))))
	    (if (not (feql (concatenate-envelopes '(0 0 1 1.5) '(0 1 1 0)) '(0.0 0 1.0 1.5 1.01 1 2.01 0)))
		(snd-display #__line__ ";concatenate-envelopes: ~A" (concatenate-envelopes '(0 0 1 1.5) '(0 1 1 0))))
	    (if (not (feql (repeat-envelope '(0 0 1 100) 2) '(0 0 1 100 1.01 0 2.01 100)))
		(snd-display #__line__ ";repeat-envelope 0: ~A" (repeat-envelope '(0 0 1 100) 2)))
	    (if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 2) '(0 0 1.5 1 2.0 0 3.5 1 4.0 0)))
		(snd-display #__line__ ";repeat-envelope 1: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 2)))
	    (if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 2 #f #t) '(0.0 0 0.75 1 1.0 0 1.75 1 2.0 0)))
		(snd-display #__line__ ";repeat-envelope 2: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 2 #f #t)))
	    (if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 2 #t) '(0 0 1.5 1 2.0 0 2.5 1 4.0 0)))
		(snd-display #__line__ ";repeat-envelope 3: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 2 #t)))
	    (if (not (feql (repeat-envelope '(0 0 1.5 1 2 0) 3) '(0 0 1.5 1 2.0 0 3.5 1 4.0 0 5.5 1 6.0 0)))
		(snd-display #__line__ ";repeat-envelope 4: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 3)))
	    (if (not (feql (normalize-envelope '(0 0 1 1.5 2.0 1.0)) '(0 0.0 1 1.0 2.0 0.667)))
		(snd-display #__line__ ";normalize-envelope: ~A" (normalize-envelope '(0 0 1 1.5 2.0 1.0))))
	    (if (not (feql (normalize-envelope '(0 0 1 .5 2 -.8)) '(0 0.0 1 0.625 2 -1.0)))
		(snd-display #__line__ ";normalize-envelope: ~A" (normalize-envelope '(0 0 1 .5 2 -.8))))
	    
	    (let ((val (envelope-exp '(0 0 1 1) 2.0 10)))
	      (if (not (feql val '(0.000 0.000 0.100 0.010 0.200 0.040 0.300 0.090 0.400 0.160 
					 0.500 0.250 0.600 0.360 0.700 0.490 0.800 0.640 0.900 0.810 1.000 1.000)))
		  (snd-display #__line__ ";envelope-exp: ~A" val))
	      (set! val (envelope-exp '(0 0 1 1 2 0) 1.0 10))
	      (if (not (feql val '(0.000 0.000 0.200 0.200 0.400 0.400 0.600 0.600 0.800 0.800 
					 1.000 1.000 1.200 0.800 1.400 0.600 1.600 0.400 1.800 0.200 2.000 0.000)))
		  (snd-display #__line__ ";envelope exp 2: ~A" val)))
	    
	    (let ((ind (new-sound "fmv.snd"))
		  (v (make-vct 20 1.0)))
	      (vct->channel v)
	      (if (selection?) (set! (selection-member? #t) #f))
	      (make-selection 5 9 ind 0)
	      (scale-selection-to 0.5)
	      (insert-selection 15 ind)
	      (if (not (= (frames ind) 25)) (snd-display #__line__ ";insert-selection 5: ~A" (frames ind)))
	      (if (not (vequal (channel->vct 0 25) (vct 1.0 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5 
							1.0 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5
							1.0 1.0 1.0 1.0 1.0)))
		  (snd-display #__line__ ";insert-selection: ~A" (channel->vct 0 25)))
	      (mix-selection 1 ind 0) ; this is being confused by clipping settings
	      (if (not (vequal (channel->vct 0 10 ind 0) (vct 1.000 1.500 1.500 1.500 1.500 1.000 0.500 0.500 0.500 0.500)))
		  (snd-display #__line__ ";mix-selection vals: ~A" (channel->vct 0 10 ind 0)))
	      (close-sound ind))
	    
	    (let ((ind (new-sound "fmv.snd"))
		  (v (make-vct 2000))
		  (ctr 0)
		  (old-size (transform-size))
		  (old-type (transform-type))
		  (old-norm (transform-normalization))
		  (old-grf (transform-graph-type)))
	      (vct-map! v (lambda ()
			    (let ((val (sin (* ctr 2.0 (/ pi 10.0)))))
			      (set! ctr (+ 1 ctr))
			      val)))
	      (vct->channel v 0 2000 ind 0)
	      (set! (transform-size) 256)
	      (set! (transform-type) fourier-transform)
	      (set! (transform-normalization) normalize-by-channel)
	      (set! (transform-graph-type) graph-once)
	      (set! (zero-pad) 0)
	      (set! (transform-graph?) #t)
	      (make-selection 0 200)
	      (set! (show-selection-transform) #t)
	      (set! (selection-frames) 300)
	      (update-transform-graph)
	      (let* ((data (transform->vct))
		     (peak (vct-peak data))
		     (val (transform-sample 0)))
		(if (= peak 0.0) (snd-display #__line__ ";transform selection peak: ~A" peak))
		(if (fneq val (vct-ref data 0)) (snd-display #__line__ ";transform-sample: ~A, data: ~A" val (vct-ref data 0)))
		(if (and (>= (vct-length data) 64)
			 (> (* .5 peak) (vct-ref data 51)))
		    (snd-display #__line__ ";transform selection at 51: ~A, peak: ~A" (vct-ref data 51) peak)))
	      (for-each
	       (lambda (pad)
		 (set! (zero-pad) pad)
		 (update-transform-graph)
		 (let* ((data (transform->vct))
			(peak (vct-peak data))
			(pval (vct-ref data (floor (* .1 (vct-length data))))))
		   (if (> (* .5 peak) pval)
		       (snd-display #__line__ ";transform selection padded ~D: ~A, peak: ~A" pad pval peak))))
	       (list 1 0 3 31))
	      (set! (zero-pad) 100000)
	      (if (> (zero-pad) 1000)
		  (snd-display #__line__ ";zero-pad: ~A" (zero-pad)))
	      (set! (zero-pad) 0)
	      (set! (transform-size) old-size)
	      (set! (transform-type) old-type)
	      (set! (transform-normalization) old-norm)
	      (set! (transform-graph-type) old-grf)
	      (close-sound ind))
	    
	    (let ((ind (open-sound "storm.snd"))
		  (maxes (vct 0.8387 0.5169 0.3318 0.2564 0.1982 0.1532)))
	      (do ((i 0 (+ 1 i)))
		  ((= i 5))
		(if (fneq (maxamp) (vct-ref maxes i)) (snd-display #__line__ ";enving storm ~D: ~A ~A" i (vct-ref maxes i) (maxamp)))
		(env-sound '(0 0 1 1 2 0))
		(if (fneq (maxamp) (vct-ref maxes (+ 1 i))) (snd-display #__line__ ";enving storm ~D: ~A ~A" (+ 1 i) (vct-ref maxes (+ 1 i)) (maxamp))))
	      (close-sound ind))
	    ))
	
	;; --------------------------------------------------------------------------------
	;; length as generic function:
	;;     string-length vector-length hash-table-size vct-length 
	;;     frames mus-length sound-data-length mix-length region-frames 
	
	(let ((snd (open-sound "oboe.snd"))
	      (v (vct .1 .2 .3))
	      (vc (vector .1 .2 .3 .4))
	      (lst (list 1 2 3 4 5))
	      (hsh (make-hash-table 100))
	      (sd (make-sound-data 1 10))
	      (str "123456")
	      (fr (frame .1 .2))
	      (mx (mixer .1 .2 .3 .4)))
	  (let ((mxv (mix-vct v 1000))
		(reg (make-region 0 100))
		(dly (make-delay 32))
		(ply (make-player snd 0))
		)
	    (if (not (= (length snd) 50828)) (snd-display #__line__ ";length of sound: ~A" (length snd)))
	    (if (not (= (length v) 3)) (snd-display #__line__ ";length of vct: ~A" (length v)))
	    (if (not (= (length vc) 4)) (snd-display #__line__ ";length of vector: ~A" (length vc)))
	    (if (not (= (length lst) 5)) (snd-display #__line__ ";length of list: ~A" (length lst)))
	    (if (not (= (length str) 6)) (snd-display #__line__ ";length of string: ~A" (length str)))
	    (if (not (= (length sd) 10)) (snd-display #__line__ ";length of sound-data: ~A" (length sd)))
	    (if (not (= (length hsh) 100)) (snd-display #__line__ ";length of hash-table: ~A" (length hsh)))
	    (if (not (= (length fr) 2)) (snd-display #__line__ ";length of frame: ~A" (length fr)))
	    (if (not (= (length mx) 2)) (snd-display #__line__ ";length of mixer: ~A" (length mx)))
	    (if (not (= (length mxv) 3)) (snd-display #__line__ ";length of mix: ~A" (length mxv)))
	    (if (not (= (length reg) 101)) (snd-display #__line__ ";length of region: ~A" (length reg)))
	    (if (not (= (length dly) 32)) (snd-display #__line__ ";length of delay: ~A" (length dly)))
	    (if (not (= (length ply) 50828)) (snd-display #__line__ ";length of player: ~A" (length ply)))
	    )
	  (close-sound snd))
	
	;; srate as generic: mus-sound-srate region-srate srate 
	
	(let ((snd (open-sound "oboe.snd"))
	      (str "oboe.snd"))
	  (let ((reg (make-region 0 100))
		(ply (make-player snd 0))
		)
	    (if (not (= (srate snd) 22050)) (snd-display #__line__ ";srate of sound: ~A" (srate snd)))
	    (if (not (= (srate str) 22050)) (snd-display #__line__ ";srate of string: ~A" (srate str)))
	    (if (not (= (srate reg) 22050)) (snd-display #__line__ ";srate of region: ~A" (srate reg)))
	    (if (not (= (srate ply) 22050)) (snd-display #__line__ ";srate of player: ~A" (srate ply)))
	    )
	  (close-sound snd))
	
	
	;; channels as generic: mus-sound-chans region-chans chans mus-channels mix/etc
	
	(let ((snd (open-sound "oboe.snd"))
	      (v (vct .1 .2 .3))
	      (sd (make-sound-data 2 10))
	      (str "oboe.snd")
	      (fr (frame .1 .2))
	      (mx (mixer .1 .2 .3 .4)))
	  (let ((mxv (mix-vct v 1000))
		(reg (make-region 0 100))
		(ply (make-player snd 0))
		)
	    (if (not (= (channels snd) 1)) (snd-display #__line__ ";channels of sound: ~A" (channels snd)))
	    (if (not (= (channels v) 1)) (snd-display #__line__ ";channels of vct: ~A" (channels v)))
	    (if (not (= (channels str) 1)) (snd-display #__line__ ";channels of string: ~A" (channels str)))
	    (if (not (= (channels sd) 2)) (snd-display #__line__ ";channels of sound-data: ~A" (channels sd)))
	    (if (not (= (channels fr) 2)) (snd-display #__line__ ";channels of frame: ~A" (channels fr)))
	    (if (not (= (channels mx) 2)) (snd-display #__line__ ";channels of mixer: ~A" (channels mx)))
	    (if (not (= (channels mxv) 1)) (snd-display #__line__ ";channels of mix: ~A" (channels mxv)))
	    (if (not (= (channels reg) 1)) (snd-display #__line__ ";channels of region: ~A" (channels reg)))
	    (if (not (= (channels ply) 1)) (snd-display #__line__ ";channels of player: ~A" (channels ply)))
	    )
	  (close-sound snd))
	
	;; frames as generic
	
	(let ((snd (open-sound "oboe.snd"))
	      (v (vct .1 .2 .3))
	      (sd (make-sound-data 1 10))
	      (str "oboe.snd")
	      (fr (frame .1 .2))
	      (mx (mixer .1 .2 .3 .4)))
	  (let ((mxv (mix-vct v 1000))
		(reg (make-region 0 100))
		(dly (make-delay 32))
		(ply (make-player snd 0))
		)
	    (if (not (= (frames snd) 50828)) (snd-display #__line__ ";frames of sound: ~A" (frames snd)))
	    (if (not (= (frames v) 3)) (snd-display #__line__ ";frames of vct: ~A" (frames v)))
	    (if (not (= (frames str) 50828)) (snd-display #__line__ ";frames of string: ~A" (frames str)))
	    (if (not (= (frames sd) 10)) (snd-display #__line__ ";frames of sound-data: ~A" (frames sd)))
	    (if (not (= (frames fr) 2)) (snd-display #__line__ ";frames of frame: ~A" (frames fr)))
	    (if (not (= (frames mx) 2)) (snd-display #__line__ ";frames of mixer: ~A" (frames mx)))
	    (if (not (= (frames mxv) 3)) (snd-display #__line__ ";frames of mix: ~A" (frames mxv)))
	    (if (not (= (frames reg) 101)) (snd-display #__line__ ";frames of region: ~A" (frames reg)))
	    (if (not (= (frames dly) 32)) (snd-display #__line__ ";frames of delay: ~A" (frames dly)))
	    (if (not (= (frames ply) 50828)) (snd-display #__line__ ";frames of player: ~A" (frames ply)))
	    )
	  (close-sound snd))
	
	;; file-name as generic
	
	(let ((snd (open-sound "oboe.snd"))
	      (str "oboe.snd")
	      (frm (make-file->sample "oboe.snd"))
	      (prt (open-output-file "tst.dat")))
	  (let ((mxv (car (mix "pistol.snd" 1000)))
		(reg (make-region 0 100))
		)
	    (if (not (string=? (file-name snd) (string-append (getcwd) "/oboe.snd"))) (snd-display #__line__ ";file-name of sound: ~A" (file-name snd)))
	    (if (not (string=? (file-name str) (string-append (getcwd) "/oboe.snd"))) (snd-display #__line__ ";file-name of string: ~A" (file-name str)))
	    (if (not (string=? (file-name frm) "oboe.snd")) (snd-display #__line__ ";file-name of file->sample: ~A" (file-name frm)))
	    (if (not (string=? (file-name prt) "tst.dat")) (snd-display #__line__ ";file-name of output port: ~A" (file-name prt)))
	    (if (not (string=? (file-name mxv) (string-append (getcwd) "/pistol.snd"))) (snd-display #__line__ ";file-name of mix: ~A" (file-name mxv)))
	    (if (not (string=? (file-name reg) "oboe.snd")) (snd-display #__line__ ";file-name of region: ~A" (file-name reg)))
	    )
	  (close-output-port prt)
	  (mus-close frm)
	  (close-sound snd))
	
	;; sync as generic: mix-sync mark-sync sync 
	
	(let ((snd (open-sound "oboe.snd")))
	  (let ((mrk (add-mark 123))
		(mx (mix-vct (vct .1 .2 .3)))
		)
	    (if (not (= (sync snd) 0)) (snd-display #__line__ ";sync of sound (0): ~A" (sync snd)))
	    (if (not (= (sync mrk) 0)) (snd-display #__line__ ";sync of mark (0): ~A" (sync mrk)))
	    (if (not (= (sync mx) 0)) (snd-display #__line__ ";sync of mx (0): ~A" (sync mx)))
	    
	    (set! (sync snd) 12)
	    (set! (sync mrk) 24)
	    (set! (sync mx) 36)
	    
	    (if (not (= (sync snd) 12)) (snd-display #__line__ ";sync of sound (12): ~A" (sync snd)))
	    (if (not (= (sync mrk) 24)) (snd-display #__line__ ";sync of mark (24): ~A" (sync mrk)))
	    (if (not (= (sync mx) 36)) (snd-display #__line__ ";sync of mx (36): ~A" (sync mx)))
	    )
	  (close-sound snd))
	
	;; maxamp as generic
	
	(let ((snd (open-sound "oboe.snd"))
	      (v (vct .1 .2 .3))
	      (vc (vector .1 .2 .3 .4))
	      (lst (list 1 2 3 4 5))
	      (sd (make-sound-data 1 10))
	      (str "pistol.snd") ; can't use oboe.snd since we messed with mus-sound-maxamp above
	      (fr (frame .1 .2)))
	  (let ((mxv (mix-vct v 1000))
		(reg (make-region 0 900))
		(dly (make-delay 32))
		)
	    (set! (sd 0 1) .1)
	    (delay dly .1)
	    (delay dly .2)
	    
	    (if (fneq (maxamp snd) .334) (snd-display #__line__ ";maxamp of sound: ~A" (maxamp snd)))
	    (if (fneq (maxamp snd 0) .334) (snd-display #__line__ ";maxamp of sound (0): ~A" (maxamp snd)))
	    (if (fneq (maxamp snd 0 0) .14724) (snd-display #__line__ ";maxamp of sound (0 0): ~A" (maxamp snd)))
	    (if (fneq (maxamp v) .3) (snd-display #__line__ ";maxamp of vct: ~A" (maxamp v)))
	    (if (fneq (maxamp vc) .4) (snd-display #__line__ ";maxamp of vector: ~A" (maxamp vc)))
	    (if (fneq (maxamp lst) 5.0) (snd-display #__line__ ";maxamp of list: ~A" (maxamp lst)))
	    (if (fneq (maxamp str) .49267) (snd-display #__line__ ";maxamp of string: ~A" (maxamp str)))
	    (if (fneq (maxamp sd) 0.1) (snd-display #__line__ ";maxamp of sound-data: ~A" (maxamp sd)))
	    (if (fneq (maxamp fr) .2) (snd-display #__line__ ";maxamp of frame: ~A" (maxamp fr)))
	    (if (fneq (maxamp mxv) .3) (snd-display #__line__ ";maxamp of mix: ~A" (maxamp mxv)))
	    (if (fneq (maxamp reg) .02139) (snd-display #__line__ ";maxamp of region: ~A" (maxamp reg)))
	    (if (fneq (maxamp dly) .2) (snd-display #__line__ ";maxamp of delay: ~A" (maxamp dly)))
	    )
	  (close-sound snd))
	
	)))

;;; ---------------- test 16: regularized funcs ----------------

(define (snd_test_16)
  
  (define (undo-env s c)
    (let ((len (car (edits s c))))
      (if (> len 0)
	  (let ((unhappy #f))
	    (do ((i 1 (+ 1 i)))
		((or unhappy (> i len))
		 unhappy)
	      (let ((ed (edit-fragment i s c)))
		(if (and ed
			 (or (string=? (cadr ed) "env")
			     (string=? (cadr ed) "ptree")))
		    (begin
		      (set! (edit-position s c) (- i 1))
		      (set! unhappy #t))))))
	  #f)))
  
  (define (opt-test choice)
    (let* ((snds (sounds))
	   (cursnd (list-ref snds (random (length snds))))
	   (curchn (random (chans cursnd)))
	   (chan-list (all-chans))
	   (cur-maxamps (apply map maxamp chan-list))
	   (cur-edits (apply map edit-position chan-list))
	   (cur-frames (apply map frames chan-list))
	   (cur-amp (maxamp cursnd curchn))
	   (cur-edit (edit-position cursnd curchn))
	   (cur-frame (frames cursnd curchn)))
      
      (case choice
	;; scale-channel
	((0) (let* ((scaler (if (< (maxamp cursnd curchn) 1.0) (+ 1.0 (random 1.0)) (+ 0.5 (random 0.5))))
		    (cur-loc (random cur-frame))
		    (cur-samp (sample cur-loc cursnd curchn)))
	       (scale-channel scaler 0 (frames cursnd curchn) cursnd curchn)
	       (if (and (not (= (edit-position cursnd curchn) (+ 1 cur-edit))) 
			(not (= (edit-position cursnd curchn) cur-edit)))
		   (snd-display #__line__ ";scale-channel ~A[~A] edit pos: ~A ~A" (short-file-name cursnd) curchn (edit-position cursnd curchn) cur-edit))
	       (if (not (= (frames cursnd curchn) cur-frame))
		   (snd-display #__line__ ";scale-channel ~A[~A] frames: ~A ~A" (short-file-name cursnd) curchn (frames cursnd curchn) cur-frame))
	       (if (fneq (maxamp cursnd curchn) (* scaler cur-amp))
		   (snd-display #__line__ ";scale-channel ~A[~A] maxamp: ~A ~A (~A, scaler: ~A)" 
				(short-file-name cursnd) curchn (maxamp cursnd curchn) (* scaler cur-amp)
				(abs (- (maxamp cursnd curchn) (* scaler cur-amp)))
				scaler))
	       (if (fneq (sample cur-loc cursnd curchn) (* scaler cur-samp))
		   (snd-display #__line__ ";scale-channel ~A[~A] cur-samp: ~A ~A" (short-file-name cursnd) curchn (sample cur-loc cursnd curchn) (* scaler cur-samp)))
	       (for-each
		(lambda (s c amp ed fr)
		  (if (not (and (equal? s cursnd)
				(= c curchn)))
		      (begin
			(if (not (= (edit-position s c) ed))
			    (snd-display #__line__ ";scale-channel ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";scale-channel ~A[~A] wrong frames: ~A ~A" (short-file-name s) c (frames s c) fr))
			(if (fneq (maxamp s c) amp)
			    (snd-display #__line__ ";scale-channel ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))))
		(car chan-list)
		(cadr chan-list)
		cur-maxamps
		cur-edits
		cur-frames)))
	
	;; scale-by
	((1) (let* ((maxscl (apply max cur-maxamps))
		    (scaler (if (< maxscl 1.0) (+ 1.0 (random 1.0)) (+ 0.5 (random 0.5)))))
	       (scale-by scaler cursnd curchn)
	       (for-each
		(lambda (s c amp ed fr)
		  (if (or (and (= (sync cursnd) 0) 
			       (or (not (equal? s cursnd))
				   (not (= c curchn))))
			  (not (= (sync s) (sync cursnd))))
		      (begin
			(if (not (= (edit-position s c) ed))
			    (snd-display #__line__ ";scale-by ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";scale-by ~A[~A] wrong frames: ~A ~A" (short-file-name s) c (frames s c) fr))
			(if (fneq (maxamp s c) amp)
			    (snd-display #__line__ ";scale-by ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
		      (begin
			(if (and (not (= (edit-position s c) (+ 1 ed))) 
				 (not (= (edit-position s c) ed)))
			    (snd-display #__line__ ";scale-by ~A[~A] edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";scale-by ~A[~A] frames: ~A ~A" (short-file-name s) c (frames s c) fr))
			(if (fneq (maxamp s c) (* scaler amp))
			    (snd-display #__line__ ";scale-by ~A[~A] maxamp: ~A ~A" (short-file-name s) c (maxamp s c) (* scaler amp))))))
		(car chan-list)
		(cadr chan-list)
		cur-maxamps
		cur-edits
		cur-frames)))
	
	;; scale-sound-by
	((4) (let* ((maxscl (apply max cur-maxamps))
		    (scaler (if (< maxscl 1.0) (+ 1.0 (random 1.0)) (+ 0.5 (random 0.5)))))
	       (scale-sound-by scaler 1000 1000 cursnd)
	       (for-each
		(lambda (s c amp ed fr)
		  (if (not (equal? s cursnd))
		      (begin
			(if (not (= (edit-position s c) ed))
			    (snd-display #__line__ ";scale-sound-by ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";scale-sound-by ~A[~A] wrong frames: ~A ~A" (short-file-name s) c (frames s c) fr))
			(if (fneq (maxamp s c) amp)
			    (snd-display #__line__ ";scale-sound-by ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
		      (begin
			(if (and (not (= (edit-position s c) (+ 1 ed))) 
				 (not (= (edit-position s c) ed))) 
			    (snd-display #__line__ ";scale-sound-by ~A[~A] edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";scale-sound-by ~A[~A] frames: ~A ~A" (short-file-name s) c (frames s c) fr)))))
		(car chan-list)
		(cadr chan-list)
		cur-maxamps
		cur-edits
		cur-frames)))
	
	((5) (let ((pos (edit-position cursnd curchn)))
	       (if (> pos 0)
		   (undo (random pos) cursnd curchn))))
	
	((6) (let ((len (frames cursnd curchn)))
	       (if (> len 10000)
		   (let ((beg (random (floor (/ len 2)))))
		     (delete-samples beg (+ 10 (random 100)) cursnd curchn)))))
	
	((7) (let ((beg (random (+ (frames cursnd curchn) 100)))
		   (dur (+ 10 (random 100))))
	       (set! (samples beg dur cursnd curchn) (make-vct dur 1.0))))
	
	((8) (let ((beg (random (+ (frames cursnd curchn) 100)))
		   (dur (+ 10 (random 100))))
	       (insert-samples beg dur (make-vct dur 1.0) cursnd curchn)))
	
	((9) (add-mark (random (frames cursnd curchn)) cursnd curchn))
	
	((10) (let ((beg (random (+ (frames cursnd curchn) 100))))
		(mix-vct (make-vct (+ 10 (random 100)) (random 1.0)) beg cursnd curchn)))
	
	((11) (let ((beg (random (+ (frames cursnd curchn) 100))))
		(pad-channel beg (+ 10 (random 100)) cursnd curchn)))
	
	((12) (let* ((beg (random (- (frames cursnd curchn) 210)))
		     (dur (+ 10 (random 200)))
		     (preader0 (make-sampler (+ beg dur -1) cursnd curchn -1))
		     (reader0 (make-sampler beg cursnd curchn)))
		(ptree-channel (lambda (y) (* y 2.0)) beg dur cursnd curchn #f #t)
		(let* ((preader1 (make-sampler (+ beg dur -1) cursnd curchn -1))
		       (reader1 (make-sampler beg cursnd curchn)))
		  (do ((i 0 (+ 1 i)))
		      ((= i dur))
		    (let ((pval0 (preader0))
			  (val0 (reader0))
			  (pval1 (preader1))
			  (val1 (reader1)))
		      (if (or (fneq (* val0 2) val1)
			      (fneq (* pval0 2) pval1))
			  (begin
			    (snd-display #__line__ ";read ptree at ~A: ~A ~A ~A ~A (~A ~A ~A ~A): ~A" 
					 i val0 val1 pval0 pval1
					 reader0 reader1 preader0 preader1
					 (safe-display-edits cursnd curchn))
			    (throw 'mus-error))))))))
	
	((13) (let ((beg (random (- (frames cursnd curchn) 100))))
		(scale-channel .5 beg (+ 10 (random 100)) cursnd curchn)))
	
	((14) (let ((beg (random (- (frames cursnd curchn) 200))))
		(scale-channel .5 beg (+ 10 (random 100)) cursnd curchn)
		(scale-channel .5 (+ beg 10) (+ 10 (random 100)) cursnd curchn)))
	
	((15) (let ((beg (random (- (frames cursnd curchn) 200))))
		(scale-channel .5 beg (+ 10 (random 100)) cursnd curchn)
		(scale-channel 2.0 beg (+ 10 (random 100)) cursnd curchn)))
	
	((16) (let ((beg (random (- (frames cursnd curchn) 200))))
		(pad-channel beg (+ 10 (random 100)) cursnd curchn)
		(pad-channel (+ beg 10) (+ 10 (random 100)) cursnd curchn)))
	
	((17) (let ((beg (random (- (frames cursnd curchn) 200))))
		(pad-channel beg (+ 10 (random 100)) cursnd curchn)
		(pad-channel beg (+ 10 (random 100)) cursnd curchn)))
	
	((18) (let ((beg (random (- (frames cursnd curchn) 200))))
		(delete-sample beg cursnd curchn)
		(delete-sample (+ beg (random 100)) cursnd curchn)))
	
	((19) (let ((beg (random (+ (frames cursnd curchn) 200))))
		(set! (sample beg cursnd curchn) .1)
		(set! (sample (+ beg (random 100)) cursnd curchn) .2)))
	
	((20) (let ((beg (random (- (frames cursnd curchn) 200))))
		(ramp-channel (- (random 2.0) 1.0) (- (random 2.0) 1.0) beg (+ 10 (random 100)) cursnd curchn)))
	
	((21) (let* ((pts (+ 1 (random 8)))
		     (maxpt 0.0)
		     (e (let ((e1 '())
			      (x 0.0)
			      (y 0.0))
			  (do ((i 0 (+ 1 i)))
			      ((= i pts))
			    (set! e1 (cons x e1))
			    (if (> (random 3) 0)
				(set! y (- (random 2.0) 1.0)))
			    (set! e1 (cons y e1))
			    (if (> (abs y) maxpt) (set! maxpt (abs y)))
			    (set! x (+ x (+ .01 (random 1.0)))))
			  (reverse e1)))
		     (beg (random (- (frames cursnd curchn) 300)))
		     (dur (+ 80 (random 200)))
		     (reader0 (make-sampler beg cursnd curchn)))
		(env-channel e beg dur cursnd curchn)
		(let* ((reader1 (make-sampler beg cursnd curchn))
		       (en (make-env e :length dur)))
		  (do ((i 0 (+ 1 i)))
		      ((= i dur))
		    (let* ((e0 (env en))
			   (val00 (reader0))
			   (val0 (* e0 val00))
			   (val1 (reader1)))
		      (if (> (abs (- val0 val1)) .005)
			  (begin
			    (if (file-exists? "baddy.scm") (delete-file "baddy.scm"))
			    (save-state "baddy.scm")
			    (snd-display #__line__ ";read env off by ~A: ~%    (~A) at ~A: ~%    ~A ~A (~A ~A) [~A ~A]:~%    ~A" 
					 (abs (- val0 val1))
					 e i val0 val1
					 reader0 reader1 e0 val00
					 (safe-display-edits cursnd curchn))
			    (throw 'mus-error))))))))
	
	;; env-channel
	((2) (let* ((pts (+ 1 (random 6)))
		    (maxpt 0.0)
		    (e (let ((e1 '())
			     (x 0.0)
			     (y 0.0))
			 (do ((i 0 (+ 1 i)))
			     ((= i pts))
			   (set! e1 (cons x e1))
			   (if (> (random 3) 0)
			       (set! y (- (random 2.0) 1.0)))
			   (set! e1 (cons y e1))
			   (if (> (abs y) maxpt) (set! maxpt (abs y)))
			   (set! x (+ x (+ .01 (random 1.0)))))
			 (reverse e1))))
	       (if (undo-env cursnd curchn)
		   (begin
		     (set! cur-maxamps (apply map maxamp chan-list))
		     (set! cur-edits (apply map edit-position chan-list))
		     (set! cur-frames (apply map frames chan-list))
		     (set! cur-amp (maxamp cursnd curchn))
		     (set! cur-edit (edit-position cursnd curchn))
		     (set! cur-frame (frames cursnd curchn))))
	       (env-channel e 0 (frames cursnd curchn) cursnd curchn) ; can be a no-op
	       (if (and (not (= (edit-position cursnd curchn) (+ 1 cur-edit)))
			(not (= (edit-position cursnd curchn) cur-edit)))
		   (snd-display #__line__ ";env-channel ~A[~A] edit pos: ~A ~A" (short-file-name cursnd) curchn (edit-position cursnd curchn) cur-edit))
	       (if (not (= (frames cursnd curchn) cur-frame))
		   (snd-display #__line__ ";env-channel ~A[~A] frames: ~A ~A" (short-file-name cursnd) curchn (frames cursnd curchn) cur-frame))
	       (if (> (- (maxamp cursnd curchn) .01) (* maxpt cur-amp))
		   (begin
		     (snd-display #__line__ ";env-channel ~A[~A] maxamp: ~A ~A from ~A" (short-file-name cursnd) curchn (maxamp cursnd curchn) (* maxpt cur-amp) e)
		     (throw 'mus-error)))
	       (for-each
		(lambda (s c amp ed fr)
		  (if (not (and (equal? s cursnd)
				(= c curchn)))
		      (begin
			(if (not (= (edit-position s c) ed))
			    (snd-display #__line__ ";env-channel ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";env-channel ~A[~A] wrong frames: ~A ~A" (short-file-name s) c (frames s c) fr))
			(if (fneq (maxamp s c) amp)
			    (snd-display #__line__ ";env-channel ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))))
		(car chan-list)
		(cadr chan-list)
		cur-maxamps
		cur-edits
		cur-frames)))
	
	;; env-sound
	((3) (let* ((pts (+ 1 (random 6)))
		    (maxpt 0.0)
		    (recalc #f)
		    (e (let ((e1 '())
			     (x 0.0)
			     (y 0.0))
			 (do ((i 0 (+ 1 i)))
			     ((= i pts))
			   (set! e1 (cons x e1))
			   (if (> (random 3) 0)
			       (set! y (- (random 2.0) 1.0)))
			   (set! e1 (cons y e1))
			   (if (> (abs y) maxpt) (set! maxpt (abs y)))
			   (set! x (+ x (+ .01 (random 1.0)))))
			 (reverse e1)))
		    (end (apply min cur-frames)) ; env-sound can lengthen a shorter sound if syncd+multichannel
		    (beg (random (floor (/ end 2)))))
	       (for-each
		(lambda (s c)
		  (if (not (or (and (= (sync cursnd) 0) 
				    (or (not (equal? s cursnd)) 
					(not (= c curchn))))
			       (not (= (sync s) (sync cursnd)))))
		      (let ((val (undo-env s c)))
			(set! recalc (or recalc val)))))
		(car chan-list)
		(cadr chan-list))
	       (if recalc
		   (begin
		     (set! cur-maxamps (apply map maxamp chan-list))
		     (set! cur-edits (apply map edit-position chan-list))
		     (set! cur-frames (apply map frames chan-list))
		     (set! cur-amp (maxamp cursnd curchn))
		     (set! cur-edit (edit-position cursnd curchn))
		     (set! cur-frame (frames cursnd curchn))))
	       (env-sound e beg (max pts (- end beg)) 1.0 cursnd curchn) ; dur here, not end point
	       (for-each
		(lambda (s c amp ed fr)
		  (if (or (and (= (sync cursnd) 0) 
			       (or (not (equal? s cursnd)) 
				   (not (= c curchn))))
			  (not (= (sync s) (sync cursnd))))
		      (begin
			(if (not (= (edit-position s c) ed))
			    (snd-display #__line__ ";env-sound ~A[~A] wrong edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";env-sound ~A[~A] wrong frames: ~A ~A" (short-file-name s) c (frames s c) fr))
			(if (fneq (maxamp s c) amp)
			    (snd-display #__line__ ";env-sound ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
		      (begin
			(if (and (not (= (edit-position s c) (+ 1 ed)))
				 (not (= (edit-position s c) ed)))
			    (snd-display #__line__ ";env-sound ~A[~A] edit pos: ~A ~A" (short-file-name s) c (edit-position s c) ed))
			(if (not (= (frames s c) fr))
			    (snd-display #__line__ ";env-sound ~A[~A] frames: ~A ~A" (short-file-name s) c (frames s c) fr)))))
		(car chan-list)
		(cadr chan-list)
		cur-maxamps
		cur-edits
		cur-frames)))
	)))
  
  (define (amp-envs-equal? snd chn pos0 pos1 df)
    (let* ((env0 (channel-amp-envs snd chn pos0))
	   (len0 (and env0 (list-p env0) (= (length env0) 2) (vct-length (cadr env0))))
	   (env1 (channel-amp-envs snd chn pos1))
	   (len1 (and env1 (list-p env1) (= (length env1) 2) (vct-length (cadr env1))))
	   (happy #t))
      (if (and len0 len1)
	  (let* ((minlen (min len0 len1))
		 (inc0 (/ len0 minlen))
		 (inc1 (/ len1 minlen))
		 (e0 (cadr env0))
		 (e1 (cadr env1)))
	    (if (and (integer? inc0) 
		     (integer? inc1))
		(do ((i 0 (+ 1 i)))
		    ((or (not happy) (= i (- minlen 1)))
		     happy)
		  (let ((max0 -1.0)
			(max1 -1.0))
		    (if (= inc0 1)
			(set! max0 (vct-ref e0 i))
			(do ((j 0 (+ 1 j)))
			    ((= j inc0))
			  (if (> (vct-ref e0 (+ j (* inc0 i))) max0)
			      (set! max0 (vct-ref e0 (+ j (* inc0 i)))))))
		    (if (= inc1 1)
			(set! max1 (vct-ref e1 i))
			(do ((j 0 (+ 1 j)))
			    ((= j inc1))
			  (if (> (vct-ref e1 (+ j (* inc1 i))) max1)
			      (set! max1 (vct-ref e1 (+ j (* inc1 i)))))))
		    (if (> (abs (- max0 max1)) df)
			(begin
			  (snd-display #__line__ ";amp-env ~A: ~A ~A" i max0 max1)
			  (set! happy #f)))
		    (set! max0 -1.0)
		    (set! max1 -1.0)))
		(begin
		  (snd-display #__line__ ";lens: ~A ~A" len0 len1)
		  #f)))
	  #f)))
  
  (define* (edit-difference s1 c1 e1 e2 (offset 0))
    (let* ((r1 (make-sampler 0 s1 c1 1 e1))
	   (r2 (make-sampler offset s1 c1 1 e2))
	   (max-diff 0.0)
	   (max-loc 0)
	   (N (frames s1 c1 e1)))
      (do ((i 0 (+ 1 i)))
	  ((= i N))
	(let ((diff (abs (- (r1) (r2)))))
	  (if (> diff max-diff)
	      (begin
		(set! max-diff diff)
		(set! max-loc i)))))
      (if (> max-diff 0.0)
	  (list max-diff max-loc)
	  #f)))
  
  (define* (edit-distance s1 c1 e1 e2 (offset 0))
    (let* ((r1 (make-sampler 0 s1 c1 1 e1))
	   (r2 (make-sampler offset s1 c1 1 e2))
	   (sum 0.0)
	   (N (frames s1 c1 e1)))
      (do ((i 0 (+ 1 i)))
	  ((= i N))
	(let ((f1 (r1))
	      (f2 (r2)))
	  (set! sum (+ sum (abs (- (* f1 f1) (* f2 f2)))))))
      (sqrt sum)))
  
  
  (define (check-edit-tree expected-tree expected-vals name)
    (define (vequal-at v0 v1)
      (call-with-exit
       (lambda (return)
	 (let ((len (vct-length v0)))
	   (do ((i 0 (+ 1 i)))
	       ((= i len) #f)
	     (if (> (abs (- (vct-ref v0 i) (vct-ref v1 i))) .001)
		 (return (list i (vct-ref v0 i) (vct-ref v1 i)))))))))
    (define (edits-not-equal? tl0 tl1 pos)
      (if (null? tl0)
	  (if (null? tl1)
	      #f
	      (list pos tl0 #f))
	  (let ((t0 (car tl0))
		(t1 (car tl1)))
	    (if (or (not (= (car t0) (car t1)))
		    (not (= (cadr t0) (cadr t1)))
		    (not (= (caddr t0) (caddr t1)))
		    (not (= (cadddr t0) (cadddr t1)))
		    (> (abs (- (list-ref t0 4) (list-ref t1 4))) .0001)
		    (> (abs (- (list-ref t0 5) (list-ref t1 5))) .0001) ; rmp0
		    (> (abs (- (list-ref t0 6) (list-ref t1 6))) .0001)) ; rmp1
		(list pos t0 t1)
		(edits-not-equal? (cdr tl0) (cdr tl1) (+ 1 pos))))))
    (let* ((current-vals (channel->vct))
	   (len (vct-length current-vals)))
      (if (and expected-vals (not (= len (vct-length expected-vals))))
	  (snd-display #__line__ ";~A: lengths differ: ~A ~A" name len (vct-length expected-vals))
	  (if (and expected-vals (not (vequal current-vals expected-vals)))
	      (let ((bad-data (vequal-at current-vals expected-vals)))
		(snd-display #__line__ ";checking ~A, vals disagree (loc cur expect): ~A" name bad-data))
	      (let* ((tree (edit-tree))
		     (bad-data (edits-not-equal? tree expected-tree 0)))
		(if bad-data
		    (snd-display #__line__ ";checking ~A, trees disagree (loc cur expect): ~A~%  in~%~A" name bad-data (edit-tree)))
		(if (> len 5)
		    (let* ((split-loc (+ 2 (random (- len 3))))
			   (fread (make-sampler split-loc))
			   (bread (make-sampler (- split-loc 1) #f #f -1))
			   (split-vals (make-vct len)))
		      (do ((i split-loc (+ 1 i)))
			  ((= i len))
			(vct-set! split-vals i (fread)))
		      (do ((i (- split-loc 1) (- i 1)))
			  ((< i 0))
			(vct-set! split-vals i (bread)))
		      (if (and expected-vals (not (vequal split-vals expected-vals)))
			  (let ((bad-data (vequal-at split-vals expected-vals)))
			    (snd-display #__line__ ";checking ~A, split vals disagree (loc cur expect): ~A" name bad-data)
			    (throw 'uhoh1)
			    )))))))))
  
  (define (reversed-read snd chn)
    (let* ((len (frames snd chn))
	   (data (make-vct len))
	   (sf (make-sampler (- len 1) snd chn -1)))
      (do ((i (- len 1) (- i 1)))
	  ((< i 0))
	(vct-set! data i (read-sample sf)))
      data))
  
  (define (zigzag-read snd chn)
    (let* ((len (frames snd chn))
	   (data (make-vct len))
	   (sf (make-sampler 3 snd chn 1)))
      (do ((i 3 (+ 1 i)))
	  ((= i 6))
	(vct-set! data i (next-sample sf)))
      (do ((i 6 (- i 1)))
	  ((= i 0))
	(vct-set! data i (previous-sample sf)))
      (do ((i 0 (+ 1 i)))
	  ((= i len))
	(vct-set! data i (next-sample sf)))
      data))
  
  (define (zigzag-check name snd chn)
    (let* ((data (channel->vct))
	   (sf (make-sampler 3 snd chn)))
      (do ((i 3 (+ 1 i)))
	  ((= i 8))
	(let ((val (next-sample sf)))
	  (if (fneq (vct-ref data i) val)
	      (snd-display #__line__ ";~A: forward data[~D]: ~A ~A" name i val (vct-ref data i)))))
      (do ((i 7 (- i 1)))
	  ((= i 0))
	(let ((val (previous-sample sf)))
	  (if (fneq (vct-ref data i) val)
	      (snd-display #__line__ ";~A: backward data[~D]: ~A ~A" name i val (vct-ref data i)))))))
  
  (define (init-sound val dur chans)
    (let ((ind (new-sound "test.snd" mus-next mus-bshort 22050 chans)))
      (do ((i 0 (+ 1 i)))
	  ((= i chans))
	(insert-silence 0 dur ind i)
	(map-channel (lambda (y) val) 0 (frames) ind i))
      ind))
  
  (define (check-back-and-forth ind name v)
    (let ((happy #t))
      (if (not (vequal v (channel->vct 0 (frames) ind 0)))
	  (begin
	    (set! happy #f)
	    (snd-display #__line__ ";~A forth:~%     current: ~A~%     expected: ~A" name (channel->vct 0 (frames) ind 0) v)))
      (if (not (vequal v (reversed-read ind 0)))
	  (begin
	    (set! happy #f)
	    (snd-display #__line__ ";~A back: ~A ~A" name (reversed-read ind 0) v)))
      happy))
  
  
  (define (rampx-channel r0 r1)
    (xramp-channel r0 r1 3.0 0 (frames)))
  
  (define (check-both-chans ind name f0 f1)
    (let ((c0 (scan-channel f0 0 (frames) ind 0))
	  (c1 (scan-channel f1 0 (frames) ind 1)))
      (if c0 (snd-display #__line__ ";~A swap c0: ~A" name c0))
      (if c1 (snd-display #__line__ ";~A swap c1: ~A" name c1))))
  
  
  (define (convolve-coeffs v1 v2)
    (let* ((v1-len (vct-length v1))
	   (v2-len (vct-length v2))
	   (res-len (+ v1-len v2-len -1))
	   (vres (make-vct res-len)))
      (do ((i 0 (+ 1 i)))
	  ((= i res-len))
	(let ((sum 0.0))
	  (do ((j (max 0 (+ 1 (- i v2-len))) (+ 1 j)))
	      ((> j (min i (- v1-len 1))))
	    (set! sum (+ sum (* (vct-ref v1 j) 
				(vct-ref v2 (- i j))))))
	  (vct-set! vres i sum)))
      vres))
  
  (begin
    
    (do ((test-16 0 (+ 1 test-16)))
	((= test-16 tests))
      (let ((oboe (open-sound "oboe.snd")))
	(log-mem test-16)
	(for-each
	 (lambda (func name)
	   (func)
	   (if (not (= (edit-position oboe) 0))
	       (snd-display #__line__ ";dur:0 ~A? ~A ~A" name (edit-position oboe) (edit-fragment))))
	 (list 
	  (lambda () (scale-channel 2.0 0 0 oboe))
	  (lambda () (env-channel (make-env '(0 0 1 1) :length 124) 0 0 oboe))
	  (lambda () (clm-channel (make-oscil) 0 0 oboe))
	  (lambda () (vct->channel (make-vct 3) 0 0 oboe))
	  (lambda () (smooth-channel 0 0 oboe))
	  (lambda () (pad-channel 0 0 oboe))
	  (lambda () (src-channel 2.0 0 0 oboe))
	  (lambda () (mix-channel "pistol.snd" 0 0 oboe))
	  (lambda () (insert-channel "pistol.snd" 0 0 oboe))
	  (lambda () (reverse-channel 0 0 oboe))
	  (lambda () (play oboe :start 0 :end 0))
	  (lambda () (scale-sound-by 2.0 0 0 oboe))
	  (lambda () (env-sound '(0 0 1 1) 0 0 oboe))
	  (lambda () (set-samples 0 0 (make-vct 3) oboe))
	  (lambda () (smooth-sound 0 0 oboe))
	  (lambda () (insert-silence 0 0 oboe)))
	 (list 
	  "scale-channel" "env-channel" "clm-channel" "vct->channel" "smooth-channel" "pad-channel" "src-channel"
	  "mix-channel" "insert-channel" "reverse-channel" "play" 
	  "scale-sound-by" "env-sound" "set-samples" "smooth-sound" "insert-silence"))
	
	(for-each
	 (lambda (func name)
	   (let ((tag (catch #t
			     func
			     (lambda args (car args)))))
	     (if (not (eq? tag 'no-such-sample))
		 (snd-display #__line__ ";~A beg -1->~A" name tag))
	     (if (not (= (edit-position oboe) 0))
		 (snd-display #__line__ ";beg:-1 ~A? ~A ~A" name (edit-position oboe) (edit-fragment)))))
	 (list 
	  (lambda () (scale-channel 2.0 -1 123 oboe))
	  (lambda () (env-channel (make-env '(0 0 1 1) :length 124) -1 123 oboe))
	  (lambda () (clm-channel (make-oscil) -1 123 oboe))
	  (lambda () (vct->channel (make-vct 3) -1 123 oboe))
	  (lambda () (smooth-channel -1 123 oboe))
	  (lambda () (pad-channel -1 123 oboe))
	  (lambda () (src-channel 2.0 -1 123 oboe))
	  (lambda () (mix-channel "pistol.snd" -1 123 oboe))
	  (lambda () (insert-channel "pistol.snd" -1 123 oboe))
	  (lambda () (reverse-channel -1 123 oboe))
	  (lambda () (scale-sound-by 2.0 -1 123 oboe))
	  (lambda () (env-sound '(0 0 1 1) -1 123 oboe))
	  (lambda () (set-samples -1 123 (make-vct 3) oboe))
	  (lambda () (smooth-sound -1 123 oboe))
	  (lambda () (insert-silence -1 123 oboe))
	  (lambda () (ptree-channel (lambda (y) (+ y .1)) -1 123 oboe)))
	 (list 
	  "scale-channel" "env-channel" "clm-channel" "vct->channel" "smooth-channel" "pad-channel" "src-channel"
	  "mix-channel" "insert-channel" "reverse-channel"
	  "scale-sound-by" "env-sound" "set-samples" "smooth-sound" "insert-silence" "ptree-channel"))
	
	(scale-channel 2.0 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display #__line__ ";beg:12345678 scale-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(env-channel (make-env '(0 0 1 1) :length 124) 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display #__line__ ";beg:12345678 env-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(smooth-channel 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display #__line__ ";beg:12345678 smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(src-channel 2.0 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display #__line__ ";beg:12345678 src-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(reverse-channel 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display #__line__ ";beg:12345678 reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(play oboe :start 12345678 :end (+ 12345678 123))
	
	(scale-channel 2.0 0 123 oboe 0)
	(if (not (= (edit-position oboe) 1))
	    (snd-display #__line__ ";oboe scale-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(env-channel (make-env '(0 0 1 1) :length 124) 0 123 oboe 0)
	(if (not (= (edit-position oboe) 2))
	    (snd-display #__line__ ";oboe env-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(clm-channel (make-oscil) 0 123 oboe 0)
	(if (not (= (edit-position oboe) 3))
	    (snd-display #__line__ ";oboe clm-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(vct->channel (make-vct 3) 0 123 oboe 0)
	(if (not (= (edit-position oboe) 4))
	    (snd-display #__line__ ";oboe vct->channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(smooth-channel 0 123 oboe 0)
	(if (not (= (edit-position oboe) 5))
	    (snd-display #__line__ ";oboe smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(pad-channel 0 123 oboe 0)
	(if (not (= (edit-position oboe) 6))
	    (snd-display #__line__ ";oboe pad-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(src-channel 2.0 0 123 oboe 0)
	(if (not (= (edit-position oboe) 7))
	    (snd-display #__line__ ";oboe src-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(mix-channel "pistol.snd" 0 123 oboe 0)
	(if (not (= (edit-position oboe) 8))
	    (snd-display #__line__ ";oboe mix-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(insert-channel "pistol.snd" 0 123 oboe 0)
	(if (not (= (edit-position oboe) 9))
	    (snd-display #__line__ ";oboe insert-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(reverse-channel 0 123 oboe 0)
	(if (not (= (edit-position oboe) 10))
	    (snd-display #__line__ ";oboe reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(let* ((rd (make-sampler 0))
	       (sr (make-src :srate 2.0 :input (lambda (dir) (rd)))))
	  (clm-channel sr 0 12345 oboe 0)
	  (if (not (= (edit-position oboe) 11))
	      (snd-display #__line__ ";oboe clm-channel src? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let* ((rd (make-sampler 0))
	       (sr (make-granulate :expansion 2.0 :input (lambda (dir) (rd)))))
	  (clm-channel sr 0 12345 oboe 0)
	  (if (not (= (edit-position oboe) 12))
	      (snd-display #__line__ ";oboe clm-channel granulate? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let* ((rd (make-sampler 0))
	       (flt (vct 1.0 0.0 0.0 0.0))
	       (sr (make-convolve :input (lambda (dir) (rd)) :filter flt)))
	  (clm-channel sr 0 12345 oboe 0)
	  (if (not (= (edit-position oboe) 13))
	      (snd-display #__line__ ";oboe clm-channel convolve? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let* ((rd (make-sampler 0))
	       (sr (make-phase-vocoder :input (lambda (dir) (rd)))))
	  (clm-channel sr 0 12345 oboe 0)
	  (if (not (= (edit-position oboe) 14))
	      (snd-display #__line__ ";oboe clm-channel phase-vocoder? ~A ~A" (edit-position oboe) (edit-fragment))))
	(revert-sound)
	
	(let ((tag (catch #t (lambda () (scale-channel 2.0 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (eq? tag 'bad-arity)) (snd-display #__line__ ";bad edpos scale-channel: ~A" tag))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func scale-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (env-channel (make-env '(0 0 1 1) :length 124) 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func env-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (clm-channel (make-oscil) 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func clm-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (vct->channel (make-vct 3) 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func vct->channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (smooth-channel 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (pad-channel 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func pad-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (src-channel 2.0 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func src-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (mix-channel "pistol.snd" 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func mix-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (insert-channel "pistol.snd" 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func insert-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (reverse-channel 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos:func reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	
	(let ((tag (catch #t (lambda () (scale-channel 2.0 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-edit)) (snd-display #__line__ ";bad edpos scale-channel: ~A" tag))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 scale-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (env-channel (make-env '(0 0 1 1) :length 124) 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 env-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (clm-channel (make-oscil) 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 clm-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (vct->channel (make-vct 3) 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 vct->channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (smooth-channel 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (pad-channel 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 pad-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (src-channel 2.0 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 src-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (mix-channel "pistol.snd" 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 mix-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (insert-channel "pistol.snd" 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 insert-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (reverse-channel 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display #__line__ ";edpos 123 reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(revert-sound oboe)
	
	(let ((oldv (channel->vct 1000 10 oboe)))
	  (mix-channel "oboe.snd" 0)
	  (vct-scale! oldv 2.0)
	  (if (not (vequal oldv (channel->vct 1000 10 oboe)))
	      (snd-display #__line__ ";mix-channel at 0: ~A ~A" oldv (channel->vct 1000 10 oboe)))
	  (revert-sound oboe)
	  (vct-scale! oldv 0.5)
	  (insert-channel "oboe.snd" 0)
	  (if (not (vequal oldv (channel->vct 1000 10 oboe)))
	      (snd-display #__line__ ";insert-channel at 0: ~A ~A" oldv (channel->vct 1000 10 oboe)))
	  (if (not (= (frames oboe 0) (* 2 (frames oboe 0 0))))
	      (snd-display #__line__ ";insert-channel frames: ~A ~A" (frames oboe 0) (frames oboe 0 0)))
	  (revert-sound oboe))
	(close-sound oboe)
	
	(let* ((ind (new-sound "test.snd" :size 10 :channels 2)))
	  (set! (sample 3 ind 0) .5)
	  (set! (sample 2 ind 1) -.4)
	  (save-sound-as "fmv.snd")
	  (revert-sound ind)
	  (let ((val (mix-channel "fmv.snd")))
	    (if (mix? val)
		(snd-display #__line__ ";mix-channel returned a mix: ~A?" val)))
	  (if (not (vequal (channel->vct 0 #f ind 1) (make-vct 10 0.0)))
	      (snd-display #__line__ ";mix-channel mixed channel 1: A?" (channel->vct 0 #f ind 1)))
	  (if (not (vequal (channel->vct 0 #f ind 0) (vct 0 0 0 .5 0 0 0 0 0 0)))
	      (snd-display #__line__ ";mix-channel chan 0: ~A" (channel->vct 0 #f ind 0)))
	  (revert-sound ind)
	  (let ((val (mix-channel (list "fmv.snd" 2 1) 0 #f ind 0)))
	    (if (mix? val)
		(snd-display #__line__ ";mix-channel 2 returned a mix: ~A?" val)))
	  (if (not (vequal (channel->vct 0 #f ind 1) (make-vct 10 0.0)))
	      (snd-display #__line__ ";mix-channel mixed channel 1a: A?" (channel->vct 0 #f ind 1)))
	  (if (not (vequal (channel->vct 0 #f ind 0) (vct -.4 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";mix-channel chan 0a: ~A" (channel->vct 0 #f ind 0)))
	  (revert-sound ind)
	  (set! (sample 2 ind 1) -.4)
	  (let ((val (mix-channel (list ind 2 1) 0 #f ind 0 -1 #t)))
	    (if (not (mix? val))
		(snd-display #__line__ ";mix-channel with-tag: ~A" val)))
	  (if (not (vequal (channel->vct 0 #f ind 1) (vct 0 0 -.4 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";mix-channel mixed channel 1b: A?" (channel->vct 0 #f ind 1)))
	  (if (not (vequal (channel->vct 0 #f ind 0) (vct -.4 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";mix-channel chan 0b: ~A" (channel->vct 0 #f ind 0)))
	  (revert-sound ind)
	  (let ((val (car (mix-channel (list "fmv.snd" 2 1) 0 #f ind 0 -1 #t))))
	    (if (not (mix? val))
		(snd-display #__line__ ";mix-channel file with-tag: ~A" val)))
	  (if (not (vequal (channel->vct 0 #f ind 1) (make-vct 10 0.0)))
	      (snd-display #__line__ ";mix-channel mixed channel 1c: A?" (channel->vct 0 #f ind 1)))
	  (if (not (vequal (channel->vct 0 #f ind 0) (vct -.4 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";mix-channel chan 0c: ~A" (channel->vct 0 #f ind 0)))
	  (revert-sound ind)
	  (let ((val (car (mix-channel (list "fmv.snd") 0 #f ind 1 -1 #t))))
	    (if (not (mix? val))
		(snd-display #__line__ ";mix-channel file 1 with-tag: ~A" val)))
	  (if (not (vequal (channel->vct 0 #f ind 0) (make-vct 10 0.0)))
	      (snd-display #__line__ ";mix-channel mixed channel 0d: A?" (channel->vct 0 #f ind 1)))
	  (if (not (vequal (channel->vct 0 #f ind 1) (vct 0 0 0 .5 0 0 0 0 0 0)))
	      (snd-display #__line__ ";mix-channel chan 1d: ~A" (channel->vct 0 #f ind 1)))
	  (revert-sound ind)
	  (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
	  (close-sound ind))
	
	(if (not (= (default-output-chans) 1)) (set! (default-output-chans) 1))
	(let ((ind (new-sound "fmv.snd"))
	      (v0 (vct-fill! (make-vct 20) 1.0)))
	  (vct->channel v0)
	  (if (not (= (frames) 20)) (snd-display #__line__ ";vct->channel new 20: ~A" (frames)))
	  (if (fneq (maxamp) 1.0) (snd-display #__line__ ";vct 1->new: ~A" (maxamp)))
	  
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 20))
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)))
		(snd-display #__line__ ";env-channel step 1: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 20) 8)
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1)))
		(snd-display #__line__ ";env-channel step 1 at 8: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 12))
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1)))
		(snd-display #__line__ ";env-channel step 1 at 0: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 12) 4)
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)))
		(snd-display #__line__ ";env-channel step 1 at 4: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :length 12) 4 3)
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1)))
		(snd-display #__line__ ";env-channel step 1 at 4 by 3: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 1 1 0 2 0) :base 0 :length 8) 0 12)
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1)))
		(snd-display #__line__ ";env-channel step 1 at 0 for 7: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1 3 0 4 0) :base 0 :length 20))
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0)))
		(snd-display #__line__ ";env-channel step 1: ~A" v1)))
	  (env-channel (make-env '(0 0 1 .5 2 .25 3 0 4 0) :base 0 :length 21))
	  (let ((v1 (channel->vct)))
	    (if (not (vequal v1 (vct 0 0 0 0 0 0 .5 .5 .5 .5 .5 .25 .25 .25 .25 0 0 0 0 0)))
		(snd-display #__line__ ";env-channel step 1 (.5): ~A" v1)))
	  (close-sound ind))
	
	(set! (x-axis-style) x-axis-as-percentage)
	(let* ((ind (open-sound "2.snd"))
	       (fr (frames))
	       (m0 (maxamp ind 0))
	       (m1 (maxamp ind 1)))
	  (set! (sync ind) 64)
	  (insert-sound "2.snd")
	  (insert-sound "2.snd")
	  (if (not (= (frames) (* 3 fr))) (snd-display #__line__ ";2.snd 3x = ~A ~A" fr (frames)))
	  (if (not (= (frames ind 0) (frames ind 1))) (snd-display #__line__ ";insert sync'd: ~A ~A" (frames ind 0) (frames ind 1)))
	  (swap-channels)
	  (if (or (fneq m0 (maxamp ind 1)) (fneq m1 (maxamp ind 0)))
	      (snd-display #__line__ ";swapped: ~A ~A -> ~A ~A" m0 m1 (maxamp ind 0) (maxamp ind 1)))
	  (close-sound ind))
	(set! (x-axis-style) x-axis-in-seconds)
	(let ((new-snd (mono-files->stereo "test.snd" "oboe.snd" "pistol.snd")))
	  (if (not (= (channels new-snd) 2)) (snd-display #__line__ ";mono-files->stereo not stereo? ~A" (channels new-snd)))
	  (if (not (string=? (short-file-name new-snd) "test.snd")) (snd-display #__line__ ";mono-files->stereo filename: ~A" (short-file-name new-snd)))
	  (if (not (= (frames new-snd) 50828)) (snd-display #__line__ ";mono-files->stereo frames: ~A" (frames new-snd)))
	  (close-sound new-snd))
	
	(let ((oboe0 (open-sound "oboe.snd"))
	      (oboe1 (open-sound "oboe.snd")))
	  
	  (define (funcs-equal? name func0 func1)
	    (func0 #f #f oboe0)
	    (func1 #f #f oboe1)
	    (if (not (vequal (channel->vct 1000 100 oboe0) (channel->vct 1000 100 oboe1)))
		(snd-display #__line__ ";~A via #f: ~A ~A" name (channel->vct 1000 100 oboe0) (channel->vct 1000 100 oboe1)))
	    (revert-sound oboe0)
	    (revert-sound oboe1)
	    (select-sound oboe0)
	    (func0)
	    (select-sound oboe1)
	    (func1)
	    (if (not (vequal (channel->vct 1000 100 oboe0) (channel->vct 1000 100 oboe1)))
		(snd-display #__line__ ";~A via none: ~A ~A" name (channel->vct 1000 100 oboe0) (channel->vct 1000 100 oboe1)))
	    (revert-sound oboe0)
	    (revert-sound oboe1)
	    (func0 0 (frames oboe0) oboe0)
	    (func1 0 (frames oboe1) oboe1)
	    (if (not (vequal (channel->vct 1000 100 oboe0) (channel->vct 1000 100 oboe1)))
		(snd-display #__line__ ";~A via frames: ~A ~A" name (channel->vct 1000 100 oboe0) (channel->vct 1000 100 oboe1)))
	    (revert-sound oboe0)
	    (revert-sound oboe1))
	  
	  (funcs-equal? "scale-sound-by" 
			(lambda args (apply scale-sound-by (cons 2.0 args)))
			(lambda args (apply scale-channel (cons 2.0 args))))
	  (funcs-equal? "scale-and-ramp" 
			(lambda args (apply scale-sound-by (cons 0.0 args)))
			(lambda args (apply ramp-channel (cons 0.0 (cons 0.0 args)))))
	  (funcs-equal? "scale-and-ramp" 
			(lambda args (apply scale-sound-by (cons 2.0 args)))
			(lambda args (apply ramp-channel (cons 2.0 (cons 2.0 args)))))
	  (funcs-equal? "smooth-sound"
			(lambda args (apply smooth-sound args))
			(lambda args (apply smooth-channel args)))
	  (funcs-equal? "env-sound"
			(lambda args (apply env-sound (list (list 0 0 1 1)
							    (if (> (length args) 0) (car args) 0)
							    (if (and (> (length args) 1) 
								     (number? (cadr args)))
								(- (cadr args) 1)
								#f)
							    1.0
							    (if (> (length args) 2)
								(caddr args)
								(selected-sound)))))
			(lambda args (apply env-channel 
					    (cons (make-env :envelope (list 0 0 1 1) 
							    :length (if (and (> (length args) 1)
									     (number? (cadr args)))
									(cadr args)
									(frames (if (> (length args) 2)
										    (caddr args)
										    (selected-sound)))))
						  args))))
	  (funcs-equal? "map-chan"
			(lambda args (map-chan (lambda (n) (* n 2)) 
					       (if (> (length args) 0) (car args) 0)
					       (if (and (> (length args) 1) 
							(number? (cadr args)))
						   (- (cadr args) 1)
						   #f)
					       "testing..."
					       (if (> (length args) 2)
						   (caddr args)
						   (selected-sound))))
			(lambda args (map-channel (lambda (n) (* n 2))
						  (if (> (length args) 0) (car args) 0)
						  (if (and (> (length args) 1) 
							   (number? (cadr args)))
						      (- (cadr args) 1)
						      #f)
						  (if (> (length args) 2)
						      (caddr args)
						      (selected-sound)))))
	  
	  (funcs-equal? "src-sound"
			(lambda args (apply src-sound (list 2.0 1.0 (if (> (length args) 2) (caddr args) #f))))
			(lambda args (apply src-channel (cons 2.0 args))))
	  (funcs-equal? "reverse-sound"
			(lambda args (apply reverse-sound (list (if (> (length args) 2) (caddr args) #f))))
			(lambda args (apply reverse-channel args)))
	  (funcs-equal? "mix"
			(lambda args (apply mix (list "pistol.snd" 0 0 (if (> (length args) 2) (caddr args) #f))))
			(lambda args (apply mix-channel "pistol.snd" args)))
	  (funcs-equal? "insert-sound"
			(lambda args (apply insert-sound (list "pistol.snd" 0 0 (if (> (length args) 2) (caddr args) #f))))
			(lambda args (apply insert-channel "pistol.snd" args)))
	  (funcs-equal? "ptree-channel"
			(lambda args scale-channel (cons 2.0 args))
			(lambda args ptree-channel (cons (lambda (y) (* y 2.0)) args)))
	  (funcs-equal? "ptree-channel"
			(lambda args map-channel (cons (lambda (n) (+ n .2)) args))
			(lambda args ptree-channel (cons (lambda (y) (+ y .2)) args)))
	  (close-sound oboe0)
	  (close-sound oboe1))
	
	(if (= test-16 0)
	    (let ((ind (open-sound "oboe.snd")))
	      (scale-by .5)
	      (scale-by .25)
	      (undo)
	      (for-each
	       (lambda (func name)
		 (let ((tag (catch #t (lambda () (func ind)) (lambda args (car args)))))
		   (if (not (eq? tag 'no-such-edit))
		       (snd-display #__line__ ";~A upon about-to-be-clobbered data: ~A" name tag))))
	       (list (lambda (n) (scale-channel .5 0 #f n 0 2))
		     (lambda (n) (env-channel '(0 0 1 1 2 0) 0 #f n 0 2))
		     (if (> (optimization) 0)
			 (lambda (n) (ptree-channel (lambda (y1) y1) 0 #f n 0 2 #f))
			 (lambda (n) (pad-channel 0 100 n 0 2)))
		     ;;(lambda (n) (map-channel (lambda (y2) y2) 0 #f n 0 2)) ; actually will work
		     (lambda (n) (pad-channel 100 100 n 0 2))
		     (lambda (n) (delete-sample 100 n 0 2))
		     (lambda (n) (set! (sample 100 n 0 2) .52))
		     )
	       (list "scale" "env" "ptree" 
		     ;;"map" 
		     "pad" "delete" "set"
		     ))
	      (close-sound ind)))
	
	(let ((ind (new-sound "test.snd")))
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y .5)))
	  (insert-silence 100 200)
	  (if (fneq (sample 500) 0.5)
	      (snd-display #__line__ ";trailing ptree rmp0 trouble: ~A" (sample 500)))
	  (revert-sound ind)
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (scale-by .5)
	  (ptree-channel (lambda (y) (* y .5)))
	  (insert-silence 100 200)
	  (if (fneq (sample 500) 0.25)
	      (snd-display #__line__ ";trailing ptree scaled rmp0 trouble: ~A" (sample 500)))
	  (scale-by 2.0)
	  (if (fneq (sample 500) 0.5)
	      (snd-display #__line__ ";trailing ptree post scaled rmp0 trouble: ~A" (sample 500)))
	  (revert-sound ind)
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y .5)))
	  (delete-samples 100 200)
	  (if (fneq (sample 500) 0.5)
	      (snd-display #__line__ ";trailing ptree post delete rmp0 trouble: ~A" (sample 500)))
	  (if (fneq (sample 0) 0.5)
	      (snd-display #__line__ ";trailing ptree pre delete rmp0 trouble: ~A" (sample 500)))
	  (revert-sound ind)
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y .5)))
	  (set! (sample 100) .95)
	  (if (fneq (sample 500) 0.5)
	      (snd-display #__line__ ";trailing ptree post change rmp0 trouble: ~A" (sample 500)))
	  (if (fneq (sample 0) 0.5)
	      (snd-display #__line__ ";trailing ptree pre change rmp0 trouble: ~A" (sample 500)))
	  (revert-sound ind)
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y .1)))
	  (delete-samples 100 200)
	  (if (fneq (sample 500) 0.1)
	      (snd-display #__line__ ";trailing ptree post delete(1) loc trouble: ~A" (sample 500)))
	  (if (fneq (sample 0) 0.1)
	      (snd-display #__line__ ";trailing ptree pre delete(1) loc trouble: ~A" (sample 500)))
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (scale-by .5)
	  (ptree-channel (lambda (y) (* y .5)))
	  (scale-by .5)
	  (if (fneq (sample 500) 0.125)
	      (snd-display #__line__ ";scl-ptree-scl trouble: ~A" (sample 500)))
	  (revert-sound ind)
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y .5)))
	  (env-sound '(0 0 1 1 2 0))
	  (if (or (fneq (sample 0) 0.0)
		  (fneq (sample 999) 0.0005)
		  (fneq (sample 500) 0.5)
		  (fneq (sample 250) 0.25)
		  (fneq (sample 750) 0.25))
	      (snd-display #__line__ ";ptree-env trouble: ~A"
			   (map sample (list 0 999 500 250 750))))
	  
	  (insert-silence 0 1000)
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y .5)))
	  (make-selection 100 200)
	  (scale-selection-by .5)
	  (if (or (fneq (sample 500) 0.5)
		  (fneq (sample 50) 0.5)
		  (fneq (sample 150) 0.25))
	      (snd-display #__line__ ";ptree-scl-selection trouble: ~A" (map sample (list 500 50 150))))
	  (revert-sound ind)
	  (close-sound ind))
	
	(let ((ind (open-sound "oboe.snd"))
	      (ind1 (new-sound "test.snd"))
	      (old-save-dir (save-dir)))
	  (set! (save-dir) #f)
	  (map-channel (lambda (y) 0.5) 0 100 ind1 0)
	  (save-sound ind1)
	  (close-sound ind1)
	  (insert-sound "test.snd" 12345)
	  (let ((vals (channel->vct (- 12345 50) 200 ind 0)))
	    (if (file-exists? "hiho.scm") (delete-file "hiho.scm"))
	    (save-state "hiho.scm")
	    (close-sound ind)
	    (for-each forget-region (regions))
	    (load (string-append cwd "hiho.scm"))
	    (set! ind (find-sound "oboe.snd"))
	    (if (not (sound? ind))
		(snd-display #__line__ ";save hiho failed?")
		(let ((new-vals (channel->vct (- 12345 50) 200 ind 0)))
		  (if (not (vequal vals new-vals))
		      (snd-display #__line__ ";save state hiho vals: ~A ~A" vals new-vals))))
	    (close-sound ind))
	  (set! (save-dir) old-save-dir))
	
	(let ((ind (open-sound "oboe.snd")))
	  (for-each
	   (lambda (func val name)
	     (func ind)
	     (if (file-exists? "s61.scm") (delete-file "s61.scm"))
	     (save-state "s61.scm")
	     (close-sound ind)
	     (for-each forget-region (regions))
	     (load (string-append cwd "s61.scm"))
	     (set! ind (find-sound "oboe.snd"))
	     (if (fneq (maxamp ind) val)
		 (snd-display #__line__ ";saved ~A max: ~A ~A (at ~A of ~A)" 
			      name (maxamp ind) val (edit-position ind 0) (display-edits ind 0)))
	     (revert-sound ind))
	   (list (lambda (ind)
		   (ptree-channel (lambda (y) (* y .5))))
		 (lambda (ind)
		   (ptree-channel (lambda (y data forward)
				    (* y (vct-ref data 0)))
				  0 #f ind 0 #f #f
				  (lambda (pos dur)
				    (vct 0.5))))
		 (lambda (ind)
		   (scale-by 0.0)
		   (pad-channel 0 10 ind 0 0))
		 (lambda (ind)
		   (scale-by 0.0)
		   (scale-channel 0.5 0 #f ind 0 0))
		 (lambda (ind)
		   (scale-by 0.0)
		   (env-channel '(0 0 1 .5 2 0) 0 #f ind 0 0))
		 (lambda (ind)
		   (scale-by 0.0)
		   (set! (sample 0 ind 0 0) 0.9))
		 (lambda (ind)
		   (scale-by 0.0)
		   (delete-samples 0 100 ind 0 0))
		 (lambda (ind)
		   (scale-by 0.0)
		   (ptree-channel (lambda (y) (* y 0.5)) 0 #f ind 0 0 #f))
		 (lambda (ind)
		   (scale-by 0.0)
		   (ptree-channel (lambda (y data forward)
				    (* y (vct-ref data 0)))
				  0 #f ind 0 0 #f
				  (lambda (pos dur)
				    (vct 0.5))))
		 (lambda (ind)
		   (insert-samples 100 10 (make-vct 10 0.1) ind 0 0))	  
		 )
	   (list .0736 .0736 .147 .0736 .0736 0.9 .147 .0736 .0736 .147)
	   (list "ptree" "ptree with init" "pad edpos" "scl edpos" "env edpos" 
		 "set edpos" "delete edpos" "ptree edpos" "init ptree edpos" "insert edpos"))
	  (close-sound ind))
	
	(let ((ind-ptree (new-sound "test1.snd"))
	      (ind-closure (new-sound "test2.snd"))
	      (ind-map (new-sound "test3.snd")))
	  (for-each
	   (lambda (m)
	     (insert-silence 0 9 m 0)
	     (map-channel (lambda (y) 1.0) 0 #f m 0))
	   (list ind-ptree ind-closure ind-map))
	  (for-each
	   (lambda (pt cl mp vc name)
	     (let ((edpt (edit-position ind-ptree 0))
		   (edcl (edit-position ind-closure 0))
		   (edmp (edit-position ind-map 0)))
	       (pt ind-ptree)
	       (cl ind-closure)
	       (mp ind-map)
	       (let ((ptv (samples->vct 0 (frames ind-ptree) ind-ptree 0))
		     (ptc (samples->vct 0 (frames ind-closure) ind-closure 0))
		     (ptm (samples->vct 0 (frames ind-map) ind-map 0)))
		 (if (not (vequal ptv vc)) (snd-display #__line__ ";~A ptree: ~A ~A" name ptv vc))
		 (if (not (vequal ptc vc)) (snd-display #__line__ ";~A closure: ~A ~A" name ptc vc))
		 (if (not (vequal ptm vc)) (snd-display #__line__ ";~A map: ~A ~A" name ptm vc)))
	       
	       (let ((ptv (reversed-read ind-ptree 0))
		     (ptc (reversed-read ind-closure 0))
		     (ptm (reversed-read ind-map 0)))
		 (if (not (vequal ptv vc)) (snd-display #__line__ ";reversed ~A ptree: ~A ~A" name ptv vc))
		 (if (not (vequal ptc vc)) (snd-display #__line__ ";reversed ~A closure: ~A ~A" name ptc vc))
		 (if (not (vequal ptm vc)) (snd-display #__line__ ";reversed ~A map: ~A ~A" name ptm vc)))
	       
	       (let ((ptv (zigzag-read ind-ptree 0))
		     (ptc (zigzag-read ind-closure 0))
		     (ptm (zigzag-read ind-map 0)))
		 (if (not (vequal ptv vc)) (snd-display #__line__ ";zigzag ~A ptree: ~A ~A" name ptv vc))
		 (if (not (vequal ptc vc)) (snd-display #__line__ ";zigzag ~A closure: ~A ~A" name ptc vc))
		 (if (not (vequal ptm vc)) (snd-display #__line__ ";zigzag ~A map: ~A ~A" name ptm vc)))
	       
	       (set! (edit-position ind-ptree 0) edpt)
	       (set! (edit-position ind-closure 0) edcl)
	       (set! (edit-position ind-map 0) edmp)))
	   
	   (list 
	    (lambda (ind) 
	      (ptree-channel (lambda (y) 1.0) 0 #f ind 0 #f #f))
	    (lambda (ind) 
	      (scale-by 0.5 ind 0) 
	      (ptree-channel (lambda (y3) y3) 0 #f ind 0 #f #f))
	    (lambda (ind)
	      (ptree-channel (lambda (y4) y4) 0 #f ind 0 #f #f)
	      (scale-by 0.5 ind 0))
	    (lambda (ind)
	      (ptree-channel (lambda (y) (* y 0.5)) 0 #f ind 0 #f #f)
	      (delete-samples 2 3 ind 0))
	    (lambda (ind)
	      (ptree-channel (lambda (y) (* y 0.5)) 0 #f ind 0 #f #f)
	      (set! (samples 2 3 ind 0) (make-vct 3)))
	    (lambda (ind)
	      (set! (samples 0 10 ind 0) (vct 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
	      (ptree-channel (lambda (y) (* y 0.5)) 0 #f ind 0 #f #f)
	      (delete-sample 2 ind 0)
	      (delete-sample 6 ind 0))
	    
	    (lambda (ind) 
	      (ptree-channel (lambda (y) 1.0) 2 #f ind 0 #f #f))
	    (lambda (ind) 
	      (scale-by 0.5 ind 0) 
	      (ptree-channel (lambda (y5) y5) 2 #f ind 0 #f #f))
	    (lambda (ind)
	      (ptree-channel (lambda (y6) y6) 2 #f ind 0 #f #f)
	      (scale-by 0.5 ind 0))
	    (lambda (ind)
	      (ptree-channel (lambda (y) (* y 0.5)) 2 #f ind 0 #f #f)
	      (delete-samples 2 3 ind 0))
	    (lambda (ind)
	      (ptree-channel (lambda (y) (* y 0.5)) 2 #f ind 0 #f #f)
	      (set! (samples 2 3 ind 0) (make-vct 3)))
	    (lambda (ind)
	      (set! (samples 0 10 ind 0) (vct 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
	      (ptree-channel (lambda (y) (* y 0.5)) 2 #f ind 0 #f #f)
	      (delete-sample 2 ind 0)
	      (delete-sample 6 ind 0))
	    
	    (lambda (ind)
	      ;; forced-fallback
	      (ptree-channel (let ((sym (list 1))) (lambda (y) (if (eq? (car sym) 1) (* y 0.5) y))) 2 3 ind 0 #f #f))
	    (lambda (ind)
	      ;; forced-fallback
	      (ptree-channel (let ((sym (list 1))) (lambda (y) (if (eq? (car sym) 1) (* y 0.5) y))) 0 #f ind 0 #f #f))
	    
	    (lambda (ind)
	      (scale-by 0.0)
	      (ptree-channel (lambda (y7) y7) 0 #f ind 0 2 #f)
	      (scale-by 0.5 ind 0))
	    
	    )
	   
	   (list 
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       1.0) 
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0))))
	    (lambda (ind) 
	      (scale-by 0.5 ind 0) 
	      (ptree-channel (lambda (y data dir) 
			       y) 
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0))))
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       y) 
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0)))
	      (scale-by 0.5 ind 0) )
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       (* y (vct-ref data 0)))
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.5)))
	      (delete-samples 2 3 ind 0))
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       (* y (vct-ref data 0)))
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.5)))
	      (set! (samples 2 3 ind 0) (make-vct 3)))
	    (lambda (ind) 
	      (set! (samples 0 10 ind 0) (vct 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
	      (ptree-channel (lambda (y data dir) 
			       (* y (vct-ref data 0)))
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.5)))
	      (delete-sample 2 ind 0)
	      (delete-sample 6 ind 0))
	    
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       1.0) 
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0))))
	    (lambda (ind) 
	      (scale-by 0.5 ind 0) 
	      (ptree-channel (lambda (y data dir) 
			       y) 
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0))))
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       y) 
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0)))
	      (scale-by 0.5 ind 0) )
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       (* y (vct-ref data 0)))
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.5)))
	      (delete-samples 2 3 ind 0))
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       (* y (vct-ref data 0)))
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.5)))
	      (set! (samples 2 3 ind 0) (make-vct 3)))
	    (lambda (ind) 
	      (set! (samples 0 10 ind 0) (vct 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
	      (ptree-channel (lambda (y data dir) 
			       (* y (vct-ref data 0)))
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.5)))
	      (delete-sample 2 ind 0)
	      (delete-sample 6 ind 0))
	    
	    (lambda (ind)
	      ;; forced-fallback
	      (ptree-channel (let ((sym (list 1))) 
			       (lambda (y data dir)
				 (if (eq? (car sym) 1) (* y 0.5) (* y (vct-ref data 0)))))
			     2 3 ind 0 #f #f
			     (lambda (pos dur)
			       (vct 1.0))))
	    (lambda (ind)
	      ;; forced-fallback
	      (ptree-channel (let ((sym (list 1))) 
			       (lambda (y data dir)
				 (if (eq? (car sym) 1) (* y 0.5) (* y (vct-ref data 0)))))
			     0 #f ind 0 #f #f
			     (lambda (pos dur)
			       (vct 1.0))))
	    (lambda (ind) 
	      (scale-by 0.0)
	      (ptree-channel (lambda (y data dir) 
			       y) 
			     0 #f ind 0 2 #f 
			     (lambda (pos dur) (vct 0.0)))
	      (scale-by 0.5 ind 0) )
	    
	    )
	   
	   (list 
	    (lambda (ind) 
	      (map-channel (lambda (y) 1.0) 0 #f ind 0))
	    (lambda (ind)
	      (scale-by 0.5 ind 0)
	      (map-channel (lambda (y8) y8) 0 #f ind 0))
	    (lambda (ind)
	      (map-channel (lambda (y9) y9) 0 #f ind 0)
	      (scale-by 0.5 ind 0))
	    (lambda (ind)
	      (map-channel (lambda (y) (* y 0.5)) 0 #f ind 0)
	      (delete-samples 2 3 ind 0))
	    (lambda (ind)
	      (map-channel (lambda (y) (* y 0.5)) 0 #f ind 0)
	      (set! (samples 2 3 ind 0) (make-vct 3)))
	    (lambda (ind)
	      (set! (samples 0 10 ind 0) (vct 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
	      (map-channel (lambda (y) (* y 0.5)) 0 #f ind 0)
	      (delete-sample 2 ind 0)
	      (delete-sample 6 ind 0))
	    
	    (lambda (ind) 
	      (map-channel (lambda (y) 1.0) 2 #f ind 0))
	    (lambda (ind)
	      (scale-by 0.5 ind 0)
	      (map-channel (lambda (y10) y10) 2 #f ind 0))
	    (lambda (ind)
	      (map-channel (lambda (y11a) y11a) 2 #f ind 0)
	      (scale-by 0.5 ind 0))
	    (lambda (ind)
	      (map-channel (lambda (y) (* y 0.5)) 2 #f ind 0)
	      (delete-samples 2 3 ind 0))
	    (lambda (ind)
	      (map-channel (lambda (y) (* y 0.5)) 2 #f ind 0)
	      (set! (samples 2 3 ind 0) (make-vct 3)))
	    (lambda (ind)
	      (set! (samples 0 10 ind 0) (vct 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))
	      (map-channel (lambda (y) (* y 0.5)) 2 #f ind 0)
	      (delete-sample 2 ind 0)
	      (delete-sample 6 ind 0))
	    
	    (lambda (ind)
	      ;; forced-fallback
	      (map-channel (let ((sym (list 1))) (lambda (y) (if (eq? (car sym) 1) (* y 0.5) y))) 2 3 ind 0))
	    (lambda (ind)
	      ;; forced-fallback
	      (map-channel (let ((sym (list 1))) (lambda (y) (if (eq? (car sym) 1) (* y 0.5) y))) 0 #f ind 0))
	    (lambda (ind)
	      (scale-by 0.0)
	      (map-channel (lambda (y12a) y12a) 0 #f ind 0 2)
	      (scale-by 0.5 ind 0))
	    
	    )
	   
	   (list 
	    (make-vct 10 1.0)
	    (make-vct 10 0.5)
	    (make-vct 10 0.5)
	    (make-vct 7 0.5)
	    (vct 0.5 0.5 0.0 0.0 0.0 0.5 0.5 0.5 0.5 0.5)
	    (vct-scale! (vct 0.0 1.0 3.0 4.0 5.0 6.0 8.0 9.0) 0.5)
	    
	    (make-vct 10 1.0)
	    (make-vct 10 0.5)
	    (make-vct 10 0.5)
	    (vct 1.0 1.0 0.5 0.5 0.5 0.5 0.5)
	    (vct 1.0 1.0 0.0 0.0 0.0 0.5 0.5 0.5 0.5 0.5)
	    (vct 0.0 1.0 1.5 2.0 2.5 3.0 4.0 4.5)
	    
	    (vct 1.0 1.0 0.5 0.5 0.5 1.0 1.0 1.0 1.0 1.0)
	    (make-vct 10 0.5)
	    (make-vct 10 0.5)
	    )
	   
	   (list 
	    "identity"
	    "half"
	    "flah"
	    "2:3 delete"
	    "2:3 change"
	    "step delete"
	    
	    "2 identity"
	    "2 half"
	    "2 flah"
	    "2 2:3 delete"
	    "2 2:3 change"
	    "2 step delete"
	    
	    "fallback 1"
	    "fallback 2"
	    "edpos"
	    )
	   )
	  
	  (for-each
	   (lambda (m)
	     (close-sound m))
	   (list ind-ptree ind-closure ind-map))
	  )
	
	(let ((ind (new-sound "test.snd")))
	  (map-chan (lambda (y) (random 1.0)) 0 10)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp" ind 0)
	  (undo)
	  
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree" ind 0)
	  (undo)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ptree-channel (lambda (y) (* y 1.5)))
	  (zigzag-check "ptree2" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp-ptree2" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2-ptree2" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp3-ptree2" ind 0)
	  (undo 3)
	  (xramp-channel 0.0 1.0 32.0)
	  (zigzag-check "xramp-ptree2" ind 0)
	  (undo 3)
	  
	  (scale-channel 0.0)
	  (ptree-channel (lambda (y) (+ y 0.5)))
	  (zigzag-check "ptree-zero" ind 0)
	  (undo)
	  (ptree-channel (lambda (y) (+ y 0.5)))
	  (ptree-channel (lambda (y) (+ y 1.5)))
	  (zigzag-check "ptree2-zero" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp-ptree2-zero" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2-ptree2-zero" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp3-ptree2-zero" ind 0)
	  (undo 3)
	  (xramp-channel 0.0 1.0 32.0)
	  (zigzag-check "xramp-ptree2-zero" ind 0)
	  (undo 4)
	  
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 1.0 0.0)
	  (zigzag-check "ramp2" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 3.0)
	  (xramp-channel 1.0 0.0 0.3)
	  (zigzag-check "xramp2" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 3.0)
	  (xramp-channel 1.0 0.0 0.3)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+xramp2" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (xramp-channel 1.0 0.0 0.3)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+xramp+ramp" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 1.0 0.0)
	  (ramp-channel 0.1 0.8)
	  (zigzag-check "ramp3" ind 0)
	  (undo 3)
	  (xramp-channel 0.0 1.0 32.0)
	  (zigzag-check "xramp" ind 0)
	  (undo)
	  (scale-channel 0.5)
	  (set! (sample 4) .5)
	  (delete-sample 2)
	  (insert-sample 1 .1)
	  (zigzag-check "simple" ind 0)
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (xramp-channel 1.0 0.0 32.0)
	  (zigzag-check "xramp+ramp" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 32.0)
	  (ramp-channel 1.0 0.0)
	  (zigzag-check "ramp+xramp" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 32.0)
	  (ramp-channel 1.0 0.0)
	  (ramp-channel 1.0 0.0)
	  (zigzag-check "ramp2+xramp" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+ramp" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+ramp2" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (+ y 0.5)))
	  (zigzag-check "ptree+ramp3" ind 0)
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (xramp-channel 0.0 1.0 32.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+xramp+ramp" ind 0)
	  (undo 1)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+ramp+xramp+ramp" ind 0)
	  (undo 4)
	  
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+ptree+ramp" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2+ptree+ramp" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 .3)
	  (zigzag-check "xramp+ptree+ramp" ind 0)
	  (undo 3)
	  (xramp-channel 0.0 1.0 .3)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+ptree+xramp" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2+ptree+xramp" ind 0)
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+ptree+ramp2" ind 0)
	  (undo 4)
	  
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y data forward)
			   (* y (vct-ref data 0)))
			 0 (frames) ind 0 #f #f
			 (lambda (pos dur)
			   (vct 0.5)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+ptreec+ramp" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2+ptreec+ramp" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 .3)
	  (zigzag-check "xramp+ptreec+ramp" ind 0)
	  (undo 3)
	  (xramp-channel 0.0 1.0 .3)
	  (ptree-channel (lambda (y data forward)
			   (* y (vct-ref data 0)))
			 0 (frames) ind 0 #f #f
			 (lambda (pos dur)
			   (vct 0.5)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+ptreec+xramp" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2+ptreec+xramp" ind 0)
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y data forward)
			   (* y (vct-ref data 0)))
			 0 (frames) ind 0 #f #f
			 (lambda (pos dur)
			   (vct 0.5)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+ptreec+ramp2" ind 0)
	  (undo 4)
	  
	  (pad-channel 2 3)
	  (zigzag-check "zero" ind 0)
	  (undo)
	  (ptree-channel (lambda (y data forward)
			   (* y (vct-ref data 0)))
			 0 (frames) ind 0 #f #f
			 (lambda (pos dur)
			   (vct 0.5)))
	  (zigzag-check "ptree+closure" ind 0)
	  (undo)
	  (ramp-channel 0.0 1.0)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (zigzag-check "ptree+ramp" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 .3)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (zigzag-check "ptree+xramp" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 1.0 0.0)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (zigzag-check "ptree+ramp2" ind 0)
	  (undo 3)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+ptreec" ind 0)
	  (undo 2)
	  (scale-channel 0.0 3 4)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+ptreec+zero" ind 0)
	  (undo 3)
	  
	  ;; zero checks
	  (scale-channel 0.0 3 4)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+zero" ind 0)
	  (undo 2)
	  (scale-channel 0.0 3 4)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ptree-channel (lambda (y) (+ y .1)))
	  (zigzag-check "ptree2+zero" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ptree-channel (lambda (y) (+ y .1)))
	  (zigzag-check "ptree2+ramp" ind 0)
	  (undo 3)
	  (pad-channel 2 4)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree+pad" ind 0)
	  (undo 2)
	  (scale-channel 0.0 3 4)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (zigzag-check "ptree+closure+zero" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (scale-channel 0.0 2 4)
	  (cosine-channel-via-ptree 0 (frames) ind 0 #f)
	  (zigzag-check "ptree+ramp+zero" ind 0)
	  (undo 3)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (zigzag-check "ptree+ramp+ptree" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ptree+ramp+ptree+ramp" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ptree+ramp+ptree+ramp2" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (zigzag-check "ptree+ramp2+ptree" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ptree+ramp2+ptree+ramp" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (zigzag-check "ptree+ramp3+ptree" ind 0)
	  (undo 5)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree2+ramp2" ind 0)
	  (undo 4)
	  (xramp-channel 0.0 1.0 32)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "ptree2+xramp" ind 0)
	  (undo)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2+ptree+xramp" ind 0)
	  (undo 4)
	  (xramp-channel 0.0 1.0 32)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (zigzag-check "prx" ind 0)
	  (undo 3)
	  (scale-channel 0.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (xramp-channel 0.0 1.0 32)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "rxpz" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "r2xpz" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (xramp-channel 0.0 1.0 32)
	  (zigzag-check "xrpz" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "rxrpz" ind 0)
	  (undo 5)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (ramp-channel 0.0 1.0)
	  (xramp-channel 0.0 1.0 32)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "rxrp" ind 0)
	  (undo 4)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (xramp-channel 0.0 1.0 32)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "r2xp" ind 0)
	  (undo 4)
	  (scale-channel 0.0)
	  (ptree-channel (lambda (y) (* y 0.25)))
	  (xramp-channel 0.0 1.0 32)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "pxpz" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "prpz" ind 0)
	  (undo)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "pr2pz" ind 0)
	  (undo)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "pr3pz" ind 0)
	  (undo 6)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "p2r3" ind 0)
	  (undo 4)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "prpr" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "rprpr" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "pr2pr" ind 0)
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "prpr2" ind 0)
	  (undo 5)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "prpr" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "rprpr" ind 0)
	  (undo 5)
	  (xramp-channel 0.0 1.0 32)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "pr2x" ind 0)
	  (undo 4)
	  (xramp-channel 0.0 1.0 32)
	  (xramp-channel 0.0 1.0 32)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "px2" ind 0)
	  (undo 3)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (xramp-channel 0.0 1.0 32)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "rxp" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (xramp-channel 0.0 1.0 32)
	  (zigzag-check "xrp" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 32)
	  (ptree-channel (lambda (y) (* y 0.5)))
	  (zigzag-check "pxp" ind 0)
	  (undo 3)
	  
	  ;; ramp[n]-ptree[c][zero] or xen checks
	  (revert-sound ind)
	  (map-chan (lambda (y) (random 1.0)) 0 10)
	  (for-each
	   (lambda (func name twice)
	     (func)
	     (zigzag-check "first" ind 0)
	     (ramp-channel 0.0 1.0)
	     (zigzag-check name ind 0)
	     (undo 2)
	     (scale-channel 0.0)
	     (func)
	     (zigzag-check "first-zero" ind 0)
	     (ramp-channel 0.0 1.0)
	     (zigzag-check (string-append name "-zero") ind 0)
	     (undo 3)
	     (func)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (zigzag-check (string-append name "2") ind 0)
	     (undo 3)
	     (scale-channel 0.0)
	     (func)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (zigzag-check (string-append name "2-zero") ind 0)
	     (undo 4)
	     (func)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (zigzag-check (string-append name "3") ind 0)
	     (undo 4)
	     (scale-channel 0.0)
	     (func)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (zigzag-check (string-append name "4-zero") ind 0)
	     (undo 5)
	     (func)
	     (xramp-channel 0.0 1.0 32.0)
	     (zigzag-check (string-append name "x1") ind 0)
	     (if twice
		 (begin
		   (xramp-channel 0.0 1.0 32.0)
		   (zigzag-check (string-append name "x2") ind 0)
		   (undo 1)))
	     (undo 2)
	     (scale-channel 0.0)
	     (func)
	     (xramp-channel 0.0 1.0 32)
	     (zigzag-check (string-append name "x1-zero") ind 0)
	     (if twice
		 (begin
		   (xramp-channel 0.0 1.0 32.0)
		   (zigzag-check (string-append name "x2-zero") ind 0)
		   (undo 1)))
	     (undo 3)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (ramp-channel 0.0 1.0)
	     (func)
	     (zigzag-check (string-append name "-r3") ind 0)
	     (undo 4))
	   (list (lambda () (ptree-channel (lambda (y) (+ y 0.5))))
		 (lambda () (ptree-channel (lambda (y data forward)
					     (* y (vct-ref data 0)))
					   0 (frames) ind 0 #f #f
					   (lambda (pos dur)
					     (vct 0.5))))
		 )
	   (list "ramp-ptree" "ramp-ptreec")
	   (list #t #t))
	  (close-sound ind))
	
	(let ((ind (new-sound "test.snd")))
	  (insert-silence 0 100)
	  (map-chan (lambda (y) 1.0))
	  (cosine-channel-via-ptree)
	  (delete-sample 10)
	  (set! (sample 20) .5)
	  (insert-silence 30 1)
	  (if (or (fneq (sample 12) .393)
		  (fneq (sample 0) 0.0)
		  (fneq (sample 25) .723)
		  (fneq (sample 30) 0.0)
		  (fneq (sample 20) 0.5)
		  (fneq (sample 21) .632)
		  (fneq (sample 31) .822)
		  (fneq (sample 50) 1.0))
	      (snd-display #__line__ ";cosine-chan with edits: ~A"
			   (map sample (list 12 0 25 30 20 21 31 50))))
	  (close-sound ind))
	
	(let ((ind (open-sound "oboe.snd")))
	  (scale-by 0.0)
	  (ptree-channel (lambda (y) (+ y .1)))
	  (set! (sample 100) .05)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";scale+ptree+set -> ~A" mx)))
	  (if (and (> (optimization) 0)
		   (not (string=? (display-edits) (string-append "
EDITS: 3

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (scale 0 50828) ; scale-channel 0.000 0 #f [1:2]:
   (at 0, cp->sounds[0][0:50827, 0.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[0] 0 50828) ; ptree-channel [2:2]:
   (at 0, cp->sounds[0][0:50827, 1.000, loc: 0, pos: 0, scl: 0.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (set 100 1) ; set-sample 100 0.0500 [3:4]:
   (at 0, cp->sounds[0][0:99, 1.000, loc: 0, pos: 0, scl: 0.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 101, cp->sounds[0][101:50827, 1.000, loc: 0, pos: 101, scl: 0.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
"))))
	      (snd-display #__line__ ";ptree split: ~A" (display-edits)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";scale+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";scale+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display #__line__ ";scale+ptree+mix -> ~A" mx)))
	  (undo)
	  (ptree-channel (lambda (y) .01) 100 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";scale+ptree+ptree -> ~A" mx)))
	  (undo)
	  (env-channel '(0 0 1 1) 100 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";scale+ptree+env -> ~A" mx)))
	  (revert-sound)
	  (scale-by 0.01)
	  (ptree-channel (lambda (y) .1))
	  (set! (sample 100) .05)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)scale+ptree+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)scale+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)scale+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display #__line__ ";(1)scale+ptree+mix -> ~A" mx)))
	  (revert-sound)
	  (ptree-channel (lambda (y) .1))
	  (set! (sample 100) .05)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(2)scale+ptree+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(2)scale+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(2)scale+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display #__line__ ";(2)scale+ptree+mix -> ~A" mx)))
	  (revert-sound)
	  (env-sound '(0 0 1 .01 2 0))
	  (ptree-channel (lambda (y) .1))
	  (set! (sample 100) .05)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(3)env+ptree+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(3)env+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(3)env+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display #__line__ ";(3)env+ptree+mix -> ~A" mx)))
	  (revert-sound)
	  
	  (env-sound '(0 0 1 .679 2 0))
	  (set! (sample 100) .05)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)env+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)env+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)env+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display #__line__ ";(1)env+mix -> ~A" mx)))
	  (revert-sound)
	  
	  (close-sound ind))
	
	(let ((ind (new-sound "test.snd")))
	  (map-chan (lambda (y) 1.0) 0 100)
	  (ramp-channel 0.0 1.0)
	  (smooth-channel 0 99)
	  (let ((orig-data (channel->vct)))
	    (undo)
	    (smooth-channel-via-ptree 0 99)
	    (let ((diff (vct-peak (vct-subtract! orig-data (channel->vct)))))
	      (if (> diff .00001)
		  (snd-display #__line__ ";smooth-channel-via-ptree diff: ~A" diff))))
	  (close-sound ind))
	
	(set! (x-axis-style) x-axis-in-beats)
	(let ((ind (open-sound "storm.snd")))
	  (reverse-channel 500000 1000000)
	  (set! (sample 0 ind 0 current-edit-position) .1)
	  (if (fneq (sample 0 ind 0 current-edit-position) .1) 
	      (snd-display #__line__ ";set sample + edpos: ~A" (sample 0 ind 0 current-edit-position)))
	  (close-sound ind))
	(set! (x-axis-style) x-axis-in-seconds)
	
	(for-each 
	 (lambda (out-chans)
	   (let ((ind (new-sound "new.snd" mus-next mus-bfloat 22050 out-chans "edpos testing"))
		 (mx (apply max (map sync (sounds)))))
	     (set! (sync ind) (+ mx 1))
	     (for-each 
	      (lambda (in-sound)
		(for-each
		 (lambda (func)
		   (for-each 
		    (lambda (edpos)
		      (func edpos)
		      (revert-sound ind))
		    (list (lambda () current-edit-position)
			  (lambda () 0)
			  (lambda () (lambda (s c) (- (edit-position s c) 1)))
			  (lambda () (lambda (s c) (edit-position s c)))
			  (lambda () (lambda (s c) current-edit-position))
			  (lambda () (lambda (s c) 0)))))
		 (list 
		  (lambda (posfunc)
		    (let ((chn (min (random (+ 1 out-chans)) (- out-chans 1))))
		      (if (not (vequal (channel->vct 0 (frames ind chn) ind chn 0) (vct 0.0)))
			  (snd-display #__line__ ";start bad: ~A" (channel->vct 0 (frames ind chn) ind chn 0)))
		      (set! (sample 0 ind chn) .1)
		      (if (not (vequal (channel->vct 0 (frames ind chn) ind chn) (vct 0.1)))
			  (snd-display #__line__ ";set bad: ~A" (channel->vct 0 (frames ind chn) ind chn)))
		      (pad-channel 0 1 ind chn (posfunc))
		      (let ((pos (posfunc))) (if (procedure? pos)
						 (set! pos (pos ind chn)))
			   (let ((data (channel->vct 0 (frames ind chn) ind chn)))
			     (if (or (and (= pos 0) 
					  (not (vequal data (vct 0.0 0.0))))
				     (and (or (= pos current-edit-position) 
					      (= pos (edit-position ind chn)))
					  (not (vequal data (vct 0.0 0.1))))			  
				     (and (= pos (- (edit-position ind chn) 1))
					  (not (vequal data (vct 0.0 0.0)))))
				 (snd-display #__line__ ";pos[~A]: edpos ~A of ~A, pad result[~A, ~A]: ~A" 
					      chn pos (edit-position ind chn) (frames ind chn pos) (frames ind chn) data))
			     (if (> (chans ind) 1)
				 (do ((i 0 (+ 1 i)))
				     ((= i (chans ind)))
				   (if (not (= i chn))
				       (let ((data (channel->vct 0 (frames ind i) ind i)))
					 (if (not (vequal data (vct 0.0)))
					     (snd-display #__line__ ";pad[~A / ~A] empty: ~A" i chn data))))))))))
		  (lambda (posfunc)
		    (let ((chn (min (random (+ 1 out-chans)) (- out-chans 1))))
		      (set! (sample 0 ind chn) .1)
		      (set! (sample 0 ind chn (posfunc)) (* 2 (sample 0 ind chn (posfunc)))) ; not scale since it checks for zeros
		      (let ((pos (posfunc)))
			(if (procedure? pos) (set! pos (pos ind chn)))
			(let ((data (channel->vct 0 (frames ind chn) ind chn)))
			  (if (or (and (= pos 0) 
				       (not (vequal data (vct 0.0))))
				  (and (or (= pos current-edit-position) 
					   (= pos (edit-position ind chn)))
				       (not (vequal data (vct 0.2))))			  
				  (and (= pos (- (edit-position ind chn) 1))
				       (not (vequal data (vct 0.0)))))
			      (snd-display #__line__ ";pos[~A]: edpos ~A of ~A, set *2 result[~A, ~A]: ~A" 
					   chn pos (edit-position ind chn) (frames ind chn pos) (frames ind chn) data))
			  (if (> (chans ind) 1)
			      (do ((i 0 (+ 1 i)))
				  ((= i (chans ind)))
				(if (not (= i chn))
				    (let ((data (channel->vct 0 (frames ind i) ind i)))
				      (if (not (vequal data (vct 0.0)))
					  (snd-display #__line__ ";scale[~A / ~A] empty: ~A" i chn data)))))))))))))
	      (list "2a.snd" "1a.snd" "4a.snd"))
	     (close-sound ind)))
	 (list 1 2 4))
	
	(let ((ind (open-sound "oboe.snd")))
	  (map-channel (lambda (y) #f))
	  (if (not (= (frames ind) 0)) (snd-display #__line__ ";map-channel #f frames: ~A" (frames ind)))
	  (if (equal? (edits ind) (list 0 0)) (snd-display #__line__ ";map-channel #f edits backed up"))
	  (undo 1 ind)
	  (if (= (frames ind) 0) (snd-display #__line__ ";map-channel #f frames after undo: ~A" (frames ind)))
	  (let ((tag (catch #t (lambda () (map-channel (lambda (y) "hiho"))) (lambda args (car args)))))
	    (if (not (eq? tag 'bad-type)) (snd-display #__line__ ";map-channel bad-type: ~A" tag)))
	  (let* ((ctr 0)
		 (tag (catch #t (lambda () (scan-channel (lambda (y) (set! ctr (+ 1 ctr)) (asdf)))) (lambda args (car args)))))
	    (if (not (= ctr 1)) (snd-display #__line__ ";scan-channel error exit: ~A" ctr))
	    (if (and (not (eq? tag 'unbound-variable)) 
		     (not (eq? tag 'syntax-error))
		     (not (eq? tag 'error)))
		(snd-display #__line__ ";scan-channel unbound: ~A" tag)))
	  (let ((val (scan-channel (lambda (y) #f)))) (if val (snd-display #__line__ ";scan-channel func #f: ~A" val)))
	  (let ((val (scan-channel (lambda (y) #f) 1234))) (if val (snd-display #__line__ ";scan-channel func #f with beg: ~A" val)))
	  (let ((val (scan-channel (lambda (y) #f) 1234 4321))) (if val (snd-display #__line__ ";scan-channel func #f with beg+dur: ~A" val)))
	  (revert-sound ind)
	  (let ((del (make-delay 1000))
		(len (frames)))
	    (clm-channel del 0 (frames) ind 0 0 2000)
	    (if (not (= (frames ind) (+ 2000 len)))
		(snd-display #__line__ ";clm-channel overlap length: ~A ~A" len (frames)))
	    (if (not (equal? (edit-tree) '((0 1 0 52827 1.0 0.0 0.0 0) (52828 -2 0 0 0.0 0.0 0.0 0))))
		(snd-display #__line__ ";clm-channel overlaps: ~A" (edit-tree)))
	    (let ((reader (make-sampler 0))
		  (preader (make-sampler 0 ind 0 1 0))
		  (happy #t))
	      (do ((i 0 (+ 1 i)))
		  ((or (not happy) (= i 1000)))
		(let ((val (reader)))
		  (if (fneq val 0.0)
		      (begin
			(snd-display #__line__ ";clm-channel overlap delayed: ~A: ~A" i val)
			(set! happy #f)))))
	      (do ((i 0 (+ 1 i)))
		  ((or (not happy) (= i len)))
		(let ((val0 (preader))
		      (val1 (reader)))
		  (if (fneq val0 val1)
		      (begin
			(snd-display #__line__ ";clm-channel overlap main: ~A: ~A ~A" (+ i 1000) val0 val1)
			(set! happy #f)))))
	      (do ((i 0 (+ 1 i)))
		  ((or (not happy) (= i 1000)))
		(if (fneq (reader) 0.0)
		    (begin
		      (snd-display #__line__ ";clm-channel overlap trailing garbage")
		      (set! happy #f))))))
	  (close-sound ind))
	
	(let* ((ind (open-sound "oboe.snd"))
	       (oldamp 0.0)
	       (oldloc 0)
	       (ctr 0))
	  (scan-channel (lambda (y)
			  (if (>= (abs y) oldamp) 
			      (begin
				(set! oldloc ctr)
				(set! oldamp (abs y))))
			  (set! ctr (+ 1 ctr))
			  #f))
	  (scale-by 10.0)
	  (scale-by 0.1)
	  (reverse-channel 0 #f ind 0 1)
	  (let ((amp 0.0)
		(loc 0)
		(ctr (- (frames) 1)))
	    (scan-channel (lambda (y)
			    (if (> (abs y) amp) 
				(begin
				  (set! amp (abs y))
				  (set! loc ctr)))
			    (set! ctr (- ctr 1))
			    #f))
	    ;; can't use maxamp here because it may be set by scaling process
	    (if (or (fneq oldamp (* .1 amp))
		    (not (= loc oldloc)))
		(snd-display #__line__ ";reverse edpos screwup: ~A at ~A,  ~A at ~A" oldamp oldloc amp loc)))
	  (undo)
	  (reverse-channel 0 #f ind 0 2)
	  (let ((amp 0.0)
		(loc 0)
		(ctr (- (frames) 1)))
	    (scan-channel (lambda (y)
			    (if (> (abs y) amp) 
				(begin
				  (set! amp (abs y))
				  (set! loc ctr)))
			    (set! ctr (- ctr 1))
			    #f))
	    ;; can't use maxamp here because it may be set by scaling process
	    (if (or (fneq oldamp amp)
		    (not (= loc oldloc)))
		(snd-display #__line__ ";reverse unscaled edpos screwup: ~A at ~A,  ~A at ~A" oldamp oldloc amp loc)))
	  
	  (close-sound ind))
	
	(if (mus-clipping) (set! (mus-clipping) #f))
	(if (clipping) (set! (clipping) #f))
	(let ((ind (new-sound "fmv.snd" mus-next mus-bfloat 22050 1 "edit trees"))
	      (vals (make-vct 100)))
	  (select-sound ind)
	  (select-channel 0)
	  (check-edit-tree '((0 0 0 0 0.0 0.0 0.0 1) (1 -2 0 0 0.0 0.0 0.0 0)) (make-vct 1) "initial new-sound")
	  (vct-fill! vals 1.0)
	  (set! (samples 0 100) vals)
	  (check-edit-tree '((0 1 0 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0)) vals "set first samps to one")
	  (scale-channel 0.5 10 20)
	  (do ((i 10 (+ 1 i)))
	      ((= i 30))
	    (vct-set! vals i 0.5))
	  (check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0)) 
			   vals "scale-channel 0.5 10 20")
	  (env-channel (make-env '(0 0 1 1) :length 11) 15 10)
	  (let ((e (make-env '(0 0 1 1) :length 11)))
	    (do ((i 15 (+ 1 i)))
		((= i 25))
	      (vct-set! vals i (* (vct-ref vals i) (env e)))))
	  (check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 14 0.5 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
			     (25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0)) 
			   vals "env-channel 15 10")
	  (normalize-channel 1.0)
	  (check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 14 0.5 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
			     (25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0)) 
			   vals "env-channel 15 10 a")
	  (select-all)
	  (if (fneq (selection-maxamp) 1.0)
	      (snd-display #__line__ ";selection-maxamp in checker: ~A" (selection-maxamp)))
	  (scale-selection-to 1.0)
	  (check-edit-tree '((0 1 0 9 1.0 0.0 0.0 0) (10 1 10 14 0.5 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1)
			     (25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0)) 
			   vals "env-channel 15 10 b")
	  (set! (selection-position) 5)
	  (set! (selection-frames) 10)
	  (scale-selection-to .5)
	  (do ((i 5 (+ 1 i)))
	      ((= i 15))
	    (vct-set! vals i (* (vct-ref vals i) 0.5)))
	  (check-edit-tree '((0 1 0 4 1.0 0.0 0.0 0) (5 1 5 9 0.5 0.0 0.0 0) (10 1 10 14 0.25 0.0 0.0 0) (15 1 15 24 0.5 0.0 0.1 1) 
			     (25 1 25 29 0.5 0.0 0.0 0) (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "scale-selection-to .5")
	  (set! (sample 20) .1)
	  (vct-set! vals 20 .1)
	  (check-edit-tree '((0 1 0 4 1.0 0.0 0.0 0) (5 1 5 9 0.5 0.0 0.0 0) (10 1 10 14 0.25 0.0 0.0 0) 
			     (15 1 15 19 0.5 0.0 0.1 1) (20 2 0 0 1.0 0.0 0.0 0)
			     (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 29 0.5 0.0 0.0 0) 
			     (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "set 20 .1")
	  (reverse-channel 5 10)
	  (do ((i 5 (+ 1 i))
	       (j 14 (- j 1)))
	      ((= i 10))
	    (let ((temp (vct-ref vals i)))
	      (vct-set! vals i (vct-ref vals j))
	      (vct-set! vals j temp)))
	  (check-edit-tree '((0 1 0 4 1.0 0.0 0.0 0) (5 3 0 9 1.0 0.0 0.0 0) 
			     (15 1 15 19 0.5 0.0 0.1 1) (20 2 0 0 1.0 0.0 0.0 0) 
			     (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 29 0.5 0.0 0.0 0) 
			     (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "reverse-channel 5 10")
	  (if (fneq (selection-maxamp) .5) (snd-display #__line__ ";selection-maxamp before: ~A" (selection-maxamp)))
	  (let ((mixvals (make-vct 10))
		(old-sample4 (sample 4))
		(old-sample5 (sample 5)))
	    (vct-fill! mixvals .1)
	    (let ((id (mix-vct mixvals 4)))
	      (do ((i 4 (+ 1 i))
		   (j 0 (+ 1 j)))
		  ((= i 14))
		(vct-set! vals i (+ (vct-ref vals i) (vct-ref mixvals j))))
	      (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0) 
				 (15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0) 
				 (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 29 0.5 0.0 0.0 0) 
				 (30 1 30 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			       vals (format #f "mix-vct (id: ~A (~A) [~A ~A] + .1 -> [~A ~A] [~A ~A]) 4 (.1)" 
					    id ind
					    old-sample4 old-sample5
					    (sample 4) (sample 5) 
					    (vct-ref vals 4) (vct-ref vals 5)))))
	  
					;     (list global-position data-number local-position local-end scaler ramp0 ramp1 type)
	  
	  (delete-samples 28 12)
	  (insert-silence 28 12)
	  (do ((i 28 (+ 1 i)))
	      ((= i 40))
	    (vct-set! vals i 0.0))
	  (let ((old-vals (vct-copy vals)))
	    (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1)
			       (14 3 9 9 1.0 0.0 0.0 0) (15 1 15 19 0.5 0.0 0.1 4) 
			       (20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.6 0.1 4) 
			       (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2) 
			       (40 1 40 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			     vals "delete/insert")
	    (if (fneq (selection-maxamp) .6) (snd-display #__line__ ";selection-maxamp after: ~A" (selection-maxamp)))
	    (set! (selection-position) 50)
	    (set! (selection-frames) 10)
	    (scale-selection-by .1)
	    (if (fneq (selection-maxamp) .1) (snd-display #__line__ ";re-selection-maxamp: ~A" (selection-maxamp)))
	    (do ((i 50 (+ 1 i)))
		((= i 60))
	      (vct-set! vals i .1))
	    (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0) 
			       (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2) 
			       (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.100000001490116 0.0 0.0 0) (60 1 60 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			     vals "scale-selection-by .1")
	    (env-channel (make-env '(0 0 1 1 2 0 3 0) :length 31 :base 0) 50 30)
	    (let ((e (make-env '(0 0 1 1 2 0 3 0) :length 31 :base 0)))
	      (do ((i 50 (+ 1 i)))
		  ((= i 80))
		(vct-set! vals i (* (vct-ref vals i) (env e)))))
	    (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0) 
			       (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
			       (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2) 
			       (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 79 0.0 0.0 0.0 2) (80 1 80 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			     vals "step env 30")
	    (undo-channel 2)
	    (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) 
			       (14 3 9 9 1.0 0.0 0.0 0) (15 1 15 19 0.5 0.0 0.1 4) 
			       (20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) 
			       (28 -1 0 11 0.0 0.0 0.0 2) (40 1 40 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			     old-vals "undo to delete/insert (over step env)"))
	  (redo-channel 2)
	  (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0) 
			     (15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0) 
			     (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
			     (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
			     (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 79 0.0 0.0 0.0 2) (80 1 80 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "redo past step env 30")
	  (set! (sample 75) -.5)
	  (vct-set! vals 75 -.5)
	  (let ((flt (make-one-zero 0.5 0.5))
		(flt1 (make-one-zero 0.5 0.5)))
	    (clm-channel flt 75 10)
	    (do ((i 75 (+ 1 i)))
		((= i 85))
	      (vct-set! vals i (one-zero flt1 (vct-ref vals i))))
	    (check-edit-tree '((0 1 0 3 1.0 0.0 0.0 0) (4 1 4 4 1.0 0.0 0.0 1) (5 3 0 8 1.0 0.0 0.0 1) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 0.0 0.1 4) (20 2 0 0 1.0 0.0 0.0 0) 
			       (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2) 
			       (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2) 
			       (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.0 0.0 0) (85 1 85 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			     vals "clm-channel 75 10"))
	  (map-channel (lambda (y) (* y .5)) 3 11)
	  (do ((i 3 (+ 1 i)))
	      ((= i 14))
	    (vct-set! vals i (* .5 (vct-ref vals i))))
	  (check-edit-tree '((0 1 0 2 1.0 0.0 0.0 0) (3 8 0 10 1.0 0.0 0.0 0) (14 7 10 11 1.0 0.0 0.0 0) 
			     (16 1 16 19 0.5 0.1 0.1 4) (20 2 0 0 1.0 0.0 0.0 0) 
			     (21 1 21 24 0.5 0.6 0.1 4) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2) 
			     (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2) 
			     (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.0 0.0 0) 
			     (85 1 85 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "map-channel 3 14")
	  (map-channel (let ((reader (make-sampler 50)))
			 (lambda (y)
			   (- y (reader))))
		       0 25)
	  (do ((i 0 (+ 1 i))
	       (j 50 (+ 1 j)))
	      ((= i 25))
	    (vct-set! vals i (- (vct-ref vals i) (vct-ref vals j))))
	  (check-edit-tree '((0 9 0 24 1.0 0.0 0.0 0) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 2)
			     (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 2) (60 1 60 60 0.0 0.0 0.0 2)
			     (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.0 0.0 0)
			     (85 1 85 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "back set via map-channel")
	  (set! (selection-position) 20)
	  (set! (selection-frames) 70)
	  (env-selection '(0 0 1 1))
	  (if (fneq (selection-maxamp ind 0) 1.0) (snd-display #__line__ ";selection-maxamp after env-selection: ~A" (selection-maxamp ind 0)))
	  (do ((i 20 (+ 1 i))
	       (x 0.0)
	       (incr (/ 1.0 69.0)))
	      ((= i 90))
	    (vct-set! vals i (* (vct-ref vals i) x))
	    (set! x (+ x incr)))
	  (check-edit-tree '((0 9 0 19 1.0 0.0 0.0 0) (20 9 20 24 1.0 0.0 0.014492753893137 4) 
			     (25 1 25 27 0.5 0.0724637657403946 0.014492753893137 4) (28 -1 0 11 0.0 0.0 0.0 2) 
			     (40 1 40 49 1.0 0.289855062961578 0.014492753893137 4) (50 1 50 59 0.0 0.0 0.0 2) 
			     (60 1 60 60 0.0 0.0 0.0 2) (61 1 61 70 1.0 0.594202876091003 0.014492753893137 4)
			     (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 1.0 0.797101438045502 0.014492753893137 4) 
			     (85 1 85 89 1.0 0.942028999328613 0.014492753893137 4) (90 1 90 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "env-selection")
	  (normalize-channel .5)
	  (vct-scale! vals .5)
	  (check-edit-tree '((0 9 0 19 0.5 0.0 0.0 0) (20 9 20 24 0.5 0.0 0.014492753893137 4) 
			     (25 1 25 27 0.25 0.0724637657403946 0.014492753893137 4) (28 -1 0 11 0.0 0.0 0.0 2) 
			     (40 1 40 49 0.5 0.289855062961578 0.014492753893137 4) (50 1 50 59 0.0 0.0 0.0 2) 
			     (60 1 60 60 0.0 0.0 0.0 2) (61 1 61 70 0.5 0.594202876091003 0.014492753893137 4) 
			     (71 1 71 74 0.0 0.0 0.0 2) (75 6 0 9 0.5 0.797101438045502 0.014492753893137 4) 
			     (85 1 85 89 0.5 0.942028999328613 0.014492753893137 4) (90 1 90 99 0.5 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "scale-to")
	  (if (fneq (selection-maxamp) .5) (snd-display #__line__ ";selection-maxamp after scale: ~A" (selection-maxamp)))
	  (delete-samples 0 100)
	  (insert-silence 0 100)
	  (vct-fill! vals 0.0)
	  (check-edit-tree '((0 -1 0 99 0.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "second set...")
	  
	  (set! (sample 50) .5)
	  (vct-set! vals 50 .5)
	  (check-edit-tree '((0 -1 0 49 0.0 0.0 0.0 2) (50 10 0 0 1.0 0.0 0.0 0) (51 -1 51 99 0.0 0.0 0.0 2) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "split silence")
	  (map-channel (lambda (y) 1.0) 0 25)
	  (do ((i 0 (+ 1 i)))
	      ((= i 25))
	    (vct-set! vals i 1.0))
	  (check-edit-tree '((0 11 0 24 1.0 0.0 0.0 0) (25 -1 25 49 0.0 0.0 0.0 2) (50 10 0 0 1.0 0.0 0.0 0) (51 -1 51 99 0.0 0.0 0.0 2) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "clobber silence start")
	  (map-channel (lambda (y) 1.0) 75 25)
	  (do ((i 75 (+ 1 i)))
	      ((= i 100))
	    (vct-set! vals i 1.0))
	  (check-edit-tree '((0 11 0 24 1.0 0.0 0.0 0) (25 -1 25 49 0.0 0.0 0.0 2) (50 10 0 0 1.0 0.0 0.0 0) 
			     (51 -1 51 74 0.0 0.0 0.0 2) (75 12 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "clobber silence end")
	  (scale-channel 0.0 0 100)
	  (vct-fill! vals 0.0)
	  (check-edit-tree '((0 0 0 99 0.0 0.0 0.0 1) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "scale all to 0.0")
	  (let ((e (make-env '(0 0 1 1) :length 101))
		(e1 (make-env '(0 0 1 1) :length 101)))
	    (map-channel (lambda (y) (env e)))
	    (do ((i 0 (+ 1 i)))
		((= i 100))
	      (vct-set! vals i (env e1))))
	  (check-edit-tree '((0 13 0 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "env start")
	  (set! (sample 50) -.5)
	  (vct-set! vals 50 -.5)
	  (check-edit-tree '((0 13 0 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 0.0 0.0 0) (51 13 51 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "split env segment")
	  (map-channel (lambda (y) 1.0) 0 25)
	  (do ((i 0 (+ 1 i)))
	      ((= i 25))
	    (vct-set! vals i 1.0))
	  (check-edit-tree '((0 15 0 24 1.0 0.0 0.0 0) (25 13 25 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 0.0 0.0 0) (51 13 51 99 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "clobber env start")
	  (map-channel (lambda (y) 1.0) 75 25)
	  (do ((i 75 (+ 1 i)))
	      ((= i 100))
	    (vct-set! vals i 1.0))
	  (check-edit-tree '((0 15 0 24 1.0 0.0 0.0 0) (25 13 25 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 0.0 0.0 0) 
			     (51 13 51 74 1.0 0.0 0.0 0) (75 16 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "clobber env end")
	  ;; this can't be expected to work anymore -- internal backup can change edit tree bounds
					;	  (save-edit-history "hiho.scm")
					;	  (revert-sound ind)
					;	  (set! sfile ind)
					;	  (load (string-append cwd "hiho.scm"))
					;	  (check-edit-tree '((0 14 0 24 1.0 0.0 0.0 0) (25 12 25 49 1.0 0.0 0.0 0) (50 13 0 0 1.0 0.0 0.0 0) (51 12 51 74 1.0 0.0 0.0 0) (75 15 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
					;			   vals "reload edits")
					;	  (if (not (equal? (edits) (list 27 0))) (snd-display #__line__ ";edits after reload: ~A" (edits)))
					;	  (delete-file "hiho.scm")
	  
	  (env-channel (make-env '(0 1 1 0 2 1) :length 20) 50 20)
	  (let ((e (make-env '(0 1 1 0 2 1) :length 20)))
	    (do ((i 50 (+ 1 i)))
		((= i 70))
	      (vct-set! vals i (* (env e) (vct-ref vals i)))))
	  (check-edit-tree '((0 15 0 24 1.0 0.0 0.0 0) (25 13 25 49 1.0 0.0 0.0 0) (50 14 0 0 1.0 1.0 -0.100000001490116 4) 
			     (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 4) (60 13 60 69 1.0 0.0 0.111111111938953 4) 
			     (70 13 70 74 1.0 0.0 0.0 0) (75 16 0 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "env on env")
	  (env-channel (make-env '(0 1 1 0 2 1) :length 80) 10 80)
	  (let ((e (make-env '(0 1 1 0 2 1) :length 80)))
	    (do ((i 10 (+ 1 i)))
		((= i 90))
	      (vct-set! vals i (* (env e) (vct-ref vals i)))))
	  (check-edit-tree '((0 15 0 9 1.0 0.0 0.0 0) (10 15 10 24 1.0 1.0 -0.025000000372529 4) (25 13 25 49 1.0 0.625 -0.025000000372529 4) 
			     (50 14 0 0 1.0 1.0 -0.100000001490116 6) (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 6) 
			     (60 13 60 69 1.0 0.0 0.111111111938953 6) (70 13 70 74 1.0 0.512820541858673 0.0256410259753466 4) 
			     (75 16 0 14 1.0 0.64102566242218 0.0256410259753466 4) (90 16 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "env on env 2")
	  (env-channel (make-env '(0 1 1 0 2 1) :length 20) 50 20)
	  (let ((e (make-env '(0 1 1 0 2 1) :length 20)))
	    (do ((i 50 (+ 1 i)))
		((= i 70))
	      (vct-set! vals i (* (env e) (vct-ref vals i)))))
	  (check-edit-tree '((0 15 0 9 1.0 0.0 0.0 0) (10 15 10 24 1.0 1.0 -0.025000000372529 4) (25 13 25 49 1.0 0.625 -0.025000000372529 4) 
			     (50 14 0 0 1.0 1.0 -0.100000001490116 10) (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 10) 
			     (60 13 60 69 1.0 0.0 0.111111111938953 10) (70 13 70 74 1.0 0.512820541858673 0.0256410259753466 4)
			     (75 16 0 14 1.0 0.64102566242218 0.0256410259753466 4) (90 16 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "env on env 3")
	  (delete-samples 10 20)
	  (insert-silence 10 20)
	  (do ((i 10 (+ 1 i)))
	      ((= i 30))
	    (vct-set! vals i 0.0))
	  (check-edit-tree '((0 15 0 9 1.0 0.0 0.0 0) (10 -1 0 19 0.0 0.0 0.0 2) (30 13 30 49 1.0 0.5 -0.025000000372529 4) 
			     (50 14 0 0 1.0 1.0 -0.100000001490116 10) (51 13 51 59 1.0 0.899999976158142 -0.100000001490116 10) 
			     (60 13 60 69 1.0 0.0 0.111111111938953 10) (70 13 70 74 1.0 0.512820541858673 0.0256410259753466 4) 
			     (75 16 0 14 1.0 0.64102566242218 0.0256410259753466 4) (90 16 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 0))
			   vals "env preclobbered")
	  (close-sound ind))
	
	(for-each
	 (lambda (dur)
	   (let* ((i1 (new-sound))
		  (v (vct-fill! (make-vct dur) 1.0)))
	     (define (check-env name r e)
	       (let ((happy #t))
		 (do ((i 0 (+ 1 i)))
		     ((or (not happy) (= i dur))
		      happy)
		   (let ((rv (r))
			 (ev (e)))
		     (if (fneq rv ev) 
			 (begin
			   (snd-display #__line__ ";~A env check [~A]: ~A ~A" name i rv ev)
			   (set! happy #f)))))))
	     (vct->channel v)
	     (env-sound '(0 0 1 1))
	     (check-env 'ramp (make-sampler 0) (make-env '(0 0 1 1) :length dur))
	     (reverse-channel)
	     (check-env 'rev-ramp (make-sampler 0) (make-env '(0 1 1 0) :length dur))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0))
	     (check-env 'ramp (make-sampler 0) (make-env '(0 0 1 1 2 0) :length dur))
	     (let ((cur-read (make-sampler 0)))
	       (reverse-channel)
	       (let ((rev-read (make-sampler (- dur 1) i1 0 -1)))
		 (check-env 'rev-pyr cur-read rev-read)))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0 3 1))
	     (check-env '3-ramp (make-sampler 0) (make-env '(0 0 1 1 2 0 3 1) :length dur))
	     (let ((cur-read (make-sampler 0)))
	       (reverse-channel)
	       (let ((rev-read (make-sampler (- dur 1) i1 0 -1)))
		 (check-env 'rev-pyr cur-read rev-read)))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 1 3 0))
	     (check-env 'sqoff (make-sampler 0) (make-env '(0 0 1 1 2 1 3 0) :length dur))
	     (undo 1)
	     (env-sound '(0 0 1 .5 2 .5 3 0))
	     (check-env '5sqoff (make-sampler 0) (make-env '(0 0 1 .5 2 .5 3 0) :length dur))
	     (undo 1)
	     (scale-channel .5)
	     (env-sound '(0 0 1 1))
	     (check-env 'scl-ramp (make-sampler 0) (make-env '(0 0 1 1) :length dur :scaler .5))
	     (reverse-channel)
	     (check-env 'scl-rev-ramp (make-sampler 0) (make-env '(0 1 1 0) :length dur :scaler .5))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0))
	     (check-env 'scl-3-ramp (make-sampler 0) (make-env '(0 0 1 1 2 0) :length dur :scaler .5))
	     (let ((cur-read (make-sampler 0)))
	       (reverse-channel)
	       (let ((rev-read (make-sampler (- dur 1) i1 0 -1)))
		 (check-env 'scl-rev-pyr cur-read rev-read)))
	     (undo 3)
	     (if (= dur 10000)
		 (begin
		   (for-each 
		    (lambda (beg local-dur)
		      (env-sound '(0 0 1 1 2 0))
		      (scale-channel .5 beg local-dur)
		      (check-env 'env+scl 
				 (make-sampler 0)
				 (let ((e (make-env '(0 0 1 1 2 0) :length dur))
				       (ctr 0))
				   (lambda ()
				     (let ((val (env e)))
				       (set! ctr (+ 1 ctr))
				       (if (and (> ctr beg)
						(<= ctr (+ beg local-dur)))
					   (* val .5)
					   val)))))
		      (undo 2))
		    (list 0    0    1000 1000 4000 5000 6000 5000)
		    (list 1000 6000 1000 4000 2000 1000 1000 5000))))
	     (if (= dur 10000)
		 (begin
		   (for-each 
		    (lambda (env-beg env-dur scl-beg scl-dur)
		      (env-channel '(0 0 1 1 2 1 3 0) env-beg env-dur)
		      (scale-channel .5 scl-beg scl-dur)
		      (check-env 'env+scl-partial
				 (make-sampler 0)
				 (let ((e (make-env '(0 0 1 1 2 1 3 0) :length env-dur))
				       (ctr 0))
				   (lambda ()
				     (let ((val 1.0))
				       (set! ctr (+ 1 ctr))
				       (if (and (> ctr env-beg)
						(<= ctr (+ env-beg env-dur)))
					   (set! val (* val (env e))))
				       (if (and (> ctr scl-beg)
						(<= ctr (+ scl-beg scl-dur)))
					   (set! val (* val 0.5)))
				       val))))
		      (undo 2))
		    (list 0    0     1000 1000 4000 5000 6000 5000)
		    (list 1000 6000  1000 4000 2000 1000 1000 5000)
		    (list 500  0     0    2000 5000 4000 0    8000)
		    (list 200  10000 1500 1000 500  2000 2000 2000))))
	     (env-sound '(0 0 1 1))
	     (env-sound '(0 0 1 1))
	     (check-env 'unenv-ramp 
			(make-sampler 0) 
			(let ((e (make-env '(0 0 1 1) :length dur)))
			  (lambda ()
			    (let ((val (env e)))
			      (* val val)))))
	     (undo 2)
	     (env-sound '(0 0 1 1))
	     (let ((v1 (vct-fill! (make-vct 3) 1.0)))
	       (vct->channel v1 3 3)
	       (let ((vals (channel->vct 0 10)))
		 (if (not (vequal vals (vct 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66  dur) (/ 7.77  dur) (/ 8.88  dur) (/ 10.0 dur))))
		     (snd-display #__line__ "; 1 vals: ~A" vals))))
	     (undo 2)
	     (env-sound '(0 0 1 1))
	     (let ((v1 (vct-fill! (make-vct 3) 1.0)))
	       (delete-samples 3 3)
	       (insert-samples 3 3 v1)
	       (let ((vals (channel->vct 0 10)))
		 (if (not (vequal vals (vct 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66  dur) (/ 7.77  dur) (/ 8.88  dur) (/ 10.0 dur))))
		     (snd-display #__line__ "; 2 vals: ~A" vals))))
	     (undo 3)
	     (env-sound '(0 0 1 1))
	     (let ((v1 (vct-fill! (make-vct 3) 1.0)))
	       (insert-samples 3 3 v1)
	       (delete-samples 3 3))
	     (check-env '5-ramp (make-sampler 0) (make-env '(0 0 1 1) :length dur))
	     (undo 3)
	     (env-sound '(0 0 1 1 2 0))
	     (let ((v1 (vct-fill! (make-vct 3) 1.0)))
	       (if (= dur 10)
		   (begin
		     (vct->channel v1 3 3)
		     (let ((vals (channel->vct 0 10)))
		       (if (not (vequal vals (vct 0.0 .2 .4 1 1 1 .75 .5 .25 0)))
			   (snd-display #__line__ "; 4 vals (~A): ~A" dur vals))))
		   (begin
		     (vct-fill! v1 0.0)
		     (vct->channel v1 4998 3)
		     (let ((vals (channel->vct 4995 10)))
		       (if (not (vequal vals (vct 0.999 0.999 1.000 0.000 0.000 0.000 1.000 0.999 0.999 0.999)))
			   (snd-display #__line__ "; 4 vals big: ~A" vals))))))
	     (undo 2)
	     (if (= dur 10)
		 (begin
		   (env-sound '(0 0 1 1 2 0))
		   (let ((v1 (vct-fill! (make-vct 3) 1.0)))
		     (delete-samples 3 3)
		     (insert-samples 3 3 v1)
		     (let ((vals (channel->vct 0 10)))
		       (if (not (vequal vals (vct 0.0 .2 .4 1 1 1 .75 .5 .25 0)))
			   (snd-display #__line__ "; 2 vals: ~A" vals))))
		   (undo 3)
		   (env-sound '(0 0 1 1 2 0))
		   (let ((v1 (vct-fill! (make-vct 3) 1.0)))
		     (vct->channel v1 0 3)
		     (let ((vals (channel->vct 0 10)))
		       (if (not (vequal vals (vct 1.000 1.000 1.000 0.600 0.800 1.000 0.750 0.500 0.250 0.000)))
			   (snd-display #__line__ "; 4 vals: ~A" vals))))
		   (undo 2)
		   (env-sound '(0 0 1 1 2 0))
		   (let ((v1 (vct-fill! (make-vct 3) 1.0)))
		     (vct->channel v1 7 3)
		     (let ((vals (channel->vct 0 10)))
		       (if (not (vequal vals (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.750 1.000 1.000 1.000)))
			   (snd-display #__line__ "; 5 vals: ~A" vals))))
		   (undo 2)))
	     (let ((file (file-name i1)))
	       (close-sound i1)
	       (if (file-exists? file) (delete-file file)))
	     ))
	 (list 10 10000))
	
	(let ((ind (new-sound "fmv.snd" mus-next mus-bfloat 22050 1 "envd edit trees"))
	      (vals (make-vct 10000)))
	  (select-sound ind)
	  (select-channel 0)
	  (check-edit-tree '((0 0 0 0 0.0 0.0 0.0 1) (1 -2 0 0 0.0 0.0 0.0 0)) (make-vct 1) "initial new-sound")
	  (vct-fill! vals 1.0)
	  (set! (samples 0 10000) vals)
	  (check-edit-tree '((0 1 0 9999 1.0 0.0 0.0 0) (10000 -2 0 0 0.0 0.0 0.0 0)) vals "envd set first samps to one")
	  (env-sound '(0 0 1 1))
	  (let ((e (make-env '(0 0 1 1) :length 10000)))
	    (vct-map! vals (lambda () (e))))
	  (check-edit-tree '((0 1 0 9999 1.0 0.0 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
			   vals "env frag '(0 0 1 1)")
	  (delete-samples 1000 1000)
	  (let ((v1 (make-vct 9000)))
	    (do ((i 0 (+ 1 i)))
		((= i 1000))
	      (vct-set! v1 i (vct-ref vals i)))
	    (do ((i 1000 (+ 1 i))
		 (j 2000 (+ 1 j)))
		((= i 9000))
	      (vct-set! v1 i (vct-ref vals j)))
	    (check-edit-tree '((0 1 0 999 1.0 0.0 1.00010001915507e-4 4) (1000 1 2000 9999 1.0 0.200020000338554 1.00010001915507e-4 4) (9000 -2 0 0 0.0 0.0 0.0 0))
			     v1 "env frag del"))
	  (undo 1)
	  (delete-samples 9000 1000)
	  (insert-samples 3000 1000 (make-vct 1000))
	  (do ((i 9999 (- i 1)))
	      ((< i 4000))
	    (vct-set! vals i (vct-ref vals (- i 1000))))
	  (do ((i 3000 (+ 1 i)))
	      ((= i 4000))
	    (vct-set! vals i 0.0))
	  (check-edit-tree '((0 1 0 2999 1.0 0.0 1.00010001915507e-4 4) (3000 2 0 999 1.0 0.0 0.0 0) 
			     (4000 1 3000 8999 1.0 0.300029993057251 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
			   vals "envd ins/del")
	  (delete-samples 0 1000)
	  (insert-samples 0 1000 (make-vct 1000))
	  (do ((i 0 (+ 1 i)))
	      ((= i 1000))
	    (vct-set! vals i 0.0))
	  (check-edit-tree '((0 3 0 999 1.0 0.0 0.0 0) (1000 1 1000 2999 1.0 0.100010000169277 1.00010001915507e-4 4) 
			     (3000 2 0 999 1.0 0.0 0.0 0) (4000 1 3000 8999 1.0 0.300029993057251 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
			   vals "envd predel")
	  (scale-by 0.5)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10000))
	    (vct-set! vals i (* (vct-ref vals i) 0.5)))
	  (check-edit-tree '((0 3 0 999 0.5 0.0 0.0 0) (1000 1 1000 2999 0.5 0.100010000169277 1.00010001915507e-4 4) 
			     (3000 2 0 999 0.5 0.0 0.0 0) (4000 1 3000 8999 0.5 0.300029993057251 1.00010001915507e-4 4) (10000 -2 0 0 0.0 0.0 0.0 0))
			   vals "envd scl")
	  (reverse-channel)
	  (do ((i 0 (+ 1 i))
	       (j 9999 (- j 1)))
	      ((= i 5000))
	    (let ((temp (vct-ref vals i)))
	      (vct-set! vals i (vct-ref vals j))
	      (vct-set! vals j temp)))
	  (check-edit-tree '((0 4 0 9999 1.0 0.0 0.0 0) (10000 -2 0 0 0.0 0.0 0.0 0))
			   vals "envd rev")
	  
	  (revert-sound ind)
	  (set! vals (make-vct 100000))
	  (vct-fill! vals 1.0)
	  (vct->channel vals 0 100000)
	  (env-channel (make-env '(0 0 1 1 2 0) :length 10000) 30000 10000)
	  (let ((e (make-env '(0 0 1 1 2 0) :length 10000)))
	    (do ((i 30000 (+ 1 i)))
		((= i 40000))
	      (vct-set! vals i (env e))))
	  (check-edit-tree '((0 1 0 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 4)
			     (35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 4) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
			   vals "partial env")
	  (scale-channel .5 10000 10000)
	  (env-channel (make-env '(0 0 1 1 2 0) :length 10000) 30000 10000) ; env over env
	  (let ((e (make-env '(0 0 1 1 2 0) :length 10000)))
	    (do ((i 30000 (+ 1 i)))
		((= i 40000))
	      (vct-set! vals i (* (vct-ref vals i) (env e)))))
	  (do ((i 10000 (+ 1 i)))
	      ((= i 20000))
	    (vct-set! vals i (* (vct-ref vals i) 0.5)))
	  (check-edit-tree '((0 1 0 9999 1.0 0.0 0.0 0) (10000 1 10000 19999 0.5 0.0 0.0 0) (20000 1 20000 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 6) (35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
			   vals "env over env")
	  (env-channel (make-env '(0 0 1 1 2 0) :length 10000) 5000 10000) ; env over scl
	  (let ((e (make-env '(0 0 1 1 2 0) :length 10000)))
	    (do ((i 5000 (+ 1 i)))
		((= i 15000))
	      (vct-set! vals i (* (vct-ref vals i) (env e)))))
	  (check-edit-tree '((0 1 0 4999 1.0 0.0 0.0 0) (5000 1 5000 9999 1.0 0.0 1.99999994947575e-4 4) (10000 1 10000 14999 0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 0.5 0.0 0.0 0) (20000 1 20000 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 6) (35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
			   vals "env over scl")
	  (ramp-channel .5 -.5 25000 1000)
	  (let ((e (make-env '(0 .5 1 -.5) :length 1000)))
	    (do ((i 25000 (+ 1 i)))
		((= i 26000))
	      (vct-set! vals i (* (vct-ref vals i) (env e)))))
	  (check-edit-tree '((0 1 0 4999 1.0 0.0 0.0 0) (5000 1 5000 9999 1.0 0.0 1.99999994947575e-4 4) (10000 1 10000 14999 0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 0.5 0.0 0.0 0) (20000 1 20000 24999 1.0 0.0 0.0 0) (25000 1 25000 25999 1.0 0.5 -0.00100100098643452 4) (26000 1 26000 29999 1.0 0.0 0.0 0) (30000 1 30000 34999 1.0 0.0 1.99999994947575e-4 6) (35000 1 35000 39999 1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
			   vals "ramp")
	  (scale-by -1.0)
	  (vct-scale! vals -1.0)
	  (check-edit-tree '((0 1 0 4999 -1.0 0.0 0.0 0) (5000 1 5000 9999 -1.0 0.0 1.99999994947575e-4 4) (10000 1 10000 14999 -0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 -0.5 0.0 0.0 0) (20000 1 20000 24999 -1.0 0.0 0.0 0) (25000 1 25000 25999 -1.0 0.5 -0.00100100098643452 4) (26000 1 26000 29999 -1.0 0.0 0.0 0) (30000 1 30000 34999 -1.0 0.0 1.99999994947575e-4 6) (35000 1 35000 39999 -1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 99999 -1.0 0.0 0.0 0) (100000 -2 0 0 -0.0 0.0 0.0 0))
			   vals "invert")
	  (let ((reader (make-sampler 0 ind 0 1 (- (edit-position) 1))))
	    (map-channel (lambda (y)
			   (+ (reader) y)))
	    (check-edit-tree '((0 2 0 99999 1.0 0.0 0.0 0) (100000 -2 0 0 0.0 0.0 0.0 0))
			     (make-vct 100000) "invert and add")
	    (if (fneq (maxamp) 0.0) (snd-display #__line__ ";invert-and-add maxamp: ~A" (maxamp))))
	  
	  (undo 1)
	  (ramp-channel -1.0 1.0 50000 30000)
	  (let ((e (make-env '(0 -1.0 1 1.0) :length 30000)))
	    (do ((i 50000 (+ 1 i)))
		((= i 80000))
	      (vct-set! vals i (* (vct-ref vals i) (env e)))))
	  (check-edit-tree '((0 1 0 4999 -1.0 0.0 0.0 0) (5000 1 5000 9999 -1.0 0.0 1.99999994947575e-4 4) (10000 1 10000 14999 -0.5 1.0 -2.00040012714453e-4 4) (15000 1 15000 19999 -0.5 0.0 0.0 0) (20000 1 20000 24999 -1.0 0.0 0.0 0) (25000 1 25000 25999 -1.0 0.5 -0.00100100098643452 4) (26000 1 26000 29999 -1.0 0.0 0.0 0) (30000 1 30000 34999 -1.0 0.0 1.99999994947575e-4 6) (35000 1 35000 39999 -1.0 1.0 -2.00040012714453e-4 6) (40000 1 40000 49999 -1.0 0.0 0.0 0) (50000 1 50000 79999 -1.0 -1.0 6.66688865749165e-5 4) (80000 1 80000 99999 -1.0 0.0 0.0 0) (100000 -2 0 0 -0.0 0.0 0.0 0))
			   vals "ramp")
	  (env-sound '(0 0 1 1))
	  (reverse-channel)
	  (delete-samples 1 99999)
	  (if (fneq (sample 0) -1.0) (snd-display #__line__ ";sample at end: ~A" (sample 0)))
	  (if (not (= (frames) 1)) (snd-display #__line__ ";length at end: ~A" (frames)))
	  (check-edit-tree '((0 2 0 0 1.0 0.0 0.0 0) (1 -2 0 0 0.0 0.0 0.0 0))
			   (vct-fill! (make-vct 1) -1.0) "at end")
	  (close-sound ind))
	
	;; a special case that catches the round-off problem
	(let ((ind (open-sound "oboe.snd")))
	  (env-channel '(0.0 0.984011617147162 0.644050741979388 0.110976689002195 1.17272046995914 0.384709990674106 
			     1.25650287720397 0.551452668245628 1.4389507801877 0.843827758574229 2.16614272265275 0.226832341237953))
	  (let ((val (sample 50827)))
	    (if (or (not (number? val))
		    (fneq val 0.0))
		(snd-display #__line__ ";round-off env: ~A" val)))
	  (check-edit-tree '((0 0 0 15111 1.0 0.984011590480804 -5.77709688514005e-5 4) (15112 0 15112 27516 1.0 0.110976688563824 2.20663678192068e-5 4) (27517 0 27517 29482 1.0 0.384709984064102 8.4813182184007e-5 4) (29483 0 29483 33763 1.0 0.551452696323395 6.82959798723459e-5 4) (33764 0 33764 50827 1.0 0.843827784061432 -3.61598467861768e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "round-off test")
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0))
	  (env-channel '(0 0 1 1 2 0))
	  (scale-channel .5 1000 1000)
	  (let ((val (sample 800)))
	    (if (fneq val .0314)
		(snd-display #__line__ ";scl on env trouble: ~A" val)))
	  (check-edit-tree '((0 1 0 999 1.0 0.0 3.93483896914404e-5 4) (1000 1 1000 1999 0.5 0.0393483899533749 3.93483896914404e-5 4) (2000 1 2000 25413 1.0 0.0786967799067497 3.93483896914404e-5 4) (25414 1 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "scl on env")
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0))
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (let ((val (sample 20000)))
	    (if (fneq val (expt (/ 20000.0 50828) 3))
		(snd-display #__line__ ";ramp-channels piled up: ~A" val)))
	  (check-edit-tree '((0 1 0 50827 1.0 0.0 1.96745822904631e-5 10) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "ramp upon ramp")
	  (revert-sound ind)
	  
	  (map-channel (lambda (y) 1.0))
	  (ramp-channel 0.5 1.0) ; val = 0.5 + (20000/50828)*0.5
	  (ramp-channel 0.0 0.5) ; val * (20000/50828)*0.5
	  (ramp-channel 0.1 0.4) ; val * (0.1 + (20000/50828)*0.3)
	  (let* ((val (sample 20000))
		 (ratio (/ 20000.0 50828))
		 (val1 (+ 0.5 (* 0.5 ratio)))
		 (val2 (* val1 (* 0.5 ratio)))
		 (val3 (* val2 (+ 0.1 (* ratio 0.3)))))
	    (if (fneq val val3)
		(snd-display #__line__ ";ramp-channels piled up (2): ~A ~A" val val3)))
	  
	  (revert-sound ind)
	  (env-channel '(0 0 1 1 2 0))
	  (check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 0")
	  (scale-channel .5 0 1000)
	  (check-edit-tree '((0 0 0 999 0.5 0.0 3.93483896914404e-5 4) (1000 0 1000 25413 1.0 0.0393483899533749 3.93483896914404e-5 4) (25414 0 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 1")
	  (undo)
	  (scale-channel .5 1000 1000)
	  (check-edit-tree '((0 0 0 999 1.0 0.0 3.93483896914404e-5 4) (1000 0 1000 1999 0.5 0.0393483899533749 3.93483896914404e-5 4) (2000 0 2000 25413 1.0 0.0786967799067497 3.93483896914404e-5 4) (25414 0 25414 50827 1.0 1.0 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 2")
	  (undo)
	  (scale-channel .5 0 25415)
	  (check-edit-tree '((0 0 0 25413 0.5 0.0 3.93483896914404e-5 4) (25414 0 25414 25414 0.5 1.0 -3.93499394704122e-5 4) (25415 0 25415 50827 1.0 0.999960660934448 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 3")
	  (undo)
	  (scale-channel .5 20000 10000)
	  (check-edit-tree '((0 0 0 19999 1.0 0.0 3.93483896914404e-5 4) (20000 0 20000 25413 0.5 0.786967813968658 3.93483896914404e-5 4) (25414 0 25414 29999 0.5 1.0 -3.93499394704122e-5 4) (30000 0 30000 50827 1.0 0.819541156291962 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 4")
	  (undo)
	  (scale-channel .5 30000 1000)
	  (check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 29999 1.0 1.0 -3.93499394704122e-5 4) (30000 0 30000 30999 0.5 0.819541156291962 -3.93499394704122e-5 4) (31000 0 31000 50827 1.0 0.780191242694855 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 5")
	  (undo)
	  (scale-channel .5 25415 1000)
	  (check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 25414 1.0 1.0 -3.93499394704122e-5 4) (25415 0 25415 26414 0.5 0.999960660934448 -3.93499394704122e-5 4) (26415 0 26415 50827 1.0 0.960610687732697 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 6")
	  (undo)
	  (scale-channel .5 40000 10828)
	  (check-edit-tree '((0 0 0 25413 1.0 0.0 3.93483896914404e-5 4) (25414 0 25414 39999 1.0 1.0 -3.93499394704122e-5 4) (40000 0 40000 50827 0.5 0.426041781902313 -3.93499394704122e-5 4) (50828 -2 0 0 0.0 0.0 0.0 0))
			   #f "env+scl 7")
	  
	  (close-sound ind))
	
	(for-each
	 (lambda (dur)
	   (let* ((i1 (new-sound))
		  (i2 (new-sound "fmv1.snd" mus-next mus-bfloat 44100 2))
		  (v (vct-fill! (make-vct dur) 1.0)))
	     (define (check-env name r e)
	       (let ((happy #t))
		 (do ((i 0 (+ 1 i)))
		     ((or (not happy) (= i dur))
		      happy)
		   (let ((rv (r))
			 (ev (e)))
		     (if (fneq rv ev) 
			 (begin
			   (snd-display #__line__ ";~A env check [~A]: ~A ~A" name i rv ev)
			   (throw 'uhoh2)
			   (set! happy #f)))))))
	     (define (check-envs name r-maker e-maker)
	       (check-env (format #f "~A-1-0" name) (r-maker i1 0) (e-maker i1 0))
	       (check-env (format #f "~A-2-0" name) (r-maker i2 0) (e-maker i2 0))
	       (check-env (format #f "~A-2-1" name) (r-maker i2 1) (e-maker i2 1)))
	     (vct->channel v 0 dur i1)
	     (vct->channel v 0 dur i2 0)
	     (vct->channel v 0 dur i2 1)
	     (set! (sync i1) 1)
	     (set! (sync i2) 1)
	     (env-sound '(0 0 1 1))
	     (check-envs 'ramps (lambda (s c) (make-sampler 0 s c)) (lambda (s c) (make-env '(0 0 1 1) :length dur)))
	     (reverse-sound)
	     (check-envs 'rev-ramps (lambda (s c) (make-sampler 0 s c)) (lambda (s c) (make-env '(0 1 1 0) :length dur)))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0))
	     (check-envs 'ramps (lambda (s c) (make-sampler 0 s c)) (lambda (s c) (make-env '(0 0 1 1 2 0) :length dur)))
	     (undo 1)
	     (scale-by .5)
	     (env-sound '(0 0 1 1))
	     (check-envs 'scl-ramps (lambda (s c) (make-sampler 0 s c)) (lambda (s c) (make-env '(0 0 1 1) :length dur :scaler .5)))
	     (reverse-sound)
	     (check-envs 'scl-rev-ramps (lambda (s c) (make-sampler 0)) (lambda (s c) (make-env '(0 1 1 0) :length dur :scaler .5)))
	     (undo 3)
	     (env-sound '(0 0 1 1))
	     (env-sound '(0 0 1 1))
	     (check-envs 'unenv-ramps
			 (lambda (s c)
			   (make-sampler 0 s c))
			 (lambda (s c)
			   (let ((e (make-env '(0 0 1 1) :length dur)))
			     (lambda ()
			       (let ((val (env e)))
				 (* val val))))))
	     (undo 2)
	     (env-sound '(0 0 1 1))
	     (let ((v1 (vct-fill! (make-vct 3) 1.0)))
	       (vct->channel v1 3 3 i1)
	       (vct->channel v1 3 3 i2 0)
	       (vct->channel v1 3 3 i2 1)
	       (let ((vals (channel->vct 0 10 i1 0)))
		 (if (not (vequal vals (vct 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66  dur) (/ 7.77  dur) (/ 8.88  dur) (/ 10.0 dur))))
		     (snd-display #__line__ "; 1 0 vals: ~A" vals))
		 (set! vals (channel->vct 0 10 i2 0))
		 (if (not (vequal vals (vct 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66  dur) (/ 7.77  dur) (/ 8.88  dur) (/ 10.0 dur))))
		     (snd-display #__line__ "; 2 0 vals: ~A" vals))
		 (set! vals (channel->vct 0 10 i2 1))
		 (if (not (vequal vals (vct 0.0 (/ 1.111 dur) (/ 2.222 dur) 1 1 1 (/ 6.66  dur) (/ 7.77  dur) (/ 8.88  dur) (/ 10.0 dur))))
		     (snd-display #__line__ "; 2 1 vals: ~A" vals))))
	     (let ((file (file-name i1)))
	       (close-sound i1)
	       (if (file-exists? file) (delete-file file)))
	     (close-sound i2)
	     ))
	 (list 10 10000))
	
	(if (hook-empty? initial-graph-hook)
	    (begin
	      (reset-hook! update-hook)
	      (reset-hook! close-hook)
	      (reset-hook! exit-hook)))
	
	(let ((data (map
		     (lambda (sound)
		       (if (file-exists? sound)
			   (let ((ind (view-sound sound))
				 (old-opt (optimization)))
			     (set! (squelch-update ind) #t)
			     (set! (optimization) max-optimization)
			     
			     (let ((times (map
					   (lambda (function)
					     (let ((start (real-time)))
					       (function)
					       (revert-sound)
					       (- (real-time) start)))
					   (list (lambda () (scale-channel 2.0))
						 (lambda () (reverse-channel))
						 (lambda () (env-channel '(0 0 1 1)))
						 (lambda () (map-channel (lambda (y) (* y 2))))
						 (lambda () (ptree-channel (lambda (y) (+ y .2)) #f #f ind 0 #f #t))
						 (lambda () (scan-channel (lambda (y) (> y 1.0))))
						 (lambda () (pad-channel 0 2000))
						 (lambda () (vct->channel (vct-fill! (make-vct 1000) .1) 0 1000))
						 (lambda () (clm-channel (make-two-zero .5 .5)))
						 (lambda () (mix "pistol.snd" 12345))
						 (lambda () (src-channel 2.0))
						 (lambda () (delete-samples 10 200))
						 ))))
			       (set! (optimization) old-opt)
			       (close-sound ind)
			       times))))
		     (let ((away (string-append home-dir "/test/sound/away.snd")))
		       (if (file-exists? away)
			   (list "1a.snd" "oboe.snd" "storm.snd" away)
			   (list "1a.snd" "oboe.snd" "storm.snd" "lola.snd"))))))
	  
	  (snd-display #__line__ ";         scl    rev    env    map    ptree   scn   pad    wrt    clm    mix    src    del")
	  (snd-display #__line__ ";1a:   ~{~A ~}" (map (lambda (a) (if (< a .005) "   0.0" (format #f "~6,2F" a))) (car data)))
	  (snd-display #__line__ ";oboe: ~{~A ~}" (map (lambda (a) (if (< a .005) "   0.0" (format #f "~6,2F" a))) (cdar data)))
	  (snd-display #__line__ ";storm:~{~A ~}" (map (lambda (a) (if (< a .005) "   0.0" (format #f "~6,2F" a))) (caddr data)))
	  (if (list-p (cadddr data))
	      (snd-display #__line__ ";away: ~{~A ~}" (map (lambda (a) (if (< a .005) "   0.0" (format #f "~6,2F" a))) (cadddr data))))
	  )
	
	(if (and all-args with-big-file)
	    (let ((ind (view-sound big-file-name))
		  (old-opt (optimization)))
	      (catch #t
		     (lambda ()
		       (set! (squelch-update ind) #t)
		       (set! (optimization) max-optimization)
		       (set! (selection-creates-region) #f)
		       (let ((times (map
				     (lambda (function)
				       (let ((start (real-time)))
					 (function)
					 (update-time-graph)
					 (revert-sound)
					 (- (real-time) start)))
				     (list (lambda () 
					     (let ((ma (maxamp)))
					       (scale-channel 2.0)
					       (if (fneq (maxamp) (* 2 ma)) (snd-display #__line__ ";bigger scale max: ~A ~A" ma (maxamp)))))
					   (lambda () 
					     (let ((ma (maxamp)))
					       (env-channel '(0 0 1 1))
					       (if (fneq (maxamp) ma) (snd-display #__line__ ";bigger env max: ~A ~A" ma (maxamp)))))
					   (lambda () 
					     (let ((ma (maxamp)))
					       (ptree-channel (lambda (y) (+ y .2)) #f #f ind 0 #f #t)
					       (if (fneq (maxamp) (+ ma .2)) (snd-display #__line__ ";bigger ptree max: ~A ~A" ma (maxamp)))))
					   (lambda () (pad-channel 0 2000))
					   (lambda () (pad-channel 1336909605 297671280))
					   (lambda () (insert-silence (+ (frames ind) 100) 100))
					   (lambda () (vct->channel (vct-fill! (make-vct 1000) .1) 0 1000))
					   (lambda () (vct->channel (vct-fill! (make-vct 1000) .1) (/ (frames ind) 2) 1000))
					   (lambda () (vct->channel (vct-fill! (make-vct 1000) .1) (- (frames ind) 2000) 1000))
					   (lambda () (mix "pistol.snd" 12345))
					   (lambda () (delete-samples 10 200))
					   (lambda () (delete-samples 1336909605 297671280))
					   (lambda () (delete-samples (- (frames ind) 100) 10))
					   ))))
			 (set! (optimization) old-opt)
			 (set! (squelch-update ind) #f)
			 (snd-display #__line__ ";big:  ~{~6,2F~}" times)
			 ))
		     (lambda args (set! (squelch-update) #f)))
	      (close-sound ind)))
	
	(if with-big-file
	    (letrec ((fieql
		      (lambda (a b)
			(if (null? a)
			    (null? b)
			    (if (null? b)
				#f
				(if (and (integer? (car a))
					 (not (= (car a) (car b))))
				    #f
				    (if (and (number? (car a))
					     (fneq (car a) (car b)))
					#f
					(fieql (cdr a) (cdr b)))))))))
	      
	      (reset-hook! after-graph-hook)
	      (reset-hook! mouse-click-hook)
	      
	      (let ((ind (open-sound big-file-name))
		    (vals (make-vct 100))
		    (old-vals #f)
		    (new-vals #f)
		    (maxa 0.0))
		(if (= big-file-frames 0)
		    (set! big-file-frames (frames ind)))
		(select-sound ind)
		(select-channel 0)
		(set! (squelch-update) #t)
		(if (not (fieql (edit-tree) (list (list 0 0 0 (- big-file-frames 1) 1.0 0.0 0.0 0) (list big-file-frames -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger initial tree: ~A" (edit-tree)))
		(vct-fill! vals 1.0)
		(set! maxa (maxamp))
		(scale-channel 0.5)
		(set! old-vals (channel->vct (- (* 44100 50000) 50) 200))
		(if (fneq (maxamp) (* 0.5 maxa)) (snd-display #__line__ ";bigger scale: ~A ~A" maxa (maxamp)))
		(set! (samples (* 44100 50000) 100) vals)
		(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 0.5 0.0 0.0 0) 
						  (list 2205000000 1 0 99 1.0 0.0 0.0 0) 
						  (list 2205000100 0 2205000100 (- big-file-frames 1) 0.5 0.0 0.0 0) 
						  (list big-file-frames -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger set tree: ~A" (edit-tree)))
		(set! new-vals (channel->vct (- (* 44100 50000) 50) 200))
		(do ((i 50 (+ 1 i))) ((= i 150)) (vct-set! old-vals i 1.0))
		(if (not (vequal new-vals old-vals)) (snd-display #__line__ ";bigger set ~A ~A" old-vals new-vals))
		(env-channel (make-env '(0 0 1 1) :length (* 44100 60000)) 1000 (* 44100 60000))
		(if (not (fieql (edit-tree) (list (list 0 0 0 999 0.5 0.0 0.0 0) 
						  (list 1000 0 1000 2204999999 0.5 1.12130420080871e-17 0.83333295583725 1) 
						  (list 2205000000 1 0 99 1.0 0.83333295583725 0.833333015441895 1) 
						  (list 2205000100 0 2205000100 2646000999 0.5 0.833333015441895 1.0 1) 
						  (list 2646001000 0 2646001000 (- big-file-frames 1) 0.5 0.0 0.0 0) 
						  (list big-file-frames -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger with env: ~A" (edit-tree)))
		(revert-sound ind)
		(env-channel (make-env '(0 0 1 1 2 0) :length 101) (* 44100 50000) 100)
		(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0) 
						  (list 2205000000 0 2205000000 2205000050 1.0 4.47034825823422e-10 1.0 2) 
						  (list 2205000051 0 2205000051 2205000099 1.0 0.979591846466064 -5.55111512312578e-17 2) 
						  (list 2205000100 0 2205000100 (- big-file-frames 1) 1.0 0.0 0.0 0) 
						  (list big-file-frames -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger short env: ~A" (edit-tree)))
		(let ((r (make-sampler (+ 75 (* 44100 50000))))
		      (v (make-vct 10)))
		  (do ((i 0 (+ 1 i)))
		      ((= i 10))
		    (vct-set! v i (read-sample r)))
		  (if (not (vequal v (vct -0.021 -0.020 -0.020 -0.019 -0.018 -0.017 -0.016 -0.016 -0.015 -0.014)))
		      (snd-display #__line__ ";bigger short env vals: ~A" v)))
		(revert-sound)
		
		(let ((v (channel->vct (+ 75 (* 44100 50000)) 10)))
		  (if (not (vequal v (vct -0.042 -0.043 -0.044 -0.045 -0.045 -0.045 -0.045 -0.045 -0.045 -0.046)))
		      (snd-display #__line__ ";bigger no env vals: ~A" v)))
		(scale-to 1.0)
		(if (fneq (maxamp) 1.0) (snd-display #__line__ ";bigger scale-to 1.0 maxamp: ~A" (maxamp)))
		(set! (sample (* 44100 51000)) 0.0)
		(if (not (fieql (edit-tree) (list (list 0 0 0 2249099999 1.18574941158295 0.0 0.0 0) 
						  (list 2249100000 1 0 0 1.0 0.0 0.0 0) 
						  (list 2249100001 0 2249100001 (- big-file-frames 1) 1.18574941158295 0.0 0.0 0) 
						  (list big-file-frames -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger set 0 samp: ~A" (edit-tree)))
		(if (fneq (sample (* 44100 51000)) 0.0) (snd-display #__line__ ";bigger 0 samp: ~A" (sample (* 44100 51000))))
		(delete-samples (* 44100 52000) 100)
		(if (not (= (frames) (- big-file-frames 100))) 
		    (snd-display #__line__ ";bigger deletion frames: ~A (~A)" (frames) (- big-file-frames 100)))
		(if (not (= (frames ind 0 0) big-file-frames)) 
		    (snd-display #__line__ ";bigger edpos deletion frames: ~A (~A)" (frames ind 0 0) big-file-frames))
		(if (not (= (frames ind 0 (edit-position)) (- big-file-frames 100))) 
		    (snd-display #__line__ ";bigger ed deletion frames: ~A (~A)" (frames ind 0 (edit-position)) (- big-file-frames 100)))
		(if (not (fieql (edit-tree) (list (list 0 0 0 2249099999 1.18574941158295 0.0 0.0 0) 
						  (list 2249100000 1 0 0 1.0 0.0 0.0 0) 
						  (list 2249100001 0 2249100001 2293199999 1.18574941158295 0.0 0.0 0) 
						  (list 2293200000 0 2293200100 (- big-file-frames 1) 1.18574941158295 0.0 0.0 0) 
						  (list (- big-file-frames 100) -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger deletion: ~A" (edit-tree)))
		(delete-samples 954624868 67)
		(revert-sound)
		
		(delete-samples 1000 (* 44100 50000))
		(if (not (= (frames) (- big-file-frames (* 44100 50000)))) (snd-display #__line__ ";bigger big deletion: ~A" (frames)))
		(if (not (fieql (edit-tree) (list (list 0 0 0 999 1.0 0.0 0.0 0) 
						  (list 1000 0 1085232704 (- big-file-frames 1) 1.0 0.0 0.0 0) 
						  (list 970200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger big delete: ~A" (edit-tree)))
		(insert-silence 0 (* 44100 50000))
		(if (not (= (frames) big-file-frames)) (snd-display #__line__ ";bigger silence: ~A (~A)" (frames) big-file-frames))
		(if (not (fieql (edit-tree) (list (list 0 -1 0 2204999999 0.0 0.0 0.0 0) 
						  (list 2205000000 0 0 999 1.0 0.0 0.0 0) 
						  (list 2205001000 0 1085232704 (- big-file-frames 1) 1.0 0.0 0.0 0) 
						  (list big-file-frames -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger pad: ~A" (edit-tree)))
		(revert-sound)
		
		(pad-channel (* 44100 50000) 100)
		(if (fneq (sample (+ (* 44100 50000) 10)) 0.0) 
		    (snd-display #__line__ ";bigger pad samp: ~A" (sample (+ (* 44100 50000) 10))))
		(if (not (= (frames) (+ big-file-frames 100))) 
		    (snd-display #__line__ ";bigger pad frames: ~A (~A)" (frames) (+ big-file-frames 100)))
		(map-channel (lambda (y) (+ y .2)) (* 44100 50000) 10)
		(if (fneq (sample (+ (* 44100 50000) 1)) 0.2) (snd-display #__line__ ";bigger map samp: ~A" (sample (+ (* 44100 50000) 1))))
		(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0) 
						  (list 2205000000 1 0 9 1.0 0.0 0.0 0) 
						  (list 2205000010 -1 10 99 0.0 0.0 0.0 0) 
						  (list 2205000100 0 2205000000 (- big-file-frames 1) 1.0 0.0 0.0 0) 
						  (list (+ big-file-frames 100) -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger map: ~A" (edit-tree)))
		(save-edit-history "hiho.scm")
		(revert-sound)
		
		(set! sfile ind)
		(load (string-append cwd "hiho.scm"))
		(if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0) 
						  (list 2205000000 1 0 9 1.0 0.0 0.0 0) 
						  (list 2205000010 -1 10 99 0.0 0.0 0.0 0) 
						  (list 2205000100 0 2205000000 (- big-file-frames 1) 1.0 0.0 0.0 0) 
						  (list (+ big-file-frames 100) -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display #__line__ ";bigger reload: ~A" (edit-tree)))
		(delete-file "hiho.scm")
		
		(let ((flt (make-one-zero 0.5 0.5))
		      (flt1 (make-one-zero 0.5 0.5)))
		  (let ((lvals (channel->vct (+ 1000 (* 44100 65000)) 10 ind 0 0)))
		    (if (not (vequal lvals (vct -0.006 0.052 0.103 0.146 0.182 0.210 0.232 0.249 0.262 0.272)))
			(snd-display #__line__ ";bigger (orig) vals: ~A" lvals))
		    (clm-channel flt (+ (* 44100 65000) 1000) 10)
		    (if (not (fieql (edit-tree) (list (list 0 0 0 2204999999 1.0 0.0 0.0 0) 
						      (list 2205000000 1 0 9 1.0 0.0 0.0 0) 
						      (list 2205000010 -1 10 99 0.0 0.0 0.0 0) 
						      (list 2205000100 0 2205000000 2866499899 1.0 0.0 0.0 0) 
						      (list 2866500000 2 0 9 1.0 0.0 0.0 0) 
						      (list 2866500010 0 2866499910 (- big-file-frames 1) 1.0 0.0 0.0 0) 
						      (list (+ big-file-frames 100) -2 0 0 0.0 0.0 0.0 0))))
			(snd-display #__line__ ";bigger clm: ~A" (edit-tree)))
		    (if (not (vequal (channel->vct (+ 1000 (* 44100 65000)) 10) 
				     (vct -0.006 0.015 0.065 0.107 0.142 0.169 0.190 0.205 0.216 0.222)))
			(snd-display #__line__ ";bigger clm vals: ~A" (channel->vct (+ 1000 (* 44100 65000)) 10)))
		    
		    (let ((r (make-readin big-file-name :start (+ 1000 (* 44100 65000))))
			  (v (make-vct 10)))
		      (do ((i 0 (+ 1 i)))
			  ((= i 10))
			(vct-set! v i (readin r)))
		      (if (not (vequal v lvals))
			  (snd-display #__line__ ";bigger (orig) readin vals: ~A (~A)" v lvals)))))
		(revert-sound)
		(let ((found (scan-channel (lambda (y) (> y .5)) (* 44100 50000))))
		  (if (not (equal? found (list #t 2205000925)))
		      (snd-display #__line__ ";bigger scan: ~A" found)))
		(set! (squelch-update) #f)
		(close-sound ind))))
	
	(let ((ind-map (view-sound "oboe.snd"))
	      (ind-ptree (view-sound "oboe.snd")))
	  (map-channel (lambda (y) (+ y .1)) #f #f ind-map)
	  (ptree-channel (lambda (y) (+ y .1)) #f #f ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree + .1 differs"))
	  (undo 1 ind-map)
	  (undo 1 ind-ptree)
	  (scale-by 2.0 ind-map)
	  (scale-by 2.0 ind-ptree)
	  (map-channel (lambda (y) (+ y .1)) #f #f ind-map)
	  (ptree-channel (lambda (y) (+ y .1)) #f #f ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree + .1 differs"))
	  (scale-by 2.0 ind-map)
	  (scale-by 2.0 ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree + .1 differs"))
	  (if (and (> (optimization) 0)
		   (not (string=? (safe-display-edits ind-ptree) (string-append "
EDITS: 3

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (scale 0 50828) ; scale-channel 2.000 0 #f [1:2]:
   (at 0, cp->sounds[0][0:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[0] 0 50828) ; ptree-channel [2:2]:
   (at 0, cp->sounds[0][0:50827, 1.000, loc: 0, pos: 0, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (scale 0 50828) ; scale-channel 2.000 0 #f [3:2]:
   (at 0, cp->sounds[0][0:50827, 2.000, loc: 0, pos: 0, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
"))))
	      (snd-display #__line__ ";ptree display edits: ~A" (safe-display-edits ind-ptree)))
	  (revert-sound ind-map)
	  (revert-sound ind-ptree)
	  
	  (map-channel (lambda (y) (* 2.0 (sin y))) #f #f ind-map)
	  (ptree-channel (lambda (y) (* 2.0 (sin y))) #f #f ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree sin differs"))
	  (map-channel (lambda (y) (* 2.0 (sin y))) #f #f ind-map)
	  (ptree-channel (lambda (y) (* 2.0 (sin y))) #f #f ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree sin (2) differs"))
	  (if (and (> (optimization) 0)
		   (not (string=? (safe-display-edits ind-ptree) (string-append "
EDITS: 2

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[0] 0 50828) ; ptree-channel [1:2]:
   (at 0, cp->sounds[0][0:50827, 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* 2.0 (sin y)))]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[1] 0 50828) ; ptree-channel [2:2]:
   (at 0, cp->sounds[0][0:50827, 1.000, loc2: 1, pos2: 0, scl2: 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (* 2.0 (sin y)))]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
"))))
	      (snd-display #__line__ ";ptree display: ~A" (safe-display-edits ind-ptree)))
	  
	  (revert-sound ind-map)
	  (revert-sound ind-ptree)
	  (env-channel '(0 0 1 1 2 0) #f #f ind-map)
	  (env-channel '(0 0 1 1 2 0) #f #f ind-ptree)
	  (map-channel (lambda (y) (* y y)) #f #f ind-map)
	  (ptree-channel (lambda (y) (* y y)) #f #f ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree y*y differs"))
	  
	  (revert-sound ind-map)
	  (revert-sound ind-ptree)
	  (map-channel (lambda (y) (* y y)) #f #f ind-map)
	  (ptree-channel (lambda (y) (* y y)) #f #f ind-ptree)
	  (env-channel '(0 0 1 1 2 0) #f #f ind-map)
	  (env-channel '(0 0 1 1 2 0) #f #f ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree y*y differs"))
	  
	  (revert-sound ind-map)
	  (revert-sound ind-ptree)
	  (map-channel (lambda (y) (+ y .1)) 100 100 ind-map)
	  (ptree-channel (lambda (y) (+ y .1)) 100 100 ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree[100] + .1 differs"))
	  (scale-by 2.0 ind-map)
	  (scale-by 2.0 ind-ptree)
	  (map-channel (lambda (y) (+ y .2))  1000 100 ind-map)
	  (ptree-channel (lambda (y) (+ y .2)) 1000 100 ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree[1000] + .2 differs"))
	  (if (and (> (optimization) 0)
		   (not (string=? (safe-display-edits ind-ptree) (string-append "
EDITS: 3

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[0] 100 100) ; ptree-channel [1:4]:
   (at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[0][100:199, 1.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 200, cp->sounds[0][200:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (scale 0 50828) ; scale-channel 2.000 0 #f [2:4]:
   (at 0, cp->sounds[0][0:99, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[0][100:199, 2.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 200, cp->sounds[0][200:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[1] 1000 100) ; ptree-channel [3:6]:
   (at 0, cp->sounds[0][0:99, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[0][100:199, 2.000, loc: 0, pos: 0, scl: 1.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 200, cp->sounds[0][200:999, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 1000, cp->sounds[0][1000:1099, 1.000, loc: 1, pos: 0, scl: 2.000, code: (lambda (y) (+ y 0.2))]) [file: " cwd "oboe.snd[0]]
   (at 1100, cp->sounds[0][1100:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
"))))
	      (snd-display #__line__ ";ptree[1000] display: ~A" (safe-display-edits ind-ptree)))
	  
	  (env-channel '(0 0 1 1 2 0) 2000 1000 ind-map)
	  (env-channel '(0 0 1 1 2 0) 2000 1000 ind-ptree)
	  (map-channel (lambda (y) (+ y .3))  4000 100 ind-map)
	  (ptree-channel (lambda (y) (+ y .3)) 4000 100 ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree[2000] + .2 differs"))
	  (map-channel (lambda (y) (+ y .1)) 0 3200 ind-map)
	  (ptree-channel (lambda (y) (+ y .1)) 0 3200 ind-ptree)
	  (if (not (vequal (channel->vct 0 (frames ind-map) ind-map) (channel->vct 0 (frames ind-ptree) ind-ptree)))
	      (snd-display #__line__ ";ptree[3200] + .2 differs"))
	  (undo 1 ind-ptree)
	  (let ((reader (make-sampler (- (frames) 1) ind-ptree 0 -1)))
	    (map-channel (lambda (y) (read-sample reader)) 0 (frames) ind-ptree))
	  (let ((reader (make-sampler (- (frames) 1) ind-ptree 0 -1)))
	    (map-channel (lambda (y) (read-sample reader)) 0 (frames) ind-ptree))
	  (scan-channel (let ((old-reader (make-sampler 0 ind-ptree 0 1 (- (edit-position ind-ptree 0) 2)))
			      (pos 0))
			  (lambda (y)
			    (let ((val (read-sample old-reader)))
			      (if (fneq y val)
				  (begin
				    (display (format #f "~%;trouble in reverse ptree read at ~D ~A ~A" pos val y))
				    #t)
				  (begin
				    (set! pos (+ 1 pos))
				    #f))))))
	  (close-sound ind-map)
	  (close-sound ind-ptree))
	
	(let ((ind (new-sound "fmv.snd" mus-next mus-bfloat)))
	  (set! (sinc-width) 10)
	  (pad-channel 0 1000 ind)
	  (set! (sample 100) 0.5)
	  (if (fneq (sample 100 ind 0 2) 0.5) (snd-display #__line__ ";sample 100 (2): ~A" (sample 100 ind 0 2)))
	  (if (fneq (sample 100 ind 0 1) 0.0) (snd-display #__line__ ";sample 100 (1): ~A" (sample 100 ind 0 1)))
	  (src-channel 0.5)
	  (let ((mx (maxamp ind 0)))
	    (if (fneq mx 0.5) (snd-display #__line__ ";src-channel max .5: ~A" mx)))
	  (if (fneq (sample 200) 0.5) (snd-display #__line__ ";src-channel 0.5 200: ~A" (sample 200)))
	  (if (not (vequal (channel->vct 180 40 ind 0)
			   (vct 0.000 -0.000 0.000 0.001 -0.000 -0.003 0.000 0.007 -0.000 -0.012
				0.000 0.020 -0.000 -0.033 0.000 0.054 -0.000 -0.100 -0.000 0.316
				0.500 0.316 -0.000 -0.100 -0.000 0.054 0.000 -0.033 -0.000 0.020
				0.000 -0.012 -0.000 0.007 0.000 -0.003 -0.000 0.001 0.000 -0.000)))
	      (snd-display #__line__ ";scr-channel 0.5 -> ~A" (channel->vct 180 40 ind 0)))
	  (undo 1 ind 0)
	  (src-channel 0.25)
	  (let ((mx (maxamp ind 0)))
	    (if (fneq mx 0.5) (snd-display #__line__ ";src-channel max .25: ~A" mx)))
	  (if (fneq (sample 400) 0.5) (snd-display #__line__ ";src-channel 0.25 400: ~A" (sample 400)))
	  (if (not (vequal (channel->vct 360 80 ind 0)
			   (vct 0.000 -0.000 -0.000 -0.000 0.000 0.000 0.001 0.001 -0.000 -0.002
				-0.003 -0.003 0.000 0.004 0.007 0.006 -0.000 -0.008 -0.012 -0.010
				0.000 0.013 0.020 0.016 -0.000 -0.021 -0.033 -0.026 0.000 0.034
				0.054 0.044 -0.000 -0.060 -0.100 -0.087 -0.000 0.148 0.316 0.449
				0.500 0.449 0.316 0.148 -0.000 -0.087 -0.100 -0.060 -0.000 0.044
				0.054 0.034 0.000 -0.026 -0.033 -0.021 -0.000 0.016 0.020 0.013
				0.000 -0.010 -0.012 -0.008 -0.000 0.006 0.007 0.004 0.000 -0.003
				-0.003 -0.002 -0.000 0.001 0.001 0.000 0.000 -0.000 -0.000 -0.000)))
	      (snd-display #__line__ ";scr-channel 0.25 -> ~A" (channel->vct 360 80 ind 0)))
	  (undo 2 ind 0)
	  (map-channel (let ((i 0)) (lambda (y) (let ((val (sin (* i (/ pi 100))))) (set! i (+ 1 i)) (* .5 val)))))
	  (for-each
	   (lambda (sr df)
	     (src-channel sr)
	     (if (> (abs (- (maxamp ind 0) .5)) df) (snd-display #__line__ ";src-channel sine ~A: ~A" sr (maxamp ind 0)))
	     (if (integer? sr)
		 (let ((r0 (make-sampler 0))
		       (r1 (make-sampler 0 ind 0 1 (- (edit-position) 1)))
		       (sri (floor sr)))
		   (do ((i 0 (+ 1 i)))
		       ((= i 500))
		     (let ((diff (abs (- (r0) (r1)))))
		       (if (> diff df) (snd-display #__line__ ";src-channel ~A diff ~D: ~A" sr i diff))
		       (do ((j 1 (+ 1 j)))
			   ((= j sri))
			 (r1))))))
	     (do ((i 0 (+ 1 i)))
		 ((= i 50))
	       (let ((s1 (sample i ind 0 (edit-position)))
		     (s2 (sample (round (* sr i)) ind 0 (- (edit-position) 1)))
		     (s3 (sample i ind 0 1)))
		 (if (> (abs (- s1 s2)) df) (snd-display #__line__ ";sample ~D src(~A): ~A ~A" i sr s1 s2))
		 (if (fneq s3 0.0) (snd-display #__line__ ";sample ~D (1): ~A" i s3))))
	     (undo 1 ind 0))
	   (list 2.0 1.5 3.0 3.14)
	   (list 0.008 0.01 0.015 0.025))
	  (close-sound ind)
	  (set! ind (open-sound "oboe.snd"))
	  (let ((orig-max (maxamp ind 0)))
	    (for-each
	     (lambda (sr df)
	       (src-channel sr)
	       (if (> (abs (- (maxamp ind 0) orig-max)) df) (snd-display #__line__ ";src-channel oboe ~A: ~A ~A" sr orig-max (maxamp ind 0)))
	       (if (integer? sr)
		   (let ((r0 (make-sampler 0))
			 (r1 (make-sampler 0 ind 0 1 (- (edit-position) 1)))
			 (sri (floor sr)))
		     (do ((i 0 (+ 1 i)))
			 ((= i 5000))
		       (let ((diff (abs (- (r0) (r1)))))
			 (if (> diff df) (snd-display #__line__ ";src-channel oboe ~A diff ~D: ~A" sr i diff))
			 (do ((j 1 (+ 1 j)))
			     ((= j sri))
			   (r1))))))
	       (undo 1 ind 0))
	     (list 2.0 1.5 3.0 3.14)
	     (list 0.008 0.01 0.015 0.025))
	    
	    (for-each
	     (lambda (sr df)
	       (src-channel sr)
	       (if (> (abs (- (maxamp ind 0) orig-max)) df) (snd-display #__line__ ";src-channel oboe ~A: ~A ~A" sr orig-max (maxamp ind 0)))
	       (do ((i 0 (+ 1 i)))
		   ((= i 50))
		 (let* ((samp (* i 100))
			(s1 (sample samp ind 0 (edit-position)))
			(s2 (sample (floor (* sr samp)) ind 0 (- (edit-position) 1))))
		   (if (> (abs (- s1 s2)) df) (snd-display #__line__ ";sample ~D oboe src(~A): ~A ~A" i sr s1 s2))))
	       (undo 1 ind 0)
	       (amp-envs-equal? ind 0 (edit-position) (+ 1 (edit-position)) .01))
	     (list 0.5 0.25 0.9 0.1)
	     (list 0.001 0.001 0.001 0.001)))
	  (revert-sound ind)
	  (scale-by 2.0)
	  (scale-by 0.5)
	  (amp-envs-equal? ind 0 (edit-position) (- (edit-position) 2) .001)
	  (revert-sound ind)
	  (ptree-channel (lambda (y) y) #f #f ind 0 0 #t)
	  (amp-envs-equal? ind 0 (edit-position) (- (edit-position) 1) .001)
	  (close-sound ind))
	(let ((ind (open-sound "storm.snd")))
	  (ptree-channel (lambda (y) (* y .5)) 1000 123000 ind 0 0 #t) ; get the amp-env code too
	  (pad-channel 0 10000)
	  (ptree-channel (lambda (y) .1))
	  (let ((reader (make-sampler 1000 ind 0 -1))
		(happy #t))
	    (do ((i 0 (+ 1 i)))
		((or (not happy) (= i 10)))
	      (let ((val (reader)))
		(if (fneq val .1)
		    (begin
		      (snd-display #__line__ ";ptree previous: ~A ~A" i val)
		      (set! happy #f))))))
	  (close-sound ind))
	
     	;; recursion tests
        (let ((old-opt (optimization))
	      (ind (open-sound "oboe.snd")))
	  (for-each
	   (lambda (n)
	     (set! (optimization) n)
	     (let ((val (scan-channel (lambda (y) 
					(let ((bigger (scan-channel (lambda (n5) 
								      (> n5 .1)))))
					  bigger)))))
	       (if (not (equal? val (list (list #t 4423) 0))) 
		   (snd-display #__line__ ";scan-channel in scan-channel (~A): ~A" n val)))
	     (let ((hi (make-vct 3))
		   (ho (make-vct 3)))
	       (vct-map! hi (lambda () 
			      (if (scan-channel (lambda (y)
						  (> y .1))) 
				  1.0 0.0)))
	       (if (not (vequal hi (vct 1.0 1.0 1.0))) (snd-display #__line__ ";vct-map! with scan-channel (~A): ~A" n hi))
	       (vct-fill! ho .1)
	       (vct-map! hi (lambda () 
			      (vct-map! ho (lambda () 
					     (+ (vct-ref ho 0) .1))) 
			      (vct-ref ho 0)))
	       (if (not (vequal hi (vct .2 .3 .4))) (snd-display #__line__ ";vct-map! with vct-map! (~A): ~A ~A" n hi ho)))
	     (let ((val (find-channel (lambda (y) (if (find-channel (lambda (n6) (> n6 .1))) #t #f)))))
	       (if (not (equal? val (list #t 0))) (snd-display #__line__ ";find with find: ~A" val)))
	     (let ((val (find-channel (lambda (y) (if (scan-channel (lambda (n7) (> n7 .1))) #t #f)))))
	       (if (not (equal? val (list #t 0))) (snd-display #__line__ ";find with scan-channel: ~A" val)))
	     (let ((mx (maxamp ind 0))
		   (val (scan-channel (lambda (y) (map-channel (lambda (n) (* n 2))) #t))))
	       (if (not (equal? val (list #t 0))) (snd-display #__line__ ";scan-channel with map-channel: ~A" val))
	       (if (fneq mx (/ (maxamp ind 0) 2)) (snd-display #__line__ ";scan+map max: ~A ~A" mx (maxamp ind 0)))
	       (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";scan+map edit-pos: ~A" (edit-position ind 0)))
	       (revert-sound ind)
	       (map-channel (let ((ctr 0)) 
			      (lambda (y) 
				(if (= ctr 0) (map-channel (lambda (n) 
							     (* n 2)))) 
				(set! ctr 1) 
				y)))
	       (if (fneq mx (maxamp ind 0)) (snd-display #__line__ ";map+map max 2: ~A ~A" mx (maxamp ind 0)))
	       (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";map+map edit-pos: ~A" (edit-position ind 0)))
	       (if (fneq mx (/ (maxamp ind 0 1) 2)) (snd-display #__line__ ";map+map max 1: ~A ~A" mx (maxamp ind 0 1)))
	       (revert-sound ind))
	     
	     
	     )
	   (list 0 5))
	  (close-sound ind)
	  (set! (optimization) old-opt))
	
	(let ((ind (open-sound "oboe.snd")))
	  (for-each
	   (lambda (func beg dur len)
	     (let ((old-len (frames ind)))
	       (func beg dur)
	       (if (not (= (frames ind) len)) 
		   (snd-display #__line__ ";(~A ~A ~A) with ~A -> ~A (~A)?" func beg dur old-len (frames ind) len))))
	   (list (lambda (beg dur) (env-channel '(0 0 1 1) beg dur))
		 (lambda (beg dur) (map-channel (lambda (y) (* y .5)) beg dur))
		 (lambda (beg dur) (reverse-channel beg dur))
		 (lambda (beg dur) (scale-channel 2.0 beg dur))
		 (lambda (beg dur) (vct->channel (make-vct dur) beg dur))
		 (lambda (beg dur) (smooth-channel beg dur))
		 (lambda (beg dur) (pad-channel beg dur))
		 (lambda (beg dur) (src-channel 0.5 beg dur))
		 (lambda (beg dur) (insert-silence beg dur)))
	   (list 0 0 0 0 0 0 0 0 0)
	   (list 1000 1000 1000 1000 1000 1000 1000 1000 1000)
	   (list 50828 50828 50828 50828 50828 50828 51828 52829 53829))
	  
	  (revert-sound ind)
	  
	  (for-each
	   (lambda (beg dur len)
	     (let ((old-len (frames ind)))
	       (pad-channel beg dur)
	       (if (not (= (frames ind) len))
		   (snd-display #__line__ ";(pad-channel ~A ~A) with ~A -> ~A (~A)?" beg dur old-len (frames ind) len))))
	   (list 1000 60000 0 62000 62000 62004)
	   (list 1000 1000 1000 1 2 1)
	   (list 51828 61000 62000 62001 62003 62005))
	  
	  (revert-sound ind)
	  
	  (for-each
	   (lambda (func dur len)
	     (let ((old-len (frames ind)))
	       (func (+ old-len 100) dur)
	       (if (not (= (frames ind) len)) 
		   (snd-display #__line__ ";(~A ~A) with ~A -> ~A (~A)?" func dur old-len (frames ind) len))))
	   (list (lambda (beg dur) (env-channel '(0 0 1 1) beg dur))
		 (lambda (beg dur) (reverse-channel beg dur))
		 (lambda (beg dur) (scale-channel 2.0 beg dur))
		 (lambda (beg dur) (scale-sound-by 2.0 beg dur))
		 (lambda (beg dur) (vct->channel (make-vct dur) beg dur))
		 (lambda (beg dur) (smooth-channel beg dur))
		 (lambda (beg dur) (pad-channel beg dur))
		 (lambda (beg dur) (src-channel 0.5 beg dur))
		 (lambda (beg dur) (insert-silence beg dur)) ; diff from pad-channel
		 (lambda (beg dur) (env-sound '(0 0 1 1) beg dur))
		 )
	   (list 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000)
	   (list 50828 50828 50828 50828 51928 51928 53028 53028 54028 54028))
	  
	  (revert-sound ind)
	  
	  (do ((i 0 (+ 1 i)))
	      ((= i 100))
	    (case (floor (random 10))
	      ((0) (pad-channel (random (* 1.25 (frames))) (random 1000)))
	      ((1) (env-channel '(0 0 1 1 2 0) (random (* 1.25 (frames))) (random 1000)))
	      ((2) (env-sound '(0 0 1 1 2 0) (random (* 1.25 (frames))) (random 1000)))
	      ((3) (scale-channel (random 1.0) (random (* 1.25 (frames))) (random 1000)))
	      ((4) (scale-sound-by (random 1.0) (random (* 1.25 (frames))) (random 1000)))
	      ((5) (src-channel (+ .9 (random .2)) (random (* 1.25 (frames))) (random 1000)))
	      ((6) (ramp-channel (random 1.0) (random 1.0) (random (* 1.25 (frames))) (random 1000)))
	      ((7) (reverse-channel (random (* 1.25 (frames))) (random 1000)))
	      ((8) (let ((dur (max 2 (floor (random 100))))) (vct->channel (make-vct dur) (random (* 1.25 (frames))) dur)))
	      ((9) (map-channel (lambda (y) (* y 2)) (random (* .5 (frames))) (random 1000)))))
	  
	  (close-sound ind))
	
	(let ((ind (new-sound "test.snd")))
	  (pad-channel 0 100000) ; force tempfile in fallback
	  (ptree-channel (lambda (y) (if (current-input-port) 1.0 0.0)))
	  (if (fneq (maxamp ind) 1.0)
	      (snd-display #__line__ ";ptree fallback: ~A" (maxamp ind)))
	  (undo)
	  (ptree-channel (lambda (y data dir)
			   (if (current-input-port) (* y 0.5) (* y (vct-ref data 0))))
			 0 #f ind 0 #f #f
			 (lambda (pos dur)
			   (vct 1.0)))
	  (close-sound ind))
	
	(let ((ind0 (open-sound "oboe.snd"))
	      (ind1 (open-sound "2.snd"))
	      (ind2 (open-sound "4.aiff")))
  	  (set! (squelch-update ind0 #t) #t)
	  (set! (squelch-update ind1 #t) #t)
	  (set! (squelch-update ind2 #t) #t)
	  (catch 'mus-error
		 (lambda ()
		   (do ((i 0 (+ 1 i)))
		       ((= i 500))
		     (set! (sync ind0) (random 3))
		     (set! (sync ind1) (random 3))
		     (set! (sync ind2) (random 3))
		     (opt-test (random 22))))
		 (lambda args
		   (snd-display #__line__ ";caught mus-error")
		   #f))
  	  (set! (squelch-update ind0 #t) #f)
	  (set! (squelch-update ind1 #t) #f)
	  (set! (squelch-update ind2 #t) #f)
	  (close-sound ind0)
	  (close-sound ind1)
	  (close-sound ind2))
	
	(let ((ind (open-sound "oboe.snd")))
	  (env-channel '(0 0 1 1 2 0) 1000 10000)
	  (ptree-channel (lambda (y) (* y 2)) 20000 10000)
	  (ramp-channel .2 .6 40000 10000)
	  (scale-channel .5 0 500)
	  (if (> (optimization) 0)
	      (check-edit-tree '((0 0 0 499 0.5 0.0 0.0 0) (500 0 500 999 1.0 0.0 0.0 0) (1000 0 1000 5999 1.0 0.0 1.99999994947575e-4 4) (6000 0 6000 10999 1.0 1.0 -2.00040012714453e-4 4) (11000 0 11000 19999 1.0 0.0 0.0 0) (20000 0 20000 29999 1.0 0.0 0.0 16) (30000 0 30000 39999 1.0 0.0 0.0 0) (40000 0 40000 49999 1.0 0.200000002980232 4.00040007662028e-5 4) (50000 0 50000 50827 1.0 0.0 0.0 0) (50828 -2 0 0 0.0 0.0 0.0 0))
			       #f "no-overlaps"))
	  (revert-sound ind)
	  (pad-channel 0 1000)
	  (ptree-channel (lambda (y) (+ y .1)) 0 2000)
	  (let ((val (sample 100)))
	    (if (fneq val .1)
		(snd-display #__line__ ";pad+ptree: ~A" val)))
	  (undo 2)
	  (pad-channel 0 2000)
	  (ptree-channel (lambda (y) (+ y .1)) 1000 200)
	  (let ((val (sample 1100)))
	    (if (fneq val .1)
		(snd-display #__line__ ";pad+ptree(2): ~A" val)))
	  (undo 2)
	  (pad-channel 1000 1000)
	  (ptree-channel (lambda (y) (+ y .1)) 0 1500)
	  (let ((val (sample 1100)))
	    (if (fneq val .1)
		(snd-display #__line__ ";pad+ptree(3): ~A" val)))
	  (undo 2)
	  (close-sound ind))
	
	(catch #t
	       (lambda ()
		 (let* ((ind (open-sound (string-append home-dir "/test/sound/away.snd")))
			(start (real-time))
			(mxs (maxamp ind #t)))
		   (swap-channels)
		   (update-time-graph)
		   (let ((tm (- (real-time) start)))
		     (if (> tm .1) (snd-display #__line__ ";swap-channels not optimized? ~A" tm)))
		   (let ((new-mxs (maxamp ind #t)))
		     (if (or (fneq (car mxs) (cadr new-mxs))
			     (fneq (cadr mxs) (car new-mxs)))
			 (snd-display #__line__ ";swap-channels amps: ~A -> ~A" mxs new-mxs)))
		   (revert-sound ind)
		   (close-sound ind)))
	       (lambda args args)) ; away.snd may not exist
	
	(let ((ind (init-sound 0.5 10 2)))
	  (save-sound ind)
	  (scale-channel 2.0 0 (frames) ind 1)
	  (swap-channels)
	  (check-both-chans ind "1" (lambda (y) (fneq y 1.0)) (lambda (y) (fneq y 0.5)))
	  (undo 1 ind 0)
	  (undo 2 ind 1)
	  (scale-channel 0.5 0 (frames) ind 0)
	  (scale-channel 2.0 0 (frames) ind 1)
	  (swap-channels)
	  (check-both-chans ind "2" (lambda (y) (fneq y 1.0)) (lambda (y) (fneq y 0.25)))
	  (undo 2 ind 0)
	  (undo 2 ind 1)
	  (delete-samples 2 3 ind 0)
	  (env-channel '(0 0 1 1 2 0) 0 (frames ind 1) ind 1)
	  (swap-channels)
	  (if (not (= (frames ind 1) 11)) (snd-display #__line__ ";frames swapped: ~A" (frames ind 1)))
	  (if (not (vequal (channel->vct 0 (frames ind 0) ind 0) (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000)))
	      (snd-display #__line__ ";swapped env: ~A" (channel->vct 0 (frames ind 0) ind 0)))
	  (undo 2 ind 0)
	  (undo 2 ind 1)
	  (delete-samples 2 7 ind 0)
	  (swap-channels ind 0 ind 1 5 4)
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0.500 0.500 0.500 0.500 0.000 0.500 0.500 0.500 0.500 0.000)))
	      (snd-display #__line__ ";partial swap 1: ~A" (channel->vct 0 10 ind 0)))
	  (if (not (vequal (channel->vct 0 10 ind 1) (vct 0.500 0.500 0.500 0.500 0.500 0.000 0.000 0.000 0.000 0.500)))
	      (snd-display #__line__ ";partial swap 2: ~A" (channel->vct 0 10 ind 1)))
	  (revert-sound ind)
	  (let ((m0 (add-mark 3 ind 0))
		(m1 (add-mark 4 ind 1))
		(m2 (add-mark 5 ind 1)))
	    (scale-channel 0.5)
	    (swap-channels)
	    (if (not (= (mark-sample m0) 3)) (snd-display #__line__ ";swapped m0: ~A" (mark-sample m0)))
	    (if (not (= (mark-sample m1) 4)) (snd-display #__line__ ";swapped m1: ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 5)) (snd-display #__line__ ";swapped m2: ~A" (mark-sample m2)))
	    (if (not (equal? (mark-home m0) (list ind 1))) (snd-display #__line__ ";mark-home m0: ~A" (mark-home m0)))
	    (if (not (equal? (mark-home m1) (list ind 0))) (snd-display #__line__ ";mark-home m1: ~A" (mark-home m1)))
	    (if (not (equal? (mark-home m2) (list ind 0))) (snd-display #__line__ ";mark-home m2: ~A" (mark-home m2)))
	    (undo 1 ind 0)
	    (undo 1 ind 1)
	    (if (not (= (mark-sample m0) 3)) (snd-display #__line__ ";swapped m0 2: ~A" (mark-sample m0)))
	    (if (not (= (mark-sample m1) 4)) (snd-display #__line__ ";swapped m1 2: ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 5)) (snd-display #__line__ ";swapped m2 2: ~A" (mark-sample m2)))
	    (if (not (equal? (mark-home m0) (list ind 0))) (snd-display #__line__ ";mark-home m0 2: ~A" (mark-home m0)))
	    (if (not (equal? (mark-home m1) (list ind 1))) (snd-display #__line__ ";mark-home m1 2: ~A" (mark-home m1)))
	    (if (not (equal? (mark-home m2) (list ind 1))) (snd-display #__line__ ";mark-home m2 2: ~A" (mark-home m2))))
	  (close-sound ind)
	  (delete-file "test.snd"))
	
	(let ((ind (init-sound 0.5 10 4)))
	  (scale-channel 0.5 0 (frames) ind 1)
	  (scale-channel 0.25 0 (frames) ind 2)
	  (scale-channel 0.125 0 (frames) ind 3)
	  (swap-channels ind 1 ind 2)
	  (let ((maxs (maxamp ind #t)))
	    (if (or (fneq (list-ref maxs 0) 0.5) (fneq (list-ref maxs 1) 0.125) (fneq (list-ref maxs 2) 0.25) (fneq (list-ref maxs 3) 0.0625))
		(snd-display #__line__ ";swap midchans: ~A" maxs))
	    (close-sound ind)))
	
	(let* ((ind0 (open-sound "oboe.snd"))
	       (ind1 (open-sound "pistol.snd"))
	       (mx0 (maxamp ind0 0))
	       (mx1 (maxamp ind1 0)))
	  (swap-channels ind0 0 ind1 0)
	  (if (fneq (maxamp ind0 0) mx1) (snd-display #__line__ ";maxamp cross swap 0: ~A" (maxamp ind0 0)))
	  (if (fneq (maxamp ind1 0) mx0) (snd-display #__line__ ";maxamp cross swap 1: ~A" (maxamp ind1 0)))
	  (close-sound ind1)
	  (if (and (> (optimization) 0)
		   (not (string=? (display-edits) (string-append "
EDITS: 1

 (begin) [0:2]:
   (at 0, cp->sounds[0][0:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (set 0 41623) ; swap-channels [1:2]:
   (at 0, cp->sounds[1][0:41622, 1.000]) [file: " cwd "pistol.snd[0]]
   (at 41623, end_mark)
"))))
	      (snd-display #__line__ ";cross swap state: ~A" (display-edits)))
	  (close-sound ind0))
	
	(let ((ind (init-sound 1.0 10 1)))
	  
	  ;; -------- ramp+ramp
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ramp 1" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ramp 2" (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.000))
	  (undo)
	  (ramp-channel 1.0 0.0)
	  (check-back-and-forth ind "ramp 3" (vct 0.000 0.090 0.160 0.210 0.240 0.250 0.240 0.210 0.160 0.090 0.000))
	  (undo)
	  (env-channel '(0 0 1 1 2 0))
	  (check-back-and-forth ind "ramp 4" (vct 0.000 0.020 0.080 0.180 0.320 0.500 0.480 0.420 0.320 0.180 0.000))
	  (undo 2)
	  (env-channel '(0 0 1 1 2 0))
	  (check-back-and-forth ind "ramp 5" (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200 0.000))
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ramp 6" (vct 0.000 0.020 0.080 0.180 0.320 0.500 0.480 0.420 0.320 0.180 0.000))
	  (scale-channel 0.5)
	  (check-back-and-forth ind "ramp 7" (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.240 0.210 0.160 0.090 0.000))
	  (undo 3)
	  (scale-channel 0.5)
	  (env-channel '(0 0 1 1 2 0))
	  (check-back-and-forth ind "ramp 8" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000))
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ramp 9" (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.240 0.210 0.160 0.090 0.000))
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ramp 10" (vct 0.000 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1.000))
	  (undo 3)
	  
	  
	  ;; -------- ramp+ptree
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ramp+ptree 1" (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800 2.000))
	  (scale-channel .5)
	  (check-back-and-forth ind "ramp+ptree 2" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (ptree-channel (lambda (y) (+ y .5)))
	  (check-back-and-forth ind "ramp+ptree 3" (vct 0.500 0.600 0.700 0.800 0.900 1.000 1.100 1.200 1.300 1.400 1.500))
	  (undo 4)
	  (env-channel '(0 0 1 1 2 0))
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ramp+ptree 4" (vct 0.000 0.400 0.800 1.200 1.600 2.000 1.600 1.200 0.800 0.400 0.000))
	  (undo 2)
	  (scale-channel .5)
	  (env-channel '(0 0 1 1 2 0))
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ramp+ptree 5" (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200 0.000))
	  (scale-by .5)
	  (check-back-and-forth ind "ramp+ptree 6" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000))
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (scale-channel 0.5)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ramp+ptree 7" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (scale-channel 0.5)
	  (check-back-and-forth ind "ramp+ptree 8" (vct 0.000 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 0.500))
	  (undo 4)
	  (ramp-channel 0.0 1.0 0 5)
	  (ptree-channel (lambda (y) (* y 2.0)) 3 3)
	  (check-back-and-forth ind "ramp+ptree 9" (vct 0.000 0.250 0.500 1.500 2.000 2.000 1.000 1.000 1.000 1.000 1.000))
	  (undo 2)
	  (ramp-channel 0.0 1.0 0 5)
	  (ptree-channel (lambda (y) (* y 2.0)) 0 3)
	  (check-back-and-forth ind "ramp+ptree 10" (vct 0.000 0.500 1.000 0.750 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	  (undo 2)
	  (ramp-channel 1.0 0.0 5 5)
	  (ptree-channel (lambda (y) (* y 2.0)) 3 4)
	  (check-back-and-forth ind "ramp+ptree 11" (vct 1.000 1.000 1.000 2.000 2.000 2.000 1.500 0.500 0.250 0.000 1.000))
	  (undo 2)
	  
	  ;; ramp+scl (checking split loc)
	  (ramp-channel 0.0 1.0 0 5)
	  (scale-channel 0.5 3 3)
	  (check-back-and-forth ind "ramp+scl 12" (vct 0.000 0.250 0.500 0.375 0.500 0.500 1.000 1.000 1.000 1.000 1.000))
	  (undo 2)
	  (ramp-channel 1.0 0.0 5 5)
	  (scale-channel 0.5 4 3)
	  (check-back-and-forth ind "ramp+scl 13" (vct 1.000 1.000 1.000 1.000 0.500 0.500 0.375 0.500 0.250 0.000 1.000))
	  (undo 2)
	  
	  ;; ramp+scl (checking split loc)
	  
	  (let ((start-pos (edit-position ind 0)))
	    (for-each
	     (lambda (func)
	       (ramp-channel 0.0 1.0 0 5)
	       (let ((edpos (edit-position ind 0)))
		 (check-back-and-forth ind "ramp+scl setup" (vct 0.000 0.250 0.500 0.750 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
		 (let ((happy #t))
		   (do ((start 0 (+ 1 start)))
		       ((or (not happy)
			    (= start 10)))
		     (do ((len 1 (+ 1 len)))
			 ((or (not happy)
			      (= (+ start len) 11)))
		       (let ((v (vct 0.000 0.250 0.500 0.750 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
			 (do ((i 0 (+ 1 i)))
			     ((= i len))
			   (vct-set! v (+ start i) (* (vct-ref v (+ start i)) 0.5)))
			 (func 0.5 start len)
			 (set! happy (check-back-and-forth ind (format #f "ramp+scl 0-1 [~A ~A] with ~A" start len func) v))
			 (set! (edit-position ind 0) edpos)
			 )))))
	       (set! (edit-position ind 0) start-pos)
	       
	       (ramp-channel 1.0 0.0 5 5)
	       (let ((edpos (edit-position ind 0)))
		 (check-back-and-forth ind "ramp+scl 2 setup" (vct 1.000 1.000 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.000 1.000))
		 (let ((happy #t))
		   (do ((start 0 (+ 1 start)))
		       ((or (not happy)
			    (= start 10)))
		     (do ((len 1 (+ 1 len)))
			 ((or (not happy)
			      (= (+ start len) 11)))
		       (let ((v (vct 1.000 1.000 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.000 1.000)))
			 (do ((i 0 (+ 1 i)))
			     ((= i len))
			   (vct-set! v (+ start i) (* (vct-ref v (+ start i)) 0.5)))
			 (func 0.5 start len)
			 (set! happy (check-back-and-forth ind (format #f "ramp+scl 1-0 [~A ~A] with ~A" start len func) v))
			 (set! (edit-position ind 0) edpos)
			 )))))
	       (set! (edit-position ind 0) start-pos)
	       
	       (ramp-channel 0.0 1.0 0 5)
	       (ramp-channel 1.0 0.0 5 5)
	       (let ((edpos (edit-position ind 0)))
		 (check-back-and-forth ind "ramp+scl 3 setup" (vct 0.000 0.250 0.500 0.750 1.000 1.000 0.750 0.500 0.250 0.000 1.000))
		 (let ((happy #t))
		   (do ((start 0 (+ 1 start)))
		       ((or (not happy)
			    (= start 10)))
		     (do ((len 1 (+ 1 len)))
			 ((or (not happy)
			      (= (+ start len) 11)))
		       (let ((v (vct 0.000 0.250 0.500 0.750 1.000 1.000 0.750 0.500 0.250 0.000 1.000)))
			 (do ((i 0 (+ 1 i)))
			     ((= i len))
			   (vct-set! v (+ start i) (* (vct-ref v (+ start i)) 0.5)))
			 (func 0.5 start len)
			 (set! happy (check-back-and-forth ind (format #f "ramp+scl 0-1-1-0 [~A ~A] with ~A" start len func) v))
			 (set! (edit-position ind 0) edpos)
			 )))))
	       (set! (edit-position ind 0) start-pos)
	       
	       (ramp-channel 1.0 0.0 3 5)
	       (let ((edpos (edit-position ind 0)))
		 (check-back-and-forth ind "ramp+scl 4 setup" (vct 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.000 1.000 1.000 1.000))
		 (let ((happy #t))
		   (do ((start 0 (+ 1 start)))
		       ((or (not happy)
			    (= start 10)))
		     (do ((len 1 (+ 1 len)))
			 ((or (not happy)
			      (= (+ start len) 11)))
		       (let ((v (vct 1.000 1.000 1.000 1.000 0.750 0.500 0.250 0.000 1.000 1.000 1.000)))
			 (do ((i 0 (+ 1 i)))
			     ((= i len))
			   (vct-set! v (+ start i) (* (vct-ref v (+ start i)) 0.5)))
			 (func 0.5 start len)
			 (set! happy (check-back-and-forth ind (format #f "ramp+scl mid 1-0 [~A ~A] with ~A" start len func) v))
			 (set! (edit-position ind 0) edpos)
			 )))))
	       (set! (edit-position ind 0) start-pos)
	       
	       (env-channel '(0 1 1 0 2 0 3 1))
	       (let ((edpos (edit-position ind 0)))
		 (check-back-and-forth ind "ramp+scl setup" (vct 1.000 0.667 0.333 0.000 0.000 0.000 0.000 0.000 0.333 0.667 1.000))
		 (let ((happy #t))
		   (do ((start 0 (+ 1 start)))
		       ((or (not happy)
			    (= start 10)))
		     (do ((len 1 (+ 1 len)))
			 ((or (not happy) 
			      (= (+ start len) 11)))
		       (let ((v (vct 1.000 0.667 0.333 0.000 0.000 0.000 0.000 0.000 0.333 0.667 1.000)))
			 (do ((i 0 (+ 1 i)))
			     ((= i len))
			   (vct-set! v (+ start i) (* (vct-ref v (+ start i)) 0.5)))
			 (func 0.5 start len)
			 (set! happy (check-back-and-forth ind (format #f "ramp+scl 0-1-0-1 [~A ~A] with ~A" start len func) v))
			 (set! (edit-position ind 0) edpos)
			 )))))
	       (set! (edit-position ind 0) start-pos))
	     
	     (list
	      (lambda (scl beg dur)
		(scale-channel scl beg dur))
	      (lambda (scl beg dur)
		(ptree-channel (lambda (y) (* y scl)) beg dur))
	      (lambda (scl beg dur)
		(map-channel (lambda (y) (* y scl)) beg dur))
	      (lambda (scl beg dur)
		(ptree-channel (lambda (y data dir)
				 (* y (vct-ref data 0))) 
			       beg dur ind 0 #f #f (lambda (pos dur) (vct scl)))))))
	  
	  ;; -------- ramp+ptree-closure
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "ramp+ptreec 1" (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800 2.000))
	  (scale-channel .5)
	  (check-back-and-forth ind "ramp+ptreec 2" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (ptree-channel (lambda (y data dir) 
			   (+ y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 0.5)))
	  (check-back-and-forth ind "ramp+ptreec 3" (vct 0.500 0.600 0.700 0.800 0.900 1.000 1.100 1.200 1.300 1.400 1.500))
	  (undo 4)
	  (env-channel '(0 0 1 1 2 0))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "ramp+ptreec 4" (vct 0.000 0.400 0.800 1.200 1.600 2.000 1.600 1.200 0.800 0.400 0.000))
	  (undo 2)
	  (scale-channel .5)
	  (env-channel '(0 0 1 1 2 0))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "ramp+ptreec 5" (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200 0.000))
	  (scale-by .5)
	  (check-back-and-forth ind "ramp+ptreec 6" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000))
	  (undo 4)
	  (ramp-channel 0.0 1.0)
	  (scale-channel 0.5)
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "ramp+ptreec 7" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (scale-channel 0.5)
	  (check-back-and-forth ind "ramp+ptreec 8" (vct 0.000 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 0.500))
	  (undo 4)
	  
	  
	  ;; -------- xramp+ptree+closure
	  (xramp-channel 0.0 1.0 .0325)
	  (check-back-and-forth ind "xramp(+ptree+closure) 0" (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 1" (vct-scale! (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000) 2.0))
	  (scale-channel .5)
	  (check-back-and-forth ind "xramp+ptree-closure 2" (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000))
	  (ptree-channel (lambda (y data dir) 
			   (+ y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 0.5)))
	  (check-back-and-forth ind "xramp+ptree-closure 3" (vct-offset! (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000) 0.5))
	  (undo 4)
	  (env-sound '(0 0 1 1 2 0) 0 11 .0325)
	  (check-back-and-forth ind "xramp(+ptree-closure) 4" (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 4" (vct-scale! (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000) 2.0))
	  (undo 2)
	  (scale-channel .5)
	  (env-sound '(0 0 1 1 2 0) 0 11 .0325)
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 5" (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000))
	  (scale-by .5)
	  (check-back-and-forth ind "ramp+ptree-closure 6" (vct-scale! (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000) 0.5))
	  (undo 4)
	  (xramp-channel 0.0 1.0 .0325)
	  (scale-channel 0.5)
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 (frames) ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 7" (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000))
	  (scale-channel 0.5)
	  (check-back-and-forth ind "ramp+ptree-closure 8" (vct-scale! (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000) 0.5))
	  (undo 4)
	  (xramp-channel 0.0 1.0 .0325 0 5)
	  (check-back-and-forth ind "xramp(+ptree-closure) 9" (vct 0.000 0.595 0.847 0.954 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 3 3 ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 9" (vct 0.000 0.595 0.847 1.909 2.000 2.000 1.000 1.000 1.000 1.000 1.000))
	  (undo 2)
	  (xramp-channel 0.0 1.0 .0325 0 5)
	  (check-back-and-forth ind "xramp(+ptree-closure) 10" (vct 0.000 0.595 0.847 0.954 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 0 3 ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 10" (vct 0.000 1.189 1.695 0.954 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	  (undo 2)
	  (xramp-channel 1.0 0.0 .0325 5 5)
	  (check-back-and-forth ind "xramp(+ptree-closure) 11" (vct 1.000 1.000 1.000 1.000 1.000 1.000 0.954 0.847 0.595 0.000 1.000))
	  (ptree-channel (lambda (y data dir) 
			   (* y (vct-ref data 0))) 
			 3 4 ind 0 #f #f (lambda (pos dur) (vct 2.0)))
	  (check-back-and-forth ind "xramp+ptree-closure 11" (vct 1.000 1.000 1.000 2.000 2.000 2.000 1.909 0.847 0.595 0.000 1.000))
	  (undo 2)
	  
	  ;; -------- ptree+ramp
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ptree+ramp 1" (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800 2.000))
	  (scale-channel .5)
	  (check-back-and-forth ind "ptree+ramp 2" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (undo 3)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (env-channel '(0 0 1 1 2 0))
	  (check-back-and-forth ind "ptree+ramp 3" (vct 0.000 0.400 0.800 1.200 1.600 2.000 1.600 1.200 0.800 0.400 0.000))
	  (undo 2)
	  (scale-channel .5)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (env-channel '(0 0 1 1 2 0))
	  (check-back-and-forth ind "ptree+ramp 4" (vct 0.000 0.200 0.400 0.600 0.800 1.000 0.800 0.600 0.400 0.200 0.000))
	  (scale-by .5)
	  (check-back-and-forth ind "ptree+ramp 5" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000))
	  (undo 4)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (scale-channel 0.5)
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ptree+ramp 6" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (undo 3)
	  ;; try on-air cases
	  (undo 1)
	  (ptree-channel (lambda (y) 2.0))
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ptree+ramp air 1" (vct 0.000 0.200 0.400 0.600 0.800 1.000 1.200 1.400 1.600 1.800 2.000))
	  (scale-channel .5)
	  (check-back-and-forth ind "ptree+ramp air 2" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (undo 3)
	  (ptree-channel (lambda (y) 2.0))
	  (env-channel '(0 0 1 1 2 0))
	  (check-back-and-forth ind "ptree+ramp air 3" (vct 0.000 0.400 0.800 1.200 1.600 2.000 1.600 1.200 0.800 0.400 0.000))
	  (undo 2)
	  (ptree-channel (lambda (y) 2.0))
	  (scale-channel 0.5)
	  (ramp-channel 0.0 1.0)
	  (check-back-and-forth ind "ptree+ramp air 4" (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000))
	  (undo 3)
	  
	  ;; -------- xramp+ptree
	  (map-chan (lambda (y) 1.0))
	  
	  (ptree-channel (lambda (y) y))
	  (xramp-channel 0.0 1.0 .0325)
	  (let ((orig-data (channel->vct)))
	    (undo 2)
	    (xramp-channel 0.0 1.0 .0325)
	    (if (not (vequal orig-data (channel->vct)))
		(snd-display #__line__ ";xramp cases: ~A ~A" orig-data (channel->vct)))
	    (check-back-and-forth ind "xramp(+ptree) 0" (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000))
	    (ptree-channel (lambda (y) (* y 2.0)))
	    (check-back-and-forth ind "xramp+ptree 1" (vct-scale! (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000) 2.0))
	    (scale-channel .5)
	    (check-back-and-forth ind "xramp+ptree 2" (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000))
	    (ptree-channel (lambda (y) (+ y .5)))
	    (check-back-and-forth ind "xramp+ptree 3" (vct-offset! (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000) 0.5))
	    (undo 4)
	    (ptree-channel (lambda (y) y))
	    (env-sound '(0 0 1 1 2 0) 0 11 .0325)
	    (set! orig-data (channel->vct))
	    (undo 2)
	    (env-sound '(0 0 1 1 2 0) 0 11 .0325)
	    (if (not (vequal orig-data (channel->vct)))
		(snd-display #__line__ ";xramp cases 1: ~A ~A" orig-data (channel->vct)))
	    (check-back-and-forth ind "xramp(+ptree) 4" (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000))
	    (ptree-channel (lambda (y) (* y 2.0)))
	    (check-back-and-forth ind "xramp+ptree 4" (vct-scale! (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000) 2.0))
	    (undo 2)
	    (scale-channel .5)
	    (env-sound '(0 0 1 1 2 0) 0 11 .0325)
	    (ptree-channel (lambda (y) (* y 2.0)))
	    (check-back-and-forth ind "xramp+ptree 5" (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000))
	    (scale-by .5)
	    (check-back-and-forth ind "ramp+ptree 6" (vct-scale! (vct 0.000 0.513 0.771 0.901 0.967 1.000 0.967 0.901 0.771 0.513 0.000) 0.5))
	    (undo 4)
	    (xramp-channel 0.0 1.0 .0325)
	    (scale-channel 0.5)
	    (ptree-channel (lambda (y) (* y 2.0)))
	    (check-back-and-forth ind "xramp+ptree 7" (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000))
	    (scale-channel 0.5)
	    (check-back-and-forth ind "ramp+ptree 8" (vct-scale! (vct 0.000 0.300 0.513 0.664 0.771 0.847 0.901 0.940 0.967 0.986 1.000) 0.5))
	    (undo 4)
	    (xramp-channel 0.0 1.0 .0325 0 5)
	    (check-back-and-forth ind "xramp(+ptree) 9" (vct 0.000 0.595 0.847 0.954 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	    (ptree-channel (lambda (y) (* y 2.0)) 3 3)
	    (check-back-and-forth ind "xramp+ptree 9" (vct 0.000 0.595 0.847 1.909 2.000 2.000 1.000 1.000 1.000 1.000 1.000))
	    (undo 2)
	    (xramp-channel 0.0 1.0 .0325 0 5)
	    (check-back-and-forth ind "xramp(+ptree) 10" (vct 0.000 0.595 0.847 0.954 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	    (ptree-channel (lambda (y) (* y 2.0)) 0 3)
	    (check-back-and-forth ind "xramp+ptree 10" (vct 0.000 1.189 1.695 0.954 1.000 1.000 1.000 1.000 1.000 1.000 1.000))
	    (undo 2)
	    (xramp-channel 1.0 0.0 .0325 5 5)
	    (check-back-and-forth ind "xramp(+ptree) 11" (vct 1.000 1.000 1.000 1.000 1.000 1.000 0.954 0.847 0.595 0.000 1.000))
	    (ptree-channel (lambda (y) (* y 2.0)) 3 4)
	    (check-back-and-forth ind "xramp+ptree 11" (vct 1.000 1.000 1.000 2.000 2.000 2.000 1.909 0.847 0.595 0.000 1.000))
	    (undo 2))
	  
	  ;; -------- ptree chains
	  (map-chan (lambda (y) 1.0))
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ptree+ptree 1" (vct 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000))
	  (undo)
	  (ptree-channel (lambda (y) (let ((a (* y .5))) (+ y a))))
	  (check-back-and-forth ind "ptree+ptree 2" (vct 3.000 3.000 3.000 3.000 3.000 3.000 3.000 3.000 3.000 3.000 3.000))
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ptree+ptree 3" (vct 6.000 6.000 6.000 6.000 6.000 6.000 6.000 6.000 6.000 6.000 6.000))
	  (undo 3)
	  (scale-channel 2.0)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (scale-channel 0.5)
	  (ptree-channel (lambda (y) (* y 2.0)))
	  (check-back-and-forth ind "ptree+ptree 4" (vct 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000 4.000))
	  (scale-channel 0.5)
	  (check-back-and-forth ind "ptree+ptree 4" (vct 2.000 2.000 2.000 2.000 2.000 2.000 2.000 2.000 2.000 2.000 2.000))
	  (undo 5)
	  
	  (close-sound ind)
	  )	
	
	(if (and all-args (= test-16 0))
	    (let ((old-opt (optimization))
		  (tries 256))
	      (set! (optimization) 6)
	      (snd-display #__line__ ";frames: ~,2F ~,2F" 
			   (exact->inexact (/ (mus-sound-frames "1.snd") (mus-sound-frames "oboe.snd")))
			   (exact->inexact (/ (mus-sound-frames "1.snd") (mus-sound-frames "1a.snd"))))
	      (snd-display #__line__ ";~12T~A~28T~A~44T~A~56T(1/oboe, 1/1a)" "1.snd" "oboe.snd" "1a.snd")
	      (for-each
	       (lambda (name func)
		 (let* ((ind (open-sound "1.snd"))
			(start-time-1 (real-time)))
		   (set! (squelch-update ind 0) #t)
		   (do ((i 0 (+ 1 i)))
		       ((= i tries))
		     (if (= (modulo i 10) 0) (revert-sound ind))
		     (func ind i))
		   (let ((mid-time-1 (real-time)))
		     (revert-sound ind)
		     (set! (squelch-update ind 0) #f)
		     (close-sound ind)
		     (let ((end-time-1 (real-time)))
		       (let* ((ind (open-sound "oboe.snd"))
			      (start-time-2 (real-time)))
			 (set! (squelch-update ind 0) #t)
			 (do ((i 0 (+ 1 i)))
			     ((= i tries))
			   (if (= (modulo i 10) 0) (revert-sound ind))
			   (func ind i))
			 (let ((mid-time-2 (real-time)))
			   (revert-sound ind)
			   (set! (squelch-update ind 0) #f)
			   (close-sound ind)
			   (let ((end-time-2 (real-time)))
			     (let* ((ind (open-sound "1a.snd"))
				    (start-time (real-time)))
			       (set! (squelch-update ind 0) #t)
			       (do ((i 0 (+ 1 i)))
				   ((= i tries))
				 (if (= (modulo i 10) 0) (revert-sound ind))
				 (func ind i))
			       (let ((mid-time (real-time)))
				 (revert-sound ind)
				 (set! (squelch-update ind 0) #f)
				 (close-sound ind)
				 (let ((end-time (real-time)))
				   (snd-display #__line__ ";~A:~12T~A~18T~A~28T~A~34T~A~44T~A~50T~A~56T(~,2F, ~,2F)" 
						name 
						
						(hundred (- mid-time-1 start-time-1)) (hundred (- end-time-1 mid-time-1))
						(hundred (- mid-time-2 start-time-2)) (hundred (- end-time-2 mid-time-2))
						(hundred (- mid-time start-time)) (hundred (- end-time mid-time))
						
						(exact->inexact (/ (+ (hundred (- mid-time-1 start-time-1)) (hundred (- end-time-1 mid-time-1)))
								   (max 1 (+ (hundred (- mid-time-2 start-time-2)) (hundred (- end-time-2 mid-time-2))))))
						(exact->inexact (/ (+ (hundred (- mid-time-1 start-time-1)) (hundred (- end-time-1 mid-time-1)))
								   (max 1 (+ (hundred (- mid-time start-time)) (hundred (- end-time mid-time)))))))))))))))))
	       
	       (list "scale" "set!" "env" "env-exp" "env-step" "delete" "insert" "ptree" "pad"
		     "mix-no-tag" "mix-tag" "mix-amp" "mix-scale" "src-2" "src" 
		     "filter" "filter-sym" "f10" "f10sym" "clm" 
		     "reverse" 
		     )
	       (list 
		(lambda (snd i)
		  (scale-channel (* i .01)))
		(lambda (snd i)
		  (set! (sample i) .5))
		(lambda (snd i)
		  (env-channel '(0 0 1 1)))
		(lambda (snd i)
		  (env-channel-with-base '(0 0 1 1) 32.0))
		(lambda (snd i)
		  (env-channel-with-base '(0 0 1 1) 0.0))
		(lambda (snd i)
		  (delete-sample (* 10 i)))
		(lambda (snd i)
		  (insert-sample (* 10 i) .5))
		(lambda (snd i)
		  (ptree-channel (lambda (y) (* y .999))))
		(lambda (snd i)
		  (pad-channel (* 10 i) (* 10 i)))
		(lambda (snd i)
		  (mix "pistol.snd" (* i 10) 0 snd 0 #f))
		(lambda (snd i)
		  (mix "pistol.snd" (* i 10) 0 snd 0 #t))
		(lambda (snd i)
		  (let ((mx (car (mix "pistol.snd" (* i 100)))))
		    (set! (mix-amp mx) .01)))
		(lambda (snd i)
		  (let ((mx (mix "pistol.snd" (* i 100))))
		    (scale-by .5))) ; scale-to before but that forces channel-maxamp which forces a full read which skews everything
		(lambda (snd i)
		  (src-sound 2.0)
		  (undo))
		(lambda (snd i)
		  (src-sound 2.01)
		  (undo))
		(lambda (snd i)
		  (filter-channel (vct .25 .5 .25 .1) 4))
		(lambda (snd i)
		  (filter-channel (vct .25 .5 .5 .25) 4))
		(lambda (snd i)
		  (filter-channel (vct .1 .2 .1 .1 .1 .1 .1 .2 .1 .1) 10))
		(lambda (snd i)
		  (filter-channel (vct .1 .1 .1 .1 .1 .1 .1 .1 .1 .1) 10))
		(lambda (snd i)
		  (clm-channel (make-two-zero .5 .5)))
		(lambda (snd i)
		  (reverse-channel (* i 10) (* i 100)))
		))
	      (set! (optimization) old-opt)))
	
	(let ((ind (new-sound "fmv.snd" :size 50))
	      (sw (sinc-width)))
	  (set! (sinc-width) 10)
	  (set! (sample 20 ind 0) 0.5)
	  (let ((edpos (edit-position ind 0)))
	    
	    ;; -------- no-ops
	    (src-channel 1)
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";src-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    (src-sound 1)
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";src-sound 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    (select-all)
	    (src-selection 1)
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";src-selection 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    
	    (filter-channel (vct 1.0))
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";filter-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    
	    (env-channel '(0 1 1 1))
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";env-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    (env-sound '(0 1 1 1))
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";env-sound 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    (env-selection '(0 1 1 1))
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";env-selection 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    
	    (scale-channel 1)
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";scale-channel 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    (scale-by 1)
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";scale-by 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    (scale-selection-by 1)
	    (if (not (= (edit-position ind 0) edpos)) (snd-display #__line__ ";scale-selection 1 as no-op: ~A ~A" edpos (edit-position ind 0)))
	    
	    ;; -------- other special cases
	    (src-channel -1)
	    (reverse-channel)
	    (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
	      (if diff (snd-display #__line__ ";src -1 and reverse diff: ~A" diff)))
	    
	    (set! (edit-position ind 0) edpos)
	    (scale-by 2)
	    (filter-channel (vct 2) 1 0 #f ind 0 edpos)
	    (let ((diff (edit-difference ind 0 (+ 1 edpos) (+ edpos 2))))
	      (if diff (snd-display #__line__ ";scale and filter 2 diff: ~A" diff)))
	    
	    ;; -------- not no-ops!
	    (scale-channel 1.0 0 #f ind 0 edpos)
	    (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
	      (if diff (snd-display #__line__ ";edpos scale 1 diff: ~A" diff)))
	    (if (fneq (maxamp ind 0) 0.5) (snd-display #__line__ ";scale 1 of original: ~A" (maxamp ind 0)))
	    (if (= (edit-position ind 0) (+ edpos 2)) 
		(snd-display #__line__ ";edpos scl copy opted out?")
		(undo))
	    
	    (filter-channel (vct 1) 1 0 #f ind 0 edpos)
	    (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
	      (if diff (snd-display #__line__ ";edpos flt 1 diff: ~A" diff)))
	    (if (= (edit-position ind 0) (+ edpos 2)) 
		(snd-display #__line__ ";edpos flt copy opted out?")
		(undo))
	    
	    (env-channel '(0 1 1 1) 0 #f ind 0 edpos)
	    (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
	      (if diff (snd-display #__line__ ";edpos env 1 diff: ~A" diff)))
	    (if (= (edit-position ind 0) (+ edpos 2)) 
		(snd-display #__line__ ";edpos env copy opted out?")
		(undo))
	    
	    (src-channel 1.0 0 #f ind 0 edpos)
	    (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
	      (if (and diff (> (car diff) .0001)) (snd-display #__line__ ";edpos src 1 diff: ~A" diff)))
	    (if (= (edit-position ind 0) (+ edpos 2)) 
		(snd-display #__line__ ";edpos src copy opted out?")
		(undo))
	    
	    (set! edpos (edit-position ind 0))
	    (let ((len (frames ind 0)))
	      (src-channel 0.5)
	      
	      (scale-channel 1.0 0 #f ind 0 edpos)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos scale 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";scl len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (filter-channel (vct 1) 1 0 #f ind 0 edpos)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos flt 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";flt len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (env-channel '(0 1 1 1) 0 #f ind 0 edpos)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos env 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";env len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (reverse-channel 0 #f ind 0 edpos)
	      (reverse-channel 0 #f ind 0)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos rev 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";rev len edpos: ~A ~A" len (frames ind 0)))
	      (undo 2)
	      
	      (src-channel 1.0 0 #f ind 0 edpos)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if (and diff (> (car diff) .0001)) (snd-display #__line__ ";1 edpos src 1 diff: ~A" diff)))
	      (if (> (abs (- (frames ind 0) len)) 2)
		  (snd-display #__line__ ";src len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (let ((opt (optimization)))
		(set! (optimization) 0)
		(map-channel (lambda (y) y) 0 #f ind 0 edpos)
		(set! (optimization) opt))
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos map 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";map len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (ptree-channel (lambda (y) y) 0 #f ind 0 edpos)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos ptree 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";ptree len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (smooth-channel 0 len ind 0 edpos)
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";smooth len edpos: ~A ~A" len (frames ind 0)))
	      (undo)
	      
	      (clm-channel (make-one-zero 1.0 0.0) 0 #f ind 0 edpos)
	      (let ((diff (edit-difference ind 0 edpos (edit-position ind 0))))
		(if diff (snd-display #__line__ ";1 edpos clm 1 diff: ~A" diff)))
	      (if (not (= (frames ind 0) len))
		  (snd-display #__line__ ";clm len edpos: ~A ~A" len (frames ind 0)))
	      (undo))
	    
	    ;; dur of 0 is ignored no matter what -- else I have a million special cases
	    ;;   -> insert 0 at other edpos, delete 0, change 0 (x|ramp-channel) (map? etc)
	    
	    (revert-sound ind)
	    (close-sound ind)
	    
	    ;; -------- reach back with partial edit
	    (set! ind (new-sound "fmv.snd" :size 10))
	    (as-one-edit
	     (lambda ()
	       (do ((i 0 (+ 1 i)))
		   ((= i 10))
		 (set! (sample i) (* i .01)))))
	    (set! edpos (edit-position ind 0))
	    
	    (pad-channel 0 10 ind 0)
	    (pad-channel 20 10 ind 0)
	    (set! (samples 0 10 ind 0) (make-vct 10 .5))
	    (set! (samples 20 10 ind 0) (make-vct 10 -.75))
	    
	    (pad-channel 0 10 ind 0 edpos)
	    (if (not (= (frames ind 0) 20)) (snd-display #__line__ ";pad edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";pad edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (delete-samples 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 5)) (snd-display #__line__ ";del edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";del edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (set! (samples 5 5 ind 0 #f "set" 0 edpos) (make-vct 5 0.0))
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";set edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .04) (snd-display #__line__ ";set edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (ramp-channel 0.0 1.0 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";rmp edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";rmp edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (xramp-channel 0.0 1.0 32.0 5 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";xrmp edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";xrmp edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (env-channel '(0 0 1 1) 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";env edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";env edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (ptree-channel (lambda (y) y) 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";ptree edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";ptree edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (smooth-channel 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";smooth edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";smooth edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (src-channel 0.5 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 16)) (snd-display #__line__ ";src edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";src edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (reverse-channel 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";rev edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";rev edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (filter-channel (vct .1 .2 .1) 3 0 5 ind 0 edpos #t) ; truncate
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";flt edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";flt edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (scale-channel 1.5 0 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 10)) (snd-display #__line__ ";scl edpos len: ~A" (frames ind 0)))
	    (if (fneq (maxamp ind 0) .09) (snd-display #__line__ ";scl edpos max: ~A" (maxamp ind 0)))
	    (undo)
	    
	    (close-sound ind)))
	
	(let ((ind (new-sound "fmv.snd" :size 20)))
	  (map-channel (lambda (y) 1.0))
	  (let ((edpos (edit-position ind 0)))
	    (delete-samples 5 10)
	    (delete-samples 15 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 15)) (snd-display #__line__ ";delete-samples edpos len: ~A" (frames ind 0)))
	    (undo)
	    (vct->channel (make-vct 5 0.5) 15 5 ind 0 edpos)
	    (if (not (= (frames ind 0) 20)) (snd-display #__line__ ";delete-samples edpos len: ~A" (frames ind 0)))
	    (if (not (vequal (channel->vct 10 10) (vct 1.0 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5)))
		(snd-display #__line__ ";set samples edpos: ~A" (channel->vct 10 10)))
	    (undo)
	    (env-channel '(0 0 1 1) 0 #f ind 0 edpos)
	    (if (not (= (frames ind 0) 20)) (snd-display #__line__ ";env edpos len: ~A" (frames ind 0)))
	    (if (not (vequal (channel->vct 0 20) (vct 0.000 0.053 0.105 0.158 0.211 0.263 0.316 0.368 0.421 0.474 0.526 0.579 0.632 0.684 0.737 0.789 0.842 0.895 0.947 1.000)))
		(snd-display #__line__ ";env edpos: ~A" (channel->vct 0 20)))
	    (undo)
	    (ptree-channel (lambda (y) 0.5) 0 #f ind 0 edpos)
	    (if (not (= (frames ind 0) 20)) (snd-display #__line__ ";ptree edpos len: ~A" (frames ind 0)))
	    (if (not (vequal (channel->vct 0 20) (make-vct 20 0.5))) (snd-display #__line__ ";ptree edpos: ~A" (channel->vct 0 20)))
	    (undo)
	    (close-sound ind)))
	
	;; virtual filter as ptree
	(let ((ind (new-sound "fmv.snd" :size 20)))
	  (set! (sample 5) 1.0)
	  
	  ;; forward all
	  (filter-channel (vct 1.0 0.5 0.25))
	  (let ((data (channel->vct 0 20 ind 0)))
	    (undo)
	    (virtual-filter-channel (vct 1.0 0.5 0.25) 0 #f ind 0 1)
	    (let ((vdata (channel->vct 0 20 ind 0)))
	      (undo)
	      (if (not (vequal data vdata))
		  (snd-display #__line__ ";virtual filter: ~%  standard: ~A~%   virtual: ~A~%" data vdata))))
	  
	  ;; reverse all
	  (filter-channel (vct 0.25 0.5 1.0))
	  (reverse-sound)
	  (let ((data (channel->vct 3 20))) ; filter-channel assumes ring
	    (undo 2)
	    (virtual-filter-channel (vct 0.25 0.5 1.0) 0 #f ind 0 1)
	    (reverse-sound)
	    (let ((vdata (channel->vct 0 20)))
	      (undo 2)
	      (if (not (vequal data vdata))
		  (snd-display #__line__ ";reverse virtual filter: ~%  standard: ~A~%   virtual: ~A~%" data vdata))))
	  
	  ;; insert block
	  (filter-channel (vct 0.25 0.5 1.0 0.9 0.6 0.3))
	  (pad-channel 8 5)
	  (let ((data (channel->vct 0 20)))
	    (undo 2)
	    (virtual-filter-channel (vct 0.25 0.5 1.0 0.9 0.6 0.3) 0 #f ind 0 1)
	    (pad-channel 8 5)
	    (let ((vdata (channel->vct 0 20)))
	      (undo 2)
	      (if (not (vequal data vdata))
		  (snd-display #__line__ ";pad virtual filter: ~%  standard: ~A~%   virtual: ~A~%" data vdata))))
	  
	  ;; delete block
	  (filter-channel (vct 0.25 0.5 1.0 0.9 0.6 0.3))
	  (delete-samples 7 2)
	  (let ((data (channel->vct 0 20)))
	    (undo 2)
	    (virtual-filter-channel (vct 0.25 0.5 1.0 0.9 0.6 0.3) 0 #f ind 0 1)
	    (delete-samples 7 2)
	    (let ((vdata (channel->vct 0 20)))
	      (undo 2)
	      (if (not (vequal data vdata))
		  (snd-display #__line__ ";delete virtual filter: ~%  standard: ~A~%   virtual: ~A~%" data vdata))))
	  
	  ;; forward partial
	  (filter-channel (vct 1.0 0.5 0.25) 3 3 10) ; 3=order! + pre-ring?? -- this is too clever
	  (let ((data (channel->vct 0 20)))
	    (undo)
	    (virtual-filter-channel (vct 1.0 0.5 0.25) 3 10 ind 0 1)
	    (let ((vdata (channel->vct 2 20)))
	      (undo)
	      (if (not (vequal data vdata))
		  (snd-display #__line__ ";partial virtual filter: ~%  standard: ~A~%   virtual: ~A~%" data vdata))))
	  
	  ;; forward partial reversed
	  (filter-channel (vct 1.0 0.5 0.25 .6 .3) 5 2 10)
	  (reverse-sound)
	  (let ((data (channel->vct 2 20)))
	    (undo 2)
	    (virtual-filter-channel (vct 1.0 0.5 0.25 .6 .3) 2 10 ind 0 1)
	    (reverse-sound)
	    (let ((vdata (channel->vct 0 20)))
	      (undo)
	      (if (not (vequal data vdata))
		  (snd-display #__line__ ";partial virtual filter reversed: ~%  standard: ~A~%   virtual: ~A~%" data vdata))))
	  
	  (close-sound ind))
	
	(let ((ind (new-sound "fmv.snd" :size 20)))
	  (set! (sample 5) 1.0)
	  (filter-channel (vct 1.0 0.5))
	  (filter-channel (vct 1.0 0.5))
	  (let ((data (channel->vct 0 20)))
	    (undo 2)
	    (let ((v (convolve-coeffs (vct 1.0 0.5) (vct 1.0 0.5))))
	      (filter-channel v)
	      (let ((vdata (channel->vct 0 20)))
		(if (not (vequal data vdata)) 
		    (snd-display #__line__ ";filter convolved: ~%  standard: ~A~%   virtual: ~A~%" data vdata)))
	      (undo)))
	  (let ((v1 (make-vct 8))
		(v2 (make-vct 5)))
	    (do ((i 0 (+ 1 i))) ((= i 8)) (vct-set! v1 i (random 1.0)))
	    (do ((i 0 (+ 1 i))) ((= i 5)) (vct-set! v2 i (random 1.0)))
	    (filter-channel v1)
	    (filter-channel v2)
	    (let ((data (channel->vct 0 20)))
	      (undo 2)
	      (let ((v (convolve-coeffs v1 v2)))
		(filter-channel v)
		(let ((vdata (channel->vct 0 20)))
		  (if (not (vequal data vdata)) 
		      (snd-display #__line__ ";random filter convolved: ~%  standard: ~A~%   virtual: ~A~%" data vdata)))
		(undo))))
	  (let ((v1 (make-vct 18))
		(v2 (make-vct 15)))
	    (do ((i 0 (+ 1 i))) ((= i 18)) (vct-set! v1 i (random 1.0)))
	    (do ((i 0 (+ 1 i))) ((= i 15)) (vct-set! v2 i (random 1.0)))
	    (filter-channel v1)
	    (filter-channel v2)
	    (let ((data (channel->vct 0 20)))
	      (undo 2)
	      (let ((v (convolve-coeffs v1 v2)))
		(filter-channel v)
		(let ((vdata (channel->vct 0 20)))
		  (if (not (vequal data vdata)) 
		      (snd-display #__line__ ";big random filter convolved: ~%  standard: ~A~%   virtual: ~A~%" data vdata)))
		(undo))))
	  (close-sound ind))
	
	(let ((ind (new-sound "fmv.snd" :size 100)))
	  (set! (sample 5) .5)
	  (set! (sample 85) .5)
	  
	  (src-channel -1.001) ; avoid optimization
	  (src-channel '(0 -1.0 1 -1.0) 0 #f ind 0 2)
	  (let ((dis (edit-distance ind 0 3 4)))
	    (if (> dis .2) (snd-display #__line__ ";src-channel -1, distance: ~A" dis)))
	  (undo 2)
	  
	  (src-channel 1.001) ; avoid optimization
	  (src-channel '(0 1.0 1 1.0) 0 #f ind 0 2)
	  (let ((dis (edit-distance ind 0 3 4)))
	    (if (> dis .2) (snd-display #__line__ ";src-channel 1, distance: ~A" dis)))
	  (undo 2)
	  
	  (for-each
	   (lambda (rate)
	     (src-channel rate)
	     (src-channel (list 0 rate 1 rate) 0 #f ind 0 2)
	     (let ((dis (edit-distance ind 0 3 4)))
	       (if (> dis .2) (snd-display #__line__ ";src-channel ~A, distance: ~A" rate dis)))
	     (undo 2))
	   (list 2.0 -2.0 0.5 -0.5 1.5 -1.5 3.0 -3.0 0.2 -0.2))
	  
	  
	  (src-sound -1.001) ; avoid optimization
	  (src-sound '(0 -1.0 1 -1.0) 1.0 ind 0 2)
	  (let ((dis (edit-distance ind 0 3 4)))
	    (if (> dis .2) (snd-display #__line__ ";src-sound -1, distance: ~A" dis)))
	  (undo 2)
	  
	  (src-sound 1.001) ; avoid optimization
	  (src-sound '(0 1.0 1 1.0) 1.0 ind 0 2)
	  (let ((dis (edit-distance ind 0 3 4)))
	    (if (> dis .2) (snd-display #__line__ ";src-sound 1, distance: ~A" dis)))
	  (undo 2)
	  
	  (for-each
	   (lambda (rate)
	     (src-sound rate)
	     (src-sound (list 0 rate 1 rate) 1.0 ind 0 2)
	     (let ((dis (edit-distance ind 0 3 4)))
	       (if (> dis .2) (snd-display #__line__ ";src-sound ~A, distance: ~A" rate dis)))
	     (undo 2))
	   (list 2.0 -2.0 0.5 -0.5 1.5 -1.5 3.0 -3.0 0.2 -0.2))
	  
	  (close-sound ind))
	
	
	;; additional coverage tests
	
	(let ((ind (new-sound "test.snd" :size 10)))
	  (vct->channel (make-vct 10 .4))
	  (make-selection 3 7) ; beg end just for confusion
	  (env-selection '(0 0.5 1 0.5))
	  (let ((data (channel->vct)))
	    (if (not (vequal data (vct .4 .4 .4 .2 .2 .2 .2 .2 .4 .4)))
		(snd-display #__line__ ";env-selection constant: ~A" data)))
	  (undo)
	  (let ((edpos (edit-position ind 0)))
	    (smooth-channel 10 10 ind 0)
	    (if (not (= (edit-position ind 0) edpos))
		(snd-display #__line__ ";smooth past end: ~A ~A" (edit-position ind 0) edpos))
	    
	    (let ((ctr 0))
	      (map-channel (lambda (y) (set! ctr (+ 1 ctr)) (if (> ctr 3) #t (* y 2)))))
	    (if (not (= (frames ind 0) 3)) 
		(snd-display #__line__ ";map-channel -> #t at 3: ~A" (frames ind 0))
		(if (not (vequal (channel->vct) (vct 0.8 0.8 0.8)))
		    (snd-display #__line__ ";map-channel #t result: ~A" (channel->vct))))
	    
	    (undo)
	    (let ((ctr 0))
	      (map-channel (lambda (y) (set! ctr (+ 1 ctr)) (if (= ctr 3) (make-vct 5 .1) (* y .5)))))
	    (if (not (= (frames ind 0) 14)) 
		(snd-display #__line__ ";map-channel -> vct at 3: ~A" (frames ind 0))
		(if (not (vequal (channel->vct) (vct 0.200 0.200 0.100 0.100 0.100 0.100 0.100 0.200 0.200 0.200 0.200 0.200 0.200 0.200)))
		    (snd-display #__line__ ";map-channel vct result: ~A" (channel->vct))))
	    
	    (undo)
	    (let ((data (make-vct 2 0.0)))
	      (map-channel (lambda (y) (vct-set! data 0 y) data)))
	    (if (not (= (frames ind 0) 20))
		(snd-display #__line__ ";map-channel -> vct ptree: ~A" (frames ind 0))
		(if (not (vequal (channel->vct) (vct 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000 0.400 0.000)))
		    (snd-display #__line__ ";map-channel vct ptree result: ~A" (channel->vct))))
	    
	    (undo))
	  
	  (set! (amp-control ind) 2.0)
	  (apply-controls ind 1 0)
	  (if (> (abs (- (maxamp ind 0) .8)) .01) (snd-display #__line__ ";apply-controls 10: ~A" (channel->vct)))
	  (undo)
	  (set! (amp-control ind) 2.0)
	  (apply-controls ind 1 5)
	  (if (not (vequal (channel->vct 0 5) (vct 0.4 0.4 0.4 0.4 0.4)))
	      (snd-display #__line__ ";apply controls from 5: ~A" (channel->vct)))
	  (if (ffneq (sample 5) .8) (snd-display #__line__ ";apply-controls at 5: ~A" (sample 5)))
	  (let ((tag (catch 'no-such-edit
			    (lambda ()
			      (save-sound-as "nope.snd" :edit-position 21))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-edit)) (snd-display #__line__ ";save-sound-as at bad edpos: ~A" tag)))
	  (let ((tag (catch 'no-such-file
			    (lambda ()
			      (channel-amp-envs "/baddy/hiho"))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-file)) (snd-display #__line__ ";channel-amp-envs bad file: ~A" tag)))
	  
	  (close-sound ind))
	
	
	(let ((ind (open-sound "oboe.snd")))
	  (let ((ctr 0))
	    (map-channel (lambda (y) (set! ctr (+ 1 ctr)) (if (> ctr 3) #t (* y 2)))))
	  (if (not (= (frames ind 0) 3)) 
	      (snd-display #__line__ ";map-channel oboe -> #t at 3: ~A" (frames ind 0))
	      (if (not (vequal (channel->vct) (vct 0.0 -.001 -.001)))
		  (snd-display #__line__ ";map-channel #t oboe result: ~A" (channel->vct))))
	  
	  (undo)
	  (let ((ctr 0))
	    (map-channel (lambda (y) (set! ctr (+ 1 ctr)) (if (= ctr 3) (make-vct 5 .1) (* y .5)))))
	  (if (not (= (frames ind 0) (+ 50828 4)))
	      (snd-display #__line__ ";map-channel oboe -> vct at 3: ~A" (frames ind 0))
	      (if (not (vequal (channel->vct 0 10) (vct 0.000 -0.000 0.100 0.100 0.100 0.100 0.100 -0.000 -0.000 -0.000)))
		  (snd-display #__line__ ";map-channel vct result: ~A" (channel->vct 0 10))))
	  
	  (undo)
	  (let ((data (make-vct 2 0.0)))
	    (map-channel (lambda (y) (vct-set! data 0 y) data)))
	  (if (not (= (frames ind 0) (* 2 50828)))
	      (snd-display #__line__ ";map-channel oboe -> vct ptree: ~A" (frames ind 0))
	      (if (not (vequal (channel->vct 0 10) (vct 0.000 0.000 -0.000 0.000 -0.000 0.000 -0.000 0.000 -0.000 0.0)))
		  (snd-display #__line__ ";map-channel vct ptree result: ~A" (channel->vct 0 10))))
	  (revert-sound)
	  (close-sound ind))
	
	(let ((ind (open-sound "2.snd")))
	  (ramp-channel 0.9 1.0)
	  (ramp-channel 0.9 1.0)
	  (xramp-channel 0.9 1.0 32.0)
	  (xramp-channel 0.9 1.0 32.0)
	  (mix-vct (vct .01 .02) 10000 ind 0 #t)
	  (set! (sync ind) 1)
	  (let ((mxs (maxamp ind #t)))
	    (env-sound '(0 .25 1 0.5))
	    (let ((mxs1 (maxamp ind #t)))
	      (if (or (fneq (car mxs) (* 2.0 (car mxs1)))
		      (fneq (cadr mxs) (* 2.0 (cadr mxs1))))
		  (snd-display #__line__ ";env-sound sync'd maxes: ~A -> ~A" mxs mxs1)))
	    (undo 1))
	  (close-sound ind))
	
	
	(let ((ind (new-sound :channels 2 :size 10 :comment "new-sound for ramp2-xramp2")))
	  (map-channel (lambda (y) 1.0))
	  (ramp-channel 0.9 1.0)
	  (ramp-channel 0.9 1.0)
	  (xramp-channel 0.9 1.0 32.0)
	  (xramp-channel 0.9 1.0 32.0)
	  (mix-vct (vct .1 .2) 1 ind 0 #t)	  
	  (set! (sync ind) 1)
	  (let ((mxs (maxamp ind #t)))
	    (env-sound '(0 .25 1 0.5))
	    (let ((mxs1 (maxamp ind #t)))
	      (if (or (fneq (car mxs) (* 2.0 (car mxs1)))
		      (fneq (cadr mxs) (* 2.0 (cadr mxs1))))
		  (snd-display #__line__ ";env-sound sync'd maxes buf: ~A -> ~A" mxs mxs1)))
	    (undo 1))
	  (let ((name (file-name ind)))
	    (if (not (= (srate ind) (default-output-srate)))
		(snd-display #__line__ ";new-sound default srate: ~A ~A" (srate ind) (default-output-srate)))
	    (close-sound ind)
	    (if (not (file-exists? name))
		(snd-display #__line__ ";new-sound temp? ~A" name)
		(delete-file name))))
	
	))
    ))



;;; ---------------- test 17: dialogs and graphics ----------------

(if (not (provided? 'snd-draw.scm)) (load "draw.scm")) ; needed also in test_21 (color-samples)
(if with-gui
    (if (not (provided? 'snd-musglyphs.scm)) (load "musglyphs.scm")))

(define (snd_test_17)
  
  (define (-> x0 y0 size snd chn)
    "draw an arrow pointing (from the left) at the point (x0 y0)"
    (let ((points (make-vector 8)))
      (define (point i x y)
	(vector-set! points (* i 2) x)
	(vector-set! points (+ (* i 2) 1) y))
      (define (arrow-head x y)
	(point 0 x y)
	(point 1 (- x (* 2 size)) (- y size))
	(point 2 (- x (* 2 size)) (+ y size))
	(point 3 x y)
	(fill-polygon points snd chn))
      (arrow-head x0 y0)
      (fill-rectangle (- x0 (* 4 size)) 
		      (floor (- y0 (* .4 size)))
		      (* 2 size)
		      (floor (* .8 size))
		      snd chn)))  
  
  (if with-gui
      (begin
	
	(if (not (provided? 'snd-musglyphs.scm)) (load "musglyphs.scm"))
	(add-hook! after-graph-hook display-previous-edits)
	(add-hook! lisp-graph-hook 
		   (lambda (snd chn)
		     (lambda ()
		       (draw-string "hi" 
				    (x->position .5 snd chn lisp-graph) 
				    (y->position .5 snd chn lisp-graph)
				    snd chn))))
	(let* ((ind (open-sound "oboe.snd"))
	       (wids (channel-widgets))
	       (wids1 (channel-widgets (selected-sound)))
	       (wids2 (channel-widgets (selected-sound) (selected-channel))))
	  (do ((i 1 (+ 1 i)))
	      ((= i 4))
	    (scale-by 0.5)
	    (set! (x-bounds) (list 0 (* i .3))))
	  (revert-sound ind)
	  (draw-bass-clef 100 100 100 0 ind 0)
	  (update-time-graph ind 0)
	  (draw-fermata 200 100 60 0 ind 0)
	  (draw-line 100 100 200 200 ind 0)
	  (draw-dot 300 300 10 ind 0)
	  (draw-string "hiho" 20 20 ind 0)
	  (draw-dots '#(25 25 50 50 100 100) 10 ind 0)
	  (-> 100 50 10 ind 0)
	  (fill-rectangle 20 20 100 100 ind 0)
	  (make-bezier 0 0 20 20 40 30 60 10 10)
	  (update-time-graph ind 0)
	  (fill-rectangle 20 20 100 100 ind 0 time-graph #t)
	  (reset-hook! after-graph-hook)
	  (reset-hook! lisp-graph-hook)
	  
	  (reset-hook! lisp-graph-hook)
	  (let ((ind (open-sound "oboe.snd")))
	    (set! (time-graph? ind 0) #f)
	    (graph (list (vct 0 1 2) (vct 3 2 1) (vct 1 2 3) (vct 1 1 1) (vct 0 1 0) (vct 3 1 2)))
	    (update-lisp-graph)
	    (add-hook! lisp-graph-hook (lambda (snd chn)
					 (list (basic-color) (zoom-color) (data-color) (selected-data-color) (mix-color))))
	    (graph (list (vct 0 1 2) (vct 3 2 1) (vct 1 2 3) (vct 1 1 1) (vct 0 1 0) (vct 3 1 2)))
	    (update-lisp-graph)
	    (reset-hook! lisp-graph-hook)
	    (close-sound ind))
	  
	  (let* ((ind1 (open-sound "2.snd"))
		 (wids3 (channel-widgets ind1 0))
		 (wids4 (channel-widgets ind1 1)))
	    (if (or (not (list-p wids))
		    (not (list-p wids3))
		    (and (provided? 'snd-motif)
			 (or (not (= (length wids1) 11))
			     (not (= (length wids2) 11)))))
		(snd-display #__line__ ";channel-widgets confused: ~A ~A ~A ~A ~A" wids wids1 wids2 wids3 wids4))
	    (hide-widget (car (channel-widgets)))
	    (show-widget (car (channel-widgets)))
	    (close-sound ind1))
	  (close-sound ind))
	
	)))


;;; ---------------- test 18: enved ----------------

(if (not (provided? 'snd-enved.scm)) (load "enved.scm"))

(define (snd_test_18)
  (if with-gui
      (begin
	(start-enveloping)
	(let ((nind (open-sound "oboe.snd")))
	  (if (not (equal? (channel-envelope nind 0) (list 0.0 1.0 1.0 1.0)))
	      (snd-display #__line__ ";channel-envelope: ~A?" (channel-envelope nind 0)))
	  (set! (channel-envelope nind 0) (list 0 0 1 1 2 0))
	  (if (not (equal? (channel-envelope nind 0) (list 0 0 1 1 2 0)))
	      (snd-display #__line__ ";set channel-envelope: ~A?" (channel-envelope nind 0)))
	  (close-sound nind)
	  (stop-enveloping))
	)))


;;; ---------------- test 19: save and restore ----------------

(if (not (provided? 'snd-fade.scm)) (load "fade.scm"))

(define after-save-state-hook-var 0) ; global for load save-state stuff

(define* (clm-channel-test snd chn) ; edit-list->function wants this to be global??
  (clm-channel (make-two-zero 1 -1) 0 #f snd chn #f #f "clm-channel-test"))

(define* (make-v-mix snd chn)
  (mix-vct (vct .1 .2 .3) 100 snd chn #t "mix-vct (vct .1 .2 .3)"))

(define (snd_test_19)
  
  (define* (hilbert-transform-via-fft snd chn)
    "same as FIR version but use FFT and change phases by hand"
    (let* ((size (frames snd chn))
	   (len (expt 2 (ceiling (/ (log size) (log 2.0)))))
	   (rl (make-vct len))
	   (im (make-vct len))
	   (rd (make-sampler 0 snd chn)))
      (do ((i 0 (+ 1 i)))
	  ((= i size))
	(vct-set! rl i (rd)))
      (mus-fft rl im len)
      (do ((i 0 (+ 1 i)))
	  ((= i len))
	(let* ((c (make-rectangular (vct-ref rl i) (vct-ref im i)))
	       (ph (angle c))
	       (mag (magnitude c)))
	  (if (< i (/ len 2))
	      (set! ph (+ ph (* 0.5 pi)))
	      (set! ph (- ph (* 0.5 pi))))
	  (set! c (make-polar mag ph))
	  (vct-set! rl i (real-part c))
	  (vct-set! im i (imag-part c))))
      (mus-fft rl im len -1)
      (vct-scale! rl (/ 1.0 len))
      (vct->channel rl 0 len snd chn #f "hilbert-transform-via-fft")))
  
  ;; echoes with each echo at a new pitch via ssb-am etc
  
  (define* (make-ssb-transposer old-freq new-freq pairs (order 40) (bw 50.0))
    (let* ((ssbs (make-vector pairs))
	   (bands (make-vector pairs))
	   (factor (/ (- new-freq old-freq) old-freq)))
      (do ((i 1 (+ 1 i)))
	  ((> i pairs))
	(let* ((aff (* i old-freq))
	       (bwf (* bw (+ 1.0 (/ i (* 2 pairs))))))
	  (vector-set! ssbs (- i 1) (make-ssb-am (* i factor old-freq)))
	  (vector-set! bands (- i 1) (make-bandpass (hz->radians (- aff bwf)) 
						    (hz->radians (+ aff bwf)) 
						    order))))
      (list ssbs bands)))
  
  (define (ssb-transpose transposer input)
    (let* ((sum 0.0)
	   (ssbs (car transposer))
	   (bands (cadr transposer))
	   (pairs (vector-length ssbs)))
      (do ((i 0 (+ 1 i)))
	  ((= i pairs) sum)
	(set! sum (+ sum (ssb-am (vector-ref ssbs i) 
				 (bandpass (vector-ref bands i) 
					   input)))))))
  
  (define (fdelay gen input)
    (gen input))	
  
  (define (make-fdelay len pitch scaler)
    (let ((dly (make-delay len))
	  (ssb (make-ssb-transposer 440.0 (* 440.0 pitch) 10)))
      (lambda (input)
	(delay dly (+ input (* scaler (ssb-transpose ssb (tap dly))))))))
  
  (define (transposed-echo pitch scaler secs)
    (let ((del (make-fdelay (round (* secs (srate))) pitch scaler)))
      (map-channel (lambda (y) (fdelay del y)))))
  
  (define (local-eq? a b)
    (if (number? a)
	(if (rational? a)
	    (= a b)
	    (< (abs (- a b)) .001))
	(eq? a b)))
  
  ;; from dsp.scm (commented out)
  (define (repitch-sound old-freq new-freq)
    (ssb-bank old-freq new-freq 10))
  
  (define (retime-sound new-time)
    (let* ((old-time (/ (frames) (srate)))
	   (factor (/ new-time old-time)))
      (ssb-bank 557 (* 557 factor) 10)
      (src-sound (/ 1.0 factor))))
  
  (let ((nind (open-sound "oboe.snd")))
    (add-mark 123)
    (delete-sample 12)
    (set! (x-bounds) (list .2 .4))
    (let ((old-bounds (x-bounds)))
      (set! (show-axes) show-all-axes)
      (set! (transform-graph-type) graph-as-sonogram)
      (set! (speed-control-style) speed-control-as-ratio)
      (set! (channel-style) channels-superimposed)
      (set! (enved-target) enved-srate)
      (set! (sound-property :hi nind) "hi")
      (set! (sound-property 'ho nind) 1234)
      (set! (channel-property :ha nind 0) 3.14)
      (reset-hook! after-save-state-hook)
      (add-hook! before-save-state-hook 
		 (lambda (name) 
		   (with-output-to-file name
		     (lambda ()
		       (display (format #f ";this comment will be at the top of the saved state file.~%~%"))
		       #t))))
      (if (defined? 'open)
	  (add-hook! after-save-state-hook
		     (lambda (filename)
		       (let ((fd (open filename (logior O_RDWR O_APPEND))))
			 (format fd "~%~%(set! after-save-state-hook-var 1234)~%")
			 (close fd)))))
      (if (file-exists? (save-state-file)) (delete-file (save-state-file)))
      (save-state (save-state-file))
      (close-sound nind)
      (for-each forget-region (regions))
      (load (string-append cwd (save-state-file)))
      (let ((ind (find-sound "oboe.snd")))
	(if (not (sound? ind))
	    (snd-display #__line__ ";can't restore oboe.snd from ~A?" (save-state-file))
	    (begin
	      (if (or (> (abs (- (car old-bounds) (car (x-bounds ind 0)))) .05)
		      (> (abs (- (cadr old-bounds) (cadr (x-bounds ind 0)))) .05))
		  (snd-display #__line__ ";save bounds: ~A" (x-bounds ind 0)))
	      (if (not (= (length (marks ind 0)) 1))
		  (snd-display #__line__ ";save marks: ~A (~A)?" (marks ind 0) (save-state-file))
		  (begin
		    (if (not (= (mark-sample (car (marks ind 0))) 122))
			(snd-display #__line__ ";save mark: ~A?" (mark-sample (car (marks ind 0)))))
		    (if (not (= (edit-position ind 0) 1))
			(snd-display #__line__ ";save edit-position: ~A" (edit-position ind 0)))))
	      (if (not (equal? (edit-fragment 1 ind 0) (list "delete-samples 12 1" "delete" 12 1)))
		  (snd-display #__line__ ";save edits: ~A" (edit-fragment 1 ind 0)))
	      (if (not (equal? (edit-tree ind 0) 
			       (list (list 0 0 0 11 1.0 0.0 0.0 0) (list 12 0 13 50827 1.0 0.0 0.0 0) (list 50827 -2 0 0 0.0 0.0 0.0 0))))
		  (snd-display #__line__ ";save edit tree: ~A" (edit-tree ind 0)))
	      (if (or (not (number? (sound-property 'ho ind)))
		      (not (= (sound-property 'ho ind) 1234)))
		  (snd-display #__line__ ";sound-property saved: 1234 -> ~A" (sound-property 'ho ind)))
	      (if (or (not (string? (sound-property :hi ind)))
		      (not (string=? (sound-property :hi ind) "hi")))
		  (snd-display #__line__ ";sound-property saved: hi -> ~A" (sound-property :hi ind)))
	      (if (or (not (number? (channel-property :ha ind 0)))
		      (fneq (channel-property :ha ind 0) 3.14))
		  (snd-display #__line__ ";channel-property saved: 3.14 -> ~A" (channel-property :ha ind 0)))
	      (close-sound ind)))
	(if (not (= after-save-state-hook-var 1234))
	    (snd-display #__line__ ";after-save-state-hook: ~A" after-save-state-hook-var))
	(reset-hook! after-save-state-hook)
	(reset-hook! before-save-state-hook)
	
	(let ((err (catch 'cannot-save
			  (lambda () 
			    (save-state "/bad/bad.save"))
			  (lambda args 12345))))
	  (if (not (= err 12345)) (snd-display #__line__ ";save-state err: ~A?" err)))
	
	(let ((err (catch 'cannot-save
			  (lambda () 
			    (save-listener "/bad/bad.save"))
			  (lambda args 12345))))
	  (if (not (= err 12345)) (snd-display #__line__ ";save-listener err: ~A?" err)))
	))
    (set! nind (open-sound "oboe.snd"))
    (set! (sample 1) .5)
    (delete-sample 100)
    (insert-sample 10 .5)
    (scale-channel 2.0)
    (insert-silence 100 20)
    (save-edit-history "hiho.scm")
    (revert-sound nind)
    (set! sfile nind)
    (load (string-append cwd "hiho.scm"))
    (if (not (equal? (edit-fragment 1) '("set-sample 1 0.5000" "set" 1 1))) (snd-display #__line__ ";save-edit-history 1: ~A?" (edit-fragment 1)))
    (if (not (equal? (edit-fragment 2) '("delete-samples 100 1" "delete" 100 1))) (snd-display #__line__ ";save-edit-history 2: ~A?" (edit-fragment 2)))
    (if (not (equal? (edit-fragment 3) '("insert-sample 10 0.5000" "insert" 10 1))) (snd-display #__line__ ";save-edit-history 3: ~A?" (edit-fragment 3)))
    (if (not (equal? (edit-fragment 4) '("scale-channel 2.000 0 #f" "scale" 0 50828))) (snd-display #__line__ ";save-edit-history 4: ~A?" (edit-fragment 4)))
    (if (not (equal? (edit-fragment 5) '("pad-channel" "zero" 100 20))) (snd-display #__line__ ";save-edit-history 5: ~A?" (edit-fragment 5)))
    (save-edit-history "hiho.scm" nind 0)
    (scale-sound-to 1.0 0 (frames nind 0) nind 0)
    (let ((eds (edit-position nind 0))
	  (val (insert-sound "zero.snd")))
      (if (or (not (= 0 val))
	      (not (= eds (edit-position nind 0))))
	  (snd-display #__line__ ";insert-sound zero.snd was an edit? ~A ~A ~A" val eds (edit-position nind 0))))
    (revert-sound nind)
    (scale-sound-to 0.5 0 (frames nind 0) nind 0)
    (if (fneq (maxamp nind 0) 0.5) (snd-display #__line__ ";scale-sound-to 0.5: ~A" (maxamp nind)))
    (close-sound nind)
    
    (let ((nind (open-sound "oboe.snd")))
      (ramp-channel 0.0 1.0)
      (xramp-channel 0.0 1.0 32.0)
      (save-edit-history "hiho.scm")
      (revert-sound nind)
      (set! sfile nind)
      (load (string-append cwd "hiho.scm"))
      (if (not (equal? (edit-fragment 1) '("ramp-channel 0.000 1.000 0 #f" "env" 0 50828)))
	  (snd-display #__line__ ";save-edit-history ramp 1: ~A?" (edit-fragment 1)))
      (if (not (equal? (edit-fragment 2) '("xramp-channel 0.000 1.000 32.000 0 #f" "env" 0 50828)))
	  (snd-display #__line__ ";save-edit-history xramp 2: ~A?" (edit-fragment 2)))
      (revert-sound nind)
      (let ((str (file->string "hiho.scm")))
	(if (not (string=? str "      (ramp-channel 0.000 1.000 0 #f sfile 0 #f)
      (xramp-channel 0.000 1.000 32.000 0 #f sfile 0 #f)
"))
	    (snd-display #__line__ ";file->string: ~A" str)))
      (let ((old-opt (optimization)))
	(set! (optimization) 5)
	(ptree-channel (lambda (y) (* y 2)))
	(save-edit-history "hiho.scm")
	(revert-sound nind)
	(set! sfile nind)
	(load (string-append cwd "hiho.scm"))
	(set! (optimization) old-opt))
      (if (not (equal? (edit-fragment 1) '("ptree-channel" "ptree" 0 50828)))
	  (snd-display #__line__ ";save-edit-history ptree 1: ~A?" (edit-fragment 1)))
      (close-sound nind))
    
    (let ((ind (open-sound "oboe.snd")))
      (set! (speed-control ind) 2/3)
      (set! (filter-control-envelope ind) (list 0.0 0.0 1.0 1.0))
      (set! (sound-property :hi ind) 12345)
      (insert-samples 0 100 (make-vct 100 .1) ind 0) ; need data to force save-state-hook to be called
      (reset-hook! save-state-hook)
      (add-hook! save-state-hook (lambda (filename) "savehook.snd"))
      (save-state "s61.scm")
      (close-sound ind)
      (if (not (file-exists? "savehook.snd"))
	  (snd-display #__line__ ";save-state-hook redirect failed? ~A" (hook->list save-state-hook))
	  (begin
	    (load (string-append cwd "s61.scm"))
	    (set! ind (find-sound "oboe.snd"))
	    (if (not (sound? ind))
		(snd-display #__line__ ";save-state after hook restored but no sound?")
		(begin
		  (if (fneq (speed-control ind) .6667) (snd-display #__line__ ";save-state w/hook speed: ~A" (speed-control ind)))
		  (if (or (not (number? (sound-property :hi ind)))
			  (not (= (sound-property :hi ind) 12345)))
		      (snd-display #__line__ ";save-state w/hook hi: ~A" (sound-property :hi ind)))
		  (if (not (feql (filter-control-envelope ind) (list 0.0 0.0 1.0 1.0)))
		      (snd-display #__line__ ";save-state w/hook filter env: ~A" (filter-control-envelope ind)))
		  ;; now check that save-state-hook is not called by other funcs
		  (reset-hook! save-state-hook)
		  (add-hook! save-state-hook (lambda (file) (snd-display #__line__ ";bogus save-state-hook call!") "edit-list-to-function-saved.snd"))
		  (let ((func (edit-list->function ind 0)))
		    (if (file-exists? "edit-list-to-function-saved.snd")
			(begin
			  (snd-display #__line__ ";edit-list->function called save-state-hook")
			  (delete-file "edit-list-to-function-saved.snd"))))
		  (save-edit-history "save-edit-history-saved.scm" ind 0)
		  (if (file-exists? "edit-list-to-function-saved.snd")
		      (begin
			(snd-display #__line__ ";save-edit-history called save-state-hook")
			(delete-file "edit-list-to-function-saved.snd")))
		  (delete-file "save-edit-history-saved.scm")
		  (delete-file "savehook.snd")
		  (close-sound ind)))))
      (delete-file "s61.scm")
      (reset-hook! save-state-hook))
    
    (add-sound-file-extension "ogg")
    (add-sound-file-extension "OGG")
    (add-sound-file-extension "sf")
    (add-sound-file-extension "SF2")
    (add-sound-file-extension "mp3")
    (add-sound-file-extension "MP3")
    (add-sound-file-extension "W01")
    (add-sound-file-extension "W02")
    (add-sound-file-extension "W03")
    (add-sound-file-extension "W04")
    (add-sound-file-extension "W05")
    (add-sound-file-extension "W06")
    (add-sound-file-extension "W07")
    (add-sound-file-extension "W08")
    (add-sound-file-extension "W09")
    (add-sound-file-extension "W10")
    (add-sound-file-extension "w01")
    (add-sound-file-extension "w02")
    (add-sound-file-extension "w03")
    (add-sound-file-extension "w04")
    (add-sound-file-extension "w05")
    (add-source-file-extension "gad")
    
    (let ((ind (new-sound "fmv.snd")))
      (set! (sample 10) .1)
      (save-sound ind)
      (set! (sample 1) .1)
      (let ((eds (safe-display-edits ind)))
	(if (file-exists? "t1.scm") (delete-file "t1.scm"))
	(save-state "t1.scm")
	(close-sound ind)
	(for-each forget-region (regions))
	(load (string-append cwd "t1.scm"))
	(set! ind (find-sound "fmv.snd"))
	(if (not (sound? ind))
	    (snd-display #__line__ ";save-state restored but no sound?"))
	(do ((i 3 (+ 1 i)))
	    ((= i 6))
	  (set! (sample i) (* i .1))
	  (set! eds (safe-display-edits ind))
	  (if (file-exists? "t1.scm") (delete-file "t1.scm"))
	  (save-state "t1.scm")
	  (close-sound ind)
	  (for-each forget-region (regions))
	  (load (string-append cwd "t1.scm"))
	  (set! ind (find-sound "fmv.snd"))
	  (if (not (sound? ind))
	      (snd-display #__line__ ";save-state ~A restored but no sound?" i))))
      (close-sound ind)
      (delete-file "t1.scm"))
    
    (let ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 8 "this is an 8-channel save-state test"))
	  (ind1 (new-sound "fmv1.snd" mus-next mus-bshort 22050 2 "this is a 2-channel save-state test")))
      (set! (sample 10 ind 0) .1)
      (set! (sample 10 ind 1) .2)
      (set! (sample 10 ind 2) .3)
      (set! (sample 10 ind 3) .4)
      (set! (sample 10 ind1 0) -.1)
      (set! (sample 10 ind1 1) -.2)
      (save-sound ind)
      (save-sound ind1)
      (set! (sample 1 ind 0) .1)
      (set! (sample 1 ind 1) .2)
      (set! (sample 1 ind 2) .3)
      (set! (sample 1 ind 3) .4)
      (set! (sample 1 ind1 0) -.1)
      (set! (sample 1 ind1 1) -.2)
      (let ((eds (safe-display-edits ind))
	    (eds1 (safe-display-edits ind1)))
	(if (file-exists? "t1.scm") (delete-file "t1.scm"))
	(save-state "t1.scm")
	(close-sound ind)
	(close-sound ind1)
	(for-each forget-region (regions))
	(load (string-append cwd "t1.scm"))
	(set! ind (find-sound "fmv.snd"))
	(set! ind1 (find-sound "fmv1.snd"))
	(if (or (not (sound? ind))
		(not (sound? ind1)))
	    (snd-display #__line__ ";save-state(2) restored but no sound? ~A ~A" ind ind1)))
      (close-sound ind)
      (close-sound ind1)
      (delete-file "t1.scm"))
    
    (let ((ind (open-sound "oboe.snd"))
	  (old-save-dir (save-dir))
	  (old-eps-file (eps-file)))
      (set! (save-dir) #f)
      (let ((v (make-vct 32 1.0)))
	(set! (samples 100 32) v))
      (map-channel (lambda (y) (+ y .1)) 1000 10000)
      (set! (show-axes ind 0) show-no-axes)
      (set! (zoom-focus-style) zoom-focus-middle)
      (set! (transform-normalization ind 0) dont-normalize)
      (set! (graph-style ind 0) graph-filled)
      (set! (transform-graph-type ind 0) graph-as-spectrogram)
      (set! (time-graph-type ind 0) graph-as-wavogram)
      (set! (x-axis-style ind 0) x-axis-as-percentage)
      (set! (speed-control-style ind) speed-control-as-semitone)
      (set! (cursor ind 0) 1234)
      (set! (eps-file) "hiho.eps")
      (set! (amp-control-bounds ind) (list 0.0 2.5))
      (set! (speed-control-bounds ind) (list 1.0 2.5))
      (set! (reverb-control-scale-bounds ind) (list 0.0 2.5))
      (set! (reverb-control-length-bounds ind) (list 0.0 2.5))
      (set! (contrast-control-bounds ind) (list 0.0 2.5))
      (set! (x-axis-label ind 0 time-graph) "time-x")
      (set! (y-axis-label ind 0 time-graph) "amp-y")
      (let ((old-srate (mus-srate))
	    (old-file-buffer-size (mus-file-buffer-size))
	    (old-array-print-length (mus-array-print-length))
	    (old-clm-table-size (clm-table-size)))
	(set! (mus-srate) 48000)
	(set! (mus-array-print-length) 24)
	(set! (mus-file-buffer-size) 4096)
	(set! (clm-table-size) 256)
	(if (file-exists? "s61.scm") (delete-file "s61.scm"))
	(save-state "s61.scm")
	(close-sound ind)
	(for-each forget-region (regions))
	(load (string-append cwd "s61.scm"))
	(if (fneq (mus-srate) 48000.0) (snd-display #__line__ ";save/restore mus-srate: ~A" (mus-srate)))
	(if (not (= (mus-file-buffer-size) 4096)) (snd-display #__line__ ";save/restore mus-file-buffer-size: ~A" (mus-file-buffer-size)))
	(if (not (= (mus-array-print-length) 24)) (snd-display #__line__ ";save/restore mus-array-print-length: ~A" (mus-array-print-length)))
	(if (not (= (clm-table-size) 256)) (snd-display #__line__ ";save/restore clm-table-size: ~A" (clm-table-size)))
	(set! (mus-srate) old-srate)
	(set! (mus-array-print-length) old-array-print-length)
	(set! (mus-file-buffer-size) old-file-buffer-size)
	(set! (clm-table-size) old-clm-table-size))
      (set! (save-dir) old-save-dir)
      (set! ind (find-sound "oboe.snd"))
      (if (not (= (show-axes ind 0) show-no-axes)) (snd-display #__line__ ";save show-no-axes: ~A" (show-axes ind 0)))
      (if (not (= (zoom-focus-style) zoom-focus-middle)) (snd-display #__line__ ";save zoom-focus-middle: ~A" (zoom-focus-style)))
      (if (not (= (transform-normalization ind 0) dont-normalize)) (snd-display #__line__ ";save dont-normalize: ~A" (transform-normalization ind 0)))
      (if (not (= (graph-style ind 0) graph-filled)) (snd-display #__line__ ";save graph-filled: ~A" (graph-style ind 0)))
      (if (not (= (transform-graph-type ind 0) graph-as-spectrogram)) (snd-display #__line__ ";save graph-as-spectrogram: ~A" (transform-graph-type ind 0)))
      (if (not (= (time-graph-type ind 0) graph-as-wavogram)) (snd-display #__line__ ";save graph-as-wavogram: ~A" (time-graph-type ind 0)))
      (if (not (= (x-axis-style ind 0) x-axis-as-percentage)) (snd-display #__line__ ";save x-axis-as-percentage: ~A" (x-axis-style ind 0)))
      (if (not (= (speed-control-style ind) speed-control-as-semitone)) (snd-display #__line__ ";save speed-control-style: ~A" (speed-control-style ind)))
      (if (not (= (cursor ind 0) 1234)) (snd-display #__line__ ";save cursor 1234: ~A" (cursor ind 0)))
      (if (not (string=? (eps-file) "hiho.eps")) (snd-display #__line__ ";save eps-file: ~A" (eps-file)))
      (if (not (string=? (x-axis-label ind 0 time-graph) "time-x"))
	  (snd-display #__line__ ";save x-axis-label: ~A" (x-axis-label ind 0 time-graph)))
      (if (not (string=? (y-axis-label ind 0 time-graph) "amp-y"))
	  (snd-display #__line__ ";save y-axis-label: ~A" (y-axis-label ind 0 time-graph)))
      (if (not (feql (amp-control-bounds ind) (list 0 2.5))) 
	  (snd-display #__line__ ";save amp-control-bounds: ~A" (amp-control-bounds ind)))
      (if (not (feql (speed-control-bounds ind) (list 1.0 2.5))) 
	  (snd-display #__line__ ";save speed-control-bounds: ~A" (speed-control-bounds ind)))
      (if (not (feql (contrast-control-bounds ind) (list 0 2.5))) 
	  (snd-display #__line__ ";save contrast-control-bounds: ~A" (contrast-control-bounds ind)))
      (if (not (feql (reverb-control-scale-bounds ind) (list 0 2.5))) 
	  (snd-display #__line__ ";save reverb-control-scale-bounds: ~A" (reverb-control-scale-bounds ind)))
      (if (not (feql (reverb-control-length-bounds ind) (list 0 2.5))) 
	  (snd-display #__line__ ";save reverb-control-length-bounds: ~A" (reverb-control-length-bounds ind)))
      (set! (eps-file) old-eps-file)
      (delete-file "s61.scm")
      (close-sound ind))
    
    (let ((ind (open-sound "oboe.snd"))
	  (old-tiny-font (tiny-font))
	  (old-peaks-font (peaks-font))
	  (old-bold-peaks-font (bold-peaks-font))
	  (old-amp (amp-control-bounds))
	  (old-speed (speed-control-bounds))
	  (old-contrast (contrast-control-bounds))
	  (old-revlen (reverb-control-length-bounds))
	  (old-revscl (reverb-control-scale-bounds)))
      (set! (tiny-font) "8x13")
      (set! (peaks-font) "8x13")
      (set! (bold-peaks-font) "8x13")
      (set! (amp-control-bounds) (list 0.0 2.5))
      (set! (speed-control-bounds) (list 1.0 2.5))
      (set! (reverb-control-scale-bounds) (list 0.0 2.5))
      (set! (reverb-control-length-bounds) (list 0.0 2.5))
      (set! (contrast-control-bounds) (list 0.0 2.5))
      (save-state "s61.scm")
      (close-sound ind)
      (for-each forget-region (regions))
      (load (string-append cwd "s61.scm"))
      (if (not (string=? (tiny-font) "8x13")) (snd-display #__line__ ";save tiny-font: ~A" (tiny-font)))
      (if (not (string=? (peaks-font) "8x13")) (snd-display #__line__ ";save peaks-font: ~A" (peaks-font)))
      (if (not (string=? (bold-peaks-font) "8x13")) (snd-display #__line__ ";save bold-peaks-font: ~A" (bold-peaks-font)))
      (if (not (feql (amp-control-bounds) (list 0 2.5))) 
	  (snd-display #__line__ ";save amp-control-bounds: ~A" (amp-control-bounds)))
      (if (not (feql (speed-control-bounds) (list 1.0 2.5))) 
	  (snd-display #__line__ ";save speed-control-bounds: ~A" (speed-control-bounds)))
      (if (not (feql (contrast-control-bounds) (list 0 2.5))) 
	  (snd-display #__line__ ";save contrast-control-bounds: ~A" (contrast-control-bounds)))
      (if (not (feql (reverb-control-scale-bounds) (list 0 2.5))) 
	  (snd-display #__line__ ";save reverb-control-scale-bounds: ~A" (reverb-control-scale-bounds)))
      (if (not (feql (reverb-control-length-bounds) (list 0 2.5))) 
	  (snd-display #__line__ ";save reverb-control-length-bounds: ~A" (reverb-control-length-bounds)))
      (set! (tiny-font) old-tiny-font)
      (set! (peaks-font) old-peaks-font)
      (set! (bold-peaks-font) old-bold-peaks-font)
      (set! (amp-control-bounds) old-amp)
      (set! (speed-control-bounds) old-speed)
      (set! (contrast-control-bounds) old-contrast)
      (set! (reverb-control-scale-bounds) old-revscl)
      (set! (reverb-control-length-bounds) old-revlen)
      (delete-file "s61.scm")
      (close-sound ind))
    
    (let* ((ind (open-sound "oboe.snd"))
	   (funcs (list transform-graph-type time-graph-type show-axes transform-normalization
			graph-style x-axis-style spectro-x-scale transform-size fft-window
			dot-size max-transform-peaks with-verbose-cursor zero-pad min-dB spectro-hop spectrum-end
			cursor-size cursor-style))
	   (func-names (list 'transform-graph-type 'time-graph-type 'show-axes 'transform-normalization
			     'graph-style 'x-axis-style 'spectro-x-scale 'transform-size 'fft-window
			     'dot-size 'max-transform-peaks 'with-verbose-cursor 'zero-pad 'min-dB 'spectro-hop 'spectrum-end
			     'cursor-size 'cursor-style))
	   (old-globals (map (lambda (func) (func)) funcs))
	   (new-globals (list graph-as-sonogram graph-as-wavogram show-all-axes normalize-by-sound
			      graph-dots x-axis-in-samples 0.1 32 bartlett-window
			      4 10 #t 1 -90 12 .1 15 cursor-cross))
	   (new-locals (list graph-once graph-once show-x-axis normalize-by-channel
			     graph-lines x-axis-in-seconds 1.0 256 blackman2-window
			     1 100 #f 0 -60 4 1.0 25 cursor-line)))
      (for-each (lambda (func func-name global local)
		  (set! (func) global)
		  (set! (func ind 0) local))
		funcs func-names new-globals new-locals)
      (set! (zoom-focus-style) zoom-focus-right)
      (set! (channel-style) channels-combined)
      (set! (channel-style ind) channels-separate)
      (if (file-exists? "s61.scm") (delete-file "s61.scm"))
      (save-state "s61.scm")
      (close-sound ind)
      (for-each forget-region (regions))
      (load (string-append cwd "s61.scm"))
      (set! ind (find-sound "oboe.snd"))
      (for-each (lambda (func func-name global local)
		  (if (or (not (local-eq? (func) global))
			  (not (local-eq? (func ind 0) local)))
		      (snd-display #__line__ "; save ~A reversed: ~A [~A] ~A [~A]" 
				   func-name (func) global (func ind 0) local)))
		funcs func-names new-globals new-locals)
      (if (not (= (channel-style ind) channels-separate))
	  (snd-display #__line__ ";save channel-style reversed: ~A ~A" (channel-style) (channel-style ind)))
      (for-each (lambda (func val) (set! (func) val)) funcs old-globals)
      (close-sound ind)
      (set! (zoom-focus-style) zoom-focus-active)
      (set! (channel-style) channels-separate)
      (delete-file "s61.scm"))
    
    (let* ((ind0 (open-sound "oboe.snd"))
	   (ind1 (open-sound "oboe.snd")))
      (if (not (equal? (find-sound "oboe.snd" 0) ind0))
	  (snd-display #__line__ ";find-sound 0: ~A ~A" ind0 (find-sound "oboe.snd" 0)))
      (if (not (equal? (find-sound "oboe.snd" 1) ind1))
	  (snd-display #__line__ ";find-sound 1: ~A ~A" ind1 (find-sound "oboe.snd" 1)))
      (add-mark 123 ind0)
      (add-mark 321 ind1)
      (if (file-exists? "s61.scm") (delete-file "s61.scm"))
      (save-state "s61.scm")
      (close-sound ind0)
      (close-sound ind1)
      (load (string-append cwd "s61.scm"))
      (set! ind0 (find-sound "oboe.snd" 0))
      (set! ind1 (find-sound "oboe.snd" 1))
      (if (or (not ind0) (not ind1)) (snd-display #__line__ ";saved 2oboes, found: ~A" (map short-file-name (sounds))))
      (if (not (find-mark 123 ind0)) (snd-display #__line__ ";saved 2oboes mark 0?"))
      (if (find-mark 123 ind1) (snd-display #__line__ ";saved 2oboes mark 1->0?"))
      (if (not (find-mark 321 ind1)) (snd-display #__line__ ";saved 2oboes mark 1?"))
      (if (find-mark 321 ind0) (snd-display #__line__ ";saved 2oboes mark 0->1?"))
      (close-sound ind0)
      (close-sound ind1))
    
    (let ((ctr 1))
      (for-each 
       (lambda (func test)
	 (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "mono save-state tests" 100)))
	   (func ind)
	   (if (file-exists? "s61.scm") (delete-file "s61.scm"))
	   (save-state "s61.scm")
	   (close-sound ind)
	   (load (string-append cwd "s61.scm"))
	   (set! ind (find-sound "test.snd"))
	   (if (not (sound? ind)) 
	       (snd-display #__line__ ";save-state test ~D no test.snd?" ctr)
	       (begin
		 (test ind)
		 (close-sound ind)))
	   (set! ctr (+ 1 ctr))))
       
       (list 
	
	;; basic choices
	(lambda (ind) (insert-sample 10 .5 ind 0))
	(lambda (ind) (delete-sample 10 ind 0))
	(lambda (ind) (set! (sample 10 ind 0) .5))
	(lambda (ind) (set! (sample 10 ind 0) .5) (scale-channel .5))
	(lambda (ind) (vct->channel (make-vct 10 .5) 10 5 ind 0) (pad-channel 12 5 ind 0))
	(lambda (ind) (map-channel (lambda (y) 1.0)) (env-channel '(0 0 1 1) 0 11 ind 0))
	(lambda (ind) (ptree-channel (lambda (y) (+ y .1))))
	
	;; map-channel as backup
	(lambda (ind)
	  (let ((ctr 0))
	    (map-channel (lambda (y) (set! ctr (+ 1 ctr)) (if (even? ctr) .1 #f)))))
	
	;; as-one-edit
	(lambda (ind)
	  ;; change
	  (as-one-edit 
	   (lambda ()
	     (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 0 10 ind 0)
	     (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 20 10 ind 0))))
	
	(lambda (ind)
	  ;; scale
	  (as-one-edit
	   (lambda ()
	     (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 0 10 ind 0)
	     (scale-by .5))))
	
	(lambda (ind)
	  ;; delete
	  (as-one-edit
	   (lambda ()
	     (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 0 10 ind 0)
	     (delete-samples 5 5))))
	
	(lambda (ind)
	  ;; insert
	  (as-one-edit
	   (lambda ()
	     (delete-samples 5 5)
	     (insert-samples 5 2 (vct .1 .2)))))
	)
       
       (list
	;; basic cases
	(lambda (ind)
	  (if (fneq (sample 10) .5) (snd-display #__line__ ";insert-sample save-state: ~A" (channel->vct 5 10 ind 0)))
	  (if (not (= (frames ind 0) 101)) (snd-display #__line__ ";insert-sample save-state len: ~A" (frames ind 0))))
	(lambda (ind)
	  (if (fneq (sample 10) 0.0) (snd-display #__line__ ";delete-sample save-state: ~A" (channel->vct 5 10 ind 0)))
	  (if (not (= (frames ind 0) 99)) (snd-display #__line__ ";delete-sample save-state len: ~A" (frames ind 0))))
	(lambda (ind)
	  (if (fneq (sample 10) .5) (snd-display #__line__ ";set sample save-state: ~A" (channel->vct 5 10 ind 0)))
	  (if (not (= (frames ind 0) 100)) (snd-display #__line__ ";set sample save-state len: ~A" (frames ind 0))))
	(lambda (ind)
	  (if (fneq (sample 10) .25) (snd-display #__line__ ";scl sample save-state: ~A" (channel->vct 5 10 ind 0)))
	  (if (not (= (frames ind 0) 100)) (snd-display #__line__ ";scl sample save-state len: ~A" (frames ind 0)))
	  (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";scl sample save-state edpos: ~A" (edit-position ind 0))))
	(lambda (ind)
	  (if (not (= (frames ind 0) 105)) (snd-display #__line__ ";pad sample save-state len: ~A" (frames ind 0)))
	  (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";pad sample save-state edpos: ~A" (edit-position ind 0)))
	  (if (not (vequal (vct .5 .5 0 0 0 0 0 .5 .5 .5) (channel->vct 10 10 ind 0)))
	      (snd-display #__line__ ";pad sample save-state: ~A" (channel->vct 10 10 ind 0))))
	(lambda (ind)
	  (if (not (= (frames ind 0) 100)) (snd-display #__line__ ";env sample save-state len: ~A" (frames ind 0)))
	  (if (not (= (edit-position ind 0) 2)) (snd-display #__line__ ";env sample save-state edpos: ~A" (edit-position ind 0)))
	  (if (not (vequal (vct 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.0 1.0 1.0 1.0) (channel->vct 0 15 ind 0)))
	      (snd-display #__line__ ";env sample save-state: ~A" (channel->vct 0 15 ind 0))))
	(lambda (ind)
	  (if (not (= (frames ind 0) 100)) (snd-display #__line__ ";ptree sample save-state len: ~A" (frames ind 0)))
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";ptree sample save-state edpos: ~A" (edit-position ind 0)))
	  (if (fneq (maxamp ind 0) .1) (snd-display #__line__ ";ptree save-state max: ~A" (maxamp ind 0)))
	  (if (not (vequal (make-vct 10 .1) (channel->vct 0 10))) (snd-display #__line__ ";ptree save-state vals: ~A" (channel->vct 0 10 ind 0))))
	
	;; map-channel as backup
	(lambda (ind)
	  (if (not (= (frames ind 0) 50)) (snd-display #__line__ ";map #f save-state len: ~A" (frames ind 0)))
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";map #f save-state edpos: ~A" (edit-position ind 0)))
	  (if (fneq (maxamp ind 0) .1) (snd-display #__line__ ";map #f save-state max: ~A" (maxamp ind 0)))
	  (if (not (vequal (make-vct 10 .1) (channel->vct 0 10))) (snd-display #__line__ ";map #f save-state vals: ~A" (channel->vct 0 10 ind 0))))
	
	;; as-one-edit
	(lambda (ind)
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";save-state backup 2 vcts edpos: ~A" (edit-position ind 0)))
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0)))
	      (snd-display #__line__ ";as-one-edit save-state 1: ~A" (channel->vct 0 10 ind 0)))
	  (if (not (vequal (channel->vct 20 10 ind 0) (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0)))
	      (snd-display #__line__ ";as-one-edit save-state 2: ~A" (channel->vct 0 10 ind 0))))
	
	(lambda (ind)
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";save-state backup vct+scl edpos: ~A" (edit-position ind 0)))
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct-scale! (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) .5)))
	      (snd-display #__line__ ";as-one-edit save-state 3: ~A" (channel->vct 0 10 ind 0))))
	
	(lambda (ind)
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";save-state backup vct+del edpos: ~A" (edit-position ind 0)))
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct .1 .2 .3 .4 .5 0 0 0 0 0)))
	      (snd-display #__line__ ";as-one-edit save-state 4: ~A" (channel->vct 0 10 ind 0))))
	
	(lambda (ind)
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";save-state backup del+insert edpos: ~A" (edit-position ind 0)))
	  (if (not (vequal (channel->vct 0 10 ind 0) (vct 0 0 0 0 0 .1 .2 0 0 0)))
	      (snd-display #__line__ ";as-one-edit save-state 5: ~A" (channel->vct 0 10 ind 0)))
	  (if (not (= (frames ind 0) 97)) (snd-display #__line__ ";save-state backup del+insert len: ~A" (frames ind 0))))
	
	)))
    
    ;; ---------------- edit-list->function ----------------
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((mx0 (maxamp))
	    (frs (frames)))
	
	;; ---- simple scale
	(scale-channel 2.0)
	(if (fneq (* 2 mx0) (maxamp)) (snd-display #__line__ ";edit-list->function off to a bad start: ~A" (maxamp)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 1: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (scale-channel 2.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 1: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq (* 4 mx0) mx) (snd-display #__line__ ";edit-list->function called (1): ~A ~A" mx mx0))))
	(revert-sound ind)
	
	(scale-by 2.0)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 1a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (scale-channel 2.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 1a: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	(normalize-channel 1.0)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 1c: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (normalize-channel 1.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 1c: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	
	;; ---- simple delete
	(delete-samples 10 100)
	(if (not (= (frames) (- frs 100))) (snd-display #__line__ ";edit-list->function delete: ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 2: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (delete-samples 10 100 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 2: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (if (not (= (frames) (- frs 200))) (snd-display #__line__ ";edit-list->function called (2): ~A ~A" frs (frames))))
	(revert-sound ind)
	
	;; ---- simple delete (a)
	(delete-sample 100)
	(if (not (= (frames) (- frs 1))) (snd-display #__line__ ";edit-list->function delete (2a): ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 2a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (delete-samples 100 1 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 2a: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (if (not (= (frames) (- frs 2))) (snd-display #__line__ ";edit-list->function called (2a): ~A ~A" frs (frames))))
	(revert-sound ind)
	
	;; ---- simple zero pad
	(pad-channel 10 100)
	(if (not (= (frames) (+ frs 100))) (snd-display #__line__ ";edit-list->function pad: ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 3: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (pad-channel 10 100 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 3: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (if (not (= (frames) (+ frs 200))) (snd-display #__line__ ";edit-list->function called (3): ~A ~A" frs (frames))))
	(revert-sound ind)
	
	;; ---- simple zero pad (a)
	(insert-silence 10 100)
	(if (not (= (frames) (+ frs 100))) (snd-display #__line__ ";edit-list->function pad (3a): ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 3a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (pad-channel 10 100 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 3a: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (if (not (= (frames) (+ frs 200))) (snd-display #__line__ ";edit-list->function called (3a): ~A ~A" frs (frames))))
	(revert-sound ind)
	
	;; --- simple ramp
	(ramp-channel 0.2 0.9)
	(if (fneq (maxamp) 0.0899) (snd-display #__line__ ";edit-list ramp: ~A" (maxamp)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 4: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (ramp-channel 0.2 0.9 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 4: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.061) (snd-display #__line__ ";edit-list->function called (4): ~A" mx))))
	(revert-sound ind)
	
	;; --- simple xramp
	(xramp-channel 0.2 0.9 32.0)
	(if (and (fneq (maxamp) 0.055) (fneq (maxamp) .056)) (snd-display #__line__ ";edit-list xramp: ~A" (maxamp)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 5: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (xramp-channel 0.2 0.9 32.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 5: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.0266) (snd-display #__line__ ";edit-list->function called (5): ~A" mx))))
	(revert-sound ind)
	
	;; ---- simple env
	(env-sound '(0 0 1 1))
	(if (fneq (maxamp) 0.0906) (snd-display #__line__ ";edit-list env: ~A" (maxamp)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 6: ~A" func))
	  (if (not (string=? (object->string (procedure-source func))
			     "(lambda (snd chn) (env-channel (quote (0.0 0.0 1.0 1.0)) 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 6: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.0634) (snd-display #__line__ ";edit-list->function called (6): ~A" mx))))
	(revert-sound ind)
	
	;; ---- less simple env
	(env-sound '(0 0 1 .3 2 .8 3 0))
	(if (fneq (maxamp) 0.107) (snd-display #__line__ ";edit-list env: ~A" (maxamp)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (env-channel (quote (0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0)) 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 7: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.0857) (snd-display #__line__ ";edit-list->function called (7): ~A" mx))))
	(revert-sound ind)
	
	(env-channel '(0 0 1 .3 2 .8 3 0))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (env-channel (quote (0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0)) 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 7a: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	
	(env-channel '(0 0 1 .3 2 .8 3 0) 1000 2000)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7b: ~A" func))
	  (if (and (not (string=? (object->string (procedure-source func)) 
				  "(lambda (snd chn) (env-channel (make-env (quote (0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0)) :base 1.0 :end 1999) 1000 2000 snd chn))"))
		   (not (string=? (object->string (procedure-source func)) 
				  "(lambda (snd chn) (env-channel (make-env (quote (0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0)) #:base 1.0 #:end 1999) 1000 2000 snd chn))")))
	      (snd-display #__line__ ";edit-list->function 7b: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	
	(env-channel (make-env '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) :base 32.0 :length 2000) 1000 2000)
	(let ((func (edit-list->function))
	      (mxenv0 (maxamp)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7c: ~A" func))
	  (if (and (not (string=? (object->string (procedure-source func)) 
				  "(lambda (snd chn) (env-channel (make-env (quote (0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0)) :base 32.0 :end 1999) 1000 2000 snd chn))"))
		   (not (string=? (object->string (procedure-source func)) 
				  "(lambda (snd chn) (env-channel (make-env (quote (0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0)) #:base 32.0 #:end 1999) 1000 2000 snd chn))")))
	      (snd-display #__line__ ";edit-list->function 7c: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  
	  (env-channel (make-env '(0.0 0.0 1.0 0.3 2.0 0.8 3.0 0.0) :length 2000 :offset 2.0 :scaler 3.0) 1000 2000)
	  (let ((func (edit-list->function))
		(mxenv1 (maxamp)))
	    (if (not (procedure? func)) 
		(snd-display #__line__ ";edit-list->function 7d: ~A" func))
	    (if (and (not (string=? (object->string (procedure-source func)) 
				    "(lambda (snd chn) (env-channel (make-env (quote (0.0 2.0 1.0 2.9 2.0 4.4 3.0 2.0)) :base 1.0 :end 1999) 1000 2000 snd chn))"))
		     (not (string=? (object->string (procedure-source func)) 
				    "(lambda (snd chn) (env-channel (make-env (quote (0.0 2.0 1.0 2.9 2.0 4.4 3.0 2.0)) #:base 1.0 #:end 1999) 1000 2000 snd chn))")))
		(snd-display #__line__ ";edit-list->function 7d: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (let ((nmx (maxamp)))
	      (if (fneq nmx mxenv1) (snd-display #__line__ ";edit-list->function 7d max: ~A ~A ~A" nmx mxenv1 mxenv0)))))
	(revert-sound ind)
	
	(do ((i 0 (+ 1 i)))
	    ((= i 5)) ; get to unrampable case
	  (env-channel '(0 0 1 1 2 0)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7e: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (env-channel (quote (0.0 0.0 1.0 1.0 2.0 0.0)) 0 #f snd chn) (env-channel (quote (0.0 0.0 1.0 1.0 2.0 0.0)) 0 #f snd chn) (env-channel (quote (0.0 0.0 1.0 1.0 2.0 0.0)) 0 #f snd chn) (env-channel (quote (0.0 0.0 1.0 1.0 2.0 0.0)) 0 #f snd chn) (env-channel (quote (0.0 0.0 1.0 1.0 2.0 0.0)) 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 7e: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq (maxamp) 0.1459) (snd-display #__line__ ";edit-list->function 7e max: ~A" (maxamp)))
	  (if (not (= (edit-position) 5)) (snd-display #__line__ ";edit-list->function 7e edpos: ~A" (edit-position))))
	(revert-sound ind)
	
	(env-sound '(0 0 1 1 2 0) 0 (frames) 32.0)
	(if (fneq (maxamp) 0.146) (snd-display #__line__ ";edit-list env 7f: ~A" (maxamp)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7f: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (env-channel-with-base (quote (0.0 0.0 1.0 1.0 2.0 0.0)) 32.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 7f: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.146) (snd-display #__line__ ";edit-list->function called (7f): ~A" mx))))
	(revert-sound ind)
	
	(env-sound '(0 0 1 1 2 1 3 0) 0 (frames) 0.0)
	(if (fneq (sample 4000) 0.0) (snd-display #__line__ ";edit-list env 7g: ~A" (sample 4000)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 7g: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (env-channel-with-base (quote (0.0 0.0 1.0 1.0 2.0 1.0 3.0 0.0)) 0.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 7g: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq (sample 4000) 0.0) (snd-display #__line__ ";edit-list function 7g: ~A" (sample 4000))))
	(revert-sound ind)
	
	;; ---- simple ptree
	
	(let ((old-opt (optimization)))
	  (set! (optimization) 6)
	  (ptree-channel (lambda (y) (+ y .1)))
	  (if (fneq (maxamp) 0.247) (snd-display #__line__ ";edit-list ptree: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display #__line__ ";edit-list->function 8: ~A" func))
	    (if (not (string=? (object->string (procedure-source func)) 
			       "(lambda (snd chn) (ptree-channel (lambda (y) (+ y 0.1)) 0 #f snd chn))"))
		(snd-display #__line__ ";edit-list->function 8: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq mx 0.347) (snd-display #__line__ ";edit-list->function called (8): ~A" mx))))
	  (revert-sound ind)
	  (set! (optimization) old-opt))
	
	;; ---- simple 1 sample insert
	(insert-sample 100 .1)
	(if (not (= (frames) (+ frs 1))) (snd-display #__line__ ";edit-list->function insert-sample: ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 9: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (insert-sample 100 0.1 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 9: ~A" (object->string (procedure-source func))))
	  (func ind 0)
	  (if (not (vequal (channel->vct 99 4) (vct 0.0 0.1 0.1 0.0)))
	      (snd-display #__line__ ";edit-list->function func 9: ~A" (channel->vct 99 4)))
	  (if (not (= (frames) (+ frs 2))) (snd-display #__line__ ";edit-list->function called (9): ~A ~A" frs (frames))))
	(revert-sound ind)
	
	;; ---- insert-samples with data
	(insert-samples 0 100 (make-vct 100 .1))
	(if (not (= (frames) (+ frs 100))) (snd-display #__line__ ";edit-list->function insert-samples (100): ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 9a: ~A" func))
	  (func ind 0)
	  (if (not (= (frames) (+ frs 200))) (snd-display #__line__ ";edit-list->function insert-samples (200): ~A ~A" frs (frames)))
	  (if (not (vequal (channel->vct 0 5) (vct 0.1 0.1 0.1 0.1 0.1)))
	      (snd-display #__line__ ";edit-list->function func 9a: ~A" (channel->vct 0 5))))
	(revert-sound ind)
	
	;; ---- set-samples with data
	(set! (samples 0 100) (make-vct 100 .1))
	(if (not (= (frames) frs)) (snd-display #__line__ ";edit-list->function set-samples (1): ~A ~A" frs (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 9b: ~A" func))
	  (func ind 0)
	  (if (not (= (frames) frs)) (snd-display #__line__ ";edit-list->function set-samples (2): ~A ~A" frs (frames)))
	  (if (not (vequal (channel->vct 0 5) (vct 0.1 0.1 0.1 0.1 0.1)))
	      (snd-display #__line__ ";edit-list->function func 9b: ~A" (channel->vct 0 5))))
	(revert-sound ind)
	
	;; ---- simple 1 sample set
	(let ((val (sample 100)))
	  (set! (sample 100) .1)
	  (if (not (= (frames) frs)) (snd-display #__line__ ";edit-list->function set-sample frames: ~A ~A" frs (frames)))
	  (if (fneq (sample 100) .1) (snd-display #__line__ ";edit-list->function set-sample val: ~A ~A" val (sample 100)))
	  (let ((func (edit-list->function)))
	    (revert-sound)
	    (if (fneq val (sample 100)) (snd-display #__line__ ";edit-list->function unset-sample val: ~A ~A" val (sample 100)))
	    (if (not (procedure? func)) 
		(snd-display #__line__ ";edit-list->function 10: ~A" func))
	    (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (set-sample 100 0.1 snd chn))"))
		(snd-display #__line__ ";edit-list->function 10: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (if (not (vequal (channel->vct 99 4) (vct 0.0 0.1 0.0 0.0)))
		(snd-display #__line__ ";edit-list->function func 10: ~A" (channel->vct 99 4)))))
	(revert-sound ind)
	
	(let ((pfrs (mus-sound-frames "pistol.snd")))
	  (insert-sound "pistol.snd" 1000)
	  (if (not (= (frames) (+ frs pfrs))) (snd-display #__line__ ";edit-list->function insert-sound: ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display #__line__ ";edit-list->function 10a: ~A" func))
	    (if (and (not (string=? (object->string (procedure-source func)) 
				    "(lambda (snd chn) (insert-sound \"/home/bil/cl/pistol.snd\" 1000 0 snd chn))"))
		     (not (string=? (object->string (procedure-source func)) 
				    "(lambda (snd chn) (insert-sound \"/home/bil/snd-11/pistol.snd\" 1000 0 snd chn))")))
		(snd-display #__line__ ";edit-list->function 10a: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (not (= (frames) (+ frs pfrs))) (snd-display #__line__ ";edit-list->function called (10): ~A ~A" frs (frames)))))
	(revert-sound ind)
	
	(let ((pfrs (mus-sound-frames "pistol.snd")))
	  (insert-samples 1000 pfrs "pistol.snd")
	  (if (not (= (frames) (+ frs pfrs))) (snd-display #__line__ ";edit-list->function insert-samples: ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display #__line__ ";edit-list->function 11: ~A" func))
	    (if (and (not (string=? (object->string (procedure-source func)) 
				    "(lambda (snd chn) (insert-samples 1000 41623 \"/home/bil/cl/pistol.snd\" snd chn))"))
		     (not (string=? (object->string (procedure-source func)) 
				    "(lambda (snd chn) (insert-samples 1000 41623 \"/home/bil/snd-11/pistol.snd\" snd chn))")))
		(snd-display #__line__ ";edit-list->function 11: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (not (= (frames) (+ frs pfrs))) (snd-display #__line__ ";edit-list->function called (11): ~A ~A" frs (frames)))))
	(revert-sound ind)
	
	(smooth-channel 1000 100)
	(let ((func (edit-list->function))
	      (val (sample 1050)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 12: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (smooth-channel 1000 100 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 12: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq (sample 1050) val) (snd-display #__line__ ";edit-list->function 12: ~A ~A" (sample 1050) val)))
	(revert-sound ind)
	
	(smooth-sound 1000 100)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 12a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (smooth-channel 1000 100 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 12a: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	
	
	;; ---- selection stuff
	(make-selection 1000 11000)
	(scale-selection-by 2.0)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 13: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (scale-channel 2.0 1000 10001 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 13: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (let ((mx (maxamp)))
	    (if (fneq mx .269) (snd-display #__line__ ";edit-list->function called (13): ~A" mx))))
	(revert-sound ind)
	
	(scale-selection-to 1.0)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 13a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (normalize-channel 1.0 1000 10001 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 13a: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	
	(env-selection '(0 0 1 1 2 0))
	(let ((func (edit-list->function)))
	  (if (fneq (sample 4000) 0.0173) (snd-display #__line__ ";edit-list->function 14 samp: ~A" (sample 4000)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 14: ~A" func))
	  (if (and (not (string=? (object->string (procedure-source func)) 
				  "(lambda (snd chn) (env-channel (make-env (quote (0.0 0.0 1.0 1.0 2.0 0.0)) :base 1.0 :end 10000) 1000 10001 snd chn))"))
		   (not (string=? (object->string (procedure-source func)) 
				  "(lambda (snd chn) (env-channel (make-env (quote (0.0 0.0 1.0 1.0 2.0 0.0)) #:base 1.0 #:end 10000) 1000 10001 snd chn))")))
	      (snd-display #__line__ ";edit-list->function 14: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq (sample 4000) 0.0173) (snd-display #__line__ ";edit-list->function 14 re-samp: ~A" (sample 4000))))
	(revert-sound ind)
	
	(make-selection 1000 1100)
	(smooth-selection)
	(let ((func (edit-list->function))
	      (val (sample 1050)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 14a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (smooth-channel 1000 101 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 14a: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq (sample 1050) val) (snd-display #__line__ ";edit-list->function 14a: ~A ~A" (sample 1050) val)))
	(revert-sound ind)
	
	(reverse-selection)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 14b: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (reverse-channel 1000 101 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 14b: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0))
	(revert-sound ind)
	
	(delete-selection)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 14c: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (delete-samples 1000 101 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 14c: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0))
	(revert-sound ind)
	
	
	;; ---- simple reapply
	(env-channel '(0 0 1 1 2 0))
	(let ((func (edit-list->function)))
	  (close-sound ind)
	  (set! ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1 :size 20 :comment #f))
	  (map-channel (lambda (y) 1.0))
	  (func ind 0)
	  (let ((data (channel->vct)))
	    (if (not (vequal data (vct 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 0.889 0.778 0.667 0.556 0.444 0.333 0.222 0.111 0.0)))
		(snd-display #__line__ ";edit-list->function env reapply: ~A" data)))
	  (close-sound ind)
	  (set! ind (open-sound "oboe.snd")))
	
	;; ---- insert-region
	(let ((reg (make-region 1000 1100)))
	  (insert-region reg 2000)
	  (let ((func (edit-list->function))
		(val (sample 2050)))
	    (if (not (procedure? func)) 
		(snd-display #__line__ ";edit-list->function 16: ~A" func))
					;	    (if (not (string=? (object->string (procedure-source func)) 
					;			       (string-append "(lambda (snd chn) (insert-region (integer->region " (number->string (region->integer reg)) " 2000 snd chn))")))
					;		(snd-display #__line__ ";edit-list->function 16: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (sample 2050) val) (snd-display #__line__ ";edit-list->function 16: ~A ~A" (sample 2050) val))))
	(revert-sound ind)
	
	;; ---- reverse
	(reverse-channel)
	(let ((func (edit-list->function))
	      (val (sample 2000)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 17: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (reverse-channel 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 17: ~A" (object->string (procedure-source func))))
	  (if (fneq val -.002) (snd-display #__line__ ";edit-list->function val: ~A" val))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq val -.002) (snd-display #__line__ ";edit-list->function 17 re-val: ~A" val)))
	(revert-sound ind)
	
	(reverse-sound)
	(let ((func (edit-list->function))
	      (val (sample 2000)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 17a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (reverse-channel 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 17a: ~A" (object->string (procedure-source func))))
	  (if (fneq val -.002) (snd-display #__line__ ";edit-list->function 17a val: ~A" val)))
	(revert-sound ind)
	
	(reverse-channel 1000 500)
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 17b: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (reverse-channel 1000 500 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 17b: ~A" (object->string (procedure-source func)))))
	(revert-sound ind)
	
	;; ---- src
	(src-sound 2.0)
	(if (> (abs (- (frames) 25415)) 2) (snd-display #__line__ ";edit-list->function 18 len: ~A" (frames)))
	(let ((func (edit-list->function)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 18: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (src-channel 2.0 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 18: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (> (abs (- (frames) 25415)) 2) (snd-display #__line__ ";edit-list->function 18 re-len: ~A" (frames))))
	(revert-sound ind)
	
	(src-channel 2.0 1000 500)
	(let ((func (edit-list->function))
	      (frs (frames)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 18a: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (src-channel 2.0 1000 500 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 18a: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (not (= frs (frames))) (snd-display #__line__ ";edit-list->function 18a re-len: ~A ~A" frs (frames))))
	(revert-sound)
	
	(src-sound '(0 1 1 2 2 1))
	(let ((func (edit-list->function))
	      (frs (frames)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 18b: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (src-channel (quote (0.0 1.0 1.0 2.0 2.0 1.0)) 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 18b: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (not (= frs (frames))) (snd-display #__line__ ";edit-list->function 18b re-len: ~A ~A" frs (frames))))
	(revert-sound)
	
	(src-channel '(0 1 1 2) 1000 500)
	(let ((func (edit-list->function))
	      (frs (frames)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 18c: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (src-channel (quote (0.0 1.0 1.0 2.0)) 1000 500 snd chn))"))
	      (snd-display #__line__ ";edit-list->function 18c: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (not (= frs (frames))) (snd-display #__line__ ";edit-list->function 18c re-len: ~A ~A" frs (frames))))
	(revert-sound)
	
	;; ---- filter-channel
	(filter-channel '(0 1 1 0) 10)
	(let ((func (edit-list->function))
	      (mx (maxamp)))
	  (if (not (procedure? func)) 
	      (snd-display #__line__ ";edit-list->function 19: ~A" func))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (filter-channel (quote (0.0 1.0 1.0 0.0)) 10 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function 19: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (if (fneq mx (maxamp)) (snd-display #__line__ ";edit-list->function 19 re-filter: ~A ~A" mx (maxamp))))
	(revert-sound)
	
	(let ((op (make-one-zero .5 .5))) (filter-fft op))
	(vct->channel (fft-smoother .1 (cursor) 400) (cursor) 400)
	(revert-sound)
	
	(let ((ind (new-sound :size 32)))
	  (select-sound ind)
	  (let ((ang 0.0)) 
	    (map-channel (lambda (y) 
			   (let ((val (+ (* .5 (sin ang)) (* .5 (sin (* ang 4)))))) 
			     (set! ang (+ ang (/ (* 2 pi) 16.0))) 
			     val))))
	  (let ((vals (fft-env-data '(0 0 .3 0 .4 1 1 1))))
	    (vct->channel vals)
	    (if (not (vequal vals (vct -0.000 0.500 0.000 -0.500 0.000 0.500 0.000 -0.500 0.000 0.500 -0.000 
				       -0.500 -0.000 0.500 -0.000 -0.500 -0.000 0.500 0.000 -0.500 0.000 0.500 
				       0.000 -0.500 0.000 0.500 -0.000 -0.500 -0.000 0.500 -0.000 -0.500)))
		(snd-display #__line__ ";fft-env-data: ~A" vals)))
	  (hilbert-transform-via-fft)
	  (let ((vals (channel->vct)))
	    (if (not (vequal vals (vct -0.500 -0.000 0.500 -0.000 -0.500 0.000 0.500 0.000 -0.500 0.000 0.500 
				       0.000 -0.500 -0.000 0.500 -0.000 -0.500 -0.000 0.500 -0.000 -0.500 0.000 
				       0.500 0.000 -0.500 0.000 0.500 0.000 -0.500 -0.000 0.500 -0.000)))
		(snd-display #__line__ ";hilbert via dft: ~A" vals)))
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0))
	  
	  (powenv-channel '(0 0 .325  1 1 32.0 2 0 32.0))
	  (let ((vals (channel->vct)))
	    (if (not (vequal vals (vct 0.000 0.107 0.206 0.298 0.384 0.463 0.536 0.605 0.668 0.727 0.781 0.832 0.879 
				       0.922 0.963 1.000 1.000 0.787 0.618 0.484 0.377 0.293 0.226 0.173 0.130 0.097 
				       0.070 0.049 0.032 0.019 0.008 0.000)))
		(snd-display #__line__ ";powenv-channel: ~A" vals)))
	  (undo)
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0))
	  (env-sound '(0 0 1 1))
	  (set! (cursor ind 0) 10)
	  (make-selection 0 7 ind 0)
	  (if (not (selection?))
	      (snd-display #__line__ ";make-selection failed??")
	      (begin
		(replace-with-selection)
		(let ((vals (channel->vct)))
		  (if (not (vequal vals (vct 0.000 0.032 0.065 0.097 0.129 0.161 0.194 0.226 0.258 0.290 0.000 0.032 0.065 
					     0.097 0.129 0.161 0.194 0.226 0.581 0.613 0.645 0.677 0.710 0.742 0.774 0.806 
					     0.839 0.871 0.903 0.935 0.968 1.000)))
		      (snd-display #__line__ ";replace-with-selection: ~A" vals)))))
	  (set! (cursor ind 0) 2)
	  (replace-with-selection)
	  (let ((vals (channel->vct)))
	    (if (not (vequal vals (vct 0.000 0.032 0.000 0.032 0.065 0.097 0.129 0.161 0.194 0.226 0.000 0.032 0.065 
				       0.097 0.129 0.161 0.194 0.226 0.581 0.613 0.645 0.677 0.710 0.742 0.774 0.806 
				       0.839 0.871 0.903 0.935 0.968 1.000)))
		(snd-display #__line__ ";replace-with-selection (at 2): ~A" vals)))
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0))
	  (env-sound '(0 0 1 1))
	  (let ((m1 (add-mark 10))
		(m2 (add-mark 20)))
	    (make-selection 0 9)
	    (fit-selection-between-marks m1 m2)
	    (let ((vals (channel->vct))) 
	      (if (not (vequal vals (vct 0.000 0.032 0.065 0.097 0.129 0.161 0.194 0.226 0.258 0.290 0.323 0.387 0.452 
					 0.516 0.581 0.645 0.710 0.774 0.839 0.903 0.645 0.677 0.710 0.742 0.774 0.806 
					 0.839 0.871 0.903 0.935 0.968 1.000)))
		  (snd-display #__line__ ";fit-selection-between-marks: ~A" vals))))
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0))
	  (let ((ramper (make-ramp 10)))
	    (map-channel (lambda (y) (ramp ramper y)))
	    (let ((vals (channel->vct 0 20)))
	      (if (not (vequal vals (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000 
					 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
		  (snd-display #__line__ ";make-ramp: ~A" vals))))
	  (revert-sound ind)
	  (vct->channel (with-sound (:output (make-vct 44100)) (cross-fade 0 2 1.0 "oboe.snd" "trumpet.snd" 0.5 1.0 0 .1 256 2)))
	  (if (and (ffneq (maxamp) .142) (ffneq (maxamp) .155)) (snd-display #__line__ ";cross fade maxamp: ~A" (maxamp)))
	  (revert-sound)
	  (vct->channel (with-sound (:output (make-vct 44100)) (dissolve-fade 0 2 1.0 "oboe.snd" "trumpet.snd" 512 2 2 #f)))
	  (let ((new-file-name (file-name ind)))
	    (close-sound ind)
	    (if (file-exists? new-file-name) (delete-file new-file-name))))
	
	(let ((vals (apply vct (rms-envelope "oboe.snd" :rfreq 4))))
	  (if (not (vequal vals (vct 0.0 0.0430 0.25 0.0642 0.5 0.0695 0.75 0.0722 1.0 0.0738 1.25 0.0713 
				     1.5 0.065 1.75 0.0439 2.0 0.01275 2.25 0.0)))
	      (snd-display #__line__ ";rms-envelope: ~A" vals)))
	
	(let ((ind (open-sound "2a.snd")))
	  (add-hook! graph-hook display-correlation)
	  (update-time-graph)
	  (reset-hook! graph-hook)
	  (stereo->mono ind "hi1.snd" "hi2.snd")
	  (let ((hi1 (find-sound "hi1.snd"))
		(hi2 (find-sound "hi2.snd")))
	    (if (or (not hi1) (not hi2) (not (= (chans hi1) 1)) (not (= (chans hi2) 1)))
		(snd-display #__line__ ";stereo->mono: ~A ~A" (map file-name (sounds)) (map chans (sounds)))
		(let ((dist1 (channel-distance ind 0 hi1 0))
		      (dist2 (channel-distance ind 1 hi2 0)))
		  (if (or (fneq dist1 0.0) (fneq dist2 0.0))
		      (snd-display #__line__ ";stereo->mono distances: ~A ~A" dist1 dist2))
		  (mono->stereo "ho2.snd" hi1 0 hi2 0)
		  (let ((ho2 (find-sound "ho2.snd")))
		    (if (or (not ho2) (not (= (chans ho2) 2)))
			(snd-display #__line__ ";mono->stereo: ~A" (map file-name (sounds)))
			(let ((dist1 (channel-distance ho2 0 ind 0))
			      (dist2 (channel-distance ho2 1 ind 1)))
			  (if (or (fneq dist1 0.0) (fneq dist2 0.0))
			      (snd-display #__line__ ";stereo->mono->stereo distances: ~A ~A" dist1 dist2))))
		    (close-sound ho2))))
	    (close-sound hi1)
	    (close-sound hi2))
	  (close-sound ind))
	(if (file-exists? "hi1.snd") (delete-file "hi1.snd"))
	(if (file-exists? "hi2.snd") (delete-file "hi2.snd"))
	(if (file-exists? "ho2.snd") (delete-file "ho2.snd"))
	
	(let ((ind (new-sound :size 1000)))
	  (map-channel (lambda (y) 0.5))
	  (map-channel (vibro 1000.0 .5))
	  (let ((vals (channel->vct 0 20)))
	    (if (and (not (vequal vals (vct 0.375 0.410 0.442 0.469 0.489 0.499 0.499 0.489 0.470 0.443 0.411 0.376 
					    0.341 0.308 0.281 0.262 0.251 0.251 0.261 0.280)))
		     (not (vequal vals (vct 0.375 0.393 0.410 0.427 0.442 0.457 0.469 0.480 0.489 0.495 0.499 0.500 
					    0.499 0.495 0.489 0.480 0.470 0.457 0.443 0.428))))
		(snd-display #__line__ ";no vibro? ~A" vals)))
	  (let ((new-file-name (file-name ind)))
	    (close-sound ind)
	    (if (file-exists? new-file-name) (delete-file new-file-name))))
	
	(let ((ind (open-sound "pistol.snd")))
	  (transposed-echo 1.1 .95 .25)
	  (play :wait #t)
	  (set! (channel-property 'colored-samples ind 0) (list (list (cursor-color) 0 100)))
	  (add-hook! after-graph-hook display-samples-in-color)
	  (update-time-graph)
	  (repitch-sound 220.0 440.0)
	  (uncolor-samples)
	  (retime-sound 1.0)
	  (close-sound ind))
	(remove-hook! after-graph-hook display-samples-in-color)
	
	(let ((val 0)) 
	  (tree-for-each (lambda (n) (set! val (+ val n))) (list (list 1 0) (list 2) 3))
	  (if (not (= val 6)) (snd-display #__line__ ";tree-for-each: ~A" val)))
	
	(let ((ind (new-sound :channels 4 :size 32)))
	  (set! (sample 0 ind 0) 0.5)
	  (set! (sample 10 ind 1) 0.25)
	  (set! (sample 20 ind 2) 0.125)
	  (set! (sample 30 ind 3) 0.0625)
	  (scramble-channels 3 2 0 1)                ; 3->0, 2->1, 0->2 1->3
	  (if (or (fneq (sample 0 ind 2) .5)         ; chan 0 is 2 after swaps
		  (fneq (sample 10 ind 3) .25)
		  (fneq (sample 20 ind 1) .125)
		  (fneq (sample 30 ind 0) .0625))
	      (snd-display #__line__ ";scramble-channels: ~A ~A ~A ~A (~A ~A ~A ~A)" 
			   (sample 0 ind 2) (sample 10 ind 3) (sample 20 ind 1) (sample 30 ind 2)
			   (sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
	  (do ((i 0 (+ 1 i))) ((= i 4)) (set! (edit-position ind i) 1))
	  (scramble-channels 3 0 1 2)
	  (if (or (fneq (sample 0 ind 1) .5)
		  (fneq (sample 10 ind 2) .25)
		  (fneq (sample 20 ind 3) .125)
		  (fneq (sample 30 ind 0) .0625))
	      (snd-display #__line__ ";scramble-channels (1): ~A ~A ~A ~A (~A ~A ~A ~A)" 
			   (sample 0 ind 1) (sample 10 ind 2) (sample 20 ind 3) (sample 30 ind 0)
			   (sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
	  (do ((i 0 (+ 1 i))) ((= i 4)) (set! (edit-position ind i) 1))
	  (scramble-channels 0 1 3 2)
	  (if (or (fneq (sample 0 ind 0) .5)
		  (fneq (sample 10 ind 1) .25)
		  (fneq (sample 20 ind 3) .125)
		  (fneq (sample 30 ind 2) .0625))
	      (snd-display #__line__ ";scramble-channels (2): ~A ~A ~A ~A (~A ~A ~A ~A)" 
			   (sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 3) (sample 30 ind 2)
			   (sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
	  (do ((i 0 (+ 1 i))) ((= i 4)) (set! (edit-position ind i) 1))
	  (scramble-channels 1 2 3 0)
	  (if (or (fneq (sample 0 ind 3) .5)
		  (fneq (sample 10 ind 0) .25)
		  (fneq (sample 20 ind 1) .125)
		  (fneq (sample 30 ind 2) .0625))
	      (snd-display #__line__ ";scramble-channels (3): ~A ~A ~A ~A (~A ~A ~A ~A)" 
			   (sample 0 ind 3) (sample 10 ind 0) (sample 20 ind 1) (sample 30 ind 2)
			   (sample 0 ind 0) (sample 10 ind 1) (sample 20 ind 2) (sample 30 ind 3)))
	  (do ((i 0 (+ 1 i))) ((= i 4)) (set! (edit-position ind i) 1))
	  (let ((new-file-name (file-name ind)))
	    (close-sound ind)
	    (if (file-exists? new-file-name) (delete-file new-file-name))))
	
	(let ((ind (new-sound :channels 8 :size 10 :comment "new-sound for scramble-channels")))
	  (do ((i 0 (+ 1 i))) ((= i 8)) (set! (sample i ind i) .5))
	  (scramble-channels 1 2 3 4 7 6 5 0)
	  (if (or (fneq (sample 1 ind 0) .5)
		  (fneq (sample 2 ind 1) .5)
		  (fneq (sample 3 ind 2) .5)
		  (fneq (sample 4 ind 3) .5)
		  (fneq (sample 7 ind 4) .5)
		  (fneq (sample 6 ind 5) .5)
		  (fneq (sample 5 ind 6) .5)
		  (fneq (sample 0 ind 7) .5))
	      (snd-display #__line__ ";scramble-channels 8 ways: ~A"
			   (list (sample 1 ind 0) (sample 2 ind 1) (sample 3 ind 2) (sample 4 ind 3)
				 (sample 7 ind 4) (sample 6 ind 5) (sample 5 ind 6) (sample 0 ind 7))))
	  (let ((new-file-name (file-name ind)))
	    (close-sound ind)
	    (if (file-exists? new-file-name) (delete-file new-file-name))))
	
	
	;; ---- *.scm
	(if (defined? 'effects-squelch-channel)
	    (begin
	      (if (or (provided? 'xm) (provided? 'xg))
		  (let ((ctr 1))
		    (for-each
		     (lambda (func1 descr)
		       (func1)
		       (let ((func (edit-list->function)))
					;(display (format #f "~A: ~A~%" ctr (procedure-source func)))
			 (if (not (string=? (object->string (procedure-source func)) descr))
			     (snd-display #__line__ ";edit-list->function 20[~D]:~%;  [~A]~%;  [~A]" ctr descr (object->string (procedure-source func))))
			 (revert-sound ind)
			 (func ind 0))
		       (set! ctr (+ 1 ctr))
		       (revert-sound ind))
		     (list 
		      (lambda () (insert-vct (vct 1.0 0.5) 0 2))
		      (lambda () (clm-channel-test))
		      
		      ;; examp.scm
		      (lambda () (fft-edit 1000 3000))
		      (lambda () (fft-squelch .01))
		      (lambda () (fft-cancel 1000 3000))
		      (lambda () (squelch-vowels))
		      (lambda () (fft-env-edit '(0 0 1 1 2 0)))
		      (lambda () (fft-env-interp '(0 0 1 1 2 0) '(0 1 1 0 2 0) '(0 0 1 1)))
		      (lambda () (hello-dentist 10.0 .1))
		      (lambda () (fp 1.0 0.3 20.0))
		      (lambda () (expsnd '(0 1 1 2)))
		      (lambda () (voiced->unvoiced 1.0 256 2.0 2.0))
		      (lambda () (env-sound-interp '(0 0 1 1 2 0) 2.0))
		      (lambda () (add-notes '(("1a.snd") ("pistol.snd" 1.0 2.0))))
		      (lambda () (compand-channel))
		      (lambda () (smooth-channel-via-ptree))
		      (lambda () (ring-modulate-channel 300))
		      (lambda () (filtered-env '(0 0 1 1 2 0)))
		      (lambda () (reverse-by-blocks .1))
		      (lambda () (reverse-within-blocks .1))
		      
		      ;; extensions.scm
		      (lambda () (mix-channel "1a.snd" 1200))
		      (lambda () (insert-channel "1a.snd" 1200))
		      (lambda () (sine-ramp 0.5 0.9))
		      (lambda () (sine-env-channel '(0 0 1 1 2 -0.5 3 1)))
		      (lambda () (blackman4-ramp 0.0 1.0))
		      (lambda () (blackman4-env-channel '(0 0 1 1 2 -0.5 3 1)))
		      (lambda () (ramp-squared 0.2 0.8 #t))
		      (lambda () (env-squared-channel '(0.0 0.0 1.0 1.0) #t))
		      (lambda () (ramp-expt 0.2 0.8 32.0 #t))
		      (lambda () (env-expt-channel '(0.0 0.0 1.0 1.0) 32.0 #t))
		      (lambda () (offset-channel .1))
		      (lambda () (dither-channel .1))
		      (lambda () (contrast-channel .1))
		      
		      ;; dsp.scm
		      (lambda () (ssb-bank 550 600 10))
		      (lambda () (ssb-bank-env 550 600 '(0 1 1 2) 10))	   
		      (lambda () (down-oct 1))
		      (lambda () (freqdiv 8))
		      (lambda () (adsat 8))
		      (lambda () (spike))
		      (lambda () (zero-phase))
		      (lambda () (rotate-phase (lambda (x) (random pi))))
		      (lambda () (brighten-slightly .5))
		      (lambda () (shift-channel-pitch 100))
		      (lambda () (channel-polynomial (vct 0.0 0.5)))
		      (lambda () (spectral-polynomial (vct 0.0 1.0)))
		      (lambda () (notch-channel (list 60.0 120.0 240.0) #f #f #f))
		      
		      ;; ---- new-effects.scm
		      (lambda () (effects-squelch-channel .1 128))
		      (lambda () (effects-echo #f 0.5 0.1 0 #f))
		      (lambda () (effects-flecho-1 0.5 0.1 #f 0 #f))
		      (lambda () (effects-zecho-1 0.75 0.75 6.0 10.0 #f 0 #f))
		      ;;		      (lambda () (effects-comb-filter 0.1 50 0 #f))
		      (lambda () (effects-moog 10000 0.5 0 #f))
		      (lambda () (effects-remove-dc))
		      (lambda () (effects-compand))
		      (lambda () (effects-am 100.0 #f))
		      (lambda () (effects-rm 100.0 #f))
		      (lambda () (effects-bbp 1000.0 100.0 0 #f))
		      (lambda () (effects-bbr 1000.0 100.0 0 #f))
		      (lambda () (effects-bhp 1000.0 0 #f))
		      (lambda () (effects-blp 1000.0 0 #f))
		      (lambda () (effects-hello-dentist 50.0 0.5 0 #f))
		      (lambda () (effects-fp 1.0 0.3 20.0 0 #f))
		      (lambda () (effects-flange 5.0 2.0 0.001 0 #f))
		      (lambda () (effects-jc-reverb-1 0.1 0 #f))
		      
		      )
		     (list 
		      "(lambda (snd chn) (insert-vct (vct 1.0 0.5) 0 2 snd chn))"
		      "(lambda (snd chn) (clm-channel-test snd chn))"
		      
		      "(lambda (snd chn) (fft-edit 1000 3000 snd chn))"
		      "(lambda (snd chn) (fft-squelch 0.01 snd chn))"
		      "(lambda (snd chn) (fft-cancel 1000 3000 snd chn))"
		      "(lambda (snd chn) (squelch-vowels snd chn))"
		      "(lambda (snd chn) (fft-env-edit (quote (0 0 1 1 2 0)) snd chn))"
		      "(lambda (snd chn) (fft-env-interp (quote (0 0 1 1 2 0)) (quote (0 1 1 0 2 0)) (quote (0 0 1 1)) snd chn))"
		      "(lambda (snd chn) (hello-dentist 10.0 0.1 snd chn))"
		      "(lambda (snd chn) (fp 1.0 0.3 20.0 snd chn))"
		      "(lambda (snd chn) (expsnd (quote (0 1 1 2)) snd chn))"
		      "(lambda (snd chn) (voiced->unvoiced 1.0 256 2.0 2.0 snd chn))"
		      "(lambda (snd chn) (env-sound-interp (quote (0 0 1 1 2 0)) 2.0 snd chn))"
		      "(lambda (snd chn) (add-notes (quote ((\"1a.snd\") (\"pistol.snd\" 1.0 2.0))) snd chn))"
		      "(lambda (snd chn) (compand-channel 0 #f snd chn))"
		      "(lambda (snd chn) (smooth-channel-via-ptree 0 #f snd chn))"
		      "(lambda (snd chn) (ring-modulate-channel 300 0 #f snd chn))"
		      "(lambda (snd chn) (filtered-env (quote (0 0 1 1 2 0)) snd chn))"
		      "(lambda (snd chn) (reverse-by-blocks 0.1 snd chn))"
		      "(lambda (snd chn) (reverse-within-blocks 0.1 snd chn))"
		      
		      "(lambda (snd chn) (mix-channel \"1a.snd\" 1200 #f snd chn))"
		      "(lambda (snd chn) (insert-channel \"1a.snd\" 1200 #f snd chn))"
		      "(lambda (snd chn) (sine-ramp 0.5 0.9 0 #f snd chn))"
		      "(lambda (snd chn) (sine-env-channel (quote (0 0 1 1 2 -0.5 3 1)) 0 #f snd chn))"
		      "(lambda (snd chn) (blackman4-ramp 0.0 1.0 0 #f snd chn))"
		      "(lambda (snd chn) (blackman4-env-channel (quote (0 0 1 1 2 -0.5 3 1)) 0 #f snd chn))"
		      "(lambda (snd chn) (ramp-squared 0.2 0.8 #t 0 #f snd chn))"
		      "(lambda (snd chn) (env-squared-channel (quote (0.0 0.0 1.0 1.0)) #t 0 #f snd chn))"
		      "(lambda (snd chn) (ramp-expt 0.2 0.8 32.0 #t 0 #f snd chn))"
		      "(lambda (snd chn) (env-expt-channel (quote (0.0 0.0 1.0 1.0)) 32.0 #t 0 #f snd chn))"
		      "(lambda (snd chn) (offset-channel 0.1 0 #f snd chn))"
		      "(lambda (snd chn) (dither-channel 0.1 0 #f snd chn))"
		      "(lambda (snd chn) (contrast-channel 0.1 0 #f snd chn))"
		      
		      "(lambda (snd chn) (ssb-bank 550 600 10 40 50.0 0 #f snd chn))"
		      "(lambda (snd chn) (ssb-bank-env 550 600 (quote (0 1 1 2)) 10 40 50.0 0 #f snd chn))"
		      "(lambda (snd chn) (down-oct 1 snd chn))"
		      "(lambda (snd chn) (freqdiv 8 snd chn))"
		      "(lambda (snd chn) (adsat 8 #f #f snd chn))"
		      "(lambda (snd chn) (spike snd chn))"
		      "(lambda (snd chn) (zero-phase snd chn))"
		      "(lambda (snd chn) (rotate-phase (lambda (x) (random pi)) snd chn))"
		      "(lambda (snd chn) (brighten-slightly 0.5 snd chn))"
		      "(lambda (snd chn) (shift-channel-pitch 100 40 0 #f snd chn))"
		      "(lambda (snd chn) (channel-polynomial (vct 0.0 0.5) snd chn))"
		      "(lambda (snd chn) (spectral-polynomial (vct 0.0 1.0) snd chn))"
		      "(lambda (snd chn) (notch-channel (quote (60.0 120.0 240.0)) #f #f #f snd chn))"
		      
		      "(lambda (snd chn) (effects-squelch-channel 0.1 128 snd chn))"
		      "(lambda (snd chn) (effects-echo #f 0.5 0.1 0 #f snd chn))"
		      "(lambda (snd chn) (effects-flecho-1 0.5 0.1 #f 0 #f snd chn))"
		      "(lambda (snd chn) (effects-zecho-1 0.75 0.75 6.0 10.0 #f 0 #f snd chn))"
		      ;;		      "(lambda (snd chn) (effects-comb-filter 0.1 50 0 #f snd chn))"
		      "(lambda (snd chn) (effects-moog 10000 0.5 0 #f snd chn))"
		      "(lambda (snd chn) (effects-remove-dc snd chn))"
		      "(lambda (snd chn) (effects-compand snd chn))"
		      "(lambda (snd chn) (effects-am 100.0 #f #f #f snd chn))"
		      "(lambda (snd chn) (effects-rm 100.0 #f #f #f snd chn))"
		      "(lambda (snd chn) (effects-bbp 1000.0 100.0 0 #f snd chn))"
		      "(lambda (snd chn) (effects-bbr 1000.0 100.0 0 #f snd chn))"
		      "(lambda (snd chn) (effects-bhp 1000.0 0 #f snd chn))"
		      "(lambda (snd chn) (effects-blp 1000.0 0 #f snd chn))"
		      "(lambda (snd chn) (effects-hello-dentist 50.0 0.5 0 #f snd chn))"
		      "(lambda (snd chn) (effects-fp 1.0 0.3 20.0 0 #f snd chn))"
		      "(lambda (snd chn) (effects-flange 5.0 2.0 0.001 0 #f snd chn))"
		      "(lambda (snd chn) (effects-jc-reverb-1 0.1 0 #f snd chn))"
		      
		      )
		     )))))
	
	(close-sound ind)
	))
    
    ;; ---- apply controls edit lists
    (let* ((ind (open-sound "oboe.snd"))
	   (original-maxamp (maxamp)))
      (reset-controls)
      (controls->channel (list 2.0))
      (if (fneq (amp-control ind) 1.0) (snd-display #__line__ ";controls->channel amp: ~A" (amp-control ind)))
      (if (fneq (maxamp) (* 2 original-maxamp)) (snd-display #__line__ ";controls->channel maxamp: ~A" (maxamp)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (scale-channel 2.0 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 1: ~A" (object->string (procedure-source func))))
	(func ind 0)
	(revert-sound ind))
      
      (controls->channel (list #f 2.0))
      (let ((pk (vct-peak (channel->vct 22000 22100))))
	(if (fneq pk 0.0479) (snd-display #__line__ ";dp->end screwed up again!?!: ~A" pk)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (controls->channel (quote (#f 2.0)) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 2: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (fneq (speed-control ind) 1.0) (snd-display #__line__ ";controls->channel speed: ~A" (speed-control ind))))
      
      (controls->channel (list #f #f (list 0.5)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (controls->channel (quote (#f #f (0.5))) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 3: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (fneq (contrast-control ind) 0.0) (snd-display #__line__ ";controls->channel contrast: ~A" (contrast-control ind))))
      
      (controls->channel (list #f #f (list 0.5 2.0)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (controls->channel (quote (#f #f (0.5 2.0))) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 3a: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (fneq (contrast-control ind) 0.0) (snd-display #__line__ ";controls->channel contrast 3a: ~A" (contrast-control ind))))
      
      (controls->channel (list #f #f #f (list 0.5)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (controls->channel (quote (#f #f #f (0.5))) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 4: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (ffneq (expand-control ind) 1.0) (snd-display #__line__ ";controls->channel expand: ~A" (expand-control ind))))
      
      (controls->channel (list #f #f #f (list 0.5 .1 .2 .06 0.0)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) 
			   "(lambda (snd chn) (controls->channel (quote (#f #f #f (0.5 0.1 0.2 0.06 0.0))) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 4a: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (ffneq (expand-control ind) 1.0) (snd-display #__line__ ";controls->channel expand 4a: ~A" (expand-control ind))))
      
      (controls->channel (list #f #f #f #f (list 0.1)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (controls->channel (quote (#f #f #f #f (0.1))) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 5: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (fneq (reverb-control-scale ind) 0.0) (snd-display #__line__ ";controls->channel reverb: ~A" (reverb-control-scale ind))))
      
      (controls->channel (list #f #f #f #f (list 0.1 1.2 0.9 0.9 2.0)))
      (let ((func (edit-list->function)))
	(if (not (string=? (object->string (procedure-source func)) 
			   "(lambda (snd chn) (controls->channel (quote (#f #f #f #f (0.1 1.2 0.9 0.9 2.0))) 0 #f snd chn))"))
	    (snd-display #__line__ ";edit-list->function controls->channel 5a: ~A" (object->string (procedure-source func))))
	(revert-sound ind)
	(func ind 0)
	(revert-sound ind)
	(if (fneq (reverb-control-scale ind) 0.0) (snd-display #__line__ ";controls->channel reverb 5a: ~A" (reverb-control-scale ind))))
      
      (let ((order (filter-control-order ind)))
	(controls->channel (list #f #f #f #f #f (list 10 '(0 0 1 1))))
	(let ((func (edit-list->function)))
	  (if (not (string=? (object->string (procedure-source func)) 
			     "(lambda (snd chn) (controls->channel (quote (#f #f #f #f #f (10 (0 0 1 1)))) 0 #f snd chn))"))
	      (snd-display #__line__ ";edit-list->function controls->channel 6: ~A" (object->string (procedure-source func))))
	  (revert-sound ind)
	  (func ind 0)
	  (revert-sound ind)
	  (if (not (= (filter-control-order ind) order)) (snd-display #__line__ ";controls->channel filter: ~A" (filter-control-order ind)))))
      
      
      (if (not (provided? 'snd-nogui))
	  ;; ---- mix stuff
	  (let ((id (make-v-mix ind 0)))
	    ;; ---- mix-position
	    (if (mix? id)
		(begin
		  (set! (mix-position id) 200)
		  (if (not (= (mix-position id) 200)) (snd-display #__line__ ";edit-list->function mix off to a bad start: ~A" (mix-position id)))
		  (let ((func (edit-list->function)))
		    (if (not (procedure? func)) 
			(snd-display #__line__ ";edit-list->function mix 1: ~A" func))
		    (if (not (string=? (object->string (procedure-source func))
				       (format #f "(lambda (snd chn) (let ((-mix-~D #f)) (set! -mix-~D (mix-vct (vct 0.1 0.2 0.3) 100 snd chn)) (set! (mix-position -mix-~D) 200)))"
					       (mix->integer id) (mix->integer id) (mix->integer id))))
			(snd-display #__line__ ";edit-list->function mix 1: ~A" (object->string (procedure-source func))))
		    (revert-sound ind)
		    (func ind 0)
		    (if (or (null? (mixes ind 0))
			    (not (member 200 (map (lambda (m) (and (mix? m) (mix-position m))) (mixes ind 0)))))
			(snd-display #__line__ ";edit-list->function mix 1 repos: ~A ~A" 
				     (mixes ind 0) (map (lambda (m) (and (mix? m) (mix-position m))) (mixes ind 0)))))))
	    (revert-sound ind)
	    
	    ;; ---- mix-amp
	    (set! id (make-v-mix ind 0))
	    (if (mix? id)
		(begin
		  (set! (mix-amp id) 0.5)
		  (let ((func (edit-list->function)))
		    (if (not (procedure? func)) 
			(snd-display #__line__ ";edit-list->function mix 4: ~A" func))
		    (if (not (string=? (object->string (procedure-source func))
				       (format #f "(lambda (snd chn) (let ((-mix-~D #f)) (set! -mix-~D (mix-vct (vct 0.1 0.2 0.3) 100 snd chn)) (set! (mix-amp -mix-~D) 0.5)))"
					       (mix->integer id) (mix->integer id) (mix->integer id))))
			(snd-display #__line__ ";edit-list->function mix 4: ~A" (object->string (procedure-source func))))
		    (revert-sound ind)
		    (func ind 0))))
	    (revert-sound ind)
	    
	    ;; ---- mix-speed
	    (if (mix? id)
		(begin
		  (set! id (make-v-mix ind 0))
		  (set! (mix-speed id) 0.5)
		  (let ((func (edit-list->function)))
		    (if (not (procedure? func)) 
			(snd-display #__line__ ";edit-list->function mix 5: ~A" func))
		    (if (not (string=? (object->string (procedure-source func))
				       (format #f "(lambda (snd chn) (let ((-mix-~D #f)) (set! -mix-~D (mix-vct (vct 0.1 0.2 0.3) 100 snd chn)) (set! (mix-speed -mix-~D) 0.5)))"
					       (mix->integer id) (mix->integer id) (mix->integer id))))
			(snd-display #__line__ ";edit-list->function mix 5: ~A" (object->string (procedure-source func))))
		    (revert-sound ind)
		    (func ind 0))))
	    (revert-sound ind)))
      
      (close-sound ind))
    
    (let ((ind (open-sound "2.snd")))
      (src-sound 3.0 1.0 ind)
      (save-sound-as "test.snd")
      (close-sound ind)
      (set! ind (open-sound "test.snd"))
      (if (not (= (chans ind) 2)) (snd-display #__line__ ";src-sound/save-sound-as-> ~D chans" (chans ind)))
      (let ((tag (scan-channel (lambda (y) (not (= y 0.0))) 8000 #f)))
	(if tag (snd-display #__line__ ";src-sound/save-sound-as not zeros: ~A ~A" tag (sample (cadr tag) ind 0))))
      (close-sound ind))
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((tag (catch #t (lambda () (save-sound-as "test.snd" :edit-position 1)) (lambda args args))))
	(if (or (not tag)
		(not (eq? (car tag) 'no-such-edit)))
	    (snd-display #__line__ ";save-sound-as bad edpos: ~A" tag)))
      (let ((tag (catch #t (lambda () (save-sound-as "test.snd" :channel 1 :edit-position 1)) (lambda args args))))
	(if (or (not tag)
		(not (eq? (car tag) 'no-such-channel)))
	    (snd-display #__line__ ";save-sound-as bad chan: ~A" tag)))
      (save-sound-as "test.snd" :comment "this is a comment")
      (close-sound ind)
      (set! ind (open-sound "test.snd"))
      (if (not (string=? (comment ind) "this is a comment"))
	  (snd-display #__line__ ";save-sound-as with comment: ~A" (comment ind)))
      (close-sound ind))
    
    (mus-sound-prune)
    ))


;;; ---------------- test 20: transforms ----------------
(define (snd_test_20)
  
  (define (bes-j0-1 x)				;returns J0(x) for any real x
    (if (< (abs x) 8.0)			;direct rational function fit
	(let* ((y (* x x))
	       (ans1 (+ 57568490574.0
			(* y (+ -13362590354.0 
				(* y  (+ 651619640.7
					 (* y (+ -11214424.18 
						 (* y (+ 77392.33017
							 (* y -184.9052456)))))))))))
	       (ans2 (+ 57568490411.0 
			(* y (+ 1029532985.0 
				(* y (+ 9494680.718
					(* y (+ 59272.64853
						(* y (+ 267.8532712 y)))))))))))
	  (/ ans1 ans2))
	(let* ((ax (abs x))
	       (z (/ 8.0 ax))
	       (y (* z z))
	       (xx (- ax 0.785398164))
	       (ans1 (+ 1.0 
			(* y (+ -0.1098628627e-2 
				(* y (+ 0.2734510407e-4
					(* y (+ -0.2073370639e-5
						(* y 0.2093887211e-6)))))))))
	       (ans2 (+ -0.1562499995e-1
			(* y (+ 0.1430488765e-3
				(* y (+ -0.6911147651e-5
					(* y (+ 0.7621095161e-6
						(* y -0.934945152e-7))))))))))
	  (* (sqrt (/ 0.636619772 ax))
	     (- (* (cos xx) ans1)
		(* z (sin xx) ans2))))))
  
  (define (test-j0)
    (for-each 
     (lambda (x)
       (if (fneq (bes-j0 x) (bes-j0-1 x))
	   (snd-display #__line__ ";(bes-j0 ~A) -> ~A ~A" x (bes-j0 x) (bes-j0-1 x))))
     (list 0.0 0.5 1.0 2.0 20.0))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((x (random 100.0)))
	(if (fneq (bes-j0 x) (bes-j0-1 x))
	    (snd-display #__line__ ";(bes-j0 ~A) -> ~A ~A" x (bes-j0 x) (bes-j0-1 x))))))
  
  
  (define (bes-j1-1 x)				;returns J1(x) for any real x
    (define (signum x) (if (= x 0.0) 0 (if (< x 0.0) -1 1)))
    (if (< (abs x) 8.0)
	(let* ((y (* x x))
	       (ans1 (* x 
			(+ 72362614232.0
			   (* y (+ -7895059235.0
				   (* y (+ 242396853.1
					   (* y (+ -2972611.439
						   (* y (+ 15704.48260
							   (* y -30.16036606))))))))))))
	       (ans2 (+ 144725228442.0 
			(* y (+ 2300535178.0 
				(* y (+ 18583304.74
					(* y (+ 99447.43394
						(* y (+ 376.9991397 y)))))))))))
	  (/ ans1 ans2))
	(let* ((ax (abs x))
	       (z (/ 8.0 ax))
	       (y (* z z))
	       (xx (- ax 2.356194491))
	       (ans1 (+ 1.0
			(* y (+ 0.183105e-2
				(* y (+ -0.3516396496e-4
					(* y (+ 0.2457520174e-5
						(* y -0.240337019e-6)))))))))
	       (ans2 (+ 0.04687499995
			(* y (+ -0.2002690873e-3
				(* y (+ 0.8449199096e-5
					(* y (+ -0.88228987e-6
						(* y 0.105787412e-6))))))))))
	  (* (signum x)
	     (sqrt (/ 0.636619772 ax))
	     (- (* (cos xx) ans1)
		(* z (sin xx) ans2))))))
  
  (define (test-j1)
    (for-each 
     (lambda (x)
       (if (fneq (bes-j1 x) (bes-j1-1 x))
	   (snd-display #__line__ ";(bes-j1 ~A) -> ~A ~A" x (bes-j1 x) (bes-j1-1 x))))
     (list 0.0 0.5 1.0 2.0 20.0))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((x (random 100.0)))
	(if (fneq (bes-j1 x) (bes-j1-1 x))
	    (snd-display #__line__ ";(bes-j1 ~A) -> ~A ~A" x (bes-j1 x) (bes-j1-1 x))))))
  
  (define (bes-jn-1 nn x)				;return Jn(x) for any integer n, real x
    (let* ((n (abs nn))
	   (besn (if (= n 0) 
		     (bes-j0-1 x)
		     (if (= n 1) 
			 (bes-j1-1 x)
			 (if (= x 0.0) 
			     0.0
			     (let ((iacc 40)	;make iacc larger to increase accuracy
				   (ans 0.0)
				   (bigno 1.0e10)
				   (bigni 1.0e-10))
			       (if (> (abs x) n) ;can use upward recurrence from J0 and J1
				   (do ((tox (/ 2.0 (abs x)))
					(bjm (bes-j0-1 (abs x)))
					(bj (bes-j1-1 (abs x)))
					(j 1 (+ j 1))
					(bjp 0.0))
				       ((= j n) (set! ans bj))
				     (set! bjp (- (* j tox bj) bjm))
				     (set! bjm bj)
				     (set! bj bjp))
				   (let ((tox (/ 2.0 (abs x))) ;else use downward recurrence from even value (m)
					 (m (* 2 (floor (/ (+ n (sqrt (* iacc n))) 2))))
					 (jsum 0) ;alternate 0 and 1 -- when 1, accumulate even terms in sum
					 (bjm 0.0)
					 (sum 0.0)
					 (bjp 0.0)
					 (bj 1.0))
				     (do ((j m (- j 1))) ;the downward recurrence
					 ((= j 0))
				       (set! bjm (- (* j tox bj) bjp))
				       (set! bjp bj)
				       (set! bj bjm)
				       (if (> (abs bj) bigno) ;renormalize (may not be necessary in common lisp)
					   (begin
					     (set! bj (* bj bigni))
					     (set! bjp (* bjp bigni))
					     (set! ans (* ans bigni))
					     (set! sum (* sum bigni))))
				       (if (not (= 0 jsum)) (set! sum (+ sum bj)))
				       (set! jsum (- 1 jsum))
				       (if (= j n) (set! ans bjp)))
				     (set! sum (- (* 2.0 sum) bj))
				     (set! ans (/ ans sum))))
			       (if (and (< x 0.0) (odd? n)) (- ans) ans)))))))
      (if (and (< nn 0)
	       (odd? nn))
	  (- besn)
	  besn)))
  
  (define (test-jn)
    (do ((k 0 (+ 1 k)))
	((= k 10))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((x (random 100.0)))
	  (if (fneq (bes-jn k x) (bes-jn-1 k x))
	      (snd-display #__line__ ";(bes-jn ~A ~A) -> ~A ~A" k x (bes-jn k x) (bes-jn-1 k x)))))))
  
  
  (define (bes-y0-1 x)				;Bessel function Y0(x)
    (if (< x 8.0)
	(let* ((y (* x x))
	       (ans1 (+ -2957821389.0 
			(* y (+ 7062834065.0
				(* y (+ -512359803.6
					(* y (+ 10879881.29
						(* y (+ -86327.92757
							(* y 228.4622733)))))))))))
	       (ans2 (+ 40076544269.0
			(* y (+ 745249964.8
				(* y (+ 7189466.438
					(* y (+ 47447.26470
						(* y (+ 226.1030244 y)))))))))))
	  (+ (/ ans1 ans2) (* 0.636619772 (bes-j0 x) (log x))))
	(let* ((z (/ 8.0 x))
	       (y (* z z))
	       (xx (- x 0.785398164))
	       (ans1 (+ 1.0
			(* y (+ -0.1098628627e-2
				(* y (+ 0.2734510407e-4
					(* y (+ -0.2073370639e-5
						(* y 0.2093887211e-6)))))))))
	       (ans2 (+ -0.1562499995e-1
			(* y (+ 0.1430488765e-3
				(* y (+ -0.6911147651e-5
					(* y (+ 0.7621095161e-6
						(* y -0.934945152e-7)))))))))
	       (ans (+ (* (sin xx) ans1) (* z (cos xx) ans2))))
	  (* (sqrt (/ 0.636619772 x)) ans))))
  
  (define (test-y0)
    (for-each 
     (lambda (x)
       (if (fneq (bes-y0 x) (bes-y0-1 x))
	   (snd-display #__line__ ";(bes-y0 ~A) -> ~A ~A" x (bes-y0 x) (bes-y0-1 x))))
     (list 0.5 1.0 2.0 20.0))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((x (random 100.0)))
	(if (fneq (bes-y0 x) (bes-y0-1 x))
	    (snd-display #__line__ ";(bes-y0 ~A) -> ~A ~A" x (bes-y0 x) (bes-y0-1 x))))))
  
  (define (bes-y1-1 x)				;Bessel function Y1(x)
    (if (= x 0.0)
	-inf.0
	(if (< x 8.0)
	    (let* ((y (* x x))
		   (ans1 (* x (+ -0.4900604943e13
				 (* y (+ 0.1275274390e13
					 (* y (+ -0.5153438139e11
						 (* y (+ 0.7349264551e9
							 (* y (+ -0.4237922726e7
								 (* y 0.8511937935e4))))))))))))
		   (ans2 (+ 0.2499580570e14
			    (* y (+ 0.4244419664e12
				    (* y (+ 0.3733650367e10
					    (* y (+ 0.2245904002e8
						    (* y (+ 0.1020426050e6
							    (* y (+ 0.3549632885e3 y)))))))))))))
	      (+ (/ ans1 ans2) (* 0.636619772 (- (* (bes-j1 x) (log x)) (/ 1.0 x)))))
	    (let* ((z (/ 8.0 x))
		   (y (* z z))
		   (xx (- x 2.356194491))
		   (ans1 (+ 1.0 
			    (* y (+ 0.183105e-2
				    (* y (+ -0.3516396496e-4
					    (* y (+ 0.2457520174e-5
						    (* y -0.240337019e-6)))))))))
		   (ans2 (+ 0.04687499995
			    (* y (+ -0.200269087e-3
				    (* y (+ 0.8449199096e-5
					    (* y (+ -0.88228987e-6
						    (* y 0.105787412e-6))))))))))
	      (* (sqrt (/ 0.636619772 x)) (+ (* (sin xx) ans1) (* z (cos xx) ans2)))))))
  
  (define (test-y1)
    (for-each 
     (lambda (x)
       (if (fneq (bes-y1 x) (bes-y1-1 x))
	   (snd-display #__line__ ";(bes-y1 ~A) -> ~A ~A" x (bes-y1 x) (bes-y1-1 x))))
     (list 0.01 0.5 1.0 2.0 20.0))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((x (random 100.0)))
	(if (fneq (bes-y1 x) (bes-y1-1 x))
	    (snd-display #__line__ ";(bes-y1 ~A) -> ~A ~A" x (bes-y1 x) (bes-y1-1 x))))))
  
  (define (bes-yn-1 n x)				;return Yn(x) for any integer n, real x
    (if (= n 0) 
	(bes-y0-1 x)
	(if (= n 1) 
	    (bes-y1-1 x)
	    (do ((tox (/ 2.0 x))
		 (byp 0.0)
		 (by (bes-y1-1 x))
		 (bym (bes-y0-1 x))
		 (j 1 (+ j 1)))
		((= j n) by)
	      (set! byp (- (* j tox by) bym))
	      (set! bym by)
	      (set! by byp)))))
  
  (define (test-yn)
    (do ((k 0 (+ 1 k)))
	((= k 10))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(let ((x (random 100.0)))
	  (if (fneq (/ (bes-yn k x) (bes-yn-1 k x)) 1.0)
	      (snd-display #__line__ ";(bes-yn ~A ~A) -> ~A ~A" k x (bes-yn k x) (bes-yn-1 k x)))))))
  
  
  (define (bes-i0-1 x)			;I0(x)
    (if (< (abs x) 3.75)
	(let* ((y (expt (/ x 3.75) 2)))
	  (+ 1.0
	     (* y (+ 3.5156229
		     (* y (+ 3.0899424
			     (* y (+ 1.2067492
				     (* y (+ 0.2659732
					     (* y (+ 0.360768e-1
						     (* y 0.45813e-2)))))))))))))
	(let* ((ax (abs x))
	       (y (/ 3.75 ax)))
	  (* (/ (exp ax) (sqrt ax)) 
	     (+ 0.39894228
		(* y (+ 0.1328592e-1
			(* y (+ 0.225319e-2
				(* y (+ -0.157565e-2
					(* y (+ 0.916281e-2
						(* y (+ -0.2057706e-1
							(* y (+ 0.2635537e-1
								(* y (+ -0.1647633e-1
									(* y 0.392377e-2))))))))))))))))))))
  
  (define (test-i0)
    (for-each 
     (lambda (x)
       (if (fneq (bes-i0 x) (bes-i0-1 x))
	   (snd-display #__line__ ";(bes-i0 ~A) -> ~A ~A" x (bes-i0 x) (bes-i0-1 x))))
     (list 0.0 0.5 1.0 2.0 0.01))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((x (random 1.0)))
	(if (fneq (bes-i0 x) (bes-i0-1 x))
	    (snd-display #__line__ ";(bes-i0 ~A) -> ~A ~A" x (bes-i0 x) (bes-i0-1 x))))))
  
  (define (bes-i1 x)				;I1(x)
    (if (< (abs x) 3.75)
	(let* ((y (expt (/ x 3.75) 2)))
	  (* x (+ 0.5
		  (* y (+ 0.87890594
			  (* y (+ 0.51498869
				  (* y (+ 0.15084934
					  (* y (+ 0.2658733e-1
						  (* y (+ 0.301532e-2
							  (* y 0.32411e-3))))))))))))))
	(let* ((ax (abs x))
	       (y (/ 3.75 ax))
	       (ans1 (+ 0.2282967e-1
			(* y (+ -0.2895312e-1
				(* y (+ 0.1787654e-1 
					(* y -0.420059e-2)))))))
	       (ans2 (+ 0.39894228
			(* y (+ -0.3988024e-1
				(* y (+ -0.362018e-2
					(* y (+ 0.163801e-2
						(* y (+ -0.1031555e-1 (* y ans1)))))))))))
	       (sign (if (< x 0.0) -1.0 1.0)))
	  (* (/ (exp ax) (sqrt ax)) ans2 sign))))
  
  (define (test-i1)
    (if (fneq (bes-i1 1.0) 0.565159) (snd-display #__line__ ";bes-i1 1.0: ~A" (bes-i1 1.0)))
    (if (fneq (bes-i1 2.0) 1.59063685) (snd-display #__line__ ";bes-i1 2.0: ~A" (bes-i1 2.0)))
    (if (fneq (bes-i1 5.0) 24.33564) (snd-display #__line__ ";bes-i1 5.0: ~A" (bes-i1 5.0)))
    (if (fneq (bes-i1 10.0) 2670.9883) (snd-display #__line__ ";bes-i1 10.0: ~A" (bes-i1 10.0))))
  
  (define (bes-in n x)			;return In(x) for any integer n, real x
    (if (= n 0) 
	(bes-i0 x)
	(if (= n 1) 
	    (bes-i1 x)
	    (if (= x 0.0) 
		0.0
		(let* ((iacc 40)
		       (bigno 1.0e10)
		       (bigni 1.0e-10)
		       (ans 0.0)
		       (tox (/ 2.0 (abs x)))
		       (bip 0.0)
		       (bi 1.0)
		       (m (* 2 (+ n (truncate (sqrt (* iacc n))))))
		       (bim 0.0))
		  (do ((j m (- j 1)))
		      ((= j 0))
		    (set! bim (+ bip (* j tox bi)))
		    (set! bip bi)
		    (set! bi bim)
		    (if (> (abs bi) bigno)
			(begin
			  (set! ans (* ans bigni))
			  (set! bi (* bi bigni))
			  (set! bip (* bip bigni))))
		    (if (= j n) (set! ans bip)))
		  (if (and (< x 0.0) (odd? n)) (set! ans (- ans)))
		  (* ans (/ (bes-i0 x) bi)))))))
  
  (define (test-in)
    (if (fneq (bes-in 1 1.0) 0.565159) (snd-display #__line__ ";bes-in 1 1.0: ~A" (bes-in 1 1.0)))
    (if (fneq (bes-in 2 1.0) 0.13574767) (snd-display #__line__ ";bes-in 2 1.0: ~A" (bes-in 2 1.0)))
    (if (fneq (bes-in 3 1.0) 0.02216842) (snd-display #__line__ ";bes-in 3 1.0: ~A" (bes-in 3 1.0)))
    (if (fneq (bes-in 5 1.0) 2.71463e-4) (snd-display #__line__ ";bes-in 5 1.0: ~A" (bes-in 5 1.0)))
    (if (fneq (bes-in 10 1.0) 2.752948e-10) (snd-display #__line__ ";bes-in 10 1.0: ~A" (bes-in 10 1.0)))
    
    (if (fneq (bes-in 1 2.0) 1.5906368) (snd-display #__line__ ";bes-in 1 2.0: ~A" (bes-in 1 2.0)))
    (if (fneq (bes-in 2 2.0) 0.6889484) (snd-display #__line__ ";bes-in 2 2.0: ~A" (bes-in 2 2.0)))
    (if (fneq (bes-in 3 2.0) 0.21273995) (snd-display #__line__ ";bes-in 3 2.0: ~A" (bes-in 3 2.0)))
    (if (fneq (bes-in 5 2.0) 0.009825679) (snd-display #__line__ ";bes-in 5 2.0: ~A" (bes-in 5 2.0)))
    (if (fneq (bes-in 10 2.0) 3.016963e-7) (snd-display #__line__ ";bes-in 10 2.0: ~A" (bes-in 10 2.0)))
    
    (if (fneq (bes-in 1 5.0) 24.33564) (snd-display #__line__ ";bes-in 1 5.0: ~A" (bes-in 1 5.0)))
    (if (fneq (bes-in 2 5.0) 17.505615) (snd-display #__line__ ";bes-in 2 5.0: ~A" (bes-in 2 5.0)))
    (if (fneq (bes-in 3 5.0) 10.331150) (snd-display #__line__ ";bes-in 3 5.0: ~A" (bes-in 3 5.0)))
    (if (fneq (bes-in 5 5.0) 2.157974) (snd-display #__line__ ";bes-in 5 5.0: ~A" (bes-in 5 5.0)))
    (if (fneq (bes-in 10 5.0) 0.004580044) (snd-display #__line__ ";bes-in 10 5.0: ~A" (bes-in 10 5.0))))
  
  (define (bes-k0 x)				;K0(x)
    (if (<= x 2.0)
	(let* ((y (* x (/ x 4.0))))
	  (+ (* (- (log (/ x 2.0))) (bes-i0 x)) -0.57721566
	     (* y (+ 0.42278420
		     (* y (+ 0.23069756
			     (* y (+ 0.3488590e-1
				     (* y (+ 0.262698e-2
					     (* y (+ 0.10750e-3
						     (* y 0.74e-5)))))))))))))
	(let* ((y (/ 2.0 x)))
	  (* (/ (exp (- x)) (sqrt x)) 
	     (+ 1.25331414
		(* y (+ -0.7832358e-1
			(* y (+ 0.2189568e-1
				(* y (+ -0.1062446e-1
					(* y (+ 0.587872e-2
						(* y (+ -0.251540e-2
							(* y -0.53208e-3))))))))))))))))
  
  (define (test-k0)
    (if (fneq (bes-k0 1.0) 0.4210244) (snd-display #__line__ ";bes-k0 1.0: ~A" (bes-k0 1.0)))
    (if (fneq (bes-k0 2.0) 0.1138938) (snd-display #__line__ ";bes-k0 2.0: ~A" (bes-k0 2.0)))
    (if (fneq (bes-k0 10.0) 1.7780e-5) (snd-display #__line__ ";bes-k0 10.0: ~A" (bes-k0 10.0))))
  
  (define (bes-k1 x)				;K1(x)
    (if (<= x 2.0)
	(let* ((y (* x (/ x 4.0))))
	  (+ (* (log (/ x 2)) (bes-i1 x)) 
	     (* (/ 1.0 x)
		(+ 1.0
		   (* y (+ 0.15443144
			   (* y (+ -0.67278579
				   (* y (+ -0.18156897
					   (* y (+ -0.1919402e-1
						   (* y (+ -0.110404e-2
							   (* y -0.4686e-4)))))))))))))))
	(let* ((y (/ 2.0 x)))
	  (* (/ (exp (- x)) (sqrt x)) 
	     (+ 1.25331414 
		(* y (+ 0.23498619
			(* y (+ -0.3655620e-1
				(* y (+ 0.1504268e-1
					(* y (+ -0.780353e-2
						(* y (+ 0.325614e-2
							(* y -0.68245e-3))))))))))))))))
  
  (define (test-k1)
    (if (fneq (bes-k1 1.0) 0.60190723) (snd-display #__line__ ";bes-k1 1.0: ~A" (bes-k1 1.0)))
    (if (fneq (bes-k1 2.0) 0.1398658) (snd-display #__line__ ";bes-k1 2.0: ~A" (bes-k1 2.0)))
    (if (fneq (bes-k1 10.0) 1.86487e-5) (snd-display #__line__ ";bes-k1 10.0: ~A" (bes-k1 10.0))))
  
  
  (define (bes-kn n x)			;return Kn(x) for any integer n, real x
    (if (= n 0) 
	(bes-k0 x)
	(if (= n 1) 
	    (bes-k1 x)
	    (do ((tox (/ 2.0 x))
		 (bkm (bes-k0 x))
		 (bk (bes-k1 x))
		 (bkp 0.0)
		 (j 1 (+ j 1)))
		((= j n) bk)
	      (set! bkp (+ bkm (* j tox bk)))
	      (set! bkm bk)
	      (set! bk bkp)))))
  
  (define (test-kn)
    (if (fneq (bes-kn 1 1.0) 0.6019072) (snd-display #__line__ ";bes-kn 1 1.0: ~A" (bes-kn 1 1.0)))
    (if (fneq (bes-kn 2 1.0) 1.6248389) (snd-display #__line__ ";bes-kn 2 1.0: ~A" (bes-kn 2 1.0)))
    (if (fneq (bes-kn 3 1.0) 7.1012629) (snd-display #__line__ ";bes-kn 3 1.0: ~A" (bes-kn 3 1.0)))
    (if (fneq (bes-kn 5 1.0) 360.96059) (snd-display #__line__ ";bes-kn 5 1.0: ~A" (bes-kn 5 1.0)))
    
    (if (fneq (bes-kn 1 2.0) 0.139865) (snd-display #__line__ ";bes-kn 1 2.0: ~A" (bes-kn 1 2.0)))
    (if (fneq (bes-kn 2 2.0) 0.2537597) (snd-display #__line__ ";bes-kn 2 2.0: ~A" (bes-kn 2 2.0)))
    (if (fneq (bes-kn 3 2.0) 0.6473854) (snd-display #__line__ ";bes-kn 3 2.0: ~A" (bes-kn 3 2.0)))
    (if (fneq (bes-kn 5 2.0) 9.431049) (snd-display #__line__ ";bes-kn 5 2.0: ~A" (bes-kn 5 2.0)))
    
    (if (fneq (bes-kn 1 5.0) 0.00404461) (snd-display #__line__ ";bes-kn 1 5.0: ~A" (bes-kn 1 5.0)))
    (if (fneq (bes-kn 2 5.0) 0.0053089) (snd-display #__line__ ";bes-kn 2 5.0: ~A" (bes-kn 2 5.0)))
    (if (fneq (bes-kn 3 5.0) 0.0082917) (snd-display #__line__ ";bes-kn 3 5.0: ~A" (bes-kn 3 5.0)))
    (if (fneq (bes-kn 5 5.0) 0.0327062) (snd-display #__line__ ";bes-kn 5 5.0: ~A" (bes-kn 5 5.0))))
  
  
  (define (gammln xx)			;Ln(gamma(xx)), xx>0 
    (let* ((stp 2.5066282746310005d0)
	   (x xx)
	   (tmp (+ x 5.5))
	   (tmp1 (- tmp (* (+ x 0.5) (log tmp))))
	   (ser (+ 1.000000000190015
		   (/ 76.18009172947146 (+ x 1.0))
		   (/ -86.50532032941677 (+ x 2.0))
		   (/ 24.01409824083091 (+ x 3.0))
		   (/ -1.231739572450155 (+ x 4))
		   (/ 0.1208650973866179e-2 (+ x 5.0))
		   (/ -0.5395239384953e-5 (+ x 6.0)))))
      (- (log (/ (* stp ser) x)) tmp1)))
  
  (define (test-lgamma)
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((x (random 100.0)))
	(if (fneq (lgamma x) (gammln x))
	    (snd-display #__line__ ";(lgamma ~A) -> ~A ~A" x (lgamma x) (gammln x))))))
  
  (define (test-erf)
    (if (fneq (erf 0.0) 0.0) (snd-display #__line__ ";erf 0.0: ~A" (erf 0.0)))
    (if (fneq (erf 0.5) 0.5204998) (snd-display #__line__ ";erf 0.5: ~A" (erf 0.5)))
    (if (fneq (erf 1.0) 0.8427007) (snd-display #__line__ ";erf 0.0: ~A" (erf 1.0)))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((val (random 2.0)))
	(if (fneq (+ (erf val) (erfc val)) 1.0)
	    (snd-display #__line__ ";erf+erfc: ~A (~A + ~A)" 
			 (+ (erf val) (erfc val))
			 (erf val)
			 (erfc val))))))
  
  (define (inverse-haar f)
    (let* ((n (vct-length f))
	   (g (make-vct n))
	   (s2 (sqrt 2.0))
	   (v (/ 1.0 (sqrt n))))
      (vct-set! f 0 (* (vct-ref f 0) v))
      (do ((m 2 (* m 2)))
	  ((> m n))
	(let ((mh (/ m 2)))
	  (do ((j 0 (+ j 2))
	       (k 0 (+ k 1)))
	      ((= j m))
	    (let ((x (vct-ref f k))
		  (y (* (vct-ref f (+ mh k)) v)))
	      (vct-set! g j (+ x y))
	      (vct-set! g (+ j 1) (- x y))))
	  (do ((i (- m 1) (- i 1)))
	      ((< i 0))
	    (vct-set! f i (vct-ref g i)))
	  (set! v (* v s2))))
      f))
  
  (define (wavelet data n isign wf cc)
    (let* ((cc-size (vct-length cc))
	   (ccr (make-vct cc-size))
	   (sig -1.0))
      (do ((i 0 (+ 1 i))
	   (j (- cc-size 1) (- j 1)))
	  ((= i cc-size))
	(vct-set! ccr j (* sig (vct-ref cc i)))
	(set! sig (- sig)))
      (if (>= n 4)
	  (if (>= isign 0)
	      (do ((nn n (/ nn 2)))
		  ((< nn 4))
		(wf data nn isign cc ccr))
	      (do ((nn 4 (* nn 2)))
		  ((> nn n))
		(wf data nn isign cc ccr))))))
  
  (define (pwt data n isign cc cr)
    (let* ((data1 (make-vct n))
	   (n1 (- n 1))
	   (ncof (vct-length cc))
	   (nmod (* ncof n))
	   (nh (floor (/ n 2)))
	   (joff (- (floor (/ ncof 2))))
	   (ioff joff))
      (if (>= isign 0)
	  (do ((ii 0 (+ 1 ii))
	       (i 1 (+ i 2)))
	      ((> i n))
	    (let ((ni (+ i nmod ioff))
		  (nj (+ i nmod joff)))
	      (do ((k 1 (+ 1 k)))
		  ((> k ncof))
		(let ((jf (logand n1 (+ ni k))) ;gad wotta kludge...
		      (jr (logand n1 (+ nj k))))
		  (vct-set! data1 ii (+ (vct-ref data1 ii)
					(* (vct-ref cc (- k 1)) 
					   (vct-ref data jf))))
		  (vct-set! data1 (+ ii nh) (+ (vct-ref data1 (+ ii nh))
					       (* (vct-ref cr (- k 1)) 
						  (vct-ref data jr))))))))
	  (do ((ii 0 (+ 1 ii))
	       (i 1 (+ i 2)))
	      ((> i n))
	    (let ((ai (vct-ref data ii))
		  (ai1 (vct-ref data (+ ii nh)))
		  (ni (+ i nmod ioff))
		  (nj (+ i nmod joff)))
	      (do ((k 1 (+ 1 k)))
		  ((> k ncof))
		(let ((jf (logand n1 (+ ni k)))
		      (jr (logand n1 (+ nj k))))
		  (vct-set! data1 jf (+ (vct-ref data1 jf) 
					(* ai (vct-ref cc (- k 1)))))
		  (vct-set! data1 jr (+ (vct-ref data1 jr)
					(* ai1 (vct-ref cr (- k 1))))))))))
      (do ((i 0 (+ 1 i)))
	  ((= i n))
	(vct-set! data i (vct-ref data1 i)))
      data))
  
  (define (corr x y N M)
    ;; correlation from Orfanidis
    (let ((R (make-vct (+ 1 M))))
      (do ((k 0 (+ 1 k)))
	  ((> k M))
	(vct-set! R k 0.0)
	(do ((n 0 (+ 1 n)))
	    ((= n (- N k)))
	  (vct-set! R k (+ (vct-ref R k) (* (vct-ref x (+ n k)) (vct-ref y n))))))
      R))
  
  ;; this returns the same results as the fft-based version below, modulo vct lengths
  (define (cross-correlate-1 snd0 chn0 snd1 chn1)
    (let* ((len0 (frames snd0 chn0))
	   (len1 (frames snd1 chn1))
	   (clen (min len0 len1))
	   (dlen (max len0 len1))
	   (corr (make-vct clen))
	   (data0 (channel->vct 0 dlen snd0 chn0))
	   (data1 (channel->vct 0 dlen snd1 chn1)))
      (do ((lag 0 (+ 1 lag)))
	  ((= lag clen) corr)
	(let ((mdata (vct-multiply! (vct-copy data0) data1))
	      (sum 0.0))
	  (do ((i 0 (+ 1 i)))
	      ((= i dlen))
	    (set! sum (+ sum (vct-ref mdata i))))
	  (vct-set! corr lag sum)
	  (let ((orig (vct-ref data0 0)))
	    (vct-move! data0 0 1)
	    (vct-set! data0 (- dlen 1) orig))))))
  
  (define (cross-correlate-2 snd0 chn0 snd1 chn1)
    (let* ((len0 (frames snd0 chn0))
	   (len1 (frames snd1 chn1))
	   (ilen (max len0 len1))
	   (pow2 (ceiling (/ (log ilen) (log 2))))
	   (fftlen (expt 2 pow2))
	   (fftlen2 (/ fftlen 2))
	   (fftscale (/ 1.0 fftlen))
	   (rl1 (channel->vct 0 fftlen snd1 chn1))
	   (rl2 (channel->vct 0 fftlen snd0 chn0))
	   (im1 (make-vct fftlen))
	   (im2 (make-vct fftlen)))
      (fft rl1 im1 1)
      (fft rl2 im2 1)
      (let* ((tmprl (vct-copy rl1))
	     (tmpim (vct-copy im1))
	     (data3 (make-vct fftlen)))
	(vct-multiply! tmprl rl2)     ; (* tempr1 tempr2)
	(vct-multiply! tmpim im2)     ; (* tempi1 tempi2)
	(vct-multiply! im2 rl1)       ; (* tempr1 tempi2)
	(vct-multiply! rl2 im1)       ; (* tempr2 tempi1)
	(vct-add! tmprl tmpim)        ; add the first two
	(vct-subtract! im2 rl2)       ; subtract the 4th from the 3rd
	(vct-scale! (fft tmprl im2 -1) fftscale))))
  
  (define (cross-correlate-3 rl1 rl2 fftlen)
    (let* ((fftlen2 (/ fftlen 2))
	   (fftscale (/ 1.0 fftlen))
	   (im1 (make-vct fftlen))
	   (im2 (make-vct fftlen)))
      (fft rl1 im1 1)
      (fft rl2 im2 1)
      (let* ((tmprl (vct-copy rl1))
	     (tmpim (vct-copy im1))
	     (data3 (make-vct fftlen)))
	(vct-multiply! tmprl rl2)     ; (* tempr1 tempr2)
	(vct-multiply! tmpim im2)     ; (* tempi1 tempi2)
	(vct-multiply! im2 rl1)       ; (* tempr1 tempi2)
	(vct-multiply! rl2 im1)       ; (* tempr2 tempi1)
	(vct-add! tmprl tmpim)        ; add the first two
	(vct-subtract! im2 rl2)       ; subtract the 4th from the 3rd
	(vct-scale! (fft tmprl im2 -1) fftscale))))
  
  (define* (automorph a b c d snd chn)
    (let* ((len (frames snd chn))
	   (pow2 (ceiling (/ (log len) (log 2))))
	   (fftlen (expt 2 pow2))
	   (fftscale (/ 1.0 fftlen))
	   (rl (channel->vct 0 fftlen snd chn))
	   (im (make-vct fftlen)))
      (fft rl im 1)
      (vct-scale! rl fftscale)
      (vct-scale! im fftscale)
      ;; handle 0 case by itself
      (let* ((c1 (make-rectangular (vct-ref rl 0) (vct-ref im 0)))
	     (val (/ (+ (* a c1) b)
		     (+ (* c c1) d)))
	     (rval (real-part val))
	     (ival (imag-part val)))
	(vct-set! rl 0 rval)
	(vct-set! im 0 ival))
      (do ((i 1 (+ i 1))
	   (k (- fftlen 1) (- k 1)))
	  ((= i (/ fftlen 2)))
	(let* ((c1 (make-rectangular (vct-ref rl i) (vct-ref im i)))
	       (val (/ (+ (* a c1) b)      ; (az + b) / (cz + d)
		       (+ (* c c1) d)))
	       (rval (real-part val))
	       (ival (imag-part val)))
	  (vct-set! rl i rval)
	  (vct-set! im i ival)
	  (vct-set! rl k rval)
	  (vct-set! im k (- ival))))
      (fft rl im -1)
      (vct->channel rl 0 len snd chn #f (format #f "automorph ~A ~A ~A ~A" a b c d))))
  
  
  (let* ((daub4 (vct 0.4829629131445341 0.8365163037378079 0.2241438680420134 -0.1294095225512604))
	 (daub6 (vct 0.332670552950 0.806891509311 0.459877502118 -0.135011020010 -0.085441273882 0.035226291886))
	 (daub8 (vct 0.230377813309 0.714846570553 0.630880767930 -0.027983769417 -0.187034811719 0.030841381836
		     0.032883011667 -0.010597401785))
	 (daub10 (vct 0.160102397974 0.603829269797 0.724308528438 0.138428145901 -0.242294887066 -0.032244869585
		      0.077571493840 -0.006241490213 -0.012580751999 0.003335725285))
	 (daub12 (vct 0.111540743350 0.494623890398 0.751133908021 0.315250351709 -0.226264693965 -0.129766867567
		      0.097501605587 0.027522865530 -0.031582039317 0.000553842201 0.004777257511 -0.001077301085))
	 (daub14 (vct 0.077852054085 0.396539319482 0.729132090846 0.469782287405 -0.143906003929 -0.224036184994
		      0.071309219267 0.080612609151 -0.038029936935 -0.016574541631 0.012550998556 0.000429577973
		      -0.001801640704 0.000353713800))
	 (daub16 (vct 0.054415842243 0.312871590914 0.675630736297 0.585354683654 -0.015829105256 -0.284015542962
		      0.000472484574 0.128747426620 -0.017369301002 -0.044088253931 0.013981027917 0.008746094047
		      -0.004870352993 -0.000391740373 0.000675449406 -0.000117476784))
	 (daub18 (vct 0.038077947364 0.243834674613 0.604823123690 0.657288078051 0.133197385825 -0.293273783279
		      -0.096840783223 0.148540749338 0.030725681479 -0.067632829061 0.000250947115 0.022361662124
		      -0.004723204758 -0.004281503682 0.001847646883 0.000230385764 -0.000251963189 0.000039347320))
	 (daub20 (vct 0.026670057901 0.188176800077 0.527201188931 0.688459039453 0.281172343661 -0.249846424327
		      -0.195946274377 0.127369340336 0.093057364604 -0.071394147166 -0.029457536822 0.033212674059
		      0.003606553567 -0.010733175483 0.001395351747 0.001992405295 -0.000685856695 -0.000116466855
		      0.000093588670 -0.000013264203))
	 (SQRT2 1.41421356237309504880168872420969808)
	 (Battle-Lemarie (vct (* SQRT2 -0.002) (* SQRT2 -0.003) (* SQRT2  0.006) (* SQRT2  0.006) (* SQRT2 -0.013)
			      (* SQRT2 -0.012) (* SQRT2  0.030) (* SQRT2  0.023) (* SQRT2 -0.078) (* SQRT2 -0.035)
			      (* SQRT2  0.307) (* SQRT2  0.542) (* SQRT2  0.307) (* SQRT2 -0.035) (* SQRT2 -0.078)
			      (* SQRT2  0.023) (* SQRT2  0.030) (* SQRT2 -0.012) (* SQRT2 -0.013) (* SQRT2  0.006)
			      (* SQRT2  0.006) (* SQRT2 -0.003) (* SQRT2 -0.002) 0.0))
	 (Burt-Adelson (vct (* SQRT2 (/ -1.0 20.0)) (* SQRT2 (/ 5.0 20.0)) (* SQRT2 (/ 12.0 20.0))
			    (* SQRT2 (/ 5.0 20.0)) (* SQRT2 (/ -1.0 20.0)) 0.0))
	 (Beylkin (vct 0.099305765374353 0.424215360812961 0.699825214056600 0.449718251149468
		       -.110927598348234 -.264497231446384 0.026900308803690 0.155538731877093
		       -.017520746266529 -.088543630622924 0.019679866044322 0.042916387274192
		       -.017460408696028 -.014365807968852 0.010040411844631 .0014842347824723
		       -.002736031626258 .0006404853285212))
	 (SQRT15 3.87298334620741688517927)
	 (coif2 (vct (/ (* SQRT2 (- SQRT15 3)) 32.0) (/ (* SQRT2 (- 1 SQRT15)) 32.0) (/ (* SQRT2 (- 6 (* 2 SQRT15))) 32.0)
		     (/ (* SQRT2 (+ (* 2 SQRT15) 6)) 32.0) (/ (* SQRT2 (+ SQRT15 13)) 32.0) (/ (* SQRT2 (- 9 SQRT15)) 32.0)))
	 (coif4 (vct 0.0011945726958388 	-0.01284557955324 0.024804330519353 0.050023519962135 -0.15535722285996
		     -0.071638282295294 0.57046500145033 0.75033630585287 0.28061165190244 -0.0074103835186718
		     -0.014611552521451 -0.0013587990591632))
	 (coif6 (vct -0.0016918510194918 -0.00348787621998426 0.019191160680044 0.021671094636352 -0.098507213321468
		     -0.056997424478478 0.45678712217269 0.78931940900416 0.38055713085151 -0.070438748794943 
		     -0.056514193868065 0.036409962612716 0.0087601307091635 -0.011194759273835 -0.0019213354141368
		     0.0020413809772660 0.00044583039753204 -0.00021625727664696))
	 (sym2 (vct (* SQRT2 -0.125) (* SQRT2  0.25) (* SQRT2  0.75) (* SQRT2  0.25) (* SQRT2 -0.125)))
	 (sym3 (vct (/ (* SQRT2 1.0) 8.0) (/ (* SQRT2 3.0) 8.0) (/ (* SQRT2 3.0) 8.0) (/ (* SQRT2 1.0) 8.0)))
	 (sym4 (vct (/ (* SQRT2   3.0) 128.0) (/ (* SQRT2  -6.0) 128.0) (/ (* SQRT2 -16.0) 128.0)
		    (/ (* SQRT2  38.0) 128.0) (/ (* SQRT2  90.0) 128.0) (/ (* SQRT2  38.0) 128.0)
		    (/ (* SQRT2 -16.0) 128.0) (/ (* SQRT2  -6.0) 128.0) (/ (* SQRT2   3.0) 128.0) 0.0))
	 (sym5 (vct (/ (* SQRT2  3.0) 64.0) (/ (* SQRT2 -9.0) 64.0) (/ (* SQRT2 -7.0) 64.0) (/ (* SQRT2 45.0) 64.0)
		    (/ (* SQRT2 45.0) 64.0) (/ (* SQRT2 -7.0) 64.0) (/ (* SQRT2 -9.0) 64.0) (/ (* SQRT2  3.0) 64.0)))
	 (sym6 (vct (/ (* SQRT2   -35.0) 16384.0) (/ (* SQRT2  -105.0) 16384.0) (/ (* SQRT2  -195.0) 16384.0)
		    (/ (* SQRT2   865.0) 16384.0) (/ (* SQRT2   363.0) 16384.0) (/ (* SQRT2 -3489.0) 16384.0)
		    (/ (* SQRT2  -307.0) 16384.0) (/ (* SQRT2 11025.0) 16384.0) (/ (* SQRT2 11025.0) 16384.0)
		    (/ (* SQRT2  -307.0) 16384.0) (/ (* SQRT2 -3489.0) 16384.0) (/ (* SQRT2   363.0) 16384.0)
		    (/ (* SQRT2   865.0) 16384.0) (/ (* SQRT2  -195.0) 16384.0) (/ (* SQRT2  -105.0) 16384.0)
		    (/ (* SQRT2   -35.0) 16384.0))))
    (define wts (list 
		 daub4 daub6 daub8 daub10 daub12 daub14 daub16 daub18 daub20
		 Battle-Lemarie Burt-Adelson Beylkin coif2 coif4 coif6
		 sym2 sym3 sym4 sym5 sym6))
    
    
    (if (defined? 'bes-j0) ; dependent on mus-config.h HAVE_SPECIAL_FUNCTIONS
	(begin
	  (test-j0)
	  (test-j1)
	  (test-jn)
	  (test-y0)
	  (test-y1)
	  (test-yn)
	  (test-k0)
	  (test-k1)
	  (test-kn)
	  (test-i0)
	  (test-i1)
	  (test-in)
	  (test-erf)
	  (test-lgamma)))
    
    (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests))
      (log-mem clmtest)
      (let ((d0 #f) (d1 #f) (fn #f))
	
	(let ((index (open-sound "oboe.snd")))
	  ;; check small transform cases
	  (set! (transform-graph?) #t)
	  (for-each 
	   (lambda (transform)
	     (set! (transform-type) transform)
	     (for-each
	      (lambda (size)
		(catch #t
		       (lambda ()
			 (set! (transform-size) size)
			 (update-transform-graph))
		       (lambda args args)))
	      (list 8 7 -7 4 3 2 1 0)))
	   (list fourier-transform wavelet-transform autocorrelation walsh-transform cepstrum haar-transform))
	  (close-sound index))
	
	;; -------- fft
	
	(set! d0 (make-vct 16))
	(vct-set! d0 0 1.0)
	(snd-transform fourier-transform d0 0)
	(do ((i 0 (+ 1 i)))
	    ((= i 16))
	  (if (fneq (vct-ref d0 i) 1.0)
	      (snd-display #__line__ ";fourier (1.0) [~D]: ~A?" i (vct-ref d0 i))))
	
	(set! d0 (make-vct 19))
	(vct-set! d0 0 1.0)
	(snd-transform fourier-transform d0 0)
	(let ((happy #t))
	  (do ((i 0 (+ 1 i)))
	      ((or (not happy) (= i 16)))
	    (if (fneq (vct-ref d0 i) 1.0)
		(begin
		  (snd-display #__line__ ";fourier (1.0) [~D]: ~A?" i (vct-ref d0 i))
		  (set! happy #f)))))
	
	(snd-transform fourier-transform d0 0)
	(if (and (fneq (vct-ref d0 0) 256.0)
		 (fneq (vct-ref d0 0) 361.0)) ; fftw funny length 
	    (snd-display #__line__ ";fourier (256.0): ~A?" (vct-ref d0 0)))
	(let ((happy #t))
	  (do ((i 1 (+ 1 i)))
	      ((or (not happy) (= i 16)))
	    (if (fneq (vct-ref d0 i) 0.0)
		(begin
		  (snd-display #__line__ ";fourier (0.0) [~D]: ~A?" i (vct-ref d0 i))
		  (set! happy #f)))))
	
	(let ((r0 (make-vct 8))
	      (i0 (make-vct 8))
	      (r1 (make-vct 8))
	      (i1 (make-vct 8))
	      (r2 (make-vct 8))
	      (i2 (make-vct 8)))
	  (vct-set! r0 1 .5)
	  (vct-set! r1 3 .75)
	  (vct-set! r2 1 .25) ; 1/2
	  (vct-set! r2 3 .25) ; 1/3
	  (mus-fft r0 i0)
	  (mus-fft r1 i1)
	  (mus-fft r2 i2)
	  (vct-scale! r0 .5)
	  (vct-scale! i0 .5)
	  (vct-scale! r1 .3333)
	  (vct-scale! i1 .3333)
	  (vct-add! r0 r1)
	  (vct-add! i0 i1)
	  (if (or (not (vequal r0 r2))
		  (not (vequal i0 i2)))
	      (snd-display #__line__ ";fft additions/scaling: ~A ~A: ~A ~A" r2 i2 r0 i0)))
	
	(set! d0 (make-vct 8))
	(set! d1 (make-vct 8))
	(vct-set! d0 2 1.0)
	(mus-fft d0 d1 8 1)
	(if (or (not (vequal d0 (vct 1.000 0.000 -1.000 0.000 1.000 0.000 -1.000 0.000)))
		(not (vequal d1 (vct 0.000 1.000 0.000 -1.000 0.000 1.000 0.000 -1.000))))
	    (snd-display #__line__ ";mus-fft 1: ~A ~A?" d0 d1))
	(mus-fft d0 d1 8 -1)
	(if (or (not (vequal d0 (vct 0.000 0.000 8.000 0.000 0.000 0.000 0.000 0.000)))
		(not (vequal d1 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
	    (snd-display #__line__ ";mus-fft -1: ~A ~A?" d0 d1))
	
	(vct-fill! d0 1.0)
	(vct-fill! d1 0.0)
	(mus-fft d0 d1 8)
	(if (or (not (vequal d0 (vct 8.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		(not (vequal d1 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
	    (snd-display #__line__ ";mus-fft 2: ~A ~A?" d0 d1))
	(mus-fft d0 d1 8 -1)
	(if (or (not (vequal d0 (vct 8.000 8.000 8.000 8.000 8.000 8.000 8.000 8.000)))
		(not (vequal d1 (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
	    (snd-display #__line__ ";mus-fft -2: ~A ~A?" d0 d1))
	
	(vct-fill! d1 0.0)
	(vct-map! d0 (lambda () (random 1.0)))
	(set! fn (vct-copy d0))
	(mus-fft d0 d1 8)
	(mus-fft d0 d1 8 -1)
	(vct-scale! d0 (/ 1.0 8.0))
	(if (not (vequal d0 fn))
	    (snd-display #__line__ ";mus-fft 3: ~A ~A?" d0 fn))
	
	(let ((d0 (make-vct 8))
	      (d1 (make-vct 8)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 8))
	    (vct-set! d0 i (- 1.0 (random 2.0)))
	    (vct-set! d1 i (- 1.0 (random 2.0))))
	  (let ((save-d0 (vct-copy d0))
		(save-d1 (vct-copy d1))
		(reversed-d0 (make-vct 8))
		(reversed-d1 (make-vct 8)))
	    (do ((i 0 (+ 1 i)))
		((= i 8))
	      (vct-set! reversed-d0 i (vct-ref d0 (- 7 i)))
	      (vct-set! reversed-d1 i (vct-ref d1 (- 7 i))))
	    (mus-fft d0 d1 8)
	    (mus-fft d0 d1 8)
	    (vct-scale! d0 .125)
	    (vct-scale! d1 .125)
	    (do ((i 0 (+ 1 i))) ; one sample rotation here
		((= i 7))
	      (if (fneq (vct-ref d0 (+ 1 i)) (vct-ref reversed-d0 i))
		  (snd-display #__line__ ";mus-fft d0 reversed: ~A ~A" d0 reversed-d0))
	      (if (fneq (vct-ref d1 (+ 1 i)) (vct-ref reversed-d1 i))
		  (snd-display #__line__ ";mus-fft d1 reversed: ~A ~A" d1 reversed-d1)))
	    (mus-fft d0 d1 8)
	    (mus-fft d0 d1 8)
	    (vct-scale! d0 .125)
	    (vct-scale! d1 .125)
	    (if (not (vequal d0 save-d0))
		(snd-display #__line__ ";mus-fft d0 saved: ~A ~A" d0 save-d0))
	    (if (not (vequal d1 save-d1))
		(snd-display #__line__ ";mus-fft d1 saved: ~A ~A" d1 save-d1))))
	
	(for-each 
	 (lambda (size)
	   (let ((dcopy #f))
	     (set! d0 (make-vct size))
	     (vct-set! d0 0 1.0)
	     (set! dcopy (vct-copy d0))
	     (set! d1 (snd-spectrum d0 rectangular-window size))
	     (if (not (vequal d0 dcopy)) (snd-display #__line__ ";snd-spectrum not in-place? ~A ~A" d0 dcopy)))
	   (let ((happy #t))
	     (do ((i 0 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) 1.0)
		   (begin
		     (snd-display #__line__ ";snd-spectrum (1.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (set! d0 (make-vct size 1.0))
	   (set! d1 (snd-spectrum d0 rectangular-window))
	   (if (fneq (vct-ref d1 0) 1.0)
	       (snd-display #__line__ ";snd-spectrum back (1.0 ~D): ~A?" size (vct-ref d1 0)))
	   (let ((happy #t))
	     (do ((i 1 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) 0.0)
		   (begin
		     (snd-display #__line__ ";snd-spectrum (0.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (set! d0 (make-vct size))
	   (vct-set! d0 0 1.0)
	   (set! d1 (snd-spectrum d0 rectangular-window size #f)) ; dB (0.0 = max)
	   (let ((happy #t))
	     (do ((i 0 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) 0.0)
		   (begin
		     (snd-display #__line__ ";snd-spectrum dB (0.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (set! d0 (make-vct size 1.0))
	   (set! d1 (snd-spectrum d0 rectangular-window size #f))
	   (if (fneq (vct-ref d1 0) 0.0)
	       (snd-display #__line__ ";snd-spectrum dB back (0.0 ~D): ~A?" size (vct-ref d1 0)))
	   (let ((happy #t))
	     (do ((i 1 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) -90.0) ; currently ignores min-dB (snd-sig.c 5023)
		   (begin
		     (snd-display #__line__ ";snd-spectrum dB (1.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (let ((dcopy #f))
	     (set! d0 (make-vct size))
	     (vct-set! d0 0 1.0)
	     (set! dcopy (vct-copy d0))
	     (set! d1 (snd-spectrum d0 rectangular-window size #t 1.0 #t)) ; in-place 
	     (if (vequal d0 dcopy) (snd-display #__line__ ";snd-spectrum in-place? ~A ~A" d0 dcopy))
	     (if (not (vequal d0 d1)) (snd-display #__line__ ";snd-spectrum returns in-place? ~A ~A" d0 d1)))
	   (let ((happy #t))
	     (do ((i 0 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) 1.0)
		   (begin
		     (snd-display #__line__ ";snd-spectrum (1.0 #t) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (let ((dcopy #f))
	     (set! d0 (make-vct size))
	     (vct-set! d0 0 1.0)
	     (set! dcopy (vct-copy d0))
	     (set! d1 (snd-spectrum d0 rectangular-window size #f 1.0 #t)) ; in-place dB
	     (if (vequal d0 dcopy) (snd-display #__line__ ";snd-spectrum dB in-place? ~A ~A" d0 dcopy))
	     (if (not (vequal d0 d1)) (snd-display #__line__ ";snd-spectrum dB returns in-place? ~A ~A" d0 d1)))
	   (let ((happy #t))
	     (do ((i 0 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) 0.0)
		   (begin
		     (snd-display #__line__ ";snd-spectrum dB (1.0 #t) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (set! d0 (make-vct size 1.0))
	   (set! d1 (snd-spectrum d0 rectangular-window size #t 0.0 #f #f)) ; linear (in-place) not normalized
	   (if (fneq (vct-ref d1 0) size) (snd-display #__line__ ";snd-spectrum no norm 0: ~A" d1))
	   (let ((happy #t))
	     (do ((i 1 (+ 1 i)))
		 ((or (not happy) (= i (/ size 2))))
	       (if (fneq (vct-ref d1 i) 0.0)
		   (begin
		     (snd-display #__line__ ";snd-spectrum no norm (0.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
		     (set! happy #f)))))
	   
	   (set! d0 (make-vct size 1.0))
	   (set! d1 (snd-spectrum d0 blackman2-window size))
	   (if (and (not (vequal d1 (vct 1.000 0.721 0.293 0.091)))
		    (not (vequal d1 (vct 1.000 0.647 0.173 0.037 0.024 0.016 0.011 0.005))))
	       (snd-display #__line__ ";blackman2 snd-spectrum: ~A~%" d1))
	   
	   (set! d0 (make-vct size 1.0))
	   (set! d1 (snd-spectrum d0 gaussian-window size #t 0.5))
	   (if (and (not (vequal d1 (vct 1.000 0.900 0.646 0.328)))
		    (not (vequal d1 (vct 1.000 0.870 0.585 0.329 0.177 0.101 0.059 0.028))))
	       (snd-display #__line__ ";gaussian 0.5 snd-spectrum: ~A~%" d1))
	   
	   (set! d0 (make-vct size 1.0))
	   (set! d1 (snd-spectrum d0 gaussian-window size #t 0.85))
	   (if (and (not (vequal d1 (vct 1.000 0.924 0.707 0.383)))
		    (not (vequal d1 (vct 1.000 0.964 0.865 0.725 0.566 0.409 0.263 0.128))))
	       (snd-display #__line__ ";gaussian 0.85 snd-spectrum: ~A~%" d1))
	   
	   )
	 
	 (list 8 16))
	
	(for-each
	 (lambda (len)
	   (let ((rl (make-vct len))
		 (xrl (make-vct len))
		 (len2 (/ len 2)))
	     (vct-fill! rl 1.0)
	     (vct-fill! xrl 1.0)
	     (snd-transform fourier-transform rl)
	     (snd-transform fourier-transform xrl #t)
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len2)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";flat fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))
	     (if (fneq (vct-ref rl 0) (* len len)) (snd-display #__line__ ";snd-transform ~A at 0: ~A" len (vct-ref rl 0)))
	     (vct-set! rl 0 0.0)
	     (if (> (vct-peak rl) .001) (snd-display #__line__ ";snd-transform ~A impulse: ~A" len (vct-peak rl)))))
	 (list 16 128 512 1024))
	
	(for-each
	 (lambda (len)
	   (let ((rl (make-vct len))
		 (xrl (make-vct len))
		 (len2 (/ len 2)))
	     (vct-set! rl len2 1.0)
	     (vct-set! xrl len2 1.0)
	     (snd-transform fourier-transform rl)
	     (snd-transform fourier-transform xrl #t)
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len2)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";impulse fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))
	     (if (fneq (vct-ref rl 0) 1.0) (snd-display #__line__ ";flat ~A at 0: ~A" len (vct-ref rl 0)))))
	 (list 16 128 512 1024))
	
	(for-each
	 (lambda (len)
	   (let ((rl (make-vct len))
		 (xrl (make-vct len))
		 (len2 (/ len 2)))
	     (do ((i 0 (+ 1 i)))
		 ((= i len))
	       (let ((val (random 1.0)))
		 (vct-set! rl i val)
		 (vct-set! xrl i val)))
	     (snd-transform fourier-transform rl)
	     (vct-scale! rl (/ 1.0 len))
	     (snd-transform fourier-transform xrl #t)
	     (vct-scale! xrl (/ 1.0 len))
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len2)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";random fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))))
	 (list 16 128 512 1024 4096))
	
	(for-each
	 (lambda (len)
	   (let ((rl (make-vct len))
		 (xrl (make-vct len))
		 (len2 (/ len 2)))
	     (do ((i 0 (+ 1 i)))
		 ((= i len))
	       (let ((val (sin (/ (* 2.0 10 pi i) len))))
		 (vct-set! rl i val)
		 (vct-set! xrl i val)))
	     (snd-transform fourier-transform rl)
	     (vct-scale! rl (/ 1.0 len))
	     (snd-transform fourier-transform xrl #t)
	     (vct-scale! xrl (/ 1.0 len))
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len2)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";random fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))))
	 (list 16 128 512 1024 4096))
	
	;; -------- autocorrelation
	
	(let ((rl (make-vct 16 0.0)))
	  (vct-set! rl 0 1.0)
	  (autocorrelate rl)
	  (if (not (vequal rl (vct 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";autocorrelate 1: ~A" rl)))
	
	(let ((rl (make-vct 16 0.0)))
	  (vct-set! rl 0 1.0)
	  (vct-set! rl 1 -1.0)
	  (autocorrelate rl)
	  (if (not (vequal rl (vct 2 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";autocorrelate 1 -1: ~A" rl)))
	
	(let ((rl (make-vct 16 0.0)))
	  (vct-set! rl 0 1.0)
	  (vct-set! rl 4 -1.0)
	  (autocorrelate rl)
	  (if (not (vequal rl (vct 2 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0)))
	      (snd-display #__line__ ";autocorrelate 1 0 0 0 -1: ~A" rl)))
	
	(let ((rl (make-vct 16))
	      (rl1 (make-vct 16)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 8))
	    (vct-set! rl i (- 8.0 i))
	    (vct-set! rl1 i (vct-ref rl i)))
	  (let ((nr (vct-subseq (corr rl rl 16 16) 0 15)))
	    (autocorrelate rl1)
	    (if (not (vequal rl1 nr))
		(snd-display #__line__ ";autocorrelate/corr (ramp):~%;  ~A~%;  ~A" rl1 nr))))
	
	(let ((rl (make-vct 16))
	      (rl1 (make-vct 16)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 8))
	    (vct-set! rl i (- 1.0 (random 2.0)))
	    (vct-set! rl1 i (vct-ref rl i)))
	  (let ((nr (vct-subseq (corr rl rl 16 16) 0 15)))
	    (autocorrelate rl1)
	    (if (not (vequal rl1 nr))
		(snd-display #__line__ ";autocorrelate/corr:~%;  ~A~%;  ~A" rl1 nr))))
	
	(let ((ind0 (new-sound "test.snd" :size 16))
	      (ind1 (new-sound "fmv.snd" :size 16)))
	  (set! (sample 3 ind0 0) .75)
	  (set! (sample 6 ind1 0) -.5)
	  (let ((data0 (cross-correlate-1 ind0 0 ind1 0))
		(data1 (cross-correlate-2 ind0 0 ind1 0)))
	    (if (not (vequal data0 data1))
		(snd-display #__line__ ";cross-correlate: ~A ~A" data0 data1)))
	  (set! (sample 3 ind0 0) 0.0)
	  (set! (sample 8 ind0 0) 1.0)
	  (let ((data0 (cross-correlate-1 ind0 0 ind1 0))
		(data1 (cross-correlate-2 ind0 0 ind1 0)))
	    (if (not (vequal data0 data1))
		(snd-display #__line__ ";cross-correlate 1: ~A ~A" data0 data1)))
	  (close-sound ind0)
	  (close-sound ind1))
	
	(let ((v1 (make-vct 16))
	      (v2 (make-vct 16))
	      (v3 (make-vct 16))
	      (v4 (make-vct 16)))
	  (vct-set! v1 0 1.0)  
	  (vct-set! v2 3 1.0)  
	  (vct-set! v3 0 1.0)  
	  (vct-set! v4 3 1.0)
	  (set! v1 (cross-correlate-3 v1 v2 16))
	  (set! v3 (correlate v3 v4))
	  (if (not (vequal v1 v3))
	      (snd-display #__line__ ";correlate 16:~%;  ~A~%;  ~A" v1 v3)))
	
	(let ((v1 (make-vct 128))
	      (v2 (make-vct 128))
	      (v3 (make-vct 128))
	      (v4 (make-vct 128)))
	  (vct-set! v1 0 1.0)  
	  (vct-set! v2 32 1.0)  
	  (vct-set! v3 0 1.0)  
	  (vct-set! v4 32 1.0)
	  (set! v1 (cross-correlate-3 v1 v2 128))
	  (set! v3 (correlate v3 v4))
	  (if (not (vequal v1 v3))
	      (snd-display #__line__ ";correlate 128:~%;  ~A~%;  ~A" v1 v3)))
	
	(let ((v1 (make-vct 128))
	      (v2 (make-vct 128))
	      (v3 #f)
	      (v4 #f))
	  (do ((i 0 (+ 1 i)))
	      ((= i 128))
	    (vct-set! v1 i (- 5.0 (random 10.0)))
	    (vct-set! v2 i (- 0.5 (random 1.0))))
	  (set! v3 (vct-copy v1))
	  (set! v4 (vct-copy v2))
	  (set! v1 (cross-correlate-3 v1 v2 128))
	  (set! v3 (correlate v3 v4))
	  (if (not (vequal v1 v3))
	      (snd-display #__line__ ";correlate 128 at random:~%;  ~A~%;  ~A" v1 v3)))
	
	(let ((v1 (make-vct 16))
	      (v2 (make-vct 16)))
	  (vct-set! v1 3 1.0)  
	  (vct-set! v2 3 1.0)  
	  (set! v1 (correlate v1 (vct-copy v1)))
	  (set! v2 (autocorrelate v2))
	  (if (not (vequal v1 v2))
	      (snd-display #__line__ ";auto/correlate 16:~%;  ~A~%;  ~A" v1 v2)))
	
	(for-each
	 (lambda (len)
	   (let ((rl (make-vct len))
		 (rla (make-vct len))
		 (xim (make-vct len))
		 (xrl (make-vct len))
		 (len2 (/ len 2)))
	     (vct-set! rl 0 1.0)
	     (vct-set! rl 4 1.0)
	     (snd-transform autocorrelation rl 0) ; this is exactly the same as (autocorrelate rl)
	     (if (fneq (vct-ref rl 0) 2.0) (snd-display #__line__ ";autocorrelation ~A 0: ~A" len (vct-ref rl 0)))
	     (if (fneq (vct-ref rl 4) 1.0) (snd-display #__line__ ";autocorrelation ~A 4: ~A" len (vct-ref rl 4)))
	     
	     (vct-set! rla 0 1.0)
	     (vct-set! rla 4 1.0)
	     (autocorrelate rla)
	     (if (fneq (vct-ref rla 0) 2.0) (snd-display #__line__ ";autocorrelate ~A 0: ~A" len (vct-ref rla 0)))
	     (if (fneq (vct-ref rla 4) 1.0) (snd-display #__line__ ";autocorrelate ~A 4: ~A" len (vct-ref rla 4)))
	     
	     (vct-set! xrl 0 1.0)
	     (vct-set! xrl 4 1.0)
	     (mus-fft xrl xim len 1)
	     (do ((i 0 (+ 1 i)))
		 ((= i len))
	       (vct-set! xrl i (+ (* (vct-ref xrl i) (vct-ref xrl i)) (* (vct-ref xim i) (vct-ref xim i)))))
	     (vct-scale! xim 0.0)
	     (mus-fft xrl xim len -1)
	     (vct-scale! xrl (/ 1.0 len))
	     
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len2)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";mus-fft? ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))
	     (vct-set! rl 0 0.0)
	     (vct-set! rl 4 0.0)
	     (do ((i (/ len 2) (+ 1 i)))
		 ((= i len))
	       (vct-set! rl i 0.0))
	     (if (> (vct-peak rl) .001) (snd-display #__line__ ";autocorrelate peak: ~A" (vct-peak rl)))))
	 (list 16 64 256 512))
	
	(for-each
	 (lambda (len)
	   (let* ((rl (make-vct len))
		  (xim (make-vct len))
		  (xrl (make-vct len))
		  (len2 (/ len 2))
		  (ones (max 2 (random len2))))
	     (do ((i 0 (+ 1 i)))
		 ((= i ones))
	       (let ((val (random 1.0))
		     (ind (random len)))
		 (vct-set! rl ind val)
		 (vct-set! xrl ind val)))
	     (snd-transform autocorrelation rl 0)
	     (mus-fft xrl xim len 1)
	     (vct-set! xrl 0 (* (vct-ref xrl 0) (vct-ref xrl 0)))
	     (vct-set! xrl len2 (* (vct-ref xrl len2) (vct-ref xrl len2)))
	     (do ((i 1 (+ 1 i))
		  (j (- len 1) (- j 1)))
		 ((= i len2))
	       (vct-set! xrl i (+ (* (vct-ref xrl i) (vct-ref xrl i)) (* (vct-ref xim j) (vct-ref xim j))))
	       (vct-set! xrl j (vct-ref xrl i)))
	     (vct-scale! xim 0.0)
	     (mus-fft xrl xim len -1)
	     (vct-scale! xrl (/ 1.0 len))
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len2)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";random ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))))
	 (list 16 64 256 512))
	
	;; -------- cepstrum
	
	;; these values from Octave real(ifft(log(abs(fft(x)))))
	(let ((rl (make-vct 16))
	      (lst '( 0.423618  0.259318 -0.048365  1.140571  -0.811856  -0.994098  -0.998613 -2.453642
				-0.438549  -1.520463  -0.312065  -0.724707    1.154010    1.466936   0.110463  -1.520854)))
	  (do ((i 0 (+ 1 i))) ((= i 16)) (vct-set! rl i (list-ref lst i)))
	  (let ((nrl (vct-scale! (snd-transform cepstrum rl 0) 1.399)))
	    (if (not (vequal nrl (vct  1.3994950   0.1416877   0.0952407   0.0052814  -0.0613192   0.0082986  -0.0233993
				       -0.0476585   0.0259498  -0.0476585  -0.0233993   0.0082986  -0.0613192   0.0052814
				       0.0952407   0.1416877)))
		(snd-display #__line__ ";cepstrum 16: ~A" nrl))))
	
	(let ((rl (make-vct 16)))
	  (do ((i 0 (+ 1 i))) ((= i 16)) (vct-set! rl i i))
	  (let ((nrl (vct-scale! (snd-transform cepstrum rl 0) 2.72)))
	    (if (not (vequal nrl (vct 2.720 0.452 0.203 0.122 0.082 0.061 0.048 0.041 0.039 0.041 0.048 0.061 0.082 0.122 0.203 0.452)))
		(snd-display #__line__ ";cepstrum 16 by ones: ~A" nrl))))
	
	(for-each
	 (lambda (len)
	   (let ((rl (make-vct len))
		 (xim (make-vct len))
		 (xrl (make-vct len)))
	     (vct-set! rl 0 1.0)
	     (vct-set! rl 4 1.0)
	     (snd-transform cepstrum rl 0)
	     (vct-set! xrl 0 1.0)
	     (vct-set! xrl 4 1.0)
	     (mus-fft xrl xim len 1)
	     (do ((i 0 (+ 1 i)))
		 ((= i len))
	       (let ((val (+ (* (vct-ref xrl i) (vct-ref xrl i)) (* (vct-ref xim i) (vct-ref xim i)))))
		 (if (> val .0000001)
		     (set! val (log (sqrt val)))
		     (set! val -10.0))
		 (vct-set! xrl i val)))
	     (vct-scale! xim 0.0)
	     (mus-fft xrl xim len -1)
	     (let ((fscl 0.0))
	       (do ((i 0 (+ 1 i)))
		   ((= i len))
		 (set! fscl (max fscl (abs (vct-ref xrl i)))))
	       (vct-scale! xrl (/ 1.0 fscl)))
	     (let ((happy #t))
	       (do ((i 0 (+ 1 i)))
		   ((or (not happy) (= i len)))
		 (if (fneq (vct-ref rl i) (vct-ref xrl i))
		     (begin
		       (snd-display #__line__ ";mus-fft?? ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
		       (set! happy #f)))))))
	 (list 16 64 256 512))
	
	
	;; -------- walsh
	
	(set! d0 (make-vct 8))
	(vct-set! d0 0 1.0)
	(snd-transform walsh-transform d0)
	(if (not (vequal d0 (vct 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
	    (snd-display #__line__ ";walsh 1: ~A" d0))
	(snd-transform walsh-transform d0)
	(if (not (vequal d0 (vct 8.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";walsh -1: ~A" d0))
	
	(set! d0 (make-vct 8))
	(vct-set! d0 1 1.0)
	(snd-transform walsh-transform d0)
	(if (not (vequal d0 (vct 1.000 -1.000 1.000 -1.000 1.000 -1.000 1.000 -1.000)))
	    (snd-display #__line__ ";walsh 2: ~A" d0))
	(snd-transform walsh-transform d0)
	(if (not (vequal d0 (vct 0.000 8.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";walsh -2: ~A" d0))
	
	(set! d0 (make-vct 8))
	(vct-set! d0 1 1.0)
	(vct-set! d0 0 0.5)
	(snd-transform walsh-transform d0)
	(if (not (vequal d0 (vct 1.500 -0.500 1.500 -0.500 1.500 -0.500 1.500 -0.500)))
	    (snd-display #__line__ ";walsh 3: ~A" d0))
	(snd-transform walsh-transform d0)
	(if (not (vequal d0 (vct 4.000 8.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";walsh -3: ~A" d0))
	
	(set! d0 (make-vct 8))
	(vct-map! d0 (lambda () (random 1.0)))
	(set! d1 (vct-copy d0))
	(snd-transform walsh-transform d0)
	(snd-transform walsh-transform d0)
	(vct-scale! d0 (/ 1.0 8.0))
	(if (not (vequal d0 d1))
	    (snd-display #__line__ ";walsh 4: ~A ~A" d0 d1))
	
	(set! d0 (vct 1 1 1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1))
	(set! d1 (snd-transform walsh-transform d0))
	(if (not (vequal d1 (vct 4.00 4.00 4.00 -4.00 4.00 4.00 4.00 -4.00 4.00 4.00 4.00 -4.00 -4.00 -4.00 -4.00 4.00)))
	    (snd-display #__line__ ";walsh 5: ~A" d1))
	
	(set! d0 (vct 1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0))
	(set! d1 (snd-transform walsh-transform d0))
	(if (not (vequal d1 (vct 0.000 2.000 2.000 0.000 0.000 2.000 2.000 0.000 0.000 2.000 2.000 0.000 0.000 2.000 2.000 0.000)))
	    (snd-display #__line__ ";walsh 6: ~A" d1))
	
	(set! d0 (vct 0.174 -0.880 -0.555 -0.879 0.038 0.696 -0.612 0.006 -0.613 0.334 -0.111 -0.821 0.130 0.030 -0.229 0.170))
	(set! d1 (snd-transform walsh-transform d0))
	(if (not (vequal d1 (vct -3.122 -0.434 2.940 -0.468 -3.580 2.716 -0.178 -1.386 -0.902 0.638 1.196 1.848 -0.956 2.592 -1.046 2.926)))
	    (snd-display #__line__ ";walsh 7: ~A" d1))
	
	
	;; -------- haar
	
	(set! d0 (make-vct 8))
	(vct-set! d0 2 1.0)
	(snd-transform haar-transform d0)
	(if (not (vequal d0 (vct 0.354 0.354 -0.500 0.000 0.000 0.707 0.000 0.000)))
	    (snd-display #__line__ ";haar 1: ~A" d0))
	(inverse-haar d0)
	(if (not (vequal d0 (vct 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";inverse haar 1: ~A" d0))
	
	(set! d0 (make-vct 8))
	(vct-set! d0 0 1.0)
	(snd-transform haar-transform d0)
	(if (not (vequal d0 (vct 0.354 0.354 0.500 0.000 0.707 0.000 0.000 0.000)))
	    (snd-display #__line__ ";haar 2: ~A" d0))
	(inverse-haar d0)
	(if (not (vequal d0 (vct 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";inverse haar 2: ~A" d0))
	
	(set! d0 (snd-transform haar-transform (vct -0.483 0.174 -0.880 -0.555 -0.879 0.038 0.696 -0.612)))
	(if (not (vequal d0 (vct -0.884 -0.349 0.563 -0.462 -0.465 -0.230 -0.648 0.925)))
	    (snd-display #__line__ ";haar 3: ~A" d0))
	
	;; from "A Primer on Wavelets"
	(let ((sq2 (sqrt 2.0)))
	  (set! d0 (snd-transform haar-transform (vct 4 6 10 12 8 6 5 5)))
	  (if (not (vequal d0 (vct (* 14 sq2) (* 2 sq2) -6 2 (- sq2) (- sq2) sq2 0)))
	      (snd-display #__line__ ";haar 4: ~A" d0))
	  
	  (set! d0 (snd-transform haar-transform (vct 2 4 6 8 10 12 14 16)))
	  (if (not (vequal d0 (vct (* 18 sq2) (* -8 sq2) -4 -4 (- sq2) (- sq2) (- sq2) (- sq2))))
	      (snd-display #__line__ ";haar 5: ~A" d0)))
	
	(set! d0 (make-vct 8))
	(set! d1 (make-vct 8))
	(do ((i 0 (+ 1 i)))
	    ((= i 8))
	  (vct-set! d0 i (random 1.0))
	  (vct-set! d1 i (vct-ref d0 i)))
	(snd-transform haar-transform d0)
	(inverse-haar d0)
	(if (not (vequal d0 d1))
	    (snd-display #__line__ ";inverse haar 6: ~A ~A" d0 d1))
	
	
	;; --------- wavelet
	
	;; test against fxt output
	(set! d0 (snd-transform wavelet-transform (vct 1 1 0 0 0 0 0 0) 0)) ;"daub4"
	(if (not (vequal d0 (vct 0.625 0.375 -0.217 1.083 -0.354 0.000 0.000 0.354)))
	    (snd-display #__line__ ";fxt wavelet 1: ~A" d0))
	
	(for-each 
	 (lambda (size)
	   (do ((i 0 (+ 1 i)))
	       ((= i 20))
	     (let ((d1 (make-vct size))
		   (d2 (make-vct size)))
	       (vct-set! d1 2 1.0)
	       (vct-set! d2 2 1.0)
	       (wavelet d1 size 0 pwt (list-ref wts i))
	       (snd-transform wavelet-transform d2 i)
	       (if (not (vequal d1 d2))
		   (snd-display #__line__ ";wavelet ~D: ~A ~A" i d1 d2))
	       (wavelet d2 size -1 pwt (list-ref wts i))
	       (vct-fill! d1 0.0)
	       (vct-set! d1 2 1.0)
	       (if (not (vequal d1 d2))
		   (if (or (= i 9) (= i 10))
		       (begin
			 (vct-set! d2 2 0.0)
			 (if (> (vct-peak d2) .1)
			     (snd-display #__line__ ";inverse wavelet ~D: ~A ~A" i d1 d2)))
		       (if (> i 14)
			   (let ((pk (vct-ref d2 2)))
			     (vct-set! d2 2 0.0)
			     (if (> (vct-peak d2) pk)
				 (snd-display #__line__ ";inverse wavelet ~D: ~A ~A" i d1 d2)))
			   (snd-display #__line__ ";inverse wavelet ~D: ~A ~A" i d1 d2))))))
	   (do ((i 0 (+ 1 i)))
	       ((= i 9))
	     (let ((d1 #f)
		   (d2 (make-vct size)))
	       (vct-map! d2 (lambda () (random 1.0)))
	       (set! d1 (vct-copy d2))
	       (snd-transform wavelet-transform d2 i)
	       (wavelet d2 size -1 pwt (list-ref wts i))
	       (if (not (vequal d1 d2))
		   (snd-display #__line__ ";random wavelet ~D: ~A ~A" i d1 d2)))))
	 (list 16 64))
	
	(set! (max-transform-peaks) 100)
	(let ((ind (open-sound "oboe.snd"))
	      (ftype (add-transform "low-pass" "filtered" 0.0 1.0
				    (lambda (len fd)
				      (let ((flt (make-fir-filter :order 8 
								  :xcoeffs (let ((v1 (make-vct 8)))
									     (vct-fill! v1 .0125)
									     v1))))
					(vct-map! 
					 (make-vct len) 
					 (lambda () 
					   (fir-filter flt (read-sample fd)))))))))
	  (if (not (transform? ftype)) (snd-display #__line__ ";transform added: ~A?" ftype))
	  (set! (transform-normalization) dont-normalize)
	  (set! (transform-type ind 0) ftype)
	  (set! (transform-size ind 0) 16)
	  (set! (transform-graph-type ind 0) graph-once)
	  (set! (transform-graph? ind 0) #t)
	  (set! (cursor ind 0) 12000)
	  (if (file-exists? "s61.scm") (delete-file "s61.scm"))
	  (save-state "s61.scm")
	  (delete-file "s61.scm") ; added transform needs to be saved somehow?
	  (close-sound ind))
	
	(let ((ind (open-sound "oboe.snd"))
	      (ftype (add-transform "abs-it" "absit" 0.0 1.0
				    (lambda (len fd)
				      (vct-map! 
				       (make-vct len) 
				       (lambda () 
					 (read-sample fd)))))))
	  (set! (transform-normalization) dont-normalize)
	  (set! (transform-type ind 0) ftype)
	  (set! (transform-size ind 0) 256)
	  (set! (transform-graph-type ind 0) graph-once)
	  (set! (transform-graph? ind 0) #t)
	  (set! (cursor ind 0) 12000)
	  (let* ((samps (transform->vct ind 0))
		 (orig (channel->vct (left-sample ind 0) 256))
		 (happy #t))
	    (do ((i 0 (+ 1 i)))
		((or (not happy) (= i 256)))
	      (if (fneq (vct-ref samps i) (vct-ref orig i))
		  (begin
		    (snd-display #__line__ ";add-transform same (~A): ~D ~A ~A" ftype i (vct-ref samps i) (vct-ref orig i))
		    (set! happy #f)))))
	  (set! (dot-size ind 0) 60)
	  (set! (graph-style ind 0) graph-lollipops)
	  (set! (x-bounds) (list 2.579 2.580))
	  (update-time-graph)
	  (delete-transform ftype)
	  (if (transform? ftype) (snd-display #__line__ ";transform deleted: ~A" ftype))
	  (if (transform? -1) (snd-display #__line__ ";transform? -1"))
	  (if (transform? (integer->transform 123)) (snd-display #__line__ ";transform? 123"))
	  (if (not (equal? (transform-type ind 0) fourier-transform)) 
	      (snd-display #__line__ ";after delete-transform ~A -> ~A" ftype (transform-type ind 0)))
	  (close-sound ind))
	
	
	(if (defined? 'bignum-fft)
	    (let ()
	      
	      (define* (vectors-equal? v1 v2 (error 1e-30))
		(let ((len (vector-length v1)))
		  (if (= (vector-length v2) len)
		      (let ((happy #t))
			(do ((i 0 (+ i 1)))
			    ((or (= i len) (not happy)) happy)
			  (set! happy (< (magnitude (- (vector-ref v1 i) (vector-ref v2 i))) error))))
		      #f)))
	      
	      (define* (bignum-vector :rest args)
		(let* ((len (length args))
		       (v (make-vector len)))
		  (do ((i 0 (+ i 1))
		       (arg args (cdr arg)))
		      ((= i len) v)
		    (if (bignum? (car arg))
			(vector-set! v i (car arg))
			(vector-set! v i (bignum (number->string (car arg))))))))
	      
	      ;; -------- -1 -1 at 1
	      (let ((rl (make-vector 8))
		    (im (make-vector 8)))
		(do ((i 0 (+ i 1))) 
		    ((= i 8)) 
		  (vector-set! rl i (bignum "0.0")) 
		  (vector-set! im i (bignum "0.0")))
		(vector-set! rl 1 (bignum "-1.0"))
		(vector-set! im 1 (bignum "-1.0"))
		(bignum-fft rl im 8) ; 3rd arg is size
		(let ((crl (bignum-vector -1.000 0.000 1.000 (sqrt (bignum "2")) 1.000 0.000 -1.000 (- (sqrt (bignum "2")))))
		      (cim (bignum-vector -1.000 (- (sqrt (bignum "2"))) -1.000 0.000 1.000 (sqrt (bignum "2")) 1.000 0.000)))
		  (if (or (not (vectors-equal? rl crl))
			  (not (vectors-equal? im cim)))
		      (format #t "big-fft -1 -1 at 1:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim)))
		(bignum-fft rl im 8 -1)
		(let ((crl (bignum-vector 0.0 -8.0 0.0 0.0 0.0 0.0 0.0 0.0))
		      (cim (bignum-vector 0.0 -8.0 0.0 0.0 0.0 0.0 0.0 0.0)))
		  (if (or (not (vectors-equal? rl crl))
			  (not (vectors-equal? im cim)))
		      (format #t "big-fft -1 -1 at 1 inverse:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim))
		  (vector-set! rl 1 (bignum "-1.0"))
		  (vector-set! im 1 (bignum "-1.0"))
		  (do ((i 0 (+ i 1)))
		      ((= i 4))
		    (bignum-fft rl im 8))
		  (vector-set! crl 1 (bignum "-64.0"))
		  (vector-set! cim 1 (bignum "-64.0"))
		  (if (or (not (vectors-equal? rl crl))
			  (not (vectors-equal? im cim)))
		      (format #t "big-fft -1 -1 at 1 rotate:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim))))
	      
	      ;; -------- -1 1 at 3
	      (let ((rl (make-vector 8))
		    (im (make-vector 8)))
		(do ((i 0 (+ i 1))) 
		    ((= i 8)) 
		  (vector-set! rl i (bignum "0.0")) 
		  (vector-set! im i (bignum "0.0")))
		(vector-set! rl 3 (bignum "-1.0"))
		(vector-set! im 3 (bignum "1.0"))
		(bignum-fft rl im 8)
		(let ((crl (bignum-vector -1.000 0.000 1.000 (- (sqrt (bignum "2"))) 1.000 0.000 -1.000 (sqrt (bignum "2"))))
		      (cim (bignum-vector 1.000 (- (sqrt (bignum "2"))) 1.000 0.000 -1.000 (sqrt (bignum "2")) -1.000 0.000)))
		  (if (or (not (vectors-equal? rl crl))
			  (not (vectors-equal? im cim)))
		      (format #t "big-fft -1 1 at 3:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim))))
	      
	      ;; -------- 1 0 at 0 with bignum arg to make-vector (so it should copy)
	      (let ((rl (make-vector 8 (bignum "0.0")))
		    (im (make-vector 8 (bignum "0.0"))))
		(vector-set! rl 0 (bignum "1.0"))
		(bignum-fft rl im 8)
		(let ((crl (bignum-vector 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0))
		      (cim (bignum-vector 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
		  (if (or (not (vectors-equal? rl crl))
			  (not (vectors-equal? im cim)))
		      (format #t "big-fft 1 0 at 0 (and copied fill):~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim))))
	      
	      ;; -------- cos/sin
	      (let ((rl (make-vector 64))
		    (im (make-vector 64)))
		(do ((i 0 (+ i 1))) 
		    ((= i 64)) 
		  (vector-set! rl i (bignum "0.0")) 
		  (vector-set! im i (bignum "0.0")))
		(vector-set! rl 1 (bignum "1.0"))
		(bignum-fft rl im 64 -1)
		(let ((happy #t))
		  (do ((i 0 (+ i 1)))
		      ((or (= i 64) (not happy)))
		    (let ((cerr (magnitude (- (vector-ref rl i) (cos (/ (* 2 pi i) 64)))))
			  (serr (magnitude (- (vector-ref im i) (sin (/ (* -2 pi i) 64))))))
		      (set! happy (and (< cerr 1e-30)
				       (< serr 1e-30)))
		      (if (not happy)
			  (format #t "big fft 1 at 0 (sin/cos) differs by ~A in ~A at ~A (~A ~A)~%"
				  (max cerr serr)
				  (if (> cerr serr) "cos" "sin")
				  i
				  (if (> cerr serr)
				      (cos (/ (* 2 pi i) 64))
				      (sin (/ (* -2 pi i) 64)))
				  (if (> cerr serr)
				      (vector-ref rl i)
				      (vector-ref im i)))))))
		(bignum-fft rl im 64)
		(let ((crl (make-vector 64 (bignum "0.0")))
		      (cim (make-vector 64 (bignum "0.0"))))
		  (vector-set! crl 1 (bignum "64"))
		  (if (or (not (vectors-equal? rl crl))
			  (not (vectors-equal? im cim)))
		      (format #t "big-fft 1 at 0 fill cos/sin inverse:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim))))
	      
	      ;; -------- random 
	      (let ((rl (make-vector 64))
		    (im (make-vector 64))
		    (crl (make-vector 64))
		    (cim (make-vector 64))
		    (rs (make-random-state (bignum "12345678"))))
		(do ((i 0 (+ i 1))) 
		    ((= i 64)) 
		  (vector-set! rl i (random (bignum "1.0") rs))
		  (vector-set! crl i (+ (vector-ref rl i) 0.0)) ; try to force a copy
		  (vector-set! im i (random (bignum "1.0") rs))
		  (vector-set! cim i (+ (vector-ref im i) 0.0)))
		(bignum-fft rl im 64 1)
		(if (or (vectors-equal? rl crl)
			(vectors-equal? im cim))
		    (format #t "big-fft random not copied?:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim))
		(bignum-fft rl im 64 -1)
		(do ((i 0 (+ i 1)))
		    ((= i 64))
		  (vector-set! rl i (/ (vector-ref rl i) 64.0))
		  (vector-set! im i (/ (vector-ref im i) 64.0)))
		(if (or (not (vectors-equal? rl crl))
			(not (vectors-equal? im cim)))
		    (format #t "big-fft random:~%rl: ~A~%    ~A~%im: ~A~%    ~A~%" rl crl im cim)))
	      ))
	
	
	(if (defined? 'gsl-dht)
	    (begin
	      (add-transform "Hankel" "Hankel" 0.0 1.0
			     (lambda (n rd)
			       (let ((v (make-vct n)))
				 (do ((i 0 (+ 1 i))) ((= i n)) (vct-set! v i (rd)))
				 (gsl-dht n v 1.0 1.0)
				 v)))
	      (let* ((n 16) 
		     (v (make-vct n)))
		(do ((i 0 (+ 1 i))) ((= i n)) (vct-set! v i 1.0))
		(gsl-dht n v 1.0 1.0))
	      (let ((tag (catch #t (lambda () (gsl-dht -1 (make-vct 3) 1.0 1.0)) (lambda args args))))
		(if (not (eq? (car tag) 'out-of-range)) (snd-display #__line__ ";gsl-dht bad size: ~A" tag)))))
	
	(if (defined? 'gsl-eigenvectors)
	    (let ((vals (gsl-eigenvectors (make-mixer 4  -1.0 1.0 -1.0 1.0
						      -8.0 4.0 -2.0 1.0
						      27.0 9.0 3.0 1.0
						      64.0 16.0 4.0 1.0))))
	      (if (not (vequal (vector->vct (car vals)) (vct -6.41391102627093 5.54555349890946 5.54555349890946 2.32280402845201)))
		  (snd-display #__line__ ";gsl-eigenvalues: ~A" (car vals)))
	      (if (or (not (= (vector-length (cadr vals)) 4))
		      (not (vequal (vector->vct (vector-ref (cadr vals) 0)) (vct -0.0998821746683654 -0.111251309674367 0.292500673281302 0.94450518972065)))
		      (not (vequal (vector->vct (vector-ref (cadr vals) 1)) (vct -0.0434869537653505 0.0642376994169207 -0.515252756143484 -0.840592191366022)))
		      (not (vequal (vector->vct (vector-ref (cadr vals) 2)) (vct -0.0434869537653505 0.0642376994169207 -0.515252756143484 -0.840592191366022)))
		      (not (vequal (vector->vct (vector-ref (cadr vals) 3)) (vct -0.144932944248023 0.356601443087312 0.91936884368837 0.0811836295983152))))
		  (snd-display #__line__ ";gsl eigenvectors: ~A" (cadr vals)))))
	
	(let ((ind1 (open-sound "oboe.snd")))
	  (set! (time-graph-style ind1 0) graph-lollipops)
	  (graph->ps "aaa.eps")
	  (set! (transform-graph? ind1 0) #t)
	  (set! (transform-graph-type ind1 0) graph-as-sonogram)
	  (set! (transform-size) 256)
	  (update-transform-graph)
	  (let ((size (transform-frames ind1 0)))
	    (if (or (number? size)
		    (not (= (length size) 3)))
		(snd-display #__line__ ";transform-frames of sonogram: ~A" size)))
	  (graph->ps "aaa.eps")
	  (catch #t
		 (lambda ()
		   (let ((ax (axis-info ind1 0 transform-graph)))
		     (if (not ax) (snd-display #__line__ ";axis-info transform-graph?"))
		     (if (and (provided? 'xm) (provided? 'snd-debug))
			 (let ((cwid (car (channel-widgets ind1 0))))
			   (focus-widget cwid)
			   (click-event cwid 0 0 
					(floor (* .5 (+ (list-ref ax 10) (list-ref ax 12))))
					(floor (* .5 (+ (list-ref ax 11) (list-ref ax 13)))))
			   (force-event)))))
		 (lambda args args))
	  (let ((old-colormap (colormap)))
	    (set! (colormap) black-and-white-colormap)
	    (update-transform-graph)
	    (set! (transform-graph-type ind1 0) graph-as-spectrogram)
	    (update-transform-graph)
	    (graph->ps "aaa.eps")
	    (catch #t
		   (lambda ()
		     (let ((ax (axis-info ind1 0 transform-graph)))
		       (if (not ax) (snd-display #__line__ ";axis-info transform-graph?"))
		       (if (and (provided? 'xm) (provided? 'snd-debug))
			   (let ((cwid (car (channel-widgets ind1 0))))
			     (focus-widget cwid)
			     (click-event cwid 0 0 
					  (floor (* .5 (+ (list-ref ax 10) (list-ref ax 12))))
					  (floor (* .5 (+ (list-ref ax 11) (list-ref ax 13)))))
			     (force-event)))))
		   (lambda args args))
	    (set! (colormap) old-colormap))
	  (close-sound ind1))
	
	(let* ((ind (new-sound "test.snd" mus-next mus-bfloat)))
	  (pad-channel 0 1000)
	  (set! (transform-graph-type ind 0) graph-once)
	  (set! (show-transform-peaks ind 0) #t)
	  (set! (fft-log-magnitude ind 0) #t)
	  (set! (fft-log-frequency ind 0) #f)
	  (set! (transform-graph? ind 0) #t)
	  (set! (x-bounds) (list 0.0 .04))
	  (update-time-graph)
	  (update-transform-graph)
	  (close-sound ind))
	
	(let* ((ind (open-sound "oboe.snd"))
	       (size 8192)
	       (v (channel->vct 1000 size ind 0)))
	  (set! (show-listener) #f)
	  (set! (window-height) 800)
	  (set! (lisp-graph? ind 0) #t)
	  (graph v "biggy" 0.0 1.0 0.0 1.0 ind 0)
	  (set! (transform-graph-type ind 0) graph-once)
	  (set! (show-transform-peaks ind 0) #t)
	  (set! (fft-log-magnitude ind 0) #t)
	  (set! (fft-log-frequency ind 0) #f)
	  (set! (transform-graph? ind 0) #t)
	  (graph->ps "aaa.eps")
	  (set! (x-bounds) (list 0.0 1.0))
	  (set! (max-transform-peaks ind 0) 3)
	  (update-time-graph)
	  (update-transform-graph)
	  (update-lisp-graph)
	  (scale-by 0.0)
	  (update-time-graph)
	  (update-transform-graph)
	  (undo)
	  (set! (transform-graph-type ind 0) graph-as-sonogram)
	  (set! (fft-log-magnitude ind 0) #f)
	  (update-transform-graph)
	  (graph->ps "aaa.eps")
	  (set! (with-gl) #f)
	  (set! (spectrum-end ind 0) .2)
	  (set! (transform-graph-type ind 0) graph-as-spectrogram)
	  (update-transform-graph)
	  (update-lisp-graph)
	  (graph->ps "aaa.eps")
	  (set! (show-listener) #t)
	  (close-sound ind))
	
	(let ((v (dolph 16 2.5)))
	  (if (not (vequal v (vct 0.097 0.113 0.221 0.366 0.536 0.709 0.860 0.963 1.000 0.963 0.860 0.709 0.536 0.366 0.221 0.113)))
	      (snd-display #__line__ ";dolph 16 2.5 (dsp.scm): ~A" v)))
	
	(let ((v (make-vct 8))
	      (v0 (make-vct 8)))
	  (do ((i 0 (+ 1 i)))
	      ((= i 8))
	    (vct-set! v i (- (random 2.0) 1.0))
	    (vct-set! v0 i (vct-ref v i)))
	  (set! v (vct-scale! (dht (dht v)) (/ 1.0 8.0)))
	  (if (not (vvequal v v0))
	      (snd-display #__line__ ";dht twice: ~A ~A" v v0))
	  (vct-fill! v 0.0)
	  (vct-set! v 1 1.0)
	  (set! v (dht v))
	  (if (not (vequal v (vct 1.000 1.414 1.000 0.000 -1.000 -1.414 -1.000 0.000)))
	      (snd-display #__line__ ";dht of pulse: ~A" v)))
	
	(let* ((ind (open-sound "oboe.snd"))
	       (val1 (car (find-sine 553.0 2000 3000 ind)))
	       (val2 (car (find-sine 620.0 2000 3000 ind))))
	  (if (or (fneq val1 .03835)
		  (fneq val2 .0012))
	      (snd-display #__line__ ";find-sine: ~A ~A" val1 val2))
	  (let ((frq (spot-freq 2000 ind 0)))
	    (if (not (= (round frq) 553))
		(snd-display #__line__ ";spot-freq: ~A" frq)))
	  (down-oct 2)
	  (let ((frq (spot-freq 2000 ind 0)))
	    (if (and (not (= (round frq) 276))
		     (not (= (round frq) 277)))
		(snd-display #__line__ ";spot-freq down oct: ~A" frq)))
	  (undo)
	  (zero-phase)
	  (if (fneq (sample 0) .1472) (snd-display #__line__ ";zero-phase: ~A" (sample 0)))
	  (undo)
	  (rotate-phase (lambda (x) x))
	  (undo)
	  (brighten-slightly .5)
	  (undo)
	  (spike)
	  (close-sound ind))
	(let ((old-opt (optimization)))
	  (set! (optimization) 0)
	  (let* ((ind (open-sound "1a.snd"))
		 (valf (car (find-sine 440.0 0 (frames) ind)))
		 (valg (* 2 (/ (goertzel 440.0 0 (frames) ind) (frames))))
		 (valf1 (car (find-sine 100.0 0 (frames) ind)))
		 (valg1 (* 2 (/ (goertzel 100.0 0 (frames) ind) (frames))))
		 (valf2 (car (find-sine 440.0 0 (frames) ind)))
		 (valg2 (* 2 (/ (goertzel 440.0 0 (frames) ind) (frames))))
		 (valf3 (car (find-sine 437.0 0 (frames) ind)))
		 (valg3 (* 2 (/ (goertzel 437.0 0 (frames) ind) (frames)))))
	    (if (fneq valf valg) (snd-display #__line__ ";goertzel 0: ~A ~A" valf valg))
	    (if (fneq valf1 valg1) (snd-display #__line__ ";goertzel 1: ~A ~A" valf1 valg1))
	    (if (fneq valf2 valg2) (snd-display #__line__ ";goertzel 2: ~A ~A" valf2 valg2))
	    (if (fneq valf3 valg3) (snd-display #__line__ ";goertzel 3: ~A ~A" valf3 valg3))
	    (close-sound ind))
	  (set! (optimization) old-opt))
	
	(let ((v (vct-polynomial (vct 0.0 2.0) (vct 1.0 2.0))))
	  (if (not (vequal v (vct 1.0 5.0)))
	      (snd-display #__line__ ";vct-polynomial 0: ~A" v)))
	(let ((v (vct-polynomial (vct 0 1 2) (vct 0 2 1))))
	  (if (not (vequal v (vct 0.000 3.000 8.000)))
	      (snd-display #__line__ ";vct-polynomial 1: ~A" v)))
	(let ((v (vct-polynomial (vct 0 1 2) (vct 0 2 1 .5))))
	  (if (not (vequal v (vct 0.000 3.500 12.000)))
	      (snd-display #__line__ ";vct-polynomial 2: ~A" v)))
	(let ((v (vct-polynomial (vct 0 1 2) (vct 1))))
	  (if (not (vequal v (vct 1 1 1)))
	      (snd-display #__line__ ";vct-polynomial 3: ~A" v)))
	(let* ((ind (open-sound "pistol.snd"))
	       (mx (maxamp ind 0)))
	  (channel-polynomial (vct 0.0 2.0) ind 0)
	  (if (fneq (maxamp) (* mx 2))
	      (snd-display #__line__ ";channel-polynomial 2: ~A" (maxamp)))
	  (undo)
	  (channel-polynomial (vct 0.0 0.5 0.25 0.25) ind 0)
	  (if (fneq (maxamp) .222)
	      (snd-display #__line__ ";channel-polynomial 3: ~A" (maxamp)))
	  (undo)
	  (channel-polynomial (vct 0.0 0.0 1.0) ind 0)
	  (let ((pos (scan-channel (lambda (y) (< y 0.0)))))
	    (if pos
		(snd-display #__line__ ";channel-polynomial squares: ~A" pos)))
	  (undo)
	  (channel-polynomial (vct 0.5 1.0) ind 0)
	  (let ((pos (scan-channel (lambda (y) (< y 0.0)))))
	    (if pos
		(snd-display #__line__ ";channel-polynomial offset: ~A" pos)))
	  (if (fneq (maxamp) .8575)
	      (snd-display #__line__ ";channel-polynomial off mx: ~A" (maxamp)))
	  (undo)
	  (spectral-polynomial (vct 0.0 1.0) ind 0)
	  (if (fneq (maxamp) .493)
	      (snd-display #__line__ ";spectral-polynomial 0 mx: ~A" (maxamp)))
	  (if (not (= (frames ind 0) 41623))
	      (snd-display #__line__ ";spectral-polynomial 0 len: ~A" (frames)))
	  (undo)
	  (spectral-polynomial (vct 0.0 0.5 0.5) ind 0)
	  (if (fneq (maxamp) .493)
	      (snd-display #__line__ ";spectral-polynomial 1: ~A" (maxamp)))
	  (if (not (= (frames ind 0) (* 2 41623)))
	      (snd-display #__line__ ";spectral-polynomial 1 len: ~A" (frames)))
	  (undo)
	  (spectral-polynomial (vct 0.0 0.0 0.0 1.0) ind 0)
	  (if (fneq (maxamp) .493)
	      (snd-display #__line__ ";spectral-polynomial 2: ~A" (maxamp)))
	  (if (not (= (frames ind 0) (* 3 41623)))
	      (snd-display #__line__ ";spectral-polynomial 1 len: ~A" (frames)))
	  (close-sound ind))
	
	(let ((vals (scentroid "oboe.snd")))
	  (if (or (fneq (vct-ref vals 0) 1876.085) (fneq (vct-ref vals 1) 1447.004))
	      (snd-display #__line__ ";scentroid: ~A" vals)))
	
	(let ((flt (make-fir-filter 3 (vct 0.5 0.25 0.125)))
	      (data (make-vct 10))
	      (undata (make-vct 10)))
	  (vct-set! data 0 1.0)
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! undata i (fir-filter flt (vct-ref data i))))
	  (let ((fdata (invert-filter (vct 0.5 0.25 0.125))))
	    (set! flt (make-fir-filter (vct-length fdata) fdata))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (vct-set! undata i (fir-filter flt (vct-ref undata i))))
	    (if (not (vequal undata data))
		(snd-display #__line__ ";invert-filter: ~A" undata))))
	
	(let ((coeffs (make-vct 6)))
	  (do ((i 0 (+ 1 i))
	       (top .8 (- top .1)))
	      ((= i 6))
	    (vct-set! coeffs i (+ top (random .2))))
	  (let ((flt (make-fir-filter 6 coeffs))
		(data (make-vct 20))
		(undata (make-vct 20)))
	    (vct-set! data 0 1.0)
	    (do ((i 0 (+ 1 i)))
		((= i 20))
	      (vct-set! undata i (fir-filter flt (vct-ref data i))))
	    (let ((fdata (invert-filter coeffs)))
	      (set! flt (make-fir-filter (vct-length fdata) fdata))
	      (do ((i 0 (+ 1 i)))
		  ((= i 20))
		(vct-set! undata i (fir-filter flt (vct-ref undata i))))
	      (if (not (vequal undata data))
		  (snd-display #__line__ ";invert-filter (6): ~A" undata)))))
	
	(let ((flt (make-volterra-filter (vct 1.0 .4) (vct .3 .2 .1)))
	      (data (make-vct 10))
	      (x 0.0))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (vct-set! data i (volterra-filter flt x))
	    (if (= i 0) (set! x 0.5) (set! x 0.0)))
	  (if (not (vequal data (vct 0.000 0.575 0.250 0.025 0.000 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";volterra-filter: ~A" data)))
	
	(let ((flt (make-volterra-filter (vct 1.0) (vct 1.0)))
	      (data (make-vct 10)))
	  (do ((i 0 (+ 1 i))
	       (x 1.0 0.0))
	      ((= i 10))
	    (vct-set! data i (volterra-filter flt x)))
	  (if (not (vequal data (vct 2.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";volterra-filter x + x^2: ~A" data)))
	
	(let ((flt (make-volterra-filter (vct 1.0) (vct 1.0)))
	      (data (make-vct 10)))
	  (do ((i 0 (+ 1 i))
	       (x 1.0 (- x 0.1)))
	      ((= i 10))
	    (vct-set! data i (volterra-filter flt x)))
	  (if (not (vequal data (vct 2.000 1.710 1.440 1.190 0.960 0.750 0.560 0.390 0.240 0.110)))
	      (snd-display #__line__ ";volterra-filter x + x^2 by -0.1: ~A" data)))
	
	(let ((flt (make-volterra-filter (vct 1.0 0.5) (vct 1.0)))
	      (data (make-vct 10)))
	  (do ((i 0 (+ 1 i))
	       (x 1.0 0.0))
	      ((= i 10))
	    (vct-set! data i (volterra-filter flt x)))
	  (if (not (vequal data (vct 2.000 0.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";volterra-filter x + .5x(n-1) + x^2: ~A" data)))
	
	(let ((flt (make-volterra-filter (vct 1.0 0.5) (vct 1.0 0.6)))
	      (data (make-vct 10)))
	  (do ((i 0 (+ 1 i))
	       (x 0.9 0.0))
	      ((= i 10))
	    (vct-set! data i (volterra-filter flt x)))
	  (if (not (vequal data (vct 1.710 0.936 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";volterra-filter x + .5x(n-1) + x^2 + 0.6: ~A" data)))
	
	
	(let ((ind (new-sound "test.snd" :size 100))
	      (gen (make-oscil 440.0)))
	  (map-chan (lambda (y) (oscil gen)))
	  (down-oct 2)
	  (if (not (= (frames) 200)) (snd-display #__line__ ";down-oct new len: ~A" (frames)))
	  (let ((r1 (make-sampler 0 ind 0 1 1))
		(r2 (make-sampler 0 ind 0 1 2)))
	    (do ((i 0 (+ i 2)))
		((= i 200))
	      (let ((val1 (r1))
		    (val2 (r2))
		    (val3 (r2)))
		(if (and (fneq val1 val2)
			 (fneq val1 val3))
		    (snd-display #__line__ ";down-oct: ~A ~A ~A ~A" i val1 val2 val3)))))
	  
	  (kalman-filter-channel) ; just make sure it runs
	  
	  (close-sound ind))
	
	(let* ((d0 (make-vct 8))
	       (d1 (make-vct 8)))
	  (vct-set! d0 2 1.0)
	  (let ((vals (fractional-fourier-transform d0 d1 8 1.0)))
	    (if (or (not (vequal (car vals) (vct 1.000 0.000 -1.000 -0.000 1.000 0.000 -1.000 -0.000)))
		    (not (vequal (cadr vals) (vct 0.000 1.000 0.000 -1.000 0.000 1.000 0.000 -1.000))))
		(snd-display #__line__ ";fractional-fft: ~A?" vals))))
	
	(let* ((d0 (make-vct 8))
	       (d1 (make-vct 8)))
	  (vct-set! d0 2 1.0)
	  (let ((val (z-transform d0 8 (exp (make-rectangular 0.0 (* .25 pi))))))
	    (do ((i 0 (+ 1 i)))
		((= i 8))
	      (vct-set! d0 i (real-part (vector-ref val i)))
	      (vct-set! d1 i (imag-part (vector-ref val i))))
	    (if (or (not (vequal d0 (vct 1.000 0.000 -1.000 -0.000 1.000 0.000 -1.000 -0.000)))
		    (not (vequal d1 (vct 0.000 1.000 0.000 -1.000 0.000 1.000 0.000 -1.000))))
		(snd-display #__line__ ";z-transform: ~A ~A?" d0 d1))))
	
	(let ((v1 (make-vct 16)))
	  (vct-set! v1 0 1.0)
	  (let ((res (vector->vct (z-transform v1 16 0.5))))
	    (if (not (vequal res (make-vct 16 1.0)))
		(snd-display #__line__ ";z 0.5 0=1: ~A" res)))
	  (let ((res (vector->vct (z-transform v1 16 -1.0))))
	    (if (not (vequal res (make-vct 16 1.0)))
		(snd-display #__line__ ";z -1.0 0=1: ~A" res)))
	  (vct-set! v1 0 0.0)
	  (vct-set! v1 1 1.0)
	  (let ((res (vector->vct (z-transform v1 16 0.5))))
	    (if (not (vequal res (vct 1.000 0.500 0.250 0.125 0.062 0.031 0.016 0.008 0.004 0.002 0.001 0.0 0.0 0.0 0.0 0.0)))
		(snd-display #__line__ ";z 0.5 1=1: ~A" res)))
	  (let ((res (vector->vct (z-transform v1 16 2.0))))
	    (if (not (vequal res (vct 1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 
				      2048.0 4096.0 8192.0 16384.0 32768.0)))
		(snd-display #__line__ ";z 2.0 1=1: ~A" res)))
	  (vct-set! v1 2 1.0)
	  (let ((res (vector->vct (z-transform v1 16 0.5))))
	    (if (not (vequal res (vct 2.0 0.75 0.3125 0.140 0.0664 0.0322 0.0158 0.00787 0.0039 0.0019 0 0 0 0 0 0)))
		(snd-display #__line__ ";z 0.5 1=1 2=1: ~A" res)))
	  (let ((res (vector->vct (z-transform v1 16 2.0))))
	    (if (not (vequal res (vct 2.0 6.0 20.0 72.0 272.0 1056.0 4160.0 16512.0 65792.0 
				      262656.0 1049600.0 4196352.0 16781312.0 67117056.0 268451840.0 1073774592.0)))
		(snd-display #__line__ ";z 2.0 1=1 2=1: ~A" res)))
	  (do ((i 0 (+ 1 i))
	       (j 1.0 (* j 0.4)))
	      ((= i 16))
	    (vct-set! v1 i j))
	  (let ((res (vector->vct (z-transform v1 16 1.0))))
	    (if (not (vequal res (make-vct 16 (/ 1.0 (- 1.0 0.4))))) ; this is confusing
		(snd-display #__line__ ";z 1 0.4g: ~A" res))))
	
	(let ((ind (open-sound "oboe.snd")))
	  (automorph 0.0+1.0i 0 0 1)
	  (automorph 0.0+1.0i 0 0 1)
	  (automorph 0.0+1.0i 0 0 1)
	  (automorph 0.0+1.0i 0 0 1)
	  (let ((mxdiff 0.0) 
		(rd1 (make-sampler 0 ind 0)) 
		(rd2 (make-sampler 0 ind 0 1 0))) 
	    (scan-channel (lambda (y)
			    (let ((diff (abs (- (rd1) (rd2))))) 
			      (if (> diff mxdiff) 
				  (set! mxdiff diff)) 
			      #f))) 
	    (if (> mxdiff .003) (snd-display #__line__ ";automorph rotation: ~A" mxdiff)))
	  
	  (revert-sound ind)
	  (periodogram 256)
	  (if (not (lisp-graph? ind)) (snd-display #__line__ ";periodogram not graphed?"))
	  (close-sound ind))
	))
    
    (do ((i 0 (+ i 1)))
	((= i 10))
      (let* ((len (expt 2 (+ 2 (random 8))))
	     (v0 (make-vct len))
	     (v1 (make-vct len))
	     (v2 (make-vector len)))
	(do ((k 0 (+ k 1)))
	    ((= k len))
	  (set! (v0 k) (- (random 1.0) 0.5))
	  (set! (v1 k) (- (random 1.0) 0.5))
	  (set! (v2 k) (make-rectangular (v0 k) (v1 k))))
	(let ((res1 (mus-fft v0 v1 len 1))
	      (res2 (cfft! v2 len 1))
	      (sum 0.0)
	      (mx 0.0))
	  (do ((m 0 (+ m 1)))
	      ((= m len))
	    (let ((diffr (abs (- (v0 m) (real-part (v2 m)))))
		  (diffi (abs (- (v1 m) (imag-part (v2 m))))))
	      (set! sum (+ sum diffr diffi))
	      (if (> (max diffr diffi) mx)
		  (set! mx (max diffr diffi)))))
	  (if (or (> mx 1e-6)
		  (> sum 1e-6))
	      (format #t ";cfft! ~A: ~A ~A~%" len mx sum)))))
    
    (let ((val (cfft! (cfft! (cfft! (cfft! (vector 0.0 1+i 0.0 0.0)))))))
      (if (not (equal? val '#(0.0 16+16i 0.0 0.0)))
	  (snd-display #__line__ ";cfft! 4x: ~A" val)))
    
    (do ((i 0 (+ i 1)))
	((= i 10))
      (let* ((len (expt 2 (+ 2 (random 8))))
	     (v0 (make-vct len))
	     (v1 (make-vct len))
	     (v2 (make-vct len))
	     (v3 (make-vct len)))
	(do ((k 0 (+ k 1)))
	    ((= k len))
	  (set! (v0 k) (- (random 1.0) 0.5))
	  (set! (v1 k) (- (random 1.0) 0.5))
	  (set! (v2 k) (v0 k))
	  (set! (v3 k) (v1 k)))
	(let ((res1 (mus-fft v0 v1 len 1))
	      (res2 (fft! v2 v3 len 1))
	      (sum 0.0)
	      (mx 0.0))
	  (do ((m 0 (+ m 1)))
	      ((= m len))
	    (let ((diffr (abs (- (v0 m) (v2 m))))
		  (diffi (abs (- (v1 m) (v3 m)))))
	      (set! sum (+ sum diffr diffi))
	      (if (> (max diffr diffi) mx)
		  (set! mx (max diffr diffi)))))
	  (if (or (> mx 1e-6)
		  (> sum 1e-6))
	      (format #t ";fft! ~A: ~A ~A~%" len mx sum)))))
    ))



;;; ---------------- test 21: new stuff ----------------

(if (not (defined? 'load-font))
    (define (load-font name) #f))

(if (not (provided? 'snd-clean.scm)) (load "clean.scm"))
(if (not (provided? 'snd-snddiff.scm)) (load "snddiff.scm"))


(define (snd_test_21)
  
  (define* (add-comment sample comment snd1 chn1)
    (let* ((snd (or snd1 (selected-sound)))
	   (chn (or chn1 (selected-channel)))
	   (old-comments (or (channel-property 'comments snd chn) '())))
      (set! (channel-property 'comments snd chn)
	    (cons (list sample comment)
		  old-comments))))
  
  (define (show-comments snd chn)
    (let ((comments (or (channel-property 'comments snd chn) '())))
      (for-each
       (lambda (comment)
	 (let* ((samp (car comment))
		(text (cadr comment))
		(text-width (* 6 (string-length text)))
		(ls (left-sample snd chn))
		(rs (right-sample snd chn)))
	   (if (and (< ls samp)
		    (> rs samp))
	       (let ((xpos (x->position (/ samp (srate))))
		     (ypos (y->position (sample samp))))
		 (draw-line xpos 20 xpos (- ypos 4))
		 (draw-string text (- xpos (/ text-width 2)) 18)))))
       comments)))
  
  (define (display-samps-in-red snd chn)
    "display samples 1000 to 2000 in red whenever they're in the current view"
    (let ((left (left-sample snd chn))
	  (right (right-sample snd chn))
	  (old-color (foreground-color snd chn))
	  (red (make-color-with-catch 1 0 0)))
      (if (and (< left 2000)
	       (> right 1000))
	  (let* ((data (make-graph-data snd chn)))
	    (if data
		(if (vct? data)                      ;the simple, one-sided graph case
		    (let* ((samps (- (min right 2000)
				     (max left 1000)))
			   (offset (max 0 (- 1000 left)))
			   (new-data (vct-subseq data offset (+ offset samps))))
		      (set! (foreground-color snd chn) red)
		      (graph-data new-data snd chn copy-context (max 1000 left) (min 2000 right))
		      (set! (foreground-color snd chn) old-color))
		    (let* ((low-data (car data))     ;the two-sided envelope graph case
			   (high-data (cadr data))
			   ;; we need to place the red portion correctly in the current graph
			   ;; so the following is getting the "bin" numbers associated with 
			   ;; samples 1000 and 2000
			   (size (vct-length low-data))
			   (samps (- right left))
			   (left-offset (max 0 (- 1000 left)))
			   (left-bin (round (/ (* size left-offset) samps)))
			   (right-offset (- (min 2000 right) left))
			   (right-bin (round (/ (* size right-offset) samps)))
			   (new-low-data (vct-subseq low-data left-bin right-bin))
			   (new-high-data (vct-subseq high-data left-bin right-bin)))
		      (set! (foreground-color snd chn) red)
		      (graph-data 
		       (list new-low-data new-high-data) snd chn copy-context left-bin right-bin)
		      (set! (foreground-color snd chn) old-color))))))))
  
  (define show-hiho
    ;; show a red "hiho" in the helvetica bold font on a gray background
    (lambda (snd chn)
      (let ((ls (left-sample snd chn))
	    (rs (right-sample snd chn)))
	(if (and (< ls 1000)
		 (> rs 1000))
	    (let ((pos (x->position (/ 1000.0 (srate))))
		  (old-color (foreground-color)))
	      (set! (foreground-color) (make-color-with-catch .75 .75 .75))
	      (fill-rectangle pos 10 50 20)
	      (set! (foreground-color) (make-color-with-catch 1 0 0))
	      (draw-string "hiho" (+ pos 5) 24)
	      (set! (foreground-color) old-color))))))
  
  (begin
    
    (do ((test-ctr 0 (+ 1 test-ctr))) ((= test-ctr tests)) 
      (log-mem test-ctr)
      
      (if (not (sound-file? "oboe.snd")) (snd-display #__line__ ";oboe.snd not a sound file?"))
      (if (not (sound-file? "4.aiff")) (snd-display #__line__ ";4.aiff not a sound file?"))
      (if (sound-file? "snd.h") (snd-display #__line__ ";snd.h is a sound-file?"))
      
      (let ((ind1 (open-sound "oboe.snd")))
	(save-sound-as "test.snd" ind1)
	(let ((ind2 (open-sound "test.snd")))
	  (if (not (channels-equal? ind1 0 ind2 0))
	      (snd-display #__line__ ";channels-equal? of copy"))
	  (if (not (channels=? ind1 0 ind2 0))
	      (snd-display #__line__ ";channels=? of copy"))
	  (pad-channel (frames ind2 0) 100)
	  (if (channels-equal? ind1 0 ind2 0)
	      (snd-display #__line__ ";channels-equal? of pad"))
	  (if (not (channels=? ind1 0 ind2 0))
	      (snd-display #__line__ ";channels=? of pad"))
	  (set! (sample 50900 ind2 0) .1)
	  (if (channels-equal? ind1 0 ind2 0)
	      (snd-display #__line__ ";channels-equal? of pad+set"))
	  (if (channels=? ind1 0 ind2 0)
	      (snd-display #__line__ ";channels=? of pad+set 0 err"))
	  (if (not (channels=? ind1 0 ind2 0 .2))
	      (snd-display #__line__ ";channels=? of pad+set .2 err"))
	  (if with-gui
	      (begin
		(add-comment 1234 "sample 1234" ind1 0)
		(let ((comments (show-comments ind1 0)))
		  (update-time-graph)
		  (if (null? comments) (snd-display #__line__ ";add-comment failed?")))
		(display-db ind1 0)
		(display-samps-in-red ind1 0)
		(update-time-graph)
		(catch #t (lambda () (show-hiho ind1 0)) (lambda args args))
		(update-time-graph)
		(color-samples (highlight-color) 0 100 ind1 0)
		(update-time-graph)))
	  (power-env-channel (make-power-env '(0 0 .325  1 1 32.0 2 0 32.0) :duration 2.0))
	  (update-time-graph)
	  (if (provided? 'xm) (show-disk-space ind1))
	  (update-time-graph)
	  (revert-sound ind1)
	  (make-selection 10000 20000 ind1 0)
	  (if (not (selection?))
	      (snd-display #__line__ ";make-selection for show failed?")
	      (begin
		(show-selection)
		(let ((vals (x-bounds ind1 0)))
		  (if (or (fneq (car vals) (/ 10000.0 (srate ind1)))
			  (fneq (cadr vals) (/ 20000.0 (srate ind1))))
		      (snd-display #__line__ ";show-selection: ~A (~A)" vals (list (/ 10000.0 (srate ind1)) (/ 20000.0 (srate ind1))))))))
	  (add-hook! graph-hook zoom-spectrum)
	  (set! (transform-graph? ind1 0) #t)
	  (let ((ind3 (open-sound "pistol.snd")))
	    (overlay-sounds ind2 ind1 ind3)
	    (close-sound ind3))
	  (samples-via-colormap ind1 0)
	  (close-sound ind1)
	  (remove-hook! graph-hook zoom-spectrum)
	  (close-sound ind2)))
      
      (let ((old-srate (mus-srate)))
	(set! (print-length) (max (print-length) 48))
	(set! (mus-srate) 22050)
	(let ((ind (new-sound :size 33 :srate 22050)))
	  (map-channel (lambda (y) 1.0))
	  (let ((pe (make-power-env '(0 0 32.0  1 1 0.0312  2 0 1) :duration (/ 34.0 22050.0))))
	    (map-channel (lambda (y) (* y (power-env pe))))
	    (if (and (not (vequal1 (channel->vct) 
				   (vct 0.000 0.008 0.017 0.030 0.044 0.063 0.086 0.115 0.150 0.194 0.249 
					0.317 0.402 0.507 0.637 0.799 1.000 0.992 0.983 0.971 0.956 0.937 
					0.914 0.885 0.850 0.806 0.751 0.683 0.598 0.493 0.363 0.201 0.000)))
		     (not (vequal1 (channel->vct)
				   (vct 0.000 0.008 0.019 0.032 0.049 0.070 0.097 0.130 0.173 0.226 0.293 
					0.377 0.484 0.618 0.787 1.000 0.992 0.981 0.968 0.951 0.930 0.903 
					0.870 0.828 0.774 0.707 0.623 0.516 0.382 0.213 0.000 0.000 0.000))))
		(snd-display #__line__ ";power-env: ~A" (channel->vct))))
	  (map-channel (lambda (y) 1.0))
	  (let ((pe (make-power-env '(0 0 1.0  1 1 0.0  2 0 1  3 0 1) :duration (/ 34.0 22050.0))))
	    (map-channel (lambda (y) (* y (power-env pe))))
	    (if (not (vequal1 (channel->vct) 
			      (vct 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000 
				   1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 0.000 0.000 
				   0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		(snd-display #__line__ ";power-env 0 and 1: ~A" (channel->vct))))
	  (map-channel (lambda (y) 1.0))
	  (let ((pe (make-power-env '(0 0 .01 1 1 1) :duration (/ 34.0 22050.0))))
	    (map-channel (lambda (y) (* y (power-env pe))))
	    (if (and (not (vequal1 (channel->vct) 
				   (vct 0.000 0.132 0.246 0.346 0.432 0.507 0.573 0.630 0.679 0.722 0.760 
					0.792 0.821 0.845 0.867 0.886 0.902 0.916 0.928 0.939 0.948 0.956 
					0.963 0.969 0.975 0.979 0.983 0.987 0.990 0.992 0.995 0.997 0.998)))
		     (not (vequal1 (channel->vct)
				   (vct 0.000 0.135 0.253 0.354 0.442 0.518 0.584 0.641 0.691 0.733 0.771 
					0.803 0.830 0.855 0.875 0.893 0.909 0.923 0.934 0.945 0.953 0.961 
					0.968 0.973 0.978 0.982 0.986 0.987 0.990 0.992 0.995 0.997 0.998))))
		(snd-display #__line__ ";power-env .01: ~A" (channel->vct))))
	  (let ((name (file-name ind)))
	    (close-sound ind)
	    (if (file-exists? name) (delete-file name))))
	(set! (mus-srate) old-srate))
      
      (let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1 :size 50)))
	(set! (sample 3) 1.0)
	(filter-channel (vct .5 1.0 .5) 3)
	(let ((data (channel->vct 0 10)))
	  (if (not (vequal data (vct 0.000 0.000 0.000 0.500 1.000 0.500 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";filter (sym 3): ~A" data)))
	(undo)
	(filter-channel (vct .5 1.0 .25) 3)
	(let ((data (channel->vct 0 10)))
	  (if (not (vequal data (vct 0.000 0.000 0.000 0.500 1.000 0.250 0.000 0.000 0.000 0.000)))
	      (snd-display #__line__ ";filter (3): ~A" data)))
	(undo)
	(filter-channel (vct .5 1.0 1.0 .5) 4)
	(let ((data (channel->vct 0 10)))
	  (if (not (vequal data (vct 0.000 0.000 0.000 0.500 1.000 1.000 0.500 0.000 0.000 0.000)))
	      (snd-display #__line__ ";filter (sym 4): ~A" data)))
	(undo)
	(filter-channel (vct .5 1.0 1.0 .25) 4)
	(let ((data (channel->vct 0 10)))
	  (if (not (vequal data (vct 0.000 0.000 0.000 0.500 1.000 1.000 0.250 0.000 0.000 0.000)))
	      (snd-display #__line__ ";filter (4): ~A" data)))
	(undo)
	(close-sound ind))
      
      (let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1 #f 100)))
	(set! (sample 10) 0.5)
	(filter-sound (vct 1.0 0.0 1.0) 3)
	(if (not (vequal (channel->vct 5 10) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.500 0.000 0.000)))
	    (snd-display #__line__ ";filter-sound 1 0 1: ~A" (channel->vct 5 10)))
	(undo)
	(filter-channel (vct 1.0 0.0 1.0) 3)
	(if (not (vequal (channel->vct 5 10) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.500 0.000 0.000)))
	    (snd-display #__line__ ";filter-channel (v) 1 0 1: ~A" (channel->vct 5 10)))
	(undo)
	(filter-sound '(0 1 1 1) 100)
	(let ((coeffs (make-fir-coeffs 100 (make-vct 100 0.5)))
	      (data (channel->vct 10 100))
	      (happy #t))
	  (do ((i 0 (+ 1 i)))
	      ((or (not happy) (= i 100)))
	    (if (fneq (vct-ref data i) (vct-ref coeffs i))
		(begin
		  (snd-display #__line__ ";coeffs '(0 1 1 1): ~A ~A ~A" i (vct-ref coeffs i) (vct-ref data i))
		  (set! happy #f)))))
	(undo)
	(filter-sound '(0 1 1 1) 1000)
	(if (not (vequal (channel->vct 5 10) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";filter-sound 1 (1000): ~A" (channel->vct 5 10)))
	(undo)
	(make-selection 5 15)
	(filter-selection '(0 1 1 1) 100)
	(if (and (not (equal? (edit-fragment 2) (list "filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 11)))
		 (not (equal? (edit-fragment 2) (list "filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 111))))
	    (snd-display #__line__ ";filter-selection truncated: ~S" (edit-fragment 2)))
	(undo)
	(filter-selection '(0 1 1 1) 100 #f)  
	(if (not (equal? (edit-fragment 2) (list "filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 111)))
	    (snd-display #__line__ ";filter-selection not truncated: ~S" (edit-fragment 2)))
	(if (not (vequal (channel->vct 50 10) (vct -0.016 0.018 -0.021 0.024 -0.029 0.035 -0.045 0.064 -0.106 0.318)))
	    (snd-display #__line__ ";filter-selection no trunc: ~A" (channel->vct 50 10)))
	(undo)
	(filter-selection '(0 1 1 1) 1000 #t)
	(if (not (equal? (edit-fragment 2) (list "filter-selection '(0.000 1.000 1.000 1.000) 1000" "set" 5 11)))
	    (snd-display #__line__ ";filter-selection truncated (1000): ~S" (edit-fragment 2)))
	(if (fneq (maxamp) 0.0) (snd-display #__line__ ";filter-selection 1000 untrunc? ~A" (maxamp)))
	(undo)
	(filter-selection '(0 1 1 1) 1000 #f)
	(if (not (equal? (edit-fragment 2) (list "filter-selection '(0.000 1.000 1.000 1.000) 1000" "set" 5 1011)))
	    (snd-display #__line__ ";filter-selection not truncated (1000): ~S" (edit-fragment 2)))
	(if (fneq (maxamp) 0.318) (snd-display #__line__ ";filter-selection 1000 no trunc? ~A" (maxamp)))
	(if (not (vequal (channel->vct 505 10) (vct 0.035 -0.045 0.064 -0.106 0.318 0.318 -0.106 0.064 -0.045 0.035)))
	    (snd-display #__line__ ";filter-selection 1000 no trunc: ~A" (channel->vct 505 10)))
	
	(undo)
	(filter-channel '(0 1 1 1) 10)
	(if (not (vequal (channel->vct 10 10) (vct 0.008 -0.025 0.050 -0.098 0.316 0.316 -0.098 0.050 -0.025 0.008)))
	    (snd-display #__line__ ";filter-channel 10: ~A" (channel->vct 10 10)))
	(undo)
	(filter-channel '(0 1 1 1) 1000)
	(if (not (vequal (channel->vct 5 10) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";filter-channel 1 (1000): ~A" (channel->vct 5 10)))
	(undo)
	(filter-channel '(0 1 1 0) 10)
	(if (not (vequal (channel->vct 0 30) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
						  0.005 0.010 0.006 0.038 0.192 0.192 0.038 0.006 0.010 0.005
						  0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";filter-channel lp: ~A ~A ~A" (channel->vct 0 10) (channel->vct 10 10) (channel->vct 20 10)))
	(undo)
	(filter-channel '(0 1 1 0) 10 0 20 #f #f #f #f)
	(if (not (vequal (channel->vct 0 30) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
						  0.005 0.010 0.006 0.038 0.192 0.192 0.038 0.006 0.010 0.005
						  0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";filter-channel lp no trunc: ~A ~A ~A" (channel->vct 0 10) (channel->vct 10 10) (channel->vct 20 10)))
	(undo)
	(close-sound))
      
      (let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 2 #f 100)))
	(set! (sample 10) 0.5)
	(set! (sample 5 ind 1) -0.5)
	(set! (sync ind) 1)
	(filter-sound (vct 1.0 0.0 1.0) 3)
	(if (not (vequal (channel->vct 5 10 ind 0) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-sound 1 0 1: ~A" (channel->vct 5 10)))
	(if (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.000 0.000 0.000 0.000 -0.500 0.000 -0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-sound 1 0 2: ~A" (channel->vct 0 10 ind 1)))
	(undo)
	(filter-sound '(0 1 1 1) 1000)
	(if (not (vequal (channel->vct 5 10 ind 0) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-sound 1 (1000): ~A" (channel->vct 5 10)))
	(if (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.000 0.000 0.000 0.000 -0.500 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-sound 2 (1000): ~A" (channel->vct 0 10)))
	(undo)
	(make-selection 0 20)
	(filter-selection (vct 1.0 0.0 1.0) 3)
	(if (not (vequal (channel->vct 5 10 ind 0) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-selection 1 0 1: ~A" (channel->vct 5 10)))
	(if (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.000 0.000 0.000 0.000 -0.500 0.000 -0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-selection 1 0 2: ~A" (channel->vct 0 10 ind 1)))
	(undo)
	(set! (sync ind) 0)
	(filter-selection (vct 1.0 0.0 1.0) 3)
	(if (not (vequal (channel->vct 5 10 ind 0) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-selection 1 0 1 (no sync): ~A" (channel->vct 5 10)))
	(if (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.000 0.000 0.000 0.000 -0.500 0.000 -0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-selection 1 0 2 (no sync): ~A" (channel->vct 0 10 ind 1)))
	(undo 1 ind 0)
	(undo 1 ind 1)
	(if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";edpos filter-sel undo: ~A" (edit-position ind 0)))
	(if (not (= (edit-position ind 1) 1)) (snd-display #__line__ ";edpos filter-sel undo 1: ~A" (edit-position ind 1)))
	(filter-sound (vct 1.0 0.0 1.0) 3)
	(if (not (vequal (channel->vct 5 10 ind 0) (vct 0.000 0.000 0.000 0.000 0.000 0.500 0.000 0.500 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-sound 1 0 1 no sync: ~A" (channel->vct 5 10)))
	(if (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.000 0.000 0.000 0.000 -0.500 0.000 0.000 0.000 0.000)))
	    (snd-display #__line__ ";(2) filter-sound 1 0 2 no sync: ~A" (channel->vct 0 10 ind 1)))
	(undo 1 ind 0)
	(filter-channel '(0 1 1 0) 10 #f #f ind 1)
	(if (not (vequal (channel->vct 0 30 ind 1) (vct 0.000 0.000 0.000 0.000 0.000; 0.000 0.000 0.000 0.000 0.000
							-0.005 -0.010 -0.006 -0.038 -0.192 -0.192 -0.038 -0.006 -0.010 -0.005
							0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
							0 0 0 0 0)))
	    (snd-display #__line__ ";filter-channel lp: ~A ~A ~A" (channel->vct 0 10 ind 1) (channel->vct 10 10 ind 1) (channel->vct 20 10 ind 1)))
	(undo 1 ind 1)
	(close-sound ind))
      
      (let ((ind (new-sound "tmp.snd" mus-next mus-bshort 22050 1 :size 100)))
	(set! (sample 10) 0.5)
	(set! (sample 20) -0.5)
	(scale-to 1.0)
	(if (fneq (sample 10) .999) (snd-display #__line__ ";scale-to 1.0 short (10): ~A" (sample 10)))
	(if (fneq (sample 20) -.999) (snd-display #__line__ ";scale-to 1.0 short (20): ~A" (sample 10)))
	(close-sound ind))
      (let ((ind (new-sound "tmp.snd" mus-next mus-byte 22050 1 :size 100)))
	(set! (sample 10) 0.5)
	(set! (sample 20) -0.5)
	(scale-to 1.0)
	(if (fneq (sample 10) .992) (snd-display #__line__ ";scale-to 1.0 byte (10): ~A" (sample 10)))
	(if (fneq (sample 20) -.992) (snd-display #__line__ ";scale-to 1.0 byte (20): ~A" (sample 10)))
	(close-sound ind))
      
      (set! (transform-graph-type) graph-once)
      (set! (fft-window) 6)
      (set! (show-y-zero) #f)
      (set! (show-transform-peaks) #f)
      (set! (fft-log-frequency) #f)
      (set! (fft-log-magnitude) #f)
      (set! (with-verbose-cursor) #f)
      (set! (show-grid) #f)
      (set! (show-sonogram-cursor) #f)
      (set! (with-tracking-cursor) #f)
      (set! (show-controls) #f)
      (set! (speed-control-tones) 12)
      (set! (wavelet-type) 0)
      (set! (spectrum-start) 0.0)
      (set! (spectro-hop) 4)
      (set! (fft-window-alpha) 0.0)
      (set! (fft-window-beta) 0.0)
      (set! (min-dB) -60.0)
      (set! (reverb-control-decay) 1.0)
      
      (letrec ((test-sound-func-1
		(lambda (func name ind-1 ind-2 new-val eq-func leq-func settable channel global)
		  (let* ((old-val (func))
			 (old-vals (func #t))
			 (old-default (func #f))
			 (old-1 (func ind-1))
			 (old-2 (func ind-2))
			 (sel-snd (selected-sound))
			 (unsel-snd (if (equal? sel-snd ind-1) ind-2 ind-1))
			 (caller (if channel "channel" "sound")))
		    (if (not (eq-func old-val old-default))
			(snd-display #__line__ ";~A sound-func: no arg: ~A, #f: ~A" name old-val old-default))
		    (if (not (or (leq-func old-vals (list old-1 old-2))
				 (leq-func old-vals (list old-2 old-1))))
			(snd-display #__line__ ";~A sound-func #t: ~A, sep: ~A" name old-vals (list old-1 old-2)))
		    (if settable
			(begin
			  (set! (func) new-val)
			  (if (not (eq-func (func) new-val))
			      (snd-display #__line__ ";~A set no arg: ~A ~A" name (func) new-val))
			  (if (not (eq-func (func) (func sel-snd)))
			      (snd-display #__line__ ";~A set no arg sel: ~A ~A" name (func) (func sel-snd)))
			  (if (or (and global (not (eq-func (func) (func unsel-snd))))
				  (and (not global) (eq-func (func) (func unsel-snd))))
			      (snd-display #__line__ ";~A set no arg unsel: ~A ~A (sel: ~A)" name (func) (func unsel-snd) (func sel-snd)))
			  (if (not (or (leq-func (func #t) (list (func sel-snd) (func unsel-snd)))
				       (leq-func (func #t) (list (func unsel-snd) (func sel-snd)))))
			      (snd-display #__line__ ";~A ~A-func #t set: ~A, sep: ~A" name caller (func #t) (list (func sel-snd) (func unsel-snd))))
			  (set! (func) old-val)
			  (set! (func ind-1) new-val)
			  (if (not (eq-func (func ind-1) new-val))
			      (snd-display #__line__ ";~A set arg: ~A ~A" name (func ind-1) new-val))
			  (if (eq-func (func ind-2) new-val)
			      (snd-display #__line__ ";~A set arg (2): ~A ~A" name (func ind-2) new-val))
			  (if (not (or (leq-func (func #t) (list (func ind-1) (func ind-2)))
				       (leq-func (func #t) (list (func ind-2) (func ind-1)))))
			      (snd-display #__line__ ";~A ~A-func arg set: ~A, sep: ~A" name caller (func #t) (list (func ind-1) (func ind-2))))
			  (set! (func ind-1) old-1)
			  (set! (func #t) new-val)
			  (if (not (leq-func (func #t) (list new-val new-val)))
			      (snd-display #__line__ ";~A ~A-func arg set #t: ~A, sep: ~A" name caller (func #t) (list new-val new-val)))
			  (if (not (eq-func (func ind-1) new-val))
			      (snd-display #__line__ ";~A set arg #t: ~A ~A" name (func ind-1) new-val))
			  (if (not (eq-func (func ind-2) new-val))
			      (snd-display #__line__ ";~A set arg #t (2): ~A ~A" name (func ind-2) new-val))
			  (set! (func ind-1) old-1)
			  (set! (func ind-2) old-2)
			  (if (not (eq-func (func ind-1) old-1))
			      (snd-display #__line__ ";~A set arg #t old: ~A ~A" name (func ind-1) old-1))
			  (if (not (eq-func (func ind-2) old-2))
			      (snd-display #__line__ ";~A set arg #t (2): ~A ~A" name (func ind-2) old-2)))))))
	       (test-sound-func (lambda (func name ind-1 ind-2 new-val eq-func leq-func settable)
				  (test-sound-func-1 func name ind-1 ind-2 new-val eq-func leq-func settable #f #f))))
	
	(let ((ind-1 (new-sound "test-1.snd" mus-next mus-bfloat 22050 1 "mono testing" 100))
	      (ind-2 (new-sound "test-2.snd" mus-aifc mus-bshort 44100 2 "stereo testing" 300)))
	  
	  (for-each
	   (lambda (data)
	     (apply test-sound-func data))
	   (list
	    (list srate 'srate ind-1 ind-2 48000 = equal? #t)
	    (list data-format 'data-format ind-1 ind-2 mus-byte = equal? #t)
	    (list data-location 'data-location ind-1 ind-2 123 = equal? #t)
	    (list data-size 'data-size ind-1 ind-2 12348 = equal? #t)
	    (list frames 'frames ind-1 ind-2 12348 = equal? #t)
	    (list sync 'sync ind-1 ind-2 2 = equal? #t)
	    (list data-format 'data-format ind-1 ind-2 mus-byte = equal? #t)
	    (list channels 'channels ind-1 ind-2 0 = equal? #f)
	    (list chans 'chans ind-1 ind-2 0 = equal? #f)
	    (list header-type 'header-type ind-1 ind-2 0 = equal? #f)
	    
	    (list amp-control 'amp-control ind-1 ind-2 .5 (lambda (a b) (< (abs (- a b)) .01)) feql #t)
	    (list contrast-control 'contrast-control ind-1 ind-2 .5 (lambda (a b) (< (abs (- a b)) .01)) feql #t)
	    (list expand-control 'expand-control ind-1 ind-2 .5 (lambda (a b) (< (abs (- a b)) .01)) ffeql #t)
	    (list speed-control 'speed-control ind-1 ind-2 .5 (lambda (a b) (< (abs (- a b)) .01)) feql #t)
	    (list reverb-control-length 'reverb-control-length ind-1 ind-2 .5 (lambda (a b) (< (abs (- a b)) .01)) feql #t)
	    (list reverb-control-scale 'reverb-control-scale ind-1 ind-2 .5 (lambda (a b) (< (abs (- a b)) .01)) feql #t)
	    
	    (list contrast-control? 'contrast-control? ind-1 ind-2 #t equal? equal? #t)
	    (list expand-control? 'expand-control? ind-1 ind-2 #t equal? equal? #t)
	    (list filter-control? 'filter-control? ind-1 ind-2 #t equal? equal? #t)
	    (list reverb-control? 'reverb-control? ind-1 ind-2 #t equal? equal? #t)
	    (list read-only 'read-only ind-1 ind-2 #t equal? equal? #t)
	    
	    (list file-name 'file-name ind-1 ind-2 #f string=? equal? #f)
	    (list short-file-name 'short-file-name ind-1 ind-2 #f string=? equal? #f)
	    (list comment 'comment ind-1 ind-2 #f string=? equal? #f)))
	  
	  (save-controls #t)
	  (restore-controls #t)
	  (reset-controls #t)
	  (close-sound #t)
	  (if (not (equal? (sounds) '())) (snd-display #__line__ ";sounds after close-sound #t: ~A" (sounds)))
	  
	  ;; snd chn cases
	  (letrec ((test-channel-func-1 
		    (lambda (func name ind-1 ind-2 new-val eq-func leq-func settable global)
		      (let ((old-1-0 (func ind-1 0))
			    (old-2-0 (func ind-2 0))
			    (old-2-1 (func ind-2 1))
			    (old-1-all (func ind-1 #t))
			    (old-2-all (func ind-2 #t))
			    (old-all-0 (func #t 0))
			    (old-all-all (func #t #t)))
			(if (not (eq-func old-1-0 (car old-1-all))) (snd-display #__line__ ";~A channel-func old 1/#t: ~A ~A" name old-1-0 old-1-all))
			(if (not (eq-func old-2-0 (car old-2-all))) (snd-display #__line__ ";~A channel-func old 2/#t: ~A ~A" name old-2-0 old-2-all))
			(if (not (eq-func old-2-1 (cadr old-2-all))) (snd-display #__line__ ";~A channel-func old 2-2/#t: ~A ~A" name old-2-1 old-2-all))
			(if (not (leq-func old-1-all (list old-1-0))) (snd-display #__line__ ";~A channel-func #t list: ~A ~A" name old-1-all old-1-0))
			(if (not (leq-func old-2-all (list old-2-0 old-2-1))) 
			    (snd-display #__line__ ";~A channel-func (2) #t list: ~A ~A ~A" name old-2-all old-2-0 old-2-1))
			(if (not (and (or (leq-func (car old-all-all) old-1-all)
					  (leq-func (car old-all-all) old-2-all))
				      (or (leq-func (cadr old-all-all) old-1-all)
					  (leq-func (cadr old-all-all) old-2-all))))
			    (snd-display #__line__ ";~A channel-func #t #t: ~A ~A ~A" name old-all-all old-1-all old-2-all))
			(if settable
			    (begin
			      (set! (func ind-1 0) new-val)
			      (if (not (eq-func (func ind-1 0) new-val)) (snd-display #__line__ ";~A set channel-func: ~A ~A" name (func ind-1 0) new-val))
			      (if (eq-func (func ind-2 0) new-val) (snd-display #__line__ ";~A set 2 channel-func: ~A ~A" name (func ind-2 0) new-val))
			      (set! (func ind-1 0) old-1-0)
			      (set! (func ind-2 1) new-val)
			      (if (eq-func (func ind-1 0) new-val) (snd-display #__line__ ";~A set (2) channel-func: ~A ~A" name (func ind-1 0) new-val))
			      (if (not (eq-func (func ind-2 1) new-val)) (snd-display #__line__ ";~A set (2) 2 channel-func: ~A ~A" name (func ind-2 0) new-val))
			      (set! (func ind-2 0) new-val)
			      (set! (func ind-2 #t) old-2-0)
			      (if (not (eq-func (func ind-2 0) old-2-0)) (snd-display #__line__ ";~A set (#t 0) 2 channel-func: ~A ~A" name (func ind-2 0) old-2-0))
			      (if (not (eq-func (func ind-2 1) old-2-0)) (snd-display #__line__ ";~A set (#t 1) 2 channel-func: ~A ~A" name (func ind-2 1) old-2-0))
			      (set! (func ind-2 0) old-2-0)
			      (set! (func ind-2 1) old-2-1)))
			)))
		   (test-channel-func 
		    (lambda (func name ind-1 ind-2 new-val eq-func leq-func settable global)
		      (test-sound-func-1 func name ind-1 ind-2 new-val eq-func leq-func settable #t global)
		      (test-channel-func-1 func name ind-1 ind-2 new-val eq-func leq-func settable global))))
	    (let ((ind-1 (new-sound "test-1.snd" mus-next mus-bfloat 22050 1 "mono testing" 100))
		  (ind-2 (new-sound "test-2.snd" mus-aifc mus-bshort 44100 2 "stereo testing" 300)))
	      (set! (sample 1 ind-1 0) .1)
	      (set! (sample 2 ind-2 0) .2)
	      (set! (sample 3 ind-2 1) .3)
	      (for-each
	       (lambda (data)
		 (apply test-channel-func data))
	       (list
		(list min-dB 'min-dB ind-1 ind-2 -100.0 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list x-position-slider 'x-position-slider ind-1 ind-2 .1 (lambda (a b) (< (abs (- a b)) .01)) feql #t #f)
		
		(list y-position-slider 'y-position-slider ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .01)) feql #t #f)
		(list x-zoom-slider 'x-zoom-slider ind-1 ind-2 0.2 (lambda (a b) (< (abs (- a b)) .01)) feql #t #f)
		(list y-zoom-slider 'y-zoom-slider ind-1 ind-2 0.2 (lambda (a b) (< (abs (- a b)) .01)) feql #t #f)
		(list fft-window-alpha 'fft-window-alpha ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .02)) feql #t #t)
		(list fft-window-beta 'fft-window-beta ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .02)) feql #t #t)
		(list spectrum-end 'spectrum-end ind-1 ind-2 0.2 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectrum-start 'spectrum-start ind-1 ind-2 0.1 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-x-angle 'spectro-x-angle ind-1 ind-2 10.0 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-x-scale 'spectro-x-scale ind-1 ind-2 0.2 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-y-angle 'spectro-y-angle ind-1 ind-2 10.0 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-y-scale 'spectro-y-scale ind-1 ind-2 0.1 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-z-angle 'spectro-z-angle ind-1 ind-2 10.0 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-z-scale 'spectro-z-scale ind-1 ind-2 0.3 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list beats-per-minute 'beats-per-minute ind-1 ind-2 100.0 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		
		(list spectro-hop 'spectro-hop ind-1 ind-2 10 = equal? #t #t)
		(list cursor 'cursor ind-1 ind-2 50 = equal? #t #f)
		(list cursor-style 'cursor-style ind-1 ind-2 1 = equal? #t #t)
		(list cursor-size 'cursor-size ind-1 ind-2 10 = equal? #t #t)
		(list frames 'frames ind-1 ind-2 50 = equal? #t #f)
		(list zero-pad 'zero-pad ind-1 ind-2 1 = equal? #t #t)
		(list wavelet-type 'wavelet-type ind-1 ind-2 1 = equal? #t #t)
		(list time-graph-type 'time-graph-type ind-1 ind-2 graph-as-wavogram = equal? #t #t)
		(list wavo-hop 'wavo-hop ind-1 ind-2 10 = equal? #t #t)
		(list wavo-trace 'wavo-trace ind-1 ind-2 10 = equal? #t #t)
		(list transform-size 'transform-size ind-1 ind-2 64 = equal? #t #t)
		(list transform-graph-type 'transform-graph-type ind-1 ind-2 1 = equal? #t #t)
		(list fft-window 'fft-window ind-1 ind-2 1 = equal? #t #t)
					;               (list transform-type 'transform-type ind-1 ind-2 1 equal? equal? #t #t)
		(list transform-normalization 'transform-normalization ind-1 ind-2 2 = equal? #t #t)
		(list max-transform-peaks 'max-transform-peaks ind-1 ind-2 10 = equal? #t #t)
		(list dot-size 'dot-size ind-1 ind-2 10 = equal? #t #t)
		(list x-axis-style 'x-axis-style ind-1 ind-2 1 = equal? #t #t)
					;		(list left-sample 'left-sample ind-1 ind-2 1 (lambda (a b) (< (abs (- a b)) 2)) equal? #t #f)
					;		(list right-sample 'right-sample ind-1 ind-2 50 (lambda (a b) (< (abs (- a b)) 2)) equal? #t #f)
		(list show-axes 'show-axes ind-1 ind-2 2 = equal? #t #t)
		
		(list transform-graph? 'transform-graph? ind-1 ind-2 #t equal? equal? #t #f)
		(list time-graph? 'time-graph? ind-1 ind-2 #f equal? equal? #t #f)
		(list lisp-graph? 'lisp-graph? ind-1 ind-2 #t equal? equal? #t #f)
		(list squelch-update 'squelch-update ind-1 ind-2 #t equal? equal? #t #f)
		(list show-y-zero 'show-y-zero ind-1 ind-2 #t equal? equal? #t #t)
		(list show-grid 'show-grid ind-1 ind-2 #t equal? equal? #t #t)
		(list grid-density 'grid-density ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list show-sonogram-cursor 'show-sonogram-cursor ind-1 ind-2 #t equal? equal? #t #t)
		(list show-marks 'show-marks ind-1 ind-2 #f equal? equal? #t #t)
		(list show-transform-peaks 'show-transform-peaks ind-1 ind-2 #t equal? equal? #t #t)
		(list fft-log-frequency 'fft-log-frequency ind-1 ind-2 #t equal? equal? #t #t)
		(list fft-log-magnitude 'fft-log-magnitude ind-1 ind-2 #t equal? equal? #t #t)
		(list show-mix-waveforms 'show-mix-waveforms ind-1 ind-2 #f equal? equal? #t #t)
		(list with-verbose-cursor 'with-verbose-cursor ind-1 ind-2 #t equal? equal? #t #t)
		
		)))
	    (update-time-graph #t #t)
	    (update-transform-graph #t #t)
	    (update-lisp-graph #t #t)
	    
	    (close-sound #f)
	    (close-sound #f)
	    (if (not (equal? (sounds) '())) (snd-display #__line__ ";sounds after close-sound #t: ~A" (sounds))))))
      
      (letrec ((test-sound-func-2
		(lambda (func name ind-1 ind-2 new-val eq-func leq-func)
		  (let* ((old-global-val (func))
			 (old-vals (func #t))
			 (old-1 (func ind-1))
			 (old-2 (func ind-2))
			 (sel-snd (selected-sound))
			 (unsel-snd (if (equal? sel-snd ind-1) ind-2 ind-1)))
		    (if (not (or (leq-func old-vals (list old-1 old-2))
				 (leq-func old-vals (list old-2 old-1))))
			(snd-display #__line__ ";~A sound-func #t: ~A, sep: ~A" name old-vals (list old-1 old-2)))
		    (set! (func) new-val)
		    (if (not (eq-func (func) new-val))
			(snd-display #__line__ ";~A global set no arg: ~A ~A" name (func) new-val))
		    (if (not (eq-func (func) (func sel-snd)))
			(snd-display #__line__ ";~A global set no arg sel: ~A ~A" name (func) (func sel-snd)))
		    (if (not (eq-func (func) (func unsel-snd)))
			(snd-display #__line__ ";~A set global no arg unsel: ~A ~A (sel: ~A)" name (func) (func unsel-snd) (func sel-snd)))
		    (if (not (or (leq-func (func #t) (list (func sel-snd) (func unsel-snd)))
				 (leq-func (func #t) (list (func unsel-snd) (func sel-snd)))))
			(snd-display #__line__ ";~A func #t set: ~A, sep: ~A" name (func #t) (list (func sel-snd) (func unsel-snd))))
		    (set! (func) old-global-val)
		    (set! (func ind-1) new-val)
		    (if (not (eq-func (func ind-1) new-val))
			(snd-display #__line__ ";~A set arg: ~A ~A" name (func ind-1) new-val))
		    (if (eq-func (func ind-2) new-val)
			(snd-display #__line__ ";~A set arg (2): ~A ~A" name (func ind-2) new-val))
		    (if (not (or (leq-func (func #t) (list (func ind-1) (func ind-2)))
				 (leq-func (func #t) (list (func ind-2) (func ind-1)))))
			(snd-display #__line__ ";~A func arg set: ~A, sep: ~A" name (func #t) (list (func ind-1) (func ind-2))))
		    (set! (func ind-1) old-1)
		    (set! (func #t) new-val)
		    (if (not (leq-func (func #t) (list new-val new-val)))
			(snd-display #__line__ ";~A func arg set #t: ~A, sep: ~A" name (func #t) (list new-val new-val)))
		    (if (not (eq-func (func ind-1) new-val))
			(snd-display #__line__ ";~A set arg #t: ~A ~A" name (func ind-1) new-val))
		    (if (not (eq-func (func ind-2) new-val))
			(snd-display #__line__ ";~A set arg #t (2): ~A ~A" name (func ind-2) new-val))
		    (if (eq-func (func) new-val)
			(snd-display #__line__ ";~A overwrote global: ~A ~A" name (func) new-val))
		    (set! (func ind-1) old-1)
		    (set! (func ind-2) old-2)
		    (if (not (eq-func (func ind-1) old-1))
			(snd-display #__line__ ";~A set arg #t old: ~A ~A" name (func ind-1) old-1))
		    (if (not (eq-func (func ind-2) old-2))
			(snd-display #__line__ ";~A set arg #t (2): ~A ~A" name (func ind-2) old-2))))))
	
	(let ((ind-1 (new-sound "test-1.snd" mus-next mus-bfloat 22050 1 "mono testing" 100))
	      (ind-2 (new-sound "test-2.snd" mus-aifc mus-bshort 44100 2 "stereo testing" 300)))
	  
	  (for-each
	   (lambda (data)
	     (apply test-sound-func-2 data))
	   (list
	    (list filter-control-in-dB 'filter-control-in-dB ind-1 ind-2 #t eq? equal?)
	    (list filter-control-in-hz 'filter-control-in-hz ind-1 ind-2 #t eq? equal?)
	    (list show-controls 'show-controls ind-1 ind-2 #t eq? equal?)
	    (list with-tracking-cursor 'with-tracking-cursor ind-1 ind-2 #t eq? equal?)
	    
	    (list speed-control-tones 'speed-control-tones ind-1 ind-2 14 = equal?)
	    (list speed-control-style 'speed-control-style ind-1 ind-2 speed-control-as-semitone = equal?)
	    (list filter-control-order 'filter-control-order ind-1 ind-2 14 = equal?)
	    
	    (list expand-control-length 'expand-control-length ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list expand-control-ramp 'expand-control-ramp ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list expand-control-hop 'expand-control-hop ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list expand-control-jitter 'expand-control-jitter ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list contrast-control-amp 'contrast-control-amp ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list reverb-control-feedback 'reverb-control-feedback ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list reverb-control-lowpass 'reverb-control-lowpass ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    (list reverb-control-decay 'reverb-control-decay ind-1 ind-2 .25 (lambda (a b) (< (abs (- a b)) .01)) feql)
	    
	    (list amp-control-bounds 'amp-control-bounds ind-1 ind-2 (list 0.0 2.0) feql 
		  (lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
	    (list contrast-control-bounds 'contrast-control-bounds ind-1 ind-2 (list 0.0 2.0) feql
		  (lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
	    (list expand-control-bounds 'expand-control-bounds ind-1 ind-2 (list 0.1 2.0) feql
		  (lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
	    (list speed-control-bounds 'speed-control-bounds ind-1 ind-2 (list 0.1 2.0) feql
		  (lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
	    (list reverb-control-length-bounds 'reverb-control-length-bounds ind-1 ind-2 (list 0.0 2.0) feql
		  (lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))
	    (list reverb-control-scale-bounds 'reverb-control-scale-bounds ind-1 ind-2 (list 0.0 2.0) feql
		  (lambda (a b) (and (feql (car a) (car b)) (feql (cadr a) (cadr b)))))))
	  (close-sound ind-1)
	  (close-sound ind-2)))
      
      (if (and all-args (defined? 'snd-simulate-keystroke))
	  (begin
	    ;; monkeys pound on keyboard...
	    (copy-file (string-append (getcwd) "/2a.snd") (string-append (getcwd) "/test.snd"))
	    (let ((ind (open-sound "test.snd"))
		  (last-time (+ (real-time) 300))
		  (tests 2500))
	      (do ((i 0 (+ 1 i)))
		  ((or (> (real-time) last-time)
		       (= i tests)))
		(let ((k (+ 1 (random 200)))
		      (s (let ((v (random 5)))
			   (if (= v 1) 4
			       (if (= v 2) 8
				   (if (= v 3) 12
				       0))))))
		  (if (> k 127) (begin (set! k (char->integer #\x)) (set! s 4)))
		  (if (> (random 1.0) .99) (clear-listener))
		  (if (or (= k (char->integer #\e)) 
			  (= k (char->integer #\E)))
		      (snd-simulate-keystroke ind 0 (char->integer #\g) 0))
		  (snd-simulate-keystroke ind (random (channels ind)) k s)
		  (if (and (sound? ind) (> (frames ind 0) 1000000))
		      (begin
			(close-sound ind)
			(copy-file (string-append (getcwd) "/2a.snd") (string-append (getcwd) "/test.snd"))))
		  (if (not (sound? ind))
		      (set! ind (open-sound "test.snd")))))
	      (close-sound ind))))
      
      (remember-sound-state)
      (let ((ind (open-sound "oboe.snd")))
	(set! (transform-graph? ind 0) #t)
	(set! (show-transform-peaks ind 0) #t)
	(set! (show-y-zero ind 0) #t)
	(close-sound ind))
      (let ((ind (open-sound "oboe.snd")))
	(if (or (not (transform-graph? ind 0))
		(not (show-transform-peaks ind 0))
		(not (show-y-zero ind 0)))
	    (snd-display #__line__ ";remember-sound-state: ~A ~A ~A" (transform-graph? ind 0) (show-transform-peaks ind 0) (show-y-zero ind 0)))
	(close-sound ind))
      (reset-almost-all-hooks)
      
      (catch #t
	     (lambda ()
	       (let ((help (snd-apropos "close-sound"))
		     (help1 (snd-apropos 'close-sound)))
		 (if (or (not (string? help))
			 (not (string? help1)))
		     (snd-display #__line__ ";snd-apropos: ~%~A~% ~A~%" help help1))))
	     (lambda args 
	       (snd-display #__line__ ";snd-apropos trouble: ~A" args)))
      
      (map-sound-files (lambda (n) (if (> (mus-sound-duration n) 1000.0) (snd-display #__line__ ";~A is pretty long! ~A" n (mus-sound-duration n)))))
      (if (string? sf-dir)
	  (map-sound-files 
	   (lambda (n)
	     (catch #t
		    (lambda ()
		      (if (> (mus-sound-duration (string-append sf-dir n)) 1000.0) 
			  (snd-display #__line__ ";~A is pretty long! ~A" 
				       n 
				       (mus-sound-duration (string-append sf-dir n)))))
		    (lambda args #f))
	     (mus-sound-forget (string-append sf-dir n)))
	   sf-dir))
      
      (let ((snd (new-sound "test.snd")))
	(pad-channel 0 20)
	(map-channel (lambda (y) 1.0))
	(env-channel-with-base '(0 0 1 1) 1.0)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 0.0 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95)))
	      (snd-display #__line__ ";env-chan 1.0: ~A" data)))
	(undo)
	(env-channel-with-base '(0 0 1 1 2 1 3 0) 0.0)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)))
	      (snd-display #__line__ ";env-chan 0.0: ~A" data)))
	(undo)
	(env-channel-with-base '(0 0 1 1) 100.0)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 0.0 0.003 0.006 0.010 0.015 0.022 0.030 0.041 0.054 0.070 0.091 0.117 0.150 0.191 0.244 0.309 0.392 0.496 0.627 0.792)))
	      (snd-display #__line__ ";env-chan 100.0: ~A" data)))
	(undo)
	(env-channel-with-base '(0 0 1 1) 0.01)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 0.0 0.208 0.373 0.504 0.608 0.691 0.756 0.809 0.850 0.883 0.909 0.930 0.946 0.959 0.970 0.978 0.985 0.990 0.994 0.997)))
	      (snd-display #__line__ ";env-chan 0.01: ~A" data)))
	(undo)
	
	(env-channel-with-base '(0 0 1 1) 1.0 5 10)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 1.0 1.0 1.0 1.0 1.0 0.0 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.0 1.0 1.0 1.0 1.0 1.0)))
	      (snd-display #__line__ ";env-chan 1.0 seg: ~A" data)))
	(undo)
	(env-channel-with-base '(0 0 1 1 2 1 3 0) 0.0 5 10)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)))
	      (snd-display #__line__ ";env-chan 0.0 seg: ~A" data)))
	(undo)
	(env-channel-with-base '(0 0 1 1) 100.0 5 10)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 1.0 1.0 1.0 1.0 1.0 0.0 0.007 0.018 0.037 0.068 0.120 0.208 0.353 0.595 1.0 1.0 1.0 1.0 1.0 1.0)))
	      (snd-display #__line__ ";env-chan 100.0 seg: ~A" data)))
	(undo)
	(env-channel-with-base '(0 0 1 1) 0.01 5 10)
	(let ((data (channel->vct 0 20)))
	  (if (not (vequal data (vct 1.0 1.0 1.0 1.0 1.0 0.0 0.405 0.647 0.792 0.880 0.932 0.963 0.982 0.993 1.0 1.0 1.0 1.0 1.0 1.0)))
	      (snd-display #__line__ ";env-chan 0.01 seg: ~A" data)))
	(undo)
	(close-sound snd))
      
      (let ((ind1 (open-sound "now.snd"))
	    (ind2 (open-sound "oboe.snd")))
	(let ((val (channel-mean ind1 0)))
	  (if (fneq val 5.02560673308833e-5) (snd-display #__line__ ";channel-mean: ~A" val)))
	(let ((val (channel-total-energy ind1 0)))
	  (if (fneq val 50.7153476262465) (snd-display #__line__ ";channel-total-energy: ~A" val)))
	(let ((val (channel-average-power ind1 0)))
	  (if (fneq val 0.00155078578803922) (snd-display #__line__ ";channel-average-power: ~A" val)))
	(let ((val (channel-rms ind1 0)))
	  (if (fneq val 0.039380017623653) (snd-display #__line__ ";channel-rms: ~A" val)))
	(let ((val (channel-norm ind1 0)))
	  (if (fneq val 7.12147088923675) (snd-display #__line__ ";channel-norm: ~A" val)))
	(let ((val (channel-variance ind1 0)))
	  (if (fneq val 50.7153476237207) (snd-display #__line__ ";channel-variance: ~A" val)))
	(let ((val (channel-lp 2 ind1 0)))
	  (if (fneq val 7.12147088923675) (snd-display #__line__ ";channel-lp 2: ~A" val)))
	(let ((val (channel-lp 1 ind1 0)))
	  (if (fneq val 775.966033935547) (snd-display #__line__ ";channel-lp 1: ~A" val)))
	(let ((val (channel2-inner-product ind1 0 ind2 0)))
	  (if (fneq val 1.52892031334341) (snd-display #__line__ ";channel2-inner-product: ~A" val)))
	(let ((val (channel2-angle ind1 0 ind2 0)))
	  (if (fneq val 1.55485084385627) (snd-display #__line__ ";channel2-angle: ~A" val)))
	(let ((val (channel2-orthogonal? ind1 0 ind2 0)))
	  (if val (snd-display #__line__ ";channel2-orthogonal: ~A" val)))
	(let ((val (channel2-coefficient-of-projection ind1 0 ind2 0)))
	  (if (fneq val 0.0301470932351876) (snd-display #__line__ ";channel2-coefficient-of-projection: ~A" val)))
	(close-sound ind1)
	(set! ind1 (open-sound "oboe.snd"))
	(scale-by .99 ind1 0)
	(let ((dist (channel-distance ind1 0 ind2 0)))
	  (if (fneq dist .1346) (snd-display #__line__ ";channel-distance: ~A" dist)))
	
	(close-sound ind1)
	(close-sound ind2))
      
      (let ((loboe  (string-append (getcwd) "/oboe.snd"))
	    (ltest  (string-append (getcwd) "/test.snd")))
	(copy-file loboe ltest)
	(mus-sound-forget ltest)
	(let* ((ind (open-sound ltest))
	       (mx (maxamp ind 0))
	       (chns (chans ind))
	       (sr (srate ind))
	       (fr (frames ind 0)))
	  (if (or (not (= (chans ind) (mus-sound-chans loboe)))
		  (not (= (srate ind) (mus-sound-srate loboe)))
		  (not (= (frames ind) (mus-sound-frames loboe))))
	      (snd-display #__line__ ";copy oboe -> test seems to have failed? ~A ~A ~A"
			   (chans ind) (srate ind) (frames ind))
	      (with-local-hook
	       update-hook
	       (list (lambda (orig-ind)
		       (lambda (new-ind)
			 (set! ind new-ind))))
	       (lambda ()
		 (do ((i 0 (+ 1 i)))
		     ((= i 10))
		   (let ((v (channel->vct)))
		     (if (not (vct? v))
			 (snd-display #__line__ ";channel->vct of oboe copy is null??")
			 (array->file ltest v fr sr chns))
		     (update-sound ind)
		     (let ((mx1 (maxamp ind 0)))
		       (if (fneq mx mx1)
			   (snd-display #__line__ ";update-sound looped maxamp: ~A ~A ~A ~A ~A (~A)" i ind (frames ind) mx1 mx (/ mx1 mx))))
		     (if (not (= (chans ind) chns)) (snd-display #__line__ ";update-sound looped chans: ~A ~A" chns (chans ind)))
		     (if (not (= (srate ind) sr)) (snd-display #__line__ ";update-sound looped srate: ~A ~A" sr (srate ind)))
		     (if (not (= (frames ind) fr)) (snd-display #__line__ ";update-sound looped frames: ~A ~A" fr (frames ind 0)))))
		 (let* ((old-ind (open-sound "oboe.snd"))
			(diff 0.0)
			(rd (make-sampler 0 ind 0))
			(home (sampler-home rd)))
		   (scan-channel (lambda (y)
				   (let ((cd (abs (- y (rd)))))
				     (if (> cd diff) (set! diff cd))
				     #f))
				 0 fr old-ind 0)
		   (if (fneq diff 0.0) 
		       (snd-display #__line__ ";update-sound looped overall max diff: ~A, sounds: ~A, ind: ~A, old-ind: ~A, rd: ~A" diff (sounds) ind old-ind home))
		   (close-sound old-ind)))))
	  (close-sound ind)))
      
      (if (file-exists? "test.snd") (delete-file "test.snd"))
      (let* ((ind (open-sound "oboe.snd"))
	     (data (channel->vct)))
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (array->file "test.snd" data (frames ind) 22050 1)
	  (file->array "test.snd" 0 0 (frames) data)
	  (let ((diff 0.0)
		(ctr 0))
	    (scan-channel (lambda (y)
			    (let ((cd (abs (- y (vct-ref data ctr)))))
			      (if (> cd diff) (set! diff cd))
			      (set! ctr (+ 1 ctr))
			      #f)))
	    (if (fneq diff 0.0) (snd-display #__line__ ";arr->file->array overall max diff: ~A" diff))))
	
	;; now clear sono bins if possible 
	(set! (colormap-size) 16)
	(set! (transform-size ind 0) 8)
	(set! (transform-graph-type ind 0) graph-as-sonogram)
	(set! (transform-graph? ind 0) #t)
	(update-transform-graph)
	(set! (x-bounds) (list 0.0 .04))
	(update-time-graph)
	(update-transform-graph)
	(set! (zoom-focus-style) (lambda (s c z x0 x1 range)
				   0))
	(if (not (procedure? (zoom-focus-style)))
	    (snd-display #__line__ ";zoom-focus-style as func: ~A" (zoom-focus-style)))
	(set! (zoom-focus-style) zoom-focus-right)
	(if (not (= (zoom-focus-style) zoom-focus-right))
	    (snd-display #__line__ ";unset zoom-focus-style as func: ~A" (zoom-focus-style)))
	(close-sound ind))
      
      (if (file-exists? "test.snd") (delete-file "test.snd"))
      (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
      (let* ((rdin #f)
	     (rdout #f)
	     (len (mus-sound-frames "oboe.snd"))
	     (types (list mus-riff mus-aifc mus-next mus-nist mus-ircam))
	     (forms (list mus-lshort mus-bshort mus-b24int mus-l24int mus-bint)))
	(system "cp oboe.snd fmv.snd")
	(do ((i 0 (+ 1 i)))
	    ((= i 5))
	  (set! rdin (make-readin :file "fmv.snd"))
	  (set! rdout (make-sample->file "test.snd" 1 (list-ref forms i) (list-ref types i)))
	  (do ((k 0 (+ 1 k)))
	      ((= k len))
	    (sample->file rdout k 0 (readin rdin)))
	  (mus-close rdout)
	  (mus-close rdin)
	  (system "mv test.snd fmv.snd")
	  (mus-sound-forget "test.snd")
	  (mus-sound-forget "fmv.snd"))
	(let ((diff 0.0)
	      (ctr 0)
	      (ind1 (open-sound "oboe.snd"))
	      (ind2 (make-file->sample "fmv.snd")))
	  (scan-channel (lambda (y)
			  (let* ((yy (file->sample ind2 ctr 0))
				 (cd (abs (- y yy))))
			    (if (> cd diff) (begin (set! diff cd) (display (format #f ";~A: ~A ~A ~A" ctr diff y yy))))
			    (set! ctr (+ 1 ctr))
			    #f)))
	  (if (fneq diff 0.0) (snd-display #__line__ ";file->sample->file overall max diff: ~A" diff))
	  (close-sound ind1)))
      
      (let* ((ind (open-sound "1a.snd"))
	     (mx (maxamp)))
	;; jokes from extsnd.html (make sure they run)
	(for-each
	 (lambda (name-and-func)
	   (let ((name (car name-and-func)))
	     ((cadr name-and-func))
	     (if (fneq (/ (maxamp) mx) 2.0)
		 (if (and (not (eq? name 'set-samples))
			  (not (eq? name 'coroutines)))
		     (snd-display #__line__ ";silly scalers: ~A ~A" name (/ (maxamp) mx))))
	     (revert-sound)))
	 (list
	  (list 'scale-by (lambda () (scale-by 2.0)))
	  (list 'scale-channel (lambda () (scale-channel 2.0)))
	  (list 'map-channel (lambda () (map-channel (lambda (val) (* val 2.0)))))
	  (list 'set-max (lambda () (set! (maxamp) (* 2 (maxamp)))))
	  (list 'env-sound (lambda () (env-sound '(0 2 1 2))))
	  (list 'env-channel (lambda () (env-channel (make-env '(0 1 1 1) :scaler 2.0 :length (frames)))))
	  (list 'clm-channel (lambda () (clm-channel (make-one-zero :a0 2.0 :a1 0.0))))
	  (list 'filter-channel (lambda () (filter-channel (vct 2.0) 1)))
	  (list 'vct->channel (lambda () (vct->channel (vct-scale! (channel->vct) 2.0) 0)))
	  (list 'mix-selection (lambda () (begin (select-all) (mix-selection 0))))
	  (list 'scale-selection (lambda () (begin (select-all) (scale-selection-by 2.0))))
	  (list 'mix (lambda () (begin (save-sound-as "temp.snd") (mix "temp.snd" 0) (delete-file "temp.snd"))))
	  (list 'sound-data (lambda ()
			      (let ((sd (samples->sound-data)))
				(do ((i 0 (+ 1 i))) 
				    ((= i (frames)))
				  (sound-data-set! sd 0 i (* 2.0 (sound-data-ref sd 0 i))))
				(set! (samples 0 (frames)) (sound-data->vct sd)))))
	  (list 'convolve (lambda () 
			    (let ((flt (make-vct 8)))
			      (vct-set! flt 0 2.0)
			      (let ((cnv (make-convolve :filter flt))
				    (sf (make-sampler 0)))
				(map-channel
				 (lambda (val)
				   (convolve cnv (lambda (dir) 
						   (read-sample sf)))))))))
	  (list 'fft (lambda ()
		       (let* ((len (frames))
			      (fsize (expt 2 (ceiling (/ (log len) (log 2)))))
			      (rl (channel->vct 0 fsize))
			      (im (make-vct fsize)))
			 (mus-fft rl im fsize)
			 (mus-fft rl im fsize)
			 (mus-fft rl im fsize)
			 (mus-fft rl im fsize)
			 (vct->channel (vct-scale! rl (/ 2.0 (* fsize fsize))) 0 len))))
	  (list 'set-samples (lambda () ; too slow for some reason, so cut it short at 100
			       (set! (squelch-update) #t)
			       (do ((i 0 (+ 1 i)))
				   ((= i 100))
				 (set! (sample i) (* 2 (sample i))))
			       (set! (squelch-update) #f)))
	  (list 'coroutines (lambda ()
			      (set! (squelch-update) #t)
			      (let ((make-scaler 
				     (lambda (start end)
				       (letrec ((ctr start)
						(us (lambda (them)
						      (set! (sample ctr) (* 2.0 (sample ctr)))
						      (set! ctr (+ ctr 2))
						      (if (<= ctr end)
							  (them us)))))
					 us))))
				((make-scaler 0 100)
				 (make-scaler 1 100)))
			      (set! (squelch-update) #f)
			      ))
	  ))
	(close-sound ind))
      
      ;; frame.scm functions
      
      (let ((tag (catch #t (lambda () (frame-reverse! 32)) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";frame-reverse! bad arg: ~A" tag)))
      (let ((tag (catch #t (lambda () (frame-copy 32)) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";frame-copy bad arg: ~A" tag)))
      
      (let ((fr1 (make-frame 3 .1 .2 .3)))
	(let ((val (frame-copy fr1)))
	  (if (or (fneq (frame-ref val 0) 0.1)
		  (fneq (frame-ref val 1) 0.2)
		  (fneq (frame-ref val 2) 0.3))
	      (snd-display #__line__ ";frame-copy: ~A" val))
	  (if (not (equal? val fr1)) (snd-display #__line__ ";frames not equal after copy?"))
	  (frame-set! val 0 0.0)
	  (if (or (fneq (frame-ref val 0) 0.0)
		  (fneq (frame-ref fr1 0) 0.1))
	      (snd-display #__line__ ";set of copied frame: ~A ~A" fr1 val))
	  (frame-reverse! val)
	  (if (or (fneq (frame-ref val 0) 0.3)
		  (fneq (frame-ref val 1) 0.2)
		  (fneq (frame-ref val 2) 0.0))
	      (snd-display #__line__ ";frame-reverse: ~A" val))
	  (if (equal? fr1 val) (snd-display #__line__ ";these frames are equal??: ~A ~A" fr1 val))))
      
      
      (let ((tag (catch #t (lambda () (vct->frame 32)) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";vct->frame bad arg: ~A" tag)))
      (let ((tag (catch #t (lambda () (frame->vct 32)) (lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";frame->vct bad arg: ~A" tag)))
      
      (let ((fr1 (make-frame 4 .1 .2 .3 .4))
	    (vc1 (vct .1 .2 .3 .4)))
	(let ((fr2 (vct->frame vc1))
	      (vc2 (frame->vct fr1)))
	  (if (not (equal? vc1 vc2)) (snd-display #__line__ ";frame->vct: ~A ~A" vc1 vc2))
	  (if (not (equal? fr1 fr2)) (snd-display #__line__ ";vct->frame: ~A ~A" fr1 fr2))
	  (vct-set! vc2 0 0.0)
	  (frame-set! fr2 0 0.0)
	  (if (equal? vc1 vc2) (snd-display #__line__ ";frame->vct + change: ~A ~A" vc1 vc2))
	  (if (equal? fr1 fr2) (snd-display #__line__ ";vct->frame + change: ~A ~A" fr1 fr2))
	  (let ((vc3 (make-vct 10))
		(fr3 (make-frame 10)))
	    (let ((vc4 (frame->vct fr1 vc3))
		  (fr4 (vct->frame vc1 fr3)))
	      (if (not (equal? vc3 vc4)) (snd-display #__line__ ";frame->vct + v: ~A ~A" vc3 vc4))
	      (if (not (equal? fr3 fr4)) (snd-display #__line__ ";vct->frame + fr: ~A ~A" fr3 fr4))
	      (if (not (vequal vc3 (vct .1 .2 .3 .4 0 0 0 0 0 0))) 
		  (snd-display #__line__ ";frame->vct results: ~A -> ~A" fr1 vc3))
	      (if (not (equal? fr3 (make-frame 10 .1 .2 .3 .4 0 0 0 0 0 0)))
		  (snd-display #__line__ ";vct->frame results: ~A -> ~A" vc1 fr3))))))
      
      (let ((fr1 (make-frame 2 .1 .2))
	    (sd1 (make-sound-data 2 5)))
	(frame->sound-data fr1 sd1 3)
	(let ((vc1 (sound-data->vct sd1 0))
	      (vc2 (sound-data->vct sd1 1)))
	  (if (or (not (vequal vc1 (vct 0 0 0 .1 0)))
		  (not (vequal vc2 (vct 0 0 0 .2 0))))
	      (snd-display #__line__ ";frame->sound-data: ~A ~A ~A)" sd1 vc1 vc2)))
	(let ((fr2 (make-frame 2)))
	  (sound-data->frame sd1 3 fr2)
	  (if (not (equal? fr1 fr2)) (snd-display #__line__ ";sound-data->frame: ~A ~A" fr1 fr2))
	  
	  (let ((tag (catch #t (lambda () (sound-data->frame sd1 0 32)) (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";sound-data->frame bad frame arg: ~A" tag)))
	  (let ((tag (catch #t (lambda () (sound-data->frame 32 0 fr1)) (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";sound-data->frame bad sound-data arg: ~A" tag)))
	  (let ((tag (catch #t (lambda () (frame->sound-data fr1 32 0)) (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";frame->sound-data bad sound-data arg: ~A" tag)))
	  (let ((tag (catch #t (lambda () (frame->sound-data 32 sd1 0)) (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";frame->sound-data bad frame arg: ~A" tag)))))
      
      (let ((index (new-sound "test.snd" mus-next mus-bfloat 22050 2 "frame->sound test" 100)))
	(set! (sample 4 index 0) 0.5)
	(set! (sample 4 index 1) 0.25)
	(set! (sample 6 index 1) 1.0)
	(let ((fr1 (sound->frame 1))
	      (fr4 (sound->frame 4 index))
	      (fr6 (sound->frame 6 index)))
	  (if (not (equal? fr1 (make-frame 2 0.0 0.0))) (snd-display #__line__ ";sound->frame 1: ~A" fr1))
	  (if (not (equal? fr4 (make-frame 2 0.5 0.25))) (snd-display #__line__ ";sound->frame 4: ~A" fr4))
	  (if (not (equal? fr6 (make-frame 2 0.0 1.0))) (snd-display #__line__ ";sound->frame 6: ~A" fr6))
	  (frame->sound fr4 8 index)
	  (frame->sound fr1 4)
	  (frame->sound fr6 0 index)
	  (let ((fr0 (sound->frame 0))
		(fr41 (sound->frame 4 index))
		(fr8 (sound->frame 8 index)))
	    (if (not (equal? fr0 fr6)) (snd-display #__line__ ";sound->frame 0: ~A" fr0))
	    (if (not (equal? fr41 fr1)) (snd-display #__line__ ";sound->frame 41: ~A" fr41))
	    (if (not (equal? fr8 fr4)) (snd-display #__line__ ";sound->frame 8: ~A" fr8))))
	(set! (sample 40 index 0) 0.5)
	(set! (sample 40 index 1) 0.3)
	(set! (sample 41 index 0) 0.7)
	(let ((reg (make-region 40 50 index #t)))
	  (let ((fr0 (region->frame reg 0))
		(fr1 (region->frame reg 1))
		(fr4 (region->frame reg 4)))
	    (if (not (equal? fr0 (make-frame 2 0.5 0.3))) (snd-display #__line__ ";region->frame 0: ~A" fr0))
	    (if (not (equal? fr1 (make-frame 2 0.7 0.0))) (snd-display #__line__ ";region->frame 1: ~A" fr1))
	    (if (not (equal? fr4 (make-frame 2 0.0 0.0))) (snd-display #__line__ ";region->frame 4: ~A" fr4))))      
	(close-sound index))
      
      (let ((index (new-sound "test.snd" mus-next mus-bfloat 22050 1 "frame->sound test" 100)))
	(set! (sample 4 index 0) 0.5)
	(let ((fr1 (sound->frame 1))
	      (fr4 (sound->frame 4 index)))
	  (if (not (equal? fr1 (make-frame 1 0.0))) (snd-display #__line__ ";sound->frame 1 1: ~A" fr1))
	  (if (not (equal? fr4 (make-frame 1 0.5))) (snd-display #__line__ ";sound->frame 1 4: ~A" fr4))
	  (frame->sound (make-frame 4 .1 .2 .3 .4) 8 index)
	  (let ((fr8 (sound->frame 8 index)))
	    (if (not (equal? fr8 (make-frame 1 .1))) (snd-display #__line__ ";sound->frame 1 8: ~A" fr8))))
	(close-sound index))
      
      (let ((index (new-sound "test.snd" mus-next mus-bfloat 22050 1 "frame->sound test" 10)))
	(set! (sample 4 index 0) 0.5)
	(let ((sd1 (sound->sound-data 0 10 index))
	      (sd2 (sound->sound-data 10 2)))
	  (if (not (equal? sd2 (make-sound-data 1 2))) (snd-display #__line__ ";sound->sound-data 2: ~A" sd2))
	  (if (not (vequal (sound-data->vct sd1 0) (vct 0 0 0 0 0.5 0 0 0 0 0)))
	      (snd-display #__line__ ";sound->sound-data 10: ~A" sd1))
	  (sound-data-set! sd1 0 0 0.7)
	  (sound-data->sound sd1 0 10 index)
	  (if (not (vequal (channel->vct 0 10 index 0) (vct 0.7 0 0 0 0.5 0 0 0 0 0)))
	      (snd-display #__line__ ";sound-data->sound 1: ~A" sd1))
	  (let ((tag (catch #t (lambda () (sound-data->sound 32 0)) (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";sound-data->sound bad sound-data arg: ~A" tag)))
	  (let ((tag (catch #t (lambda () (sound-data->sound sd1 0 10 -1)) (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-sound)) (snd-display #__line__ ";sound-data->sound bad sound arg: ~A" tag)))
	  (close-sound index)))
      
      (let ((index (new-sound "test.snd" mus-next mus-bfloat 22050 4 "frame->sound test" 10)))
	(set! (sample 4 index 0) 0.5)
	(set! (sample 4 index 1) 0.4)
	(set! (sample 4 index 2) 0.3)
	(set! (sample 4 index 3) 0.2)
	(let ((sd1 (sound->sound-data 0 10 index))
	      (sd2 (sound->sound-data 10 2)))
	  (if (not (equal? sd2 (make-sound-data 4 2))) (snd-display #__line__ ";sound->sound-data 4 2: ~A" sd2))
	  (if (not (vequal (sound-data->vct sd1 0) (vct 0 0 0 0 0.5 0 0 0 0 0)))
	      (snd-display #__line__ ";sound->sound-data 4a 10: ~A" (sound-data->vct sd1 0)))
	  (if (not (vequal (sound-data->vct sd1 1) (vct 0 0 0 0 0.4 0 0 0 0 0)))
	      (snd-display #__line__ ";sound->sound-data 4b 10: ~A" (sound-data->vct sd1 1)))
	  (if (not (vequal (sound-data->vct sd1 2) (vct 0 0 0 0 0.3 0 0 0 0 0)))
	      (snd-display #__line__ ";sound->sound-data 4c 10: ~A" (sound-data->vct sd1 2)))
	  (if (not (vequal (sound-data->vct sd1 3) (vct 0 0 0 0 0.2 0 0 0 0 0)))
	      (snd-display #__line__ ";sound->sound-data 4d 10: ~A" (sound-data->vct sd1 3)))
	  (sound-data-set! sd1 0 0 0.7)
	  (sound-data-set! sd1 1 0 0.8)
	  (sound-data-set! sd1 2 0 0.9)
	  (sound-data-set! sd1 3 0 0.6)
	  (sound-data->sound sd1 0)
	  (if (not (vequal (channel->vct 0 10 index 0) (vct 0.7 0 0 0 0.5 0 0 0 0 0)))
	      (snd-display #__line__ ";sound-data->sound 1 4a: ~A" (sound-data->vct sd1 0)))
	  (if (not (vequal (channel->vct 0 10 index 1) (vct 0.8 0 0 0 0.4 0 0 0 0 0)))
	      (snd-display #__line__ ";sound-data->sound 1 4b: ~A" (sound-data->vct sd1 1)))
	  (if (not (vequal (channel->vct 0 10 index 2) (vct 0.9 0 0 0 0.3 0 0 0 0 0)))
	      (snd-display #__line__ ";sound-data->sound 1 4c: ~A" (sound-data->vct sd1 2)))
	  (if (not (vequal (channel->vct 0 10 index 3) (vct 0.6 0 0 0 0.2 0 0 0 0 0)))
	      (snd-display #__line__ ";sound-data->sound 1 4d: ~A" (sound-data->vct sd1 3)))
	  (close-sound index)))
      
      (for-each
       (lambda (file)
	 (let ((index (open-sound file)))
	   (let ((fd (make-frame-reader 10000)))
	     (if (not (frame-reader? fd)) (snd-display #__line__ ";~A: frame-reader?: ~A" file fd))
	     (if (> (frames index) 10000)
		 (begin
		   (if (frame-reader-at-end? fd) (snd-display #__line__ ";~A: frame-reader-at-end?: ~A" file fd))
		   (if (not (= (frame-reader-position fd) 10000)) 
		       (snd-display #__line__ ";~A: frame-reader: position: ~A ~A" fd (frame-reader-position fd) file)))
		 (begin
		   (if (not (frame-reader-at-end? fd)) (snd-display #__line__ ";~A: not frame-reader-at-end?: ~A" file fd))
		   (if (= (frame-reader-position fd) 10000)
		       (snd-display #__line__ ";~A: frame-reader: position but frames: ~A ~A ~A" file fd (frame-reader-position fd) (frames index)))))
	     (if (not (equal? (frame-reader-home fd) index)) 
		 (snd-display #__line__ ";~A: frame-reader: home: ~A ~A ~A" file fd (frame-reader-home fd) index))
	     (if (not (= (frame-reader-chans fd) (chans index))) 
		 (snd-display #__line__ ";frame-reader-chans: ~A ~A" (frame-reader-chans fd) (chans index)))
	     (let ((fr0 (frame-copy (read-frame fd)))
		   (fr1 (frame-copy (next-frame fd)))
		   (fr2 (frame-copy (previous-frame fd))))
	       (if (not (equal? fr0 (sound->frame 10000 index)))
		   (snd-display #__line__ ";~A: frame reader 10000: ~A ~A" file fr0 (sound->frame 10000 index)))
	       (if (not (equal? fr1 (sound->frame 10001 index)))
		   (snd-display #__line__ ";~A: frame reader 10001: ~A ~A" file fr1 (sound->frame 10001 index)))
	       (if (not (equal? fr2 (sound->frame 10001 index)))
		   (snd-display #__line__ ";~A: frame reader 10001 prev: ~A ~A" file fr2 (sound->frame 10001 index))))
	     (free-frame-reader fd))
	   (close-sound index)))
       (list "oboe.snd" "4.aiff" "2.snd" "2a.snd")) ; 2a=eof
      
      (for-each
       (lambda (file)
	 (let ((index (open-sound file)))
	   (let ((fd (make-sampler 10000)))
	     (if (not (sampler? fd)) (snd-display #__line__ ";~A: sampler?: ~A" file fd))
	     (if (> (frames index) 10000)
		 (begin
		   (if (sampler-at-end? fd) (snd-display #__line__ ";~A: sampler-at-end?: ~A" file fd))
		   (if (not (= (sampler-position fd) 10000)) 
		       (snd-display #__line__ ";~A: sampler: position: ~A ~A" fd (sampler-position file fd))))
		 (begin
		   (if (not (sampler-at-end? fd)) (snd-display #__line__ ";~A: not sampler-at-end?: ~A" file fd))
		   (if (= (sampler-position fd) 10000)
		       (snd-display #__line__ ";~A: sampler: position but samples: ~A ~A ~A" file fd (sampler-position fd) (frames index)))))
	     (if (not (equal? (sampler-home fd) (list index 0)))
		 (snd-display #__line__ ";~A: sampler: home: ~A ~A ~A" file fd (sampler-home fd) index))
	     (let ((fr0 (read-sample fd))
		   (fr1 (next-sample fd))
		   (fr2 (previous-sample fd)))
	       (if (fneq fr0 (sample 10000 index))
		   (snd-display #__line__ ";~A: sample reader 10000: ~A ~A" file fr0 (sample 10000 index)))
	       (if (fneq fr1 (sample 10001 index))
		   (snd-display #__line__ ";~A: sample reader 10001: ~A ~A" file fr1 (sample 10001 index)))
	       (if (fneq fr2 (sample 10001 index))
		   (snd-display #__line__ ";~A: sample reader 10001 prev: ~A ~A" file fr2 (sample 10001 index))))
	     (free-sampler fd))
	   (close-sound index)))
       (list "oboe.snd" "4.aiff" "2.snd" "2a.snd" "z.snd")) ; 2a=eof
      
      (let ((old-create (selection-creates-region)))
	(set! (selection-creates-region) #t)
	(for-each
	 (lambda (file)
	   (let ((index (open-sound file)))
	     (set! (selected-sound) index)
	     (set! (sync index) 1) ; select-all follows sync field
	     (let* ((reg (select-all))
		    (fd (make-region-frame-reader reg 10000)))
	       (if (not (frame-reader? fd)) (snd-display #__line__ ";~A: region frame-reader?: ~A" file fd))
	       (if (> (frames index) 10000)
		   (begin
		     (if (frame-reader-at-end? fd) (snd-display #__line__ ";~A: region frame-reader-at-end?: ~A" file fd))
		     (if (not (= (frame-reader-position fd) 10000)) 
			 (snd-display #__line__ ";~A: region frame-reader: position: ~A ~A" fd (frame-reader-position fd) file)))
		   (begin
		     (if (not (frame-reader-at-end? fd)) (snd-display #__line__ ";~A: not region frame-reader-at-end?: ~A" file fd))
		     (if (= (frame-reader-position fd) 10000)
			 (snd-display #__line__ ";~A: region frame-reader: position but frames: ~A ~A ~A" file fd (frame-reader-position fd) (frames index)))))
	       (if (not (equal? (frame-reader-home fd) reg)) 
		   (snd-display #__line__ ";~A: region frame-reader: home: ~A ~A ~A" file fd (frame-reader-home fd) reg))
	       (if (not (= (frame-reader-chans fd) (region-chans reg)))
		   (snd-display #__line__ ";region frame-reader-chans: ~A ~A" (frame-reader-chans fd) (region-chans reg)))
	       (let ((fr0 (frame-copy (read-frame fd)))
		     (fr1 (frame-copy (next-frame fd)))
		     (fr2 (frame-copy (previous-frame fd))))
		 (if (not (equal? fr0 (sound->frame 10000 index)))
		     (snd-display #__line__ ";~A: region frame reader 10000: ~A ~A" file fr0 (sound->frame 10000 index)))
		 (if (not (equal? fr1 (sound->frame 10001 index)))
		     (snd-display #__line__ ";~A: region frame reader 10001: ~A ~A" file fr1 (sound->frame 10001 index)))
		 (if (not (equal? fr2 (sound->frame 10001 index)))
		     (snd-display #__line__ ";~A: region frame reader 10001 prev: ~A ~A" file fr2 (sound->frame 10001 index))))
	       (free-frame-reader fd))
	     (close-sound index)))
	 (list "oboe.snd" "4.aiff" "2.snd" "2a.snd")) ; 2a=eof
	(set! (selection-creates-region) old-create))
      
      (let ((ind1 (open-sound "1a.snd"))
	    (data1 (file->vct "1a.snd"))
	    (ind2 (open-sound "2a.snd"))
	    (data2 (file->vct "2a.snd")))
	(if (not (equal? data1 (channel->vct 0 #f ind1 0)))
	    (snd-display #__line__ ";file->vct 1a.snd"))
	(if (not (equal? data2 (channel->vct 0 #f ind2 0)))
	    (snd-display #__line__ ";file->vct 2a.snd"))
	(vct->file data1 "tmp.snd")
	(let ((ind3 (open-sound "tmp.snd")))
	  (if (not (equal? data1 (channel->vct 0 #f ind3 0)))
	      (snd-display #__line__ ";vct->file 1a"))
	  (close-sound ind3))
	(mus-sound-forget "tmp.snd")
	(vct->file data2 "tmp.snd" 44100 "this is a comment")
	(let ((ind3 (open-sound "tmp.snd")))
	  (if (not (string=? (comment ind3) "this is a comment"))
	      (snd-display #__line__ ";vct->file comment: ~A" (comment ind3)))
	  (if (not (= (srate ind3) 44100))
	      (snd-display #__line__ ";vct->file srate: ~A" (srate ind3)))
	  (close-sound ind3))
	(mus-sound-forget "tmp.snd")
	(let ((tag (catch #t (lambda () (vct->file 32 "tmp.snd")) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";vct->file bad arg: ~A" tag)))
	
	(let ((sdata1 (file->sound-data "1a.snd"))
	      (sdata2 (file->sound-data "2a.snd")))
	  (if (not (equal? sdata1 (sound->sound-data 0 #f ind1)))
	      (snd-display #__line__ ";sfile->sound-data 1a.snd"))
	  (if (not (equal? sdata2 (sound->sound-data 0 #f ind2)))
	      (snd-display #__line__ ";file->sound-data 2a.snd"))
	  (sound-data->file sdata1 "tmp.snd")
	  (let ((ind3 (open-sound "tmp.snd")))
	    (if (not (equal? sdata1 (sound->sound-data 0 #f ind3)))
		(snd-display #__line__ ";sound-data->file 1a"))
	    (close-sound ind3))
	  (mus-sound-forget "tmp.snd")
	  (sound-data->file sdata2 "tmp.snd" 44100 "another comment")
	  (let ((ind3 (open-sound "tmp.snd")))
	    (if (not (string=? (comment ind3) "another comment"))
		(snd-display #__line__ ";sound-data->file comment: ~A" (comment ind3)))
	    (if (not (= (srate ind3) 44100))
		(snd-display #__line__ ";sound-data->file srate: ~A" (srate ind3)))
	    (close-sound ind3))
	  (mus-sound-forget "tmp.snd")
	  (let ((tag (catch #t (lambda () (sound-data->file 32 "tmp.snd")) (lambda args (car args)))))
	    (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";sound-data->file bad arg: ~A" tag))))
	(close-sound ind1)
	(close-sound ind2))
      
      (let ((old-create (selection-creates-region)))
	(set! (selection-creates-region) #t)
	(for-each
	 (lambda (file)
	   (let ((index (open-sound file)))
	     (set! (selected-sound) index)
	     (set! (sync index) 1) ; select-all follows sync field
	     (let* ((reg (select-all))
		    (reg-sd (region->sound-data reg))
		    (len (region-frames reg))
		    (reg-v (region->vct reg 0 len 0)))
	       (if (not (vequal reg-v (sound-data->vct reg-sd 0)))
		   (snd-display #__line__ ";region->sound-data ~A 0 differs" file))
	       (if (not (vequal reg-v (channel->vct 0 len index 0)))
		   (snd-display #__line__ ";region->sound-data ~A original 0 differs" file))
	       (if (> (chans index) 1)
		   (begin
		     (set! reg-v (region->vct reg 0 len 1 reg-v))
		     (if (not (vequal reg-v (sound-data->vct reg-sd 1)))
			 (snd-display #__line__ ";region->sound-data ~A 1 differs" file))
		     (if (not (vequal reg-v (channel->vct 0 len index 1)))
			 (snd-display #__line__ ";region->sound-data ~A original 1 differs" file)))))
	     (close-sound index)))
	 (list "oboe.snd" "1a.snd" "2a.snd"))
	(set! (selection-creates-region) old-create))
      
      (let ((total-chans 0)
	    (previous-syncs '()))
	(for-each
	 (lambda (file)
	   (let ((index (open-sound file)))
	     (set! (selected-sound) index)
	     (if (not (= (sync index) 0)) (snd-display #__line__ ";~A sync before sync-all: ~A" file (sync index)))
	     (sync-all)
	     (for-each
	      (lambda (snd)
		(if (not (sync snd))
		    (snd-display #__line__ ";sync-all did not set ~A's sync" file)
		    (if (member (sync index) previous-syncs)
			(snd-display #__line__ ";sync-all not new? ~A ~A" (sync index) previous-syncs))))
	      (sounds))
	     (let ((current-syncs (map sync (sounds))))
	       (if (and (> (length current-syncs) 1)
			(not (apply = current-syncs)))
		   (snd-display #__line__ ";sync-all not the same? ~A" current-syncs))
	       (set! previous-syncs (cons (sync index) previous-syncs)))
	     (set! total-chans (+ total-chans (chans index)))
	     (let* ((fd (make-sync-frame-reader 10000)))
	       (if (not (frame-reader? fd)) (snd-display #__line__ ";~A: sync frame-reader?: ~A" file fd))
	       (if (frame-reader-at-end? fd) (snd-display #__line__ ";~A: sync frame-reader-at-end?: ~A" file fd))
	       (if (not (= (frame-reader-position fd) 10000)) 
		   (snd-display #__line__ ";~A: sync frame-reader: position: ~A ~A" fd (frame-reader-position fd) file))
	       (if (not (equal? (frame-reader-home fd) index))
		   (snd-display #__line__ ";~A: sync frame-reader: home: ~A ~A ~A" file fd (frame-reader-home fd) index))
	       (if (not (= (frame-reader-chans fd) total-chans))
		   (snd-display #__line__ ";sync frame-reader-chans: ~A ~A" (frame-reader-chans fd) total-chans))
	       (let ((fr0 (frame-copy (read-frame fd)))
		     (fr1 (frame-copy (next-frame fd)))
		     (fr2 (frame-copy (previous-frame fd))))
		 (for-each
		  (lambda (snd)
		    (do ((i 0 (+ 1 i)))
			((= i (chans snd)))
		      (let ((val0 (sample 10000 snd i))
			    (val1 (sample 10001 snd i))
			    (got0 #f)
			    (got1 #f)
			    (got2 #f))
			(do ((j 0 (+ 1 j)))
			    ((or got0
				 (= j (mus-length fr0))))
			  (if (< (abs (- (frame-ref fr0 j) val0)) .001)
			      (begin
				(frame-set! fr0 j -100.0)
				(set! got0 #t))))
			(if (not got0) (snd-display #__line__ ";sync fr0 missed for ~A (~A) ~A" snd (short-file-name snd) i))
			(do ((j 0 (+ 1 j)))
			    ((or got1
				 (= j (mus-length fr1))))
			  (if (< (abs (- (frame-ref fr1 j) val1)) .001)
			      (begin
				(frame-set! fr1 j -100.0)
				(set! got1 #t))))
			(if (not got1) (snd-display #__line__ ";sync fr1 missed for ~A (~A) ~A" snd (short-file-name snd) i))
			(do ((j 0 (+ 1 j)))
			    ((or got2
				 (= j (mus-length fr2))))
			  (if (< (abs (- (frame-ref fr2 j) val1)) .001)
			      (begin
				(frame-set! fr2 j -100.0)
				(set! got2 #t))))
			(if (not got2) (snd-display #__line__ ";sync fr2 missed for ~A (~A) ~A" snd (short-file-name snd) i)))))
		  (sounds)))
	       (free-frame-reader fd))
	     (select-all)
	     
	     (let* ((fd (make-selection-frame-reader 10000)))
	       (if (not (frame-reader? fd)) (snd-display #__line__ ";~A: selection frame-reader?: ~A" file fd))
	       (if (frame-reader-at-end? fd) (snd-display #__line__ ";~A: selection frame-reader-at-end?: ~A" file fd))
	       (if (not (= (frame-reader-position fd) 10000)) 
		   (snd-display #__line__ ";~A: selection frame-reader: position: ~A ~A" fd (frame-reader-position fd) file))
	       (if (not (= (frame-reader-home fd) -1))
		   (snd-display #__line__ ";~A: selection frame-reader: home: ~A ~A ~A" file fd (frame-reader-home fd) index))
	       (if (not (= (frame-reader-chans fd) total-chans))
		   (snd-display #__line__ ";selection frame-reader-chans: ~A ~A" (frame-reader-chans fd) total-chans))
	       (let ((fr0 (frame-copy (read-frame fd)))
		     (fr1 (frame-copy (next-frame fd)))
		     (fr2 (frame-copy (previous-frame fd))))
		 (for-each
		  (lambda (snd)
		    (do ((i 0 (+ 1 i)))
			((= i (chans snd)))
		      (let ((val0 (sample 10000 snd i))
			    (val1 (sample 10001 snd i))
			    (got0 #f)
			    (got1 #f)
			    (got2 #f))
			(do ((j 0 (+ 1 j)))
			    ((or got0
				 (= j (mus-length fr0))))
			  (if (< (abs (- (frame-ref fr0 j) val0)) .001)
			      (begin
				(frame-set! fr0 j -100.0)
				(set! got0 #t))))
			(if (not got0) (snd-display #__line__ ";selection fr0 missed for ~A (~A) ~A" snd (short-file-name snd) i))
			(do ((j 0 (+ 1 j)))
			    ((or got1
				 (= j (mus-length fr1))))
			  (if (< (abs (- (frame-ref fr1 j) val1)) .001)
			      (begin
				(frame-set! fr1 j -100.0)
				(set! got1 #t))))
			(if (not got1) (snd-display #__line__ ";selection fr1 missed for ~A (~A) ~A" snd (short-file-name snd) i))
			(do ((j 0 (+ 1 j)))
			    ((or got2
				 (= j (mus-length fr2))))
			  (if (< (abs (- (frame-ref fr2 j) val1)) .001)
			      (begin
				(frame-set! fr2 j -100.0)
				(set! got2 #t))))
			(if (not got2) (snd-display #__line__ ";selection fr2 missed for ~A (~A) ~A" snd (short-file-name snd) i)))))
		  (sounds)))
	       (free-frame-reader fd))))
	 (list "oboe.snd" "4.aiff" "2.snd"))
	(map close-sound (sounds)))
      
      (let ((index0 (open-sound "oboe.snd"))
	    (index1 (open-sound "2.snd")))
	(sync-all)
	(make-selection 10000 (+ 10000 9))
	(if (not (selection?))
	    (snd-display #__line__ ";make-selection failed?")
	    (begin
	      (if (not (= (selection-frames) 10)) 
		  (snd-display #__line__ ";sync-all + make-selection length: ~A" (selection-frames)))
	      (if (not (= (selection-chans) 3))
		  (snd-display #__line__ ";sync-all + make-selection chans: ~A" (selection-chans)))
	      (let ((val0 (selection->sound-data)))
		(if (not (sound-data? val0))
		    (snd-display #__line__ ";selection->sound-data 0 result: ~A" val0)
		    (begin
		      (if (not (= (sound-data-chans val0) 3)) 
			  (snd-display #__line__ ";selection->sound-data 0 chans: ~A" (sound-data-chans val0)))
		      (if (not (= (sound-data-length val0) 10))
			  (snd-display #__line__ ";selection->sound-data 0 length: ~A" (sound-data-length val0)))
		      (let ((o0 (channel->vct 10000 10 index0))
			    (t0 (channel->vct 10000 10 index1 0))
			    (t1 (channel->vct 10000 10 index1 1))
			    (s0 (sound-data->vct val0 0))
			    (s1 (sound-data->vct val0 1))
			    (s2 (sound-data->vct val0 2)))
			(if (and (not (vequal o0 s0)) (not (vequal o0 s1)) (not (vequal o0 s2)))
			    (snd-display #__line__ ";selection->sound-data lost oboe: ~A ~A" o0 val0))
			(if (and (not (vequal t0 s0)) (not (vequal t0 s1)) (not (vequal t0 s2)))
			    (snd-display #__line__ ";selection->sound-data lost 2 0: ~A ~A" t0 val0))
			(if (and (not (vequal t1 s0)) (not (vequal t1 s1)) (not (vequal t1 s2)))
			    (snd-display #__line__ ";selection->sound-data lost 2 1: ~A ~A" t1 val0))))))
	      (let ((val1 (selection->sound-data 5)))
		(if (not (sound-data? val1))
		    (snd-display #__line__ ";selection->sound-data 1 result: ~A" val1)
		    (begin
		      (if (not (= (sound-data-chans val1) 3)) 
			  (snd-display #__line__ ";selection->sound-data 1 chans: ~A" (sound-data-chans val1)))
		      (if (not (= (sound-data-length val1) 5))
			  (snd-display #__line__ ";selection->sound-data 1 length: ~A" (sound-data-length val1)))
		      (let ((o0 (channel->vct 10005 5 index0))
			    (t0 (channel->vct 10005 5 index1 0))
			    (t1 (channel->vct 10005 5 index1 1))
			    (s0 (sound-data->vct val1 0))
			    (s1 (sound-data->vct val1 1))
			    (s2 (sound-data->vct val1 2)))
			(if (and (not (vequal o0 s0)) (not (vequal o0 s1)) (not (vequal o0 s2)))
			    (snd-display #__line__ ";selection->sound-data 1 lost oboe: ~A ~A" o0 val1))
			(if (and (not (vequal t0 s0)) (not (vequal t0 s1)) (not (vequal t0 s2)))
			    (snd-display #__line__ ";selection->sound-data 1 lost 2 0: ~A ~A" t0 val1))
			(if (and (not (vequal t1 s0)) (not (vequal t1 s1)) (not (vequal t1 s2)))
			    (snd-display #__line__ ";selection->sound-data 1 lost 2 1: ~A ~A" t1 val1))))))))
	(let ((val (scan-sound
		    (lambda (fr)
		      (if (not (= (mus-length fr) 3)) (snd-display #__line__ ";with-sync scan-sound chans: ~A" (mus-length fr)))
		      (and (> (frame-ref fr 0) .01) (> (frame-ref fr 1) .01) (> (frame-ref fr 2) .01)))
		    0 #f #f #t)))
	  (if (not (equal? val (list #t 960)))
	      (snd-display #__line__ ";scan-sound with-sync; ~A" val)))
	(close-sound index0)
	(close-sound index1))
      
      (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "insert-* tests" 10)))
	(map-channel (lambda (y) 1.0) 0 10 ind 0)
	(insert-vct (make-vct 5 .1) 2)
	(if (not (= (frames ind) 15)) (snd-display #__line__ ";insert-vct len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct 1 1 .1 .1 .1 .1 .1 1 1 1 1 1 1 1 1)))
	      (snd-display #__line__ ";insert-vct vals: ~A" vals))) 
	
	(let ((tag (catch #t (lambda () (insert-vct 32)) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";insert-vct bad arg: ~A" tag)))
	
	(insert-vct (make-vct 1 1.5) 0 1 ind 0)
	(if (not (= (frames ind) 16)) (snd-display #__line__ ";insert-vct 1 len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct 1.5 1 1 .1 .1 .1 .1 .1 1 1 1 1 1 1 1 1)))
	      (snd-display #__line__ ";insert-vct 1 vals: ~A" vals)))
	
	(let ((tag (catch #t (lambda () (insert-frame 32)) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";insert-frame bad arg: ~A" tag)))
	
	(insert-frame (make-frame 1 .3))
	(if (not (= (frames ind) 17)) (snd-display #__line__ ";insert-frame len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct .3 1.5 1 1 .1 .1 .1 .1 .1 1 1 1 1 1 1 1 1)))
	      (snd-display #__line__ ";insert-frame vals: ~A" vals)))
	
	(insert-frame (make-frame 1 .4) 20 ind)
	(if (not (= (frames ind) 21)) (snd-display #__line__ ";insert-frame 1 len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct .3 1.5 1 1 .1 .1 .1 .1 .1 1 1 1 1 1 1 1 1 0 0 0 .4)))
	      (snd-display #__line__ ";insert-frame 1 vals: ~A" vals)))
	
	(insert-frame (make-frame 1 .2) 10)
	(if (not (= (frames ind) 22)) (snd-display #__line__ ";insert-frame 2 len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct .3 1.5 1 1 .1 .1 .1 .1 .1 1 .2 1 1 1 1 1 1 1 0 0 0 .4)))
	      (snd-display #__line__ ";insert-frame 2 vals: ~A" vals)))
	
	(let ((tag (catch #t (lambda () (insert-sound-data 32)) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";insert-sound-data bad arg: ~A" tag)))
	
	(let ((sd (make-sound-data 1 3)))
	  (sound-data-set! sd 0 0 .23)
	  (sound-data-set! sd 0 1 .24)
	  (sound-data-set! sd 0 2 .25)
	  (insert-sound-data sd 10)
	  (if (not (= (frames ind) 25)) (snd-display #__line__ ";insert-sound-data len: ~A" (frames ind)))
	  (let ((vals (channel->vct 0 #f ind 0)))
	    (if (not (vequal vals (vct .3 1.5 1 1 .1 .1 .1 .1 .1 1 .23 .24 .25 .2 1 1 1 1 1 1 1 0 0 0 .4)))
		(snd-display #__line__ ";insert-sound-data vals: ~A" vals)))
	  
	  (insert-sound-data sd)
	  (if (not (= (frames ind) 28)) (snd-display #__line__ ";insert-sound-data 1 len: ~A" (frames ind)))
	  (let ((vals (channel->vct 0 #f ind 0)))
	    (if (not (vequal vals (vct .23 .24 .25 .3 1.5 1 1 .1 .1 .1 .1 .1 1 .23 .24 .25 .2 1 1 1 1 1 1 1 0 0 0 .4)))
		(snd-display #__line__ ";insert-sound-data 1 vals: ~A" vals)))
	  
	  (insert-sound-data sd 30 2 ind)
	  (if (not (= (frames ind) 32)) (snd-display #__line__ ";insert-sound-data 2 len: ~A" (frames ind)))
	  (let ((vals (channel->vct 0 #f ind 0)))
	    (if (not (vequal vals (vct .23 .24 .25 .3 1.5 1 1 .1 .1 .1 .1 .1 1 .23 .24 .25 .2 1 1 1 1 1 1 1 0 0 0 .4 0 0 .23 .24)))
		(snd-display #__line__ ";insert-sound-data 2 vals: ~A" vals))))
	(close-sound ind))
      
      (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 4 "insert-* tests" 5)))
	(map-channel (lambda (y) 0.4) 0 5 ind 0)
	(map-channel (lambda (y) 0.5) 0 5 ind 1)
	(map-channel (lambda (y) 0.6) 0 5 ind 2)
	(map-channel (lambda (y) 0.7) 0 5 ind 3)
	
	(insert-vct (make-vct 20 .1) 2 2 ind 2)
	(if (not (= (frames ind 0) 5)) (snd-display #__line__ ";4chn insert-vct (0) len: ~A" (frames ind 0)))
	(if (not (= (frames ind 2) 7)) (snd-display #__line__ ";4chn insert-vct (2) len: ~A" (frames ind 2)))
	(if (not (vequal (channel->vct 0 7 ind 0) (vct .4 .4 .4 .4 .4 0 0)))
	    (snd-display #__line__ ";4chn insert-vct 0: ~A" (channel->vct 0 7 ind 0)))
	(if (not (vequal (channel->vct 0 7 ind 1) (vct .5 .5 .5 .5 .5 0 0)))
	    (snd-display #__line__ ";4chn insert-vct 1: ~A" (channel->vct 0 7 ind 1)))
	(if (not (vequal (channel->vct 0 7 ind 2) (vct .6 .6 .1 .1 .6 .6 .6)))
	    (snd-display #__line__ ";4chn insert-vct 2: ~A" (channel->vct 0 7 ind 2)))
	(if (not (vequal (channel->vct 0 7 ind 3) (vct .7 .7 .7 .7 .7 0 0)))
	    (snd-display #__line__ ";4chn insert-vct 3: ~A" (channel->vct 0 7 ind 3)))
	
	(insert-vct (make-vct 20 .2) 0 2 ind 0)
	(if (not (= (frames ind 0) 7)) (snd-display #__line__ ";4chn insert-vct (0 0) len: ~A" (frames ind 0)))
	(if (not (= (frames ind 1) 5)) (snd-display #__line__ ";4chn insert-vct (0 1) len: ~A" (frames ind 1)))
	(if (not (= (frames ind 2) 7)) (snd-display #__line__ ";4chn insert-vct (2 2) len: ~A" (frames ind 2)))
	(if (not (vequal (channel->vct 0 7 ind 0) (vct .2 .2 .4 .4 .4 .4 .4)))
	    (snd-display #__line__ ";4chn insert-vct 1 0: ~A" (channel->vct 0 7 ind 0)))
	(if (not (vequal (channel->vct 0 7 ind 1) (vct .5 .5 .5 .5 .5 0 0)))
	    (snd-display #__line__ ";4chn insert-vct 1 1: ~A" (channel->vct 0 7 ind 1)))
	(if (not (vequal (channel->vct 0 7 ind 2) (vct .6 .6 .1 .1 .6 .6 .6)))
	    (snd-display #__line__ ";4chn insert-vct 1 2: ~A" (channel->vct 0 7 ind 2)))
	(if (not (vequal (channel->vct 0 7 ind 3) (vct .7 .7 .7 .7 .7 0 0)))
	    (snd-display #__line__ ";4chn insert-vct 1 3: ~A" (channel->vct 0 7 ind 3)))
	
	(insert-frame (make-frame 4 1.5 1.6 1.7 1.8))
	(if (not (= (frames ind 0) 8)) (snd-display #__line__ ";4chn insert-frame (0) len: ~A" (frames ind 0)))
	(if (not (= (frames ind 1) 6)) (snd-display #__line__ ";4chn insert-frame (1) len: ~A" (frames ind 1)))
	(if (not (= (frames ind 2) 8)) (snd-display #__line__ ";4chn insert-frame (2) len: ~A" (frames ind 2)))
	(if (not (vequal (channel->vct 0 8 ind 0) (vct 1.5 .2 .2 .4 .4 .4 .4 .4)))
	    (snd-display #__line__ ";4chn insert-frame 0: ~A" (channel->vct 0 8 ind 0)))
	(if (not (vequal (channel->vct 0 8 ind 1) (vct 1.6 .5 .5 .5 .5 .5 0 0)))
	    (snd-display #__line__ ";4chn insert-frame 1: ~A" (channel->vct 0 8 ind 1)))
	(if (not (vequal (channel->vct 0 8 ind 2) (vct 1.7 .6 .6 .1 .1 .6 .6 .6)))
	    (snd-display #__line__ ";4chn insert-frame 2: ~A" (channel->vct 0 8 ind 2)))
	(if (not (vequal (channel->vct 0 8 ind 3) (vct 1.8 .7 .7 .7 .7 .7 0 0)))
	    (snd-display #__line__ ";4chn insert-frame 3: ~A" (channel->vct 0 8 ind 3)))
	
	(insert-frame (make-frame 4 1.5 1.6 1.7 1.8) 10 ind)
	(if (not (= (frames ind 0) 11)) (snd-display #__line__ ";4chn insert-frame (0 0) len: ~A" (frames ind 0)))
	(if (not (= (frames ind 1) 11)) (snd-display #__line__ ";4chn insert-frame (0 1) len: ~A" (frames ind 1)))
	(if (not (= (frames ind 2) 11)) (snd-display #__line__ ";4chn insert-frame (0 2) len: ~A" (frames ind 2)))
	(if (not (vequal (channel->vct 0 11 ind 0) (vct 1.5 .2 .2 .4 .4 .4 .4 .4 0 0 1.5)))
	    (snd-display #__line__ ";4chn insert-frame 0 0: ~A" (channel->vct 0 11 ind 0)))
	(if (not (vequal (channel->vct 0 11 ind 1) (vct 1.6 .5 .5 .5 .5 .5 0 0 0 0 1.6)))
	    (snd-display #__line__ ";4chn insert-frame 0 1: ~A" (channel->vct 0 11 ind 1)))
	(if (not (vequal (channel->vct 0 11 ind 2) (vct 1.7 .6 .6 .1 .1 .6 .6 .6 0 0 1.7)))
	    (snd-display #__line__ ";4chn insert-frame 0 2: ~A" (channel->vct 0 11 ind 2)))
	(if (not (vequal (channel->vct 0 11 ind 3) (vct 1.8 .7 .7 .7 .7 .7 0 0 0 0 1.8)))
	    (snd-display #__line__ ";4chn insert-frame 0 3: ~A" (channel->vct 0 11 ind 3)))
	
	(revert-sound ind)
	(map-channel (lambda (y) 0.4) 0 5 ind 0)
	(map-channel (lambda (y) 0.5) 0 5 ind 1)
	(map-channel (lambda (y) 0.6) 0 5 ind 2)
	(map-channel (lambda (y) 0.7) 0 5 ind 3)
	
	(let ((sd (make-sound-data 4 10)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd chn i (+ i (* chn 10)))))
	  (insert-sound-data sd 1 2)
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (if (not (= (frames ind chn) 7)) (snd-display #__line__ ";4chn ~A insert-sound-data len: ~A" chn (frames ind chn)))
	    (let ((vals (channel->vct 0 #f ind chn))
		  (base-val (list-ref (list .4 .5 .6 .7) chn)))
	      (if (not (vequal vals (vct base-val 
					 (+ 0 (* chn 10)) (+ 1 (* chn 10)) ; insert starts at 0 in sd
					 base-val base-val base-val base-val)))
		  (snd-display #__line__ ";4chn ~A insert-sound-data vals: ~A" chn vals)))))
	(close-sound ind))
      
      (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "mix-frame tests" 5)))
	(map-channel (lambda (y) 1.0) 0 5 ind 0)
	
	(let ((tag (catch #t (lambda () (mix-frame 32)) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";mix-frame bad arg: ~A" tag)))
	
	(mix-frame (make-frame 1 .3))
	(if (not (= (frames ind) 5)) (snd-display #__line__ ";mix-frame len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct 1.3 1 1 1 1)))
	      (snd-display #__line__ ";mix-frame vals: ~A" vals)))
	
	(mix-frame (make-frame 1 .4) 8 ind)
	(if (not (= (frames ind) 9)) (snd-display #__line__ ";mix-frame 1 len: ~A" (frames ind)))
	(let ((vals (channel->vct 0 #f ind 0)))
	  (if (not (vequal vals (vct 1.3 1 1 1 1 0 0 0 .4)))
	      (snd-display #__line__ ";mix-frame 1 vals: ~A" vals)))
	
	(let ((tag (catch #t (lambda () (mix-sound-data 32)) (lambda args (car args)))))
	  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";mix-sound-data bad arg: ~A" tag)))
	
	(let ((sd (make-sound-data 1 3)))
	  (sound-data-set! sd 0 0 .23)
	  (sound-data-set! sd 0 1 .24)
	  (sound-data-set! sd 0 2 .25)
	  (mix-sound-data sd)
	  (if (not (= (frames ind) 9)) (snd-display #__line__ ";mix-sound-data len: ~A" (frames ind)))
	  (let ((vals (channel->vct 0 #f ind 0)))
	    (if (not (vequal vals (vct 1.53 1.24 1.25 1 1 0 0 0 .4)))
		(snd-display #__line__ ";mix-sound-data vals: ~A" vals)))
	  
	  (mix-sound-data sd 7 3)
	  (if (not (= (frames ind) 10)) (snd-display #__line__ ";mix-sound-data 1 len: ~A" (frames ind)))
	  (let ((vals (channel->vct 0 #f ind 0)))
	    (if (not (vequal vals (vct 1.53 1.24 1.25 1 1 0 0 .23 .64 .25)))
		(snd-display #__line__ ";mix-sound-data 1 vals: ~A" vals)))
	  
	  (let ((mix-id (mix-sound-data sd 0 #f ind #t)))
	    (if (not (= (frames ind) 10)) (snd-display #__line__ ";mix-sound-data 2 len: ~A" (frames ind)))
	    (let ((vals (channel->vct 0 #f ind 0)))
	      (if (not (vequal vals (vct (+ .23 1.53) (+ .24 1.24) (+ .25 1.25) 1 1 0 0 .23 .64 .25)))
		  (snd-display #__line__ ";mix-sound-data 2 vals: ~A" vals)))
	    (if (not (mix? mix-id)) (snd-display #__line__ ";mix-sound-data tagged: ~A" mix-id)))
	  
	  )
	(close-sound ind))
      
      (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 4 "mix-* tests" 5)))
	(map-channel (lambda (y) 0.4) 0 5 ind 0)
	(map-channel (lambda (y) 0.5) 0 5 ind 1)
	(map-channel (lambda (y) 0.6) 0 5 ind 2)
	(map-channel (lambda (y) 0.7) 0 5 ind 3)
	
	(mix-frame (make-frame 4 1 2 3 4))
	(if (not (vequal (channel->vct 0 #f ind 0) (vct 1.4 .4 .4 .4 .4)))
	    (snd-display #__line__ ";4chn mix-frame 0: ~A" (channel->vct 0 #f ind 0)))
	(if (not (vequal (channel->vct 0 #f ind 1) (vct 2.5 .5 .5 .5 .5)))
	    (snd-display #__line__ ";4chn mix-frame 1: ~A" (channel->vct 0 #f ind 1)))
	(if (not (vequal (channel->vct 0 #f ind 2) (vct 3.6 .6 .6 .6 .6)))
	    (snd-display #__line__ ";4chn mix-frame 2: ~A" (channel->vct 0 #f ind 2)))
	(if (not (vequal (channel->vct 0 #f ind 3) (vct 4.7 .7 .7 .7 .7)))
	    (snd-display #__line__ ";4chn mix-frame 3: ~A" (channel->vct 0 #f ind 3)))
	
	(mix-frame (make-frame 4 1 2 3 4) 8)
	
	(if (not (vequal (channel->vct 0 #f ind 0) (vct 1.4 .4 .4 .4 .4 0 0 0 1)))
	    (snd-display #__line__ ";4chn mix-frame 0 0: ~A" (channel->vct 0 #f ind 0)))
	(if (not (vequal (channel->vct 0 #f ind 1) (vct 2.5 .5 .5 .5 .5 0 0 0 2)))
	    (snd-display #__line__ ";4chn mix-frame 0 1: ~A" (channel->vct 0 #f ind 1)))
	(if (not (vequal (channel->vct 0 #f ind 2) (vct 3.6 .6 .6 .6 .6 0 0 0 3)))
	    (snd-display #__line__ ";4chn mix-frame 0 2: ~A" (channel->vct 0 #f ind 2)))
	(if (not (vequal (channel->vct 0 #f ind 3) (vct 4.7 .7 .7 .7 .7 0 0 0 4)))
	    (snd-display #__line__ ";4chn mix-frame 0 3: ~A" (channel->vct 0 #f ind 3)))
	
	(revert-sound ind)
	(map-channel (lambda (y) 0.4) 0 5 ind 0)
	(map-channel (lambda (y) 0.5) 0 5 ind 1)
	(map-channel (lambda (y) 0.6) 0 5 ind 2)
	(map-channel (lambda (y) 0.7) 0 5 ind 3)
	
	(let ((sd (make-sound-data 4 10)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd chn i (+ i (* chn 10)))))
	  (mix-sound-data sd 1 2)
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (let ((vals (channel->vct 0 #f ind chn))
		  (base-val (list-ref (list .4 .5 .6 .7) chn)))
	      (if (not (vequal vals (vct base-val 
					 (+ base-val (* chn 10)) (+ 1 base-val (* chn 10))
					 base-val base-val)))
		  (snd-display #__line__ ";4chn ~A mix-sound-data vals: ~A" chn vals))))
	  
	  (let ((mix-id (mix-sound-data sd 8 2 ind #t)))
	    (if (not (mix? mix-id)) (snd-display #__line__ ";4chn mix-sound-data 2nd mix: ~A" mix-id))
	    (if (not (mix? (integer->mix (+ 1 (mix->integer mix-id))))) (snd-display #__line__ ";4chn mix-sound-data 2nd mix 1: ~A" mix-id))
	    (do ((chn 0 (+ 1 chn)))
		((= chn 4))
	      (let ((vals (channel->vct 0 #f ind chn))
		    (base-val (list-ref (list .4 .5 .6 .7) chn)))
		(if (not (vequal vals (vct base-val 
					   (+ base-val (* chn 10)) (+ 1 base-val (* chn 10))
					   base-val base-val 0 0 0
					   (+ 0 (* chn 10)) (+ 1 (* chn 10)))))
		    (snd-display #__line__ ";4chn ~A mix-sound-data 8 vals: ~A" chn vals))))))
	
	(close-sound ind))
      
      (mus-sound-forget "oboe.snd")
      (let ((ind (open-sound "oboe.snd"))
	    (len 0))
	(let ((val (scan-sound 
		    (lambda (fr)
		      (set! len (mus-length fr))
		      (> (frame-ref fr 0) .1)))))
	  (if (not (equal? val (list #t 4423)))
	      (snd-display #__line__ ";scan-sound oboe: ~A" val))
	  (if (not (= len 1)) (snd-display #__line__ ";scan-sound frame len: ~A" len)))
	
	(set! len 0)
	(let ((mx (maxamp)))
	  (map-sound
	   (lambda (fr)
	     (set! len (mus-length fr))
	     (frame* fr 2.0)))
	  (if (fneq (maxamp) (* 2 mx)) (snd-display #__line__ ";map-sound max: ~A ~A" mx (maxamp)))
	  (if (not (= (edit-position ind 0) 1)) (snd-display #__line__ ";map-sound edpos: ~A" (edit-position ind 0)))
	  (if (not (= len 1)) (snd-display #__line__ ";map-sound frame len: ~A" len)))
	(close-sound ind))
      
      (mus-sound-forget "4.aiff")
      (let ((ind (open-sound "4.aiff"))
	    (len 0))
	(if (not (= (chans ind) 4)) (snd-display #__line__ ";chans 4.aiff: ~A" (chans ind)))
	(let ((val (scan-sound 
		    (lambda (fr)
		      (set! len (mus-length fr))
		      (> (frame-ref fr 3) .1)))))
	  (if (not (equal? val (list #t 21244)))
	      (snd-display #__line__ ";4 scan-sound: ~A" val))
	  (if (not (= len 4)) (snd-display #__line__ ";4 scan-sound frame len: ~A" len)))
	
	(set! len 0)
	(let ((mx (maxamp ind #t)))
	  (map-sound
	   (lambda (fr)
	     (set! len (mus-length fr))
	     (frame* fr 2.0))
	   800000 #f ind)
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (if (fneq (maxamp ind chn) (* 2 (list-ref mx chn)))
		(snd-display #__line__ ";4:~D map-sound max: ~A ~A" chn mx (maxamp ind chn)))
	    (if (not (= (edit-position ind chn) 1)) 
		(snd-display #__line__ ";4:~D map-sound edpos: ~A" chn (edit-position ind chn))))
	  (if (not (= len 4)) (snd-display #__line__ ";4 map-sound frame len: ~A" len)))
	(close-sound ind))
      
      (let ((sd (make-sound-data 4 10)))
	(do ((chn 0 (+ 1 chn)))
	    ((= chn 4))
	  (do ((i 0 (+ 1 i)))
	      ((= i 10))
	    (sound-data-set! sd chn i (+ i (* chn 10)))))
	(let ((sd1 (sound-data-copy sd)))
	  (if (not (equal? sd sd1))
	      (snd-display #__line__ ";sound-data-copy not equal? ~A ~A" sd sd1))
	  (sound-data-scale! sd1 2.0)
	  (let ((sd2 (make-sound-data 4 10)))
	    (do ((chn 0 (+ 1 chn)))
		((= chn 4))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(sound-data-set! sd2 chn i (* 2 (+ i (* chn 10))))))
	    (if (not (equal? sd2 sd1)) (snd-display #__line__ ";sound-data-scale! not equal? ~%    ~A~%    ~A" sd1 sd2))
	    (if (equal? sd2 sd) (snd-display #__line__ ";sound-data-scale! crosstalk??")))
	  (sound-data-multiply! sd sd)
	  (let ((sd2 (make-sound-data 4 10)))
	    (do ((chn 0 (+ 1 chn)))
		((= chn 4))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(sound-data-set! sd2 chn i (* (+ i (* chn 10)) (+ i (* chn 10))))))
	    (if (not (equal? sd2 sd)) (snd-display #__line__ ";sound-data-multiply! not equal? ~%    ~A~%     ~A" sd sd2)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd chn i (+ i (* chn 10)))))
	  (sound-data-offset! sd 1.0)
	  (let ((sd2 (make-sound-data 4 10)))
	    (do ((chn 0 (+ 1 chn)))
		((= chn 4))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(sound-data-set! sd2 chn i (+ 1 i (* chn 10)))))
	    (if (not (equal? sd2 sd)) (snd-display #__line__ ";sound-data-offset! not equal? ~%    ~A~%     ~A" sd sd2)))
	  (let ((sd3 (sound-data-reverse! (sound-data-copy sd))))
	    (let ((sd2 (make-sound-data 4 10)))
	      (do ((chn 0 (+ 1 chn)))
		  ((= chn 4))
		(do ((i 0 (+ 1 i)))
		    ((= i 10))
		  (sound-data-set! sd2 chn i (+ 1 (- 9 i) (* chn 10)))))
	      (if (not (equal? sd2 sd3)) (snd-display #__line__ ";sound-data-reverse! not equal? ~%    ~A~%     ~A" sd3 sd2)))
	    (sound-data-add! sd sd3)
	    (do ((chn 0 (+ 1 chn)))
		((= chn 4))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(sound-data-set! sd1 chn i (+ 1 10 (* chn 20)))))
	    (if (not (equal? sd1 sd)) (snd-display #__line__ ";sound-data-add! not equal? ~%    ~A~%     ~A" sd sd1)))
	  
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd chn i (+ i (* chn 10)))
	      (sound-data-set! sd1 chn i 1)))
	  (let ((sd2 (sound-data-copy sd)))
	    (sound-data+ sd 1)
	    (sound-data-add! sd2 sd1)
	    (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data+ sd 1: ~%    ~A~%    ~A" sd sd2))
	    (sound-data+ 1 sd)
	    (sound-data-add! sd2 sd1)
	    (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data+ 1 sd: ~%    ~A~%    ~A" sd sd2))
	    (sound-data+ sd sd1)
	    (sound-data-add! sd2 sd1)
	    (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data+ sd sd: ~%    ~A~%    ~A" sd sd2)))
	  
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd chn i (+ i (* chn 10)))
	      (sound-data-set! sd1 chn i 2)))
	  (let ((sd2 (sound-data-copy sd)))
	    (if (fneq (sound-data-peak sd) (apply max (sound-data-maxamp sd)))
		(snd-display #__line__ ";sound-data-peak: ~A ~A" (sound-data-peak sd) (apply max (sound-data-maxamp sd))))
	    (sound-data* sd 2)
	    (sound-data-multiply! sd2 sd1)
	    (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data* sd 1: ~%    ~A~%    ~A" sd sd2))
	    (sound-data* 2 sd)
	    (sound-data-multiply! sd2 sd1)
	    (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data* 1 sd: ~%    ~A~%    ~A" sd sd2))
	    (sound-data* sd sd1)
	    (sound-data-add! sd2 sd2)
	    (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data* sd sd: ~%    ~A~%    ~A" sd sd2)))))
      
      ;; tests from clean.scm
      (test-remove-single-clicks)
      (test-remove-pops)
      (test-notch-hum)
      (test-remove-DC)
      
      ;; check 0 cases
      (let ((ind (open-sound "oboe.snd")))
	(scale-by 0.0)
	(if (fneq (maxamp) 0.0) (snd-display #__line__ ";scale-by 0 amp: ~A" (maxamp)))
	(scale-by 3.0)
	(if (not (= (edit-position) 1)) (snd-display #__line__ ";scale-by over 0: ~A" (edit-position)))
	(scale-to 1.0)
	(if (not (= (edit-position) 1)) (snd-display #__line__ ";scale-to 1.0 over 0: ~A" (edit-position)))
	(if (fneq (maxamp) 0.0) (snd-display #__line__ ";scale-to 1.0 over 0 amp: ~A" (maxamp)))  
	(ramp-channel 0 1)
	(if (not (= (edit-position) 1)) (snd-display #__line__ ";ramp over 0: ~A" (edit-position)))  
	(env-channel '(0 0 1 1 2 0))
	(if (not (= (edit-position) 1)) (snd-display #__line__ ";ramp over 0: ~A" (edit-position)))  
	(if (not (string=? (car (edit-fragment 1)) "scale-channel 0.000 0 #f"))
	    (snd-display #__line__ ";ramp over 0 clobbered origin: ~A" (edit-fragment 1)))
	(xramp-channel 0 1 32.0)
	(if (not (= (edit-position) 1)) (snd-display #__line__ ";ramp over 0: ~A" (edit-position)))  
	(env-channel-with-base '(0 0 1 1 2 0 3 1) 0.0)  
	(if (not (= (edit-position) 1)) (snd-display #__line__ ";ramp over 0: ~A" (edit-position)))
	(close-sound ind))
      
      ;; snddiff.scm
      (let ((ind0 (open-sound "oboe.snd"))
	    (ind1 (open-sound "oboe.snd")))
	(let ((diff (snddiff ind0 0 ind1 0)))
	  (if (not (equal? diff 'no-difference))
	      (snd-display #__line__ ";snddiff of same sound: ~A" diff)))
	(scale-channel 2.0 0 #f ind1)
	(let ((diff (snddiff ind0 0 ind1 0)))
	  (if (or (not (eq? (car diff) 'scale))
		  (fneq (cadr diff) 2.0))
	      (snd-display #__line__ ";snddiff scale by 2: ~A" diff)))
	(revert-sound ind1)
	(set! (sample 100 ind0 0) 1.0)
	(let* ((diff (snddiff ind0 0 ind1 0))
	       (info (and diff (list? diff) (= (length diff) 2) (= (length (car (cadr diff))) 3) (car (cadr diff)))))
	  (if (or (not (eq? (car diff) 'differences))
		  (not info)
		  (not (= (car info) 100))
		  (fneq (cadr info) 1.0)
		  (fneq (caddr info) -3.051e-4))
	      (snd-display #__line__ ";snddiff change sample 100: ~A" diff)))
	(revert-sound ind0)
	(pad-channel 0 100 ind0 0)
	(let ((diff (snddiff ind0 0 ind1 0)))
	  (if (or (not (eq? (list-ref diff 0) 'lag))
		  (not (= (list-ref diff 1) 100))
		  (not (eq? (list-ref diff 2) 'no-difference))
		  (fneq (list-ref diff 3) 0.0)
		  (not (eq? (list-ref diff 4) #f))
		  (not (eq? (list-ref diff 5) #f))
		  (not (eq? (list-ref diff 6) #f)))
	      (snd-display #__line__ ";snddiff + lag: ~A" diff)))
	(revert-sound ind0)
	(filter-channel (vct 1.0 0.5 0.25) 3 0 #f ind1 0)
	(let* ((diff (snddiff ind0 0 ind1 0))
	       (info (and (cadr diff) (= (length (cadr diff)) 3) (cadr diff))))
	  (if (or (not (list? info))
		  (not (list? diff))
		  (not (eq? (car diff) 'filter))
		  (fneq (car (car info)) 1.0)
		  (fneq (car (cadr info)) 0.5)
		  (fneq (car (caddr info)) 0.25)
		  (not (= (cadr (car info)) 0))
		  (not (= (cadr (cadr info)) 1))
		  (not (= (cadr (caddr info)) 1)))
	      (snd-display #__line__ ";snddiff filter: ~A" diff)))
	(revert-sound ind1)
	
	(close-sound ind0)
	(close-sound ind1))
      
      (let ((ind (open-sound "oboe.snd")))
	(let ((g550 (goertzel-channel 550.0))
	      (g1700 (goertzel-channel 1700.0)))
	  (if (> (* 1000 g1700) g550) (snd-display #__line__ ";goertzel-channel oboe: ~A ~A" g550 g1700))
	  (close-sound ind)))
      
      )))


;;; ---------------- test 22: run ----------------

(defmacro fxtst (form result)
  `(let ((val ,form))
     (if (fneq val ,result) 
	 (snd-display #__line__ ";~A -> ~A (~A)" ',form val ,result))))

(defmacro ixtst (form result)
  `(let ((val ,form))
     (if (not (= val ,result))
	 (snd-display #__line__ ";~A -> ~A (~A)" ',form val ,result))))

(defmacro bxtst (form result)
  `(let ((val ,form))
     (if (not (eq? val ,result))
	 (snd-display #__line__ ";~A -> ~A (~A)" ',form val ,result))))

(defmacro time-it (a) 
  `(let ((start (real-time))) 
     ,a 
     (- (real-time) start)))

(define unique-float 3.0)
(define unique-int 3)
(define unique-char #\c)
(define unique-string "hiho")
(define unique-float-vector (make-vector 3 1.0))
(define unique-int-vector (make-vector 3 1))
(define unique-generator (make-oscil))
(define unique-list (list 1 (make-oscil)))
(define unique-symbol 'hiho)
(define unique-keyword :hiho)
(define unique-clm-vector (make-vector 3 #f))
(define unique-boolean #t)
(define unique-vct-vector (make-vector 3 #f))
(define int-var 32)
(define dbl-var 3.14)
(define bool-var #t)
(define lst-var '(0 1 2))
(define biggie (expt 2 31))
(define str-var "hi")
(define cont1 #f)
(define cont2 #f)
(define gv 1)
(define global-v (make-vct 3 1.0))
(define global-v1 (make-vct 3 1.0))
(define c-var #\a)
(define list-var (list 2 3 4 5))
(define l0111 (list 0 1 1 1))
(define v-var (make-vct 8))
(define ivect (make-vector 3 1))

(define lfunc
  (let ((ho 3))
    (lambda ()
      ho)))

(def-clm-struct st3 one two)
(define svar (make-st3 :one 1.0 :two 2.0))
(define svar1 #f)
(define bst3 #f)
(def-clm-struct st4 (one 1) (two 2.0))
(define bst4 #f)
(def-clm-struct hiho1 i x (s "hiho") (ii 3 :type int) (xx 1.0 :type float))
(def-clm-struct hiho2 (i 0 :type int) (x 0.0 :type float) (v #f :type vct) (s "hiho") (ii 3 :type int) (xx 1.0 :type float))
(define g-gen (make-oscil 440))

(define clm_vector (make-vector 2))
(define vct_vector (make-vector 2))

(define hi1 (make-hiho1))
(define hif2 (make-hiho1 :xx 3.14))
(define hi2 (make-hiho2 :v (make-vct 3 .1)))


(define (efunc-1 arg) (+ arg 1))
(define (efunc-2 arg) (not arg))
(define (efunc-3 arg1 arg2 arg3) (if arg1 (+ arg2 arg3) 0))
(define (efunc-4 arg) (string-append arg "!"))
(define (efunc-5 arg) (+ 1 (string-length arg)))
(define (efunc-6 arg) (oscil arg))
(define efunc-gen (make-oscil 440.0))
(define (efunc-7 arg) arg)

(def-clm-struct hi308 freq phase)

(define (call-hi308 hi308-gen)
  (declare (hi308-gen hi308))
  (hi308-freq hi308-gen))

(define (set-hi308 hi308-gen)
  (declare (hi308-gen hi308))
  (set! (hi308-freq hi308-gen) (* 3.5 (hi308-freq hi308-gen))))

(def-clm-struct hiho309 (i 0 :type int) (x 0.0 :type float) (v #f :type vct))

(def-clm-struct hiho310 (v #f :type string))

(def-clm-struct hiho311 (v #f :type sound-data))

(def-clm-struct abc232 (x 0.0))
(def-clm-struct abd232 (x 1.0))

(define (abc232-func gen)
  (declare (gen abc232))
  (abc232-x gen))

(define (abd232-func gen)
  (declare (gen abd232))
  (abd232-x gen))



(define (snd_test_22)
  
  (define (test-run-protection-release)
    (let ((this-oscil-protected-by-run (make-oscil 1234.567))
	  (this-window-protected-by-run (make-fft-window rectangular-window 16)))
      (* (vct-ref this-window-protected-by-run 8) 
	 (oscil this-oscil-protected-by-run))))
  
  (define (make-osc frq)
    (run
     (make-oscil frq)))
  
  (define (make-fc scl size)
    (run 
     (make-filtered-comb scl size :filter (make-one-zero .4 .6))))
  
  (definstrument (test-set-gens)
    (let ((cs (make-ncos 440.0 5))
	  (ss (make-nsin 440.0 5))
	  (sq (make-square-wave 44.0))
	  (en (make-env '(0 0 1 1) :base .3 :length 11))
	  (fl (make-fir-filter 4 (vct .5 .5 .5 .5)))
	  (dl (make-delay 32))
	  (ap (make-all-pass .4 .6 32))
	  (av (make-moving-average 4))
	  (sr (make-src :srate .5))
	  (gr (make-granulate :expansion 2.0))
	  (sb (make-ssb-am 440.0))
	  )
      (run
       (set! (mus-length cs) 3)
       (if (not (= (mus-length cs) 3)) (display ";cosines messed up"))
       (set! (mus-length cs) 32)
       (if (not (= (mus-length cs) 32)) (display ";length messed up"))
       (set! (mus-frequency cs) 100.0)
       (if (fneq (mus-frequency cs) 100.0) (display ";frequency messed up"))
       (set! (mus-phase cs) 2.0)
       (if (fneq (mus-phase cs) 2.0) (display ";phase messed up"))
       (set! (mus-scaler cs) .5)
       (if (fneq (mus-scaler cs) .5) (display ";scaler messed up"))
       (set! (mus-width sq) .123)
       (if (fneq (mus-width sq) .123) (display ";width messed up"))
       (set! (mus-location en) 3)
       (if (not (= (mus-location en) 3)) (display ";location messed up"))
       (set! (mus-length dl) 24)
       (if (not (= (mus-length dl) 24)) (display ";dl length messed up"))
       (set! (mus-feedback ap) .5)
       (if (fneq (mus-feedback ap) .5) (display ";feedback messed up"))
       (set! (mus-feedforward ap) .5)
       (if (fneq (mus-feedforward ap) .5) (display ";feedforward messed up"))
       (set! (mus-increment sr) .3)
       (if (fneq (mus-increment sr) .3) (display ";sr increment messed up"))
       (set! (mus-frequency gr) .05)
       (if (fneq (mus-frequency gr) .05) (display ";gr frequency messed up"))
       (set! (mus-scaler gr) .05)
       (if (fneq (mus-scaler gr) .05) (display ";gr scaler messed up"))
       (set! (mus-increment gr) .5)
       (if (fneq (mus-increment gr) .5) (display ";gr increment messed up"))
       (set! (mus-ramp gr) 1234)
       (if (not (= (mus-ramp gr) 1234)) (display ";gr ramp messed up"))
       (set! (mus-hop gr) 1234)
       (if (not (= (mus-hop gr) 1234)) (display ";gr hop messed up"))
       (set! (mus-length gr) 1234)
       (if (not (= (mus-length gr) 1234)) (display ";gr length messed up"))
       (if (fneq (mus-frequency sb) 440.0) (display ";sb freq?"))
       (set! (mus-frequency sb) 220.0)
       (if (fneq (mus-frequency sb) 220.0) (display ";sb freq messed up"))
       )))
  
  (define (make-linear-src sr)
    (vct 0.0 sr 0.0 0.0)) ; position sr last next
  
  (define (linear-src gen input)
    (let ((pos (vct-ref gen 0)))
      (if (>= pos 1.0)
	  (begin
	    (if (< pos 2.0)
		(begin
		  (vct-set! gen 2 (vct-ref gen 3))
		  (vct-set! gen 3 (input))
		  (set! pos (- 1.0 (vct-ref gen 0))))
		(let ((num (floor pos)))
		  (do ((i 0 (+ 1 i)))
		      ((= i num))
		    (vct-set! gen 2 (vct-ref gen 3))
		    (vct-set! gen 3 (input)))
		  (set! pos (- pos num))))
	    (vct-set! gen 0 pos)))
      (vct-set! gen 0 (+ pos (vct-ref gen 1)))
      (let ((lo (vct-ref gen 2)))
	(+ lo (* pos (- (vct-ref gen 3) lo))))))
  
  
  (define (itst form result)
    (let ((val (run-eval form)))
      (if (not (eqv? val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (itsta form arg result)
    (let ((val (run-eval form arg)))
      (if (not (eqv? val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (fitst form result)
    (let ((val (run-eval form)))
      (if (not (= val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (fitsta form arg result)
    (let ((val (run-eval form arg)))
      (if (not (= val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (btst form result)
    (let ((val (run-eval form)))
      (if (not (eq? val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (btsta form arg result)
    (let ((val (run-eval form arg)))
      (if (not (eq? val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (ftst form result)
    (let ((val (run-eval form)))
      (if (fneq val result) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (ftsta form arg result)
    (let ((val (run-eval form arg)))
      (if (fneq val result) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (etst form)
    (let ((tag (catch #t (lambda () (run-eval form)) (lambda args args))))
      (if (or (not (list-p tag))
	      (not (eq? (car tag) 'cannot-parse)))
	  (snd-display #__line__ ";~A -> ~A?" form tag))))
  
  (define (etsta form arg)
    (let ((tag (catch #t (lambda () (run-eval form arg)) (lambda args args))))
      (if (or (not (list-p tag))
	      (and (not (eq? (car tag) 'cannot-parse))
		   (not (eq? (car tag) 'wrong-type-arg))))
	  (snd-display #__line__ ";~A -> ~A?" form tag))))
  
  (define (ctst form result)
    (let ((val (run-eval form)))
      (if (not (char=? val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (ctsta form arg result)
    (let ((val (run-eval form arg)))
      (if (not (char=? val result)) (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (stst form result)
    (catch 'cannot-parse
	   (lambda ()
	     (let ((val (run-eval form)))
	       (if (or (not (string? val))
		       (not (string=? val result)))
		   (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
	   (lambda args
	     (snd-display #__line__ ";stst ~A: unparsable" form))))
  
  (define (ststa form arg result)
    (let ((val (run-eval form arg)))
      (if (or (not (string? val))
	      (not (string=? val result)))
	  (snd-display #__line__ ";~A -> ~A (~A)" form val result))))
  
  (define (t22-i->i arg) (+ arg 32))
  (define (t22-i->b arg) (= arg 3))
  (define (t22-i->f arg) (* arg 2.0))
  (define (t22-i->s arg) (if (= arg 3) "yes" "no"))
  (define (t22-i->c arg) (integer->char (+ arg 70)))
  (define (t22-i->k arg) (if (= arg 3) :yes :no))
  (define (t22-i->sym arg) (if (= arg 3) 'yes 'no))
  (define (t22-i->clm arg) (make-oscil arg))
  (define (t22-i2->i arg) (+ arg (t22-i->i arg)))
  (define (t22-i-f->f arg1 arg2) (+ arg1 arg2))
  (define (t22-iv-i-i->iv arg1 arg2 arg3) (vector-set! arg1 arg2 arg3) arg1)
  (define (t22-fv-i-f->fv arg1 arg2 arg3) (vector-set! arg1 arg2 arg3) arg1)
  (define (t22-s->c arg) (string-ref arg 1))
  (define (t22-sd->f arg) (sound-data-ref arg 1 1))
  (define (t22-sd->sd arg) (sound-data-set! arg 1 1 44.0) arg)
  (define (t22-clm->i arg) (mus-order arg))
  (define (t22-vct->vct arg) (vct-set! arg 1 44.0) arg)
  (define (t22-cv->f arg) (mus-frequency (vector-ref arg 1)))
  
  
  (set! (optimization) 6)
  
  (do ((run-test 0 (+ 1 run-test))) ((= run-test tests))
    
    (log-mem run-test)
    
    (set! unique-float 3.0)
    (set! unique-int 3)
    (set! unique-char #\c)
    (set! unique-string "hiho")
    (set! unique-float-vector (make-vector 3 1.0))
    (set! unique-int-vector (make-vector 3 1))
    (set! unique-generator (make-oscil))
    (set! unique-list (list 1 (make-oscil)))
    (set! unique-symbol 'hiho)
    (set! unique-keyword :hiho)
    (set! unique-clm-vector (make-vector 3 #f))
    (set! unique-boolean #t)
    (set! unique-vct-vector (make-vector 3 #f))
    (set! int-var 32)
    (set! dbl-var 3.14)
    (set! bool-var #t)
    (set! lst-var '(0 1 2))
    (set! biggie (expt 2 31))
    (set! str-var "hi")
    (set! cont1 #f)
    (set! cont2 #f)
    (set! gv 1)
    (set! global-v (make-vct 3 1.0))
    (set! global-v1 (make-vct 3 1.0))
    (set! c-var #\a)
    (set! list-var (list 2 3 4 5))
    (set! l0111 (list 0 1 1 1))
    (set! v-var (make-vct 8))
    (set! ivect (make-vector 3 1))
    (set! svar (make-st3 :one 1.0 :two 2.0))
    (set! svar1 #f)
    (set! bst3 #f)
    (set! bst4 #f)
    (set! g-gen (make-oscil 440))
    (set! clm_vector (make-vector 2))
    (set! vct_vector (make-vector 2))
    (set! hi1 (make-hiho1))
    (set! hif2 (make-hiho1 :xx 3.14))
    (set! hi2 (make-hiho2 :v (make-vct 3 .1)))
    
    
    (ftsta '(lambda (y) (set! dbl-var 32.0) dbl-var) 0.0 32.0)
    (if (fneq dbl-var 32.0) (snd-display #__line__ ";set! 1 dbl-var: ~A" dbl-var))
    (ftsta '(lambda (y) (set! dbl-var y) dbl-var) 0.5 0.5)
    (if (fneq dbl-var 0.5) (snd-display #__line__ ";set! 2 dbl-var: ~A" dbl-var))
    
    (itsta '(lambda (y) (set! int-var 3) int-var) 0 3)
    (if (not (= int-var 3)) (snd-display #__line__ ";set! 1 int-var: ~A" int-var))
    (itsta '(lambda (y) (set! int-var (inexact->exact y)) int-var) -2 -2)
    (if (not (= int-var -2)) (snd-display #__line__ ";set! 2 int-var: ~A" int-var))
    
    (btsta '(lambda (y) (set! bool-var #f) bool-var) 0.0 #f)
    (if (not (eq? bool-var #f)) (snd-display #__line__ ";set! 1 bool-var: ~A" bool-var))
    (btsta '(lambda (y) (set! bool-var (odd? y)) bool-var) 1 #t)
    (if (not (eq? bool-var #t)) (snd-display #__line__ ";set! 2 bool-var: ~A" bool-var))
    
    (set! int-var 32)
    (set! dbl-var 3.14)
    (set! bool-var #t)
    
    (etst '(set!))
    (etst '(set! int-var))
    (etst '(set! int-var 3 dbl-var 2.0))
    (etst '(let))
    (etst '(let*))
    (etst '(let ()))
    (etst '(let* ()))
    (etst '(let* * *))
    (etst '(let ((a 1))))
    (etst '(let* ((a 1))))
    (etst '(do))
    (etst '(do ()))
    (etst '(do () ()))
    (etst '(if))
    (etst '(if #t))
    (etst '(if #f #f #f #f))
    (etst '(cond))
    (etst '(case))
    (etst '(case 1))
    (etst '(call-with-current-continuation))
    (etst '(call-with-current-continuation #f #f))
    (etst '(lambda))
    (etst '(quote))
    (etst '(quote 1 2 4))
    (etst '(* + -))
    
    (itst '(* 2 3) 6)
    (itst '(* 2) 2)
    (itst '(* 2 0) 0)
    (itst '(* int-var 2) 64)
    (ftst '(* 2.0 2.5) 5.0)
    (ftst '(* -2.0 1.5 2.0) -6.0)
    (ftst '(* dbl-var 2.0) 6.28)
    (ftst '(* dbl-var int-var) (* 32 3.14))
    (ftsta '(lambda (y) y) 4.0 4.0)
    (ftsta '(lambda (y) (* 2 y)) 4.0 8.0)
    (ftsta '(lambda (y) (* 2.5 y)) 4.0 10.0)
    (ftsta '(lambda (y) (* y y)) 4.0 16.0)
    (ftsta '(lambda (y) (* y y 2)) 2.0 8.0)
    (ftsta '(lambda (y) (* y y 2 y)) 2.0 16.0)
    (ftsta '(lambda (y) (* y 2.0 y 0.5 y y)) 2.0 16.0)
    (ftsta '(lambda (y) (* y 1)) 4.0 4.0)
    (ftsta '(lambda (y) (* y 1.0)) 4.0 4.0)
    (itsta '(lambda (y) (* 2 (inexact->exact y))) 3.0 6)
    (itsta '(lambda (y) (* 2 (inexact->exact y) (inexact->exact (* 2 y)))) 3.0 36)
    (itsta '(lambda (y) (* 2 (inexact->exact y) (inexact->exact (* 2 y)) (inexact->exact y))) 2.0 32)
    (itst '(* 2 (* 3 (* 4))) 24)
    (ftsta '(lambda (y) (* y 3 2)) 1.5 9.0)
    (ftsta '(lambda (y) (* y y y y y y)) 2.0 64.0)
    (etst '(* #f))
    (etst '(* 2.0 "a string"))
    (etst '(* 2.0 1+2i))
    (itsta '(lambda (y) (* (inexact->exact y) 
			   (inexact->exact (+ y 1)) 
			   (inexact->exact y) 
			   (inexact->exact (+ y 2)) 
			   (inexact->exact (* y 2) )))
	   1 12)
    (itsta '(lambda (y) (+ (inexact->exact y) 
			   (inexact->exact (+ y 1)) 
			   (inexact->exact y) 
			   (inexact->exact (+ y 2)) 
			   (inexact->exact (* y 2) )))
	   1 9)
    
    (itst '(+ 2 3) 5)
    (itst '(+ 2) 2)
    (itst '(+ 2 0) 2)
    (ftst '(+ 3.4) 3.4)
    (ftst '(+ 2.0 2.5) 4.5)
    (ftst '(+ -2.0 1.5 2.0) 1.5)
    (ftsta '(lambda (y) (+ 2 y)) 4.0 6.0)
    (ftsta '(lambda (y) (+ 2.5 y)) 4.0 6.5)
    (ftsta '(lambda (y) (+ y y)) 4.0 8.0)
    (ftsta '(lambda (y) (+ y y 2)) 2.0 6.0)
    (ftsta '(lambda (y) (+ y y 2 y)) 2.0 8.0)
    (ftsta '(lambda (y) (+ y 2.0 y 0.5 y y)) 2.0 10.5)
    (ftsta '(lambda (y) (+ y 1)) 4.0 5.0)
    (ftsta '(lambda (y) (+ y 1.0)) 4.0 5.0)
    (itsta '(lambda (y) (+ 2 (inexact->exact y))) 3.0 5)
    (itsta '(lambda (y) (+ 2 (inexact->exact y) (inexact->exact (+ 2 y)))) 3.0 10)
    (itsta '(lambda (y) (+ 2 (inexact->exact y) (inexact->exact (+ 2 y)) (inexact->exact y))) 2.0 10)
    (itst '(+ 2 (+ 3 (+ 4))) 9)
    (ftsta '(lambda (y) (+ y 3 2)) 1.5 6.5)
    (ftsta '(lambda (y) (+ y y y y y y)) 2.0 12.0)
    (ftst '(+ dbl-var 2) (+ dbl-var 2))
    (itst '(+ int-var 2) (+ int-var 2))
    (etst '(+ #t))
    (etst '(+ 2 "oops"))
    (itst '(let ((res 1)) (do ((i 2 (+ 1 i))) ((= i 21)) (set! res (* res i))) res) 2432902008176640000)
    (itst '(+ 2432902008176640000 1) 2432902008176640001)
    
    (itst '(* (+ 1 2) (+ 3 4)) 21)
    (itst '(+ (* 2 3) (* 4 5)) 26)
    (etst '(+ 1.0 0.1+i))
    (etst '(abs 0+i))
    (ftst '(abs 1+0i) 1.0)
					;	    (etsta '(lambda (y) (+ 1 y)) (sqrt -1.0))
					; this now returns #f and optimization hook sends a warning
    
    (itst '(- 2 3) -1)
    (itst '(- 2) -2)
    (itst '(- 2 0) 2)
    (ftst '(- 2 2.5) -.5)
    (ftst '(- 2 0.5 2) -.5)
    (ftst '(- 2.0 0.5 2) -.5)
    (ftst '(- 2.0 2.5) -.5)
    (ftst '(- 2.5 2) .5)
    (ftst '(- -2.0 1.5 2.0) -5.5)
    (ftst '(- 2.0) -2.0)
    (itst '(- 0 0) 0)
    (itst '(- 1 0) 1)
    (itst '(- 0 1) -1)
    (ftsta '(lambda (y) (- 2 y)) 4.0 -2.0)
    (ftsta '(lambda (y) (- 2.5 y)) 4.0 -1.5)
    (ftsta '(lambda (y) (- y y)) 4.0 0.0)
    (ftsta '(lambda (y) (- y y 2)) 2.0 -2.0)
    (ftsta '(lambda (y) (- y y 2 y)) 2.0 -4.0)
    (ftsta '(lambda (y) (- y 2.0 y 0.5 y y)) 2.0 -6.5)
    (ftsta '(lambda (y) (- y 1)) 4.0 3.0)
    (ftsta '(lambda (y) (- y 1.0)) 4.0 3.0)
    (itsta '(lambda (y) (- 2 (inexact->exact y))) 3.0 -1)
    (itsta '(lambda (y) (- (inexact->exact y))) 1.0 -1)
    (itsta '(lambda (y) (- 2 (inexact->exact y) (inexact->exact (- 2 y)))) 3.0 0)
    (itsta '(lambda (y) (- 2 (inexact->exact y) (inexact->exact (- 2 y)) (inexact->exact y))) 2.0 -2)
    (itst '(- 2 (- 3 (- 4))) -5)
    (ftsta '(lambda (y) (- y 3 2)) 1.5 -3.5)
    (ftsta '(lambda (y) (- y 0)) 1.0 1.0)
    (ftsta '(lambda (y) (- y 0 1)) 1.0 0.0)
    (ftsta '(lambda (y) (- 0 y)) 1.0 -1.0)
    (ftsta '(lambda (y) (- 0.0 y)) 1.0 -1.0)
    (ftsta '(lambda (y) (- 0.0 y 1)) 1.0 -2.0)
    (ftsta '(lambda (y) (- y y y y y y)) 2.0 -8.0)
    (etst '(- "hi"))
    (etst '(- *))
    
    (ftst '(/ 2.0) 0.5)
    (ftst '(/ 2) 0.5)
    (ftst '(/ 2.0 0.5) 4.0)
    (ftst '(/ 2.0 0.5 2.0) 2.0)
    (ftst '(/ 1.0) 1.0)
    (ftst '(/ 1) 1.0)
    (ftst '(/ 1.0 2) 0.5)
    (ftst '(/ 1 2) 0.5)
    (ftst '(/ 2 2) 1.0)
    (ftst '(/ 2 1 2 5) .2)
    (ftst '(/ 2 1.0 2.0 5) .2)
    (ftsta '(lambda (y) (/ 2 y)) 4.0 0.5)
    (ftsta '(lambda (y) (/ 2.0 y)) 4.0 0.5)
    (ftsta '(lambda (y) (/ y y)) 4.0 1.0)
    (ftsta '(lambda (y) (/ y)) 4.0 0.25)
    (itsta '(lambda (y) (inexact->exact (/ y))) 0.25 4)
    (itsta '(lambda (y) (inexact->exact (/ y 2.0))) 4.0 2)
    (ftsta '(lambda (y) (/ y (* 2 y))) 2.0 0.5)
    (ftsta '(lambda (y) (/ y (* 2 y) y)) 2.0 0.25)
    (ftsta '(lambda (y) (/ y (* 2 y) 2 y)) 2.0 0.125)
    (ftsta '(lambda (y) (/ y (* 2 y) (+ y y) y 2)) 2.0 0.03125)
    (itst '(inexact->exact (/ 0.5)) 2)
    (itst '(inexact->exact (/ 0.5 0.5)) 1)
    (itst '(inexact->exact (/ 3)) 0)
    (itst '(inexact->exact (/ 3 1.5 2)) 1)
    (etst '(/ #f))
    (etst '(/ 1.0 2 "oops" 2))
    (ftst '(/ 2.0 1.0) 2.0)
    (ftst '(let ((a 3.0)) (/ a 1.0)) 3.0)
    (ftst '(let ((a 3.0)) (/ a 0.5)) 6.0)
    (ftst '(let ((a 3.0)) (/ a (* 2 0.5))) 3.0)
    (ftst '(/ int-var 2) 16.0)
    (ftst '(/ 32 int-var) 1.0)
    (ftst '(/ int-var 2.0) 16.0)
    (ftst '(/ 32.0 int-var) 1.0)
    (ftst '(/ int-var int-var) 1.0)
    (ftst '(/ dbl-var int-var) (/ dbl-var int-var))
    (ftst '(/ int-var dbl-var) (/ int-var dbl-var))
    
    (btst '(exact? 1) #t)
    (btst '(exact? 2.01) #f)
    (btst '(exact? #i77) #f)
    (btst '(exact? #x77) #t)
    (btst '(exact? #b11) #t)
    (btst '(inexact? 1) #f)
    (btst '(inexact? 2.01) #t)
    (btst '(inexact? #i77) #t)
    (btst '(inexact? #x77) #f)
    (btst '(inexact? #b11) #f)
    (btst '(exact? (/ 3.0 2.0)) #f)
    (btst '(inexact? (/ 3.0 2.0)) #t)
    (btst '(exact? #f) #f)
    (btst '(inexact? #f) #f)
    (btsta '(lambda (y) (inexact? y)) 1.5 #t)
    (btsta '(lambda (y) (inexact? (inexact->exact y))) 1.5 #f)
    (btsta '(lambda (y) (exact? y)) 1.5 #f)
    (btsta '(lambda (y) (exact? (inexact->exact y))) 1.5 #t)
    
    (btst '(= 7 7) #t)
    (btst '(= 7 9) #f)
    (btst '(= 1.0 1.0) #t)
    (btst '(= 1.0 2.0) #f)
    (btst '(= 2.0 (+ 1.0 1.0) (* 1.0 2.0)) #t)
    (btst '(= 7 (+ 6 1) (- 9 2)) #t)
    (btst '(= 1.0 1.0 2.0 1.0) #f)
    (btst '(= 7 (+ 6 1) (- 9 2) (- 9 4)) #f)
    (etst '(= 1.0 #f))
    (btsta '(lambda (y) (= (inexact->exact y) int-var)) 32.0 #t)
    (btsta '(lambda (y) (= (inexact->exact y) 1)) 2.0 #f)
    (btsta '(lambda (y) (= y 1.0)) 1.0 #t)
    (btsta '(lambda (y) (= y y y 1.0)) 1.0 #t)
    (btsta '(lambda (y) (= (inexact->exact y) (inexact->exact (* y 1)) (inexact->exact (- y 0)) 1)) 1.0 #t)
    
    (btst '(< 1 2 3) #t)
    (btst '(< 1 2.0 3) #t)
    (btst '(< 1 2 3 2) #f)
    (btst '(< 1 2) #t)
    (btst '(< 1) #t)
    (btst '(< 1.0 2.0) #t)
    (btst '(< 1.0 2) #t)
    (btst '(< 1.0 2.0 1.0) #f)
    (btst '(< 1.0 1) #f)
    (btsta '(lambda (y) (< y 2.0)) 3.0 #f)
    (btsta '(lambda (y) (< y 2.0)) 1.0 #t)
    (btsta '(lambda (y) (< y 2.0)) 2.0 #f)
    (btsta '(lambda (y) (< y 2.0 3.0 1.0)) 0.0 #f)
    (btsta '(lambda (y) (< y 2.0 3.0 4.0)) 0.0 #t)
    (btsta '(lambda (y) (< y (- y 2.0))) 3.0 #f)
    (btsta '(lambda (y) (< y 2.0 3)) 1.0 #t)
    (btsta '(lambda (y) (< 0.0 y 3)) 1.0 #t)
    (btsta '(lambda (y) (< 0.0 2 y)) 3.0 #t)
    (btsta '(lambda (y) (< 0.0 2 y 1.0)) 3.0 #f)
    (btsta '(lambda (y) (< (- y 1.0) 2.0)) 2.0 #t)
    (btsta '(lambda (y) (< 0 2 (inexact->exact y))) 3.0 #t)
    (btsta '(lambda (y) (< 0 2 (inexact->exact y) 4)) 3.0 #t)
    (btsta '(lambda (y) (< 0 2 (inexact->exact y) 4 1)) 3.0 #f)
    (btsta '(lambda (y) (< 0 2 y 4)) 3.0 #t)
    (btsta '(lambda (y) (< 0 2 y 4 1.5)) 3.0 #f)
    (btsta '(lambda (y) (< (- y 2) y (+ y 1))) 0.0 #t)
    (btsta '(lambda (y) (< (+ y 1) y (- y 0))) 0.0 #f)
    (etst '(< 1 #f))
    (etst '(< > 0))
    
    (btst '(>= 1 2 3) #f)
    (btst '(>= 3 2 1) #t)
    (btst '(>= 1 2.0 3) #f)
    (btst '(>= 1 2 3 2) #f)
    (btst '(>= 3 2 2 1 1) #t)
    (btst '(>= 1 2) #f)
    (btst '(>= 1) #t)
    (btst '(>= 1.0) #t)
    (btst '(>= 1.0 2.0) #f)
    (btst '(>= 2.0 1.0) #t)
    (btst '(>= 1.0 2) #f)
    (btst '(>= 1.0 2.0 1.0) #f)
    (btst '(>= 2.0 2.0 1.0) #t)
    (btst '(>= 1.0 1) #t)
    (btsta '(lambda (y) (>= y 2.0)) 3.0 #t)
    (btsta '(lambda (y) (>= y 2.0)) 1.0 #f)
    (btsta '(lambda (y) (>= y 2.0)) 2.0 #t)
    (btsta '(lambda (y) (>= y 2.0 3.0 1.0)) 0.0 #f)
    (btsta '(lambda (y) (>= y 2.0 3.0 4.0)) 0.0 #f)
    (btsta '(lambda (y) (>= y (- y 2.0))) 3.0 #t)
    (btsta '(lambda (y) (>= y 2.0 3)) 1.0 #f)
    (btsta '(lambda (y) (>= 0.0 y 3)) 1.0 #f)
    (btsta '(lambda (y) (>= 0.0 2 y)) 3.0 #f)
    (btsta '(lambda (y) (>= 4.0 y 3 3 2)) 3.0 #t)
    (btsta '(lambda (y) (>= 0.0 2 y 1.0)) 3.0 #f)
    (btsta '(lambda (y) (>= (- y 1.0) 2.0)) 2.0 #f)
    (btsta '(lambda (y) (>= 0 2 (inexact->exact y))) 3.0 #f)
    (btsta '(lambda (y) (>= 0 2 (inexact->exact y) 4)) 3.0 #f)
    (btsta '(lambda (y) (>= 0 2 (inexact->exact y) 4 1)) 3.0 #f)
    (btsta '(lambda (y) (>= 0 2 y 4)) 3.0 #f)
    (btsta '(lambda (y) (>= 0 2 y 4 1.5)) 3.0 #f)
    (btsta '(lambda (y) (>= (- y 2) y (+ y 1))) 0.0 #f)
    (btsta '(lambda (y) (>= (+ y 1) y (- y 0))) 0.0 #t)
    (etst '(>= 1 #f))
    (etst '(>= > 0))
    
    (btst '(> 1 2 3) #f)
    (btst '(> 3 2 1) #t)
    (btst '(> 1 2.0 3) #f)
    (btst '(> 1 2 3 2) #f)
    (btst '(> 3 2 2 1 1) #f)
    (btst '(> 1 2) #f)
    (btst '(> 3 2) #t)
    (btst '(> 1) #t)
    (btst '(> 1.0) #t)
    (btst '(> 1.0 2.0) #f)
    (btst '(> 2.0 1.0) #t)
    (btst '(> 1.0 2) #f)
    (btst '(> 1.0 2.0 1.0) #f)
    (btst '(> 2.0 2.0 1.0) #f)
    (btst '(> 1.0 1) #f)
    (btsta '(lambda (y) (> y 2.0)) 3.0 #t)
    (btsta '(lambda (y) (> y 2.0)) 1.0 #f)
    (btsta '(lambda (y) (> y 2.0)) 2.0 #f)
    (btsta '(lambda (y) (> y 2.0 3.0 1.0)) 0.0 #f)
    (btsta '(lambda (y) (> y 2.0 3.0 4.0)) 0.0 #f)
    (btsta '(lambda (y) (> y (- y 2.0))) 3.0 #t)
    (btsta '(lambda (y) (> y 2.0 3)) 1.0 #f)
    (btsta '(lambda (y) (> 0.0 y 3)) 1.0 #f)
    (btsta '(lambda (y) (> 0.0 2 y)) 3.0 #f)
    (btsta '(lambda (y) (> 4.0 y 3 3 2)) 3.0 #f)
    (btsta '(lambda (y) (> 0.0 2 y 1.0)) 3.0 #f)
    (btsta '(lambda (y) (> (- y 1.0) 2.0)) 2.0 #f)
    (btsta '(lambda (y) (> 0 2 (inexact->exact y))) 3.0 #f)
    (btsta '(lambda (y) (> 0 2 (inexact->exact y) 4)) 3.0 #f)
    (btsta '(lambda (y) (> 0 2 (inexact->exact y) 4 1)) 3.0 #f)
    (btsta '(lambda (y) (> 0 2 y 4)) 3.0 #f)
    (btsta '(lambda (y) (> 0 2 y 4 1.5)) 3.0 #f)
    (btsta '(lambda (y) (> (- y 2) y (+ y 1))) 0.0 #f)
    (btsta '(lambda (y) (> (+ y 1) y (- y 0))) 0.0 #f)
    (etst '(> 1 #f))
    (etst '(> > 0))
    
    (btst '(<= 1 2 3) #t)
    (btst '(<= 1 2.0 3) #t)
    (btst '(<= 1 2 3 2) #f)
    (btst '(<= 1 2) #t)
    (btst '(<= 1) #t)
    (btst '(<= 1.0 2.0) #t)
    (btst '(<= 1.0 2) #t)
    (btst '(<= 1.0 2.0 1.0) #f)
    (btst '(<= 1.0 2.0 2.0) #t)
    (btst '(<= 1.0 1) #t)
    (btsta '(lambda (y) (<= y 2.0)) 3.0 #f)
    (btsta '(lambda (y) (<= y 2.0)) 1.0 #t)
    (btsta '(lambda (y) (<= y 2.0)) 2.0 #t)
    (btsta '(lambda (y) (<= y 2.0 3.0 1.0)) 0.0 #f)
    (btsta '(lambda (y) (<= y 2.0 3.0 4.0)) 0.0 #t)
    (btsta '(lambda (y) (<= y (- y 2.0))) 3.0 #f)
    (btsta '(lambda (y) (<= y 2.0 3)) 1.0 #t)
    (btsta '(lambda (y) (<= 0.0 y 3)) 1.0 #t)
    (btsta '(lambda (y) (<= 0.0 2 y)) 3.0 #t)
    (btsta '(lambda (y) (<= 0.0 2 y 1.0)) 3.0 #f)
    (btsta '(lambda (y) (<= (- y 1.0) 2.0)) 2.0 #t)
    (btsta '(lambda (y) (<= 0 2 (inexact->exact y))) 3.0 #t)
    (btsta '(lambda (y) (<= 0 2 (inexact->exact y) 4)) 3.0 #t)
    (btsta '(lambda (y) (<= 0 2 (inexact->exact y) 4 1)) 3.0 #f)
    (btsta '(lambda (y) (<= 0 2 y 4)) 3.0 #t)
    (btsta '(lambda (y) (<= 0 2 y 4 1.5)) 3.0 #f)
    (btsta '(lambda (y) (<= (- y 2) y (+ y 1))) 0.0 #t)
    (btsta '(lambda (y) (<= (+ y 1) y (- y 0))) 0.0 #f)
    (etst '(<= 1 #f))
    (etst '(<= > 0))
    
    (itst '(+) (+))
    (itst '(*) (*))
    (etst '(/))
    (etst '(-))
    (btst '(>) #t)
    (btst '(>=) #t)
    (btst '(<) #t)
    (btst '(<=) #t)
    
    (btst '(zero? 0) #t)
    (btst '(zero? 0.0) #t)
    (btst '(zero? 1) #f)
    (etst '(zero?))
    (etst '(zero? #f))
    (etst '(zero? 1 2 3))
    (btsta '(lambda (y) (zero? y)) 0.0 #t)
    (btsta '(lambda (y) (zero? (inexact->exact y))) 32 #f)
    
    (btst '(positive? 0) #f)
    (btst '(positive? -1) #f)
    (btst '(positive? 0.0) #f)
    (btst '(positive? 1) #t)
    (etst '(positive?))
    (etst '(positive? #f))
    (etst '(positive? 3 2))
    (etst '(positive? bool-var))
    (btsta '(lambda (y) (positive? y)) 0.0 #f)
    (btsta '(lambda (y) (positive? y)) 1.0 #t)
    (btsta '(lambda (y) (positive? (inexact->exact y))) 1.0 #t)
    
    (btst '(negative? 0) #f)
    (btst '(negative? -1) #t)
    (btst '(negative? 0.0) #f)
    (btst '(negative? 1) #f)
    (etst '(negative?))
    (etst '(negative? 'hi))
    (etst '(negative? 3.1 2))
    (btsta '(lambda (y) (negative? y)) 0.0 #f)
    (btsta '(lambda (y) (negative? y)) -1.0 #t)
    (btsta '(lambda (y) (negative? y)) 1.0 #f)
    (btsta '(lambda (y) (negative? (inexact->exact y))) -1.0 #t)
    
    (btst '(even? 2) #t)
    (btst '(even? 2.0) #t)
    (btst '(even? -2) #t)
    (btst '(even? 1) #f)
    (btst '(even? 3.0) #f)
    (btst '(even? 0) #t)
    (etst '(even?))
    (etst '(even? #t))
    (etst '(even? 3 2.1))
    (btsta '(lambda (y) (even? y)) 1 #f)
    (btsta '(lambda (y) (even? y)) -1 #f)
    (btsta '(lambda (y) (even? y)) 2 #t)
    (btsta '(lambda (y) (even? y)) 4.0 #t)
    
    (btst '(odd? 2) #f)
    (btst '(odd? 2.0) #f)
    (btst '(odd? -2) #f)
    (btst '(odd? 1) #t)
    (btst '(odd? 3.0) #t)
    (btst '(odd? 0) #f)
    (btst '(odd? -3) #t)
    (etst '(odd?))
    (etst '(odd? (list 1 2)))
    (etst '(odd? 2 1))
    (btsta '(lambda (y) (odd? y)) 1 #t)
    (btsta '(lambda (y) (odd? y)) -1 #t)
    (btsta '(lambda (y) (odd? y)) 2 #f)
    (btsta '(lambda (y) (odd? y)) 4.0 #f)
    
    (itst '(quotient 45 6) 7)
    (ftst '(quotient 6.0 2.0) 3.0)
    (itst '(quotient 6.0 2.0) 3)
    (itst '(quotient 3 -2) -1)
    (itsta '(lambda (y) (quotient y 6)) 45.0 7)
    (ftsta '(lambda (y) (quotient 6.0 y)) 2.0 3.0)
    (itsta '(lambda (y) (quotient y 2.0)) 6.0 3)
    (itsta '(lambda (y) (quotient y int-var)) 64 2)
    (etst '(quotient))
    (etst '(quotient 1))
    (etst '(quotient "hiho" 2))
    (etst '(quotient 1 2 3))
    
    (itst '(remainder 13 4) 1)
    (itst '(remainder -13 4) -1)
    (itst '(remainder 13 -4) 1)
    (itst '(remainder -13 -4) -1)
    (ftst '(remainder -13 -4.0) -1.0)
    (itst '(remainder 16 4) 0)
    (itst '(remainder 5 2) 1)
    (itst '(remainder -45.0 7) -3)
    (itst '(remainder -17 -9) -8)
    (itsta '(lambda (y) (remainder y 4)) 16.0 0)
    (itsta '(lambda (y) (remainder 5 y)) 2.0 1)
    (itsta '(lambda (y) (remainder y 7)) -45.0 -3)
    (itsta '(lambda (y) (remainder y -9)) -17.0 -8)
    (etst '(remainder))
    (etst '(remainder 1))
    (etst '(remainder #f 2))
    (etst '(remainder 1 2 3))
    
    (itst '(modulo 13 4) 1)
    (itst '(modulo -13 4) 3)
    (itst '(modulo 13 -4) -3)
    (itst '(modulo -13 -4) -1)
    (itst '(modulo 16 4) 0)
    (itst '(modulo 5 2) 1)
    (itst '(modulo -45.0 7) 4.0)
    (itst '(modulo 10 -3.0) -2.0)
    (itst '(modulo -17 -9) -8)
    (itsta '(lambda (y) (modulo 5 y)) 2.0 1.0)
    (itsta '(lambda (y) (modulo y 7)) -45.0 4.0)
    (itsta '(lambda (y) (modulo 10 y)) -3.0 -2.0)
    (itsta '(lambda (y) (modulo -17 y)) -9.0 -8.0)
    (etst '(modulo))
    (etst '(modulo 1))
    (etst '(modulo 11 #f))
    (etst '(modulo 1 2 3))
    
    (ftst '(truncate -4.3) -4.0)
    (ftst '(truncate 3.5) 3.0)
    (itst '(truncate 19) 19)
    (ftst '(truncate .6) 0)
    (ftst '(truncate -8.5) -8)
    (ftst '(truncate 17.3) 17.0)
    (ftsta '(lambda (y) (truncate y)) 4.3 4.0)
    (ftsta '(lambda (y) (truncate y)) 3.5 3.0)
    (ftsta '(lambda (y) (truncate y)) .6 0)
    (ftsta '(lambda (y) (truncate y)) -8.5 -8)
    (ftsta '(lambda (y) (truncate y)) 17.3 17.0)
    (etst '(truncate))
    (etst '(truncate #f))
    (etst '(truncate 3 2 1))
    (ftsta '(lambda (y) (truncate (inexact->exact y))) 1.0 1.0)
    (itsta '(lambda (y) (inexact->exact (truncate (inexact->exact y)))) 1.0 1)
    (itsta '(lambda (y) (inexact->exact (round (inexact->exact y)))) 1.0 1)
    (itsta '(lambda (y) (inexact->exact (ceiling (inexact->exact y)))) 1.0 1)
    (itst '(inexact->exact (truncate -4.3)) -4)
    (itsta '(lambda (y) (inexact->exact (truncate y))) -4.3 -4)
    (itst '(inexact->exact (round 4.3)) 4)
    (itsta '(lambda (y) (inexact->exact (round y))) 4.3 4)
    (itst '(inexact->exact (ceiling 1.5)) 2)
    (itsta '(lambda (y) (inexact->exact (ceiling y))) 1.5 2)
    
    (let* ((g0 (make-oscil 440)) (g1 g0) (v (make-vct 1)))
      (vct-map! v (lambda () (if (eq? g0 g1) 1.0 2.0)))
      (if (fneq (vct-ref v 0) 1.0) (snd-display #__line__ ";run clm eq?: ~A" v)))
    (let* ((g0 (make-oscil 440)) (g1 (make-oscil 330.0)) (v (make-vct 1)))
      (vct-map! v (lambda () (if (eq? g0 g1) 1.0 2.0)))
      (if (fneq (vct-ref v 0) 2.0) (snd-display #__line__ ";run clm neq?: ~A" v)))
    
    (let* ((g0 (make-oscil 440)) (g1 g0) (v (make-vct 1)))
      (vct-map! v (lambda () (if (eqv? g0 g1) 1.0 2.0)))
      (if (fneq (vct-ref v 0) 1.0) (snd-display #__line__ ";run clm eqv?: ~A" v)))
    (let* ((g0 (make-oscil 440)) (g1 (make-oscil 330.0)) (v (make-vct 1)))
      (vct-map! v (lambda () (if (eqv? g0 g1) 1.0 2.0)))
      (if (fneq (vct-ref v 0) 2.0) (snd-display #__line__ ";run clm neqv?: ~A" v)))
    
    (let* ((g0 (make-oscil 440)) (g1 g0) (v (make-vct 1)))
      (vct-map! v (lambda () (if (equal? g0 g1) 1.0 2.0)))
      (if (fneq (vct-ref v 0) 1.0) (snd-display #__line__ ";run clm equal?: ~A" v)))
    (let* ((g0 (make-oscil 440)) (g1 (make-oscil 330.0)) (v (make-vct 1)))
      (vct-map! v (lambda () (if (equal? g0 g1) 1.0 2.0)))
      (if (fneq (vct-ref v 0) 2.0) (snd-display #__line__ ";run clm nequal?: ~A" v)))
    
    (fitst '(floor -4.3) -5.0)
    (fitst '(floor 3.5) 3.0)
    (itst '(floor 3) 3)
    (ftst '(floor .6) 0)
    (ftst '(floor -.6) -1.0)
    (ftst '(floor 17.3) 17.0)
    (ftst '(floor -8.5) -9.0)
    (fitsta '(lambda (y) (floor y)) -4.3 -5.0)
    (fitsta '(lambda (y) (floor y)) 3.5 3.0)
    (ftsta '(lambda (y) (floor y)) .6 0)
    (ftsta '(lambda (y) (floor y)) -.6 -1.0)
    (ftsta '(lambda (y) (floor y)) 17.3 17.0)
    (ftsta '(lambda (y) (floor y)) -8.5 -9.0)
    (etst '(floor))
    (etst '(floor "HI"))
    (etst '(floor 1.7 2))
    (itst '(inexact->exact (floor 2.5)) 2)
    (ftsta '(lambda (y) (floor (inexact->exact y))) 1.0 1.0)
    (itsta '(lambda (y) (inexact->exact (floor y))) 1.0 1)
    
    (fitst '(ceiling -4.3) -4.0)
    (fitst '(ceiling 3.5) 4.0)
    (itst '(ceiling 3) 3)
    (ftst '(ceiling .6) 1.0)
    (ftst '(ceiling -.6) 0)
    (ftst '(ceiling 17.3) 18.0)
    (ftst '(ceiling -8.5) -8.0)
    (etst '(ceiling))
    (etst '(ceiling #t))
    (etst '(ceiling 3.2 1))
    (itst '(inexact->exact (ceiling 2.5)) 3)
    (ftsta '(lambda (y) (ceiling y)) .6 1.0)
    (ftsta '(lambda (y) (ceiling y)) -.6 0)
    (ftsta '(lambda (y) (ceiling y)) 17.3 18.0)
    (ftsta '(lambda (y) (ceiling y)) -8.5 -8.0)
    (ftsta '(lambda (y) (ceiling (inexact->exact y))) 1.0 1.0)
    
    (fitst '(round -4.3) -4.0)
    (ftst '(round 3.5) 4.0)
    (itst '(round 7) 7)
    (ftst '(round .6) 1.0)
    (ftst '(round -.6) -1.0)
    (ftst '(round 17.3) 17.0)
    (ftst '(round -8.5) -8.0)
    (ftst '(round 2.5) 2.0)
    (ftst '(round 3.5) 4.0)
    (ftst '(round -2.5) -2.0)
    (etst '(round))
    (etst '(round 3.2 4))
    (etst '(round "test"))
    (ftsta '(lambda (y) (round y)) .6 1.0)
    (ftsta '(lambda (y) (round y)) -.6 -1.0)
    (ftsta '(lambda (y) (round y)) 17.3 17.0)
    (ftsta '(lambda (y) (round y)) -8.5 -8.0)
    (ftsta '(lambda (y) (round y)) 2.5 2.0)
    (ftsta '(lambda (y) (round y)) 3.5 4.0)
    (ftsta '(lambda (y) (round (inexact->exact y))) 1.0 1.0)
    (itst '(inexact->exact (round .6)) 1)
    
    (itst '(abs 3) 3)
    (itst '(abs -3) 3)
    (itst '(abs 0) 0)
    (ftst '(abs 3.0) 3.0)
    (ftst '(abs -3.1) 3.1)
    (etst '(abs))
    (etst '(abs 3.2 -1))
    (etst '(abs '(hiho)))
    (ftsta '(lambda (y) (abs y)) 3.0 3.0)
    (ftsta '(lambda (y) (abs y)) -3.1 3.1)
    (itsta '(lambda (y) (abs (inexact->exact y))) 3 3)
    (itsta '(lambda (y) (abs (inexact->exact y))) -3 3)
    
    (itst '(max 1) 1)
    (itst '(max 1 2) 2)
    (itst '(max 1 2 4 2 5) 5)
    (itst '(max 1 2 4 2 5 1) 5)
    (itst '(max 2 1) 2)
    (itst '(max 3 2 1) 3)
    (itst '(max 1 2 3) 3)
    (itst '(max 1 2 -4 2 -5) 2)
    (ftst '(max 1.0) 1.0)
    (ftst '(max 1 2.0) 2.0)
    (ftst '(max 1.0 2 4 2 5) 5.0)
    (ftst '(max 1 2 4.0 2.0 5 1) 5.0)
    (ftst '(max 1 -4.0 2.0 -5) 2.0)
    (ftst '(max 2.0 1.0) 2.0)
    (ftst '(max 2.0 1.0 0.0) 2.0)
    (ftst '(max 0.0 1.0 2.0) 2.0)
    (etst '(max))
    (etst '(max 1 #f 3))
    (ftsta '(lambda (y) (max y 2.0)) 1.0 2.0)
    (ftsta '(lambda (y) (max y)) 1.0 1.0)
    (ftsta '(lambda (y) (max 1.0 y 4 int-var 5)) 1.0 32.0)
    (ftsta '(lambda (y) (max 1 2 4.0 2.0 y 1)) 5.0 5.0)
    (ftsta '(lambda (y) (max 1 y 2.0 -5)) -4.0 2.0)
    (ftsta '(lambda (y) (max 2.0 y)) 1.0 2.0)
    (itsta '(lambda (y) (max 1 (inexact->exact y))) 2.0 2)
    (itsta '(lambda (y) (max (inexact->exact y) 1)) 2.0 2)
    (itsta '(lambda (y) (max 1 (inexact->exact y) 3)) 2.0 3)
    (itsta '(lambda (y) (max (inexact->exact y) 3 1 2)) 4.0 4)
    
    (itst '(min 1) 1)
    (itst '(min 1 2) 1)
    (itst '(min 1 2 4 2 5) 1)
    (itst '(min 1 2 4 2 5 1) 1)
    (itst '(min 2 1) 1)
    (itst '(min 3 2 1) 1)
    (itst '(min 1 2 3) 1)
    (itst '(min 1 2 -4 2 -5) -5)
    (itst '(min 1 2 -1 3) -1)
    (ftst '(min 1.0) 1.0)
    (ftst '(min 1 2.0) 1.0)
    (ftst '(min 1.0 2 4 2 5) 1.0)
    (ftst '(min 1 2 4.0 2.0 5 1) 1.0)
    (ftst '(min 1 -4.0 2.0 -5) -5.0)
    (ftst '(min 2.0 1.0) 1.0)
    (ftst '(min 2.0 1.0 0.0) 0.0)
    (ftst '(min 0.0 1.0 2.0) 0.0)
    (etst '(min))
    (etst '(min #f))
    (ftsta '(lambda (y) (min y 2.0)) 1.0 1.0)
    (ftsta '(lambda (y) (min y)) 1.0 1.0)
    (ftsta '(lambda (y) (min 1.0 2 y 2 5)) 4.0 1.0)
    (ftsta '(lambda (y) (min 1 2 y int-var 2.0 5 1)) 4.0 1.0)
    (ftsta '(lambda (y) (min 1 y 2.0 -5)) -4.0 -5.0)
    (ftsta '(lambda (y) (min 2.0 y)) 1.0 1.0)
    (itsta '(lambda (y) (min 1 (inexact->exact y))) 2.0 1)
    (itsta '(lambda (y) (min (inexact->exact y) 1)) 2.0 1)
    (itsta '(lambda (y) (min 1 (inexact->exact y) 3)) 2.0 1)
    (itsta '(lambda (y) (min (inexact->exact y) 3 1 2)) 4.0 1)
    
    (itst '(gcd 32 -36) 4)
    (itst '(gcd) 0)
    (itst '(gcd 34) 34)
    (itst '(gcd 33.0 15.0) 3)
    (itst '(gcd 70 -42 28) 14)
    (itst '(gcd 70 42.0 28 56) 14)
    (itsta '(lambda (y) (gcd y)) 34 34)
    (itsta '(lambda (y) (gcd y 15.0)) 33.0 3)
    (itsta '(lambda (y) (gcd 70 (inexact->exact y) 28)) -42.0 14)
    (itsta '(lambda (y) (gcd 70 y 28 56)) 42.0 14)
    (etst '(gcd #f))
    
    (itst '(lcm) 1)
    (itst '(lcm 32 -36) 288)
    (itst '(lcm 34) 34)
    (itst '(lcm 33.0 15.0) 165)
    (itst '(lcm 17 0) 0)
    (itst '(lcm 70 -42 28) 420)
    (etst '(lcm "hi"))
    (itsta '(lambda (y) (lcm y -36)) 32.0 288)
    (itsta '(lambda (y) (lcm y)) 34 34)
    (itsta '(lambda (y) (lcm 33.0 y)) 15.0 165)
    (itsta '(lambda (y) (lcm 70 (inexact->exact (* 3 y)) (inexact->exact (* -2 y)))) 14.0 420)
    
    (ftst '(expt 2 10) 1024.0)
    (ftst '(expt 2 -1) 0.5)
    (ftst '(expt -0.5 5) -.03125)
    (ftst '(expt 0 0) 1)
    (ftst '(expt 0.0 1) 0.0)
    (ftst '(expt 3.0 3.0) 27.0)
    (etst '(expt))
    (etst '(expt -1))
    (etst '(expt 2 #f))
    (ftsta '(lambda (y) (expt 2 y)) 10 1024.0)
    (ftsta '(lambda (y) (expt y -1)) 2.0 0.5)
    (ftsta '(lambda (y) (expt -0.5 y)) 5.0 -.03125)
    (ftsta '(lambda (y) (expt y 0)) 0.0 1)
    (ftsta '(lambda (y) (expt 0.0 y)) 1.0 0.0)
    (ftsta '(lambda (y) (expt y 3.0)) 3.0 27.0)
    
    (ftst '(exact->inexact 3) 3.0)
    (ftst '(exact->inexact 3.0) 3.0)
    (etst '(exact->inexact))
    (etst '(exact->inexact 1.0 2.0))
    (ftsta '(lambda (y) (exact->inexact (inexact->exact y))) 3.0 3.0)
    
    (itst '(inexact->exact 3.0) 3)
    (itst '(inexact->exact 3) 3)
    (etst '(inexact->exact))
    (etst '(inexact->exact #f))
    (etst '(inexact->exact 2.3 8.1))
    (itsta '(lambda (y) (inexact->exact y)) 3.0 3)
    
    (ftst '(sqrt 16.0) 4.0)
    (ftsta '(lambda (y) (sqrt y)) 4.84 2.2)
    (etst '(sqrt))
    (etst '(sqrt 1 2 3))
    (etst '(sqrt 'hi))
    (ftst '(sqrt 4) 2.0)
    
    (ftst '(exp 1) 2.71828)
    (ftst '(exp 0) 1.0)
    (ftst '(exp -.5) 0.60653)
    (etst '(exp))
    (etst '(exp 2.0 1.0))
    (ftsta '(lambda (y) (exp y)) 1.0 2.71828)
    (ftsta '(lambda (y) (exp y)) 0.0 1.0)
    (ftsta '(lambda (y) (exp y)) -0.5 0.60653)
    
    (ftst '(log 1.0) 0.0)
    (ftst '(log 2.71828) 1.0)
    (ftst '(/ (log 8.0) (log 2.0)) 3.0)
    (etst '(log))
    (etst '(log #t))
    (etst '(log 1 2 3))
    (ftsta '(lambda (y) (log y)) 1.0 0.0)
    (ftsta '(lambda (y) (log y)) 2.71828 1.0)
    (ftsta '(lambda (y) (/ (log y) (log 2.0))) 8.0 3.0)
    (ftst '(log 2) 0.6931)
    
    (itst '(* 2 2147483648) (* biggie 2))
    (itsta '(lambda (y) (declare (y integer)) (* y 2)) 2147483648 (* biggie 2))
    (itst '(+ 1 2147483648) 2147483649)
    (itsta '(lambda (y) (declare (y integer)) (+ 1 y)) 2147483648 2147483649)
    (btst '(eqv? 536870912 536870912) #t)
    (fitst '(/ 2147483648 536870912) 4.0)
    (fitsta '(lambda (y) (declare (y integer)) (/ 2147483648 y)) 536870912 4.0)
    (itst '(abs -536870912) 536870912)
    (itst '(abs -2147483647) 2147483647)
    (itsta '(lambda (y) (declare (y integer)) (abs y)) -2147483647 2147483647)
    (itst '(abs -2147483648) 2147483648)
    (itsta '(lambda (y) (declare (y integer)) (abs y)) -2147483648 2147483648)
    (itst '(abs (* -4 2147483647)) 8589934588)
    (itsta '(lambda (y) (declare (y integer)) (abs (* -4 y))) 2147483647 8589934588)
    (itsta '(lambda (y) (declare (y integer)) (gcd (* y 3) 536870912)) 536870912 536870912)
    (itst '(gcd (* 3 536870912) 536870912) 536870912)
    (itst '(gcd (* 3 536870912 4) (* 4 536870912)) 2147483648)
    (itst '(lcm (* 3 536870912) 536870912) 1610612736)
    (itsta '(lambda (y) (declare (y integer)) (lcm (* 3 536870912) y)) 536870912 1610612736)
    (itst '(+ 1 (* 4 2147483648)) 8589934593)
    (itsta '(lambda (y) (declare (y integer)) (+ 1 (* 4 y))) 2147483648 8589934593)
    (itsta '(lambda (y) (declare (y integer)) (+ 1 (* y 2147483648))) 4 8589934593)
    (itst '(+ 1 (* 2147483648 536870912)) 1152921504606846977)
    (itsta '(lambda (y) (declare (y integer)) (+ 1 (* 2147483648 y))) 536870912 1152921504606846977)
    (itst '(let ((i 0)) (set! i (inexact->exact (* 1.5 2147483648.0))) i) 3221225472)
    (itsta '(lambda (y) (let ((i 0)) (set! i (inexact->exact (* 1.5 y))) i)) 2147483648.0 3221225472)
    (itst '(- 2147483649) -2147483649)
    (itsta '(lambda (y) (declare (y integer)) (- y)) 2147483649 -2147483649)
    (itst '(- 2147483649 2147483648) 1)
    (itsta '(lambda (y) (declare (y integer)) (- 2147483649 y)) 2147483648 1)
    (itst '(- 536870912 2147483648) -1610612736)
    (itsta '(lambda (y) (declare (y integer)) (- y 2147483648)) 536870912 -1610612736)
    (itst '(inexact->exact (/ 2.3283064365386e-10)) 4294967296)
    (itsta '(lambda (y) (inexact->exact (/ y))) 2.3283064365386e-10 4294967296)
    (itst '(max 2147483648 2147483649) 2147483649)
    (itsta '(lambda (y) (declare (y integer)) (max 2147483648 y)) 2147483649 2147483649)
    (itst '(max 2147483648 8589934593 2147483649 -115292150460684697) 8589934593)
    (itsta '(lambda (y) (declare (y integer)) (max 2147483648 8589934593 2147483649 y)) -115292150460684697 8589934593)
    (itst '(min 2147483648 2147483649) 2147483648)
    (itsta '(lambda (y) (declare (y integer)) (min 2147483648 y)) 2147483649 2147483648)
    (itst '(min 2147483648 8589934593 2147483649 -115292150460684697) -115292150460684697)
    (itsta '(lambda (y) (declare (y integer)) (min 2147483648 8589934593 2147483649 y)) -115292150460684697 -115292150460684697)
    (fitst '(round 2147483649.55) 2147483650.0)
    (fitsta '(lambda (y) (round y)) 2147483649.55 2147483650.0)
    (fitst '(ceiling 2147483649.55) 2147483650.0)
    (fitsta '(lambda (y) (ceiling y)) 2147483649.55 2147483650.0)
    (fitst '(truncate 2147483649.55) 2147483649.0)
    (fitsta '(lambda (y) (truncate y)) 2147483649.55 2147483649.0)
    (fitst '(floor 2147483649.55) 2147483649.0)
    (fitsta '(lambda (y) (floor y)) 2147483649.55 2147483649.0)
    (fitst '(ceiling 2147483649.55) 2147483650.0)
    (fitsta '(lambda (y) (ceiling y)) 2147483649.55 2147483650.0)
    (fitst '(ceiling -2147483649.55) -2147483649.0)
    (fitsta '(lambda (y) (ceiling y)) -2147483649.55 -2147483649.0)
    (fitst '(round -2147483649.55) -2147483650.0)
    (fitsta '(lambda (y) (round y)) -2147483649.55 -2147483650.0)
    (fitst '(truncate -2147483649.55) -2147483649.0)
    (fitsta '(lambda (y) (truncate y)) -2147483649.55 -2147483649.0)
    (fitst '(floor -2147483649.55) -2147483650.0)
    (fitsta '(lambda (y) (floor y)) -2147483649.55 -2147483650.0)
    (itst '(inexact->exact 2147483649.55) 2147483650)
    (itsta '(lambda (y) (inexact->exact y)) 2147483649.55 2147483650)
    (itst '(inexact->exact -2147483649.55) -2147483650)
    (itsta '(lambda (y) (inexact->exact y)) -2147483649.55 -2147483650)
    (itst '(modulo 2147483648 3) 2)
    (itsta '(lambda (y) (declare (y integer)) (modulo y 3)) 2147483648 2)
    (itst '(modulo 2147483648 2) 0)
    (itsta '(lambda (y) (declare (y integer)) (modulo 2147483648 y)) 2 0)
    (itst '(modulo 2147483648 2147483649) 2147483648)
    (itsta '(lambda (y) (declare (y integer)) (modulo 2147483648 y)) 2147483649 2147483648)
    (itst '(ash 1 34) 17179869184)
    (itsta '(lambda (y) (declare (y integer)) (ash 1 y)) 34 17179869184)
    (stst '(number->string (ash 1 34)) "17179869184")
    (ststa '(lambda (y) (declare (y integer)) (number->string (ash 1 y))) 34 "17179869184")
    (stst '(number->string 2147483649) "2147483649")
    (ststa '(lambda (y) (declare (y integer)) (number->string y)) 2147483649 "2147483649")
    (stst '(number->string -2147483649) "-2147483649")
    (ststa '(lambda (y) (declare (y integer)) (number->string y)) -2147483649 "-2147483649")
    
    (btst '(number? 2) #t)
    (btst '(number? 2.1) #t)
    (btst '(number? #f) #f)
    (btst '(number? "hi") #f)
    (etst '(number?))
    (etst '(number? 1 2 3))
    (btsta '(lambda (y) (number? y)) 2.0 #t)
    
    (btst '(real? 2) #t)
    (btst '(real? 2.1) #t)
    (btst '(real? #f) #f)
    (btst '(real? "hi") #f)
    (etst '(real?))
    (etst '(real? 1 2 3))
    (btsta '(lambda (y) (real? y)) 2.0 #t)
    
    (btst '(integer? 2) #t)
    (btst '(integer? 2.1) #f)
    (btst '(integer? #f) #f)
    (btst '(integer? "hi") #f)
    (etst '(integer?))
    (etst '(integer? 1 2 3))
    (btsta '(lambda (y) (integer? y)) 2.1 #f)
    (btsta '(lambda (y) (declare (y integer)) (let ((x y)) (integer? x))) 1 #t)
    
    (btst '(exact? 2) #t)
    (btst '(exact? 2.1) #f)
    (btst '(exact? 2.0) #f)
    (btst '(exact? "hi") #f)
    (etst '(exact?))
    (etst '(exact? 1 2 3))
    (btsta '(lambda (y) (exact? y)) 2.1 #f)
    
    (btst '(inexact? 2) #f)
    (btst '(inexact? 2.1) #t)
    (btst '(inexact? 2.0) #t)
    (btst '(inexact? "hi") #f)
    (etst '(inexact?))
    (etst '(inexact? 1 2 3))
    (btsta '(lambda (y) (inexact? y)) 2.1 #t)
    
    (btst '(boolean? 2) #f)
    (btst '(boolean? 2.1) #f)
    (btst '(boolean? #f) #t)
    (btst '(boolean? "hi") #f)
    (etst '(boolean?))
    (etst '(boolean? 1 2 3))
    (btsta '(lambda (y) (boolean? (odd? y))) 2.0 #t)
    
    (btst '(symbol? 'a) #t)
    (btst '(symbol? 1) #f)
    (btst '(symbol? :a) #f)
    (btst '(symbol? "a") #f)
    
    (stst '(symbol->string 'asdf) "asdf")
    
    (btst '(keyword? :asdf) #t)
    (btst '(keyword? 32) #f)
    (etst '(null? :asdf))
    (etst '(* 1 2 :asdf))
    (btst '(keyword? (quote :asdf)) #t)
    (btst '(keyword? 'a) #f)
    
    (ftst '(sin 0.0) 0.0)
    (ftst '(sin 0) 0.0)
    (ftst '(sin (/ pi 2)) 1.0)
    (etst '(sin))
    (etst '(sin #f))
    (etst '(sin 1 2 3))
    (ftsta '(lambda (y) (sin y)) 0.0 0.0)
    (ftsta '(lambda (y) (sin (/ pi y))) 2.0 1.0)
    
    (ftst '(cos 0.0) 1.0)
    (ftst '(cos 0) 1.0)
    (ftst '(cos (/ pi 2)) 0.0)
    (etst '(cos))
    (etst '(cos #f))
    (etst '(cos 1 2 3))
    (ftsta '(lambda (y) (cos y)) 0.0 1.0)
    (ftsta '(lambda (y) (cos (/ pi y))) 2.0 0.0)
    
    (ftst '(asin 0.0) 0.0)
    (ftst '(asin 0) 0.0)
    (ftst '(asin 1.0) (/ pi 2))
    (ftst '(asin 1) (/ pi 2))
    (etst '(asin))
    (etst '(asin #f))
    (etst '(asin 1 2 3))
    (ftsta '(lambda (y) (asin y)) 0.0 0.0)
    (ftsta '(lambda (y) (asin y)) 1.0 (/ pi 2.0))
    
    (ftst '(acos 1.0) 0.0)
    (ftst '(acos 1) 0.0)
    (ftst '(acos 0.0) (/ pi 2))
    (ftst '(acos 0) (/ pi 2))
    (etst '(acos))
    (etst '(acos #f))
    (etst '(acos 1 2 3))
    (ftsta '(lambda (y) (acos y)) 1.0 0.0)
    (ftsta '(lambda (y) (acos y)) 0.0 (/ pi 2.0))
    
    (ftst '(tan 0.0) 0.0)
    (ftst '(tan 0) 0.0)
    (ftst '(tan (/ pi 4)) 1.0)
    (etst '(tan))
    (etst '(tan 'hi))
    (etst '(tan 1.0 2.0))
    (ftsta '(lambda (y) (tan y)) 0.0 0.0)
    (ftsta '(lambda (y) (tan y)) (/ pi 4) 1.0)
    
    (ftst '(atan 0.0) 0.0)      
    (ftst '(atan 0) 0.0)
    (ftst '(atan 1.0) (/ pi 4))
    (ftst '(atan 1) (/ pi 4))
    (ftsta '(lambda (y) (atan y)) 0.0 0.0)
    (ftsta '(lambda (y) (atan y)) 1.0 (/ pi 4))
    (etst '(atan))
    (etst '(atan 'hi))
    (etst '(atan 1.0 2.0 3.0))
    (ftsta '(lambda (y) (atan y)) 0.0 0.0)
    (ftsta '(lambda (y) (atan y)) 1.0 (/ pi 4))
    (ftst '(atan 0.0 1.0) 0.0)
    (ftst '(atan 0 1) 0.0)
    (ftst '(atan 0.5 0.5) (atan 1.0))
    (ftst '(atan 0.5 1.0) (atan 0.5))
    (ftst '(atan 0.5 1) (atan 0.5))
    (ftsta '(lambda (y) (atan 0.5 y)) 0.5 (atan 1.0))
    (ftsta '(lambda (y) (atan y 1.0)) 0.5 (atan 0.5))
    
    (btst '(not #t) #f)
    (btst '(not #f) #t)
    (btst '(not (odd? 2)) #t)
    (etst '(not))
    (btst '(not 1) #f)
    (btst '(not 3.14) #f)
    (btsta '(lambda (y) (not y)) 3.1 #f)
    (btsta '(lambda (y) (set! bool-var (not (odd? y))) (not bool-var)) 3 #t)
    
    (btsta '(lambda (y) (or)) 0 #f)
    (btsta '(lambda (y) (or #f)) 0 #f)
    (btsta '(lambda (y) (or #t #f)) 0 #t)
    (btsta '(lambda (y) (or #f #t)) 0 #t)
    (btsta '(lambda (y) (or (odd? 3))) 0.0 #t)
    (btsta '(lambda (y) (or (odd? 3) #f)) 0.0 #t)
    (btsta '(lambda (y) (or #f (odd? 4))) 0.0 #f)
    (btsta '(lambda (y) (or (odd? y) (begin (set! int-var 123) #f))) 3 #t)
    (if (= int-var 123) (snd-display #__line__ ";or not short-circuited"))
    (etst '(or (hiho 3)))
    
    (btsta '(lambda (y) (and)) 0 #t)
    (btsta '(lambda (y) (and #f)) 0 #f)
    (btsta '(lambda (y) (and #t #f)) 0 #f)
    (btsta '(lambda (y) (and #f #t)) 0 #f)
    (btsta '(lambda (y) (and (odd? 3))) 0.0 #t)
    (btsta '(lambda (y) (and (odd? 3) #f)) 0.0 #f)
    (btsta '(lambda (y) (and #f (odd? 4))) 0.0 #f)
    (btsta '(lambda (y) (and (odd? y) (begin (set! int-var 123) #t))) 3 #t)
    (if (not (= int-var 123)) (snd-display #__line__ ";and quit early?"))
    (btsta '(lambda (y) (and (odd? y) (begin (set! int-var 321) #t))) 2 #f)
    (if (= int-var 321) (snd-display #__line__ ";and not short-circuited"))
    (etst '(and (hiho 3)))
    
    (btst '(eq? 1 1) #t)
    (btst '(eq? 1 2) #f)
    (btst '(eq? #f #f) #t)
    (btst '(eq? unique-boolean unique-boolean) #t)
    (btst '(eq? #f 1) #f)
    (btst '(eq? 1.0 1.0) #f)
    (btst '(eq? #t 1) #f)
    (btst '(eq? 1 1.0) #f)
    (etst '(eq?))
    (etst '(eq? 1))
    (btsta '(lambda (y) (eq? 1 1)) 1.0 #t)
    (btsta '(lambda (y) (eq? #f #f)) 0.0 #t)
    (btsta '(lambda (y) (eq? #f 1)) 0.0 #f)
    (btsta '(lambda (y) (eq? y 1.0)) 1.0 #f)
    (btsta '(lambda (y) (eq? #t y)) 1.0 #f)
    (btsta '(lambda (y) (eq? 1 y)) 1.0 #f)
    (btst '(let ((a 1) (b 1)) (eq? a b)) #t)
    (btsta '(lambda (y) (let ((a (inexact->exact y)) (b 1)) (eq? a b))) 1.0 #t)
    (btst '(eq? :a :a) #t)
    (btst '(eq? :a :b) #f)
    (btst '(eq? 'a 'a) #t)
    (btst '(eq? 'a 'b) #f)
    (btst '(eq? int-var int-var) #t)
    (btst '(eq? int-var 123) #t)
    (btst '(eq? dbl-var dbl-var) #t)
    (btst '(eq? bool-var bool-var) #t)
    
    (btst '(eqv? 1 1) #t)
    (btst '(eqv? 1 2) #f)
    (btst '(eqv? #f #f) #t)
    (btst '(eqv? #f 1) #f)
    (btst '(eqv? 1.0 1.0) #t)
    (btst '(eqv? #t 1) #f)
    (btst '(eqv? 1 1.0) #f)
    (etst '(eqv?))
    (etst '(eqv? 1))
    (btsta '(lambda (y) (eqv? 1 1)) 1.0 #t)
    (btsta '(lambda (y) (eqv? #f #f)) 0.0 #t)
    (btsta '(lambda (y) (eqv? #f 1)) 0.0 #f)
    (btsta '(lambda (y) (eqv? y 1.0)) 1.0 #t)
    (btsta '(lambda (y) (eqv? #t y)) 1.0 #f)
    (btsta '(lambda (y) (eqv? 1 y)) 1.0 #f)
    (btsta '(lambda (y) (eqv? 1 (inexact->exact y))) 1 #t)
    (btst '(eqv? :a :a) #t)
    (btst '(eqv? :a :b) #f)
    (btst '(eqv? 'a 'a) #t)
    (btst '(eqv? 'a 'b) #f)
    (btst '(eqv? int-var int-var) #t)
    (btst '(eqv? int-var 123) #t)
    (btst '(eqv? dbl-var dbl-var) #t)
    (btst '(eqv? bool-var bool-var) #t)
    
    (btst '(equal? 1 1) #t)
    (btst '(equal? 1 2) #f)
    (btst '(equal? #f #f) #t)
    (btst '(equal? #f 1) #f)
    (btst '(equal? 1.0 1.0) #t)
    (btst '(equal? 1.0 2.0) #f)
    (btst '(equal? #t 1) #f)
    (btst '(equal? 1 1.0) #f)
    (etst '(equal?))
    (etst '(equal? 1))
    (btsta '(lambda (y) (equal? 1 1)) 1.0 #t)
    (btsta '(lambda (y) (equal? #f #f)) 0.0 #t)
    (btsta '(lambda (y) (equal? #f 1)) 0.0 #f)
    (btsta '(lambda (y) (equal? y 1.0)) 1.0 #t)
    (btsta '(lambda (y) (equal? #t y)) 1.0 #f)
    (btsta '(lambda (y) (equal? 1 y)) 1.0 #f)
    (btst '(equal? :a :a) #t)
    (btst '(equal? :a :b) #f)
    (btst '(equal? 'a 'a) #t)
    (btst '(equal? 'a 'b) #f)
    (btst '(equal? int-var int-var) #t)
    (btst '(equal? int-var 123) #t)
    (btst '(equal? dbl-var dbl-var) #t)
    (btst '(equal? bool-var bool-var) #t)
    
    (btst '(eq? #\a #\a) #t)
    (btst '(eqv? #\a #\a) #t)
    (btst '(equal? #\a #\a) #t)
    (btst '(eq? #\a #\A) #f)
    (btst '(eqv? #\a #\A) #f)
    (btst '(equal? #\a #\A) #f)
    (btst '(eq? #\a 97) #f)
    (btst '(eqv? #\a 97) #f)
    (btst '(equal? #\a 97) #f)
    
    (itst '(if #t 3 2) 3)
    (itst '(if #f 3 2) 2)
    (btst '(if (odd? 3) #f #t) #f)
    (btst '(if (even? 3) #f #t) #t)
    (ftst '(if (odd? 3) 1.5 2.5) 1.5)
    (ftst '(if (odd? 4) 1.5 2.5) 2.5)
    (itst '(if #t 3) 3)
    (btst '(if (odd? 3) #f) #f)
    (ftst '(if (odd? 3) 1.5) 1.5)
    (itsta '(lambda (y) (if (odd? (inexact->exact y)) 3 2)) 3.0 3)
    (itsta '(lambda (y) (if (odd? (inexact->exact y)) 3)) 3.0 3)
    (ftsta '(lambda (y) (if (odd? (inexact->exact y)) (+ y 1) (* y 2))) 3.0 4.0)
    (ftsta '(lambda (y) (if (odd? (inexact->exact y)) (+ y 1) (* y 2))) 4.0 8.0)
    (ftsta '(lambda (y) (if (odd? (inexact->exact (* y 2))) (+ y 1) (* y 2))) 3.0 6.0)
    (ftsta '(lambda (y) (if (even? (inexact->exact (* y 2))) (+ y 1) (* y 2))) 3.0 4.0)
    (itsta '(lambda (y) (if (number? y) 32)) 1.0 32)
    (itsta '(lambda (y) (if (not (number? y)) 32 31)) 1.0 31)
    (itsta '(lambda (y) (if (not (number? y)) (set! int-var 456) (set! int-var 654)) int-var) 1.0 654)
    
    (itst '(ash 2 3) 16)
    (itst '(ash 16 -3) 2)
    (etst '(ash))
    (etst '(ash 2))
    (itsta '(lambda (y) (ash 2 (inexact->exact y))) 3.0 16)
    (itsta '(lambda (y) (ash (inexact->exact y) -3)) 16.0 2)
    
    (itst '(logand 8 1) 0)
    (itst '(logand 7 1) 1)
    (itst '(logand 7 6) 6)
    (itst '(logand 2 6) 2)
    (itst '(logand 1 6) 0)
    (etst '(logand))
    (etst '(logand 1))
    (itsta '(lambda (y) (logand (inexact->exact y) 1)) 8.0 0)
    (itsta '(lambda (y) (logand 7 (inexact->exact y))) 1.0 1)
    (itsta '(lambda (y) (logand (inexact->exact y) 6)) 7.0 6)
    (itsta '(lambda (y) (logand 2 (inexact->exact y))) 6.0 2)
    
    (itst '(logior 8 1) 9)
    (itst '(logior 7 1) 7)
    (itst '(logior 7 6) 7)
    (itst '(logior 2 6) 6)
    (itst '(logior 1 6) 7)
    (etst '(logior))
    (etst '(logior 1))
    (itsta '(lambda (y) (logior (inexact->exact y) 1)) 8.0 9)
    (itsta '(lambda (y) (logior 7 (inexact->exact y))) 1.0 7)
    (itsta '(lambda (y) (logior (inexact->exact y) 6)) 7.0 7)
    (itsta '(lambda (y) (logior 2 (inexact->exact y))) 6.0 6)
    
    (itst '(logxor 8 1) (logxor 8 1))
    (itst '(logxor 7 1) (logxor 7 1))
    (itst '(logxor 7 6) (logxor 7 6))
    (itst '(logxor 2 6) (logxor 2 6))
    (itst '(logxor 1 6) (logxor 1 6))
    (etst '(logxor))
    (etst '(logxor 1))
    (itsta '(lambda (y) (logxor (inexact->exact y) 1)) 8.0 (logxor 8 1))
    (itsta '(lambda (y) (logxor 7 (inexact->exact y))) 1.0 (logxor 7 1))
    (itsta '(lambda (y) (logxor (inexact->exact y) 6)) 7.0 (logxor 7 6))
    (itsta '(lambda (y) (logxor 2 (inexact->exact y))) 6.0 (logxor 2 6))
    
    (itst '(lognot 1) (lognot 1))
    (itst '(lognot -1) (lognot -1))
    (etst '(lognot))
    (etst '(lognot 1 2 3))
    (itsta '(lambda (y) (lognot (inexact->exact y))) 1.0 (lognot 1))
    (itsta '(lambda (y) (lognot (inexact->exact y))) -1.0 (lognot -1))
    (etst '(logxor 1.5 0))
    (etst '(logxor 0 1.5))
    (etst '(logior 1.5 0))
    (etst '(logior 0 1.5))
    (etst '(logand 1.5 0))
    (etst '(logand 0 1.5))
    (etst '(lognot 1.5))
    (etst '(ash 1.5 1))
    (etst '(ash 1 1.5))
    
    (itst '(begin (set! int-var 1) (if (> int-var 1) (set! int-var 0)) int-var) 1)
    (itst '(begin (set! int-var 1) (if (> int-var 1) (set! int-var 0) 1)) 1)
    (itst '(begin (if (> int-var 1) (set! int-var 0)) int-var) 1)
    (ftst '(begin 1.0) 1.0)
    (ftst '(begin (* int-var 3) (cos 0)) 1.0)
    (itst '(begin (set! int-var 4) (if (odd? int-var) (begin (set! int-var 3) (+ int-var 2)) (begin 2))) 2)
    (btst '(begin #f) #f)
    
    (etst '(set! int-var 1.5))
    (etst '(set! int-var #f))
    (etst '(set! dbl-var #f))
    (etst '(set! dbl-var 1))
    (etst '(set! bool-var 1))
    (etst '(let ((a 1)) (set! a 3.14)))
    (etst '(set! (hiho) 3))
    (etst '(set! (sample 0 0 0) .1))
					;	    (let ((hiho '(1 2))) (etst '(set! hiho 3)))
    (etst '(set! lst-var 3))
    
    (itst '(+ 1 1) 2)
    (itst '(+ 1 0) 1)
    (itst '(+ 1 -1) 0)
    (ftst '(+ 1 2.5) 3.5)
    (ftsta '(lambda (y) (+ 1 y)) 2.1 3.1)
    (itsta '(lambda (y) (+ 1 (inexact->exact y))) 2.0 3)
    (etst '(+ 1 #f))
    (etst '(1+))
    
    (itst '(1- 1) 0)
    (itst '(1- 0) -1)
    (itst '(1- -1) -2)
    (ftst '(1- 2.5) 1.5)
    (ftsta '(lambda (y) (1- y)) 2.1 1.1)
    (itsta '(lambda (y) (1- (inexact->exact y))) 2.0 1)
    (etst '(1- #f))
    (etst '(1-))
    (etst '(1- 1 2 3))
    
    (btst '(integer? (random 32)) #t)
    (btst '(real? (random 32.0)) #t)
    (btst '(exact? (random 32.0)) #f)
    
    (set! dbl-var 32.0)
    (set! int-var 32)
    (set! bool-var #t)
    
    (itst '(let ((a 1)) a) 1)
    (itst '(let ((a 1) (b 2)) (+ a b)) 3)
    (itst '(let ((int-var 2)) int-var) 2) (if (not (= int-var 32)) (snd-display #__line__ ";let local trouble: ~A" int-var))
    (itst '(let ((a 1) (b (let ((a 32)) a))) (+ a b)) 33)
    (ftst '(let ((a 1.0)) a) 1.0)
    (ftst '(let ((a 1.5) (b 2.5)) (+ a b)) 4.0)
    (ftst '(let ((dbl-var 2.5)) (+ int-var dbl-var)) 34.5) (if (not (= dbl-var 32.0)) (snd-display #__line__ ";let flt local trouble: ~A" dbl-var))
    (ftst '(let ((a 1.0) (b (let ((a 32.5)) (set! a 3.5) (+ a 1.0)))) (if (< a 2.0) (+ a b) 0.0)) 5.5)
    (ftst '(let ((dbl-var 2.5)) (set! dbl-var 1.5) dbl-var) 1.5) (if (not (= dbl-var 32.0)) (snd-display #__line__ ";let flt local trouble: ~A" dbl-var))
    (btst '(let ((a #f)) (not a)) #t)
    (btst '(let ((a #f) (b #t)) (and a b)) #f)
    (btst '(let ((bool-var (not bool-var))) bool-var) #f) (if (not bool-var) (snd-display #__line__ ";let b local trouble: ~A" bool-var))
    (btst '(let ((a bool-var) (bool-var (let ((a (not bool-var))) a))) bool-var) #f)
    (itst '(let ((a ( + int-var 1))) a) (+ int-var 1))
    (ftsta '(let ((a 1)) (lambda (y) (+ y a))) 2.5 3.5)
    (itsta '(let ((a 1)) (lambda (y) (+ (inexact->exact y) a))) 2.0 3)
    
    (itst '(let* ((a 1)) a) 1)
    (itst '(let* ((a 1) (b (* 2 a))) (+ a b)) 3)
    (itst '(let* ((int-var 2)) int-var) 2) (if (not (= int-var 32)) (snd-display #__line__ ";let* local trouble: ~A" int-var))
    (itst '(let* ((a 1) (b (let* ((xx 32) (a xx)) a))) (+ a b)) 33)
    (ftst '(let* ((a 1.0)) a) 1.0)
    (ftst '(let* ((a 1.5) (b (* a 2))) (+ a b)) 4.5)
    (ftst '(let* ((dbl-var 2.5)) (+ int-var dbl-var)) 34.5) (if (not (= dbl-var 32.0)) (snd-display #__line__ ";let* flt local trouble: ~A" dbl-var))
    (ftst '(let* ((a 1.0) (b (let* ((a 32.5)) (set! a 3.5) (+ a 1.0)))) (if (< a 2.0) (+ a b) 0.0)) 5.5)
    (btst '(let* ((a #f) (b (not a))) (or b a)) #t)
    (btst '(let* ((a #f) (b #t)) (and a b)) #f)
    (ftsta '(let* ((a 1) (b a)) (lambda (y) (+ y a b))) 2.5 4.5)
    (itsta '(let* ((a 1) (b a)) (lambda (y) (+ (inexact->exact y) b))) 2.0 3)
    (itsta '(let ((a 32)) (let* ((a 1) (b a)) (lambda (y) (+ (inexact->exact y) b)))) 2.0 3)
    (itsta '(let ((a 32)) (let ((a 1) (b a)) (lambda (y) (+ (inexact->exact y) b)))) 2.0 34)
    
    (itst '(let* ((a 1)) (define b 2) (+ a b)) 3)
    (itst '(let* ((a 1)) (define b 2) (define c 3) (+ a b c)) 6)
    (itst '(let* ((a 1) (b 3)) (begin (define b 2) (set! a b)) (+ a b)) 5)
    (itst '(begin (define b 2) (let ((a 1)) (+ a b))) 3)
    (itst '(begin (define b 2) (let ((a 1)) (define b 12) (+ a b))) 13)
    (ftsta '(lambda (y) (define a 3) (+ y a)) 1.0 4.0)
    (ftsta '(lambda (y) (define (a d) (define (b c) (+ c 1)) (+ d (b 3))) (+ y (a 1))) 1.0 6.0)
    (ftsta '(lambda (y) (define (a d) (define b 3) (+ d b)) (+ y (a 1))) 1.0 5.0)
    (ftsta '(lambda (y) (define a (lambda () 3)) (+ y (a))) 1.0 4.0)
    (ftsta '(lambda (y) (define a (lambda () 3)) (+ y (a))) 1.0 4.0)
    (ftsta '(lambda (y) (define a (lambda (b) (+ b 3))) (+ y (a 1))) 1.0 5.0)
    (ftsta '(lambda (y) (define a (lambda (b c) (+ b c))) (+ y (a 1 3))) 1.0 5.0)
    (ftsta '(lambda (y) (define a (lambda (b c) (declare (b real)) (+ b c))) (+ y (a 1.5 3))) 1.0 5.5)
    (ftsta '(lambda (y) (define a (lambda (b c) (declare (b real) (c int)) (+ b c))) (+ y (a 1.5 3))) 1.0 5.5)
    (ftsta '(lambda (y) (define a (lambda (b c) (declare (b int)) (+ b c))) (+ y (a 1 3))) 1.0 5.0)
    (ftsta '(lambda (y) (define a (lambda (b) (declare (b string)) (+ (string-length b) 3))) (+ y (a "hi"))) 1.0 6.0)
    (ftsta '(lambda (y) (define a (lambda (b) (declare (b string)) b)) (+ y (string-length (a "hi")))) 1.0 3.0)
    (ftsta '(lambda (y) (define a (lambda (b) (declare (b string)) b)) (+ y (string-length (a "hi")))) 1.0 3.0)
    (itsta '(lambda (y) (declare (y integer)) (+ y 1)) 1 2)
    (itsta '(lambda (y) (declare (y string)) (string-length y)) "hi" 2)
    (ftsta '(lambda (y) (define (a) 3) (+ y (a))) 1.0 4.0)
    (ftsta '(lambda (y) (define (a b) (+ b 3)) (+ y (a 1))) 1.0 5.0)
    (ftsta '(lambda (y) (define (a b c) (+ b c)) (+ y (a 1 3))) 1.0 5.0)
    (ftsta '(lambda (y) (define (a b c) (declare (b real)) (+ b c)) (+ y (a 1.5 3))) 1.0 5.5)
    (ftsta '(lambda (y) (define (a b c) (declare (b real) (c int)) (+ b c)) (+ y (a 1.5 3))) 1.0 5.5)
    (ftsta '(lambda (y) (define (a b c) (declare (b int)) (+ b c)) (+ y (a 1 3))) 1.0 5.0)
    (ftsta '(lambda (y) (define (a b) (declare (b string)) (+ (string-length b) 3)) (+ y (a "hi"))) 1.0 6.0)
    (ftsta '(lambda (y) (define (a b) (declare (b string)) b) (+ y (string-length (a "hi")))) 1.0 3.0)
    (ftsta '(lambda (y) (define (a b) (declare (b string)) b) (+ y (string-length (a "hi")))) 1.0 3.0)
    
    (itst '(let ((a 0)) (do ((i 0 (+ 1 i))) ((= i 3) a) (set! a (+ 1 a)))) 3)
    (itst '(let ((a 0)) (do ((i 0 (+ 1 i)) (j 1 (* j 2))) ((= i 3) a) (set! a j))) 4)
    (itst '(let ((a 0)) (do ((i 0 (+ 1 i)) (j 1 (* j 2))) ((= i 3) (+ a 1)))) 1)
    (itst '(let ((a 0)) (do ((i 0 (+ 1 i)) (j 1 (* j 2))) ((= i 3) (+ j 1)))) 9)
    (itst '(let ((a 0)) (do () ((= a 3) a) (set! a (+ 1 a)))) 3)
    (itst '(let ((a 0)) (do () ((= a 3) a) (set! a (+ 1 a))) (set! a -1) a) -1)
    (itst '(let ((a 0) (b 3)) (do ((i 0 (+ 1 i))) ((= i (1- b))) (set! a (+ 1 a))) (set! a -1) a) -1)
    
    (itst '(let ((k 123)) (do ((i 0 (+ 1 i)) (j 0 (+ 1 j))) ((= i 3) k) (set! k j))) 2)
    (itst '(let ((k 123)) (do ((j 0 (+ 1 j)) (i 0 (+ 1 i))) ((= i 3) k) (set! k j))) 2)
    (itst '(let ((k 123)) (do ((i 0 (+ 1 i)) (j 0 i)) ((= i 3) k) (set! k j))) 1) ; the "i" ref is to the previous value
    (itst '(let ((k 123)) (do ((i 0 (+ 1 i)) (j 0)) ((= i 3) k) (set! k j))) 0)
    
    (itst '(let ((a 0) (b 3)) (if (> b 2) (set! a 2) (set! b 2)) (set! a -1) a) -1)
    (itst '(let ((a 0) (b 3)) (if (< b 2) (set! a 2) (set! b 2)) (set! a -1) a) -1)
    (itst '(let ((a 0) (b 3)) (cond ((> b 2) (set! a 2)) (else (set! b 2))) (set! a -1) a) -1)
    (itst '(let ((a 0) (b 3))
	     (call-with-current-continuation
	      (lambda (break)
		(set! b 3)))
	     (set! a -1) a) -1)
    (itst '(let ((a 0) (b 3))
	     (call-with-current-continuation
	      (lambda (break)
		(if (> b 2) (break))
		(set! b 3)))
	     (set! a -1) a) -1)
    (itst '(let ((a 0)) a) 0)
    (btst '(do ((i 0 (+ 1 i))) ((= i 3))) #f)
    (btst '(let ((a 0)) (do ((i 0 (+ 1 i)) (j 3)) ((= i 3)) (set! a (+ 1 a)))) #f)
    (btst '(let ((a 0)) (do ((i 0 (+ 1 i)) (j 3)) ((= i 3)) (set! a (+ 1 a)))) #f)
    (itst '(let ((a 0)) (do ((i 0 (+ 1 i)) (j 3)) ((= i 3) j) (set! a (+ 1 a)))) 3)
    
    (let ((j 1))
      (run
       (do ((i 0 (+ i 1)))
	   ((= i 3))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 1 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ i 1))
	    (k 1 (+ k 2)))
	   ((= i 3))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 2 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ i 1)))
	   ((= 3 i))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 2 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= 3 i))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 3 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ 1 i)))
	   ((>= i 3))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 4 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= j 2))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 5 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ i 2)))
	   ((= i 4))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 6 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((k 1 (+ k 2))
	    (i 0 (+ i 1)))
	   ((= i 3))
	 (set! j i)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 7 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((k 0 (+ k 1))
	    (i 6 (- i 1)))
	   ((= i 3))
	 (set! j k)))
      (if (not (= j 2)) (snd-display #__line__ ";loop 8 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ i 1)))
	   ((= i 3))
	 (set! j i))
       (set! j (+ j 1)))
      (if (not (= j 3)) (snd-display #__line__ ";loop 9 j=~A" j)))
    
    (let ((j 1))
      (run
       (do ((i 0 (+ i 1)))
	   ((= i 3))
	 (do ((k 0 (+ k 1)))
	     ((= k 3))
	   (set! j (+ i k)))))
      (if (not (= j 4)) (format #t ";loop 10 j=~A" j)))
    
    
    (etst '(do ((i 0 (+ i 0.5)) (j 0 (+ 1 j))) ((>= j 3)) (display i)))
    
    (itst '(let ((a 32)) (let ((a 3)) (set! a 4)) a) 32)
    
    (set! int-var 32)
    (itst '(call-with-current-continuation
	    (lambda (return)
	      (let ((a 1))
		(if (even? a) (return a))
		12)))
	  12)
    (itst '(call-with-current-continuation
	    (lambda (return)
	      (let ((a 1))
		(if (odd? a) (return a))
		(set! int-var 12)
		12)))
	  1)
    (if (not (= int-var 32)) (snd-display #__line__ ";call/cc didn't exit? ~A" int-var))
    (itst '(call-with-current-continuation
	    (lambda (return)
	      (let ((a 1))
		(return a)
		(set! int-var 12)
		12)))
	  1)
    (if (not (= int-var 32)) (snd-display #__line__ ";call/cc 1 didn't exit? ~A" int-var))
    
    (set! dbl-var 32.0)
    (ftst '(call-with-current-continuation
	    (lambda (return)
	      (let ((a 1.0))
		(if (> a 2) (return a))
		12.0)))
	  12.0)
    (ftst '(call-with-current-continuation
	    (lambda (return)
	      (let ((a 1.0))
		(if (not (= a 0.0)) (return a))
		(set! dbl-var 12.0)
		12.0)))
	  1.0)
    (if (not (= dbl-var 32.0)) (snd-display #__line__ ";call/cc dbl didn't exit? ~A" dbl-var))
    (ftst '(call-with-current-continuation
	    (lambda (return)
	      (let ((a 1.0))
		(return a)
		(set! dbl-var 12.0)
		12.0)))
	  1.0)
    (if (not (= dbl-var 32.0)) (snd-display #__line__ ";call/cc dbl 1 didn't exit? ~A" dbl-var))
    (ftsta '(lambda (y)
	      (if (> y 0.0)
		  (call-with-current-continuation
		   (lambda (return)
		     (let ((a 1.0))
		       (if (> y 0.0)
			   (+ y a)
			   (begin
			     (return a)
			     (set! dbl-var 12.0)
			     12.0)))))))
	   1.0
	   2.0)
    (if (not (= dbl-var 32.0)) (snd-display #__line__ ";call/cc dbl 1 didn't exit? ~A" dbl-var))
    (ftsta '(lambda (y)
	      (call-with-current-continuation
	       (lambda (return)
		 (let ((a 1.0))
		   (if (> y 0.0)
		       (+ y a)
		       (begin
			 (return a)
			 (set! dbl-var 12.0)
			 12.0))))))
	   -1.0
	   1.0)
    (if (not (= dbl-var 32.0)) (snd-display #__line__ ";call/cc dbl 1 didn't exit? ~A" dbl-var))
    
    (set! str-var "")
    (btst '(let ((a 1)
		 (b 1))
	     (let ((cont1 #f)
		   (cont2 #f))
	       (call-with-current-continuation
		(lambda (x) (set! cont1 x)))
	       (set! a (+ a 2))
	       (set! str-var (string-append str-var "a"))
	       (if cont2
		   (cont2)
		   (begin
		     (call-with-current-continuation
		      (lambda (x) 
			(set! cont2 x)
			(set! b (+ b 1))
			(set! str-var (string-append str-var "b"))))
		     (set! b (+ b 2))
		     (set! str-var (string-append str-var "!"))
		     (if (< b 6) (cont1) #f)))))
	  #f)
    (if (not (string=? str-var "ab!a!")) (snd-display #__line__ ";two continuations: ~A" str-var))
    
    (set! str-var "")
    (run-eval
     '(let ((a 1))
	(call-with-current-continuation
	 (lambda (x) (set! cont1 x)))
	(set! a (+ a 1))
	(set! str-var (string-append str-var (number->string gv)))
	(set! gv (+ gv 2))
	(set! str-var (string-append str-var " "))
	(if (and cont2 
		 (< a 10))
	    (cont2))
	(let ((b 1))
	  (call-with-current-continuation
	   (lambda (x) (set! cont2 x)))
	  (set! b (+ b 1))
	  (set! str-var (string-append str-var (number->string b)))
	  (if (and cont1 
		   (< b 6))
	      (cont1)))))
    (if (not (string=? str-var "1 23 35 47 59 6")) (snd-display #__line__ ";cont2 trouble: ~A" str-var))
    (set! str-var "hi")
    (if (not (keyword? (run-eval '(if (even? 2) :hi :ho)))) 
	(snd-display #__line__ ";run -> key: ~A" (run-eval '(if (even? 2) :hi :ho))))
    (if (not (vct? (run-eval '(if (odd? 2) (make-vct 3) (make-vct 2))))) 
	(snd-display #__line__ ";run -> vct ~A" (run-eval '(if (odd? 2) (make-vct 3) (make-vct 2)))))
    
    (itst '(* 1 1 1) 1)
    (itst '(+ 0 0 0) 0)
    (itst '(+ 2 '3) 5)
    (ftst '(+ 2.0 '3.1) 5.1)
    (btst '(and #t '#t) #t)
    (itst '(+ 2 (quote 3)) 5)
    (etst '(+ 2 '(+ 1 2)))
    (etst '(* '#f))
    (etst '(* '"hihi"))
    (ftsta '(lambda (y) (+ y '3.1)) 1.2 4.3)
    (ctst '(quote #\a) #\a)
    (ctst '#\a #\a)
    (itst '3 3)
    (ftst '3.0 3.0)
    (btst '#f #f)
    
    (btst '(vct? global-v) #t)
    (btst '(vct? 1) #f)
    (btst '(eq? global-v global-v) #t)
    (btst '(eqv? global-v global-v) #t)
    (btst '(equal? global-v global-v) #t)
    (btst '(eq? global-v global-v1) #f)
    (btst '(eqv? global-v global-v1) #t)
    (btst '(equal? global-v global-v1) #t)
    (vct-set! global-v1 2 2.0)
    (btst '(eq? global-v global-v1) #f)
    (btst '(eqv? global-v global-v1) #f)
    (btst '(equal? global-v global-v1) #f)
    
    (let ((val (run-eval '(let ((a (make-vct 3))) (vct-set! a 0 (/ .3 .2)) (vct-ref a 0)))))
      (if (fneq val 1.5) (snd-display #__line__ ";run-eval of trailing non-int in vct-set! (1): ~A" val)))
    (let ((val (run-eval '(let ((a (make-vct 3)) (b .3)) (vct-set! a 0 (/ b 2)) (vct-ref a 0)))))
      (if (fneq val .15) (snd-display #__line__ ";run-eval of trailing non-int in vct-set! (2): ~A" val)))
    (let ((val (run-eval '(let ((a (make-frame 3)) (b .3)) (frame-set! a 0 (/ b .2)) (frame-ref a 0)))))
      (if (fneq val 1.5) (snd-display #__line__ ";run-eval of trailing non-int in frame-set! (1): ~A" val)))
    
    (btst '(char? #\a) #t)
    (btst '(char? 3) #f)
    (btst '(char? "hiho") #f)
    (btst '(char? (integer->char 97)) #t)
    (btst '(char? #t) #f)
    (btsta '(lambda (y) (char? (integer->char (inexact->exact y)))) 97 #t)
    
    (btst '(char>? #\a #\b) #f)
    (btst '(char>? c-var #\b) #f)
    (btst '(char>? #\b #\b) #f)
    (btst '(char>? #\b #\a) #t)
    (btst '(char>? #\b c-var) #t)
    (btst '(char>? #\c #\b #\a) #t)
    (btst '(char>? #\c #\b c-var) #t)
    (btsta '(lambda (y) (char>? (integer->char (inexact->exact y)) #\b)) 97 #f)
    (btsta '(lambda (y) (char>? (integer->char (inexact->exact y)) #\b)) (char->integer #\c) #t)
    
    (btst '(char>=? #\a #\b) #f)
    (btst '(char>=? c-var #\b) #f)
    (btst '(char>=? #\b #\b) #t)
    (btst '(char>=? #\b #\a) #t)
    (btst '(char>=? #\b c-var) #t)
    (btst '(char>=? #\c #\b #\a) #t)
    (btst '(char>=? #\c #\b #\b) #t)
    (btst '(char>=? #\c #\b c-var) #t)
    (btst '(char>=? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char>=? (integer->char (inexact->exact y)) #\b)) 97 #f)
    (btsta '(lambda (y) (char>=? (integer->char (inexact->exact y)) #\b)) (char->integer #\c) #t)
    
    (btst '(char=? #\a #\b) #f)
    (btst '(char=? c-var #\b) #f)
    (btst '(char=? #\b #\b) #t)
    (btst '(char=? #\b #\a) #f)
    (btst '(char=? #\b c-var) #f)
    (btst '(char=? #\c #\b #\a) #f)
    (btst '(char=? #\c #\b #\b) #f)
    (btst '(char=? #\c #\b c-var) #f)
    (btst '(char=? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char=? (integer->char (inexact->exact y)) #\a)) 97 #t)
    (btsta '(lambda (y) (char=? (integer->char (inexact->exact y)) #\b)) (char->integer #\c) #f)
    (btst '(char=? #\+ #\+) #t)
    (btst '(char=? #\space #\space) #t)
    (btst '(char=? #\newline #\+) #f)
    
    (btst '(char<=? #\a #\b) #t)
    (btst '(char<=? c-var #\b) #t)
    (btst '(char<=? #\b #\b) #t)
    (btst '(char<=? #\b #\a) #f)
    (btst '(char<=? #\b c-var) #f)
    (btst '(char<=? #\c #\b #\a) #f)
    (btst '(char<=? #\c #\b #\b) #f)
    (btst '(char<=? #\c #\b c-var) #f)
    (btst '(char<=? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char<=? (integer->char (inexact->exact y)) #\b)) 97 #t)
    (btsta '(lambda (y) (char<=? (integer->char (inexact->exact y)) #\b)) (char->integer #\c) #f)
    
    (btst '(char<? #\a #\b) #t)
    (btst '(char<? c-var #\b) #t)
    (btst '(char<? #\b #\b) #f)
    (btst '(char<? #\b #\a) #f)
    (btst '(char<? #\b c-var) #f)
    (btst '(char<? #\c #\b #\a) #f)
    (btst '(char<? #\c #\b #\b) #f)
    (btst '(char<? #\c #\b c-var) #f)
    (btst '(char<? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char<? (integer->char (inexact->exact y)) #\b)) 97 #t)
    (btsta '(lambda (y) (char<? (integer->char (inexact->exact y)) #\b)) (char->integer #\c) #f)
    (btst '(char<? #\a #\b #\c) #t)
    
    (etst '(char=? #f))
    (etst '(char=? 1.0))
    (etst '(char=? 1.0 2.0))
    (etst '(char=? '(asd) #\c))
    
    (btst '(char-ci<? #\a #\B) #t)
    (btst '(char-ci<? c-var #\b) #t)
    (btst '(char-ci<? #\B #\b) #f)
    (btst '(char-ci<? #\b #\A) #f)
    (btst '(char-ci<? #\B c-var) #f)
    (btst '(char-ci<? #\c #\B #\a) #f)
    (btst '(char-ci<? #\c #\b #\b) #f)
    (btst '(char-ci<? #\C #\b c-var) #f)
    (btst '(char-ci<? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char-ci<? (integer->char (inexact->exact y)) #\B)) 97 #t)
    (btsta '(lambda (y) (char-ci<? (integer->char (inexact->exact y)) #\B)) (char->integer #\c) #f)
    (btst '(char-ci<? #\a #\B #\c) #t)
    
    (btst '(char-ci<=? #\a #\B) #t)
    (btst '(char-ci<=? c-var #\b) #t)
    (btst '(char-ci<=? #\B #\b) #t)
    (btst '(char-ci<=? #\c #\B #\a) #f)
    (btst '(char-ci<=? #\C #\b c-var) #f)
    (btst '(char-ci<=? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char-ci<=? (integer->char (inexact->exact y)) #\B)) 97 #t)
    (btsta '(lambda (y) (char-ci<=? (integer->char (inexact->exact y)) #\B)) (char->integer #\c) #f)
    
    (btst '(char-ci>=? #\a #\B) #f)
    (btst '(char-ci>=? c-var #\b) #f)
    (btst '(char-ci>=? #\B #\b) #t)
    (btst '(char-ci>=? #\c #\B #\a) #t)
    (btst '(char-ci>=? #\C #\b c-var) #t)
    (btst '(char-ci>=? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char-ci>=? (integer->char (inexact->exact y)) #\B)) 97 #f)
    (btsta '(lambda (y) (char-ci>=? (integer->char (inexact->exact y)) #\B)) (char->integer #\c) #t)
    
    (btst '(char-ci>? #\a #\B) #f)
    (btst '(char-ci>? c-var #\b) #f)
    (btst '(char-ci>? #\B #\b) #f)
    (btst '(char-ci>? #\c #\B #\a) #t)
    (btst '(char-ci>? #\C #\b c-var) #t)
    (btst '(char-ci>? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char-ci>? (integer->char (inexact->exact y)) #\B)) 97 #f)
    (btsta '(lambda (y) (char-ci>? (integer->char (inexact->exact y)) #\B)) (char->integer #\c) #t)
    
    (btst '(char-ci=? #\a #\B) #f)
    (btst '(char-ci=? c-var #\b) #f)
    (btst '(char-ci=? #\B #\b) #t)
    (btst '(char-ci=? #\c #\B #\a) #f)
    (btst '(char-ci=? #\C #\b c-var) #f)
    (btst '(char-ci=? #\c #\b c-var #\b) #f)
    (btsta '(lambda (y) (char-ci=? (integer->char (inexact->exact y)) #\B)) 97 #f)
    (btsta '(lambda (y) (char-ci=? (integer->char (inexact->exact y)) #\B)) (char->integer #\c) #f)
    
    (btst '(char-alphabetic? #\a) #t)
    (btst '(char-alphabetic? #\T) #t)
    (btst '(char-alphabetic? #\+) #f)
    (btst '(char-alphabetic? #\8) #f)
    (btsta '(lambda (y) (char-alphabetic? (integer->char (inexact->exact y)))) (exact->inexact (char->integer #\8)) #f)
    
    (btst '(char-numeric? #\a) #f)
    (btst '(char-numeric? #\T) #f)
    (btst '(char-numeric? #\+) #f)
    (btst '(char-numeric? #\8) #t)
    (btsta '(lambda (y) (char-numeric? (integer->char (inexact->exact y)))) (exact->inexact (char->integer #\8)) #t)
    
    (btst '(char-lower-case? #\a) #t)
    (btst '(char-lower-case? #\T) #f)
    (btst '(char-lower-case? #\+) #f)
    (btst '(char-lower-case? #\8) #f)
    (btsta '(lambda (y) (char-lower-case? (integer->char (inexact->exact y)))) (exact->inexact (char->integer #\B)) #f)
    
    (btst '(char-upper-case? #\a) #f)
    (btst '(char-upper-case? #\T) #t)
    (btst '(char-upper-case? #\+) #f)
    (btst '(char-upper-case? #\8) #f)
    (btsta '(lambda (y) (char-upper-case? (integer->char (inexact->exact y)))) (exact->inexact (char->integer #\B)) #t)
    
    (btst '(char-whitespace? #\a) #f)
    (btst '(char-whitespace? #\T) #f)
    (btst '(char-whitespace? #\space) #t)
    (btst '(char-whitespace? #\8) #f)
    (btsta '(lambda (y) (char-whitespace? (integer->char (inexact->exact y)))) (exact->inexact (char->integer #\B)) #f)
    
    (ctst '(char-upcase #\a) #\A)
    (ctsta '(lambda (y) (char-upcase (integer->char (inexact->exact y)))) 97.0 #\A)
    (ctst '(char-downcase #\A) #\a)
    (ctsta '(lambda (y) (char-downcase (integer->char (inexact->exact y)))) 65.0 #\a)
    (ctst '(integer->char 65) #\A)
    (itst '(char->integer #\A) 65)
    (itst '(char->integer #\newline) 10)
    (ctst '(integer->char 48) #\0)
    
    (ctst '(let ((cv #\a)) (set! cv #\b) cv) #\b)
    (ctst '(let ((cv #\a)) (set! c-var #\b) cv) #\a)
    (if (not (char=? c-var #\b)) (snd-display #__line__ ";set c-var: ~A" c-var))
    (ctsta '(lambda (y) (let ((cv (integer->char (inexact->exact y)))) (set! cv #\b) cv)) 97 #\b)
    (ctsta '(lambda (y) (let ((cv (integer->char (inexact->exact y)))) (set! c-var cv) cv)) 97 #\a)
    (if (not (char=? c-var #\a)) (snd-display #__line__ ";set c-var: ~A" c-var))
    
    (btst '(string? "hi") #t)
    (btst '(string? 3) #f)
    (btst '(string? #\a) #f)
    (btst '(string? str-var) #t)
    (btsta '(lambda (y) (string? "hiho")) 1 #t)
    
    (stst '(string #\a #\b) "ab")
    (stst '(string #\a #\b (integer->char 65)) "abA")
    (stst '(string) "")
    (stst '(string #\a) "a")
    (ststa '(lambda (y) (string #\a #\!)) 1 "a!")
    (etst '(string 1))
    (etst '(string "hi"))
    (stst '(if #t "hi" "ho") "hi")
    (stst '(if #f "hi" "ho") "ho")
    (ststa '(lambda (y) (if (> y 1.0) "hi" "ho")) 0.0 "ho")
    (itst '(if #t 3 2) 3)
    (itst '(if #f 3 2) 2)
    (itsta '(lambda (y) (if (> y 1.0) 3 2)) 0.0 2)
    (ftst '(if #t 1.5 2.5) 1.5)
    (ftst '(if #f 1.5 2.5) 2.5)
    (ftsta '(lambda (y) (if (> y 1.0) 3.1 2.1)) 0.0 2.1)
    (btst '(if #f #f #t) #t)
    (btst '(let ((v (make-vct 3))) (vct? (if #t v))) #t)
    (btst '(let ((v (make-vector 3 1.0))) (vector? (if #t v))) #t)
    (btst '(let ((v (make-vector 3 1))) (vector? (if #t v))) #t)
    (btst '(let ((v (make-vector 3))) (vector? (if #t v))) #t)
    (etst '(let ((v (make-vector 3 (make-vct 3)))) (vector? (if #t v))))
    (btsta '(lambda (y) (let ((v (make-vct 3))) (vct? (if (> y 1.0) v)))) 2.0 #t)
    
    (itst '(string-length "abc") 3)
    (itst '(string-length str-var) 2)
    (itsta '(lambda (y) (string-length (string #\a (integer->char (inexact->exact y))))) 65 2)
    
    (stst '(string-copy "hi") "hi")
    (stst '(string-copy (string #\a #\b)) "ab")
    (stst '(string-copy str-var) "hi")
    (ststa '(lambda (y) (string-copy (string (integer->char (inexact->exact y)) #\!))) 65 "A!")
    (etst '(string-copy #\a))
    (etst '(string-copy))
    (etst '(string-copy 123))
    
    (stst '(let ((str "asdfg")) (string-fill! str #\x) str) "xxxxx")
    (stst '(let ((str "asdf")) (string-set! str 1 #\x) str) "axdf")
    (ctst '(string-ref "asdf" 2) #\d)
    (etst '(string-ref 123))
    (etst '(string-ref "hi" "ho"))
    (etst '(string-set! "hi" 1 "c"))
    (etst '(string-set! "hi" 1 #\b))
    (etst '(string-fill! "hi" "ho"))
    (etst '(string-fill! "hi" #\b))
    (stst '(make-string 3) "   ")
    (stst '(make-string 3 #\a) "aaa")
    
    (set! str-var "a")
    (btst '(string>? "a" "b") #f)
    (btst '(string>? str-var "b") #f)
    (btst '(string>? "b" "b") #f)
    (btst '(string>? "b" "a") #t)
    (btst '(string>? "b" str-var) #t)
    (btst '(string>? "c" "b" "a") #t)
    (btst '(string>? "c" "b" str-var) #t)
    (btsta '(lambda (y) (string>? (string (integer->char (inexact->exact y))) "b")) 97 #f)
    (btsta '(lambda (y) (string>? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #t)
    
    (btst '(string>=? "a" "b") #f)
    (btst '(string>=? str-var "b") #f)
    (btst '(string>=? "b" "b") #t)
    (btst '(string>=? "b" "a") #t)
    (btst '(string>=? "b" str-var) #t)
    (btst '(string>=? "c" "b" "a") #t)
    (btst '(string>=? "c" "b" "b") #t)
    (btst '(string>=? "c" "b" str-var) #t)
    (btst '(string>=? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string>=? (string (integer->char (inexact->exact y))) "b")) 97 #f)
    (btsta '(lambda (y) (string>=? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #t)
    
    (btst '(string=? "a" "b") #f)
    (btst '(string=? str-var "b") #f)
    (btst '(string=? "b" "b") #t)
    (btst '(string=? "b" "a") #f)
    (btst '(string=? "b" str-var) #f)
    (btst '(string=? "c" "b" "a") #f)
    (btst '(string=? "c" "b" "b") #f)
    (btst '(string=? "c" "b" str-var) #f)
    (btst '(string=? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string=? (string (integer->char (inexact->exact y))) "a")) 97 #t)
    (btsta '(lambda (y) (string=? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #f)
    (btst '(string=? "+" "+") #t)
    
    (btst '(string<=? "a" "b") #t)
    (btst '(string<=? str-var "b") #t)
    (btst '(string<=? "b" "b") #t)
    (btst '(string<=? "b" "a") #f)
    (btst '(string<=? "b" str-var) #f)
    (btst '(string<=? "c" "b" "a") #f)
    (btst '(string<=? "c" "b" "b") #f)
    (btst '(string<=? "c" "b" str-var) #f)
    (btst '(string<=? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string<=? (string (integer->char (inexact->exact y))) "b")) 97 #t)
    (btsta '(lambda (y) (string<=? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #f)
    
    (btst '(string<? "a" "b") #t)
    (btst '(string<? str-var "b") #t)
    (btst '(string<? "b" "b") #f)
    (btst '(string<? "b" "a") #f)
    (btst '(string<? "b" str-var) #f)
    (btst '(string<? "c" "b" "a") #f)
    (btst '(string<? "c" "b" "b") #f)
    (btst '(string<? "c" "b" str-var) #f)
    (btst '(string<? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string<? (string (integer->char (inexact->exact y))) "b")) 97 #t)
    (btsta '(lambda (y) (string<? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #f)
    (btst '(string<? "a" "b" "c") #t)
    
    (etst '(string=? #f))
    (etst '(string=? 1.0))
    (etst '(string=? 1.0 2.0))
    
    (btst '(string-ci<? "a" "b") #t)
    (btst '(string-ci<? str-var "b") #t)
    (btst '(string-ci<? "b" "b") #f)
    (btst '(string-ci<? "b" "a") #f)
    (btst '(string-ci<? "b" str-var) #f)
    (btst '(string-ci<? "c" "b" "a") #f)
    (btst '(string-ci<? "c" "b" "b") #f)
    (btst '(string-ci<? "c" "b" str-var) #f)
    (btst '(string-ci<? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string-ci<? (string (integer->char (inexact->exact y))) "b")) 97 #t)
    (btsta '(lambda (y) (string-ci<? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #f)
    (btst '(string-ci<? "a" "b" "c") #t)
    
    (btst '(string-ci<=? "a" "b") #t)
    (btst '(string-ci<=? str-var "b") #t)
    (btst '(string-ci<=? "b" "b") #t)
    (btst '(string-ci<=? "c" "b" "a") #f)
    (btst '(string-ci<=? "c" "b" str-var) #f)
    (btst '(string-ci<=? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string-ci<=? (string (integer->char (inexact->exact y))) "b")) 97 #t)
    (btsta '(lambda (y) (string-ci<=? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #f)
    
    (btst '(string-ci>=? "a" "b") #f)
    (btst '(string-ci>=? str-var "b") #f)
    (btst '(string-ci>=? "b" "b") #t)
    (btst '(string-ci>=? "c" "b" "a") #t)
    (btst '(string-ci>=? "c" "b" str-var) #t)
    (btst '(string-ci>=? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string-ci>=? (string (integer->char (inexact->exact y))) "b")) 97 #f)
    (btsta '(lambda (y) (string-ci>=? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #t)
    
    (btst '(string-ci>? "a" "b") #f)
    (btst '(string-ci>? str-var "b") #f)
    (btst '(string-ci>? "b" "b") #f)
    (btst '(string-ci>? "c" "b" "a") #t)
    (btst '(string-ci>? "c" "b" str-var) #t)
    (btst '(string-ci>? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string-ci>? (string (integer->char (inexact->exact y))) "b")) 97 #f)
    (btsta '(lambda (y) (string-ci>? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #t)
    
    (btst '(string-ci=? "a" "b") #f)
    (btst '(string-ci=? str-var "b") #f)
    (btst '(string-ci=? "b" "b") #t)
    (btst '(string-ci=? "c" "b" "a") #f)
    (btst '(string-ci=? "c" "b" str-var) #f)
    (btst '(string-ci=? "c" "b" str-var "b") #f)
    (btsta '(lambda (y) (string-ci=? (string (integer->char (inexact->exact y))) "b")) 97 #f)
    (btsta '(lambda (y) (string-ci=? (string (integer->char (inexact->exact y))) "b")) (char->integer #\c) #f)
    (set! str-var "hi")
    
    (stst '(let ((str "asdfg")) (string-fill! str #\x) str) "xxxxx")
    (stst '(begin (set! str-var "ho") str-var) "ho")
    (if (not (string=? str-var "ho")) (snd-display #__line__ ";global str not reset upon exit? ~A" str-var))
    (ststa '(lambda (y) (begin (set! str-var (string #\c #\b #\a)) str-var)) 0 "cba")
    (if (not (string=? str-var "cba")) (snd-display #__line__ ";global str not reset upon lambda exit? ~A" str-var))
    (stst '(let ((str (make-string 4 #\a))) str) "aaaa")
    (stst '(let ((str (make-string 4 #\a))) (string-set! str 0 #\b) str) "baaa")
    (itst '(let ((str (make-string 4 #\a))) (string-set! str 0 #\b) (string-length str)) 4)
    (itsta '(lambda (y) (let ((str (make-string 4 #\a))) (string-set! str 0 #\b) (string-length str))) 0 4)
    (stst '(let ((str (make-string 4 #\a))) (string-set! str 0 #\b) (set! str-var "a") (set! str (string (string-ref str-var 0))) str) "a")
    
    (stst '(substring "012345" 0 1) "0")
    (stst '(substring "012345" 0 0) "")
    (stst '(substring "012345" 1 4) "123")
    (set! str-var "012345")
    (stst '(substring str-var 1 4) "123")
    (etst '(substring "asdfg"))
    (etst '(substring "asdfg" "hi"))
    (etst '(substring "asdfg" 0 3 123))
    (etst '(substring "hi" 3 4))
    (etst '(substring "hi" 3 2))
    (ststa '(lambda (y) (substring "012345" 1 (inexact->exact y))) 4 "123")
    (ststa '(lambda (y) (substring "012345" (inexact->exact y) 1)) 1 "")
    (ststa '(lambda (y) (substring "hi" 2 (inexact->exact y))) 4 "") ; should send error
    (ststa '(lambda (y) (substring (make-string 6 (integer->char (inexact->exact y))) 2 4)) 65 "AA")
    (ststa '(lambda (y) (let ((str (make-string 6 (integer->char (inexact->exact y))))) (string-set! str 0 #\b) (substring str 0 2))) 65 "bA")
    (stst '(string-append "a" "bc") "abc")
    (stst '(string-append "hi") "hi")
    (stst '(string-append "01" "2" "345") "012345")
    (set! str-var "01")
    (stst '(string-append str-var "2" "345") "012345")
    (btst '(string? (string-append)) #t)
    (stst '(string-append str-var) str-var)
    (ststa '(lambda (y) (string-append str-var (string (integer->char (inexact->exact y)) #\1 #\2) "345")) 48 "01012345")
    (etst '(make-string "hi"))
    (etst '(make-string 3 3.14))
    
    (stst '(number->string 1) "1")
    (stst '(number->string 3 2) "11")
    (stst '(number->string 1.5) "1.5")
    (stst '(number->string 1.5 10) "1.5") ; actually radix is ignored here by scheme
    (ststa '(lambda (y) (number->string y)) 1.5 "1.5")
    (ststa '(lambda (y) (number->string (inexact->exact y))) 1.0 "1")
    (ststa '(lambda (y) (number->string y 10)) 1.0 "1.0")
    (ststa '(lambda (y) (number->string (inexact->exact y) 2)) 1.0 "1")
    (ststa '(lambda (y) (number->string 3 (inexact->exact y))) 2.0 "11")
    
    (etst '(snd-print #f))
    (etst '(snd-warning #f))
    (etst '(string-ref #f 1))
    (etst '(string-fill! #f #\c))
    (etst '(string-set! #f 1 #\c))
    
    (stst '(format #f "hiho: ~D" 43) "hiho: 43")
    (stst '(format #f "~A: ~A" "hiho" '(3 4)) "hiho: (3 4)")
    (stst '(format #f "~A: ~A" (> 2 3) (make-vct 2 .1)) "#f: #<vct[len=2]: 0.100 0.100>")
    (stst '(format #f "hi~16Tho") "hi              ho")
    (stst '(format #f "~{~D ~}" '(1 2 3)) "1 2 3 ")
    (stst '(clm-print "hiho: ~D" 43) "hiho: 43")
    
    (btst '(sampler? "hi") #f)
    (btst '(sampler? #t) #f)
    
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 32.1) (vct-ref v 1)) 32.1)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 32) (vct-ref v 1)) 32.0)
    (ftst '(let ((v (make-vector 3 0.0))) (vector-set! v 1 32.1) (vector-ref v 1)) 32.1)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 3.0) (vct-scale! v 2.0) (vct-ref v 1)) 6.0)
    (btst '(let ((v (make-vct 3))) (vct? (vct-scale! v 2.0))) #t)
    (ftst '(let ((v (make-vct 3))) (set! int-var 2) (vct-set! v 1 3.0) (vct-scale! v int-var) (vct-ref v 1)) 6.0)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 3.0) (vct-add! v v) (vct-ref v 1)) 6.0)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 3.0) (vct+ v v) (vct-ref v 1)) 6.0)
    (btst '(let ((v (make-vct 3))) (vct? (vct-add! v v))) #t)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 3.0) (vct-multiply! v v) (vct-ref v 1)) 9.0)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 3.0) (vct* v v) (vct-ref v 1)) 9.0)
    (btst '(let ((v (make-vct 3))) (vct? (vct-multiply! v v))) #t)
    (ftst '(let ((v (make-vct 3))) (vct-set! v 1 3.0) (vct-subtract! v v) (vct-ref v 1)) 0.0)
    (btst '(let ((v (make-vct 3))) (vct? (vct-subtract! v v))) #t)
    (ftst '(let ((v (make-vct 3))) (set! (vct-ref v 2) 3.0) (vct-offset! v 17) (vct-ref v 2)) 20.0)
    (ftst '(let ((v (make-vct 3))) (set! (vct-ref v 2) 3.0) (vct+ v 17) (vct-ref v 2)) 20.0)
    (ftst '(let ((v (make-vct 3))) (set! (vct-ref v 2) 3.0) (vct+ 17 v) (vct-ref v 2)) 20.0)
    (btst '(let ((v (make-vct 3))) (vct? (vct-offset! v 17))) #t)
    (ftst '(let ((v (make-vct 3))) (set! (vct-ref v 0) 3.0) (vct-fill! v 7) (vct-ref v 0)) 7.0)
    (btst '(let ((v (make-vct 3))) (vct? (vct-fill! v 7))) #t)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 3.14) (let ((v1 (vct-copy v))) (vct-ref v1 2))) 3.14)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-ref (vct-scale! v 2.0) 1)) 2.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-ref (vct* v 2.0) 1)) 2.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-ref (vct* 2.0 v) 1)) 2.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-ref (vct-scale! (vct-add! v v) 2.0) 1)) 4.0)
    (ftst '(let ((v (make-vct 3))) (set! (vct-ref v 1) 1.0) (vct-ref v 1)) 1.0)
    (ftst '(let ((v (make-vct 3)) (ind 0)) (set! (vct-ref v ind) 2.0) (vct-ref v ind)) 2.0)
    (ftst '(vct-ref (vct .1 .2) 0) .1)
    (ftst '(vct-ref (vct .1 .2 .3 .4) 2) .3)
    (btst '(let ((v0 (make-vct 4)) (v1 (make-vct 4))) (vct? (mus-fft v0 v1))) #t)
    (btst '(let ((v0 (make-vct 4)) (v1 (make-vct 4))) (vct? (mus-fft v0 v1 4))) #t)
    (btst '(let ((v0 (make-vct 4)) (v1 (make-vct 4))) (vct? (mus-fft v0 v1 4 1))) #t)
    (btst '(let ((v0 (make-vct 4)) (v1 (make-vct 4))) (vct? (fft v0 v1))) #t)
    (btst '(let ((v0 (make-vct 4)) (v1 (make-vct 4))) (vct? (fft v0 v1 1))) #t)
    (btst '(let ((v0 (make-vct 4))) (vct? (clear-array v0))) #t)
    
    (let ((x 0.0))
      (run (set! x (vct-ref (vct 0 1 2 3) 2)))
      (if (fneq x 2.0) (snd-display #__line__ ";vct with ints in run: ~A" x)))
    
    (let ((v1 (make-vct 32 1.0)))
      (run
       (lambda ()
	 (if (> (vct-ref v1 0) 2.0)
	     (vct-scale! v1 0.5)))))
    (let ((g1 (make-oscil)))
      (run
       (lambda ()
	 (if (square-wave? g1)
	     g1))))
    
    (let ((v (vct 1.0 2.0 3.0)))
      (let ((val (run (v 1))))
	(if (fneq val 2.0) (snd-display #__line__ ";run (v 1): ~A" val))))
    (let ((v (vector 1.0 2.0 3.0)))
      (let ((val (run (v 1))))
	(if (fneq val 2.0) (snd-display #__line__ ";run (v 1) as vector: ~A" val))))
    (let ((v (vct 1.0 2.0 3.0))) 
      (run (set! (v 1) 0.5))
      (if (fneq (vct-ref v 1) 0.5) (snd-display #__line__ ";run set (v 1): ~A" (vct-ref v 1))))
    (let ((v (vector 1.0 2.0 3.0))) 
      (let ((val (run (set! (v 1) 0.5) (vector-ref v 1))))
	(if (fneq val 0.5) (snd-display #__line__ ";run vector-set (v 1): ~A" val))))
    
    (btst '(let ((sd (make-sound-data 2 2))) (sound-data? sd)) #t)
    (btst '(sound-data? "hi") #f)
    (btst '(sound-data? (make-vct 3)) #f)
    (ftst '(let ((sd (make-sound-data 2 2))) (sound-data-set! sd 0 1 .3) (sound-data-ref sd 0 1)) .3)
    (ftst '(let ((sd (make-sound-data 2 2))) (sound-data-set! sd 0 1 3) (sound-data-ref sd 0 1)) 3.0)
    (ftst '(let ((sd (make-sound-data 2 2))) (set! (sound-data-ref sd 0 1) .3) (sound-data-ref sd 0 1)) .3)
    (itst '(let ((sd (make-sound-data 2 3))) (sound-data-chans sd)) 2)
    (itst '(let ((sd (make-sound-data 2 3))) (sound-data-length sd)) 3)
    (btst '(let ((sd (make-sound-data 2 3))) (equal? sd sd)) #t)
    (btst '(let ((sd (make-sound-data 2 3))) (eq? sd sd)) #t)
    (btst '(let ((sd (make-sound-data 2 3)) (sd1 (make-sound-data 2 3))) (equal? sd sd1)) #t)
    (btst '(let ((sd (make-sound-data 2 3)) (sd1 (make-sound-data 2 3))) (sound-data-set! sd 0 0 .1) (equal? sd sd1)) #f)
    (btst '(let ((sd (make-sound-data 2 3)) (sd1 (make-sound-data 2 4))) (equal? sd sd1)) #f)
    (btst '(let ((sd (make-sound-data 2 3)) (sd1 (make-sound-data 2 3))) (eq? sd sd1)) #f)
    
    (catch 'cannot-parse
	   (lambda ()
	     (let ((val (run-eval '(lambda ()
				     (let ((our-val 0.0))
				       (do ((i 0 (+ 1 i)))
					   ((= i 32) our-val)
					 (let ((v (make-vct 3))
					       (sd (make-sound-data 1 4))
					       (str (make-string 3 #\c)))
					   (if (not (string=? str "ccc"))
					       (snd-print (format #f ";make-string: ~A" str)))
					   (vct-set! v 0 .1)
					   (sound-data-set! sd 0 1 .2)
					   (set! our-val (+ our-val (vct-ref v 0) (sound-data-ref sd 0 1))))))))))
	       (if (or (not (number? val))
		       (fneq val 9.6))
		   (snd-display #__line__ ";make-all val: ~A" val))))
	   (lambda args
	     (snd-display #__line__ ";can't parse sound-data example (format)")))
    
    (itst '(case 1 ((1) 4) ((2 3) 5)) 4)
    (stst '(case 2 ((1) "hi") ((2 3) "ho")) "ho")
    (itsta '(lambda (y) (declare (y integer)) (case y ((1) (let ((a y)) (+ a 1))) ((2 3 4) (* y 2)))) 1 2)
    (itsta '(lambda (y) (declare (y integer)) (case y ((1) (let ((a y)) (+ a 1))) ((2 3 4) (* y 2)))) 3 6)
    (itst '(case 1 ((1) 4) ((2 3) 5) (else 123)) 4)
    (itst '(case 3 ((1) 4) ((2 3) 5) (else 123)) 5)
    (itst '(case 10 ((1) 4) ((2 3) 5) (else 123)) 123)
    (etst '(case 10 ((1) 4) ((2 3) .5) (else 123)))
    (etst '(case 10 ((1) 4) ((2 1.3) 5) (else 123)))
    
    (etst '(let ((a 1)) (if (> a 0) 2 (list 1 2))))
    (etst '(let ((a 1)) (if (> a 0) 2 "hi")))
    (btst '(let ((a 1)) (cond ((> a 0)))) #t)
    (etst '(let ((a 1)) (cond ((> a 0) (list 1 2)))))
    (etst '(let ((a 1)) (cond ((> a 1) 2) ((> a 0) "hi"))))
    (etst '(do ((i 0 (+ 1 i))) ("hi" 3)))
    (etst '(do ((i 0 (+ 1 i))) ((= i 3) (list 1 2)) (+ 1 2)))
    (etst '(do ((i 0 (+ 1 i)) (j 0 (+ 1 i))) ((= i 3)) (hiho 3)))
    (etst '(do ((i 0 (+ 1 i)) (j 0 (+ 1 i)) (k 0 (hiho k))) ((= i 3)) 0))
    (etst '(call/cc (lambda (break) (let ((a 1)) (if (> a 0) (break 3) (break "hi"))))))
    (etst '(call/cc (lambda (break) (let ((a 1)) (if (> a 0) (break 3)) (break "hi")))))
    (btst '(let ((a 1)) (or (> a 1) "hi")) #t)
    (btst '(let ((a 1)) (and (> a 1) "hi")) #f)
    (etst '(let ((v0 (make-vct 1)) (v1 (make-vct 1))) (set! v0 v1)))
    
    (itst '(cond ((> 1 0) 1)) 1)
    (itst '(cond ((> 1 0) 1) ((< 0 1) 2)) 1)
    (itst '(cond ((< 1 0) 1) ((< 0 1) 2)) 2)
    (itst '(cond ((< 1 0) 1) ((> 0 1) 2) (else 3)) 3)
    (itst '(cond ((< 1 0) 1) ((< 0 1) (* 3 2) 2) (else 3)) 2)
    (ftsta '(lambda (y) (cond ((> y 0.0) y) ((< y 0.0) (abs y)) (else (- y 100.0)))) 1.0 1.0)
    (ftsta '(lambda (y) (cond ((> y 0.0) y) ((< y 0.0) (abs y)) (else (- y 100.0)))) -1.0 1.0)
    (ftsta '(lambda (y) (cond ((> y 0.0) y) ((< y 0.0) (abs y)) (else (- y 100.0)))) 0.0 -100.0)
    (ftsta '(lambda (y) (cond ((> y 0.0) y) ((< y 0.0) (abs y)) (else (- y 100.0)))) 1.0 1.0)
    (set! dbl-var 0.0)
    (ftsta '(lambda (y) (cond ((> y 0.0) (let ((a (+ y 2))) (* a 2)))
			      ((< y 0.0) (abs y)) 
			      (else (set! dbl-var 1.0)
				    (if (> dbl-var 0.0)
					(+ y (* dbl-var 2))
					(- y 100.0))))) 
	   1.0 6.0)
    (if (fneq dbl-var 0.0) (snd-display #__line__ ";cond mid dbl (0.0): ~A" dbl-var))
    (ftsta '(lambda (y) (cond ((> y 0.0) (let ((a (+ y 2))) (* a 2)))
			      ((< y 0.0) (abs y)) 
			      (else (set! dbl-var 1.0)
				    (if (> dbl-var 0.0)
					(+ y (* dbl-var 2))
					(- y 100.0))))) 
	   -1.0 1.0)
    (if (fneq dbl-var 0.0) (snd-display #__line__ ";cond dbl (0.0): ~A" dbl-var))
    (ftsta '(lambda (y) (cond ((> y 0.0) (let ((a (+ y 2))) (* a 2)))
			      ((< y 0.0) (abs y)) 
			      (else (set! dbl-var 1.0)
				    (if (> dbl-var 0.0)
					(+ y (* dbl-var 2))
					(- y 100.0))))) 
	   0.0 2.0)
    (if (fneq dbl-var 1.0) (snd-display #__line__ ";cond dbl (1.0): ~A" dbl-var))
    (ststa '(lambda (y) (cond ((> y 0.0) "hi") ((< y 0.0) "ho") (else "ha"))) 1.0 "hi")
    (ststa '(lambda (y) (cond ((> y 0.0) "hi") ((< y 0.0) "ho") (else "ha"))) 0.0 "ha")
    (ststa '(lambda (y) (cond ((> y 0.0) "hi") ((< y 0.0) "ho") (else "ha"))) -1.0 "ho")
    
    (let ((pv (list 123 321))) (run (set! int-var (car pv))))
    (if (not (= int-var 123)) (snd-display #__line__ ";car local pv: ~A" int-var))
    
    (btst '(list? list-var) #t)
    (btst '(list? int-var) #f)
    (btsta '(lambda (y) (list? list-var)) 0.0 #t)
    (btsta '(lambda (y) (list? dbl-var)) 0.0 #f)
    (run (set! int-var (car list-var)))
    (if (not (= int-var 2)) (snd-display #__line__ ";car run lst: ~A" int-var))
    (itsta '(lambda (y) (car list-var)) 0.0 2)
    (itsta '(lambda (y) (cadr list-var)) 0.0 3)
    (itsta '(lambda (y) (caddr list-var)) 0.0 4)
    (itsta '(lambda (y) (cadddr list-var)) 0.0 5)
    (itst '(car list-var) 2)
    (itst '(cadr list-var) 3)
    (itst '(caddr list-var) 4)
    (itst '(cadddr list-var) 5)
    (itst '(list-ref list-var 1) 3)
    (let ((lv (list 321 123))) (run (set! int-var (car lv))))
    (if (not (= int-var 321)) (snd-display #__line__ ";car run local lst: ~A" int-var))
    (let ((lv (list 321 123))) (run (set! int-var (cadr lv))))
    (if (not (= int-var 123)) (snd-display #__line__ ";cadr run local lst: ~A" int-var))
    (let ((lv (list 321 123))) (run (set! int-var (list-ref lv 0))))
    (if (not (= int-var 321)) (snd-display #__line__ ";list-ref 0 run local lst: ~A" int-var))
    (btst '(null? list-var) #f)
    (let ((lv '())) (run (set! int-var (if (null? lv) 1 0))))
    (if (not (= int-var 1)) (snd-display #__line__ ";null? run local lst: ~A" int-var))
    (itst '(length list-var) 4)
    (let ((lv (list 321 123))) (run (set! int-var (length lv))))
    (if (not (= int-var 2)) (snd-display #__line__ ";length run local lst: ~A" int-var))
    
    (itst '(cadr '(3 4)) 4)
    (btst '(null? '()) #t)
    (btst '(null? '(1)) #f)
    (itst '(vector-ref '#(0 1 2) 2) 2)
    (ftst '(vector-ref '#(0.1 1.1 2.1) 1) 1.1)
    
    (let ((val (run-eval '(lambda (v) (declare (v char)) (char->integer v)) #\b)))
      (if (not (= val 98)) (snd-display #__line__ ";char as arg to run: ~A" val)))
    (let ((val (run-eval '(lambda (v) (declare (v integer)) (+ 1 v)) 32)))
      (if (not (= val 33)) (snd-display #__line__ ";integer as arg to run: ~A" val)))
    (let ((val (run-eval '(lambda (v) (declare (v real)) (* v 2)) 1.3)))
      (if (fneq val 2.6) (snd-display #__line__ ";real as arg to run: ~A" val)))
    (let ((val (run-eval '(lambda (v) (declare (v string)) (string-length v)) "hiho")))
      (if (not (= val 4)) (snd-display #__line__ ";string as arg to run: ~A" val)))
    (let ((val (run-eval '(lambda (v) (declare (v boolean)) (not v)) #t)))
      (if val (snd-display #__line__ ";boolean as arg to run: ~A" val)))
    (let ((val (run-eval '(lambda (gen) (declare (gen clm)) (mus-frequency gen)) (make-oscil 440))))
      (if (fneq val 440.0) (snd-display #__line__ ";clm gen as arg to run: ~A" val)))
    (let ((val (run-eval '(lambda (v) (declare (v vct)) (vct-ref v 0)) (make-vct 3 1.5))))
      (if (fneq val 1.5) (snd-display #__line__ ";vct as arg to run: ~A" val)))
    
    (let* ((gen (make-oscil))
	   (val (run (lambda () (mus-generator? gen)))))
      (if (not val) (snd-display #__line__ ";run mus-generator? oscil")))
    (let* ((gen (make-nssb))
	   (val (run (mus-generator? gen))))
      (if (not val) (snd-display #__line__ ";run mus-generator? nssb")))
    (let* ((gen 123)
	   (val (run (lambda () (mus-generator? gen)))))
      (if val (snd-display #__line__ ";run mus-generator? 123")))
    
    (let ((val (run-eval '(lambda (y) (let ((ge (make-env '(0 1 1 1) :length 11))) (env ge))) 0.0)))
      (if (fneq val 1.0) (snd-display #__line__ ";make-env in run: ~A" val)))
    
    (let ((val (run-eval '(lambda (y) (let ((ge (make-env l0111 :length 11))) (env ge))) 0.0)))
      (if (fneq val 1.0) (snd-display #__line__ ";make-env in run with var list: ~A" val)))
    
    (let ((x 0.0))
      (run
       (lambda ()
	 (let ((e (make-env '(0 0 1 1) :length 11)))
	   (env e)
	   (set! x (env e))
	   x)))
      (if (fneq x .1) (snd-display #__line__ ";make-env in run 0: ~A" x)))
    
    (let ((x 0.0)
	  (samps 11)
	  (data (vct 0 0 1 1)))
      (run
       (lambda ()
	 (let ((e (make-env data :length samps)))
	   (env e)
	   (set! x (env e))
	   x)))
      (if (fneq x .1) (snd-display #__line__ ";make-env in run 1: ~A" x)))
    
    (let ((x 0.0))
      (run
       (lambda ()
	 (let* ((samps 11)
		(data (vct 0 0 1 1))
		(e (make-env data :length samps)))
	   (env e)
	   (set! x (env e))
	   x)))
      (if (fneq x .1) (snd-display #__line__ ";make-env in run 2: ~A" x)))
    
    (let ((x 0.0))
      (run
       (lambda ()
	 (let* ((samps 1)
		(data (vct 0 0 1 1))
		(e (make-env data :length (+ 10 samps))))
	   (env e)
	   (set! x (env e))
	   x)))
      (if (fneq x .1) (snd-display #__line__ ";make-env in run 3: ~A" x)))
    
    (let ((x 0.0))
      (run
       (lambda ()
	 (let* ((samps 1)
		(e (make-env (vct 0 0 1 1) :length (+ 10 samps) :scaler (hz->radians (/ (mus-srate) (* 2 pi))))))
	   (env e)
	   (set! x (env e))
	   x)))
      (if (fneq x .1) (snd-display #__line__ ";make-env in run 4: ~A" x)))
    
    (btst '(let ((gen (make-all-pass))) (all-pass? gen)) #t)
    (btst '(let ((gen (make-all-pass))) (if gen #t #f)) #t)
    (btst '(let ((gen (make-moving-average))) (moving-average? gen)) #t)
    (btst '(let ((gen (make-moving-average))) (if gen #t #f)) #t)
    (btst '(let ((gen (make-asymmetric-fm))) (asymmetric-fm? gen)) #t)
    (btst '(let ((gen (make-comb))) (comb? gen)) #t)
    (btst '(let ((gen (make-filtered-comb))) (or (comb? gen) (filtered-comb? gen))) #t)
    (btst '(let ((gen (make-convolve :filter v-var))) (convolve? gen)) #t)
    (btst '(let ((gen (make-delay))) (delay? gen)) #t)
    (btst '(let ((gen (make-env '(0 0 1 1)))) (env? gen)) #t)
    (btst '(let ((gen (make-file->frame "oboe.snd"))) (file->frame? gen)) #t)
    (btst '(let ((gen (make-file->sample "oboe.snd"))) (file->sample? gen)) #t)
    (btst '(let ((gen (make-filter 8 v-var v-var))) (filter? gen)) #t)
    (btst '(let ((gen (make-fir-filter 8 v-var))) (fir-filter? gen)) #t)
    (btst '(let ((gen (make-firmant))) (firmant? gen)) #t)
    (btst '(let ((gen (make-formant))) (formant? gen)) #t)
    (btst '(let ((gen (make-frame 2))) (frame? gen)) #t)
    ;;(btst '(let ((gen (make-frame->file))) (frame->file? gen)) #t)
    (btst '(let ((gen (make-granulate))) (granulate? gen)) #t)
    (btst '(let ((gen (make-iir-filter 8 v-var))) (iir-filter? gen)) #t)
    (btst '(let ((gen (make-locsig))) (locsig? gen)) #t)
    (btst '(let ((gen (make-mixer 2))) (mixer? gen)) #t)
    (btst '(let ((gen (make-notch))) (notch? gen)) #t)
    (btst '(let ((gen (make-one-pole))) (one-pole? gen)) #t)
    (btst '(let ((gen (make-one-zero))) (one-zero? gen)) #t)
    (btst '(let ((gen (make-oscil 440.0))) (oscil? gen)) #t)
    (btst '(let ((gen (make-phase-vocoder))) (phase-vocoder? gen)) #t)
    (btst '(let ((gen (make-pulse-train))) (pulse-train? gen)) #t)
    (btst '(let ((gen (make-rand))) (rand? gen)) #t)
    (btst '(let ((gen (make-rand-interp))) (rand-interp? gen)) #t)
    (btst '(let ((gen (make-readin "oboe.snd"))) (readin? gen)) #t)
    ;;(btst '(let ((gen (make-sample->file))) (sample->file? gen)) #t)
    (btst '(let ((gen (make-sawtooth-wave))) (sawtooth-wave? gen)) #t)
    (btst '(let ((gen (make-nrxysin))) (nrxysin? gen)) #t)
    (btst '(let ((gen (make-nrxycos))) (nrxycos? gen)) #t)
    (btst '(let ((gen (make-square-wave))) (square-wave? gen)) #t)
    (btst '(let ((gen (make-src))) (src? gen)) #t)
    (btst '(let ((gen (make-ncos))) (ncos? gen)) #t)
    (btst '(let ((gen (make-nsin))) (nsin? gen)) #t)
    (btst '(let ((gen (make-ssb-am))) (ssb-am? gen)) #t)
    (btst '(let ((gen (make-table-lookup))) (table-lookup? gen)) #t)
    (btst '(let ((gen (make-triangle-wave))) (triangle-wave? gen)) #t)
    (btst '(let ((gen (make-two-pole))) (two-pole? gen)) #t)
    (btst '(let ((gen (make-two-zero))) (two-zero? gen)) #t)
    (btst '(let ((gen (make-wave-train))) (wave-train? gen)) #t)
    (btst '(let ((gen (make-polyshape))) (polyshape? gen)) #t)
    (btst '(let ((gen (make-polywave))) (polywave? gen)) #t)
    
    (btst '(let ((win (make-fft-window hamming-window 8))) (vct? win)) #t)
    (btst '(if #f (oscil #f) #t) #t)
    (btst '(if #f (mus-frequency #f) #t) #t)
    (btst '(if #f (set! (mus-frequency #f) 100.0) #t) #t)
    
    (ftst '(let ((gen (make-all-pass))) (all-pass gen)) 0.0)
    (ftst '(let ((gen (make-all-pass))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-all-pass))) (gen 0) (gen 0 0) (gen 0.0 0) (gen 0 0.0)) 0.0)
    (ftst '(let ((gen (make-moving-average))) (moving-average gen)) 0.0)
    (ftst '(let ((gen (make-moving-average))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-moving-average))) (gen 0) (gen 0 0) (gen 0.0 0) (gen 0 0.0)) 0.0)
    (ftst '(let ((gen (make-asymmetric-fm))) (asymmetric-fm gen 1.0)) 1.0)
    (ftst '(let ((gen (make-asymmetric-fm))) (gen)) 1.0)
    (ftst '(let ((gen (make-comb))) (comb gen)) 0.0)
    (ftst '(let ((gen (make-comb))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-filtered-comb :filter (make-one-zero .5 .5)))) (filtered-comb gen)) 0.0)
    (ftst '(let ((gen (make-filtered-comb :filter (make-one-zero .5 .5)))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-convolve :filter v-var))) (convolve gen)) 0.0)
    (ftst '(let ((gen (make-convolve :filter v-var))) (gen)) 0.0)
    (ftst '(let ((gen (make-delay))) (delay gen)) 0.0)
    (ftst '(let ((gen (make-delay))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-env '(0 0 1 1)))) (env gen)) 0.0)
    (ftst '(let ((gen (make-env '(0 0 1 1)))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-file->frame "oboe.snd"))) (frame-ref (file->frame gen 0) 0)) 0.0)
    (ftst '(let ((gen (make-file->sample "oboe.snd"))) (file->sample gen 0)) 0.0)
    (ftst '(let ((gen (make-file->sample "oboe.snd"))) (gen 0)) 0.0)
    (ftst '(let ((gen (make-filter 8 v-var v-var))) (filter gen)) 0.0)
    (ftst '(let ((gen (make-filter 8 v-var v-var))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-fir-filter 8 v-var))) (fir-filter gen)) 0.0)
    (ftst '(let ((gen (make-fir-filter 8 v-var))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-firmant))) (firmant gen)) 0.0)
    (ftst '(let ((gen (make-firmant))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-formant))) (formant gen)) 0.0)
    (ftst '(let ((gen (make-formant))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-frame 2))) (frame-ref gen 0)) 0.0)
    (ftst '(let ((gen (make-frame 2))) (gen 0) (gen 0.0) (gen 0.0 0.0)) 0.0)
    ;;(ftst '(let ((gen (make-frame->file))) (frame->file gen)) 0.0)
    (ftst '(let ((gen (make-granulate))) (granulate gen)) 0.0)
    (ftst '(let ((gen (make-granulate))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-iir-filter 8 v-var))) (iir-filter gen)) 0.0)
    (ftst '(let ((gen (make-iir-filter 8 v-var))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-locsig))) (locsig gen 0 0)) 0.0)
    (ftst '(let ((gen (make-locsig))) (gen 0.0)) 0.0)
    (ftst '(let ((gen (make-mixer 2))) (mixer-ref gen 0 0)) 0.0)
    (ftst '(let ((gen (make-mixer 2))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-mixer 2))) (gen 0.0 0) (gen 0 0) (gen 0) (gen 0 0.0)) 0.0)
    (ftst '(let ((gen (make-notch))) (notch gen)) 0.0)
    (ftst '(let ((gen (make-notch))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-one-pole))) (one-pole gen)) 0.0)
    (ftst '(let ((gen (make-one-pole))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-one-zero))) (one-zero gen)) 0.0)
    (ftst '(let ((gen (make-one-zero))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-oscil 440.0))) (oscil gen)) 0.0)
    (ftst '(let ((gen (make-oscil 440.0))) (gen)) 0.0)
    (ftst '(let ((gen (make-phase-vocoder))) (phase-vocoder gen)) 0.0)
    (ftst '(let ((gen (make-phase-vocoder))) (gen)) 0.0)
    (ftst '(let ((gen (make-pulse-train))) (pulse-train gen)) 1.0)
    (ftst '(let ((gen (make-pulse-train))) (gen)) 1.0)
    (btst '(let ((gen (make-rand))) (< (rand gen) 1.0)) #t)
    (btst '(let ((gen (make-rand))) (< (gen) 1.0)) #t)
    (btst '(let ((gen (make-rand-interp))) (< (rand-interp gen) 1.0)) #t)
    (btst '(let ((gen (make-rand-interp))) (< (gen) 1.0)) #t)
    (ftst '(let ((gen (make-readin "oboe.snd"))) (readin gen)) 0.0)
    (ftst '(let ((gen (make-readin "oboe.snd"))) (gen)) 0.0)
    ;;(ftst '(let ((gen (make-sample->file))) (sample->file gen)) 0.0)
    (ftst '(let ((gen (make-sawtooth-wave))) (sawtooth-wave gen)) 0.0)
    (ftst '(let ((gen (make-sawtooth-wave))) (gen)) 0.0)
    (ftst '(let ((gen (make-nrxysin))) (nrxysin gen)) 0.0)
    (ftst '(let ((gen (make-nrxysin))) (gen)) 0.0)
    (ftst '(let ((gen (make-nrxycos))) (nrxycos gen)) 1.0)
    (ftst '(let ((gen (make-nrxycos))) (gen)) 1.0)
    (ftst '(let ((gen (make-square-wave))) (square-wave gen)) 1.0)
    (ftst '(let ((gen (make-square-wave))) (gen)) 1.0)
    (ftst '(let ((gen (make-src))) (src gen)) 0.0)
    (ftst '(let ((gen (make-src))) (gen)) 0.0)
    (ftst '(let ((gen (make-ncos))) (ncos gen)) 1.0)
    (ftst '(let ((gen (make-ncos))) (gen)) 1.0)
    (ftst '(let ((gen (make-nsin))) (nsin gen)) 0.0)
    (ftst '(let ((gen (make-nsin))) (gen)) 0.0)
    (ftst '(let ((gen (make-ssb-am))) (ssb-am gen)) 0.0)
    (ftst '(let ((gen (make-ssb-am))) (gen)) 0.0)
    (ftst '(let ((gen (make-table-lookup))) (table-lookup gen)) 0.0)
    (ftst '(let ((gen (make-table-lookup))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-triangle-wave))) (triangle-wave gen)) 0.0)
    (ftst '(let ((gen (make-triangle-wave))) (gen)) 0.0)
    (ftst '(let ((gen (make-two-pole))) (two-pole gen)) 0.0)
    (ftst '(let ((gen (make-two-pole))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-two-zero))) (two-zero gen)) 0.0)
    (ftst '(let ((gen (make-two-zero))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
    (ftst '(let ((gen (make-wave-train))) (wave-train gen)) 0.0)
    (ftst '(let ((gen (make-wave-train))) (gen)) 0.0)
    (ftst '(let ((gen (make-polyshape))) (polyshape gen)) 1.0)
    (ftst '(let ((gen (make-polyshape))) (gen 1.0)) 1.0) ;; 1.0 needed for index in this case (filled in by hand in the previous case)
    (ftst '(let ((gen (make-polywave))) (polywave gen)) 1.0)
    (ftst '(let ((gen (make-polywave))) (gen)) 1.0)
    
    (ftst '(let ((win (make-fft-window hamming-window 8))) (vct-ref win 0)) 0.08)
    
    (ftst '(let ((gen (make-delay 3 :initial-contents '(0.5 1.0 1.0)))) (if (delay? gen) (delay gen) 0.0)) 0.5)
    (ftst '(let ((gen (make-delay 3 :initial-element .1))) (if (delay? gen) (delay gen) 0.0)) 0.1)
    (ftst '(let ((gen1 (make-delay 3 :initial-element .3))
		 (gen2 (make-delay 3 :initial-contents '(.1 .2 .3))))
	     (if (and (delay? gen1)
		      (delay? gen2))
		 (+ (delay gen1) (delay gen2))
		 0.0))
	  0.4)
    
    (let ((tst 0.0))
      (run (set! tst (st3-one svar)))
      (if (not (= tst 1)) (snd-display #__line__ ";run st3-one: ~A ~A" tst (st3-one svar)))
      (run (set! bst3 (st3? svar)))
      (if (not bst3) (snd-display #__line__ ";st3? ~A" (st3? svar))))
    
    (set! svar (make-st4))
    (let ((tst 0))
      (run (set! tst (st4-one svar)))
      (if (not (= tst 1)) (snd-display #__line__ ";run st4-one: ~A ~A" tst (st4-one svar)))
      (ftst '(st4-two svar) 2.0)
      (run (set! bst4 (st4? svar)))
      (if (not bst4) (snd-display #__line__ ";st4? ~A ~A" svar (st4? svar))))
    
    (set! svar (make-st3 :one 1.0 :two 2.0))
    (set! svar1 (make-st3 :one 2.0 :two 3.0))
    (let ((tst 0.0)
	  (tst1 0.0)
	  (tst2 0.0)
	  (tst3 0.0))
      (run 
       (if (not (c-g?)) (set! tst (st3-two svar))) ;2
       (set! tst1 (st3-two svar1)) ;3
       (set! (st3-two svar) (st3-two svar1))
       (set! tst2 (st3-two svar)) ;3
       (set! (st3-one svar1) 123.0)
       (set! tst3 (st3-one svar1))) ;123
      (if (fneq tst 2) (snd-display #__line__ ";run st3-two (2): ~A ~A" tst (st3-two svar)))
      (if (fneq tst1 3) (snd-display #__line__ ";run st3-two (3): ~A ~A" tst (st3-two svar1)))
      (if (fneq tst2 3) (snd-display #__line__ ";run st3-two (2->3): ~A ~A" tst (st3-two svar)))
      (if (fneq tst3 123) (snd-display #__line__ ";run st3-one (123): ~A ~A" tst (st3-one svar1))))
    
    ;; restore tests
    (if (fneq (st3-one svar) 1.0) (snd-display #__line__ ";restore st3-one (1): ~A" (st3-one svar)))
    (if (fneq (st3-one svar1) 123.0) (snd-display #__line__ ";restore st3-one (123): ~A" (st3-one svar1)))
    (if (fneq (st3-two svar) 3.0) (snd-display #__line__ ";restore st3-two (2->3): ~A" (st3-two svar)))
    (if (fneq (st3-two svar1) 3.0) (snd-display #__line__ ";restore st3-two (3): ~A" (st3-two svar1)))
    
    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) (hiho1-ii y)) hi1)))
      (if (not (= val 3)) (snd-display #__line__ ";typed hiho1-ii: ~A" val)))
    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) (hiho1-xx y)) hif2)))
      (if (or (not (number? val)) (fneq val 3.14)) (snd-display #__line__ ";typed hiho1-xx: ~A" val)))
    (let ((val (run-eval '(lambda (x y) (declare (x hiho1) (y hiho1)) (+ (hiho1-xx y) (hiho1-xx x))) hi1 hif2)))
      (if (or (not (number? val)) (fneq val 4.14)) (snd-display #__line__ ";typed hiho1-xx+xx: ~A" val)))
    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) y) hi1)))
      (if (not (hiho1? val)) (snd-display #__line__ ";clm-struct return: ~A" val)))
    (let ((tag (catch 'cannot-parse
		      (lambda () (run-eval '(set! (hiho1-ii hi1) "ho")))
		      (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse))
	  (snd-display #__line__ ";set def-clm-struct type check? ~A" tag)))
    (let ((tag (catch 'cannot-parse
		      (lambda () (run-eval '(let ((r (make-sampler))) (format #f "~A" r))))
		      (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse))
	  (snd-display #__line__ ";format arg type check? ~A" tag)))
    
    ;; this is testing a missing quote??
    (let ((tag (catch #t (lambda () (run-eval (lambda () (eq? .3 .2)))) (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";cannot parse case: ~A" tag)))
    
    (let ((val (run-eval '(lambda (y) (declare (y hiho2)) (vct-ref (hiho2-v y) 1)) hi2)))
      (if (fneq val .1) (snd-display #__line__ ";typed hiho2-v: ~A" val))
      (run-eval '(lambda (y) (declare (y hiho2)) (vct-set! (hiho2-v y) 2 3.14)) hi2)
      (if (fneq (vct-ref (hiho2-v hi2) 2) 3.14)
	  (snd-display #__line__ ";vct-set hiho2-v: ~A" (vct-ref (hiho2-v hi2) 2))))
    (let ((val (run-eval '(lambda (y) (declare (y hiho2)) (hiho2-i y)) hi2)))
      (if (not (= val 0)) (snd-display #__line__ ";typed hiho2-i: ~A" val))
      (set! val (run-eval '(lambda (y) (declare (y hiho2)) (set! (hiho2-i y) 2) (hiho2-i y)) hi2))
      (if (not (= val 2)) (snd-display #__line__ ";inner set hiho2-i: ~A" val)))
    (let ((val (run-eval '(lambda (y) (declare (y hiho2)) (hiho2-x y)) hi2)))
      (if (fneq val 0.0) (snd-display #__line__ ";hiho2-x: ~A" val))
      (set! val (run-eval '(lambda (y) (declare (y hiho2)) (set! (hiho2-x y) 3.14) (hiho2-x y)) hi2))
      (if (fneq val 3.14) (snd-display #__line__ ";inner set hiho2-x: ~A" val)))
    
    ;; this tests the fallback process
    (let ((lst (list 1 2 (vct-fill! (make-vct 4) 3.14) 3))
	  (k 123.0))
      (run (set! k (vct-ref (list-ref lst 2) 1)))
      (if (fneq k 3.14) (snd-display #__line__ ";list-ref ->vct: ~A" k)))
    
    (itst '(mus-sound-samples "oboe.snd") 50828)
    (itst '(mus-sound-length "oboe.snd") 101684)
    (itst '(mus-sound-frames "oboe.snd") 50828)
    (itst '(mus-sound-data-location "oboe.snd") 28)
    (itst '(mus-sound-chans "oboe.snd") 1)
    (itst '(mus-sound-srate "oboe.snd") 22050)
    (itst '(mus-sound-header-type "oboe.snd") mus-next)
    (itst '(mus-sound-data-format "oboe.snd") mus-bshort)
    (ftst '(mus-sound-duration "oboe.snd") 2.305)
    (stst '(mus-sound-comment "4.aiff") ";Written Tue 26-Nov-96 14:55 PST by bil at bill (Silicon Graphics Iris 4D) using Allegro CL, clm of 21-Nov-96")
    (itst '(mus-sound-datum-size "oboe.snd") 2)
    (itst '(mus-sound-length "oboe.snd") (+ 28 (* 2 50828)))
    (itst '(mus-sound-header-type "oboe.snd") mus-next)
    (itst '(mus-sound-data-format "oboe.snd") mus-bshort)
    (stst '(mus-data-format-name mus-bshort) "big endian short (16 bits)")
    (etst '(mus-data-format-name 3.14))
    (stst '(mus-header-type-name mus-aifc) "AIFC")
    (stst '(mus-header-type-name (mus-sound-header-type "oboe.snd")) "Sun/Next")
    (etst '(mus-header-type-name "hiho"))
    (itst '(mus-bytes-per-sample mus-bshort) 2)
    (etst '(make-vct 3 "hi"))
    (btst '(let* ((file "oboe.snd")
		  (str (string-append file ": chans: "
				      (number->string (mus-sound-chans file))
				      ", srate: "
				      (number->string (mus-sound-srate file))
				      ", "
				      (mus-header-type-name (mus-sound-header-type file))
				      ", "
				      (mus-data-format-name (mus-sound-data-format file))
				      ", len: "
				      (number->string 
				       (exact->inexact (/ (mus-sound-samples file)
							  (* (mus-sound-chans file) (mus-sound-srate file))))))))
	     (or (string=? str "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.30512475967407")
		 (string=? str "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.30512471655329")
		 (string=? str "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.305124716553287989")))
	  #t)
    
    (let ((old-srate (mus-srate)))
      (set! (mus-srate) 22050)
      (ftst '(mus-sound-duration "oboe.snd") 2.30512)
      (stst '(mus-sound-comment "1.snd") ";Written Tue 2-Jul-102 at 12:09 MDT  by bil at goggle (Linux/X86) using Allegro CL, clm of 3-July-02")
      (ftst '(radians->hz 2.84951704088598e-4) 1.0)
      (ftst '(radians->degrees 1.0) 57.2957801818848)
      (ftst '(degrees->radians 57.2957801818848) 1.0)
      (ftst '(linear->db .25) -12.0411996841431)
      (ftst '(db->linear -12.0411996841431) .25)
      (ftsta '(lambda (y) (radians->hz y)) 2.84951704088598e-4 1.0)
      (ftsta '(lambda (y) (radians->degrees y)) 1.0 57.2957801818848)
      (ftsta '(lambda (y) (degrees->radians y)) 57.2957801818848 1.0)
      (ftsta '(lambda (y) (linear->db y)) .25 -12.0411996841431)
      (ftsta '(lambda (y) (db->linear y)) -12.0411996841431 .25)
      (ftst '(ring-modulate .4 .5) .2)
      (ftst '(amplitude-modulate 1.0 .5 .4) .7)
      (ftst '(contrast-enhancement 0.1 0.75) (sin (+ (* 0.1 (/ pi 2)) (* .75 (sin (* 0.1 2.0 pi))))))
      (itst '(seconds->samples 1.0) 22050)
      (itst '(seconds->samples 1) 22050)
      
      (etst '(mus-sound-samples 1))
      (etst '(mus-sound-length 3.14))
      (etst '(mus-sound-frames #\c))
      (etst '(mus-sound-data-location 1))
      (etst '(mus-sound-chans 1))
      (etst '(mus-sound-srate 3.14))
      (etst '(mus-sound-header-type #\v))
      (etst '(mus-sound-data-format 1))
      (etst '(mus-sound-duration 1))
      (etst '(mus-sound-comment 3.14))
      (etst '(mus-sound-datum-size #\c))
      (etst '(mus-sound-length 1))
      (etst '(frames 0 1 2 3))
      (etst '(edit-position 0 1 2))
      (etst '(cursor 0 1 2))
      (etst '(report-in-minibuffer "hi" 0 1 2))
      (etst '(vct-ref (make-vct 2) 3.14))
      (etst '(make-vct 2 3 4))
      (etst '(make-vct 2 1))
      
      (set! g-gen (make-oscil 440.0))
      (ftst '(mus-frequency g-gen) 440.0)
      (ftst '(mus-phase g-gen) 0.0)
      (ftst '(oscil g-gen) 0.0)
      (ftst '(mus-phase g-gen) 0.125)
      (run-eval '(set! (mus-frequency g-gen) 100.0))
      (ftst '(mus-frequency g-gen) 100.0)
      (ftst '(g-gen) .125)
      (ftst '(g-gen 1.0) 0.153)
      (ftst '(g-gen 0.0 0.0) 0.925)
      (ftst '(g-gen 0.0 1.0) 0.802)
      (etst '(oscil g-gen 1.0 2.0 3.0))
      
      (ftst '(mus-srate) 22050.0)
					;(ftst '(set! (mus-srate) 44100.0) 44100.0)
					;(ftst '(set! (mus-srate) 22050) 22050.0)
					;(etst '(mus-srate 0.0))
					;(etst '(set! (mus-srate) "hi"))
      (btst '(< (mus-random 1.0) 2.0) #t)
      (btst '(>= (mus-random 1.0) -1.0) #t)
      (set! (mus-srate) old-srate))
    
    (let ((mx 0.0)
	  (mn 0.0))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= i 100))
	 (let ((val (mus-random 1.0)))
	   (if (or (= i 0) (< val mn)) (set! mn val))
	   (if (or (= i 0) (> val mx)) (set! mx val)))))
      (if (= mx mn) 
	  (snd-display #__line__ ";optimized mus-random is a constant: ~A" mx)
	  (begin
	    (if (< (- mx mn) 1.0) (snd-display #__line__ ";optimized mus-random range: ~A ~A" mn mx))
	    (if (or (>= mn 0.0) (<= mx 0.0)) (snd-display #__line__ ";optimized mus-random range odd: ~A ~A" mn mx)))))
    
    (let ((mx 0.0)
	  (mn 0.0))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= i 100))
	 (let ((val (random 1.0)))
	   (if (or (= i 0) (< val mn)) (set! mn val))
	   (if (or (= i 0) (> val mx)) (set! mx val)))))
      (if (= mx mn) 
	  (snd-display #__line__ ";optimized random is a constant: ~A" mx)
	  (begin
	    (if (< (- mx mn) 0.5) (snd-display #__line__ ";optimized random range: ~A ~A" mn mx))
	    (if (or (< mn 0.0) (> mx 1.0)) (snd-display #__line__ ";optimized random range odd: ~A ~A" mn mx)))))
    
    (if with-gui
	(let* ((ind (sound->integer (open-sound "oboe.snd")))
	       (reg (make-region 0 10))
	       (mrk (add-mark 123))
	       (reg-val -100.0))
	  (set! (mark-sync mrk) 1234)
	  (btst '(sampler? (make-sampler)) #t)
	  (btst '(let ((a (make-sampler))) (and (eq? a a) (eqv? a a) (equal? a a))) #t)
	  (btst '(let ((a (make-sampler)) (b (make-sampler))) (or (eq? a b) (eqv? a b) (equal? a b))) #f)
	  (let ((ok #f))
	    (run (set! ok (sound? ind)))
	    (if (not ok) (snd-display #__line__ ";run sound?")))
	  (let ((ok #f))
	    (run (set! ok (sound? (+ 1 ind))))
	    (if ok (snd-display #__line__ ";run not sound?")))
	  (let ((val (run (sample 1000))))
	    (if (fneq val .0328) (snd-display #__line__ ";run 1 sample 1000: ~A" val)))
	  (let ((val (run (sample 1000 ind 0))))
	    (if (fneq val .0328) (snd-display #__line__ ";run 2 sample 1000: ~A" val)))
	  (let ((val (run (sample 1000 ind 0 -1))))
	    (if (fneq val .0328) (snd-display #__line__ ";run 3 sample 1000: ~A" val)))
	  (let ((val (run (sample 1000 ind 0 0))))
	    (if (fneq val .0328) (snd-display #__line__ ";run 4 sample 1000: ~A" val)))
	  (if (string? (temp-dir))
	      (let ((str "hiho")
		    (str1 (temp-dir)))
		(run (set! str (temp-dir)))
		(if (not (string=? str str1)) (snd-display #__line__ ";run temp-dir: ~A ~A" str str1))))
	  (if (string? (save-dir))
	      (let ((str "hiho")
		    (str1 (save-dir)))
		(run (set! str (save-dir)))
		(if (not (string=? str str1)) (snd-display #__line__ ";run save-dir: ~A ~A" str str1))))
	  (let ((mx (selection-chans))
		(mx1 -1))
	    (run (set! mx1 (selection-chans)))
	    (if (not (= mx mx1)) (snd-display #__line__ ";run selection-chans: ~A ~A" mx mx1)))
	  (close-sound ind)))
    
    (let* ((ind (open-sound "oboe.snd"))
	   (gen (make-snd->sample ind))
	   (v0 (make-vct 10))
	   (v1 (channel->vct 1490 10 ind 0)))
      (run 
       (if (snd->sample? gen)
	   (do ((i 0 (+ 1 i)))
	       ((= i 10))
	     (vct-set! v0 i (snd->sample gen (+ 1490 i))))))
      (if (not (vequal v0 v1))
	  (snd-display #__line__ ";snd->sample: ~A ~A" v0 v1))
      (close-sound ind)
      (set! ind (open-sound "2.snd"))
      (set! v1 (channel->vct 10 10 ind 1))
      (set! gen (make-snd->sample ind))
      (run 
       (if (snd->sample? gen)
	   (do ((i 0 (+ 1 i)))
	       ((= i 10))
	     (vct-set! v0 i (snd->sample gen (+ 10 i) 1)))))
      (if (not (vequal v0 v1))
	  (snd-display #__line__ ";snd->sample chn 1: ~A ~A" v0 v1))
      (close-sound ind))
    
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-ref v 1)) 1.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-scale! v 2.0) (vct-ref v 1)) 2.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-offset! v 2.0) (vct-ref v 1)) 3.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-offset! v 2.0) (vct-peak v)) 3.0)
    (ftst '(let ((v (make-vct 3))) (vct-fill! v 1.0) (vct-ref (vct-copy v) 1)) 1.0)
    (itst '(let ((v (make-vct 3))) (vct-length v)) 3)
    (btst '(let ((v (make-vct 3))) (vct? v)) #t)
    (ftst '(let ((v0 (make-vct 3)) (v1 (make-vct 3))) (vct-fill! v0 1.0) (vct-fill! v1 2.0) (vct-ref (vct-multiply! v0 v1) 1)) 2.0)
    (ftst '(let ((v0 (make-vct 3)) (v1 (make-vct 3))) (vct-fill! v0 1.0) (vct-fill! v1 2.0) (vct-ref (vct-add! v0 v1) 1)) 3.0)
    (ftst '(let ((v0 (make-vct 3)) (v1 (make-vct 3))) (vct-fill! v0 1.0) (vct-fill! v1 2.0) (vct-ref (vct-subtract! v0 v1) 1)) -1.0)
    (ftsta '(lambda (y) (declare (y vct)) (vct-ref y 1)) global-v 1.0)
    
    (let ((a 0) (v (make-vct 1))) 
      (vct-map! v (lambda () (do ((i 0 (+ 1 i))) ((= i 3) a) (set! a (+ 1 a))))) 
      (if (not (= a 3)) (snd-display #__line__ ";i a: ~A" a)))
    (let ((a 0.0) (v (make-vct 1))) 
      (vct-map! v (lambda () (do ((i 0 (+ 1 i))) ((= i 3) a) (set! a (+ a 0.5))))) 
      (if (not (= a 1.5)) (snd-display #__line__ ";f a: ~A" a)))
    (let ((a "hi") (v (make-vct 1))) 
      (vct-map! v (lambda () (do ((i 0 (+ 1 i))) ((= i 3) 0.0) (set! a "ho"))))
      (if (not (string=? a "ho")) (snd-display #__line__ ";s a: ~A" a)))
    (itst '(do ((i 0 (+ 1 i))) ((= i 3) 0) (vct-scale! (make-vct 3) 1.0)) 0)
    (let ((v (make-vct 8)))
      (vct-set! v 4 1.0)
      (run (vct-move! v 0 1))
      (if (not (vequal v (vct 0 0 0 1 0 0 0 0)))
	  (snd-display #__line__ ";vct-move! in run: ~A" v)))
    
    (let ((vect (make-vector 2 1.5))
	  (v (make-vct 2)))
      (vct-map! v (lambda () (vector-ref vect 0)))
      (if (fneq (vct-ref v 0) 1.5) (snd-display #__line__ ";f1.5 vector-ref: ~A" v)))
    
    (let ((vect (make-vector 2 1))
	  (v (make-vct 2))
	  (i 0))
      (vct-map! v (lambda () (set! i (vector-ref vect 0)) 0.0))
      (if (not (= i 1)) (snd-display #__line__ ";i1 vector-ref: ~A" i)))
    
    (let ((vect (make-vector 2))
	  (v (make-vct 2))
	  (i 0))
      (vector-set! vect 0 (make-vct 2 3.0))
      (vector-set! vect 1 (make-vct 2 4.0))
      (vct-map! v (lambda () (vct-ref (vector-ref vect 0) 0)))
      (if (fneq (vct-ref v 0) 3.0) (snd-display #__line__ ";v3.0 vector-ref: ~A" v)))
    
    (let ((vect (make-vector 2 1.5))
	  (v (make-vct 2)))
      (vct-map! v (lambda () (vector-fill! vect 2.0) (vector-ref vect 0)))
      (if (fneq (vct-ref v 0) 2.0) (snd-display #__line__ ";f2.0 vector-fill: ~A" v)))
    
    (let ((vect (make-vector 2 1))
	  (v (make-vct 2))
	  (i 0))
      (vct-map! v (lambda () (vector-fill! vect 32) (set! i (vector-ref vect 0)) 0.0))
      (if (not (= i 32)) (snd-display #__line__ ";i32 vector-fill: ~A" i)))
    
    (let ((vect (make-vector 2 1.5))
	  (v (make-vct 2)))
      (vct-map! v (lambda () (exact->inexact (vector-length vect))))
      (if (fneq (vct-ref v 0) 2.0) (snd-display #__line__ ";f2.0 vector-length: ~A" v)))
    
    (let ((vect (make-vector 2 1))
	  (v (make-vct 2))
	  (i 0))
      (vct-map! v (lambda () (set! i (vector-length vect)) 0.0))
      (if (not (= i 2)) (snd-display #__line__ ";i2 vector-length: ~A" i)))
    
    (let ((vect (make-vector 2))
	  (v (make-vct 2))
	  (i 0))
      (vector-set! vect 0 (make-vct 2 3.0))
      (vector-set! vect 1 (make-vct 2 4.0))
      (vct-map! v (lambda () (inexact->exact (vector-length vect))))
      (if (fneq (vct-ref v 0) 2.0) (snd-display #__line__ ";v2.0 vector-length: ~A" v)))
    
    (let ((vect (make-vector 2 1.5))
	  (v (make-vct 2)))
      (vct-map! v (lambda () (vector-set! vect 0 32.0) (vector-ref vect 0)))
      (if (fneq (vct-ref v 0) 32.0) (snd-display #__line__ ";f32.0 vector-set: ~A" v)))
    
    (let ((vect (make-vector 2 1))
	  (v (make-vct 2))
	  (i 0))
      (vct-map! v (lambda () (vector-set! vect 0 123) (set! i (vector-ref vect 0)) 0.0))
      (if (not (= i 123)) (snd-display #__line__ ";i123 vector-set: ~A" i)))
    
    (let ((vect (make-vector 3 32))
	  (v (make-vct 3)))
      (vct-map! v (lambda () (vector-set! vect 0 123) 0.0))
      (if (not (= (vector-ref vect 0) 123)) (snd-display #__line__ ";i vect set: ~A" vect)))
    
    (let ((vect (make-vector 3 32.0))
	  (v (make-vct 3)))
      (vct-map! v (lambda () (vector-set! vect 0 123.0) 0.0))
      (if (fneq (vector-ref vect 0) 123.0) (snd-display #__line__ ";f vect set: ~A" vect)))
    
    (let ((vect (make-vector 3))
	  (v (make-vct 3))
	  (zero 0.0)
	  (gen (make-oscil 440)))
      (vector-set! vect 0 (make-oscil 440))
      (vector-set! vect 1 (make-oscil 440))
      (vector-set! vect 2 (make-oscil 440))
      (vct-map! v (lambda ()
		    (let ((val (vector-ref vect 0)))
		      (oscil val 0.0))))
      (if (and (not (vequal v (vct 0.0 0.125 0.248))) 
	       (not (vequal v (vct 0.0 0.063 0.125))))
	  (snd-display #__line__ ";vect gen vct-map 1.0: ~A" v))
      (vct-map! v (lambda ()
		    (let ((val (vector-ref vect 0)))
		      (oscil val zero))))
      (if (and (not (vequal v (vct 0.367 0.481 0.587))) 
	       (not (vequal v (vct 0.187 0.248 0.308))))
	  (snd-display #__line__ ";vect gen vct-map 1.0 (phase): ~A" v)))
    
    (vector-set! clm_vector 0 (make-oscil))
    (vector-set! clm_vector 1 (make-two-pole .1 .1))
    (btsta '(lambda (y) (declare (y clm-vector)) (oscil? (vector-ref y 0))) clm_vector #t)
    (btsta '(lambda (y) (declare (y clm-vector)) (oscil? (vector-ref y 1))) clm_vector #f)
    (itsta '(lambda (y) (declare (y clm-vector)) (vector-length y)) clm_vector 2)
    
    (vector-set! vct_vector 0 (make-vct 2))
    (vector-set! vct_vector 1 (make-vct 3))
    (btsta '(lambda (y) (declare (y vct-vector)) (= (vct-length (vector-ref y 0)) 2)) vct_vector #t)
    (itsta '(lambda (y) (declare (y vct-vector)) (vector-length y)) vct_vector 2)
    
    (let ((tag (catch #t 
		      (lambda ()
			(run-eval '(lambda (y) (declare (y vct)) (vct-ref y 1))))
		      (lambda args (car args)))))
      (if (not (eq? tag 'wrong-number-of-args)) (snd-display #__line__ ";wrong num args to run-eval: ~A" tag)))
    
    (let ((vect (make-vector 3))
	  (v (make-vct 3))
	  (gen (make-oscil 440)))
      (vector-set! vect 0 (make-oscil 440))
      (vector-set! vect 1 (make-oscil 440))
      (vector-set! vect 2 (make-oscil 440))
      (vct-map! v (lambda ()
		    (let ((val (vector-ref vect 0)))
		      (vector-set! vect 0 gen)
		      (vector-fill! vect gen)
		      (oscil val 0.0))))
      (if (and (not (vequal v (vct 0.0 0.0 0.125))) 
	       (not (vequal v (vct 0.000 0.000 0.063))))
	  (snd-display #__line__ ";vect gen set vct-map 1.0: ~A" v)))
    
    (let ((vect (make-vector 1))
	  (v (make-vct 3))
	  (gen (make-oscil 440)))
      (vector-set! vect 0 gen)
      (vct-map! v (lambda ()
		    (oscil (vector-ref vect 0) 0.0)))
      (if (and (not (vequal v (vct 0.0 0.125 0.248))) 
	       (not (vequal v (vct 0.000 0.063 0.125))))
	  (snd-display #__line__ ";vect[0] gen set vct-map 1.0: ~A" v)))
    
    (let ((vect (make-vector 1))
	  (v (make-vct 3))
	  (gen (make-oscil 440)))
      (vector-set! vect 0 gen)
      (vct-map! v (lambda ()
		    ((vector-ref vect 0) 0.0)))
      (if (and (not (vequal v (vct 0.0 0.125 0.248))) 
	       (not (vequal v (vct 0.000 0.063 0.125))))
	  (snd-display #__line__ ";[vect] gen set vct-map 1.0: ~A" v)))
    
    (let ((vect (make-vector 3))
	  (v (make-vct 3))
	  (v1 (make-vct 3)))
      (vector-set! vect 0 (make-vct 3 0.25))
      (vector-set! vect 1 (make-vct 3 0.5))
      (vector-set! vect 2 (make-vct 3 1.0))
      (vct-map! v (lambda ()
		    (let ((val (vector-ref vect 0)))
		      (vct-ref val 0))))
      (if (not (vequal v (vct 0.25 0.25 0.25))) (snd-display #__line__ ";vect vct vct-map 1.0: ~A" v)))
    
    (let ((vect (make-vector 3))
	  (v (make-vct 3))
	  (v1 (make-vct 3 2.0)))
      (vector-set! vect 0 (make-vct 3 0.25))
      (vector-set! vect 1 (make-vct 3 0.5))
      (vector-set! vect 2 (make-vct 3 1.0))
      (vct-map! v (lambda ()
		    (let ((val (vector-ref vect 0)))
		      (vector-set! vect 0 v1)
		      (vector-fill! vect v1)
		      (vct-ref val 0))))
      (if (not (vequal v (vct 0.25 2.0 2.0))) (snd-display #__line__ ";vect vct set vct-map 1.0: ~A" v)))
    
    (if (not (string=? (mus-describe (make-frame)) "frame[1]: [0.000]")) (snd-display #__line__ ";make-frame 0 args: ~A" (mus-describe (make-frame))))
    
    (let ((v1 (make-vector 3 1.5))
	  (v2 (make-vector 3 32))
	  (v3 (make-vct 3))
	  (vp #f))
      (vct-map! v3
		(lambda ()
		  (vector-set! v2 0 1)
		  (vector-set! v1 0 3.14)
		  (set! vp (vector? v2))
		  (+ (vector-ref v2 0) (vector-ref v1 0))))
      (if (or (not (vequal v3 (vct 4.14 4.14 4.14)))
	      (not (= (vector-ref v2 0) 1))
	      (not (= (vector-ref v2 1) 32))
	      (fneq (vector-ref v1 0) 3.14)
	      (fneq (vector-ref v1 1) 1.5)
	      (not vp))
	  (snd-display #__line__ ";run vector-set: ~A ~A ~A ~A" v1 v2 v3 vp)))
    
    (let ((oscs (vector (make-oscil 440.)))) 
      (let ((val (run (outa 0 (oscil (oscs 0))) 
		      (outa 0 (oscil (oscs 0))))))
	(if (fneq val 0.06265)
	    (snd-display #__line__ ";run clm vector: ~A" val))))
    
    (let ((v (vector 1 2 3 4)))
      (let ((val (run (outa 0 (* .1 (v 1))))))
	(if (fneq val 0.2)
	    (snd-display #__line__ ";run int vector: ~A" val))))
    
    (let ((v (vector (vct .1 .2 .3))))
      (let ((val (run (outa 0 (* .1 ((v 0) 1))))))
	(if (fneq val 0.02)
	    (snd-display #__line__ ";run vct vector: ~A" val))))
    
    (let ((v (vector 1 2 3))) 
      (let ((val (run (set! (v 1) 32) (v 1))))
	(if (not (= val 32))
	    (snd-display #__line__ ";run set int vector: ~A" val))))
    
    (let ((v1 (vector (vct 1 2 3)))) 
      (let ((val (run ((v1 0) 1))))
	(if (fneq val 2.0)
	    (snd-display #__line__ ";run vct + vector: ~A" val))))
    
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (v (make-vct 1)))
      (do ((i 0 (+ 1 i)))
	  ((= i 16))
	(vct-set! rdat i 0.0)
	(vct-set! idat i 0.0))
      (vct-set! rdat 3 1.0)
      (vct-map! v (lambda ()
		    (mus-fft rdat idat)
		    (mus-fft rdat idat 16 -1)
		    0.0))
      (if (or (fneq (vct-ref rdat 3) 16.0)
	      (fneq (vct-ref rdat 4) 0.0))
	  (snd-display #__line__ ";run vct fft real[3 or 4]: ~A ~A?" (vct-ref rdat 3) (vct-ref rdat 4)))
      (vct-fill! rdat 0.0)
      (vct-fill! idat 0.0)
      (vct-set! rdat 3 1.0)
      (vct-map! v (lambda ()
		    (mus-fft rdat idat 16)
		    (mus-fft rdat idat 16 -1)
		    0.0))
      (if (or (fneq (vct-ref rdat 3) 16.0)
	      (fneq (vct-ref rdat 4) 0.0))
	  (snd-display #__line__ ";run vct fft (2) real[3 or 4]: ~A ~A?" (vct-ref rdat 3) (vct-ref rdat 4)))
      (catch #t (lambda () (vct-map! v (lambda () (mus-fft rdat idat 16 1.5)))) (lambda args args)))
    
    (etst '(let ((v0 (make-vct 3))) (polynomial v0 0.0 123)))
    (etst '(let ((v0 (make-vct 3))) (vct-ref v0 "hiho")))
    (etst '(let ((v0 (make-vct 3))) (vct-set! v0 "hiho" 3.1)))
    
    (let ((v0 (make-vct 10))
	  (v1 (make-vct 10))
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (vct-fill! v0 1.0)
		    (multiply-arrays v0 v1 1)
		    0.0))
      (if (not (vequal v0 (vct 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)))
	  (snd-display #__line__ ";run multiply-arrays[0]: ~A?" v0)))
    
    (let ((v (make-vct 3 1.5))
	  (v1 (make-vct 1)))
      (vct-map! v1 (lambda ()
		     (clear-array v)
		     1.0))
      (if (not (vequal v (vct 0.0 0.0 0.0)))
	  (snd-display #__line__ ";run clear-array: ~A" v)))
    
    (let ((osc (make-oscil 440.0))
	  (v (make-vct 1))
	  (frq 0.0)
	  (phs 1234.0)
	  (cs 0))
      (vct-map! v 
		(lambda ()
		  (set! frq (mus-frequency osc))
		  (set! phs (mus-phase osc))
		  (set! cs (mus-length osc))
		  (set! (mus-frequency osc) 123.0)
		  (set! (mus-phase osc) 1.0)
		  0.0))
      (if (fneq frq 440.0) (snd-display #__line__ ";run frq: ~A" frq))
      (if (fneq phs 0.0) (snd-display #__line__ ";run phs: ~A" phs))
      (if (not (= cs 1)) (snd-display #__line__ ";run cs: ~A" cs))
      (if (fneq (mus-frequency osc) 123.0) (snd-display #__line__ ";run mus-frequency: ~A" (mus-frequency osc)))
      (if (fneq (mus-phase osc) 1.0) (snd-display #__line__ ";run mus-phase: ~A" (mus-phase osc))))
    
    (let ((v (make-vct 10))
	  (gen1 (make-oscil 440))
	  (gen2 (make-oscil 440)))
      (vct-map! v (lambda () (+ (gen1) (gen2))))
      (if (and (not (vequal v (vct 0.000 0.250 0.496 0.735 0.962 1.173 1.367 1.538 1.686 1.807)))
	       (not (vequal v (vct 0.000 0.125 0.250 0.374 0.496 0.617 0.735 0.850 0.962 1.069))))
	  (snd-display #__line__ ";gen+gen vct-map: ~A" v)))
    
    (let ((v (make-vct 10))
	  (gen1 (make-oscil 440))
	  (gen2 (make-oscil 440 :initial-phase pi)))
      (vct-map! v (lambda () (+ (gen1) (gen2))))
      (if (fneq (vct-peak v) 0.0) (snd-display #__line__ ";gen+gen-pi vct-map: ~A" v)))
    
    (let ((v (make-vct 10))
	  (gen1 (make-oscil 440))
	  (gen2 (make-oscil 440))
	  (gen3 (make-oscil 440 :initial-phase 0.0)))
      (vct-map! v (lambda () (+ (gen1) (gen2) (gen3))))
      (if (and (not (vequal v (vct 0.000 0.375 0.744 1.102 1.442 1.760 2.050 2.308 2.529 2.711))) 
	       (not (vequal v (vct 0.000 0.188 0.375 0.561 0.744 0.925 1.102 1.275 1.442 1.604))))
	  (snd-display #__line__ ";gen+gen+gen vct-map: ~A" v)))
    
    (let ((v (make-vct 1000))
	  (gen1 (make-oscil 1.0))
	  (gen2 (make-oscil 1.0 :initial-phase pi)))
      (vct-map! v (lambda () (+ (gen1) (gen2))))
      (if (fneq (vct-peak v) 0.0) (snd-display #__line__ ";gen+gen-pi 1.0: ~A" v)))
    
    (let ((v (make-vct 1000))
	  (gen1 (make-oscil 1.0))
	  (gen2 (make-oscil 1.0 :initial-phase (* 1023 pi))))
      (vct-map! v (lambda () (+ (gen1) (gen2))))
      (if (fneq (vct-peak v) 0.0) (snd-display #__line__ ";gen+gen-pi 1.0: ~A ~A" (vct-peak v) v)))
    
    (let ((v (make-vct 1000))
	  (gen1 (make-oscil 1.0))
	  (gen2 (make-oscil 1.0 :initial-phase (* (+ 1 (* 1024 1024)) pi))))
      (vct-map! v (lambda () (+ (gen1) (gen2))))
      ;; assume initial offset because phase is truncated to float in clm2xen
      (let ((off (vct-ref v 0)))
	(vct-offset! v (- off))
	(if (> (vct-peak v) 0.002) (snd-display #__line__ ";gen+gen-pi 1.0(2): ~A ~A" (vct-peak v) v))))
    
    (let ((v (make-vct 1000))
	  (gen1 (make-oscil 1.0))
	  (gen2 (make-oscil 1.0 :initial-phase pi)))
      (vct-map! v (lambda () (+ (gen1 0.0) (gen2 0.0 0.0))))
      (if (fneq (vct-peak v) 0.0) (snd-display #__line__ ";gen+gen-pi+args 1.0: ~A" v)))
    
    (let ((v1 (make-vct 10))
	  (v2 (make-vct 10))
	  (gen1 (make-oscil 100.0))
	  (gen2 (make-oscil 100.0))
	  (gen3 (make-oscil 100.0))
	  (gen4 (make-oscil 100.0))
	  (vr (make-vct 10)))
      (do ((i 0 (+ 1 i))) ((= i 10)) (vct-set! vr i (random 1.0)))
      (let ((i 0)) 
	(vct-map! v1 (lambda () (let ((val (+ (gen1 (vct-ref vr i)) (gen2 (vct-ref vr i) (vct-ref vr i))))) (set! i (+ 1 i)) val))))
      (let ((i 0)) 
	(vct-map! v2 (lambda () (let ((val (+ (oscil gen3 (vct-ref vr i)) (oscil gen4 (vct-ref vr i) (vct-ref vr i))))) (set! i (+ 1 i)) val))))
      (if (not (vequal v1 v2)) (snd-display #__line__ ";gen+gen+vr args: ~A ~A" v1 v2)))
    
    (let ((osc (make-ncos 440.0 3))
	  (v (make-vct 1))
	  (frq 0.0)
	  (phs 1234.0)
	  (cs 0))
      (vct-map! v 
		(lambda ()
		  (set! frq (mus-frequency osc))
		  (set! phs (mus-phase osc))
		  (set! cs (mus-length osc))
		  (set! (mus-frequency osc) 123.0)
		  (set! (mus-phase osc) 1.0)
		  (set! (mus-length osc) 10)
		  0.0))
      (if (fneq frq 440.0) (snd-display #__line__ ";cs run frq: ~A" frq))
      (if (fneq phs 0.0) (snd-display #__line__ ";cs run phs: ~A" phs))
      (if (not (= cs 3)) (snd-display #__line__ ";cs run cs: ~A" cs))
      (if (fneq (mus-frequency osc) 123.0) (snd-display #__line__ ";cs run mus-frequency: ~A" (mus-frequency osc)))
      (if (fneq (mus-phase osc) 1.0) (snd-display #__line__ ";cs run mus-phase: ~A" (mus-phase osc)))
      (if (not (= (mus-length osc) 10)) (snd-display #__line__ ";cs run set cs: ~A" (mus-length osc))))
    
    (let ((osc (make-nsin 440.0 3))
	  (v (make-vct 1))
	  (frq 0.0)
	  (phs 1234.0)
	  (cs 0))
      (vct-map! v 
		(lambda ()
		  (set! frq (mus-frequency osc))
		  (set! phs (mus-phase osc))
		  (set! cs (mus-length osc))
		  (set! (mus-frequency osc) 123.0)
		  (set! (mus-phase osc) 1.0)
		  (set! (mus-length osc) 10)
		  0.0))
      (if (fneq frq 440.0) (snd-display #__line__ ";scs run frq: ~A" frq))
      (if (fneq phs 0.0) (snd-display #__line__ ";scs run phs: ~A" phs))
      (if (not (= cs 3)) (snd-display #__line__ ";scs run cs: ~A" cs))
      (if (fneq (mus-frequency osc) 123.0) (snd-display #__line__ ";scs run mus-frequency: ~A" (mus-frequency osc)))
      (if (fneq (mus-phase osc) 1.0) (snd-display #__line__ ";scs run mus-phase: ~A" (mus-phase osc)))
      (if (not (= (mus-length osc) 10)) (snd-display #__line__ ";scs run set cs: ~A" (mus-length osc))))
    
    (let ((osc (make-ncos 440.0 3))
	  (v (make-vct 1))
	  (frq 0.0)
	  (phs 1234.0)
	  (cs 0))
      (vct-map! v 
		(lambda ()
		  (set! frq (mus-frequency osc))
		  (set! phs (mus-phase osc))
		  (set! cs (mus-length osc))
		  (set! (mus-frequency osc) 123.0)
		  (set! (mus-phase osc) 1.0)
		  (set! (mus-length osc) 10)
		  0.0))
      (if (fneq frq 440.0) (snd-display #__line__ ";cs run frq: ~A" frq))
      (if (fneq phs 0.0) (snd-display #__line__ ";cs run phs: ~A" phs))
      (if (not (= cs 3)) (snd-display #__line__ ";cs run cs: ~A" cs))
      (if (fneq (mus-frequency osc) 123.0) (snd-display #__line__ ";cs run mus-frequency: ~A" (mus-frequency osc)))
      (if (fneq (mus-phase osc) 1.0) (snd-display #__line__ ";cs run mus-phase: ~A" (mus-phase osc)))
      (if (not (= (mus-length osc) 10)) (snd-display #__line__ ";cs run set cs: ~A" (mus-length osc))))
    
    (let ((osc (make-nsin 440.0 3))
	  (v (make-vct 1))
	  (frq 0.0)
	  (phs 1234.0)
	  (cs 0))
      (vct-map! v 
		(lambda ()
		  (set! frq (mus-frequency osc))
		  (set! phs (mus-phase osc))
		  (set! cs (mus-length osc))
		  (set! (mus-frequency osc) 123.0)
		  (set! (mus-phase osc) 1.0)
		  (set! (mus-length osc) 10)
		  0.0))
      (if (fneq frq 440.0) (snd-display #__line__ ";scs run frq: ~A" frq))
      (if (fneq phs 0.0) (snd-display #__line__ ";scs run phs: ~A" phs))
      (if (not (= cs 3)) (snd-display #__line__ ";scs run cs: ~A" cs))
      (if (fneq (mus-frequency osc) 123.0) (snd-display #__line__ ";scs run mus-frequency: ~A" (mus-frequency osc)))
      (if (fneq (mus-phase osc) 1.0) (snd-display #__line__ ";scs run mus-phase: ~A" (mus-phase osc)))
      (if (not (= (mus-length osc) 10)) (snd-display #__line__ ";scs run set cs: ~A" (mus-length osc))))
    
    (let ((zf (make-two-zero .4 .7 .3))
	  (pf (make-two-pole .4 .7 .3))
	  (z1 0.0) (z2 0.0) (z3 0.0)
	  (p1 0.0) (p2 0.0) (p3 0.0)
	  (v (make-vct 1)))
      (vct-map! v 
		(lambda ()
		  (set! z1 (two-zero zf 1.0))
		  (set! z2 (two-zero zf 0.5))
		  (set! z3 (two-zero zf 1.0))
		  (set! p1 (two-pole pf 1.0))
		  (set! p2 (two-pole pf 0.5))
		  (set! p3 (two-pole pf 1.0))
		  0.0))
      (if (fneq z1 .4) (snd-display #__line__ ";run 2zero->0.4: ~A" z1))
      (if (fneq z2 .9) (snd-display #__line__ ";run 2zero->0.9: ~A" z2))
      (if (fneq z3 1.05) (snd-display #__line__ ";run 2zero->1.05: ~A" z3))
      (if (fneq p1 .4) (snd-display #__line__ ";run a0->out 2pole: ~A" p1))
      (if (fneq p2 -.08) (snd-display #__line__ ";run a0->out 2pole (-0.08): ~A" p2))
      (if (fneq p3 0.336) (snd-display #__line__ ";run a0->out 2pole (0.336): ~A" p3)))
    
    (let ((ind (open-sound "oboe.snd")))
      ;; ycoeff is after old end, so there's some small hope this could catch incomplete class declarations
      (for-each
       (lambda (n)
	 (let ((tag (catch #t
			   (lambda ()
			     (mus-ycoeff (n) 0))
			   (lambda args (car args)))))
	   (if (not (eq? tag 'mus-error))
	       (snd-display #__line__ ";~A ~A" n tag))))
       (list make-all-pass make-asymmetric-fm make-snd->sample make-moving-average make-comb make-filtered-comb make-delay make-frame make-granulate
	     make-locsig make-mixer make-notch make-oscil make-pulse-train make-rand make-rand-interp make-sawtooth-wave
	     make-nrxysin make-nrxycos make-square-wave make-src make-ncos 
	     make-nsin make-table-lookup make-triangle-wave
	     make-wave-train make-phase-vocoder make-ssb-am make-polyshape make-polywave))
      (close-sound ind))
    
    (let ((frm (make-formant 440.0 .1))
	  (v (make-vct 3)))
      (vct-map! v (lambda ()
		    (mus-set-formant-radius-and-frequency frm 2.0 100.0)))
      (if (fneq (mus-scaler frm) 2.0) (snd-display #__line__ ";run set-radius-etc: ~A" (mus-scaler frm)))
      (if (fneq (mus-frequency frm) 100.0) (snd-display #__line__ ";run set-radius-etc (frq): ~A" (mus-frequency frm))))
    
    (let ((v (make-vct 3)))
      (vct-map! v (let ((i 0))
		    (lambda ()
		      (let ((v0 (make-vct 3 .1)))
			(vct-set! v0 1 2)
			(let ((res (vct-ref v0 i)))
			  (set! i (+ 1 i))
			  res)))))
      (if (not (vequal v (vct .1 2.0 .1))) (snd-display #__line__ ";run make-vct: ~A" v)))
    
    (let ((val (run-eval '(let ((fr (make-frame 2 0.0 0.0)))
			    (frame-set! fr 0 1)
			    (frame-set! fr 1 2)
			    fr))))
      (if (or (fneq (frame-ref val 0) 1.0)
	      (fneq (frame-ref val 1) 2.0))
	  (snd-display #__line__ ";frame-set int opt: ~A" val)))
    
    (let ((val (run-eval '(let ((fr (make-frame 2 0.0 0.0)))
			    (frame-set! fr 0 (floor 1.4))
			    (frame-set! fr 1 3/4)
			    fr))))
      (if (or (fneq (frame-ref val 0) 1.0)
	      (fneq (frame-ref val 1) 0.75))
	  (snd-display #__line__ ";frame-set int opt 1: ~A" val)))
    
    (let ((val (run-eval '(let ((mx (make-mixer 2 1 0 0 1)))
			    (mixer-set! mx 0 0 2)
			    (mixer-set! mx 1 0 3/4)
			    (mixer-set! mx 1 1 (floor 3.14))
			    (mixer-set! mx 0 1 (+ 32 1))
			    mx))))
      (if (or (fneq (mixer-ref val 0 0) 2.0)
	      (fneq (mixer-ref val 1 0) 0.75)
	      (fneq (mixer-ref val 0 1) 33.0)
	      (fneq (mixer-ref val 1 1) 3))
	  (snd-display #__line__ ";mixer-set int opt: ~A" val)))
    
    (let ((fr1 (run (frame .1 .2)))
	  (fr2 (make-frame 2 .1 .2)))
      (if (not (equal? fr1 fr2))
	  (snd-display #__line__ ";frame...: ~A ~A" fr1 fr2)))
    
    (let ((fr1 (frame .1)))
      (if (fneq (run (fr1 0)) .1) (snd-display #__line__ ";frame gen ref (.1): ~A" (fr1 0)))
      (run (set! (fr1 0) .2))
      (if (fneq (fr1 0) .2) (snd-display #__line__ ";frame gen ref (.2): ~A" (fr1 0)))
      (if (not (equal? fr1 (frame .2)))
	  (snd-display #__line__ ";frame gen set! (.2): ~A" fr1)))
    
    (let ((fr1 (frame .1 .2 .3 .4)))
      (run (set! (fr1 2) (+ (fr1 1) (fr1 2))))
      (if (fneq (fr1 2) .5) (snd-display #__line__ ";frame gen ref/set (.5): ~A" (fr1 2))))
    
    
    (let ((mx (run (lambda () (mixer .1 .2 .3 .4)))))
      (if (fneq (mx 0 0) .1) (snd-display #__line__ ";mixer gen ref (.1): ~A" (mx 0 0)))
      (if (not (equal? mx (make-mixer 2 .1 .2 .3 .4))) (snd-display #__line__ ";mixer...: ~A" mx))
      (run (lambda () (set! (mx 0 0) .5)))
      (if (fneq (mx 0 0) .5) (snd-display #__line__ ";mixer gen set (.5): ~A" (mx 0 0)))
      (if (not (equal? mx (make-mixer 2 .5 .2 .3 .4))) (snd-display #__line__ ";mixer... (after set): ~A" mx))
      (if (fneq (mx 1 0) .3) (snd-display #__line__ ";mixer gen ref (.3): ~A" (mx 1 0)))
      (run (lambda () (set! (mx 0 1) .5)))
      (if (fneq (mx 0 1) .5) (snd-display #__line__ ";mixer (0 1) gen set (.5): ~A" (mx 0 1)))
      (if (not (equal? mx (make-mixer 2 .5 .5 .3 .4))) (snd-display #__line__ ";mixer... (after set 1): ~A" mx)))
    
    (let ((mx (mixer .1)))
      (if (not (equal? mx (make-mixer 1 .1))) (snd-display #__line__ ";mixer .1: ~A" mx))
      (if (fneq (run (lambda () (mx 0 0))) .1) (snd-display #__line__ ";mixer (1) gen ref (.1): ~A" (mx 0 0)))  
      (run (lambda () (set! (mx 0 0) .5)))
      (if (fneq (run (lambda () (mx 0 0))) .5) (snd-display #__line__ ";mixer (1) gen set (.5): ~A" (mx 0 0))))
    
    (let ((mx (run (lambda () (mixer .1 .2 .3)))))
      (if (not (equal? mx (make-mixer 2 .1 .2 .3 0.0))) (snd-display #__line__ ";mixer .1 .2 .3: ~A" mx))
      (run (lambda () (set! (mx 1 1) .5)))
      (if (fneq (run (lambda () (mx 1 1))) .5) (snd-display #__line__ ";mixer (1 1) gen set (.5): ~A" (mx 1 1))))
    
    
    (let ((sd (make-sound-data 1 1)))
      (if (fneq (run (lambda () (sd 0 0))) 0.0) (snd-display #__line__ ";sound-data ref: ~A" (sd 0 0)))
      (run (lambda () (set! (sd 0 0) 1.0)))
      (if (fneq (sd 0 0) 1.0) (snd-display #__line__ ";sound-data set: ~A" (sd 0 0)))
      (if (not (equal? sd (let ((sd1 (make-sound-data 1 1))) (sound-data-set! sd1 0 0 1.0) sd1)))
	  (snd-display #__line__ ";sound-data set not equal: ~A" sd)))
    
    (let ((sd (make-sound-data 2 3)))
      (if (fneq (sd 0 0) 0.0) (snd-display #__line__ ";sound-data ref (1): ~A" (sd 0 0)))
      (run (lambda () (set! (sd 1 0) 1.0)))
      (if (fneq (run (lambda () (sd 1 0))) 1.0) (snd-display #__line__ ";sound-data set (1 0): ~A" (sd 1 0)))
      (run (lambda () (set! (sd 1 2) 2.0)))
      (if (fneq (run (lambda () (sd 1 2))) 2.0) (snd-display #__line__ ";sound-data set (1 2): ~A" (sd 1 2)))
      (if (not (equal? sd (let ((sd1 (make-sound-data 2 3)))
			    (sound-data-set! sd1 1 0 1.0)
			    (sound-data-set! sd1 1 2 2.0)
			    sd1)))
	  (snd-display #__line__ ";sound-data set (3) not equal: ~A" sd)))
    
    (let ((val (run-eval '(let ((loc (make-locsig :channels 2)))
			    (locsig-set! loc 0 32)
			    (locsig-set! loc 1 3/4)
			    (+ (locsig-ref loc 0)
			       (locsig-ref loc 1))))))
      (if (fneq val 32.75) (snd-display #__line__ ";locsig-set int opt: ~A" val)))
    
    (set! (locsig-type) mus-interp-linear)
    (let* ((rev (make-frame->file "fmv4.reverb" 1 mus-bshort mus-next))
	   (loc (make-locsig 30.0 :channels 2 :reverb .1 :revout rev))
	   (d0 123.0)
	   (d1 123.0)
	   (dr 123.0)
	   (d01 123.0)
	   (d11 123.0)
	   (dr1 123.0)
	   (cs 0)
	   (isloc #f)
	   (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (set! d0 (locsig-ref loc 0))
		    (set! d1 (locsig-ref loc 1))
		    (set! dr (locsig-reverb-ref loc 0))
		    (set! cs (mus-channels loc))
		    (set! isloc (locsig? loc))
		    (move-locsig loc 60.0 2.0)
		    (set! d01 (locsig-ref loc 0))
		    (set! d11 (locsig-ref loc 1))
		    (set! dr1 (locsig-reverb-ref loc 0))
		    (locsig-set! loc 0 .123)
		    (set! (locsig-ref loc 1) .23)
		    (locsig-reverb-set! loc 0 .23)
		    (set! (locsig-reverb-ref loc 0) .123)
		    0.0))
      (if (fneq d0 .667) (snd-display #__line__ ";run locsig ref 0: ~A" d0))
      (if (fneq d1 .333) (snd-display #__line__ ";run locsig ref 1: ~A" d1))
      (if (fneq dr .1) (snd-display #__line__ ";run locsig reverb ref 0: ~A" dr))
      (if (not (= cs 2)) (snd-display #__line__ ";run mus-channels: ~A" cs))
      (if (fneq d01 .167) (snd-display #__line__ ";run locsig ref 01: ~A" d01))
      (if (fneq d11 .333) (snd-display #__line__ ";run locsig ref 11: ~A" d11))
      (if (fneq dr1 .0707) (snd-display #__line__ ";run locsig reverb ref 01: ~A" dr1))
      (if (fneq (locsig-ref loc 0) .123) (snd-display #__line__ ";run set loc 0: ~A" (locsig-ref loc 0)))	
      (if (fneq (locsig-ref loc 1) .23) (snd-display #__line__ ";run set loc 1: ~A" (locsig-ref loc 1)))	
      (if (fneq (locsig-reverb-ref loc 0) .123) (snd-display #__line__ ";run set loc rev 0: ~A" (locsig-reverb-ref loc 0)))
      (mus-close rev))
    
    (let* ((outp (make-sound-data 1 10))
	   (gen (make-locsig 0.0 :output outp)))
      (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";(opt)make-locsig->sd chans (1): ~A" (mus-channels gen)))
      (run 
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 1.0))))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 1.0)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 0: ~A" (sound-data->vct outp 0))))
    
    (let* ((outp (make-sound-data 2 10))
	   (gen (make-locsig 0.0 :output outp)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";(opt)make-locsig->sd chans: ~A" (mus-channels gen)))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 1.0))))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 1.0)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 0: ~A" (sound-data->vct outp 0)))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.0)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 1: ~A" (sound-data->vct outp 1))))
    
    (let* ((outp (make-sound-data 2 10))
	   (gen (make-locsig 45.0 :output outp)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";(opt)make-locsig->sd chans: ~A" (mus-channels gen)))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 1.0))))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 0.5)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 0 (0.5): ~A" (sound-data->vct outp 0)))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.5)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 1 (0.5): ~A" (sound-data->vct outp 1)))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 0.5))))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 0.75)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 0 (0.75): ~A" (sound-data->vct outp 0)))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.75)))
	  (snd-display #__line__ ";(opt)locsig->sd chan 1 (0.75): ~A" (sound-data->vct outp 1))))
    
    (let* ((outp (make-vct 10))
	   (gen (make-locsig 0.0 :output outp)))
      (if (not (= (mus-channels gen) 1)) (snd-display #__line__ ";(opt)make-locsig->vct chans: ~A" (mus-channels gen)))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 1.0))))
      (if (not (vequal outp (make-vct 10 1.0)))
	  (snd-display #__line__ ";(opt)locsig->vct chan 0: ~A" outp))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 0.5))))
      (if (not (vequal outp (make-vct 10 1.5)))
	  (snd-display #__line__ ";(opt)locsig->vct chan 0: ~A" outp)))
    
    (let* ((outp (make-vct 10))
	   (gen (make-locsig 45.0 :channels 2 :output outp)))
      (if (not (= (mus-channels gen) 2)) (snd-display #__line__ ";(opt)make-locsig->vct chans (2): ~A" (mus-channels gen)))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 1.0))))
      (if (not (vequal outp (make-vct 10 0.5)))
	  (snd-display #__line__ ";(opt)locsig(2)->vct chan 0: ~A" outp))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 0.5))))
      (if (not (vequal outp (make-vct 10 0.75)))
	  (snd-display #__line__ ";(opt)locsig(2)->vct chan 0: ~A" outp)))
    
    (let* ((outp (make-sound-data 4 10))
	   (gen (make-locsig 135.0 :output outp)))
      (if (not (= (mus-channels gen) 4)) (snd-display #__line__ ";(opt)make-locsig->sd chans (4): ~A" (mus-channels gen)))
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (locsig gen i 1.0))))
      (if (not (vequal (sound-data->vct outp 0) (make-vct 10 0.0)))
	  (snd-display #__line__ ";(opt)locsig(4)->sd chan 0 (0.5): ~A" (sound-data->vct outp 0)))
      (if (not (vequal (sound-data->vct outp 1) (make-vct 10 0.5)))
	  (snd-display #__line__ ";(opt)locsig(4)->sd chan 1 (0.5): ~A" (sound-data->vct outp 1)))
      (if (not (vequal (sound-data->vct outp 2) (make-vct 10 0.5)))
	  (snd-display #__line__ ";(opt)locsig(4)->sd chan 2 (0.5): ~A" (sound-data->vct outp 2)))
      (if (not (vequal (sound-data->vct outp 3) (make-vct 10 0.0)))
	  (snd-display #__line__ ";(opt)locsig(4)->sd chan 3 (0.5): ~A" (sound-data->vct outp 3))))
    
    
    (let ((fr (make-frame 2 1.5 0.5))
	  (mx (make-mixer 2 0.1 0.2 0.3 0.4))
	  (vs (make-vct 6))
	  (v (make-vct 1))
	  (fq #f)
	  (mq #f))
      (vct-map! v (lambda ()
		    (vct-set! vs 0 (frame-ref fr 0))
		    (vct-set! vs 1 (frame-ref fr 1))
		    (vct-set! vs 2 (mixer-ref mx 0 0))
		    (vct-set! vs 3 (mixer-ref mx 0 1))
		    (vct-set! vs 4 (mixer-ref mx 1 0))
		    (vct-set! vs 5 (mixer-ref mx 1 1))
		    (frame-set! fr 0 .123)
		    (mixer-set! mx 0 1 .123)
		    (set! fq (frame? fr))
		    (set! mq (mixer? mx))
		    0.0))
      (if (not (vequal vs (vct 1.5 0.5 0.1 0.2 0.3 0.4))) (snd-display #__line__ ";run frame-set: ~A" vs))
      (if (not fq) (snd-display #__line__ ";run frame?"))
      (if (not mq) (snd-display #__line__ ";run mixer?"))
      (if (fneq (frame-ref fr 0) .123) (snd-display #__line__ ";run frame-ref: ~A" (frame-ref fr 0)))
      (if (fneq (mixer-ref mx 0 1) .123) (snd-display #__line__ ";run mixer-ref: ~A" (mixer-ref mx 0 1))))
    
    (let ((cmb (make-comb .1 12))
	  (fb .123)
	  (len 123)
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (set! fb (mus-feedback cmb))
		    (set! len (mus-length cmb))
		    (set! (mus-feedback cmb) .123)
		    0.0))
      (if (fneq fb .1) (snd-display #__line__ ";run feedback: ~A" fb))
      (if (not (= len 12)) (snd-display #__line__ ";run mus-length: ~A" len))
      (if (fneq (mus-feedback cmb) .123) (snd-display #__line__ ";run set feedback: ~A" (mus-feedback cmb))))
    
    (let ((cmb (make-filtered-comb .1 12 :filter (make-one-zero .5 .5)))
	  (fb .123)
	  (len 123)
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (set! fb (mus-feedback cmb))
		    (set! len (mus-length cmb))
		    (set! (mus-feedback cmb) .123)
		    0.0))
      (if (fneq fb .1) (snd-display #__line__ ";run feedback: ~A" fb))
      (if (not (= len 12)) (snd-display #__line__ ";run mus-length: ~A" len))
      (if (fneq (mus-feedback cmb) .123) (snd-display #__line__ ";run set feedback: ~A" (mus-feedback cmb))))
    
    (let ((cmb (make-notch .1 12))
	  (ff .123)
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (set! ff (mus-feedforward cmb))
		    (set! (mus-feedforward cmb) .321)
		    0.0))
      (if (fneq ff .1) (snd-display #__line__ ";run feedforward: ~A" ff))
      (if (fneq (mus-feedforward cmb) .321) (snd-display #__line__ ";run set feedforward: ~A" (mus-feedforward cmb))))
    
    (let ((gen (make-oscil 440))
	  (res 0)
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (if (not (string=? (mus-name gen) "oscil")) (set! res 1))
		    (if (not (string=? (mus-describe gen) "oscil freq: 440.000Hz, phase: 0.000")) (set! res (+ res 10)))
		    0.0))
      (if (not (= res 0)) (snd-display #__line__ ";run mus-name etc: ~A" res)))
    
    (let ((r1 (make-rand 100))
	  (r2 (make-rand-interp 100 .1))
	  (v (make-vct 1))
	  (r1q #f)
	  (r2q #f))
      (vct-map! v (lambda ()
		    (set! r1q (rand? r1))
		    (set! r2q (rand-interp? r2))
		    (if (or (not (= (rand r1) (rand r1)))
			    (= (rand-interp r2) (rand-interp r2)))
			1.0
			0.0)))
      (if (fneq (vct-ref v 0) 0.0) (snd-display #__line__ ";run rand/interp?"))
      (if (not r1q) (snd-display #__line__ ";run rand?"))
      (if (not r2q) (snd-display #__line__ ";run rand-interp?"))
      (catch #t (lambda () (vct-map! v (lambda () (rand r1 0.0 1.0 2.0)))) (lambda args args))
      (catch #t (lambda () (vct-map! v (lambda () (rand-interp r2 1.0 2.0 3.0)))) (lambda args args)))
    
    (let ((v0 (make-vct 10))
	  (v (make-vct 1)))
      (do ((i 0 (+ 1 i))) ((= i 10))
	(vct-set! v0 i i))
      (vct-map! v (lambda () (array-interp v0 3.5)))
      (if (fneq (vct-ref v 0) 3.5) (snd-display #__line__ ";run array-interp: ~F?" (vct-ref v 0)))
      (vct-map! v (lambda () (array-interp v0 3.5 10)))
      (if (fneq (vct-ref v 0) 3.5) (snd-display #__line__ ";run array-interp sized: ~F?" (vct-ref v 0)))
      (catch #t (lambda () (vct-map! v (lambda () (array-interp v0)))) (lambda args args))
      (catch #t (lambda () (vct-map! v (lambda () (array-interp v0 3.5 10 123)))) (lambda args args))
      
      (do ((i 0 (+ 1 i))) ((= i 10))
	(vct-set! v0 i i))
      (let ((val (run (lambda () (mus-interpolate mus-interp-linear 1.5 v0)))))
	(if (fneq val 1.5) (snd-display #__line__ ";opt mus-interpolate linear: ~A" val))
	(set! val (run (mus-interpolate mus-interp-all-pass 1.5 v0 10)))
	(if (fneq val 1.5) (snd-display #__line__ ";opt mus-interpolate all-pass: ~A" val))
	(set! val (run (lambda () (mus-interpolate mus-interp-none 1.5 v0 10 0.0))))
	(if (fneq val 1.0) (snd-display #__line__ ";opt mus-interpolate none: ~A" val))
	(set! val (run (lambda () (mus-interpolate mus-interp-hermite 1.5 v0))))
	(if (fneq val 1.5) (snd-display #__line__ ";opt mus-interpolate hermite: ~A" val))
	(set! val (run (lambda () (mus-interpolate mus-interp-lagrange 1.5 v0))))
	(if (fneq val 1.5) (snd-display #__line__ ";opt mus-interpolate lagrange: ~A" val))))
    
    (let ((e (make-env '(0 0 1 1) :length 11))
	  (v (make-vct 1))
	  (b 123.0)
	  (enq #f)
	  (cs 123)
	  (ep -123)
	  (val8 123.0)
	  (val0 123.0))
      (env e) (env e)
      (vct-map! v (lambda ()
		    (set! b (mus-increment e))
		    (set! cs (mus-location e))
		    (set! (mus-location e) 8)
		    (set! enq (env? e))
		    (set! val8 (env e))
		    (set! ep (mus-channels e))
		    (mus-reset e)
		    (set! val0 (env e))
		    (env-interp .5 e)))
      (if (not enq) (snd-display #__line__ ";run env?"))
      (if (not (= cs 2)) (snd-display #__line__ ";run mus-location: ~A" cs))
      (if (not (= ep 0)) (snd-display #__line__ ";run mus-channels: ~A" ep))
      (if (fneq b 1.0) (snd-display #__line__ ";run mus-increment: ~A" b))
      (if (fneq val8 0.8) (snd-display #__line__ ";run set location: ~A" val8))
      (if (fneq val0 0.0) (snd-display #__line__ ";run mus-reset: ~A" val0))
      (if (fneq (vct-ref v 0) .5) (snd-display #__line__ ";run env-interp: ~A" (vct-ref v 0)))
      (catch #t (lambda () (vct-map! v (lambda () (env e 1.0)))) (lambda args args))
      (catch #t (lambda () (vct-map! v (lambda () (env-interp e)))) (lambda args args)))
    
    (test-set-gens)
    
    (let ((flt (make-filter 3 (vct .1 .2 .3) (vct .4 .5 .6)))
	  (v (make-vct 1))
	  (d1 -1.0)
	  (x1 -1.0)
	  (y1 -1.0))
      (vct-map! v (lambda ()
		    (filter flt 1.0)
		    (set! d1 (vct-ref (mus-data flt) 1))
		    (set! x1 (vct-ref (mus-xcoeffs flt) 1))
		    (set! y1 (vct-ref (mus-ycoeffs flt) 1))
		    0.0))
      (if (fneq d1 1.0) (snd-display #__line__ ";run mus-data: ~A ~A" d1 (mus-data flt)))
      (if (fneq x1 .2) (snd-display #__line__ ";run mus-xcoeffs: ~A ~A" x1 (mus-xcoeffs flt)))
      (if (fneq y1 .5) (snd-display #__line__ ";run mus-ycoeffs: ~A ~A" y1 (mus-ycoeffs flt))))
    
    (let ((grn (make-granulate :expansion 2.0))
	  (v (make-vct 1))
	  (gr 123)
	  (gs .123)
	  (ge .123)
	  (gh 123))
      (vct-map! v (lambda ()
		    (set! gr (mus-ramp grn))
		    (set! gs (mus-scaler grn))
		    (set! ge (mus-increment grn))
		    (set! gh (mus-hop grn))
		    (set! (mus-ramp grn) 321)
		    (set! (mus-scaler grn) .321)
		    (set! (mus-hop grn) 1234)
		    0.0))
      (if (and (not (= gr 1323)) (not (= gr 2646))) (snd-display #__line__ ";run ramp: ~A" gr))
      (if (and (not (= gh 1102)) (not (= gh 2205))) (snd-display #__line__ ";run hop: ~A" gh))
      (if (fneq gs 0.6) (snd-display #__line__ ";run scaler: ~A" gs))
      (if (fneq ge 2.0) (snd-display #__line__ ";run gran exp: ~A" ge))
      (if (fneq (mus-scaler grn) .321) (snd-display #__line__ ";run set scl: ~A" (mus-scaler grn)))
      (if (not (= (mus-hop grn) 1234)) (snd-display #__line__ ";run set hop: ~A" (mus-hop grn)))
      (if (not (= (mus-ramp grn) 321)) (snd-display #__line__ ";run set ramp: ~A" (mus-ramp grn))))
    
    (let ((v0 (make-vct 1))
	  (v1 (make-vct 1))
	  (v (make-vct 1))
	  (val .123))
      (vct-set! v0 0 1.0)
      (vct-set! v1 0 1.0)
      (vct-map! v (lambda ()
		    (rectangular->polar v0 v1)
		    (set! val (vct-ref v0 0))
		    (polar->rectangular v0 v1)
		    (vct-ref v1 0)))
      (if (fneq (vct-ref v 0) 1.0) (snd-display #__line__ ";run r->p not inverted: ~A" v))
      (if (fneq val (sqrt 2.0)) (snd-display #__line__ ";r->p: ~A" val)))
    
    (let ((v (make-vct 1))
	  (v0 (vct 1.0 2.0))
	  (v1 (vct 0.5 1.0)))
      (vct-map! v (lambda ()
		    (dot-product v0 v1)))
      (if (fneq (vct-ref v 0) 2.5) (snd-display #__line__ ";run dot-product: ~A" (vct-ref v 0))))
    
    (let ((v (make-vct 1))
	  (v0 (vct 1.0 2.0))
	  (v1 (vct 0.5 1.0)))
      (vct-map! v (lambda ()
		    (dot-product v0 v1 2)))
      (if (fneq (vct-ref v 0) 2.5) (snd-display #__line__ ";run dot-product (2): ~A" (vct-ref v 0))))
    
    (let ((fr1 (make-frame 2 .1 .2))
	  (fr2 (make-frame 2 .3 .4))
	  (fr3 (make-frame 2 0.0 0.0))
	  (fr4 (make-frame 2 0.0 0.0))
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (frame* fr1 fr2 fr3)
		    (frame+ fr1 fr2 fr4)
		    (frame->sample fr1 fr2)))
      (if (fneq (frame-ref fr3 0) .03) (snd-display #__line__ ";run frame* 0: ~A" (frame-ref fr3 0)))
      (if (fneq (frame-ref fr3 1) .08) (snd-display #__line__ ";run frame* 1: ~A" (frame-ref fr3 1)))
      (if (fneq (frame-ref fr4 0) .4) (snd-display #__line__ ";run frame+ 0: ~A" (frame-ref fr4 0)))
      (if (fneq (frame-ref fr4 1) .6) (snd-display #__line__ ";run frame+ 1: ~A" (frame-ref fr4 1)))
      (if (fneq (vct-ref v 0) .11) (snd-display #__line__ ";run frame->sample: ~A" (vct-ref v 0)))
      (let ((val (run (lambda () (frame+ fr1 1.0)))))
	(if (or (fneq (frame-ref val 0) 1.1)
		(fneq (frame-ref val 1) 1.2))
	    (snd-display #__line__ ";frame-offset: ~A" val)))
      (let ((val (run (lambda () (frame+ 1.0 fr1)))))
	(if (or (fneq (frame-ref val 0) 1.1)
		(fneq (frame-ref val 1) 1.2))
	    (snd-display #__line__ ";frame-offset a: ~A" val)))
      (let ((val (run (lambda () (frame* fr1 2.0)))))
	(if (or (fneq (frame-ref val 0) 0.2)
		(fneq (frame-ref val 1) 0.4))
	    (snd-display #__line__ ";frame-scale: ~A" val)))
      (let ((val (run (lambda () (frame* 2.0 fr1)))))
	(if (or (fneq (frame-ref val 0) 0.2)
		(fneq (frame-ref val 1) 0.4))
	    (snd-display #__line__ ";frame-scale a: ~A" val))))
    (let ((v0 (make-vct 4))
	  (v1 (make-vct 4))
	  (v (make-vct 1)))
      (vct-set! v0 0 1.0)
      (vct-set! v1 2 1.0)
      (vct-map! v (lambda () (convolution v0 v1) 0.0))
      (if (or (not (vequal v0 (vct 0.0 0.0 1.0 0.0)))
	      (not (vequal v1 (vct 0.0 0.0 0.0 0.0))))
	  (snd-display #__line__ ";run convolution: ~A ~A" v0 v1)))
    
    (let ((v0 (make-vct 4))
	  (v1 (make-vct 4))
	  (v (make-vct 1)))
      (vct-set! v0 0 1.0)
      (vct-set! v1 2 1.0)
      (vct-map! v (lambda () (vct-convolve! v0 v1) 0.0))
      (if (or (not (vequal v0 (vct 0.0 0.0 1.0 0.0)))
	      (not (vequal v1 (vct 0.0 0.0 0.0 0.0))))
	  (snd-display #__line__ ";run vct-convolve!: ~A ~A" v0 v1)))
    
    (if all-args
	(let ((v (make-vct 1))
	      (amps (list->vct '(0.5 0.25 1.0)))
	      (phases (list->vct '(1.0 0.5 2.0))))
	  (vct-map! v (lambda () (sine-bank amps phases)))
	  (if (fneq (vct-ref v 0) 1.44989) (snd-display #__line__ ";run sine-bank: ~A?" (vct-ref v 0)))))
    (if all-args
	(let ((v (make-vct 1))
	      (amps (list->vct '(0.5 0.25 1.0)))
	      (phases (list->vct '(1.0 0.5 2.0))))
	  (vct-map! v (lambda () (sine-bank amps phases 3)))
	  (if (fneq (vct-ref v 0) 1.44989) (snd-display #__line__ ";run sine-bank (1): ~A?" (vct-ref v 0)))))
    
    (let ((fr0 (make-frame 2 1.0 1.0))
	  (fr1 (make-frame 2 0.0 0.0))
	  (gen (make-mixer 2 .5 .25 .125 1.0))
	  (v (make-vct 1)))
      (vct-map! v (lambda () (frame->frame fr0 gen fr1) (frame-ref fr1 1)))
      (if (fneq (frame-ref fr1 1) 1.25) (snd-display #__line__ ";run frame->frame right: ~A" fr1)))
    
    (let ((fr0 (make-frame 2 1.0 1.0))
	  (fr1 (make-frame 2 0.0 0.0))
	  (gen (make-mixer 2 .5 .25 .125 1.0))
	  (v (make-vct 1)))
      (vct-map! v (lambda () (frame->frame gen fr0 fr1) (frame-ref fr1 1)))
      (if (fneq (frame-ref fr1 1) 1.125) (snd-display #__line__ ";run frame->frame left: ~A" fr1)))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (win (make-fft-window rectangular-window 16))
	  (v (make-vct 1)))
      (vct-set! rdat 0 1.0)
      (vct-map! v (lambda ()
		    (spectrum rdat idat win 1)
		    0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 8)) 
	(if (fneq (vct-ref rdat i) 1.0)
	    (snd-display #__line__ ";run impulse->flat? ~A" rdat)))
      (catch #t (lambda () (vct-map! v (lambda () (spectrum rdat idat win 17.3)))) (lambda args args)))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (win (make-fft-window rectangular-window 16))
	  (v (make-vct 1)))
      (vct-set! rdat 0 1.0)
      (vct-map! v (lambda ()
		    (spectrum rdat idat win)
		    0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 8)) 
	(if (fneq (vct-ref rdat i) 1.0)
	    (snd-display #__line__ ";run impulse->flat (1)? ~A" rdat))))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (win (make-fft-window rectangular-window 16))
	  (v (make-vct 1)))
      (vct-set! rdat 0 1.0)
      (vct-map! v (lambda ()
		    (spectrum rdat idat win)
		    0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 8)) 
	(if (fneq (vct-ref rdat i) 1.0)
	    (snd-display #__line__ ";run impulse->flat (2)? ~A" rdat))))
    
    (let ((mx1 (make-mixer 2))
	  (mx2 (make-mixer 2))
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (mixer-set! mx1 0 0 .1)
		    (mixer* mx1 mx1 mx2)
		    0.0))
      (if (fneq (mixer-ref mx2 0 0) .01) (snd-display #__line__ ";run mixer* res: ~A" mx2)))
    
    (let ((mx1 (make-mixer 2 1 2 3 4)) 
	  (mx2 (make-mixer 2 0 0 0 0))) 
      (run (lambda () (mixer* mx1 2.0 mx2)))
      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
	  (snd-display #__line__ ";run mixer-scale 1: ~A" mx2)))
    
    (let* ((mx1 (make-mixer 2 1 2 3 4))
	   (mx2 (run (lambda () (mixer* mx1 2.0)))))
      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
	  (snd-display #__line__ ";run mixer-scale 2: ~A" mx2))
      (set! mx2 (run (lambda () (mixer* 2.0 mx1))))
      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
	  (snd-display #__line__ ";run mixer-scale 2a: ~A" mx2))
      (set! mx2 (run (lambda () (mixer+ 2.0 mx1))))
      (if (not (equal? mx2 (make-mixer 2 3 4 5 6)))
	  (snd-display #__line__ ";run mixer-offset 2: ~A" mx2))
      (set! mx2 (run (lambda () (mixer+ mx1 2.0))))
      (if (not (equal? mx2 (make-mixer 2 3 4 5 6)))
	  (snd-display #__line__ ";run mixer-offset 2a: ~A" mx2)))
    
    (let ((mx1 (make-mixer 2))
	  (mx2 (make-mixer 2))
	  (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (set! (mixer-ref mx1 0 0) .1)
		    (mixer* mx1 mx1 mx2)
		    0.0))
      (if (fneq (mixer-ref mx2 0 0) .01) (snd-display #__line__ ";run mixer* res (set): ~A" mx2)))
    
    (let ((gen (make-sample->file "fmv.snd" 2 mus-lshort mus-riff))
	  (v (make-vct 1))
	  (oq #f)
	  (sq #f))
      (vct-map! v (lambda ()
		    (set! oq (mus-output? gen))
		    (set! sq (sample->file? gen))
		    (do ((i 0 (+ 1 i)))
			((= i 100))
		      (sample->file gen i 0 (* i .001))
		      (sample->file gen i 1 (* i .01)))
		    (outa 50 .015 gen)
		    (outb 50 .15 gen)
		    (out-any 60 .015 0 gen)
		    (out-any 60 .15 1 gen)
		    0.0))
      (mus-close gen)
      (if (not oq) (snd-display #__line__ ";run mus-output?"))
      (if (not sq) (snd-display #__line__ ";run mus-output?"))
      (catch #t (lambda () (vct-map! v (lambda () (sample->file gen)))) (lambda args args))
      (catch #t (lambda () (vct-map! v (lambda () (sample->file gen 0 0 .1 .2)))) (lambda args args)))
    
    (let ((gen (make-vct 10))
	  (chans 0))
      (run 
       (lambda ()
	 (set! chans (mus-channels gen))
	 (do ((i 0 (+ 1 i))
	      (x 0.0 (+ x 0.1)))
	     ((= i 10))
	   (outa i x gen))))
      (if (not (vequal gen (vct 0 .1 .2 .3 .4 .5 .6 .7 .8 .9)))
	  (snd-display #__line__ ";outa->vct opt ramp: ~A" gen))
      (if (not (= chans 1)) (snd-display #__line__ ";mus-channels vct opt: ~A" chans))
      (run 
       (lambda ()
	 (do ((i 0 (+ 1 i))
	      (x 0.0 (+ x 0.1)))
	     ((= i 10))
	   (outa i x gen))))
      (if (not (vequal gen (vct-scale! (vct 0 .1 .2 .3 .4 .5 .6 .7 .8 .9) 2.0)))
	  (snd-display #__line__ ";outa->vct opt ramp 2: ~A" gen)))
    
    (let ((gen (make-sound-data 4 100))
	  (chans 0))
      (run 
       (lambda ()
	 (set! chans (mus-channels gen))
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (outa i .1 gen)
	   (outb i .2 gen)
	   (outc i .3 gen)
	   (outd i .4 gen))
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (outa i .01 gen)
	   (outb i .02 gen)
	   (outc i .03 gen)
	   (outd i .04 gen))
	 (mus-close gen)))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (or (fneq (ina i gen) .11)
		(fneq (inb i gen) .22)
		(fneq (in-any i 2 gen) .33)
		(fneq (in-any i 3 gen) .44))
	    (snd-display #__line__ ";4-chan sd opt out/in[~A]: ~A ~A ~A ~A?" i (ina i gen) (inb i gen) (in-any i 2 gen) (in-any i 3 gen))))
      (if (not (= chans 4)) (snd-display #__line__ ";mus-channels sd 4 opt: ~A" chans)))
    
    (let ((gen (make-sound-data 4 100)))
      (run 
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (out-any i .1 0 gen)
	   (out-any i .2 1 gen)
	   (out-any i .3 2 gen)
	   (out-any i .4 3 gen))
	 (do ((i 0 (+ 1 i)))
	     ((= i 10))
	   (out-any i .01 0 gen)
	   (out-any i .02 1 gen)
	   (out-any i .03 2 gen)
	   (out-any i .04 3 gen))))
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(if (or (fneq (in-any i 0 gen) .11)
		(fneq (in-any i 1 gen) .22)
		(fneq (in-any i 2 gen) .33)
		(fneq (in-any i 3 gen) .44))
	    (snd-display #__line__ ";4-chan sd out/in-any[~A]: ~A ~A ~A ~A?" i (in-any i 0 gen) (in-any i 1 gen) (in-any i 2 gen) (in-any i 3 gen)))))
    
    (let* ((gen (make-file->sample "fmv.snd"))
	   (vals (make-vct 10))
	   (iq #f)
	   (fq #f)
	   (v (make-vct 1)))
      (vct-map! v (lambda ()
		    (vct-set! vals 0 (in-any 20 0 gen))
		    (vct-set! vals 1 (in-any 20 1 gen))
		    (vct-set! vals 2 (ina 30 gen))
		    (vct-set! vals 3 (inb 30 gen))
		    (vct-set! vals 4 (file->sample gen 40 0))
		    (vct-set! vals 5 (file->sample gen 40 1))
		    (vct-set! vals 6 (in-any 50 0 gen))
		    (vct-set! vals 7 (in-any 50 1 gen))
		    (vct-set! vals 8 (in-any 60 0 gen))
		    (vct-set! vals 9 (in-any 60 1 gen))
		    (set! iq (mus-input? gen))
		    (set! fq (file->sample? gen))
		    0.0))
      (if (not iq) (snd-display #__line__ ";run mus-input?"))
      (if (not fq) (snd-display #__line__ ";run file->sample?"))
      (if (not (vequal vals (vct .02 .2 .03 .3 .04 .4 .065 .65 .075 .75))) (snd-display #__line__ ";run i/o: ~A" vals)))
    (delete-file "fmv.snd")
    
    (let ((gen (make-frame->file "fmv.snd" 2 mus-bshort mus-next))
	  (v (make-vct 1))
	  (fq #f)
	  (fr0 (make-frame 2 0.0 0.0)))
      (vct-map! v (lambda ()
		    (set! fq (frame->file? gen))
		    (do ((i 0 (+ 1 i)))
			((= i 10))
		      (frame-set! fr0 0 (* i .001))
		      (frame-set! fr0 1 (* i .01))
		      (frame->file gen i fr0))
		    0.0))
      (mus-close gen)
      (if (not fq) (snd-display #__line__ ";run frame->file?")))
    
    (let* ((gen (make-file->frame "fmv.snd"))
	   (frout (make-frame 2))
	   (v (make-vct 1))
	   (fq #f))
      (vct-map! v (lambda ()
		    (file->frame gen 4 frout)
		    (set! fq (file->frame? gen))
		    (frame-ref frout 0)))
      (if (not fq) (snd-display #__line__ ";run file->frame?"))
      (if (fneq (vct-ref v 0) .004) (snd-display #__line__ ";run frame i/o: ~A" frout)))
    (delete-file "fmv.snd")
    
    (let ((hi (make-power-env '(0 0 32.0 1 1 .0312 2 0 1) :duration 1.0)))
      (itsta '(lambda (y) (declare (y penv)) (+ 1 2)) hi 3)
					;(itsta '(lambda () (penv-total-envs hi)) 0 2)
      )
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((r (make-sampler 2000))
	    (v (make-vct 2)))
	(itst '(srate) 22050)
	(itst '(channels) 1)
	(itst '(frames) 50828)
	(if (not (= (run (lambda () (srate ind))) 22050))
	    (snd-display #__line__ ";run srate ind: ~A" (run (lambda () (srate ind)))))
	(if (not (= (run (lambda () (channels ind))) 1))
	    (snd-display #__line__ ";run channels ind: ~A" (run (lambda () (channels ind)))))
	(if (not (= (run (lambda () (frames ind 0))) 50828))
	    (snd-display #__line__ ";run frames ind: ~A" (run (lambda () (frames ind 0)))))
	(vct-map! v (lambda () (next-sample r)))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample ftst: ~A" v))
	(vct-map! v (lambda () (previous-sample r)))
	(if (or (fneq (vct-ref v 0) .0551) (fneq (vct-ref v 1) .0662)) (snd-display #__line__ ";previous-sample ftst: ~A" v))
	(previous-sample r)
	(next-sample r)
	(vct-map! v (lambda () (read-sample r)))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";read-sample ftst: ~A" v))
	(vct-map! v (lambda () (r)))
	(if (or (fneq (vct-ref v 0) .039) (fneq (vct-ref v 1) .024)) (snd-display #__line__ ";read-sample apply ftst: ~A" v))
	(etst '(set! (sample 100) 0.0))
	)
      (close-sound ind))
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((val (run (lambda () (let ((ho (make-sampler 12345.0))) (read-sample ho))))))
	(if (fneq val 0.0549)
	    (snd-display #__line__ ";run make-sampler with float sample arg: ~A" val)))
      (let ((v (make-vct 2)))
	(ftst '(let ((r (make-sampler 1200.0))) (next-sample r)) 0.04898)
	(vct-map! v (let ((r (make-sampler 2000)))
		      (lambda () (next-sample r))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let ftst: ~A" v))
	(vct-map! v (let ((r (make-sampler 2000 #f)))
		      (lambda () (next-sample r))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let ftst #f: ~A" v))
	(vct-map! v (let ((r (make-sampler 2000 #f #f)))
		      (lambda () (next-sample r))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let ftst #f #f: ~A" v))
	(vct-map! v (let ((r (make-sampler 2000 #f #f 1 current-edit-position)))
		      (lambda () (next-sample r))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let ftst #f #f 1 -1: ~A" v))
	(vct-map! v (let ((r (make-sampler 2000 ind)))
		      (lambda () (next-sample r))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let snd ftst: ~A" v))
	(vct-map! v (let ((r (make-sampler 2000 ind 0)))
		      (lambda () (next-sample r))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let chn ftst: ~A" v))
	(vct-map! v (let ((r (make-sampler 2000 ind 0 1 (edit-position ind 0))))
		      (lambda () 
			(if (or (not (= (edit-position ind 0) 0))
				(not (= (edit-position ind) 0))
				(not (= (edit-position) 0)))
			    (begin
			      (report-in-minibuffer "oops")
			      (report-in-minibuffer "oops again" ind)
			      -123.0)
			    (next-sample r)))))
	(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display #__line__ ";next-sample let edit ftst: ~A" v))
	(itst '(frames) 50828)
	(itst (list 'frames ind) 50828)
	(itst (list 'frames ind 0) 50828)
	(itst (list 'frames ind 0 0) 50828)
	(itst (list 'frames #f 0) 50828)
	(itst (list 'frames #f #f) 50828)
	(itst (list 'frames #f #f current-edit-position) 50828)
	(itst (list 'cursor ind) 0)
	(itst (list 'cursor) 0)
	(itst (list 'cursor ind 0) 0)
	(ftst (list 'maxamp ind 0) .1472)
	(ftst (list 'maxamp ind 0 -1) .1472)
	(ftst (list 'maxamp ind 0 0) .1472)
	(ftst (list 'maxamp) .1472)
	(set! (cursor ind 0) 100)
	(itst (list 'cursor ind) 100)
	(itst (list 'cursor) 100)
	(itst (list 'cursor ind 0) 100)
	(etst '(edit-position ind 0 0))
	(close-sound ind)))
    
    (let ((ind0 (new-sound "fmv0.snd" mus-next mus-bfloat 22050 1 "map tests"))
	  (ind1 (new-sound "fmv1.snd" mus-next mus-bfloat 22050 1 "map tests"))
	  (ones (make-vct 1000000))
	  (t0 0)
	  (t1 0)
	  (ts '()))
      (vct-map! ones (lambda () (- 1.0 (* 2 (random 1.0)))))
      (vct->channel ones 0 1000000 ind0)
      (vct->channel ones 0 1000000 ind1)
      (set! (optimization) 0) 
      (set! t0 (time-it (map-channel (lambda (y) (* y 2)) 0 1000000 ind0)))
      (set! (optimization) max-optimization) 
      (set! t1 (time-it (map-channel (lambda (y) (* y 2)) 0 1000000 ind1)))
      (if (not (vequal (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1))) 
	  (snd-display #__line__ ";y * 2 run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
      (set! ts (cons (list "*2     " (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      (set! (optimization) 0) 
      (set! t0 (time-it (map-channel (lambda (y) (- y 1.0)) 0 1000000 ind0)))
      (set! (optimization) max-optimization)
      (set! t1 (time-it (map-channel (lambda (y) (- y 1.0)) 0 1000000 ind1)))
      (if (not (vequal (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1))) 
	  (snd-display #__line__ ";y - 1 run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
      (set! ts (cons (list "-1     " (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      (set! (optimization) 0) 
      (set! t0 (time-it (map-channel (lambda (y) (abs (sin y))) 0 1000000 ind0)))
      (set! (optimization) max-optimization) 
      (set! t1 (time-it (map-channel (lambda (y) (abs (sin y))) 0 1000000 ind1)))
      (if (not (vequal (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1))) 
	  (snd-display #__line__ ";abs sin run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
      (set! ts (cons (list "abs sin" (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      (set! (optimization) 0) 
      (set! t0 (time-it (map-channel (lambda (y) (let ((a (* y 2))) (if (> y 1.0) 1.0 y))) 0 1000000 ind0)))
      (set! (optimization) max-optimization) 
      (set! t1 (time-it (map-channel (lambda (y) (let ((a (* y 2))) (if (> y 1.0) 1.0 y))) 0 1000000 ind1)))
      (if (not (vequal (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1))) 
	  (snd-display #__line__ ";let y run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
      (set! ts (cons (list "let if " (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      (set! (optimization) 0) 
      (set! t0 (time-it (map-channel (let ((v (make-vct 3))) (lambda (y) (vct-set! v 1 .5) (* y (vct-ref v 1)))) 0 1000000 ind0)))
      (set! (optimization) max-optimization) 
      (set! t1 (time-it (map-channel (let ((v (make-vct 3))) (lambda (y) (vct-set! v 1 .5) (* y (vct-ref v 1)))) 0 1000000 ind1)))
      (if (not (vequal (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1))) 
	  (snd-display #__line__ ";let y run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
      (set! ts (cons (list "vct-ref" (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      
      (set! (optimization) 0) 
      (set! t0 (time-it (let ((osc (make-oscil :frequency 440))
			      (e1 (make-env '(0 0 1 1 2 0) :length 1000000)))
			  (map-channel (lambda (y) (* (env e1) (oscil osc y))) 0 1000000 ind0))))
      (set! (optimization) max-optimization) 
      (set! t1 (time-it (let ((osc (make-oscil :frequency 440))
			      (e1 (make-env '(0 0 1 1 2 0) :length 1000000)))
			  (map-channel (lambda (y) (* (env e1) (oscil osc y))) 0 1000000 ind1))))
      (if (not (vequal (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1))) 
	  (snd-display #__line__ ";let y run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
      (set! ts (cons (list "osc+env" (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      
      (close-sound ind0)
      (close-sound ind1)
      (snd-display #__line__ ";timings:~{~%~20T~A~}" ts))
    
    (let ((v0 (make-vct 10))
	  (v1 (make-vct 10)))
      (set! (optimization) 0) (vct-map! v0 (lambda () .1))
      (set! (optimization) max-optimization) (vct-map! v1 (lambda () .1))
      (if (or (not (vequal v0 v1)) (fneq (vct-ref v1 0) .1)) (snd-display #__line__ ";vct-map .1: ~A ~A" v0 v1))
      (set! dbl-var .1)
      (set! (optimization) 0) (vct-map! v0 (lambda () dbl-var))
      (set! (optimization) max-optimization) (vct-map! v1 (lambda () dbl-var))
      (if (or (not (vequal v0 v1)) (fneq (vct-ref v1 0) .1)) (snd-display #__line__ ";vct-map dbl-var .1: ~A ~A" v0 v1))
      (let ((dbl-var .3))
	(set! (optimization) 0) (vct-map! v0 (lambda () dbl-var))
	(set! (optimization) max-optimization) (vct-map! v1 (lambda () dbl-var))
	(if (or (not (vequal v0 v1)) (fneq (vct-ref v1 0) .3)) (snd-display #__line__ ";vct-map dbl-var .3: ~A ~A" v0 v1)))
      (let ((dbl-var .3))
	(let ((dbl-var .5))
	  (set! (optimization) 0) (vct-map! v0 (lambda () dbl-var))
	  (set! (optimization) max-optimization) (vct-map! v1 (lambda () dbl-var))
	  (if (or (not (vequal v0 v1)) (fneq (vct-ref v1 0) .5)) (snd-display #__line__ ";vct-map dbl-var .5: ~A ~A" v0 v1))))
      (let ((dbl-var .3))
	(let ((dbl-var .5))
	  (set! (optimization) 0) (vct-map! v0 (let ((dbl-var .9)) (lambda () dbl-var)))
	  (set! (optimization) max-optimization) (vct-map! v1 (let ((dbl-var .9)) (lambda () dbl-var)))
	  (if (or (not (vequal v0 v1)) (fneq (vct-ref v1 0) .9)) (snd-display #__line__ ";vct-map dbl-var .9: ~A ~A" v0 v1))))
      (let ((dbl-var .3))
	(let ((dbl-var .5))
	  (set! (optimization) 0) (vct-map! v0 (let ((dbl-var .9)) (lambda () (let ((dbl-var .01)) dbl-var))))
	  (set! (optimization) max-optimization) (vct-map! v1 (let ((dbl-var .9)) (lambda () (let ((dbl-var .01)) dbl-var))))
	  (if (or (not (vequal v0 v1)) (fneq (vct-ref v1 0) .01)) (snd-display #__line__ ";vct-map dbl-var .01: ~A ~A" v0 v1))))
      )
    
    (let ((t0 0)
	  (t1 0)
	  (ts '()))
      (set! (optimization) 0) 
      (set! t0 (time-it (with-temp-sound (:srate 44100 :output (make-vct (round (* 5 (mus-srate))))) (fm-violin 0 5 440 .1))))
      (set! (optimization) max-optimization) 
      (set! t1 (time-it (with-temp-sound (:srate 44100 :output (make-vct (round (* 5 (mus-srate))))) (fm-violin 0 5 440 .1))))
      (set! ts (cons (list "fm vln " (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
      
      (let ((ind (open-sound "1.snd"))
	    (v0 #f)
	    (v1 #f))
	(set! (optimization) 0) 
	(set! t0 (time-it (expsnd '(0 1 2 .4))))
	(set! v0 (channel->vct 1000 100))
	(undo 1 ind)
	(set! (optimization) max-optimization) 
	(set! t1 (time-it (expsnd '(0 1 2 .4))))
	(set! v1 (channel->vct 1000 100))
	(if (not (vequal v0 v1)) (snd-display #__line__ ";expsnd: opt: ~A ~A" v0 v1))
	(set! ts (cons (list "expsnd " (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
	(undo 1 ind)
	(set! (optimization) 0) 
	(set! t0 (time-it (snd-test-jc-reverb 1.0 #f 1.0 #f)))
	(set! v0 (channel->vct 1000 100))
	(undo 1 ind)
	(set! (optimization) max-optimization) 
	(set! t1 (time-it (snd-test-jc-reverb 1.0 #f 1.0 #f)))
	(set! v1 (channel->vct 1000 100))
	(if (not (vequal v0 v1)) (snd-display #__line__ ";jcrev: opt: ~A ~A" v0 v1))
	(set! ts (cons (list "jcrev  " (hundred t0) (hundred t1) (round (safe-divide t0 t1))) ts))
	(close-sound ind))
      (snd-display #__line__ "~{~%~20T~A~}~%" ts))
    (if with-gui
	(let* ((osc (make-oscil 440))
	       (vi (make-vector 2 1))
	       (vf (make-vector 2 .1))
	       (v (make-vct 2 3.14))
	       (vv (make-vector 2 v))
	       (vc (make-vector 2 osc))
	       (vc1 (make-vector 12 osc))
	       (vi1 (make-vector 12 1))
	       (vv1 (make-vector 12 v))
	       (ind (open-sound "oboe.snd"))
	       (sm (make-sampler 0 ind))
	       (mx (mix-vct (make-vct 10 .1) 100))
	       (sd (make-sound-data 2 3))
	       (mxr (make-mix-sampler mx)))
	  
	  (run (lambda ()
		 (define (hi a) (+ a 1))
		 (display "---------------------------------------------------------------") (display #\newline)
		 (display 3) (display .14) (display "15") (display #\1) (display #f) 
		 (display osc) (display vi) (display vf) (display v) (display vv) (display vc) (display sm)
		 (display mxr) (display sd) (display vi1) (display vv1) (display vc1)
		 (snd-print "snd-print test...")
		 (snd-warning "snd-warning test...")
		 (report-in-minibuffer "report-in-minibuffer test..." ind)
		 (display hi) (display '(1 2)) (display :hiho) (display 'asdf)
		 (call/cc (lambda (hiho) (if #f (hiho) (display hiho))))
		 (call-with-current-continuation (lambda (hiho) (if #f (hiho) (display hiho))))
		 (display svar)
		 (display #\newline) (display "---------------------------------------------------------------") (display #\newline)
		 ))
	  (close-sound ind)))
    
    (let ((val (run-eval '(lambda () (fneq .1 .1)))))
      (if val (snd-display #__line__ ";embedded func 0: ~A" val)))
    (let ((val (run-eval '(lambda () (fneq .1 .2)))))
      (if (not val) (snd-display #__line__ ";embedded func 1: ~A" val)))
    (let ((val (run-eval '(lambda () (fneq .1 .1001)))))
      (if val (snd-display #__line__ ";embedded func 2: ~A" val)))
    
    (let ((val (run-eval '(fneq .1 .1))))
      (if val (snd-display #__line__ ";embedded func 3: ~A" val)))
    (let ((val (run-eval '(fneq .1 .2))))
      (if (not val) (snd-display #__line__ ";embedded func 4: ~A" val)))
    (let ((val (run-eval '(fneq .1 .1001))))
      (if val (snd-display #__line__ ";embedded func 5: ~A" val)))
    
    (let ((val (run-eval '(efunc-1 1.5))))
      (if (fneq val 2.5) (snd-display #__line__ ";embedded func 6: ~A" val)))
    (let ((val (run-eval '(+ 1.0 (efunc-1 1.5)))))
      (if (fneq val 3.5) (snd-display #__line__ ";embedded func 7: ~A" val)))
    (let ((val (run-eval '(efunc-1 1))))
      (if (not (= val 2)) (snd-display #__line__ ";embedded func 8: ~A" val)))
    (let ((val (run-eval '(* 2 (efunc-1 1)))))
      (if (not (= val 4)) (snd-display #__line__ ";embedded func 9: ~A" val)))
    
    (let ((val (run-eval '(if (fneq .1 .2) (* 2 (efunc-1 1)) -1))))
      (if (not (= val 4)) (snd-display #__line__ ";embedded func 10: ~A" val)))
    
    (let ((val (run-eval '(efunc-2 #f))))
      (if (not val) (snd-display #__line__ ";embedded func 11: ~A" val)))
    (let ((val (run-eval '(if (efunc-2 (fneq .1 .1)) 0 1))))
      (if (not (= val 0)) (snd-display #__line__ ";embedded func 12: ~A" val)))
    (let ((val (run-eval '(if (efunc-2 (fneq .1 (efunc-1 .2))) 0 1))))
      (if (not (= val 1)) (snd-display #__line__ ";embedded func 13: ~A" val)))
    
    (let ((val (run-eval '(efunc-3 (fneq .1 .2) 32 12))))
      (if (not (= val 44)) (snd-display #__line__ ";embedded func 14: ~A" val)))
    
    (let ((val (run-eval '(efunc-4 "hi"))))
      (if (not (string=? val "hi!")) (snd-display #__line__ ";embedded func 15: ~A" val)))
    (let ((val (run-eval '(efunc-5 "hi"))))
      (if (not (= val 3)) (snd-display #__line__ ";embedded func 16: ~A" val)))
    
    (oscil efunc-gen)
    (let ((val (run-eval '(efunc-6 efunc-gen))))
      (if (and (fneq val .125) (fneq val .0626))
	  (snd-display #__line__ ";embedded func 17: ~A" val)))
    (let ((val (run-eval '(oscil (efunc-7 efunc-gen)))))
      (if (and (fneq val .248) 
	       (fneq val .125))
	  (snd-display #__line__ ";embedded func 18: ~A" val)))
    (mus-reset efunc-gen)
    
    (let ((v (vct 1.0 2.0)))
      (run (set! (v 1) 32))
      (if (fneq (v 1) 32.0)
	  (snd-display #__line__ ";vct set i 32: ~A" v)))
    
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->i arg)))))
      (if (not (equal? val 35)) (snd-display #__line__ ";run func i->i: ~A (35)" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i2->i arg)))))
      (if (not (equal? val 38)) (snd-display #__line__ ";run func i2->i: ~A (38)" val)))
    (let* ((arg1 3)
	   (val (run (lambda () (t22-i->i (t22-i->i arg1))))))
      (if (not (equal? val 67)) (snd-display #__line__ ";run func i->i (2): ~A (67)" val)))
    (let* ((arg1 3)
	   (arg2 2)
	   (val (run (lambda () (t22-i->i (* arg2 (t22-i->i arg1)))))))
      (if (not (equal? val 102)) (snd-display #__line__ ";run func i->i (3): ~A (102)" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->f arg)))))
      (if (not (equal? val 6.0)) (snd-display #__line__ ";run func i->f: ~A (6.0)" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->s arg)))))
      (if (not (equal? val "yes")) (snd-display #__line__ ";run func i->s: ~A (\"yes\")" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->b arg)))))
      (if (not (equal? val #t)) (snd-display #__line__ ";run func i->b: ~A (#t)" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->c arg)))))
      (if (not (equal? val #\I)) (snd-display #__line__ ";run func i->c: ~A (#\\I)" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->k arg)))))
      (if (not (equal? val :yes)) (snd-display #__line__ ";run func i->k: ~A (:yes)" val)))
    (let* ((arg 3)
	   (val (run (lambda () (t22-i->sym arg)))))
      (if (not (equal? val 'yes)) (snd-display #__line__ ";run func i->sym: ~A ('yes)" val)))
    (let* ((arg 440)
	   (val (run (lambda () (t22-i->clm arg)))))
      (if (not (equal? val (make-oscil 440))) (snd-display #__line__ ";run func i->clm: ~A (oscil at 440)" val)))
    (let* ((arg1 11)
	   (arg2 44.0)
	   (val (run (lambda () (t22-i-f->f arg1 arg2)))))
      (if (not (equal? val 55.0)) (snd-display #__line__ ";run func i-f->f: ~A (55.0)" val)))
    (let* ((arg2 1)
	   (arg3 44)
	   (arg1 (make-vector 3 0)) 
	   (val (run (lambda () (t22-iv-i-i->iv arg1 arg2 arg3)))))
      (if (not (equal? val '#(0 44 0))) (snd-display #__line__ ";run func iv-i-i->iv: ~A (#(0 44 0))" val)))
    (let* ((arg2 1)
	   (arg3 44.0)
	   (arg1 (make-vector 3 0.0)) 
	   (val (run (lambda () (t22-fv-i-f->fv arg1 arg2 arg3)))))
      (if (not (vequal val (vct 0.0 44.0 0.0))) (snd-display #__line__ ";run func iv-i-f->iv: ~A (#(0.0 44.0 0.0))" val)))
    (let ((val (run (lambda () (t22-s->c "abcdef")))))
      (if (not (equal? val #\b)) (snd-display #__line__ ";run func s->c: ~A (#\\b)" val)))
    (let ((sd (make-sound-data 2 2)))
      (sound-data-set! sd 1 1 3.0)
      (let ((val (t22-sd->f sd)))
	(if (fneq val 3.0) (snd-display #__line__ ";run func sd->f: ~A (3.0)" val))))
    (let ((sd (make-sound-data 2 2)))
      (sound-data-set! sd 1 1 3.0)
      (let ((val (t22-sd->sd sd)))
	(if (fneq (sound-data-ref val 1 1) 44.0) (snd-display #__line__ ";run func sd->sd: ~A (44.0)" val))))
    (let ((gen (make-fir-filter 12 (make-vct 12 .1))))
      (let ((val (t22-clm->i gen)))
	(if (not (equal? val 12)) (snd-display #__line__ ";run func clm->i: ~A (12)" val))))
    (let* ((arg (vct 1.0 2.0 3.0 4.0))
	   (val (t22-vct->vct arg)))
      (if (not (vequal val (vct 1.0 44.0 3.0 4.0))) (snd-display #__line__ ";run func vct->vct: ~A (<1 2 3 4>)" val)))
    (let* ((arg (vector (make-oscil 330.0) (make-oscil 440.0) (make-oscil 550.0)))
	   (val (t22-cv->f arg)))
      (if (fneq val 440.0) (snd-display #__line__ ";run func clm-vect->f: ~A (440.0)" val)))
    
    (let* ((arg1 3.0)
	   (val (run (lambda () (+ 1.0 (* arg1 2))))))
      (if (fneq val 7.0) (snd-display #__line__ ";mfa run opt: ~A (7.0)" val)))
    (let* ((arg1 3.0)
	   (arg2 5)
	   (arg3 4)
	   (val (run (lambda () (+ (* arg2 arg1) (* arg1 arg3))))))
      (if (fneq val 27.0) (snd-display #__line__ ";mfi run opt: ~A (27.0)" val)))
    (let* ((arg1 2.0)
	   (val (run (lambda () (* (sin (/ pi 2)) arg1)))))
      (if (fneq val 2.0) (snd-display #__line__ ";sin and pi run opt: ~A (2.0)" val)))
    (let* ((arg1 2.0)
	   (arg2 pi)
	   (val (run (lambda () (* (sin (/ arg2 2)) arg1)))))
      (if (fneq val 2.0) (snd-display #__line__ ";sin run opt: ~A (2.0)" val)))
    
    (let ((val
	   (let ((xx 3)
		 (yy 0))
	     (run
	      (lambda ()
		(let ((x (+ xx 1)))
		  (do ((i x (+ i 1)))
		      ((= i 10))
		    (set! yy x)))))
	     yy)))
      (if (not (= val 4)) (snd-display #__line__ ";run do: ~A (4)" val)))
    
    (let ((val
	   (let ((xx 3)
		 (yy 0))
	     (run
	      (lambda ()
		(let* ((x (+ xx 1)))
		  (let ((i x))
		    (set! i 10)
		    (set! yy x)))))
	     yy)))
      (if (not (= val 4)) (snd-display #__line__ ";run do 1: ~A (4)" val)))
    
    (let ((val
	   (let ((x 0))
	     (define (x+ a) (set! x a) (+ a 1))
	     (run
	      (lambda ()
		(do ((i 0 (x+ i)))
		    ((= i 4)))))
	     x)))
      (if (not (= val 3)) (snd-display #__line__ ";run do 2: ~A (3)" val)))
    
    (let ((val
	   (let ((x 0))
	     (define (x+ a) (set! x a) (+ a 1))
	     (do ((i 0 (x+ i)))
		 ((= i 4)))
	     x)))
      (if (not (= val 3)) (snd-display #__line__ ";run do 3: ~A (3)" val)))
    
    (let ((val
	   (run
	    (lambda ()
	      (let ((xx 0))
		(do ((i xx (+ i 1)))
		    ((= i 4) xx)
		  (set! xx i)))))))
      (if (not (= val 3)) (snd-display #__line__ ";run do 4: ~A (3)" val)))
    
    (let ((val
	   (let ((xx 0))
	     (run
	      (lambda ()
		(do ((i 0 (+ i 1)))
		    ((= i 3) xx)
		  (set! xx i)))))))
      (if (not (= val 2)) (snd-display #__line__ ";run do 5: ~A (2)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(* k x))))))
      (if (fneq val 6.2) (snd-display #__line__ ";run do 6: ~A (6.2)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(* x k))))))
      (if (fneq val 6.2) (snd-display #__line__ ";run do 7: ~A (6.2)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(+ k x))))))
      (if (fneq val 5.1) (snd-display #__line__ ";run do 8: ~A (5.1)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(+ x k))))))
      (if (fneq val 5.1) (snd-display #__line__ ";run do 9: ~A (5.1)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(- k x))))))
      (if (fneq val -1.1) (snd-display #__line__ ";run do 10: ~A (-1.1)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(- x k))))))
      (if (fneq val 1.1) (snd-display #__line__ ";run do 11: ~A (1.1)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(/ k x))))))
      (if (fneq val 0.64516129) (snd-display #__line__ ";run do 12: ~A (0.64516129)" val)))
    
    (let ((val
	   (let ((k 2)
		 (x 3.1))
	     (run
	      (lambda ()
		(/ x k))))))
      (if (fneq val 1.55) (snd-display #__line__ ";run do 12: ~A (1.55)" val)))
    
    (let ((val
	   (let ((v (vct 1 2 3 4 5)))
	     (run
	      (lambda () 
		(vct-ref v 3))))))
      (if (fneq val 4.0) (snd-display #__line__ ";run do 13: ~A (4.0)" val)))
    
    (let ((val
	   (let ((v (vct 1 2 3 4 5)))
	     (run
	      (lambda () 
		(vct-ref v 4))))))
      (if (fneq val 5.0) (snd-display #__line__ ";run do 14: ~A (5.0)" val)))
    
    (let ((val
	   (let ((v (vct 1 2 3 4 5)))
	     (run
	      (lambda () 
		(vct-set! v 3 32.0)
		(vct-ref v 3))))))
      (if (fneq val 32.0) (snd-display #__line__ ";run do 15: ~A (21.0)" val)))
    
    (let ((val
	   (let ((v (vct 1 2 3 4 5)))
	     (run
	      (lambda () 
		(set! (vct-ref v 3) 32.0) ; bug here!
		(vct-ref v 3))))))
      (if (fneq val 32.0) (snd-display #__line__ ";run do 16: ~A (21.0)" val)))
    
    (let ((data1 (make-vct 10))
	  (data2 (make-vct 10))
	  (gen1 (make-oscil 100.0))
	  (gen2 (make-oscil 100.0))
	  (e1 (make-env '(0 0 1 1) :end 10))
	  (e2 (make-env '(0 0 1 1) :end 10))
	  (x1 0.1)
	  (y1 0.2)
	  (x2 0.1)
	  (y2 0.2))
      (do ((i 0 (+ i 1)))
	  ((= i 10))
	(vct-set! data1 i (* (env e1) (oscil gen1 (+ x1 y1)))))
      (run
       (lambda ()
	 (do ((i 0 (+ i 1)))
	     ((= i 10))
	   (vct-set! data2 i (* (env e2) (oscil gen2 (+ x2 y2)))))))
      (if (not (vequal data1 data2)) (snd-display #__line__ ";run opt oscil_1f_2_env: ~A ~A" data1 data2)))
    
    (let ((data1 (make-vct 10))
	  (data2 (make-vct 10))
	  (gen1 (make-polyshape 100.0 0.0 (vct 1 .5 2 .5)))
	  (gen2 (make-polyshape 100.0 0.0 (vct 1 .5 2 .5)))
	  (e1 (make-env '(0 0 1 1) :end 10))
	  (e2 (make-env '(0 0 1 1) :end 10))
	  (x1 0.1)
	  (x2 0.1))
      (do ((i 0 (+ i 1)))
	  ((= i 10))
	(vct-set! data1 i (* (env e1) (polyshape gen1 1.0 x1))))
      (run
       (lambda ()
	 (do ((i 0 (+ i 1)))
	     ((= i 10))
	   (vct-set! data2 i (* (env e2) (polyshape gen2 1.0 x2))))))
      (if (not (vequal data1 data2)) (snd-display #__line__ ";run opt polyshape_1fn_env: ~A ~A" data1 data2)))
    
    (let ((val (catch 'oops
		      (lambda ()
			(run (lambda ()
			       (let ((inner 0))
				 (do ((i 0 (+ 1 i)))
				     ((= i 10) inner)
				   (if (= inner 3)
				       (throw 'oops))
				   (set! inner i))))))
		      (lambda args (car args)))))
      (if (not (eq? val 'oops)) (snd-display #__line__ ";run throw: ~A" val)))
    
    (let ((outer 0))
      (let ((val (catch 'oops
			(lambda ()
			  (run (lambda ()
				 (let ((inner 0))
				   (do ((i 0 (+ 1 i)))
				       ((= i 10) inner)
				     (set! outer i)
				     (if (= inner 3)
					 (throw 'oops))
				     (set! inner i))))))
			(lambda args (car args)))))
	(if (not (eq? val 'oops)) (snd-display #__line__ ";run throw: ~A" val))
	(if (not (= outer 4)) (snd-display #__line__ ";run throw reset outer: ~A" outer))))
    
    (let ((val (run (lambda () (let ((v (make-vct 2 .1))) (define (ho xv) (declare (xv vct)) (vct-ref xv 1)) (ho v))))))
      (if (fneq val 0.1) (snd-display #__line__ ";run embedded lambda arg vct: ~A" val)))
    (let ((val (run (lambda () (let ((v (make-vct 2 .1))) (define (ho) (make-vct 3 .5)) (vct-ref (ho) 0))))))
      (if (fneq val 0.5) (snd-display #__line__ ";run embedded lambda rtn vct: ~A" val)))
    (let ((val (run (lambda () (let ((v (make-sound-data 2 3))) (define (ho xv) (declare (xv sound-data)) (sound-data-chans xv)) (ho v))))))
      (if (not (= val 2)) (snd-display #__line__ ";run embedded lambda arg sound-data: ~A" val)))
    (let ((val (run (lambda () (let ((v (make-sound-data 2 3))) (define (ho) (make-sound-data 3 5)) (sound-data-length (ho)))))))
      (if (not (= val 5)) (snd-display #__line__ ";run embedded lambda rtn sound-data: ~A" val)))
    (if with-gui
	(let ((ind (open-sound "oboe.snd")))
	  (let ((val (run (lambda () 
			    (let ((r (make-sampler 1000 ind 0))) 
			      (define (ho rd) (declare (rd sampler)) (next-sample rd)) 
			      (ho r))))))
	    (if (fneq val (sample 1000)) (snd-display #__line__ ";run embedded lambda arg sampler: ~A ~A" (sample 1000) val)))
	  (let ((val (run (lambda ()
			    (define (ho) (make-sampler 1000 ind 0))
			    (read-sample (ho))))))
	    (if (fneq val (sample 1000)) (snd-display #__line__ ";run embedded lambda rtn sampler: ~A ~A" (sample 1000) val)))
	  (close-sound ind)))
    
    (let ((ind (open-sound "oboe.snd")))
      ;; check that sequestering works with init-func/ptree-channel
      (ring-modulate-channel 100)
      (make-region 0 10000)
      (close-sound ind))
    
    (let ((lrla (make-vct 16))
	  (lvok #f))
      (let ((val (run (lambda () 
			(vct-set! lrla 0 1.0)
			(vct-set! lrla 4 1.0)
			(let ((v (autocorrelate lrla)))
			  (set! lvok (vct? v)))
			lrla))))
	(if (not lvok) (snd-display #__line__ ";run autocorrelate vct return?"))
	(if (not (vct? lrla)) (snd-display #__line__ ";run lambda vct return: ~A?" lrla))
	(if (fneq (vct-ref val 0) 2.0) (snd-display #__line__ ";run autocorrelate 0: ~A" (vct-ref lrla 0)))
	(if (fneq (vct-ref val 4) 1.0) (snd-display #__line__ ";run autocorrelate 4: ~A" (vct-ref lrla 4)))))
    
    (if (not (vequal (vct -0.5 1 1)
		     (run (lambda () (partials->polynomial (vct 1 1 2 .5))))))
	(snd-display #__line__ ";run partials->polynomial no kind: ~A" (run (lambda () (partials->polynomial (vct 1 1 2 .5))))))
    (if (not (vequal (vct -0.5 1 1)
		     (run (lambda () (partials->polynomial (vct 1 1 2 .5) mus-chebyshev-first-kind)))))
	(snd-display #__line__ ";run partials->polynomial 1st kind: ~A" (run (lambda () (partials->polynomial (vct 1 1 2 .5) mus-chebyshev-first-kind)))))
    (if (not (vequal (vct 1 1 0)
		     (run (lambda () (partials->polynomial (vct 1 1 2 .5) mus-chebyshev-second-kind)))))
	(snd-display #__line__ ";run partials->polynomial 2nd kind: ~A" (run (lambda () (partials->polynomial (vct 1 1 2 .5) mus-chebyshev-second-kind)))))
    
    (let ((vals (vct 1 1 3 1)))
      (let ((nvals (run (lambda () (normalize-partials vals)))))
	(if (not (vequal nvals (vct 1.000 0.500 3.000 0.500)))
	    (snd-display #__line__ ";run normalize-partials: ~A" nvals))))
    
    (let ((ho 123))
      (let ((val (run-eval '(lambda () (lfunc)))))
	(if (not (= val 3)) (snd-display #__line__ ";opt 6 case broken!: ~A" val))))
    
    (let ((old-opt (optimization)))
      (set! (optimization) 4) ; below global-set level
      (run-eval '(set! int-var 4321))
      (if (not (= int-var 4321)) (snd-display #__line__ ";no global set, int: ~A" int-var))
      (run-eval '(set! dbl-var 4321.5))
      (if (fneq dbl-var 4321.5) (snd-display #__line__ ";no global set, dbl: ~A" dbl-var))
      (run-eval '(set! c-var #\f))
      (if (not (char=? c-var #\f)) (snd-display #__line__ ";no global set, char: ~A" c-var))
      (run-eval '(set! bool-var #t))
      (if (not bool-var) (snd-display #__line__ ";no global set, bool: ~A" bool-var))
      (run-eval '(set! str-var "hiha"))
      (if (not (string=? str-var "hiha")) (snd-display #__line__ ";no global set, str: ~A" str-var))
      (run-eval '(vector-set! ivect 1 2))
      (if (not (= (vector-ref ivect 1) 2)) (snd-display #__line__ ";no global set, ivect: ~A" (vector-ref ivect 1)))
      (set! (optimization) old-opt))
    
    (let ((old-opt (optimization)))
      (for-each
       (lambda (n)
	 (set! (optimization) n)
	 (run (lambda ()
		(set! unique-float 1.5)
		(set! unique-int 5)
		(set! unique-char #\z)
		(set! unique-string "a new string")
		(set! unique-boolean #f)
		(vector-set! unique-float-vector 1 3.0)
		(vector-set! unique-int-vector 1 6)))
	 (if (not (= unique-int 5)) (snd-display #__line__ ";unique-int (~A): ~A" n unique-int))
	 (if (fneq unique-float 1.5) (snd-display #__line__ ";unique-float (~A): ~A" n unique-float))
	 (if (not (char=? unique-char #\z)) (snd-display #__line__ ";unique-char (~A): ~A" n unique-char))
	 (if (not (string=? unique-string "a new string")) (snd-display #__line__ ";unique-string (~A): ~A" n unique-string))
	 (if (not (= (vector-ref unique-int-vector 1) 6)) (snd-display #__line__ ";unique-int-vector (~A): ~A" n unique-int-vector))
	 (if (fneq (vector-ref unique-float-vector 1) 3.0) (snd-display #__line__ ";unique-float-vector (~A): ~A" n unique-float-vector))
	 (if unique-boolean (snd-display #__line__ ";unique-boolean?"))
	 (set! unique-float 3.0)
	 (set! unique-int 3)
	 (set! unique-char #\c)
	 (set! unique-string "hiho")
	 (set! unique-boolean #t)
	 (vector-set! unique-float-vector 1 1.0)
	 (vector-set! unique-int-vector 1 1))
       (list 3 6))
      (set! (optimization) old-opt))
    
    (let ((val (run-eval '(format #f "~A" 'hiho))))
      (if (or (not (string? val))
	      (not (string=? val "hiho")))
	  (snd-display #__line__ ";run format 'hiho: ~A" val)))
    (let ((val (run (lambda () (oscil (make-oscil :frequency 100 :initial-phase 0.0))))))
      (if (fneq val 0.0) (snd-display #__line__ ";run oscil make-oscil: ~A" val)))
    (let ((val (run-eval '(format #f "~A ~A ~A ~A ~A" 'a 'b 'c 'd 'e))))
      (if (not (string=? val "a b c d e"))
	  (snd-display #__line__ ";run format abcde: ~A" val)))
    
    (let ((val (run-eval '(let ((str1 (format #f "~A~A" 'a 'a)) 
				(str2 (format #f "~A" 'a))
				(str3 (format #f "~A~A~A" 'a 'a 'a)) 
				(str4 (format #f "~A" 'a))
				(str5 (format #f "~A" 'a))
				(str6 (format #f "~A" 'b)))
			    (string-append str1 str2 str3 str4 str5 str6)))))
      (if (not (string=? val "aaaaaaaab"))
	  (snd-display #__line__ ";run format aaaaaaaab: ~A" val)))
    
    (let ((tag (catch #t (lambda () (mus-close 1)) (lambda args (car args)))))
      (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";mus-close 1: ~A" tag)))
    
    (if (file-exists? "test.snd")
	(delete-file "test.snd"))
    (run (lambda () 
	   (let ((v (make-sample->file "test.snd" 2 mus-lshort mus-riff))) 
	     (sample->file v 0 0 0.7) 
	     (mus-close v))))
    (if (not (file-exists? "test.snd"))
	(snd-display #__line__ ";run sample->file no file")
	(let ((ind (open-sound "test.snd")))
	  (if (not (= (data-format ind) mus-lshort)) (snd-display #__line__ ";run sample->file data format: ~A" (mus-data-format-name (data-format ind))))
	  (if (not (= (header-type ind) mus-riff)) (snd-display #__line__ ";run sample->file header type: ~A" (mus-header-type-name (header-type ind))))
	  (if (not (= (frames ind) 1)) (snd-display #__line__ ";run sample->file frames: ~A" (frames ind)))
	  (if (not (= (channels ind) 2)) (snd-display #__line__ ";run sample->file chans: ~A" (channels ind)))
	  (if (fneq (sample 0 ind) 0.7) (snd-display #__line__ ";run sample->file sample: ~A" (sample 0 ind)))
	  (close-sound ind)))
    
    (if (file-exists? "test.snd")
	(delete-file "test.snd"))
    (run (lambda () 
	   (let ((v (make-frame->file "test.snd" 4 mus-bfloat mus-aifc)))
	     (frame->file v 0 (make-frame 4 0.7 0.3 0.1 0.2))
	     (mus-close v))))
    (if (not (file-exists? "test.snd"))
	(snd-display #__line__ ";run frame->file no file")
	(let ((ind (open-sound "test.snd")))
	  (if (not (= (data-format ind) mus-bfloat)) (snd-display #__line__ ";run frame->file data format: ~A" (mus-data-format-name (data-format ind))))
	  (if (not (= (header-type ind) mus-aifc)) (snd-display #__line__ ";run frame->file header type: ~A" (mus-header-type-name (header-type ind))))
	  (if (not (= (frames ind) 1)) (snd-display #__line__ ";run frame->file frames: ~A" (frames ind)))
	  (if (not (= (channels ind) 4)) (snd-display #__line__ ";run frame->file chans: ~A" (channels ind)))
	  (if (fneq (sample 0 ind 0) 0.7) (snd-display #__line__ ";run frame->file sample 0: ~A" (sample 0 ind 0)))
	  (if (fneq (sample 0 ind 1) 0.3) (snd-display #__line__ ";run frame->file sample 1: ~A" (sample 0 ind 1)))
	  (if (fneq (sample 0 ind 2) 0.1) (snd-display #__line__ ";run frame->file sample 2: ~A" (sample 0 ind 2)))
	  (if (fneq (sample 0 ind 3) 0.2) (snd-display #__line__ ";run frame->file sample 3: ~A" (sample 0 ind 3)))
	  (close-sound ind)))
    
    (let ((tag (catch #t (lambda () (make-frame 2 .1 .2 .3)) (lambda args (car args)))))
      (if (not (eq? tag 'mus-error))
	  (snd-display #__line__ ";frame too many args: ~A" tag)))
    
    
    (let ((val (run-eval '(lambda (a) (declare (a sound-data)) (sound-data-ref a 0 0)) (make-sound-data 1 1))))
      (if (fneq val 0.0) (snd-display #__line__ ";run sound-data arg: ~A" val)))
    
    (let ((rdat (make-vct 16))
	  (idat (make-vct 16))
	  (v (make-vct 1)))
      (vct-set! rdat 0 1.0)
      (vct-map! v (lambda ()
		    (spectrum rdat idat #f 1)
		    0.0))
      (do ((i 0 (+ 1 i)))
	  ((= i 8)) 
	(if (fneq (vct-ref rdat i) 1.0)
	    (snd-display #__line__ ";run impulse->flat? ~A" rdat))))
    
    (let ((val (run-eval '(frame-ref (sample->frame (make-mixer 1 1.0) .5) 0))))
      (if (fneq val 0.5) (snd-display #__line__ ";run sample->frame no frame: ~A" val)))
    
    (run (lambda () (oscil unique-generator))) ; needed below
    
    (let ((tag (catch #t (lambda () 
			   (run-eval '(lambda (a) (declare (sound-data a)) (sound-data-ref a 0 0)) 
				     (make-sound-data 1 1))) 
		      (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run declare backwards sound-data: ~A" tag)))
    
    
    (let ((val (run-eval '(format #f "~A ~A" (+ 1 2) (* 3 4)))))
      (if (not (string=? val "3 12")) (snd-display #__line__ ";run format 3 12: ~A" val)))
    (let ((val (run-eval '(format #f "~A ~A" (make-vct 3 1.0) (make-vector 3 2.0)))))
      (if (not (string=? val "#<vct[len=3]: 1.000 1.000 1.000> #<vct[len=3]: 2.000 2.000 2.000>"))
	  (snd-display #__line__ ";run format vcts: ~A" val)))
    (let ((val (run-eval '(format #f "~A ~A" (string-append "a" "b") (number? "c")))))
      (if (not (string=? val "ab #f")) (snd-display #__line__ ";run format ab #f: ~A" val)))
    (let ((old-opt (optimization)))
      (set! (optimization) 6)
      (let ((val (run (lambda () (format #f "~A ~A" (make-vct 3 1.0) (make-vector 3 2.0))))))
	(if (not (string=? val "#<vct[len=3]: 1.000 1.000 1.000> #<vct[len=3]: 2.000 2.000 2.000>"))
	    (if (string=? val "#<vct[len=3]: 1.000 1.000 1.000> #(2.0 2.0 2.0)")
		(snd-display #__line__ ";run format vector instead of vct: ~A (opt: ~A, max: ~A)" val (optimization) max-optimization)
		(snd-display #__line__ ";run format vcts l: ~A" val))))
      (let ((val (run (lambda () (format #f "~A ~A" (string-append "a" "b") (number? "c"))))))
	(if (not (string=? val "ab #f")) (snd-display #__line__ ";run format ab #f l: ~A" val)))
      (let ((val (run (lambda () (format #f "~A ~A" (make-sound-data 1 1) (make-oscil))))))
	(if (and (not (string=? val "#<sound-data[chans=1, length=1]:\n    (0.000)> #<oscil freq: 0.000Hz, phase: 0.000>"))
		 (not (string=? val "#<sound-data[chans=1, length=1]:\n    (0.000)> oscil freq: 0.000Hz, phase: 0.000")))
	    (snd-display #__line__ ";run format sd osc: ~A" val)))
      (let ((val (run (lambda () (format #f "~A ~A" (+ 1 2) (* 3 4))))))
	(if (not (string=? val "3 12")) (snd-display #__line__ ";run format 3 12 l: ~A" val)))
      (set! (optimization) old-opt))
    
    (let ((hi (vector 1 2 3)))
      (let ((ho (run (lambda () (vector-set! hi 2 4) hi))))
	(if (not (vector? ho)) 
	    (snd-display #__line__ ";run rtns int vect: ~A" ho)
	    (if (not (= (vector-ref ho 2) 4)) 
		(snd-display #__line__ ";run sets int vect: ~A" (vector-ref ho 2))))))
    
    (let ((hi (run (lambda () (let ((v (make-vector 3 0))) (vector-set! v 1 2) v)))))
      (if (not (vector? hi)) 
	  (snd-display #__line__ ";run rtns make int vect: ~A" hi)
	  (if (not (= (vector-ref hi 1) 2))
	      (snd-display #__line__ ";run sets make int vect: ~A" (vector-ref hi 1)))))
    
    (let ((tag (catch #t (lambda () 
			   (run-eval '(lambda (x) 
					(declare (x boolean)) 
					(let ((val (if x 123 "hi"))) 
					  val)) 
				     #t))
		      (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run branches ~A" tag)))
    (let ((tag (catch #t (lambda () 
			   (run-eval '(lambda (x) 
					(declare (x float)) 
					(let ((val (if x 123 "hi"))) 
					  val)) 
				     #t)) 
		      (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run selector ~A" tag)))
    (let ((tag (catch #t (lambda () 
			   (run-eval '(lambda (x) 
					(declare (x int)) 
					(let ((val (case x ((0) 0) (hi 3)))) 
					  val)) 
				     0)) 
		      (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run case key ~A" tag)))
    
    (let ((val (run (lambda () (let ((val (if (> 3 2) 123 "hi"))) val)))))
      (if (not (= val 123)) (snd-display #__line__ ";run opt-if 123: ~A" val)))
    (let ((val (run-eval '(if (< 3 2) 123 "hi"))))
      (if (not (string=? val "hi")) (snd-display #__line__ ";run opt-if-not 123: ~A" val)))
    (let ((sd (make-sound-data 1 1))) 
      (let ((val (run (lambda () (format #f "~A" sd)))))
	(if (not (string=? val "#<sound-data[chans=1, length=1]:\n    (0.000)>"))
	    (snd-display #__line__ ";run format sound-data 0: ~A" val))))
    (let ((val (run-eval '(format #f "~A" (make-sound-data 1 1)))))
      (if (not (string=? val "#<sound-data[chans=1, length=1]:\n    (0.000)>"))
	  (snd-display #__line__ ";run format sound-data 1: ~A" val)))
    (let ((val (run-eval '(lambda (arg) 
			    (declare (arg sound-data)) 
			    (format #f "~A" arg)) 
			 (make-sound-data 1 1))))
      (if (not (string=? val "#<sound-data[chans=1, length=1]:\n    (0.000)>"))
	  (snd-display #__line__ ";run format sound-data 2: ~A" val)))
    
    (let ((val (run-eval '(format #f "~A" (make-oscil)))))
      (if (and (not (string=? val "#<oscil freq: 0.000Hz, phase: 0.000>"))
	       (not (string=? val "oscil freq: 0.000Hz, phase: 0.000")))
	  (snd-display #__line__ ";run format gen 0: ~A" val)))
    (let ((val (run (lambda () (format #f "~A" unique-generator)))))
      (if (and (not (string=? val "#<oscil freq: 0.000Hz, phase: 0.000>"))
	       (not (string=? val "oscil freq: 0.000Hz, phase: 0.000")))
	  (snd-display #__line__ ";run format gen phase 1: ~A" val)))
    (let ((val (run-eval '(format #f "~A" unique-generator))))
      (if (and (not (string=? val "#<oscil freq: 0.000Hz, phase: 0.000>"))
	       (not (string=? val "oscil freq: 0.000Hz, phase: 0.000")))
	  (snd-display #__line__ ";run format gen phase 2: ~A" val)))
    
    (let ((make-procs (list
		       make-all-pass make-asymmetric-fm make-moving-average
		       make-comb make-filtered-comb (lambda () (make-convolve :filter (vct 0.0 .1 .2))) 
		       make-delay (lambda () (make-env '(0 1 1 0)))
		       (lambda () (make-filter :xcoeffs (vct 0.0 .1 .2))) (lambda () (make-fir-filter :xcoeffs (vct 0.0 .1 .2))) 
		       make-formant (lambda () (make-frame 3 .1 .2 .3)) make-granulate
		       (lambda () (make-iir-filter :xcoeffs (vct 0.0 .1 .2))) make-locsig (lambda () (make-mixer 3 3)) 
		       make-notch make-one-pole make-one-zero make-oscil
		       make-pulse-train make-rand make-rand-interp make-sawtooth-wave
		       make-nrxysin make-nrxycos make-square-wave make-src make-ncos 
		       make-nsin make-table-lookup make-triangle-wave
		       make-two-pole make-two-zero make-wave-train make-phase-vocoder make-ssb-am make-polyshape make-polywave
		       (lambda () (make-filter :ycoeffs (vct 0.0 .1 .2)))
		       (lambda () (make-filter :xcoeffs (vct 1.0 2.0 3.0) :ycoeffs (vct 0.0 1.0 2.0))))))
      (for-each
       (lambda (n)
	 (let* ((gen (n))
		(val1 (format #f "~A" gen))
		(val2 (run (lambda () (format #f "~A" gen)))))
	   
	   (if (not (string=? val1 val2))
	       (snd-display #__line__ ";run format gen: format: ~A, run format: ~A (~A)" val1 val2 gen))))
       make-procs))
    
    (let ((val1 (run-eval '(format #f "~A" (make-all-pass))))
	  (val2 (run (lambda () (let ((gen (make-all-pass))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-all-pass))))
      
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    
    (let ((val1 (run-eval '(format #f "~A" (make-asymmetric-fm ))))
	  (val2 (run (lambda () (let ((gen (make-asymmetric-fm ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-asymmetric-fm ))))
      
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-moving-average))))
	  (val2 (run (lambda () (let ((gen (make-moving-average))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-moving-average))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-comb ))))
	  (val2 (run (lambda () (let ((gen (make-comb ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-comb ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-filtered-comb  :filter (make-one-zero .5 .5)))))
	  (val2 (run (lambda () (let ((gen (make-filtered-comb  :filter (make-one-zero .5 .5)))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-filtered-comb  :filter (make-one-zero .5 .5)))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-delay ))))
	  (val2 (run (lambda () (let ((gen (make-delay ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-delay ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-firmant ))))
	  (val2 (run (lambda () (let ((gen (make-firmant ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-firmant ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-formant ))))
	  (val2 (run (lambda () (let ((gen (make-formant ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-formant ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-granulate))))
	  (val2 (run (lambda () (let ((gen (make-granulate))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-granulate))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-locsig ))))
	  (val2 (run (lambda () (let ((gen (make-locsig ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-locsig ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-notch ))))
	  (val2 (run (lambda () (let ((gen (make-notch ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-notch ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-one-pole ))))
	  (val2 (run (lambda () (let ((gen (make-one-pole ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-one-pole ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-one-zero ))))
	  (val2 (run (lambda () (let ((gen (make-one-zero ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-one-zero ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-oscil ))))
	  (val2 (run (lambda () (let ((gen (make-oscil ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-oscil ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-pulse-train ))))
	  (val2 (run (lambda () (let ((gen (make-pulse-train ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-pulse-train ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-rand ))))
	  (val2 (run (lambda () (let ((gen (make-rand ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-rand ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-sawtooth-wave))))
	  (val2 (run (lambda () (let ((gen (make-sawtooth-wave))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-sawtooth-wave))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-nrxysin ))))
	  (val2 (run (lambda () (let ((gen (make-nrxysin ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-nrxysin ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-nrxycos ))))
	  (val2 (run (lambda () (let ((gen (make-nrxycos ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-nrxycos ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-square-wave ))))
	  (val2 (run (lambda () (let ((gen (make-square-wave ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-square-wave ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-src ))))
	  (val2 (run (lambda () (let ((gen (make-src ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-src ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-ncos ))))
	  (val2 (run (lambda () (let ((gen (make-ncos ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-ncos ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-nsin ))))
	  (val2 (run (lambda () (let ((gen (make-nsin ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-nsin ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-table-lookup ))))
	  (val2 (run (lambda () (let ((gen (make-table-lookup ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-table-lookup ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-triangle-wave))))
	  (val2 (run (lambda () (let ((gen (make-triangle-wave))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-triangle-wave))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-two-pole ))))
	  (val2 (run (lambda () (let ((gen (make-two-pole ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-two-pole ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-two-zero ))))
	  (val2 (run (lambda () (let ((gen (make-two-zero ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-two-zero ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-wave-train ))))
	  (val2 (run (lambda () (let ((gen (make-wave-train ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-wave-train ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-polyshape ))))
	  (val2 (run (lambda () (let ((gen (make-polyshape ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-polyshape ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-polywave ))))
	  (val2 (run (lambda () (let ((gen (make-polywave ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-polywave ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-phase-vocoder ))))
	  (val2 (run (lambda () (let ((gen (make-phase-vocoder ))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-phase-vocoder ))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((val1 (run-eval '(format #f "~A" (make-ssb-am))))
	  (val2 (run (lambda () (let ((gen (make-ssb-am))) (format #f "~A" gen)))))
	  (val3 (format #f "~A" (make-ssb-am))))
      (if (or (not (string=? val1 val2))
	      (not (string=? val2 val3)))
	  (snd-display #__line__ ";run-eval format: ~A ~A ~A" val1 val2 val3)))
    
    (let ((v (run
	      (lambda ()
		(let ((x 2.0)
		      (y 3.0))
		  (let ((p (make-polyshape 440 :partials (vct 1 x 2 y))))
		    (mus-data p)))))))
      (if (not (vequal v (vct -3 2 6))) (snd-display #__line__ ";run make-polyshape vct x y: ~A" v)))
    
    (let ((v (run
	      (lambda ()
		(let ((x 2.0)
		      (y 3.0))
		  (let ((p (make-polyshape 440 :partials (vct 1 (+ x y) 2 (- y x)))))
		    (mus-data p)))))))
      (if (not (vequal v (vct -1 5 2))) (snd-display #__line__ ";run make-polyshape vct x+y: ~A" v)))
    
    (let ((val (run-eval '(format #f "~A" unique-symbol))))
      (if (not (string=? val "hiho")) (snd-display #__line__ ";run format symbol: ~A" val)))
    (let ((val (run-eval '(symbol? unique-symbol))))
      (if (not val) (snd-display #__line__ ";run-eval symbol? global?")))
    (let ((val (run (lambda () (symbol? unique-symbol)))))
      (if (not val) (snd-display #__line__ ";run symbol? global?")))
    (let ((val (run (lambda () (eq? unique-symbol :hiho)))))
      (if val (snd-display #__line__ ";run :hiho is a symbol?")))
    (let ((val (run (lambda () (eq? unique-symbol 'hiho)))))
      (if (not val) (snd-display #__line__ ";run eq? symbol 'hiho?")))
    (let ((val (run-eval '(symbol? unique-keyword))))
      (if val (snd-display #__line__ ";run symbol? of keyword")))
    (let ((val (run-eval '(keyword? unique-keyword))))
      (if (not val) (snd-display #__line__ ";run keyword? of keyword?")))
    (let ((val (run (lambda () (eq? unique-keyword :hiho)))))
      (if (not val) (snd-display #__line__ ";run eq? of :hiho?")))
    (let ((val (run (lambda () (eq? unique-keyword 0)))))
      (if val (snd-display #__line__ ";run eq? key 0?")))
    (let ((val (run-eval '(cond ((= 1 2) 3) ((+ 2 3) 4)))))
      (if (not (= val 4)) (snd-display #__line__ ";run bad cond: ~A" val)))
    (let ((tag (catch #t (lambda () (run-eval '(let ((a 3)) (set! a (current-environment))))) (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run bad set!: ~A" tag)))
    (let ((tag (catch #t (lambda () (run-eval '(let ((a 2)) (define "hi" 3) a))) (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run bad define: ~A" tag)))
    
    (vector-set! unique-float-vector 1 "hi")
    (let ((tag (catch #t (lambda () (run (lambda () (vector-ref unique-float-vector 1)))) (lambda args (car args)))))
      (if (not (equal? tag "hi")) (snd-display #__line__ ";run bad float vector: ~A" tag)))
    (vector-set! unique-float-vector 1 1.0)
    
    (vector-set! unique-int-vector 2 "hi")
    (let ((tag (catch #t (lambda () (run (lambda () (vector-ref unique-int-vector 1)))) (lambda args (car args)))))
      (if (not (equal? tag 1)) (snd-display #__line__ ";run bad int vector: ~A" tag)))
    (vector-set! unique-int-vector 2 2)
    
    (do ((i 0 (+ 1 i))) ((= i 2)) (vector-set! unique-clm-vector i (make-oscil)))
    (vector-set! unique-clm-vector 2 "hi")
    (let ((tag (catch #t (lambda () (run (lambda () (vector-ref unique-clm-vector 1)))) (lambda args (car args)))))
      (if (not (oscil? tag)) (snd-display #__line__ ";run bad clm vector: ~A" tag)))
    (vector-set! unique-clm-vector 2 (make-oscil))
    
    (let ((tag (catch #t (lambda () (run-eval '(let ((a 1)) (set! c a)))) (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run bad set var: ~A" tag)))
    
    (do ((i 0 (+ 1 i))) ((= i 2)) (vector-set! unique-vct-vector i (make-vct 3)))
    (vector-set! unique-vct-vector 2 "hi")
    (let ((tag (catch #t (lambda () (run (lambda () (vector-ref unique-vct-vector 1)))) (lambda args (car args)))))
      (if (not (vct? tag)) (snd-display #__line__ ";run bad vct vector: ~A" tag)))
    (vector-set! unique-vct-vector 2 (make-vct 3))
    
    (let ((val (run-eval '(let* ((a 1) (b (if (odd? a) :hi :ho))) (keyword? b)))))
      (if (not val) (snd-display #__line__ ";run local return key")))
    (let ((val (run-eval '(let* ((a 1) (b (if (odd? a) :hi :ho))) b))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run local return key: ~A" val)))
    (let ((val (run-eval '(let* ((a 1) (b (if (even? a) 'hi 'ho))) (symbol? b)))))
      (if (not val) (snd-display #__line__ ";run local return symbol")))
    (let ((val (run-eval '(let* ((a 1) (b (if (even? a) 'hi 'ho))) b))))
      (if (not (equal? val 'ho)) (snd-display #__line__ ";run local return symbol: ~A" val)))
    
    (let ((val (run (lambda () (let* ((a 1) (b (if (odd? a) :hi :ho))) (equal? b :hi))))))
      (if (not (equal? val #t)) (snd-display #__line__ ";run b2 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1) (b :hi)) (equal? b :hi))))))
      (if (not (equal? val #t)) (snd-display #__line__ ";run b3 ~A:" val)))
    (let ((val (run-eval '(let* ((a 1) (b :hi)) b))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b4 ~A:" val)))
    (let ((val (run-eval '(let* ((a 1) (b 'ho)) b))))
      (if (not (equal? val 'ho)) (snd-display #__line__ ";run b5 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (if (odd? a) :hi :ho))))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b6 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (if (odd? a) 'hi 'ho))))))
      (if (not (equal? val 'hi)) (snd-display #__line__ ";run b7 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (case a ((0) :hi) ((1) :ho) (else :ha)))))))
      (if (not (equal? val :ho)) (snd-display #__line__ ";run b8 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (begin :hi))))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b9 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (cond ((= a 0) :hi) ((= a 1) :ho) (else :ha)))))))
      (if (not (equal? val :ho)) (snd-display #__line__ ";run b10 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (cond ((= a 0) :hi) ((= a 1) :ho)))))))
      (if (not (equal? val :ho)) (snd-display #__line__ ";run b11 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (or (= a 0) :hi))))))
      (if (not val) (snd-display #__line__ ";run b12 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (and (= a 1) 'hi))))))
      (if (not val) (snd-display #__line__ ";run b13 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (cond ((= a 0) 1) ((= a 1) 2) (else 3)))))))
      (if (not (equal? val 2)) (snd-display #__line__ ";run b14 ~A:" val)))
    (let ((val (run (lambda () (let* ((a 1)) (cond ((= a 0) "hi") ((= a 1) "ho") (else "ha")))))))
      (if (not (equal? val "ho")) (snd-display #__line__ ";run b15 ~A:" val)))
    (let ((val (run-eval '(if #t :hi))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b16 ~A:" val)))
    (let ((val (run-eval '(if #f :hi :ho))))
      (if (not (equal? val :ho)) (snd-display #__line__ ";run b17 ~A:" val)))
    (let ((val (run-eval '(let ((a (let ((b :hi)) b))) a))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b18 ~A:" val)))
    (let ((val (run-eval '(let ((a 1) (b :hi)) (if (odd? a) b :ho)))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b19 ~A:" val)))
    (let ((val (run-eval '(let ((a 1) (b :hi)) (if #t b :ho)))))
      (if (not (equal? val :hi)) (snd-display #__line__ ";run b20 ~A:" val)))
    (let ((val (run-eval '(let ((a #\a)) (if (char? a) a)))))
      (if (not (equal? val #\a)) (snd-display #__line__ ";run b21 ~A:" val)))
    (let ((val (run-eval '(let ((a #\a)) (if (number? a) a)))))
      (if (not (equal? val #f)) (snd-display #__line__ ";run b22 ~A:" val)))
    (let ((val (run-eval '(let ((a #\a)) (if (char? a) '(1 2))))))
      (if (not (equal? val '(1 2))) (snd-display #__line__ ";run b24 ~A:" val)))
    
    (let ((val (run (lambda () (let* ((a 1) (b :hi)) (if (odd? a) (set! b :ho)) b)))))
      (if (not (equal? val :ho)) (snd-display #__line__ ";run b25 ~A" val)))
    (let ((tag (catch #t (lambda () (run-eval '(let* ((a 1) (b (case (a) ((0) -1) ((1) a) else -2)))))) (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run bad case selector: ~A" tag)))
    (let ((tag (catch #t (lambda () (run-eval '(let* ((a 1) (b (case a ((0) -1) ((1) a) else -2))) b))) (lambda args (car args)))))
      (if (not (eq? tag 'cannot-parse)) (snd-display #__line__ ";run bad case else: ~A" tag)))
    (let ((val (run-eval '(let* ((a 1) (b (case 0 ((0) -1) ((1) a)))) b))))
      (if (not (= val -1)) (snd-display #__line__ ";run b26 ~A" val)))
    (let ((val (run-eval '(let* ((a 1) (b (case a ((0) -1) ((1) a)))) b))))
      (if (not (= val 1)) (snd-display #__line__ ";run b27 ~A" val)))
    (let ((val (run-eval '(let* ((a 1) (b (case 0 ((0) -1) ((1) a) (else -2)))) b))))
      (if (not (= val -1)) (snd-display #__line__ ";ru b28 ~A" val)))
    (let ((val (run-eval '(let* ((a 1) (b (case 3 ((0) -1) ((1) a) (else -2)))) b))))
      (if (not (= val -2)) (snd-display #__line__ ";run b29 ~A" val)))
    (let ((val (run-eval '(let* ((a 1) (b (case a ((0) -1) ((1) a) (else -2)))) b))))
      (if (not (= val 1)) (snd-display #__line__ ";run b30 ~A" val)))
    (let ((val (run-eval '(begin (case 0 ((0) -1) ((1) 0) (else -2)) 2))))
      (if (not (= val 2)) (snd-display #__line__ ";run b31 ~A" val)))
    
    (let ((val (run (lambda () (let ((a :ho)) (define (hi b) (declare (b keyword)) b) (hi a))))))
      (if (not (equal? val :ho)) (snd-display #__line__ ";run b32 ~A" val)))
    (let ((val (run (lambda () (let ((a 'ho)) (define (hi b) (declare (b symbol)) b) (hi a))))))
      (if (not (equal? val 'ho)) (snd-display #__line__ ";run b33 ~A" val)))
    (let ((val (run (lambda () (let ((a "ho")) (define (hi b) (declare (b string)) b) (hi a))))))
      (if (not (equal? val "ho")) (snd-display #__line__ ";run b34 ~A" val)))
    (let ((val (run (lambda () (let ((a unique-int-vector)) (define (hi b) (declare (b int-vector)) b) (vector-ref (hi a) 0))))))
      (if (not (= val 1)) (snd-display #__line__ ";run b35 ~A" val)))
    (set! unique-generator (make-delay 3))
    (let ((val (run-eval '(vct-ref (mus-data unique-generator) 0)))) ; if oscil here, segfault
      (if (fneq val 0.0) (snd-display #__line__ ";run b36 ~A" val)))
    
    (let ((val (run-eval '(make-oscil 440.0))))
      (if (not (oscil? val)) (snd-display #__line__ ";run -> gen: ~A" val)))
    (let ((val (run-eval '(let ((a 1)) (if (odd? a) (make-oscil))))))
      (if (not (oscil? val)) (snd-display #__line__ ";run if -> gen: ~A" val)))
    (let ((val (run-eval '(let ((a :hoi) (b :ha)) (do ((i 0 (+ 1 i))) ((= i 3) a) (set! b a))))))
      (if (not (equal? val :hoi)) (snd-display #__line__ ";run b37 ~A" val)))
    (let ((val (run-eval '(let ((a "hio") (b "ha")) (do ((i 0 (+ 1 i))) ((= i 3) a) (set! b a))))))
      (if (not (equal? val "hio")) (snd-display #__line__ ";run b38 ~A" val)))
    (let ((val (run-eval '(let ((a (make-oscil)) (b 0)) (do ((i 0 (+ 1 i))) ((= i 3) a) (set! b i))))))
      (if (not (oscil? val)) (snd-display #__line__ ";run b39 ~A" val)))
    (let ((osc (make-oscil)))
      (let ((val (run (lambda () (oscil osc) (mus-reset osc) (oscil osc)))))
	(if (fneq val 0.0) (snd-display #__line__ ";run reset oscil: ~A ~A" val osc))))
    (let ((gen (make-oscil 440.0)))
      (let ((val (run (lambda () (let ((g1 gen)) (oscil g1) (oscil g1))))))
	(if (and (fneq val 0.1250) 
		 (fneq val 0.0626))
	    (snd-display #__line__ ";let osc g1: ~A" val))))
    (let ((gen (make-oscil 440.0)))
      (let ((val (run (lambda () (let ((g1 gen)) (oscil g1 1.0) (oscil g1 0.5))))))
	(if (and (fneq val 0.9024) 
		 (fneq val 0.8736))
	    (snd-display #__line__ ";let osc g1 1: ~A" val))))
    (let ((gen (make-oscil 440.0)))
      (let ((val (run (lambda () (let ((g1 gen)) (oscil g1 0.0 1.0) (oscil g1 0.0 0.5))))))
	(if (and (fneq val 0.585) 
		 (fneq val 0.5334))
	    (snd-display #__line__ ";let osc g1 0 1: ~A" val))))
    
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (> hi 2) 2 3)) a))))
      (if (not (= val 2)) (snd-display #__line__ ";set let: ~A" val)))
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (> hi 123) 2 3)) a))))
      (if (not (= val 3)) (snd-display #__line__ ";set let 2: ~A" val)))
    (let ((val (run-eval '(let ((a 0)) (set! a (do ((i 0 (+ 1 i))) ((= i 3) (+ i 1)) (set! a (* i 3))))))))
      (if (not (= val 4)) (snd-display #__line__ ";set do ~A" val)))
    (let ((val (run-eval '(let ((a 0)) (set! a (cond ((= a 0) 1) ((= a 1) 2))) a))))
      (if (not (= val 1)) (snd-display #__line__ ";set cond ~A" val)))
    (let ((val (run-eval '(let ((a 1)) (set! a (cond ((= a 0) 1) ((= a 1) 2))) a))))
      (if (not (= val 2)) (snd-display #__line__ ";set cond 2 ~A" val)))
    (let ((val (run-eval '(let ((a 1)) (set! a (case a ((0) 1) ((1) 2))) a))))
      (if (not (= val 2)) (snd-display #__line__ ";set case ~A" val)))
    (let ((val (run-eval '(let ((a 1)) (set! a (begin (set! a 2) (+ a 1)))))))
      (if (not (= val 3)) (snd-display #__line__ ";set begin ~A" val)))
    (let ((val (run-eval '(let ((a 1)) (set! a (let ((b 2)) (set! b (* b 2)) b))))))
      (if (not (= val 4)) (snd-display #__line__ ";set let 3 ~A" val)))
    (let ((val (run-eval '(let* ((a 3) (b a)) (set! a (let ((c 2)) (set! c (* b c 2)) c))))))
      (if (not (= val 12)) (snd-display #__line__ ";set let 4 ~A" val)))
    
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (> hi 2) (if (> a 1) 2 3) 4)) a))))
      (if (not (= val 3)) (snd-display #__line__ ";set let 6: ~A" val)))
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (< hi 2) (if (> a 1) 2 3) 4)) a))))
      (if (not (= val 4)) (snd-display #__line__ ";set let 7: ~A" val)))
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (< hi 2) (if (< a 1) 2 3) 4)) a))))
      (if (not (= val 4)) (snd-display #__line__ ";set let 8: ~A" val)))
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (> hi 2) (if (< a 1) 2 3) 4)) a))))
      (if (not (= val 2)) (snd-display #__line__ ";set let 9: ~A" val)))
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (< hi 2) (if (< a 1) 2 3) (if (> a 1) 4 5))) a))))
      (if (not (= val 5)) (snd-display #__line__ ";set let 10: ~A" val)))
    (let ((val (run-eval '(let ((a 0) (hi 3)) (set! a (if (< hi 2) (if (< a 1) 2 3) (if (< a 1) 4 5))) a))))
      (if (not (= val 4)) (snd-display #__line__ ";set let 10: ~A" val)))
    (let ((val (run-eval '(or 1 2))))
      (if (not (= val 1)) (snd-display #__line__ ";or 1 2: ~A" val)))
    (let ((val (run-eval '(or #f 2))))
      (if (not val) (snd-display #__line__ ";or #f 2: ~A" val)))
    (let ((val (run-eval '(and #f 2))))
      (if (not (eq? val #f)) (snd-display #__line__ ";and #f 2: ~A" val)))
    (let ((a 0))
      (let ((val (run (lambda () (and (let ((b 32)) (if (< a 0) (set! a b) (set! a (+ 1 b))) #t) #f)))))
	(if val (snd-display #__line__ ";run side-effect and result: ~A" val))
	(if (not (= a 33)) (snd-display #__line__ ";run side-effect and a: ~A" a))))
    (let ((a 0))
      (let ((val (run (lambda () (or (let ((b 32)) (if (< a 0) (set! a b) (set! a (+ 1 b))) #f) #t)))))
	(if (not val) (snd-display #__line__ ";run side-effect or result: ~A" val))
	(if (not (= a 33)) (snd-display #__line__ ";run side-effect or a: ~A" a))))
    
    (let ((tag (catch #t (lambda () (run-eval '(let ((a 0)) (set! a (and 1 3)) a))) (lambda args (car args)))))
      (if (not (equal? tag 'cannot-parse)) (snd-display #__line__ ";set and not bool: ~A" tag)))
    (let ((val (run-eval '(if 1 2 3))))
      (if (not (= val 2)) (snd-display #__line__ ";if not bool: ~A" val)))
    
    (let ((val (run-eval '(let* ((sine (make-vct 32 1.0))
				 (sr (make-table-lookup :wave sine))) 
			    (let ((b (mus-data sr))) 
			      (vct-ref b 2))))))
      (if (fneq val 1.0) (snd-display #__line__ ";mus-data -> vct opt: ~A" val)))
    
    (let ((diff 
	   (run (lambda ()
		  (let ((x 1.0))
		    (let ((val1 (bes-j0 x))
			  (val2 (if (< (abs x) 8.0)			;direct rational function fit
				    (let* ((y (* x x))
					   (ans1 (+ 57568490574.0
						    (* y (+ -13362590354.0 
							    (* y  (+ 651619640.7
								     (* y (+ -11214424.18 
									     (* y (+ 77392.33017
										     (* y -184.9052456)))))))))))
					   (ans2 (+ 57568490411.0 
						    (* y (+ 1029532985.0 
							    (* y (+ 9494680.718
								    (* y (+ 59272.64853
									    (* y (+ 267.8532712 y)))))))))))
				      (/ ans1 ans2))
				    (let* ((ax (abs x))
					   (z (/ 8.0 ax))
					   (y (* z z))
					   (xx (- ax 0.785398164))
					   (ans1 (+ 1.0 
						    (* y (+ -0.1098628627e-2 
							    (* y (+ 0.2734510407e-4
								    (* y (+ -0.2073370639e-5
									    (* y 0.2093887211e-6)))))))))
					   (ans2 (+ -0.1562499995e-1
						    (* y (+ 0.1430488765e-3
							    (* y (+ -0.6911147651e-5
								    (* y (+ 0.7621095161e-6
									    (* y -0.934945152e-7))))))))))
				      (* (sqrt (/ 0.636619772 ax))
					 (- (* (cos xx) ans1)
					    (* z (sin xx) ans2)))))))
		      (abs (- val1 val2))))))))
      (if (> diff .001) (snd-print (format #f ";opt exploded j0 ~A ~A?" val1 val2))))
    (ftst '(bes-j0 1.0) 0.7651976865)
    (ftst '(bes-j1 1.0) 0.4400505857)
    (ftst '(bes-jn 2 1.0) 0.11490348)
    (ftst '(bes-y0 1.0) 0.0882569642)
    (ftst '(bes-y1 1.0) -0.78121282)
    (ftst '(bes-yn 2 1.0) -1.65068260)
    (ftst '(erf 0.5) 0.52049987)
    (ftst '(+ (erf .1) (erfc .1)) 1.0)
    (ftst '(lgamma 20.0) 39.33988)
    (ftst '(sinh 1.0) 1.1752011)
    (ftst '(cosh 1.0) 1.54308063)
    (ftst '(tanh 1.0) 0.76159415)
    (ftst '(asinh 1.1752011) 1.0)
    (ftst '(acosh 1.54308063) 1.0)
    (ftst '(atanh 0.76159415) 1.0)
    (ftst '(bes-i0 1.0) 1.2660659)
    
    (ftst '(let ((val1 1.0)) (bes-j0 val1)) 0.7651976865)
    (ftst '(let ((val1 1.0)) (bes-j1 val1)) 0.4400505857)
    (ftst '(let ((val1 1.0) (two 2)) (bes-jn two val1)) 0.11490348)
    (ftst '(let ((val1 1.0)) (bes-y0 val1)) 0.0882569642)
    (ftst '(let ((val1 1.0)) (bes-y1 val1)) -0.78121282)
    (ftst '(let ((val1 1.0) (two 2)) (bes-yn two val1)) -1.65068260)
    (ftst '(let ((val5 0.5)) (erf val5)) 0.52049987)
    (ftst '(let ((val1 0.1)) (+ (erf val1) (erfc val1))) 1.0)
    (ftst '(let ((val20 20.0)) (lgamma val20)) 39.33988)
    (ftst '(let ((val1 1.0)) (sinh val1)) 1.1752011)
    (ftst '(let ((val1 1.0)) (cosh val1)) 1.54308063)
    (ftst '(let ((val1 1.0)) (tanh val1)) 0.76159415)
    (ftst '(let ((val 1.1752011)) (asinh val)) 1.0)
    (ftst '(let ((val 1.54308063)) (acosh val)) 1.0)
    (ftst '(let ((val 0.76159415)) (atanh val)) 1.0)
    (ftst '(let ((val1 1.0)) (bes-i0 val1)) 1.2660659)
    
    (let ((val (run-eval '(let ((osc (make-oscil 440.0)))
			    (or (not osc)
				(not (oscil? osc)))))))
      (if val (snd-display #__line__ ";not osc: ~A" val)))
    
    (let ((val (run-eval '(let ((osc1 (make-oscil 440.0))
				(osc2 (make-oscil 880.0)))
			    (not (or osc1 osc2))))))
      (if val (snd-display #__line__ ";not osc1: ~A" val)))
    
    (let ((val (run-eval '(let ((osc1 (make-oscil 440.0))
				(osc2 #f))
			    (declare (osc2 clm))
			    (and osc1 (not osc2))))))
      (if (not val) (snd-display #__line__ ";not osc2: ~A" val)))
    
    (let ((val (run-eval '(let ((v1 (make-vct 3))
				(v2 (make-vct 3)))
			    (or (not v1)
				(and v1 v2))))))
      (if (not val) (snd-display #__line__ ";not v1: ~A" val)))
    
    (let ((v1 (make-vector 3 1))
	  (v2 (make-vector 3 2)))
      (let ((val (run (lambda ()
			(and v1 v2
			     (vector? v1))))))
	(if (not val) (snd-display #__line__ ";outer not vi1: ~A" val))))
    
    (let ((val (run-eval '(let ((v1 (make-vector 3))
				(v2 (make-vector 3)))
			    (and v1 v2
				 (vector? v1))))))
      (if (not val) (snd-display #__line__ ";not vi1: ~A" val)))
    
    (let ((val (run-eval '(let ((v1 (make-vector 3 1.0))
				(v2 (make-vector 3 2.0)))
			    (and v1 v2
				 (vector? v1))))))
      (if (not val) (snd-display #__line__ ";not vect1: ~A" val)))
    
    (let ((snd (open-sound "oboe.snd")))
      (let ((r1 (make-sampler 0))
	    (r2 (make-sampler 1000)))
	(let ((val (run (lambda ()
			  (and r1 r2
			       (or r1 r2)
			       (sampler? r1))))))
	  (if (not val) (snd-display #__line__ ";outer or rd: ~A" val))))
      
      (close-sound snd))
    
    (let ((val (run-eval '(let ((str1 "hiho")
				(str2 "ho"))
			    (and str1 str2)))))
      (if (not val) (snd-display #__line__ ";or str: ~A" val)))
    
    (let ((osc #f))
      (let ((val (run (lambda ()
			(declare (osc vct))
			(not osc)))))
	(if (not val) (snd-display #__line__ ";not v osc: ~A" val))))
    
    (let ((osc #f))
      (let ((val (run (lambda ()
			(declare (osc vct))
			osc))))
	(if val (snd-display #__line__ ";v osc: ~A" val))))
    
    (let ((ind (open-sound "oboe.snd")))
      (let ((s "hi")
	    (v (make-vct 3 3.0))
	    (vi (make-vector 3 32))
	    (vf (make-vector 3 3.14))
	    (sd (make-sound-data 2 4))
	    (g (make-oscil 440.0))
	    (rd (make-sampler 0))
	    (lst (list 1 2))
					;	    (pr (cons 1 2)) ; dotted lists aren't currently supported in any way in run
	    (ch #\c)
	    (ch2 #\null)
	    (i 0)
	    (i1 32)
	    (f 0.0)
	    (f1 3.14)
	    (ok 0))
	(run (lambda ()
	       (let ((v1 (make-vct 3 3.0))
		     (vf1 (make-vector 3 3.14))
		     (sd1 (make-sound-data 2 4))
		     (g1 (make-oscil 440.0))
		     (rd1 (make-sampler 0)))
		 (if s (set! ok (+ 1 ok)) (clm-print ";if direct s"))
		 (if v (set! ok (+ 1 ok)) (clm-print ";if direct v"))
		 (if v1 (set! ok (+ 1 ok)) (clm-print ";if direct v1"))
		 (if vi (set! ok (+ 1 ok)) (clm-print ";if direct vi"))
		 (if vf (set! ok (+ 1 ok)) (clm-print ";if direct vf"))
		 (if vf1 (set! ok (+ 1 ok)) (clm-print ";if direct vf1"))
		 (if sd (set! ok (+ 1 ok)) (clm-print ";if direct sd"))
		 (if sd1 (set! ok (+ 1 ok)) (clm-print ";if direct sd1"))
		 (if g (set! ok (+ 1 ok)) (clm-print ";if direct g"))
		 (if g1 (set! ok (+ 1 ok)) (clm-print ";if direct g1"))
		 (if rd (set! ok (+ 1 ok)) (clm-print ";if direct rd"))
		 (if rd1 (set! ok (+ 1 ok)) (clm-print ";if direct rd1"))
		 (if lst (set! ok (+ 1 ok)) (clm-print ";if direct lst"))
					;		 (if pr (set! ok (+ 1 ok)) (clm-print ";if direct pr"))
		 (if ch (set! ok (+ 1 ok)) (clm-print ";if direct ch"))
		 (if 0 (set! ok (+ 1 ok)) (clm-print ";if direct 0"))
		 (if i (set! ok (+ 1 ok)) (clm-print ";if direct i"))
		 (if i1 (set! ok (+ 1 ok)) (clm-print ";if direct i1"))
		 (if 0.0 (set! ok (+ 1 ok)) (clm-print ";if direct 0.0"))
		 (if f (set! ok (+ 1 ok)) (clm-print ";if direct f"))
		 (if f1 (set! ok (+ 1 ok)) (clm-print ";if direct f1"))
		 (if ch2 (set! ok (+ 1 ok)) (clm-print ";if direct ch2"))
		 (if #\null (set! ok (+ 1 ok)) (clm-print ";if direct null"))
		 
		 (if (or s v v1 vi vf g rd lst i f) (set! ok (+ 1 ok)) (clm-print ";if direct or"))
		 (if (and s v v1 vi vf g rd lst i f) (set! ok (+ 1 ok)) (clm-print ";if direct and"))
		 
		 (cond ((not s) (clm-print ";cond direct s"))
		       ((not v) (clm-print ";cond direct v"))
		       ((not v1) (clm-print ";cond direct v1"))
		       ((not vi) (clm-print ";cond direct vi"))
		       ((not vf) (clm-print ";cond direct vf"))
		       ((not vf1) (clm-print ";cond direct vf1"))
		       ((not sd) (clm-print ";cond direct sd"))
		       ((not sd1) (clm-print ";cond direct sd1"))
		       ((not g) (clm-print ";cond direct g"))
		       ((not g1) (clm-print ";cond direct g1"))
		       ((not rd) (clm-print ";cond direct rd"))
		       ((not rd1) (clm-print ";cond direct rd1"))
		       ((not lst) (clm-print ";cond direct lst"))
					;		       ((not pr) (clm-print ";cond direct pr"))
		       ((not ch) (clm-print ";cond direct ch"))
		       ((not i) (clm-print ";cond direct i"))
		       ((not i1) (clm-print ";cond direct i1"))
		       ((not f) (clm-print ";cond direct f"))
		       ((not f1) (clm-print ";cond direct f1"))
		       ((not ch2) (clm-print ";cond direct ch2")))
		 
		 )))
	
	(let ((gen (make-linear-src .5))
	      (rd (make-sampler 0)))
	  (map-channel (lambda (y) (linear-src gen (lambda () (rd))))))
	
	(close-sound ind)
	(if (not (= ok 24)) (clm-print ";ok: ~A" ok))))
    
    (run-eval '(lambda (g) (declare (g clm)) (if g (clm-print ";lambda clm #f arg"))) #f)
    (run-eval '(lambda (g g1) (declare (g clm) (g1 clm)) (if (or g g1) (clm-print ";lambda clm #f args 1"))) #f #f)
    (run-eval '(lambda (g g1) (declare (g clm) (g1 clm)) (if (not (or g g1)) (clm-print ";lambda clm #f args 2"))) #f (make-oscil 344.0))
    (run-eval '(lambda (g g1) (declare (g clm) (g1 clm)) (if (and g g1) (clm-print ";lambda clm #f args 3"))) #f (make-oscil 344.0))
    (run-eval '(lambda (g g1) (declare (g clm) (g1 clm)) (if (not g1) (clm-print ";lambda clm #f args 4"))) #f (make-oscil 344.0))
    
    (run-eval '(lambda (g) (declare (g vct)) (if g (clm-print ";lambda vct #f arg"))) #f)
    (run-eval '(lambda (g g1) (declare (g vct) (g1 vct)) (if (or g g1) (clm-print ";lambda vct #f args 1"))) #f #f)
    (run-eval '(lambda (g g1) (declare (g vct) (g1 vct)) (if (not (or g g1)) (clm-print ";lambda vct #f args 2"))) #f (make-vct 3))
    (run-eval '(lambda (g g1) (declare (g vct) (g1 vct)) (if (and g g1) (clm-print ";lambda vct #f args 3"))) #f (make-vct 3))
    (run-eval '(lambda (g g1) (declare (g vct) (g1 vct)) (if (not g1) (clm-print ";lambda vct #f args 4"))) #f (make-vct 3))
    
    (run-eval '(lambda (g) (declare (g sound-data)) (if g (clm-print ";lambda sound-data #f arg"))) #f)
    (run-eval '(lambda (g g1) (declare (g sound-data) (g1 sound-data)) (if (or g g1) (clm-print ";lambda sound-data #f args 1"))) #f #f)
    (run-eval '(lambda (g g1) 
		 (declare (g sound-data) (g1 sound-data)) 
		 (if (not (or g g1)) (clm-print ";lambda sound-data #f args 2"))) 
	      #f (make-sound-data 3 3))
    (run-eval '(lambda (g g1) 
		 (declare (g sound-data) (g1 sound-data)) 
		 (if (and g g1) (clm-print ";lambda sound-data #f args 3"))) 
	      #f (make-sound-data 3 3))
    (run-eval '(lambda (g g1) 
		 (declare (g sound-data) (g1 sound-data)) 
		 (if (not g1) (clm-print ";lambda sound-data #f args 4"))) 
	      #f (make-sound-data 3 3))
    
    (let ((sd (make-sound-data 2 10)))
      (vct->sound-data (make-vct 10 .25) sd 0)  
      (vct->sound-data (make-vct 10 .5) sd 1)
      (run 
       (lambda ()
	 (sound-data-scale! sd 2.0)))
      (if (not (vequal (sound-data->vct sd 0) (make-vct 10 .5)))
	  (snd-display #__line__ ";opt sound-data-scale! chan 0: ~A" (sound-data->vct sd 0)))
      (if (not (vequal (sound-data->vct sd 1) (make-vct 10 1.0)))
	  (snd-display #__line__ ";opt sound-data-scale! chan 1: ~A" (sound-data->vct sd 1))))
    
    (let ((sd (make-sound-data 2 10)))
      (run
       (lambda ()
	 (sound-data-fill! sd 2.0)))
      (if (not (vequal (sound-data->vct sd 0) (make-vct 10 2.0)))
	  (snd-display #__line__ ";opt sound-data-fill! chan 0: ~A" (sound-data->vct sd 0)))
      (if (not (vequal (sound-data->vct sd 1) (make-vct 10 2.0)))
	  (snd-display #__line__ ";opt sound-data-fill! chan 1: ~A" (sound-data->vct sd 1))))
    
    (run (lambda ()
	   (do ((i 0 (+ 1 i)))
	       ((= i 8))
	     (test-run-protection-release))))
    
    (let ((o (make-osc 440)))
      
      (oscil o))
    
    (let ((o (make-fc .8 128)))
      
      (filtered-comb o (random 1.0)))
    
    (let ((sd (make-sound-data 4 10)))
      (run (lambda ()
	     (do ((chn 0 (+ 1 chn)))
		 ((= chn 4))
	       (do ((i 0 (+ 1 i)))
		   ((= i 10))
		 (sound-data-set! sd chn i (+ i (* chn 10)))))))
      (let ((sd1 (run (lambda () (sound-data-copy sd)))))
	(if (not (equal? sd sd1))
	    (snd-display #__line__ ";sound-data-copy not equal? ~A ~A" sd sd1))
	(run (lambda () (sound-data-scale! sd1 2.0)))
	(let ((sd2 (make-sound-data 4 10)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd2 chn i (* 2 (+ i (* chn 10))))))
	  (if (not (equal? sd2 sd1)) (snd-display #__line__ ";sound-data-scale! not equal? ~%    ~A~%    ~A" sd1 sd2))
	  (if (equal? sd2 sd) (snd-display #__line__ ";sound-data-scale! crosstalk??")))
	(run (lambda () (sound-data-multiply! sd sd)))
	(let ((sd2 (make-sound-data 4 10)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd2 chn i (* (+ i (* chn 10)) (+ i (* chn 10))))))
	  (if (not (equal? sd2 sd)) (snd-display #__line__ ";sound-data-multiply! not equal? ~%    ~A~%     ~A" sd sd2)))
	(run (lambda ()
	       (do ((chn 0 (+ 1 chn)))
		   ((= chn 4))
		 (do ((i 0 (+ 1 i)))
		     ((= i 10))
		   (sound-data-set! sd chn i (+ i (* chn 10)))))
	       (sound-data-offset! sd 1.0)))
	(let ((sd2 (make-sound-data 4 10)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd2 chn i (+ 1 i (* chn 10)))))
	  (if (not (equal? sd2 sd)) (snd-display #__line__ ";sound-data-offset! not equal? ~%    ~A~%     ~A" sd sd2)))
	(let ((sd3 (run (lambda () (sound-data-reverse! (sound-data-copy sd))))))
	  (let ((sd2 (make-sound-data 4 10)))
	    (do ((chn 0 (+ 1 chn)))
		((= chn 4))
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(sound-data-set! sd2 chn i (+ 1 (- 9 i) (* chn 10)))))
	    (if (not (equal? sd2 sd3)) (snd-display #__line__ ";sound-data-reverse! not equal? ~%    ~A~%     ~A" sd3 sd2)))
	  (run (lambda () (sound-data-add! sd sd3)))
	  (do ((chn 0 (+ 1 chn)))
	      ((= chn 4))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (sound-data-set! sd1 chn i (+ 1 10 (* chn 20)))))
	  (if (not (equal? sd1 sd)) (snd-display #__line__ ";sound-data-add! not equal? ~%    ~A~%     ~A" sd sd1)))
	
	(run (lambda ()
	       (do ((chn 0 (+ 1 chn)))
		   ((= chn 4))
		 (do ((i 0 (+ 1 i)))
		     ((= i 10))
		   (sound-data-set! sd chn i (+ i (* chn 10)))
		   (sound-data-set! sd1 chn i 1)))))
	(let ((sd2 (sound-data-copy sd)))
	  (run (lambda ()
		 (sound-data+ sd 1)
		 (sound-data-add! sd2 sd1)))
	  (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data+ sd 1: ~%    ~A~%    ~A" sd sd2))
	  (run (lambda ()
		 (sound-data+ 1 sd)
		 (sound-data-add! sd2 sd1)))
	  (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data+ 1 sd: ~%    ~A~%    ~A" sd sd2))
	  (run (lambda ()
		 (sound-data+ sd sd1)
		 (sound-data-add! sd2 sd1)))
	  (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data+ sd sd: ~%    ~A~%    ~A" sd sd2)))
	
	(run (lambda ()
	       (do ((chn 0 (+ 1 chn)))
		   ((= chn 4))
		 (do ((i 0 (+ 1 i)))
		     ((= i 10))
		   (sound-data-set! sd chn i (+ i (* chn 10)))
		   (sound-data-set! sd1 chn i 2)))))
	(let ((sd2 (sound-data-copy sd)))
	  (run (lambda ()
		 (sound-data* sd 2)
		 (sound-data-multiply! sd2 sd1)))
	  (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data* sd 1: ~%    ~A~%    ~A" sd sd2))
	  (run (lambda ()
		 (sound-data* 2 sd)
		 (sound-data-multiply! sd2 sd1)))
	  (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data* 1 sd: ~%    ~A~%    ~A" sd sd2))
	  (run (lambda ()
		 (sound-data* sd sd1)
		 (sound-data-add! sd2 sd2)))
	  (if (not (equal? sd sd2)) (snd-display #__line__ ";sound-data* sd sd: ~%    ~A~%    ~A" sd sd2)))))
    
    (let ((index (new-sound  "test.snd" mus-next mus-bfloat 22050 4 "*-sound tests" 10)))
      (offset-sound 1.0)
      (do ((chn 0 (+ 1 chn)))
	  ((= chn 4))
	(if (not (vequal (channel->vct 0 10 index chn) (make-vct 10 1.0)))
	    (snd-display #__line__ ";offset-sound chan ~A: ~A" chn (channel->vct 0 10 index chn))))
      (scale-sound 0.5)
      (do ((chn 0 (+ 1 chn)))
	  ((= chn 4))
	(if (not (vequal (channel->vct 0 10 index chn) (make-vct 10 0.5)))
	    (snd-display #__line__ ";scale-sound chan ~A: ~A" chn (channel->vct 0 10 index chn))))
      (offset-sound 0.5 2 4)
      (do ((chn 0 (+ 1 chn)))
	  ((= chn 4))
	(if (not (vequal (channel->vct 0 10 index chn) (vct 0.5 0.5 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5)))
	    (snd-display #__line__ ";offset-sound chan [2:4] ~A: ~A" chn (channel->vct 0 10 index chn))))
      (scale-sound 0.5 1 7)
      (do ((chn 0 (+ 1 chn)))
	  ((= chn 4))
	(if (not (vequal (channel->vct 0 10 index chn) (vct 0.5 0.25 0.5 0.5 0.5 0.5 0.25 0.25 0.5 0.5)))
	    (snd-display #__line__ ";scale-sound chan [1:7] ~A: ~A" chn (channel->vct 0 10 index chn))))
      (scale-channel 2.0 0 10 index 2)
      (scale-channel 4.0 0 10 index 3)
      (normalize-sound 1.0) ; should be across full sound, so only chan 4 hits 1
      (if (not (vequal (channel->vct 0 10 index 3)
		       (vct-scale! (vct 0.5 0.25 0.5 0.5 0.5 0.5 0.25 0.25 0.5 0.5) 2.0)))
	  (snd-display #__line__ ";normalize-sound 3: ~A" (channel->vct 0 10 index 3)))
      (if (not (vequal (channel->vct 0 10 index 2)
		       (vct 0.5 0.25 0.5 0.5 0.5 0.5 0.25 0.25 0.5 0.5)))
	  (snd-display #__line__ ";normalize-sound 2: ~A" (channel->vct 0 10 index 2)))
      (if (not (vequal (channel->vct 0 10 index 1)
		       (vct-scale! (vct 0.5 0.25 0.5 0.5 0.5 0.5 0.25 0.25 0.5 0.5) 0.5)))
	  (snd-display #__line__ ";normalize-sound 1: ~A" (channel->vct 0 10 index 1)))
      (normalize-sound 2.0 2 4 index)
      (if (not (vequal (channel->vct 0 10 index 3)
		       (vct-scale! (vct 0.5 0.25 1.0 1.0 1.0 1.0 0.25 0.25 0.5 0.5) 2.0)))
	  (snd-display #__line__ ";normalize-sound 3 [2:4]: ~A" (channel->vct 0 10 index 3)))
      (if (not (vequal (channel->vct 0 10 index 2)
		       (vct 0.5 0.25 1.0 1.0 1.0 1.0 0.25 0.25 0.5 0.5)))
	  (snd-display #__line__ ";normalize-sound 2 [2:4]: ~A" (channel->vct 0 10 index 2)))
      (revert-sound index)
      (offset-sound 1.0)
      (pad-sound 2 4)
      (do ((chn 0 (+ 1 chn)))
	  ((= chn 4))
	(if (not (vequal (channel->vct 0 14 index chn) (vct 1 1 0 0 0 0 1 1 1 1 1 1 1 1)))
	    (snd-display #__line__ ";pad-sound chan ~A: ~A" chn (channel->vct 0 14 index chn))))
      (revert-sound)
      (do ((i 0 (+ 1 i)))
	  ((= i 10))
	(set! (sample i index 2) (+ -1.0 (* i .2))))
      (compand-sound)
      (if (not (vequal (channel->vct 0 10 index 2)
		       (vct -1.000 -0.924 -0.800 -0.624 -0.370 0.000 0.370 0.624 0.800 0.924)))
	  (snd-display #__line__ ";compand-sound 2: ~A" (channel->vct 0 10 index 2)))
      (revert-sound index)
      (offset-sound 0.5)
      (dither-sound 0.1)
      (contrast-sound 2.0)
      (close-sound index))
    
    (let ((ind (open-sound "2.snd")))
      (let ((val (simultaneous-zero-crossing)))
	(if (not (equal? val (list #t 6))) (snd-display #__line__ ";simultaneous-zero-crossing 0: ~A" val))
	(set! val (simultaneous-zero-crossing 9))
	(if (not (equal? val (list #t 17))) (snd-display #__line__ ";simultaneous-zero-crossing 2: ~A" val)))
      (close-sound ind))
    
    (let ((v (make-vct 10 .1))
	  (sd (make-sound-data 2 10))
	  (v0 (make-vct 10 0.0))
	  (v1 (make-vct 10 0.0)))
      (run
       (lambda ()
	 (vct->sound-data v sd 0)
	 (vct-scale! v 2.0)
	 (vct->sound-data v sd 1)
	 (sound-data->vct sd 0 v0)
	 (sound-data->vct sd 1 v1)))
      (if (not (equal? v0 (make-vct 10 .1))) (snd-display #__line__ ";vct<->sound-data 0: ~A" v0))
      (if (not (equal? v1 (make-vct 10 .2))) (snd-display #__line__ ";vct<->sound-data 1: ~A" v1)))
    
    (let ((val (list 1 2 3))) 
      (if (not (= (run (lambda () (list-ref val 1))) 2))
	  (snd-display #__line__ ";list-ref 2: ~A" (run (lambda () (list-ref val 1))))))
    
    (let ((val (list 1.0 2.0 3.0))) 
      (if (fneq (run (lambda () (list-ref val 1))) 2.0)
	  (snd-display #__line__ ";list-ref 2.0: ~A" (run (lambda () (list-ref val 1))))))
    
    (let ((val (list 1 2 3))) 
      (if (not (run (lambda () (list? val))))
	  (snd-display #__line__ ";list? -> ~A" (run (lambda () (list? val))))))
    
    (let ((val (list 1 2 3 4))) 
      (if (not (= (run (lambda () (car val))) 1))
	  (snd-display #__line__ ";car 1: ~A" (run (lambda () (car val))))))
    
    (let ((val (list 1 2 3 4))) 
      (if (not (= (run (lambda () (cadr val))) 2))
	  (snd-display #__line__ ";cadr 2: ~A" (run (lambda () (cadr val))))))
    
    (let ((val (list 1 2 3 4))) 
      (if (not (= (run (lambda () (caddr val))) 3))
	  (snd-display #__line__ ";caddr 3: ~A" (run (lambda () (caddr val))))))
    
    (let ((val (list 1 2 3 4))) 
      (if (not (= (run (lambda () (cadddr val))) 4))
	  (snd-display #__line__ ";cadddr 4: ~A" (run (lambda () (cadddr val))))))
    
    (let ((val (list 1 2 3 4))) 
      (if (not (= (run (lambda () (+ (car val) (cadddr val)))) 5))
	  (snd-display #__line__ ";car + cadddr 5: ~A" (run (lambda () (+ (car val) (cadddr val)))))))
    
    (let ((val (list 1 2 3))) 
      (run (lambda () (list-set! val 1 123)))
      (if (not (= (list-ref val 1) 123))
	  (snd-display #__line__ ";list-set 123: ~A" val)))
    
    (let ((val (list 1 2 3))) 
      (run (lambda () (set-car! val 123)))
      (if (not (= (car val) 123))
	  (snd-display #__line__ ";set-car 123: ~A" val)))
    
    (let ((val (list 1.0 2.0 3.0 4.0))) 
      (if (fneq (run (lambda () (car val))) 1.0)
	  (snd-display #__line__ ";car 1.0: ~A" (run (lambda () (car val))))))
    
    (let ((val (list 1.0 2.0 3.0))) 
      (run (lambda () (list-set! val 1 123.0)))
      (if (fneq (list-ref val 1) 123.0)
	  (snd-display #__line__ ";list-set 123.0: ~A" val)))
    
    (let ((val (list 1.0 2.0 3.0))) 
      (run (lambda () (set-car! val 123.0)))
      (if (fneq (car val) 123.0)
	  (snd-display #__line__ ";set-car 123.0: ~A" val)))
    
    (let* ((val (list 1.0 2.0 3.0))
	   (locs (list 1 2 3))
	   (lv (run (lambda () (list-ref val (list-ref locs 1))))))
      (if (fneq lv 3.0)
	  (snd-display #__line__ ";list-ref(list-ref) 3.0: ~A" lv)))
    
    (let* ((val (list 1.0 2.0 3.0))
	   (locs (list 1 2 3))
	   (lv (run (lambda () (list-ref val (list-ref locs (car locs)))))))
      (if (fneq lv 3.0)
	  (snd-display #__line__ ";list-ref(list-ref(car)) 3.0: ~A" lv)))
    
    (let ((val (list "hi" "ho" "ha")))
      (if (not (string=? (run (lambda () (list-ref val 1))) "ho"))
	  (snd-display #__line__ ";list-ref strings: ~A" (run (lambda () (list-ref val 1))))))
    
    (let ((val (list "hi" "ho" "ha")))
      (run (lambda () (list-set! val 1 "hiho")))
      (if (not (string=? (list-ref val 1) "hiho"))
	  (snd-display #__line__ ";list-set string: ~A" val)))
    
    (let ((val (list (make-oscil 100) (make-oscil 200) (make-oscil 300))))
      (let ((clm (run (lambda () (list-ref val 1)))))
	(if (or (not (oscil? clm))
		(fneq (mus-frequency clm) 200))
	    (snd-display #__line__ ";list-ref clm: ~A" clm))))
    
    (let ((val (list (make-vct 10) (make-vct 20) (make-vct 30))))
      (let ((v (run (lambda () (list-ref val 2)))))
	(if (or (not (vct? v))
		(not (= (vct-length v) 30)))
	    (snd-display #__line__ ";list-ref vct: ~A" v))))
    
    (let ((val (list 1 2 3))) 
      (if (not (= (run (lambda () (length val))) 3))
	  (snd-display #__line__ ";length 3: ~A" (run (lambda () (length val))))))
    
    (let ((val '()))
      (if (not (= (run (lambda () (length val))) 0))
	  (snd-display #__line__ ";length 0: ~A" (run (lambda () (length val))))))
    
    (let ((gen (make-polyoid 100.0 (vct 1 1 0.0)))) 
      (let ((val (run (lambda () (mus-ycoeffs gen)))))
	(if (not (vct? val))
	    (snd-display #__line__ ";run mus-ycoeffs: ~A" val))))
    
    (let ((val (list 1 2 3))) 
      (if (run (lambda () (null? val)))
	  (snd-display #__line__ ";null? : ~A" (run (lambda () (null? val))))))
    
    (let ((val '()))
      (if (run (lambda () (not (null? val))))
	  (snd-display #__line__ ";not null? : ~A" (run (lambda () (not (null? val)))))))
    
    (let ((val (list #f #t #t)))
      (if (run (lambda () (not (list-ref val 1))))
	  (snd-display #__line__ ";list-ref bools (not #t): ~A" (run (lambda () (not (list-ref val 1)))))))
    
    (let ((val (list #f #t #t)))
      (run (lambda () (list-set! val 1 #f)))
      (if (list-ref val 1)
	  (snd-display #__line__ ";list-set bools (not #t): ~A" val)))
    
    (let ((val (list #\f #\t #\c)))
      (if (not (char=? (run (lambda () (list-ref val 1))) #\t))
	  (snd-display #__line__ ";list-ref chars #\\t): ~A" (run (lambda () (list-ref val 1))))))
    
    (let ((val (list #\f #\t #\c)))
      (run (lambda () (list-set! val 2 #\d)))
      (if (not (char=? (list-ref val 2) #\d))
	  (snd-display #__line__ ";list-set char: ~A" val)))
    
    (let ((val (list (vector .1 .2 .3) (vector 1.0 2.0 3.0))))
      (let ((x (run (lambda () (vector-ref (list-ref val 1) 1)))))
	(if (fneq x 2.0) (snd-display #__line__ ";list-ref -> float vector: ~A" x))))
    
    (let ((val (list (vector 1 2 3) (vector 3 4 5))))
      (let ((x (run (lambda () (vector-ref (list-ref val 1) 1)))))
	(if (not (= x 4)) (snd-display #__line__ ";list-ref -> int vector: ~A" x))))
    
    (let ((val (list (vector (make-oscil 100) (make-oscil 200)) (vector (make-oscil 300) (make-oscil 400)))))
      (let ((x (run (lambda () (vector-ref (list-ref val 1) 1)))))
	(if (or (not (oscil? x))
		(fneq (mus-frequency x) 400.0))
	    (snd-display #__line__ ";list-ref clm-vector: ~A" x))))
    
    (let ((val (list (vector (make-vct 1) (make-vct 2)) (vector (make-vct 3) (make-vct 4)))))
      (let ((x (run (lambda () (vector-ref (list-ref val 0) 1)))))
	(if (or (not (vct? x))
		(not (= (vct-length x) 2)))
	    (snd-display #__line__ ";list-ref vct-vector: ~A" x))))
    
    (let ((val (list (make-sound-data 1 1) (make-sound-data 2 2))))
      (let ((x (run (lambda () (list-ref val 1)))))
	(if (or (not (sound-data? x))
		(not (= (sound-data-chans x) 2)))
	    (snd-display #__line__ ";list-ref sound-data: ~A" x))))
    
    (let ((val (list 'a 'b 'c)))
      (let ((sym (run (lambda () (list-ref val 0)))))
	(if (or (not (symbol? sym))
		(not (eq? sym 'a)))
	    (snd-display #__line__ ";list-ref sym: ~A" x))))
    
    (let ((val (list 'a 'b 'c)))
      (run (lambda () (list-set! val 1 'd)))
      (if (not (eq? (list-ref val 1) 'd))
	  (snd-display #__line__ ";list-set sym: ~A" val)))
    
    (let ((val (list :a :b :c)))
      (let ((sym (run (lambda () (list-ref val 0)))))
	(if (or (not (keyword? sym))
		(not (eq? sym :a)))
	    (snd-display #__line__ ";list-ref key: ~A" x))))
    
    (let ((val (list :a :b :c)))
      (run (lambda () (list-set! val 1 :d)))
      (if (not (eq? (list-ref val 1) :d))
	  (snd-display #__line__ ";list-set key: ~A" val)))
    
    (let ((val (list (make-sampler 0 "oboe.snd"))))
      (let ((x (run (lambda () (read-sample (list-ref val 0))))))
	(if (fneq x 0.0)
	    (snd-display #__line__ ";list-ref sampler: ~A" x))
	(free-sampler (list-ref val 0))))
    
    
    
    (let ((val (run (lambda () (+ '3 '4)))))
      (if (not (= val 7)) (snd-display #__line__ ";quote '3+'4: ~A" val)))
    
    (let ((val (run (lambda () (+ '3.5 '4.5)))))
      (if (fneq val 8.0) (snd-display #__line__ ";quote '3.5+'4.5: ~A" val)))
    
    (let ((val (run (lambda () (list-ref '(1 2 3) 1)))))
      (if (not (= val 2)) (snd-display #__line__ ";quote: '(1 2 3): ~A" val)))
    
    (let ((val (run (lambda () (list? '(0 1 2))))))
      (if (not val) (snd-display #__line__ ";(list? '()) #f?")))
    
    
    
    (let ((ho (make-hi308 1.0 2.0))) 
      (if (not (run (lambda () (hi308? ho))))
	  (snd-display #__line__ ";hi308? ho: ~A" (run (lambda () (hi308? ho))))))
    
    (let ((ho (make-hi308 1.0 2.0))) 
      (if (fneq (run (lambda () (hi308-freq ho))) 1.0)
	  (snd-display #__line__ ";hi308-freq 1.0: ~A" (run (lambda () (hi308-freq ho))) 1.0)))
    
    (let ((ho (make-hi308 1.0 2.0))) 
      (run (lambda () (set! (hi308-phase ho) 123.0)))
      (if (fneq (hi308-phase ho) 123.0)
	  (snd-display #__line__ ";set hi308-phase 123.0: ~A" ho)))
    
    (let ((ho (make-hi308 1.0 2.0))) 
      (if (fneq (run (lambda () (set! (hi308-phase ho) 123.0) (hi308-phase ho))) 123.0)
	  (snd-display #__line__ ";set hi308-phase and rtn 123.0: ~A ~A" ho (run (lambda () (set! (hi308-phase ho) 123.0) (hi308-phase ho))) 123.0)))
    
    (let ((ho (make-hi308 :freq 1.0 :phase 2.0)))
      (if (fneq (run (lambda () (call-hi308 ho))) 1.0)
	  (snd-display #__line__ ";funcall gen 1.0: ~A" (run (lambda () (call-hi308 ho))))))
    
    (let ((ho (make-hi308 :freq 1.0 :phase 2.0)))
      (run (lambda () (set-hi308 ho)))
      (if (fneq (hi308-freq ho) 3.5) (snd-display #__line__ ";set in outer func: ~A" ho)))
    
    (let ((ho (make-hi308 1.0 2.0)))
      (let ((ha (run (lambda () ho))))
	(if (not (hi308? ha))
	    (snd-display #__line__ ";run hi308: ~A" ha))))
    
    (let* ((ho (make-hi308 3.0 2.0))
	   (val (run-eval '(lambda (y) (declare (y hi308)) y) ho)))
      (if (not (hi308? val))
	  (snd-display #__line__ ";run clm-struct prog arg: ~A" val)))
    
    (let ((val (run-eval '(lambda (y) (declare (y hi308)) y) (make-hi308 3.0 2.0)))) 
      (if (or (not (hi308? val))
	      (fneq (hi308-freq val) 3.0))
	  (snd-display #__line__ ";run clm-struct prog arg with make: ~A" val)))
    
    (let ((val (run-eval '(lambda (y) (declare (y list)) y) (list 1.0 2.0 3.0))))
      (if (or (not (list? val))
	      (fneq (list-ref val 1) 2.0))
	  (snd-display #__line__ ";run list as arg: ~A" val)))
    
    
    
    (let ((val (run (lambda () (make-oscil 200)))))
      (if (or (not (oscil? val))
	      (fneq (mus-frequency val) 200))
	  (snd-display #__line__ ";run make-oscil: ~A" val)))
    
    (let ((val (run (lambda () (make-oscil :frequency 200)))))
      (if (or (not (oscil? val))
	      (fneq (mus-frequency val) 200))
	  (snd-display #__line__ ";run make-oscil: ~A" val)))
    
    (let ((val (run (lambda () (let ((gen (make-oscil 200))) (mus-frequency gen))))))
      (if (fneq val 200.0) (snd-display #__line__ ";run make-oscil freq: ~A" val)))
    
    (let ((ex (list 0.0 0.0 1.0 1.0)))
      (let ((val (run (lambda () (make-env ex :length 101)))))
	(if (not (env? val)) (snd-display #__line__ ";make-env run: ~A" val))))
    
    
    (let ((val (vector (make-hi308 1.0 2.0) (make-hi308 3.0 4.0))))
      (let ((x (run (lambda () (vector-ref val 1)))))
	(if (or (not (hi308? x))
		(fneq (hi308-phase x) 4.0))
	    (snd-display #__line__ ";run pass list vector as arg: ~A" x))))
    
    ;; 309
    (let ((val (list 1 2 3)) (val1 (list 1 2 3))) 
      (let ((x (run (lambda () (eq? val val1)))))
	(if x (snd-display #__line__ ";run list eq 1: ~A" x))))
    
    (let ((val (list 1 2 3)) (val1 (list 1 2 3))) 
      (let ((x (run (lambda () (eq? val val)))))
	(if (not x) (snd-display #__line__ ";run list eq 2: ~A" x))))
    
    (let ((val (list 1 2 3)) (val1 (list 1 2 3))) 
      (let ((x (run (lambda () (equal? val val)))))
	(if (not x) (snd-display #__line__ ";run list equal 3: ~A" x))))
    
    (let ((val (list 1 2 3)) (val1 (list 1 2 3))) 
      (let ((x (run (lambda () (equal? val1 val))))) ; this one doesn't work in run
	(if (not x) (snd-display #__line__ ";run list equal 4: ~A" x))))
    
    (let ((val (list 1 2 3)) (val1 (list 1.0 2.0 3.0))) 
      (let ((x (run (lambda () (equal? val1 val)))))
	(if x (snd-display #__line__ ";run list equal 5: ~A" x))))
    
    (let ((val1 (list "hi" "hi"))
	  (val2 (list "hi" "hi")))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if (not x) (snd-display #__line__ ";run list equal? strs: ~A" x))))
    
    (let ((val1 (list "hi" "hi"))
	  (val2 (list "hi" "hi" "hi")))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? strs 1: ~A" x))))
    
    (let ((val1 (list "hi" "hi"))
	  (val2 (list "hi" "ho")))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? strs 2: ~A" x))))
    
    
    (let ((val1 (list 'hi 'hi))
	  (val2 (list 'hi 'hi)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if (not x) (snd-display #__line__ ";run list equal? syms: ~A" x))))
    
    (let ((val1 (list 'hi 'hi))
	  (val2 (list 'hi 'hi 'hi)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? syms 1: ~A" x))))
    
    (let ((val1 (list 'hi 'hi))
	  (val2 (list 'hi 'ho)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? syms 2: ~A" x))))
    
    
    (let ((val1 (list :hi :hi))
	  (val2 (list :hi :hi)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if (not x) (snd-display #__line__ ";run list equal? keys: ~A" x))))
    
    (let ((val1 (list :hi :hi))
	  (val2 (list :hi :hi :hi)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? keys 1: ~A" x))))
    
    (let ((val1 (list :hi :hi))
	  (val2 (list :hi :ho)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? keys 2: ~A" x))))
    
    (let ((val1 (list 1))
	  (val2 (list)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? nil 2: ~A" x))))
    
    (let ((val1 (list)) ; (equal? (list) (list)) -> #t in Scheme
	  (val2 (list)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if (not x) (snd-display #__line__ ";run list equal? nil both: ~A" x))))
    
    (let ((val1 (list 1))
	  (val2 (list 1.0)))
      (let ((x (run (lambda () (equal? val1 val2)))))
	(if x (snd-display #__line__ ";run list equal? int/dbl 2: ~A" x))))
    
    
    (let ((val (vector (make-hi308 1.0 2.0) (make-hi308 3.0 4.0))))
      (let ((x (run (lambda () (vector-ref val 1)))))
	(if (or (not (hi308? x))
		(fneq (hi308-phase x) 4.0))
	    (snd-display #__line__ ";run pass list vector as arg: ~A" x))))
    
    
    (let ((val (vector (make-hi308 1.0 2.0) (make-hi308 3.0 4.0))))
      (let ((x (run (lambda () (call-hi308 (vector-ref val 1))))))
	(if (fneq x 3.0) (snd-display #__line__ ";run list-vector call-hi: ~A" x))))
    
    (let ((val (vector (make-hi308 1.0 2.0) (make-hi308 3.0 4.0))))
      (let ((x (run (lambda () (set-hi308 (vector-ref val 1)) (call-hi308 (vector-ref val 1))))))
	(if (fneq x (* 3.5 3.0)) (snd-display #__line__ ";run list-vector set-hi+call-hi: ~A" val))))
    
    
    (let ((val (make-hiho309)))
      (run (lambda () (set! (hiho309-i val) 321)))
      (if (not (= (hiho309-i val) 321)) (snd-display #__line__ ";set hiho309-i: ~A" val)))
    
    (let ((val (make-hiho309)))
      (let ((x (run (lambda () (set! (hiho309-v val) (make-vct 32 .1)) (vct-ref (hiho309-v val) 2)))))
	(if (or (fneq x .1)
		(not (vct? (hiho309-v val)))
		(fneq (vct-ref (hiho309-v val) 2) .1))
	    (snd-display #__line__ ";set hiho309 vct: ~A" val))))
    
    
    (let ((val (make-hiho310)))
      (let ((x (run (lambda () (set! (hiho310-v val) "hiho") (hiho310-v val)))))
	(if (or (not (string? (hiho310-v val)))
		(not (string=? (hiho310-v val) "hiho")))
	    (snd-display #__line__ ";set hiho310 string: ~A" val))
	(if (or (not (string? x))
		(not (string=? x "hiho")))
	    (snd-display #__line__ ";set hiho310 string and return: ~A ~A" x val))))
    
    
    (let ((val (make-hiho311)))
      (run (lambda () (set! (hiho311-v val) (make-sound-data 2 3))))
      (if (or (not (sound-data? (hiho311-v val)))
	      (not (= (sound-data-chans (hiho311-v val)) 2)))
	  (snd-display #__line__ ";set hiho311 sound-data: ~A" val)))
    
    (let ((val (make-hiho311)))
      (run (lambda () (set! (hiho311-v val) (make-sound-data 2 3)) (sound-data-set! (hiho311-v val) 1 1 1.0)))
      (if (or (not (sound-data? (hiho311-v val)))
	      (not (= (sound-data-chans (hiho311-v val)) 2))
	      (fneq (sound-data-ref (hiho311-v val) 1 1) 1.0)
	      (fneq (sound-data-ref (hiho311-v val) 0 0) 0.0))
	  (snd-display #__line__ ";set hiho311 sound-data and return: ~A" val)))
    
    (let ((abc232g (make-abc232))
	  (abd232g (make-abd232)))
      (let ((result (run
		     (lambda ()
		       (+ (abc232-x abc232g)
			  (abd232-x abd232g))))))
	(if (fneq result 1.0) (snd-display #__line__ ";two structs: ~A" result))))
    
    (let ((abc232g (make-abc232))
	  (abd232g (make-abd232)))
      (let ((result (run
		     (lambda ()
		       (+ (abc232-func abc232g)
			  (abd232-func abd232g))))))
	(if (fneq result 1.0) (snd-display #__line__ ";two structs via func: ~A" result))))
    
    (with-sound (:output "test.snd" :channels 4)
		(let* ((dur 100)
		       (samps (seconds->samples dur))
		       (flta (make-formant 100 .999))
		       (fltb (make-formant 5000 .1))
		       (fltc (make-firmant 100 .999))
		       (fltd (make-firmant 5000 .1))
		       (ampf (make-env '(0 0 1 1 100 1 101 0) :duration dur))
		       (frqf (make-env '(0 100 1 10000) :scaler (hz->radians 1.0) :duration dur))
		       (rf (make-env '(0 .6 1 .999) :base .01 :duration dur)))
		  (run
		   (lambda ()
		     (do ((i 0 (+ 1 i)))
			 ((= i samps))
		       (let* ((frq (env frqf))
			      (r (env rf))
			      (amp (env ampf))
			      (pulse (- (random 2.0) 1.0)))
			 (outa i (* amp (formant flta pulse frq)))
			 (set! (mus-scaler fltb) r)
			 (outc i (* amp (formant fltb pulse)))
			 (outb i (* amp (firmant fltc pulse frq)))
			 (outd i (* amp (firmant fltd pulse)))
			 (set! (mus-scaler fltd) r)
			 ))))))
    (let ((ind (find-sound "test.snd")))
      (if (sound? ind)
	  (close-sound ind)))
    
    (let ((hie (lambda* ((a 0.0)) (declare (a float)) (+ a 1.0))))
      (if (fneq (run (lambda () (hie 1.0))) 2.0) (snd-display #__line__ ";run opt args 0"))
      (if (fneq (run (lambda () (hie))) 1.0) (snd-display #__line__ ";run opt args 1"))
      (if (fneq (run (lambda () (+ (hie) (hie 1.0)))) 3.0) (snd-display #__line__ ";run opt args 2")))
    
    (let ((hi (lambda* ((a 0.0) (b 0.0)) (declare (a float) (b float)) (+ a b))))
      (if (fneq (run (lambda () (hi 1.0))) 1.0) (snd-display #__line__ ";run opt args 3"))
      (if (fneq (run (lambda () (hi 1.0 2.0))) 3.0) (snd-display #__line__ ";run opt args 4"))
      (if (fneq (run (lambda () (hi))) 0.0) (snd-display #__line__ ";run opt args 5"))
      (if (fneq (run (lambda () (+ (hi) (hi 1.0) (hi 1.0 2.0)))) 4.0) (snd-display #__line__ ";run opt args 6"))
      (if (fneq (run (lambda () (+ (hi 1.0) (hi) (hi 1.0 2.0)))) 4.0) (snd-display #__line__ ";run opt args 7"))
      (if (fneq (run (lambda () (+ (hi 1.0) (hi 1.0 2.0) (hi)))) 4.0) (snd-display #__line__ ";run opt args 8"))
      (if (fneq (run (lambda () (+ (hi 1.0 2.0) (hi) (hi 1.0)))) 4.0) (snd-display #__line__ ";run opt args 9")))
    
    ;; optimizer tests
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (= x y) (+ x y) (- x y))))) -1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (not (= x y 1)) 3 2)))) 3)
    (ixtst (let ((x 1)) (run (lambda () (if (or (= x 2) (not (= x 3))) 3 2)))) 3)
    (ixtst (let ((x 0) (y 1)) (run (lambda () (if (not (= x 1)) (if (not (= y 1)) 3 2) 1)))) 2)
    (ixtst (let ((x 1) (y 2) (z #t)) (run (lambda () (= x y) (if z 1 0)))) 1)
    (ixtst (let ((x 1)) (run (lambda () (if (and (= x 1) (not (< x 0))) 3 2)))) 3)
    (ixtst (let ((x 1)) (run (lambda () (if (or (= x 1) (not (< x 0))) 3 2)))) 3)
    (ixtst (let ((x 1)) (run (lambda () (cond ((= x 0) 1) ((= x 1) 2) ((= x 3) 3))))) 2)
    
    (ixtst (let ((x 1)) (run (lambda () (if (= x 1) 1 2)))) 1)
    (ixtst (let ((x 1)) (run (lambda () (if (> x 1) 1 2)))) 2)
    (ixtst (let ((x 1)) (run (lambda () (if (< x 1) 1 2)))) 2)
    (ixtst (let ((x 1)) (run (lambda () (if (>= x 1) 1 2)))) 1)
    (ixtst (let ((x 1)) (run (lambda () (if (<= x 1) 1 2)))) 1)
    
    (ixtst (let ((x 1)) (run (lambda () (if (not (= x 1)) 1 2)))) 2)
    (ixtst (let ((x 1)) (run (lambda () (if (not (> x 1)) 1 2)))) 1)
    (ixtst (let ((x 1)) (run (lambda () (if (not (< x 1)) 1 2)))) 1)
    (ixtst (let ((x 1)) (run (lambda () (if (not (>= x 1)) 1 2)))) 2)
    (ixtst (let ((x 1)) (run (lambda () (if (not (<= x 1)) 1 2)))) 2)
    
    (fxtst (let ((x 1.0)) (run (lambda () (if (= x 1.0) 1 2)))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (if (> x 1.0) 1 2)))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (if (< x 1.0) 1 2)))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (if (>= x 1.0) 1 2)))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (if (<= x 1.0) 1 2)))) 1)
    
    (fxtst (let ((x 1.0)) (run (lambda () (if (not (= x 1.0)) 1 2)))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (if (not (> x 1.0)) 1 2)))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (if (not (< x 1.0)) 1 2)))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (if (not (>= x 1.0)) 1 2)))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (if (not (<= x 1.0)) 1 2)))) 2)
    
    
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (= y x 1) 1 2)))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (> y x 1) 1 2)))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (< y x 1) 1 2)))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (>= y x 1) 1 2)))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (<= y x 1) 1 2)))) 2)
    
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (not (= y x 1)) 1 2)))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (not (> y x 1)) 1 2)))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (not (< y x 1)) 1 2)))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (not (>= y x 1)) 1 2)))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (if (not (<= y x 1)) 1 2)))) 1)
    
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (= y x 1.0) 1 2)))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (> y x 1.0) 1 2)))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (< y x 1.0) 1 2)))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (>= y x 1.0) 1 2)))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (<= y x 1.0) 1 2)))) 2)
    
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (not (= y x 1.0)) 1 2)))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (not (> y x 1.0)) 1 2)))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (not (< y x 1.0)) 1 2)))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (not (>= y x 1.0)) 1 2)))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (if (not (<= y x 1.0)) 1 2)))) 1)
    
    (ixtst (let ((x 3)) (run (lambda () (if (odd? x) 1 2)))) 1)
    (ixtst (let ((x 3)) (run (lambda () (if (even? x) 1 2)))) 2)
    (ixtst (let ((x 3)) (run (lambda () (if (not (odd? x)) 1 2)))) 2)
    (ixtst (let ((x 3)) (run (lambda () (if (not (even? x)) 1 2)))) 1)
    
    (ixtst (let ((x -4)) (run (lambda () (if (odd? x) 1 2)))) 2)
    (ixtst (let ((x -4)) (run (lambda () (if (even? x) 1 2)))) 1)
    (ixtst (let ((x -4)) (run (lambda () (if (not (odd? x)) 1 2)))) 1)
    (ixtst (let ((x -4)) (run (lambda () (if (not (even? x)) 1 2)))) 2)
    
    (ixtst (let ((x 2)) (run (lambda () (if (zero? x) 1 2)))) 2)
    (ixtst (let ((x 2)) (run (lambda () (if (negative? x) 1 2)))) 2)
    (ixtst (let ((x 2)) (run (lambda () (if (positive? x) 1 2)))) 1)
    (ixtst (let ((x 2)) (run (lambda () (if (not (zero? x)) 1 2)))) 1)
    (ixtst (let ((x 2)) (run (lambda () (if (not (negative? x)) 1 2)))) 1)
    (ixtst (let ((x 2)) (run (lambda () (if (not (positive? x)) 1 2)))) 2)
    
    (fxtst (let ((x 2.0)) (run (lambda () (if (zero? x) 1 2)))) 2)
    (fxtst (let ((x 2.0)) (run (lambda () (if (negative? x) 1 2)))) 2)
    (fxtst (let ((x 2.0)) (run (lambda () (if (positive? x) 1 2)))) 1)
    (fxtst (let ((x 2.0)) (run (lambda () (if (not (zero? x)) 1 2)))) 1)
    (fxtst (let ((x 2.0)) (run (lambda () (if (not (negative? x)) 1 2)))) 1)
    (fxtst (let ((x 2.0)) (run (lambda () (if (not (positive? x)) 1 2)))) 2)
    
    
    (ixtst (let ((x 1)) (run (lambda () (cond ((= x 1) 1) (#t 2))))) 1)
    (ixtst (let ((x 1)) (run (lambda () (cond ((> x 1) 1) (#t 2))))) 2)
    (ixtst (let ((x 1)) (run (lambda () (cond ((< x 1) 1) (#t 2))))) 2)
    (ixtst (let ((x 1)) (run (lambda () (cond ((>= x 1) 1) (#t 2))))) 1)
    (ixtst (let ((x 1)) (run (lambda () (cond ((<= x 1) 1) (#t 2))))) 1)
    
    (ixtst (let ((x 1)) (run (lambda () (cond ((not (= x 1)) 1) (#t 2))))) 2)
    (ixtst (let ((x 1)) (run (lambda () (cond ((not (> x 1)) 1) (#t 2))))) 1)
    (ixtst (let ((x 1)) (run (lambda () (cond ((not (< x 1)) 1) (#t 2))))) 1)
    (ixtst (let ((x 1)) (run (lambda () (cond ((not (>= x 1)) 1) (#t 2))))) 2)
    (ixtst (let ((x 1)) (run (lambda () (cond ((not (<= x 1)) 1) (#t 2))))) 2)
    
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((= x 1.0) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((> x 1.0) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((< x 1.0) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((>= x 1.0) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((<= x 1.0) 1) (#t 2))))) 1)
    
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((not (= x 1.0)) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((not (> x 1.0)) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((not (< x 1.0)) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((not (>= x 1.0)) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0)) (run (lambda () (cond ((not (<= x 1.0)) 1) (#t 2))))) 2)
    
    
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((= y x 1) 1) (#t 2))))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((> y x 1) 1) (#t 2))))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((< y x 1) 1) (#t 2))))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((>= y x 1) 1) (#t 2))))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((<= y x 1) 1) (#t 2))))) 2)
    
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((not (= y x 1)) 1) (#t 2))))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((not (> y x 1)) 1) (#t 2))))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((not (< y x 1)) 1) (#t 2))))) 1)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((not (>= y x 1)) 1) (#t 2))))) 2)
    (ixtst (let ((x 1) (y 2)) (run (lambda () (cond ((not (<= y x 1)) 1) (#t 2))))) 1)
    
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((= y x 1.0) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((> y x 1.0) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((< y x 1.0) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((>= y x 1.0) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((<= y x 1.0) 1) (#t 2))))) 2)
    
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((not (= y x 1.0)) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((not (> y x 1.0)) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((not (< y x 1.0)) 1) (#t 2))))) 1)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((not (>= y x 1.0)) 1) (#t 2))))) 2)
    (fxtst (let ((x 1.0) (y 2.0)) (run (lambda () (cond ((not (<= y x 1.0)) 1) (#t 2))))) 1)
    
    (ixtst (let ((x 3)) (run (lambda () (cond ((odd? x) 1) (#t 2))))) 1)
    (ixtst (let ((x 3)) (run (lambda () (cond ((even? x) 1) (#t 2))))) 2)
    (ixtst (let ((x 3)) (run (lambda () (cond ((not (odd? x)) 1) (#t 2))))) 2)
    (ixtst (let ((x 3)) (run (lambda () (cond ((not (even? x)) 1) (#t 2))))) 1)
    
    (ixtst (let ((x -4)) (run (lambda () (cond ((odd? x) 1) (#t 2))))) 2)
    (ixtst (let ((x -4)) (run (lambda () (cond ((even? x) 1) (#t 2))))) 1)
    (ixtst (let ((x -4)) (run (lambda () (cond ((not (odd? x)) 1) (#t 2))))) 1)
    (ixtst (let ((x -4)) (run (lambda () (cond ((not (even? x)) 1) (#t 2))))) 2)
    
    (ixtst (let ((x 2)) (run (lambda () (cond ((zero? x) 1) (#t 2))))) 2)
    (ixtst (let ((x 2)) (run (lambda () (cond ((negative? x) 1) (#t 2))))) 2)
    (ixtst (let ((x 2)) (run (lambda () (cond ((positive? x) 1) (#t 2))))) 1)
    (ixtst (let ((x 2)) (run (lambda () (cond ((not (zero? x)) 1) (#t 2))))) 1)
    (ixtst (let ((x 2)) (run (lambda () (cond ((not (negative? x)) 1) (#t 2))))) 1)
    (ixtst (let ((x 2)) (run (lambda () (cond ((not (positive? x)) 1) (#t 2))))) 2)
    
    (fxtst (let ((x 2.0)) (run (lambda () (cond ((zero? x) 1) (#t 2))))) 2)
    (fxtst (let ((x 2.0)) (run (lambda () (cond ((negative? x) 1) (#t 2))))) 2)
    (fxtst (let ((x 2.0)) (run (lambda () (cond ((positive? x) 1) (#t 2))))) 1)
    (fxtst (let ((x 2.0)) (run (lambda () (cond ((not (zero? x)) 1) (#t 2))))) 1)
    (fxtst (let ((x 2.0)) (run (lambda () (cond ((not (negative? x)) 1) (#t 2))))) 1)
    (fxtst (let ((x 2.0)) (run (lambda () (cond ((not (positive? x)) 1) (#t 2))))) 2)
    
    (ixtst (let ((x 1)) (run (lambda () (cond ((= x 0) 1) ((> x 1) 2) ((< x 3) 3))))) 3)
    (ixtst (run (lambda () (let ((x 1)) (= 1 (let ((y 2)) (set! x y) x)) (+ x 1)))) 3)
    (ixtst (let ((x 1)) (let ((xx (lambda (a) (set! x a) a))) (run (lambda () (= 1 (xx 2)) (+ x 1))))) 3)
    (ixtst (run (lambda () (let ((x 1) (xx 1.0)) (+ (cond ((= x 2) (cond ((> xx 2.0) 1) (#t 2))) ((= x 1) (cond ((> xx 0.0) 3) (#t 4)))) 32)))) 35)
    (ixtst (run (lambda () (let ((x 1) (xx 1.0)) (+ (cond ((= x 2) (cond ((> xx 2.0) 1) (#t 2))) ((= x 1) (cond ((> xx 2.0) 3) (#t 4)))) 32)))) 36)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (cond ((= x 2) (not z)) ((= y 2) (= x 1)))))) #t)
    
    (bxtst (run (lambda () (let ((x 1) (y 2)) (and (= x 1) (> y 2))))) #f)
    (bxtst (run (lambda () (let ((x 1) (y 2)) (and (< x 1) (not (= y 2)))))) #f)
    (bxtst (run (lambda () (let ((x 1) (y 2)) (and (not (= x 2)) (not (> y 2)))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (and (= x 1) (not z) (> y 2))))) #f)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (and (>= x 1) (not z) (<= y 2))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (and (odd? x) z (even? y))))) #f)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (and (odd? x) (not (not (not z))) (even? y))))) #t)
    
    (bxtst (run (lambda () (let ((x 1) (y 2)) (or (= x 1) (> y 2))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2)) (or (< x 1) (not (= y 2)))))) #f)
    (bxtst (run (lambda () (let ((x 1) (y 2)) (or (not (= x 2)) (not (> y 2)))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (or (= x 1) (not z) (> y 2))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (or (>= x 1) (not z) (<= y 2))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (or (odd? x) z (even? y))))) #t)
    (bxtst (run (lambda () (let ((x 1) (y 2) (z #f)) (or (negative? x) (not (not z)) (zero? y))))) #f)
    
    (bxtst (run (lambda () (cond (#t 'a) (#t 'b)))) 'a)
    (bxtst (run (lambda () (cond ((> 3 2) 'greater) ((< 3 2) 'less)))) 'greater)
    (bxtst (run (lambda () (cond ((> 3 3) 'greater) ((< 3 3) 'less)  (else 'equal)))) 'equal)
    (ixtst (run (lambda () (cond (#f 2) (else 5)))) 5)
    (ixtst (run (lambda () (cond (1 2) (else 5)))) 2)
    (ixtst (run (lambda () (cond ((+ 1 2))))) 3)
    (ixtst (run (lambda () (cond ((zero? 1) 123) ((= 1 1) 321)))) 321)
    (ixtst (run (lambda () (cond (1 2 3)))) 3)
    (ixtst (run (lambda () (cond ((= 1 2) 3) ((+ 3 4))))) 7)
    (ixtst (run (lambda () (cond ((= 1 1) (abs -1) (+ 2 3) (* 10 2)) (else 123)))) 20)
    (ixtst (run (lambda () (let ((a 1)) (cond ((= a 1) (set! a 2) (+ a 3)))))) 5)
    (ixtst (run (lambda () (let ((a 1)) (cond ((= a 2) (+ a 2)) (else (set! a 3) (+ a 3)))))) 6)
    (bxtst (run (lambda () (cond ((= 1 1))))) #t)
    (bxtst (run (lambda () (cond ((= 1 2) #f) (#t)))) #t)
    (ixtst (run (lambda () (cond ((+ 1 2))))) 3)
    
    (bxtst (run (lambda () (and (= 2 2) (> 2 1)))) #t)
    (bxtst (run (lambda () (and (= 2 2) (< 2 1)))) #f)
    (bxtst (run (lambda () (and))) #t)
    (bxtst (run (lambda () (and 3 (zero? 1) (/ 1 0) (display "or is about to exit!") (exit)))) #f)
    (bxtst (run (lambda () (and (or (and (> 3 2) (> 3 4)) (> 2 3)) 4))) #f)
    (bxtst (run (lambda () (let ((a 1)) (and (let () (set! a 2) #t) (= a 1) (let () (set! a 3) #f) (and (= a 3) a) (let () (set! a 4) #f) a)))) #f)
    
    
    (ixtst (run (lambda () (lcm -1))) 1)
    (ixtst (run (lambda () (gcd -1))) 1)
    (bxtst (run (lambda () (eq? "asd" "asd"))) #f)
    (bxtst (run (lambda () (eqv? "asd" "asd"))) #f)
    (bxtst (run (lambda () (equal? "asd" "asd"))) #t)
    (bxtst (run (lambda () (equal? "asd" "dsa"))) #f)
    
    (let ((len (let ((v (make-vct 32))) (run (lambda () (length v))))))
      (if (not (= len 32)) (snd-display #__line__ ";run length vct: ~A" len)))
    (let ((len (let ((v (make-vector 32 1.0))) (run (lambda () (length v))))))
      (if (not (= len 32)) (snd-display #__line__ ";run length vector 1.0: ~A" len)))
    (let ((len (let ((v (make-vector 32 1))) (run (lambda () (length v))))))
      (if (not (= len 32)) (snd-display #__line__ ";run length vector 1: ~A" len)))
    (let ((len (let ((s (string #\h #\i))) (run (lambda () (length s))))))
      (if (not (= len 2)) (snd-display #__line__ ";run length string: ~A" len)))
    (let ((len (let ((l (list 1 2 3))) (run (lambda () (length l))))))
      (if (not (= len 3)) (snd-display #__line__ ";run length list: ~A" len)))
    (let ((len (let ((f (make-frame 3))) (run (lambda () (length f))))))
      (if (not (= len 3)) (snd-display #__line__ ";run length frame: ~A" len)))
    (let ((len (let ((f (make-mixer 3))) (run (lambda () (length f))))))
      (if (not (= len 3)) (snd-display #__line__ ";run length mixer: ~A" len)))
    (let ((len (let ((f (make-delay 32))) (run (lambda () (length f))))))
      (if (not (= len 32)) (snd-display #__line__ ";run length delay: ~A" len)))
    
    
    ;; length as generic function:
    ;;     string-length vector-length hash-table-size vct-length 
    ;;     frames mus-length sound-data-length mix-length region-frames 
    
    (let ((snd (open-sound "oboe.snd"))
	  (v (vct .1 .2 .3))
	  (vc (vector .1 .2 .3 .4))
	  (lst (list 1 2 3 4 5))
	  (sd (make-sound-data 1 10))
	  (str "123456")
	  (fr (frame .1 .2))
	  (mx (mixer .1 .2 .3 .4)))
      (let ((mxv (mix-vct v 1000))
	    (reg (make-region 0 100))
	    (dly (make-delay 32))
	    )
	(if (not (= (run (lambda () (length snd))) 50828)) (snd-display #__line__ ";length of sound: ~A" (length snd)))
	(if (not (= (run (lambda () (length v))) 3)) (snd-display #__line__ ";length of vct: ~A" (length v)))
	(if (not (= (run (lambda () (length vc))) 4)) (snd-display #__line__ ";length of vector: ~A" (length vc)))
	(if (not (= (run (lambda () (length lst))) 5)) (snd-display #__line__ ";length of list: ~A" (length lst)))
	(if (not (= (run (lambda () (length str))) 6)) (snd-display #__line__ ";length of string: ~A" (length str)))
	(if (not (= (run (lambda () (length sd))) 10)) (snd-display #__line__ ";length of sound-data: ~A" (length sd)))
	(if (not (= (run (lambda () (length fr))) 2)) (snd-display #__line__ ";length of frame: ~A" (length fr)))
	(if (not (= (run (lambda () (length mx))) 2)) (snd-display #__line__ ";length of mixer: ~A" (length mx)))
	(if (and (mix? mxv) (not (= (run (lambda () (length mxv))) 3))) (snd-display #__line__ ";length of mix: ~A" (length mxv)))
	(if (not (= (run (lambda () (length reg))) 101)) (snd-display #__line__ ";length of region: ~A" (length reg)))
	(if (not (= (run (lambda () (length dly))) 32)) (snd-display #__line__ ";length of delay: ~A" (length dly)))
	)
      (close-sound snd))
    
    ;; srate as generic: mus-sound-srate region-srate srate 
    
    (let ((snd (open-sound "oboe.snd"))
	  (str "oboe.snd"))
      (let ((reg (make-region 0 100))
	    )
	(if (not (= (run (lambda () (srate snd))) 22050)) (snd-display #__line__ ";srate of sound: ~A" (srate snd)))
	(if (not (= (run (lambda () (srate str))) 22050)) (snd-display #__line__ ";srate of string: ~A" (srate str)))
	(if (not (= (run (lambda () (srate reg))) 22050)) (snd-display #__line__ ";srate of region: ~A" (srate reg)))
	)
      (close-sound snd))
    
    ;; channels as generic: mus-sound-chans region-chans chans mus-channels mix/etc
    
    (let ((snd (open-sound "oboe.snd"))
	  (v (vct .1 .2 .3))
	  (sd (make-sound-data 2 10))
	  (str "oboe.snd")
	  (fr (frame .1 .2))
	  (mx (mixer .1 .2 .3 .4)))
      (let ((mxv (mix-vct v 1000))
	    (reg (make-region 0 100))
	    )
	(if (not (= (run (lambda () (channels snd))) 1)) (snd-display #__line__ ";channels of sound: ~A" (channels snd)))
	(if (not (= (run (lambda () (channels v))) 1)) (snd-display #__line__ ";channels of vct: ~A" (channels v)))
	(if (not (= (run (lambda () (channels str))) 1)) (snd-display #__line__ ";channels of string: ~A" (channels str)))
	(if (not (= (run (lambda () (channels sd))) 2)) (snd-display #__line__ ";channels of sound-data: ~A" (channels sd)))
	(if (not (= (run (lambda () (channels fr))) 2)) (snd-display #__line__ ";channels of frame: ~A" (channels fr)))
	(if (not (= (run (lambda () (channels mx))) 2)) (snd-display #__line__ ";channels of mixer: ~A" (channels mx)))
	(if (not (= (run (lambda () (channels mxv))) 1)) (snd-display #__line__ ";channels of mix: ~A" (channels mxv)))
	(if (not (= (run (lambda () (channels reg))) 1)) (snd-display #__line__ ";channels of region: ~A" (channels reg)))
	)
      (close-sound snd))
    
    ;; frames as generic
    
    (let ((snd (open-sound "oboe.snd"))
	  (v (vct .1 .2 .3))
	  (sd (make-sound-data 1 10))
	  (str "oboe.snd")
	  (fr (frame .1 .2))
	  (mx (mixer .1 .2 .3 .4)))
      (let ((mxv (mix-vct v 1000))
	    (reg (make-region 0 100))
	    (dly (make-delay 32))
	    )
	(if (not (= (run (lambda () (frames snd))) 50828)) (snd-display #__line__ ";frames of sound: ~A" (frames snd)))
	(if (not (= (run (lambda () (frames v))) 3)) (snd-display #__line__ ";frames of vct: ~A" (frames v)))
	(if (not (= (run (lambda () (frames str))) 50828)) (snd-display #__line__ ";frames of string: ~A" (frames str)))
	(if (not (= (run (lambda () (frames sd))) 10)) (snd-display #__line__ ";frames of sound-data: ~A" (frames sd)))
	(if (not (= (run (lambda () (frames fr))) 2)) (snd-display #__line__ ";frames of frame: ~A" (frames fr)))
	(if (not (= (run (lambda () (frames mx))) 2)) (snd-display #__line__ ";frames of mixer: ~A" (frames mx)))
	(if (not (= (run (lambda () (frames mxv))) 3)) (snd-display #__line__ ";frames of mix: ~A" (frames mxv)))
	(if (not (= (run (lambda () (frames reg))) 101)) (snd-display #__line__ ";frames of region: ~A" (frames reg)))
	(if (not (= (run (lambda () (frames dly))) 32)) (snd-display #__line__ ";frames of delay: ~A" (frames dly)))
	)
      (close-sound snd))
    
    ;; file-name as generic
    
    (let ((snd (open-sound "oboe.snd"))
	  (str "oboe.snd")
	  (frm (make-file->sample "oboe.snd")))
      (let ((mxv (car (mix "pistol.snd" 1000)))
	    (reg (make-region 0 100))
	    )
	(if (not (string=? (run (lambda () (file-name snd))) (string-append (getcwd) "/oboe.snd"))) (snd-display #__line__ ";file-name of sound: ~A" (file-name snd)))
	(if (not (string=? (run (lambda () (file-name str))) (string-append (getcwd) "/oboe.snd"))) (snd-display #__line__ ";file-name of string: ~A" (file-name str)))
	(if (not (string=? (run (lambda () (file-name frm))) "oboe.snd")) (snd-display #__line__ ";file-name of file->sample: ~A" (file-name frm)))
	(if (not (string=? (run (lambda () (file-name mxv))) (string-append (getcwd) "/pistol.snd"))) (snd-display #__line__ ";file-name of mix: ~A" (file-name mxv)))
	(if (not (string=? (run (lambda () (file-name reg))) "oboe.snd")) (snd-display #__line__ ";file-name of region: ~A" (file-name reg)))
	)
      (mus-close frm)
      (close-sound snd))
    
    ;; maxamp as generic
    
    (let ((snd (open-sound "oboe.snd"))
	  (v (vct .1 .2 .3))
	  (vc (vector .1 .2 .3 .4)))
      (let ((mxv (mix-vct v 1000))
	    (reg (make-region 0 900))
	    )
	(if (fneq (run (lambda () (maxamp snd))) .334) (snd-display #__line__ ";maxamp of sound: ~A" (maxamp snd)))
	(if (fneq (run (lambda () (maxamp snd 0))) .334) (snd-display #__line__ ";maxamp of sound (0): ~A" (maxamp snd)))
	(if (fneq (run (lambda () (maxamp snd 0 0))) .14724) (snd-display #__line__ ";maxamp of sound (0 0): ~A" (maxamp snd)))
	(if (fneq (run (lambda () (maxamp v))) .3) (snd-display #__line__ ";maxamp of vct: ~A" (maxamp v)))
	(if (fneq (run (lambda () (maxamp vc))) .4) (snd-display #__line__ ";maxamp of vector: ~A" (run (lambda () (maxamp vc)))))
	(if (fneq (run (lambda () (maxamp mxv))) .3) (snd-display #__line__ ";maxamp of mix: ~A" (maxamp mxv)))
	(if (fneq (run (lambda () (maxamp reg))) .02139) (snd-display #__line__ ";maxamp of region: ~A" (maxamp reg)))
	)
      (close-sound snd))
    
    ))


;; (set! *clm-notehook* (lambda args (display (format #f "~A~%" args))))




;;; ---------------- test 23: with-sound ----------------

(if (not (provided? 'snd-prc95.scm)) (load "prc95.scm"))
(if (not (provided? 'snd-jcrev.scm)) (load "jcrev.scm"))
(if (not (provided? 'snd-maraca.scm)) (load "maraca.scm"))
(if (not (provided? 'snd-singer.scm)) (load "singer.scm"))
(if (not (provided? 'snd-strad.scm)) (load "strad.scm"))
(if (not (provided? 'snd-noise.scm)) (load "noise.scm"))
(if (not (provided? 'snd-clm-ins.scm)) (load "clm-ins.scm"))
(if (not (provided? 'snd-jcvoi.scm)) (load "jcvoi.scm"))
(if (not (provided? 'snd-piano.scm)) (load "piano.scm"))
(if (not (provided? 'snd-play.scm)) (load "play.scm"))
(if (not (provided? 'snd-zip.scm)) (load "zip.scm"))
(if (not (provided? 'snd-clm23.scm)) (load "clm23.scm"))
(if (not (provided? 'snd-freeverb.scm)) (load "freeverb.scm"))
(if (not (provided? 'snd-grani.scm)) (load "grani.scm"))
(if (not (provided? 'snd-animals.scm)) (load "animals.scm"))
(if (not (provided? 'snd-big-gens.scm)) (load "big-gens.scm"))
(if (not (provided? 'snd-dlocsig.scm)) (load "dlocsig.scm"))
(if (not (provided? 'snd-sndwarp.scm)) (load "sndwarp.scm"))

(define old-opt-23 (optimization))

(def-clm-struct st1 one two)
(def-clm-struct st2 (one 11) (two 22))
(def-clm-struct grab-bag 
  (flt 0.0 :type float)
  (flt1 1.0)
  (i 0 :type int)
  (i1 123)
  (bool #f :type boolean)
  (bool1 #t)
  (ch #\c :type char)
  (ch1 #\c)
  (str "hi" :type string)
  (str1 "hi1")
  (lst '() :type list)
  (sym 'hi :type symbol)
  (v #f :type vct)
  (rd #f :type sampler)
  (mxrd #f :type mix-sampler)
  (sd #f :type sound-data)
  (gen #f :type clm)
  (fvect #f :type float-vector)
  (ivect #f :type int-vector)
  (vvect #f :type vct-vector)
  (cvect #f :type clm-vector))

(def-clm-struct (osc329 :make-wrapper (lambda (gen)
					(set! (osc329-freq gen) (hz->radians (osc329-freq gen)))
					gen)
			:methods (list
				  (list 'mus-frequency 
					(lambda (g) (radians->hz (osc329-freq g)))
					(lambda (g val) (set! (osc329-freq g) (hz->radians val))))
				  
				  (list 'mus-phase 
					(lambda (g) (osc329-phase g))
					(lambda (g val) (set! (osc329-phase g) val)))
				  
				  (list 'mus-increment 
					(make-procedure-with-setter
					 (lambda (g) (osc329-incr g))
					 (lambda (g val) (set! (osc329-incr g) val))))
				  
				  (list 'mus-name
					(lambda (g) "osc329"))
				  
				  (list 'mus-length
					(lambda (g) (osc329-n g))
					(lambda (g val) (set! (osc329-n g) val)))
				  
				  (list 'mus-hop
					(make-procedure-with-setter
					 (lambda (g) (osc329-n g))
					 (lambda (g val) (set! (osc329-n g) val))))
				  
				  (list 'mus-describe 
					(lambda (g) (format #f "osc329 freq: ~A, phase: ~A" 
							    (mus-frequency g) 
							    (mus-phase g))))))
  freq phase (n 1 :type int)
  (incr 1.0))

(define (osc329 gen fm)
  (declare (gen osc329) (fm float))
  (let ((result (sin (osc329-phase gen))))
    (set! (osc329-phase gen) (+ (osc329-phase gen) (osc329-freq gen) fm))
    result))


(define (snd_test_23)
  
  (definstrument (green3 start dur freq amp amp-env noise-freq noise-width noise-max-step)
    ;; brownian noise on amp env
    (let* ((grn (make-green-noise-interp :frequency noise-freq :amplitude noise-max-step :high (* 0.5 noise-width) :low (* -0.5 noise-width)))
	   (osc (make-oscil freq))
	   (e (make-env amp-env :scaler amp :duration dur))
	   (beg (floor (* start (mus-srate))))
	   (end (+ beg (floor (* dur (mus-srate))))))
      (run
       (lambda ()
	 (do ((i beg (+ 1 i)))
	     ((= i end))
	   (outa i (* (env e) 
		      (+ 1.0 (green-noise-interp grn 0.0))
		      (oscil osc))))))))
  
					;(with-sound () (green3 0 2.0 440 .5 '(0 0 1 1 2 1 3 0) 100 .2 .02))
  
  (definstrument (green4 start dur freq amp freq-env gliss noise-freq noise-width noise-max-step)
    ;; same but on freq env
    (let* ((grn (make-green-noise-interp :frequency noise-freq :amplitude noise-max-step :high (* 0.5 noise-width) :low (* -0.5 noise-width)))
	   (osc (make-oscil freq))
	   (e (make-env freq-env :scaler gliss :duration dur))
	   (beg (floor (* start (mus-srate))))
	   (end (+ beg (floor (* dur (mus-srate))))))
      (run
       (lambda ()
	 (do ((i beg (+ 1 i)))
	     ((= i end))
	   (outa i (* amp (oscil osc (hz->radians (+ (env e) (green-noise-interp grn 0.0)))))))))))
					;(with-sound () (green4 0 2.0 440 .5 '(0 0 1 1 2 1 3 0) 440 100 100 10))
  
  (define (ws-sine freq)
    (let ((o (make-oscil freq)))
      (run
       (do ((i 0 (+ 1 i)))
	   ((= i 100))
	 (outa i (oscil o))))))
  
  (define (step-src)
    (let* ((rd (make-sampler 0))
	   (o (make-oscil 2205.0))
	   (s (make-src :srate 0.0))
	   (incr (+ 2.0 (oscil o)))	  
	   (tempfile (with-sound (:output (snd-tempnam) :srate (srate) :to-snd #f :comment "step-src")
				 (run
				  (do ((samp 0 (+ 1 samp)))
				      ((or (c-g?) 
					   (sampler-at-end? rd)))
				    (out-any samp 
					     (src s incr (lambda (dir) (read-sample rd)))
					     0)
				    (if (= (modulo samp 2205) 0)
					(set! incr (+ 2.0 (oscil o))))))))
	   (len (mus-sound-frames tempfile)))
      (set-samples 0 (- len 1) tempfile #f #f #t "step-src" 0 #f #t)))
  
  (define (check-with-mix num dur total-dur amp opts calls old-date chkmx)
    (let ((ind (find-sound "test.snd")))
      (if (not (sound? ind)) (snd-display #__line__ ";with-mix (~A) init: no test.snd?" num))
      (if (and chkmx (fneq (maxamp ind) amp)) (snd-display #__line__ ";with-mix (~A) maxamp: ~A (~A)" num (maxamp ind) amp))
      (if (not (file-exists? "with-mix.snd")) (snd-display #__line__ ";with-mix (~A) output doesn't exist" num))
      (let ((mx (mus-sound-maxamp "with-mix.snd"))
	    (date (mus-sound-write-date "with-mix.snd"))
	    (duration (mus-sound-duration "with-mix.snd")))
	(if (fneq duration dur) (snd-display #__line__ ";with-mix (~A) dur: ~A ~A" num dur duration))
	(if (fneq total-dur (/ (frames ind) (srate ind))) 
	    (snd-display #__line__ ";with-mix (~A) total dur: ~A ~A" num total-dur (/ (frames ind) (srate ind))))
	(if (and old-date
		 (> (- date old-date) 1)) ; these can be off by some amount in Linux
	    (snd-display #__line__ ";with-mix (~A) rewrote output?: ~A ~A ~A" num (- date old-date)
			 (strftime "%d-%b-%g %H:%M:%S" (localtime old-date))
			 (strftime "%d-%b-%g %H:%M:%S" (localtime date))))
	(if (and chkmx (or (not mx) (fneq (cadr mx) amp))) (snd-display #__line__ ";with-mix sndf (~A) maxamp: ~A (~A)" num mx amp))
	(let ((header-str (mus-sound-comment "with-mix.snd")))
	  (if (not (string? header-str)) (snd-display #__line__ ";with-mix (~A) comment unwritten?: ~A" num (mus-sound-comment "with-mix.snd")))
	  (let ((header (eval-string header-str)))
	    (if (not (list? header)) (snd-display #__line__ ";with-mix (~A) comment: ~A -> ~A" num header-str header))
	    (if (or (not (string=? (car header) opts))
		    (not (string=? (cadr header) calls)))
		(snd-display #__line__ ";with-mix (~A) header values: ~A" num header))))
	(close-sound ind)
	date)))
  
  (define* (clm-reverb-sound reverb-amount reverb (reverb-data '()) snd)
    (let ((output (snd-tempnam))
	  (revout (snd-tempnam))
	  (len (+ (frames snd) (srate snd))))
      (scale-by (- 1.0 reverb-amount) snd)
      (save-sound-as output snd)
      (undo 1 snd)
      (scale-by reverb-amount snd)
      (save-sound-as revout snd)
      (undo 1 snd)
      (dynamic-wind
	  (lambda ()
	    (set! *output* (continue-sample->file output))
	    (set! (mus-srate) (srate snd))
	    (set! *reverb* (make-file->sample revout)))
	  (lambda ()
	    (apply reverb reverb-data))
	  (lambda ()
	    (mus-close *reverb*)
	    (mus-close *output*)
	    (set! *reverb* #f)
	    (set! *output* #f)
	    (delete-file revout)
	    (set! (samples 0 len snd #f #f #f 0 #f #t) output)))))
  
  (define* (optkey-1 a) a)
  (define* (optkey-2 (a 3) b) (list a b))
  (define* (optkey-3 a b c) (list a b c))
  (define* (optkey-4 (a 1) (b 2) (c 3) d) (list a b c d))
  
  (define (fir+comb beg dur freq amp size)
    (let* ((start (floor (* (mus-srate) beg)))
	   (end (+ start (floor (* (mus-srate) dur))))
	   (dly (make-comb :scaler .9 :size size)) 
	   (flt (make-fir-filter :order size :xcoeffs (mus-data dly))) 
	   (r (make-rand freq)))
      (run 
       (do ((i start (+ 1 i))) 
	   ((= i end)) 
	 (outa i (* amp (fir-filter flt (comb dly (rand r)))))))))
  
  (definstrument (dloc-sinewave start-time duration freq amp 
				(amp-env '(0 1 1 1))
				(path (make-path :path '(-10 10 0 5 10 10))))
    (let* ((vals (make-dlocsig :start-time start-time
			       :duration duration
			       :path path))
	   (dloc (car vals))
	   (beg (cadr vals))
	   (end (caddr vals)))
      (let* ((osc (make-oscil :frequency freq))
	     (aenv (make-env :envelope amp-env :scaler amp :duration duration)))
	(run
	 (lambda ()
	   (do ((i beg (+ 1 i)))
	       ((= i end))
	     (dlocsig dloc i (* (env aenv) (oscil osc)))))))))
  
  (definstrument (dlocsig-sinewave-1 start-time duration freq amp 
				     (amp-env '(0 1 1 1))
				     (path (make-path :path '(-10 10 0 5 10 10)))
				     (decode amplitude-panning)
				     (initdly #f))
    (let* ((vals (make-dlocsig :start-time start-time
			       :duration duration
			       :render-using decode
			       :initial-delay initdly
			       :path path))
	   (dloc (car vals))
	   (beg (cadr vals))
	   (end (caddr vals)))
      (let* ((osc (make-oscil :frequency freq))
	     (aenv (make-env :envelope amp-env :scaler amp :duration duration)))
	(run
	 (lambda ()
	   (do ((i beg (+ 1 i)))
	       ((= i end))
	     (dlocsig dloc i (* (env aenv) (oscil osc)))))))))
  
  (define (mix-move-sound start-time file path)
    (let* ((duration (mus-sound-duration file))
	   (rd (make-sampler 0 file))
	   (start (round (* (mus-srate) start-time)))
	   (tmp-sound (with-temp-sound (:channels 4 :srate (mus-sound-srate file))
				       (let* ((vals (make-dlocsig :start-time 0
								  :duration duration
								  :path path))
					      (dloc (car vals))
					      (beg (cadr vals))
					      (end (caddr vals)))
					 (run
					  (lambda ()
					    (do ((i beg (+ 1 i)))
						((= i end))
					      (dlocsig dloc i (read-sample rd)))))))))
      (mix tmp-sound start #t #f #f (with-mix-tags) #t)))
  
  (define (check-segments vals snd chn name)
    (let* ((rd (make-sampler 0 snd chn))
	   (len (frames snd chn))
	   (seglen (round (/ len 50)))
	   (segctr 0)
	   (segmax 0.0)
	   (valctr 0)
	   (unhappiest 0.0)
	   (unhappiestseg 0)
	   (unhappy 0)
	   (alldone #f))
      (do ((i 0 (+ 1 i)))
	  ((or alldone (= i len)))
	(let ((samp (abs (rd))))
	  (if (> samp segmax) (set! segmax samp))
	  (set! segctr (+ 1 segctr))
	  (if (>= segctr seglen)
	      (begin
		(set! segctr 0)
		(if (> (abs (- segmax (vector-ref vals valctr))) .003)
		    (begin
					;(if (< unhappy 2)
		      (snd-print (format #f "~A: seg ~D differs: ~A ~A~%" name valctr segmax (vector-ref vals valctr)));)
		      (let ((hdiff (abs (- segmax (vector-ref vals valctr)))))
			(if (> hdiff unhappiest)
			    (begin
			      (set! unhappiestseg valctr)
			      (set! unhappiest hdiff))))
		      (set! unhappy (+ 1 unhappy))))
		(set! valctr (+ 1 valctr))
		(if (>= valctr (vector-length vals)) (set! alldone #t))
		(set! segmax 0.0)))))
      (if (> unhappy 0)
	  (snd-print (format #f "~A: unhappiest: ~A ~A~%" name unhappiestseg unhappiest)))))
  
  (definstrument (defopt-simp beg dur (frequency 440.0) (amplitude 0.1))
    (let* ((os (make-oscil frequency)))
      (run 
       (do ((i 0 (+ 1 i))) ((= i dur))
	 (outa (+ i beg) (* amplitude (oscil os)))))))
  
  
  (definstrument (jcrev2)
    (let* (
	   (allpass11 (make-all-pass -0.700 0.700 1051))
	   (allpass21 (make-all-pass -0.700 0.700  337))
	   (allpass31 (make-all-pass -0.700 0.700  113))
	   (comb11 (make-comb 0.742 4799))
	   (comb21 (make-comb 0.733 4999))
	   (comb31 (make-comb 0.715 5399))
	   (comb41 (make-comb 0.697 5801))
	   (outdel11 (make-delay (seconds->samples .01)))
	   
	   (allpass12 (make-all-pass -0.700 0.700 1051))
	   (allpass22 (make-all-pass -0.700 0.700  337))
	   (allpass32 (make-all-pass -0.700 0.700  113))
	   (comb12 (make-comb 0.742 4799))
	   (comb22 (make-comb 0.733 4999))
	   (comb32 (make-comb 0.715 5399))
	   (comb42 (make-comb 0.697 5801))
	   (outdel12 (make-delay (seconds->samples .01)))
	   
	   (file-dur (frames *reverb*))
	   (decay-dur (mus-srate))
	   (len (floor (+ decay-dur file-dur))))
      
      (run
       (lambda ()
	 (do ((i 0 (+ 1 i)))
	     ((= i len))
	   
	   (let* ((allpass-sum (all-pass allpass31 
					 (all-pass allpass21 
						   (all-pass allpass11 
							     (ina i *reverb*)))))
		  (comb-sum (+ (comb comb11 allpass-sum)
			       (comb comb21 allpass-sum)
			       (comb comb31 allpass-sum)
			       (comb comb41 allpass-sum))))
	     (outa i (delay outdel11 comb-sum)))
	   
	   (let* ((allpass-sum (all-pass allpass32 
					 (all-pass allpass22 
						   (all-pass allpass12 
							     (inb i *reverb*)))))
		  (comb-sum (+ (comb comb12 allpass-sum)
			       (comb comb22 allpass-sum)
			       (comb comb32 allpass-sum)
			       (comb comb42 allpass-sum))))
	     (outb i (delay outdel12 comb-sum)))
	   )))))
  
  
  (definstrument (floc-simp beg dur (amp 0.5) (freq 440.0) (ramp 2.0) (rfreq 1.0) offset)
    (let* ((os (make-pulse-train freq))
	   (floc (make-flocsig :reverb-amount 0.1
			       :frequency rfreq
			       :amplitude ramp
			       :offset offset))
	   (start (seconds->samples beg))
	   (end (+ start (seconds->samples dur))))
      (run
       (lambda ()
	 (do ((i start (+ i 1))) 
	     ((= i end))
	   (flocsig floc i (* amp (pulse-train os))))))))
  
  
  (define (test-ws-errors)
    ;; since we only catch 'mus-error and 'with-sound-interrupt above, any other error
    ;;   closes *output* and returns to the top-level -- are there languishing threads?
    ;;   Need a way outside with-sound to see what threads are out there.
    
    (define (bad-ins start)
      (c-g!))
    
    (set! *clm-threads* 4)
    
    (let ((prev (find-sound "test.snd")))
      (if (sound? prev)
	  (close-sound prev)))
    
    (if (mus-output? *output*)
	(begin
	  (snd-display #__line__ ";ws-error start: *output*: ~A" *output*)
	  (mus-close *output*)
	  (set! *output* #f)))
    
    
    ;; ---------------- catch 'wrong-type-arg (not handled by with-sound) ----------------
    
    (let ((tag (catch #t
		      (lambda ()
			(with-sound (:output "test.snd")
				    (fm-violin 0 1 440 .1)
				    (fm-violin .1 1 660 .1)
				    (fm-violin .2 1 880 .1)
				    (fm-violin .3 1 -220 .1)))
		      (lambda args args))))
      
      (if (or (not (list? tag))
	      (not (eq? (car tag) 'wrong-type-arg)))
	  (snd-display #__line__ ";ws-error -220: ~A" tag))
      (if (mus-output? *output*)
	  (begin
	    (snd-display #__line__ ";ws-error -220: *output*: ~A" *output*)
	    (mus-close *output*)
	    (set! *output* #f)))
      (let ((prev (find-sound "test.snd")))
	(if (sound? prev)
	    (begin
	      (snd-display #__line__ ";ws error -220 opened test.snd?")
	      (close-sound prev))))
      (if *ws-finish*
	  (snd-display #__line__ ";ws error -220 caught interrupt? ~A" *ws-finish*)))
    
    (if (defined? 'all-threads)
	(let ((current-threads (all-threads)))
	  (if (not (equal? current-threads (list (current-thread))))
	      (snd-display #__line__ ";ws error threaded start threads: ~A, current:~A" current-threads (current-thread)))
	  
	  (let ((tag (catch #t
			    (lambda ()
			      (with-threaded-sound (:output "test.snd")
						   (fm-violin 0 1 440 .1)
						   (fm-violin .1 1 660 .1)
						   (fm-violin .2 1 880 .1)
						   (fm-violin .3 1 -220 .1)))
			    (lambda args args))))
	    
	    (if (or (not (list? tag))
		    (not (eq? (car tag) 'wrong-type-arg)))
		(snd-display #__line__ ";ws-error threaded -220: ~A" tag))
	    (if (mus-output? *output*)
		(begin
		  (snd-display #__line__ ";ws-error threaded -220: *output*: ~A" *output*)
		  (mus-close *output*)
		  (set! *output* #f)))
	    (let ((prev (find-sound "test.snd")))
	      (if (sound? prev)
		  (begin
		    (snd-display #__line__ ";ws error threaded -220 opened test.snd?")
		    (close-sound prev))))
	    (if *ws-finish*
		(snd-display #__line__ ";ws error threaded -220 caught interrupt? ~A" *ws-finish*))
	    
	    (if (not (equal? current-threads (all-threads)))
		(snd-display #__line__ ";ws error threaded -220 threads: ~A, current:~A, all: ~A" current-threads (current-thread) (all-threads))))
	  
	  (let ((tag (catch #t
			    (lambda ()
			      (with-threaded-sound (:output "test.snd")
						   (fm-violin .3 1 44220 .1)))
			    (lambda args args))))
	    
	    (if (or (not (list? tag))
		    (not (eq? (car tag) 'out-of-range)))
		(snd-display #__line__ ";ws-error threaded -220 1: ~A" tag))
	    (if (mus-output? *output*)
		(begin
		  (snd-display #__line__ ";ws-error threaded -220 1: *output*: ~A" *output*)
		  (mus-close *output*)
		  (set! *output* #f)))
	    (let ((prev (find-sound "test.snd")))
	      (if (sound? prev)
		  (begin
		    (snd-display #__line__ ";ws error threaded -220 1 opened test.snd?")
		    (close-sound prev))))
	    (if *ws-finish*
		(snd-display #__line__ ";ws error threaded -220 1 caught interrupt? ~A" *ws-finish*))
	    
	    (if (not (equal? current-threads (all-threads)))
		(snd-display #__line__ ";ws error threaded -220 1 threads: ~A, current:~A, all: ~A" current-threads (current-thread) (all-threads))))
	  
	  (let ((tag (catch #t
			    (lambda ()
			      (with-threaded-sound (:output "test.snd" :reverb jc-reverb)
						   (fm-violin 0 1 440 .1)
						   (fm-violin .1 1 660 .1)
						   (fm-violin .2 1 880 .1)
						   (fm-violin .2 1 880 .1)
						   (fm-violin .3 -1 220 .1)))
			    (lambda args args))))
	    
	    (if (or (not (list? tag))
		    (not (eq? (car tag) 'out-of-range)))
		(snd-display #__line__ ";ws-error threaded -220 2: ~A" tag))
	    (if (mus-output? *output*)
		(begin
		  (snd-display #__line__ ";ws-error threaded -220 2: *output*: ~A" *output*)
		  (mus-close *output*)
		  (set! *output* #f)))
	    (if (mus-output? *reverb*)
		(begin
		  (snd-display #__line__ ";ws-error threaded -220 2: *reverb*: ~A" *reverb*)
		  (mus-close *reverb*)
		  (set! *reverb* #f)))
	    (let ((prev (find-sound "test.snd")))
	      (if (sound? prev)
		  (begin
		    (snd-display #__line__ ";ws error threaded -220 2 opened test.snd?")
		    (close-sound prev))))
	    (if *ws-finish*
		(snd-display #__line__ ";ws error threaded -220 2 caught interrupt? ~A" *ws-finish*))
	    
	    (if (not (equal? current-threads (all-threads)))
		(snd-display #__line__ ";ws error threaded -220 2 threads: ~A, current:~A, all: ~A" current-threads (current-thread) (all-threads))))
	  ))
    
    
    ;; ---------------- catch 'mus-error (handled by with-sound, but no continuation -- appears to exit after cleaning up) ----------------      
    
    (snd-display #__line__ ";error printout expected.....")
    
    (let ((tag (catch #t
		      (lambda ()
			(with-sound (:output "test.snd")
				    (fm-violin 0 1 440 .1)
				    (fm-violin .1 1 660 .1)
				    (fm-violin .2 1 880 .1)
				    (fm-violin .3 1 220 .1 :amp-env '(0 0 1 1 .5 1 0 0))))
		      (lambda args args))))
      
      (if (or (not (string? tag))
	      (not (string=? tag "test.snd")))
	  (snd-display #__line__ ";ws-error bad env: ~A" tag))
      (if (mus-output? *output*)
	  (begin
	    (snd-display #__line__ ";ws-error bad env: *output*: ~A" *output*)
	    (mus-close *output*)
	    (set! *output* #f)))
      (let ((prev (find-sound "test.snd")))
	(if (not (sound? prev))
	    (snd-display #__line__ ";ws error bad env did not open test.snd?")
	    (close-sound prev)))
      (if *ws-finish*
	  (snd-display #__line__ ";ws error bad env caught interrupt? ~A" *ws-finish*)))
    
    (if (defined? 'all-threads)
	(let ((current-threads (all-threads)))
	  (if (not (equal? current-threads (list (current-thread))))
	      (snd-display #__line__ ";ws error threaded start 1 threads: ~A, current:~A" current-threads (current-thread)))
	  
	  (let ((tag (catch #t
			    (lambda ()
			      (with-threaded-sound (:output "test.snd")
						   (fm-violin 0 1 440 .1)
						   (fm-violin .1 1 660 .1)
						   (fm-violin .2 1 880 .1)
						   (fm-violin .3 1 220 .1 :amp-env '(0 0 1 1 .5 1 0 0))))
			    (lambda args args))))
	    
	    (if (or (not (string? tag))
		    (not (string=? tag "test.snd")))
		(snd-display #__line__ ";ws-error threaded bad env: ~A" tag))
	    (if (mus-output? *output*)
		(begin
		  (snd-display #__line__ ";ws-error threaded bad env: *output*: ~A" *output*)
		  (mus-close *output*)
		  (set! *output* #f)))
	    (let ((prev (find-sound "test.snd")))
	      (if (not (sound? prev))
		  (snd-display #__line__ ";ws error threaded bad env did not open test.snd?")
		  (close-sound prev)))
	    (if *ws-finish*
		(snd-display #__line__ ";ws error threaded bad env caught interrupt? ~A" *ws-finish*)))
	  
	  (if (not (equal? current-threads (all-threads)))
	      (snd-display #__line__ ";ws error threaded bad env threads: ~A, current:~A, all: ~A" current-threads (current-thread) (all-threads)))))
    
    
    ;; ---------------- interrupt with-sound ----------------
    
    (let ((tag (catch #t
		      (lambda ()
			(with-sound (:output "test.snd")
				    (fm-violin 0 1 440 .1)
				    (bad-ins 1)
				    (fm-violin 2 1 220 .1)))
		      (lambda args args))))
      
      (ws-quit!)
      (if (mus-output? *output*)
	  (begin
	    (snd-display #__line__ ";ws-error interrupt quit: *output*: ~A" *output*)
	    (mus-close *output*)
	    (set! *output* #f)))
      (let ((prev (find-sound "test.snd")))
	(if (not (sound? prev))
	    (snd-display #__line__ ";ws error interrupt quit did not open test.snd?")
	    (close-sound prev)))
      (if *ws-finish*
	  (snd-display #__line__ ";ws error interrupt not complete? ~A" *ws-finish*)))
    
    (let ((tag (catch #t
		      (lambda ()
			(with-threaded-sound (:output "test.snd")
					     (fm-violin 0 1 440 .1)
					     (bad-ins 1)
					     (fm-violin 2 1 220 .1)))
		      (lambda args args))))
      
      (ws-quit!)
      (if (mus-output? *output*)
	  (begin
	    (snd-display #__line__ ";ws-error threaded interrupt quit: *output*: ~A" *output*)
	    (mus-close *output*)
	    (set! *output* #f)))
      (let ((prev (find-sound "test.snd")))
	(if (not (sound? prev))
	    (snd-display #__line__ ";ws error threaded interrupt quit did not open test.snd?")
	    (close-sound prev)))
      (if *ws-finish*
	  (snd-display #__line__ ";ws error threaded interrupt not complete? ~A" *ws-finish*)))
    
    
    (snd-display #__line__ ";end error printout.")
    
    (let ((tag (with-sound (:output "test.snd" :srate 44100) (fm-violin 0 1 440 .1))))
      (if (or (not (string? tag))
	      (not (string=? tag "test.snd")))
	  (snd-display #__line__ ";ws-error all done: ~A" tag))
      (if (not (= (mus-sound-frames "test.snd") 44100))
	  (snd-display #__line__ ";ws-error all done frames: ~A" (mus-sound-frames "test.snd"))))
    
    (let ((tag (with-threaded-sound (:output "test.snd" :srate 44100) (fm-violin 0 1 440 .1))))
      (if (or (not (string? tag))
	      (not (string=? tag "test.snd")))
	  (snd-display #__line__ ";ws-error threaded all done: ~A" tag))
      (if (not (= (mus-sound-frames "test.snd") 44100))
	  (snd-display #__line__ ";ws-error threaded all done frames: ~A" (mus-sound-frames "test.snd"))))
    
    (close-sound (find-sound "test.snd"))
    (delete-file "test.snd")
    )
  
  (catch #t
	 (lambda ()
	   (vector-synthesis (let ((ctr 0) (file 0)) 
			       (lambda (files bufsize)
				 (if (> ctr 4)
				     (begin
				       (set! file (+ 1 file))
				       (set! ctr 0)
				       (if (>= file files)
					   (set! file 0)))
				     (set! ctr (+ 1 ctr)))
				 file))
			     (list "oboe.snd" "pistol.snd") #t))
	 (lambda args (display args)))
  
  (if (provided? 'snd-threads)
      (begin
	
	;; 1-chan
	(let* ((snd (open-sound "oboe.snd"))
	       (len (frames snd)))
	  (with-threaded-channels snd (lambda (snd chn) (src-channel 2.0 0 #f snd chn)))
	  (if (> (abs (- (* 2 (frames snd)) len)) 5)
	      (snd-display #__line__ ";with-threaded-sound oboe src: ~A ~A" (frames) len))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (filter-channel '(0 1 .1 0 1 0) 120 0 #f snd chn)))
	  (if (> (maxamp snd 0) .1)
	      (snd-display #__line__ ";with-threaded-channels oboe filter: ~A ~A" (maxamp snd 0) (maxamp snd 0 0)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (map-channel (lambda (y) (* y 2)) 0 #f snd chn)))
	  (if (< (maxamp snd 0) .25)
	      (snd-display #__line__ ";with-threaded-channels oboe map: ~A ~A" (maxamp snd 0) (maxamp snd 0 0)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y) (* y 2)) 0 #f snd chn)))
	  (if (< (maxamp snd 0) .25)
	      (snd-display #__line__ ";with-threaded-channels oboe ptree: ~A ~A" (maxamp snd 0) (maxamp snd 0 0)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y) (* y 2)) 0 #f snd chn #f #t)))
	  (if (< (maxamp snd 0) .25)
	      (snd-display #__line__ ";with-threaded-channels oboe ptree peak: ~A ~A" (maxamp snd 0) (maxamp snd 0 0)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y data forward) (* y (vct-ref data 0))) 0 #f snd chn #f #f (lambda (beg dur) (vct 2.0)))))
	  (if (< (maxamp snd 0) .25)
	      (snd-display #__line__ ";with-threaded-channels oboe ptree vct: ~A ~A" (maxamp snd 0) (maxamp snd 0 0)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (reverse-channel 0 #f snd chn)))
	  (if (not (= (frames snd 0) (frames snd 0 0)))
	      (snd-display #__line__ ";with-threaded-channels oboe reverse: ~A ~A" (frames snd 0) (frames snd 0 0)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (src-channel 0.5 0 #f snd chn)))
	  (if (> (abs (- (* .5 (frames snd)) len)) 5)
	      (snd-display #__line__ ";with-threaded-sound oboe src 5: ~A ~A" (frames) len))
	  (revert-sound snd)
	  (close-sound snd))
	
	;; 4-chans
	(let* ((snd (open-sound "4.aiff"))
	       (len (frames snd)))
	  (with-threaded-channels snd (lambda (snd chn) (src-channel 2.0 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (> (abs (- (* 2 (frames snd i)) len)) 5)
		(snd-display #__line__ ";with-threaded-sound 4 src ~D: ~A ~A" i (frames) len)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (filter-channel '(0 1 .1 0 1 0) 120 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (> (maxamp snd 0) .1)
		(snd-display #__line__ ";with-threaded-channels 4.aiff filter ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (map-channel (lambda (y) (* y 2)) 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 4.aiff map~D : ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y) (* y 2)) 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 4.aiff ptree ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y) (* y 2)) 0 #f snd chn #f #t)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 4.aiff ptree peak ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y data forward) (* y (vct-ref data 0))) 0 #f snd chn #f #f (lambda (beg dur) (vct 2.0)))))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 4.aiff ptree vct ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (reverse-channel 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (not (= (frames snd 0) (frames snd 0 0)))
		(snd-display #__line__ ";with-threaded-channels 4.aiff reverse ~D: ~A ~A" i (frames snd 0) (frames snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (src-channel 0.5 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 4))
	    (if (> (abs (- (* .5 (frames snd)) len)) 5)
		(snd-display #__line__ ";with-threaded-sound 4.aiff src 5 ~D: ~A ~A" i (frames) len)))
	  (revert-sound snd)
	  (close-sound snd))
	
	;; 8-chans
	(let* ((snd (find-sound (with-sound (:channels 8)
					    (do ((i 0 (+ 1 i)))
						((= i 8))
					      (fm-violin 0 1 (* (+ 1 i) 100.0) .3 :degree (* i (/ 360 8)))))))
	       (len (frames snd)))
	  (with-threaded-channels snd (lambda (snd chn) (src-channel 2.0 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (> (abs (- (* 2 (frames snd i)) len)) 5)
		(snd-display #__line__ ";with-threaded-sound 4 src ~D: ~A ~A" i (frames) len)))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (filter-channel '(0 1 .1 0 1 0) 120 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (or (> (maxamp snd 0) .35) ; the other two cases involve higher sounds
		    (< (maxamp snd 0) .25))
		(snd-display #__line__ ";with-threaded-channels 8 chan filter ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (map-channel (lambda (y) (* y 2)) 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 8 chan map ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y) (* y 2)) 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 8 chan ptree ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y) (* y 2)) 0 #f snd chn #f #t)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 8 chan ptree peak ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (ptree-channel (lambda (y data forward) (* y (vct-ref data 0))) 0 #f snd chn #f #f (lambda (beg dur) (vct 2.0)))))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (< (maxamp snd 0) .25)
		(snd-display #__line__ ";with-threaded-channels 8 chan ptree vct ~D: ~A ~A" i (maxamp snd 0) (maxamp snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (reverse-channel 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (not (= (frames snd 0) (frames snd 0 0)))
		(snd-display #__line__ ";with-threaded-channels 8 chan reverse ~D: ~A ~A" i (frames snd 0) (frames snd 0 0))))
	  (revert-sound snd)
	  (with-threaded-channels snd (lambda (snd chn) (src-channel 0.5 0 #f snd chn)))
	  (do ((i 0 (+ i 1))) 
	      ((= i 8))
	    (if (> (abs (- (* .5 (frames snd)) len)) 5)
		(snd-display #__line__ ";with-threaded-sound 8 chan src 5 ~D: ~A ~A" i (frames) len)))
	  (revert-sound snd)
	  (close-sound snd))
	))
  
  (set! (optimization) max-optimization)
  (dismiss-all-dialogs)
  
  (do ((clmtest 0 (+ 1 clmtest))) ((= clmtest tests)) 
    (log-mem clmtest)
    
    (set! (mus-srate) 22050)
    (set! (default-output-srate) 22050)
    
    ;; check clm output for bad zero case
    (for-each
     (lambda (type)
       (let ((ind (find-sound 
		   (with-sound (:data-format type)
			       (fm-violin 0 .1 440 .1)
			       (fm-violin 10 .1 440 .1)
			       (fm-violin 100 .1 440 .1)
			       (fm-violin 1000 .1 440 .1)))))
	 (let ((mx (maxamp ind)))
	   (if (ffneq mx .1) ; mus-byte -> 0.093
	       (snd-display #__line__ ";max: ~A, format: ~A" mx (mus-data-format->string type))))))
     (list mus-bshort   mus-lshort   mus-mulaw   mus-alaw   mus-byte  
	   mus-lfloat   mus-bint     mus-lint    mus-b24int mus-l24int
	   mus-ubshort  mus-ulshort  mus-ubyte   mus-bfloat mus-bdouble 
	   mus-ldouble))
    
    (let ((old-opt (optimization)))
      (do ((opt 0 (+ 1 opt)))
	  ((> opt max-optimization))
	(set! (optimization) opt)
	(with-sound (:srate 22050) (fm-violin 0 .1 (* 110 (+ 1 opt)) .1))
	(let ((ind (find-sound "test.snd")))
	  (if (not ind) (snd-display #__line__ ";with-sound: ~A" (map file-name (sounds))))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1) (snd-display #__line__ ";with-sound max: ~A" (maxamp)))
	    (if (not (= (srate ind) 22050)) (snd-display #__line__ ";with-sound srate: ~A (~A, ~A)" 
							 (srate ind) (mus-srate) (mus-sound-srate "test.snd")))
	    (if (not (= (frames ind) 2205)) (snd-display #__line__ ";with-sound frames: ~A" (frames ind))))
	  (play ind :wait #t)))
      (set! (optimization) old-opt))
    
    (with-sound (:continue-old-file #t) (fm-violin .2 .1 440 .25))
    (let ((ind (find-sound "test.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound continued: ~A" (map file-name (sounds))))
      (if (not (= (length (sounds)) 1)) (snd-display #__line__ ";with-sound continued: ~{~A ~}" (map short-file-name (sounds))))
      (let ((mx (maxamp)))
	(if (fneq mx .25) (snd-display #__line__ ";with-sound continued max: ~A" (maxamp)))
	(if (not (= (srate ind) 22050)) (snd-display #__line__ ";with-sound continued srate: ~A (~A, ~A)" 
						     (srate ind) (mus-srate) (mus-sound-srate "test.snd")))
	(if (not (= (frames ind) (* 3 2205))) (snd-display #__line__ ";with-sound continued frames: ~A (~A)" (frames ind) (srate ind))))
      (close-sound ind))
    
    (with-sound () (fm-violin 0 .1 440 .1))
    (with-sound (:continue-old-file #t) (fm-violin .2 .1 660 .04))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp ind 0) .1) (snd-display #__line__ ";maxamp after continued sound: ~A" (maxamp ind 0)))
      (if (fneq (/ (frames ind) (srate ind)) .3) (snd-display #__line__ ";duration after continued sound: ~A" (/ (frames ind) (srate ind))))
      (close-sound ind))
    
    (with-sound (:srate 22050 :channels 2 :output "test1.snd") (fm-violin 0 .1 440 .1 :degree 45.0))
    (let ((ind (find-sound "test1.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound (1): ~A" (map file-name (sounds))))
      (let ((mx (maxamp)))
	(if (fneq mx .05) (snd-display #__line__ ";with-sound max (1): ~A" (maxamp)))
	(if (or (not (= (srate ind) 22050)) 
		(not (= (mus-sound-srate "test1.snd") 22050))) 
	    (snd-display #__line__ ";with-sound srate (1): ~A (~A, ~A)" (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
	(if (not (= (frames ind) 2205)) (snd-display #__line__ ";with-sound frames (1): ~A" (frames ind)))
	(if (or (not (= (chans ind) 2))
		(not (= (mus-sound-chans "test1.snd") 2)))
	    (snd-display #__line__ ";with-sound chans (1): ~A" (chans ind))))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 48000 :channels 2 :header-type mus-riff :data-format mus-lshort :output "test1.snd") (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test1.snd")))
      (if (or (not (= (srate ind) 48000))
	      (not (= (mus-sound-srate "test1.snd") 48000)))
	  (snd-display #__line__ ";with-sound srate (48000, r): ~A (~A, ~A)" (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
      (if (not (= (header-type ind) mus-riff)) (snd-display #__line__ ";with-sound type (~A, r): ~A" mus-riff (header-type ind)))
      (if (not (= (chans ind) 2)) (snd-display #__line__ ";with-sound chans (2, r): ~A" (chans ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 48000 :channels 2 :header-type mus-rf64 :data-format mus-lshort :output "test1.snd") (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test1.snd")))
      (if (or (not (= (srate ind) 48000))
	      (not (= (mus-sound-srate "test1.snd") 48000)))
	  (snd-display #__line__ ";with-sound srate (48000, r): ~A (~A, ~A)" (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
      (if (not (= (header-type ind) mus-rf64)) (snd-display #__line__ ";with-sound type (~A, r): ~A" mus-rf64 (header-type ind)))
      (if (not (= (chans ind) 2)) (snd-display #__line__ ";with-sound chans (2, r): ~A" (chans ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 48000 :channels 2 :header-type mus-caff :data-format mus-lshort :output "test1.snd") (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test1.snd")))
      (if (or (not (= (srate ind) 48000))
	      (not (= (mus-sound-srate "test1.snd") 48000)))
	  (snd-display #__line__ ";with-sound mus-caff srate (48000, r): ~A (~A, ~A)" (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
      (if (not (= (header-type ind) mus-caff)) (snd-display #__line__ ";with-sound type (~A, r): ~A" mus-caff (header-type ind)))
      (if (not (= (chans ind) 2)) (snd-display #__line__ ";with-sound mus-caff chans (2, r): ~A" (chans ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 8000 :channels 3 :header-type mus-next :output "test1.snd") (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test1.snd")))
      (if (not (= (srate ind) 8000)) (snd-display #__line__ ";with-sound srate (8000, s): ~A (~A, ~A)" 
						  (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
      (if (not (= (header-type ind) mus-next)) (snd-display #__line__ ";with-sound type (~A, s): ~A" mus-next (header-type ind)))
      (if (not (= (chans ind) 3)) (snd-display #__line__ ";with-sound chans (3, s): ~A" (chans ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 96000 :channels 4 :header-type mus-aifc :output "test1.snd") (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test1.snd")))
      (if (not (= (srate ind) 96000)) (snd-display #__line__ ";with-sound srate (96000, t): ~A (~A, ~A)" 
						   (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
      (if (not (= (header-type ind) mus-aifc)) (snd-display #__line__ ";with-sound type (~A, t): ~A" mus-aifc (header-type ind)))
      (if (not (= (chans ind) 4)) (snd-display #__line__ ";with-sound chans (4, t): ~A" (chans ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 22050 :channels 1 :header-type mus-raw :output "test1.snd") (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test1.snd")))
      (if (not (= (srate ind) 22050)) (snd-display #__line__ ";with-sound srate (22050, u): ~A (~A, ~A)" 
						   (srate ind) (mus-srate) (mus-sound-srate "test1.snd")))
      (if (not (= (header-type ind) mus-raw)) (snd-display #__line__ ";with-sound type (~A, u): ~A" mus-raw (header-type ind)))
      (if (not (= (chans ind) 1)) (snd-display #__line__ ";with-sound chans (1, u): ~A" (chans ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 22050 :channels 2 :output "test1.snd" :reverb jc-reverb) 
		(if (not (= (mus-sound-srate (mus-file-name *output*)) 22050))
		    (snd-display #__line__ ";srate file *output*: ~A" (mus-sound-srate (mus-file-name *output*))))
		(if (not (= (mus-sound-srate (mus-file-name *reverb*)) 22050))
		    (snd-display #__line__ ";srate file *reverb*: ~A" (mus-sound-srate (mus-file-name *reverb*))))
		(fm-violin 0 .1 440 .1 :degree 45.0))
    (let ((ind (find-sound "test1.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound (2): ~A" (map file-name (sounds))))
      (if (not (= (frames ind) (+ 22050 2205))) (snd-display #__line__ ";with-sound reverbed frames (2): ~A" (frames ind)))
      (close-sound ind))
    
    (let ((old-opt (optimization)))
      (do ((opt 0 (+ 1 opt)))
	  ((> opt max-optimization))
	(set! (optimization) opt)
	(with-sound (:srate 22050 :output "test1.snd" :reverb jc-reverb) (fm-violin 0 .1 440 .1))
	(set! (optimization) old-opt)))
    
    (let ((ind (find-sound "test1.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound (3): ~A" (map file-name (sounds))))
      (if (not (= (frames ind) (+ 22050 2205))) (snd-display #__line__ ";with-sound reverbed frames (3): ~A" (frames ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:srate 22050 :comment "Snd+Run!" :scaled-to .5) (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound: ~A" (map file-name (sounds))))
      (let ((mx (maxamp)))
	(if (fneq mx .5) (snd-display #__line__ ";with-sound scaled-to: ~A" (maxamp)))
	(if (not (string=? (comment ind) "Snd+Run!")) (snd-display #__line__ ";with-sound comment: ~A (~A)" (comment ind) (mus-sound-comment "test.snd"))))
      (close-sound ind))
    
    (with-sound (:srate 22050 :scaled-by .5 :header-type mus-aifc :data-format mus-bfloat) (fm-violin 0 .1 440 .1))
    (let ((ind (find-sound "test.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound: ~A" (map file-name (sounds))))
      (let ((mx (maxamp)))
	(if (fneq mx .05) (snd-display #__line__ ";with-sound scaled-by: ~A" (maxamp)))
	(if (not (= (header-type ind) mus-aifc)) (snd-display #__line__ ";with-sound type: ~A (~A)" (header-type ind) (mus-header-type-name (header-type ind))))
	(if (not (= (data-format ind) mus-bfloat)) (snd-display #__line__ ";with-sound format: ~A (~A)" (data-format ind) (mus-data-format-name (data-format ind)))))
      (close-sound ind))
    
    (add-hook! open-raw-sound-hook (lambda (file choice) (list 1 22050 mus-bshort)))      
    (with-sound (:header-type mus-raw) (fm-violin 0 1 440 .1))
    (reset-hook! open-raw-sound-hook)
    (let ((ind (find-sound "test.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound (raw out): ~A" (map file-name (sounds))))
      (if (not (= (header-type ind) mus-raw)) 
	  (snd-display #__line__ ";with-sound type raw: ~A (~A)" (header-type ind) (mus-header-type-name (header-type ind))))
      (if (and (not (= (data-format ind) mus-bshort)) 
	       (not (= (data-format ind) mus-bfloat))
	       (not (= (data-format ind) mus-lfloat)))
	  (snd-display #__line__ ";with-sound format raw: ~A (~A)" (data-format ind) (mus-data-format-name (data-format ind))))
      (close-sound ind))
    
    (with-sound (:srate 44100 :statistics #t) (ws-sine 1000))
    (let ((ind (find-sound "test.snd")))
      (let ((i -1))
	(scan-channel (lambda (y)
			(set! i (+ 1 i))
			(if (fneq y (sin (* 2 pi i (/ 1000.0 44100.0))))
			    (begin
			      (display (format #f "~%;with-sound sine: ~D ~A ~A" i y (sin (* 2 pi i (/ 1000.0 44100.0)))))
			      #t)
			    #f))))
      (close-sound ind))
    
    (set! *opt* #t)
    (with-sound ()
		(run
		 (do ((i 0 (+ i 1)))
		     ((= i 3))
		   (let ((gen (make-oscil 440.0))
			 (e (make-env (vct 0.0 0.0 1.0 1.0 2.0 0.0) 0.1 1.0)))
		     (do ((k 0 (+ k 1)))
			 ((= k 44100))
		       (outa (+ k (* i 50000)) (* (env e) (oscil gen))))))))
    (if (not *opt*)
	(snd-display #__line__ ";with-sound make-oscil in run loop optimization failed?"))
    (let ((ind (find-sound "test.snd")))
      (if (not (= (frames ind) 144100))
	  (snd-display #__line__ ";with-sound make-oscil in run frames: ~A" (frames)))
      (if (fneq (maxamp ind) .1)
	  (snd-display #__line__ ";with-sound make-oscil in run maxamp: ~A" (maxamp ind)))
      (close-sound ind))
    
    
    (if (file-exists? "ii.scm")
	(begin
	  (time (load "ii.scm"))
	  (for-each close-sound (sounds))
	  (delete-file "test.snd")
	  (delete-file "test.rev")))
    
    (let ((var (make-st1 :one 1 :two 2)))
      (if (not (= (st1-one var) 1)) (snd-display #__line__ ";st1-one: ~A" (st1-one var)))
      (if (not (= (st1-two var) 2)) (snd-display #__line__ ";st1-two: ~A" (st1-two var)))
      (if (not (st1? var)) (snd-display #__line__ ";st1? ~A (~A)" (st1? var) var))
      (set! (st1-one var) 321)
      (set! (st1-two var) "hiho")
      (if (not (= (st1-one var) 321)) (snd-display #__line__ ";st1-one (321): ~A" (st1-one var)))
      (if (not (string=? (st1-two var) "hiho")) (snd-display #__line__ ";st1-two (hiho): ~A" (st1-two var)))
      (set! var (make-st1))
      (if (fneq (st1-one var) 0.0) (snd-display #__line__ ";st1-one #f: ~A" (st1-one var)))
      (if (fneq (st1-two var) 0.0) (snd-display #__line__ ";st1-two #f: ~A" (st1-two var)))
      (set! var (make-st1 :two 3))
      (if (fneq (st1-one var) 0.0) (snd-display #__line__ ";st1-one #f (def): ~A" (st1-one var)))  
      (if (not (= (st1-two var) 3)) (snd-display #__line__ ";st1-two (3): ~A" (st1-two var))))
    
    (let ((var (make-st2 :one 1 :two 2)))
      (if (not (= (st2-one var) 1)) (snd-display #__line__ ";st2-one: ~A" (st2-one var)))
      (if (not (= (st2-two var) 2)) (snd-display #__line__ ";st2-two: ~A" (st2-two var)))
      (if (not (st2? var)) (snd-display #__line__ ";st2? ~A (~A)" (st1? var) var))
      (if (st1? var) (snd-display #__line__ ";st1? (not ~A): ~A" (st1? var) var))
      (set! (st2-one var) 321)
      (set! (st2-two var) "hiho")
      (if (not (= (st2-one var) 321)) (snd-display #__line__ ";st2-one (321): ~A" (st2-one var)))
      (if (not (string=? (st2-two var) "hiho")) (snd-display #__line__ ";st2-two (hiho): ~A" (st2-two var)))
      (set! var (make-st2))
      (if (not (= (st2-one var) 11)) (snd-display #__line__ ";st2-one 11: ~A" (st2-one var)))
      (if (not (= (st2-two var) 22)) (snd-display #__line__ ";st2-two 22: ~A" (st2-two var)))
      (set! var (make-st2 :two 3))
      (if (not (= (st2-one var) 11)) (snd-display #__line__ ";st2-one 11 (def): ~A" (st2-one var)))  
      (if (not (= (st2-two var) 3)) (snd-display #__line__ ";st2-two (3): ~A" (st2-two var))))
    
    (let ((gad (make-grab-bag)))
      (if (not (= (grab-bag-i gad) 0))
	  (snd-display #__line__ ";grab-bag-i: ~A" (grab-bag-i gad)))
      (set! (grab-bag-flt gad) 123.0)
      (set! (grab-bag-v gad) (vct .1 .2 .3))
      (set! (grab-bag-fvect gad) (vector .1 .2 .3))
      (set! (grab-bag-ivect gad) (make-vector 3 1))
      (set! (grab-bag-cvect gad) (make-vector 3 #f))
      (do ((i 0 (+ 1 i)))
	  ((= i 3))
	(vector-set! (grab-bag-cvect gad) i (make-oscil 440.0)))
      (set! (grab-bag-gen gad) (make-oscil 440.0))
      (let ((val 0.0))
	(run
	 (lambda ()
	   (set! val (grab-bag-flt gad))))
	(if (fneq val 123.0) (snd-display #__line__ ";def-clm-struct flt: ~A ~A" val (grab-bag-flt gad))))
      (if (fneq (grab-bag-flt1 gad) 1.0) (snd-display #__line__ ";def-clm-struct flt1: ~A" (grab-bag-flt1 gad)))
      (if (not (= (grab-bag-i gad) 0)) (snd-display #__line__ ";def-clm-struct i: ~A" (grab-bag-i gad)))
      (if (not (= (grab-bag-i1 gad) 123)) (snd-display #__line__ ";def-clm-struct i1: ~A" (grab-bag-i1 gad))))
    
    (if (file-exists? "test.snd") (delete-file "test.snd"))
    (set! (mus-srate) 22050)
    (set! *clm-srate* 22050)
    (set! (default-output-srate) 22050)
    (let ((outer (with-sound () 
			     (sound-let ((a () (fm-violin 0 .1 440 .1))) 
					(mus-mix *output* a)))))
      (if (not (string=? outer "test.snd"))
	  (snd-display #__line__ ";with-sound returns: ~A" outer))
      (let ((ind (find-sound outer)))
	(if (or (not (sound? ind))
		(not (= (frames ind) (floor (* (mus-srate) .1)))))
	    (snd-display #__line__ ";sound-let: ~A ~A" (frames ind) (floor (* (mus-srate) .1))))
	(close-sound ind)))
    
    (if (file-exists? "test.snd") (delete-file "test.snd"))
    (let ((outer (with-sound () 
			     (sound-let ((a () (fm-violin 0 .1 440 .1))
					 (b 100))
					(mus-mix *output* a b)
					(sound-let ((c (:channels 1 :output "temp.snd") (fm-violin 0 .1 110.0 .1)))
						   (mus-mix *output* c))))))
      (if (not (string=? outer "test.snd"))
	  (snd-display #__line__ ";with-sound (2) returns: ~A" outer))
      (let ((ind (find-sound outer)))
	(if (or (not (sound? ind))
		(not (= (frames ind) (+ 100 (floor (* (mus-srate) .1))))))
	    (snd-display #__line__ ";sound-let (2): ~A ~A" (frames ind) (+ 100 (floor (* (mus-srate) .1)))))
	(if (file-exists? "temp.snd")
	    (snd-display #__line__ ";sound-let explicit output exists?"))
	(close-sound ind)))
    
    (let ((w (init-with-sound)))
      (fm-violin 0 1 440 .1)
      (let ((outer (finish-with-sound w)))
	(if (not (string=? outer "test.snd"))
	    (snd-display #__line__ ";finish-with-sound returns: ~A" outer))
	(let ((ind (find-sound outer)))
	  (if (not (sound? ind))
	      (snd-display #__line__ ";init-with-sound: ~A" (map short-file-name (sounds)))
	      (begin
		(if (fneq (maxamp ind 0) .1)
		    (snd-display #__line__ ";init-with-sound max: ~A" (maxamp ind 0)))
		(close-sound ind))))))
    
    (let ((w (init-with-sound :output "test.aiff" :header-type mus-aifc :scaled-to .5)))
      (fm-violin 0 1 440 .1)
      (let ((outer (finish-with-sound w)))
	(if (not (string=? outer "test.aiff"))
	    (snd-display #__line__ ";finish-with-sound (2) returns: ~A ~A" outer w))
	(let ((ind (find-sound outer)))
	  (if (not (sound? ind))
	      (snd-display #__line__ ";init-with-sound (2): ~A" (map short-file-name (sounds)))
	      (begin
		(if (fneq (maxamp ind 0) .5)
		    (snd-display #__line__ ";init-with-sound scaled-to: ~A ~A" (maxamp ind 0) w))
		(if (not (= (header-type ind) mus-aifc))
		    (snd-display #__line__ ";init-with-sound type: ~A ~A" (header-type ind) w))
		(close-sound ind))))))
    
    (with-sound (:output "test1.snd" :reverb freeverb :reverb-data '(:output-gain 3.0)) (fm-violin 0 .1 440 .1 :reverb-amount .1))
    (let ((ind (find-sound "test1.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound (freeverb): ~A" (map file-name (sounds))))
      (if (not (> (maxamp ind) .1)) (snd-display #__line__ ";freeverb 3.0: ~A" (maxamp ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (with-sound (:output "test1.snd" :reverb freeverb :reverb-data '(:output-gain 3.0 :global 0.5)) (fm-violin 0 .1 440 .1 :reverb-amount .1))
    (let ((ind (find-sound "test1.snd")))
      (if (not ind) (snd-display #__line__ ";with-sound (freeverb): ~A" (map file-name (sounds))))
      (if (not (> (maxamp ind) .16)) (snd-display #__line__ ";freeverb 3.0 global 0.5: ~A" (maxamp ind)))
      (close-sound ind)
      (delete-file "test1.snd"))
    
    (set! (mus-srate) 22050)
    (set! (default-output-srate) 22050)
    
    (let ((fmt1 '(0 1200 100 1000))
	  (fmt2 '(0 2250 100 1800))
	  (fmt3 '(0 4500 100 4500))
	  (fmt4 '(0 6750 100 8100))
	  (amp1 '(0 .67 100 .7))
	  (amp2 '(0 .95 100 .95))
	  (amp3 '(0 .28 100 .33))
	  (amp4 '(0 .14 100 .15))
	  (ind1 '(0 .75 100 .65))
	  (ind2 '(0 .75 100 .75))
	  (ind3 '(0 1 100 1))
	  (ind4 '(0 1 100 1))
	  (skwf '(0 0 100 0))
	  (ampf '(0 0 25 1 75 1 100 0))
	  (ranf '(0 .5 100 .5))
	  (index '(0 1 100 1))
	  (zero_fun '(0 0 100 0))
	  (atskew '(0 -1 15 .3 22 -.1 25 0 75 0 100 -.2))
	  (vibfun '(0 0 .3 .3 15 .6 25 1 100 1))
	  (slopefun '(0 1 75 1 100 0))
	  (trap '(0 0 25 1 75 1 100 0))
	  (ramp '(0 0 25 0 75 1 100 1))
	  (solid '(0 0 5 1 95 1 100 0))
	  (sfz '(0 0 25 1 30 .6 50 .5 75 .2 100 0))
	  (mound '(0 0 10 .4 25 .8 40 1 60 1 75 .8 90 .4 100 0))
	  (vio '(0 0 7 .2 25 .5 40 .6 60 .6 75 .5 90 .2 100 0))
	  (bassdr2 '(.5 .06 1 .62 1.5 .07 2.0 .6 2.5 .08 3.0 .56 4.0 .24 
			5 .98 6 .53 7 .16 8 .33 9 .62 10 .12 12 .14 14 .86
			16 .12 23 .14 24 .17))
	  (bassdrstr '(.5 .06 1.0 .63 1.5 .07 2.01 .6 2.5 .08 3.02 .56
			  4.04 .24 5.05 .98 6.06 .53 7.07 .16 8.08 .33 9.09 .62
			  10.1 .12 12.12 .14 13.13 .37 14.14 .86 16.16 .12 23.23 .14 24.24 .17))
	  (tenordr '(.3 .04 1 .81 2 .27 3 .2 4 .21 5 .18 6 .35 7 .03 8 .07 9 .02 10 .025 11 .035))
	  (tenordrstr '(.3 .04 1.03 .81 2.03 .27 3.03 .20 4.03 .21 5.03 .18
			   6.03 .35 7.03 .03 8.03 .07 9.03 .02 10.03 .03 11.03 .04)))
      (with-sound (:reverb nrev)
		  (drone  .000  4.000  115.000  (* .25 .500) solid bassdr2  .100  .500
			  .030  45.000 1  .010 10)
		  (drone  .000  4.000  229.000  (* .25 .500) solid tenordr  .100  .500
			  .030  45.000 1  .010 11)
		  (drone  .000  4.000  229.500  (* .25 .500) solid tenordr  .100  .500
			  .030  45.000 1  .010 9)
		  (canter  .000  2.100 918  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  2.100  .300 688.5  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  2.400  .040 826.2  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  2.440  .560 459  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.000  .040 408  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.040  .040 619.65  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.080  .040 408  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.120  .040 688.5  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.160  .290 459  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.450  .150 516.375  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.600  .040 826.2  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.640  .040 573.75  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.680  .040 619.65  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.720  .180 573.75  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.900  .040 688.5  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )
		  (canter  3.940  .260 459  (* .25 .700)  45.000 1  .050 ampf ranf skwf
			   .050  .010 10 index  .005  .005 amp1 ind1 fmt1 amp2
			   ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4  )))
    
    (let ((ind (find-sound "test.snd")))
      (play ind :wait #t)
      (close-sound ind))
    
    (with-sound (:srate 22050) 
		(fm-violin 0 .01 440 .1 :noise-amount 0.0)
		(pluck 0.05 .01 330 .1 .95 .95)
		(maraca .1 .1)
		(big-maraca .2 .5 .25 0.95 0.9985 .03125 '(2300 5600 8100) '(0.96 0.995 0.995) .01)
		(fm-bell 0.3 1.0 220.0 .5 
			 '(0 0 .1000 1 10 .6000 25 .3000 50 .1500 90 .1000 100 0 )
			 '(0 1 2 1.1000 25 .7500 75 .5000 100 .2000 )
			 1.0)
		(singer .4 .1 (list (list .4 ehh.shp test.glt 523.0 .8 0.0 .01) (list .6 oo.shp test.glt 523.0 .7 .1 .01)))
		(stereo-flute .6 .2 440 .55 :flow-envelope '(0 0 1 1 2 1 3 0))
		(fofins 1 .3 270 .4 .001 730 .6 1090 .3 2440 .1)
		(bow 1.2 .3 400 0.5 :vb 0.15 :fb 0.1 :inharm 0.25)
		(pqw-vox 1.5 1 300 300 .1 '(0 0 50 1 100 0) '(0 0 100 0) 0 '(0 L 100 L) '(.33 .33 .33) '((1 1 2 .5) (1 .5 2 .5 3 1) (1 1 4 .5)))
		(fm-noise 2 0.5 500 0.25 '(0 0 25 1 75 1 100 0) 0.1 0.1  1000 '(0 0 100 1) 0.1 0.1 10 1000 '(0 0 100 1) 0 0  100 500 '(0 0 100 1) 0 0)
		(bes-fm 2.5 .5 440 5.0 1.0 8.0)
		(chain-dsps 3 0.5 '(0 0 1 .1 2 0) (make-oscil 440))
		(chain-dsps 3.5 1.0 '(0 0 1 1 2 0) (make-one-zero .5) (make-readin "oboe.snd"))
		(vox 4 2 170 .4 '(0 0 25 1 75 1 100 0) '(0 0 5 .5 10 0 100 1) .1 '(0 E 25 AE 35 ER 65 ER 75 I 100 UH) 
		     '(.8 .15 .05) '(.005 .0125 .025) .05 .1)
		(p 5.0 :duration .5 :keyNum 36 :strike-velocity .5 :amp .4 :DryPedalResonanceFactor .25)
					;(bobwhite 5.5)
		(scissor 2.0) 
		(plucky 3.25 .3 440 .2 1.0)
		(bowstr 3.75 .3 220 .2 1.0)
		(brass 4.2 .3 440 .2 1.0)
		(clarinet 5.75 .3 440 .2 1.0)
		(flute 6 .3 440 .2 1.0)
		(fm-trumpet 6.5 .25)
		(touch-tone 6.75 '(7 2 3 4 9 7 1))
		(pins 7.0 1.0 "now.snd" 1.0 :time-scaler 2.0)
		
		(let ((locust '(0 0 40 1 95 1 100 .5))
		      (bug_hi '(0 1 25 .7 75 .78 100 1))
		      (amp    '(0 0 25 1 75 .7 100 0)))
		  (fm-insect 7      1.699  4142.627  .015 amp 60 -16.707 locust 500.866 bug_hi  .346  .500)
		  (fm-insect 7.195   .233  4126.284  .030 amp 60 -12.142 locust 649.490 bug_hi  .407  .500)
		  (fm-insect 7.217  2.057  3930.258  .045 amp 60 -3.011  locust 562.087 bug_hi  .591  .500)
		  (fm-insect 9.100  1.500   900.627  .06  amp 40 -16.707 locust 300.866 bug_hi  .346  .500)
		  (fm-insect 10.000  1.500   900.627  .06  amp 40 -16.707 locust 300.866 bug_hi  .046  .500)
		  (fm-insect 10.450  1.500   900.627  .09  amp 40 -16.707 locust 300.866 bug_hi  .006  .500)
		  (fm-insect 10.950  1.500   900.627  .12  amp 40 -10.707 locust 300.866 bug_hi  .346  .500)
		  (fm-insect 11.300  1.500   900.627  .09  amp 40 -20.707 locust 300.866 bug_hi  .246  .500))
		
		(fm-drum 7.5 1.5 55 .3 5 #f)
		(fm-drum 8 1.5 66 .3 4 #t)
		(gong 9 3 261.61 .6)
		(attract 10 .25 .5 2.0)
		(pqw 11 .5 200 1000 .2 '(0 0 25 1 100 0) '(0 1 100 0) '(2 .1 3 .3 6 .5))
		
		(zn 10 1 100 .1 20 100 .995) 
		(zn 11.5 1 100 .1 100 20 .995)
		(zc 11 1 100 .1 20 100 .95) 
		(zc 12.5 1 100 .1 100 20 .95)
		(za 13 1 100 .1 20 100 .95 .95) 
		(za 14.5 1 100 .1 100 20 .95 .95)
		
		(tubebell 12 2 440 .2)
		(wurley 12.5 .25 440 .2)
		(rhodey 12.75 .25 440 .2)
		(hammondoid 13 .25 440 .2)
		(metal 13.5 .25 440 .2)
		(reson 14.0 1.0 440 .1 2 '(0 0 100 1) '(0 0 100 1) .1 .1 .1 5 .01 5 .01 0 1.0 0.01
		       '(((0 0 100 1) 1200 .5 .1 .1 0 1.0 .1 .1)
			 ((0 1 100 0) 2400 .5 .1 .1 0 1.0 .1 .1)))
		(cellon 14.5 1 220 .1 
			'(0 0 25 1 75 1 100 0) 
			'(0 0 25 1 75 1 100 0) .75 1.0 0 0 0 0 1 0 0 220 
			'(0 0 25 1 75 1 100 0) 0 0 0 0 
			'(0 0 100 0) 0 0 0 0 '(0 0 100 0))
		(clm-expsrc 14.75 4 "oboe.snd" 2.0 1.0 1.0)
		(scratch 15.0 "now.snd" 1.5 '(0.0 .5 .25 1.0))
		(two-tab 15 1 440 .1)
		(exp-snd "fyow.snd" 15 3 1 '(0 1 1 3) 0.4 .15 '(0 2 1 .5) 0.05)
		(exp-snd "oboe.snd" 16 3 1 '(0 1 1 3) 0.4 .15 '(0 2 1 .5) 0.2)
		(gran-synth 15.5 1 300 .0189 .03 .4)
		(spectra 16 1 440.0 .1 '(1.0 .4 2.0 .2 3.0 .2 4.0 .1 6.0 .1) '(0.0 0.0 1.0 1.0 5.0 0.9 12.0 0.5 25.0 0.25 100.0 0.0))
		(lbj-piano 16.5 1 440.0 .2)
		(resflt 17 1.0 0 0 0 #f .1 200 230 10 '(0 0 50 1 100 0) '(0 0 100 1) 500 .995 .1 1000 .995 .1 2000 .995 .1)
		(resflt 17.5 1.0 1 10000 .01 '(0 0 50 1 100 0) 0 0 0 0 #f #f 500 .995 .1 1000 .995 .1 2000 .995 .1)
		(bes-fm 18 1 440 10.0 1.0 4.0)
		
		(green3 19 2.0 440 .5 '(0 0 1 1 2 1 3 0) 100 .2 .02)
		(green4 21 2.0 440 .5 '(0 0 1 1 2 1 3 0) 440 100 100 10)
		
		(fir+comb 20 2 10000 .001 200)
		(fir+comb 22 2 1000 .0005 400)
		(fir+comb 24 2 3000 .001 300)
		(fir+comb 26 2 3000 .0005 1000)
		
		(sndwarp 28 1.0 "pistol.snd")
		(expandn 29 .5 "oboe.snd" .2)
		(let ((ampf '(0 0 1 1 2 1 3 0))) 
		  (fm-voice 0 1 300 .8 3 1 ampf ampf ampf ampf ampf ampf ampf 1 0 0 .25 1 .01 0 ampf .01))
		(graphEq "oboe.snd")
		)
    (let ((ind (find-sound "test.snd")))
      (play ind :wait #t)
      (close-sound ind))
    
    (with-sound (:play #f) (defopt-simp 0 10000) (defopt-simp 10000 10000 550.0 0.1) (defopt-simp 20000 10000 :amplitude .2))
    (with-sound (:channels 2 :reverb-channels 2 :reverb jcrev2 :play #f) (floc-simp 0 1))
    
    
    (with-sound (:channels 2 :statistics #t)
		(fullmix "pistol.snd")
		(fullmix "oboe.snd" 1 2 0 (list (list .1 (make-env '(0 0 1 1) :duration 2 :scaler .5)))))
    (let ((ind (find-sound "test.snd")))
      (if (sound? ind) (close-sound ind)))
    
    (with-sound (:channels 2) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (1.0 0.0) (0.0 1.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.664947509765625) (snd-display #__line__ ";4->2(0) fullmix: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:channels 1) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((1.0) (0.0) (0.0) (0.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.221649169921875) (snd-display #__line__ ";4->1(0) fullmix: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:channels 1) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0) (1.0) (0.0) (0.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.44329833984375) (snd-display #__line__ ";4->1(1) fullmix: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:channels 1) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0) (0.0) (1.0) (0.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.664947509765625) (snd-display #__line__ ";4->1(2) fullmix: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:channels 1) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0) (0.0) (0.0) (1.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.8865966796875) (snd-display #__line__ ";4->1(3) fullmix: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:channels 2) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (1.0 0.0) (0.0 1.0))))
    (let* ((ind (find-sound "test.snd"))
	   (mxs (maxamp ind #t)))
      (if (or (fneq (car mxs) 0.664947509765625)
	      (fneq (cadr mxs) 0.8865966796875))
	  (snd-display #__line__ ";4->2(1) fullmix: ~A" mxs))
      (close-sound ind))
    
    (with-sound (:channels 2) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (0.0 1.0) (1.0 0.0))))
    (let* ((ind (find-sound "test.snd"))
	   (mxs (maxamp ind #t)))
      (if (or (fneq (car mxs) 0.8865966796875)
	      (fneq (cadr mxs) 0.664947509765625))
	  (snd-display #__line__ ";4->2(2) fullmix: ~A" mxs))
      (close-sound ind))
    
    (with-sound (:channels 2 :reverb nrev) 
		(fullmix "pistol.snd" 0.0 2.0 0.25 #f 2.0 0.1)
		(fullmix "pistol.snd" 1.0 2.0 0.25 0.2 2.0 0.1)
		(fullmix "2a.snd" #f #f #f '((0.5 0.0) (0.0 0.75)))
		(fullmix "oboe.snd" #f #f #f (list (list (list 0 0 1 1 2 0) 0.5)))
		(fullmix "oboe.snd" 3 2 0 (list (list .1 (make-env '(0 0 1 1) :duration 2 :scaler .5)))))
    
    
    (load "fullmix.scm") ; this is also in clm-ins.scm so we need a separate set of tests
    
    (with-sound (:channels 2 :statistics #t)
		(fullmix "pistol.snd")
		(fullmix "oboe.snd" 1 2 0 (list (list .1 (make-env '(0 0 1 1) :duration 2 :scaler .5)))))
    (let ((ind (find-sound "test.snd")))
      (if (sound? ind) (close-sound ind) (snd-display #__line__ ";fullmix.scm no output?")))
    
    (with-sound (:channels 2) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((0.0 0.0) (0.0 0.0) (1.0 0.0) (0.0 1.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.664947509765625) (snd-display #__line__ ";4->2(0) fullmix.scm: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:channels 1) 
		(fullmix "4.aiff" 0.0 0.1 36.4 '((1.0) (0.0) (0.0) (0.0))))
    (let ((ind (find-sound "test.snd")))
      (if (fneq (maxamp) 0.221649169921875) (snd-display #__line__ ";4->1(0) fullmix.scm: ~A" (maxamp)))
      (close-sound ind))
    
    (with-sound (:statistics #t :scaled-to .5 :srate 44100 :channels 1) 
		(cnvrev "oboe.snd" "fyow.snd"))
    (let ((ind (find-sound "test.snd")))
      (if (sound? ind) (close-sound ind) (snd-display #__line__ ";cnvrev no output?")))
    
    
    (if (file-exists? "with-mix.snd") (delete-file "with-mix.snd"))
    (with-sound () (with-mix () "with-mix" 0 (fm-violin 0 .1 440 .1)))
    (let ((old-date (check-with-mix 1 .1 .1 .1 "()" "((fm-violin 0 0.1 440 0.1))" #f #t)))
      (with-sound () (with-mix () "with-mix" 0 (fm-violin 0 .1 440 .1)))
      (check-with-mix 1 .1 .1 .1 "()" "((fm-violin 0 0.1 440 0.1))" old-date #t))
    
    (if (file-exists? "with-mix.snd") (delete-file "with-mix.snd"))
    (with-sound () (fm-violin 0 .1 660 .1) (with-mix () "with-mix" .1 (fm-violin 0 .1 440 .1)))
    (let ((old-date (check-with-mix 2 .1 .2 .1 "()" "((fm-violin 0 0.1 440 0.1))" #f #t)))
      (with-sound () (fm-violin 0 .1 660 .1) (with-mix () "with-mix" .1 (fm-violin 0 .1 440 .1)))
      (check-with-mix 2 .1 .2 .1 "()" "((fm-violin 0 0.1 440 0.1))" old-date #t))
    
    (if (file-exists? "with-mix.snd") (delete-file "with-mix.snd"))
    (with-sound () (fm-violin 0 .1 660 .1) (with-mix () "with-mix" .1 (fm-violin 0 .1 440 .1) (fm-violin .1 .1 660 .2)))
    (let ((old-date (check-with-mix 3 .2 .3 .2 "()" "((fm-violin 0 0.1 440 0.1) (fm-violin 0.1 0.1 660 0.2))" #f #t)))
      (with-sound () (fm-violin 0 .1 660 .1) (with-mix () "with-mix" .1 (fm-violin 0 .1 440 .1) (fm-violin .1 .1 660 .2)))
      (check-with-mix 3 .2 .3 .2 "()" "((fm-violin 0 0.1 440 0.1) (fm-violin 0.1 0.1 660 0.2))" old-date #t))
    
    (with-sound ()
		(sound-let ((temp-1 () (fm-violin 0 1 440 .1))
			    (temp-2 () (fm-violin 0 2 660 .1 :base 32.0)
				    (fm-violin .125 .5 880 .1)))
			   (mus-mix *output* temp-1 0) 
			   (mus-mix *output* temp-2 22050)))
    (let ((ind (find-sound "test.snd")))
      (if (not (sound? ind)) (snd-display #__line__ ";with-sound+sound-lets init: no test.snd?"))
      (if (or (> (maxamp ind) .2) (< (maxamp ind) .15))  (snd-display #__line__ ";with-mix+sound-lets maxamp: ~A" (maxamp ind)))
      (if (fneq 3.0 (/ (frames ind) (srate ind))) (snd-display #__line__ ";with-sound+sound-lets dur: ~A" (/ (frames ind) (srate ind))))
      (close-sound ind))
    
    (if (file-exists? "with-mix.snd") (delete-file "with-mix.snd"))
    (with-sound ()
		(with-mix () "with-mix" 0
			  (sound-let ((tmp () (fm-violin 0 1 440 .1))) (mus-mix *output* tmp 0))))
    (let ((old-date (check-with-mix 4 1 1 .1 "()" "((sound-let ((tmp () (fm-violin 0 1 440 0.1))) (mus-mix *output* tmp 0)))" #f #t)))
      (with-sound ()
		  (with-mix () "with-mix" 0
			    (sound-let ((tmp () (fm-violin 0 1 440 .1))) (mus-mix *output* tmp 0))))
      (check-with-mix 4 1 1 .1 "()" "((sound-let ((tmp () (fm-violin 0 1 440 0.1))) (mus-mix *output* tmp 0)))" old-date #t))
    
    (if (file-exists? "with-mix.snd") (delete-file "with-mix.snd"))
    (with-sound (:channels 2) (fm-violin 0 .1 440 .1 :degree 0) (with-mix () "with-mix" 0 (fm-violin 0 .1 550 .3 :degree 90)))
    (let ((ind (find-sound "test.snd")))
      (if (or (fneq (maxamp ind 0) .1)
	      (fneq (maxamp ind 1) .3))
	  (snd-display #__line__ ";with-mix stereo: ~A" (maxamp ind #t)))
      (if (not (= (mus-sound-chans "with-mix.snd") 2)) (snd-display #__line__ ";with-mix stereo out: ~A" (mus-sound-chans "with-mix.snd"))))
    (let ((old-date (mus-sound-write-date "with-mix.snd")))
      (with-sound (:channels 2) (fm-violin 0 .1 440 .1 :degree 0) (with-mix () "with-mix" 0 (fm-violin 0 .1 550 .3 :degree 90)))
      (if (not (= (mus-sound-write-date "with-mix.snd") old-date)) 
	  (snd-display #__line__ ";stereo with-mix dates: ~A ~A" old-date (mus-sound-write-date "with-mix.snd"))))
    (let ((ind (find-sound "test.snd")))
      (close-sound ind))
    
    (if (file-exists? "with-mix.snd") (delete-file "with-mix.snd"))
    (with-sound (:reverb jc-reverb) (fm-violin 0 .1 440 .1) (with-mix () "with-mix" 0 (fm-violin 0 .1 550 .3)))
    (let ((old-date (check-with-mix 6 .1 1.1 .398 "()" "((fm-violin 0 0.1 550 0.3))" #f #f)))
      (with-sound (:reverb jc-reverb) (fm-violin 0 .1 440 .1) (with-mix () "with-mix" 0 (fm-violin 0 .1 550 .3)))
      (check-with-mix 6 .1 1.1 .398 "()" "((fm-violin 0 0.1 550 0.3))" old-date #f))
    
    (with-sound (:srate 44100 :play #f) (bigbird 0 2 60 0 .5 '(0 0 1 1) '(0 0 1 1 2 1 3 0) '(1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1)))
    (let ((ind (or (find-sound "test.snd") (open-sound "oboe.snd"))))
      (let ((mx (maxamp)))
	(notch-sound (let ((freqs '())) (do ((i 60 (+ i 60))) ((= i 3000)) (set! freqs (cons i freqs))) (reverse freqs)))
	(if (or (fneq mx .5)
		(ffneq (maxamp) .027))
	    (snd-display #__line__ ";notch 60 Hz: ~A to ~A" mx (maxamp)))
	(undo)
	(notch-sound (let ((freqs '())) (do ((i 60 (+ i 60))) ((= i 3000)) (set! freqs (cons i freqs))) (reverse freqs)) #f ind 0 10)
	(if (ffneq (maxamp) .004)
	    (snd-display #__line__ ";notch-sound 60 hz 2: ~A" (maxamp)))
	(undo)
	(notch-channel (let ((freqs '())) (do ((i 60 (+ i 60))) ((= i 3000)) (set! freqs (cons i freqs))) (reverse freqs)) #f #f #f ind 0 #f #f 10)
	(if (ffneq (maxamp) .004)
	    (snd-display #__line__ ";notch-channel 60 hz 2: ~A" (maxamp)))
	(undo)
	
					;	  (select-all)
	(make-selection 10000 11000)
	(notch-selection (let ((freqs '())) (do ((i 60 (+ i 60))) ((= i 3000)) (set! freqs (cons i freqs))) (reverse freqs)) #f)
					;	  (if (ffneq (maxamp) .066)
					;	      (snd-display #__line__ ";notch-selection 60 hz 2: ~A" (maxamp)))
	(play-sound
	 (lambda (data)
	   (let ((len (sound-data-length data)))
	     (run
	      (lambda ()
		(do ((i 0 (+ 1 i)))
		    ((= i len))
		  (sound-data-set! data 0 i (* 2.0 (sound-data-ref data 0 i)))))))))
	
	(close-sound ind)))
    
    (with-sound (:srate 44100 :play #f) (bigbird 0 60 60 0 .5 '(0 0 1 1) '(0 0 1 1 2 1 3 0) '(1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1)))
    (let ((ind (find-sound "test.snd")))
      (let ((mx (maxamp)))
	(notch-sound (let ((freqs '())) (do ((i 60 (+ i 60))) ((= i 3000)) (set! freqs (cons i freqs))) (reverse freqs)) #f ind 0 10)
	(if (ffneq (maxamp) .036)
	    (snd-display #__line__ ";notch-sound 60 hz 2 60: ~A" (maxamp))))
      (close-sound ind))
    
    (play-sine 440 .1)
    (play-sines '((425 .05) (450 .01) (470 .01) (546 .02) (667 .01) (789 .034) (910 .032)))
    
    (with-sound (:channels 2 :reverb jc-reverb :reverb-channels 1 :statistics #t)
		(grani 0 1 .5 "oboe.snd" :grain-envelope '(0 0 0.2 0.2 0.5 1 0.8 0.2 1 0))
		(grani 0 4 1 "oboe.snd")
		(if (> (optimization) 4) 
		    (begin
		      (grani 0 4 1 "oboe.snd" :grains 10)
		      (grani 0 4 1 "oboe.snd" 
			     :grain-start 0.11 
			     :amp-envelope '(0 1 1 1) :grain-density 8
			     :grain-envelope '(0 0 0.2 0.2 0.5 1 0.8 0.2 1 0)
			     :grain-envelope-end '(0 0 0.01 1 0.99 1 1 0)
			     :grain-envelope-transition '(0 0 0.4 1 0.8 0 1 0))
		      (grani 0 3 1 "oboe.snd" 
			     :grain-start 0.1 
			     :amp-envelope '(0 1 1 1) :grain-density 20
			     :grain-duration '(0 0.003 0.2 0.01 1 0.3))
		      (grani 0 3 1 "oboe.snd" 
			     :grain-start 0.1 
			     :amp-envelope '(0 1 1 1) :grain-density 20
			     :grain-duration '(0 0.003 0.2 0.01 1 0.3)
			     :grain-duration-limit 0.02)
		      (grani 0 2 1 "oboe.snd" 
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :grain-start '(0 0.1 0.3 0.1 1 0.6))
		      (grani 0 2 1 "oboe.snd" 
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :grain-start '(0 0.1 0.3 0.1 1 0.6)
			     :grain-start-spread 0.01)
		      (grani 0 2.6 1 "oboe.snd" 
			     :grain-start 0.1 :grain-start-spread 0.01
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :srate '(0 0 0.2 0 0.6 5 1 5))
		      (grani 0 2.6 1 "oboe.snd" 
			     :grain-start 0.1 :grain-start-spread 0.01
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :srate-base 2
			     :srate '(0 0 0.2 0 0.6 -1 1 -1))
		      (grani 0 2.6 1 "oboe.snd" 
			     :grain-start 0.1 :grain-start-spread 0.01
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :srate-linear #t
			     :srate (list 0 1 0.2 1 0.6 (expt 2 (/ 5 12)) 1 (expt 2 (/ 5 12))))
		      (grani 0 2 1 "oboe.snd" 
			     :grain-start 0.1 :grain-start-spread 0.01
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :grain-duration '(0 0.02 1 0.1) 
			     :grain-duration-spread '(0 0 0.5 0.1 1 0)
			     :where-to grani-to-grain-duration
			     :where-bins (vct 0 0.05 1))
		      (grani 0 2 1 "oboe.snd" 
			     :grain-start 0.1 :grain-start-spread 0.01
			     :amp-envelope '(0 1 1 1) :grain-density 40
			     :grain-degree '(0 0 1 90)
			     :grain-degree-spread 10)
		      )))
    
    (let ((ind (open-sound "oboe.snd")))
      (with-sound (:output "test1.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
      (set-samples 0 2205 "test1.snd" ind 0 #f "set-samples auto-delete test" 0 #f #t)
      (if (not (file-exists? "test1.snd")) (snd-display #__line__ ";oops: auto-delete test1.snd?"))
      (undo 1 ind)
      (with-sound (:output "test2.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
      (insert-sound "test2.snd" 0 0 ind 0 #f #t)
      (if (file-exists? "test1.snd") (snd-display #__line__ ";auto-delete set-samples?"))
      (undo 1 ind)
      (with-sound (:output "test3.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
      (insert-samples 0 2205 "test3.snd" ind 0 #f #t)  
      (if (file-exists? "test2.snd") (snd-display #__line__ ";auto-delete insert-sound?"))
      (undo 1 ind)
      (with-sound (:output "test4.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
      (mix "test4.snd" 0 0 ind 0 #f #t)
      (if (file-exists? "test3.snd") (snd-display #__line__ ";auto-delete insert-samples?"))
      (undo 1 ind)
      (delete-sample 100)
      (if (file-exists? "test4.snd") (snd-display #__line__ ";auto-delete mix?"))
      (with-sound (:output "test5.snd" :to-snd #f) (fm-violin 0 .1 440 .1))
      (mix "test5.snd" 0 0 ind 0 #t #t)
      (revert-sound ind)
      (close-sound ind)
      (if (file-exists? "test5.snd") (snd-display #__line__ ";auto-delete mix (with-tag)?")))
    )        
  
  (let ((o2 (optkey-1 1)))
    (if (not (equal? o2 1)) (snd-display #__line__ ";optkey-1: ~A" o2)))
  (let ((o2 (optkey-1 :a 1)))
    (if (not (equal? o2 1)) (snd-display #__line__ ";optkey-1 1: ~A" o2)))
  (let ((o2 (optkey-1)))
    (if (not (equal? o2 #f)) (snd-display #__line__ ";optkey-1 2: ~A" o2)))
  (let ((o2 (optkey-2 1 2)))
    (if (not (equal? o2 (list 1 2))) (snd-display #__line__ ";optkey-2: ~A" o2)))
  (let ((o2 (optkey-2 :a 1 :b 2)))
    (if (not (equal? o2 (list 1 2))) (snd-display #__line__ ";optkey-2 1: ~A" o2)))
  (let ((o2 (optkey-2)))
    (if (not (equal? o2 (list 3 #f))) (snd-display #__line__ ";optkey-2 2: ~A" o2)))
  (let ((o2 (optkey-2 1 :b 2)))
    (if (not (equal? o2 (list 1 2))) (snd-display #__line__ ";optkey-2 3: ~A" o2)))
  (let ((o2 (optkey-3 1 2 3)))
    (if (not (equal? o2 (list 1 2 3))) (snd-display #__line__ ";optkey-3: ~A" o2)))
  (let ((o2 (optkey-3 1 :b 2 :c 3)))
    (if (not (equal? o2 (list 1 2 3))) (snd-display #__line__ ";optkey-3 1: ~A" o2)))
  (let ((o2 (optkey-3 1 2 :c 3)))
    (if (not (equal? o2 (list 1 2 3))) (snd-display #__line__ ";optkey-3 2: ~A" o2)))
  (let ((o2 (optkey-4)))
    (if (not (equal? o2 (list 1 2 3 #f))) (snd-display #__line__ ";optkey-4: ~A" o2)))
  (let ((o2 (optkey-4 1 :b 3 :c 4 :d 5)))
    (if (not (equal? o2 (list 1 3 4 5))) (snd-display #__line__ ";optkey-4 1: ~A 1" o2)))
  (let ((o2 (optkey-4 1 :d 5 :c 4 :b 3)))
    (if (not (equal? o2 (list 1 3 4 5))) (snd-display #__line__ ";optkey-4 2: ~A 1" o2)))
  (let ((o2 (optkey-4 1 3 4 5)))
    (if (not (equal? o2 (list 1 3 4 5))) (snd-display #__line__ ";optkey-4 3: ~A 2" o2)))
  
  (if (and (or (provided? 'snd-motif)
	       (provided? 'snd-gtk))
	   (defined? 'variable-display))
      (let ((wid1 (make-variable-display "do-loop" "i*1" 'text))
	    (wid2 (make-variable-display "do-loop" "i*2" 'scale '(-1.0 1.0)))
	    (wid3 (make-variable-display "do-loop" "i3" 'spectrum))
	    (wid4 (make-variable-display "do-loop" "i4" 'graph)))
	(do ((i 0 (+ 1 i)))
	    ((= i 1000))
	  (variable-display (variable-display (* (variable-display (sin (* (variable-display i wid1) .1)) wid3) .5) wid2) wid4))
	(let ((tag (catch #t (lambda () (set! (sample 0 (car wid3) 0) .5)) (lambda args (car args)))))
	  (if (> (edit-position (car wid3) 0) 0) (snd-display #__line__ ";edited variable graph? ~A ~A" tag (edit-position (car wid3) 0))))
	(if (provided? 'snd-motif)
	    (XtUnmanageChild variables-dialog)
	    (gtk_widget_hide variables-dialog))
	(close-sound (car wid3))
	(close-sound (car wid4))
	))
  
  (if (not (= *clm-srate* (default-output-srate))) (snd-display #__line__ ";*clm-srate*: ~A ~A" *clm-srate* (default-output-srate)))
  (if (not (= *clm-channels* (default-output-chans))) (snd-display #__line__ ";*clm-channels*: ~A ~A" *clm-channels* (default-output-chans)))
  (if (not (= *clm-header-type* (default-output-header-type))) (snd-display #__line__ ";*clm-header-type*: ~A ~A" *clm-header-type* (default-output-header-type)))
					;	(if (not (= *clm-data-format* (default-output-data-format))) (snd-display #__line__ ";*clm-data-format*: ~A ~A" *clm-data-format* (default-output-data-format)))
  (if (not (= *clm-reverb-channels* 1)) (snd-display #__line__ ";*clm-reverb-channels*: ~A ~A" *clm-reverb-channels*))
  (if (not (string=? *clm-file-name* "test.snd")) (snd-display #__line__ ";*clm-file-name*: ~A" *clm-file-name*))
  (if *clm-play* (snd-display #__line__ ";*clm-play*: ~A" *clm-play*))
  (if *clm-verbose* (snd-display #__line__ ";*clm-verbose*: ~A" *clm-verbose*))
  (if *clm-statistics* (snd-display #__line__ ";*clm-statistics*: ~A" *clm-statistics*))
  (if *clm-reverb* (snd-display #__line__ ";*clm-reverb*: ~A" *clm-reverb*))
  (if (not (null? *clm-reverb-data*)) (snd-display #__line__ ";*clm-reverb-data*: ~A?" *clm-reverb-data*))
  (if *clm-delete-reverb* (snd-display #__line__ ";*clm-delete-reverb*: ~A" *clm-delete-reverb*))
  
  (set! *clm-channels* 2)
  (set! *clm-srate* 44100)
  (set! *clm-file-name* "test.wav")
  (set! *clm-verbose* #t)
  (set! *clm-statistics* #t)
  (set! *clm-play* #t)
  (set! *clm-data-format* mus-mulaw)
  (set! *clm-header-type* mus-riff)
  (set! *clm-delete-reverb* #t)
  (set! *clm-reverb* jc-reverb)
  (set! *clm-reverb-data* (list #t 2.0 (list 0 1 3.0 1 4.0 0)))
  
  (with-sound () (fm-violin 0 1 440 .1 :reverb-amount .1))
  
  (let ((ind (find-sound "test.wav")))
    (if (not (sound? ind))
	(snd-display #__line__ ";default output in ws: ~A" (map file-name (sounds)))
	(begin
	  (if (not (= (srate ind) 44100)) (snd-display #__line__ ";default srate in ws: ~A ~A" (srate ind) *clm-srate*))
	  (if (not (= (channels ind) 2)) (snd-display #__line__ ";default chans in ws: ~A ~A" (channels ind) *clm-channels*))
	  (if (not (= (data-format ind) mus-mulaw)) (snd-display #__line__ ";default format in ws: ~A ~A" (data-format ind) *clm-data-format*))
	  (if (not (= (header-type ind) mus-riff)) (snd-display #__line__ ";default type in ws: ~A ~A" (header-type ind) *clm-header-type*))
	  (if (not (= (frames ind) 88200)) (snd-display #__line__ ";reverb+1 sec out in ws: ~A" (frames ind)))
	  (if (file-exists? "test.rev") (snd-display #__line__ ";perhaps reverb not deleted in ws?"))
	  (close-sound ind))))
  
  (let ((val 0)
	(old-hook *clm-notehook*))
    (set! *clm-notehook* (lambda args (set! val 1)))
    (with-sound () (fm-violin 0 .1 440 .1))
    (if (not (= val 1)) (snd-display #__line__ ";*clm-notehook*: ~A ~A" val *clm-notehook*))
    (with-sound (:notehook (lambda args (set! val 2))) (fm-violin 0 .1 440 .1))
    (if (not (= val 2)) (snd-display #__line__ ";:notehook: ~A" val))
    (with-sound () (fm-violin 0 .1 440 .1))
    (if (not (= val 1)) (snd-display #__line__ ";*clm-notehook* (1): ~A ~A" val *clm-notehook*))
    (set! *clm-notehook* old-hook))
  
  (set! *clm-channels* 1)
  (set! *clm-srate* 22050)
  (set! *clm-file-name* "test.snd")
  (set! *clm-verbose* #f)
  (set! *clm-statistics* #f)
  (set! *clm-play* #f)
  (set! *clm-data-format* mus-bshort)
  (set! *clm-header-type* mus-next)
  (set! *clm-delete-reverb* #f)
  (set! *clm-reverb* #f)
  (set! *clm-reverb-data* '())
  
  (with-sound (:reverb jl-reverb)
	      (attract 0 1 0.1 2.0)
	      (expfil 0 2 .2 .01 .1 "oboe.snd" "fyow.snd")
	      (fm-violin 0 .1 660 .1 :reverb-amount .1)
	      (anoi "oboe.snd" 1 1)
	      (let* ((ind (open-sound "oboe.snd"))
		     (ind1 (open-sound "now.snd"))
		     (zp (make-zipper (make-env '(0 0 1 1) :length 22050)
				      0.05
				      (make-env (list 0 (* (mus-srate) 0.05)) :length 22050)))
		     (reader0 (make-sampler 0 ind 0))
		     (reader1 (make-sampler 0 ind1 0)))
		(run (lambda () (do ((i 0 (+ 1 i))) ((= i 22050)) (outa i (zipper zp reader0 reader1)))))
		(close-sound ind)
		(close-sound ind1)))
  
  (zip-sound 1 1 "fyow.snd" "now.snd" '(0 0 1 1) .05)
  (zip-sound 2 3 "mb.snd" "fyow.snd" '(0 0 1.0 0 1.5 1.0 3.0 1.0) .025)
  
  (if all-args
      (let* ((ind (open-sound "oboe.snd"))
	     (pv (make-pvocoder 256 4 64))
	     (rd (make-sampler 0)))
	(map-channel (lambda (y) (pvocoder pv rd)))
	(clm-reverb-sound .1 jc-reverb)
	(close-sound ind)))
  
  (let ((old-play *clm-play*))
    (set! *clm-play* #f)
    (make-birds)
    (set! *clm-play* old-play))
  
  (for-each close-sound (sounds))
  
  (with-sound ()
	      (simple-ssb 0 .2 440 .1)
	      (simple-osc 0.75 .2 440 .1)
	      (simple-asy 1.25 .2 .1)
	      (simple-saw 1.5 .2 .1)
	      (simple-tri 1.75 .2 .1)
	      (simple-pul 2.0 .2 .1)
	      (simple-sqr 2.25 .2 .1)
	      (if all-args (simple-sib 2.5 .2 440.0 .1))
	      (simple-oz 2.75 .2 440.0 .1)
	      (simple-op 3.0 .2 440.0 .1)
	      (simple-tz 3.25 .2 440.0 .1)
	      (simple-tp 3.5 .2 440.0 .1)
	      (simple-frm 3.75 .2 440.0 .1)
	      (simple-firm 3.875 .2 440.0 .1)
	      (simple-firm2 4.0 .2 440.0 .1)
	      (simple-poly 4.25 .2 440.0 .1)
	      (simple-polyw 4.5 .2 440.0 .1)
	      (simple-dly 4.75 .2 440.0 .1)
	      (simple-cmb 5.0 .2 440.0 .1)
	      (simple-filtered-cmb 5.125 .2 440.0 .1)
	      (simple-not 5.25 .2 440.0 .1)
	      (simple-alp 5.5 .2 440.0 .1)
	      (simple-ave 5.75 .2 440.0 .1)
	      (simple-tab 6.0 .2 440.0 .1)
	      (simple-flt 6.25 .2 440.0 .1)
	      (simple-fir 6.5 .2 440.0 .1)
	      (simple-iir 6.5 .2 440.0 .3)
	      (simple-f 6.75 .2 440.0 .1)
	      (simple-ran 7.0 .2 440.0 .1)
	      (simple-ri 7.25 .2 440.0 .1)
	      (simple-env 7.5 .2 440.0 .1)
	      (simple-amb 7.75 .2 440.0 .1)
	      (simple-fof 8 1 270 .1 .001 730 .6 1090 .3 2440 .1) ;"Ahh"
	      (simple-fof 9 4 270 .1 0.005 730 .6 1090 .3 2440 .1 '(0 0 40 0 75 .2 100 1) 
			  '(0 0 .5 1 3 .5 10 .2 20 .1 50 .1 60 .2 85 1 100 0))
	      (simple-fof 9 4 (* 6/5 540) .1 0.005 730 .6 1090 .3 2440 .1 '(0 0 40 0 75 .2 100 1) 
			  '(0 0 .5 .5 3 .25 6 .1 10 .1 50 .1 60 .2 85 1 100 0))
	      (simple-fof 9 4 135 .1 0.005 730 .6 1090 .3 2440 .1 '(0 0 40 0 75 .2 100 1) 
			  '(0 0 1 3 3 1 6 .2 10 .1 50 .1 60 .2 85 1 100 0))
	      
	      (simple-src-f 13  .45 1.0 2.0 "oboe.snd")
	      (simple-rd 13.5 .45 .75 "oboe.snd")
	      (simple-rd-start 13.65 .25 .75 "oboe.snd" 0 0)
	      (simple-rd-start 13.8 .25 .75 "oboe.snd" 0 12345)
	      (simple-rd-start 13.9 .25 .75 "oboe.snd" 0 12345678)
	      (simple-cnv 14.0 .45 .75 "oboe.snd")
	      (simple-cnf 14.5 .45 .75 "oboe.snd")
	      (simple-lrg 15.0 .45 .75 "oboe.snd")
	      (simple-cn2 15.5 .45 .4 "oboe.snd")
	      (simple-src 16  .45 1.0 2.0 "oboe.snd")
	      (simple-sr2 16.5 .45 1.0 2.0 "oboe.snd")
	      (simple-sr2a 16.75 .45 1.0 2.0 "oboe.snd")
	      (simple-rndist 17.0 .2 440.0 .1)
	      (simple-ridist 17.25 .2 440.0 .1)
	      (simple-sro 17.5 .45 .1 .5 440)
	      (simple-grn 18 .2 .1 1.0 440)
	      (simple-pvoc 18.25 .2 .4 256 "oboe.snd")
	      (simple-ina 18.5 .45 1 "oboe.snd")
	      (simple-rdf 19 .45 1 "oboe.snd")
	      (simple-f2s 19.5 .45 1 "oboe.snd")
	      (simple-loc 20 .2 440 .1)
	      (simple-dloc 20.1 .2 440 .1)
	      (simple-out 20.25 .2 440 .1)	
	      (simple-fm 20 1 440 .1 2 1.0)
	      (simple-dup 20.5 .2 440 .1)
	      (simple-du1 20.75 .2 440 .1)
	      (simple-grn-f1 21 .45 .1 2 440)
	      (simple-grn-f2 21.5 .45 1 2 "oboe.snd")
	      (simple-grn-f3 22 .45 1 2 "oboe.snd")
	      (simple-grn-f4 22.5 .45 1 2 "oboe.snd")
	      (simple-grn-f5 23 .45 1 2 "oboe.snd")
	      (simple-multiarr 23.5 .5 440 .1))
  
  
  (with-sound (:channels 4) (simple-dloc-4 0 2 440 .5))
  
  (with-sound ()
	      (or1) (or2) (or3) (or4)
	      (sample-desc 0 .2 440 .1)
	      (sample-mdat .25 .2 440 .1)
	      (sample-xtab .5 .2 440 .1)
	      (sample-xts .75 .2 440 .1)
	      (sample-srl2 1 .2 .2 .5 (* 440 2))
	      (sample-srll 1.25 .2 .1 .5 (* 440 4))
	      (sample-srl3 1.5 .2 .1 .5 880)
	      (sample-grn2 1.75 .2 .1 .5 880)
	      (sample-grn3 2 .45 1 1 "oboe.snd")
	      
	      (sample-cnv 2.5 .45 1 1 "oboe.snd")
	      (sample-cnv1 3.0 .45 1 1 "oboe.snd")
	      (sample-pvoc1 3.5 .45 1 512 "oboe.snd")
	      (sample-pvoc2 4.0 .45 1 512 "oboe.snd")
	      (sample-pvoc3 4.5 .001 1 512 "oboe.snd")
	      (sample-mxf 5 .2 440 .1)
	      (sample-osc 5.25 .2 440 .1)
	      (if all-args (sample-ardcl 5.5 .2 440 .1))
	      (sample-strs 5.75 .2 440 .1)
	      (sample-flt 6 .2 440 .1)
	      (sample-arrintp 6.25 .2 440 .1)
	      (sample-if 6.5 .2 440 .1)
	      (sample-arrfile 6.75 .2 440 .15)
	      (sample-pvoc5 7.25 .2 .1 256 "oboe.snd" 440.0)
	      )
  
  (if all-args
      (let* ((outfile (with-sound () (pvoc-a 0 2.3 1 256 "oboe.snd") (pvoc-e 0 2.3 -1 256 "oboe.snd")))
	     (mx (mus-sound-maxamp outfile)))
	(if (fneq (cadr mx) 0.0)
	    (snd-display #__line__ ";pvoc a-e: ~A" mx))))
  
  (let* ((file (with-sound (:clipped #f :data-format mus-bfloat :header-type mus-next)
			   (fm-violin 0 .1 440 pi)))
	 (ind (find-sound file))
	 (mx (maxamp ind)))
    (if (fneq mx pi) (snd-display #__line__ ";clipped #f: ~A" mx))
    (close-sound ind)
    (set! file (with-sound (:clipped #t :data-format mus-bfloat :header-type mus-next)
			   (fm-violin 0 .1 440 pi)))
    (set! ind (find-sound file))
    (set! mx (maxamp ind))
    (if (fneq mx 1.0) (snd-display #__line__ ";clipped #t: ~A" mx))
    
    (close-sound ind)
    (set! file (with-sound (:data-format mus-bfloat :header-type mus-next :scaled-by .1 :clipped #f)
			   (fm-violin 0 .1 440 pi)))
    (set! ind (find-sound file))
    (set! mx (maxamp ind))
    (if (fneq mx .314159) (snd-display #__line__ ";scaled-by ~A" mx))
    
    (close-sound ind)
    (set! file (with-sound (:data-format mus-bfloat :header-type mus-next :scaled-to .1 :clipped #f)
			   (fm-violin 0 .1 440 pi)))
    (set! ind (find-sound file))
    (set! mx (maxamp ind))
    (if (fneq mx .1) (snd-display #__line__ ";scaled-to ~A" mx))
    
    (close-sound ind)
    (let ((old-bufsize *clm-file-buffer-size*)
	  (old-tsize *clm-table-size*)
	  (old-arrp *clm-array-print-length*))
      (set! *clm-file-buffer-size* (* 1024 1024))
      (set! *clm-table-size* 256)
      (set! *clm-array-print-length* 123)
      (let ((tsize 0)
	    (arrp 0))
	(set! file (with-sound (:data-format mus-bfloat :header-type mus-next)
			       (set! mx (mus-file-buffer-size))
			       (set! tsize (clm-table-size))
			       (set! arrp (mus-array-print-length))
			       (fm-violin 0 .1 440 .1)))
	(set! ind (find-sound file))
	(if (not (= mx (* 1024 1024))) (snd-display #__line__ ";*clm-file-buffer-size*: ~A" mx))
	(if (not (= tsize 256)) (snd-display #__line__ ";*clm-table-size*: ~A" tsize))
	(if (not (= arrp 123)) (snd-display #__line__ ";*clm-array-print-length*: ~A" arrp))
	(set! *clm-file-buffer-size* old-bufsize)
	(set! *clm-table-size* old-tsize)
	(set! *clm-array-print-length* old-arrp)
	(close-sound ind)))
    
    (set! file (with-sound () (fm-violin 0 3.0 440 .1)))
    (set! ind (find-sound file))
    (set! (amp-control ind) .5)
    (set! (x-bounds ind 0) (list 1.0 2.0))
    (set! file (with-sound () (fm-violin 0 4.0 440 .1)))
    (set! ind (find-sound file))
    (if (fneq (amp-control ind) .5) (snd-display #__line__ ";update ws amp: ~A" (amp-control ind)))
    (if (or (fneq (car (x-bounds ind 0)) 1.0)
	    (fneq (cadr (x-bounds ind 0)) 2.0))
	(snd-display #__line__ ";update ws bounds: ~A" (x-bounds ind)))
    
    (if (not (= (->sample 1.0) (srate))) (snd-display #__line__ ";1.0->sample: ~A" (->sample 1.0)))
    (close-sound ind)
    
    (set! file (with-sound (:reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount .1)))
    (set! ind (find-sound file))
    (set! mx (maxamp ind))
    (set! file (with-sound (:reverb jc-reverb :reverb-data '(#f 12.0 (0 0 1 1 20 1 21 0))) (fm-violin 0 .1 440 .1 :reverb-amount .1)))
    (set! ind (find-sound file))
    (if (not (> (maxamp ind) mx)) (snd-display #__line__ ";reverb-data: ~A ~A" mx (maxamp ind)))
    (close-sound ind))
  
  (let ((ind (open-sound "oboe.snd")))
    (step-src)
    (if (> (abs (- (frames) 24602)) 100) (snd-display #__line__ ";step-src frames: ~A (~A)" (frames) (edits)))
    (close-sound ind))
  
  (let ((file (with-sound (:channels 3)
			  (let ((rg (make-rmsgain))
				(rg1 (make-rmsgain 40))
				(rg2 (make-rmsgain 2))
				(e (make-env '(0 0 1 1 2 0) :length 10000))
				(e1 (make-env '(0 0 1 1) :length 10000))
				(e2 (make-env '(0 0 1 1 2 0 10 0) :length 10000))
				(o (make-oscil 440.0)))
			    (do ((i 0 (+ 1 i)))
				((= i 10000))
			      (let ((sig (env e)))
				(outa i (balance rg sig (env e2)))
				(outb i (balance rg1 sig (env e1)))
				(outc i (balance rg2 (* .1 (oscil o)) (env e2)))))
			    (if (fneq (gain-avg rg) 0.98402) (snd-display #__line__ ";rmsgain gain-avg: ~A" (gain-avg rg)))
			    (if (not (= (rmsg-avgc rg2) 10000)) (snd-display #__line__ ";rmsgain count: ~A" (rmsg-avgc rg2)))))))
    (let ((ind (find-sound file)))
      (if (not (sound? ind))
	  (snd-display #__line__ ";with-sound balance?")
	  (close-sound ind))))
  
  (let* ((mg (make-oscil 100.0))
	 (gen (make-ssb-fm 1000))
	 (ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1)))
    (pad-channel 0 1000 ind 0)
    (catch #t (lambda () (map-channel (lambda (y) (ssb-fm gen (* .02 (oscil mg)))))) (lambda arg (display arg) arg))
    (close-sound ind))
  
  (let ((file (with-sound () 
			  (let ((rd (make-sampler 0 "oboe.snd")) 
				(m (make-mfilter :decay .99 :frequency 1000)) 
				(e (make-env '(0 100 1 2000) :length 10000))) 
			    (run 
			     (do ((i 0 (+ 1 i))) 
				 ((= i 10000))
			       (outa i (mfilter-1 m (* .1 (rd)) 0.0)) 
			       (set! (mflt-eps m) (* 2.0 (sin (/ (* pi (env e)) (mus-srate)))))))))))
    (let ((ind (find-sound file)))
      (if (not (sound? ind))
	  (snd-display #__line__ ";with-sound mfilter?")
	  (close-sound ind))))
  
  (let ((m1 (make-mfilter .9 1000.0))
	(m2 (make-firmant 1000.0 .9))
	(gain (- 1.0 (* .9 .9))))
    (firmant m2 1.0)
    (mfilter-1 m1 1.0 0.0)
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let ((v1 (* gain (mfilter-1 m1 0.0 0.0)))
	    (v2 (firmant m2 0.0)))
	(if (fneq v1 v2)
	    (snd-display #__line__ ";~D mfilter/firmant: ~A ~A" i v1 v2)))))
  
  (let ((m1 (make-mfilter .9 1000.0))
	(m2 (make-firmant 1000.0 .9))
	(gain (- 1.0 (* .9 .9))))
    (do ((i 0 (+ 1 i)))
	((= i 10))
      (let* ((y (- (random 2.0 )1.0))
	     (v1 (* gain (mfilter-1 m1 y 0.0)))
	     (v2 (firmant m2 y)))
	(if (fneq v1 v2)
	    (snd-display #__line__ ";rand case mfilter/firmant: ~A ~A" i v1 v2)))))
  
  
  ;; dlocsig tests
  (if (not (provided? 'snd-dlocsig.scm))
      (catch #t 
	     (lambda () (load "dlocsig.scm"))
	     (lambda args (snd-display #__line__ ";load dlocsig: ~A" args))))
  (if (not (defined? 'make-spiral-path))
      (snd-display #__line__ ";make-spiral-path is not defined, dlocsig is ~Aloaded"
		   (if (provided? 'snd-dlocsig.scm) "" "not "))
      (begin
	
	(let ((file (new-sound "tmp.snd" mus-next mus-bfloat 22050 4)))
	  (mix-move-sound 0 "oboe.snd" (make-spiral-path :turns 3))
	  (close-sound file))
	
	(let ((ind 0))
	  (with-sound (:channels 2) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .010 .011 .012 .013 .014 .015 .017 .018 
				  .020 .023 .025 .029 .033 .039 .046 .055 .068 .088 .122 
				  .182 .301 .486 .477 .402 .160 .000 .000 .000 .000 .000 
				  .000 .000 .000 .001 .001 .002 .002 .002 .002 .002 .003 
				  .003 .003 .003 .003 .003)
			  ind 0 "dlocsig 0 0")
	  
	  (check-segments (vector .000 .000 .000 .003 .003 .003 .003 .003 .003 .003 .003 
				  .003 .003 .003 .003 .003 .003 .003 .003 .002 .002 .002 
				  .007 .036 .168 .386 .487 .497 .000 .000 .000 .000 .000 
				  .000 .000 .015 .033 .031 .027 .024 .021 .019 .018 .016 
				  .015 .014 .013 .012 .011)
			  ind 1 "dlocsig 0 1")
	  
	  (with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .011 .011 .012 .013 .014 .015 .017 .018 
				  .020 .023 .025 .029 .033 .038 .045 .054 .066 .086 .118 
				  .178 .300 .499 .497 .399 .079 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000)
			  ind 0 "dlocsig 1 0")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .052 .376 .499 .496 .339 .184 .122 .087 .068 
				  .055 .046 .039 .034 .030 .026 .023 .021 .019 .018 .016
				  .015 .014 .013 .012 .011)
			  ind 1 "dlocsig 1 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .036 .160 .166 .122 .111 .078 .054 .037 .027 
				  .020 .015 .012 .009 .007 .006 .005 .004 .003 .002 .002 
				  .001 .001 .001 .001 .000)
			  ind 2 "dlocsig 1 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .001 .001 .001 .001 .002 .002 
				  .002 .003 .004 .005 .006 .007 .009 .012 .016 .022 .030 
				  .041 .048 .045 .160 .166 .079 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 1 3")
	  
	  
	  (with-sound (:channels 8) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .007 .007 .008 .008 .008 .009 .009 
				  .010 .010 .011 .011 .012 .012 .013 .014 .015 .017 
				  .021 .028 .050 .128 .382 .495 .389 .078 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 0 "dlocsig 2 0")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .356 .497 .322 .042 .000 
				  .000 .001 .003 .005 .006 .007 .007 .008 .008 .008 
				  .008 .008 .008 .008 .008 .008 .007 .007 .007)
			  ind 1 "dlocsig 2 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .163 .397 .480 .353 .197 
				  .133 .095 .073 .058 .048 .040 .034 .030 .026 .023 
				  .020 .018 .016 .014 .013 .011 .010 .009 .009)
			  ind 2 "dlocsig 2 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .163 .169 .078 .003 .005 
				  .004 .001 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 2 3")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .163 .169 .078 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 4 "dlocsig 2 4")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .163 .169 .078 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 5 "dlocsig 2 5")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .163 .169 .078 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 6 "dlocsig 2 6")
	  
	  (check-segments (vector .000 .000 .000 .008 .009 .010 .010 .012 .013 .014 
				  .016 .018 .020 .023 .027 .031 .036 .044 .053 .066 
				  .086 .118 .175 .273 .377 .315 .169 .078 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 7 "dlocsig 2 7")
	  
	  
	  (with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #t)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .011 .011 .012 .013 .014 .015 .017 
				  .018 .020 .023 .025 .029 .033 .038 .045 .054 .066 
				  .086 .118 .178 .300 .499 .497 .399 .079 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 0 "dlocsig 3 0")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .052 .376 .499 .496 .339 .184 
				  .122 .087 .068 .055 .046 .039 .034 .030 .026 .023 
				  .021 .019 .018 .016 .015 .014 .013 .012 .011)
			  ind 1 "dlocsig 3 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .036 .160 .166 .122 .111 .078 
				  .054 .037 .027 .020 .015 .012 .009 .007 .006 .005 
				  .004 .003 .002 .002 .001 .001 .001 .001 .000)
			  ind 2 "dlocsig 3 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .001 .001 .001 .001 .002 
				  .002 .002 .003 .004 .005 .006 .007 .009 .012 .016 
				  .022 .030 .041 .048 .045 .160 .166 .079 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 3 3")
	  
	  
	  (with-sound (:channels 4 :reverb jc-reverb) (dloc-sinewave 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :error .001 :3d #f)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .011 .012 .014 .017 .020 .025 .036 .046 .070 
				  .114 .261 .505 .453 .006 .006 .008 .007 .012 .034 
				  .035 .027 .022 .022 .018 .040 .041 .032 .050 .044 
				  .049 .037 .037 .040 .040 .033 .027 .028 .032 .029 
				  .017 .020 .018 .015 .013 .011 .011 .017 .018 .015)
			  ind 0 "dlocsig 4 0")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .004 .006 .008 
				  .008 .007 .316 .503 .373 .130 .073 .052 .040 .050 
				  .034 .026 .023 .022 .030 .040 .041 .032 .050 .044 
				  .049 .037 .037 .040 .040 .033 .027 .028 .032 .029 
				  .017 .020 .018 .015 .013 .011 .011 .017 .018 .015)
			  ind 1 "dlocsig 4 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .150 .173 .120 .058 .029 .017 .010 .006 
				  .004 .003 .002 .001 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 4 2")
	  
	  (check-segments (vector .000 .000 .000 .001 .001 .002 .004 .006 .009 .015 
				  .028 .049 .150 .173 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 4 3")
	  
	  
	  (with-sound (:channels 2) (dloc-sinewave 0 1.0 440 .5 :path (make-path :path '((-10 10 0 1) (0 5 0 0) (10 10 10 1)) :3d #t)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .116 .125 .136 .148 .161 .175 .190 .206 
				  .223 .241 .260 .278 .296 .313 .329 .342 .353 .361 
				  .367 .370 .371 .370 .368 .367 .365 .362 .360 .358 
				  .353 .354 .333 .288 .240 .196 .158 .127 .104 .085 
				  .071 .060 .051 .045 .039 .035 .031 .028 .025)
			  ind 0 "dlocsig 5 0")
	  
	  (check-segments (vector .000 .000 .031 .035 .039 .044 .049 .056 .064 .074 
				  .085 .097 .113 .129 .148 .168 .190 .212 .233 .254 
				  .272 .290 .304 .316 .328 .333 .336 .340 .344 .346 
				  .350 .363 .370 .367 .352 .326 .295 .265 .237 .212 
				  .191 .171 .155 .141 .128 .117 .108 .100 .092)
			  ind 1 "dlocsig 5 1")
	  
	  
	  (with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :total-angle 360)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .351 .304 .256 .200 .145 .084 .024 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .057 .115 .174 .232 .282 .331 .373 .411 
				  .443 .467 .485 .496 .499 .499 .494 .482 .462 .436)
			  ind 0 "dlocsig 6 0")
	  
	  (check-segments (vector .393 .426 .455 .476 .491 .498 .500 .497 .489 .474 
				  .451 .421 .386 .343 .298 .246 .189 .134 .073 .014 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .006 .068 .126 .185 .239 .292)
			  ind 1 "dlocsig 6 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .034 .096 .153 .211 
				  .266 .314 .360 .398 .432 .460 .480 .493 .499 .500 
				  .496 .486 .470 .445 .416 .378 .335 .289 .236 .182 
				  .123 .061 .002 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 6 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .045 
				  .107 .164 .221 .272 .323 .368 .405 .438 .463 .483 
				  .495 .499 .499 .495 .485 .466 .440 .409 .371 .328 
				  .279 .225 .171 .111 .053 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 6 3")
	  
	  
	  (with-sound (:channels 8) (dloc-sinewave 0 3.0 440 .5 :path (make-spiral-path :turns 3)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .350 .010 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .099 .429 .500 .493 .280 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .168 .465 .500 .480 .214 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .235 .486 .499)
			  ind 0 "dlocsig 7 0")
	  
	  (check-segments (vector .499 .500 .378 .042 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .069 .408 .500 .497 .320 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .129 .447 .499 .488 .248 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .201)
			  ind 1 "dlocsig 7 1")
	  
	  (check-segments (vector .000 .319 .497 .500 .408 .070 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .036 .377 .500 
				  .499 .351 .015 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .097 .429 .500 .493 .289 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 7 2")
	  
	  (check-segments (vector .000 .000 .000 .279 .493 .500 .430 .101 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .009 
				  .348 .498 .500 .385 .043 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .068 .402 .500 .497 
				  .321 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 7 3")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .245 .487 .499 .452 .138 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .311 .496 .500 .409 .071 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .034 .376 
				  .500 .499 .352 .018 .000 .000 .000 .000 .000 .000)
			  ind 4 "dlocsig 7 4")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .204 .478 .500 
				  .467 .171 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .278 .493 .500 .431 .108 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .008 .347 .498 .500 .386 .044 .000 .000 .000 .000)
			  ind 5 "dlocsig 7 5")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .170 
				  .466 .500 .478 .212 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .243 .486 .499 .453 
				  .139 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .309 .496 .500 .411 .074 .000 .000)
			  ind 6 "dlocsig 7 6")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .137 .448 .499 .488 .246 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .202 .477 
				  .500 .467 .173 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .276 .493 .500 .436 .109)
			  ind 7 "dlocsig 7 7")
	  
	  
	  (with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-literal-path '((-10 10) (10 10)) :polar #f)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .308 .318 .327 .336 .344 .354 .362 .370 .378 
				  .386 .392 .398 .403 .408 .410 .412 .412 .412 .411 
				  .408 .403 .396 .388 .378 .346 .352 .328 .324 .307 
				  .289 .272 .253 .235 .216 .199 .180 .163 .146 .131 
				  .116 .101 .087 .075 .064 .052 .042 .033 .025)
			  ind 0 "dlocsig 8 0")
	  
	  (check-segments (vector .000 .009 .016 .023 .032 .041 .050 .062 .073 .085 
				  .099 .113 .128 .143 .161 .178 .195 .213 .232 .250 
				  .268 .286 .304 .321 .329 .344 .353 .375 .386 .394 
				  .402 .407 .410 .412 .413 .412 .411 .409 .404 .399 
				  .394 .387 .380 .372 .363 .355 .346 .337 .329)
			  ind 1 "dlocsig 8 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 8 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 8 3")
	  
	  
	  (with-sound (:channels 3) (dloc-sinewave 0 1.0 440 .5 :path (make-literal-path '((-10 10) (10 10)) :polar #t)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .004 .004 .004 .004 .005 .005 .006 .006 
				  .007 .007 .008 .009 .011 .012 .014 .017 .020 .025 
				  .033 .044 .066 .102 .215 .406 .490 .443 .345 .281 
				  .180 .121 .090 .069 .056 .046 .039 .034 .029 .026 
				  .023 .021 .019 .017 .015 .014 .013 .012 .011 .011)
			  ind 0 "dlocsig 9 0")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .002 .141 .383 .495 .475 .434 .401 
				  .257 .173 .129 .098 .080 .066 .055 .048 .042 .037 
				  .033 .029 .027 .024 .022 .020 .019 .017 .016 .015)
			  ind 1 "dlocsig 9 1")
	  
	  (check-segments (vector .000 .000 .017 .018 .019 .021 .023 .024 .026 .029 
				  .032 .035 .039 .044 .050 .058 .066 .079 .096 .118 
				  .155 .208 .310 .482 .491 .497 .499 .372 .137 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 9 2")
	  
	  
	  (with-sound (:channels 4) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :total-angle 360 :distance '(0 10 1 30 2 10))))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .348 .227 .134 .065 .013 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .010 .024 .041 .058 .077 .097 
				  .120 .144 .168 .195 .222 .251 .280 .306 .331)
			  ind 0 "dlocsig 10 0")
	  
	  (check-segments (vector .353 .347 .329 .306 .280 .253 .226 .198 .174 .148 
				  .126 .104 .083 .064 .046 .031 .016 .003 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .013 .067 .141)
			  ind 1 "dlocsig 10 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .025 .056 .082 .100 .114 .124 
				  .131 .135 .137 .137 .136 .135 .131 .127 .122 .116 
				  .110 .104 .097 .089 .082 .074 .067 .063 .057 .051 
				  .044 .035 .025 .015 .003 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 10 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .009 .020 .030 
				  .039 .046 .053 .059 .064 .069 .077 .084 .092 .099 
				  .106 .113 .119 .125 .130 .133 .136 .137 .137 .136 
				  .132 .126 .116 .103 .085 .060 .026 .000 .000)
			  ind 3 "dlocsig 10 3")
	  
	  
	  (set-speaker-configuration (arrange-speakers :speakers '(-45 45 90 135 225) 
						       :delays '(.010 .020 .030 .040 .050)
						       :channel-map '(0 1 3 2 4)))
	  
	  (with-sound (:channels 5) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :turns 2)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .350 .297 .187 .058 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .056 .178 .296 .387 .457 
				  .493 .499 .496 .465 .400 .313 .198 .077 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .036 
				  .167 .280 .379 .449 .491 .500 .498 .469 .411 .000)
			  ind 0 "dlocsig 11 0")
	  
	  (check-segments (vector .355 .432 .483 .499 .499 .434 .220 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .115 .240 .342 .426 .478 .499 .500 .454 
				  .245 .017 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .103 .223 .289 .000)
			  ind 1 "dlocsig 11 1")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .011 .237 .450 
				  .500 .500 .479 .428 .350 .243 .126 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .212 .429 .499 .499 .484 .438 .358 .260 
				  .137 .013 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 11 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .111 .359 .489 .500 .486 .339 
				  .097 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .088 .330 
				  .480 .500 .490 .371 .119 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 11 3")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .072 .194 .309 .398 .464 .496 .500 .494 .459 
				  .391 .299 .189 .060 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .053 .183 .294 .390 .456 
				  .494 .500 .496 .464 .402 .314 .200 .079 .000 .000)
			  ind 4 "dlocsig 11 4")
	  
	  
	  (with-sound (:channels 5 :reverb freeverb :reverb-channels 5) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :turns 2)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .350 .194 .013 .028 .020 .011 .012 .006 .246 .427 
				  .502 .504 .450 .281 .064 .041 .021 .011 .012 .009 
				  .169 .377 .489 .502 .480 .052 .058 .043 .015 .015 
				  .013 .009 .005 .010 .010 .006 .005 .005 .003 .002 
				  .002 .002 .001 .001 .001 .000 .001 .001 .000 .000)
			  ind 0 "dlocsig 12 0")
	  
	  (check-segments (vector .428 .499 .500 .244 .015 .018 .018 .007 .009 .007 
				  .012 .151 .355 .479 .499 .417 .044 .046 .042 .025 
				  .012 .012 .016 .071 .273 .036 .030 .035 .051 .049 
				  .031 .020 .014 .011 .011 .010 .009 .005 .002 .003 
				  .003 .002 .002 .001 .001 .001 .001 .001 .000 .000)
			  ind 1 "dlocsig 12 1")
	  
	  (check-segments (vector .000 .009 .013 .028 .411 .502 .484 .374 .175 .007 
				  .006 .023 .043 .050 .049 .041 .252 .488 .488 .421 
				  .252 .015 .003 .012 .031 .052 .058 .043 .015 .015 
				  .013 .009 .005 .010 .010 .006 .005 .005 .003 .002 
				  .002 .002 .001 .001 .001 .000 .001 .001 .000 .000)
			  ind 2 "dlocsig 12 2")
	  
	  (check-segments (vector .000 .011 .331 .493 .487 .149 .018 .007 .009 .007 
				  .012 .026 .036 .036 .137 .473 .480 .315 .042 .025 
				  .012 .012 .016 .024 .034 .036 .030 .035 .051 .049 
				  .031 .020 .014 .011 .011 .010 .009 .005 .002 .003 
				  .003 .002 .002 .001 .001 .001 .001 .001 .000 .000)
			  ind 3 "dlocsig 12 3")
	  
	  (check-segments (vector .000 .009 .013 .028 .020 .032 .277 .443 .502 .502 
				  .430 .244 .043 .050 .049 .041 .021 .011 .198 .397 
				  .492 .496 .464 .318 .082 .052 .058 .043 .015 .015 
				  .013 .009 .005 .010 .010 .006 .005 .005 .003 .002 
				  .002 .002 .001 .001 .001 .000 .001 .001 .000 .000)
			  ind 4 "dlocsig 12 4")
	  
	  
	  (set-speaker-configuration (arrange-speakers :speakers '(-45 45 90 135 225) 
						       :delays '(.010 .020 .030 .040 .050)
						       :channel-map '(4 3 2 1 0)))
	  
	  (with-sound (:channels 5 :reverb freeverb :reverb-channels 5) (dloc-sinewave 0 1.0 440 .5 :path (make-spiral-path :turns 2)))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .035 .279 .442 .483 .480 
				  .393 .207 .040 .018 .012 .012 .009 .003 .187 .393 
				  .482 .484 .441 .284 .061 .029 .011 .012 .011 .005 
				  .005 .006 .006 .003 .004 .004 .002 .002 .002 .001 
				  .001 .001 .001 .000 .000 .000 .000 .000 .000 .000)
			  ind 0 "dlocsig 13 0")
	  
	  (check-segments (vector .000 .000 .000 .000 .409 .500 .490 .380 .173 .035 
				  .035 .025 .030 .045 .046 .041 .243 .497 .497 .440 
				  .264 .035 .036 .031 .024 .039 .045 .043 .030 .014 
				  .008 .011 .011 .010 .007 .003 .002 .003 .003 .002 
				  .002 .001 .001 .001 .001 .001 .000 .000 .000 .000)
			  ind 1 "dlocsig 13 1")
	  
	  (check-segments (vector .000 .000 .327 .500 .494 .148 .004 .005 .022 .043 
				  .051 .050 .041 .018 .164 .501 .505 .323 .004 .002 
				  .013 .033 .048 .048 .045 .029 .011 .012 .011 .005 
				  .005 .006 .006 .003 .004 .004 .002 .002 .002 .001 
				  .001 .001 .001 .000 .000 .000 .000 .000 .000 .000)
			  ind 2 "dlocsig 13 2")
	  
	  (check-segments (vector .428 .499 .499 .249 .000 .000 .004 .011 .024 .035 
				  .035 .181 .406 .525 .534 .439 .023 .011 .012 .016 
				  .025 .035 .036 .088 .311 .039 .045 .043 .030 .014 
				  .008 .011 .011 .010 .007 .003 .002 .003 .003 .002 
				  .002 .001 .001 .001 .001 .001 .000 .000 .000 .000)
			  ind 3 "dlocsig 13 3")
	  
	  (check-segments (vector .350 .194 .000 .000 .000 .000 .004 .008 .256 .436 
				  .511 .511 .453 .277 .035 .012 .009 .003 .004 .002 
				  .171 .380 .497 .511 .489 .029 .011 .012 .011 .005 
				  .005 .006 .006 .003 .004 .004 .002 .002 .002 .001 
				  .001 .001 .001 .000 .000 .000 .000 .000 .000 .000)
			  ind 4 "dlocsig 13 4")
	  
	  
	  (with-sound (:channels 4) 
		      (dlocsig-sinewave-1 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f) :decode b-format-ambisonics))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .008 .008 .009 .009 .010 .011 .012 
				  .013 .014 .016 .018 .020 .023 .027 .032 .039 .048 
				  .063 .086 .129 .215 .374 .437 .440 .398 .252 .141 
				  .094 .067 .052 .041 .034 .029 .025 .022 .019 .017 
				  .015 .014 .013 .011 .011 .010 .009 .008 .008)
			  ind 0 "dlocsig 14 0")
	  
	  (check-segments (vector .000 .000 .000 .007 .008 .008 .009 .009 .010 .011 
				  .012 .013 .014 .015 .017 .019 .022 .025 .029 .036 
				  .045 .062 .097 .180 .342 .337 .326 .275 .160 .075 
				  .048 .035 .029 .025 .021 .019 .017 .016 .014 .013 
				  .012 .011 .011 .010 .009 .009 .008 .008 .008)
			  ind 1 "dlocsig 14 1")
	  
	  (check-segments (vector .000 .000 .000 .008 .008 .009 .010 .011 .012 .013 
				  .014 .016 .018 .021 .023 .027 .032 .038 .047 .058 
				  .076 .105 .155 .244 .362 .301 .301 .424 .317 .185 
				  .124 .088 .067 .053 .043 .036 .030 .026 .023 .020 
				  .018 .016 .014 .013 .012 .010 .010 .009 .008)
			  ind 2 "dlocsig 14 2")
	  
	  (check-segments (vector .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 
				  .000 .000 .000 .000 .000 .000 .000 .000 .000)
			  ind 3 "dlocsig 14 3")
	  
	  
	  (with-sound (:channels 4) 
		      (dlocsig-sinewave-1 0 1.0 440 .5 :path (make-path '((-10 10) (0.5 0.5) (10 10)) :3d #f) :decode decoded-ambisonics))
	  (set! ind (find-sound "test.snd"))
	  
	  (check-segments (vector .000 .000 .000 .011 .012 .013 .014 .015 .016 .018 .020 
				  .022 .024 .027 .030 .035 .041 .048 .058 .071 .092 .126 
				  .190 .319 .529 .509 .385 .179 .047 .015 .009 .007 .007 
				  .006 .006 .006 .006 .006 .005 .005 .005 .005 .005 .004 
				  .004 .004 .004 .004 .004)
			  ind 0 "dlocsig 15 0")
	  
	  (check-segments (vector .000 .000 .000 .004 .004 .004 .004 .004 .005 .005 .005 
				  .006 .006 .006 .007 .008 .008 .009 .011 .013 .016 .022 
				  .036 .075 .199 .372 .491 .516 .365 .200 .133 .095 .074 
				  .059 .049 .042 .036 .032 .028 .025 .022 .021 .019 .017 
				  .016 .015 .014 .013 .012)
			  ind 1 "dlocsig 15 1")
	  
	  (check-segments (vector .000 .000 .000 .004 .004 .004 .005 .005 .005 .006 .006 
				  .007 .008 .009 .010 .011 .013 .015 .019 .023 .029 .040 
				  .061 .105 .175 .130 .214 .258 .204 .126 .085 .060 .045 
				  .035 .028 .023 .019 .016 .014 .012 .010 .009 .008 .007 
				  .006 .006 .005 .005 .004)
			  ind 2 "dlocsig 15 2")
	  
	  (check-segments (vector .000 .000 .000 .004 .004 .005 .005 .006 .006 .007 .008 
				  .009 .010 .012 .013 .016 .019 .023 .028 .036 .047 .064 
				  .093 .139 .187 .172 .087 .165 .113 .059 .039 .028 .022 
				  .018 .015 .013 .011 .010 .009 .008 .007 .007 .006 .006 
				  .005 .005 .004 .004 .004)
			  ind 3 "dlocsig 15 3")
	  ))); end dlocsig tests
  
  (let ((a4 (->frequency 'a4))
	(a440 (->frequency 440.0))
	(cs5 (->frequency 'cs5))
	(df3 (->frequency 'df3))
	(c1 (->frequency 'cn1))
	(b8 (->frequency 'b8)))
    (if (fneq a4 440.0) (snd-display #__line__ ";a4->frequency: ~A" a4))
    (if (fneq a440 440.0) (snd-display #__line__ ";a440->frequency: ~A" a440))
    (if (fneq cs5 554.365) (snd-display #__line__ ";cs5->frequency: ~A" cs5))
    (if (fneq df3 138.591) (snd-display #__line__ ";df3->frequency: ~A" df3))
    (if (fneq c1 32.703) (snd-display #__line__ ";c1->frequency: ~A" c1))
    (if (fneq b8 7902.132) (snd-display #__line__ ";b8->frequency: ~A" b8)))
  
  (let ((violins (make-sample->file "violins.snd" 1 mus-lfloat mus-next))
	(cellos (make-sample->file "cellos.snd" 1 mus-lfloat mus-next)))
    
    (define (violin beg dur freq amp)
      (with-temp-sound (:continue-old-file #t :output "violins.snd") 
		       (fm-violin beg dur (->frequency freq #t) amp)))
    
    (define (cello beg dur freq amp)
      (with-temp-sound (:continue-old-file #t :output "cellos.snd") 
		       (fm-violin beg dur (->frequency freq #t) amp :fm-index 1.5)))
    
    (violin 0 1 'e4 .2)  (violin 1 1.5 'g4 .2)   (violin 2.5 .5 'g3 .2)
    (cello  0 1 'c3 .2)  (cello  1 1.5 'e3 .2)  (cello  2.5 .5 'g2 .2)
    
    (let* ((index (new-sound "test.snd" :channels 1)) ; our overall output file
	   (vs1 (mix "violins.snd"))
	   (cs1 (mix "cellos.snd"))
	   (vs (and (pair? vs1) (car vs1)))
	   (cs (and (pair? cs1) (car cs1))))
      
      (mus-close violins)
      (mus-close cellos)
      
      (if (mix? vs)
	  (let ((vsr (make-mix-sampler vs))
		(csr (make-mix-sampler cs))
		(fsr (make-sampler 0 index)))
	    
	    (do ((i 0 (+ 1 i)))
		((= i 1000))
	      (let ((v (vsr))
		    (c (csr))
		    (f (fsr)))
		(if (fneq f (+ c v))
		    (snd-display #__line__ ";multi temp output: ~A != ~A + ~A" f v c))))
	    
	    (free-sampler vsr)
	    (free-sampler csr)
	    (free-sampler fsr)))
      
      (close-sound index)
      (if (file-exists? "violins.snd") (delete-file "violins.snd"))  
      (if (file-exists? "cellos.snd") (delete-file "cellos.snd"))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-vct 2210)) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (fneq (vct-peak v1) .1) (snd-display #__line__ ";with-sound -> vct fm-violin maxamp (opt): ~A" (vct-peak v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-vct 2210)) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
	(if (fneq (vct-peak v2) .1) (snd-display #__line__ ";with-sound -> vct fm-violin maxamp: ~A" (vct-peak v2)))
	(if (not (vequal v1 v2)) (snd-display #__line__ ";with-sound -> vct v1 v2 not equal?"))
	(set! (optimization) 6)
	(sound-let ((tmp () (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)))
		   (let ((v3 (make-vct 2210)))
		     (file->array tmp 0 0 2205 v3)
		     (if (not (vequal v1 v3)) (snd-display #__line__ ";with-sound -> vct v1 v3 not equal?"))))
	(with-sound (:output v1)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
	(if (fneq (vct-peak v1) .2) (snd-display #__line__ ";with-sound -> vct fm-violin maxamp (opt 2): ~A" (vct-peak v1))))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 1 2210)) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (fneq (car (sound-data-maxamp v1)) .1) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 1 2210)) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
	(if (fneq (car (sound-data-maxamp v2)) .1) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp: ~A" (sound-data-maxamp v2)))
	(if (not (sd-equal v1 v2)) (snd-display #__line__ ";with-sound -> sound-data v1 v2 not equal?"))
	(set! (optimization) 6)
	(with-sound (:output v1)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
	(if (fneq (car (sound-data-maxamp v1)) .2) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  (let ((oldopt (optimization)))
    (set! (locsig-type) mus-interp-linear)
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 2 2210))
			  (if (not (= (mus-channels *output*) 2)) (snd-display #__line__ ";with-sound *output* chans: ~A" (mus-channels *output*)))
			  (fm-violin 0 .1 440 .1 :degree 45 :random-vibrato-amplitude 0.0))))
      (if (fneq (car (sound-data-maxamp v1)) .05) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (1 opt): ~A" (sound-data-maxamp v1)))
      (if (fneq (cadr (sound-data-maxamp v1)) .05) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (2 opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 2 2210)) 
			    (fm-violin 0 .1 440 .1 :degree 45 :random-vibrato-amplitude 0.0))))
	(if (fneq (car (sound-data-maxamp v2)) .05) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (2): ~A" (sound-data-maxamp v2)))
	(if (fneq (cadr (sound-data-maxamp v2)) .05) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (2 2): ~A" (sound-data-maxamp v2)))
	(if (not (sd-equal v1 v2)) (snd-display #__line__ ";with-sound (2 chans) -> sound-data v1 v2 not equal?"))
	(set! (optimization) 6)
	(with-sound (:output v1)
		    (fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
		    (fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0))
	(if (fneq (car (sound-data-maxamp v1)) .2) (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-vct 2210) :scaled-to .3) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (fneq (vct-peak v1) .3) 
	  (snd-display #__line__ ";with-sound -> vct fm-violin maxamp (opt, scaled-to): ~A" (vct-peak v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-vct 2210) :scaled-to .3) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
	(if (fneq (vct-peak v2) .3) 
	    (snd-display #__line__ ";with-sound -> vct fm-violin maxamp scaled-to: ~A" (vct-peak v2)))
	(if (not (vequal v1 v2)) (snd-display #__line__ ";with-sound (scaled-to) -> vct v1 v2 not equal?"))
	(set! (optimization) 6)
	(with-sound (:output v1 :scaled-by 2.0)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
	(if (fneq (vct-peak v1) .4) (snd-display #__line__ ";with-sound -> vct fm-violin maxamp (opt 2 scaled-by): ~A" (vct-peak v1))))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 1 2210) :scaled-to .5) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (fneq (car (sound-data-maxamp v1)) .5) 
	  (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (opt, scaled-to): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 1 2210) :scaled-to .5) (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
	(if (fneq (car (sound-data-maxamp v2)) .5) 
	    (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp scaled-to: ~A" (sound-data-maxamp v2)))
	(if (not (sd-equal v1 v2)) (snd-display #__line__ ";with-sound scaled-to -> sound-data v1 v2 not equal?"))
	(set! (optimization) 6)
	(with-sound (:output v1 :scaled-by 0.5)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)
		    (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
	(if (fneq (car (sound-data-maxamp v1)) .1) 
	    (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (opt 2 scaled-by): ~A" (sound-data-maxamp v1))))))
  
  (let ((stats-string ""))
    (let ((v1 (with-sound (:output (make-vct 2210) :statistics (lambda (str) (set! stats-string str)))
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (and (not (string=? stats-string "\n;vct:\n  maxamp: 0.1000\n  compute time: 0.000\n"))
	       (not (string=? stats-string "\n;vct:\n  maxamp: 0.1000\n  compute time: 0.001\n"))
	       (not (string=? stats-string "\n;vct:\n  maxamp: 0.1000\n  compute time: 0.002\n"))
	       (not (string=? stats-string "\n;vct:\n  maxamp: 0.1000\n  compute time: 0.010\n"))
	       (not (string=? stats-string "\n;vct:\n  maxamp: 0.1000\n  compute time: 0.180\n")))
	  (snd-display #__line__ ";with-sound to vct stats: [~A]" stats-string)))
    (let ((v1 (with-sound (:output (make-sound-data 1 2210) :scaled-to .5 :statistics (lambda (str) (set! stats-string str)))
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (and (not (string=? stats-string "\n;sound-data:\n  maxamp (before scaling): 0.1000\n  compute time: 0.000\n"))
	       (not (string=? stats-string "\n;sound-data:\n  maxamp (before scaling): 0.1000\n  compute time: 0.001\n"))
	       (not (string=? stats-string "\n;sound-data:\n  maxamp (before scaling): 0.1000\n  compute time: 0.002\n"))
	       (not (string=? stats-string "\n;sound-data:\n  maxamp (before scaling): 0.1000\n  compute time: 0.010\n")))
	  (snd-display #__line__ ";with-sound to sound-data stats: [~A]" stats-string)))
    
    (with-sound (:output (make-sound-data 4 2210) :channels 4 :statistics (lambda (str) (set! stats-string str)))
		(fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
		(fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
		(fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
		(fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))
    )
  
  (for-each
   (lambda (n)
     (set! (optimization) n)
     
     ;; testing overwrites here -- just hope we don't crash...
     (let ((v1 (with-sound (:output (make-vct 20) :channels 1)
			   (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
       (if (fneq (vct-ref v1 0) 0.0) (snd-display #__line__ ";overwrite vct with-sound: ~A (~A)" (vct-ref v1 0) (vct-peak v1))))
     
     (let ((v1 (with-sound (:output (make-vct 20) :channels 4)
			   (fm-violin 0 .1 440 .1 :degree 45 :random-vibrato-amplitude 0.0))))
       (if (fneq (vct-ref v1 0) 0.0) (snd-display #__line__ ";overwrite vct with-sound (4): ~A (~A)" (vct-ref v1 0) (vct-peak v1))))
     
     (let ((v1 (with-sound (:output (make-sound-data 4 20) :channels 4)
			   (fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))))
       (do ((i 0 (+ 1 i))) ((= i 4))
	 (if (fneq (sound-data-ref v1 i 0) 0.0) (snd-display #__line__ ";overwrite sd ~D with-sound: ~A" i (sound-data-ref v1 i 0)))))
     
     (let ((v1 (with-sound (:output (make-sound-data 2 20) :channels 4)
			   (fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))))
       (do ((i 0 (+ 1 i))) ((= i 2))
	 (if (fneq (sound-data-ref v1 i 0) 0.0) (snd-display #__line__ ";overwrite sd (2) ~D with-sound: ~A" i (sound-data-ref v1 i 0)))))
     
     (let ((v1 (with-sound (:output (make-sound-data 4 20) :channels 1)
			   (fm-violin 0 .1 440 .1 :degree 0 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .2 :degree 90 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .3 :degree 180 :random-vibrato-amplitude 0.0)
			   (fm-violin 0 .1 440 .4 :degree 270 :random-vibrato-amplitude 0.0))))
       (do ((i 0 (+ 1 i))) ((= i 4))
	 (if (fneq (sound-data-ref v1 i 0) 0.0) (snd-display #__line__ ";overwrite sd (4) ~D with-sound: ~A" i (sound-data-ref v1 i 0)))))
     )
   (list 0 3 6))
  
  ;; reverb cases parallel to above
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-vct 44100) :reverb jc-reverb)
			  (if (not (= (mus-length *output*) 44100)) (snd-display #__line__ ";ws mus-length vct: ~A" (mus-length *output*)))
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0 :reverb-amount 0.9)))
	  (v4 (with-sound (:output (make-vct 44100)) 
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (vequal v1 v4) (snd-display #__line__ ";reverb output not written to vct?"))
      (if (< (vct-peak v1) .29)
	  (snd-display #__line__ ";rev with-sound -> vct fm-violin maxamp (opt): ~A" (vct-peak v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-vct 44100) :reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
	(if (< (vct-peak v2) .29) 
	    (snd-display #__line__ ";rev with-sound -> vct fm-violin maxamp: ~A" (vct-peak v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :channels 1 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))
	(if (< (vct-peak v1) .29) 
	    (snd-display #__line__ ";rev with-sound -> vct fm-violin maxamp (opt 2): ~A" (vct-peak v1))))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 1 44100) :reverb jc-reverb) 
			  (if (not (= (mus-length *output*) 44100)) (snd-display #__line__ ";ws mus-length sd: ~A" (mus-length *output*)))
			  (fm-violin 0 .1 440 .1 :reverb-amount 0.9 :random-vibrato-amplitude 0.0)))
	  (v4 (with-sound (:output (make-sound-data 1 44100)) 
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (sd-equal v1 v4) (snd-display #__line__ ";reverb output not written to sd?"))
      (if (< (car (sound-data-maxamp v1)) .23) 
	  (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp (opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 1 44100) :reverb jc-reverb) (fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
	(if (< (car (sound-data-maxamp v2)) .23) 
	    (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp: ~A" (sound-data-maxamp v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))
	(if (< (car (sound-data-maxamp v1)) .55) 
	    (snd-display #__line__ ";with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  (let ((oldopt (optimization)))
    (set! (locsig-type) mus-interp-linear)
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 2 44100) :reverb jc-reverb)
			  (if (not (= (mus-channels *output*) 2)) 
			      (snd-display #__line__ ";rev with-sound *output* chans: ~A" (mus-channels *output*)))
			  (fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
      (if (< (car (sound-data-maxamp v1)) .23) 
	  (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp (1 opt): ~A" (sound-data-maxamp v1)))
      (if (< (cadr (sound-data-maxamp v1)) .23) 
	  (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp (2 opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 2 44100) :reverb jc-reverb) 
			    (fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
	(if (< (car (sound-data-maxamp v2)) .23) 
	    (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp (2): ~A" (sound-data-maxamp v2)))
	(if (< (cadr (sound-data-maxamp v2)) .23) 
	    (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp (2 2): ~A" (sound-data-maxamp v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9))
	(if (< (car (sound-data-maxamp v1)) .56) 
	    (snd-display #__line__ ";rev with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-vct 44100) :revfile (make-vct 44100) :reverb jc-reverb)
			  (if (not (= (mus-length *output*) 44100)) (snd-display #__line__ ";1 ws mus-length vct: ~A" (mus-length *output*)))
			  (if (not (= (mus-length *reverb*) 44100)) (snd-display #__line__ ";1 ws mus-length vct rev: ~A" (mus-length *reverb*)))
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0 :reverb-amount 0.9)))
	  (v4 (with-sound (:output (make-vct 44100)) 
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (vequal v1 v4) (snd-display #__line__ ";1 reverb output not written to vct?"))
      (if (< (vct-peak v1) .28)
	  (snd-display #__line__ ";1 rev with-sound -> vct fm-violin maxamp (opt): ~A" (vct-peak v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-vct 44100) :revfile (make-vct 44100) :reverb jc-reverb) 
			    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
	(if (< (vct-peak v2) .28) 
	    (snd-display #__line__ ";1 rev with-sound -> vct fm-violin maxamp: ~A" (vct-peak v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :revfile v2 :channels 1 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))
	(if (< (vct-peak v1) .28) 
	    (snd-display #__line__ ";1 rev with-sound -> vct fm-violin maxamp (opt 2): ~A" (vct-peak v1))))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 1 44100) :revfile (make-sound-data 1 44100) :reverb jc-reverb) 
			  (if (not (= (mus-length *output*) 44100)) (snd-display #__line__ ";ws mus-length sd: ~A" (mus-length *output*)))
			  (fm-violin 0 .1 440 .1 :reverb-amount 0.9 :random-vibrato-amplitude 0.0)))
	  (v4 (with-sound (:output (make-sound-data 1 44100)) 
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (sd-equal v1 v4) (snd-display #__line__ ";2 reverb output not written to sd?"))
      (if (< (car (sound-data-maxamp v1)) .28) 
	  (snd-display #__line__ ";2 rev with-sound -> sound-data fm-violin maxamp (opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 1 44100) :revfile (make-sound-data 1 44100) :reverb jc-reverb) 
			    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
	(if (< (car (sound-data-maxamp v2)) .28) 
	    (snd-display #__line__ ";2 rev with-sound -> sound-data fm-violin maxamp: ~A" (sound-data-maxamp v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :revfile v2 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))
	(if (< (car (sound-data-maxamp v1)) .54) 
	    (snd-display #__line__ ";2 with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  (let ((oldopt (optimization)))
    (set! (optimization) 0)
    (let ((v1 (with-sound (:output (make-sound-data 1 44100) :revfile (make-sound-data 1 44100) :reverb jc-reverb) 
			  (if (not (= (mus-length *output*) 44100)) (snd-display #__line__ ";ws mus-length sd: ~A" (mus-length *output*)))
			  (fm-violin 0 .1 440 .1 :reverb-amount 0.9 :random-vibrato-amplitude 0.0)))
	  (v4 (with-sound (:output (make-sound-data 1 44100)) 
			  (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))))
      (if (sd-equal v1 v4) (snd-display #__line__ ";2 reverb output not written to sd?"))
      (if (< (car (sound-data-maxamp v1)) .28) 
	  (snd-display #__line__ ";2 rev with-sound -> sound-data fm-violin maxamp (opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 1 44100) :revfile (make-sound-data 1 44100) :reverb jc-reverb) 
			    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))))
	(if (< (car (sound-data-maxamp v2)) .28) 
	    (snd-display #__line__ ";2 rev with-sound -> sound-data fm-violin maxamp: ~A" (sound-data-maxamp v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :revfile v2 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :reverb-amount 0.9))
	(if (< (car (sound-data-maxamp v1)) .5) 
	    (snd-display #__line__ ";2 with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  (let ((oldopt (optimization)))
    (set! (locsig-type) mus-interp-linear)
    (set! (optimization) 6)
    (let ((v1 (with-sound (:output (make-sound-data 2 44100) :revfile (make-sound-data 1 44100) :reverb jc-reverb)
			  (if (not (= (mus-channels *output*) 2)) 
			      (snd-display #__line__ ";3 rev with-sound *output* chans: ~A" (mus-channels *output*)))
			  (fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
      (if (< (car (sound-data-maxamp v1)) .23) 
	  (snd-display #__line__ ";3 rev with-sound -> sound-data fm-violin maxamp (1 opt): ~A" (sound-data-maxamp v1)))
      (if (< (cadr (sound-data-maxamp v1)) .23) 
	  (snd-display #__line__ ";3 rev with-sound -> sound-data fm-violin maxamp (2 opt): ~A" (sound-data-maxamp v1)))
      (set! (optimization) 0)
      (let ((v2 (with-sound (:output (make-sound-data 2 44100) :revfile (make-sound-data 1 44100) :reverb jc-reverb) 
			    (fm-violin 0 .1 440 .1 :degree 45 :reverb-amount 0.9))))
	(if (< (car (sound-data-maxamp v2)) .23) 
	    (snd-display #__line__ ";3 rev with-sound -> sound-data fm-violin maxamp (2): ~A" (sound-data-maxamp v2)))
	(if (< (cadr (sound-data-maxamp v2)) .23) 
	    (snd-display #__line__ ";3 rev with-sound -> sound-data fm-violin maxamp (2 2): ~A" (sound-data-maxamp v2)))
	(set! (optimization) 6)
	(with-sound (:output v1 :revfile v2 :reverb jc-reverb)
		    (fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9)
		    (fm-violin 0 .1 440 .1 :degree 0 :reverb-amount 0.9))
	(if (< (car (sound-data-maxamp v1)) .56) 
	    (snd-display #__line__ ";3 rev with-sound -> sound-data fm-violin maxamp (opt 2): ~A" (sound-data-maxamp v1))))))
  
  
  (let ((oldopt (optimization)))
    (for-each
     (lambda (n)
       (set! (optimization) n)
       (let ((v1 (with-sound (:output (make-vct 44100))
			     (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0)))
	     (v2 (with-sound (:output (make-vct 400))
			     (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0)))
	     (v3 (with-sound (:output (make-vct 400))
			     (simple-outn 0 .1 440 0.0 .5 0.0 0.0 0.0 0.0)))
	     (v4 (with-sound (:output (make-vct 44100) :reverb jc-reverb)
			     (simple-outn 0 .1 440 0.2 0.0 0.0 0.0 0.05 0.0)))
	     (v5 (with-sound (:output (make-vct 44100) :reverb simple-in-rev :reverb-data '(0.0 1.0 1.0 0.0))
			     (simple-outn 0 .1 440 0.0 0.0 0.0 0.0 0.5 0.0)))
	     (v6 (with-sound (:output (make-vct 400))
			     (simple-outn 0 .1 440 0.5 0.0 0.0 0.0 0.0 0.0)
			     (simple-outn 0 .1 440 0.2 0.0 0.0 0.0 0.0 0.0)))
	     (sd1 (with-sound (:output (make-sound-data 1 44100))
			      (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0)))
	     (sd2 (with-sound (:output (make-sound-data 4 44100))
			      (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0)))
	     (sd3 (with-sound (:output (make-sound-data 2 44100))
			      (simple-outn 0 .1 440 0.0 0.0 .3 .4 0.0 0.0)))
	     (sd4 (with-sound (:output (make-sound-data 4 44100) :reverb simple-in-rev :reverb-channels 2 :reverb-data '(0.0 1.0 1.0 1.0))
			      (simple-outn 0 .1 440 0.0 0.0 0.0 0.0 0.5 0.25)))
	     (sd5 (with-sound (:output (make-sound-data 4 44100) :reverb simple-in-rev :reverb-channels 1 :reverb-data '(0.0 1.0 1.0 1.0))
			      (simple-outn 0 .1 440 0.0 0.0 0.0 0.0 0.5 0.25)))
	     (sd6 (with-sound (:output (make-sound-data 4 44100))
			      (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0)
			      (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0))))
	 (if (fneq (vct-peak v1) 0.1) (snd-display #__line__ ";outa tests 1 ~A: ~A" n (vct-peak v1)))
	 (if (fneq (vct-peak v2) 0.1) (snd-display #__line__ ";outa tests 2 ~A: ~A" n (vct-peak v2)))
	 (if (fneq (vct-peak v3) 0.0) (snd-display #__line__ ";outa tests 3 ~A: ~A" n (vct-peak v3)))
	 (if (< (vct-peak v4) 0.2) (snd-display #__line__ ";outa tests 4 ~A: ~A" n (vct-peak v4)))
	 (if (fneq (vct-peak v5) 0.5) (snd-display #__line__ ";outa tests 5 ~A: ~A" n (vct-peak v5)))
	 (if (fneq (vct-peak v6) 0.7) (snd-display #__line__ ";outa tests 11 ~A: ~A" n (vct-peak v6)))
	 
	 (let ((mx1 (sound-data-maxamp sd1)))
	   (if (not (feql mx1 (list .1))) (snd-display #__line__ ";outa tests 6 ~A: ~A" n mx1)))	  
	 (let ((mx2 (sound-data-maxamp sd2)))
	   (if (not (feql mx2 (list .1 .2 .3 .4))) (snd-display #__line__ ";outa tests 7 ~A: ~A" n mx2)))
	 (let ((mx3 (sound-data-maxamp sd3)))
	   (if (not (feql mx3 (list 0.0 0.0))) (snd-display #__line__ ";outa tests 8 ~A: ~A" n mx3)))
	 (let ((mx4 (sound-data-maxamp sd4)))
	   (if (not (feql mx4 (list 0.5 0.25 0.0 0.0))) (snd-display #__line__ ";outa tests 9 ~A: ~A" n mx4)))
	 (let ((mx5 (sound-data-maxamp sd5)))
	   (if (not (feql mx5 (list 0.5 0.0 0.0 0.0))) (snd-display #__line__ ";outa tests 10 ~A: ~A" n mx5)))
	 (let ((mx6 (sound-data-maxamp sd6)))
	   (if (not (feql mx6 (list .2 .4 .6 .8))) (snd-display #__line__ ";outa tests 12 ~A: ~A" n mx6)))
	 
	 (with-sound (:output v1 :continue-old-file #t)
		     (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0))
	 (if (fneq (vct-peak v1) 0.2) (snd-display #__line__ ";outa tests 13 ~A: ~A" n (vct-peak v1)))
	 
	 (with-sound (:output sd2 :continue-old-file #t)
		     (simple-outn 0 .1 440 .1 .2 .3 .4 0.0 0.0))
	 (let ((mx7 (sound-data-maxamp sd2)))
	   (if (not (feql mx7 (list .2 .4 .6 .8))) (snd-display #__line__ ";outa tests 14 ~A: ~A" n mx7)))))
     (list 0 6))
    (set! (optimization) oldopt))
  
  (let* ((file (with-sound ()
			   (fm-violin 0 .1 880 .1 :random-vibrato-amplitude 0.0)
			   (let ((v1 (with-temp-sound (:output (make-vct 2210))
						      (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0)))
				 (sd1 (with-temp-sound (:output (make-sound-data 1 2210))
						       (fm-violin 0 .1 660 .1 :random-vibrato-amplitude 0.0))))
			     (do ((i 0 (+ 1 i)))
				 ((= i 2205))
			       (outa i (+ (vct-ref v1 i) (sound-data-ref sd1 0 i)))))
			   (fm-violin 0 .1 220.0 .1 :random-vibrato-amplitude 0.0)))
	 (ind (find-sound file)))
    (if (not (sound? ind))
	(snd-display #__line__ ";can't find mixed with-sound output")
	(let ((mx (maxamp ind 0)))
	  (if (< mx .35) (snd-display #__line__ ";mixed with-sound max: ~A" mx))
	  (if (not (vequal (channel->vct 1000 10) (vct 0.255 0.275 0.316 0.364 0.391 0.379 0.337 0.283 0.228 0.170)))
	      (snd-display #__line__ ";mixed with-sound: ~A" (channel->vct 1000 10)))
	  (close-sound ind))))
  
  (let* ((file (with-sound ()
			   (fm-violin 0 .1 880 .1 :random-vibrato-amplitude 0.0)
			   (sound-let ((v1 (:output (make-vct 2210))
					   (fm-violin 0 .1 440 .1 :random-vibrato-amplitude 0.0))
				       (sd1 (:output (make-sound-data 1 2210))
					    (fm-violin 0 .1 660 .1 :random-vibrato-amplitude 0.0))
				       (fs1 ()
					    (fm-violin 0 .1 110 .1 :random-vibrato-amplitude 0.0)))
				      (mus-mix *output* fs1)
				      (do ((i 0 (+ 1 i)))
					  ((= i 2205))
					(outa i (+ (vct-ref v1 i) (sound-data-ref sd1 0 i)))))
			   (fm-violin 0 .1 220.0 .1 :random-vibrato-amplitude 0.0)))
	 (ind (find-sound file)))
    (if (not (sound? ind))
	(snd-display #__line__ ";can't find mixed with-sound sound-let output")
	(let ((mx (maxamp ind 0)))
	  (if (< mx .375) (snd-display #__line__ ";mixed with-sound max: ~A" mx))
	  (if (not (vequal (channel->vct 1000 10) (vct 0.349 0.370 0.412 0.461 0.489 0.478 0.436 0.383 0.328 0.270)))
	      (snd-display #__line__ ";mixed with-sound via sound-let: ~A" (channel->vct 1000 10)))
	  (close-sound ind))))
  
  
  (let* ((res (with-mixed-sound () (fm-violin 0 .1 440 .1)))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";with-mixed-sound (1): ~A?" res))
    (let ((mxs (mixes snd 0))
	  (info (sound-property 'with-mixed-sound-info snd)))
      (if (not (list? mxs))
	  (snd-display #__line__ ";with-mixed-sound (1) mixes: ~A" mxs))
      (if (or (not (equal? (car (list-ref info 0)) (car mxs)))
	      (not (= (cadr (list-ref info 0)) 0))
	      (not (= (caddr (list-ref info 0)) 1)))
	  (snd-display #__line__ ";with-mixed-sound info (1) 0: ~A" (list-ref info 0)))
      (if (ffneq (maxamp snd) .1)
	  (snd-display #__line__ ";with-mixed-sound (1) 0: ~A" (maxamp snd)))
      (close-sound snd)))
  
  (let* ((res (with-mixed-sound (:srate 44100) 
				(fm-violin 0 .1 440 .1) 
				(fm-violin 1 .1 660 .1)))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";with-mixed-sound (2): ~A?" res))
    (let ((mxs (mixes snd 0))
	  (info (sound-property 'with-mixed-sound-info snd)))
      (if (or (not (list? mxs))
	      (not (= (length mxs) 2)))
	  (snd-display #__line__ ";with-mixed-sound mixes (2): ~A" mxs))
      (if (or (not (equal? (car (list-ref info 0)) (car mxs)))
	      (not (= (cadr (list-ref info 0)) 0))
	      (not (= (caddr (list-ref info 0)) 1)))
	  (snd-display #__line__ ";with-mixed-sound info (2) 0: ~A" (list-ref info 0)))
      (if (or (not (equal? (car (list-ref info 1)) (cadr mxs)))
	      (not (= (cadr (list-ref info 1)) 44100))
	      (not (= (caddr (list-ref info 1)) 1)))
	  (snd-display #__line__ ";with-mixed-sound info (2) 1: ~A" (list-ref info 1)))
      (if (or (not (= (frames snd) 48510))
	      (fneq (maxamp snd) .1))
	  (snd-display #__line__ ";with-mixed-sound 0 (2): ~A ~A" (frames snd) (maxamp snd)))
      (close-sound snd)))
  
  (let* ((res (with-mixed-sound (:channels 2 :srate 44100) 
				(fm-violin 0 .1 440 .1 :degree 0) 
				(fm-violin 1 .1 660 .1 :degree 45)))
	 (snd (find-sound res))
	 (mxs (mixes snd))
	 (info (sound-property 'with-mixed-sound-info snd)))
    (if (or (not (= (length mxs) 2))
	    (not (= (length (car mxs)) 2))
	    (not (= (length info) 2))
	    (not (equal? (caar info) (caar mxs))))
	(snd-display #__line__ ";with-mixed-sound (3) 1: ~A ~A" mxs info))
    (close-sound snd))
  
  (let* ((res (with-marked-sound () 
				 (fm-violin 0 .1 440 .1) 
				 (fm-violin 1 .1 660 .1)))
	 (snd (find-sound res))
	 (mxs (marks snd 0)))
    (if (not (= (length mxs) 2))
	(snd-display #__line__ ";with-marked-sound marks: ~A " mxs))
    (if (not (string=? (mark-name (car mxs)) "fm-violin 0 0.1"))
	(snd-display #__line__ ";with-marked-sound name: ~A" (mark-name (car mxs))))
    (if (fneq (maxamp snd) .1)
	(snd-display #__line__ ";with-marked-sound maxamp: ~A" (maxamp snd)))
    (close-sound snd))
  
  (reset-hook! mark-click-hook)
  (reset-hook! mix-click-hook)
  (reset-hook! mix-drag-hook)
  
  
  ;; generators.scm
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-ercos 100 :r 1.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (ercos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";ercos: ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";ercos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)  
			  (let ((gen (make-ercos 100 :r 0.1))
				(t-env (make-env '(0 .1 1 2) :length 20000)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (set! (ercos-r gen) (env t-env))
			       (set! (ercos-cosh-t gen) (cosh (ercos-r gen)))
			       (let ((exp-t (exp (- (ercos-r gen)))))
				 (set! (ercos-offset gen) (/ (- 1.0 exp-t) (* 2.0 exp-t)))
				 (set! (ercos-scaler gen) (* (sinh (ercos-r gen)) (ercos-offset gen))))
			       (outa i (ercos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";ercos 1: ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";ercos 1 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-erssb 1000.0 0.1 1.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (erssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";erssb: ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";erssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-noddsin 100 :n 10)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (noddsin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";noddsin: ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";noddsin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-noddcos 100 :n 10)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (noddcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";noddcos: ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";noddcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-noddssb 1000.0 0.1 5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (noddssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";noddssb: ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";noddssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f) 
			  (let ((gen (make-asyfm 2000.0 :ratio .1))) 
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 1000))
			       (outa i (asyfm-J gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";asyfm-J ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";asyfm-J max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f) 
			  (let ((gen (make-asyfm 2000.0 :ratio .1 :index 1))
				(r-env (make-env '(0 -4 1 -1) :length 20000)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (set! (asyfm-r gen) (env r-env))
			       (outa i (asyfm-J gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";asyfm-J1 ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";asyfm-J1 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f) 
			  (let ((gen (make-asyfm 2000.0 :ratio .1))) 
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 1000))
			       (outa i (asyfm-I gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";asyfm-I ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";asyfm-I max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :statistics #t)
			  (let ((gen (make-nrcos 400.0 :n 5 :r 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nrcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nrcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nrcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((samps 44100)
				(gen (make-noid 100.0 3 'min-peak)))
			    (do ((i 0 (+ 1 i)))
				((= i samps))
			      (outa i (noid gen))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";noid ~A" snd))
    (if (ffneq (maxamp snd) 0.6599) (snd-display #__line__ ";noid min-peak max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((samps 44100)
				(gen (make-noid 100.0 3 'max-peak)))
			    (do ((i 0 (+ 1 i)))
				((= i samps))
			      (outa i (noid gen))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";noid ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";noid max-peak max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nrcos 100 :n 15 :r 0.5))
				(indr (make-env '(0 -1 1 1) :length 40000 :scaler 0.9999)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 40000))
			       (set! (mus-scaler gen) (env indr)) 
			       (outa i (nrcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nrcos with scaler ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nrcos with scaler max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-ncos2 100.0 :n 10)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (ncos2 gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";ncos2 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";ncos2 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-ncos4 100.0 :n 10)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (ncos4 gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";ncos4 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";ncos4 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-npcos 100.0 :n 10)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (npcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";npcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";npcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-n1cos 100.0 :n 10)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (n1cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";n1cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";n1cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rcos 100.0 :r 0.5)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (rcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-bess 100.0 :n 0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 1000))
			       (outa i (bess gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";bess ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";bess max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen1 (make-bess 400.0 :n 1))
				(gen2 (make-bess 400.0 :n 1))
				(vol (make-env '(0 0 1 1 9 1 10 0) :scaler 2.0 :length 20000)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (bess gen1 (* (env vol) (bess gen2 0.0)))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";bess 1 ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";bess 1 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen1 (make-bess 400.0 :n 1))
				(gen2 (make-oscil 400.0))
				(vol (make-env '(0 1 1 0) :scaler 1.0 :length 20000)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (bess gen1 (* (env vol) (oscil gen2 0.0)))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";bess 2 ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";bess 2 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-eoddcos 400.0 :r 1.0)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (eoddcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";eoddcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";eoddcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-eoddcos 400.0 :r 0.0))
				(a-env (make-env '(0 0 1 1) :length 10000)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (set! (eoddcos-r gen) (env a-env))
			       (outa i (eoddcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";eoddcos 1 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";eoddcos 1 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen1 (make-eoddcos 400.0 :r 0.0))
				(gen2 (make-oscil 400.0))
				(a-env (make-env '(0 0 1 1) :length 10000)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (set! (eoddcos-r gen1) (env a-env))
			       (outa i (eoddcos gen1 (* .1 (oscil gen2)))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";eoddcos 2 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";eoddcos 2 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nssb 2000.0 0.05 3)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (* .3 (nssb gen))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nssb ~A" snd))
    (if (fneq (maxamp snd) 0.3) (snd-display #__line__ ";nssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nrssb 2000.0 0.05 3 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nrssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nrssb ~A" snd))
    (if (fneq (maxamp snd) 0.777) (snd-display #__line__ ";nrssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rkcos 440.0 :r 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rkcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rkcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rkcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rk!cos 440.0 :r 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rk!cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rk!cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rk!cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-r2k!cos 440.0 :r 0.5 :k 3.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (r2k!cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";r2k!cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";r2k!cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-k2sin 440.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (k2sin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";k2sin ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";k2sin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-k2cos 440.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (k2cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";k2cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";k2cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-k2ssb 1000.0 0.1)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (k2ssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";k2ssb ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";k2ssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rssb 1000 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rssb ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-dblsum 100 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (dblsum gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";dblsum ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";dblsum max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nkssb 1000.0 0.1 5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nkssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nkssb ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nkssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nkssb 1000.0 0.1 5))
				(vib (make-oscil 5.0))
				(vibamp (hz->radians 50.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 30000))
			       (outa i (nkssb gen (* vibamp (oscil vib)))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nkssb 1 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nkssb 1 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nkssb 1000.0 0.1 5))
				(move (make-env '(0 1 1 -1) :length 30000))
				(vib (make-oscil 5.0))
				(vibamp (hz->radians 50.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 30000))
			       (outa i (nkssb-interp gen (* vibamp (oscil vib)) (env move))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nkssb 2 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nkssb 2 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rkoddssb 1000.0 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rkoddssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rkoddssb ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rkoddssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-krksin 440.0 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (krksin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";krksin ~A" snd)))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-abcos 100.0 0.5 0.25)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (abcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";abcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";abcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :statistics #t)
			  (let ((gen (make-absin 100.0 0.5 0.25)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (absin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";absin ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";absin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-r2k2cos 100.0 1.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (r2k2cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";r2k2cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";r2k2cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-jjcos 100.0 :a 1.0 :r 1.0 :k 1)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (jjcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";jjcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";jjcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-j0evencos 100.0 1.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (j0evencos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";j0evencos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";j0evencos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rksin 100.0 :r 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rksin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rksin ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rksin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rkssb 1000.0 0.1 :r 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rkssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rkssb ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rkssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rk!ssb 1000.0 0.1 :r 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rk!ssb gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rk!ssb ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rk!ssb max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-jpcos 100.0 :a 1.0 :r 0.99 :k 1)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 210000))
			       (outa i (jpcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";jpcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";jpcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-j2cos 100.0 :r 1.0 :n 0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (j2cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";j2cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";j2cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nxysin 300 1/3 3)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nxysin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nxysin ~A" snd)))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nxycos 300 1/3 3)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nxycos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nxycos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nxycos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nxy1cos 300 1/3 3)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nxy1cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nxy1cos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nxy1cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nxy1sin 300 1/3 3)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (nxy1sin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nxy1sin ~A" snd))
    (if (fneq (maxamp snd) 0.951) (snd-display #__line__ ";nxy1sin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :statistics #t)
			  (let ((gen (make-nrxysin 1000 0.1 5 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 2000))
			       (outa i (nrxysin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nrxysin ~A" snd))
    (if (fneq (maxamp snd) 0.985) (snd-display #__line__ ";nrxysin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nrxycos 1000 0.1 5 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 2000))
			       (outa i (nrxycos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nrxycos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nrxycos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-nrxycos 1000 0.1 15 0.5))
				(indr (make-env '(0 -1 1 1) :length 40000 :scaler 0.9999)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 40000))
			       (set! (mus-scaler gen) (env indr)) 
			       (outa i (nrxycos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nrxycos with scaler ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nrxycos with scaler max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((black4 (make-blackman 440.0)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (blackman black4 0.0)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";blackman ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";blackman max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((black4 (make-sinc-train 440.0 10)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (sinc-train black4 0.0)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";sinc-train ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";sinc-train max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-k3sin 100.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (k3sin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";k3sin ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";k3sin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :statistics #t)
			  (let ((gen (make-izcos 100.0 1.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 30000))
			       (outa i (izcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";izcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";izcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rxysin 1000 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rxysin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rxysin ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rxysin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rxycos 1000 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rxycos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rxycos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rxycos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :srate 44100)
			  (let ((gen (make-safe-rxycos 1000 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (safe-rxycos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";safe-rxycos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";safe-rxycos max: ~A" (maxamp snd))))
  
  (let* ((base-r 0.0)
	 (end-r 0.0)
	 (res (with-sound (:clipped #f :channels 2 :srate 44100)
			  (let ((gen1 (make-safe-rxycos 1000 1 0.99))
				(gen2 (make-safe-rxycos 1000 1 0.99))
				(frqf (make-env '(0 0 1 1) :length 10000 :scaler (hz->radians 1000))))
			    (set! base-r (safe-rxycos-r gen1))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (let ((fm (env frqf)))
				 (set! (mus-frequency gen2) (+ 1000 (radians->hz fm)))
				 (outa i (safe-rxycos gen1 fm))
				 (outb i (safe-rxycos gen2 0.0))
				 (set! end-r (clamp-rxycos-r gen2 0.0))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";safe-rxycos 1 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";safe-rxycos 1 max: ~A" (maxamp snd)))
    (if (fneq base-r .588) (snd-display #__line__ ";safe-rxycos-r 1 base: ~A" base-r))
    (if (fneq end-r .316) (snd-display #__line__ ";safe-rxycos-r 1 end: ~A" end-r)))
  
  (let* ((base-r 0.0)
	 (end-r 0.0)
	 (res (with-sound (:clipped #f :channels 2 :srate 44100)
			  (let ((gen1 (make-safe-rxycos 1000 .1 0.99))
				(gen2 (make-safe-rxycos 1000 .1 0.99))
				(frqf (make-env '(0 0 1 1) :length 10000 :scaler (hz->radians 1000))))
			    (set! base-r (safe-rxycos-r gen1))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (let ((fm (env frqf)))
				 (set! (mus-frequency gen2) (+ 1000 (radians->hz fm)))
				 (outa i (safe-rxycos gen1 fm))
				 (outb i (safe-rxycos gen2 0.0))
				 (set! end-r (clamp-rxycos-r gen2 0.0))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";safe-rxycos 2 ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";safe-rxycos 2 max: ~A" (maxamp snd)))
    (if (fneq base-r .951) (snd-display #__line__ ";safe-rxycos-r 2 base: ~A" base-r))
    (if (fneq end-r .896) (snd-display #__line__ ";safe-rxycos-r 2 end: ~A" end-r)))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rxyk!sin 1000 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rxyk!sin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rxyk!sin ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";rxyk!sin max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-rxyk!cos 1000 0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (rxyk!cos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";rxyk!cos ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";rxyk!cos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :statistics #t :play #f)
			  (let ((gen (make-nsincos 100.0 3)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 20000))
			       (outa i (nsincos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nsincos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";nsincos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f :play #f)
			  (let ((gen (make-nchoosekcos 2000.0 0.05 10)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 30000))
			       (outa i (nchoosekcos gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";nchoosekcos ~A" snd))
    (if (ffneq (maxamp snd) 1.0) (snd-display #__line__ ";nchoosekcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound ()
			  (let ((gen (make-adjustable-square-wave 100 .2 .5)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 200))
			       (outa i (adjustable-square-wave gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";adj sq ~A" snd))
    (if (fneq (maxamp snd) 0.5) (snd-display #__line__ ";adj sq max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound ()
			  (let ((gen (make-adjustable-triangle-wave 100 .2 .5)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 22050))
			       (outa i (adjustable-triangle-wave gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";adj tri ~A" snd))
    (if (ffneq (maxamp snd) 0.5) (snd-display #__line__ ";adj tri max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound ()
			  (let ((gen (make-adjustable-sawtooth-wave 100 .2 .5)))
			    (run
			     (do ((i 0 (+ 1 i)))
				 ((= i 22050))
			       (outa i (adjustable-sawtooth-wave gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";adj saw ~A" snd))
    (if (ffneq (maxamp snd) 0.5) (snd-display #__line__ ";adj saw max: ~A" (maxamp snd))))
  
  (with-sound (:clipped #f) ; at least run the thing -- not sure how to test this automatically
	      (let* ((gen (make-pink-noise 12)))
		(run (lambda ()
		       (do ((i 0 (+ 1 i)))
			   ((= i 44100))
			 (outa i (pink-noise gen)))))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-brown-noise 100.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (brown-noise gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";brown-noise ~A" snd))
    (if (< (maxamp snd) 0.01) (snd-display #__line__ ";brown-noise max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-green-noise 100.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (green-noise gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";green-noise ~A" snd))
    (if (or (< (maxamp snd) 0.01) (> (maxamp snd) 1.0)) (snd-display #__line__ ";green-noise max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-green-noise 100.0 0.1 -0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (green-noise gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";green-noise .5 ~A" snd))
    (if (or (< (maxamp snd) 0.01) (> (maxamp snd) 0.5)) (snd-display #__line__ ";green-noise .5 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-green-noise-interp 100.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (green-noise-interp gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";green-noise-interp ~A" snd))
    (if (or (< (maxamp snd) 0.01) (> (maxamp snd) 1.0)) (snd-display #__line__ ";green-noise-interp max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-green-noise-interp 100.0 0.1 -0.1 0.5)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (green-noise-interp gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";green-noise-interp .5 ~A" snd))
    (if (or (< (maxamp snd) 0.01) (> (maxamp snd) 0.5)) (snd-display #__line__ ";green-noise-interp .5 max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen (make-tanhsin 440.0 2.0)))
			    (run 
			     (do ((i 0 (+ 1 i)))
				 ((= i 10000))
			       (outa i (tanhsin gen)))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";tanhsin ~A" snd))
    (if (> (abs (- 1.0 (maxamp snd))) 0.1) (snd-display #__line__ ";tanhsin max: ~A" (maxamp snd))))
  
  (if (not (provided? 'snd-nogui))
      (let* ((snd (new-sound))
	     (rd (make-readin "oboe.snd"))
	     (ft (make-moving-fft rd))
	     (data (make-vct 256)))
	(set! (lisp-graph?) #t)
	(do ((i 0 (+ i 1)))
	    ((= i 10000))
	  (moving-fft ft)
	  (vct-subseq (mus-xcoeffs ft) 0 255 data)
	  (graph data "fft" 0.0 11025.0 0.0 0.1 snd 0 #t))
	(close-sound snd)))
  
  (test-sv)
  
  (let* ((rd (make-readin "1a.snd"))
	 (cur-srate (mus-sound-srate "1a.snd"))
	 (old-srate (mus-srate)))
    (set! (mus-srate) cur-srate)
    (let* ((scn (make-moving-pitch rd))
	   (pitch (moving-pitch scn)))
      (if (or (> pitch 443.0)
	      (< pitch 439.0))
	  (snd-display #__line__ ";moving-pitch 1a: ~A" pitch)))
    (set! (mus-srate) old-srate))
  
  (let ((val (make-vector 3))
	(frq 0.0))
    (vector-set! val 0 (make-nrcos 100))  
    (vector-set! val 1 (make-nrcos 200))  
    (vector-set! val 2 (make-nrcos 300))
    (run
     (lambda ()
       (set! frq (mus-frequency (vector-ref val 1)))))
    (if (fneq frq 200.0) (snd-display #__line__ ";defgen vect freq: ~A" frq)))
  
  (let ((val (make-vector 3))
	(frq 0.0))
    (vector-set! val 0 (make-nrcos 100))  
    (vector-set! val 1 (make-nrcos 200))  
    (vector-set! val 2 (make-nrcos 300))
    (run
     (lambda ()
       (set! frq (+ (mus-frequency (vector-ref val 0))
		    (mus-frequency (vector-ref val 1))
		    (mus-frequency (vector-ref val 2))))))
    (if (fneq frq 600.0) (snd-display #__line__ ";defgen vect freq 1: ~A" frq)))
  
  (let ((val (make-vector 3))
	(frq 0.0))
    (vector-set! val 0 (make-nrcos 100))  
    (vector-set! val 1 (make-nrcos 200))  
    (vector-set! val 2 (make-nrcos 300))
    (run
     (lambda ()
       (set! (mus-frequency (vector-ref val 1)) 500.0)
       (set! frq (mus-frequency (vector-ref val 1)))))
    (if (fneq frq 500.0) (snd-display #__line__ ";defgen set freq: ~A ~A" frq (mus-frequency (vector-ref val 1)))))
  
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((v (make-vector 2 #f)))
			    (vector-set! v 0 (make-nrcos 440 10 .5))    
			    (vector-set! v 1 (make-nrcos 440 10 .5))    
			    (run
			     (lambda ()
			       (do ((i 0 (+ 1 i)))
				   ((= i 1000))
				 (outa i (nrcos (vector-ref v 0) 0.0))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";vect nrcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";vect nrcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((val (make-vector 2))
				(frq 0.0))
			    (vector-set! val 0 (make-nrcos 100 1 .1))  
			    (vector-set! val 1 (make-nrcos 200 1 .1))  
			    (run
			     (lambda ()
			       (do ((i 0 (+ 1 i)))
				   ((= i 2000))
				 (outa i (* .5 (+ (nrcos (vector-ref val 0) 0.0)
						  (nrcos (vector-ref val 1) 0.0))))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";vect 2 nrcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";vect 2 nrcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((gen1 (make-nrcos 100 1 .1))
				(gen2 (make-nrcos 200 1 .1))
				(frq 0.0))
			    (run
			     (lambda ()
			       (do ((i 0 (+ 1 i)))
				   ((= i 2000))
				 (outa i (* .5 (+ (nrcos gen1 0.0)
						  (nrcos gen2 0.0))))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";no vect 2 nrcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";no vect 2 nrcos max: ~A" (maxamp snd))))
  
  (let* ((res (with-sound (:clipped #f)
			  (let ((v (make-vector 2 #f)))
			    (vector-set! v 0 (make-nrcos 440 10 .5))    
			    (vector-set! v 1 (make-nrcos 440 10 .5))    
			    (run
			     (lambda () 
			       (do ((i 0 (+ 1 i))) 
				   ((= i 2000))
				 (let ((gen (vector-ref v 0)))
				   (outa i (nrcos gen)))))))))
	 (snd (find-sound res)))
    (if (not (sound? snd)) (snd-display #__line__ ";vect let nrcos ~A" snd))
    (if (fneq (maxamp snd) 1.0) (snd-display #__line__ ";vect let nrcos max: ~A" (maxamp snd))))
  
  (with-sound (:play #t)
	      (let* ((exp-amt 8.0)
		     (gran (make-granulate :expansion exp-amt))
		     (dur 2.0)
		     (samps (seconds->samples dur))
		     (ampf (make-env '(0.000 0.000 0.011 0.147 0.023 0.131 0.028 0.034 0.059 0.000 0.063 0.153 0.067 0.113 
					     0.072 0.391 0.081 0.095 0.088 0.052 0.102 0.025 0.124 0.000 0.131 0.452 0.139 0.327 
					     0.144 0.099 0.156 0.097 0.160 0.048 0.186 0.000 0.194 0.438 0.200 0.366 0.201 0.156 
					     0.211 0.063 0.247 0.000 0.256 0.628 0.268 0.154 0.274 0.190 0.285 0.027 0.296 0.059 
					     0.309 0.031 0.312 0.481 0.322 0.939 0.331 0.314 0.351 0.061 0.363 0.099 0.374 0.056 
					     0.377 0.438 0.389 0.858 0.394 0.467 0.403 0.241 0.414 0.197 0.415 0.127 0.425 0.075 
					     0.436 0.090 0.441 0.526 0.454 0.869 0.471 0.239 0.490 0.029 0.503 0.117 0.505 0.485
					     0.514 0.811 0.528 0.415 0.538 0.088 0.552 0.056 0.561 0.106 0.580 0.075 0.597 0.000 
					     0.776 0.000 0.777 0.573 0.786 0.145 0.801 0.054 0.826 0.000 0.827 0.632 0.844 1.000 
					     0.856 0.524 0.866 0.031 0.883 0.074 0.891 0.136 0.896 0.745 0.907 0.424 0.915 0.765 
					     0.934 0.059 0.951 0.048 0.962 0.079 0.970 0.436 0.986 0.266 1.000 0.000)
				     :duration 0.25 :scaler 0.5))
		     (frqf (make-env '(0.000 0.220 0.074 0.249 0.133 0.249 0.194 0.240 0.258 0.252 0.324 0.264 0.389 0.267 
					     0.456 0.270 0.520 0.264 0.847 0.270 0.920 0.273 1.000 0.279)
				     :duration 0.25 :scaler (hz->radians (* 0.5 0.205 22050.0))))
		     (gen1 (make-polywave :partials (list 2 .35  3 .1 4 .8  5 .01 6 .03  8 .005)))
		     (rnd (make-rand-interp 600 (hz->radians 50))))
		(run
		 (lambda ()
		   (do ((i 0 (+ 1 i)))
		       ((= i samps))
		     (outa i (granulate gran
					(lambda (dir)
					  (* (env ampf)
					     (polywave gen1 (+ (env frqf)
							       (rand-interp rnd))))))))))))
  
  (let ((g (make-osc329 440.0)) (f 10.0)) 
    (run (lambda () (set! f (osc329 g 0.0)))) 
    (if (fneq f 0.0) (snd-display #__line__ ";run osc329: ~A" f)))
  (let ((g (make-osc329 440.0)) (f #t)) 
    (run (lambda () (set! f (oscil? g)))) 
    (if f (snd-display #__line__ ";oscil? osc329: ~A" f)))
  (let ((g (+ 3 2)) (f #t)) 
    (run (lambda () (set! f (oscil? g)))) 
    (if f (snd-display #__line__ ";oscil? 5: ~A" f)))
  (let ((g (make-osc329 440.0)) (f #t))  
    (run (lambda () (set! f (osc329? g)))) 
    (if (not f) (snd-display #__line__ ";osc329? osc329: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 0.0)) 
    (run (lambda () (set! f (mus-frequency g)))) 
    (if (fneq f 440.0) (snd-display #__line__ ";mus-frequency osc329: ~A" f)))
  (let ((g123 (make-osc329 440.0)) (f 0.0)) 
    (run (lambda () (set! f (mus-frequency g123)))) 
    (if (or (not (number? f)) (fneq f 440.0)) (snd-display #__line__ ";(name) mus-frequency osc329: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 32)) (set! f (mus-length g)) 
       (if (not (= f 1)) (snd-display #__line__ ";osc329 (no run) mus-length: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 32)) 
    (run (lambda () (set! f (mus-length g)))) 
    (if (not (= f 1)) (snd-display #__line__ ";osc329 mus-length: ~A" f)))
  (let ((g (make-osc329 440.0)) (f "hiho")) 
    (run (lambda () (set! f (mus-name g)))) 
    (if (not (string=? f "osc329")) (snd-display #__line__ ";osc329 mus-name: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 1.0)) 
    (run (lambda () (set! f (mus-phase g)))) 
    (if (fneq f 0.0) (snd-display #__line__ ";mus-phase osc329: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 1.0)) 
    (run (lambda () (set! (mus-phase g) f))) 
    (if (fneq (mus-phase g) 1.0) (snd-display #__line__ ";set mus-phase osc329: ~A" (mus-phase g))))
  (let ((g (make-osc329 440.0)) (f "hiho")) 
    (run (lambda () (set! f (mus-describe g)))) 
    (if (not (string? f)) (snd-display #__line__ ";osc329 mus-describe: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 0.0)) 
    (run (lambda () (set! f (mus-increment g)))) 
    (if (fneq f 1.0) (snd-display #__line__ ";mus-increment osc329: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 32))
    (run (lambda () (set! (mus-length g) f)))
    (if (not (= (mus-length g) 32)) (snd-display #__line__ ";osc329 set mus-length: ~A" (mus-length g))))
  (let ((g (make-osc329 440.0)) (f 440.0))
    (run (lambda () (set! (mus-frequency g) 100.0) (set! f (mus-frequency g))))
    (if (fneq f 100.0) (snd-display #__line__ ";osc329 set mus-frequency: ~A" (mus-frequency g))))
  (let ((g (make-osc329 440.0)) (f 440.0))
    (run (lambda () (set! (mus-increment g) 100.0) (set! f (mus-increment g))))
    (if (fneq f 100.0) (snd-display #__line__ ";osc329 set mus-increment: ~A" (mus-increment g))))
  (let ((g (make-osc329 440.0)) (f 32)) 
    (run (lambda () (set! f (mus-hop g)))) 
    (if (not (= f 1)) (snd-display #__line__ ";osc329 mus-hop: ~A" f)))
  (let ((g (make-osc329 440.0)) (f 32))
    (run (lambda () (set! (mus-hop g) f)))
    (if (not (= (mus-hop g) 32)) (snd-display #__line__ ";osc329 set mus-hop: ~A" (mus-hop g))))
  
  (if (not (provided? 'gmp))
      (set! nearly-zero 1.0e-8)) ; in case floats
  (let ((test-zero-stability 
	 (lambda (make-func run-func zero)
	   (let ((gen (make-func)))
	     (set! (mus-phase gen) zero)
	     (let ((zero-val (run-func gen zero)))
	       (for-each
		(lambda (val)
		  (set! gen (make-func)) ; remake else carrier drifts away in ssb cases
		  (set! (mus-phase gen) (+ zero val))
		  (let ((new-val (run-func gen 0.0)))
		    (if (> (abs (- new-val zero-val)) .01)
			(snd-display #__line__ ";~A:~%;   zero check at (+ ~A ~A): ~A ~A~%" gen zero val zero-val new-val))))
		(list 1.0e-11 1.0e-10 1.0e-9 1.0e-8 1.0e-7 1.0e-6
		      -1.0e-11 -1.0e-10 -1.0e-9 -1.0e-8 -1.0e-7 -1.0e-6)))))))
    
    (for-each
     (lambda (zero)
       (test-zero-stability (lambda () (make-oscil 0.0)) oscil zero)
       
       (for-each
	(lambda (n)
	  (test-zero-stability (lambda () (make-nsin 0.0 n)) nsin zero)
	  (test-zero-stability (lambda () (make-ncos 0.0 n)) ncos zero)
	  
	  (test-zero-stability (lambda () (make-nrxysin :n n)) nrxysin zero)
	  (test-zero-stability (lambda () (make-nrxycos :n n)) nrxycos zero)
	  (test-zero-stability (lambda () (make-nrxysin :n n :r .999999)) nrxysin zero)
	  (test-zero-stability (lambda () (make-nrxycos :n n :r .999999)) nrxycos zero)
	  
	  (test-zero-stability (lambda () (make-nssb 0.0 1.0 n)) nssb zero)
	  (test-zero-stability (lambda () (make-noddssb 0.0 1.0 n)) noddssb zero)
	  (test-zero-stability (lambda () (make-nrssb 0.0 1.0 n)) nrssb zero)
	  (test-zero-stability (lambda () (make-nxycos 0.0 1.0 :n n)) nxycos zero)
	  (test-zero-stability (lambda () (make-nxy1cos 0.0 1.0 :n n)) nxy1cos zero)
	  (test-zero-stability (lambda () (make-nxysin 0.0 1.0 :n n)) nxysin zero)
	  
	  (test-zero-stability (lambda () (make-nssb 0.0 1.0 n)) nssb zero)
	  (test-zero-stability (lambda () (make-noddssb 0.0 1.0 n)) noddssb zero)
	  (test-zero-stability (lambda () (make-nrssb 0.0 1.0 n)) nrssb zero)
	  (test-zero-stability (lambda () (make-nxycos 0.0 1.0 :n n)) nxycos zero)
	  (test-zero-stability (lambda () (make-nxy1cos 0.0 1.0 :n n)) nxy1cos zero)
	  (test-zero-stability (lambda () (make-nxysin 0.0 1.0 :n n)) nxysin zero)
	  
	  (test-zero-stability (lambda () (make-nkssb 0.0 1.0 n)) nkssb zero)
	  (test-zero-stability (lambda () (make-nkssb 0.0 1.0 n)) nkssb zero)
	  
	  (test-zero-stability (lambda () (make-noddsin :n n)) noddsin zero)
	  (test-zero-stability (lambda () (make-noddcos :n n)) noddcos zero)
	  (test-zero-stability (lambda () (make-ncos2 :n n)) ncos2 zero)
	  (test-zero-stability (lambda () (make-npcos :n n)) npcos zero)
	  (test-zero-stability (lambda () (make-n1cos :n n)) n1cos zero)
	  (test-zero-stability (lambda () (make-nrcos :n n)) nrcos zero))
	(list 1 10 3 30))
       
       (test-zero-stability (lambda () (make-krksin :r 0.1)) krksin zero)
       (test-zero-stability (lambda () (make-k2sin)) k2sin zero)
       (test-zero-stability (lambda () (make-k2cos)) k2cos zero)
       (test-zero-stability (lambda () (make-k2ssb 0.0 1.0)) k2ssb zero)
       (test-zero-stability (lambda () (make-abcos :a 1.0 :b 0.5)) abcos zero)
       (test-zero-stability (lambda () (make-absin :a 1.0 :b 0.5)) absin zero)
       
       (for-each
	(lambda (r)
	  (test-zero-stability (lambda () (make-rcos :r r)) rcos zero)
	  (test-zero-stability (lambda () (make-ercos :r r)) ercos zero)
					;(test-zero-stability (lambda () (make-r2sin :r r)) r2sin zero)
					;(test-zero-stability (lambda () (make-r2cos :r r)) r2cos zero)
	  (test-zero-stability (lambda () (make-eoddcos  :r r)) eoddcos  zero)
	  (test-zero-stability (lambda () (make-rkcos  :r r)) rkcos  zero)
	  (test-zero-stability (lambda () (make-rksin :r r)) rksin zero)
	  (test-zero-stability (lambda () (make-rk!cos :r r)) rk!cos zero)
	  (test-zero-stability (lambda () (make-r2k!cos :r r)) r2k!cos zero)
	  (test-zero-stability (lambda () (make-r2k2cos :r r)) r2k2cos zero)
	  
	  (test-zero-stability (lambda () (make-nrxysin :n 3 :r r)) nrxysin zero)
	  (test-zero-stability (lambda () (make-nrxycos :n 3 :r r)) nrxycos zero)
	  
	  (test-zero-stability (lambda () (make-rssb 0.0 1.0 :r r)) rssb zero)
	  (test-zero-stability (lambda () (make-erssb 0.0 1.0 :r r)) erssb zero)
	  (test-zero-stability (lambda () (make-rkssb 0.0 1.0 :r r)) rkssb zero)
	  (test-zero-stability (lambda () (make-rk!ssb 0.0 1.0 :r r)) rk!ssb zero)
	  (test-zero-stability (lambda () (make-rkoddssb 0.0 1.0 :r r)) rkoddssb zero)
					;(test-zero-stability (lambda () (make-r2ssb 0.0 1.0 :r r)) r2ssb zero)
	  
	  (test-zero-stability (lambda () (make-rssb 0.0 1.0 :r r)) rssb zero)
	  (test-zero-stability (lambda () (make-erssb 0.0 1.0 :r r)) erssb zero)
	  (test-zero-stability (lambda () (make-rkssb 0.0 1.0 :r r)) rkssb zero)
	  (test-zero-stability (lambda () (make-rk!ssb 0.0 1.0 :r r)) rk!ssb zero)
	  (test-zero-stability (lambda () (make-rkoddssb 0.0 1.0 :r r)) rkoddssb zero)
					;(test-zero-stability (lambda () (make-r2ssb 0.0 1.0 :r r)) r2ssb zero)
	  )
	(list 0.1 0.5 .99 .999)))
     (list 0.0 (* 0.5 pi) pi (* 2.0 pi) (* -0.5 pi) (- pi) (* -2.0 pi) (* 1.5 pi) (* -1.5 pi))))
  
  (calling-all-animals)
  (calling-all-generators)
  
  (let ((funcs (list nssb nxysin nxycos nxy1cos nxy1sin noddsin noddcos noddssb ncos2 npcos
		     nrsin nrcos nrssb nkssb nsincos rcos rssb rxysin rxycos
		     rxyk!sin rxyk!cos ercos erssb eoddcos rkcos rksin rkssb
		     rk!cos rk!ssb r2k!cos k2sin k2cos k2ssb dblsum rkoddssb krksin 
		     abcos absin r2k2cos bess jjcos j0evencos j2cos jpcos jncos 
		     j0j1cos jycos blackman fmssb k3sin izcos
		     adjustable-square-wave adjustable-triangle-wave adjustable-sawtooth-wave adjustable-oscil 
		     round-interp))
	(make-funcs (list make-nssb make-nxysin make-nxycos make-nxy1cos make-nxy1sin make-noddsin make-noddcos make-noddssb make-ncos2 make-npcos
			  make-nrsin make-nrcos make-nrssb make-nkssb make-nsincos make-rcos make-rssb make-rxysin make-rxycos
			  make-rxyk!sin make-rxyk!cos make-ercos make-erssb make-eoddcos make-rkcos make-rksin make-rkssb
			  make-rk!cos make-rk!ssb make-r2k!cos make-k2sin make-k2cos make-k2ssb make-dblsum make-rkoddssb make-krksin 
			  make-abcos make-absin make-r2k2cos make-bess make-jjcos make-j0evencos make-j2cos make-jpcos make-jncos
			  make-j0j1cos make-jycos make-blackman make-fmssb make-k3sin make-izcos
			  make-adjustable-square-wave make-adjustable-triangle-wave make-adjustable-sawtooth-wave make-adjustable-oscil
			  make-round-interp))
	(pfuncs (list nssb? nxysin? nxycos? nxy1cos? nxy1sin? noddsin? noddcos? noddssb? ncos2? npcos?
		      nrsin? nrcos? nrssb? nkssb? nsincos? rcos? rssb? rxysin? rxycos?
		      rxyk!sin? rxyk!cos? ercos? erssb? eoddcos? rkcos? rksin? rkssb?
		      rk!cos? rk!ssb? r2k!cos? k2sin? k2cos? k2ssb? dblsum? rkoddssb? krksin? 
		      abcos? absin? r2k2cos? bess? jjcos? j0evencos? j2cos? jpcos? jncos?
		      j0j1cos? jycos? blackman? fmssb? k3sin? izcos?
		      adjustable-square-wave? adjustable-triangle-wave? adjustable-sawtooth-wave? adjustable-oscil?
		      round-interp?))
	(names (list 'nssb 'nxysin 'nxycos 'nxy1cos 'nxy1sin 'noddsin 'noddcos 'noddssb 'ncos2 'npcos
		     'nrsin 'nrcos 'nrssb 'nkssb 'nsincos 'rcos 'rssb 'rxysin 'rxycos
		     'rxyk!sin 'rxyk!cos 'ercos 'erssb 'eoddcos 'rkcos 'rksin 'rkssb
		     'rk!cos 'rk!ssb 'r2k!cos 'k2sin 'k2cos 'k2ssb 'dblsum 'rkoddssb 'krksin 
		     'abcos 'absin 'r2k2cos 'bess 'jjcos 'j0evencos 'j2cos 'jpcos 'jncos
		     'j0j1cos 'jycos 'blackman 'fmssb 'k3sin 'izcos
		     'adjustable-square-wave 'adjustable-triangle-wave 'adjustable-sawtooth-wave 'adjustable-oscil
		     'round-interp))
	(methods (list nssb-methods nxysin-methods nxycos-methods nxy1cos-methods nxy1sin-methods 
		       noddsin-methods noddcos-methods noddssb-methods ncos2-methods npcos-methods 
		       nrsin-methods nrcos-methods nrssb-methods nkssb-methods nsincos-methods 
		       rcos-methods rssb-methods rxysin-methods rxycos-methods 
		       rxyk!sin-methods rxyk!cos-methods ercos-methods erssb-methods
		       eoddcos-methods rkcos-methods rksin-methods rkssb-methods 
		       rk!cos-methods rk!ssb-methods r2k!cos-methods k2sin-methods k2cos-methods k2ssb-methods 
		       dblsum-methods rkoddssb-methods krksin-methods 
		       abcos-methods absin-methods r2k2cos-methods bess-methods 
		       jjcos-methods j0evencos-methods j2cos-methods jpcos-methods jncos-methods 
		       j0j1cos-methods jycos-methods blackman-methods fmssb-methods k3sin-methods izcos-methods 
		       adjustable-square-wave-methods adjustable-triangle-wave-methods 
		       adjustable-sawtooth-wave-methods adjustable-oscil-methods 
		       round-interp-methods))
	)
    
    
    (for-each
     (lambda (mf rf pf name mth)
       (let ((gen (mf)))
	 (if (not (pf gen))
	     (snd-display #__line__ ";make-* generators ~A: ~A" name gen))
	 (if (not (mus-generator? gen))
	     (snd-display #__line__ ";make-* generators mus-generator? ~A" gen))
	 (rf gen 0.0)
	 (mus-run gen 0.0 0.0)
	 (mus-reset gen)
	 (if (not (string=? (mus-name gen) (symbol->string name)))
	     (snd-display #__line__ ";mus-name generators: ~A ~A" (mus-name gen) (symbol->string name)))
	 (let* ((has-freq (assoc 'mus-frequency (mth)))
		(has-n (and (assoc 'mus-order (mth))
			    (pf (catch #t (lambda () (mf :n 3)) (lambda args (car args))))))
		(has-r (and (assoc 'mus-scaler (mth))
			    (pf (catch #t (lambda () (mf :r 0.75)) (lambda args (car args)))))))
	   (if has-freq
	       (begin
		 (set! gen (mf :frequency 440.0))
		 (if (fneq (mus-frequency gen) 440.0) 
		     (snd-display #__line__ ";mus-frequency from make-~A: ~A" name (mus-frequency gen)))))
	   (if has-n
	       (begin
		 (set! gen (mf :n 3))
		 (if (not (= (mus-order gen) 3))
		     (snd-display #__line__ ";mus-order from make-~A: ~A" name (mus-order gen)))))
	   (if has-r
	       (begin
		 (set! gen (mf :r 0.75))
		 (if (fneq (mus-scaler gen) 0.75)
		     (snd-display #__line__ ";mus-scaler from make-~A: ~A" name (mus-scaler gen))))))))
     
     make-funcs funcs pfuncs names methods))
  
  
  (for-each
   (lambda (name maker methods isit)
     (let ((gen (maker)))
       (if (not (isit gen))
	   (format #t "~A is not a ~A?" gen name)
	   (let* ((funcs (methods)))
	     (if (null? funcs)
		 (format #t "A has no methods?" name)
		 (for-each
		  (lambda (method)
		    (let ((method-name (car method)))
		      (catch #t
			     (lambda ()
			       (let ((curval (if (not (eq? method-name 'mus-run)) ((cadr method) gen) #f)))
				 (if (not (null? (cddr method)))
				     (begin
				       (if (eq? method-name 'mus-name)
					   (set! (mus-name gen) "hiho")
					   (if (eq? method-name 'mus-n)
					       (set! (mus-n gen) 1)
					       ((caddr method) gen 10.0)))))))
			     (lambda args
			       (format #t "error in ~A~%" (car method))
			       #f))))
		  funcs))))))
   
   (list 'nssb 'nxysin 'nxycos 'nxy1cos 'nxy1sin 'noddsin 'noddcos 'noddssb 'ncos2 'npcos
	 nrsin 'nrcos 'nrssb 'nkssb 'nsincos 'rcos 'rssb 'rxysin 'rxycos
	 rxyk!sin 'rxyk!cos 'ercos 'erssb 'eoddcos 'rkcos 'rksin 'rkssb
	 rk!cos 'rk!ssb 'r2k!cos 'k2sin 'k2cos 'k2ssb 'dblsum 'rkoddssb 'krksin
	 abcos 'absin 'r2k2cos 'bess 'jjcos 'j0evencos 'j2cos 'jpcos 'jncos
	 j0j1cos 'jycos 'blackman 'fmssb 'k3sin 'izcos 'nchoosekcos 'n1cos
	 adjustable-square-wave 'adjustable-triangle-wave 'adjustable-sawtooth-wave 'adjustable-oscil
	 round-interp 'sinc-train 'pink-noise 'green-noise 'brown-noise 'green-noise-interp
	 moving-max 'moving-sum 'moving-rms 'moving-length 'weighted-moving-average 'exponentially-weighted-moving-average
	 tanhsin 'moving-fft 'moving-scentroid 'moving-autocorrelation 'moving-pitch)
   
   (list make-nssb make-nxysin make-nxycos make-nxy1cos make-nxy1sin make-noddsin make-noddcos make-noddssb make-ncos2 make-npcos
	 make-nrsin make-nrcos make-nrssb make-nkssb make-nsincos make-rcos make-rssb make-rxysin make-rxycos
	 make-rxyk!sin make-rxyk!cos make-ercos make-erssb make-eoddcos make-rkcos make-rksin make-rkssb
	 make-rk!cos make-rk!ssb make-r2k!cos make-k2sin make-k2cos make-k2ssb make-dblsum make-rkoddssb make-krksin
	 make-abcos make-absin make-r2k2cos make-bess make-jjcos make-j0evencos make-j2cos make-jpcos make-jncos
	 make-j0j1cos make-jycos make-blackman make-fmssb make-k3sin make-izcos make-nchoosekcos make-n1cos
	 make-adjustable-square-wave make-adjustable-triangle-wave make-adjustable-sawtooth-wave make-adjustable-oscil
	 make-round-interp make-sinc-train make-pink-noise make-green-noise make-brown-noise make-green-noise-interp
	 make-moving-max make-moving-sum make-moving-rms make-moving-length make-weighted-moving-average make-exponentially-weighted-moving-average 
	 make-tanhsin make-moving-fft make-moving-scentroid make-moving-autocorrelation make-moving-pitch)
   
   (list nssb-methods nxysin-methods nxycos-methods nxy1cos-methods nxy1sin-methods noddsin-methods noddcos-methods noddssb-methods ncos2-methods npcos-methods
	 nrsin-methods nrcos-methods nrssb-methods nkssb-methods nsincos-methods rcos-methods rssb-methods rxysin-methods rxycos-methods
	 rxyk!sin-methods rxyk!cos-methods ercos-methods erssb-methods eoddcos-methods rkcos-methods rksin-methods rkssb-methods
	 rk!cos-methods rk!ssb-methods r2k!cos-methods k2sin-methods k2cos-methods k2ssb-methods dblsum-methods rkoddssb-methods krksin-methods
	 abcos-methods absin-methods r2k2cos-methods bess-methods jjcos-methods j0evencos-methods j2cos-methods jpcos-methods jncos-methods
	 j0j1cos-methods jycos-methods blackman-methods fmssb-methods k3sin-methods izcos-methods nchoosekcos-methods n1cos-methods
	 adjustable-square-wave-methods adjustable-triangle-wave-methods adjustable-sawtooth-wave-methods adjustable-oscil-methods
	 round-interp-methods sinc-train-methods pink-noise-methods green-noise-methods brown-noise-methods green-noise-interp-methods
	 moving-max-methods moving-sum-methods moving-rms-methods moving-length-methods weighted-moving-average-methods exponentially-weighted-moving-average-methods
	 tanhsin-methods moving-fft-methods moving-scentroid-methods moving-autocorrelation-methods moving-pitch-methods)
   
   (list nssb? nxysin? nxycos? nxy1cos? nxy1sin? noddsin? noddcos? noddssb? ncos2? npcos? 
	 nrsin? nrcos? nrssb? nkssb? nsincos? rcos? rssb? rxysin? rxycos? 
	 rxyk!sin? rxyk!cos? ercos? erssb? eoddcos? rkcos? rksin? rkssb? 
	 rk!cos? rk!ssb? r2k!cos? k2sin? k2cos? k2ssb? dblsum? rkoddssb? krksin? 
	 abcos? absin? r2k2cos? bess? jjcos? j0evencos? j2cos? jpcos? jncos? 
	 j0j1cos? jycos? blackman? fmssb? k3sin? izcos? nchoosekcos? n1cos? 
	 adjustable-square-wave? adjustable-triangle-wave? adjustable-sawtooth-wave? adjustable-oscil? 
	 round-interp? sinc-train? pink-noise? green-noise? brown-noise? green-noise-interp? 
	 moving-max? moving-sum? moving-rms? moving-length? weighted-moving-average? exponentially-weighted-moving-average? 
	 tanhsin? moving-fft? moving-scentroid? moving-autocorrelation? moving-pitch? )
   )
  
  
  (let ((gen1 (make-oscil 440.0))
	(gen2 (make-oscil 440.0)))
    (do ((i 0 (+ 1 i)))
	((= i 1000))
      (let* ((pm (- 1.0 (random 2.0)))
	     (val1 (oscil gen1 0.0 pm))
	     (val2 (run-with-fm-and-pm gen2 0.0 pm)))
	(if (fneq val1 val2)
	    (snd-display #__line__ ";run-with-fm-and-pm: ~A ~A" val1 val2)))))
  
  (let ((gen1 (make-oscil 440.0))
	(gen2 (make-oscil 440.0))
	(happy #t))
    (run 
     (do ((i 0 (+ 1 i)))
	 ((or (not happy)
	      (= i 1000)))
       (let* ((pm (- 1.0 (random 2.0)))
	      (val1 (oscil gen1 0.0 pm))
	      (val2 (run-with-fm-and-pm gen2 0.0 pm)))
	 (if (fneq val1 val2)
	     (set! happy #f)))))
    (if (not happy)
	(snd-display #__line__ ";run-with-fm-and-pm unhappy")))
  
  (set! (mus-srate) 44100)
  (let ((gen (make-nssb 440.0 :n 3))
	(order 0)
	(frequency 0.0)
	(val 0.0)
	(name "hiho"))
    (run
     (lambda ()
       (set! order (mus-order gen))
       (set! frequency (mus-frequency gen))
       (nssb gen 1.0)
       (set! val (mus-run gen 0.0 0.0))
       (set! name (mus-name gen))
       ))
    (if (not (string=? name "nssb")) (snd-display #__line__ ";run mus-name nssb: ~A" name))
    (if (not (= order 3)) (snd-display #__line__ ";run mus-order nssb: ~A" order))
    (if (fneq frequency 440.0) (snd-display #__line__ ";run mus-frequency nssb: ~A" frequency))
    (if (fneq val 0.371) (snd-display #__line__ ";run mus-run nssb: ~A" val)))
  
  ;; mus-reset and mus-describe in this case have an embedded for-each, so not optimizable
  
  (let ((gen (make-oscil 123.0)))
    (set! (mus-name gen) "oscil123")
    (if (not (string=? (mus-name gen) "oscil123")) (snd-display #__line__ ";set mus-name oscil123: ~A" (mus-name gen)))
    (set! (mus-name gen) "another-name")
    (if (not (string=? (mus-name gen) "another-name")) (snd-display #__line__ ";set mus-name again: ~A" (mus-name gen)))
    (let ((descr (mus-describe gen)))
      (if (not (string=? descr "another-name freq: 123.000Hz, phase: 0.000"))
	  (snd-display #__line__ ";set mus-name describe: ~A" descr))))
  
  (let ((gen (make-nssb 123.0)))
    (set! (mus-name gen) "nssb123")
    (if (not (string=? (mus-name gen) "nssb123")) (snd-display #__line__ ";set mus-name nssb123: ~A" (mus-name gen)))
    (set! (mus-name gen) "another-name")
    (if (not (string=? (mus-name gen) "another-name")) (snd-display #__line__ ";set mus-name nssb again: ~A" (mus-name gen)))
    (set! (mus-frequency gen) 0.0)
    (let ((descr (mus-describe gen)))
      (if (not (string=? descr "another-name frequency: 0.0, ratio: 1.0, n: 1, angle: 0.0"))
	  (snd-display #__line__ ";set mus-name nssb describe: ~A" descr))))
  
  (let ((gen (make-oscil 123.0))
	(gen1 (make-oscil 440.0)))
    (set! (mus-name gen) "oscil123")
    (set! (mus-name gen1) "440")
    (if (not (string=? (mus-name gen) "oscil123")) (snd-display #__line__ ";set mus-name oscil123 1: ~A" (mus-name gen)))
    (if (not (string=? (mus-name gen1) "440")) (snd-display #__line__ ";set mus-name oscil 440 1: ~A" (mus-name gen)))
    (set! (mus-name gen1) "another-name")
    (if (not (string=? (mus-name gen1) "another-name")) (snd-display #__line__ ";set mus-name again 1: ~A" (mus-name gen)))
    (if (not (string=? (mus-name gen) "oscil123")) (snd-display #__line__ ";set mus-name oscil123 2: ~A" (mus-name gen)))
    (let ((descr (mus-describe gen1)))
      (if (not (string=? descr "another-name freq: 440.000Hz, phase: 0.000"))
	  (snd-display #__line__ ";set mus-name describe 1: ~A" descr))))
  
  (let ((gen (make-nssb 123.0))
	(gen1 (make-nssb 440.0)))
    (set! (mus-name gen) "nssb123")
    (set! (mus-name gen1) "440")
    (if (not (string=? (mus-name gen) "nssb123")) (snd-display #__line__ ";set mus-name nssb123 1: ~A" (mus-name gen)))
    (if (not (string=? (mus-name gen1) "440")) (snd-display #__line__ ";set mus-name nssb 440 1: ~A" (mus-name gen)))
    (set! (mus-name gen) "another-name")
    (if (not (string=? (mus-name gen) "another-name")) (snd-display #__line__ ";set mus-name nssb again 1: ~A" (mus-name gen)))
    (set! (mus-frequency gen) 0.0)
    (let ((descr (mus-describe gen)))
      (if (not (string=? descr "another-name frequency: 0.0, ratio: 1.0, n: 1, angle: 0.0"))
	  (snd-display #__line__ ";set mus-name nssb describe 1: ~A" descr))))
  
  
  (if (not (null? (sounds))) (for-each close-sound (sounds)))
  (set! (optimization) old-opt-23)
  
  (test-documentation-instruments) ; clm23.scm
  
  (if #f
      (let ((outfile "/home/bil/test/sound/big3.snd"))
	(if (file-exists? outfile)
	    (delete-file outfile))
	(for-each
	 (lambda (ht)
	   (with-sound (:output outfile :srate 44100 :channels 2 :header-type ht)
		       (do ((i 0 (+ i 1)))
			   ((= i 30000))
			 (fm-violin i .1 440 (+ .1 (* (/ i 30000.0) .9)))))
	   (if (not (file-exists? outfile))
	       (snd-display #__line__ ";big3 ~A not written?" (mus-header-type-to-string ht))
	       (let ((snd (find-sound outfile)))
		 (if (> (abs (- (frames snd 0) (* 30000 44100))) 44100)
		     (snd-display #__line__ ";big3 frames: ~A, should be ~A (~A)" (frames snd 0) (* 30000 44100) (- (frames snd 0) (* 30000 44100))))
		 (if (< (maxamp snd ) .97)
		     (snd-display #__line__ ";big3 max: ~A" (maxamp snd)))
		 (if (and (= ht mus-riff)
			  (not (= (header-type snd) mus-rf64)))
		     (snd-display #__line__ ";big3 auto convert? ~A -> ~A" (mus-header-type-to-string ht) (mus-header-type-to-string (header-type snd))))
		 (close-sound snd))))
	 (list mus-next mus-caff))
	
	(if (file-exists? outfile)
	    (delete-file outfile))))
  
  )


(define (snd_test_24)
  #f
  )


;;; ---------------- test 25: X/Xt/Xm --------------------
(define (snd_test_25)
  (define (x->snd-color color-name)
    "(x->snd-color color-name) returns a Snd color object corresponding to the X11 color name 'color-name'"
    (let* ((col (XColor))
	   (dpy (XtDisplay (cadr (main-widgets))))
	   (scr (DefaultScreen dpy))
	   (cmap (DefaultColormap dpy scr)))
      (if (= (XAllocNamedColor dpy cmap color-name col col) 0)
	  (snd-error (format #f "can't allocate ~A" color-name))
	  (make-color-with-catch (/ (.red col) 65535.0)
				 (/ (.green col) 65535.0)
				 (/ (.blue col) 65535.0)))))
  
  (define (snd-test-clean-string str)
    ;; full file name should be unique, so I think we need only fix it up to look like a flat name
    (let* ((len (string-length str))
	   (new-str (make-string len #\.)))
      (do ((i 0 (+ 1 i)))
	  ((= i len) new-str)
	(let ((c (string-ref str i)))
	  (if (or (char=? c #\\)
		  (char=? c #\/))
	      (string-set! new-str i #\_)
	      (string-set! new-str i c))))))
  
  (define (tagged-p val sym)  (or (eq? val #f) (and (list? val) (not (null? val)) (eq? (car val) sym))))
  (define (array-p val type)  (and (list? val) (or (null? val) (type (car val)))))
  (define (XM_INT val)  (integer? val))
  (define (XM_ULONG val)  (and (integer? val) (>= val 0)))
  (define (XM_UCHAR val)  (or (char? val) (and (integer? val) (>= val 0) (< val 65536))))
  (define (XM_FLOAT val)  (real? val))
  (define (XM_STRING val)  (or (eq? val #f) (string? val) (and (number? val) (= val 0))))
  (define (XM_XMSTRING val)  (or (tagged-p val 'XmString) (and (number? val) (= val 0))))
  (define (XM_STRING_TABLE val)  (or (array-p val (lambda (n) (eq? (car n) 'XmString))) (and (number? val) (= val 0))))
  (define (XM_INT_TABLE val)  (or (array-p val integer?) (and (number? val) (= val 0))))
  (define (XM_BOOLEAN val)  (or (boolean? val) (and (number? val) (= val 0))))
  (define (XM_RENDER_TABLE val)  (or (tagged-p val 'XmRenderTable) (and (number? val) (= val 0))))
  (define (XM_TRANSFER_ENTRY_LIST val)  (or (list? val) (and (number? val) (= val 0))))
  (define (XM_RECTANGLE_LIST val)  (or (array-p val (lambda (n) (eq? (car n) 'XRectangle))) (and (number? val) (= val 0))))
  (define (XM_TAB_LIST val)  (or (tagged-p val 'XmTabList) (and (number? val) (= val 0))))
  (define (XM_WIDGET_LIST val)  (or (array-p val (lambda (n) (eq? (car n) 'Widget))) (and (number? val) (= val 0))))
  (define (XM_ATOM_LIST val)  (or (eq? val #f) (array-p val (lambda (n) (eq? (car n) 'Atom))) (and (number? val) (= val 0))))
  (define (XM_STRING_LIST val)  (or (array-p val (lambda (n) (eq? (car n) 'XmString))) (and (number? val) (= val 0))))
  (define (XM_CHARSET_TABLE val)  (or (array-p val (lambda (n) (eq? (car n) 'CharSet))) (and (number? val) (= val 0))))
  (define (XM_KEYSYM_TABLE val)  (or (array-p val (lambda (n) (eq? (car n) 'KeySym))) (and (number? val) (= val 0))))
  (define (XM_WIDGET val)  (or (tagged-p val 'Widget) (and (number? val) (= val 0))))
  (define (XM_PIXEL val)  (or (tagged-p val 'Pixel) (and (number? val) (= val 0))))
  (define (XM_PIXMAP val)  (or (tagged-p val 'Pixmap) (and (number? val) (= val 0))))
  (define (XM_XFONTSTRUCT val)  (or (tagged-p val 'XFontStruct) (and (number? val) (= val 0))))
  (define (XM_DIMENSION val)  (and (integer? val) (>= val 0) (< val 65536)))
  (define (XM_ATOM val)  (or (tagged-p val 'Atom) (and (number? val) (= val 0))))
  (define (XM_TEXT_SOURCE val)  (or (tagged-p val 'XmTextSource) (and (number? val) (= val 0))))
  (define (XM_FONTLIST val)  (or (tagged-p val 'FontList) (and (number? val) (= val 0))))
  (define (XM_COLORMAP val)  (or (tagged-p val 'Colormap) (and (number? val) (= val 0))))
  (define (XM_KEYSYM val)  (or (tagged-p val 'KeySym) (and (number? val) (= val 0))))
  (define (XM_SCREEN val)  (or (tagged-p val 'Screen) (and (number? val) (= val 0))))
  (define (XM_WINDOW val)  (or (tagged-p val 'Window) (and (number? val) (= val 0))))
  (define (XM_VISUAL val)  (or (tagged-p val 'Visual) (and (number? val) (= val 0))))
  (define (XM_WIDGET_CLASS val)  (or (tagged-p val 'WidgetClass) (and (number? val) (= val 0))))
  (define (XM_STRING_OR_INT val)  (or (string? val) (integer? val) (eq? val #f)))
  (define (XM_STRING_OR_XMSTRING val)  (or (string? val) (eq? val #f) (and (list? val) (not (null? val)) (eq? (car val) 'XmString)) (and (number? val) (= val 0))))
  (define (XM_BOOLEAN_OR_INT val)  (or (boolean? val) (integer? val)))
  (define (XM_POSITION val)  (and (integer? val) (< (abs val) 65536)))
  (define (XM_SHORT val)  (and (integer? val) (< (abs val) 65536)))
  (define (XM_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_TRANSFER_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val) (and (list? val) (not (null? val)) (procedure? (car val)))))
  (define (XM_CONVERT_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val) (and (list? val) (not (null? val)) (procedure? (car val)))))
  (define (XM_SEARCH_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_ORDER_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_QUALIFY_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_ALLOC_COLOR_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_POPUP_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_SCREEN_COLOR_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_DROP_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_DRAG_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  (define (XM_PARSE_CALLBACK val)  (or (procedure? val) (eq? val #f) (integer? val)))
  
  
  (if (and (provided? 'snd-motif) 
	   (provided? 'xm)) 
      (begin
	
	(do ((clmtest 0 (+ 1 clmtest))) ((= clmtest (min 2 tests)))
	  (log-mem clmtest)
	  
	  ;; check some resource stuff first
	  (let ((hgt (cadr (XtVaGetValues (cadr (main-widgets)) (list XmNheight 0))))
		(wid (cadr (XtVaGetValues (cadr (main-widgets)) (list XmNwidth 0)))))
	    (if (or (<= wid 0) (<= hgt 0) (> wid 65535) (> hgt 65535))
		(snd-display #__line__ ";Dimension miscast: ~A ~A" wid hgt)))
	  
	  ;; ---------------- X tests ----------------
	  (let ((scr (current-screen))
		(dpy (XtDisplay (cadr (main-widgets)))))
	    (if (and (not (= (.height scr) 1200))
		     (not (= (.height scr) 1600)))
		(snd-display #__line__ ";screen height: ~A" (.height scr)))
	    (if (and (not (= (.width scr) 1600))
		     (not (= (.width scr) 2560)))
		(snd-display #__line__ ";screen width: ~A" (.width scr)))
	    (if (not (= (.ndepths scr) 7))
		(snd-display #__line__ ";screen ndepths: ~A" (.ndepths scr)))
	    (let ((dps (.depths scr)))
	      (if (or (not (= (length dps) (.ndepths scr)))
		      (not (Depth? (car dps))))
		  (snd-display #__line__ ";depths: ~A" (.depths scr)))
	      (if (not (= (.depth (car dps)) 24)) (snd-display #__line__ ";.depths val: ~A" (map .depth dps)))
	      (if (not (null? (.visuals (car dps))))
		  (if (not (Visual? (car (.visuals (car dps))))) 
		      (snd-display #__line__ ";visuals: ~A" (map .visuals dps))
		      (if (not (= (.bits_per_rgb (car (.visuals (car dps)))) 8))
			  (snd-display #__line__ ";bits/visuals: ~A" (map .bits_per_rgb (.visuals (car dps))))))
		  (if (and (cadr dps)
			   (not (null? (.visuals (cadr dps)))))
		      (if (not (Visual? (car (.visuals (cadr dps))))) 
			  (snd-display #__line__ ";visuals: ~A" (map .visuals dps))
			  (if (not (= (.bits_per_rgb (car (.visuals (cadr dps)))) 8))
			      (snd-display #__line__ ";bits/visuals: ~A" (map .bits_per_rgb (.visuals (cadr dps)))))))))
	    (if (not (= (cadr (.white_pixel scr)) 16777215))
		(snd-display #__line__ ";screen white_pixel: ~A" (.white_pixel scr)))
	    (if (not (= (cadr (.black_pixel scr)) 0))
		(snd-display #__line__ ";screen black_pixel: ~A" (.black_pixel scr)))
	    (if (not (eq? (.backing_store scr) #f))
		(snd-display #__line__ ";screen backing_store: ~A" (.backing_store scr)))
	    (if (not (= (.min_maps scr) 1))
		(snd-display #__line__ ";screen min_maps: ~A" (.min_maps scr)))
	    (if (not (= (.max_maps scr) 1))
		(snd-display #__line__ ";screen max_maps: ~A" (.max_maps scr)))
	    (if (not (eq? (.save_unders scr) #f))
		(snd-display #__line__ ";screen save_unders: ~A" (.save_unders scr)))
	    (if (not (GC? (.default_gc scr)))
		(snd-display #__line__ ";screen default_gc: ~A" (.default_gc scr)))
	    (if (not (Window? (.root scr)))
		(snd-display #__line__ ";screen root: ~A" (.root scr)))
	    (if (not (Colormap? (.cmap scr)))
		(snd-display #__line__ ";screen colormap: ~A" (.cmap scr)))
	    
	    (if (not (equal? (DisplayOfScreen scr) (.display scr))) 
		(snd-display #__line__ ";DisplayOfScreen: ~A ~A" (DisplayOfScreen scr) (.display scr)))
	    (if (not (equal? (RootWindowOfScreen scr) (.root scr))) 
		(snd-display #__line__ ";RootWindowOfScreen: ~A ~A" (RootWindowOfScreen scr) (.root scr)))
	    (if (not (equal? (BlackPixelOfScreen scr) (.black_pixel scr))) 
		(snd-display #__line__ ";BlackPixelOfScreen: ~A ~A" (BlackPixelOfScreen scr) (.black_pixel scr)))
	    (if (not (equal? (WhitePixelOfScreen scr) (.white_pixel scr))) 
		(snd-display #__line__ ";WhitePixelOfScreen: ~A ~A" (WhitePixelOfScreen scr) (.white_pixel scr)))
	    (if (not (equal? (DefaultColormapOfScreen scr) (.cmap scr))) 
		(snd-display #__line__ ";DefaultColormapOfScreen: ~A ~A" (DefaultColormapOfScreen scr) (.cmap scr)))
	    (if (not (equal? (DefaultDepthOfScreen scr) (.root_depth scr))) 
		(snd-display #__line__ ";DefaultDepthOfScreen: ~A ~A" (DefaultDepthOfScreen scr) (.root_depth scr)))
	    (if (not (equal? (DefaultGCOfScreen scr) (.default_gc scr))) 
		(snd-display #__line__ ";DefaultGCOfScreen: ~A ~A" (DefaultGCOfScreen scr) (.default_gc scr)))
	    (if (not (equal? (DefaultVisualOfScreen scr) (.root_visual scr))) 
		(snd-display #__line__ ";DefaultVisualOfScreen: ~A ~A" (DefaultVisualOfScreen scr) (.root_visual scr)))
	    (if (not (equal? (WidthOfScreen scr) (.width scr))) 
		(snd-display #__line__ ";WidthOfScreen: ~A ~A" (WidthOfScreen scr) (.width scr)))
	    (if (not (equal? (HeightOfScreen scr) (.height scr))) 
		(snd-display #__line__ ";HeightOfScreen: ~A ~A" (HeightOfScreen scr) (.height scr)))
	    (if (not (equal? (WidthMMOfScreen scr) (.mwidth scr))) 
		(snd-display #__line__ ";WidthMMOfScreen: ~A ~A" (WidthMMOfScreen scr) (.mwidth scr)))
	    (if (not (equal? (HeightMMOfScreen scr) (.mheight scr))) 
		(snd-display #__line__ ";HeightMMOfScreen: ~A ~A" (HeightMMOfScreen scr) (.mheight scr)))
	    (if (not (equal? (PlanesOfScreen scr) (.root_depth scr))) 
		(snd-display #__line__ ";PlanesOfScreen: ~A ~A" (PlanesOfScreen scr) (.root_depth scr)))
	    (if (not (equal? (MinCmapsOfScreen scr) (.min_maps scr))) 
		(snd-display #__line__ ";MinCmapsOfScreen: ~A ~A" (MinCmapsOfScreen scr) (.min_maps scr)))
	    (if (not (equal? (MaxCmapsOfScreen scr) (.max_maps scr))) 
		(snd-display #__line__ ";MaxCmapsOfScreen: ~A ~A" (MaxCmapsOfScreen scr) (.max_maps scr)))
	    (if (not (equal? (DoesSaveUnders scr) (.save_unders scr))) 
		(snd-display #__line__ ";DoesSaveUnders: ~A ~A" (DoesSaveUnders scr) (.save_unders scr)))
	    (if (not (equal? (DoesBackingStore scr) (.backing_store scr))) 
		(snd-display #__line__ ";DoesBackingStore: ~A ~A" (DoesBackingStore scr) (.backing_store scr)))
	    (if (not (equal? (EventMaskOfScreen scr) (.root_input_mask scr))) 
		(snd-display #__line__ ";EventMaskOfScreen: ~A ~A" (EventMaskOfScreen scr) (.root_input_mask scr)))
	    
	    (if (not (equal? (XDisplayOfScreen scr) (.display scr))) 
		(snd-display #__line__ ";XDisplayOfScreen: ~A ~A" (XDisplayOfScreen scr) (.display scr)))
	    (if (not (equal? (XDisplayOfScreen (XScreenOfDisplay dpy 0)) dpy))
		(snd-display #__line__ ";XScreenOfDisplay ~A ~A" (XDisplayOfScreen (XScreenOfDisplay dpy 0)) dpy))
	    (if (not (equal? (XDefaultScreenOfDisplay dpy) scr))
		(snd-display #__line__ ";XDefaultScreenOfDisplay ~A ~A" (XDefaultScreenOfDisplay dpy) scr))
	    (if (not (equal? (XRootWindowOfScreen scr) (.root scr))) 
		(snd-display #__line__ ";XRootWindowOfScreen: ~A ~A" (XRootWindowOfScreen scr) (.root scr)))
	    (if (not (equal? (XBlackPixelOfScreen scr) (.black_pixel scr))) 
		(snd-display #__line__ ";XBlackPixelOfScreen: ~A ~A" (XBlackPixelOfScreen scr) (.black_pixel scr)))
	    (if (not (equal? (XWhitePixelOfScreen scr) (.white_pixel scr))) 
		(snd-display #__line__ ";XWhitePixelOfScreen: ~A ~A" (XWhitePixelOfScreen scr) (.white_pixel scr)))
	    (if (not (equal? (XDefaultColormapOfScreen scr) (.cmap scr))) 
		(snd-display #__line__ ";XDefaultColormapOfScreen: ~A ~A" (XDefaultColormapOfScreen scr) (.cmap scr)))
	    (if (not (equal? (XDefaultDepthOfScreen scr) (.root_depth scr))) 
		(snd-display #__line__ ";XDefaultDepthOfScreen: ~A ~A" (XDefaultDepthOfScreen scr) (.root_depth scr)))
	    (if (not (equal? (XDefaultGCOfScreen scr) (.default_gc scr)))
		(snd-display #__line__ ";XDefaultGCOfScreen: ~A ~A" (XDefaultGCOfScreen scr) (.default_gc scr)))
	    (if (not (equal? (XDefaultVisualOfScreen scr) (.root_visual scr)))
		(snd-display #__line__ ";XDefaultVisualOfScreen: ~A ~A" (XDefaultVisualOfScreen scr) (.root_visual scr)))
	    (if (not (equal? (XWidthOfScreen scr) (.width scr)))
		(snd-display #__line__ ";XWidthOfScreen: ~A ~A" (XWidthOfScreen scr) (.width scr)))
	    (if (not (equal? (XHeightOfScreen scr) (.height scr)))
		(snd-display #__line__ ";XHeightOfScreen: ~A ~A" (XHeightOfScreen scr) (.height scr)))
	    (if (not (equal? (XWidthMMOfScreen scr) (.mwidth scr))) 
		(snd-display #__line__ ";XWidthMMOfScreen: ~A ~A" (XWidthMMOfScreen scr) (.mwidth scr)))
	    (if (not (equal? (XHeightMMOfScreen scr) (.mheight scr))) 
		(snd-display #__line__ ";XHeightMMOfScreen: ~A ~A" (XHeightMMOfScreen scr) (.mheight scr)))
	    (if (not (equal? (XPlanesOfScreen scr) (.root_depth scr))) 
		(snd-display #__line__ ";XPlanesOfScreen: ~A ~A" (XPlanesOfScreen scr) (.root_depth scr)))
	    (if (not (equal? (XMinCmapsOfScreen scr) (.min_maps scr)))
		(snd-display #__line__ ";XMinCmapsOfScreen: ~A ~A" (XMinCmapsOfScreen scr) (.min_maps scr)))
	    (if (not (equal? (XMaxCmapsOfScreen scr) (.max_maps scr)))
		(snd-display #__line__ ";XMaxCmapsOfScreen: ~A ~A" (XMaxCmapsOfScreen scr) (.max_maps scr)))
	    (if (not (equal? (XDoesSaveUnders scr) (.save_unders scr)))
		(snd-display #__line__ ";XDoesSaveUnders: ~A ~A" (XDoesSaveUnders scr) (.save_unders scr)))
	    (if (not (equal? (XDoesBackingStore scr) (.backing_store scr))) 
		(snd-display #__line__ ";XDoesBackingStore: ~A ~A" (XDoesBackingStore scr) (.backing_store scr)))
	    (if (not (equal? (XEventMaskOfScreen scr) (.root_input_mask scr)))
		(snd-display #__line__ ";XEventMaskOfScreen: ~A ~A" (XEventMaskOfScreen scr) (.root_input_mask scr)))
	    )
	  
	  (let* ((scr (current-screen))
		 (scrn (XScreenNumberOfScreen scr))
		 (dpy (XtDisplay (cadr (main-widgets))))
		 (vis (DefaultVisual dpy scrn))
		 (win (XtWindow (cadr (main-widgets)))))
	    
	    (if (not (equal? (RootWindow dpy scrn) (.root scr)))
		(snd-display #__line__ ";RootWindow: ~A ~A" (RootWindow dpy scrn) (.root scr)))
	    (if (not (equal? (DefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
		(snd-display #__line__ ";DefaultRootWindow: ~A ~A" (DefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
	    (if (not (equal? (DefaultVisual dpy scrn) (.root_visual scr)))
		(snd-display #__line__ ";DefaultVisual: ~A ~A" (DefaultVisual dpy scrn) (.root_visual scr)))
	    (if (not (equal? (DefaultGC dpy scrn) (.default_gc scr)))
		(snd-display #__line__ ";DefaultGC: ~A ~A" (DefaultGC dpy scrn) (.default_gc scr)))
	    (if (not (equal? (BlackPixel dpy scrn) (.black_pixel scr)))
		(snd-display #__line__ ";BlackPixel: ~A ~A" (BlackPixel dpy scrn) (.black_pixel scr)))
	    (if (not (equal? (WhitePixel dpy scrn) (.white_pixel scr)))
		(snd-display #__line__ ";WhitePixel ~A ~A" (WhitePixel dpy scrn) (.white_pixel scr)))
	    (if (not (equal? (DisplayWidth dpy scrn) (.width scr)))
		(snd-display #__line__ ";DisplayWidth: ~A ~A" (DisplayWidth dpy scrn) (.width scr)))
	    (if (not (equal? (DisplayHeight dpy scrn) (.height scr)))
		(snd-display #__line__ ";DisplayHeight: ~A ~A" (DisplayHeight dpy scrn) (.height scr)))
	    (if (not (equal? (DisplayWidthMM dpy scrn) (.mwidth scr)))
		(snd-display #__line__ ";DisplayWidthMM: ~A ~A" (DisplayWidthMM dpy scrn) (.mwidth scr)))
	    (if (not (equal? (DisplayHeightMM dpy scrn) (.mheight scr)))
		(snd-display #__line__ ";DisplayHeightMM: ~A ~A" (DisplayHeightMM dpy scrn) (.mheight scr)))
	    (if (not (equal? (DisplayPlanes dpy scrn) (.root_depth scr)))
		(snd-display #__line__ ";DisplayPlanes: ~A ~A" (DisplayPlanes dpy scrn) (.root_depth scr)))
	    (if (not (equal? (DefaultDepth dpy scrn) (.root_depth scr)))
		(snd-display #__line__ ";DefaultDepth: ~A ~A" (DefaultDepth dpy scrn) (.root_depth scr)))
	    (if (not (equal? (DefaultColormap dpy scrn) (.cmap scr)))
		(snd-display #__line__ ";DefaultColormap: ~A ~A" (DefaultColormap dpy scrn) (.cmap scr)))
	    
	    (if (not (equal? (XRootWindow dpy scrn) (.root scr)))
		(snd-display #__line__ ";XRootWindow: ~A ~A" (XRootWindow dpy scrn) (.root scr)))
	    (if (not (equal? (XDefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
		(snd-display #__line__ ";XDefaultRootWindow: ~A ~A" (XDefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
	    (if (not (equal? (XDefaultVisual dpy scrn) (.root_visual scr)))
		(snd-display #__line__ ";XDefaultVisual: ~A ~A" (XDefaultVisual dpy scrn) (.root_visual scr)))
	    (if (not (equal? (XDefaultGC dpy scrn) (.default_gc scr)))
		(snd-display #__line__ ";XDefaultGC: ~A ~A" (XDefaultGC dpy scrn) (.default_gc scr)))
	    (if (not (equal? (XBlackPixel dpy scrn) (.black_pixel scr)))
		(snd-display #__line__ ";XBlackPixel: ~A ~A" (XBlackPixel dpy scrn) (.black_pixel scr)))
	    (if (not (equal? (XWhitePixel dpy scrn) (.white_pixel scr)))
		(snd-display #__line__ ";XWhitePixel ~A ~A" (XWhitePixel dpy scrn) (.white_pixel scr)))
	    (if (not (equal? (XDisplayWidth dpy scrn) (.width scr)))
		(snd-display #__line__ ";XDisplayWidth: ~A ~A" (XDisplayWidth dpy scrn) (.width scr)))
	    (if (not (equal? (XDisplayHeight dpy scrn) (.height scr)))
		(snd-display #__line__ ";XDisplayHeight: ~A ~A" (XDisplayHeight dpy scrn) (.height scr)))
	    (if (not (equal? (XDisplayWidthMM dpy scrn) (.mwidth scr)))
		(snd-display #__line__ ";XDisplayWidthMM: ~A ~A" (XDisplayWidthMM dpy scrn) (.mwidth scr)))
	    (if (not (equal? (XDisplayHeightMM dpy scrn) (.mheight scr)))
		(snd-display #__line__ ";XDisplayHeightMM: ~A ~A" (XDisplayHeightMM dpy scrn) (.mheight scr)))
	    (if (not (equal? (XDisplayPlanes dpy scrn) (.root_depth scr)))
		(snd-display #__line__ ";XDisplayPlanes: ~A ~A" (XDisplayPlanes dpy scrn) (.root_depth scr)))
	    (if (not (equal? (XDefaultDepth dpy scrn) (.root_depth scr)))
		(snd-display #__line__ ";XDefaultDepth: ~A ~A" (XDefaultDepth dpy scrn) (.root_depth scr)))
	    (if (not (equal? (XDefaultColormap dpy scrn) (.cmap scr)))
		(snd-display #__line__ ";XDefaultColormap: ~A ~A" (XDefaultColormap dpy scrn) (.cmap scr)))
	    
	    (if (not (equal? (XDefaultVisual dpy scrn) vis))
		(snd-display #__line__ ";XDefaultVisual: ~A ~A" (XDefaultVisual dpy scrn) vis))
	    (if (not (equal? (DisplayCells dpy scrn) (.map_entries vis)))
		(snd-display #__line__ ";DisplayCells: ~A ~A" (DisplayCells dpy scrn) (.map_entries vis)))
	    (if (not (equal? (CellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
		(snd-display #__line__ ";CellsOfScreen: ~A ~A" (CellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
	    (if (not (equal? (XDisplayCells dpy scrn) (.map_entries vis)))
		(snd-display #__line__ ";XDisplayCells: ~A ~A" (XDisplayCells dpy scrn) (.map_entries vis)))
	    (if (not (equal? (XCellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
		(snd-display #__line__ ";XCellsOfScreen: ~A ~A" (XCellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
	    (if (< (XNextRequest dpy) (XLastKnownRequestProcessed dpy))
		(snd-display #__line__ ";XRequests: ~A ~A" (XNextRequest dpy) (XLastKnownRequestProcessed dpy)))
	    (if (< (NextRequest dpy) (LastKnownRequestProcessed dpy))
		(snd-display #__line__ ";Requests: ~A ~A" (NextRequest dpy) (LastKnownRequestProcessed dpy)))
	    (if (not (= (XDisplayMotionBufferSize dpy) 256))
		(snd-display #__line__ ";XDisplayMotionBufferSize: ~A" (XDisplayMotionBufferSize dpy)))
	    (XGetMotionEvents dpy win (list 'Time 100) (list 'Time CurrentTime))
	    
	    (let ((lmapk (XNewModifiermap 2))
		  (kcd (list 'KeyCode 50)))
	      (if (not (XModifierKeymap? lmapk))
		  (snd-display #__line__ ";xNewModifiermap: ~A" lmapk)
		  (begin
		    (set! lmapk (XInsertModifiermapEntry lmapk kcd ShiftMapIndex))
		    (set! lmapk (XDeleteModifiermapEntry lmapk kcd ShiftMapIndex))
					;		      (XFreeModifiermap lmapk) ;prone to segfault in X
		    )))
	    
	    (if (not (= (XExtendedMaxRequestSize dpy) 4194303))
		(snd-display #__line__ ";XExtendedMaxRequestSize ~A" (XExtendedMaxRequestSize dpy)))
	    (if (not (= (XMaxRequestSize dpy) 65535))
		(snd-display #__line__ ";XMaxRequestSize ~A" (XMaxRequestSize dpy)))
	    (if (not (member (list 'Atom 40) (XListProperties dpy win)))
		(snd-display #__line__ ";XListProperties: ~A" (XListProperties dpy win)))
	    (if (not (member "SHAPE" (XListExtensions dpy)))
		(snd-display #__line__ ";XListExtensions: ~A" (XListExtensions dpy)))
	    (let ((val (XListInstalledColormaps dpy win)))
	      (if (or (not val)
		      (null? val)
		      (not (Colormap? (car val))))
		  (snd-display #__line__ ";XListInstalledColormaps: ~A" (XListInstalledColormaps dpy win))))
	    (if (not (string=? (XKeysymToString (list 'KeySym 80)) "P"))
		(snd-display #__line__ ";XKeysymToString: ~A" (XKeysymToString (list 'KeySym 80))))
	    (if (not (string=? (XGetAtomName dpy (list 'Atom 40)) "WM_NORMAL_HINTS"))
		(snd-display #__line__ ";XGetAtomName: ~A" (XGetAtomName dpy (list 'Atom 40))))
	    
	    (if (not (= (.bits_per_rgb vis) 8)) (snd-display #__line__ ";bits_per_rgb: ~A" (.bits_per_rgb vis)))
	    (if (not (= (.blue_mask vis) 255)) (snd-display #__line__ ";blue_mask: ~A" (.blue_mask vis)))
	    (if (not (= (.green_mask vis) 65280)) (snd-display #__line__ ";green_mask: ~A" (.green_mask vis)))
	    (if (not (= (.red_mask vis) 16711680)) (snd-display #__line__ ";red_mask: ~A" (.red_mask vis)))
	    (if (not (= AllPlanes 4294967295)) (snd-display #__line__ ";AllPlanes: ~A" AllPlanes))
	    
	    (if (< (QLength dpy) 0) (snd-display #__line__ ";QLength: ~A" (QLength dpy)))
	    (if (not (= (ScreenCount dpy) 1)) (snd-display #__line__ ";ScreenCount: ~A" (ScreenCount dpy)))
	    (if (not (string=? (ServerVendor dpy) "The X.Org Foundation")) (snd-display #__line__ ";ServerVendor: ~A" (ServerVendor dpy)))
	    (if (not (= (ProtocolRevision dpy) 0)) (snd-display #__line__ ";ProtocolRevision: ~A" (ProtocolRevision dpy)))
	    (if (not (= (ProtocolVersion dpy) 11)) (snd-display #__line__ ";ProtocolVersion: ~A" (ProtocolVersion dpy)))
	    (if (not (number? (VendorRelease dpy))) (snd-display #__line__ ";VendorRelease: ~A" (VendorRelease dpy)))
	    (if (not (string=? (DisplayString dpy) ":0.0")) (snd-display #__line__ ";DisplayString: ~A" (DisplayString dpy)))
	    (if (not (= (BitmapUnit dpy) 32)) (snd-display #__line__ ";BitmapUnit: ~A" (BitmapUnit dpy)))
	    (if (not (= (BitmapPad dpy) 32)) (snd-display #__line__ ";BitmapPad: ~A" (BitmapPad dpy)))
	    (if (not (= (BitmapBitOrder dpy) 0)) (snd-display #__line__ ";BitmapBitOrder: ~A" (BitmapBitOrder dpy)))
	    (if (not (= (ImageByteOrder dpy) 0)) (snd-display #__line__ ";ImageByteOrder: ~A" (ImageByteOrder dpy)))
	    (if (not (= (DefaultScreen dpy) 0)) (snd-display #__line__ ";DefaultScreen: ~A" (DefaultScreen dpy)))
	    
	    (let* ((col (XColor))
		   (col1 (XColor))
		   (dpy (XtDisplay (cadr (main-widgets))))
		   (scr (DefaultScreen dpy))
		   (cmap (DefaultColormap dpy scr)))
	      (if (= (XAllocNamedColor dpy cmap "blue" col col) 0) (snd-display #__line__ ";XAllocNamedColor blue ~A?" col))
	      (if (not (= (.red col) 0)) (snd-display #__line__ ";XAllocNamedColor: ~A" (.red col)))
	      (if (= (XAllocColor dpy cmap col) 0) (snd-display #__line__ ";XAllocColor?"))
	      (if (not (= (.red col) 0)) (snd-display #__line__ ";XAllocColor: ~A" (.red col)))
	      (if (= (XParseColor dpy cmap "blue" col) 0) (snd-display #__line__ ";XParseColor?"))
	      (if (not (= (.red col) 0)) (snd-display #__line__ ";XParseColor: ~A" (.red col)))
	      (if (= (XAllocNamedColor dpy cmap "green" col1 col1) 0) (snd-display #__line__ ";XAllocNamedColor green ~A?" col1))
	      (XQueryColor dpy cmap col)
	      (XQueryColors dpy cmap (list col col1)))
	    
	    (XSetAfterFunction dpy (lambda (n) 0))
	    (XSetAfterFunction dpy #f)
	    (if (not (equal? (XDisplayKeycodes dpy) (list 1 8 255)))
		(snd-display #__line__ ";XDisplayKeycodes: ~A" (XDisplayKeycodes dpy)))
	    (let ((str (XFetchName dpy win)))
	      (if (not (string=? (substring str 0 3) "snd"))
		  (snd-display #__line__ ";XFetchName: ~A" str)))
	    (XStoreName dpy win "hiho")
	    (let ((str (XFetchName dpy win)))
	      (if (not (string=? str "hiho"))
		  (snd-display #__line__ ";XStoreName: ~A" str)))
	    (XStoreName dpy win "snd")
	    (let ((str (XGetIconName dpy win)))
	      (if (not (string=? str "snd"))
		  (snd-display #__line__ ";XGetIconName: ~A" str)))
	    (XSetIconName dpy win "hiho")
	    (let ((str (XGetIconName dpy win)))
	      (if (not (string=? str "hiho"))
		  (snd-display #__line__ ";XSetIconName: ~A" str)))
	    (let ((geo (XGetGeometry dpy win)))
	      (if (or (not (= (window-width) (list-ref geo 4)))
		      (not (= (window-height) (list-ref geo 5))))
		  (snd-display #__line__ ";XGetGeometry: ~A (~A ~A)" geo (window-width) (window-height))))
	    (let ((focus (XGetInputFocus dpy)))
	      (if (or (not (= (car focus) 1))
		      (not (Window? (cadr focus))))
		  (snd-display #__line__ ";XGetInputFocus: ~A" focus)))
	    (let ((vals (XGetPointerControl dpy)))
	      (if (not (equal? vals (list 1 2 1 4))) (snd-display #__line__ ";pointer state: ~A" vals))
	      (XChangePointerControl dpy #f #t 2 1 8)
	      (set! vals (XGetPointerControl dpy))
	      (if (not (equal? vals (list 1 2 1 8))) (snd-display #__line__ ";set pointer state: ~A" vals))
	      (XChangePointerControl dpy #f #t 2 1 4))
	    (XAutoRepeatOff dpy)
	    (if (not (= (list-ref (XGetKeyboardControl dpy) 5) 0)) (snd-display #__line__ ";AutoRepeatOff?"))
	    (XAutoRepeatOn dpy)
	    (if (not (= (list-ref (XGetKeyboardControl dpy) 5) 1)) (snd-display #__line__ ";AutoRepeatOn?"))
	    (let ((vals (XGetPointerMapping dpy 0 3)))
	      (if (not (equal? vals (list 1 2 3))) (snd-display #__line__ ";XGetPointerMapping: ~A" vals)))
	    (XGetScreenSaver dpy)
	    (XMoveWindow dpy win 100 10)
	    (XSync dpy #f)
	    (XResizeWindow dpy win 400 400)
	    (XSync dpy #f)
	    (XMoveResizeWindow dpy win 120 20 500 500)
	    (XSync dpy #f)
	    (let ((attr (XGetWindowAttributes dpy win)))
	      (if (> (abs (- (.x attr) 120)) 200) (snd-display #__line__ ";XMoveWindow x etc: ~A" (.x attr)))
	      (if (> (abs (- (.y attr) 20)) 200) (snd-display #__line__ ";XMoveWindow y etc: ~A" (.y attr)))
	      (if (> (abs (- (.width attr) 500)) 20) (snd-display #__line__ ";XMoveWindow width etc: ~A" (.width attr)))
	      (if (> (abs (- (.height attr) 500)) 20) (snd-display #__line__ ";XMoveWindow height etc: ~A" (.height attr)))
	      (if (not (= (.border_width attr) 0)) (snd-display #__line__ ";XGetWindowAttributes border_width: ~A" (.border_width attr)))
	      (if (not (= (.depth attr) 24)) (snd-display #__line__ ";XGetWindowAttributes depth: ~A" (.depth attr)))
	      (if (not (= (.bit_gravity attr) 0)) (snd-display #__line__ ";XGetWindowAttributes bit_gravity: ~A" (.bit_gravity attr)))
	      (if (not (= (.win_gravity attr) 1)) (snd-display #__line__ ";XGetWindowAttributes win_gravity: ~A" (.win_gravity attr)))
	      (if (.backing_store attr) (snd-display #__line__ ";XGetWindowAttributes backing_store: ~A" (.backing_store attr)))
	      (if (.override_redirect attr) (snd-display #__line__ ";XGetWindowAttributes override_redirect: ~A" (.override_redirect attr)))
	      (if (.save_under attr) (snd-display #__line__ ";XGetWindowAttributes save_under: ~A" (.save_under attr)))
					;		(if (.map_installed attr) (snd-display #__line__ ";XGetWindowAttributes map_installed: ~A" (.map_installed attr)))
	      (if (not (equal? (.backing_pixel attr) (list 'Pixel 0))) (snd-display #__line__ ";XGetWindowAttributes backing_pixel: ~A" (.backing_pixel attr)))
	      (if (not (= (.map_state attr) 2)) (snd-display #__line__ ";XGetWindowAttributes map_state: ~A" (.map_state attr)))
	      (if (not (= (.your_event_mask attr) #x628033)) (snd-display #__line__ ";your_event_mask: ~X" (.your_event_mask attr)))
	      (if (and (not (= (.all_event_masks attr) #x628033)) 
		       (not (= (.all_event_masks attr) #xe28033))
		       (not (= (.all_event_masks attr) #xea8033)))
		  (snd-display #__line__ ";all_event_masks: ~X" (.all_event_masks attr)))
	      (if (not (Screen? (.screen attr))) (snd-display #__line__ ";XGetWindowAttributes screen: ~A" (.screen attr)))
	      (if (and (not (= (.do_not_propagate_mask attr) 0)) 
		       (not (= (.do_not_propagate_mask attr) 8204)))
		  (snd-display #__line__ ";XGetWindowAttributes do_not_propagate_mask: ~A" (.do_not_propagate_mask attr)))
	      (if (not (= (.backing_planes attr) AllPlanes)) (snd-display #__line__ ";XGetWindowAttributes backing_planes: ~A" (.backing_planes attr)))
	      (if (not (= (.win_gravity attr) 1)) (snd-display #__line__ ";XGetWindowAttributes win_gravity: ~A" (.win_gravity attr)))
	      (if (not (= (.bit_gravity attr) 0)) (snd-display #__line__ ";XGetWindowAttributes bit_gravity: ~A" (.bit_gravity attr)))
					;(segfault)	(XFree (cadr attr))
	      )
	    (XResetScreenSaver dpy)
	    (if (< (XPending dpy) 0) (snd-display #__line__ ";XPending: ~A" (XPending dpy)))
	    (XNoOp dpy)
	    (XQueryBestStipple dpy win 100 100)
	    (XQueryBestTile dpy win 100 100)
	    (XQueryBestSize dpy 0 win 100 100)
	    (let ((ext (XQueryExtension dpy "SHAPE")))
	      (if (not (eq? (car ext) #t))
		  (snd-display #__line__ ";XQueryExtension: ~A" ext)))
	    (XQueryKeymap dpy)
	    (let ((tree (XQueryTree dpy win)))
	      (if (or (not (= (car tree) 1))
		      (not (equal? (XRootWindow dpy 0) (cadr tree))))
		  (snd-display #__line__ ";XQueryTree: ~A (~A)" tree (XRootWindow dpy 0))))
	    
	    (if (< (XQLength dpy) 0) (snd-display #__line__ ";XQLength: ~A" (XQLength dpy)))
	    (if (not (= (XScreenCount dpy) 1)) (snd-display #__line__ ";XScreenCount: ~A" (XScreenCount dpy)))
	    (if (not (string=? (XServerVendor dpy) "The X.Org Foundation")) (snd-display #__line__ ";XServerVendor: ~A" (XServerVendor dpy)))
	    (if (not (= (XProtocolRevision dpy) 0)) (snd-display #__line__ ";XProtocolRevision: ~A" (XProtocolRevision dpy)))
	    (if (not (= (XProtocolVersion dpy) 11)) (snd-display #__line__ ";XProtocolVersion: ~A" (XProtocolVersion dpy)))
	    (if (not (number? (XVendorRelease dpy))) (snd-display #__line__ ";XVendorRelease: ~A" (XVendorRelease dpy)))
	    (if (not (string=? (XDisplayString dpy) ":0.0")) (snd-display #__line__ ";XDisplayString: ~A" (XDisplayString dpy)))
	    (if (not (= (XBitmapUnit dpy) 32)) (snd-display #__line__ ";XBitmapUnit: ~A" (XBitmapUnit dpy)))
	    (if (not (= (XBitmapPad dpy) 32)) (snd-display #__line__ ";XBitmapPad: ~A" (XBitmapPad dpy)))
	    (if (not (= (XBitmapBitOrder dpy) 0)) (snd-display #__line__ ";XBitmapBitOrder: ~A" (XBitmapBitOrder dpy)))
	    (if (not (= (XImageByteOrder dpy) 0)) (snd-display #__line__ ";XImageByteOrder: ~A" (XImageByteOrder dpy)))
	    (if (not (= (XDefaultScreen dpy) 0)) (snd-display #__line__ ";XDefaultScreen: ~A" (XDefaultScreen dpy)))
	    (if (XGetIconSizes dpy win) (snd-display #__line__ ";XGetIconSizes: ~A" (XGetIconSizes dpy win)))
	    (if (XGetRGBColormaps dpy win XA_RGB_DEFAULT_MAP)
		(snd-display #__line__ ";XGetRGBColormaps: ~A!" (XGetRGBColormaps dpy win XA_RGB_DEFAULT_MAP)))
	    (let ((cmap (XAllocStandardColormap)))
	      (for-each 
	       (lambda (func name)
		 (if (not (= (func cmap) 0)) (snd-display #__line__ ";standardcolormap ~A: ~A" name (func cmap))))
	       (list .visualid .red_max .red_mult .green_max .green_mult .blue_max .blue_mult)
	       (list 'visualid 'red_max 'red_mult 'green_max 'green_mult 'blue_max 'blue_mult))
	      (if (.colormap cmap) (snd-display #__line__ ";colormap: ~A" (.colormap cmap)))
	      (XtFree (cadr cmap))
	      )
	    (let ((icon (XAllocIconSize)))
	      (for-each
	       (lambda (func name)
		 (if (not (= (func icon) 0)) (snd-display #__line__ ";iconsize ~A: ~A" name (func icon))))
	       (list .min_width .min_height .max_width .max_height .width_inc .height_inc)
	       (list 'min_width 'min_height 'max_width 'max_height 'width_inc 'height_inc))
	      (XFree icon))
	    
	    (let ((fs (XCreateFontSet dpy "*-*-*-*-Normal-*-*-*-*-*-*")))
	      (if (or (not (XFontSet? fs))
		      (= (cadr fs) 0))
		  (snd-display #__line__ ";XCreateFontSet: ~A" fs)
		  (let* ((fnts (XFontsOfFontSet fs))
			 (fnt (caar fnts)))
		    (if (not (XFontStruct? fnt))
			(snd-display #__line__ ";XFontsOfFontSet: ~A" fnts))
		    (if (XContextualDrawing fs)
			(snd-display #__line__ ";XContextualDrawing: ~A" (XContextualDrawing fs)))
		    (if (XContextDependentDrawing fs)
			(snd-display #__line__ ";XContextDependentDrawing: ~A" (XContextDependentDrawing fs)))
		    (if (XDirectionalDependentDrawing fs)
			(snd-display #__line__ ";XDirectionalDependentDrawing: ~A" (XDirectionalDependentDrawing fs)))
		    (if (not (string=? (XLocaleOfFontSet fs) "en_US"))
			(snd-display #__line__ ";XLocaleOfFontSet: ~A" (XLocaleOfFontSet fs)))
		    (if (not (string=? (XBaseFontNameListOfFontSet fs) "*-*-*-*-Normal-*-*-*-*-*-*"))
			(snd-display #__line__ ";XBaseFontNameListOfFontSet: ~A" (XBaseFontNameListOfFontSet fs)))
		    (if fnt
			(let ((wgt (XGetFontProperty fnt XA_WEIGHT))
			      (siz (XGetFontProperty fnt XA_POINT_SIZE)))
			  (if (or (not (= (cadr wgt) 10))
				  (not (= (cadr siz) 120)))
			      (snd-display #__line__ ";XGetFontProperty: ~A ~A" wgt siz))
			  (if (not (= (.descent fnt) 2)) (snd-display #__line__ ";descent: ~A" (.descent fnt)))
			  (if (not (= (.ascent fnt) 11)) (snd-display #__line__ ";ascent: ~A" (.ascent fnt)))
			  (if (not (XCharStruct? (.per_char fnt))) (snd-display #__line__ ";per_char: ~A" (.per_char fnt)))
			  (if (not (XCharStruct? (.max_bounds fnt))) (snd-display #__line__ ";max_bounds: ~A" (.max_bounds fnt)))
			  (if (not (XCharStruct? (.min_bounds fnt))) (snd-display #__line__ ";min_bounds: ~A" (.min_bounds fnt)))
			  (if (not (XFontProp? (car (.properties fnt)))) (snd-display #__line__ ";properties ~A" (.properties fnt)))
			  (if (not (= (.card32 (car (.properties fnt))) 7)) (snd-display #__line__ ";card32: ~A" (.card32 (car (.properties fnt)))))))
		    (XFreeFontSet dpy fs))))
	    (XBell dpy 10)
	    (let ((cmd (XGetCommand dpy win)))
	      (if (or (not (> (length cmd) 0))
		      (not (string=? (my-substring (car cmd) (- (string-length (car cmd)) 3)) "snd")))
		  (snd-display #__line__ ";XGetCommand: ~A" cmd)))
	    (XSetCommand dpy win (list "hiho" "away") 2)
	    (if (not (equal? (XGetCommand dpy win) (list "hiho" "away"))) 
		(snd-display #__line__ ";XSetCommand: ~A" (XGetCommand dpy win)))
	    (let ((wmp (map (lambda (w) (XGetAtomName dpy w)) (XGetWMProtocols dpy win))))
	      (if (not (equal? wmp (list "_MOTIF_WM_MESSAGES" "WM_DELETE_WINDOW")))
		  (snd-display #__line__ ";XGetWMProtocols: ~A" wmp)))
	    (if (not (equal? (XListDepths dpy 0) (list 24 1 4 8 15 16 32)))
		(snd-display #__line__ ";XListDepths: ~A" (XListDepths dpy 0)))
	    (if (not (equal? (XListPixmapFormats dpy) '((1 1 32) (4 8 32) (8 8 32) (15 16 32) (16 16 32) (24 32 32) (32 32 32))))
		(snd-display #__line__ ";XListPixmapFormats: ~A" (XListPixmapFormats dpy)))
	    
	    (XWarpPointer dpy (list 'Window None) (list 'Window None) 0 0 10 10 100 100)
	    (let ((cs (XQueryBestCursor dpy win 10 10)))
	      (if (not (equal? cs (list 1 10 10))) (snd-display #__line__ ";XQueryBestCursor: ~A" cs)))
	    (let ((pt (XQueryPointer dpy win)))
	      (if (not (Window? (cadr pt))) (snd-display #__line__ ";XQueryPointer: ~A" pt)))
	    (XRaiseWindow dpy win)
	    (XRotateBuffers dpy 1)
	    (XSetWindowBorderWidth dpy win 10)
	    (XSetWindowBorder dpy win (black-pixel))
	    (XSetWindowBackground dpy win (basic-color))
	    (let* ((vis (XGetVisualInfo dpy 0 (list 'XVisualInfo 0)))
		   (depth (.depth (car vis))))
	      (XSetWindowBorderPixmap dpy win (XCreatePixmap dpy win 10 10 depth))
	      (XSetWindowBackgroundPixmap dpy win (XCreatePixmap dpy win 10 10 depth))
	      (XSetWindowBorderPixmap dpy win CopyFromParent)
	      (XSetWindowBackgroundPixmap dpy win ParentRelative)
					;(segfault)     (XFree (cadr vis))
	      )
	    (let ((hints (XGetWMHints dpy win)))
	      (if (or (not hints) (not (XWMHints? hints))) (snd-display #__line__ ";XGetWMHints?"))
	      (if (not (= (.flags hints) 7)) (snd-display #__line__ ";flags wmhints: ~A" (.flags hints)))
	      (if (not (= (.initial_state hints) 1)) (snd-display #__line__ ";initial_state wmhints: ~A" (.initial_state hints)))
	      (if (not (.input hints)) (snd-display #__line__ ";input wmhints: ~A" (.input hints)))
	      (if (not (Pixmap? (.icon_pixmap hints))) (snd-display #__line__ ";icon_pixmap wmhints: ~A" (.icon_pixmap hints)))
	      (if (.icon_window hints) (snd-display #__line__ ";icon_window: ~A" (.icon_window hints)))
	      (if (not (equal? (.icon_mask hints) (list 'Pixmap 0))) (snd-display #__line__ ";icon_mask: ~A" (.icon_mask hints)))
	      (if (not (number? (.window_group hints))) (snd-display #__line__ ";window_group: ~A" (.window_group hints)))
	      (XtFree (cadr hints))
	      (let ((st (XAllocWMHints)))
		(if (not (XWMHints? st)) (snd-display #__line__ ";XAllocWMHints: ~A" st))
		(XFree st))))
	  
	  (if (not (IsKeypadKey (list 'KeySym XK_KP_Space))) (snd-display #__line__ ";IsKeypadKey kp-space"))
	  (if (IsKeypadKey (list 'KeySym XK_A)) (snd-display #__line__ ";IsKeypadKey A"))
	  (if (IsPrivateKeypadKey (list 'KeySym XK_A)) (snd-display #__line__ ";IsPrivateKeypadKey A"))
	  (if (not (IsCursorKey (list 'KeySym XK_Home))) (snd-display #__line__ ";IsCursorKey Home"))
	  (if (IsCursorKey (list 'KeySym XK_S)) (snd-display #__line__ ";IsCursorKey S"))
	  (if (not (IsPFKey (list 'KeySym XK_KP_F1))) (snd-display #__line__ ";IsPFKey F1"))
	  (if (IsPFKey (list 'KeySym XK_S)) (snd-display #__line__ ";IsPFKey S"))
	  (if (not (IsFunctionKey (list 'KeySym XK_F1))) (snd-display #__line__ ";IsFunctionKey F1"))
	  (if (IsFunctionKey (list 'KeySym XK_S)) (snd-display #__line__ ";IsFunctionKey S"))
	  (if (not (IsMiscFunctionKey (list 'KeySym XK_Select))) (snd-display #__line__ ";IsMiscFunctionKey Select"))
	  (if (IsMiscFunctionKey (list 'KeySym XK_S)) (snd-display #__line__ ";IsMiscFunctionKey S"))
	  (if (not (IsModifierKey (list 'KeySym XK_Shift_L))) (snd-display #__line__ ";IsModifierKey Shift"))
	  (if (IsModifierKey (list 'KeySym XK_S)) (snd-display #__line__ ";IsModifierKey S"))
	  
	  (let* ((scr (current-screen))
		 (scrn (XScreenNumberOfScreen scr))
		 (dpy (XtDisplay (cadr (main-widgets))))
		 (val (XGCValues))
		 (wn (XtWindow (cadr (main-widgets)))))
	    (set! (.function val) GXclear)
	    (if (not (equal? (.function val) GXclear))
		(snd-display #__line__ ";function: ~A ~A" (.function val) GXclear))
	    (set! (.line_width val) 10)
	    (if (not (equal? (.line_width val) 10)) 
		(snd-display #__line__ ";line_width: ~A ~A" (.line_width val) 10))
	    (set! (.line_style val) LineSolid)
	    (if (not (equal? (.line_style val) LineSolid)) 
		(snd-display #__line__ ";line_style: ~A ~A" (.line_style val) LineSolid))
	    (set! (.background val) (WhitePixelOfScreen (current-screen)))
	    (if (not (equal? (.background val) (WhitePixelOfScreen (current-screen)))) 
		(snd-display #__line__ ";background: ~A ~A" (.background val) (WhitePixelOfScreen (current-screen))))
	    (set! (.foreground val) (BlackPixelOfScreen (current-screen)))
	    (if (not (equal? (.foreground val) (BlackPixelOfScreen (current-screen)))) 
		(snd-display #__line__ ";foreground: ~A ~A" (.foreground val) (BlackPixelOfScreen (current-screen))))
	    ;; plane_mask?
	    (set! (.cap_style val) CapRound)
	    (if (not (equal? (.cap_style val) CapRound)) 
		(snd-display #__line__ ";cap_style: ~A ~A" (.cap_style val) CapRound))
	    (set! (.join_style val) JoinMiter)
	    (if (not (equal? (.join_style val) JoinMiter)) 
		(snd-display #__line__ ";join_style: ~A ~A" (.join_style val) JoinMiter))
	    (set! (.fill_style val) FillSolid)
	    (if (not (equal? (.fill_style val) FillSolid)) 
		(snd-display #__line__ ";fill_style: ~A ~A" (.fill_style val) FillSolid))
	    (set! (.fill_rule val) EvenOddRule)
	    (if (not (equal? (.fill_rule val) EvenOddRule)) 
		(snd-display #__line__ ";fill_rule: ~A ~A" (.fill_rule val) EvenOddRule))
	    (set! (.arc_mode val) ArcChord)
	    (if (not (equal? (.arc_mode val) ArcChord))
		(snd-display #__line__ ";arc_mode: ~A ~A" (.arc_mode val) ArcChord))
	    ;; tile stipple clip_mask are Pixmaps
	    (set! (.ts_x_origin val) 1)
	    (if (not (equal? (.ts_x_origin val) 1)) 
		(snd-display #__line__ ";ts_x_origin: ~A ~A" (.ts_x_origin val) 1))
	    (set! (.ts_y_origin val) 1)
	    (if (not (equal? (.ts_y_origin val) 1)) 
		(snd-display #__line__ ";ts_y_origin: ~A ~A" (.ts_y_origin val) 1))
	    ;; font is Font
	    (set! (.subwindow_mode val) ClipByChildren)
	    (if (not (equal? (.subwindow_mode val) ClipByChildren)) 
		(snd-display #__line__ ";subwindow_mode: ~A ~A" (.subwindow_mode val) ClipByChildren))
	    (set! (.graphics_exposures val) #f)
	    (if (not (equal? (.graphics_exposures val) #f)) 
		(snd-display #__line__ ";graphics_exposures: ~A ~A" (.graphics_exposures val) #f))
	    (set! (.clip_x_origin val) 0)
	    (if (not (equal? (.clip_x_origin val) 0)) 
		(snd-display #__line__ ";clip_x_origin: ~A ~A" (.clip_x_origin val) 0))
	    (set! (.clip_y_origin val) 0)
	    (if (not (equal? (.clip_y_origin val) 0)) 
		(snd-display #__line__ ";clip_y_origin: ~A ~A" (.clip_y_origin val) 0))
	    (set! (.dash_offset val) 1)
	    (if (not (equal? (.dash_offset val) 1))
		(snd-display #__line__ ";dash_offset: ~A ~A" (.dash_offset val) 1))
	    (if (not (number? (XConnectionNumber dpy)))
		(snd-display #__line__ ";XConnectionNumber: ~A" (XConnectionNumber dpy)))
	    
	    (let ((sgc (XCreateGC dpy wn (+ GCFunction GCForeground GCBackground GCLineWidth GCLineStyle 
					    GCCapStyle GCJoinStyle GCFillStyle GCFillRule GCTileStipXOrigin
					    GCTileStipYOrigin GCSubwindowMode GCGraphicsExposures GCClipXOrigin
					    GCClipYOrigin GCDashOffset GCArcMode)
				  val)))
	      
	      (if (not (GC? sgc)) (snd-display #__line__ ";XCreateGC returned ~A" sgc))
	      (XSetArcMode dpy sgc ArcPieSlice)
	      (XSetFunction dpy sgc GXcopy)
	      (XSetLineAttributes dpy sgc 3 LineDoubleDash CapButt JoinMiter)
	      (XSetClipOrigin dpy sgc 1 1)
	      (XSetTSOrigin dpy sgc 0 0)
	      (XSetFillRule dpy sgc WindingRule)
	      (XSetFillStyle dpy sgc FillStippled)
	      (XSetForeground dpy sgc (WhitePixelOfScreen (current-screen)))
	      (XSetBackground dpy sgc (BlackPixelOfScreen (current-screen)))
	      (XSetGraphicsExposures dpy sgc #t)
	      (XSetSubwindowMode dpy sgc IncludeInferiors)
	      (let ((owner (XGetSelectionOwner dpy XA_PRIMARY)))
		(if (and owner (not (Window? owner)))
		    (snd-display #__line__ ";XGetSelectionOwner: ~A" owner)))
	      (let ((mods (XGetModifierMapping dpy)))
		(if (not (XModifierKeymap? mods))
		    (snd-display #__line__ ";XGetModifierMapping: ~A" mods)))
	      (let ((vis (XGetVisualInfo dpy 0 (list 'XVisualInfo 0))))
		(if (or (not vis)
			(not (XVisualInfo? (car vis))))
		    (snd-display #__line__ ";XGetVisualInfo: ~A" vis))
		(if (not (= (.depth (car vis)) 24)) (snd-display #__line__ ";depth vis: ~A" (.depth (car vis))))
		(if (not (= (.screen (car vis)) 0)) (snd-display #__line__ ";screen vis: ~A" (.screen (car vis))))
		(catch #t ; in c++ no class field
		       (lambda ()
			 (if (not (= (.class (car vis)) TrueColor)) (snd-display #__line__ ";class vis: ~A (~A)" (.class (car vis)) TrueColor)))
		       (lambda args args))
		(if (not (= (.colormap_size (car vis)) 256)) (snd-display #__line__ ";colormap_size vis: ~A" (.colormap_size (car vis))))
		(if (and (not (XVisualInfo? (XMatchVisualInfo dpy 0 24 TrueColor)))
			 (not (XVisualInfo? (XMatchVisualInfo dpy 0 16 TrueColor))))
		    (snd-display #__line__ ";XMatchVisualInfo: ~A" (XMatchVisualInfo dpy 0 24 TrueColor))))
	      (XCheckMaskEvent dpy KeyPressMask)
	      
	      (let* ((vals (XGetGCValues dpy sgc (+ GCFunction GCForeground GCBackground GCLineWidth GCLineStyle 
						    GCCapStyle GCJoinStyle GCFillStyle GCFillRule GCTileStipXOrigin
						    GCTileStipYOrigin GCSubwindowMode GCGraphicsExposures GCClipXOrigin
						    GCClipYOrigin GCDashOffset GCArcMode)))
		     (val1 (cadr vals)))
		(if (= (car vals) 0)
		    (snd-display #__line__ ";XGetGCValues failed"))
		
		(if (not (equal? (.function val1) GXcopy))
		    (snd-display #__line__ ";function: ~A ~A" (.function val1) GXcopy))
		(if (not (equal? (.line_width val1) 3)) 
		    (snd-display #__line__ ";line_width: ~A ~A" (.line_width val1) 3))
		(if (not (equal? (.line_style val1) LineDoubleDash)) 
		    (snd-display #__line__ ";line_style: ~A ~A" (.line_style val1) LineDoubleDash))
		(if (not (equal? (.background val1) (BlackPixelOfScreen (current-screen)))) 
		    (snd-display #__line__ ";background: ~A ~A" (.background val1) (BlackPixelOfScreen (current-screen))))
		(if (not (equal? (.foreground val1) (WhitePixelOfScreen (current-screen)))) 
		    (snd-display #__line__ ";foreground: ~A ~A" (.foreground val1) (WhitePixelOfScreen (current-screen))))
		(if (not (equal? (.cap_style val1) CapButt)) 
		    (snd-display #__line__ ";cap_style: ~A ~A" (.cap_style val1) CapButt))
		(if (not (equal? (.join_style val1) JoinMiter)) 
		    (snd-display #__line__ ";join_style: ~A ~A" (.join_style val1) JoinMiter))
		(if (not (equal? (.fill_style val1) FillStippled)) 
		    (snd-display #__line__ ";fill_style: ~A ~A" (.fill_style val1) FillStippled))
		(if (not (equal? (.fill_rule val1) WindingRule)) 
		    (snd-display #__line__ ";fill_rule: ~A ~A" (.fill_rule val1) WindingRule))
		(if (not (equal? (.arc_mode val1) ArcPieSlice))
		    (snd-display #__line__ ";arc_mode: ~A ~A" (.arc_mode val1) ArcPieSlice))
		(if (not (equal? (.ts_x_origin val1) 0)) 
		    (snd-display #__line__ ";ts_x_origin: ~A ~A" (.ts_x_origin val1) 0))
		(if (not (equal? (.ts_y_origin val1) 0)) 
		    (snd-display #__line__ ";ts_y_origin: ~A ~A" (.ts_y_origin val1) 0))
		(if (not (equal? (.subwindow_mode val1) IncludeInferiors)) 
		    (snd-display #__line__ ";subwindow_mode: ~A ~A" (.subwindow_mode val1) IncludeInferiors))
		(if (not (equal? (.graphics_exposures val1) #t)) 
		    (snd-display #__line__ ";graphics_exposures: ~A ~A" (.graphics_exposures val1) #t))
		(if (not (equal? (.clip_x_origin val1) 1)) 
		    (snd-display #__line__ ";clip_x_origin: ~A ~A" (.clip_x_origin val1) 1))
		(if (not (equal? (.clip_y_origin val1) 1)) 
		    (snd-display #__line__ ";clip_y_origin: ~A ~A" (.clip_y_origin val1) 1))
		(if (not (equal? (.dash_offset val1) 1))
		    (snd-display #__line__ ";dash_offset: ~A ~A" (.dash_offset val1) 1))
		
		(set! (.plane_mask val) 0)
		(if (not (equal? (.plane_mask val) 0)) 
		    (snd-display #__line__ ";plane_mask: ~A ~A" (.plane_mask val) 0))
		(set! (.tile val) (list 'Pixmap 0))
		(if (not (equal? (.tile val) (list 'Pixmap 0)))
		    (snd-display #__line__ ";tile: ~A" (.tile val)))
		(set! (.stipple val) (list 'Pixmap 0))
		(if (not (equal? (.stipple val) (list 'Pixmap 0)))
		    (snd-display #__line__ ";stipple: ~A" (.stipple val)))
		
		(let* ((dpy (XtDisplay (cadr (main-widgets))))
		       (win (XtWindow (cadr (main-widgets))))
		       (attr (XSetWindowAttributes #f (basic-color) #f (highlight-color)))
		       (newwin (XCreateWindow dpy win 10 10 100 100 3 
					      CopyFromParent InputOutput (list 'Visual CopyFromParent)
					      (logior CWBackPixel CWBorderPixel)
					      attr)))
		  (if (not (= (.do_not_propagate_mask attr) 0)) (snd-display #__line__ ";do_not_propagate_mask: ~A" (.do_not_propagate_mask attr)))
		  (if (not (= (.event_mask attr) 0)) (snd-display #__line__ ";event_mask: ~A" (.event_mask attr)))
		  (if (not (Pixel? (.backing_pixel attr))) (snd-display #__line__ ";backing_pixel: ~A" (.backing_pixel attr)))
		  (if (not (Pixel? (.border_pixel attr))) (snd-display #__line__ ";border_pixel: ~A" (.border_pixel attr)))
		  (if (not (= (cadr (.border_pixmap attr)) 0)) (snd-display #__line__ ";border_pixmap: ~A" (.border_pixmap attr)))
		  (if (not (Pixel? (.background_pixel attr))) (snd-display #__line__ ";background_pixel: ~A" (.background_pixel attr)))
		  (if (not (= (cadr (.background_pixmap attr)) 0)) (snd-display #__line__ ";background_pixmap: ~A" (.background_pixmap attr)))
		  (if (not (= (.backing_planes attr) 0)) (snd-display #__line__ ";backing_planes: ~A" (.backing_planes attr)))
		  (if (.save_under attr) (snd-display #__line__ ";save_under: ~A" (.save_under attr)))
		  (if (not (= (cadr (.cursor attr)) 0)) (snd-display #__line__ ";cursor: ~A" (.cursor attr)))
		  (if (not (Window? newwin)) (snd-display #__line__ ";XCreateWindow: ~A" newwin))
		  (if (not (= (.bit_gravity attr) 0)) (snd-display #__line__ ";bit_gravity: ~A" (.bit_gravity attr)))
		  (XChangeWindowAttributes dpy newwin CWBackPixel (XSetWindowAttributes #f (basic-color)))
		  (XDestroyWindow dpy newwin)
		  (set! newwin (XCreateSimpleWindow dpy win 10 10 100 100 3 (basic-color) (highlight-color)))
		  (XDestroyWindow dpy newwin))
		
		(XSetRegion dpy sgc (XPolygonRegion (list (XPoint 0 0) (XPoint 10 0) (XPoint 10 10) (XPoint 0 10)) 4 WindingRule))
		(let ((pix (make-pixmap (cadr (main-widgets)) arrow-strs)))
		  (if (not (Pixmap? pix)) 
		      (snd-display #__line__ ";make-pixmap?")
		      (begin
			(XSetTile dpy sgc pix)
			(XSetStipple dpy sgc (XCreateBitmapFromData dpy wn right-arrow 16 12))
			(XSetClipMask dpy sgc None)
			(XSetState dpy sgc (basic-color) (mark-color) GXcopy 0)
			(XSetPlaneMask dpy sgc 0)
			(XSetDashes dpy sgc 0 '(3 4 3 1))
			(XSetClipRectangles dpy sgc 0 0 (list (XRectangle 0 0 10 10) (XRectangle 10 10 100 100)) 2 Unsorted)
			(let ((err (XWriteBitmapFile dpy "testx.data" pix 16 12 -1 -1)))
			  (if (not (= BitmapSuccess err)) (snd-display #__line__ ";XWriteBitmapFile: ~A" err)))
					;(let ((vals (XReadBitmapFile dpy (XtWindow (cadr (main-widgets))) "testx.data")))
					;  (if (not (= (car vals BitmapSuccess))) (snd-display #__line__ ";XReadBitmapFile: ~A" vals)))
					;(let ((vals (XReadBitmapFileData "testx.data")))
					;  (if (not (= (car vals BitmapSuccess))) (snd-display #__line__ ";XReadBitmapFileData: ~A" vals)))
			
			(let* ((fid (XLoadFont dpy "cursor"))
			       (col (XColor))
			       (col1 (XColor))
			       (scr (DefaultScreen dpy))
			       (cmap (DefaultColormap dpy scr)))
			  (XAllocNamedColor dpy cmap "blue" col col)
			  (XAllocNamedColor dpy cmap "green" col1 col1)
			  (let ((vals (XCreateGlyphCursor dpy fid None XC_dot 0 col col1)))
			    (if (not (Cursor? vals)) (snd-display #__line__ ";XCreateGlyphCursor: ~A" vals)))
			  (let ((vals (XCreatePixmapCursor dpy pix None col col1 5 5)))
			    (if (not (Cursor? vals)) (snd-display #__line__ ";XCreatePixmapCursor: ~A" vals))
			    (XRecolorCursor dpy vals col1 col))
			  (XAllocColorPlanes dpy cmap #f 2 1 1 1)
			  (XAllocColorCells dpy cmap #f 1 1))
			
			
			)))
		(let* ((fid (XLoadFont dpy "-*-times-medium-r-*-*-14-*-*-*-*-*-*-*"))
		       (fnt (XLoadQueryFont dpy "-*-times-medium-r-*-*-14-*-*-*-*-*-*-*"))
		       (chs (XQueryTextExtents dpy fid "hiho"))
		       (struct (list-ref chs 4))
		       (fnt1 (XQueryFont dpy fid)))
		  (if (not (Font? fid)) (snd-display #__line__ ";XLoadFont: ~A" fid))
		  (if (not (XFontStruct? fnt)) (snd-display #__line__ ";XLoadQueryFont: ~A" fnt))
		  (if (not (XFontStruct? fnt1)) (snd-display #__line__ ";XQueryFont: ~A" fnt1))
		  (if (not (XCharStruct? struct)) (snd-display #__line__ ";XQueryTextExtents: ~A" chs))
		  (if (not (= (list-ref chs 2) 12)) (snd-display #__line__ ";XQueryTextExtents max ascent: ~A" (list-ref chs 2)))
		  (if (not (= (list-ref chs 3) 3)) (snd-display #__line__ ";XQueryTextExtents max descent: ~A" (list-ref chs 3)))
		  (if (not (= (.lbearing struct) 0)) (snd-display #__line__ ";lbearing: ~A" (.lbearing struct)))
		  (if (not (= (.rbearing struct) 23)) (snd-display #__line__ ";rbearing: ~A" (.rbearing struct)))
		  (if (not (= (.width struct) 24)) (snd-display #__line__ ";width: ~A" (.width struct)))
		  (if (not (= (.ascent struct) 10)) (snd-display #__line__ ";ascent: ~A" (.ascent struct)))
		  (if (not (= (.descent struct) 0)) (snd-display #__line__ ";descent: ~A" (.descent struct)))
		  (if (not (= (.attributes struct) 0)) (snd-display #__line__ ";attributes: ~A" (.attributes struct)))
		  (let ((fid (load-font "-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*")))
		    (if (not (Font? fid)) (snd-display #__line__ ";load-font -> ~A" fid)))
		  )
		(XFreeGC (XtDisplay (cadr (main-widgets))) sgc)
		)))
	  
	  (let ((atoms (list XA_PRIMARY XA_SECONDARY XA_ARC XA_ATOM XA_BITMAP XA_CARDINAL XA_COLORMAP XA_CURSOR XA_CUT_BUFFER0
			     XA_CUT_BUFFER1 XA_CUT_BUFFER2 XA_CUT_BUFFER3 XA_CUT_BUFFER4 XA_CUT_BUFFER5 XA_CUT_BUFFER6
			     XA_CUT_BUFFER7 XA_DRAWABLE XA_FONT XA_INTEGER XA_PIXMAP XA_POINT XA_RECTANGLE XA_RESOURCE_MANAGER
			     XA_RGB_COLOR_MAP XA_RGB_BEST_MAP XA_RGB_BLUE_MAP XA_RGB_DEFAULT_MAP XA_RGB_GRAY_MAP XA_RGB_GREEN_MAP
			     XA_RGB_RED_MAP XA_STRING XA_VISUALID XA_WINDOW XA_WM_COMMAND XA_WM_HINTS XA_WM_CLIENT_MACHINE
			     XA_WM_ICON_NAME XA_WM_ICON_SIZE XA_WM_NAME XA_WM_NORMAL_HINTS XA_WM_SIZE_HINTS XA_WM_ZOOM_HINTS
			     XA_MIN_SPACE XA_NORM_SPACE XA_MAX_SPACE XA_END_SPACE XA_SUPERSCRIPT_X XA_SUPERSCRIPT_Y
			     XA_SUBSCRIPT_X XA_SUBSCRIPT_Y XA_UNDERLINE_POSITION XA_UNDERLINE_THICKNESS XA_STRIKEOUT_ASCENT
			     XA_STRIKEOUT_DESCENT XA_ITALIC_ANGLE XA_X_HEIGHT XA_QUAD_WIDTH XA_WEIGHT XA_POINT_SIZE
			     XA_RESOLUTION XA_COPYRIGHT XA_NOTICE XA_FONT_NAME XA_FAMILY_NAME XA_FULL_NAME XA_CAP_HEIGHT
			     XA_WM_CLASS XA_WM_TRANSIENT_FOR))
		(atom-names (list 'XA_PRIMARY 'XA_SECONDARY 'XA_ARC 'XA_ATOM 'XA_BITMAP 'XA_CARDINAL 'XA_COLORMAP 'XA_CURSOR 'XA_CUT_BUFFER0
				  'XA_CUT_BUFFER1 'XA_CUT_BUFFER2 'XA_CUT_BUFFER3 'XA_CUT_BUFFER4 'XA_CUT_BUFFER5 'XA_CUT_BUFFER6
				  'XA_CUT_BUFFER7 'XA_DRAWABLE 'XA_FONT 'XA_INTEGER 'XA_PIXMAP 'XA_POINT 'XA_RECTANGLE 'XA_RESOURCE_MANAGER
				  'XA_RGB_COLOR_MAP 'XA_RGB_BEST_MAP 'XA_RGB_BLUE_MAP 'XA_RGB_DEFAULT_MAP 'XA_RGB_GRAY_MAP 'XA_RGB_GREEN_MAP
				  'XA_RGB_RED_MAP 'XA_STRING 'XA_VISUALID 'XA_WINDOW 'XA_WM_COMMAND 'XA_WM_HINTS 'XA_WM_CLIENT_MACHINE
				  'XA_WM_ICON_NAME 'XA_WM_ICON_SIZE 'XA_WM_NAME 'XA_WM_NORMAL_HINTS 'XA_WM_SIZE_HINTS 'XA_WM_ZOOM_HINTS
				  'XA_MIN_SPACE 'XA_NORM_SPACE 'XA_MAX_SPACE 'XA_END_SPACE 'XA_SUPERSCRIPT_X 'XA_SUPERSCRIPT_Y
				  'XA_SUBSCRIPT_X 'XA_SUBSCRIPT_Y 'XA_UNDERLINE_POSITION 'XA_UNDERLINE_THICKNESS 'XA_STRIKEOUT_ASCENT
				  'XA_STRIKEOUT_DESCENT 'XA_ITALIC_ANGLE 'XA_X_HEIGHT 'XA_QUAD_WIDTH 'XA_WEIGHT 'XA_POINT_SIZE
				  'XA_RESOLUTION 'XA_COPYRIGHT 'XA_NOTICE 'XA_FONT_NAME 'XA_FAMILY_NAME 'XA_FULL_NAME 'XA_CAP_HEIGHT
				  'XA_WM_CLASS 'XA_WM_TRANSIENT_FOR)))
	    (for-each
	     (lambda (n name)
	       (if (not (Atom? n))
		   (snd-display #__line__ ";Atom: ~A -> ~A" name (Atom? n))))
	     atoms
	     atom-names))
	  
	  (let ((r (XRectangle 10 20 100 110)))
	    (if (not (= (.width r) 100))
		(snd-display #__line__ ";XRectangle width: ~A" (.width r)))
	    (if (not (= (.height r) 110))
		(snd-display #__line__ ";XRectangle height: ~A" (.height r)))
	    (if (not (= (.x r) 10))
		(snd-display #__line__ ";XRectangle x: ~A" (.x r)))
	    (if (not (= (.y r) 20))
		(snd-display #__line__ ";XRectangle y: ~A" (.y r)))
	    (set! (.width r) 10)
	    (if (not (= (.width r) 10))
		(snd-display #__line__ ";set XRectangle width: ~A" (.width r)))
	    (set! (.height r) 11)
	    (if (not (= (.height r) 11))
		(snd-display #__line__ ";set XRectangle height: ~A" (.height r)))
	    (set! (.x r) 1)
	    (if (not (= (.x r) 1))
		(snd-display #__line__ ";set XRectangle x: ~A" (.x r)))
	    (set! (.y r) 2)
	    (if (not (= (.y r) 2))
		(snd-display #__line__ ";XRectangle y: ~A" (.y r))))
	  
	  (let ((r (XArc 10 20 100 110 0 235)))
	    (if (not (= (.width r) 100))
		(snd-display #__line__ ";XArc width: ~A" (.width r)))
	    (if (not (= (.height r) 110))
		(snd-display #__line__ ";XArc height: ~A" (.height r)))
	    (if (not (= (.x r) 10))
		(snd-display #__line__ ";XArc x: ~A" (.x r)))
	    (if (not (= (.y r) 20))
		(snd-display #__line__ ";XArc y: ~A" (.y r)))
	    (if (not (= (.angle1 r) 0))
		(snd-display #__line__ ";XArc angle1: ~A" (.angle1 r)))
	    (if (not (= (.angle2 r) 235))
		(snd-display #__line__ ";XArc angle2: ~A" (.angle2 r)))
	    (set! (.width r) 10)
	    (if (not (= (.width r) 10))
		(snd-display #__line__ ";set XArc width: ~A" (.width r)))
	    (set! (.height r) 11)
	    (if (not (= (.height r) 11))
		(snd-display #__line__ ";set XArc height: ~A" (.height r)))
	    (set! (.x r) 1)
	    (if (not (= (.x r) 1))
		(snd-display #__line__ ";set XArc x: ~A" (.x r)))
	    (set! (.y r) 2)
	    (if (not (= (.y r) 2))
		(snd-display #__line__ ";set XArc y: ~A" (.y r)))
	    (set! (.angle1 r) 123)
	    (if (not (= (.angle1 r) 123))
		(snd-display #__line__ ";set XArc angle1: ~A" (.angle1 r)))
	    (set! (.angle2 r) 321)
	    (if (not (= (.angle2 r) 321))
		(snd-display #__line__ ";set XArc angle2: ~A" (.angle2 r))))
	  
	  (let ((r (XPoint 10 20)))
	    (if (not (= (.x r) 10))
		(snd-display #__line__ ";XPoint x: ~A" (.x r)))
	    (if (not (= (.y r) 20))
		(snd-display #__line__ ";XPoint y: ~A" (.y r)))
	    (set! (.x r) 1)
	    (if (not (= (.x r) 1))
		(snd-display #__line__ ";set XPoint x: ~A" (.x r)))
	    (set! (.y r) 2)
	    (if (not (= (.y r) 2))
		(snd-display #__line__ ";set XPoint y: ~A" (.y r))))
	  
	  (let ((r (XSegment 10 20 100 110)))
	    (if (not (= (.x1 r) 10))
		(snd-display #__line__ ";XSegment x1: ~A" (.x1 r)))
	    (if (not (= (.y1 r) 20))
		(snd-display #__line__ ";XSegment y1: ~A" (.y1 r)))
	    (if (not (= (.x2 r) 100))
		(snd-display #__line__ ";XSegment x2: ~A" (.x2 r)))
	    (if (not (= (.y2 r) 110))
		(snd-display #__line__ ";XSegment y2: ~A" (.y2 r)))
	    (set! (.x1 r) 1)
	    (if (not (= (.x1 r) 1))
		(snd-display #__line__ ";set XSegment x1: ~A" (.x1 r)))
	    (set! (.y1 r) 2)
	    (if (not (= (.y1 r) 2))
		(snd-display #__line__ ";set XSegment y1: ~A" (.y1 r)))
	    (set! (.x2 r) 10)
	    (if (not (= (.x2 r) 10))
		(snd-display #__line__ ";set XSegment x2: ~A" (.x2 r)))
	    (set! (.y2 r) 11)
	    (if (not (= (.y2 r) 11))
		(snd-display #__line__ ";set XSegment y2: ~A" (.y2 r))))
	  
	  (let ((c (XColor)))
	    (set! (.red c) 1)
	    (if (not (= (.red c) 1)) (snd-display #__line__ ";Xcolor red: ~A" (.red c)))
	    (set! (.green c) 1)
	    (if (not (= (.green c) 1)) (snd-display #__line__ ";Xcolor green: ~A" (.green c)))
	    (set! (.blue c) 1)
	    (if (not (= (.blue c) 1)) (snd-display #__line__ ";Xcolor blue: ~A" (.blue c)))
	    (set! (.flags c) DoRed)
	    (if (not (= (.flags c) DoRed)) (snd-display #__line__ ";Xcolor flags: ~A" (.flags c)))
	    (if (not (= (.pad c) 0)) (snd-display #__line__ ";pad: ~A" (.pad c)))
	    (set! (.pixel c) (basic-color))
	    (if (not (equal? (.pixel c) (basic-color))) (snd-display #__line__ ";Xcolor pixel: ~A" (.pixel c))))
	  
	  (let ((obj (XTextItem "hiho" 4 3 (list 'Font 1))))
	    (if (not (XTextItem? obj)) (snd-display #__line__ ";XTextItem -> ~A" obj))
	    (if (not (equal? (.font obj) (list 'Font 1))) (snd-display #__line__ ";font ~A" (.font obj)))
	    (set! (.font obj) (list 'Font 2))
	    (if (not (equal? (.font obj) (list 'Font 2))) (snd-display #__line__ ";set font ~A" (.font obj)))
	    (if (not (string=? (.chars obj) "hiho")) (snd-display #__line__ ";chars: ~A" (.chars obj)))
	    (if (not (= (.nchars obj) 4)) (snd-display #__line__ ";chars: ~A" (.nchars obj)))
	    (set! (.chars obj) "away!")
	    (set! (.nchars obj) 5)
	    (if (not (string=? (.chars obj) "away!")) (snd-display #__line__ ";set chars: ~A" (.chars obj)))
	    (if (not (= (.nchars obj) 5)) (snd-display #__line__ ";set chars: ~A" (.nchars obj)))
	    (if (not (= (.delta obj) 3)) (snd-display #__line__ ";delta ~A" (.delta obj)))
	    (set! (.delta obj) 4)
	    (if (not (= (.delta obj) 4)) (snd-display #__line__ ";set delta ~A" (.delta obj)))
	    )
	  
	  (let ((reg (XPolygonRegion (list (XPoint 0 0) (XPoint 10 0) (XPoint 10 10) (XPoint 0 10)) 4 WindingRule)))
	    (if (not (XPointInRegion reg 4 4)) (snd-display #__line__ ";XPointInRegion"))
	    (XShrinkRegion reg 1 2)
	    (if (not (XPointInRegion reg 4 7)) (snd-display #__line__ ";t XShrinkRegion"))
	    (if (XPointInRegion reg 4 9) (snd-display #__line__ ";f XShrinkRegion"))
	    (XOffsetRegion reg 1 2)
	    (if (not (XPointInRegion reg 4 9)) (snd-display #__line__ ";t XOffsetRegion"))
	    (if (XPointInRegion reg 1 9) (snd-display #__line__ ";f XOffsetRegion"))
	    (let ((reg2 (XCreateRegion))
		  (reg1 (XPolygonRegion (list (XPoint 2 2) (XPoint 10 2) (XPoint 10 10) (XPoint 2 10)) 4 WindingRule)))
	      (if (XEqualRegion reg reg1) (snd-display #__line__ ";f XEqualRegion"))
	      (if (XEmptyRegion reg) (snd-display #__line__ ";f XEmptyRegion"))
	      (XXorRegion reg reg1 reg2)
	      (let ((box (XClipBox reg2)))
		(if (or (not (= (.x (cadr box)) 2))
			(not (= (.y (cadr box)) 2))
			(not (= (.width (cadr box)) 8))
			(not (= (.height (cadr box)) 2)))
		    (snd-display #__line__ ";XXorRegion: ~A ~A ~A ~A" (.x (cadr box)) (.y (cadr box)) (.width (cadr box)) (.height (cadr box)))))
	      (XUnionRegion reg reg1 reg2)
	      (let ((box (XClipBox reg2)))
		(if (or (not (= (.x (cadr box)) 2))
			(not (= (.y (cadr box)) 2))
			(not (= (.width (cadr box)) 8))
			(not (= (.height (cadr box)) 8)))
		    (snd-display #__line__ ";XUnionRegion: ~A ~A ~A ~A" (.x (cadr box)) (.y (cadr box)) (.width (cadr box)) (.height (cadr box)))))
	      (XSubtractRegion reg reg1 reg2)
	      (let ((box (XClipBox reg2)))
		(if (or (not (= (.x (cadr box)) 0))
			(not (= (.y (cadr box)) 0))
			(not (= (.width (cadr box)) 0))
			(not (= (.height (cadr box)) 0)))
		    (snd-display #__line__ ";XSubtractRegion: ~A ~A ~A ~A" (.x (cadr box)) (.y (cadr box)) (.width (cadr box)) (.height (cadr box)))))
	      (XIntersectRegion reg reg1 reg2)
	      (let ((box (XClipBox reg2)))
		(if (or (not (= (.x (cadr box)) 2))
			(not (= (.y (cadr box)) 4))
			(not (= (.width (cadr box)) 8))
			(not (= (.height (cadr box)) 6)))
		    (snd-display #__line__ ";XIntersectRegion: ~A ~A ~A ~A" (.x (cadr box)) (.y (cadr box)) (.width (cadr box)) (.height (cadr box)))))
	      (XUnionRectWithRegion (XRectangle 1 3 100 100) reg1 reg2)
	      (let ((box (XClipBox reg2)))
		(if (or (not (= (.x (cadr box)) 1))
			(not (= (.y (cadr box)) 2))
			(not (= (.width (cadr box)) 100))
			(not (= (.height (cadr box)) 101)))
		    (snd-display #__line__ ";XUnionRectWithRegion: ~A ~A ~A ~A" (.x (cadr box)) (.y (cadr box)) (.width (cadr box)) (.height (cadr box)))))
	      (XRectInRegion reg 0 0 100 100)
	      (let ((box (XClipBox reg1)))
		(if (or (not (= (.x (cadr box)) 2))
			(not (= (.y (cadr box)) 2))
			(not (= (.width (cadr box)) 8))
			(not (= (.height (cadr box)) 8)))
		    (snd-display #__line__ ";XClipBox: ~A ~A ~A ~A" (.x (cadr box)) (.y (cadr box)) (.width (cadr box)) (.height (cadr box)))))
	      (XDestroyRegion reg1)
	      ))
	  
	  (let ((xid (XUniqueContext))
		(dpy (XtDisplay (cadr (main-widgets)))))
	    (if (not (eq? (car xid) 'XContext))
		(snd-display #__line__ ";XUniqueContext: ~A" xid))
	    (XSaveContext dpy  123 xid "hiho")
	    (let ((val (XFindContext dpy 123 xid)))
	      (if (or (not (= 0 (car val)))
		      (not (string=? (cadr val) "hiho")))
		  (snd-display #__line__ ";XFindContext: ~A" val)))
	    (XDeleteContext dpy 123 xid)
	    (XStoreBytes dpy "hiho" 4)
	    (if (not (string=? (XFetchBytes dpy) "hiho")) (snd-display #__line__ ";XStoreBytes: ~A" (XFetchBytes dpy)))
	    (XStoreBuffer dpy "hiho" 4 1)
	    (if (not (string=? (XFetchBuffer dpy 1) "hiho")) (snd-display #__line__ ";XStoreBuffer: ~A" (XFetchBuffer dpy)))
	    )
	  
	  
	  ;; ---------------- Xt tests ----------------
	  (let ((name (XtGetApplicationNameAndClass (XtDisplay (cadr (main-widgets))))))
	    (if (not (equal? name (list "snd" "Snd")))
		(snd-display #__line__ ";XtGetApplicationNameAndClass: ~A?" name)))
	  (let ((dpys (XtGetDisplays (car (main-widgets)))))
	    (if (not (Display? (car dpys)))
		(snd-display #__line__ ";XtGetDisplays: ~A?" dpys)))
	  (let ((app (XtDisplayToApplicationContext (XtDisplay (cadr (main-widgets)))))
		(orig (car (main-widgets)))
		(wid (XtWidgetToApplicationContext (cadr (main-widgets)))))
	    (if (not (equal? app orig))
		(snd-display #__line__ ";XtDisplayToApplicationContext: ~A ~A?" app orig))
	    (if (not (equal? app wid))
		(snd-display #__line__ ";XtWidgetToApplicationContext: ~A ~A?" app wid)))
	  (if (not (string=? (XtName (caddr (main-widgets))) "mainpane"))
	      (snd-display #__line__ ";XtName main pane: ~A" (XtName (caddr (main-widgets)))))
	  (if (not (= (XtGetMultiClickTime (XtDisplay (cadr (main-widgets)))) 200))
	      (snd-display #__line__ ";XtGetMultiClickTime: ~A" (XtGetMultiClickTime (XtDisplay (cadr (main-widgets))))))
	  (XtSetMultiClickTime (XtDisplay (cadr (main-widgets))) 250)
	  (if (not (= (XtGetMultiClickTime (XtDisplay (cadr (main-widgets)))) 250))
	      (snd-display #__line__ ";XtSetMultiClickTime: ~A" (XtGetMultiClickTime (XtDisplay (cadr (main-widgets))))))
	  (XtGetResourceList xmListWidgetClass)
	  (let ((wid1 (XtCreateWidget "wid1" xmPushButtonWidgetClass (cadr (main-widgets)) '())))
	    (XtDestroyWidget wid1))
	  
	  (let ((hook-id (XtAppAddActionHook 
			  (car (main-widgets))
			  (lambda (w data name e p)
			    (display (format #f "~A ~A ~A ~A ~A~%" w data name e p)))
			  #f)))
	    (XtRemoveActionHook hook-id))
	  
	  (let* ((shell (cadr (main-widgets)))
		 (wid (XtCreateWidget "wid" xmFormWidgetClass shell '()))
		 (wid1 (XtCreateWidget "wid1" xmPushButtonWidgetClass wid '()))
		 (wid2 (XtVaCreateWidget "wid" xmFormWidgetClass shell '())))
	    (if (XtIsApplicationShell wid) (snd-display #__line__ ";XtIsApplicationShell"))
	    (if (not (XtIsApplicationShell shell)) (snd-display #__line__ ";XtIsApplicationShell of appshell"))
	    (if (not (XtIsComposite wid)) (snd-display #__line__ ";XtIsComposite"))
	    (if (not (XtIsConstraint wid)) (snd-display #__line__ ";XtIsConstraint"))
	    (if (XtIsManaged wid) (snd-display #__line__ ";XtIsManaged"))
	    (if (not (XtIsObject wid)) (snd-display #__line__ ";XtIsObject"))
	    (if (XtIsOverrideShell wid) (snd-display #__line__ ";XtIsOverrideShell"))
	    (if (XtIsRealized wid) (snd-display #__line__ ";XtIsRealized"))
	    (if (not (XtIsRealized shell)) (snd-display #__line__ ";XtIsRealized main shell"))
	    (if (not (XtIsRectObj wid)) (snd-display #__line__ ";XtIsRectObj"))
	    (if (not (XtIsSensitive wid)) (snd-display #__line__ ";XtIsSensitive"))
	    (if (not (XtIsSensitive shell)) (snd-display #__line__ ";XtIsSensitive of main shell"))
	    (XtSetSensitive wid1 #t)
	    (if (not (XtIsSensitive wid1)) (snd-display #__line__ ";XtIsSensitive of button"))
	    (if (XtIsSessionShell wid) (snd-display #__line__ ";XtIsSessionShell"))
	    (if (XtIsShell wid) (snd-display #__line__ ";XtIsShell"))
	    (if (not (XtIsShell shell)) (snd-display #__line__ ";XtIsShell of main shell"))
	    (if (XtIsTopLevelShell wid) (snd-display #__line__ ";XtIsTopLevelShell"))
	    (if (not (XtIsTopLevelShell shell)) (snd-display #__line__ ";XtIsTopLevelShell of main shell"))
	    (if (XtIsTransientShell wid) (snd-display #__line__ ";XtIsTransientShell"))
	    (if (XtIsVendorShell wid) (snd-display #__line__ ";XtIsVendorShell"))
	    (if (not (XtIsVendorShell shell)) (snd-display #__line__ ";XtIsVendorShell of main shell"))
	    (if (XtIsWMShell wid) (snd-display #__line__ ";XtIsWMShell"))
	    (if (not (XtIsWidget wid)) (snd-display #__line__ ";XtIsWidget"))
	    (XtRealizeWidget wid)
	    (if (not (XtIsRealized wid)) (snd-display #__line__ ";XtRealizeWidget?"))
	    (XtAddGrab shell #f #f)
	    (XtRemoveGrab shell)
	    (XtMakeResizeRequest wid 200 200)
	    (XtMapWidget wid)
	    (XtUnmapWidget wid)
	    (XtUnrealizeWidget wid)
					;(XtDestroyWidget wid1)
	    )
					;	     (XtFree 0) (XtCalloc 0 0) (XtMalloc 0) (XtRealloc 0 0)
	  (XtSetLanguageProc 
	   (car (main-widgets)) 
	   (lambda (dpy str data)
	     (snd-display #__line__ ";YOW: language proc: got ~A ~A" str data))
	   "who called us?")
	  (XtSetLanguageProc (car (main-widgets)) #f "oops")
	  (XtSetLanguageProc #f #f "oops")
	  (XtMergeArgLists (list 1 2) 2 (list 1) 1)
	  
	  (let* ((shell (cadr (main-widgets)))
		 (dpy (XtDisplay shell)))
	    (if (not (equal? (XtClass shell) applicationShellWidgetClass))
		(snd-display #__line__ ";XtClass shell: ~A" (XtClass shell)))
	    (if (not (equal? (XtSuperclass shell) topLevelShellWidgetClass))
		(snd-display #__line__ ";XtSuperclass shell: ~A" (XtClass shell)))
	    (if (not (string=? (XtName shell) "snd"))
		(snd-display #__line__ ";XtName: ~A" (XtName shell)))
	    (if (not (equal? (XtWindow shell) (XtWindowOfObject shell)))
		(snd-display #__line__ ";XtWindow: ~A ~A" (XtWindow shell) (XtWindowOfObject shell)))
	    (if (not (equal? (XtScreen shell) (XtScreenOfObject shell)))
		(snd-display #__line__ ";XtScreen: ~A ~A" (XtScreen shell) (XtScreenOfObject shell)))
	    (if (not (equal? (XtDisplay shell) (XtDisplayOfObject shell)))
		(snd-display #__line__ ";XtDisplay: ~A ~A" (XtDisplay shell) (XtDisplayOfObject shell)))
	    (if (not (Time? (XtLastTimestampProcessed dpy)))
		(snd-display #__line__ ";XtLastTimestampProcessed: ~A" (XtLastTimestampProcessed dpy)))
	    (if (not (XEvent? (XtLastEventProcessed dpy)))
		(snd-display #__line__ ";XtLastEventProcessed: ~A" (XtLastEventProcessed dpy)))
	    (XtBuildEventMask shell)
	    (let ((k (XtConvertCase dpy (XKeycodeToKeysym dpy (list 'KeyCode XK_b) 0)))
		  (x (XConvertCase (XKeycodeToKeysym dpy (list 'KeyCode XK_b) 0))))
	      (if (not (KeySym? (car k)))
		  (snd-display #__line__ ";XtConvertCase: ~A" k))
	      (if (not (equal? k x))
		  (snd-display #__line__ ";X(t)ConvertCase: ~A ~A" k x)))
	    (let ((val 0))
	      (XtRegisterCaseConverter 
	       dpy
	       (lambda (dp key)
		 (set! val 123)
		 (list (list 'KeySym 65)
		       (list 'KeySym 97)))
	       (list 'KeySym 65)
	       (list 'KeySym 65))
	      (XtConvertCase dpy (list 'KeySym 65))
	      (if (not (= val 123)) (snd-display #__line__ ";XtRegisterCaseConverter: ~A" val)))
	    (XtRegisterGrabAction (lambda (a b c) #f) #f ColormapChangeMask GrabModeSync GrabModeAsync)
	    (let ((vals (XtTranslateKeycode dpy (list 'KeyCode XK_B) 0)))
	      (if (or (not (= (car vals) 0))
		      (not (KeySym? (cadr vals))))
		  (snd-display #__line__ ";XtTranslateKeycode: ~A" vals))
	      (if (not (equal? vals (XtTranslateKey dpy (list 'KeyCode XK_B) 0)))
		  (snd-display #__line__ ";XtTranslateKey: ~A ~A" vals (XtTranslateKey dpy (list 'KeyCode XK_B) 0)))
	      (XtSetKeyTranslator dpy #f)
	      (if (not (equal? vals (XtTranslateKeycode dpy (list 'KeyCode XK_B) 0)))
		  (snd-display #__line__ ";XtSetKeyTranslator #f: ~A ~A" vals (XtTranslateKeycode dpy (list 'KeyCode XK_B) 0)))
	      (XtSetKeyTranslator dpy (lambda (d k m)
					(if (not (equal? d dpy)) (snd-display #__line__ ";d in keyproc: ~A ~A" d dpy))
					(XtTranslateKey d k m)))
	      (let ((newvals (XtTranslateKeycode dpy (list 'KeyCode XK_B) 0)))
		(if (not (equal? vals newvals)) (snd-display #__line__ ";XtSetKeyTranslator: ~A ~A" vals newvals)))
	      (XtSetKeyTranslator dpy #f))
	    (if (not (KeySym? (cadr (XmTranslateKey dpy (list 'KeyCode XK_B) 0))))
		(snd-display #__line__ ";XmTranslateKey: ~A" (XmTranslateKey dpy XK_B 0)))
	    (let ((kv (XtKeysymToKeycodeList dpy (list 'KeySym 65509))))
	      (if (not (equal? (car kv) (list 'KeyCode 66))) 
		  (snd-display #__line__ ";XtKeysymToKeycodeList: ~A ~A" kv (XtKeysymToKeycodeList dpy (list 'KeySym 65509)))))
	    (XtInstallAllAccelerators (cadr (main-widgets)) (caddr (main-widgets)))
	    (XtInstallAccelerators (cadr (main-widgets)) (caddr (main-widgets)))
	    (if (not (equal? (list 0 1 2) (XtSetArg 0 1 2))) (snd-display #__line__ ";XtSetArg: ~A" (XtSetArg 0 1 2)))
	    (if (not (Widget? (XtGetKeyboardFocusWidget (cadr (main-widgets)))))
		(snd-display #__line__ ";XtGetKeyboardFocusWidget: ~A" (XtGetKeyboardFocusWidget (cadr (main-widgets)))))
	    (let ((id (XtAppAddInput (car (main-widgets)) 1 XtInputReadMask (lambda (a b c) #f) #f)))
	      (XtRemoveInput id))
	    
	    (let ((id (XtAppAddWorkProc (car (main-widgets)) (lambda (me) #f) #f)))
	      (XtRemoveWorkProc id))
	    (if (not (equal? (caddr (main-widgets)) (XtNameToWidget (cadr (main-widgets)) "mainpane")))
		(snd-display #__line__ ";XtNameToWidget: ~A ~A" (caddr (main-widgets)) (XtNameToWidget (cadr (main-widgets)) "mainpane")))
	    (XtVaCreatePopupShell "hiho" vendorShellWidgetClass (cadr (main-widgets)) '())
	    (XtResolvePathname (XtDisplay (cadr (main-widgets))) "app-defaults" #f #f #f #f 0 #f)
	    (XtFindFile ".snd" #f 0 #f)
	    
	    (XtAppLock (car (main-widgets)))
	    (XtAppUnlock (car (main-widgets)))
	    (let ((acts (XtGetActionList xmLabelWidgetClass)))
	      (if (or (not (= (length acts) 4))
		      (not (string=? (caar acts) "Enter")))
		  (snd-display #__line__ ";XtGetActionList: ~A" acts)))
	    )
	  
	  (let ((pop (XtCreatePopupShell "hiho" xmGrabShellWidgetClass (cadr (main-widgets))
					 (list XmNiconNameEncoding XA_STRING))))
	    (XtPopup pop XtGrabNone)
	    (XtPopdown pop))
	  (XtAppSetWarningHandler (car (main-widgets))
				  (lambda (n) 
				    (if (not (string=? n "hiho"))
					(snd-display #__line__ ";XtWarning: ~A" n))))
	  (XtAppSetWarningMsgHandler (car (main-widgets)) 
				     (lambda (name type klass def pars num)
				       (snd-print (format #f ";ignore: ~A ~A ~A~%" name def pars))))
	  
	  (let ((listener (list-ref (main-widgets) 4)))
	    (XtCallActionProc listener "text-transpose" (XEvent) #f 0)
	    (XtCallActionProc listener "begin-of-line" (XEvent) #f 0)
	    (XtCallActionProc listener "kill-line" (XEvent) #f 0)
	    (XtCallActionProc listener "yank" (XEvent) #f 0)
	    (XtCallActionProc listener "name-completion" (XEvent) #f 0)
	    (XtCallActionProc listener "listener-completion" (XEvent) #f 0)
	    (XtCallActionProc listener "no-op" (XEvent) #f 0)
	    (XtCallActionProc listener "delete-region" (XEvent) #f 0)
	    (XtCallActionProc listener "listener-g" (XEvent) #f 0)
	    (XtCallActionProc listener "listener-clear" (XEvent) #f 0)
	    (XtCallActionProc listener "b1-press" (XEvent) #f 0)
	    (XtCallActionProc listener "delete-to-previous-command" (XEvent) #f 0)
	    (let ((BEvent (XEvent ButtonPress)))
	      (set! (.x BEvent) 10)
	      (set! (.y BEvent) 10)
	      (XtCallActionProc listener "b1-press" BEvent #f 0)
	      (XtCallActionProc listener "b1-release" BEvent #f 0))
	    (XtCallActionProc listener "word-upper" (XEvent) (list "u") 1))
	  
	  (let ((ind (open-sound "oboe.snd")))
	    (set! (show-controls ind) #t)
	    (let* ((swids (sound-widgets ind))
		   (spane (car swids))
		   (sctrls (list-ref swids 2))
		   (cmain (find-child spane "chn-main-window"))
		   (wh (widget-size sctrls)))
	      (XtUnmanageChild sctrls)
	      (set! (widget-size sctrls) (list (car wh) (* (cadr wh) 3)))
	      (XtManageChild sctrls)
	      
	      (let ((tag (catch #t (lambda () (XtVaGetValues (car (sound-widgets)) (list "XmNpaneMaximum" 0)))
				(lambda args (car args)))))
		(if (not (eq? tag 'no-such-resource))
		    (snd-display #__line__ ";XtVaGetValues of incorrectly quoted resource name: ~A" tag)))
	      )
	    
	    (close-sound ind))
	  
	  
	  ;; ---------------- XM tests ----------------
	  (let* ((label-render-table (cadr (XtVaGetValues (cadr (main-widgets)) (list XmNlabelRenderTable 0))))
		 (renditions (and label-render-table 
				  (XmRenderTableGetRenditions label-render-table (XmRenderTableGetTags label-render-table))))
		 (default-font-name (and renditions
					 (cadr (XmRenditionRetrieve (car renditions) (list XmNfontName 0)))))
		 (default-font-info (and renditions
					 (XmRenditionRetrieve (car renditions) (list XmNfont 0 XmNfontType 0)))))
	    (if (not (string=? default-font-name "fixed")) (snd-display #__line__ ";XmRenderTableGetRenditions name: ~A" default-font-name))
	    (if (not (XFontStruct? (list-ref default-font-info 1))) (snd-display #__line__ ";XmRenderTableGetRenditions font struct: ~A" default-font-info))
	    (if (not (= (list-ref default-font-info 3) XmFONT_IS_FONT)) (snd-display #__line__ ";XmRenderTableGetRenditions font type: ~A" default-font-info)))
	  
	  
	  (let* ((button-render-table (cadr (XtVaGetValues (cadr (main-widgets)) (list XmNbuttonRenderTable 0))))
		 (default-rendition (and button-render-table 
					 (XmRenderTableGetRendition button-render-table XmFONTLIST_DEFAULT_TAG)))
		 (default-font-info (and default-rendition
					 (XmRenditionRetrieve default-rendition (list XmNfont 0 XmNfontType 0)))))
	    (if (and default-font-info
		     (= (list-ref default-font-info 3) XmFONT_IS_FONT))
		(let* ((font (cadr default-font-info))
		       (dpy (XtDisplay (cadr (main-widgets))))
		       (data '()))
		  (for-each (lambda (name atom?)
			      (let ((val (XGetFontProperty font name)))
				(if (car val)
				    (set! data (cons (list (XGetAtomName (XtDisplay (cadr (main-widgets))) name)
							   (if atom? 
							       (XGetAtomName (XtDisplay (cadr (main-widgets))) (list 'Atom (cadr val)))
							       (cadr val)))
						     data)))))
			    (list XA_POINT_SIZE XA_FONT XA_FULL_NAME 
				  (XInternAtom dpy "XA_SLANT" #f) 
				  (XInternAtom dpy "XA_WEIGHT_NAME" #f) 
				  XA_FAMILY_NAME 
				  (XInternAtom dpy "XA_FOUNDRY" #f) 
				  XA_CAP_HEIGHT)
			    (list #f #t #t #t #t #t #t #f))
		  (if (not (string=? "Fixed" (cadr (list-ref data 1)))) (snd-display #__line__ ";XmRenderTableGetRendition: ~A" data)))))
	  
	  (let ((dpy (XtDisplay (cadr (main-widgets))))
		(win (XtWindow (cadr (main-widgets)))))
	    (let ((version (list-ref (XGetWindowProperty dpy win
							 (XInternAtom (XtDisplay (cadr (main-widgets)))
								      "SND_VERSION"
								      #f)
							 0 32 #f XA_STRING)
				     5)))
	      (XDeleteProperty dpy win (XInternAtom dpy "AN_ATOM" #f))
	      (if (not (string=? version (snd-version)))
		  (snd-display #__line__ ";SND_VERSION: ~A, ~A?" version (snd-version)))))
	  
	  (let* ((tabs (let ((ctr 0))
			 (map
			  (lambda (n)
			    (set! ctr (+ ctr 1))
			    (XmTabCreate n XmINCHES (if (= ctr 1) XmABSOLUTE XmRELATIVE) XmALIGNMENT_BEGINNING "."))
			  (list 1.5 1.5 1.5 1.5))))
		 (tablist (XmTabListInsertTabs #f tabs (length tabs) 0)))
	    (if (not (= (XmTabListTabCount tablist) (length tabs))) 
		(snd-display #__line__ ";tablist len: ~A ~A~%" (XmTabListTabCount tablist) (length tabs)))
	    (if (not (equal? (XmTabGetValues (XmTabListGetTab tablist 0)) (list 1.5 5 0 0 ".")))
		(snd-display #__line__ ";XmTabs 0: ~A" (XmTabGetValues (XmTabListGetTab tablist 0))))
	    (if (not (equal? (XmTabGetValues (XmTabListGetTab tablist 2)) (list 1.5 5 1 0 ".")))
		(snd-display #__line__ ";XmTabs 2: ~A" (XmTabGetValues (XmTabListGetTab tablist 2))))
	    (let ((copytab (XmTabListCopy tablist 0 0)))
	      (if (not (equal? (XmTabGetValues (XmTabListGetTab copytab 0)) (list 1.5 5 0 0 ".")))
		  (snd-display #__line__ ";XmTabListCopy 0: ~A" (XmTabGetValues (XmTabListGetTab copytab 0))))
	      (let ((another (XmTabListRemoveTabs copytab (list 0 1)))
		    (atab (XmTabCreate 3.0 XmINCHES XmABSOLUTE XmALIGNMENT_BEGINNING ".")))
		(if (not (equal? (XmTabGetValues (XmTabListGetTab another 0)) (list 1.5 5 1 0 ".")))
		    (snd-display #__line__ ";XmTabListRemoveTabs: ~A" (XmTabGetValues (XmTabListGetTab another 0))))
		(XmTabListReplacePositions (XmTabListCopy tablist 0 0) (list 1) (list atab))
		;; this (replacepositions) is very prone to segfaults -- *very* poorly implemented! 
		(XmTabSetValue atab 6.0)
		(XmTabFree atab)
		(XmTabListFree another))
	      (let ((tabl (XmStringTableProposeTablist
			   (list (XmStringCreateLocalized "a-string") (XmStringCreateLocalized "another")) 2
			   (cadr (main-widgets))
			   1.0
			   XmABSOLUTE)))
		(if (not (XmTabList? tabl)) (snd-display #__line__ ";XmStringTableProposeTabList: ~A" tabl))
		(XmTabListFree tabl)))
	    
	    (let ((hname (host-name))) ; from snd-motif.scm
	      (if (not (equal? hname (getenv "HOSTNAME")))
		  (snd-display #__line__ ";host name appears to be ~A or maybe ~A" hname (getenv "HOSTNAME"))))
	    (let ((blu (x->snd-color "blue")))
	      (if (not (Pixel? blu)) (snd-display #__line__ ";x->snd-color can't find blue! ~A" blu))
	      (if (not (equal? (color->list blu) (list 0.0 0.0 1.0)))
		  (snd-display #__line__ ";x->snd-color blue: ~A" (color->list blu))))
	    
	    (let* ((tmp (XmStringCreateLocalized "h"))
		   (pm (XmParseMappingCreate (list XmNincludeStatus XmINSERT
						   XmNsubstitute    tmp
						   XmNpattern       "i"
						   XmNpatternType   XmCHARSET_TEXT))))
	      (XmStringFree tmp)
	      (XmParseMappingFree pm)
	      (set! pm (XmParseMappingCreate (list XmNinvokeParseProc
						   (lambda (txt end type tag entry pattern str call)
						     #f))))
	      (XmParseMappingFree pm)
	      (let ((tag (catch #t (lambda ()
				     (set! pm (XmParseMappingCreate (list XmNinvokeParseProc
									  (lambda (txt end type tag entry pattern)
									    #f)))))
				(lambda args (car args)))))
		(if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmNinvokeParseProc wrong arity: ~A" tag))))
	    
	    (let* ((fonts (list "fixed"
				"-*-times-bold-r-*-*-14-*-*-*-*-*-*-*"
				"-*-*-medium-i-*-*-18-*-*-*-*-*-*-*"
				"-*-helvetica-*-*-*-*-18-*-*-*-*-*-*-*"))
		   (tags (list "one" "two" "three" "four"))
		   (colors (list "red" "green" "blue" "orange"))
		   (pixels
		    (let* ((dpy (XtDisplay (cadr (main-widgets))))
			   (scr (DefaultScreen dpy))
			   (cmap (DefaultColormap dpy scr)))
		      (let ((col (XColor)))
			(XParseColor dpy cmap "blue" col)
			(if (or (not (= (.red col) 0))
				(not (= (.green col) 0))
				(not (= (.blue col) 65535)))
			    (snd-display #__line__ ";XParseColor: ~A ~A ~A ~A" col (.red col) (.blue col) (.green col)))
			(XLookupColor dpy cmap "red" col (XColor))
			(if (or (not (= (.red col) 65535))
				(not (= (.green col) 0))
				(not (= (.blue col) 0)))
			    (snd-display #__line__ ";XLookupColor: ~A ~A ~A ~A" col (.red col) (.blue col) (.green col))))
		      (map
		       (lambda (color)
			 (let ((col (XColor)))
			   (if (= (XAllocNamedColor dpy cmap color col col) 0)
			       (snd-error (format #f "can't allocate ~A" color))
			       (.pixel col))))
		       colors)))
		   (rendertable (XmRenderTableAddRenditions #f 
							    (let ((ctr 0))
							      (map (lambda (r)
								     (set! ctr (+ ctr 1))
								     (XmRenditionCreate (cadr (main-widgets))
											r
											(append
											 (if (= ctr 1)
											     (list XmNtabList tablist)
											     '())
											 (list XmNrenditionForeground (list-ref pixels (- ctr 1))
											       XmNfontName (list-ref fonts (- ctr 1))
											       XmNfontType XmFONT_IS_FONT))))
								   tags))
							    (length tags)
							    XmMERGE_NEW)))
	      
	      (if (file-exists? "hiho") (delete-file "hiho"))
	      (let* ((dpy (XtDisplay (cadr (main-widgets))))
		     (scr (DefaultScreenOfDisplay dpy))
		     (p1 (XmGetPixmap scr "hiho" (car pixels) (cadr pixels))))
		(if (not (Pixmap? p1)) (snd-display #__line__ ";XmGetPixmap: ~A" p1))
		(set! p1 (XmGetPixmapByDepth scr "hoho" (car pixels) (cadr pixels) (XDefaultDepth dpy (XScreenNumberOfScreen scr))))
		(if (not (Pixmap? p1)) (snd-display #__line__ ";XmGetPixmapByDepth: ~A" p1))
		(XmDestroyPixmap scr p1))
	      
	      (let ((tabl (XmStringTableParseStringArray (list "hi" "ho") 2 "hiho" XmCHARSET_TEXT #f 0 #f)))
		(if (not (XmString? (car tabl))) (snd-display #__line__ ";XmStringTableParseStringArray: ~A" tabl))
		(let ((strs (XmStringTableUnparse tabl 2 "hiho" XmCHARSET_TEXT XmCHARSET_TEXT #f 0 XmOUTPUT_ALL)))
		  (if (not (equal? strs (list "hi" "ho"))) (snd-display #__line__ ";XmStringTableUnparse: ~A" strs)))
		(let ((str (XmStringTableToXmString tabl 2 #f)))
		  (if (not (XmString? str)) (snd-display #__line__ ";XmStringTableToXmString: ~A" str))
		  (XmStringToXmStringTable str #f)
		  (let ((val (XmStringUnparse str "hiho" XmCHARSET_TEXT XmCHARSET_TEXT #f 0 XmOUTPUT_ALL)))
		    (if (not (string=? val "hiho")) (snd-display #__line__ ";XmStringUnparse: ~A" val))
		    (set! val (XmStringUnparse (XmStringCreateLocalized "hi") #f XmCHARSET_TEXT XmCHARSET_TEXT #f 0 XmOUTPUT_ALL))
		    (if (not (string=? val "hi")) (snd-display #__line__ ";XmStringUnparse null tag: ~A" val)))
		  ;; XmCvtXmStringToByteStream test deleted because it seems to be buggy in memory handling
		  (let* ((ind (open-sound "oboe.snd"))
			 (grf1 (car (channel-widgets)))
			 (dpy (XtDisplay grf1))
			 (win (XtWindow grf1))
			 (scr (DefaultScreenOfDisplay dpy))
			 (scrn (XScreenNumberOfScreen scr))
			 (gv (XGCValues)))
		    (if (not (Font? (current-font ind))) (snd-display #__line__ ";current-font: ~A" (current-font ind)))
		    (let ((old-font (current-font))
			  (a-font (load-font "6x12")))
		      (set! (current-font) a-font)
		      (if (not (equal? a-font (current-font)))
			  (snd-display #__line__ ";set current-font: ~A ~A" a-font (current-font)))
		      (set! (current-font ind) old-font)
		      (if (not (equal? old-font (current-font ind)))
			  (snd-display #__line__ ";set current-font with ind: ~A ~A" old-font (current-font ind)))
		      (set! (current-font) a-font)
		      (set! (current-font ind 0) old-font)
		      (if (not (equal? old-font (current-font ind 0)))
			  (snd-display #__line__ ";set current-font with ind/0: ~A ~A" old-font (current-font ind 0)))
		      (set! (current-font) old-font))
		    
		    (set! (.foreground gv) (data-color))
		    (set! (.background gv) (basic-color))
		    (set! (.function gv) GXcopy)
		    (let* ((sgc (XtAllocateGC grf1
					      (XDefaultDepth dpy scrn) 
					      (logior GCForeground GCBackground GCFunction)
					      gv
					      (logior GCFont GCDashList)
					      0))
			   (str2 (XmStringCreateLocalized "hiho")))
		      (XmStringDraw dpy win rendertable str2 sgc 10 10 100 
				    XmALIGNMENT_END XmSTRING_DIRECTION_L_TO_R (XRectangle 0 0 100 100))
		      (XmStringDrawImage dpy win rendertable str2 sgc 10 10 100 
					 XmALIGNMENT_END XmSTRING_DIRECTION_L_TO_R (XRectangle 0 0 100 100))
		      (XmStringDrawUnderline dpy win rendertable str2 sgc 10 10 100 
					     XmALIGNMENT_END XmSTRING_DIRECTION_L_TO_R (XRectangle 0 0 100 100) str2)
		      (XtGetGC (cadr (main-widgets)) GCForeground gv)
		      (XCopyGC dpy sgc GCFunction sgc)
		      (XCopyArea dpy win win sgc 0 0 100 100 0 0)
		      (XCopyPlane dpy win win sgc 0 0 100 100 0 0 1)
		      (XtReleaseGC grf1 sgc))
		    (close-sound ind))
		  (let ((lc (XmStringLineCount (XmStringCreateLocalized "hiho"))))
		    (if (not (= lc 1)) (snd-display #__line__ ";XmStringLineCount: ~A" lc)))
		  (if (not (XmStringHasSubstring str (XmStringCreateLocalized "hi"))) (snd-display #__line__ ";XmStringHasSubstring?"))))
	      
	      
	      (if (not (equal? (XmRenderTableGetTags rendertable) (list "one" "two" "three" "four")))
		  (snd-display #__line__ ";tags: ~A~%" (XmRenderTableGetTags rendertable)))
	      (let* ((rend (XmRenderTableGetRendition rendertable "one"))
		     (r (and rend (XmRenditionRetrieve rend
						       (list XmNrenditionForeground 0
							     XmNfontName 0
							     XmNfontType 0
							     XmNtag 0)))))
		(if (and rend r)
		    (begin
		      (if (or (not (string=? (list-ref r 7) "one"))
			      (not (string=? (list-ref r 3) "fixed")))
			  (snd-display #__line__ ";rendertable: ~A" r))
		      (XmRenditionUpdate rend (list XmNstrikethruType XmSINGLE_LINE))
		      (if (not (= (cadr (XmRenditionRetrieve rend (list XmNstrikethruType 0))) XmSINGLE_LINE))
			  (snd-display #__line__ ";XmRenditionUpdate: ~A ~A" (cadr (XtGetValues rend (list XmNstrikethruType 0))) XmSINGLE_LINE)))
		    (snd-display #__line__ ";r and rend: ~A ~A~%" r rend)))
	      (let ((r1 (XmRenditionCreate (cadr (main-widgets)) "r1" (list XmNfontName "fixed"))))
		(XmRenditionFree r1))
	      
	      (if (not (equal? (XmDropSiteQueryStackingOrder (list-ref (main-widgets) 4)) (list #f)))
		  (snd-display #__line__ ";XmDropSiteQueryStackingOrder: ~A" (XmDropSiteQueryStackingOrder (list-ref (main-widgets) 4)) (list #f)))
	      (let ((tab (XmStringComponentCreate XmSTRING_COMPONENT_TAB 0 #f))
		    (row #f)
		    (table '())
		    (our-tags tags))
		(for-each 
		 (lambda (word)
		   (let ((entry (XmStringGenerate word
						  #f
						  XmCHARSET_TEXT
						  (car our-tags))))
		     (if (XmStringIsVoid entry) (snd-display #__line__ ";~A is void?" entry))
		     (if (XmStringEmpty entry) (snd-display #__line__ ";~A is empty?" entry))
		     
		     (if row
			 (let ((tmp (XmStringConcat row tab)))
			   (XmStringFree row)
			   (set! row (XmStringConcatAndFree tmp entry)))
			 (set! row entry))
		     (set! our-tags (cdr our-tags))
		     (if (null? our-tags) 
			 (begin
			   (set! our-tags tags)
			   (set! table (cons row table))
			   (set! row #f)))))
		 (list "this" "is" "a" "test" "of" "the" "renditions" "and" "rendertables" 
		       "perhaps" "all" "will" "go" "well" "and" "then" "again" "perhaps" "not"))
		(let* ((n (car table))
		       (c (XmStringInitContext n))
		       (ctr 0)
		       (happy #t))
		  (do ((i 0 (+ 1 i)))
		      ((not happy))
		    (let ((type (XmStringGetNextTriple (cadr c))))
		      (if (= (car type) XmSTRING_COMPONENT_TEXT)
			  (if (or (not (= (cadr type) (list-ref (list 0 0 2 0 0 0 4 0 0 0 3 0 0 0 4) i)))
				  (not (string=? (caddr type) 
						 (list-ref (list "o" "o" "go" "o" "o" "o" "well" "o" "o" "o" "and" "o" "o" "o" "then") i))))
			      (snd-display #__line__ ";component ~A -> ~A" i (cdr type)))
			  (if (not (= (car type) XmSTRING_COMPONENT_TAB))
			      (if (= (car type) XmSTRING_COMPONENT_END)
				  (set! happy #f))))))
		  (XmStringFreeContext (cadr c))))))
	  
	  (XtAppAddActions (car (main-widgets))
			   (list (list "try1" (lambda (w e strs)	
						(snd-display #__line__ ";try1: ~A~%" strs)))
				 (list "try2" (lambda (w e strs)
						(snd-display #__line__ ";try2: ~A~%" strs)))))
	  (let* ((tab (XtParseTranslationTable 
		       (format #f "Ctrl <Key>osfLeft:  try1()~%Ctrl <Key>osfRight: try2()~%Ctrl <Key>osfUp:  try1(hiho)~%Ctrl <Key>osfDown: try2(down, up)~%")))
		 (pane (add-main-pane "hiho" xmTextWidgetClass '())))
	    (XtOverrideTranslations pane tab))
	  (if (defined? 'XtAddActions)
	      (XtAddActions (list (list "try3" (lambda (w e strs)	
						 (snd-display #__line__ ";try3: ~A~%" strs)))
				  (list "try4" (lambda (w e strs)
						 (snd-display #__line__ ";try4: ~A~%" strs))))))
	  
	  (let ((XmNhiho (add-resource "hiho" 0)))
	    (if (not (string=? XmNhiho "hiho")) (snd-display #__line__ ";add-resource XmNhiho: ~A" XmNhiho)))
	  
	  (open-sound "cardinal.snd")
	  (let*  ((mouse_width 32)
		  (mouse_height 32)
		  (mouse_bits (list
			       #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00
			       #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00
			       #x80 #xff #xff #x01 #x80 #x00 #x01 #x01 #x80 #x00 #x01 #x01
			       #x80 #x00 #x01 #x01 #x80 #x00 #x01 #x01 #x80 #x00 #x01 #x01
			       #x80 #x00 #x01 #x01 #x80 #xff #xff #x01 #x80 #x00 #x00 #x01
			       #x80 #x00 #x00 #x01 #x80 #x00 #x00 #x01 #x80 #x00 #x00 #x01
			       #x80 #x00 #x00 #x01 #x80 #x00 #x00 #x01 #x80 #x00 #x00 #x01
			       #x80 #x00 #x00 #x01 #x00 #x01 #x80 #x00 #x00 #x01 #x80 #x00
			       #x00 #x06 #x60 #x00 #x00 #xf8 #x1f #x00 #x00 #x00 #x00 #x00
			       #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00
			       #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00))
		  (rb (list
		       #x00 #x04 #x10 #x08 #x00 #x10 #x04 #x20 #x00 #x40 #xa5 #xbf
		       #x00 #x40 #x04 #x20 #x00 #x10 #x10 #x08 #x00 #x04 #x00 #x00))
		  (iconw (list-ref (sound-widgets) 8))
		  (dpy (XtDisplay iconw))
		  (win (XtWindow iconw)))
	    (XCreateBitmapFromData dpy win rb 16 12)
	    (XCreateBitmapFromData dpy win mouse_bits mouse_width mouse_height)
	    (XCreatePixmapFromBitmapData dpy win mouse_bits 32 32 (white-pixel) (black-pixel) 8))
	  
	  (let* ((grf1 (car (channel-widgets)))
		 (dpy (XtDisplay grf1))
		 (win (XtWindow grf1))
		 (sgc (car (snd-gcs)))
		 (shell (cadr (main-widgets)))
		 (scr (DefaultScreen dpy))
		 (vis (DefaultVisual dpy scr))
		 (depth (cadr (XtGetValues grf1 (list XmNdepth 0))))
		 (pix (XCreatePixmap dpy win 10 10 depth))
		 (rotpix (XCreatePixmap dpy win 10 10 depth)))
	    
	    (XDrawText dpy win sgc 50 50 (list (XTextItem "hi" 2 2 '(Font 0))
					       (XTextItem "ho" 2 3 '(Font 0))))
	    
	    (let ((cmap (XCreateColormap dpy win vis AllocNone)))
	      (set! cmap (XCopyColormapAndFree dpy cmap))
	      (XFreeColormap dpy cmap)
	      (if (XCheckTypedWindowEvent dpy win ExposureMask) 
		  (snd-display #__line__ ";XCheckTypedWindowEvent: ~A" (XCheckTypedWindowEvent dpy win ExposureMask)))
	      (if (XCheckTypedEvent dpy ExposureMask) 
		  (snd-display #__line__ ";XCheckTypedEvent: ~A" (XCheckTypedEvent dpy ExposureMask)))
	      (XCheckWindowEvent dpy win ExposureMask)
					;		(if (XCheckIfEvent dpy (lambda (d e data) #f) #f)
					;		    (snd-display #__line__ ";XCheckIfEvent: ~A" (XCheckIfEvent dpy (lambda (d e data) #f) #f)))
	      (XCirculateSubwindows dpy win RaiseLowest)
	      (XCirculateSubwindowsUp dpy win)
	      (XCirculateSubwindowsDown dpy win)
	      (let ((wc (XWindowChanges 10 10 100 100 10 win 0)))
		(if (not (= (.stack_mode wc) 0)) (snd-display #__line__ ";stack_mode wc: ~A" (.stack_mode wc)))
		(if (not (equal? (.sibling wc) win)) (snd-display #__line__ ";sibling wc: ~A" (.sibling wc)))
		(if (not (= (.x wc) 10)) (snd-display #__line__ ";x wc: ~A" (.x wc)))
		(if (not (= (.y wc) 10)) (snd-display #__line__ ";y wc: ~A" (.y wc)))
		(if (not (= (.width wc) 100)) (snd-display #__line__ ";width wc: ~A" (.width wc)))
		(if (not (= (.height wc) 100)) (snd-display #__line__ ";height wc: ~A" (.height wc)))
		(if (not (= (.border_width wc) 10)) (snd-display #__line__ ";border_width wc: ~A" (.border_width wc))))
	      (if (defined? 'XpmImage)
		  (let ((xp (XpmImage 10 10 0 1 0)))
		    (if (not (= (.cpp xp) 0)) (snd-display #__line__ ";cpp xp: ~A" (.cpp xp)))
		    (if (not (= (.ncolors xp) 1)) (snd-display #__line__ ";ncolors xp: ~A" (.ncolors xp)))))
	      )
	    (XmObjectAtPoint shell 100 100)
	    (if (not (string=? (XmGetAtomName dpy XA_STRING) "STRING")) (snd-display #__line__ ";XmGetAtomName: ~A" (XmGetAtomName dpy XA_STRING)))
	    (if (not (XmTargetsAreCompatible dpy (list XA_STRING) 1 (list XA_STRING) 1)) (snd-display #__line__ ";XmTargetsAreCompatible"))
	    (XmUpdateDisplay grf1)
	    (let ((lines (XmWidgetGetBaselines (list-ref (main-widgets) 4))))
	      (if (not lines) (snd-display #__line__ ";XmWidgetGetBaselines?"))
	      (if (< (length lines) 4) (snd-display #__line__ ";no listener text?? ~A" lines)))
	    (let ((r (XmWidgetGetDisplayRect (list-ref (sound-widgets) 8))))
	      (if (not (XRectangle? r)) (snd-display #__line__ ";XmWidgetGetDisplayRect: ~A" r)))
	    (XDrawImageString dpy (list 'Window (cadr pix)) sgc 0 10 "hiho" 4)
	    (let* ((data (XtCalloc (* 11 11 depth) 1))
		   (before (XCreateImage dpy vis depth XYPixmap 0 data 10 10 8 0))
		   (newimage (XGetSubImage dpy (list 'Window (cadr pix)) 0 0 10 10 AllPlanes XYPixmap before 0 0)))
	      (XSubImage newimage 0 0 3 3)
	      (if (not (= (.bytes_per_line newimage) 2)) (snd-display #__line__ ";bytes_per_line: ~A" (.bytes_per_line newimage)))
	      (if (not (= (.byte_order newimage) 0)) (snd-display #__line__ ";byte_order: ~A" (.byte_order newimage)))
	      (if (not (= (.bitmap_pad newimage) 8)) (snd-display #__line__ ";bitmap_pad: ~A" (.bitmap_pad newimage)))
	      (if (not (= (.bitmap_bit_order newimage) 0)) (snd-display #__line__ ";bitmap_bit_order: ~A" (.bitmap_bit_order newimage)))
	      (if (not (= (.bitmap_unit newimage) 32)) (snd-display #__line__ ";bitmap_unit: ~A" (.bitmap_unit newimage)))
					;		 (if (not (= (.obdata newimage) 0)) (snd-display #__line__ ";obdata: ~A" (.obdata newimage)))
	      (if (not (= (.xoffset newimage) 0)) (snd-display #__line__ ";xoffset: ~A" (.xoffset newimage)))
	      (XPutPixel before 1 1 (basic-color))
	      (XGetPixel before 1 1)
	      (XPutImage dpy (list 'Window (cadr rotpix)) sgc before 0 0 0 0 10 10)
	      (XAddPixel before 1)
	      (if (> (.bits_per_pixel before) 123) (snd-display #__line__ ";bits_per_pixel: ~A" (.bits_per_pixel before)))
	      (XmInstallImage before "before_image")
	      (XmUninstallImage before)
	      (if (defined? 'XpmAttributes)
		  (let ((i11 (XGetImage dpy (list 'Window (cadr pix)) 0 0 10 10 AllPlanes XYPixmap))
			(attr (XpmAttributes))
			(vals (XtGetValues (cadr (main-widgets)) (list XmNcolormap 0 XmNdepth 0)))
			(sym (XpmColorSymbol "basiccolor" #f (basic-color))))
		    (if (not (string=? (.name sym) "basiccolor")) (snd-display #__line__ ";.name colorsymbol: ~A" (.name sym)))
		    (set! (.name sym) "hiho")
		    (if (not (string=? (.name sym) "hiho")) (snd-display #__line__ ";set .name colorsymbol: ~A" (.name sym)))
		    (set! (.visual attr) vis)
		    (if (not (equal? vis (.visual attr))) (snd-display #__line__ ";visual xpm attr: ~A" (.visual attr)))
		    (if (not (list? (.colorsymbols attr))) (snd-display #__line__ ";.colorsymbols attr: ~A" (.colorsymbols attr)))
		    (set! (.colorsymbols attr) (list sym))
		    (set! (.pixel sym) (basic-color))
		    (set! (.numsymbols attr) 1)
		    (if (not (equal? 1 (.numsymbols attr))) (snd-display #__line__ ";numsymbols xpm attr: ~A" (.numsymbols attr)))
		    (set! (.depth attr) (list-ref vals 3))
		    (if (not (equal? (list-ref vals 3) (.depth attr))) (snd-display #__line__ ";depth xpm attr: ~A" (.depth attr)))
		    (set! (.colormap attr) (list-ref vals 1))
		    (if (not (equal? (list-ref vals 1) (.colormap attr))) (snd-display #__line__ ";colormap xpm attr: ~A" (.colormap attr)))
		    (set! (.valuemask attr) (logior XpmColorSymbols XpmDepth XpmColormap XpmVisual))
		    (if (not (= (.valuemask attr) (logior XpmColorSymbols XpmDepth XpmColormap XpmVisual)))
			(snd-display #__line__ ";valuemask: ~A" (.valuemask attr)))
		    (if (not (= (.x_hotspot attr) 0)) (snd-display #__line__ ";x_hotspot: ~A" (.x_hotspot attr)))
		    (if (not (= (.y_hotspot attr) 0)) (snd-display #__line__ ";y_hotspot: ~A" (.y_hotspot attr)))
		    (if (not (= (.npixels attr) 0)) (snd-display #__line__ ";npixels: ~A" (.npixels attr)))
		    (let ((err (XpmCreatePixmapFromData dpy win 
							(list "16 14 6 1"
							      " 	c None s None"
							      ".	c gray50"
							      "X	c black"
							      "o	c white"
							      "O	c yellow"
							      "-      c ivory2 s basiccolor"
							      "------.XXX.-----"
							      "-----X.ooo.X----"
							      "----..oXXXo..---"
							      "----XoX...XoX---"
							      "----XoX.--XoX.--"
							      "----XoX.--XoX.--"
							      "---XXXXXXXXXXX--"
							      "---XOOOOOOOOOX.-"
							      "---XO.......OX.-"
							      "---XOOOOOOOOOX.-"
							      "---XO.......OX.-"
							      "---XOOOOOOOOOX.-"
							      "---XXXXXXXXXXX.-"
							      "----...........-")
							attr)))
		      (if (or (not (= (car err) XpmSuccess))
			      (not (Pixmap? (cadr err))))
			  (snd-display #__line__ ";XpmCreatePixmapFromData: ~A" err)))
		    
		    (let* ((shell (cadr (main-widgets)))
			   (dpy (XtDisplay shell))
			   (button (XmCreatePushButton shell "button" '()))
			   (status-and-whatnot (XpmReadFileToPixmap dpy (XRootWindowOfScreen (XtScreen shell)) "bullet.xpm" #f))
			   (status (car status-and-whatnot))
			   (pixmap (cadr status-and-whatnot))
			   (pixmap1 (caddr status-and-whatnot)))
		      (if (not (string=? (XpmGetErrorString XpmSuccess) "XpmSuccess")) 
			  (snd-display #__line__ ";XpmGetErrorString: ~A" (XpmGetErrorString XpmSuccess)))
		      (if (not (= status XpmSuccess))
			  (snd-display #__line__ "; XpmError ReadFileToPixmap: ~A" (XpmGetErrorString status)))
		      (XtVaSetValues button (list XmNlabelType XmPIXMAP
						  XmNlabelPixmap pixmap))
		      (XpmWriteFileFromPixmap dpy "test.xpm" pixmap pixmap1 #f)
		      (XpmCreateDataFromPixmap dpy pixmap pixmap1 #f)
		      (let* ((status (XpmReadFileToXpmImage "bullet.xpm"))
			     (symb (XpmColorSymbol "Foreground" "green" (basic-color)))
			     (attr (XpmAttributes)))
			(if (not (XpmImage? status))
			    (snd-display #__line__ "; XpmError ReadFileToXpmImage: ~A" (XpmGetErrorString status)))
			(set! (.valuemask attr) XpmColorSymbols)
			(XpmCreatePixmapFromXpmImage dpy (XRootWindowOfScreen (XtScreen shell)) status attr)
			(XpmCreateXpmImageFromPixmap dpy pixmap pixmap1 attr)
			(for-each
			 (lambda (func val name)
			   (set! (func attr) val)
			   (if (not (equal? (func attr) val)) (snd-display #__line__ ";attr ~A ~A" name (func attr))))
			 (list .valuemask .depth .width .x_hotspot .y_hotspot .cpp .npixels .ncolors)
			 (list 0 0 0 0 0 0 0 0)
			 (list 'valuemask 'depth 'width 'x_hotspot 'y_hotspot 'cpp 'npixels 'ncolors)))
		      )
		    (XDestroyImage i11)))
	      
	      (XDestroyImage before)
	      (XFreePixmap dpy pix)
	      (XVisualIDFromVisual vis)
	      (XGrabServer dpy)
	      (XUngrabServer dpy)
	      (XGrabPointer dpy win #t ButtonPressMask GrabModeSync GrabModeSync (list 'Window None) (list 'Cursor None) (list 'Time CurrentTime))
	      (XUngrabPointer dpy (list 'Time CurrentTime))
	      (XGrabKeyboard dpy win #t GrabModeSync GrabModeSync (list 'Time CurrentTime))
	      (XUngrabKeyboard dpy (list 'Time CurrentTime))
	      (XGrabKey dpy AnyKey AnyModifier win #t GrabModeSync GrabModeSync)
	      (XUngrabKey dpy AnyKey AnyModifier win)
	      (XGrabButton dpy AnyButton AnyModifier win #t ButtonPressMask GrabModeSync GrabModeSync (list 'Window None) (list 'Cursor None))
	      (XUngrabButton dpy AnyButton AnyModifier win)
	      (XtGrabPointer shell #t ButtonPressMask GrabModeSync GrabModeSync (list 'Window None) (list 'Cursor None) (list 'Time CurrentTime))
	      (XtUngrabPointer shell (list 'Time CurrentTime))
	      (XtGrabKeyboard shell #t GrabModeSync GrabModeSync (list 'Time CurrentTime))
	      (XtUngrabKeyboard shell (list 'Time CurrentTime))
	      (XtGrabKey shell (list 'KeyCode AnyKey) AnyModifier #t GrabModeSync GrabModeSync)
	      (XtUngrabKey shell (list 'KeyCode AnyKey) AnyModifier)
	      (XtGrabButton shell AnyButton AnyModifier #t ButtonPressMask GrabModeSync GrabModeSync (list 'Window None) (list 'Cursor None))
	      (XtUngrabButton shell AnyButton AnyModifier)
	      ))
	  
	  (let* ((sgc (car (snd-gcs)))
		 (grf1 (car (channel-widgets)))
		 (dpy (XtDisplay grf1))
		 (win (XtWindow grf1))
		 (shl (cadr (main-widgets))))
	    (let ((wid (XtWindowToWidget dpy win)))
	      (if (not (equal? wid grf1))
		  (snd-display #__line__ ";XtWindowToWidget: ~A ~A" grf1 win)))
					; these are causing: X Error of failed request:  BadAccess (attempt to access private resource denied)
					;	       (if (not (equal? (XGetTransientForHint dpy win) (list 0 #f)))
					;		   (snd-display #__line__ ";XGetTransientForHint: ~A" (XGetTransientForHint dpy win)))
	    (if (not (equal? (XGetErrorText dpy BadColor #f 9) (list 0 "BadColor")))
		(snd-display #__line__ ";XGetErrorText: ~A" (XGetErrorText dpy BadColor #f 9)))
	    (if (not (equal? (XGeometry dpy 0 "500x400" "500x400+10+10" 4 7 14 2 2) (list 12 10 10 500 400)))
		(snd-display #__line__ ";XGeometry: ~A" (XGeometry dpy 0 "500x400" "500x400+10+10" 4 7 14 2 2)))
	    (if (< (XEventsQueued dpy QueuedAlready) 0)
		(snd-display #__line__ ";XEventsQueued: ~A" (XEventsQueued dpy QueuedAlready)))
					;	       (let ((coords (XTranslateCoordinates dpy (XtWindow shl) win 10 10)))
					;		 (if (not (car coords))
					;		     (snd-display #__line__ ";XTranslateCoordinates: ~A" coords)))
	    (let ((coords (XtTranslateCoords shl 10 10)))
	      (if (not (number? (car coords)))
		  (snd-display #__line__ ";XtTranslateCoords: ~A" coords)))
	    (if (not (XmIsVendorShell shl)) (snd-display #__line__ ";XmIsVendorShell?"))
	    (if (XmIsPrimitive shl) (snd-display #__line__ ";XmIsPrimitive?"))
	    (if (XmIsManager shl) (snd-display #__line__ ";XmIsManager?"))
	    (if (XmIsIconGadget shl) (snd-display #__line__ ";XmIsIconGadget?"))
	    (if (XmIsGadget shl) (snd-display #__line__ ";XmIsGadget?"))
	    (if (XmIsIconHeader shl) (snd-display #__line__ ";XmIsHeader?"))
	    (if (XmIsDropTransfer shl) (snd-display #__line__ ";XmIsDropTransfer?"))
	    (if (XmIsDropSiteManager shl) (snd-display #__line__ ";XmIsDropSiteManager?"))
	    (if (XmIsDragContext shl) (snd-display #__line__ ";XmIsDragContext?"))
	    (if (XmIsDragIconObjectClass shl) (snd-display #__line__ ";XmIsDragIconObjectClass?"))
	    (if (XmIsMessageBox shl) (snd-display #__line__ ";XmIsMessageBox?"))
	    (if (XmIsScreen shl) (snd-display #__line__ ";XmIsScreen?"))
	    (if (XmIsDisplay shl) (snd-display #__line__ ";XmIsDisplay?"))
	    
	    (let ((val 0))
	      (XSetErrorHandler (lambda (dpy e)
				  (set! val (.error_code e))))
	      (XGetAtomName dpy '(Atom 0))
	      (if (not (= val 5)) (snd-display #__line__ ";XSetErrorHandler: ~A" val)))
	    
	    (XDrawImageString dpy win sgc 10 10 "hiho" 4)
	    (XDrawRectangle dpy win sgc 0 0 10 10)
	    (XDrawString dpy win sgc 10 10 "hi" 2)
	    (XDrawSegments dpy win sgc (list (XSegment 1 1 2 20) (XSegment 3 3 40 4)) 2)
	    (XDrawRectangles dpy win sgc (list (XRectangle 0 0 10 10) (XRectangle 20 20 30 30)) 2)
	    (XFillRectangles dpy win sgc (list (XRectangle 0 0 10 10) (XRectangle 20 20 30 30)) 2)
	    (XDrawRectangle dpy win sgc 10 10 10 10)
	    (XFillRectangle dpy win sgc 10 10 10 10)
	    (XDrawPoints dpy win sgc (list (XPoint 23 23) (XPoint 109 10)) 2 CoordModeOrigin)
	    (XDrawPoint dpy win sgc 10 10)
	    (XDrawLines dpy win sgc (list (XPoint 23 23) (XPoint 109 10)) 2 CoordModeOrigin)
	    (XDrawLine dpy win sgc 10 10 20 20)
	    (XDrawArcs dpy win sgc (list (XArc 10 10 4 4 0 360) (XArc 20 20 1 23 0 123)) 2)
	    (XFillArcs dpy win sgc (list (XArc 10 10 4 4 0 360) (XArc 20 20 1 23 0 123)) 2)
	    (XDrawArc dpy win sgc 0 0 10 10 45 90)
	    (XFillArc dpy win sgc 0 0 10 10 45 90)
	    (XFillPolygon dpy win sgc (list (XPoint 0 0) (XPoint 0 10) (XPoint 10 10) (XPoint 10 0) (XPoint 0 0)) 5 Convex CoordModeOrigin)
	    (XClearArea dpy win 10 10 20 20 #f)
	    (XClearWindow dpy win))
	  
	  (close-sound)
	  
	  (let ((button (XtCreateManagedWidget "button" xmPushButtonWidgetClass (cadr (main-widgets)) '() 0))
		(val1 0))
	    (define (call1 w c i)
	      (set! val1 (+ 1 val1)))
	    (let ((descr (XtAddCallback button XmNactivateCallback call1 #f)))
	      (XtCallCallbacks button XmNactivateCallback #f)
	      (if (not (= val1 1))
		  (snd-display #__line__ ";XtCallCallbacks val1: ~A" val1))
	      (XtRemoveCallback button XmNactivateCallback descr)
	      (let ((calls (XtHasCallbacks button XmNactivateCallback)))
		(if (not (= calls XtCallbackHasNone))
		    (snd-display #__line__ ";XtRemoveCallbacks: ~A" calls))))
	    (XtUnmanageChild button)
					;(XtDestroyWidget button)
	    )
	  
	  (let ((button (XtCreateManagedWidget "button" xmPushButtonWidgetClass (cadr (main-widgets)) '() 0))
		(val1 0)
		(val2 0))
	    (define (call1 w c i)
	      (set! val1 (+ 1 val1)))
	    (define (call2 w c i)
	      (set! val2 (+ 1 val2)))
	    (let ((descr1 (XtAddCallback button XmNactivateCallback call1 #f))
		  (descr2 (XtAddCallback button XmNactivateCallback call2 #f)))
	      (XtCallCallbacks button XmNactivateCallback #f)
	      (if (and (not (= val1 1)) (not (= val2 1)))
		  (snd-display #__line__ ";XtCallCallbacks val12: ~A ~A" val1 val2))
	      (XtRemoveCallbacks button XmNactivateCallback (list descr1 descr2))
	      (let ((calls (XtHasCallbacks button XmNactivateCallback)))
		(if (not (= calls XtCallbackHasNone))
		    (snd-display #__line__ ";XtRemoveCallbacks: ~A" calls))))
	    (XtUnmanageChild button)
					;(XtDestroyWidget button)
	    )
	  
	  (let ((button (XtCreateManagedWidget "button" xmPushButtonWidgetClass (cadr (main-widgets)) '() 0))
		(val1 0)
		(val2 0))
	    (define (call1 w c i)
	      (set! val1 (+ 1 val1)))
	    (define (call2 w c i)
	      (set! val2 (+ 1 val2)))
	    (let ((descrs (XtAddCallbacks button XmNactivateCallback (list (list call1 #f) (list call2 #f)))))
	      (XtCallCallbacks button XmNactivateCallback #f)
	      (if (and (not (= val1 1)) (not (= val2 1)))
		  (snd-display #__line__ ";XtCallCallbacks add val12: ~A ~A" val1 val2))
	      (XtRemoveCallbacks button XmNactivateCallback descrs)
	      (let ((calls (XtHasCallbacks button XmNactivateCallback)))
		(if (not (= calls XtCallbackHasNone))
		    (snd-display #__line__ ";XtRemoveCallbacks (add): ~A" calls))))
	    (XtUnmanageChild button)
					;(XtDestroyWidget button)
	    )
	  
	  (let* ((frm (add-main-pane "hi" xmFormWidgetClass (list XmNpaneMinimum 120)))
		 (browsed 0)
		 (lst (XtCreateManagedWidget "lst" xmListWidgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_FORM
						   XmNbottomAttachment    XmATTACH_FORM
						   XmNautomaticSelection   XmNO_AUTO_SELECT
						   XmNdoubleClickInterval  100
						   XmNitemCount            3
						   XmNitems                (list (XmStringCreate "one" XmFONTLIST_DEFAULT_TAG)
										 (XmStringCreate "two" XmFONTLIST_DEFAULT_TAG)
										 (XmStringCreate "three" XmFONTLIST_DEFAULT_TAG))
						   XmNlistMarginHeight     4
						   XmNlistMarginWidth      1
						   XmNlistSizePolicy       XmVARIABLE
						   XmNlistSpacing          2
						   XmNmatchBehavior        XmQUICK_NAVIGATE
						   XmNprimaryOwnership     XmOWN_NEVER
						   XmNscrollBarDisplayPolicy XmAS_NEEDED
						   XmNselectColor          (basic-color)
						   XmNselectedPositions    (list 0 1)
						   XmNselectionMode        XmNORMAL_MODE
						   XmNselectionPolicy      XmBROWSE_SELECT))))
	    (XtAddCallback lst XmNbrowseSelectionCallback (lambda (w c i) (set! browsed 123)))
	    (let ((vals (XtVaGetValues lst
				       (list XmNautomaticSelection 0 XmNdoubleClickInterval 0 XmNitemCount 0 XmNitems 0 XmNlistMarginHeight 0
					     XmNlistMarginWidth 0 XmNlistSizePolicy 0 XmNlistSpacing 0 XmNmatchBehavior 0
					     XmNprimaryOwnership 0  XmNscrollBarDisplayPolicy 0 XmNselectColor 0 XmNselectionMode 0
					     XmNselectionPolicy 0 XmNhorizontalScrollBar 0 XmNselectedItemCount 0 XmNtopItemPosition 0))))
	      (if (not (= (list-ref vals 1) XmNO_AUTO_SELECT)) (snd-display #__line__ ";XmNautomaticSelection: ~A" (list-ref vals 1)))
	      (if (not (= (list-ref vals 3) 100)) (snd-display #__line__ ";XmNdoubleClickInterval: ~A" (list-ref vals 3)))
	      (if (not (= (list-ref vals 5) 3)) (snd-display #__line__ ";XmNitemCount: ~A" (list-ref vals 5)))
	      (if (or (null? (list-ref vals 7)) (not (XmString? (car (list-ref vals 7))))) (snd-display #__line__ ";XmNitems: ~A" (list-ref vals 7)))
	      (if (not (= (list-ref vals 9) 4)) (snd-display #__line__ ";XmNlistMarginHeight: ~A" (list-ref vals 9)))
	      (if (not (= (list-ref vals 11) 1)) (snd-display #__line__ ";XmNlistMarginWidth: ~A" (list-ref vals 11)))
	      (if (not (= (list-ref vals 13) XmVARIABLE)) (snd-display #__line__ ";XmNlistSizePolicy: ~A" (list-ref vals 13)))
	      (if (not (= (list-ref vals 15) 2)) (snd-display #__line__ ";XmNlistSpacing: ~A" (list-ref vals 15)))
	      (if (not (= (list-ref vals 17) XmQUICK_NAVIGATE)) (snd-display #__line__ ";XmNmatchBehavior: ~A" (list-ref vals 17)))
	      (if (not (= (list-ref vals 19) XmOWN_NEVER)) (snd-display #__line__ ";XmNprimaryOwnership : ~A" (list-ref vals 19)))
	      (if (not (= (list-ref vals 21) XmAS_NEEDED)) (snd-display #__line__ ";XmNscrollBarDisplayPolicy: ~A" (list-ref vals 21)))
	      (if (not (Pixel? (list-ref vals 23))) (snd-display #__line__ ";XmNselectColor: ~A" (list-ref vals 23)))
	      (if (not (= (list-ref vals 25) XmNORMAL_MODE)) (snd-display #__line__ ";XmNselectionMode: ~A" (list-ref vals 25)))
	      (if (not (= (list-ref vals 27) XmBROWSE_SELECT)) (snd-display #__line__ ";XmNselectionPolicy: ~A" (list-ref vals 27)))
	      (if (list-ref vals 29) (snd-display #__line__ ";XmNhorizontalScrollBar: ~A" (list-ref vals 29)))
	      (if (not (= (list-ref vals 31) 0)) (snd-display #__line__ ";XmNselectedItemCount : ~A" (list-ref vals 31)))
	      (if (not (= (list-ref vals 33) 1)) (snd-display #__line__ ";XmNtopItemPosition: ~A" (list-ref vals 33)))
	      
	      (let ((tag (catch #t
				(lambda ()
				  (XmListAddItem frm (XmStringCreate "four" XmFONTLIST_DEFAULT_TAG) 0))
				(lambda args (car args)))))
		(if (not (eq? tag 'wrong-type-arg))
		    (snd-display #__line__ ";list type check: ~A" tag)))
	      
	      (XmListAddItem lst (XmStringCreate "four" XmFONTLIST_DEFAULT_TAG) 0) ; 0 -> last position
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 4)) (snd-display #__line__ ";XmAddItem len: ~A" (list-ref vals 1)))
	      (XmListAddItems lst (list (XmStringCreateLocalized "five") (XmStringCreateLocalized "six")) 2 0)
	      (let ((tag (catch #t
				(lambda () (XmListAddItems lst (list (XmStringCreateLocalized "seven") 123) 2 0))
				(lambda args (car args)))))
		(if (not (eq? tag 'wrong-type-arg))
		    (snd-display #__line__ ";xstrings->list add: ~A" tag)))
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 6)) (snd-display #__line__ ";XmAddItems len: ~A" (list-ref vals 1)))
	      
	      (XmListDeletePos lst 1)
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 5)) (snd-display #__line__ ";XmListDeletePos len: ~A" (list-ref vals 1)))
	      (XmListDeletePositions lst (list 2 4))
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 3)) (snd-display #__line__ ";XmListDeletePositions len: ~A" (list-ref vals 1)))
	      
	      (XmListAddItemUnselected lst (XmStringCreate "seven" XmFONTLIST_DEFAULT_TAG) 0) ; 0 -> last position
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 4)) (snd-display #__line__ ";XmListAddItemUnselected len: ~A" (list-ref vals 1)))
	      (XmListAddItemsUnselected lst (list (XmStringCreateLocalized "eight") (XmStringCreateLocalized "nine")) 2 0)
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 6)) (snd-display #__line__ ";XmListAddItemsUnselected len: ~A" (list-ref vals 1)))
	      
	      (XmListDeleteAllItems lst)
	      (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
	      (if (not (= (list-ref vals 1) 0)) (snd-display #__line__ ";XmListDeleteAllItems len: ~A" (list-ref vals 1)))
	      (if (not (null? (list-ref vals 3)))
		  (snd-display #__line__ ";deleted all items: ~A" (list-ref vals 3)))
	      
	      (let ((item1 (XmStringCreate "one" XmFONTLIST_DEFAULT_TAG))
		    (item2 (XmStringCreate "two" XmFONTLIST_DEFAULT_TAG))
		    (item3 (XmStringCreate "three" XmFONTLIST_DEFAULT_TAG))
		    (item4 (XmStringCreate "four" XmFONTLIST_DEFAULT_TAG))
		    (item5 (XmStringCreate "five" XmFONTLIST_DEFAULT_TAG)))
		(XtVaSetValues lst 
			       (list XmNitemCount 5
				     XmNitems (list item1 item2 item3 item4 item5))) 
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 5)) (snd-display #__line__ ";Xt set items len: ~A" (list-ref vals 1)))
		
		(XmListSelectItem lst item3 #t)
		(if (not (= browsed 123)) (snd-display #__line__ ";XmListSelectItem callback: ~A" browsed))
		(if (XmListPosSelected lst 1) (snd-display #__line__ ";XmList selected pos 1?"))
		(if (not (XmListPosSelected lst 3)) (snd-display #__line__ ";XmList didn't select pos 3?"))
		(set! vals (XtVaGetValues lst (list XmNselectedItemCount 0 XmNselectedItems 0)))
		(if (not (= (list-ref vals 1) 1)) (snd-display #__line__ ";selected count: ~A" (list-ref vals 1)))
		(set! vals (XmListGetSelectedPos lst))
		(if (not (= (length vals) 1)) (snd-display #__line__ ";XmListGetSelectedPos: ~A" vals))
		(if (not (= (car vals) 3)) (snd-display #__line__ ";XmListGetSelectedPos: ~A" vals))
		(set! browsed 0)
		(XmListSelectPos lst 1 #f)
		(if (not (= browsed 0)) (snd-display #__line__ ";XmListSelectPos callback: ~A" browsed))
		(if (not (XmListPosSelected lst 1)) (snd-display #__line__ ";XmList select pos?"))
		(if (not (= (XmListItemPos lst item3) 3)) (snd-display #__line__ ";XmListItemPos: ~A" (XmListItemPos lst item3)))
		(if (not (= (car (XmListGetMatchPos lst item3)) 3)) (snd-display #__line__ ";XmListGetMatchPos: ~A" (XmListGetMatchPos lst item3)))
		(if (not (XmListItemExists lst item3)) (snd-display #__line__ ";XmListItemExists?"))
		
		(if (not (= (XmListYToPos lst 40) 2)) (snd-display #__line__ ";XmListYToPos: ~A" (XmListYToPos lst 40)))
		(let ((box (XmListPosToBounds lst 2)))
		  (if (and (not (= (cadr box) 3))
			   (not (= (cadr box) 2)))
		      (snd-display #__line__ ";XmListPosToBounds: ~A" box)))
		(XmListDeselectPos lst 1)
		(if (XmListPosSelected lst 1) (snd-display #__line__ ";XmList deselected pos?"))
		(XmListSelectItem lst item3 #t)
		(XmListDeselectAllItems lst)
		(if (XmListPosSelected lst 3) (snd-display #__line__ ";XmList deselect all pos?"))
		(XmListSelectItem lst item3 #f)
		(XmListDeselectItem lst item3)
		(if (XmListPosSelected lst 3) (snd-display #__line__ ";XmList deselect item?"))
		
		(XmListDeleteItem lst item2)
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 4)) (snd-display #__line__ ";XmDeleteItem len: ~A" (list-ref vals 1)))
		(XmListDeleteItems lst (list item1 item4))
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 2)) (snd-display #__line__ ";XmDeleteItems len: ~A" (list-ref vals 1)))
		(XmListDeleteAllItems lst)
		(XtVaSetValues lst 
			       (list XmNitemCount 5
				     XmNitems (list item1 item2 item3 item4 item5))) 
		
		(XtUnmanageChild frm))))
	  
	  (let* ((frm (add-main-pane "hi" xmFormWidgetClass (list XmNpaneMinimum 120)))
		 (current-time (list 'Time CurrentTime))
		 (calls (make-vector 10 "none"))
		 (txt (XtCreateManagedWidget "text" xmTextWidgetClass frm
					     (list XmNeditable #t
						   XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_FORM
						   XmNbottomAttachment    XmATTACH_NONE
						   XmNdestinationCallback 
						   (list (lambda (w c i) 
							   (vector-set! calls c "dest")
							   (if (< (.location_data i) 0) (snd-display #__line__ ";location_data: A~" (.location_data i))))
							 1)
						   XmNactivateCallback (list (lambda (w c i) (vector-set! calls c "act")) 2)
						   XmNfocusCallback (list (lambda (w c i) (vector-set! calls c "focus")) 3)
						   XmNlosingFocusCallback (list (lambda (w c i) (vector-set! calls c "losingfocus")) 4)
						   XmNgainPrimaryCallback (list (lambda (w c i) (vector-set! calls c "gain")) 5)
						   XmNlosePrimaryCallback (list (lambda (w c i) (vector-set! calls c "lose")) 6)
						   XmNmodifyVerifyCallback 
						   (list (lambda (w c i) 
							   (vector-set! calls c "modify")
							   (if (< (.currInsert i) 0) (snd-display #__line__ ";currInsert: A~" (.currInsert i)))
							   (if (< (.newInsert i) 0) (snd-display #__line__ ";newInsert: A~" (.newInsert i)))
							   (if (string? (.doit i)) (snd-display #__line__ ";doit: A~" (.doit i)))
							   (if (< (.startPos i) 0) (snd-display #__line__ ";startPos: A~" (.startPos i)))
							   (if (< (.endPos i) 0) (snd-display #__line__ ";endPos: A~" (.endPos i))))
							 7)
						   XmNmotionVerifyCallback (list (lambda (w c i) (vector-set! calls c "motion")) 8)
						   XmNvalueChangedCallback (list (lambda (w c i) (vector-set! calls c "value")) 9)))))
	    (letrec ((transfer-proc
		      (lambda (w c info)
			(let* ((dpy (XtDisplay w))
			       (TARGETS (XmInternAtom dpy "TARGETS" #f))
			       (CB_TARGETS (XmInternAtom dpy "_MOTIF_CLIPBOARD_TARGETS" #f)))
			  (if (equal? (.target info) XA_STRING)
			      (begin
					;(XmTextInsert w (XmTextGetInsertionPosition w) (->string (.value info)))
					;I think the .value field here is an XmString
				(XmTransferDone (.transfer_id info) XmTRANSFER_DONE_SUCCEED))
			      (if (and (or (equal? (.target info) TARGETS)
					   (equal? (.target info) CB_TARGETS))
				       (equal? (.type info) XA_ATOM))
				  (let ((targets (->Atoms (.value info) (.length info)))
					(happy #f))
				    (for-each
				     (lambda (targ)
				       (if (equal? targ XA_STRING)
					   (set! happy #t)))
				     targets)
				    (if happy
					(XmTransferValue (.transfer_id info) 
							 XA_STRING
							 transfer-proc
							 #f
							 (XtLastTimestampProcessed dpy)))))))))
		     (txtf (XtVaCreateManagedWidget "textfield" xmTextFieldWidgetClass frm
						    (list XmNeditable #t
							  XmNleftAttachment      XmATTACH_FORM
							  XmNrightAttachment     XmATTACH_FORM
							  XmNtopAttachment       XmATTACH_WIDGET
							  XmNtopWidget           txt
							  XmNbottomAttachment    XmATTACH_FORM))))
	      
	      (let ((vals (XtVaGetValues txt (list XmNrenderTable 0 XmNselectionArray 0))))
		(if (not (XmRenderTable? (list-ref vals 1))) (snd-display #__line__ ";XmNrenderTable: ~A" (list-ref vals 1)))
		(if (not (list-p (list-ref vals 3))) (snd-display #__line__ ";XmNselectionArray: ~A" (list-ref vals 3))))
	      (if (not (XmTextGetEditable txt)) (snd-display #__line__ ";XmTextGetEditable?"))
	      (if (not (XmTextFieldGetEditable txtf)) (snd-display #__line__ ";XmTextFieldGetEditable?"))
	      (XmTextSetEditable txt #f)
	      (XmTextFieldSetEditable txtf #f)
	      (if (XmTextGetEditable txt) (snd-display #__line__ ";XmTextSetEditable?"))
	      (if (XmTextFieldGetEditable txtf) (snd-display #__line__ ";XmTextFieldSetEditable?"))
	      (XmTextSetEditable txt #t)
	      (XmTextFieldSetEditable txtf #t)
	      (XmTextSetString txt "0123456789")
	      (XmTextFieldSetString txtf "0123456789")
	      (XmTextFieldCopyLink txtf (list 'Time CurrentTime))
	      (let ((val (XmTextGetString txt))
		    (valf (XmTextFieldGetString txtf))
		    (val1 (cadr (XtVaGetValues txt (list XmNvalue 0))))
		    (val1f (cadr (XtVaGetValues txtf (list XmNvalue 0)))))
		(if (not (string=? val "0123456789")) (snd-display #__line__ ";XmTextSetString: ~A" val))
		(if (not (string=? valf "0123456789")) (snd-display #__line__ ";XmTextFieldSetString: ~A" valf))
		(if (not (string=? val1 "0123456789")) (snd-display #__line__ ";text value: ~A" val1))
		(if (not (string=? val1f "0123456789")) (snd-display #__line__ ";text field value: ~A" val)))
	      (let ((untext (XtCreateWidget "untext" xmTextWidgetClass frm '()))
		    (source (XmTextGetSource txt)))
		(XmTextSetSource untext source 0 3)
		(if (not (XmTextSource? source))
		    (snd-display #__line__ ";XmTextSource? ~A" source))
		(if (not (equal? (XmTextGetSource untext) source))
		    (snd-display #__line__ ";XmTextSetSource: ~A ~A" source (XmTextGetSource untext)))
		(if (XtIsSubclass untext xmFormWidgetClass)
		    (snd-display #__line__ ";XtIsSubclass thinks untext is a form?"))
		(if (not (XtIsSubclass untext coreWidgetClass))
		    (snd-display #__line__ ";XtIsSubclass thinks untext is not a core widget"))
		(XmTextCopyLink untext (list 'Time CurrentTime))
		(XmTextPasteLink untext))
	      (let ((val (XmTextGetSubstring txt 2 3))
		    (valf (XmTextFieldGetSubstring txtf 2 3)))
		(if (or (not (string? val)) (not (string=? val "234"))) (snd-display #__line__ ";XmTextGetSubstring: ~A" val))
		(if (or (not (string? valf)) (not (string=? valf "234"))) (snd-display #__line__ ";XmTextFieldGetSubstring: ~A" valf)))
	      (XmTextSetSelection txt 2 5 current-time)
	      (let ((val (XmTextGetSelection txt)))
		(if (or (not (string? val)) (not (string=? val "234"))) (snd-display #__line__ ";XmTextGetSelection: ~A" val)))
	      (XmTextClearSelection txt current-time)
	      (let ((val (XmTextGetSelection txt)))
		(if val (snd-display #__line__ ";XmTextClearSelection: ~A" val)))
	      (XmTextFieldSetSelection txtf 2 5 current-time)
	      (let ((tag (catch #t
				(lambda ()
				  (XmTextFieldSetSelection txt 2 3 current-time))
				(lambda args (car args)))))
		(if (not (eq? tag 'wrong-type-arg))
		    (snd-display #__line__ ";text field type check: ~A" tag)))
	      (let ((tag (catch #t
				(lambda ()
				  (XmTextSetSelection frm 2 3 current-time))
				(lambda args (car args)))))
		(if (not (eq? tag 'wrong-type-arg))
		    (snd-display #__line__ ";text type check: ~A" tag)))
	      (let ((dpy (XtDisplay (cadr (main-widgets))))
		    (win (XtWindow (cadr (main-widgets))))
		    (app (car (main-widgets))))
		(let ((tag (catch #t (lambda () (XmTransferSetParameters 123 123 123 123 "hiho")) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmTransferSetParameters type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmDropSiteConfigureStackingOrder txtf txtf "hiho")) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmDropSiteConfigureStackingOrder type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmScrollVisible txtf txtf 5 "hiho")) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmScrollVisible type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmDragStart txtf (XEvent KeyPress) (list 0 1) "hiho")) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmDragStart type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmClipboardStartRetrieve dpy win 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmClipboardStartRetrieve type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmClipboardCopyByName dpy win 1 "hi" "hi" 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmClipboardCopyByName type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmClipboardBeginCopy dpy win "hi" txtf #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmClipboardBeginCopy type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmRemoveProtocolCallback txtf XA_STRING XA_STRING #f 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmRemoveProtocolCallback type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetRGBColormaps dpy win (list 'XStandardColormap 0) 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetRGBColormap type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetWMHints dpy win 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetWMHints type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XWindowEvent dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XWindowEvent type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XStoreNamedColor dpy (list 'Colormap 0) "hi" 0 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XStoreNamedColor type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XStoreColors dpy (list 'Colormap 0) (list 1 2) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XStoreColors type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XStoreColor dpy (list 'Colormap 0) (list 1 2))) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XStoreColor type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtDisplayInitialize app dpy "hi" "ho" 1 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtDisplayInitialize type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtOwnSelectionIncremental txtf '(Atom 0) '(Time 0) #f #f #f #f #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtOwnSelectionIncremental type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtOwnSelection txtf '(Atom 0) '(Time 0) #f #f #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtOwnSelection type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtGetSelectionValue txtf '(Atom 0) '(Atom 0) #f #f #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtGetSelectionValue type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtGetSelectionValues txtf '(Atom 0) (list (list 'Atom 0)) #f #f #f #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtGetSelectionValues type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtDisownSelection txtf '(Atom 0) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtDisownSelection type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtGetSelectionRequest txtf '(Atom 0) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtGetSelectionRequest type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtGetSelectionValueIncremental txtf '(Atom 0) (list (list 'Atom 0)) 1 #f #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtGetSelectionValueIncremental type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtGetSelectionValuesIncremental txtf '(Atom 0) '(Atom 0) 1 #f #f #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtGetSelectionValuesIncremental type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XtSendSelectionRequest txtf '(Atom 0) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XtSendSelectionRequest type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XReconfigureWMWindow dpy win 1 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XReconfigureWMWindow type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetWMProtocols dpy win 1 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetWMProtocols type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XIconifyWindow dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XIconifyWindow type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XWithdrawWindow dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XWithdrawWindow type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetWMColormapWindows dpy win #f 1)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetWMColormapWindows type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetTransientForHint dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetTransientForHint type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XAllowEvents dpy 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XAllowEvents type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XChangeActivePointerGrab dpy 1 '(Cursor 0) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XChangeActivePointerGrab type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XChangeGC dpy '(GC 0) 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XChangeGC type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XChangeKeyboardMapping dpy 1 1 (list 1 1) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XChangeKeyboardMapping type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XConfigureWindow dpy win 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XConfigureWindow type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XConvertSelection dpy '(Atom 0) '(Atom 0) '(Atom 0) win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XConvertSelection type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XReparentWindow dpy win win 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XReparentWindow type check: ~A" tag)))
		
		(let ((tag (catch #t (lambda () (XFreeColors dpy '(Colormap 0) (list 0) 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XFreeColors type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XReadBitmapFile dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XReadBitmapFile type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XRebindKeysym dpy '(KeySym 0) (list 0) 1 "hi" #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XRebindKeysym type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XRestackWindows dpy (list 0) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XRestackWindows type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XRotateWindowProperties dpy win (list 0) 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XRotateWindowProperties type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSelectInput dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSelectInput type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetFontPath dpy (list 0) #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetFontPath type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetInputFocus dpy win 1 #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetInputFocus type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetSelectionOwner dpy '(Atom 0) win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetSelectionOwner type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XSetWindowColormap dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XSetWindowColormap type check: ~A" tag)))
		(let ((tag (catch #t (lambda () (XmClipboardCancelCopy dpy win #f)) (lambda args (car args)))))
		  (if (not (eq? tag 'wrong-type-arg)) (snd-display #__line__ ";XmClipboardCancelCopy type check: ~A" tag)))
		
		)
	      
	      (let ((valf (XmTextFieldGetSelection txtf)))
		(if (not (string=? valf "234")) (snd-display #__line__ ";XmTextFieldGetSelection: ~A" valf)))
	      (XmTextFieldClearSelection txtf current-time)
	      (let ((valf (XmTextFieldGetSelection txtf)))
		(if valf (snd-display #__line__ ";XmTextFieldClearSelection: ~A" valf)))
	      (let ((val (XmTextGetInsertionPosition txt))
		    (valf (XmTextFieldGetInsertionPosition txtf)))
		(if (not (= val 5)) (snd-display #__line__ ";XmTextGetInsertionPosition: ~A" val))
		(if (not (= valf 5)) (snd-display #__line__ ";XmTextFieldGetInsertionPosition: ~A" val)))
	      
	      (XmTextScroll txt 1)
	      (XmTextScroll txt -1)
	      (let ((pos (XmTextGetTopCharacter txt)))
		(if (not (= pos 0)) (snd-display #__line__ ";XmTextGetTopCharacter after scroll: ~A" pos)))
	      (XmTextShowPosition txt 0)
	      (XmTextFieldShowPosition txtf 0)
	      (XmTextSetTopCharacter txt 0)
	      (XmTextXYToPos txt 10 10)
	      (XmTextFieldXYToPos txtf 10 10)
	      
	      (XmTextSetHighlight txt 3 6 XmHIGHLIGHT_SELECTED)
	      (XmTextFieldSetHighlight txtf 3 6 XmHIGHLIGHT_SELECTED)
	      (XmTextFieldGetBaseline txtf)
	      (XmTextSetAddMode txt #t)
	      (if (not (XmTextGetAddMode txt)) (snd-display #__line__ ";XmTextSetAddMode?"))
	      (XmTextFieldSetAddMode txtf #t)
	      (if (not (XmTextFieldGetAddMode txtf)) (snd-display #__line__ ";XmTextFieldSetAddMode?"))
	      
	      (if (not (string=? (vector-ref calls 5) "gain")) (snd-display #__line__ ";gain callback: ~A" (vector-ref calls 5)))
	      (if (not (string=? (vector-ref calls 7) "modify")) (snd-display #__line__ ";modify callback: ~A" (vector-ref calls 7)))
	      (if (not (string=? (vector-ref calls 8) "motion")) (snd-display #__line__ ";motion callback: ~A" (vector-ref calls 8)))
	      (if (not (string=? (vector-ref calls 9) "value")) (snd-display #__line__ ";value callback: ~A" (vector-ref calls 9)))
	      
	      (let ((txtf1 (XtVaCreateManagedWidget "textfield" xmTextFieldWidgetClass frm
						    (list XmNeditable #t
							  XmNleftAttachment      XmATTACH_FORM
							  XmNrightAttachment     XmATTACH_FORM
							  XmNtopAttachment       XmATTACH_WIDGET
							  XmNtopWidget           txt
							  XmNbottomAttachment    XmATTACH_FORM
							  XmNdestinationCallback
							  (list (lambda (w c info)
								  (let* ((dpy (XtDisplay w))
									 (TARGETS (XmInternAtom dpy "TARGETS" #f)))
								    (XmTransferValue (.transfer_id info) 
										     TARGETS 
										     transfer-proc
										     #f
										     (XtLastTimestampProcessed dpy))))
								#f)))))
		(focus-widget txtf1)
		(XmTextFieldPaste txtf1)
		(XmTextFieldPasteLink txtf1)
		(if (not (Widget? (XmGetTabGroup txtf1))) (snd-display #__line__ ";XmGetTabGroup: ~A " (XmGetTabGroup txtf1)))
		(let ((fw (XmGetFocusWidget (cadr (main-widgets)))))
		  (if (not (equal? fw txtf1))
		      (snd-display #__line__ ";XmGetFocusWidget: ~A" fw)))
		(let ((callback (lambda (w context ev flag)
				  (XtSetValues w (list XmNbackground (white-pixel))))))
		  (XtAddEventHandler txtf1 EnterWindowMask #f callback #f)
		  (XtRemoveEventHandler txtf1 EnterWindowMask #f callback #f)
		  (XtAddRawEventHandler txtf1 EnterWindowMask #f callback #f)
		  (XtRemoveRawEventHandler txtf1 EnterWindowMask #f callback #f)
		  (XtInsertEventHandler txtf1 EnterWindowMask #f callback #f XtListHead)
		  (XtRemoveEventHandler txtf1 EnterWindowMask #f callback #f)
		  (XtInsertRawEventHandler txtf1 EnterWindowMask #f callback #f XtListTail)
		  (XtRemoveRawEventHandler txtf1 EnterWindowMask #f callback #f))
		(XtRemoveAllCallbacks txtf1 XmNdestinationCallback))
	      (XtAppAddActions (car (main-widgets)) (list (list "hiho" (lambda args (snd-print "hiho")))))
	      (XtAugmentTranslations txt (XtParseTranslationTable "Ctrl <Key>i: hiho()\n"))
	      (XtCallActionProc txt "hiho" (XEvent) #f 0)
	      (XtUninstallTranslations txt)
	      (XtUnmanageChild frm)))
	  
	  (let* ((shell (cadr (main-widgets)))
		 (dpy (XtDisplay shell))
		 (win (XtWindow shell))
		 (err (XmClipboardRegisterFormat dpy "SND_DATA" 8)))
	    (if (not (= err ClipboardSuccess)) 
		(snd-display #__line__ ";XmClipboardRegisterFormat: ~A" err)
		(let ((vals (XmClipboardStartCopy dpy win
						  (XmStringCreateLocalized "SND_DATA") 
						  (list 'Time CurrentTime) 
						  shell
						  (lambda (w id pid reason)
						    (let ((status (XmClipboardCopyByName dpy win id "copy this" 10 123))))))))
		  (if (not (= (car vals) ClipboardSuccess))
		      (snd-display #__line__ ";XmClipboardStartCopy: ~A" vals)
		      (let ((data-id (cadr vals)))
			(set! err (XmClipboardCopy dpy win data-id "SND_DATA" "copy this" 10 0))
			(if (not (= (car err) ClipboardSuccess)) (snd-display #__line__ ";XmClipboardCopy: ~A" err))
			(let ((item-id (cadr err)))
			  (set! err (XmClipboardEndCopy dpy win data-id))
			  (if (not (= err ClipboardSuccess)) (snd-display #__line__ ";copy ~A" err))
			  (if (not (= (cadr (XmClipboardInquireLength dpy win "SND_DATA")) 10))
			      (snd-display #__line__ ";clip len: ~A" (XmClipboardInquireLength dpy win "SND_DATA")))
			  (let ((pend (XmClipboardInquirePendingItems dpy win "SND_DATA")))
			    (if (not (= (car pend) ClipboardSuccess)) (snd-display #__line__ ";XmClipboardInquirePendingItems: ~A" pend)))
			  (let ((formats1 (XmClipboardInquireCount dpy win)))
			    (if (= (cadr formats1) 0) (snd-display #__line__ ";XmClipboardInquireCount: ~A" formats1))
			    (let ((data (XmClipboardInquireFormat dpy win 1 10)))
			      (let ((clip (XmClipboardRetrieve dpy win "SND_DATA" 10)))
				(if (not (string=? (cadr clip) "copy this")) (snd-display #__line__ ";XmClipboardRetrieve: ~A" clip))
				(XmClipboardWithdrawFormat dpy win item-id)))))))))
	    (let ((val (XmClipboardLock dpy win)))
	      (if (not (= val ClipboardLocked))
		  (XmClipboardUnlock dpy win #t)))
	    (let ((selbox (XmCreateSelectionBox shell "selbox" '() 0)))
	      (XmSelectionBoxGetChild selbox XmDIALOG_APPLY_BUTTON)))
	  
	  (let* ((frm (add-main-pane "hi" xmFormWidgetClass (list XmNpaneMinimum 120)))
		 (current-time (list 'Time CurrentTime))
		 (box (XtCreateManagedWidget "box" xmContainerWidgetClass frm '()))
		 (tgl (XtCreateManagedWidget "tgl" xmToggleButtonWidgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_FORM
						   XmNbottomAttachment    XmATTACH_NONE)))
		 (tgg (XtCreateManagedWidget "tgg" xmToggleButtonGadgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_WIDGET
						   XmNtopWidget           tgl
						   XmNbottomAttachment    XmATTACH_NONE)))
		 (spn (XtCreateManagedWidget "spn" xmSimpleSpinBoxWidgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_WIDGET
						   XmNtopWidget           tgg
						   XmNbottomAttachment    XmATTACH_NONE)))
		 (cmd (XtCreateManagedWidget "cmd" xmCommandWidgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_WIDGET
						   XmNtopWidget           spn
						   XmNbottomAttachment    XmATTACH_NONE)))
		 (scl (XtCreateManagedWidget "scl" xmScaleWidgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_WIDGET
						   XmNtopWidget           cmd
						   XmNbottomAttachment    XmATTACH_NONE)))
		 (notes (XtCreateManagedWidget "notes" xmNotebookWidgetClass frm
					       (list XmNleftAttachment      XmATTACH_FORM
						     XmNrightAttachment     XmATTACH_FORM
						     XmNtopAttachment       XmATTACH_WIDGET
						     XmNtopWidget           scl
						     XmNbottomAttachment    XmATTACH_NONE)))
		 
		 (cmb (XtCreateManagedWidget "cmb" xmComboBoxWidgetClass frm
					     (list XmNleftAttachment      XmATTACH_FORM
						   XmNrightAttachment     XmATTACH_FORM
						   XmNtopAttachment       XmATTACH_WIDGET
						   XmNtopWidget           notes
						   XmNbottomAttachment    XmATTACH_FORM)))
		 (toggled 0))
	    (XtCreateManagedWidget "one" xmPushButtonWidgetClass notes '())
	    (XtCreateManagedWidget "two" xmPushButtonWidgetClass notes '())
	    (let ((info (cadr (XmNotebookGetPageInfo notes 1))))
	      (if (not (= (.page_number info) 1)) (snd-display #__line__ ";page_number: ~A" (.page_number info)))
	      (if (.page_widget info) (snd-display #__line__ ";page_widget: ~A" (.page_widget info)))
	      (if (.status_area_widget info) (snd-display #__line__ ";status_area_widget: ~A" (.status_area_widget info)))
	      (if (not (Widget? (.major_tab_widget info))) (snd-display #__line__ ";major_tab_widget: ~A" (.major_tab_widget info)))
	      (if (.minor_tab_widget info) (snd-display #__line__ ";minor_tab_widget: ~A" (.minor_tab_widget info)))
					;(segfault)	(XtFree (cadr info))
	      )
	    
	    (XmSimpleSpinBoxAddItem spn (XmStringCreateLocalized "hiho") 0)
	    (XmSimpleSpinBoxAddItem spn (XmStringCreateLocalized "away") 0)
	    (XmSimpleSpinBoxDeletePos spn 0)
	    (let ((vals (XtVaGetValues spn (list XmNvalues 0))))
	      (XmSimpleSpinBoxSetItem spn (car (cadr vals))))
	    (XmSimpleSpinBoxAddItem spn (XmStringCreateLocalized "another") 0)
	    (let ((vals (XtGetValues spn (list XmNeditable 0 XmNtextField 0))))
	      (if (not (list-ref vals 1)) (snd-display #__line__ ";XmNeditable spin box"))
	      (if (not (Widget? (list-ref vals 3))) (snd-display #__line__ ";XmNtextField: ~A" (list-ref vals 3))))
	    
	    (XtAddCallback tgl XmNvalueChangedCallback (lambda (w c i) (set! toggled 123)) #f)
	    (XmToggleButtonSetState tgl #f #f)
	    (XmToggleButtonGadgetSetState tgg #f #f)
	    (if (not (= toggled 0)) (snd-display #__line__ ";toggle calledback: ~A?" toggled))
	    (if (XmToggleButtonGetState tgl) (snd-display #__line__ ";XmToggleButtonSetState #f"))
	    (if (XmToggleButtonGadgetGetState tgg) (snd-display #__line__ ";XmToggleButtonGadgetSetState #f"))
	    (XtVaSetValues tgl (list XmNtoggleMode XmTOGGLE_INDETERMINATE))
	    (XmToggleButtonSetValue tgl XmINDETERMINATE #t)
	    (XmToggleButtonGadgetSetValue tgg XmINDETERMINATE #t)
	    (if (not (= toggled 123)) (snd-display #__line__ ";toggle not calledback: ~A?" toggled))
	    
	    (XmCommandAppendValue cmd (XmStringCreateLocalized "hiho"))
	    (XmCommandError cmd (XmStringCreateLocalized "hiho"))
	    (if (not (Widget? (XmCommandGetChild cmd XmDIALOG_COMMAND_TEXT)))
		(snd-display #__line__ ";XmCommandGetChild: ~A" (XmCommandGetChild cmd XmDIALOG_COMMAND_TEXT)))
	    (XmCommandSetValue cmd (XmStringCreateLocalized "hiho"))
	    
	    (let ((one1 (XmStringCreateLocalized "one"))
		  (two1 (XmStringCreateLocalized "two"))
		  (three1 (XmStringCreateLocalized "three")))
	      (XmComboBoxAddItem cmb one1 0 #f)
	      (XmComboBoxAddItem cmb two1 0 #f)
	      (XmComboBoxAddItem cmb three1 0 #f)
	      (XmComboBoxDeletePos cmb 1)
	      (XmComboBoxSelectItem cmb three1)
	      (XmComboBoxSetItem cmb three1) ; hunh??
	      (XmComboBoxUpdate cmb)
	      (let ((vals (cadr (XtGetValues cmb (list XmNitems 0)))))
		(if (not (equal? vals (list two1 three1))) (snd-display #__line__ ";XmComboBox: ~A" vals))))
	    
	    (XmContainerCut box current-time)
	    (XmContainerCopy box current-time)
	    (XmContainerPaste box)
	    (XmContainerCopyLink box (list 'Time CurrentTime))
	    (XmContainerPasteLink box)
	    (let ((vals (XtVaGetValues box (list XmNlargeIconX 0 XmNlargeIconY 0))))
	      (if (or (null? (cdr vals))
		      (not (real? (cadr vals)))
		      (fneq (cadr vals) 0.0)
		      (null? (cdddr vals))
		      (not (real? (cadddr vals)))
		      (fneq (cadddr vals) 0.0))
		  (snd-display #__line__ ";xm-float resource vals: ~A" vals)))
	    
	    (XtAddCallback scl XmNvalueChangedCallback (lambda (w c i) #f))
	    (XmScaleSetValue scl 25)
	    (if (not (= (XmScaleGetValue scl) 25)) (snd-display #__line__ ";XmScaleSetValue: ~A" (XmScaleGetValue scl)))
	    (if (XmGetTearOffControl (car (menu-widgets))) (snd-display #__line__ ";XmGetTearOffControl: ~A" (XmGetTearOffControl (car (menu-widgets)))))
	    (let ((children (cadr (XtGetValues scl (list XmNchildren 0)))))
	      (for-each 
	       (lambda (w)
		 (let ((name (XtName w)))
		   (if (and (XmIsSeparatorGadget w)
			    (or (string=? name "BigTic")
				(string=? name "MedTic")
				(string=? name "SmallTic")))
		       (XtDestroyWidget w))))
	       children))
	    (XmScaleSetTicks scl 5 2 0 10 5 0)
	    )
	  
	  (XmSetColorCalculation #f)
	  (let* ((dpy (XtDisplay (cadr (main-widgets))))
		 (scr1 (DefaultScreen dpy))
		 (cmap (DefaultColormap dpy scr1))
		 (screen (XDefaultScreenOfDisplay dpy))
		 (scr (XmGetXmScreen (XDefaultScreenOfDisplay dpy)))
		 (old-h (cadr (XtVaGetValues scr (list XmNhorizontalFontUnit 0))))
		 (old-v (cadr (XtVaGetValues scr (list XmNverticalFontUnit 0)))))
	    (if (not (XmIsScreen scr)) (snd-display #__line__ ";XmIsScreen: ~A" scr))
	    (let ((colors (XmGetColors screen cmap (basic-color))))
	      (if (not (Pixel? (car colors)))
		  (snd-display #__line__ ";colors: ~A " colors))
	      (let ((color-proc (lambda (bg)
				  (list (white-pixel) (black-pixel) (white-pixel) (black-pixel)))))
		(XmSetColorCalculation color-proc)
		(if (not (equal? (XmGetColorCalculation) color-proc))
		    (snd-display #__line__ ";XmSetColorcalulcation ~A" (XmGetColorCalculation)))))
	    (let ((vals (XtVaGetValues scr 
				       (list XmNbitmapConversionModel 0 XmNdarkThreshold 0 XmNfont 0 XmNunpostBehavior 0))))
	      (if (not (= (list-ref vals 1) XmMATCH_DEPTH)) (snd-display #__line__ ";XmNbitmapConversionModel: ~A" (list-ref vals 1)))
	      (if (not (= (list-ref vals 3) 0)) (snd-display #__line__ ";XmNdarkThreshold: ~A" (list-ref vals 3)))
	      (if (not (XFontStruct? (list-ref vals 5))) (snd-display #__line__ ";XmNfont: ~A" (list-ref vals 5)))
	      (if (not (= (list-ref vals 7) XmUNPOST_AND_REPLAY)) (snd-display #__line__ ";XmNunpostBehavior: ~A" (list-ref vals 7)))
	      (XSetScreenSaver dpy -1 5 DefaultBlanking DefaultExposures)
	      ))
	  (let ((dpy (XtDisplay (cadr (main-widgets)))))
	    (let* ((dp (XmGetXmDisplay dpy))
		   (vals (XtVaGetValues dp
					(list XmNdragInitiatorProtocolStyle 0 XmNenableThinThickness 0 XmNmotifVersion 0))))
	      (if (not (XmIsDisplay dp)) (snd-display #__line__ ";XmIsDisplay: ~A" dp))
	      (if (not (= (list-ref vals 1) XmDRAG_PREFER_RECEIVER)) (snd-display #__line__ ";XmNdragInitiatorProtocolStyle: ~A" (list-ref vals 1)))
	      (if (not (list-ref vals 3)) (snd-display #__line__ ";XmNenableThinThickness?"))
	      (if (not (= (list-ref vals 5) 2002)) (snd-display #__line__ ";XmGetXmDisplay motif version: ~A" (list-ref vals 5)))
	      (XtAddCallback dp XmNdragStartCallback (lambda (w c i) #f)))
	    
	    (if (not (string=? (XmCvtXmStringToCT (XmStringCreateLocalized "hiho")) "hiho"))
		(snd-display #__line__ ";XmCvtXmStringToCT: ~A" (XmCvtXmStringToCT (XmStringCreateLocalized "hiho"))))
	    (let ((val (XmConvertStringToUnits (XDefaultScreenOfDisplay dpy) "3.14 in" XmHORIZONTAL XmINCHES)))
	      (if (not (= val 3)) (snd-display #__line__ ";XmConvertStringToUnits in->in ~A" val)))
	    (let ((val (XmConvertStringToUnits (XDefaultScreenOfDisplay dpy) "3.14 in" XmHORIZONTAL XmPOINTS)))
	      (if (not (= val 225)) (snd-display #__line__ ";XmConvertStringToUnits in->pts ~A" val)))
	    (let ((val (XmConvertStringToUnits (XDefaultScreenOfDisplay dpy) "3.14 in" XmHORIZONTAL XmCENTIMETERS)))
	      (if (not (= val 7)) (snd-display #__line__ ";XmConvertStringToUnits in->cm ~A" val)))
	    (let ((val (XmConvertUnits (cadr (main-widgets)) XmHORIZONTAL XmCENTIMETERS 7 XmMILLIMETERS)))
	      (if (not (= val 70)) (snd-display #__line__ ";XmConvertUnits cm->mm ~A" val)))
	    (let ((val (XmConvertUnits (cadr (main-widgets)) XmHORIZONTAL XmCENTIMETERS 7 XmPIXELS)))
	      (if (and (not (= val 278)) (not (= val 273))) (snd-display #__line__ ";XmConvertUnits cm->pix ~A" val)))
	    (XmVaCreateSimpleRadioBox (caddr (main-widgets)) "hiho" 0 (lambda (w c i) #f) '())
	    (XmVaCreateSimpleCheckBox (caddr (main-widgets)) "hiho" (lambda (w c i) #f) '())
	    (XmVaCreateSimplePulldownMenu (caddr (main-widgets)) "hiho" 0 (lambda (w c i) #f) '())
	    (XmVaCreateSimplePopupMenu (caddr (main-widgets)) "hiho" (lambda (w c i) #f) '())
	    (XmVaCreateSimpleMenuBar (caddr (main-widgets)) "hiho" '())
	    (XmVaCreateSimpleOptionMenu (caddr (main-widgets)) "hiho" 
					(XmStringCreateLocalized "away") 
					(XKeycodeToKeysym dpy (list 'KeyCode XK_b) 0)
					0  (lambda (w c i) #f) '())
	    
					;	       (if (not (XmIsMotifWMRunning (cadr (main-widgets)))) (snd-display #__line__ ";not XmIsMotifWMRunning?"))
	    (install-searcher (lambda (file) (= (mus-sound-srate file) 44100)))
	    (zync)
	    (make-hidden-controls-dialog)
	    (make-pixmap (cadr (main-widgets)) arrow-strs)
	    (display-scanned-synthesis)
	    (add-mark-pane)
	    (let ((ind (open-sound "oboe.snd")))
	      (snd-clock-icon ind 6)
	      (add-tooltip (cadr (channel-widgets)) "the w button")
	      (with-minmax-button ind)
	      (make-channel-drop-site ind 0)
	      (set-channel-drop (lambda (file s c) (snd-print file)) ind 0)
	      (let ((drop-site (find-child (XtParent (XtParent (list-ref (channel-widgets ind 0) 7))) "drop here")))
		(if drop-site
		    (begin
		      (XtVaGetValues drop-site (list XmNdropRectangles 0))
		      (let ((val (XmDropSiteRetrieve drop-site (list XmNnumImportTargets 0))))
			(if (not (= (cadr val) 1)) (snd-display #__line__ ";XmDropSiteRetrieve num: ~A" val)))
		      (XmDropSiteRetrieve drop-site (list XmNimportTargets 0))
		      (if (not (XmDropSiteRegistered drop-site))
			  (snd-display #__line__ ";XmDropSiteRegistered?"))
		      (XmDropSiteUnregister drop-site))
		    (snd-display #__line__ ";no drop site?"))))
	    
	    (add-mark 123)
	    (add-popups)
	    (let ((container
		   (make-sound-box "sounds"
				   (list-ref (main-widgets) 3)
				   (lambda (file) 
				     (mix file))
				   (lambda (file chn)
				     (define (without-directories filename)
				       (call-with-exit
					(lambda (return)
					  (do ((i (- (string-length filename) 1) (- i 1)))
					      ((= 0 i) filename)
					    (if (char=? (string-ref filename i) #\/)
						(return (my-substring filename (+ i 1))))))))
				     (format #f "~~/peaks/~A-peaks-~D" 
					     (snd-test-clean-string (mus-expand-filename file))
					     chn))
				   (list "oboe.snd" "pistol.snd" "cardinal.snd" "storm.snd")
				   '())))
	      (XmContainerRelayout container)
	      (let ((vals (XtVaGetValues container 
					 (list XmNlargeCellHeight 0 XmNcollapsedStatePixmap 0 XmNdetailOrder 0 XmNdetailTabList 0
					       XmNselectedObjects 0 XmNconvertCallback 0 XmNdestinationCallback 0 XmNselectionCallback 0))))
		(if (not (= (list-ref vals 1) 0)) (snd-display #__line__ ";XmNlargeCellHeight: ~A" (list-ref vals 1)))
		(if (not (Pixmap? (list-ref vals 3))) (snd-display #__line__ ";XmNcollapsedStatePixmap: ~A" (list-ref vals 3)))
		(let ((children '()))
		  (for-each-child container
				  (lambda (w)
				    (if (XmIsIconGadget w)
					(set! children (cons w children)))))
		  (XmContainerReorder container children (length children)))
		(let ((func (lambda (w) 0)))
		  (XtSetValues container (list XmNinsertPosition func))
		  (let ((func1 (cadr (XtGetValues container (list XmNinsertPosition 0)))))
		    (if (not (equal? func func1)) (snd-display #__line__ ";XmNinsertPosition: ~A ~A" func func1))))))
	    
	    (show-smpte-label)
	    (with-level-meters 4)
	    (play)
	    (close-sound))
	  
	  ;; qualify proc is causing a segfault somehow
					;	    (let ((box (XmCreateFileSelectionBox (cadr (main-widgets)) "box" 
					;						 (list XmNfileSearchProc (lambda (w c) #f)
					;						       XmNqualifySearchDataProc (lambda (w c i)
					;										  (display "qualifier was called!")
					;										  )))))
					;	      (XtUnmanageChild box))
	  (let ((hi (XtCreateManagedWidget "hi" xmTextWidgetClass (cadr (main-widgets)) 
					   (list XmNqualifySearchDataProc (lambda (w c i) "hi")
						 XmNtransferProc (lambda (a b c d e f g) "ho")
						 XmNcolorAllocationProc (lambda (a b c) #f)
						 XmNcolorCalculationProc (lambda (a b) #f)
						 XmNcreatePopupChildProc (lambda (a) #f)
						 XmNlargeIconX 0.5
						 ))))
	    (XtVaSetValues hi (list XmNqualifySearchDataProc (lambda (w c i) "hi")
				    XmNtransferProc (lambda (a b c d e f g) "ho")
				    XmNcolorAllocationProc (lambda (a b c) #f)
				    XmNcolorCalculationProc (lambda (a b) #f)
				    XmNcreatePopupChildProc (lambda (a) #f)))
	    (XtVaSetValues hi (list XmNqualifySearchDataProc #f
				    XmNcolorAllocationProc #f
				    XmNcolorCalculationProc #f
				    XmNcreatePopupChildProc #f
				    XmNx 10
				    XmNsource (XmTextGetSource hi)
				    ))
	    (XtUnmanageChild hi))
	  
	  (if (and (defined? 'XmCreateFontSelector)
		   (defined? 'XmCreateColorSelector))
	      (let ((fonts-dialog #f)
		    (colors-dialog #f))
		(for-each
		 (lambda (make-dialog)
		   (let* ((xdismiss (XmStringCreate "Dismiss" XmFONTLIST_DEFAULT_TAG))
			  (xhelp (XmStringCreate "Help" XmFONTLIST_DEFAULT_TAG))
			  (xok (XmStringCreate "DoIt" XmFONTLIST_DEFAULT_TAG))
			  (titlestr (XmStringCreate "Fonts" XmFONTLIST_DEFAULT_TAG))
			  (new-dialog (XmCreateTemplateDialog
				       (cadr (main-widgets)) "Fonts"
				       (list XmNcancelLabelString   xdismiss
					     XmNhelpLabelString     xhelp
					     XmNokLabelString       xok
					     XmNautoUnmanage        #f
					     XmNdialogTitle         titlestr
					     XmNresizePolicy        XmRESIZE_GROW
					     XmNnoResize            #f
					     XmNbackground          (basic-color)
					     XmNtransient           #f))))
		     (for-each
		      (lambda (button color)
			(XtVaSetValues
			 (XmMessageBoxGetChild new-dialog button)
			 (list XmNarmColor   (pushed-button-color)
			       XmNbackground color)))
		      (list XmDIALOG_HELP_BUTTON XmDIALOG_CANCEL_BUTTON XmDIALOG_OK_BUTTON)
		      (list (help-button-color) (quit-button-color) (doit-button-color)))
		     (XtAddCallback new-dialog XmNcancelCallback (lambda (w c i) (XtUnmanageChild w)))
		     (XtAddCallback new-dialog XmNhelpCallback (lambda (w c i) (help-dialog "Fonts" "no help yet")))
		     (XtAddCallback new-dialog XmNokCallback (lambda (w c i) (XtUnmanageChild w)))
		     (XmStringFree xhelp)
		     (XmStringFree xok)
		     (XmStringFree xdismiss)
		     (XmStringFree titlestr)
		     (if (not fonts-dialog)
			 (set! fonts-dialog new-dialog)
			 (set! colors-dialog new-dialog))
		     (let* ((mainform (XtCreateManagedWidget "mainform" xmFormWidgetClass new-dialog
							     (list XmNleftAttachment   XmATTACH_FORM
								   XmNrightAttachment  XmATTACH_FORM
								   XmNtopAttachment    XmATTACH_FORM
								   XmNbottomAttachment XmATTACH_WIDGET
								   XmNbottomWidget     (XmMessageBoxGetChild new-dialog XmDIALOG_SEPARATOR)
								   XmNbackground       (basic-color))))
			    (fnts (make-dialog mainform)))
		       (XtManageChild fnts)
		       (if (not colors-dialog)
			   (XtManageChild fonts-dialog)
			   (XtManageChild colors-dialog)))))
		 (list 
		  (lambda (mainform)
		    (XmCreateFontSelector mainform "Fonts" 
					  (list XmNbackground (basic-color)
						XmNcurrentFont "-*-times-bold-r-*-*-14-140-*-*-*-*-*-*"
						XmNleftAttachment   XmATTACH_FORM
						XmNrightAttachment  XmATTACH_FORM
						XmNtopAttachment    XmATTACH_FORM
						XmNbottomAttachment XmATTACH_NONE)))
		  
		  (lambda (mainform)
		    (XmCreateColorSelector mainform "Colors" 
					   (list XmNbackground (basic-color)
						 XmNleftAttachment   XmATTACH_FORM
						 XmNrightAttachment  XmATTACH_FORM
						 XmNtopAttachment    XmATTACH_FORM
						 XmNbottomAttachment XmATTACH_NONE)))))
		(XtUnmanageChild fonts-dialog)
		(XtUnmanageChild colors-dialog)))
	  
	  (let* ((xdismiss (XmStringCreate "Dismiss" XmFONTLIST_DEFAULT_TAG))
		 (xhelp (XmStringCreate "Help" XmFONTLIST_DEFAULT_TAG))
		 (xok (XmStringCreate "DoIt" XmFONTLIST_DEFAULT_TAG))
		 (titlestr (XmStringCreate "Fonts" XmFONTLIST_DEFAULT_TAG))
		 (new-dialog (XmCreateTemplateDialog
			      (cadr (main-widgets)) "Fonts"
			      (list XmNcancelLabelString   xdismiss
				    XmNhelpLabelString     xhelp
				    XmNokLabelString       xok
				    XmNautoUnmanage        #f
				    XmNdialogTitle         titlestr
				    XmNresizePolicy        XmRESIZE_GROW
				    XmNnoResize            #f
				    XmNbackground          (basic-color)
				    XmNtransient           #f))))
	    (XmStringFree xhelp)
	    (XmStringFree xok)
	    (XmStringFree xdismiss)
	    (XmStringFree titlestr)
	    (let* ((mainform (XtCreateManagedWidget "mainform" xmFormWidgetClass new-dialog
						    (list XmNleftAttachment   XmATTACH_FORM
							  XmNrightAttachment  XmATTACH_FORM
							  XmNtopAttachment    XmATTACH_FORM
							  XmNbottomAttachment XmATTACH_WIDGET
							  XmNbottomWidget     (XmMessageBoxGetChild new-dialog XmDIALOG_SEPARATOR)
							  XmNbackground       (basic-color))))
		   (fnts 
		    (if (defined? 'XmIsColumn)
			(let* ((w1 (XmCreateColumn mainform "column" '()))
			       (w1-child (XtCreateManagedWidget "hihi" xmLabelWidgetClass w1 '() 0))
			       (w2 (XtCreateManagedWidget "column1" xmColumnWidgetClass mainform '() 0)))
			  (if (or (not (XmIsColumn w1))
				  (not (XmIsColumn w2))
				  (not (XmColumn? w1)))
			      (snd-display #__line__ ";XmIsColumn: ~A ~A" w1 w2))
			  (if (defined? 'XmColumnGetChildLabel)
			      (let ((child (XmColumnGetChildLabel w1)))
				(if (or (not (child)) (not (equal? child w1-child)))
				    (snd-display #__line__ ";XmColumn child: ~A ~A" child w1-child))))
			  (XtManageChild w1)
			  w1)
			#f))
		   (fntt
		    (if (defined? 'XmIsButtonBox)
			(let ((w1 (XmCreateButtonBox mainform "box" (list XmNfillOption XmFillMajor))))
			  (if (or (not (XmIsButtonBox w1))
				  (not (XmButtonBox? w1)))
			      (snd-display #__line__ ";XmIsButtonBox: ~A ~A ~A" w1 (XmIsButtonBox w1) (XmButtonBox? w1)))
			  (XtManageChild w1)
			  w1)
			#f))
		   (fntd 
		    (if (defined? 'XmIsDropDown)
			(let ((w1 (XmCreateDropDown mainform "drop" '())))
			  (if (or (not (XmIsDropDown w1))
				  (not (XmDropDown? w1)))
			      (snd-display #__line__ ";XmIsDropDown: ~A ~A ~A" w1 (XmIsDropDown w1) (XmDropDown? w1)))
			  (XtManageChild w1)
			  (let ((text (XmDropDownGetText w1))
				(label (XmDropDownGetLabel w1))
				(arrow (XmDropDownGetArrow w1))
				(lst (XmDropDownGetList w1))
				(str (XmDropDownGetValue w1)))
			    (if (not (XmTextField? text)) (snd-display #__line__ ";dropdown text: ~A" text))
			    (if (not (XmLabel? label)) (snd-display #__line__ ";dropdown label: ~A" label))
			    (if (not (XmArrowButton? arrow)) (snd-display #__line__ ";dropdown arrow: ~A" arrow))
			    (if (not (XmList? lst)) (snd-display #__line__ ";dropdown lst: ~A" text))
			    w1))
			#f))
		   (fntda
		    (if (defined? 'XmIsDataField)
			(let ((w1 (XmCreateDataField mainform "data" '())))
			  (if (or (not (XmIsDataField w1))
				  (not (XmDataField? w1)))
			      (snd-display #__line__ ";XmIsDataField: ~A ~A ~A" w1 (XmIsDataField w1) (XmDataField? w1)))
			  (let ((str (XmDataFieldGetString w1))
				(sel (XmDataFieldGetSelection w1)))
			    (XmDataFieldSetString w1 "hiho")
			    (XmDataFieldSetEditable w1 #t)
			    (XmDataFieldSetAddMode w1 #f)
			    (XmDataFieldShowPosition w1 0)
			    (XmDataFieldXYToPos w1 0 0)
			    (XmDataFieldSetHighlight w1 0 0 0)
			    (let ((sel1 (XmDataFieldGetSelectionPosition w1)))
			      (XmDataFieldSetSelection w1 0 0 '(Time 0)))
			    (XmDataFieldCopy w1 '(Time 0))
					;(XmDataFieldPaste w1) ; x error
			    (XmDataFieldCut w1 '(Time 0))
			    w1))
			#f))
		   (fnttab
		    (if (defined? 'XmIsTabStack)
			(let ((w1 (XmCreateTabStack mainform "hi" '())))
			  (if (or (not (XmIsTabStack w1))
				  (not (XmTabStack? w1)))
			      (snd-display #__line__ ";XmIsTabStack: ~A ~A ~A" w1 (XmIsTabStack w1) (XmTabStack? w1)))
			  (let ((tab (XmTabStackGetSelectedTab w1)))
			    (XmTabStackSelectTab w1 #f)
			    w1))
			#f)))
	      
	      (if (and (defined? 'XmToolTipGetLabel)
		       (defined? 'XmNtoolTipString))
		  (let ((wid1 (XtCreateManagedWidget "wid1" xmPushButtonWidgetClass mainform
						     (list XmNtoolTipString (XmStringCreateLocalized "tooltip")
							   XmNtoolTipPostDelay 100
							   XmNtoolTipPostDuration 500
							   XmNtoolTipEnable #t
							   XmNanimate #f))))
		    (let ((tip (XmToolTipGetLabel wid1)))
		      (if (not (Widget? tip)) (snd-display #__line__ ";tooltip label: ~A" tip)))))
	      
	      (XtManageChild new-dialog)
	      (XtUnmanageChild new-dialog)))
	  
	  (let* ((shell (cadr (main-widgets)))
		 (dpy (XtDisplay shell))
		 (prop (XmInternAtom dpy "TESTING" #f))
		 (proto1 (XmInternAtom dpy "TEST1" #f))
		 (proto2 (XmInternAtom dpy "TEST2" #f))
		 (val 0))
	    (if (not (Atom? prop)) (snd-display #__line__ ";XmInternAtom: ~A" prop))
	    (if (not (string=? (XmGetAtomName dpy prop) "TESTING")) (snd-display #__line__ ";XmGetAtomName: ~A" (XmGetAtomName dpy prop)))
	    (XmAddProtocols shell prop (list proto1 proto2))
	    (XmSetProtocolHooks shell
				(XmInternAtom dpy "WM_PROTOCOLS" #f)
				prop
				(lambda (w c i)
				  (snd-display #__line__ ";prehook: ~A ~A ~A" w c i))
				12345
				(lambda (w c i)
				  (snd-display #__line__ ";posthook: ~A ~A ~A" w c i))
				54321)
	    (XmDeactivateProtocol shell prop proto2)
	    (XmRemoveProtocols shell prop (list proto2))
	    (XmAddProtocolCallback shell prop proto1 (lambda (w c i) (set! val c)) 123)
	    (XmActivateProtocol shell prop proto1)
	    (let ((e (XEvent ClientMessage))
		  (window (XtWindow shell)))
	      (set! (.window e) window)
	      (set! (.display e) dpy)
	      (set! (.format e) 8)
	      (set! (.message_type e) XA_STRING)
	      (set! (.data e) "hiho")
	      (XSendEvent dpy window #f 0 e))
	    (XmRemoveProtocols shell prop (list proto1)))
	  (XmCascadeButtonHighlight (XmCreateCascadeButton (cadr (main-widgets)) "cascade" '()) #f)
					;(XmCascadeButtonGadgetHighlight (XmCreateCascadeButtonGadget (cadr (main-widgets)) "gadget" '()) #f)
	  
	  (let ((callbacks
		 (list
		  (list XmAnyCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event))
		  (list XmArrowButtonCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) (list .click_count 'int '.click_count))
		  (list XmCommandCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .value 'XmString '.value) (list .length 'int '.length #f))
		  (list XmDragDropFinishCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp))
		  (list XmDragMotionCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .operation 'uchar '.operation) 
			(list .operations 'uchar '.operations #f) (list .dropSiteStatus 'uchar '.dropSiteStatus) 
			(list .x 'Position '.x #f) (list .y 'Position '.y #f))
		  (list XmDragProcCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .dragContext 'Widget '.dragContext #f) 
			(list .x 'Position '.x #f) (list .y 'Position '.y #f) (list .dropSiteStatus 'uchar '.dropSiteStatus) 
			(list .operation 'uchar '.operation) (list .operations 'uchar '.operations #f) (list .animate 'Boolean '.animate #f))
		  (list XmDrawingAreaCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) (list .window 'Window '.window))
		  (list XmDrawnButtonCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .window 'Window '.window) (list .click_count 'int '.click_count))
		  (list XmDropFinishCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .operation 'uchar '.operation) 
			(list .operations 'uchar '.operations #f) (list .dropSiteStatus 'uchar '.dropSiteStatus) 
			(list .dropAction 'uchar '.dropAction #f) (list .completionStatus 'uchar '.completionStatus #f))
		  (list XmDropProcCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .dragContext 'Widget '.dragContext #f) 
			(list .x 'Position '.x #f) (list .y 'Position '.y #f) (list .dropSiteStatus 'uchar '.dropSiteStatus)
			(list .operation 'uchar '.operation) (list .operations 'uchar '.operations #f) (list .dropAction 'uchar '.dropAction #f))
		  (list XmDropSiteEnterCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .operation 'uchar '.operation) 
			(list .operations 'uchar '.operations #f) (list .dropSiteStatus 'uchar '.dropSiteStatus) 
			(list .x 'Position '.x #f) (list .y 'Position '.y #f))
		  (list XmDropSiteLeaveCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp))
		  (list XmDropStartCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .operation 'uchar '.operation) 
			(list .operations 'uchar '.operations #f) (list .dropSiteStatus 'uchar '.dropSiteStatus) 
			(list .dropAction 'uchar '.dropAction #f))
		  (list XmFileSelectionBoxCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .value 'XmString '.value) (list .length 'int '.length #f) (list .mask 'XmString '.mask #f) 
			(list .mask_length 'int '.mask_length #f) (list .dir 'XmString '.dir #f) (list .dir_length 'int '.dir_length #f) 
			(list .pattern 'XmString '.pattern #f) (list .pattern_length 'int '.pattern_length #f))
		  (list XmListCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .item 'XmString '.item #f) (list .item_length 'int '.item_length #f) (list .item_position 'int '.item_position #f) 
			(list .selected_items 'XmString* '.selected_items) (list .selected_item_count 'int '.selected_item_count #f) 
			(list .selected_item_positions 'int* '.selected_item_positions) (list .selection_type 'char '.selection_type #f) 
			(list .auto_selection_type 'char '.auto_selection_type #f))
		  (list XmOperationChangedCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .operation 'uchar '.operation) (list .operations 'uchar '.operations #f) 
			(list .dropSiteStatus 'uchar '.dropSiteStatus))
		  (list XmPushButtonCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) (list .click_count 'int '.click_count))
		  (list XmRowColumnCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event)
			(list .widget 'Widget '.widget #f) (list .data 'char* '.data #f) (list .callbackstruct 'char* '.callbackstruct #f))
		  (list XmScaleCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) (list .value 'int '.value))
		  (list XmScrollBarCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .value 'int '.value) (list .pixel 'int '.pixel #f))
		  (list XmSelectionBoxCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .value 'XmString '.value) (list .length 'int '.length #f))
		  (list XmTextVerifyCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .doit 'Boolean '.doit) (list .currInsert 'int '.currInsert #f) (list .newInsert 'int '.newInsert #f) 
			(list .startPos 'int '.startPos #f) (list .endPos 'int '.endPos #f)
			(list .text 'XmTextBlock '.text #f))
		  (list XmToggleButtonCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) (list .set 'int '.set))
		  (list XmDestinationCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .selection 'Atom '.selection #f) (list .operation 'uchar '.operation) (list .flags 'int '.flags #f) 
			(list .transfer_id 'XtPointer '.transfer_id #f) (list .destination_data 'XtPointer '.destination_data #f) 
			(list .location_data 'XtPointer '.location_data #f) (list .time 'Time '.time))
		  (list XmConvertCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) (list .selection 'Atom '.selection #f) 
			(list .target 'Atom '.target #f) (list .source_data 'XtPointer '.source_data #f)
			(list .location_data 'XtPointer '.location_data #f) (list .flags 'int '.flags #f) (list .parm 'XtPointer '.parm #f) 
			(list .parm_format 'int '.parm_format #f) (list .parm_length 'int '.parm_length #f) 
			(list .parm_type 'Atom '.parm_type #f) (list .status 'int '.status #f) (list .value 'XtPointer '.value #f)
			(list .type 'Atom '.type #f) (list .format 'int '.format #f) (list .length 'int '.length #f))
		  (list XmComboBoxCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .item_or_text 'XmString '.item_or_text #f) (list .item_position 'int '.item_position #f))
		  (list XmContainerOutlineCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .item 'Widget '.item #f) (list .new_outline_state 'uchar '.new_outline_state #f))
		  (list XmContainerSelectCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .selected_items 'Widget* '.selected_items) (list .selected_item_count 'int '.selected_item_count #f) 
			(list .auto_selection_type 'uchar '.auto_selection_type #f))
		  (list XmNotebookCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .page_number 'int '.page_number #f) (list .page_widget 'Widget '.page_widget #f) 
			(list .prev_page_number 'int '.prev_page_number #f) (list .prev_page_widget 'Widget '.prev_page_widget #f))
		  (list XmSpinBoxCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .widget 'Widget '.widget #f) (list .doit 'Boolean '.doit) (list .position 'int '.position #f)
			(list .value 'XmString '.value #f) (list .crossed_boundary 'Boolean '.crossed-boundary #f))
		  (list XmTraverseObscuredCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .traversal_destination 'Widget '.traversal_destination #f))
		  (list XmTopLevelLeaveCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .screen 'Screen '.screen) (list .window 'Window '.window))
		  (list XmTopLevelEnterCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .timeStamp 'Time '.timeStamp) (list .screen 'Screen '.screen) (list .window 'Window '.window) 
			(list .x 'Position '.x #f) (list .y 'Position '.y #f) (list .dragProtocolStyle 'uchar '.dragProtocolStyle #f))
		  (list XmPopupHandlerCallbackStruct (list .reason 'int '.reason)
			(list .event 'XEvent '.event) (list .menuToPost 'Widget '.menuToPost) (list .postIt 'Boolean '.postIt)
			(list .target 'Widget '.target #f))
		  (list XmSelectionCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .selection 'Atom '.selection #f) (list .target 'Atom '.target #f) (list .type 'Atom '.type #f)
			(list .transfer_id 'XtPointer '.transfer_id #f) (list .flags 'int '.flags #f) (list .remaining 'int '.remaining #f) 
			(list .value 'XtPointer '.value #f) (list .length 'int '.length #f) (list .format 'int '.format #f))
		  (list XmTransferDoneCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event)  
			(list .selection 'Atom '.selection #f) (list .transfer_id 'XtPointer '.transfer_id #f) (list .status 'int '.status #f) 
			(list .client_data 'XtPointer '.client_data #f))
		  (list XmDisplayCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .font_name 'char* '.font_name #f) (list .tag 'int '.tag #f)
			(list .render_table 'XmRenderTable '.render_table #f)
			(list .rendition 'XmRendition '.rendition #f))
		  (list XmDragStartCallbackStruct (list .reason 'int '.reason) (list .event 'XEvent '.event) 
			(list .widget 'Widget '.widget #f) (list .doit 'Boolean '.doit))
		  )))
	    
	    
	    (for-each
	     (lambda (call)
	       (let ((struct ((car call)))
		     (val #f))
		 (set! (.event struct) (XEvent))
		 (for-each
		  (lambda (field)
		    (if (not (list-p field)) (snd-display #__line__ ";~A: ~A" struct field))
		    (set! val ((car field) struct))
		    (if (< (length field) 4)
			(case (cadr field)
			  ((int) (set! ((car field) struct) 0))
			  ((Atom) (set! ((car field) struct) XA_STRING))
			  ((uchar) (set! ((car field) struct) 0))
			  ((Position) (set! ((car field) struct) 0))
			  ((Widget) (set! ((car field) struct) (list 'Widget 0)))
			  ((XmString) (set! ((car field) struct) (list 'XmString 0)))
			  ((XtPointer) (set! ((car field) struct) 0))
			  ((char*) (set! ((car field) struct) "hi"))
			  ((Boolean) (set! ((car field) struct) #f))
			  ((XEvent) #f) ; already being set
			  ((XmString* int* Time Window Widget* Screen) #f) 
			  ((char) (set! ((car field) struct) 0))
			  )))
		  (cdr call))))
	     callbacks)
	    )
	  
	  (let ((shell (cadr (main-widgets)))
		(resource-list
		 (list
		  (list XmNaccelerator XM_STRING) (list XmNacceleratorText XM_XMSTRING) (list XmNaccelerators XM_ULONG)
		  (list XmNactivateCallback XM_CALLBACK) (list XmNadjustLast XM_BOOLEAN) (list XmNadjustMargin XM_BOOLEAN)
		  (list XmNalignment XM_UCHAR) (list XmNallowOverlap XM_BOOLEAN) (list XmNallowResize XM_BOOLEAN)
		  (list XmNallowShellResize XM_BOOLEAN) (list XmNancestorSensitive XM_BOOLEAN) (list XmNanimationMask XM_PIXMAP)
		  (list XmNanimationPixmap XM_PIXMAP) (list XmNanimationPixmapDepth XM_INT) (list XmNanimationStyle XM_UCHAR)
		  (list XmNapplyCallback XM_CALLBACK) (list XmNapplyLabelString XM_XMSTRING) (list XmNargc XM_INT)
		  (list XmNargv XM_STRING_LIST) (list XmNarmCallback XM_CALLBACK) (list XmNarmColor XM_PIXEL)
		  (list XmNarmPixmap XM_PIXMAP) (list XmNarrowDirection XM_UCHAR) (list XmNattachment XM_UCHAR)
		  (list XmNaudibleWarning XM_UCHAR) (list XmNautoShowCursorPosition XM_BOOLEAN) (list XmNautoUnmanage XM_BOOLEAN)
		  (list XmNautomaticSelection XM_UCHAR) (list XmNbackground XM_PIXEL) (list XmNbackgroundPixmap XM_PIXMAP)
		  (list XmNbaseHeight XM_INT) (list XmNbaseWidth XM_INT) (list XmNbitmap XM_PIXMAP)
		  (list XmNblendModel XM_ULONG) (list XmNblinkRate XM_INT) (list XmNborderColor XM_PIXEL)
		  (list XmNborderPixmap XM_PIXMAP) (list XmNborderWidth XM_DIMENSION) (list XmNbottomAttachment XM_UCHAR)
		  (list XmNbottomOffset XM_INT) (list XmNbottomPosition XM_INT) (list XmNbottomShadowColor XM_PIXEL)
		  (list XmNbottomShadowPixmap XM_PIXMAP) (list XmNbottomWidget XM_WIDGET) (list XmNbrowseSelectionCallback XM_CALLBACK)
		  (list XmNbuttonAcceleratorText XM_STRING_TABLE) (list XmNbuttonAccelerators XM_STRING_TABLE) (list XmNbuttonCount XM_INT)
		  (list XmNbuttonMnemonicCharSets XM_CHARSET_TABLE) (list XmNbuttonMnemonics XM_KEYSYM_TABLE) (list XmNbuttonSet XM_INT)
		  (list XmNbuttonType XM_ULONG) (list XmNbuttons XM_STRING_TABLE) (list XmNcancelButton XM_WIDGET)
		  (list XmNcancelCallback XM_CALLBACK) (list XmNcancelLabelString XM_XMSTRING) (list XmNcascadePixmap XM_PIXMAP)
		  (list XmNcascadingCallback XM_CALLBACK) (list XmNchildHorizontalAlignment XM_UCHAR) (list XmNchildHorizontalSpacing XM_DIMENSION)
		  (list XmNchildPlacement XM_UCHAR) (list XmNchildVerticalAlignment XM_UCHAR) (list XmNchildren XM_WIDGET_LIST)
		  (list XmNclientData XM_ULONG) (list XmNclipWindow XM_WIDGET) (list XmNcolormap XM_COLORMAP)
		  (list XmNcolumns XM_SHORT) (list XmNcommand XM_XMSTRING) (list XmNcommandChangedCallback XM_CALLBACK)
		  (list XmNcommandEnteredCallback XM_CALLBACK) (list XmNcommandWindow XM_WIDGET) (list XmNcommandWindowLocation XM_UCHAR)
		  (list XmNconvertProc XM_CONVERT_CALLBACK) (list XmNcreatePopupChildProc XM_POPUP_CALLBACK) (list XmNcursorBackground XM_PIXEL)
		  (list XmNcursorForeground XM_PIXEL) (list XmNcursorPosition XM_INT) (list XmNcursorPositionVisible XM_BOOLEAN)
		  (list XmNdarkThreshold XM_INT) (list XmNdecimalPoints XM_SHORT) (list XmNdecrementCallback XM_CALLBACK)
		  (list XmNdefaultActionCallback XM_CALLBACK) (list XmNdefaultButton XM_WIDGET) (list XmNdefaultButtonShadowThickness XM_DIMENSION)
		  (list XmNdefaultButtonType XM_UCHAR) (list XmNdefaultCopyCursorIcon XM_WIDGET) (list XmNdefaultInvalidCursorIcon XM_WIDGET)
		  (list XmNdefaultLinkCursorIcon XM_WIDGET) (list XmNdefaultMoveCursorIcon XM_WIDGET) (list XmNdefaultNoneCursorIcon XM_WIDGET)
		  (list XmNdefaultPosition XM_BOOLEAN) (list XmNdefaultSourceCursorIcon XM_WIDGET) (list XmNdefaultValidCursorIcon XM_WIDGET)
		  (list XmNdeleteResponse XM_UCHAR) (list XmNdepth XM_INT) (list XmNdestroyCallback XM_CALLBACK)
		  (list XmNdialogStyle XM_UCHAR) (list XmNdialogTitle XM_XMSTRING) (list XmNdialogType XM_UCHAR)
		  (list XmNdirListItemCount XM_INT) (list XmNdirListItems XM_STRING_TABLE) (list XmNdirListLabelString XM_XMSTRING)
		  (list XmNdirMask XM_XMSTRING) (list XmNdirSearchProc XM_SEARCH_CALLBACK) (list XmNdirSpec XM_XMSTRING)
		  (list XmNdirectory XM_XMSTRING) (list XmNdirectoryValid XM_BOOLEAN) (list XmNdisarmCallback XM_CALLBACK)
		  (list XmNdoubleClickInterval XM_INT) (list XmNdragDropFinishCallback XM_CALLBACK) (list XmNdragInitiatorProtocolStyle XM_UCHAR)
		  (list XmNdragMotionCallback XM_CALLBACK) (list XmNdragOperations XM_UCHAR) (list XmNdragReceiverProtocolStyle XM_UCHAR)
		  (list XmNdropFinishCallback XM_CALLBACK) (list XmNdropProc XM_DROP_CALLBACK) (list XmNdropRectangles XM_RECTANGLE_LIST)
		  (list XmNdropSiteActivity XM_UCHAR) (list XmNdropSiteEnterCallback XM_CALLBACK) (list XmNdropSiteLeaveCallback XM_CALLBACK)
		  (list XmNdropSiteOperations XM_UCHAR) (list XmNdropSiteType XM_UCHAR) (list XmNdropStartCallback XM_CALLBACK)
		  (list XmNdropTransfers XM_TRANSFER_ENTRY_LIST) (list XmNeditMode XM_INT) (list XmNeditable XM_BOOLEAN)
		  (list XmNentryAlignment XM_UCHAR) (list XmNentryBorder XM_DIMENSION) (list XmNentryCallback XM_CALLBACK)
		  (list XmNentryClass XM_WIDGET_CLASS) (list XmNentryVerticalAlignment XM_UCHAR) (list XmNexportTargets XM_ATOM_LIST)
		  (list XmNexposeCallback XM_CALLBACK) (list XmNextendedSelectionCallback XM_CALLBACK) (list XmNfileListItemCount XM_INT)
		  (list XmNfileListItems XM_STRING_TABLE) (list XmNfileListLabelString XM_XMSTRING) (list XmNfileSearchProc XM_SEARCH_CALLBACK)
		  (list XmNfileTypeMask XM_UCHAR) (list XmNfillOnArm XM_BOOLEAN) (list XmNfillOnSelect XM_BOOLEAN)
		  (list XmNfilterLabelString XM_XMSTRING) (list XmNfocusCallback XM_CALLBACK) (list XmNfont XM_XFONTSTRUCT)
		  (list XmNforeground XM_PIXEL) (list XmNforegroundThreshold XM_INT) (list XmNfractionBase XM_INT)
		  (list XmNgainPrimaryCallback XM_CALLBACK) (list XmNgeometry XM_STRING) (list XmNheight XM_DIMENSION)
		  (list XmNheightInc XM_INT) (list XmNhelpCallback XM_CALLBACK) (list XmNhelpLabelString XM_XMSTRING)
		  (list XmNhighlightColor XM_PIXEL) (list XmNhighlightOnEnter XM_BOOLEAN) (list XmNhighlightPixmap XM_PIXMAP)
		  (list XmNhighlightThickness XM_DIMENSION) (list XmNhistoryItemCount XM_INT) (list XmNhistoryItems XM_STRING_TABLE)
		  (list XmNhistoryMaxItems XM_INT) (list XmNhistoryVisibleItemCount XM_INT) (list XmNhorizontalFontUnit XM_INT)
		  (list XmNhorizontalScrollBar XM_WIDGET) (list XmNhorizontalSpacing XM_DIMENSION) (list XmNhotX XM_POSITION)
		  (list XmNhotY XM_POSITION) (list XmNiconMask XM_PIXMAP) (list XmNiconName XM_STRING)
		  (list XmNiconNameEncoding XM_ATOM) (list XmNiconPixmap XM_PIXMAP) (list XmNiconWindow XM_WIDGET)
		  (list XmNiconX XM_INT) (list XmNiconY XM_INT) (list XmNiconic XM_BOOLEAN)
		  (list XmNimportTargets XM_ATOM_LIST) (list XmNincrement XM_INT) (list XmNincrementCallback XM_CALLBACK)
		  (list XmNincremental XM_BOOLEAN) (list XmNindicatorOn XM_INT) (list XmNindicatorSize XM_DIMENSION)
		  (list XmNindicatorType XM_UCHAR) (list XmNinitialDelay XM_INT) (list XmNinitialFocus XM_WIDGET)
		  (list XmNinitialResourcesPersistent XM_BOOLEAN) (list XmNinitialState XM_INT) (list XmNinput XM_BOOLEAN)
		  (list XmNinputCallback XM_CALLBACK) (list XmNinputMethod XM_STRING) (list XmNinsertPosition XM_ORDER_CALLBACK)
		  (list XmNinvalidCursorForeground XM_PIXEL) (list XmNisAligned XM_BOOLEAN) (list XmNisHomogeneous XM_BOOLEAN)
		  (list XmNitemCount XM_INT) (list XmNitems XM_STRING_TABLE) (list XmNkeyboardFocusPolicy XM_UCHAR)
		  (list XmNlabelInsensitivePixmap XM_PIXMAP) (list XmNlabelPixmap XM_PIXMAP) (list XmNlabelString XM_XMSTRING)
		  (list XmNlabelType XM_UCHAR) (list XmNleftAttachment XM_UCHAR) (list XmNleftOffset XM_INT)
		  (list XmNleftPosition XM_INT) (list XmNleftWidget XM_WIDGET) (list XmNlightThreshold XM_INT)
		  (list XmNlistItemCount XM_INT) (list XmNlistItems XM_STRING_TABLE) (list XmNlistLabelString XM_XMSTRING)
		  (list XmNlistMarginHeight XM_DIMENSION) (list XmNlistMarginWidth XM_DIMENSION) (list XmNlistSizePolicy XM_UCHAR)
		  (list XmNlistSpacing XM_DIMENSION) (list XmNlistUpdated XM_BOOLEAN) (list XmNlistVisibleItemCount XM_INT)
		  (list XmNlosePrimaryCallback XM_CALLBACK) (list XmNlosingFocusCallback XM_CALLBACK) (list XmNmainWindowMarginHeight XM_DIMENSION)
		  (list XmNmainWindowMarginWidth XM_DIMENSION) (list XmNmapCallback XM_CALLBACK) (list XmNmappedWhenManaged XM_BOOLEAN)
		  (list XmNmappingDelay XM_INT) (list XmNmargin XM_DIMENSION) (list XmNmarginBottom XM_DIMENSION)
		  (list XmNmarginHeight XM_DIMENSION) (list XmNmarginLeft XM_DIMENSION) (list XmNmarginRight XM_DIMENSION)
		  (list XmNmarginTop XM_DIMENSION) (list XmNmarginWidth XM_DIMENSION) (list XmNmask XM_PIXMAP)
		  (list XmNmaxAspectX XM_INT) (list XmNmaxAspectY XM_INT) (list XmNmaxHeight XM_INT)
		  (list XmNmaxLength XM_INT) (list XmNmaxWidth XM_INT) (list XmNmaximum XM_INT)
		  (list XmNmenuAccelerator XM_STRING) (list XmNmenuBar XM_WIDGET) (list XmNmenuCursor XM_STRING)
		  (list XmNmenuHelpWidget XM_WIDGET) (list XmNmenuHistory XM_WIDGET) (list XmNmenuPost XM_STRING)
		  (list XmNmessageAlignment XM_UCHAR) (list XmNmessageString XM_XMSTRING) (list XmNmessageWindow XM_WIDGET)
		  (list XmNminAspectX XM_INT) (list XmNminAspectY XM_INT) (list XmNminHeight XM_INT)
		  (list XmNminWidth XM_INT) (list XmNminimizeButtons XM_BOOLEAN) (list XmNminimum XM_INT)
		  (list XmNmnemonic XM_KEYSYM) (list XmNmnemonicCharSet XM_STRING) (list XmNmodifyVerifyCallback XM_CALLBACK)
		  (list XmNmotionVerifyCallback XM_CALLBACK) (list XmNmoveOpaque XM_BOOLEAN) (list XmNmultiClick XM_UCHAR)
		  (list XmNmultipleSelectionCallback XM_CALLBACK) (list XmNmustMatch XM_BOOLEAN) (list XmNmwmDecorations XM_INT)
		  (list XmNmwmFunctions XM_INT) (list XmNmwmInputMode XM_INT) (list XmNmwmMenu XM_STRING)
		  (list XmNnavigationType XM_UCHAR) (list XmNnoMatchCallback XM_CALLBACK) (list XmNnoMatchString XM_XMSTRING)
		  (list XmNnoResize XM_BOOLEAN) (list XmNnoneCursorForeground XM_PIXEL) (list XmNnumChildren XM_INT)
		  (list XmNnumColumns XM_SHORT) (list XmNnumDropRectangles XM_INT) (list XmNnumDropTransfers XM_INT)
		  (list XmNnumExportTargets XM_INT) (list XmNnumImportTargets XM_INT) (list XmNoffsetX XM_POSITION)
		  (list XmNoffsetY XM_POSITION) (list XmNokCallback XM_CALLBACK) (list XmNokLabelString XM_XMSTRING)
		  (list XmNoperationChangedCallback XM_CALLBACK) (list XmNoperationCursorIcon XM_WIDGET) (list XmNoptionLabel XM_XMSTRING)
		  (list XmNoptionMnemonic XM_KEYSYM) (list XmNorientation XM_UCHAR) (list XmNoverrideRedirect XM_BOOLEAN)
		  (list XmNpacking XM_UCHAR) (list XmNpageDecrementCallback XM_CALLBACK) (list XmNpageIncrement XM_INT)
		  (list XmNpageIncrementCallback XM_CALLBACK) (list XmNpaneMaximum XM_DIMENSION) (list XmNpaneMinimum XM_DIMENSION)
		  (list XmNpattern XM_STRING_OR_XMSTRING) (list XmNpendingDelete XM_BOOLEAN) (list XmNpixmap XM_PIXMAP)
		  (list XmNpopdownCallback XM_CALLBACK) (list XmNpopupCallback XM_CALLBACK) (list XmNpopupEnabled XM_INT)
		  (list XmNpositionIndex XM_SHORT) (list XmNpostFromButton XM_INT) (list XmNpreeditType XM_STRING)
		  (list XmNprocessingDirection XM_UCHAR) (list XmNpromptString XM_XMSTRING) (list XmNpushButtonEnabled XM_BOOLEAN)
		  (list XmNqualifySearchDataProc XM_QUALIFY_CALLBACK) (list XmNradioAlwaysOne XM_BOOLEAN) (list XmNradioBehavior XM_BOOLEAN)
		  (list XmNrecomputeSize XM_BOOLEAN) (list XmNrefigureMode XM_BOOLEAN) (list XmNrepeatDelay XM_INT)
		  (list XmNresizable XM_BOOLEAN) (list XmNresizeCallback XM_CALLBACK) (list XmNresizeHeight XM_BOOLEAN)
		  (list XmNresizePolicy XM_UCHAR) (list XmNresizeWidth XM_BOOLEAN) (list XmNrightAttachment XM_UCHAR)
		  (list XmNrightOffset XM_INT) (list XmNrightPosition XM_INT) (list XmNrightWidget XM_WIDGET)
		  (list XmNrowColumnType XM_UCHAR) (list XmNrows XM_SHORT) (list XmNrubberPositioning XM_BOOLEAN)
		  (list XmNsashHeight XM_DIMENSION) (list XmNsashIndent XM_POSITION) (list XmNsashShadowThickness XM_DIMENSION)
		  (list XmNsashWidth XM_DIMENSION) (list XmNsaveUnder XM_BOOLEAN) (list XmNscaleHeight XM_DIMENSION)
		  (list XmNscaleMultiple XM_INT) (list XmNscaleWidth XM_DIMENSION) (list XmNscreen XM_SCREEN)
		  (list XmNscrollBarDisplayPolicy XM_UCHAR) (list XmNscrollBarPlacement XM_UCHAR) (list XmNscrollHorizontal XM_BOOLEAN)
		  (list XmNscrollLeftSide XM_BOOLEAN) (list XmNscrollTopSide XM_BOOLEAN) (list XmNscrollVertical XM_BOOLEAN)
		  (list XmNscrolledWindowMarginHeight XM_DIMENSION) (list XmNscrolledWindowMarginWidth XM_DIMENSION) (list XmNscrollingPolicy XM_UCHAR)
		  (list XmNselectColor XM_PIXEL) (list XmNselectInsensitivePixmap XM_PIXMAP) (list XmNselectPixmap XM_PIXMAP)
		  (list XmNselectThreshold XM_INT) (list XmNselectedItemCount XM_INT) (list XmNselectedItems XM_STRING_TABLE)
		  (list XmNselectionArray XM_INT_TABLE) (list XmNselectionArrayCount XM_INT) (list XmNselectionLabelString XM_XMSTRING)
		  (list XmNselectionPolicy XM_UCHAR) (list XmNsensitive XM_BOOLEAN) (list XmNseparatorOn XM_BOOLEAN)
		  (list XmNseparatorType XM_UCHAR) (list XmNset XM_UCHAR) (list XmNshadowThickness XM_DIMENSION)
		  (list XmNshadowType XM_UCHAR) (list XmNshowArrows XM_BOOLEAN) (list XmNshowAsDefault XM_DIMENSION)
		  (list XmNshowSeparator XM_BOOLEAN) (list XmNsimpleCallback XM_CALLBACK) (list XmNsingleSelectionCallback XM_CALLBACK)
		  (list XmNskipAdjust XM_BOOLEAN) (list XmNsliderSize XM_INT) (list XmNsliderVisual XM_INT)
		  (list XmNslidingMode XM_INT) (list XmNsource XM_TEXT_SOURCE) (list XmNsourceCursorIcon XM_WIDGET)
		  (list XmNsourcePixmapIcon XM_WIDGET) (list XmNspacing XM_DIMENSION) (list XmNspotLocation XM_INT)
		  (list XmNstateCursorIcon XM_WIDGET) (list XmNsubMenuId XM_WIDGET) (list XmNsymbolPixmap XM_PIXMAP)
		  (list XmNtearOffMenuActivateCallback XM_CALLBACK) (list XmNtearOffMenuDeactivateCallback XM_CALLBACK) (list XmNtearOffModel XM_UCHAR)
		  (list XmNtextAccelerators XM_ULONG) (list XmNtextColumns XM_SHORT) (list XmNtextString XM_XMSTRING)
		  (list XmNtextTranslations XM_CALLBACK) (list XmNtitle XM_STRING) (list XmNtitleEncoding XM_ATOM)
		  (list XmNtitleString XM_XMSTRING) (list XmNtoBottomCallback XM_CALLBACK) (list XmNtoTopCallback XM_CALLBACK)
		  (list XmNtopAttachment XM_UCHAR) (list XmNtopCharacter XM_INT) (list XmNtopItemPosition XM_INT)
		  (list XmNtopLevelEnterCallback XM_CALLBACK) (list XmNtopLevelLeaveCallback XM_CALLBACK) (list XmNtopOffset XM_INT)
		  (list XmNtopPosition XM_INT) (list XmNtopShadowColor XM_PIXEL) (list XmNtopShadowPixmap XM_PIXMAP)
		  (list XmNtopWidget XM_WIDGET) (list XmNtransferProc XM_TRANSFER_CALLBACK) (list XmNtransferStatus XM_UCHAR)
		  (list XmNtransient XM_BOOLEAN) (list XmNtransientFor XM_WIDGET) (list XmNtranslations XM_CALLBACK)
		  (list XmNtraversalOn XM_BOOLEAN) (list XmNtraverseObscuredCallback XM_CALLBACK) (list XmNtroughColor XM_PIXEL)
		  (list XmNunitType XM_UCHAR) (list XmNunmapCallback XM_CALLBACK) (list XmNunpostBehavior XM_UCHAR)
		  (list XmNuseAsyncGeometry XM_BOOLEAN) (list XmNuserData XM_ULONG) (list XmNvalidCursorForeground XM_PIXEL)
		  (list XmNvalue XM_STRING_OR_INT) (list XmNvalueChangedCallback XM_CALLBACK) (list XmNverifyBell XM_BOOLEAN)
		  (list XmNverticalFontUnit XM_INT) (list XmNverticalScrollBar XM_WIDGET) (list XmNverticalSpacing XM_DIMENSION)
		  (list XmNvisibleItemCount XM_INT) (list XmNvisibleWhenOff XM_BOOLEAN) (list XmNvisual XM_VISUAL)
		  (list XmNvisualPolicy XM_UCHAR) (list XmNwidth XM_DIMENSION) (list XmNwidthInc XM_INT)
		  (list XmNwinGravity XM_INT) (list XmNwindow XM_WIDGET) (list XmNwindowGroup XM_WINDOW)
		  (list XmNwmTimeout XM_INT) (list XmNwordWrap XM_BOOLEAN) (list XmNworkWindow XM_WIDGET)
		  (list XmNx XM_POSITION) (list XmNy XM_POSITION) (list XmNarrowLayout XM_UCHAR)
		  (list XmNarrowOrientation XM_UCHAR) (list XmNarrowSensitivity XM_UCHAR) (list XmNarrowSize XM_INT)
		  (list XmNarrowSpacing XM_INT) (list XmNautoDragModel XM_INT) (list XmNbackPageBackground XM_PIXEL)
		  (list XmNbackPageForeground XM_PIXEL) (list XmNbackPageNumber XM_INT) (list XmNbackPagePlacement XM_UCHAR)
		  (list XmNbackPageSize XM_DIMENSION) (list XmNbindingPixmap XM_PIXMAP) (list XmNbindingType XM_UCHAR)
		  (list XmNbindingWidth XM_INT) (list XmNbitmapConversionModel XM_INT) (list XmNbuttonRenderTable XM_RENDER_TABLE)
		  (list XmNcollapsedStatePixmap XM_PIXMAP) (list XmNcolorAllocationProc XM_ALLOC_COLOR_CALLBACK) 
		  (list XmNcolorCalculationProc XM_SCREEN_COLOR_CALLBACK)
		  (list XmNcomboBoxType XM_UCHAR) (list XmNconvertCallback XM_CALLBACK) (list XmNcurrentPageNumber XM_INT)
		  (list XmNdecimal XM_STRING) (list XmNdefaultArrowSensitivity XM_UCHAR) (list XmNdefaultButtonEmphasis XM_INT)
		  (list XmNdefaultVirtualBindings XM_STRING) (list XmNdestinationCallback XM_CALLBACK) (list XmNdetail XM_STRING_TABLE)
		  (list XmNdetailColumnHeading XM_INT) (list XmNdetailColumnHeadingCount XM_INT) (list XmNdetailCount XM_INT)
		  (list XmNdetailOrder XM_INT_TABLE) (list XmNdetailOrderCount XM_INT) (list XmNdetailShadowThickness XM_INT)
		  (list XmNdetailTabList XM_TAB_LIST) (list XmNdirTextLabelString XM_XMSTRING) (list XmNdragStartCallback XM_CALLBACK)
		  (list XmNenableBtn1Transfer XM_INT) (list XmNenableButtonTab XM_BOOLEAN) (list XmNenableDragIcon XM_BOOLEAN)
		  (list XmNenableEtchedInMenu XM_BOOLEAN) (list XmNenableMultiKeyBindings XM_BOOLEAN) (list XmNenableThinThickness XM_BOOLEAN)
		  (list XmNenableToggleColor XM_BOOLEAN) (list XmNenableToggleVisual XM_BOOLEAN) (list XmNenableUnselectableDrag XM_BOOLEAN)
		  (list XmNenableWarp XM_INT) (list XmNentryParent XM_WIDGET) (list XmNentryViewType XM_UCHAR)
		  (list XmNexpandedStatePixmap XM_PIXMAP) (list XmNfileFilterStyle XM_INT) (list XmNfirstPageNumber XM_INT)
		  (list XmNfontName XM_STRING) (list XmNfontType XM_UCHAR) (list XmNframeBackground XM_PIXEL)
		  (list XmNframeChildType XM_UCHAR) (list XmNframeShadowThickness XM_DIMENSION) (list XmNgrabStyle XM_INT)
		  (list XmNincludeStatus XM_INT) (list XmNincrementValue XM_INT) (list XmNindeterminateInsensitivePixmap XM_PIXMAP)
		  (list XmNindeterminatePixmap XM_PIXMAP) (list XmNinnerMarginHeight XM_DIMENSION) (list XmNinnerMarginWidth XM_DIMENSION)
		  (list XmNinputPolicy XM_ULONG) (list XmNinsensitiveStippleBitmap XM_PIXMAP) (list XmNinvokeParseProc XM_PARSE_CALLBACK)
		  (list XmNlabelRenderTable XM_RENDER_TABLE) (list XmNlargeCellHeight XM_DIMENSION) (list XmNlargeCellWidth XM_DIMENSION)
		  (list XmNlargeIconMask XM_PIXMAP) (list XmNlargeIconPixmap XM_PIXMAP) (list XmNlargeIconX XM_FLOAT)
		  (list XmNlargeIconY XM_FLOAT) (list XmNlastPageNumber XM_INT) (list XmNlayoutDirection XM_UCHAR)
		  (list XmNlayoutType XM_UCHAR) (list XmNlist XM_WIDGET) (list XmNloadModel XM_UCHAR)
		  (list XmNmajorTabSpacing XM_DIMENSION) (list XmNmatchBehavior XM_UCHAR) (list XmNmaximumValue XM_INT)
		  (list XmNminimumValue XM_INT) (list XmNminorTabSpacing XM_DIMENSION) (list XmNmotifVersion XM_INT)
		  (list XmNnoFontCallback XM_CALLBACK) (list XmNnoRenditionCallback XM_CALLBACK) (list XmNnotebookChildType XM_UCHAR)
		  (list XmNnumValues XM_INT) (list XmNoutlineButtonPolicy XM_UCHAR) (list XmNoutlineChangedCallback XM_CALLBACK)
		  (list XmNoutlineColumnWidth XM_DIMENSION) (list XmNoutlineIndentation XM_DIMENSION) (list XmNoutlineLineStyle XM_UCHAR)
		  (list XmNoutlineState XM_UCHAR) (list XmNpageChangedCallback XM_CALLBACK) (list XmNpageNumber XM_INT)
		  (list XmNpathMode XM_INT) (list XmNpatternType XM_UCHAR) (list XmNpopupHandlerCallback XM_CALLBACK)
		  (list XmNposition XM_INT) (list XmNpositionMode XM_INT) (list XmNpositionType XM_UCHAR)
		  (list XmNprimaryOwnership XM_UCHAR) (list XmNrenderTable XM_RENDER_TABLE) (list XmNrenditionBackground XM_PIXEL)
		  (list XmNrenditionForeground XM_PIXEL) (list XmNscrolledWindowChildType XM_UCHAR) (list XmNselectedItem XM_XMSTRING)
		  (list XmNselectedObjectCount XM_INT) (list XmNselectedObjects XM_WIDGET_LIST) (list XmNselectedPosition XM_INT)
		  (list XmNselectedPositionCount XM_INT) (list XmNselectedPositions XM_INT_TABLE) (list XmNselectionCallback XM_CALLBACK)
		  (list XmNselectionMode XM_UCHAR) (list XmNselectionTechnique XM_UCHAR) (list XmNsliderMark XM_INT)
		  (list XmNsmallCellHeight XM_DIMENSION) (list XmNsmallCellWidth XM_DIMENSION) (list XmNsmallIconMask XM_PIXMAP)
		  (list XmNsmallIconPixmap XM_PIXMAP) (list XmNsmallIconX XM_FLOAT) (list XmNsmallIconY XM_FLOAT)
		  (list XmNsnapBackMultiple XM_SHORT) (list XmNspatialIncludeModel XM_UCHAR) (list XmNspatialResizeModel XM_UCHAR)
		  (list XmNspatialSnapModel XM_UCHAR) (list XmNspatialStyle XM_UCHAR) (list XmNspinBoxChildType XM_UCHAR)
		  (list XmNstrikethruType XM_UCHAR) (list XmNsubstitute XM_XMSTRING) (list XmNtabList XM_TAB_LIST)
		  (list XmNtag XM_STRING) (list XmNtearOffTitle XM_XMSTRING) (list XmNtextField XM_WIDGET)
		  (list XmNtextRenderTable XM_RENDER_TABLE) (list XmNtoggleMode XM_UCHAR) (list XmNunderlineType XM_UCHAR)
		  (list XmNunselectColor XM_PIXEL) (list XmNtabValue XM_FLOAT) (list XmNoffsetModel XM_INT)
		  (list XmNcallback XM_CALLBACK) (list XmNwaitForWm XM_BOOLEAN) (list XmNuseColorObj XM_BOOLEAN)
		  (list XmNvalues XM_STRING_TABLE) (list XmNviewType XM_UCHAR) (list XmNvisualEmphasis XM_UCHAR)
		  (list XmNwrap XM_BOOLEAN)
		  )))
	    
	    (for-each
	     (lambda (n)
	       (if (not (string? (car n))) (snd-display #__line__ ";resource ~A is not a string?" (car n)))
	       (XtVaGetValues shell (list (car n) 0)))
	     resource-list)
	    )
	  
	  (if (not (XEvent? (XEvent)))
	      (snd-display #__line__ ";xevent type trouble! ~A -> ~A" (XEvent) (XEvent? (XEvent))))
	  (if (not (XGCValues? (XGCValues)))
	      (snd-display #__line__ ";xgcvalues type trouble! ~A -> ~A" (XGCValues) (XGCValues? (XGCValues))))
	  (if (not (= (.direction (XmTraverseObscuredCallbackStruct)) 0))
	      (snd-display #__line__ ";.direction: ~A" (.direction (XmTraverseObscuredCallbackStruct))))
	  (if (.ptr (XmTextBlock))
	      (snd-display #__line__ ";.ptr block: ~A" (.ptr (XmTextBlock))))
	  (let ((hi (XmTextBlock)))
	    (set! (.ptr hi) "hi")
	    (if (not (string=? (.ptr hi) "hi"))
		(snd-display #__line__ ";.ptr set block: ~A" (.ptr hi)))
	    (if (not (= (.length hi) 0)) (snd-display #__line__ ";.length block: ~A" (.length hi)))
	    (set! (.length hi) 3)
	    (if (not (= (.length hi) 3)) (snd-display #__line__ ";set .length block: ~A" (.length hi))))
	  (if (not (= (.dashes (XGCValues)) 0)) (snd-display #__line__ ";dashes: ~A" (.dashes (XGCValues))))
	  (set! (.dashes (XGCValues)) 1)
	  (set! (.clip_mask (XGCValues)) (list 'Pixmap 0))
	  (set! (.resourceid (XEvent -1)) 0)
	  (set! (.error_code (XEvent -1)) 0)
	  (set! (.request_code (XEvent -1)) 0)
	  (if (not (= (.resourceid (XEvent -1)) 0)) (snd-display #__line__ ";error resourceid: ~A" (.resourceid (XEvent -1))))
	  (if (not (= (.request_code (XEvent -1)) 0)) (snd-display #__line__ ";error request_code: ~A" (.request_code (XEvent -1))))
	  (set! (.pad (XColor)) 1)
	  )
	
	(if (defined? 'XShapeQueryExtents)
	    (let* ((dpy (XtDisplay (cadr (main-widgets))))
		   (win (XtWindow (cadr (main-widgets))))
		   (vals (XShapeQueryExtents dpy win)))
	      (if (not (= (car vals) 1))
		  (snd-display #__line__ ";XShapeQueryExtents: ~A" vals))
	      (set! vals (XShapeGetRectangles dpy win 0))
	      (if (not (list? vals)) (snd-display #__line__ ";XShapeGetRectangles: ~A" vals))
					;(segfault)	  (XtFree (cadr vals)) 
	      (set! vals (XShapeQueryExtension dpy))
	      (if (not (equal? vals (list #t 64 0))) (snd-display #__line__ ";XShapeQueryExtension: ~A" vals))
	      (set! vals (XShapeQueryVersion dpy))
	      (if (and (not (equal? vals (list #t 1 0)))
		       (not (equal? vals (list #t 1 1))))
		  (snd-display #__line__ ";XShapeQueryVersion: ~A" vals))
	      (if (XShapeOffsetShape dpy win 0 0 0) (snd-display #__line__ ";XShapeOffsetShape?"))
	      
	      (let* ((attr (XSetWindowAttributes #f (basic-color) #f (highlight-color)))
		     (newwin (XCreateWindow dpy win 10 10 100 100 3 
					    CopyFromParent InputOutput (list 'Visual CopyFromParent)
					    (logior CWBackPixel CWBorderPixel)
					    attr))
		     (bitmap (XCreateBitmapFromData dpy win right-arrow 16 12))) ; right-arrow is in snd-motif.scm
		(XShapeCombineMask dpy newwin ShapeClip 0 0 bitmap ShapeSet)
		(XShapeCombineRectangles dpy newwin  ShapeUnion 0 0 
					 (list (XRectangle 0 0 10 10) (XRectangle 0 0 10 30)) 2
					 ShapeSet ShapeBounding)
		(let ((newerwin (XCreateWindow dpy win 10 10 100 100 3 
					       CopyFromParent InputOutput (list 'Visual CopyFromParent)
					       (logior CWBackPixel CWBorderPixel)
					       attr)))
		  (XShapeCombineShape dpy newerwin ShapeIntersect 0 0 newwin ShapeSet ShapeClip))
		(let* ((reg1 (XPolygonRegion (list (XPoint 2 2) (XPoint 10 2) (XPoint 10 10) (XPoint 2 10)) 4 WindingRule)))
		  (XShapeCombineRegion dpy newwin ShapeUnion 0 0 reg1 ShapeSet)))))
	
	(let ((classes (list xmArrowButtonWidgetClass xmBulletinBoardWidgetClass xmCascadeButtonWidgetClass xmCommandWidgetClass
			     xmDrawingAreaWidgetClass xmDrawnButtonWidgetClass xmFileSelectionBoxWidgetClass xmFormWidgetClass
			     xmFrameWidgetClass xmLabelWidgetClass xmListWidgetClass xmMainWindowWidgetClass xmManagerWidgetClass
			     xmMessageBoxWidgetClass xmPanedWindowWidgetClass xmPrimitiveWidgetClass xmPushButtonWidgetClass
			     xmRowColumnWidgetClass xmScaleWidgetClass xmScrollBarWidgetClass xmScrolledWindowWidgetClass
			     xmSelectionBoxWidgetClass xmSeparatorWidgetClass xmTextFieldWidgetClass xmTextWidgetClass 
			     xmToggleButtonWidgetClass xmContainerWidgetClass xmComboBoxWidgetClass xmNotebookWidgetClass))
	      (wids '()))
	  (for-each
	   (lambda (class)
	     (let* ((shell (cadr (main-widgets)))
		    (wid (XtCreateWidget "hiho" class shell '())))
	       (set! wids (cons wid wids))
	       (XtAddCallback wid XmNhelpCallback (lambda (w c i) "help!"))))
	   classes)
	  (for-each
	   (lambda (w)
	     (XtCallCallbacks w XmNhelpCallback #f))
	   wids))
	
	(let ((key (XStringToKeysym "Cancel")))
	  (if (not (= (cadr key) XK_Cancel))
	      (snd-display #__line__ ";XStringToKeysym ~A ~A" key XK_Cancel)))
	
	(let* ((win (XtWindow (cadr (main-widgets))))
	       (xm-procs-1
		(list
		 XPutBackEvent XNextEvent
		 XtAppProcessEvent XtAppMainLoop XtAppAddActions XtAppNextEvent XtAppPeekEvent
		 
		 XtSetArg XtManageChildren XtManageChild XtUnmanageChildren XtUnmanageChild
		 XtDispatchEvent XtCallAcceptFocus XtIsSubclass XtIsObject XtIsManaged XtIsRealized
		 XtIsSensitive XtOwnSelection XtOwnSelectionIncremental XtMakeResizeRequest XtTranslateCoords
		 XtKeysymToKeycodeList XtParseTranslationTable XtParseAcceleratorTable XtOverrideTranslations XtAugmentTranslations
		 XtInstallAccelerators XtInstallAllAccelerators XtUninstallTranslations XtAppAddActionHook
		 XtRemoveActionHook XtGetActionList XtCallActionProc XtRegisterGrabAction XtSetMultiClickTime
		 XtGetMultiClickTime XtGetActionKeysym XtTranslateKeycode XtTranslateKey XtSetKeyTranslator
		 XtRegisterCaseConverter XtConvertCase XtAddEventHandler XtRemoveEventHandler XtAddRawEventHandler
		 XtRemoveRawEventHandler XtInsertEventHandler XtInsertRawEventHandler XtDispatchEventToWidget
		 XtBuildEventMask XtAddGrab XtRemoveGrab XtAddExposureToRegion XtSetKeyboardFocus
		 XtGetKeyboardFocusWidget XtLastEventProcessed XtLastTimestampProcessed 
		 XtAppAddTimeOut XtRemoveTimeOut XtAppAddInput XtRemoveInput XtAppPending
		 XtRealizeWidget XtUnrealizeWidget XtSetSensitive XtNameToWidget XtWindowToWidget
		 XtMergeArgLists XtVaCreateArgsList XtDisplay XtDisplayOfObject XtScreen XtScreenOfObject
		 XtWindow XtWindowOfObject XtName XtSuperclass XtClass XtParent XtAddCallback XtRemoveCallback
		 XtAddCallbacks XtRemoveCallbacks XtRemoveAllCallbacks XtCallCallbacks
		 XtHasCallbacks XtCreatePopupShell XtVaCreatePopupShell XtPopup XtPopupSpringLoaded
		 XtCallbackNone XtCallbackNonexclusive XtCallbackExclusive XtPopdown XtCallbackPopdown
		 XtCreateWidget XtCreateManagedWidget XtVaCreateWidget XtVaCreateManagedWidget
		 XtAppCreateShell XtVaAppCreateShell 
		 XtDisplayToApplicationContext 
		 XtSetValues XtVaSetValues XtGetValues XtVaGetValues
		 XtAppSetErrorMsgHandler XtAppSetWarningMsgHandler
		 XtAppErrorMsg XtAppWarningMsg XtAppSetErrorHandler
		 XtAppSetWarningHandler XtAppError
		 XtAppAddWorkProc XtGetGC XtAllocateGC XtDestroyGC XtReleaseGC
		 XtFindFile XtResolvePathname XtDisownSelection XtGetSelectionValue
		 XtGetSelectionValues XtAppSetSelectionTimeout XtAppGetSelectionTimeout
		 XtGetSelectionRequest XtGetSelectionValueIncremental
		 XtGetSelectionValuesIncremental XtCreateSelectionRequest XtSendSelectionRequest
		 XtCancelSelectionRequest XtGrabKey XtUngrabKey
		 XtGrabKeyboard XtUngrabKeyboard XtGrabButton XtUngrabButton XtGrabPointer XtUngrabPointer
		 XtGetApplicationNameAndClass XtGetDisplays XtToolkitThreadInitialize XtAppLock XtAppUnlock XtIsRectObj XtIsWidget
		 XtIsComposite XtIsConstraint XtIsShell XtIsOverrideShell XtIsWMShell XtIsVendorShell
		 XtIsTransientShell XtIsTopLevelShell XtIsApplicationShell XtIsSessionShell XtMapWidget
		 XtUnmapWidget XLoadQueryFont XQueryFont XGetMotionEvents XDeleteModifiermapEntry
		 XGetModifierMapping XInsertModifiermapEntry XNewModifiermap XCreateImage XGetImage
		 XGetSubImage XOpenDisplay XFetchBytes XFetchBuffer XGetAtomName XDisplayName XUniqueContext
		 XKeysymToString XSynchronize XSetAfterFunction XInternAtom XCopyColormapAndFree XCreateColormap
		 XCreatePixmapCursor XCreateGlyphCursor XCreateFontCursor XLoadFont XCreateGC XFlushGC
		 XCreatePixmap XCreateBitmapFromData XCreatePixmapFromBitmapData XCreateSimpleWindow
		 XGetSelectionOwner XCreateWindow XListInstalledColormaps XListFonts XListFontsWithInfo
		 XListExtensions XListProperties XKeycodeToKeysym XLookupKeysym
		 XGetKeyboardMapping ;XStringToKeysym
		 XDisplayMotionBufferSize XVisualIDFromVisual XMaxRequestSize XExtendedMaxRequestSize
		 XRootWindow XDefaultRootWindow XRootWindowOfScreen
		 XDefaultVisual XDefaultVisualOfScreen XDefaultGC XDefaultGCOfScreen XBlackPixel XWhitePixel
		 XAllPlanes XBlackPixelOfScreen XWhitePixelOfScreen XNextRequest XLastKnownRequestProcessed
		 XServerVendor XDisplayString XDefaultColormap XDefaultColormapOfScreen XDisplayOfScreen
		 XScreenOfDisplay XDefaultScreenOfDisplay XEventMaskOfScreen XScreenNumberOfScreen
		 XSetErrorHandler XSetIOErrorHandler XListPixmapFormats XListDepths XReconfigureWMWindow
		 XGetWMProtocols XSetWMProtocols XIconifyWindow XWithdrawWindow XGetCommand XGetWMColormapWindows
		 XSetTransientForHint XActivateScreenSaver
		 XAllocColor XAllocColorCells XAllocColorPlanes XAllocNamedColor
		 XAllowEvents XAutoRepeatOff XAutoRepeatOn XBell XBitmapBitOrder XBitmapPad XBitmapUnit
		 XCellsOfScreen XChangeActivePointerGrab XChangeGC XChangeKeyboardControl XChangeKeyboardMapping
		 XChangePointerControl XChangeProperty XChangeWindowAttributes ; XCheckIfEvent
		 XCheckMaskEvent XCheckTypedEvent XCheckTypedWindowEvent XCheckWindowEvent XCirculateSubwindows
		 XCirculateSubwindowsDown XCirculateSubwindowsUp XClearArea XClearWindow XCloseDisplay
		 XConfigureWindow XConnectionNumber XConvertSelection XCopyArea XCopyGC XCopyPlane XDefaultDepth
		 XDefaultDepthOfScreen XDefaultScreen XDefineCursor XDeleteProperty XDestroyWindow
		 XDestroySubwindows XDoesBackingStore XDoesSaveUnders XDisableAccessControl XDisplayCells
		 XDisplayHeight XDisplayHeightMM XDisplayKeycodes XDisplayPlanes XDisplayWidth XDisplayWidthMM
		 XDrawArc XDrawArcs XDrawImageString XDrawLine XDrawLines XDrawLinesDirect XDrawPoint
		 XDrawPoints XDrawRectangle XDrawRectangles XDrawSegments XDrawString XDrawText
		 XEnableAccessControl XEventsQueued XFetchName XFillArc XFillArcs XFillPolygon XFillRectangle
		 XFillRectangles XFlush XForceScreenSaver XFreeColormap XFreeColors XFreeCursor
		 XFreeExtensionList XFreeFont XFreeFontInfo XFreeFontNames XFreeFontPath XFreeGC
		 XFreeModifiermap XFreePixmap XGeometry XGetErrorText XGetFontProperty
		 XGetGCValues XGCValues XEvent XGetGeometry XGetIconName XGetInputFocus XGetKeyboardControl
		 XGetPointerControl XGetPointerMapping XGetScreenSaver XGetTransientForHint XGetWindowProperty
		 XGetWindowAttributes XGrabButton XGrabKey XGrabKeyboard XGrabPointer XGrabServer
		 XHeightMMOfScreen XHeightOfScreen XIfEvent XImageByteOrder XInstallColormap XKeysymToKeycode
		 XKillClient XLookupColor XLowerWindow XMapRaised XMapSubwindows XMapWindow XMaskEvent
		 XMaxCmapsOfScreen XMinCmapsOfScreen XMoveResizeWindow XMoveWindow XNoOp XParseColor
		 XParseGeometry XPeekEvent XPeekIfEvent XPending XPlanesOfScreen XProtocolRevision
		 XProtocolVersion XPutImage XQLength XQueryBestCursor XQueryBestSize XQueryBestStipple
		 XQueryBestTile XQueryColor XQueryColors XQueryExtension XQueryKeymap XQueryPointer
		 XQueryTextExtents XQueryTree XRaiseWindow XRebindKeysym XRecolorCursor XRefreshKeyboardMapping
		 XReparentWindow XResetScreenSaver XResizeWindow
		 XRestackWindows XRotateBuffers XRotateWindowProperties XScreenCount XSelectInput XSendEvent
		 XSetAccessControl XSetArcMode XSetBackground XSetClipMask XSetClipOrigin XSetClipRectangles
		 XSetCloseDownMode XSetCommand XSetDashes XSetFillRule XSetFillStyle XSetFont XSetFontPath
		 XSetForeground XSetFunction XSetGraphicsExposures XSetIconName XSetInputFocus XSetLineAttributes
		 XSetModifierMapping XSetPlaneMask XSetPointerMapping XSetScreenSaver XSetSelectionOwner
		 XSetState XSetStipple XSetSubwindowMode XSetTSOrigin XSetTile XSetWindowBackground
		 XSetWindowBackgroundPixmap XSetWindowBorder XSetWindowBorderPixmap XSetWindowBorderWidth
		 XSetWindowColormap XStoreBuffer XStoreBytes XStoreColor XStoreColors XStoreName
		 XStoreNamedColor XSync XTextExtents XTextWidth XTranslateCoordinates XUndefineCursor
		 XUngrabButton XUngrabKey XUngrabKeyboard XUngrabPointer XUngrabServer XUninstallColormap
		 XUnloadFont XUnmapSubwindows XUnmapWindow XVendorRelease XWarpPointer XWidthMMOfScreen
		 XWidthOfScreen XWindowEvent XWriteBitmapFile XSupportsLocale XSetLocaleModifiers XCreateFontSet
		 XFreeFontSet XFontsOfFontSet XBaseFontNameListOfFontSet XLocaleOfFontSet XContextDependentDrawing
		 XDirectionalDependentDrawing XContextualDrawing XFilterEvent XAllocIconSize
		 XAllocStandardColormap XAllocWMHints XClipBox XCreateRegion XDefaultString XDeleteContext
		 XDestroyRegion XEmptyRegion XEqualRegion ;XFindContext 
		 XGetIconSizes XGetRGBColormaps
		 XGetVisualInfo XGetWMHints XIntersectRegion XConvertCase XLookupString
		 XMatchVisualInfo XOffsetRegion XPointInRegion XPolygonRegion XRectInRegion XSaveContext
		 XSetRGBColormaps XSetWMHints XSetRegion XShrinkRegion XSubtractRegion
		 XUnionRectWithRegion XUnionRegion XXorRegion DefaultScreen DefaultRootWindow QLength
		 ScreenCount ServerVendor ProtocolVersion ProtocolRevision VendorRelease DisplayString
		 BitmapUnit BitmapBitOrder BitmapPad ImageByteOrder NextRequest LastKnownRequestProcessed
		 DefaultScreenOfDisplay DisplayOfScreen RootWindowOfScreen BlackPixelOfScreen WhitePixelOfScreen
		 DefaultColormapOfScreen DefaultDepthOfScreen DefaultGCOfScreen DefaultVisualOfScreen
		 WidthOfScreen HeightOfScreen WidthMMOfScreen HeightMMOfScreen PlanesOfScreen CellsOfScreen
		 MinCmapsOfScreen MaxCmapsOfScreen DoesSaveUnders DoesBackingStore EventMaskOfScreen RootWindow
		 DefaultVisual DefaultGC BlackPixel WhitePixel DisplayWidth DisplayHeight DisplayWidthMM
		 DisplayHeightMM DisplayPlanes DisplayCells DefaultColormap ScreenOfDisplay DefaultDepth
		 IsKeypadKey IsPrivateKeypadKey IsCursorKey IsPFKey IsFunctionKey IsMiscFunctionKey
		 IsModifierKey XmCreateMessageBox XmCreateMessageDialog XmCreateErrorDialog
		 XmCreateInformationDialog XmCreateQuestionDialog XmCreateWarningDialog XmCreateWorkingDialog
		 XmCreateTemplateDialog XmMessageBoxGetChild XmCreateArrowButtonGadget XmCreateArrowButton
		 XmCreateNotebook XmNotebookGetPageInfo 
		 XmTransferSetParameters XmTransferValue XmCreateComboBox
		 XmCreateDropDownComboBox XmCreateDropDownList XmComboBoxAddItem XmComboBoxDeletePos
		 XmComboBoxSelectItem XmComboBoxSetItem XmComboBoxUpdate XmCreateContainer
		 XmContainerGetItemChildren XmContainerRelayout XmContainerReorder XmContainerCut XmContainerCopy
		 XmContainerPaste XmContainerCopyLink XmContainerPasteLink XmCreateSpinBox
		 XmSpinBoxValidatePosition XmCreateSimpleSpinBox XmSimpleSpinBoxAddItem XmSimpleSpinBoxDeletePos
		 XmSimpleSpinBoxSetItem XmDropSiteRegistered XmTextFieldCopyLink XmTextFieldPasteLink
		 XmTextGetCenterline XmToggleButtonGadgetSetValue XmCreateIconGadget
		 XmCreateIconHeader XmObjectAtPoint XmConvertStringToUnits XmCreateGrabShell
		 XmToggleButtonSetValue XmTextPasteLink XmTextCopyLink XmScaleSetTicks XmInternAtom XmGetAtomName
		 XmCreatePanedWindow XmCreateBulletinBoard XmCreateBulletinBoardDialog XmCreateCascadeButtonGadget
		 XmCascadeButtonGadgetHighlight XmAddProtocols XmRemoveProtocols XmAddProtocolCallback
		 XmRemoveProtocolCallback XmActivateProtocol XmDeactivateProtocol XmSetProtocolHooks
		 XmCreateCascadeButton XmCascadeButtonHighlight XmCreatePushButtonGadget XmCreatePushButton
		 XmCreateCommand XmCommandGetChild XmCommandSetValue XmCommandAppendValue XmCommandError
		 XmCreateCommandDialog XmMenuPosition XmCreateRowColumn XmCreateWorkArea XmCreateRadioBox
		 XmCreateOptionMenu XmOptionLabelGadget XmOptionButtonGadget XmCreateMenuBar XmCreatePopupMenu
		 XmCreatePulldownMenu XmGetPostedFromWidget XmGetTearOffControl 
		 XmScaleSetValue XmScaleGetValue XmCreateScale
		 XmClipboardStartCopy XmClipboardCopy XmClipboardEndCopy XmClipboardCancelCopy
		 XmClipboardWithdrawFormat XmClipboardCopyByName XmClipboardUndoCopy XmClipboardLock
		 XmClipboardUnlock XmClipboardStartRetrieve XmClipboardEndRetrieve XmClipboardRetrieve
		 XmClipboardInquireCount XmClipboardInquireFormat XmClipboardInquireLength
		 XmClipboardInquirePendingItems XmClipboardRegisterFormat XmGetXmScreen XmCreateScrollBar
		 XmScrollBarGetValues XmScrollBarSetValues XmCreateDialogShell 
		 XmCreateScrolledWindow XmScrollVisible XmGetDragContext XmGetXmDisplay XmSelectionBoxGetChild
		 XmCreateSelectionBox XmCreateSelectionDialog XmCreatePromptDialog XmDragStart XmDragCancel
		 XmTargetsAreCompatible XmCreateSeparatorGadget XmCreateDragIcon XmCreateSeparator
		 XmCreateDrawingArea XmCreateDrawnButton XmDropSiteRegister XmDropSiteUnregister
		 XmDropSiteStartUpdate XmDropSiteUpdate XmDropSiteEndUpdate XmDropSiteRetrieve
		 XmDropSiteQueryStackingOrder XmDropSiteConfigureStackingOrder XmDropTransferStart
		 XmDropTransferAdd XmTextFieldGetString XmTextFieldGetSubstring XmTextFieldGetLastPosition
		 XmTextFieldSetString XmTextFieldReplace XmTextFieldInsert XmTextFieldSetAddMode
		 XmTextFieldGetAddMode XmTextFieldGetEditable XmTextFieldSetEditable XmTextFieldGetMaxLength
		 XmTextFieldSetMaxLength XmTextFieldGetCursorPosition XmTextFieldGetInsertionPosition
		 XmTextFieldSetCursorPosition XmTextFieldSetInsertionPosition XmTextFieldGetSelectionPosition
		 XmTextFieldGetSelection XmTextFieldRemove XmTextFieldCopy XmTextFieldCut XmTextFieldPaste
		 XmTextFieldClearSelection XmTextFieldSetSelection XmTextFieldXYToPos XmTextFieldPosToXY
		 XmTextFieldShowPosition XmTextFieldSetHighlight XmTextFieldGetBaseline XmCreateTextField
		 XmFileSelectionBoxGetChild XmFileSelectionDoSearch XmCreateFileSelectionBox
		 XmCreateFileSelectionDialog XmTextSetHighlight XmCreateScrolledText XmCreateText
		 XmTextGetSubstring XmTextGetString XmTextGetLastPosition XmTextSetString XmTextReplace
		 XmTextInsert XmTextSetAddMode XmTextGetAddMode XmTextGetEditable XmTextSetEditable
		 XmTextGetMaxLength XmTextSetMaxLength XmTextGetTopCharacter XmTextSetTopCharacter
		 XmTextGetCursorPosition XmTextGetInsertionPosition XmTextSetInsertionPosition
		 XmTextSetCursorPosition XmTextRemove XmTextCopy XmTextCut XmTextPaste XmTextGetSelection
		 XmTextSetSelection XmTextClearSelection XmTextGetSelectionPosition XmTextXYToPos XmTextPosToXY
		 XmTextGetSource XmTextSetSource XmTextShowPosition XmTextScroll XmTextGetBaseline
		 XmTextDisableRedisplay XmTextEnableRedisplay XmTextFindString XmCreateForm XmCreateFormDialog
		 XmCreateFrame XmToggleButtonGadgetGetState XmToggleButtonGadgetSetState XmCreateToggleButtonGadget
		 XmToggleButtonGetState XmToggleButtonSetState XmCreateToggleButton XmCreateLabelGadget
		 XmCreateLabel XmIsMotifWMRunning XmListAddItem XmListAddItems XmListAddItemsUnselected
		 XmListAddItemUnselected XmListDeleteItem XmListDeleteItems XmListDeletePositions XmListDeletePos
		 XmListDeleteItemsPos XmListDeleteAllItems XmListReplaceItems XmListReplaceItemsPos
		 XmListReplaceItemsUnselected XmListReplaceItemsPosUnselected XmListReplacePositions
		 XmListSelectItem XmListSelectPos XmListDeselectItem XmListDeselectPos XmListDeselectAllItems
		 XmListSetPos XmListSetBottomPos XmListSetItem XmListSetBottomItem XmListSetAddMode
		 XmListItemExists XmListItemPos XmListGetKbdItemPos XmListSetKbdItemPos XmListYToPos
		 XmListPosToBounds XmListGetMatchPos XmListGetSelectedPos XmListSetHorizPos
		 XmListUpdateSelectedList XmListPosSelected XmCreateList XmCreateScrolledList XmTranslateKey
		 XmInstallImage XmUninstallImage XmGetPixmap XmGetPixmapByDepth XmDestroyPixmap XmUpdateDisplay
		 XmWidgetGetBaselines XmRegisterSegmentEncoding XmMapSegmentEncoding
		 XmCvtCTToXmString XmCvtXmStringToCT XmConvertUnits
		 XmCreateSimpleMenuBar XmCreateSimplePopupMenu XmCreateSimplePulldownMenu
		 XmCreateSimpleOptionMenu XmCreateSimpleRadioBox XmCreateSimpleCheckBox XmVaCreateSimpleMenuBar
		 XmVaCreateSimplePopupMenu XmVaCreateSimplePulldownMenu XmVaCreateSimpleOptionMenu
		 XmVaCreateSimpleRadioBox XmVaCreateSimpleCheckBox XmTrackingEvent
		 XmSetColorCalculation XmGetColorCalculation XmGetColors XmChangeColor XmStringCreate
		 XmStringCreateLocalized XmStringDirectionCreate XmStringSeparatorCreate
		 XmStringInitContext
		 XmStringFreeContext 
		 XmStringConcatAndFree XmStringIsVoid XmStringPeekNextTriple XmStringGetNextTriple
		 XmStringComponentCreate XmStringUnparse XmStringParseText XmStringToXmStringTable
		 XmStringTableToXmString XmStringTableUnparse XmStringTableParseStringArray
		 XmDirectionToStringDirection XmStringDirectionToDirection XmStringGenerate XmStringPutRendition
		 XmParseMappingGetValues XmParseMappingFree XmParseTableFree XmStringTableProposeTablist
		 XmTabSetValue XmTabGetValues XmTabFree XmTabCreate XmTabListTabCount XmTabListRemoveTabs
		 XmTabListReplacePositions XmTabListGetTab XmTabListCopy XmTabListInsertTabs
					; XmRenderTableCvtFromProp XmRenderTableCvtToProp XmRenditionUpdate XmRenditionRetrieve
		 XmRenditionFree XmRenditionCreate XmRenderTableGetRenditions XmRenderTableGetRendition
		 XmRenderTableGetTags XmRenderTableFree XmRenderTableCopy XmRenderTableRemoveRenditions
		 XmRenderTableAddRenditions 
		 XmStringEmpty XmStringHasSubstring XmStringFree XmStringBaseline XmStringWidth XmStringHeight
		 XmStringExtent XmStringLineCount XmStringDraw XmStringDrawImage XmStringDrawUnderline
		 XmGetDestination XmIsTraversable XmGetVisibility XmGetTabGroup XmGetFocusWidget
		 XmProcessTraversal XmCreateMenuShell XmIsMessageBox
		 XmIsArrowButtonGadget XmIsArrowButton XmIsNotebook XmIsComboBox XmIsContainer
		 XmIsGrabShell XmIsIconGadget XmIsIconHeader XmIsPanedWindow XmIsBulletinBoard XmIsPrimitive
		 XmIsCascadeButtonGadget XmIsCascadeButton XmIsPushButtonGadget XmIsPushButton XmIsCommand
		 XmIsRowColumn XmIsScale XmIsScreen XmIsScrollBar XmIsDialogShell XmIsScrolledWindow XmIsDisplay
		 XmIsSelectionBox XmIsDragContext XmIsSeparatorGadget XmIsDragIconObjectClass
		 XmIsSeparator XmIsDrawingArea XmIsDrawnButton XmIsDropSiteManager XmIsDropTransfer XmIsTextField
		 XmIsFileSelectionBox XmIsText XmIsForm XmIsFrame XmIsGadget XmIsToggleButtonGadget
		 XmIsToggleButton XmIsLabelGadget XmIsLabel XmIsVendorShell XmIsList XmIsManager
		 XmIsMenuShell XGetPixel XDestroyImage XPutPixel XSubImage XAddPixel
		 XtAppContext? XtRequestId? XtWorkProcId? XtInputId? XtIntervalId? Screen? XEvent?
		 XRectangle? XArc? XPoint? XSegment? XColor? Atom? Colormap?
		 XModifierKeymap? Depth? Display? Drawable? Font? GC? KeySym? Pixel? Pixmap? Region?
		 Time? Visual? Window? XFontProp? XFontSet? XFontStruct? XGCValues? XImage? XVisualInfo?
		 XWMHints? XWindowAttributes? XWindowChanges? KeyCode? XContext? XCharStruct? XTextItem?
		 Widget? XmStringContext? WidgetClass? XmString?
		 XmToggleButton? XmDrawingArea? XmPushButton? XmTextField? XmFileSelectionBox? XmText?
		 XmFrame? XmLabel? XmList? XmArrowButton? XmScrollBar? XmCommand? XmScale? XmRowColumn?
		 XmTab? XmNotebook? XmComboBox? XmContainer? XmIconHeader?
		 XmGrabShell? XmRendition? XmRenderTable? XmIconGadget? XmTabList? XmParseMapping?
		 XmPanedWindow? XmScrolledWindow? XmCascadeButton? XmForm? XmBulletinBoard? XmScreen?
		 XmDialogShell? XmDisplay? XmSelectionBox? XmDragContext? XmDragIconObjectClass? XmSeparator?
		 XmDropSiteManager? XmDropTransfer? XmVendorShell? XmMessageBox? XmManager?
		 XmMenuShell? XmLabelGadget? XmPushButtonGadget? XmSeparatorGadget? XmArrowButtonGadget?
		 XmCascadeButtonGadget? XmToggleButtonGadget? XmDrawnButton? XmPrimitive?
		 XmTextSource? 
		 ))
	       (xm-procs (if (defined? 'XpmImage?)
			     (append xm-procs-1
				     (list 
				      XpmCreatePixmapFromData XpmCreateDataFromPixmap XpmReadFileToPixmap
				      XpmReadPixmapFile XpmWriteFileFromPixmap XpmWritePixmapFile XpmCreatePixmapFromXpmImage
				      XpmCreateXpmImageFromPixmap XpmAttributes? XpmImage? XpmColorSymbol?))
			     xm-procs-1))
	       (xm-procs0 (remove-if (lambda (n) (not (arity-ok n 0))) xm-procs))
	       (xm-procs1 (remove-if (lambda (n) (not (arity-ok n 1))) xm-procs))
	       (xm-procs2 (remove-if (lambda (n) (not (arity-ok n 2))) xm-procs))
	       (xm-procs3 (remove-if (lambda (n) (not (arity-ok n 3))) xm-procs))
	       (xm-procs4 (remove-if (lambda (n) (not (arity-ok n 4))) xm-procs))
	       )
	  
	  ;; ---------------- 0 Args
	  (for-each 
	   (lambda (n)
	     (catch #t
		    (lambda () 
		      (n))
		    (lambda args (car args))))
	   xm-procs0)
	  
	  ;; ---------------- 1 Arg
	  (for-each 
	   (lambda (arg)
	     (for-each 
	      (lambda (n)
		(catch #t
		       (lambda () (n arg))
		       (lambda args (car args))))
	      xm-procs1))
	   (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color-with-catch .95 .95 .95)  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
		 (lambda () #t) (current-environment) (make-sound-data 2 3) :order 0 1 -1 (make-hook 2) #f #t '() (make-vector 0)))
	  
	  ;; ---------------- 2 Args
	  (for-each 
	   (lambda (arg1)
	     (for-each 
	      (lambda (arg2)
		(for-each 
		 (lambda (n)
		   (catch #t
			  (lambda () (n arg1 arg2))
			  (lambda args (car args))))
		 xm-procs2))
	      (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color-with-catch .95 .95 .95) '#(0 1) 3/4 
		    (sqrt -1.0) (make-delay 32) :feedback -1 0 #f #t '() (make-vector 0))))
	   (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color-with-catch .95 .95 .95) '#(0 1) 3/4 
		 (sqrt -1.0) (make-delay 32) :frequency -1 0 #f #t '() (make-vector 0)))
	  
	  (if all-args
	      (begin
		
		;; ---------------- 3 Args
		(for-each 
		 (lambda (arg1)
		   (for-each 
		    (lambda (arg2)
		      (for-each 
		       (lambda (arg3)
			 (for-each 
			  (lambda (n)
			    (catch #t
				   (lambda () (n arg1 arg2 arg3))
				   (lambda args (car args))))
			  xm-procs3))
		       (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) '#(0 1) (sqrt -1.0) (make-delay 32) 
			     :start -1 0 #f #t '() (make-vector 0))))
		    (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) '#(0 1) (sqrt -1.0) (make-delay 32) 
			  :phase -1 0 #f #t '() (make-vector 0))))
		 (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) '#(0 1) (sqrt -1.0) (make-delay 32) 
		       :channels -1 0 #f #t '() (make-vector 0)))
		))
	  
	  (let* ((struct-accessors-1 
		  (list  .pixel .red .green .blue .flags .pad .x .y .width .height .angle1 .angle2 .ptr
			 .x1 .y1 .x2 .y2 .dashes .dash_offset .clip_mask .clip_y_origin .clip_x_origin .graphics_exposures
			 .subwindow_mode .font .ts_y_origin .ts_x_origin .stipple .tile .arc_mode .fill_rule .fill_style
			 .join_style .cap_style .line_style .line_width .background .foreground .plane_mask .function .delta
			 .nchars .chars .name .depth .visual .mwidth .mheight .ndepths .depths .root_depth .root_visual
			 .default_gc .cmap .white_pixel .black_pixel .max_maps .min_maps .backing_store .save_unders .root_input_mask
			 .lbearing .rbearing .ascent .descent .attributes .card32 .fid .properties .min_bounds .max_bounds .per_char
			 .input .initial_state .icon_pixmap .icon_window .icon_x .icon_y .icon_mask .window_group .visualid
			 .class  .red_mask .green_mask .blue_mask .bits_per_rgb .map_entries .nvisuals .visuals .bits_per_pixel
			 .background_pixmap .background_pixel .border_pixmap .border_pixel .bit_gravity .win_gravity .backing_planes
			 .backing_pixel .save_under .event_mask .do_not_propagate_mask .cursor .map_installed .map_state .all_event_masks
			 .your_event_mask .screen .xoffset .byte_order .bitmap_unit .bitmap_bit_order .bitmap_pad .bytes_per_line
			 .obdata .sibling .stack_mode .red_max .red_mult .green_max .green_mult .blue_max .blue_mult .base_pixel
			 .killid .data .min_height .max_height .min_width .max_width .height_inc .width_inc .page_number
			 .page_widget .status_area_widget .major_tab_widget .minor_tab_widget .source_data .location_data .parm
			 .parm_format .parm_length .parm_type .transfer_id .destination_data .remaining .item_or_text .auto_selection_type
			 .new_outline_state .prev_page_number .prev_page_widget .rendition .render_table 
					;			    .last_page 
			 .crossed_boundary
			 .client_data .status .font_name .tag .traversal_destination .dragProtocolStyle .direction .reason
			 .timeStamp .operation .operations .dropSiteStatus .dropAction .iccHandle .completionStatus .dragContext
			 .animate .length .click_count .widget .item_position .callbackstruct
			 .set .item .item_length .selected_items .selected_item_count .selected_item_positions .selection_type
			 .mask .mask_length .dir .dir_length .pattern .pattern_length .position .currInsert .newInsert .startPos
			 .endPos .text .request_code .error_code .first_keycode .request .resourceid .format .message_type .new
			 .property .display .target .requestor .owner .selection .atom .place .value_mask .above .from_configure
			 .event .override_redirect .border_width .parent .minor_code .major_code .drawable .count .key_vector .focus
			 .detail .mode .is_hint .button .same_screen .keycode .state .y_root .x_root .root .time .subwindow .window
			 .send_event .serial .type .value .doit .colormap .menuToPost .postIt))
		 (struct-accessors (if (defined? 'XpmImage?)
				       (append struct-accessors-1
					       (list .valuemask .ncolors .cpp .numsymbols .colorsymbols .npixels 
						     .y_hotspot .x_hotspot .colormap_size))
				       struct-accessors-1))
		 
		 (struct-accessor-names-1
		  (list  '.pixel '.red '.green '.blue '.flags '.pad '.x '.y '.width '.height '.angle1 '.angle2 '.ptr
			 '.x1 '.y1 '.x2 '.y2 '.dashes '.dash_offset '.clip_mask '.clip_y_origin '.clip_x_origin '.graphics_exposures
			 '.subwindow_mode '.font '.ts_y_origin '.ts_x_origin '.stipple '.tile '.arc_mode '.fill_rule '.fill_style
			 '.join_style '.cap_style '.line_style '.line_width '.background '.foreground '.plane_mask '.function '.delta
			 '.nchars '.chars '.name '.depth '.visual '.mwidth '.mheight '.ndepths '.depths '.root_depth '.root_visual
			 '.default_gc '.cmap '.white_pixel '.black_pixel '.max_maps '.min_maps '.backing_store '.save_unders '.root_input_mask
			 '.lbearing '.rbearing '.ascent '.descent '.attributes '.card32 '.fid '.properties '.min_bounds '.max_bounds '.per_char
			 '.input '.initial_state '.icon_pixmap '.icon_window '.icon_x '.icon_y '.icon_mask '.window_group '.visualid
			 '.class  '.red_mask '.green_mask '.blue_mask '.bits_per_rgb '.map_entries '.nvisuals '.visuals '.bits_per_pixel
			 '.background_pixmap '.background_pixel '.border_pixmap '.border_pixel '.bit_gravity '.win_gravity '.backing_planes
			 '.backing_pixel '.save_under '.event_mask '.do_not_propagate_mask '.cursor '.map_installed '.map_state '.all_event_masks
			 '.your_event_mask '.screen '.xoffset '.byte_order '.bitmap_unit '.bitmap_bit_order '.bitmap_pad '.bytes_per_line
			 '.obdata '.sibling '.stack_mode '.red_max '.red_mult '.green_max '.green_mult '.blue_max '.blue_mult '.base_pixel
			 '.killid '.data '.min_height '.max_height '.min_width '.max_width '.height_inc '.width_inc '.page_number
			 '.page_widget '.status_area_widget '.major_tab_widget '.minor_tab_widget '.source_data '.location_data '.parm
			 '.parm_format '.parm_length '.parm_type '.transfer_id '.destination_data '.remaining '.item_or_text '.auto_selection_type
			 '.new_outline_state '.prev_page_number '.prev_page_widget '.rendition '.render_table 
					;			    '.last_page 
			 '.crossed_boundary
			 '.client_data '.status '.font_name '.tag '.traversal_destination '.dragProtocolStyle '.direction '.reason
			 '.timeStamp '.operation '.operations '.dropSiteStatus '.dropAction '.iccHandle '.completionStatus '.dragContext
			 '.animate '.length '.click_count '.widget '.item_position '.callbackstruct
			 '.set '.item '.item_length '.selected_items '.selected_item_count '.selected_item_positions '.selection_type
			 '.mask '.mask_length '.dir '.dir_length '.pattern '.pattern_length '.position '.currInsert '.newInsert '.startPos
			 '.endPos '.text '.request_code '.error_code '.first_keycode '.request '.resourceid '.format '.message_type '.new
			 '.property '.display '.target '.requestor '.owner '.selection '.atom '.place '.value_mask '.above '.from_configure
			 '.event '.override_redirect '.border_width '.parent '.minor_code '.major_code '.drawable '.count '.key_vector '.focus
			 '.detail '.mode '.is_hint '.button '.same_screen '.keycode '.state '.y_root '.x_root '.root '.time '.subwindow '.window
			 '.send_event '.serial '.type '.value '.doit '.colormap '.menuToPost '.postIt))
		 (struct-accessor-names (if (defined? 'XpmImage?)
					    (append struct-accessor-names-1
						    (list '.valuemask '.ncolors '.cpp
							  '.numsymbols '.colorsymbols '.npixels '.y_hotspot '.x_hotspot '.colormap_size))
					    struct-accessor-names-1))
		 (dpy (XtDisplay (cadr (main-widgets))))
		 (win (XtWindow (cadr (main-widgets)))))
	    
	    ;; ---------------- 0 Args
	    (for-each 
	     (lambda (n name)
	       (let ((tag
		      (catch #t
			     (lambda () 
			       (n))
			     (lambda args (car args)))))
		 (if (not (eq? tag 'wrong-number-of-args))
		     (snd-display #__line__ ";(~A) -> ~A" name tag)))
	       (if (procedure-with-setter? n)
		   (let ((tag
			  (catch #t
				 (lambda () 
				   (set! (n) 0))
				 (lambda args (car args)))))
		     (if (not (eq? tag 'wrong-number-of-args))
			 (snd-display #__line__ ";(~A) -> ~A" name tag)))))
	     struct-accessors
	     struct-accessor-names)
	    
	    ;; ---------------- 1 Arg
	    (for-each 
	     (lambda (arg)
	       (for-each 
		(lambda (n name)
		  (let ((tag 
			 (catch #t
				(lambda () (n arg))
				(lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg))
			(snd-display #__line__ ";(~A ~A) -> ~A" name arg tag)))
		  (if (procedure-with-setter? n)
		      (begin
			(let ((tag 
			       (catch #t
				      (lambda () (set! (n arg) 0))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display #__line__ ";(~A ~A) -> ~A" name arg tag)))
			(let ((tag 
			       (catch #t
				      (lambda () (set! (n 0) arg))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display #__line__ ";(set ~A ~A) -> ~A" name arg tag))))))
		struct-accessors
		struct-accessor-names))
	     (list dpy win '(Atom 0) '(Colormap 0) 1.5 "/hiho" 1234 #f #\c '(Time 0) '(Font 0) (make-vector 0) '(Cursor 1))))
	  )
	(show-sounds-in-directory)
					;(show-all-atoms)
	)))



;;; ---------------- test 26: Gtk --------------------

#|
;;; until cairo connection, this is useless
(if (and (provided? 'snd-gtk)
	 (provided? 'cairo)
	 (provided? 'xg))
    (define (gtk-print-test)
      (let* ((operation (gtk_print_operation_new)))
	
	(g_signal_connect operation "begin-print" (lambda (op context user-data)
						    (let ((height (gtk_print_context_get_height (GTK_PRINT_CONTEXT context))))
						      (display (format #f "begin height: ~A" height))
						      (gtk_print_operation_set_n_pages (GTK_PRINT_OPERATION op) 1)))
			  #f)
	
	(g_signal_connect operation "draw-page" (lambda (op context page user-data)
						  ;; cairo is necessary to get output
						  #f)
			  #f)
	
	(g_signal_connect operation "end-print" (lambda (op context user-data)
						  (display (format #f "all done")))
			  #f)
	
	(let ((error (gtk_print_operation_run operation GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG (GTK_WINDOW (cadr (main-widgets))))))
	  (display error)
	  )
	
	(g_object_unref (GPOINTER operation))))
    )
|#

(define (snd_test_26)
  (begin
    
    (if (and (provided? 'snd-gtk)
	     (provided? 'xg))
	(let ((ind (open-sound "oboe.snd")))
	  (if (not (GTK_IS_WIDGET (cadr (main-widgets)))) (snd-display #__line__ ";GTK_IS_WIDGET?"))
	  ;; all gtk proc names are in gtk-procs.scm
	  (if (not (GTK_IS_ENTRY (list-ref (sound-widgets) 3))) (snd-display #__line__ ";GTK_IS_ENTRY?"))
	  
	  (let* ((win (car (main-widgets)))
		 (vals (gdk_property_get win (gdk_atom_intern "SND_VERSION" #f) GDK_TARGET_STRING 0 1024 0))
		 (str (list-ref vals 4)))
	    (if (or (not str) 
		    (not (string=? (snd-version) str)))
		(snd-display #__line__ ";SND_VERSION: ~A ~A" str (snd-version))))
	  (if (not (string=? "STRING" (gdk_atom_name GDK_TARGET_STRING)))
	      (snd-display #__line__ ";gdk_atom_name: ~A" (gdk_atom_name GDK_TARGET_STRING)))
	  
	  (close-sound ind)
	  
	  (for-each
	   (lambda (data)
	     (let* ((creator (car data))
		    (checker (cadr data))
		    (name (caddr data))
		    (w (creator)))
	       (if (not (checker w)) (snd-display #__line__ ";~A: ~A?" name w))))
	   (list
	    (list (lambda () (gtk_vbox_new #t 0)) GTK_IS_VBOX 'GTK_IS_VBOX)
	    (list gtk_accel_group_new GTK_IS_ACCEL_GROUP 'GTK_IS_ACCEL_GROUP)
	    (list (lambda () (gtk_accel_label_new "hiho")) GTK_IS_ACCEL_LABEL 'GTK_IS_ACCEL_LABEL)
	    (list (lambda () (gtk_adjustment_new 1.0 0.0 2.0 .1 .1 .1)) GTK_IS_ADJUSTMENT 'GTK_IS_ADJUSTMENT)
	    (list (lambda () (gtk_alignment_new 0.0 0.0 1.0 1.0)) GTK_IS_ALIGNMENT 'GTK_IS_ALIGNMENT)
	    (list (lambda () (gtk_arrow_new GTK_ARROW_UP GTK_SHADOW_IN)) GTK_IS_ARROW 'GTK_IS_ARROW)
	    (list (lambda () (gtk_aspect_frame_new "hi" 1.0 1.0 1.0 #f)) GTK_IS_ASPECT_FRAME 'GTK_IS_ASPECT_FRAME)
	    (list (lambda () (gtk_button_new_with_label "hi")) GTK_IS_BUTTON 'GTK_IS_BUTTON)
	    (list gtk_calendar_new GTK_IS_CALENDAR 'GTK_IS_CALENDAR)
	    (list gtk_check_button_new GTK_IS_CHECK_BUTTON 'GTK_IS_CHECK_BUTTON)
	    (list gtk_check_menu_item_new GTK_IS_CHECK_MENU_ITEM 'GTK_IS_CHECK_MENU_ITEM)
	    (list (lambda () (gtk_color_selection_dialog_new "hi")) GTK_IS_COLOR_SELECTION_DIALOG 'GTK_IS_COLOR_SELECTION_DIALOG)
	    (list gtk_color_selection_new GTK_IS_COLOR_SELECTION 'GTK_IS_COLOR_SELECTION)
	    (list gtk_dialog_new GTK_IS_DIALOG 'GTK_IS_DIALOG)
	    (list gtk_drawing_area_new GTK_IS_DRAWING_AREA 'GTK_IS_DRAWING_AREA)
	    (list gtk_entry_new GTK_IS_ENTRY 'GTK_IS_ENTRY)
	    (list gtk_event_box_new GTK_IS_EVENT_BOX 'GTK_IS_EVENT_BOX)
	    (list gtk_fixed_new GTK_IS_FIXED 'GTK_IS_FIXED)
	    (list gtk_font_selection_new GTK_IS_FONT_SELECTION 'GTK_IS_FONT_SELECTION)
	    (list (lambda () (gtk_font_selection_dialog_new "hi")) GTK_IS_FONT_SELECTION_DIALOG 'GTK_IS_FONT_SELECTION_DIALOG)
	    (list (lambda () (gtk_frame_new "hi")) GTK_IS_FRAME 'GTK_IS_FRAME)
	    (list gtk_handle_box_new GTK_IS_HANDLE_BOX 'GTK_IS_HANDLE_BOX)
	    (list gtk_hbutton_box_new GTK_IS_HBUTTON_BOX 'GTK_IS_HBUTTON_BOX)
	    (list (lambda () (gtk_hbox_new #f 0)) GTK_IS_HBOX 'GTK_IS_HBOX)
	    (list gtk_hpaned_new GTK_IS_HPANED 'GTK_IS_HPANED)
	    (list gtk_hruler_new GTK_IS_HRULER 'GTK_IS_HRULER)
	    (list gtk_hseparator_new GTK_IS_HSEPARATOR 'GTK_IS_HSEPARATOR)
	    (list gtk_icon_factory_new GTK_IS_ICON_FACTORY 'GTK_IS_ICON_FACTORY)
	    (list gtk_image_new GTK_IS_IMAGE 'GTK_IS_IMAGE)
	    (list gtk_image_menu_item_new GTK_IS_IMAGE_MENU_ITEM 'GTK_IS_IMAGE_MENU_ITEM)
	    (list gtk_im_context_simple_new GTK_IS_IM_CONTEXT_SIMPLE 'GTK_IS_IM_CONTEXT_SIMPLE)
	    (list gtk_im_multicontext_new GTK_IS_IM_MULTICONTEXT 'GTK_IS_IM_MULTICONTEXT)
	    (list gtk_invisible_new GTK_IS_INVISIBLE 'GTK_IS_INVISIBLE)
	    (list (lambda () (gtk_label_new "hi")) GTK_IS_LABEL 'GTK_IS_LABEL)
	    (list gtk_menu_bar_new GTK_IS_MENU_BAR 'GTK_IS_MENU_BAR)
	    (list gtk_menu_new GTK_IS_MENU 'GTK_IS_MENU)
	    (list gtk_menu_item_new GTK_IS_MENU_ITEM 'GTK_IS_MENU_ITEM)
	    (list gtk_notebook_new GTK_IS_NOTEBOOK 'GTK_IS_NOTEBOOK)
	    (list gtk_progress_bar_new GTK_IS_PROGRESS_BAR 'GTK_IS_PROGRESS_BAR)
	    (list gtk_rc_style_new GTK_IS_RC_STYLE 'GTK_IS_RC_STYLE)
	    (list gtk_separator_menu_item_new GTK_IS_SEPARATOR_MENU_ITEM 'GTK_IS_SEPARATOR_MENU_ITEM)
	    (list gtk_socket_new GTK_IS_SOCKET 'GTK_IS_SOCKET)
	    (list (lambda () (gtk_spin_button_new_with_range 0.0 20.0 1.0)) GTK_IS_SPIN_BUTTON 'GTK_IS_SPIN_BUTTON)
	    (list gtk_statusbar_new GTK_IS_STATUSBAR 'GTK_IS_STATUSBAR)
	    (list gtk_style_new GTK_IS_STYLE 'GTK_IS_STYLE)
	    (list (lambda () (gtk_table_new 2 2 #t)) GTK_IS_TABLE 'GTK_IS_TABLE)
	    (list gtk_tearoff_menu_item_new GTK_IS_TEAROFF_MENU_ITEM 'GTK_IS_TEAROFF_MENU_ITEM)
	    (list gtk_text_tag_table_new GTK_IS_TEXT_TAG_TABLE 'GTK_IS_TEXT_TAG_TABLE)
	    (list gtk_text_view_new GTK_IS_TEXT_VIEW 'GTK_IS_TEXT_VIEW)
	    (list gtk_toggle_button_new GTK_IS_TOGGLE_BUTTON 'GTK_IS_TOGGLE_BUTTON)
	    (list gtk_toolbar_new GTK_IS_TOOLBAR 'GTK_IS_TOOLBAR)
	    (list gtk_tree_view_column_new GTK_IS_TREE_VIEW_COLUMN 'GTK_IS_TREE_VIEW_COLUMN)
	    (list gtk_tree_view_new GTK_IS_TREE_VIEW 'GTK_IS_TREE_VIEW)
	    (list gtk_vbutton_box_new GTK_IS_VBUTTON_BOX 'GTK_IS_VBUTTON_BOX)
	    (list gtk_vpaned_new GTK_IS_VPANED 'GTK_IS_VPANED)
	    (list gtk_vruler_new GTK_IS_VRULER 'GTK_IS_VRULER)
	    (list gtk_vseparator_new GTK_IS_VSEPARATOR 'GTK_IS_VSEPARATOR)))
	  
	  (let ((_gchar_ (gdk_set_locale)))
	    (let ((_gchar1_ (gtk_set_locale)))
	      (if (not (string=? _gchar_ _gchar1_))
		  (snd-display #__line__ ";*-set-locale: ~A ~A" _gchar_ _gchar1_))))
	  (let ((_char_ (gdk_get_program_class)))
	    (if (or (not (string? _char_))
		    (not (string=? _char_ "Snd")))
		(snd-display #__line__ ";get program class: ~A" _char_))
	    (gdk_set_program_class "Hiho")
	    (if (not (string=? (gdk_get_program_class) "Hiho")) (snd-display #__line__ ";set program class: ~A" (gdk_get_program_class)))
	    (gdk_set_program_class "Snd"))
	  (if (not (string=? (gdk_get_display) ":0.0")) (snd-display #__line__ ";gdk_get_display: ~A" (gdk_get_display)))
	  (if (not (= (gdk_screen_width) 2560)) (snd-display #__line__ ";gdk_screen_width: ~A" (gdk_screen_width)))
	  (if (not (= (gdk_screen_width_mm) 644)) (snd-display #__line__ ";gdk_screen_width_mm: ~A" (gdk_screen_width_mm)))
	  (if (not (= (gdk_screen_height) 1600)) (snd-display #__line__ ";gdk_screen_height: ~A" (gdk_screen_height)))
	  (if (not (= (gdk_screen_height_mm) 402)) (snd-display #__line__ ";gdk_screen_height_mm: ~A" (gdk_screen_height_mm)))
	  (gdk_beep)
	  (if (not (gtk_true)) (snd-display #__line__ ";gtk_true: ~A" (gtk_true)))
	  (if (gtk_false) (snd-display #__line__ ";gtk_false: ~A" (gtk_false)))
	  (if (gdk_pointer_is_grabbed) (snd-display #__line__ ";gdk_pointer_is_grabbed?"))
	  (if (not (gdk_list_visuals)) (snd-display #__line__ ";gdk_list_visuals?"))
	  (if (not (gtk_window_list_toplevels)) (snd-display #__line__ ";gtk_window_list_toplevels?"))
	  (gtk_window_set_default_icon_list (gtk_window_get_default_icon_list))
	  (if (gdk_rgb_ditherable) (snd-display #__line__ ";rgb ditherable?"))
	  (if (not (= (gdk_visual_get_best_depth) 32)) (snd-display #__line__ ";best depth: ~A" (gdk_visual_get_best_depth)))
	  (if (not (string=? (gtk_rc_get_theme_dir) "/usr/local/share/themes")) (snd-display #__line__ ";theme dir: ~A" (gtk_rc_get_theme_dir)))
	  (if (and (not (string=? (gtk_rc_get_module_dir) "/usr/local/lib/gtk-2.0/2.4.0/engines")) 
		   (not (string=? (gtk_rc_get_module_dir) "/usr/local/lib/gtk-2.0/2.10.0/engines")))
	      (snd-display #__line__ ";module dir: ~A" (gtk_rc_get_module_dir)))
	  (if (not (string? (gtk_rc_get_im_module_path))) (snd-display #__line__ ";module path: ~A" (gtk_rc_get_im_module_path)))
	  (if (not (string=? (gtk_rc_get_im_module_file) "/usr/local/etc/gtk-2.0/gtk.immodules")) 
	      (snd-display #__line__ ";module file: ~A" (gtk_rc_get_im_module_path)))
	  (let* ((_gchar__ (gtk_rc_get_default_files))
		 (files (c-array->list _gchar__ #f)))
	    (if (or (not (= (length files) 2))
		    (not (string? (car files))))
		(snd-display #__line__ ";gtk rc def files: ~A" files)))
	  (if (not (gtk_get_default_language)) (snd-display #__line__ ";def lang: ~A" (gtk_get_default_language)))
	  
	  (let* ((_GdkColormap_ (gdk_colormap_get_system))
		 (_GdkVisual_ (gdk_colormap_get_visual _GdkColormap_))
		 (_GdkColormap1_ (gdk_rgb_get_colormap))
		 (_GdkColormap2_ (gtk_widget_get_default_colormap))
		 (_GdkVisual9_ (gdk_rgb_get_visual))
		 (_GdkVisual1_ (gdk_visual_get_system))
		 (_GdkVisual2_ (gdk_visual_get_best))
		 (_GdkVisual3_ (gtk_widget_get_default_visual))
		 (_GdkVisualType (gdk_visual_get_best_type))
		 (_GdkScreen_ (gdk_screen_get_default))
		 (_GdkDisplay_ (gdk_display_get_default))
		 (_GdkWindow_ (gdk_screen_get_root_window _GdkScreen_))
		 (_GdkDisplay1_ (gdk_screen_get_display _GdkScreen_))
		 (_GdkVisual4_ (gdk_visual_get_best_with_type _GdkVisualType))
		 (_GdkColormap3_ (gdk_screen_get_default_colormap _GdkScreen_))
		 (_GdkColormap4_ (gdk_screen_get_system_colormap _GdkScreen_))
		 (_GdkColormap5_ (gdk_screen_get_rgb_colormap _GdkScreen_))
		 (_gint 24)
		 (_GdkVisual5_ (gdk_visual_get_best_with_depth _gint))
		 (_gboolean #f)
		 (_GdkColormap6_ (gdk_colormap_new _GdkVisual_ _gboolean))
		 (_GdkVisual6_ (gdk_screen_get_system_visual _GdkScreen_))
		 (_GdkVisual7_ (gdk_screen_get_rgb_visual _GdkScreen_))
		 (_GdkScreen1_ (gdk_display_get_default_screen _GdkDisplay_))
		 (_GdkVisual8_ (gdk_visual_get_best_with_both _gint _GdkVisualType))
		 (_gchar_ (gdk_display_get_name _GdkDisplay_))
		 (_int (gdk_display_get_n_screens _GdkDisplay_))
		 (_gboolean1 (gdk_display_pointer_is_grabbed _GdkDisplay_))
		 (_int1 (gdk_screen_get_number _GdkScreen_))
		 (_int2 (gdk_screen_get_width _GdkScreen_))
		 (_int3 (gdk_screen_get_height _GdkScreen_))
		 (_int4 (gdk_screen_get_width_mm _GdkScreen_))
		 (_int5 (gdk_screen_get_height_mm _GdkScreen_))
		 (_GList_ (gdk_screen_list_visuals _GdkScreen_))
		 (_GList1_ (gdk_screen_get_toplevel_windows _GdkScreen_))
		 (_gchar1_ (gdk_screen_make_display_name _GdkScreen_))
		 (_int6 (gdk_screen_get_n_monitors _GdkScreen_))
;		 (_GList2_ (gdk_display_list_devices _GdkDisplay_))
		 (_guint (gdk_display_get_default_cursor_size _GdkDisplay_))
		 (_GtkWidget_ (gtk_check_button_new))
		 (_GdkColormap7_ (gtk_widget_get_colormap _GtkWidget_))
		 (_GdkWindow1_ (gdk_get_default_root_window))
		 (_GdkWindow2_ (gtk_widget_get_root_window _GtkWidget_))
		 (_GdkDrawable_ (GDK_DRAWABLE _GdkWindow_))
		 (_GdkGC_ (gdk_gc_new _GdkDrawable_))
		 (_GdkColormap8_ (gdk_drawable_get_colormap _GdkDrawable_))
		 (_GdkColormap9_ (gdk_gc_get_colormap _GdkGC_))
		 
		 )
	    (if (or (not (equal? _GdkColormap_ _GdkColormap1_)) (not (equal? _GdkColormap_ _GdkColormap2_)) (not (equal? _GdkColormap_ _GdkColormap3_)) 
		    (not (equal? _GdkColormap_ _GdkColormap4_)) (not (equal? _GdkColormap_ _GdkColormap5_)) (not (equal? _GdkColormap_ _GdkColormap7_)) 
		    (not (equal? _GdkColormap_ _GdkColormap8_)) (not (equal? _GdkColormap_ _GdkColormap9_)))
		(snd-display #__line__ ";colormaps not equal"))
	    (if (or (not (equal? _GdkVisual_ _GdkVisual1_)) (not (equal? _GdkVisual_ _GdkVisual3_)) (not (equal? _GdkVisual_ _GdkVisual9_)) 
		    (not (equal? _GdkVisual_ _GdkVisual6_)) (not (equal? _GdkVisual_ _GdkVisual7_)))
		(snd-display #__line__ ";visuals not equal"))
	    (if (not (= _GdkVisualType 5)) (snd-display #__line__ ";visual type: ~A" _GdkVisualType))
	    (if (not (equal? _GdkScreen_ _GdkScreen1_)) (snd-display #__line__ ";screens not equal"))
	    (if (not (equal? _GdkDisplay_ _GdkDisplay1_)) (snd-display #__line__ ";displays not equal"))
	    (if (not (= _gint 24)) (snd-display #__line__ ";_gint: ~A" _gint))
	    (if (not (= _int 1)) (snd-display #__line__ ";_int: ~A" _int))
	    (if (not (= _int1 0)) (snd-display #__line__ ";_int1: ~A" _int1))
	    (if (not (= _int2 2560)) (snd-display #__line__ ";_int2: ~A" _int2))
	    (if (not (= _int3 1600)) (snd-display #__line__ ";_int3: ~A" _int3))
	    (if (not (= _int4 644)) (snd-display #__line__ ";_int4: ~A" _int4))
	    (if (not (= _int5 402)) (snd-display #__line__ ";_int5: ~A" _int5))
	    (if (not (= _int6 1)) (snd-display #__line__ ";_int6: ~A" _int6))
	    (if (or (not (equal? _GdkWindow_ _GdkWindow2_)) (not (equal? _GdkWindow1_ _GdkWindow2_))) (snd-display #__line__ ";windows not equal"))
	    (if (not (string=? _gchar_ ":0.0")) (snd-display #__line__ ";_gchar: ~A" _gchar_))
	    (if _gboolean (snd-display #__line__ ";_gboolean: ~A" _gboolean))
	    (if _gboolean1 (snd-display #__line__ ";_gboolean1: ~A" _gboolean1))
	    (if (not (= _guint 18)) (snd-display #__line__ ";_giunt: ~A" _guint))
	    (if (not (GDK_IS_COLORMAP _GdkColormap6_)) (snd-display #__line__ ";not colormap6: ~A" _GdkColormap6_))
	    (if (not (GTK_IS_WIDGET _GtkWidget_)) (snd-display #__line__ ";not widget: ~A" _GtkWidget_))
	    (if (not (GDK_IS_DRAWABLE _GdkDrawable_)) (snd-display #__line__ ";not drawable: ~A" _GdkDrawable_))
	    (if (not (GDK_IS_GC _GdkGC_)) (snd-display #__line__ ";not gc: ~A" _GdkGC_))
	    (if (not (GDK_IS_VISUAL _GdkVisual_)) (snd-display #__line__ ";not visual: ~A" _GdkVisual_))
	    (if (not (GDK_IS_SCREEN _GdkScreen_)) (snd-display #__line__ ";not screen: ~A" _GdkScreen_))
	    (if (not (GDK_IS_DISPLAY _GdkDisplay_)) (snd-display #__line__ ";not display: ~A" _GdkDisplay_))
	    (if (not (GDK_IS_WINDOW _GdkWindow_)) (snd-display #__line__ ";not window: ~A" _GdkWindow_))
	    (let ((types (gdk_query_visual_types)))
	      (if (not (member _GdkVisualType (c-array->list (car types) (cadr types))))
		  (snd-display #__line__ ";visuals: ~A and ~A" _GdkVisualType types)))
	    (let ((depths (gdk_query_depths)))
	      (if (not (member _gint (c-array->list (car depths) (cadr depths))))
		  (snd-display #__line__ ";depths: ~A and ~A" _gint depths)))
	    )
	  
	  (let* ((_GtkButton_ (GTK_BUTTON (gtk_button_new)))
		 (_gchar_ "hiho")
		 (_GtkWidget1_ (gtk_button_new_with_label _gchar_))
		 (_GtkWidget2_ (gtk_button_new_from_stock GTK_STOCK_CANCEL))
		 (_GtkWidget3_ (gtk_button_new_with_mnemonic "A"))
		 (_GtkReliefStyle (gtk_button_get_relief _GtkButton_))
		 (_gchar1_ (gtk_button_get_label (GTK_BUTTON _GtkWidget1_)))
		 (_gboolean (gtk_button_get_use_underline _GtkButton_))
		 (_gboolean1 (gtk_button_get_use_stock _GtkButton_))
		 (_gboolean2 (gtk_button_get_focus_on_click _GtkButton_))
		 (_GtkWidget4_ (gtk_check_button_new))
		 (_GtkWidget5_ (gtk_check_button_new_with_label "a label"))
		 (_GtkWidget6_ (gtk_check_button_new_with_mnemonic "A")))
	    (gtk_widget_show (GTK_WIDGET _GtkButton_))
	    (if (not (string=? _gchar1_ "hiho")) (snd-display #__line__ ";gtk button label: ~A" _gchar1_))
	    (if _gboolean (snd-display #__line__ ";button underline"))
	    (if _gboolean1 (snd-display #__line__ ";button use stock"))
	    (if (not _gboolean2) (snd-display #__line__ ";button focus on click"))
	    (if (not (= _GtkReliefStyle GTK_RELIEF_NORMAL)) (snd-display #__line__ ";button relief: ~A" _GtkReliefStyle))
	    (let ((align (gtk_button_get_alignment _GtkButton_)))
	      (if (or (fneq (car align) 0.5) (fneq (cadr align) 0.5)) (snd-display #__line__ ";button align: ~A" align)))
	    ;; presumably these are explicit callbacks (out 2.19)
	    ;; (gtk_button_pressed _GtkButton_)
	    ;; (gtk_button_released _GtkButton_)
	    ;; (gtk_button_clicked _GtkButton_)
	    ;; (gtk_button_enter _GtkButton_)
	    ;; (gtk_button_leave _GtkButton_)
	    (gtk_button_set_relief _GtkButton_ GTK_RELIEF_NONE)
	    (gtk_button_set_label _GtkButton_ "label")
	    (gtk_button_set_use_underline _GtkButton_ #t)
	    (gtk_button_set_use_stock _GtkButton_ #t)
	    (gtk_button_set_focus_on_click _GtkButton_ #f)
	    (gtk_button_set_alignment _GtkButton_ 0.2 0.75)
	    (if (not (string=? (gtk_button_get_label _GtkButton_) "label")) (snd-display #__line__ ";set gtk button label: ~A" _gchar1_))
	    (if (not (gtk_button_get_use_underline _GtkButton_)) (snd-display #__line__ ";set button underline"))
	    (if (not (gtk_button_get_use_stock _GtkButton_)) (snd-display #__line__ ";set button use stock"))
	    (if (gtk_button_get_focus_on_click _GtkButton_) (snd-display #__line__ ";set button focus on click"))
	    (if (not (= (gtk_button_get_relief _GtkButton_) GTK_RELIEF_NONE)) (snd-display #__line__ ";button relief: ~A" (gtk_button_get_relief _GtkButton_)))
	    (let ((align (gtk_button_get_alignment _GtkButton_)))
	      (if (or (fneq (car align) 0.2) (fneq (cadr align) 0.75)) (snd-display #__line__ ";set button align: ~A" align)))
	    (gtk_widget_hide (GTK_WIDGET _GtkButton_))
	    (gtk_widget_destroy (GTK_WIDGET _GtkButton_)))
	  
	  (let* ((_GtkToggleButton_ (GTK_TOGGLE_BUTTON (gtk_toggle_button_new)))
		 (_GtkWidget_ (gtk_toggle_button_new_with_label "hiho"))
		 (_GtkWidget1_ (gtk_toggle_button_new_with_mnemonic "A"))
		 (_gboolean (gtk_toggle_button_get_mode _GtkToggleButton_))
		 (_gboolean1 (gtk_toggle_button_get_active _GtkToggleButton_))
		 (_gboolean2 (gtk_toggle_button_get_inconsistent _GtkToggleButton_)))
	    (if _gboolean (snd-display #__line__ ";toggle mode"))
	    (if _gboolean1 (snd-display #__line__ ";toggle active"))
	    (if _gboolean2 (snd-display #__line__ ";toggle inconsistent"))
	    (gtk_toggle_button_toggled _GtkToggleButton_)
	    (gtk_toggle_button_set_mode _GtkToggleButton_ #t)
	    (gtk_toggle_button_set_active _GtkToggleButton_ #t)
	    (gtk_toggle_button_set_inconsistent _GtkToggleButton_ #t)
	    (if (not (gtk_toggle_button_get_mode _GtkToggleButton_)) (snd-display #__line__ ";set toggle mode"))
	    (if (not (gtk_toggle_button_get_mode _GtkToggleButton_)) (snd-display #__line__ ";set toggle active"))
	    (if (not (gtk_toggle_button_get_mode _GtkToggleButton_)) (snd-display #__line__ ";set toggle inconsistent")))
	  
	  (let* ((_GtkLabel_ (GTK_LABEL (gtk_label_new "hiho")))
		 (_GtkWidget_ (gtk_label_new_with_mnemonic "A"))
		 (_gchar_ (gtk_label_get_text _GtkLabel_))
		 (_PangoAttrList_ (gtk_label_get_attributes _GtkLabel_))
		 (_gchar1_ (gtk_label_get_label _GtkLabel_))
		 (_gboolean (gtk_label_get_use_markup _GtkLabel_))
		 (_gboolean1 (gtk_label_get_use_underline _GtkLabel_))
		 (_guint (gtk_label_get_mnemonic_keyval _GtkLabel_))
		 (_GtkWidget1_ (gtk_label_get_mnemonic_widget _GtkLabel_))
		 (_GtkJustification (gtk_label_get_justify _GtkLabel_))
		 (_gboolean2 (gtk_label_get_line_wrap _GtkLabel_))
		 (_gboolean3 (gtk_label_get_selectable _GtkLabel_))
		 (_PangoLayout_ (gtk_label_get_layout _GtkLabel_))
		 (_PangoAttrList_ (pango_attr_list_new))
		 (_list (gtk_label_get_selection_bounds _GtkLabel_))
		 (_list1 (gtk_label_get_layout_offsets _GtkLabel_))
		 )
	    
	    (if (not (string=? _gchar_ "hiho")) (snd-display #__line__ ";label text: ~A" _gchar_))
	    (if (not (string=? _gchar1_ "hiho")) (snd-display #__line__ ";label label: ~A" _gchar1_))
	    (if (not (= _GtkJustification GTK_JUSTIFY_LEFT)) (snd-display #__line__ ";label justification: ~A ~A" _GtkJustification GTK_JUSTIFY_LEFT))
	    (if (not (equal? (list #f 0 0) _list)) (snd-display #__line__ ";label selection bounds: ~A" _list))
	    (if (and (not (equal? (list 0 0) _list1)) 
		     (not (equal? (list -1 -1) _list1)))
		(snd-display #__line__ ";label layout offsets: ~A" _list1))
	    (if _GtkWidget1_ (snd-display #__line__ ";mnemnoinic widget: ~A" _GtkWidget1_))
	    (if _gboolean (snd-display #__line__ ";label use markup"))
	    (if _gboolean1 (snd-display #__line__ ";label underline"))
	    (if _gboolean2 (snd-display #__line__ ";label line wrap"))
	    (if _gboolean3 (snd-display #__line__ ";label selectable"))
	    
	    (gtk_label_set_text _GtkLabel_ "another label")
	    (if (not (string=? (gtk_label_get_text _GtkLabel_) "another label")) (snd-display #__line__ ";set label text: ~A" (gtk_label_get_text _GtkLabel_)))
	    (gtk_label_set_attributes _GtkLabel_ _PangoAttrList_)
	    (gtk_label_set_label _GtkLabel_ "not text")
	    (if (not (string=? (gtk_label_get_label _GtkLabel_) "not text")) (snd-display #__line__ ";set label label: ~A" (gtk_label_get_label _GtkLabel_)))
	    (gtk_label_set_use_markup _GtkLabel_ #f)
	    (if (gtk_label_get_use_markup _GtkLabel_) (snd-display #__line__ ";set label use markup: ~A" (gtk_label_get_use_markup _GtkLabel_)))
	    (gtk_label_set_use_underline _GtkLabel_ #f)
	    (if (gtk_label_get_use_underline _GtkLabel_) (snd-display #__line__ ";set label use underline: ~A" (gtk_label_get_use_underline _GtkLabel_)))
	    (gtk_label_set_text_with_mnemonic _GtkLabel_ "A")
	    (gtk_label_set_justify _GtkLabel_ GTK_JUSTIFY_FILL)
	    (if (not (= (gtk_label_get_justify _GtkLabel_) GTK_JUSTIFY_FILL)) (snd-display #__line__ ";set label justify: ~A" (gtk_label_get_justify _GtkLabel_)))
	    (gtk_label_set_pattern _GtkLabel_ "a pattern")
	    (gtk_label_set_line_wrap _GtkLabel_ #t)
	    (if (not (gtk_label_get_line_wrap _GtkLabel_)) (snd-display #__line__ ";set label line wrap: ~A" (gtk_label_get_line_wrap _GtkLabel_)))
	    (gtk_widget_queue_draw _GtkWidget_)
	    (gtk_widget_queue_resize _GtkWidget_)
	    (gtk_widget_show_now _GtkWidget_)
	    (gtk_widget_show_all _GtkWidget_)
	    (gtk_widget_hide_all _GtkWidget_)
	    (gtk_widget_unmap _GtkWidget_)
	    (gtk_widget_unrealize _GtkWidget_)
	    (gtk_widget_unparent _GtkWidget_))
	  
	  (for-each
	   (lambda (type)
	     (let* ((arr (list->c-array '(1 2 3) type))
		    (lst (c-array->list arr 3)))
	       (if (not (equal? lst '(1 2 3)))
		   (snd-display #__line__ ";~A c-array->list not invertible?: ~A ~A" type arr lst))))
	   (list "gint*" "guint*" "guint32*" "guint16*" "int*" "guchar*"))
	  
	  (let* ((arr (list->c-array '(#f #t #t) "gboolean*"))
		 (lst (c-array->list arr 3)))
	    (if (not (equal? lst '(#f #t #t)))
		(snd-display #__line__ ";gboolean* c-array->list not invertible?: ~A ~A" arr lst)))
	  
	  (for-each
	   (lambda (type)
	     (let* ((arr (list->c-array '("hi" "ho" "hiho") type))
		    (lst (c-array->list arr 3)))
	       (if (not (equal? lst '("hi" "ho" "hiho")))
		   (snd-display #__line__ ";~A c-array->list not invertible?: ~A ~A" type arr lst))))
	   (list "char**" "gchar**"))
	  
	  (let* ((_GdkRegion_ (gdk_region_new))
		 (_GdkRegion1_ (gdk_region_copy _GdkRegion_))
		 (_GdkRectangle_ (GdkRectangle 0 0 10 10))
		 (_GdkRegion2_ (gdk_region_rectangle _GdkRectangle_))
		 (_gboolean (gdk_region_empty _GdkRegion_))
		 (_gboolean1 (gdk_region_equal _GdkRegion_ _GdkRegion1_))
		 (_GdkRectangle1_ (GdkRectangle))
		 (_gboolean2 (gdk_region_point_in _GdkRegion2_ 2 3))
		 (_gboolean3 (gdk_rectangle_intersect _GdkRectangle_ (GdkRectangle 3 3 10 10) (GdkRectangle 0 0 4 4)))
		 (pts (vector->GdkPoints (vct->vector (vct 0.0 0.0 1.0 1.0))))
		 (_GdkRegion3_ (gdk_region_polygon (list 'GdkPoint_ pts) 2 GDK_WINDING_RULE)))
	    (if (equal? _GdkRegion_ _GdkRegion1_) (snd-display #__line__ ";regions equal?"))
	    (if (not _gboolean) (snd-display #__line__ ";region not empty"))
	    (if (not _gboolean1) (snd-display #__line__ ";region not copied equal"))
	    (if (not _gboolean2) (snd-display #__line__ ";region no point"))
	    (if (not _gboolean3) (snd-display #__line__ ";region no intersect"))
	    (gdk_region_get_clipbox _GdkRegion_ _GdkRectangle1_)
	    (gdk_region_union_with_rect _GdkRegion_ _GdkRectangle_)
	    (gdk_region_intersect _GdkRegion2_ _GdkRegion1_)
	    (gdk_region_union _GdkRegion_ _GdkRegion_)
	    (gdk_region_subtract _GdkRegion_ _GdkRegion_)
	    (gdk_region_xor _GdkRegion_ _GdkRegion_)
	    (let ((val (gdk_region_get_rectangles _GdkRegion_)))
	      (if (not (equal? val (list #f 0))) (snd-display #__line__ ";region rects: ~A" val)))
	    (gdk_region_offset _GdkRegion_ 10 10)
	    (gdk_region_shrink _GdkRegion_ 2 2)
	    (gdk_rectangle_union _GdkRectangle_ _GdkRectangle1_ _GdkRectangle_)
	    (gdk_region_destroy _GdkRegion_)
	    (freeGdkPoints pts))
	  
	  (let* ((_gchar_ (gdk_keyval_name 60))
		 (_guint (gdk_keyval_from_name "less"))
		 (_guint1 (gdk_keyval_to_upper 120)) ;88
		 (_guint2 (gdk_keyval_to_lower 65))  ;97
		 (_gboolean (gdk_keyval_is_upper 120)) ;#f
		 (_gboolean1 (gdk_keyval_is_lower 65)) ;#f
		 (_guint32 (gdk_keyval_to_unicode 65)) ;65
		 (_guint3 (gdk_unicode_to_keyval 65)) ;65
		 (vals (gdk_keyval_convert_case 120))) ;(120 88)
	    (if (not (string=? "less" _gchar_)) (snd-display #__line__ ";key name: ~A" _gchar_))
	    (if (not (= _guint 60)) (snd-display #__line__ ";key from less: ~A" _guint))
	    (if (not (= _guint1 88)) (snd-display #__line__ ";key to upper: ~A" _guint1))
	    (if (not (= _guint2 97)) (snd-display #__line__ ";key to lower: ~A" _guint2))
	    (if (not (= _guint32 65)) (snd-display #__line__ ";key to unicode: ~A" _guint32))
	    (if (not (= _guint3 65)) (snd-display #__line__ ";key from unicode: ~A" _guint3))
	    (if (not (equal? vals (list 120 88))) (snd-display #__line__ ";key convert: ~A" vals))
	    (if _gboolean (snd-display #__line__ ";is upper"))
	    (if _gboolean1 (snd-display #__line__ ";is lower")))
	  
	  (let* ((_GtkEntry_ (GTK_ENTRY (gtk_entry_new)))
		 (_GtkEntryCompletion_ (gtk_entry_completion_new))
		 (_gboolean (gtk_entry_get_visibility _GtkEntry_))
		 (_gunichar (gtk_entry_get_invisible_char _GtkEntry_))
		 (_gboolean1 (gtk_entry_get_has_frame _GtkEntry_))
		 (_gint (gtk_entry_get_max_length _GtkEntry_))
		 (_gboolean2 (gtk_entry_get_activates_default _GtkEntry_))
		 (_gint1 (gtk_entry_get_width_chars _GtkEntry_))
		 (_gchar_ (gtk_entry_get_text _GtkEntry_))
		 (_PangoLayout_ (gtk_entry_get_layout _GtkEntry_))
		 (_gfloat (gtk_entry_get_alignment _GtkEntry_))
		 (_GtkEntryCompletion1_ (gtk_entry_get_completion _GtkEntry_))
		 (_GtkWidget_ (gtk_entry_completion_get_entry _GtkEntryCompletion_))
		 (_gint2 (gtk_entry_completion_get_minimum_key_length _GtkEntryCompletion_))
;		 (_list (gtk_entry_get_layout_offsets _GtkEntry_))
		 )
	    (if (not _gboolean) (snd-display #__line__ ";entry not visible"))
	    (if (not _gboolean1) (snd-display #__line__ ";entry no frame"))
	    (if _gboolean2 (snd-display #__line__ ";entry activates default"))
	    (if (not (= _gint 0)) (snd-display #__line__ ";max length: ~A" _gint))
	    (if (not (= _gint1 -1)) (snd-display #__line__ ";width chars: ~A" _gint1))
	    (if (not (= (string-length _gchar_) 0)) (snd-display #__line__ ";entry text: ~A" _gchar_))
	    (if (fneq _gfloat 0.0) (snd-display #__line__ ";entry alignment: ~A" _gfloat))
	    (if (not (= _gint2 1)) (snd-display #__line__ ";completion min key: ~A" _gint2))
	    (if _GtkWidget_ (snd-display #__line__ ";completion get entry: ~A" _GtkWidget_))
	    (if _GtkEntryCompletion1_ (snd-display #__line__ ";entry get completion: ~A" _GtkEntryCompletion1_))
	    (gtk_widget_show (GTK_WIDGET _GtkEntry_))
	    (gtk_entry_set_visibility _GtkEntry_ #f)
	    (if (gtk_entry_get_visibility _GtkEntry_) (snd-display #__line__ ";set entry visible"))
	    (gtk_entry_set_invisible_char _GtkEntry_ 65)
	    (if (not (= (gtk_entry_get_invisible_char _GtkEntry_) 65)) 
		(snd-display #__line__ ";set entry invisible char: ~A" (gtk_entry_get_invisible_char _GtkEntry_)))
	    (gtk_entry_set_has_frame _GtkEntry_ #f)
	    (if (gtk_entry_get_has_frame _GtkEntry_) (snd-display #__line__ ";set entry has frame: ~A" (gtk_entry_get_has_frame _GtkEntry_)))
	    (gtk_entry_set_max_length _GtkEntry_ 40)
	    (if (not (= (gtk_entry_get_max_length _GtkEntry_) 40)) (snd-display #__line__ ";set entry max: ~A" (gtk_entry_get_max_length _GtkEntry_)))
	    (gtk_entry_set_activates_default _GtkEntry_ #f)
	    (gtk_entry_set_width_chars _GtkEntry_ 40)
	    (if (not (= (gtk_entry_get_width_chars _GtkEntry_) 40)) (snd-display #__line__ ";set entry width: ~A" (gtk_entry_get_width_chars _GtkEntry_)))
	    (gtk_entry_set_text _GtkEntry_ "some text")
	    (if (not (string=? (gtk_entry_get_text _GtkEntry_) "some text")) (snd-display #__line__ ";set entry text: ~A" (gtk_entry_get_text _GtkEntry_)))
	    (gtk_entry_set_completion _GtkEntry_ _GtkEntryCompletion_)
	    (gtk_entry_completion_set_minimum_key_length _GtkEntryCompletion_ 6)
	    (gtk_entry_completion_set_text_column _GtkEntryCompletion_ 4)
	    (gtk_entry_set_alignment _GtkEntry_ 0.1)
	    (if (fneq (gtk_entry_get_alignment _GtkEntry_) 0.1) (snd-display #__line__ ";set entry alignment: ~A" (gtk_entry_get_alignment _GtkEntry_)))
	    (gtk_entry_completion_insert_action_text _GtkEntryCompletion_ 10 "hiho"))
	  
	  (let* ((_GtkCalendar_ (GTK_CALENDAR (gtk_calendar_new)))
		 (_GtkCalendarDisplayOptions (gtk_calendar_get_display_options _GtkCalendar_))
		 (_gboolean (gtk_calendar_mark_day _GtkCalendar_ 2))
		 (_gboolean1 (gtk_calendar_unmark_day _GtkCalendar_ 3))
		 (_gboolean2 (gtk_calendar_select_month _GtkCalendar_ 7 1951)))
	    (if (not _gboolean) (snd-display #__line__ ";calendar mark day"))
	    (if (not _gboolean1) (snd-display #__line__ ";calendar unmark day"))
	    (if (not _gboolean2) (snd-display #__line__ ";calendar select month"))
	    (gtk_calendar_clear_marks _GtkCalendar_)
	    (gtk_calendar_select_day _GtkCalendar_ 14)
	    (gtk_calendar_set_display_options _GtkCalendar_ _GtkCalendarDisplayOptions)
	    (let ((vals (gtk_calendar_get_date _GtkCalendar_))) ;(1951 7 14)
	      (if (not (equal? vals (list 1951 7 14))) (snd-display #__line__ ";calendar sez birthday: ~A" vals))))
	  
	  (let* ((_gboolean (gtk_rc_reparse_all))
		 (_GtkRcStyle_ (gtk_rc_style_new))
		 (_GtkWidget_ (gtk_label_new "hiho"))
		 (_GtkStyle_ (gtk_rc_get_style _GtkWidget_))
		 (_GtkRcStyle1_ (gtk_rc_style_copy _GtkRcStyle_))
		 (_GdkColor_ (let ((tmp (GdkColor)))
			       (gdk_color_parse "red" tmp)
			       (let ((col (gdk_color_copy tmp)))
				 (gdk_rgb_find_color (gdk_colormap_get_system) col)
				 col)))
		 (_gchar_ (gtk_rc_find_module_in_path "hiho"))
		 )
	    (gtk_rc_add_default_file "Snd.gtkrc")
	    (gtk_rc_parse "Snd.gtkrc")
	    (gtk_rc_parse_string "widget \"*.preset_button\" style \"reset\"")
	    )
	  
	  (let* ((_GtkPaned_ (GTK_PANED (gtk_hpaned_new)))
		 (_GtkPaned1_ (GTK_PANED (gtk_vpaned_new)))
		 (_GtkWidget_ (gtk_label_new "hiho"))
		 (_GtkWidget1_ (gtk_label_new "hiho"))
		 (_GtkWidget2_ (gtk_label_new "hiho"))
		 (_GtkWidget3_ (gtk_label_new "hiho")))
	    (gtk_paned_add1 _GtkPaned_ _GtkWidget_)
	    (gtk_paned_add2 _GtkPaned_ _GtkWidget1_)
	    (gtk_paned_pack1 _GtkPaned1_ _GtkWidget2_ #f #f)
	    (gtk_paned_pack2 _GtkPaned1_ _GtkWidget3_ #f #f)
	    (gtk_paned_set_position _GtkPaned_ 20)
	    (let ((_gint (gtk_paned_get_position _GtkPaned_))
		  (_GtkWidget4_ (gtk_paned_get_child1 _GtkPaned_))
		  (_GtkWidget5_ (gtk_paned_get_child2 _GtkPaned_)))
	      (if (not (= _gint 20)) (snd-display #__line__ ";set paned position: ~A" _gint))
	      (if (not (equal? _GtkWidget_ _GtkWidget4_)) (snd-display #__line__ ";paned child1: ~A ~A" _GtkWidget_ _GtkWidget4_))
	      (if (not (equal? _GtkWidget1_ _GtkWidget5_)) (snd-display #__line__ ";paned child2: ~A ~A" _GtkWidget1_ _GtkWidget5_))))
	  
	  (let* ((_GtkRuler_ (GTK_RULER (gtk_vruler_new)))
		 (_GtkRuler1_ (GTK_RULER (gtk_hruler_new)))
		 (_GtkMetricType (gtk_ruler_get_metric _GtkRuler_)))
	    (gtk_ruler_draw_ticks _GtkRuler_)
	    (gtk_ruler_draw_pos _GtkRuler_)
	    (gtk_ruler_set_metric _GtkRuler_ GTK_PIXELS)
	    (gtk_ruler_set_range _GtkRuler_ 0.0 1.0 0.1 0.5)
	    (let ((vals (gtk_ruler_get_range _GtkRuler_)))
	      (if (not (feql vals (list 0.0 1.0 0.1 0.5))) (snd-display #__line__ ";ruler get range: ~A" vals))))
	  
	  (let* ((_GtkStatusbar_ (GTK_STATUSBAR (gtk_statusbar_new)))
		 (_gboolean (gtk_statusbar_get_has_resize_grip _GtkStatusbar_))
		 (_guint (gtk_statusbar_get_context_id _GtkStatusbar_ "hiho")))
	    (if (not _gboolean) (snd-display #__line__ ";statusbar grip"))
	    (gtk_statusbar_set_has_resize_grip _GtkStatusbar_ #f)
	    (if (gtk_statusbar_get_has_resize_grip _GtkStatusbar_) (snd-display #__line__ ";set statusbar grip")))
	  
	  (let* ((_GdkScreen_ (gdk_screen_get_default))
		 (_GdkDisplay_ (gdk_display_get_default))
		 (_GdkWindow_ (gdk_screen_get_root_window _GdkScreen_))
		 (_GtkWindow_ (GTK_WINDOW (cadr (main-widgets))))
		 (_GtkWidget_ (gtk_window_new GTK_WINDOW_TOPLEVEL))
		 (_GdkWindow1_ (gdk_display_get_default_group _GdkDisplay_))
		 (_gchar_ (gtk_window_get_title _GtkWindow_))
		 (_gchar1_ (gtk_window_get_role _GtkWindow_))
		 (_GtkWidget1_ (gtk_window_get_focus _GtkWindow_))
		 (_GtkWindow2_ (gtk_window_get_transient_for _GtkWindow_))
		 (_GdkWindowTypeHint (gtk_window_get_type_hint _GtkWindow_))
		 (_gboolean (gtk_window_get_destroy_with_parent _GtkWindow_))
		 (_gboolean1 (gtk_window_get_resizable _GtkWindow_))
		 (_GdkGravity (gtk_window_get_gravity _GtkWindow_))
		 (_gboolean2 (gtk_window_get_has_frame _GtkWindow_))
		 (_gboolean3 (gtk_window_get_decorated _GtkWindow_))
		 (_GList_ (gtk_window_get_icon_list _GtkWindow_))
		 (_GdkPixbuf_ (gtk_window_get_icon _GtkWindow_))
		 (_gboolean4 (gtk_window_get_modal _GtkWindow_))
		 (_GdkModifierType (gtk_window_get_mnemonic_modifier _GtkWindow_))
		 (_gboolean5 (gtk_window_is_active _GtkWindow_))
		 (_gboolean6 (gtk_window_has_toplevel_focus _GtkWindow_))
		 (_gboolean7 (gtk_window_get_accept_focus _GtkWindow_))
		 (_list (gdk_window_at_pointer))
		 (_list11 (gdk_window_get_decorations _GdkWindow_))
		 (_GdkWindowType (gdk_window_get_window_type _GdkWindow_))
		 (_gboolean10 (gdk_window_is_visible _GdkWindow_))
		 (_gboolean11 (gdk_window_is_viewable _GdkWindow_))
		 (_GdkWindowState (gdk_window_get_state _GdkWindow_))
		 (_GdkWindow3_ (gdk_window_get_parent _GdkWindow_))
		 (_GdkWindow4_ (gdk_window_get_toplevel _GdkWindow_))
		 (_GList1_ (gdk_window_get_children _GdkWindow_))
		 (_GList2_ (gdk_window_peek_children _GdkWindow_))
		 (_GdkEventMask (gdk_window_get_events _GdkWindow_))
		 (_GdkRegion_ (gdk_window_get_update_area _GdkWindow_))
		 (_GdkWindow5_ (gdk_window_get_group _GdkWindow_))
		 (_list1 (gdk_window_get_origin _GdkWindow_))
		 (_list2 (gdk_window_get_pointer _GdkWindow_))
		 (_list3 (gdk_window_get_geometry _GdkWindow_))
		 (_list4 (gtk_window_get_default_size _GtkWindow_))
		 (_list5 (gtk_window_get_position _GtkWindow_))
		 (_list6 (gtk_window_get_frame_dimensions _GtkWindow_))
		 (_list7 (gdk_window_get_root_origin _GdkWindow_))
		 (_list8 (gdk_window_get_position _GdkWindow_))
		 (_list9 (gdk_window_get_internal_paint_info _GdkWindow_))
		 (_list10 (gtk_window_get_size _GtkWindow_))
		 )
	    (if (gtk_window_get_icon_name _GtkWindow_) (snd-display #__line__ ";get icon name: ~A" (gtk_window_get_icon_name _GtkWindow_)))
	    (gtk_window_set_icon_name _GtkWindow_ "Snd")
	    (if (not (string=? (gtk_window_get_icon_name _GtkWindow_) "Snd"))
		(snd-display #__line__ ";set icon name: ~A" (gtk_window_get_icon_name _GtkWindow_)))
	    (if (not (gtk_window_get_focus_on_map _GtkWindow_)) (snd-display #__line__ ";focus on map?"))
	    (gtk_window_set_default_icon_name "hiho")
	    (if (not (= _GdkWindowTypeHint GDK_WINDOW_TYPE_HINT_NORMAL)) (snd-display #__line__ ";_GdkWindowTypeHint: ~A" _GdkWindowTypeHint))
	    (if _gboolean (snd-display #__line__ ";gtk window destroy with parent"))
	    (if (not _gboolean1) (snd-display #__line__ ";gtk window not resizable"))
	    (if (not (= _GdkGravity GDK_GRAVITY_NORTH_WEST)) (snd-display #__line__ ";window gravity: ~A" _GdkGravity))
	    (if _gboolean2 (snd-display #__line__ ";gtk window has frame"))
	    (if (not _gboolean3) (snd-display #__line__ ";gtk window not decorated"))
	    (if _gboolean4 (snd-display #__line__ ";gtk window modal"))
	    (if (not (= _GdkModifierType GDK_MOD1_MASK)) (snd-display #__line__ ";_GdkModifierType: ~A" _GdkModifierType))
	    (if (not _gboolean7) (snd-display #__line__ ";window not focusable"))
	    (if (not (= _GdkWindowType GDK_WINDOW_ROOT)) (snd-display #__line__ ";root window type: ~A" _GdkWindowType))
	    (if _gboolean10 (snd-display #__line__ ";window visible"))
	    (if (not _gboolean11) (snd-display #__line__ ";window not viewable"))
	    (if (not (= _GdkWindowState GDK_WINDOW_STATE_WITHDRAWN)) (snd-display #__line__ ";window state: ~A" _GdkWindowState))
	    (if (not (equal? (list 1 0 0) _list1)) (snd-display #__line__ ";window get origin: ~A" _list1))
	    (if (and (not (equal? (list 0 0 2560 1600 32) _list3))
		     (not (equal? (list 0 0 2560 1600 24) _list3)))
		(snd-display #__line__ ";window geometry: ~A" _list3))
	    (if (not (equal? (list -1 -1) _list4)) (snd-display #__line__ ";window default size: ~A" _list4))
	    (if (not (equal? (list 0 0 0 0) _list6)) (snd-display #__line__ ";window frame: ~A" _list6))
	    (if (not (equal? (list 0 0) _list7)) (snd-display #__line__ ";window get root origin: ~A" _list7))
	    (if (not (equal? (list 0 0) _list8)) (snd-display #__line__ ";window get position: ~A" _list8))
	    
	    (gdk_window_set_user_data _GdkWindow_ (GPOINTER 123))
	    
	    (gdk_window_set_title _GdkWindow_ "Snd") ; there's no corresponding get?
	    (gtk_window_set_title _GtkWindow_ "Snd")
	    (let ((title (gtk_window_get_title _GtkWindow_)))
	      (if (not (string=? title "Snd")) (snd-display #__line__ ";gtk_window_get_title: ~A?" title)))
	    
	    (gtk_window_present _GtkWindow_)
	    (gtk_window_deiconify _GtkWindow_)
	    (gtk_window_unmaximize _GtkWindow_)
	    (gtk_window_move _GtkWindow_ 200 20)
	    (gtk_window_resize _GtkWindow_ 750 600)
	    (gdk_window_set_decorations _GdkWindow_ GDK_DECOR_ALL)
	    (gtk_window_set_resizable _GtkWindow_ #t)
	    (gtk_window_set_position _GtkWindow_ GTK_WIN_POS_CENTER)
	    (gtk_window_set_modal _GtkWindow_ #f)
	    (gtk_window_set_frame_dimensions _GtkWindow_ 0 0 0 0))
	  
	  (let ((_GtkArrow_ (GTK_ARROW (gtk_arrow_new GTK_ARROW_DOWN GTK_SHADOW_IN))))
	    (gtk_arrow_set _GtkArrow_ GTK_ARROW_LEFT GTK_SHADOW_OUT))
	  
	  (let* ((_GtkProgressBar_ (GTK_PROGRESS_BAR (gtk_progress_bar_new)))
		 (_gchar_ (gtk_progress_bar_get_text _GtkProgressBar_))
		 (_gdouble (gtk_progress_bar_get_fraction _GtkProgressBar_))
		 (_gdouble1 (gtk_progress_bar_get_pulse_step _GtkProgressBar_))
		 (_GtkProgressBarOrientation (gtk_progress_bar_get_orientation _GtkProgressBar_)))
	    (if _gchar_ (snd-display #__line__ ";progress text: ~A" _gchar_))
	    (if (fneq _gdouble 0.0) (snd-display #__line__ ";progress fraction: ~A" _gdouble))
	    (if (fneq _gdouble1 0.1) (snd-display #__line__ ";progress step: ~A" _gdouble1))
	    (if (not (= _GtkProgressBarOrientation 0)) (snd-display #__line__ ";progress orient: ~A" _GtkProgressBarOrientation))
	    (gtk_progress_bar_pulse _GtkProgressBar_)
	    (gtk_progress_bar_set_text _GtkProgressBar_ "hiho")
	    (gtk_progress_bar_set_fraction _GtkProgressBar_ .25)
	    (gtk_progress_bar_set_pulse_step _GtkProgressBar_ .2)
	    (gtk_progress_bar_set_orientation _GtkProgressBar_ GTK_PROGRESS_RIGHT_TO_LEFT)
	    (set! _gchar_ (gtk_progress_bar_get_text _GtkProgressBar_))
	    (set! _gdouble (gtk_progress_bar_get_fraction _GtkProgressBar_))
	    (set! _gdouble1 (gtk_progress_bar_get_pulse_step _GtkProgressBar_))
	    (set! _GtkProgressBarOrientation (gtk_progress_bar_get_orientation _GtkProgressBar_))
	    (if (not (string=? _gchar_ "hiho")) (snd-display #__line__ ";set progress text: ~A" _gchar_))
	    (if (fneq _gdouble 0.25) (snd-display #__line__ ";set progress fraction: ~A" _gdouble))
	    (if (fneq _gdouble1 0.2) (snd-display #__line__ ";set progress step: ~A" _gdouble1))
	    (if (not (= _GtkProgressBarOrientation GTK_PROGRESS_RIGHT_TO_LEFT)) (snd-display #__line__ ";set progress orient: ~A" _GtkProgressBarOrientation)))
	  
	  (let* ((_GdkCursor_ (gdk_cursor_new GDK_BOTTOM_TEE))
		 (_GdkCursor1_ (gdk_cursor_ref _GdkCursor_)))
	    (gdk_cursor_unref _GdkCursor1_))
	  
	  (let* ((_GtkAdjustment_ (GTK_ADJUSTMENT (gtk_adjustment_new 0.0 1.0 2.0 0.1 0.1 0.1)))
		 (_GtkAdjustment1_ (GTK_ADJUSTMENT (gtk_adjustment_new 0.0 1.0 2.0 0.1 0.1 0.1)))
		 (_gdouble (gtk_adjustment_get_value _GtkAdjustment_))
		 (_GtkScale_ (GTK_SCALE (gtk_hscale_new _GtkAdjustment_)))
		 (_GtkScrollbar_ (GTK_SCROLLBAR (gtk_hscrollbar_new _GtkAdjustment_)))
		 (_GtkWidget_ (gtk_vscale_new _GtkAdjustment_))
		 (_GtkWidget1_ (gtk_vscrollbar_new _GtkAdjustment_))
		 (_GtkLayout_ (GTK_LAYOUT (gtk_layout_new _GtkAdjustment_ _GtkAdjustment1_)))
		 (_GtkAdjustment2_ (gtk_layout_get_hadjustment _GtkLayout_))
		 (_GtkAdjustment3_ (gtk_layout_get_vadjustment _GtkLayout_))
		 (_GtkScale1_ (GTK_SCALE (gtk_vscale_new_with_range 0.0 1.0 0.1)))
		 (_GtkScale2_ (GTK_SCALE (gtk_hscale_new_with_range 0.0 1.0 0.1)))
		 (_GtkRange_ (GTK_RANGE _GtkScale1_))
		 (_GtkUpdateType (gtk_range_get_update_policy _GtkRange_))
		 (_GtkAdjustment4_ (gtk_range_get_adjustment _GtkRange_))
		 (_gboolean (gtk_range_get_inverted _GtkRange_))
		 (_gdouble1 (gtk_range_get_value _GtkRange_))
		 (_gint (gtk_scale_get_digits _GtkScale_))
		 (_gboolean1 (gtk_scale_get_draw_value _GtkScale_))
		 (_GtkPositionType (gtk_scale_get_value_pos _GtkScale_))
		 (_PangoLayout_ (gtk_scale_get_layout _GtkScale_))
		 (_list (gtk_scale_get_layout_offsets _GtkScale_))
		 (_list1 (gtk_layout_get_size _GtkLayout_)))
	    (if (fneq _gdouble 1.0) (snd-display #__line__ ";adjust init: ~A" _gdouble))
	    (if _gboolean (snd-display #__line__ ";range invert"))
	    (if (fneq _gdouble1 0.0) (snd-display #__line__ ";range init: ~A" _gdouble1))
	    (if (not _gboolean1) (snd-display #__line__ ";scale not drawn"))
	    (if (not (= 1 _gint)) (snd-display #__line__ ";scale init digits: ~A" _gint))
	    (if (not (= _GtkPositionType 2)) (snd-display #__line__ ";scale init pos: ~A" _GtkPositionType))
	    (if (not (equal? _list1 (list 100 100))) (snd-display #__line__ ";layout size: ~A" _list1))
	    (if (not (= _GtkUpdateType GTK_UPDATE_CONTINUOUS)) (snd-display #__line__ ";range update: ~A" _GtkUpdateType))
	    (gtk_range_set_update_policy _GtkRange_ GTK_UPDATE_DISCONTINUOUS)
	    (set! _GtkUpdateType (gtk_range_get_update_policy _GtkRange_))
	    (if (not (= _GtkUpdateType GTK_UPDATE_DISCONTINUOUS)) (snd-display #__line__ ";set range update: ~A" _GtkUpdateType))
	    (gtk_range_set_adjustment _GtkRange_ _GtkAdjustment4_)
	    (gtk_range_set_inverted _GtkRange_ #f)
	    (set! _gboolean (gtk_range_get_inverted _GtkRange_))
	    (if _gboolean (snd-display #__line__ ";set range invert"))
	    (gtk_range_set_value _GtkRange_ 0.5)
	    (set! _gdouble1 (gtk_range_get_value _GtkRange_))
	    (if (fneq _gdouble1 0.5) (snd-display #__line__ ";set range val: ~A" _gdouble1))
	    (gtk_scale_set_digits _GtkScale_ 2)
	    (set! _gint (gtk_scale_get_digits _GtkScale_))
	    (if (not (= 2 _gint)) (snd-display #__line__ ";set scale digits: ~A" _gint))
	    (gtk_scale_set_draw_value _GtkScale_ #t)
	    (set! _gboolean1 (gtk_scale_get_draw_value _GtkScale_))
	    (if (not _gboolean1) (snd-display #__line__ ";set scale drawn"))
	    (gtk_scale_set_value_pos _GtkScale_ GTK_POS_LEFT)
	    (set! _GtkPositionType (gtk_scale_get_value_pos _GtkScale_))
	    (if (not (= _GtkPositionType GTK_POS_LEFT)) (snd-display #__line__ ";set scale pos: ~A" _GtkPositionType))
	    (gtk_range_set_increments _GtkRange_ 1.0 0.1)
	    (gtk_range_set_range _GtkRange_ 0.0 3.0)
	    (gtk_adjustment_set_value _GtkAdjustment_ 0.5)
	    (gtk_adjustment_changed _GtkAdjustment_)
	    (gtk_adjustment_value_changed _GtkAdjustment_)
	    (gtk_layout_set_hadjustment _GtkLayout_ _GtkAdjustment_)
	    (gtk_layout_set_vadjustment _GtkLayout_ _GtkAdjustment_)
	    (gtk_layout_set_size _GtkLayout_ 0 100)
	    (set! _list1 (gtk_layout_get_size _GtkLayout_))
	    (if (not (equal? _list1 (list 0 100))) (snd-display #__line__ ";layout set size: ~A" _list1))
	    (gtk_layout_put _GtkLayout_ _GtkWidget_ 0 10)
	    (gtk_layout_move _GtkLayout_ _GtkWidget_ 10 10))
	  
	  (let* ((_GtkAdjustment_ (GTK_ADJUSTMENT (gtk_adjustment_new 0.0 1.0 2.0 0.1 0.1 0.1)))
		 (_GtkSpinButton_ (GTK_SPIN_BUTTON (gtk_spin_button_new_with_range 0.0 20.0 1.0)))
		 (_guint (gtk_spin_button_get_digits _GtkSpinButton_))
		 (_gdouble (gtk_spin_button_get_value _GtkSpinButton_))
		 (_gint (gtk_spin_button_get_value_as_int _GtkSpinButton_))
		 (_GtkSpinButtonUpdatePolicy (gtk_spin_button_get_update_policy _GtkSpinButton_))
		 (_gboolean (gtk_spin_button_get_numeric _GtkSpinButton_))
		 (_gboolean1 (gtk_spin_button_get_wrap _GtkSpinButton_))
		 (_gboolean2 (gtk_spin_button_get_snap_to_ticks _GtkSpinButton_))
		 (_GtkSpinButton1_ (GTK_SPIN_BUTTON (gtk_spin_button_new _GtkAdjustment_ 0.0 1)))
		 (_GtkAdjustment1_ (gtk_spin_button_get_adjustment _GtkSpinButton1_))
		 (_list (gtk_spin_button_get_increments _GtkSpinButton_))
		 (_list1 (gtk_spin_button_get_range _GtkSpinButton_)))
	    (if (not (equal? _GtkAdjustment_ _GtkAdjustment1_)) (snd-display #__line__ ";spin button get adj: ~A ~A" _GtkAdjustment_ _GtkAdjustment1_))
	    (if (not (= _guint 0)) (snd-display #__line__ ";spin digits: ~A" _guint))
	    (if (fneq _gdouble 0.0) (snd-display #__line__ ";spin init: ~A" _gdouble))
	    (if (not (= _GtkSpinButtonUpdatePolicy GTK_UPDATE_ALWAYS)) (snd-display #__line__ ";spin update: ~A" _GtkSpinButtonUpdatePolicy))
	    (if (not (= _gint 0)) (snd-display #__line__ ";spin val as int: ~A" _gint))
	    (if (not _gboolean) (snd-display #__line__ ";spin not numeric"))
	    (if _gboolean1 (snd-display #__line__ ";spin wraps"))
	    (if _gboolean2 (snd-display #__line__ ";spin snaps"))
	    (if (not (feql _list (list 1.0 10.0))) (snd-display #__line__ ";spin incr: ~A" _list))
	    (if (not (feql _list1 (list 0.0 20.0))) (snd-display #__line__ ";spin range: ~A" _list1))
	    (gtk_spin_button_update _GtkSpinButton_)
	    (gtk_spin_button_set_adjustment _GtkSpinButton_ _GtkAdjustment_)
	    (gtk_spin_button_set_digits _GtkSpinButton1_ 2)
	    (gtk_spin_button_set_value _GtkSpinButton1_ 0.5)
	    (gtk_spin_button_set_update_policy _GtkSpinButton_ GTK_UPDATE_ALWAYS)
	    (gtk_spin_button_set_numeric _GtkSpinButton_ #t)
	    (gtk_spin_button_set_wrap _GtkSpinButton_ #f)
	    (gtk_spin_button_set_snap_to_ticks _GtkSpinButton_ #f)
	    (gtk_spin_button_set_increments _GtkSpinButton_ 0.1 0.1)
	    (gtk_spin_button_set_range _GtkSpinButton_ 0.0 1.0)
	    (gtk_spin_button_spin _GtkSpinButton_ GTK_SPIN_STEP_FORWARD 0.1)
	    (gtk_spin_button_configure _GtkSpinButton_ _GtkAdjustment_ 1.0 1)
	    (set! _guint (gtk_spin_button_get_digits _GtkSpinButton1_))
	    (set! _gdouble (gtk_spin_button_get_value _GtkSpinButton1_))
	    (set! _GtkSpinButtonUpdatePolicy (gtk_spin_button_get_update_policy _GtkSpinButton_))
	    (set! _gboolean (gtk_spin_button_get_numeric _GtkSpinButton_))
	    (set! _gboolean1 (gtk_spin_button_get_wrap _GtkSpinButton_))
	    (set! _gboolean2 (gtk_spin_button_get_snap_to_ticks _GtkSpinButton_))
	    (set! _list1 (gtk_spin_button_get_range _GtkSpinButton_))
	    (if (not (= _guint 2)) (snd-display #__line__ ";set spin digits: ~A" _guint))
	    (if (not (= _GtkSpinButtonUpdatePolicy GTK_UPDATE_ALWAYS)) (snd-display #__line__ ";set spin update: ~A" _GtkSpinButtonUpdatePolicy))
	    (if (not _gboolean) (snd-display #__line__ ";set spin not numeric"))
	    (if _gboolean1 (snd-display #__line__ ";set spin wraps"))
	    (if _gboolean2 (snd-display #__line__ ";set spin snaps"))
	    (if (not (feql _list1 (list 0.0 1.0))) (snd-display #__line__ ";set spin range: ~A" _list1)))
	  
	  (let* ((_GtkToolbar_ (GTK_TOOLBAR (gtk_toolbar_new)))
		 (_GtkWidget_ (cadr (main-widgets)))
		 (_GtkWindow_ (GTK_WINDOW _GtkWidget_))
		 (_GtkToolItem_ (gtk_tool_item_new))
		 (_GtkSeparatorToolItem_ (GTK_SEPARATOR_TOOL_ITEM (gtk_separator_tool_item_new)))
		 (_GtkToggleToolButton_ (GTK_TOGGLE_TOOL_BUTTON (gtk_toggle_tool_button_new)))
		 (_GtkToolItem8_ (gtk_toggle_tool_button_new_from_stock GTK_STOCK_CANCEL))
					;		 (_GtkOrientation (gtk_toolbar_get_orientation _GtkToolbar_))
		 (_GtkToolbarStyle (gtk_toolbar_get_style _GtkToolbar_))
		 (_GtkIconSize (gtk_toolbar_get_icon_size _GtkToolbar_))
		 (_gint (gtk_toolbar_get_n_items _GtkToolbar_))
		 (_gboolean1 (gtk_toolbar_get_show_arrow _GtkToolbar_))
		 (_GtkReliefStyle (gtk_toolbar_get_relief_style _GtkToolbar_))
		 (_GtkToolButton_ (GTK_TOOL_BUTTON (gtk_tool_button_new_from_stock GTK_STOCK_CANCEL)))
		 (_gchar_ (gtk_tool_button_get_label _GtkToolButton_))
		 (_gboolean2 (gtk_tool_button_get_use_underline _GtkToolButton_))
		 (_gchar1_ (gtk_tool_button_get_stock_id _GtkToolButton_))
		 (_GtkWidget1_ (gtk_tool_button_get_icon_widget _GtkToolButton_))
		 (_GtkWidget2_ (gtk_tool_button_get_label_widget _GtkToolButton_))
		 (_gboolean3 (gtk_tool_item_get_homogeneous _GtkToolItem_))
		 (_gboolean4 (gtk_tool_item_get_expand _GtkToolItem_))
		 (_gboolean5 (gtk_tool_item_get_use_drag_window _GtkToolItem_))
		 (_gboolean6 (gtk_tool_item_get_visible_horizontal _GtkToolItem_))
		 (_gboolean7 (gtk_tool_item_get_visible_vertical _GtkToolItem_))
		 (_gboolean8 (gtk_tool_item_get_is_important _GtkToolItem_))
		 (_GtkIconSize1 (gtk_tool_item_get_icon_size _GtkToolItem_))
		 (_GtkOrientation1 (gtk_tool_item_get_orientation _GtkToolItem_))
		 (_GtkToolbarStyle1 (gtk_tool_item_get_toolbar_style _GtkToolItem_))
		 (_GtkReliefStyle1 (gtk_tool_item_get_relief_style _GtkToolItem_))
		 (_GtkWidget3_ (gtk_tool_item_retrieve_proxy_menu_item _GtkToolItem_))
		 (_GtkToolItem4_ (gtk_toolbar_get_nth_item _GtkToolbar_ 0))
		 (_gint2 (gtk_toolbar_get_drop_index _GtkToolbar_ 0 0))
		 (_GtkRadioToolButton_ (GTK_RADIO_TOOL_BUTTON (gtk_radio_tool_button_new #f)))
		 (_GSList_ (gtk_radio_tool_button_get_group _GtkRadioToolButton_))
		 (_gboolean9 (gtk_toggle_tool_button_get_active _GtkToggleToolButton_))
		 (_GtkToolItem6_ (gtk_radio_tool_button_new_from_widget _GtkRadioToolButton_))
		 (_gboolean10 (gtk_separator_tool_item_get_draw _GtkSeparatorToolItem_))
		 (_GtkToolItem5_ (gtk_radio_tool_button_new_from_stock #f GTK_STOCK_CANCEL)))
	    
	    (if (not (= _GtkToolbarStyle 2)) (snd-display #__line__ ";toolbar style: ~A" _GtkToolbarStyle))
	    (if (not (= _GtkIconSize 3)) (snd-display #__line__ ";toolbar icon size: ~A" _GtkIconSize))
	    (if (not (= _gint 0)) (snd-display #__line__ ";toolbar items: ~A" _gint))
	    (if (not _gboolean1) (snd-display #__line__ ";toolbar no arrow"))
	    (if (not (= _GtkReliefStyle 2)) (snd-display #__line__ ";toolbar relief: ~A" _GtkReliefStyle))
	    (if _gboolean2 (snd-display #__line__ ";toolbar underlined"))
	    (if (not (string=? _gchar1_ "gtk-cancel")) (snd-display #__line__ ";tool button stock: ~A" _gchar1_))
	    (if _gboolean3 (snd-display #__line__ ";tool item homogenous"))
	    (if _gboolean4 (snd-display #__line__ ";tool item expands"))
	    (if _gboolean5 (snd-display #__line__ ";tool item drags"))
	    (if (not _gboolean6) (snd-display #__line__ ";tool item not visible horizontal"))
	    (if (not _gboolean7) (snd-display #__line__ ";tool item not visible vertical"))
	    (if _gboolean8 (snd-display #__line__ ";tool item important"))
	    (if (not (= _GtkIconSize1 3)) (snd-display #__line__ ";tool item icon size: ~A" _GtkIconSize1))
	    (if (not (= _GtkOrientation1 0)) (snd-display #__line__ ";tool item orientation: ~A" _GtkOrientation1))
	    (if (not (= _GtkToolbarStyle1 0)) (snd-display #__line__ ";tool item style: ~A" _GtkToolbarStyle1))
	    (if (not (= _GtkReliefStyle1 2)) (snd-display #__line__ ";tool item relief: ~A" _GtkReliefStyle))
	    
	    (gtk_radio_tool_button_set_group _GtkRadioToolButton_ #f)
	    (gtk_toggle_tool_button_set_active _GtkToggleToolButton_ #t)
	    (gtk_toolbar_unset_style _GtkToolbar_)
					;	    (gtk_toolbar_set_orientation _GtkToolbar_ GTK_ORIENTATION_HORIZONTAL)
	    (gtk_toolbar_set_style _GtkToolbar_ GTK_TOOLBAR_TEXT)
	    (gtk_toolbar_set_show_arrow _GtkToolbar_ #f)
	    (gtk_tool_button_set_label _GtkToolButton_ "hi")
	    (gtk_tool_button_set_use_underline _GtkToolButton_ #f)
	    (gtk_tool_button_set_stock_id _GtkToolButton_ GTK_STOCK_CANCEL)
	    (gtk_tool_item_set_homogeneous _GtkToolItem_ #t)
	    (gtk_tool_item_set_expand _GtkToolItem_ #t)
	    (gtk_tool_item_set_use_drag_window _GtkToolItem_ #f)
	    (gtk_tool_item_set_visible_horizontal _GtkToolItem_ #t)
	    (gtk_tool_item_set_visible_vertical _GtkToolItem_ #f)
	    (gtk_tool_item_set_is_important _GtkToolItem_ #t)
	    (gtk_separator_tool_item_set_draw _GtkSeparatorToolItem_ #f))
	  
	  (let* ((_GtkButtonBox_ (GTK_BUTTON_BOX (gtk_vbutton_box_new)))
		 (_GtkWidget_ (gtk_hbutton_box_new))
		 (_GtkButtonBoxStyle (gtk_button_box_get_layout _GtkButtonBox_))
		 (_GtkWidget1_ (gtk_button_new_with_label "hi")))
	    (gtk_button_box_set_layout _GtkButtonBox_ GTK_BUTTONBOX_SPREAD))
	  
	  (let* ((_GtkTable_ (GTK_TABLE (gtk_table_new 2 3 #t)))
		 (_guint (gtk_table_get_default_row_spacing _GtkTable_))
		 (_guint1 (gtk_table_get_default_col_spacing _GtkTable_))
		 (_gboolean (gtk_table_get_homogeneous _GtkTable_))
		 (_guint2 (gtk_table_get_row_spacing _GtkTable_ 0))
		 (_guint3 (gtk_table_get_col_spacing _GtkTable_ 0)))
	    (if (not (= _guint 0)) (snd-display #__line__ ";table row def: ~A" _guint))
	    (if (not (= _guint1 0)) (snd-display #__line__ ";table col def: ~A" _guint1))
	    (if (not (= _guint2 0)) (snd-display #__line__ ";table row: ~A" _guint2))
	    (if (not (= _guint3 0)) (snd-display #__line__ ";table col: ~A" _guint3))
	    (if (not _gboolean) (snd-display #__line__ ";table not homogenous"))
	    (gtk_table_set_row_spacings _GtkTable_ 10)
	    (gtk_table_set_col_spacings _GtkTable_ 10)
	    (gtk_table_set_homogeneous _GtkTable_ #t)
	    (gtk_table_resize _GtkTable_ 2 3)
	    (gtk_table_set_row_spacing _GtkTable_ 0 2)
	    (gtk_table_set_col_spacing _GtkTable_ 0 3)
	    (gtk_table_attach_defaults _GtkTable_ (gtk_label_new "hiho") 0 1 0 1)
	    (set! _guint (gtk_table_get_default_row_spacing _GtkTable_))
	    (set! _guint1 (gtk_table_get_default_col_spacing _GtkTable_))
	    (set! _guint2 (gtk_table_get_row_spacing _GtkTable_ 0))
	    (set! _guint3 (gtk_table_get_col_spacing _GtkTable_ 0))
	    (if (not (= _guint1 10)) (snd-display #__line__ ";set table col def: ~A" _guint1))
	    (if (not (= _guint2 2)) (snd-display #__line__ ";set table row: ~A" _guint2))
	    (if (not (= _guint3 3)) (snd-display #__line__ ";set table col: ~A" _guint3)))
	  
	  (let* ((_GtkNotebook_ (GTK_NOTEBOOK (gtk_notebook_new)))
		 (page (gtk_button_new_with_label "hi"))
		 (_gint (gtk_notebook_append_page _GtkNotebook_ page (gtk_label_new "ho")))
		 (_gint1 (gtk_notebook_get_current_page _GtkNotebook_))
		 (_gboolean (gtk_notebook_get_show_border _GtkNotebook_))
		 (_gboolean1 (gtk_notebook_get_show_tabs _GtkNotebook_))
		 (_GtkPositionType (gtk_notebook_get_tab_pos _GtkNotebook_))
		 (_gboolean2 (gtk_notebook_get_scrollable _GtkNotebook_))
		 (_int (gtk_notebook_get_n_pages _GtkNotebook_))
		 (_GtkWidget_ (gtk_notebook_get_nth_page _GtkNotebook_ 0))
		 (_gint2 (gtk_notebook_page_num _GtkNotebook_ page))
		 (_GtkWidget1_ (gtk_notebook_get_tab_label _GtkNotebook_ page))
		 (_gchar_ (gtk_notebook_get_tab_label_text _GtkNotebook_ page))
		 (_GtkWidget2_ (gtk_notebook_get_menu_label _GtkNotebook_ page))
		 (_gchar1_ (gtk_notebook_get_menu_label_text _GtkNotebook_ page))
		 (_gint3 (gtk_notebook_prepend_page _GtkNotebook_ (gtk_button_new_with_label "ha") (gtk_label_new "ho")))
		 (_gint6 (gtk_notebook_insert_page _GtkNotebook_ (gtk_button_new_with_label "ha") (gtk_label_new "ho") 1)))
	    (if (not (= _gint 0)) (snd-display #__line__ ";notebook page: ~A" _gint))
	    (if (not (= _gint1 -1)) (snd-display #__line__ ";notebook current page: ~A" _gint1))
	    (if (not _gboolean) (snd-display #__line__ ";notebook no border"))
	    (if (not _gboolean1) (snd-display #__line__ ";notebook no show tabs"))
	    (if (not (= _GtkPositionType 2)) (snd-display #__line__ ";notebook tab pos: ~A" _GtkPositionType))
	    (if _gboolean2 (snd-display #__line__ ";notebook scrollable"))
	    (if (not (= _int 1)) (snd-display #__line__ ";notebook pages: ~A" _int))
	    (if (not (equal? _GtkWidget_ page)) (snd-display #__line__ ";notebook page widget: ~A ~A" _GtkWidget_ page))
	    (if (not (= _gint2 0)) (snd-display #__line__ ";notebook page num: ~A" _gint2))
	    (if (not (string=? _gchar_ "ho")) (snd-display #__line__ ";notebook tab label: ~A" _gchar_))
	    (if (not (= _gint3 0)) (snd-display #__line__ ";notebook prepend to: ~A" _gint3))
	    (if (not (= _gint6 1)) (snd-display #__line__ ";notebook insert to: ~A" _gint6))
	    (gtk_notebook_set_current_page _GtkNotebook_ 1)
	    (gtk_notebook_next_page _GtkNotebook_)
	    (gtk_notebook_prev_page _GtkNotebook_)
	    (gtk_notebook_popup_enable _GtkNotebook_)
	    (gtk_notebook_popup_disable _GtkNotebook_)
	    (gtk_notebook_remove_page _GtkNotebook_ 1)
	    (gtk_notebook_set_show_border _GtkNotebook_ #t)
	    (gtk_notebook_set_show_tabs _GtkNotebook_ #t)
	    (gtk_notebook_set_tab_pos _GtkNotebook_ GTK_POS_TOP)
	    (gtk_notebook_set_scrollable _GtkNotebook_ #t)
	    (gtk_notebook_set_tab_label_text _GtkNotebook_ page "yow")
	    (gtk_notebook_reorder_child _GtkNotebook_ _GtkWidget_ 0)
	    ;;	    (gtk_notebook_set_tab_label_packing _GtkNotebook_ page #f #f GTK_PACK_START)
	    ;;	    (let ((vals (gtk_notebook_query_tab_label_packing _GtkNotebook_ page)))
	    ;;	      (if (not (equal? vals (list #f #f GTK_PACK_START))) (snd-display #__line__ ";notebook tab pack: ~A" vals)))
	    (gtk_notebook_set_tab_label _GtkNotebook_ page (gtk_label_new "ho")))
	  
	  (let* ((_GtkHandleBox_ (GTK_HANDLE_BOX (gtk_handle_box_new)))
		 (_GtkShadowType (gtk_handle_box_get_shadow_type _GtkHandleBox_))
		 (_GtkPositionType (gtk_handle_box_get_handle_position _GtkHandleBox_))
		 (_GtkPositionType1 (gtk_handle_box_get_snap_edge _GtkHandleBox_)))
	    (gtk_handle_box_set_shadow_type _GtkHandleBox_ GTK_SHADOW_IN)
	    (gtk_handle_box_set_handle_position _GtkHandleBox_ GTK_POS_TOP)
	    (gtk_handle_box_set_snap_edge _GtkHandleBox_ GTK_POS_TOP))
	  
	  (let* ((_GSList_ (gtk_stock_list_ids))
		 (_GtkWidget_ (cadr (main-widgets)))
		 (shell _GtkWidget_)
		 (_GdkColor_ (let ((tmp (GdkColor)))
			       (gdk_color_parse "red" tmp)
			       (let ((col (gdk_color_copy tmp)))
				 (gdk_rgb_find_color (gdk_colormap_get_system) col)
				 col)))
		 (_GtkWidget5_ (gtk_label_new "hi"))
		 (_GdkDisplay_ (gdk_display_get_default))
		 (_GdkWindow_ (gtk_widget_get_parent_window (list-ref (main-widgets) 2)))
		 (_GtkStyle_ (gtk_style_new))
		 (_GtkStyle2_ (gtk_widget_get_default_style))
		 (_GtkTextDirection (gtk_widget_get_default_direction))
		 (_GtkStyle1_ (gtk_style_copy _GtkStyle_))
		 (_GtkStyle2_ (gtk_widget_get_style _GtkWidget_))
		 (_GtkStyle3_ (gtk_style_attach _GtkStyle_ _GdkWindow_))
		 (_GtkWidget1_ _GtkWidget_)
		 (_gboolean (gtk_widget_activate _GtkWidget_))
		 (_gboolean1 (gtk_widget_is_focus _GtkWidget_))
		 (_gchar_ (gtk_widget_get_name _GtkWidget_))
		 (_gboolean2 (gtk_widget_get_child_visible _GtkWidget_))
		 (_GtkWidget2_ (gtk_widget_get_parent _GtkWidget_))
		 (_GtkWidget3_ (gtk_widget_get_toplevel _GtkWidget_))
		 (_GdkVisual_ (gtk_widget_get_visual _GtkWidget_))
		 (_AtkObject_ (gtk_widget_get_accessible _GtkWidget_))
		 (_gint (gtk_widget_get_events _GtkWidget_))
		 (_GtkRcStyle_ (gtk_widget_get_modifier_style _GtkWidget_))
		 (_PangoContext_ (gtk_widget_create_pango_context _GtkWidget_))
		 (_PangoContext1_ (gtk_widget_get_pango_context _GtkWidget_))
		 (_gchar1_ (gtk_widget_get_composite_name _GtkWidget_))
		 (_GtkTextDirection1 (gtk_widget_get_direction _GtkWidget_))
		 (_GdkScreen_ (gtk_widget_get_screen _GtkWidget_))
		 (_gboolean4 (gtk_widget_has_screen _GtkWidget_))
		 (_GdkDisplay_ (gtk_widget_get_display _GtkWidget_))
		 (_gboolean5 (gtk_widget_get_no_show_all _GtkWidget_))
		 (_GList_ (gtk_widget_list_mnemonic_labels _GtkWidget_))
		 (_GdkRegion_ (gtk_widget_region_intersect _GtkWidget_ (gdk_region_new)))
		 (_gboolean8 (gtk_widget_child_focus _GtkWidget_ GTK_DIR_TAB_FORWARD))
		 (_gboolean9 (gtk_widget_is_ancestor shell _GtkWidget_))
		 (_PangoLayout_ (gtk_widget_create_pango_layout _GtkWidget_ "hi"))
		 (_gboolean11 (gtk_widget_intersect _GtkWidget_ (GdkRectangle 0 0 10 10) (GdkRectangle 10 10 100 100)))
		 (vals (gtk_widget_get_size_request shell))
		 (vals1 (gtk_widget_get_pointer shell))
		 (_GList1_ (gtk_widget_list_accel_closures _GtkWidget_))
		 (_list (gtk_widget_translate_coordinates _GtkWidget_ _GtkWidget_ 0 0)))
	    (if (not (= _GtkTextDirection 1)) (snd-display #__line__ ";gtk widget default dir: ~A" _GtkTextDirection))
	    (if _gboolean (snd-display #__line__ ";gtk widget activated"))
	    (if _gboolean1 (snd-display #__line__ ";gtk widget focussed"))
	    (if (not (string=? _gchar_ "GtkWindow")) (snd-display #__line__ ";gtk widget name: ~A" _gchar_))
	    (if (not _gboolean2) (snd-display #__line__ ";gtk widget child not visible"))
	    (if (not (= _gint 65536)) (snd-display #__line__ ";gtk widget events: ~A" _gint))
	    (if (not (= _GtkTextDirection1 1)) (snd-display #__line__ ";gtk widget get dir: ~A" _GtkTextDirection1))  
	    (if (not _gboolean4) (snd-display #__line__ ";gtk widget no screen"))
	    (if _gboolean5 (snd-display #__line__ ";gtk widget show all"))
	    (if (not _gboolean8) (snd-display #__line__ ";gtk widget child not focussed"))
	    (if _gboolean9 (snd-display #__line__ ";gtk widget ancestor shell"))
	    (if (not _gboolean11) (snd-display #__line__ ";gtk widget no intersect"))
	    (if (not (equal? vals (list -1 -1))) (snd-display #__line__ ";gtk widget size request: ~A" vals))
	    (gtk_widget_modify_fg _GtkWidget5_ GTK_STATE_NORMAL _GdkColor_)
	    (gtk_widget_modify_bg _GtkWidget5_ GTK_STATE_NORMAL _GdkColor_)
	    (gtk_widget_modify_text _GtkWidget5_ GTK_STATE_NORMAL _GdkColor_)
	    (gtk_widget_modify_base _GtkWidget5_ GTK_STATE_NORMAL _GdkColor_)
	    (gtk_widget_set_events _GtkWidget5_ 0)
	    (gtk_widget_add_events _GtkWidget5_ 0)
	    (gtk_widget_set_direction _GtkWidget5_ GTK_TEXT_DIR_RTL)
	    (gtk_widget_set_no_show_all _GtkWidget5_ #f)
	    (gtk_widget_set_size_request _GtkWidget5_ 100 100)
	    (gtk_style_detach _GtkStyle_)
	    (gtk_widget_set_style _GtkWidget5_ _GtkStyle_)
	    (gtk_style_set_background _GtkStyle_ _GdkWindow_ GTK_STATE_NORMAL)
	    (gtk_widget_freeze_child_notify _GtkWidget5_)
	    (gtk_widget_thaw_child_notify _GtkWidget5_)
	    (gtk_widget_grab_focus _GtkWidget5_)
	    (gtk_widget_set_name _GtkWidget5_ "hi")
	    (gtk_widget_set_state _GtkWidget5_ GTK_STATE_NORMAL)
	    (gtk_widget_set_sensitive _GtkWidget5_ #f)
	    (gtk_widget_set_app_paintable _GtkWidget5_ #t)
	    (gtk_widget_set_double_buffered _GtkWidget5_ #t)
	    (gtk_widget_set_redraw_on_allocate _GtkWidget5_ #t)
	    (gtk_widget_set_parent _GtkWidget5_ _GtkWidget_)
	    (gtk_widget_queue_resize_no_redraw _GtkWidget5_)
	    (gtk_widget_ensure_style _GtkWidget5_)
	    (gtk_widget_reset_rc_styles _GtkWidget5_)
	    (gtk_widget_set_default_direction GTK_TEXT_DIR_LTR)
	    (gtk_widget_reset_shapes _GtkWidget5_)
	    (gtk_widget_queue_draw_area _GtkWidget5_ 0 0 100 100)
	    (set! _gchar_ (gtk_widget_get_name _GtkWidget5_))
	    (if (not (string=? _gchar_ "hi")) (snd-display #__line__ ";set gtk widget name: ~A" _gchar_)))
	  
	  (let* ((_GtkFrame_ (GTK_FRAME (gtk_frame_new "hi")))
		 (_GtkAspectFrame_ (GTK_ASPECT_FRAME (gtk_aspect_frame_new "hi" 1.0 2.0 3.0 #f)))
		 (_gchar_ (gtk_frame_get_label _GtkFrame_))
		 (_GtkWidget_ (gtk_frame_get_label_widget _GtkFrame_))
		 (_GtkShadowType (gtk_frame_get_shadow_type _GtkFrame_)))
	    (if (not (string=? _gchar_ "hi")) (snd-display #__line__ ";frame label: ~A" _gchar_))
	    (gtk_frame_set_label _GtkFrame_ "ho") ; actually sets label widget
	    (gtk_frame_set_label_widget _GtkFrame_ (gtk_label_new "ha"))
	    (if (not (= _GtkShadowType GTK_SHADOW_ETCHED_IN)) (snd-display #__line__ ";frame shadow: ~A" _GtkShadowType))
	    (gtk_frame_set_shadow_type _GtkFrame_ GTK_SHADOW_OUT)
	    (set! _GtkShadowType (gtk_frame_get_shadow_type _GtkFrame_))
	    (if (not (= _GtkShadowType GTK_SHADOW_OUT)) (snd-display #__line__ ";set frame shadow: ~A" _GtkShadowType))
	    (gtk_frame_set_label_align _GtkFrame_ .1 .1)
	    (let ((vals (gtk_frame_get_label_align _GtkFrame_)))
	      (if (not (feql vals (list .1 .1))) (snd-display #__line__ ";set frame align: ~A" vals)))
	    (gtk_aspect_frame_set _GtkAspectFrame_ .1 .2 .3 #f))
	  
	  (let* ((_GtkDialog_ (GTK_DIALOG (gtk_dialog_new)))
		 (_gchar_ "dialog")
		 (_GtkColorSelectionDialog_ (GTK_COLOR_SELECTION_DIALOG (gtk_color_selection_dialog_new _gchar_)))
		 (_GtkColorSelection_ (GTK_COLOR_SELECTION (gtk_color_selection_new)))
		 (_GtkFontSelectionDialog_ (GTK_FONT_SELECTION_DIALOG (gtk_font_selection_dialog_new _gchar_)))
		 (_GtkFontSelection_ (GTK_FONT_SELECTION (gtk_font_selection_new)))
		 (dialog (gtk_dialog_new_with_buttons "title" (GTK_WINDOW (cadr (main-widgets))) 0 
						      (list GTK_STOCK_OK GTK_RESPONSE_ACCEPT GTK_STOCK_CANCEL GTK_RESPONSE_REJECT)))
					;		 (_GtkFileChooser_ (GTK_FILE_CHOOSER (gtk_file_chooser_widget_new GTK_FILE_CHOOSER_ACTION_OPEN)))
					;		 (_GtkFileChooserDialog_ (GTK_FILE_CHOOSER_DIALOG (gtk_file_chooser_dialog_new 
					;								   "save" (GTK_WINDOW (cadr (main-widgets)))
					;								   GTK_FILE_CHOOSER_ACTION_SAVE (list GTK_STOCK_OK GTK_RESPONSE_ACCEPT))))
					;		 (_GtkFileSelection_ (GTK_FILE_SELECTION (gtk_file_selection_new "delete")))
					;		 (_GtkWidget_ (gtk_file_chooser_widget_new_with_backend 0 "linux"))
		 (_GtkFileFilter_ (gtk_file_filter_new))
		 (_GdkColor_ (let ((tmp (GdkColor)))
			       (gdk_color_parse "red" tmp)
			       (let ((col (gdk_color_copy tmp)))
				 (gdk_rgb_find_color (gdk_colormap_get_system) col)
				 col)))
		 
		 (_gboolean (gtk_color_selection_get_has_opacity_control _GtkColorSelection_))
		 (_gboolean1 (gtk_color_selection_get_has_palette _GtkColorSelection_))
		 (_guint16 (gtk_color_selection_get_current_alpha _GtkColorSelection_))
		 (_guint161 (gtk_color_selection_get_previous_alpha _GtkColorSelection_))
		 (_gboolean2 (gtk_color_selection_is_adjusting _GtkColorSelection_))
		 (_gchar_1 (gtk_font_selection_get_font_name _GtkFontSelection_))
		 (_gchar_2 (gtk_font_selection_get_preview_text _GtkFontSelection_))
		 (_gchar_3 (gtk_font_selection_dialog_get_font_name _GtkFontSelectionDialog_))
		 (_gchar_4 (gtk_font_selection_dialog_get_preview_text _GtkFontSelectionDialog_))
		 (_gboolean3 (gtk_dialog_get_has_separator _GtkDialog_))
		 (_GtkWidget_1 (gtk_dialog_add_button _GtkDialog_ "yow" 1))
		 )
	    (if (not _gboolean) (snd-display #__line__ ";dialog opacity"))
	    (if _gboolean1 (snd-display #__line__ ";dialog palette"))
	    (if (not (= _guint16 65535)) (snd-display #__line__ ";dialog alpha: ~A" _guint16))
	    (if (not (= _guint161 65535)) (snd-display #__line__ ";dialog prev alpha: ~A" _guint161))
	    (if _gboolean2 (snd-display #__line__ ";dialog adjusting"))
	    (if (not (string=? _gchar_1 "Sans 10")) (snd-display #__line__ ";dialog font: ~A" _gchar_1))
	    (if (not (string=? _gchar_4 "abcdefghijk ABCDEFGHIJK")) (snd-display #__line__ ";dialog preview text: ~A" _gchar_4))
	    (if (not _gboolean3) (snd-display #__line__ ";dialog no sep"))
	    (gtk_color_selection_set_current_alpha _GtkColorSelection_ 12345)
	    (gtk_color_selection_set_previous_alpha _GtkColorSelection_ 54321)
	    (gtk_dialog_set_default_response _GtkDialog_ 0)
	    (gtk_color_selection_set_has_palette _GtkColorSelection_ #t)
	    (gtk_color_selection_set_current_color _GtkColorSelection_ _GdkColor_)
	    (gtk_color_selection_get_current_color _GtkColorSelection_ _GdkColor_)
	    (gtk_color_selection_set_previous_color _GtkColorSelection_ _GdkColor_)
	    (gtk_color_selection_get_previous_color _GtkColorSelection_ _GdkColor_)
	    (gtk_color_selection_palette_to_string _GdkColor_ 0)
	    (gtk_dialog_set_response_sensitive _GtkDialog_ 0 #f)
	    (gtk_color_selection_palette_from_string "hiho")
	    (gtk_dialog_response _GtkDialog_ 0)
	    (gtk_dialog_add_action_widget _GtkDialog_ (gtk_button_new_with_label "hi") 0))
	  
	  (let* ((_GtkUIManager_ (gtk_ui_manager_new))
		 (_GtkActionGroup_ (gtk_action_group_new "unique-name"))
		 (_gchar_ (gtk_action_group_get_name _GtkActionGroup_))
		 (_gboolean (gtk_action_group_get_sensitive _GtkActionGroup_))
		 (_gboolean1 (gtk_action_group_get_visible _GtkActionGroup_))
		 (_gboolean2 (gtk_ui_manager_get_add_tearoffs _GtkUIManager_))
		 (_GtkAction_ (gtk_action_new "unique" "label" "tooltip" GTK_STOCK_HELP))
		 (_GtkToggleAction_ (gtk_toggle_action_new "hiho" "label" "tooltip" GTK_STOCK_CANCEL))
		 (_gboolean3 (gtk_toggle_action_get_draw_as_radio _GtkToggleAction_))
		 (_guint (gtk_ui_manager_new_merge_id _GtkUIManager_))
		 (_gchar1_ (gtk_action_get_name _GtkAction_))
		 (_gboolean4 (gtk_action_is_sensitive _GtkAction_))
		 (_gboolean5 (gtk_action_get_sensitive _GtkAction_))
		 (_gboolean6 (gtk_action_is_visible _GtkAction_))
		 (_gboolean7 (gtk_action_get_visible _GtkAction_)))
	    (gtk_action_group_add_action _GtkActionGroup_ _GtkAction_)
	    (gtk_action_group_remove_action _GtkActionGroup_ _GtkAction_)
					;	      (gtk_action_group_add_action_with_accel _GtkActionGroup_ _GtkAction_ "hiho")
					; this line leads to later trouble with gtk_file_chooser!
	    (gtk_action_group_set_sensitive _GtkActionGroup_ #t)
	    (gtk_action_group_set_visible _GtkActionGroup_ #t)
	    (gtk_toggle_action_set_active _GtkToggleAction_ #t)
	    (gtk_toggle_action_set_draw_as_radio _GtkToggleAction_ #f)
					;	      (let ((_GtkAction_1 (gtk_action_group_get_action _GtkActionGroup_ "unique")))
					;		(if (not (equal? _GtkAction_ _GtkAction_1)) (snd-display #__line__ ";gtk_action_group_get_action: ~A, returned ~A" _GtkAction_ _GtkAction_1)))
					; appears to depend on test above commented out
	    (gtk_ui_manager_insert_action_group _GtkUIManager_ _GtkActionGroup_ 0)
	    (gtk_ui_manager_set_add_tearoffs _GtkUIManager_ #f)
	    (gtk_ui_manager_remove_action_group _GtkUIManager_ _GtkActionGroup_)
	    (gtk_ui_manager_add_ui _GtkUIManager_ _guint home-dir "hiho" #f GTK_UI_MANAGER_SEPARATOR #f)
	    (gtk_ui_manager_get_action_groups _GtkUIManager_)
	    (gtk_ui_manager_get_accel_group _GtkUIManager_)
	    (gtk_ui_manager_get_ui _GtkUIManager_)
	    (gtk_ui_manager_remove_ui _GtkUIManager_ _guint))
	  
	  (let* ((_GtkFixed_ (GTK_FIXED (gtk_fixed_new))))
	    (gtk_fixed_put _GtkFixed_ (gtk_label_new "hi") 0 0)
	    (let* ((_gpointer (g_object_ref (GPOINTER _GtkFixed_)))
		   (_GType (G_OBJECT_TYPE (GTK_OBJECT _GtkFixed_)))
		   (_GType1 (G_OBJECT_TYPE (GTK_OBJECT (gtk_label_new "hi"))))
		   (_gboolean1 (g_type_is_a _GType _GType1)))
	      (g_object_set_data (G_OBJECT _GtkFixed_) "hiho" (GPOINTER 123))
	      (g_object_unref _gpointer)
					;		(g_free _gpointer)
	      ))
	  
	  (let* ((_GtkTextChildAnchor_ (gtk_text_child_anchor_new))
		 (_GtkTextAttributes_ (gtk_text_attributes_new))		
		 (_GtkTextTagTable_ (gtk_text_tag_table_new))
		 (_GtkTextView_ (GTK_TEXT_VIEW (gtk_text_view_new)))
		 (_GtkTextBuffer_ (gtk_text_buffer_new _GtkTextTagTable_))
		 (_GtkTextTag_ (gtk_text_tag_new "tag-name?"))
		 (_GtkTextView_1 (GTK_TEXT_VIEW (gtk_text_view_new_with_buffer _GtkTextBuffer_)))
		 (_GtkTextIter_ (GtkTextIter)))
	    (gtk_text_buffer_get_iter_at_offset _GtkTextBuffer_ _GtkTextIter_ 0)
	    (let ((_GtkTextMark_ (gtk_text_buffer_create_mark _GtkTextBuffer_ "mark-name" _GtkTextIter_ #t)))
	      (gtk_text_buffer_insert _GtkTextBuffer_ _GtkTextIter_ "hiho" 4)
	      (let* ((_GtkTextChildAnchor_1 (gtk_text_buffer_create_child_anchor _GtkTextBuffer_ _GtkTextIter_))
		     (_GtkTextTag_1 (gtk_text_buffer_create_tag _GtkTextBuffer_ "a-tag"))
		     (_GtkTextIter_1 (gtk_text_iter_copy _GtkTextIter_))
		     (_GtkTextTagTable_ (gtk_text_buffer_get_tag_table _GtkTextBuffer_))
		     (_GtkTextMark_1 (gtk_text_buffer_get_insert _GtkTextBuffer_))
		     (_GtkTextBuffer_1 (gtk_text_iter_get_buffer _GtkTextIter_1))
		     (_GtkTextChildAnchor_2 (gtk_text_iter_get_child_anchor _GtkTextIter_))
		     (_GtkTextBuffer_2 (gtk_text_mark_get_buffer _GtkTextMark_1))
		     (_GtkTextBuffer_3 (gtk_text_view_get_buffer _GtkTextView_1))
		     (_GtkTextAttributes_1 (gtk_text_view_get_default_attributes _GtkTextView_1))
		     (_GtkTextAttributes_2 (gtk_text_attributes_copy _GtkTextAttributes_1))
		     (_GtkTextTag_2 (gtk_text_tag_table_lookup _GtkTextTagTable_ "a-tag"))
		     (_gint (gtk_text_buffer_get_line_count _GtkTextBuffer_))
		     (_gint1 (gtk_text_buffer_get_char_count _GtkTextBuffer_))
		     (_gint2 (gtk_text_iter_get_offset _GtkTextIter_))
		     (_gint3 (gtk_text_iter_get_line _GtkTextIter_))
		     (_gint4 (gtk_text_iter_get_line_offset _GtkTextIter_))
		     (_gint5 (gtk_text_iter_get_line_index _GtkTextIter_))
		     (_gint6 (gtk_text_iter_get_visible_line_offset _GtkTextIter_))
		     (_gint7 (gtk_text_iter_get_visible_line_index _GtkTextIter_))
		     (_gint8 (gtk_text_iter_get_chars_in_line _GtkTextIter_))
		     (_gint9 (gtk_text_iter_get_bytes_in_line _GtkTextIter_))
		     (_gint10 (gtk_text_tag_get_priority _GtkTextTag_1))
		     (_gint11 (gtk_text_tag_table_get_size _GtkTextTagTable_))
		     (_gint12 (gtk_text_view_get_left_margin _GtkTextView_1))
		     (_gint13 (gtk_text_view_get_right_margin _GtkTextView_1))
		     (_gint14 (gtk_text_view_get_indent _GtkTextView_1))
		     (_gint15 (gtk_text_view_get_pixels_above_lines _GtkTextView_1))
		     (_gint16 (gtk_text_view_get_pixels_below_lines _GtkTextView_1))
		     (_gint17 (gtk_text_view_get_pixels_inside_wrap _GtkTextView_1))
		     (_gint18 (gtk_text_iter_compare _GtkTextIter_ _GtkTextIter_1))
		     (_gboolean (gtk_text_buffer_get_modified _GtkTextBuffer_))
		     (_gboolean1 (gtk_text_iter_starts_word _GtkTextIter_))
		     (_gboolean2 (gtk_text_iter_ends_word _GtkTextIter_))
		     (_gboolean3 (gtk_text_iter_inside_word _GtkTextIter_))
		     (_gboolean4 (gtk_text_iter_starts_sentence _GtkTextIter_))
		     (_gboolean5 (gtk_text_iter_ends_sentence _GtkTextIter_))
		     (_gboolean6 (gtk_text_iter_inside_sentence _GtkTextIter_))
		     (_gboolean7 (gtk_text_iter_starts_line _GtkTextIter_))
		     (_gboolean8 (gtk_text_iter_ends_line _GtkTextIter_))
		     (_gboolean9 (gtk_text_iter_is_cursor_position _GtkTextIter_))
		     (_gboolean10 (gtk_text_iter_is_end _GtkTextIter_))
		     (_gboolean11 (gtk_text_iter_is_start _GtkTextIter_))
		     (_gboolean12 (gtk_text_view_get_editable _GtkTextView_1))
		     (_gboolean13 (gtk_text_view_get_overwrite _GtkTextView_1))
		     (_gboolean14 (gtk_text_view_get_accepts_tab _GtkTextView_1))
		     (_gboolean15 (gtk_text_iter_equal _GtkTextIter_ _GtkTextIter_1))
		     (_gboolean16 (gtk_text_iter_begins_tag _GtkTextIter_ _GtkTextTag_))
		     (_gboolean17 (gtk_text_iter_ends_tag _GtkTextIter_ _GtkTextTag_))
		     (_gboolean18 (gtk_text_iter_toggles_tag _GtkTextIter_ _GtkTextTag_))
		     (_gboolean19 (gtk_text_iter_has_tag _GtkTextIter_ _GtkTextTag_))
		     (_gboolean20 (gtk_text_iter_get_attributes _GtkTextIter_ _GtkTextAttributes_2))
		     (_gboolean21 (gtk_text_mark_get_visible _GtkTextMark_))
		     (_gunichar (gtk_text_iter_get_char _GtkTextIter_)) 
		     (_PangoLanguage_ (gtk_text_iter_get_language _GtkTextIter_))
		     (_char_ (gtk_text_mark_get_name _GtkTextMark_))
		     (_GtkWrapMode (gtk_text_view_get_wrap_mode _GtkTextView_1))
		     (_GtkJustification (gtk_text_view_get_justification _GtkTextView_1))
		     (_PangoTabArray_ (gtk_text_view_get_tabs _GtkTextView_1))
		     (_GtkTextMark_2 (gtk_text_buffer_get_mark _GtkTextBuffer_ "mark-name")))
		(if (not (equal? _GtkTextBuffer_ _GtkTextBuffer_1)) (snd-display #__line__ ";iter text buffer: ~A ~A" _GtkTextBuffer_ _GtkTextBuffer_1))
		(if (not (equal? _GtkTextBuffer_ _GtkTextBuffer_3)) (snd-display #__line__ ";view text buffer: ~A ~A" _GtkTextBuffer_ _GtkTextBuffer_3))
		(if (not (equal? _GtkTextBuffer_1 _GtkTextBuffer_2)) (snd-display #__line__ ";mark text buffer: ~A ~A" _GtkTextBuffer_1 _GtkTextBuffer_2))
		(if (not (equal? _GtkTextTag_1 _GtkTextTag_2)) (snd-display #__line__ ";view text tag: ~A ~A" _GtkTextTag_1 _GtkTextTag_2))
		(if (not (= _gint 1)) (snd-display #__line__ ";text lines: ~A" _gint))
		(if (not (= _gint1 5)) (snd-display #__line__ ";text chars: ~A" _gint1))
		(if (not (= _gint2 5)) (snd-display #__line__ ";text iter offset:~A" _gint2))
		(if (not (= _gint3 0)) (snd-display #__line__ ";text iter line:~A" _gint3))
		(if (not (= _gint4 5)) (snd-display #__line__ ";text iter line offset:~A" _gint4))
		(if (not (= _gint5 7)) (snd-display #__line__ ";text iter index:~A" _gint5))
		(if (not (= _gint6 5)) (snd-display #__line__ ";text vis line offset:~A" _gint6))
		(if (not (= _gint7 7)) (snd-display #__line__ ";text vis line index:~A" _gint7))
		(if (not (= _gint8 5)) (snd-display #__line__ ";text chars in line:~A" _gint8))
		(if (not (= _gint9 7)) (snd-display #__line__ ";text bytes in line:~A" _gint9))
		(if (not (= _gint10 0)) (snd-display #__line__ ";text priority:~A" _gint10))
		(if (not (= _gint11 1)) (snd-display #__line__ ";text table size:~A" _gint11))
		(if (not (= _gint12 0)) (snd-display #__line__ ";text left margin:~A" _gint12))
		(if (not (= _gint13 0)) (snd-display #__line__ ";text right margin:~A" _gint13))
		(if (not (= _gint14 0)) (snd-display #__line__ ";text indent:~A" _gint14))
		(if (not (= _gint15 0)) (snd-display #__line__ ";text above:~A" _gint15))
		(if (not (= _gint16 0)) (snd-display #__line__ ";text below:~A" _gint16))
		(if (not (= _gint17 0)) (snd-display #__line__ ";text inside:~A" _gint17))
		(if (not (= _gint18 0)) (snd-display #__line__ ";text iter compare:~A" _gint18))
		(if (not (eq? _gboolean #t)) (snd-display #__line__ ";text modified"))
		(if (not (eq? _gboolean1 #f)) (snd-display #__line__ ";text starts word"))
		(if (not (eq? _gboolean2 #f)) (snd-display #__line__ ";text ends word"))
		(if (not (eq? _gboolean3 #f)) (snd-display #__line__ ";text inside word"))
		(if (not (eq? _gboolean4 #f)) (snd-display #__line__ ";text starts sentence"))
		(if (not (eq? _gboolean5 #t)) (snd-display #__line__ ";text ends sentence"))
		(if (not (eq? _gboolean6 #f)) (snd-display #__line__ ";text inside sentence"))
		(if (not (eq? _gboolean7 #f)) (snd-display #__line__ ";text starts line"))
		(if (not (eq? _gboolean8 #t)) (snd-display #__line__ ";text ends line"))
		(if (not (eq? _gboolean9 #t)) (snd-display #__line__ ";text is cursor"))
		(if (not (eq? _gboolean10 #t)) (snd-display #__line__ ";text is end"))
		(if (not (eq? _gboolean11 #f)) (snd-display #__line__ ";text is start"))
		(if (not (eq? _gboolean12 #t)) (snd-display #__line__ ";text editable"))
		(if (not (eq? _gboolean13 #f)) (snd-display #__line__ ";text overwrite"))
		(if (not (eq? _gboolean14 #t)) (snd-display #__line__ ";text tabs"))
		(if (not (eq? _gboolean15 #t)) (snd-display #__line__ ";text iters equal"))
		(if (not (eq? _gboolean16 #f)) (snd-display #__line__ ";text begins tag"))
		(if (not (eq? _gboolean17 #f)) (snd-display #__line__ ";text ends tag"))
		(if (not (eq? _gboolean18 #f)) (snd-display #__line__ ";text toggles tag"))
		(if (not (eq? _gboolean19 #f)) (snd-display #__line__ ";text has attr"))
		(if (not (eq? _gboolean20 #f)) (snd-display #__line__ ";text get attr"))
		(if (not (eq? _gboolean21 #f)) (snd-display #__line__ ";text mark get visible"))
		(if (not (string=? _char_ "mark-name")) (snd-display #__line__ ";text mark name: ~A" _char_))
		(if (not (= _GtkWrapMode 0)) (snd-display #__line__ ";text wrap: ~A" _gtkWrapMode))
		(if (not (= _GtkJustification 0)) (snd-display #__line__ ";text just: ~A" _GtkJustification))
		(let* ((_gint 1)
		       (_gboolean22 (gtk_text_iter_backward_chars _GtkTextIter_ _gint))
		       (_gboolean23 (gtk_text_iter_forward_chars _GtkTextIter_ _gint))
		       (_gboolean24 (gtk_text_iter_backward_lines _GtkTextIter_ _gint))
		       (_gboolean25 (gtk_text_iter_forward_lines _GtkTextIter_ _gint))
		       (_gboolean26 (gtk_text_iter_forward_word_ends _GtkTextIter_ _gint))
		       (_gboolean27 (gtk_text_iter_backward_word_starts _GtkTextIter_ _gint))
		       (_gboolean28 (gtk_text_iter_forward_sentence_ends _GtkTextIter_ _gint))
		       (_gboolean29 (gtk_text_iter_backward_sentence_starts _GtkTextIter_ _gint))
		       (_gboolean30 (gtk_text_iter_forward_cursor_positions _GtkTextIter_ _gint))
		       (_gboolean31 (gtk_text_iter_backward_cursor_positions _GtkTextIter_ _gint))
		       (_gboolean32 (gtk_text_iter_forward_to_tag_toggle _GtkTextIter_ _GtkTextTag_))
		       (_gboolean33 (gtk_text_iter_backward_to_tag_toggle _GtkTextIter_ _GtkTextTag_))
		       (_gboolean34 (gtk_text_view_move_mark_onscreen _GtkTextView_1 _GtkTextMark_))
		       (_gboolean35 (gtk_text_view_forward_display_line _GtkTextView_1 _GtkTextIter_))
		       (_gboolean36 (gtk_text_view_backward_display_line _GtkTextView_1 _GtkTextIter_))
		       (_gboolean37 (gtk_text_view_forward_display_line_end _GtkTextView_1 _GtkTextIter_))
		       (_gboolean38 (gtk_text_view_backward_display_line_start _GtkTextView_1 _GtkTextIter_))
		       (_gboolean39 (gtk_text_view_starts_display_line _GtkTextView_1 _GtkTextIter_))
		       (_gboolean40 (gtk_text_iter_forward_char _GtkTextIter_))
		       (_gboolean41 (gtk_text_iter_backward_char _GtkTextIter_))
		       (_gboolean42 (gtk_text_iter_forward_line _GtkTextIter_))
		       (_gboolean43 (gtk_text_iter_backward_line _GtkTextIter_))
		       (_gboolean44 (gtk_text_iter_forward_word_end _GtkTextIter_))
		       (_gboolean45 (gtk_text_iter_backward_word_start _GtkTextIter_))
		       (_gboolean46 (gtk_text_iter_forward_sentence_end _GtkTextIter_))
		       (_gboolean47 (gtk_text_iter_backward_sentence_start _GtkTextIter_))
		       (_gboolean48 (gtk_text_iter_forward_cursor_position _GtkTextIter_))
		       (_gboolean49 (gtk_text_iter_backward_cursor_position _GtkTextIter_))
		       (_gboolean50 (gtk_text_iter_forward_to_line_end _GtkTextIter_))
		       (_gboolean51 (gtk_text_mark_get_deleted _GtkTextMark_))
		       (_gboolean52 (gtk_text_mark_get_left_gravity _GtkTextMark_))
		       (_gboolean53 (gtk_text_view_place_cursor_onscreen _GtkTextView_1))
		       (_gboolean54 (gtk_text_view_get_cursor_visible _GtkTextView_1)))
		  (gtk_text_view_set_pixels_above_lines _GtkTextView_1 _gint)
		  (gtk_text_view_set_pixels_below_lines _GtkTextView_1 _gint)
		  (gtk_text_view_set_pixels_inside_wrap _GtkTextView_1 _gint)
		  (gtk_text_view_set_justification _GtkTextView_1 _GtkJustification)
		  (gtk_text_view_set_left_margin _GtkTextView_1 _gint)
		  (gtk_text_view_set_right_margin _GtkTextView_1 _gint)
		  (gtk_text_view_set_indent _GtkTextView_1 _gint)
		  (gtk_text_iter_forward_to_end _GtkTextIter_)
					;		    (gtk_text_attributes_ref _GtkTextAttributes_)
		  (gtk_text_attributes_unref _GtkTextAttributes_)
		  (gtk_text_iter_set_offset _GtkTextIter_ _gint)
		  (gtk_text_iter_set_line _GtkTextIter_ _gint)
		  (gtk_text_iter_set_line_offset _GtkTextIter_ _gint)
		  (gtk_text_iter_set_line_index _GtkTextIter_ _gint)
		  (gtk_text_iter_set_visible_line_offset _GtkTextIter_ _gint)
		  (gtk_text_iter_set_visible_line_index _GtkTextIter_ _gint)
		  (gtk_text_buffer_set_text _GtkTextBuffer_ "hiho away" 0)
		  (gtk_text_buffer_get_iter_at_offset _GtkTextBuffer_ _GtkTextIter_ 0)
		  (let* ((_gboolean55 (gtk_text_iter_editable _GtkTextIter_ #t))
			 (_gboolean56 (gtk_text_iter_can_insert _GtkTextIter_ #t))
			 (_GSList_ (gtk_text_iter_get_marks _GtkTextIter_))
			 (_GSList_1 (gtk_text_iter_get_tags _GtkTextIter_))
			 (_GtkTextIter_3 (GtkTextIter))
			 (_GtkTextIter_4 (GtkTextIter))
			 (_GtkTextIter_5 (GtkTextIter))
			 (_GtkTextIter_6 (GtkTextIter))
			 (_GtkTextIter_7 (GtkTextIter))
			 (_GtkTextIter_8 (GtkTextIter)))
		    (gtk_text_buffer_get_iter_at_offset _GtkTextBuffer_ _GtkTextIter_4 5)
		    (gtk_text_buffer_get_iter_at_offset _GtkTextBuffer_ _GtkTextIter_3 _gint)
		    (gtk_text_buffer_get_iter_at_line _GtkTextBuffer_ _GtkTextIter_3 _gint)
		    (gtk_text_buffer_get_bounds _GtkTextBuffer_ _GtkTextIter_ _GtkTextIter_3)
		    (gtk_text_buffer_get_iter_at_mark _GtkTextBuffer_ _GtkTextIter_3 _GtkTextMark_)
		    (let* ((_gchar_ (gtk_text_iter_get_slice _GtkTextIter_ _GtkTextIter_4))
			   (_gchar_1 (gtk_text_iter_get_text _GtkTextIter_ _GtkTextIter_4))
			   (_gchar_2 (gtk_text_iter_get_visible_slice _GtkTextIter_ _GtkTextIter_4))
			   (_gchar_3 (gtk_text_iter_get_visible_text _GtkTextIter_ _GtkTextIter_4))
			   (_GtkTextMark_4 (gtk_text_buffer_create_mark _GtkTextBuffer_ "mark-name-1" _GtkTextIter_4 #t))
			   (_GtkTextMark_5 (gtk_text_buffer_create_mark _GtkTextBuffer_ "mark-name-2" _GtkTextIter_4 #t))
			   (vals (gtk_text_view_get_line_yrange _GtkTextView_1 _GtkTextIter_4))
			   (vals1 (gtk_text_view_get_line_at_y _GtkTextView_1 _GtkTextIter_4 0)))
		      (gtk_text_buffer_delete_mark _GtkTextBuffer_ _GtkTextMark_4)
		      (gtk_text_buffer_delete_mark_by_name _GtkTextBuffer_ "mark-name")
		      (gtk_text_buffer_delete _GtkTextBuffer_ _GtkTextIter_ _GtkTextIter_4)
		      (gtk_text_buffer_move_mark _GtkTextBuffer_ _GtkTextMark_5 _GtkTextIter_)
		      (gtk_text_buffer_move_mark_by_name _GtkTextBuffer_ "mark-name-2" _GtkTextIter_)
					;			(gtk_text_iter_free _GtkTextIter_3)
		      (gtk_text_buffer_place_cursor _GtkTextBuffer_ _GtkTextIter_)
		      (gtk_text_buffer_get_start_iter _GtkTextBuffer_ _GtkTextIter_5)
		      (gtk_text_buffer_get_end_iter _GtkTextBuffer_ _GtkTextIter_6)
		      (gtk_text_buffer_select_range _GtkTextBuffer_ _GtkTextIter_5 _GtkTextIter_6)
		      (gtk_text_view_get_iter_at_location _GtkTextView_ _GtkTextIter_ 0 0)
		      (let* ((_gchar_4 (gtk_text_buffer_get_text _GtkTextBuffer_ _GtkTextIter_5 _GtkTextIter_6 #t))
			     (_gchar_5 (gtk_text_buffer_get_slice _GtkTextBuffer_ _GtkTextIter_5 _GtkTextIter_6 #t))
			     (_GtkTextMark_6 (gtk_text_buffer_get_selection_bound _GtkTextBuffer_))
			     (_gboolean57 (gtk_text_buffer_get_selection_bounds _GtkTextBuffer_ _GtkTextIter_7 _GtkTextIter_8))
			     (_GtkTextAttributes_3 (gtk_text_attributes_new))
			     (_GdkRectangle_ (GdkRectangle))		
			     (_GtkTextTag_3 (gtk_text_buffer_create_tag _GtkTextBuffer_ "a-tag-1")))
			(gtk_text_buffer_get_iter_at_offset _GtkTextBuffer_ _GtkTextIter_ 0)
			(gtk_text_buffer_insert _GtkTextBuffer_ _GtkTextIter_ "hiho again" 10)
			(gtk_text_tag_set_priority _GtkTextTag_2 0)
					;			  (gtk_text_attributes_copy_values _GtkTextAttributes_3 _GtkTextAttributes_)
			(gtk_text_view_set_buffer _GtkTextView_ _GtkTextBuffer_)
			(gtk_text_view_set_cursor_visible _GtkTextView_ #f)
			(gtk_text_view_set_wrap_mode _GtkTextView_ 0)
			(gtk_text_view_set_editable _GtkTextView_ #t)
			(gtk_text_view_set_tabs _GtkTextView_ _PangoTabArray_)
			(gtk_text_view_set_overwrite _GtkTextView_ #f)
			(gtk_text_view_set_accepts_tab _GtkTextView_ #t)
			(gtk_text_buffer_insert _GtkTextBuffer_ _GtkTextIter_ "hiho" 1)
			(gtk_text_buffer_get_iter_at_line_offset _GtkTextBuffer_ _GtkTextIter_7 0 3)
			(gtk_text_buffer_get_iter_at_line_index _GtkTextBuffer_ _GtkTextIter_8 0 0)
			(gtk_text_view_get_iter_location _GtkTextView_ _GtkTextIter_7 _GdkRectangle_)
			(let* ((_GdkPixbuf_ (gtk_text_iter_get_pixbuf _GtkTextIter_))
			       (_GSList_ (gtk_text_iter_get_toggled_tags _GtkTextIter_ _gboolean))
			       (_gboolean (gtk_text_iter_in_range _GtkTextIter_ _GtkTextIter_ _GtkTextIter_))
			       (_gboolean (gtk_text_view_move_visually _GtkTextView_ _GtkTextIter_ _gint))
			       (_gboolean (gtk_text_buffer_insert_interactive_at_cursor _GtkTextBuffer_ _gchar_ _gint _gboolean))
			       (_gboolean (gtk_text_buffer_delete_interactive _GtkTextBuffer_ _GtkTextIter_ _GtkTextIter_ _gboolean))
			       (_gboolean (gtk_text_iter_forward_find_char _GtkTextIter_ (lambda (ch x) #t) #f _GtkTextIter_))
			       (_gboolean (gtk_text_iter_backward_find_char _GtkTextIter_ (lambda (ch x) #t) #f _GtkTextIter_))
			       (_gboolean (gtk_text_buffer_insert_interactive _GtkTextBuffer_ _GtkTextIter_ "hi" _gint _gboolean))
			       (_gboolean (gtk_text_iter_forward_search _GtkTextIter_ _gchar_ GTK_TEXT_SEARCH_TEXT_ONLY 
									_GtkTextIter_ _GtkTextIter_ _GtkTextIter_))
			       (_gboolean (gtk_text_iter_backward_search _GtkTextIter_ _gchar_ GTK_TEXT_SEARCH_TEXT_ONLY 
									 _GtkTextIter_ _GtkTextIter_ _GtkTextIter_))
			       (_gboolean (gtk_text_view_scroll_to_iter _GtkTextView_ _GtkTextIter_ .1 #f .3 .4))
			       (_GdkDisplay_ (gdk_display_get_default))
			       (_GdkAtom (gdk_atom_intern "PRIMARY" #f))
			       (_GtkClipboard_ (gtk_clipboard_get_for_display _GdkDisplay_ _GdkAtom)))
			  (gtk_text_buffer_begin_user_action _GtkTextBuffer_)
			  (gtk_text_buffer_end_user_action _GtkTextBuffer_)
			  (gtk_text_buffer_set_modified _GtkTextBuffer_ _gboolean)
			  (gtk_text_buffer_add_selection_clipboard _GtkTextBuffer_ _GtkClipboard_)
			  (gtk_text_buffer_remove_selection_clipboard _GtkTextBuffer_ _GtkClipboard_)
			  (gtk_text_buffer_copy_clipboard _GtkTextBuffer_ _GtkClipboard_)
			  (gtk_text_iter_order _GtkTextIter_ _GtkTextIter_)
			  (gtk_text_view_get_visible_rect _GtkTextView_ _GdkRectangle_)
			  (gtk_text_buffer_insert_at_cursor _GtkTextBuffer_ "hi" _gint)
			  (gtk_text_buffer_cut_clipboard _GtkTextBuffer_ _GtkClipboard_ _gboolean)
			  (gtk_text_tag_table_foreach _GtkTextTagTable_ (lambda (a b) #f) #f)))))))))
	  
	  (let* ((_gchar_ (g_signal_name 1))
		 (_guint (g_idle_add (lambda (n) #t) #f))
		 (_guint1 (g_timeout_add 200 (lambda (n) #t) #f))
		 (_GtkEventBox_ (GTK_EVENT_BOX (gtk_event_box_new)))
		 (_guint32 (gtk_get_current_event_time)))
	    (if (not (string=? _gchar_ "notify")) (snd-display #__line__ ";g signal name: ~A" _gchar_))
	    (g_source_remove _guint)
	    (g_source_remove _guint1)
	    (gtk_event_box_set_visible_window _GtkEventBox_ #f)
	    (gtk_event_box_set_above_child _GtkEventBox_ #f)
	    (let* ((_gboolean (gtk_event_box_get_visible_window _GtkEventBox_))
		   (_gboolean1 (gtk_event_box_get_above_child _GtkEventBox_)))
	      (if _gboolean (snd-display #__line__ ";event box visible"))
	      (if _gboolean1 (snd-display #__line__ ";event box above")))
	    (let* ((_PangoCoverage_ (pango_coverage_new))
		   (_PangoCoverage_1 (pango_coverage_ref _PangoCoverage_))
		   (_PangoCoverage_2 (pango_coverage_copy _PangoCoverage_))
		   (_PangoCoverageLevel (pango_coverage_get _PangoCoverage_ 0))
		   (vals (pango_coverage_to_bytes _PangoCoverage_)))
	      (pango_coverage_unref _PangoCoverage_1)
	      (pango_coverage_max _PangoCoverage_ _PangoCoverage_2)
	      (pango_coverage_set _PangoCoverage_ 0 _PangoCoverageLevel)
	      (let* ((_PangoCoverage_ (pango_coverage_from_bytes "hi" 0)))
		#f)))
	  
	  (let* ((_GtkFontButton_ (GTK_FONT_BUTTON (gtk_font_button_new)))
		 (_GtkColorButton_ (GTK_COLOR_BUTTON (gtk_color_button_new)))
		 (_GtkFontButton_1 (GTK_FONT_BUTTON (gtk_font_button_new_with_font "Monospace 10")))
		 (_GdkColor_ (let ((tmp (GdkColor)))
			       (gdk_color_parse "red" tmp)
			       (let ((col (gdk_color_copy tmp)))
				 (gdk_rgb_find_color (gdk_colormap_get_system) col)
				 col)))
		 (_GtkColorButton_1 (gtk_color_button_new_with_color _GdkColor_)))
	    (gtk_font_button_set_title _GtkFontButton_ "hi")
	    (gtk_font_button_set_use_font _GtkFontButton_ #t)
	    (gtk_font_button_set_use_size _GtkFontButton_ #f)
	    (gtk_font_button_set_font_name _GtkFontButton_ "Monospace 10")
	    (gtk_font_button_set_show_style _GtkFontButton_ #f)
	    (gtk_font_button_set_show_size _GtkFontButton_ #f)
	    (gtk_color_button_set_color _GtkColorButton_ _GdkColor_)
	    (gtk_color_button_set_alpha _GtkColorButton_ 12345)
	    (gtk_color_button_get_color _GtkColorButton_ _GdkColor_)
	    (gtk_color_button_set_use_alpha _GtkColorButton_ #f)
	    (gtk_color_button_set_title _GtkColorButton_ "hi")
	    (let* ((_gchar_ (gtk_font_button_get_title _GtkFontButton_))
		   (_gboolean (gtk_font_button_get_use_font _GtkFontButton_))
		   (_gboolean1 (gtk_font_button_get_use_size _GtkFontButton_))
		   (_gchar_1 (gtk_font_button_get_font_name _GtkFontButton_))
		   (_gboolean2 (gtk_font_button_get_show_style _GtkFontButton_))
		   (_gboolean3 (gtk_font_button_get_show_size _GtkFontButton_))
		   (_guint16 (gtk_color_button_get_alpha _GtkColorButton_))
		   (_gboolean4 (gtk_color_button_get_use_alpha _GtkColorButton_))
		   (_gchar_2 (gtk_color_button_get_title _GtkColorButton_)))
	      (if (not (string=? _gchar_ "hi")) (snd-display #__line__ ";font button title: ~A" _gchar_))
	      (if (not _gboolean) (snd-display #__line__ ";font button use font"))
	      (if _gboolean1 (snd-display #__line__ ";font button use size"))
	      (if (not (string=? _gchar_1 "Monospace 10")) (snd-display #__line__ ";font button font: ~A" _gchar_1))
	      (if _gboolean2 (snd-display #__line__ ";font button style"))
	      (if _gboolean3 (snd-display #__line__ ";font button size"))
	      (if (not (= _guint16 12345)) (snd-display #__line__ ";color button alpha: ~A" _guint16))
	      (if _gboolean4 (snd-display #__line__ ";color button alpha"))
	      (if (not (string=? _gchar_2 "hi")) (snd-display #__line__ ";color button title: ~A" _gchar_2))))
	  
	  (let* ((_GtkAlignment_ (GTK_ALIGNMENT (gtk_alignment_new .1 .2 .3 .4)))
		 (_GtkMisc_ (GTK_MISC (gtk_label_new "hi"))))
	    (gtk_alignment_set_padding _GtkAlignment_ 0 1 2 3)
	    (let ((vals (gtk_alignment_get_padding _GtkAlignment_)))
	      (if (not (equal? vals (list 0 1 2 3))) (snd-display #__line__ ";alignment pad: ~A" vals)))
	    (gtk_alignment_set _GtkAlignment_ .1 .2 .3 .4)
	    (gtk_misc_set_alignment _GtkMisc_ .1 .2)
	    (let ((vals (gtk_misc_get_alignment _GtkMisc_)))
	      (if (not (feql vals (list .1 .2))) (snd-display #__line__ ";misc align: ~A" vals)))
	    (gtk_misc_set_padding _GtkMisc_ 0 1)
	    (let ((vals (gtk_misc_get_padding _GtkMisc_)))
	      (if (not (equal? vals (list 0 1))) (snd-display #__line__ ";misc pad: ~A" vals))))
	  (let* ((_GdkDisplay_ (gdk_display_get_default))
		 (vals (gdk_display_get_maximal_cursor_size _GdkDisplay_))
		 (_GdkAtom (gdk_atom_intern "PRIMARY" #f))
		 (_GdkScreen_ (gdk_screen_get_default))
		 (vals1 (gdk_display_get_pointer _GdkDisplay_))
		 (_GtkClipboard_ (gtk_clipboard_get _GdkAtom))
		 (_GtkClipboard_1 (gtk_clipboard_get_for_display _GdkDisplay_ _GdkAtom))
		 (_GdkScreen_1 (gdk_display_get_screen _GdkDisplay_ 0))
		 (vals2 (gdk_display_get_window_at_pointer _GdkDisplay_))
		 (_GObject_ (gtk_clipboard_get_owner _GtkClipboard_))
		 (_GdkDisplay_1 (gtk_clipboard_get_display _GtkClipboard_)))
	    (gdk_display_add_client_message_filter _GdkDisplay_ _GdkAtom (lambda (a b c) #f) #f)
	    (gdk_display_set_double_click_distance _GdkDisplay_ 20)
	    (gdk_display_set_double_click_time _GdkDisplay_ 200)
	    (gtk_clipboard_clear _GtkClipboard_)
	    (gtk_clipboard_set_text _GtkClipboard_ "hiho" 0)
	    (gtk_clipboard_request_text _GtkClipboard_ (lambda (clip text data) #f) #f)
	    (gtk_clipboard_request_contents _GtkClipboard_ _GdkAtom (lambda (clip contents data) #f) #f)
	    (gtk_clipboard_request_targets _GtkClipboard_ (lambda (a b c d) #f) #f)
	    (if (gtk_clipboard_wait_is_text_available _GtkClipboard_)
		(gtk_clipboard_wait_for_text _GtkClipboard_)))
	  
	  (let* ((_GtkListStore_ (gtk_list_store_new 1 (list G_TYPE_STRING)))
		 (_GtkTreeModel_ (GTK_TREE_MODEL _GtkListStore_))
		 (_GtkTreeView_ (GTK_TREE_VIEW (gtk_tree_view_new_with_model _GtkTreeModel_)))
		 (_GtkCellRenderer_ (gtk_cell_renderer_text_new))
		 (_GtkTreeViewColumn_ (gtk_tree_view_column_new_with_attributes "hiho" _GtkCellRenderer_ (list "text" 0)))
		 (_GtkScrolledWindow_ (GTK_SCROLLED_WINDOW (gtk_scrolled_window_new #f #f)))
		 (_GtkTreeIter_ (GtkTreeIter))
		 (_GtkComboBoxEntry_ (GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new)))
		 (_GtkComboBox_ (GTK_COMBO_BOX (gtk_combo_box_new)))
		 (_GtkWidgetc_ (gtk_combo_box_entry_new_text))
		 (_GtkWidgetc1_ (gtk_combo_box_new_text)))
	    (gtk_tree_view_column_set_sizing _GtkTreeViewColumn_ GTK_TREE_VIEW_COLUMN_AUTOSIZE)
	    (gtk_tree_view_column_set_widget _GtkTreeViewColumn_ (gtk_label_new "ho"))
	    (gtk_tree_view_append_column _GtkTreeView_ _GtkTreeViewColumn_)
	    (gtk_scrolled_window_set_shadow_type _GtkScrolledWindow_ GTK_SHADOW_IN)
	    (gtk_container_add (GTK_CONTAINER _GtkScrolledWindow_) (GTK_WIDGET _GtkTreeView_))
	    (gtk_scrolled_window_set_policy _GtkScrolledWindow_ GTK_POLICY_AUTOMATIC GTK_POLICY_ALWAYS)
	    (gtk_container_set_border_width (GTK_CONTAINER _GtkScrolledWindow_) 0)
	    (gtk_list_store_append _GtkListStore_ _GtkTreeIter_)
	    (gtk_list_store_set _GtkListStore_ _GtkTreeIter_ (list 0 "hiho"))
	    (let* ((vals (gtk_scrolled_window_get_policy _GtkScrolledWindow_))
		   (_GtkAdjustment_ (gtk_scrolled_window_get_hadjustment _GtkScrolledWindow_))
		   (_GtkAdjustment_1 (gtk_scrolled_window_get_vadjustment _GtkScrolledWindow_))
		   (_GtkCornerType (gtk_scrolled_window_get_placement _GtkScrolledWindow_))
		   (_GtkShadowType (gtk_scrolled_window_get_shadow_type _GtkScrolledWindow_))
		   (_gint (gtk_tree_view_column_get_fixed_width _GtkTreeViewColumn_))
		   (_gint1 (gtk_tree_view_column_get_max_width _GtkTreeViewColumn_))
		   (_gint2 (gtk_tree_view_column_get_min_width _GtkTreeViewColumn_))
		   (_gint3 (gtk_tree_view_column_get_sort_column_id _GtkTreeViewColumn_))
		   (_gint4 (gtk_tree_view_column_get_spacing _GtkTreeViewColumn_))
		   (_gint5 (gtk_tree_view_column_get_width _GtkTreeViewColumn_))
		   (_gint6 (gtk_tree_view_get_search_column _GtkTreeView_))
		   (_gint7 (gtk_tree_model_get_n_columns _GtkTreeModel_))
		   (_GtkTreeModelFlags (gtk_tree_model_get_flags _GtkTreeModel_))
		   (_GtkSortType (gtk_tree_view_column_get_sort_order _GtkTreeViewColumn_))
		   (_GtkTreeModel_1 (gtk_tree_view_get_model _GtkTreeView_))
		   (_gboolean (gtk_tree_view_column_get_clickable _GtkTreeViewColumn_))
		   (_gboolean1 (gtk_tree_view_column_get_expand _GtkTreeViewColumn_))
		   (_gboolean2 (gtk_tree_view_column_get_reorderable _GtkTreeViewColumn_))
		   (_gboolean3 (gtk_tree_view_column_get_resizable _GtkTreeViewColumn_))
		   (_gboolean4 (gtk_tree_view_column_get_sort_indicator _GtkTreeViewColumn_))
		   (_gboolean5 (gtk_tree_view_column_get_visible _GtkTreeViewColumn_))
		   (_gboolean6 (gtk_tree_view_get_enable_search _GtkTreeView_))
		   (_gboolean7 (gtk_tree_view_get_headers_visible _GtkTreeView_))
		   (_gboolean8 (gtk_tree_view_get_reorderable _GtkTreeView_))
		   (_gboolean9 (gtk_tree_view_get_rules_hint _GtkTreeView_))
		   (_gchar_ (gtk_tree_view_column_get_title _GtkTreeViewColumn_))
		   (_gfloat (gtk_tree_view_column_get_alignment _GtkTreeViewColumn_)))
	      (if (not (equal? vals (list 1 0))) (snd-display #__line__ ";scrolled policy: ~A" vals))
	      (if (not (= _GtkCornerType 0)) (snd-display #__line__ ";scrolled placement :~A" _GtkCornerType))
	      (if (not (= _GtkShadowType 1)) (snd-display #__line__ ";scrolled shadow :~A" _GtkShadowType))
	      (if (and (not (= _gint 0)) (not (= _gint 1))) (snd-display #__line__ ";tree col fix wid:~A" _gint))
	      (if (not (= _gint1 -1)) (snd-display #__line__ ";tree col max wid:~A" _gint1))
	      (if (not (= _gint2 -1)) (snd-display #__line__ ";tree col min wid :~A" _gint2))
	      (if (not (= _gint3 -1)) (snd-display #__line__ ";tree col sort id:~A" _gint3))
	      (if (not (= _gint4 0)) (snd-display #__line__ ";tree col spacing:~A" _gint4))
	      (if (not (= _gint5 0)) (snd-display #__line__ ";tree col wid:~A" _gint5))
	      (if (not (= _gint6 0)) (snd-display #__line__ ";tree view col:~A" _gint6))
	      (if (not (= _gint7 1)) (snd-display #__line__ ";tree model n col:~A" _gint7))
	      (if (not (= _GtkTreeModelFlags 3)) (snd-display #__line__ ";tree mode flags:~A" _GtkTreeModelFlags))
	      (if (not (= _GtkSortType 0)) (snd-display #__line__ ";tree view sort:~A" _GtkSortType))
	      (if (not (eq? _gboolean #f)) (snd-display #__line__ ";tree col click:~A" _gboolean))
	      (if (not (eq? _gboolean1 #f)) (snd-display #__line__ ";tree col expand:~A" _gboolean1))
	      (if (not (eq? _gboolean2 #f)) (snd-display #__line__ ";tree col reorder:~A" _gboolean2))
	      (if (not (eq? _gboolean3 #f)) (snd-display #__line__ ";tree col resize:~A" _gboolean3))
	      (if (not (eq? _gboolean4 #f)) (snd-display #__line__ ";tree col sort:~A" _gboolean4))
	      (if (not (eq? _gboolean5 #t)) (snd-display #__line__ ";tree col vis:~A" _gboolean5))
	      (if (not (eq? _gboolean6 #t)) (snd-display #__line__ ";tree view search:~A" _gboolean6))
	      (if (not (eq? _gboolean7 #t)) (snd-display #__line__ ";tree view vis:~A" _gboolean7))
	      (if (not (eq? _gboolean8 #f)) (snd-display #__line__ ";tree view reorder:~A" _gboolean8))
	      (if (not (eq? _gboolean9 #f)) (snd-display #__line__ ";tree view hint:~A" _gboolean9))
	      (if (not (string=? _gchar_ "hiho")) (snd-display #__line__ ";tree col title:~A" _gchar_))
	      (if (fneq _gfloat 0.0) (snd-display #__line__ ";tree col align:~A" _gfloat))
	      (gtk_scrolled_window_set_hadjustment _GtkScrolledWindow_ _GtkAdjustment_)
	      (gtk_scrolled_window_set_placement _GtkScrolledWindow_ _GtkCornerType)
	      (gtk_scrolled_window_set_vadjustment _GtkScrolledWindow_ _GtkAdjustment_1)
	      (gtk_tree_view_column_set_alignment _GtkTreeViewColumn_ .5)
	      (gtk_tree_view_column_set_clickable _GtkTreeViewColumn_ #t)
	      (gtk_tree_view_column_set_expand _GtkTreeViewColumn_ #t)
	      (gtk_tree_view_column_set_fixed_width _GtkTreeViewColumn_ 40)
	      (gtk_tree_view_column_set_max_width _GtkTreeViewColumn_ 200)
	      (gtk_tree_view_column_set_min_width _GtkTreeViewColumn_ 10)
	      (gtk_tree_view_column_set_reorderable _GtkTreeViewColumn_ #t)
	      (gtk_tree_view_column_set_resizable _GtkTreeViewColumn_ #t)
	      (gtk_tree_view_column_set_sort_column_id _GtkTreeViewColumn_ 0)
	      (gtk_tree_view_column_set_sort_indicator _GtkTreeViewColumn_ #t)
	      (gtk_tree_view_column_set_sort_order _GtkTreeViewColumn_ GTK_SORT_ASCENDING)
	      (gtk_tree_view_column_set_spacing _GtkTreeViewColumn_ 10)
	      (gtk_tree_view_column_set_title _GtkTreeViewColumn_ "a-tree")
	      (gtk_tree_view_column_set_visible _GtkTreeViewColumn_ #t)
	      (gtk_tree_view_set_enable_search _GtkTreeView_ #t)
	      (gtk_tree_view_set_headers_clickable _GtkTreeView_ #t)
	      (gtk_tree_view_set_headers_visible _GtkTreeView_ #t)
	      (gtk_tree_view_set_reorderable _GtkTreeView_ #t)
	      (gtk_tree_view_set_rules_hint _GtkTreeView_ #t)
	      (gtk_tree_view_set_search_column _GtkTreeView_ 0)
	      (gtk_cell_renderer_set_fixed_size _GtkCellRenderer_ 10 10)
	      (let* ((_GtkTreeIterc_ (GtkTreeIter))
		     (_GtkTreeIterc1_ (GtkTreeIter))
		     (_GtkListStorec_ (gtk_list_store_new 1 (list G_TYPE_STRING)))
		     (_GtkTreeModelc_ (GTK_TREE_MODEL _GtkListStore_))
		     (_GtkWidget_ (gtk_combo_box_entry_new_with_model _GtkTreeModelc_ 0))
		     (_GtkWidget_ (gtk_combo_box_new_with_model _GtkTreeModelc_))
		     (_GtkTreeModelc1_ (gtk_combo_box_get_model _GtkComboBox_)))
		(gtk_combo_box_set_model _GtkComboBox_ _GtkTreeModelc_)
		(gtk_combo_box_append_text _GtkComboBox_ "hi")
		(gtk_combo_box_insert_text _GtkComboBox_ 0 "hi")
		(gtk_combo_box_prepend_text _GtkComboBox_ "ho")
		(gtk_combo_box_remove_text _GtkComboBox_ 0)
		(gtk_combo_box_set_active _GtkComboBox_ 0)
		(gtk_combo_box_set_wrap_width _GtkComboBox_ 60)
		(let* ((_gboolean (gtk_combo_box_get_active_iter _GtkComboBox_ _GtkTreeIterc1_))
		       (_gintc1 (gtk_combo_box_entry_get_text_column _GtkComboBoxEntry_))
		       (_gintc2 (gtk_combo_box_get_active _GtkComboBox_)))
		  (if (not (= _gintc2 0)) (snd-display #__line__ ";combo box active: ~A" _gintc2))))
	      (let* ((_GtkTreePath_1 (gtk_tree_path_new))
		     (_GtkTreePath_2 (gtk_tree_path_new_first))
		     (_GtkTreePath_3 (gtk_tree_path_new_from_string "0"))
		     (_GtkTreePath_4 (gtk_tree_path_copy _GtkTreePath_3))
		     (_gchar_ (gtk_tree_path_to_string _GtkTreePath_3))
		     (_gint (gtk_tree_path_get_depth _GtkTreePath_3))
		     (_gint_ (c-array->list (gtk_tree_path_get_indices _GtkTreePath_3) _gint))
		     (_GtkTreeModelFilter_ (GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new _GtkTreeModel_ _GtkTreePath_3)))
		     (_GtkTreeModelSort_ (GTK_TREE_MODEL_SORT (gtk_tree_model_sort_new_with_model _GtkTreeModel_)))
		     (_GtkTreeSortable_ (GTK_TREE_SORTABLE _GtkTreeModelSort_))
		     (_GtkTreeRowReference_ (gtk_tree_row_reference_new _GtkTreeModel_ _GtkTreePath_3))
		     (_GtkTreeModel_5 (gtk_tree_model_filter_get_model _GtkTreeModelFilter_))
		     (_GtkTreeModel_6 (gtk_tree_model_sort_get_model _GtkTreeModelSort_))
		     (_GtkTreeViewColumn_ (gtk_tree_view_get_column _GtkTreeView_ 0))
		     (_GtkTreeViewColumn_1 (gtk_tree_view_column_new))
		     (_GtkCellRendererToggle_ (GTK_CELL_RENDERER_TOGGLE (gtk_cell_renderer_toggle_new)))
		     (_GtkCellRendererText_ (GTK_CELL_RENDERER_TEXT (gtk_cell_renderer_text_new)))
		     (_gboolean1 (gtk_cell_renderer_toggle_get_active _GtkCellRendererToggle_))
		     (_gboolean2 (gtk_cell_renderer_toggle_get_radio _GtkCellRendererToggle_))
		     (vals (gtk_cell_renderer_get_fixed_size _GtkCellRenderer_))
		     (_GtkTreeStore_ (gtk_tree_store_newv 1 (list->c-array (list G_TYPE_STRING) "GType*")))
		     (_GtkTreeView_2 (GTK_TREE_VIEW (gtk_tree_view_new)))
		     (_GtkListStore_2 (GTK_LIST_STORE (gtk_list_store_newv 1 (list->c-array (list G_TYPE_STRING) "GType*"))))
		     (_GType (gtk_tree_model_get_column_type _GtkTreeModel_ 0))
		     (_GdkWindow_ (gtk_tree_view_get_bin_window _GtkTreeView_))
		     (_GtkAdjustment_1 (gtk_tree_view_get_hadjustment _GtkTreeView_))
		     (_GtkAdjustment_2 (gtk_tree_view_get_vadjustment _GtkTreeView_))
		     (_GList_ (gtk_tree_view_get_columns _GtkTreeView_))
		     (_GtkTreePath_5 (gtk_tree_model_get_path _GtkTreeModel_ _GtkTreeIter_))
		     (_GtkTreePath_6 (gtk_tree_row_reference_get_path _GtkTreeRowReference_))
		     (_GtkTreeViewColumnSizing (gtk_tree_view_column_get_sizing _GtkTreeViewColumn_))
		     (_GtkTreeIterp_ (GtkTreeIter))
		     (_GtkTreeIter_5 (gtk_tree_iter_copy _GtkTreeIterp_))
		     (_gboolean3 (gtk_tree_model_get_iter _GtkTreeModel_ _GtkTreeIterp_ _GtkTreePath_3))
		     (_gboolean4 (gtk_tree_model_get_iter_first _GtkTreeModel_ _GtkTreeIterp_))
		     (_gboolean5 (gtk_tree_model_get_iter_from_string _GtkTreeModel_ _GtkTreeIterp_ "0"))
		     (_gchar_1 (gtk_tree_model_get_string_from_iter _GtkTreeModel_ _GtkTreeIterp_))
		     (_GtkTreeSelection_ (gtk_tree_view_get_selection _GtkTreeView_))
		     (_GtkTreeView_3 (gtk_tree_selection_get_tree_view _GtkTreeSelection_))
		     (_gpointer (gtk_tree_selection_get_user_data _GtkTreeSelection_))
		     (_gboolean (gtk_tree_sortable_has_default_sort_func _GtkTreeSortable_))
		     (_list (gtk_tree_sortable_get_sort_column_id _GtkTreeSortable_ 0))
		     (_GtkSelectionMode (gtk_tree_selection_get_mode _GtkTreeSelection_)))
		(if (not (string=? _gchar_ "0")) (snd-display #__line__ ";tree path: ~S" _gchar_))
		(if (not (string=? _gchar_1 "0")) (snd-display #__line__ ";tree model iter path: ~S" _gchar_1))
		(if (not (= _gint 1)) (snd-display #__line__ ";tree path depth: ~A" _gint))
		(if (not (equal? _gint_ (list 0))) (snd-display #__line__ ";tree path indices: ~A" _gint_))
		(if (not (equal? _GtkTreeModel_ _GtkTreeModel_5)) (snd-display #__line__ ";tree model filter get model: ~A ~A" _GtkTreeModel_ _GtkTreeModel_5))
		(if (not (equal? _GtkTreeModel_ _GtkTreeModel_6)) (snd-display #__line__ ";tree model sort get model: ~A ~A" _GtkTreeModel_ _GtkTreeModel_6))
		(if (not (equal? vals (list 10 10))) (snd-display #__line__ ";cell renderer fixed size: ~A" vals))
		(if (not (= _GType G_TYPE_STRING)) (snd-display #__line__ ";tree model col type: ~A" _GType))
		(if (not (equal? _GtkTreeView_ _GtkTreeView_3)) (snd-display #__line__ ";tree selection get view: ~A ~A" _GtkTreeView_ _GtkTreeView_3))
		(gtk_tree_model_filter_clear_cache _GtkTreeModelFilter_)
		(gtk_tree_model_unref_node _GtkTreeModel_ _GtkTreeIter_)
		(gtk_tree_model_ref_node _GtkTreeModel_ _GtkTreeIter_)
		(gtk_cell_renderer_text_set_fixed_height_from_font _GtkCellRendererText_ 1)
		(gtk_cell_renderer_toggle_set_active _GtkCellRendererToggle_ #f)
		(gtk_cell_renderer_toggle_set_radio _GtkCellRendererToggle_ #t)
		(gtk_list_store_set_column_types _GtkListStore_2 1 (list->c-array (list G_TYPE_STRING) "GType*"))
		(gtk_tree_store_set_column_types _GtkTreeStore_ 1 (list->c-array (list G_TYPE_STRING) "GType*"))
		(gtk_tree_selection_set_select_function _GtkTreeSelection_ (lambda (a b c d e) #f) #f #f)
		(gtk_tree_view_set_expander_column _GtkTreeView_ _GtkTreeViewColumn_)
		(gtk_tree_view_get_expander_column _GtkTreeView_)
		(gtk_tree_view_column_set_cell_data_func _GtkTreeViewColumn_ _GtkCellRenderer_ (lambda (a b c d e) #f) #f #f)
		(gtk_tree_view_set_column_drag_function _GtkTreeView_ (lambda (a b c d e) #f) #f #f)
		(gtk_tree_view_set_search_equal_func _GtkTreeView_ (lambda (a b c d e) #f) #f #f)
		(gtk_tree_view_set_hadjustment _GtkTreeView_ _GtkAdjustment_1)
		(gtk_tree_view_set_vadjustment _GtkTreeView_ _GtkAdjustment_2)
		(gtk_tree_model_sort_reset_default_sort_func _GtkTreeModelSort_)
		(gtk_tree_selection_set_mode _GtkTreeSelection_ GTK_SELECTION_MULTIPLE)
		(gtk_tree_selection_select_all _GtkTreeSelection_)
		(gtk_tree_selection_unselect_all _GtkTreeSelection_)
		(gtk_tree_selection_select_iter _GtkTreeSelection_ _GtkTreeIter_)
		(gtk_tree_selection_unselect_iter _GtkTreeSelection_ _GtkTreeIter_)
		(gtk_tree_selection_select_path _GtkTreeSelection_ _GtkTreePath_3)
		(gtk_tree_selection_unselect_path _GtkTreeSelection_ _GtkTreePath_3)
		(gtk_tree_selection_selected_foreach _GtkTreeSelection_ (lambda (a b c d) #f) #f)
		(gtk_tree_model_sort_clear_cache _GtkTreeModelSort_)
		(gtk_tree_model_foreach _GtkTreeModel_ (lambda (a b c d) #f) #f)
		(gtk_tree_sortable_set_sort_func _GtkTreeSortable_ 0 (lambda (a b c d) #f) #f #f)
		(gtk_tree_sortable_set_default_sort_func _GtkTreeSortable_ (lambda (a b c d) #f) #f #f)
		(gtk_tree_sortable_set_sort_column_id _GtkTreeSortable_ 0 GTK_SORT_ASCENDING)
		(gtk_tree_sortable_sort_column_changed _GtkTreeSortable_)
		(gtk_tree_store_clear _GtkTreeStore_)
		(let* ((_GtkTreeViewSearchEqualFunc (gtk_tree_view_get_search_equal_func _GtkTreeView_))
		       (_gboolean6 (gtk_tree_selection_iter_is_selected _GtkTreeSelection_ _GtkTreeIter_))
		       (_gboolean7 (gtk_tree_selection_path_is_selected _GtkTreeSelection_ _GtkTreePath_3))
		       (_gboolean8 (gtk_tree_model_sort_iter_is_valid _GtkTreeModelSort_ _GtkTreeIter_))
		       (_GtkTreeDragDest_ (GTK_TREE_DRAG_DEST _GtkTreeModel_)))
		  (if _gboolean7 (snd-display #__line__ ";tree path selected"))
		  (gtk_tree_view_set_drag_dest_row _GtkTreeView_ _GtkTreePath_3 GTK_TREE_VIEW_DROP_AFTER)
		  (gtk_tree_view_get_drag_dest_row _GtkTreeView_))
		(gtk_tree_view_set_cursor _GtkTreeView_ _GtkTreePath_3 _GtkTreeViewColumn_ #f)
		(gtk_tree_view_set_model _GtkTreeView_ _GtkTreeModel_)
		(gtk_tree_model_filter_set_visible_column _GtkTreeModelFilter_ 0)
		(gtk_tree_path_append_index _GtkTreePath_2 1)
		(gtk_tree_path_prepend_index _GtkTreePath_4 0)
		(gtk_tree_path_down _GtkTreePath_2)
		(gtk_tree_path_next _GtkTreePath_2)
		(gtk_tree_path_free _GtkTreePath_2)
		(gtk_tree_view_column_pack_end _GtkTreeViewColumn_ (gtk_cell_renderer_toggle_new) #f)
		(gtk_tree_view_column_pack_start _GtkTreeViewColumn_ (gtk_cell_renderer_toggle_new) #f)
		(gtk_tree_path_prev _GtkTreePath_3)
		(gtk_tree_path_up _GtkTreePath_3)
		(let ((_GtkTreeIter_t (GtkTreeIter))
		      (_GtkTreeIter_t1 (GtkTreeIter))
		      (_GtkTreeIter_t2 (GtkTreeIter)))
		  (gtk_tree_store_append _GtkTreeStore_ _GtkTreeIter_t #f)
		  (gtk_tree_store_set _GtkTreeStore_ _GtkTreeIter_t '(0 "hiho"))
		  (let ((_gint (gtk_tree_store_iter_depth _GtkTreeStore_ _GtkTreeIter_t)))
		    (if (not (= _gint 0)) (snd-display #__line__ ";tree store iter depth: ~A" _gint))
					;(gtk_tree_iter_free _GtkTreeIter_t2)
		    ))
		(let* ((_GtkScrolledWindow_1 (GTK_SCROLLED_WINDOW (gtk_scrolled_window_new #f #f)))
		       (_GtkViewPort_ (GTK_VIEWPORT (gtk_viewport_new (gtk_scrolled_window_get_hadjustment _GtkScrolledWindow_1)
								      (gtk_scrolled_window_get_vadjustment _GtkScrolledWindow_1)))))
		  (gtk_scrolled_window_add_with_viewport _GtkScrolledWindow_1 (gtk_label_new "hi"))
		  (gtk_viewport_set_hadjustment _GtkViewPort_ (gtk_scrolled_window_get_hadjustment _GtkScrolledWindow_1))
		  (gtk_viewport_set_shadow_type _GtkViewPort_ GTK_SHADOW_OUT)
		  (gtk_viewport_set_vadjustment _GtkViewPort_ (gtk_scrolled_window_get_vadjustment _GtkScrolledWindow_1))
		  (let* ((_GtkAdjustment_ (gtk_viewport_get_hadjustment _GtkViewPort_))
			 (_GtkAdjustment_1 (gtk_viewport_get_vadjustment _GtkViewPort_))
			 (_GtkShadowType (gtk_viewport_get_shadow_type _GtkViewPort_))
			 (_GtkTreePath_8 (gtk_tree_path_new_from_string "0"))
			 (_GtkTreeRowReference_1 (gtk_tree_row_reference_new _GtkTreeModel_ _GtkTreePath_8))
			 (_gboolean (gtk_tree_row_reference_valid _GtkTreeRowReference_1)))
		    (if (not (= _GtkShadowType GTK_SHADOW_OUT)) (snd-display #__line__ ";viewport shadow: ~A" _GtkShadowType))
		    (gtk_tree_row_reference_free _GtkTreeRowReference_1)))
		(gtk_tree_view_column_clear _GtkTreeViewColumn_)
		(gtk_tree_view_get_cursor _GtkTreeView_)
		(let ((_int (gtk_tree_selection_count_selected_rows _GtkTreeSelection_)))
		  (if (not (= _int 0)) (snd-display #__line__ ";tree selection selected rows: ~A" _int)))
		(gtk_list_store_clear _GtkListStore_2)
		(let* ((_GtkTreePath_ (gtk_tree_model_filter_convert_child_path_to_path _GtkTreeModelFilter_ _GtkTreePath_3))
		       (_GdkPixmap_ (gtk_tree_view_create_row_drag_icon _GtkTreeView_ _GtkTreePath_3))
		       (_GtkTreePath_ (gtk_tree_model_filter_convert_path_to_child_path _GtkTreeModelFilter_ _GtkTreePath_3))
		       (_GtkListStore_a (gtk_list_store_new 1 (list G_TYPE_STRING)))
		       (_GtkTreeIter_a (GtkTreeIter))
		       (_GtkTreeIter_b (GtkTreeIter)))
		  (gtk_list_store_append _GtkListStore_a _GtkTreeIter_a)
		  (gtk_list_store_insert _GtkListStore_a _GtkTreeIter_b 0)
		  (gtk_list_store_insert_after _GtkListStore_a _GtkTreeIter_b _GtkTreeIter_a)
		  (gtk_list_store_prepend _GtkListStore_a _GtkTreeIter_b)
		  (gtk_list_store_swap _GtkListStore_a _GtkTreeIter_a _GtkTreeIter_b)
		  (gtk_list_store_remove _GtkListStore_a _GtkTreeIter_b))
		(gtk_tree_model_filter_refilter _GtkTreeModelFilter_)
		(gtk_tree_view_collapse_all _GtkTreeView_)
		(gtk_tree_view_expand_all _GtkTreeView_)
		(let* ((_GtkTreePath_5 (gtk_tree_path_copy _GtkTreePath_3))
		       (_gboolean10 (gtk_tree_path_is_ancestor _GtkTreePath_5 _GtkTreePath_3))
		       (_gboolean11 (gtk_tree_path_is_descendant _GtkTreePath_5 _GtkTreePath_3))
		       (_GtkTreeIter_2 (GtkTreeIter))
		       (_GtkTreeIter_3 (GtkTreeIter))
		       (_gboolean12 (gtk_tree_model_iter_children _GtkTreeModel_ _GtkTreeIter_2 _GtkTreeIter_3))
		       (_gboolean13 (gtk_tree_model_iter_has_child _GtkTreeModel_ _GtkTreeIter_2))
		       (_gboolean15 (gtk_tree_model_iter_nth_child _GtkTreeModel_ _GtkTreeIter_2 _GtkTreeIter_3 0))
		       (_gboolean16 (gtk_tree_model_iter_parent _GtkTreeModel_ _GtkTreeIter_2 _GtkTreeIter_3)))
		  (if _gboolean10 (snd-display #__line__ ";tree path copy is ancestor"))
		  (if _gboolean11 (snd-display #__line__ ";tree path copy is descendent"))))))
	  
	  (let* ((_GtkSizeGroup_ (gtk_size_group_new GTK_SIZE_GROUP_VERTICAL))
		 (_GtkSizeGroupMode (gtk_size_group_get_mode _GtkSizeGroup_))
		 (_lab (gtk_label_new "hi")))
	    (if (not (= _GtkSizeGroupMode GTK_SIZE_GROUP_VERTICAL)) (snd-display #__line__ ";size group mode: ~A" _GtkSizeGroupMode))
	    (gtk_size_group_add_widget _GtkSizeGroup_ _lab)
	    (gtk_size_group_remove_widget _GtkSizeGroup_ _lab)
	    (gtk_size_group_set_mode _GtkSizeGroup_ GTK_SIZE_GROUP_HORIZONTAL))
	  
	  (let* ((_GtkRequisition_ (GtkRequisition 10 10))
		 (_GtkRequisition_1 (gtk_requisition_copy _GtkRequisition_))
		 (_GtkWidget_ (gtk_label_new "hi")))
	    (gtk_requisition_free _GtkRequisition_1)
	    (gtk_widget_get_child_requisition _GtkWidget_ _GtkRequisition_)
	    (gtk_widget_size_request _GtkWidget_ _GtkRequisition_))
	  
	  (let* ((_GtkIconFactory_ (gtk_icon_factory_new))
		 (_GtkIconSet_ (gtk_icon_set_new))
		 (_GtkIconSet_1 (gtk_icon_set_copy _GtkIconSet_))
		 (_GtkIconSource_ (gtk_icon_source_new))
		 (_GtkIconTheme_ (gtk_icon_theme_new))
		 (_GtkIconTheme_1 (gtk_icon_theme_get_default))
		 (_GdkScreen_ (gdk_screen_get_default))
		 (_GtkIconTheme_2 (gtk_icon_theme_get_for_screen _GdkScreen_))
		 (_GtkIconSource_1 (gtk_icon_source_copy _GtkIconSource_))
		 (_GtkIconSize (gtk_icon_size_register "hiho" 32 32))
		 (_GtkIconSize1 (gtk_icon_size_from_name "hiho"))
		 (_GtkStateType (gtk_icon_source_get_state _GtkIconSource_))
		 (_GtkTextDirection (gtk_icon_source_get_direction _GtkIconSource_))
		 (_GtkIconSize2 (gtk_icon_source_get_size _GtkIconSource_))
		 (_GtkWidget_ (gtk_image_new_from_icon_set _GtkIconSet_ _GtkIconSize))
		 (vals (gtk_icon_theme_get_search_path _GtkIconTheme_1))
		 (_GList_ (gtk_icon_theme_list_icons _GtkIconTheme_1 #f))
		 (icon-name (->string (cadr (g_list_nth_data _GList_ 0))))
		 (_GtkIconInfo_ (gtk_icon_theme_lookup_icon _GtkIconTheme_1 icon-name 16 0))
		 (_GtkIconInfo_1 (gtk_icon_info_copy _GtkIconInfo_))
		 (_GdkPixbuf_ (gtk_icon_info_get_builtin_pixbuf _GtkIconInfo_))
		 (_GdkPixbuf_1 (gtk_icon_source_get_pixbuf _GtkIconSource_))
		 (_GtkIconSet_2 (gtk_icon_set_ref _GtkIconSet_))
		 (_GdkRectangle_ (GdkRectangle))
		 (_gboolean1 (gtk_icon_info_get_embedded_rect _GtkIconInfo_ _GdkRectangle_))
		 (_gboolean2 (gtk_icon_source_get_direction_wildcarded _GtkIconSource_))
		 (_gboolean3 (gtk_icon_source_get_size_wildcarded _GtkIconSource_))
		 (_gboolean4 (gtk_icon_source_get_state_wildcarded _GtkIconSource_))
		 (_gboolean5 (gtk_icon_theme_has_icon _GtkIconTheme_ "hiho-away"))
		 (_gboolean6 (gtk_icon_theme_rescan_if_needed _GtkIconTheme_))
		 (_gchar_ (gtk_icon_info_get_display_name _GtkIconInfo_))
		 (_gchar_1 (gtk_icon_info_get_filename _GtkIconInfo_))
		 (_gchar_2 (gtk_icon_size_get_name _GtkIconSize))
		 (_gchar_3 (gtk_icon_source_get_filename _GtkIconSource_))
		 (_gchar_4 (gtk_icon_source_get_icon_name _GtkIconSource_))
		 (_char_ (gtk_icon_theme_get_example_icon_name _GtkIconTheme_))
		 (_gint (gtk_icon_info_get_base_size _GtkIconInfo_))
		 (_list1 (gtk_icon_info_get_attach_points _GtkIconInfo_))
		 (_list2 (gtk_icon_size_lookup _GtkIconSize))
		 (_GtkIconSet_4 (gtk_icon_factory_lookup_default "away"))
		 (_GtkIconSet_5 (gtk_icon_factory_lookup _GtkIconFactory_ "away"))
		 (vals2 (gtk_icon_set_get_sizes _GtkIconSet_)))
	    (gtk_icon_theme_set_screen _GtkIconTheme_ _GdkScreen_)
	    (gtk_icon_factory_add_default _GtkIconFactory_)
	    (gtk_icon_factory_remove_default _GtkIconFactory_)
	    (gtk_icon_info_free _GtkIconInfo_1)
	    (gtk_icon_set_unref _GtkIconSet_2)
	    (gtk_icon_source_set_direction _GtkIconSource_ GTK_TEXT_DIR_RTL)
	    (gtk_icon_source_set_direction_wildcarded _GtkIconSource_ #f)
	    (gtk_icon_source_set_filename _GtkIconSource_ _gchar_3)
	    (gtk_icon_source_set_pixbuf _GtkIconSource_ _GdkPixbuf_)
	    (gtk_icon_source_set_size _GtkIconSource_ _GtkIconSize)
	    (gtk_icon_source_set_size_wildcarded _GtkIconSource_ #f)
	    (gtk_icon_source_set_state _GtkIconSource_ _GtkStateType)
	    (gtk_icon_source_set_state_wildcarded _GtkIconSource_ #f)
	    (gtk_icon_factory_add _GtkIconFactory_ "away" _GtkIconSet_)
	    (gtk_icon_info_set_raw_coordinates _GtkIconInfo_ #f)
	    (gtk_icon_source_free _GtkIconSource_)
	    (gtk_icon_theme_append_search_path _GtkIconTheme_ home-dir)
	    (gtk_icon_theme_prepend_search_path _GtkIconTheme_ "/usr/local")
	    (gtk_icon_theme_set_custom_theme _GtkIconTheme_ "custom"))
	  
	  (let* ((_GtkBindingSet_ (gtk_binding_set_new "GtkLabel"))
		 (_GtkBindingSet_1 (gtk_binding_set_find "GtkLabel")))
	    (gtk_binding_set_add_path _GtkBindingSet_ GTK_PATH_CLASS "GtkLabel" GTK_PATH_PRIO_GTK))
	  
	  (let* ((_GtkBox_ (GTK_BOX (gtk_vbox_new #t 0)))
		 (_gboolean (gtk_box_get_homogeneous _GtkBox_))
		 (_gint (gtk_box_get_spacing _GtkBox_))
		 (_GtkWidget_ (gtk_label_new "0"))
		 (_GtkWidget_1 (gtk_label_new "1"))
		 (_GtkWidget_2 (gtk_label_new "2"))
		 (_GtkWidget_3 (gtk_label_new "3")))
	    (if (not _gboolean) (snd-display #__line__ ";box not homogenous"))
	    (if (not (= _gint 0)) (snd-display #__line__ ";box spacing: ~A" _gint))
	    (gtk_box_pack_start _GtkBox_ _GtkWidget_ #f #f 10)
					;	    (gtk_box_pack_start_defaults _GtkBox_ _GtkWidget_1)
	    (gtk_box_pack_end _GtkBox_ _GtkWidget_2 #t #t 10)
					;	    (gtk_box_pack_end_defaults _GtkBox_ _GtkWidget_3)
	    (let ((vals (gtk_box_query_child_packing _GtkBox_ _GtkWidget_)))
	      (if (not (equal? vals (list #f #f 10 0))) (snd-display #__line__ ";box child packing: ~A" vals)))
	    (gtk_box_set_homogeneous _GtkBox_ #t)
	    (gtk_box_set_spacing _GtkBox_ 4)
	    (gtk_box_reorder_child _GtkBox_ _GtkWidget_ 2)
	    (gtk_box_set_child_packing _GtkBox_ _GtkWidget_ #t #t 10 0))
	  
	  (let* ((_GtkRadioButton_ (GTK_RADIO_BUTTON (gtk_radio_button_new #f)))
		 (_gchar_ "hiho")
		 (_GSList_ #f)
		 (_GtkWidget_ (gtk_radio_button_new_from_widget _GtkRadioButton_))
		 (_GtkWidget_1 (gtk_radio_button_new_with_label _GSList_ _gchar_))
		 (_GtkWidget_2 (gtk_radio_button_new_with_mnemonic _GSList_ _gchar_))
		 (_GSList_ (gtk_radio_button_get_group _GtkRadioButton_))
		 (_int (GTK_OBJECT_FLAGS (GTK_OBJECT _GtkRadioButton_))))
	    (GTK_OBJECT_SET_FLAGS (GTK_OBJECT _GtkWidget_) 0)
	    (GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT _GtkWidget_) 0))
	  
	  (if (not (provided? 'cairo))
	      (let* ((_GdkScreen_ (gdk_screen_get_default))
		     (_GdkWindow_ (gdk_screen_get_root_window _GdkScreen_))
		     (_GdkDrawable_ (GDK_DRAWABLE _GdkWindow_))
		     (_GdkGC_ (gdk_gc_new _GdkDrawable_))
		     (_GdkGC_1 (gdk_gc_new _GdkDrawable_)))
		(gdk_gc_copy _GdkGC_ _GdkGC_1)
		(gdk_gc_set_clip_origin _GdkGC_ 0 0)
		(gdk_gc_set_fill _GdkGC_ GDK_SOLID)
		(gdk_gc_set_exposures _GdkGC_ #f)
		(gdk_gc_set_function _GdkGC_ GDK_OR)
		(gdk_gc_offset _GdkGC_ 0 0)
		(gdk_gc_set_background _GdkGC_ (basic-color))
		(gdk_gc_set_colormap _GdkGC_ (gdk_colormap_get_system))
		(gdk_gc_set_foreground _GdkGC_ (highlight-color))
		(gdk_gc_set_clip_rectangle _GdkGC_ (GdkRectangle 0 0 100 100))
		(gdk_gc_set_rgb_bg_color _GdkGC_ (basic-color))
		(gdk_gc_set_rgb_fg_color _GdkGC_ (highlight-color))
		(gdk_gc_set_ts_origin _GdkGC_ 0 0)
		(gdk_gc_set_line_attributes _GdkGC_ 1 GDK_LINE_SOLID GDK_CAP_ROUND GDK_JOIN_MITER)
		(gdk_rgb_set_verbose #f)))
	  
	  (let* ((_GtkCheckMenuItem_ (GTK_CHECK_MENU_ITEM (gtk_check_menu_item_new)))
		 (_GtkWidget_ (gtk_check_menu_item_new_with_label "hi"))
		 (_GtkWidget_1 (gtk_check_menu_item_new_with_mnemonic "_hi"))
		 (_GtkImageMenuItem_ (GTK_IMAGE_MENU_ITEM (gtk_image_menu_item_new)))
		 (_GtkWidget_2 (gtk_image_menu_item_get_image _GtkImageMenuItem_))
		 (_GtkWidget_3 (gtk_image_menu_item_new_with_label "hi"))
		 (_GtkWidget_4 (gtk_image_menu_item_new_with_mnemonic "_ahi"))
		 (_GtkMenuShell_ (GTK_MENU_SHELL (gtk_menu_bar_new)))
		 (_GtkMenuItem_ (GTK_MENU_ITEM (gtk_menu_item_new)))
		 (_GtkMenuItem_1 (GTK_MENU_ITEM (gtk_menu_item_new_with_label "hi")))
		 (_GtkMenuItem_2 (GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic "_bhi")))
		 (_GtkMenu_ (GTK_MENU (gtk_menu_new)))
		 (_GtkRadioMenuItem_ (GTK_RADIO_MENU_ITEM (gtk_radio_menu_item_new #f)))
		 (_GtkWidget_8 (gtk_radio_menu_item_new_with_label #f "hi"))
		 (_GtkWidget_10 (gtk_radio_menu_item_new_with_mnemonic #f "chi"))
		 (_GtkRadioMenuItem_1 (GTK_RADIO_MENU_ITEM (gtk_radio_menu_item_new_from_widget _GtkRadioMenuItem_)))
		 (_GtkWidget_11 (gtk_radio_menu_item_new_with_mnemonic_from_widget _GtkRadioMenuItem_ "hi"))
		 (_GtkWidget_9 (gtk_radio_menu_item_new_with_label_from_widget _GtkRadioMenuItem_ "_dhi"))
		 (_GtkWidget_12 (gtk_separator_menu_item_new))
		 (_GtkWidget_13 (gtk_tearoff_menu_item_new))
		 (_GtkAccelGroup_ (gtk_accel_group_new))
		 (_GtkAccelLabel_ (GTK_ACCEL_LABEL (gtk_accel_label_new "hi")))
		 (_GSList_ (gtk_radio_menu_item_get_group _GtkRadioMenuItem_))
		 (_gboolean (gtk_check_menu_item_get_active _GtkCheckMenuItem_))
		 (_gboolean1 (gtk_check_menu_item_get_draw_as_radio _GtkCheckMenuItem_))
		 (_gboolean2 (gtk_check_menu_item_get_inconsistent _GtkCheckMenuItem_))
		 (_gboolean3 (gtk_menu_get_tearoff_state _GtkMenu_))
		 (_gboolean4 (gtk_menu_item_get_right_justified _GtkMenuItem_))
		 (_GtkWindow_ (GTK_WINDOW (cadr (main-widgets))))
		 (_GtkAction_ (gtk_action_new "unique" "label" "tooltip" GTK_STOCK_HELP)))
	    (if _gboolean (snd-display #__line__ ";menu item active"))
	    (if _gboolean1 (snd-display #__line__ ";menu item radio"))
	    (if _gboolean2 (snd-display #__line__ ";menu item inconsistent"))
	    (if _gboolean3 (snd-display #__line__ ";menu item tearoff"))
	    (if _gboolean4 (snd-display #__line__ ";menu item right justified"))
	    (gtk_menu_set_title _GtkMenu_ "title")
	    (gtk_menu_shell_append _GtkMenuShell_ (GTK_WIDGET _GtkMenuItem_))
	    (gtk_menu_shell_insert _GtkMenuShell_ (GTK_WIDGET _GtkMenuItem_1) 0)
	    (gtk_menu_shell_prepend _GtkMenuShell_ (GTK_WIDGET _GtkMenuItem_2))
	    (gtk_menu_item_set_submenu _GtkMenuItem_ (GTK_WIDGET _GtkMenu_))
	    (gtk_window_add_accel_group _GtkWindow_ _GtkAccelGroup_)
	    (gtk_menu_set_accel_group _GtkMenu_ _GtkAccelGroup_)
	    (gtk_widget_add_accelerator (GTK_WIDGET _GtkMenuItem_) "activate" _GtkAccelGroup_ GDK_C GDK_MOD1_MASK GTK_ACCEL_VISIBLE)
	    (let* ((_GtkWidget_ (gtk_menu_item_get_submenu _GtkMenuItem_))
		   (_GtkWidget_1 (gtk_image_menu_item_new_from_stock GTK_STOCK_CANCEL _GtkAccelGroup_))
		   (_GtkAccelGroup_1 (gtk_menu_get_accel_group _GtkMenu_))
		   (_guint (gtk_accel_label_get_accel_width _GtkAccelLabel_))
		   (_guint1 (gtk_accelerator_get_default_mod_mask))
		   (_gchar_ (gtk_menu_get_title _GtkMenu_))
		   (_GtkAccelMap_ (gtk_accel_map_get))
		   (_GtkAccelKey_ (gtk_accel_group_find _GtkAccelGroup_ (lambda (a b c) #f) #f))
		   (_GSList_ (gtk_accel_groups_from_object (G_OBJECT _GtkMenu_)))
		   (_list (gtk_accel_group_query _GtkAccelGroup_ GDK_C GDK_MOD1_MASK))
		   (_gboolean (gtk_accel_label_refetch _GtkAccelLabel_)))
	      (if (not (= _guint 0)) (snd-display #__line__ ";accel width: ~A" _guint))
	      (if (not (string=? _gchar_ "title")) (snd-display #__line__ ";menu title: ~A" _gchar_))
	      
	      (gtk_accel_map_foreach #f (lambda (a b c d e) #f))
	      (gtk_accel_map_foreach_unfiltered #f (lambda (a b c d e) #f)))
	    (gtk_accel_map_save (string-append home-dir "/accelmap"))
	    (gtk_accel_map_load (string-append home-dir "/accelmap"))
	    (gtk_menu_set_monitor _GtkMenu_ 0)
	    (gtk_menu_shell_select_first _GtkMenuShell_ #f)
	    (gtk_menu_shell_deselect _GtkMenuShell_)
	    (gtk_menu_shell_cancel _GtkMenuShell_)
	    (gtk_menu_shell_select_item _GtkMenuShell_ (GTK_WIDGET _GtkMenuItem_))
	    (gtk_menu_item_set_right_justified _GtkMenuItem_ #f)
	    (gtk_accel_group_lock _GtkAccelGroup_)
	    (gtk_accel_group_unlock _GtkAccelGroup_)
	    (let* ((vals (gtk_accelerator_parse "activate"))
		   (_gchar_ (gtk_accelerator_name GDK_C GDK_MOD1_MASK))
		   (_gboolean (gtk_accelerator_valid GDK_C GDK_MOD1_MASK)))
	      (if (not _gboolean) (snd-display #__line__ ";accelerator not valid"))
	      (if (not (string=? _gchar_ "<Alt>c")) (snd-display #__line__ ";accelerator name: ~A" _gchar_))
	      (if (not (equal? vals (list 0 0))) (snd-display #__line__ ";accelerator parse: ~A" vals)))
	    (gtk_menu_reposition _GtkMenu_)
	    (gtk_menu_item_activate _GtkMenuItem_)
	    (gtk_menu_set_active _GtkMenu_ 0)
	    (gtk_menu_item_toggle_size_allocate _GtkMenuItem_ 10)
	    (gtk_menu_set_tearoff_state _GtkMenu_ #f)
	    (gtk_check_menu_item_set_draw_as_radio _GtkCheckMenuItem_ #f)
	    (gtk_check_menu_item_set_inconsistent _GtkCheckMenuItem_ #f)
	    (gtk_action_connect_accelerator _GtkAction_)
	    (gtk_action_disconnect_accelerator _GtkAction_)
	    (gtk_accel_label_set_accel_closure _GtkAccelLabel_ #f)
	    (gtk_check_menu_item_set_active _GtkCheckMenuItem_ #f)
	    (gtk_accel_label_set_accel_widget _GtkAccelLabel_ _GtkWidget_)
	    (gtk_accel_label_get_accel_widget _GtkAccelLabel_)
	    (gtk_accel_map_add_filter "*.snd")
	    (gtk_menu_detach _GtkMenu_)
	    (gtk_radio_menu_item_set_group _GtkRadioMenuItem_ #f)
	    (gtk_accelerator_set_default_mod_mask GDK_MOD1_MASK)
	    (gtk_window_remove_accel_group _GtkWindow_ _GtkAccelGroup_)
	    (gtk_accel_group_disconnect _GtkAccelGroup_ #f))
	  
	  (let* ((label (gtk_label_new "hi"))
		 (_gboolean (GTK_IS_RESIZE_CONTAINER (GTK_WIDGET label)))
		 (_gboolean1 #f)
		 (_GtkExpander_ (GTK_EXPANDER (gtk_expander_new "hi")))
		 (_GtkExpander_1 (GTK_EXPANDER (gtk_expander_new_with_mnemonic "_ehi")))
		 (_GtkEditable_ (GTK_EDITABLE (gtk_entry_new)))
		 (_gboolean2 (gtk_editable_get_editable _GtkEditable_))
		 (_gboolean3 (gtk_expander_get_expanded _GtkExpander_))
		 (_gboolean4 (gtk_expander_get_use_markup _GtkExpander_))
		 (_gboolean5 (gtk_expander_get_use_underline _GtkExpander_))
		 (_gchar_ (gtk_expander_get_label _GtkExpander_))
		 (_gint (gtk_expander_get_spacing _GtkExpander_))
		 (_gint1 (gtk_editable_get_position _GtkEditable_))
		 (_GtkContainer_ (GTK_CONTAINER (gtk_vbox_new #t 0))))
	    (if _gboolean (snd-display #__line__ ";label is resize container"))
	    (if (not _gboolean2) (snd-display #__line__ ";editable not editable"))
	    (if _gboolean3 (snd-display #__line__ ";expander expanded"))
	    (if _gboolean4 (snd-display #__line__ ";expander use markup"))
	    (if _gboolean5 (snd-display #__line__ ";expander use underline"))
	    (if (not (string=? "hi" _gchar_)) (snd-display #__line__ ";expander name: ~A" _gchar_))
	    (if (not (= _gint 0)) (snd-display #__line__ ";expander spacing: ~A" _gint))
	    (if (not (= _gint1 0)) (snd-display #__line__ ";editable position: ~A" _gint1))
	    (gtk_container_add _GtkContainer_ label)
	    (gtk_container_foreach _GtkContainer_ (lambda (w c) #f) #f)
	    (gtk_container_set_resize_mode _GtkContainer_ GTK_RESIZE_IMMEDIATE)
	    (let ((_GList_ (gtk_container_get_children _GtkContainer_)))
	      (gtk_container_check_resize _GtkContainer_)
	      (gtk_container_remove _GtkContainer_ label))
	    (gtk_editable_get_chars _GtkEditable_ 0 3)
	    (gtk_editable_set_editable _GtkEditable_ #t)
	    (gtk_editable_insert_text _GtkEditable_ "hiho" 4)
	    (gtk_editable_select_region _GtkEditable_ 1 2)
	    (let ((vals (gtk_editable_get_selection_bounds _GtkEditable_)))
	      (if (not (equal? vals (list #t 1 2))) (snd-display #__line__ ";editable selection: ~A" vals)))
	    (gtk_editable_set_position _GtkEditable_ 2)
	    (gtk_editable_delete_selection _GtkEditable_)
	    (gtk_editable_delete_text _GtkEditable_ 0 1)
	    (gtk_expander_set_expanded _GtkExpander_ #f)
	    (gtk_expander_set_label _GtkExpander_ "hi")
	    (gtk_expander_set_spacing _GtkExpander_ 1)
	    (gtk_expander_set_use_markup _GtkExpander_ #f)
	    (gtk_expander_set_use_underline _GtkExpander_ #f)
	    (gtk_expander_set_label_widget _GtkExpander_ (gtk_label_new "hi"))
	    (gtk_expander_get_label_widget _GtkExpander_)
	    (let* ((_GtkStockItem_ (GtkStockItem))
		   (_GtkStockItem_1 (gtk_stock_item_copy _GtkStockItem_)))
	      (gtk_stock_lookup _gchar_ _GtkStockItem_)
	      (gtk_stock_item_free _GtkStockItem_1)))
	  
	  (let* ((_PangoAttribute_ (gdk_pango_attr_embossed_new #f))
		 (_PangoAttribute_1 (pango_attr_rise_new 2))
		 (_PangoAttribute_2 (pango_attr_scale_new 2.0))
		 (_PangoAttribute_3 (pango_attr_size_new 32))
		 (_PangoAttribute_4 (pango_attr_underline_new PANGO_UNDERLINE_SINGLE))
		 (_PangoAttrType (pango_attr_type_register "unused"))
		 (_gboolean (pango_attribute_equal _PangoAttribute_1 _PangoAttribute_2))
		 (_PangoAttribute_5 (pango_attr_family_new "Monospace"))
		 (_PangoAttribute_6 (pango_attr_background_new 0 0 0))
		 (_PangoAttribute_7 (pango_attr_foreground_new 200 100 0))
		 (_PangoAttribute_8 (pango_attr_strikethrough_new #f))
		 (_PangoAttribute_9 (pango_attr_weight_new PANGO_WEIGHT_LIGHT))
		 (_PangoAttribute_10 (pango_attr_stretch_new PANGO_STRETCH_NORMAL))
		 (_PangoAttribute_11 (pango_attr_style_new PANGO_STYLE_NORMAL))
		 (_PangoAttribute_12 (pango_attr_variant_new PANGO_VARIANT_NORMAL))
		 (_PangoContext_ (gdk_pango_context_get))
		 (_PangoItem_ (pango_item_new))
		 (_PangoItem_1 (pango_item_copy _PangoItem_))
		 (_PangoFontDescription_ (pango_font_description_new))
		 (_PangoFontDescription_1 (pango_font_description_from_string "Monospace 10"))
		 (_PangoFontDescription_2 (pango_font_description_copy _PangoFontDescription_1))
		 (_PangoFontDescription_3 (pango_font_description_copy_static _PangoFontDescription_1))
		 (_gboolean2 (pango_font_description_equal _PangoFontDescription_ _PangoFontDescription_1))
		 (_PangoGlyphString_ (pango_glyph_string_new))
		 (_PangoGlyphString_1 (pango_glyph_string_copy _PangoGlyphString_))
		 (_PangoLayout_ (pango_layout_new _PangoContext_))
		 (_PangoLayout_1 (pango_layout_copy _PangoLayout_))
		 (_PangoContext_1 (pango_layout_get_context _PangoLayout_))
		 (_PangoColor_ (PangoColor))
		 (_gboolean1 (pango_color_parse _PangoColor_ "red"))
		 (_PangoColor_1 (pango_color_copy _PangoColor_))
		 (_PangoLanguage_ (pango_language_from_string "de"))
		 (_gboolean2 (pango_language_matches _PangoLanguage_ "de"))
		 (_PangoAttribute_13 (pango_attr_language_new _PangoLanguage_)))
	    (pango_context_set_font_description _PangoContext_ _PangoFontDescription_1)
	    (pango_context_set_base_dir _PangoContext_ PANGO_DIRECTION_LTR)
	    (pango_layout_set_font_description _PangoLayout_ _PangoFontDescription_1)
	    (pango_layout_set_width _PangoLayout_ 40)
	    (pango_layout_set_indent _PangoLayout_ 0)
	    (pango_layout_set_justify _PangoLayout_ #t)
	    (pango_layout_set_spacing _PangoLayout_ 1)
	    (pango_layout_set_wrap _PangoLayout_ PANGO_WRAP_WORD)
	    (pango_layout_set_single_paragraph_mode _PangoLayout_ #f)
	    (pango_layout_set_text _PangoLayout_ "hiho" -1)
	    (pango_layout_set_alignment _PangoLayout_ PANGO_ALIGN_LEFT)
	    (let* ((_PangoFontDescription_4 (pango_context_get_font_description _PangoContext_))
		   (_PangoDirection (pango_context_get_base_dir _PangoContext_)))
	      (if (not (= _PangoDirection PANGO_DIRECTION_LTR)) (snd-display #__line__ ";pango context base dir: ~A" _PangoDirection))
	      (pango_color_free _PangoColor_1)
	      (pango_font_description_set_family _PangoFontDescription_ "Monospace")
	      (pango_font_description_set_family_static _PangoFontDescription_ "Monospace")
	      (pango_font_description_set_size _PangoFontDescription_ 16)
	      (pango_font_description_set_stretch _PangoFontDescription_ PANGO_STRETCH_NORMAL)
	      (pango_font_description_set_style _PangoFontDescription_ PANGO_STYLE_NORMAL)
	      (pango_font_description_set_weight _PangoFontDescription_ PANGO_WEIGHT_NORMAL)
	      (pango_font_description_set_variant _PangoFontDescription_ PANGO_VARIANT_NORMAL)
	      (let* ((_char_ (pango_font_description_get_family _PangoFontDescription_))
		     (_char_1 (pango_font_description_to_filename _PangoFontDescription_))
		     (_char_2 (pango_font_description_to_string _PangoFontDescription_))
		     (_PangoFontMask (pango_font_description_get_set_fields _PangoFontDescription_))
		     (_PangoStretch (pango_font_description_get_stretch _PangoFontDescription_))
		     (_PangoStyle (pango_font_description_get_style _PangoFontDescription_))
		     (_PangoVariant (pango_font_description_get_variant _PangoFontDescription_))
		     (_PangoWeight (pango_font_description_get_weight _PangoFontDescription_))
		     (_PangoAttribute_13 (pango_attr_font_desc_new _PangoFontDescription_))
		     (_gint (pango_font_description_get_size _PangoFontDescription_))
		     (_guint (pango_font_description_hash _PangoFontDescription_))
		     (_PangoAlignment (pango_layout_get_alignment _PangoLayout_))
		     (_PangoRectangle_ (PangoRectangle))
		     (_PangoLayoutLine_ (pango_layout_get_line _PangoLayout_ 0))
		     (vals (pango_layout_line_x_to_index _PangoLayoutLine_ 0))
		     (vals1 (pango_layout_xy_to_index _PangoLayout_ 0 0))
		     (_int (pango_layout_get_indent _PangoLayout_))
		     (_int1 (pango_layout_get_line_count _PangoLayout_))
		     (_int2 (pango_layout_get_spacing _PangoLayout_))
		     (_int3 (pango_layout_get_width _PangoLayout_))
		     (_gboolean (pango_layout_get_justify _PangoLayout_))
		     (_gboolean1 (pango_layout_get_single_paragraph_mode _PangoLayout_))
		     (_PangoTabArray_ (pango_layout_get_tabs _PangoLayout_))
		     (_PangoWrapMode (pango_layout_get_wrap _PangoLayout_))
		     (_GSList_ (pango_layout_get_lines _PangoLayout_))
		     (_char_2 (pango_layout_get_text _PangoLayout_))
		     (_PangoLayoutIter_ (pango_layout_get_iter _PangoLayout_))
		     (vals2 (pango_layout_get_size _PangoLayout_))
		     (vals3 (pango_layout_get_pixel_size _PangoLayout_))
		     (_PangoRectangle_1 (PangoRectangle))
		     (_PangoRectangle_2 (PangoRectangle))
		     (_PangoLogAttr_ (PangoLogAttr))
		     (_PangoLayoutLine_1 (pango_layout_iter_get_line _PangoLayoutIter_))
		     (_gboolean3 (pango_layout_iter_at_last_line _PangoLayoutIter_))
		     (_gboolean4 (pango_layout_iter_next_char _PangoLayoutIter_))
		     (_gboolean5 (pango_layout_iter_next_cluster _PangoLayoutIter_))
		     (_gboolean6 (pango_layout_iter_next_line _PangoLayoutIter_))
		     (_gboolean7 (pango_layout_iter_next_run _PangoLayoutIter_))
		     (_int (pango_layout_iter_get_baseline _PangoLayoutIter_))
		     (_int (pango_layout_iter_get_index _PangoLayoutIter_))
		     (vals4 (pango_layout_iter_get_line_yrange _PangoLayoutIter_))
		     (_PangoLayoutRun_ (pango_layout_iter_get_run _PangoLayoutIter_))
		     (_PangoAttrList_1 (pango_layout_get_attributes _PangoLayout_))
		     (_PangoAttrList_ (pango_attr_list_new))
		     (_PangoAttrList_3 (pango_attr_list_new)))
		(if (not (string=? _char_ "Monospace")) (snd-display #__line__ ";font descr familt: ~A" _char_))
		(if (not (= _PangoStretch PANGO_STRETCH_NORMAL)) (snd-display #__line__ ";font descr stretch: ~A" _PangoStretch))
		(if (not (= _PangoStyle PANGO_STYLE_NORMAL)) (snd-display #__line__ ";font descr style: ~A" _PangoStyle))
		(if (not (= _PangoWeight PANGO_WEIGHT_NORMAL)) (snd-display #__line__ ";font descr weight: ~A" _PangoWeight))
		(if (not (= _PangoVariant PANGO_VARIANT_NORMAL)) (snd-display #__line__ ";font descr variant: ~A" _PangoVariant))
		(if (not (= _PangoAlignment PANGO_ALIGN_LEFT)) (snd-display #__line__ ";layout align: ~A" _PangoAlignment))
		(pango_layout_index_to_pos _PangoLayout_ 0 _PangoRectangle_)
		(pango_layout_get_cursor_pos _PangoLayout_ 0 _PangoRectangle_1 _PangoRectangle_2)
		(pango_layout_get_extents _PangoLayout_ _PangoRectangle_1 _PangoRectangle_2)
		(pango_layout_get_pixel_extents _PangoLayout_ _PangoRectangle_1 _PangoRectangle_2)
		(pango_layout_set_tabs _PangoLayout_ _PangoTabArray_)
		(pango_layout_iter_get_char_extents _PangoLayoutIter_ _PangoRectangle_)
		(pango_layout_iter_get_cluster_extents _PangoLayoutIter_ _PangoRectangle_2 _PangoRectangle_2)
		(pango_layout_iter_get_layout_extents _PangoLayoutIter_ _PangoRectangle_1 _PangoRectangle_2)
		(pango_layout_iter_get_line_extents _PangoLayoutIter_ _PangoRectangle_1 _PangoRectangle_2)
		(pango_layout_iter_get_run_extents _PangoLayoutIter_ _PangoRectangle_1 _PangoRectangle_2)
		(pango_attr_list_change _PangoAttrList_ _PangoAttribute_)
		(pango_attr_list_insert _PangoAttrList_ _PangoAttribute_2)
		(pango_attr_list_insert_before _PangoAttrList_ _PangoAttribute_1)
		(pango_attr_list_insert _PangoAttrList_3 _PangoAttribute_4)
		(pango_attr_list_splice _PangoAttrList_ _PangoAttrList_3 0 1)
		(pango_layout_set_attributes _PangoLayout_ _PangoAttrList_)
		(pango_context_set_language _PangoContext_ _PangoLanguage_)
		(let* ((_PangoAttrList_1 (pango_attr_list_copy _PangoAttrList_))
		       (_PangoAttrIterator_ (pango_attr_list_get_iterator _PangoAttrList_))
		       (_PangoAttrIterator_1 (pango_attr_iterator_copy _PangoAttrIterator_))
		       (_PangoAttribute_16 (pango_attr_iterator_get _PangoAttrIterator_ PANGO_ATTR_SIZE))
		       (_gboolean (pango_attr_iterator_next _PangoAttrIterator_))
		       (vals (pango_attr_iterator_get_font _PangoAttrIterator_ _PangoFontDescription_))
		       (vals1 (pango_attr_iterator_range _PangoAttrIterator_))
		       (_PangoLanguage_1 (pango_context_get_language _PangoContext_))
		       (_PangoFontset_ (pango_context_load_fontset _PangoContext_ _PangoFontDescription_ _PangoLanguage_))
		       (_PangoGlyphString_ (pango_glyph_string_new))
		       (_PangoAttribute_17 (pango_attr_shape_new _PangoRectangle_1 _PangoRectangle_2))
		       (_PangoFontMetrics_ (pango_context_get_metrics _PangoContext_ _PangoFontDescription_ _PangoLanguage_))
		       (_PangoFontMetrics_1 (pango_font_metrics_ref _PangoFontMetrics_))
		       (_PangoFont_ (pango_context_load_font _PangoContext_ _PangoFontDescription_))
		       (_int (pango_font_metrics_get_approximate_char_width _PangoFontMetrics_))
		       (_int1 (pango_font_metrics_get_approximate_digit_width _PangoFontMetrics_))
		       (_int2 (pango_font_metrics_get_ascent _PangoFontMetrics_))
		       (_int3 (pango_font_metrics_get_descent _PangoFontMetrics_))
		       (_PangoFontMetrics_2 (pango_font_get_metrics _PangoFont_ _PangoLanguage_))
		       (_PangoFontDescription_ (pango_font_describe _PangoFont_))
		       (vals2 (pango_context_list_families _PangoContext_))
		       (_GList_ (pango_itemize _PangoContext_ "hiho" 0 0 _PangoAttrList_ _PangoAttrIterator_)))
		  (pango_glyph_string_set_size _PangoGlyphString_ 10)
		  (pango_font_description_unset_fields _PangoFontDescription_ _PangoFontMask)
		  (pango_layout_context_changed _PangoLayout_)
		  (pango_font_description_merge _PangoFontDescription_ _PangoFontDescription_2 #f)
		  (pango_font_description_merge_static _PangoFontDescription_ _PangoFontDescription_2 #f)
		  (pango_attribute_destroy _PangoAttribute_4)
		  (pango_font_description_free _PangoFontDescription_)
		  (pango_layout_iter_free _PangoLayoutIter_)
		  (pango_item_free _PangoItem_)
		  (pango_attr_iterator_destroy _PangoAttrIterator_)
		  (pango_glyph_string_free _PangoGlyphString_)
		  (pango_font_metrics_unref _PangoFontMetrics_1)))))
	  
	  (if (not (provided? 'cairo))
	      (let* ((_GdkScreen_ (gdk_screen_get_default))
		     (_GtkWidget_ (cadr (main-widgets)))
		     (scan-outer (let ((pane (gtk_hbox_new #f 0)))
				   (gtk_box_pack_start (GTK_BOX (list-ref (main-widgets) 5)) pane #f #f 4)
				   (gtk_widget_show pane)
				   pane))
		     (scan-pane (let ((grf (gtk_drawing_area_new)))
				  (gtk_widget_set_events grf GDK_ALL_EVENTS_MASK)
				  (gtk_box_pack_start (GTK_BOX scan-outer) grf #t #t 0)
				  (gtk_widget_show grf)
				  (gdk_window_set_background (gtk_widget_get_window grf) (graph-color))
				  grf))
		     (red-pixel
		      (let ((tmp (GdkColor)))
			(gdk_color_parse "red" tmp)
			(let ((col (gdk_color_copy tmp)))
			  (gdk_rgb_find_color (gdk_colormap_get_system) col)
			  col)))
		     (wnd (gtk_widget_get_window scan-pane))
		     (_GdkWindow_ wnd)
		     (wn (GDK_DRAWABLE wnd))
		     (vect (make-vector 4 0))
		     (pts1 #f)
		     (vals (gdk_drawable_get_size wn))
		     (_GdkColormap_ (gdk_colormap_get_system))
		     (_GdkColor_ (gdk_color_copy red-pixel))
		     (_gboolean (gdk_color_equal _GdkColor_ red-pixel))
		     (_gboolean1 (gdk_colormap_alloc_color _GdkColormap_ _GdkColor_ #f #f))
		     (_PangoLayout_ (gtk_widget_create_pango_layout scan-pane "hi"))
		     (_GdkRegion_ (gdk_drawable_get_clip_region wn))
		     (_GdkRegion_1 (gdk_drawable_get_visible_region wn))
		     (_GdkVisual_ (gdk_drawable_get_visual wn))
		     (_GdkAtom (gdk_atom_intern "MY_MESSAGE" #t))
		     (_GtkIMContext_ (gtk_im_context_simple_new))
		     (_GtkIMContext_1 (gtk_im_multicontext_new))
		     (_GtkWindow_ (GTK_WINDOW (cadr (main-widgets))))
		     (_GdkWindow_1 (gdk_selection_owner_get GDK_SELECTION_PRIMARY))
		     (_gchar_ (gdk_atom_name GDK_SELECTION_SECONDARY))
		     (_gchar_1 (gdk_utf8_to_string_target "hiho"))
		     (_gchar_2 (gtk_check_version 2 3 1))
		     (_guint (gtk_container_get_border_width (GTK_CONTAINER scan-outer)))
		     (_GtkResizeMode (gtk_container_get_resize_mode (GTK_CONTAINER scan-outer)))
		     (zero (g_signal_lookup "activate" G_TYPE_OBJECT))
		     (_int (gdk_screen_get_monitor_at_point _GdkScreen_ 0 0))
		     (_int1 (gdk_screen_get_monitor_at_window _GdkScreen_ _GdkWindow_))
		     (_gint (gdk_drawable_get_depth wn))
		     (hi (g_quark_from_string "hiho")))
		(if (not (string=? (g_quark_to_string hi) "hiho")) (snd-display #__line__ ";g quark/string: ~A ~A" hi (g_quark_to_string hi)))
		(if (not _gboolean) (snd-display #__line__ ";gdk colors copy not equal"))
		(if (not (string=? _gchar_ "SECONDARY")) (snd-display #__line__ ";atom name: ~A" _gchar_))
		(gdk_colormap_query_color _GdkColormap_ 0 _GdkColor_)
		(gdk_color_hash _GdkColor_)
		(gdk_set_double_click_time 200)
		(gdk_screen_get_monitor_geometry _GdkScreen_ 0 (GdkRectangle))
		(gdk_screen_set_default_colormap _GdkScreen_ _GdkColormap_)
		(vector-set! vect 1 10)
		(vector-set! vect 2 20)
		(vector-set! vect 3 30)
		(let ((sgc (car (snd-gcs))))
		  (gdk_draw_rectangle wn sgc #t 0 0 100 100)
		  (gdk_draw_line wn sgc 0 0 100 100)
		  (gdk_draw_point wn sgc 10 10)
		  (gdk_draw_arc wn sgc #f 10 10 20 20 0 (* 45 64))
		  (gdk_add_client_message_filter (gdk_atom_intern "SND_MESSAGE" #f) (lambda (xe e d) #f) #f)
		  (set! pts1 (vector->GdkPoints vect))
		  (gdk_draw_lines wn sgc (list 'GdkPoint_ pts1) 2)
		  (gdk_draw_segments wn sgc (list 'GdkSegment_ pts1) 1)
		  (gdk_draw_points wn sgc (list 'GdkPoint_ pts1) 2)
		  (gdk_draw_polygon wn sgc #f (list 'GdkPoint_ pts1) 2)
		  (freeGdkPoints pts1)
		  (gdk_drawable_set_colormap wn (gdk_colormap_get_system))
		  (gdk_draw_layout wn sgc 0 0 _PangoLayout_))
		(gdk_window_clear wnd)
		(gdk_window_clear_area wnd 0 0 10 10)
		(gdk_window_clear_area_e wnd 0 0 10 10)
		(gdk_window_begin_paint_rect wnd (GdkRectangle 0 0 10 10))
		(let* ((_GdkImage_ (gdk_drawable_get_image wn 0 0 20 20)) ; -> #f
		       (_GtkImage_ (GTK_IMAGE (gtk_image_new)))
		       (_GtkImageType (gtk_image_get_storage_type _GtkImage_)))
		  (gtk_image_set_from_stock _GtkImage_ GTK_STOCK_CANCEL 32)
		  (let* ((_GdkPixbuf_ (gtk_image_get_pixbuf (GTK_IMAGE (gtk_image_new)))) ; -> #f
			 (_GdkImage_1 (gdk_image_new GDK_IMAGE_NORMAL _GdkVisual_ 32 32))
			 (_GdkImage_2 (gdk_drawable_copy_to_image wn _GdkImage_1 0 0 0 0 32 32))
			 (_GdkPixbuf_1 (gdk_pixbuf_get_from_image _GdkPixbuf_ _GdkImage_1 _GdkColormap_ 0 0 0 0 32 32))
			 (_GdkPixbuf_2 (gdk_pixbuf_copy _GdkPixbuf_1))
			 (_GdkPixmap_ (gdk_pixmap_new (GDK_DRAWABLE (car (main-widgets))) 16 16 -1))
			 (arrow-strs (list
				      "16 12 6 1"
				      " 	c None s None"
				      ".	c gray50"
				      "X	c black"
				      "o	c white"
				      "O	c yellow"
				      "-      c ivory2 s basiccolor"
				      "--------X---------"
				      "---------X--------"
				      "----------X-------"
				      "-----------X------"
				      "------------X-----"
				      "XXXXXXXXXXXXXX----"
				      "------------X-----"
				      "-----------X------"
				      "----------X-------"
				      "---------X--------"
				      "--------X---------"
				      "-------X----------"))
			 (_GdkPixmap_1 (gdk_pixmap_create_from_xpm_d (GDK_DRAWABLE (car (main-widgets))) #f (basic-color) (list->c-array arrow-strs "gchar**")))
			 (_GdkColorspace (gdk_pixbuf_get_colorspace _GdkPixbuf_1))
			 (_GtkWidget_2 (gtk_image_new_from_pixbuf _GdkPixbuf_1))
			 (_GdkPixbuf_3 (gdk_pixbuf_get_from_drawable _GdkPixbuf_1 (GDK_DRAWABLE _GdkPixmap_1) _GdkColormap_ 0 0 0 0 10 10))
			 (_PangoContext_ (gdk_pango_context_get))
			 (_PangoLayout_ (pango_layout_new _PangoContext_))
			 (_GdkPixbuf_5 (gdk_pixbuf_new_from_xpm_data (list->c-array arrow-strs "char**")))
			 (_GdkPixbuf_4 (gdk_pixbuf_new _GdkColorspace #f 8 10 10))
			 (_gboolean (gdk_pixbuf_get_has_alpha _GdkPixbuf_5))
			 (_guchar_ (gdk_pixbuf_get_pixels _GdkPixbuf_5))
			 (_int (gdk_pixbuf_get_bits_per_sample _GdkPixbuf_5))
			 (_int1 (gdk_pixbuf_get_height _GdkPixbuf_5))
			 (_int2 (gdk_pixbuf_get_n_channels _GdkPixbuf_5))
			 (_int3 (gdk_pixbuf_get_rowstride _GdkPixbuf_5))
			 (_int4 (gdk_pixbuf_get_width _GdkPixbuf_5))
			 (_gchar_ (gdk_pixbuf_get_option _GdkPixbuf_5 "hi")))
		    (let ((sgc (car (snd-gcs))))
		      (gdk_draw_image wn sgc _GdkImage_1 0 0 0 0 32 32)
		      (gdk_draw_drawable wn sgc (GDK_DRAWABLE _GdkPixmap_1) 0 0 0 0 32 32)
		      (gdk_draw_gray_image wn sgc 0 0 10 10 GDK_RGB_DITHER_NONE "hihohohio" 0)
		      (gdk_draw_rgb_image wn sgc 0 0 10 10 GDK_RGB_DITHER_NONE "hihohohio" 0)
		      (gdk_draw_rgb_32_image wn sgc 0 0 10 10 GDK_RGB_DITHER_NONE "hihohohio" 0)
		      (pango_layout_set_text _PangoLayout_ "hiho" -1)
		      (let ((_PangoLayoutLine_ (pango_layout_get_line _PangoLayout_ 0)))
			(gdk_draw_layout_line wn sgc 0 0 _PangoLayoutLine_))
		      (gdk_pixbuf_fill _GdkPixbuf_3 0))))
		
		
		(gdk_color_free _GdkColor_)
		(gdk_rgb_set_min_colors 8)
		(let ((_GdkRgbCmap_ (gdk_rgb_cmap_new (list->c-array '(0 0 0 0 0 0 0 0) "guint32*") 8)))
		  (gdk_rgb_cmap_free _GdkRgbCmap_))
		(gdk_property_change wnd _GdkAtom GDK_TARGET_STRING 8 GDK_PROP_MODE_REPLACE "hiho" 4)
		(gdk_property_delete wnd _GdkAtom)
		(gdk_window_show wnd)
		(gtk_window_stick _GtkWindow_)
		(gtk_window_unstick _GtkWindow_)
		(gdk_window_stick wnd)
		(gdk_window_unstick wnd)
		(gtk_window_add_embedded_xid _GtkWindow_ 12345)
		(gtk_window_remove_embedded_xid _GtkWindow_ 12345)
		(gtk_window_set_accept_focus _GtkWindow_ #t)
		(gtk_window_set_decorated _GtkWindow_ #t)
		(gtk_window_set_destroy_with_parent _GtkWindow_ #t)
		(gdk_window_begin_paint_region _GdkWindow_ _GdkRegion_)
		(gdk_window_deiconify _GdkWindow_)
		(gdk_window_end_paint _GdkWindow_)
		(gdk_window_freeze_updates _GdkWindow_)
		(gdk_window_thaw_updates _GdkWindow_)
		(gdk_window_get_frame_extents _GdkWindow_ (GdkRectangle))
		(gdk_window_invalidate_rect _GdkWindow_ (GdkRectangle 0 0 10 10) #f)
		(gdk_window_invalidate_region _GdkWindow_ _GdkRegion_ #f)
		(gdk_window_move _GdkWindow_ 0 0)
		(gdk_window_move_resize _GdkWindow_ 0 0 500 800)
		(gdk_window_resize _GdkWindow_ 500 800)
;		(gdk_window_set_accept_focus _GdkWindow_ #t)
		(gdk_window_set_background _GdkWindow_ red-pixel)
		(gdk_window_set_cursor _GdkWindow_ (gdk_cursor_new GDK_BOTTOM_TEE))
		(gdk_window_set_icon_name _GdkWindow_ "hiho")
		(gtk_window_move _GtkWindow_ 200 20)
		(gdk_window_resize (gtk_widget_get_window _GtkWidget_) 800 500)
		(let ((_guint (g_idle_add_full G_PRIORITY_DEFAULT_IDLE (lambda (n) #f) 1234 #f)))
		  (g_source_remove _guint))
		
		#|
		(let ((_GtkTargetList_ (gtk_target_list_new #f 0)))
		(gtk_target_list_add _GtkTargetList_ GDK_TARGET_STRING 0 0)
					;		(gtk_target_list_ref _GtkTargetList_)
		(gtk_target_list_unref _GtkTargetList_)
		(gtk_target_list_remove _GtkTargetList_ GDK_TARGET_STRING)
		(gtk_drag_dest_set (cadr (main-widgets)) GTK_DEST_DEFAULT_ALL 
		(make-target-entry (list (list "STRING" 0 0) (list "FILENAME" 0 0))) 2 
		(logior GDK_ACTION_COPY GDK_ACTION_MOVE))
		(let ((trg (gtk_drag_dest_get_target_list (cadr (main-widgets)))))
		(gtk_drag_dest_set_target_list (cadr (main-widgets)) trg))
		
		)
		|#
		(let* ((_GtkRadioAction_ (gtk_radio_action_new "hi" "label" "tool" GTK_STOCK_CANCEL 0))
		       (_gint (gtk_radio_action_get_current_value _GtkRadioAction_))
		       (_GSList_ (gtk_radio_action_get_group _GtkRadioAction_)))
		  (if (not (= 0 _gint)) (snd-display #__line__ ";radio action value: ~A" _gint)))))
	  
	  (let ((dialog (gtk_about_dialog_new)))
	    ;; sort of half-implemented, apparently
	    (if (not (GTK_IS_ABOUT_DIALOG dialog)) (snd-display #__line__ ";about dialog isn't?"))
	    (gtk_about_dialog_set_version (GTK_ABOUT_DIALOG dialog) "1234.4321.89765")
	    (let ((version (gtk_about_dialog_get_version (GTK_ABOUT_DIALOG dialog))))
	      (if (not (string=? version "1234.4321.89765")) (snd-display #__line__ ";about dialog version: ~A" version)))
	    (gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG dialog) "(c) 1234 Roger Bacon")
	    (let ((copyright (gtk_about_dialog_get_copyright (GTK_ABOUT_DIALOG dialog))))
	      (if (not (string=? copyright "(c) 1234 Roger Bacon")) (snd-display #__line__ ";about dialog copyright: ~A" copyright)))
	    (gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG dialog) "This here dialog is About")
	    (let ((comments (gtk_about_dialog_get_comments (GTK_ABOUT_DIALOG dialog))))
	      (if (not (string=? comments "This here dialog is About")) (snd-display #__line__ ";about dialog comments: ~A" comments)))
	    (gtk_about_dialog_set_license (GTK_ABOUT_DIALOG dialog) "You can't use this, it sez right here!")
	    (let ((license (gtk_about_dialog_get_license (GTK_ABOUT_DIALOG dialog))))
	      (if (not (string=? license "You can't use this, it sez right here!")) (snd-display #__line__ ";about dialog license: ~A" license)))
	    (gtk_about_dialog_set_website (GTK_ABOUT_DIALOG dialog) "http://www.this.is.silly.com")
	    (let ((website (gtk_about_dialog_get_website (GTK_ABOUT_DIALOG dialog))))
	      (if (not (string=? website "http://www.this.is.silly.com")) (snd-display #__line__ ";about dialog website: ~A" website)))
	    (gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG dialog) "The Home Of About")
	    (let ((website_label (gtk_about_dialog_get_website_label (GTK_ABOUT_DIALOG dialog))))
	      (if (and (string? website_label)
		       (not (string=? website_label "The Home Of About")))
		  (snd-display #__line__ ";about dialog website_label: ~A" website_label)))
	    (gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG dialog) (list->c-array (list "Who" "Why") "gchar**"))
	    (gtk_about_dialog_set_documenters (GTK_ABOUT_DIALOG dialog) (list->c-array (list "gah" "use an o") "gchar**"))
	    (let ((documenters (c-array->list (gtk_about_dialog_get_documenters (GTK_ABOUT_DIALOG dialog)) 2)))
	      (if (and (list? documenters)
		       (string? (car documenters))
		       (not (string=? (car documenters) "gah")))
		  (snd-display #__line__ ";about dialog documenters: ~A" documenters)))
	    (gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG dialog) (list->c-array (list "Me!" "Just me!") "gchar**"))
	    (let ((artists (c-array->list (gtk_about_dialog_get_artists (GTK_ABOUT_DIALOG dialog)) 2)))
	      (if (and (list? artists)
		       (string? (car artists))
		       (not (string=? (car artists) "Me!")))
		  (snd-display #__line__ ";about dialog artists: ~A" artists)))
	    (gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG dialog) "he did it all")
	    (gtk_widget_show dialog)
	    (gtk_widget_hide dialog))
	  
	  (let* ((_GtkListStore_ (gtk_list_store_new 1 (list G_TYPE_STRING)))
		 (_GtkTreeModelc_ (GTK_TREE_MODEL _GtkListStore_))
		 (_GtkComboBox_ (GTK_COMBO_BOX (gtk_combo_box_new_with_model _GtkTreeModelc_))))
	    (gtk_combo_box_set_add_tearoffs _GtkComboBox_ #t)
	    (if (not (gtk_combo_box_get_add_tearoffs _GtkComboBox_)) (snd-display #__line__ ";combo tear offs?"))
	    (let ((gint0 (gtk_combo_box_get_wrap_width _GtkComboBox_))
		  (gint1 (gtk_combo_box_get_row_span_column _GtkComboBox_))
		  (gint2 (gtk_combo_box_get_column_span_column _GtkComboBox_))
		  (gchar (gtk_combo_box_get_active_text _GtkComboBox_)))
	      (if (or (not (= gint0 0)) (not (= gint1 -1))  (not (= gint2 -1)))
		  (snd-display #__line__ ";combo gints: ~A ~A ~A" gint0 gint1 gint2))))
	  
	  
	  ;; taken from gtk demo dir
	  (let ((vbox (gtk_vbox_new #f 0)))
	    (let ((tool_bar (gtk_toolbar_new)))
	      (gtk_box_pack_start (GTK_BOX vbox) tool_bar #f #f 0)
	      (let ((up_button (gtk_tool_button_new_from_stock GTK_STOCK_GO_UP)))
		(gtk_tool_item_set_is_important up_button #t)
		(gtk_widget_set_sensitive (GTK_WIDGET up_button) #f)
		(gtk_toolbar_insert (GTK_TOOLBAR tool_bar) up_button -1)
		(let ((home_button (gtk_tool_button_new_from_stock GTK_STOCK_HOME)))
		  (gtk_tool_item_set_is_important home_button #t)
		  (gtk_toolbar_insert (GTK_TOOLBAR tool_bar) home_button -1)
		  (let ((sw (gtk_scrolled_window_new #f #f)))
		    (gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW sw) GTK_SHADOW_ETCHED_IN)
		    (gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW sw) GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC)
		    (gtk_box_pack_start (GTK_BOX vbox) sw #t #t 0)
		    (let ((store (gtk_list_store_new 2 (list G_TYPE_STRING GDK_TYPE_PIXBUF))))
		      (gtk_list_store_clear store)
		      (let ((iter (GtkTreeIter)))
			(for-each
			 (lambda (path)
			   (gtk_list_store_append store iter)
			   (gtk_list_store_set store iter
					       (list 0 path
						     1 #f)))
			 (sounds))
			(let ((icon_view (gtk_icon_view_new_with_model (GTK_TREE_MODEL store))))
			  (gtk_icon_view_set_selection_mode (GTK_ICON_VIEW icon_view) GTK_SELECTION_SINGLE)
			  ;; just calls
			  (if (not (GTK_IS_ICON_VIEW icon_view)) (snd-display #__line__ ";not icon view?"))
			  (let ((gint0 (gtk_icon_view_get_text_column (GTK_ICON_VIEW icon_view)))
				(gint1 (gtk_icon_view_get_pixbuf_column (GTK_ICON_VIEW icon_view))))
			    (if (or (not (= gint0 -1)) (not (= gint1 -1))) (snd-display #__line__ ";icon view cols: ~A ~A" gint0 gint1)))
			  (let ((ic (gtk_icon_view_new)))
			    (if (not (GTK_IS_ICON_VIEW ic)) (snd-display #__line__ ";icon view2?"))
			    (gtk_icon_view_set_orientation (GTK_ICON_VIEW ic) GTK_ORIENTATION_VERTICAL)
			    (if (not (= (gtk_icon_view_get_orientation (GTK_ICON_VIEW ic)) GTK_ORIENTATION_VERTICAL))
				(snd-display #__line__ ";icon view orientation")))
			  (let ((model (gtk_icon_view_get_model (GTK_ICON_VIEW icon_view))))
			    (if (not (GTK_TREE_MODEL model)) (snd-display #__line__ ";icon view model: ~A (~A)" model store))
			    (gtk_icon_view_set_model (GTK_ICON_VIEW icon_view) (GTK_TREE_MODEL store)))
			  (let ((gint0 (gtk_icon_view_get_markup_column (GTK_ICON_VIEW icon_view))))
			    (if (not (= gint0 -1)) (snd-display #__line__ ";icon view markup: ~A" gint0)))
			  (let ((gint0 (gtk_icon_view_get_selection_mode (GTK_ICON_VIEW icon_view))))
			    (if (not (= gint0 GTK_SELECTION_SINGLE)) (snd-display #__line__ ";icon view selection mode")))
			  (gtk_icon_view_set_markup_column (GTK_ICON_VIEW icon_view) -1)
			  (gtk_icon_view_select_all (GTK_ICON_VIEW icon_view))
			  (gtk_icon_view_unselect_all (GTK_ICON_VIEW icon_view))
			  ;; end just calls
			  (g_signal_connect up_button "clicked" (lambda (item data) #f) store)
			  (g_signal_connect home_button "clicked" (lambda (item data) #f) store)
			  (gtk_icon_view_set_text_column (GTK_ICON_VIEW icon_view) 0)
			  (gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW icon_view) 1)
			  (g_signal_connect icon_view "item_activated" 
					    (lambda (iconview treepath data) 
					      #f)
					    store)
			  (gtk_container_add (GTK_CONTAINER sw) icon_view)
			  (gtk_widget_grab_focus icon_view)))))))))
	  
	  (let ((store (gtk_list_store_new 2 (list G_TYPE_STRING G_TYPE_BOOLEAN))))
	    (let ((cell0 (gtk_cell_view_new))
		  (cell1 (gtk_cell_view_new_with_text "hiho")))
	      (if (not (GTK_IS_CELL_VIEW cell1)) (snd-display #__line__ ";not cell view? ~A" cell1))
	      (gtk_cell_view_set_model (GTK_CELL_VIEW cell1) (GTK_TREE_MODEL store))
	      (if (not (provided? 'cairo))
		  (gtk_cell_view_set_background_color (GTK_CELL_VIEW cell1) (basic-color)))
	      ))
	  
	  (let* ((_PangoLanguage_ (pango_language_from_string "de"))
		 (_PangoContext_ (gdk_pango_context_get))
		 (_PangoFontDescription_ (pango_font_description_from_string "Monospace 10"))
		 (_PangoFont_ (pango_context_load_font _PangoContext_ _PangoFontDescription_))
		 (_PangoFontMetrics_ (pango_font_get_metrics _PangoFont_ _PangoLanguage_))
		 (_PangoScript (pango_script_for_unichar 12345))
		 (_PangoScriptIter_ (pango_script_iter_new "hi" 2)))
	    (let ((int0 (pango_font_metrics_get_underline_position _PangoFontMetrics_))
		  (int1 (pango_font_metrics_get_underline_thickness _PangoFontMetrics_))
		  (int2 (pango_font_metrics_get_strikethrough_position _PangoFontMetrics_))
		  (int3 (pango_font_metrics_get_strikethrough_thickness _PangoFontMetrics_)))
	      (if (or (and (not (= int0 -1024)) (not (= int0 0)))
		      (not (= int1 1024)) 
		      (and (not (= int2 3072)) (not (= int2 4096))) 
		      (not (= int3 1024)))
		  (snd-display #__line__ ";pango underlines: ~A ~A ~A ~A" int0 int1 int2 int3)))
	    (if (not _PangoScript) (snd-display #__line__ ";pango script: ~A" _PangoScript))
	    (pango_script_iter_get_range _PangoScriptIter_)
	    (pango_script_iter_next _PangoScriptIter_)
	    (pango_script_iter_free _PangoScriptIter_))
	  
	  (let ((cell0 (gtk_cell_renderer_combo_new))
		(cell1 (gtk_cell_renderer_progress_new)))
	    (if (not (GTK_IS_CELL_RENDERER_COMBO cell0)) (snd-display #__line__ ";not cell renderer combo?"))
	    (if (not (GTK_IS_CELL_RENDERER_PROGRESS cell1)) (snd-display #__line__ ";not cell renderer progress?")))
	  
	  (let* ((breakable-gtk-procs 
		  (list ; these are problematic, but make sure they are defined
		   g_free g_signal_lookup g_source_remove g_type_from_name g_type_is_a
		   g_type_name g_type_parent g_type_qname gdk_atom_intern gdk_init
		   gdk_init_check gdk_pixmap_new gdk_set_show_events gdk_threads_enter gdk_threads_init
		   gdk_threads_leave gdk_utf8_to_string_target gtk_accel_map_load gtk_accel_map_load_fd ;gtk_accel_map_load_scanner
		   gtk_accel_map_lookup_entry gtk_accel_map_save gtk_accel_map_save_fd gtk_button_new_with_label gtk_check_button_new_with_label
		   gtk_check_menu_item_new_with_label gtk_color_selection_palette_from_string gtk_disable_setlocale gtk_icon_size_from_name 
		   gtk_image_menu_item_new_with_label
		   gtk_init gtk_init_add gtk_init_check gtk_key_snooper_install gtk_key_snooper_remove
		   gtk_main gtk_main_do_event gtk_main_iteration gtk_main_iteration_do gtk_main_level
		   gtk_main_quit gtk_menu_item_new_with_label gtk_quit_add gtk_quit_add_destroy gtk_quit_remove
		   gtk_quit_remove_by_data gtk_radio_button_new_with_label gtk_radio_menu_item_new_with_label 
		   gtk_rc_find_module_in_path gtk_toggle_button_new_with_label
		   pango_coverage_from_bytes pango_find_paragraph_boundary pango_language_from_string pango_script_iter_new 
		   ))
		 
		 (gtk-procs 
		  (list
		   GDK_COLORMAP GDK_DEVICE GDK_DISPLAY_OBJECT GDK_DRAG_CONTEXT GDK_DRAWABLE
		   GDK_EVENT_ANY GDK_EVENT_BUTTON GDK_EVENT_CONFIGURE GDK_EVENT_CROSSING GDK_EVENT_DND
		   GDK_EVENT_EXPOSE GDK_EVENT_FOCUS GDK_EVENT_KEY GDK_EVENT_MOTION GDK_EVENT_NOEXPOSE
		   GDK_EVENT_PROPERTY GDK_EVENT_PROXIMITY GDK_EVENT_SCROLL GDK_EVENT_SELECTION GDK_EVENT_SETTING
		   GDK_EVENT_VISIBILITY GDK_EVENT_WINDOWSTATE GDK_GC GDK_IMAGE GDK_IS_COLORMAP
		   GDK_IS_DEVICE GDK_IS_DISPLAY GDK_IS_DRAG_CONTEXT GDK_IS_DRAWABLE GDK_IS_GC
		   GDK_IS_IMAGE GDK_IS_KEYMAP GDK_IS_PANGO_RENDERER GDK_IS_PIXBUF GDK_IS_PIXBUF_ANIMATION
		   GDK_IS_PIXBUF_ANIMATION_ITER ;GDK_IS_PIXBUF_LOADER 
		   GDK_IS_PIXMAP GDK_IS_SCREEN GDK_IS_VISUAL
		   GDK_IS_WINDOW GDK_KEYMAP GDK_PANGO_RENDERER GDK_PIXBUF GDK_PIXBUF_ANIMATION
		   GDK_PIXBUF_ANIMATION_ITER ;GDK_PIXBUF_LOADER 
		   GDK_PIXMAP GDK_SCREEN GDK_VISUAL
		   GDK_WINDOW GPOINTER GTK_ABOUT_DIALOG GTK_ACCEL_GROUP GTK_ACCEL_LABEL
		   GTK_ACCEL_MAP GTK_ACCESSIBLE GTK_ACTION GTK_ACTION_GROUP GTK_ADJUSTMENT
		   GTK_ALIGNMENT GTK_ARROW GTK_ASPECT_FRAME GTK_BIN GTK_BOX
		   GTK_BUTTON GTK_BUTTON_BOX GTK_CALENDAR GTK_CELL_EDITABLE GTK_CELL_LAYOUT
		   GTK_CELL_RENDERER GTK_CELL_RENDERER_COMBO GTK_CELL_RENDERER_PIXBUF GTK_CELL_RENDERER_PROGRESS GTK_CELL_RENDERER_TEXT
		   GTK_CELL_RENDERER_TOGGLE GTK_CELL_VIEW GTK_CHECK_BUTTON GTK_CHECK_MENU_ITEM GTK_CLIPBOARD
		   GTK_COLOR_BUTTON GTK_COLOR_SELECTION GTK_COLOR_SELECTION_DIALOG GTK_COMBO_BOX GTK_COMBO_BOX_ENTRY
		   GTK_CONTAINER GTK_DIALOG GTK_DRAWING_AREA GTK_EDITABLE
		   GTK_ENTRY GTK_ENTRY_COMPLETION GTK_EVENT_BOX GTK_EXPANDER GTK_FILE_CHOOSER
		   GTK_FILE_CHOOSER_BUTTON GTK_FILE_CHOOSER_DIALOG GTK_FILE_CHOOSER_WIDGET GTK_FILE_FILTER ;GTK_FILE_SELECTION
		   GTK_FIXED GTK_FONT_BUTTON GTK_FONT_SELECTION GTK_FONT_SELECTION_DIALOG GTK_FRAME
		   GTK_HANDLE_BOX GTK_HBOX GTK_HBUTTON_BOX GTK_HPANED
		   GTK_HRULER GTK_HSCALE GTK_HSCROLLBAR GTK_HSEPARATOR GTK_ICON_FACTORY
		   GTK_ICON_THEME GTK_ICON_VIEW GTK_IMAGE GTK_IMAGE_MENU_ITEM GTK_IM_CONTEXT
		   GTK_IM_CONTEXT_SIMPLE GTK_IM_MULTICONTEXT GTK_INVISIBLE GTK_IS_ABOUT_DIALOG
		   GTK_IS_ACCEL_GROUP GTK_IS_ACCEL_LABEL GTK_IS_ACCEL_MAP GTK_IS_ACCESSIBLE GTK_IS_ACTION
		   GTK_IS_ACTION_GROUP GTK_IS_ADJUSTMENT GTK_IS_ALIGNMENT GTK_IS_ARROW GTK_IS_ASPECT_FRAME
		   GTK_IS_BIN GTK_IS_BOX GTK_IS_BUTTON GTK_IS_BUTTON_BOX GTK_IS_CALENDAR
		   GTK_IS_CELL_EDITABLE GTK_IS_CELL_LAYOUT GTK_IS_CELL_RENDERER GTK_IS_CELL_RENDERER_COMBO GTK_IS_CELL_RENDERER_PIXBUF
		   GTK_IS_CELL_RENDERER_PROGRESS GTK_IS_CELL_RENDERER_TEXT GTK_IS_CELL_RENDERER_TOGGLE GTK_IS_CELL_VIEW GTK_IS_CHECK_BUTTON
		   GTK_IS_CHECK_MENU_ITEM GTK_IS_CLIPBOARD GTK_IS_COLOR_BUTTON GTK_IS_COLOR_SELECTION GTK_IS_COLOR_SELECTION_DIALOG
		   GTK_IS_COMBO_BOX GTK_IS_COMBO_BOX_ENTRY GTK_IS_CONTAINER GTK_IS_DIALOG
		   GTK_IS_DRAWING_AREA GTK_IS_EDITABLE GTK_IS_ENTRY GTK_IS_ENTRY_COMPLETION GTK_IS_EVENT_BOX
		   GTK_IS_EXPANDER GTK_IS_FILE_CHOOSER GTK_IS_FILE_CHOOSER_BUTTON GTK_IS_FILE_CHOOSER_DIALOG GTK_IS_FILE_CHOOSER_WIDGET
		   GTK_IS_FILE_FILTER ;GTK_IS_FILE_SELECTION 
		   GTK_IS_FIXED GTK_IS_FONT_BUTTON GTK_IS_FONT_SELECTION
		   GTK_IS_FONT_SELECTION_DIALOG GTK_IS_FRAME GTK_IS_HANDLE_BOX GTK_IS_HBOX
		   GTK_IS_HBUTTON_BOX GTK_IS_HPANED GTK_IS_HRULER GTK_IS_HSCALE GTK_IS_HSCROLLBAR
		   GTK_IS_HSEPARATOR GTK_IS_ICON_FACTORY GTK_IS_ICON_THEME GTK_IS_ICON_VIEW GTK_IS_IMAGE
		   GTK_IS_IMAGE_MENU_ITEM GTK_IS_IM_CONTEXT GTK_IS_IM_CONTEXT_SIMPLE GTK_IS_IM_MULTICONTEXT
		   GTK_IS_INVISIBLE GTK_IS_ITEM GTK_IS_LABEL GTK_IS_LAYOUT GTK_IS_LIST_STORE
		   GTK_IS_MENU GTK_IS_MENU_BAR GTK_IS_MENU_ITEM GTK_IS_MENU_SHELL GTK_IS_MENU_TOOL_BUTTON
		   GTK_IS_MISC GTK_IS_NOTEBOOK GTK_IS_OBJECT GTK_IS_PANED
		   GTK_IS_PLUG GTK_IS_PROGRESS_BAR GTK_IS_RADIO_ACTION GTK_IS_RADIO_BUTTON GTK_IS_RADIO_MENU_ITEM
		   GTK_IS_RADIO_TOOL_BUTTON GTK_IS_RANGE GTK_IS_RC_STYLE GTK_IS_RESIZE_CONTAINER GTK_IS_RULER
		   GTK_IS_SCALE GTK_IS_SCROLLBAR GTK_IS_SCROLLED_WINDOW GTK_IS_SEPARATOR GTK_IS_SEPARATOR_MENU_ITEM
		   GTK_IS_SEPARATOR_TOOL_ITEM GTK_IS_SIZE_GROUP GTK_IS_SOCKET GTK_IS_SPIN_BUTTON GTK_IS_STATUSBAR
		   GTK_IS_STYLE GTK_IS_TABLE GTK_IS_TEAROFF_MENU_ITEM GTK_IS_TEXT_BUFFER GTK_IS_TEXT_CHILD_ANCHOR
		   GTK_IS_TEXT_MARK GTK_IS_TEXT_TAG GTK_IS_TEXT_TAG_TABLE GTK_IS_TEXT_VIEW GTK_IS_TOGGLE_ACTION
		   GTK_IS_TOGGLE_BUTTON GTK_IS_TOGGLE_TOOL_BUTTON GTK_IS_TOOLBAR GTK_IS_TOOL_BUTTON
		   GTK_IS_TOOL_ITEM GTK_IS_TREE_DRAG_DEST GTK_IS_TREE_DRAG_SOURCE GTK_IS_TREE_MODEL GTK_IS_TREE_MODEL_FILTER
		   GTK_IS_TREE_MODEL_SORT GTK_IS_TREE_SELECTION GTK_IS_TREE_SORTABLE GTK_IS_TREE_STORE GTK_IS_TREE_VIEW
		   GTK_IS_TREE_VIEW_COLUMN GTK_IS_UI_MANAGER GTK_IS_VBOX GTK_IS_VBUTTON_BOX GTK_IS_VIEWPORT
		   GTK_IS_VPANED GTK_IS_VRULER GTK_IS_VSCALE GTK_IS_VSCROLLBAR GTK_IS_VSEPARATOR
		   GTK_IS_WIDGET GTK_IS_WINDOW GTK_ITEM GTK_LABEL GTK_LAYOUT
		   GTK_LIST_STORE GTK_MENU GTK_MENU_BAR GTK_MENU_ITEM GTK_MENU_SHELL
		   GTK_MENU_TOOL_BUTTON GTK_MISC GTK_NOTEBOOK GTK_OBJECT
		   GTK_OBJECT_FLAGS GTK_OBJECT_SET_FLAGS GTK_OBJECT_UNSET_FLAGS
		   GTK_PANED GTK_PLUG GTK_PROGRESS_BAR GTK_RADIO_ACTION GTK_RADIO_BUTTON
		   GTK_RADIO_MENU_ITEM GTK_RADIO_TOOL_BUTTON GTK_RANGE GTK_RULER GTK_SCALE
		   GTK_SCROLLBAR GTK_SCROLLED_WINDOW GTK_SEPARATOR GTK_SEPARATOR_MENU_ITEM GTK_SEPARATOR_TOOL_ITEM
		   GTK_SIZE_GROUP GTK_SOCKET GTK_SPIN_BUTTON GTK_STATUSBAR GTK_STYLE
		   GTK_TABLE GTK_TEAROFF_MENU_ITEM GTK_TEXT_BUFFER GTK_TEXT_CHILD_ANCHOR GTK_TEXT_MARK
		   GTK_TEXT_TAG GTK_TEXT_TAG_TABLE GTK_TEXT_VIEW GTK_TOGGLE_ACTION GTK_TOGGLE_BUTTON
		   GTK_TOGGLE_TOOL_BUTTON GTK_TOOLBAR GTK_TOOL_BUTTON GTK_TOOL_ITEM
		   GTK_TREE_DRAG_DEST GTK_TREE_DRAG_SOURCE GTK_TREE_MODEL GTK_TREE_MODEL_FILTER GTK_TREE_MODEL_SORT
		   GTK_TREE_SELECTION GTK_TREE_SORTABLE GTK_TREE_STORE GTK_TREE_VIEW GTK_TREE_VIEW_COLUMN
		   GTK_UI_MANAGER GTK_VBOX GTK_VBUTTON_BOX GTK_VIEWPORT GTK_VPANED
		   GTK_VRULER GTK_VSCALE GTK_VSCROLLBAR GTK_VSEPARATOR GTK_WIDGET
		   G_IS_OBJECT G_OBJECT G_OBJECT_TYPE PANGO_CONTEXT PANGO_FONT
		   PANGO_FONT_FACE PANGO_FONT_FAMILY PANGO_FONT_MAP PANGO_IS_CONTEXT PANGO_IS_FONT
		   PANGO_IS_FONT_FACE PANGO_IS_FONT_FAMILY PANGO_IS_FONT_MAP PANGO_IS_LAYOUT PANGO_IS_RENDERER
		   PANGO_LAYOUT PANGO_RENDERER g_cclosure_new g_idle_add g_idle_add_full
		   g_idle_remove_by_data g_list_copy g_list_first g_list_free g_list_last
		   g_list_length g_list_nth_data g_list_remove_link g_list_reverse g_object_get_data
		   g_object_ref g_object_set_data g_object_unref g_quark_from_string g_quark_to_string
		   g_signal_add_emission_hook g_signal_connect_closure g_signal_connect_closure_by_id g_signal_connect_data g_signal_get_invocation_hint
		   g_signal_handler_block g_signal_handler_disconnect g_signal_handler_find g_signal_handler_is_connected g_signal_handler_unblock
		   g_signal_handlers_block_matched g_signal_handlers_destroy g_signal_handlers_disconnect_matched 
		   g_signal_handlers_unblock_matched g_signal_has_handler_pending
		   g_signal_list_ids g_signal_name g_signal_newv g_signal_parse_name g_signal_query
		   g_signal_remove_emission_hook g_signal_stop_emission g_signal_stop_emission_by_name g_timeout_add g_timeout_add_full
		   gdk_add_client_message_filter gdk_atom_name gdk_beep gdk_bitmap_create_from_data
		   gdk_color_copy gdk_color_equal gdk_color_free
		   gdk_color_hash gdk_color_parse gdk_colormap_alloc_color gdk_colormap_alloc_colors
		   gdk_colormap_get_system gdk_colormap_get_visual gdk_colormap_new gdk_colormap_query_color
					;gdk_cursor_new gdk_cursor_new_from_pixbuf
					;gdk_cursor_new_from_pixmap gdk_cursor_ref gdk_cursor_unref ;gdk_device_free_history
		   gdk_display_add_client_message_filter gdk_display_beep gdk_display_close gdk_display_flush ;gdk_display_get_core_pointer
		   gdk_display_get_default gdk_display_get_default_cursor_size gdk_display_get_default_group gdk_display_get_default_screen gdk_display_get_event
		   gdk_display_get_maximal_cursor_size gdk_display_get_n_screens gdk_display_get_name gdk_display_get_pointer gdk_display_get_screen
		   gdk_display_get_window_at_pointer gdk_display_keyboard_ungrab gdk_display_open
		   gdk_display_peek_event gdk_display_pointer_is_grabbed gdk_display_pointer_ungrab gdk_display_put_event gdk_display_set_double_click_distance
		   gdk_display_set_double_click_time gdk_display_supports_clipboard_persistence gdk_display_supports_cursor_alpha 
		   gdk_display_supports_cursor_color gdk_display_sync
		   gdk_drag_abort gdk_drag_begin gdk_drag_context_new
		   gdk_drag_drop gdk_drag_drop_succeeded gdk_drag_find_window gdk_drag_get_protocol gdk_drag_get_selection
		   gdk_drag_motion gdk_drag_status gdk_draw_arc gdk_draw_drawable
		   gdk_draw_glyphs gdk_draw_glyphs_transformed gdk_draw_gray_image gdk_draw_image gdk_draw_indexed_image
		   gdk_draw_layout gdk_draw_layout_line gdk_draw_layout_line_with_colors gdk_draw_layout_with_colors gdk_draw_line
		   gdk_draw_lines gdk_draw_pixbuf gdk_draw_point gdk_draw_points gdk_draw_polygon
		   gdk_draw_rectangle gdk_draw_rgb_32_image gdk_draw_rgb_32_image_dithalign gdk_draw_rgb_image gdk_draw_rgb_image_dithalign
		   gdk_draw_segments gdk_draw_trapezoids gdk_drawable_copy_to_image gdk_drawable_get_clip_region gdk_drawable_get_colormap
		   gdk_drawable_get_depth gdk_drawable_get_image gdk_drawable_get_size gdk_drawable_get_visible_region
		   gdk_drawable_get_visual gdk_drawable_set_colormap gdk_drop_finish gdk_drop_reply gdk_error_trap_pop
		   gdk_error_trap_push gdk_event_copy gdk_event_free gdk_event_get ;gdk_event_get_axis
		   gdk_event_get_coords ;gdk_event_get_graphics_expose 
		   gdk_event_get_root_coords gdk_event_get_state gdk_event_get_time
		   gdk_event_handler_set gdk_event_peek gdk_event_put
		   gdk_event_send_client_message gdk_event_send_clientmessage_toall gdk_events_pending   gdk_flush   gdk_gc_copy gdk_gc_get_colormap gdk_gc_get_values
		   gdk_gc_new gdk_gc_new_with_values gdk_gc_offset gdk_gc_set_background gdk_gc_set_clip_mask
		   gdk_gc_set_clip_origin gdk_gc_set_clip_rectangle gdk_gc_set_clip_region gdk_gc_set_colormap ;gdk_gc_set_dashes
		   gdk_gc_set_exposures gdk_gc_set_fill gdk_gc_set_foreground gdk_gc_set_function gdk_gc_set_line_attributes
		   gdk_gc_set_rgb_bg_color gdk_gc_set_rgb_fg_color gdk_gc_set_stipple gdk_gc_set_subwindow gdk_gc_set_tile
		   gdk_gc_set_ts_origin gdk_gc_set_values gdk_get_default_root_window gdk_get_display
		   gdk_get_display_arg_name gdk_get_program_class gdk_get_show_events   gdk_image_new   ;gdk_input_set_extension_events 
		   gdk_keyboard_grab
		   gdk_keyboard_ungrab gdk_keymap_get_default gdk_keymap_get_direction gdk_keymap_get_entries_for_keycode gdk_keymap_get_entries_for_keyval
		   gdk_keymap_lookup_key gdk_keyval_convert_case gdk_keyval_from_name gdk_keyval_is_lower
		   gdk_keyval_is_upper gdk_keyval_name gdk_keyval_to_lower gdk_keyval_to_unicode gdk_keyval_to_upper
		   gdk_list_visuals gdk_notify_startup_complete   gdk_pango_attr_embossed_new gdk_pango_attr_stipple_new gdk_pango_context_get gdk_pango_layout_get_clip_region
		   gdk_pango_layout_line_get_clip_region gdk_pango_renderer_get_default 
		   gdk_pango_renderer_new gdk_pango_renderer_set_drawable
		   gdk_pango_renderer_set_gc gdk_pango_renderer_set_override_color 
		   gdk_pango_renderer_set_stipple gdk_pixbuf_add_alpha   gdk_pixbuf_animation_get_height gdk_pixbuf_animation_get_iter gdk_pixbuf_animation_get_static_image 
		   gdk_pixbuf_animation_get_width
		   gdk_pixbuf_animation_is_static_image gdk_pixbuf_animation_iter_advance gdk_pixbuf_animation_iter_get_delay_time 
		   gdk_pixbuf_animation_iter_get_pixbuf   gdk_pixbuf_animation_iter_on_currently_loading_frame gdk_pixbuf_animation_new_from_file gdk_pixbuf_composite 
		   gdk_pixbuf_composite_color gdk_pixbuf_composite_color_simple
		   gdk_pixbuf_copy gdk_pixbuf_copy_area gdk_pixbuf_error_quark gdk_pixbuf_fill
		   gdk_pixbuf_get_bits_per_sample gdk_pixbuf_get_colorspace gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_image gdk_pixbuf_get_has_alpha
		   gdk_pixbuf_get_height gdk_pixbuf_get_n_channels gdk_pixbuf_get_option gdk_pixbuf_get_pixels gdk_pixbuf_get_rowstride
		   gdk_pixbuf_get_width 
		   gdk_pixbuf_new_from_data gdk_pixbuf_new_from_file gdk_pixbuf_new_from_inline gdk_pixbuf_new_from_xpm_data gdk_pixbuf_new_subpixbuf
		   gdk_pixbuf_render_pixmap_and_mask gdk_pixbuf_render_pixmap_and_mask_for_colormap gdk_pixbuf_render_threshold_alpha 
		   gdk_pixbuf_saturate_and_pixelate gdk_pixbuf_savev
		   gdk_pixbuf_scale gdk_pixbuf_scale_simple gdk_pixmap_colormap_create_from_xpm gdk_pixmap_colormap_create_from_xpm_d gdk_pixmap_create_from_data
		   gdk_pixmap_create_from_xpm gdk_pixmap_create_from_xpm_d gdk_pixmap_foreign_new gdk_pixmap_lookup
		   gdk_pointer_grab gdk_pointer_is_grabbed gdk_pointer_ungrab gdk_property_change
		   gdk_property_delete gdk_property_get gdk_query_depths gdk_query_visual_types
		   gdk_rectangle_intersect gdk_rectangle_union gdk_region_copy gdk_region_destroy
		   gdk_region_empty gdk_region_equal gdk_region_get_clipbox gdk_region_get_rectangles gdk_region_intersect
		   gdk_region_new gdk_region_offset gdk_region_point_in gdk_region_polygon ;gdk_region_rect_in
		   gdk_region_rectangle gdk_region_shrink gdk_region_subtract gdk_region_union gdk_region_union_with_rect
		   gdk_region_xor gdk_rgb_cmap_free gdk_rgb_cmap_new gdk_rgb_colormap_ditherable
		   gdk_rgb_ditherable gdk_rgb_find_color gdk_rgb_get_colormap gdk_rgb_get_visual gdk_rgb_set_install
		   gdk_rgb_set_min_colors gdk_rgb_set_verbose gdk_screen_broadcast_client_message gdk_screen_get_default gdk_screen_get_default_colormap
		   gdk_screen_get_display gdk_screen_get_height gdk_screen_get_height_mm gdk_screen_get_monitor_at_point gdk_screen_get_monitor_at_window
		   gdk_screen_get_monitor_geometry gdk_screen_get_n_monitors gdk_screen_get_number gdk_screen_get_rgb_colormap gdk_screen_get_rgb_visual
		   gdk_screen_get_root_window gdk_screen_get_system_colormap gdk_screen_get_system_visual gdk_screen_get_toplevel_windows
		   gdk_screen_get_width gdk_screen_get_width_mm gdk_screen_height gdk_screen_height_mm gdk_screen_list_visuals
		   gdk_screen_make_display_name gdk_screen_set_default_colormap gdk_screen_width gdk_screen_width_mm
		   gdk_selection_convert gdk_selection_owner_get gdk_selection_owner_set gdk_selection_property_get gdk_selection_send_notify
		   gdk_set_double_click_time gdk_set_locale gdk_set_program_class gdk_set_sm_client_id   gdk_unicode_to_keyval gdk_visual_get_best
		   gdk_visual_get_best_depth gdk_visual_get_best_type gdk_visual_get_best_with_both gdk_visual_get_best_with_depth gdk_visual_get_best_with_type
		   gdk_visual_get_system gdk_window_add_filter gdk_window_at_pointer
		   gdk_window_begin_move_drag 
		   gdk_window_begin_paint_rect gdk_window_begin_paint_region gdk_window_begin_resize_drag
		   gdk_window_clear gdk_window_clear_area gdk_window_clear_area_e gdk_window_configure_finished
		   gdk_window_constrain_size gdk_window_deiconify gdk_window_destroy gdk_window_enable_synchronized_configure
		   gdk_window_end_paint gdk_window_focus gdk_window_foreign_new gdk_window_freeze_updates gdk_window_get_children
		   gdk_window_get_decorations gdk_window_get_events gdk_window_get_frame_extents gdk_window_get_geometry gdk_window_get_group
		   gdk_window_get_internal_paint_info gdk_window_get_origin gdk_window_get_parent gdk_window_get_pointer gdk_window_get_position
		   gdk_window_get_root_origin gdk_window_get_state gdk_window_get_toplevel gdk_window_get_update_area
		   gdk_window_get_user_data gdk_window_get_window_type gdk_window_hide gdk_window_iconify
		   gdk_window_invalidate_maybe_recurse gdk_window_invalidate_rect gdk_window_invalidate_region gdk_window_is_viewable gdk_window_is_visible
		   gdk_window_lookup gdk_window_lower gdk_window_maximize gdk_window_merge_child_shapes gdk_window_move
		   gdk_window_move_resize gdk_window_new gdk_window_peek_children gdk_window_process_all_updates gdk_window_process_updates
		   gdk_window_raise gdk_window_register_dnd gdk_window_remove_filter gdk_window_reparent gdk_window_resize
		   gdk_window_scroll gdk_window_set_back_pixmap gdk_window_set_background gdk_window_set_child_shapes
		   gdk_window_set_cursor gdk_window_set_debug_updates gdk_window_set_decorations gdk_window_set_events 
		   gdk_window_set_functions gdk_window_set_geometry_hints gdk_window_set_group gdk_window_set_icon gdk_window_set_icon_list
		   gdk_window_set_icon_name gdk_window_set_keep_above gdk_window_set_keep_below gdk_window_set_modal_hint gdk_window_set_override_redirect
		   gdk_window_set_role gdk_window_set_static_gravities gdk_window_set_title gdk_window_set_transient_for gdk_window_set_type_hint
		   gdk_window_set_user_data gdk_window_shape_combine_mask gdk_window_shape_combine_region gdk_window_show gdk_window_show_unraised
		   gdk_window_stick gdk_window_thaw_updates   gdk_window_unmaximize gdk_window_unstick gdk_window_withdraw
		   gtk_about_dialog_get_artists gtk_about_dialog_get_authors 
		   gtk_about_dialog_get_comments gtk_about_dialog_get_copyright gtk_about_dialog_get_documenters
		   gtk_about_dialog_get_license gtk_about_dialog_get_logo gtk_about_dialog_get_logo_icon_name ;gtk_about_dialog_get_name 
		   gtk_about_dialog_get_translator_credits
		   gtk_about_dialog_get_version gtk_about_dialog_get_website gtk_about_dialog_get_website_label gtk_about_dialog_new
		   gtk_about_dialog_set_artists gtk_about_dialog_set_authors gtk_about_dialog_set_comments 
		   gtk_about_dialog_set_copyright gtk_about_dialog_set_documenters
		   gtk_about_dialog_set_license gtk_about_dialog_set_logo gtk_about_dialog_set_logo_icon_name ;gtk_about_dialog_set_name 
		   gtk_about_dialog_set_translator_credits
		   gtk_about_dialog_set_version gtk_about_dialog_set_website gtk_about_dialog_set_website_label gtk_accel_group_activate gtk_accel_group_connect
		   gtk_accel_group_connect_by_path gtk_accel_group_disconnect gtk_accel_group_disconnect_key gtk_accel_group_find gtk_accel_group_from_accel_closure
		   gtk_accel_group_lock gtk_accel_group_new gtk_accel_group_query gtk_accel_group_unlock
		   gtk_accel_groups_activate gtk_accel_groups_from_object gtk_accel_label_get_accel_widget gtk_accel_label_get_accel_width
		   gtk_accel_label_new gtk_accel_label_refetch gtk_accel_label_set_accel_closure gtk_accel_label_set_accel_widget gtk_accel_map_add_entry
		   gtk_accel_map_add_filter gtk_accel_map_change_entry gtk_accel_map_foreach gtk_accel_map_foreach_unfiltered gtk_accel_map_get
		   gtk_accelerator_get_default_mod_mask gtk_accelerator_get_label gtk_accelerator_name gtk_accelerator_parse
		   gtk_accelerator_set_default_mod_mask gtk_accelerator_valid gtk_accessible_connect_widget_destroyed gtk_action_activate
		   gtk_action_connect_accelerator gtk_action_create_icon gtk_action_create_menu_item gtk_action_create_tool_item
		   gtk_action_disconnect_accelerator gtk_action_get_name gtk_action_get_proxies gtk_action_get_sensitive
		   gtk_action_get_visible gtk_action_group_add_action gtk_action_group_add_action_with_accel gtk_action_group_add_actions
		   gtk_action_group_add_toggle_actions gtk_action_group_add_toggle_actions_full gtk_action_group_get_action 
		   gtk_action_group_get_name gtk_action_group_get_sensitive
		   gtk_action_group_get_visible gtk_action_group_list_actions gtk_action_group_new gtk_action_group_remove_action
		   gtk_action_group_set_sensitive gtk_action_group_set_translation_domain gtk_action_group_set_visible gtk_action_is_sensitive gtk_action_is_visible
		   gtk_action_new gtk_action_set_sensitive gtk_action_set_visible gtk_adjustment_changed gtk_adjustment_clamp_page
		   gtk_adjustment_get_value gtk_adjustment_new gtk_adjustment_set_value gtk_adjustment_value_changed
		   gtk_alignment_get_padding gtk_alignment_new gtk_alignment_set gtk_alignment_set_padding
		   gtk_alternative_dialog_button_order gtk_arrow_new gtk_arrow_set   gtk_aspect_frame_new gtk_aspect_frame_set gtk_bin_get_child ;gtk_binding_entry_add_signall
		   gtk_binding_entry_remove ;gtk_binding_parse_binding 
		   gtk_binding_set_activate gtk_binding_set_add_path
		   gtk_binding_set_by_class gtk_binding_set_find gtk_binding_set_new gtk_bindings_activate gtk_border_copy
		   gtk_border_free gtk_box_get_homogeneous gtk_box_get_spacing
		   gtk_box_pack_end gtk_box_pack_start gtk_box_query_child_packing
		   gtk_box_reorder_child gtk_box_set_child_packing gtk_box_set_homogeneous gtk_box_set_spacing gtk_button_box_get_child_secondary
		   gtk_button_box_get_layout gtk_button_box_set_child_secondary gtk_button_box_set_layout 
		   gtk_button_get_alignment gtk_button_get_focus_on_click gtk_button_get_image gtk_button_get_label
		   gtk_button_get_relief gtk_button_get_use_stock gtk_button_get_use_underline
		   gtk_button_new gtk_button_new_from_stock gtk_button_new_with_mnemonic
		   gtk_button_set_alignment gtk_button_set_focus_on_click gtk_button_set_image gtk_button_set_label gtk_button_set_relief
		   gtk_button_set_use_stock gtk_button_set_use_underline gtk_calendar_clear_marks gtk_calendar_get_date
		   gtk_calendar_get_display_options gtk_calendar_mark_day gtk_calendar_new gtk_calendar_select_day
		   gtk_calendar_select_month gtk_calendar_set_display_options gtk_calendar_unmark_day gtk_cell_editable_editing_done
		   gtk_cell_editable_remove_widget gtk_cell_editable_start_editing gtk_cell_layout_add_attribute gtk_cell_layout_clear
		   gtk_cell_layout_clear_attributes gtk_cell_layout_pack_end gtk_cell_layout_pack_start gtk_cell_layout_reorder
		   gtk_cell_layout_set_attributes gtk_cell_layout_set_cell_data_func 
		   gtk_cell_renderer_activate gtk_cell_renderer_combo_new
		   gtk_cell_renderer_get_fixed_size gtk_cell_renderer_get_size 
		   gtk_cell_renderer_pixbuf_new
		   gtk_cell_renderer_progress_new gtk_cell_renderer_render 
		   gtk_cell_renderer_set_fixed_size gtk_cell_renderer_start_editing
		   gtk_cell_renderer_text_new gtk_cell_renderer_text_set_fixed_height_from_font 
		   gtk_cell_renderer_toggle_get_active gtk_cell_renderer_toggle_get_radio
		   gtk_cell_renderer_toggle_new gtk_cell_renderer_toggle_set_active 
		   gtk_cell_renderer_toggle_set_radio 
		   gtk_cell_view_get_displayed_row gtk_cell_view_get_size_of_row gtk_cell_view_new gtk_cell_view_new_with_markup
		   gtk_cell_view_new_with_pixbuf gtk_cell_view_new_with_text 
		   gtk_cell_view_set_background_color gtk_cell_view_set_displayed_row gtk_cell_view_set_model
		   gtk_check_button_new gtk_check_button_new_with_mnemonic gtk_check_menu_item_get_active
		   gtk_check_menu_item_get_draw_as_radio gtk_check_menu_item_get_inconsistent 
		   gtk_check_menu_item_new gtk_check_menu_item_new_with_mnemonic
		   gtk_check_menu_item_set_active gtk_check_menu_item_set_draw_as_radio 
		   gtk_check_menu_item_set_inconsistent gtk_check_menu_item_toggled gtk_check_version
		   gtk_clipboard_clear gtk_clipboard_get gtk_clipboard_get_display gtk_clipboard_get_for_display gtk_clipboard_get_owner
		   gtk_clipboard_request_contents gtk_clipboard_request_image gtk_clipboard_request_targets gtk_clipboard_request_text gtk_clipboard_set_can_store
		   gtk_clipboard_set_image gtk_clipboard_set_text gtk_clipboard_set_with_data gtk_clipboard_store gtk_clipboard_wait_for_contents
		   gtk_clipboard_wait_for_image gtk_clipboard_wait_for_targets gtk_clipboard_wait_for_text 
		   gtk_clipboard_wait_is_image_available gtk_clipboard_wait_is_target_available
		   gtk_clipboard_wait_is_text_available gtk_color_button_get_alpha gtk_color_button_get_color gtk_color_button_get_title
		   gtk_color_button_get_use_alpha gtk_color_button_new gtk_color_button_new_with_color gtk_color_button_set_alpha gtk_color_button_set_color
		   gtk_color_button_set_title gtk_color_button_set_use_alpha 
		   gtk_color_selection_dialog_new gtk_color_selection_get_current_alpha
		   gtk_color_selection_get_current_color gtk_color_selection_get_has_opacity_control gtk_color_selection_get_has_palette 
		   gtk_color_selection_get_previous_alpha gtk_color_selection_get_previous_color
		   gtk_color_selection_is_adjusting gtk_color_selection_new 
		   gtk_color_selection_palette_to_string gtk_color_selection_set_current_alpha
		   gtk_color_selection_set_current_color gtk_color_selection_set_has_opacity_control 
		   gtk_color_selection_set_has_palette gtk_color_selection_set_previous_alpha gtk_color_selection_set_previous_color
		   gtk_combo_box_append_text gtk_combo_box_entry_get_text_column gtk_combo_box_entry_new gtk_combo_box_entry_new_text
		   gtk_combo_box_entry_new_with_model gtk_combo_box_entry_set_text_column gtk_combo_box_get_active 
		   gtk_combo_box_get_active_iter gtk_combo_box_get_active_text
		   gtk_combo_box_get_add_tearoffs gtk_combo_box_get_column_span_column gtk_combo_box_get_focus_on_click 
		   gtk_combo_box_get_model gtk_combo_box_get_row_span_column
		   gtk_combo_box_get_wrap_width gtk_combo_box_insert_text gtk_combo_box_new gtk_combo_box_new_text
		   gtk_combo_box_new_with_model gtk_combo_box_popdown gtk_combo_box_popup gtk_combo_box_prepend_text gtk_combo_box_remove_text
		   gtk_combo_box_set_active gtk_combo_box_set_active_iter gtk_combo_box_set_add_tearoffs 
		   gtk_combo_box_set_column_span_column gtk_combo_box_set_focus_on_click
		   gtk_combo_box_set_model gtk_combo_box_set_row_separator_func gtk_combo_box_set_row_span_column gtk_combo_box_set_wrap_width gtk_container_add
		   gtk_container_check_resize gtk_container_foreach gtk_container_get_border_width gtk_container_get_children gtk_container_get_resize_mode
		   gtk_container_remove gtk_container_set_border_width gtk_container_set_resize_mode
		   gtk_dialog_add_action_widget gtk_dialog_add_button gtk_dialog_add_buttons
		   gtk_dialog_get_has_separator gtk_dialog_new gtk_dialog_new_with_buttons gtk_dialog_response
		   gtk_dialog_run gtk_dialog_set_alternative_button_order_from_array gtk_dialog_set_default_response 
		   gtk_dialog_set_has_separator gtk_dialog_set_response_sensitive
		   gtk_drag_begin gtk_drag_check_threshold gtk_drag_dest_add_image_targets gtk_drag_dest_add_text_targets gtk_drag_dest_add_uri_targets
		   gtk_drag_dest_find_target gtk_drag_dest_get_target_list gtk_drag_dest_set gtk_drag_dest_set_proxy gtk_drag_dest_set_target_list
		   gtk_drag_dest_unset gtk_drag_finish gtk_drag_get_data gtk_drag_get_source_widget gtk_drag_highlight
		   gtk_drag_set_icon_default gtk_drag_set_icon_pixbuf gtk_drag_set_icon_pixmap gtk_drag_set_icon_stock gtk_drag_set_icon_widget
		   gtk_drag_source_add_image_targets gtk_drag_source_add_text_targets 
		   gtk_drag_source_add_uri_targets gtk_drag_source_get_target_list gtk_drag_source_set
		   gtk_drag_source_set_icon gtk_drag_source_set_icon_pixbuf gtk_drag_source_set_icon_stock gtk_drag_source_set_target_list gtk_drag_source_unset
		   gtk_drag_unhighlight gtk_drawing_area_new gtk_editable_copy_clipboard gtk_editable_cut_clipboard
		   gtk_editable_delete_selection gtk_editable_delete_text gtk_editable_get_chars gtk_editable_get_editable gtk_editable_get_position
		   gtk_editable_get_selection_bounds gtk_editable_insert_text gtk_editable_paste_clipboard gtk_editable_select_region
		   gtk_editable_set_editable gtk_editable_set_position gtk_entry_completion_complete 
		   gtk_entry_completion_delete_action gtk_entry_completion_get_entry
		   gtk_entry_completion_get_inline_completion gtk_entry_completion_get_minimum_key_length 
		   gtk_entry_completion_get_model gtk_entry_completion_get_popup_completion gtk_entry_completion_get_text_column
		   gtk_entry_completion_insert_action_markup 
		   gtk_entry_completion_insert_action_text gtk_entry_completion_insert_prefix gtk_entry_completion_new
		   gtk_entry_completion_set_inline_completion gtk_entry_completion_set_match_func 
		   gtk_entry_completion_set_minimum_key_length gtk_entry_completion_set_model gtk_entry_completion_set_popup_completion
		   gtk_entry_completion_set_text_column gtk_entry_get_activates_default gtk_entry_get_alignment gtk_entry_get_completion gtk_entry_get_has_frame
		   gtk_entry_get_invisible_char gtk_entry_get_layout gtk_entry_get_max_length gtk_entry_get_text
		   gtk_entry_get_visibility gtk_entry_get_width_chars gtk_entry_layout_index_to_text_index gtk_entry_new
		   gtk_entry_set_activates_default gtk_entry_set_alignment gtk_entry_set_completion gtk_entry_set_has_frame gtk_entry_set_invisible_char
		   gtk_entry_set_max_length gtk_entry_set_text gtk_entry_set_visibility gtk_entry_set_width_chars gtk_entry_text_index_to_layout_index
		   gtk_event_box_get_above_child gtk_event_box_get_visible_window gtk_event_box_new gtk_event_box_set_above_child
		   gtk_event_box_set_visible_window gtk_events_pending gtk_expander_get_expanded gtk_expander_get_label gtk_expander_get_label_widget
		   gtk_expander_get_spacing gtk_expander_get_use_markup gtk_expander_get_use_underline gtk_expander_new
		   gtk_expander_new_with_mnemonic gtk_expander_set_expanded gtk_expander_set_label gtk_expander_set_label_widget gtk_expander_set_spacing
		   gtk_expander_set_use_markup gtk_expander_set_use_underline gtk_false gtk_file_chooser_add_filter gtk_file_chooser_add_shortcut_folder
		   gtk_file_chooser_add_shortcut_folder_uri gtk_file_chooser_button_get_title 
		   gtk_file_chooser_button_get_width_chars ;gtk_file_chooser_button_new
		   gtk_file_chooser_button_set_title gtk_file_chooser_button_set_width_chars
		   gtk_file_chooser_dialog_new gtk_file_chooser_get_action gtk_file_chooser_get_current_folder 
		   gtk_file_chooser_get_current_folder_uri gtk_file_chooser_get_extra_widget
		   gtk_file_chooser_get_filename gtk_file_chooser_get_filenames gtk_file_chooser_get_filter 
		   gtk_file_chooser_get_local_only gtk_file_chooser_get_preview_filename
		   gtk_file_chooser_get_preview_uri gtk_file_chooser_get_preview_widget 
		   gtk_file_chooser_get_preview_widget_active gtk_file_chooser_get_select_multiple gtk_file_chooser_get_show_hidden
		   gtk_file_chooser_get_uri gtk_file_chooser_get_uris gtk_file_chooser_get_use_preview_label gtk_file_chooser_list_filters
		   gtk_file_chooser_list_shortcut_folder_uris gtk_file_chooser_list_shortcut_folders 
		   gtk_file_chooser_remove_filter gtk_file_chooser_remove_shortcut_folder gtk_file_chooser_remove_shortcut_folder_uri
		   gtk_file_chooser_select_all gtk_file_chooser_select_filename gtk_file_chooser_select_uri 
		   gtk_file_chooser_set_action gtk_file_chooser_set_current_folder
		   gtk_file_chooser_set_current_folder_uri gtk_file_chooser_set_current_name gtk_file_chooser_set_extra_widget 
		   gtk_file_chooser_set_filename gtk_file_chooser_set_filter
		   gtk_file_chooser_set_local_only gtk_file_chooser_set_preview_widget 
		   gtk_file_chooser_set_preview_widget_active gtk_file_chooser_set_select_multiple gtk_file_chooser_set_show_hidden
		   gtk_file_chooser_set_uri gtk_file_chooser_set_use_preview_label gtk_file_chooser_unselect_all 
		   gtk_file_chooser_unselect_filename gtk_file_chooser_unselect_uri
		   gtk_file_filter_add_pattern gtk_file_filter_add_pixbuf_formats gtk_file_filter_filter gtk_file_filter_get_name gtk_file_filter_get_needed
		   gtk_file_filter_new gtk_file_filter_set_name 
		   gtk_fixed_move gtk_fixed_new gtk_fixed_put gtk_font_button_get_font_name
		   gtk_font_button_get_show_size gtk_font_button_get_show_style gtk_font_button_get_title gtk_font_button_get_use_font
		   gtk_font_button_get_use_size gtk_font_button_new gtk_font_button_new_with_font gtk_font_button_set_font_name gtk_font_button_set_show_size
		   gtk_font_button_set_show_style gtk_font_button_set_title gtk_font_button_set_use_font 
		   gtk_font_button_set_use_size gtk_font_selection_dialog_get_font_name
		   gtk_font_selection_dialog_get_preview_text 
		   gtk_font_selection_dialog_new gtk_font_selection_dialog_set_font_name gtk_font_selection_dialog_set_preview_text
		   gtk_font_selection_get_font_name gtk_font_selection_get_preview_text 
		   gtk_font_selection_new ;gtk_font_selection_set_font_name
		   gtk_font_selection_set_preview_text gtk_frame_get_label gtk_frame_get_label_align gtk_frame_get_label_widget gtk_frame_get_shadow_type
		   gtk_frame_new gtk_frame_set_label gtk_frame_set_label_align gtk_frame_set_label_widget
		   gtk_frame_set_shadow_type gtk_gc_get gtk_gc_release
		   gtk_get_current_event gtk_get_current_event_state gtk_get_current_event_time gtk_get_default_language gtk_get_event_widget
		   gtk_grab_add gtk_grab_get_current gtk_grab_remove gtk_handle_box_get_handle_position gtk_handle_box_get_shadow_type
		   gtk_handle_box_get_snap_edge gtk_handle_box_new gtk_handle_box_set_handle_position gtk_handle_box_set_shadow_type
		   gtk_handle_box_set_snap_edge gtk_hbox_new gtk_hbutton_box_new
		   gtk_hpaned_new gtk_hruler_new   gtk_hscale_new gtk_hscale_new_with_range gtk_hscrollbar_new
		   gtk_hseparator_new gtk_icon_factory_add gtk_icon_factory_add_default gtk_icon_factory_lookup
		   gtk_icon_factory_lookup_default gtk_icon_factory_new gtk_icon_factory_remove_default gtk_icon_info_copy gtk_icon_info_free
		   gtk_icon_info_get_attach_points gtk_icon_info_get_base_size 
		   gtk_icon_info_get_builtin_pixbuf gtk_icon_info_get_display_name gtk_icon_info_get_embedded_rect
		   gtk_icon_info_get_filename gtk_icon_info_load_icon gtk_icon_info_set_raw_coordinates gtk_icon_set_add_source
		   gtk_icon_set_copy gtk_icon_set_get_sizes gtk_icon_set_new gtk_icon_set_new_from_pixbuf
		   gtk_icon_set_ref gtk_icon_set_render_icon gtk_icon_set_unref gtk_icon_size_get_name gtk_icon_size_lookup
		   gtk_icon_size_register gtk_icon_size_register_alias gtk_icon_source_copy gtk_icon_source_free gtk_icon_source_get_direction
		   gtk_icon_source_get_direction_wildcarded gtk_icon_source_get_filename 
		   gtk_icon_source_get_icon_name gtk_icon_source_get_pixbuf gtk_icon_source_get_size
		   gtk_icon_source_get_size_wildcarded gtk_icon_source_get_state gtk_icon_source_get_state_wildcarded gtk_icon_source_new
		   gtk_icon_source_set_direction gtk_icon_source_set_direction_wildcarded 
		   gtk_icon_source_set_filename gtk_icon_source_set_pixbuf gtk_icon_source_set_size
		   gtk_icon_source_set_size_wildcarded gtk_icon_source_set_state gtk_icon_source_set_state_wildcarded 
		   gtk_icon_theme_add_builtin_icon gtk_icon_theme_append_search_path
		   gtk_icon_theme_get_default gtk_icon_theme_get_example_icon_name 
		   gtk_icon_theme_get_for_screen gtk_icon_theme_get_icon_sizes gtk_icon_theme_get_search_path
		   gtk_icon_theme_has_icon gtk_icon_theme_list_icons gtk_icon_theme_load_icon gtk_icon_theme_lookup_icon
		   gtk_icon_theme_new gtk_icon_theme_prepend_search_path gtk_icon_theme_rescan_if_needed gtk_icon_theme_set_custom_theme gtk_icon_theme_set_screen
		   gtk_icon_view_get_markup_column gtk_icon_view_get_model gtk_icon_view_get_orientation 
		   gtk_icon_view_get_path_at_pos gtk_icon_view_get_pixbuf_column
		   gtk_icon_view_get_selected_items gtk_icon_view_get_selection_mode 
		   gtk_icon_view_get_text_column gtk_icon_view_item_activated
		   gtk_icon_view_new gtk_icon_view_new_with_model gtk_icon_view_path_is_selected gtk_icon_view_select_all gtk_icon_view_select_path
		   gtk_icon_view_selected_foreach gtk_icon_view_set_markup_column 
		   gtk_icon_view_set_model gtk_icon_view_set_orientation gtk_icon_view_set_pixbuf_column
		   gtk_icon_view_set_selection_mode gtk_icon_view_set_text_column gtk_icon_view_unselect_all gtk_icon_view_unselect_path
		   gtk_im_context_delete_surrounding gtk_im_context_filter_keypress 
		   gtk_im_context_focus_in gtk_im_context_focus_out gtk_im_context_get_preedit_string
		   gtk_im_context_get_surrounding gtk_im_context_reset gtk_im_context_set_client_window gtk_im_context_set_cursor_location
		   gtk_im_context_set_surrounding gtk_im_context_set_use_preedit 
		   gtk_im_context_simple_add_table gtk_im_context_simple_new
		   gtk_im_multicontext_append_menuitems gtk_im_multicontext_new gtk_image_get_animation gtk_image_get_icon_set
		   gtk_image_get_image gtk_image_get_pixbuf gtk_image_get_pixel_size gtk_image_get_pixmap gtk_image_get_stock
		   gtk_image_get_storage_type gtk_image_menu_item_get_image gtk_image_menu_item_new
		   gtk_image_menu_item_new_from_stock gtk_image_menu_item_new_with_mnemonic gtk_image_menu_item_set_image gtk_image_new gtk_image_new_from_animation
		   gtk_image_new_from_file gtk_image_new_from_icon_name gtk_image_new_from_icon_set gtk_image_new_from_image gtk_image_new_from_pixbuf
		   gtk_image_new_from_pixmap gtk_image_new_from_stock gtk_image_set_from_animation gtk_image_set_from_file gtk_image_set_from_icon_name
		   gtk_image_set_from_icon_set gtk_image_set_from_image gtk_image_set_from_pixbuf gtk_image_set_from_pixmap gtk_image_set_from_stock
		   gtk_image_set_pixel_size gtk_invisible_new
		   gtk_item_deselect gtk_item_select gtk_item_toggle gtk_label_get_angle
		   gtk_label_get_attributes gtk_label_get_ellipsize gtk_label_get_justify gtk_label_get_label gtk_label_get_layout
		   gtk_label_get_layout_offsets gtk_label_get_line_wrap gtk_label_get_mnemonic_keyval gtk_label_get_mnemonic_widget gtk_label_get_selectable
		   gtk_label_get_selection_bounds gtk_label_get_single_line_mode gtk_label_get_text gtk_label_get_use_markup
		   gtk_label_get_use_underline gtk_label_get_width_chars gtk_label_new gtk_label_new_with_mnemonic gtk_label_select_region
		   gtk_label_set_angle gtk_label_set_attributes gtk_label_set_ellipsize gtk_label_set_justify gtk_label_set_label
		   gtk_label_set_line_wrap gtk_label_set_markup gtk_label_set_markup_with_mnemonic gtk_label_set_mnemonic_widget gtk_label_set_pattern
		   gtk_label_set_selectable gtk_label_set_single_line_mode gtk_label_set_text gtk_label_set_text_with_mnemonic gtk_label_set_use_markup
		   gtk_label_set_use_underline gtk_label_set_width_chars gtk_layout_get_hadjustment gtk_layout_get_size
		   gtk_layout_get_vadjustment gtk_layout_move gtk_layout_new gtk_layout_put gtk_layout_set_hadjustment
		   gtk_layout_set_size gtk_layout_set_vadjustment gtk_list_store_append gtk_list_store_clear
		   gtk_list_store_insert gtk_list_store_insert_after gtk_list_store_insert_before gtk_list_store_move_after gtk_list_store_move_before
		   gtk_list_store_new gtk_list_store_newv gtk_list_store_prepend gtk_list_store_remove gtk_list_store_reorder
		   gtk_list_store_set gtk_list_store_set_column_types gtk_list_store_swap gtk_menu_attach
		   gtk_menu_bar_new gtk_menu_detach gtk_menu_get_accel_group gtk_menu_get_active gtk_menu_get_attach_widget
		   gtk_menu_get_for_attach_widget gtk_menu_get_tearoff_state gtk_menu_get_title gtk_menu_item_activate
		   gtk_menu_item_deselect gtk_menu_item_get_right_justified gtk_menu_item_get_submenu gtk_menu_item_new
		   gtk_menu_item_new_with_mnemonic gtk_menu_item_select gtk_menu_item_set_accel_path gtk_menu_item_set_right_justified
		   gtk_menu_item_set_submenu gtk_menu_item_toggle_size_allocate gtk_menu_item_toggle_size_request gtk_menu_new gtk_menu_popdown
		   gtk_menu_popup gtk_menu_reorder_child gtk_menu_reposition gtk_menu_set_accel_group gtk_menu_set_accel_path
		   gtk_menu_set_active gtk_menu_set_monitor gtk_menu_set_screen gtk_menu_set_tearoff_state gtk_menu_set_title
		   gtk_menu_shell_activate_item gtk_menu_shell_append gtk_menu_shell_cancel gtk_menu_shell_deactivate gtk_menu_shell_deselect
		   gtk_menu_shell_insert gtk_menu_shell_prepend gtk_menu_shell_select_first gtk_menu_shell_select_item
		   gtk_menu_tool_button_get_menu gtk_menu_tool_button_new 
		   gtk_menu_tool_button_new_from_stock 
		   gtk_menu_tool_button_set_menu gtk_misc_get_alignment gtk_misc_get_padding 
		   gtk_misc_set_alignment gtk_misc_set_padding gtk_notebook_append_page gtk_notebook_append_page_menu gtk_notebook_get_current_page
		   gtk_notebook_get_menu_label gtk_notebook_get_menu_label_text gtk_notebook_get_n_pages gtk_notebook_get_nth_page gtk_notebook_get_scrollable
		   gtk_notebook_get_show_border gtk_notebook_get_show_tabs gtk_notebook_get_tab_label gtk_notebook_get_tab_label_text gtk_notebook_get_tab_pos
		   gtk_notebook_insert_page gtk_notebook_insert_page_menu gtk_notebook_new gtk_notebook_next_page
		   gtk_notebook_page_num gtk_notebook_popup_disable gtk_notebook_popup_enable gtk_notebook_prepend_page gtk_notebook_prepend_page_menu
		   gtk_notebook_prev_page gtk_notebook_remove_page gtk_notebook_reorder_child gtk_notebook_set_current_page
		   gtk_notebook_set_menu_label gtk_notebook_set_menu_label_text gtk_notebook_set_scrollable gtk_notebook_set_show_border gtk_notebook_set_show_tabs
		   gtk_notebook_set_tab_label gtk_notebook_set_tab_label_text gtk_notebook_set_tab_pos gtk_object_destroy
		   gtk_paint_arrow gtk_paint_box gtk_paint_box_gap
		   gtk_paint_check gtk_paint_diamond gtk_paint_expander gtk_paint_extension gtk_paint_flat_box
		   gtk_paint_focus gtk_paint_handle gtk_paint_hline gtk_paint_layout gtk_paint_option
		   gtk_paint_polygon gtk_paint_resize_grip gtk_paint_shadow gtk_paint_shadow_gap gtk_paint_slider
		   gtk_paint_tab gtk_paint_vline gtk_paned_add1 gtk_paned_add2 gtk_paned_get_child1
		   gtk_paned_get_child2 gtk_paned_get_position gtk_paned_pack1 gtk_paned_pack2
		   gtk_paned_set_position gtk_plug_construct gtk_plug_get_id gtk_plug_new
		   gtk_progress_bar_get_ellipsize gtk_progress_bar_get_fraction 
		   gtk_progress_bar_get_orientation gtk_progress_bar_get_pulse_step gtk_progress_bar_get_text
		   gtk_progress_bar_new gtk_progress_bar_pulse gtk_progress_bar_set_ellipsize gtk_progress_bar_set_fraction
		   gtk_progress_bar_set_orientation gtk_progress_bar_set_pulse_step gtk_progress_bar_set_text gtk_propagate_event gtk_radio_action_get_current_value
		   gtk_radio_action_get_group gtk_radio_action_new gtk_radio_action_set_group gtk_radio_button_get_group
		   gtk_radio_button_new gtk_radio_button_new_from_widget 
		   gtk_radio_button_new_with_label_from_widget gtk_radio_button_new_with_mnemonic
		   gtk_radio_button_new_with_mnemonic_from_widget gtk_radio_button_set_group 
		   gtk_radio_menu_item_get_group gtk_radio_menu_item_new
		   gtk_radio_menu_item_new_from_widget gtk_radio_menu_item_new_with_label_from_widget 
		   gtk_radio_menu_item_new_with_mnemonic gtk_radio_menu_item_new_with_mnemonic_from_widget gtk_radio_menu_item_set_group
		   gtk_radio_tool_button_get_group gtk_radio_tool_button_new 
		   gtk_radio_tool_button_new_from_stock gtk_radio_tool_button_new_from_widget
		   gtk_radio_tool_button_new_with_stock_from_widget gtk_radio_tool_button_set_group 
		   gtk_range_get_adjustment gtk_range_get_inverted
		   gtk_range_get_update_policy gtk_range_get_value gtk_range_set_adjustment gtk_range_set_increments gtk_range_set_inverted
		   gtk_range_set_range gtk_range_set_update_policy gtk_range_set_value gtk_rc_add_default_file gtk_rc_get_default_files
		   gtk_rc_get_im_module_file gtk_rc_get_im_module_path gtk_rc_get_module_dir gtk_rc_get_style gtk_rc_get_theme_dir
		   gtk_rc_parse ;gtk_rc_parse_color gtk_rc_parse_priority gtk_rc_parse_state gtk_rc_parse_string
		   gtk_rc_reparse_all ;gtk_rc_scanner_new 
		   gtk_rc_set_default_files gtk_rc_style_copy
		   gtk_rc_style_new gtk_requisition_copy gtk_requisition_free
		   gtk_ruler_draw_pos gtk_ruler_draw_ticks gtk_ruler_get_metric gtk_ruler_get_range
		   gtk_ruler_set_metric gtk_ruler_set_range gtk_scale_get_digits gtk_scale_get_draw_value
		   gtk_scale_get_layout gtk_scale_get_layout_offsets gtk_scale_get_value_pos gtk_scale_set_digits
		   gtk_scale_set_draw_value gtk_scale_set_value_pos gtk_scrolled_window_add_with_viewport gtk_scrolled_window_get_hadjustment
		   gtk_scrolled_window_get_placement gtk_scrolled_window_get_policy gtk_scrolled_window_get_shadow_type 
		   gtk_scrolled_window_get_vadjustment
		   gtk_scrolled_window_new gtk_scrolled_window_set_hadjustment gtk_scrolled_window_set_placement 
		   gtk_scrolled_window_set_policy gtk_scrolled_window_set_shadow_type
		   gtk_scrolled_window_set_vadjustment gtk_selection_add_target gtk_selection_add_targets gtk_selection_clear_targets gtk_selection_convert
		   gtk_selection_data_copy gtk_selection_data_free gtk_selection_data_get_pixbuf gtk_selection_data_get_targets gtk_selection_data_get_text
		   gtk_selection_data_get_uris gtk_selection_data_set gtk_selection_data_set_pixbuf gtk_selection_data_set_text
		   gtk_selection_data_set_uris gtk_selection_data_targets_include_image 
		   gtk_selection_data_targets_include_text gtk_selection_owner_set gtk_selection_remove_all
		   gtk_separator_menu_item_new gtk_separator_tool_item_get_draw
		   gtk_separator_tool_item_new gtk_separator_tool_item_set_draw gtk_set_locale gtk_size_group_add_widget gtk_size_group_get_mode
		   gtk_size_group_new gtk_size_group_remove_widget gtk_size_group_set_mode gtk_socket_add_id
		   gtk_socket_get_id gtk_socket_new gtk_spin_button_configure gtk_spin_button_get_adjustment
		   gtk_spin_button_get_digits gtk_spin_button_get_increments gtk_spin_button_get_numeric gtk_spin_button_get_range gtk_spin_button_get_snap_to_ticks
		   gtk_spin_button_get_update_policy gtk_spin_button_get_value gtk_spin_button_get_value_as_int gtk_spin_button_get_wrap
		   gtk_spin_button_new gtk_spin_button_new_with_range gtk_spin_button_set_adjustment gtk_spin_button_set_digits gtk_spin_button_set_increments
		   gtk_spin_button_set_numeric gtk_spin_button_set_range 
		   gtk_spin_button_set_snap_to_ticks gtk_spin_button_set_update_policy gtk_spin_button_set_value
		   gtk_spin_button_set_wrap gtk_spin_button_spin gtk_spin_button_update gtk_statusbar_get_context_id gtk_statusbar_get_has_resize_grip
		   gtk_statusbar_new gtk_statusbar_pop gtk_statusbar_push gtk_statusbar_remove
		   gtk_statusbar_set_has_resize_grip gtk_stock_add gtk_stock_add_static gtk_stock_item_copy gtk_stock_item_free
		   gtk_stock_list_ids gtk_stock_lookup gtk_style_apply_default_background gtk_style_attach gtk_style_copy
		   gtk_style_detach gtk_style_lookup_icon_set gtk_style_new gtk_style_render_icon
		   gtk_style_set_background gtk_table_attach gtk_table_attach_defaults gtk_table_get_col_spacing gtk_table_get_default_col_spacing
		   gtk_table_get_default_row_spacing gtk_table_get_homogeneous gtk_table_get_row_spacing gtk_table_new
		   gtk_table_resize gtk_table_set_col_spacing gtk_table_set_col_spacings gtk_table_set_homogeneous gtk_table_set_row_spacing
		   gtk_table_set_row_spacings gtk_target_list_add gtk_target_list_add_image_targets gtk_target_list_add_table gtk_target_list_add_text_targets
		   gtk_target_list_add_uri_targets gtk_target_list_find ;gtk_target_list_ref 
		   gtk_target_list_remove ;gtk_target_list_new
		   gtk_target_list_unref gtk_tearoff_menu_item_new gtk_text_attributes_copy gtk_text_attributes_copy_values
		   gtk_text_attributes_new gtk_text_attributes_unref gtk_text_buffer_add_selection_clipboard gtk_text_buffer_apply_tag
		   gtk_text_buffer_apply_tag_by_name gtk_text_buffer_backspace gtk_text_buffer_begin_user_action 
		   gtk_text_buffer_copy_clipboard gtk_text_buffer_create_child_anchor
		   gtk_text_buffer_create_mark gtk_text_buffer_create_tag gtk_text_buffer_cut_clipboard gtk_text_buffer_delete gtk_text_buffer_delete_interactive
		   gtk_text_buffer_delete_mark gtk_text_buffer_delete_mark_by_name gtk_text_buffer_delete_selection 
		   gtk_text_buffer_end_user_action gtk_text_buffer_get_bounds
		   gtk_text_buffer_get_char_count gtk_text_buffer_get_end_iter gtk_text_buffer_get_insert 
		   gtk_text_buffer_get_iter_at_child_anchor gtk_text_buffer_get_iter_at_line
		   gtk_text_buffer_get_iter_at_line_index gtk_text_buffer_get_iter_at_line_offset 
		   gtk_text_buffer_get_iter_at_mark gtk_text_buffer_get_iter_at_offset gtk_text_buffer_get_line_count
		   gtk_text_buffer_get_mark gtk_text_buffer_get_modified 
		   gtk_text_buffer_get_selection_bound gtk_text_buffer_get_selection_bounds gtk_text_buffer_get_slice
		   gtk_text_buffer_get_start_iter gtk_text_buffer_get_tag_table gtk_text_buffer_get_text gtk_text_buffer_insert
		   gtk_text_buffer_insert_at_cursor gtk_text_buffer_insert_child_anchor gtk_text_buffer_insert_interactive 
		   gtk_text_buffer_insert_interactive_at_cursor gtk_text_buffer_insert_pixbuf
		   gtk_text_buffer_insert_range gtk_text_buffer_insert_range_interactive gtk_text_buffer_insert_with_tags 
		   gtk_text_buffer_insert_with_tags_by_name gtk_text_buffer_move_mark
		   gtk_text_buffer_move_mark_by_name gtk_text_buffer_new 
		   gtk_text_buffer_paste_clipboard gtk_text_buffer_place_cursor gtk_text_buffer_remove_all_tags
		   gtk_text_buffer_remove_selection_clipboard gtk_text_buffer_remove_tag 
		   gtk_text_buffer_remove_tag_by_name gtk_text_buffer_select_range gtk_text_buffer_set_modified
		   gtk_text_buffer_set_text gtk_text_child_anchor_get_deleted 
		   gtk_text_child_anchor_get_widgets gtk_text_child_anchor_new
		   gtk_text_iter_backward_char gtk_text_iter_backward_chars gtk_text_iter_backward_cursor_position 
		   gtk_text_iter_backward_cursor_positions gtk_text_iter_backward_find_char
		   gtk_text_iter_backward_line gtk_text_iter_backward_lines gtk_text_iter_backward_search 
		   gtk_text_iter_backward_sentence_start gtk_text_iter_backward_sentence_starts
		   gtk_text_iter_backward_to_tag_toggle gtk_text_iter_backward_word_start gtk_text_iter_backward_word_starts 
		   gtk_text_iter_begins_tag gtk_text_iter_can_insert
		   gtk_text_iter_compare gtk_text_iter_copy gtk_text_iter_editable gtk_text_iter_ends_line gtk_text_iter_ends_sentence
		   gtk_text_iter_ends_tag gtk_text_iter_ends_word gtk_text_iter_equal gtk_text_iter_forward_char gtk_text_iter_forward_chars
		   gtk_text_iter_forward_cursor_position gtk_text_iter_forward_cursor_positions 
		   gtk_text_iter_forward_find_char gtk_text_iter_forward_line gtk_text_iter_forward_lines
		   gtk_text_iter_forward_search gtk_text_iter_forward_sentence_end gtk_text_iter_forward_sentence_ends 
		   gtk_text_iter_forward_to_end gtk_text_iter_forward_to_line_end
		   gtk_text_iter_forward_to_tag_toggle gtk_text_iter_forward_word_end 
		   gtk_text_iter_forward_word_ends gtk_text_iter_free gtk_text_iter_get_attributes
		   gtk_text_iter_get_buffer gtk_text_iter_get_bytes_in_line gtk_text_iter_get_char gtk_text_iter_get_chars_in_line gtk_text_iter_get_child_anchor
		   gtk_text_iter_get_language gtk_text_iter_get_line gtk_text_iter_get_line_index gtk_text_iter_get_line_offset gtk_text_iter_get_marks
		   gtk_text_iter_get_offset gtk_text_iter_get_pixbuf gtk_text_iter_get_slice gtk_text_iter_get_tags gtk_text_iter_get_text
		   gtk_text_iter_get_toggled_tags gtk_text_iter_get_visible_line_index 
		   gtk_text_iter_get_visible_line_offset gtk_text_iter_get_visible_slice gtk_text_iter_get_visible_text
		   gtk_text_iter_has_tag gtk_text_iter_in_range gtk_text_iter_inside_sentence gtk_text_iter_inside_word gtk_text_iter_is_cursor_position
		   gtk_text_iter_is_end gtk_text_iter_is_start gtk_text_iter_order gtk_text_iter_set_line gtk_text_iter_set_line_index
		   gtk_text_iter_set_line_offset gtk_text_iter_set_offset gtk_text_iter_set_visible_line_index 
		   gtk_text_iter_set_visible_line_offset gtk_text_iter_starts_line
		   gtk_text_iter_starts_sentence gtk_text_iter_starts_word gtk_text_iter_toggles_tag gtk_text_mark_get_buffer gtk_text_mark_get_deleted
		   gtk_text_mark_get_left_gravity gtk_text_mark_get_name gtk_text_mark_get_visible gtk_text_mark_set_visible
		   gtk_text_tag_event gtk_text_tag_get_priority gtk_text_tag_new gtk_text_tag_set_priority
		   gtk_text_tag_table_add gtk_text_tag_table_foreach gtk_text_tag_table_get_size gtk_text_tag_table_lookup
		   gtk_text_tag_table_new gtk_text_tag_table_remove 
		   gtk_text_view_add_child_at_anchor gtk_text_view_add_child_in_window gtk_text_view_backward_display_line
		   gtk_text_view_backward_display_line_start gtk_text_view_buffer_to_window_coords 
		   gtk_text_view_forward_display_line gtk_text_view_forward_display_line_end gtk_text_view_get_accepts_tab
		   gtk_text_view_get_border_window_size gtk_text_view_get_buffer gtk_text_view_get_cursor_visible 
		   gtk_text_view_get_default_attributes gtk_text_view_get_editable
		   gtk_text_view_get_indent gtk_text_view_get_iter_at_location 
		   gtk_text_view_get_iter_location gtk_text_view_get_justification gtk_text_view_get_left_margin
		   gtk_text_view_get_line_at_y gtk_text_view_get_line_yrange gtk_text_view_get_overwrite 
		   gtk_text_view_get_pixels_above_lines gtk_text_view_get_pixels_below_lines
		   gtk_text_view_get_pixels_inside_wrap gtk_text_view_get_right_margin gtk_text_view_get_tabs gtk_text_view_get_visible_rect
		   gtk_text_view_get_window gtk_text_view_get_window_type gtk_text_view_get_wrap_mode gtk_text_view_move_child gtk_text_view_move_mark_onscreen
		   gtk_text_view_move_visually gtk_text_view_new gtk_text_view_new_with_buffer 
		   gtk_text_view_place_cursor_onscreen gtk_text_view_scroll_mark_onscreen
		   gtk_text_view_scroll_to_iter gtk_text_view_scroll_to_mark gtk_text_view_set_accepts_tab 
		   gtk_text_view_set_border_window_size gtk_text_view_set_buffer
		   gtk_text_view_set_cursor_visible gtk_text_view_set_editable 
		   gtk_text_view_set_indent gtk_text_view_set_justification gtk_text_view_set_left_margin
		   gtk_text_view_set_overwrite gtk_text_view_set_pixels_above_lines gtk_text_view_set_pixels_below_lines 
		   gtk_text_view_set_pixels_inside_wrap gtk_text_view_set_right_margin
		   gtk_text_view_set_tabs gtk_text_view_set_wrap_mode gtk_text_view_starts_display_line 
		   gtk_text_view_window_to_buffer_coords gtk_toggle_action_get_active
		   gtk_toggle_action_get_draw_as_radio gtk_toggle_action_new 
		   gtk_toggle_action_set_active gtk_toggle_action_set_draw_as_radio
		   gtk_toggle_action_toggled gtk_toggle_button_get_active gtk_toggle_button_get_inconsistent gtk_toggle_button_get_mode
		   gtk_toggle_button_new gtk_toggle_button_new_with_mnemonic 
		   gtk_toggle_button_set_active gtk_toggle_button_set_inconsistent gtk_toggle_button_set_mode
		   gtk_toggle_button_toggled gtk_toggle_tool_button_get_active 
		   gtk_toggle_tool_button_new gtk_toggle_tool_button_new_from_stock
		   gtk_toggle_tool_button_set_active gtk_tool_button_get_icon_widget gtk_tool_button_get_label 
		   gtk_tool_button_get_label_widget gtk_tool_button_get_stock_id
		   gtk_tool_button_get_use_underline gtk_tool_button_new gtk_tool_button_new_from_stock gtk_tool_button_set_icon_widget
		   gtk_tool_button_set_label gtk_tool_button_set_label_widget 
		   gtk_tool_button_set_stock_id gtk_tool_button_set_use_underline gtk_tool_item_get_expand
		   gtk_tool_item_get_homogeneous gtk_tool_item_get_icon_size gtk_tool_item_get_is_important 
		   gtk_tool_item_get_orientation gtk_tool_item_get_proxy_menu_item
		   gtk_tool_item_get_relief_style gtk_tool_item_get_toolbar_style 
		   gtk_tool_item_get_use_drag_window gtk_tool_item_get_visible_horizontal
		   gtk_tool_item_get_visible_vertical gtk_tool_item_new gtk_tool_item_rebuild_menu gtk_tool_item_retrieve_proxy_menu_item gtk_tool_item_set_expand
		   gtk_tool_item_set_homogeneous gtk_tool_item_set_is_important 
		   gtk_tool_item_set_proxy_menu_item; gtk_tool_item_set_tooltip gtk_tool_item_set_use_drag_window
		   gtk_tool_item_set_visible_horizontal gtk_tool_item_set_visible_vertical 
		   gtk_toolbar_get_drop_index gtk_toolbar_get_icon_size gtk_toolbar_get_item_index
		   gtk_toolbar_get_n_items gtk_toolbar_get_nth_item gtk_toolbar_get_relief_style gtk_toolbar_get_show_arrow
		   gtk_toolbar_get_style gtk_toolbar_insert gtk_toolbar_new
		   gtk_toolbar_set_show_arrow gtk_toolbar_set_style gtk_toolbar_unset_style
		   gtk_tree_drag_dest_drag_data_received   gtk_tree_drag_dest_row_drop_possible gtk_tree_drag_source_drag_data_delete 
		   gtk_tree_drag_source_drag_data_get gtk_tree_drag_source_row_draggable
		   gtk_tree_get_row_drag_data gtk_tree_iter_copy gtk_tree_iter_free gtk_tree_model_filter_clear_cache
		   gtk_tree_model_filter_convert_child_path_to_path 
		   gtk_tree_model_filter_convert_iter_to_child_iter gtk_tree_model_filter_convert_path_to_child_path gtk_tree_model_filter_get_model
		   gtk_tree_model_filter_new 
		   gtk_tree_model_filter_refilter gtk_tree_model_filter_set_visible_column gtk_tree_model_foreach
		   gtk_tree_model_get_column_type gtk_tree_model_get_flags gtk_tree_model_get_iter gtk_tree_model_get_iter_first gtk_tree_model_get_iter_from_string
		   gtk_tree_model_get_n_columns gtk_tree_model_get_path gtk_tree_model_get_string_from_iter gtk_tree_model_iter_children
		   gtk_tree_model_iter_has_child gtk_tree_model_iter_n_children gtk_tree_model_iter_next gtk_tree_model_iter_nth_child gtk_tree_model_iter_parent
		   gtk_tree_model_ref_node gtk_tree_model_row_changed gtk_tree_model_row_deleted gtk_tree_model_row_has_child_toggled gtk_tree_model_row_inserted
		   gtk_tree_model_rows_reordered gtk_tree_model_sort_clear_cache gtk_tree_model_sort_convert_child_iter_to_iter 
		   gtk_tree_model_sort_convert_child_path_to_path gtk_tree_model_sort_convert_iter_to_child_iter
		   gtk_tree_model_sort_convert_path_to_child_path gtk_tree_model_sort_get_model 
		   gtk_tree_model_sort_iter_is_valid gtk_tree_model_sort_new_with_model
		   gtk_tree_model_sort_reset_default_sort_func gtk_tree_model_unref_node gtk_tree_path_append_index gtk_tree_path_compare gtk_tree_path_copy
		   gtk_tree_path_down gtk_tree_path_free gtk_tree_path_get_depth gtk_tree_path_get_indices 
		   gtk_tree_path_is_ancestor gtk_tree_path_is_descendant gtk_tree_path_new gtk_tree_path_new_first gtk_tree_path_new_from_string
		   gtk_tree_path_next gtk_tree_path_prepend_index gtk_tree_path_prev gtk_tree_path_to_string gtk_tree_path_up
		   gtk_tree_row_reference_deleted gtk_tree_row_reference_free 
		   gtk_tree_row_reference_get_path gtk_tree_row_reference_inserted gtk_tree_row_reference_new
		   gtk_tree_row_reference_new_proxy gtk_tree_row_reference_reordered gtk_tree_row_reference_valid 
		   gtk_tree_selection_count_selected_rows gtk_tree_selection_get_mode
		   gtk_tree_selection_get_selected gtk_tree_selection_get_selected_rows gtk_tree_selection_get_tree_view 
		   gtk_tree_selection_get_user_data
		   gtk_tree_selection_iter_is_selected gtk_tree_selection_path_is_selected gtk_tree_selection_select_all 
		   gtk_tree_selection_select_iter gtk_tree_selection_select_path
		   gtk_tree_selection_select_range gtk_tree_selection_selected_foreach gtk_tree_selection_set_mode 
		   gtk_tree_selection_set_select_function gtk_tree_selection_unselect_all
		   gtk_tree_selection_unselect_iter gtk_tree_selection_unselect_path gtk_tree_set_row_drag_data 
		   gtk_tree_sortable_get_sort_column_id   gtk_tree_sortable_has_default_sort_func gtk_tree_sortable_set_default_sort_func gtk_tree_sortable_set_sort_column_id 
		   gtk_tree_sortable_set_sort_func gtk_tree_sortable_sort_column_changed
		   gtk_tree_store_append gtk_tree_store_clear gtk_tree_store_insert gtk_tree_store_insert_after
		   gtk_tree_store_insert_before gtk_tree_store_is_ancestor gtk_tree_store_iter_depth gtk_tree_store_new gtk_tree_store_newv
		   gtk_tree_store_prepend gtk_tree_store_remove gtk_tree_store_reorder gtk_tree_store_set gtk_tree_store_set_column_types
		   gtk_tree_store_swap gtk_tree_view_append_column gtk_tree_view_collapse_all gtk_tree_view_collapse_row gtk_tree_view_column_add_attribute
		   gtk_tree_view_column_cell_get_position gtk_tree_view_column_cell_get_size gtk_tree_view_column_cell_is_visible 
		   gtk_tree_view_column_cell_set_cell_data gtk_tree_view_column_clear
		   gtk_tree_view_column_clear_attributes gtk_tree_view_column_clicked gtk_tree_view_column_get_alignment 
		   gtk_tree_view_column_get_clickable
		   gtk_tree_view_column_get_expand gtk_tree_view_column_get_fixed_width gtk_tree_view_column_get_max_width 
		   gtk_tree_view_column_get_min_width gtk_tree_view_column_get_reorderable
		   gtk_tree_view_column_get_resizable gtk_tree_view_column_get_sizing gtk_tree_view_column_get_sort_column_id 
		   gtk_tree_view_column_get_sort_indicator gtk_tree_view_column_get_sort_order
		   gtk_tree_view_column_get_spacing gtk_tree_view_column_get_title 
		   gtk_tree_view_column_get_visible gtk_tree_view_column_get_widget
		   gtk_tree_view_column_get_width gtk_tree_view_column_new gtk_tree_view_column_new_with_attributes 
		   gtk_tree_view_column_pack_end gtk_tree_view_column_pack_start
		   gtk_tree_view_column_set_alignment gtk_tree_view_column_set_attributes gtk_tree_view_column_set_cell_data_func 
		   gtk_tree_view_column_set_clickable gtk_tree_view_column_set_expand
		   gtk_tree_view_column_set_fixed_width gtk_tree_view_column_set_max_width gtk_tree_view_column_set_min_width 
		   gtk_tree_view_column_set_reorderable gtk_tree_view_column_set_resizable
		   gtk_tree_view_column_set_sizing gtk_tree_view_column_set_sort_column_id gtk_tree_view_column_set_sort_indicator 
		   gtk_tree_view_column_set_sort_order gtk_tree_view_column_set_spacing
		   gtk_tree_view_column_set_title gtk_tree_view_column_set_visible gtk_tree_view_column_set_widget 
		   gtk_tree_view_columns_autosize gtk_tree_view_create_row_drag_icon
		   gtk_tree_view_enable_model_drag_dest gtk_tree_view_enable_model_drag_source 
		   gtk_tree_view_expand_all gtk_tree_view_expand_row gtk_tree_view_expand_to_path
		   gtk_tree_view_get_background_area gtk_tree_view_get_bin_window gtk_tree_view_get_cell_area gtk_tree_view_get_column gtk_tree_view_get_columns
		   gtk_tree_view_get_cursor gtk_tree_view_get_dest_row_at_pos gtk_tree_view_get_drag_dest_row gtk_tree_view_get_enable_search
		   gtk_tree_view_get_expander_column
		   gtk_tree_view_get_fixed_height_mode gtk_tree_view_get_hadjustment gtk_tree_view_get_headers_visible 
		   gtk_tree_view_get_hover_expand gtk_tree_view_get_hover_selection
		   gtk_tree_view_get_model gtk_tree_view_get_path_at_pos gtk_tree_view_get_reorderable gtk_tree_view_get_rules_hint gtk_tree_view_get_search_column
		   gtk_tree_view_get_search_equal_func gtk_tree_view_get_selection 
		   gtk_tree_view_get_vadjustment gtk_tree_view_get_visible_rect
		   gtk_tree_view_insert_column gtk_tree_view_insert_column_with_attributes 
		   gtk_tree_view_insert_column_with_data_func gtk_tree_view_map_expanded_rows gtk_tree_view_move_column_after
		   gtk_tree_view_new gtk_tree_view_new_with_model gtk_tree_view_remove_column gtk_tree_view_row_activated gtk_tree_view_row_expanded
		   gtk_tree_view_scroll_to_cell gtk_tree_view_scroll_to_point gtk_tree_view_set_column_drag_function 
		   gtk_tree_view_set_cursor gtk_tree_view_set_drag_dest_row
		   gtk_tree_view_set_enable_search gtk_tree_view_set_expander_column gtk_tree_view_set_fixed_height_mode 
		   gtk_tree_view_set_hadjustment gtk_tree_view_set_headers_clickable
		   gtk_tree_view_set_headers_visible gtk_tree_view_set_hover_expand 
		   gtk_tree_view_set_hover_selection gtk_tree_view_set_model gtk_tree_view_set_reorderable
		   gtk_tree_view_set_row_separator_func gtk_tree_view_set_rules_hint gtk_tree_view_set_search_column 
		   gtk_tree_view_set_search_equal_func gtk_tree_view_set_vadjustment
		   gtk_tree_view_unset_rows_drag_dest 
		   gtk_tree_view_unset_rows_drag_source gtk_true
		   gtk_ui_manager_add_ui gtk_ui_manager_add_ui_from_file gtk_ui_manager_add_ui_from_string 
		   gtk_ui_manager_ensure_update gtk_ui_manager_get_accel_group
		   gtk_ui_manager_get_action gtk_ui_manager_get_action_groups gtk_ui_manager_get_add_tearoffs gtk_ui_manager_get_ui
		   gtk_ui_manager_get_widget gtk_ui_manager_insert_action_group gtk_ui_manager_new gtk_ui_manager_new_merge_id gtk_ui_manager_remove_action_group
		   gtk_ui_manager_remove_ui gtk_ui_manager_set_add_tearoffs gtk_vbox_new 
		   gtk_vbutton_box_new gtk_viewport_get_hadjustment gtk_viewport_get_shadow_type gtk_viewport_get_vadjustment
		   gtk_viewport_new gtk_viewport_set_hadjustment gtk_viewport_set_shadow_type gtk_viewport_set_vadjustment   gtk_vpaned_new gtk_vruler_new gtk_vscale_new
		   gtk_vscale_new_with_range gtk_vscrollbar_new gtk_vseparator_new
		   gtk_widget_activate gtk_widget_add_accelerator gtk_widget_add_events gtk_widget_add_mnemonic_label gtk_widget_can_activate_accel
		   gtk_widget_child_focus gtk_widget_child_notify gtk_widget_class_path gtk_widget_create_pango_context gtk_widget_create_pango_layout
		   gtk_widget_destroy gtk_widget_destroyed gtk_widget_ensure_style gtk_widget_event gtk_widget_freeze_child_notify
		   gtk_widget_get_accessible gtk_widget_get_ancestor gtk_widget_get_child_requisition gtk_widget_get_child_visible gtk_widget_get_clipboard
		   gtk_widget_get_colormap gtk_widget_get_composite_name gtk_widget_get_default_colormap 
		   gtk_widget_get_default_direction gtk_widget_get_default_style
		   gtk_widget_get_default_visual gtk_widget_get_direction gtk_widget_get_display gtk_widget_get_events ;gtk_widget_get_extension_events
		   gtk_widget_get_modifier_style gtk_widget_get_name gtk_widget_get_no_show_all gtk_widget_get_pango_context gtk_widget_get_parent
		   gtk_widget_get_parent_window gtk_widget_get_pointer gtk_widget_get_root_window gtk_widget_get_screen gtk_widget_get_size_request
		   gtk_widget_get_style gtk_widget_get_toplevel gtk_widget_get_visual gtk_widget_grab_default
		   gtk_widget_grab_focus gtk_widget_has_screen gtk_widget_hide gtk_widget_hide_all gtk_widget_hide_on_delete
		   gtk_widget_intersect gtk_widget_is_ancestor gtk_widget_is_focus gtk_widget_list_accel_closures gtk_widget_list_mnemonic_labels
		   gtk_widget_map gtk_widget_mnemonic_activate gtk_widget_modify_base gtk_widget_modify_bg gtk_widget_modify_fg
		   gtk_widget_modify_font gtk_widget_modify_style gtk_widget_modify_text gtk_widget_path gtk_widget_pop_colormap
		   gtk_widget_pop_composite_child gtk_widget_push_colormap gtk_widget_push_composite_child gtk_widget_queue_draw gtk_widget_queue_draw_area
		   gtk_widget_queue_resize gtk_widget_queue_resize_no_redraw gtk_widget_realize gtk_widget_region_intersect
		   gtk_widget_remove_accelerator gtk_widget_remove_mnemonic_label gtk_widget_render_icon gtk_widget_reparent gtk_widget_reset_rc_styles
		   gtk_widget_reset_shapes gtk_widget_send_expose gtk_widget_set_accel_path gtk_widget_set_app_paintable gtk_widget_set_child_visible
		   gtk_widget_set_colormap gtk_widget_set_composite_name gtk_widget_set_default_colormap gtk_widget_set_default_direction gtk_widget_set_direction
		   gtk_widget_set_double_buffered gtk_widget_set_events ;gtk_widget_set_extension_events 
		   gtk_widget_set_name gtk_widget_set_no_show_all
		   gtk_widget_set_parent gtk_widget_set_parent_window gtk_widget_set_redraw_on_allocate gtk_widget_set_scroll_adjustments gtk_widget_set_sensitive
		   gtk_widget_set_size_request gtk_widget_set_state gtk_widget_set_style gtk_widget_shape_combine_mask gtk_widget_show
		   gtk_widget_show_all gtk_widget_show_now gtk_widget_size_allocate gtk_widget_size_request gtk_widget_thaw_child_notify
		   gtk_widget_translate_coordinates gtk_widget_unmap gtk_widget_unparent gtk_widget_unrealize
		   gtk_window_activate_default gtk_window_activate_focus gtk_window_activate_key gtk_window_add_accel_group gtk_window_add_embedded_xid
		   gtk_window_add_mnemonic gtk_window_begin_move_drag gtk_window_begin_resize_drag gtk_window_deiconify gtk_window_get_accept_focus
		   gtk_window_get_decorated gtk_window_get_default_icon_list gtk_window_get_default_size gtk_window_get_destroy_with_parent gtk_window_get_focus
		   gtk_window_get_focus_on_map gtk_window_get_frame_dimensions gtk_window_get_gravity gtk_window_get_has_frame gtk_window_get_icon
		   gtk_window_get_icon_list gtk_window_get_icon_name gtk_window_get_mnemonic_modifier gtk_window_get_modal gtk_window_get_position
		   gtk_window_get_resizable gtk_window_get_role gtk_window_get_size gtk_window_get_title gtk_window_get_transient_for
		   gtk_window_has_toplevel_focus gtk_window_iconify
		   gtk_window_is_active gtk_window_list_toplevels gtk_window_maximize gtk_window_mnemonic_activate gtk_window_move
		   gtk_window_new gtk_window_parse_geometry gtk_window_present gtk_window_propagate_key_event gtk_window_remove_accel_group
		   gtk_window_remove_embedded_xid gtk_window_remove_mnemonic gtk_window_reshow_with_initial_size gtk_window_resize gtk_window_set_accept_focus
		   gtk_window_set_auto_startup_notification gtk_window_set_decorated gtk_window_set_default 
		   gtk_window_set_default_icon gtk_window_set_default_icon_list
		   gtk_window_set_default_icon_name gtk_window_set_default_size gtk_window_set_destroy_with_parent gtk_window_set_focus gtk_window_set_focus_on_map
		   gtk_window_set_frame_dimensions gtk_window_set_geometry_hints gtk_window_set_gravity gtk_window_set_has_frame gtk_window_set_icon
		   gtk_window_set_icon_list gtk_window_set_icon_name gtk_window_set_keep_above gtk_window_set_keep_below gtk_window_set_mnemonic_modifier
		   gtk_window_set_modal gtk_window_set_position gtk_window_set_resizable gtk_window_set_role gtk_window_set_title
		   gtk_window_set_transient_for gtk_window_set_type_hint gtk_window_set_wmclass gtk_window_stick gtk_window_unmaximize
		   gtk_window_unstick pango_attr_background_new pango_attr_fallback_new pango_attr_family_new
		   pango_attr_font_desc_new pango_attr_foreground_new pango_attr_iterator_copy pango_attr_iterator_destroy pango_attr_iterator_get
		   pango_attr_iterator_get_attrs pango_attr_iterator_get_font pango_attr_iterator_next pango_attr_iterator_range pango_attr_language_new
		   pango_attr_letter_spacing_new pango_attr_list_change pango_attr_list_copy pango_attr_list_filter pango_attr_list_get_iterator
		   pango_attr_list_insert pango_attr_list_insert_before pango_attr_list_new 
		   pango_attr_list_splice pango_attr_list_unref pango_attr_rise_new pango_attr_scale_new pango_attr_shape_new
		   pango_attr_size_new pango_attr_stretch_new pango_attr_strikethrough_color_new pango_attr_strikethrough_new pango_attr_style_new
		   pango_attr_type_register pango_attr_underline_color_new pango_attr_underline_new pango_attr_variant_new
		   pango_attr_weight_new pango_attribute_copy pango_attribute_destroy pango_attribute_equal pango_break
		   pango_color_copy pango_color_free pango_color_parse pango_context_get_base_dir
		   pango_context_get_font_description pango_context_get_language pango_context_get_metrics pango_context_list_families
		   pango_context_load_font pango_context_load_fontset pango_context_set_base_dir pango_context_set_font_description pango_context_set_language
		   pango_coverage_copy pango_coverage_get pango_coverage_max pango_coverage_new
		   pango_coverage_ref pango_coverage_set pango_coverage_to_bytes pango_coverage_unref
		   pango_font_describe pango_font_description_better_match pango_font_description_copy 
		   pango_font_description_copy_static pango_font_description_equal
		   pango_font_description_free pango_font_description_from_string pango_font_description_get_family 
		   pango_font_description_get_set_fields pango_font_description_get_size
		   pango_font_description_get_stretch pango_font_description_get_style 
		   pango_font_description_get_variant pango_font_description_get_weight
		   pango_font_description_hash pango_font_description_merge pango_font_description_merge_static 
		   pango_font_description_new pango_font_description_set_family
		   pango_font_description_set_family_static pango_font_description_set_size pango_font_description_set_stretch 
		   pango_font_description_set_style pango_font_description_set_variant
		   pango_font_description_set_weight pango_font_description_to_filename pango_font_description_to_string 
		   pango_font_description_unset_fields pango_font_descriptions_free
		   pango_font_face_describe pango_font_face_get_face_name pango_font_face_list_sizes pango_font_family_get_name
		   pango_font_family_is_monospace pango_font_family_list_faces pango_font_get_coverage pango_font_get_glyph_extents
		   pango_font_get_metrics pango_font_map_list_families pango_font_map_load_font
		   pango_font_map_load_fontset pango_font_metrics_get_approximate_char_width 
		   pango_font_metrics_get_approximate_digit_width pango_font_metrics_get_ascent
		   pango_font_metrics_get_descent pango_font_metrics_get_strikethrough_position 
		   pango_font_metrics_get_strikethrough_thickness pango_font_metrics_get_underline_position
		   pango_font_metrics_get_underline_thickness pango_font_metrics_ref pango_font_metrics_unref pango_get_log_attrs pango_glyph_string_copy
		   pango_glyph_string_extents pango_glyph_string_extents_range pango_glyph_string_free 
		   pango_glyph_string_get_logical_widths
		   pango_glyph_string_index_to_x pango_glyph_string_new pango_glyph_string_set_size pango_glyph_string_x_to_index pango_item_copy
		   pango_item_free pango_item_new pango_item_split pango_itemize
		   pango_language_matches pango_layout_context_changed pango_layout_copy pango_layout_get_alignment pango_layout_get_attributes
		   pango_layout_get_auto_dir pango_layout_get_context pango_layout_get_cursor_pos pango_layout_get_extents pango_layout_get_indent
		   pango_layout_get_iter pango_layout_get_justify pango_layout_get_line pango_layout_get_line_count pango_layout_get_lines
		   pango_layout_get_log_attrs pango_layout_get_pixel_extents pango_layout_get_pixel_size 
		   pango_layout_get_single_paragraph_mode pango_layout_get_size
		   pango_layout_get_spacing pango_layout_get_tabs pango_layout_get_text pango_layout_get_width
		   pango_layout_get_wrap pango_layout_index_to_pos pango_layout_iter_at_last_line pango_layout_iter_free pango_layout_iter_get_baseline
		   pango_layout_iter_get_char_extents pango_layout_iter_get_cluster_extents 
		   pango_layout_iter_get_index pango_layout_iter_get_layout_extents pango_layout_iter_get_line
		   pango_layout_iter_get_line_extents pango_layout_iter_get_line_yrange pango_layout_iter_get_run 
		   pango_layout_iter_get_run_extents pango_layout_iter_next_char
		   pango_layout_iter_next_cluster pango_layout_iter_next_line pango_layout_iter_next_run 
		   pango_layout_line_get_extents pango_layout_line_get_pixel_extents
		   pango_layout_line_get_x_ranges pango_layout_line_index_to_x 
		   pango_layout_line_x_to_index
		   pango_layout_move_cursor_visually pango_layout_new pango_layout_set_alignment pango_layout_set_attributes pango_layout_set_auto_dir
		   pango_layout_set_font_description pango_layout_set_indent pango_layout_set_justify pango_layout_set_markup pango_layout_set_markup_with_accel
		   pango_layout_set_single_paragraph_mode pango_layout_set_spacing pango_layout_set_tabs pango_layout_set_text pango_layout_set_width
		   pango_layout_set_wrap pango_layout_xy_to_index pango_parse_markup pango_renderer_activate
		   pango_renderer_deactivate pango_renderer_draw_error_underline pango_renderer_draw_glyph pango_renderer_draw_glyphs pango_renderer_draw_layout
		   pango_renderer_draw_layout_line pango_renderer_draw_rectangle pango_renderer_draw_trapezoid pango_renderer_get_color
		   pango_renderer_part_changed pango_renderer_set_color pango_renderer_set_matrix pango_reorder_items pango_script_for_unichar
		   pango_script_iter_free pango_script_iter_get_range pango_script_iter_next pango_shape       ))
		 
		 (gtk-procs0 (remove-if (lambda (n) (not (arity-ok n 0))) gtk-procs))
		 (gtk-procs1 (remove-if (lambda (n) (not (arity-ok n 1))) gtk-procs))
		 (gtk-procs2 (remove-if (lambda (n) (not (arity-ok n 2))) gtk-procs))
		 (gtk-procs3 (remove-if (lambda (n) (not (arity-ok n 3))) gtk-procs))
		 (gtk-procs4 (remove-if (lambda (n) (not (arity-ok n 4))) gtk-procs))
		 
		 (error-log (open-output-file "gtk-errors"))
		 
		 (gtk-logger (g_log_set_handler "Gtk" (logior G_LOG_LEVEL_CRITICAL G_LOG_LEVEL_WARNING G_LOG_LEVEL_MESSAGE)
						(lambda (domain level msg ptr)
						  (display (format #f "gtk: ~A~%" msg) error-log))
						#f))
		 (gdk-logger (g_log_set_handler "Gdk" (logior G_LOG_LEVEL_CRITICAL G_LOG_LEVEL_WARNING G_LOG_LEVEL_MESSAGE)
						(lambda (domain level msg ptr)
						  (display (format #f "gdk: ~A~%" msg) error-log))
						#f))
		 (gdkpix-logger (g_log_set_handler "GdkPixbuf" (logior G_LOG_LEVEL_CRITICAL G_LOG_LEVEL_WARNING G_LOG_LEVEL_MESSAGE)
						   (lambda (domain level msg ptr)
						     (display (format #f "gdkpix: ~A~%" msg) error-log))
						   #f))
		 (pango-logger (g_log_set_handler "Pango" (logior G_LOG_LEVEL_CRITICAL G_LOG_LEVEL_WARNING G_LOG_LEVEL_MESSAGE)
						  (lambda (domain level msg ptr)
						    (display (format #f "pango: ~A~%" msg) error-log))
						  #f))
		 (glib-logger (g_log_set_handler "GLib" (logior G_LOG_LEVEL_CRITICAL G_LOG_LEVEL_WARNING G_LOG_LEVEL_MESSAGE)
						 (lambda (domain level msg ptr)
						   (display (format #f "glib: ~A~%" msg) error-log))
						 #f))
		 (gobject-logger (g_log_set_handler "GLib-GObject" (logior G_LOG_LEVEL_CRITICAL G_LOG_LEVEL_WARNING G_LOG_LEVEL_MESSAGE)
						    (lambda (domain level msg ptr)
						      (display (format #f "gobject: ~A~%" msg) error-log))
						    #f)))
	    
	    
	    ;; ---------------- 0 Args
	    (for-each 
	     (lambda (n)
	       (catch #t
		      (lambda () 
			(if (c-g?) (abort))
			(n))
		      (lambda args (car args))))
	     gtk-procs0)
	    
	    ;; ---------------- 1 Arg
	    (for-each 
	     (lambda (arg)
					;(display (format #f "11---------------- ~A ----------------~%" arg))
	       (for-each 
		(lambda (n)
		  (catch #t
			 (lambda () 
			   (if (c-g?) (abort))
			   (n arg))
			 (lambda args 
			   (if (and (not (eq? (car args) 'wrong-type-arg))
				    (not (eq? (car args) 'out-of-range)))
			       (snd-display #__line__ ";1 arg: ~A ~A" args n))
			   (car args))))
		gtk-procs1))
	     (list 1.5 "/hiho" (list 0 1) 1234  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
		   (lambda () #t) (make-sound-data 2 3) :order 0 1 -1 (make-hook 2) #f #t '() (make-vector 0)))
	    
	    ;; ---------------- 2 Args
	    (for-each 
	     (lambda (arg1)
					;(display (format #f "22---------------- ~A ----------------~%" arg1))
	       (for-each 
		(lambda (arg2)
		  (for-each 
		   (lambda (n)
		     (catch #t
			    (lambda () 
			      (if (c-g?) (abort))
			      (n arg1 arg2))
			    (lambda args 
			      (car args))))
		   gtk-procs2))
		(list 1.5 "/hiho" (list 0 1) 1234  '#(0 1) 3/4 
		      (sqrt -1.0) (make-delay 32) :feedback -1 0 #f #t '() (make-vector 0))))
	     (list 1.5 "/hiho" (list 0 1) 1234  '#(0 1) 3/4 
		   (sqrt -1.0) (make-delay 32) :frequency -1 0 #f #t '() (make-vector 0)))
	    
	    (if all-args
		(begin
		  
		  ;; ---------------- 3 Args
		  (for-each 
		   (lambda (arg1)
					;(display (format #f "33---------------- ~A ----------------~%" arg1))
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (n)
			      (catch #t
				     (lambda () 
				       (if (c-g?) (abort))
				       (n arg1 arg2 arg3))
				     (lambda args (car args))))
			    gtk-procs3))
			 (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0)  :start -1 0 #f #t '())))
		      (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0) :phase -1 0 #f #t '())))
		   (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0) :channels -1 0 #f #t '()))
		  
		  ;; ---------------- 4 Args
		  (for-each 
		   (lambda (arg1)
					;(display (format #f "44---------------- ~A ----------------~%" arg1))
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each 
			       (lambda (n)
				 (catch #t
					(lambda () 
					  (if (c-g?) (abort))
					  (n arg1 arg2 arg3 arg4))
					(lambda args (car args))))
			       gtk-procs4))
			    (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0) :start -1 0 #f #t '())))
			 (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0) :phase -1 0 #f #t '())))
		      (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0) :channels -1 0 #f #t '())))
		   (list 1.5 "/hiho" (list 0 1) 1234 '#(0 1) (sqrt -1.0) :channels -1 0 #f #t '()))
		  
		  ))
	    
	    (g_log_remove_handler "Gtk" gtk-logger)
	    (g_log_remove_handler "Gdk" gdk-logger)
	    (g_log_remove_handler "GdkPixbuf" gdkpix-logger)
	    (g_log_remove_handler "Pango" pango-logger)
	    (g_log_remove_handler "GLib" glib-logger)
	    (g_log_remove_handler "GLib-GObject" gobject-logger)
	    
	    (close-output-port error-log)
	    )
	  ))
    ))

;;; ---------------- test 27: GL --------------------

(define (snd_test_27)
  (if (and (provided? 'snd-motif) 
	   (provided? 'gl)
	   (provided? 'xm))
      
      (begin
	
	(if (not (provided? 'snd-snd-gl.scm)) (load "snd-gl.scm"))
	(gl-info)
	(if all-args (gl-dump-state))
	(let ((gl-procs 
	       (list
		glXChooseVisual glXCopyContext glXCreateContext glXCreateGLXPixmap glXDestroyContext glXDestroyGLXPixmap glXGetConfig
		glXGetCurrentContext glXGetCurrentDrawable glXIsDirect glXMakeCurrent glXQueryExtension glXQueryVersion glXSwapBuffers
		glXUseXFont glXWaitGL glXWaitX glXGetClientString glXQueryServerString glXQueryExtensionsString glClearIndex glClearColor
		glClear glIndexMask glColorMask glAlphaFunc glBlendFunc glLogicOp glCullFace glFrontFace glPointSize glLineWidth glLineStipple
		glPolygonMode glPolygonOffset glPolygonStipple glEdgeFlag glScissor glClipPlane glGetClipPlane
		glDrawBuffer glReadBuffer glEnable glDisable glIsEnabled glEnableClientState glDisableClientState glGetBooleanv
		glGetDoublev glGetFloatv glGetIntegerv glPushAttrib glPopAttrib glPushClientAttrib glPopClientAttrib glRenderMode
		glGetError glGetString glFinish glFlush glHint glClearDepth glDepthFunc glDepthMask glDepthRange glClearAccum glAccum
		glMatrixMode glOrtho glFrustum glViewport glPushMatrix glPopMatrix glLoadIdentity glLoadMatrixd glLoadMatrixf
		glMultMatrixd glMultMatrixf glRotated glRotatef glScaled glScalef glTranslated glTranslatef glIsList glDeleteLists
		glGenLists glNewList glEndList glCallList glCallLists glListBase glBegin glEnd glVertex2d glVertex2f glVertex2i glVertex2s
		glVertex3d glVertex3f glVertex3i glVertex3s glVertex4d glVertex4f glVertex4i glVertex4s glNormal3b glNormal3d glNormal3f
		glNormal3i glNormal3s glIndexd glIndexf glIndexi glIndexs glIndexub glColor3b glColor3d glColor3f glColor3i glColor3s
		glColor3ub glColor3ui glColor3us glColor4b glColor4d glColor4f glColor4i glColor4s glColor4ub glColor4ui glColor4us glTexCoord1d
		glTexCoord1f glTexCoord1i glTexCoord1s glTexCoord2d glTexCoord2f glTexCoord2i glTexCoord2s glTexCoord3d glTexCoord3f glTexCoord3i
		glTexCoord3s glTexCoord4d glTexCoord4f glTexCoord4i glTexCoord4s glRasterPos2d glRasterPos2f glRasterPos2i glRasterPos2s
		glRasterPos3d glRasterPos3f glRasterPos3i glRasterPos3s glRasterPos4d glRasterPos4f glRasterPos4i glRasterPos4s glRectd
		glRectf glRecti glRects glVertexPointer glNormalPointer glColorPointer glIndexPointer glTexCoordPointer glEdgeFlagPointer
		glGetPointerv glArrayElement glDrawArrays glDrawElements glInterleavedArrays glShadeModel glLightf glLighti glGetLightfv
		glGetLightiv glLightModelf glLightModeli glMaterialf glMateriali glGetMaterialfv glGetMaterialiv glColorMaterial glPixelZoom
		glPixelStoref glPixelStorei glPixelTransferf glPixelTransferi glGetPixelMapfv glGetPixelMapuiv glGetPixelMapusv glBitmap
		glReadPixels glDrawPixels glCopyPixels glStencilFunc glStencilMask glStencilOp glClearStencil glTexGend glTexGenf glTexGeni
		glGetTexGendv glGetTexGenfv glGetTexGeniv glTexEnvf glTexEnvi glGetTexEnvfv glGetTexEnviv glTexParameterf glTexParameteri
		glGetTexParameterfv glGetTexParameteriv glGetTexLevelParameterfv glGetTexLevelParameteriv glTexImage1D glTexImage2D
		glGenTextures glDeleteTextures glBindTexture glAreTexturesResident glIsTexture glTexSubImage1D glTexSubImage2D glCopyTexImage1D
		glCopyTexImage2D glCopyTexSubImage1D glCopyTexSubImage2D glMap1d glMap1f glMap2d glMap2f glGetMapdv glGetMapfv glGetMapiv
		glEvalCoord1d glEvalCoord1f glEvalCoord2d glEvalCoord2f glMapGrid1d glMapGrid1f glMapGrid2d glMapGrid2f glEvalPoint1
		glEvalPoint2 glEvalMesh1 glEvalMesh2 glFogf glFogi glFeedbackBuffer glPassThrough glSelectBuffer glInitNames glLoadName
		glPushName glPopName glDrawRangeElements glTexImage3D glTexSubImage3D glCopyTexSubImage3D glColorTable glColorSubTable
		glCopyColorSubTable glCopyColorTable glGetColorTableParameterfv glGetColorTableParameteriv glBlendEquation glBlendColor
		glHistogram glResetHistogram glGetHistogram glGetHistogramParameterfv glGetHistogramParameteriv glMinmax glResetMinmax
		glGetMinmax glGetMinmaxParameterfv glGetMinmaxParameteriv glConvolutionFilter1D glConvolutionFilter2D glConvolutionParameterf
		glConvolutionParameteri glCopyConvolutionFilter1D glCopyConvolutionFilter2D glSeparableFilter2D ))
	      (glu-procs 
	       (if (defined? 'gluBeginPolygon)
		   (list
		    gluBeginPolygon gluBuild1DMipmaps gluLookAt gluNewTess gluNextContour gluTessEndContour
		    gluBuild2DMipmaps gluDeleteTess gluEndPolygon gluErrorString gluGetString gluGetTessProperty 
		    gluOrtho2D gluPerspective gluPickMatrix gluProject gluScaleImage gluTessBeginContour gluTessBeginPolygon 
		    gluTessEndPolygon gluTessNormal gluTessProperty gluTessVertex gluUnProject)
		   '())))
	  
	  ;; ---------------- 1 Arg
	  (for-each 
	   (lambda (arg)
	     (for-each 
	      (lambda (n)
		(catch #t
		       (lambda () (n arg))
		       (lambda args (car args))))
	      gl-procs))
	   (list (list 0 1) (sqrt -1.0)))
	  
	  (if (not (null? glu-procs))
	      (begin
		(for-each 
		 (lambda (arg)
		   (for-each 
		    (lambda (n)
		      (catch #t
			     (lambda () (n arg))
			     (lambda args (car args))))
		    gl-procs))
		 (list (list 0 1) (sqrt -1.0)))
		
		(let ((ind (open-sound "oboe.snd")))
		  (glXMakeCurrent (XtDisplay (cadr (main-widgets))) 
				  (XtWindow (car (channel-widgets)))
				  (snd-glx-context))
		  (glEnable GL_DEPTH_TEST)
		  (glDepthFunc GL_LEQUAL)
		  (glClearDepth 1.0)
		  (glClearColor 0.0 0.0 0.0 0.0)
		  (glLoadIdentity)
		  (gluPerspective 40.0 1.0 10.0 200.0)
		  (glTranslatef 0.0 0.0 -50.0)
		  (glRotatef -58.0 0.0 1.0 0.0)
		  (let ((vals (XtVaGetValues (car (channel-widgets)) (list XmNwidth 0 XmNheight 0))))
		    (glViewport 0 0 (list-ref vals 1) (list-ref vals 3)))
		  (glClear (logior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))
		  (glBegin GL_POLYGON)
		  (glColor3f 0.0 0.0 0.0)   (glVertex3f -10.0 -10.0 0.0)
		  (glColor3f 0.7 0.7 0.7)   (glVertex3f 10.0 -10.0 0.0)
		  (glColor3f 1.0 1.0 1.0)   (glVertex3f -10.0 10.0 0.0)
		  (glEnd)
		  (glBegin GL_POLYGON)
		  (glColor3f 1.0 1.0 0.0)   (glVertex3f 0.0 -10.0 -10.0)
		  (glColor3f 0.0 1.0 0.7)   (glVertex3f 0.0 -10.0 10.0)
		  (glColor3f 0.0 0.0 1.0)   (glVertex3f 0.0 5.0 -10.0)
		  (glEnd)
		  (glBegin GL_POLYGON)
		  (glColor3f 1.0 1.0 0.0)   (glVertex3f -10.0 6.0 4.0)
		  (glColor3f 1.0 0.0 1.0)   (glVertex3f -10.0 3.0 4.0)
		  (glColor3f 0.0 0.0 1.0)   (glVertex3f 4.0 -9.0 -10.0)
		  (glColor3f 1.0 0.0 1.0)   (glVertex3f 4.0 -6.0 -10.0)
		  (glEnd)
		  (glXSwapBuffers (XtDisplay (cadr (main-widgets))) 
				  (XtWindow (car (channel-widgets))))
		  (glFlush)
		  (close-sound ind)))))
	)))

(if (and with-gui
	 (provided? 'xm)
	 (= snd-test 25))
    (if (file-exists? "misc.scm")
	(load "misc.scm")))



;;; ---------------- test 28: errors ----------------

(defvar env3 '(0 0 1 1))

(defmacro simple-time (a) 
  `(let ((start (get-internal-real-time))) 
     ,a 
     (- (get-internal-real-time) start)))


(define (snd_test_28)
  
  (define (traced a) (+ 2 a))
  
  (define (extract-channel filename snd chn)
    (save-sound-as filename snd #f #f #f chn))
  
  (define* (extract-channels :rest chans)
    ;; extract a list of channels from the current sound and save as test.snd: (extract-channels 0 2)
    (let ((snd (or (selected-sound) (car (sounds)))))
      (if (sound? snd)
	  (begin
	    (for-each
	     (lambda (chan)
	       (set! (selection-member? snd chan) #t)
	       (set! (selection-position snd chan) 0)
	       (set! (selection-frames snd chan) (frames snd chan)))
	     chans)
	    (save-selection "test.snd")))))
  
  (define* (notch-out-rumble-and-hiss snd chn)
    "(notch-out-rumble-and-hiss s c) applies a bandpass filter with cutoffs at 40 Hz and 3500 Hz"
    (let* ((cur-srate (exact->inexact (srate snd))))
      (filter-sound
       (list 0.0 0.0                    ; get rid of DC
	     (/ 80.0 cur-srate) 0.0     ; get rid of anything under 40 Hz (1.0=srate/2 here)
	     (/ 90.0 cur-srate) 1.0     ; now the passband
	     (/ 7000.0 cur-srate) 1.0 
	     (/ 8000.0 cur-srate) 0.0   ; end passband (40..4000)
	     1.0 0.0)                   ; get rid of some of the hiss
       ;; since the minimum band is 10 Hz here, 
       ;;   cur-srate/10 rounded up to next power of 2 seems a safe filter size
       ;;   filter-sound will actually use overlap-add convolution in this case
       (expt 2 (ceiling (/ (log (/ cur-srate 10.0)) (log 2.0))))
       snd chn)))
  
  (define* (reverse-channels snd)
    (let* ((ind (or snd (selected-sound) (car (sounds))))
	   (chns (chans ind)))
      (let ((swaps (floor (/ chns 2))))
	(as-one-edit
	 (lambda ()
	   (do ((i 0 (+ 1 i))
		(j (- chns 1) (- j 1)))
	       ((= i swaps))
	     (swap-channels ind i ind j)))))))
  
  (define* (rotate-channel (samps 1) snd chn)
    (let* ((ind (or snd (selected-sound) (car (sounds))))
	   (chan (or chn (selected-channel) 0)))
      (let ((reg (make-region 0 (- samps 1) ind chan)))
	(as-one-edit
	 (lambda ()
	   (delete-samples 0 samps ind chan)
	   (insert-region reg (frames ind chan))))
	(forget-region reg))))
  
  (define (randomize-list lst)
    (let* ((len (length lst))
	   (vals (make-vector len #f))
	   (nlst '()))
      (do ((i 0 (+ 1 i)))
	  ((= i len))
	(let ((loc (random len)))
	  (if (vector-ref vals loc)
	      (do ((j 0 (+ 1 j)))
		  ((or (= j len) 
		       (not (vector-ref vals j)))
		   (vector-set! vals j (car lst))))
	      (vector-set! vals loc (car lst)))
	  (set! lst (cdr lst))))
      (do ((i 0 (+ 1 i)))
	  ((= i len))
	(set! nlst (cons (vector-ref vals i) nlst)))
      nlst))
  
  (define (check-error-tag expected-tag thunk)
    (let ((tag
	   (catch #t 
		  thunk
		  (lambda args args))))
      (if (or (and (not (list? tag))
		   (not (pair? tag)))
	      (not (eq? (car tag) expected-tag)))
	  (snd-display #__line__ ";check-error-tag ~A from ~A: ~A" 
		       expected-tag (procedure-source thunk) tag))))
  
  (set! (with-background-processes) #t)
  
  (load "s7test.scm")
  
  (if (and (provided? 'gsl)
	   (provided? 'gmp))
      (begin
	
	;; from GSL
	(num-test (bes-j0 0.1) 0.99750156206604003230) 
	(num-test (bes-j0 2.0) 0.22389077914123566805) 
	(num-test (bes-j0 100.0) 0.019985850304223122424) 
	(num-test (bes-j0 1.0e+10) 2.1755917502468917269e-06) 
	(num-test (bes-j1 0.1) 0.04993752603624199756) 
	(num-test (bes-j1 2.0) 0.57672480775687338720) 
	(num-test (bes-j1 100.0) -0.07714535201411215803) 
	(num-test (bes-j1 1.0e+10) -7.676508175684157103e-06) 
	(num-test (bes-jn 4 0.1) 2.6028648545684032338e-07) 
	(num-test (bes-jn 5 2.0) 0.007039629755871685484) 
	(num-test (bes-jn 10 20.0) 0.18648255802394508321) 
	(num-test (bes-jn 100 100.0) 0.09636667329586155967) 
	(num-test (bes-jn 2 900.0) -0.019974345269680646400) 
	(num-test (bes-jn 2 15000.0) -0.0020455820181216382666) 
	(num-test (bes-jn 0 1.0e+10) 2.1755917502468917269e-06) 
	(num-test (bes-jn 1 1.0e+10) -7.676508175684157103e-06) 
	(num-test (bes-jn 0 20000) 0.00556597490495494615709982972) 
	
	(num-test (bes-y0 0.1) -1.5342386513503668441) 
	(num-test (bes-y0 2)  0.5103756726497451196) 
	(num-test (bes-y0 256.0) -0.03381290171792454909) 
	(num-test (bes-y0 4294967296.0) 3.657903190017678681e-06) 
	(num-test (bes-y1 0.1) -6.45895109470202698800) 
	(num-test (bes-y1 2) -0.10703243154093754689) 
	(num-test (bes-y1 100.0) -0.020372312002759793305) 
	(num-test (bes-y1 4294967296.0) 0.000011612249378370766284) 
	(num-test (bes-yn 4 0.1)  -305832.29793353160319) 
	(num-test (bes-yn 5 2)  -9.935989128481974981) 
	(num-test (bes-yn 100 100.0) -0.16692141141757650654) 
	(num-test (bes-yn 100 4294967296.0) 3.657889671577715808e-06) 
	(num-test (bes-yn 1000 4294967296.0) 3.656551321485397501e-06) 
	(num-test (bes-yn 2 15000.0) -0.006185217273358617849) 
	
	(num-test (bes-i0 0.1) 1.0025015629340956014) 
	(num-test (bes-i0 2.0) 2.2795853023360672674) 
	(num-test (bes-i0 100.0) 1.0737517071310738235e+42) 
	(num-test (bes-i1 0.1) 0.05006252604709269211 ) 
	(num-test (bes-i1 2.0) 1.59063685463732906340 ) 
	(num-test (bes-i1 100.0) 1.0683693903381624812e+42) 
	(num-test (bes-in 4 0.1) 2.6054690212996573677e-07) 
	(num-test (bes-in 5 2.0) 0.009825679323131702321) 
	(num-test (bes-in 100 100.0) 4.641534941616199114e+21) 
	
	(num-test (bes-k0 0.1) 2.4270690247020166125) 
	(num-test (bes-k0 2.0) 0.11389387274953343565) 
	(num-test (bes-k0 100.0) 4.656628229175902019e-45) 
	(num-test (bes-k1 0.1) 9.853844780870606135 ) 
	(num-test (bes-k1 2.0) 0.13986588181652242728) 
	(num-test (bes-k1 100.0) 4.679853735636909287e-45) 
	(num-test (bes-kn 4 0.1) 479600.2497925682849) 
	(num-test (bes-kn 5 2.0) 9.431049100596467443) 
	(num-test (bes-kn 100 100.0) 7.617129630494085416e-25) 
	
	
	;; from maxima
	
	(num-test (bes-j0 0.0) 1.0)
	(num-test (bes-j0 0.001) .9999997500000155)
	(num-test (bes-j0 0.01) .9999750001562496)
	(num-test (bes-j0 0.1) .9975015620660401)
	(num-test (bes-j0 1.0) .7651976865579666)
	(num-test (bes-j0 10.0) -.24593576445134830)
	(num-test (bes-j0 100.0) .01998585030422355)
	(num-test (bes-j0 1000.0) .02478668615241997)
	(num-test (bes-j0 10000.0)  -.007096160353384438)
	
	(num-test (bes-j1 0.0) 0.0)
	(num-test (bes-j1 0.001) 4.9999993750000266E-4)
	(num-test (bes-j1 0.01) .004999937500260417)
	(num-test (bes-j1 0.1) 0.049937526036242)
	(num-test (bes-j1 1.0) .4400505857449335)
	(num-test (bes-j1 10.0) .04347274616886149)
	(num-test (bes-j1 100.0) -0.0771453520141124)
	(num-test (bes-j1 1000.0) .004728311907088393)
	(num-test (bes-j1 10000.0) .003647450755527218)
	
	(num-test (bes-jn 10 0.0) 0.0)
	(num-test (bes-jn 10 0.001) 2.691144394304978E-40)
	(num-test (bes-jn 10 0.01) 2.691138339236334E-30)
	(num-test (bes-jn 10 0.1) 2.690532895434216E-20)
	(num-test (bes-jn 10 1.0) 2.630615123687444E-10)
	(num-test (bes-jn 10 10.0) .2074861066333596)
	(num-test (bes-jn 10 100.0) -.05473217693547214)
	(num-test (bes-jn 10 1000.0) -.02452062230603636)
	(num-test (bes-jn 10 10000.0) .007114312383352328)
	
	(num-test (bes-jn 100 0.0) 0.0)
	(num-test (bes-jn 100 0.1) 8.45251653512169E-289)
	(num-test (bes-jn 100 1.0) 8.43182878962675E-189)
	(num-test (bes-jn 100 10.0) 6.597316064155484E-89)
	(num-test (bes-jn 100 100.0) 0.0963666732958616)
	(num-test (bes-jn 100 1000.0) .01167613500780332)
	(num-test (bes-jn 100 10000.0) -0.00797651631139348)
	
	(num-test (bes-jn 1000 1000.0) .04473067294796409)
	(num-test (bes-jn 10000 10000.0) .02076216527720082)
	
	
	(num-test (bes-i0 0.0) 1.0)
	(num-test (bes-i0 0.001) 1.000000250000016)
	(num-test (bes-i0 0.01) 1.00002500015625)
	(num-test (bes-i0 0.1) 1.002501562934096)
	(num-test (bes-i0 1.0) 1.266065877752009)
	(num-test (bes-i0 10.0) 2815.716628466254)
	(num-test (bes-i0 100.0) 1.073751707131074E+42)
	
	(num-test (bes-i1 0.0) 0.0)
	(num-test (bes-i1 0.001) 5.000000625000026E-4)
	(num-test (bes-i1 0.01) .005000062500260419)
	(num-test (bes-i1 0.1) .05006252604709269)
	(num-test (bes-i1 1.0) 0.565159103992485)
	(num-test (bes-i1 10.0) 2670.988303701255)
	(num-test (bes-i1 100.0) 1.068369390338162E+42)
	
	(num-test (bes-in 10 0.0) 0.0)
	(num-test (bes-in 10 0.001) 2.691144516629725E-40)
	(num-test (bes-in 10 0.01) 2.691150571711132E-30)
	(num-test (bes-in 10 0.1) 2.691756142922141E-20)
	(num-test (bes-in 10 1.0) 2.752948039836866E-10)
	(num-test (bes-in 10 10.0) 21.89170616372356)
	(num-test (bes-in 10 100.0) 6.498975524720151E+41)
	
	(num-test (bes-in 100 0.0) 0.0)
	(num-test (bes-in 100 0.1) 8.45293498689195E-289)
	(num-test (bes-in 100 1.0) 8.47367400813812E-189)
	(num-test (bes-in 100 10.0) 1.082344201749218E-88)
	(num-test (bes-in 100 100.0) 4.641534941616278E+21)
	
	
	
	(num-test (bes-y0 0.001) -4.471416611375923)
	(num-test (bes-y0 0.01) -3.005455637083646)
	(num-test (bes-y0 0.1) -1.534238651350367)
	(num-test (bes-y0 1.0) .08825696421567691)
	(num-test (bes-y0 10.0) .05567116728359947)
	(num-test (bes-y0 100.0) -.07724431336508303)
	(num-test (bes-y0 1000.0) .004715917977623911)
	
	(num-test (bes-y1 0.001) -636.6221672311393)
	(num-test (bes-y1 0.01) -63.67859628206064)
	(num-test (bes-y1 0.1) -6.458951094702027)
	(num-test (bes-y1 1.0) -.7812128213002888)
	(num-test (bes-y1 10.0) .2490154242069539)
	(num-test (bes-y1 100.0) -.02037231200275883)
	(num-test (bes-y1 1000.0) -0.024784331292352)
	
	(num-test (bes-yn 10 0.001) -1.182804937799041E+38)
	(num-test (bes-yn 10 0.01) -1.182808190517663E+28)
	(num-test (bes-yn 10 0.1) -1.18313351320452E+18)
	(num-test (bes-yn 10 1.0) -1.2161801427868918E+8)
	(num-test (bes-yn 10 10.0) -.3598141521834028)
	(num-test (bes-yn 10 100.0) .05833157423641527)
	(num-test (bes-yn 10 1000.0) -.005949000574163774)
	
	(num-test (bes-yn 100 0.1) -3.76586125601925E+285)
	(num-test (bes-yn 100 1.0) -3.77528781011053E+185)
	(num-test (bes-yn 100 10.0) -4.849148271180334E+85)
	(num-test (bes-yn 100 100.0) -.1669214114175733)
	(num-test (bes-yn 100 1000.0) -.02243868825772313)
	
	(num-test (bes-yn 1000 1000.0) -.07747600152069181)
	
	
	(num-test (bes-k0 0.001) 7.023688800562383)
	(num-test (bes-k0 0.01) 4.721244730161095)
	(num-test (bes-k0 0.1) 2.427069024702016)
	(num-test (bes-k0 1.0) .4210244382407085)
	(num-test (bes-k0 10.0) 1.7780062316167652E-5)
	(num-test (bes-k0 100.0) 4.656628229175902E-45)
	
	(num-test (bes-k1 0.001) 999.9962381560855)
	(num-test (bes-k1 0.01) 99.97389411829626)
	(num-test (bes-k1 0.1) 9.853844780870606)
	(num-test (bes-k1 1.0) .6019072301972346)
	(num-test (bes-k1 10.0) 1.8648773453825582E-5)
	(num-test (bes-k1 100.0) 4.67985373563691E-45)
	
	(num-test (bes-kn 10 0.001) 1.857945548390401E+38)
	(num-test (bes-kn 10 0.01) 1.857940439048065E+28)
	(num-test (bes-kn 10 0.1) 1.857429584630401E+18)
	(num-test (bes-kn 10 1.0) 1.807132899010295E+8)
	(num-test (bes-kn 10 10.0) 0.00161425530039067)
	(num-test (bes-kn 10 100.0) 7.655427977388101E-45)
	
	(num-test (bes-kn 100 0.1) 5.91510227809082E+285)
	(num-test (bes-kn 100 1.0) 5.90033318363862E+185)
	(num-test (bes-kn 100 10.0) 4.596674084269265E+85)
	(num-test (bes-kn 100 100.0) 7.617129630494247E-25)
	(num-test (bes-kn 100 1000.0) 0.0)
	))
  
  (if with-gui
      
      (let* ((delay-32 (make-delay 32))
	     (color-95 (make-color-with-catch .95 .95 .95))
	     (vector-0 (make-vector 0))
	     (vct-3 (make-vct 3))
	     (vct-5 (make-vct 5))
	     (car-main (if with-gui (car (main-widgets)) #f))
	     (cadr-main (if with-gui (cadr (main-widgets)) #f))
	     (sound-data-23 (make-sound-data 2 3))
	     (a-hook (make-hook 2))
	     (a-sound #f)
	     (exts (sound-file-extensions)) ; save across possible set below
	     
	     (procs (list 
		     add-mark add-sound-file-extension add-source-file-extension sound-file-extensions sound-file? 
		     add-to-main-menu add-to-menu add-transform amp-control
		     as-one-edit ask-before-overwrite audio-input-device audio-output-device ; add-player
		     auto-resize auto-update autocorrelate axis-color axis-info axis-label-font axis-numbers-font
		     basic-color bind-key bomb c-g? apply-controls change-samples-with-origin channel-style
		     channel-widgets channels chans peaks-font bold-peaks-font close-sound
		     color-cutoff color-orientation-dialog colormap-ref add-colormap delete-colormap colormap-size colormap-name colormap?
		     color-inverted color-scale color->list colormap color?  comment contrast-control contrast-control-amp
		     contrast-control? convolve-selection-with convolve-with channel-properties channel-property controls->channel
		     amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
		     reverb-control-length-bounds reverb-control-scale-bounds cursor-update-interval cursor-location-offset
		     auto-update-interval count-matches current-font cursor cursor-color with-tracking-cursor cursor-size
		     cursor-style tracking-cursor-style dac-combines-channels dac-size clipping data-color data-format data-location data-size
		     default-output-chans default-output-data-format default-output-srate default-output-header-type define-envelope
		     delete-mark delete-marks forget-region delete-sample delete-samples
		     delete-selection dialog-widgets display-edits dot-size draw-dot draw-dots draw-line
		     draw-lines draw-string edit-header-dialog edit-fragment edit-list->function edit-position edit-tree edits env-selection
		     env-sound enved-envelope enved-base enved-clip? enved-in-dB enved-dialog enved-style enved-power
		     enved-target enved-waveform-color enved-wave? eps-file eps-left-margin 
		     eps-bottom-margin eps-size expand-control expand-control-hop expand-control-jitter expand-control-length expand-control-ramp
		     expand-control? fft fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases transform-size disk-kspace
		     transform-graph-type fft-window transform-graph? view-files-dialog mix-file-dialog file-name fill-polygon
		     fill-rectangle filter-sound filter-control-in-dB filter-control-envelope enved-filter-order enved-filter
		     filter-control-in-hz filter-control-order filter-selection filter-channel filter-control-waveform-color filter-control? find-channel
		     find-mark find-sound finish-progress-report foreground-color insert-file-dialog file-write-date
		     frames free-sampler graph transform? delete-transform delete-watcher
		     graph-color graph-cursor graph-data graph->ps gl-graph->ps graph-style lisp-graph?  graphs-horizontal header-type
		     help-dialog info-dialog highlight-color insert-region insert-sample insert-samples
		     insert-samples-with-origin insert-selection insert-silence insert-sound just-sounds key key-binding
		     left-sample listener-color listener-font listener-prompt listener-selection listener-text-color
		     main-widgets make-color make-graph-data make-mix-sampler make-player make-region
		     make-region-sampler make-sampler map-chan mark-color mark-name mark-properties mark-property
		     mark-sample mark-sync mark-sync-max mark-home marks mark?  max-transform-peaks max-regions max-virtual-ptrees
		     maxamp maxamp-position menu-widgets minibuffer-history-length min-dB log-freq-start mix mixes mix-amp mix-amp-env
		     mix-color mix-length mix? view-mixes-dialog mix-position
		     mix-dialog-mix mix-name mix-sync-max mix-sync mix-properties mix-property 
		     mix-region mix-sampler?  mix-selection mix-sound mix-home mix-speed mix-tag-height mix-tag-width mark-tag-height mark-tag-width
		     mix-tag-y mix-vct mix-waveform-height time-graph-style lisp-graph-style transform-graph-style
					;new-sound in add-watcher
		     read-mix-sample next-sample read-region-sample
		     transform-normalization open-file-dialog-directory open-raw-sound open-sound previous-sample
		     peaks player? players
		     position-color position->x position->y add-directory-to-view-files-list add-file-to-view-files-list view-files-sort 
		     view-files-amp view-files-speed view-files-files view-files-selected-files view-files-speed-style view-files-amp-env
		     print-length progress-report prompt-in-minibuffer pushed-button-color read-only
		     redo region-chans view-regions-dialog region-home 
		     region-graph-style region-frames region-position region-maxamp region-maxamp-position 
		     selection-maxamp selection-maxamp-position region-sample region->vct clear-minibuffer
		     region-srate regions region?  remove-from-menu report-in-minibuffer reset-controls restore-controls
		     restore-region reverb-control-decay reverb-control-feedback 
		     reverb-control-length reverb-control-lowpass reverb-control-scale reverb-control?  reverse-sound
		     reverse-selection revert-sound right-sample sample sampler-at-end?  sampler? samples sampler-position
		     sash-color save-controls ladspa-dir peak-env-dir save-dir save-edit-history save-envelopes
		     save-listener save-marks save-region save-selection save-sound save-sound-as
		     save-state save-state-file scale-by scale-selection-by scale-selection-to scale-to
		     scan-chan search-procedure select-all select-channel select-sound
		     selected-channel selected-data-color selected-graph-color selected-sound
		     selection-position selection-color selection-creates-region selection-frames selection-member? selection?
		     short-file-name show-axes show-controls show-transform-peaks show-indices show-listener
		     show-marks show-mix-waveforms show-selection-transform show-y-zero sinc-width show-grid show-sonogram-cursor grid-density
		     smooth-sound smooth-selection snd-print snd-spectrum snd-tempnam snd-version sound-files-in-directory
		     sound-loop-info sound-widgets soundfont-info sound? sounds spectrum-end spectro-hop spectrum-start
		     spectro-x-angle spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale
		     speed-control speed-control-style speed-control-tones squelch-update srate src-sound src-selection
					;start-playing 
		     start-progress-report stop-player stop-playing swap-channels syncd-marks sync sync-max sound-properties sound-property temp-dir
		     text-focus-color tiny-font region-sampler? transform-dialog transform-sample
		     transform->vct transform-frames transform-type trap-segfault with-file-monitor optimization unbind-key undo
		     update-transform-graph update-time-graph update-lisp-graph update-sound clm-table-size clm-default-frequency
		     with-verbose-cursor view-sound wavelet-type with-inset-graph with-pointer-focus
		     time-graph?  time-graph-type wavo-hop wavo-trace window-height window-width window-x window-y
		     with-mix-tags with-relative-panes with-gl x-axis-style beats-per-measure
		     beats-per-minute x-bounds x-position-slider x->position x-zoom-slider mus-header-type->string mus-data-format->string
		     y-bounds y-position-slider y->position y-zoom-slider zero-pad zoom-color zoom-focus-style mus-set-formant-radius-and-frequency
		     mus-sound-samples mus-sound-frames mus-sound-duration mus-sound-datum-size mus-sound-data-location data-size
		     mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-data-format mus-sound-length
		     mus-sound-type-specifier mus-header-type-name mus-data-format-name mus-sound-comment mus-sound-write-date
		     mus-bytes-per-sample mus-sound-loop-info mus-sound-mark-info mus-audio-describe
					;mus-alsa-buffers mus-alsa-buffer-size mus-apply
		     mus-alsa-squelch-warning
					;mus-alsa-device mus-alsa-playback-device mus-alsa-capture-device 
		     mus-sound-maxamp mus-sound-maxamp-exists? 
					;mus-sound-open-input mus-sound-open-output
					;mus-sound-reopen-output mus-sound-close-input mus-sound-close-output mus-sound-read mus-sound-write
					;mus-sound-seek-frame 
		     mus-file-prescaler mus-prescaler mus-clipping mus-file-clipping mus-header-raw-defaults 
		     moving-average moving-average? make-moving-average
		     mus-expand-filename 
		     make-sound-data sound-data-ref sound-data-set! sound-data-scale! sound-data-fill! sound-data? sound-data-length
		     sound-data-multiply! sound-data-add! sound-data-offset! sound-data* sound-data+ sound-data-copy sound-data-reverse!
		     sound-data-maxamp sound-data-chans sound-data->vct vct->sound-data sound-data-peak
		     all-pass all-pass? amplitude-modulate
		     array->file array-interp mus-interpolate asymmetric-fm asymmetric-fm? sound-data->sound-data
		     clear-array comb comb? filtered-comb filtered-comb? contrast-enhancement convolution convolve convolve? db->linear degrees->radians
		     delay delay? dot-product env env-interp env? file->array file->frame file->frame?  file->sample
		     file->sample? filter filter? fir-filter fir-filter? formant formant-bank formant? frame* frame+ firmant firmant?
		     frame->file frame->file? frame->frame frame->list frame->sample frame-ref frame-set! frame?
		     granulate granulate? hz->radians iir-filter iir-filter? linear->db locsig ; in-any ina inb (sound-data arg troubles)
		     locsig-ref locsig-reverb-ref locsig-reverb-set! locsig-set!  locsig? make-all-pass make-asymmetric-fm
		     make-comb make-filtered-comb make-convolve make-delay make-env make-fft-window make-file->frame
		     make-file->sample make-filter make-fir-filter make-formant make-firmant frame make-frame make-frame->file make-granulate
		     make-iir-filter make-locsig move-locsig make-mixer make-notch make-one-pole make-one-zero make-oscil
		     make-pulse-train make-rand make-rand-interp make-readin make-sample->file make-sawtooth-wave
		     make-nrxysin make-nrxycos make-square-wave make-src make-ncos 
		     make-nsin make-ssb-am make-table-lookup make-triangle-wave
		     make-two-pole make-two-zero make-wave-train mixer mixer* mixer-ref mixer-set! mixer? mixer+
		     move-sound make-move-sound move-sound? mus-float-equal-fudge-factor
		     multiply-arrays mus-array-print-length mus-channel mus-channels make-polyshape polyshape polyshape? make-polywave polywave polywave?
		     mus-close mus-data mus-feedback mus-feedforward mus-fft mus-frequency
		     mus-hop mus-increment mus-input? mus-file-name mus-length mus-location mus-mix mus-order mus-output?  mus-phase
		     mus-ramp mus-random mus-scaler mus-srate mus-xcoeff mus-xcoeffs mus-ycoeff mus-ycoeffs notch notch? one-pole one-pole?
		     one-zero one-zero? oscil oscil? out-any outa outb outc outd partials->polynomial normalize-partials
		     partials->wave phase-partials->wave polynomial pulse-train pulse-train?
		     radians->degrees radians->hz rand rand-interp rand-interp?  rand? readin readin? rectangular->polar rectangular->magnitudes
		     ring-modulate sample->file sample->file? sample->frame sawtooth-wave
		     sawtooth-wave? nrxysin nrxysin? nrxycos nrxycos?
		     spectrum square-wave square-wave? src src? ncos nsin ssb-am
		     ncos? nsin? ssb-am? table-lookup table-lookup? tap triangle-wave triangle-wave? two-pole two-pole? two-zero
		     two-zero? wave-train wave-train?  make-vct vct-add! vct-subtract!  vct-copy
		     vct-length vct-multiply! vct-offset! vct-ref vct-scale! vct-fill! vct-set! vct-peak
		     vct? list->vct vct->list vector->vct vct->vector vct-move! vct-reverse! vct-subseq vct little-endian? vct->string
		     clm-channel env-channel env-channel-with-base map-channel scan-channel
		     reverse-channel seconds->samples samples->seconds
		     smooth-channel vct->channel channel->vct src-channel scale-channel ramp-channel pad-channel normalize-channel
		     cursor-position clear-listener mus-sound-prune mus-sound-forget xramp-channel ptree-channel
		     snd->sample snd->sample? make-snd->sample make-scalar-mixer
		     
		     beats-per-minute beats-per-measure channel-amp-envs convolve-files filter-control-coeffs 
		     locsig-type make-phase-vocoder 
		     mus-describe mus-error-type->string mus-file-buffer-size mus-name mus-offset mus-out-format mus-reset
		     mus-rand-seed mus-width phase-vocoder?
		     polar->rectangular phase-vocoder-amp-increments phase-vocoder-amps phase-vocoder-freqs
		     phase-vocoder-phase-increments phase-vocoder-phases mus-generator?
		     
		     read-sample reset-listener-cursor goto-listener-end sampler-home selection-chans selection-srate snd-gcs snd-font snd-color
		     snd-warning channel-data x-axis-label variable-graph? y-axis-label
		     snd-url snd-urls free-player
		     quit-button-color help-button-color reset-button-color doit-button-color doit-again-button-color
		     
		     delay-tick playing pausing draw-axes copy-sampler html-dir html-program
		     make-fir-coeffs mus-interp-type mus-run phase-vocoder
		     player-home redo-edit undo-edit widget-position widget-size 
		     focus-widget 
		     ))
	     
	     (set-procs (list 
			 amp-control ask-before-overwrite audio-input-device audio-output-device auto-resize
			 auto-update axis-color axis-label-font axis-numbers-font ;basic-color 
			 channel-style peaks-font bold-peaks-font sound-file-extensions
			 color-cutoff color-inverted color-scale contrast-control contrast-control-amp 
			 amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
			 reverb-control-length-bounds reverb-control-scale-bounds cursor-update-interval cursor-location-offset
			 contrast-control? auto-update-interval current-font cursor cursor-color channel-properties channel-property 
			 with-tracking-cursor cursor-size cursor-style tracking-cursor-style dac-combines-channels dac-size clipping data-color
			 default-output-chans default-output-data-format default-output-srate default-output-header-type dot-size
			 enved-envelope enved-base enved-clip? enved-in-dB enved-style enved-power
			 enved-target enved-waveform-color enved-wave? eps-file eps-left-margin eps-bottom-margin eps-size
			 expand-control expand-control-hop expand-control-jitter expand-control-length expand-control-ramp expand-control?
			 fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases transform-size transform-graph-type fft-window
			 transform-graph? filter-control-in-dB filter-control-envelope enved-filter-order enved-filter 
			 filter-control-in-hz filter-control-order filter-control-waveform-color filter-control?  foreground-color
			 graph-color graph-cursor graph-style lisp-graph? graphs-horizontal highlight-color
			 just-sounds left-sample listener-color listener-font listener-prompt listener-text-color mark-color
			 mark-name mark-properties mark-property mark-sample mark-sync max-transform-peaks max-regions min-dB log-freq-start mix-amp
			 mix-amp-env mix-color mix-name mix-position mix-sync mix-properties mix-property max-virtual-ptrees
			 mix-speed mix-tag-height mix-tag-width mix-tag-y mark-tag-width mark-tag-height 
			 mix-waveform-height transform-normalization open-file-dialog-directory
			 position-color view-files-sort print-length pushed-button-color
			 view-files-amp view-files-speed view-files-speed-style view-files-amp-env
			 view-files-files view-files-selected-files 
			 region-graph-style reverb-control-decay reverb-control-feedback
			 reverb-control-length reverb-control-lowpass reverb-control-scale time-graph-style lisp-graph-style transform-graph-style
			 reverb-control? sash-color ladspa-dir peak-env-dir save-dir save-state-file selected-data-color selected-graph-color
			 selection-color selection-creates-region show-axes show-controls
			 show-transform-peaks show-indices show-marks show-mix-waveforms show-selection-transform show-listener
			 show-y-zero show-grid show-sonogram-cursor sinc-width spectrum-end spectro-hop spectrum-start spectro-x-angle  grid-density
			 spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale speed-control
			 speed-control-style speed-control-tones squelch-update sync sound-properties sound-property temp-dir text-focus-color tiny-font y-bounds
			 transform-type trap-segfault with-file-monitor optimization with-verbose-cursor with-inset-graph with-pointer-focus wavelet-type x-bounds
			 time-graph? wavo-hop wavo-trace with-gl with-mix-tags x-axis-style beats-per-minute zero-pad zoom-color zoom-focus-style 
			 with-relative-panes  window-x window-y window-width window-height mix-dialog-mix beats-per-measure
			 channels chans colormap comment data-format data-location data-size edit-position frames header-type maxamp
			 minibuffer-history-length read-only right-sample sample samples selected-channel colormap-size colormap?
			 selected-sound selection-position selection-frames selection-member? sound-loop-info
			 srate time-graph-type x-position-slider x-zoom-slider
			 y-position-slider y-zoom-slider sound-data-ref mus-array-print-length mus-float-equal-fudge-factor
					;mus-data 
			 mus-feedback mus-feedforward mus-frequency mus-hop
			 mus-increment mus-length mus-location mus-name mus-phase mus-ramp mus-scaler vct-ref x-axis-label
			 filter-control-coeffs locsig-type mus-file-buffer-size 
			 mus-rand-seed mus-width clm-table-size clm-default-frequency mus-offset mus-reset
			 phase-vocoder-amp-increments phase-vocoder-amps 
			 phase-vocoder-freqs phase-vocoder-phase-increments phase-vocoder-phases 
			 quit-button-color help-button-color reset-button-color doit-button-color doit-again-button-color
			 html-dir html-program mus-interp-type widget-position widget-size 
			 mixer-ref frame-ref locsig-ref locsig-reverb-ref
			 mus-file-prescaler mus-prescaler mus-clipping mus-file-clipping mus-header-raw-defaults
			 ))
	     
	     (make-procs (list
			  make-all-pass make-asymmetric-fm make-snd->sample make-moving-average
			  make-comb make-filtered-comb make-convolve make-delay make-env make-fft-window make-file->frame
			  make-file->sample make-filter make-fir-filter make-formant make-firmant make-frame make-frame->file make-granulate
			  make-iir-filter make-locsig make-mixer make-notch make-one-pole make-one-zero make-oscil
			  make-pulse-train make-rand make-rand-interp make-readin make-sample->file make-sawtooth-wave
			  make-nrxysin make-nrxycos make-square-wave 
			  make-src make-ncos make-nsin make-table-lookup make-triangle-wave
			  make-two-pole make-two-zero make-wave-train make-phase-vocoder make-ssb-am make-polyshape make-polywave
			  make-color make-player make-region make-scalar-mixer
			  ))
	     
	     (keyargs
	      (list 
	       :frequency :initial-phase :wave :cosines :amplitude :ratio :size :a0 :a1 :a2 :b1 :b2 :input 
	       :srate :file :channel :start :initial-contents :initial-element :scaler :feedforward :feedback 
	       :max-size :radius :gain :partials :r :a :n :fill-time :order :xcoeffs :ycoeffs :envelope 
	       :base :duration :offset :end :direction :degree :distance :reverb :output :fft-size :expansion 
	       :length :hop :ramp :jitter :type :format :comment :channels :filter :revout :width :edit 
	       :synthesize :analyze :interp :overlap :pitch :distribution :sines :dur))
	     
	     (procs0 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 0)))) procs))
	     (set-procs0 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 1)))) set-procs))
	     (procs1 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 1)))) procs))
	     (set-procs1 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 2)))) set-procs))
	     (procs2 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 2)))) procs))
	     (set-procs2 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 3)))) set-procs))
	     (procs3 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 3)))) procs))
	     (set-procs3 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 4)))) set-procs))
	     (procs4 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 4)))) procs))
	     (set-procs4 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 5)))) set-procs))
	     (procs5 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 5)))) procs))
	     (procs6 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 6)))) procs))
	     (procs7 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 7)))) procs))
	     (procs8 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 8)))) procs))
	     (procs10 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 10)))) procs))
	     
	     (already-warned '("mus-length" "mus-data" "hz->radians" "mus-order" "mus-xcoeffs" "mus-ycoeffs"
			       "list->vct" "vct" "formant-bank"
			       ))
	     )
	#|
	(for-each 
	(lambda (n)
	(if (and (not (member n procs0))
	(not (member n procs1))
	(not (member n procs2))
	(not (member n procs3))
	(not (member n procs4))
	(not (member n procs5))
	(not (member n procs6))
	(not (member n procs8))
	(not (member n procs10)))
	(snd-display #__line__ ";not in any list: ~A" n)))
	procs)
	
	(for-each 
	(lambda (n)
	(if (and (not (member n set-procs0))
	(not (member n set-procs1))
	(not (member n set-procs2))
	(not (member n set-procs3))
	(not (member n set-procs4)))
	(snd-display #__line__ ";not in any set list: ~A" n)))
	set-procs)
	|#	
	(if all-args
	    (snd-display #__line__ ";procs 0: ~A ~A, 1: ~A ~A, 2: ~A ~A, 3: ~A ~A, 4: ~A ~A, 5: ~A, 6: ~A, 7: ~A, 8: ~A, 10: ~A"
			 (length procs0) (length set-procs0) 
			 (length procs1) (length set-procs1) 
			 (length procs2) (length set-procs2) 
			 (length procs3) (length set-procs3) 
			 (length procs4) (length set-procs4) 
			 (length procs5) (length procs6) (length procs7) (length procs8) (length procs10)))
	
	(reset-almost-all-hooks)
	
	(do ((test-28 0 (+ 1 test-28)))
	    ((= test-28 tests))
	  (log-mem test-28)
	  
	  (if (= test-28 1)
	      (begin
		(set! delay-32 (make-oscil 440))
		(set! color-95 (vector 1 2 3))
		(set! vector-0 (make-comb .1 3))
		(set! vct-3 (make-notch .1 101))
		(set! car-main (make-all-pass .4 .5 2))
		(set! cadr-main (make-table-lookup 101))
		(set! sound-data-23 (make-square-wave 440))
		(set! a-hook (make-triangle-wave 220)))
	      (if (= test-28 2)
		  (begin
		    (set! delay-32 (make-sawtooth-wave 440))
		    (set! color-95 123+123i)
		    (set! vector-0 (make-rand 100))
		    (set! vct-3 (make-rand-interp 100))
		    (set! car-main (make-asymmetric-fm 100))
		    (set! sound-data-23 (make-one-zero .1 .1))
		    (set! a-hook (make-one-pole .1 .1)))
		  (if (= test-28 3)
		      (begin
			(set! delay-32 (make-two-zero .5 .5 .1))
			(set! color-95 (list 1 2 3))
			(set! vector-0 (make-formant 100 .1))
			(set! vct-3 (make-polyshape :frequency 300 :partials '(1 1 2 1)))
			(set! car-main (make-oscil))
			(set! cadr-main (vector 1 2 3))
			(set! sound-data-23 (make-wave-train 100))
			(set! a-hook (make-frame 2 .2 .1)))
		      (if (= test-28 4)
			  (begin
			    (set! delay-32 (make-filter 3 (vct 3 1 2 3) (vct 3 1 2 3)))
			    (set! color-95 (make-sound-data 2 1))
			    (set! vector-0 (make-iir-filter 3 (vct 1 2 3)))
			    (set! vct-3 (make-ncos))
			    (set! car-main (make-env '(0 0 1 1) :length 101))
			    (set! cadr-main (make-nsin 100 4))
			    (set! sound-data-23 (make-ssb-am 440))
			    (set! a-hook (make-nsin 100 3)))
			  (if (= test-28 5)
			      (begin
				(set! delay-32 '(1 2))
				(set! color-95 (make-color-with-catch .9 .9 .9))
				(set! vector-0 (make-vector 1))
				(set! car-main (make-moving-average 3))
				(set! cadr-main (make-oscil 440))
				(set! a-hook (make-mixer 2 .1 .2 .1 .2))
				))))))
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n (integer->sound 123)))
				    (lambda args (car args)))))
			(if (not (eq? tag 'no-such-sound))
			    (snd-display #__line__ ";snd no-such-sound ~A: ~A" n tag))))
		    (list amp-control apply-controls channels chans comment contrast-control 
			  amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
			  reverb-control-length-bounds reverb-control-scale-bounds
			  contrast-control-amp contrast-control? data-format data-location data-size 
			  expand-control expand-control-hop expand-control-jitter
			  expand-control-length expand-control-ramp expand-control? file-name filter-control-in-dB filter-control-in-hz
			  filter-control-envelope filter-control-order filter-control?  finish-progress-report frames header-type
			  progress-report read-only reset-controls restore-controls reverb-control-decay reverb-control-feedback
			  reverb-control-length reverb-control-lowpass reverb-control-scale reverb-control? save-controls
			  select-sound short-file-name sound-loop-info soundfont-info speed-control speed-control-style
			  speed-control-tones srate channel-style start-progress-report sync sound-properties sound-property swap-channels))
	  
	  (for-each (lambda (arg)
		      (for-each (lambda (n)
				  (let ((tag
					 (catch #t
						(lambda ()
						  (n arg))
						(lambda args (car args)))))
				    (if (and (not (eq? tag 'wrong-type-arg))
					     (not (eq? tag 'mus-error)))
					(snd-display #__line__ ";snd wrong-type-arg ~A: ~A ~A" n tag arg))))
				(list amp-control bomb apply-controls close-sound comment contrast-control 
				      amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
				      reverb-control-length-bounds reverb-control-scale-bounds
				      contrast-control-amp contrast-control? data-format data-location data-size expand-control
				      expand-control-hop expand-control-jitter expand-control-length expand-control-ramp expand-control?
				      filter-control-in-dB filter-control-in-hz filter-control-envelope filter-control-order filter-control?
				      finish-progress-report header-type read-only reset-controls restore-controls
				      reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-lowpass
				      reverb-control-scale reverb-control? save-controls select-sound short-file-name
				      sound-loop-info soundfont-info speed-control speed-control-style speed-control-tones srate
				      channel-style start-progress-report sync sound-properties swap-channels)))
		    (list vct-5 (sqrt -1.0) 1.5 "hiho" delay-32))
	  
	  (for-each (lambda (arg)
		      (let ((ctr 0))
			(for-each (lambda (n)
				    (let ((tag
					   (catch #t
						  (lambda ()
						    (set! (n arg) 0))
						  (lambda args (car args)))))
				      (if (and (not (eq? tag 'wrong-type-arg))
					       (not (eq? tag 'syntax-error))
					       (not (eq? tag 'error)))
					  (snd-display #__line__ ";snd set wrong-type-arg ~D: ~A: ~A ~A" ctr n tag arg))
				      (set! ctr (+ ctr 1))))
				  (list amp-control channels chans comment contrast-control contrast-control-amp 
					amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
					reverb-control-length-bounds reverb-control-scale-bounds
					contrast-control? data-format data-location data-size expand-control expand-control-hop expand-control-jitter
					expand-control-length expand-control-ramp expand-control? filter-control-in-dB filter-control-in-hz
					filter-control-envelope filter-control-order filter-control? frames header-type read-only
					reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-lowpass
					reverb-control-scale reverb-control? sound-loop-info soundfont-info speed-control
					speed-control-style speed-control-tones srate channel-style sync))))
		    (list vct-5 (sqrt -1.0) 1.5 "hiho" delay-32))
	  
	  (let ((index (open-sound "obtest.snd")))
	    (for-each (lambda (arg)
			(let ((ctr 0))
			  (for-each (lambda (n)
				      (let ((tag
					     (catch #t
						    (lambda ()
						      (set! (n index) arg))
						    (lambda args (car args)))))
					(if (not (eq? tag 'wrong-type-arg))
					    (snd-display #__line__ ";snd safe set wrong-type-arg ~A: ~A ~A ~A" ctr n tag arg))
					(set! ctr (+ ctr 1))))
				    (list amp-control contrast-control contrast-control-amp contrast-control? expand-control 
					  amp-control-bounds speed-control-bounds expand-control-bounds contrast-control-bounds
					  reverb-control-length-bounds reverb-control-scale-bounds
					  expand-control-hop expand-control-jitter expand-control-length expand-control-ramp expand-control?
					  filter-control-in-dB filter-control-in-hz filter-control-envelope filter-control-order filter-control?
					  reverb-control-decay reverb-control-feedback reverb-control-length reverb-control-lowpass
					  reverb-control-scale reverb-control? speed-control speed-control-style speed-control-tones
					  channel-style sync))))
		      (list vct-5 (sqrt -1.0) "hiho" delay-32))
	    (close-sound index))
	  
	  (for-each (lambda (arg)
		      (for-each (lambda (n)
				  (let ((tag
					 (catch #t
						(lambda ()
						  (n arg))
						(lambda args (car args)))))
				    (if (not (eq? tag 'wrong-type-arg))
					(snd-display #__line__ ";vct 0 wrong-type-arg ~A: ~A ~A" n tag arg))))
				(list make-vct vct-copy vct-length vct->list vct-peak)))
		    (list (make-vector 1) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1) delay-32))
	  
	  (for-each (lambda (arg1)
		      (for-each (lambda (arg2)
				  (for-each (lambda (n)
					      (let ((tag
						     (catch #t
							    (lambda ()
							      (n arg1 arg2))
							    (lambda args (car args)))))
						(if (not (or (eq? tag 'wrong-type-arg)
							     (eq? tag 'wrong-number-of-args)
							     (eq? tag 'mus-error)))
						    (snd-display #__line__ ";vct 1 wrong-whatever ~A: ~A ~A ~A" n tag arg1 arg2))))
					    (list vct-add! vct-subtract! vct-multiply! vct-ref vct-scale! vct-fill!)))
				(list vct-5 "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1) delay-32)))
		    (list (make-vector 1) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1) delay-32))
	  
	  (for-each (lambda (arg)
		      (for-each (lambda (n)
				  (let ((tag
					 (catch #t
						(lambda ()
						  (n vct-3 arg))
						(lambda args (car args)))))
				    (if (not (eq? tag 'wrong-type-arg))
					(snd-display #__line__ ";vct 2 wrong-type-arg ~A: ~A" n tag))))
				(list vct-add! vct-subtract! vct-multiply! vct-ref vct-scale! vct-fill!)))
		    (list (make-vector 1) "hiho" (sqrt -1.0) (list 1 0) '#(0 1) delay-32))
	  
	  (let ((tag
		 (catch #t
			(lambda ()
			  (make-vct -23))
			(lambda args (car args)))))
	    (if (not (eq? tag 'out-of-range))
		(snd-display #__line__ ";make-vct -23: ~A" tag)))
	  
	  (let* ((v vct-3))
	    (let ((tag
		   (catch #t
			  (lambda ()
			    (vct-ref v 12))
			  (lambda args (car args)))))
	      (if (not (eq? tag 'out-of-range))
		  (snd-display #__line__ ";vct[12]: ~A" tag))))
	  
	  (for-each (lambda (arg)
		      (for-each (lambda (n)
				  (let ((tag
					 (catch #t
						(lambda ()
						  (n arg))
						(lambda args (car args)))))
				    (if tag
					(snd-display #__line__ ";?proc ~A: ~A" n tag))))
				(list all-pass? asymmetric-fm? comb? filtered-comb? convolve? delay? env? file->frame? file->sample? snd->sample?
				      filter? fir-filter? formant? firmant? frame->file? frame? granulate? iir-filter? locsig? mixer? move-sound? mus-input? 
				      mus-output? notch? one-pole? one-zero? oscil? phase-vocoder? pulse-train? rand-interp? rand? readin? 
				      sample->file? sawtooth-wave? nrxysin? nrxycos?
				      square-wave? src? ncos? nsin? table-lookup? 
				      triangle-wave? two-pole? two-zero? wave-train? color? mix-sampler? moving-average? ssb-am?
				      sampler? region-sampler? vct? )))
		    (list (make-vector 1) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1)))
	  
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n (make-oscil 440)))
				    (lambda args (car args)))))
			(if tag
			    (snd-display #__line__ ";oscil?proc ~A: ~A" n tag))))
		    (list all-pass? asymmetric-fm? comb? filtered-comb? convolve? delay? env? file->frame? file->sample? snd->sample?
			  filter? fir-filter? formant? firmant? frame->file? frame? granulate? iir-filter? locsig? mixer? move-sound? mus-input? 
			  mus-output? notch? one-pole? one-zero? phase-vocoder? pulse-train? rand-interp? rand? readin? 
			  sample->file? sawtooth-wave? nrxysin? nrxycos?
			  square-wave? src? ncos? nsin? table-lookup? 
			  triangle-wave? two-pole? two-zero? wave-train? sound? color? mix-sampler? moving-average? ssb-am?
			  sampler? region-sampler? vct?))
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n))
				    (lambda args (car args)))))
			(if (not (eq? tag 'no-active-selection))
			    (snd-display #__line__ ";selection ~A: ~A" n tag))))
		    (list reverse-selection selection-position selection-frames smooth-selection
			  scale-selection-to insert-selection delete-selection mix-selection))
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n 0.0))
				    (lambda args (car args)))))
			(if (not (eq? tag 'no-active-selection))
			    (snd-display #__line__ ";selection ~A: ~A" n tag))))
		    (list src-selection filter-selection env-selection))
	  
	  (for-each (lambda (arg)
		      (let ((ctr 0))
			(for-each (lambda (n)
				    (let ((tag
					   (catch #t
						  (lambda ()
						    (n arg))
						  (lambda args (car args)))))
				      (if (and (not (eq? tag 'wrong-type-arg))
					       (not (eq? tag 'no-data))
					       (not (eq? tag 'no-such-method))
					       (not (eq? tag 'bad-type))
					       (not (eq? tag 'error))
					       (not (eq? tag 'arg-error)))
					  (snd-display #__line__ ";clm ~A: tag: ~A arg: ~A [~A]" n tag arg ctr))
				      (set! ctr (+ 1 ctr))))
				  (list all-pass asymmetric-fm clear-array comb filtered-comb convolve db->linear moving-average
					degrees->radians delay env formant firmant frame->list granulate hz->radians linear->db
					make-all-pass make-asymmetric-fm make-comb make-filtered-comb make-convolve make-delay make-env
					make-file->frame make-file->sample make-filter make-fir-filter make-formant make-firmant make-frame
					make-granulate make-iir-filter make-locsig make-notch make-one-pole make-one-zero
					make-oscil make-pulse-train make-rand make-rand-interp make-readin
					make-sawtooth-wave make-nrxysin make-nrxycos make-square-wave make-src 
					make-ncos make-nsin
					make-table-lookup make-triangle-wave make-two-pole make-two-zero make-wave-train make-ssb-am
					mus-channel mus-channels make-polyshape make-polywave
					mus-data mus-feedback mus-feedforward mus-frequency mus-hop
					mus-increment mus-length mus-file-name mus-location mus-name mus-order mus-phase mus-ramp mus-random mus-run
					mus-scaler mus-xcoeffs mus-ycoeffs notch one-pole one-zero make-moving-average seconds->samples samples->seconds
					oscil partials->polynomial partials->wave phase-partials->wave
					phase-vocoder pulse-train radians->degrees radians->hz rand rand-interp readin
					sawtooth-wave nrxysin nrxycos square-wave src 
					ncos nsin table-lookup tap triangle-wave
					two-pole two-zero wave-train ssb-am))))
		    (list (make-vector 1) color-95 (sqrt -1.0) (list 1.0)))
	  
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n (make-oscil) vct-5)
				      )
				    (lambda args (car args)))))
			(if (not (or (eq? tag 'wrong-type-arg)
				     (eq? tag 'bad-arity)
				     (eq? tag 'error)
				     (eq? tag 'mus-error)))
			    (snd-display #__line__ ";clm-1 ~A: ~A" n tag))))
		    (list all-pass array-interp asymmetric-fm comb filtered-comb contrast-enhancement convolution convolve moving-average
			  convolve-files delay dot-product env-interp file->frame file->sample snd->sample filter fir-filter formant firmant
			  formant-bank frame* frame+ frame->frame frame-ref frame->sample granulate iir-filter ina
			  inb locsig-ref locsig-reverb-ref make-all-pass make-asymmetric-fm make-comb make-filtered-comb
			  make-delay make-env make-fft-window make-filter make-fir-filter make-formant make-firmant make-frame make-granulate
			  make-iir-filter make-locsig make-notch make-one-pole make-one-zero make-oscil make-phase-vocoder
			  make-pulse-train make-rand make-rand-interp make-readin make-sawtooth-wave make-moving-average
			  make-nrxysin make-nrxycos make-square-wave make-src make-ncos 
			  make-nsin make-table-lookup make-triangle-wave
			  make-two-pole make-two-zero make-wave-train mixer* mixer+ multiply-arrays
			  notch one-pole one-zero oscil partials->polynomial partials->wave make-polyshape make-polywave
			  phase-partials->wave phase-vocoder polynomial pulse-train rand rand-interp rectangular->polar rectangular->magnitudes
			  ring-modulate sample->frame sawtooth-wave nrxysin nrxycos square-wave src ncos nsin
			  table-lookup tap triangle-wave two-pole two-zero wave-train ssb-am make-ssb-am))
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (set! (n (make-oscil)) vector-0))
				    (lambda args (car args)))))
			(if (and (not (eq? tag 'wrong-type-arg))
				 (not (eq? tag 'syntax-error))
				 (not (eq? tag 'error)))
			    (snd-display #__line__ ";mus-gen ~A: ~A" n tag))))
		    (list mus-channel mus-channels mus-data
			  mus-feedback mus-feedforward mus-frequency mus-hop mus-increment mus-length
			  mus-location mus-mix mus-name mus-order mus-phase mus-ramp mus-random mus-run mus-scaler mus-xcoeffs
			  mus-ycoeffs))
	  
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n vct-5))
				    (lambda args (car args)))))
			(if (not (eq? tag 'wrong-type-arg))
			    (snd-display #__line__ ";mus-sound ~A: ~A" n tag))))
		    (list mus-sound-samples mus-sound-frames mus-sound-duration mus-sound-datum-size
			  mus-sound-data-location mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-data-format
			  mus-sound-length mus-sound-type-specifier mus-header-type-name mus-data-format-name mus-sound-comment
			  mus-sound-write-date mus-bytes-per-sample mus-sound-loop-info mus-sound-mark-info mus-sound-maxamp
			  mus-sound-maxamp-exists? mus-header-type->string mus-data-format->string))
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n))
				    (lambda args (car args)))))
			(if (and (not (eq? tag 'wrong-number-of-args))
				 (not (eq? tag 'error)))
			    (snd-display #__line__ ";no arg mus-sound ~A: ~A" n tag))))
		    (list mus-sound-samples mus-sound-frames mus-sound-duration mus-sound-datum-size
			  mus-sound-data-location mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-data-format
			  mus-sound-length mus-sound-type-specifier mus-header-type-name mus-data-format-name mus-sound-comment
			  mus-sound-write-date mus-bytes-per-sample mus-sound-loop-info mus-sound-mark-info mus-sound-maxamp
			  mus-sound-maxamp-exists? mus-header-type->string mus-data-format->string))
	  
	  (for-each (lambda (n)
		      (let ((tag
			     (catch #t
				    (lambda ()
				      (n "/bad/baddy"))
				    (lambda args (car args)))))
			(if (not (eq? tag 'mus-error))
			    (snd-display #__line__ ";bad file mus-sound ~A: ~A" n tag))))
		    (list mus-sound-samples mus-sound-frames mus-sound-duration mus-sound-datum-size
			  mus-sound-data-location mus-sound-chans mus-sound-srate mus-sound-header-type mus-sound-data-format
			  mus-sound-length mus-sound-type-specifier mus-sound-comment mus-sound-write-date mus-sound-maxamp
			  mus-sound-maxamp-exists?))
	  (mus-sound-forget "/bad/baddy") ; for possible second time around
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n vct-5))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'wrong-type-arg))
				   (not (eq? tag 'error))
				   (not (eq? tag 'no-such-sound)))
			      (snd-display #__line__ ";~D: chn (no snd) procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list channel-widgets count-matches cursor channel-properties channel-property 
			    with-tracking-cursor cursor-position cursor-size cursor-style tracking-cursor-style delete-sample display-edits dot-size
			    draw-dots draw-lines edit-fragment edit-position edit-tree edits fft-window-alpha fft-window-beta fft-log-frequency
			    fft-log-magnitude fft-with-phases transform-size transform-graph-type fft-window transform-graph? find-channel
			    graph graph-style lisp-graph? (lambda (a) (insert-region 0 a)) insert-sound
			    time-graph-style lisp-graph-style transform-graph-style
			    left-sample make-graph-data map-chan max-transform-peaks maxamp-position min-dB mix-region
			    transform-normalization peaks ;play
			    position->x position->y reverse-sound
			    revert-sound right-sample sample save-sound save-sound-as scan-chan
			    select-channel show-axes show-transform-peaks show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor
			    spectrum-end spectro-hop spectrum-start spectro-x-angle spectro-x-scale spectro-y-angle  grid-density
			    spectro-y-scale spectro-z-angle spectro-z-scale squelch-update transform-sample
			    transform->vct transform-frames transform-type update-transform-graph update-time-graph
			    update-lisp-graph update-sound wavelet-type time-graph? time-graph-type wavo-hop wavo-trace x-bounds
			    x-position-slider x-zoom-slider x-axis-label y-axis-label y-bounds y-position-slider y-zoom-slider zero-pad))
	    )
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n 0 vct-5))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display #__line__ ";~D: chn (no chn) procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list channel-widgets count-matches cursor channel-properties channel-property 
			    cursor-position cursor-size cursor-style tracking-cursor-style delete-sample display-edits dot-size draw-dots draw-lines
			    edit-fragment edit-position edit-tree edits fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases
			    transform-size transform-graph-type fft-window transform-graph? find-channel
			    graph graph-style lisp-graph? insert-region insert-sound left-sample
			    time-graph-style lisp-graph-style transform-graph-style
			    make-graph-data map-chan max-transform-peaks maxamp maxamp-position min-dB mix-region transform-normalization
			    peaks play position->x position->y reverse-sound right-sample sample
			    save-sound-as scan-chan show-axes show-transform-peaks show-marks
			    show-mix-waveforms show-y-zero show-grid show-sonogram-cursor 
			    spectrum-end spectro-hop spectrum-start spectro-x-angle
			    spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale squelch-update  grid-density
			    transform-sample transform->vct transform-frames transform-type
			    update-transform-graph update-time-graph update-lisp-graph wavelet-type time-graph? time-graph-type
			    wavo-hop wavo-trace x-bounds x-position-slider x-zoom-slider x-axis-label y-axis-label y-bounds y-position-slider
			    y-zoom-slider zero-pad)))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (integer->sound 1234)))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-sound))
			      (snd-display #__line__ ";~D: chn procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list channel-widgets cursor with-tracking-cursor channel-properties
			    cursor-position cursor-size cursor-style tracking-cursor-style 
			    (lambda (snd) (delete-sample 0 snd)) display-edits dot-size 
			    (lambda (snd) (edit-fragment 0 snd))
			    edit-position edit-tree edits env-sound fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases
			    transform-size transform-graph-type fft-window transform-graph? filter-sound
			    graph-data graph-style lisp-graph? left-sample
			    time-graph-style lisp-graph-style transform-graph-style
			    make-graph-data max-transform-peaks maxamp maxamp-position min-dB transform-normalization
			    (lambda (snd) (position->x 0 snd))
			    (lambda (snd) (position->y 0 snd))
			    (lambda (snd) (redo 1 snd)) reverse-sound revert-sound right-sample 
			    (lambda (snd) (sample 0 snd))
			    save-sound scale-by scale-to show-axes show-transform-peaks
			    show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor 
			    spectrum-end spectro-hop spectrum-start spectro-x-angle
			    spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle spectro-z-scale squelch-update  grid-density
			    src-sound 
			    (lambda (snd) (transform-sample 0 0 snd)) transform->vct
			    transform-frames transform-type 
			    (lambda (snd) (undo 1 snd)) update-transform-graph update-time-graph update-lisp-graph
			    update-sound wavelet-type time-graph? time-graph-type wavo-hop wavo-trace x-bounds x-position-slider 
			    (lambda (snd) (normalize-channel 0.5 0 #f snd))
			    (lambda (snd) (x->position 0 snd))
			    x-zoom-slider y-bounds y-position-slider x-axis-label y-axis-label 
			    (lambda (snd) (y->position 0 snd)) y-zoom-slider 
			    zero-pad 
			    (lambda (snd) (scale-channel 2.0 0 #f snd))
			    )))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n 0 1234))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-sound))
			      (snd-display #__line__ ";~D: snd(1) chn procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list delete-sample edit-fragment graph-data graph-style play position->x position->y redo
			    time-graph-style lisp-graph-style transform-graph-style
			    scale-by scale-to undo x->position y->position x-axis-label)))
	  
	  (let ((ctr 0)
		(index (open-sound "oboe.snd")))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n 0 index 1234))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-channel))
			      (snd-display #__line__ ";~D: snd(1 1234) chn procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list delete-sample edit-fragment graph-data position->x position->y redo scale-by
			    scale-to undo x->position y->position))
	    (close-sound index))
	  
	  (let ((ctr 0)
		(index (open-sound "oboe.snd")))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n index 1234))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'no-such-channel))
				   (not (eq? tag 'no-such-sound)))
			      (snd-display #__line__ ";~D: chn procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list channel-widgets cursor cursor-position cursor-size cursor-style tracking-cursor-style display-edits
			    dot-size edit-position edit-tree edits fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases
			    transform-size transform-graph-type fft-window transform-graph? graph-style lisp-graph? left-sample
			    time-graph-style lisp-graph-style transform-graph-style
			    make-graph-data max-transform-peaks maxamp maxamp-position min-dB transform-normalization
			    reverse-sound right-sample show-axes show-transform-peaks show-marks 
			    show-mix-waveforms show-y-zero show-grid show-sonogram-cursor  grid-density
			    spectrum-end spectro-hop spectrum-start spectro-x-angle spectro-x-scale spectro-y-angle
			    spectro-y-scale spectro-z-angle spectro-z-scale squelch-update transform->vct
			    transform-frames transform-type update-transform-graph update-time-graph update-lisp-graph
			    wavelet-type time-graph?  time-graph-type wavo-hop wavo-trace x-bounds x-position-slider x-axis-label
			    x-zoom-slider y-bounds y-position-slider y-zoom-slider zero-pad channel-properties channel-property ))
	    (close-sound index))
	  
	  (let ((ctr 0)
		(index (open-sound "oboe.snd")))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(set! (n index 0) vct-5))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'wrong-type-arg))
				   (not (eq? tag 'syntax-error))
				   (not (eq? tag 'error)))
			      (snd-display #__line__ ";~D: set chn procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list channel-widgets cursor cursor-position display-edits dot-size edit-tree edits
			    fft-window-alpha fft-window-beta fft-log-frequency fft-log-magnitude fft-with-phases transform-size transform-graph-type fft-window
			    transform-graph? graph-style lisp-graph? left-sample make-graph-data max-transform-peaks maxamp maxamp-position
			    time-graph-style lisp-graph-style transform-graph-style
			    min-dB transform-normalization reverse-sound right-sample show-axes  grid-density
			    show-transform-peaks show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor spectrum-end spectro-hop
			    spectrum-start spectro-x-angle spectro-x-scale spectro-y-angle spectro-y-scale spectro-z-angle
			    spectro-z-scale squelch-update transform->vct transform-frames transform-type
			    update-transform-graph update-time-graph update-lisp-graph wavelet-type time-graph? time-graph-type
			    wavo-hop wavo-trace x-bounds x-position-slider x-zoom-slider y-bounds y-position-slider
			    y-zoom-slider zero-pad x-axis-label
			    ))
	    
	    (close-sound index))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n b)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n vct-5))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'wrong-type-arg))
				   (not (eq? tag 'syntax-error))
				   (not (eq? tag 'error)))
			      (snd-display #__line__ ";[0] ~D: mix procs ~A: ~A (~A)" ctr b tag vct-5))
			  (set! ctr (+ ctr 1))))
		      (list mix-amp mix-amp-env mix-length mix-name mix-position mix-home mix-speed mix-tag-y)
		      (list 'mix-amp 'mix-amp-env 'mix-length 'mix-name 'mix-position 'mix-home 'mix-speed 'mix-tag-y)))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (integer->mix 1234)))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-mix))
			      (snd-display #__line__ ";[1] ~D: mix procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list mix-amp mix-length mix-name mix-position mix-home mix-speed mix-tag-y)))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(set! (n (integer->mix 1234)) vct-5))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'wrong-type-arg))
				   (not (eq? tag 'syntax-error))
				   (not (eq? tag 'error))
				   (not (eq? tag 'no-such-mix))) ; if id checked first
			      (snd-display #__line__ ";[2] ~D: mix procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list mix-name mix-position mix-home mix-speed mix-tag-y))) 
	  
	  (let* ((ctr 0)
		 (index (open-sound "oboe.snd"))
		 (id (mix-sound "oboe.snd" 10)))
	    (for-each (lambda (n b)
			(let ((tag
			       (catch #t
				      (lambda ()
					(set! (n id) vct-5))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'wrong-type-arg))
				   (not (eq? tag 'syntax-error))
				   (not (eq? tag 'error)))
			      (snd-display #__line__ ";[3] ~D: mix procs ~A: ~A (~A)" ctr b tag vct-5))
			  (set! ctr (+ ctr 1))))
		      (list  mix-name mix-position mix-home mix-speed mix-tag-y)
		      (list 'mix-name 'mix-position 'mix-home 'mix-speed 'mix-tag-y))
	    (close-sound index))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n vct-5))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display #__line__ ";~D: mark procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list add-mark mark-name mark-sample mark-sync mark-home delete-mark delete-marks find-mark))) 
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (integer->mark 1234)))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-mark))
			      (snd-display #__line__ ";~D: no mark procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list mark-name mark-sample mark-sync mark-home delete-mark))) 
	  
	  (let* ((ctr 0)
		 (index (open-sound "oboe.snd"))
		 (id (add-mark 0 index 0)))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(set! (n id) vct-5))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display #__line__ ";~D: set mark procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list mark-name mark-sample mark-sync))
	    (close-sound index)
	    )
	  
	  (for-each (lambda (arg)
		      (let ((ctr 0))
			(for-each (lambda (n)
				    (let ((tag
					   (catch #t
						  (lambda ()
						    (n arg))
						  (lambda args (car args)))))
				      (if (and (not (eq? tag 'wrong-type-arg))
					       (not (eq? tag 'wrong-number-of-args)))
					  (snd-display #__line__ ";~D: region procs ~A: ~A ~A" ctr n tag arg))
				      (set! ctr (+ ctr 1))))
				  (list region-chans region-home region-frames 
					region-position region-maxamp region-maxamp-position region-sample 
					region->vct region-srate forget-region))))
		    (list vct-5 '#(0 1) (sqrt -1.0) "hiho" (list 0 1)))
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (integer->region 1234)))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-region))
			      (snd-display #__line__ ";~D: (no) region procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list region-chans region-home region-frames region-position 
			    region-maxamp region-maxamp-position region-srate forget-region))) 
	  
	  (let ((ctr 0))
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(set! (n) vct-5))
				      (lambda args (car args)))))
			  (if (and (not (eq? tag 'wrong-type-arg))
				   (not (eq? tag 'syntax-error))
				   (not (eq? tag 'error)))
			      (snd-display #__line__ ";~D: misc procs ~A: ~A" ctr n tag))
			  (set! ctr (+ ctr 1))))
		      (list axis-color enved-filter-order enved-filter filter-control-waveform-color ask-before-overwrite
			    auto-resize auto-update axis-label-font axis-numbers-font basic-color bind-key
			    channel-style color-cutoff color-orientation-dialog color-inverted color-scale
			    cursor-color dac-combines-channels dac-size clipping data-color default-output-chans 
			    default-output-data-format default-output-srate default-output-header-type enved-envelope enved-base
			    enved-clip? enved-in-dB enved-dialog enved-style  enved-power enved-target
			    enved-waveform-color enved-wave? eps-file eps-left-margin eps-bottom-margin eps-size
			    foreground-color graph-color graph-cursor highlight-color just-sounds key-binding
			    listener-color listener-font listener-prompt listener-text-color max-regions
			    minibuffer-history-length mix-waveform-height region-graph-style position-color
			    time-graph-style lisp-graph-style transform-graph-style peaks-font bold-peaks-font
			    view-files-sort print-length pushed-button-color sash-color ladspa-dir peak-env-dir save-dir save-state-file
			    selected-channel selected-data-color selected-graph-color 
			    selected-sound selection-creates-region show-controls show-indices show-listener
			    show-selection-transform sinc-width temp-dir text-focus-color tiny-font
			    trap-segfault with-file-monitor optimization unbind-key with-verbose-cursor with-inset-graph with-pointer-focus window-height beats-per-measure
			    window-width window-x window-y with-gl with-mix-tags x-axis-style beats-per-minute zoom-color mix-tag-height
			    mix-tag-width with-relative-panes clm-table-size clm-default-frequency mark-tag-width mark-tag-height
			    quit-button-color help-button-color reset-button-color doit-button-color doit-again-button-color
			    ))
	    )
	  
	  (for-each (lambda (n)
		      (let* ((hook (car n))
			     (hook-name (cadr n))
			     (tag
			      (catch #t
				     (lambda () (add-hook! hook (lambda () (+ 1 2))))
				     (lambda args (car args)))))
			(if (not (eq? tag 'wrong-type-arg))
			    (snd-display #__line__ ";hooks ~A: ~A" hook-name tag))))
		    (list (list after-graph-hook 'after-graph-hook)
			  (list after-lisp-graph-hook 'after-lisp-graph-hook)
			  (list lisp-graph-hook 'lisp-graph-hook)
			  (list time-graph-hook 'time-graph-hook)
			  (list before-transform-hook 'before-transform-hook)
			  (list mix-release-hook 'mix-release-hook)
			  (list save-hook 'save-hook)
			  (list before-save-as-hook 'before-save-as-hook)
			  (list after-save-as-hook 'after-save-as-hook)
			  (list save-state-hook 'save-state-hook)
			  (list new-sound-hook 'new-sound-hook)
			  (list mus-error-hook 'mus-error-hook)
			  (list mouse-enter-graph-hook 'mouse-enter-graph-hook)
			  (list mouse-leave-graph-hook 'mouse-leave-graph-hook)
			  (list open-raw-sound-hook 'open-raw-sound-hook)
			  (list select-channel-hook 'select-channel-hook)
			  (list output-name-hook 'output-name-hook)
			  (list peak-env-hook 'peak-env-hook)
			  (list after-open-hook 'after-open-hook)
			  (list close-hook 'close-hook)
			  (list draw-mark-hook 'draw-mark-hook)
			  (list draw-mix-hook 'draw-mix-hook)
			  (list mark-click-hook 'mark-click-hook)
			  (list listener-click-hook 'listener-click-hook)
			  (list mix-click-hook 'mix-click-hook)
			  (list after-save-state-hook 'after-save-state-hook)
			  (list before-save-state-hook 'before-save-state-hook)
			  (list mark-hook 'mark-hook)
			  (list mark-drag-hook 'mark-drag-hook)
			  (list mark-drag-triangle-hook 'mark-drag-triangle-hook)
			  (list mix-drag-hook 'mix-drag-hook)
			  (list name-click-hook 'name-click-hook)
			  (list after-apply-controls-hook 'after-apply-controls-hook)
			  (list open-hook 'open-hook)
			  (list output-comment-hook 'output-comment-hook)
			  (list help-hook 'help-hook)
			  (list play-hook 'play-hook)
			  (list dac-hook 'dac-hook)
			  (list new-widget-hook 'new-widget-hook)
			  (list read-hook 'read-hook)
			  (list bad-header-hook 'bad-header-hook)
			  (list snd-error-hook 'snd-error-hook)
			  (list snd-warning-hook 'snd-warning-hook)
			  (list start-hook 'start-hook)
			  (list start-playing-hook 'start-playing-hook)
			  (list stop-playing-hook 'stop-playing-hook)
			  (list mouse-enter-listener-hook 'mouse-enter-listener-hook)
			  (list mouse-leave-listener-hook 'mouse-leave-listener-hook)
			  (list window-property-changed-hook 'window-property-changed-hook)
			  (list select-sound-hook 'select-sound-hook)
			  (list view-files-select-hook 'view-files-select-hook)
			  (list during-open-hook 'during-open-hook)
			  (list after-transform-hook 'after-transform-hook)
			  (list mouse-enter-label-hook 'mouse-enter-label-hook)
			  (list mouse-leave-label-hook 'mouse-leave-label-hook)
			  (list initial-graph-hook 'initial-graph-hook)
			  (list graph-hook 'graph-hook)
			  (list key-press-hook 'key-press-hook)
			  (list mouse-drag-hook 'mouse-drag-hook)
			  (list mouse-press-hook 'mouse-press-hook)
			  (list mouse-click-hook 'mouse-click-hook)
			  (list enved-hook 'enved-hook)))
	  
	  (if (= test-28 0) 
	      (begin
		(check-error-tag 'no-such-envelope (lambda () (set! (enved-envelope) "not-an-env")))
		(check-error-tag 'cannot-save (lambda () (save-envelopes "/bad/baddy")))
		(check-error-tag 'cannot-save (lambda () (save-macros "/bad/baddy")))
		(check-error-tag 'cannot-save (lambda () (mus-sound-report-cache "/bad/baddy")))
		(check-error-tag 'bad-arity (lambda () (set! (search-procedure) (lambda (a b c) a))))
		(check-error-tag 'no-such-sound (lambda () (set! (search-procedure 1234) (lambda (a) a))))
		(check-error-tag 'no-such-channel (lambda () (make-sampler 0 "oboe.snd" 1)))
		(check-error-tag 'no-such-channel (lambda () (make-sampler 0 "oboe.snd" -1)))
		(check-error-tag 'bad-arity (lambda () (bind-key (char->integer #\p) 0 (lambda (a b) (play-often (max 1 a))))))
		(check-error-tag 'bad-arity (lambda () (set! (zoom-focus-style) (lambda (a) 0))))
		(check-error-tag 'wrong-type-arg (lambda () (mus-mix "oboe.snd" "pistol.snd" 0 12 0 (make-mixer 1 1.0) "a string")))
		(check-error-tag 'bad-header (lambda () (mus-mix "oboe.snd" (string-append sf-dir "bad_chans.aifc"))))
		(check-error-tag 'mus-error (lambda () (mus-mix "oboe.snd" (string-append sf-dir "bad_length.aifc"))))
		(check-error-tag 'bad-header (lambda () (mus-mix (string-append sf-dir "bad_chans.aifc") "oboe.snd")))
		(check-error-tag 'no-such-sound (lambda () (set! (sound-loop-info 123) '(0 0 1 1))))
		(check-error-tag 'bad-header (lambda () (new-sound "fmv.snd" mus-nist mus-bfloat 22050 2 "this is a comment")))
		(check-error-tag 'wrong-type-arg (lambda () (player-home 123)))
		(check-error-tag 'no-such-file (lambda () (set! (temp-dir) "/hiho")))
		(check-error-tag 'no-such-file (lambda () (set! (save-dir) "/hiho")))
		(check-error-tag 'out-of-range (lambda () (snd-transform (integer->transform 20) (make-vct 4))))
		(check-error-tag 'bad-header (lambda () (mus-sound-maxamp (string-append sf-dir "bad_chans.snd"))))
		(check-error-tag 'bad-header (lambda () (set! (mus-sound-maxamp (string-append sf-dir "bad_chans.snd")) '(0.0 0.0))))
		(check-error-tag 'mus-error (lambda () (make-iir-filter :order 32 :ycoeffs (make-vct 4))))
		(check-error-tag 'mus-error (lambda () (make-iir-filter :coeffs (make-vct 4) :ycoeffs (make-vct 4))))
		(check-error-tag 'mus-error (lambda () (make-fir-filter :coeffs (make-vct 4) :xcoeffs (make-vct 4))))
		(check-error-tag 'out-of-range (lambda () (make-table-lookup :size 123456789)))
					;		(check-error-tag 'out-of-range (lambda () (make-src :srate -0.5)))
		(check-error-tag 'out-of-range (lambda () (make-granulate :ramp -0.5)))
		(check-error-tag 'out-of-range (lambda () (make-granulate :ramp 1.5)))
		(check-error-tag 'mus-error (lambda () (make-granulate :expansion 32000.0)))
		(check-error-tag 'out-of-range (lambda () (new-sound "test.snd" :channels 0)))
		(check-error-tag 'out-of-range (lambda () (new-sound "test.snd" :srate 0)))
		(check-error-tag 'out-of-range (lambda () (new-sound "test.snd" :size -1)))
		(check-error-tag 'out-of-range (lambda () (make-readin "oboe.snd" :size 0)))
		(check-error-tag 'out-of-range (lambda () (make-readin "oboe.snd" :size -1)))
		(check-error-tag 'out-of-range (lambda () (make-file->sample "oboe.snd" 0)))
		(check-error-tag 'out-of-range (lambda () (make-file->sample "oboe.snd" -1)))
		(check-error-tag 'out-of-range (lambda () (make-file->frame "oboe.snd" 0)))
		(check-error-tag 'out-of-range (lambda () (make-file->frame "oboe.snd" -1)))
		(check-error-tag 'out-of-range (lambda () (set! (default-output-data-format) -1)))
		(check-error-tag 'out-of-range (lambda () (set! (default-output-header-type) mus-soundfont)))
		(check-error-tag 'mus-error (lambda () (mus-sound-chans (string-append sf-dir "bad_location.nist"))))
		(check-error-tag 'mus-error (lambda () (mus-sound-chans (string-append sf-dir "bad_field.nist"))))
		(if (provided? 'snd-motif)
		    (begin
		      (check-error-tag 'no-such-widget (lambda () (widget-position (list 'Widget 0)))) ; dubious -- not sure these should be supported
		      (check-error-tag 'no-such-widget (lambda () (widget-size (list 'Widget 0))))
		      (check-error-tag 'no-such-widget (lambda () (widget-text (list 'Widget 0))))
		      (check-error-tag 'no-such-widget (lambda () (set! (widget-position (list 'Widget 0)) (list 0 0))))
		      (check-error-tag 'no-such-widget (lambda () (set! (widget-size (list 'Widget 0)) (list 10 10))))
		      (check-error-tag 'no-such-widget (lambda () (set! (widget-text (list 'Widget 0)) "hiho")))
		      ))
		(check-error-tag 'no-such-menu (lambda () (main-menu -1)))
		(check-error-tag 'no-such-menu (lambda () (main-menu 111)))
		(check-error-tag 'out-of-range (lambda () (new-sound "hiho" 123)))
		(check-error-tag 'out-of-range (lambda () (new-sound "hiho" mus-nist 123)))
		(check-error-tag 'bad-header (lambda () (new-sound "hiho" mus-nist mus-bfloat)))
		(check-error-tag 'out-of-range (lambda () (make-sound-data 0 1)))
		(check-error-tag 'out-of-range (lambda () (make-sound-data -2 1)))
		(check-error-tag 'out-of-range (lambda () (make-sound-data 1 -1)))
		(check-error-tag 'out-of-range (lambda () (make-sound-data 1 0)))
		(check-error-tag 'out-of-range (lambda () (mus-sound-close-output 0 1)))
		(check-error-tag 'out-of-range (lambda () (mus-sound-close-output 1 1)))
		(check-error-tag 'out-of-range (lambda () (mus-sound-close-output 2 1)))
		(check-error-tag 'out-of-range (lambda () (mus-sound-close-input 0)))
		(check-error-tag 'out-of-range (lambda () (mus-sound-close-input 1)))
		(check-error-tag 'out-of-range (lambda () (mus-sound-close-input 2)))
		(check-error-tag 'out-of-range (lambda () (set! (mus-array-print-length) -1)))
		(check-error-tag 'out-of-range (lambda () (set! (print-length) -1)))
					;		(check-error-tag 'wrong-type-arg (lambda () (vector->vct (make-vector 3 "hio"))))
		(check-error-tag 'out-of-range (lambda () (set! (enved-style) 12)))
		(check-error-tag 'out-of-range (lambda () (make-color 1.5 0.0 0.0)))
		(check-error-tag 'out-of-range (lambda () (make-color -0.5 0.0 0.0)))
		(check-error-tag 'wrong-type-arg (lambda () (make-variable-graph #f)))
		(check-error-tag 'cannot-print (lambda () (graph->ps)))
		(let ((ind (open-sound "oboe.snd"))) 
		  (set! (selection-creates-region) #t)
		  (select-all)
		  (check-error-tag 'mus-error (lambda () (save-selection "sel0.snd" :not-a-key 3)))
		  (check-error-tag 'wrong-type-arg (lambda () (read-only (list ind))))
		  (check-error-tag 'wrong-type-arg (lambda () (frames ind (list 0))))
		  (check-error-tag 'wrong-type-arg (lambda () (smooth-sound 0 -10)))
		  (check-error-tag 'bad-arity (lambda () (ptree-channel (lambda (a b c) #f) 0 10 #f #f #f #f (lambda (a) #f))))
		  (check-error-tag 'bad-arity (lambda () (ptree-channel (lambda (a) #f) 0 10 #f #f #f #f (lambda (a b) #f))))
		  (check-error-tag 'no-such-channel (lambda () (mix-selection 0 ind 123)))
		  (check-error-tag 'no-such-channel (lambda () (insert-selection 0 ind 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (channels ind) 0)))
		  (check-error-tag 'out-of-range (lambda () (set! (channels ind) -1)))
		  (check-error-tag 'out-of-range (lambda () (set! (channels ind) 12340)))
		  (check-error-tag 'out-of-range (lambda () (set! (data-format ind) 12340)))
		  (check-error-tag 'out-of-range (lambda () (set! (header-type ind) 12340)))
		  (check-error-tag 'out-of-range (lambda () (set! (srate ind) 0)))
		  (check-error-tag 'out-of-range (lambda () (set! (data-location ind) -1)))
		  (check-error-tag 'out-of-range (lambda () (set! (data-size ind) -1)))
		  (check-error-tag 'no-such-sample (lambda () (set! (sample -1) -1)))
		  (check-error-tag 'no-such-sample (lambda () (sample -1)))
		  (check-error-tag 'out-of-range (lambda () (set! (frames) -10)))
		  (check-error-tag 'out-of-range (lambda () (set! (min-dB) 0.0)))
		  (check-error-tag 'out-of-range (lambda () (set! (min-dB ind 0) 0.0)))
		  (check-error-tag 'out-of-range (lambda () (start-playing 1 -22)))
		  (check-error-tag 'out-of-range (lambda () (start-playing 1 0)))
		  (check-error-tag 'out-of-range (lambda () (set! (filter-control-envelope ind) (list 0.0 1.0 0.1 -0.1 1.0 0.0))))
		  (check-error-tag 'out-of-range (lambda () (set! (filter-control-envelope ind) (list 0.0 1.0 0.1 1.1 1.0 0.0))))
		  (check-error-tag 'env-error (lambda () (filter-sound '(0 0 .1 .1 .05 .1 1 1) 32)))
		  (check-error-tag 'out-of-range (lambda () (apply-controls ind 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (speed-control-bounds) (list 0.0 2.0))))
		  (check-error-tag 'out-of-range (lambda () (set! (expand-control-bounds) (list 0.0 2.0))))
		  (check-error-tag 'out-of-range (lambda () (set! (speed-control-bounds) (list 2.0 0.0))))
		  (check-error-tag 'out-of-range (lambda () (set! (expand-control-bounds) (list 2.0 0.0))))
		  (check-error-tag 'bad-header (lambda () (insert-sound (string-append sf-dir "bad_chans.snd"))))
		  (check-error-tag 'IO-error (lambda () (convolve-with (string-append sf-dir "bad_chans.snd"))))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "hiho.snd" ind -12)))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "hiho.snd" ind mus-next -12)))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "test.snd" ind mus-nist mus-bdouble)))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "test.snd" ind mus-aifc mus-lfloat)))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "test.snd" ind mus-riff mus-bshort)))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "test.snd" ind mus-voc mus-bshort)))
		  (check-error-tag 'cannot-save (lambda () (save-selection "test.snd" mus-riff mus-bshort)))
		  (check-error-tag 'cannot-save (lambda () (save-selection "test.snd" mus-voc mus-bshort)))
		  (check-error-tag 'no-data (lambda () (draw-lines '#())))
		  (check-error-tag 'bad-length (lambda () (draw-lines '#(1 2 3))))
		  (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 0 1 1) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 1 1 0) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 1 1 -1) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 -1 1 1) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 0 1 1) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 1 1 0) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 1 1 -1) :length 11))))
		  (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 -1 1 1) :length 11))))
		  (check-error-tag 'mus-error (lambda () (make-readin 0.0 0.0 0.0 0.0 0.0 0.0 0.0)))
		  (check-error-tag 'out-of-range (lambda () (filter-sound vct-3 32)))
		  (check-error-tag 'out-of-range (lambda () (filter-sound '(0 0 1 1) 0)))
		  (check-error-tag 'no-such-sound (lambda () (swap-channels ind 0 12345 0)))
		  (check-error-tag 'no-such-sample (lambda () (mix-vct (vct 0.1 0.2 0.3) -1 ind 0 #t)))
		  (check-error-tag 'out-of-range (lambda () (snd-spectrum (make-vct 8) 0 -123)))
		  (check-error-tag 'out-of-range (lambda () (snd-spectrum (make-vct 8) 0 0)))
		  (check-error-tag 'no-such-file (lambda () (play "/baddy/hiho")))
		  (check-error-tag 'bad-format (lambda () (play (string-append sf-dir "nist-shortpack.wav"))))
					;		  (check-error-tag 'no-such-channel (lambda () (play ind 0 :channel 123)))
		  (check-error-tag 'no-such-channel (lambda () (make-player ind 123)))
		  (check-error-tag 'no-such-file (lambda () (mix "/baddy/hiho")))
		  (check-error-tag 'no-such-channel (lambda () (mix "oboe.snd" 0 2)))
		  (check-error-tag 'no-such-file (lambda () (mix-sound "/baddy/hiho" 0)))
		  (check-error-tag 'no-such-file (lambda () (insert-sound "/baddy/hiho.snd")))
		  (check-error-tag 'no-such-file (lambda () (insert-samples 0 10 "/baddy/hiho.snd")))
		  (check-error-tag 'no-data (lambda () (set! (filter-control-envelope ind) '())))
		  (check-error-tag 'out-of-range (lambda () (set! (data-format ind) 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (header-type ind) 123)))
		  (check-error-tag 'no-such-channel (lambda () (set! (selected-channel ind) 123)))
		  (check-error-tag 'bad-arity (lambda () (set! (search-procedure ind) (lambda (a b c) #t))))
		  (check-error-tag 'bad-arity (lambda () (map-chan (lambda (a b c) 1.0))))
		  (check-error-tag 'bad-arity (lambda () (scan-chan (lambda (a b c) 1.0))))
		  (check-error-tag 'bad-arity (lambda () (set! (cursor-style ind 0) (lambda (a) 32))))
		  (check-error-tag 'bad-arity (lambda () (find-channel (lambda () 1.0))))
		  (check-error-tag 'bad-arity (lambda () (count-matches (lambda () 1.0))))
		  (check-error-tag 'no-such-graphics-context (lambda () (draw-line 0 0 1 1 ind 0 1234)))
		  (check-error-tag 'no-such-graphics-context (lambda () (foreground-color ind 0 1234)))
		  (check-error-tag 'no-such-graphics-context (lambda () (current-font ind 0 1234)))
		  (check-error-tag 'no-such-graphics-context (lambda () (graph-data (list vct-3 vct-3) ind 0 1234 0 1 0)))
		  (check-error-tag 'no-such-axis (lambda () (position->x 100 ind 0 1234)))
		  (check-error-tag 'no-such-axis (lambda () (position->y 100 ind 0 1234)))
		  (check-error-tag 'no-such-axis (lambda () (x->position 100 ind 0 1234)))
		  (check-error-tag 'no-such-axis (lambda () (y->position 100 ind 0 1234)))
		  (check-error-tag 'no-such-axis (lambda () (axis-info ind 0 1234)))
		  (check-error-tag 'out-of-range (lambda () (draw-axes (car (channel-widgets)) (car (snd-gcs)) "hiho" 0.0 1.0 -1.0 1.0 x-axis-in-seconds 1234)))
		  (check-error-tag 'out-of-range (lambda () (draw-axes (car (channel-widgets)) (car (snd-gcs)) "hiho" 0.0 1.0 -1.0 1.0 1234)))
		  (check-error-tag 'no-such-channel (lambda () (axis-info ind 1234)))
		  (check-error-tag 'no-such-sound (lambda () (axis-info 1234)))
		  (set! (time-graph-type) graph-once)
					;		  (check-error-tag 'out-of-range (lambda () (set! (x-bounds) (list 0 0))))
		  (check-error-tag 'out-of-range (lambda () (set! (x-bounds) (list .1 -.1))))
					;		  (check-error-tag 'out-of-range (lambda () (set! (y-bounds) (list .2 .1))))
		  (check-error-tag 'out-of-range (lambda () (make-region 100 0)))
		  (check-error-tag 'no-such-sample (lambda () (delete-sample -1)))
		  (check-error-tag 'no-such-sample (lambda () (delete-sample (* 2 (frames ind)))))
		  (check-error-tag 'no-such-file (lambda () (play "/bad/baddy.snd")))
		  (check-error-tag 'no-such-sound (lambda () (play 1234 0)))
					;		  (check-error-tag 'no-such-channel (lambda () (play ind 0 :channel 1234)))
		  (if (= (length (regions)) 0) (make-region 0 100))
		  (check-error-tag 'no-such-channel (lambda () (region-sample (car (regions)) 0 1234)))
		  (check-error-tag 'no-such-channel (lambda () (region-frames (car (regions)) 1234)))
		  (check-error-tag 'no-such-channel (lambda () (region-position (car (regions)) 1234)))
					;		  (check-error-tag 'no-such-region (lambda () (region->vct #f 0 1)))
					;		  (check-error-tag 'no-such-channel (lambda () (region->vct (car regions) 0 1 1234)))
		  (check-error-tag 'cannot-save (lambda () (save-sound-as "/bad/baddy.snd")))
		  (check-error-tag 'no-such-sound (lambda () (transform-sample 0 1 1234)))
		  (check-error-tag 'no-such-channel (lambda () (transform-sample 0 1 ind 1234)))
		  (check-error-tag 'no-such-sound (lambda () (samples->sound-data 0 100 1234)))
		  (check-error-tag 'no-such-channel (lambda () (samples->sound-data 0 100 ind 1234)))
		  (check-error-tag 'no-such-sound (lambda () (graph (vct 0 1) "hi" 0 1 0 1 1234)))
		  (check-error-tag 'no-such-channel (lambda () (graph (vct 0 1) "hi" 0 1 0 1 ind 1234)))
		  (set! (selection-member? #t) #f)
		  (check-error-tag 'no-active-selection (lambda () (filter-selection (vct 0 0 1 1) 4)))
		  (check-error-tag 'no-active-selection (lambda () (save-selection "/bad/baddy.snd")))
		  (check-error-tag 'no-active-selection (lambda () (env-selection '(0 0 1 1))))
		  (check-error-tag 'no-such-region (lambda () (save-region (integer->region 1234) "/bad/baddy.snd")))
		  (make-region 0 100 ind 0)
		  (check-error-tag 'cannot-save (lambda () (save-selection "/bad/baddy.snd")))
		  (check-error-tag 'cannot-save (lambda () (save-region (car (regions)) "/bad/baddy.snd")))
		  (check-error-tag 'no-such-mix (lambda () (make-mix-sampler (integer->mix 1234))))
		  (check-error-tag 'no-such-sound (lambda () (make-region 0 12 1234 #t)))
		  (set! (read-only ind) #t)
		  (check-error-tag 'cannot-save (lambda () (set! (sound-loop-info ind) '(0 0 1 1))))
		  (check-error-tag 'no-such-direction (lambda () (make-sampler 0 ind 0 123)))
		  (check-error-tag 'no-such-direction (lambda () (make-sampler 0 ind 0 0)))
		  (check-error-tag 'no-such-direction (lambda () (make-sampler 0 ind 0 -2)))
		  (check-error-tag 'no-data (lambda () (scale-by '())))
		  (check-error-tag 'no-data (lambda () (scale-to '())))
		  (check-error-tag 'bad-arity (lambda () (prompt-in-minibuffer "hi" (lambda (x y) (+ x y)))))
		  (check-error-tag 'no-such-sample (lambda () (set! (selection-position ind 0) -999)))
		  (check-error-tag 'wrong-type-arg (lambda () (set! (selection-frames ind 0) -999)))
		  (check-error-tag 'wrong-type-arg (lambda () (set! (selection-frames ind 0) 0)))
		  (check-error-tag 'no-such-edit (lambda () (edit-fragment -1)))
		  (check-error-tag 'no-such-edit (lambda () (edit-fragment 101 ind 0)))
		  (check-error-tag 'no-such-edit (lambda () (edit-tree ind 0 -2)))
		  (check-error-tag 'no-such-edit (lambda () (edit-tree ind 0 101)))
		  (check-error-tag 'no-such-sample (lambda () (add-mark -1)))
		  (check-error-tag 'no-such-sample (lambda () (add-mark (* 2 (frames)))))
		  (check-error-tag 'no-such-file (lambda () (convolve-with "/bad/baddy")))
		  (check-error-tag 'no-such-file (lambda () (mix "/bad/baddy")))
		  (check-error-tag 'no-such-sound (lambda () (swap-channels ind 0 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (show-axes ind 0) 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (show-axes ind 0) -123)))
		  (check-error-tag 'out-of-range (lambda () (set! (x-axis-style ind 0) 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (x-axis-style ind 0) -123)))
		  (check-error-tag 'out-of-range (lambda () (set! (graph-style ind 0) 123)))
		  (check-error-tag 'out-of-range (lambda () (set! (graph-style ind 0) -123)))
		  (check-error-tag 'out-of-range (lambda () (env-sound '(0 0 1 1) 0 #f -1.5)))
		  (check-error-tag 'out-of-range (lambda () (xramp-channel 0.0 1.0 -1.6)))
		  (check-error-tag 'wrong-type-arg (lambda () (set! (samples 0 2) -1)))
		  (check-error-tag 'wrong-type-arg (lambda () (left-sample (list 0))))
		  (check-error-tag 'wrong-type-arg (lambda () (amp-control (list 0))))
		  (check-error-tag 'wrong-type-arg (lambda () (sound-loop-info (list 0))))
		  (check-error-tag 'wrong-type-arg (lambda () (add-mark 123 (list 0))))
		  (check-error-tag 'no-such-sound (lambda () (filter-channel '(0 0 1 1) 100 #f #f 1234 0)))
		  (check-error-tag 'no-such-channel (lambda () (filter-channel '(0 0 1 1) 100 #f #f ind 1)))
		  (check-error-tag 'no-such-channel (lambda () (filter-channel (vct 0 0 1 1) 4 #f #f ind 1)))
		  (check-error-tag 'out-of-range (lambda () (filter-sound (vct 0 0 1 1) 0)))
		  (check-error-tag 'out-of-range (lambda () (filter-sound (vct 0 0 1 1) 10)))
		  (check-error-tag 'bad-arity (lambda () (play (selected-sound) 0 :stop (lambda () #f))))
		  (check-error-tag 'out-of-range (lambda () (set! (reverb-control-length-bounds ind) (list .1 .01))))
		  (check-error-tag 'out-of-range (lambda () (set! (reverb-control-scale-bounds ind) (list .1 .01))))
		  (check-error-tag 'wrong-type-arg (lambda () (scale-by #f)))
		  (check-error-tag 'wrong-type-arg (lambda () (scale-by (make-mixer 2 .1 .1 .2 .2))))
		  (check-error-tag 'wrong-type-arg (lambda () (src-sound 3.0 1.0 #t)))
		  (check-error-tag 'wrong-type-arg (lambda () (src-sound 3.0 1.0 ind #t)))
		  (check-error-tag 'no-such-edit (lambda () (display-edits ind 0 123)))
		  (check-error-tag 'no-such-edit (lambda () (marks ind 0 123)))
		  (check-error-tag 'no-such-edit (lambda () (save-sound-as "test.snd" :edit-position 123)))
		  (check-error-tag 'no-such-auto-delete-choice (lambda () (insert-sound "1a.snd" 0 0 ind 0 0 123)))
		  (close-sound ind))
		(check-error-tag 'bad-arity (lambda () (add-transform "hiho" "time" 0 1 (lambda () 1.0))))
		(check-error-tag 'cannot-save (lambda () (save-state "/bad/baddy")))
		(check-error-tag 'no-such-menu (lambda () (add-to-menu 1234 "hi" (lambda () #f))))
		(check-error-tag 'bad-arity (lambda () (add-to-main-menu "hi" (lambda (a b) #f))))
		(check-error-tag 'bad-arity (lambda () (add-to-menu 1 "hi" (lambda (a b) #f))))
		(check-error-tag 'wrong-type-arg (lambda () (set! (transform-type) (integer->transform -1))))
		(check-error-tag 'out-of-range (lambda () (set! (transform-type) (integer->transform 123))))
		(check-error-tag 'wrong-type-arg (lambda () (help-dialog (list 0 1) "hiho")))
		(check-error-tag 'wrong-type-arg (lambda () (info-dialog (list 0 1) "hiho")))
		(check-error-tag 'no-such-sound (lambda () (edit-header-dialog 1234)))
		(check-error-tag 'no-such-file (lambda () (open-sound "/bad/baddy.snd")))
		(check-error-tag 'no-such-file (lambda () (open-raw-sound "/bad/baddy.snd" 1 22050 mus-lshort)))
		(check-error-tag 'no-such-file (lambda () (view-sound "/bad/baddy.snd")))
		(check-error-tag 'no-such-file (lambda () (make-sampler 0 "/bad/baddy.snd")))
		(check-error-tag 'no-such-region (lambda () (make-region-sampler (integer->region 1234567) 0)))
		(check-error-tag 'no-such-key (lambda () (bind-key 12345678 0 #f)))
		(check-error-tag 'no-such-key (lambda () (bind-key -1 0 #f)))
		(check-error-tag 'no-such-key (lambda () (bind-key 12 17 #f)))
		(check-error-tag 'no-such-key (lambda () (bind-key 12 -1 #f)))
		(check-error-tag 'no-such-key (lambda () (key-binding 12345678 0)))
		(check-error-tag 'no-such-key (lambda () (key-binding -1 0)))
		(check-error-tag 'no-such-key (lambda () (key-binding 12 17)))
		(check-error-tag 'no-such-key (lambda () (key-binding 12 -1)))
		(if (defined? 'send-mozilla) (check-error-tag 'wrong-type-arg (lambda () (send-mozilla -1))))
		(check-error-tag 'bad-header (lambda () (file->array (string-append sf-dir "bad_chans.snd") 0 0 123 (make-vct 123))))
		(check-error-tag 'bad-header (lambda () (make-readin (string-append sf-dir "bad_chans.snd"))))
		(check-error-tag 'mus-error (lambda () (make-iir-filter 30 (make-vct 3))))
		(check-error-tag 'out-of-range (lambda () (make-wave-train :size (expt 2 30))))
		(check-error-tag 'out-of-range (lambda () (set! (mus-srate) 0.0)))
		(check-error-tag 'out-of-range (lambda () (set! (mus-srate) -1000)))
		(check-error-tag 'out-of-range (lambda () (dot-product (make-vct 3) (make-vct 3) -1)))
		(check-error-tag 'out-of-range (lambda () (sine-bank (make-vct 3) (make-vct 3) -1)))
		(check-error-tag 'out-of-range (lambda () (multiply-arrays (make-vct 3) (make-vct 3) -1)))
		(check-error-tag 'out-of-range (lambda () (make-delay 3 :initial-element 0.0 :initial-contents (vct .1 .2 .3))))
		(check-error-tag 'out-of-range (lambda () (make-delay 3 :max-size 100 :initial-contents (vct .1 .2 .3))))
		(check-error-tag 'out-of-range (lambda () (make-table-lookup :size 100 :wave (make-vct 3))))
		(check-error-tag 'out-of-range (lambda () (make-wave-train :size 100 :wave (make-vct 3))))
					;		(check-error-tag 'out-of-range (lambda () (make-granulate :max-size (expt 2 30))))
		(check-error-tag 'out-of-range (lambda () (make-ssb-am 100 12345678)))
		(check-error-tag 'mus-error (lambda () (make-rand :envelope '(0 0 1 1) :distribution (make-vct 10))))
		(check-error-tag 'mus-error (lambda () (make-rand :envelope '(0 0 1))))
		(check-error-tag 'out-of-range (lambda () (make-rand :envelope '(0 0 1 1) :size -2)))
		(check-error-tag 'out-of-range (lambda () (make-rand :envelope '(0 0 1 1) :size 1234567890)))
		(check-error-tag 'bad-arity (lambda () (let ((grn (make-granulate))) (granulate grn #f (lambda (a s d) #f)))))
		(check-error-tag 'bad-arity (lambda () (let ((pv (make-phase-vocoder))) (phase-vocoder pv #f (lambda () #f)))))
		(check-error-tag 'bad-arity (lambda () (let ((pv (make-phase-vocoder))) (phase-vocoder pv #f #f (lambda () #f)))))
		(check-error-tag 'bad-arity (lambda () (let ((pv (make-phase-vocoder))) (phase-vocoder pv #f #f #f (lambda () #f)))))
		(check-error-tag 'mus-error (lambda () (let ((f (make-filter 3 :xcoeffs vct-3 :ycoeffs vct-3))) (mus-xcoeff f 4))))
		(check-error-tag 'mus-error (lambda () (let ((f (make-filter 3 :xcoeffs vct-3 :ycoeffs vct-3))) (mus-ycoeff f 4))))
		(check-error-tag 'mus-error (lambda () (let ((f (make-filter 3 :xcoeffs vct-3 :ycoeffs vct-3))) (set! (mus-xcoeff f 4) 1.0))))
		(check-error-tag 'mus-error (lambda () (let ((f (make-filter 3 :xcoeffs vct-3 :ycoeffs vct-3))) (set! (mus-ycoeff f 4) 1.0))))
		(check-error-tag 'mus-error (lambda () (make-filter :ycoeffs (make-vct 4) :order 12)))
		(check-error-tag 'mus-error (lambda () (let ((hi (make-oscil))) (set! (mus-offset hi) 1))))
		(check-error-tag 'out-of-range (lambda () (make-locsig :channels (expt 2 30))))
		(check-error-tag 'out-of-range (lambda () (make-src :width 3000)))
		(check-error-tag 'out-of-range (lambda () (make-frame -1)))
		(check-error-tag 'mus-error (lambda () (let ((hi (make-frame 2 .1 .2))) (frame-ref hi 3))))
		(check-error-tag 'out-of-range (lambda () (make-scalar-mixer 0 .1)))
		(check-error-tag 'mus-error (lambda () (let ((m (make-mixer 2))) (mixer-ref m 3 4))))
		(check-error-tag 'bad-arity (lambda () (add-colormap "baddy" (lambda () #f))))
		(check-error-tag 'bad-arity (lambda () (add-colormap "baddy" (lambda (a b c) #f))))
					;		(check-error-tag 'out-of-range (lambda () (make-phase-vocoder :fft-size (expt 2 30))))
		(check-error-tag 'out-of-range (lambda () (let ((sr (make-src :input (lambda (dir) 1.0)))) (src sr 2000000.0))))
		(check-error-tag 'out-of-range (lambda () (partials->polynomial '(1 1) -1)))
		(check-error-tag 'out-of-range (lambda () (partials->polynomial '(1 1) 3)))
		(check-error-tag 'out-of-range (lambda () (make-polyshape 440.0 :partials '(1 1) :kind -1)))
		(check-error-tag 'out-of-range (lambda () (make-polyshape 440.0 :partials '(1 1) :kind 3)))
		(check-error-tag 'wrong-type-arg (lambda () (normalize-partials 32)))
		(check-error-tag 'wrong-type-arg (lambda () (normalize-partials '())))
		(check-error-tag 'bad-type (lambda () (normalize-partials '(1 2 3))))
		(check-error-tag 'bad-type (lambda () (normalize-partials (vct 3))))
		
		(check-error-tag 'no-data (lambda () (make-polyshape 440.0 :partials (vct 1 1 -2 1))))
		(check-error-tag 'no-data (lambda () (make-polyshape 440.0 :partials (list 1 1 -2 1))))
					;(check-error-tag 'wrong-type-arg (lambda () (make-polyshape 440.0 :partials (list 1 1 "hi" 1)))) ; can be 'no-data etc
					;(check-error-tag 'wrong-type-arg (lambda () (make-polyshape 440.0 :partials (list 1 1 2 "hi"))))
		(check-error-tag 'no-data (lambda () (make-polyshape 440.0 :partials (list))))
		
		(check-error-tag 'wrong-type-arg (lambda () (set! (mus-header-raw-defaults) 1234)))
		(check-error-tag 'wrong-type-arg (lambda () (set! (mus-header-raw-defaults) (list 44100 2.123 "hi"))))
		(check-error-tag 'no-such-mix (lambda () (mix-properties (integer->mix (+ 1 (mix-sync-max))))))
		(check-error-tag 'no-such-mix (lambda () (set! (mix-properties (integer->mix (+ 1 (mix-sync-max)))) 1)))
		))
	  
	  (if (provided? 'snd-motif)
	      (for-each
	       (lambda (n name)
		 (let ((tag (catch #t
				   (lambda () (n (list 'Widget 0)))
				   (lambda args (car args)))))
		   (if (not (eq? tag 'no-such-widget))
		       (snd-display #__line__ ";~A of null widget -> ~A" name tag))))
	       (list widget-position widget-size widget-text hide-widget show-widget focus-widget)
	       (list 'widget-position 'widget-size 'widget-text 'hide-widget 'show-widget 'focus-widget)))
	  
	  ;; now try everything! (all we care about here is that Snd keeps running)
	  
					;	    (reset-hook! snd-error-hook)
					;	    (add-hook! snd-error-hook (lambda (msg) (snd-display #__line__ msg) #t))
	  
	  ;; ---------------- key args
	  (for-each
	   (lambda (arg1)
	     (for-each 
	      (lambda (arg2)
		(for-each 
		 (lambda (n)
		   (catch #t
			  (lambda () (n arg1 arg2))
			  (lambda args (car args))))
		 make-procs))
	      (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 delay-32)))
	   keyargs)
	  
	  (if (and all-args (= test-28 0))
	      (begin
		(for-each
		 (lambda (arg1)
		   (for-each 
		    (lambda (arg2)
		      (for-each 
		       (lambda (arg3)
			 (for-each 
			  (lambda (n)
			    (catch #t
				   (lambda () (n arg1 arg2 arg3))
				   (lambda args (car args))))
			  make-procs))
		       (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 delay-32)))
		    keyargs))
		 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 delay-32))
		
		(for-each
		 (lambda (arg1)
		   (for-each 
		    (lambda (arg2)
		      (for-each 
		       (lambda (arg3)
			 (for-each 
			  (lambda (arg4)
			    (for-each 
			     (lambda (n)
			       (catch #t
				      (lambda () (n arg1 arg2 arg3 arg4))
				      (lambda args (car args))))
			     make-procs))
			  keyargs))
		       (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 delay-32)))
		    keyargs))
		 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 delay-32))))
	  
	  ;;	(set! a-sound (new-sound "test.snd" mus-next mus-bshort 22050 1 "set-samples test" 100))
	  (if all-args (snd-display #__line__ ";args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time)))))
	  
	  ;; ---------------- 0 Args
	  (for-each 
	   (lambda (n)
	     (let ((err (catch #t
			       (lambda ()
				 (n))
			       (lambda args (car args)))))
	       (if (eq? err 'wrong-number-of-args)
		   (snd-display #__line__ ";procs0: ~A ~A" err (procedure-property n 'documentation)))))
	   procs0)
	  (dismiss-all-dialogs)
	  
	  (let* ((main-args (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95  '#(0 1) 3/4 'mus-error (sqrt -1.0) delay-32
				  (lambda () #t) vct-5 sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 -1.0 
				  '() '3 64 -64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
				  (lambda (a) #f) abs
				  1.0+1.0i (cons 1 2) '((1 2) (3 4)) '((1 (2)) (((3) 4)))
				  (vector 1 #\a '(3)) (make-vector 0)
				  (let ((x 3)) (lambda (y) (+ x y))) (lambda args args)
				  "" (make-hash-table 256)
				  (symbol->value '_?__undefined__?_)                  ; -> #<undefined> hopefully
				  (vector-fill! (vector 0) 0)                         ; -> #<unspecified>?
				  (with-input-from-string "" (lambda () (read-char))) ; -> #<eof>?
				  (make-random-state 1234)
				  ))
		 (few-args (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 -1.0
				 (sqrt -1.0) delay-32 :feedback -1 0 1 "" 'hi (lambda (a) (+ a 1)) -64 #f #t '() vector-0))
		 (fewer-args (list "/hiho" 1234 vct-3 -1.0 (sqrt -1.0) delay-32 -1 0 1 #f #t "" '()))
		 (less-args (if all-args main-args few-args)))
	    
	    ;; ---------------- 1 Arg
	    (for-each 
	     (lambda (arg)
	       (for-each 
		(lambda (n)
		  (let ((err (catch #t
				    (lambda () (n arg))
				    (lambda args (car args)))))
		    (if (eq? err 'wrong-number-of-args)
			(snd-display #__line__ ";procs1 wna: ~A ~A" err (procedure-property n 'documentation)))))
		procs1))
	     main-args)
	    
	    ;; ---------------- 2 Args
	    (for-each 
	     (lambda (arg1)
	       (for-each 
		(lambda (arg2)
		  (for-each 
		   (lambda (n)
		     (let ((err (catch #t
				       (lambda () (n arg1 arg2))
				       (lambda args (car args)))))
		       (if (eq? err 'wrong-number-of-args)
			   (snd-display #__line__ ";procs2: ~A ~A" err (procedure-property n 'documentation)))))
		   procs2))
		main-args))
	     main-args)
	    
	    ;; ---------------- set! no Args
	    (for-each 
	     (lambda (arg)
	       (for-each 
		(lambda (n)
		  (let ((err (catch #t
				    (lambda () (set! (n) arg))
				    (lambda args (car args)))))
		    (if (eq? err 'wrong-number-of-args)
			(snd-display #__line__ ";set-procs0: ~A ~A" err (procedure-property n 'documentation)))))
		set-procs0))
	     main-args)
	    
	    ;; ---------------- set! 1 Arg
	    (for-each 
	     (lambda (arg1)
	       (for-each 
		(lambda (arg2)
		  (for-each 
		   (lambda (n)
		     (let ((err (catch #t
				       (lambda () (set! (n arg1) arg2))
				       (lambda args (car args)))))
		       (if (eq? err 'wrong-number-of-args)
			   (snd-display #__line__ ";set-procs1: ~A ~A" err (procedure-property n 'documentation)))))
		   set-procs1))
		main-args))
	     main-args)
	    
	    ;; ---------------- set! 2 Args
	    (for-each 
	     (lambda (arg1)
	       (for-each 
		(lambda (arg2)
		  (for-each 
		   (lambda (arg3)
		     (for-each 
		      (lambda (n)
			(let ((err (catch #t
					  (lambda () (set! (n arg1 arg2) arg3))
					  (lambda args (car args)))))
			  (if (eq? err 'wrong-number-of-args)
			      (snd-display #__line__ ";set-procs2: ~A ~A" err (procedure-property n 'documentation)))))
		      set-procs2))
		   less-args))
		less-args))
	     less-args)
	    
	    (if (and all-args (= test-28 0))
		;; these can take awhile...
		(begin
		  
		  (snd-display #__line__ ";3 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- 3 Args
		  (for-each 
		   (lambda (arg1)
		     (begin
		       (for-each
			(lambda (arg2)
			  (for-each 
			   (lambda (arg3)
			     (for-each
			      (lambda (n)
				(let ((err (catch #t
						  (lambda () (n arg1 arg2 arg3))
						  (lambda args (car args)))))
				  (if (eq? err 'wrong-number-of-args)
				      (snd-display #__line__ ";procs3: ~A ~A" err (procedure-property n 'documentation)))))
			      procs3))
			   less-args))
			less-args)))
		   less-args)
		  
		  (snd-display #__line__ ";set 3 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- set! 3 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each 
			       (lambda (n)
				 (let ((err (catch #t
						   (lambda () (set! (n arg1 arg2 arg3) arg4))
						   (lambda args (car args)))))
				   (if (eq? err 'wrong-number-of-args)
				       (snd-display #__line__ ";set-procs3: ~A ~A" err (procedure-property n 'documentation)))))
			       set-procs3))
			    less-args))
			 less-args))
		      less-args))
		   less-args)
		  
		  (snd-display #__line__ ";4 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- 4 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each
			       (lambda (n)
				 (let ((err (catch #t
						   (lambda () (n arg1 arg2 arg3 arg4))
						   (lambda args (car args)))))
				   (if (eq? err 'wrong-number-of-args)
				       (snd-display #__line__ ";procs4: ~A ~A ~A" err n (procedure-property n 'documentation)))))
			       procs4))
			    few-args))
			 few-args))
		      few-args))
		   few-args)
		  
		  (snd-display #__line__ ";set 4 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- set! 4 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each 
			       (lambda (arg5)
				 (for-each 
				  (lambda (n)
				    (let ((err (catch #t
						      (lambda () (set! (n arg1 arg2 arg3 arg4) arg5))
						      (lambda args (car args)))))
				      (if (eq? err 'wrong-number-of-args)
					  (snd-display #__line__ ";set-procs4: ~A ~A" err (procedure-property n 'documentation)))))
				  set-procs4))
			       fewer-args))
			    fewer-args))
			 fewer-args))
		      fewer-args))
		   fewer-args)
		  
		  (clear-sincs)
		  (stop-playing)
		  (snd-display #__line__ ";5 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- 5 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each
			       (lambda (arg5)
				 (for-each 
				  (lambda (n)
				    (let ((err (catch #t
						      (lambda () (n arg1 arg2 arg3 arg4 arg5))
						      (lambda args (car args)))))
				      (if (eq? err 'wrong-number-of-args)
					  (snd-display #__line__ ";procs5: ~A ~A ~A" err n (procedure-property n 'documentation)))))
				  procs5))
			       fewer-args))
			    fewer-args))
			 fewer-args))
		      fewer-args))
		   fewer-args)
		  
		  (clear-sincs)
		  (snd-display #__line__ ";6 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- 6 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each
			       (lambda (arg5)
				 (for-each 
				  (lambda (arg6)
				    (for-each 
				     (lambda (n)
				       (let ((err (catch #t
							 (lambda () (n arg1 arg2 arg3 arg4 arg5 arg6))
							 (lambda args (car args)))))
					 (if (eq? err 'wrong-number-of-args)
					     (snd-display #__line__ ";procs6: ~A ~A" err (procedure-property n 'documentation)))))
				     procs6))
				  (list 1.5 "/hiho" -1234 -1 0 #f #t '() vct-3 delay-32)))
			       (list 1.5 "/hiho" -1234 0 vct-5 #f #t delay-32)))
			    (list 1.5 "/hiho" -1234 vct-3 #f #t delay-32)))
			 (list 1.5 "/hiho" -1234 vct-3 -1 #f #t delay-32)))
		      (list 1.5 -1234 vct-3 vct-5 -1 0 #f #t delay-32)))
		   (list 1.5 "/hiho" -1234 #f #t vct-5 delay-32))
		  
		  (snd-display #__line__ ";8 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- 8 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each
			       (lambda (arg5)
				 (for-each 
				  (lambda (arg6)
				    (for-each 
				     (lambda (arg7)
				       (for-each 
					(lambda (arg8)
					  (for-each 
					   (lambda (n)
					     (let ((err (catch #t
							       (lambda () (n arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8))
							       (lambda args (car args)))))
					       (if (eq? err 'wrong-number-of-args)
						   (snd-display #__line__ ";procs8: ~A ~A" err (procedure-property n 'documentation)))))
					   procs8))
					(list 1.5 -1 1234 #f '() delay-32)))
				     (list "/hiho" -1 1234 '() vct-5 delay-32)))
				  (list #t #f -1 1234 '() vct-3 delay-32)))
			       (list (sqrt -1.0) 1234 0 -1 '() delay-32)))
			    (list 1.5 -1 #f 1234 vct-3 '() delay-32)))
			 (list 2 #f #t 1234 vct-5 -1 delay-32)))
		      (list #f #t -1 1234 vct-3 delay-32)))
		   (list 1.5 -1 '() 1234 "/hiho" delay-32))
		  
		  (clear-sincs)
		  (snd-display #__line__ ";10 args: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
		  
		  ;; ---------------- 10 Args
		  (for-each 
		   (lambda (arg1)
		     (for-each 
		      (lambda (arg2)
			(for-each 
			 (lambda (arg3)
			   (for-each 
			    (lambda (arg4)
			      (for-each
			       (lambda (arg5)
				 (for-each 
				  (lambda (arg6)
				    (for-each 
				     (lambda (arg7)
				       (for-each 
					(lambda (arg8)
					  (for-each 
					   (lambda (arg9)
					     (for-each 
					      (lambda (arg10)
						(for-each 
						 (lambda (n)
						   (let ((err (catch #t
								     (lambda () (n arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10))
								     (lambda args (car args)))))
						     (if (eq? err 'wrong-number-of-args)
							 (snd-display #__line__ ";procs10: ~A ~A" err (procedure-property n 'documentation)))))
						 procs10))
					      (list 1.5 -1 #f 1234 delay-32)))
					   (list "/hiho" -1 1234 delay-32)))
					(list #t #f vct-3 1234 delay-32)))
				     (list (sqrt -1.0) #f -1 vct-5 delay-32)))
				  (list 1.5 #f -1 1234 '() delay-32)))
			       (list -2 #f 1234 vct-3 delay-32)))
			    (list #f #t '() 1234 vct-5 delay-32)))
			 (list 1.5 -1 "/hiho" '() delay-32)))
		      (list 1.5 -1 '() delay-32)))
		   (list #f -1 1234 delay-32))
		  ))))
	
	(snd-display #__line__ ";end args")
	
	(if (defined? 'mus-audio-reinitialize) (mus-audio-reinitialize))
	(set! (window-y) 10)
	(dismiss-all-dialogs)
	
	(if (file-exists? "test.snd")
	    (begin
	      (system "chmod 644 test.snd")
	      (delete-file "test.snd")))
	
	(copy-file "oboe.snd" "test.snd")
	(let ((ind (open-sound "test.snd")))
	  (delete-file "test.snd")
	  (let ((tag (catch #t
			    (lambda ()
			      (update-sound ind))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'cant-update-file))
		(snd-display #__line__ ";update-sound after deletion: ~A" tag)))
	  (delete-sample 10)
	  (let ((tag (catch #t
			    (lambda () (save-sound ind))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'cannot-save))
		(snd-display #__line__ ";save file deleted: ~A" tag)))
	  (close-sound ind))
	
	(copy-file "oboe.snd" "test.snd")
	(let ((ind (open-sound "test.snd"))
	      (reg (select-all)))
	  (delete-file "test.snd")
	  (view-regions-dialog)
	  (dismiss-all-dialogs)
	  (close-sound ind))
	
	(copy-file "oboe.snd" "test.snd")
	(let ((ind (open-sound "test.snd")))
	  (system "chmod 400 test.snd")
	  (delete-sample 10)
	  (let ((tag (catch #t
			    (lambda () (save-sound ind))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'cannot-save))
		(snd-display #__line__ ";save protected sound msg: ~A" tag)))
	  (close-sound ind))
	
	(system "chmod 644 test.snd")
	(delete-file "test.snd")
	
	(copy-file "oboe.snd" "test.snd")
	(system "chmod 400 test.snd")
	(let ((ind (open-sound "oboe.snd")))
	  (delete-sample 10)
	  (let ((tag
		 (catch #t
			(lambda () (save-sound-as "test.snd"))
			(lambda args (car args)))))
	    (if (not (eq? tag 'cannot-save))
		(snd-display #__line__ ";save-as write-protected sound: ~A" tag)))
	  (close-sound ind))
	(system "chmod 644 test.snd")
	(delete-file "test.snd")
	
	;; these redefine several basic names ("tap"), so they're not in test 23
	(if all-args
	    (begin
	      (snd-display #__line__ ";away and colony5: ~A~%" (strftime "%d-%b %H:%M %Z" (localtime (current-time))))
	      
	      (set! (optimization) 6)
	      (set! *clm-table-size* 512)
	      (set! *clm-file-buffer-size* (* 1024 1024))
	      (if (and (file-exists? "away.scm")
		       (file-exists? "away.frb"))
		  (begin
		    (let ((val (simple-time (load "away.scm"))))
		      (snd-display #__line__ ";away: ~A" val))
		    (for-each close-sound (sounds))
		    (if (file-exists? "a.snd") (delete-file "a.snd"))
		    (if (file-exists? "ar.snd") (delete-file "ar.snd"))))
	      (if (file-exists? "colony5.scm")
		  (begin
		    (let ((val (simple-time (load "colony5.scm"))))
		      (snd-display #__line__ ";colony 5: ~A" val))
		    (for-each close-sound (sounds))
		    (if (file-exists? "col5.snd") (delete-file "col5.snd"))
		    (if (file-exists? "reverb.snd") (delete-file "reverb.snd"))))))
	
	;; close-sound cases that are nutty...
	
	(let ((tag (catch #t
			  (lambda ()
			    (let ((ind (open-sound "oboe.snd")))
			      (map-channel
			       (lambda (y)
				 (if (sound? ind)
				     (close-sound ind))
				 0.0))))
			  (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-channel)) (snd-display #__line__ ";map-channel closing own chan: ~A" tag)))
	
	#|
	;; this will return a truncated (at the start) result, but I currently can't think of a
	;;    reasonable way to disallow it.  We either need a before-undo-hook, or edit-hook that is
	;;    local to the map-channel lambda (so that we can remove it before map-channel itself
	;;    wants to edit, but adding/removing it on every call seems silly).
	
	(let ((ind (open-sound "oboe.snd"))
	(ctr 0))
	(set! (sample 100) .5)
	(map-channel (lambda (y)
	(if (= ctr 0)
	(begin
	(revert-sound ind)
	(set! (sample 200) .6)))
	(set! ctr (+ 1 ctr))
	(* y 3))))
	|#	
	
	(let ((ind1 (open-sound "oboe.snd"))
	      (ind2 (open-sound "pistol.snd")))
	  (as-one-edit
	   (lambda ()
	     (close-sound ind1)
	     (close-sound ind2))))
	
	(let ((ind1 (open-sound "oboe.snd"))
	      (ind2 (open-sound "pistol.snd")))
	  (as-one-edit
	   (lambda ()
	     (set! (sample 100 ind1 0) .1)
	     (set! (sample 200 ind2 0) .1)
	     (as-one-edit
	      (lambda ()
		(close-sound ind1)
		(close-sound ind2))
	      "inner edit"))
	   "outer edit"))
	
	(let ((ind (open-sound "oboe.snd")))
	  (find-channel
	   (lambda (y)
	     (if (sound? ind)
		 (close-sound ind))
	     #f)))
	
	(let ((ind (open-sound "oboe.snd")))
	  (let ((rd (make-sampler 0)))
	    (close-sound ind)
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (read-sample rd))
	    (let ((home (sampler-home rd)))
	      (if (and (list? home)
		       (sound? (car home)))
		  (snd-display #__line__ ";reader-home of closed sound: ~A ~A" home (sounds))))
	    (let ((loc (sampler-position rd)))
	      (if (not (= loc 0))
		  (snd-display #__line__ ";closed reader position: ~A" loc)))
	    (let ((at-end (sampler-at-end? rd)))
	      (if (not at-end)
		  (snd-display #__line__ ";closed sampler at end: ~A" at-end)))))
	
	(let ((ind (open-sound "oboe.snd")))
	  (let ((mx (mix-vct (vct .1 .2 .3))))
	    (let ((rd (make-mix-sampler mx)))
	      (close-sound ind)
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(read-mix-sample rd)))))
	
	(set! (max-regions) (max 8 (max-regions)))
	(let ((ind (open-sound "oboe.snd")))
	  (let ((reg (make-region 0 100 ind 0)))
	    (let ((rd (make-region-sampler reg 0)))
	      (close-sound ind)
	      (forget-region reg)
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(read-sample rd)))))
	
	(let ((ind (open-sound "oboe.snd"))
	      (scl 1.0))
	  (set! (sample 100 ind 0) .5)
	  (map-channel (lambda (y)
			 (if (> y .4)
			     (let* ((mx 0.0))
			       (scan-channel (lambda (x)
					       (set! mx (max mx (abs x)))
					       #f))
			       (set! scl (/ 1.0 mx))))
			 (* scl y)))
	  (if (fneq (sample 100 ind 0) 1.0) (snd-display #__line__ ";scan + map 100: ~A" (sample 100 ind 0)))
	  (revert-sound ind)
	  
	  (set! (sample 100 ind 0) .5)
	  (map-channel (lambda (y)
			 (if (> y .4)
			     (set! (frames ind 0) 1))
			 y))
	  (if (fneq (sample 100 ind 0) 0.5) (snd-display #__line__ ";map + reset frames: ~A" (sample 100 ind 0)))
	  (if (not (= (frames ind 0) 50828)) (snd-display #__line__ ";map + reset frames, frames: ~A" (frames ind 0)))
	  (undo 1 ind 0)
	  (if (not (= (frames ind 0) 1)) (snd-display #__line__ ";map + reset frames, undo frames: ~A" (frames ind 0)))
	  (revert-sound ind)
	  
	  (set! (sample 100 ind 0) .5)
					;(let ((tag (catch #t (lambda () (set! (frames ind 0 1) 1)) (lambda args (car args)))))
					;  (if (not (eq? tag 'wrong-number-of-args)) (snd-display #__line__ ";set frames + edpos: ~A" tag)))
	  (revert-sound ind)
	  
	  (let ((tag (catch #t (lambda () (map-channel (lambda (y) (* y 0.0+1.0i)))) (lambda args (car args)))))
	    (if (not (eq? tag 'bad-type)) (snd-display #__line__ ";map-channel rtn complex: ~A" tag)))
	  
	  (let ((rd (make-sampler 0)))
	    (do ((i 0 (+ 1 i)))
		((= i 10))
	      (rd))
	    (let ((crd (copy-sampler rd)))
	      (close-sound ind)
	      (do ((i 0 (+ 1 i)))
		  ((= i 10))
		(read-sample crd))
	      (let ((home (sampler-home crd)))
		(if (and (list? home)
			 (sound? (car home)))
		    (snd-display #__line__ ";copy reader-home of closed sound: ~A ~A" home (sounds))))
	      (let ((loc (sampler-position crd)))
		(if (not (= loc 0))
		    (snd-display #__line__ ";closed copy reader position: ~A" loc)))
	      (let ((at-end (sampler-at-end? crd)))
		(if (not at-end)
		    (snd-display #__line__ ";closed copy sampler at end: ~A" at-end)))))
	  
	  (let ((tag (catch #t (lambda () (revert-sound ind)) (lambda args (car args)))))
	    (if (not (eq? tag 'no-such-sound)) (snd-display #__line__ ";revert-sound of closed sound: ~A" tag)))
	  
	  (set! ind (open-sound "oboe.snd")) ; closed in copy case above
	  (set! (sample 100 ind 0) .5)
	  (let ((tag (catch #t 
			    (lambda () (scale-channel .5 0 100 ind 0 (lambda () (close-sound ind) current-edit-position)))
			    (lambda args (car args)))))
	    (if (not (eq? tag 'bad-arity)) (snd-display #__line__ ";edpos proc bad args: ~A" tag)))
	  
	  (if (not (sound? ind)) (snd-display #__line__ ";edpos bad arity proc clobbers chan?? ~A" ind))
	  )
	
	(set! env3 #f)
	(set! delay-32 #f)
	(set! color-95 #f)
	(set! vector-0 #f)
	(set! vct-3 #f)
	(set! sound-data-23 #f)
	(set! (mus-srate) 22050)
	(set! *clm-srate* 22050)
	(set! (print-length) 12)
	(set! (mus-array-print-length) 12)
	(set! (sound-file-extensions) exts)
	(set! car-main #f)
	(set! cadr-main #f)
	(set! a-hook #f)
	(set! a-sound #f)
	(set! vct-5 #f)
	
	)))

					;(tracing #t)

(define test-funcs (make-vector (+ 1 total-tests)))
(vector-set! test-funcs 0 snd_test_0)
(vector-set! test-funcs 1 snd_test_1)
(vector-set! test-funcs 2 snd_test_2)
(vector-set! test-funcs 3 snd_test_3)
(vector-set! test-funcs 4 snd_test_4)
(vector-set! test-funcs 5 snd_test_5)
(vector-set! test-funcs 6 snd_test_6)
(vector-set! test-funcs 7 snd_test_7)
(vector-set! test-funcs 8 snd_test_8)
(vector-set! test-funcs 9 snd_test_9)
(vector-set! test-funcs 10 snd_test_10)
(vector-set! test-funcs 11 snd_test_11)
(vector-set! test-funcs 12 snd_test_12)
(vector-set! test-funcs 13 snd_test_13)
(vector-set! test-funcs 14 snd_test_14)
(vector-set! test-funcs 15 snd_test_15)
(vector-set! test-funcs 16 snd_test_16)
(vector-set! test-funcs 17 snd_test_17)
(vector-set! test-funcs 18 snd_test_18)
(vector-set! test-funcs 19 snd_test_19)
(vector-set! test-funcs 20 snd_test_20)
(vector-set! test-funcs 21 snd_test_21)
(vector-set! test-funcs 22 snd_test_22)
(vector-set! test-funcs 23 snd_test_23)
(vector-set! test-funcs 24 snd_test_24)
(vector-set! test-funcs 25 snd_test_25)
(vector-set! test-funcs 26 snd_test_26)
(vector-set! test-funcs 27 snd_test_27)
(vector-set! test-funcs 28 snd_test_28)

(if (> test-at-random 0)
    (begin                                       ; run tests in any random order
      (do ((i 0 (+ 1 i)))
	  ((= i test-at-random))
	(set! snd-test (min 23 (random 24)))
	(display (format #f "~%~A: ~A" i snd-test))
	(run-hook before-test-hook snd-test)
	((vector-ref test-funcs snd-test))
	(run-hook after-test-hook snd-test)
	))
    
    (if (and (not full-test)
	     (not keep-going)
	     (>= snd-test 0))
	(begin                                   ; run one test
	  (run-hook before-test-hook snd-test)
	  ((vector-ref test-funcs snd-test))
	  (run-hook after-test-hook snd-test))
	
	(do ((i 0 (+ 1 i)))                       ; run all tests except the irritating ones
	    ((> i total-tests))
	  (if (and (or (< i 24)
		       (> i 26))
		   (or full-test 
		       (and keep-going (<= snd-test i))))
	      (begin
		(run-hook before-test-hook i)
		((vector-ref test-funcs i))
		(run-hook after-test-hook i))))))


;;; ---------------- test all done

(let ((regs (regions)))
  (for-each
   (lambda (n)
     (forget-region n))
   regs))
(set! (view-files-sort) 0)

(clear-sincs)
(stop-playing)
(mus-oss-set-buffers 4 12)

(reset-almost-all-hooks)

(close-output-port optimizer-log)

(if (and full-test
	 (= test-at-random 0)
	 (= tests 1)
	 (file-exists? "oldopt.log"))
    (system "diff -w optimizer.log oldopt.log"))

(save-listener "test.output")
(set! (listener-prompt) original-prompt)
(clear-listener)
(set! (show-listener) #t)

(display (format #f "~%;all done!~%~A" original-prompt))

(set! (print-length) 64)
(display (format #f "~%;times: ~A~%;total: ~A~%" timings (round (- (real-time) overall-start-time))))

(let ((best-times (vector 59 58 114 95 2244 5373 613 134 11680 2892 609 743 868 976 815 1288 3020 197 168 2952 758 1925 4997 6567 846  183 0 242 6696))) ; 571
  (do ((i 0 (+ 1 i)))
      ((= i (vector-length timings)))
    (if (and (> (vector-ref timings i) 0)
	     (> (vector-ref best-times i) 0))
	(vector-set! best-times i (exact->inexact (/ (vector-ref timings i) (vector-ref best-times i))))
	(vector-set! best-times i 0.0)))
  (display (format #f ";ratios: ("))
  (do ((i 0 (+ 1 i)))
      ((= i (vector-length timings)))
    (if (< (vector-ref best-times i) 10.0)
	(display (format #f "~1,1F " (vector-ref best-times i)))
	(display (format #f "(test ~D:) ~1,1F " i (vector-ref best-times i)))))
  (display (format #f ")~%~%")))

;;; -------- cleanup temp files

(if (provided? 'snd-nogui)
    (set! (max-regions) 0))

(if (file-exists? "saved-snd.scm") (delete-file "saved-snd.scm"))
(if (file-exists? original-save-dir)
    (begin
      (display (format #f "ls ~A/snd_* | wc~%" original-save-dir))
      (system (format #f "ls ~A/snd_* | wc" original-save-dir))
      (system (format #f "rm -f ~A/snd_*" original-save-dir))))

(if (file-exists? original-temp-dir)
    (begin
      (display (format #f "ls ~A/snd_* | wc~%" original-temp-dir))
      (system (format #f "ls ~A/snd_* | wc" original-temp-dir))
      (system (format #f "rm -f ~A/snd_*" original-temp-dir))))

(if (file-exists? "/tmp")
    (begin
      (display (format #f "ls /tmp/snd_* | wc~%"))
      (system "ls /tmp/snd_* | wc")
      (system "rm -f /tmp/snd_*")
      (system "ls /tmp/file*.snd | wc")
      (system "rm -f /tmp/file*.snd")))

(if (file-exists? "/var/tmp")
    (begin
      (display (format #f "ls /var/tmp/snd_* | wc~%"))
      (system "ls /var/tmp/snd_* | wc")
      (system "rm -f /var/tmp/snd_*")
      (system "ls /var/tmp/file*.snd | wc")
      (system "rm -f /var/tmp/file*.snd")))

(if (defined? 'dlocsig-speaker-configs) (set! dlocsig-speaker-configs #f))

(for-each
 (lambda (f)
   (if (file-exists? f)
       (delete-file f)))
 (list 
  "aaa.eps"
  "envs.save"
  "fmv.snd"
  "fmv.wav"
  "fmv0.snd"
  "fmv1.snd"
  "fmv2.snd"
  "fmv3.snd"
  "fmv4.reverb"
  "fmv4.snd"
  "hiho.marks"
  "hiho.snd"
  "hiho.snd"
  "hiho.tmp"
  "hiho.wave"
  "ho"
  "new.snd"
  "oboe.marks"
  "obtest.snd.stereo"
  "snd.eps"
  "test-1.snd"
  "test-2.snd"
  "test-macros.scm"
  "test.aiff"
  "testx.data"
  "test.output"
  "test.rev"
  "test.reverb"
  "test.snd"
  "test.snd.snd"
  "test.wav"
  "test.xpm"
  "test2.snd"
  "test3.snd"
  "tmp.snd"
  "with-mix.snd"
  "1"
  "gtk-errors"
  "accelmap"
  ".snd-remember-sound"
  "test.clm"
  "hiho.scm"
  
  (string-append sf-dir "mus10.snd.snd")
  (string-append sf-dir "ieee-text-16.snd.snd")
  (string-append sf-dir "trumps22.adp.snd")
  (string-append sf-dir "oki.wav.snd")
  (string-append sf-dir "nasahal.avi.snd")
  (string-append sf-dir "hcom-16.snd.snd")
  (string-append sf-dir "ce-c3.w02.snd")
  (string-append sf-dir "oboe.g723_24.snd")
  (string-append sf-dir "oboe.g723_40.snd")
  (string-append sf-dir "oboe.g721.snd")
  (string-append sf-dir "wood.sds.snd")
  (string-append sf-dir "o2_dvi.wave.snd")
  (string-append sf-dir "nist-shortpack.wav.snd")
  (string-append sf-dir "bad_data_format.snd.snd")
  ))

(if (file-exists? "/home/bil/peaks")
    (system "rm /home/bil/peaks/*"))

(for-each close-sound (sounds))
(mus-sound-prune)
(if (dialog-widgets)
    (let ((vfs (list-ref (dialog-widgets) 8))) ; view-files (possible list)
      (if vfs
	  (if (symbol? (car vfs))
	      (set! (view-files-files vfs) '())
	      (for-each
	       (lambda (d)
		 (set! (view-files-files d) '()))
	       vfs)))))


(if (defined? 'run-report-counts) (run-report-counts))

(if profiling (profile)) ; writes to sort.data

#|
(let ((st (symbol-table)))
  (do ((i 0 (+ i 1))) 
      ((= i (vector-length st)))
    (let ((lst (vector-ref st i)))
      (for-each 
       (lambda (sym)
	 (if (defined? sym)
	     (let ((val (symbol->value sym)))
	       (if (and (procedure? val)
			(string=? "" (procedure-documentation val)))
		   (format #t "~A " sym)))))
       lst))))
|#

(if with-exit (exit))

;;; ---------------- test the end


#|
valgrind --tool=callgrind snd -l snd-test
callgrind_annotate --auto=yes callgrind.out.<pid> > hi

10-Feb-10 (full snd-test, not just test 23):
372,028,372,850  PROGRAM TOTALS
45,638,227,518  io.c:mus_read_any_1 [/home/bil/snd-11/snd]
44,386,146,639  s7.c:eval [/home/bil/snd-11/snd]
26,599,493,642  s7.c:eval'2 [/home/bil/snd-11/snd]
20,950,395,846  s7.c:gc [/home/bil/snd-11/snd]
20,800,612,761  snd-edits.c:next_sample_value_unscaled [/home/bil/snd-11/snd]
17,699,734,242  snd-edits.c:channel_local_maxamp [/home/bil/snd-11/snd]
14,661,979,458  io.c:mus_write_1 [/home/bil/snd-11/snd]
14,486,041,393  snd-sig.c:direct_filter [/home/bil/snd-11/snd]
10,836,543,187  run.c:eval_ptree [/home/bil/snd-11/snd]
6,663,065,404  /home/bil/test/gsl-1.13/linalg/householder.c:gsl_linalg_householder_mh [/usr/local/lib/libgsl.so.0.14.0]
4,848,628,373  ???:memset [/lib/ld-2.9.so]
4,354,124,652  clm.c:mus_out_any_to_file [/home/bil/snd-11/snd]
4,081,657,874  clm.c:mus_fir_filter [/home/bil/snd-11/snd]
3,881,809,674  snd-edits.c:next_sample_value [/home/bil/snd-11/snd]
3,676,951,173  clm.c:mus_src [/home/bil/snd-11/snd]
3,588,422,788  /home/bil/test/gsl-1.13/linalg/householder.c:gsl_linalg_householder_hm [/usr/local/lib/libgsl.so.0.14.0]
3,166,989,992  run.c:jump_if_not_equal [/home/bil/snd-11/snd]
2,997,117,922  s7.c:g_add [/home/bil/snd-11/snd]
2,761,768,633  s7.c:s7_mark_object_1'2 [/home/bil/snd-11/snd]
2,568,586,593  s7.c:s7_make_real [/home/bil/snd-11/snd]
2,533,319,957  xen.c:xen_s7_type_p [/home/bil/snd-11/snd]
2,450,756,818  /home/bil/test/gsl-1.13/linalg/../gsl/gsl_matrix_double.h:gsl_linalg_householder_mh
2,389,660,542  clm.c:mus_phase_vocoder_with_editors [/home/bil/snd-11/snd]
2,383,913,072  s7.c:copy_object'2 [/home/bil/snd-11/snd]
2,119,836,764  s7.c:s7_cons [/home/bil/snd-11/snd]
2,118,663,239  s7.c:new_cell [/home/bil/snd-11/snd]
1,815,226,062  s7.c:s7_object_value [/home/bil/snd-11/snd]

7-Mar-10
318,148,021,968  PROGRAM TOTALS
40,864,919,790  s7.c:eval [/home/bil/snd-s7/snd]
26,485,168,742  io.c:mus_read_any_1 [/home/bil/snd-s7/snd]
24,338,113,084  s7.c:eval'2 [/home/bil/snd-s7/snd]
21,345,385,043  snd-edits.c:next_sample_value_unscaled [/home/bil/snd-s7/snd]
18,089,464,229  snd-edits.c:channel_local_maxamp [/home/bil/snd-s7/snd]
16,230,371,673  s7.c:gc [/home/bil/snd-s7/snd]
10,973,188,812  io.c:mus_write_1 [/home/bil/snd-s7/snd]
10,939,541,547  run.c:eval_ptree [/home/bil/snd-s7/snd]
8,918,483,945  snd-sig.c:direct_filter [/home/bil/snd-s7/snd]
7,030,924,951  s7.c:s7_mark_object_1'2 [/home/bil/snd-s7/snd]
6,663,065,404  /home/bil/test/gsl-1.13/linalg/householder.c:gsl_linalg_householder_mh [/usr/local/lib/libgsl.so.0.14.0]
3,946,755,027  clm.c:mus_out_any_to_file [/home/bil/snd-s7/snd]
3,702,560,061  snd-edits.c:next_sample_value [/home/bil/snd-s7/snd]
3,675,942,470  clm.c:mus_src [/home/bil/snd-s7/snd]
3,588,422,788  /home/bil/test/gsl-1.13/linalg/householder.c:gsl_linalg_householder_hm [/usr/local/lib/libgsl.so.0.14.0]
3,173,655,679  run.c:jump_if_not_equal [/home/bil/snd-s7/snd]
2,997,971,312  clm.c:mus_fir_filter [/home/bil/snd-s7/snd]
2,572,480,120  s7.c:g_add [/home/bil/snd-s7/snd]
2,450,756,818  /home/bil/test/gsl-1.13/linalg/../gsl/gsl_matrix_double.h:gsl_linalg_householder_mh
2,389,660,564  clm.c:mus_phase_vocoder_with_editors [/home/bil/snd-s7/snd]
2,383,162,838  s7.c:s7_make_real [/home/bil/snd-s7/snd]
2,256,089,964  clm.c:mus_formant [/home/bil/snd-s7/snd]
|#

