;;; Snd tests
;;;
;;;  test 0: constants                          [359]
;;;  test 1: defaults                           [911]
;;;  test 2: headers                            [1085]
;;;  test 3: variables                          [1384]
;;;  test 4: sndlib                             [1772]
;;;  test 5: simple overall checks              [3581]
;;;  test 6: vcts                               [10823]
;;;  test 7: colors                             [11057]
;;;  test 8: clm                                [11553]
;;;  test 9: mix                                [17813]
;;;  test 10: marks                             [20877]
;;;  test 11: dialogs                           [21574]
;;;  test 12: extensions                        [21891]
;;;  test 13: menus, edit lists, hooks, etc     [22305]
;;;  test 14: all together now                  [23575]
;;;  test 15: chan-local vars                   [24626]
;;;  test 16: regularized funcs                 [25886]
;;;  test 17: dialogs and graphics              [30223]
;;;  test 18: enved                             [30297]
;;;  test 19: save and restore                  [30317]
;;;  test 20: transforms                        [31790]
;;;  test 21: new stuff                         [32874]
;;;  test 22: run                               [33633]
;;;  test 23: with-sound                        [38715]
;;;  test 24: user-interface                    [39700]
;;;  test 25: X/Xt/Xm                           [42862]
;;;  test 26: Gtk                               [47381]
;;;  test 27: GL                                [50492]
;;;  test 28: errors                            [50596]
;;;  test all done                              [52596]
;;;
;;; how to send ourselves a drop?  (button2 on menu is only the first half -- how to force 2nd?)
;;; need all html example code in autotests
;;; need some way to check that graphs are actually drawn (region dialog, oscope etc) and sounds played correctly

(use-modules (ice-9 format) (ice-9 debug) (ice-9 optargs) (ice-9 popen))

;(setlocale LC_ALL "de_DE")

(define tests 1)
(define keep-going #f)
(define all-args #f) ; huge arg testing
(define with-big-file #t)

(define (snd-display . args)
  (let ((str (if (null? (cdr args))
		 (car args)
		 (apply format #f args))))
    (newline) 
    (display str)
    (if (not (provided? 'snd-nogui))
	(begin
	  (snd-print #\newline)
	  (snd-print str)))))

(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)))

(set! (with-background-processes) #f)
(set! (show-backtrace) #t)

(define debugging-device-channels 2)

(define pi 3.141592653589793)
(define max-optimization 6)

;; start-playing-hook is only called when an indexed sound is played, not if play-mix etc -- need a way to hit all possible playback
(define mus-audio-playback-amp
  (make-procedure-with-setter
   (lambda ()
     (let ((vals (make-vct 32)))
       (mus-audio-mixer-read mus-audio-default mus-audio-amp 0 vals)
       (let ((ch0-amp (vct-ref vals 0)))
	 (mus-audio-mixer-read mus-audio-default mus-audio-amp 1 vals)
	 (let ((ch1-amp (vct-ref vals 0)))
	   (list ch0-amp ch1-amp)))))
   (lambda (val)
     (let ((vals (make-vct 32)))
       (vct-set! vals 0 val)
       (mus-audio-mixer-write mus-audio-default mus-audio-amp 0 vals)       
       (mus-audio-mixer-write mus-audio-default mus-audio-amp 1 vals)
       val))))

(define playback-amp 0.0)
(set! (mus-audio-playback-amp) playback-amp)

(define home-dir "/home/bil")
(if (file-exists? "/export/home/bil/cl/oboe.snd")
    (set! home-dir "/export/home/bil")
    (if (file-exists? "/Users/bill/cl/oboe.snd")
	(set! home-dir "/Users/bill")
	(if (file-exists? "/users/b/bil/cl/oboe.snd")
	    (set! home-dir "/users/b/bil"))))
(system (string-append "cp " home-dir "/.snd " home-dir "/dot-snd"))
(define cwd (string-append (getcwd) "/"))
(define sf-dir "/sf1")
(define sample-reader-tests 300)
(define original-save-dir (or (save-dir) "/zap/snd"))
(define original-temp-dir (or (temp-dir) "/zap/tmp"))
(debug-set! stack 0)
(debug-enable 'debug 'backtrace)
(read-enable 'positions)
(define (irandom n) (if (= n 0) 0 (inexact->exact (random n))))
(add-hook! bad-header-hook (lambda (n) #t))

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

(if (file-exists? "optimizer.log")
    (delete-file "optimizer.log"))
(define optimizer-log (open-output-file "optimizer.log"))
(reset-hook! optimization-hook)
(add-hook! optimization-hook 
	   (lambda (msg)
	     (display msg optimizer-log)
	     (newline optimizer-log)))

(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 ";;;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")))

(define (real-time) (exact->inexact (/ (get-internal-real-time) internal-time-units-per-second)))
(define (hundred n) (inexact->exact (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)))))

;(show-ptree 1)
(define original-prompt (listener-prompt))
(show-listener)
(set! (window-x) 600)
(set! (window-y) 10)

(define test14-file #f)
(define fneq (lambda (a b) (> (abs (- a b)) .001)))
(define ffneq (lambda (a b) (> (abs (- a b)) .01)))
(define fffneq (lambda (a b) (> (abs (- a b)) .1)))
(define (fneqerr val true-val err) (> (abs (- val true-val)) err))
(define (cneq a b)
  (or (> (abs (- (real-part a) (real-part b))) .001)
      (> (abs (- (imag-part a) (imag-part b))) .001)))

(define feql
  (lambda (a b)
    (if (null? a)
	(null? b)
	(if (null? b)
	    #f
	    (if (fneq (car a) (car b))
		#f
		(feql (cdr a) (cdr b)))))))
(define ffeql
  (lambda (a b)
    (if (list? a)
	(if (null? a)
	    (null? b)
	    (if (null? b)
		#f
		(if (fffneq (car a) (car b))
		    #f
		    (ffeql (cdr a) (cdr b)))))
	#f)))
(define fieql
  (lambda (a b)
    (if (null? a)
	(null? b)
	(if (null? b)
	    #f
	    (if (integer? (car a))
		(if (not (= (car a) (car b)))
		    #f
		    (if (fneq (car a) (car b))
			#f))
		(fieql (cdr a) (cdr b)))))))
(define fveql 
  (lambda (a b i)
    (if (null? b)
	#t
	(if (fneq (car b) (vct-ref a i))
	    #f
	    (fveql a (cdr b) (+ i 1))))))

(define (vequal v0 v1)
  (<= (vct-peak (vct-subtract! (vct-copy v0) v1)) .001))

(define (vvequal v0 v1)
  (<= (vct-peak (vct-subtract! (vct-copy v0) v1)) .00002))

(define (string-=? a b)
  (or (string=? a b)
      (let* ((alen (string-length a))
	     (blen (string-length b))
	     (j 0))
	(call-with-current-continuation
	 (lambda (return)
	   (do ((i 0 (1+ i)))
	       ((= i alen) (= 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)))
				 (return #f)
				 (set! j (1+ j))))
			   (return #f)))))))))))

(define ran-state (seed->random-state (current-time)))
(define my-random
  (lambda (n)
    (if (= n 0) 
	0 ;sigh...
	(random n ran-state))))

;(define rs (lambda (n) (< (my-random 1.0) n)))
(define rs (lambda (n) #t))

(if (not (defined? 'nan)) (define (nan) 0.0))

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

(snd-display ";;~A" (snd-version))
(define test-number -1)
(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)))
(add-hook! before-test-hook (lambda (n)
			      (set! test-number n)
			      (if (and (> n 0) (number? (vector-ref timings (- n 1))))
				  (vector-set! timings (- n 1) (hundred (- (real-time) (vector-ref timings (- n 1))))))
			      (vector-set! timings n (real-time))
			      (snd-display ";test ~D" n)
			      (gc)
			      (set! (show-backtrace) #f)
					;(snd-display (gc-stats))
					;(if (file-exists? "memlog")
					;	 (system (format #f "cp memlog memlog.~D" (1- n))))
					;(if (defined? 'mem-report) (mem-report))
			      ))

;(add-hook! after-test-hook (lambda (n) (snd-display ";...~D" n)))
(add-hook! after-test-hook
	   (lambda (n)
	     (gc)
	     (if (not (null? (sounds))) 
		 (snd-display ";test ~D: open sounds: ~A" n (map short-file-name (sounds))))))


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

(define (log-mem tst) 
  (if (> tests 1) (begin (snd-display ";test ~D " (1+ tst)) (gc)))
  (if (= (modulo tst 10) 0) (if (defined? 'mem-report) (mem-report))))

(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)
  (and (list? val)
       (not (null? val))))

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

(define (set-arity-ok func args)
  (let ((arity (if (procedure-with-setter? func)
		   (procedure-property (setter func) 'arity)
		   (procedure-property func 'arity))))
    (and (list-p arity)
	 (>= args (car arity))
	 (or (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 (1- arg)) "-l")) 
	  (snd-display ";script-args[~A]: ~A (~A)?" (1- arg) (list-ref args (1- arg)) args))
      (if (not (string=? (list-ref args arg) "snd-test")) 
	  (snd-display ";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! 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-event.scm)) (load "event.scm"))
      (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

;(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)


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

(if (or full-test (= snd-test 0) (and keep-going (<= snd-test 0)))
    (letrec ((test-constants 
	      (lambda (lst)
		(if (not (null? lst))
		    (begin
		      (if (not (= (cadr lst) (caddr lst)))
			  (snd-display ";~A /= ~A (~A)~%"
				       (car lst) (cadr lst) (caddr lst)))
		      (test-constants (cdddr lst)))))))
      (run-hook before-test-hook 0)
      (if (or (not (null? (sounds)))
	      (not (null? (mixes)))
	      (not (null? (marks)))
	      (not (null? (regions))))
	  (snd-display ";start up: ~A ~A ~A ~A" (sounds) (mixes) (marks) (regions)))
      (test-constants
       (list
	'enved-amplitude enved-amplitude 0 
	'autocorrelation autocorrelation 3
	'bartlett-window bartlett-window 4 
	'blackman2-window blackman2-window 6 
	'blackman3-window blackman3-window 7 
	'blackman4-window blackman4-window 8
	'cauchy-window cauchy-window 12 
	'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 
	'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 
	'fourier-transform fourier-transform 0 
	'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
	'haar-transform haar-transform 5
	'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
	'cepstrum cepstrum 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 
	'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 
	'walsh-transform walsh-transform 2
	'wavelet-transform wavelet-transform 1
	'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-seconds x-axis-in-seconds 0 
	'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
	
	;; 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 5
	'mus-raw mus-raw 11
	'mus-ircam mus-ircam 14
	'mus-aiff mus-aiff 48
	'mus-bicsf mus-bicsf 4
	'mus-voc mus-voc 9
	'mus-svx mus-svx 8
	'mus-soundfont mus-soundfont 25

	'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-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
	'mus-audio-default mus-audio-default 0
	'mus-audio-duplex-default mus-audio-duplex-default 1
	'mus-audio-line-out mus-audio-line-out 4
	'mus-audio-line-in mus-audio-line-in 5
	'mus-audio-microphone mus-audio-microphone 6
	'mus-audio-speakers mus-audio-speakers 7
	'mus-audio-dac-out mus-audio-dac-out 10
	'mus-audio-adat-in mus-audio-adat-in 2
	'mus-audio-aes-in mus-audio-aes-in 3
	'mus-audio-digital-in mus-audio-digital-in 8
	'mus-audio-digital-out mus-audio-digital-out 9
	'mus-audio-adat-out mus-audio-adat-out 11
	'mus-audio-aes-out mus-audio-aes-out 12
	'mus-audio-dac-filter mus-audio-dac-filter 13
	'mus-audio-mixer mus-audio-mixer 14
	'mus-audio-line1 mus-audio-line1 15
	'mus-audio-line2 mus-audio-line2 16
	'mus-audio-line3 mus-audio-line3 17
	'mus-audio-aux-input mus-audio-aux-input 18
	'mus-audio-cd mus-audio-cd 19
	'mus-audio-aux-output mus-audio-aux-output 20
	'mus-audio-spdif-in mus-audio-spdif-in 21
	'mus-audio-spdif-out mus-audio-spdif-out 22
	'mus-audio-amp mus-audio-amp 23
	'mus-audio-srate mus-audio-srate 24
	'mus-audio-channel mus-audio-channel 25
	'mus-audio-format mus-audio-format 26
	'mus-audio-port mus-audio-port 37
	'mus-audio-imix mus-audio-imix 27
	'mus-audio-igain mus-audio-igain 28
	'mus-audio-reclev mus-audio-reclev 29
	'mus-audio-pcm mus-audio-pcm 30
	'mus-audio-pcm2 mus-audio-pcm2 31
	'mus-audio-ogain mus-audio-ogain 32
	'mus-audio-line mus-audio-line 33
	'mus-audio-synth mus-audio-synth 34
	'mus-audio-bass mus-audio-bass 35
	'mus-audio-treble mus-audio-treble 36
	'mus-audio-direction mus-audio-direction 39
	'mus-audio-samples-per-channel mus-audio-samples-per-channel 38
	))
      
      (set! (region-graph-style) (region-graph-style))
      (if (not (equal? (region-graph-style) graph-lines))
	  (snd-display ";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 ";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 ";audio-output-device set def: ~A" (audio-output-device)))
      (set! (auto-resize) (auto-resize))
      (if (not (equal? (auto-resize)  #t )) 
	  (snd-display ";auto-resize set def: ~A" (auto-resize)))
      (set! (auto-update) (auto-update))
      (if (not (equal? (auto-update)  #f)) 
	  (snd-display ";auto-update set def: ~A" (auto-update)))
      (set! (channel-style) (channel-style))
      (if (not (equal? (channel-style)  0 )) 
	  (snd-display ";channel-style set def: ~A" (channel-style)))
      (set! (color-cutoff) (color-cutoff))
      (if (fneq (color-cutoff)  0.003 )
	  (snd-display ";color-cutoff set def: ~A" (color-cutoff)))
      (set! (color-inverted) (color-inverted))
      (if (not (equal? (color-inverted)  #t)) 
	  (snd-display ";color-inverted set def: ~A" (color-inverted)))
      (set! (color-scale) (color-scale))
      (if (fneq (color-scale)  1.0 )
	  (snd-display ";color-scale set def: ~A" (color-scale)))
      (set! (auto-update-interval) (auto-update-interval))
      (if (fneq (auto-update-interval)  60.0 )
	  (snd-display ";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 ";cursor-update-interval set def: ~A" (cursor-update-interval)))
      (set! (cursor-location-offset) (cursor-location-offset))
      (if (not (= (cursor-location-offset)  0))
	  (snd-display ";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 ";dac-combines-channels set def: ~A" (dac-combines-channels)))
      (set! (dac-size) (dac-size))
      (if (not (equal? (dac-size)  256 )) 
	  (snd-display ";dac-size set def: ~A" (dac-size)))
      (set! (minibuffer-history-length) (minibuffer-history-length))
      (if (not (equal? (minibuffer-history-length)  8)) 
	  (snd-display ";minibuffer-history-length set def: ~A" (minibuffer-history-length)))
      (set! (data-clipped) (data-clipped))
      (if (not (equal? (data-clipped)  #f )) 
	  (snd-display ";data-clipped set def: ~A" (data-clipped)))
      (set! (default-output-chans) (default-output-chans))
      (if (not (equal? (default-output-chans)  1 )) 
	  (snd-display ";default-output-chans set def: ~A" (default-output-chans)))
      (set! (default-output-format) (default-output-format))
      (if (not (equal? (default-output-format) mus-bshort)) 
	  (snd-display ";default-output-format set def: ~A" (default-output-format)))
      (set! (default-output-srate) (default-output-srate))
      (if (not (equal? (default-output-srate)  22050 )) 
	  (snd-display ";default-output-srate set def: ~A" (default-output-srate)))
      (set! (default-output-type) (default-output-type))
      (if (not (equal? (default-output-type)  mus-next)) 
	  (snd-display ";default-output-type set def: ~A" (default-output-type)))
      (set! (dot-size) (dot-size))
      (if (not (equal? (dot-size)  1 )) 
	  (snd-display ";dot-size set def: ~A" (dot-size)))
      (set! (cursor-size) (cursor-size))
      (if (not (equal? (cursor-size)  15 )) 
	  (snd-display ";cursor-size set def: ~A" (cursor-size)))
      (set! (cursor-style) (cursor-style))
      (if (not (equal? (cursor-style)  cursor-cross )) 
	  (snd-display ";cursor-style set def: ~A" (cursor-style)))
      (set! (emacs-style-save-as) (emacs-style-save-as))
      (if (not (equal? (emacs-style-save-as)  #f)) 
	  (snd-display ";emacs-style-save-as set def: ~A" (emacs-style-save-as)))
      (set! (enved-base) (enved-base))
      (if (fneq (enved-base)  1.0 )
	  (snd-display ";enved-base set def: ~A" (enved-base)))
      (set! (enved-clip?) (enved-clip?))
      (if (not (equal? (enved-clip?)  #f )) 
	  (snd-display ";enved-clip? set def: ~A" (enved-clip?)))
      (set! (enved-filter) (enved-filter))
      (if (not (equal? (enved-filter) #t)) 
	  (snd-display ";enved-filter set def: ~A" (enved-filter)))
      (set! (enved-filter-order) (enved-filter-order))
      (if (not (equal? (enved-filter-order)  40)) 
	  (snd-display ";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 ";enved-in-dB set def: ~A" (enved-in-dB)))
      (set! (enved-style) (enved-style))
      (if (not (equal? (enved-style)  envelope-linear )) 
	  (snd-display ";enved-style set def: ~A" (enved-style)))
      (set! (enved-power) (enved-power))
      (if (fneq (enved-power)  3.0)
	  (snd-display ";enved-power set def: ~A" (enved-power)))
      (set! (enved-target) (enved-target))
      (if (not (equal? (enved-target)  0 )) 
	  (snd-display ";enved-target set def: ~A" (enved-target)))
      (set! (enved-wave?) (enved-wave?))
      (if (not (equal? (enved-wave?)  #f )) 
	  (snd-display ";enved-wave? set def: ~A" (enved-wave?)))
      (if with-gui
	  (begin
	    (set! (enved-envelope) (enved-envelope))
	    (if (not (equal? (enved-envelope)  '())) 
		(snd-display ";enved-envelope set def: ~A" (enved-envelope)))))
      (set! (eps-file) (eps-file))
      (if (not (equal? (eps-file)  "snd.eps" )) 
	  (snd-display ";eps-file set def: ~A" (eps-file)))
      (set! (eps-bottom-margin) (eps-bottom-margin))
      (if (fneq (eps-bottom-margin)  0.0)
	  (snd-display ";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 ";eps-left-margin set def: ~A" (eps-left-margin)))
      (set! (eps-size) (eps-size))
      (if (fneq (eps-size)  1.0)
	  (snd-display ";eps-size set def: ~A" (eps-size)))
      (set! (fft-window-beta) (fft-window-beta))
      (if (fneq (fft-window-beta)  0.0 )
	  (snd-display ";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 ";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 ";fft-log-magnitude set def: ~A" (fft-log-magnitude)))
      (set! (transform-size) (transform-size))
      (if (not (equal? (transform-size)  512 )) 
	  (snd-display ";transform-size set def: ~A" (transform-size)))
      (set! (transform-graph-type) (transform-graph-type))
      (if (not (equal? (transform-graph-type) 0))
	  (snd-display ";transform-graph-type set def: ~A" (transform-graph-type)))
      (set! (fft-window) (fft-window))
      (if (not (equal? (fft-window)  6 )) 
	  (snd-display ";fft-window set def: ~A" (fft-window)))
      (set! (graph-cursor) (graph-cursor))
      (if (not (equal? (graph-cursor)  34)) 
	  (snd-display ";graph-cursor set def: ~A" (graph-cursor)))
      (set! (graph-style) (graph-style))
      (if (not (equal? (graph-style)  graph-lines )) 
	  (snd-display ";graph-style set def: ~A" (graph-style)))
      (set! (graphs-horizontal) (graphs-horizontal))
      (if (not (equal? (graphs-horizontal)  #t)) 
	  (snd-display ";graphs-horizontal set def: ~A" (graphs-horizontal)))
      (set! (html-dir) (html-dir))
      (if (not (equal? (html-dir)  ".")) 
	  (snd-display ";html-dir set def: ~A" (html-dir)))
      (set! (html-program) (html-program))
      (if (not (equal? (html-program)  "mozilla")) 
	  (snd-display ";html-program set def: ~A" (html-program)))
      (set! (just-sounds) (just-sounds))
      (if (not (equal? (just-sounds)  #f)) 
	  (snd-display ";just-sounds set def: ~A" (just-sounds)))
      (set! (listener-prompt) (listener-prompt))
      (if (not (equal? (listener-prompt)  ">" )) 
	  (snd-display ";listener-prompt set def: ~A" (listener-prompt)))
      (set! (max-transform-peaks) (max-transform-peaks))
      (if (not (equal? (max-transform-peaks)  100)) 
	  (snd-display ";max-transform-peaks set def: ~A" (max-transform-peaks)))
      (set! (max-transform-peaks) -123)
      (if (not (equal? (max-transform-peaks) 100)) 
	  (snd-display ";max-transform-peaks set -123: ~A" (max-transform-peaks)))
      (set! (max-regions) (max-regions))
      (if (not (equal? (max-regions)  16 )) 
	  (snd-display ";max-regions set def: ~A" (max-regions)))
      (set! (min-dB) (min-dB))
      (if (fneq (min-dB)  -60.0 )
	  (snd-display ";min-dB set def: ~A" (min-dB)))
      (set! (log-freq-start) (log-freq-start))
      (if (fneq (log-freq-start)  32.0 )
	  (snd-display ";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 ";selection-creates-region set def: ~A" (selection-creates-region)))
      (set! (transform-normalization) (transform-normalization))
      (if (not (equal? (transform-normalization)  normalize-by-channel)) 
	  (snd-display ";transform-normalization set def: ~A" (transform-normalization)))
      (set! (previous-files-sort) (previous-files-sort))
      (if (not (equal? (previous-files-sort)  0 )) 
	  (snd-display ";previous-files-sort set def: ~A" (previous-files-sort)))
      (set! (print-length) (print-length))
      (if (not (equal? (print-length)  12 )) 
	  (snd-display ";print-length set def: ~A" (print-length)))
      (set! (recorder-autoload) (recorder-autoload))
      (if (not (equal? (recorder-autoload)  #f)) 
	  (snd-display ";recorder-autoload set def: ~A" (recorder-autoload)))
      (set! (recorder-buffer-size) (recorder-buffer-size))
      (if (not (equal? (recorder-buffer-size)  4096 )) 
	  (snd-display ";recorder-buffer-size set def: ~A" (recorder-buffer-size)))
      (set! (recorder-file) (recorder-file))
      (if (not (equal? (recorder-file)  #f )) 
	  (snd-display ";recorder-file set def: ~A" (recorder-file)))
      (set! (recorder-max-duration) (recorder-max-duration))
      (if (fneq (recorder-max-duration)  1000000.0)
	  (snd-display ";recorder-max-duration set def: ~A" (recorder-max-duration)))
      (set! (recorder-out-chans) (recorder-out-chans))
      (if (not (equal? (recorder-out-chans)  2 )) 
	  (snd-display ";recorder-out-chans set def: ~A" (recorder-out-chans)))
      (set! (recorder-in-chans) (recorder-in-chans))
      (if (not (equal? (recorder-in-chans)  0 )) 
	  (snd-display ";recorder-in-chans set def: ~A" (recorder-in-chans)))
      (set! (recorder-srate) (recorder-srate))
      (if (not (equal? (recorder-srate)  22050 )) 
	  (snd-display ";recorder-srate set def: ~A" (recorder-srate)))
      (set! (recorder-trigger) (recorder-trigger))
      (if (fneq (recorder-trigger)  0.0)
	  (snd-display ";recorder-trigger set def: ~A" (recorder-trigger)))
      (set! (save-state-file) (save-state-file))
      (if (not (equal? (save-state-file)  "saved-snd.scm" )) 
	  (snd-display ";save-state-file set def: ~A" (save-state-file)))
      (set! (show-axes) (show-axes))
      (if (not (equal? (show-axes)  1)) 
	  (snd-display ";show-axes set def: ~A" (show-axes)))
      (set! (show-transform-peaks) (show-transform-peaks))
      (if (not (equal? (show-transform-peaks)  #f )) 
	  (snd-display ";show-transform-peaks set def: ~A" (show-transform-peaks)))
      (set! (show-indices) (show-indices))
      (if (not (equal? (show-indices)  #f)) 
	  (snd-display ";show-indices set def: ~A" (show-indices)))
      (set! (show-backtrace) (show-backtrace))
      (if (not (equal? (show-backtrace)  #f)) 
	  (snd-display ";show-backtrace set def: ~A" (show-backtrace)))
      (set! (show-marks) (show-marks))
      (if (not (equal? (show-marks)  #t )) 
	  (snd-display ";show-marks set def: ~A" (show-marks)))
      (set! (show-mix-waveforms) (show-mix-waveforms))
      (if (not (equal? (show-mix-waveforms)  #t)) 
	  (snd-display ";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 ";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 ";show-y-zero set def: ~A" (show-y-zero)))
      (set! (show-grid) (show-grid))
      (if (not (equal? (show-grid)  #f )) 
	  (snd-display ";show-grid set def: ~A" (show-grid)))
      (set! (grid-density) (grid-density))
      (if (fneq (grid-density) 1.0)
	  (snd-display ";grid-density set def: ~A" (grid-density)))
      (set! (show-sonogram-cursor) (show-sonogram-cursor))
      (if (not (equal? (show-sonogram-cursor)  #f )) 
	  (snd-display ";show-sonogram-cursor set def: ~A" (show-sonogram-cursor)))
      (set! (sinc-width) (sinc-width))
      (if (not (equal? (sinc-width)  10 )) 
	  (snd-display ";sinc-width set def: ~A" (sinc-width)))
      (set! (spectro-cutoff) (spectro-cutoff))
      (if (fneq (spectro-cutoff)  1.0)
	  (snd-display ";spectro-cutoff set def: ~A" (spectro-cutoff)))
      (set! (spectro-hop) (spectro-hop))
      (if (not (equal? (spectro-hop)  4 )) 
	  (snd-display ";spectro-hop set def: ~A" (spectro-hop)))
      (set! (spectro-start) (spectro-start))
      (if (fneq (spectro-start)  0.0 )
	  (snd-display ";spectro-start set def: ~A" (spectro-start)))
      (set! (spectro-x-angle) (spectro-x-angle))
      (if (fneq (spectro-x-angle)  (if (provided? 'gl) 300.0 90.0))
	  (snd-display ";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 ";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 ";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 ";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 ";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 ";spectro-z-scale set def: ~A" (spectro-z-scale)))
      (set! (temp-dir) (temp-dir))
      (if (not (equal? (temp-dir)  #f )) 
	  (snd-display ";temp-dir set def: ~A" (temp-dir)))
      (set! (ladspa-dir) (ladspa-dir))
      (if (not (equal? (ladspa-dir)  #f )) 
	  (snd-display ";ladspa-dir set def: ~A" (ladspa-dir)))
      (set! (tiny-font) (tiny-font))
      (if (and (not (equal? (tiny-font) "6x12"))
	       (not (equal? (tiny-font) "Monospace 8")))
	  (snd-display ";tiny-font set def: ~A" (tiny-font)))
      (set! (transform-type) (transform-type))
      (if (not (equal? (transform-type)  0 )) 
	  (snd-display ";transform-type set def: ~A" (transform-type)))
      (set! (trap-segfault) (trap-segfault))
      (if (not (equal? (trap-segfault)  #f)) 
	  (snd-display ";trap-segfault set def: ~A" (trap-segfault)))
      (set! (optimization) (optimization))
      (if (not (equal? (optimization) 0)) 
	  (snd-display ";optimization set def: ~A" (optimization)))
      (set! (run-safety) (run-safety))
      (if (not (equal? (run-safety) 0)) 
	  (snd-display ";run-safety set def: ~A" (run-safety)))
      (set! (clm-table-size) (clm-table-size))
      (if (not (equal? (clm-table-size) 512)) 
	  (snd-display ";clm-table-size set def: ~A" (clm-table-size)))
      (set! (verbose-cursor) (verbose-cursor))
      (if (not (equal? (verbose-cursor)  #f)) 
	  (snd-display ";verbose-cursor set def: ~A" (verbose-cursor)))
      (set! (vu-font) (vu-font))
      (if (not (equal? (vu-font)  #f )) 
	  (snd-display ";vu-font set def: ~A" (vu-font)))
      (set! (vu-font-size) (vu-font-size))
      (if (fneq (vu-font-size)  1.0 )
	  (snd-display ";vu-font-size set def: ~A" (vu-font-size)))
      (set! (vu-size) (vu-size))
      (if (fneq (vu-size)  1.0 )
	  (snd-display ";vu-size set def: ~A" (vu-size)))
      (set! (wavelet-type) (wavelet-type))
      (if (not (equal? (wavelet-type)  0 )) 
	  (snd-display ";wavelet-type set def: ~A" (wavelet-type)))
      (set! (time-graph-type) (time-graph-type))
      (if (not (equal? (time-graph-type)  graph-once)) 
	  (snd-display ";time-graph-type set def: ~A" (time-graph-type)))
      (set! (wavo-hop) (wavo-hop))
      (if (not (equal? (wavo-hop)  3 )) 
	  (snd-display ";wavo-hop set def: ~A" (wavo-hop)))
      (set! (wavo-trace) (wavo-trace))
      (if (not (equal? (wavo-trace)  64 )) 
	  (snd-display ";wavo-trace set def: ~A" (wavo-trace)))
      (set! (x-axis-style) (x-axis-style))
      (if (not (equal? (x-axis-style)  0 )) 
	  (snd-display ";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 ";beats-per-minute set def: ~A" (beats-per-minute)))
      (set! (zero-pad) (zero-pad))
      (if (not (equal? (zero-pad)  0)) 
	  (snd-display ";zero-pad set def: ~A" (zero-pad)))
      (set! (zero-pad) -123)
      (if (not (equal? (zero-pad)  0)) 
	  (snd-display ";zero-pad set -123: ~A" (zero-pad)))
      (if (not (equal? (zero-pad #t #t) '()))
	  (snd-display ";zero-pad #t: ~A" (zero-pad #t #t)))
      (set! (zoom-focus-style) (zoom-focus-style))
      (if (not (equal? (zoom-focus-style)  2 )) 
	  (snd-display ";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 ";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 ";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 ";mix-tag-height set def: ~A" (mix-tag-height)))
      (set! (audio-output-device) (audio-output-device))
      (if (not (equal? (audio-output-device)  0 )) 
	  (snd-display ";audio-output-device set def: ~A" (audio-output-device)))
      
      (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 ";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)))
      (run-hook after-test-hook 0)
      ))


;;; ---------------- test 1: defaults ----------------
(if (or full-test (= snd-test 1) (and keep-going (<= 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))
				   (inexact? (caddr lst)))
			      (if (fneq (cadr lst) (caddr lst))
				  (snd-display ";~A /= ~A (~A)" (car lst) (caddr lst) (cadr lst)))
			      (snd-display ";~A /= ~A (~A)" (car lst) (caddr lst) (cadr lst))))
		      (test-defaults (cdddr lst)))))))
      (run-hook before-test-hook 1)
      (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
	'auto-resize (auto-resize) #t 
	'auto-update (auto-update) #f
	'channel-style (channel-style) 0 
	'color-cutoff (color-cutoff) 0.003 
	'color-inverted (color-inverted) #t
	'color-scale (color-scale) 1.0 
	'colormap (colormap) (if (provided? 'gl) 2 0)
	'contrast-control (without-errors (contrast-control)) 'no-such-sound
	'contrast-control-bounds (cadr (contrast-control-bounds)) 10.0
	'contrast-control-amp (contrast-control-amp) 1.0
	'contrast-control? (without-errors (contrast-control?)) 'no-such-sound
	'auto-update-interval (auto-update-interval) 60.0 
	'cursor-update-interval (cursor-update-interval) 0.05
	'cursor-location-offset (cursor-location-offset) 0
	'cursor-follows-play (cursor-follows-play) #f
	'cursor-size (cursor-size) 15
	'cursor-style (cursor-style) cursor-cross
	'dac-combines-channels (dac-combines-channels) #t
	'emacs-style-save-as (emacs-style-save-as) #f
	'dac-size (dac-size) 256 
	'minibuffer-history-length (minibuffer-history-length) 8
	'data-clipped (data-clipped) #f 
	'default-output-chans (default-output-chans) 1 
	'default-output-format (default-output-format) mus-bshort
	'default-output-srate (default-output-srate) 22050 
	'default-output-type (default-output-type) mus-next
	'dot-size (dot-size) 1 
	'enved-base (enved-base) 1.0 
	'enved-clip? (enved-clip?) #f 
	'enved-filter-order (enved-filter-order) 40
	'enved-filter (enved-filter) #t
	'enved-in-dB (enved-in-dB) #f 
	'enved-style (enved-style) envelope-linear
	'enved-power (enved-power) 3.0
	'enved-target (enved-target) 0 
	'enved-wave? (enved-wave?) #f 
	'enved-envelope (enved-envelope) '()
	'eps-file (eps-file) "snd.eps" 
	'eps-bottom-margin (eps-bottom-margin) 0.0
	'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-window-beta (fft-window-beta) 0.0 
	'fft-log-frequency (fft-log-frequency) #f 
	'fft-log-magnitude (fft-log-magnitude) #f 
	'transform-size (transform-size) 512
	'transform-graph-type (transform-graph-type) 0
	'fft-window (fft-window) 6 
	'transform-graph? (without-errors (transform-graph?)) 'no-such-sound
	'filter-control-in-dB (filter-control-in-dB) #f
	'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-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
	'html-dir (html-dir) "."
	'html-program (html-program) "mozilla"
	'lisp-graph? (without-errors (lisp-graph?)) 'no-such-sound
	'graphs-horizontal (graphs-horizontal) #t
	'just-sounds (just-sounds) #f
	'listener-prompt (listener-prompt) ">" 
	'max-transform-peaks (max-transform-peaks) 100
	'max-regions (max-regions) 16 
	'min-dB (min-dB) -60.0 
	'log-freq-start (log-freq-start) 32.0
	'selection-creates-region (selection-creates-region) #t 
	'transform-normalization (transform-normalization) normalize-by-channel
	'previous-files-sort (previous-files-sort) 0 
	'print-length (print-length) 12 
	'read-only (without-errors (read-only)) 'no-such-sound
	'recorder-autoload (recorder-autoload) #f
	'recorder-buffer-size (recorder-buffer-size) 4096 
	'recorder-file (recorder-file) #f 
	'recorder-max-duration (recorder-max-duration) 1000000.0
	'recorder-out-chans (recorder-out-chans) 2 
	'recorder-in-chans (recorder-in-chans) 0
	'recorder-srate (recorder-srate) 22050 
	'recorder-trigger (recorder-trigger) 0.0
	'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" 
	'show-axes (show-axes) 1
	'show-transform-peaks (show-transform-peaks) #f 
	'show-indices (show-indices) #f
	'show-backtrace (show-backtrace) #f
	'show-marks (show-marks) #t 
	'show-mix-waveforms (show-mix-waveforms) #t
	'show-selection-transform (show-selection-transform) #f 
	'show-y-zero (show-y-zero) #f 
	'show-grid (show-grid) #f 
	'grid-density (grid-density) 1.0
	'show-sonogram-cursor (show-sonogram-cursor) #f 
	'show-controls (show-controls) #f
	'sinc-width (sinc-width) 10 
	'spectro-cutoff (spectro-cutoff) 1.0
	'spectro-hop (spectro-hop) 4 
	'spectro-start (spectro-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 
	'ladspa-dir (ladspa-dir) #f 
	'tiny-font (tiny-font) "6x12"
	'transform-type (transform-type) 0 
	'optimization (optimization) 0
	'run-safety (run-safety) 0
	'clm-table-size (clm-table-size) 512
	'verbose-cursor (verbose-cursor) #f
	'vu-font (vu-font) #f 
	'vu-font-size (vu-font-size) 1.0 
	'vu-size (vu-size) 1.0 
	'wavelet-type (wavelet-type) 0 
	'time-graph? (without-errors (time-graph?)) 'no-such-sound
	'time-graph-type (time-graph-type) graph-once
	'wavo-hop (wavo-hop) 3 
	'wavo-trace (wavo-trace) 64 
	'x-axis-style (x-axis-style) 0 
	'beats-per-minute (beats-per-minute) 60.0
	'zero-pad (zero-pad) 0
	'zoom-focus-style (zoom-focus-style) 2 
	'mix-waveform-height (mix-waveform-height) 20 
	'mix-tag-width (mix-tag-width) 6
	'mix-tag-height (mix-tag-height) 14
	'with-mix-tags (with-mix-tags) #t
	'with-relative-panes (with-relative-panes) #t
	'audio-output-device (audio-output-device) 0 
	))
      (if (not snd-remember-paths) (snd-display ";snd-remember-paths?"))
      (if memo-sound (snd-display ";memo-sound: ~A" memo-sound))
      (run-hook after-test-hook 1)
      ))


;;; ---------------- test 2: headers ----------------
(if (or full-test (= snd-test 2) (and keep-going (<= 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 ";~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 ";~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 ";~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 ";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 ";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 ";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 ";~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 ";~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 ";~A: loop start: ~A" (car lst) (list-ref testf 6)))
					  (if (not (equal? (cadr lst) (list-ref testf 7))) 
					      (snd-display ";~A: loop end: ~A" (cadr lst) (list-ref testf 7))))
					(if (not (null? lst))
					    (snd-display ";~A thinks it has loop info: ~A" file lst)))))
				(snd-display ";~A missing?" file))
			    (test-headers (cdr base-files))))))))
	  (run-hook before-test-hook 2)
	  ;; 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 ";midi60?")))
		 (lambda args args))
	  (test-headers
	   (list
	    (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" "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" "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" "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" "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" "big endian short (16 bits)")
	    (list "next-8.snd" 1 22050 0.226757362484932 "Sun" "signed byte (8 bits)")
	    (list "next-dbl.snd" 1 22050 0.226757362484932 "Sun" "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" "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" "mulaw (8 bits)")
	    (list "next24.snd" 1 44100 0.0367800444364548 "Sun" "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" "unknown")
	    (list "o2_726.aiff" 1 8000 0.0367499999701977 "AIFC" "unknown")
	    (list "o2_726.snd" 1 44100 0.0230158735066652 "Sun" "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" "unknown")
	    (list "oboe.g723_24" 1 22050 0.864761888980865 "Sun" "unknown")
	    (list "oboe.g723_40" 1 22050 1.44126987457275 "Sun" "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.nsp" 1 22050 2.305125 "CSL" "little endian short (16 bits)")
	    (list "oboe.nvf" 1 8000 6.353500 "Creative NVF" "unknown")
	    (list "oboe.wfp" 1 22050 2.305125 "Turtle Beach" "little endian short (16 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" "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" "big endian short (16 bits)")
	    (list "sun-mulaw.snd" 1 8000 4.61950016021729 "Sun" "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" "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 "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 ";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 ";can't open ~A" in-name)
				(begin
				  (if (not (string=? (file-name ind) real-name))
				      (snd-display ";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"))
	  (run-hook after-test-hook 2)
	  ))
    )


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

;;; ---------------- test 3: variables ----------------
(if (or full-test (= snd-test 3) (and keep-going (<= snd-test 3)))
    (let ((ind #f))
      (run-hook before-test-hook 3)
      (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 ";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 ";sample: ~A?" (sample 1000)))
      (if (or (not (hook? output-name-hook)) (not (hook-empty? output-name-hook)))
	  (snd-display ";output-name-hook: ~A?" output-name-hook))
      (if (or (not (hook? output-comment-hook)) (not (hook-empty? output-comment-hook)))
	  (snd-display ";output-comment-hook: ~A?" output-comment-hook))
      (if (or (not (hook? help-hook)) (not (hook-empty? help-hook)))
	  (snd-display ";help-hook: ~A?" help-hook))
      (if (or (not (hook? mark-drag-hook)) (not (hook-empty? mark-drag-hook)))
	  (snd-display ";mark-drag-hook: ~A?" mark-drag-hook))
      (if (or (not (hook? mark-drag-triangle-hook)) (not (hook-empty? mark-drag-triangle-hook)))
	  (snd-display ";mark-drag-triangle-hook: ~A?" mark-drag-triangle-hook))
      (if (or (not (hook? mix-drag-hook)) (not (hook-empty? mix-drag-hook)))
	  (snd-display ";mix-drag-hook: ~A?" mix-drag-hook))
      (if (or (not (hook? mouse-drag-hook)) (not (hook-empty? mouse-drag-hook)))
	  (snd-display ";mouse-drag-hook: ~A?" mouse-drag-hook))
      (if (or (not (hook? mouse-click-hook)) (not (hook-empty? mouse-click-hook)))
	  (snd-display ";mouse-click-hook: ~A?" mouse-click-hook))
      (if (or (not (hook? mouse-press-hook)) (not (hook-empty? mouse-press-hook)))
	  (snd-display ";mouse-press-hook: ~A?" mouse-press-hook))
      (if (or (not (hook? start-playing-hook)) (not (hook-empty? start-playing-hook)))
	  (snd-display ";start-playing-hook: ~A?" start-playing-hook))
      (if (or (not (hook? start-playing-selection-hook)) (not (hook-empty? start-playing-selection-hook)))
	  (snd-display ";start-playing-selection-hook: ~A?" start-playing-selection-hook))
      (if (or (not (hook? stop-playing-hook)) (not (hook-empty? stop-playing-hook)))
	  (snd-display ";stop-playing-hook: ~A?" stop-playing-hook))
      (if (or (not (hook? key-press-hook)) (not (hook-empty? key-press-hook)))
	  (snd-display ";key-press-hook: ~A?" key-press-hook))
      (if (or (not (hook? snd-error-hook)) (not (hook-empty? snd-error-hook)))
	  (snd-display ";snd-error-hook: ~A?" snd-error-hook))
      (if (or (not (hook? snd-warning-hook)) (not (hook-empty? snd-warning-hook)))
	  (snd-display ";snd-warning-hook: ~A?" snd-warning-hook))
      (if (or (not (hook? name-click-hook)) (not (hook-empty? name-click-hook)))
	  (snd-display ";name-click-hook: ~A?" name-click-hook))
      (if (or (not (hook? after-apply-hook)) (not (hook-empty? after-apply-hook)))
	  (snd-display ";after-apply-hook: ~A?" after-apply-hook))
      (if (or (not (hook? enved-hook)) (not (hook-empty? enved-hook)))
	  (snd-display ";enved-hook: ~A?" enved-hook))
      (if (or (not (hook? mouse-enter-label-hook)) (not (hook-empty? mouse-enter-label-hook)))
	  (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";window-property-changed-hook: ~A?" window-property-changed-hook))
      (if (or (not (hook? initial-graph-hook)) (not (hook-empty? initial-graph-hook)))
	  (snd-display ";initial-graph-hook: ~A?" initial-graph-hook))
      (if (or (not (hook? after-graph-hook)) (not (hook-empty? after-graph-hook)))
	  (snd-display ";after-graph-hook: ~A?" after-graph-hook))
      (if (or (not (hook? graph-hook)) (not (hook-empty? graph-hook)))
	  (snd-display ";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 ";enved-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 2))))
	    (if (not (list-ref (dialog-widgets) 2)) (snd-display ";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 ";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 ";set enved-envelope to self: ~A?" (enved-envelope)))
	    (let ((wid (orientation-dialog)))
	      (if (not (list-ref (dialog-widgets) 1)) (snd-display ";orientation-dialog?"))
	      (if (not (equal? wid (list-ref (dialog-widgets) 1)))
		  (snd-display ";orientation-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 1))))))
      
      (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) (inexact? newval))
				  (if (> (abs (- newval nowval)) .01)
				      (snd-display ";~A /= ~A (~A)" name newval nowval))
				  (snd-display ";~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) (inexact? newval))
				    (if (> (abs (- newval nowval)) .01)
					(snd-display ";set! ~A /= ~A (~A)" name newval nowval))
				    (snd-display ";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 2 0)
	  (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 'cursor-follows-play cursor-follows-play #f #t)
	  (list 'cursor-size cursor-size 15 30)
	  (list 'cursor-style 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 'data-clipped data-clipped #f #t)
	  (list 'default-output-chans default-output-chans 1 2)
	  (list 'default-output-format default-output-format 1 1)
	  (list 'default-output-srate default-output-srate 22050 44100)
	  (list 'default-output-type default-output-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-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 'transform-size transform-size 512 1024)
	  (list 'transform-graph-type transform-graph-type 0 1)
	  (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 'selection-creates-region selection-creates-region #t #f)
	  (list 'transform-normalization transform-normalization normalize-by-channel dont-normalize)
	  (list 'previous-files-sort previous-files-sort 0 1)
	  (list 'print-length print-length 12 16)
	  (list 'recorder-autoload recorder-autoload #f #t)
	  (list 'recorder-out-chans recorder-out-chans 2 1)
	  (list 'recorder-in-chans recorder-in-chans 0 1)
	  (list 'recorder-buffer-size recorder-buffer-size 4096 256)
	  (list 'recorder-max-duration recorder-max-duration 1000000.0 1000.0)
	  (list 'recorder-trigger recorder-trigger 0.0 0.1)
	  (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-backtrace show-backtrace #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 'spectro-cutoff spectro-cutoff 1.0 0.7)
	  (list 'spectro-hop spectro-hop 4 10)
	  (list 'spectro-start spectro-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 "6x12" "9x15")
	  (list 'transform-type transform-type 0 1)
	  (list 'verbose-cursor verbose-cursor #f #t)
	  (list 'vu-size vu-size 1.0 2.0)
	  (list 'vu-font-size vu-font-size 1.0 2.0)
	  (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 '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 ";~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 2 '(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-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 'transform-graph-type transform-graph-type 0 '(-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 'previous-files-sort previous-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 'spectro-cutoff spectro-cutoff 1.0 '(-1.0))
	  (list 'spectro-hop spectro-hop 4 '(-10 -1 0))
	  (list 'spectro-start spectro-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 0 '(-1 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 ";window width: ~A /= 300?" (window-width)))
      (if (not (equal? (window-height) 300))
	  (snd-display ";window height: ~A /= 300?" (window-height)))
      (set! (window-x) 123)
      (set! (window-y) 321)
      (if (not (equal? (window-x) 123))
	  (snd-display ";window x: ~A /= 123?" (window-x)))
      (if (not (equal? (window-y) 321))
	  (snd-display ";window y: ~A /= 321?" (window-y)))
      (set! (window-y) 10) ; get it back out of harm's way
      (set! (vu-font) "8x15")
      (set! (color-scale) 100.0)
      (if (fneq (color-scale) 100.0) (snd-display ";color-scale to 100: ~A" (color-scale)))
      
      (if (procedure? (search-procedure))
	  (snd-display ";global search procedure: ~A?" (search-procedure)))
      (set! (search-procedure) (lambda (y) (> y .1)))
      (if (not (procedure? (search-procedure)))
	  (snd-display ";set global search procedure: ~A?" (search-procedure)))
      (if (not ((search-procedure) .2))
	  (snd-display ";search > .1 .2"))
      (if ((search-procedure) .02)
	  (snd-display ";search > .1 .02"))
      (set! (search-procedure) (lambda (y) (< y 0.0)))
      (if ((search-procedure) .02)
	  (snd-display ";search < 0.0 .02"))
      (set! (search-procedure) #f)
      (if (procedure? (search-procedure))
	  (snd-display ";global search procedure after reset: ~A?" (search-procedure)))
      (set! (search-procedure) (lambda (y) (> y .1)))
      (if (not (procedure? (search-procedure)))
	  (snd-display ";set global search procedure: ~A?" (search-procedure)))
      
      (set! (enved-filter-order) 5)
      (if (not (= (enved-filter-order) 6)) (snd-display ";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 ";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 ";set string enved-envelope: ~A ~A" (enved-envelope) mod_down))))

      (close-sound ind) 
      (dismiss-all-dialogs)
      
      (if (provided? 'snd-debug)
	  (begin
	    (snd-stdin-test "(set! (enved-filter-order) 12)")
	    (if (not (= (enved-filter-order) 12)) (snd-display ";set enved-filter-order 12 via stdin: ~A" (enved-filter-order)))
	    (snd-stdin-test "(set! (enved-filter")
	    (snd-stdin-test "-order) 10)")
	    (if (not (= (enved-filter-order) 10)) (snd-display ";set enved-filter-order 12 via 2 stdin: ~A" (enved-filter-order)))))
      (run-hook after-test-hook 3)
      ))

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

(define play-sound-1
  (lambda (file)
    (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 (1- bufsize) chans data)
      (catch #t
	     (lambda ()
	       (let ((audio-fd (mus-audio-open-output mus-audio-default (mus-sound-srate file) chans mus-lshort bytes)))
		 (if (= audio-fd -1)
		     (set! audio-fd (mus-audio-open-output mus-audio-default (mus-sound-srate file) chans mus-bshort bytes)))
		 (if (= audio-fd -1)
		     (snd-display ";can't play ~A" file)
		     (begin
		       (do ((i 0 (+ i bufsize)))
			   ((>= i frames))
			 (mus-audio-write audio-fd data bufsize)
			 (mus-sound-read sound-fd 0 (1- bufsize) chans data))
		       (mus-audio-close audio-fd)))))
	     (lambda args "can't open audio"))
      (mus-sound-close-input sound-fd))))


(define (frame->byte file frame)
  (+ (mus-sound-data-location file)
     (* (mus-sound-chans file)
	(mus-sound-datum-size file)
	frame)))

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

(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 mus-audio-default) 
			    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 ";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)))))

(if (or full-test (= snd-test 4) (and keep-going (<= snd-test 4)))
    (begin
      (run-hook before-test-hook 4)
      (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")))
	      (sys (mus-audio-systems)))
	  (if (or (not (= (car mz) 0))
		  (fneq (cadr mz) 0.0))
	      (snd-display ";mus-sound-maxamp z.snd: ~A" mz))
	  (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 ";mus-bytes-per-sample ~A: ~A" (mus-data-format-name frm) siz)))
	     formats
	     sizes))
	  (if (provided? 'snd-debug)
	      (for-each
	       (lambda (format type name)
		 (if (not (string=? name (mus-header-original-format-name format type)))
		     (snd-display ";original name: ~A ~A" name (mus-header-original-format-name format type))))
	       (list 29 13 17 10 8 23 20
		     (logior (ash (char->integer #\M) 24) (ash (char->integer #\A) 16) (ash (char->integer #\C) 8) (char->integer #\!))
		     2 #x10 #x13 #x16 #x19 #x22 #x25 #x28 #x32
		     #x35 #x38 #x3b #x40 #x50 #x55 #x61 #x64 #x67
		     #x71 #x74 #x77 #x80 #x83 #x86 #x91 #x98 #x101
		     #x111 #x200 #x203 #x220 #x680 #x1002 #x1100 #x1500)
	       (list mus-next mus-next mus-next mus-next mus-next mus-next mus-next
		     mus-aifc
		     mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff
		     mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff
		     mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff 
		     mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff mus-riff)
	       (list "delat_mulaw_8" "dsp_data_24" "mulaw_squelch" "dsp_core" "indirect" "adpcm_g721" "compressed_emphasized"
		     "!CAM"
		     "ADPCM" "OKI_ADPCM" "Sierra_ADPCM" "DIGIFIX" "HP cu codec" "DSPGroup_TrueSpeech" "APTX" "lrc" "MSN audio codec"
		     "DIGIREAL" "NMS_VBXADPCM" "Rockwell adpcm" "G721_ADPCM" "MPEG" "Mpeg layer 3" "ESS Tech pcm" "G726" "DSAT display"
		     "voxware ac10 " "voxware rt24" "voxware vr12 " "softsound" "G729A" "DF GSM610" "sbc24" "philips lpcbb" "Irat"
		     "vivo G723" "Creative_ADPCM" "Creative fastspeech 10" "quarterdeck" "VME vmpcm" "OLICELP" "LH codec" "Soundspace musicompression")))
	  (mus-sound-report-cache "hiho.tmp")
	  (if (defined? 'read-line)
	      (let ((p (open-input-file "hiho.tmp")))
		(if (not p)
		    (snd-display ";mus-sound-report-cache->hiho.tmp failed?")
		    (let ((line (read-line p)))
		      (if (or (not (string? line))
			      (not (string=? "sound table:")))
			  (snd-display ";print-cache 1: ~A?" line))
		      (close-port p)
		      (delete-file "hiho.tmp")))))
	  (if (< (string-length (mus-audio-report)) 10)
	      (snd-display ";mus-audio-report: ~A" (mus-audio-report)))
	  (if (and (not (= sys 1)) (not (= sys 2))) (snd-display ";mus-audio-systems: ~A?" sys))
	  (if (not (= chns 1)) (snd-display ";oboe: mus-sound-chans ~D?" chns))
	  (if (not (= dl 28)) (snd-display ";oboe: mus-sound-data-location ~D?" dl))
	  (if (not (= fr 50828)) (snd-display ";oboe: mus-sound-frames ~D?" fr))
	  (if (not (= smps 50828)) (snd-display ";oboe: mus-sound-samples ~D?" smps))
	  (if (not (= len (+ 28 (* 2 50828)))) (snd-display ";oboe: mus-sound-length ~D?" len))
	  (if (not (= size 2)) (snd-display ";oboe: mus-sound-datum-size ~D?" size))
	  (if (not (= bytes 2)) (snd-display ";oboe: sound-bytes ~D?" bytes))
	  (if (not (= sr 22050)) (snd-display ";oboe: mus-sound-srate ~D?" sr))
	  (if (and m1 (= clmtest 0)) (snd-display ";oboe: mus-sound-maxamp-exists before maxamp: ~A" m1))
	  (if (not (mus-sound-maxamp-exists? "oboe.snd")) 
	      (snd-display ";oboe: mus-sound-maxamp-exists after maxamp: ~A" (mus-sound-maxamp-exists? "oboe.snd")))
	  (mus-audio-set-oss-buffers 4 12)
	  
	  (let ((str (strftime "%d-%b %H:%M %Z" (localtime (mus-sound-write-date "oboe.snd")))))
	    (if (not (string=? str "01-Nov 06:10 PST"))
		(snd-display ";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 ";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 33)) ; 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"))))
	    (save-sound-as long-file-name index)
	    (close-sound index)
	    (set! index (open-sound long-file-name))
	    (if (not (sound? index)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";saved null loop-info (no mode1): ~A" (mus-sound-loop-info "fmv1.snd")))))
	  
	  (if (mus-audio-sun-outputs 1 2 3) (snd-display ";mus-audio-sun-outputs: ~A" (mus-audio-sun-outputs 1 2 3)))
	  
	  (if com (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";mus-sound-comment \"telephone.wav\") -> ~A?" com)))))

	  (if (not (string? (mus-sound-comment (string-append sf-dir "traffic.aiff"))))
	      (snd-display ";mus-sound-comment traffic: ~A" (mus-sound-comment (string-append sf-dir "traffic.aiff"))))
	  
	  (if (fneq (cadr mal) .14724) (snd-display ";oboe: mus-sound-maxamp ~F?" (cadr mal)))
	  (if (not (= (car mal) 24971)) (snd-display ";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 ";oboe: set! mus-sound-maxamp ~F?" (cadr mal)))
	  (if (not (= (car mal) 1234)) (snd-display ";oboe: set! mus-sound-maxamp at ~D?" (car mal)))
	  (set! mal (mus-sound-maxamp "4.aiff"))
	  (if (not (feql mal (list 810071 0.245 810071 0.490 810071 0.735 810071 0.980)))
	      (snd-display ";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 ";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 ";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 ";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"))) "01-Nov-2004 06:10"))
	      (snd-display ";oboe: file-write-date: ~A?" (strftime "%d-%b-%Y %H:%M" (localtime (file-write-date "oboe.snd")))))
	  (play-sound-1 "oboe.snd")
	  
	  (let ((lasth (do ((i 1 (1+ i)))
			   ((string-=? (mus-header-type-name i) "unsupported") i))))
	    (if (< lasth 50) (snd-display ";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 ";data-format[~A] = ~A" lasth (mus-data-format-name lasth))))
	  
	  (set! (transform-normalization) dont-normalize)
	  (if (not (= (transform-normalization) dont-normalize))
	      (snd-display ";set-transform-normalization none -> ~A" (transform-normalization)))
	  (set! (transform-normalization) normalize-globally)
	  (if (not (= (transform-normalization) normalize-globally))
	      (snd-display ";set-transform-normalization globally -> ~A" (transform-normalization)))
	  (set! (transform-normalization) normalize-by-channel)
	  (if (not (= (transform-normalization) normalize-by-channel))
	      (snd-display ";set-transform-normalization channel -> ~A" (transform-normalization)))
	  
	  (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))
		   (vct-set! v i (- 1.0 (random 2.0))))
		 (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 ";~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)
	    (save-sound-as "test.snd" ob mus-aifc mus-bdouble)
	    (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)
		  (begin
		    (if (snd-sound-pointer 12345) (snd-display ";snd-sound-pointer #f: ~A" (snd-sound-pointer 12345)))
		    (if (not (number? (snd-sound-pointer ab))) (snd-display ";snd-sound-pointer ~A: ~A" ab (snd-sound-pointer ab)))))
	      (if (not (= (header-type ab) mus-aifc)) 
		  (snd-display ";save-as aifc -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-aifc)) 
		  (snd-display ";saved-as aifc -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";aifc[1000] = ~A?" (sample 1000 ab)))
	      (if (not (string-=? (mus-sound-comment "test.snd") str))
		  (snd-display ";output-comment: ~A ~A" (mus-sound-comment "test.snd") str))
	      (if (or (not (string? (comment ab)))
		      (not (string-=? (comment ab) str)))
		  (snd-display ";output-comment (comment): ~A ~A" (comment ab) str))
	      (close-sound ab))
	    (if (not (equal? old-comment (mus-sound-comment "oboe.snd")))
		(snd-display ";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 ";save-as raw -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-raw)) 
		  (snd-display ";saved-as raw -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";save-as nist -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-nist)) 
		  (snd-display ";saved-as nist -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-bint)) 
		  (snd-display ";save-as int -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-bint)) 
		  (snd-display ";saved-as int -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";save-as riff -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-riff)) 
		  (snd-display ";saved-as riff -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-lfloat)) 
		  (snd-display ";save-as float -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-lfloat)) 
		  (snd-display ";saved-as float -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";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 ";save-as aiff -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-aiff)) 
		  (snd-display ";saved-as aiff -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-b24int))
		  (snd-display ";save-as 24-bit -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-b24int))
		  (snd-display ";saved-as 24-bit -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";save-as ircam -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-ircam)) 
		  (snd-display ";saved-as ircam -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-mulaw))
		  (snd-display ";save-as mulaw -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-mulaw))
		  (snd-display ";saved-as mulaw -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";save-as next -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-next)) 
		  (snd-display ";saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-alaw)) 
		  (snd-display ";save-as alaw -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-alaw)) 
		  (snd-display ";saved-as alaw -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";save-as dbl next -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (data-format ab) mus-bdouble)) 
		  (snd-display ";save-as dbl -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 ";save-as next -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-next)) 
		  (snd-display ";saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-bshort)) 
		  (snd-display ";save-as short -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-bshort)) 
		  (snd-display ";saved-as short -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";next (short)[1000] = ~A?" (sample 1000 ab)))
	      (set! (y-bounds ab 0) (list -3.0 3.0))
	      (set! (data-format ab) mus-lshort)
	      (if (not (= 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 ";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 ";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 ";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 ";set data format y-bounds -2: ~A?" (y-bounds ab 0)))
	      (set! (header-type ab) mus-aifc)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (header-type ab) mus-aifc)) (snd-display ";set header-type: ~A?" (mus-header-type-name (header-type ab))))
	      (set! (channels ab) 3)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (channels ab) 3)) (snd-display ";set chans: ~A?" (channels ab)))
	      (set! (data-location ab) 1234)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (data-location ab) 1234)) (snd-display ";set data-location: ~A?" (data-location ab)))
	      (let ((old-size (data-size ab)))
		(set! (data-size ab) 1234)
		(if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
		(if (not (= (data-size ab) 1234)) (snd-display ";set data-size: ~A?" (data-size ab)))
		(set! (data-size ab) old-size))
	      (set! (srate ab) 12345)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (srate ab) 12345)) (snd-display ";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 ";save-as next -> ~A?" (mus-header-type-name (header-type ab))))
	      (if (not (= (mus-sound-header-type "test.snd") mus-next)) 
		  (snd-display ";saved-as next -> ~A?" (mus-header-type-name (mus-sound-header-type "test.snd"))))
	      (if (not (= (data-format ab) mus-bfloat)) 
		  (snd-display ";save-as float -> ~A?" (mus-data-format-name (data-format ab))))
	      (if (not (= (mus-sound-data-format "test.snd") mus-bfloat)) 
		  (snd-display ";saved-as float -> ~A?" (mus-data-format-name (mus-sound-data-format "test.snd"))))
	      (if (fneq (sample 1000 ab) samp) (snd-display ";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 (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (data-format) mus-lshort)) (snd-display ";set data-format: ~A?" (mus-data-format-name (data-format))))
	      (set! (header-type) mus-aifc)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (header-type) mus-aifc)) (snd-display ";set header-type: ~A?" (mus-header-type-name (header-type))))
	      (set! (channels) 3)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (channels) 3)) (snd-display ";set chans: ~A?" (channels)))
	      (set! (data-location) 1234)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (data-location) 1234)) (snd-display ";set data-location: ~A?" (data-location)))
	      (set! (srate) 12345)
	      (if (not (= ab (find-sound "test.snd"))) (set! ab (find-sound "test.snd")))
	      (if (not (= (srate) 12345)) (snd-display ";set srate: ~A?" (srate)))
	      (close-sound ab)))
	  (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 ";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 ";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 ";~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 ";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 "/home/bil/sf1/bad_chans.snd"
			    "/home/bil/sf1/bad_srate.snd"
			    "/home/bil/sf1/bad_chans.aifc"
			    "/home/bil/sf1/bad_srate.aifc"
			    "/home/bil/sf1/bad_length.aifc"
			    "/home/bil/sf1/bad_chans.riff"
			    "/home/bil/sf1/bad_srate.riff"
			    "/home/bil/sf1/bad_chans.nist"
			    "/home/bil/sf1/bad_location.nist"
			    "/home/bil/sf1/bad_field.nist"
			    "/home/bil/sf1/bad_srate.nist"
			    "/home/bil/sf1/bad_length.nist"))
	    (close-sound ind))
	  
	  (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 ";oboe->sd: len ~A?" (sound-data-length sd)))
	    (if (fneq (sound-data-ref sd 0 1000) .0328369) (snd-display ";oboe->sd[1000]: ~A?" (sound-data-ref sd 0 1000)))
	    (if (not (= (length mx) 1)) (snd-display ";sound-data-maxamp oboe.snd: ~A?" (sound-data-maxamp sd)))
	    (if (not (= (maxamp ob 0) (car mx))) (snd-display ";sound-data-maxamp oboe.snd: ~A ~A?" (sound-data-maxamp sd) (maxamp ob 0)))
	    
	    (let ((var (catch #t (lambda () (set! (selected-channel) 1)) (lambda args args))))
	      (if (not (eq? (car var) 'no-such-channel))
		  (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";vct->sound-data-set! bad chan: ~A" var)))
	    (close-sound ob))
	  (if (selected-sound)
	      (snd-display ";selected-sound ~A ~A" (selected-sound) (sounds)))
	  
	  (let* ((vals (make-vct 32))
		 (err (mus-audio-mixer-read mus-audio-microphone mus-audio-amp 0 vals)))
	    (if (= err -1) (snd-display ";mus-audio-mixer-read?"))
	    (for-each 
	     (lambda (field)
	       (for-each
		(lambda (device)
		  (if (not (= (mus-audio-mixer-read device field 0 vals) -1))
		      (mus-audio-mixer-write device field 0 vals)))
		(list mus-audio-default mus-audio-duplex-default mus-audio-line-out mus-audio-line-in mus-audio-microphone
		      mus-audio-speakers mus-audio-dac-out mus-audio-adat-in mus-audio-aes-in mus-audio-digital-in
		      mus-audio-digital-out mus-audio-adat-out mus-audio-aes-out mus-audio-dac-filter mus-audio-mixer
		      mus-audio-line1 mus-audio-line2 mus-audio-line3 mus-audio-aux-input mus-audio-cd mus-audio-aux-output
		      mus-audio-spdif-in mus-audio-spdif-out)))
	     (list mus-audio-amp mus-audio-srate mus-audio-channel mus-audio-format mus-audio-port mus-audio-imix
		   mus-audio-igain mus-audio-reclev mus-audio-pcm mus-audio-pcm2 mus-audio-ogain mus-audio-line
		   mus-audio-line1 mus-audio-line2 mus-audio-line3 mus-audio-cd
		   mus-audio-synth mus-audio-bass mus-audio-treble mus-audio-direction mus-audio-samples-per-channel))
	    )
	  
	  (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 ";soundfont-info: ~A?" loops))
		      (close-sound fil)))))
	  
	  (if (file-exists? "fmv5.snd") (delete-file "fmv5.snd"))
	  (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: 1 chan, 100 frames>" (format #f "~A" sdata)))
		(snd-display ";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 ";sound-data not eq? ~A ~A" sdata edat))
	      (if (not (equal? sdata edat)) (snd-display ";sound-data not equal? ~A ~A" sdata edat))
	      (if (equal? sdata edat1) (snd-display ";sound-data 1 equal? ~A ~A" sdata edat1))
	      (if (equal? edat2 edat1) (snd-display ";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 ";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 ";sound-data->vct: ~A?" v0))
	      (sound-data->vct sdata 0 v1) 
	      (if (fneq (vct-ref v1 1) .01) (snd-display ";sound-data->(small)vct: ~A?" v1))
	      (vct->sound-data v0 sdata 0) 
	      (if (fneq (sound-data-ref sdata 0 10) .1) (snd-display ";vct->sound-data: ~A?" (sound-data-ref 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 ";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 ";mus-audio-write bad frames: ~A" var))))
	    
	    (let ((v0 (make-vct 10))
		  (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) 
	      (if (fneq (vct-ref v0 1) .1) (snd-display ";sound-data->vct[1]: ~A?" v0))
	      (sound-data->vct sdata2 1 v0) 
	      (if (fneq (vct-ref v0 1) .2) (snd-display ";sound-data->vct[2]: ~A?" v0))
	      (vct->sound-data v0 sdata2 0) 
	      (if (fneq (sound-data-ref sdata2 0 1) .2) 
		  (snd-display ";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 ";vct->sound-data[3]: ~A?" (sound-data-ref sdata2 1 1))))
	    (mus-sound-write fd 0 99 1 sdata)
	    (mus-sound-close-output fd 200)
	    (set! fd (mus-sound-reopen-output "fmv5.snd" 1 mus-bshort mus-aiff (mus-sound-data-location "fmv5.snd")))
	    (mus-sound-close-output fd 200)
	    (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 ";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 ";1 mus-sound-seek-frame: ~A ~A?" pos (ftell fd)))
	      (if (not (= pos (frame->byte "fmv5.snd" 20)))
		  (snd-display ";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 ";2 mus-sound-seek: ~A?" (sound-data-ref sdata 0 0)))
	    (mus-sound-close-input fd))
	  
	  (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 ";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 ";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 ";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 ";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 ";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 ";mus-sound-reopen-output bad type: ~A" var)))
	  
	  (for-each
	   (lambda (proc name)
	     (let ((var (catch #t (lambda () (proc mus-audio-default 22050 -1 mus-lshort 512)) (lambda args args))))
	       (if (not (eq? (car var) 'out-of-range))
		   (snd-display ";~A bad chans: ~A" name var)))
	     (let ((var (catch #t (lambda () (proc mus-audio-default 22050 1 -1 512)) (lambda args args))))
	       (if (not (eq? (car var) 'out-of-range))
		   (snd-display ";~A bad format: ~A" name var)))
	     (let ((var (catch #t (lambda () (proc -1 22050 1 mus-lshort 512)) (lambda args args))))
	       (if (not (eq? (car var) 'out-of-range))
		   (snd-display ";~A bad device: ~A" name var)))
	     (let ((var (catch #t (lambda () (proc mus-audio-default -22050 1 mus-lshort 512)) (lambda args args))))
	       (if (not (eq? (car var) 'out-of-range))
		   (snd-display ";~A bad srate: ~A" name var)))
	     (let ((var (catch #t (lambda () (proc mus-audio-default 22050 1 mus-lshort -512)) (lambda args args))))
	       (if (not (eq? (car var) 'out-of-range))
		   (snd-display ";~A bad size: ~A" name var))))
	   (list mus-audio-open-output mus-audio-open-input)
	   (list "mus-audio-open-output" "mus-audio-open-input"))
	  
	  (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 ";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 ";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 ((vals (make-vct 32)))
	    (for-each 
	     (lambda (proc name)
	       (let ((var (catch #t (lambda () (proc -1 mus-audio-amp 0 vals)) (lambda args args))))
		 (if (not (eq? (car var) 'out-of-range))
		     (snd-display ";~A bad device: ~A" name var)))
	       (let ((var (catch #t (lambda () (proc mus-audio-microphone -1 0 vals)) (lambda args args))))
		 (if (not (eq? (car var) 'out-of-range))
		     (snd-display ";~A bad field: ~A" name var))))
	     (list mus-audio-mixer-read mus-audio-mixer-write)
	     (list "mus-audio-mixer-read" "mus-audio-mixer-write")))
	  (mus-audio-mixer-write mus-audio-microphone mus-audio-amp 0 (make-vct 1))
	  
	  (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 ";samples->sound-data->vct: ~A ~A" vc1 vc2))
	    (if (not (equal? sd1 sd2)) (snd-display ";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 ";edpos samples->sound-data->vct: ~A ~A" vc1 vc2))
	    (if (not (equal? sd1 sd2)) (snd-display ";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 ";1 samples->sound-data->vct: ~A ~A" vc1 vc2))
	    (if (not (equal? sd1 sd2)) (snd-display ";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 ";1 scaled samples->sound-data->vct: ~A ~A" vc1 vc2))
	    (if (not (equal? sd1 sd2)) (snd-display ";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 ";sound-data->sound-data 0: ~A" (sound-data-ref sd1 0 0)))
	    (if (fneq (sound-data-ref sd1 0 2) 0.02) (snd-display ";sound-data->sound-data 2: ~A" (sound-data-ref sd1 0 2)))
	    (if (fneq (sound-data-ref sd1 0 3) 0.0) (snd-display ";sound-data->sound-data 3: ~A" (sound-data-ref sd1 0 3)))
	    (if (fneq (sound-data-ref sd1 0 6) 0.3) (snd-display ";sound-data->sound-data 6: ~A" (sound-data-ref sd1 0 6)))
	    (if (fneq (sound-data-ref sd1 0 10) 0.1) (snd-display ";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 ";sound-data->sound-data 2 5: ~A" (sound-data-ref sd2 0 5))))

	  (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 
		     (lambda ()
		       (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 ";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 ";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)
		    (catch #t
			   (lambda ()
			     (run
			      (lambda ()
				(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))
					(throw 'read-write-error)))))))
			   (lambda args 
			     (begin 
			       (snd-display ";read-write trouble: ~A ~A"
					    (mus-data-format-name (car df-ht))
					    (mus-header-type-name (cadr df-ht)))
			       (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))
	  
	  (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 (1- (sound-data-length sd)) (1- i)))
		    ((< i 0) ls)
		  (set! ls (cons (sound-data-ref sd chan i) ls)))))
	    (define (sound-data->list sd)
	      (let ((lst '()))
		(do ((i (1- (sound-data-chans sd)) (1- i)))
		    ((< 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 ";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"))
	    (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.1)
		    (fneq (sound-data-ref sdata 0 3) 0.1)
		    (fneq (sound-data-ref sdata 0 6) 0.0))
		(snd-display ";re-read/write: ~A?" (sound-data->list sdata)))
	    (mus-sound-close-input fd)
	    
	    ;; check data-clipped choices
	    (let ((ind (view-sound "oboe.snd")))
	      (set! (data-clipped) #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 ";clipping 0: ~A ~A" (maxamp ind1 0) (maxamp ind 0)))
		(close-sound ind1))
	      (delete-file "test.snd")
	      (set! (data-clipped) #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 ";clipping 1: ~A ~A" (maxamp ind1 0) (maxamp ind 0)))
		(close-sound ind1))
	      (delete-file "test.snd")
	      (set! (data-clipped) #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 ";clipping 2: ~A" baddy))
		  (close-sound ind1))
		(delete-file "test.snd")
		(set! (data-clipped) #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 ";clipping 3: ~A" baddy))
		  (close-sound ind1))
		(delete-file "test.snd")
		(set! (data-clipped) #f))
	      (close-sound ind))
	    
	    (delete-file "fmv.snd")
	    (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 ";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"))
	    (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.1)
		      (fneq (sound-data-ref sdata i 3) 0.1)
		      (fneq (sound-data-ref sdata i 6) 0.0))
		  (snd-display ";re-read/write[~A]: ~A?" 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 ";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 ";~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" 
			    "no audio lines available" "audio write error" "audio size not available" "audio device not available"
			    "can't close audio" "can't open audio" "audio read error" "audio amp not available"
			    "can't write audio" "can't read audio" "no audio read permission" 
			    "can't close file" "arg out of range"
			    "midi open error" "midi read error" "midi write error" "midi close error" "midi init error" "midi misc error"
			    "no channels method" "no hop method" "no width method" "no file-name method" "no ramp method" "no run method"
			    "no increment method" "no inspect method" "no offset method"
			    "no xcoeff method" "no ycoeff method" "no xcoeffs method" "no ycoeffs method" "can't translate"
			    )))
	    (call-with-current-continuation
	     (lambda (quit)
	       (do ((i 0 (1+ i)))
		   ((= i 67))
		 (if (not (string-=? (list-ref errs i) (mus-error-to-string i)))
		     (begin
		       (snd-display ";mus-error-to-string ~D: ~A ~A" i (list-ref errs i) (mus-error-to-string i))
		       (quit #f)))))))
	  (let ((new-id (mus-make-error "hiho all messed up")))
	    (if (not (string=? (mus-error-to-string new-id) "hiho all messed up"))
		(snd-display ";mus-make-error :~A ~A" new-id (mus-error-to-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 ";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 ";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 ";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 ";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 ";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 ";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))
	  
;	  (with-sound (:output "/home/bil/zap/sounds/bigger.snd" :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 ((big-file-name "/home/bil/zap/sounds/bigger.snd"))
		(if (file-exists? big-file-name)
		    (begin
		      (if (not (= (mus-sound-samples big-file-name) 3175160310))
			  (snd-display ";bigger samples: ~A" (mus-sound-samples big-file-name)))
		      (if (not (= (mus-sound-frames big-file-name) 3175160310))
			  (snd-display ";bigger frames: ~A" (mus-sound-frames big-file-name)))
		      (if (not (= (mus-sound-length big-file-name) 6350320648))
			  (snd-display ";bigger bytes: ~A" (mus-sound-length big-file-name)))
		      (if (fneq (mus-sound-duration big-file-name) 71999.1015)
			  (snd-display ";bigger dur: ~A" (mus-sound-duration big-file-name)))
		      (let ((ind (open-sound big-file-name)))
			(if (not (= (frames ind) 3175160310)) (snd-display ";bigger frames: ~A" (frames ind)))
			(if (not (= (frames ind 0 0) 3175160310)) (snd-display ";bigger edpos-frames: ~A" (frames ind)))
			(let ((m1 (add-mark (* 44100 50000) ind)))
			  (if (not (= (mark-sample m1) (* 44100 50000))) (snd-display ";bigger mark at: ~A" (mark-sample m1)))
			  (set! (mark-sample m1) (* 44100 66000))
			  (if (not (= (mark-sample m1) (* 44100 66000))) (snd-display ";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 ";bigger mix at: ~A" (mix-position mx)))
				(set! (mix-position mx) (* 44100 61000))
				(if (not (= (mix-position mx) (* 44100 61000))) (snd-display ";bigger mix to: ~A" (mix-position mx))))
			      (snd-display ";no mix tag from mix-sound"))
			  (undo 2))
			(let ((old-select (selection-creates-region)))
			  (set! (selection-creates-region) #f)
			  (select-all ind)
			  (if (not (= (selection-frames) (frames ind))) (snd-display ";bigger select all: ~A ~A" (selection-frames) (frames)))
			  (set! (selection-position) (* 44100 50000))
			  (if (not (= (selection-position) (* 44100 50000))) (snd-display ";bigger select pos: ~A" (selection-position)))
			  (set! (selection-position) 0)
			  (set! (selection-frames) (* 44100 65000))
			  (if (not (= (selection-frames) (* 44100 65000))) (snd-display ";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 ";bigger cursor: ~A" (cursor ind)))
			(let ((val (backward-sample)))
			  (if (not (= (cursor ind) (1- (* 44100 50000)))) (snd-display ";backup bigger cursor: ~A" (cursor ind)))
			  (if (not (= val (1- (* 44100 50000)))) (snd-display ";backup rtn bigger cursor: ~A" (cursor ind))))
			(let ((val (forward-sample)))
			  (if (not (= (cursor ind) (* 44100 50000))) (snd-display ";up bigger cursor: ~A" (cursor ind)))
			  (if (not (= val (* 44100 50000))) (snd-display ";up rtn bigger cursor: ~A" (cursor ind))))
			(let ((m1 (add-mark (* 44123 51234) ind)))
			  (if (not (= (mark-sample m1) (* 44123 51234))) (snd-display ";bigger mark at: ~A" (mark-sample m1)))
			  (let ((mid (find-mark (* 44123 51234))))
			    (if (or (not (number? mid)) (not (= mid m1))) (snd-display ";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 ";bigger find-mix ~A ~A" mxd mx))))
			(set! (cursor ind) (* 44123 51234))
			(if (not (= (cursor ind) (* 44123 51234))) (snd-display ";bigger cursor 123: ~A" (cursor ind)))
			(close-sound ind))
		      ))))

	  (let ((ind (new-sound "tmp.snd" mus-riff mus-l24int 22050 1 :size 100000)))
	    (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 ";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 ";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 ";l24 (next) region not saved correctly? ~A" err)))
		(close-sound ind1))
	      (delete-file "tmp1.snd")
	      (close-sound ind)
	      (delete-file "tmp.snd")))
	  (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 ";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))
      (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 (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))
		 (snd-display ";open-sound garbage ~A: ~A?" magic 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))
		 (snd-display ";open-sound plausible garbage ~A: ~A?" magic 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))
		 (snd-display ";open-sound very plausible garbage ~A: ~A?" magic 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-char #\000) (write-char #\000) (write-char #\000) (write-char #\034) ; location
	  (write-char #\000) (write-char #\001) (write-char #\215) (write-char #\030) ; nominal size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\022) ; format
	  (write-char #\000) (write-char #\000) (write-char #\126) (write-char #\042) ; srate
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\001) ; chans
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; comment
	  (write-char #\000) (write-char #\001) ; samp 1
	  ))
      (if (not (= (mus-sound-data-format "test.snd") mus-bshort))
	  (snd-display ";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-char #\000) (write-char #\000) (write-char #\000) (write-char #\004) ; location
	  (write-char #\000) (write-char #\001) (write-char #\215) (write-char #\030) ; nominal size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\022) ; format
	  (write-char #\000) (write-char #\000) (write-char #\126) (write-char #\042) ; srate
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\001) ; chans
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; comment
	  (write-char #\000) (write-char #\001) ; samp 1
	  ))
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.snd"))
			(lambda args (car args)))))
	(if (and (number? tag)
		 (sound? tag))
	    (begin
	      (snd-display ";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-char #\000) (write-char #\000) (write-char #\000) (write-char #\034) ; location
	  (write-char #\000) (write-char #\001) (write-char #\215) (write-char #\030) ; nominal size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\122) ; format
	  (write-char #\000) (write-char #\000) (write-char #\126) (write-char #\042) ; srate
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\001) ; chans
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; comment
	  (write-char #\000) (write-char #\001) ; samp 1
	  ))
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.snd"))
			(lambda args (car args)))))
	(if (and (number? tag)
		 (sound? tag))
	    (begin
	      (snd-display ";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-char #\000) (write-char #\000) (write-char #\000) (write-char #\146) ; len
		      (display "AIFCFVER")
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\004) ; version chunk size
		      (write-char #\242) (write-char #\200) (write-char #\121) (write-char #\100) ; version  
		      (display "COMM")
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\046) ; COMM chunk size
		      (write-char #\000) (write-char #\001) ; 1 chan
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char frames) ; frames
		      (write-char #\000) (write-char bits) ; bits
		      (write-char #\100) (write-char #\016) (write-char #\254) (write-char #\104) (write-char #\000) 
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ;
		      ;; srate as 80-bit float (sheesh)
		      (display "NONE") ; compression
		      (write-char #\016) ; pascal string len
		      (display "not compressed")
		      (write-char #\000)
		      (display "AUTH")
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char auth-lo) ; AUTH chunk size
		      (display "bil")
		      (write-char #\000)
		      (display "SSND")
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
		      (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
		      (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
		      )))))
	(if (file-exists? "test.aif") (delete-file "test.aif"))
	(mus-sound-forget "test.aif")
	;;correct (make-aifc-file #\002 #\004 #\020)
	(make-aifc-file #\102 #\004 #\020)
	(let ((ind (open-sound "test.aif")))
	  (if (not (= (frames ind) 2)) (snd-display ";bad frames in header: ~A" (frames ind)))
	  (close-sound ind))
	(delete-file "test.aif")
	(mus-sound-forget "test.aif")
	(make-aifc-file #\002 #\150 #\020)
	(let ((tag (catch #t
			  (lambda ()
			    (open-sound "test.aif"))
			  (lambda args (car args)))))
	  (if (and (number? tag)
		   (sound? tag))
	      (begin
		(snd-display ";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 #\002 #\000 #\020)
	(let ((tag (catch #t
			  (lambda ()
			    (open-sound "test.aif"))
			  (lambda args (car args)))))
	  (if (and (number? tag)
		   (sound? tag))
	      (begin
		(snd-display ";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 #\002 #\150 #\120)
	(let ((tag (catch #t
			  (lambda ()
			    (open-sound "test.aif"))
			  (lambda args (car args)))))
	  (if (and (number? tag)
		   (sound? tag))
	      (begin
		(snd-display ";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-char #\000) (write-char #\000) (write-char #\000) (write-char #\176) ; len
	  (display "AIFCFVER")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\004) ; version chunk size
	  (write-char #\242) (write-char #\200) (write-char #\121) (write-char #\100) ; version  
	  (display "COMM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\046) ; COMM chunk size
	  (write-char #\000) (write-char #\001) ; 1 chan
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\002) ; frames
	  (write-char #\000) (write-char #\020) ; bits
	  (write-char #\100) (write-char #\016) (write-char #\254) (write-char #\104) (write-char #\000) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; srate as 80-bit float (sheesh)
	  (display "NONE") ; compression
	  (write-char #\016) ; pascal string len
	  (display "not compressed")
	  (write-char #\000)
	  (display "AUTH")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\004) ; AUTH chunk size
	  (display "bil")
	  (write-char #\000)
	  (display "ANNO")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\004) ; AUTH chunk size
	  (display "cat")
	  (write-char #\000)
	  (display "NAME")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\004) ; AUTH chunk size
	  (display "dog")
	  (write-char #\000)
	  (display "SSND")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
	  (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
	  ))
      (if (not (= (string-length (mus-sound-comment "test.aif")) 15))
	  (snd-display ";aifc 3 aux comments: ~A?" (mus-sound-comment "test.aif")))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif")
      (with-output-to-file "test.aif"
	(lambda ()
	  (display "FORM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\142) ; len
	  (display "AIFC")
	  (display "SSND")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
	  (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
	  (display "COMM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\046) ; COMM chunk size
	  (write-char #\000) (write-char #\001) ; 1 chan
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\002) ; frames
	  (write-char #\000) (write-char #\020) ; bits
	  (write-char #\100) (write-char #\016) (write-char #\254) (write-char #\104) (write-char #\000) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; srate as 80-bit float (sheesh)
	  (display "NONE") ; compression
	  (write-char #\016) ; pascal string len
	  (display "not compressed")
	  (write-char #\000)
	  (display "COMT")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) 
	  (display "bil")
	  (write-char #\000)
	  ))
      (if (not (string=? (substring (mus-sound-comment "test.aif") 0 3) "bil"))
	  (snd-display ";aifc trailing comt comment: ~A?" (mus-sound-comment "test.aif")))
      (if (not (= (mus-sound-frames "test.aif") 2))
	  (snd-display ";aifc trailing comt frames: ~A?" (mus-sound-frames "test.aif")))
      (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 ";aifc trailing comt samps: ~A ~A ~A ~A" (sample 0) (sample 1) (sample 2) (sample 3)))
	(close-sound ind))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif")
      (with-output-to-file "test.aif"
	(lambda ()
	  (display "FORM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\142) ; len
	  (display "AIFC")
	  (display "SSND")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
	  (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
	  (display "COMM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\046) ; COMM chunk size
	  (write-char #\000) (write-char #\001) ; 1 chan
	  (write-char #\000) (write-char #\000) (write-char #\100) (write-char #\102) ; frames
	  (write-char #\000) (write-char #\020) ; bits
	  (write-char #\100) (write-char #\016) (write-char #\254) (write-char #\104) (write-char #\000) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; srate as 80-bit float (sheesh)
	  (display "NONE") ; compression
	  (write-char #\016) ; pascal string len
	  (display "not compressed")
	  (write-char #\000)
	  (display "COMT")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) 
	  (display "bil")
	  (write-char #\000)
	  ))
      (if (not (string=? (substring (mus-sound-comment "test.aif") 0 3) "bil"))
	  (snd-display ";aifc trailing comt comment: ~A?" (mus-sound-comment "test.aif")))
      (if (not (= (mus-sound-frames "test.aif") 2))
	  (snd-display ";aifc trailing comt (bogus) frames: ~A?" (mus-sound-frames "test.aif")))
      (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 ";aifc trailing comt samps (bogus frame setting): ~A ~A ~A ~A" (sample 0) (sample 1) (sample 2) (sample 3)))
	(close-sound ind))
      (delete-file "test.aif")
      (mus-sound-forget "test.aif")
      (with-output-to-file "test.aif"
	(lambda ()
	  (display "FORM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\142) ; len
	  (display "AIFC")
	  (display "SSND")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
	  (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
	  (display "COMM")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\046) ; COMM chunk size
	  (write-char #\000) (write-char #\001) ; 1 chan
	  (write-char #\000) (write-char #\000) (write-char #\100) (write-char #\102) ; frames
	  (write-char #\000) (write-char #\020) ; bits
	  (write-char #\100) (write-char #\016) (write-char #\254) (write-char #\104) (write-char #\000) 
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; srate as 80-bit float (sheesh)
	  (display "NONE") ; compression
	  (write-char #\016) ; pascal string len
	  (display "not compressed")
	  (write-char #\000)
	  (display "SSND")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
	  (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
	  ))
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.aif"))
			(lambda args (car args)))))
	(if (and (number? tag)
		 (sound? tag))
	    (begin
	      (snd-display ";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-char #\000) (write-char #\000) (write-char #\000) (write-char #\040) ; len
	  (display "AIFC")
	  (display "SSND")
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\014) ; SSND chunk size
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; SSND data loc
	  (write-char #\000) (write-char #\000) (write-char #\000) (write-char #\000) ; block size?
	  (write-char #\000) (write-char #\101) (write-char #\000) (write-char #\100) ; two samples
	  ))
      (let ((tag (catch #t
			(lambda ()
			  (open-sound "test.aif"))
			(lambda args (car args)))))
	(if (not (eq? tag 'mus-error))
	    (begin
	      (snd-display ";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")

      (reset-hook! bad-header-hook)
      (reset-hook! open-raw-sound-hook)
      (if (not (null? (sounds))) (map close-sound (sounds)))
      
      (run-hook after-test-hook 4)
      ))

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

(if (not (provided? 'snd-snd4.scm)) (load "snd4.scm")) ; needed for various scan/map extensions
(define a-ctr 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 ";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 ";~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 ";~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 ";~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 ";~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 ";~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 ";~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 ";~A (orig: 1) ~A ~A" func-name v0 v2))))
    (revert-sound ind1)))

(if (not (provided? 'snd-extensions.scm)) (load "extensions.scm"))
(if (not (provided? 'snd-examp.scm)) (load "examp.scm"))
(if (not (provided? 'snd-dsp.scm)) (load "dsp.scm"))
(if (not (provided? 'snd-pvoc.scm)) (load "pvoc.scm"))
(if (not (provided? 'snd-edit-menu.scm)) (load "edit-menu.scm"))
(define g-init-val 0)

(define* (make-bandpass-2 flo1 fhi1 flo2 fhi2 #:optional (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-via-ptree #:optional (beg 0) (dur #f) (snd #f) (chn #f) (edpos #f))
  ;; vct: angle increment
  (ptree-channel
   (lambda (y data forward)
     (declare (y real) (data vct) (forward boolean))
     (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* (cosine-channel #:optional (beg 0) (dur #f) (snd #f) (chn #f) (edpos #f))
  (let ((old-opt (optimization)))
    (set! (optimization) 0)
    (map-channel
     (let* ((samps (or dur (frames snd chn)))
	    (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* (xen-channel proc #:optional (beg 0) (dur #f) (snd #f) (chn #f) (edpos #f) (env-too #f) (init-func #f))
  (ptree-channel proc beg dur snd chn edpos env-too init-func #f))

(define (check-maxamp ind val name)
  (if (fneq (maxamp ind 0) val) (snd-display ";maxamp amp-env ~A: ~A should be ~A" name (maxamp ind) val))
  (let ((pos (find (lambda (y) (>= (abs y) (- val .001))))))
    (if (not pos) (snd-display ";actual maxamp ~A vals not right" name))
    (let ((mx 0.0))
      (scan-chan (lambda (y) 
		   (if (> (abs y) mx) 
		       (set! mx (abs y))) 
		   #f))
      (if (fneq mx val) (snd-display ";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-sample-reader 0 r 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 0 len r c))

(define old-opt-val (optimization))

(if (or full-test (= snd-test 5) (and keep-going (<= snd-test 5)))
    (begin
      (run-hook before-test-hook 5)
      
      (set! (optimization) max-optimization) ; these trees assume optimization is on
      
      (if (dac-is-running) (snd-display ";dac is running??"))
      (do ((clmtest 0 (1+ clmtest))) ((= clmtest tests)) 
	(log-mem clmtest)

      ;; basic edit tree cases
      (let ((ind (new-sound "test.snd")))
	(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 ";new 0: ~A" (display-edits)))
	(insert-samples 10 10 (make-vct 10))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 2

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

 (silence 1 9) ; pad-channel [1:3]:
   (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, end_mark)

 (insert 10 10) ; insert-samples [2: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 ";new 1: ~A" (display-edits)))
	(undo)
	(insert-samples 0 10 (make-vct 10))
	(if (not (string-=? (display-edits) (string-append "
EDITS: 2

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

 (silence 1 9) ; pad-channel [1:3]:
   (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, end_mark)

 (insert 0 10) ; insert-samples [2:4]:
   (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, cp->sounds[-1][0:8, 0.000])
   (at 20, end_mark)
")))
	    (snd-display ";new 2: ~A" (display-edits)))
	(undo 2)
	(insert-samples 0 10 (make-vct 10))
	(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 ";new 3: ~A" (display-edits)))
	(undo)
	(set! (sample 0) .5)
	(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 ";new 4: ~A" (display-edits)))      
	(undo)
	(set! (samples 0 10) (make-vct 10))
	(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 ";new 5: ~A" (display-edits)))
	(delete-samples 3 4)
	(if (not (string-=? (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 ";new 6: ~A" (display-edits ind 0 2)))
	(set! (samples 1 4) (make-vct 4))
	(if (not (string-=? (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 ";new 7: ~A" (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 (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 ";new 8: ~A" (display-edits)))
	(delete-samples 2 1)
	(if (not (string-=? (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 ";new 9: ~A" (display-edits ind 0 6)))
	(delete-samples 0 5)
	(if (not (string-=? (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 ";new 10: ~A" (display-edits ind 0 7)))
	(delete-samples 6 4)
	(if (not (string-=? (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 ";new 11: ~A" (display-edits ind 0 8)))
	(delete-samples 0 1)
	(if (not (string-=? (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 ";new 12: ~A" (display-edits ind 0 9)))
	
	(delete-samples 0 5)
	(if (not (string-=? (display-edits ind 0 10) "
 (delete 0 5) ; delete-samples 0 5 [10:1]:
   (at 0, end_mark)
"))
	    (snd-display ";new 13: ~A" (display-edits ind 0 10)))
	(delete-samples 0 10)
	(if (not (= (edit-position) 10))
	    (snd-display ";no-op delete deleted something! ~A" (display-edits)))
	(insert-samples 0 3 (make-vct 3))
	(if (not (string-=? (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 ";new 14: ~A" (display-edits ind 0 11)))
	(delete-samples 2 1)
	(if (not (string-=? (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 ";new 15: ~A" (display-edits ind 0 12)))
	(set! (sample 0) .5)
	(if (not (string-=? (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 ";new 16: ~A" (display-edits ind 0 13)))
	(set! (sample 1) .5)
	(if (not (string-=? (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 ";new 17: ~A" (display-edits ind 0 14)))  
	(map-channel (lambda (y) 1.0) 0 10)
	(if (not (string-=? (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 ";new 18: ~A" (display-edits ind 0 15)))  
	(insert-samples 0 10 (make-vct 10))
	(if (not (string-=? (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 ";new 19: ~A" (display-edits ind 0 16)))
	(set! (samples 2 3) (make-vct 3))
	(if (not (string-=? (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 ";new 20: ~A" (display-edits ind 0 17)))
	(set! (samples 0 12) (make-vct 12))
	(if (not (string-=? (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 ";new 21: ~A" (display-edits ind 0 18)))
	(set! (samples 30 10) (make-vct 10))
	(if (not (string-=? (display-edits ind 0 19) "
 (silence 20 11) ; pad-channel [19:4]:
   (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:10, 0.000])
   (at 31, end_mark)
"))
	    (snd-display ";new 22 silence extension: ~A" (display-edits ind 0 19)))
	(if (not (string-=? (display-edits ind 0 20) "
 (set 30 10) ; set-samples [20: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 ";new 21: ~A" (display-edits ind 0 20)))
	(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-=? (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 ";scl 0: ~A" (display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 0 3)
	(if (not (string-=? (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 ";scl 1: ~A" (display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 5 5)
	(if (not (string-=? (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 ";scl 2: ~A" (display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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 ";scl 2a: ~A" (display-edits ind 0 2)))
	(undo)
	(scale-channel 0.5 10 10)
	(if (not (= (edit-position) 1))
	    (snd-display ";scale beyond end edited? ~A" (display-edits)))
	(scale-channel 0.5 100 10)
	(if (not (= (edit-position) 1))
	    (snd-display ";scale way beyond end edited? ~A" (display-edits)))
	(scale-channel 0.5 5 10)
	(if (not (string-=? (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 ";scl 3: ~A" (display-edits ind 0 2)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (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 ";scl 4: ~A" (display-edits ind 0 2)))
	(scale-channel 0.5 0 4)
	(if (not (string-=? (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 ";scl 5: ~A" (display-edits ind 0 3)))
	(scale-channel 0.5 4 1)
	(if (not (string-=? (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 ";scl 6: ~A" (display-edits ind 0 4)))
	(scale-channel 0.5 0 7)
	(if (not (string-=? (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 ";scl 7: ~A" (display-edits ind 0 5)))
	(scale-channel 0.5 1 4)
	(if (not (string-=? (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 ";scl 8: ~A" (display-edits ind 0 6)))
	(undo 4)
	(scale-channel 0.5 1 8)
	(if (not (string-=? (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 ";scl 9: ~A" (display-edits ind 0 3)))
	(undo 2)
	
	(ramp-channel 0.0 1.0)
	(if (not (string-=? (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 ";ramp 0: ~A" (display-edits ind 0 2)))
	(scale-channel 0.5)
	(if (not (string-=? (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 ";ramp 1: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ramp 2: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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 ";ramp 3: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 5 5)
	(if (not (string-=? (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 ";ramp 4: ~A" (display-edits ind 0 3)))
	(undo 2)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (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 ";ramp 5: ~A" (display-edits ind 0 2)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ramp 6: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 2 6)
	(if (not (string-=? (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 ";ramp 7: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 5 4)
	(if (not (string-=? (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 ";ramp 8: ~A" (display-edits ind 0 3)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (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 ";ramp 9: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 4 1)
	(if (not (string-=? (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 ";ramp 10: ~A" (display-edits ind 0 3)))
	(undo)
	(delete-sample 4)
	(if (not (string-=? (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 ";ramp 11: ~A" (display-edits ind 0 3)))
	(undo)
	(delete-samples 4 2)
	(if (not (string-=? (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 ";ramp 12: ~A" (display-edits ind 0 3)))
	(undo)
	(delete-samples 4 3)
	(if (not (string-=? (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 ";ramp 13: ~A" (display-edits ind 0 3)))
	(undo)
	(delete-samples 4 4)
	(if (not (string-=? (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 ";ramp 14: ~A" (display-edits ind 0 3)))
	(undo)
	(delete-samples 4 5)
	(if (not (string-=? (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 ";ramp 15: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-channel 0.5 4 2)
	(if (not (string-=? (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 ";ramp 16: ~A" (display-edits ind 0 3)))
	(undo)
	(pad-channel 4 1)
	(if (not (string-=? (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 ";ramp 17: ~A" (display-edits ind 0 3)))
	(close-sound ind))
      
      ;; xramp
      (let ((ind (new-sound "test.snd")))
	(map-channel (lambda (y) 1.0) 0 10)
	(xramp-channel 0.0 1.0 32.0)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display ";xramp 1: ~A" (display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.0 1.0 0.325)
	(if (not (string-=? (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, [4]-0.000 -> -1.124, off: 1.481, scl: -1.481]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display ";xramp 2: ~A" (display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.0 1.0 0.0)
	(if (not (string-=? (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 ";xramp 3: ~A" (display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.0 1.0 1.0)
	(if (not (string-=? (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 ";xramp 4: ~A" (display-edits ind 0 2)))
	(undo)
	(xramp-channel 0.5 1.5 32.0)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: 0.468, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display ";xramp 5: ~A" (display-edits ind 0 2)))
	(if (or (fneq (maxamp) 1.5) (fneq (sample 0) 0.5))
	    (snd-display ";xramp 5 vals: ~A ~A" (maxamp) (sample 0)))
	(undo)
	(xramp-channel -0.5 1.5 32.0)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: -0.565, scl: 0.065]) [buf: 10] 
   (at 10, end_mark)
"))
	    (snd-display ";xramp 6: ~A" (display-edits ind 0 2)))
	(if (or (fneq (maxamp) 1.5) (fneq (sample 0) -0.5))
	    (snd-display ";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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display ";xramp 7: ~A" (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 ";trouble in xramp 7: ~A" baddy)))
	  (undo)
	  (delete-sample 0)
	  (if (not (string-=? (display-edits ind 0 3) "
 (delete 0 1) ; delete-samples 0 1 [3:2]:
   (at 0, cp->sounds[1][1:9, 1.000, [4]0.385 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 9, end_mark)
"))
	      (snd-display ";xramp 8: ~A" (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 ";trouble in xramp 8: ~A" baddy)))
	  (undo)
	  (delete-samples 0 2)
	  (if (not (string-=? (display-edits ind 0 3) "
 (delete 0 2) ; delete-samples 0 2 [3:2]:
   (at 0, cp->sounds[1][2:9, 1.000, [4]0.770 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 8, end_mark)
"))
	      (snd-display ";xramp 9: ~A" (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 ";trouble in xramp 9: ~A" baddy)))
	  (undo)
	  (delete-sample 0)
	  (delete-sample 0)
	  (if (not (string-=? (display-edits ind 0 4) "
 (delete 0 1) ; delete-samples 0 1 [4:2]:
   (at 0, cp->sounds[1][2:9, 1.000, [4]0.770 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 8, end_mark)
"))
	      (snd-display ";xramp 10: ~A" (display-edits ind 0 4)))
	  (undo 2)
	  (delete-sample 4)
	  (if (not (string-=? (display-edits ind 0 3) "
 (delete 4 1) ; delete-samples 4 1 [3:3]:
   (at 0, cp->sounds[1][0:3, 1.000, [4]0.000 -> 1.155, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[1][5:9, 1.000, [4]1.925 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 9, end_mark)
"))
	      (snd-display ";xramp 11: ~A" (display-edits ind 0 3)))
	  (undo)
	  (delete-samples 4 2)
	  (if (not (string-=? (display-edits ind 0 3) "
 (delete 4 2) ; delete-samples 4 2 [3:3]:
   (at 0, cp->sounds[1][0:3, 1.000, [4]0.000 -> 1.155, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[1][6:9, 1.000, [4]2.310 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 8, end_mark)
"))
	      (snd-display ";xramp 12: ~A" (display-edits ind 0 3)))
	  (undo)
	  (scale-channel 0.5 4 2)
	  (if (not (string-=? (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, [4]0.000 -> 1.155, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 4, cp->sounds[1][4:5, 0.500, [4]1.540 -> 1.925, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 6, cp->sounds[1][6:9, 1.000, [4]2.310 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display ";xramp 13: ~A" (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 ";trouble in xramp 8: ~A" baddy)))
	  (undo)
	  (scale-channel 0.5 0 2)
	  (if (not (string-=? (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, [4]0.000 -> 0.385, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 2, cp->sounds[1][2:9, 1.000, [4]0.770 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display ";xramp 14: ~A" (display-edits ind 0 3)))
	  (undo)
	  (pad-channel 4 2)
	  (if (not (string-=? (display-edits ind 0 3) "
 (silence 4 2) ; pad-channel [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [4]0.000 -> 1.155, 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, [4]1.540 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 12, end_mark)
"))
	      (snd-display ";xramp 15: ~A" (display-edits ind 0 3)))
	  (undo)
	  (set! (sample 4) 1.0)
	  (if (not (string-=? (display-edits ind 0 3) "
 (set 4 1) ; set-sample 4 1.0000 [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [4]0.000 -> 1.155, 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, [4]1.925 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display ";xramp 16: ~A" (display-edits ind 0 3)))
	  (undo)
	  (set! (samples 4 2) (make-vct 2))
	  (if (not (string-=? (display-edits ind 0 3) "
 (set 4 2) ; set-samples [3:4]:
   (at 0, cp->sounds[1][0:3, 1.000, [4]0.000 -> 1.155, 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, [4]2.310 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display ";xramp 17: ~A" (display-edits ind 0 3)))
	  (undo)
	  (scale-channel 0.5)
	  (set! (samples 4 2) (make-vct 2))
	  (if (not (string-=? (display-edits ind 0 4) "
 (set 4 2) ; set-samples [4:4]:
   (at 0, cp->sounds[1][0:3, 0.500, [4]0.000 -> 1.155, 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, [4]2.310 -> 3.466, off: -0.032, scl: 0.032]) [buf: 10] 
   (at 10, end_mark)
"))
	      (snd-display ";xramp 18: ~A" (display-edits ind 0 4)))
	  )
	(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.5 (* i 10) 10))
	(ramp-channel 0.0 1.0)
	(if (not (string=? (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 ";multi-ramp 1: ~A" (display-edits ind 0 12)))
	(if (fneq (maxamp) 0.5) (snd-display ";multi ramp 1 maxamp: ~A" (maxamp)))
	(undo)
	(ramp-channel 0.1 1.0 10 90)
	(if (not (string=? (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 ";multi-ramp 2: ~A" (display-edits ind 0 12)))
	(if (fneq (maxamp) 0.5) (snd-display ";multi ramp 2 maxamp: ~A" (maxamp)))
	(undo)
	(ramp-channel 0.0 0.9 0 90)
	(if (not (string=? (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 ";multi-ramp 3: ~A" (display-edits ind 0 12)))
	(if (fneq (maxamp) 0.5) (snd-display ";multi ramp 3 maxamp: ~A" (maxamp)))
	(if (fneq (sample 89) 0.45) (snd-display ";multi ramp 3 sample 89: ~A" (sample 89)))
	(if (fneq (sample 90) 0.5) (snd-display ";multi ramp 3 sample 90: ~A" (sample 90)))
	(undo)
	(ramp-channel 0.1 0.9 10 80)
	(if (not (string=? (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 ";multi-ramp 4: ~A" (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=? (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 ";multi-ramp 5: ~A" (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 ";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=? (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 ";multi-tree 0: ~A" (display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";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=? (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 ";multi-tree 1: ~A" (display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";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 ";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-=? (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 ";multi-tree 2: ~A" (display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";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 ";map and ptree 10:80 cosine disagree: ~A ~A" map-data tree-data)))
	  (if (not (string-=? (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 ";multi-tree 3: ~A" (display-edits ind 0 12 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";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 ";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-=? (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 ";multi-tree 4: ~A" (display-edits ind 0 13 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";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-=? (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 ";multi-tree 5: ~A" (display-edits ind 0 13 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 2.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";map and ptree->ramp (scl) cosine disagree: ~A ~A" map-data scl-data)))
	  
	  (scale-channel 0.5)
	  (if (not (string-=? (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 ";multi-tree 5 + scl: ~A" (display-edits ind 0 14 #f)))
	  (let ((scl-data (vct-scale! (channel->vct) 4.0)))
	    (if (not (vequal map-data scl-data))
		(snd-display ";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-=? (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 ";multi-tree 6: ~A" (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 ";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-=? (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 ";multi-tree 7: ~A" (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)
			 (declare (y real) (data vct) (forward boolean))
			 (* y (vct-ref data 0)))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct 0.5)))
	(ptree-channel (lambda (y data forward)
			 (declare (y real) (data vct) (forward boolean))
			 (* 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 ";p2 pos test data: ~A" data))
	  (if (not (string-=? (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 ";p2 pos multi: ~A" (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 ";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-=? (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, [4]0.000 -> 0.315, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [4]0.350 -> 0.665, off: -0.032, scl: 0.032, loc: 0, pos: 10, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [4]0.700 -> 1.015, off: -0.032, scl: 0.032, loc: 0, pos: 20, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [4]1.050 -> 1.365, off: -0.032, scl: 0.032, loc: 0, pos: 30, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [4]1.400 -> 1.715, off: -0.032, scl: 0.032, loc: 0, pos: 40, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [4]1.750 -> 2.065, off: -0.032, scl: 0.032, loc: 0, pos: 50, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [4]2.100 -> 2.416, off: -0.032, scl: 0.032, loc: 0, pos: 60, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [4]2.451 -> 2.766, off: -0.032, scl: 0.032, loc: 0, pos: 70, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [4]2.801 -> 3.116, off: -0.032, scl: 0.032, loc: 0, pos: 80, scl: 1.000]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [4]3.151 -> 3.466, off: -0.032, scl: 0.032, loc: 0, pos: 90, scl: 1.000]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-tree 9: ~A" (display-edits ind 0 13 #f)))
	(let ((scl-data (vct-scale! (channel->vct) 2.0)))
	  (if (not (vequal map-data scl-data))
	      (snd-display ";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-=? (display-edits ind 0 13 #f) "
 (ptree[0] 0 100) ; ptree-channel [13:11]:
   (at 0, cp->sounds[1][0:9, 1.000, [4]0.000 -> 0.315, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [4]0.350 -> 0.665, off: -0.032, scl: 0.032, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [4]0.700 -> 1.015, off: -0.032, scl: 0.032, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [4]1.050 -> 1.365, off: -0.032, scl: 0.032, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [4]1.400 -> 1.715, off: -0.032, scl: 0.032, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [4]1.750 -> 2.065, off: -0.032, scl: 0.032, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [4]2.100 -> 2.416, off: -0.032, scl: 0.032, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [4]2.451 -> 2.766, off: -0.032, scl: 0.032, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [4]2.801 -> 3.116, off: -0.032, scl: 0.032, loc: 0, pos: 80, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 1.000, [4]3.151 -> 3.466, off: -0.032, scl: 0.032, loc: 0, pos: 90, scl: 0.500]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-tree 10: ~A" (display-edits ind 0 13 #f)))
	(let ((scl-data (vct-scale! (channel->vct) 2.0)))
	  (if (not (vequal map-data scl-data))
	      (snd-display ";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-=? (display-edits ind 0 13 #f) "
 (ptree[0] 10 80) ; ptree-channel [13:11]:
   (at 0, cp->sounds[1][0:9, 0.500, [4]0.000 -> 0.315, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 1.000, [4]0.350 -> 0.665, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 0.500]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 1.000, [4]0.700 -> 1.015, off: -0.032, scl: 0.032, loc: 0, pos: 10, scl: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 1.000, [4]1.050 -> 1.365, off: -0.032, scl: 0.032, loc: 0, pos: 20, scl: 0.500]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 1.000, [4]1.400 -> 1.715, off: -0.032, scl: 0.032, loc: 0, pos: 30, scl: 0.500]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [4]1.750 -> 2.065, off: -0.032, scl: 0.032, loc: 0, pos: 40, scl: 0.500]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 1.000, [4]2.100 -> 2.416, off: -0.032, scl: 0.032, loc: 0, pos: 50, scl: 0.500]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 1.000, [4]2.451 -> 2.766, off: -0.032, scl: 0.032, loc: 0, pos: 60, scl: 0.500]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 1.000, [4]2.801 -> 3.116, off: -0.032, scl: 0.032, loc: 0, pos: 70, scl: 0.500]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [4]3.151 -> 3.466, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-tree 11: ~A" (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 ";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-=? (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, [4]0.000 -> 0.315, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:14, 0.500, [4]0.350 -> 0.490, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 15, cp->sounds[1][15:19, 0.500, [4]0.525 -> 0.665, off: -0.032, scl: 0.032, loc: 0, pos: 0, scl: 1.000]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [4]0.700 -> 1.015, off: -0.032, scl: 0.032, loc: 0, pos: 5, scl: 1.000]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [4]1.050 -> 1.365, off: -0.032, scl: 0.032, loc: 0, pos: 15, scl: 1.000]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [4]1.400 -> 1.715, off: -0.032, scl: 0.032, loc: 0, pos: 25, scl: 1.000]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [4]1.750 -> 2.065, off: -0.032, scl: 0.032, loc: 0, pos: 35, scl: 1.000]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [4]2.100 -> 2.416, off: -0.032, scl: 0.032, loc: 0, pos: 45, scl: 1.000]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [4]2.451 -> 2.766, off: -0.032, scl: 0.032, loc: 0, pos: 55, scl: 1.000]) [buf: 100] 
   (at 80, cp->sounds[1][80:84, 0.500, [4]2.801 -> 2.941, off: -0.032, scl: 0.032, loc: 0, pos: 65, scl: 1.000]) [buf: 100] 
   (at 85, cp->sounds[1][85:89, 0.500, [4]2.976 -> 3.116, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [4]3.151 -> 3.466, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-tree 12: ~A" (display-edits ind 0 13 #f)))
	
	(close-sound ind))
      
      ;; ptree2
      (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)))
	(if (not (vequal (channel->vct) (make-vct 11 0.5)))
	    (snd-display ";ptree2 0: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2 3: ~A" (display-edits ind 0 2)))
	(ptree-channel (lambda (y) (* y 1.5)))
	(if (not (vequal (channel->vct) (make-vct 11 0.75)))
	    (snd-display ";ptree2 1: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2 4: ~A" (display-edits ind 0 3)))
	(undo)
	(scale-by (vct 1.5))
	(if (not (vequal (channel->vct) (make-vct 11 0.75)))
	    (snd-display ";ptree2 5: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2 6: ~A" (display-edits ind 0 3)))
	(ptree-channel (lambda (y) (* y 0.1)))
	(if (not (vequal (channel->vct) (make-vct 11 0.075)))
	    (snd-display ";ptree2 7: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2 8: ~A" (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 ";ptree2 9: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2 10: ~A" (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 ";ptree2 11: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2 12: ~A" (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 ";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 ";ptree2-zero 1: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2-zero 2: ~A" (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 ";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 ";ptree2-ramp 1: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2-ramp 2: ~A" (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 ";ptree2-ramp 3: ~A" (channel->vct)))
	(if (not (string-=? (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 ";ptree2-ramp 4: ~A" (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-=? (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 ";ptree-ramp3: ~A" (display-edits ind 0 5 #f)))
	(undo 1)
	(ptree-channel (lambda (y data forward)
			 (declare (y real) (data vct) (forward boolean))
			 (* y (vct-ref data 0)))
		       0 (frames) ind 0 #f #t
		       (lambda (pos dur)
			 (vct 0.5)))
	(if (not (string-=? (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 ";ptreec-ramp3: ~A" (display-edits ind 0 5 #f)))
	(undo 1)
	(xen-channel (lambda (y data forward) (* y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.25)))
	(if (not (string-=? (display-edits ind 0 5 #f) "
 (xen[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 ";xen-ramp3: ~A" (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-=? (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, [3]0.000 -> 3.466, [4]0.000 -> 3.466, off: -0.032, scl: 0.032, off2: -0.032, scl2: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp-xramp2: ~A" (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-=? (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 ";ramp2 0: ~A" (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 ";ramp2 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (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 ";ramp2 1: ~A" (display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ramp2 2: ~A" (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 ";ramp2 (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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 ";ramp2 3: ~A" (display-edits ind 0 4)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string-=? (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 ";ramp2 4: ~A" (display-edits ind 0 3)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (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 ";ramp2 5: ~A" (display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ramp2 6: ~A" (display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (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 ";ramp2 7: ~A" (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-=? (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 ";multi-ramp2 1: ~A" (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-=? (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 ";multi-ramp2 2: ~A" (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-=? (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 ";~A 1: ~A" name (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 ";~A 1: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (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 ";~A 2: ~A" name (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 ";~A 2: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (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 ";~A 3: ~A" name (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 ";~A 3: ~A" name (channel->vct)))
	   
	   (undo 4)
	   (scale-by 0.0)
	   (func-zero)
	   (ramp-channel 0 1)
	   (if (not (string-=? (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 ";~A-zero 1: ~A" name (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 ";~A-zero 1: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (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 ";~A-zero 2: ~A" name (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 ";~A-zero 2: ~A" name (channel->vct)))
	   (ramp-channel 0 1)
	   (if (not (string-=? (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 ";~A-zero 3: ~A" name (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 ";~A-zero 3: ~A" name (channel->vct)))
	   (undo 5)
	   )
	 (list 
	  (lambda () (ptree-channel (lambda (y) (* y 0.5))))
	  (lambda () (xen-channel (lambda (y data forward) (* y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(declare (y real) (data vct) (forward boolean))
			(* 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 () (xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(declare (y real) (data vct) (forward boolean))
			(+ y (vct-ref data 0)))
		      0 (frames) ind 0 #f #f (lambda (p d) (vct 0.5)))))
	 (list "ramp-ptree" "ramp-xen" "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 ";~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 ";~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 ";~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 ";~A-zero 2: ~A" name (channel->vct)))
		 (undo 1)))
	   (undo 3))
	 (list 
	  (lambda () (ptree-channel (lambda (y) (* y 0.5))))
	  (lambda () (xen-channel (lambda (y data forward) (* y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(declare (y real) (data vct) (forward boolean))
			(* 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 () (xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.5))))
	  (lambda () (ptree-channel
		      (lambda (y data forward)
			(declare (y real) (data vct) (forward boolean))
			(+ y (vct-ref data 0)))
		      0 (frames) ind 0 #f #f (lambda (p d) (vct 0.5)))))
	 (list "xramp-ptree" "xramp-xen" "xramp-ptreec")
	 (list #t #f #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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp-xramp 0: ~A" (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 ";ramp-xramp (1): ~A" case1))
	(scale-channel 0.5)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp-xramp 1: ~A" (display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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, [4]0.000 -> 1.386, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [4]1.733 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp-xramp 2: ~A" (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 ";ramp-xramp (2): ~A" case2))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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, [4]0.000 -> 0.347, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [4]0.693 -> 1.733, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [4]2.079 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp-xramp 3: ~A" (display-edits ind 0 4)))
	(undo 2)
	(xramp-channel 0.75 0.25 32.0)
	(if (not (string-=? (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, [4]3.466 -> 0.000, off: 0.234, scl: 0.016]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp-xramp 4: ~A" (display-edits ind 0 3)))
	(undo)
	(xramp-channel .2 .6 3.0 2 6)
	(if (not (string-=? (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, [4]-0.000 -> 1.099, 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 ";ramp-xramp 5: ~A" (display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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, [4]-0.000 -> 0.439, off: -0.000, scl: 0.200]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.500 -> 0.700, [4]0.659 -> 1.099, 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 ";ramp-xramp 6: ~A" (display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (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, [4]-0.000 -> 0.220, 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, [4]0.659 -> 1.099, 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 ";ramp-xramp 7: ~A" (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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 0: ~A" (display-edits ind 0 3)))
	(if (not (vequal case1 (channel->vct)))
	    (snd-display ";xramp-ramp (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 1: ~A" (display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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, [4]0.000 -> 1.386, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [1]0.500 -> 1.000, [4]1.733 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 2: ~A" (display-edits ind 0 4)))
	(if (not (vequal case2 (channel->vct)))
	    (snd-display ";xramp-ramp (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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, [4]0.000 -> 0.347, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [1]0.200 -> 0.500, [4]0.693 -> 1.733, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.600 -> 1.000, [4]2.079 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 3: ~A" (display-edits ind 0 4)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 4: ~A" (display-edits ind 0 3)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string=? (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, [4]0.000 -> 0.347, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [1]0.200 -> 0.600, [4]0.693 -> 2.426, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [4]2.773 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 5: ~A" (display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string=? (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, [4]0.000 -> 0.347, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [1]0.200 -> 0.360, [4]0.693 -> 1.386, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [1]0.440 -> 0.600, [4]1.733 -> 2.426, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [4]2.773 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 6: ~A" (display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string=? (display-edits ind 0 4) "
 (set 4 1) ; set-sample 4 0.5000 [4:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [4]0.000 -> 0.347, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [1]0.200 -> 0.280, [4]0.693 -> 1.040, 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, [4]1.733 -> 2.426, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [4]2.773 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp-ramp 7: ~A" (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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 0: ~A" (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 ";ramp2+xramp (1): ~A" case1))
	(scale-channel 0.5)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 1: ~A" (display-edits ind 0 5)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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, [4]0.000 -> 1.386, 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, [4]1.733 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 2: ~A" (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 ";ramp2+xramp (2): ~A" case2))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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, [4]0.000 -> 0.347, 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, [4]0.693 -> 1.733, 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, [4]2.079 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 3: ~A" (display-edits ind 0 5)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 4: ~A" (display-edits ind 0 4)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (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, [4]0.000 -> 0.347, 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, [4]0.693 -> 2.426, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [4]2.773 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 5: ~A" (display-edits ind 0 4)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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, [4]0.000 -> 0.347, 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, [4]0.693 -> 1.386, 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, [4]1.733 -> 2.426, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [4]2.773 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 6: ~A" (display-edits ind 0 5)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (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, [4]0.000 -> 0.347, 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, [4]0.693 -> 1.040, 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, [4]1.733 -> 2.426, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [1]0.800 -> 1.000, [4]2.773 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp2+xramp 7: ~A" (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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp+ramp2 0: ~A" (display-edits ind 0 4)))
	(if (not (vequal case1 (channel->vct)))
	    (snd-display ";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 ";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-=? (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, [4]3.466 -> 3.151, 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, [4]3.116 -> 2.801, 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, [4]2.766 -> 2.451, 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, [4]2.416 -> 2.100, 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, [4]2.065 -> 1.750, 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, [4]1.715 -> 1.400, 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, [4]1.365 -> 1.050, 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, [4]1.015 -> 0.700, 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, [4]0.665 -> 0.350, 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, [4]0.315 -> -0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-ramp2+xramp 1: ~A" (display-edits ind 0 14)))
	(if (not (vequal case3 (channel->vct)))
	    (snd-display ";multi-ramp2+xramp: ~A" (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-=? (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, [4]3.466 -> 3.151, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:24, 1.000, [1]-0.000 -> 0.737, [4]3.116 -> 2.626, 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, [4]2.591 -> 2.451, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [1]0.556 -> 1.000, [4]2.416 -> 2.275, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 35, cp->sounds[1][35:49, 1.000, [4]2.240 -> 1.750, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 1.000, [1]-0.000 -> 1.000, [4]1.715 -> 1.400, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:99, 1.000, [4]1.365 -> 0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-ramp2+xramp 2: ~A" (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-=? (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, [4]3.466 -> 3.151, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [4]3.116 -> 2.801, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [4]2.766 -> 2.451, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [4]2.416 -> 2.100, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [4]2.065 -> 1.750, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [4]1.715 -> 1.400, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [4]1.365 -> 1.050, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [4]1.015 -> 0.700, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [4]0.665 -> 0.350, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [4]0.315 -> -0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-ramp-xramp 1: ~A" (display-edits ind 0 13)))
	(if (not (vequal case3 (channel->vct)))
	    (snd-display ";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-=? (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, [4]-0.000 -> 0.810, off: -0.500, scl: 0.500]) [buf: 100] 
   (at 25, cp->sounds[1][25:29, 1.000, [3]0.000 -> 0.488, [4]0.867 -> 1.099, off: -0.500, scl: 0.500, off2: -0.500, scl2: 0.500]) [buf: 100] 
   (at 30, cp->sounds[1][30:34, 1.000, [4]0.610 -> 1.099, 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, [4]0.000 -> 1.099, 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 ";multi-ramp-xramp 2: ~A" (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-=? (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, [4]3.466 -> 3.151, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [1]0.101 -> 0.192, [4]3.116 -> 2.801, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [1]0.202 -> 0.293, [4]2.766 -> 2.451, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [1]0.303 -> 0.394, [4]2.416 -> 2.100, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [1]0.404 -> 0.495, [4]2.065 -> 1.750, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [1]0.505 -> 0.596, [4]1.715 -> 1.400, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [1]0.606 -> 0.697, [4]1.365 -> 1.050, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [1]0.707 -> 0.798, [4]1.015 -> 0.700, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [1]0.808 -> 0.899, [4]0.665 -> 0.350, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [1]0.909 -> 1.000, [4]0.315 -> -0.000, off: -0.032, scl: 0.032]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-xramp-ramp 1: ~A" (display-edits ind 0 13)))
	(if (not (vequal case3 (channel->vct)))
	    (snd-display ";case3 xramp-ramp: ~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-=? (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 ";multi-xramp-ramp 2: ~A" (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=? (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, [3]0.000 -> 0.693, [4]0.000 -> 0.693, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 0: ~A" (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 ";xramp2 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string=? (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, [3]0.000 -> 0.693, [4]0.000 -> 0.693, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 1: ~A" (display-edits ind 0 4)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string=? (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, [3]0.000 -> 0.277, [4]0.000 -> 0.277, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 5, cp->sounds[1][5:10, 1.000, [3]0.347 -> 0.693, [4]0.347 -> 0.693, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 2: ~A" (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 ";xramp2 (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string=? (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, [3]0.000 -> 0.069, [4]0.000 -> 0.069, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:5, 0.500, [3]0.139 -> 0.347, [4]0.139 -> 0.347, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [3]0.416 -> 0.693, [4]0.416 -> 0.693, off: -1.000, scl: 1.000, off2: -1.000, scl2: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 3: ~A" (display-edits ind 0 4)))
	(undo 2)
	(xramp-channel 0.75 0.25 0.3)
	(if (not (string-=? (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, [3]-1.204 -> -0.000, [4]0.000 -> 0.693, off: -1.000, scl: 1.000, off2: 0.964, scl2: -0.714]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 4: ~A" (display-edits ind 0 3)))
	(undo)
	(xramp-channel .2 .6 32.0 2 6)
	(if (not (string=? (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, [4]0.000 -> 0.069, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:7, 1.000, [3]0.000 -> 3.466, [4]0.139 -> 0.485, off: -1.000, scl: 1.000, off2: 0.187, scl2: 0.013]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [4]0.555 -> 0.693, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 5: ~A" (display-edits ind 0 3)))
	(scale-channel 0.5 0 5)
	(if (not (string=? (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, [4]0.000 -> 0.069, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:4, 0.500, [3]0.000 -> 1.386, [4]0.139 -> 0.277, off: -1.000, scl: 1.000, off2: 0.187, scl2: 0.013]) [buf: 11] 
   (at 5, cp->sounds[1][5:7, 1.000, [3]2.079 -> 3.466, [4]0.347 -> 0.485, off: -1.000, scl: 1.000, off2: 0.187, scl2: 0.013]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [4]0.555 -> 0.693, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 6: ~A" (display-edits ind 0 4)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string=? (display-edits ind 0 4) "
 (set 4 1) ; set-sample 4 0.5000 [4:6]:
   (at 0, cp->sounds[1][0:1, 1.000, [4]0.000 -> 0.069, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[1][2:3, 1.000, [3]0.000 -> 0.693, [4]0.139 -> 0.208, off: -1.000, scl: 1.000, off2: 0.187, scl2: 0.013]) [buf: 11] 
   (at 4, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 5, cp->sounds[1][5:7, 1.000, [3]2.079 -> 3.466, [4]0.347 -> 0.485, off: -1.000, scl: 1.000, off2: 0.187, scl2: 0.013]) [buf: 11] 
   (at 8, cp->sounds[1][8:10, 1.000, [4]0.555 -> 0.693, off: -1.000, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp2 7: ~A" (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-=? (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, [3]-1.204 -> -1.095, [4]-0.000 -> 0.100, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 10, cp->sounds[1][10:19, 0.500, [3]-1.082 -> -0.973, [4]0.111 -> 0.211, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 20, cp->sounds[1][20:29, 0.500, [3]-0.961 -> -0.851, [4]0.222 -> 0.322, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 30, cp->sounds[1][30:39, 0.500, [3]-0.839 -> -0.730, [4]0.333 -> 0.433, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 40, cp->sounds[1][40:49, 0.500, [3]-0.718 -> -0.608, [4]0.444 -> 0.544, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 50, cp->sounds[1][50:59, 0.500, [3]-0.596 -> -0.486, [4]0.555 -> 0.655, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 60, cp->sounds[1][60:69, 0.500, [3]-0.474 -> -0.365, [4]0.666 -> 0.766, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 70, cp->sounds[1][70:79, 0.500, [3]-0.353 -> -0.243, [4]0.777 -> 0.877, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 80, cp->sounds[1][80:89, 0.500, [3]-0.231 -> -0.122, [4]0.888 -> 0.988, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 90, cp->sounds[1][90:99, 0.500, [3]-0.109 -> -0.000, [4]0.999 -> 1.099, off: -0.500, scl: 0.500, off2: 1.429, scl2: -1.429]) [buf: 100] 
   (at 100, end_mark)
"))
	    (snd-display ";multi-xramp2 1: ~A" (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-=? (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 ";ptree-ramp2 0: ~A" (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 ";ptree-ramp2 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (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 ";ptree-ramp2 1: ~A" (display-edits ind 0 5 #f)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ptree-ramp2 2: ~A" (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 ";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-=? (display-edits ind 0 5 #f) "
 (ptree[0] 0 11) ; ptree-channel [5:5]:
   (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:5, 1.000, [1]1.000 -> 1.000, loc: 0, pos: 5, scl: 0.500]) [buf: 11] 
   (at 6, cp->sounds[1][6:10, 1.000, [1]0.800 -> 0.000, loc: 0, pos: 6, scl: 0.500]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ptree-ramp2 4: ~A" (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)
			 (declare (y real) (data vct) (forward boolean))
			 (* y (vct-ref data 0)))
		       0 (frames) ind 0 #f #t
		       (lambda (pos dur)
			 (vct 0.5)))
	(if (not (string-=? (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 ";ptree-ramp2 5: ~A" (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 ";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-=? (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 ";ptree multi-ramp2 1: ~A" (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-=? (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 ";ptree-ramp3 0: ~A" (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 ";ptree-ramp3 1: ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (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 ";ptree-ramp3 2: ~A" (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-=? (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 ";ptree-ramp3 3: ~A" (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 ";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-=? (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 ";ramp3 0: ~A" (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 ";ramp3 (1): ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (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 ";ramp3 1: ~A" (display-edits ind 0 5)))
	(undo)
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ramp3 2: ~A" (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 ";ramp3 (2): ~A" (channel->vct)))
	(undo)
	(scale-channel 0.5 2 4)
	(if (not (string-=? (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 ";ramp3 3: ~A" (display-edits ind 0 5)))
	(undo 2)
	(ramp-channel 0.75 0.25)
	(if (not (string-=? (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 ";ramp3 4: ~A" (display-edits ind 0 4)))
	(undo)
	(ramp-channel .2 .6 2 6)
	(if (not (string-=? (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 ";ramp3 5: ~A" (display-edits ind 0 4)))
	(scale-channel 0.5 0 5)
	(if (not (string-=? (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 ";ramp3 6: ~A" (display-edits ind 0 5)))
	(undo)
	(set! (sample 4) .5)
	(if (not (string-=? (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 ";ramp3 7: ~A" (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=? (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 ";multi-ramp3 1: ~A" (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-=? (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 ";multi-ramp3 2: ~A" (display-edits ind 0 5)))
	
	;; xen
	(let ((ind (new-sound "test.snd")))
	  (map-chan (lambda (y) 1.0) 0 10)
	  (xen-channel (lambda (y data forward)
			 (+ y (list-ref data 0)))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (list 0.5)))
	  (if (not (string=? (display-edits ind 0 2) "
 (xen[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 data forward) (+ y (list-ref data 0))), init: (lambda (pos dur) (list 0.5))]) [buf: 11] 
   (at 11, end_mark)
"))
	      (snd-display ";xen 0: ~A" (display-edits ind 0 2)))
	  (if (not (vequal (channel->vct) (make-vct 11 1.5)))
	      (snd-display ";xen 0: ~A" (channel->vct)))
	  (undo)
	  (ramp-channel 0.0 1.0)
	  (xen-channel (lambda (y data forward)
			 (let ((val (* 0.5 (+ y (list-ref data 0)))))
			   (list-set! data 0 y)
			   val))
		       0 (frames) ind 0 #f #f
		       (let ((edpos (edit-position ind 0)))
			 (lambda (pos dur)
			   (list (if (= pos 0) 0.0
				     (sample (1- pos) ind 0 edpos))))))
	  (if (not (string-=? (display-edits ind 0 2 #f) "
 (ramp 0 11) ; ramp-channel 0.000 1.000 0 #f [2:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000]) [buf: 11] 
   (at 11, end_mark)
"))	
	      (snd-display ";xen 1: ~A" (display-edits ind 0 2 #f)))
	  (if (not (vequal (channel->vct) (vct 0.000 0.050 0.150 0.250 0.350 0.450 0.550 0.650 0.750 0.850 0.950)))
	      (snd-display ";xen 1: ~A" (channel->vct)))
	  (undo 2)
	  
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 1.0 0.0)
	  (let ((outer .5))
	    (xen-channel (lambda (y data forward)
			   (data y))
			 0 (frames) ind 0 #f #f
			 (lambda (pos dur)
			   (lambda (y)
			     (* outer y)))))
	  (if (not (string-=? (display-edits ind 0 4 #f) "
 (xen[0] 0 11) ; ptree-channel [4:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [1]-0.000 -> 1.000, [2]1.000 -> -0.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	      (snd-display ";xen 2: ~A" (display-edits ind 0 4 #f)))
	  (if (not (vequal (channel->vct) (vct 0.000 0.045 0.080 0.105 0.120 0.125 0.120 0.105 0.080 0.045 0.000)))
	      (snd-display ";xen 2: ~A" (channel->vct)))
	  (undo 3)
	  
	  (xramp-channel 0.0 1.0 3.0)
	  (xen-channel (lambda (y data forward)
			 (let ((val (* y (vector-ref data 0))))
			   (vector-set! data 0 (+ (vector-ref data 0) (if forward .1 -.1)))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (let ((val (make-vector 1)))
			   (vector-set! val 0 (* pos .1))
			   val)))
	  (if (not (string-=? (display-edits ind 0 3 #f) "
 (xen[0] 0 11) ; ptree-channel [3:2]:
   (at 0, cp->sounds[1][0:10, 1.000, [4]-0.000 -> 1.099, off: -0.500, scl: 0.500, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	      (snd-display ";xen 3: ~A" (display-edits ind 0 3 #f)))
	  (if (not (vequal (channel->vct) (vct 0.000 0.006 0.025 0.059 0.110 0.183 0.280 0.405 0.563 0.760 1.000)))
	      (snd-display ";xen 3: ~A" (channel->vct)))
	  
	  (undo 2)
	  (pad-channel 2 5)
	  (xen-channel (lambda (y data forward) (+ y .1)))
	  (if (not (string=? (display-edits ind 0 3 #f) "
 (xen[0] 0 16) ; ptree-channel [3:4]:
   (at 0, cp->sounds[1][0:1, 1.000, loc: 0, pos: 0, scl: 1.000]) [buf: 11] 
   (at 2, cp->sounds[-1][0:4, 1.000, loc: 0, pos: 2, scl: 0.000])
   (at 7, cp->sounds[1][2:10, 1.000, loc: 0, pos: 7, scl: 1.000]) [buf: 11] 
   (at 16, end_mark)
"))
	      (snd-display ";xen 5: ~A" (display-edits ind 0 3 #f)))
	  (if (not (vequal (channel->vct 0 10) (vct 1.100 1.100 0.100 0.100 0.100 0.100 0.100 1.100 1.100 1.100)))
	      (snd-display ";xen 5: ~A" (channel->vct)))
	  
	  (revert-sound ind)
	  (map-channel (lambda (y) 1.0) 0 100)
	  (do ((i 0 (1+ i)))
	      ((= i 10))
	    (scale-channel 0.5 (* i 10) 10))
	  (xen-channel (lambda (y data forward)
			 (let ((val (* y (vector-ref data 0))))
			   (vector-set! data 0 (+ (vector-ref data 0) (if forward .01 -.01)))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (let ((val (make-vector 1)))
			   (vector-set! val 0 (* pos .01))
			   val)))
	  (if (not (string=? (display-edits ind 0 12 #f) "
 (xen[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 ";xen 4: ~A" (display-edits ind 0 12 #f)))
	  (if (not (vequal (channel->vct 0 10) (vct 0.000 0.005 0.010 0.015 0.020 0.025 0.030 0.035 0.040 0.045)))
	      (snd-display ";xen 4: ~A" (channel->vct)))
	  (close-sound ind))
	
	(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 ";ramp3 opt vs unopt: ~A ~A" vals (channel->vct))))
	
	(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)
	(xen-channel (lambda (y data forward)
		       (+ y (list-ref data 0)))
		     0 (frames) ind 0 #f #f
		     (lambda (pos dur)
		       (list 0.1)))
	(if (not (string-=? (display-edits ind 0 5 #f) "
 (xen[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 ";xen-ramp3 0: ~A" (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 ";xen-ramp3 1: ~A" (channel->vct)))
	(scale-channel 0.5)
	(if (not (string-=? (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 ";xen-ramp3 2: ~A" (display-edits ind 0 6 #f)))
	
	(undo 5)
	(ramp-channel 0 1)
	(ramp-channel 0 1 5 5)
	(ramp-channel 0 1 7 3)
	(xen-channel (lambda (y data forward)
		       (+ y (list-ref data 0)))
		     0 (frames) ind 0 #f #f
		     (lambda (pos dur)
		       (list 0.1)))
	(if (not (string-=? (display-edits ind 0 5 #f) "
 (xen[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 ";xen-ramp3 3: ~A" (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 ";xen-ramp3 4: ~A" (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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp+xramp: ~A" (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=? (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, [3]0.000 -> 3.466, [4]0.000 -> -1.139, off: 1.471, scl: -1.471, off2: -0.032, scl2: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp+xramp: ~A" (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=? (display-edits ind 0 4) "
 (set 0 11) ; env-channel-with-base '(0.000 0.000 1.000 1.000) 32.0000 0 #f [4:2]:
   (at 0, cp->sounds[2][0:10, 1.000]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp+xramp+xramp: ~A" (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-=? (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, [3]0.000 -> 3.466, [4]0.000 -> -1.139, off: 1.471, scl: -1.471, off2: -0.032, scl2: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp+xramp+ramp: ~A" (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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";xramp+ramp: ~A" (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-=? (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, [4]0.000 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp+ramp+xramp: ~A" (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-=? (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 ";ramp+ramp+ramp+ramp: ~A" (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-=? (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 -> 3.466, off: -0.032, scl: 0.032]) [buf: 11] 
   (at 11, end_mark)
"))
	    (snd-display ";ramp+ramp+ramp+xramp: ~A" (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-=? (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 ";ptree+ramp: ~A" (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-=? (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, [4]0.000 -> 3.466, 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 ";ramp+xramp+ptree: ~A" (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-=? (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, [4]0.000 -> 3.466, 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 ";xramp+ramp+ptree: ~A" (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-=? (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 ";ramp3+ptree: ~A" (display-edits ind 0 5)))
	(undo 4)
	
	;; ptree+ptree (now optimized)
	(ptree-channel (lambda (y) y))
	(ptree-channel (lambda (y) y))
	(if (not (string=? (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 ";ptree+ptree: ~A" (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-=? (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 ";ramp ptree2: ~A" (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 ";ramp ptree2: ~A" (channel->vct)))
	(ramp-channel 0 1)
	(if (not (string-=? (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 ";ramp2 ptree2: ~A" (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 ";ramp2 ptree2: ~A" (channel->vct)))
	(undo 2)
	(xramp-channel 0 1 32)
	(if (not (string=? (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, [4]0.000 -> 3.466, 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 ";xramp ptree2: ~A" (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 ";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=? (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 ";ramp ptree2 zero: ~A" (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 ";ramp ptree2 zero: ~A" (channel->vct)))
	(ramp-channel 0 1)
	(if (not (string-=? (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 ";ramp2 ptree2 zero: ~A" (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 ";ramp2 ptree2 zero: ~A" (channel->vct)))
	(undo 2)
	(xramp-channel 0 1 32)
	(if (not (string=? (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 ";xramp ptree2 zero: ~A" (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 ";xramp ptree2 zero: ~A" (channel->vct)))
	
	(close-sound ind))
      
      (let ((ind (new-sound :file "test.snd" :header-type mus-next :data-format mus-bfloat :srate 22050 :channels 1 :comment "xen tests" :size 10)))
	(do ((ramps 1 (1+ ramps)))
	    ((= ramps 5))
	  (revert-sound)
	  (map-chan (lambda (y) 1.0))
	  (do ((i 0 (1+ i)))
	      ((= i ramps))
	    (ramp-channel 0.0 1.0))
	  (let ((old-vals (channel->vct)))
	    (xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.25)))
	    (let ((new-vals (channel->vct)))
	      (if (not (vequal (vct-offset! old-vals .25) new-vals))
		  (snd-display ";xen-ramp~A: i ~A ~A" old-vals new-vals)))))
	(do ((ramps 1 (1+ ramps)))
	    ((= ramps 5))
	  (revert-sound)
	  (xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.75)))
	  (do ((i 0 (1+ i)))
	      ((= i ramps))
	    (ramp-channel 0.0 1.0))
	  (let ((old-vals (channel->vct)))
	    (revert-sound)
	    (map-chan (lambda (y) 0.5))
	    (xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.25)))
	    (do ((i 0 (1+ i)))
		((= i ramps))
	      (ramp-channel 0.0 1.0))
	    (let ((new-vals (channel->vct)))
	      (if (not (vequal old-vals new-vals))
		  (snd-display ";ramp~A-xen(zero): i ~A ~A" old-vals new-vals)))))
	(revert-sound)
	(map-chan (lambda (y) 1.0))
	(ramp-channel 0.0 1.0)
	(xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.25)))	    
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(ramp-channel 0.0 1.0)
	(let ((old-vals (channel->vct)))
	  (revert-sound)
	  (map-chan (lambda (y) 1.0))
	  (ramp-channel 0.0 1.0)
	  (ptree-channel (lambda (y) (+ y .25)))
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 0.0 1.0)
	  (let ((new-vals (channel->vct)))
	    (let ((new-vals (channel->vct)))
	      (if (not (vequal old-vals new-vals))
		  (snd-display ";ramp3-xen-ramp: ~A ~A" old-vals new-vals)))))
	(close-sound ind))

      (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) (xen-channel (lambda (y data forward) (* y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.25))))
	(define (cxen dat) (vct-scale! dat 0.25))
	(define (rev-channel->vct)
	  (let* ((l (vct-length data))
		 (r (make-sample-reader (1- l) ind 0 -1))
		 (d (make-vct l)))
	    (do ((i (1- l) (1- i)))
		((< i 0))
	      (vct-set! d i (r)))
	    d))
	(define (ptreec1)
	  (ptree-channel (lambda (y data forward)
			   (declare (y real) (data vct) (forward boolean))
			   (* 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) :end 100 :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 ";0 case! ~A" (channel->vct)))
	(if (not (vvequal data (rev-channel->vct)))
	    (snd-display ";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 ";1 case: ~A ~A" (procedure-name func) (channel->vct)))
	   (if (not (vvequal data (rev-channel->vct)))
	       (snd-display ";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 ";2 case: ~A(~A): ~A" (procedure-name func1) (procedure-name func) (channel->vct)))
	      (if (not (vvequal data (rev-channel->vct)))
		  (snd-display ";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))
	
	;; 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 ";3 case: ~A(~A(~A)): ~A" (procedure-name func2) (procedure-name func1) (procedure-name func) (channel->vct)))
		 (if (not (vvequal data (rev-channel->vct)))
		     (snd-display ";3 rev case: ~A(~A(~A)): ~A" (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))
	
	(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 ";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 ";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 ";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 ";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")))
	(set! (cursor) 1000)
	(delete-sample 321)
	(if (not (= (cursor) 999)) (snd-display ";delete-sample before cursor: ~A" (cursor)))
	(if (not (= (cursor ind 0 0) 1000)) (snd-display ";delete-sample before cursor (0): ~A" (cursor ind 0 0)))
	(undo)
	(if (not (= (cursor) 1000)) (snd-display ";delete-sample after cursor undo: ~A" (cursor)))
	(undo -1)
	(if (not (= (cursor) 999)) (snd-display ";delete-sample before cursor redo: ~A" (cursor)))
	(redo -1)
	(delete-sample 1321)
	(if (not (= (cursor) 1000)) (snd-display ";delete-sample after cursor: ~A" (cursor)))
	(undo)
	(delete-samples 0 100)
	(if (not (= (cursor) 900)) (snd-display ";delete-samples before cursor: ~A" (cursor)))
	(undo)
	(delete-samples 1100 100)
	(if (not (= (cursor) 1000)) (snd-display ";delete-samples after cursor: ~A" (cursor)))
	(undo)
	(insert-samples 100 100 (make-vct 100))
	(if (not (= (cursor) 1100)) (snd-display ";insert-samples before cursor: ~A" (cursor)))
	(undo)
	(insert-samples 1100 100 (make-vct 100))
	(if (not (= (cursor) 1000)) (snd-display ";insert-samples after cursor: ~A" (cursor)))
	(undo)
	(set! (samples 0 100) (make-vct 100))
	(if (not (= (cursor) 1000)) (snd-display ";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* ((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 ";completion: ~A" (snd-completion " open-so")))
	(if (not (string=? (snd-completion " open-sound") " open-sound"))
	    (snd-display ";completion: ~A" (snd-completion " open-so")))
	(if (not (string=? (snd-completion " zoom-focus-r") " zoom-focus-right"))
	    (snd-display ";completion: ~A" (snd-completion " zoom-focus-r")))
	(play-and-wait "oboe.snd")
	(play-and-wait "oboe.snd" 12000)
	(play-and-wait "oboe.snd" 12000 15000)
	(play-and-wait 0 #f #f #f #f (1- (edit-position)))
	(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-and-wait 12345 index)
	  (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 ";disk-kspace = ~A" (disk-kspace "oboe.snd")))
	  (set! k (disk-kspace "/baddy/hiho"))
	  (if (not (= k -1))
	      (snd-display ";disk-kspace of bogus file = ~A" (disk-kspace "/baddy/hiho"))))
	(if (not (= (transform-frames) 0)) (snd-display ";transform-frames ~A?" (transform-frames)))
	(set! (transform-graph?) #t)
	(let ((pk (fft-peak index 0 1.0)))
	  (if (not pk) (snd-display ";fft-peak? ")))
	(set! (time-graph?) #t)
	(if (not (string=? (x-axis-label) "time")) (snd-display ";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 ";time x-axis-label: ~A" (x-axis-label index 0 time-graph)))
	(graph '(0 0 1 1 2 0) "lisp")
	(update-lisp-graph)
	(if (not (string=? (x-axis-label index 0 lisp-graph) "lisp")) (snd-display ";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 ";lisp x-axis-label: ~A" (x-axis-label index 0 lisp-graph)))
	(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 (inexact->exact (round (* .5 (vct-length data))))))
		(if (not (= (vct-length data) (1+ (- (right-sample) (left-sample)))))
		    (snd-display ";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 ";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 ";make-graph-data 100:199: ~A" (vct-length data)))
		(if (fneq (vct-ref data 50) (sample 50))
		    (snd-display ";make-graph-data 50: ~A ~A" (vct-ref data 50) (sample 50))))))
	(set! (x-bounds) (list 0.0 0.1))
	(update-transform-graph)
	(if (not (string=? (x-axis-label index 0 transform-graph) "frequency")) (snd-display ";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 ";fft x-axis-label: ~A" (x-axis-label index 0 transform-graph)))
	(if (and (number? (transform-frames))
		 (= (transform-frames) 0))
	    (snd-display ";transform-graph? transform-frames ~A?" (transform-frames)))
	(update-transform-graph)
	(peaks "tmp.peaks")
	(if (defined? 'read-line)
	    (let ((p (open-input-file "tmp.peaks")))
	      (if (not p)
		  (snd-display ";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 ";peaks 1: ~A?" line))
		    (set! line (read-line p))
		    (set! line (read-line p))
		    (if (or (not (string? line))
			    (not (string=? "oboe.snd, fft 512 points beginning at sample 0 (0.000 secs), blackman2-window" line)))
			(snd-display ";peaks 2: ~A?" line))
		    (set! line (read-line p))
		    (set! line (read-line p))
		    (if (or (not (string? line))
			    (and (not (string=? "  86.132812  1.00000" line))
				 (not (string=? "  0.000000  1.00000" line)))) ; fht/fft disagreement about 0/1 (groan)
			(snd-display ";peaks 3: ~A?" line))
		    (close-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 ";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) 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 (read-only index) (snd-display ";read-only open-sound: ~A?" (read-only index)))
	(set! (read-only index) #t)
	(if (not (read-only index)) (snd-display ";set-read-only: ~A?" (read-only index)))
	(bind-key (char->integer #\a) 0 (lambda () (set! a-ctr 3)))
	(key (char->integer #\a) 0) 
	(if (not (= a-ctr 3)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";channel-style[0]->~D: ~A?" channels-separate (channel-style index)))))
	(set! (sync index) 32)
	(if (not (= (sync index) 32)) (snd-display ";sync->32: ~A?" (sync index)))
	(set! (sync index) 0)
	(set! (channel-sync index 0) 12)
	(if (not (= (channel-sync index 0) 12)) (snd-display ";sync-chn->12: ~A?" (channel-sync index 0)))
	(set! (channel-sync index 0) 0)
	(if (not (= a-ctr 0)) (snd-display ";unbind-key: ~A?" a-ctr))
	(if (fneq xp 0.0) (snd-display ";x-position-slider: ~A?" xp))
	(if (fneq yp 0.0) (snd-display ";y-position-slider: ~A?" yp))
	(if (fneq xz 0.04338) (snd-display ";x-zoom-slider: ~A?" xz))
	(if (fneq yz 1.0) (snd-display ";y-zoom-slider: ~A?" yz))
	(if (or (fneq (car bnds) 0.0) (fneq (cadr bnds) 0.1)) (snd-display ";x-bounds: ~A?" bnds))
	(if (not (= (find-sound "oboe.snd") index)) (snd-display ";oboe: index ~D /= ~D?" (find-sound "oboe.snd") index))
	(if (not (sound? index)) (snd-display ";oboe: ~D not ok?" index))
	(if (not (= (chans index) 1)) (snd-display ";oboe: chans ~D?" (chans index)))
	(if (not (= (channels index) 1)) (snd-display ";oboe: channels ~D?" (channels index)))
	(if (not (= (frames index) 50828)) (snd-display ";oboe: frames ~D?" (frames index)))
	(if (not (= (srate index) 22050)) (snd-display ";oboe: srate ~D?" (srate index)))
	(if (not (= (data-location index) 28)) (snd-display ";oboe: location ~D?" (data-location index)))
	(if (not (= (data-size index) (* 50828 2))) (snd-display ";oboe: size ~D?" (data-size index)))
	(if (not (= (data-format index) mus-bshort)) (snd-display ";oboe: format ~A?" (data-format index)))
	(if (fneq (maxamp index) .14724) (snd-display ";oboe: maxamp ~F?" (maxamp index)))
	(if (comment index) (snd-display ";oboe: comment ~A?" (comment index)))
	(if (not (= (string-length "asdf") 4)) (snd-display ";string-length: ~A?" (string-length "asdf")))
	(if (not (string=? (short-file-name index) "oboe.snd")) (snd-display ";oboe short name: ~S?" (short-file-name index)))
	(let ((matches (count-matches (lambda (a) (> a .125)))))
	  (if (not (= matches 1313)) (snd-display ";count-matches: ~A?" matches)))
	(let ((spot (find (lambda (a) (> a .13)))))
	  (if (or (null? spot) (not (= (cadr spot) 8862))) (snd-display ";find: ~A?" spot)))
	(set! (right-sample) 3000) 
	(let ((samp (right-sample)))
	  (if (> (abs (- samp 3000)) 1) (snd-display ";right-sample: ~A?" samp)))
	(set! (left-sample) 1000) 
	(let ((samp (left-sample)))
	  (if (> (abs (- samp 1000)) 1) (snd-display ";left-sample: ~A?" samp)))
	(let ((eds (edits)))
	  (if (or (not (= (car eds) 0)) (not (= (cadr eds) 0)))
	      (snd-display ";edits: ~A?" eds))
	  (if (not (= (edit-position) (car eds)))
	      (snd-display ";edit-position: ~A ~A?" (edit-position) eds)))
	(play-and-wait 0 index 0)
	
	(bomb index #f)
	(select-all index 0) 
	(let ((r0 (car (regions))))
	  (if (not (selection?)) (snd-display ";selection?"))
	  (if (not (region? r0)) (snd-display ";region?"))
	  (if (not (= (selection-chans) 1)) (snd-display ";selection-chans(1): ~A" (selection-chans)))
	  (if (not (= (selection-srate) (srate index))) (snd-display ";selection-srate: ~A ~A" (selection-srate) (srate index)))
	  (if (fneq (region-maxamp r0) (maxamp index)) (snd-display ";region-maxamp (1): ~A?" (region-maxamp r0)))
	  (if (fneq (selection-maxamp index 0) (maxamp index)) (snd-display ";selection-maxamp (1): ~A?" (selection-maxamp index 0)))
	  (save-region r0 "temp.dat")
	  (if (file-exists? "temp.dat")
	      (delete-file "temp.dat")
	      (snd-display ";save-region file disappeared?"))
	  (play-region r0 #t) ;needs to be #t here or it never gets run
	  (if (not (= (length (regions)) 2)) (snd-display ";regions: ~A?" (regions)))
	  (if (not (selection-member? index)) (snd-display ";selection-member?: ~A" (selection-member? index)))
	  (if (not (= (region-srate r0) 22050)) (snd-display ";region-srate: ~A?" (region-srate r0)))
	  (if (not (= (region-chans r0) 1)) (snd-display ";region-chans: ~A?" (region-chans r0)))
	  (if (not (= (region-frames r0) 50828)) (snd-display ";region-frames: ~A?" (region-frames r0)))
	  (if (not (= (selection-frames) 50828)) (snd-display ";selection-frames: ~A?" (selection-frames 0)))
	  (if (not (= (selection-position) 0)) (snd-display ";selection-position: ~A?" (selection-position)))
	  (if (not (= (region-position r0 0) 0)) (snd-display ";region-position: ~A?" (region-position r0 0)))
	  (if (fneq (region-maxamp r0) (maxamp index)) (snd-display ";region-maxamp: ~A?" (region-maxamp r0)))
	  (if (fneq (selection-maxamp index 0) (maxamp index)) (snd-display ";selection-maxamp: ~A?" (selection-maxamp index 0)))
	  (let ((samps1 (samples->vct 0 50827 index 0))
		(samps2 (region->vct 0 50828 r0 0))
		(vr (make-sample-reader 0 index 0 1)))
	    (if (not (sample-reader? vr)) (snd-display ";~A not sample-reader?" vr))
	    (if (not (= (sample-reader-position vr) 0)) (snd-display ";initial sample-reader-position: ~A" (sample-reader-position vr)))
	    (if (not (equal? (sample-reader-home vr) (list index 0))) 
		(snd-display ";sample-reader-home: ~A ~A?" (sample-reader-home vr) (list index 0)))
	    (if (sample-reader-at-end? vr) (snd-display ";~A init at end?" vr))
	    (let ((err (catch #t
			      (lambda ()
				(region->vct -1 1233 r0))
			      (lambda args (car args)))))
	      (if (not (eq? err 'no-such-sample)) (snd-display ";region->vct -1: ~A" err)))
	    (let ((err (catch #t
			      (lambda ()
				(region->vct 12345678 1 r0))
			      (lambda args (car args)))))
	      ;; should this return 'no-such-sample?
	      (if err (snd-display ";region->vct 12345678: ~A" err)))
	    (let ((reader-string (format #f "~A" vr)))
	      (if (not (string=? reader-string "#<sample-reader: oboe.snd[0: 0] from 0, at 0>"))
		  (snd-display ";sample reader actually got: [~S]" reader-string)))
	    (let ((evr vr))
	      (if (not (equal? evr vr)) (snd-display ";sample-reader 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 ";readers disagree at ~D" i)
			     (throw 'break)))))
		   (lambda args (car args)))
	    (free-sample-reader vr)))
	(let ((var (catch #t (lambda () (make-sample-reader 0 index -1)) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display ";make-sample-reader bad chan (-1): ~A" var)))
	(let ((var (catch #t (lambda () (make-sample-reader 0 index 1)) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display ";make-sample-reader bad chan (1): ~A, ~A" var index)))
	(let ((fd (make-sample-reader 0)))
	  (if (mix-sample-reader? fd) (snd-display ";sample-reader: mix ~A" fd))
	  (if (region-sample-reader? fd) (snd-display ";sample-reader: region ~A" fd))
	  (if (track-sample-reader? fd) (snd-display ";sample-reader: track ~A" fd))
	  (if (not (sample-reader? fd)) (snd-display ";sample-reader: normal ~A" fd))
	  (if (not (= (sample-reader-position fd) 0)) (snd-display ";sample-reader: position: ~A" fd))
	  (free-sample-reader fd)
	  (let ((str (format #f "~A" fd)))
	    (if (not (string=? (substring str (- (string-length str) 16)) "at eof or freed>"))
		(snd-display ";freed sample-reader: ~A [~A]?" str (substring str (- (string-length str) 16))))))
	(let* ((reg (car (regions)))
	       (chns (region-chans reg))
	       (var (catch #t (lambda () (make-region-sample-reader 0 reg (+ chns 1))) (lambda args args))))
	  (if (not (eq? (car var) 'no-such-channel))
	      (snd-display ";make-region-sample-reader bad chan (2): ~A ~A" var (regions))))
	
	(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 ";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 ";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 ";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 ";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 ";save-sound-as: ~A ~A?" (sample 101 nindex) (sample 101 index)))
	  (if (not (read-only nindex)) (snd-display ";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 ";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 ";speed-control-tones -8: ~A" (speed-control-tones nindex)))
	  (set! (speed-control-tones nindex) 18)
	  (if (not (= (speed-control-tones nindex) 18))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";set-samples temp deleted?"))
	(delete-file "temporary.snd")
	(if (not (= (frames index) 50827)) (snd-display ";delete-sample: ~A?" (frames index)))
	(delete-samples 0 100 index) 
	(if (not (= (frames index) 50727)) (snd-display ";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 ";scale-to: ~A?" newmaxa))
	    (undo 1 index) 
	    (scale-by 2.0 index) 
	    (set! newmaxa (maxamp index))
	    (if (fneq newmaxa (* 2.0 maxa)) (snd-display ";scale-by: ~A?" newmaxa))
	    (revert-sound index)
	    (scale-by -1 index)
	    (mix "oboe.snd")
	    (if (fneq (maxamp index 0) 0.0) (snd-display ";invert+mix->~A" (maxamp)))
	    (revert-sound index)
	    (select-all index) 
	    (if (not (= (length (regions)) 3)) (snd-display ";regions(2): ~A?" (regions)))
	    (scale-selection-to .5) 
	    (set! newmaxa (maxamp index))
	    (if (fneq newmaxa .5) (snd-display ";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 ";scale-selection-by: ~A?" newmaxa))
	    (revert-sound index)
	    (select-all index) 
	    (let ((rread (make-region-sample-reader 0 (car (regions))))
		  (sread (make-sample-reader 0 index))
		  (rvect (region->vct 0 100 (car (regions))))
		  (svect (samples 0 100 index)))
	      (if (fneq (vct-ref rvect 1) (region-sample 1 (car (regions))))
		  (snd-display ";region-sample: ~A ~A?" (region-sample 1 (car (regions))) (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 ";sample-read: ~A ~A?" rval sval))
		  (if (fneq rval (vct-ref rvect i)) (snd-display ";region-samples: ~A ~A?" rval (vct-ref rvect i)))
		  (if (fneq sval (vct-ref svect i)) (snd-display ";samples: ~A ~A?" sval (vct-ref svect i)))))
	      (free-sample-reader rread) 
	      (let ((val0 (next-sample sread)))
		(if (sample-reader-at-end? sread) (snd-display ";premature end?"))
		(previous-sample sread)
		(let ((val1 (previous-sample sread)))
		  (if (fneq val0 val1) (snd-display ";previous-sample: ~A ~A?" val0 val1))))
	      (free-sample-reader 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 ";cursor-style: ~A? " (cursor-style)))
	  (if (not (= (cursor-size) 25))
	      (snd-display ";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) 
	  (set! (cursor-style index 0)
		(lambda (snd chn ax)
		  (let* ((point (cursor-position))
			 (x (car point))
			 (y (cadr point))
			 (size (inexact->exact (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 ";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 ";insert-sound: ~A?" (sample 100)))
	  (if (not (= (frames) (+ len addlen))) (snd-display ";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 ";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 ";insert-samples deleted its file?")
	      (delete-file "not-temporary.snd"))
	  (let ((id (make-region 0 99)))
	    (insert-region 60 id index) 
	    (if (not (= (frames) (+ len 100))) (snd-display ";insert-region len: ~A?" (frames)))
	    (if (fneq (sample 100) s40) (snd-display ";insert-region: ~A ~A?" (sample 100) s40))
	    (let ((var (catch #t (lambda () (insert-region 0 (+ 1000 (apply max (regions))))) (lambda args args))))
	      (if (not (eq? (car var) 'no-such-region))
		  (snd-display ";insert-region bad id: ~A" var)))
	    (save-region id "fmv.snd")
	    (if (not (= (mus-sound-header-type "fmv.snd") mus-next))
		(snd-display ";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 ";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 ";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 ";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 ";save-region length: ~A (~A)" (mus-sound-frames "fmv.snd") (region-frames id)))
	    (if (not (= (region-position id 0) 0))
		(snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";saved silence 1: ~A ~A" (frames index 0) (frames index 1)))
	(if (not (= (mus-sound-frames "fmv.snd") 1001))
	    (snd-display ";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 ";auto-pad 0: ~A" (vct-peak v0)))
	  (if (fneq (vct-peak v1) 0.0)
	      (snd-display ";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 ";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 ";pad 0: ~A" (vct-peak v0)))
	  (if (fneq (vct-peak v1) 0.0)
	      (snd-display ";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 ";pad-channel ed 1: ~A ~A" (frames index 0) (frames index 1)))
	(close-sound index)
	(delete-file "fmv.snd")
	
	(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 ";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 ";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 ";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 ";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 ";env-selection: ~A ~A ~A ~A?" (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 ";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 ";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 ";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 ";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 ";save-selection format: ~A?" (mus-data-format-name (mus-sound-data-format "fmv5.snd"))))
	  (if (not (= (mus-sound-srate "fmv5.snd") 22050))
	      (snd-display ";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 ";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 ";save reverse-selection: ~A?" v0))
	  (if (not (= (mus-sound-header-type "fmv4.snd") mus-riff))
	      (snd-display ";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 ";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 ";save-selection srate 1: ~A?" (mus-sound-srate "fmv4.snd")))
	  (if (not (string=? (mus-sound-comment "fmv4.snd") "this is a comment"))
	      (snd-display ";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 ";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 ";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 ";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 ";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 (not (= (mus-sound-header-type "fmv4.snd") mus-next))
	      (snd-display ";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 ";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 ";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) 
	  (convolve-selection-with "fmv5.snd" .5) 
	  (set! v0 (samples->vct 0 128 index 0 v0))
	  (if (fneq (sample 66) -.5) (snd-display ";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 ";set amp-control ~A" (amp-control obind)))
	  (reset-controls obind)
	  (if (ffneq (amp-control obind) 1.0) (snd-display ";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 ";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 ";apply-controls can't find oboe.snd?"))
	  (let ((newamp (maxamp obind)))
	    (if (> (abs (- (* 2.0 vol) newamp)) .05) (snd-display ";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 ";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 ";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 ";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 ";contrast-control-bounds (2): ~A" (contrast-control-bounds)))
	      (let ((secamp (maxamp obind))
		    (secdur (frames obind)))
		(if (fneq secamp .989) (snd-display ";apply contrast: ~A?" secamp))
		(if (not (= secdur newdur)) (snd-display ";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 ";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 ";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 ";apply reverb scale: ~A?" revamp))
		  (if (not (< (- revdur (+ 50828 (inexact->exact (round (* (reverb-control-decay) 22050))))) 256)) 
		      (snd-display ";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 ";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)) .01) (snd-display ";apply expand-control scale: ~A?" expamp))
		    (if (not (> expdur (* 1.25 50828))) (snd-display ";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 1 0))
		    (apply-controls obind)
		    (let ((fltamp (maxamp obind))
			  (fltdur (frames obind)))
		      (if (> (abs (- fltamp .01)) .005) (snd-display ";apply filter scale: ~A?" fltamp))
		      (if (> (- fltdur (+ 40 50828)) 256) (snd-display ";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 ";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 ";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 ";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 ";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 (format ";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 (format ";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 ";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 ";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 ";mark after zeros: ~D (1100)? " (mark-sample m1)))))
	  (revert-sound obind)
	  (let ((frs (frames obind)))
	    (make-region 0 999 obind 0)
	    (if (not (selection?)) (snd-display ";make-region but no selection? ~A" (selection?)))
	    (delete-selection)
	    (if (not (= (frames obind) (- frs 1000)))
		(snd-display ";delete-selection: ~A?" (frames obind)))
	    (let ((val (sample 0 obind 0)))
	      (undo)
	      (if (fneq (sample 1000) val)
		  (snd-display ";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 ";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 ";mix-selection bad chan: ~A" var)))
	      (if (not (= (frames obind) (+ frs 1000)))
		  (snd-display ";insert-selection: ~A?" (frames obind)))
	      (if (fneq (sample 2000) val)
		  (snd-display ";insert-selection val: ~A ~A" val (sample 2000)))
	      (set! val (sample 900))
	      (mix-selection)
	      (if (fneq (sample 900) (* 2 val))
		  (snd-display ";mix-selection val: ~A ~A" (* 2 val) (sample 900)))
	      (if (not (= (frames obind) (+ frs 1000)))
		  (snd-display ";mix-selection: ~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 ";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 ";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 0 reg) ; 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 ";apply srate .5 to chan 1: ~A ~A" (frames ind 1) (* 2 len)))
	  (if (not (= (frames ind 0) len))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";2:0 scale-sound-by 2.0: ~A ~A?" mx20 nmx)))
	  (let ((nmx (maxamp ind2 1)))
	    (if (fneq (* 2 mx21) nmx) (snd-display ";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 ";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 ";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 ";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 ";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 ";sync scale-sound-by 2.0: ~A ~A?" mx1 nmx)))
	  (let ((nmx (maxamp ind2 0)))
	    (if (fneq (* 2 mx20) nmx) (snd-display ";2:0 sync scale-sound-by 2.0: ~A ~A?" mx20 nmx)))
	  (let ((nmx (maxamp ind2 1)))
	    (if (fneq (* 2 mx21) nmx) (snd-display ";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 ";sync scale-sound-to 1.0: ~A ~A?" mx1 nmx)))
	  (let ((nmx (maxamp ind2 0)))
	    (if (fneq (* 2 mx20) nmx) (snd-display ";2:0 sync scale-sound-to 1.0: ~A ~A?" mx20 nmx)))
	  (let ((nmx (maxamp ind2 1)))
	    (if (fneq nmx 1.0) (snd-display ";2:1 sync scale-sound-to 1.0: ~A?" nmx)))
	  
	  (close-sound ind1)
	  (close-sound ind2))
	
	(let* ((ind (open-sound "now.snd"))
	       (cur-amp (amp-control ind)))
	  (if (not (= now-snd-index ind)) (snd-display ";memo-sound: ~A ~A ~A" memo-sound ind now-snd-index))
	  (set! (amp-control ind) .5)
	  (if (ffneq (amp-control ind) .5) (snd-display ";amp-control (.5): ~A?" (amp-control ind)))
	  (set! (amp-control ind 0) .25)
	  (if (ffneq (amp-control ind) .5) (snd-display ";amp-control after local set (.5): ~A?" (amp-control ind)))
	  (if (ffneq (amp-control ind 0) .25) (snd-display ";amp-control 0 (.25): ~A?" (amp-control ind 0)))
	  (set! (amp-control ind) 1.0)
	  (if (ffneq (amp-control ind) 1.0) (snd-display ";amp-control (1.0): ~A?" (amp-control ind)))
	  (if (ffneq (amp-control ind 0) .25) (snd-display ";amp-control 0 after set (.25): ~A?" (amp-control ind 0)))
	  (set! (transform-graph-type ind 0) graph-as-sonogram)
	  (if (not (= (transform-frames ind 0) 0)) 
	      (snd-display ";transform-frames: ~A" (transform-frames ind 0)))
	  (if (transform-sample 0 0 ind 0) (snd-display ";transform-sample (empty): ~A" (transform-sample 0 0 ind 0)))
	  (if (transform->vct ind 0) (snd-display ";transform->vct (empty): ~A" (transform->vct ind 0)))
	  (close-sound ind)
	  (set! ind (open-sound "4.aiff"))
	  (if (ffneq (amp-control ind) 1.0) (snd-display ";amp-control upon open (1.0): ~A?" (amp-control ind)))
	  (if (ffneq (amp-control ind 2) 1.0) (snd-display ";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 ";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 ";amp-control 2 (.25): ~A?" (amp-control ind 2)))
	  (if (ffneq (amp-control ind 1) .5) (snd-display ";amp-control 1 after local set (.5): ~A?" (amp-control ind 1)))
	  (let ((before-ran #f)
		(after-ran #f))
	    (reset-hook! after-apply-hook)
	    (add-hook! after-apply-hook (lambda (snd) (set! after-ran snd)))
	    (apply-controls ind)
	    (if (not (= ind after-ran)) (snd-display ";after-apply-hook: ~A?" after-ran))
	    (reset-hook! after-apply-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 ";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 ";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 ";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 ";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 ";lowpass coeffs: ~A" (filter-control-coeffs ind)))
	  (close-sound ind))
	
	(let* ((obind (open-sound "4.aiff"))
	       (amps (maxamp obind #t)))
	  (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 ";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 ";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 ";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) (inexact->exact (floor (+ (list-ref axinfo 10) 
						      (* (- x x0) (/ (- (list-ref axinfo 12) (list-ref axinfo 10)) 
								     (- x1 x0)))))))
		  (define (cp-y y) (inexact->exact (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 ";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 ";x<->position: ~A ~A?" (position->x (x->position xpos)) xpos))
		  (if (> (abs (- (position->y (y->position ypos)) ypos)) .5)
		      (snd-display ";y<->position: ~A ~A?" (position->y (y->position ypos)) ypos))
		  (if (not (= losamp (left-sample obind 0)))
		      (snd-display ";axis-info[0 losamp]: ~A ~A?" losamp (left-sample obind 0)))
		  (if (not (= hisamp (right-sample obind 0)))
		      (snd-display ";axis-info[1 hisamp]: ~A ~A?" hisamp (right-sample obind 0)))
		  (if (fneq (list-ref axinfo 6) 0.0)
		      (snd-display ";axis-info[6 xmin]: ~A?" (list-ref axinfo 6)))
		  (if (fneq (list-ref axinfo 7) -1.0)
		      (snd-display ";axis-info[7 ymin]: ~A?" (list-ref axinfo 7)))
		  (if (fneq (list-ref axinfo 9) 1.0)
		      (snd-display ";axis-info[9 ymax]: ~A?" (list-ref axinfo 9)))
		  (if (> (abs (apply - (our-x->position obind x0))) 1) 
		      (snd-display ";x0->position: ~A?" (our-x->position obind x0)))
		  (if (> (abs (apply - (our-x->position obind x1))) 1) 
		      (snd-display ";x1->position: ~A?" (our-x->position obind x1)))
		  (if (> (abs (apply - (our-x->position obind (* 0.5 (+ x0 x1))))) 1)
		      (snd-display ";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 ";cp-x .5: ~A ~A?" (x->position xpos) (cp-x xpos)))
			(if (> (abs (- (y->position ypos) (cp-y ypos))) 1)
			    (snd-display ";cp-y .75: ~A ~A?" (y->position ypos) (cp-y ypos)))
			(do ((i 0 (1+ i)))
			    ((= i 10))
			  (let ((xpos (+ x0 (my-random (- x1 x0))))
				(ypos (+ y0 (my-random (- y1 y0)))))
			    (if (> (abs (- (x->position xpos) (cp-x xpos))) 1)
				(snd-display ";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 ";cp-y[~A] ~A: ~A ~A?" i ypos (y->position ypos) (cp-y ypos)))
			    (if (fneq (position->x (cp-x xpos)) xpos)
				(snd-display ";x->position cp-x ~A ~A" xpos (position->x (cp-x xpos))))
			    (if (fffneq (position->y (cp-y ypos)) ypos)
				(snd-display ";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 ";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 ";x0a->position: ~A?" (our-x->position obind x0)))
		  (if (> (abs (apply - (our-x->position obind x1))) 1) 
		      (snd-display ";x1a->position: ~A?" (our-x->position obind x1)))
		  (if (> (abs (apply - (our-x->position obind (* 0.5 (+ x0 x1))))) 1)
		      (snd-display ";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 ";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 ";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 ind1)) (lambda (snd) (scale-sound-by 0.5 ind1)) '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) ind1)) (lambda (snd) (env-sound '(0 1.0 1 0.5) ind1)) 'env-sound ind1)
	  (test-orig (lambda (snd) (env-sound '(0 1.0 1 2.0 2 1.0) ind1)) (lambda (snd) (env-sound '(0 1.0 1 0.5 2 1.0) ind1)) 'env-sound ind1)
	  (test-orig (lambda (snd) (env-channel (make-env :envelope '(0 1.0 1 2.0) :end (frames))))
		     (lambda (snd) (env-channel (make-env :envelope '(0 1.0 1 0.5) :end (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 :end (frames))))
		     (lambda (snd) (env-channel (make-env :envelope '(0 0.5 1 0.5 2 2 3 2) :base 0 :end (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) 0 ind1 0)) 
		     (lambda (snd) (filter-sound (make-one-zero :a0 0.5 :a1 0.0)) 0 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 ";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 ";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 ";~A (orig: 0) ~A ~A" 'convolve-with v1 v2))
	      (file->array "fmv5.snd" 0 12000 10 v2)
	      (if (not (vfequal v1 v2))
		  (snd-display ";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 (fneq (cadr (mus-sound-maxamp "fmv5.snd")) 0.5) (snd-display ";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 ";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 ";~A (orig: 2) ~A ~A" 'convolve-with v1 v2))
	      (file->array "fmv5.snd" 0 12005 10 v2)
	      (if (not (vfequal v1 v2))
		  (snd-display ";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 ";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 ";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 ";convolve-selection-with 1000: ~A ~A?" ma (maxamp ind1))))
	  (make-selection 1000 2000 ind1)
	  (let ((id (make-region)))
	    (if (not (region? id))
		(snd-display ";make-region argless: ~A" id))
	    (if (not (= (region-frames id 0) (selection-frames)))
		(snd-display ";region/selection-frames: ~A ~A (~A)?" (region-frames id 0) (selection-frames) (region-frames id)))
	    (if (fneq (region-sample 0 id) (sample 1000 ind1))
		(snd-display ";region-sample from make-region: ~A ~A?" (region-sample 0 id) (sample 1000 ind1))))
	  (close-sound ind1))
	(let* ((ind (open-sound "2.snd"))
	       (reg (make-region 0 100 ind #t)))
	  (if (not (= (region-chans reg) 2))
	      (snd-display ";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 ";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 ";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 ";cursor: ~A ~A?" (cursor ind1 0) (cursor ind1 1)))
	    (forward-sample 10 ind1 0)
	    (forward-sample -10 ind1 1)
	    (if (or (not (= (cursor ind1 0) 110)) 
		    (not (= (cursor ind1 1) 190)))
		(snd-display ";cursor (1): ~A ~A?" (cursor ind1 0) (cursor ind1 1)))
	    (backward-sample -10 ind1 0)
	    (backward-sample 10 ind1 1)
	    (if (or (not (= (cursor ind1 0) 120)) 
		    (not (= (cursor ind1 1) 180)))
		(snd-display ";cursor (2): ~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 ";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 ";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 ";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 ";2[0] scan-chan: ~A ~A?" ups1 ups3))
	      (if (not (= ups2 ups4))
		  (snd-display ";2[1] scan-chan: ~A ~A?" ups2 ups4)))
	    
	    (set! (sync ind2) #t)
	    (let ((total
		   (let ((count 0)) 
		     (scan-chans (lambda (n) 
				   (if (> n .03) 
				       (set! count (+ count 1))) 
				   #f))
		     count)))
	      (if (not (= total (+ ups1 ups2)))
		  (snd-display ";scan-chans: ~A ~A?" total (+ ups1 ups2))))
	    (set! (sync ind2) #f)
	    (let ((total
		   (let ((count 0)) 
		     (scan-sound-chans (lambda (n) 
					 (if (> n .03) 
					     (set! count (+ count 1))) 
					 #f)
				       0 (frames ind2) ind2)
		     count)))
	      (if (not (= total (+ ups1 ups2)))
		  (snd-display ";scan-sound-chans: ~A ~A?" total (+ ups1 ups2))))
	    (set! (sync ind2) #f)
	    (let ((total
		   (let ((count 0)) 
		     (scan-across-all-chans (lambda (nd len) 
					      (do ((i 0 (1+ i)))
						  ((= i len) #f) 
						(if (> (vector-ref nd i) .03) 
						    (set! count (+ count 1))))))
		     count))
		  (ups3 (count-matches (lambda (n) (> n .03)) 0 ind1 0)))
	      (if (not (= total (+ ups1 ups2 ups3)))
		  (snd-display ";scan-across-all-chans: ~A ~A?" total (+ ups1 ups2 ups3))))
	    (let ((total
		   (let ((count 0)) 
		     (scan-all-chans (lambda (n) 
				       (if (> n .03)
					   (set! count (+ count 1)))
				       #f))
		     count))
		  (ups3 (count-matches (lambda (n) (> n .03)) 0 ind1 0)))
	      (if (not (= total (+ ups1 ups2 ups3)))
		  (snd-display ";scan-all-chans: ~A ~A?" total (+ ups1 ups2 ups3)))))
	  
	  (select-sound ind1)
	  (forward-graph)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 0)))
	      (snd-display ";forward from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (forward-graph)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display ";forward from ~A 0 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (forward-graph 1)
	  (if (or (not (= (selected-sound) ind1))
		  (not (= (selected-channel) 0)))
	      (snd-display ";forward from ~A 1 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (forward-graph 2)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display ";forward from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (forward-graph 0)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display ";forward 0 from ~A 1 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (backward-graph 2)
	  (if (or (not (= (selected-sound) ind1))
		  (not (= (selected-channel) 0)))
	      (snd-display ";backward 2 from ~A 1 to ~A ~A?" ind2 (selected-sound) (selected-channel)))
	  (backward-graph)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display ";backward 2 from ~A 0 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (forward-graph -1)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 0)))
	      (snd-display ";forward -1 from ~A 1 to ~A ~A?" ind1 (selected-sound) (selected-channel)))
	  (backward-graph -1)
	  (if (or (not (= (selected-sound) ind2))
		  (not (= (selected-channel) 1)))
	      (snd-display ";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"))
	      (ind2 (open-sound "2.snd")))
	  (let ((ups1 (maxamp ind1 0))
		(ups2 (maxamp ind2 #t)))
	    (map-chan (lambda (n)
			(* n 2.0))
		      0 (frames ind1) "ignore: times 2" ind1 0)
	    (map-sound-chans (lambda (n)
			       (* n 2.0))
			     0 (frames ind2) "ignore: times 2" ind2)
	    (let ((ups3 (maxamp ind1 0))
		  (ups4 (maxamp ind2 #t)))
	      (if (fneq ups3 (* ups1 2.0))
		  (snd-display ";map-chan: ~A ~A?" ups3 (* ups1 2.0)))
	      (if (or (fneq (car ups4) (* (car ups2) 2.0))
		      (fneq (cadr ups4) (* (cadr ups2) 2.0)))
		  (snd-display ";map-sound-chans: ~A ~A?" (map (lambda (n) (* 2 n)) ups2) ups4)))
	    
	    (set! (sync ind2) #t)
	    (set! (sync ind1) #t)
	    (map-chans (lambda (n) (* n 0.5)))
	    (let ((ups3 (maxamp ind1 0))
		  (ups4 (maxamp ind2 #t)))
	      (if (fneq ups3 ups1)
		  (snd-display ";map-chans: ~A ~A?" ups3 ups1))
	      (if (or (fneq (car ups4) (car ups2))
		      (fneq (cadr ups4) (cadr ups2)))
		  (snd-display ";map-chans: ~A ~A?" ups2 ups4)))
	    (set! (sync ind1) #f)
	    
	    (let ((len-err #f))
	      (map-across-all-chans (lambda (data len)
				      (if (not (= len 3))
					  (set! len-err len)
					  (begin
					    (vector-set! data 0 (* (vector-ref data 0) 4.0))
					    (let ((chan0-sample (vector-ref data 1)))
					      (vector-set! data 1 (vector-ref data 2))
					      (vector-set! data 2 chan0-sample))))
				      data))
	      
	      (if (number? len-err)
		  (snd-display ";map-across-all-chans len: ~A?" len-err))
	      (let ((ups3 (maxamp ind1 0))
		    (ups4 (maxamp ind2 #t)))
		(if (fneq ups3 (* 4 ups1))
		    (snd-display ";map-across-all-chans 1: ~A ~A?" ups3 ups1))
		(if (or (fneq (car ups4) (cadr ups2))
			(fneq (car ups4) (cadr ups2)))
		    (snd-display ";map-across-all-chans 2: ~A ~A?" ups2 ups4))))
	    (revert-sound ind1)
	    (revert-sound ind2)
	    (map-all-chans (lambda (n) (* n 4.0)))
	    
	    (let ((ups3 (maxamp ind1 0))
		  (ups4 (maxamp ind2 0))
		  (ups5 (maxamp ind1 0 0))
		  (ups6 (maxamp ind2 0 0)))
	      (if (fneq ups3 (* 4 ups5))
		  (snd-display ";map-all-chans: ~A ~A?" ups3 ups5))
	      (if (fneq ups4 (* 4 ups6))
		  (snd-display ";map-all-chans(2): ~A ~A?" ups4 ups6)))
	    
	    (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 ";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 ";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 ";map-chan double: ~A ~A?" len (frames ind1)))
	  (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* (#:optional (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* (#:optional (snd 0) (chn 0) (edpos current-edit-position)) (cadr (find (lambda (n2) (> n2 .1)) 0 snd chn edpos)))
	   'find
	   (lambda () (delete-samples 0 100 ind1 0))
	   ind1)
	  (test-edpos 
	   (lambda* (#:optional (snd 0) (chn 0) (edpos current-edit-position)) 
		    (let ((samp 0)) 
		      (scan-chan (lambda (n3) 
				   (if (> n3 .1) 
				       samp 
				       (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)
	  (play-and-wait 0 ind1 0 #f #f 0)
	  (play-and-wait 0 ind1 0 #f #f 1)
	  (play-and-wait 0 ind1 0 #f #f (lambda (snd chn) (edit-position snd chn)))
	  (undo 1 ind1 0)
	  (play-and-wait 0 ind1 0 #f #f 1)
	  
	  (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 ";save-sound-as bad chan: ~A" var)))
	  (if (not (= (mus-sound-frames "fmv.snd") (frames ind1 0 0)))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";filter-sound maxamp 3: ~A" (maxamp)))
	    (close-sound ind))
	  
	  (if (and (provided? 'xm) (provided? 'snd-debug))
	      (XtCallCallbacks (menu-option "Files") XmNactivateCallback (snd-global-state))
	      (view-files-dialog))
	  (set! (previous-files-sort-procedure)
		(lambda (lst)
		  (sort lst 
			(lambda (a b)
			  (> (mus-sound-duration a) (mus-sound-duration b))))))
	  (if (not (procedure? (previous-files-sort-procedure)))
	      (snd-display ";previous-files-sort-procedure: ~A" (previous-files-sort-procedure)))
	  (set! (previous-files-sort) 5)
	  (close-sound ind1)
	  (let ((val (catch #t
			    (lambda ()
			      (set! (previous-files-sort-procedure) (lambda (a b c) #f)))
			    (lambda args (car args)))))
	    (if (not (eq? val 'bad-arity))
		(snd-display ";previous-files-sort-procedure arity error: ~A" val)))
	  (do ((i 0 (1+ i)))
	      ((= i 5))
	    (set! (previous-files-sort) i))
	  (set! (previous-files-sort) 1)
	  (dismiss-all-dialogs)
	  )
	
	(with-output-to-file "sndtst" 
	  (lambda ()
	    (display (string-append "#!" home-dir "/cl/snd -b
!#
 (use-modules (ice-9 format))
 (if (= (length (script-args)) 2) ;i.e. (\"-l\" \"script\")
   (display \"usage: script file-name...\n\")
   (do ((arg (+ (script-arg) 1) (1+ arg)))
       ((= arg (length (script-args))))
     (let ((name (list-ref (script-args) arg)))
       (display (format #f \"~A: ~A~%\" name (mus-sound-comment name))))))
 (exit)
"))))
	
	(system "chmod 777 sndtst")
	(let ((val (shell "sndtst fyow.snd")))
	  (if (not (string=? val "fyow.snd: ;Written on Tue 11-May-93 at 15:55 PDT by me at localhost (NeXT) using Allegro CL and clm of 11-May-93
"))
	      (snd-display ";script: ~A?" val)
	      (delete-file "sndtst")))
	
	(with-output-to-file "sndtst" 
	  (lambda ()
	    (display (string-append "#!" home-dir "/cl/snd -b
!#
 (open-sound \"fmv.snd\")
 (scale-by 2.0)
 (save-sound)
 (exit)
"))))
	(system "chmod 777 sndtst")
	(if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
	(mus-sound-prune)
	(system "cp oboe.snd fmv.snd")
	(sleep 1) ; force dates to be different
	(let* ((ind (open-sound "fmv.snd"))
	       (samps (samples->vct 5000 10))
	       (date (mus-sound-write-date "fmv.snd"))
	       (s-in #f)
	       (s-out #f))
	  (if (not (= (frames ind) (mus-sound-frames "oboe.snd")))
	      (snd-display ";cp oboe.snd fmv.snd: ~A ~A" (frames ind) (mus-sound-frames "oboe.snd")))
	  (reset-hook! update-hook)
	  (add-hook! update-hook (lambda (snd)
				   (set! s-in snd)
				   (lambda (newsnd)
				     (set! s-out newsnd))))
	  (scale-by 3.0)
	  (catch #t
		 (lambda ()
		   (add-mark 101 ind)
		   (add-mark 202 ind))
		 (lambda args (snd-display ";got error from add-mark: ~A" args)))
	  (system "sndtst") 
	  (if (= (mus-sound-write-date "fmv.snd") date)
	      (snd-display ";script didn't overwrite fmv.snd?"))
	  (set! (sync ind) 123)
	  (let ((nind (update-sound ind)))
	    (if (not (equal? (edits nind) (list 0 0)))
		(snd-display ";update-sound edits: ~A?" (edits nind)))
	    (if (not (equal? (map mark-sample (marks nind 0)) (list 101 202)))
		(snd-display ";update-sound marks: ~A" (map mark-sample (marks nind 0))))
	    (if (not (= (sync nind) 123)) (snd-display ";update-sound sync: ~A" (sync nind)))
	    (let ((nsamps (samples->vct 5000 10)))
	      (if (not (vequal samps (vct-scale! nsamps 0.5)))
		  (snd-display ";udpate-sound amps: ~A ~A?" samps nsamps)))
	    (if (or (not (number? s-in)) (not (= ind s-in))) (snd-display ";update-hook init: ~A ~A" ind s-in))
	    (if (or (not (number? s-out)) (not (= nind s-in))) (snd-display ";update-hook done: ~A ~A" nind s-out)))
	  (reset-hook! update-hook)
	  (close-sound ind)
	  (let ((ind (open-sound "fmv.snd")))
	    (add-hook! update-hook (lambda (snd) (lambda () (snd-error "oops"))))
	    (system "sndtst")
	    (let ((tag (catch #t (lambda ()
				   (update-sound ind))
			      (lambda args args))))
	      (if (not (eq? (car tag) 'bad-arity))
		  (snd-display ";bad update-hook result: ~A" tag))))
	  (close-sound (find-sound "fmv.snd"))
	  (delete-file "fmv.snd")
	  (delete-file "sndtst"))
	
	(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-sample-reader 0 index 0))
		   (e-size (vct-length (car e)))
		   (samps-per-bin (inexact->exact (ceiling (/ (frames index) e-size))))
		   (mins (car e))
		   (maxs (cadr e))
		   (max-diff 0.0))
	      (call-with-current-continuation
	       (lambda (return)
		 (do ((e-bin 0)
		      (samp 0 (1+ samp))
		      (mx -10.0)
		      (mn 10.0))
		     ((= e-bin e-size) #t)
		   (if (>= samp (inexact->exact (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 ";~A: peak-env-equal? [bin ~D of ~D]: (~,4F to ~,4F), diff: ~,5F" 
					    name
					    e-bin e-size
					    mn mx
					    (max mxdiff mndiff))
			       (return #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))))))
;	    (snd-display ";~A max-diff: ~A" name max-diff)
	      ))
	  
	  (if (null? e0)
	      (snd-display ";no amp env data")
	      (let ((mx1 (vct-peak (car e0)))
		    (mx2 (vct-peak (cadr e0))))
		(if (fneq mx (max mx1 mx2))
		    (snd-display ";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 ";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 ";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 ";selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (if (fneq (maxamp ind 0) (* 3 mx)) 
		      (snd-display ";maxamp after selection scale: ~A ~A" mx (maxamp ind 0)))
		  (peak-env-equal? "selection peak" ind e1 .0001))
		(map-chan abs 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 ";abs selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (if (fneq (maxamp ind 0) (* 3 mx)) 
		      (snd-display ";maxamp after abs selection scale: ~A ~A" mx (maxamp ind 0)))
		  (if (ffneq mx3 0.03)
		      (snd-display ";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 ";abs selection 3.0 amp env max: ~A ~A ~A ~A" mx1 mx2 mx3 mx4))
		  (if (fneq (maxamp ind 0) (* 3 mx)) 
		      (snd-display ";maxamp after abs selection scale: ~A ~A" mx (maxamp ind 0)))
		  (if (ffneq mx3 0.03)
		      (snd-display ";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)))
		       (mx4 (vct-peak (cadr e1))))
		  (if (fneq (maxamp ind 0) mx)
		      (snd-display ";maxamp after minus abs selection scale: ~A ~A" mx (maxamp ind 0)))
		  (if (fneq (maxamp ind 0) mx3)
		      (snd-display ";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 :end (1- (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 :end (1- (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 :end (1- (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 :end (1- (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 :end (1- (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 :end (1- (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)
				 (declare (y real) (data vct) (forward boolean))
				 (* 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)
				 (declare (y real) (data vct) (forward boolean))
				 (* 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)
				 (declare (y real) (data vct) (forward boolean))
				 (* 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 :end 4999) 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 :end 4999) 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 :end 4999) 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 :end 4999) 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)
				 (declare (y real) (data vct) (forward boolean))
				 (* 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)
				 (declare (y real) (data vct) (forward boolean))
				 (* 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)
		(xen-channel (lambda (y data forward)
			       (* y (list-ref data 0)))
			     0 (frames) ind 0 #f #t
			     (lambda (pos dur)
			       (list 0.5)))
		(peak-env-equal? "xen peak" ind (channel-amp-envs ind 0 1) .0001)
		
		(revert-sound ind)
		(xen-channel (lambda (y data forward)
			       (* y (list-ref data 0)))
			     2000 1000 ind 0 #f #t
			     (lambda (pos dur)
			       (list 0.5)))
		(peak-env-equal? "xen peak selection" ind (channel-amp-envs ind 0 1) .0001)
		
		))
	  (close-sound ind))
	
	(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 ";not a continuation: ~A" break))
	       (if (continuation? abs) (snd-display ";abs is a continuation?"))
	       (if (continuation? open-sound) (snd-display ";open-sound is a continuation?"))
	       (if (continuation? 32) (snd-display ";32 is a continuation?"))
	       (if (continuation? (let ((hi 1)) (lambda () hi))) (snd-display ";closure is a continuation?"))
	       (do ((i 0 (1+ i)))
		   ((= i (- (vct-length mn) 4)))
		 (if (< (vct-ref mn i) 0.5) (begin (snd-display ";peak min: ~A ~A" (vct-ref mn i) i) (break #f)))
		 (if (< (vct-ref mx i) 0.5) (begin (snd-display ";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)))
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 0 (1+ i)))
		   ((= i (- (vct-length mn) 4)))
		 (if (> (vct-ref mn i) -0.5) (begin (snd-display ";1 peak min: ~A ~A" (vct-ref mn i) i) (break #f)))
		 (if (> (vct-ref mx i) -0.5) (begin (snd-display ";1 peak max: ~A ~A" (vct-ref mx i) i) (break #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 ";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 ";chan func: ~A ~A" vi val))
			  (if (scan-channel (lambda (n) (> (abs n) .001)) 0 len index j)
			      (snd-display ";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 ";ed chan func: ~A ~A" vi val))
			    (if (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j)
				(snd-display ";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 (inexact->exact (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 ";chan func n: ~A ~A" vi val))
			    (if (scan-channel (lambda (n) (> (abs n) 0.001)) 0 len index j)
				(snd-display ";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 #:optional edpos)
				      (clm-channel (make-env :envelope '(0 0 1 1) :end (1- dur)) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 0 1 1) :end (1- 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 #:optional 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 #:optional 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 #:optional edpos)
				      (env-channel (make-env :envelope '(0 0 1 1) :end (1- dur)) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 0 1 1) :end (1- 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 #:optional edpos)
				      (env-channel '(0 0 1 1) beg dur index chan edpos))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 0 1 1) :end (1- 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 #:optional 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 #:optional 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 #:optional 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 #:optional 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 #:optional edpos)
				      (env-channel (make-env :envelope '(0 0 1 1) :end (1- dur)) beg dur index chan edpos)
				      (reverse-channel beg dur index chan))
			     (lambda (dur)
			       (let ((e (make-env :envelope '(0 1 1 0) :end (1- 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 #:optional edpos)
				      (env-channel (make-env :envelope '(0 0 1 1) :end (1- 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)
	  (if (not (equal? (edits index) (list 276 0)))
	      (snd-display ";channel edits: ~A" (edits index)))
	  (let ((old-max (maxamp index #t))
		(regdata (map (lambda (n)
				(region->vct 0 10 n))
			      (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))
	    (save-state "s61.scm")
	    (close-sound index)
	    (for-each forget-region (regions))
	    (load "s61.scm")
	    (if (not (equal? old-reglen (map region-frames (regions))))
		(snd-display ";region-frames after save: ~A ~A" old-reglen (map region-frames (regions))))
	    (for-each (lambda (n data)
			(if (not (vequal data (region->vct 0 10 n)))
			    (snd-display ";region after save ~A: ~A ~A" n data (region->vct 0 10 n))))
		      (regions)
		      regdata)
	    (set! index (find-sound "fmv.snd"))
	    (if (not (equal? (maxamp index #t) old-max))
		(snd-display ";maxes: ~A ~A" (maxamp index #t) old-max))
	    (if (not (equal? (edits index) (list 276 0))) ; extend adds 2
		(snd-display ";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) (inexact->exact (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")
	    ))
	
	(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 ";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 ";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 ";src bad func: ~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) :end 20) 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 ";src-channel env: ~A" (channel->vct 0 10 index 1)))
	  (if (not (vequal (make-vct 10) (channel->vct 0 10 index 0)))
	      (snd-display ";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 ";src-channel lst: ~A" (channel->vct 0 10 index 1)))
	  (if (not (vequal (make-vct 10) (channel->vct 0 10 index 0)))
	      (snd-display ";src-channel lst leaks: ~A" (channel->vct 0 10 index 0)))
	  (set! (sinc-width) sw)
	  (close-sound index))
	
	(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-region rid0 #t)
	  (let ((nv (region2vct rid0 0 20)))
	    (if (not (vequal rid0-data nv)) (snd-display ";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 ";deferred region after scaling (rs):~%  ~A~%  ~A" rid0-data nv)))
	  (undo)
	  (scale-by 4.0)
	  (play-region rid0 #t)
	  (let ((nv (region2vct rid0 0 20)))
	    (if (not (vequal rid0-data nv)) (snd-display ";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 ";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 ";deferred region after scale-to:~%  ~A~%  ~A" rid1-data nv)))
	    (close-sound ind)
	    (play-region rid0 #t)
	    (play-region rid1 #t)
	    (let ((nv (region2vct rid1 0 20)))
	      (if (not (vequal rid1-data nv)) (snd-display ";deferred region after close:~%  ~A~%  ~A" rid1-data nv)))
	    (let ((nv (region2vct rid0 0 20)))
	      (if (not (vequal rid0-data nv)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 (save-sound ind)))
	      (if val (snd-display ";save-sound read-only: ~A" val)))
	    (if (not (equal? (edits ind) (list 1 0))) (snd-display ";read-only ignored? ~A" (edits ind)))
	    (if with-gui
		(let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		  (if (not (string=? str "can't write obtest.snd (it is read-only)"))
		      (snd-display ";read-only report-in-minibuffer: ~A?" str))
		  (set! str (widget-text (list-ref (sound-widgets ind) 4))) ; listener
		  (if (not (string? str))
		      (snd-display ";widget-text of listener?: ~A?" str))))
	    (set! (read-only ind) #f)
	    (revert-sound ind)
	    (save-sound ind)
	    (if with-gui
		(let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		  (if (not (string=? str "(no changes need to be saved)"))
		      (snd-display ";save unneeded report-in-minibuffer: ~A?" str))))
	    (key (char->integer #\j) 4)
	    (if with-gui
		(let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		  (if (not (string=? str "no marks"))
		      (snd-display ";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 ";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 ";set button label to F: ~A" (widget-text (list-ref (channel-widgets ind 0) 2)) "F"))
		  (if (not (string=? str "no marks"))
		      (snd-display ";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 ";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 ";C-u 6 C-x c: ~A?" str))))
	    (close-sound ind))
	  
	  (let ((ind (view-sound "obtest.snd")))
	    (delete-samples 0 1000 ind 0)
	    (save-sound ind)
	    (if (not (equal? (edits ind) (list 1 0))) (snd-display ";view read-only ignored? ~A" (edits ind)))
	    (if with-gui
		(let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		  (if (not (string=? str "can't write obtest.snd (it is read-only)"))
		      (snd-display ";view read-only report-in-minibuffer: ~A?" str))))
	    (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 (cursor-follows-play)))
	      (set! (cursor-follows-play) #t)
	      (play-and-wait)
	      (set! (cursor-follows-play) 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-sample-reader (1- (frames)) ind 0 -1)))
		 (if (not (= (sample-reader-position reader) (1- (frames)))) (snd-display ";sample-reader-position: ~A" (sample-reader-position reader)))
		 (map-channel (lambda (y) (read-sample reader))))
	       (scan-channel (let ((pos 0)
				   (e (make-env '(0 0 1 1 2 0) :end 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-sample-reader (1- (frames)) ind 0 -1)))
	      (map-channel (lambda (y) (read-sample reader))))
	    (scan-channel (let ((pos 0)
				(e (make-env '(0 0 1 1 2 0) :end 1000)))
			    (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-sample-reader (1- (frames)) ind 0 -1)))
		  (map-channel (lambda (y) (read-sample reader))))
		(let ((reader (make-sample-reader (1- (frames)) ind 0 -1)))
		  (map-channel (lambda (y) (read-sample reader))))
		(scan-channel (let ((old-reader (make-sample-reader 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 (sample-reader-at-end? reader)
		  #f
		  (let ((val (last-proc (reader))))
		    (if val 
			(list val (1- (sample-reader-position reader)))
			(scan-again)))))
	    (define* (my-scan-chan #:optional proc)
	      (if proc 
		  (begin
		    (set! last-proc proc)
		    (set! reader (make-sample-reader 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 ";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 ";my-scan-chan: ~A" val))
	      (set! val (scan-again))
	      (if (not (equal? val (list #t 4463)))
		  (snd-display ";scan-again: ~A" val))
	      (let ((val (find (lambda (y)
				 (let ((val (find (lambda (y) (> y .1)))))
				   val)))))
		(if (not (equal? val (list (list #t 4423) 0)))
		    (snd-display ";find twice: ~A" val)))
	      (let ((val (find (lambda (y)
				 (count-matches (lambda (y) (> y .1)))))))
		(if (not (equal? val (list 2851 0)))
		    (snd-display ";find+count: ~A" val)))
	      (set! (cursor) 1000)
	      (set! (sample) .5)
	      (if (fneq (sample 1000) .5)
		  (snd-display ";set sample no arg: ~A ~A" (sample 1000) (sample 0)))
	      (close-sound ind)))
	  
	  ;; edit-menu.scm tests
	  (let ((ind (view-sound "oboe.snd")))
	    (make-selection 1000 1999 ind 0)
	    (let ((newsnd (selection->new)))
	      (if (not (sound? newsnd)) (snd-display ";selection->new -> ~A" newsnd))
	      (if (not (= (frames newsnd 0) 1000)) (snd-display ";selection->new frames: ~A" (frames newsnd 0)))
	      (if (not (equal? (edits ind 0) (list 0 0))) (snd-display ";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 ";cut-selection->new -> ~A" newsnd))
	      (if (not (= (frames newsnd 0) 1000)) (snd-display ";cut-selection->new frames: ~A" (frames newsnd 0)))
	      (if (not (equal? (edits ind 0) (list 1 0))) (snd-display ";cut-selection->new did not edit original? ~A" (edits ind 0)))
	      (if (not (= (frames ind 0) (- (frames ind 0 0) 1000))) 
		  (snd-display ";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 ";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 ";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 ";time-front did not edit original? ~A" (edits ind 0)))
	      (if (not (= (frames ind 0) (- (frames ind 0 0) 1000))) 
		  (snd-display ";trim-front: ~A ~A" (frames ind 0) (- (frames ind 0 0) 1000)))
	      (if (not (= (mark-sample m2) 11000)) (snd-display ";trim-front m2: ~A" (mark-sample m2)))
	      (undo 1 ind 0)
	      (trim-back)
	      (if (not (equal? (edits ind 0) (list 1 0))) (snd-display ";time-back did not edit original? ~A" (edits ind 0)))
	      (if (not (= (frames ind 0) 12001)) (snd-display ";trim-back: ~A" (frames ind 0)))
	      (if (not (= (mark-sample m1) 1000)) (snd-display ";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 ";crop did not edit original? ~A" (edits ind 0)))
	      (if (not (= (frames ind 0) 21001)) (snd-display ";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 :end 1000))
	    (check-maxamp ind .5 "simple scaler")
	    (check-env-vals "simple scaler" (make-env '(0 1 1 1) :scaler .5 :end 1000))
	    (if (= (edit-position) 2)
		(undo)
		(snd-display ";env+scl was no-op"))
	    (env-channel (make-env '(0 1 1 1) :offset .5 :end 1000))
	    (check-maxamp ind 1.5 "simple offset")
	    (check-env-vals "simple offset" (make-env '(0 1 1 1) :offset .5 :end 1000))
	    (if (= (edit-position) 2)
		(undo)
		(snd-display ";env+offset was no-op"))
	    (env-channel (make-env '(0 0 1 1 2 0) :offset .5 :scaler 2.0 :end 1000))
	    (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 :end 1000))
	    (undo)
	    (env-channel (make-env '(0 -1 1 0 2 -1) :offset .5 :scaler 2.0 :end 1000))
	    (check-maxamp ind 1.5 "off+scl #2") ; 1.5 because abs max
	    (let ((mx -12.0))
	      (scan-chan (lambda (y) 
			   (if (> y mx) 
			       (set! mx y))
			   #f))
	      (if (fneq mx 0.5) (snd-display ";non abs max: ~A (correct: 0.5)" mx)))
	    (check-env-vals "off+scl #2" (make-env '(0 -1 1 0 2 -1) :offset .5 :scaler 2.0 :end 1000))
	    (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 :end 1000))
	    (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 :end 1000))
	    
	    (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 ";hilbert-transform 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 ";hilbert impulse: ~A" (sample 500)))
	      (set! (sample 500) 0.0)
	      (if (> (maxamp ind 0) .02)
		  (snd-display ";hilbert 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 ";lowpass+highpass impulse: ~A" (sample 120)))
	      (set! (sample 120) 0.0)
	      (if (fneq (maxamp ind 0) 0.0)
		  (snd-display ";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 ";bandpass+bandstop impulse: ~A" (sample 120)))
	      (set! (sample 120) 0.0)
	      (if (fneq (maxamp ind 0) 0.0)
		  (snd-display ";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 ";fir-filter 2: ~A" (vct-peak data))))
		  (undo))))
	    (close-sound ind))
	  
	  (let ((ind (new-sound  "test.snd" mus-next mus-bfloat 22050 1 "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 ";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 ";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 ";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 "ramp re-order tests" 100))
		(oldopt (optimization)))
	    
	    (define (reversed-channel->vct start dur snd chn)
	      (let* ((len (frames snd chn))
		     (data (make-vct dur))
		     (sf (make-sample-reader (+ start dur -1) snd chn -1)))
		(do ((i (+ start dur -1) (1- i)))
		    ((< i start))
		  (vct-set! data i (read-sample sf)))
		data))
	    
	    (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 '())
		     (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 ";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))
			      (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 ";virtual op tests: ~A(~A~A) * ~A: ~A ~A => ~A at ~A"
					       (op-name second) (op-name first)
					       (if (= k 1) "(ptree_zero)" "")
					       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 ";virtual op reversed tests (2): ~A(~A~A) * ~A: ~A ~A => ~A"
						 (op-name second) (op-name first)
						 (if (= k 1) "(ptree_zero)" "")
						 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 ";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))
				     (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 ";virtual op tests: ~A * ~A(~A(~A~A)): ~A ~A => ~A at ~A"
						      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 ";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)" "")
							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 ";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))
					    (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 ";virtual op tests: ~A * ~A(~A(~A(~A~A))): ~A ~A => ~A at ~A"
							     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 ";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)" "")
							       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 ";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))
						       (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 ";virtual op tests: ~A * ~A(~A(~A(~A(~A~A)))): ~A ~A => ~A at ~A"
									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 ";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)" "")
									  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 ";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))
							      (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 ";virtual op tests: ~A * ~A(~A(~A(~A(~A(~A~A))))): ~A ~A => ~A at ~A"
									       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 ";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)" "")
										 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))
	  
	  
	  (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 ";as-one-edit env+ptree pos: ~A" (edit-position ind 0)))
	    (if (fneq (maxamp ind 0) .1825) (snd-display ";as-one-edit env+ptree max: ~A" (maxamp ind 0)))
	    (undo)
	    (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 ";as-one-edit ptree+ptree pos: ~A" (edit-position ind 0)))
	    (if (fneq (maxamp ind 0) (* 4 mx)) (snd-display ";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 ";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 ";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 ";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 ";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 ";sine-ramp 1 0: ~A" (channel->vct)))
	    (if (> (optimization) 0)
		(if (not (string=? (edit-fragment-type-name (list-ref (car (edit-tree)) 7)) "ed_ptree2_zero"))
		    (snd-display ";sine-ramp tree op: ~A ~A" (edit-fragment-type-name (list-ref (car (edit-tree)) 7)) (edit-tree))))
	    (revert-sound ind)
	    (as-one-edit
	     (lambda ()
	       (map-channel (lambda (y) 1.0))
	       (env-channel '(0 0 1 1))
	       (xen-channel (lambda (y data forward) (+ y (car data))) 0 (frames) ind 0 #f #f (lambda (p d) (list 0.25)))))
	    (if (not (vequal (channel->vct) (vct 0.250 0.361 0.472 0.583 0.694 0.806 0.917 1.028 1.139 1.250)))
		(snd-display ";as-one-edit xen: ~A" (channel->vct)))
	    (if (not (string=? (edit-fragment-type-name (list-ref (car (edit-tree)) 7)) "ed_xen_ramp"))
		(snd-display ";as-one-edit xen 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 ";sine-env-channel 0: ~A ~A" (channel->vct 20 10) (channel->vct 60 10)))
	    (if (not (= (edit-position ind 0) 2)) (snd-display ";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 ";off+sine-env: ~A ~A" (channel->vct 40 20) (channel->vct 30 10)))
	    (revert-sound ind)
	    (let ((tag (catch #t
			      (lambda ()
				(xen-channel (lambda (y) (* y 2))))
			      (lambda args (car args)))))
	      (if (not (eq? tag 'bad-arity))
		  (snd-display ";xen-channel with 1-arg func: ~A ~A" tag (optimization))))
	    (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 ";dithering: ~A" mx)))
	    (revert-sound ind)
	    (map-channel (ring-mod 10 (list 0 0 1 (hz->radians 100))))
	    (map-channel (osc-formants .99 '(400 800 1200) '(400 800 1200) '(4 2 3)))
	    (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 ";squelch-vowels init: ~A" (maxamp)))
	      (squelch-vowels)
	      (if (fneq (maxamp) .047) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 "ramp re-order tests" 101)))
	    (offset-channel 1.0)
	    (env-sound '(0 0 1 1))
	    (contrast-channel 1.0)
	    (let ((reader (make-sample-reader 0)))
	      (call-with-current-continuation
	       (lambda (break)
		 (do ((i 0 (1+ i))
		      (val 0.0 (+ val .01)))
		     ((= i 100))
		   (let ((y (reader))
			 (ny (sin (+ (* val 0.5 pi) (* 1.0 (sin (* val 2.0 pi)))))))
		     (if (fneq y ny)
			 (break (snd-display ";contrast-channel: ~A ~A ~A" val y ny))))))))
	    (undo)
	    (compand-channel)
	    (let ((reader (make-sample-reader 0)))
	      (call-with-current-continuation
	       (lambda (break)
		 (do ((i 0 (1+ i))
		      (val 0.0 (+ val .01)))
		     ((= i 100))
		   (let ((y (reader))
			 (ny (array-interp compand-table (+ 8.0 (* 8.0 val)) 17)))
		     (if (fneq y ny)
			 (break (snd-display ";compand-channel: ~A ~A ~A" val y ny))))))))
	    (undo 2)
	    (ring-modulate-channel 1000)
	    (let ((reader (make-sample-reader 0))
		  (incr (/ (* 2 pi 1000) (srate))))
	      (call-with-current-continuation
	       (lambda (break)
		 (do ((i 0 (1+ i))
		      (val 0.0 (+ val incr)))
		     ((= i 100))
		   (let ((y (reader))
			 (ny (sin val)))
		     (if (fneq y ny)
			 (break (snd-display ";ring-modulate-channel: ~A ~A ~A" val y ny))))))))
	    (undo)
	    (env-sound '(0 0 1 1))
	    (smooth-channel-via-ptree)
	    (let ((reader (make-sample-reader 0))
		  (incr (/ pi 101)))
	      (call-with-current-continuation
	       (lambda (break)
		 (do ((i 0 (1+ i))
		      (val pi (+ val incr)))
		     ((= i 100))
		   (let ((y (reader))
			 (ny (+ 0.5 (* 0.5 (cos val)))))
		     (if (fneq y ny)
			 (break (snd-display ";smooth-channel-via-ptree: ~A ~A ~A" val y ny))))))))
	    (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 ";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")))
	    (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 ";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 ";sync field over selection: ~A ~A" (edit-position ind0 0) (edit-position ind1 0)))
	    (close-sound ind0)
	    (close-sound ind1))
	  ))
      )
      (run-hook after-test-hook 5)
      ))


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

(if (or full-test (= snd-test 6) (and keep-going (<= snd-test 6)))
    (begin 
      (run-hook before-test-hook 6)
      (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 ";v0 isn't a vct?!?"))
	  (if (equal? v0 10) (snd-display ";v0 is 10!?"))
	  (if (vct? 10) (snd-display ";10 is a vct?"))
	  (if (not (= (vct-length v0) 10)) (snd-display ";v0 length = ~D?" (vct-length v0)))
	  (vct-fill! v0 1.0)
	  (vct-fill! v1 0.5)
	  (if (equal? v0 v1) (snd-display ";vct equal? ~A ~A" v0 v1))
	  (if (eq? v0 v1) (snd-display ";vct eq? ~A ~A" v0 v1))
	  (let ((v2 v1)
		(v3 (make-vct 10))
		(v4 (make-vct 3)))
	    (if (not (eq? v1 v2)) (snd-display ";vct not eq? ~A ~A" v1 v2))
	    (vct-fill! v3 0.5) 
	    (if (not (equal? v3 v1)) (snd-display ";vct not equal? ~A ~A" v3 v1))
	    (if (equal? v4 v1) (snd-display ";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 ";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 ";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 ";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 ";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 ";vct(32) print: ~%  ~A~%" str1))
	    (if (not (vequal v123 v2)) (snd-display ";vector->vct: ~A" v2))
	    (if (not (equal? (vct->vector v123) vect)) (snd-display ";vct->vector: ~A ~A" vect (vct->vector v123)))
	    (if (not (equal? v3 v2)) (snd-display ";vct=? ~A ~A?" v2 v3))
	    (if (not (= (vct-length v2) 4)) (snd-display ";vector->vct length: ~A?" (vct-length v2)))
	    (if (fneq (vct-ref v2 2) 2.0) (snd-display ";vector->vct: ~A?" v2))
	    (vct-move! v2 0 2)
	    (if (fneq (vct-ref v2 0) 2.0) (snd-display ";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 ";vct-move! back: ~A?" v2)))

	  (if (not (string=? (vct->string (vct 1.0 2.0)) "(vct 1.000 2.000)")) 
	      (snd-display ";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 ";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 ";vct-reverse: ~A" (vct-reverse! (vct 1 2 3))))
	  (if (not (vequal (vct 2 1) (vct-reverse! (vct 1 2)))) (snd-display ";vct-reverse: ~A" (vct-reverse! (vct 1 2))))
	  (if (not (vequal (vct 1) (vct-reverse! (vct 1)))) (snd-display ";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 ";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 ";vct-reverse: ~A" (vct-reverse! (vct 1 2 3))))
	  (if (not (vequal (vct 2 1) (vct-reverse! (vct 1 2) 2))) (snd-display ";vct-reverse: ~A" (vct-reverse! (vct 1 2))))
	  (if (not (vequal (vct 1) (vct-reverse! (vct 1) 1))) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";fill v0[~D] = ~F?" i (vct-ref v0 i)))
	    (if (fneq (vct-ref v1 i) 0.5) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";multiply v2[~D] = ~F?" i (vct-ref v2 i))))
	    (if (fneq (vct-peak v2) 2.5) (snd-display ";v2's peak is ~F?" (vct-peak v2)))
	    (vct-set! v2 5 123.0)
	    (if (fneq (vct-peak v2) 123.0) (snd-display ";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 ";vct-subseq[3:] ~A?" (vct-ref vnew 0)))
		(if (not (= (vct-length vnew) 29)) (snd-display ";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 ";vct-subseq[3:8] ~A?" (vct-ref vnew 0)))
		(if (not (= (vct-length vnew) 6)) (snd-display ";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 ";vct-subseq[3:3->vs] ~A?" vs))
	      (vct-subseq vn 0 32 vs)
	      (if (not (= (vct-length vs) 3)) (snd-display ";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 ";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 ";vct-subseq[1:8->vb] ~A?" (vct-ref vb 0)))
	      (if (fneq (vct-ref vb 8) 123.0) (snd-display ";vct-subseq[1:8->vb][8] ~A?" (vct-ref vb 8))))
	    (vct-map! v0 (lambda () 1.0))
	    (do ((i 0 (1+ i)))
		((= i 10))
	      (if (fneq (vct-ref v0 i) 1.0) (snd-display ";map v0[~D] = ~F?" i (vct-ref v0 i))))
	    (let ((fd (open-sound-file)))
	      (close-sound-file fd 0)
	      (let ((name (if (little-endian?) "test.wav" "test.snd"))
		    (frm (if (little-endian?) mus-lfloat mus-bfloat)))
		(if (not (= (mus-sound-frames name) 0))
		    (snd-display ";open-sound-file no out frames: ~A" (mus-sound-frames name)))
		(if (not (= (mus-sound-data-format name) frm))
		    (snd-display ";open-sound-file format: ~A" (mus-data-format-name (mus-sound-data-format name))))))
	    (if (file-exists? "hiho.snd") (delete-file "hiho.snd"))
	    (mus-sound-forget "hiho.snd")
	    (let* ((typ (if (little-endian?) mus-riff mus-aifc))
		   (fd (open-sound-file "hiho.snd" 2 44100 #f typ)))
	      (vct->sound-file fd (vct .1 .2 .01 .02) 4)
	      (close-sound-file fd (* 4 4))
	      (if (not (= (mus-sound-chans "hiho.snd") 2)) (snd-display ";open-sound-file 2 chans: ~A" (mus-sound-chans "hiho.snd")))
	      (if (not (= (mus-sound-srate "hiho.snd") 44100)) (snd-display ";open-sound-file srate: ~A" (mus-sound-srate "hiho.snd")))
	      (if (not (= (mus-sound-header-type "hiho.snd") typ)) (snd-display ";open-sound-file type: ~A" (mus-sound-header-type "hiho.snd")))
	      (let ((ind (open-sound "hiho.snd")))
		(if (or (fneq (maxamp ind 0) .1)
			(fneq (maxamp ind 1) .2))
		    (snd-display ";vct->sound-file vals: ~A ~A" (channel->vct 0 2 ind 0) (channel->vct 0 2 ind 1)))
		(if (not (= (frames ind) 2)) (snd-display ";vct->channel frames: ~A" (frames ind)))
		(close-sound ind)))
	    (if (file-exists? "hiho.snd") (delete-file "hiho.snd"))
	    (mus-sound-forget "hiho.snd")
	    (let* ((typ (if (little-endian?) mus-riff mus-aifc))
		   (fd (open-sound-file :channels 4 :file "hiho.snd" :header-type typ :srate 8192)))
	      (close-sound-file fd 0)
	      (if (not (= (mus-sound-chans "hiho.snd") 4)) (snd-display ";open-sound-file 4 chans: ~A" (mus-sound-chans "hiho.snd")))
	      (if (not (= (mus-sound-srate "hiho.snd") 8192)) (snd-display ";open-sound-file low srate: ~A" (mus-sound-srate "hiho.snd")))
	      (if (not (= (mus-sound-header-type "hiho.snd") typ)) (snd-display ";open-sound-file (2nd) type: ~A" (mus-sound-header-type "hiho.snd"))))
	    (let ((fd (open-sound-file "hiho.snd" 1 :srate 22050 :comment "hiho is from snd-test")))
	      (vct->sound-file fd v2 10)
	      (close-sound-file fd 10)
	      (let ((var (catch #t (lambda () (vct->sound-file -1 v2 1)) (lambda args args))))
		(if (not (eq? (car var) 'out-of-range))
		    (snd-display ";vct->sound-file bad fd: ~A" var)))
	      (let ((v3 (make-vct 40)))
		(file->array "hiho.snd" 0 0 10 v3)
		(if (fneq (vct-ref v3 5) (vct-ref v2 5))
		    (snd-display ";vct->sound-file: ~A ~A?" v2 v3)))))
	  (if (fneq ((vct 1.0 2.0 3.0) 1) 2.0)
	      (snd-display ";(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 ";(v1 1) = ~A?" (v1 1))))
	  (let ((nind (open-sound "oboe.snd")))
	    (set! (speed-control nind) .5)
	    (play-and-wait)
	    (apply-controls)
	    (close-sound nind))
	  (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 ";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 ";vct-subseq 1 0: ~A" tag)))
	    (if (vct) (snd-display ";(vct) -> ~A" (vct)))
	    (let ((tag (catch #t (lambda () (make-vct 0)) (lambda args (car args)))))
	      (if (not (eq? tag 'out-of-range)) (snd-display ";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 ";vct-add + offset: ~A" v0)))
	  ))
      (run-hook after-test-hook 6)
      ))


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

(define colormap-error-max 0.0)
(define cfneq (lambda (a b) (> (abs (- a b)) colormap-error-max)))
(define old-colormap-size (colormap-size))

(if (and (or full-test (= snd-test 7) (and keep-going (<= snd-test 7)))
	 (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 ";~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 ";~A /= ~A (~A)?" name initval (getfnc)))
		      (setfnc beige)
		      (if (not (equal? (getfnc) beige))
			  (snd-display ";set-~A /= beige (~A)?" name (getfnc)))
		      (setfnc initval)
		      (test-color (cdr lst)))))))
      (run-hook before-test-hook 7)
      (if (not (provided? 'snd-rgb.scm)) (load "rgb.scm"))
      (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 ";color equal? ~A ~A?" c1 c2))
	(if (not (eq? c1 c2)) (snd-display ";color eq? ~A ~A?" c1 c2))
	(if (provided? 'snd-motif) (if (not (equal? c1 c3)) (snd-display ";diff color equal? ~A ~A?" c1 c3)))
	(if (eq? c1 c3) (snd-display ";diff color eq? ~A ~A?" c1 c3))
	(if (not (equal? (color->list c1) (list 0.0 0.0 1.0)))
	    (snd-display ";color->list: ~A ~A?" c1 (color->list c1))))
      (do ((i 0 (1+ i))) ((> i flag-colormap))
	(let ((val (colormap-ref 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 0.0))
				  i)))
	  (if (not (feql val true-val))
	      (snd-display ";colormap-ref ~A: ~A (~A)" i val true-val))))
      (catch '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 1.0 0.0 0.0)))
		   (set! (foreground-color ind 0 cursor-context) red)
		   (let ((col (foreground-color ind 0 cursor-context)))
		     (if (not (equal? col red))
			 (snd-display ";set foreground cursor color: ~A ~A" col red)))
		   (set! (foreground-color) blue)
		   (let ((col (foreground-color)))
		     (if (not (equal? col blue))
			 (snd-display ";set foreground-color: ~A ~A" col black)))
		   (set! (foreground-color ind) black)
		   (let ((col (foreground-color ind)))
		     (if (not (equal? col black))
			 (snd-display ";set foreground-color with ind: ~A ~A" col black))))
		 (set! (selected-graph-color) (make-color 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))

      (for-each 
       (lambda (n err)
	 (set! (colormap-size) n)
	 (set! colormap-error-max err)
	 
	 (let ((x 0.0))
	   (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))
		    (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 ";bone ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";copper ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";winter ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";autumn ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";cool ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";hot ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";jet ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";pink ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";spring ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";gray ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";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))))))
	 
	 (let ((x 0.0))
	   (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 ";summer ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";rainbow ~,3F (~,3F): ~{~,3F ~} ~{~,3F ~}" 
				x (max (abs (- r r1)) (abs (- g g1)) (abs (- b b1))) (list r g b) (list r1 g1 b1))))))
	 
	 (let ((x 0.0))
	   (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 ";prism ~A" rgb)))))
	 
	 (let ((x 0.0))
	   (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 ";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 (feql (colormap-ref ind 0.5) '(1.0 1.0 1.0)))
	    (snd-display ";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 (= (colormap) ind)))
	      (snd-display ";colormap white: ~A ~A ~A" tag ind (colormap))))
	(if (not (string=? (colormap-name ind) "white"))
	    (snd-display ";white colormap name: ~A" (colormap-name ind))))
      
      (let ((tag (catch #t (lambda () (delete-colormap 1234)) (lambda args (car args)))))
	(if (not (eq? tag 'no-such-colormap))
	    (snd-display ";delete-colormap 1234: ~A" tag)))
      (let ((tag (catch #t (lambda () (colormap-ref 1234 0.5)) (lambda args (car args)))))
	(if (not (eq? tag 'no-such-colormap))
	    (snd-display ";colormap-ref 1234: ~A" tag)))
      (let ((tag (catch #t (lambda () (colormap-ref -1 0.5)) (lambda args (car args)))))
	(if (not (eq? tag 'no-such-colormap))
	    (snd-display ";colormap-ref -1: ~A" tag)))
      (let ((tag (catch #t (lambda () (set! (colormap) 1234)) (lambda args (car args)))))
	(if (not (eq? tag 'no-such-colormap))
	    (snd-display "; set colormap 1234: ~A" tag)))
      (let ((tag (catch #t (lambda () (set! (colormap) -1)) (lambda args (car args)))))
	(if (not (eq? tag 'no-such-colormap))
	    (snd-display "; 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 ";colormap-ref 2.0: ~A" tag)))
      
      (set! (colormap-size) old-colormap-size)
      (if (not (= (colormap-size) old-colormap-size))
	  (snd-display ";set colormap-size: ~A ~A" (colormap-size) old-colormap-size))
      
      (if (not (string=? (colormap-name black-and-white-colormap) "black-and-white"))
	  (snd-display ";black-and-white: ~A" (colormap-name black-and-white-colormap)))
      (if (not (string=? (colormap-name gray-colormap) "gray"))
	  (snd-display ";gray: ~A" (colormap-name gray-colormap)))
      (if (not (string=? (colormap-name rainbow-colormap) "rainbow"))
	  (snd-display ";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 3.14159) 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 3.14159) 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)
	(let ((tag (catch #t (lambda () (set! (colormap) pink-colormap)) (lambda args args))))
	  (if (or (not (eq? (car tag) 'no-such-colormap))
		  (= (colormap) pink-colormap))
	      (snd-display ";delete pink colormap: ~A ~A ~A" tag pink-colormap (colormap))))

	(for-each
	 (lambda (n)
	   (set! (colormap-size) n)
	   (let ((x 0.0))
	     (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 ";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))


      (run-hook after-test-hook 7)
      ))


(reset-hook! graph-hook)
(clear-sincs)

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

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

(define (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 (inexact->exact (round (* .013 (srate))))))
	 (dur (+ decay-dur (/ (frames) (srate))))
	 (envA (if amp-env (make-env :envelope amp-env :scaler volume :duration dur) #f))
	 (len (inexact->exact (round (* dur (srate))))))
    (map-chan
     (let ((comb-sum 0.0)
	   (comb-sum-1 0.0)
	   (comb-sum-2 0.0)
	   (all-sums 0.0)
	   (delA 0.0)
	   (delB 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 (inexact->exact (round (* dur (srate)))))))

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

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

(define (scissor begin-time)
  "(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))))


;;; -------- fm-violin
;;;
;;; here we're using the keyword stuff in guile/ice-9/optargs.scm
;;; CLM version is v.ins, C version is in sndlib.html
;;; a version treating the entire violin as a generator is in fmv.scm.

(define fm-violin 
  (lambda* (startime dur frequency amplitude #:key
		     (fm-index 1.0)
		     (amp-env '(0 0  25 1  75 1  100 0))
		     (periodic-vibrato-rate 5.0) 
		     (random-vibrato-rate 16.0)
		     (periodic-vibrato-amplitude 0.0025) 
		     (random-vibrato-amplitude 0.005)
		     (noise-amount 0.0) 
		     (noise-freq 1000.0)
		     (ind-noise-freq 10.0) 
		     (ind-noise-amount 0.0)
		     (amp-noise-freq 20.0) 
		     (amp-noise-amount 0.0)
		     (gliss-env '(0 0  100 0)) 
		     (glissando-amount 0.0) 
		     (fm1-env '(0 1  25 .4  75 .6  100 0))  
		     (fm2-env '(0 1  25 .4  75 .6  100 0)) 
		     (fm3-env '(0 1  25 .4  75 .6  100 0))
		     (fm1-rat 1.0) 
		     (fm2-rat 3.0)	 
		     (fm3-rat 4.0)                    
		     (fm1-index #f) 
		     (fm2-index #f) 
		     (fm3-index #f)
		     (base 1.0)
		     (reverb-amount 0.01)
		     (degree #f) (distance 1.0) (degrees #f)
		     #:allow-other-keys)
	   (let* ((beg (inexact->exact (floor (* startime (mus-srate)))))
		  (len (inexact->exact (floor (* dur (mus-srate)))))
		  (end (+ beg len))
		  (frq-scl (hz->radians frequency))
		  (modulate (not (zero? fm-index)))
		  (maxdev (* frq-scl fm-index))
		  (logfreq (log frequency))
		  (sqrtfreq (sqrt frequency))
		  (index1 (or fm1-index (min pi (* maxdev (/ 5.0 logfreq)))))
		  (index2 (or fm2-index (min pi (* maxdev 3.0 (/ (- 8.5 logfreq) (+ 3.0 (* frequency .001)))))))
		  (index3 (or fm3-index (min pi (* maxdev (/ 4.0 sqrtfreq)))))
		  (easy-case (and (zero? noise-amount)
				  (equal? fm1-env fm2-env)
				  (equal? fm1-env fm3-env)
				  (= fm1-rat (floor fm1-rat))
				  (= fm2-rat (floor fm2-rat))
				  (= fm3-rat (floor fm3-rat))))
		  (coeffs (and easy-case modulate
			       (partials->polynomial
				(list (inexact->exact fm1-rat) index1
				      (inexact->exact (floor (/ fm2-rat fm1-rat))) index2
				      (inexact->exact (floor (/ fm3-rat fm1-rat))) index3))))
		  (norm (or (and easy-case modulate 1.0) index1))
		  (carrier (make-oscil frequency))
		  (fmosc1  (and modulate (make-oscil (* fm1-rat frequency))))
		  (fmosc2  (and modulate (or easy-case (make-oscil (* fm2-rat frequency)))))
		  (fmosc3  (and modulate (or easy-case (make-oscil (* fm3-rat frequency)))))
		  (ampf  (make-env amp-env :scaler amplitude :base base :duration dur))
		  (indf1 (and modulate (make-env fm1-env norm :duration dur)))
		  (indf2 (and modulate (or easy-case (make-env fm2-env index2 :duration dur))))
		  (indf3 (and modulate (or easy-case (make-env fm3-env index3 :duration dur))))
		  (frqf (make-env gliss-env (* glissando-amount frq-scl) :duration dur))
		  (pervib (make-triangle-wave periodic-vibrato-rate (* periodic-vibrato-amplitude frq-scl)))
		  (ranvib (make-rand-interp random-vibrato-rate (* random-vibrato-amplitude frq-scl)))
		  (fm-noi (and (not (= 0.0 noise-amount))
			       (make-rand noise-freq (* pi noise-amount))))
		  (ind-noi (and (not (= 0.0 ind-noise-amount)) 
				(not (= 0.0 ind-noise-freq))
				(make-rand-interp ind-noise-freq ind-noise-amount)))
		  (amp-noi (and (not (= 0.0 amp-noise-amount)) 
				(not (= 0.0 amp-noise-freq))
				(make-rand-interp amp-noise-freq amp-noise-amount)))
		  (vib 0.0) 
		  (modulation 0.0)
		  (loc (make-locsig :channels (channels) :degree (or degree degrees (random 90.0)) :reverb reverb-amount :distance distance))
		  (fuzz 0.0)
		  (ind-fuzz 1.0)
		  (amp-fuzz 1.0)
		  (out-data (make-vct len)))
	     (vct-map! out-data
		       (lambda ()
			 (if (not (= 0.0 noise-amount))
			     (set! fuzz (rand fm-noi)))
			 (set! vib (+ (env frqf) (triangle-wave pervib) (rand-interp ranvib)))
			 (if ind-noi (set! ind-fuzz (+ 1.0 (rand-interp ind-noi))))
			 (if amp-noi (set! amp-fuzz (+ 1.0 (rand-interp amp-noi))))
			 (if modulate
			     (if easy-case
				 (set! modulation
				       (* (env indf1) 
					  (polynomial coeffs (oscil fmosc1 vib)))) ;(* vib fm1-rat)??
				 (set! modulation
				       (+ (* (env indf1) (oscil fmosc1 (+ (* fm1-rat vib) fuzz)))
					  (* (env indf2) (oscil fmosc2 (+ (* fm2-rat vib) fuzz)))
					  (* (env indf3) (oscil fmosc3 (+ (* fm3-rat vib) fuzz)))))))
			 (* (env ampf) amp-fuzz
			    (oscil carrier (+ vib (* ind-fuzz modulation))))))
	     (if (= (channels) 2)
		 (let ((bsamps (vct-copy out-data)))
		   (mix-vct (vct-scale! bsamps (locsig-ref loc 1)) beg #f 1 #f)
		   (mix-vct (vct-scale! out-data (locsig-ref loc 0)) beg #f 0 #f))
		 (mix-vct out-data beg #f 0 #f)))))

; (fm-violin 0 1 440 .1 :fm-index 2.0)
(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) :end 100)))
    (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-1 #:optional (order 40))
  (let* ((freq freq-1)
	 (carrier-freq (abs freq-1))
	 (cos-carrier (make-oscil carrier-freq (* .5 pi)))
	 (sin-carrier (make-oscil carrier-freq))
	 (dly (make-delay order))
	 (hlb (make-hilbert-transform order)))
    (lambda (y fm)
      (let ((ccos (oscil cos-carrier fm))
	    (csin (oscil sin-carrier fm))
	    (yh (hilbert-transform hlb y))
	    (yd (delay dly y)))
	(if (> freq 0.0)
	    (- (* ccos yd) ; shift up
	       (* csin yh))
	    (+ (* ccos yd) ; shift down
	       (* csin yh)))))))

(define* (ssb-am-1 gen y #:optional (fm 0.0)) (gen y fm))

(define (rough-spectrum ind)
  (let ((r (make-sample-reader 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)
  (if (not (string=? (mus-name gen) name))
      (snd-display ";mus-name ~A: ~A?" name (mus-name gen)))
  (if (not (string=? (mus-describe gen) desc))
      (snd-display ";mus-describe ~A: ~A?" (mus-name gen) (mus-describe gen)))
  (let ((egen gen))
    (if (not (equal? egen gen))
	(snd-display ";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 ";let ~A eq? ~A ~A" (mus-name g0) g0 g3))
    (if (eq? g0 g1)
	(snd-display ";arg ~A eq? ~A ~A" (mus-name g0) g0 g1))
    (if (not (equal? g0 g1))
	(snd-display ";~A equal? ~A ~A" (mus-name g0) g0 g1))
    (if (equal? g0 g2)
	(snd-display ";~A not equal? ~A ~A" (mus-name g0) g0 g2))
    (if (equal? g0 gad)
	(snd-display ";~A equal frame? ~A ~A" (mus-name g0) g0 gad))
    (g0)
    (g3)
    (g3)
    (if (not (eq? g0 g3))
	(snd-display ";run let ~A eq? ~A ~A" (mus-name g0) g0 g3))
    (if (eq? g0 g1)
	(snd-display ";arg ~A eq? ~A ~A" (mus-name g0) g0 g1))
    (if (equal? g0 g1)
	(snd-display ";run ~A equal? ~A ~A" (mus-name g0) g0 g1))
    (if (equal? g0 g2)
	(snd-display ";run ~A not equal? ~A ~A" (mus-name g0) g0 g2))))

(define (fm-test 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 ";~A phase(0): ~A" gen (mus-phase gen)))
  (gen 1.0)
  (if (fneq (mus-phase gen) 1.0) (snd-display ";~A phase(1): ~A" gen (mus-phase gen)))
  (gen 0.0)
  (if (fneq (mus-phase gen) 1.0) (snd-display ";~A phase(1, 0): ~A" gen (mus-phase gen)))
  (set! (mus-frequency gen) (radians->hz 2.0))
  (gen 0.0)
  (if (fneq (mus-phase gen) 3.0) (snd-display ";~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 ";~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 ";~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)
  (gen (log 0))
  (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 3.14159265) 2.0)))
      (snd-display ";phase: ~A freq: ~A" (mus-phase gen))))

(if (or full-test (= snd-test 8) (and keep-going (<= snd-test 8)))
    (do ((clmtest 0 (1+ clmtest))) ((= clmtest tests))
      (if (= clmtest 0) (run-hook before-test-hook 8))
      (log-mem clmtest)
      (if (odd? clmtest) (set! (run-safety) 1) (set! (run-safety) 0))
      (set! (mus-srate) 22050)
      (let ((samps (seconds->samples 1.0))
	    (secs (samples->seconds 22050)))
	(if (not (= samps 22050)) (snd-display ";seconds->samples: ~A" samps))
	(if (fneq secs 1.0) (snd-display ";samples->seconds: ~A" secs)))
      (if (not (= (mus-file-buffer-size) default-file-buffer-size)) (snd-display ";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 ";mus-file-buffer-size bad size: ~A" var)))
      (set! (mus-file-buffer-size) 128)
      (if (not (= (mus-file-buffer-size) 128)) (snd-display ";mus-file-buffer-size: ~D?" (mus-file-buffer-size)))
      (set! (mus-file-buffer-size) default-file-buffer-size)
      
      (if (not (= (mus-array-print-length) 8)) (snd-display ";mus-array-print-length: ~D?" (mus-array-print-length)))
      (set! (mus-array-print-length) 32)
      (if (not (= (mus-array-print-length) 32)) (snd-display ";set mus-array-print-length: ~D?" (mus-array-print-length)))
      (set! (mus-array-print-length) 8)
      (if (fneq (mus-srate) 22050.0) (snd-display ";mus-srate: ~F?" (mus-srate)))
      (if (fneq (hz->radians 1.0) 2.84951704088598e-4) (snd-display ";hz->radians: ~F?" (hz->radians 1.0)))
      (if (fneq (radians->hz 2.84951704088598e-4) 1.0) (snd-display ";radians->hz: ~F?" (radians->hz 2.84951704088598e-4)))
      (if (fneq (radians->degrees 1.0) 57.2957801818848) (snd-display ";radians->degrees: ~F?" (radians->degrees 1.0)))
      (if (fneq (degrees->radians 57.2957801818848) 1.0) (snd-display ";degrees->radians: ~F?" (degrees->radians 57.2957801818848)))
      (if (fneq (linear->db .25) -12.0411996841431) (snd-display ";linear->db: ~F?" (linear->db .25)))
      (if (fneq (db->linear -12.0411996841431) .25) (snd-display ";db->linear: ~F?" (db->linear -12.0411996841431)))
      (if (fneq (hz->radians 1.0) (in-hz 1.0)) (snd-display ";in-hz: ~F? " (in-hz 1.0)))
      (if (fneq (ring-modulate .4 .5) .2) (snd-display ";ring-modulate: ~F?" (ring-modulate .4 .5)))
      (if (fneq (amplitude-modulate 1.0 .5 .4) .7) (snd-display ";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 ";contrast-enhancement: ~F (0.562925306221587)" (contrast-enhancement 0.1 0.75)))
      (let ((lv0 (partials->polynomial '(1 1 2 1) 1))
	    (lv1 (partials->polynomial '(1 1 2 1) 0))
	    (lv2 (partials->polynomial '(1 1 2 1 3 1 5 1) 1))
	    (lv3 (partials->polynomial '(1 1 2 1 3 1 5 1) 0))
	    (lv4 (partials->polynomial '(1 1 2 .5 3 .1 6 .01) 1))
	    (lv5 (partials->polynomial '(1 1 2 .5 3 .1 6 .01) 0))
	    (lv6 (partials->polynomial '(1 9 2 3 3 5 4 7 5 1))) ; MLB
	    (lv7 (partials->polynomial '(7 1)))
	    (lv7a (partials->polynomial '(7 1) 1)) ; first kind (default)
	    (lv8 (partials->polynomial '(7 1) 0)) ; second kind (confusing parameter!)
	    )
	(if (not (fveql lv0 '(-1.000 1.000 2.000) 0)) (snd-display ";partials->polynomial(1): ~A?" lv0))
	(if (not (fveql lv1 '(1.000 2.000 0.0) 0)) (snd-display ";partials->polynomial(2): ~A?" lv1))
	(if (not (fveql lv2 '(-1.000 3.000 2.000 -16.000 0.000 16.000) 0)) (snd-display ";partials->polynomial(3): ~A?" lv2))
	(if (not (fveql lv3 '(1.000 2.000 -8.000 0.000 16.000 0.000) 0)) (snd-display ";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 ";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 ";partials->polynomial(6): ~A?" lv5))
	(if (not (vequal lv6 (vct 4.000 -1.000 -50.000 0.000 56.000 16.000))) (snd-display ";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 ";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 ";partials->polynomial(9): ~A?" lv8))
	(if (not (vequal lv7 lv7a)) (snd-display ";partials->polynomial kind=1? ~A ~A" lv7 lv7a))
	)
      
      ;; check phase-quadrature cancellations
      (let ((cos-coeffs (partials->polynomial '(1 1 2 1) 1))
	    (sin-coeffs (partials->polynomial '(1 1 2 1) 0)))
	(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 ";~A ~A, ~A ~A" upper upper2 lower lower2)))))

      (let* ((amps (list->vct '(1.0)))
	     (phases (list->vct '(0.0)))
	     (val (sine-bank amps phases)))
	(if (fneq val 0.0) (snd-display ";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 ";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 ";sine-bank: ~A 1.449?" val))
	(set! val (sine-bank amps phases 3))
	(if (fneq val 1.44989) (snd-display ";sine-bank (3): ~A 1.449?" val))
	(set! val (sine-bank amps phases 1))
	(if (fneq val 0.4207) (snd-display ";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 ";oscil-bank: ~A 0.0?" val))
	  (set! (mus-phase (vector-ref oscs 0)) (/ pi 2))
	  (set! val (oscil-bank amps oscs))
	  (if (fneq val 1.0) (snd-display ";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 ";spectra not equal: ~A ~A" v0 v1))))
	(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 ";spectra not equal: ~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 ";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 ";vct convolution: ~A?" v0))
	  (if (or (fneq (vct-ref v1 0) 0.0) (fneq (vct-ref v1 1) 1.0)) (snd-display ";vct-convolve!: ~A?" v1))
	  (do ((i 0 (1+ i)))
	      ((= i 8)) 
	    (if (fneq (vct-ref v0 i) (vct-ref v1 i))
		(snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";multiply-arrays[0]: ~A?" v0))
	(multiply-arrays v0 v1 100)
	(if (fneq (vct-peak v0) 0.0)
	    (snd-display ";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 ";multiple-arrays: ~F?" (vct-ref v0 0)))
	(let ((sum (dot-product v0 v1)))
	  (if (fneq sum 2.5) (snd-display ";dot-product: ~F?" sum)))
	(let ((sum (dot-product v0 v1 10)))
	  (if (fneq sum 2.5) (snd-display ";dot-product (10): ~F?" sum)))
	(let ((sum (dot-product v0 v1 3)))
	  (if (fneq sum 0.75) (snd-display ";dot-product (3): ~F?" sum)))
	(clear-array v0)
	(if (fneq (vct-ref v0 3) 0.0) (snd-display ";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 ";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 ";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 ";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 ";run r->p not inverted: ~A" v))
	  (if (fneq val (sqrt 2.0)) (snd-display ";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 ";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)))
      
      (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 ";edot 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 ";edot 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 ";edot 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 ";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 ";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 ";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 ";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 ";polynomial: ~A ~A ~A?"
			 (polynomial v0 0.0)
			 (polynomial v0 1.0)
			 (polynomial v0 2.0))))
      
      (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 ";array-interp: ~F?" (array-interp v0 3.5)))
	(if (fneq (array-interp v0 13.5) 3.5) (snd-display ";array-interp(13.5): ~F?" (array-interp v0 13.5)))
	(if (fneq (array-interp v0 -6.5) 3.5) (snd-display ";array-interp(-6.5): ~F?" (array-interp v0 -6.5)))
	(if (fneq (array-interp v0 103.6) 3.6) (snd-display ";array-interp(103.5): ~F?" (array-interp v0 103.6)))
	(if (fneq (array-interp v0 -106.6) 3.4) (snd-display ";array-interp(-106.6): ~F?" (array-interp v0 -106.6)))
	(if (fneq (array-interp v0 -0.5) 4.5) (snd-display ";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 ";array-interp(-0.9): ~F?" (array-interp v0 -0.9)))
	(if (fneq (array-interp v0 -0.1) 0.9) (snd-display ";array-interp(-0.1): ~F?" (array-interp v0 -0.1)))
	(if (fneq (array-interp v0 9.1) 8.1) (snd-display ";array-interp(9.1): ~F?" (array-interp v0 9.1)))
	(if (fneq (array-interp v0 9.9) 0.9) (snd-display ";array-interp(9.9): ~F?" (array-interp v0 9.9)))
	(if (fneq (array-interp v0 10.1) 0.1) (snd-display ";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 ";array-interp bad index: ~A" var))))
      
      (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 ";map delay: ~A ~A" v0 v1))
	(if (not (delay? gen)) (snd-display ";~A not delay?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";set delay data: ~A ~A" val (mus-data gen)))))
	(if (mus-data (make-oscil))
	    (snd-display ";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 ";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 0.000 1.000 0.000]"))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";tap with low pass: ~A" v)))
      
      (let ((dly (make-delay 3 :initial-element 32.0)))
	(if (not (vct? (mus-data dly))) (snd-display ";delay data not vct?"))
	(if (fneq (vct-ref (mus-data dly) 1) 32.0) (snd-display ";delay [1] 32: ~A" (vct-ref (mus-data dly) 1)))
	(if (not (= (vct-length (mus-data dly)) 3)) (snd-display ";delay data len(3): ~A" (vct-length (mus-data dly))))
	(let ((tag (catch #t (lambda () (set! (mus-length dly) -1)) (lambda args (car args)))))
	  (if (not (equal? tag 'out-of-range)) (snd-display ";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 ";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 ";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 ";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 ";set delay data not vct?"))
	  (if (fneq (vct-ref (mus-data dly) 1) 1.0) (snd-display ";set delay [1] 1: ~A" (vct-ref (mus-data dly) 1)))
	  (if (not (= (vct-length (mus-data dly)) 32)) (snd-display ";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 ";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 ";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 ";d1 interp type: ~A" (mus-interp-type d1)))
	(if (not (= (mus-interp-type d2) mus-interp-linear)) (snd-display ";d2 interp type: ~A" (mus-interp-type d2)))
	(if (not (= (mus-interp-type d3) mus-interp-all-pass)) (snd-display ";d3 interp type: ~A" (mus-interp-type d3)))
	(if (not (= (mus-interp-type d4) mus-interp-none)) (snd-display ";d4 interp type: ~A" (mus-interp-type d4)))
	(if (not (= (mus-interp-type d5) mus-interp-lagrange)) (snd-display ";d5 interp type: ~A" (mus-interp-type d5)))
	(if (not (= (mus-interp-type d6) mus-interp-hermite)) (snd-display ";d6 interp type: ~A" (mus-interp-type d6)))
	(if (not (= (mus-interp-type d7) mus-interp-linear)) (snd-display ";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 ";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 ";delay interp linear (2): ~A" v2))
	(if (not (vequal v3 (vct 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.429 0.143 0.095 0.905 0.397 0.830 0.793 0.912 -0.912 0.608 -0.261 0.065 -0.007)))
	    (snd-display ";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 ";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 ";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 ";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 ";delay interp linear (7): ~A" v7)))

      (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 ";map all-pass: ~A ~A" v0 v1))
	(if (not (all-pass? gen)) (snd-display ";~A not all-pass?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";all-pass length: ~D?" (mus-length gen)))
	(if (not (= (mus-order gen) 3)) (snd-display ";all-pass order: ~D?" (mus-order gen)))
	(if (fneq (mus-feedback gen) .4) (snd-display ";all-pass feedback: ~F?" (mus-feedback gen)))
	(if (fneq (mus-feedforward gen) .6) (snd-display ";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 ";all-pass output: ~A" v0))
	(set! (mus-feedback gen) 0.5) 
	(if (fneq (mus-feedback gen) .5) (snd-display ";all-pass set-feedback: ~F?" (mus-feedback gen)))
	(set! (mus-feedforward gen) 0.5) 
	(if (fneq (mus-feedforward gen) .5) (snd-display ";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 (or (not (eq? (car err) 'out-of-range))
		(not (string=? (cadr err) "make-all-pass"))
		(not (string=? (caddr err) "size ~A < 0?"))
		(not (= (car (cadddr err)) -1)))
	    (snd-display ";make-all-pass bad size error message: ~A" err)))
      
      (let ((gen (make-average 4))
	    (v0 (make-vct 10))
	    (gen1 (make-average 4))
	    (v1 (make-vct 10)))
	(print-and-check gen 
			 "average"
			 "average: 0.000, line[4]:[0.000 0.000 0.000 0.000]")
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (vct-set! v0 i (average gen 1.0)))
	(vct-map! v1 (lambda () (if (average? gen1) (average gen1 1.0) -1.0)))
	(if (not (vequal v1 v0)) (snd-display ";map average: ~A ~A" v0 v1))
	(if (not (average? gen)) (snd-display ";~A not average?" gen))
	(if (not (= (mus-length gen) 4)) (snd-display ";average length: ~D?" (mus-length gen)))
	(if (not (= (mus-order gen) 4)) (snd-display ";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 ";average output: ~A" v0)))

      (let* ((gen (make-average 8))
	     (val (average gen)))
	(if (fneq val 0.0) (snd-display ";empty average: ~A" val))
	(set! val (average gen 1.0))
	(if (fneq val 0.125) (snd-display ";average 1: ~A" val))
	(set! val (average gen 1.0))
	(if (fneq val 0.25) (snd-display ";average 2: ~A" val))
	(set! val (average gen 0.5))
	(if (fneq val 0.3125) (snd-display ";average 2: ~A" val))
	(do ((i 0 (1+ i))) ((= i 5)) (set! val (average gen 0.0))) 
	(if (fneq val 0.3125) (snd-display ";average 6: ~A" val))
	(set! val (average gen 0.0))
	(if (fneq val 0.1875) (snd-display ";average 7: ~A" val))
	(set! val (average gen 0.0))
	(if (fneq val 0.0625) (snd-display ";average 8: ~A" val))
	(set! val (average gen 0.0))
	(if (fneq val 0.0) (snd-display ";average 9: ~A" val))
	)
      (let* ((gen (make-average 10 :initial-element .5))
	     (val (average gen 0.5)))
	(if (fneq val 0.5) (snd-display ";average initial-element: ~A" val)))
      (let* ((gen (make-average 3 :initial-contents '(1.0 1.0 1.0)))
	     (val (average gen 1.0)))
	(if (fneq val 1.0) (snd-display ";average initial-contents: ~A" val)))
      
      (test-gen-equal (let ((d1 (make-average 3 :initial-contents '(0.7 0.5 3)))) (average d1 1.0) d1)
		      (let ((d2 (make-average 3 :initial-contents (vct 0.7 0.5 3)))) (average d2 1.0) d2) 
		      (let ((d3 (make-average 4 :initial-contents '(0.7 0.5 0.1 4)))) (average d3 1.0) d3))
      (test-gen-equal (make-average 3 :initial-element 1.0) 
		      (make-average 3 :initial-element 1.0) 
		      (make-average 3 :initial-element 0.5))
      (test-gen-equal (make-average 3 :initial-element 1.0) 
		      (make-average 3 :initial-element 1.0) 
		      (make-average 4 :initial-element 1.0))
      (test-gen-equal (make-average 3 :initial-contents '(1.0 0.0 0.0)) 
		      (make-average 3 :initial-contents '(1.0 0.0 0.0)) 
		      (make-average 3 :initial-contents '(1.0 1.0 1.0)))
      (let ((err (catch #t (lambda () (make-average :size -1)) (lambda args args))))
	(if (or (not (eq? (car err) 'out-of-range))
		(not (string=? (cadr err) "make-average"))
		(not (string=? (caddr err) "size ~A < 0?"))
		(not (= (car (cadddr err)) -1)))
	    (snd-display ";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 ";map comb: ~A ~A" v0 v1))
	(if (not (comb? gen)) (snd-display ";~A not comb?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";comb length: ~D?" (mus-length gen)))
	(if (not (= (mus-order gen) 3)) (snd-display ";comb order: ~D?" (mus-order gen)))
	(if (fneq (mus-feedback gen) .4) (snd-display ";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 ";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 ";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 0.000 1.000 0.000]"))
	      (snd-display ";describe zcomb: ~A" (mus-describe del))))
	(set! (mus-feedback del) 1.0)
	(if (fneq (mus-feedback del) 1.0)
	    (snd-display ";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 ";map notch: ~A ~A" v0 v1))
	(if (not (notch? gen)) (snd-display ";~A not notch?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";notch length: ~D?" (mus-length gen)))
	(if (not (= (mus-order gen) 3)) (snd-display ";notch order: ~D?" (mus-order gen)))
	(if (fneq (mus-feedforward gen) .4) (snd-display ";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 ";notch output: ~A" v0))
	(set! (mus-feedforward gen) 1.0)
	(if (fneq (mus-feedforward gen) 1.0)
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";6all-pass (5 .5 0): ~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 ";map one-pole: ~A ~A" v0 v1))
	(if (not (one-pole? gen)) (snd-display ";~A not one-pole?" gen))
	(if (not (= (mus-order gen) 1)) (snd-display ";one-pole order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) .4) (snd-display ";one-pole a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-b1 gen) .7) (snd-display ";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 ";one-pole output: ~A" v0))
	(if (fneq (mus-ycoeff gen 1) .7) (snd-display ";1p ycoeff 1 .7: ~A" gen))
	(set! (mus-ycoeff gen 1) .1)
	(if (fneq (mus-ycoeff gen 1) .1) (snd-display ";1p set ycoeff 1 .1: ~A" gen))
	(if (fneq (mus-xcoeff gen 0) .4) (snd-display ";1p xcoeff 0 .4: ~A" gen))
	(set! (mus-xcoeff gen 0) .3)
	(if (fneq (mus-xcoeff gen 0) .3) (snd-display ";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 ";map one-zero: ~A ~A" v0 v1))
	(if (not (one-zero? gen)) (snd-display ";~A not one-zero?" gen))
	(if (not (= (mus-order gen) 1)) (snd-display ";one-zero order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) .4) (snd-display ";one-zero a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-a1 gen) .7) (snd-display ";one-zero a1: ~F?" (mus-a1 gen)))
	(if (fneq (vct-ref v0 1) 1.1) (snd-display ";one-zero output: ~A" v0))
	(if (fneq (mus-xcoeff gen 0) .4) (snd-display ";1z xcoeff 0 .4: ~A" gen))
	(set! (mus-xcoeff gen 0) .1)
	(if (fneq (mus-xcoeff gen 0) .1) (snd-display ";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 ";map two-zero: ~A ~A" v0 v1))
	(if (not (two-zero? gen)) (snd-display ";~A not two-zero?" gen))
	(if (not (= (mus-order gen) 2)) (snd-display ";two-zero order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) .4) (snd-display ";two-zero a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-a1 gen) .7) (snd-display ";two-zero a1: ~F?" (mus-a1 gen)))
	(if (fneq (mus-a2 gen) .3) (snd-display ";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 ";two-zero output: ~A" v0))
	(if (fneq (mus-xcoeff gen 0) .4) (snd-display ";2z xcoeff 0 .4: ~A" gen))
	(set! (mus-xcoeff gen 0) .1)
	(if (fneq (mus-xcoeff gen 0) .1) (snd-display ";2z set xcoeff 0 .1: ~A" gen)))
      
      (let ((gen (make-two-zero .4 .7 .3)))
	(let ((val (gen 1.0)))
	  (if (fneq val .4) (snd-display ";2zero->0.4: ~A" val))
	  (set! val (gen 0.5))
	  (if (fneq val .9) (snd-display ";2zero->0.9: ~A" val))
	  (set! val (gen 1.0))
	  (if (fneq val 1.05) (snd-display ";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 ";map two-pole: ~A ~A" v0 v1))
	(if (not (two-pole? gen)) (snd-display ";~A not two-pole?" gen))
	(if (not (= (mus-order gen) 2)) (snd-display ";two-pole order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) .4) (snd-display ";two-pole a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-b1 gen) .7) (snd-display ";two-pole b1: ~F?" (mus-b1 gen)))
	(if (fneq (mus-b2 gen) .3) (snd-display ";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 ";two-pole output: ~A" v0))
	(if (fneq (mus-ycoeff gen 1) .7) (snd-display ";2p ycoeff 1 .7: ~A" gen))
	(set! (mus-ycoeff gen 1) .1)
	(if (fneq (mus-ycoeff gen 1) .1) (snd-display ";2p set ycoeff 1 .1: ~A" gen))
	(if (fneq (mus-xcoeff gen 0) .4) (snd-display ";2p xcoeff 0 .4: ~A" gen))
	(set! (mus-xcoeff gen 0) .3)
	(if (fneq (mus-xcoeff gen 0) .3) (snd-display ";2p set xcoeff 0 .3: ~A" gen)))
      
      (let ((gen (make-two-pole .4 .7 .3)))
	(let ((val (gen 1.0)))
	  (if (fneq val .4) (snd-display ";a0->out 2pole: ~A" val))
	  (set! val (gen 0.5))
	  (if (fneq val -.08) (snd-display ";a0->out 2pole (-0.08): ~A" val))
	  (set! val (gen 1.0))
	  (if (fneq val 0.336) (snd-display ";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 ";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 ";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 ";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 ";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 ";map oscil: ~A ~A" v0 v2))
	(if (not (oscil? gen)) (snd-display ";~A not oscil?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";oscil phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";oscil frequency: ~F?" (mus-frequency gen)))
	(if (not (= (mus-cosines gen) 1)) (snd-display ";oscil cosines: ~D?" (mus-cosines gen)))
	(if (or (fneq (vct-ref v0 1) 0.125) (fneq (vct-ref v0 8) 0.843)) (snd-display ";oscil output: ~A" v0))
	(set! (mus-phase gen) 0.0)
	(if (fneq (mus-phase gen) 0.0) (snd-display ";oscil set-phase: ~F?" (mus-phase gen)))
	(set! (mus-frequency gen) 100.0)
	(if (fneq (mus-frequency gen) 100.0) (snd-display ";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 ";mus-apply oscil at ~D: ~A ~A?" i (vct-ref v0 i) (vct-ref v1 i))))
	(if (fneq (mus-apply) 0.0)
	    (snd-display ";(mus-apply): ~A" (mus-apply))))
      
      (let ((o1 (make-oscil (+ (mus-srate) 100)))
	    (o2 (make-oscil 100)))
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (let ((val1 (o1))
		(val2 (o2)))
	    (if (fneq val1 val2) (snd-display ";~D: o1: ~A, o2: ~A" i val1 val2)))))
      
      (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 ";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 ";cosil +-: ~A" mx)))

      (fm-test (make-oscil))
      (fm-test (make-sine-summation))
      (fm-test (make-square-wave))
      (fm-test (make-triangle-wave))
      (fm-test (make-sum-of-cosines))
      (fm-test (make-sum-of-sines))
      (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 ";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 ";oscil fm output: ~A" v0))
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (if (fneq (vct-ref v0 i) (vct-ref v1 i))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";set mus-location bad gen: ~A" var)))
      (let ((var (catch #t (lambda () (mus-scaler (make-oscil))) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";mus-scaler 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 ";set mus-scaler bad gen: ~A" var)))
      (let ((var (catch #t (lambda () (mus-length (make-oscil))) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";mus-length bad gen: ~A" var)))
      (let ((var (catch #t (lambda () (set! (mus-length (make-oscil)) 0)) (lambda args args))))
	(if (and (not (eq? (car var) 'mus-error))
		 (not (eq? (car var) 'out-of-range)))
	    (snd-display ";set mus-length 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 ";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 ";set mus-frequency bad gen: ~A" var)))
      (let ((var (catch #t (lambda () (mus-scaler (make-delay 3))) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";mus-scaler bad gen: ~A" var)))
      (let ((var (catch #t (lambda () (set! (mus-scaler (make-delay 3)) 0)) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";set mus-scaler 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 ";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 ";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 ";oscil-bank: ~A?" results)))
      
      (let ((gen (make-sum-of-cosines 10 440.0))
	    (v0 (make-vct 10))
	    (gen1 (make-sum-of-cosines 10 440.0))
	    (v1 (make-vct 10)))
	(print-and-check gen 
			 "sum-of-cosines"
			 "sum-of-cosines freq: 440.000Hz, phase: 0.000, cosines: 10")
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (vct-set! v0 i (sum-of-cosines gen 0.0)))
	(vct-map! v1 (lambda () (if (sum-of-cosines? gen1) (sum-of-cosines gen1 0.0) -1.0)))
	(if (not (vequal v0 v1)) (snd-display ";map sum-of-cosines: ~A ~A" v0 v1))
	(if (not (sum-of-cosines? gen)) (snd-display ";~A not sum-of-cosines?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";sum-of-cosines phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";sum-of-cosines frequency: ~F?" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) .1) (snd-display ";sum-of-cosines scaler: ~F?" (mus-scaler gen)))
	(if (not (= (mus-cosines gen) 10)) (snd-display ";sum-of-cosines cosines: ~D?" (mus-cosines gen)))
	(if (not (= (mus-length gen) 10)) (snd-display ";sum-of-cosines length: ~D?" (mus-length gen)))
	(if (or (fneq (vct-ref v0 1) 0.722) (fneq (vct-ref v0 8) -0.143)) (snd-display ";sum-of-cosines output: ~A" v0))
	(set! (mus-scaler gen) .5) (if (fneq (mus-scaler gen) 0.5) (snd-display ";sum-of-cosines set-scaler: ~F?" (mus-scaler gen)))
	(set! (mus-cosines gen) 5) (if (not (= (mus-cosines gen) 5)) (snd-display ";set sum-of-cosines cosines: ~D?" (mus-cosines gen)))
	(if (fneq (mus-scaler gen) .2) (snd-display ";set cosines->scaler: ~A" (mus-scaler gen))))
      
      (test-gen-equal (make-sum-of-cosines 3 440.0) (make-sum-of-cosines 3 440.0) (make-sum-of-cosines 5 440.0))
      (test-gen-equal (make-sum-of-cosines 3 440.0) (make-sum-of-cosines 3 440.0) (make-sum-of-cosines 3 440.0 1.0))
      (test-gen-equal (make-sum-of-cosines 3 440.0) (make-sum-of-cosines 3 440.0) (make-sum-of-cosines 3 400.0))
      
      (let ((gen (make-sum-of-cosines 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-cosines gen) 0.5)))
					     (* 2.0 den))
					  0.5)))))
		 (val2 (gen 0.0)))
	    (if (> (abs (- val1 val2)) .002)
		(snd-display ";sum-of-cosines: ~A: ~A ~A" i val1 val2)))))

      (let ((gen1 (make-sum-of-cosines 10 100.0))
	    (gen2 (make-sum-of-cosines 10 -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 ";sum-of-cosines +-: ~A" mx)))

      (let ((gen (make-sum-of-sines 10 440.0))
	    (v0 (make-vct 10))
	    (gen1 (make-sum-of-sines 10 440.0))
	    (v1 (make-vct 10)))
	(print-and-check gen 
			 "sum-of-sines"
			 "sum-of-sines freq: 440.000Hz, phase: 0.000, sines: 10")
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (vct-set! v0 i (sum-of-sines gen 0.0)))
	(vct-map! v1 (lambda () (if (sum-of-sines? gen1) (sum-of-sines gen1 0.0) -1.0)))
	(if (not (vequal v0 v1)) (snd-display ";map sum-of-sines: ~A ~A" v0 v1))
	(if (not (sum-of-sines? gen)) (snd-display ";~A not sum-of-sines?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";sum-of-sines phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";sum-of-sines frequency: ~F?" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) .1315) (snd-display ";sum-of-sines scaler: ~F?" (mus-scaler gen)))
	(if (not (= (mus-cosines gen) 10)) (snd-display ";sum-of-sines cosines: ~D?" (mus-cosines gen)))
	(if (not (= (mus-length gen) 10)) (snd-display ";sum-of-sines length: ~D?" (mus-length gen)))
	(if (or (fneq (vct-ref v0 1) 0.784) (fneq (vct-ref v0 8) 0.181)) (snd-display ";sum-of-sines output: ~A" v0))
	(set! (mus-scaler gen) .5) (if (fneq (mus-scaler gen) 0.5) (snd-display ";sum-of-sines set-scaler: ~F?" (mus-scaler gen)))
	(set! (mus-cosines gen) 5) (if (not (= (mus-cosines gen) 5)) (snd-display ";set sum-of-sines cosines: ~D?" (mus-cosines gen)))
	(if (fneq (mus-scaler gen) .2525) (snd-display ";set sines->scaler: ~A" (mus-scaler gen))))
      
      (test-gen-equal (make-sum-of-sines 3 440.0) (make-sum-of-sines 3 440.0) (make-sum-of-sines 5 440.0))
      (test-gen-equal (make-sum-of-sines 3 440.0) (make-sum-of-sines 3 440.0) (make-sum-of-sines 3 440.0 1.0))
      (test-gen-equal (make-sum-of-sines 3 440.0) (make-sum-of-sines 3 440.0) (make-sum-of-sines 3 400.0))
      
      (let ((gen (make-sum-of-sines 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 ";sum-of-sines: ~A ~A" val1 val2)))))

      (let ((gen1 (make-sum-of-sines 10 100.0))
	    (gen2 (make-sum-of-sines 10 -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 ";sum-of-sines +-: ~A" mx)))

      (let ((gen (make-sine-summation 440.0))
	    (v0 (make-vct 10))
	    (gen1 (make-sine-summation 440.0))
	    (v1 (make-vct 10)))
	(print-and-check gen 
			 "sine-summation"
			 "sine-summation: frequency: 440.000, phase: 0.000, n: 1, a: 0.500, ratio: 1.000")
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (vct-set! v0 i (sine-summation gen 0.0)))
	(vct-map! v1 (lambda () (if (sine-summation? gen1) (sine-summation gen1 0.0) -1.0)))
	(if (not (vequal v0 v1)) (snd-display ";map sine-summation: ~A ~A" v0 v1))
	(if (not (sine-summation? gen)) (snd-display ";~A not sine-summation?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";sine-summation phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";sine-summation frequency: ~F?" (mus-frequency gen)))
	(if (or (fneq (vct-ref v0 1) 0.249) (fneq (vct-ref v0 8) 1.296)) (snd-display ";sine-summation output: ~A" v0))
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";mus-scaler (a) sine-summation: ~A" (mus-scaler gen)))
	(set! (mus-scaler gen) 0.75)
	(if (fneq (mus-scaler gen) 0.75) (snd-display ";mus-scaler (set a) sine-summation: ~A" (mus-scaler gen)))
	(if (not (= (mus-cosines gen) 1)) (snd-display ";mus-cosines sine-summation: ~A" (mus-cosines gen)))
	(if (fneq (mus-increment gen) 1.0) (snd-display ";mus-increment sine-summation: ~A" (mus-increment gen))))
      
      (test-gen-equal (make-sine-summation 440.0) (make-sine-summation 440.0) (make-sine-summation 100.0))
      (test-gen-equal (make-sine-summation 440.0) (make-sine-summation 440.0) (make-sine-summation 440.0 1.0))
      (test-gen-equal (make-sine-summation 440.0) (make-sine-summation 440.0) (make-sine-summation 440.0 0.0 3))
      
      (let ((gen1 (make-sine-summation 1000 0 1 0.0 1))
	    (gen2 (make-oscil 1000))
	    (gen3 (make-sine-summation 1000 0 1 0.5 2))
	    (gen4 (make-oscil 1000))
	    (gen5 (make-oscil 3000))
	    (gen6 (make-sine-summation 500.0 3.0 10 .1 .4))
	    (v0 (make-vct 10)))

	(if (fneq (mus-phase gen6) 3.0) (snd-display ";sine-summation phase (3): ~F?" (mus-phase gen6)))
	(if (fneq (mus-frequency gen6) 500.0) (snd-display ";sine-summation frequency (500): ~F?" (mus-frequency gen6)))
	(if (fneq (mus-scaler gen6) 0.1) (snd-display ";mus-scaler (a) sine-summation (.1): ~A" (mus-scaler gen6)))
	(if (not (= (mus-cosines gen6) 10)) (snd-display ";mus-cosines sine-summation (10): ~A" (mus-cosines gen6)))
	(if (fneq (mus-increment gen6) 0.4) (snd-display ";mus-increment sine-summation (0.4): ~A" (mus-increment gen6)))
	
	(call-with-current-continuation
	 (lambda (give-up)
	   (do ((i 0 (1+ i)))
	       ((= i 100))
	     (let ((ss (sine-summation gen1 0.0))
		   (os (oscil gen2 0.0))
		   (ss1 (sine-summation gen3 0.0))
		   (os1 (+ (oscil gen4 0.0) 
			   (* 0.5 (oscil gen5 0.0)))))
	       (if (ffneq ss os)
		   (begin
		     (snd-display ";sine-summation 1: ~A: os: ~A ss: ~A" i os ss)
		     (give-up)))
	       (if (ffneq ss1 os1)
		   (begin
		     (snd-display ";sine-summation 2: ~A: os1: ~A ss1: ~A" i os1 ss1)
		     (give-up)))))))
	(set! gen1 (make-sine-summation 440.0 0.0 0))
	(sine-summation gen1)
	(let ((val (sine-summation gen1)))
	  (if (fneq val 0.125050170279874) (snd-display ";sine-summation n=0: ~A" val))))
      
      (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.229 0.224 0.218 0.211 0.203 0.195 0.187 0.178 0.169 0.160)))
		(snd-display ";cosine-summation: ~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 ";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 ";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 ";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 ";map asymmetric-fm: ~A ~A" v0 v1))
	(if (not (asymmetric-fm? gen)) (snd-display ";~A not asymmetric-fm?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";asymmetric-fm phase: ~F?" (mus-phase gen)))
	(set! (mus-phase gen) 1.0)
	(if (fneq (mus-phase gen) 1.0) (snd-display ";set! asymmetric-fm phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";asymmetric-fm frequency: ~F?" (mus-frequency gen)))
	(set! (mus-frequency gen) 100.0)
	(if (fneq (mus-frequency gen) 100.0) (snd-display ";set! asymmetric-fm frequency: ~F?" (mus-frequency gen)))
	(if (or (fneq (vct-ref v0 2) 0.248) (fneq (vct-ref v0 8) .843)) (snd-display ";asymmetric-fm output: ~A" v0))
	(if (fneq (mus-scaler gen) 1.0) (snd-display ";mus-scaler (r) asymmetric-fm: ~A" (mus-scaler gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";mus-scaler (set r) asymmetric-fm: ~A" (mus-scaler gen)))
	(if (fneq (mus-increment gen) 1.0) (snd-display ";mus-increment asymmetric-fm: ~A" (mus-increment 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)))
	(call-with-current-continuation
	 (lambda (give-up)
	   (do ((i 0 (1+ i)))
	       ((= i 100))
	     (let ((ss (asymmetric-fm gen1 0.0 0.0))
		   (os (oscil gen2 0.0)))
	       (if (fneq ss os)
		   (begin
		     (snd-display ";asymmetric-fm 1: ~A: os: ~A ss: ~A" i os ss)
		     (give-up))))))))
      
      (let ((vct0 (make-vct 2048))
	    (vct1 (make-vct 2048))
	    (gen3 (make-asymmetric-fm 1000 0 1.0 0.2))
	    (gen4 (make-oscil 1000))
	    (gen5 (make-oscil 200))
	    (fm1 (in-hz (* 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)))
	  (call-with-current-continuation
	   (lambda (give-up)
	     (do ((i 1 (1+ i)))
		 ((= i 512))
	       (if (ffneq (vct-ref spectr1 i) (vct-ref spectr2 i))
		   (begin
		     (snd-display ";asymmetric-fm 2: ~A: ~A ~A" (* i (/ 22050 2048)) (vct-ref spectr1 i) (vct-ref spectr2 i))
		     (give-up))))))))
      
      (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) 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 (cos mth)))
			  (sin (+ th (* index sr (sin mth)))))))
	    (if (or (fneq val1 val2)
		    (fneq val1 val3))
		(snd-display ";asyfm by hand: ~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 ";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 ";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-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")
	(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 ";map fir-filter: ~A ~A" v0 v1))
	(if (not (fir-filter? gen)) (snd-display ";~A not fir-filter?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";fir-filter length: ~D?" (mus-length gen)))
	(if (or (fneq (vct-ref v0 1) 0.25) (fneq (vct-ref v0 2) .125)) (snd-display ";fir-filter output: ~A" v0))
	(let ((data (mus-xcoeffs gen)))
	  (if (fneq (vct-ref data 1) .25) (snd-display ";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 ";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 ";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) :end 101)))
	(vector-set! es 5 (make-env '(0 .4 1 1) :end 101))
	(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 ";filter xcoeffs: ~A?" data))))
      
      (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")
	(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 ";map iir-filter: ~A ~A" v0 v1))
	(if (not (iir-filter? gen)) (snd-display ";~A not iir-filter?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";iir-filter length: ~D?" (mus-length gen)))
	(if (or (fneq (vct-ref v0 1) -0.25) (fneq (vct-ref v0 2) -.062)) (snd-display ";iir-filter output: ~A" v0))
	(let ((data (mus-ycoeffs gen)))
	  (if (fneq (vct-ref data 1) .25) (snd-display ";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 ";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 ";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")
	(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 ";map filter: ~A ~A" v0 v1))
	(if (not (filter? gen)) (snd-display ";~A not filter?" gen))
	(if (not (= (mus-length gen) 3)) (snd-display ";filter length: ~D?" (mus-length gen)))
	(if (or (fneq (vct-ref v0 1) 0.125) (fneq (vct-ref v0 2) .031)) (snd-display ";filter output: ~A" v0))
	(if (not (filter? gen2)) (snd-display ";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 ";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) 'wrong-type-arg))
	    (snd-display ";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 ";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) 'wrong-type-arg))
	    (snd-display ";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) 'wrong-type-arg))
	    (snd-display ";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 ";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 ";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 ";filter-length: ~A" (mus-length fr))))

      (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";bs rough spectrum: ~A" sp)))
	  (undo))
	
	(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 ";spectrum->coeffs: ~A" v))
	  (if (not (vequal v v1))
	      (snd-display ";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 ";spectrum->coeffs (notch): ~A" v))
	    (if (not (vequal v v1))
		(snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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))))
	      (snd-display ";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))))
		(snd-display ";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 ";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 ";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 ";butter bp: ~A" v))
	  (set! b (make-butter-bp 4 1000.0 1500.0))
	  (map-channel (lambda (y) (filter b y)))
	  (let ((sp (rough-spectrum ind)))
	    (if (and (not (vequal sp (vct 0.026 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		     (not (vequal sp (vct  0.022 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000)))
		     (not (vequal sp (vct 0.042 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000))))
		(snd-display ";bp 4 rough spectrum: ~A" sp)))
	  (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))))
	      (snd-display ";butter bs: ~A" v))
	  (set! b (make-butter-bs 4 1000.0 1500.0))
	  (map-channel (lambda (y) (filter b y)))
	  (let ((sp (rough-spectrum ind)))
	    (if (and (not (vequal sp (vct 0.798 0.657 1.000 0.997 0.996 0.997 0.997 0.996 0.995 0.998)))
		     (not (vequal sp (vct 0.795 0.668 1.000 0.997 0.996 0.997 0.997 0.997 0.995 0.994)))
		     (not (vequal sp (vct 0.801 0.698 1.000 0.997 0.996 0.997 0.997 0.997 0.995 0.994)))
		     (not (vequal sp (vct 0.884 0.586 1.000 0.996 0.996 0.997 0.997 0.997 0.995 0.994)))
		     (not (vequal sp (vct 0.793 0.667 1.000 0.997 0.996 0.997 0.997 0.997 0.995 0.994))))
		(snd-display ";bs 4 rough spectrum: ~A" sp)))
	  (undo))
	
	(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 ";map sawtooth: ~A ~A" v0 v1))
	(if (not (sawtooth-wave? gen)) (snd-display ";~A not sawtooth-wave?" gen))
	(if (fneq (mus-phase gen) 4.39538) (snd-display ";sawtooth-wave phase: ~F?" (mus-phase gen))) ;starts at pi
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";sawtooth-wave frequency: ~F?" (mus-frequency gen)))
	(set! (mus-frequency gen) 100.0)
	(if (fneq (mus-frequency gen) 100.0) (snd-display ";set! sawtooth-wave frequency: ~F?" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) 1.0) (snd-display ";sawtooth-wave scaler: ~F?" (mus-scaler gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";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 ";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 ";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 ";mus-width opt: ~A" w)))
	(if (not (vequal v0 v1)) (snd-display ";map square-wave: ~A ~A" v0 v1))
	(if (not (square-wave? gen)) (snd-display ";~A not square-wave?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";square-wave phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";square-wave frequency: ~F?" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) 1.0) (snd-display ";square-wave scaler: ~F?" (mus-scaler gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";set! square-wave scaler: ~F?" (mus-scaler gen)))
	(if (fneq (mus-width gen) 0.5) (snd-display ";square-wave width: ~A" (mus-width gen)))
	(set! (mus-width gen) 0.75)
	(if (fneq (mus-width gen) 0.75) (snd-display ";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 ";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 ";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 ";map triangle-wave: ~A ~A" v0 v1))
	(if (not (triangle-wave? gen)) (snd-display ";~A not triangle-wave?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";triangle-wave phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-phase gen1) pi) (snd-display ";init triangle-wave phase: ~F?" (mus-phase gen1)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";triangle-wave frequency: ~F?" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) 1.0) (snd-display ";triangle-wave scaler: ~F?" (mus-scaler gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";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 ";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 ";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 ";map pulse-train: ~A ~A" v0 v1))
	(if (not (pulse-train? gen)) (snd-display ";~A not pulse-train?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";pulse-train phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";pulse-train frequency: ~F?" (mus-frequency gen)))
	(if (fneq (mus-scaler gen) 1.0) (snd-display ";pulse-train scaler: ~F?" (mus-scaler gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";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 ";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 ";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 ";~A not ppolar?" gen))
	(if (not (= (mus-order gen) 2)) (snd-display ";ppolar order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) 1.0) (snd-display ";ppolar a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-b1 gen) -.188) (snd-display ";ppolar b1: ~F?" (mus-b1 gen)))
	(if (fneq (mus-b2 gen) .01) (snd-display ";ppolar b2: ~F?" (mus-b2 gen)))
	(if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 1) .188)) (snd-display ";ppolar output: ~A" v0)))
      
      (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 .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 .2 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-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 ";~A not zpolar?" gen))
	(if (not (= (mus-order gen) 2)) (snd-display ";zpolar order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) 1.0) (snd-display ";zpolar a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-a1 gen) -.188) (snd-display ";zpolar a1: ~F?" (mus-a1 gen)))
	(if (fneq (mus-a2 gen) .01) (snd-display ";zpolar a2: ~F?" (mus-a2 gen)))
	(if (or (fneq (vct-ref v0 0) 1.0) (fneq (vct-ref v0 1) -.188)) (snd-display ";zpolar output: ~A" v0)))
      
      (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 .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 .2 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 .9 1200.0 1.0))
	    (v0 (make-vct 10))
	    (gen1 (make-formant .9 1200.0 1.0))
	    (v1 (make-vct 10)))
	(print-and-check gen 
			 "formant"
			 "formant: radius: 0.900, frequency: 1200.000, (gain: 1.000)")
	(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 ";map formant: ~A ~A" v0 v1))
	(if (not (formant? gen)) (snd-display ";~A not formant?" gen))
	(if (not (= (mus-order gen) 2)) (snd-display ";formant order: ~D?" (mus-order gen)))
	(if (fneq (mus-a0 gen) 0.06371) (snd-display ";formant a0: ~F?" (mus-a0 gen)))
	(if (fneq (mus-a1 gen) 1.0) (snd-display ";formant a1: ~F?" (mus-a1 gen)))
	(if (fneq (mus-a2 gen) -0.9) (snd-display ";formant a2: ~F?" (mus-a2 gen)))
	(if (fneq (mus-b1 gen) -1.6957893) (snd-display ";formant b1: ~F?" (mus-b1 gen)))
	(if (fneq (mus-b2 gen) 0.81) (snd-display ";formant b2: ~F?" (mus-b2 gen)))
	(if (fneq (mus-formant-radius gen) .9) (snd-display ";formant radius: ~F?" (mus-formant-radius gen)))
	(if (fneq (mus-frequency gen) 1200.0) (snd-display ";formant frequency: ~F?" (mus-frequency gen)))
	(if (or (fneq (vct-ref v0 0) .064) (fneq (vct-ref v0 1) .108)) (snd-display ";formant output: ~A" v0))
	(if (fneq (mus-scaler gen) 1.0) (snd-display ";formant gain: ~F?" (mus-scaler gen)))

	(if (fneq (mus-ycoeff gen 2) .81) (snd-display ";frm ycoeff 2 .81: ~A" (mus-ycoeff gen 2)))
	(set! (mus-ycoeff gen 2) .1)
	(if (fneq (mus-ycoeff gen 2) .1) (snd-display ";frm set ycoeff 2 .1: ~A" (mus-ycoeff gen 2)))
	(if (fneq (mus-xcoeff gen 2) -0.9) (snd-display ";frm xcoeff 2 -0.9: ~A" (mus-xcoeff gen 2)))
	(set! (mus-xcoeff gen 2) .3)
	(if (fneq (mus-xcoeff gen 2) .3) (snd-display ";frm set xcoeff 2 .3: ~A" (mus-xcoeff gen 2)))

	(set! (mus-a0 gen) .5) (if (fneq (mus-a0 gen) 0.5) (snd-display ";formant set-a0: ~F?" (mus-a0 gen)))
	(set! (mus-a1 gen) .5) (if (fneq (mus-a1 gen) 0.5) (snd-display ";formant set-a1: ~F?" (mus-a1 gen)))
	(set! (mus-a2 gen) .5) (if (fneq (mus-a2 gen) 0.5) (snd-display ";formant set-a2: ~F?" (mus-a2 gen)))
	(set! (mus-b1 gen) .5) (if (fneq (mus-b1 gen) 0.5) (snd-display ";formant set-b1: ~F?" (mus-b1 gen)))
	(set! (mus-b2 gen) .5) (if (fneq (mus-b2 gen) 0.5) (snd-display ";formant set-b2: ~F?" (mus-b2 gen)))
	(set! (mus-formant-radius gen) .01) 
	(if (fneq (mus-formant-radius gen) 0.01) (snd-display ";formant set-radius: ~F?" (mus-formant-radius gen)))
	(set! (mus-scaler gen) 2.0)
	(if (fneq (mus-scaler gen) 2.0) (snd-display ";formant set gain: ~F?" (mus-scaler gen))))
      
      (test-gen-equal (let ((f1 (make-formant .9 1200.0 1.0))) (formant f1 1.0) f1)
		      (let ((f2 (make-formant .9 1200.0 1.0))) (formant f2 1.0) f2)
		      (let ((f3 (make-formant .9 600.0 1.0))) (formant f3 1.0) f3))
      (test-gen-equal (let ((f1 (make-formant .9 1200.0 1.0))) (formant f1 1.0) f1)
		      (let ((f2 (make-formant .9 1200.0 1.0))) (formant f2 1.0) f2)
		      (let ((f3 (make-formant .99 1200.0 1.0))) (formant f3 1.0) f3))
      (test-gen-equal (let ((f1 (make-formant .9 1200.0 1.0))) (formant f1 1.0) f1)
		      (let ((f2 (make-formant .9 1200.0 1.0))) (formant f2 1.0) f2)
		      (let ((f3 (make-formant .9 1200.0 0.5))) (formant f3 1.0) f3))
      
      (let ((frm (make-formant .1 440.0)))
	(mus-set-formant-radius-and-frequency frm 2.0 100.0)
	(if (fneq (mus-formant-radius frm) 2.0) (snd-display ";set-formant-radius-etc: ~A" (mus-formant-radius frm)))
	(if (fneq (mus-frequency frm) 100.0) (snd-display ";set-formant-radius-etc (frq): ~A" (mus-frequency frm))))
      
      (let ((fs (make-vector 1))
	    (f0 (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 (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 ";formant bank: ~A ~A" v0 v1)))
      
      (let ((fs (make-vector 2))
	    (f0 (make-formant .1 1000.0))
	    (f1 (make-formant .2 100.0))
	    (amps (make-vector 2 1.0))
	    (val 1.0)
	    (v0 (make-vct 10))
	    (v1 (make-vct 10)))
	(vector-set! fs 0 (make-formant .1 1000.0))
	(vector-set! fs 1 (make-formant .2 100.0))
	(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 ";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 .1 1000.0))
	(vector-set! fs 1 (make-formant .2 100.0))
	(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.146 0.029 -0.011 -0.003 -0.000))) (snd-display ";run formant-bank: ~A" v)))
      
      (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 R frek gain))
		(fe (make-env :envelope frek-env :end (frames) :offset frek))
		(re (make-env :envelope R-env :end (frames) :offset R)))
	    (lambda (y)
	      (let ((outval (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-and-wait 0 ob)
	(close-sound ob))
      
      (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, vals: [(0.500 0.250) (0.125 1.000)]")
	(print-and-check fr0 
			 "frame"
			 "frame[2]: [1.000 1.000]")
	(if (not (frame? fr0)) (snd-display ";~A not a frame?" fr0))
	(if (not (mixer? gen)) (snd-display ";~A not a mixer?" gen))
	(if (equal? fr0 fr1) (snd-display ";frame=? ~A ~A?" fr0 fr1))
	(if (not (= (mus-channels fr0) 2)) (snd-display ";frame channels: ~D?" (mus-channels fr0)))
	(if (not (= (mus-length fr1) 2)) (snd-display ";frame length: ~D?" (mus-length fr0)))
	(if (not (= (mus-channels gen) 2)) (snd-display ";mixer channels: ~D?" (mus-channels gen)))
	(frame->frame gen fr0 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 ";fr0: ~A" fr0))
	(frame-set! fr1 0 1.0)
	(set! (frame-ref fr1 1) 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 ";fr+*: ~A ~A" fr3 fr4))
	  (if (fneq (frame-ref fr5 0) .5) 
	      (snd-display ";sample->frame: ~A?" (frame-ref fr5 0)))
	  (sample->frame fr1 .5 fr5)
	  (if (fneq (frame-ref fr5 0) .5) 
	      (snd-display ";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 ";frame+ unequal chans: ~A?" (frame+ fr3 fr4))))
	(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 ";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 ";frame->sample: ~A?" val))
	  (if (fneq (frame->sample fr5 fr4) 2.0) (snd-display ";frame->sample ~A" (frame->sample fr5 fr4)))
	  (if (not (equal? (frame->list fr1) (list 1.0 1.0))) (snd-display ";frame->list: ~A?" (frame->list fr1)))
	  (if (or (fneq (mixer-ref mx2 0 1) .25) (fneq (mixer-ref mx2 1 0) .125)) (snd-display ";mixer*: ~A?" mx2))
	  (if (not (equal? mx2 gen)) (snd-display ";mixer=? ~A ~A?" gen mx2))
	  (if (equal? mx2 mx1) (snd-display ";mixer/=? ~A ~A?" mx1 mx2))
	  ;; mus-data doesn't apply from scheme level here
					;(if (not (vct? (mus-data fr4))) (snd-display ";mus-data frame: ~A" (mus-data fr4)))
					;(if (not (vct? (mus-data mx1))) (snd-display ";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 ";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 ";sample->frame: ~A?" fr0))
	  (let ((frout (make-frame 2)))
	    (sample->frame mx2 1.0 frout)
	    (if (not (equal? frout fr0)) (snd-display ";sample->frame via frout: ~A ~A?" frout fr0)))))
      
      (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 ";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 ";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 ";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 ";make-scale (identity): ~A" mx1))))
    
      (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 mx1id fr1) (make-frame 1 1))) (snd-display ";frame->frame 1 id: ~A?"            (frame->frame mx1id fr1)))
	(if (not (equal? (frame->frame mx1 fr1) (make-frame 1 5))) (snd-display ";frame->frame 1: ~A?"                 (frame->frame mx1 fr1)))  
	(if (not (equal? (frame->frame mx2id fr1) (make-frame 2 1 0))) (snd-display ";frame->frame 2 1 id: ~A?"        (frame->frame mx2id fr1)))  
	(if (not (equal? (frame->frame mx2 fr1) (make-frame 2 1 2))) (snd-display ";frame->frame 2 1: ~A?"             (frame->frame mx2 fr1)))  
	(if (not (equal? (frame->frame mx4 fr1) (make-frame 4 1 1 1 1))) (snd-display ";frame->frame 4 1: ~A?"         (frame->frame mx4 fr1)))  
	(if (not (equal? (frame->frame mx8 fr1) (make-frame 8 1 0 0 0 0 0 0 0))) (snd-display ";frame->frame 8 1: ~A?" (frame->frame mx8 fr1))) 
	(if (not (equal? (frame->frame mx1 fr2) (make-frame 1 5))) (snd-display ";frame->frame 1 2: ~A?"               (frame->frame mx1 fr2)))   
	(if (not (equal? (frame->frame mx2id fr2) (make-frame 2 1 2))) (snd-display ";frame->frame 2id 2: ~A?"         (frame->frame mx2id fr2)))  
	(if (not (equal? (frame->frame mx2 fr2) (make-frame 2 7 10))) (snd-display ";frame->frame 2 2: ~A?"            (frame->frame mx2 fr2)))  
	(if (not (equal? (frame->frame mx4id fr2) (make-frame 4 1 2 0 0))) (snd-display ";frame->frame 4id 2: ~A?"     (frame->frame mx4id fr2)))  
	(if (not (equal? (frame->frame mx8id fr2) (make-frame 8 1 2 0 0 0 0 0 0))) (snd-display ";frame->frame 8id 2: ~A?" (frame->frame mx8id fr2)))  
	(if (not (equal? (frame->frame mx4 fr2) (make-frame 4 1 1 1 1))) (snd-display ";frame->frame 4 2: ~A?"         (frame->frame mx4 fr2)))  
	(if (not (equal? (frame->frame mx8 fr2) (make-frame 8 3 0 0 0 0 0 0 0))) (snd-display ";frame->frame 8 2: ~A?" (frame->frame mx8 fr2))) 
	(if (not (equal? (frame->frame mx1 fr4) (make-frame 1 5))) (snd-display ";frame->frame 1 4: ~A?"               (frame->frame mx1 fr4))) 
	(if (not (equal? (frame->frame mx1 fr8) (make-frame 1 5))) (snd-display ";frame->frame 1 8: ~A?"               (frame->frame mx1 fr8))) 
	(if (not (equal? (frame->frame mx8id fr2) (make-frame 8 1 2 0 0 0 0 0 0))) (snd-display ";frame->frame 8id 2: ~A?" (frame->frame mx8id fr2)))
	(if (not (equal? (frame->frame mx4id fr2) (make-frame 4 1 2 0 0))) (snd-display ";frame->frame 4id 2: ~A?"     (frame->frame mx4id fr2)))  
	(if (not (equal? (frame->frame mx8 fr4) (make-frame 8 10 0 0 0 0 0 0 0))) (snd-display ";frame->frame 8 4: ~A?" (frame->frame mx8 fr4))) 
	(if (not (equal? (frame->frame mx4 fr4) (make-frame 4 1 1 1 1))) (snd-display ";frame->frame 4 4: ~A?"         (frame->frame mx4 fr4))))
      
      (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 ";frame+ with res frame: ~A ~A" fr2 fradd))
	  (if (not (equal? fr2 (make-frame 2 0.2 0.0))) (snd-display ";frame+ res: ~A" fr2))
	  (set! fradd (frame* fr1 fr1 fr2))
	  (if (not (equal? fr2 fradd)) (snd-display ";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 ";frame* res: ~A" fr2)))
	(set! (mixer-ref mx1 0 0) .1)
	(let ((mxadd (mixer* mx1 mx1 mx2)))
	  (if (not (equal? mx2 mxadd)) (snd-display ";mixer* with res frame: ~A ~A" mx2 mxadd))
	  (if (fneq (mixer-ref mx2 0 0) .01) (snd-display ";mixer* res: ~A" mx2))))
      
      (for-each 
       (lambda (chans)
	 (let ((m1 (make-mixer chans)))
	   (if (or (not (= (mus-channels m1) chans))
		   (not (= (mus-length m1) chans)))
	       (snd-display ";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 ";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 (1- chans) (1- chans) 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 ";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 ";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 (1- chans)))
			    (not (= j (1- chans))))
		       (snd-display ";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 ";set mixer-length: ~A ~A" tag (mus-length mx)))))

      (if (file-exists? "mixer.scm")
	  (begin
	    (load "mixer.scm")
	    (if (fneq (mixer-determinant (make-mixer 2 1 2 3 4)) -2.0)
		(snd-display ";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 ";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 ";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 "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 ";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 ";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 ";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 ";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 ";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? (mixer-inverse (make-mixer 2 1 0 0 1)) 
				   (make-mixer 2 1.000 0.000 0.000 1.000)))
		(snd-display ";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 ";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 ";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 ";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 "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 ";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 ";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 (not (mixer-diagonal? (make-scalar-mixer 2 2.0))) (snd-display ";mixer-diagonal 1"))
	    (if (not (mixer-diagonal? (make-mixer 3 1 0 0 0 1 0 0 0 1))) (snd-display ";mixer-diagonal 2"))
	    (if (mixer-diagonal? (make-mixer 3 1 0 0 0 1 1 0 0 1)) (snd-display ";mixer-diagonal 3"))
	    (if (not (mixer-diagonal? (make-mixer 3 0 0 0 0 1 0 0 0 1))) (snd-display ";mixer-diagonal 4"))
	    (if (not (mixer-symmetric? (make-mixer 3 0 0 0 0 1 0 0 0 1))) (snd-display ";mixer-symmetric 1"))
	    (if (not (mixer-symmetric? (make-mixer 3 1 2 0 2 1 0 0 0 1))) (snd-display ";mixer-symmetric 2"))
	    (if (mixer-symmetric? (make-mixer 3 1 2 0 2 1 0 0 2 1)) (snd-display ";mixer-symmetric 3"))
	    (if (not (mixer-equal? (make-scalar-mixer 2 2.0) (make-mixer 2 2.0 0 0 2.0))) (snd-display ";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 ";mixer-equal 2"))
	    (if (mixer-equal? (make-mixer 2 1 2 3 4) (make-mixer 2 1 2 3 5)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";mixer-poly 2: ~A" (mixer-poly (make-mixer 2 1 2 4 3) 1 0 1 0)))
	    ))
      
      (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";blackman4 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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";tukey 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 ";dolph-chebyshev window: ~A" gen))))
      
      (let ((v0 (make-vct 10))
	    (gen (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 10))
	    (v1 (make-vct 10))
	    (gen1 (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 10)))
	(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 ";~A not env?" gen))
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";env scaler ~F?" (mus-scaler gen)))
	(if (fneq (mus-increment gen) 1.0) (snd-display ";env base (1.0): ~A?" (mus-increment gen)))
	(if (not (= (mus-length gen) 10)) (snd-display ";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 ";mus-offset opt: ~A" off)))
	(if (not (vequal v0 v1)) (snd-display ";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 ";~A output: ~A" gen v0))
	(if (fneq (env-interp 1.6 gen) 0.2) (snd-display ";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 :end 10))
	(if (fneq (mus-increment gen) 32.0) (snd-display ";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 ";~A output: ~A" gen v0))
	(set! gen (make-env :envelope '(0 1 1 0) :base .0325 :end 10))
	(if (fneq (mus-increment gen) .0325) (snd-display ";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 ";~A output: ~A" gen v0))
	(set! gen (make-env :envelope '(0 1 1 .5 2 0) :base 0.0 :end 10 :offset 1.0))
	(if (fneq (mus-offset gen) 1.0) (snd-display ";mus-offset: ~A" (mus-offset gen)))
	(if (fneq (mus-increment gen) 0.0) (snd-display ";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 ";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 ";~A output: ~A" gen v0))
	(if (fneq (env-interp 1.5 gen) 1.5) (snd-display ";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 ";set! mus-location ~A (6)?" (mus-location gen)))
	(let ((val (env gen)))
	  (if (fneq val 1.5) (snd-display ";set! mus-location 6 -> ~A (1.5)?" val)))
	(set! (mus-location gen) 0)
	(let ((val (env gen)))
	  (if (fneq val 2.0) (snd-display ";set! mus-location 0 -> ~A (2.0)?" val)))
	(let ((gen (make-env '(0 0 1 -1 2 0) :end 10)))
	  (do ((i 0 (1+ i)))
	      ((= i 5))
	    (let ((val (env gen)))
	      (if (fneq val (/ i -5.0)) (snd-display ";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 ";neg env: ~D ~A" (+ i 5) val)))))
	(let ((gen (make-env '(0 0 1 -1 2 0) :end 10 :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 ";neg exp env: ~D ~A" i val)))))
	
	(let ((e (make-env '(0 0 1 1) :end 9)))
	  (if (fneq (env-interp 1.0 e) 1.0) (snd-display ";env-interp 0011 at 1: ~A" (env-interp 1.0 e)))
	  (if (fneq (env-interp 2.0 e) 1.0) (snd-display ";env-interp 0011 at 2: ~A" (env-interp 2.0 e)))
	  (if (fneq (env-interp 0.0 e) 0.0) (snd-display ";env-interp 0011 at 0: ~A" (env-interp 0.0 e)))
	  (if (fneq (env-interp 0.444 e) 0.444) (snd-display ";env-interp 0011 at .444: ~A" (env-interp 0.45 e)))
	  (restart-env e)
	  (do ((i 0 (1+ i)))
	      ((= i 10))
	    (let ((val (env e)))
	      (if (fneq val (* i .111111)) (snd-display ";ramp env over 10: ~A at ~A" val i)))))
	(let ((e (make-env '(0 0 .5 .5 1 1) :base 32 :end 9))
	      (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 ";(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 :end 9))
	      (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 ";(-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 :end 9))
	      (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 ";(-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 :end 9))
	      (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 ";(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) :end 9 :base 4.0)))
	  (if (fneq (env-interp 1.0 e) 1.0) (snd-display ";env-interp 0011 4 at 1: ~A" (env-interp 1.0 e)))
	  (if (fneq (env-interp 0.0 e) 0.0) (snd-display ";env-interp 0011 4 at 0: ~A" (env-interp 0.0 e)))
	  (if (fneq (env-interp 0.45 e) 0.2839) (snd-display ";env-interp 0011 4 at .45: ~A" (env-interp 0.45 e))))
	(let ((e (make-env '(0 0 1 1) :end 9 :base 0.2)))
	  (if (fneq (env-interp 1.0 e) 1.0) (snd-display ";env-interp 0011 2 at 1: ~A" (env-interp 1.0 e)))
	  (if (fneq (env-interp 0.0 e) 0.0) (snd-display ";env-interp 0011 2 at 0: ~A" (env-interp 0.0 e)))
	  (if (fneq (env-interp 0.45 e) 0.6387) (snd-display ";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 ";set mus-offset env: ~A" val)))
	
	(let ((e1 (make-env '(0 0 1 1) :base 32.0 :end 10))
	      (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 ";exp env direct (32.0): ~A ~A" val (vct-ref v i))))))
	
	(let ((e1 (make-env '(0 1 1 2) :base 32.0 :end 10))
	      (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 ";exp env direct (32.0) offset: ~A ~A" val (vct-ref v i))))))
	(let ((e1 (make-env '(0 1 1 2) :base 32.0 :dur 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 ";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 :end 10))
	      (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 ";exp env direct (.032): ~A ~A" val (vct-ref v i))))))
	
	(let ((e1 (make-env '(0 0 1 1) :base .03125 :end 10))
	      (e2 (make-env '(0 0 1 1 2 0) :base 32.0 :end 10))
	      (e3 (make-env '(0 0 .1 1 2 0) :base 1.1 :end 100)))
	  (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 ";env-interp[rmp ~F]: ~A (~A)?" (* .1 i) lv1 lv2))
	      (if (ffneq lv3 lv4) (snd-display ";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 ";env-interp[tri ~F]: ~A (~A)?" (* .02 i) lv5 lv6)))))
	
	(let ((e1 (make-env '(0 0 1 1 2 0) :end 9))
	      (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)))
	  (restart-env e1)
	  (do ((i 0 (1+ i))) ((= i 11)) (vct-set! lv3 i (env e1)))
	  (if (not (vequal lv1 lv3)) (snd-display ";restart-env: ~A ~A?" lv1 lv3))
	  (if (not (vequal lv2 (make-vct 11))) (snd-display ";restart-env 1: ~A?" lv2)))
	
	(set! gen (make-env '(0 0 1 1 2 0) :end 10))
	(do ((i 0 (1+ i))) ((= i 4)) (env gen))
	(let ((val (env gen)))
	  (if (fneq val .8) (snd-display ";env(5): ~A?" val))
	  (restart-env gen)
	  (do ((i 0 (1+ i))) ((= i 4)) (env gen))
	  (set! val (env gen))
	  (if (fneq val .8) (snd-display ";restart-env: ~A?" val))
	  (set! (mus-location gen) 6)
	  (let ((val (env gen)))
	    (if (fneq val 0.8) (snd-display ";set! mus-location 6 -> ~A (0.8)?" val)))))
      
      (let ((gen (make-env '(0 0 1 1) :base .032 :end 11)))
	(set! (mus-location gen) 5)
	(let ((val (env gen)))
	  (if (fneq val 0.817)
	      (snd-display ";set env location with base: ~A ~A" val gen))))
      (let ((gen (make-env '(0 0 1 1) :base .032 :dur 12)))
	(set! (mus-location gen) 5)
	(let ((val (env gen)))
	  (if (fneq val 0.817)
	      (snd-display ";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 :end 9) (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 9) (make-env '(0 0 1 1 2 0) :scaler 0.25 :end 9))
      (test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 9) (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 9) (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 10))
      (test-gen-equal (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 9) (make-env '(0 0 1 1 2 0) :scaler 0.5 :end 9) (make-env '(0 0 1 1 3 0) :scaler 0.5 :end 9))
      
      (let ((var (catch #t (lambda () (make-env :envelope '())) (lambda args args))))
	(if (not (eq? (car var) 'no-data))
	    (snd-display ";make-env null env: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :end 0)) (lambda args args))))
	(if (not (eq? (car var) 'no-data))
	    (snd-display ";make-env no env: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :envelope '(0 0) :end -1)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display ";make-env bad end: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :envelope '(0 0) :start -1)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display ";make-env bad start: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :envelope '(0 0) :dur -1)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display ";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 ";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 ";make-env bad base: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :envelope '(1 1 0 0) :end 10)) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";make-env bad env 1 1 0 0: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :envelope '(0 1 -1 0) :end 10)) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";make-env bad env 0 1 -1 0: ~A" var)))
      (let ((var (catch #t (lambda () (make-env :envelope '(0 1 1 0) :end 10 :dur 10)) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";make-env bad end/dur: ~A" var)))
      
      (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 ";table-lookup length: ~A?" (mus-length gen)))
	(if (not (= (mus-length gen3) 512)) (snd-display ";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 ";map table-lookup: ~A ~A" v0 v2))
	(set! gen4 (make-table-lookup 440.0 :wave (partials->wave '(1 1 2 1))))
	(vct-map! v2 (lambda () (table-lookup gen4)))
	(if (not (vequal v0 v2)) (snd-display ";map table-lookup (no fm): ~A ~A" v0 v2))
	(if (not (table-lookup? gen)) (snd-display ";~A not table-lookup?" gen))
	(if (not (vct? (mus-data gen))) (snd-display ";mus-data table-lookup: ~A" (mus-data gen)))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";table-lookup phase: ~F?" (mus-phase gen)))
	(set! (mus-phase gen) 1.0)
	(if (fneq (mus-phase gen) 1.0) (snd-display ";set! table-lookup phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";table-lookup frequency: ~F?" (mus-frequency gen)))
	(set! (mus-frequency gen) 100.0)
	(if (fneq (mus-frequency gen) 100.0) (snd-display ";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 ";table-lookup output: ~A" v0))
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (if (fneq (vct-ref v0 i) (vct-ref v1 i))
	      (snd-display ";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 ";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 ";normalized partials?"))
	(set! (mus-data gen) (phase-partials->wave (list 1 1 0 2 1 (* pi .5)) #f #t)))
      
      (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 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))))
      
      (let ((hi (make-table-lookup :size 256)))
	(if (not (= (mus-length hi) 256)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 (not (vequal v vals))
		   (snd-display ";tbl interp ~A: ~A" type v))
	       (if (not (= (mus-interp-type tbl1) type)) (snd-display ";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-none (vct 0.000 0.000 0.000 0.000 0.000 0.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-hermite (vct 0.000 0.168 0.424 0.696 0.912 1.000 0.912 0.696 0.424 0.168))))

      (let ((gen0 (make-waveshape 440.0 :wave (partials->waveshape '(1 1))))
	    (gen (make-waveshape 440.0 :size 512 :partials '(1 1)))
	    (v0 (make-vct 10))
	    (gen1 (make-waveshape 440.0 :wave (partials->waveshape '(1 1))))
	    (v1 (make-vct 10)))
	(print-and-check gen 
			 "waveshape"
			 "waveshape freq: 440.000Hz, phase: 0.000, size: 512")
	(if (not (= (mus-length gen) 512)) (snd-display ";waveshape length: ~A?" (mus-length gen)))
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (let ((val0 (waveshape gen0 1.0 0.0))
		(val (waveshape gen 1.0 0.0)))
	    (if (fneq val val0) (snd-display ";waveshape: ~A /= ~F?" val val0))
	    (vct-set! v0 i val)))
	(vct-map! v1 (lambda () (if (waveshape? gen1) (waveshape gen1 1.0 0.0) -1.0)))
	(if (not (vequal v0 v1)) (snd-display ";map waveshape: ~A ~A" v0 v1))
	(set! gen1 (make-waveshape 440.0 :wave (partials->waveshape '(1 1))))
	(vct-map! v1 (lambda () (waveshape gen1 1.0)))
	(if (not (vequal v0 v1)) (snd-display ";1 map waveshape: ~A ~A" v0 v1))
	(if (not (waveshape? gen)) (snd-display ";~A not waveshape?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";waveshape phase: ~F?" (mus-phase gen)))
	(set! (mus-phase gen) 1.0)
	(if (fneq (mus-phase gen) 1.0) (snd-display ";set! waveshape phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";waveshape frequency: ~F?" (mus-frequency gen)))
	(set! (mus-frequency gen) 100.0)
	(if (fneq (mus-frequency gen) 100.0) (snd-display ";waveshape frequency: ~F?" (mus-frequency gen)))
	(if (not (vct? (mus-data gen))) (snd-display ";mus-data waveshape: ~A" (mus-data gen)))
	(if (or (fneq (vct-ref v0 1) 0.125) (fneq (vct-ref v0 8) .843)) (snd-display ";waveshape output: ~A" v0))
	(set! (mus-data gen0) (make-vct 32))
	(set! (mus-length gen0) 32)
	(if (not (= (mus-length gen0) 32)) (snd-display ";set mus-length waveshape: ~A" (mus-length gen0))))
      
      (test-gen-equal (make-waveshape 440.0 :partials '(1 1)) (make-waveshape 440.0 :partials '(1 1)) (make-waveshape 100.0 :partials '(1 1)))
      (test-gen-equal (make-waveshape 440.0 :partials '(1 1)) (make-waveshape 440.0 :partials '(1 1)) (make-waveshape 4400.0 :partials '(1 1 2 .5)))
      
      (let ((d11 (partials->waveshape '(1 1) 16)))
	(if (not (vequal d11 (vct -1.000 -0.867 -0.733 -0.600 -0.467 -0.333 -0.200 -0.067 0.067 0.200 0.333 0.467 0.600 0.733 0.867 1.000)))
	    (snd-display ";partials->waveshape 1 1: ~A" d11))
	(set! d11 (partials->waveshape '(2 1) 16))
	(if (not (vequal d11 (vct -1.000 -0.502 -0.076 0.280 0.564 0.778 0.920 0.991 0.991 0.920 0.778 0.564 0.280 -0.076 -0.502 -1.000)))
	    (snd-display ";partials->waveshape 2 1: ~A" d11)))

      (let ((gen (make-waveshape 440.0 :partials '(1 1))))
	(do ((i 0 (1+ i)))
	    ((= i 1100))
	  (let* ((a (mus-phase gen))
		 (val1 (sin a))
		 (val2 (gen 1.0 0.0)))
	  (if (fneq val1 val2)
	      (snd-display ";waveshaper (1 1) ~A: ~A ~A" i val1 val2)))))

      (let ((gen (make-waveshape 440.0 :partials '(2 1))))
	(do ((i 0 (1+ i)))
	    ((= i 1100))
	  (let* ((a (mus-phase gen))
		 (val1 (sin (+ (* pi 0.5) (* 2 a))))
		 (val2 (gen 1.0 0.0)))
	  (if (fneq val1 val2)
	      (snd-display ";waveshaper (2 1) ~A: ~A ~A" i val1 val2)))))

      (let ((gen (make-waveshape 440.0 :partials '(1 1 2 .5))))
	(do ((i 0 (1+ i)))
	    ((= i 1100))
	  (let* ((a (mus-phase gen))
		 (val1 (+ (* .6667 (sin a)) (* .3333 (sin (+ (* pi 0.5) (* 2 a))))))
		 (val2 (gen 1.0 0.0)))
	  (if (fneq val1 val2)
	      (snd-display ";waveshaper (1 1 2 .5) ~A: ~A ~A" i val1 val2)))))

      (let ((gen (make-waveshape 440.0 :partials '(1 1))))
	(do ((i 0 (1+ i)))
	    ((= i 1100))
	  (let* ((a (mus-phase gen))
		 (val1 (* .5 (sin a)))
		 (val2 (gen 0.5 0.0)))
	  (if (fneq val1 val2)
	      (snd-display ";waveshaper (1 1) .5 index ~A: ~A ~A" i val1 val2)))))

      (let ((var (catch #t (lambda () (make-waveshape 440.0 :partials '(1 1) :size #f)) (lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display ";make-waveshape bad size: ~A" var)))
      (let ((var (catch #t (lambda () (make-waveshape 440.0 :wave 3.14)) (lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display ";make-waveshape bad wave: ~A" var)))
      (let ((var (catch #t (lambda () (make-waveshape 440.0 :size 0)) (lambda args args))))
	(if (not (eq? (car var) 'out-of-range))
	    (snd-display ";make-waveshape bad size -1: ~A" var)))
      (let ((hi (make-waveshape :size 256)))
	(if (not (= (mus-length hi) 256)) (snd-display ";waveshape set length: ~A?" (mus-length hi))))
      
      (let ((gen (make-waveshape 0.0 :wave (partials->waveshape '(1 1))))
	    (gen1 (make-waveshape 40.0 :wave (partials->waveshape '(1 1))))
	    (a1 0.0))
	(do ((i 0 (1+ i))
	     (a 0.0 (+ a (/ (* 2 pi 40.0) 22050.0))))
	    ((= i 400))
	  (let* ((fm (sin a))
		 (val1 (sin a1))
		 (val2 (waveshape gen 1.0 (waveshape gen1 1.0))))
	    (set! a1 (+ a1 fm))
	    (if (> (abs (- val1 val2)) .002)
		(snd-display ";waveshape fm: ~A: ~A ~A" i val1 val2)))))

      (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 ";wave-train data length: ~A?" (vct-length (mus-data gen))))
	(if (not (= (mus-length gen) 20)) (snd-display ";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 ";map wave-train: ~A ~A" v0 v1))
	(if (not (wave-train? gen)) (snd-display ";~A not wave-train?" gen))
	(if (fneq (mus-phase gen) 0.0) (snd-display ";wave-train phase: ~F?" (mus-phase gen)))
	(set! (mus-phase gen) 1.0)
	(if (fneq (mus-phase gen) 1.0) (snd-display ";set wave-train phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";wave-train frequency: ~F?" (mus-frequency gen)))
	(set! (mus-frequency gen) 100.0)
	(if (fneq (mus-frequency gen) 100.0) (snd-display ";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 ";wave-train output: ~A" v0))
	(if (not (vct? (mus-data gen))) (snd-display ";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)))
      
      (let ((hi (make-wave-train :size 256)))
	(if (not (= (mus-length hi) 256)) (snd-display ";wave-train set length: ~A?" (mus-length hi)))
	(set! (mus-length hi) 128)
	(if (not (= (mus-length hi) 128)) (snd-display ";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 ";tbl interp ~A: ~A ~A" type v (mus-describe tbl1)))
	       (if (not (= (mus-interp-type tbl1) type)) (snd-display ";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 ";wave-train size 0: ~A" tag)))
      
      (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 "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 ";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 ";wt 0 data 85: ~A" (channel->vct 85 30)))
	  (undo))
	
	(let* ((table (make-vct 10 .1))
	       (gen (make-wave-train 1000.0 :initial-phase 3.14159 :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 "wt 1 max: ~A" mx)))
	  (if (not (vequal (channel->vct 0 30) 
			   (vct 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 0.100 0.100 0.100 0.000)))
	      (snd-display ";wt 1 data: ~A" (channel->vct 0 30)))
	  (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 "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 ";wt 2 data: ~A" (channel->vct 0 30)))
	  (if (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)))
	      (snd-display ";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 "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 ";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 ";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 "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 ";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 ";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) :end 1000))
	       (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 "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 ";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 ";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 ";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 "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 ";wt 6 data: ~A" (channel->vct 0 30)))
	  (if (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)))
	      (snd-display ";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 ";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 ";map readin: ~A ~A" v0 v1))
	(if (not (readin? gen)) (snd-display ";~A not readin?" gen))
	(if (not (mus-input? gen)) (snd-display ";~A not input?" gen))
	(if (not (= (mus-length gen) 50828)) (snd-display ";readin length: ~A?" (mus-length gen)))
	(if (not (= (mus-channel gen) 0)) (snd-display ";readin chan: ~A?" (mus-channel gen)))
	(if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display ";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 ";readin output: ~A" v0))
	(set! (mus-location gen) 1000)
	(if (not (= (mus-location gen) 1000)) (snd-display ";set! mus-location: ~A?" (mus-location gen)))
	(let ((val (readin gen)))
	  (if (fneq val 0.033) (snd-display ";set! mus-location readin: ~A?" val)))
	(set! (mus-increment gen) -1)
	(if (fneq (mus-increment gen) -1.0) (snd-display ";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 ";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 ";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) (make-readin "oboe.snd" 0) (make-readin "pistol.snd" 0))
      (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))
	    (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 ";readin chan 1: ~A?" (mus-channel gen)))
	(if (or (fneq (vct-ref v0 1) 0.010) (fneq (vct-ref v0 7) -.006)) (snd-display ";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 ";~A not input?" gen))
	(if (not (= (mus-length gen) 50828)) (snd-display ";file->sample length: ~A?" (mus-length gen)))
	(if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display ";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 ";~A not file->sample?" gen))
	(if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display ";file->sample output: ~A" v0))
	(if (fneq (mus-increment gen) 0.0) (snd-display ";file->sample increment: ~A" (mus-increment gen)))
	(set! (mus-increment gen) 1.0)
	(if (fneq (mus-increment gen) 1.0) (snd-display ";file->sample set increment: ~A" (mus-increment gen))))
      
      (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 ";snd->sample not eq? itself?"))
	(if (equal? gen gen1) (snd-display ";snd->sample eq? not itself?"))
	(if (not (mus-input? gen)) (snd-display ";snd->sample ~A not input?" gen))
	(if (not (= (frames ind) (mus-length gen))) (snd-display ";snd->sample len: ~A ~A" (frames ind) (mus-length gen)))
	(if (not (string=? (mus-file-name gen) (string-append cwd "oboe.snd")))
	    (snd-display ";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 ";~A not snd->sample?" gen))
	(if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display ";snd->sample output: ~A" v0))
	(if (not (= (mus-channels gen) 1)) (snd-display ";snd->sample channels: ~A" (mus-channels gen)))
	(if (not (= (mus-location gen) 1499)) (snd-display ";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 ";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:[#<sample-reader: 2.snd[0: 0] from 1490, at 1500>, #<sample-reader: 2.snd[1: 0] from 1490, at 1500>]")
	(if (not (mus-input? gen)) (snd-display ";snd->sample ~A not input?" gen))
	(if (not (string=? (mus-file-name gen) (string-append cwd "2.snd")))
	    (snd-display ";snd->sample mus-file-name: ~A ~A" (mus-file-name gen) (string-append cwd "2.snd")))
	(if (not (snd->sample? gen)) (snd-display ";~A not snd->sample?" gen))
	(if (not (= (mus-channels gen) 2)) (snd-display ";snd->sample channels (2): ~A" (mus-channels gen)))
	(if (not (= (mus-location gen) 1499)) (snd-display ";snd->sample location (2): ~A" (mus-location gen)))
	(close-sound ind))
      
      (let* ((fgen (make-file->sample "oboe.snd"))
	     (gen (make-xen->sample (lambda (samp chan) (* 2.0 (file->sample fgen samp chan)))))
	     (gen1 (make-xen->sample (lambda (s c) 1.0)))
	     (gen2 gen)
	     (v0 (make-vct 10)))
	(print-and-check gen 
			 "xen->sample"
			 "xen->sample: (lambda (samp chan) (* 2.0 (file->sample fgen samp chan)))")
	(if (not (mus-input? gen)) (snd-display ";xen->sample ~A not input?" gen))
	(if (not (equal? gen gen)) (snd-display ";xen->sample not eq? itself?"))
	(if (equal? gen gen1) (snd-display ";xen->sample eq? ~A ~A" gen gen1))
	(if (not (equal? gen gen2)) (snd-display ";xen->sample not eq? ~A ~A" gen gen2))
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (vct-set! v0 i (xen->sample gen (+ 1490 i) 0)))
	(if (not (xen->sample? gen)) (snd-display ";~A not xen->sample?" gen))
	(if (or (fneq (vct-ref v0 1) (* 2 -0.009)) (fneq (vct-ref v0 7) (* 2 .029))) (snd-display ";xen->sample output: ~A" v0))
	(do ((i 0 (1+ i)))
	    ((= i 10))
	  (vct-set! v0 i (ina (+ 1490 i) gen)))
	(if (or (fneq (vct-ref v0 1) (* 2 -0.009)) (fneq (vct-ref v0 7) (* 2 .029))) (snd-display ";xen->sample ina output: ~A" v0)))
      
      (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 ";~A not input?" gen))
	(if (not (= (mus-length gen) 50828)) (snd-display ";file->frame length: ~A?" (mus-length gen)))
	(if (not (string=? (mus-file-name gen) "oboe.snd")) (snd-display ";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 ";~A not file->frame?" gen))
	(if (or (fneq (vct-ref v0 1) -0.009) (fneq (vct-ref v0 7) .029)) (snd-display ";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 ";~A not output?" gen))
	(if (not (sample->file? gen)) (snd-display ";~A not sample->file?" gen))
	(if (not (= (mus-length gen) (mus-file-buffer-size))) (snd-display ";sample->file length: ~A?" (mus-length gen)))
	(let ((genx gen))
	  (if (not (equal? genx gen)) (snd-display ";sample->file equal? ~A ~A" genx gen)))
	(if (not (string=? (mus-file-name gen) "fmv.snd")) (snd-display ";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 ";make-sample->file chans: ~A?" (mus-channels gen)))
	(if (not (mus-input? gen)) (snd-display ";~A not input?" gen))
	(if (or (fneq val0 .02) (fneq val1 .2)) (snd-display ";in-any: ~A ~A?" val0 val1))
	(if (or (fneq val2 .03) (fneq val3 .3)) (snd-display ";inab: ~A ~A?" val2 val3))
	(if (or (fneq val4 .04) (fneq val5 .4)) (snd-display ";sample->file: ~A ~A?" val4 val5))
	(if (or (fneq val6 .065) (fneq val7 .65)) (snd-display ";outab: ~A ~A?" val6 val7))
	(if (or (fneq val8 .075) (fneq val9 .75)) (snd-display ";out-any: ~A ~A?" val8 val9)))
      
      (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 ";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
	 (lambda ()
	   (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 ";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 ";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 ";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 ";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 ";make-sample->file bad type: ~A" var)))
      
      (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 ";~A not output?" gen))
	(if (not (frame->file? gen)) (snd-display ";~A not frame->file?" gen))
	(if (not (= (mus-length gen) (mus-file-buffer-size))) (snd-display ";frame->file length: ~A?" (mus-length gen)))
	(if (not (string=? (mus-file-name gen) "fmv1.snd")) (snd-display ";frame->file mus-file-name: ~A" (mus-file-name gen)))
	(set! (mus-length gen) 4096)
	(if (not (= (mus-length gen) 4096)) (snd-display ";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"))
	     (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 ";frame->file output: ~A?" val4))
	(file->frame gen 40 frout)
	(if (not (equal? frout val4))
	    (snd-display ";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 ";~A not output?" gen))
	(if (not (sample->file? gen)) (snd-display ";~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 ";make-file->sample (4) chans: ~A?" (mus-channels gen)))
	(if (not (= (mus-increment gen) 0.0)) (snd-display ";file->sample increment: ~A" (mus-increment gen))) ; dir never set in this case
	(if (or (fneq val0 .04) (fneq val1 .06)) (snd-display ";in-any(0, 4): ~A ~A?" val0 val1))
	(if (or (fneq val2 .12) (fneq val3 .18)) (snd-display ";file->sample(4): ~A ~A?" val2 val3))
	(if (or (fneq val4 .14) (fneq val5 .21)) (snd-display ";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 ";sample->file chans: ~A" (mus-sound-chans "fmv.snd")))
	(if (not (= (mus-sound-frames "fmv.snd") 10)) 
	    (snd-display ";sample->file frames: ~A" (mus-sound-frames "fmv.snd")))
	(if (not (= (mus-sound-samples "fmv.snd") 20)) 
	    (snd-display ";sample->file samples: ~A" (mus-sound-samples "fmv.snd")))
	(if (not (= (mus-sound-header-type "fmv.snd") mus-next)) 
	    (snd-display ";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 ";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 ";sample->file comment: ~A" (mus-sound-comment "fmv.snd")))
	(let ((rd (make-file->sample "fmv.snd")))
	  (call-with-current-continuation
	   (lambda (break)
	     (do ((i 0 (1+ i)))
		 ((= 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 ";sample->file->sample at ~A: ~A ~A" i c0 c1)
		       (break)))))))
	  (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 ";continue-sample->file chans: ~A" (mus-sound-chans "fmv.snd")))
	(if (not (= (mus-sound-frames "fmv.snd") 15)) 
	    (snd-display ";continue-sample->file frames: ~A" (mus-sound-frames "fmv.snd")))
	(if (not (= (mus-sound-samples "fmv.snd") 30)) 
	    (snd-display ";continue-sample->file samples: ~A" (mus-sound-samples "fmv.snd")))
	(if (not (= (mus-sound-header-type "fmv.snd") mus-next)) 
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";frame->file chans: ~A" (mus-sound-chans "fmv.snd")))
	(if (not (= (mus-sound-frames "fmv.snd") 10)) 
	    (snd-display ";frame->file frames: ~A" (mus-sound-frames "fmv.snd")))
	(if (not (= (mus-sound-samples "fmv.snd") 20)) 
	    (snd-display ";frame->file samples: ~A" (mus-sound-samples "fmv.snd")))
	(if (not (= (mus-sound-header-type "fmv.snd") mus-riff)) 
	    (snd-display ";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 ";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 ";frame->file comment: ~A" (mus-sound-comment "fmv.snd")))
	(let ((rd (make-file->frame "fmv.snd")))
	  (call-with-current-continuation
	   (lambda (break)
	     (do ((i 0 (1+ i)))
		 ((= 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 ";frame->file->frame at ~A: ~A" i f0)
		       (break)))))))
	  (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 ";continue-frame->file chans: ~A" (mus-sound-chans "fmv.snd")))
	(if (not (= (mus-sound-frames "fmv.snd") 15)) 
	    (snd-display ";continue-frame->file frames: ~A" (mus-sound-frames "fmv.snd")))
	(if (not (= (mus-sound-samples "fmv.snd") 30)) 
	    (snd-display ";continue-frame->file samples: ~A" (mus-sound-samples "fmv.snd")))
	(if (not (= (mus-sound-header-type "fmv.snd") mus-riff)) 
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";~A not rand?" gen))
	(if (fneq (mus-phase gen) 3.3624296) (snd-display ";rand phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 10000.0) (snd-display ";rand frequency: ~F?" (mus-frequency gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";set! mus-scaler rand: ~A" (mus-scaler gen)))
	(if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display ";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 ";(dist) ~A not rand?" gen))
	(if (fneq (mus-frequency gen) 10000.0) (snd-display ";(dist) rand frequency: ~F?" (mus-frequency gen)))
	(if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display ";(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 ";(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.5 down1) up1)
		(> (* 2.5 up2) down2))
	    (snd-display "; 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 ";~A not rand-interp?" gen))
	(if (fneq (mus-phase gen) 5.114882) (snd-display ";rand-interp phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 4000.0) (snd-display ";rand-interp frequency: ~F?" (mus-frequency gen)))
	(set! (mus-scaler gen) 0.5)
	(if (fneq (mus-scaler gen) 0.5) (snd-display ";set! mus-scaler rand-interp: ~A" (mus-scaler gen)))
	(if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display ";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 ";(dist) ~A not rand-interp?" gen))
	(if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display ";(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 ";(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 ";rand: ~A ~A" val1 gen))
	    (if (or (> val2 1.0)
		    (< val2 -1.0))
		(snd-display ";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 ";(dist 2) ~A not rand?" gen))
	(if (fneq (mus-frequency gen) 10000.0) (snd-display ";(dist 2) rand frequency: ~F?" (mus-frequency gen)))
	(if (= (vct-ref v0 1) (vct-ref v0 8)) (snd-display ";(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 ";(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.5 up2) down2))
	    (snd-display "; rand dist 2: ~A ~A ~A, ~A ~A ~A" down1 up1 bad1 down2 up2 bad2)))

      (let ((v1 (inverse-integrate '(-1 1 1 1))))
	(if (fneq (vct-ref v1 4) -0.984)
	    (snd-display ";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 ";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 ";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 ";inverse-integrate triangle: ~A" v1)))
      (let ((v1 (inverse-integrate (gaussian-envelope 1.0))))
	(if (fneq (vct-ref v1 4) -0.593)
	    (snd-display ";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 ";mus-random: ~A" val1))))
	(if (or (< maxp .9)
		(> minp -.9))
	    (snd-display ";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 ";mus-random (12): ~A" val1))))
	(if (or (< maxp 11.0)
		(> minp -11.0))
	    (snd-display ";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 (inexact->exact (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 ";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 (inexact->exact (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 ";rand not so random? ~A (chi)" vr))))
      
      (let ((v2 (lambda (n) ; Kolmogorov-Smirnov
		  (let ((vals (make-vector n 0.0))
			(sn (sqrt n)))
		    (do ((i 1 (1+ i)))
			((= i n))
		      (vector-set! vals i (+ 0.5 (mus-random 0.5))))
		    (set! vals (sort vals <))
		    (let ((K+ 0.0)
			  (K- 0.0)
			  (incr (/ 1.0 n))
			  (y 0.0))
		      (do ((i 1 (1+ i))
			   (x incr (+ x incr)))
			  ((= i n))
			(let ((Kp (- x (vector-ref vals i)))
			      (Km (- (vector-ref vals i) y)))
			  (if (> Kp K+) (set! K+ Kp))
			  (if (> Km K-) (set! K- Km))
			  (set! y x)))
		      (list (* sn K+) (* sn K-)
			    (- .07089 (/ 0.15 sn)) 
			    (- .1601 (/ .014 sn))
			    (- .3793 (/ 0.15 sn))
			    (- .5887 (/ 0.15 sn))))))))
	
	;;:(v2 1000)
	;;(0.419489806081307 0.536508579184211 0.0661465835097474 0.159657281127576 0.374556583509747 0.583956583509747)
	;; if < .2 complain?
	
	(let* ((vr (v2 1000))
	       (kp (car vr))
	       (km (cadr vr))
	       (k (list-ref vr 3)))
	  (if (or (< kp k)
		  (< km k))
	      (snd-display ";mus-random not random? ~A (KS)" 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 ";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 ";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 ";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 ";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 ";~A not locsig?" gen))
	(if (not (eq? gen1 gen3)) (snd-display ";locsig eq? ~A ~A" gen1 gen3))
	(if (not (equal? gen1 gen3)) (snd-display ";locsig equal? ~A ~A" gen1 gen3))
	(if (eq? gen1 gen2) (snd-display ";locsig 1 eq? ~A ~A" gen1 gen2))
	(if (equal? gen gen1) (snd-display ";locsig 2 equal? ~A ~A" gen gen1))
	(if (equal? gen gen2) (snd-display ";locsig 3 equal? ~A ~A" gen gen2))
	(if (or (fneq (frame-ref fr0 0) .667) (fneq (frame-ref fr0 1) .333)) (snd-display ";locsig output: ~A" fr0))
	(if (or (fneq (locsig-ref gen 0) .667) (fneq (locsig-ref gen 1) .333))
	    (snd-display ";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 ";locsig gen outn: ~A" (mus-data gen)))
	(if (not (vequal (mus-data gen1) (vct 0.333 0.667)))
	    (snd-display ";locsig gen2 outn: ~A" (mus-data gen1)))
	(if (not (vequal (mus-data gen2) (vct 0.333 0.667 0.000 0.000)))
	    (snd-display ";locsig gen2 outn: ~A" (mus-data gen2)))
	(if (not (vequal (mus-data gen200) (vct 0.000 0.000 0.778 0.222)))
	    (snd-display ";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 ";locsig gen .25 outn: ~A" (mus-data gen)))
	(set! fr0 (locsig gen 0 1.0))
	(if (fneq (frame-ref fr0 0) .25) (snd-display ";set locsig-ref: ~F?" (frame-ref fr0 0)))
	(locsig-set! gen 0 .5)
	(if (not (vequal (mus-data gen) (vct 0.500 0.333)))
	    (snd-display ";locsig gen .5 outn: ~A" (mus-data gen)))
	(set! fr0 (locsig gen 0 1.0))
	(if (fneq (frame-ref fr0 0) .5) (snd-display ";locsig-set: ~F?" (frame-ref fr0 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 ";locsig gen 120 outn: ~A" (mus-data gen)))
	(set! fr0 (locsig gen 0 1.0))
	(if (or (fneq (frame-ref fr0 1) .333) (fneq (frame-ref fr0 2) .167)) (snd-display ";locsig quad output: ~A" fr0))
	(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 ";locsig gen 300 outn: ~A" (mus-data gen)))
	(set! fr0 (locsig gen 0 1.0))
	(if (or (fneq (frame-ref fr0 3) .333) (fneq (frame-ref fr0 0) .167)) (snd-display ";300 locsig quad output: ~A" fr0))
	(move-locsig gen1 90.0 1.0)
	(if (not (vequal (mus-data gen1) (vct 0.000 1.000)))
	    (snd-display ";locsig gen1 90 outn: ~A" (mus-data gen)))
	(if (or (fneq (locsig-ref gen1 0) 0.0) (fneq (locsig-ref gen1 1) 1.0)) (snd-display ";move-locsig 90 1: ~A" gen1))
	(move-locsig gen1 0.0 1.0)
	(if (not (vequal (mus-data gen1) (vct 1.000 0.000)))
	    (snd-display ";locsig gen1 0 outn: ~A" (mus-data gen)))
	(if (or (fneq (locsig-ref gen1 0) 1.0) (fneq (locsig-ref gen1 1) 0.0)) (snd-display ";move-locsig 0 1: ~A" gen1))
	(move-locsig gen1 45.0 1.0)
	(if (not (vequal (mus-data gen1) (vct 0.500 0.500)))
	    (snd-display ";locsig gen1 45 outn: ~A" (mus-data gen)))
	(if (or (fneq (locsig-ref gen1 0) 0.5) (fneq (locsig-ref gen1 1) 0.5)) (snd-display ";move-locsig 45 1: ~A" gen1))
	(move-locsig gen1 135.0 2.0)
	(if (not (vequal (mus-data gen1) (vct 0.000 0.500)))
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";make-locsig bad output: ~A" var)))
      (let ((var (catch #t (lambda () (locsig-ref (make-locsig) 1)) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";locsig-ref bad chan: ~A" var)))
      (let ((var (catch #t (lambda () (make-locsig :revout 1)) (lambda args args))))
	(if (not (eq? (car var) 'wrong-type-arg))
	    (snd-display ";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 (not (eq? (car var) 'mus-error))
	    (snd-display ";locsig-ref bad chan: ~A" var)))
      (let ((var (catch #t (lambda () (let ((locs (make-locsig))) (locsig-set! locs 2 .1))) (lambda args args))))
	(if (not (eq? (car var) 'mus-error))
	    (snd-display ";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 (not (eq? (car var) 'mus-error))
	    (snd-display ";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 (not (eq? (car var) 'mus-error))
	    (snd-display ";locsig-reverb-set! bad reverb chan (2): ~A" var)))
      
      (if (file-exists? "fmv4.snd") (delete-file "fmv4.snd"))
      (if (file-exists? "fmv4.reverb") (delete-file "fmv4.reverb"))
      (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 ";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 ";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 ";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 ";locsig reverb: ~A?" v2))
	  (if (fneq (* 2 (vct-ref v0 0)) (vct-ref v1 0)) (snd-display ";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 ";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 ";out data locsig: ~A" (mus-data lc)))
	(if (not (vct? (mus-xcoeffs lc))) (snd-display ";rev data locsig: ~A" (mus-xcoeffs lc)))
	(let ((xcs (mus-xcoeffs lc)))
	  (if (fneq (mus-xcoeff lc 0) (vct-ref xcs 0)) (snd-display ";locsig xcoeff: ~A ~A" (mus-xcoeff lc 0) (vct-ref xcs 0)))
	  (if (fneq (mus-xcoeff lc 1) .1) (snd-display ";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")
      (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";locsig 24(8): ~A" (locsig-data gen)))))
      
      (for-each 
       (lambda (rev-chans)
	 
	 (define (locsig-scalers chans degree type)
	   (define (fmod a b)
	     (let ((pos (inexact->exact (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 (inexact->exact (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)))
	   (for-each
	    (lambda (type)
	      ;; global type def as well as local par override etc
	      
	      (set! (locsig-type) type)
	      (if (not (= (locsig-type) type)) (snd-display ";locsig-type: ~A ~A" type (locsig-type)))
	      
	      (call-with-current-continuation
	       (lambda (quit)
		 
		 (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 ";locsig ~A: ~A" deg gen))
		      (if (fneq (locsig-ref gen 0) 0.5) (snd-display ";locsig scaler[~A] ~A: ~A" type deg (locsig-ref gen 0)))
		      (if revfile
			  (do ((i 0 (1+ i)))
			      ((= i rev-chans))
			    (if (fneq (locsig-reverb-ref gen i) (* (/ .1 (sqrt 2.0)) (vct-ref revs i)))
				(begin 
				  (snd-display ";mono locrev[~A] ~A at ~A: ~A ~A" 
					       type gen deg 
					       (locsig-reverb-ref gen i) 
					       (* (/ .1 (sqrt 2.0)) (vct-ref revs i)))
				  (quit)))))))
		  (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 ";locsig ~A: ~A" deg gen))
			 (if (fneq (locsig-ref gen 0) 1.0) (snd-display ";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 ";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)))
			       ((= i chans))
			     (if (fneq (locsig-ref gen i) (vct-ref scalers i)) 
				 (begin 
				   (snd-display ";locsig[~A] ~A at ~A: ~A ~A" type gen deg (locsig-ref gen i) (vct-ref scalers i)) 
				   (quit))))
			   (if revfile
			       (do ((i 0 (1+ i)))
				   ((= i rev-chans))
				 (if (fneq (locsig-reverb-ref gen i) (* .1 (vct-ref revs i)))
				     (begin 
				       (snd-display ";locrev[~A] ~A at ~A: ~A ~A" 
						    type gen deg 
						    (locsig-reverb-ref gen i) 
						    (* .1 (vct-ref revs i)))
				       (quit))))))))
		     (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 ";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)))
				  ((= i chans))
				(if (fneq (locsig-ref gen i) (vct-ref scalers i)) 
				    (begin
				      (snd-display ";locsig[~A] ~A at ~A: ~A ~A" ltype gen deg (locsig-ref gen i) (vct-ref scalers i))
				      (quit))))
			      (if revfile
				  (do ((i 0 (1+ i)))
				      ((= i rev-chans))
				    (if (fneq (locsig-reverb-ref gen i) (* .1 (vct-ref revs i)))
					(begin 
					  (snd-display ";locrev[~A] ~A at ~A: ~A ~A" 
						       type gen deg 
						       (locsig-reverb-ref gen i) 
						       (* .1 (vct-ref revs i)))
					  (quit))))))))
			(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))
      
      (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 ";run src: ~A ~A" v0 v1))
	(if (not (src? gen)) (snd-display ";~A not scr?" gen))
	(if (or (fneq (vct-ref v0 1) .001) (fneq (vct-ref v0 7) .021)) (snd-display ";src output: ~A" v0))
	(if (fneq (mus-increment gen) 2.0) (snd-display ";src increment: ~F?" (mus-increment gen)))
	(if (fneq (mus-increment gen2) 0.0) (snd-display ";src 0.0 increment: ~F?" (mus-increment gen2)))
	(if (fneq (mus-increment rd) 1.0) (snd-display ";readin increment: ~F?" (mus-increment rd)))
	(if (not (= (mus-length gen) 10)) (snd-display ";src length: ~A" (mus-length gen)))
	(let ((gold gen))
	  (set! gen (make-src (lambda (dir)
				0.0)))
	  (if (equal? gen gold) (snd-display ";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 ";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 ((gen (make-granulate :expansion 2.0))
	    (v0 (make-vct 1000))
	    (rd (make-readin "oboe.snd" 0 4000))
	    (gen1 (make-granulate :expansion 2.0))
	    (v1 (make-vct 1000))
	    (rd1b (make-readin "oboe.snd" 0 4000)))
	(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 ";run granulate: ~A" worst)))
	(let ((genx gen1))
	  (if (not (equal? genx gen1))
	      (snd-display ";granulate equal? ~A ~A ~A" genx gen1 (equal? genx gen1))))
	(if (equal? gen gen1) (snd-display ";granulate equal? ~A ~A" gen gen1))
	(if (= (vct-peak v0) 0.0) (snd-display ";granulate output peak: ~F?" (vct-peak v0)))
	(if (not (granulate? gen)) (snd-display ";~A not granulate?" gen))
	(if (fneq (mus-increment gen) 2.0) (snd-display ";granulate increment: ~F?" (mus-increment gen)))
	(if (fneq (mus-scaler gen) 0.6) (snd-display ";granulate scaler: ~F?" (mus-scaler gen)))
	(if (ffneq (mus-frequency gen) 0.05) (snd-display ";granulate frequency: ~F?" (mus-frequency gen)))
	(if (not (= (mus-ramp gen) 1323)) (snd-display ";granulate ramp: ~F?" (mus-ramp gen)))
	(if (not (= (mus-length gen) 3308)) (snd-display ";granulate length: ~A?" (mus-length gen)))
	(if (not (= (mus-hop gen) 1102)) (snd-display ";granulate hop: ~A?" (mus-hop gen)))
	(set! (mus-hop gen) 1000) (if (not (= (mus-hop gen) 1000)) (snd-display ";granulate set-hop: ~A?" (mus-hop gen)))
	(set! (mus-ramp gen) 1000) (if (not (= (mus-ramp gen) 1000)) (snd-display ";granulate set-ramp: ~A?" (mus-ramp gen)))
	(set! (mus-length gen) 3000) (if (not (= (mus-length gen) 3000)) (snd-display ";granulate set-length: ~A?" (mus-length gen)))
	(set! (mus-increment gen) 3.0)
	(if (> (abs (- (mus-increment gen) 3.0)) .01) (snd-display ";granulate set-increment: ~F?" (mus-increment gen)))
	(set! (mus-frequency gen) .1)
	(if (fneq (mus-frequency gen) .1) (snd-display ";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 ";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 ";make-granulate bad sizes: ~A" var)))
      
      (let ((ind (open-sound "oboe.snd"))
	    (mx (maxamp)))
	(let ((rd (make-sample-reader 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.5) (> (/ mx (maxamp)) 2.5))
		(snd-display ";gran edit 2* (0): ~A ~A" mx (maxamp)))
	    (undo)))
	(let ((rd (make-sample-reader 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 ";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-sample-reader 0)))
	  (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	  (if (or (< (/ (maxamp) mx) 1.5) (> (/ mx (maxamp)) 2.5))
	      (snd-display ";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-sample-reader 0)))
	    (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	    (if (or (< (/ (maxamp) mx) 3.0) (> (/ mx (maxamp)) 6.0))
		(snd-display ";gran edit 4* (1): ~A ~A" mx (maxamp)))
	    (revert-sound ind)))
	(let ((grn (make-granulate :expansion 2.0))
	      (rd (make-sample-reader 0)))
	  (map-channel (lambda (y) (granulate grn 
					      (lambda (dir) 
						(rd))
					      (lambda (g)
						(declare (g clm))
						(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.5) (> (/ mx (maxamp)) 2.5))
	      (snd-display ";gran edit 2* (2): ~A ~A" mx (maxamp)))
          (undo)
	  (let ((grn (make-granulate :expansion 2.0))
		(rd (make-sample-reader 0)))
	    (map-channel (lambda (y) (granulate grn 
						(lambda (dir) 
						  (rd))
						(lambda (g)
						  (declare (g clm))
						  (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 ";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-sample-reader 0)))
	  (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	  (let ((mx (maxamp)))
	    (if (> mx .2) (snd-display ";trouble in granulate len .01 hop .05: ~A" mx))
	    (undo)))
	(let ((grn (make-granulate :expansion 2.0 :length .04 :hop .05))
	      (rd (make-sample-reader 0)))
	  (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	  (let ((mx (maxamp)))
	    (if (> mx .2) (snd-display ";trouble in granulate len .04 hop .05: ~A" mx))
	    (undo)))
	(let ((grn (make-granulate :expansion 2.0 :length .01 :hop .25))
	      (rd (make-sample-reader 0)))
	  (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	  (let ((mx (maxamp)))
	    (if (> mx .2) (snd-display ";trouble in granulate len .01 hop .25: ~A" mx))
	    (undo)))
	(let ((grn (make-granulate :expansion 2.0 :length .4 :hop .5))
	      (rd (make-sample-reader 0)))
	  (map-channel (lambda (y) (granulate grn (lambda (dir) (rd)))))
	  (let ((mx (maxamp)))
	    (if (> mx .2) (snd-display ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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 "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 ";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 ";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)
						(declare (g clm))
						(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 "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 ";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 ";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)
						(declare (g clm))
						(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 "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 ";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 ";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 "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 ";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 ";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)
					   (declare (g clm))
					   (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 "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 ";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 ";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)
					    (declare (g clm))
					    (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 "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 ";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 ";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) :end 1000))
	       (base-ramp-len (mus-length gen)))
	  (map-channel 
	   (lambda (y) 
	     (let ((result (granulate gen (lambda (dir) .1))))
	       (set! (mus-ramp gen) (inexact->exact (round (* base-ramp-len (env e)))))
	       result)))
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.06) (snd-display "granf 0 max: ~A" mx)))
	  (if (> (abs (- (mus-ramp gen) (* .5 (mus-length gen)))) 1)
	      (snd-display ";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 ";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 ";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 ";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) :end 1000))
	       (base-hop-len (mus-hop gen)))
	  (map-channel 
	   (lambda (y) 
	     (let ((result (granulate gen (lambda (dir) .1))))
	       (set! (mus-hop gen) (inexact->exact (round (* base-hop-len (env e)))))
	       result)))
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.06) (snd-display "granf 1 max: ~A" mx)))
	  (if (> (abs (- (mus-hop gen) (* .001 (srate)))) 1)
	      (snd-display ";granf 1 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 ";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 ";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) :end 1000))
	       (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 "granf 2 max: ~A" mx)))
	  (if (> (abs (- (mus-hop gen) (* .001 (srate)))) 1)
	      (snd-display ";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 ";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 ";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 "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 ";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) :end 1000)))
	  (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 "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 ";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 ";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 ";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 .01))
	       (e (make-env '(0 1 1 5) :end 1000))
	       (base-len (mus-length gen)))
	  (map-channel 
	   (lambda (y) 
	     (let ((result (granulate gen (lambda (dir) .1))))
	       (set! (mus-length gen) (inexact->exact (round (* base-len (env e)))))
	       result)))
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.06) (snd-display "granf 5 max: ~A" mx)))
	  (if (> (abs (- (mus-length gen) (* 5 base-len))) 10)
	      (snd-display ";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 ";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 ";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 ";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 .01))
	       (e (make-env '(0 1 1 .2) :end 1000))
	       (base-len (mus-length gen)))
	  (map-channel 
	   (lambda (y) 
	     (let ((result (granulate gen (lambda (dir) .1))))
	       (set! (mus-length gen) (inexact->exact (round (* base-len (env e)))))
	       result)))
	  (let ((mx (maxamp)))
	    (if (fneq mx 0.06) (snd-display "granf 6 max: ~A" mx)))
	  (if (> (abs (- (mus-length gen) (* .2 base-len))) 4)
	      (snd-display ";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 ";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 ";granf 6 data 820: ~A" (channel->vct 820 30)))
	  (undo))

	(let ((fname (file-name ind)))
	  (close-sound ind)
	  (delete-file fname)))

      (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 ";~A not convolve?" gen))
	  (let ((genx gen1))
	    (if (not (equal? genx gen1)) (snd-display ";convolve equal?: ~A ~A ~A" genx gen1 (equal? genx gen1))))
	  (if (equal? gen gen1) (snd-display ";convolve equal? ~A ~A" gen gen1))
	  (if (not (= (mus-length gen) 64)) (snd-display ";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 ";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 ";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 ";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 ";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 ";~A not sound-data?" data))
	(if (not (= (sound-data-chans data) 1)) (snd-display ";sound-data chans: ~A?" (sound-data-chans data)))
	(if (not (= (sound-data-length data) 2000)) (snd-display ";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 ";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 ";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 ";save-sound 2 samps: ~A?" (frames ind 0)))
	(if (or (fneq (sample 0) 0.0)
		(fneq (sample 1) 0.1))
	    (snd-display ";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 ";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 ";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 ";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 ";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) .003) (snd-display ";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) .003) (snd-display ";ssb-am fm cancelled: ~A" (maxamp)))
	  (close-sound ind)))

      (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 ";ssb-bank cancelled: ~A" (maxamp))))
	(close-sound ind))

      (if *output* 
	  (begin
	    (snd-display ";*output* ~A" *output*)
	    (set! *output* #f)))

      (let ((nind (new-sound "fmv.snd" mus-aifc mus-bshort 22050 1 "this is a comment")))
	(time (fm-violin 0 1 440 .1))
	(play-and-wait 0 nind)
	(save-sound nind)
	(if (not (sound? nind)) (snd-display ";save sound clobbered ~A?" nind))
	(let ((oboe-index (or (find-sound "oboe.snd") (open-sound "oboe.snd"))))
	  (if (= oboe-index nind) (snd-display ";find-sound found bogus case: ~A" oboe-index))
	  (cnvtest oboe-index nind .1) 
	  (select-sound nind)
	  (select-channel 0)
	  (if (not (= (selected-sound) nind)) (snd-display ";selected-sound: ~A?" (selected-sound)))
	  (if (not (= (selected-channel) 0)) (snd-display ";selected-channel: ~A?" (selected-channel)))
	  (jc-reverb 1.0 #f .1 #f) 
	  (play-and-wait 0 nind)
	  (voiced->unvoiced 1.0 256 2.0 2.0) 
	  (map-chan (fltit))
	  (close-sound oboe-index))
	(if (not (sound? nind)) (snd-display ";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 ";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-type)))
	    (snd-display ";new-sound default header-type: ~A ~A?"
			 (mus-header-type-name (header-type nind))
			 (mus-header-type-name (default-output-type))))
	(if (not (= (data-format nind) (default-output-format)))
	    (snd-display ";new-sound default data-format: ~A ~A?"
			 (mus-data-format-name (data-format nind))
			 (mus-data-format-name (default-output-format))))
	(if (not (= (chans nind) (default-output-chans)))
	    (snd-display ";new-sound default chans: ~A ~A?" (chans nind) (default-output-chans)))
	(if (not (= (srate nind) (default-output-srate)))
	    (snd-display ";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 "hiho" 0 1 nind)
	(if (fneq (sample 1000) -0.22299) (snd-display ";convolve-with: ~A?" (sample 1000)))
	(progress-report .3 "hiho" 0 1 nind)
	(revert-sound nind)
	(progress-report .5 "hiho" 0 1 nind)
	(set! (sample 200) .0001) 
	(set! (sample 100) 1.0) 
	(progress-report .8 "hiho" 0 1 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 ";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 ";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 ";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 "; new-sound initial-length: ~A" (frames nind)))
	(mix "pistol.snd") 
	(map-chan (expsrc 2.0 nind)) 
	;(play-and-wait 0 nind)
	(undo) 
	(let ((eds (edits)))
	  (if (or (not (= (car eds) 1)) (not (= (cadr eds) 1)))
	      (snd-display ";undo edits: ~A?" eds))
	  (if (not (= (edit-position) (car eds)))
	      (snd-display ";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) 
	;(play-and-wait 0)
	(let ((eds (edits)))
	  (if (or (not (= (car eds) 6)) (not (= (cadr eds) 0)))
	      (snd-display ";edits(6): ~A?" eds))
	  (if (not (= (edit-position) (car eds)))
	      (snd-display ";edit-position(6): ~A ~A?" (edit-position) eds)))
	(set! (edit-position) 1)
	(if (not (= (edit-position) 1))
	    (snd-display ";set edit-position(1): ~A?" (edit-position)))
	(set! (edit-position) 4)
	(if (not (= (edit-position) 4))
	    (snd-display ";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) 
	;(play-and-wait 0 nind)
	(revert-sound nind)
	(let ((mid (mix-sound "pistol.snd" 0)))
	  (if (and (mix? mid)
		   (not (equal? (mix-home mid) (list (selected-sound) 0))))
	      (snd-display ";mix-sound mix-home: ~A (~A or ~A 0)" (mix-home mid) (selected-sound) nind)))
	(hello-dentist 40.0 .1) 
	(fp 1.0 .3 20) 
	;(play-and-wait 0 nind)
	(revert-sound nind)
	(enveloped-mix "oboe.snd" 0 '(0 0 1 1 2 0)) 
	(pvoc :pitch 0.5 :time 1.0 :snd nind) 
	;(play-and-wait 0 nind)
	(revert-sound nind)
	(close-sound nind))
      
      (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 #:optional 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)
	    (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)
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 0 (1+ i))) ((= i 12)) 
		 (if (fneq (vct-ref v0 i) (+ 0.1 (* i .01))) 
		     (break (snd-display ";~D mus-mix(1->1): ~A?" k v0))))))
	    (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 ";~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 ";~D mus-mix(4->1): ~A?" k v0))
	    (let ((e0 (make-env '(0 0 1 1) :end 10))
		  (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 ";~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) :end 9))
	      (vector-set! vf2 1 (make-env '(0 0 1 1) :end 9))
	      (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 ";~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 ";~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 ";~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 ";~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 ";~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) :end 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) :end 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 ";~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 ";~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) :end len))
		(vector-set! egen1 1 (make-env :envelope '(0 0 1 1) :end 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 ";~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 ";~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 ";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 ";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-sample-reader 0)))
	(if (not (phase-vocoder? pv)) (snd-display ";~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! (phase-vocoder-outctr pv) 120) (phase-vocoder-outctr pv))))
	  (if (not (= val 120)) (snd-display ";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 ";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 ";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 ";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 ";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 ";set phase-vocoder-freqs: ~A?" (vct-ref (phase-vocoder-freqs pv) 0)))
	(undo 1)
	(free-sample-reader 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
					 (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 (inexact->exact (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-sample-reader 0))
	  (map-chan (lambda (val)
		      (phase-vocoder pv (lambda (dir) 
					  (next-sample reader))))))
	(undo 1)
	(free-sample-reader reader)
	(set! pv (make-phase-vocoder #f
				     512 4 (inexact->exact (* 128 2.0)) 1.0
				     #f ;no change to analysis
				     #f ;no change to edits
				     #f ;no change to synthesis
				     ))
	(set! reader (make-sample-reader 0))
	(let* ((len (inexact->exact (* 2.0 (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-sample-reader reader)
	
	(let ((incalls 0)
	      (outcalls 0))
	  (set! pv (make-phase-vocoder #f
				       512 4 (inexact->exact (* 128 2.0)) 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-sample-reader 0))
	  (let* ((len (inexact->exact (* 2.0 (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-sample-reader reader)
	  (if (or (= incalls 0)
		  (= outcalls 0))
	      (snd-display ";phase-vocoder incalls: ~A, outcalls: ~A" incalls outcalls))
	  (set! (phase-vocoder-outctr pv) (phase-vocoder-outctr 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 ";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 ";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 ";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 ";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 ";phase-vocoder equal? ~A ~A" geno genx))
	    (if (fneq (mus-frequency genx) 1.0) (snd-display ";mus-frequency phase-vocoder: ~A" (mus-frequency genx)))
	    (set! (mus-frequency genx) 2.0)
	    (if (fneq (mus-frequency genx) 2.0) (snd-display ";set mus-frequency phase-vocoder: ~A" (mus-frequency genx)))
	    (if (fneq (mus-increment genx) 128) (snd-display ";mus-increment phase-vocoder: ~A" (mus-increment genx)))
	    (set! (mus-increment genx) 256)
	    (if (fneq (mus-increment genx) 256) (snd-display ";set mus-increment phase-vocoder: ~A" (mus-increment genx)))
	    (if (not (= (mus-hop genx) 128)) (snd-display ";phase vocoder hop: ~A" (mus-hop genx)))
	    (set! (mus-hop genx) 64)
	    (if (not (= (mus-hop genx) 64)) (snd-display ";set phase vocoder hop: ~A" (mus-hop genx)))
	    (if (not (= (mus-length genx) 512)) (snd-display ";phase vocoder length: ~A" (mus-length genx)))
	    (let ((genxx genx))
	      (if (not (equal? genx genxx)) (snd-display ";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 (car gen)) (snd-display ";moog freq: ~A" (car gen)))
	  (if (fneq .1 (cadr gen)) (snd-display ";moog Q: ~A" (cadr gen)))
	  (if (not (vct? (list-ref gen 2))) (snd-display ";moog state: ~A" (list-ref gen 2)))
	  (if (fneq 0.0 (list-ref gen 3)) (snd-display ";moog A? ~A" (list-ref gen 3)))
	  (if (fneq -0.861 (list-ref gen 4)) (snd-display ";moog freqtable: ~A" (lisst-ref gen 4)))
	  (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 ";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: 40")
	(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 ";map ssb-am: ~A ~A" v0 v1))
	(if (not (ssb-am? gen)) (snd-display ";~A not ssb-am?" gen))
	(if (fneq (mus-phase gen) 1.253787) (snd-display ";ssb-am phase: ~F?" (mus-phase gen)))
	(if (fneq (mus-frequency gen) 440.0) (snd-display ";ssb-am frequency: ~F?" (mus-frequency gen)))
	(if (not (= (mus-order gen) 40)) (snd-display ";ssb-am order: ~F?" (mus-order gen)))
	(if (not (= (mus-cosines gen) 1)) (snd-display ";ssb-am cosines: ~D?" (mus-cosines gen)))
	(if (not (= (mus-length gen) 40)) (snd-display ";ssb-am length: ~D?" (mus-length gen)))
	(if (not (= (mus-interp-type gen) mus-interp-none)) (snd-display ";ssb-am interp type: ~D?" (mus-interp-type gen)))
	(if (fneq (mus-xcoeff gen 0) 0.0) (snd-display ";ssb-am xcoeff 0: ~A" (mus-xcoeff gen 0)))
	(if (fneq (mus-xcoeff gen 1) -.001) (snd-display ";ssb-am xcoeff 1: ~A" (mus-xcoeff gen 1)))
;	(if (not (vct? (mus-data gen))) (snd-display ";mus-data ssb-am: ~A" (mus-data gen)))
;	(if (not (vct? (mus-xcoeffs gen))) (snd-display ";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)))
	(call-with-current-continuation
	 (lambda (break)
	   (do ((i 0 (1+ i)))
	       ((= 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 ";ssb-am (up): ~A ~A at ~A" o1o o2o i)
		     (break))))))))
      
      (let ((o1 (make-ssb-am 400.0))
	    (o2 (make-ssb-am-1 400.0)))
	(call-with-current-continuation
	 (lambda (break)
	   (do ((i 0 (1+ i)))
	       ((= 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 ";ssb-am + fm (up): ~A ~A at ~A" o1o o2o i)
		     (break))))))))

      (let ((o1 (make-ssb-am -100.0))
	    (o2 (make-ssb-am-1 -100.0)))
	(call-with-current-continuation
	 (lambda (break)
	   (do ((i 0 (1+ i)))
	       ((= 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 ";ssb-am (down): ~A ~A at ~A" o1o o2o i)
		     (break))))))))
      
      (let ((o1 (make-ssb-am 1000.0 100))
	    (o2 (make-ssb-am-1 1000.0 100)))
	(call-with-current-continuation
	 (lambda (break)
	   (do ((i 0 (1+ i)))
	       ((= 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 ";ssb-am (down): ~A ~A at ~A" o1o o2o i)
		     (break))))))))
      
	(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 (fneq (maxamp) scl) 
		(snd-display ";convolve-with amps: ~A ~A" (maxamp) scl)
		(let ((preader (make-sample-reader 0 index 0 1 1))
		      (reader (make-sample-reader 0))
		      (len (frames)))
		  (call-with-current-continuation 
		   (lambda (break) 
		     (do ((i 0 (1+ i))) 
			 ((= i len))
		       (let ((val0 (preader))
			     (val1 (reader)))
			 (if (fneq val0 val1)
			     (begin
			       (snd-display ";convolve-with amps at: ~A: ~A ~A" i val0 val1)
			       (break))))))))))
	  (close-sound index)
	  (let ((reader (make-sample-reader 0 "pistol.snd")))
	    (do ((i 0 (1+ i)))
		((= i 10))
	      (if (fneq (vct-ref data i) (next-sample reader))
		  (snd-display ";external reader trouble")))
	    (free-sample-reader reader)))

      (let ((make-procs (list
			 make-all-pass make-asymmetric-fm make-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))) 
			 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-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines make-table-lookup make-triangle-wave
			 make-two-pole make-two-zero make-wave-train make-waveshape 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 average
			     comb convolve delay env 
			     filter fir-filter 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
			     sine-summation square-wave (lambda (gen a) (src gen 0.0 a)) sum-of-cosines sum-of-sines table-lookup triangle-wave
			     two-pole two-zero wave-train waveshape two-zero phase-vocoder ssb-am
			     filter filter))
	    (ques-procs (list all-pass? asymmetric-fm? average?
			      comb? convolve? delay? env? 
			      filter? fir-filter? formant? frame? granulate?
			      iir-filter? locsig? mixer? notch? one-pole? one-zero? oscil? two-pole?
			      pulse-train? rand? rand-interp? sawtooth-wave?
			      sine-summation? square-wave? src? sum-of-cosines? sum-of-sines? table-lookup? triangle-wave?
			      two-pole? two-zero? wave-train? waveshape? two-zero? phase-vocoder? ssb-am?
			      filter? filter?))
	    (func-names (list 'all-pass 'asymmetric-fm 'average
			      'comb 'convolve 'delay 'env 
			      'filter-x 'fir-filter 'formant 'frame 'granulate
			      'iir-filter 'locsig 'mixer 'notch 'one-pole 'one-zero 'oscil 'two-pole
			      'pulse-train 'rand 'rand-interp 'sawtooth-wave
			      'sine-summation 'square-wave 'src 'sum-of-cosines 'sum-of-sines 'table-lookup 'triangle-wave
			      'two-pole 'two-zero 'wave-train 'waveshape '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 (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 0.0 (lambda (dir) 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))
	    (generic-procs (list mus-a0 mus-a1 mus-a2 mus-b1 mus-b2 mus-channel mus-channels mus-cosines mus-data
				 mus-feedback mus-feedforward mus-formant-radius mus-frequency mus-hop mus-increment mus-length
				 mus-location mus-mix mus-order mus-phase mus-ramp mus-random mus-run mus-scaler mus-xcoeffs
				 mus-ycoeffs))
	    (generic-names (list 'mus-a0 'mus-a1 'mus-a2 'mus-b1 'mus-b2 'mus-channel 
				 'mus-channels 'mus-cosines 'mus-data
				 'mus-feedback 'mus-feedforward 'mus-formant-radius 'mus-frequency 'mus-hop 'mus-increment 'mus-length
				 'mus-location 'mus-mix 'mus-order 'mus-phase 'mus-ramp 'mus-random 'mus-run 'mus-scaler 'mus-xcoeffs
				 'mus-ycoeffs)))
	(for-each
	 (lambda (make run ques arg name)
	   (let ((gen (make)))
	     (if (not (ques gen)) (snd-display ";~A: ~A -> ~A?" name make gen))
	     (let ((tag (catch #t (lambda () (if arg (run gen arg) (run gen))) (lambda args args))))
	       (if (and (not (number? tag)) 
			(not (frame? tag)))
		   (snd-display ";~A: ~A ~A ~A: ~A" name run gen arg tag)))
	     (for-each
	      (lambda (func genname)
		(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 ";~A set ~A ~A ~A -> ~A" name genname gen tag tag1))))))
	      generic-procs generic-names)))
	 make-procs run-procs ques-procs gen-args func-names)

	(if all-args
	    (for-each
	     (lambda (make runp)
	       (let ((gen (make)))
		 (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 .95 .95 .95)  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
			   (lambda () #t) (current-module) (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)
			   12345678901234567890 (log 0) (nan))))
		  (list 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color .95 .95 .95)  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
			(lambda () #t) (current-module) (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)
			12345678901234567890 (log 0) (nan)))))
	     make-procs run-procs)))
      
      (run-hook after-test-hook 8)
      ))



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

(define (track-end id) (+ (track-position id) (track-frames id) -1))
(define-envelope xrmx '(0 0 1 1) 32.0)
(define-envelope xrmx1 '(0 0 1 1) 0.03)
(define-envelope xrmx2 '(0 0 1 1) 0.5)

(if (and with-gui (or full-test (= snd-test 9) (and keep-going (<= snd-test 9))))
    (begin
	  (run-hook before-test-hook 9)
      (do ((test-ctr 0 (1+ test-ctr)))
	  ((= test-ctr tests))
	(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 ";found non-existent mix? ~A" (find-mix 0 new-index 0)))
	  (let ((mix-id (mix "pistol.snd" 100)))
	    (if (not (mix? mix-id)) (snd-display ";~A not mix?" mix-id))
	    (view-mixes-dialog)
	    (let ((pos (mix-position mix-id))
		  (len (mix-frames mix-id))
		  (loc (mix-locked? mix-id))
		  (inv (mix-inverted? mix-id))
		  (anc (mix-tag-position mix-id))
		  (spd (mix-speed mix-id))
		  (trk (mix-track mix-id))
		  (snd (car (mix-home mix-id)))
		  (chn (cadr (mix-home mix-id)))
		  (chns (mix-chans mix-id))
		  (amp (mix-amp mix-id 0))
		  (mr (make-mix-sample-reader mix-id)))
	      (if (not (mix-sample-reader? mr)) (snd-display ";~A not mix-sample-reader?" mr))
	      (if (track-sample-reader? mr) (snd-display ";mix sample-reader: track ~A" mr))
	      (if (region-sample-reader? mr) (snd-display ";mix sample-reader: region ~A" mr))
	      (if (sample-reader? mr) (snd-display ";mix sample-reader: normal ~A" mr))
	      (if (not (= (sample-reader-position mr) 0)) (snd-display ";mix sample reader position: ~A" (sample-reader-position mr)))
	      (if (sample-reader-at-end? mr) (snd-display ";mix sample reader at end? ~A" mr))
	      (if (not (equal? (sample-reader-home mr) mix-id))
		  (snd-display ";~A home: ~A" mr (sample-reader-home mr)))
	      (let ((reader-string (format #f "~A" mr)))
		(if (not (string=? (substring reader-string 0 22) "#<mix-sample-reader mi"))
		    (snd-display ";mix sample reader actually got: [~S]" (substring reader-string 0 22))))
	      (let ((var (catch #t (lambda () (mix-amp mix-id 1234)) (lambda args args))))
		(if (not (eq? (car var) 'no-such-channel))
		    (snd-display ";mix-amp bad chan: ~A" var)))
	      (let ((var (catch #t (lambda () (set! (mix-amp mix-id 1234) .1)) (lambda args args))))
		(if (not (eq? (car var) 'no-such-channel))
		    (snd-display ";set mix-amp bad chan: ~A" var)))
	      (let ((var (catch #t (lambda () (set! (mix-amp-env mix-id 1234) '(0 0 1 1))) (lambda args args))))
		(if (not (eq? (car var) 'no-such-channel))
		    (snd-display ";set mix-amp-env bad chan: ~A" var)))
	      (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 ";read-mix-sample: ~A ~A?" mx sx))))
	      (let ((mx (mr))
		    (sx (sample 199)))
		(if (fneq mx sx) (snd-display ";mix-sample 100: ~A ~A?" mx sx)))
	      (free-sample-reader mr)
	      (if (not (= pos 100)) (snd-display ";mix-position: ~A?" pos))
	      (if (not (= len 41623)) (snd-display ";mix-frames: ~A?" len))
	      (if loc (snd-display ";mix-locked?: ~A?" loc))
	      (if inv (snd-display ";mix-inverted?: ~A?" inv))
	      (if (not (= anc 0)) (snd-display ";mix-tag-position: ~A?" anc))
	      (if (not (= trk 0)) (snd-display ";mix-track: ~A?" trk))
	      (if (not (= snd new-index)) (snd-display ";s mix-home: ~A?" snd))		
	      (if (not (= chn 0)) (snd-display ";c mix-home: ~A?" chn))
	      (if (not (= chns 1)) (snd-display ";mix-chans: ~A?" chn))
	      (if (fneq amp 1.0) (snd-display ";mix-amp: ~A?" amp))
	      (if (fneq spd 1.0) (snd-display ";mix-speed: ~A?" spd))
	      (catch 'mus-error
		     (lambda () (play-mix mix-id))
		     (lambda args (snd-display ";can't play mix")))
	      (let ((tag (catch #t
				(lambda () (set! (mix-track mix-id) -1))
				(lambda args (car args)))))
		(if (not (eq? tag 'out-of-range)) (snd-display ";set mix-track -1: ~A (~A)" tag (mix-track mix-id))))
	      (set! (mix-position mix-id) 200) 
	      (set! (mix-amp mix-id 0) 0.5) 
	      (set! (mix-speed mix-id) 2.0) 
	      (let ((trk (make-track mix-id)))
		(let ((tag (catch #t
				  (lambda () (play-track 1231233))
				  (lambda args (car args)))))
		  (if (not (eq? tag 'no-such-track)) (snd-display ";play-track bad track: ~A" tag)))
		(let ((tag (catch #t
				  (lambda () (play-track 1231233 #t))
				  (lambda args (car args)))))
		  (if (not (eq? tag 'no-such-track)) (snd-display ";play-track bad track #t: ~A" tag)))
		(let ((tag (catch #t
				  (lambda () (play-track 1231233 0))
				  (lambda args (car args)))))
		  (if (not (eq? tag 'no-such-track)) (snd-display ";play-track bad track index: ~A" tag)))
		(play-track trk))
	      (set! (mix-tag-position mix-id) 30) 
	      (set! (mix-amp-env mix-id 0) '(0.0 0.0 1.0 1.0)) 
	      (let ((val (mix-amp-env mix-id 0)))
		(set! (mix-amp-env mix-id 0) (mix-amp-env mix-id 0))
		(if (not (feql (mix-amp-env mix-id 0) val)) 
		    (snd-display ";set mix-amp-env to self: ~A ~A" val (mix-amp-env mix-id 0))))
	      (set! (mix-tag-y mix-id) 20) 
	      (let ((pos (mix-position mix-id))
		    (spd (mix-speed mix-id))
		    (trk (mix-track mix-id))
		    (amp (mix-amp mix-id 0))
		    (my (mix-tag-y mix-id))
		    (anc (mix-tag-position mix-id)))
		(if (not (= pos 200)) (snd-display ";set-mix-position: ~A?" pos))
		(if (not (= my 20)) (snd-display ";set-mix-tag-y: ~A?" my))
		(if (not (track? trk)) (snd-display ";set-mix-track: ~A?" trk))
		(if (fneq amp 0.5) (snd-display ";set-mix-amp: ~A?" amp))
		(if (fneq spd 2.0) (snd-display ";set-mix-speed: ~A?" spd))
		(if (not (= anc 30)) (snd-display ";set-mix-tag-position: ~A?" anc))
		(if (not (equal? (mix-amp-env mix-id 0) '(0.0 0.0 1.0 1.0))) (snd-display ";set-mix-amp-env: ~A?" (mix-amp-env mix-id 0))))
	      ))
	  (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 ";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 ";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 ";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 ";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 ";find-mix(200): ~A ~A?" nid (and (mix? nid) (mix-position nid)))))
	  (let ((mix-id (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 ";mix-property: ~A" (mix-property mix-id)))
	    (if (mix-property :not-there mix-id) (snd-display ";mix-not-property: ~A" (mix-property :not-there mix-id)))
	    (update-time-graph)
	    (set! (mix-waveform-height) 20))
	  ;; now track tests (mix.scm)
	  (revert-sound new-index)
	  (let ((mix-ids (make-vector 6))
		(trk (make-track)))
	    (do ((i 0 (1+ i)))
		((= i 6))
	      (vector-set! mix-ids i (mix "oboe.snd" (* i 1000))))
	    (set! (mix-track (vector-ref mix-ids 0)) trk)
	    (set! (mix-track (vector-ref mix-ids 2)) trk)
	    (set! (mix-track (vector-ref mix-ids 4)) trk)
	    (if (not (= (track-position trk) 0)) (snd-display ";track-position: ~D?" (track-position trk)))
	    (let* ((mr (make-track-sample-reader trk))
		   (reader-string (format #f "~A" mr)))
	      (if (not (string=? (substring reader-string 0 24) "#<track-sample-reader tr"))
		  (snd-display ";track sample reader actually got: [~S]" (substring reader-string 0 24)))
	      (if (not (= (sample-reader-position mr) 0)) (snd-display ";track sample reader position: ~A" (sample-reader-position mr)))
	      (if (sample-reader-at-end? mr) (snd-display ";track sample reader at end? ~A" mr))
	      (if (not (equal? (sample-reader-home mr) (list trk 0))) 
		  (snd-display ";track ~A home: ~A" mr (sample-reader-home mr)))
	      (if (mix-sample-reader? mr) (snd-display ";track sample-reader: mix ~A" mr))
	      (if (region-sample-reader? mr) (snd-display ";track sample-reader: region ~A" mr))
	      (if (sample-reader? mr) (snd-display ";track sample-reader: normal ~A" mr))
	      (free-sample-reader mr))
	    (let ((curend (track-end trk))
		  (curframes (track-frames trk))
		  (curmixpos (map mix-position (track trk)))
		  (curmixframes (map mix-frames (track trk))))
	      (set! (track-position trk) 500)
	      (if (not (= (track-position trk) 500)) (snd-display ";set track-position: ~D?" (track-position trk)))
	      (if (not (= (mix-position (vector-ref mix-ids 0)) 500)) (snd-display ";track-position ~D = ~D?" 0 (mix-position (vector-ref mix-ids 0))))
	      (if (not (= (mix-position (vector-ref mix-ids 1)) 1000)) (snd-display ";track-position ~D = ~D?" 1 (mix-position (vector-ref mix-ids 1))))
	      (if (not (= (mix-position (vector-ref mix-ids 4)) 4500)) (snd-display ";track-position ~D = ~D?" 4 (mix-position (vector-ref mix-ids 4))))
	      (if (not (< (abs (- (track-end trk) (+ curend 500))) 2))
		  (snd-display ";track-end: ~D (cur+500: ~D, ~D, ~D + ~D -> ~D, ~A ~A ~A ~A ~A)?" 
			       (track-end trk) (+ curend 500) curframes
			       (track-position trk) (track-frames trk)
			       (+ (track-position trk) (track-frames trk) -1)
			       (track trk) (map mix-frames (track trk)) (map mix-position (track trk))
			       curmixpos curmixframes)))
	    (set! (track-amp trk) .5)
	    (if (fneq (track-amp trk) .5) (snd-display ";set track-amp ~F?" (track-amp trk)))
	    (set! (track-amp trk) (+ (track-amp trk) .25))
	    (if (fneq (track-amp trk) .75) (snd-display ";incf track-amp ~F?" (track-amp trk)))
	    (transpose-track trk 12)
	    (if (fneq (track-speed trk) 2.0)
		(snd-display ";transpose-track: ~F?" (track-speed trk)))
	    (retempo-track trk 2.0)
	    (if (not (= (track-frames trk) (/ (+ 4000 50828) 2)))
		(snd-display ";track-tempo: ~D (~D, ~A ~A)?" 
			     (track-frames trk) (/ (+ 4000 50828) 2)
			     (track trk) (map mix-frames (track trk))))
	    (catch 'no-such-color
		   (lambda () (set! (track-color trk) (make-color .8 .8 .8)))
		   (lambda args args))
	    (let ((trk2 (make-track)))
	      (set! (mix-track (vector-ref mix-ids 1)) trk2)
	      (set! (mix-track (vector-ref mix-ids 3)) trk2)
	      (catch 'no-such-color 
		     (lambda () (set! (track-color trk2) (make-color .2 .8 0)))
		     (lambda args args))
	      (let ((t2 (track->vct trk2))
		    (t3 (mix->vct (vector-ref mix-ids 5))))
		(if (or (fneq (vct-ref t2 1000) (vct-ref t3 1000))
			(fneq (vct-ref t3 1000) 0.0328369))
		    (snd-display ";track->vct: ~F, mix->vct: ~F (.0328369)?" (vct-ref t2 1000) (vct-ref t3 1000))))
	      (set! (track-amp-env trk) '(0 0 1 1))
	      (play-and-wait)))
	  (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 ";envelope-interp(1): ~F (0.5)?" v1))
	    (if (fneq v2 1.0) (snd-display ";envelope-interp(2): ~F (1.0)?" v2))
	    (if (fneq v3 1.0) (snd-display ";envelope-interp(3): ~F (1.0)?" v3))
	    (if (fneq v4 0.5) (snd-display ";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 ";envelope-interp(1a): ~A" v1))
	    (if (fneq v2 0.5) (snd-display ";envelope-interp(2a): ~A" v2))
	    (if (fneq v3 0.0) (snd-display ";envelope-interp(3a): ~A" v3))
	    (if (fneq v4 -0.5) (snd-display ";envelope-interp(4a): ~A" v4))
	    (if (fneq v5 -1.0) (snd-display ";envelope-interp(5a): ~A" v5))
	    (if (fneq v6 1.0) (snd-display ";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 ";multiply-envelopes: ~A?" v1))
	    (if (not (feql v2 (list 1.0 0.2 3.0 0.6))) (snd-display ";window-envelope: ~A?" v2)))
	  (close-sound new-index))
	)
      (dismiss-all-dialogs)
      
      (let ((ind (new-sound "new.snd"))
	    (mxs (make-vector 10))
	    (trk33 (make-track)))
	(call-with-current-continuation
	 (lambda (quit)
	   (do ((i 0 (1+ i)))
	       ((= i 10))
	     (let ((v (make-vct 1)))
	       (vct-set! v 0 (* i .05))
	       (vector-set! mxs i (mix-vct v i ind 0))
	       (if (not (mix? (vector-ref mxs i)))
		   (quit (snd-display ";mix-vct at ~A failed? " i))
		   (set! (mix-track (vector-ref mxs i)) trk33))))
	   (let ((tr (make-track-sample-reader trk33))
		 (tr1 (make-track-sample-reader trk33 #t 5)))
	     (do ((i 0 (1+ i)))
		 ((= i 10))
	       (let ((val (if (odd? i) (read-track-sample tr) (read-track-sample tr))))
		 (if (fneq val (* i .05))
		     (begin
		       (close-sound ind)
		       (quit (snd-display ";read track at ~A: ~A?" i val))))))
	     (let ((val (read-track-sample tr1)))
	       (if (fneq val (* .05 5))
		   (snd-display ";track-sample-reader with beg: ~A ~A ~A" val (* 5 .05) tr1)))
	     (free-sample-reader tr)
	     (free-sample-reader tr1)
	     (save-sound ind)
	     (if (not (mix? (vector-ref mxs 0)))
		 (snd-display ";saved mixes not re-activated?"))
	     (close-sound ind)))))
      
      (let* ((ind (open-sound "oboe.snd"))
	     (open-readers (make-vector 100 #f))
	     (mix1 (mix-vct (vct 0.1 0.2 0.3) 120 ind 0 #t "origin!"))
	     (mix2 (mix-vct (vct 0.1 0.2 0.3) 1200 ind 0 #t))
	     (mix3 (mix-vct (vct 0.1 0.2 0.3) 12000 ind 0 #t))
	     (trk123 (make-track))
	     (reg1 (make-region 200 300 ind 0)))
	(set! (mix-track mix1) trk123)
	(set! (mix-track mix2) trk123)
	(set! (mix-track mix3) trk123)
	(do ((i 0 (1+ i)))
	    ((= i sample-reader-tests))
	  (let* ((cur (random 4))
		 (r (random 100)))
	    (if (= cur 0)
		(begin
		  (vector-set! open-readers r (make-sample-reader (random 30000) ind 0))
		  (if (not (sample-reader? (vector-ref open-readers r))) (snd-display ";sample-reader? ~A?" (vector-ref open-readers r)))
		  (next-sample (vector-ref open-readers r))
		  (if (not (equal? (list ind 0) (sample-reader-home (vector-ref open-readers r))))
		      (snd-display ";sample-reader-home ~A?" (sample-reader-home (vector-ref open-readers r)))))
		(if (= cur 1)
		    (begin
		      (vector-set! open-readers r (make-region-sample-reader (random 90) reg1))
		      (if (not (region-sample-reader? (vector-ref open-readers r))) (snd-display ";region-sample-reader? ~A?" (vector-ref open-readers r)))
		      (next-sample (vector-ref open-readers r)))
		    (if (= cur 2)
			(begin
			  (vector-set! open-readers r (make-mix-sample-reader mix1))
			  (if (not (mix-sample-reader? (vector-ref open-readers r))) (snd-display ";mix-sample-reader? ~A?" (vector-ref open-readers r)))
			  (let ((val (read-mix-sample (vector-ref open-readers r))))
			    (if (fneq val 0.1) (snd-display ";read-mix-sample: ~A" val))))
			(begin
			  (vector-set! open-readers r (make-track-sample-reader trk123))
			  (if (not (track-sample-reader? (vector-ref open-readers r))) (snd-display ";track-sample-reader? ~A?" (vector-ref open-readers r)))
			  (let ((val (read-track-sample (vector-ref open-readers r))))
			    (if (fneq val 0.1) (snd-display ";read-track-sample: ~A" val)))))))
	    (if (> (random 1.0) .25)
		(let ((rr (random 100)))
		  (if (vector-ref open-readers rr)
		      (if (sample-reader? (vector-ref open-readers rr)) (free-sample-reader (vector-ref open-readers rr))
			  (if (mix-sample-reader? (vector-ref open-readers rr)) (free-sample-reader (vector-ref open-readers rr))
			      (if (track-sample-reader? (vector-ref open-readers rr)) (free-sample-reader (vector-ref open-readers rr))))))
		  (vector-set! open-readers rr #f)))))
	(do ((i 0 (1+ i)))
	    ((= i 100))
	  (vector-set! open-readers i #f))
	(close-sound ind)
	(gc))
      
      (let ((id (open-sound "oboe.snd")))
	(make-selection 1000 2000 id 0)
	(let ((mix-id (mix-selection 3000 id 0)))
	  (set! (mix-amp mix-id 0) .5)
	  (if (fneq (mix-amp mix-id 0) .5)
	      (snd-display ";mix-amp .5: ~A" (mix-amp mix-id 0)))
	  (scale-by .5)
	  (if (not (mix-locked? mix-id))
	      (snd-display ";mix not locked? ~A" mix-id))
	  (let ((var (catch #t (lambda () (set! (mix-amp mix-id 0) 1.0)) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-mix))
		(snd-display ";set locked mix amp: ~A" var)))
	  (let ((var (catch #t (lambda () (set! (mix-position mix-id) 10)) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-mix))
		(snd-display ";set locked mix position: ~A" var)))
	  (let ((var (catch #t (lambda () (set! (mix-speed mix-id) 1.5)) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-mix))
		(snd-display ";set locked mix speed: ~A" var)))
	  (let ((var (catch #t (lambda () (set! (mix-amp-env mix-id 0) '(0 0 1 1))) (lambda args args))))
	    (if (not (eq? (car var) 'no-such-mix))
		(snd-display ";set locked mix amp env: ~A" var)))
	  (undo)
	  (if (mix-locked? mix-id)
	      (snd-display ";undo locked mix: ~A" mix-id)
	      (begin
		(set! (mix-position mix-id) 10)
		(if (not (= (mix-position mix-id) 10))
		    (snd-display ";mix-position 10: ~A" (mix-position mix-id)))))
	  (close-sound id)))
      (set! (print-length) 30)
      (let ((index (new-sound "test.snd"))
	    (v1 (make-vct 1))
	    (v2 (make-vct 2))
	    (v3 (make-vct 3)))
	(vct-fill! v1 .1)
	(vct-fill! v2 .2)
	(vct-fill! v3 .3)
	(let ((id1 (map (lambda (start)
			  (mix-vct v1 start))
			(list 0 10 20)))
	      (id2 (map (lambda (start)
			  (mix-vct v2 start))
			(list 1 12 23)))
	      (id3 (map (lambda (start)
			  (mix-vct v3 start))
			(list 2 14 26)))
	      (trk1 (make-track)))
	  (if (not (vequal (channel->vct)
			   (vct .1 .2 .5 .3 .3  0 0  0 0 0  
				.1 0  .2 .2 .3 .3 .3 0 0 0
				.1 0  0  .2 .2  0 .3 .3 .3)))
	      (snd-display ";mix tests off to a bad start: ~A" (channel->vct)))
	  (if (not (vequal (mix->vct (car id2)) (vct .2 .2)))
	      (snd-display ";mix->vct of .2: ~A" (mix->vct (car id2))))
	  (set! (mix-track (car id1)) trk1)
	  (let ((tr1 trk1))
	    (if (not (equal? (track tr1) (list (car id1))))
		(snd-display ";1 track->~A ~A" (track tr1) (list (car id1))))
	    (if (not (= (track-position tr1) (mix-position (car id1))))
		(snd-display ";1 track-position ~A ~A (~A)" tr1 (track-position tr1) (mix-position (car id1))))
	    (if (not (= (track-frames tr1) (mix-frames (car id1))))
		(snd-display ";1 track-frames ~A frames: ~A (mix frames: ~A)" (track tr1) (track-frames tr1) (mix-frames (car id1))))
	    (if (not (= (track-end tr1) (+ (mix-position (car id1)) (mix-frames (car id1)) -1)))
		(snd-display ";1 track-end ~A ~A ~A" (track-end tr1) (mix-position (car id1)) (mix-frames (car id1))))
	    (if (fneq (track-amp tr1) (mix-amp (car id1) 0))
		(snd-display ";1 track-amp: ~A ~A" (track-amp tr1) (mix-amp (car id1) 0)))
	    (if (fneq (track-speed tr1) (mix-speed (car id1)))
		(snd-display ";1 track-speed: ~A ~A" (track-speed tr1) (mix-speed (car id1))))
	    (if (not (vequal (track->vct tr1) (mix->vct (car id1))))
		(snd-display ";1 track->vct ~A ~A" (track->vct tr1) (mix->vct (car id1))))
	    (set! (track-amp tr1) 0.0)
	    (if (not (vequal (channel->vct)
			     (vct 0 .2 .5 .3 .3  0 0  0 0 0  
				  .1 0  .2 .2 .3 .3 .3 0 0 0
				  .1 0  0  .2 .2  0 .3 .3 .3)))
		(snd-display ";first mix deleted: ~A" (channel->vct)))
	    (undo)
	    (if (fneq (mix-amp (car id1) 0) 1.0)
		(snd-display ";1 undo delete-track amp: ~A" (mix-amp (car id1) 0)))
	    (set! (track-amp tr1) 2.0)
	    (if (not (vequal (channel->vct)
			     (vct .2 .2 .5 .3 .3  0 0  0 0 0  
				  .1 0  .2 .2 .3 .3 .3 0 0 0
				  .1 0  0  .2 .2  0 .3 .3 .3)))
		(snd-display ";1 set track-amp: ~A" (channel->vct)))
	    (set! (track-position tr1) 8)
	    (if (not (= (track-position tr1) 8))
		(snd-display ";moved track 1: ~A" (track-position tr1)))
	    (if (not (vequal (channel->vct)
			     (vct 0 .2 .5 .3 .3  0 0  0 .2 0  
				  .1 0  .2 .2 .3 .3 .3 0 0 0
				  .1 0  0  .2 .2  0 .3 .3 .3)))
		(snd-display ";1 set track-position 8: ~A" (channel->vct)))
	    (reverse-track tr1)
	    (if (not (vequal (channel->vct)
			     (vct 0 .2 .5 .3 .3  0 0  0 .2 0  
				  .1 0  .2 .2 .3 .3 .3 0 0 0
				  .1 0  0  .2 .2  0 .3 .3 .3)))
		(snd-display ";1 reverse track: ~A" (channel->vct)))
	    
	    (let* ((trk2 (make-track (cadr id1) (cadr id2) (cadr id3)))
		   (tr2 trk2))
	      (if (not (= (track-position tr2) (mix-position (cadr id1))))
		  (snd-display ";2 track-position ~A ~A (~A)" tr2 (track-position tr2) (mix-position (cadr id1))))
	      (set! (track-amp tr2) 2.0)
	      (if (not (vequal (channel->vct)
			       (vct 0 .2 .5 .3 .3  0 0  0 .2 0  
				    .2 0  .4 .4 .6 .6 .6 0 0 0
				    .1 0  0  .2 .2  0 .3 .3 .3)))
		  (snd-display ";2 set track-amp: ~A" (channel->vct)))
	      (set! (track-position tr2) (- (track-position tr2) 1))
	      (revert-sound index)
	      
	      (set! id1 (map (lambda (start)
			       (mix-vct v1 start))
			     (list 0 10 20)))
	      (set! id2 (map (lambda (start)
			       (mix-vct v2 start))
			     (list 1 12 23)))
	      (set! id3 (map (lambda (start)
			       (mix-vct v3 start))
			     (list 2 14 26)))
	      (if (not (vequal (channel->vct)
			       (vct .1 .2 .5 .3 .3  0 0  0 0 0  
				    .1 0  .2 .2 .3 .3 .3 0 0 0
				    .1 0  0  .2 .2  0 .3 .3 .3)))
		  (snd-display ";mix tests 2nd start: ~A" (channel->vct)))
	      (set! tr1 (apply make-track id1))
	      (set! tr2 (apply make-track id3))
	      (let ((old-pos (map mix-position (track tr1))))
		(if (not (equal? old-pos (map mix-position id1)))
		    (snd-display ";old-pos: ~A ~A" old-pos (map mix-position id1)))
		(retempo-track tr1 2) ; tempo > 1 is faster
		(if (not (vequal (channel->vct)
				 (vct .1 .2 .5 .3 .3  .1 0  0 0 0  
				      .1 0  .2 .2 .3 .3 .3 0 0 0
				      0 0  0  .2 .2  0 .3 .3 .3)))
		    (snd-display ";3 track-tempo .5: ~A -> ~A, ~A" old-pos (map mix-position (track tr1)) (channel->vct))))
	      (set! (track-amp tr1) 0.0)
	      (if (not (vequal (channel->vct)
			       (vct 0 .2 .5 .3 .3  0 0  0 0 0  
				    0 0  .2 .2 .3 .3 .3 0 0 0
				    0 0  0  .2 .2  0 .3 .3 .3)))
		  (snd-display ";3 track-amp 0: ~A" (channel->vct)))
	      (delete-all-mixes)
	      ))
	  (close-sound index)
	  ))
      
      (let* ((ind (open-sound "2.snd"))
	     (md (mix "1a.snd" 1000 0 ind 1 #t)))
	(if (fneq (maxamp ind 1) .1665) (snd-display ";maxamp after mix into chan 2: ~A" (maxamp ind 1)))
	(set! (mix-amp md 0) 0.0)
	(if (or (not (equal? (edits ind 0) (list 0 0)))
		(not (equal? (edits ind 1) (list 2 0))))
	    (snd-display ";mix into chan2 zeroed: ~A ~A" (edits ind 0) (edits ind 1)))
	(if (fneq (maxamp ind 1) .066) (snd-display ";maxamp after mix zeroed into chan 2: ~A" (maxamp ind 1)))
	(set! (mix-amp md 0) 0.5)
	(if (fneq (maxamp ind 1) .116) (snd-display ";maxamp after mix 0.5 into chan 2: ~A" (maxamp ind 1)))
	(set! (mix-speed md) 2.0)
	(if (fneq (/ (mix-frames md) (mus-sound-frames "1a.snd")) 0.5)
	    (snd-display ";mix srate chan 2: ~A ~A" (mix-frames md) (mus-sound-frames "1a.snd")))
	(update-time-graph)
	(set! (mix-speed md) 0.5)
	(update-time-graph)
	(set! (mix-amp md 0) 1.0)
	(if (fneq (maxamp ind 1) .166) (snd-display ";non-sync mix-speed: ~A" (maxamp ind 1)))
	(set! (mix-amp-env md 0) '(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")) ; 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 ";mix twice syncd: 0: ~A -> ~A, m1: ~A -> ~A, len: ~A -> ~A"
			   m0 (maxamp ind 0) m1 (maxamp ind 1) len (frames ind 0)))
	  (if (and (provided? 'snd-motif)
		   (provided? 'xm))
	      (begin
		(let ((wid (view-mixes-dialog)))
		  (if (not (equal? wid (list-ref (dialog-widgets) 16)))
		      (snd-display ";view-mixes-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 16))))
		(let* ((mixd (list-ref (dialog-widgets) 16))
		       (spdscr (find-child mixd "mix-speed"))
		       (dragged #f))
		  (add-hook! mix-drag-hook (lambda (n) (set! dragged n)))
		  (XtCallCallbacks spdscr XmNvalueChangedCallback
				   (let ((cb (XmScrollBarCallbackStruct)))
				     (set! (.value cb) 650)
				     (set! (.event cb) (XEvent))
				     cb))
		  (let* ((xy (mix-tag-xy md))
			 (cwid (car (channel-widgets ind 0)))
			 (x (+ (car xy) 1))
			 (y (- (cadr xy) 2))
			 (pos (mix-position md)))
		    (focus-widget cwid)
		    (drag-event cwid 1 0 x y (+ x 50) y) (force-event)
		    (XtUnmanageChild mixd)
		    (reset-hook! mix-drag-hook)
		    ))))
	  (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 (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 ";mix 1->1: ~A ~A" samps v)))
	  (if (not (mix? tag)) (snd-display ";mix 1->1 tag: ~A" tag))
	  (undo))
	(let ((tag (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 ";mix 1->1 at 5: ~A ~A" samps v)))
	  (if (not (mix? tag)) (snd-display ";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 ";mix 1->1 at 0 #f: ~A ~A" samps v)))
	  (if (mix? tag) (snd-display ";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 (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 ";mix 2->1: ~A ~A" samps v)))
	  (if (not (mix? tag)) (snd-display ";mix 2->1 tag: ~A" tag))
	  (undo))
	(let ((tag (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 ";mix 2->1 at 5: ~A ~A" samps v)))
	  (if (not (mix? tag)) (snd-display ";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 (mix "test.snd")))
	  (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) ; new version of mix auto-syncs in this case
	    (vct-set! v 5 .125)
	    (if (not (vequal samps1 v))
		(snd-display ";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 ";mix 1->1 (3): ~A ~A" samps0 v)))
	  (if (not (mix? tag)) (snd-display ";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 ";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 ";mix 1->1 (5): ~A ~A" samps1 v)))
	  (if (mix? tag) (snd-display ";mix 1->1 tag (5): ~A" tag))
	  (undo 1 ind 1))
	(set! (sync ind) 1)
	(let ((tag (mix "test.snd")))
	  (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 ";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 ";mix 1->1 (7): ~A ~A" samps1 v)))
	  (undo))
	(set! (cursor ind) 5)
	(let ((tag (mix "test.snd")))
	  (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 ";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 ";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 ";mix-position m1[0]: ~A" (mix-position m1)))
	(if (not (= (mix-position m2) 123)) (snd-display ";mix-position m2[0]: ~A" (mix-position m2)))
	(undo)
	(set! (mix-position m2) 500)
	(if (not (= (mix-position m2) 500)) (snd-display ";mix-position m2[1]: ~A" (mix-position m2)))
	(if (not (= (mix-position m1) 321)) (snd-display ";mix-position m1[1]: ~A" (mix-position m1)))
	(undo)
	(insert-silence 0 100)
	(if (not (= (mix-position m1) (+ 100 321))) (snd-display ";mix-position m1[2]: ~A" (mix-position m1)))
	(if (not (= (mix-position m2) (+ 100 123))) (snd-display ";mix-position m2[2]: ~A" (mix-position m2)))
	(delete-samples 0 50)
	(if (not (= (mix-position m1) (+ 50 321))) (snd-display ";mix-position m1[3]: ~A" (mix-position m1)))
	(if (not (= (mix-position m2) (+ 50 123))) (snd-display ";mix-position m2[3]: ~A" (mix-position m2)))
	(undo 2)
	(let ((ntrack (make-track)))
	  (set! (mix-track m1) ntrack)
	  (set! (mix-track m2) ntrack)
	  (reverse-track ntrack)
	  (if (not (= (mix-position m1) 123)) (snd-display ";mix-position m1[4]: ~A" (mix-position m1)))
	  (if (not (= (mix-position m2) 321)) (snd-display ";mix-position m1[4]: ~A" (mix-position m2))))
	(undo)
	(set! (mix-position m2) 500)
	(undo)
	(scale-channel 0.5 1000 100)
	(if (not (= (mix-position m2) 123)) (snd-display ";mix-position m2[5]: ~A" (mix-position m2)))
	(if (not (= (mix-position m1) 321)) (snd-display ";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 ";mix-position m2[6]: ~A" (mix-position m2)))
	(if (not (= (mix-position m1) 321)) (snd-display ";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 ";mix-position m2[7]: ~A" (mix-position m2)))
		 (if (not (= (mix-position m1) 321)) (snd-display ";mix-position m1[7]: ~A" (mix-position m1))))
	       (lambda args (snd-display ";mix-position trouble: ~A" args)))
	(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 (mix-selection 900000))
	      (m2 (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 ";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 ";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 ";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 ";stereo selection: ~A" (selection-chans)))
	(set! (sync ind) #t)
	(let ((md (mix-selection 500 ind)))
	  (if (not (= (mix-chans md) 2))
	      (snd-display ";mix-chans of stereo selection: ~A" (mix-chans md)))
	  (if (not (mix? (1+ md)))
	      (snd-display ";where is 2nd mix? ~A ~A" md (mixes)))
	  (if (not (= (edit-position ind 0) 1))
	      (snd-display ";edit-position 0 after stereo mix selection: ~A" (edit-position ind 0)))
	  (if (not (= (edit-position ind 1) 1))
	      (snd-display ";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 (1+ md)) 750)
	  (if (not (= (edit-position ind 1) 2))
	      (snd-display ";edit-position 1 after stereo mix selection moved: ~A" (edit-position ind 2)))
	  (revert-sound ind)
	  (delete-sample 25 ind 1)
	  (if (or (mix? md) (mix? (1+ md)))
	      (snd-display ";undo mix stereo sel: ~A ~A" (mix? md) (mix? (1+ md))))
	  (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-sample-reader mx))
		(ho (make-mix-sample-reader mx 5)))
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 0 (1+ i)))
		   ((= i 10))
		 (let ((ho-val (ho))
		       (hi-val (hi)))
		   (if (fneq hi-val (* i -.01))
		       (begin
			 (snd-display ";mix-reader at ~A from 0: ~A" i hi-val)
			 (break)))
		   (if (fneq ho-val (* (+ i 5) -.01))
		       (begin
			 (snd-display ";mix-reader at ~A from 5: ~A" i ho-val)
			 (break)))))))))
	(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 0 1 1))
	  (let ((hi (make-mix-sample-reader mx 0))
		(ho (make-mix-sample-reader mx 10)))
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 0 (1+ i)))
		   ((= i 10))
		 (let ((ho-val (ho))
		       (hi-val (hi)))
		   (if (fneq hi-val (* i .025))
		       (begin
			 (snd-display ";mix-reader env'd at ~A from 0: ~A" i hi-val)
			 (break)))
		   (if (fneq ho-val (* (+ i 10) .025))
		       (begin
			 (snd-display ";mix-reader env'd at ~A from 10: ~A" i ho-val)
			 (break)))))))))
	(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 ";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 ";mix-position 2 (no-op): ~A ~A" (mix-position id) (edit-position ind 0)))
	(set! (mix-amp id 0) 1.0)
	(if (or (fneq (mix-amp id 0) 1.0)
		(not (= (edit-position ind 0) 2)))
	    (snd-display ";mix-amp no-op: ~A ~A" (mix-amp id 0) (edit-position ind 0)))
	(set! (mix-amp id) 0.5)
	(if (or (fneq (mix-amp id 0) 0.5)
		(not (= (edit-position ind 0) 3)))
	    (snd-display ";mix-amp .5: ~A ~A" (mix-amp id 0) (edit-position ind 0)))
	(set! (mix-amp id 0) (mix-amp id 0))
	(if (or (fneq (mix-amp id 0) 0.5)
		(not (= (edit-position ind 0) 3)))
	    (snd-display ";mix-amp no-op: ~A ~A" (mix-amp id 0) (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 ";mix-speed no-op: ~A ~A" (mix-speed id 0) (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 ";mix-speed .5: ~A ~A" (mix-speed id 0) (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 ";mix-speed 2 no-op: ~A ~A" (mix-speed id 0) (edit-position ind 0)))
	(set! (mix-amp-env id 0) '(0 0 1 1))
	(if (not (= (edit-position ind 0) 5))
	    (snd-display ";mix-amp-env init: ~A ~A" (mix-amp-env id 0) (edit-position ind 0)))
	(set! (mix-amp-env id 0) '(0 0 1 1))
	(if (not (= (edit-position ind 0) 5))
	    (snd-display ";mix-amp-env no-op: ~A ~A" (mix-amp-env id 0) (edit-position ind 0)))
	(close-sound ind))

      (letrec ((test-mix-disconnect
		(lambda (name id0 chn0 id1 chn1)
		  (let ((amp0 (mix-amp id0 chn0))
			(amp1 (mix-amp id1 chn1))
			(env0 (mix-amp-env id0 chn0))
			(env1 (mix-amp-env id1 chn1)))
		    (set! (mix-amp id0 chn0) (* (mix-amp id0 chn0) .5))
		    (if (or (fneq (mix-amp id0 chn0) (* .5 amp0))
			    (fneq (mix-amp id1 chn1) amp1))
			(snd-display ";pan-mix disconnect amp ~A: ~A (~A) ~A (~A)" 
				     name (mix-amp id0 chn0) amp0 (mix-amp id1 chn1) amp1))
		    (set! (mix-amp-env id1 chn1) (list 0.0 (random 1.0) 1.0 (random 1.0)))
		    (if (or (not (equal? (mix-amp-env id0 chn0) env0))
			    (feql (mix-amp-env id1 chn1) (or env1 '())))
			(snd-display ";pan-mix disconnect amp-env ~A: ~A (~A) ~A (~A)" 
				     name (mix-amp-env id0 chn0) env0 (mix-amp-env id1 chn1) env1))
		    (if (not (= id0 id1))
			(let ((pos0 (mix-position id0))
			      (pos1 (mix-position id1))
			      (spd0 (mix-speed id0))
			      (spd1 (mix-speed id1)))
			  (set! (mix-position id0) (+ pos0 12))
			  (if (or (= (mix-position id0) pos0)
				  (not (= (mix-position id1) pos1)))
			      (snd-display ";pan-mix disconnect position ~A: ~A (~A) ~A (~A)" 
					   name (mix-position id0) pos0 (mix-position id1) pos1))
			  (set! (mix-speed id1) (* (mix-speed id1) 1.5))
			  (if (or (fneq (mix-speed id1) (* 1.5 spd1))
				  (fneq (mix-speed id0) spd0))
			      (snd-display ";pan-mix disconnect speed ~A: ~A (~A) ~A (~A)" 
					   name (mix-speed id0) spd0 (mix-speed id1) spd1)))))))
	       (find-next-child 
		(lambda (widget name ptr)
		  (call-with-current-continuation
		   (lambda (return)
		     (for-each-child
		      widget
		      (lambda (child)
			(if (and (string=? (XtName child) name)
				 (not (equal? child ptr)))
			    (return child))))
		     #f))))
	       (env-at-one
		(lambda (e)
		  (or (null? e)
		      (and (< (abs (- (cadr e) 1.0)) .001)
			   (env-at-one (cddr e)))))))
	
	(if (and (provided? 'snd-motif)
		 (provided? 'xm)
		 #t)
	    (let* ((ind (open-sound "oboe.snd"))
		   (mix1 (mix-vct (vct 0.1 0.2 0.3) 120 ind 0 #t "origin!"))
		   (mix2 (mix-vct (vct 0.1 0.2 0.3) 1200 ind 0 #t))
		   (mix3 (mix-vct (vct 0.1 0.2 0.3) 12000 ind 0 #t)))
	      (set! (mix-track mix1) (make-track))
	      (set! (mix-track mix3) (mix-track mix1))
	      (if (not (equal? (mixes ind 0) (list mix1 mix2 mix3)))
		  (snd-display ";mixes: ~A ~A" (mixes ind 0) (list mix1 mix2 mix3)))
	      (if (not (equal? (mixes ind #t) (list (list mix1 mix2 mix3))))
		  (snd-display ";mixes #t: ~A ~A" (mixes ind #t) (list (list mix1 mix2 mix3))))
	      (if (not (equal? (mixes) (list (list (list mix1 mix2 mix3)))))
		  (snd-display ";mixes all: ~A ~A" (mixes) (list (list (list mix1 mix2 mix3)))))
		
		(view-mixes-dialog)
		(set! (mix-dialog-mix) mix1)
		(let* ((mixd (list-ref (dialog-widgets) 16))
		       (nxt (find-child mixd "Next"))
		       (prev (find-child mixd "Previous"))
		       (tplay (find-child mixd "mix-track-play")))
		  (click-button tplay) (force-event)
		  (if (or (not (XtIsSensitive nxt))
			  (XtIsSensitive prev))
		      (snd-display ";mix-dialog next/previous: ~A ~A ~A ~A" nxt (XtIsSensitive nxt) prev (XtIsSensitive prev)))
		  (click-button nxt) (force-event)
		  (click-button nxt) (force-event)
		  (if (or (XtIsSensitive nxt)
			  (not (XtIsSensitive prev)))
		      (snd-display ";mix-dialog (1) next/previous: ~A ~A ~A ~A" nxt (XtIsSensitive nxt) prev (XtIsSensitive prev)))
		  (click-button prev) (force-event)
		  (click-button prev) (force-event))
		(dismiss-all-dialogs)
	      (close-sound ind)))
	)

      (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "copy-mix tests" 300)))
	
	(define (check-copied-mix original copy pos)
	  (if (not (mix? copy)) (snd-display ";copy-mix returns bad mix: ~A" copy))
	  (if (not (= (mix-track copy) 0)) (snd-display ";copy-mix set track: ~A ~A" (mix-track copy) (mix-track original)))
	  (if (not (= (mix-chans copy) (mix-chans original))) (snd-display ";copy-mix chans: ~A ~A" (mix-chans copy) (mix-chans original)))
	  (if (not (= (mix-tag-position copy) (mix-tag-position original))) 
	      (snd-display ";copy-mix anchor: ~A ~A" (mix-tag-position copy) (mix-tag-position original)))
	  (if (not (= (mix-frames copy) (mix-frames original))) (snd-display ";copy-mix frames: ~A ~A" (mix-frames copy) (mix-frames original)))
	  (if (not (= (mix-position copy) pos)) (snd-display ";copy-mix set position: ~A ~A ~A" (mix-position copy) pos (mix-position original)))   
	  (if (fneq (mix-speed copy) (mix-speed original)) (snd-display ";copy-mix speed: ~A ~A" (mix-speed copy) (mix-speed original)))
	  (if (fneq (mix-maxamp copy) (mix-maxamp original)) (snd-display ";copy-mix maxamp: ~A ~A" (mix-maxamp copy) (mix-maxamp original)))
	  (do ((i 0 (1+ i)))
	      ((= i (mix-chans copy)))
	    (if (fneq (mix-amp copy i) (mix-amp original i)) (snd-display ";copy-mix amp[~A]: ~A ~A" i (mix-amp copy i) (mix-amp original i)))
	    (let ((copy-amp-env (mix-amp-env copy i))
		  (original-amp-env (mix-amp-env original i)))
	      (if (and (list? copy-amp-env)
		       (list? original-amp-env))
		  (if (not (feql copy-amp-env original-amp-env)) 
		      (snd-display ";copy-mix amp-env[~A]: ~A ~A" i copy-amp-env original-amp-env))
		  (if (not (eq? copy-amp-env original-amp-env))
		      (snd-display ";copy-mix amp-env[~A]: ~A ~A" i copy-amp-env original-amp-env)))))
	  (if (not (equal? (mix-home copy) (mix-home original))) (snd-display ";copy-mix home: ~A ~A" (mix-home copy) (mix-home original))))
	
	(let* ((mix1 (mix-vct (make-vct 10 .5) 10))
	       (copy-mix1 (copy-mix mix1)))
	  (let ((old-color (mix-color mix1)))
	    (set! (mix-color mix1) (make-color 0 1 1))
	    (let ((new-color (mix-color mix1)))
	      (if (not (equal? new-color (make-color 0 1 1)))
		  (snd-display ";mix-color ~A ~A = ~A (~A)?" mix1 (make-color 0 1 1) new-color old-color))))
	  (check-copied-mix mix1 copy-mix1 10)
	  (set! (mix-amp mix1) 2.0)
	  (set! copy-mix1 (copy-mix mix1 20))
	  (check-copied-mix mix1 copy-mix1 20)    
	  (set! (mix-speed mix1) 2.0)
	  (set! copy-mix1 (copy-mix mix1 40))
	  (check-copied-mix mix1 copy-mix1 40)    
	  (set! (mix-amp-env mix1 0) '(0 0 1 1))
	  (set! copy-mix1 (copy-mix mix1 60))
	  (check-copied-mix mix1 copy-mix1 60)
	  (set! (mix-tag-position mix1) 2)
	  (set! copy-mix1 (copy-mix mix1 80))
	  (check-copied-mix mix1 copy-mix1 80)
	  (set! (mix-position mix1) 100)
	  (set! copy-mix1 (copy-mix mix1))
	  (check-copied-mix mix1 copy-mix1 100)
	  (set! mix1 (mix "2a.snd" 100 #t ind))
	  (set! (mix-amp mix1 0) 0.5)
	  (set! (mix-amp mix1 1) 0.75)
	  (set! (mix-amp-env mix1 0) '(0 1 1 0))
	  (set! copy-mix1 (copy-mix mix1 200))
	  (check-copied-mix mix1 copy-mix1 200)
	  (set! (mix-amp-env mix1 1) '(0 0 1 1))
	  (set! copy-mix1 (copy-mix mix1 300))
	  (check-copied-mix mix1 copy-mix1 300)
	  (let ((mix2 (copy-mix copy-mix1 500)))
	    (check-copied-mix copy-mix1 mix2 500))
	  (close-sound ind)
	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 4 "copy-mix tests" 300))
	  (set! mix1 (mix "2a.snd" 10 #t ind 2))
	  (set! copy-mix1 (copy-mix mix1 20))
	  (check-copied-mix mix1 copy-mix1 20)
	  (close-sound ind)))

      (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "copy-mix tests" 300))
	    (old-color (mix-color)))
	(set! (mix-color) (make-color 1 1 0))
	(let ((mix1 (mix-vct (make-vct 10 .5) 10)))
	  (if (or (not (equal? (mix-color) (make-color 1 1 0)))
		  (not (equal? (mix-color mix1) (make-color 1 1 0))))
	      (snd-display ";set mix-color: ~A ~A ~A ~A" (mix-color) (mix-color mix1) (make-color 1 1 0) old-color))
	  (set! (mix-color) old-color)
	  (save-mix mix1 "test.snd")
	  (let ((ind1 (open-sound "test.snd")))
	    (if (not (= (frames ind1) (mix-frames mix1))) (snd-display ";save-mix frames: ~A ~A" (mix-frames mix1) (frames ind1)))
	    (if (not (vequal (channel->vct 0 10) (mix->vct mix1)))
		(snd-display ";save-mix data: ~A ~A" (mix->vct mix1) (channel->vct 0 10 ind1)))
	    (close-sound ind1)))
	(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)))
	(if (mix-locked? mix1) (snd-display ";make mix locked: ~A ~A" mix1 (mix-locked? mix1)))
	(delete-mix mix1)
	(if (fneq (maxamp ind 0) 0.0) (snd-display ";delete-mix maxamp: ~A" (maxamp ind 0)))
	(if (not (mix-locked? mix1)) (snd-display ";delete mix not locked: ~A ~A" mix1 (mix-locked? mix1)))
	(undo-channel 1 ind 0)
	(if (fneq (maxamp ind 0) 0.5) (snd-display ";undelete-mix maxamp: ~A" (maxamp ind 0)))
	(if (mix-locked? mix1) (snd-display ";undelete mix locked: ~A ~A" mix1 (mix-locked? mix1)))
	(redo-channel 1 ind 0)
	(if (fneq (maxamp ind 0) 0.0) (snd-display ";redelete-mix maxamp: ~A" (maxamp ind 0)))
	(if (not (mix-locked? mix1)) (snd-display ";redelete mix not locked: ~A ~A" mix1 (mix-locked? mix1)))
	(undo 2)
	(if (mix? mix1) (snd-display ";undo 2 kept mix?"))
	(if (fneq (maxamp ind 0) 0.0) (snd-display ";no delete-mix maxamp: ~A" (maxamp ind 0)))
	(let ((tag (catch 'no-such-mix
			  (lambda () (if (mix-locked? mix1) (snd-display ";no delete mix locked: ~A ~A" mix1 (mix-locked? mix1))))
			  (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-mix)) (snd-display ";pending mix release accessible?")))
	(let ((tag (catch 'no-such-mix
			  (lambda () (set! (mix-locked? mix1) #t))
			  (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-mix)) (snd-display ";pending mix release settable?")))
	(redo)
	(if (mix-locked? mix1) (snd-display ";mix un/locked: ~A ~A" mix1 (mix-locked? mix1)))
	(if (fneq (maxamp ind 0) 0.5) (snd-display ";reundelete-mix maxamp: ~A" (maxamp ind 0)))
	(let ((track1 (make-track mix1)))
	  (delete-track track1)
	  (if (fneq (maxamp ind 0) 0.0) (snd-display ";delete-track maxamp: ~A" (maxamp ind 0)))
	  (undo)
	  (if (fneq (maxamp ind 0) 0.5) (snd-display ";undelete-track maxamp: ~A" (maxamp ind 0)))
	  (redo)
	  (if (fneq (maxamp ind 0) 0.0) (snd-display ";redelete-track maxamp: ~A" (maxamp ind 0))))
	(revert-sound ind)
	(let* ((mix2 (mix-vct (make-vct 10 .5) 10))
	       (track2 (make-track mix2)))
	  (set! (track-amp-env track2) '(0 0 1 1))
	  (delete-track track2)
	  (if (fneq (maxamp ind 0) 0.0) (snd-display ";delete-track (amp-env) maxamp: ~A" (maxamp ind 0)))
	  (undo)
	  (let ((mix3 (mix-vct (make-vct 10 .5) 50)))
	    (set! (mix-track mix3) track2))
	  (delete-track track2)
	  (if (fneq (maxamp ind 0) 0.0) (snd-display ";redelete-track (amp-env) maxamp: ~A" (maxamp ind 0)))
	  (close-sound ind)))

      (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "mix undo tests" 300))
	     (mix1 (mix-vct (make-vct 10 .1) 10))
	     (track1 (make-track))
	     (track2 (make-track)))
	(set! (mix-track mix1) track1)
	(if (not (= (mix-track mix1) track1)) (snd-display ";mix-track start ~A: ~A" track1 (mix-track mix1)))
	(set! (track-amp track2) 2.0)
	(set! (mix-amp mix1 0) 3.0)
	(if (fneq (maxamp ind 0) .3) (snd-display ";mix-track chain setup: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(set! (mix-track mix1) track2)
	(if (not (= (mix-track mix1) track2)) (snd-display ";mix-track set ~A: ~A" track2 (mix-track mix1)))
	(if (fneq (maxamp ind 0) .6) (snd-display ";mix-track chain set: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(undo)
	(if (not (= (mix-track mix1) track1)) (snd-display ";mix-track undo ~A: ~A" track1 (mix-track mix1)))
	(if (fneq (maxamp ind 0) .3) (snd-display ";mix-track chain undo setup: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))	
	(undo 2)
	(if (not (= (mix-track mix1) 0)) (snd-display ";mix-track undo2: ~A ~A ~A: ~A" track1 track2 (mix-track mix1) (edit-position ind 0)))
	(if (fneq (maxamp ind 0) .1) (snd-display ";mix-track chain undo: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(set! (mix-position mix1) 20)
	(if (fneq (maxamp ind 0) .1) (snd-display ";mix-track chain undo: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(let ((pos0 (mix-tag-position mix1))
	      (y0 (mix-tag-y mix1)))
	  (set! (mix-amp mix1) 1.0)
	  (set! (mix-tag-position mix1) 3)
	  (set! (mix-tag-y mix1) 6)
	  (if (not (= (mix-tag-position mix1) 3)) (snd-display ";mix-tag-position chain test 0: ~A" (mix-tag-position mix1)))
	  (if (not (= (mix-tag-y mix1) 6)) (snd-display ";mix-tag-y chain test 0: ~A" (mix-tag-y mix1)))
	  (undo)
	  (if (not (= (mix-tag-position mix1) pos0)) (snd-display ";mix-tag-position chain test 1: ~A" (mix-tag-position mix1)))
	  (if (not (= (mix-tag-y mix1) y0)) (snd-display ";mix-tag-y chain test 1: ~A" (mix-tag-y mix1)))
	  (close-sound ind)))

      (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "copy-mix tests" 300))
	     (mix1 (mix-vct (make-vct 10 .1) 10))
	     (track1 (make-track))
	     (track2 (make-track))
	     (edpos 0))
	(set! edpos (edit-position ind 0))
	(set! (mix-track mix1) track1)
	(if (not (= (mix-track mix1) track1)) (snd-display ";mix-track start ~A: ~A" track1 (mix-track mix1)))
	(set! (track-amp track2) 2.0)
	(set! (mix-amp mix1 0) 3.0)
	(if (fneq (maxamp ind 0) .3) (snd-display ";mix-track chain setup: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(set! (mix-track mix1) track2)
	(if (not (= (mix-track mix1) track2)) (snd-display ";mix-track set ~A: ~A" track2 (mix-track mix1)))
	(if (fneq (maxamp ind 0) .6) (snd-display ";mix-track chain set: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(undo)
	(if (not (= (mix-track mix1) track1)) (snd-display ";mix-track undo ~A: ~A" track1 (mix-track mix1)))
	(if (fneq (maxamp ind 0) .3) (snd-display ";mix-track chain undo setup: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))	
	(set! (edit-position ind 0) edpos)
	(if (not (= (mix-track mix1) 0)) (snd-display ";mix-track undo2: ~A" (mix-track mix1)))
	(if (fneq (maxamp ind 0) .1) (snd-display ";mix-track chain undo: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(set! (mix-position mix1) 20)
	(if (fneq (maxamp ind 0) .1) (snd-display ";mix-track chain undo: ~A ~A" (maxamp ind 0) (mix-amp mix1 0)))
	(let ((pos0 (mix-tag-position mix1))
	      (y0 (mix-tag-y mix1)))
	  (set! (mix-amp mix1) 1.0)
	  (set! (mix-tag-position mix1) 3)
	  (set! (mix-tag-y mix1) 6)
	  (set! (mix-amp mix1 0) .1)
	  (if (not (= (mix-tag-position mix1) 3)) (snd-display ";mix-tag-position chain test 0: ~A" (mix-tag-position mix1)))
	  (if (not (= (mix-tag-y mix1) 6)) (snd-display ";mix-tag-y chain test 0: ~A" (mix-tag-y mix1)))
	  (undo)
	  (if (not (= (mix-tag-position mix1) pos0)) (snd-display ";mix-tag-position chain test 1: ~A ~A" pos0 (mix-tag-position mix1)))
	  (if (not (= (mix-tag-y mix1) y0)) (snd-display ";mix-tag-y chain test 1: ~A ~A" y0 (mix-tag-y mix1)))
	  (redo)
	  (if (not (= (mix-tag-position mix1) 3)) (snd-display ";mix-tag-position chain test 2: ~A" (mix-tag-position mix1)))
	  (if (not (= (mix-tag-y mix1) 6)) (snd-display ";mix-tag-y chain test 2: ~A" (mix-tag-y mix1)))
	  (close-sound ind)))

      (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "copy-track tests" 300)))
	
	(define (check-copied-track original copy pos)
	  (if (not (track? copy)) (snd-display ";copy-track returns bad track: ~A" copy))
	  (if (not (= (track-track copy) 0)) (snd-display ";copy-track set track: ~A ~A" (track-track copy) (track-track original)))
	  (if (not (= (track-chans copy) (track-chans original))) (snd-display ";copy-track chans: ~A ~A" (track-chans copy) (track-chans original)))
	  (if (not (= (track-frames copy) (track-frames original))) (snd-display ";copy-track frames: ~A ~A" (track-frames copy) (track-frames original)))
	  (if (not (= (track-position copy) pos)) (snd-display ";copy-track set position: ~A ~A ~A" (track-position copy) pos (track-position original)))   
	  (if (fneq (track-speed copy) (track-speed original)) (snd-display ";copy-track speed: ~A ~A" (track-speed copy) (track-speed original)))
	  (if (fneq (track-amp copy) (track-amp original)) (snd-display ";copy-track amp: ~A ~A" (track-amp copy) (track-amp original)))
	  (let ((copy-amp-env (track-amp-env copy))
		(original-amp-env (track-amp-env original)))
	    (if (and (list? copy-amp-env)
		     (list? original-amp-env))
		(if (not (feql copy-amp-env original-amp-env)) 
		    (snd-display ";copy-track amp-env: ~A ~A" copy-amp-env original-amp-env))
		(if (not (eq? copy-amp-env original-amp-env))
		    (snd-display ";copy-track amp-env: ~A ~A" copy-amp-env original-amp-env))))
	  (if (not (= (length (track copy)) (length (track original)))) 
	      (snd-display ";copy-track mix lists differ: ~A ~A" (track copy) (track original))
	      (for-each
	       (lambda (orig cop)
		 (if (= (mix-track orig) original)
		     (if (not (= (mix-track cop) copy))
			 (snd-display ";copy-track mix-tracks: ~A -> ~A" (mix-track orig) (mix-track cop)))))
	       (track original)
	       (track copy)))
	  (if (> (track-chans original) 0)
	      (let ((vcopy (track->vct copy))
		    (vorig (track->vct original)))
		(if (not (vequal vcopy vorig)) (snd-display ";copy-track data: ~A ~A" vcopy vorig)))))
	
	(let ((tag (catch #t (lambda () (copy-track 0)) (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-track)) (snd-display ";copy-track 0: ~A" tag)))
	(let* ((mix1 (mix-vct (make-vct 10 1.0) 100))
	       (track0 (make-track))
	       (track1 (make-track mix1)))
	  (if (not (equal? (track track1) (list mix1))) (snd-display ";make-track for copy: ~A ~A" mix1 (track track1)))
	  (if (not (= track1 (mix-track mix1))) (snd-display ";make-track for copy mix: ~A ~A" (mix-track mix1) track1))
	  (let* ((copy-track0 (copy-track track0))
		 (edpos (edit-position ind 0))
		 (copy-track1 (copy-track track1)))
	    (if (not (equal? (track track1) (list mix1))) (snd-display ";copy-track clobbered original: ~A ~A" mix1 (track track1)))
	    (if (not (= track1 (mix-track mix1))) (snd-display ";copy-track clobbered original: ~A ~A" (mix-track mix1) track1))
	    (check-copied-track track0 copy-track0 -1)
	    (check-copied-track track1 copy-track1 100)
	    (if (not (= (edit-position ind 0) (1+ edpos)))
		(snd-display ";copy-track not atomic? ~A ~A" edpos (edit-position ind 0)))
	    (undo 2)))
	(let* ((mix1 (mix-vct (make-vct 10 1.0) 50))
	       (track1 (make-track mix1))
	       (track2 (copy-track track1 200)))
	  (check-copied-track track1 track2 200)
	  (undo)
	  (set! (track-amp track1) 2.0)
	  (set! (track-amp-env track1) '(0 0 1 1))
	  (set! (mix-amp mix1) 0.25)
	  (set! track2 (copy-track track1 200))
	  (check-copied-track track1 track2 200)
	  (revert-sound ind))
	(let* ((mix1 (mix-vct (make-vct 10 1.0) 50))
	       (mix2 (mix-vct (make-vct 10 1.0) 75))
	       (track1 (make-track mix1 mix2))
	       (track2 (copy-track track1 200)))
	  (check-copied-track track1 track2 200)
	  (let* ((mix3 (mix-vct (make-vct 10 1.0) 10))
		 (mix4 (mix-vct (make-vct 10 1.0) 20))
		 (track3 (make-track mix3 mix4)))
	    (set! (track-track track3) track1)
	    (set! track2 (copy-track track1 300))
	    (check-copied-track track1 track2 300))
	  )
	(close-sound ind)
	)
      
      (let ((old-with-mix-tags (with-mix-tags)))
	(set! (with-mix-tags) #t)
	(let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track tests" 1000)))
	  (let ((mix1 (mix-vct (make-vct 10 .4) 100)))
	    
	    ;; -------- empty and 1-mix tracks --------
	    (if (not (mix? mix1)) (snd-display ";can't even get track tests started!"))
	    (let ((track1 (make-track mix1)))
	      
	      (define (track-states-match? track-id state) ; state is (list amp speed track env color)
		(and (< (abs (- (track-amp track-id) (list-ref state 0))) .0001)
		     (< (abs (- (track-speed track-id) (list-ref state 1))) .0001)
		     (= (track-track track-id) (list-ref state 2))
		     (or (and (not (track-amp-env track-id))
			      (not (list-ref state 3)))
			 (feql (track-amp-env track-id) (list-ref state 3)))
		     (equal? (track-color track-id) (list-ref state 4))))
	      (define (track-state->list track-id)
		(list (track-amp track-id)
		      (track-speed track-id)
		      (track-track track-id)
		      (track-amp-env track-id)
		      (track-color track-id)))
	      
	      (if (not (track? track1)) (snd-display ";track? ~A" track1))
	      (let ((tag (catch #t
				(lambda () (set! (track-track track1) -1))
				(lambda args (car args)))))
		(if (not (eq? tag 'out-of-range)) (snd-display ";set track-track -1: ~A (~A)" tag (track-track track1))))
	      (if (not (= (track-chans track1) 1)) (snd-display ";track-chans 1 mix: ~A" (track-chans track1)))
	      (if (not (= (mix-track mix1) track1)) (snd-display ";make track didn't set track? ~A" (mix-track mix1)))
	      (if (not (equal? (track track1) (list mix1))) (snd-display ";track 1: ~A ~A" mix1 (track track1)))
	      (if (not (track-states-match? track1 '(1.0 1.0 0 () #f)))
		  (snd-display ";track states 1: ~A" (track-state->list track1)))
	      (if (not (= (edit-position ind 0) 2))
		  (snd-display ";tracked mix edit position: ~A ~A" (edit-position ind 0) (edit-tree ind 0)))
	      (if (fneq (maxamp ind 0) .4) (snd-display ";mixed maxamp .4: ~A" (maxamp ind 0)))
	      (if (not (= (track-position track1) 100)) (snd-display ";track position mix1: ~A" (track-position track1)))
	      (if (not (= (track-frames track1) 10)) (snd-display ";track frames mix1: ~A" (track-frames track1)))
	      (set! (track-amp track1) 2.0)
	      (if (not (track-states-match? track1 '(2.0 1.0 0 () #f)))
		  (snd-display ";track states 2: ~A" (track-state->list track1)))
	      (if (not (= (edit-position ind 0) 3))
		  (snd-display ";tracked mix amp-2 edit position: ~A ~A" (edit-position ind 0) (edit-tree ind 0)))
	      (if (fneq (maxamp ind 0) .8) (snd-display ";mixed maxamp .8: ~A" (maxamp ind 0)))
	      (undo 1)
	      (if (not (track-states-match? track1 '(1.0 1.0 0 () #f)))
		  (snd-display ";track states 3 (undo): ~A" (track-state->list track1)))
	      (if (not (= (edit-position ind 0) 2))
		  (snd-display ";tracked mix edit position (undo): ~A ~A" (edit-position ind 0) (edit-tree ind 0)))
	      (if (fneq (maxamp ind 0) .4) (snd-display ";mixed maxamp .4 (undo): ~A" (maxamp ind 0)))
	      (redo 1)
	      (if (not (track-states-match? track1 '(2.0 1.0 0 () #f)))
		  (snd-display ";track states 4 (redo): ~A" (track-state->list track1)))
	      (if (not (= (edit-position ind 0) 3))
		  (snd-display ";tracked mix amp-2 edit position (redo): ~A ~A" (edit-position ind 0) (edit-tree ind 0)))
	      (if (fneq (maxamp ind 0) .8) (snd-display ";mixed maxamp .8 (redo): ~A" (maxamp ind 0)))
	      (let ((mr (make-mix-sample-reader mix1))
		    (tr (make-track-sample-reader track1)))
		(call-with-current-continuation
		 (lambda (break)
		   (do ((i 0 (1+ i)))
		       ((= i (mix-frames mix1)))
		     (let ((ms (read-mix-sample mr))
			   (ts (read-track-sample tr)))
		       (if (or (fneq ms ts)
			       (fneq ms .8))
			   (begin
			     (snd-display ";mix+track readers: ~A ~A (.8)" ms ts)
			     (break))))))))
	      (for-each
	       (lambda (samp val)
		 (if (fneq (sample samp) val) (snd-display ";track read ~D: ~A (~A)" samp (sample samp) val)))
	       (list 99 105 111 199 207 211 299 306 311)
	       (list 0.0 .8 0.0 0.0 0.0 0.0 0.0 0.0 0.0))
	      (if (fneq (sample 99) 0.0) (snd-display ";track read 99: ~A" (sample 99)))
	      (if (fneq (sample 111) 0.0) (snd-display ";track read 111: ~A" (sample 111)))
	      (set! (track-position track1) 200)
	      (if (not (= (track-position track1) 200)) (snd-display ";track position mix1 200: ~A" (track-position track1)))
	      (if (not (= (track-frames track1) 10)) (snd-display ";track frames mix1 200: ~A" (track-frames track1)))
	      (if (not (= (mix-position mix1) 200)) (snd-display ";track position mix 1 200: ~A" (mix-position mix1)))
	      (if (not (= (mix-frames mix1) 10)) (snd-display ";track frames mix 1 200: ~A" (mix-frames mix1)))
	      (if (not (track-states-match? track1 '(2.0 1.0 0 () #f)))
		  (snd-display ";track states 5 (move): ~A" (track-state->list track1)))
	      (for-each
	       (lambda (samp val)
		 (if (fneq (sample samp) val) (snd-display ";track read ~D: ~A (~A)" samp (sample samp) val)))
	       (list 99 105 111 199 207 211 299 306 311)
	       (list 0.0 0.0 0.0 0.0 .8 0.0 0.0 0.0 0.0))
	      (undo 1)
	      (set! (mix-position mix1) 300)
	      (if (not (= (track-position track1) 300)) (snd-display ";track position mix1 300: ~A" (track-position track1)))
	      (if (not (= (track-frames track1) 10)) (snd-display ";track frames mix1 300: ~A" (track-frames track1)))
	      (if (not (= (mix-position mix1) 300)) (snd-display ";track position mix 1 300: ~A" (mix-position mix1)))
	      (if (not (= (mix-frames mix1) 10)) (snd-display ";track frames mix 1 300: ~A" (mix-frames mix1)))
	      (if (not (track-states-match? track1 '(2.0 1.0 0 () #f)))
		  (snd-display ";track states 6 (move mix): ~A" (track-state->list track1)))
	      (for-each
	       (lambda (samp val)
		 (if (fneq (sample samp) val) (snd-display ";track read ~D: ~A (~A)" samp (sample samp) val)))
	       (list 99 105 111 199 207 211 299 306 311)
	       (list 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.8 0.0))
	      (undo 1)
	      (let ((track2 (make-track))
		    (pos (edit-position ind)))
		(if (not (equal? (track track2) '())) (snd-display ";empty track: ~A ~A" mix1 (track track2)))
		(if (not (= (track-chans track2) 0)) (snd-display ";track-chans no mix: ~A" (track-chans track2)))
		(if (not (= (track-position track2) -1)) (snd-display ";empty track position: ~A" (track-position track2)))	  
		(if (not (= (track-frames track2) 0)) (snd-display ";empty track frames: ~A" (track-frames track2)))
		(if (not (track-states-match? track2 '(1.0 1.0 0 () #f)))
		    (snd-display ";empty track states 7: ~A" (track-state->list track2)))
		(let ((tag (catch #t (lambda () (set! (track-track track1) track1)) (lambda args (car args)))))
		  (if (not (eq? tag 'out-of-range)) (snd-display ";circular track: ~A" tag)))
		(set! (track-track track1) track2)
		(if (not (track-states-match? track1 (list 2.0 1.0 track2 '() #f)))
		    (snd-display ";track states 8 (track): ~A" (track-state->list track1)))
		(let ((tag (catch #t (lambda () (set! (track-track track2) track1)) (lambda args (car args)))))
		  (if (not (eq? tag 'out-of-range)) (snd-display ";circular track 2: ~A" tag)))
		(if (fneq (maxamp ind 0) .8) (snd-display ";track+track maxamp .8: ~A" (maxamp ind 0)))
		(set! (track-amp track2) 0.5)
		(if (not (track-states-match? track2 '(0.5 1.0 0 () #f)))
		    (snd-display ";empty track states 9 (amp): ~A" (track-state->list track2)))
		(if (fneq (maxamp ind 0) .4) (snd-display ";track+track maxamp .4: ~A" (maxamp ind 0)))
		(set! (track-amp track1) 0.5)
		(if (fneq (maxamp ind 0) .1) (snd-display ";track+track maxamp .1: ~A" (maxamp ind 0)))
		(set! (track-track track1) 0)
		(if (fneq (maxamp ind 0) .2) (snd-display ";track+track maxamp .2: ~A" (maxamp ind 0)))
		(set! (edit-position ind) pos)
		(if (not (track-states-match? track1 '(2.0 1.0 0 () #f)))
		    (snd-display ";track states 10 (edit-pos): ~A" (track-state->list track1)))
		(set! (track-speed track1) 0.5)
		(if (not (= (mix-frames mix1) 20)) (snd-display ";mix-frames with track-speed: ~A" (mix-frames mix1)))
		(if (not (= (track-frames track1) 20)) (snd-display ";track-frames with track-speed: ~A" (track-frames track1)))
		(if (not (track-states-match? track1 '(2.0 0.5 0 () #f)))
		    (snd-display ";track states 11 (speed): ~A" (track-state->list track1)))
		;; track2 amp at this point is 0.5
		(set! (mix-track mix1) 0)
		(if (not (equal? (track track1) '())) (snd-display ";empty track 1: ~A ~A" mix1 (track track1)))
		(if (not (= (mix-frames mix1) 10)) (snd-display ";mix-frames without track-speed: ~A" (mix-frames mix1)))
		(if (not (= (track-frames track1) 0)) (snd-display ";track-frames without track-speed: ~A" (track-frames track1)))
		(if (not (= (track-position track1) -1)) (snd-display ";empty track1 position: ~A" (track-position track1)))	  	  
		(if (fneq (maxamp ind 0) .4) (snd-display ";no track maxamp .4: ~A ~A" (maxamp ind 0)	(mix-amp mix1))) 
		(set! (mix-track mix1) track2)
		(if (not (equal? (track track2) (list mix1))) (snd-display ";track 2: ~A ~A" mix1 (track track2)))
		(if (not (equal? (track track1) '())) (snd-display ";empty track (set 2): ~A ~A ~A" mix1 (track track1) (track track2)))
		(if (not (= (track-position track2) 100)) (snd-display ";track 2 position mix1: ~A" (track-position track2)))
		(if (not (= (track-frames track2) 10)) (snd-display ";track 2 frames mix1: ~A" (track-frames track2)))
		(if (fneq (maxamp ind 0) .2) (snd-display ";track 2 maxamp .2: ~A ~A ~A" (maxamp ind 0) (mix-amp mix1) (track-amp track2)))
		(set! (mix-amp-env mix1 0) '(0 0 1 1))
		(let ((tv (track->vct track2))
		      (mv (mix->vct mix1)))
		  ;; should be the same: a ramp to .2
		  (if (or (not (= (vct-length mv) (vct-length tv)))
			  (not (vequal tv mv))
			  (not (vequal tv (vct 0.000 0.022 0.044 0.067 0.089 0.111 0.133 0.156 0.178 0.200))))
		      (snd-display ";amp env ramp track2 mix1: ~A ~A" tv mv))
		  (set! (track-amp-env track2) '(0 0 1 1))
		  (set! tv (track->vct track2))
		  (set! mv (mix->vct mix1))
		  (if (or (not (= (vct-length mv) (vct-length tv)))
			  (not (vequal tv mv))
			  (not (vequal tv (vct 0.000 0.002 0.008 0.018 0.032 0.050 0.072 0.098 0.128 0.162))))
		      ;; presumably this is a round-off error in that we have 10 or so segments and 10 samples 
		      (snd-display ";amp env 2 ramp track2 mix1: ~A ~A" tv mv))
		  (set! (mix-amp-env mix1 0) #f)
		  (set! tv (track->vct track2))
		  (set! mv (mix->vct mix1))
		  (if (or (not (= (vct-length mv) (vct-length tv)))
			  (not (vequal tv mv))
			  (not (vequal tv (vct 0.000 0.022 0.044 0.067 0.089 0.111 0.133 0.156 0.178 0.200))))
		      (snd-display ";amp env ramp track2: ~A ~A" tv mv))
		  (set! (track-speed track1) 1.0)
		  (set! (mix-track mix1) track1)
		  ;; that should undo the track2 env and apply the track1 amp
		  (set! tv (track->vct track1))
		  (set! mv (mix->vct mix1))
		  (if (or (not (= (vct-length mv) (vct-length tv)))
			  (not (vequal tv mv))
			  (not (vequal tv (make-vct 10 0.8))))
		      (snd-display ";no amp env track1 mix1: ~A ~A" tv mv)))
		(let ((color (make-color 0 1 0)))
		  (set! (track-color track1) color)
		  (if (not (equal? (track-color track1) color))
		      (snd-display ";track color green: ~A" (track-color track1)))
		  (if (not (track-states-match? track1 (list 2.0 1.0 0 '() color)))
		      (snd-display ";track 1 states 9 color: ~A" (track-state->list track1))))
		(free-track track2)
		(if (track? track2) (snd-display ";free-track track?"))
		(if (member track2 (tracks)) (snd-display ";free-track tracks: ~A in ~A" track2 (tracks))))
	      
	      (revert-sound ind)
	      ;; now track1 should be in its unedited state
	      (if (not (track-states-match? track1 '(1.0 1.0 0 () #f)))
		  (snd-display ";track states 12 after revert: ~A" (track-state->list track1)))
	      (if (not (member track1 (tracks))) (snd-display ";revert->tracks: ~A ~A" track1 (tracks)))
	      (if (not (equal? (track track1) '())) (snd-display ";revert past mix track1: ~A ~A ~A" (track track1) mix1 (mix? mix1)))
	      (let ((tag (catch #t (lambda () (track->vct track1)) (lambda args (car args)))))
		(if (not (eq? 'no-such-channel tag)) (snd-display ";track->vct empty track: ~A" tag)))
	      
	      ;; one sample mix
	      (set! mix1 (mix-vct (make-vct 1 .1) 50))
	      (set! (mix-track mix1) track1)
	      (if (not (= (track-position track1) 50)) (snd-display ";track 1 position mix-samp: ~A" (track-position track1)))
	      (if (not (= (track-frames track1) 1)) (snd-display ";track 1 frames mix-samp: ~A" (track-frames track1)))

	      (let ((start-state (track-state->list track1)))
		(set! (track-amp-env track1) '(0 1 1 0))
		(undo)
		(if (not (track-states-match? track1 start-state))
		    (snd-display ";undo after set amp-env: ~A ~A" start-state (track-state->list track1)))
		(redo)
		(if (not (feql (track-amp-env track1) '(0.0 1.0 1.0 0.0)))
		    (snd-display ";redo set track-amp-env: ~A" (track-amp-env track1)))
		(set! (track-amp-env track1) #f)
		(if (not (track-states-match? track1 start-state))
		    (snd-display ";redo/undo after set amp-env: ~A ~A" start-state (track-state->list track1))))

	      (let ((edpos (edit-position ind 0))
		    (state (track-state->list track1)))
		(as-one-edit
		 (lambda ()
		   (set! (track-amp track1) 4.0)
		   (set! (track-speed track1) 1.5)
		   (set! (track-amp-env track1) '(0 1 1 0))))
		(if (not (= edpos (1- (edit-position ind 0))))
		    (snd-display ";backup in as-one-edit: ~A ~A" edpos (edit-position ind 0)))
		(if (not (track-states-match? track1 '(4.0 1.5 0 (0 1 1 0) #f)))
		    (snd-display ";track states after as-one-edit: ~A" (track-state->list track1)))
		(undo)
		(if (not (track-states-match? track1 state))
		    (snd-display ";track states after undone as-one-edit: ~A ~A" state (track-state->list track1)))

		(redo)
		(if (not (track-states-match? track1 '(4.0 1.5 0 (0 1 1 0) #f)))
		    (snd-display ";track states after as-one-edit redo: ~A" (track-state->list track1)))
		(set! (track-amp-env track1) #f)
		(if (not (track-states-match? track1 '(4.0 1.5 0 () #f)))
		    (snd-display ";track states after amp env #f: ~A" (track-state->list track1)))
		(undo))

	      (revert-sound ind)
	      
	      ;; -------- multi mix tracks --------
	      (set! mix1 (mix-vct (make-vct 100 .1) 50))
	      (let ((mix2 (mix-vct (make-vct 100 .2) 250)))
		(set! (mix-track mix1) track1)
		(set! (mix-track mix2) track1)
		(if (not (= (track-chans track1) 1)) (snd-display ";track-chans mono mix: ~A" (track-chans track1)))
		(if (not (= (track-position track1) 50)) (snd-display ";track 1 position mix2/3: ~A" (track-position track1)))
		(if (not (= (track-frames track1) 300)) (snd-display ";track 1 frames mix2/3: ~A" (track-frames track1)))
		(if (not (equal? (track track1) (list mix1 mix2))) (snd-display ";track1 mix2/3 track: ~A ~A ~A" mix1 mix2 (track track1)))
		(if (not (track-states-match? track1 '(1.0 1.0 0 () #f)))
		    (snd-display ";track states 1 mix2/3: ~A" (track-state->list track1)))
		(if (fneq (maxamp) .2) (snd-display ";track1 mix2/3 maxamp: ~A" (maxamp)))
		(let ((edpos (edit-position ind 0)))
		  (set! (track-amp track1) 2.0)
		  (if (fneq (maxamp) .4) (snd-display ";track1 mix2/3 *2 maxamp: ~A" (maxamp)))
		  (if (or (fneq (sample 51) .2)
			  (fneq (sample 251) .4))
		      (snd-display ";track1 mix2/3 *2 samples: ~A ~A" (sample 51) (sample 251)))
		  (if (or (fneq (mix-amp mix1) 1.0)
			  (fneq (mix-amp mix2) 1.0))
		      (snd-display ";track1 mix2/3 mix amps: ~A ~A" (mix-amp mix1) (mix-amp mix2)))
		  (if (not (= (edit-position ind 0) (1+ edpos)))
		      (snd-display ";track amp set was not atomic: ~A ~A" edpos (edit-position ind 0)))
		  (undo)
		  (set! (track-position track1) 100)
		  (if (not (= (mix-position mix1) 100)) (snd-display ";set track position 100 mix1: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 300)) (snd-display ";set track position 100 mix2: ~A" (mix-position mix2)))
		  (if (not (= (track-position track1) 100)) (snd-display ";set track position 100 track1: ~A" (track-position track1)))
		  (if (not (= (edit-position ind 0) (1+ edpos)))
		      (snd-display ";track position set was not atomic: ~A ~A" edpos (edit-position ind 0)))
		  ;; now try to see if the remix was correct (kinda messy...)
		  (if (or (fneq (sample 51) 0.0)
			  (fneq (sample 99) 0.0)
			  (fneq (sample 251) 0.0)
			  (fneq (sample 299) 0.0))
		      (snd-display ";set track-position, bad cancel?: ~A ~A ~A ~A" (sample 51) (sample 99) (sample 251) (sample 299)))
		  (if (or (fneq (sample 100) 0.1)
			  (fneq (sample 199) 0.1)
			  (fneq (sample 301) 0.2)
			  (fneq (sample 399) 0.2))
		      (snd-display ";set track-position, bad remix after cancel?: ~A ~A ~A ~A" (sample 100) (sample 199) (sample 301) (sample 399)))
		  (undo)
		  (set! (track-speed track1) 0.5)
		  (if (or (not (= (mix-frames mix1) 200))
			  (not (= (mix-frames mix2) 200)))
		      (snd-display ";set track speed mix-frames: ~A ~A ~A" (mix-frames mix1) (mix-frames mix2) (track-frames track1)))
		  (if (not (= (edit-position ind 0) (1+ edpos)))
		      (snd-display ";track speed set was not atomic: ~A ~A" edpos (edit-position ind 0)))
		  (if (not (track-states-match? track1 '(1.0 0.5 0 () #f)))
		      (snd-display ";track states speed set mix2/3: ~A" (track-state->list track1)))
		  (undo)
		  (let ((old-track-color (track-color track1))
			(old-mix1-color (mix-color mix1))
			(old-mix2-color (mix-color mix2))
			(color (make-color 0 1 1)))
		    (set! (track-color track1) color)
		    (if (not (= (edit-position ind 0) edpos))
			(snd-display ";track color set was an edit?: ~A ~A" edpos (edit-position ind 0)))
		    (if (not (track-states-match? track1 (list 1.0 1.0 0 '() color)))
			(snd-display ";track states color set mix2/3: ~A" (track-state->list track1)))
		    (if (or (not (equal? (mix-color mix1) color))
			    (not (equal? (mix-color mix2) color))
			    (not (equal? (track-color track1) color)))
			(snd-display ";set track color mix2/3: ~A ~A ~A" (mix-color mix1) (mix-color mix2) (track-color track1)))
		    (set! (track-amp-env track1) '(0 0 .5 0 .51 1 1 1))
		    (if (not (feql (track-amp-env track1) '(0 0 .5 0 .51 1 1 1)))
			(snd-display ";set track-amp-env mix2/3: ~A" (track-amp-env track1)))
		    (if (or (fneq (sample 51) 0.0)
			    (fneq (sample 99) 0.0)
			    (fneq (sample 251) 0.2)
			    (fneq (sample 299) 0.2))
			(snd-display ";set track-position, bad remix after cancel?: ~A ~A ~A ~A" (sample 100) (sample 199) (sample 301) (sample 399)))
		    (if (not (= (edit-position ind 0) (1+ edpos)))
			(snd-display ";track amp env set was not atomic: ~A ~A" edpos (edit-position ind 0)))
		    (if (not (track-states-match? track1 (list 1.0 1.0 0 (list 0 0 .5 0 .51 1 1 1) color)))
			(snd-display ";track states amp-env set mix2/3: ~A" (track-state->list track1)))
		    (if (not (equal? (track-color track1) color)) (snd-display ";track color not stacked? ~A ~A" color (track-color track1)))
		    (set! (track-color track1) old-track-color)
		    (let* ((edpos (edit-position ind 0))
			   (track2a (make-track mix1 mix2)))
		      (if (not (= (1+ edpos) (edit-position ind 0))) 
			  (snd-display ";make-track not atomic? ~A ~A ~A" edpos (edit-position ind 0) (track track2a)))
		      (if (not (= (mix-track mix1) (mix-track mix2) track2a)) 
			  (snd-display ";make-track didn't reset track? ~A ~A ~A" (mix-track mix1) (mix-track mix2) track2a))
		      (if (not (equal? (track track1) '())) (snd-display ";make-track didn't cancel old track? ~A" (track track1)))
		      (set! edpos (edit-position ind 0))
		      (delete-track track2a)
		      (if (not (= (1+ edpos) (edit-position ind 0)))
			  (snd-display ";delete-track not atomic? ~A ~A" edpos (edit-position ind 0)))
		      (if (or (not (mix-locked? mix1)) (not (mix-locked? mix2)))
			  (snd-display ";delete-track didn't lock mixes? ~A ~A" (mix-locked? mix1) (mix-locked? mix2)))
		      (if (fneq (track-amp track2a) 0.0) (snd-display ";delete-track track amp: ~A" (track-amp track2a)))
		      (if (fneq (maxamp ind 0) 0.0) (snd-display ";delete-track maxamp: ~A" (maxamp ind 0)))
		      (catch 'no-such-mix
			     (lambda ()
			       (set! (mix-track mix1) 0))
			     (lambda args args))
		      (if (= (mix-track mix1) 0) (snd-display ";locked mix set track: ~A" (mix-track mix1)))
		      (let ((old-amp (mix-amp mix1 0)))
			(catch 'no-such-mix
			       (lambda ()
				 (set! (mix-amp mix1 0) 123.0))
			       (lambda args args))
			(if (fneq (mix-amp mix1 0) old-amp) (snd-display ";locked mix set amp: ~A ~A" old-amp (mix-amp mix1 0))))
		      (let ((old-speed (mix-speed mix1)))
			(catch 'no-such-mix
			       (lambda ()
				 (set! (mix-speed mix1) 123.0))
			       (lambda args args))
			(if (fneq (mix-speed mix1) old-speed) (snd-display ";locked mix set speed: ~A ~A" old-speed (mix-speed mix1))))
		      (let ((old-position (mix-position mix1)))
			(catch 'no-such-mix 
			       (lambda ()
				 (set! (mix-position mix1) 123))
			       (lambda args args))
			(if (not (= (mix-position mix1) old-position)) (snd-display ";locked mix set position: ~A ~A" old-position (mix-position mix1))))
		      (undo)
		      (if (fneq (maxamp ind 0) 0.2) (snd-display ";undo delete-track maxamp: ~A" (maxamp ind 0)))
		      (if (or (mix-locked? mix1) (mix-locked? mix2))
			  (snd-display ";undo delete-track didn't unlock mixes? ~A ~A" (mix-locked? mix1) (mix-locked? mix2)))
		      ))))
	      (revert-sound ind)))
	  (let* ((mix1 (mix-vct (make-vct 100 .2) 50))
		 (mix2 (mix-vct (make-vct 100 .2) 250))
		 (mix3 (mix-vct (make-vct 100 .2) 500))
		 (track3 (make-track mix1 mix2 mix3))
		 (edpos (edit-position ind 0)))
	    (lock-track track3)
	    (if (or (not (mix-locked? mix1))
		    (not (mix-locked? mix2))
		    (not (mix-locked? mix3)))
		(snd-display ";lock-track: ~A ~A ~A" (mix-locked? mix1) (mix-locked? mix2) (mix-locked? mix3)))
	    (if (not (equal? (track track3) '())) (snd-display ";locked track: ~A" (track track3)))
	    (if (not (= (edit-position ind 0) (1+ edpos))) (snd-display ";lock track not atomic?: ~A ~A" edpos (edit-position ind 0)))
	    (close-sound ind)
	    (if (not (equal? (track track3) '())) (snd-display ";close-sound unset track: ~A ~A" (track track3) (map mix? (track track3)))))
	  ;; stereo track
	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 2 "track tests" 1000))
	  (let* ((mixid (mix "2a.snd" 100 #t ind))
		 (trk (mix-track mixid))
		 (mixids (track trk)))
	    (if (not (> (mix-track mixid) 0)) (snd-display ";multimix 1: ~A ~A ~A" (mix-track mixid) trk mixids))
	    (if (not (apply = (map mix-track mixids))) (snd-display ";multimix 2: ~A" (map mix-track mixids)))
	    (if (not (= 1 (edit-position ind 0) (edit-position ind 1)))
		(snd-display ";multimix 3 edpos: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
	    (if (not (= (track-chans trk) 2)) (snd-display ";track-chans stereo mix: ~A" (track-chans trk)))

	    ;; track properties
	    (set! (track-property :hiho trk) 123)
	    (if (not (= (track-property :hiho trk) 123)) (snd-display ";track-property: ~A" (track-property trk)))
	    (if (track-property :not-there trk) (snd-display ";track-not-property: ~A" (track-property :not-there trk)))
	    (set! (track-property :hi trk) "hi")
	    (if (not (string=? (track-property :hi trk) "hi")) (snd-display ";track(1)-property: ~A" (track-property :hi trk)))

	    ;; 2chan basic stuff
	    (let ((max0 (maxamp ind 0))
		  (max1 (maxamp ind 1)))
	      (set! (track-amp trk) 2.0)
	      (if (or (fneq (maxamp ind 0) (* 2 max0))
		      (fneq (maxamp ind 1) (* 2 max1)))
		  (snd-display ";2chn track-amp: ~A ~A -> ~A ~A" max0 max1 (maxamp ind 0) (maxamp ind 1)))
	      (if (not (= 2 (edit-position ind 0) (edit-position ind 1)))
		  (snd-display ";2chn amp edpos: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
	      (undo 1 ind 0)
	      (undo 1 ind 1)
	      (set! (track-position trk) 500)
	      (if (not (= (track-position trk) 500)) (snd-display ";2chn track-position: ~A" (track-position trk)))
	      (if (or (not (apply = (map mix-position mixids)))
		      (not (= (mix-position (car mixids)) 500)))
		  (snd-display ";2chn track-position mixes: ~A" (map mix-position mixids)))
	      (if (not (= 2 (edit-position ind 0) (edit-position ind 1)))
		  (snd-display ";2chn position edpos: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
	      (undo 1 ind 0)
	      (undo 1 ind 1)
	      (let ((old-frames (frames)))
		(set! (track-speed trk) .5)
		(if (not (= (frames ind 0) (frames ind 1) (+ 100 (* 2 (- old-frames 100))))) ; mix is at 100
		    (snd-display ";2chn speed: ~A ~A ~A" (frames ind 0) (frames ind 1) (* 2 old-frames)))
		(if (not (= 2 (edit-position ind 0) (edit-position ind 1)))
		    (snd-display ";2chn speed edpos: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
		(undo 1 ind 0)
		(undo 1 ind 1))
	      (set! (track-amp-env trk) '(0 1 .1 2 .9 2 1 0))
	      (if (or (fneq (* 2 max0) (maxamp ind 0))
		      (fneq (* 2 max1) (maxamp ind 1)))
		  (snd-display ";2ch track-env: ~A ~A -> ~A ~A" max0 max1 (maxamp ind 0) (maxamp ind 1)))
	      (if (not (= 2 (edit-position ind 0) (edit-position ind 1)))
		  (snd-display ";2chn env edpos: ~A ~A" (edit-position ind 0) (edit-position ind 1)))
	      (undo 1 ind 0)
	      (undo 1 ind 1))
	    (close-sound ind)
	    (if (not (equal? (track trk) '())) (snd-display ";close-sound unset track (2): ~A ~A" (track trk) (map mix? (track trk)))))

	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track tests" 1000))      
	  (let* ((track4 (make-track))
		 (mixid (mix-vct (make-vct 10 .5) 100 ind 0 #t "snd-test" track4)))
	    (if (not (= (mix-track mixid) track4)) (snd-display ";mix-vct with track: ~A" (mix-track mixid)))
	    (if (not (= 1 (edit-position ind 0)))
		(snd-display ";mix-vct w/track not atomic?: ~A" (edit-position ind 0)))
	    (if (fneq (maxamp ind 0) 0.5) (snd-display ";mix-vct+track maxamp: ~A" (maxamp ind 0)))
	    (if (fneq (mix-maxamp mixid) 0.5) (snd-display ";mix-maxamp: ~A" (mix-maxamp mixid)))
	    (if (fneq (track-maxamp track4 0) 0.5) (snd-display ";track-maxamp: ~A" (track-maxamp track4 0)))
	    (undo)
	    (if (fneq (maxamp ind 0) 0.0) (snd-display ";mix-vct+track undo maxamp: ~A" (maxamp ind 0)))
	    (redo)
	    (if (not (= (mix-track mixid) track4)) (snd-display ";mix-vct with track (redo): ~A" (mix-track mixid)))
	    (if (fneq (maxamp ind 0) 0.5) (snd-display ";mix-vct+track redo maxamp: ~A" (maxamp ind 0)))
	    (let ((amix (mix "1a.snd" 200 0 ind 0 #t #f track4)))
	      (if (not (= (mix-track amix) track4)) (snd-display ";mix with track: ~A" (mix-track amix)))
	      (if (not (= 2 (edit-position ind 0)))
		  (snd-display ";mix w/track not atomic?: ~A" (edit-position ind 0)))
	      (if (fneq (maxamp ind 0) 0.5) (snd-display ";mix+track maxamp: ~A" (maxamp ind 0)))
	      (undo)
	      (if (fneq (maxamp ind 0) 0.5) (snd-display ";mix+track undo maxamp: ~A" (maxamp ind 0)))
	      (redo)
	      (if (not (= (mix-track amix) track4)) (snd-display ";mix with track (redo): ~A" (mix-track amix)))
	      (if (fneq (maxamp ind 0) 0.5) (snd-display ";mix+track redo maxamp: ~A" (maxamp ind 0)))
	      (if (not (equal? (track track4) (list mixid amix))) (snd-display ";mix-vct+mix+track: ~A" (track track4)))
	      (let ((rid (make-region 100 110 ind 0)))
		;; should be ok because with-mix-tags was turned on above
		(if (fneq (region-maxamp rid) 0.5) (snd-display ";region(mix) picked up wrong section? ~A" (region-maxamp rid)))
		(let ((rmix (mix-region 900 rid ind 0 track4)))
		  (if (not (= (mix-track rmix) track4)) (snd-display ";mix-region with track: ~A" (mix-track rmix)))
		  (if (not (= 3 (edit-position ind 0)))
		      (snd-display ";mix-region w/track not atomic?: ~A" (edit-position ind 0)))
		  (if (fneq (maxamp ind 0) 0.56) (snd-display ";mix-region+track maxamp: ~A" (maxamp ind 0)))
		  (undo)
		  (if (fneq (maxamp ind 0) 0.5) (snd-display ";mix-region+track undo maxamp: ~A" (maxamp ind 0)))
		  (redo)
		  (if (not (= (mix-track rmix) track4)) (snd-display ";mix-region with track (redo): ~A" (mix-track rmix)))
		  (if (fneq (maxamp ind 0) 0.56) (snd-display ";mix-region+track redo maxamp: ~A" (maxamp ind 0)))
		  (if (not (equal? (track track4) (list mixid amix rmix))) (snd-display ";mix-vct+mix-region+mix+track: ~A" (track track4)))
		  (make-selection 400 500 ind 0)
		  (let ((smix (mix-selection 4000 ind 0)))
		    (set! (mix-track smix) track4)
		    (if (not (= (mix-track smix) track4)) (snd-display ";mix-selection with track: ~A" (mix-track smix)))
		    (if (fneq (maxamp ind 0) 0.56) (snd-display ";mix-selection+track maxamp: ~A" (maxamp ind 0)))
		    (undo)
		    (if (fneq (maxamp ind 0) 0.56) (snd-display ";mix-selection+track undo maxamp: ~A" (maxamp ind 0)))
		    (redo)
		    (if (not (= (mix-track smix) track4)) (snd-display ";mix-selection with track (redo): ~A" (mix-track smix)))
		    (if (fneq (maxamp ind 0) 0.56) (snd-display ";mix-selection+track redo maxamp: ~A" (maxamp ind 0)))
		    (if (not (equal? (track track4) (list mixid amix rmix smix))) (snd-display ";mix-vct+mix-selection+mix+track: ~A" (track track4)))
		    (set! (track-amp track4) .5)
		    (if (fneq (maxamp ind 0) 0.28) (snd-display ";mix-selection+track reset amp maxamp: ~A" (maxamp ind 0)))
		    (let ((bmix (mix-vct (make-vct 10 .75) 4300 ind 0 #t "snd-test" track4)))
		      (if (not (= (mix-track bmix) track4)) (snd-display ";mix-vct with track amp: ~A" (mix-track smix)))
		      (if (not (= 7 (edit-position ind 0)))
			  (snd-display ";mix-vct w/track amp not atomic?: ~A" (edit-position ind 0)))
		      (if (fneq (maxamp ind 0) 0.375) (snd-display ";mix-vct+track amp maxamp: ~A" (maxamp ind 0)))
		      (if (not (equal? (track track4) (list mixid amix rmix smix bmix))) 
			  (snd-display ";mix-vct+mix-selection+mix+track amp: ~A" (track track4))))
		    (delete-track track4)
		    (if (fneq (maxamp ind 0) 0.0) (snd-display ";maxamp delete-track4: ~A" (maxamp ind 0))))))))
	  (close-sound ind)
	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 2 "track tests" 1000))      
	  (let* ((trk (make-track))
		 (mix1 (mix-vct (make-vct 10 .5) 10 ind 0 #t "snd-test" trk))
		 (mix2 (mix-vct (make-vct 10 .25) 20 ind 1 #t "snd-test" trk))
		 (mix3 (mix-vct (make-vct 10 .3) 30 ind 0 #t "snd-test" trk))
		 (mix4 (mix-vct (make-vct 10 .1) 40 ind 1 #t "snd-test" trk)))
	    (if (not (= (track-chans trk) 2)) (snd-display ";track-chans 4 mix-vct: ~A ~A" (track-chans trk) (map mix-home (track trk))))
	    (if (fneq (maxamp ind 0) .5) (snd-display ";maxamp mix-vct 4 0: ~A" (maxamp ind 0)))
	    (if (fneq (maxamp ind 1) .25) (snd-display ";maxamp mix-vct 4 1: ~A" (maxamp ind 1)))
	    (if (not (= (track-position trk) 10)) (snd-display ";overall track-position: ~A" (track-position trk)))
	    (if (not (= (track-frames trk) 40)) (snd-display ";overall track-frames: ~A" (track-frames trk)))
	    (if (not (= (track-position trk 0) 10)) (snd-display ";chn0 track-position: ~A" (track-position trk 0)))
	    (if (not (= (track-position trk 1) 20)) (snd-display ";chn1 track-position: ~A" (track-position trk 1)))
	    (if (not (= (track-frames trk 0) 30)) (snd-display ";chn0 track-frames: ~A" (track-frames trk 0)))
	    (if (not (= (track-frames trk 1) 30)) (snd-display ";chn1 track-frames: ~A" (track-frames trk 1)))
	    (if (not (equal? (track trk 0) (list mix1 mix3))) (snd-display ";track + chan0: ~A ~A" (track trk 0) (track trk)))
	    (if (not (equal? (track trk 1) (list mix2 mix4))) (snd-display ";track + chan1: ~A ~A" (track trk 1) (track trk)))
	    (set! (track-position trk) 0)
	    (if (not (= (track-position trk) 0)) (snd-display ";overall track-position 0: ~A" (track-position trk)))
	    (if (not (= (track-frames trk) 40)) (snd-display ";overall track-frames 0: ~A" (track-frames trk)))
	    (if (not (= (track-position trk 0) 0)) (snd-display ";chn0 track-position 0: ~A" (track-position trk 0)))
	    (if (not (= (track-position trk 1) 10)) (snd-display ";chn1 track-position 0: ~A" (track-position trk 1)))
	    (if (not (= (track-frames trk 0) 30)) (snd-display ";chn0 track-frames 0: ~A" (track-frames trk 0)))
	    (if (not (= (track-frames trk 1) 30)) (snd-display ";chn1 track-frames 0: ~A" (track-frames trk 1)))
	    (if (not (= (mix-position mix3) 20)) (snd-display ";chn0 track-position mix3: ~A" (mix-position mix3)))
	    (if (not (= (mix-position mix4) 30)) (snd-display ";chn1 track-position mix4: ~A" (mix-position mix4)))
	    (set! (track-position trk 0) 20)
	    (if (not (= (track-position trk) 10)) (snd-display ";overall track-position 1: ~A" (track-position trk)))
	    (if (not (= (track-frames trk) 40)) (snd-display ";overall track-frames 1: ~A" (track-frames trk)))
	    (if (not (= (track-position trk 0) 20)) (snd-display ";chn0 track-position 1: ~A" (track-position trk 0)))
	    (if (not (= (track-position trk 1) 10)) (snd-display ";chn1 track-position 1: ~A" (track-position trk 1)))
	    (if (not (= (track-frames trk 0) 30)) (snd-display ";chn0 track-frames 1: ~A" (track-frames trk 0)))
	    (if (not (= (track-frames trk 1) 30)) (snd-display ";chn1 track-frames 1: ~A" (track-frames trk 1)))
	    (if (not (= (mix-position mix3) 40)) (snd-display ";chn0 track-position mix3 1: ~A" (mix-position mix3)))
	    (if (not (= (mix-position mix4) 30)) (snd-display ";chn1 track-position mix4 1: ~A" (mix-position mix4)))
	    (set! (track-position trk 1) 20)
	    (if (not (= (track-position trk) 20)) (snd-display ";overall track-position 2: ~A" (track-position trk)))
	    (if (not (= (track-frames trk) 30)) (snd-display ";overall track-frames 2: ~A" (track-frames trk)))
	    (if (not (= (track-position trk 0) 20)) (snd-display ";chn0 track-position 2: ~A" (track-position trk 0)))
	    (if (not (= (track-position trk 1) 20)) (snd-display ";chn1 track-position 2: ~A" (track-position trk 1)))
	    (if (not (= (track-frames trk 0) 30)) (snd-display ";chn0 track-frames 2: ~A" (track-frames trk 0)))
	    (if (not (= (track-frames trk 1) 30)) (snd-display ";chn1 track-frames 2: ~A" (track-frames trk 1)))
	    (if (not (= (mix-position mix3) 40)) (snd-display ";chn0 track-position mix3 2: ~A" (mix-position mix3)))
	    (if (not (= (mix-position mix4) 40)) (snd-display ";chn1 track-position mix4 2: ~A" (mix-position mix4)))
	    (close-sound ind))
	  
	  (let* ((ind0 (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track tests" 60))
		 (ind1 (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track tests" 60)))
	    (mix-vct (make-vct 3 .5) 10 ind0 0 #f)
	    (mix-vct (make-vct 3 .2) 40 ind0 0 #f)
	    (let* ((mix1 (mix-vct (make-vct 3 .5) 10 ind1 0 #t))
		   (mix2 (mix-vct (make-vct 3 .2) 40 ind1 0 #t))
		   (trk (make-track mix1 mix2)))
	      (filter-sound (vct .1 .2 .3 .3 .2 .1) 6 ind0 0)
	      (filter-track trk (list .1 .2 .3 .3 .2 .1))
	      (if (not (= (edit-position ind0 0) 3)) (snd-display ";filter-sound edpos: ~A" (edit-position ind0 0)))
	      (if (not (= (edit-position ind1 0) 4)) (snd-display ";filter-track edpos: ~A" (edit-position ind1 0)))
	      (if (or (fneq (maxamp ind0 0) .4)
		      (fneq (maxamp ind1 0) .4))
		  (snd-display ";filter-track maxamps: ~A ~A" (maxamp ind0 0) (maxamp ind 0)))
	      (if (not (vvequal (channel->vct 0 50 ind0 0) (channel->vct 0 50 ind1 0)))
		  (snd-display ";filters not the same: ~A ~A" (channel->vct 0 50 ind0 0) (channel->vct 0 50 ind1 0)))
	      (close-sound ind0)
	      (close-sound ind1)))

	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 4 "track->vct tests" 1000))      
	  (let* ((trk (make-track))
		 (mix1 (mix-vct (make-vct 10 .5) 10 ind 0 #t "snd-test" trk))
		 (mix2 (mix-vct (make-vct 10 .25) 20 ind 1 #t "snd-test" trk))
		 (mix3 (mix-vct (make-vct 10 .3) 30 ind 2 #t "snd-test" trk))
		 (mix4 (mix-vct (make-vct 10 .1) 40 ind 1 #t "snd-test" trk)))
	    (if (not (= (track-chans trk) 3)) (snd-display ";tracks chans arg: ~A" (track-chans trk)))
	    (let ((v (track->vct trk 0)))
	      (if (not (vvequal v (make-vct 10 .5))) (snd-display ";track->vct 0: ~A" v))
	      (set! v (track->vct trk 2))
	      (if (not (vvequal v (make-vct 10 .3))) (snd-display ";track->vct 2: ~A" v))
	      (set! v (track->vct trk 1))
	      (let ((v1 (make-vct 30 0.0)))
		(do ((i 0 (1+ i))
		     (j 20 (1+ j)))
		    ((= i 10))
		  (vct-set! v1 i .25)
		  (vct-set! v1 j .1))
		(if (not (vvequal v v1)) (snd-display ";track->vct 3: ~A" v))))
	    (let ((tag (catch #t (lambda () (track->vct trk 3)) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-channel)) (snd-display ";track->vct track 3: ~A" tag)))
	    (let ((tag (catch #t (lambda () (track->vct (+ trk 123))) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-track)) (snd-display ";track->vct untrack: ~A" tag)))
	    (save-track trk "test.snd")
	    (let ((ind0 (open-sound "test.snd")))
	      (if (not (= (chans ind0) 3)) (snd-display ";save-track chans: ~A" (chans ind0)))
	      (if (not (= (frames ind0) 40)) (snd-display ";save-track frames: ~A" (frames ind0)))
	      (if (not (feql (maxamp ind0 #t) (list .5 .25 .3))) (snd-display ";save-track maxamp: ~A" (maxamp ind0 #t)))
	      (let ((v (channel->vct 0 20 ind0 0))
		    (v1 (make-vct 20)))
		(do ((i 0 (1+ i))) ((= i 10)) (vct-set! v1 i .5))
		(if (not (vvequal v v1)) (snd-display ";save-track 0: ~A" v)))
	      (let ((tag (catch #t (lambda () (save-track trk "test.snd" 3)) (lambda args (car args)))))
		(if (not (eq? tag 'no-such-channel)) (snd-display ";save-track track 3: ~A" tag)))
	      (let ((tag (catch #t (lambda () (save-track (+ trk 123) "test.snd")) (lambda args (car args)))))
		(if (not (eq? tag 'no-such-track)) (snd-display ";save-track untrack: ~A" tag)))
	      (close-sound ind0))
	    (save-track trk "test.snd" 1)
	    (let ((ind0 (open-sound "test.snd")))
	      (if (not (= (chans ind0) 1)) (snd-display ";save-track chan1: ~A" (chans ind0)))
	      (if (not (= (frames ind0) 30)) (snd-display ";save-track chan1 frames: ~A" (frames ind0)))
	      (if (fneq (maxamp ind0 0) .25) (snd-display ";save-track maxamp chan1: ~A" (maxamp ind0 0)))
	      (let ((v (channel->vct 0 30 ind0 0))
		    (v1 (make-vct 30)))
		(do ((i 0 (1+ i))
		     (j 20 (1+ j)))
		    ((= i 10))
		  (vct-set! v1 i .25)
		  (vct-set! v1 j .1))
		(if (not (vvequal v v1)) (snd-display ";save-track chan1: ~A" v)))
	      (close-sound ind0))

	    (close-sound ind)
	    (let ((tag (catch #t (lambda () (save-track trk "test.snd")) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-channel)) (snd-display ";save-track empty track: ~A" tag)))
	    (let ((tag (catch #t (lambda () (save-track trk "test.snd" 1)) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-channel)) (snd-display ";save-track empty track (1): ~A" tag)))
	    (let ((tag (catch #t (lambda () (track->vct trk)) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-channel)) (snd-display ";track->vct empty track: ~A" tag)))
	    (let ((tag (catch #t (lambda () (track->vct trk 1)) (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-channel)) (snd-display ";track->vct empty track (1): ~A" tag))))

	  (if (provided? 'snd-debug)
	      ;;window_env: env *e, off_t local_beg, off_t local_dur, off_t e_beg, off_t e_dur
	      ;;multiply_envs: env *e1, env *e2, Float maxx
	      (begin
		(if (not (feql (window-env '(0 0 1 1) 0 100 0 500) '(0.0 0.0 1.0 0.2))) 
		    (snd-display ";window-env 1: ~A" (window-env '(0 0 1 1) 0 100 0 500)))
		(if (not (feql (window-env '(0 0 1 1) 0 500 0 500) '(0.0 0.0 1.0 1.0))) 
		    (snd-display ";window-env 2: ~A" (window-env '(0 0 1 1) 0 500 0 500)))
		(if (not (feql (window-env '(0 0 1 1) 100 200 0 500) '(0.0 0.2 1.0 0.6)))
		    (snd-display ";window-env 3: ~A" (window-env '(0 0 1 1) 100 200 0 500)))
		(if (not (feql (window-env '(0 0 1 1 2 0) 100 300 0 500) '(0.0 0.4 0.5 1.0 1.0 0.4)))
		    (snd-display ";window-env 4: ~A" (window-env '(0 0 1 1 2 0) 100 300 0 500)))
		(if (not (feql (window-env '(0 0 1 1 2 0) 100 400 0 500) '(0.0 0.4 0.375 1.0 1.0 0.0)))
		    (snd-display ";window-env 4: ~A" (window-env '(0 0 1 1 2 0) 100 400 0 500)))

		(if (not (feql (invert-env '(0 0 1 1)) '(0 1 1 0)))
		    (snd-display ";invert-env ramp: ~A" (invert-env '(0 0 1 1))))
		(if (not (feql (invert-env '(0 0 1 1 2 0.5)) '(0 1 1 0 2 0.5)))
		    (snd-display ";invert-env ramp 1: ~A" (invert-env '(0 0 1 1 2 0.5))))

		(if (not (feql (multiply-envs '(0 0 1 1) '(0 0 1 1) .2) '(0.0 0.0 0.2 0.04 0.4 0.16 0.6 0.36 0.8 0.64 1.0 1.0)))
		    (snd-display ";multiply-envs: ~A" (multiply-envs '(0 0 1 1) '(0 0 1 1) .2)))
		(if (not (feql (multiply-envs '(0 0 1 1) '(0 0 .5 1 1 0) .2) '(0.0 0.0 0.2 0.08 0.4 0.32 0.5 0.5 0.7 0.42 0.9 0.18 1.0 0.0)))
		    (snd-display ";multiply-envs 1: ~A" (multiply-envs '(0 0 1 1) '(0 0 .5 1 1 0) .2)))))
	  
	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track amp-env tests" 300))
	  (let ((track0 (make-track)))
	    (set! (track-amp-env track0) '(0 0 1 1))
	    (set! (track-position track0) 123)
	    (set! (track-speed track0) .5)
	    (set! (track-speed track0) 1.0)
	    (let ((mix1 (mix-vct (make-vct 10 1.0) 10)))
	      (set! (mix-track mix1) track0)
	      (let ((tdata (track->vct track0))
		    (mdata (mix->vct mix1)))
		(if (not (vequal tdata mdata)) (snd-display ";1 mix track: ~A ~A" tdata mdata)))
	      (set! (mix-position mix1) 30)
	      (if (not (= (track-position track0) 30)) (snd-display ";mix-pos change track-pos: ~A ~A" (mix-position mix1) (track-position track0)))
	      ))
	  (close-sound ind)

	  (set! ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track amp-env tests" 300))      
	  (let* ((trk (make-track))
		 (mix1 (mix-vct (make-vct 100 .5) 0 ind 0 #t "snd-test" trk))
		 (mix2 (mix-vct (make-vct 100 .3) 200 ind 0 #t "snd-test" trk))
		 (edpos (edit-position ind 0)))

	    (define (veqerr v0 v1 err)
	      (let ((this-err (vct-peak (vct-subtract! (vct-copy v0) v1))))
		;(if (< (* 2 this-err) err) (snd-display ";veqerr: ~A ~A" this-err err))
		(<= this-err err)))

	    (let ((data (channel->vct 0 300 ind 0))
		  (vdata (make-vct 300))
		  (e (make-env '(0 0 1 1) :end 299)))
	      (do ((i 0 (1+ i))
		   (j 200 (1+ j)))
		  ((= i 100))
		(vct-set! vdata i .5)
		(vct-set! vdata j .3))
	      (if (not (veqerr data vdata .00001)) (snd-display ";track not yet ramped: ~A ~A" data vdata))
	      (set! (track-amp-env trk) '(0 0 1 1))
	      (do ((i 0 (1+ i))) ((= i 300)) (vct-set! vdata i (* (vct-ref vdata i) (env e))))
	      (set! data (channel->vct 0 300 ind 0))
	      (if (not (veqerr data vdata .002)) (snd-display ";track-amp-env ramped: ~A ~A" data vdata))
	      (if (not (= (edit-position ind 0) (1+ edpos))) (snd-display ";track-amp-env ramped not atomic? ~A ~A" edpos (edit-position ind 0)))
	      (set! (mix-amp-env mix1) '(0 1 1 0))
	      (if (not (= (edit-position ind 0) (+ edpos 2))) (snd-display ";mix-amp-env ramped not atomic? ~A ~A" edpos (edit-position ind 0)))
	      (set! data (channel->vct 0 300 ind 0))
	      (set! e (make-env '(0 1 1 0) :end 99))
	      (do ((i 0 (1+ i))) ((= i 100)) (vct-set! vdata i (* (vct-ref vdata i) (env e))))
	      (if (not (veqerr data vdata .001)) (snd-display ";track-amp-env + mix-amp-env ramped: ~A ~A" data vdata))
	      (set! (mix-amp mix1) 2.0)
	      (if (not (= (edit-position ind 0) (+ edpos 3))) (snd-display ";mix-amp ramped not atomic? ~A ~A" edpos (edit-position ind 0)))
	      (set! data (channel->vct 0 300 ind 0))
	      (do ((i 0 (1+ i))) ((= i 100)) (vct-set! vdata i (* 2 (vct-ref vdata i))))
	      (if (not (veqerr data vdata .001)) (snd-display ";track-amp-env + mix-amp-env + amp ramped: ~A ~A" data vdata))
	      (set! (track-position trk) 100)
	      (if (not (= (edit-position ind 0) (+ edpos 4))) (snd-display ";track-pos+amp-env ramped not atomic? ~A ~A" edpos (edit-position ind 0)))
	      (if (not (= (frames ind 0) 400)) (snd-display ";set track position extend file: ~A" (frames ind 0)))
	      (if (not (= (track-frames trk) 300)) (snd-display ";set track position extend file track: ~A" (track-frames trk)))
	      (set! data (channel->vct 100 300 ind 0))
	      (if (not (veqerr data vdata .001)) (snd-display ";track-amp-env + mix-amp-env + amp ramped + position: ~A ~A" data vdata))	      

	      (set! (mix-amp-env mix1) #f)
	      (set! (mix-amp mix2 0) (/ 10.0 3.0))
	      (set! e (make-env '(0 0 1 1) :end 299))
	      (do ((i 0 (1+ i))
		   (j 200 (1+ j)))
		  ((= i 100))
		(vct-set! vdata i 1.0)
		(vct-set! vdata j 1.0))
	      (do ((i 0 (1+ i)))
		  ((= i 300))
		(vct-set! vdata i (* (env e) (vct-ref vdata i))))
	      (set! data (channel->vct 100 300 ind 0))
	      (if (not (veqerr data vdata .003)) (snd-display ";track-amp-env to 1.0: ~A ~A" data vdata))	      
	      (set! (track-speed trk) 0.5)
	      (if (not (= (track-frames trk) 400)) (snd-display ";track frames after speed+amp-env: ~A" (track-frames trk)))
	      (if (not (= (frames ind 0) 500)) (snd-display ";set track speed extend file: ~A" (frames ind 0)))
	      (if (or (fneq (sample 100) 0.0)
		      (fneqerr (sample 200) 0.25 .0015)
		      (fneqerr (sample 400) 0.75 .0015))
		  (snd-display ";track-amp-env+speed0.5 samps: ~A ~A ~A" (sample 100) (sample 200) (sample 400)))
	      
	      (revert-sound ind)
	      (set! mix1 (mix-vct (make-vct 100 1.0) 0 ind 0 #t "snd-test" trk))
	      (set! mix2 (mix-vct (make-vct 100 1.0) 100 ind 0 #t "snd-test" trk))
	      (if (not (equal? (track trk) (list mix1 mix2))) (snd-display ";unset track upon revert? ~A ~A" (track trk) (list mix1 mix2)))
	      (set! (track-amp-env trk) '(0 0 1 1))
	      (if (or (fneq (sample 0) 0.0)
		      (fneq (sample 50) 0.252)
		      (fneq (sample 99) 0.5)
		      (fneq (sample 100) 0.5)
		      (fneq (sample 199) 1.0))
		  (snd-display ";mix-speed/position track + track-amp-env: ~A"
			       (map sample (list 0 50 99 100 199))))
	      (set! (mix-speed mix2) 0.25)
	      (if (or (fneq (sample 0) 0.0)
		      (fneq (sample 50) 0.101)
		      (fneq (sample 99) 0.2)
		      (fneq (sample 100) 0.2)
		      (fneq (sample 200) 0.4)
		      (fneqerr (sample 300) 0.6 .003)
		      (fneqerr (sample 400) 0.801 .01)
		      (fneqerr (sample 450) 0.900 .01))
		  (snd-display ";mix-speed lengthens track + track-amp-env: ~A"
			       (map sample (list 0 50 99 100 200 300 400 450))))
	      (undo)
	      (set! (mix-speed mix2) 2.0)
	      (if (or (fneq (sample 0) 0.0)
		      (fneq (sample 50) 0.337)
		      (fneq (sample 99) 0.667)
		      (fneqerr (sample 110) 0.730 .1) ; (try to) avoid end points that are sinc functions
		      (fneqerr (sample 135) 0.900 .1) ; da same
		      (fneq (sample 151) 0.0)
		      (fneq (sample 200) 0.0))
		  (snd-display ";mix-speed shortens track + track-amp-env: ~A"
			       (map sample (list 0 50 99 110 135 151 200))))
	      (undo)
	      (set! (mix-position mix2) 400)
	      (if (or (fneq (sample 0) 0.0)
		      (fneq (sample 50) 0.101)
		      (fneq (sample 99) 0.2)
		      (fneq (sample 100) 0.0)
		      (fneq (sample 200) 0.0)
		      (fneq (sample 300) 0.0)
		      (fneq (sample 400) 0.8)
		      (fneq (sample 450) 0.901))
		  (snd-display ";mix-position lengthens track + track-amp-env: ~A"
			       (map sample (list 0 50 99 100 200 300 400 450))))
	      (undo)
	      (set! (track-position trk) 300)
	      (set! (mix-position mix1) 0)
	      (if (or (fneq (sample 0) 0.0)
		      (fneq (sample 50) 0.101)
		      (fneq (sample 99) 0.2)
		      (fneq (sample 100) 0.0)
		      (fneq (sample 200) 0.0)
		      (fneq (sample 300) 0.0)
		      (fneq (sample 400) 0.8)
		      (fneq (sample 450) 0.901))
		  (snd-display ";mix-position (backwards) lengthens track + track-amp-env: ~A"
			       (map sample (list 0 50 99 100 200 300 400 450))))
	      (undo 2)
	      (set! (mix-position mix2) 50)
	      (if (or (fneq (sample 0) 0.0)   ; 1 is 0 to .67, 2 is .3 to 1
		      (fneq (sample 49) 0.33)
		      (fneq (sample 50) 0.67) ; both are at .3
		      (fneq (sample 99) 1.33) ; both .67
		      (fneq (sample 100) 0.67)
		      (fneq (sample 149) 1.0)
		      (fneq (sample 200) 0.0))
		  (snd-display ";mix-position 2 shortens track + track-amp-env: ~A"
			       (map sample (list 0 49 50 99 100 149 200))))
	      (undo)
	      (set! (mix-position mix1) 100)
	      (if (or (fneq (sample 0) 0.0)
		      (fneq (sample 50) 0.0)
		      (fneq (sample 99) 0.0)
		      (fneq (sample 100) 0.0)
		      (fneq (sample 150) 1.01)
		      (fneq (sample 199) 2.0)
		      (fneq (sample 200) 0.0))
		  (snd-display ";mix-position 1 shortens track + track-amp-env: ~A"
			       (map sample (list 0 50 99 100 150 199 200))))
	      (undo)

	      ))
	  (close-sound ind)

	  (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 2 "multi-channel track position tests" 300))
		 (mix1 (mix-vct (make-vct 10 1.0) 0 ind 0))
		 (mix2 (mix-vct (make-vct 10 1.0) 200 ind 1))
		 (trk (make-track mix1 mix2)))
	    (if (not (= (track-chans trk) 2)) (snd-display ";2chan track-position tests off to bad start: ~A" (track-chans trk)))
	    (if (or (not (= (track-position trk 0) 0))
		    (not (= (track-position trk 1) 200))
		    (not (= (track-position trk) 0))
		    (not (= (mix-position mix1) 0))
		    (not (= (mix-position mix2) 200)))
		(snd-display ";2chan track-position pos: ~A ~A ~A ~A ~A" 
			     (track-position trk 0) (track-position trk 1) (track-position trk)
			     (mix-position mix1) (mix-position mix2)))
	    (set! (track-position trk 0) 25)
	    (if (or (not (= (track-position trk 0) 25))
		    (not (= (track-position trk 1) 200))
		    (not (= (track-position trk) 25))
		    (not (= (mix-position mix1) 25))
		    (not (= (mix-position mix2) 200)))
		(snd-display ";2chan track-position pos 2: ~A ~A ~A ~A ~A" 
			     (track-position trk 0) (track-position trk 1) (track-position trk)
			     (mix-position mix1) (mix-position mix2)))
	    (set! (track-position trk 1) 100)
	    (if (or (not (= (track-position trk 0) 25))
		    (not (= (track-position trk 1) 100))
		    (not (= (track-position trk) 25))
		    (not (= (mix-position mix1) 25))
		    (not (= (mix-position mix2) 100)))
		(snd-display ";2chan track-position pos 3: ~A ~A ~A ~A ~A" 
			     (track-position trk 0) (track-position trk 1) (track-position trk)
			     (mix-position mix1) (mix-position mix2)))
	    (set! (track-position trk 1) 10)
	    (if (or (not (= (track-position trk 0) 25))
		    (not (= (track-position trk 1) 10))
		    (not (= (track-position trk) 10))
		    (not (= (mix-position mix1) 25))
		    (not (= (mix-position mix2) 10)))
		(snd-display ";2chan track-position pos 4: ~A ~A ~A ~A ~A" 
			     (track-position trk 0) (track-position trk 1) (track-position trk)
			     (mix-position mix1) (mix-position mix2)))
	    (set! (mix-position mix1) 0)
	    (set! (mix-position mix2) 200)
	    (if (or (not (= (track-position trk 0) 0))
		    (not (= (track-position trk 1) 200))
		    (not (= (track-position trk) 0))
		    (not (= (mix-position mix1) 0))
		    (not (= (mix-position mix2) 200)))
		(snd-display ";2chan track-position pos: ~A ~A ~A ~A ~A" 
			     (track-position trk 0) (track-position trk 1) (track-position trk)
			     (mix-position mix1) (mix-position mix2)))
	    (set! (track-amp-env trk) '(0 0 1 1))
	    (if (or (not (vequal (track->vct trk 0) (vct 0.000 0.005 0.011 0.016 0.021 0.026 0.032 0.037 0.042 0.048)))
		    (not (vequal (track->vct trk 1) (vct 0.952 0.958 0.963 0.968 0.974 0.979 0.984 0.989 0.995 1.000))))
		(snd-display ";2chan track-pos amp-env: ~A ~A" (track->vct trk 0) (track->vct trk 1)))
	    (set! (track-position trk 0) 100)
	    (if (or (not (vequal (track->vct trk 0) (vct 0.000 0.010 0.020 0.030 0.040 0.051 0.061 0.071 0.081 0.091)))
		    (not (vequal (track->vct trk 1) (vct 0.909 0.919 0.929 0.939 0.949 0.960 0.970 0.980 0.990 1.000))))
		(snd-display ";2chan track-pos amp-env 2: ~A ~A" (track->vct trk 0) (track->vct trk 1)))
	    (set! (track-position trk 1) 100)
	    (if (or (not (vequal (track->vct trk 0) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
		    (not (vequal (track->vct trk 1) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000))))
		(snd-display ";2chan track-pos amp-env 3: ~A ~A" (track->vct trk 0) (track->vct trk 1)))
	    (set! (track-position trk 1) 0)
	    (if (or (not (vequal (track->vct trk 1) (vct 0.000 0.010 0.020 0.030 0.040 0.051 0.061 0.071 0.081 0.091)))
		    (not (vequal (track->vct trk 0) (vct 0.909 0.919 0.929 0.939 0.949 0.960 0.970 0.980 0.990 1.000))))
		(snd-display ";2chan track-pos amp-env 4: ~A ~A" (track->vct trk 0) (track->vct trk 1)))
	    (let ((mix3 (mix-vct (make-vct 10 1.0) 200 ind 1)))
	      (set! (mix-track mix3) trk))
	    (if (or (not (vequal (track->vct trk 0) (vct 0.476 0.481 0.487 0.492 0.497 0.503 0.508 0.513 0.519 0.524)))
		    (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.005 0.011 0.016 0.021 0.026 0.032 0.037 0.042 0.048)))
		    (not (vequal (channel->vct 200 10 ind 1) (vct 0.952 0.958 0.963 0.968 0.974 0.979 0.984 0.989 0.995 1.000))))
		(snd-display ";2chan track-pos amp-env 5: ~A ~A" (track->vct trk 0) (track->vct trk 1)))
	    (let ((edpos (edit-position ind 1)))
	      (set! (track-position trk 0) 50)
	      (if (not (= (edit-position ind 1) edpos)) (snd-display ";set track pos changed edpos: ~A ~A" edpos (edit-position ind 1)))
	      (if (or (not (vequal (track->vct trk 0) (vct 0.238 0.243 0.249 0.254 0.259 0.265 0.270 0.275 0.280 0.286)))
		      (not (vequal (channel->vct 0 10 ind 1) (vct 0.000 0.005 0.011 0.016 0.021 0.026 0.032 0.037 0.042 0.048)))
		      (not (vequal (channel->vct 200 10 ind 1) (vct 0.952 0.958 0.963 0.968 0.974 0.979 0.984 0.989 0.995 1.000))))
		  (snd-display ";2chan track-pos amp-env 6: ~A ~A" (track->vct trk 0) (track->vct trk 1))))
	    (close-sound ind))

	  (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "multi-channel track position tests" 300))
		 (mix1 (mix-vct (make-vct 10 1.0) 0 ind 0))
		 (trk (make-track)))
	    (set! (track-amp-env trk) '(0 0 1 1))
	    (if (not (feql (track-amp-env trk) (list 0 0 1 1)))
		(snd-display ";empty track env: ~A" (track-amp-env trk)))
	    (set! (mix-track mix1) trk)
	    (if (not (vequal (track->vct trk) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
		(snd-display ";track amp-env 1 mix: ~A" (track->vct trk)))
	    (set! (track-position trk) 10)
	    (if (not (vequal (channel->vct 0 20 ind 0) (vct 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
							    0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
		(snd-display ";move 1 mix track + env: ~A" (channel->vct 0 20 ind 0)))
	    (if (not (vequal (mix->vct mix1) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
		(snd-display ";track amp-env 1 mix->vct: ~A" (mix->vct mix1)))
	    (set! (mix-track mix1) 0)
	    (if (not (vequal (mix->vct mix1) (vct 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
		(snd-display ";untrack mix -> vct: ~A" (mix->vct mix1)))
	    (if (not (feql (track-amp-env trk) (list 0 0 1 1)))
		(snd-display ";newly empty track env: ~A" (track-amp-env trk)))
	    (set! (mix-speed mix1) 0.5)
	    (set! (mix-track mix1) trk)
	    (if (or (not (= (mix-frames mix1) 20))
		    (not (= (track-frames trk) 20)))
		(snd-display ";mix-speed for track frames: ~A ~A" (mix-frames mix1) (track-frames trk)))
	    (if (or (fneq (sample 30) 0.0) (fneq (sample 10) 0.0) (fneq (sample 20) 0.526))
		(snd-display ";mix-speed + track amp env: ~A" (track->vct trk)))
	    (set! (track-speed trk) 2.0)
	    (if (or (not (= (mix-frames mix1) 10))
		    (not (= (track-frames trk) 10)))
		(snd-display ";mix-speed (2) for track frames: ~A ~A" (mix-frames mix1) (track-frames trk)))
	    (if (not (vequal (track->vct trk) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000)))
		(snd-display ";mix+track speed + amp-env: ~A" (track->vct trk)))
	    (close-sound ind))

	  (let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track + track tests" 300)))
	    (let ((mix1 (mix-vct (make-vct 10 1.0) 20 ind 0))
		  (track1 (make-track))
		  (track2 (make-track))
		  (edpos (edit-position ind 0)))
	      ;; track->track+env
	      (set! (track-amp-env track2) '(0 0 1 1))
	      (set! (track-track track1) track2)
	      (set! (mix-track mix1) track1)
	      (if (not (equal? (track track1) (track track2) (list mix1)))
		  (snd-display ";embedded track: ~A ~A ~A" (track track1) (track track2) (list mix1)))
	      (if (not (= 20 (mix-position mix1) (track-position track1) (track-position track2)))
		  (snd-display ";embedded track pos: ~A ~A ~A" (mix-position mix1) (track-position track1) (track-position track2)))
	      (if (not (= 10 (mix-frames mix1) (track-frames track1) (track-frames track2)))
		  (snd-display ";embedded track dur: ~A ~A ~A" (mix-frames mix1) (track-frames track1) (track-frames track2)))
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000))))
		  (snd-display ";embedded track amp-env(t->e): ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (set! edpos (edit-position ind 0))
	      (set! (track-position track1) 50)
	      (if (not (= 50 (mix-position mix1) (track-position track1) (track-position track2)))
		  (snd-display ";embedded track set pos: ~A ~A ~A" (mix-position mix1) (track-position track1) (track-position track2)))
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000))))
		  (snd-display ";embedded track amp-env(t->e) set pos: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (set! (edit-position ind 0) edpos)
	      (set! (track-position track2) 50)
	      (if (not (= 50 (mix-position mix1) (track-position track1) (track-position track2)))
		  (snd-display ";embedded track set pos 1: ~A ~A ~A" (mix-position mix1) (track-position track1) (track-position track2)))
	      (set! (edit-position ind 0) edpos)
	      (set! (mix-position mix1) 50)
	      (if (not (= 50 (mix-position mix1) (track-position track1) (track-position track2)))
		  (snd-display ";embedded track set pos 2: ~A ~A ~A" (mix-position mix1) (track-position track1) (track-position track2)))
	      (set! (edit-position ind 0) edpos)
	      (set! (track-speed track2) 0.5)
	      (if (not (= 20 (mix-frames mix1) (track-frames track1) (track-frames track2)))
		  (snd-display ";embedded track set speed: ~A ~A ~A" (mix-frames mix1) (track-frames track1) (track-frames track2)))
	      (set! (edit-position ind 0) edpos)
	      (set! (track-speed track1) 0.5)
	      (if (not (= 20 (mix-frames mix1) (track-frames track1) (track-frames track2)))
		  (snd-display ";embedded track set speed 1: ~A ~A ~A" (mix-frames mix1) (track-frames track1) (track-frames track2)))
	      (set! (edit-position ind 0) edpos)
	      (set! (mix-speed mix1) 0.5)
	      (if (not (= 20 (mix-frames mix1) (track-frames track1) (track-frames track2)))
		  (snd-display ";embedded track set speed 2: ~A ~A ~A" (mix-frames mix1) (track-frames track1) (track-frames track2)))
	      (set! (edit-position ind 0) edpos)
	      (if (not (= 10 (mix-frames mix1) (track-frames track1) (track-frames track2)))
		  (snd-display ";embedded track undo set speed: ~A ~A ~A" (mix-frames mix1) (track-frames track1) (track-frames track2)))
	      (set! (track-amp track2) 0.5)
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct-scale! (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000) 0.5))))
		  (snd-display ";embedded track set amp(t->e): ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (undo)
	      (set! (track-amp track1) 0.5)
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct-scale! (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000) 0.5))))
		  (snd-display ";embedded track set amp(t->e) 1: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (undo)
	      (set! (mix-amp mix1) 0.5)
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct-scale! (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000) 0.5))))
		  (snd-display ";embedded track set amp(t->e) 2: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (undo)
	      (set! (track-amp-env track2) #f)
	      (set! (track-amp-env track1) '(0 0 1 1))
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000))))
		  (snd-display ";embedded track amp-env(t->e) 1: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (set! (mix-amp-env mix1 0) '(0 0 1 1))
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.0))))
		  (snd-display ";embedded track amp-env(t->e) 2: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (set! (track-amp-env track2) '(0 0 1 1))
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1.0))))
		  (snd-display ";embedded track amp-env(t->e) 3: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (set! (mix-amp-env mix1 0) #f)
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 1.0))))
		  (snd-display ";embedded track amp-env(t->e) 4: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (set! (track-amp-env track1) #f)
	      (if (or (not (vequal (mix->vct mix1) (track->vct track1)))
		      (not (vequal (mix->vct mix1) (track->vct track2)))
		      (not (vequal (track->vct track2) (vct 0.000 0.111 0.222 0.333 0.444 0.556 0.667 0.778 0.889 1.000))))
		  (snd-display ";embedded track amp-env(t->e) 1: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
	      (if (not (= 10 (mix-frames mix1) (track-frames track1) (track-frames track2)))
		  (snd-display ";embedded track dur back out: ~A ~A ~A" (mix-frames mix1) (track-frames track1) (track-frames track2)))
		
	      ;; two mixes track(1)+track-amp-env
	      (let ((mix2 (mix-vct (make-vct 10 1.0) 30 ind 0)))
		(set! (mix-track mix2) track1)
		;; technically the end point is off by 1, so we get the .5's repeated, but
		;;   this seems cleaner to me than "the right thing" -- the user will be
		;;   expecting end point matches, and in any case a 10-sample mix is silly
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
								     0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000))))
		    (snd-display ";embedded track 2mix ampenv: ~A" (channel->vct 20 20 ind 0)))
		(set! (mix-track mix2) track2)
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
								     0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000))))
		    (snd-display ";embedded track 2mix ampenv (2): ~A" (channel->vct 20 20 ind 0)))
		(set! (mix-track mix2) track1)
		(if (not (equal? (track track1) (track track2) (list mix1 mix2)))
		    (snd-display ";embedded track 2mix: ~A ~A ~A" (track track1) (track track2) (list mix1 mix2)))
		(if (not (= 20 (track-position track1) (track-position track2)))
		    (snd-display ";embedded track pos 2mix: ~A ~A" (track-position track1) (track-position track2)))
		(if (not (= 20 (track-frames track1) (track-frames track2)))
		    (snd-display ";embedded track dur 2mix: ~A ~A" (track-frames track1) (track-frames track2)))
		(set! (track-position track1) 50)
		(if (not (= 50 (mix-position mix1) (track-position track1) (track-position track2)))
		    (snd-display ";embedded track set pos 2mix: ~A ~A ~A" (mix-position mix1) (track-position track1) (track-position track2)))
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 50 20 ind 0) (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
								     0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000))))
		    (snd-display ";embedded track amp-env(t->e) set pos 2mix: ~A ~A ~A" (track->vct track1) (track->vct track2) (mix->vct mix1)))
		(undo)
		(set! (track-position track2) 50)
		(if (not (= 50 (mix-position mix1) (track-position track1) (track-position track2)))
		    (snd-display ";embedded track set pos 2mix 2: ~A ~A ~A" (mix-position mix1) (track-position track1) (track-position track2)))
		(undo)
		(set! (track-speed track2) 0.5)
		(if (not (= 30 (track-frames track1) (track-frames track2)))
		    (snd-display ";embedded track set speed 2mix: ~A ~A" (track-frames track1) (track-frames track2)))
		(undo)
		(set! (track-speed track1) 0.5)
		(if (not (= 30 (track-frames track1) (track-frames track2)))
		    (snd-display ";embedded track set speed 1: ~A ~A" (track-frames track1) (track-frames track2)))
		(undo)
		(set! (track-amp track2) 0.5)
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct-scale! (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
										 0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000) 0.5))))
		    (snd-display ";embedded track amp(t->e) set pos 2mix 2: ~A" (channel->vct 20 20 ind 0)))
		(undo)
		(set! (track-amp track1) 0.5)
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct-scale! (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
										 0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000) 0.5))))
		    (snd-display ";embedded track amp(t->e) set pos 2mix 3: ~A" (channel->vct 20 20 ind 0)))
		(undo)
		(set! (mix-amp mix1) 0.5)
		(set! (mix-amp mix2) 0.5)
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct-scale! (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
										 0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000) 0.5))))
		    (snd-display ";embedded track amp(t->e) set pos 2mix 4: ~A" (channel->vct 20 20 ind 0)))
		(undo 2)
		(set! (track-amp-env track2) #f)
		(set! (track-amp-env track1) '(0 0 1 1))
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct 0.000 0.056 0.111 0.167 0.222 0.278 0.333 0.389 0.444 0.500 
								     0.500 0.556 0.611 0.667 0.722 0.778 0.833 0.889 0.944 1.000))))
		    (snd-display ";embedded track amp-env(t->e) 2mix 1: ~A" (channel->vct 20 20 ind 0)))
		(set! (track-amp-env track2) '(0 0 1 1))
		;; here we're getting the 1/10 resampling inaccuracies
		(if (or (not (vequal (track->vct track1) (track->vct track2)))
			(not (vequal (channel->vct 20 20 ind 0) (vct 0.000 0.002 0.010 0.022 0.040 0.062 0.090 0.122 0.160 0.202 
								     0.250 0.303 0.360 0.422 0.490 0.562 0.640 0.722 0.810 0.903))))
		    (snd-display ";embedded track amp-env(t->e) 2mix 3: ~A" (channel->vct 20 20 ind 0)))

		(let* ((edpos (edit-position ind 0))
		       (track3 (make-track mix1 mix2)))

		  (if (or (not (equal? (track track3) (list mix1 mix2)))
			  (not (equal? (track track1) '()))
			  (not (equal? (track track2) '())))
		      (snd-display ";make track overrides: ~A ~A ~A" (track track1) (track track2) (track track3)))
		  (if (not (vequal (channel->vct 20 20 ind 0) (make-vct 20 1.0)))
		      (snd-display ";make-track overrides vals: ~A" (channel->vct 20 20 ind 0)))
		  (set! (edit-position ind 0) edpos)
		  (let ((track4 (make-track mix2)))
		    (if (or (not (equal? (track track4) (list mix2)))
			    (not (equal? (track track1) (list mix1)))
			    (not (equal? (track track2) (list mix1)))
			    (not (equal? (track track3) '())))
		      (snd-display ";make track again overrides: ~A ~A ~A ~A" (track track1) (track track2) (track track3) (track track4)))
		    (if (not (vequal (channel->vct 20 20 ind 0) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 
								     1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
			(snd-display ";make-track again overrides vals: ~A" (channel->vct 20 20 ind 0)))
		    (save-state "s61.scm")
		    (close-sound ind)
		    (load "s61.scm")
		    ;; this currently screws up when there's a track amp-env and a mix-track change resets the env bounds
		    (set! ind (find-sound "test.snd"))
		    (if (not (sound? ind))
			(snd-display ";can't restore test.snd: ~A?" (sounds))
			(if (not (vequal (channel->vct 20 20 ind 0) (vct 0.000 0.010 0.040 0.090 0.160 0.250 0.360 0.490 0.640 0.810 
								     1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000)))
			    (snd-display ";track save/restore: ~A" (channel->vct 20 20 ind 0))))
		    ))

	      (if (sound? ind) (close-sound ind)))))

	  ;; track-tempo tests
	  (let* ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 1 "track tests" 1000))
		 (trk (make-track))
		 (initial-edpos (edit-position ind 0)))
	    (if (fneq (track-tempo trk) 1.0) (snd-display ";initial track tempo: ~A" (track-tempo trk)))
	    (set! (track-tempo trk) 0.5)
	    (if (fneq (track-tempo trk) 0.5) (snd-display ";track-tempo set: ~A" (track-tempo trk)))
	    (if (not (= (edit-position ind 0) initial-edpos)) (snd-display ";no-op set track_tempo edits: ~A ~A" edpos (edit-position ind 0)))
	    (set! (track-tempo trk) 1.0)
	    (let ((mix0 (mix-vct (make-vct 10 .1) 100)))
	      (set! (mix-track mix0) trk)
	      (if (not (= (mix-position mix0) 100)) (snd-display ";track tempo initial mix pos: ~A" (mix-position mix0)))
	      (set! (track-tempo trk) 0.5)
	      (if (not (= (mix-position mix0) 100)) (snd-display ";track tempo mix pos: ~A" (mix-position mix0)))
	      (set! (track-tempo trk) 1.0)
	      (let ((mix1 (mix-vct (make-vct 10 .3) 300)))
		(set! (mix-track mix1) trk)
		(if (not (= (mix-position mix0) 100)) (snd-display ";track (2) tempo initial mix0 pos: ~A" (mix-position mix0)))
		(if (not (= (mix-position mix1) 300)) (snd-display ";track (2) tempo initial mix1 pos: ~A" (mix-position mix1)))
		(let ((edpos1 (edit-position ind 0)))
		  (set! (track-tempo trk) 0.5)
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track tempo (2) mix0 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 500)) (snd-display ";track tempo (2) mix1 pos: ~A" (mix-position mix1)))
		  (if (not (= (edit-position ind 0) (1+ edpos1))) (snd-display ";track tempo not atomic: ~A ~A" edpos1 (edit-position ind 0))))
		(set! (track-tempo trk) 1.0)      
		(if (not (= (mix-position mix0) 100)) (snd-display ";track (2) tempo back mix0 pos: ~A" (mix-position mix0)))
		(if (not (= (mix-position mix1) 300)) (snd-display ";track (2) tempo back mix1 pos: ~A" (mix-position mix1)))
		(set! (track-tempo trk) 2.0)
		(if (not (= (mix-position mix0) 100)) (snd-display ";track tempo (2) mix0 2 pos: ~A" (mix-position mix0)))
		(if (not (= (mix-position mix1) 200)) (snd-display ";track tempo (2) mix1 2 pos: ~A" (mix-position mix1)))
		(set! (track-tempo trk) 1.0)      
		(let ((mix2 (mix-vct (make-vct 10 .4) 400)))
		  (set! (mix-track mix2) trk)
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track (3) tempo initial mix0 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 300)) (snd-display ";track (3) tempo initial mix1 pos: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 400)) (snd-display ";track (3) tempo initial mix2 pos: ~A" (mix-position mix2)))
		  (set! (track-tempo trk) 0.5)
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track tempo (3) mix0 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 500)) (snd-display ";track tempo (3) mix1 pos: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 700)) (snd-display ";track tempo (3) mix2 pos: ~A" (mix-position mix2)))
		  (set! (track-tempo trk) 1.0)      
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track (3) tempo back mix0 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 300)) (snd-display ";track (3) tempo back mix1 pos: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 400)) (snd-display ";track (3) tempo back mix2 pos: ~A" (mix-position mix2)))
		  (set! (track-tempo trk) 2.0)
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track tempo (3) mix0 2 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 200)) (snd-display ";track tempo (3) mix1 2 pos: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 250)) (snd-display ";track tempo (3) mix2 2 pos: ~A" (mix-position mix2)))
		  
		  (set! (track-amp-env trk) '(0 0 1 1))
		  (set! (track-tempo trk) 1.0)
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track (4) tempo initial mix0 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 300)) (snd-display ";track (4) tempo initial mix1 pos: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 400)) (snd-display ";track (4) tempo initial mix2 pos: ~A" (mix-position mix2)))
		  (set! (track-amp-env trk) '(0 1 1 0))	
		  (set! (track-tempo trk) 2.0)
		  (if (not (= (mix-position mix0) 100)) (snd-display ";track tempo (4) mix0 2 pos: ~A" (mix-position mix0)))
		  (if (not (= (mix-position mix1) 200)) (snd-display ";track tempo (4) mix1 2 pos: ~A" (mix-position mix1)))
		  (if (not (= (mix-position mix2) 250)) (snd-display ";track tempo (4) mix2 2 pos: ~A" (mix-position mix2)))
		  (close-sound ind)))))

	  ;; pan-mix tests
	  (let* ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "pan-mix tests"))
		 (id0 (pan-mix "1a.snd")))
	    (if (or (not (= (mix-track id0) 0))
		    (fneq (mix-amp id0 0) 1.0)
		    (not (equal? (mix-amp-env id0 0) '())))
		(snd-display ";pan-mix 1->1 all opt: ~A ~A ~A" (mix-track id0) (mix-amp id0 0) (mix-amp-env id0 0)))
	    (if (fneq (maxamp ind 0) (mix-maxamp id0)) (snd-display ";pan-mix 1->1 maxamps: ~A ~A" (maxamp ind 0) (mix-maxamp id0)))
	    (if (not (= (mix-position id0) 0)) (snd-display ";pan-mix 1->1 pos: ~A" (mix-position id0)))
	    (if (not (= (mix-chans id0) 1)) (snd-display ";pan-mix 1->1 mix chans: ~A" (mix-chans id0)))
	    (revert-sound ind)
	    
	    (set! id0 (pan-mix "1a.snd" 10000 '(0 0 1 1)))
	    (if (or (not (= (mix-track id0) 0))
		    (fneq (mix-amp id0 0) 1.0)
		    (not (feql (mix-amp-env id0 0) '(0 0 1 1))))
		(snd-display ";pan-mix 1->1 2: ~A ~A ~A" (mix-track id0) (mix-amp id0 0) (mix-amp-env id0 0)))
	    (if (not (= (mix-position id0) 10000)) (snd-display ";pan-mix 1->1 pos 2: ~A" (mix-position id0)))
	    (revert-sound ind)
	    
	    (set! id0 (pan-mix "1a.snd" 80000 .4))
	    (if (or (not (= (mix-track id0) 0))
		    (fneq (mix-amp id0 0) 0.4)
		    (not (feql (mix-amp-env id0 0) '())))
		(snd-display ";pan-mix 1->1 3: ~A ~A ~A" (mix-track id0) (mix-amp id0 0) (mix-amp-env id0 0)))
	    (if (not (= (mix-position id0) 80000)) (snd-display ";pan-mix 1->1 pos 2: ~A" (mix-position id0)))
	    (if (not (= (frames ind 0) (+ 80000 (mus-sound-frames "1a.snd")))) (snd-display ";pan-mix past end frames: ~A" (frames ind 0)))
	    (revert-sound ind)
	    
	    (set! id0 (pan-mix "2a.snd" 100))
	    (if (or (= (mix-track id0) 0)
		    (not (mix? (1+ id0)))
		    (not (= (mix-track id0) (mix-track (1+ id0)))))
		(snd-display ";pan-mix 2->1: ~A ~A ~A" (mix-track id0) (mix? (1+ id0)) (if (mix? (1+ id0)) (mix-track (1+ id0)) #f)))
	    (if (not (= (mix-chans id0) 2)) (snd-display ";pan-mix 2->1 mix chans: ~A" (mix-chans id0)))
	    (if (not (= (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0)) 100))
		(snd-display ";pan-mix 2->1 pos: ~A ~A ~A" (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0))))
	    (if (or (fneq (mix-maxamp id0) (maxamp ind 0))
		    (fneq (mix-maxamp (1+ id0)) 0.0))
		(snd-display ";pan-mix 2->1 maxamps: ~A ~A ~A" (maxamp ind 0) (mix-maxamp id0) (mix-maxamp (1+ id0))))
	    (if (not (equal? (track (mix-track id0)) (list id0 (1+ id0)))) 
		(snd-display ";pan-mix 2->1 track: ~A ~A" (track (mix-track id0)) id0))
	    (let ((max1 (maxamp ind 0))
		  (maxid0 (mix-maxamp id0))
		  (maxid1 (mix-maxamp (1+ id0))))
	      (set! (track-amp-env (mix-track id0)) '(0 0 0 0))
	      (if (or (fneq (mix-maxamp id0) 0.0)
		      (fneq (mix-maxamp (1+ id0)) max1))
		  (snd-display ";pan-mix 2->1 maxamps (reversed): ~A ~A ~A" (maxamp ind 0) (mix-maxamp id0) (mix-maxamp (1+ id0))))
	      (revert-sound ind)
	      
	      (let ((maxs (mus-sound-maxamp "2a.snd")))
		(set! id0 (pan-mix "2a.snd" 100 .4))
		;; .4 means .4 in chan 0, .6 in chan 1
		(let ((expected-max (max (* .4 (cadr maxs)) (* .6 (list-ref maxs 3)))))
		  (if (fneq (maxamp ind 0) expected-max) (snd-display ";pan-mix scaled: ~A ~A" (maxamp ind 0) maxs)))
		(if (not (= (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0)) 100))
		    (snd-display ";pan-mix 2->1 pos 2: ~A ~A ~A" (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0))))
		(if (or (fneq (mix-amp id0 0) 1.0) (fneq (mix-amp (1+ id0) 1) 1.0))
		    (snd-display ";pan-mix 2->1 mix amps: ~A ~A" (mix-amp id0 0) (mix-amp (1+ id0) 1)))
		(if (or (fneq (mix-amp id0 1) 0.0) (fneq (mix-amp (1+ id0) 0) 0.0))
		    (snd-display ";pan-mix 2->1 mix amps (off case): ~A ~A" (mix-amp id0 1) (mix-amp (1+ id0) 0)))
		(if (not (feql (track-amp-env (mix-track id0)) '(0 .4 1.0 .4)))
		    (snd-display ";pan-mix 2->1 .4 env: ~A" (track-amp-env (mix-track id0))))
		(revert-sound ind)))
	    
	    (set! id0 (pan-mix "2a.snd" 100 '(0 0 1 1)))
	    (if (not (= (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0)) 100))
		(snd-display ";pan-mix 2->1 pos 3: ~A ~A ~A" (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0))))
	    (if (or (fneq (mix-amp id0 0) 1.0) (fneq (mix-amp (1+ id0) 1) 1.0))
		(snd-display ";pan-mix 2->1 mix amps 3: ~A ~A" (mix-amp id0 0) (mix-amp (1+ id0) 1)))
	    (if (or (fneq (mix-amp id0 1) 0.0) (fneq (mix-amp (1+ id0) 0) 0.0))
		(snd-display ";pan-mix 2->1 mix amps (off case) 3: ~A ~A" (mix-amp id0 1) (mix-amp (1+ id0) 0)))
	    (if (not (feql (track-amp-env (mix-track id0)) '(0 0 1 1)))
		(snd-display ";pan-mix 2->1 ramp env: ~A" (track-amp-env (mix-track id0))))
	    (if (or (fneq (maxamp ind 0) .0372) 
		    (fneq (maxamp ind 0) (max (mix-maxamp id0) (mix-maxamp (1+ id0)))))
		(snd-display ";ramp pan-mix 2->1 maxamp: ~A ~A ~A" (maxamp ind 0) (mix-maxamp id0) (mix-maxamp (1+ id0))))
	    (revert-sound ind)
	    
	    (mus-sound-forget "4.aiff") ; force re-read of maxamps?
	    (set! id0 (pan-mix "4.aiff" 100))
	    (if (not (= (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0)) 100))
		(snd-display ";pan-mix 4->1 pos 4: ~A ~A ~A" (mix-position id0) (mix-position (1+ id0)) (track-position (mix-track id0))))
	    (if (or (fneq (mix-amp id0 0) 1.0) (fneq (mix-amp (1+ id0) 1) 1.0))
		(snd-display ";pan-mix 4->1 mix amps 4: ~A ~A" (mix-amp id0 0) (mix-amp (1+ id0) 1)))
	    (if (or (fneq (mix-amp id0 1) 0.0) (fneq (mix-amp (1+ id0) 0) 0.0))
		(snd-display ";pan-mix 4->1 mix amps (off case) 4: ~A ~A" (mix-amp id0 1) (mix-amp (1+ id0) 0)))
	    (if (not (feql (track-amp-env (mix-track id0)) '(0 1 1 1)))
		(snd-display ";pan-mix 4->1 ramp env 4: ~A" (track-amp-env (mix-track id0))))
	    (let ((maxs (mus-sound-maxamp "4.aiff")))
	      (if (fneq (maxamp ind 0) (cadr maxs))
		  (snd-display ";ramp pan-mix 4->1 maxamp 4: ~A ~A" (maxamp ind 0) maxs))
	      (set! (track-amp-env (mix-track id0)) '(0 0 1 0))
	      (if (fneq (maxamp ind 0) (list-ref maxs 3))
		  (snd-display ";ramp pan-mix 4->1 maxamp 4(2): ~A ~A" (maxamp ind 0) maxs)))
	    (close-sound ind))

	  (let* ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "pan-mix tests"))
		 (id0 (pan-mix "1a.snd"))
		 (id1 (1+ id0))
		 (trk (mix-track id0)))
	    (if (not (track? trk)) (snd-display ";pan-mix 1->2 track: ~A?" trk))
	    (if (not (= (mix-chans id0) 1)) (snd-display ";pan-mix 1->2 mix chans: ~A" (mix-chans id0)))
	    (if (or (fneq (mix-amp id0) 1.0) (fneq (mix-amp id1) 1.0)) 
		(snd-display ";pan-mix 1->2 amps: ~A ~A" (mix-amp id0) (mix-amp id1)))
	    (if (or (fneq (maxamp ind 0) (mix-maxamp id0))
		    (fneq (maxamp ind 1) 0.0))
		(snd-display ";pan-mix 1->2 maxamps: ~A ~A ~A" (maxamp ind 0) (mix-maxamp id0) (mix-maxamp id1)))
	    (if (not (equal? (track (mix-track id0)) (list id0 id1)))
		(snd-display ";pan-mix 1->2 track: ~A ~A" (track (mix-track id0)) id0))
	    (set! (track-amp-env (mix-track id0)) '(0 0 1 0))
	    (if (or (fneq (maxamp ind 1) (mix-maxamp id1))
		    (fneq (maxamp ind 0) 0.0))
		(snd-display ";pan-mix 1->2 maxamps reversed: ~A ~A ~A" (maxamp ind #t) (mix-maxamp id0) (mix-maxamp id1)))
	    (revert-sound ind)
	    
	    (set! id0 (pan-mix "2a.snd" 100))
	    (set! id1 (1+ id0))
	    (set! trk (mix-track id0))
	    (if (not (= (mix-chans id0) 2)) (snd-display ";pan-mix 2->2 mix chans: ~A" (mix-chans id0)))
	    (if (not (equal? (track trk) (list id0 id1)))
		(snd-display ";pan-mix 2->2 track: ~A ~A" (track trk) id0))
	    (if (or (fneq (mix-amp id0 0) 1.0) (fneq (mix-amp id0 1) 0.0)
		    (fneq (mix-amp id1 0) 0.0) (fneq (mix-amp id1 1) 1.0))
		(snd-display ";pan-mix 2->2 amps: ~A ~A" (mix-amp id0 0) (mix-amp id0 1) (mix-amp id1 0) (mix-amp id1 1)))
	    (if (or (fneq (maxamp ind 0) (mix-maxamp id0))
		    (fneq (maxamp ind 1) 0.0))
		(snd-display ";pan-mix 2->2 maxamps: ~A ~A ~A" (maxamp ind 0) (mix-maxamp id0) (mix-maxamp id1)))
	    (set! (track-amp-env (mix-track id0)) '(0 0 1 0))
	    (if (or (fneq (maxamp ind 1) (mix-maxamp id1))
		    (fneq (maxamp ind 0) 0.0))
		(snd-display ";pan-mix 2->2 maxamps reversed: ~A ~A ~A" (maxamp ind #t) (mix-maxamp id0) (mix-maxamp id1)))
	    (revert-sound ind)
	    
	    (set! id0 (pan-mix "2a.snd" 1000 .4))
	    (set! id1 (1+ id0))
	    (set! trk (mix-track id0))
	    (let ((maxs (mus-sound-maxamp "2a.snd")))
	      (if (or (fneq (maxamp ind 0) (* .4 (list-ref maxs 1)))
		      (fneq (maxamp ind 1) (* .6 (list-ref maxs 3))))
		  (snd-display ";pan-mix 2->2 .4: ~A ~A" maxs (maxamp ind #t)))
	      (if (not (feql (track-amp-env trk) (list 0 .4 1 .4)))
		  (snd-display ";pan-mix 2->2 .4 env: ~A" (track-amp-env trk)))
	      (if (not (equal? (track trk) (list id0 id1)))
		  (snd-display ";pan-mix 2->2 track .4: ~A ~A" (track trk) id0))
	      (revert-sound))
	    
	    (set! id0 (pan-mix "4.aiff"))
	    (let ((maxs (mus-sound-maxamp "4.aiff")))
	      (if (or (fneq (maxamp ind 0) (list-ref maxs 1))
		      (fneq (maxamp ind 1) 0.0))
		  (snd-display ";pan-mix 4->2 max: ~A ~A" maxs (maxamp ind #t)))
	      (if (not (= (mix-chans id0) 4)) (snd-display ";pan-mix 4->2 mix chans: ~A" (mix-chans id0)))    
	      (close-sound ind))
	    
	    (set! ind (new-sound "fmv.snd" mus-next mus-bshort 22050 4 "pan-mix tests"))
	    (set! id0 (pan-mix "1a.snd"))
	    (set! id1 (1+ id0))
	    (set! trk (mix-track id0))
	    (if (not (equal? (track trk) (list id0 id1)))
		(snd-display ";pan-mix 1->4 track: ~A ~A" (track trk) id0))
	    (close-sound ind)))

	(let* ((ind (new-sound "test.snd" mus-next mus-bshort 22050 1 "pan-mix-* tests"))
	       (id0 (pan-mix-vct (make-vct 100 .3))))
	  (if (or (not (= (mix-track id0) 0))
		  (fneq (mix-amp id0 0) 1.0)
		  (not (equal? (mix-amp-env id0 0) '())))
	      (snd-display ";pan-mix-vct 1->1 all opt: ~A ~A ~A" (mix-track id0) (mix-amp id0 0) (mix-amp-env id0 0)))
	  (if (or (fneq (maxamp ind 0) (mix-maxamp id0)) 
		  (fneq (maxamp ind 0) 0.3))
	      (snd-display ";pan-mix-vct 1->1 maxamps: ~A ~A" (maxamp ind 0) (mix-maxamp id0)))
	  (if (not (= (mix-position id0) 0)) (snd-display ";pan-mix-vct 1->1 pos: ~A" (mix-position id0)))
	  (if (not (= (mix-chans id0) 1)) (snd-display ";pan-mix-vct 1->1 mix chans: ~A" (mix-chans id0)))
	  (let ((ind1 (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "pan-mix-* tests")))
	    (let ((reg (make-region 0 50 ind 0)))
	      (let ((id1 (pan-mix-region reg)))
		(if (or (fneq (maxamp ind1 0) (mix-maxamp id1)) 
			(fneq (maxamp ind1 0) 0.3))
		    (snd-display ";pan-mix-region 1->1 maxamps: ~A ~A" (maxamp ind1 0) (mix-maxamp id1)))
		(select-all)
		(revert-sound ind)
		(set! id0 (pan-mix-selection 0 1.0 ind 0))
		(if (or (fneq (maxamp ind 0) (mix-maxamp id0)) 
			(fneq (maxamp ind 0) 0.3))
		    (snd-display ";pan-mix-selection 1->1 maxamps: ~A ~A" (maxamp ind 0) (mix-maxamp id0)))
		(close-sound ind)
		(close-sound ind1)))))

	(let ((old-mix-tag (with-mix-tags)))
	  (dynamic-wind
	   (lambda () (set! (with-mix-tags) #f))
	   (lambda ()
	     (let* ((ind (new-sound "fmv.snd" mus-next mus-bshort 22050 1 "locked pan-mix tests"))
		    (id0 (pan-mix "1a.snd"))
		    (max1a (cadr (mus-sound-maxamp "1a.snd")))
		    (max2a (cadr (mus-sound-maxamp "2a.snd"))))
	       (if (or (not (mix? id0))
		       (not (mix-locked? id0)))
		   (snd-display ";no tag pan-mix: ~A ~A" id0 (mixes)))
	       (if (fneq (maxamp ind 0) max1a) (snd-display ";no-tag pan-mix 1->1 maxamps: ~A ~A" (maxamp ind 0) max1a))
	       (if (not (mix-locked? id0)) (snd-display ";no-tag pan-mix 1->1 not locked?"))
	       (revert-sound ind)
	       (set! id0 (pan-mix "2a.snd" 100))
	       (if (fneq (maxamp ind 0) max2a) (snd-display ";no-tag pan-mix 2->1 maxamps: ~A ~A" (maxamp ind 0) max2a))
	       (if (not (vequal (channel->vct 3000 10) (make-vct 10 0.0)))
		   (snd-display ";no-tag pan-mix 2->1 channel 2: ~A" (channel->vct 3000 10)))
	       (if (not (mix-locked? id0)) (snd-display ";no-tag pan-mix 2->1 not locked?"))
	       (close-sound ind)
	       (set! ind (new-sound "fmv.snd" mus-next mus-bshort 22050 2 "locked pan-mix tests"))
	       (set! id0 (pan-mix "1a.snd"))
	       (if (not (feql (maxamp ind #t) (list max1a 0.0)))
		   (snd-display ";no-tag pan-mix 1->2 maxamps: ~A ~A" (maxamp ind #t) max1a))
	       (if (not (mix-locked? id0)) (snd-display ";no-tag pan-mix 1->2 not locked?"))
	       (revert-sound ind)
	       (set! id0 (pan-mix "2a.snd" 100))
	       (if (not (feql (maxamp ind #t) (list max1a 0.0)))
		   (snd-display ";no-tag pan-mix 2->2 maxamps: ~A ~A" (maxamp ind #t) max1a))
	       (if (not (mix-locked? id0)) (snd-display ";no-tag pan-mix 2->2 not locked?"))
	       (close-sound ind)))
	   (lambda () (set! (with-mix-tags) old-mix-tag))))

	(let ((ind (new-sound "test.snd" mus-next mus-bfloat 22050 2 "copy sample-reader tests" 1000)))
	  (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 101 10 ind 0)
	  (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 201 10 ind 1)
	  (let ((rd1 (make-sample-reader 100 ind 0))
		(rd2 (make-sample-reader 200 ind 1)))
	    (rd1) (rd2) (rd1) (rd2)
	    (let ((rd11 (copy-sample-reader rd1))
		  (rd22 (copy-sample-reader rd2)))
	      (if (or (not (sample-reader? rd11)) (not (sample-reader? rd22)))
		  (snd-display ";copy-sample-reader (normal): ~A ~A" rd11 rd22))
	      (if (or (mix-sample-reader? rd11) (mix-sample-reader? rd22)
		      (track-sample-reader? rd11) (track-sample-reader? rd22)
		      (region-sample-reader? rd11) (region-sample-reader? rd22))
		  (snd-display ";copy sample-reader-p trouble: ~A ~A ~A ~A ~A ~A"
			       (mix-sample-reader? rd11) (mix-sample-reader? rd22)
			       (track-sample-reader? rd11) (track-sample-reader? rd22)
			       (region-sample-reader? rd11) (region-sample-reader? rd22)))
	      (if (or (not (equal? (sample-reader-home rd11) (list ind 0)))
		      (not (equal? (sample-reader-home rd22) (list ind 1))))
		  (snd-display ";copy normal reader home: ~A ~A" (sample-reader-home rd11) (sample-reader-home rd22)))
	      (if (or (sample-reader-at-end? rd11) (sample-reader-at-end? rd22))
		  (snd-display ";copy normal reader end?: ~A ~A" (sample-reader-at-end? rd11) (sample-reader-at-end? rd22)))
	      (if (or (not (= (sample-reader-position rd11) (sample-reader-position rd1) 102))
		      (not (= (sample-reader-position rd22) (sample-reader-position rd2) 202)))
		  (snd-display ";copy normal reader position: ~A ~A ~A ~A" 
			       (sample-reader-position rd11) (sample-reader-position rd1)
			       (sample-reader-position rd22) (sample-reader-position rd2)))
	      (call-with-current-continuation
	       (lambda (break)
		 (let ((v1 (vct .2 .3 .4 .5 .6 .7 .8 .9 1.0 0.0 0.0 0.0)))
		   (do ((i 0 (1+ i)))
		       ((= i 10))
		     (let ((rd1v (rd1))
			   (rd11v (rd11))
			   (rd2v (next-sample rd2))
			   (rd22v (read-sample rd22)))
		       (if (or (fneq rd1v rd11v)
			       (fneq rd1v (vct-ref v1 i))
			       (fneq rd2v rd22v)
			       (fneq rd2v (vct-ref v1 i)))
			   (begin
			     (snd-display ";copy sample reader vals at ~A: ~A ~A ~A ~A ~A"
					  i rd1v rd11v rd2v rd22v (vct-ref v1 i))
			     (break))))))))
	      (free-sample-reader rd1)
	      (free-sample-reader rd11)))
	  (let ((mx1m (mix-vct (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 95 ind 0))
		(mx2m (mix-vct (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 195 ind 1)))
	    (let ((mx1rd (make-mix-sample-reader mx1m 2))
		  (mx2rd (make-mix-sample-reader mx2m 4)))
	      (mx1rd)
	      (mx1rd)
	      (let ((val1 (mx1rd))
		    (val2 (mx2rd)))
		(if (or (fneq val1 val2)
			(fneq val2 .5))
		    (snd-display ";precopy-mix-sample-reader vals: ~A ~A" val1 val2))
		(let ((mx11rd (copy-sample-reader mx1rd))
		      (mx22rd (copy-sample-reader mx2rd)))
		  (if (or (not (mix-sample-reader? mx11rd)) (not (mix-sample-reader? mx22rd)))
		      (snd-display ";copy-sample-reader (mix): ~A ~A" mx11rd mx22rd))
		  (if (or (sample-reader? mx11rd) (sample-reader? mx22rd)
			  (track-sample-reader? mx11rd) (track-sample-reader? mx22rd)
			  (region-sample-reader? mx11rd) (region-sample-reader? mx22rd))
		      (snd-display ";copy mix sample-reader-p trouble: ~A ~A ~A ~A ~A ~A"
				   (sample-reader? mx11rd) (sample-reader? mx22rd)
				   (track-sample-reader? mx11rd) (track-sample-reader? mx22rd)
				   (region-sample-reader? mx11rd) (region-sample-reader? mx22rd)))
		  (if (or (not (equal? (sample-reader-home mx11rd) mx1m))
			  (not (equal? (sample-reader-home mx22rd) mx2m)))
		      (snd-display ";copy mix reader home: ~A ~A" (sample-reader-home mx11rd) (sample-reader-home mx22rd)))
		  (if (or (sample-reader-at-end? mx11rd) (sample-reader-at-end? mx22rd))
		      (snd-display ";copy mix reader end?: ~A ~A" (sample-reader-at-end? mx11rd) (sample-reader-at-end? mx22rd)))
		  (if (or (not (= (sample-reader-position mx11rd) (sample-reader-position mx1rd) 5))
			  (not (= (sample-reader-position mx22rd) (sample-reader-position mx2rd) 5)))
		      (snd-display ";copy mix reader position: ~A ~A ~A ~A" 
				   (sample-reader-position mx11rd) (sample-reader-position mx1rd)
				   (sample-reader-position mx22rd) (sample-reader-position mx2rd)))
		  (let ((tag (catch 'wrong-type-arg
				    (lambda () (next-sample mx11rd))
				    (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";next-sample of mix reader: ~A" tag)))
		  (call-with-current-continuation
		   (lambda (break)
		     (let ((v1 (vct .6 .7 .8 .9 1.0 0.0 0.0 0.0)))
		       (do ((i 0 (1+ i)))
			   ((= i 6))
			 (let ((mx1rdv (mx1rd))
			       (mx11rdv (mx11rd))
			       (mx2rdv (read-mix-sample mx2rd))
			       (mx22rdv (read-mix-sample mx22rd)))
			   (if (or (fneq mx1rdv mx11rdv)
				   (fneq mx1rdv (vct-ref v1 i))
				   (fneq mx2rdv mx22rdv)
				   (fneq mx2rdv (vct-ref v1 i)))
			       (begin
				 (snd-display ";copy mix sample reader vals at ~A: ~A ~A ~A ~A ~A"
					      i mx1rdv mx11rdv mx2rdv mx22rdv (vct-ref v1 i))
				 (break))))))))
		  (free-sample-reader mx1rd)
		  (free-sample-reader mx11rd))))
	    (let ((trk (make-track)))
	      (set! (mix-track mx1m) trk)
	      (set! (mix-track mx2m) trk)
	      (let ((mx1rd (make-track-sample-reader trk 0 2))
		    (mx2rd (make-track-sample-reader trk 1 4)))
		(mx1rd)
		(mx1rd)
		(let ((val1 (mx1rd))
		      (val2 (mx2rd)))
		  (if (or (fneq val1 val2)
			  (fneq val2 .5))
		      (snd-display ";precopy-track-sample-reader vals: ~A ~A" val1 val2))
		  (let ((mx11rd (copy-sample-reader mx1rd))
			(mx22rd (copy-sample-reader mx2rd)))
		    (if (or (not (track-sample-reader? mx11rd)) (not (track-sample-reader? mx22rd)))
			(snd-display ";copy-sample-reader (track): ~A ~A" mx11rd mx22rd))
		    (if (or (sample-reader? mx11rd) (sample-reader? mx22rd)
			    (mix-sample-reader? mx11rd) (mix-sample-reader? mx22rd)
			    (region-sample-reader? mx11rd) (region-sample-reader? mx22rd))
			(snd-display ";copy track sample-reader-p trouble: ~A ~A ~A ~A ~A ~A"
				     (sample-reader? mx11rd) (sample-reader? mx22rd)
				     (mix-sample-reader? mx11rd) (mix-sample-reader? mx22rd)
				     (region-sample-reader? mx11rd) (region-sample-reader? mx22rd)))
		    (if (or (not (equal? (sample-reader-home mx11rd) (list trk 0)))
			    (not (equal? (sample-reader-home mx22rd) (list trk 1))))
			(snd-display ";copy track reader home: ~A ~A" (sample-reader-home mx11rd) (sample-reader-home mx22rd)))
		    (if (or (sample-reader-at-end? mx11rd) (sample-reader-at-end? mx22rd))
			(snd-display ";copy track reader end?: ~A ~A" (sample-reader-at-end? mx11rd) (sample-reader-at-end? mx22rd)))
		    (if (or (not (= (sample-reader-position mx11rd) (sample-reader-position mx1rd) 5))
			    (not (= (sample-reader-position mx22rd) (sample-reader-position mx2rd) 5)))
			(snd-display ";copy track reader position: ~A ~A ~A ~A" 
				     (sample-reader-position mx11rd) (sample-reader-position mx1rd)
				     (sample-reader-position mx22rd) (sample-reader-position mx2rd)))
		    (let ((tag (catch 'wrong-type-arg
				      (lambda () (next-sample mx11rd))
				      (lambda args (car args)))))
		      (if (not (eq? tag 'wrong-type-arg)) (snd-display ";next-sample of track reader: ~A" tag)))
		    (call-with-current-continuation
		     (lambda (break)
		       (let ((v1 (vct .6 .7 .8 .9 1.0 0.0 0.0 0.0)))
			 (do ((i 0 (1+ i)))
			     ((= i 6))
			   (let ((mx1rdv (mx1rd))
				 (mx11rdv (mx11rd))
				 (mx2rdv (read-track-sample mx2rd))
				 (mx22rdv (read-track-sample mx22rd)))
			     (if (or (fneq mx1rdv mx11rdv)
				     (fneq mx1rdv (vct-ref v1 i))
				     (fneq mx2rdv mx22rdv)
				     (fneq mx2rdv (vct-ref v1 i)))
				 (begin
				   (snd-display ";copy track sample reader vals at ~A: ~A ~A ~A ~A ~A"
						i mx1rdv mx11rdv mx2rdv mx22rdv (vct-ref v1 i))
				   (break))))))))
		    (free-sample-reader mx1rd)
		    (free-sample-reader mx11rd))))))
	  (set! (sync ind) 1)
	  (let ((reg (make-region 90 220 ind #t)))
	    (if (not (= (region-frames reg) (1+ (- 220 90)))) (snd-display ";make-region frames: ~A" (region-frames reg)))
	    (if (not (= (region-chans reg) 2)) (snd-display ";make-region chans: ~A" (region-chans reg)))
	    (if (not (= (region-frames reg 0) (1+ (- 220 90)))) (snd-display ";make-region frames[0]: ~A" (region-frames reg 0)))
	    (if (not (= (region-frames reg 1) (1+ (- 220 90)))) (snd-display ";make-region frames[1]: ~A" (region-frames reg 1)))
	    (if (not (= (region-position reg 0) 90)) (snd-display ";make-region position[0]: ~A" (region-position reg 0)))
	    (if (not (= (region-position reg 1) 90)) (snd-display ";make-region position[1]: ~A" (region-position reg 1)))
	    (if (not (= (region-position reg) 90)) (snd-display ";make-region position[]: ~A" (region-position reg)))
	    
	    ;; beg = 0, chan 2 not highlighted
	    
	    (let ((rd1 (make-region-sample-reader 0 reg 0))
		  (rd2 (make-region-sample-reader 100 reg 1)))
	      (let ((rd11 (copy-sample-reader rd1))
		    (rd22 (copy-sample-reader rd2)))
		(if (or (not (region-sample-reader? rd11)) (not (region-sample-reader? rd22)))
		    (snd-display ";copy-sample-reader (region): ~A ~A" rd11 rd22))
		(if (or (mix-sample-reader? rd11) (mix-sample-reader? rd22)
			(track-sample-reader? rd11) (track-sample-reader? rd22)
			(sample-reader? rd11) (sample-reader? rd22))
		    (snd-display ";copy (region) sample-reader-p trouble: ~A ~A ~A ~A ~A ~A"
				 (mix-sample-reader? rd11) (mix-sample-reader? rd22)
				 (track-sample-reader? rd11) (track-sample-reader? rd22)
				 (sample-reader? rd11) (sample-reader? rd22)))
		(if (or (not (equal? (sample-reader-home rd11) (list reg 0)))
			(not (equal? (sample-reader-home rd22) (list reg 1))))
		    (snd-display ";copy region reader home: ~A ~A" (sample-reader-home rd11) (sample-reader-home rd22)))
		(if (or (sample-reader-at-end? rd11) (sample-reader-at-end? rd22))
		    (snd-display ";copy region reader end?: ~A ~A" (sample-reader-at-end? rd11) (sample-reader-at-end? rd22)))
		(if (or (not (= (sample-reader-position rd11) (sample-reader-position rd1) 0))
			(not (= (sample-reader-position rd22) (sample-reader-position rd2) 100)))
		    (snd-display ";copy region reader position: ~A ~A ~A ~A" 
				 (sample-reader-position rd11) (sample-reader-position rd1)
				 (sample-reader-position rd22) (sample-reader-position rd2)))
		(call-with-current-continuation
		 (lambda (break)
		   (let ((v1 (vct 0.000 0.000 0.000 0.000 0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.800 1.000 1.200 1.400 0.500 0.600 0.700 0.800 0.900)))
		     (do ((i 0 (1+ i)))
			 ((= i 20))
		       (let ((rd1v (rd1))
			     (rd11v (rd11))
			     (rd2v (read-region-sample rd2))
			     (rd22v (read-region-sample rd22)))
			 (if (or (fneq rd1v rd11v)
				 (fneq rd1v (vct-ref v1 i))
				 (fneq rd2v rd22v)
				 (fneq rd2v (vct-ref v1 i)))
			     (begin
			       (snd-display ";copy region sample reader vals at ~A: ~A ~A ~A ~A ~A"
					    i rd1v rd11v rd2v rd22v (vct-ref v1 i))
			       (break))))))))
		(free-sample-reader rd1)
		(free-sample-reader rd11))))
	  (close-sound ind))

	  (let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 1 "mix with exp env tests" 1000)))
	    (let ((mx (mix-vct (make-vct 10 1.0) 100)))
	      (set! (mix-amp-env mx) xrmx)
	      (let ((data (channel->vct 100 10)))
		(if (not (vequal data (vct 0.000 0.015 0.037 0.070 0.118 0.189 0.293 0.446 0.670 1.000)))
		    (snd-display ";mix-vct + exp env: ~A" data)))
	      (revert-sound ind)
	      (set! mx (mix-vct (make-vct 100 1.0) 100))
	      (set! (mix-amp-env mx) xrmx)
	      (let ((trk (make-track mx)))
		(set! (track-amp-env trk) '(0 0 1 1))
		(let ((data (channel->vct 120 10)))
		  (if (not (vequal data (vct 0.006 0.008 0.009 0.010 0.011 0.012 0.013 0.014 0.015 0.017)))
		      (snd-display ";mix-vct + exp + track ramp (20): ~A" data)))
		(let ((data (channel->vct 190 10)))
		  (if (not (vequal data (vct 0.665 0.702 0.740 0.777 0.814 0.851 0.888 0.926 0.963 1.000)))
		      (snd-display ";mix-vct + exp + track ramp (90): ~A" data)))
		(set! (track-amp-env trk) xrmx)
		(let ((data (channel->vct 190 10)))
		  (if (not (vequal data (vct 0.538 0.589 0.641 0.692 0.743 0.795 0.846 0.897 0.949 1.000)))
		      (snd-display ";mix-vct + exp + track exp (90): ~A" data)))
		(set! (mix-amp-env mx) '(0 0 1 1))
		(let ((data (channel->vct 190 10)))
		  (if (not (vequal data (vct 0.665 0.702 0.740 0.777 0.814 0.851 0.888 0.926 0.963 1.000)))
		      (snd-display ";mix-vct + ramp + track exp (90): ~A" data)))
		(set! (mix-amp-env mx) #f)
		(let ((data (channel->vct 190 10)))
		  (if (not (vequal data (vct 0.721 0.748 0.776 0.804 0.834 0.865 0.897 0.930 0.964 1.000)))
		      (snd-display ";mix-vct + track exp (90): ~A" data)))
		(set! (track-amp-env trk) #f)
		(set! (mix-amp-env mx) xrmx)
		(let ((data (channel->vct 190 10)))
		  (if (not (vequal data (vct 0.721 0.748 0.776 0.804 0.834 0.865 0.897 0.930 0.964 1.000)))
		      (snd-display ";mix-vct exp + track null (90): ~A" data)))
		(revert-sound ind)
		(set! mx (mix-vct (make-vct 100 1.0) 100))
		(let* ((mx1r (mix-vct (make-vct 100 1.0) 200))
		       (trk1 (make-track mx mx1r)))
		  (set! (track-amp-env trk1) xrmx2)
		  (let ((data (channel->vct 190 10)))
		    (if (not (vequal data (vct 0.542 0.547 0.552 0.557 0.562 0.567 0.572 0.576 0.581 0.586)))
			(snd-display ";mix-vct track amp env xrmx2 190 10: ~A" data)))
		  (let ((data (channel->vct 200 10)))
		    (if (not (vequal data (vct 0.586 0.591 0.596 0.601 0.606 0.611 0.615 0.620 0.625 0.630)))
			(snd-display ";mix-vct track amp env xrmx2 200 10: ~A" data)))
		  (close-sound ind)))))
	
	  (let ((ind (new-sound "tmp.snd" mus-next mus-bfloat 22050 2 "stereo mix with exp env tests" 1000)))
	    (let* ((mx0t (mix-vct (make-vct 10 1.0) 100 ind 0))
		   (mx1t (mix-vct (make-vct 10 1.0) 100 ind 1))
		   (trk (make-track mx0t mx1t)))
	      (set! (mix-inverted? mx1t) #t)
	      (set! (track-amp-env trk) xrmx)
	      (let ((data (channel->vct 100 10 ind 0)))
		(if (not (vequal data (vct 0.000 0.015 0.037 0.070 0.118 0.189 0.293 0.446 0.670 1.000)))
		    (snd-display ";0 mix-vct + exp env: ~A" data)))
	      (let ((data (channel->vct 100 10 ind 1)))
		(if (not (vequal data (vct 1.000 0.985 0.963 0.930 0.882 0.811 0.707 0.554 0.330 0.000)))
		    (snd-display ";1 mix-vct + exp env: ~A" data)))
	      (close-sound ind)))

	(set! (with-mix-tags) old-with-mix-tags))

      (let ((old (tempo-control-bounds)))
	(if (or (fneq (car old) 0.0) (fneq (cadr old) 8.0))
	    (snd-display ";tempo-control-bounds defaults: ~A" old))
	(set! (tempo-control-bounds) (list 0.0 2.0))
	(set! old (tempo-control-bounds))
	(if (or (fneq (car old) 0.0) (fneq (cadr old) 2.0))
	    (snd-display ";tempo-control-bounds set (0.0 2.0): ~A" old))
	(set! (tempo-control-bounds) (list 0.0 8.0)))
      
      (let* ((ind (new-sound "test.snd" :size 10))
	     (mx1 (mix-vct (make-vct 2 .1) 0))
	     (mx2 (mix-vct (make-vct 2 .2) 2))
	     (mx3 (mix-vct (make-vct 2 .3) 4))
	     (mx4 (mix-vct (make-vct 2 .4) 6))
	     (mx5 (mix-vct (make-vct 2 .5) 8)))
	(if (not (vequal (channel->vct) (vct .1 .1 .2 .2 .3 .3 .4 .4 .5 .5)))
	    (snd-display ";delete-all-tracks init: ~A" (channel->vct)))
	(delete-all-tracks)
	(if (not (vequal (channel->vct) (vct .1 .1 .2 .2 .3 .3 .4 .4 .5 .5)))
	    (snd-display ";delete-all-tracks no-op: ~A" (channel->vct)))
	(let ((trk (make-track mx1 mx3))
	      (trk1 (make-track)))
	  (set! (mix-track mx4) trk1)
	  (delete-all-tracks)
	  (if (not (vequal (channel->vct) (vct 0 0 .2 .2 0 0 0 0 .5 .5)))
	      (snd-display ";delete-all-tracks: ~A" (channel->vct)))
	  (close-sound ind)))

      (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)
	     (if (not (eq? lock (mix-locked? mx))) (snd-display ";~A mix locked: ~A ~A" name lock (mix-locked? mx)))
	     (if (not (= beg (mix-position mx))) (snd-display ";~A mix lock beg: ~A ~A" name beg (mix-position mx)))
	     (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))
      
      (run-hook after-test-hook 9)
      ))


(clear-sincs)

(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))

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

;;; ---------------- test 10: marks ----------------
(if (or full-test (= snd-test 10) (and keep-going (<= snd-test 10)))
    (begin 
      (run-hook before-test-hook 10)
      (do ((test-ctr 0 (1+ test-ctr)))
	  ((= test-ctr tests))
	(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))
	  (let ((t0 (make-track (vector-ref vc 0) (vector-ref vc 3) (vector-ref vc 5)))
		(t1 (make-track (vector-ref vc 2) (vector-ref vc 6) (vector-ref vc 8))))
	    (set! (track-amp t0) .5)
	    (time (transpose-track t1 3))
	    (catch 'no-such-color
		   (lambda () (set! (track-color t1) (make-color 0 0 1)))
		   (lambda args args))
	    (let ((t0e (track-end t0)))
	      (set! (track-position t0) 1000)
	      (if (not (= (track-position t0) 1000)) (snd-display ";track-position: ~A?" (track-position t0)))
	      (if (not (= (track-end t0) (+ t0e 1000))) (snd-display ";track-end: ~A ~A?" t0e (track-end t0))))
	    (if (not (= (track-frames t0) 3100)) (snd-display ";track-frames: ~A?" (track-frames t0)))
	    (retempo-track t0 2.0)
	    (if with-gui
		(let ((col (color->list (track-color t1))))
		  (if (or (fneq (car col) 0.0) (fneq (cadr col) 0.0) (fneq (caddr col) 1.0))
		      (snd-display ";track-color: ~A?" col))))
	    (if (not (= (track-frames t0) 1600)) (snd-display ";track-tempo -> length: ~A?" (track-frames t0))))
	  (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 ";1 env-sound[~D]: ~A?" i (sample i))))
	    (undo) 
	    (env-sound (make-env '(0 0 1 1) :end 9) 0 10 1.0 ind0) 
	    (do ((i 0 (1+ i))) ((= i 10)) (if (fneq (sample i) (* i .1111)) (snd-display ";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 ";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 ";env-sound exp: ~A ~A?" (sample 3) (sample 8)))
	    (undo) 
	    (env-sound (make-env '(0 0 1 1) :base 32.0 :end 9) 0 10 32.0 ind0) 
	    (if (or (fneq (sample 3) 0.070) (fneq (sample 8) 0.67) )
		(snd-display ";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 ";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 ";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 ";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 .99 1200))
	    (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 ";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 ";ind0:0 1 env-sound[~D]: ~A?" i (sample i ind0 0)))
	      (if (fneq (sample i ind0 1) (* i .1111)) (snd-display ";ind0:1 1 env-sound[~D]: ~A?" i (sample i ind0 1)))
	      (if (fneq (sample i ind1 0) (* i .1111)) (snd-display ";ind1:0 1 env-sound[~D]: ~A?" i (sample i ind1 0))))
	    (undo) 
	    (env-sound (make-env '(0 0 1 1) :end 9) 0 10 1.0 ind0) 
	    (do ((i 0 (1+ i))) 
		((= i 10)) 
	      (if (fneq (sample i ind0 0) (* i .1111)) (snd-display ";ind0:0 2 env-sound[~D]: ~A?" i (sample i ind0 0)))
	      (if (fneq (sample i ind0 1) (* i .1111)) (snd-display ";ind0:1 2 env-sound[~D]: ~A?" i (sample i ind0 1)))
	      (if (fneq (sample i ind1 0) (* i .1111)) (snd-display ";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 ";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 ";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 ";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 ";ind0:0 1 filter-sound[~D]: ~A?" i (sample i ind0 0)))
	      (if (fneq (sample i ind0 1) 0.5) (snd-display ";ind0:1 1 filter-sound[~D]: ~A?" i (sample i ind0 1)))
	      (if (fneq (sample i ind1 0) 0.5) (snd-display ";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 ";env-sound [~D]: ~A?" (+ i 10) (sample (+ i 10) ind0))))
	    (if (fneq (sample 5 ind0) old5) (snd-display ";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 ";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 ";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 ";scan-chan[0,0]: ~A?" val)))
	    (let ((val (data-max1 0 9 ind0 1)))
	      (if (fneq val 0.1) (snd-display ";scan-chan[0,1]: ~A?" val)))
	    (let ((val (data-max1 0 9 ind1 0)))
	      (if (fneq val 0.01) (snd-display ";scan-chan[1,0]: ~A?" val)))
	    (let ((val (data-max1 0 9 #f #f)))
	      (if (fneq val 0.01) (snd-display ";scan-chans: ~A?" val)))
	    (let ((val (data-max 0 9)))
	      (if (fneq val 1.0) (snd-display ";scan-all-chans: ~A?" val)))
	    (let ((val (data-max2 0 9 ind0)))
	      (if (fneq val 1.0) (snd-display ";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 ";marks after save: ~A" (marks ind0 0)))
		(if (or (not (mark? m1))
			(not (= (mark-sample m1) 99)))
		    (snd-display ";save-sound mark1: ~A" (mark-sample m1)))
		(if (or (not (mark? m2))
			(not (= (mark-sample m2) 200)))
		    (snd-display ";save-sound mark2: ~A" (mark-sample m2)))
		(if (mark? m3) (snd-display ";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 ";mark?"))
	    (if (not (= (mark-sample m1) 123)) (snd-display ";add-mark: ~A? " (mark-sample m1)))
	    (set! (mark-property :hiho m1) 123)
	    (if (not (= (mark-property :hiho m1) 123)) (snd-display ";mark-property: ~A" (mark-property m1)))
	    (if (mark-property :not-there m1) (snd-display ";mark-not-property: ~A" (mark-property :not-there m1)))
	    (if (not (eq? (without-errors (mark-sample 12345678)) 'no-such-mark)) (snd-display ";mark-sample err: ~A?" (mark-sample 12345678)))
	    (if (not (eq? (without-errors (add-mark 123 123)) 'no-such-sound)) (snd-display ";add-mark err: ~A?" (add-mark 123 123)))
	    (let ((m2 (without-errors (add-mark 12345 fd 0))))
	      (if (eq? m2 'no-such-mark) (snd-display ";add-mark failed?"))
	      (if (not (= (mark-sample m2) 12345)) (snd-display ";add-mark 0 0: ~A?" (mark-sample m2)))
	      (if (not (= (mark-sync m2) 0)) (snd-display ";init mark-sync: ~A?" (mark-sync m2)))
	      (set! (mark-sync m2) sync-val)
	      (if (not (= (mark-sync m2) sync-val)) (snd-display ";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 ";syncd-marks: ~A?" syncs))
		(if (not (equal? chans (list m1 m2))) (snd-display ";marks: ~A?" chans))
		(if (not (equal? samps (list (mark-sample m1) (mark-sample m2)))) (snd-display ";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 ";map samps: ~A?" samps))
		(let ((descr (describe-mark m2)))
		  (if (not (equal? descr (list (list 'mark m2 'sound fd "oboe.snd" 'channel 0) 12345 12245)))
		      (snd-display ";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 ";syncd move samps: ~A?" samps))
		(set! (cursor) 500)
		(backward-mark)
		(if (not (= (cursor) (mark-sample m1))) (snd-display ";backward-mark: ~A?" (cursor)))
		(forward-mark 1)
		(if (not (= (cursor) (mark-sample m2))) (snd-display ";forward-mark: ~A?" (cursor)))
		(set! (mark-sync m1) #t)
		(if (not (= (mark-sync m1) 1)) (snd-display ";mark-sync via bool: ~A" (mark-sync m1)))
		(delete-mark m1)
		(set! chans (marks fd 0))
		(if (not (equal? chans (list m2))) (snd-display ";delete-mark? ~A" chans))
		(undo)
		(set! chans (marks fd 0))
		(if (not (equal? chans (list m1 m2))) (snd-display ";delete-mark then undo? ~A" chans))
		(redo)
		(if (not (string=? (mark-name m2) "")) (snd-display ";init mark-name: ~A?" (mark-name m2)))
		(set! (mark-name m2) "hiho!")
		(if (not (string=? (mark-name m2) "hiho!")) (snd-display ";set-mark-name: ~A?" (mark-name m2)))
		(undo)
		(if (not (string=? (mark-name m2) "")) (snd-display ";undo mark-name: ~A?" (mark-name m2)))
		(redo)
		(if (not (string=? (mark-name m2) "hiho!")) (snd-display ";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 (not (eq? m2 m3 m4 m7)) (snd-display ";find-mark: ~A ~A ~A ~A?" m2 m3 m4 m7))
		  (if (not (eq? m5 m6 #f)) (snd-display ";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 ";insert ripple: ~A?" samps))
		  (set! (mark-sample m3) 300)
		  (set! (cursor) 500)
		  (backward-mark)
		  (if (not (= (cursor) 300)) (snd-display ";sort marks: ~A?" (cursor)))
		  (if (not (equal? (mark-home m2) (list fd 0))) (snd-display ";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 ";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 ";save-marks -> ~A?" file)))
		  (let ((file (save-marks fd "hiho.marks")))
		    (if (or (not file)
			    (not (string=? file "hiho.marks")))
			(snd-display ";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 ";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! (verbose-cursor) #t)
		    (save-state "s61.scm")
		    (set! (verbose-cursor) #f)
		    (close-sound s1)
		    (close-sound s2))
		  (load "s61.scm")
		  (if (not (verbose-cursor)) (snd-display ";save-state 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 ";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 ";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 ";save-marks via save-state posiitons: ~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 ";save-marks no marks -> ~A?" file)))
		    (close-sound fd))
		  (let ((fd (open-sound "oboe.snd")))
		    (load "oboe.marks")
		    (let ((mlst (marks fd 0)))
		      (if (not (= (length mlst) 2)) (snd-display ";restore-marks: ~A?" mlst))
		      (if (or (not (= (mark-sample (car mlst)) 123))
			      (not (= (mark-sample (cadr mlst)) 12345)))
			  (snd-display ";restored-marks: ~D ~D?" (mark-sample (car mlst)) (mark-sample (cadr mlst)))))
		    (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 ";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 ";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 ";marks (no args): ~A" (marks)))
		      (save-marks fd)
		      (close-sound fd)
		      (set! fd (open-sound "4.aiff"))
		      (load "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 ";save-marks[~A]: ~A?" i mlst))
			  (if (not (= (mark-sample (car mlst)) (* (+ i 1) 1000)))
			      (snd-display ";save-marks[~A] at ~A?" i (mark-sample (car mlst))))))
		      (close-sound fd)))
		  
		  ))))
	  
	  (let* ((ind (open-sound "pistol.snd"))
		 (samp1 1834)
		 (samp2 8345)
		 (m1 (add-mark samp1 ind 0))
		 (m2 (add-mark samp2)))
	    (src-sound -1)
	    (if (not (= (mark-sample m1) 39788))
		(snd-display ";src -1 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 33277))
		(snd-display ";src -1 m2 -> ~A" (mark-sample m2)))
	    (undo)
	    (src-sound .5)
	    (if (not (= (mark-sample m1) (* 2 samp1)))
		(snd-display ";src .5 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) (* 2 samp2)))
		(snd-display ";src .5 m2 -> ~A" (mark-sample m2)))
	    (undo)
	    (delete-samples 1000 100)
	    (if (not (= (mark-sample m1) (- samp1 100)))
		(snd-display ";delete 100 m1 -> ~A" (mark-sample m1)))
	    (insert-silence 1000 100)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";insert 100 m1 -> ~A" (mark-sample m1)))
	    (revert-sound ind)
	    (delete-samples 2000 100)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";delete(2) 100 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) (- samp2 100)))
		(snd-display ";delete(2) 100 m2 -> ~A" (mark-sample m2)))
	    (insert-silence 2000 100)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";insert(2) 100 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) samp2))
		(snd-display ";insert(2) 100 m2 -> ~A" (mark-sample m2)))
	    (revert-sound ind)
	    (delete-samples 10000 100)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";delete(3) 100 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) samp2))
		(snd-display ";delete(3) 100 m2 -> ~A" (mark-sample m2)))
	    (insert-silence 10000 100)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";insert(3) 100 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) samp2))
		(snd-display ";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 ";src env .5 m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) (* 2 samp2)))
		(snd-display ";src env .5 m2 -> ~A" (mark-sample m2)))
	    (undo)
	    (reverse-sound)
	    (if (not (= (mark-sample m1) 39788))
		(snd-display ";reverse-sound m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 33277))
		(snd-display ";reverse-sound m2 -> ~A" (mark-sample m2)))
	    (undo)
	    (src-sound '(0 -.5 1 -.5 2 -1))
	    (if (not (= (mark-sample m1) 68598))
		(snd-display ";src -env m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 61160))
		(snd-display ";src -env m2 -> ~A" (mark-sample m2)))
	    (revert-sound ind)
	    (src-channel (make-env '(0 .5 1 1) :end 8000) 2000 10000)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";src-channel(1) m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 11345))
		(snd-display ";src-channel(1) m2 -> ~A" (mark-sample m2)))
	    (undo)
	    (src-channel (make-env '(0 .5 1 1) :end 8000) 0 8000)
	    (if (not (= (mark-sample m1) 3303))
		(snd-display ";src-channel(2) m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) samp2))
		(snd-display ";src-channel(2) m2 -> ~A" (mark-sample m2)))
	    (undo)
	    (src-channel (make-env '(0 .5 1 1) :end 8000) 10000 8000)
	    (if (not (= (mark-sample m1) samp1))
		(snd-display ";src-channel(3) m1 -> ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) samp2))
		(snd-display ";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 ";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 ";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 ";edited swapped mark home: ~A?" (mark-home m3)))
	      (if (not (= (mark-sample m3) 1000))
		  (snd-display ";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)))
	    (define-selection-via-marks m1 m2)
	    (if (not (selection?))
		(snd-display ";define-selection-via-marks failed?")
		(let ((mc (selection-members)))
		  (if (not (equal? mc (list (list ind 0)))) (snd-display ";selection-members after mark definition: ~A (should be '((~A 0)))" mc ind))
		  (if (not (= (selection-position) 123)) (snd-display ";selection-position 123: ~A" (selection-position)))
		  (if (not (= (selection-frames) 112)) (snd-display ";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 ";define-selection-via-marks repeat failed?")
		(let ((mc (selection-members)))
		  (if (not (equal? mc (list (list ind 0)))) (snd-display ";selection-members after 2nd mark definition: ~A (should be '((~A 0)))" mc ind))
		  (if (not (= (selection-position) 1000)) (snd-display ";selection-position 1000: ~A" (selection-position)))
		  (if (not (= (selection-frames) 1001)) (snd-display ";selection-frames 1001: ~A" (selection-frames)))))
	    (set! (selection-member? #t) #f)
	    (if (selection?) (snd-display ";can't clear selection via selection-member?"))
	    (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 ";snap-marks start: ~A" (map mark-sample (marks ind 0))))
	    (set! m2 (find-mark (+ 2000 1234)))
	    (if (not (mark? m2)) (snd-display ";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) (1- (frames ind ))))
		(snd-display ";selection position past eof: ~A ~A" (selection-position ind 0) (1- (frames ind ))))
	    (revert-sound ind)
	    (src-sound '(0 .5 1 1.75665))
	    ;; trying to hit previous dur on the nose "by accident..."
	    (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 (irandom (- (length current-marks) 1)))))
		      (if (not (= id (find-mark (mark-sample id)))) 
			  (snd-display ";two marks at ~A? ~A" (mark-sample id) (map mark-sample current-marks)))
		      (if (find-mark "not-a-name") (snd-display ";find-bogus-mark: ~A" (find-mark "not-a-name")))))
		
		(case (irandom 15)
		  ((0) (let* ((beg (irandom (frames)))
			      (dur (max 1 (irandom 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 ";insert clobbered mark: ~A" id)
					  (if (not (= (mark-sample id) (+ old-loc dur)))
					      (snd-display ";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 ";scaling changed marks: ~A ~A" (marks ind 0) current-marks))
		   (if (not (equal? (map mark-sample (marks ind 0)) current-samples))
		       (snd-display ";scaling changed mark locations: ~A ~A" (map mark-sample (marks ind 0)) current-samples)))
		  ((4) (set! (sample (irandom (1- (frames)))) .5)
		   (if (not (equal? (marks ind 0) current-marks))
		       (snd-display ";set-sample changed marks: ~A ~A" (marks ind 0) current-marks))
		   (if (not (equal? (map mark-sample (marks ind 0)) current-samples))
		       (snd-display ";set-sample changed mark locations: ~A ~A" (map mark-sample (marks ind 0)) current-samples)))
		  ((5) (let* ((beg (irandom (frames)))
			      (dur (max 1 (irandom 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 ";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 ";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 ";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 (irandom (- (length current-marks) 1)))))
			     (delete-mark id)
			     (if (mark? id)
				 (snd-display ";delete-mark failed? ~A" id))
			     (if (not (= (length (marks ind 0)) (1- (length current-marks))))
				 (snd-display ";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 ";src-channel clobbered mark: ~A" id)
				    (if (> (abs (- (/ old-loc rate) (mark-sample id))) 2)
					(snd-display ";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 ";reverse-channel clobbered mark: ~A" id)
			      (if (> (abs (- (- (frames) old-loc) (mark-sample id))) 2)
				  (snd-display ";reverse moved mark: ~A ~A ~A (~A)" 
					       id old-loc (- (frames) old-loc) (mark-sample id)))))
			current-marks
			current-samples)))
		  (else (add-mark (irandom (1- (frames))))))))
	    (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 (= (list-ref (car val0) 1) m0))
			  (not (= (list-ref (car val0) 3) ind))
			  (not (= (list-ref (car val0) 6) 0))
			  (not (= (list-ref val0 1) 4321))
			  (not (= (list-ref val0 2) 4320)))
		      (snd-display ";describe-mark m0: ~A" val0))
		  (if (or (not (= (list-ref (car val1) 1) m1))
			  (not (= (list-ref (car val1) 3) ind))
			  (not (= (list-ref (car val1) 6) 0))
			  (not (eq? (list-ref val1 1) #f))
			  (not (= (list-ref val1 2) 1234)))
		      (snd-display ";describe-mark m1: ~A" val1))
		  (delete-mark m0)
		  (delete-sample 5000)
		  (set! val0 (describe-mark m0))
		  (set! val1 (describe-mark m1))
		  (if (or (not (= (list-ref (car val0) 1) m0))
			  (not (= (list-ref (car val0) 3) ind))
			  (not (= (list-ref (car val0) 6) 0))
			  (not (= (list-ref val0 1) 4321))
			  (not (eq? (list-ref val0 2) #f))
			  (not (eq? (list-ref val0 3) #f)))
		      (snd-display ";describe-mark m0 [1]: ~A" val0))
		  (if (or (not (= (list-ref (car val1) 1) m1))
			  (not (= (list-ref (car val1) 3) ind))
			  (not (= (list-ref (car val1) 6) 0))
			  (not (eq? (list-ref val1 1) #f))
			  (not (= (list-ref val1 2) 1234))
			  (not (= (list-ref val1 3) 1234)))
		      (snd-display ";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 ";pad-marks: ~A ~A" dur (/ (frames ind) (srate ind))))
	      (if (and (not (= (mark-sample m0) 4763)) 
		       (not (= (mark-sample m0) 4761)))
		  (snd-display ";pad-marks m0 pos: ~A" (mark-sample m0)))
	      (if (fneq (sample 1235) 0.0) (snd-display ";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 ";forward-mark when no marks: ~A" (forward-mark)))
	    (if (backward-mark) (snd-display ";backward-mark when no marks: ~A" (backward-mark)))
	    (if (find-mark 12345) (snd-display ";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 ";can't find 00th mark"))
		  (if (not m01) (snd-display ";can't find 01th mark"))
		  (if (not m02) (snd-display ";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 ";can't find 10th mark")
			(if (not (= (mark-sample m10) 1234)) (snd-display ";mark 10th: ~A" (mark-sample m10))))
		    (if (not m11) (snd-display ";can't find 11th mark")
			(if (not (= (mark-sample m11 1) 23)) (snd-display ";mark 11th: ~A" (mark-sample m11 1))))
		    (if (mark? m12) (snd-display ";found 12th mark: ~A ~A ~A" m12 (mark-sample m12 2) (mark-name m12 2)))))))
	    (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 ";forest marked loops: ~A ~A" (marks ind 0) pos)))
		(close-sound ind)))
	  
	  ))
      (run-hook after-test-hook 10)
      ))


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

(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-current-continuation
     (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)))))))))

(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))

(if (and with-gui
	 (or full-test (= snd-test 11) (and keep-going (<= snd-test 11))))
    (begin
      (run-hook before-test-hook 11)
      (without-errors (peaks))
      (mus-audio-describe) 
      (let ((envd (enved-dialog) ))
	(let ((cold (color-dialog))
	      (ord (orientation-dialog))
	      (trd (transform-dialog))
	      (fild (view-files-dialog))
	      (regd (view-regions-dialog))
	      (pd (print-dialog))
	      (ehd (without-errors (edit-header-dialog))))
	  (if (not (equal? cold (list-ref (dialog-widgets) 0)))
	      (snd-display ";color-dialog -> ~A ~A" cold (list-ref (dialog-widgets) 0)))
	  (if (not (equal? pd (list-ref (dialog-widgets) 17)))
	      (snd-display ";print-dialog -> ~A ~A" pd (list-ref (dialog-widgets) 17)))
	  (if (not (equal? trd (list-ref (dialog-widgets) 5)))
	      (snd-display ";transform-dialog -> ~A ~A" trd (list-ref (dialog-widgets) 5)))
	  (if (not (equal? regd (list-ref (dialog-widgets) 19)))
	      (snd-display ";view-regions-dialog -> ~A ~A" trd (list-ref (dialog-widgets) 19)))
	  (let ((wid (open-file-dialog #f)))
	    (if (not (equal? wid (list-ref (dialog-widgets) 6)))
		(snd-display ";open-file-dialog-> ~A ~A" wid (list-ref (dialog-widgets) 6))))
	  (let ((wid (mix-file-dialog #f)))
	    (if (not (equal? wid (list-ref (dialog-widgets) 11)))
		(snd-display ";mix-file-dialog-> ~A ~A" wid (list-ref (dialog-widgets) 11))))
	  (if (not (provided? 'snd-gtk))
	      (begin
					;(recorder-dialog) 
		(set! (recorder-file) "hiho.snd")
		(if (not (string=? (recorder-file) "hiho.snd")) (snd-display ";set-recorder-file: ~A?" (recorder-file)))
		(set! (recorder-in-format) mus-mulaw)
		(if (not (= (recorder-in-format) mus-mulaw)) (snd-display ";set-recorder-in-format: ~A?" (recorder-in-format)))
		(set! (recorder-in-device) mus-audio-line-in)
		(if (not (= (recorder-in-device) mus-audio-line-in)) (snd-display ";set-recorder-in-device: ~A?" (recorder-in-device)))
		(set! (recorder-out-format) mus-mulaw)
		(if (not (= (recorder-out-format) mus-mulaw)) (snd-display ";set-recorder-out-format: ~A?" (recorder-out-format)))
		(set! (recorder-out-type) mus-aifc)
		(if (not (= (recorder-out-type) mus-aifc)) (snd-display ";set-recorder-out-type: ~A?" (recorder-out-type)))
		(set! (recorder-srate) 44100)
		(if (not (= (recorder-srate) 44100)) (snd-display ";set-recorder-srate: ~A?" (recorder-srate)))
		(set! (recorder-gain 0) 0.5)
		(if (fneq (recorder-gain 0) 0.5) (snd-display ";set-recorder-gain: ~A?" (recorder-gain 0)))
		(set! (recorder-out-amp 0) 0.5)
		(if (> (abs (- (recorder-out-amp 0) 0.5)) .01) (snd-display ";set-recorder-out-amp: ~A?" (recorder-out-amp 0)))
		(set! (recorder-in-amp 0 0) 0.5)
		(if (> (abs (- (recorder-in-amp 0 0) 0.5)) .01) (snd-display ";set-recorder-in-amp: ~A?" (recorder-in-amp 0 0)))))
	  (let ((held (help-dialog "Test" "snd-test here")))
	    (if (not (= (length (menu-widgets)) 7)) (snd-display ";menu-widgets: ~A?" (menu-widgets)))
	    (if (not (equal? (widget-position (car (menu-widgets))) (list 0 0)))
		(snd-display ";position main menubar: ~A?" (widget-position (car (menu-widgets)))))
	    (if (not (equal? held (list-ref (dialog-widgets) 14)))
		(snd-display ";help-dialog -> ~A ~A" held (list-ref (dialog-widgets) 14)))
	    (save-envelopes "hiho.env")
	    (load "hiho.env")
	    (if (not (equal? env4 (list 0.0 1.0 1.0 0.0))) (snd-display ";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 ";snd-url 'open-sound: ~A" (snd-url 'open-sound)))
      (if (not (string=? (snd-url "open-sound") "extsnd.html#opensound"))
	  (snd-display ";snd-url \"open-sound\": ~A" (snd-url "open-sound")))
      (if (not (list? (snd-urls))) (snd-display ";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-equal-ignoring-white-space str2 str3)))
	    (snd-display ";snd-help open-sound: ~A ~A ~A" str1 str2 str3)))
      (if (not (string? (snd-help 'open-soud)))
	  (snd-display ";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 ";snd-help enved-base: ~A?" (snd-help enved-base)))
      (if (not (string-equal-ignoring-white-space (snd-help vu-font) "(vu-font): name of font used to make VU meter labels (courier)"))
	  (snd-display ";snd-help vu-font: ~A?" (snd-help vu-font)))
      (if (not (string-equal-ignoring-white-space (snd-help 'enved-base) "(enved-base): envelope editor exponential base value (1.0)"))
	  (snd-display ";snd-help 'enved-base: ~A?" (snd-help 'enved-base)))
      (if (not (string-equal-ignoring-white-space (snd-help 'vu-font) "(vu-font): name of font used to make VU meter labels (courier)"))
	  (snd-display ";snd-help 'vu-font: ~A?" (snd-help 'vu-font)))
      (if (not (string-equal-ignoring-white-space (snd-help "enved-base") "(enved-base): envelope editor exponential base value (1.0)"))
	  (snd-display ";snd-help \"enved-base\": ~A?" (snd-help "enved-base")))
      (if (not (string-equal-ignoring-white-space (snd-help "vu-font") "(vu-font): name of font used to make VU meter labels (courier)"))
	  (snd-display ";snd-help \"vu-font\": ~A?" (snd-help "vu-font")))
      (let ((old-val hamming-window))
	(let ((str1 (snd-help 'hamming-window))
	      (str2 (snd-help "hamming-window")))
	  (if (or (not (string-equal-ignoring-white-space str1 str2))
		  (not (string-equal-ignoring-white-space str1 "A raised cosine")))
	      (snd-display ";snd-help hamming-window: ~A ~A" str1 str2)))
	(if (or (not (number? hamming-window))
		(not (= hamming-window old-val)))
	    (snd-display ";snd-help clobbered out-of-module variable: ~A ~A" old-value hamming-window)))
      
      (set! (show-indices) #t)
      (let ((ind (open-sound "oboe.snd")))
	(if (< (length (sound-widgets ind)) 4)
	    (snd-display ";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 ";report-in-minibuffer: ~A?" str))))
	(append-to-minibuffer "away!" ind)
	(if with-gui
	    (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
	      (if (not (string=? str "hi thereaway!"))
		  (snd-display ";report-in-minibuffer 1: ~A?" str))
	      (if (widget-text (cadr (main-widgets))) 
		  (snd-display ";widget text should be #f: ~A" (widget-text (cadr (main-widgets)))))
	      (let ((str (format #f "~D: ~A" ind (short-file-name ind)))
		    (txt (widget-text (cadr (sound-widgets ind)))))
		(if (or (not (string? txt))
			(not (string=? str txt)))
		    (snd-display ";name text: ~A ~A" str txt)))))
	(close-sound ind))
      (if (file-exists? "link-oboe.snd")
	  (let* ((ind (open-sound "link-oboe.snd"))
		 (linked-str (format #f "~D: (~A)" ind (short-file-name ind))))
	    (if with-gui
		(if (not (string=? linked-str (widget-text (cadr (sound-widgets ind)))))
		    (snd-display ";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 ";linked name text (no index): ~A ~A" linked-str (widget-text (cadr (sound-widgets ind))))))
	    (close-sound ind)))
      
      (if (and (provided? 'xm)
	       (provided? 'snd-motif))
	  (begin
	    (snd-error "a test")
	    (let ((errwid (list-ref (dialog-widgets) 3)))
	      (if (not (Widget? errwid))
		  (snd-display ";snd-error no dialog?")
		  (let ((OK (find-child errwid "OK")))
		    (if (Widget? OK)
			(XtCallCallbacks OK XmNactivateCallback #f)))))))

      (define-envelope test-ramp '(0 0 1 1))
      (if (not (equal? test-ramp '(0 0 1 1))) (snd-display ";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 ";re-define-envelope test-ramp: ~A" test-ramp))
      
      (define-envelope ramp32 '(0 0 1 1) 32.0)
      (define-envelope ramp032 '(0 0 1 1) 0.032)
      (define-envelope ramp12 '(0 0 1 1 2 0) 3.0)
      (define-envelope ramp012 '(0 0 1 1 2 0) .3)

      (for-each
       (lambda (vals)
	 (let* ((e (car vals))
		(name (cadr vals))
		(base (caddr vals))
		(ebase (object-property e 'envelope-base)))
	   (if (fneq ebase base) (snd-display ";define-envelope ~A base: ~A ~A" name base ebase))))
       (list (list ramp32 "ramp32" 32.0)
	     (list ramp032 "ramp032" .032)
	     (list ramp12 "ramp12" 3.0)
	     (list ramp012 "ramp012" .3)
	     (list test-ramp "test-ramp" 1.0)))

	  (let ((ind (new-sound "fmv.snd" mus-aifc mus-bshort 22050 1 "define-envelope tests" 10)))
	    (map-channel (lambda (y) 1.0))
	    (env-sound ramp32)
	    (let ((data (channel->vct)))
	      (if (not (vequal data (vct 0.000 0.015 0.037 0.070 0.118 0.189 0.293 0.446 0.670 1.000)))
		  (snd-display ";define envelope ramp32 env-sound: ~A" data))
	      (undo)
	      (env-channel ramp032)
	      (set! data (channel->vct))
	      (if (not (vequal data (vct 0.000 0.328 0.552 0.705 0.809 0.880 0.929 0.962 0.985 1.000)))
		  (snd-display ";define envelope ramp032 env-sound: ~A" data))
	      (undo)
	      (if (provided? 'snd-debug)
		  (begin
		    (let ((we (window-env ramp32 0 100 0 200)))
		      (if (not (feql we (list 0.0 0.0 1.0 0.150)))
			  (snd-display ";window ramp32: ~A" we)))
		    (let ((we (window-env ramp32 100 100 0 200)))
		      (if (not (feql we (list 0.0 0.150 1.0 1.0)))
			  (snd-display ";window (100 100) ramp32: ~A" we)))
		    (let ((we (window-env ramp032 0 100 0 200)))
		      (if (not (feql we (list 0.0 0.0 1.0 0.848)))
			  (snd-display ";window ramp032: ~A" we)))
		    (let ((we (window-env ramp032 50 50 0 200)))
		      (if (not (feql we (list 0.0 0.596 1.0 0.848)))
			  (snd-display ";window (50 50) ramp032: ~A" we)))
		    (let ((we (window-env ramp12 50 100 0 200)))
		      (if (not (feql we (list 0.0 0.366 0.5 1.0 1.0 0.366)))
			  (snd-display ";window ramp12: ~A" we)))
		    (let ((me (multiply-envs '(0 1 1 1) ramp32 .1)))
		      (if (not (feql me (list 0.0 0.0 0.1 0.0134 0.2 0.032 0.3 0.059 0.4 0.097 0.5 0.150 0.6 0.226 0.7 0.333 0.8 0.484 0.9 0.697 1.0 1.0)))
			  (snd-display ";multiply ramp32+flat: ~A" me)))
		    (let ((me (multiply-envs '(0 0 1 1) ramp32 .1)))
		      (if (not (feql me (list 0.0 0.0 0.1 0.001 0.2 0.006 0.3 0.017 0.4 0.0388 0.5 0.075 0.6 0.135 0.7 0.233 0.8 0.387 0.9 0.628 1.0 1.0)))
			  (snd-display ";multiply ramp32+ramp: ~A" me)))
		    (let ((me (multiply-envs ramp32 ramp032 .1)))
		      (if (not (feql me (list 0.0 0.0 0.1 0.004 0.2 0.016 0.3 0.039 0.4 0.075 0.5 0.127 0.6 0.204 0.7 0.313 0.8 0.468 0.9 0.688 1.0 1.0)))
			  (snd-display ";multiply ramp32+ramp032: ~A" me)))
		    (let ((me (invert-env ramp32)))
		      (if (or (not (feql me (list 0.0 1.0 1.0 0.0)))
			      (not (number? (object-property me 'envelope-base)))
			      (fneq (object-property me 'envelope-base) (/ 1.0 32.0)))
			  (snd-display ";invert env (ramp32): ~A ~A" me (object-properties me))))
		    (let ((me (invert-env ramp012)))
		      (if (or (not (feql me (list 0.0 1.0 1.0 0.0 2.0 1.0)))
			      (not (number? (object-property me 'envelope-base)))
			      (fneq (object-property me 'envelope-base) (/ 1.0 0.3)))
			  (snd-display ";invert env (ramp012): ~A ~A" me (object-properties me))))
		    (let ((me (invert-env test-ramp)))
		      (if (or (not (feql me (list 0.0 0.0 1.0 1.0)))
			      (and (number? (object-property me 'envelope-base))
				   (fneq (object-property me 'envelope-base) 1.0)))
			  (snd-display ";invert env (test-ramp): ~A ~A" me (object-properties me))))
		    (let ((we (window-env ramp32 0 100 0 200 .1)))
		      (if (not (feql we (list 0.0 0.0 0.200 0.0133 0.400 0.0322 0.600 0.0589 0.800 0.0967 1.0 0.150)))
			  (snd-display ";window ramp32 i: ~A" we)))
		    (let ((we (window-env ramp32 100 100 0 200 .2)))
		      (if (not (feql we (list 0.0 0.150 0.4 0.333 0.8 0.697 1.0 1.0)))
			  (snd-display ";window (100 100) ramp32 i: ~A" we)))
		    (let ((we (window-env ramp032 0 100 0 200 .1)))
		      (if (not (feql we (list 0.0 0.0 0.200 0.300 0.400 0.514 0.600 0.665 0.800 0.772 1.0 0.848)))
			  (snd-display ";window ramp032 i: ~A" we)))
		    (let ((we (window-env ramp032 50 50 0 200 .2)))
		      (if (not (feql we (list 0.0 0.596 0.8 0.813 1.0 0.848)))
			  (snd-display ";window (50 50) ramp032 i: ~A" we)))
		    (let ((we (window-env ramp12 50 100 0 200 .1)))
		      (if (not (feql we (list 0.0 0.366 0.100 0.466 0.200 0.578 0.300 0.704 0.400 0.843 
					      0.5 1.0 0.60 0.843 0.70 0.704 0.80 0.578 0.90 0.466 1.0 0.366)))
			  (snd-display ";window ramp12 i: ~A" we)))))

	      (close-sound ind)))

	  (if (not (provided? 'snd-nogui))
	      (begin
		(load "oscope.scm")
		;; oscope exists
		(if (not (sound-data? (cadr oscope))) (snd-display ";oscope: ~A" oscope))
		(if (provided? 'snd-motif)
		    (XtUnmanageChild oscope-dialog)
		    (gtk_widget_hide oscope-dialog))))

      (run-hook after-test-hook 11)
      ))

(define 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))

(define sf-dir-len (if sf-dir-files (length sf-dir-files) 0))
(define buffer-menu #f)

(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))))))


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

(define (spectral-difference snd1 snd2)
  (let* ((size (max (frames snd1) (frames snd2)))
	 (pow2 (ceiling (/ (log size) (log 2))))
	 (fftlen (inexact->exact (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 ";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 ";translate spectral difference ~A ~A: ~A > ~A?" snd1 snd2 diff maxok)))))

(if (and with-gui (or full-test (= snd-test 12) (and keep-going (<= snd-test 12))))
    (if sf-dir-files
	(let ((open-files '())
	      (open-ctr 0))
	  (run-hook before-test-hook 12)
	  (add-sound-file-extension "wave")

      (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 (inexact->exact (floor (my-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 ";~A ~A ~A" name ht df)
					      -1))
				     -1))))
		    (if (not (= 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 (inexact->exact (floor (my-random (exact->inexact (length open-files))))))
			     (fd (list-ref open-files choice)))
			(close-sound fd)
			(set! open-files (remove-if (lambda (a) (= a fd)) open-files)))))))
	  (if open-files (for-each close-sound open-files))
          (set! open-files '())

	  (if (not (= (length (sounds)) 0)) (snd-display ";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 ";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-sample-reader 0 ind 0)))
	      (close-sound ind)
	      (if (not (sample-reader? hi)) (snd-display ";dangling reader? ~A" hi))
	      (let ((name (format #f "~A" hi)))
		(if (not (string? name)) (snd-display ";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 ";dangling read: ~A ~A ~A ~A" val val1 val2 val3))
		(if (sample-reader-home hi) (snd-display ";dangling reader home: ~A" (sample-reader-home hi)))
		(if (not (= (sample-reader-position hi) 0)) (snd-display ";dangling sample-reader-position: ~A" (sample-reader-position hi)))
		(if (not (sample-reader-at-end? hi)) (snd-display ";dangling reader eof: ~A" (sample-reader-at-end? hi)))
		(free-sample-reader hi))))
	  ;;; same (pruned edit)
	  (let ((ind (open-sound "oboe.snd")))
	    (delete-samples 100 100)
	    (let ((hi (make-sample-reader 0 ind 0)))
	      (revert-sound)
	      (delete-samples 100 100)
	      (if (not (sample-reader? hi)) (snd-display ";pruned dangling reader? ~A" hi))
	      (let ((name (format #f "~A" hi)))
		(if (not (string? name)) (snd-display ";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 ";pruned dangling read: ~A ~A ~A ~A" val val1 val2 val3))
		(if (not (equal? (sample-reader-home hi) (list ind 0))) (snd-display ";pruned dangling reader home: ~A" (sample-reader-home hi)))
		(if (not (sample-reader-at-end? hi)) (snd-display ";pruned dangling reader eof: ~A" (sample-reader-at-end? hi)))
		(free-sample-reader hi)))
	    (close-sound ind))
	  ;; region reader
	  (let* ((ind (open-sound "oboe.snd"))
		 (reg (make-region 1000 2000 ind 0))
		 (rd (make-region-sample-reader 0 reg)))
	    (if (mix-sample-reader? rd) (snd-display ";region sample-reader: mix ~A" rd))
	    (if (not (region-sample-reader? rd)) (snd-display ";region sample-reader: region ~A" rd))
	    (if (track-sample-reader? rd) (snd-display ";region sample-reader: track ~A" rd))
	    (if (sample-reader? rd) (snd-display ";region sample-reader: normal ~A" rd))
	    ;(if (not (= (sample-reader-position rd) 0)) (snd-display ";region sample-reader position: ~A" (sample-reader-position rd)))
	    (if (not (equal? (sample-reader-home rd) (list reg 0))) (snd-display ";region sample-reader home: ~A" (sample-reader-home rd)))
	    (if (sample-reader-at-end? rd) (snd-display ";region sample-reader at end?: ~A" (sample-reader-at-end? rd)))
	    (let ((val (rd)))
	      (if (fneq val .0328) (snd-display ";region-sample-reader at start: ~A" val))
	      (if (not (string? (format #f "~A" rd))) (snd-display ";region-sample-reader: ~A" (format #f "~A" rd)))
	      (close-sound ind)
	      ;; reader is still ok presumably
	      (set! val (next-sample rd))
	      (if (fneq val .0348) (snd-display ";region-sample-reader at 1: ~A" val))
	      (forget-region reg)
	      (set! val (read-sample rd))
	      (if (fneq val 0.0) (snd-display ";region-sample-reader at end: ~A" val))
	      (if (not (sample-reader-at-end? rd)) (snd-display ";region-sample-reader after deletion?"))
	      (free-sample-reader 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 (mix-region 0 reg ind 0))
		   (rd (make-mix-sample-reader md)))
	      (set! (mix-property :hi md) "hi")
	      (set! save-md md)
	      (if (not (string=? (mix-property :hi md) "hi")) (snd-display ";mix(9)-property: ~A" (mix-property :hi md)))
	      (let ((val (rd)))
		(if (fneq val .0328) (snd-display ";mix-sample-reader at start: ~A" val))
		(if (not (string? (format #f "~A" rd))) (snd-display ";mix-sample-reader: ~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 ";mix-property bad mix: ~A" tag)))
		(let ((str (format #f "~A" rd)))
		  (if (not (string=? str "#<mix-sample-reader: inactive>")) (snd-display ";mix-sample-reader released: ~A" str))
		  (set! val (read-mix-sample rd))
		  (if (fneq val 0.0) (snd-display ";mix-sample-reader at end: ~A" val))
		  (free-sample-reader rd))))
	    ;; track reader
	    (let* ((ind (open-sound "oboe.snd"))
		   (reg (make-region 1000 2000 ind 0))
		   (md (mix-region 0 reg ind 0))
		   (trk (make-track)))
	      (set! (mix-track md) trk)
	      (let ((rd (make-track-sample-reader trk)))
		(let ((val (rd)))
		  (if (fneq val .0328) (snd-display ";track-sample-reader at start: ~A" val))
		  (if (not (string? (format #f "~A" rd))) (snd-display ";track-sample-reader: ~A" (format #f "~A" rd)))
		  (close-sound ind)
		  (let ((tag (catch #t
				    (lambda () (mix-property :hi save-md))
				    (lambda args (car args)))))
		    (if (not (eq? tag 'no-such-mix)) (snd-display ";mix-property(2) bad mix: ~A" tag)))
		  (let ((str (format #f "~A" rd)))
		    (if (not (string? str)) (snd-display ";track-sample-reader released: ~A" str))
		    (set! val (read-track-sample rd))
		    (if (fneq val 0.0) (snd-display ";track-sample-reader at end: ~A" val))
		    (free-sample-reader rd)
		    (for-each
		     (lambda (n b)
		       (let ((tag (catch #t
					 (lambda ()
					   (n md))
					 (lambda args (car args)))))
			 (if (not (eq? tag 'no-such-mix))
			     (snd-display ";~A: ~A" b tag))))
		     (list mix-amp mix-tag-position mix-chans mix-track mix-frames mix-locked?
			   mix-position mix-home mix-speed mix-tag-y)
		     (list 'mix-amp 'mix-tag-position 'mix-chans 'mix-track 'mix-frames 'mix-locked?
			   'mix-position 'mix-home 'mix-speed 'mix-tag-y)))
		  ))))
	  (reset-hook! mix-click-hook)
	  (reset-hook! close-hook)
	  
	  (let* ((ind (open-sound "oboe.snd"))
		 (reg (make-region 1000 2000 ind 0))
		 (md1 (mix-region 0 reg ind 0))
		 (md2 (mix-region 1000 reg ind 0))
		 (trk (make-track md1 md2)))
	    (let ((rd (make-track-sample-reader trk)))
	      (let ((val (rd)))
		(if (fneq val .0328) (snd-display ";track-sample-reader(1) at start: ~A" val))
		(if (not (string? (format #f "~A" rd))) (snd-display ";track-sample-reader(1): ~A" (format #f "~A" rd)))
		(undo 1)
		(delete-sample 5000)
		(let ((str (format #f "~A" rd)))
		  (if (not (string? str)) (snd-display ";track-sample-reader (1) released: ~A" str))
		  (set! val (read-track-sample rd))
		  (if (fneq val 0.0348) (snd-display ";track-sample-reader (1) at end: ~A" val))
		  (set! (with-mix-tags) #f)
		  (set! md1 (mix-region 0 reg))
		  (if (not (= md1 -1)) (snd-display ";mix-region + #f tags: ~A" md1))
		  (set! (with-mix-tags) #t)
		  (close-sound ind)
		  (let ((str (format #f "~A" rd)))
		    (if (not (string? str)) (snd-display ";track-sample-reader (2) released: ~A" str))
		    (set! val (read-track-sample rd))
		    (if (fneq val 0.0) (snd-display ";track-sample-reader (2) at end: ~A" val))
		    (free-sample-reader rd))))))
	  
	  (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 (or (not (equal? ffiles (list "s24.snd")))
		    (not (equal? sfiles (list "s24.snd"))))
		(snd-display ";map|for-each-sound-file(s): ~A ~A" ffiles sfiles)))
	  )
	  (run-hook after-test-hook 12)
	  )))

(define read-or-run
  (lambda (fil)
    (let ((val (peek-char fil)))
      (or (and val (read-char fil))
          (c-g?)
          (read-or-run fil)))))

(define execute-and-wait
  (lambda (cmd)
    (let ((fil (open-pipe cmd "r")))
      (do ((val (read-or-run fil) (read-or-run fil)))
          ((or (eq? val #t) (eof-object? val))
           (eq? val #t))
        (write-char val (current-output-port)))
      (close-pipe fil))))

(define loop-through-files
  (lambda (description make-cmd select)
    (let* ((data (if select 
		     (selection-to-temps mus-next mus-out-format) 
		     (sound-to-temps mus-next mus-out-format)))
           (input-names (temp-filenames data))
           (files (vector-length input-names))
           (output-names (make-vector files ""))
           (stopped #f))
      (do ((i 0 (1+ i)))
          ((or stopped (= i files)))
        (vector-set! output-names i (string-append (tmpnam) ".snd"))
        (set! stopped (execute-and-wait (make-cmd (vector-ref input-names i) (vector-ref output-names i)))))
      (if select 
	  (temps-to-selection data output-names description)
	  (temps-to-sound data output-names description)))))

(define copyfile-1
  (lambda (select)
    (loop-through-files
     "(cp)"
     (lambda (in out)
       (string-append "cp " in " " out))
     select)))

(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 ";~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) (+ n 32)))"))
	 (snd-display ";~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) (+ n m 32)))"))
	 (snd-display ";~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) (+ a b c 32)))"))
	 (snd-display ";~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) (+ a b c d 32)))"))
	 (snd-display ";~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 ";~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) (+ a b c d e f 32)))"))
	 (snd-display ";~A: ~A?" ',hook str))))

(define (test-hooks)
  (define (arg0) 32)
  (define (arg1 n) (+ n 32))
  (define (arg2 n m) (+ n m 32))
  (define (arg3 a b c) (+ a b c 32))
  (define (arg4 a b c d) (+ a b c d 32))
  (define (arg5 a b c d e) (list 0 0 1 1))
  (define (arg6 a b c d e f) (+ a b c d e f 32))
  (reset-almost-all-hooks)
  
  (add-hook! after-graph-hook arg2) (carg2 after-graph-hook)
  (add-hook! lisp-graph-hook arg2) (carg2 lisp-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! 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! draw-mark-hook arg1) (carg1 draw-mark-hook)
  (add-hook! drop-hook arg1) (carg1 drop-hook)
  (add-hook! just-sounds-hook arg1) (carg1 just-sounds-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! mark-drag-hook arg1) (carg1 mark-drag-hook)
  (add-hook! mix-drag-hook arg1) (carg1 mix-drag-hook)
  (add-hook! name-click-hook arg1) (carg1 name-click-hook)
  (add-hook! after-apply-hook arg1) (carg1 after-apply-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! previous-files-select-hook arg1) (carg1 previous-files-select-hook)
  
  (add-hook! exit-hook arg0) (carg0 exit-hook)
  (add-hook! stop-dac-hook arg0) (carg0 stop-dac-hook)
  (add-hook! output-name-hook arg0) (carg0 output-name-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! selection-changed-hook arg0) (carg0 selection-changed-hook)
  
  (add-hook! during-open-hook arg3) (carg3 during-open-hook)
  (add-hook! transform-hook arg3) (carg3 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! 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)
  (reset-almost-all-hooks)
  (for-each 
   (lambda (n) 
     (if (and (not (hook-empty? n))
	      (not (eq? n optimization-hook)))
	 (snd-display ";~A not empty?" n)))
   (snd-hooks))
  )

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

(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")))
      
(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)
		       (XtIsSensitive menu)
		       (not (member (XtName menu)
				    (list "Exit" "New" 
					  "Save   C-x C-s" 
					  "Close  C-x k"
					  "Save options"
					  "Mixes" "clm" "fm-violin"))))
		  (XtCallCallbacks menu XmNactivateCallback (snd-global-state)))))))))
  (map close-sound (sounds))
  (dismiss-all-dialogs))

(define (mdt-test id x time drg) #f)

(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 mus-audio-default (srate) 1 mus-lshort (* block-size 2)))
	 (ra (ladspa-run-adding descriptor handle block-size)))
    (if ra (snd-display ";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)
       (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 ()
       (ladspa-deactivate descriptor handle)
       (mus-audio-close audio-port)
       (ladspa-cleanup descriptor handle))))))

(reset-almost-all-hooks)

(if (or full-test (= snd-test 13) (and keep-going (<= snd-test 13)))
    (let ((fd (view-sound "oboe.snd"))
	  (mb (add-to-main-menu "clm")))
      (run-hook before-test-hook 13)
      
      (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 ";add-to-menu bad menu: ~A" var)))
      
      (set! (cursor fd) 2000)
      (set! (transform-graph-type) graph-once)
      (set! (transform-graph? fd) #t)
      (if with-gui
	  (begin
	    (add-to-menu mb "not here" (lambda () (snd-display ";oops")))
	    (remove-from-menu mb "not here")
	    (add-to-menu 3 "Denoise" (lambda () (report-in-minibuffer "denoise")))))
      (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 ";help-hook subject: ~A" a))
			       (if (not (string=? b "(cursor-position (snd #f) (chn #f)): current cursor position (x y in pixels) in snd's channel chn"))
				   (snd-display ";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 ";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 ";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 ";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 ";hook-member #f? ~A" (hook->list mark-drag-triangle-hook)))
      (reset-hook! mark-drag-triangle-hook)
      (let ((fr (frames fd))
	    (chn (chans fd))
	    (sr (srate fd))
	    (mx (maxamp fd)))
	(copyfile-1 #f)
	(if (not (equal? (edit-fragment) '("(cp)" "set" 0 50828))) (snd-display ";copyfile-1: ~A?" (edit-fragment)))
	(if (or (not (= fr (frames fd)))
		(not (= chn (chans fd)))
		(fneq mx (maxamp fd))
		(fneq sr (srate fd)))
	    (snd-display ";copyfile(1): ~A ~A ~A ~A?" (frames fd) (chans fd) (srate fd) (maxamp fd)))
	(let ((eds (edits)))
	  (preload-file "oboe.snd")
	  (preload-directory ".")
	  (select-all)
	  (copyfile-1 #t)
	  (if (not (equal? (edit-fragment) '("(cp)" "set" 0 50828))) (snd-display ";copyfile-1 (select): ~A?" (edit-fragment)))
	  (if (not (equal? (edits) (list (+ (car eds) 1) (cadr eds)))) (snd-display ";copyfile-1 (select eds): ~A ~A?" eds (edits)))
	  (if (or (not (= fr (frames fd)))
		  (not (= chn (chans fd)))
		  (fneq mx (maxamp fd))
		  (fneq sr (srate fd)))
	      (snd-display ";copyfile(2): ~A ~A ~A ~A?" (frames fd) (chans fd) (srate fd) (maxamp fd)))))
      
      (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)
	 (transform->vct fd 0))
       (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 ";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 ";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 ";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 ";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 ";scale-selection-to with vector: ~A" (maxamp fd #t)))
      (close-sound fd)
      
      (set! fd (open-sound "obtest.snd"))
      (if (defined? 'window-property)
	  (begin
	    (let ((names (short-file-name #t)))
	      (if (provided? 'xm) (XSynchronize (XtDisplay (cadr (main-widgets))) #t))
	      (set! (window-property "SND_VERSION" "WM_NAME")
		    (format #f "snd (~A)~A"
			    (strftime "%d-%b %H:%M %Z" (localtime (current-time)))
		      (if (null? names)
			  ""
			  (format #f ":~{~A~^, ~}" names)))))
	    (let ((gotit #f)
		  (oldsize (vu-size)))
	      (add-hook! window-property-changed-hook (lambda (hi) (set! gotit #t) #f))
	      (set! (window-property "SND_VERSION" "SND_COMMAND") "(set! (vu-size) .5)")
	      (if (not (string=? (window-property "SND_VERSION" "SND_COMMAND") "(set! (vu-size) .5)"))
		  (snd-display ";window-property: ~A" (window-property "SND_VERSION" "SND_COMMAND")))
	      (reset-hook! window-property-changed-hook)
	      (set! (window-property "SND_VERSION" "SND_COMMAND") "(make-vector 10 3.14)")
	      (if (provided? 'xm) (XSynchronize (XtDisplay (cadr (main-widgets))) #f))
	      (if (or (not gotit)
		      (fneq (vu-size) 0.5))
		  (snd-display ";property vu-size: ~A" (vu-size)))
	      (set! (vu-size) oldsize))))
      
      (let ((ctr 0))
	(let ((added 0))
	  (set! (with-background-processes) #t)
	  (set! (vu-size) 1.25)
	  (add-hook! new-widget-hook
		     (lambda (w)
		       (set! added (+ added 1))))
	  (if (provided? 'snd-motif)
	      (without-errors
	       (test-menus)) ; built-in self-test function -- now closes all sounds due to unpredictable changes elsewhere
	      (begin
		(map close-sound (sounds))
		(dismiss-all-dialogs)))
	  (if (sound? fd) 
	      (begin 
		(snd-display ";close all didn't? ~A ~A ~A" fd (sound? fd) (short-file-name fd))
		(close-sound fd)))
	  (set! fd (open-sound "obtest.snd"))	  
	  (set! (with-background-processes) #f)
	  (if (= added 0)
	      (snd-display ";no widgets added?"))
	  (reset-hook! new-widget-hook))
	
	(if (provided? 'snd-ladspa)
	    (if (file-exists? "/home/bil/test/ladspa_sdk/plugins")
		(begin
		  (set! (ladspa-dir) "/home/bil/test/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 ";ladspa .Label: ~A" label))
		    (if (not (string=? name "Simple Delay Line")) 
			(snd-display ";ladspa .Name: ~A" name))
		    (if (not (string=? maker "Richard Furse (LADSPA example plugins)"))
			(snd-display ";ladspa .Maker: ~A" maker))
		    (if (not (string=? copy "None"))
			(snd-display ";ladspa .Copyright: ~A" copy))
		    (if (not (= id 1043)) (snd-display ";ladspa .UniqueID: ~A" id))
		    (if (not (= count 4)) (snd-display ";ladspa .PortCount: ~A" count))
		    (if (not (= props 4)) (snd-display ";ladspa .Properties: ~A" prop))
		    (if (not (equal? names (list "Delay (Seconds)" "Dry/Wet Balance" "Input" "Output")))
			(snd-display ";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 ";ladspa .PortRangeHints: ~A" hints))
		    (if (not (equal? descs (list 5 5 9 10)))
			(snd-display ";ladspa .PortDescriptors: ~A" descs))
		    (if (not (= (logand (cadr (.PortDescriptors ptr)) LADSPA_PORT_INPUT) 1))
			(snd-display ";ladspa port hint: ~A" (logand (cadr (.PortDescriptors ptr)) LADSPA_PORT_INPUT))))
		  (apply-ladspa (make-sample-reader 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 ";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-sample-reader 0) (list "delay" "delay_4s" .3 .5) 1000 "delayed"))
				    (lambda args args))))
		    (if (not (eq? (car tag) 'no-such-plugin))
			(snd-display ";apply-ladspa bad plugin: ~A" tag)))
		  (let ((tag (catch #t 
				    (lambda () 
				      (apply-ladspa (list (make-sample-reader 0) (make-sample-reader 0)) (list "delay" "delay_5s" .3 .5) 1000 "delayed"))
				    (lambda args args))))
		    (if (not (eq? (car tag) 'plugin-error))
			(snd-display ";apply-ladspa reader mismatch: ~A" tag)))
		  (let ((vals (list-ladspa)))
		    (if (not (list-p vals))
			(snd-display ";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 ";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 ";analyse-ladspa tag: ~A" tag)))
		  (let ((tag (catch #t
				    (lambda ()
				      (apply-ladspa (list (make-sample-reader 0) (make-sample-reader 0)) (list #f) 1000 "delayed"))
				    (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";apply-ladspa tag: ~A" tag))))
		(snd-display ";ladspa loaded but can't find plugin directory: ~A" (ladspa-dir))))
	
	(revert-sound fd)
	(close-sound fd))
      
      (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 ";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 ";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 ";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 ";search-procedure C-s C-s cursor: ~D?" (cursor ind 0)))
	(if with-gui
	    (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
	      (if (not (string=? str "y = .101 at .201 (4423)"))
		  (snd-display ";C-s 4423 report-in-minibuffer: ~A?" str))))
	(let ((str (with-output-to-string (lambda () (display (procedure-source (search-procedure ind)))))))
	  (if (not (string=? str "(lambda (n4) (> n4 0.1))"))
	      (snd-display ";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 ";search-procedure C-s C-s cursor failed: ~D?" (cursor ind 0)))
	(if with-gui
	    (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
	      (if (not (or (string=? str "not found") ; the lack of search expr is a bug
			   (string=? str "not found (wrapped)")))
		  (snd-display ";C-s failure report-in-minibuffer: ~A?" str))))
	(let ((str (with-output-to-string (lambda () (display (procedure-source (search-procedure ind)))))))
	  (if (not (string=? str "(lambda (n) (> n 0.2))"))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";unopt search-procedure C-s C-s cursor: ~D?" (cursor ind 0)))
	  (set! (search-procedure ind) (lambda (n) (> n .2)))
	  (set! (cursor ind 0) (1- (frames)))
	  (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-and-wait 0 ind)
	(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 ";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 ((ind (open-sound "oboe.snd")))
	(save-sound-as "test.snd" ind mus-raw)
	(close-sound ind)
	(reset-hook! open-raw-sound-hook)
	(add-hook! open-raw-sound-hook 
		   (lambda (file choice)
		     (if (not (string=? (substring file (- (string-length file) 8)) "test.snd"))
			 (snd-display ";open-raw-sound-hook file: ~A?" (substring file (- (string-length file) 8))))
		     (if (not (eq? choice #f))
			 (snd-display ";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 ";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)
		     ;; append to list
		     (if (not (equal? choice (list 2 44100 mus-mulaw)))
			 (snd-display ";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 ";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 ";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 ";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 (open-sound "oboe.snd"))
	     (mx0 (maxamp ind)))
	(save-sound-as "test.snd" ind mus-next mus-bfloat)
	(close-sound ind)
	(add-hook! during-open-hook
		   (lambda (fd name reason)
		     (set! (mus-file-prescaler fd) 4.0)))
	(let* ((ind1 (open-sound "test.snd"))
	       (mx1 (maxamp ind1)))
	  (if (fneq mx1 (* 4.0 mx0)) (snd-display ";set prescaler: ~A -> ~A" mx0 mx1))
	  (close-sound ind1)))
      (reset-hook! during-open-hook)

      (let ((ind #f)
	    (op #f)
	    (sl #f)
	    (aop #f)
	    (dop #f)
	    (cl #f)
	    (ig #f)
	    (scl #f)
	    (sel #f)
	    (other #f))
	(add-hook! open-hook 
		   (lambda (filename)
		     (if (not (string=? filename (mus-expand-filename "oboe.snd")))
			 (snd-display ";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 ";during-open-hook filename: ~A?" filename))
		     (if (not (= reason 1))
			 (snd-display ";during-open-hook reason: ~A?" reason))))
	(add-hook! initial-graph-hook
		   (lambda (snd chn dur)
		     (if (not (= chn 0))
			 (snd-display ";initial-graph-hook (channel): ~A not 0?" chn))
		     (set! ig #t)
		     #f))
	(add-hook! selection-changed-hook (lambda () (set! sel #t)))
	
	(set! ind (open-sound "oboe.snd"))
	
	(if (not op) (snd-display ";open-hook not called?"))
	(if (not dop) (snd-display ";during-open-hook not called?"))
	(if (not ig) (snd-display ";initial-graph-hook not called?"))
	(if (not (number? aop)) (snd-display ";after-open-hook not called?"))
	(if (not (= aop ind)) (snd-display ";after-open-hook ~A but ind: ~A?" aop ind))
	(if sel (snd-display ";selection-changed-hook called for no reason?"))
	(select-all)
	(if (not sel) (snd-display ";selection-changed-hook not called?"))
	(reset-hook! open-hook)
	(reset-hook! during-open-hook)
	(reset-hook! after-open-hook)
	(reset-hook! initial-graph-hook)
	(reset-hook! selection-changed-hook)
	
	(add-hook! open-hook (lambda (filename) #t))
	(let ((pistol (open-sound "pistol.snd")))
	  (if (not (eq? pistol #f))
	      (begin
		(snd-display ";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! transform-hook)
	  (reset-hook! after-graph-hook)
	  (reset-hook! graph-hook)
	  (add-hook! graph-hook
		     (lambda (snd chn y0 y1)
		       (if (not (= snd ind))
			   (snd-display ";graph-hook: ~A not ~A?" snd ind))
		       (if (not (= chn 0))
			   (snd-display ";graph-hook (channel): ~A not 0?" chn))
		       (set! gr #t)
		       #f))
	  (add-hook! after-graph-hook
		     (lambda (snd chn)
		       (if (not (= snd ind))
			   (snd-display ";after-graph-hook: ~A not ~A?" snd ind))
		       (if (not (= chn 0))
			   (snd-display ";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! 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) (snd-display ";graph-hook not called? ~A ~A ~A ~A" (time-graph? ind) (short-file-name ind) ind (sounds)))
	  (if (not agr) (snd-display ";after-graph-hook not called?"))
	  (if (not gbf) (snd-display ";before-transform-hook not called?"))
	  (if (not abf) (snd-display ";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 (= snd ind))
			 (snd-display ";select-sound-hook: ~A not ~A?" snd ind))
		     (set! sl #t)))
	(add-hook! select-channel-hook 
		   (lambda (snd chn) 
		     (if (not (= snd ind))
			 (snd-display ";select-channel-hook: ~A not ~A?" snd ind))
		     (if (not (= chn 0))
			 (snd-display ";select-channel-hook (channel): ~A not 0?" chn))
		     (set! scl #t)))
	
	(select-sound ind)
	(if (not sl) (snd-display ";select-sound-hook not called?"))
	(if (not scl) (snd-display ";select-channel-hook not called?"))
	(reset-hook! select-sound-hook)
	(reset-hook! select-channel-hook)
	
	(let ((spl #f)
	      (stl #f)
	      (ph #f)
	      (ph1 #f)
	      (pc #f))
	  (add-hook! start-playing-hook
		     (lambda (snd)
		       (if (not (= snd ind))
			   (snd-display ";start-playing-hook: ~A not ~A?" snd ind))
		       (set! spl #t)
		       #f))
	  (add-hook! stop-playing-hook
		     (lambda (snd)
		       (if (not (= snd ind))
			   (snd-display ";stop-playing-hook: ~A not ~A?" snd ind))
		       (set! stl #t)))
	  (add-hook! play-hook
		     (lambda (n)
		       (if (< n 128)
			   (snd-display ";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 ";dac-hook data: ~A?" n))
		       (if (and (< (sound-data-length n) 128)
				(not (= sound-data-length n) 64)) ; mac case
			   (snd-display ";dac-hook data length: ~A?" (sound-data-length n)))
		       (set! ph1 #t)))
	  
	  (set! (expand-control? ind) #t)
	  (set! (reverb-control? ind) #t)
	  (play-and-wait 0 ind)
	  (set! (reverb-control? ind) #f)
	  (set! (expand-control? ind) #f)
	  
	  (if (not spl) (snd-display ";start-playing-hook not called?"))
	  (if (not stl) (snd-display ";stop-playing-hook not called?"))
	  (if (not ph) (snd-display ";play-hook not called?"))
	  (if (not ph1) (snd-display ";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-and-wait 0 ind)
	  (reset-hook! play-hook)
	  
	  (add-hook! start-playing-hook (lambda (sp) #t))
	  (play "4.aiff")
	  (reset-hook! start-playing-hook)
	  
	  (let ((sr -1)
		(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 #t)
	      (play-region reg #t)
	      (if (not ss) (snd-display ";stop-playing-selection-hook: ~A" ss)))
	    (reset-hook! stop-playing-selection-hook))
	  
	  (let ((ctr 0))
	    (add-hook! dac-hook
		       (lambda (n)
			 (set! ctr (1+ ctr))
			 (stop-playing)))
	    (play-and-wait 0 ind)
	    (if (> ctr 2) (snd-display ";stop-playing: ~A" ctr))
	    (reset-hook! dac-hook))
	  
	  (let ((pl (make-player ind 0))
		(ctr 0))
	    (if (not (player? pl)) (snd-display ";make-player: ~A" pl))
	    (if (= (length (players)) 0) (snd-display ";players: ~A" (players)))
	    (add-hook! dac-hook
		       (lambda (n)
			 (set! ctr (1+ ctr))
			 (if (player? pl)
			     (stop-player pl)
			     (if (= ctr 1)
				 (snd-display ";player messed up")))))
	    (add-player pl)
	    (start-playing 1 22050 #f)
	    (if (> ctr 2) (snd-display ";stop-player: ~A" ctr))
	    (reset-hook! dac-hook))
	  )
	
	(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 ";edit-hook #t didn't disallow edit!"))
	  (if (not e0) (snd-display ";edit-hook #t not called?"))
	  (if a0 (snd-display ";after-edit-hook 0 called?"))
	  (undo 1 ind 0)
	  (if u0 (snd-display ";undo-hook called?"))
	  
	  (delete-sample 0 other 0)
	  (if (not (= (edit-position other 0) 1))
	      (snd-display ";edit-hook #f didn't allow edit!"))
	  (if (not e1) (snd-display ";edit-hook #f not called?"))
	  (if (not a1) (snd-display ";after-edit-hook 1 not called?"))
	  (undo 1 other 0)
	  (if (not u1) (snd-display ";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 ";snd-error-hook not called?"))
	  (if (not sw) (snd-display ";snd-warning-hook not called?"))
	  (if (not me) (snd-display ";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)
		       #f))
	  (snd-error "not an error")
	  (if (not (string=? se "not an error"))
	      (snd-display ";snd-error-hook saw: ~A" se))
	  (reset-hook! snd-error-hook))
	
	(add-hook! exit-hook (lambda () #f))
	(add-hook! exit-hook (lambda () #t))
	(add-hook! exit-hook (lambda () #f))
	(exit)
	(reset-hook! 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 ";save-hook filename: ~A?" filename))
		       (if (not (= snd ind))
			   (snd-display ";save-hook snd: ~A ~A?" snd ind))
		       (set! sh #t)
		       #t))
	  (save-sound-as "baddy.snd" ind)
	  (if (not sh) (snd-display ";save-hook not called?"))
	  (if (file-exists? "baddy.snd")
	      (begin
		(snd-display ";save-hook didn't cancel save?")
		(delete-file "baddy.snd")))
	  (reset-hook! save-hook))
	
	;; 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 (= snd ind))
			 (snd-display ";close-hook: ~A not ~A?" snd ind))
		     (set! cl #t)))
	
	(close-sound ind)
	(if (not cl) (snd-display ";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 ";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.5 ind 0 #f)
	(if (fneq (sample 100 ind 0) 0.5) (snd-display ";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 ";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"))

      (let ((in1 (open-sound "oboe.snd"))
	    (in2 (open-sound "2.snd")))
	(set! (sync in1) 1)
	(set! (sync in2) 1)
	(play-and-wait 0 #f #f #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) (delete-mix mx)))))
			      (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 123 reg 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 0) .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 0 1 1))))))
			      (list 'mix-track (lambda () 
						 (let ((mx (mix-vct (make-vct 3 1.0) 123))) 
						   (if (mix? mx) (set! (mix-track mx) (make-track))))))
			      (list 'mix-locked? (lambda () 
						   (let ((mx (mix-vct (make-vct 3 1.0) 123))) 
						     (if (mix? mx) (set! (mix-locked? mx) #t)))))
			      (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 123 reg 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 'track-amp (lambda () 
						 (let ((tr (if (null? (tracks)) (make-track) (car (tracks)))))
						   (let ((mx (mix-vct (make-vct 3 .1) 0 ind 0 #t "none" tr)))
						     (set! (track-amp tr) .5)))))
			      (list 'track-amp-env (lambda () 
						     (let ((tr (if (null? (tracks)) (make-track) (car (tracks)))))
						       (let ((mx (mix-vct (make-vct 3 .1) 0 ind 0 #t "none" tr)))
							 (set! (track-amp-env tr) '(0 0 1 1))))))
			      (list 'track-position (lambda () 
						      (let ((tr (if (null? (tracks)) (make-track) (car (tracks)))))
							(let ((mx (mix-vct (make-vct 3 .1) 0 ind 0 #t "none" tr)))
							  (set! (track-position tr) 5)))))
			      (list 'track-speed (lambda () 
						   (let ((tr (if (null? (tracks)) (make-track) (car (tracks)))))
						     (let ((mx (mix-vct (make-vct 3 .1) 0 ind 0 #t "none" tr))) 
						       (set! (track-speed tr) .5)))))
			      (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))))))
	
	(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 ";~A: blocked edit: ~A" name (edit-position ind 0)))
	     (if (not (= edit-hook-ctr 1)) (snd-display ";~A: edit hook calls: ~A" name edit-hook-ctr))
	     (if (not (= after-edit-hook-ctr 0)) (snd-display ";~A: after edit hook calls: ~A" name after-edit-hook-ctr))
	     (set! edit-hook-ctr 0)
	     (if (and (defined? 'edit-hook-checked) (edit-hook-checked ind 0)) (snd-display ";~A: edit-hook-checked not cleared"))
	     (if (not (equal? (mixes ind 0) '())) (snd-display ";~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 ";~A: unblocked edit: ~A" name (edit-position ind 0)))
	     (if (not (> edit-hook-ctr 0)) (snd-display ";~A: unblocked edit hook calls: ~A" name edit-hook-ctr))
	     (if (not (> after-edit-hook-ctr 0)) (snd-display ";~A: unblocked after edit hook calls: ~A" name after-edit-hook-ctr))
	     (set! edit-hook-ctr 0)
	     (set! after-edit-hook-ctr 0)
	     (if (and (defined? 'edit-hook-checked) (edit-hook-checked ind 0)) (snd-display ";~A: edit-hook-checked not cleared"))
	     (revert-sound ind)
	     (if (not (equal? (mixes ind 0) '())) (snd-display ";~A: mixes: ~A" name (mixes ind 0)))))
	 all-tests)
	(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)
      
      (run-hook after-test-hook 13)
      ))


(define (test-panel func name)
  (if (and (not (feql (func #t) (map func (sounds))))
	   (not (feql (func #t) (map func (reverse (sounds))))))
      (snd-display ";test-panel ~A: ~A ~A?" name (func #t) (map func (sounds)))))

(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 (all-chans-reversed)
  (let ((sndlist '())
	(chnlist '()))
    (for-each (lambda (snd)
		(do ((i (1- (channels snd)) (1- i)))
		    ((< 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 ";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)

(define (safe-make-region beg end snd)
  (let ((len (frames snd)))
					;(snd-display ";make ~D ~D " beg end)
    (if (> len 1)
	(if (< end len)
	    (make-region beg end snd)
	    (if (< beg len)
		(make-region beg (1- len) snd)
		(make-region 0 (1- len) snd))))))

(define sfile 0)

(define* (clone-sound-as new-name #:optional 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))


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

(define cur-dir-files (remove-if 
		       (lambda (file) (<= (catch #t 
						 (lambda () 
						   (mus-sound-frames file))
						 (lambda args 0))
					  0))
		       (sound-files-in-directory ".")))
(define cur-dir-len (length cur-dir-files))

(if (or full-test (= snd-test 14) (and keep-going (<= snd-test 14)))
    (let* ((stereo-files '())
	   (quad-files '())
	   (mono-files '())
	   (octo-files '())
	   (open-files '())
	   (s8-snd (if (file-exists? "s8.snd") "s8.snd" "oboe.snd"))
	   (open-ctr 0))
      (run-hook before-test-hook 14)
      (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)))))))))

      (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 '())))
	(clear-sincs)      
	(log-mem test-ctr)

	(if (> test-ctr 0)
	    (let ((files (length (sounds))))
	      (save-state "s61.scm")
	      (for-each close-sound (sounds))
	      (for-each forget-region (regions))
	      (load "s61.scm")
	      (if (not (= (length (sounds)) files))
		  (snd-display ";save state restart from ~A to ~A sounds?" files (length (sounds))))))

	(let* ((len (length open-files))
	       (open-chance (max 0.0 (* (- 8 len) .125)))
	       (close-chance (* len .125)))
	  (if (or (= len 0) (rs open-chance))
	      (let* ((choice (my-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))))
	      (if (and (> len 0) (rs close-chance))
		  (let* ((choice (my-random (length open-files)))
			 (fd (list-ref open-files choice)))
		    (close-sound fd)
		    (set! open-files (remove-if (lambda (a) (= a 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) (my-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 ";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 ";y-bounds: ~A?" yb)))
	      (set! (cursor curfd) curloc)
	      (let ((cl (cursor curfd)))
		(if (not (= cl curloc)) 
		    (begin
		      (snd-display ";cursor ~A /= ~A?" cl curloc)
		      (set! curloc (cursor)))))
	      (let* ((id (add-mark curloc curfd)))
		(if (and (number? id) (not (= id -1)))
		    (let* ((cl (mark-sample id))
			   (new-marks (length (marks curfd 0))))
		      (if (not (= cl curloc)) (snd-display ";mark ~A /= ~A?" cl curloc))
		      (if (not (= new-marks (1+ old-marks))) (snd-display ";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 ";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 ";find-mark (by name): ~A ~A?" id new-id)))
		      (if (not (string=? (mark-name id) "hiho")) (snd-display ";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 ";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 ";forward-mark (10): ~A (~A)?" (cursor curfd) (frames curfd)))
		      (forward-mark 1 curfd)
		      (if (and (> (frames curfd) 20)
			       (not (= (cursor curfd) 20)))
			  (snd-display ";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 ";backward-mark (10): ~A (~A)?" (cursor curfd) (frames curfd)))
		      (forward-sample 5 curfd)
		      (if (and (> (frames curfd) 15)
			       (not (= (cursor curfd) 15)))
			  (snd-display ";forward-sample (5): ~A (~A)?" (cursor curfd) (frames curfd)))
		      (backward-sample 1 curfd)
		      (if (and (> (frames curfd) 15)
			       (not (= (cursor curfd) 14)))
			  (snd-display ";backward-sample (1): ~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 2))))
			    (snd-display ";delete marks: ~A ~A?" new-marks old-marks)))))
		))
	    
	    (key (char->integer #\x) 4)
	    (key (char->integer #\() 0)
	    (key (char->integer #\f) 4)
	    (key (char->integer #\f) 4)
	    (key (char->integer #\x) 4)
	    (key (char->integer #\)) 0)
	    (key (char->integer #\x) 4)
	    (key (char->integer #\e) 0)
	    
	    (key (char->integer #\u) 4)
	    (key (char->integer #\.) 4)
	    (key (char->integer #\5) 4)
	    (key (char->integer #\x) 4)
	    (key (char->integer #\v) 4)
	    
	    (key (char->integer #\>) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\<) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\>) 0 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\<) 0 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\a) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\e) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\b) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (if (not (provided? 'snd-gtk)) (key (char->integer #\p) 4 (choose-fd))) ;this is apparently getting hung in gtk (or maybe it's the c-q below)
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\n) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\l) 4 (choose-fd))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\b) 0)))
	    (set! (cursor (choose-fd)) 1200)
	    (safe-make-region 1000 2000 (choose-fd))
	    (if (= (length (regions)) 0)
		(snd-display ";safe-make-region failed?")
		(begin
		  (if (selection?) (delete-selection))
		  (set! (cursor (choose-fd)) 0)
		  (insert-region (cursor) (car (regions)) (choose-fd))))
	    (revert-sound (choose-fd))
	    (key (char->integer #\m) 4 (choose-fd))
	    (key (char->integer #\v) 4 (choose-fd))
	    (key (char->integer #\d) 4 (choose-fd))
	    (key (char->integer #\z) 4 (choose-fd))
	    (key (char->integer #\o) 4 (choose-fd))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4)) (key (char->integer #\u) 0))
	    (undo 2 (choose-fd))
	    (key (char->integer #\<) 4 (choose-fd))
	    (key (char->integer #\i) 4 (choose-fd))
	    (key (char->integer #\w) 4 (choose-fd))
	    (key (char->integer #\y) 4 (choose-fd))
	    (if (not (provided? 'snd-gtk)) (key (char->integer #\q) 4 (choose-fd)))
	    (set! (cursor (choose-fd)) 8000)
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\f) 0) (key (char->integer #\g) 4)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\i) 0) (key (char->integer #\g) 4)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\l) 0) (key (char->integer #\g) 4)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\u) 0)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\r) 0)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\v) 0)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\o) 4)))
	    (if (rs 0.5) (begin (key (char->integer #\x) 4) (key (char->integer #\u) 4)))
	    
	    (revert-sound)
	    (select-all)
	    (without-errors
	     (if (and (region? 0) (selection?))
		 ;; these are not necessarily coupled any more
		 (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 ";region rms: ~A ~A?" r1 r4))
		   (if (fneq r2 r3)
		       (snd-display ";selection rms: ~A ~A?" r2 r3)))))
	    
	    (forward-graph (choose-fd))
	    (backward-graph (choose-fd))
	    
	    (without-errors (play-region (list-ref (regions) 2) #t))
	    (without-errors (mix-region))
	    (play-and-wait)
	    (scale-to .1 (choose-fd))
	    (scale-by 2.0 (choose-fd))
	    (equalize-panes)
	    (save-controls)
	    (set! (amp-control) .5)
	    (test-panel amp-control 'amp-control)
	    (restore-controls)
	    (report-in-minibuffer "hi")
	    (append-to-minibuffer "ho")
	    
	    (without-errors
	     (begin
	       (let ((cfd (choose-fd)))
		 (safe-make-region 1000 2000 cfd)
		 (src-selection .5)
		 (undo 1 cfd))
	       (let ((cfd (choose-fd)))
		 (safe-make-region 1000 2000 cfd)
		 (src-selection -1.5)
		 (undo 1 cfd))
	       (let ((cfd (choose-fd)))
		 (safe-make-region 1000 2000 cfd)
		 (scale-selection-by .5)
		 (undo 1 cfd))
	       (let ((cfd (choose-fd)))
		 (safe-make-region 1000 2000 cfd)
		 (env-selection '(0 0 1 1 2 0))
		 (undo 1 cfd))
	       (let ((cfd (choose-fd)))
		 (safe-make-region 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))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (src-selection .5)
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (src-selection -1.5)
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (env-selection '(0 0 1 1 2 0))
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (reverse-selection)
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (filter-selection '(0 0 .1 1 1 0) 40)
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (convolve-selection-with "oboe.snd")
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (smooth-selection)
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (safe-make-region 1000 2000 cfd)
		     (scale-selection-by .5)
		     (undo 1 cfd)))
	       (if (rs 0.5)
		   (begin
		     (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 (> (frames) 1) 
		(begin
		  (make-region 0 (frames))
		  (convolve-selection-with "fyow.snd" .5)
		  (play-and-wait)))
	    (convolve-with "fyow.snd" .25)
	    (insert-sound "oboe.snd")
	    (reset-hook! graph-hook)
	    (reset-hook! 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 (null? (peak-env-info ind))) (snd-display ";peak-env-info of empty sound: ~A" (peak-env-info ind)))
	      (restore-controls)
	      (if (not (equal? (peak-env-info ind) '()))
		  (snd-display ";peak-env-info z.snd: ~A" (peak-env-info ind)))
	      (let ((var (catch #t (lambda () (write-peak-env-info-file ind 0 "hi")) (lambda args args))))
		(if (not (eq? (car var) 'no-such-envelope))
		    (snd-display ";write-peak-env-info-file null env: ~A" var)))
	      (let ((var (catch #t (lambda () (read-peak-env-info-file ind 0 "hi")) (lambda args args))))
		(if (and (not (eq? (car var) 'no-such-file))
			 (not (eq? (car var) 'mus-error)))
		    (snd-display ";read-peak-env-info-file null file: ~A" var)))
	      (if (not (= (frames ind) 0)) (snd-display ";frames z.snd ~A" (frames ind)))
	      (if (not (eq? (samples) #f)) (snd-display ";samples of empty file (z): ~A" (samples)))
	      (if (not (eq? (channel->vct) #f)) (snd-display ";channel->vct of empty file (z): ~A" (channel->vct)))
	      (if (fneq (maxamp ind) 0.0) (snd-display ";maxamp z.snd ~A" (maxamp ind)))
	      (if (fneq (sample 100 ind) 0.0) (snd-display ";sample 100 z.snd ~A" (sample 100 ind)))
	      (scale-by 2.0)
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";scale z: ~A" (edit-position ind 0)))
	      (env-sound '(0 0 1 1))
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";env z: ~A" (edit-position ind 0)))
	      (smooth-sound)
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";smooth z: ~A" (edit-position ind 0)))
	      (reverse-sound)
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";reverse z: ~A" (edit-position ind 0)))
	      (src-sound 2.0)
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";src z: ~A" (edit-position ind 0)))
	      (insert-sound "z.snd")
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";insert z: ~A" (edit-position ind 0)))
	      (mix "z.snd")
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";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 ";filter z: ~A" (edit-position ind 0)))
	      (if (not (= (mus-sound-duration "z.snd") 0.0)) (snd-display ";duration z.snd: ~A" (mus-sound-duration "z.snd")))
	      (catch 'mus-error
		     (lambda () (convolve-with "z.snd" 1.0))
		     (lambda args args))
	      (if (not (= (edit-position ind 0) 0)) (snd-display ";convolve z: ~A" (edit-position ind 0)))
	      (let ((tag (catch #t (lambda () (find (lambda (y) *> y .1))) (lambda args (car args)))))
		(if (not (eq? tag 'no-such-sample)) (snd-display ";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 ";count z: ~A" tag)))
	      (let* ((reader (make-sample-reader 0))
		     (val (next-sample reader))
		     (str (format #f "~A" reader)))
		(if (fneq val 0.0) (snd-display ";sample-reader z.snd: ~A" val))
		(if (not (string? str)) (snd-display ";z.snd reader: ~A" str)))
	      (if (not (equal? (cursor-position) (list 0 0))) (snd-display ";cursor-position z: ~A" (cursor-position)))
	      (if (not (= (cursor) 0)) (snd-display ";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 ";dangling player: ~A" tag)))))
	    (if (channel-amp-envs "z.snd" 0 100)
		(snd-display ";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)
		(if (and (number? md) (>= md 0))
		    (begin
		      (set! (mix-locked? md) #t)
		      (if (not (mix-locked? md)) (snd-display ";set-mix-locked?: ~A?" (mix-locked? md))))))
	      (revert-sound zz)
	      (let ((editctr (edit-position zz)))
		(if (not (= (edit-position) 0)) (snd-display ";revert-sound edit-position: ~A" (edit-position)))
		(as-one-edit 
		 (lambda ()
		   (mix s8-snd 24000)
		   (select-all)
		   (if (selection?) 
		       (begin
			 (filter-selection '(0 0 .2 1 .5 0 1 0) 40)
			 (delete-selection)
			 (mix-region)))))
		(if (not (= (edit-position) 1)) (snd-display ";as-one-edit mix zz: ~A -> ~A" editctr (edit-position))))
	      (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 ";select-channel: ~A?" (selected-channel)))))
	      (let ((editctr (edit-position)))
		(as-one-edit 
		 (lambda ()
		   (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))
		   (insert-region 80000)))
		(if (not (= (edit-position) (1+ editctr))) (snd-display ";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 (my-random 3)))
		    (set! (channel-style cfd) uval)
		    (if (not (= uval (channel-style cfd))) (snd-display ";channel-style: ~A ~A?" uval (channel-style cfd)))))
	      (if (rs 0.5) (src-sound 2.5 1.0 cfd))
	      (if (rs 0.5) (src-sound -2.5 1.0 cfd))
	      (if (rs 0.5) (src-sound .5 1.0 cfd))
	      (if (rs 0.5) (revert-sound cfd))
	      (if (rs 0.5) (src-sound -.5 1.0 cfd))
	      (if (rs 0.5) (src-sound '(0 .5 1 1.5) 1.0 cfd))
	      (if (rs 0.5) (if (> (frames cfd) 0) (src-sound (make-env '(0 .5 1 1.5) :end (1- (frames cfd))) 1.0 cfd)))
	      (if (rs 0.5) (revert-sound cfd))
	      (if (rs 0.5) (filter-sound '(0 1 .2 0 .5 1 1 0) 20 cfd))      ; FIR direct form
	      (if (rs 0.5) (filter-sound '(0 0 .1 0 .11 1 .12 0 1 0) 2048 cfd))
	      (if (rs 0.5) (env-sound '(0 0 .5 1 1 0) 0 (frames cfd) 1.0 cfd))
	      (if (rs 0.5)
		  (begin
		    (insert-sample 1200 .1 cfd)
		    (if (fneq (sample 1200 cfd) .1) (snd-display ";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) 
		(play-and-wait)
		
		(if (fneq (reverb-control-decay cfd) (reverb-control-decay))
		    (snd-display ";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) 
		(play-and-wait)
		(set! (contrast-control?) #t)
		(set! (contrast-control) .5) 
		(test-panel contrast-control 'contrast-control)
		(test-panel contrast-control-amp 'contrast-control-amp)
		(apply-controls) 
		(play-and-wait)
		(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) 
		(play-and-wait)
		(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) 
		(play-and-wait)
		(set! (amp-control) 1.5) 
		(test-panel amp-control 'amp-control)
		(apply-controls) 
		(play-and-wait)
		(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 ";set-amp .75 #t -> ~A?" (amp-control cfd2)))
		(set! (contrast-control-amp #t) .75)
		(if (fneq (contrast-control-amp cfd2) .75) (snd-display ";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 ";cfd2 contrast-control-bounds: ~A" (contrast-control-bounds cfd2)))
		(set! (expand-control-length #t) .025)
		(if (fneq (expand-control-length cfd2) .025) (snd-display ";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 ";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 ";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 ";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 ";clone frames: ~A ~A" (frames cfd2) (frames clone)))
		  (if (not (equal? (edits cfd2) (edits clone)))
		      (snd-display ";clone edits: ~A ~A" (edits cfd2) (edits clone)))
		  (let ((eds (apply + (edits))))
		    (call-with-current-continuation
		     (lambda (break)
		       (do ((i 0 (1+ i)))
			   ((= i eds))
			 (if (not (equal? (edit-fragment i cfd2) (edit-fragment i clone)))
			     (begin
			       (snd-display ";clone fragment[~A]: ~A ~A?" i (edit-fragment i cfd2) (edit-fragment i clone))
			       (break)))))))
		  (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 ";as-one-edit: ~A -> ~A" editctr (edit-position)))
	      (as-one-edit (lambda () #f))
	      (if (not (= (edit-position) (1+ editctr))) (snd-display ";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 ";snd-error-hook: ~A?" msg))
			 #t))
	    (snd-error "hiho")
	    (add-hook! snd-warning-hook 
		       (lambda (msg) 
			 (if (not (string=? msg "hiho")) (snd-display ";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 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 (inexact->exact (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) graph-once)
	    (set! (x-bounds) '(.1 .2))
	    (add-hook! lisp-graph-hook display-energy)
	    (shell "df")
	    (reset-hook! graph-hook)
	    (add-hook! graph-hook correlate)
	    (set! (x-bounds) '(.1 .12))
	    (set! (x-bounds) '(.1 .2))
	    (remove-hook! graph-hook correlate)
	    (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 ";~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 ";~D: ~A ~A" i (maxamp #f 0 i) (edit-fragment i))))))
	    
	    (map-chan (echo .5 .75) 0 60000)
	    (reset-hook! 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)
	       (if (rs .5)
		   (set! (sync snd) (inexact->exact (floor (my-random 3))))))
	     (sounds))
	    (add-hook! graph-hook superimpose-ffts)
	    (do ((i 0 (1+ i)))
		((= i 10))
	      (for-each
	       (lambda (snd)
		 (if (and (> (frames snd) 0) (rs .5))
		     (let* ((dur (floor (/ (frames snd) (srate snd))))
			    (start (max 0.0 (min (- dur .1) (my-random dur)))))
		       (if (> dur 0.0) 
			   (set! (x-bounds snd 0) (list start (min (+ start .1) dur)))))))
	       (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 (rs 0.5) index)
				      (if (exact? minval)
					  (if (equal? name #t)
					      (setfnc (inexact->exact
						       (floor (expt 2 (min 31 (ceiling (/ (log (+ minval (floor (* (- maxval minval) (my-random 1.0))))) 
											  (log 2)))))))
						      index)
					      (setfnc (+ minval (inexact->exact (floor (* (- maxval minval) (my-random 1.0))))) index))
					  (setfnc (+ minval (* (- maxval minval) (my-random 1.0))) index)))
				  (if (equal? minval #f)
				      (setfnc-1 (rs 0.5))
				      (if (exact? minval)
					  (if (equal? name #t)
					      (setfnc-1 (inexact->exact
							 (floor (expt 2 (min 31 (ceiling (/ (log (+ minval (floor (* (- maxval minval) (my-random 1.0))))) 
											    (log 2))))))))
					      (setfnc-1 (+ minval (inexact->exact (floor (* (- maxval minval) (my-random 1.0)))))))
					  (setfnc-1 (+ minval (* (- maxval minval) (my-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 'cursor-follows-play cursor-follows-play #f #f #t)
		(list 'cursor-size cursor-size #f 15 25)
		(list 'cursor-style cursor-style #f cursor-cross cursor-line)
		(list 'data-clipped data-clipped #f #f #t)
		(list 'default-output-chans default-output-chans #f 1 8)
					;(list 'default-output-format default-output-format #f 1 12)
		(list 'default-output-srate default-output-srate #f 22050 44100)
					;(list 'default-output-type default-output-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-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 'transform-size transform-size #f 16 (if (<= tests 10) 4096 128))
		(list 'transform-graph-type transform-graph-type #f 0 2)
		(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 'previous-files-sort previous-files-sort #f 0 5)
		(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-backtrace show-backtrace #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 'spectro-cutoff spectro-cutoff #f 0.5 0.8)
		(list 'spectro-hop spectro-hop #f 2 20)
		(list 'spectro-start spectro-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 'transform-type transform-type #f fourier-transform (if (<= tests 10) 6 3))
		(list 'verbose-cursor 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 'zero-pad zero-pad #f 0 2)
		(list 'zoom-focus-style zoom-focus-style #f 0 3))))
	    
	    (save-options "hiho.scm")
	    (if (not (= (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 ";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 ";mus-random: ~A ~A?" val val1))
	(if (= (mus-rand-seed) 1234) (snd-display ";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 ";mus-random repeated: ~A ~A?" val val1)))
      (reset-hook! after-open-hook)
      (run-hook after-test-hook 14)
      )
    )

(set! (data-clipped) #f)

(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 
		    verbose-cursor fft-log-frequency fft-log-magnitude min-dB
		    wavelet-type transform-size 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 spectro-cutoff spectro-start graphs-horizontal x-axis-style beats-per-minute
		    cursor-size 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
			 'verbose-cursor 'fft-log-frequency 'fft-log-magnitude 'min-dB
			 'wavelet-type 'transform-size '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 'spectro-cutoff 'spectro-start 'graphs-horizontal 'x-axis-style 'beats-per-minute
			 'cursor-size '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 -120.0
			 3 32 .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
			 15 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)
	       (inexact? 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 ";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 ";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 ";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 ";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 ";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 ";test-history-channel ~A[5]: ~A ~A?" name (flatten (func #t #t)) (apply map func (all-chans))))
    (set! (func) old-value)
    ))

(if (not (provided? 'snd-rubber.scm)) (load "rubber.scm"))
(set! (transform-type) fourier-transform)

(define (src-duration e)
  (let* ((len (length e))
	 (ex0 (car e))
	 (ex1 (list-ref e (- len 2)))
	 (all-x (- ex1 ex0))
	 (dur 0.0))
    (do ((i 0 (+ i 2)))
	((>= i (- len 2)) dur)
      (let* ((x0 (list-ref e i))
	     (x1 (list-ref e (+ i 2)))
	     (xy0 (list-ref e (+ i 1))) ; 1/x x points
	     (y0 (/ 1.0 xy0))           ; related y value
	     (xy1 (list-ref e (+ i 3)))
	     (y1 (/ 1.0 xy1))
	     (area (if (< (abs (- xy0 xy1)) .0001)
		       (* y0 (/ (- x1 x0) all-x))
		       (* (/ (- (log y1) (log y0)) 
			     (- xy0 xy1)) 
			  (/ (- x1 x0) all-x)))))
	(set! dur (+ dur (abs area)))))))

;;; 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 (1- pk0loc))
			     (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))))))

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

(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)))))))))

(if (and with-gui
	 (or full-test (= snd-test 15) (and keep-going (<= snd-test 15))))
    (begin
      
      (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-sample-reader beg ind 0 1 (1- pos)))
	       (new-reader (make-sample-reader 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 ";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 ";zdiff (~D ~D): ~A" beg len diff))
	  (free-sample-reader old-reader)
	  (free-sample-reader 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-sample-reader 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 ";scale-selection-to (~D ~D) ~A: ~A?" beg len maxval newmax))
	  (free-sample-reader 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 ";player? ~A -> #f?" player))
		(if (not (member player (players))) (snd-display ";player: ~A, but players: ~A" player (players)))
		(if (not (equal? (player-home player) (list sound chan)))
		    (snd-display ";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))))
      
      (run-hook before-test-hook 15)
      (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 ";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 ";all-chans(2): ~A?" (all-chans)))
	(if (not (string=? (finfo "oboe.snd") "oboe.snd: chans: 1, srate: 22050, Sun, big endian short (16 bits), len: 2.305"))
	    (snd-display ";finfo: ~A?" (finfo "oboe.snd")))
	(close-sound s2i)
	(close-sound obi)
	(if (not (equal? (all-chans) '(() ()))) (snd-display ";all-chans(0): ~A?" (all-chans)))
	(set! obi (open-sound "oboe.snd"))
	(set! (cursor obi) 1000)
	(if (not (= (locate-zero .001) 1050)) (snd-display ";locate-zero: ~A?" (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 ";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 ";mark-in-window: ~A ~A?" (left-sample obi 0) (mark-sample m1)))
	  (delete-mark m1))
	(close-sound s2i)
	(safe-make-region 1000 2000 obi)
	(delete-selection-and-smooth)
	(if (not (equal? (edit-fragment 0 obi 0) '(#f "init" 0 50828))) 
	    (snd-display ";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 ";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 ";edit-fragment(2): ~S?" (edit-fragment 2 obi 0)))
	
	(let ((samp100 (sample 1100 obi 0)))
	  (safe-make-region 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 ";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 ";add-mark: ~A ~A?" (marks obi 0) (list m2 m3)))
	      (eval-between-marks (lambda (val) (* 2.0 val)))
	      (let ((msamp100 (sample 1100 obi 0)))
		(if (fneq (* 2.0 nsamp100) msamp100) (snd-display ";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 ";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)
							     (> (mus-sound-frames file) 1000)))))))
	(if (not (= (chans s2i) 2)) (snd-display ";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 ";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 ";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 ";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 ";do-sound-chans: ~A ~A ~A?" mc mc1 mc2)))
	    (if (every-sample? (lambda (val) (> val .5))) (snd-display ";every-sample(0)?")) 
	    (if (not (every-sample? (lambda (val) (< val 5.0)))) (snd-display ";every-sample(1)?")) 
	    (select-sound obi)
	    (let ((bins (sort-samples 32)))
	      (if (not (= (vector-ref bins 1) 4504)) (snd-display ";sort-samples: ~A?" bins)))
	    ))
	(revert-sound s2i)
	(revert-sound obi)
	(set! (sync obi) 3)
	(set! (sync s2i) 3)
	(let* ((half-way (inexact->exact (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 ";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 ";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 ";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 ";  ~A[~A] at ~A" (short-file-name snd) i (selection-position snd i)))))
		 (sounds))))
	  (if (not (= (selection-srate) (srate s2i))) (snd-display ";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 ";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 ";no regions? ~A" (regions)))
	(let ((id (make-region 100 200 obi 0)))
	  (if (not (equal? (regions) (list id))) (snd-display ";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 ";env-sound-interp: ~A ~A?" oldlen newlen))))
	
	(close-sound obi)
	)

      (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 (1- (frames ind 0))))
	  (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 ";sound-interp: ~A ~A" (channel->vct))))
	(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 ";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 ";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 ";remove-clicks: ~A" (channel->vct)))
	(undo)
	(let ((vals (scan-channel (search-for-click))))
	  (if (not (equal? vals (list -1 11)))
	      (snd-display ";search-for-click: ~A" vals)))
	(close-sound ind))
      
      (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 ";set-frames 25000: ~A?" (frames id 0)))
	(if (not (= (edit-position id 0) 1)) (snd-display ";set-frames 25000 edit: ~A?" (edit-position id 0)))
	(set! (frames id 0) 75000)
	(if (not (= (frames id 0) 75000)) (snd-display ";set-frames 75000: ~A?" (frames id 0)))
	(if (not (= (edit-position id 0) 2)) (snd-display ";set-frames 75000 edit: ~A?" (edit-position id 0)))
	(if (fneq (sample 30000 id 0) 0.0) (snd-display ";set-frames 75000 zeros: ~A?" (sample 30000 id 0)))
	(set! (frames id 0) 0)
	(if (not (= (frames id 0) 0)) (snd-display ";set-frames 0: ~A?" (frames id 0)))
	(set! (frames id 0) 100)
	(if (not (= (frames id 0) 100)) (snd-display ";set-frames 100: ~A?" (frames id 0)))
	(revert-sound)
	(if (fneq (sample 30000 id 0) -0.0844) (snd-display ";revert from set-frames: ~A?" (sample 30000 id 0)))
	(if (not (= fr (frames id 0))) (snd-display ";revert set-frames: ~A != ~A?" (frames id 0) fr))
	(set! (maxamp id 0) .5)
	(if (fneq (maxamp id 0) .5) (snd-display ";set-maxamp: ~A?" (maxamp id 0)))
	(if (not (= (edit-position id 0) 1)) (snd-display ";set-maxamp edit: ~A?" (edit-position id 0)))
	(set! (maxamp id 0) .1)
	(if (fneq (maxamp id 0) .1) (snd-display ";set-maxamp .1: ~A?" (maxamp id 0)))
	(if (not (= (edit-position id 0) 2)) (snd-display ";set-maxamp .1 edit: ~A?" (edit-position id 0)))
	(revert-sound)
	(if (fneq (maxamp id 0) mx) (snd-display ";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 ";set x-position-slider .1: ~A?" (x-position-slider id 0)))
					;(if (> (abs (- (left-sample id 0) 5083)) 3) (snd-display ";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 ";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 ";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 ";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 ";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 ";channel-amp-envs: ~A?" vals)))
	
	(let ((len (length (channel-properties id 0))))
	  (if (channel-property 'hiho id 0)
	      (snd-display ";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 ";channel-property 'hiho (123): ~A?" (channel-property 'hiho id 0)))
	  (if (channel-property 'hi id 0)
	      (snd-display ";channel-property 'hi: ~A?" (channel-property 'hi id 0)))
	  (set! (channel-property 'hi id 0) 3.1415)
	  (if (fneq (channel-property 'hi id 0) 3.1415)
	      (snd-display ";channel-property 'hi (3.1415): ~A?" (channel-property 'hi id 0)))
	  (if (not (= (channel-property 'hiho id 0) 123))
	      (snd-display ";channel-property '2nd hiho (123): ~A?" (channel-property 'hiho id 0)))
	  (if (not (= (length (channel-properties id 0)) (+ len 2)))
	      (snd-display ";channel-properties: ~A?" (channel-properties id 0))))
	
	(let ((len (length (sound-properties id))))
	  (if (sound-property 'hiho id)
	      (snd-display ";sound-property 'hiho: ~A?" (sound-property 'hiho id)))
	  (set! (sound-property 'hiho id) 123)
	  (if (not (= (sound-property 'hiho id) 123))
	      (snd-display ";sound-property 'hiho (123): ~A?" (sound-property 'hiho id)))
	  (if (sound-property 'hi id)
	      (snd-display ";sound-property 'hi: ~A?" (sound-property 'hi id)))
	  (set! (sound-property 'hi id) 3.1415)
	  (if (fneq (sound-property 'hi id) 3.1415)
	      (snd-display ";sound-property 'hi (3.1415): ~A?" (sound-property 'hi id)))
	  (if (not (= (sound-property 'hiho id) 123))
	      (snd-display ";sound-property '2nd hiho (123): ~A?" (sound-property 'hiho id)))
	  (if (not (= (length (sound-properties id)) (+ len 2)))
	      (snd-display ";sound-properties: ~A?" (sound-properties id))))
	
	(close-sound id))
      
      (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 (and (not (= left 1000)) (not (= left 1001))) (snd-display ";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 ";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 ";0f: ~A" cr)))
	(prefix-it 100 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1334)) (snd-display ";100f: ~A" cr)))
	(prefix-it -100 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1234)) (snd-display ";-100f: ~A" cr)))
	(prefix-it 1 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1235)) (snd-display ";1f: ~A" cr)))
	(key (char->integer #\+) 4 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1236)) (snd-display ";+f: ~A" cr)))
	(key (char->integer #\-) 4 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1235)) (snd-display ";-f: ~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 ";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 ";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 ";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 ";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 ";u0f: ~A" cr)))
	(prefix-uit 100 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1334)) (snd-display ";u100f: ~A" cr)))
	(prefix-uit -100 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1234)) (snd-display ";u-100f: ~A" cr)))
	(prefix-uit 1 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1235)) (snd-display ";u1f: ~A" cr)))
	(key (char->integer #\+) 4 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1236)) (snd-display ";u+f: ~A" cr)))
	(key (char->integer #\-) 4 id)
	(key (char->integer #\f) 4 id)
	(let ((cr (cursor id)))
	  (if (not (= cr 1235)) (snd-display ";u-f: ~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 ";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 ";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)
							   (> (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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)
			    :end (inexact->exact (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 ";amp-control snd: ~A" (amp-control ind)))
		       (if (> (abs (- (amp-control player) (exact->inexact (/ samp len)))) .02)
			   (snd-display ";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 ";stop proc didn't close?"))
	(set! (with-background-processes) old-bp))

      (let ((ind (open-sound "pistol.snd")))
	(if (selection-member? ind 0) 
	    (snd-display ";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 ";selection-member? ~A ~A ~A?" 
			 (selection-member? ind 0)
			 (selection-member? ind)
			 (selection?)))
	(if (not (= (selection-frames) 1))
	    (snd-display ";initial selection-frames: ~A?" (selection-frames)))
	(set! (selection-frames) 1200)
	(if (not (= (selection-frames) 1200))
	    (snd-display ";selection-frames: 1200 ~A?" (selection-frames)))
	(delete-selection)
	(if (selection?) (snd-display ";selection active after cut?"))
	(undo)
	(if (not (selection?)) (snd-display ";selection inactive after undo?"))
	(if (or (not (selection-member? ind 0))
		(not (selection-member? ind)))
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";selection after src .5 with undo/redo: '(1000 400) '(~A ~A)?" 
			   (selection-position) 
			   (selection-frames)))
	  (undo 3))
	(close-sound ind))
      
      (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 ";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 ";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 ";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 ";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 ";src-duration test5: ~A" (src-duration '(0 1 1 2 2 1))))
	
	(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 ";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 ";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 ";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 ";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 ";src (env) 0 ~A freq: ~A" f0 vals)))
	   (let ((vals (freq-peak (- (inexact->exact (floor (* (src-duration e) 10000.0))) 256) ind 256)))
	     (if (f5neq (car vals) f1)
		 (snd-display ";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 :end (frames)) 1.0 ind 0)
	   (if (fneq (/ (frames ind 0) 10000.0) (src-duration e))
	       (snd-display ";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 ";src (make-env) 0 ~A freq: ~A" f0 vals)))
	   (let ((vals (freq-peak (- (inexact->exact (floor (* (src-duration e) 10000.0))) 256) ind 256)))
	     (if (f5neq (car vals) f1)
		 (snd-display ";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 ";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 ";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 ";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 ";src-channel (env f0) ~A: ~A" f0 vals)))
	   (let ((vals (freq-peak (- (inexact->exact (floor (* (src-duration e) 10000.0))) 256) ind 256)))
	     (if (f5neq (car vals) f1)
		 (snd-display ";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 ";src-channel section: ~A ~A" (frames) (+ 7500 (* dur 2500))))
	   (let ((vals (freq-peak 0 ind 512)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";src-channel section 0 ~A freq: ~A" sr vals)))
	   (let ((vals (freq-peak (- (+ 7500 (inexact->exact (floor (* dur 2500)))) 512) ind 512)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";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 ";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 :end 2500) 1000 2500)
	   (if (f3neq (frames ind 0) (+ 7500 (* (src-duration e) 2500)))
	       (snd-display ";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 ";src-channel section (make-env f0) ~A: ~A" f0 vals)))
	   (let ((vals (freq-peak (- (+ 7500 (inexact->exact (floor (* (src-duration e) 2500)))) 256) ind 256)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";src-channel section (make-env f1) ~A: ~A" f0 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 ";src-selection section: ~A ~A" (frames) (+ 7500 (* dur 2500))))
	   (let ((vals (freq-peak 0 ind 512)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";src-selection section 0 ~A freq: ~A" sr vals)))
	   (let ((vals (freq-peak (- (+ 7500 (inexact->exact (floor (* dur 2500)))) 512) ind 512)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";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 ";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 :end 2500))
	   (if (f3neq (frames ind 0) (+ 7500 (* (src-duration e) 2500)))
	       (snd-display ";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 ";src-selection section (make-env f0) ~A: ~A" f0 vals)))
	   (let ((vals (freq-peak (- (+ 7500 (inexact->exact (floor (* (src-duration e) 2500)))) 256) ind 256)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";src-selection section (make-env f1) ~A: ~A" f0 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 ";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 ";src-selection section (env f0) ~A: ~A" f0 vals)))
	   (let ((vals (freq-peak (- (+ 7500 (inexact->exact (floor (* (src-duration e) 2500)))) 256) ind 256)))
	     (if (f5neq (car vals) 500.0)
		 (snd-display ";src-selection section (env f1) ~A: ~A" f0 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 ";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 ";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 ";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 ";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 ";C-o len: ~A? " (frames)))
	(if with-gui
	    (let ((reader (make-sample-reader 1200 ind)))
	      (do ((i 0 (1+ i)))
		  ((= i 100))
		(let ((val (next-sample reader)))
		  (if (fneq val 0.0) (snd-display ";C-o[~D]: ~A?" i val))))
	      (if (not (= (sample-reader-position reader) 1300)) (snd-display ";reader pos: ~A" (sample-reader-position reader)))
	      (free-sample-reader 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 ";C-z len: ~A? " (frames)))
	(if with-gui
	    (let ((reader (make-sample-reader 1200 ind)))
	      (do ((i 0 (1+ i)))
		  ((= i 100))
		(let ((val (next-sample reader)))
		  (if (fneq val 0.0) (snd-display ";C-z[~D]: ~A?" i val))))
	      (free-sample-reader 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 ";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 ";C-o 1.0 len: ~A? " (frames)))
	(if with-gui
	    (let ((reader (make-sample-reader 1200 ind)))
	      (do ((i 0 (1+ i)))
		  ((= i (srate ind)))
		(let ((val (next-sample reader)))
		  (if (fneq val 0.0) (snd-display ";C-o 1.0[~D]: ~A?" i val))))
	      (free-sample-reader 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 ";C-z 1.0 len: ~A? " (frames)))
	(if with-gui
	    (let ((reader (make-sample-reader 1200 ind)))
	      (do ((i 0 (1+ i)))
		  ((= i (srate ind)))
		(let ((val (next-sample reader)))
		  (if (fneq val 0.0) (snd-display ";C-z 1.0[~D]: ~A?" i val))))
	      (free-sample-reader 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 ";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 ";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 ";syncd cursors: ~A ~A" (cursor ind 0) (cursor ind 1)))
	(key (char->integer #\f) 4)
	(if (not (= (cursor ind 1) 1001)) (snd-display ";syncd cursors C-f: ~A ~A" (cursor ind 0) (cursor 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 ";no selection from 1 samp region?"))
	(if (not (= (selection-frames) 1)) (snd-display ";1 samp selection: ~A samps?" (selection-frames)))
	(scale-selection-to 1.0)
	(if (fneq (sample 1200 ind 0) 1.0) (snd-display ";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 ";region-frames after src-selection: ~A?" (region-frames id)))
	  (let ((reg-mix-id (mix-region 1500 id ind 0)))
	    (if (not (= (mix-frames reg-mix-id) (region-frames id)))
		(snd-display ";mix-region: ~A != ~A?" (region-frames id) (mix-frames reg-mix-id)))
	    (if (not (equal? (mix-home reg-mix-id) (list ind 0)))
		(snd-display ";mix-region mix-home ~A (~A 0)?" (mix-home reg-mix-id) ind))
	    (let ((sel-mix-id (mix-selection 2500 ind 0)))
	      (if (not (= (selection-frames) (mix-frames sel-mix-id)))
		  (snd-display ";mix-selection: ~A != ~A?" (selection-frames) (mix-frames sel-mix-id)))
	      (if (> (abs (- (* 2 (mix-frames reg-mix-id)) (mix-frames sel-mix-id))) 3)
		  (snd-display ";mix selection and region: ~A ~A (~A ~A)?" 
			       (mix-frames reg-mix-id) (mix-frames sel-mix-id) (region-frames id) (selection-frames)))
	      (if (not (equal? (mix-home sel-mix-id) (list ind 0)))
		  (snd-display ";mix-selection mix-home: ~A (~A 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 C-x i") XmNactivateCallback (snd-global-state))))
	      (mix-selection 3000 ind)
	      (if (and (provided? 'xm) (provided? 'snd-debug))
		  (begin
		    (XtCallCallbacks (menu-option "Mix Selection    C-x q") XmNactivateCallback (snd-global-state))
		    (XtCallCallbacks (menu-option "Play Selection   C-x p") 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 0 10 reg 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 ";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 ";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 ";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 ";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 ";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 (= (selected-sound) a4)) (snd-display ";set! selected-sound: ~A ~A?" (selected-sound) a4))
	  (set! (selected-channel) 2)
	  (if (not (= (selected-channel a4) 2)) (snd-display ";set! selected-channel: ~A?" (selected-channel a4)))
	  (set! (selected-channel a4) 3)
	  (if (not (= (selected-channel a4) 3)) (snd-display ";set! selected-channel a4: ~A?" (selected-channel a4)))
	  (close-sound a4)
	  (close-sound oboe)))
      
      (if (fneq (envelope-interp .1 '(0 0 1 1)) 0.1) 
	  (snd-display ";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 ";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 ";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 ";envelope-interp .3 '(0 0 .5 1 1 0)) -> ~A" (envelope-interp .3 '(0 0 .5 1 1 0))))
      (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 ";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 ";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 ";max-envelope: ~A?" (max-envelope '(0 0 1 1 2 3 4 0))))
      (if (fneq (max-envelope '(0 1)) 1.0)
	  (snd-display ";1 max-envelope: ~A?" (max-envelope '(0 1))))
      (if (fneq (max-envelope '(0 1 1 1 2 2)) 2.0)
	  (snd-display ";2 max-envelope: ~A?" (max-envelope '(0 1 1 1 2 2))))
      (if (fneq (max-envelope '(0 -1 1 -2)) -1.0)
	  (snd-display ";3 max-envelope: ~A?" (max-envelope '(0 -1 1 -2))))
      (if (fneq (max-envelope '(0 -2 1 -1)) -1.0)
	  (snd-display ";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 ";min-envelope: ~A?" (min-envelope '(0 0 1 1 2 3 4 0))))
      (if (fneq (min-envelope '(0 1)) 1.0)
	  (snd-display ";1 min-envelope: ~A?" (min-envelope '(0 1))))
      (if (fneq (min-envelope '(0 1 1 1 2 2)) 1.0)
	  (snd-display ";2 min-envelope: ~A?" (min-envelope '(0 1 1 1 2 2))))
      (if (fneq (min-envelope '(0 -1 1 -2)) -2.0)
	  (snd-display ";3 min-envelope: ~A?" (min-envelope '(0 -1 1 -2))))
      (if (fneq (min-envelope '(0 -2 1 -1)) -2.0)
	  (snd-display ";4 min-envelope: ~A?" (min-envelope '(0 -2 1 -1))))
      (if (fneq (integrate-envelope '(0 0 1 1)) 0.5) 
	  (snd-display ";integrate-envelope: ~A?" (integrate-envelope '(0 0 1 1))))
      (if (fneq (integrate-envelope '(0 1 1 1)) 1.0) 
	  (snd-display ";integrate-envelope: ~A?" (integrate-envelope '(0 1 1 1))))
      (if (fneq (integrate-envelope '(0 0 1 1 2 .5)) 1.25) 
	  (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";repeat-envelope 4: ~A" (repeat-envelope '(0 0 1.5 1 2 0) 3)))
      
      (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 ";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 ";envelope exp 2: ~A" val)))
      
      (let ((ind (new-sound "fmv.snd"))
	    (v (make-vct 20)))
	(vct-fill! v 1.0)
	(vct->channel v)
	(set! (selection-position ind 0) 5)
	(set! (selection-frames) 5)
	(scale-selection-to 0.5)
	(insert-selection 15 ind)
	(if (not (= (frames ind) 25)) (snd-display ";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 ";insert-selection: ~A" (channel->vct 0 25)))
	(mix-selection 1)
	(if (not (vequal (channel->vct 0 10) (vct 1.0 1.5 1.5 1.5 1.5 1.0 0.5 0.5 0.5 0.5)))
	    (snd-display ";mix-selection: ~A" (channel->vct 0 10)))
	(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)))
	  (if (< peak 40.0) (snd-display ";transform selection peak: ~A" peak))
	  (if (> (* .5 peak) (vct-ref data 51)) (snd-display ";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 (inexact->exact (floor (* .1 (vct-length data)))))))
	     (if (> (* .5 peak) pval)
		 (snd-display ";transform selection padded ~D: ~A, peak: ~A" pad pval peak))))
	 (list 1 0 3 31))
	(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 ";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 ";enving storm ~D: ~A ~A" (1+ i) (vct-ref maxes (1+ i)) (maxamp))))
	(close-sound ind))
	
	  
      ))
      (run-hook after-test-hook 15)
      ))

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

(define (undo-env s c)
  (let ((len (car (edits s c))))
    (if (> len 0)
	(call-with-current-continuation
	 (lambda (break)
	   (do ((i 1 (1+ i)))
	       ((> i len) #f)
	     (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) (1- i))
		     (break #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 (not (= (edit-position cursnd curchn) (1+ cur-edit))) 
		 (snd-display ";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 ";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 ";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 ";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 (= s cursnd)
			      (= c curchn)))
		    (begin
		      (if (not (= (edit-position s c) ed))
			  (snd-display ";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 ";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 ";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 (= s cursnd))
				 (not (= c curchn))))
			(not (= (sync s) (sync cursnd))))
		    (begin
		      (if (not (= (edit-position s c) ed))
			  (snd-display ";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 ";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 ";scale-by ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
		    (begin
		      (if (not (= (edit-position s c) (1+ ed))) 
			  (snd-display ";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 ";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 ";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 (= s cursnd))
		    (begin
		      (if (not (= (edit-position s c) ed))
			  (snd-display ";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 ";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 ";scale-sound-by ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
		    (begin
		      (if (not (= (edit-position s c) (1+ ed))) 
			  (snd-display ";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 ";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 (inexact->exact (floor (/ len 2))))))
		   (delete-samples beg (+ 10 (random 100)) cursnd curchn)))))
      
      ((7) (let ((beg (random (+ (frames cursnd curchn) 100))))
	     (set! (samples beg (+ 10 (random 100)) cursnd curchn) (make-vct 10 1.0))))
      
      ((8) (let ((beg (random (+ (frames cursnd curchn) 100))))
	     (insert-samples beg (+ 10 (random 100)) (make-vct 10 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-sample-reader (+ beg dur -1) cursnd curchn -1))
		   (reader0 (make-sample-reader beg cursnd curchn)))
	      (ptree-channel (lambda (y) (* y 2.0)) beg dur cursnd curchn #f #t)
	      (let* ((preader1 (make-sample-reader (+ beg dur -1) cursnd curchn -1))
		     (reader1 (make-sample-reader 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 ";read ptree at ~A: ~A ~A ~A ~A (~A ~A ~A ~A): ~A" 
				       i val0 val1 pval0 pval1
				       reader0 reader1 preader0 preader1
				       (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-sample-reader beg cursnd curchn)))
	      (env-channel e beg dur cursnd curchn)
	      (let* ((reader1 (make-sample-reader beg cursnd curchn))
		     (en (make-env e :end (1- 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
			  (save-state "baddy.scm")
			  (snd-display ";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
				       (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)
	     (if (not (= (edit-position cursnd curchn) (1+ cur-edit))) 
		 (snd-display ";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 ";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 ";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 (= s cursnd)
			      (= c curchn)))
		    (begin
		      (if (not (= (edit-position s c) ed))
			  (snd-display ";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 ";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 ";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 (inexact->exact (floor (/ end 2))))))
	     (for-each
	      (lambda (s c)
		(if (not (or (and (= (sync cursnd) 0) 
				  (or (not (= 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 (= s cursnd)) 
				 (not (= c curchn))))
			(not (= (sync s) (sync cursnd))))
		    (begin
		      (if (not (= (edit-position s c) ed))
			  (snd-display ";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 ";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 ";env-sound ~A[~A] wrong maxamp: ~A ~A" (short-file-name s) c (maxamp s c) amp)))
		    (begin
		      (if (not (= (edit-position s c) (1+ ed))) 
			  (snd-display ";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 ";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)))))
    (call-with-current-continuation
     (lambda (break)
       (if (and len0 len1)
	   (let* ((minlen (min len0 len1))
		  (inc0 (/ len0 minlen))
		  (inc1 (/ len1 minlen))
		  (e0 (cadr env0))
		  (e1 (cadr env1)))
	     (if (and (exact? inc0)
		      (exact? inc1))
		 (do ((i 0 (1+ i)))
		     ((= i minlen))
		   (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 ";amp-env ~A: ~A ~A" i max0 max1)
			   (break #f)))
		     (set! max0 -1.0)
		     (set! max1 -1.0)))
		 (snd-display ";lens: ~A ~A" len0 len1))))
       #t))))

(define (check-edit-tree expected-tree expected-vals name)
  (define (vequal-at v0 v1)
    (call-with-current-continuation
     (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))) .0001)
	       (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 ";~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 ";checking ~A, vals disagree (loc cur expect): ~A" name bad-data)
	      (throw 'uhoh)
	      )
	    (let* ((tree (edit-tree))
		   (bad-data (edits-not-equal? tree expected-tree 0)))
	      (if bad-data
		  (snd-display ";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-sample-reader split-loc))
			 (bread (make-sample-reader (1- split-loc) #f #f -1))
			 (split-vals (make-vct len)))
		    (do ((i split-loc (1+ i)))
			((= i len))
		      (vct-set! split-vals i (fread)))
		    (do ((i (1- split-loc) (1- i)))
			((< 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 ";checking ~A, split vals disagree (loc cur expect): ~A" name bad-data)
			  (throw 'uhoh)
			  )))))))))

(define (reversed-read snd chn)
  (let* ((len (frames snd chn))
	 (data (make-vct len))
	 (sf (make-sample-reader (1- len) snd chn -1)))
    (do ((i (1- len) (1- i)))
	((< 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-sample-reader 3 snd chn 1)))
    (do ((i 3 (1+ i)))
	((= i 6))
      (vct-set! data i (next-sample sf)))
    (do ((i 6 (1- i)))
	((= 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* ((len (frames snd chn))
	 (data (channel->vct))
	 (sf (make-sample-reader 3 snd chn)))
    (do ((i 3 (1+ i)))
	((= i 8))
      (let ((val (next-sample sf)))
	(if (fneq (vct-ref data i) val)
	    (snd-display ";~A: forward data[~D]: ~A ~A" name i val (vct-ref data i)))))
    (do ((i 7 (1- i)))
	((= i 0))
      (let ((val (previous-sample sf)))
	(if (fneq (vct-ref data i) val)
	    (snd-display ";~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)
  (if (not (vequal v (channel->vct 0 (frames) ind 0)))
      (snd-display ";~A forth: ~A ~A" name (channel->vct 0 (frames) ind 0) v))
  (if (not (vequal v (reversed-read ind 0)))
      (snd-display ";~A back: ~A ~A" name (reversed-read ind 0) v)))


(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 ";~A swap c0: ~A" name c0))
    (if c1 (snd-display ";~A swap c1: ~A" name c1))))

(if (or full-test (= snd-test 16) (and keep-going (<= snd-test 16)))
    (begin
      (run-hook before-test-hook 16)
      (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 ";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) :end 123) 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-channel 0 0 oboe))
	  (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-channel" 
	  "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 ";~A beg -1->~A" name tag))
	     (if (not (= (edit-position oboe) 0))
		 (snd-display ";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) :end 123) -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 () (play-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" "play-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 ";beg:12345678 scale-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(env-channel (make-env '(0 0 1 1) :end 123) 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display ";beg:12345678 env-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(smooth-channel 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display ";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 ";beg:12345678 src-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(reverse-channel 12345678 123 oboe)
	(if (not (= (edit-position oboe) 0))
	    (snd-display ";beg:12345678 reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(play-channel 12345678 123 oboe)
	
	(scale-channel 2.0 0 123 oboe 0)
	(if (not (= (edit-position oboe) 1))
	    (snd-display ";oboe scale-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(env-channel (make-env '(0 0 1 1) :end 123) 0 123 oboe 0)
	(if (not (= (edit-position oboe) 2))
	    (snd-display ";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 ";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 ";oboe vct->channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(smooth-channel 0 123 oboe 0)
	(if (not (= (edit-position oboe) 5))
	    (snd-display ";oboe smooth-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(pad-channel 0 123 oboe 0)
	(if (not (= (edit-position oboe) 6))
	    (snd-display ";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 ";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 ";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 ";oboe insert-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(reverse-channel 0 123 oboe 0)
	(if (not (= (edit-position oboe) 10))
	    (snd-display ";oboe reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment)))
	(let* ((rd (make-sample-reader 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 ";oboe clm-channel src? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let* ((rd (make-sample-reader 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 ";oboe clm-channel granulate? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let* ((rd (make-sample-reader 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 ";oboe clm-channel convolve? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let* ((rd (make-sample-reader 0))
	       (sr (make-phase-vocoder :input (lambda (dir) (rd)))))
	  (clm-channel sr 0 12345 oboe 0)
	  (if (not (= (edit-position oboe) 14))
	      (snd-display ";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 ";bad edpos scale-channel: ~A" tag))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display ";edpos:func scale-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (env-channel (make-env '(0 0 1 1) :end 123) 0 123 oboe 0 (lambda (hi) #f))) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";bad edpos scale-channel: ~A" tag))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display ";edpos 123 scale-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (env-channel (make-env '(0 0 1 1) :end 123) 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (= (edit-position oboe) 0))
	      (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";edpos 123 reverse-channel? ~A ~A" (edit-position oboe) (edit-fragment))))
	(let ((tag (catch #t (lambda () (play-channel 0 123 oboe 0 123)) (lambda args (car args)))))
	  (if (not (eq? tag 'no-such-edit)) (snd-display ";bad edpos play-channel: ~A" tag)))
	(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 ";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 ";insert-channel at 0: ~A ~A" oldv (channel->vct 1000 10 oboe)))
	  (if (not (= (frames oboe 0) (* 2 (frames oboe 0 0))))
	      (snd-display ";insert-channel frames: ~A ~A" (frames oboe 0) (frames oboe 0 0)))
	  (revert-sound oboe))
	
	(close-sound oboe)
	
	(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 ";vct->channel new 20: ~A" (frames)))
	  (if (fneq (maxamp) 1.0) (snd-display ";vct 1->new: ~A" (maxamp)))
	  
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :end 19))
	  (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 ";env-channel step 1: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :end 19) 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 ";env-channel step 1 at 8: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :end 11))
	  (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 ";env-channel step 1 at 0: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :end 11) 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 ";env-channel step 1 at 4: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 0 1 1 2 1) :base 0 :end 11) 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 ";env-channel step 1 at 4 by 3: ~A" v1)))
	  (undo)
	  (env-channel (make-env '(0 1 1 0 2 0) :base 0 :end 7) 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 ";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 :end 19))
	  (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 ";env-channel step 1: ~A" v1)))
	  (env-channel (make-env '(0 0 1 .5 2 .25 3 0 4 0) :base 0 :end 20))
	  (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 ";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 ";2.snd 3x = ~A ~A" fr (frames)))
	  (if (not (= (frames ind 0) (frames ind 1))) (snd-display ";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 ";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 ";mono-files->stereo not stereo? ~A" (channels new-snd)))
	  (if (not (string=? (short-file-name new-snd) "test.snd")) (snd-display ";mono-files->stereo filename: ~A" (short-file-name new-snd)))
	  (if (not (= (frames new-snd) 50828)) (snd-display ";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 ";~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 ";~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 ";~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)))
								(1- (cadr args))
								#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) 
							    :end (if (and (> (length args) 1)
									  (number? (cadr args)))
								     (cadr args)
								     (1- (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)))
						   (1- (cadr args))
						   #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)))
						      (1- (cadr args))
						      #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) #t))))
			(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))
	
	(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 ";~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) .5))
		 )
	   (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 ";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 ";trailing ptree scaled rmp0 trouble: ~A" (sample 500)))
	  (scale-by 2.0)
	  (if (fneq (sample 500) 0.5)
	      (snd-display ";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 ";trailing ptree post delete rmp0 trouble: ~A" (sample 500)))
	  (if (fneq (sample 0) 0.5)
	      (snd-display ";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 ";trailing ptree post change rmp0 trouble: ~A" (sample 500)))
	  (if (fneq (sample 0) 0.5)
	      (snd-display ";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 ";trailing ptree post delete(1) loc trouble: ~A" (sample 500)))
	  (if (fneq (sample 0) 0.1)
	      (snd-display ";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 ";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 ";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 ";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)))
	    (save-state "hiho.scm")
	    (close-sound ind)
	    (for-each forget-region (regions))
	    (load "hiho.scm")
	    (set! ind (find-sound "oboe.snd"))
	    (if (not (sound? ind))
		(snd-display ";save hiho failed?")
		(let ((new-vals (channel->vct (- 12345 50) 200 ind 0)))
		  (if (not (vequal vals new-vals))
		      (snd-display ";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)
	     (save-state "s61.scm")
	     (close-sound ind)
	     (for-each forget-region (regions))
	     (load "s61.scm")
	     (set! ind (find-sound "oboe.snd"))
	     (if (fneq (maxamp ind) val)
		 (snd-display ";saved ~A max: ~A ~A" name (maxamp ind) val))
	     (revert-sound ind))
	   (list (lambda (ind)
		   (ptree-channel (lambda (y) (* y .5))))
		 (lambda (ind)
		   (ptree-channel (lambda (y data forward)
				    (declare (y real) (data vct) (forward boolean))
				    (* 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)
				    (declare (y real) (data vct) (forward boolean))
				    (* 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 ";~A ptree: ~A ~A" name ptv vc))
		 (if (not (vequal ptc vc)) (snd-display ";~A closure: ~A ~A" name ptc vc))
		 (if (not (vequal ptm vc)) (snd-display ";~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 ";reversed ~A ptree: ~A ~A" name ptv vc))
		 (if (not (vequal ptc vc)) (snd-display ";reversed ~A closure: ~A ~A" name ptc vc))
		 (if (not (vequal ptm vc)) (snd-display ";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 ";zigzag ~A ptree: ~A ~A" name ptv vc))
		 (if (not (vequal ptc vc)) (snd-display ";zigzag ~A closure: ~A ~A" name ptc vc))
		 (if (not (vequal ptm vc)) (snd-display ";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) 
			       (declare (y real) (data vct) (dir boolean)) 
			       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) 
			       (declare (y real) (data vct) (dir boolean))
			       y) 
			     0 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0))))
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       (declare (y real) (data vct) (dir boolean))
			       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) 
			       (declare (y real) (data vct) (dir boolean))
			       (* 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) 
			       (declare (y real) (data vct) (dir boolean))
			       (* 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) 
			       (declare (y real) (data vct) (dir boolean))
			       (* 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) 
			       (declare (y real) (data vct) (dir boolean)) 
			       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) 
			       (declare (y real) (data vct) (dir boolean))
			       y) 
			     2 #f ind 0 #f #f 
			     (lambda (pos dur) (vct 0.0))))
	    (lambda (ind) 
	      (ptree-channel (lambda (y data dir) 
			       (declare (y real) (data vct) (dir boolean))
			       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) 
			       (declare (y real) (data vct) (dir boolean))
			       (* 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) 
			       (declare (y real) (data vct) (dir boolean))
			       (* 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) 
			       (declare (y real) (data vct) (dir boolean))
			       (* 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)
				 (declare (y real) (data vct) (dir boolean))
				 (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)
				 (declare (y real) (data vct) (dir boolean))
				 (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) 
			       (declare (y real) (data vct) (dir boolean))
			       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)
			   (declare (y real) (data vct) (forward boolean))
			   (* 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)
			   (declare (y real) (data vct) (forward boolean))
			   (* 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)
			   (declare (y real) (data vct) (forward boolean))
			   (* 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)
			   (declare (y real) (data vct) (forward boolean))
			   (* 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)
	  
	  (ramp-channel 0.0 1.0)
	  (xen-channel (lambda (y data forward)
			 (+ y (list-ref data 0)))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (list 0.5)))
	  (zigzag-check "xen" ind 0)
	  
	  ;; zero checks
	  (undo 2)
	  (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)
	  (scale-channel 0.0 3 4)
	  (xen-channel (lambda (y data forward)
			 (let ((val (vct-ref data (1+ (inexact->exact (floor (vct-ref data 0)))))))
			   (if forward
			       (vct-set! data 0 (1+ (vct-ref data 0)))
			       (vct-set! data 0 (1- (vct-ref data 0))))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct pos .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.1 1.2 1.3 1.4)))
	  (zigzag-check "xen+zero" ind 0)
	  (undo 2)
	  (xramp-channel 0.0 1.0 .025)
	  (xen-channel (lambda (y data forward)
			 (let ((val (vct-ref data (1+ (inexact->exact (floor (vct-ref data 0)))))))
			   (if forward
			       (vct-set! data 0 (1+ (vct-ref data 0)))
			       (vct-set! data 0 (1- (vct-ref data 0))))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct pos .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.1 1.2 1.3 1.4)))
	  (zigzag-check "xen+xramp" ind 0)
	  (undo 2)
	  (ramp-channel 0.0 1.0)
	  (ramp-channel 1.0 0.0)
	  (xen-channel (lambda (y data forward)
			 (let ((val (vct-ref data (1+ (inexact->exact (floor (vct-ref data 0)))))))
			   (if forward
			       (vct-set! data 0 (1+ (vct-ref data 0)))
			       (vct-set! data 0 (1- (vct-ref data 0))))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct pos .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.1 1.2 1.3 1.4)))
	  (zigzag-check "xen+ramp2" ind 0)
	  (undo 3)
	  (revert-sound ind)
	  (map-chan (lambda (y) (random 1.0)) 0 10)
	  (ramp-channel 0.0 1.0)
	  (xen-channel (lambda (y data forward)
			 (let ((val (vct-ref data (1+ (inexact->exact (floor (vct-ref data 0)))))))
			   (if forward
			       (vct-set! data 0 (1+ (vct-ref data 0)))
			       (vct-set! data 0 (1- (vct-ref data 0))))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct pos .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.1 1.2 1.3 1.4)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+xen+ramp" ind 0)
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp+xen+ramp2" ind 0)
	  (undo 3)
	  (ramp-channel 0.0 1.0)
	  (xen-channel (lambda (y data forward)
			 (let ((val (vct-ref data (1+ (inexact->exact (floor (vct-ref data 0)))))))
			   (if forward
			       (vct-set! data 0 (1+ (vct-ref data 0)))
			       (vct-set! data 0 (1- (vct-ref data 0))))
			   val))
		       0 (frames) ind 0 #f #f
		       (lambda (pos dur)
			 (vct pos .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.1 1.2 1.3 1.4)))
	  (ramp-channel 0.0 1.0)
	  (zigzag-check "ramp2+xen+ramp" ind 0)
	  (undo 4)
	  (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)
					     (declare (y real) (data vct) (forward boolean))
					     (* y (vct-ref data 0)))
					   0 (frames) ind 0 #f #f
					   (lambda (pos dur)
					     (vct 0.5))))
		 (lambda () (xen-channel (lambda (y data forward)
					   (let ((val (vct-ref data (1+ (inexact->exact (floor (vct-ref data 0)))))))
					     (if forward
						 (vct-set! data 0 (1+ (vct-ref data 0)))
						 (vct-set! data 0 (1- (vct-ref data 0))))
					     val))
					 0 (frames) ind 0 #f #f
					 (lambda (pos dur)
					   (vct pos .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 1.1 1.2 1.3 1.4)))))
	   (list "ramp-ptree" "ramp-ptreec" "ramp-xen")
	   (list #t #t #f))
	  (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 ";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 ";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 ";ptree split: ~A" (display-edits)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";scale+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";scale+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display ";scale+ptree+mix -> ~A" mx)))
	  (undo)
	  (ptree-channel (lambda (y) .01) 100 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";scale+ptree+ptree -> ~A" mx)))
	  (undo)
	  (env-channel '(0 0 1 1) 100 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";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 ";(1)scale+ptree+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(1)scale+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(1)scale+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display ";(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 ";(2)scale+ptree+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(2)scale+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(2)scale+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display ";(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 ";(3)env+ptree+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(3)env+ptree+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(3)env+ptree+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .11)
		(snd-display ";(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 ";(1)env+set -> ~A" mx)))
	  (undo)
	  (delete-sample 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(1)env+delete -> ~A" mx)))
	  (undo)
	  (insert-samples 100 3 (make-vct 3 .01))
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(1)env+insert -> ~A" mx)))
	  (undo)
	  (mix-vct (make-vct 3 .01) 100)
	  (let ((mx (maxamp)))
	    (if (fneq mx .1)
		(snd-display ";(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 ";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 ";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) (1- (edit-position s c))))
			  (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)) (1- out-chans))))
		      (if (not (vequal (channel->vct 0 (frames ind chn) ind chn 0) (vct 0.0)))
			  (snd-display ";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 ";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 (1- (edit-position ind chn)))
					  (not (vequal data (vct 0.0 0.0)))))
				 (snd-display ";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 ";pad[~A / ~A] empty: ~A" i chn data))))))))))
		  (lambda (posfunc)
		    (let ((chn (min (random (1+ out-chans)) (1- out-chans))))
		      (set! (sample 0 ind chn) .1)
		      (scale-channel 2.0 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))))
				  (and (or (= pos current-edit-position) 
					   (= pos (edit-position ind chn)))
				       (not (vequal data (vct 0.2))))			  
				  (and (= pos (1- (edit-position ind chn)))
				       (not (vequal data (vct 0.0)))))
			      (snd-display ";pos[~A]: edpos ~A of ~A, scale 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 ";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 ";map-channel #f frames: ~A" (frames ind)))
	  (if (equal? (edits ind) (list 0 0)) (snd-display ";map-channel #f edits backed up"))
	  (undo 1 ind)
	  (if (= (frames ind) 0) (snd-display ";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 ";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 ";scan-channel error exit: ~A" ctr))
	    (if (not (eq? tag 'unbound-variable)) (snd-display ";scan-channel unbound: ~A" tag)))
	  (let ((val (scan-channel (lambda (y) #f)))) (if val (snd-display ";scan-channel func #f: ~A" val)))
	  (let ((val (scan-channel (lambda (y) #f) 1234))) (if val (snd-display ";scan-channel func #f with beg: ~A" val)))
	  (let ((val (scan-channel (lambda (y) #f) 1234 4321))) (if val (snd-display ";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 ";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 ";clm-channel overlaps: ~A" (edit-tree)))
	    (let ((reader (make-sample-reader 0))
		  (preader (make-sample-reader 0 ind 0 1 0)))
	      (call-with-current-continuation
	       (lambda (break)
		 (do ((i 0 (1+ i)))
		     ((= i 1000))
		   (let ((val (reader)))
		     (if (fneq val 0.0)
			 (begin
			   (snd-display ";clm-channel overlap delayed: ~A: ~A" i val)
			   (break)))))
		 (do ((i 0 (1+ i)))
		     ((= i len))
		   (let ((val0 (preader))
			 (val1 (reader)))
		     (if (fneq val0 val1)
			 (begin
			   (snd-display ";clm-channel overlap main: ~A: ~A ~A" (+ i 1000) val0 val1)
			   (break)))))
		 (do ((i 0 (1+ i)))
		     ((= i 1000))
		   (if (fneq (reader) 0.0)
		       (begin
			 (snd-display ";clm-channel overlap trailing garbage")
			 (break))))))))
	  (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 (1- (frames))))
	    (scan-channel (lambda (y)
			    (if (> (abs y) amp) 
				(begin
				  (set! amp (abs y))
				  (set! loc ctr)))
			    (set! ctr (1- ctr))
			    #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 ";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 (1- (frames))))
	    (scan-channel (lambda (y)
			    (if (> (abs y) amp) 
				(begin
				  (set! amp (abs y))
				  (set! loc ctr)))
			    (set! ctr (1- ctr))
			    #f))
	    ;; can't use maxamp here because it may be set by scaling process
	    (if (or (fneq oldamp amp)
		    (not (= loc oldloc)))
		(snd-display ";reverse unscaled edpos screwup: ~A at ~A,  ~A at ~A" oldamp oldloc amp loc)))
	  
	  (close-sound ind))
	
	(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) :end 10) 15 10)
	  (let ((e (make-env '(0 0 1 1) :end 9)))
	    (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 -1.49011614158923e-9 1.0 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 -1.49011614158923e-9 1.0 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 ";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 -1.49011614158923e-9 1.0 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 -1.49011614158923e-9 1.0 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 -1.49011614158923e-9 0.444444447755814 1) (20 2 0 0 1.0 0.0 0.0 0)
			     (21 1 21 24 0.5 0.666666686534882 1.0 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 "set 20 .1")
	  (reverse-channel 5 10)
	  (do ((i 5 (1+ i))
	       (j 14 (1- j)))
	      ((= 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 -1.49011614158923e-9 0.444444447755814 1) (20 2 0 0 1.0 0.0 0.0 0) 
			     (21 1 21 24 0.5 0.666666686534882 1.0 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 "reverse-channel 5 10")
	  (if (fneq (selection-maxamp) .5) (snd-display ";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 4 0 9 1.0 0.0 0.0 0) 
				 (14 3 9 9 1.0 0.0 0.0 0) (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) 
				 (20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.666666686534882 1.0 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 (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)))))
	  (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 4 0 9 1.0 0.0 0.0 0)
			       (14 3 9 9 1.0 0.0 0.0 0) (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) 
			       (20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.666666686534882 1.0 1) 
			       (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0)
			       (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 ";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 ";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 4 0 9 1.0 0.0 0.0 0) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) 
			       (20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.666666686534882 1.0 1)
			       (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0) (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) :end 30 :base 0) 50 30)
	    (let ((e (make-env '(0 0 1 1 2 0 3 0) :end 30 :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 4 0 9 1.0 0.0 0.0 0) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) 
			       (20 2 0 0 1.0 0.0 0.0 0) (21 1 21 24 0.5 0.666666686534882 1.0 1)
			       (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0) (40 1 40 49 1.0 0.0 0.0 0) 
			       (50 1 50 59 0.0 0.0 0.0 0) (60 1 60 60 0.0 0.0 0.0 0) (61 1 61 70 1.0 0.0 0.0 0) 
			       (71 1 71 79 0.0 0.0 0.0 0) (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 4 0 9 1.0 0.0 0.0 0) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) (20 2 0 0 1.0 0.0 0.0 0) 
			       (21 1 21 24 0.5 0.666666686534882 1.0 1) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0) 
			       (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 4 0 9 1.0 0.0 0.0 0) (14 3 9 9 1.0 0.0 0.0 0) 
			     (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) (20 2 0 0 1.0 0.0 0.0 0) 
			     (21 1 21 24 0.5 0.666666686534882 1.0 1) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0) 
			     (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 0) (60 1 60 60 0.0 0.0 0.0 0) 
			     (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 79 0.0 0.0 0.0 0) (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 4 0 9 1.0 0.0 0.0 0) (14 3 9 9 1.0 0.0 0.0 0) 
			       (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) (20 2 0 0 1.0 0.0 0.0 0)
			       (21 1 21 24 0.5 0.666666686534882 1.0 1) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0)
			       (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 0) (60 1 60 60 0.0 0.0 0.0 0) 
			       (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 0) (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 7 0 10 1.0 0.0 0.0 0) (14 3 9 9 1.0 0.0 0.0 0) 
			     (15 1 15 19 0.5 -1.49011614158923e-9 0.444444447755814 1) (20 2 0 0 1.0 0.0 0.0 0) 
			     (21 1 21 24 0.5 0.666666686534882 1.0 1) (25 1 25 27 0.5 0.0 0.0 0) (28 -1 0 11 0.0 0.0 0.0 0) 
			     (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 0) (60 1 60 60 0.0 0.0 0.0 0) 
			     (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 0) (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-sample-reader 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 8 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 0) 
			     (40 1 40 49 1.0 0.0 0.0 0) (50 1 50 59 0.0 0.0 0.0 0) (60 1 60 60 0.0 0.0 0.0 0) 
			     (61 1 61 70 1.0 0.0 0.0 0) (71 1 71 74 0.0 0.0 0.0 0) (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 ";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 8 0 19 1.0 0.0 0.0 0) (20 8 20 24 1.0 -2.69948563502709e-10 0.0579710155725479 2) (25 1 25 27 0.5 0.0724637657403946 0.101449273526669 2) (28 -1 0 11 0.0 0.0 0.0 1) (40 1 40 49 1.0 0.289855062961578 0.420289844274521 2) (50 1 50 59 0.0 0.0 0.0 1) (60 1 60 60 0.0 0.0 0.0 1) (61 1 61 70 1.0 0.594202876091003 0.724637687206268 2) (71 1 71 74 0.0 0.0 0.0 1) (75 6 0 9 1.0 0.797101438045502 0.927536249160767 2) (85 1 85 89 1.0 0.942028999328613 1.0 2) (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 8 0 19 0.5 0.0 0.0 0) (20 8 20 24 0.5 -2.69948563502709e-10 0.0579710155725479 2) (25 1 25 27 0.25 0.0724637657403946 0.101449273526669 2) (28 -1 0 11 0.0 0.0 0.0 1) (40 1 40 49 0.5 0.289855062961578 0.420289844274521 2) (50 1 50 59 0.0 0.0 0.0 1) (60 1 60 60 0.0 0.0 0.0 1) (61 1 61 70 0.5 0.594202876091003 0.724637687206268 2) (71 1 71 74 0.0 0.0 0.0 1) (75 6 0 9 0.5 0.797101438045502 0.927536249160767 2) (85 1 85 89 0.5 0.942028999328613 1.0 2) (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 ";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 0) (50 9 0 0 1.0 0.0 0.0 0) (51 -1 51 99 0.0 0.0 0.0 0) (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 10 0 24 1.0 0.0 0.0 0) (25 -1 25 49 0.0 0.0 0.0 0) (50 9 0 0 1.0 0.0 0.0 0) (51 -1 51 99 0.0 0.0 0.0 0) (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 10 0 24 1.0 0.0 0.0 0) (25 -1 25 49 0.0 0.0 0.0 0) (50 9 0 0 1.0 0.0 0.0 0) (51 -1 51 74 0.0 0.0 0.0 0) (75 11 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) :end 100))
		(e1 (make-env '(0 0 1 1) :end 100)))
	    (map-channel (lambda (y) (env e)))
	    (do ((i 0 (1+ i)))
		((= i 100))
	      (vct-set! vals i (env e1))))
	  (check-edit-tree '((0 12 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 12 0 49 1.0 0.0 0.0 0) (50 13 0 0 1.0 0.0 0.0 0) (51 12 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 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 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 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 "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 "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 ";edits after reload: ~A" (edits)))
;	  (delete-file "hiho.scm")
	  
	  (env-channel (make-env '(0 1 1 0 2 1) :end 19) 50 20)
	  (let ((e (make-env '(0 1 1 0 2 1) :end 19)))
	    (do ((i 50 (1+ i)))
		((= i 70))
	      (vct-set! vals i (* (env e) (vct-ref vals i)))))
	  (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 1.0 1.0 1) (51 12 51 60 1.0 0.899999976158142 -2.38418582654276e-8 1) (61 12 61 69 1.0 0.111111111938953 1.0 1) (70 12 70 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 "env on env")
	  (env-channel (make-env '(0 1 1 0 2 1) :end 79) 10 80)
	  (let ((e (make-env '(0 1 1 0 2 1) :end 79)))
	    (do ((i 10 (1+ i)))
		((= i 90))
	      (vct-set! vals i (* (env e) (vct-ref vals i)))))
	  (check-edit-tree '((0 14 0 9 1.0 0.0 0.0 0) (10 14 10 24 1.0 1.0 0.649999976158142 1) (25 12 25 49 1.0 0.625 0.025000000372529 1) 
			     (50 13 0 0 1.0 1.0 1.0 3) (51 12 51 60 1.0 0.899999976158142 -2.38418582654276e-8 3) 
			     (61 12 61 69 1.0 0.111111111938953 1.0 3) (70 12 70 74 1.0 0.512820541858673 0.615384638309479 1) 
			     (75 15 0 14 1.0 0.64102566242218 1.0 1) (90 15 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) :end 19) 50 20)
	  (let ((e (make-env '(0 1 1 0 2 1) :end 19)))
	    (do ((i 50 (1+ i)))
		((= i 70))
	      (vct-set! vals i (* (env e) (vct-ref vals i)))))
	  (check-edit-tree '((0 14 0 9 1.0 0.0 0.0 0) (10 14 10 24 1.0 1.0 0.649999976158142 2) (25 12 25 49 1.0 0.625 0.025000000372529 2) (50 13 0 0 1.0 1.0 1.0 4) (51 12 51 60 1.0 0.899999976158142 -2.38418582654276e-8 4) (61 12 61 69 1.0 0.111111111938953 1.0 4) (70 12 70 74 1.0 0.512820541858673 0.615384638309479 2) (75 15 0 14 1.0 0.64102566242218 1.0 2) (90 15 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 1))
			   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 14 0 9 1.0 0.0 0.0 0) (10 -1 0 19 0.0 0.0 0.0 1) (30 12 30 49 1.0 0.5 0.025000000372529 2) (50 13 0 0 1.0 1.0 1.0 4) (51 12 51 60 1.0 0.899999976158142 -2.38418582654276e-8 4) (61 12 61 69 1.0 0.111111111938953 1.0 4) (70 12 70 74 1.0 0.512820541858673 0.615384638309479 2) (75 15 0 14 1.0 0.64102566242218 1.0 2) (90 15 15 24 1.0 0.0 0.0 0) (100 -2 0 0 0.0 0.0 0.0 1))
			   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)
	       (call-with-current-continuation
		(lambda (break)
		  (do ((i 0 (1+ i)))
		      ((= i dur))
		    (let ((rv (r))
			  (ev (e)))
		      (if (fneq rv ev) 
			  (begin
			    (snd-display ";~A env check [~A]: ~A ~A" name i rv ev)
			    (break))))))))
	     (vct->channel v)
	     (env-sound '(0 0 1 1))
	     (check-env 'ramp (make-sample-reader 0) (make-env '(0 0 1 1) :end (1- dur)))
	     (reverse-channel)
	     (check-env 'rev-ramp (make-sample-reader 0) (make-env '(0 1 1 0) :end (1- dur)))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0))
	     (check-env 'ramp (make-sample-reader 0) (make-env '(0 0 1 1 2 0) :end (1- dur)))
	     (let ((cur-read (make-sample-reader 0)))
	       (reverse-channel)
	       (let ((rev-read (make-sample-reader (1- dur) 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-sample-reader 0) (make-env '(0 0 1 1 2 0 3 1) :end (1- dur)))
	     (let ((cur-read (make-sample-reader 0)))
	       (reverse-channel)
	       (let ((rev-read (make-sample-reader (1- dur) 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-sample-reader 0) (make-env '(0 0 1 1 2 1 3 0) :end (1- dur)))
	     (undo 1)
	     (env-sound '(0 0 1 .5 2 .5 3 0))
	     (check-env '5sqoff (make-sample-reader 0) (make-env '(0 0 1 .5 2 .5 3 0) :end (1- dur)))
	     (undo 1)
	     (scale-channel .5)
	     (env-sound '(0 0 1 1))
	     (check-env 'scl-ramp (make-sample-reader 0) (make-env '(0 0 1 1) :end (1- dur) :scaler .5))
	     (reverse-channel)
	     (check-env 'scl-rev-ramp (make-sample-reader 0) (make-env '(0 1 1 0) :end (1- dur) :scaler .5))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0))
	     (check-env 'scl-3-ramp (make-sample-reader 0) (make-env '(0 0 1 1 2 0) :end (1- dur) :scaler .5))
	     (let ((cur-read (make-sample-reader 0)))
	       (reverse-channel)
	       (let ((rev-read (make-sample-reader (1- dur) 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-sample-reader 0)
				 (let ((e (make-env '(0 0 1 1 2 0) :end (1- 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-sample-reader 0)
				 (let ((e (make-env '(0 0 1 1 2 1 3 0) :end (1- 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-sample-reader 0) 
			(let ((e (make-env '(0 0 1 1) :end (1- 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 "; 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 "; 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-sample-reader 0) (make-env '(0 0 1 1) :end (1- 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 "; 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 "; 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 "; 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 "; 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 "; 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) :end 9999)))
	    (vct-map! vals (lambda () (e))))
	  (check-edit-tree '((0 1 0 9999 1.0 2.52621252909424e-12 1.0 1) (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 2.52621252909424e-12 0.0999099910259247 1) 
                               (1000 1 2000 9999 1.0 0.200020000338554 1.0 1) 
			       (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 (1- i)))
	      ((< 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 2.52621252909424e-12 0.29993000626564 1) 
                             (3000 2 0 999 1.0 0.0 0.0 0) 
                             (4000 1 3000 8999 1.0 0.300030022859573 0.899990022182465 1) 
                             (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.100010007619858 0.29993000626564 1) 
                             (3000 2 0 999 1.0 0.0 0.0 0)
                             (4000 1 3000 8999 1.0 0.300030022859573 0.899990022182465 1) 
                             (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.100010007619858 0.29993000626564 1) 
			     (3000 2 0 999 0.5 0.0 0.0 0) 
			     (4000 1 3000 8999 0.5 0.300030022859573 0.899990022182465 1) 
			     (10000 -2 0 0 0.0 0.0 0.0 0))
			   vals "envd scl")
	  (reverse-channel)
	  (do ((i 0 (1+ i))
	       (j 9999 (1- j)))
	      ((= 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) :end 9999) 30000 10000)
	  (let ((e (make-env '(0 0 1 1 2 0) :end 9999)))
	    (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 35000 1.0 1.71387285873709e-12 1.0 1) 
			     (35001 1 35001 39999 1.0 0.999799966812134 6.29921462214078e-17 1)
			     (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) :end 9999) 30000 10000) ; env over env
	  (let ((e (make-env '(0 0 1 1 2 0) :end 9999)))
	    (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 35000 1.0 5.05242505818848e-12 1.0 3) (35001 1 35001 39999 1.0 0.999799966812134 4.75964753721136e-17 3) (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) :end 9999) 5000 10000) ; env over scl
	  (let ((e (make-env '(0 0 1 1 2 0) :end 9999)))
	    (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 5.05242505818848e-12 0.999800026416779 1) (10000 1 10000 10000 0.5 1.0 1.0 1) (10001 1 10001 14999 0.5 0.999799966812134 4.75964753721136e-17 1) (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 35000 1.0 5.05242505818848e-12 1.0 3) (35001 1 35001 39999 1.0 0.999799966812134 4.75964753721136e-17 3) (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) :end 999)))
	    (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 5.05242505818848e-12 0.999800026416779 1) (10000 1 10000 10000 0.5 1.0 1.0 1) (10001 1 10001 14999 0.5 0.999799966812134 4.75964753721136e-17 1) (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.5 1) (26000 1 26000 29999 1.0 0.0 0.0 0) (30000 1 30000 35000 1.0 5.05242505818848e-12 1.0 3) (35001 1 35001 39999 1.0 0.999799966812134 4.75964753721136e-17 3) (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 5.05242505818848e-12 0.999800026416779 1) (10000 1 10000 10000 -0.5 1.0 1.0 1) (10001 1 10001 14999 -0.5 0.999799966812134 4.75964753721136e-17 1) (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.5 1) (26000 1 26000 29999 -1.0 0.0 0.0 0) (30000 1 30000 35000 -1.0 5.05242505818848e-12 1.0 3) (35001 1 35001 39999 -1.0 0.999799966812134 4.75964753721136e-17 3) (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-sample-reader 0 ind 0 1 (1- (edit-position)))))
	    (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 ";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) :end 29999)))
	    (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 5.05242505818848e-12 0.999800026416779 1) (10000 1 10000 10000 -0.5 1.0 1.0 1) (10001 1 10001 14999 -0.5 0.999799966812134 4.75964753721136e-17 1) (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.5 1) (26000 1 26000 29999 -1.0 0.0 0.0 0) (30000 1 30000 35000 -1.0 5.05242505818848e-12 1.0 3) (35001 1 35001 39999 -1.0 0.999799966812134 4.75964753721136e-17 3) (40000 1 40000 49999 -1.0 0.0 0.0 0) (50000 1 50000 79999 -1.0 -0.999999940395355 1.00000011920929 1) (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 ";sample at end: ~A" (sample 0)))
	  (if (not (= (frames) 1)) (snd-display ";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 ";round-off env: ~A" val)))
	  (check-edit-tree '((0 0 0 15112 1.0 0.984011590480804 0.110976688563824 1) 
			     (15113 0 15113 27517 1.0 0.110998757183552 0.384709984064102 1) 
			     (27518 0 27518 29483 1.0 0.384794801473618 0.551452696323395 1) 
			     (29484 0 29484 33764 1.0 0.551521003246307 0.843827784061432 1) 
			     (33765 0 33765 50827 1.0 0.843791604042053 0.226832345128059 1) 
			     (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 ";scl on env trouble: ~A" val)))
	  (check-edit-tree '((0 1 0 999 1.0 -1.13455122033312e-12 0.0393090434372425 1) 
			     (1000 1 1000 1999 0.5 0.0393483936786652 0.0786574333906174 1) 
			     (2000 1 2000 25414 1.0 0.0786574333906174 1.0 1) 
			     (25415 1 25415 50827 1.0 0.999960660934448 -4.22838847269347e-17 1) 
			     (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 ";ramp-channels piled up: ~A" val)))
	  (check-edit-tree '((0 1 0 50827 1.0 1.16525265456656e-13 1.0 4) (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 ";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 25414 1.0 -1.13455122033312e-12 1.0 1) 
			     (25415 0 25415 50827 1.0 0.999960660934448 -4.22838847269347e-17 1) 
			     (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 -1.13455122033312e-12 0.0393483899533749 1) 
			     (1000 0 1000 25414 1.0 0.0393483899533749 1.0 1) 
			     (25415 0 25415 50827 1.0 0.999960660934448 -4.22838847269347e-17 1) 
			     (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 -1.13455122033312e-12 0.0393483899533749 1) 
			     (1000 0 1000 1999 0.5 0.0393483899533749 0.0786967799067497 1) 
			     (2000 0 2000 25414 1.0 0.0786967799067497 1.0 1) 
			     (25415 0 25415 50827 1.0 0.999960660934448 -4.22838847269347e-17 1)
			     (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 25414 0.5 -1.13455122033312e-12 0.999960660934448 1) 
			     (25415 0 25415 50827 1.0 0.999960660934448 -4.22838847269347e-17 1) 
			     (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 -1.13455122033312e-12 0.786967813968658 1)
			     (20000 0 20000 25414 0.5 0.786967813968658 1.0 1) 
			     (25415 0 25415 29999 0.5 0.999960660934448 0.819541215896606 1) 
			     (30000 0 30000 50827 1.0 0.819541215896606 -4.22838847269347e-17 1) 
			     (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 25414 1.0 -1.13455122033312e-12 1.0 1) 
			     (25415 0 25415 29999 1.0 0.999960660934448 0.819541215896606 1) 
			     (30000 0 30000 30999 0.5 0.819541215896606 0.780191242694855 1) 
			     (31000 0 31000 50827 1.0 0.780191242694855 -4.22838847269347e-17 1) 
			     (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 25414 1.0 -1.13455122033312e-12 0.999960660934448 1) 
			     (25415 0 25415 26414 0.5 0.999960660934448 0.960610747337341 1) 
			     (26415 0 26415 50827 1.0 0.960610747337341 -4.22838847269347e-17 1) 
			     (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 25414 1.0 -1.13455122033312e-12 1.0 1) 
			     (25415 0 25415 39999 1.0 0.999960660934448 0.426041781902313 1) 
			     (40000 0 40000 50827 0.5 0.426041781902313 0.0 1) 
			     (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)
	       (call-with-current-continuation
		(lambda (break)
		  (do ((i 0 (1+ i)))
		      ((= i dur))
		    (let ((rv (r))
			  (ev (e)))
		      (if (fneq rv ev) 
			  (begin
			    (snd-display ";~A env check [~A]: ~A ~A" name i rv ev)
			    (throw 'uhoh)
			    (break))))))))
	     (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-sample-reader 0 s c)) (lambda (s c) (make-env '(0 0 1 1) :end (1- dur))))
	     (reverse-sound)
	     (check-envs 'rev-ramps (lambda (s c) (make-sample-reader 0 s c)) (lambda (s c) (make-env '(0 1 1 0) :end (1- dur))))
	     (undo 2)
	     (env-sound '(0 0 1 1 2 0))
	     (check-envs 'ramps (lambda (s c) (make-sample-reader 0 s c)) (lambda (s c) (make-env '(0 0 1 1 2 0) :end (1- dur))))
	     (undo 1)
	     (scale-by .5)
	     (env-sound '(0 0 1 1))
	     (check-envs 'scl-ramps (lambda (s c) (make-sample-reader 0 s c)) (lambda (s c) (make-env '(0 0 1 1) :end (1- dur) :scaler .5)))
	     (reverse-sound)
	     (check-envs 'scl-rev-ramps (lambda (s c) (make-sample-reader 0)) (lambda (s c) (make-env '(0 1 1 0) :end (1- 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-sample-reader 0 s c))
			 (lambda (s c)
			   (let ((e (make-env '(0 0 1 1) :end (1- 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 "; 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 "; 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 "; 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))
	
	(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)
			     (gc)
			     (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))))
		     (list "1a.snd" "oboe.snd" "storm.snd" (string-append home-dir "/test/sound/away.snd")))))
	  (snd-display ";         scl   rev   env   map   ptree  scn  pad   wrt   clm   mix   src   del")
;	  (snd-display ";1a:   ~{~6,2F~}" (car data))  
;	  (snd-display ";oboe: ~{~6,2F~}" (cadr data))  
;	  (snd-display ";storm:~{~6,2F~}" (caddr data))
;	  (if (list-p (cadddr data))
;	      (snd-display ";away: ~{~6,2F~}" (cadddr data)))
;	  (map (lambda (a) (format #f "~6,2F" a)) (car data))

	  (snd-display ";1a:   ~{~A~}" (map (lambda (a) (format #f "~6,2F" a)) (car data)))
	  (snd-display ";oboe: ~{~A~}" (map (lambda (a) (format #f "~6,2F" a)) (cadr data)))
	  (snd-display ";storm:~{~A~}" (map (lambda (a) (format #f "~6,2F" a)) (caddr data)))
	  (if (list-p (cadddr data))
	      (snd-display ";away: ~{~A~}" (map (lambda (a) (format #f "~6,2F" a)) (cadddr data))))
	  )

	(if (and all-args with-big-file)
	    (let ((big-file-name "/home/bil/zap/sounds/bigger.snd"))
	      (if (file-exists? big-file-name)
		  (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 ";bigger scale max: ~A ~A" ma (maxamp)))))
						 (lambda () 
						   (let ((ma (maxamp)))
						     (env-channel '(0 0 1 1))
						     (if (fneq (maxamp) ma) (snd-display ";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 ";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 ";bigger: ~{~6,2F~}" times)
			       ))
			   (lambda args (set! (squelch-update) #f)))
		    (close-sound ind)))))
	
	(if (and with-big-file (file-exists? "/zap/sounds/bigger.snd"))
	    (begin
	      (if (hook-empty? initial-graph-hook)
		  (if (not (provided? 'snd-peak-env.scm)) (load "peak-env.scm")))
	      (reset-hook! after-graph-hook)
	      (reset-hook! mouse-click-hook)
	      (let ((ind (open-sound "/zap/sounds/bigger.snd"))
		    (vals (make-vct 100))
		    (old-vals #f)
		    (new-vals #f)
		    (maxa 0.0))
		(select-sound ind)
		(select-channel 0)
		(set! (squelch-update) #t)
		(if (not (fieql (edit-tree) '((0 0 0 3175199999 1.0 0.0 0.0 0) (3175200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";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 ";bigger scale: ~A ~A" maxa (maxamp)))
		(set! (samples (* 44100 50000) 100) vals)
		(if (not (fieql (edit-tree) '((0 0 0 2204999999 0.5 0.0 0.0 0) 
					      (2205000000 1 0 99 1.0 0.0 0.0 0) 
					      (2205000100 0 2205000100 3175199999 0.5 0.0 0.0 0) (3175200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";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 ";bigger set ~A ~A" old-vals new-vals))
		(env-channel (make-env '(0 0 1 1) :end (* 44100 60000)) 1000 (* 44100 60000))
		(if (not (fieql (edit-tree) '((0 0 0 999 0.5 0.0 0.0 0) 
					      (1000 0 1000 2204999999 0.5 1.12130420080871e-17 0.83333295583725 1) 
					      (2205000000 1 0 99 1.0 0.83333295583725 0.833333015441895 1) 
					      (2205000100 0 2205000100 2646000999 0.5 0.833333015441895 1.0 1) 
					      (2646001000 0 2646001000 3175199999 0.5 0.0 0.0 0) 
					      (3175200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger with env: ~A" (edit-tree)))
		(revert-sound ind)
		(env-channel (make-env '(0 0 1 1 2 0) :end 100) (* 44100 50000) 100)
		(if (not (fieql (edit-tree) '((0 0 0 2204999999 1.0 0.0 0.0 0) 
					      (2205000000 1 0 99 1.0 0.0 0.0 0) 
					      (2205000100 0 2205000100 3175199999 1.0 0.0 0.0 0) (3175200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger short env: ~A" (edit-tree)))
		(let ((r (make-sample-reader (* 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.0 0.001472 0.00584 0.01297 0.02264 0.03453 0.04827 0.06339 0.07941 0.09576)))
		      (snd-display ";bigger short env vals: ~A" v)))
		(revert-sound)
		(scale-to 1.0)
		(if (fneq (maxamp) 1.0) (snd-display ";bigger scale-to 1.0 maxamp: ~A" (maxamp)))
		(set! (sample (* 44100 51000)) 0.0)
		(if (not (fieql (edit-tree) '((0 0 0 2249099999 1.18574941158295 0.0 0.0 0) 
					      (2249100000 1 0 0 1.0 0.0 0.0 0) 
					      (2249100001 0 2249100001 3175199999 1.18574941158295 0.0 0.0 0) (3175200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger set 0 samp: ~A" (edit-tree)))
		(if (fneq (sample (* 44100 51000)) 0.0) (snd-display ";bigger 0 samp: ~A" (sample (* 44100 51000))))
		(delete-samples (* 44100 52000) 100)
		(if (not (= (frames) (- 3175200000 100))) (snd-display ";bigger deletion frames: ~A" (frames)))
		(if (not (= (frames ind 0 0) 3175200000)) (snd-display ";bigger edpos deletion frames: ~A" (frames ind 0 0)))
		(if (not (= (frames ind 0 (edit-position)) (- 3175200000 100))) 
		    (snd-display ";bigger ed deletion frames: ~A" (frames ind 0 (edit-position))))
		(if (not (fieql (edit-tree) '((0 0 0 2249099999 1.18574941158295 0.0 0.0 0) 
					      (2249100000 1 0 0 1.0 0.0 0.0 0) 
					      (2249100001 0 2249100001 2293199999 1.18574941158295 0.0 0.0 0) 
					      (2293200000 0 2293200100 3175199999 1.18574941158295 0.0 0.0 0) (3175199900 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger deletion: ~A" (edit-tree)))
		(delete-samples 954624868 67)
		(revert-sound)
		(delete-samples 1000 (* 44100 50000))
		(if (not (= (frames) (- 3175200000 (* 44100 50000)))) (snd-display ";bigger big deletion: ~A" (frames)))
		(if (not (fieql (edit-tree) '((0 0 0 999 1.0 0.0 0.0 0) (1000 0 1085232704 3175199999 1.0 0.0 0.0 0) (970200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger big delete: ~A" (edit-tree)))
		(insert-silence 0 (* 44100 50000))
		(if (not (= (frames) 3175200000)) (snd-display ";bigger silence: ~A" (frames)))
		(if (not (fieql (edit-tree) '((0 -1 0 2204999999 0.0 0.0 0.0 0) 
					      (2205000000 0 0 999 1.0 0.0 0.0 0) 
					      (2205001000 0 1085232704 3175199999 1.0 0.0 0.0 0) (3175200000 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger pad: ~A" (edit-tree)))
		(revert-sound)
		(pad-channel (* 44100 50000) 100)
		(if (fneq (sample (+ (* 44100 50000) 10)) 0.0) (snd-display ";bigger pad samp: ~A" (sample (+ (* 44100 50000) 10))))
		(if (not (= (frames) (+ 3175200000 100))) (snd-display ";bigger pad frames: ~A" (frames)))
		(map-channel (lambda (y) (+ y .2)) (* 44100 50000) 10)
		(if (fneq (sample (+ (* 44100 50000) 1)) 0.2) (snd-display ";bigger map samp: ~A" (sample (+ (* 44100 50000) 1))))
		(if (not (fieql (edit-tree) '((0 0 0 2204999999 1.0 0.0 0.0 0) 
					      (2205000000 1 0 9 1.0 0.0 0.0 0) 
					      (2205000010 -1 10 99 0.0 0.0 0.0 0) 
					      (2205000100 0 2205000000 3175199999 1.0 0.0 0.0 0) (3175200100 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";bigger map: ~A" (edit-tree)))
		(save-edit-history "hiho.scm")
		(revert-sound)
		(set! sfile ind)
		(load "hiho.scm")
		(if (not (fieql (edit-tree) '((0 0 0 2204999999 1.0 0.0 0.0 0) 
					      (2205000000 1 0 9 1.0 0.0 0.0 0) 
					      (2205000010 -1 10 99 0.0 0.0 0.0 0) 
					      (2205000100 0 2205000000 3175199999 1.0 0.0 0.0 0) (3175200100 -2 0 0 0.0 0.0 0.0 0))))
		    (snd-display ";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)))
		  (clm-channel flt (* 44100 65000) 10)
		  (if (not (fieql (edit-tree) '((0 0 0 2204999999 1.0 0.0 0.0 0) 
						(2205000000 1 0 9 1.0 0.0 0.0 0) 
						(2205000010 -1 10 99 0.0 0.0 0.0 0) (2205000100 0 2205000000 2866499899 1.0 0.0 0.0 0) 
						(2866500000 2 0 9 1.0 0.0 0.0 0) (2866500010 0 2866499910 3175199999 1.0 0.0 0.0 0) 
						(3175200100 -2 0 0 0.0 0.0 0.0 0))))
		      (snd-display ";bigger clm: ~A" (edit-tree)))
		  (if (not (vequal (channel->vct (* 44100 65000) 10) (vct 0.011 0.069 0.164 0.255 0.343 0.425 0.501 0.568 0.627 0.676)))
		      (snd-display ";bigger clm vals: ~A" (channel->vct (* 44100 65000) 10))))
		
		(let ((r (make-readin "/zap/sounds/bigger.snd" :start (* 44100 65000)))
		      (v (make-vct 10)))
		  (do ((i 0 (1+ i)))
		      ((= i 10))
		    (vct-set! v i (readin r)))
		  (if (not (vequal v (vct 0.000 0.095 0.189 0.280 0.366 0.447 0.521 0.586 0.643 0.689)))
		      (snd-display ";bigger (orig) readin vals: ~A" v)))
		(revert-sound)
		(let ((found (scan-channel (lambda (y) (> y .5)) (* 44100 50000))))
		  (if (not (equal? found (list #t 2205000009)))
		      (snd-display ";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 ";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 ";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 ";ptree + .1 differs"))
	  (if (and (> (optimization) 0)
		   (not (string=? (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 ";ptree display edits: ~A" (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 ";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 ";ptree sin (2) differs"))
	  (if (and (> (optimization) 0)
		   (not (string=? (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 ";ptree display: ~A" (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 ";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 ";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 ";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 ";ptree[1000] + .2 differs"))
	  (if (and (> (optimization) 0)
		   (not (string=? (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 ";ptree[1000] display: ~A" (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 ";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 ";ptree[3200] + .2 differs"))
	  (if (and (> (optimization) 0)
		   (not (string-=? (display-edits ind-ptree) (string-append "
EDITS: 6

 (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)

 (ramp 2501 499) ; env-channel (make-env '(0.000 0.000 1.000 1.000 2.000 0.000) :base 1.0000 :end 999) 2000 1000 [4:9]:
   (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:1999, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 2000, cp->sounds[0][2000:2500, 2.000, [1]-0.000 -> 1.000]) [file: " cwd "oboe.snd[0]]
   (at 2501, cp->sounds[0][2501:2999, 2.000, [1]0.998 -> 0.000]) [file: " cwd "oboe.snd[0]]
   (at 3000, cp->sounds[0][3000:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[2] 4000 100) ; ptree-channel [5:11]:
   (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:1999, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 2000, cp->sounds[0][2000:2500, 2.000, [1]-0.000 -> 1.000]) [file: " cwd "oboe.snd[0]]
   (at 2501, cp->sounds[0][2501:2999, 2.000, [1]0.998 -> 0.000]) [file: " cwd "oboe.snd[0]]
   (at 3000, cp->sounds[0][3000:3999, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 4000, cp->sounds[0][4000:4099, 1.000, loc: 2, pos: 0, scl: 2.000, code: (lambda (y) (+ y 0.3))]) [file: " cwd "oboe.snd[0]]
   (at 4100, cp->sounds[0][4100:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (ptree[3] 0 3200) ; ptree-channel [6:12]:
   (at 0, cp->sounds[0][0:99, 1.000, loc: 3, pos: 0, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[0][100:199, 1.000, loc2: 3, pos2: 100, scl2: 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, 1.000, loc: 3, pos: 200, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 1000, cp->sounds[0][1000:1099, 1.000, loc2: 3, pos2: 1000, scl2: 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:1999, 1.000, loc: 3, pos: 1100, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 2000, cp->sounds[0][2000:2500, 1.000, [1]-0.000 -> 1.000, loc: 3, pos: 2000, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 2501, cp->sounds[0][2501:2999, 1.000, [1]0.998 -> 0.000, loc: 3, pos: 2501, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 3000, cp->sounds[0][3000:3199, 1.000, loc: 3, pos: 3000, scl: 2.000, code: (lambda (y) (+ y 0.1))]) [file: " cwd "oboe.snd[0]]
   (at 3200, cp->sounds[0][3200:3999, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 4000, cp->sounds[0][4000:4099, 1.000, loc: 2, pos: 0, scl: 2.000, code: (lambda (y) (+ y 0.3))]) [file: " cwd "oboe.snd[0]]
   (at 4100, cp->sounds[0][4100:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
"))))
	      (snd-display ";ptree[3200] display: ~A" (display-edits ind-ptree)))
	  (undo 1 ind-ptree)
	  (let ((reader (make-sample-reader (1- (frames)) ind-ptree 0 -1)))
	    (map-channel (lambda (y) (read-sample reader)) 0 (frames) ind-ptree))
	  (let ((reader (make-sample-reader (1- (frames)) ind-ptree 0 -1)))
	    (map-channel (lambda (y) (read-sample reader)) 0 (frames) ind-ptree))
	  (scan-channel (let ((old-reader (make-sample-reader 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 ";sample 100 (2): ~A" (sample 100 ind 0 2)))
	  (if (fneq (sample 100 ind 0 1) 0.0) (snd-display ";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 ";src-channel max .5: ~A" mx)))
	  (if (fneq (sample 200) 0.5) (snd-display ";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 ";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 ";src-channel max .25: ~A" mx)))
	  (if (fneq (sample 400) 0.5) (snd-display ";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 ";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 ";src-channel sine ~A: ~A" sr (maxamp ind 0)))
	     (if (integer? sr)
		 (let ((r0 (make-sample-reader 0))
		       (r1 (make-sample-reader 0 ind 0 1 (1- (edit-position))))
		       (sri (inexact->exact (floor sr))))
		   (do ((i 0 (1+ i)))
		       ((= i 500))
		     (let ((diff (abs (- (r0) (r1)))))
		       (if (> diff df) (snd-display ";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 (inexact->exact (round (* sr i))) ind 0 (1- (edit-position))))
		     (s3 (sample i ind 0 1)))
		 (if (> (abs (- s1 s2)) df) (snd-display ";sample ~D src(~A): ~A ~A" i sr s1 s2))
		 (if (fneq s3 0.0) (snd-display ";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 ";src-channel oboe ~A: ~A ~A" sr orig-max (maxamp ind 0)))
	       (if (integer? sr)
		   (let ((r0 (make-sample-reader 0))
			 (r1 (make-sample-reader 0 ind 0 1 (1- (edit-position))))
			 (sri (inexact->exact (floor sr))))
		     (do ((i 0 (1+ i)))
			 ((= i 5000))
		       (let ((diff (abs (- (r0) (r1)))))
			 (if (> diff df) (snd-display ";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 ";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 (inexact->exact (floor (* sr samp))) ind 0 (1- (edit-position)))))
		   (if (> (abs (- s1 s2)) df) (snd-display ";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-sample-reader 1000 ind 0 -1)))
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 0 (1+ i)))
		   ((= i 10))
		 (let ((val (reader)))
		   (if (fneq val .1)
		       (begin
			 (snd-display ";ptree previous: ~A ~A" i val)
			 (break))))))))
	  (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 ";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 ";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 ";vct-map! with vct-map! (~A): ~A ~A" n hi ho)))
	     (let ((val (find (lambda (y) (if (find (lambda (n6) (> n6 .1))) #t #f)))))
	       (if (not (equal? val (list #t 0))) (snd-display ";find with find: ~A" val)))
	     (let ((val (find (lambda (y) (if (scan-channel (lambda (n7) (> n7 .1))) #t #f)))))
	       (if (not (equal? val (list #t 0))) (snd-display ";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 ";scan-channel with map-channel: ~A" val))
	       (if (fneq mx (/ (maxamp ind 0) 2)) (snd-display ";scan+map max: ~A ~A" mx (maxamp ind 0)))
	       (if (not (= (edit-position ind 0) 1)) (snd-display ";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 ";map+map max 2: ~A ~A" mx (maxamp ind 0)))
	       (if (not (= (edit-position ind 0) 2)) (snd-display ";map+map edit-pos: ~A" (edit-position ind 0)))
	       (if (fneq mx (/ (maxamp ind 0 1) 2)) (snd-display ";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 ";(~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 ";(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 ";(~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 (inexact->exact (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 (inexact->exact (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 ";ptree fallback: ~A" (maxamp ind)))
	  (undo)
	  (ptree-channel (lambda (y data dir)
			   (declare (y real) (data vct) (dir boolean))
			   (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 ";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 6000 1.0 1.71387285873709e-12 1.0 1) 
				 (6001 0 6001 10999 1.0 0.999799966812134 6.29921462214078e-17 1) 
				 (11000 0 11000 19999 1.0 0.0 0.0 0) 
				 (20000 0 20000 29999 1.0 1.19209289550781e-7 0.0 2) 
				 (30000 0 30000 39999 1.0 0.0 0.0 0) 
				 (40000 0 40000 49999 1.0 0.200000002980232 0.600000023841858 1) 
				 (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 ";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 ";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 ";pad+ptree(3): ~A" val)))
	  (undo 2)
	  (close-sound ind))
	
	(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 ";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 ";swap-channels amps: ~A -> ~A" mxs new-mxs)))
	  (revert-sound ind)
	  (close-sound ind))
	
	(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 ";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 ";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 ";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 ";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 ";swapped m0: ~A" (mark-sample m0)))
	    (if (not (= (mark-sample m1) 4)) (snd-display ";swapped m1: ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 5)) (snd-display ";swapped m2: ~A" (mark-sample m2)))
	    (if (not (equal? (mark-home m0) (list ind 1))) (snd-display ";mark-home m0: ~A" (mark-home m0)))
	    (if (not (equal? (mark-home m1) (list ind 0))) (snd-display ";mark-home m1: ~A" (mark-home m1)))
	    (if (not (equal? (mark-home m2) (list ind 0))) (snd-display ";mark-home m2: ~A" (mark-home m2)))
	    (undo 1 ind 0)
	    (undo 1 ind 1)
	    (if (not (= (mark-sample m0) 3)) (snd-display ";swapped m0 2: ~A" (mark-sample m0)))
	    (if (not (= (mark-sample m1) 4)) (snd-display ";swapped m1 2: ~A" (mark-sample m1)))
	    (if (not (= (mark-sample m2) 5)) (snd-display ";swapped m2 2: ~A" (mark-sample m2)))
	    (if (not (equal? (mark-home m0) (list ind 0))) (snd-display ";mark-home m0 2: ~A" (mark-home m0)))
	    (if (not (equal? (mark-home m1) (list ind 1))) (snd-display ";mark-home m1 2: ~A" (mark-home m1)))
	    (if (not (equal? (mark-home m2) (list ind 1))) (snd-display ";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 ";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 ";maxamp cross swap 0: ~A" (maxamp ind0 0)))
	  (if (fneq (maxamp ind1 0) mx0) (snd-display ";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 ";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)
	  
	  (for-each
	   (lambda (func)
	     (ramp-channel 0.0 1.0 0 5)
	     (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))
	     (do ((start 0 (1+ start)))
		 ((= start 10))
	       (do ((len 1 (1+ len)))
		   ((= (+ 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)
		   (check-back-and-forth ind (format #f "ramp+scl 0-1 [~A ~A] with ~A" start len func) v)
		   (undo 1)
		   )))
	     (undo 1)
	     
	     (ramp-channel 1.0 0.0 5 5)
	     (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))
	     (do ((start 0 (1+ start)))
		 ((= start 10))
	       (do ((len 1 (1+ len)))
		   ((= (+ 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)
		   (check-back-and-forth ind (format #f "ramp+scl 1-0 [~A ~A] with ~A" start len func) v)
		   (undo 1)
		   )))
	     (undo 1)
	     
	     (ramp-channel 0.0 1.0 0 5)
	     (ramp-channel 1.0 0.0 5 5)
	     (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))
	     (do ((start 0 (1+ start)))
		 ((= start 10))
	       (do ((len 1 (1+ len)))
		   ((= (+ 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)
		   (check-back-and-forth ind (format #f "ramp+scl 0-1-1-0 [~A ~A] with ~A" start len func) v)
		   (undo 1)
		   )))
	     (undo 2)
	     
	     (ramp-channel 1.0 0.0 3 5)
	     (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))
	     (do ((start 0 (1+ start)))
		 ((= start 10))
	       (do ((len 1 (1+ len)))
		   ((= (+ 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)
		   (check-back-and-forth ind (format #f "ramp+scl mid 1-0 [~A ~A] with ~A" start len func) v)
		   (undo 1)
		   )))
	     (undo 1)
	     
	     (env-channel '(0 1 1 0 2 0 3 1))
	     (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))
	     (do ((start 0 (1+ start)))
		 ((= start 10))
	       (do ((len 1 (1+ len)))
		   ((= (+ 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)
		   (check-back-and-forth ind (format #f "ramp+scl 0-1-0-1 [~A ~A] with ~A" start len func) v)
		   (undo 1)
		   )))
	     (undo 1))
	   
	   (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)
			       (declare (y real) (data vct) (dir boolean))
			       (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (+ 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (+ 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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) 
			   (declare (y real) (data vct) (dir boolean))
			   (* 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 ";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 ";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)
	  )	
	))
      (run-hook after-test-hook 16)
      ))



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

(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)) 
		    (inexact->exact (floor (- y0 (* .4 size))))
		    (* 2 size)
		    (inexact->exact (floor (* .8 size)))
		    snd chn)))  

(if (and (or full-test (= snd-test 17) (and keep-going (<= snd-test 17)))
	 with-gui)
    (begin
      (run-hook before-test-hook 17)
      (if (not (provided? 'snd-musglyphs.scm)) (load "musglyphs.scm"))
      (if (not (provided? 'snd-draw.scm)) (load "draw.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)
	(reset-hook! after-graph-hook)
	(reset-hook! lisp-graph-hook)
	(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 ";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))
      (run-hook after-test-hook 17)
      ))


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

(if (not (provided? 'snd-enved.scm)) (load "enved.scm"))
(if (and (or full-test (= snd-test 18) (and keep-going (<= snd-test 18)))
	 with-gui)
    (begin
      (run-hook before-test-hook 18)
      (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 ";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 ";set channel-envelope: ~A?" (channel-envelope nind 0)))
	(close-sound nind)
	(stop-enveloping))
      (run-hook after-test-hook 18)
      ))


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

(define sfile 0)
(define after-save-state-hook-var 0)

(define (local-eq? a b)
  (if (number? a)
      (if (exact? a)
	  (= a b)
	  (< (abs (- a b)) .001))
      (eq? a b)))

(define* (insert-vct v #:optional beg dur snd chn)
  (insert-samples (or beg 0) dur v snd chn #f #f (format #f "insert-vct ~A ~A ~A" (vct->string v) beg dur)))

(define* (clm-channel-test #:optional snd chn)
  (clm-channel (make-two-zero 1 -1) 0 #f snd chn #f #f "clm-channel-test"))

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

(if (or full-test (= snd-test 19) (and keep-going (<= snd-test 19)))
    (let ((nind (open-sound "oboe.snd")))
      (run-hook before-test-hook 19)
      (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! 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))))
	(save-state (save-state-file))
	(save-options "test.temp")
	(close-sound nind)
	(for-each forget-region (regions))
	(load (save-state-file))
	(let ((ind (find-sound "oboe.snd")))
	  (if (or (> (abs (- (car old-bounds) (car (x-bounds ind 0)))) .05)
		  (> (abs (- (cadr old-bounds) (cadr (x-bounds ind 0)))) .05))
	      (snd-display ";save bounds: ~A" (x-bounds ind 0)))
	  (if (not (= (length (marks ind 0)) 1))
	      (snd-display ";save marks: ~A?" (marks ind 0)))
	  (if (not (= (mark-sample (car (marks ind 0))) 122))
	      (snd-display ";save mark: ~A?" (mark-sample (car (marks ind 0)))))
	  (if (not (= (edit-position ind 0) 1))
	      (snd-display ";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 ";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 ";save edit tree: ~A" (edit-tree ind 0)))
	  (if (not (= (sound-property 'ho ind) 1234))
	      (snd-display ";sound-property saved: 1234 -> ~A" (sound-property 'ho ind)))
	  (if (not (string=? (sound-property :hi ind) "hi"))
	      (snd-display ";sound-property saved: hi -> ~A" (sound-property :hi ind)))
	  (if (fneq (channel-property :ha ind 0) 3.14)
	      (snd-display ";channel-property saved: 3.14 -> ~A" (channel-property :ha ind 0)))
	  (close-sound ind)
	  (if (not (= after-save-state-hook-var 1234))
	      (snd-display ";after-save-state-hook: ~A" after-save-state-hook-var))
	  (reset-hook! after-save-state-hook)
	  
	  (let ((err (catch 'cannot-save
			    (lambda () 
			      (save-state "/bad/bad.save"))
			    (lambda args 12345))))
	    (if (not (= err 12345)) (snd-display ";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 ";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 "hiho.scm")
      (if (not (equal? (edit-fragment 1) '("set-sample 1 0.5000" "set" 1 1))) (snd-display ";save-edit-history 1: ~A?" (edit-fragment 1)))
      (if (not (equal? (edit-fragment 2) '("delete-samples 100 1" "delete" 100 1))) (snd-display ";save-edit-history 2: ~A?" (edit-fragment 2)))
      (if (not (equal? (edit-fragment 3) '("insert-sample 10 0.5000" "insert" 10 1))) (snd-display ";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 ";save-edit-history 4: ~A?" (edit-fragment 4)))
      (if (not (equal? (edit-fragment 5) '("pad-channel" "zero" 100 20))) (snd-display ";save-edit-history 5: ~A?" (edit-fragment 5)))
      (let ((str (display-edits)))
	(if (not (string=? str (string-append "
EDITS: 5

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

 (set 1 1) ; set-sample 1 0.5000 [1:4]:
   (at 0, cp->sounds[0][0:0, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 1, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 2, cp->sounds[0][2:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (delete 100 1) ; delete-samples 100 1 [2:5]:
   (at 0, cp->sounds[0][0:0, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 1, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 2, cp->sounds[0][2:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[0][101:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50827, end_mark)

 (insert 10 1) ; insert-sample 10 0.5000 [3:7]:
   (at 0, cp->sounds[0][0:0, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 1, cp->sounds[1][0:0, 1.000]) [buf: 1] 
   (at 2, cp->sounds[0][2:9, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 10, cp->sounds[2][0:0, 1.000]) [buf: 1] 
   (at 11, cp->sounds[0][10:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 101, cp->sounds[0][101:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (scale 0 50828) ; scale-channel 2.000 0 #f [4:7]:
   (at 0, cp->sounds[0][0:0, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 1, cp->sounds[1][0:0, 2.000]) [buf: 1] 
   (at 2, cp->sounds[0][2:9, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 10, cp->sounds[2][0:0, 2.000]) [buf: 1] 
   (at 11, cp->sounds[0][10:99, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 101, cp->sounds[0][101:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (silence 100 20) ; pad-channel [5:9]:
   (at 0, cp->sounds[0][0:0, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 1, cp->sounds[1][0:0, 2.000]) [buf: 1] 
   (at 2, cp->sounds[0][2:9, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 10, cp->sounds[2][0:0, 2.000]) [buf: 1] 
   (at 11, cp->sounds[0][10:98, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[-1][0:19, 0.000])
   (at 120, cp->sounds[0][99:99, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 121, cp->sounds[0][101:50827, 2.000]) [file: " cwd "oboe.snd[0]]
   (at 50848, end_mark)
")))
	    (snd-display ";display-edits: ~A?" str)))
      (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 ";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 ";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 "hiho.scm")
	(if (not (equal? (edit-fragment 1) '("ramp-channel 0.000 1.000 0 #f" "env" 0 50828)))
	    (snd-display ";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 ";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 ";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 "hiho.scm")
	  (set! (optimization) old-opt))
	(if (not (equal? (edit-fragment 1) '("ptree-channel" "ptree" 0 50828)))
	    (snd-display ";save-edit-history ptree 1: ~A?" (edit-fragment 1)))
	(revert-sound nind)
	(let ((old-opt (optimization)))
	  (set! (optimization) 5)
	  (xen-channel (lambda (y data dir) (* (list-ref data 0) y)) 0 (frames) nind 0 #f #f (lambda (beg dur) (list .5)))
	  (save-edit-history "hiho.scm")
	  (revert-sound nind)
	  (set! sfile nind)
	  (load "hiho.scm")
	  (set! (optimization) old-opt))
	(if (not (equal? (edit-fragment 1) '("ptree-channel" "xen" 0 50828)))
	    (snd-display ";save-edit-history xen 1: ~A?" (edit-fragment 1)))
	(close-sound nind))
      
      (let ((ind (new-sound "fmv.snd")))
	(set! (sample 10) .1)
	(save-sound ind)
	(set! (sample 1) .1)
	(let ((eds (display-edits ind)))
	  (save-state "t1.scm")
	  (close-sound ind)
	  (for-each forget-region (regions))
	  (load "t1.scm")
	  (set! ind (find-sound "fmv.snd"))
	  (if (not (sound? ind))
	      (snd-display ";save-state restored but no sound?"))
	  (let ((new-eds (display-edits ind)))
	    (if (not (string=? eds new-eds))
		(snd-display ";save-state from ~A to ~A?" eds new-eds)))
	  (do ((i 3 (1+ i)))
	      ((= i 6))
	    (set! (sample i) (* i .1))
	    (set! eds (display-edits ind))
	    (save-state "t1.scm")
	    (close-sound ind)
	    (for-each forget-region (regions))
	    (load "t1.scm")
	    (set! ind (find-sound "fmv.snd"))
	    (if (not (sound? ind))
		(snd-display ";save-state ~A restored but no sound?" i))
	    (let ((new-eds (display-edits ind)))
	      (if (not (string=? eds new-eds))
		  (snd-display ";save-state ~A from ~A to ~A?" i eds new-eds)))))
	(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 (display-edits ind))
	      (eds1 (display-edits ind1)))
	  (save-state "t1.scm")
	  (close-sound ind)
	  (close-sound ind1)
	  (for-each forget-region (regions))
	  (load "t1.scm")
	  (set! ind (find-sound "fmv.snd"))
	  (set! ind1 (find-sound "fmv1.snd"))
	  (if (or (not (sound? ind))
		  (not (sound? ind1)))
	      (snd-display ";save-state(2) restored but no sound? ~A ~A" ind ind1))
	  (let ((new-eds (display-edits ind))
		(new-eds1 (display-edits ind1)))
	    (if (not (string=? eds new-eds))
		(snd-display ";save-state(1) from ~A to ~A?" eds new-eds))
	    (if (not (string=? eds1 new-eds1))
		(snd-display ";save-state(2) from ~A to ~A?" eds1 new-eds1))))
	(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")
	(save-state "s61.scm")
	(close-sound ind)
	(for-each forget-region (regions))
	(load "s61.scm")
	(set! (save-dir) old-save-dir)
	(set! ind (find-sound "oboe.snd"))
	(if (not (= (show-axes ind 0) show-no-axes)) (snd-display ";save show-no-axes: ~A" (show-axes ind 0)))
	(if (not (= (zoom-focus-style) zoom-focus-middle)) (snd-display ";save zoom-focus-middle: ~A" (zoom-focus-style)))
	(if (not (= (transform-normalization ind 0) dont-normalize)) (snd-display ";save dont-normalize: ~A" (transform-normalization ind 0)))
	(if (not (= (graph-style ind 0) graph-filled)) (snd-display ";save graph-filled: ~A" (graph-style ind 0)))
	(if (not (= (transform-graph-type ind 0) graph-as-spectrogram)) (snd-display ";save graph-as-spectrogram: ~A" (transform-graph-type ind 0)))
	(if (not (= (time-graph-type ind 0) graph-as-wavogram)) (snd-display ";save graph-as-wavogram: ~A" (time-graph-type ind 0)))
	(if (not (= (x-axis-style ind 0) x-axis-as-percentage)) (snd-display ";save x-axis-as-percentage: ~A" (x-axis-style ind 0)))
	(if (not (= (speed-control-style ind) speed-control-as-semitone)) (snd-display ";save speed-control-style: ~A" (speed-control-style ind)))
	(if (not (= (cursor ind 0) 1234)) (snd-display ";save cursor 1234: ~A" (cursor ind 0)))
	(if (not (string=? (eps-file) "hiho.eps")) (snd-display ";save eps-file: ~A" (eps-file)))
	(set! (eps-file) old-eps-file)
	(if (not (string=? (display-edits) (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 32) ; set-samples [1:4]:
   (at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[1][0:31, 1.000]) [buf: 32] 
   (at 132, cp->sounds[0][132:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)

 (set 1000 10000) ; map-channel [2:6]:
   (at 0, cp->sounds[0][0:99, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 100, cp->sounds[1][0:31, 1.000]) [buf: 32] 
   (at 132, cp->sounds[0][132:999, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 1000, cp->sounds[2][0:9999, 1.000]) [buf: 10000] 
   (at 11000, cp->sounds[0][11000:50827, 1.000]) [file: " cwd "oboe.snd[0]]
   (at 50828, end_mark)
")))
	    (snd-display ";no save dir edits: ~A" (display-edits)))
	(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 verbose-cursor zero-pad min-dB spectro-hop spectro-cutoff
			  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 'verbose-cursor 'zero-pad 'min-dB 'spectro-hop 'spectro-cutoff
			       '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)
	(save-state "s61.scm")
	(close-sound ind)
	(for-each forget-region (regions))
	(load "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 "; 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 ";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 (= (find-sound "oboe.snd" 0) ind0))
	    (snd-display ";find-sound 0: ~A ~A" ind0 (find-sound "oboe.snd" 0)))
	(if (not (= (find-sound "oboe.snd" 1) ind1))
	    (snd-display ";find-sound 1: ~A ~A" ind1 (find-sound "oboe.snd" 1)))
	(add-mark 123 ind0)
	(add-mark 321 ind1)
	(save-state "s61.scm")
	(close-sound ind0)
	(close-sound ind1)
	(load "s61.scm")
	(set! ind0 (find-sound "oboe.snd" 0))
	(set! ind1 (find-sound "oboe.snd" 1))
	(if (or (not ind0) (not ind1)) (snd-display ";saved 2oboes, found: ~A" (map short-file-name (sounds))))
	(if (not (find-mark 123 ind0)) (snd-display ";saved 2oboes mark 0?"))
	(if (find-mark 123 ind1) (snd-display ";saved 2oboes mark 1->0?"))
	(if (not (find-mark 321 ind1)) (snd-display ";saved 2oboes mark 1?"))
	(if (find-mark 321 ind0) (snd-display ";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)
	     (save-state "s61.scm")
	     (close-sound ind)
	     (load "s61.scm")
	     (set! ind (find-sound "test.snd"))
	     (if (not (sound? ind)) 
		 (snd-display ";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)))))
	  
	  ;; track/mix ops
	  (lambda (ind)
	    (let ((mix1 (mix-vct (make-vct 3 .3) 0))
		  (mix2 (mix-vct (make-vct 2 .2) 3))
		  (mix3 (mix-vct (make-vct 5 .5) 5))
		  (trk (make-track)))
	      (set! (mix-track mix1) trk)
	      (set! (mix-track mix2) trk)
	      (set! (mix-track mix3) trk)
	      (set! (track-position trk) 10)))
	  
	  (lambda (ind)
	    (let ((mix1 (mix-vct (make-vct 3 .3) 0))
		  (mix2 (mix-vct (make-vct 2 .2) 3))
		  (mix3 (mix-vct (make-vct 5 .5) 5))
		  (trk (make-track)))
	      (set! (mix-track mix1) trk)
	      (set! (mix-track mix2) trk)
	      (set! (mix-track mix3) trk)
	      (set! (track-amp trk) 2.0)))
	  
	  (lambda (ind)
	    (let ((mix1 (mix-vct (make-vct 3 .3) 0))
		  (mix2 (mix-vct (make-vct 2 .2) 3))
		  (mix3 (mix-vct (make-vct 5 .5) 5))
		  (trk (make-track)))
	      (set! (mix-track mix1) trk)
	      (set! (mix-track mix2) trk)
	      (set! (mix-track mix3) trk)
	      (set! (track-amp-env trk) '(0 0 1 5))
	      (lock-track trk)))
	  
	  ;; 2 embedded as-one-edits
	  (lambda (ind)
	    (map-channel (lambda (y) -1.0))
	    (as-one-edit
	     (lambda ()
	       (delete-samples 5 5)
	       (insert-samples 5 2 (vct .1 .2))))
	    (scale-channel 2.0)
	    (as-one-edit 
	     (lambda ()
	       (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 10 10 ind 0)
	       (vct->channel (vct .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0) 20 10 ind 0)))
	    (delete-samples 15 10))
	  
	  )
	 
	 (list
	  ;; basic cases
	  (lambda (ind)
	    (if (fneq (sample 10) .5) (snd-display ";insert-sample save-state: ~A" (channel->vct 5 10 ind 0)))
	    (if (not (= (frames ind 0) 101)) (snd-display ";insert-sample save-state len: ~A" (frames ind 0))))
	  (lambda (ind)
	    (if (fneq (sample 10) 0.0) (snd-display ";delete-sample save-state: ~A" (channel->vct 5 10 ind 0)))
	    (if (not (= (frames ind 0) 99)) (snd-display ";delete-sample save-state len: ~A" (frames ind 0))))
	  (lambda (ind)
	    (if (fneq (sample 10) .5) (snd-display ";set sample save-state: ~A" (channel->vct 5 10 ind 0)))
	    (if (not (= (frames ind 0) 100)) (snd-display ";set sample save-state len: ~A" (frames ind 0))))
	  (lambda (ind)
	    (if (fneq (sample 10) .25) (snd-display ";scl sample save-state: ~A" (channel->vct 5 10 ind 0)))
	    (if (not (= (frames ind 0) 100)) (snd-display ";scl sample save-state len: ~A" (frames ind 0)))
	    (if (not (= (edit-position ind 0) 2)) (snd-display ";scl sample save-state edpos: ~A" (edit-position ind 0))))
	  (lambda (ind)
	    (if (not (= (frames ind 0) 105)) (snd-display ";pad sample save-state len: ~A" (frames ind 0)))
	    (if (not (= (edit-position ind 0) 2)) (snd-display ";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 ";pad sample save-state: ~A" (channel->vct 10 10 ind 0))))
	  (lambda (ind)
	    (if (not (= (frames ind 0) 100)) (snd-display ";env sample save-state len: ~A" (frames ind 0)))
	    (if (not (= (edit-position ind 0) 2)) (snd-display ";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 ";env sample save-state: ~A" (channel->vct 0 15 ind 0))))
	  (lambda (ind)
	    (if (not (= (frames ind 0) 100)) (snd-display ";ptree sample save-state len: ~A" (frames ind 0)))
	    (if (not (= (edit-position ind 0) 1)) (snd-display ";ptree sample save-state edpos: ~A" (edit-position ind 0)))
	    (if (fneq (maxamp ind 0) .1) (snd-display ";ptree save-state max: ~A" (maxamp ind 0)))
	    (if (not (vequal (make-vct 10 .1) (channel->vct 0 10))) (snd-display ";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 ";map #f save-state len: ~A" (frames ind 0)))
	    (if (not (= (edit-position ind 0) 1)) (snd-display ";map #f save-state edpos: ~A" (edit-position ind 0)))
	    (if (fneq (maxamp ind 0) .1) (snd-display ";map #f save-state max: ~A" (maxamp ind 0)))
	    (if (not (vequal (make-vct 10 .1) (channel->vct 0 10))) (snd-display ";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 ";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 ";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 ";as-one-edit save-state 2: ~A" (channel->vct 0 10 ind 0))))
	  
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 1)) (snd-display ";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 ";as-one-edit save-state 3: ~A" (channel->vct 0 10 ind 0))))
	  
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 1)) (snd-display ";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 ";as-one-edit save-state 4: ~A" (channel->vct 0 10 ind 0))))
	  
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 1)) (snd-display ";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 ";as-one-edit save-state 5: ~A" (channel->vct 0 10 ind 0)))
	    (if (not (= (frames ind 0) 97)) (snd-display ";save-state backup del+insert len: ~A" (frames ind 0))))
	  
	  ;; track/mix ops
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 7)) (snd-display ";save-state track pos edpos: ~A" (edit-position ind 0)))
	    (if (not (vequal (channel->vct 0 30 ind 0) (vct 0 0 0 0 0 0 0 0 0 0 .3 .3 .3 .2 .2 .5 .5 .5 .5 .5 0 0 0 0 0 0 0 0 0 0)))
		(snd-display ";track pos save-state 6: ~A" (channel->vct 0 30 ind 0)))
	    (if (not (= (frames ind 0) 100)) (snd-display ";save-state track pos len: ~A" (frames ind 0))))
	  
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 7)) (snd-display ";save-state track amp edpos: ~A" (edit-position ind 0)))
	    (if (not (vequal (channel->vct 0 20 ind 0) (vct .6 .6 .6 .4 .4 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 0 0 0 0)))
		(snd-display ";track amp save-state 7: ~A" (channel->vct 0 20 ind 0)))
	    (if (not (= (frames ind 0) 100)) (snd-display ";save-state track amp len: ~A" (frames ind 0))))
	  
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 8)) (snd-display ";save-state track amp env edpos: ~A" (edit-position ind 0)))
	    (if (not (vequal (channel->vct 0 15 ind 0) (vct 0.0 0.225 0.45 0.3 0.5 1.25 1.562 1.875 2.188 2.5 0.0 0.0 0 0 0)))
		(snd-display ";track amp env save-state 7: ~A" (channel->vct 0 15 ind 0)))
	    (if (not (= (frames ind 0) 100)) (snd-display ";save-state track amp env len: ~A" (frames ind 0))))
	  
	  ;; 2 embedded as-one-edits 
	  (lambda (ind)
	    (if (not (= (edit-position ind 0) 5)) (snd-display ";embed save-state edpos: ~A" (edit-position ind 0)))
	    (if (not (= (frames ind 0) 87)) (snd-display ";embed save-state track len: ~A" (frames ind 0)))
	    (if (not (vequal (channel->vct 0 25)
			     (vct -2 -2 -2 -2 -2
				  .2 .4
				  -2 -2 -2
				  .1 .2 .3 .4 .5
				  .6 .7 .8 .9 1.0
				  -2 -2 -2 -2 -2)))
		(snd-display ";embed save-state vals: ~A" (channel->vct 0 25 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 ";edit-list->function off to a bad start: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 1: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq (* 4 mx0) mx) (snd-display ";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 ";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 ";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 ";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 ";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 ";edit-list->function delete: ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 2: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (if (not (= (frames) (- frs 200))) (snd-display ";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 ";edit-list->function delete (2a): ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 2a: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (if (not (= (frames) (- frs 2))) (snd-display ";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 ";edit-list->function pad: ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 3: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (if (not (= (frames) (+ frs 200))) (snd-display ";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 ";edit-list->function pad (3a): ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 3a: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (if (not (= (frames) (+ frs 200))) (snd-display ";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 ";edit-list ramp: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 4: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq mx 0.061) (snd-display ";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 ";edit-list xramp: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 5: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq mx 0.0266) (snd-display ";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 ";edit-list env: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 6: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq mx 0.0634) (snd-display ";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 ";edit-list env: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 7: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq mx 0.0857) (snd-display ";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 ";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 ";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 ";edit-list->function 7b: ~A" func))
	    (if (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 ";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 #:end 1999) 1000 2000)
	  (let ((func (edit-list->function))
		(mxenv0 (maxamp)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function 7c: ~A" func))
	    (if (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 ";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) #:end 1999 #:offset 2.0 #:scaler 3.0) 1000 2000)
	    (let ((func (edit-list->function))
		  (mxenv1 (maxamp)))
	      (if (not (procedure? func)) 
		  (snd-display ";edit-list->function 7d: ~A" func))
	      (if (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 ";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 ";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 ";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 ";edit-list->function 7e: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (maxamp) 0.1459) (snd-display ";edit-list->function 7e max: ~A" (maxamp)))
	    (if (not (= (edit-position) 5)) (snd-display ";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 ";edit-list env 7f: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";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 ";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 ";edit-list env 7g: ~A" (sample 4000)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 7g: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (sample 4000) 0.0) (snd-display ";edit-list function 7g: ~A" (sample 4000))))
	  (revert-sound ind)
	  
	  ;; ---- simple ptree
	  (ptree-channel (lambda (y) (+ y .1)))
	  (if (fneq (maxamp) 0.247) (snd-display ";edit-list ptree: ~A" (maxamp)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 8: ~A" (object->string (procedure-source func))))
	    (func ind 0)
	    (let ((mx (maxamp)))
	      (if (fneq mx 0.347) (snd-display ";edit-list->function called (8): ~A" mx))))
	  (revert-sound ind)
	  
	  ;; ---- simple 1 sample insert
	  (insert-sample 100 .1)
	  (if (not (= (frames) (+ frs 1))) (snd-display ";edit-list->function insert-sample: ~A ~A" frs (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";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 ";edit-list->function func 9: ~A" (channel->vct 99 4)))
	    (if (not (= (frames) (+ frs 2))) (snd-display ";edit-list->function called (9): ~A ~A" frs (frames))))
	  (revert-sound ind)
	  
	  ;; ---- simple 1 sample set
	  (let ((val (sample 100)))
	    (set! (sample 100) .1)
	    (if (not (= (frames) frs)) (snd-display ";edit-list->function set-sample frames: ~A ~A" frs (frames)))
	    (if (fneq (sample 100) .1) (snd-display ";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 ";edit-list->function unset-sample val: ~A ~A" val (sample 100)))
	      (if (not (procedure? func)) 
		  (snd-display ";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 ";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 ";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 ";edit-list->function insert-sound: ~A ~A" frs (frames)))
	    (let ((func (edit-list->function)))
	      (if (not (procedure? func)) 
		  (snd-display ";edit-list->function 10: ~A" func))
	      (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (insert-sound \"/home/bil/cl/pistol.snd\" 1000 0 snd chn))"))
		  (snd-display ";edit-list->function 10: ~A" (object->string (procedure-source func))))
	      (revert-sound ind)
	      (func ind 0)
	      (if (not (= (frames) (+ frs pfrs))) (snd-display ";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 ";edit-list->function insert-samples: ~A ~A" frs (frames)))
	    (let ((func (edit-list->function)))
	      (if (not (procedure? func)) 
		  (snd-display ";edit-list->function 11: ~A" func))
	      (if (not (string=? (object->string (procedure-source func)) "(lambda (snd chn) (insert-samples 1000 41623 \"/home/bil/cl/pistol.snd\" snd chn))"))
		  (snd-display ";edit-list->function 11: ~A" (object->string (procedure-source func))))
	      (revert-sound ind)
	      (func ind 0)
	      (if (not (= (frames) (+ frs pfrs))) (snd-display ";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 ";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 ";edit-list->function 12: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (sample 1050) val) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";edit-list->function 14 samp: ~A" (sample 4000)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function 14: ~A" func))
	    (if (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 ";edit-list->function 14: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (sample 4000) 0.0173) (snd-display ";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 ";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 ";edit-list->function 14a: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (sample 1050) val) (snd-display ";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 ";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 ";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 ";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 ";edit-list->function 14c: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0))
	  (revert-sound ind)
	  
	  
	  ;; ---- sticky env end
	  (env-channel (make-env '(0 0 1 1 2 0) :end 500) 1000 1000)
	  (let ((func (edit-list->function)))
	    (if (fneq (sample 1750) 0.0) (snd-display ";edit-list->function 15 samp: ~A" (sample 1750)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function 15: ~A" func))
	    (if (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 500) 1000 1000 snd chn))"))
		(snd-display ";edit-list->function 15: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq (sample 1750) 0.0) (snd-display ";edit-list->function 15 re-samp: ~A" (sample 1750))))
	  (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 ";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 2000 reg)
	    (let ((func (edit-list->function))
		  (val (sample 2050)))
	      (if (not (procedure? func)) 
		  (snd-display ";edit-list->function 16: ~A" func))
	      (if (not (string=? (object->string (procedure-source func)) 
				 (string-append "(lambda (snd chn) (insert-region 2000 " (number->string reg) " snd chn))")))
		  (snd-display ";edit-list->function 16: ~A" (object->string (procedure-source func))))
	      (revert-sound ind)
	      (func ind 0)
	      (if (fneq (sample 2050) val) (snd-display ";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 ";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 ";edit-list->function 17: ~A" (object->string (procedure-source func))))
	    (if (fneq val -.002) (snd-display ";edit-list->function val: ~A" val))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq val -.002) (snd-display ";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 ";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 ";edit-list->function 17a: ~A" (object->string (procedure-source func))))
	    (if (fneq val -.002) (snd-display ";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 ";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 ";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 ";edit-list->function 18 len: ~A" (frames)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";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 ";edit-list->function 18: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (> (abs (- (frames) 25415)) 2) (snd-display ";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 ";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 ";edit-list->function 18a: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (not (= frs (frames))) (snd-display ";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 ";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 ";edit-list->function 18b: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (not (= frs (frames))) (snd-display ";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 ";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 ";edit-list->function 18c: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (not (= frs (frames))) (snd-display ";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 ";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 ";edit-list->function 19: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (fneq mx (maxamp)) (snd-display ";edit-list->function 19 re-filter: ~A ~A" mx (maxamp))))
	  (revert-sound)
	  
	  ;; ---- *.scm
	  (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 ";edit-list->function 20[~D]: ~A" ctr (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)))
	      
	      ;; 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 3.1415))))
	      (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) (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 3.1415)) 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 ";controls->channel amp: ~A" (amp-control ind)))
	(if (fneq (maxamp) (* 2 original-maxamp)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";controls->channel filter: ~A" (filter-control-order ind)))))
	
	;; ---- mix stuff
	(let ((id (make-v-mix ind 0)))
	  ;; ---- mix-position
	  (set! (mix-position id) 200)
	  (if (not (= (mix-position id) 200)) (snd-display ";edit-list->function mix off to a bad start: ~A" (mix-position id)))
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function mix 1: ~A" func))
	    (if (not (string=? (object->string (procedure-source func))
			       (format #f "(lambda (snd chn) (let ((-mix-~D ~D)) (set! -mix-~D (make-v-mix snd chn)) (set! (mix-position -mix-~D) 200)))"
				       id id id id)))
		(snd-display ";edit-list->function mix 1: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (or (null? (mixes ind 0))
		    (not (= (mix-position (car (mixes ind 0))) 200)))
		(snd-display ";edit-list->function mix 1 repos: ~A ~A" 
			     (mixes ind 0) (and (not (null? (mixes ind 0))) (mix-position (car (mixes ind 0)))))))
	  (revert-sound ind)
	  
	  ;; ---- mix-inverted?
	  (set! id (make-v-mix ind 0))
	  (set! (mix-inverted? id) #t)
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function mix 2: ~A" func))
	    (if (not (string=? (object->string (procedure-source func))
			       (format #f "(lambda (snd chn) (let ((-mix-~D ~D)) (set! -mix-~D (make-v-mix snd chn)) (set! (mix-inverted? -mix-~D) #t)))"
				       id id id id)))
		(snd-display ";edit-list->function mix 2: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (or (null? (mixes ind 0))
		    (not (mix-inverted? (car (mixes ind 0)))))
		(snd-display ";edit-list->function mix 2 reinvert: ~A ~A" 
			     (mixes ind 0) (and (not (null? (mixes ind 0))) (mix-inverted? (car (mixes ind 0)))))))
	  (revert-sound ind)
	  
	  ;; ---- mix-locked?
	  (set! id (make-v-mix ind 0))
	  (set! (mix-locked? id) #t)
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function mix 3: ~A" func))
	    (if (not (string=? (object->string (procedure-source func))
			       (format #f "(lambda (snd chn) (let ((-mix-~D ~D)) (set! -mix-~D (make-v-mix snd chn)) (set! (mix-locked? -mix-~D) #t)))"
				       id id id id)))
		(snd-display ";edit-list->function mix 3: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (or (null? (mixes ind 0))
		    (not (mix-locked? (car (mixes ind 0)))))
		(snd-display ";edit-list->function mix 3 relock: ~A ~A" 
			     (mixes ind 0) (and (not (null? (mixes ind 0))) (mix-locked? (car (mixes ind 0)))))))
	  (revert-sound ind)
	  
	  ;; ---- mix-amp
	  (set! id (make-v-mix ind 0))
	  (set! (mix-amp id 0) 0.5)
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function mix 4: ~A" func))
	    (if (not (string=? (object->string (procedure-source func))
			       (format #f "(lambda (snd chn) (let ((-mix-~D ~D)) (set! -mix-~D (make-v-mix snd chn)) (set! (mix-amp -mix-~D 0) 0.5)))"
				       id id id id)))
		(snd-display ";edit-list->function mix 4: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (or (null? (mixes ind 0))
		    (fneq (mix-amp (car (mixes ind 0)) 0) 0.5))
		(snd-display ";edit-list->function mix 4 reamp: ~A ~A" 
			     (mixes ind 0) (and (not (null? (mixes ind 0))) (mix-amp (car (mixes ind 0)) 0)))))
	  (revert-sound ind)
	  
	  ;; ---- mix-speed
	  (set! id (make-v-mix ind 0))
	  (set! (mix-speed id) 0.5)
	  (let ((func (edit-list->function)))
	    (if (not (procedure? func)) 
		(snd-display ";edit-list->function mix 5: ~A" func))
	    (if (not (string=? (object->string (procedure-source func))
			       (format #f "(lambda (snd chn) (let ((-mix-~D ~D)) (set! -mix-~D (make-v-mix snd chn)) (set! (mix-speed -mix-~D) 0.5)))"
				       id id id id)))
		(snd-display ";edit-list->function mix 5: ~A" (object->string (procedure-source func))))
	    (revert-sound ind)
	    (func ind 0)
	    (if (or (null? (mixes ind 0))
		    (fneq (mix-speed (car (mixes ind 0))) 0.5))
		(snd-display ";edit-list->function mix 5 respeed: ~A ~A" 
			     (mixes ind 0) (and (not (null? (mixes ind 0))) (mix-speed (car (mixes ind 0)))))))
	  (revert-sound ind)
	  )
	  
	  
	(close-sound ind))
	
      (mus-sound-prune)
      (run-hook after-test-hook 19)
      ))
    
    
;;; ---------------- test 20: transforms ----------------

(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) (1- j)))
	((= 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 (1- n))
	 (ncof (vct-length cc))
	 (nmod (* ncof n))
	 (nh (inexact->exact (floor (/ n 2))))
	 (joff (inexact->exact (- (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 (1- k)) 
					 (vct-ref data jf))))
		(vct-set! data1 (+ ii nh) (+ (vct-ref data1 (+ ii nh))
					     (* (vct-ref cr (1- k)) 
						(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 (1- k)))))
		(vct-set! data1 jr (+ (vct-ref data1 jr)
				      (* ai1 (vct-ref cr (1- k))))))))))
    (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))

(if (or full-test (= snd-test 20) (and keep-going (<= snd-test 20)))
    (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))
      
      (run-hook before-test-hook 20)
      (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)
		    (set! (transform-size) size)
		    (update-transform-graph))
		  (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 ";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)
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 0 (1+ i)))
		   ((= i 16))
		 (if (fneq (vct-ref d0 i) 1.0)
		     (begin
		       (snd-display ";fourier (1.0) [~D]: ~A?" i (vct-ref d0 i))
		       (break))))))
	    
	    (snd-transform fourier-transform d0 0)
	    (if (fneq (vct-ref d0 0) 256.0)
		(snd-display (format ";fourier (256.0): ~A?" (vct-ref d0 0))))
	    (call-with-current-continuation
	     (lambda (break)
	       (do ((i 1 (1+ i)))
		   ((= i 16))
		 (if (fneq (vct-ref d0 i) 0.0)
		     (begin
		       (snd-display ";fourier (0.0) [~D]: ~A?" i (vct-ref d0 i))
		       (break))))))
	    
	    (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 ";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 ";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 ";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 ";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 ";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 ";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 ";mus-fft d0 reversed: ~A ~A" d0 reversed-d0))
		  (if (fneq (vct-ref d1 (1+ i)) (vct-ref reversed-d1 i))
		      (snd-display ";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 ";mus-fft d0 saved: ~A ~A" d0 save-d0))
		(if (not (vequal d1 save-d1))
		    (snd-display ";mus-fft d1 saved: ~A ~A" d1 save-d1))))

	    (for-each 
	     (lambda (size)
	       (set! d0 (make-vct size))
	       (vct-set! d0 0 1.0)
	       (set! d1 (snd-spectrum d0 rectangular-window size))
	       (call-with-current-continuation
		(lambda (break)
		  (do ((i 0 (1+ i)))
		      ((= i (/ size 2)))
		    (if (fneq (vct-ref d1 i) 1.0)
			(begin
			  (snd-display ";snd-spectrum (1.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
			  (break))))))
	       
	       (set! d1 (snd-spectrum d0 rectangular-window))
	       (if (fneq (vct-ref d1 0) 1.0)
		   (snd-display ";snd-spectrum back (1.0 ~D): ~A?" size (vct-ref d1 0)))
	       (call-with-current-continuation
		(lambda (break)
		  (do ((i 1 (1+ i)))
		      ((= i (/ size 2)))
		    (if (fneq (vct-ref d1 i) 0.0)
			(begin
			  (snd-display ";snd-spectrum (0.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
			  (break))))))
	       
	       (set! d1 (snd-spectrum d0 rectangular-window size #f)) ; dB (0.0 = max)
	       (call-with-current-continuation
		(lambda (break)
		  (do ((i 0 (1+ i)))
		      ((= i (/ size 2)))
		    (if (fneq (vct-ref d1 i) 0.0)
			(begin
			  (snd-display ";snd-spectrum dB (0.0) [~D: ~D]: ~A?" i size (vct-ref d1 i))
			  (break)))))))
	     (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)
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len2))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";flat fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))
		 (if (fneq (vct-ref rl 0) (* len len)) (snd-display ";~A at 0: ~A" len (vct-ref rl 0)))
		 (vct-set! rl 0 0.0)
		 (if (> (vct-peak rl) .001) (snd-display ";~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)
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len2))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";impulse fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))
		 (if (fneq (vct-ref rl 0) 1.0) (snd-display ";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))
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len2))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";random fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))))
	     (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))
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len2))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";random fft: ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))))
	     (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)))
		  (snd-display ";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)))
		  (snd-display ";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)))
		  (snd-display ";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 (corr rl rl 16 16)))
		(autocorrelate rl1)
		(if (not (vequal rl1 nr))
		    (snd-display ";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 (corr rl rl 16 16)))
		(autocorrelate rl1)
		(if (not (vequal rl1 nr))
		    (snd-display ";autocorrelate/corr: ~A ~A" rl1 nr))))
	    
	    (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 ";autocorrelation ~A 0: ~A" len (vct-ref rl 0)))
		 (if (fneq (vct-ref rl 4) 1.0) (snd-display ";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 ";autocorrelate ~A 0: ~A" len (vct-ref rla 0)))
		 (if (fneq (vct-ref rla 4) 1.0) (snd-display ";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))
		 
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len2))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))
		 (vct-set! rl 0 0.0)
		 (vct-set! rl 4 0.0)
		 (if (> (vct-peak rl) .001) (snd-display ";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 (1- len) (1- j)))
		     ((= 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))
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len2))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";random ~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))))
	     (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 ";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 ";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)))
		 (call-with-current-continuation
		  (lambda (break)
		    (do ((i 0 (1+ i)))
			((= i len))
		      (if (fneq (vct-ref rl i) (vct-ref xrl i))
			  (begin
			    (snd-display ";~A at ~A: ~A ~A" len i (vct-ref rl i) (vct-ref xrl i))
			    (break))))))))
	     (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";inverse wavelet ~D: ~A ~A" i d1 d2)))
			       (snd-display ";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 ";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)))))))))
	      (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)
	      (let* ((samps (transform->vct ind 0)))
		(if (fneq (vct-ref samps 2) .002)
		    (snd-display ";add-transform filtering (~A): ~A" ftype samps)))
	      (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)))
		(call-with-current-continuation
		 (lambda (break)
		   (do ((i 0 (1+ i)))
		       ((= i 256))
		     (if (fneq (vct-ref samps i) (vct-ref orig i))
			 (begin
			   (snd-display ";add-transform same (~A): ~D ~A ~A" ftype i (vct-ref samps i) (vct-ref orig i))
			   (break)))))))
	      (set! (dot-size ind 0) 60)
	      (set! (graph-style ind 0) graph-lollipops)
	      (set! (x-bounds) (list 2.579 2.580))
	      (update-time-graph)
	      (close-sound ind))
	    
	    (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 ";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 ";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 
					    (inexact->exact (floor (* .5 (+ (list-ref ax 10) (list-ref ax 12)))))
					    (inexact->exact (floor (* .5 (+ (list-ref ax 11) (list-ref ax 13))))))
			       (force-event)))))
		     (lambda args args))
	      (let ((old-colormap (colormap)))
		(set! (colormap) 0) ; black-and-white
		(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 ";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 
					      (inexact->exact (floor (* .5 (+ (list-ref ax 10) (list-ref ax 12)))))
					      (inexact->exact (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! (spectro-cutoff 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 ";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 ";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 ";dht of pulse: ~A" v)))
	    
	    (let* ((ind (open-sound "oboe.snd"))
		   (val1 (car (find-sine 553.0 2000 3000)))
		   (val2 (car (find-sine 620.0 2000 3000))))
	      (if (or (fneq val1 .03835)
		      (fneq val2 .0012))
		  (snd-display ";find-sine: ~A ~A" val1 val2))
	      (let ((frq (spot-freq 2000 ind 0)))
		(if (not (= (inexact->exact (round frq)) 553))
		    (snd-display ";spot-freq: ~A" frq)))
	      (down-oct 2)
	      (let ((frq (spot-freq 2000 ind 0)))
		(if (and (not (= (inexact->exact (round frq)) 276))
			 (not (= (inexact->exact (round frq)) 277)))
		    (snd-display ";spot-freq down oct: ~A" frq)))
	      (undo)
	      (zero-phase)
	      (if (fneq (sample 0) .1472) (snd-display ";zero-phase: ~A" (sample 0)))
	      (undo)
	      (rotate-phase (lambda (x) x))
	      (undo)
	      (brighten-slightly .5)
	      (undo)
	      (spike)
	      (close-sound ind))
	    (let* ((ind (open-sound "1a.snd"))
		   (valf (car (find-sine 440.0 0 (frames))))
		   (valg (* 2 (/ (goertzel 440.0 0 (frames)) (frames))))
		   (valf1 (car (find-sine 100.0 0 (frames))))
		   (valg1 (* 2 (/ (goertzel 100.0 0 (frames)) (frames))))
		   (valf2 (car (find-sine 440.0 0 (frames))))
		   (valg2 (* 2 (/ (goertzel 440.0 0 (frames)) (frames))))
		   (valf3 (car (find-sine 437.0 0 (frames))))
		   (valg3 (* 2 (/ (goertzel 437.0 0 (frames)) (frames)))))
	      (if (fneq valf valg) (snd-display ";goertzel 0: ~A ~A" valf valg))
	      (if (fneq valf1 valg1) (snd-display ";goertzel 1: ~A ~A" valf1 valg1))
	      (if (fneq valf2 valg2) (snd-display ";goertzel 2: ~A ~A" valf2 valg2))
	      (if (fneq valf3 valg3) (snd-display ";goertzel 3: ~A ~A" valf3 valg3))
	      (close-sound ind))

	    (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";channel-polynomial offset: ~A" pos)))
	      (if (fneq (maxamp) .8575)
		  (snd-display ";channel-polynomial off mx: ~A" (maxamp)))
	      (undo)
	      (spectral-polynomial (vct 0.0 1.0) ind 0)
	      (if (fneq (maxamp) .493)
		  (snd-display ";spectral-polynomial 0 mx: ~A" (maxamp)))
	      (if (not (= (frames ind 0) 41623))
		  (snd-display ";spectral-polynomial 0 len: ~A" (frames)))
	      (undo)
	      (spectral-polynomial (vct 0.0 0.5 0.5) ind 0)
	      (if (fneq (maxamp) .493)
		  (snd-display ";spectral-polynomial 1: ~A" (maxamp)))
	      (if (not (= (frames ind 0) (* 2 41623)))
		  (snd-display ";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 ";spectral-polynomial 2: ~A" (maxamp)))
	      (if (not (= (frames ind 0) (* 3 41623)))
		  (snd-display ";spectral-polynomial 1 len: ~A" (frames)))
	      (close-sound ind))
	    
	    (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 "down-oct new len: ~A" (frames)))
	      (let ((r1 (make-sample-reader 0 ind 0 1 1))
		    (r2 (make-sample-reader 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 ";down-oct: ~A ~A ~A ~A" i val1 val2 val3)))))
	      (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";z 1 0.4g: ~A" res))))

	    ))
      (run-hook after-test-hook 20)
      ))



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

(define* (add-comment sample comment #:optional 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 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 (inexact->exact (round (/ (* size left-offset) samps))))
			 (right-offset (- (min 2000 right) left))
			 (right-bin (inexact->exact (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))))))))

(if (provided? 'snd-nogui)
    (define (load-font name) #f))
(define new-font (load-font "-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*"))
(define apropos-cs "(guile-user): close-sound	#<primitive-procedure close-sound>
(guile-user): close-sound-file	#<primitive-procedure close-sound-file>
")

(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 .75 .75 .75))
            (fill-rectangle pos 10 50 20)
	    (set! (foreground-color) (make-color 1 0 0))
	    (if new-font (set! (current-font) new-font))
            (draw-string "hiho" (+ pos 5) 24)
	    (set! (foreground-color) old-color))))))

(if (or full-test (= snd-test 21) (and keep-going (<= snd-test 21)))
    (begin
      (run-hook before-test-hook 21)

      (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 ";channels-equal? of copy"))
	  (if (not (channels=? ind1 0 ind2 0))
	      (snd-display ";channels=? of copy"))
	  (pad-channel (frames ind2 0) 100)
	  (if (channels-equal? ind1 0 ind2 0)
	      (snd-display ";channels-equal? of pad"))
	  (if (not (channels=? ind1 0 ind2 0))
	      (snd-display ";channels=? of pad"))
	  (set! (sample 50900 ind2 0) .1)
	  (if (channels-equal? ind1 0 ind2 0)
	      (snd-display ";channels-equal? of pad+set"))
	  (if (channels=? ind1 0 ind2 0)
	      (snd-display ";channels=? of pad+set 0 err"))
	  (if (not (channels=? ind1 0 ind2 0 .2))
	      (snd-display ";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 ";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)
	  (close-sound ind1)
	  (close-sound ind2)))

      (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 ";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 ";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)))
	  (call-with-current-continuation
	   (lambda (break)
	     (do ((i 0 (1+ i)))
		 ((= i 100))
	       (if (fneq (vct-ref data i) (vct-ref coeffs i))
		   (begin
		     (snd-display ";coeffs '(0 1 1 1): ~A ~A ~A" i (vct-ref coeffs i) (vct-ref data i))
		     (break)))))))
	(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 ";filter-sound 1 (1000): ~A" (channel->vct 5 10)))
	(undo)
	(make-selection 5 15)
	(filter-selection '(0 1 1 1) 100)
	(if (not (equal? (edit-fragment 2) (list "filter-selection '(0.000 1.000 1.000 1.000) 100" "set" 5 11)))
	    (snd-display ";filter-selection truncated: ~S" (edit-fragment 2)))
	(if (not (vequal (channel->vct 20 10) (make-vct 10 0.0)))
	    (snd-display ";filter-selection trunc overwrote: ~A" (channel->vct 20 10)))
	(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 ";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 ";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 ";filter-selection truncated (1000): ~S" (edit-fragment 2)))
	(if (fneq (maxamp) 0.0) (snd-display ";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 ";filter-selection not truncated (1000): ~S" (edit-fragment 2)))
	(if (fneq (maxamp) 0.318) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";(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 ";(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 ";(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 ";(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 ";(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 ";(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 ";(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 ";(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 ";edpos filter-sel undo: ~A" (edit-position ind 0)))
	(if (not (= (edit-position ind 1) 1)) (snd-display ";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 ";(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 ";(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 ";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 ";scale-to 1.0 short (10): ~A" (sample 10)))
	(if (fneq (sample 20) -.999) (snd-display ";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 ";scale-to 1.0 byte (10): ~A" (sample 10)))
	(if (fneq (sample 20) -.992) (snd-display ";scale-to 1.0 byte (20): ~A" (sample 10)))
	(close-sound ind))

      (if (not (string? (snd-help 'transpose-track))) (snd-display ";help string for transpose-track: ~A" (snd-help 'transpose-track)))

      (set! (transform-graph-type) 0)
      (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! (verbose-cursor) #f)
      
      (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 (= sel-snd ind-1) ind-2 ind-1))
			 (caller (if channel "channel" "sound")))
		    (if (not (eq-func old-val old-default))
			(snd-display ";~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 ";~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 ";~A set no arg: ~A ~A" name (func) new-val))
			  (if (not (eq-func (func) (func sel-snd)))
			      (snd-display ";~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 ";~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 ";~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 ";~A set arg: ~A ~A" name (func ind-1) new-val))
			  (if (eq-func (func ind-2) new-val)
			      (snd-display ";~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 ";~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 ";~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 ";~A set arg #t: ~A ~A" name (func ind-1) new-val))
			  (if (not (eq-func (func ind-2) new-val))
			      (snd-display ";~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 ";~A set arg #t old: ~A ~A" name (func ind-1) old-1))
			  (if (not (eq-func (func ind-2) old-2))
			      (snd-display ";~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 ";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 ";~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 ";~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 ";~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 ";~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 ";~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 ";~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 ";~A set channel-func: ~A ~A" name (func ind-1 0) new-val))
			      (if (eq-func (func ind-2 0) new-val) (snd-display ";~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 ";~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 ";~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 ";~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 ";~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 maxamp 'maxamp ind-1 ind-2 1.0 (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-beta 'fft-window-beta ind-1 ind-2 0.5 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-cutoff 'spectro-cutoff ind-1 ind-2 0.2 (lambda (a b) (< (abs (- a b)) .01)) feql #t #t)
		(list spectro-start 'spectro-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? #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 verbose-cursor '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 ";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 (= 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 ";~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 ";~A global set no arg: ~A ~A" name (func) new-val))
		    (if (not (eq-func (func) (func sel-snd)))
			(snd-display ";~A global set no arg sel: ~A ~A" name (func) (func sel-snd)))
		    (if (not (eq-func (func) (func unsel-snd)))
			(snd-display ";~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 ";~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 ";~A set arg: ~A ~A" name (func ind-1) new-val))
		    (if (eq-func (func ind-2) new-val)
			(snd-display ";~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 ";~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 ";~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 ";~A set arg #t: ~A ~A" name (func ind-1) new-val))
		    (if (not (eq-func (func ind-2) new-val))
			(snd-display ";~A set arg #t (2): ~A ~A" name (func ind-2) new-val))
		    (if (eq-func (func) new-val)
			(snd-display ";~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 ";~A set arg #t old: ~A ~A" name (func ind-1) old-1))
		    (if (not (eq-func (func ind-2) old-2))
			(snd-display ";~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 cursor-follows-play 'cursor-follows-play 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 all-args
	  (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 250000))
	      (do ((i 0 (1+ i)))
		  ((or (> (real-time) last-time)
		       (= i tests)))
		(let ((k (+ 1 (my-random 200)))
		      (s (let ((v (my-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 (> (my-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 ";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 ";snd-apropos: ~%~A~% ~A~%" help help1))))
	     (lambda args 
	       (snd-display ";snd-apropos trouble: ~A" args)))

      (map-sound-files (lambda (n) (if (> (mus-sound-duration n) 1000.0) (snd-display ";~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 ";~A is pretty long! ~A" 
				       n 
				       (mus-sound-duration (string-append sf-dir n)))))
		    (lambda args #f)))
	   sf-dir))

      (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 ";channel-mean: ~A" val)))
	(let ((val (channel-total-energy ind1 0)))
	  (if (fneq val 50.7153476262465) (snd-display ";channel-total-energy: ~A" val)))
	(let ((val (channel-average-power ind1 0)))
	  (if (fneq val 0.00155078578803922) (snd-display ";channel-average-power: ~A" val)))
	(let ((val (channel-rms ind1 0)))
	  (if (fneq val 0.039380017623653) (snd-display ";channel-rms: ~A" val)))
	(let ((val (channel-norm ind1 0)))
	  (if (fneq val 7.12147088923675) (snd-display ";channel-norm: ~A" val)))
	(let ((val (channel-variance ind1 0)))
	  (if (fneq val 50.7153476237207) (snd-display ";channel-variance: ~A" val)))
	(let ((val (channel-lp 2 ind1 0)))
	  (if (fneq val 7.12147088923675) (snd-display ";channel-lp 2: ~A" val)))
	(let ((val (channel-lp 1 ind1 0)))
	  (if (fneq val 775.966033935547) (snd-display ";channel-lp 1: ~A" val)))
	(let ((val (channel2-inner-product ind1 0 ind2 0)))
	  (if (fneq val 1.52892031334341) (snd-display ";channel2-inner-product: ~A" val)))
	(let ((val (channel2-angle ind1 0 ind2 0)))
	  (if (fneq val 1.55485084385627) (snd-display ";channel2-angle: ~A" val)))
	(let ((val (channel2-orthogonal? ind1 0 ind2 0)))
	  (if val (snd-display ";channel2-orthogonal: ~A" val)))
	(let ((val (channel2-coefficient-of-projection ind1 0 ind2 0)))
	  (if (fneq val 0.0301470932351876) (snd-display ";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 ";channel-distance: ~A" dist)))
	(close-sound ind1)
	(close-sound ind2))

      (copy-file (string-append (getcwd) "/oboe.snd") (string-append (getcwd) "/test.snd"))
      (let* ((ind (open-sound "test.snd"))
	     (mx (maxamp ind 0))
	     (chns (chans ind))
	     (sr (srate ind))
	     (fr (frames ind 0)))
	(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)))
	       (array->file "test.snd" v fr sr chns)
	       (update-sound ind)
	       (let ((mx1 (maxamp ind 0)))
		 (if (fneq mx mx1)
		     (snd-display ";update-sound looped maxamp: ~A ~A ~A ~A ~A" i ind (frames ind) mx1 mx)))
	       (if (not (= (chans ind) chns)) (snd-display ";update-sound looped chans: ~A ~A" chns (chans ind)))
	       (if (not (= (srate ind) sr)) (snd-display ";update-sound looped srate: ~A ~A" sr (srate ind)))
	       (if (not (= (frames ind) fr)) (snd-display ";update-sound looped frames: ~A ~A" fr (frames ind 0)))))
	   (let ((old-ind (open-sound "oboe.snd"))
		 (diff 0.0)
		 (rd (make-sample-reader 0 ind 0)))
	     (scan-channel (lambda (y)
			     (let ((cd (abs (- y (rd)))))
			       (if (> cd diff) (set! diff cd))
			       #f)))
	     (if (fneq diff 0.0) (snd-display ";update-sound looped overall max diff: ~A" diff))
	     (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 ";arr->file->array overall max diff: ~A" diff))))
	(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) (snd-display ";~A: ~A ~A ~A" ctr diff y yy)))
			    (set! ctr (1+ ctr))
			    #f)))
	  (if (fneq diff 0.0) (snd-display ";file->sample->file overall max diff: ~A" diff))
	  (close-sound ind1)))

      (run-hook after-test-hook 21)
      ))


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

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

(define fm-violin-opt
  (lambda* (startime dur frequency amplitude #:key
		     (fm-index 1.0)
		     (amp-env '(0 0  25 1  75 1  100 0))
		     (periodic-vibrato-rate 5.0) 
		     (random-vibrato-rate 16.0)
		     (periodic-vibrato-amplitude 0.0025) 
		     (random-vibrato-amplitude 0.005)
		     (noise-amount 0.0) 
		     (noise-freq 1000.0)
		     (ind-noise-freq 10.0) 
		     (ind-noise-amount 0.0)
		     (amp-noise-freq 20.0) 
		     (amp-noise-amount 0.0)
		     (gliss-env '(0 0  100 0)) 
		     (glissando-amount 0.0) 
		     (fm1-env '(0 1  25 .4  75 .6  100 0))  
		     (fm2-env '(0 1  25 .4  75 .6  100 0)) 
		     (fm3-env '(0 1  25 .4  75 .6  100 0))
		     (fm1-rat 1.0) 
		     (fm2-rat 3.0)	 
		     (fm3-rat 4.0)                    
		     (fm1-index #f) 
		     (fm2-index #f) 
		     (fm3-index #f)
		     (degree 0)
		     (distance 1.0)
		     (reverb-amount 0.01)
		     (base 1.0)
		     #:allow-other-keys)
	   (let* ((beg (inexact->exact (floor (* startime (mus-srate)))))
		  (len (inexact->exact (floor (* dur (mus-srate)))))
		  (end (+ beg len))
		  (frq-scl (hz->radians frequency))
		  (maxdev (* frq-scl fm-index))
		  (logfreq (log frequency))
		  (sqrtfreq (sqrt frequency))
		  (index1 (or fm1-index (min pi (* maxdev (/ 5.0 logfreq)))))
		  (index2 (or fm2-index (min pi (* maxdev 3.0 (/ (- 8.5 logfreq) (+ 3.0 (* frequency .001)))))))
		  (index3 (or fm3-index (min pi (* maxdev (/ 4.0 sqrtfreq)))))
		  (easy-case (and (zero? noise-amount)
				  (equal? fm1-env fm2-env)
				  (equal? fm1-env fm3-env)
				  (= fm1-rat (floor fm1-rat))
				  (= fm2-rat (floor fm2-rat))
				  (= fm3-rat (floor fm3-rat))))
		  (coeffs (and easy-case
			       (partials->polynomial
				(list (inexact->exact fm1-rat) index1
				      (inexact->exact (floor (/ fm2-rat fm1-rat))) index2
				      (inexact->exact (floor (/ fm3-rat fm1-rat))) index3))))
		  (norm (if easy-case 1.0 index1))
		  (carrier (make-oscil frequency))
		  (fmosc1 (make-oscil (* fm1-rat frequency)))
		  (fmosc2 (if easy-case #f (make-oscil (* fm2-rat frequency))))
		  (fmosc3 (if easy-case #f (make-oscil (* fm3-rat frequency))))
		  (ampf  (make-env amp-env :scaler amplitude :base base :duration dur))
		  (indf1 (make-env fm1-env norm :duration dur))
		  (indf2 (if easy-case #f (make-env fm2-env index2 :duration dur)))
		  (indf3 (if easy-case #f (make-env fm3-env index3 :duration dur)))
		  (frqf (make-env gliss-env (* glissando-amount frq-scl) :duration dur))
		  (pervib (make-triangle-wave periodic-vibrato-rate (* periodic-vibrato-amplitude frq-scl)))
		  (ranvib (make-rand-interp random-vibrato-rate (* random-vibrato-amplitude frq-scl)))
		  (fm-noi (if (not (= 0.0 noise-amount))
			      (make-rand noise-freq (* pi noise-amount))
			      #f))
		  (ind-noi (if (and (not (= 0.0 ind-noise-amount)) (not (= 0.0 ind-noise-freq)))
			       (make-rand-interp ind-noise-freq ind-noise-amount)
			       #f))
		  (amp-noi (if (and (not (= 0.0 amp-noise-amount)) (not (= 0.0 amp-noise-freq)))
			       (make-rand-interp amp-noise-freq amp-noise-amount)
			       #f))
					;(locs (make-locsig degree distance reverb-amount *output* *reverb* (mus-channels *output*)))
		  (data (make-vct (1+ (- end beg)))))
	     (if (or (not easy-case) ind-noi amp-noi (> noise-amount 0.0))
		 (vct-map! data
			   (lambda () 
			     (let* ((fuzz (if (> noise-amount 0.0) (rand fm-noi) 0.0))
				    (ind-fuzz (if ind-noi (+ 1.0 (rand-interp ind-noi)) 1.0))
				    (amp-fuzz (if amp-noi (+ 1.0 (rand-interp amp-noi)) 1.0))
				    (vib (+ (env frqf) (triangle-wave pervib) (rand-interp ranvib)))
				    (modulation (if easy-case
						    (* (env indf1) 
						       (polynomial coeffs (oscil fmosc1 vib)))
						    (+ (* (env indf1) (oscil fmosc1 (+ (* fm1-rat vib) fuzz)))
						       (* (env indf2) (oscil fmosc2 (+ (* fm2-rat vib) fuzz)))
						       (* (env indf3) (oscil fmosc3 (+ (* fm3-rat vib) fuzz)))))))
			       (* (env ampf) amp-fuzz
				  (oscil carrier (+ vib (* ind-fuzz modulation)))))))
		 (vct-map! data
			   (lambda () 
			     (let* ((vib (+ (env frqf) (triangle-wave pervib) (rand-interp ranvib)))
				    (modulation (* (env indf1) (polynomial coeffs (oscil fmosc1 vib)))))
			       (* (env ampf) (oscil carrier (+ vib modulation))))))))))

(definstrument (test-set-gens)
  (let ((cs (make-sum-of-cosines 5 440.0))
	(ss (make-sum-of-sines 5 440.0))
	(sq (make-square-wave 44.0))
	(en (make-env '(0 0 1 1) :base .3 :end 10))
	(fr (make-formant .1 440.0))
	(fl (make-fir-filter 4 (vct .5 .5 .5 .5)))
	(dl (make-delay 32))
	(ap (make-all-pass .4 .6 32))
	(av (make-average 4))
	(sr (make-src :srate .5))
	(gr (make-granulate :expansion 2.0))
	(sb (make-ssb-am 440.0))
	)
    (run
     (lambda ()
       (set! (mus-cosines cs) 3)
       (if (not (= (mus-cosines 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-xcoeff fr 0) .5)
       (if (fneq (mus-xcoeff fr 0) .5) (display ";a0 messed up"))
       (set! (mus-xcoeff fr 1) .5)
       (if (fneq (mus-xcoeff fr 1) .5) (display ";a1 messed up"))
       (set! (mus-xcoeff fr 2) .5)
       (if (fneq (mus-xcoeff fr 2) .5) (display ";a2 messed up"))
       (set! (mus-ycoeff fr 1) .5)
       (if (fneq (mus-ycoeff fr 1) .5) (display ";b1 messed up"))
       (set! (mus-ycoeff fr 2) .5)
       (if (fneq (mus-ycoeff fr 2) .5) (display ";b2 messed up"))
       (set! (mus-formant-radius fr) .2)
       (if (fneq (mus-formant-radius fr) .2) (display ";formant-radius 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) (snd-display ";sb freq?"))
       (set! (mus-frequency sb) 220.0)
       (if (fneq (mus-frequency sb) 220.0) (snd-display ";sb freq messed up"))
       ))))

(define (ssb-fm-no-gen gen modsig)
  (let* ((am0 (oscil (list-ref gen 0)))
	 (am1 (oscil (list-ref gen 1)))
	 (mod0 (hilbert-transform (list-ref gen 4) modsig))
	 (mod1 (delay (list-ref gen 5) modsig))
	 (car0 (oscil (list-ref gen 2) mod0))
	 (car1 (oscil (list-ref gen 3) mod1)))
    (+ (* am0 car0)
       (* am1 car1))))

(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))

(if (or full-test (= snd-test 22) (and keep-going (<= snd-test 22)))
    (begin
      
      (define (itst form result)
	(let ((val (run-eval form)))
	  (if (not (eqv? val result)) (snd-display ";~A -> ~A (~A)" form val result))))

      ;; can't use eq? here because identical numbers may not be eq?:
      ;; guile> (eq? 536870912 536870912)
      ;; #f
      ;; guile> (eq? 536870911 536870911)
      ;; #t
      
      (define (itsta form arg result)
	(let ((val (run-eval form arg)))
	  (if (not (eqv? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (fitst form result)
	(let ((val (run-eval form)))
	  (if (not (equal? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (fitsta form arg result)
	(let ((val (run-eval form arg)))
	  (if (not (equal? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (btst form result)
	(let ((val (run-eval form)))
	  (if (not (eq? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (btsta form arg result)
	(let ((val (run-eval form arg)))
	  (if (not (eq? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (ftst form result)
	(let ((val (run-eval form)))
	  (if (fneq val result) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (ftsta form arg result)
	(let ((val (run-eval form arg)))
	  (if (fneq val result) (snd-display ";~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 ";~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 ";~A -> ~A?" form tag))))
      
      (define (ctst form result)
	(let ((val (run-eval form)))
	  (if (not (char=? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define (ctsta form arg result)
	(let ((val (run-eval form arg)))
	  (if (not (char=? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
      
      (define int-var 32)
      (define dbl-var 3.14)
      (define bool-var #t)
      (define lst-var '(0 1 2))
      (define biggie (expt 2 31))
      
      (run-hook before-test-hook 22)
      (if (> (optimization) 0) 
	  (begin
	    
	    (ftsta '(lambda (y) (set! dbl-var 32.0) dbl-var) 0.0 32.0)
	    (if (fneq dbl-var 32.0) (snd-display ";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 ";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 ";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 ";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 ";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 ";set! 2 bool-var: ~A" bool-var))
	    
	    (define (stst form result)
	      (let ((val (run-eval form)))
		(if (not (string=? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
	    
	    (define (ststa form arg result)
	      (let ((val (run-eval form arg)))
		(if (not (string=? val result)) (snd-display ";~A -> ~A (~A)" form val result))))
	    
	    (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))
	    
	    (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)
	    (itst '(modulo 10 -3.0) -2)
	    (itst '(modulo -17 -9) -8)
	    (itsta '(lambda (y) (modulo 5 y)) 2.0 1)
	    (itsta '(lambda (y) (modulo y 7)) -45.0 4)
	    (itsta '(lambda (y) (modulo 10 y)) -3.0 -2)
	    (itsta '(lambda (y) (modulo -17 y)) -9.0 -8)
	    (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";and quit early?"))
	    (btsta '(lambda (y) (and (odd? y) (begin (set! int-var 321) #t))) 2 #f)
	    (if (= int-var 321) (snd-display ";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)
	    (btsta '(lambda (y) (if (not (number? y)) (set! int-var 456) (set! int-var 654))) 1.0 654)
	    (if (not (= int-var 654)) (snd-display ";if set int-var: ~A" int-var))
	    
	    (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+))
	    (etst '(1+ 1 2 3))
	    
	    (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 ";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 ";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 ";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 ";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 ";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 ";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) 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)
	    (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 ";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 ";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 ";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 ";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 ";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 ";call/cc dbl 1 didn't exit? ~A" dbl-var))
	    
	    (define str-var "hi")
	    (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 ";two continuations: ~A" str-var))
	    
	    (define cont1 #f)
	    (define cont2 #f)
	    (define gv 1)
	    
	    (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 ";cont2 trouble: ~A" str-var))
	    (set! str-var "hi")
	    (if (not (keyword? (run-eval '(if (even? 2) :hi :ho)))) 
		(snd-display ";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 ";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)
	    
	    (define global-v (make-vct 3 1.0))
	    (define global-v1 (make-vct 3 1.0))
	    (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)
	    
	    (define c-var #\a)
	    (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 ";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 ";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)
	    (etst '(let ((v (make-vector 3 1))) (vector? (if #t v))))
	    (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 ";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 ";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 "~,4F ~,3F" 3.14 (sqrt 3.0)) "3.1400 1.732")
	    (stst '(format #f "~A: ~A" "hiho" '(3 4)) "hiho: (3 4)")
	    (stst '(format #f "~A: ~C ~A" (> 2 3) #\c (make-vct 2 .1)) "#f: c #<vct[len=2]: 0.100 0.100>")
	    (stst '(format #f "~A: ~X" '(a . b) 23) "(a . b): 17")
	    (stst '(format #f "~,3E" pi) "3.142E+0")
	    (stst '(format #f "hi~16Tho") "hi              ho")
	    (stst '(format #f "~{~D ~}" '(1 2 3)) "1 2 3 ")
	    (stst '(format #f "~A ~A" 'hi :hi) "hi #:hi")
	    (stst '(clm-print "hiho: ~D" 43) "hiho: 43")
	    
	    (btst '(sample-reader? "hi") #f)
	    (btst '(sample-reader? #t) #f)
	    (btst '(mix-sample-reader? "hi") #f)
	    (btst '(mix-sample-reader? #t) #f)
	    (btst '(track-sample-reader? "hi") #f)
	    (btst '(track-sample-reader? #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)
	    (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)
	    (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)
	    (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-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)

	    (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)
	    
	    (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")))))
	    (etst '(let ((a 1)) (or (> a 1) "hi"))) ; kinda stupid -- run should handle this!
	    (etst '(let ((a 1)) (and (> a 1) "hi"))) ; kinda stupid -- run should handle this!
	    (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 ";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 ";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 ";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")
	    
	    (define pair-var (cons 2 3))
	    (btst (list 'pair? pair-var) #t)
	    (btst (list 'list? pair-var) #f)
	    (btst (list 'pair? int-var) #f)
	    (itst (list 'car pair-var) 2)
	    (itst (list 'cdr pair-var) 3)
	    (itsta '(lambda (y) (car pair-var)) 0.0 2)
	    (itsta '(lambda (y) (cdr pair-var)) 0.0 3)
	    (let ((pv (cons 123 321))) (run (lambda () (set! int-var (car pv)))))
	    (if (not (= int-var 123)) (snd-display ";car local pv: ~A" int-var))
	    (let ((pv (cons 123 321))) (run (lambda () (set! int-var (cdr pv)))))
	    (if (not (= int-var 321)) (snd-display ";cdr local pv: ~A" int-var))
	    (let ((pv (cons 123 321))) (run (lambda () (set! int-var (if (pair? pv) 1 0)))))
	    (if (not (= int-var 1)) (snd-display ";pair? local pv: ~A" int-var))
	    
	    (define list-var (list 2 3 4 5))
	    (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 (lambda () (set! int-var (car list-var))))
	    (if (not (= int-var 2)) (snd-display ";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)
	    (set! list-var (list (list 2 3 6) (list 4 5)))
	    (itst '(caar list-var) 2)
	    (itst '(cadar list-var) 3)
	    (itst '(caddar list-var) 6)
	    (itst '(caadr list-var) 4)
	    (itst '(cadadr list-var) 5)
	    (itsta '(lambda (y) (caar list-var)) 0.0 2)
	    (itsta '(lambda (y) (cadar list-var)) 0.0 3)
	    (itsta '(lambda (y) (caddar list-var)) 0.0 6)
	    (itsta '(lambda (y) (caadr list-var)) 0.0 4)
	    (itsta '(lambda (y) (cadadr list-var)) 0.0 5)
	    (set! list-var (list (list (list 2 3 6 7)) (list (list 4 5))))
	    (itst '(caaar list-var) 2)
	    (itst '(cadaar list-var) 3)
	    (itst '(caaadr list-var) 4)
	    (itsta '(lambda (y) (caaar list-var)) 0.0 2)
	    (itsta '(lambda (y) (cadaar list-var)) 0.0 3)
	    (itsta '(lambda (y) (caaadr list-var)) 0.0 4)
	    (let ((lv (list 321 123))) (run (lambda () (set! int-var (car lv)))))
	    (if (not (= int-var 321)) (snd-display ";car run local lst: ~A" int-var))
	    (let ((lv (list 321 123))) (run (lambda () (set! int-var (cadr lv)))))
	    (if (not (= int-var 123)) (snd-display ";cadr run local lst: ~A" int-var))
	    (let ((lv (list 321 123))) (run (lambda () (set! int-var (list-ref lv 0)))))
	    (if (not (= int-var 321)) (snd-display ";list-ref 0 run local lst: ~A" int-var))
	    (btst '(null? list-var) #f)
	    (let ((lv '())) (run (lambda () (set! int-var (if (null? lv) 1 0)))))
	    (if (not (= int-var 1)) (snd-display ";null? run local lst: ~A" int-var))
	    (itst '(length list-var) 2)
	    (let ((lv (list 321 123))) (run (lambda () (set! int-var (length lv)))))
	    (if (not (= int-var 2)) (snd-display ";length run local lst: ~A" int-var))
	    (set! list-var (list 2.5 3 "hiho" #t))
	    (run (lambda () (set! int-var (cadr list-var))))
	    (if (not (= int-var 3)) (snd-display ";cadr run lst: ~A" int-var))
	    (ftsta '(lambda (y) (car list-var)) 0.0 2.5)
	    (itsta '(lambda (y) (cadr list-var)) 0.0 3)
	    (ststa '(lambda (y) (caddr list-var)) 0.0 "hiho")
	    (btsta '(lambda (y) (cadddr list-var)) 0.0 #t)
	    
	    (set! list-var (list (list (list (list 2 3 6 7)) (list 4 5)) 17 (list 12 (list (list 14 15)))))
	    (itst '(caaaar list-var) 2)
	    (itst '(caadar list-var) 4)
	    (itst '(caaddr list-var) 12)
	    (itsta '(lambda (y) (caaaar list-var)) 0.0 2)
	    (itsta '(lambda (y) (caadar list-var)) 0.0 4)
	    (itsta '(lambda (y) (caaddr list-var)) 0.0 12)
	    
	    (itst '(car '(1 . 2)) 1)
	    (itst '(cdr '(1 . 2)) 2)
	    (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 ";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 ";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 ";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 ";string as arg to run: ~A" val)))
	    (let ((val (run-eval '(lambda (v) (declare (v boolean)) (not v)) #t)))
	      (if val (snd-display ";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 ";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 ";vct as arg to run: ~A" val)))
	    (let ((val (run-eval '(lambda (y) (let ((ge (make-env '(0 1 1 1) :end 10))) (env ge))) 0.0)))
	      (if (fneq val 1.0) (snd-display ";make-env in run: ~A" val)))
	    (define l0111 (list 0 1 1 1))
	    (let ((val (run-eval '(lambda (y) (let ((ge (make-env l0111 :end 10))) (env ge))) 0.0)))
	      (if (fneq val 1.0) (snd-display ";make-env in run with var list: ~A" val)))
	    
	    (define v (make-vct 8))
	    
	    (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-average))) (average? gen)) #t)
	    (btst '(let ((gen (make-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-convolve :filter v))) (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 v))) (filter? gen)) #t)
	    (btst '(let ((gen (make-fir-filter 8 v))) (fir-filter? 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))) (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-ppolar))) (two-pole? 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-sine-summation))) (sine-summation? gen)) #t)
	    (btst '(let ((gen (make-square-wave))) (square-wave? gen)) #t)
	    (btst '(let ((gen (make-src))) (src? gen)) #t)
	    (btst '(let ((gen (make-sum-of-cosines))) (sum-of-cosines? gen)) #t)
	    (btst '(let ((gen (make-sum-of-sines))) (sum-of-sines? 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-waveshape))) (waveshape? gen)) #t)
	    (btst '(let ((gen (make-zpolar))) (two-zero? 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-average))) (average gen)) 0.0)
	    (ftst '(let ((gen (make-average))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
	    (ftst '(let ((gen (make-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)) 0.0)
	    (ftst '(let ((gen (make-asymmetric-fm))) (gen)) 0.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-convolve :filter v))) (convolve gen)) 0.0)
	    (ftst '(let ((gen (make-convolve :filter v))) (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 v))) (filter gen)) 0.0)
	    (ftst '(let ((gen (make-filter 8 v v))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
	    (ftst '(let ((gen (make-fir-filter 8 v))) (fir-filter gen)) 0.0)
	    (ftst '(let ((gen (make-fir-filter 8 v))) (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))) (iir-filter gen)) 0.0)
	    (ftst '(let ((gen (make-iir-filter 8 v))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.0)
	    (ftst '(let ((gen (make-locsig))) (frame-ref (locsig gen 0 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-ppolar))) (two-pole gen)) 0.0)
	    (ftst '(let ((gen (make-ppolar))) (gen) (gen 0.0) (gen 0.0 0.0)) 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-sine-summation))) (sine-summation gen)) 0.0)
	    (ftst '(let ((gen (make-sine-summation))) (gen)) 0.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-sum-of-cosines))) (sum-of-cosines gen)) 1.0)
	    (ftst '(let ((gen (make-sum-of-cosines))) (gen)) 1.0)
	    (ftst '(let ((gen (make-sum-of-sines))) (sum-of-sines gen)) 0.0)
	    (ftst '(let ((gen (make-sum-of-sines))) (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-waveshape))) (waveshape gen)) 0.0)
	    (ftst '(let ((gen (make-waveshape))) (gen)) 0.0)
	    (ftst '(let ((gen (make-zpolar))) (two-zero gen)) 0.0)
	    (ftst '(let ((gen (make-zpolar))) (gen) (gen 0.0) (gen 0.0 0.0)) 0.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)
	    
	    (def-clm-struct st3 one two)
	    (define svar (make-st3 :one 1 :two 2))
	    (define svar1 #f)
	    (define bst3 #f)
	    (let ((tst 0))
	      (run (lambda () (set! tst (st3-one svar))))
	      (if (not (= tst 1)) (snd-display ";run st3-one: ~A ~A" tst (st3-one svar)))
	      (itst '(st3-two svar) 2)
	      (run (lambda () (set! bst3 (st3? svar))))
	      (if (not bst3) (snd-display ";st3? ~A" (st3? svar))))
	    
	    (set! svar (make-st3 :one 1.5 :two "hi"))
	    (let ((tst 0.0))
	      (run (lambda () (set! tst (st3-one svar))))
	      (if (fneq tst 1.5) (snd-display ";run st3-one (1.5): ~A ~A" tst (st3-one svar)))
	      (stst '(st3-two svar) "hi"))
	    
	    (set! svar (make-st3 :one (make-vct 3 1.0) :two (make-vector 3 2.0)))
	    (let ((tst 0.0))
	      (run (lambda () (set! tst (vct-ref (st3-one svar) 1))))
	      (if (fneq tst 1.0) (snd-display ";run st3-one (1.0 vct): ~A ~A" tst (st3-one svar)))
	      (run (lambda () (set! tst (vector-ref (st3-two svar) 1)))) ; not optimized
	      (if (fneq tst 2.0) (snd-display ";run st3-one (2.0 vector): ~A ~A" tst (st3-two svar))))
	    
	    (def-clm-struct st4 (one 1) (two 2.0))
	    (set! svar (make-st4))
	    (define bst4 #f)
	    (let ((tst 0))
	      (run (lambda () (set! tst (st4-one svar))))
	      (if (not (= tst 1)) (snd-display ";run st4-one: ~A ~A" tst (st4-one svar)))
	      (ftst '(st4-two svar) 2.0)
	      (run (lambda () (set! bst4 (st4? svar))))
	      (if (not bst4) (snd-display ";st4? ~A ~A" svar (st4? svar))))
	    
	    (set! svar (make-st4 :one 1.5))
	    (let ((tst 0.0))
	      (run (lambda () (set! tst (st4-one svar))))
	      (if (fneq tst 1.5) (snd-display ";run st4-one (1.5): ~A ~A" tst (st4-one svar)))
	      (ftst '(st4-two svar) 2.0))
	    
	    (set! svar (make-st3 :one 1 :two 2))
	    (set! svar1 (make-st3 :one 2 :two 3))
	    (let ((tst 0)
		  (tst1 0)
		  (tst2 0)
		  (tst3 0))
	      (run (lambda () 
		     (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)
		     (set! tst3 (st3-one svar1)))) ;123
	      (if (not (= tst 2)) (snd-display ";run st3-two (2): ~A ~A" tst (st3-two svar)))
	      (if (not (= tst1 3)) (snd-display ";run st3-two (3): ~A ~A" tst (st3-two svar1)))
	      (if (not (= tst2 3)) (snd-display ";run st3-two (2->3): ~A ~A" tst (st3-two svar)))
	      (if (not (= tst3 123)) (snd-display ";run st3-one (123): ~A ~A" tst (st3-one svar1))))
	    
	    ;; restore tests
	    (if (not (= (st3-one svar) 1)) (snd-display ";restore st3-one (1): ~A" (st3-one svar)))
	    (if (not (= (st3-one svar1) 123)) (snd-display ";restore st3-one (123): ~A" (st3-one svar1)))
	    (if (not (= (st3-two svar) 3)) (snd-display ";restore st3-two (2->3): ~A" (st3-two svar)))
	    (if (not (= (st3-two svar1) 3)) (snd-display ";restore st3-two (3): ~A" (st3-two svar1)))
	    
	    (set! svar (make-st3 :one 1.5 :two "hi"))
	    (set! svar1 (make-st3 :one 2 :two 3))
	    (let ((tst 0.0)
		  (tst1 0)
		  (tst2 "asdf")
		  (tst3 0))
	      (run (lambda () 
		     (set! tst (st3-one svar)) ;1.5
		     (set! tst1 (st3-two svar1)) ;3
		     (set! (st3-two svar) (number->string (st3-two svar1))) ;"3"
		     (set! tst2 (st3-two svar)) ;"3"
		     (set! (st3-one svar1) 123)
		     (set! tst3 (st3-one svar1)))) ;123
	      (if (fneq tst 1.5) (snd-display ";run st3-one (1.5): ~A ~A" tst (st3-two svar)))
	      (if (not (= tst1 3)) (snd-display ";run st3-two (3, a): ~A ~A" tst (st3-two svar1)))
	      (if (not (string=? tst2 "3")) (snd-display ";run st3-two (\"3\"): ~A ~A" tst (st3-two svar)))
	      (if (not (= tst3 123)) (snd-display ";run st3-one (123): ~A ~A" tst (st3-one svar1))))
	    
	    ;; restore tests
	    (if (fneq (st3-one svar) 1.5) (snd-display ";restore st3-one (1.5): ~A" (st3-one svar)))
	    (if (not (= (st3-one svar1) 123)) (snd-display ";restore st3-one (123): ~A" (st3-one svar1)))
	    (if (not (string=? (st3-two svar) "3")) (snd-display ";restore st3-two (\"3\"): ~A" (st3-two svar)))
	    (if (not (= (st3-two svar1) 3)) (snd-display ";restore st3-two (3): ~A" (st3-two svar1)))
	    
	    (set! svar (make-st3 :one #\c :two #f))
	    (let ((tst #f)
		  (tst1 #\z))
	      (run (lambda () 
		     (set! tst1 (st3-one svar)) ;#\c
		     (set! tst (not (st3-two svar))) ;#t
		     (set! (st3-one svar) #\f)
		     (set! (st3-two svar) #t)))
	      (if (not (char=? tst1 #\c)) (snd-display ";run st3-one (#c): ~A ~A" tst1 (st3-one svar)))
	      (if (not tst) (snd-display ";run st3-two (#t): ~A ~A" tst (st3-two svar))))
	    
	    ;; restore tests
	    (if (not (char=? (st3-one svar) #\f)) (snd-display ";restore st3-one (#\f): ~A" (st3-one svar))) 
	    (if (not (st3-two svar)) (snd-display ";restore st3-two (#t): ~A" (st3-two svar))) 
	    
	    (def-clm-struct hiho1 i x (s "hiho") (ii 3 :type int) (xx 1.0 :type float))
	    (define hi1 (make-hiho1))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) (hiho1-ii y)) hi1)))
	      (if (not (= val 3)) (snd-display ";typed hiho1-ii: ~A" val)))
	    (define hi2 (make-hiho1 :xx 3.14))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) (hiho1-xx y)) hi2)))
	      (if (fneq val 3.14) (snd-display ";typed hiho1-xx: ~A" val)))
	    (let ((val (run-eval '(lambda (x y) (declare (x hiho1) (y hiho1)) (+ (hiho1-xx y) (hiho1-xx x))) hi1 hi2)))
	      (if (fneq val 4.14) (snd-display ";typed hiho1-xx+xx: ~A" val)))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) y) hi1)))
	      (if (not (hiho1? val)) (snd-display ";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 ";set def-clm-struct type check? ~A" tag)))
	    (let ((tag (catch 'cannot-parse
			      (lambda () (run-eval '(let ((r (make-sample-reader))) (format #f "~A" r))))
			      (lambda args (car args)))))
	      (if (not (eq? tag 'cannot-parse))
		  (snd-display ";format arg type check? ~A" tag)))

	    ;; test def-clm-struct redefinition
	    (def-clm-struct hiho1 i xxx x (s "hiho") (ii 3 :type int) (xx 1.0 :type float))
	    (set! hi1 (make-hiho1))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) (hiho1-ii y)) hi1)))
	      (if (not (= val 3)) (snd-display ";typed hiho1-ii(2): ~A" val)))
	    (set! hi2 (make-hiho1 :xx 3.14))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) (hiho1-xx y)) hi2)))
	      (if (fneq val 3.14) (snd-display ";typed hiho1-xx(2): ~A" val)))
	    (let ((val (run-eval '(lambda (x y) (declare (x hiho1) (y hiho1)) (+ (hiho1-xx y) (hiho1-xx x))) hi1 hi2)))
	      (if (fneq val 4.14) (snd-display ";typed hiho1-xx+xx(2): ~A" val)))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho1)) y) hi1)))
	      (if (not (hiho1? val)) (snd-display ";clm-struct return(2): ~A" val)))
	    (set! hi2 (make-hiho1 :xxx 31.14))
	    (let ((old 0.0))
	      (run (lambda ()
		     (set! old (hiho1-xxx hi2))
		     (set! (hiho1-xxx hi2) 1.0)))
	      (if (fneq (hiho1-xxx hi2) 1.0) (snd-display ";hiho1-xxx: ~A" (hiho1-xxx hi2)))
	      (if (fneq old 31.14) (snd-display ";hiho1-xxx old: ~A" old)))
	    
	    ;; 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 ";cannot parse case: ~A" tag)))
	    
	    (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 hi2 (make-hiho2 :v (make-vct 3 .1)))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho2)) (vct-ref (hiho2-v y) 1)) hi2)))
	      (if (fneq val .1) (snd-display ";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 ";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 ";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 ";inner set hiho2-i: ~A" val))
	      (if (not (= (hiho2-i hi2) 2))
		  (snd-display ";set hiho2-i: ~A" (hiho2-i hi2))))
	    (let ((val (run-eval '(lambda (y) (declare (y hiho2)) (hiho2-x y)) hi2)))
	      (if (fneq val 0.0) (snd-display ";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 ";inner set hiho2-x: ~A" val))
	      (if (fneq (hiho2-x hi2) 3.14)
		  (snd-display ";set hiho2-x: ~A" (hiho2-x hi2))))
	    
	    (let ((lst (list 1 2 (vct-fill! (make-vct 4) 3.14) 3))
		  (k 123.0))
	      (run (lambda () (set! k (vct-ref (list-ref lst 2) 1))))
	      (if (fneq k 3.14) (snd-display ";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")
	    (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 
				     (/ (mus-sound-samples file)
					(* (mus-sound-chans file) (mus-sound-srate file)))))))
		     (or (string=? str "oboe.snd: chans: 1, srate: 22050, Sun, big endian short (16 bits), len: 2.30512475967407")
			 (string=? str "oboe.snd: chans: 1, srate: 22050, Sun, big endian short (16 bits), len: 2.30512471655329")))
		  #t)

	    (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)
	    (ftst '(hz->radians 1.0) (in-hz 1.0))
	    (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)
	    (ftsta '(lambda (y) (hz->radians y)) 1.0 (in-hz 1.0))
	    (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))))))
	    
	    (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 '(maxamp 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))
	    
	    (define gen (make-oscil 440))
	    (ftst '(mus-frequency gen) 440.0)
	    (ftst '(mus-phase gen) 0.0)
	    (ftst '(oscil gen) 0.0)
	    (ftst '(mus-phase gen) 0.125)
	    (run-eval '(set! (mus-frequency gen) 100.0))
	    (ftst '(mus-frequency gen) 100.0)
	    (ftst '(gen) .125)
	    (ftst '(gen 1.0) 0.153)
	    (ftst '(gen 0.0 0.0) 0.925)
	    (ftst '(gen 0.0 1.0) 0.802)
	    (etst '(oscil 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)
	    (let* ((ind (open-sound "oboe.snd"))
		   (reg (make-region 0 10))
		   (mx (mix-vct (vct 0 .1 .2) 10))
		   (mrk (add-mark 123))
		   (trk (make-track))
		   (reg-val -100.0))
	      (set! (mark-sync mrk) 1234)
	      (btst '(sample-reader? (make-sample-reader)) #t)
	      (btst '(let ((a (make-sample-reader))) (and (eq? a a) (eqv? a a) (equal? a a))) #t)
	      (btst '(let ((a (make-sample-reader)) (b (make-sample-reader))) (or (eq? a b) (eqv? a b) (equal? a b))) #f)
	      (let ((ok #f))
		(run (lambda () (set! ok (sound? ind))))
		(if (not ok) (snd-display ";run sound?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (sound? (1+ ind)))))
		(if ok (snd-display ";run not sound?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (mark? mrk))))
		(if (not ok) (snd-display ";run mark?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (mark? (1+ mrk)))))
		(if ok (snd-display ";run not mark?")))
	      (let ((samp -1))
		(run (lambda () (set! samp (mark-sample mrk))))
		(if (not (= samp 123)) (snd-display ";run mark-sample: ~A" samp)))
	      (let ((sc -1))
		(run (lambda () (set! sc (mark-sync mrk))))
		(if (not (= sc 1234)) (snd-display ";run mark-sync: ~A" sc)))
	      (let ((ok #f))
		(run (lambda () (set! ok (region? reg))))
		(if (not ok) (snd-display ";run region?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (region? (1+ reg)))))
		(if ok (snd-display ";run not region?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (mix? mx))))
		(if (not ok) (snd-display ";run mix?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (mix? (1+ mx)))))
		(if ok (snd-display ";run not mix?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (track? trk))))
		(if (not ok) (snd-display ";run track?")))
	      (let ((ok #f))
		(run (lambda () (set! ok (track? (1+ trk)))))
		(if ok (snd-display ";run not track?")))
	      (let ((str "hiho")
		    (str1 (temp-dir)))
		(run (lambda () (set! str (temp-dir))))
		(if (not (string=? str str1)) (snd-display ";run temp-dir: ~A ~A" str str1)))
	      (let ((str "hiho")
		    (str1 (save-dir)))
		(run (lambda () (set! str (save-dir))))
		(if (not (string=? str str1)) (snd-display ";run save-dir: ~A ~A" str str1)))
	      (let ((mx (mark-sync-max))
		    (mx1 -1))
		(run (lambda () (set! mx1 (mark-sync-max))))
		(if (not (= mx mx1)) (snd-display ";run mark-sync-max: ~A ~A" mx mx1)))
	      (let ((mx (selection-chans))
		    (mx1 -1))
		(run (lambda () (set! mx1 (selection-chans))))
		(if (not (= mx mx1)) (snd-display ";run selection-chans: ~A ~A" mx mx1)))
	      (run (lambda () 
		     (let ((a (make-region-sample-reader 0 reg 0)))
		       (set! reg-val (read-region-sample a)))))
	      (if (fneq reg-val 0.0) (snd-display ";read-region-sample opt: ~A" reg-val))

	      (let ((ok #t))
		(run (lambda () (set! ok (mix-locked? mx))))
		(if ok (snd-display ";run mix-locked?")))
	      (let ((ok #t))
		(run (lambda () (set! ok (mix-inverted? mx))))
		(if ok (snd-display ";run mix-inverted?")))
	      (let ((ok 0))
		(run (lambda () (set! ok (mix-chans mx))))
		(if (not (= ok 1)) (snd-display ";run mix-chans?")))
	      (let ((ok 0))
		(run (lambda () (set! ok (mix-position mx))))
		(if (not (= ok 10)) (snd-display ";run mix-position?")))
	      (let ((ok 0))
		(run (lambda () (set! ok (mix-frames mx))))
		(if (not (= ok 3)) (snd-display ";run mix-frames?")))
	      (let ((ok 1))
		(run (lambda () (set! ok (mix-track mx))))
		(if (not (= ok 0)) (snd-display ";run mix-track?")))
	      (let ((ok 0.0))
		(run (lambda () (set! ok (mix-speed mx))))
		(if (fneq ok 1.0) (snd-display ";run mix-speed?")))

	      (let ((ok 3))
		(run (lambda () (set! ok (track-chans trk))))
		(if (not (= ok 0)) (snd-display ";run track-chans ~A ~A?" ok (track-chans trk))))
	      (let ((ok 1))
		(run (lambda () (set! ok (track-track trk))))
		(if (not (= ok 0)) (snd-display ";run track-track?")))
	      (let ((ok 0.0))
		(run (lambda () (set! ok (track-speed trk))))
		(if (fneq ok 1.0) (snd-display ";run track-speed?")))
	      (let ((ok 0.0))
		(run (lambda () (set! ok (track-tempo trk))))
		(if (fneq ok 1.0) (snd-display ";run track-tempo?")))
	      (let ((ok 0.0))
		(run (lambda () (set! ok (track-amp trk))))
		(if (fneq ok 1.0) (snd-display ";run track-amp?")))

	      (let ((ok 0))
		(run (lambda () (set! ok (region-chans reg))))
		(if (not (= ok 1)) (snd-display ";run region-chans ~A ~A?" ok (region-chans reg))))
	      (let ((ok 0))
		(run (lambda () (set! ok (region-srate reg))))
		(if (not (= ok 22050)) (snd-display ";run region-srate ~A ~A?" ok (region-srate reg))))
	      (let ((ok 0))
		(run (lambda () (set! ok (region-frames reg))))
		(if (not (= ok 11)) (snd-display ";run region-frames ~A ~A?" ok (region-frames reg))))
	      (let ((ok 0.0))
		(run (lambda () (set! ok (region-maxamp reg))))
		(if (fneq ok .0003) (snd-display ";run region-maxamp ~A ~A?" ok (region-maxamp reg))))

	      (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 
	       (lambda ()
		 (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 ";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 
	       (lambda ()
		 (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 ";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 ";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 ";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 ";s a: ~A" a)))
	    (itst '(do ((i 0 (1+ i))) ((= i 3) 0) (vct-scale! (make-vct 3) 1.0)) 0)
	    
	    (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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 (not (vequal v (vct 0.0 0.125 0.248))) (snd-display ";vect gen vct-map 1.0: ~A" v))
	      (vct-map! v (lambda ()
			    (let ((val (vector-ref vect 0)))
			      (oscil val zero))))
	      (if (not (vequal v (vct 0.367 0.481 0.587))) (snd-display ";vect gen vct-map 1.0 (phase): ~A" v)))
	    
	    (define clm_vector (make-vector 2))
	    (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)

	    (define vct_vector (make-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 ";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 (not (vequal v (vct 0.0 0.0 0.125))) (snd-display ";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 (not (vequal v (vct 0.0 0.125 0.248))) (snd-display ";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 (not (vequal v (vct 0.0 0.125 0.248))) (snd-display ";[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 ";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 ";vect vct set vct-map 1.0: ~A" v)))
	    
	    (let ((v (make-vct 3))
		  (f (make-frame 1)))
	      (vct-map (lambda () (frame-set! f 0 1.0) f) v)
	      (if (not (vequal v (vct 1.0 1.0 1.0))) (snd-display ";vct-map 1.0: ~A (ref)" v)))
	    
	    (let ((v (make-vct 3))
		  (f (make-frame 1)))
	      (vct-map (lambda () (set! (frame-ref f 0) 1.0) f) v)
	      (if (not (vequal v (vct 1.0 1.0 1.0))) (snd-display ";vct-map 1.0 (set ref): ~A" v)))
	    
	    (let ((v (make-vct 3))
		  (f (make-frame 1)))
	      (set! (optimization) 0)
	      (vct-map (lambda () (frame-set! f 0 1.0) f) v)
	      (set! (optimization) max-optimization)
	      (if (not (vequal v (vct 1.0 1.0 1.0))) (snd-display ";unopt vct-map 1.0 (ref): ~A" v)))
	    
	    (let ((v (make-vct 3))
		  (f (make-frame 1)))
	      (vct-map (lambda () (frame-set! f 0 (+ mus-next 1.0)) f) v) ; force fall-through to Guile
	      (if (not (vequal v (vct 2.0 2.0 2.0))) (snd-display ";vct-map 1.0 (set): ~A" v)))
	    
	    (let ((v0 (make-vct 3))
		  (v1 (make-vct 3))
		  (f (make-frame 2)))
	      (vct-map (lambda () 
			 (frame-set! f 0 1.0) 
			 (frame-set! f 1 0.5) 
			 f)
		       v0 v1)
	      (if (or (not (vequal v0 (vct 1.0 1.0 1.0)))
		      (not (vequal v1 (vct 0.5 0.5 0.5))))
		  (snd-display ";vct-map 1.0 0.5: ~A ~A" v0 v1)))

	    (if (not (string=? (mus-describe (make-frame)) "frame[1]: [0.000]")) (snd-display ";make-frame 0 args: ~A" (mus-describe (make-frame))))
	    
	    (set! (locsig-type) mus-interp-linear)
	    (let ((v0 (make-vct 3))
		  (v1 (make-vct 3))
		  (l (make-locsig 30.0 :channels 2)))
	      (vct-map (lambda () 
			 (locsig l 0 1.0))
		       v0 v1)
	      (if (or (not (vequal v0 (vct 0.667 0.667 0.667)))
		      (not (vequal v1 (vct 0.333 0.333 0.333))))
		  (snd-display ";vct-map locsig: ~A ~A" v0 v1))
	      (catch #t (lambda () (vct-map! v0 (lambda () (locsig l)))) (lambda args args))
	      (catch #t (lambda () (vct-map! v0 (lambda () (locsig l 1.0 2.0 3.0 4.0)))) (lambda args args)))
	    
	    (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 ";run vector-set: ~A ~A ~A ~A" v1 v2 v3 vp)))
	    
	    (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 ";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 ";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 ";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 ";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-cosines osc))
			  (set! (mus-frequency osc) 123.0)
			  (set! (mus-phase osc) 1.0)
			  0.0))
	      (if (fneq frq 440.0) (snd-display ";run frq: ~A" frq))
	      (if (fneq phs 0.0) (snd-display ";run phs: ~A" phs))
	      (if (not (= cs 1)) (snd-display ";run cs: ~A" cs))
	      (if (fneq (mus-frequency osc) 123.0) (snd-display ";run mus-frequency: ~A" (mus-frequency osc)))
	      (if (fneq (mus-phase osc) 1.0) (snd-display ";run mus-phase: ~A" (mus-phase osc))))
	    
	    (let ((v (make-vct 10))
		  (gen1 (make-oscil 440))
		  (gen2 (make-oscil)))
	      (vct-map! v (lambda () (+ (gen1) (gen2))))
	      (if (not (vequal v (vct 0.000 0.250 0.496 0.735 0.962 1.173 1.367 1.538 1.686 1.807))) (snd-display ";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 ";gen+gen-pi vct-map: ~A" v)))
	    
	    (let ((v (make-vct 10))
		  (gen1 (make-oscil 440))
		  (gen2 (make-oscil))
		  (gen3 (make-oscil 440 :initial-phase 0.0)))
	      (vct-map! v (lambda () (+ (gen1) (gen2) (gen3))))
	      (if (not (vequal v (vct 0.000 0.375 0.744 1.102 1.442 1.760 2.050 2.308 2.529 2.711))) (snd-display ";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 ";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 ";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 ";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 ";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 ";gen+gen+vr args: ~A ~A" v1 v2)))

	    (let ((osc (make-sum-of-cosines 3 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-cosines osc))
			  (set! (mus-frequency osc) 123.0)
			  (set! (mus-phase osc) 1.0)
			  (set! (mus-cosines osc) 10)
			  0.0))
	      (if (fneq frq 440.0) (snd-display ";cs run frq: ~A" frq))
	      (if (fneq phs 0.0) (snd-display ";cs run phs: ~A" phs))
	      (if (not (= cs 3)) (snd-display ";cs run cs: ~A" cs))
	      (if (fneq (mus-frequency osc) 123.0) (snd-display ";cs run mus-frequency: ~A" (mus-frequency osc)))
	      (if (fneq (mus-phase osc) 1.0) (snd-display ";cs run mus-phase: ~A" (mus-phase osc)))
	      (if (not (= (mus-cosines osc) 10)) (snd-display ";cs run set cs: ~A" (mus-cosines osc))))
	    
	    (let ((osc (make-sum-of-sines 3 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-cosines osc))
			  (set! (mus-frequency osc) 123.0)
			  (set! (mus-phase osc) 1.0)
			  (set! (mus-cosines osc) 10)
			  0.0))
	      (if (fneq frq 440.0) (snd-display ";scs run frq: ~A" frq))
	      (if (fneq phs 0.0) (snd-display ";scs run phs: ~A" phs))
	      (if (not (= cs 3)) (snd-display ";scs run cs: ~A" cs))
	      (if (fneq (mus-frequency osc) 123.0) (snd-display ";scs run mus-frequency: ~A" (mus-frequency osc)))
	      (if (fneq (mus-phase osc) 1.0) (snd-display ";scs run mus-phase: ~A" (mus-phase osc)))
	      (if (not (= (mus-cosines osc) 10)) (snd-display ";scs run set cs: ~A" (mus-cosines 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 ";run 2zero->0.4: ~A" z1))
	      (if (fneq z2 .9) (snd-display ";run 2zero->0.9: ~A" z2))
	      (if (fneq z3 1.05) (snd-display ";run 2zero->1.05: ~A" z3))
	      (if (fneq p1 .4) (snd-display ";run a0->out 2pole: ~A" p1))
	      (if (fneq p2 -.08) (snd-display ";run a0->out 2pole (-0.08): ~A" p2))
	      (if (fneq p3 0.336) (snd-display ";run a0->out 2pole (0.336): ~A" p3)))
	    
	    (let ((flt (make-formant .1 1000.0))
		  (fa0 123.0)
		  (fa1 123.0)
		  (fa2 123.0)
		  (fb1 123.0)
		  (fb2 123.0)
		  (forder 123)
		  (fradius 123.0)
		  (v (make-vct 1)))
	      (vct-map! v
			(lambda ()
			  (set! fa0 (mus-xcoeff flt 0))
			  (set! fa1 (mus-xcoeff flt 1))
			  (set! fa2 (mus-xcoeff flt 2))
			  (set! fb1 (mus-ycoeff flt 1))
			  (set! fb2 (mus-ycoeff flt 2))
			  (set! forder (mus-order flt))
			  (set! fradius (mus-formant-radius flt))
			  (set! (mus-formant-radius flt) .3)
			  (set! (mus-xcoeff flt 0) .123)
			  (set! (mus-xcoeff flt 1) .123)
			  (set! (mus-xcoeff flt 2) .123)
			  (set! (mus-ycoeff flt 1) .123)
			  (set! (mus-ycoeff flt 2) .123)
			  0.0))
	      (if (fneq fa0 0.2783) (snd-display ";run fa0: ~A" fa0))
	      (if (fneq fa1 1.0) (snd-display ";run fa1: ~A" fa0))
	      (if (fneq fa2 -0.1) (snd-display ";run fa2: ~A" fa0))
	      (if (fneq fb1 -.192) (snd-display ";run fb1: ~A" fa0))
	      (if (fneq fb2 0.01) (snd-display ";run fb2: ~A" fa0))
	      (if (not (= forder 2)) (snd-display ";run formant order: ~A" forder))
	      (if (fneq fradius .1) (snd-display ";run formant radius: ~A" fradius))
	      (if (fneq (mus-a0 flt) .123) (snd-display ";run set mus-a0: ~A" (mus-a0 flt)))
	      (if (fneq (mus-a1 flt) .123) (snd-display ";run set mus-a1: ~A" (mus-a1 flt)))
	      (if (fneq (mus-a2 flt) .123) (snd-display ";run set mus-a2: ~A" (mus-a2 flt)))
	      (if (fneq (mus-b1 flt) .123) (snd-display ";run set mus-b1: ~A" (mus-b1 flt)))
	      (if (fneq (mus-b2 flt) .123) (snd-display ";run set mus-b2: ~A" (mus-b2 flt)))
	      (if (fneq (mus-formant-radius flt) .3) (snd-display ";run set mus-formant-radius: ~A" (mus-formant-radius flt))))
	    
	    (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 ";~A ~A" n tag))))
	       (list make-all-pass make-asymmetric-fm make-snd->sample make-average make-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-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines make-table-lookup make-triangle-wave
		     make-wave-train make-waveshape make-phase-vocoder make-ssb-am))
	      (close-sound ind))

	    (let ((frm (make-formant .1 440.0))
		  (v (make-vct 3)))
	      (vct-map! v (lambda ()
			    (mus-set-formant-radius-and-frequency frm 2.0 100.0)))
	      (if (fneq (mus-formant-radius frm) 2.0) (snd-display ";run set-formant-radius-etc: ~A" (mus-formant-radius frm)))
	      (if (fneq (mus-frequency frm) 100.0) (snd-display ";run set-formant-radius-etc (frq): ~A" (mus-frequency frm)))
	      (catch #t (lambda () (vct-map (lambda () (formant frm 1.0 2.0 3.0)) v)) (lambda args args)))
	    
	    (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 ";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 ";frame-set int opt: ~A" val)))
	    
	    (let ((val (run-eval '(let ((fr (make-frame 2 0.0 0.0)))
				    (frame-set! fr 0 (inexact->exact (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 ";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 (inexact->exact (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 ";mixer-set int opt: ~A" val)))
	    
	    (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 ";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 ";run locsig ref 0: ~A" d0))
	      (if (fneq d1 .333) (snd-display ";run locsig ref 1: ~A" d1))
	      (if (fneq dr .1) (snd-display ";run locsig reverb ref 0: ~A" dr))
	      (if (not (= cs 2)) (snd-display ";run mus-channels: ~A" cs))
	      (if (fneq d01 .167) (snd-display ";run locsig ref 01: ~A" d01))
	      (if (fneq d11 .333) (snd-display ";run locsig ref 11: ~A" d11))
	      (if (fneq dr1 .0707) (snd-display ";run locsig reverb ref 01: ~A" dr1))
	      (if (fneq (locsig-ref loc 0) .123) (snd-display ";run set loc 0: ~A" (locsig-ref loc 0)))	
	      (if (fneq (locsig-ref loc 1) .23) (snd-display ";run set loc 1: ~A" (locsig-ref loc 1)))	
	      (if (fneq (locsig-reverb-ref loc 0) .123) (snd-display ";run set loc rev 0: ~A" (locsig-reverb-ref loc 0)))
	      (mus-close rev))
	    
	    (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 ";run frame-set: ~A" vs))
	      (if (not fq) (snd-display ";run frame?"))
	      (if (not mq) (snd-display ";run mixer?"))
	      (if (fneq (frame-ref fr 0) .123) (snd-display ";run frame-ref: ~A" (frame-ref fr 0)))
	      (if (fneq (mixer-ref mx 0 1) .123) (snd-display ";run mixer-ref: ~A" (mixer-ref mx 0 1)))
	      (catch #t (lambda () (vct-map (lambda () (frame-ref fr 1 2 3)) v)) (lambda args args))
	      (catch #t (lambda () (vct-map (lambda () (mixer-ref mx 1 2 3 4)) v)) (lambda args args)))
	    
	    (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 ";run feedback: ~A" fb))
	      (if (not (= len 12)) (snd-display ";run mus-length: ~A" len))
	      (if (fneq (mus-feedback cmb) .123) (snd-display ";run set feedback: ~A" (mus-feedback cmb)))
	      (catch #t (lambda () (vct-map (lambda () (comb cmb 1.0 2.0 3.0)) v)) (lambda args args)))
	    
	    
	    (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 ";run feedforward: ~A" ff))
	      (if (fneq (mus-feedforward cmb) .321) (snd-display ";run set feedforward: ~A" (mus-feedforward cmb)))
	      (catch #t (lambda () (vct-map (lambda () (notch cmb 1.0 2.0 3.0)) v)) (lambda args args)))
	    
	    (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 ";run mus-name etc: ~A" res))
	      (catch #t (lambda () (vct-map (lambda () (oscil gen 0.0 1.0 1.0)) v)) (lambda args args)))
	    
	    (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 ";run rand/interp?"))
	      (if (not r1q) (snd-display ";run rand?"))
	      (if (not r2q) (snd-display ";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 ";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 ";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)))
	    
	    (let ((e (make-env '(0 0 1 1) :end 10))
		  (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))
			    (restart-env e)
			    (set! val0 (env e))
			    (env-interp .5 e)))
	      (if (not enq) (snd-display ";run env?"))
	      (if (not (= cs 2)) (snd-display ";run mus-location: ~A" cs))
	      (if (not (= ep 0)) (snd-display ";run mus-channels: ~A" ep))
	      (if (fneq b 1.0) (snd-display ";run mus-increment: ~A" b))
	      (if (fneq val8 0.8) (snd-display ";run set location: ~A" val8))
	      (if (fneq val0 0.0) (snd-display ";run restart-env: ~A" val0))
	      (if (fneq (vct-ref v 0) .5) (snd-display ";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 ";run mus-data: ~A ~A" d1 (mus-data flt)))
	      (if (fneq x1 .2) (snd-display ";run mus-xcoeffs: ~A ~A" x1 (mus-xcoeffs flt)))
	      (if (fneq y1 .5) (snd-display ";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 (not (= gr 1323)) (snd-display ";run ramp: ~A" gr))
	      (if (not (= gh 1102)) (snd-display ";run hop: ~A" gh))
	      (if (fneq gs 0.6) (snd-display ";run scaler: ~A" gs))
	      (if (fneq ge 2.0) (snd-display ";run gran exp: ~A" ge))
	      (if (fneq (mus-scaler grn) .321) (snd-display ";run set scl: ~A" (mus-scaler grn)))
	      (if (not (= (mus-hop grn) 1234)) (snd-display ";run set hop: ~A" (mus-hop grn)))
	      (if (not (= (mus-ramp grn) 321)) (snd-display ";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 ";run r->p not inverted: ~A" v))
	      (if (fneq val (sqrt 2.0)) (snd-display ";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 ";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 ";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 ";run frame* 0: ~A" (frame-ref fr3 0)))
	      (if (fneq (frame-ref fr3 1) .08) (snd-display ";run frame* 1: ~A" (frame-ref fr3 1)))
	      (if (fneq (frame-ref fr4 0) .4) (snd-display ";run frame+ 0: ~A" (frame-ref fr4 0)))
	      (if (fneq (frame-ref fr4 1) .6) (snd-display ";run frame+ 1: ~A" (frame-ref fr4 1)))
	      (if (fneq (vct-ref v 0) .11) (snd-display ";run frame->sample: ~A" (vct-ref v 0))))
	    
	    (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 ";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 ";run vct-convolve!: ~A ~A" v0 v1)))
	    
	    (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 ";run sine-bank: ~A?" (vct-ref v 0))))
	    
	    (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 ";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 gen fr0 fr1) (frame-ref fr1 1)))
	      (if (fneq (frame-ref fr1 1) 1.25) (snd-display ";run frame->frame: ~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 ";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 ";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 ";run impulse->flat (2)? ~A" rdat))))
	    
	    (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)
			    0.0))
	      (do ((i 0 (1+ i)))
		  ((= i 8)) 
		(if (fneq (vct-ref rdat i) 1.0)
		    (snd-display ";run impulse->flat (3)? ~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 ";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-scale mx1 2.0 mx2)))
	      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
		  (snd-display ";run mixer-scale 1: ~A" mx2)))

	    (let* ((mx1 (make-mixer 2 1 2 3 4))
		   (mx2 (run (lambda () (mixer-scale mx1 2.0)))))
	      (if (not (equal? mx2 (make-mixer 2 2 4 6 8)))
		  (snd-display ";run mixer-scale 2: ~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 ";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 ";run mus-output?"))
	      (if (not sq) (snd-display ";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-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 ";run mus-input?"))
	      (if (not fq) (snd-display ";run file->sample?"))
	      (if (not (vequal vals (vct .02 .2 .03 .3 .04 .4 .065 .65 .075 .75))) (snd-display ";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 ";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 ";run file->frame?"))
	      (if (fneq (vct-ref v 0) .004) (snd-display ";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-sample-reader 2000))
		    (v (make-vct 2)))
		(itst '(srate) 22050)
		(itst '(channels) 1)
		(itst '(frames) 50828)
		(if (not (= (run (lambda () (srate ind))) 22050))
		    (snd-display ";run srate ind: ~A" (run (lambda () (srate ind)))))
		(if (not (= (run (lambda () (channels ind))) 1))
		    (snd-display ";run channels ind: ~A" (run (lambda () (channels ind)))))
		(if (not (= (run (lambda () (frames ind 0))) 50828))
		    (snd-display ";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 ";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 ";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 ";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 ";read-sample apply ftst: ~A" v))
		(etst '(set! (sample 100) 0.0))
		)
	      (close-sound ind))
	    
	    (let ((ind (open-sound "oboe.snd")))
	      (let ((v (make-vct 2)))
		(ftst '(let ((r (make-sample-reader 1200.0))) (next-sample r)) 0.04898)
		(vct-map! v (let ((r (make-sample-reader 2000)))
			      (lambda () (next-sample r))))
		(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display ";next-sample let ftst: ~A" v))
		(vct-map! v (let ((r (make-sample-reader 2000 #f)))
			      (lambda () (next-sample r))))
		(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display ";next-sample let ftst #f: ~A" v))
		(vct-map! v (let ((r (make-sample-reader 2000 #f #f)))
			      (lambda () (next-sample r))))
		(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display ";next-sample let ftst #f #f: ~A" v))
		(vct-map! v (let ((r (make-sample-reader 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 ";next-sample let ftst #f #f 1 -1: ~A" v))
		(vct-map! v (let ((r (make-sample-reader 2000 ind)))
			      (lambda () (next-sample r))))
		(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display ";next-sample let snd ftst: ~A" v))
		(vct-map! v (let ((r (make-sample-reader 2000 ind 0)))
			      (lambda () (next-sample r))))
		(if (or (fneq (vct-ref v 0) .0662) (fneq (vct-ref v 1) .0551)) (snd-display ";next-sample let chn ftst: ~A" v))
		(vct-map! v (let ((r (make-sample-reader 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 ";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) .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))
		(let ((m (run-eval '(add-mark 100))))
		  (if (or (not (mark? m))
			  (not (= (mark-sample m) 100)))
		      (snd-display ";run add-mark: ~A" (and (mark? m) (mark-sample m)))))
		(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 ";y * 2 run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
	      (set! ts (cons (list "*2     " (hundred t0) (hundred t1) (inexact->exact (round (/ 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 ";y - 1 run: ~A ~A" (channel->vct 0 1000000 ind0) (channel->vct 0 1000000 ind1)))
	      (set! ts (cons (list "-1     " (hundred t0) (hundred t1) (inexact->exact (round (/ 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 ";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) (inexact->exact (round (/ 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 ";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) (inexact->exact (round (/ 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 ";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) (inexact->exact (round (/ 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) :end 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) :end 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 ";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) (inexact->exact (round (/ t0 t1)))) ts))
	      
	      (close-sound ind0)
	      (close-sound ind1)
	      (snd-display ";timings:~{~%       ~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 ";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 ";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 ";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 ";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 ";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 ";vct-map dbl-var .01: ~A ~A" v0 v1))))
	      )
	    
	    (let ((t0 0)
		  (t1 0)
		  (ts '()))
	      (set! (optimization) 0) 
	      (set! t0 (time-it (fm-violin-opt 0 5 440 .1)))
	      (set! (optimization) max-optimization) 
	      (set! t1 (time-it (fm-violin-opt 0 5 440 .1)))
	      (set! ts (cons (list "fm vln " (hundred t0) (hundred t1) (inexact->exact (round (/ 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 ";expsnd: opt: ~A ~A" v0 v1))
		(set! ts (cons (list "expsnd " (hundred t0) (hundred t1) (inexact->exact (round (/ t0 t1)))) ts))
		(undo 1 ind)
		(set! (optimization) 0) 
		(set! t0 (time-it (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 (jc-reverb 1.0 #f 1.0 #f)))
		(set! v1 (channel->vct 1000 100))
		(if (not (vequal v0 v1)) (snd-display ";jcrev: opt: ~A ~A" v0 v1))
		(set! ts (cons (list "jcrev  " (hundred t0) (hundred t1) (inexact->exact (round (/ t0 t1)))) ts))
		(close-sound ind))
	      (snd-display "~{       ~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-sample-reader 0 ind))
		   (mx (mix-vct (make-vct 10 .1) 100))
		   (trk (make-track))
		   (sd (make-sound-data 2 3))
		   (mxr (make-mix-sample-reader mx)))
	      (set! (mix-track mx) trk)
	      (let ((trkr (make-track-sample-reader trk)))
		(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 trkr) (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 '(1 . 2)) (display :hiho) (display 'asdf)
		       (call/cc (lambda (hiho) (if #f (hiho) (display hiho))))
		       (display svar)
		       (display #\newline) (display "---------------------------------------------------------------") (display #\newline)
		       )))
	      (if (defined? 'describe-walk-info)
		  (if (not (string? (describe-walk-info '*)))
		      (snd-display ";walk-info *: ~A" (describe-walk-info '*))))
	      (close-sound ind)))
	    
	    (let ((val (run-eval '(lambda () (fneq .1 .1)))))
	      (if val (snd-display ";embedded func 0: ~A" val)))
	    (let ((val (run-eval '(lambda () (fneq .1 .2)))))
	      (if (not val) (snd-display ";embedded func 1: ~A" val)))
	    (let ((val (run-eval '(lambda () (fneq .1 .1001)))))
	      (if val (snd-display ";embedded func 2: ~A" val)))
	    
	    (let ((val (run-eval '(fneq .1 .1))))
	      (if val (snd-display ";embedded func 3: ~A" val)))
	    (let ((val (run-eval '(fneq .1 .2))))
	      (if (not val) (snd-display ";embedded func 4: ~A" val)))
	    (let ((val (run-eval '(fneq .1 .1001))))
	      (if val (snd-display ";embedded func 5: ~A" val)))
	    
	    (define (efunc-1 arg) (+ arg 1))
	    (let ((val (run-eval '(efunc-1 1.5))))
	      (if (fneq val 2.5) (snd-display ";embedded func 6: ~A" val)))
	    (let ((val (run-eval '(+ 1.0 (efunc-1 1.5)))))
	      (if (fneq val 3.5) (snd-display ";embedded func 7: ~A" val)))
	    (let ((val (run-eval '(efunc-1 1))))
	      (if (not (= val 2)) (snd-display ";embedded func 8: ~A" val)))
	    (let ((val (run-eval '(* 2 (efunc-1 1)))))
	      (if (not (= val 4)) (snd-display ";embedded func 9: ~A" val)))
	    
	    (let ((val (run-eval '(if (fneq .1 .2) (* 2 (efunc-1 1)) -1))))
	      (if (not (= val 4)) (snd-display ";embedded func 10: ~A" val)))
	    
	    (define (efunc-2 arg) (not arg))
	    (let ((val (run-eval '(efunc-2 #f))))
	      (if (not val) (snd-display ";embedded func 11: ~A" val)))
	    (let ((val (run-eval '(if (efunc-2 (fneq .1 .1)) 0 1))))
	      (if (not (= val 0)) (snd-display ";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 ";embedded func 13: ~A" val)))
	    
	    (define (efunc-3 arg1 arg2 arg3) (if arg1 (+ arg2 arg3) 0))
	    (let ((val (run-eval '(efunc-3 (fneq .1 .2) 32 12))))
	      (if (not (= val 44)) (snd-display ";embedded func 14: ~A" val)))
	    
	    (define (efunc-4 arg) (string-append arg "!"))
	    (let ((val (run-eval '(efunc-4 "hi"))))
	      (if (not (string=? val "hi!")) (snd-display ";embedded func 15: ~A" val)))
	    (define (efunc-5 arg) (+ 1 (string-length arg)))
	    (let ((val (run-eval '(efunc-5 "hi"))))
	      (if (not (= val 3)) (snd-display ";embedded func 16: ~A" val)))
	    
	    (define (efunc-6 arg) (oscil arg))
	    (define efunc-gen (make-oscil 440.0))
	    (oscil efunc-gen)
	    (let ((val (run-eval '(efunc-6 efunc-gen))))
	      (if (fneq val .125) (snd-display ";embedded func 17: ~A" val)))
	    (define (efunc-7 arg) arg)
	    (let ((val (run-eval '(oscil (efunc-7 efunc-gen)))))
	      (if (fneq val .248) (snd-display ";embedded func 18: ~A" val)))
	    
	    (if with-gui
		(begin
	    (let* ((ind (open-sound "oboe.snd"))
		   (mx1 (mix-vct (vct 0.5 0.75 0.25) 100))
		   (val #f)
		   (trk (make-track)))
	      (set! (mix-track mx1) trk)
	      
	      (run (lambda () (set! val (mix-sample-reader? (make-mix-sample-reader mx1)))))
	      (if (not val) (snd-display ";mix-sample-reader?: ~A" val))
	      (run (lambda ()
		     (let ((a (make-mix-sample-reader mx1))) 
		       (set! val (and (eq? a a) (eqv? a a) (equal? a a))))))
	      (if (not val) (snd-display ";eq? make-mix-sample-reader 0: ~A" val))
	      (run (lambda ()
		     (let ((a (make-mix-sample-reader mx1))) 
		       (set! val (mix-sample-reader? a)))))
	      (if (not val) (snd-display ";reader? make-mix-sample-reader 0: ~A" val))
	      (run (lambda ()
		     (let ((a (make-mix-sample-reader mx1)) 
			   (b (make-mix-sample-reader mx1))) 
		       (set! val (or (eq? a b) (eqv? a b) (equal? a b))))))
	      (if val (snd-display ";eq? make-mix-sample-reader 1: ~A" val))
	      (run (lambda ()
		     (let ((a (make-mix-sample-reader mx1)) 
			   (b (make-sample-reader)))
		       (set! val (or (eq? a b) (eqv? a b) (equal? a b))))))
	      (if val (snd-display ";eq? make-mix-sample-reader 2: ~A" val))
	      
	      (let ((v (make-vct 3)))
		(vct-map! v (let ((r (make-mix-sample-reader mx1)))
			      (lambda () (read-mix-sample r))))
		(if (not (vequal v (vct 0.5 0.75 0.25))) (snd-display ";read-mix 0: ~A" v)))
	      
	      (let ((v (make-vct 2)))
		(vct-map! v (let ((r (make-mix-sample-reader mx1 1)))
			      (lambda () (read-mix-sample r))))
		(if (not (vequal v (vct 0.75 0.25))) (snd-display ";read-mix 1: ~A" v)))
	      
	      (let ((v (make-vct 2)))
		(vct-map! v (let ((r (make-mix-sample-reader mx1 1)))
			      (lambda () (r))))
		(if (not (vequal v (vct 0.75 0.25))) (snd-display ";read-mix 2: ~A" v)))
	      
	      (run (lambda () (set! val (track-sample-reader? (make-track-sample-reader trk)))))
	      (if (not val) (snd-display ";track-sample-reader?: ~A" val))
	      (run (lambda ()
		     (let ((a (make-track-sample-reader trk))) 
		       (set! val (and (eq? a a) (eqv? a a) (equal? a a))))))
	      (if (not val) (snd-display ";eq? make-track-sample-reader 0: ~A" val))
	      (run (lambda ()
		     (let ((a (make-track-sample-reader trk))) 
		       (set! val (track-sample-reader? a)))))
	      (if (not val) (snd-display ";reader? make-track-sample-reader 0: ~A" val))
	      (run (lambda ()
		     (let ((a (make-track-sample-reader trk)) 
			   (b (make-track-sample-reader trk))) 
		       (set! val (or (eq? a b) (eqv? a b) (equal? a b))))))
	      (if val (snd-display ";eq? make-track-sample-reader 1: ~A" val))
	      (run (lambda ()
		     (let ((a (make-track-sample-reader trk)) 
			   (b (make-sample-reader)))
		       (set! val (or (eq? a b) (eqv? a b) (equal? a b))))))
	      (if val (snd-display ";eq? make-track-sample-reader 2: ~A" val))
	      
	      (let ((v (make-vct 3)))
		(vct-map! v (let ((r (make-track-sample-reader trk 0)))
			      (lambda () (read-track-sample r))))
		(if (not (vequal v (vct 0.5 0.75 0.25))) (snd-display ";read-track 0: ~A" v)))
	      
	      (let ((v (make-vct 2)))
		(vct-map! v (let ((r (make-track-sample-reader trk 0 1)))
			      (lambda () (read-track-sample r))))
		(if (not (vequal v (vct 0.75 0.25))) (snd-display ";read-track 1: ~A" v)))
	      
	      (let ((v (make-vct 2)))
		(vct-map! v (let ((r (make-track-sample-reader trk 0 1)))
			      (lambda () (r))))
		(if (not (vequal v (vct 0.75 0.25))) (snd-display ";read-track 2: ~A" v)))
	      
	      (close-sound ind))))
	    
	    (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 ";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 ";run throw: ~A" val))
		(if (not (= outer 4)) (snd-display ";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 ";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 ";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 ";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 ";run embedded lambda rtn sound-data: ~A" val)))
	    (if with-gui
	    (let ((ind (open-sound "oboe.snd")))
	      (let ((val (run (lambda () 
				(let ((r (make-sample-reader 1000 ind 0))) 
				  (define (ho rd) (declare (rd sample-reader)) (next-sample rd)) 
				  (ho r))))))
		(if (fneq val (sample 1000)) (snd-display ";run embedded lambda arg sample-reader: ~A ~A" (sample 1000) val)))
	      (let ((val (run (lambda ()
				(define (ho) (make-sample-reader 1000 ind 0))
				(read-sample (ho))))))
		(if (fneq val (sample 1000)) (snd-display ";run embedded lambda rtn sample-reader: ~A ~A" (sample 1000) val)))
	      (let ((mix1 (mix-vct (make-vct 3 .1))))
		(let ((val (run (lambda () 
				  (let ((r (make-mix-sample-reader mix1))) 
				    (define (ho rd) (declare (rd mix-sample-reader)) (read-mix-sample rd)) 
				    (ho r))))))
		  (if (fneq val .1) (snd-display ";run embedded lambda arg mix-sample-reader: ~A" val)))
		(let ((val (run (lambda ()
				  (define (ho) (make-mix-sample-reader mix1))
				  (read-mix-sample (ho))))))
		  (if (fneq val .1) (snd-display ";run embedded lambda rtn mix-sample-reader: ~A" val)))
		(let ((trk (make-track)))
		  (set! (mix-track mix1) trk)
		  (let ((val (run (lambda () 
				    (let ((r (make-track-sample-reader trk))) 
				      (define (ho rd) (declare (rd track-sample-reader)) (read-track-sample rd))
				      (ho r))))))
		    (if (fneq val .1) (snd-display ";run embedded lambda arg track-sample-reader: ~A" val)))
		  (let ((val (run (lambda ()
				    (define (ho) (make-track-sample-reader trk))
				    (read-track-sample (ho))))))
		    (if (fneq val .1) (snd-display ";run embedded lambda rtn track-sample-reader: ~A" 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 ";run autocorrelate vct return?"))
		(if (not (vct? lrla)) (snd-display ";run lambda vct return: ~A?" lrla))
		(if (fneq (vct-ref val 0) 2.0) (snd-display ";run autocorrelate 0: ~A" (vct-ref lrla 0)))
		(if (fneq (vct-ref val 4) 1.0) (snd-display ";run autocorrelate 4: ~A" (vct-ref lrla 4)))))
	    
	    (define lfunc
	      (let ((ho 3))
		(lambda ()
		  ho)))
	    (let ((ho 123))
	      (let ((val (run-eval '(lambda () (lfunc)))))
		(if (not (= val 3)) (snd-display ";opt 6 case broken!: ~A" val))))

	    (define ivect (make-vector 3 1))
	    (let ((old-opt (optimization)))
	      (set! (optimization) 4) ; below global-set level
	      (run-eval '(set! int-var 4321))
	      (if (not (= int-var 4321)) (snd-display ";no global set, int: ~A" int-var))
	      (run-eval '(set! dbl-var 4321.5))
	      (if (fneq dbl-var 4321.5) (snd-display ";no global set, dbl: ~A" dbl-var))
	      (run-eval '(set! c-var #\f))
	      (if (not (char=? c-var #\f)) (snd-display ";no global set, char: ~A" c-var))
	      (run-eval '(set! bool-var #t))
	      (if (not bool-var) (snd-display ";no global set, bool: ~A" bool-var))
	      (run-eval '(set! str-var "hiha"))
	      (if (not (string=? str-var "hiha")) (snd-display ";no global set, str: ~A" str-var))
	      (run-eval '(vector-set! ivect 1 2))
	      (if (not (= (vector-ref ivect 1) 2)) (snd-display ";no global set, ivect: ~A" (vector-ref ivect 1)))
	      (set! (optimization) old-opt))
	    ))

      (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-no-gen gen (* .02 (oscil mg)))))) (lambda arg (display arg) arg))
	(close-sound ind))

      (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 ";unique-int (~A): ~A" n unique-int))
	   (if (fneq unique-float 1.5) (snd-display ";unique-float (~A): ~A" n unique-float))
	   (if (not (char=? unique-char #\z)) (snd-display ";unique-char (~A): ~A" n unique-char))
	   (if (not (string=? unique-string "a new string")) (snd-display ";unique-string (~A): ~A" n unique-string))
	   (if (not (= (vector-ref unique-int-vector 1) 6)) (snd-display ";unique-int-vector (~A): ~A" n unique-int-vector))
	   (if (fneq (vector-ref unique-float-vector 1) 3.0) (snd-display ";unique-float-vector (~A): ~A" n unique-float-vector))
	   (if unique-boolean (snd-display ";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" :hio)))) 
	(if (not (string=? val "#:hio")) 
	    (snd-display ";run format :hio: ~A" val)))
      (let ((val (run-eval '(format #f "~A" 'hiho))))
	(if (not (string=? val "hiho"))
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";run sample->file no file")
	  (let ((ind (open-sound "test.snd")))
	    (if (not (= (data-format ind) mus-lshort)) (snd-display ";run sample->file data format: ~A" (mus-data-format-name (data-format ind))))
	    (if (not (= (header-type ind) mus-riff)) (snd-display ";run sample->file header type: ~A" (mus-header-type-name (header-type ind))))
	    (if (not (= (frames ind) 1)) (snd-display ";run sample->file frames: ~A" (frames ind)))
	    (if (not (= (channels ind) 2)) (snd-display ";run sample->file chans: ~A" (channels ind)))
	    (if (fneq (sample 0 ind) 0.7) (snd-display ";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 ";run frame->file no file")
	  (let ((ind (open-sound "test.snd")))
	    (if (not (= (data-format ind) mus-bfloat)) (snd-display ";run frame->file data format: ~A" (mus-data-format-name (data-format ind))))
	    (if (not (= (header-type ind) mus-aifc)) (snd-display ";run frame->file header type: ~A" (mus-header-type-name (header-type ind))))
	    (if (not (= (frames ind) 1)) (snd-display ";run frame->file frames: ~A" (frames ind)))
	    (if (not (= (channels ind) 4)) (snd-display ";run frame->file chans: ~A" (channels ind)))
	    (if (fneq (sample 0 ind 0) 0.7) (snd-display ";run frame->file sample 0: ~A" (sample 0 ind 0)))
	    (if (fneq (sample 0 ind 1) 0.3) (snd-display ";run frame->file sample 1: ~A" (sample 0 ind 1)))
	    (if (fneq (sample 0 ind 2) 0.1) (snd-display ";run frame->file sample 2: ~A" (sample 0 ind 2)))
	    (if (fneq (sample 0 ind 3) 0.2) (snd-display ";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 ";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 ";run sound-data arg: ~A" val)))
      
      (if with-gui
      (let ((ind (open-sound "oboe.snd")))
	(let ((val (run-eval '(lambda (a) (declare (a sample-reader)) (read-sample a)) (make-sample-reader 1000))))
	  (if (fneq val .03283) (snd-display ";run arg sample-reader: ~A" val))
	  
	  (let ((mid (mix-vct (make-vct 10 .1) 10)))
	    (let ((val (run-eval '(lambda (a) (declare (a mix-sample-reader)) (read-mix-sample a)) (make-mix-sample-reader mid 0))))
	      (if (fneq val .1) (snd-display ";run mix-sample-reader arg: ~A" val)))
	    
	    (set! (mix-track mid) (make-track))
	    (let ((val (run-eval '(lambda (a) (declare (a track-sample-reader)) (read-track-sample a)) (make-track-sample-reader (mix-track mid) 0))))
	      (if (fneq val .1) (snd-display ";run track-sample-reader arg: ~A" val))))
	  (close-sound ind))))
      
      (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 ";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 ";run sample->frame no frame: ~A" val)))
      
      (show-ptree 2)
      (run (lambda () (oscil unique-generator)))
      (show-ptree 0)
      
      (let ((tag (catch #t 
			(lambda () 
			  (run-eval '(lambda (a) (declare (pair a)) (car a))  ; apparently deliberate
				    '(1 . 2))) 
			(lambda args (car args)))))
	(if (not (eq? tag 'cannot-parse)) (snd-display ";run declare backwards pair: ~A" tag)))
      (let ((tag (catch #t 
			(lambda () 
			  (run-eval '(lambda (a) (declare (a pairasd)) a)
				    '(1 . 2))) 
			(lambda args (car args)))))
	(if (not (eq? tag 'cannot-parse)) (snd-display ";run declare backwards pairasd: ~A" tag)))
      (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 ";run declare backwards sound-data: ~A" tag)))
      
      (let ((val (run-eval '(lambda (a) (declare (a pair)) a) '(1 . 2))))
	(if (not (equal? val '(1 . 2))) (snd-display ";run declare pair arg: ~A" val)))
      
      (let ((val (run-eval '(format #f "~A ~A" (+ 1 2) (* 3 4)))))
	(if (not (string=? val "3 12")) (snd-display ";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 ";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 ";run format ab #f: ~A" val)))
      (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 ";run format vector instead of vct: ~A (opt: ~A, max: ~A)" val (optimization) max-optimization)
		(snd-display ";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 ";run format ab #f l: ~A" val)))
      (let ((val (run (lambda () (format #f "~A ~A" (make-sound-data 1 1) (make-oscil))))))
	(if (not (string=? val "#<sound-data: 1 chan, 1 frame> #<oscil freq: 440.000Hz, phase: 0.000>"))
	    (snd-display ";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 ";run format 3 12 l: ~A" val)))
      
      (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 ";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 ";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 ";run case key ~A" tag)))
      
      (let ((tag (catch #t (lambda () (run-eval '(cadr unique-list))) (lambda args (car args)))))
	(if (not (eq? tag 'cannot-parse)) (snd-display ";run non-simple ~A" tag)))
      
      (let ((tag (catch #t (lambda ()
			     (run-eval '(lambda (a) 
					  (declare (a string)) a) 
				       2))
			(lambda args (car args)))))
	(if (not (eq? tag 'wrong-type-arg)) (snd-display ";run-eval bad arg: ~A" tag)))

      (let ((val (run (lambda () (let ((val (if (> 3 2) 123 "hi"))) val)))))
	(if (not (= val 123)) (snd-display ";run opt-if 123: ~A" val)))
      (let ((val (run-eval '(if (< 3 2) 123 "hi"))))
	(if (not (string=? val "hi")) (snd-display ";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: 1 chan, 1 frame>"))
	      (snd-display ";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: 1 chan, 1 frame>"))
	    (snd-display ";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: 1 chan, 1 frame>"))
	    (snd-display ";run format sound-data 2: ~A" val)))
      
      (let ((val (run-eval '(format #f "~A" (make-oscil)))))
	(if (not (string=? val "#<oscil freq: 440.000Hz, phase: 0.000>"))
	    (snd-display ";run format gen 0: ~A" val)))
      (let ((val (run (lambda () (format #f "~A" unique-generator)))))
	(if (not (string=? val "#<oscil freq: 440.000Hz, phase: 0.125>"))
	    (snd-display ";run format gen 1: ~A" val)))
      (let ((val (run-eval '(format #f "~A" unique-generator))))
	(if (not (string=? val "#<oscil freq: 440.000Hz, phase: 0.125>"))
	    (snd-display ";run format gen 2: ~A" val)))
      
      (let ((make-procs (list
			 make-all-pass make-asymmetric-fm make-average
			 make-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-ppolar
			 make-pulse-train make-rand make-rand-interp make-sawtooth-wave
			 make-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines make-table-lookup make-triangle-wave
			 make-two-pole make-two-zero make-wave-train make-waveshape make-zpolar make-phase-vocoder make-ssb-am
			 (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)))))
	     (gc)
	     (if (not (string=? val1 val2))
		 (snd-display ";run format gen: ~A ~A" val1 val2))))
	 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))))
	(gc)
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";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 ))))
	(gc)
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-average))))
	    (val2 (run (lambda () (let ((gen (make-average))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-average))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-ppolar))))
	    (val2 (run (lambda () (let ((gen (make-ppolar))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-ppolar))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";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 ";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 ";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 ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-sine-summation ))))
	    (val2 (run (lambda () (let ((gen (make-sine-summation ))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-sine-summation ))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";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 ";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 ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-sum-of-cosines ))))
	    (val2 (run (lambda () (let ((gen (make-sum-of-cosines ))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-sum-of-cosines ))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-sum-of-sines ))))
	    (val2 (run (lambda () (let ((gen (make-sum-of-sines ))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-sum-of-sines ))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";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 ";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 ";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 ";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 ";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 ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-waveshape ))))
	    (val2 (run (lambda () (let ((gen (make-waveshape ))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-waveshape ))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val1 (run-eval '(format #f "~A" (make-zpolar ))))
	    (val2 (run (lambda () (let ((gen (make-zpolar ))) (format #f "~A" gen)))))
	    (val3 (format #f "~A" (make-zpolar ))))
	(if (or (not (string=? val1 val2))
		(not (string=? val2 val3)))
	    (snd-display ";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 ";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 ";run-eval format: ~A ~A ~A" val1 val2 val3)))
      
      (let ((val (run-eval '(format #f "~A" unique-symbol))))
	(if (not (string=? val "hiho")) (snd-display ";run format symbol: ~A" val)))
      (let ((val (run-eval '(symbol? unique-symbol))))
	(if (not val) (snd-display ";run-eval symbol? global?")))
      (let ((val (run (lambda () (symbol? unique-symbol)))))
	(if (not val) (snd-display ";run symbol? global?")))
      (let ((val (run (lambda () (eq? unique-symbol :hiho)))))
	(if val (snd-display ";run :hiho is a symbol?")))
      (let ((val (run (lambda () (eq? unique-symbol 'hiho)))))
	(if (not val) (snd-display ";run eq? symbol 'hiho?")))
      (let ((val (run-eval '(format #f "~A" unique-keyword))))
	(if (not (string=? val "#:hiho")) (snd-display ";run format keyword: ~A" val)))
      (let ((val (run-eval '(symbol? unique-keyword))))
	(if val (snd-display ";run symbol? of keyword")))
      (let ((val (run-eval '(keyword? unique-keyword))))
	(if (not val) (snd-display ";run keyword? of keyword?")))
      (let ((val (run (lambda () (eq? unique-keyword :hiho)))))
	(if (not val) (snd-display ";run eq? of :hiho?")))
      (let ((val (run (lambda () (eq? unique-keyword 0)))))
	(if val (snd-display ";run eq? key 0?")))
      (let ((tag (catch #t (lambda () (run-eval '(cond ((= 1 2) 3) ((+ 2 3) 4)))) (lambda args (car args)))))
	(if (not (eq? tag 'cannot-parse)) (snd-display ";run bad cond: ~A" tag)))
      (let ((tag (catch #t (lambda () (run-eval '(let ((a 3)) (set! a (current-module))))) (lambda args (car args)))))
	(if (not (eq? tag 'cannot-parse)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";run local return symbol: ~A" val)))
      
      (let ((val (run (lambda () (let* ((a 1) (b (if (odd? a) :hi :ho))) (format #f "b: ~A" b))))))
	(if (not (equal? val "b: #:hi")) (snd-display ";run b1 ~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 ";run b2 ~A:" val)))
      (let ((val (run (lambda () (let* ((a 1) (b :hi)) (equal? b :hi))))))
	(if (not (equal? val #t)) (snd-display ";run b3 ~A:" val)))
      (let ((val (run-eval '(let* ((a 1) (b :hi)) b))))
	(if (not (equal? val :hi)) (snd-display ";run b4 ~A:" val)))
      (let ((val (run-eval '(let* ((a 1) (b 'ho)) b))))
	(if (not (equal? val 'ho)) (snd-display ";run b5 ~A:" val)))
      (let ((val (run (lambda () (let* ((a 1)) (if (odd? a) :hi :ho))))))
	(if (not (equal? val :hi)) (snd-display ";run b6 ~A:" val)))
      (let ((val (run (lambda () (let* ((a 1)) (if (odd? a) 'hi 'ho))))))
	(if (not (equal? val 'hi)) (snd-display ";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 ";run b8 ~A:" val)))
      (let ((val (run (lambda () (let* ((a 1)) (begin :hi))))))
	(if (not (equal? val :hi)) (snd-display ";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 ";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 ";run b11 ~A:" val)))
      (let ((val (run (lambda () (let* ((a 1)) (or (= a 0) :hi))))))
	(if (not (equal? val :hi)) (snd-display ";run b12 ~A:" val)))
      (let ((val (run (lambda () (let* ((a 1)) (and (= a 1) 'hi))))))
	(if (not (equal? val 'hi)) (snd-display ";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 ";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 ";run b15 ~A:" val)))
      (let ((val (run-eval '(if #t :hi))))
	(if (not (equal? val :hi)) (snd-display ";run b16 ~A:" val)))
      (let ((val (run-eval '(if #f :hi :ho))))
	(if (not (equal? val :ho)) (snd-display ";run b17 ~A:" val)))
      (let ((val (run-eval '(let ((a (let ((b :hi)) b))) a))))
	(if (not (equal? val :hi)) (snd-display ";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 ";run b19 ~A:" val)))
      (let ((val (run-eval '(let ((a 1) (b :hi)) (if #t b :ho)))))
	(if (not (equal? val :hi)) (snd-display ";run b20 ~A:" val)))
      (let ((val (run-eval '(let ((a #\a)) (if (char? a) a)))))
	(if (not (equal? val #\a)) (snd-display ";run b21 ~A:" val)))
      (let ((val (run-eval '(let ((a #\a)) (if (number? a) a)))))
	(if (not (equal? val #f)) (snd-display ";run b22 ~A:" val)))
      (let ((val (run-eval '(let ((a #\a)) (if (char? a) '(1 . 2))))))
	(if (not (equal? val '(1 . 2))) (snd-display ";run b23 ~A:" val)))
      (let ((val (run-eval '(let ((a #\a)) (if (char? a) '(1 2))))))
	(if (not (equal? val '(1 2))) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";run b30 ~A" val)))
      (let ((val (run-eval '(begin (case 0 ((0) -1) ((1) 0) (else -2)) 2))))
	(if (not (= val 2)) (snd-display ";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 ";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 ";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 ";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 ";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 ";run b36 ~A" val)))
      
      (let ((val (run-eval '(make-oscil 440.0))))
	(if (not (oscil? val)) (snd-display ";run -> gen: ~A" val)))
      (let ((val (run-eval '(let ((a 1)) (if (odd? a) (make-oscil))))))
	(if (not (oscil? val)) (snd-display ";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 ";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 ";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 ";run b39 ~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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";set let 10: ~A" val)))

      (let ((tag (catch #t (lambda () (run-eval '(let ((a 0)) (set! a (or 1 3)) a))) (lambda args (car args)))))
	(if (not (equal? tag 'cannot-parse)) (snd-display ";set or not bool: ~A" tag)))
      (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 ";set and not bool: ~A" tag)))
      (let ((tag (catch #t (lambda ()(run-eval '(if 1 2 3))) (lambda args (car args)))))
	(if (not (equal? tag 'cannot-parse)) (snd-display ";if not bool: ~A" tag)))
      
      (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 ";mus-data -> vct opt: ~A" val)))
      
      (set! (run-safety) 1)
      (let ((val (catch #t (lambda () (run-eval '(lambda () (let ((os (make-oscil))) (oscil #f))))) (lambda args (car args)))))
	(if (not (equal? val 'mus-error)) (snd-display ";run-safety #f osc: ~A" val)))
      (let ((val (catch #t (lambda () (run-eval '(lambda () (let ((os (make-oscil)) (ts (make-table-lookup))) (oscil ts))))) (lambda args (car args)))))
	(if (not (equal? val 'mus-error)) (snd-display ";run-safety tbl osc: ~A" val)))
      (fm-violin-opt 0 .01 440 .1)
      (set! (run-safety) 0)

      (run-hook after-test-hook 22)
      ))


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

(if (not (provided? 'snd-prc95.scm)) (load "prc95.scm"))
(if (not (provided? 'snd-v.scm)) (load "v.scm"))
(if (not (provided? 'snd-jcrev.scm)) (load "jcrev.scm")) ; redefines jc-reverb (different from examp.scm version used above)
(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-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"))

(define old-opt-23 (optimization))
(set! (optimization) max-optimization)

(define (make-cndf n freq)
  (let ((amps (make-vct (1- n) 0.0))
	(oscs (make-vector (1- n) #f))
	(r 1))
    (do ((i 1 (1+ i)))
	((= i n))
      (vct-set! amps (1- i) (/ 1.0 r))
      (vector-set! oscs (1- i) (make-oscil (* freq r r)))
      (set! r (* r (1+ i))))
    (list amps oscs)))

(define (cndf gen)
  (oscil-bank (car gen) (cadr gen)))

(define (cndf-ins beg dur amp freq n)
  (let* ((start (inexact->exact (floor (* beg (mus-srate)))))
	 (end (+ start (inexact->exact (floor (* dur (mus-srate))))))
	 (gen (make-cndf n freq)))
    (run
     (lambda ()
       (do ((i start (1+ i))) 
	   ((= i end))
	 (out-any i (* amp (cndf gen)) 0 *output*))))))

;(with-sound () (cndf-ins 0 1 .1 40.0 6))

(define (ws-sine freq)
  (let ((o (make-oscil freq)))
    (run
     (lambda ()
       (do ((i 0 (1+ i)))
	   ((= i 100))
	 (outa i (oscil o) *output*))))))

(define (step-src)
  (let* ((rd (make-sample-reader 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)
		     (run (lambda ()
			    (do ((samp 0 (1+ samp)))
				((or (c-g?) 
				     (sample-reader-at-end? rd)))
			      (out-any samp 
				       (src s incr (lambda (dir) (read-sample rd)))
				       0 *output*)
			      (if (= (modulo samp 2205) 0)
				  (set! incr (+ 2.0 (oscil o)))))))))
	 (len (mus-sound-frames tempfile)))
    (set-samples 0 (1- len) 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 ";with-mix (~A) init: no test.snd?" num))
    (if (and chkmx (fneq (maxamp ind) amp)) (snd-display ";with-mix (~A) maxamp: ~A (~A)" num (maxamp ind) amp))
    (if (not (file-exists? "with-mix.snd")) (snd-display ";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 ";with-mix (~A) dur: ~A ~A" num dur duration))
      (if (fneq total-dur (/ (frames ind) (srate ind))) 
	  (snd-display ";with-mix (~A) total dur: ~A ~A" num total-dur (/ (frames ind) (srate ind))))
      (if (and old-date
	       (> (abs (- date old-date)) 1)) ; these can be off by one in Linux
	  (snd-display ";with-mix (~A) rewrote output?: ~A ~A" num 
		       (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 ";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 ";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 ";with-mix (~A) comment: ~A -> ~A" num header-str header))
	  (if (or (not (string=? (car header) opts))
		  (not (string=? (cadr header) calls)))
	      (snd-display ";with-mix (~A) header values: ~A" num header))))
      (close-sound ind)
      date)))

(def-optkey-fun (optkey-1 a) a)
(def-optkey-fun (optkey-2 (a 3) b) (list a b))
(def-optkey-fun (optkey-3 a b c) (list a b c))
(def-optkey-fun (optkey-4 (a 1) (b 2) (c 3) d) (list a b c d))

(if (or full-test (= snd-test 23) (and keep-going (<= snd-test 23)))
    (begin
      (def-clm-struct st1 one two)
      (def-clm-struct st2 (one 11) (two 22))
      (run-hook before-test-hook 23)

      (do ((clmtest 0 (1+ clmtest))) ((= clmtest tests)) 
	(log-mem clmtest)

      (set! (mus-srate) 22050)
      (set! (default-output-srate) 22050)
      
      (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 ";with-sound: ~A" (map file-name (sounds))))
	    (let ((mx (maxamp)))
	      (if (fneq mx .1) (snd-display ";with-sound max: ~A" (maxamp)))
	      (if (not (= (srate ind) 22050)) (snd-display ";with-sound srate: ~A (~A, ~A)" 
							   (srate ind) (mus-srate) (mus-sound-srate "test.snd")))
	      (if (not (= (frames ind) 2205)) (snd-display ";with-sound frames: ~A" (frames ind))))
	    (play-and-wait 0 ind)))
	(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 ";with-sound continued: ~A" (map file-name (sounds))))
	(if (not (= (length (sounds)) 1)) (snd-display ";with-sound continued: ~{~A ~}" (map short-file-name (sounds))))
	(let ((mx (maxamp)))
	  (if (fneq mx .25) (snd-display ";with-sound continued max: ~A" (maxamp)))
	  (if (not (= (srate ind) 22050)) (snd-display ";with-sound continued srate: ~A (~A, ~A)" 
						       (srate ind) (mus-srate) (mus-sound-srate "test.snd")))
	  (if (not (= (frames ind) (* 3 2205))) (snd-display ";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 ";maxamp after continued sound: ~A" (maxamp ind 0)))
	(if (fneq (/ (frames ind) (srate ind)) .3) (snd-display ";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 ";with-sound (1): ~A" (map file-name (sounds))))
	(let ((mx (maxamp)))
	  (if (fneq mx .05) (snd-display ";with-sound max (1): ~A" (maxamp)))
	  (if (not (= (srate ind) 22050)) (snd-display ";with-sound srate (1): ~A (~A, ~A)" 
						       (srate ind) (mus-srate) (mus-sound-srate "test.snd")))
	  (if (not (= (frames ind) 2205)) (snd-display ";with-sound frames (1): ~A" (frames ind)))
	  (if (not (= (chans ind) 2)) (snd-display ";with-sound chans (1): ~A" (chans ind))))
	(close-sound ind)
	(delete-file "test1.snd"))
      
      (with-sound (:srate 22050 :channels 2 :output "test1.snd" :reverb jc-reverb) (fm-violin 0 .1 440 .1 :degree 45.0))
      (let ((ind (find-sound "test1.snd")))
	(if (not ind) (snd-display ";with-sound (2): ~A" (map file-name (sounds))))
	(if (not (= (frames ind) (+ 22050 2205))) (snd-display ";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 ";with-sound (3): ~A" (map file-name (sounds))))
	(if (not (= (frames ind) (+ 22050 2205))) (snd-display ";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 ";with-sound: ~A" (map file-name (sounds))))
	(let ((mx (maxamp)))
	  (if (fneq mx .5) (snd-display ";with-sound scaled-to: ~A" (maxamp)))
	  (if (not (string=? (comment ind) "Snd+Run!")) (snd-display ";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 ";with-sound: ~A" (map file-name (sounds))))
	(let ((mx (maxamp)))
	  (if (fneq mx .05) (snd-display ";with-sound scaled-by: ~A" (maxamp)))
	  (if (not (= (header-type ind) mus-aifc)) (snd-display ";with-sound type: ~A (~A)" (header-type ind) (mus-header-type-name (header-type ind))))
	  (if (not (= (data-format ind) mus-bfloat)) (snd-display ";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 ";with-sound (raw out): ~A" (map file-name (sounds))))
	(if (not (= (header-type ind) mus-raw)) (snd-display ";with-sound type raw: ~A (~A)" (header-type ind) (mus-header-type-name (header-type ind))))
	(if (not (= (data-format ind) mus-bshort)) (snd-display ";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))
      
      (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 ";st1-one: ~A" (st1-one var)))
	(if (not (= (st1-two var) 2)) (snd-display ";st1-two: ~A" (st1-two var)))
	(if (not (st1? var)) (snd-display ";st1? ~A (~A)" (st1? var) var))
	(set! (st1-one var) 321)
	(set! (st1-two var) "hiho")
	(if (not (= (st1-one var) 321)) (snd-display ";st1-one (321): ~A" (st1-one var)))
	(if (not (string=? (st1-two var) "hiho")) (snd-display ";st1-two (hiho): ~A" (st1-two var)))
	(set! var (make-st1))
	(if (not (eq? (st1-one var) #f)) (snd-display ";st1-one #f: ~A" (st1-one var)))
	(if (st1-two var) (snd-display ";st1-two #f: ~A" (st1-two var)))
	(set! var (make-st1 :two 3))
	(if (not (eq? (st1-one var) #f)) (snd-display ";st1-one #f (def): ~A" (st1-one var)))  
	(if (not (= (st1-two var) 3)) (snd-display ";st1-two (3): ~A" (st1-two var))))

      (let ((var (make-st2 :one 1 :two 2)))
	(if (not (= (st2-one var) 1)) (snd-display ";st2-one: ~A" (st2-one var)))
	(if (not (= (st2-two var) 2)) (snd-display ";st2-two: ~A" (st2-two var)))
	(if (not (st2? var)) (snd-display ";st2? ~A (~A)" (st1? var) var))
	(if (st1? var) (snd-display ";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 ";st2-one (321): ~A" (st2-one var)))
	(if (not (string=? (st2-two var) "hiho")) (snd-display ";st2-two (hiho): ~A" (st2-two var)))
	(set! var (make-st2))
	(if (not (= (st2-one var) 11)) (snd-display ";st2-one 11: ~A" (st2-one var)))
	(if (not (= (st2-two var) 22)) (snd-display ";st2-two 22: ~A" (st2-two var)))
	(set! var (make-st2 :two 3))
	(if (not (= (st2-one var) 11)) (snd-display ";st2-one 11 (def): ~A" (st2-one var)))  
	(if (not (= (st2-two var) 3)) (snd-display ";st2-two (3): ~A" (st2-two var))))
      
      (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 ";with-sound returns: ~A" outer))
	(let ((ind (find-sound outer)))
	  (if (or (not (sound? ind))
		  (not (= (frames ind) (inexact->exact (floor (* (mus-srate) .1))))))
	      (snd-display ";sound-let: ~A ~A" (frames ind) (inexact->exact (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 ";with-sound (2) returns: ~A" outer))
	(let ((ind (find-sound outer)))
	  (if (or (not (sound? ind))
		  (not (= (frames ind) (+ 100 (inexact->exact (floor (* (mus-srate) .1)))))))
	      (snd-display ";sound-let (2): ~A ~A" (frames ind) (+ 100 (floor (inexact->exact (* (mus-srate) .1))))))
	  (if (file-exists? "temp.snd")
	      (snd-display ";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 ";finish-with-sound returns: ~A" outer))
	  (let ((ind (find-sound outer)))
	    (if (not (sound? ind))
		(snd-display ";init-with-sound: ~A" (map short-file-name (sounds)))
		(begin
		  (if (fneq (maxamp ind 0) .1)
		      (snd-display ";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 ";finish-with-sound (2) returns: ~A ~A" outer w))
	  (let ((ind (find-sound outer)))
	    (if (not (sound? ind))
		(snd-display ";init-with-sound (2): ~A" (map short-file-name (sounds)))
		(begin
		  (if (fneq (maxamp ind 0) .5)
		      (snd-display ";init-with-sound scaled-to: ~A ~A" (maxamp ind 0) w))
		  (if (not (= (header-type ind) mus-aifc))
		      (snd-display ";init-with-sound type: ~A ~A" (header-type ind) w))
		  (close-sound ind))))))
      
      (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-and-wait 0 ind)
	(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))
		  (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)
		  
		  (graphEq "oboe.snd")
		  )
      (let ((ind (find-sound "test.snd")))
	(if (or (not (vequal (channel->vct 45 10) (vct -0.068 -0.059 -0.045 -0.028 -0.011 0.005 0.018 0.028 0.035 0.039)))
		(not (vequal (channel->vct 210 10) (vct 0.015 0.014 0.013 0.011 0.009 0.007 0.005 0.003 0.001 0.000))))
	    (snd-display ";fm-violin with-sound: ~A ~A" (channel->vct 45 10) (channel->vct 210 10)))
	(play-and-wait ind)
	(close-sound ind))

      (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 ";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 ";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 ";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 ";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 ";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 ";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 ";4->2(2) fullmix: ~A" mxs))
	(close-sound ind))

      (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 ";with-sound+sound-lets init: no test.snd?"))
	(if (or (> (maxamp ind) .2) (< (maxamp ind) .15))  (snd-display ";with-mix+sound-lets maxamp: ~A" (maxamp ind)))
	(if (fneq 3.0 (/ (frames ind) (srate ind))) (snd-display ";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 ";with-mix stereo: ~A" (maxamp ind #t)))
	(if (not (= (mus-sound-chans "with-mix.snd") 2)) (snd-display ";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 ";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 ";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 ";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 ";notch-channel 60 hz 2: ~A" (maxamp)))
	  (undo)
	  (select-all)
	  (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 ";notch-selection 60 hz 2: ~A" (maxamp)))

	  (play-sound
	   (lambda (data)
	     (let ((len (sound-data-length data)))
	       (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 ";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)))

      (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 ";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 ";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 ";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 ";auto-delete insert-samples?"))
	(undo 1 ind)
	(delete-sample 100)
	(if (file-exists? "test4.snd") (snd-display ";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 ";auto-delete mix (with-tag)?")))
      )        
      (let ((o2 (optkey-1 1)))
	(if (not (equal? o2 1)) (snd-display ";optkey-1: ~A" o2)))
      (let ((o2 (optkey-1 :a 1)))
	(if (not (equal? o2 1)) (snd-display ";optkey-1 1: ~A" o2)))
      (let ((o2 (optkey-1)))
	(if (not (equal? o2 #f)) (snd-display ";optkey-1 2: ~A" o2)))
      (let ((o2 (optkey-2 1 2)))
	(if (not (equal? o2 (list 1 2))) (snd-display ";optkey-2: ~A" o2)))
      (let ((o2 (optkey-2 :a 1 :b 2)))
	(if (not (equal? o2 (list 1 2))) (snd-display ";optkey-2 1: ~A" o2)))
      (let ((o2 (optkey-2)))
	(if (not (equal? o2 (list 3 #f))) (snd-display ";optkey-2 2: ~A" o2)))
      (let ((o2 (optkey-2 1 :b 2)))
	(if (not (equal? o2 (list 1 2))) (snd-display ";optkey-2 3: ~A" o2)))
      (let ((o2 (optkey-3 1 2 3)))
	(if (not (equal? o2 (list 1 2 3))) (snd-display ";optkey-3: ~A" o2)))
      (let ((o2 (optkey-3 1 :b 2 :c 3)))
	(if (not (equal? o2 (list 1 2 3))) (snd-display ";optkey-3 1: ~A" o2)))
      (let ((o2 (optkey-3 1 2 :c 3)))
	(if (not (equal? o2 (list 1 2 3))) (snd-display ";optkey-3 2: ~A" o2)))
      (let ((o2 (optkey-4)))
	(if (not (equal? o2 (list 1 2 3 #f))) (snd-display ";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 ";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 ";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 ";optkey-4 3: ~A 2" o2)))
      
      (if (and (provided? 'snd-motif)
	       (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))
	    (XtUnmanageChild variables-dialog)))

      (if (not (= *clm-srate* (default-output-srate))) (snd-display ";*clm-srate*: ~A ~A" *clm-srate* (default-output-srate)))
      (if (not (= *clm-channels* (default-output-chans))) (snd-display ";*clm-channels*: ~A ~A" *clm-channels* (default-output-channels)))
      (if (not (= *clm-header-type* (default-output-type))) (snd-display ";*clm-header-type*: ~A ~A" *clm-header-type* (default-output-type)))
      (if (not (= *clm-data-format* (default-output-format))) (snd-display ";*clm-data-format*: ~A ~A" *clm-data-format* (default-output-format)))
      (if (not (= *clm-reverb-channels* 1)) (snd-display ";*clm-reverb-channels*: ~A ~A" *clm-reverb-channels*))
      (if (not (string=? *clm-file-name* "test.snd")) (snd-display ";*clm-file-name*: ~A" *clm-file-name*))
      (if *clm-play* (snd-display ";*clm-play*: ~A" *clm-play*))
      (if *clm-verbose* (snd-display ";*clm-verbose*: ~A" *clm-verbose*))
      (if *clm-statistics* (snd-display ";*clm-statistics*: ~A" *clm-statistics*))
      (if *clm-reverb* (snd-display ";*clm-reverb*: ~A" *clm-reverb*))
      (if (not (null? *clm-reverb-data*)) (snd-display ";*clm-reverb-data*: ~A?" *clm-reverb-data*))
      (if *clm-delete-reverb* (snd-display ";*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* '(#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 ";default output in ws: ~A" (map file-name (sounds)))
	    (begin
	      (if (not (= (srate ind) 44100)) (snd-display ";default srate in ws: ~A ~A" (srate ind) *clm-srate*))
	      (if (not (= (channels ind) 2)) (snd-display ";default chans in ws: ~A ~A" (channels ind) *clm-channels*))
	      (if (not (= (data-format ind) mus-mulaw)) (snd-display ";default format in ws: ~A ~A" (data-format ind) *clm-data-format*))
	      (if (not (= (header-type ind) mus-riff)) (snd-display ";default type in ws: ~A ~A" (header-type ind) *clm-header-type*))
	      (if (not (= (frames ind) 88200)) (snd-display ";reverb+1 sec out in ws: ~A" (frames ind)))
	      (if (file-exists? "test.rev") (snd-display ";perhaps reverb not deleted in ws?"))
	      (close-sound ind))))
      
      (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 (let ((e (make-env '(0 0 1 1) :end (1- (frames ind)))))
				  (lambda () 
				    (env e)))
				0.05
				(lambda () (* (mus-srate) 0.05))))
	       (reader0 (make-sample-reader 0 ind 0))
	       (reader1 (make-sample-reader 0 ind1 0)))
	  (zip-sound 3 1 "fyow.snd" "now.snd" '(0 0 1 1) .05)
	  (zip-sound 4 3 "mb.snd" "fyow.snd" '(0 0 1.0 0 1.5 1.0 3.0 1.0) .025)
	  (map-channel (lambda (val) (zipper zp reader0 reader1)))
	  (close-sound ind)
	  (close-sound ind1))
	)
      (let* ((ind (open-sound "oboe.snd"))
	     (pv (make-pvocoder 256 4 64))
	     (rd (make-sample-reader 0)))
	(map-channel (lambda (y) (pvocoder pv rd)))
	(close-sound ind))

      (make-birds)
      (map close-sound (sounds))

      (set! (run-safety) 1)
      (with-sound ()
		  (simple-ssb 0 .2 440 .1)
		  (simple-sos .25 .2 .1)
		  (simple-soc 0.5 .2 440 .1)
		  (simple-osc 0.75 .2 440 .1)
		  (simple-sss 1.0 .2 .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)
		  (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-wav 4.0 .2 440.0 .1)
		  (simple-dly 4.75 .2 440.0 .1)
		  (simple-cmb 5.0 .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-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-out 20.25 .2 440 .1)		  
		  (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"))
    
      (with-sound ()
		  (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)
		  (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)
		  (cndf-ins 7 .2 .1 40.0 6)
		  (sample-pvoc5 7.25 .2 .1 256 "oboe.snd" 440.0)
		  )
      (set! (run-safety) 0)

      (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 ";pvoc a-e: ~A" mx)))

      (let* ((file (with-sound (:clipped #f :data-format mus-bfloat :header-type mus-next)
			       (fm-violin 0 .1 440 3.14159)))
	     (ind (find-sound file))
	     (mx (maxamp ind)))
	(if (fneq mx 3.14159) (snd-display ";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 3.14159)))
	(set! ind (find-sound file))
	(set! mx (maxamp ind))
	(if (fneq mx 1.0) (snd-display ";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 3.14159)))
	(set! ind (find-sound file))
	(set! mx (maxamp ind))
	(if (fneq mx .314159) (snd-display ";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 3.14159)))
	(set! ind (find-sound file))
	(set! mx (maxamp ind))
	(if (fneq mx .1) (snd-display ";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 ";*clm-file-buffer-size*: ~A" mx))
	    (if (not (= tsize 256)) (snd-display ";*clm-table-size*: ~A" tsize))
	    (if (not (= arrp 123)) (snd-display ";*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 ";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 ";update ws bounds: ~A" (x-bounds ind)))
	(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 ";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 ";step-src frames: ~A (~A)" (frames) (edits)))
	(close-sound ind))
      
      (if (not (null? (sounds))) (for-each close-sound (sounds)))
      
      (run-hook after-test-hook 23)
      ))
(set! (optimization) old-opt-23)

(gc)
(if (defined? 'mem-report) (mem-report))
(if (file-exists? "memlog")
    (system "mv memlog memlog.23")) ; save pre-error version


;;; ---------------- test 24: user-interface ----------------

(if (not (provided? 'snd-peak-env.scm)) 
    (begin
      (load "peak-env.scm")
      (if (hook-empty? initial-graph-hook) (snd-display ";restore peaks failed?"))))

(define (enved-x ux) 
  (let* ((axis (enved-axis-info))
	 (axis-x0 (list-ref axis 0))
	 (axis-x1 (list-ref axis 2))
	 (x (if (> ux 1.0) (/ ux 100.0) ux))
	 (val (inexact->exact (floor (+ axis-x0 (* x (- axis-x1 axis-x0)))))))
    val))
(define (enved-y y) 
  (let* ((axis (enved-axis-info))
	 (axis-y0 (list-ref axis 1))
	 (axis-y1 (list-ref axis 3)))
    (inexact->exact (floor (- axis-y0 (* y (- axis-y0 axis-y1)))))))

(define (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))))))

(set! (previous-files-sort-procedure) #f)

(define* (widget-string widget text #:optional (cleared #t))
  (define (shifted? ch)
    (if (or (and (char>=? ch #\A) (char<=? ch #\Z))
	    (char=? ch #\!) (char=? ch #\@) (char=? ch #\#) (char=? ch #\$) (char=? ch #\%) 
	    (char=? ch #\^) (char=? ch #\&) (char=? ch #\*) (char=? ch #\() (char=? ch #\)) 
	    (char=? ch #\_) (char=? ch #\+) (char=? ch #\:) (char=? ch #\") (char=? ch #\?)
					;(char=? ch #\<) 
	    (char=? ch #\>) (char=? ch #\{) (char=? ch #\}) (char=? ch #\|)  
	    (char=? ch #\~))
	1
	0))
  (focus-widget widget)
  (take-keyboard-focus widget)
  (if cleared 
      (set! (widget-text widget) text)
      (begin
  (do ((i 0 (1+ i)))
      ((= i (string-length text)))
    (let ((ch (string-ref text i)))
      (key-event widget (char->integer ch) (shifted? ch)))
    (force-event)))))

(set! (max-regions) 16)
(define mxa 32)

(if (not (defined? 'move-scale))
    (define (move-scale a b) #f))

(if (or full-test (= snd-test 24) (and keep-going (<= snd-test 24)))
    (begin
      (run-hook before-test-hook 24)
      (add-hook! snd-error-hook (lambda (msg) (snd-display ";err: ~A" msg) #t))
      
      (if (and (provided? 'snd-motif)
	       (provided? 'xm))
	  (let ((snd-return-key #xFF0D)
		(snd-left-key #xFF51)
		(snd-up-key #xFF52)
		(snd-right-key #xFF53)
		(snd-down-key #xFF54)
		(snd-kp-delete-key #xFF9F)
		(snd-kp-insert-key #xFF9E)
		(snd-kp-multiply-key #xFFAA)
		(snd-kp-add-key #xFFAB)
		(snd-kp-subtract-key #xFFAD)
		(snd-kp-decimal-key #xFFAE)
		(snd-kp-divide-key #xFFAF)
		(snd-kp-enter-key #xFF8D)
		(snd-space-key #x20)
		(snd-kp-left-key #xFF96)
		(snd-kp-right-key #xFF98)
		(snd-kp-up-key #xFF97)
		(snd-tab-key #xFF09)
					;(snd-kp-pagedown-key #xFF56) ; these are the non-keypad page up/down
					;(snd-kp-pageup-key #xFF55)
		(snd-kp-pagedown-key #xFF9B)
		(snd-kp-pageup-key #xFF9A)
		(snd-kp-down-key #xFF99)
		(snd-home-key #xFF50)
		(snd-kp-0 #xFFB0)
		(snd-kp-1 #xFFB1))
	    
	    (define (all-help wid)
	      (if (Widget? wid)
		  (for-each-child
		   wid
		   (lambda (n)
		     (let ((callable (XtHasCallbacks n XmNhelpCallback)))
		       (if (= callable XtCallbackHasSome)
			   (XtCallCallbacks n XmNhelpCallback
					    (let ((hlp (XmAnyCallbackStruct)))
					      (set! (.reason hlp) XmCR_HELP)
					      (set! (.event hlp) (XEvent))
					      hlp))))))))
	    
	    ;; force-event
	    ;; key-event widget key state
	    ;; click-event widget button state x y
	    ;; drag-event widget button state x0 y0 x1 y1
	    ;; expose-event widget x y width height
	    ;; resize-event widget width height
	    ;; click-button widget
	    ;; select-item list pos
	    ;;   these functions send either Xevents or directly invoke the Motif button callbacks
	    ;; resize-pane pane size 
	    
	    (reset-almost-all-hooks)
	    (add-hook! bad-header-hook (lambda (n) #t))
	    (for-each all-help (cdr (main-widgets)))
	    (set! (time-graph-type) graph-once)
	    (set! (transform-graph-type) graph-once)
	    (XSynchronize (XtDisplay (cadr (main-widgets))) #t)
	    ;; don't touch the mouse during this test!
	    
	    ;; -------- drive channel graph
	    (let ((ind (open-sound "oboe.snd")))
	      
	      (if (< (window-width) 600) 
		  (set! (window-width) 600))
	      (if (< (window-height) 600)
		  (set! (window-height) 600))
	      (force-event)
	      (set! (x-bounds) (list 0.0 0.1))
	      (if (< (cadr (widget-size (car (channel-widgets)))) 250)
		  (set! (widget-size (car (sound-widgets))) (list (car (widget-size (car (channel-widgets)))) 400)))
	      
	      (if (defined? 'popup-display-info)
		  (begin
		    (select-sound ind)
		    (popup-display-info)))
	      
	      (let* ((swids (sound-widgets))
		     (name-button (list-ref swids 1))
		     (minibuffer (list-ref swids 3))
		     (play-button (list-ref swids 4))
		     (cwid (car (channel-widgets)))
		     (size (widget-size (car (channel-widgets)))))
		
		(reset-hook! name-click-hook)
		(add-hook! name-click-hook (lambda (n) #t))
		(click-event name-button 1 0 1 1) (force-event)
		(reset-hook! name-click-hook)
		
		(for-each all-help swids)
		(for-each all-help (channel-widgets))
		
		(XtCallCallbacks minibuffer XmNfocusCallback (XmAnyCallbackStruct))
		(XtCallCallbacks minibuffer XmNlosingFocusCallback (XmAnyCallbackStruct))
		(enter-event minibuffer) (force-event)
		(leave-event minibuffer) (force-event)
		(take-keyboard-focus cwid)
		(click-event cwid 1 0 100 (inexact->exact (floor (/ (cadr size) 2)))) (force-event)
		(let ((pos (cursor-position)))
		  (if (> (abs (- (car pos) 100)) 1)
		      (snd-display ";pos ~A: ~A?" 100 (car pos))))
		(click-event cwid 1 0 300 (inexact->exact (floor (/ (cadr size) 2)))) (force-event)
		(let ((pos (cursor-position)))
		  (if (> (abs (- (car pos) 300)) 1)
		      (snd-display ";pos ~A: ~A?" 300 (car pos))))
		
		(expose-event cwid 20 20 200 200)
		(resize-event cwid 500 500)
		(take-keyboard-focus cwid)
		(let ((pos (cursor)))
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (if (>= pos (cursor))
		      (snd-display ";C-f: ~A ~A?" pos (cursor))))
		(key-event cwid (char->integer #\<) 4) (force-event)
		(if (not (= (cursor) 0))
		    (snd-display ";C-<: ~A ~A?" (cursor) (map channels (sounds))))
		(key-event cwid (char->integer #\>) 9) (force-event)
		(if (not (= (cursor) (- (frames) 1)))
		    (snd-display ";M->: ~A (~A)?" (cursor) (frames)))
		
		(key-event cwid (char->integer #\x) 4) (force-event)
		(key-event cwid (char->integer #\<) 0) (force-event)
		(if (not (= (cursor) 0))
		    (snd-display ";Cx-<: ~A?" (cursor)))
		(key-event cwid (char->integer #\x) 4) (force-event)
		(key-event cwid (char->integer #\>) 1) (force-event)
		(if (not (= (cursor) (- (frames) 1)))
		    (snd-display ";Cx->: ~A (~A)?" (cursor) (frames)))
		(set! (cursor) 0)
		(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 #\f) 4 ind)
		(if (not (= (cursor) 22050))
		    (snd-display ";C-u 1.0 C-f -> ~A" (cursor)))
		
		(let* ((i1 (open-sound "2.snd"))
		       (len (frames i1 0)))
		  (select-sound i1)
		  (key (char->integer #\u) 4 i1)
		  (key (char->integer #\1) 0 i1)
		  (key (char->integer #\0) 0 i1)
		  (key (char->integer #\0) 0 i1)
		  (key (char->integer #\d) 4 i1)
		  (if (not (= (frames i1 0) (- len 100)))
		      (snd-display ";C-u 100 C-d: ~A ~A" len (frames i1 0)))
		  
		  (key (char->integer #\u) 4 i1)
		  (key snd-kp-1 0 i1)
		  (key snd-kp-0 0 i1)
		  (key snd-kp-0 0 i1)
		  (key (char->integer #\d) 4 i1)
		  (if (not (= (frames i1 0) (- len 200)))
		      (snd-display ";C-u (kp)100 C-d: ~A ~A" len (frames i1 0)))
		  
		  (key (char->integer #\u) 4 i1)
		  (key snd-kp-1 4 i1)
		  (key snd-kp-0 4 i1)
		  (key snd-kp-0 4 i1)
		  (key (char->integer #\d) 4 i1)
		  (if (not (= (frames i1 0) (- len 300)))
		      (snd-display ";C-u (C-kp)100 C-d: ~A ~A" len (frames i1 0)))
		  
		  (revert-sound i1)
		  (set! (cursor) 10)
		  (key (char->integer #\u) 4 i1)
		  (key (char->integer #\-) 0 i1)
		  (key (char->integer #\1) 0 i1)
		  (key (char->integer #\0) 0 i1)
		  (key (char->integer #\0) 0 i1)
		  (key (char->integer #\d) 4 i1)
		  (if (or (not (= (frames i1 0) (- len 10)))
			  (not (= (cursor) 0)))
		      (snd-display ";C-u -100 C-d: ~A ~A ~A" len (frames i1 0) (cursor)))
		  
		  (dismiss-all-dialogs)
		  (key (char->integer #\x) 4 i1)
		  (key (char->integer #\e) 4 i1) (force-event)
		  (let ((str (widget-text (list-ref (sound-widgets i1) 3)))
			(size (widget-size (list-ref (sound-widgets i1) 3))))
		    (if (not (string=? str "no macro active?"))
			(snd-display ";C-x C-e report-in-minibuffer: ~A ~A?" str size)))

		  (dismiss-all-dialogs)
		  (key (char->integer #\x) 4 i1)
		  (key (char->integer #\() 0 i1)
		  (let ((str (widget-text (list-ref (sound-widgets i1) 3))))
		    (if (not (string=? str "defining macro..."))
			(snd-display ";C-x C-( report-in-minibuffer: ~A?" str)))
		  (key (char->integer #\x) 4 i1)
		  (key (char->integer #\() 0 i1)
		  (let ((str (widget-text (list-ref (sound-widgets i1) 3))))
		    (if (not (string=? str "macro definition already in progress"))
			(snd-display ";C-x C-( again report-in-minibuffer: ~A?" str)))
		  (key (char->integer #\g) 4 i1)
		  (key (char->integer #\x) 4 i1)
		  (key (char->integer #\9) 0 i1)
		  (let ((str (widget-text (list-ref (sound-widgets i1) 3))))
		    (if (not (string=? str "C-x 9 undefined"))
			(snd-display ";C-x C-9 report-in-minibuffer: ~A?" str)))
		  (key (char->integer #\g) 4 i1)
		  (dismiss-all-dialogs)		  
		  (close-sound i1)
		  (select-sound ind))
		
		(key-event cwid (char->integer #\x) 4) (force-event)
		(key-event cwid (char->integer #\=) 4) (force-event)
		
		(focus-widget cwid)
		(drag-event cwid 1 0 100 50 400 50) (force-event)
		(if (not (selection?))
		    (snd-display ";drag but no selection?")
		    (let* ((pos (selection-position))
			   (end (+ pos (selection-frames)))
			   (x0 (x->position (/ pos (srate))))
			   (x1 (x->position (/ end (srate)))))
		      (if (or (> (abs (- x0 100)) 1)
			      (> (abs (- x1 400)) 1))
			  (snd-display ";selectpos: ~A ~A ~A ~A " pos end x0 x1))
		      
		      (key-event cwid (char->integer #\x) 4) (force-event)
		      (key-event cwid (char->integer #\v) 0) (force-event)
		      (if (or (> (abs (- pos (left-sample))) 2)
			      (> (abs (- end (right-sample))) 2))
			  (snd-display ";C-x v selectpos: ~A ~A ~A ~A " pos end (left-sample) (right-sample)))
		      ))
		(set! (cursor) 6000)
		(let* ((ls (left-sample))
		       (rs (right-sample))
		       (len (- rs ls)))
;		  (key-event cwid snd-right-key 0) (force-event)
		  (if (key-binding snd-right-key 0)
		      (unbind-key snd-right-key 0))
		  (snd-simulate-keystroke ind 0 snd-right-key 0)
		  (if (> (abs (- (left-sample) rs)) 1)
		      (snd-display ";-> not by window? ~A ~A (~A ~A)" (left-sample) rs ls (frames)))
		  (if (> (abs (- len (- (right-sample) (left-sample)))) 1)
		      (snd-display ";-> size diff? ~A ~A" len (- (right-sample) (left-sample))))
		  (if (key-binding snd-left-key 0)
		      (unbind-key snd-left-key 0))
		  (key-event cwid snd-left-key 0) (force-event)
		  (if (> (abs (- (left-sample) ls)) 1)
		      (snd-display ";<- not by window? ~A ~A" ls (left-sample)))
		  (if (> (abs (- len (- (right-sample) (left-sample)))) 1)
		      (snd-display ";<- size diff? ~A ~A" len (- (right-sample) (left-sample))))
		  
		  (for-each 
		   (lambda (n val)
		     (key-event cwid (char->integer #\x) 4) (force-event) (key-event cwid snd-right-key n) (force-event)
		     (if (> (abs (- (left-sample) (* val len) ls)) 1)
			 (snd-display ";~A cx-> not by window? ~A ~A" n rs (left-sample)))
		     (if (> (abs (- len (- (right-sample) (left-sample)))) 1)
			 (snd-display ";~A cx-> size diff? ~A ~A" n len (- (right-sample) (left-sample))))
		     (key-event cwid (char->integer #\x) 4) (force-event) (key-event cwid snd-left-key n) (force-event)
		     (if (> (abs (- (left-sample) ls)) 1)
			 (snd-display ";~A cx<- not by window? ~A ~A" n ls (left-sample)))
		     (if (> (abs (- len (- (right-sample) (left-sample)))) 1)
			 (snd-display ";~A cx<- size diff? ~A ~A" n len (- (right-sample) (left-sample)))))
		   (list 0 4)
		   (list 1.0 0.5))
		  
		  (for-each (lambda (msk val)
			      (key-event cwid snd-right-key msk) (force-event)
			      (if (> (abs (- (left-sample) (* val len) ls)) 1)
				  (snd-display ";~A-> not by window? ~A ~A" msk rs (left-sample)))
			      (if (> (abs (- len (- (right-sample) (left-sample)))) 1)
				  (snd-display ";~A-> size diff? ~A ~A" msk len (- (right-sample) (left-sample))))
			      (key-event cwid snd-left-key msk) (force-event)
			      (if (> (abs (- (left-sample) ls)) 1)
				  (snd-display ";~A<- not by window? ~A ~A" msk ls (left-sample)))
			      (if (> (abs (- len (- (right-sample) (left-sample)))) 1)
				  (snd-display ";~A<- size diff? ~A ~A" msk len (- (right-sample) (left-sample)))))
			    (list 1 4 8 5 9 13)
			    (list 0.5 0.5 0.5 0.25 0.25 0.125))
		  
		  (if (key-binding snd-up-key 0)
		      (unbind-key snd-up-key 0))
		  (if (key-binding snd-down-key 0)
		      (unbind-key snd-down-key 0))
;		  (key-event cwid snd-up-key 0) (force-event)
		  (snd-simulate-keystroke ind 0 snd-up-key 0)
		  (if (> (abs (- (* 2 len) (- (right-sample) (left-sample)))) 3)
		      (snd-display ";up size diff? ~A ~A" ( * 2 len) (- (right-sample) (left-sample))))
		  (key-event cwid snd-down-key 0) (force-event)
		  (if (> (abs (- len (- (right-sample) (left-sample)))) 3)
		      (snd-display ";down size diff? ~A ~A" len (- (right-sample) (left-sample))))
		  (key-event cwid snd-up-key 4) (force-event)
		  (if (> (abs (- (* 1.5 len) (- (right-sample) (left-sample)))) 2)
		      (snd-display ";C-up size diff? ~A ~A" ( * 1.5 len) (- (right-sample) (left-sample))))
		  (key-event cwid snd-down-key 4) (force-event)
		  (if (> (abs (- len (- (right-sample) (left-sample)))) 2)
		      (snd-display ";C-down size diff? ~A ~A" len (- (right-sample) (left-sample))))
		  
		  (for-each
		   (lambda (n val)
		     (key-event cwid (char->integer #\x) 4) (force-event)
		     (key-event cwid snd-up-key n) (force-event)
		     (if (> (abs (- (* val len) (- (right-sample) (left-sample)))) 2)
			 (snd-display ";~A Cx-up size diff? ~A ~A" n ( * val len) (- (right-sample) (left-sample))))
		     (key-event cwid (char->integer #\x) 4) (force-event)
		     (key-event cwid snd-down-key n) (force-event)
		     (if (> (abs (- len (- (right-sample) (left-sample)))) 2)
			 (snd-display ";~A Cx-down size diff? ~A ~A" n len (- (right-sample) (left-sample)))))
		   (list 0 4)
		   (list 2.0 1.5))
		  
		  (for-each (lambda (msk val)
			      (key-event cwid snd-up-key msk) (force-event)
			      (if (> (abs (- (* val len) (- (right-sample) (left-sample)))) 3)
				  (snd-display ";~A up size diff? ~A ~A" msk ( * val len) (- (right-sample) (left-sample))))
			      (key-event cwid snd-down-key msk) (force-event)
			      (if (> (abs (- len (- (right-sample) (left-sample)))) 3)
				  (snd-display ";~A down size diff? ~A ~A" msk len (- (right-sample) (left-sample)))))
			    (list 1 4 8 5 9 13)
			    (list 1.5 1.5 1.5 1.25 1.25 1.125))
		  
		  (let ((y (spectro-y-angle))
			(x (spectro-x-angle)))
		    (key-event cwid snd-kp-right-key 4) (force-event)
		    (if (fneq (spectro-y-angle) (+ y 1.0))
			(snd-display ";C-keypad-right: ~A ~A" y (spectro-y-angle)))
		    (key-event cwid snd-kp-left-key 4) (force-event)
		    (if (fneq (spectro-y-angle) y)
			(snd-display ";C-keypad-left: ~A ~A" y (spectro-y-angle)))
		    (key-event cwid snd-kp-down-key 4) (force-event)
		    (if (fneq (spectro-x-angle) (- x 1.0))
			(snd-display ";C-keypad-down: ~A ~A" x (spectro-x-angle)))
		    (key-event cwid snd-kp-up-key 4) (force-event)
		    (if (fneq (spectro-x-angle) x)
			(snd-display ";C-keypad-up: ~A ~A" x (spectro-x-angle))))
		  
		  (let ((hop (spectro-hop)))
		    (key-event cwid snd-kp-add-key 0) (force-event)
		    (if (not (= (spectro-hop) (1+ hop)))
			(snd-display ";keypad-add ~A -> ~A" hop (spectro-hop)))
		    (key-event cwid snd-kp-subtract-key 0) (force-event)
		    (if (not (= (spectro-hop) hop))
			(snd-display ";keypad-subtract ~A -> ~A" hop (spectro-hop))))
		  
		  (set! (spectro-cutoff) 0.5)
		  (key-event cwid snd-kp-pageup-key 0) (force-event)
		  (if (> (abs (- (spectro-cutoff) (/ 0.5 0.95))) .05)
		      (snd-display ";keypad-pageup ~A -> ~A" 0.5 (spectro-cutoff)))
		  (key-event cwid snd-kp-pagedown-key 0) (force-event)
		  (if (fneq (spectro-cutoff) 0.5)
		      (snd-display ";keypad-pagedown ~A -> ~A" 0.5 (spectro-cutoff)))
		  
		  (let ((za (spectro-z-angle))
			(zs (spectro-z-scale)))
		    (key-event cwid snd-kp-right-key 0) (force-event)
		    (if (fneq (spectro-z-angle) (+ za 1.0))
			(snd-display ";z keypad-right: ~A ~A" za (spectro-z-angle)))
		    (key-event cwid snd-kp-left-key 0) (force-event)
		    (if (fneq (spectro-z-angle) za)
			(snd-display ";z keypad-left: ~A ~A" za (spectro-z-angle)))
		    (key-event cwid snd-kp-down-key 0) (force-event)
		    (if (fneq (spectro-z-scale) (- zs .01))
			(snd-display ";keypad-down: ~A ~A" zs (spectro-z-scale)))
		    (key-event cwid snd-kp-up-key 0) (force-event)
		    (if (fneq (spectro-z-scale) zs)
			(snd-display ";keypad-up: ~A ~A" zs (spectro-z-scale))))
		  
		  (bind-key (char->integer #\p) 0 (lambda () cursor-on-left))
		  (bind-key (char->integer #\q) 0 (lambda () cursor-in-middle))
		  (bind-key (char->integer #\r) 0 (lambda () cursor-on-right))
		  (key-event cwid (char->integer #\p) 0) (force-event)
		  (if (> (abs (- (cursor) (left-sample))) 1)
		      (snd-display ";cursor-on-left: ~A ~A" (cursor) (left-sample)))
		  (key-event cwid (char->integer #\r) 0) (force-event)
		  (if (> (abs (- (cursor) (right-sample))) 1)
		      (snd-display ";cursor-on-right: ~A ~A" (cursor) (right-sample)))
		  (key-event cwid (char->integer #\q) 0) (force-event)
		  (if (> (abs (- (cursor) (inexact->exact (floor (* .5 (+ (left-sample) (right-sample))))))) 1)
		      (snd-display ";cursor-in middle: ~A ~A" (cursor) (inexact->exact (floor (* .5 (+ (left-sample) (right-sample)))))))
		  (key-event cwid (char->integer #\p) 0) (force-event)
		  (if (> (abs (- (cursor) (left-sample))) 1)
		      (snd-display ";cursor-on-left (1): ~A ~A" (cursor) (left-sample)))
		  (key-event cwid (char->integer #\x) 4) (force-event) 
		  (key-event cwid (char->integer #\t) 4) (force-event)
		  
		  (set! (graph-style) graph-dots)
		  (let ((ds (dot-size)))
		    (key-event cwid snd-kp-delete-key 0) (force-event)
		    (if (not (= (dot-size) (1+ ds)))
			(snd-display ";keypad dot-size: ~A -> ~A?" ds (dot-size)))
		    (key-event cwid snd-kp-insert-key 0) (force-event)
		    (if (not (= (dot-size) ds))
			(snd-display ";keypad insert dot-size: ~A -> ~A?" ds (dot-size))))
		  (set! (graph-style) graph-lines)
		  (key-event cwid snd-kp-enter-key 0) (force-event)
		  
		  (set! (transform-graph?) #t)
		  (set! (transform-size) 256)
		  (let ((ds (transform-size)))
		    (key-event cwid snd-kp-multiply-key 0) (force-event)
		    (if (not (= (transform-size) (* 2 ds)))
			(snd-display ";multiply transform-size: ~A -> ~A?" ds (transform-size)))
		    (key-event cwid snd-kp-divide-key 0) (force-event)
		    (if (not (= (transform-size) ds))
			(snd-display ";divide transform-size: ~A -> ~A?" ds (transform-size))))
		  (set! (transform-graph?) #f)
		  
		  (set! (time-graph-type) graph-as-wavogram)
		  (let ((hop (wavo-trace)))
		    (key-event cwid snd-kp-add-key 0) (force-event)
		    (if (not (= (1+ hop) (wavo-trace))) (snd-display ";add wavo-trace ~A -> ~A" hop (wavo-trace)))
		    (key-event cwid snd-kp-subtract-key 0) (force-event)
		    (if (not (= hop (wavo-trace))) (snd-display ";subtract wavo-trace ~A -> ~A" hop (wavo-trace))))
		  (update-time-graph)
		  (set! (colormap) 0)
		  (key-event cwid snd-kp-add-key 0) (force-event)
		  (update-time-graph)
		  (set! (colormap) 2)
		  (set! (time-graph-type) graph-once)
		  (revert-sound ind)
		  (set! (read-only ind) #f)
		  
		  (take-keyboard-focus cwid)
		  (key-event cwid (char->integer #\a) 4) (force-event)
		  (if (not (= (cursor) (left-sample)))
		      (snd-display ";C-a: ~A ~A?" (cursor) (left-sample)))
		  (key-event cwid (char->integer #\e) 4) (force-event)
		  (if (not (= (cursor) (right-sample)))
		      (snd-display ";C-e: ~A ~A?" (cursor) (right-sample)))
		  (key-event cwid (char->integer #\b) 4) (force-event)
		  (if (not (= (cursor) (1- (right-sample))))
		      (snd-display ";C-b: ~A ~A?" (cursor) (1- (right-sample))))
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (if (not (= (cursor) (right-sample)))
		      (snd-display ";C-f: ~A ~A?" (cursor) (right-sample)))
		  (if (not (selection?))
		      (snd-display ";what happened to our selection?"))
		  (key-event cwid snd-space-key 0) (force-event)
		  (if (selection?)
		      (snd-display ";C-space did not cancel selection?"))
		  (set! (cursor) 100)
		  (key-event cwid (char->integer #\d) 4) (force-event)
		  (if (not (equal? (edits) '(1 0)))
		      (snd-display ";C-d (edits) -> ~A?" (edits)))
		  (if (not (equal? (edit-fragment 1) (list "delete-samples 100 1" "delete" 100 1)))
		      (snd-display ";C-d (edit) -> ~A?" (edit-fragment 1)))
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\0) 4) (force-event)
		  (key-event cwid (char->integer #\d) 4) (force-event)
		  (if (not (equal? (edits) '(1 0)))
		      (snd-display ";0 C-d (edits) -> ~A?" (edits)))
		  (key-event cwid (char->integer #\h) 4) (force-event)
		  (if (not (equal? (edits) '(2 0)))
		      (snd-display ";C-h (edits) -> ~A?" (edits)))
		  (if (not (equal? (edit-fragment 2) (list "delete-samples 99 1" "delete" 99 1)))
		      (snd-display ";C-h (edit) -> ~A?" (edit-fragment 2)))
		  
		  (let* ((ind (open-sound "2.snd"))
			 (cwid (car (channel-widgets ind 1)))
			 (fr (frames ind)))
		    (set! (sync ind) 1)
		    (select-sound ind)
		    (select-channel 1)
		    (set! (channel-style ind) channels-combined)
		    (equalize-panes)
		    (set! (channel-style ind) channels-separate)
		    (set! (cursor) 100)
		    (take-keyboard-focus cwid)
		    (if (not (= (cursor ind 0) 100)) (snd-display ";syncd cursor 0 100: ~A ~A" (cursor ind 0) (cursor ind 1)))
		    (if (not (= (cursor ind 1) 100)) (snd-display ";syncd cursor 1 100: ~A ~A" (cursor ind 0) (cursor ind 1)))
		    (key-event cwid (char->integer #\d) 4) (force-event)
		    (if (not (equal? (edits ind 1) '(1 0))) (snd-display ";C-d (edits ~A 1) -> ~A?" ind (edits ind 1)))
		    (if (not (equal? (edits ind 0) '(1 0))) (snd-display ";C-d (edits ~A 0) -> ~A?" ind (edits ind 0)))
		    (key-event cwid (char->integer #\u) 4) (force-event)
		    (key-event cwid (char->integer #\8) 4) (force-event)
		    (key-event cwid (char->integer #\d) 4) (force-event)
		    (if (not (equal? (edits ind 1) '(2 0))) (snd-display ";C-d (2 edits ~A 1) -> ~A?" ind (edits ind 1)))
		    (if (not (equal? (edits ind 0) '(2 0))) (snd-display ";C-d (2 edits ~A 0) -> ~A?" ind (edits ind 0)))
		    (if (not (= (frames ind 1) (- fr 9))) (snd-display ";1 C-d frames: ~A ~A" (- fr 9) (frames)))
		    (if (not (= (frames ind 0) (- fr 9))) (snd-display ";0 C-d frames: ~A ~A" (- fr 9) (frames)))
		    (key-event cwid (char->integer #\h) 4) (force-event)
		    (if (not (equal? (edits ind 1) '(3 0))) (snd-display ";C-h (3 edits ~A 1) -> ~A?" ind (edits ind 1)))
		    (if (not (equal? (edits ind 0) '(3 0))) (snd-display ";C-h (3 edits ~A 0) -> ~A?" ind (edits ind 0)))
		    (if (not (= (frames ind 1) (- fr 10))) (snd-display ";1 C-h frames: ~A ~A" (- fr 10) (frames)))
		    (if (not (= (frames ind 0) (- fr 10))) (snd-display ";0 C-h frames: ~A ~A" (- fr 10) (frames)))
		    (key-event cwid (char->integer #\u) 4) (force-event)
		    (key-event cwid (char->integer #\8) 0) (force-event)
		    (key-event cwid (char->integer #\h) 4) (force-event)
		    (if (not (equal? (edits ind 1) '(4 0))) (snd-display ";C-h (4 edits ~A 1) -> ~A?" ind (edits ind 1)))
		    (if (not (equal? (edits ind 0) '(4 0))) (snd-display ";C-h (4 edits ~A 0) -> ~A?" ind (edits ind 0)))
		    (if (not (= (frames ind 1) (- fr 18))) (snd-display ";1 2 C-h frames: ~A ~A" (- fr 18) (frames)))
		    (if (not (= (frames ind 0) (- fr 18))) (snd-display ";0 2 C-h frames: ~A ~A" (- fr 18) (frames)))
		    (if (not (= (cursor ind 1) 91)) (snd-display ";C-h 1 cursor: ~A" (cursor ind 1)))
		    (if (not (= (cursor ind 0) 91)) (snd-display ";C-h 0 cursor: ~A" (cursor ind 0)))
		    (key-event cwid (char->integer #\u) 4) (force-event)
		    (key-event cwid (char->integer #\-) 0) (force-event)
		    (key-event cwid (char->integer #\8) 0) (force-event)
		    (key-event cwid (char->integer #\d) 4) (force-event)
		    
		    (bind-key (char->integer #\n) 0 (lambda (arg) (set! (cursor) (+ (cursor) (* 128 arg)))))
		    (set! (cursor) 0)
		    (key-event cwid (char->integer #\u) 4) (force-event)
		    (key-event cwid (char->integer #\2) 0) (force-event)
		    (key-event cwid (char->integer #\n) 0) (force-event)
		    (if (not (= (cursor) (* 128 2))) (snd-display ";C-n bound: ~A" (cursor)))
		    (key-event cwid (char->integer #\n) 0) (force-event)
		    (if (not (= (cursor) (* 128 3))) (snd-display ";C-n bound no arg: ~A" (cursor)))
		    (unbind-key (char->integer #\n) 0)
		    
		    (close-sound ind))
		  (select-sound ind)
		  (select-channel 0)
		  
		  (set! (cursor) 5000)
		  (let ((fr (frames)))
		    (key-event cwid (char->integer #\o) 4) (force-event)
		    (if (not (equal? (edits) '(3 0)))
			(snd-display ";C-o (edits) -> ~A?" (edits))
			(if (not (equal? (edit-fragment 3) (list "pad-channel" "zero" 5000 1)))
			    (snd-display ";C-o (edit) -> ~A?" (edit-fragment 3))))
		    (if (fneq (sample (cursor)) 0.0)
			(snd-display ";C-o sample: ~A?" (sample (cursor))))
		    (if (not (= (frames) (1+ fr)))
			(snd-display ";frames after C-o: ~A ~A?" (frames) fr))
		    (key-event cwid (char->integer #\v) 4) (force-event)
		    (if (> (abs (- (cursor) (inexact->exact (floor (* .5 (+ (left-sample) (right-sample))))))) 1)
			(snd-display ";C-v loc: ~A ~A?" (cursor) (inexact->exact (floor (* .5 (+ (left-sample) (right-sample)))))))
		    (if (= (sample (cursor)) 0.0)
			(set! (cursor) (1+ (cursor))))
		    (key-event cwid (char->integer #\z) 4) (force-event)
		    (if (not (equal? (edits) '(4 0)))
			(snd-display ";C-z (edits) -> ~A?" (edits))
			(if (not (string=? (car (edit-fragment 4)) "scale-channel 0.000 5001 1"))
			    (snd-display ";C-z (edit) -> ~A?" (edit-fragment 4))))
		    (if (fneq (sample (cursor)) 0.0)
			(snd-display ";C-z sample: ~A?" (sample (cursor))))
		    (if (not (= (frames) (1+ fr)))
			(snd-display ";frames after C-z: ~A ~A?" (frames) fr)))
		  (if (> (length (marks ind 0)) 0)
		      (snd-display ";there are marks here already!"))
		  (key-event cwid (char->integer #\-) 4) (force-event)
		  (key-event cwid (char->integer #\m) 4) (force-event)
		  (let ((str (widget-text (list-ref (sound-widgets ind) 3))))
		    (if (not (string=? str (format #f "no mark at sample ~D" (cursor))))
			(snd-display ";-m report-in-minibuffer: ~A?" str)))
		  (key-event cwid (char->integer #\m) 4) (force-event)
		  (if (null? (marks ind 0))
		      (snd-display ";C-m but no mark!")
		      (let ((m (car (marks ind 0))))
			(if (not (= (mark-sample m) (cursor)))
			    (snd-display ";C-m mark sample: ~A ~A?" (mark-sample m) (cursor)))))
		  (key-event cwid (char->integer #\-) 4) (force-event)	
		  (key-event cwid (char->integer #\m) 4) (force-event)
		  (if (mark? (find-mark (cursor)))
		      (snd-display ";C-- C-m mark: ~A?" (find-mark (cursor))))
		  (key-event cwid (char->integer #\x) 4) (force-event)		  
		  (key-event cwid (char->integer #\o) 4) (force-event)
		  (if (not (show-controls ind))
		      (snd-display ";C-x C-o: ~A?" (show-controls)))
		  (key-event cwid (char->integer #\x) 4) (force-event)		  
		  (key-event cwid (char->integer #\c) 4) (force-event)
		  (if (show-controls ind)
		      (snd-display ";C-x C-c: ~A?" (show-controls)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (if (not (equal? (edits) '(3 1)))
		      (snd-display ";C-x C-u (edits) -> ~A?" (edits)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\r) 4) (force-event)
		  (if (not (equal? (edits) '(4 0)))
		      (snd-display ";C-x C-r (edits) -> ~A?" (edits)))
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\1) 0) (force-event)
		  (key-event cwid (char->integer #\2) 0) (force-event)
		  (key-event cwid (char->integer #\3) 0) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\b) 4) (force-event)
		  (if (not (= (left-sample) 123))
		      (snd-display ";C-u 123 C-x: ~A?" (left-sample)))
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\5) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\b) 4) (force-event)
		  (if (not (= (left-sample) 5000))
		      (snd-display ";C-u 5000 C-x: ~A?" (left-sample)))
		  (set! (cursor) 123)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\b) 0) (force-event)
		  (if (not (= (left-sample) 123))
		      (snd-display ";C-x b(123): ~A?" (left-sample)))
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\1) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\f) 4) (force-event)	
		  (if (not (= (cursor) 133))
		      (snd-display ";C-u 10 C-f -> ~A?" (cursor)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\/) 0) (force-event)
		  (widget-string minibuffer "away!")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (set! (cursor) 0)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\j) 0) (force-event)
		  (widget-string minibuffer "away!")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (= (cursor) 133))
		      (snd-display ";named mark? ~A ~A" (cursor) (find-mark "away!")))
		  (let ((m (find-mark "away!")))
		    (if (or (not (mark? m))
			    (not (= (mark-sample m) 133)))
			(snd-display ";are we away? ~A" (if (mark? m) (mark-sample m) "lost"))))
		  (set! (cursor) 130)
		  (key-event cwid (char->integer #\j) 4) (force-event)
		  (if (not (= (cursor) 133))
		      (snd-display ";goto mark? ~A" (cursor)))
		  (if (key-binding (char->integer #\n) 4)
		      (unbind-key (char->integer #\n) 4))
		  (key-event cwid (char->integer #\n) 4) (force-event)
		  (if (not (= (cursor) (+ 128 133)))
		      (snd-display ";ahead line? ~A" (cursor)))
		  (if (key-binding (char->integer #\p) 4)
		      (unbind-key (char->integer #\p) 4))
		  (key-event cwid (char->integer #\p) 4) (force-event)
		  (if (not (= (cursor) 133))
		      (snd-display ";back line? ~A" (cursor)))
		  (let ((fr (frames)))
		    (if (key-binding (char->integer #\k) 4)
			(unbind-key (char->integer #\k) 4))
		    (key-event cwid (char->integer #\k) 4) (force-event)
		    (if (not (equal? (edits) '(5 0)))
			(snd-display ";C-k (edits) -> ~A?" (edits)))
		    (if (not (equal? (edit-fragment 5) (list "delete-samples 133 128" "delete" 133 128)))
			(snd-display ";C-k (edit) -> ~A?" (edit-fragment 5)))
		    (if (not (= (frames) (- fr 128)))
			(snd-display ";frames after C-k: ~A ~A?" (frames) fr)))
		  (key-event cwid (char->integer #\s) 4) (force-event)
		  (widget-string minibuffer "(lambda (n) (< n -.1))")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (let ((cs (cursor)))
		    (if (not (< (sample cs) -.1))
			(snd-display ";C-s -.1 -> ~A at ~A (~A)?" 
				     (sample cs) cs
				     (widget-text (list-ref (sound-widgets ind) 3))))
		    (key-event cwid (char->integer #\s) 4) (force-event)
		    (key-event cwid (char->integer #\s) 4) (force-event)
		    (if (not (< (sample (cursor)) -.1))
			(snd-display ";C-s -.1 (1) -> ~A at ~A (~A)?" 
				     (sample (cursor)) (cursor)
				     (widget-text (list-ref (sound-widgets ind) 3))))
		    (if (= cs (cursor))
			(snd-display ";C-s 2 -> ~A at ~A?" cs (cursor)))
		    (key-event cwid (char->integer #\b) 4) (force-event)
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (widget-string minibuffer "(lambda (n) (>= n .05))")
		    (key-event minibuffer snd-return-key 0) (force-event)
		    (set! cs (cursor))
		    (if (not (>= (sample cs) .05))
			(snd-display ";C-r >= .05 -> ~A at ~A?" (sample cs) cs))
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (if (not (>= (sample (cursor)) .05))
			(snd-display ";C-r >= .05 (1) -> ~A at ~A?" (sample (cursor)) (cursor)))
		    (if (= cs (cursor))
			(snd-display ";C-r 2 -> ~A at ~A?" cs (cursor)))
		    (key-event cwid (char->integer #\>) 9) (force-event)
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (set! cs (cursor))
		    (if (not (>= (sample cs) .05))
			(snd-display ";C-r back >= .05 -> ~A at ~A?" (sample cs) cs))
		    (key-event cwid (char->integer #\>) 9) (force-event)
		    (key-event cwid (char->integer #\b) 4) (force-event)
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (key-event cwid (char->integer #\r) 4) (force-event)
		    (set! cs (cursor))
		    (if (not (>= (sample cs) .05))
			(snd-display ";C-r back 2 >= .05 -> ~A at ~A?" (sample cs) cs)))
		  (key-event cwid (char->integer #\q) 4) (force-event)
		  (key-event cwid (char->integer #\i) 4) (force-event) ; just for completeness
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\5) 0) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (if (not (equal? (edits) '(0 5)))
		      (snd-display ";C-x C-u -> ~A?" (edits)))
		  (key-event cwid (char->integer #\<) 4) (force-event)
		  (if (not (= (cursor) 0))
		      (snd-display ";C-< (1): ~A?" (cursor)))
		  
		  (let ((s1000 (sample 1000))
			(fr (frames)))
		    (make-region 0 999)
		    (make-selection 0 999)
		    (key-event cwid (char->integer #\w) 4) (force-event)
		    (if (fneq (sample 0) s1000)
			(snd-display ";C-w: ~A ~A (~A ~A)" s1000 (sample 0) fr (frames)))
		    (if (not (= fr (+ (frames) 1000)))
			(snd-display ";C-w len: ~A ~A" fr (frames)))
		    (if (not (equal? (edits) '(1 0)))
			(snd-display ";C-w -> ~A?" (edits)))
		    (if (not (equal? (edit-fragment 1) (list "delete-samples 0 1000" "delete" 0 1000)))
			(snd-display ";C-w (edit) -> ~A [~A]?" 
				     (edit-fragment 1)
				     (car (edit-fragment 1))))
		    (key-event cwid (char->integer #\<) 4) (force-event)
		    (key-event cwid (char->integer #\y) 4) (force-event)
		    (if (fneq (sample 1000) s1000)
			(snd-display ";C-y: ~A ~A (~A ~A)" s1000 (sample 1000) fr (frames)))
		    (if (not (= fr (frames)))
			(snd-display ";C-y len: ~A ~A" fr (frames)))
		    (if (not (equal? (edits) '(2 0)))
			(snd-display ";C-y -> ~A?" (edits))))
		  
		  (key-event cwid (char->integer #\<) 4) (force-event)
		  (key-event cwid (char->integer #\x) 8) (force-event)
		  (widget-string minibuffer "(do ((i 0 (1+ i))) ((= i 10)) (set! (sample i) 1.0))")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (equal? (edits) '(3 0)))
		      (snd-display ";M-x edits 10 -> 1.0: ~A?" (edits)))
		  (if (not (equal? (edit-fragment 3) (list "set-sample 9 1.0000" "set" 9 1)))
		      (snd-display ";:M-x fragment (wierd!): ~A" (edit-fragment 3)))
		  (key-event cwid snd-space-key 4) (force-event)
		  (do ((i 0 (1+ i)))
		      ((= i 9))
		    (key-event cwid (char->integer #\f) 4) (force-event))
		  (if (not (selection?))
		      (snd-display ";C-space for selection failed?"))
		  (if (not (= (selection-frames) 10))
		      (snd-display ";C-space for selection len: ~A?" (selection-frames)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\l) 0) (force-event)
		  (if (not (= (cursor) (+ (selection-position) (inexact->exact (floor (* 0.5 (selection-frames)))))))
		      (snd-display ";C-x L: ~A ~A" (cursor) (+ (selection-position) (inexact->exact (floor (* 0.5 (selection-frames)))))))
		  
		  (key-event cwid (char->integer #\x) 8) (force-event)
		  (widget-string minibuffer "(set! mxa 3)")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (= mxa 3))
		      (snd-display ";M-x (set! mxa 3) -> ~A" mxa))
		  
		  (key-event cwid (char->integer #\x) 8) (force-event)
		  (widget-string minibuffer "(mus-sound-frames \"pistol")
		  (key-event minibuffer snd-tab-key 0) (force-event)
		  (let ((str (widget-text minibuffer)))
		    (if (not (string=? str "(mus-sound-frames \"pistol.snd"))
			(snd-display ";M-x with filename completion: ~A" str)))
		  
		  (reset-listener-cursor)
		  (goto-listener-end)
		  (let ((lst (list-ref (main-widgets) 4))
			(snd-return-key #xFF0D))
		    (take-keyboard-focus lst)
		    (key-event lst snd-return-key 0) (force-event) ; possible pre-existing error msg etc
		    (key-event lst snd-return-key 0) (force-event)
		    (widget-string lst "(set! mxa (+ 1 4))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= mxa 5))
			(snd-display ";set! mxa in listener: ~A" mxa))
		    (widget-string lst "(set! mxa 32)" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= mxa 32))
			(snd-display ";preset M-p mxa in listener: ~A" mxa))
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst (char->integer #\p) 8) (force-event)
		    (key-event lst (char->integer #\p) 8) (force-event)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= mxa 5))
			(snd-display ";M-p mxa in listener: ~A" mxa))
		    (key-event lst (char->integer #\p) 8) (force-event)
		    (key-event lst (char->integer #\p) 8) (force-event)
		    (key-event lst (char->integer #\p) 8) (force-event)
		    (key-event lst (char->integer #\n) 8) (force-event)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= mxa 32))
			(snd-display ";M-n mxa in listener: ~A" mxa))
		    (widget-string lst "(set! mxa" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "123)" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= mxa 123))
			(snd-display ";set! mxa with embedded cr in listener: ~A" mxa))
		    (widget-string lst "abc" #f)
		    (key-event lst (char->integer #\a) 4)
		    (key-event lst (char->integer #\U) 9) (force-event)
		    (key-event lst (char->integer #\a) 4)
		    (key-event lst (char->integer #\t) 4)
		    (key-event lst (char->integer #\C) 9) (force-event)
		    (key-event lst (char->integer #\a) 4)
		    (key-event lst (char->integer #\k) 4)
		    (widget-string lst "(mus-sound-s" #f)
		    (key-event lst snd-tab-key 0) (force-event)
		    (let ((helpd (list-ref (dialog-widgets) 15)))
		      (if helpd
			  (if (not (XtIsManaged helpd))
			      (snd-display ";help completion dialog isn't active?")
			      (XtUnmanageChild helpd))
			  (snd-display ";no help dialog at all!")))
		    (key-event lst (char->integer #\a) 4)
		    (key-event lst (char->integer #\k) 4)
		    (widget-string lst "(open-sound ")
		    (key-event lst (char->integer #\?) 4)
		    
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-return-key 0) (force-event)
		    (widget-string lst "(define aval " #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "(+ 1 ;a comment" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "(char->integer #\\a)" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "(char->integer (string-ref \"01\\\"\" 2))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "(char->integer (string-ref \"01\\\";#\" 2))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "(vector-ref '#(1 2) 0)" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "(char->integer #\\))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (key-event lst snd-tab-key 0) (force-event)
		    (if (not (= aval 208)) (snd-display ";listener paren check: ~A" aval))
		    
					;(key-event lst (char->integer #\g) 12) (force-event)
		    (widget-string lst "(define frs (mus-sound-frames \"pistol." #f)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "\"))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= frs 41623)) (snd-display ";filename completer in listener: ~A" frs))
		    
		    (widget-string lst "(set! frs (+ 1 ;" #f)
		    (key-event lst snd-tab-key 0) (force-event)
		    (widget-string lst "comment" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (widget-string lst "2))" #f)
		    (key-event lst snd-return-key 0) (force-event)
		    (if (not (= frs 3)) (snd-display ";comment completer in listener: ~A" frs))
		    )
		  
		  (take-keyboard-focus cwid)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\a) 0) (force-event)
		  (widget-string minibuffer "'(0 0 1 1)")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (do ((i 0 (1+ i)))
		      ((= i 10))
		    (if (fneq (sample i) (* i .1111))
			(snd-display ";C-x a [~A]: ~A" i (sample i))))
		  (undo)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\a) 0) (force-event)
		  (widget-string minibuffer "ramp-u")
		  (key-event minibuffer snd-tab-key 0) (force-event)
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (undo)
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\5) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\a) 4) (force-event)
		  (widget-string minibuffer "env2")
		  (key-event minibuffer snd-tab-key 0) (force-event)
		  (key-event minibuffer snd-return-key 0) (force-event)
		  
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\() 1) (force-event)
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\)) 1) (force-event)
		  (if (file-exists? "test-macros.scm") (delete-file "test-macros.scm"))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\e) 4) (force-event)		  
		  (widget-string minibuffer "test-save-macros")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (save-macros "test-macros.scm")
		  (if (not (file-exists? "test-macros.scm")) (snd-display ";save-macros didn't write file?"))
		  (if (and (defined? 'test-save-macros)
			   (procedure? test-save-macros))
		      (set! test-save-macros #f))
		  (load "test-macros.scm")
		  (if (or (not (defined? 'test-save-macros))
			  (not (procedure? test-save-macros)))
		      (snd-display ";save-macros output incorrect?"))
		  
		  (set! (cursor) 1000)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\e) 0) (force-event)
		  (if (not (= (cursor) 1003))
		      (snd-display ";kbd macro: ~A?" (cursor)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\e) 4) (force-event)
		  (widget-string minibuffer "macro")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\8) 0) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\e) 0) (force-event)
		  (if (not (= (cursor) (+ 1003 (* 8 3))))
		      (snd-display ";kbd macro (8): ~A?" (cursor)))
		  (key-event cwid (char->integer #\t) 4) (force-event)
		  
		  (set! (cursor) 4000)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\f) 0) (force-event)
		  (if (> (abs (- (cursor) (right-sample))) 1)
		      (snd-display ";C-x f -> ~A ~A" (cursor) (right-sample)))
		  
		  (if (file-exists? "hiho.eps") (delete-file "hiho.eps"))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\g) 4) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\d) 4) (force-event)
		  (widget-string minibuffer "hiho.eps")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (file-exists? "hiho.eps"))
		      (snd-display ";C-x C-d no output?")
		      (delete-file "hiho.eps"))
		  (with-output-to-file "hiho.scm" (lambda () (display "(define a-test 32)")))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\l) 4) (force-event)
		  (widget-string minibuffer "hiho.scm")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (or (not (defined? 'a-test))
			  (not (= a-test 32)))
		      (snd-display ";C-x C-l failed?")
		      (delete-file "hiho.scm"))
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\1) 0) (force-event)
		  (key-event cwid (char->integer #\.) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\p) 4) (force-event)
		  (if (fneq (/ (- (right-sample) (left-sample)) (srate)) 1.0)
		      (snd-display ";C-x C-p 1.0: ~A?" (/ (- (right-sample) (left-sample) (srate)))))
		  (key-event cwid (char->integer #\<) 4) (force-event)
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\1) 0) (force-event)
		  (key-event cwid (char->integer #\.) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (if (fneq (/ (cursor) (srate)) 1.0)
		      (snd-display ";C-u 1.0 C-f: ~A?" (/ (cursor) (srate))))
		  
;		  (let ((edhist (list-ref (channel-widgets) 7)))
;		    (select-item edhist 1) (force-event)
;		    (if (not (= (edit-position) 1))
;			(snd-display ";click edit history: ~A ~A" (edit-position) (edits))))
		  (set! (edit-position) 1)
		  
		  (focus-widget cwid)
		  (drag-event cwid 1 0 100 50 400 50) (force-event)
		  (if (not (selection?))
		      (snd-display ";drag(1) but no selection?")
		      (let* ((pos (selection-position))
			     (samp (sample (1+ pos))))
			(key-event cwid (char->integer #\x) 4) (force-event)
			(key-event cwid (char->integer #\x) 0) (force-event)
			(widget-string minibuffer "(lambda (n) (* n 5))")
			(key-event minibuffer snd-return-key 0) (force-event)
			(if (fneq (sample (1+ pos)) (* 5 samp))
			    (snd-display ";eval-over-selection: ~A ~A (~A)" samp (sample (1+ pos)) (edit-fragment)))))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\z) 0) (force-event)
		  (let* ((md (mix "oboe.snd" 100))
			 (eds (edit-position))
			 (xy (mix-tag-xy md))
			 (x (+ (car xy) 1))
			 (y (- (cadr xy) 2)))
		    (focus-widget cwid)
		    (drag-event cwid 1 0 x y (+ x 150) y) (force-event)
		    (if (> (abs (- (car (mix-tag-xy md)) (+ x 150))) 50)
			(snd-display ";move mix: ~A ~A" (car xy) (car (mix-tag-xy md))))
		    (if (not (= (edit-position) (1+ eds)))
			(snd-display ";move mix edits: ~A ~A" eds (edit-position)))
		    (set! xy (mix-tag-xy md))
		    (click-event cwid 1 0 (+ (car xy) 1) (- (cadr xy) 2)) (force-event)
		    (set! (x-bounds) (list 0.0 (/ (frames) (srate))))
		    (set! (graph-style) graph-dots)
		    (update-time-graph)
		    (set! xy (mix-tag-xy md))
		    (set! x (+ (car xy) 1))
		    (set! y (- (cadr xy) 2))
		    (focus-widget cwid)
		    (drag-event cwid 1 0 x y (- x 150) y) (force-event)
		    (update-time-graph)
		    (set! (graph-style) graph-lines)
		    )
		  (let* ((mrk (add-mark 100))
			 (x (x->position (/ (mark-sample mrk) (srate))))
			 (y 10))
		    (click-event cwid 1 0 x y) (force-event)
		    (drag-event cwid 1 0 x y (+ x 150) y) (force-event)
		    (if (not (> (mark-sample mrk) 100))
			(snd-display ";move mark: 100 -> ~A, ~A -> ~A" (mark-sample mrk) x (x->position (/ (mark-sample mrk) (srate)))))
		    (let ((eds (edit-position))
			  (len (frames)))
		      (set! x (x->position (/ (mark-sample mrk) (srate))))
		      (drag-event cwid 1 4 x y (- x 200) y) (force-event)
		      (if (not (= (edit-position) (1+ eds)))
			  (snd-display ";C-drag mark edits: ~A ~A" eds (edit-position)))
		      (if (<= len (frames))
			  (snd-display ";C-drag mark len: ~A -> ~A" len (frames)))))
		  (revert-sound ind)
		  (key-event cwid (char->integer #\<) 4) (force-event)
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\1) 0) (force-event)
		  (key-event cwid (char->integer #\.) 0) (force-event)
		  (key-event cwid (char->integer #\0) 0) (force-event)
		  (key-event cwid (char->integer #\f) 4) (force-event)
		  (if (fneq (/ (cursor) (srate)) 1.0)
		      (snd-display ";C-u 1.0 C-f: ~A?" (/ (cursor) (srate))))
		  (let ((fr (frames)))
		    (key-event cwid (char->integer #\x) 4) (force-event)
		    (key-event cwid (char->integer #\i) 4) (force-event)
		    (widget-string minibuffer "oboe.snd")
		    (key-event minibuffer snd-return-key 0) (force-event)
		    (if (not (= (frames) (* 2 fr)))
			(snd-display ";C-x C-i oboe: ~A ~A" (* 2 fr) (frames)))
		    (if (fneq (sample 4000) (sample (+ (srate) 4000)))
			(snd-display ";inserted file: ~A ~A" (sample 4000) (sample (+ (srate) 4000))))
		    (let ((edit-pos (edit-position)))
		      (key-event cwid (char->integer #\x) 4) (force-event)
		      (key-event cwid (char->integer #\i) 4) (force-event)
		      (widget-string minibuffer "z.snd")
		      (key-event minibuffer snd-tab-key 0) (force-event)
		      (key-event minibuffer snd-return-key 0) (force-event)
		      (if (not (= (edit-position) edit-pos))
			  (snd-display ";C-x C-i empty file not a no-op?"))
		      (let ((str (widget-text minibuffer)))
			(if (not (string=? str "file z.snd has no data"))
			    (snd-display ";C-x C-i z.snd minibuffer text: ~A" str))))
		    (key-event cwid (char->integer #\x) 4) (force-event)
		    (key-event cwid (char->integer #\q) 4) (force-event)
		    (widget-string minibuffer "oboe.snd")
		    (key-event minibuffer snd-return-key 0) (force-event)
		    (if (not (= (frames) (* 2 fr)))
			(snd-display ";C-x C-q oboe: ~A ~A" (* 2 fr) (frames)))
		    (if (fneq (* 2 (sample 4000)) (sample (+ (srate) 4000)))
			(snd-display ";mixed file: ~A ~A" (* 2 (sample 4000)) (sample (+ (srate) 4000)))))
		  (set! (cursor) 0)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\j) 4) (force-event)
		  (if (not (= (cursor) (srate)))
		      (snd-display ";C-x C-j: ~A?" (cursor)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (if (not (equal? (edits) (list 1 1)))
		      (snd-display ";C-x C-u: ~A?" (edits)))
		  (set! (x-bounds) (list .3 .4))
		  (update-time-graph)
		  (key-event cwid (char->integer #\l) 4) (force-event)	
		  (update-time-graph)
		  (if (fneq (/ (cursor) (srate)) (/ (* .5 (+ (left-sample) (right-sample))) (srate)))
		      (snd-display ";C-l: ~A ~A (~A: ~A ~A of ~A in ~A)?" 
				   (/ (cursor) (srate))
				   (/ (* .5 (+ (left-sample) (right-sample))) (srate))
				   (cursor)
				   (left-sample)
				   (right-sample)
				   (selected-sound)
				   (sounds)))
		  )
		
		;; named macro
		(let ((fr (frames)))
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\() 1) (force-event)
		  (key-event cwid (char->integer #\d) 4) (force-event)
		  (key-event cwid (char->integer #\d) 4) (force-event)
		  (key-event cwid (char->integer #\d) 4) (force-event)
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\)) 1) (force-event)
		  
		  (key-event cwid (char->integer #\x) 4) (force-event)
		  (key-event cwid (char->integer #\e) 4) (force-event)
		  (widget-string minibuffer "a-name")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (= (frames) (- fr 3))) (snd-display ";macro definition wasn't effective?: ~A ~A" fr (frames)))
		  
		  (key-event cwid (char->integer #\x) 8) (force-event)
		  (widget-string minibuffer "a-name")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (= (frames) (- fr 6))) (snd-display ";macro call wasn't effective?: ~A ~A" fr (frames)))
		  
		  (key-event cwid (char->integer #\u) 4) (force-event)
		  (key-event cwid (char->integer #\4) 0) (force-event)
		  (key-event cwid (char->integer #\x) 8) (force-event)
		  (widget-string minibuffer "a-name")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (= (frames) (- fr 6 12))) (snd-display ";4 x macro call wasn't effective?: ~A ~A" fr (frames))))
		
		(set! (widget-text minibuffer) "")
		(key-event cwid (char->integer #\x) 8) (force-event)
		(widget-string minibuffer "(short-")
		(key-event minibuffer snd-tab-key 0) (force-event)
		(append-to-minibuffer ")")
		(key-event minibuffer snd-return-key 0) (force-event)
		(let ((str (widget-text minibuffer)))
		  (if (not (string=? str "\"oboe.snd\""))
		      (snd-display ";completed mini: ~A" str)))
		(set! (widget-text minibuffer) "")
		(focus-widget minibuffer)
		(key-event minibuffer (char->integer #\j) 4) (force-event)
		(let ((str (widget-text minibuffer)))
		  (if (not (string=? str " C-j"))
		      (snd-display ";C-j mini: [~A]" str)))
		(revert-sound ind)
		
		(dismiss-all-dialogs)
		(click-button name-button) (force-event)
		(take-keyboard-focus name-button)
		(key-event name-button (char->integer #\x) 4) (force-event)
		(key-event name-button (char->integer #\f) 4) (force-event)
		(focus-widget minibuffer)
		(widget-string minibuffer "pistol.snd")
		(key-event minibuffer snd-return-key 0) (force-event)
		(if (not (= (length (sounds)) 2))
		    (snd-display ";C-x C-f -> ~A: ~A?" (sounds) (map short-file-name (sounds))))
		(backward-graph)
		(take-keyboard-focus name-button)
		(key-event name-button (char->integer #\x) 4) (force-event)
		(key-event name-button (char->integer #\k) 0) (force-event)
		(if (not (= (length (sounds)) 1))
		    (snd-display ";C-x k -> ~A: ~A?" (sounds) (map short-file-name (sounds))))
		(if (not (string=? (short-file-name (car (sounds))) "pistol.snd"))
		    (snd-display ";backgraph + kill: ~A?" (short-file-name (car (sounds)))))
		(set! swids (sound-widgets))
		(set! name-button (list-ref swids 1))
		(set! minibuffer (list-ref swids 3))
		(set! play-button (list-ref swids 4))
		(set! cwid (car (channel-widgets)))
		(let ((curmax (maxamp)))
		  (take-keyboard-focus name-button)
		  (key-event name-button (char->integer #\x) 4) (force-event)
		  (key-event name-button (char->integer #\a) 4) (force-event)
		  (widget-string minibuffer "'(0 .5 1 .5)")
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (not (equal? (edits) '(1 0)))
		      (snd-display ";C-x C-a (edits) -> ~A?" (edits)))
		  (if (fneq (maxamp) (* .5 curmax))
		      (snd-display ";C-x C-a (amp) -> ~A ~A?" (maxamp) (* .5 curmax)))
		  (let ((grf (car (channel-widgets))))
		    (take-keyboard-focus grf)
		    (key-event grf (char->integer #\_) 5) (force-event)
		    (if (not (equal? (edits) '(0 1)))
			(snd-display ";C-x _ (edits) -> ~A?" (edits)))
		    (if (fneq (maxamp) curmax)
			(snd-display ";C-x _ (amp) -> ~A ~A?" (maxamp) curmax))))

		(dismiss-all-dialogs)
		(let ((tmp (temp-dir)))
		  (key-event name-button (char->integer #\x) 4) (force-event)
		  (key-event name-button (char->integer #\d) 0) (force-event)
		  (widget-string minibuffer (string-append home-dir "/snd-7"))
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (or (not (string? (temp-dir)))
			  (not (string=? (temp-dir) (string-append home-dir "/snd-7"))))
		      (snd-display ";temp-dir via prompt: ~A?" (temp-dir)))
		  (key-event name-button (char->integer #\x) 4) (force-event)
		  (key-event name-button (char->integer #\d) 0) (force-event)
		  (widget-string minibuffer (string-append home-dir "/root"))
		  (key-event minibuffer snd-return-key 0) (force-event)
		  (if (or (not (string? (temp-dir)))
			  (not (string=? (temp-dir) (string-append home-dir "/snd-7"))))
		      (snd-display ";temp-dir via prompt after /root: ~A?" (temp-dir)))
		  (set! (temp-dir) tmp)
		  (if (not (equal? (temp-dir) tmp))
		      (snd-display ";temp-dir reset: ~A ~A?" (temp-dir) tmp)))
		
		(set! (cursor) 4000)
		(take-keyboard-focus name-button)
		(key-event name-button (char->integer #\x) 4) (force-event)
		(key-event name-button (char->integer #\m) 4) (force-event)
		(widget-string minibuffer "hiho!")
		(key-event minibuffer snd-return-key 0) (force-event)
		(let ((m (find-mark 4000)))
		  (if (or (not (mark? m))
			  (not (string=? (mark-name m) "hiho!")))
		      (snd-display ";named mark prompt: ~A ~A" m (if (mark? m) (mark-name m) "no name"))))
		
		(key-event cwid (char->integer #\g) 4) (force-event)	
		(close-sound (car (sounds)))
		))
	    
	    (let* ((ind (open-sound "4.aiff"))
		   (wbutton (list-ref (channel-widgets ind 0) 1))
		   (fbutton (list-ref (channel-widgets ind 0) 2))
		   (grf (car (channel-widgets ind 0))))
	      (XSynchronize (XtDisplay (cadr (main-widgets))) #t)
	      (set! (channel-style ind) channels-combined)
	      (click-button fbutton #t 0)
	      (click-button wbutton #f 0)
	      (if (time-graph? ind 1) (snd-display ";time graphs: ~A ~A" (time-graph? ind 0) (time-graph? ind 1)))
	      (if (not (transform-graph? ind 1)) (snd-display ";transform graphs: ~A ~A" (transform-graph? ind 0) (transform-graph? ind 1)))
	      (let ((xy (widget-size grf)))
		(click-event grf 1 0 (inexact->exact (floor (* .65 (car xy)))) (inexact->exact (floor (* .35 (cadr xy)))))
		(click-event grf 1 0 (inexact->exact (floor (* .15 (car xy)))) (inexact->exact (floor (* .65 (cadr xy))))))
	      (set! (channel-style ind) channels-separate)
	      (click-button fbutton #f 4)
	      (click-button wbutton #t 4)
	      (XSynchronize (XtDisplay (cadr (main-widgets))) #f)
	      (close-sound ind))
	    
	    (let* ((ind0 (open-sound "oboe.snd"))
		   (ind1 (open-sound "pistol.snd"))
		   (cwid (car (channel-widgets ind0 0))))
	      (set! (sync ind1) 1)
	      (set! (sync ind0) 1)
	      (set! (cursor) 100)
	      (select-sound ind0)
	      (select-channel 0)
	      (take-keyboard-focus cwid)
	      (key-event cwid (char->integer #\M) 5) (force-event)
	      (let* ((m0 (marks ind0 0))
		     (m1 (marks ind1 0))
		     (mm0 (if (list-p m0) (car m0) -1))
		     (mm1 (if (list-p m1) (car m1) -1)))
		(if (or (not (= (length m0) (length m1)))
			(not (= (length m0) 1)))
		    (snd-display ";sync'd C-M: ~A ~A" m0 m1)
		    (if (not (= (mark-sample mm0) (mark-sample mm1)))
			(snd-display ";sync'd C-m: ~A ~A" (mark-sample mm0) (mark-sample mm1))
			(let* ((x (x->position (/ (mark-sample mm0) (srate))))
			       (y 10))
			  (click-event cwid 1 0 x y) (force-event)
			  (drag-event cwid 1 0 x y (+ x 150) y) (force-event)
			  (if (not (> (mark-sample mm0) 100))
			      (snd-display ";move syncd mark0: 100 -> ~A, ~A -> ~A" (mark-sample mm0) x (x->position (/ (mark-sample mm0) (srate)))))
			  (if (not (> (mark-sample mm1) 100))
			      (snd-display ";move syncd mark1: 100 -> ~A, ~A -> ~A" (mark-sample mm1) x (x->position (/ (mark-sample mm1) (srate)))))
			  (let ((eds0 (edit-position ind0 0))
				(eds1 (edit-position ind1 0))
				(len0 (frames ind0 0))
				(len1 (frames ind1 0)))
			    (dismiss-all-dialogs)
			    (set! x (x->position (/ (mark-sample mm0) (srate))))
			    (drag-event cwid 1 4 x y (- x 200) y) (force-event)
			    (if (not (= (edit-position ind0 0) (1+ eds0)))
				(snd-display ";C-drag syncd mark edits0: ~A ~A (x: ~A)" eds0 (edit-position ind0 0) x))
			    (if (<= len0 (frames ind0 0))
				(snd-display ";C-drag mark len0: ~A -> ~A" len0 (frames ind0 0)))
			    (if (not (= (edit-position ind1 0) (1+ eds1)))
				(snd-display ";C-drag syncd mark edits1: ~A ~A" eds1 (edit-position ind1 0)))
			    (if (<= len1 (frames ind1 0))
				(snd-display ";C-drag mark len1: ~A -> ~A" len1 (frames ind1 0))))))))
	      
	      (close-sound ind1)
	      (catch #t (lambda () 
			  (key-event cwid (char->integer #\x) 4) (force-event)
			  (key-event cwid (char->integer #\a) 0) (force-event))
		     (lambda args (car args)))
	      (key-event cwid snd-home-key 0) (force-event)
	      (close-sound ind0))
	    
	    (let* ((ind (open-sound "2.snd"))
		   (c0 (frames ind 0))
		   (c1 (frames ind 1))
		   (mx0 (maxamp ind 0))		   
		   (mx1 (maxamp ind 1))
		   (swids (sound-widgets))
		   (cwids (channel-widgets ind 1))
		   (cwid (car cwids))
		   (cw (cadr cwids))
		   (cf (caddr cwids))
		   (minibuffer (list-ref swids 3)))
	      (select-sound ind)
	      (select-channel 1)
	      (click-button cf #t) (force-event)
	      (if (not (transform-graph? ind 1)) (snd-display ";cf click but not fft"))
	      (click-button cw #f) (force-event)
	      (if (time-graph? ind 1) (snd-display ";cw click but still time"))
	      (click-button cf #f 4) (force-event)
	      (click-button cw #t) (force-event)
	      (click-button (list-ref swids 6) #t)
	      (set! (channel-style ind) channels-combined)
	      (set! cwids (channel-widgets ind 0)) ; pick up gsy etc
	      ;; drag changed inc/dec for zy sy zx xy, drag changed for gz gsy
	      ;; 3:sx 4:sy 5:zx 6:zy 7:edhist)
	      (set! (zoom-focus-style) zoom-focus-active)
	      (let ((sx (list-ref cwids 3))
		    (sy (list-ref cwids 4))
		    (zx (list-ref cwids 5))
		    (zy (list-ref cwids 6))
		    (gsy (list-ref cwids 8))
		    (gzy (list-ref cwids 9)))
		(if (or (not (Widget? gsy)) (not (XtIsManaged gsy))) (snd-display ";unite but no gsy?"))
		(if (or (not (Widget? gzy)) (not (XtIsManaged gzy))) (snd-display ";unite but no gzy?"))
		(for-each
		 (lambda (scrl)
		   (XtCallCallbacks scrl XmNvalueChangedCallback
				    (let ((cb (XmScrollBarCallbackStruct)))
				      (set! (.value cb) 75)
				      (set! (.event cb) (XEvent))
				      cb))
		   (XtCallCallbacks scrl XmNincrementCallback
				    (let ((cb (XmScrollBarCallbackStruct)))
				      (set! (.event cb) (XEvent))
				      cb))
		   (XtCallCallbacks scrl XmNdecrementCallback
				    (let ((cb (XmScrollBarCallbackStruct)))
				      (set! (.event cb) (XEvent))
				      cb))
		   (XtCallCallbacks scrl XmNdragCallback
				    (let ((cb (XmScrollBarCallbackStruct)))
				      (set! (.value cb) 65)
				      (set! (.event cb) (XEvent))
				      cb)))
		 (list sx zx zy))
		(if (and (Widget? gsy) (Widget? gzy))
		    (for-each
		     (lambda (scrl)
		       (XtCallCallbacks scrl XmNvalueChangedCallback
					(let ((cb (XmScrollBarCallbackStruct)))
					  (set! (.value cb) 75)
					  (set! (.event cb) (XEvent))
					  cb))
		       (XtCallCallbacks scrl XmNdragCallback
					(let ((cb (XmScrollBarCallbackStruct)))
					  (set! (.value cb) 65)
					  (set! (.event cb) (XEvent))
					  cb)))
		     (list gsy gzy))))
	      (click-button (list-ref swids 6) #f)
	      (click-button (list-ref swids 9) #t)
	      (if (= (sync) 0) (snd-display ";click sync?"))
	      (click-button (list-ref swids 9) #f)
	      (enter-event cwid) (force-event)
	      (leave-event cwid) (force-event)
	      (set! (show-controls ind) #t)
	      (let* ((ctrls (list-ref swids 2)))
		(for-each
		 (lambda (label)
		   (click-button label #t ControlMask)
		   (click-button label #t 0))
		 (map 
		  (lambda (name)
		    (find-child ctrls name))
		  (list "amp-label" "speed-label" "contrast-label" "expand-label" "revlen-label" "revscl-label" )))
		(for-each
		 (lambda (scrl)
		   (XtCallCallbacks scrl XmNdragCallback
				    (let ((cb (XmScrollBarCallbackStruct)))
				      (set! (.value cb) 50)
				      (set! (.event cb) (XEvent))
				      cb)))
		 (map 
		  (lambda (name)
		    (find-child ctrls name))
		  (list "speed-scroll" "expand-scroll" "contrast-scroll" "revscl-scroll" "revlen-scroll")))
		(click-button (find-child ctrls "fltdB") #t)
		(let ((flttxt (find-child ctrls "filter-text")))
		  (take-keyboard-focus flttxt)
		  (widget-string flttxt "'(0 0 1 1 2 0)")
		  (key-event flttxt snd-return-key 0) (force-event))
		(let ((fltord (find-child ctrls "filter-order")))
		  (take-keyboard-focus fltord)
		  (widget-string fltord "40")
		  (key-event fltord snd-return-key 0) (force-event))
		(click-button (list-ref swids 4) #t ControlMask)
		(click-button (list-ref swids 4) #f 0)
		(equalize-panes))
	      (set! (show-controls ind) #f)
	      (select-sound ind)
	      (select-channel 1)
	      (delete-sample 0)
	      (XtCallCallbacks (menu-option "Revert") XmNactivateCallback (snd-global-state))
	      (if (> (edit-position ind 1) 0)
		  (begin
		    (snd-display ";activate Revert menu: ~A" (edit-position ind 1))
		    (revert-sound ind)))
	      (XtCallCallbacks (menu-option "Redo    C-x C-r") XmNactivateCallback (snd-global-state))
	      (if (not (= (edit-position ind 1) 1))
		  (snd-display ";activate Redo menu: ~A (~A)" (edit-position ind 1) (menu-option "Redo    C-x C-r")))
	      (XtCallCallbacks (menu-option "Undo    C-x C-u") XmNactivateCallback (snd-global-state))
	      (if (not (= (edit-position ind 1) 0))
		  (snd-display ";activate Undo menu: ~A" (edit-position ind 1)))
	      (copy-file "oboe.snd" "fmv1.snd")
	      (if (file-exists? "fmv1.snd")
		  (begin
		    (if (not (= (mus-sound-frames "fmv1.snd") 50828))
			(snd-display ";C-x w wrote wrong number of samples: ~A" (mus-sound-frames "fmv1.snd")))
		    (let* ((ind2 (open-sound "fmv1.snd"))
			   (cwid2 (car (channel-widgets ind2 0))))
		      (select-sound ind2)
		      (delete-samples 0 1000)
		      (snd-simulate-keystroke ind2 0 (char->integer #\x) 4)
		      (snd-simulate-keystroke ind2 0 (char->integer #\s) 4)
		      (if (not (equal? (edits ind2) (list 0 0))) (snd-display ";C-s (save) edits: ~A" (edits ind2)))
		      (if (not (= (mus-sound-frames "fmv1.snd") (- 50828 1000)))
			  (snd-display ";C-x C-s wrote wrong number of samples: ~A" (mus-sound-frames "fmv1.snd")))
		      (key-event cwid2 (char->integer #\x) 4) (force-event)
		      (key-event cwid2 (char->integer #\z) 0) (force-event)
		      (let ((str (widget-text (list-ref (sound-widgets ind2) 3))))
			(if (not (string=? str "no active selection"))
			    (snd-display ";C-x z report-in-minibuffer: ~A?" str)))
		      (XtCallCallbacks (menu-option "Save options") XmNactivateCallback (snd-global-state))
		      (if (file-exists? (string-append home-dir "/dot-snd"))
			  (system (string-append "cp " home-dir "/dot-snd " home-dir "/.snd")))
		      (XtCallCallbacks (menu-option "Select all") XmNactivateCallback (snd-global-state))
		      (if (not (selection?))
			  (snd-display ";Select all menu option failed?"))
		      (XtCallCallbacks (menu-option "Delete Selection") XmNactivateCallback (snd-global-state))
		      (if (not (= (frames) 0))
			  (snd-display ";Delete Selection menu option failed? ~A" (frames)))
		      (XtCallCallbacks (menu-option "Revert") XmNactivateCallback (snd-global-state))
		      (if (= (frames) 0)
			  (snd-display ";Revert menu option failed? ~A" (frames)))
		      (for-each 
		       (lambda (name style)
			 (XtCallCallbacks (menu-option name) XmNactivateCallback (snd-global-state))
			 (if (not (= (graph-style) style)) (snd-display ";graph-style ~A: ~A" name (graph-style))))
		       (list "dots" "filled" "dots and lines" "lollipops" "lines")
		       (list graph-dots graph-filled graph-dots-and-lines graph-lollipops graph-lines))
		      (for-each 
		       (lambda (name style)
			 (XtCallCallbacks (menu-option name) XmNactivateCallback (snd-global-state))
			 (if (not (= (x-axis-style) style)) (snd-display ";x-axis style ~A: ~A" name (x-axis-style))))
		       (list "samples" "percentage" "beats" "seconds")
		       (list x-axis-in-samples x-axis-as-percentage x-axis-in-beats x-axis-in-seconds))
		      (set! (cursor) 50)
		      (for-each
		       (lambda (name style)
			 (XtCallCallbacks (menu-option name) XmNactivateCallback (snd-global-state))
			 (if (not (= (zoom-focus-style) style)) (snd-display ";zoom-focus style ~A: ~A" name (zoom-focus-style))))
		       (list "window left edge" "window right edge" "window midpoint" "cursor or selection")
		       (list zoom-focus-left zoom-focus-right zoom-focus-middle zoom-focus-active))
		      (XtCallCallbacks (menu-option "Close  C-x k") XmNactivateCallback (snd-global-state))
		      (if (find-sound "fmv1.snd") 
			  (begin
			    (snd-display ";activate menu ~A -> ~A" (menu-option "Close  C-x k") (find-sound "fmv1.snd"))
			    (close-sound ind2))))))
	      (let ((ind2 (open-sound "4.aiff")))
		(set! (channel-style ind2) channels-combined)
		(XtCallCallbacks (menu-option "Equalize Panes") XmNactivateCallback (snd-global-state))
		(equalize-panes ind2)
		(for-each 
		 (lambda (name style)
		   (XtCallCallbacks (menu-option name) XmNactivateCallback (snd-global-state))
		   (if (not (= (channel-style) style)) (snd-display ";channel style ~A: ~A" name (channel-style))))
		 (list "combined" "superimposed" "separate")
		 (list channels-combined channels-superimposed channels-separate))
		(close-sound ind2))
	      (if (file-exists? "fmv1.snd")
		  (begin
		    (delete-file "fmv1.snd")
		    (mus-sound-forget "fmv1.snd")))
	      (if (not (sound? ind)) (set! ind (open-sound "4.aiff")))
	      (select-sound ind)
	      (select-channel 1)
	      (set! (selection-member? #t) #f)
	      (widget-string minibuffer "")
	      (set! (lisp-graph? ind 1) #t)
	      (set! (time-graph? ind 1) #f)
	      (set! (transform-graph? ind 1) #f)
	      (graph '(0 0 1 1 2 0) "hi" 0.0 1.0 0.0 1.0 ind 1)
	      (let ((key #f)
		    (state #f)
		    (snd #f)
		    (chn #f))
		(add-hook! key-press-hook (lambda (snd1 chn1 key1 state1)
					    (set! snd snd1)
					    (set! chn chn1)
					    (set! key key1)
					    (set! state state1)
					    #f))
		(let ((ax (axis-info ind 1 lisp-graph)))
		  (focus-widget cwid)
		  (key-event-with-mouse cwid (char->integer #\f) 4
					(inexact->exact (floor (* .5 (+ (list-ref ax 10) (list-ref ax 12)))))
					;(- (list-ref ax 12) 10)
					(inexact->exact (floor (* .5 (+ (list-ref ax 11) (list-ref ax 13)))))))
		(force-event)
		(reset-hook! key-press-hook)
		(if (or (not (number? snd)) (not (= snd ind))
			(not (number? chn)) (not (= chn 1))
			(not (number? key)) (not (= key (char->integer #\f)))
			(not (number? state)) (not (= state 4)))
		    (snd-display ";key-press-hook: ~A ~A ~A ~A, ~A ~A ~A ~A (~A)"
				 snd chn key state
				 ind 1 (char->integer #\f) 4
				 (axis-info ind 1 lisp-graph))))
	      (if (provided? 'snd-debug)
		  (for-each
		   (lambda (sash)
		     (if (Widget? sash)
			 (drag-event sash 1 0 1 1 1 100)))
		   (top-sash)))
	      (close-sound ind))
	    
	    ;; -------- filter envelope editor
	    (let* ((ind (open-sound "oboe.snd"))
		   (swids (sound-widgets))
		   (filter-grf (list-ref swids 5)))
	      (set! (show-controls ind) #t)
	      (set! (filter-control-order ind) 20)
	      (let ((fe (filter-control-envelope ind)))
		(if (not (equal? fe '(0.0 1.0 1.0 1.0)))
		    (snd-display ";filter-env (initial): ~A?" fe))
		(if (not (vequal (filter-control-coeffs ind)
				 (vct -0.004 0.012 -0.021 0.031 -0.043 0.059 -0.082 0.121 -0.208 0.635 
				      0.635 -0.208 0.121 -0.082 0.059 -0.043 0.031 -0.021 0.012 -0.004)))
		    (snd-display ";filter-control-coeffs: ~A?" (filter-control-coeffs ind)))
		(let ((psize (widget-size filter-grf)))
		  (if (< (cadr psize) 100)
		      (begin
			(set! (window-height) 800)
			(resize-pane (list-ref swids 0) 600)
			(resize-pane (list-ref swids 2) 400)))
		  (set! (widget-size filter-grf) (list (car psize) (+ (cadr psize) 10))))
		(force-event)
		;; can't click filter graph at random because callbacks assume sp passed as context
		(set! (filter-control-in-dB) #t)
		(close-sound ind)
		))
	    
	    ;; -------- recorder dialog
	    (if (provided? 'snd-debug)
		(begin
		  (add-hook! recorder-file-hook
			     (lambda (name)
			       (let* ((header (recorder-out-type))
				      (extension (if (or (= header mus-aifc) (= header mus-aiff)) ".aif"
						     (if (= header mus-next) ".snd"
							 ".wav"))))
				 (if name
				     (let ((len (string-length name)))
				       (do ((i 0 (1+ i)))
					   ((or (= i len)
						(char=? (string-ref name i) #\.))
					    (string-append (if (> i 1)
							       (substring name 0 i)
							       "test")
							   extension))))
				     (string-append "test" extension)))))
		  (let ((wid (recorder-dialog)))
		    (if (not (equal? wid (list-ref (dialog-widgets) 18)))
			(snd-display ";recorder-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 18))))
		  (let* ((recd (list-ref (dialog-widgets) 18)))
		    (if recd ; /dev/mixer trouble sometimes here
			(let* ((record-button (find-child recd "record-button"))
			       (reset-button (XmMessageBoxGetChild recd XmDIALOG_CANCEL_BUTTON))
			       (dismiss-button (XmMessageBoxGetChild recd XmDIALOG_OK_BUTTON))
			       (panes (find-child recd "rec-panes"))
			       (file-pane (find-child panes "file-pane"))
			       (fdata (find-child file-pane "file-data"))
			       (ff (find-child fdata "ff-form"))
			       (file-text (find-child ff "text"))
			       (buttons '())
			       (sliders '())
			       (numbers '()))
			  (for-each-child recd (lambda (w) 
						 (if (and (XmIsPushButton w) 
							  (or (string=? (XtName w) "A")
							      (string=? (XtName w) " ")
							      (string=? (XtName w) "/")
							      (string=? (XtName (XtParent w)) "data")))
						     (set! buttons (cons w buttons)))
						 (if (and (XmIsPushButton w) 
							  (string=? (XtName w) "recorder-amp-number")) 
						     (set! numbers (cons w numbers)))
						 (if (and (XmIsScrollBar w) 
							  (or (string=? (XtName w) "amp")
							      (string=? (XtName w) "trigger-scale")))
						     (set! sliders (cons w sliders)))))
			  (XmTextSetString file-text "fmv.snd")
			  (for-each (lambda (w) (click-button w #t)) buttons)
			  (for-each (lambda (w) (click-button w #t)) numbers)
			  (for-each
			   (lambda (w)
			     (XtCallCallbacks w XmNdragCallback
					      (let ((cb (XmScrollBarCallbackStruct)))
						(set! (.value cb) 65)
						(set! (.event cb) (XEvent))
						cb)))
			   sliders)
			  (set! (with-background-processes) #t)
			  (click-button record-button #t)
			  (click-button record-button #f)
			  (click-button record-button #t)
			  (click-button reset-button #t)
			  (set! (with-background-processes) #f)
			  (if (and (string? (recorder-file))
				   (not (string=? (recorder-file) (string-append (getcwd) "/fmv.wav"))))
			      (snd-display ";recorder-file after hook: ~A" (recorder-file)))
			  (reset-hook! recorder-file-hook)
			  (click-button reset-button)
			  (for-each-child recd (lambda (w)
						 (if (or (XmIsText w)
							 (XmIsTextField w))
						     (begin
						       (widget-string w "1")
						       (key-event w snd-return-key 0)
						       (force-event))
						     (if (and (XmIsLabel w)
							      (or (string=? (XtName w) "i")
								  (string=? (XtName w) "n")
								  (string=? (XtName w) "out")))
							 (begin
							   (drag-event w 1 0 0 0 50 10)
							   (force-event))))))
			  (click-button dismiss-button))))))
	    
	    ;; -------- edit find dialog
	    
	    (let ((wid (find-dialog)))
	      (if (not (equal? wid (list-ref (dialog-widgets) 13)))
		  (snd-display ";find-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 13))))
		  (let* ((find-widgets (find-dialog-widgets))
			 (ind (open-sound "oboe.snd"))
			 (text-widget (cadr find-widgets))
			 (next-button (list-ref find-widgets 2))
			 (previous-button (list-ref find-widgets 3))
			 (cancel-button (list-ref find-widgets 4)))
		    
		    (widget-string text-widget "(lambda (n8) (> n8 .1))")
		    (key-event text-widget snd-return-key 0) (force-event)
		    (if (or (not (= (cursor) 4423))
			    (not (> (sample (cursor)) .1)))
			(snd-display ";edit find <cr>: ~A ~A" (cursor) (sample (cursor))))
		    (click-button next-button) (force-event)
		    (if (or (not (= (cursor) 4463))
			    (not (> (sample (cursor)) .1)))
			(snd-display ";edit find (1): ~A ~A" (cursor) (sample (cursor))))
		    (click-button previous-button) (force-event)
		    (if (or (not (= (cursor) 4423))
			    (not (> (sample (cursor)) .1)))
			(snd-display ";edit find (2): ~A ~A" (cursor) (sample (cursor))))
		    (do ((i 0 (1+ i)))
			((= i 10))
		      (click-button next-button) (force-event)
		      (if (not (> (sample (cursor)) .1))
			  (snd-display ";edit find (~A): ~A ~A" (+ i 3) (cursor) (sample (cursor)))))
		    (if (not (= (cursor) 4741))
			(snd-display ";edit find end: ~A?" (cursor)))
		    (set! (cursor) 0)
		    (widget-string text-widget "(lambda (n) (> n 1.1))")
		    (key-event text-widget snd-return-key 0) (force-event)
		    (if (not (= (cursor) 0))
			(snd-display ";edit no find: ~A?" (cursor)))
		    (widget-string text-widget "(lambda (n9) (if (> n9 .1) 1 #f))")
		    (key-event text-widget snd-return-key 0) (force-event)
		    (if (not (> (sample (max 0 (1- (cursor)))) .1))
			(snd-display ";find 1 past .1: ~A ~A ~A, ~A" 
				     (cursor) (sample (max 0 (1- (cursor)))) (sample (cursor))
				     (find (lambda (y) (> y .1)) 0)))
		    (click-button cancel-button) (force-event)
		    (close-sound ind))
	    
	    ;; -------- envelope editor
	    (if (defined? 'enved-dialog-widgets)
		(begin
		  (enved-dialog)
		  (force-event)
		  (let* ((enved-widgets (enved-dialog-widgets))
			 (drawer (cadr enved-widgets))
			 (apply-button (list-ref enved-widgets 4))
			 (undo-apply-button (list-ref enved-widgets 5))
			 (text-widget (list-ref enved-widgets 3))
			 (show-button (list-ref enved-widgets 7))
			 (save-button (list-ref enved-widgets 8))
			 (dismiss-button (list-ref enved-widgets 6))
			 (reset-button (list-ref enved-widgets 23))
			 (revert-button (list-ref enved-widgets 9))
			 (undo-button (list-ref enved-widgets 10))
			 (redo-button (list-ref enved-widgets 11))
			 (print-button (list-ref enved-widgets 12))
			 (graph-button (list-ref enved-widgets 13))
			 (flt-button (list-ref enved-widgets 14))
			 (amp-button (list-ref enved-widgets 15))
			 (src-button (list-ref enved-widgets 16))
			 (clip-button (list-ref enved-widgets 17))
			 (dB-button (list-ref enved-widgets 18))
			 (delete-button (list-ref enved-widgets 19))
			 (exp-button (list-ref enved-widgets 20))
			 (lin-button (list-ref enved-widgets 21))
			 (env-list (list-ref enved-widgets 24))
			 (fir-button (list-ref enved-widgets 25)) ; proc button is 26
			 (ewid drawer)
			 (senv #f))
		    (click-button reset-button) (force-event)
		    (select-item env-list 1) (force-event)
		    (set! senv (enved-envelope))
		    (click-event ewid 1 0 (enved-x 0.5) (enved-y 1.0)) (force-event)
		    (widget-string text-widget "new-env")
		    (click-button save-button) (force-event)
		    (if (not (defined? 'new-env))
			(snd-display ";save new-env failed?")
			(if (not (ffeql new-env (list 0.0 0.0 0.5 1.0 1.0 1.0)))
			    (snd-display ";saved new-env: ~A?" new-env)))
		    (click-event ewid 1 0 (enved-x 0.5) (enved-y 1.0)) (force-event)
		    (let ((active-env (enved-envelope)))
		      (if (not (ffeql active-env (list 0.0 0.0 1.0 1.0)))
			  (snd-display ";enved mid-click to delete: ~A?" active-env)))
		    (set! (enved-base) 1.0)
		    
		    (do ((i 0 (1+ i)))
			((= i 50))
		      (click-event ewid 1 0 (enved-x (random 0.999)) (enved-y (random 1.0))) (force-event)
		      (click-event ewid 1 0 (enved-x (random 0.999)) (enved-y (random 1.0))) (force-event)
		      (let* ((e (enved-envelope))
			     (len (length e)))
			(if (> len 4)
			    (let* ((pos (+ 2 (random (- len 4))))
				   (rx (list-ref e (if (odd? pos) (- pos 1) pos)))
				   (ry (list-ref e (if (odd? pos) pos (+ pos 1)))))
			      (click-event ewid 1 0 (enved-x rx) (enved-y ry)) (force-event)
;			      (if (>= (length (enved-envelope)) (length e))
;				  (snd-display "; enved loop missed a hit ~A ~A ~A" (enved-x rx) (enved-y ry) (enved-axis-info)))
			      ))))
		    (let ((len (length (enved-envelope))))
		      (do ((i 0 (1+ i)))
			  ((= i 10))
			(if (XtIsSensitive undo-button)
			    (begin 
			      (click-button undo-button) (force-event)
			      (click-button undo-button) (force-event)))
			(if (XtIsSensitive redo-button)
			    (begin 
			      (click-button redo-button) (force-event)))))
		    (if (XtIsSensitive revert-button)
			(begin
			  (click-button revert-button) (force-event)))
		    (click-button clip-button) (force-event)
		    (click-button clip-button) (force-event)
		    (do ((i 0 (1+ i)))
			((= i 50))
		      (click-event ewid 1 0 (enved-x (random 0.999)) (enved-y (random 1.0))) (force-event)
		      (if (> (random 1.0) .5) 
			  (begin
			    (if (XtIsSensitive undo-button)
				(begin
				  (click-button undo-button) (force-event)
				  (if (> (random 1.0) 0.5)
				      (begin
					(if (XtIsSensitive redo-button)
					    (begin
					      (click-button redo-button) (force-event)))))))))
		      (click-event ewid 1 0 (enved-x (random 0.999)) (enved-y (random 1.0))) (force-event)
		      (if (> (random 1.0) .9) (begin (click-button save-button) (force-event)))
		      (if (> (random 1.0) .9) (begin (click-button print-button) (force-event)))
		      (if (> (random 1.0) .9) (begin (click-button dB-button) (force-event)))
		      (if (> (random 1.0) .9) (begin (set! (enved-base) 0.0) (click-button exp-button) (force-event)))
		      (if (> (random 1.0) .9) (begin (set! (enved-base) (random 2.0)) (click-button exp-button) (force-event)))
		      (if (> (random 1.0) .9) (begin (click-button lin-button) (force-event)))
		      (let* ((e (enved-envelope)))
			(if (> (length e) 4)
			    (let* ((pos (+ 2 (random (- (length e) 4))))
				   (rx (list-ref e (if (odd? pos) (- pos 1) pos)))
				   (ry (list-ref e (if (odd? pos) pos (+ pos 1)))))
			      (click-event ewid 1 0 (enved-x rx) (enved-y ry))
			      (force-event)))))
		    (if (XtIsSensitive revert-button)
			(begin
			  (click-button revert-button) (force-event)))
		    (click-event ewid 1 0 (enved-x (random 0.999)) (enved-y (random 1.0))) (force-event)
		    (drag-event drawer 1 0 10 10 100 100)
		    (click-button reset-button) (force-event)
		    
		    (let* ((ind (open-sound "oboe.snd"))
			   (fr (frames ind)))
		      (click-button graph-button #t) (force-event)
		      (if (not (enved-wave?)) 
			  (begin
			    (set! (enved-wave?) #t)
			    (snd-display "; had to set enved-wave? by hand")))
		      
		      (widget-string text-widget "'(0 0 .5 1 1 0)") (force-event)
		      (key-event text-widget snd-return-key 0) (force-event)
		      
		      (set! (transform-size ind 0) 65536)
		      (set! (transform-graph? ind 0) #t)
		      (click-button flt-button) (force-event)
		      (if (not (= (enved-target) enved-spectrum))
			  (snd-display ";click flt button but target: ~A" (enved-target)))
		      (click-button src-button) (force-event)
		      (if (not (= (enved-target) enved-srate))
			  (snd-display ";click src button but target: ~A" (enved-target)))
		      (click-button amp-button) (force-event)
		      (if (not (= (enved-target) enved-amplitude))
			  (snd-display ";click flt button but target: ~A" (enved-target)))
		      (apply-enved)
		      (if (not (equal? (edits ind) '(1 0)))
			  (snd-display ";apply amp: ~A?" (edits ind)))
		      (catch 'no-such-edit
			     (lambda ()
			       (if (not (equal? (edit-fragment 1) 
						(list "env-channel '(0.000 0.000 0.500 1.000 1.000 0.000) 0 #f"
						      "env" 25415 25413)))
				   (snd-display ";apply amp fragment: ~A?" (edit-fragment 1))))
			     (lambda args (snd-display ";enved apply failed")))
		      (click-event ewid 1 0 (enved-x 0.25) (enved-y 1.0)) (force-event)
		      (click-button undo-apply-button) (force-event)
		      (if (not (equal? (edits ind) '(1 0)))
			  (snd-display ";undo-apply amp: ~A?" (edits ind)))
		      (click-button flt-button) (force-event)
		      (apply-enved)
		      (if (not (equal? (edits ind) '(2 0)))
			  (snd-display ";apply flt: ~A?" (edits ind)))
		      (click-button reset-button) (force-event)
		      (widget-string text-widget "'(0 .5 1 .4)") (force-event)
		      (key-event text-widget snd-return-key 0) (force-event)
		      (click-button src-button) (force-event)
		      (apply-enved)
		      (if (not (equal? (edits ind) '(3 0)))
			  (snd-display ";apply src: ~A?" (edits ind)))
		      (catch 'no-such-edit
			     (lambda ()
			       (if (and (not (equal? (edit-fragment 3) (list "src-channel '(0.000 0.500 1.000 0.400) 0 #f" "set" 0 113510)))
					(not (equal? (edit-fragment 3) (list "Enved: src" "set" 0 113420))))
				   (snd-display ";apply flt fragment: ~A?" (edit-fragment 3))))
			     (lambda args (snd-display ";again click enved apply failed")))
		      (if (not (> (frames ind) (* 2 fr)))
			  (snd-display ";apply src length: ~A ~A?" fr (frames ind)))
		      (click-button (find-child (car enved-widgets) "exp:"))
		      (XtCallCallbacks (find-child (car enved-widgets) "expscl") XmNdragCallback
				       (let ((cb (XmScrollBarCallbackStruct)))
					 (set! (.value cb) 65)
					 (set! (.event cb) (XEvent))
					 cb))
		      (XtCallCallbacks (find-child (car enved-widgets) "expscl") XmNvalueChangedCallback
				       (let ((cb (XmScrollBarCallbackStruct)))
					 (set! (.value cb) 65)
					 (set! (.event cb) (XEvent))
					 cb))
		      (click-button show-button) (force-event)
		      (close-sound ind))
		    (let ((firB (enved-filter)))
		      (click-button fir-button) (force-event)
		      (if (eq? (enved-filter) firB) (snd-display ";fir button had no effect?")))
		    (click-button delete-button) (force-event)
		    (XtCallCallbacks delete-button XmNactivateCallback #f)
		    (widget-string text-widget "'(0 .5 .4)") (force-event)
		    (key-event text-widget snd-return-key 0) (force-event)
		    (widget-string text-widget "'(.5 .4 0 0)") (force-event)
		    (key-event text-widget snd-return-key 0) (force-event)
		    (click-button dismiss-button) (force-event)
		    )
		  ))
	    
	    (for-each (lambda (dialog)
			(all-help dialog))
		      (dialog-widgets))
	    
	    (XSynchronize (XtDisplay (cadr (main-widgets))) #f)
	    
	    (if (and (provided? 'snd-motif) (provided? 'xm))
		(let ((move-scroll
		       (lambda (w val)
			 (if (and w
				  (XmScrollBar? w))
			     (let ((oldvals (XmScrollBarGetValues w)))
			       (apply XmScrollBarSetValues (list w
								 (+ (car oldvals) val)
								 (cadr oldvals)
								 (caddr oldvals)
								 (cadddr oldvals)
								 #t))
			       (let ((newvals (XmScrollBarGetValues w)))
				 (if (> (abs (- (car newvals) (car oldvals) val)) 2)
				     (snd-display ";move ~A ~A: ~A -> ~A" (XtName w) val (car oldvals) (car newvals)))))
			     (snd-display ";move-scroll ~A?" w)))))
		  (reset-almost-all-hooks)
		  (add-hook! bad-header-hook (lambda (n) #t))
		  (let* ((ind (open-sound "pistol.snd"))
			 (swids (sound-widgets ind))
			 (spane (car swids))
			 (sctrls (list-ref swids 2))
			 (cmain (find-child spane "chn-main-window")))
		    (move-scroll (find-child cmain "chn-sx") 10)
		    (move-scroll (find-child cmain "chn-zy") -30)
		    (move-scroll (find-child cmain "chn-sy") 10)
		    (move-scroll (find-child cmain "chn-zx") 10)
		    (set! (show-controls ind) #t)
		    (move-scroll (find-child sctrls "amp") 10)
		    (if (not (> (amp-control ind) 1.0)) (snd-display ";amp-control moved: ~A" (amp-control ind)))
		    (move-scroll (find-child sctrls "speed-scroll") 10)
		    (if (not (> (speed-control ind) 1.0)) (snd-display ";speed-control moved: ~A" (speed-control ind)))
		    (move-scroll (find-child sctrls "expand-scroll") 10)
		    (if (not (> (expand-control ind) 1.0)) (snd-display ";expand-control moved: ~A" (expand-control ind)))
		    (move-scroll (find-child sctrls "contrast-scroll") 10)
		    (if (not (> (contrast-control ind) 0.0)) (snd-display ";contrast-control moved: ~A" (contrast-control ind)))
		    (move-scroll (find-child sctrls "revscl-scroll") 10)
		    (if (not (> (reverb-control-scale ind) 0.0)) (snd-display ";reverb-control-scale moved: ~A" (reverb-control-scale ind)))
		    (move-scroll (find-child sctrls "revlen-scroll") 10)
		    (if (not (> (reverb-control-length ind) 1.0)) (snd-display ";reverb-control-length moved: ~A" (reverb-control-length ind)))
		    (XmToggleButtonSetState (find-child sctrls "dir") #t #t)
		    (if (>= (speed-control ind) 0.0) (snd-display ";speed arrow: ~A" (speed-control ind)))
		    (XmToggleButtonSetState (find-child sctrls "expoff") #t #t)
		    (if (not (expand-control? ind)) (snd-display ";toggle but expand off?"))
		    (XmToggleButtonSetState (find-child sctrls "conoff") #t #t)
		    (if (not (contrast-control? ind)) (snd-display ";toggle but contrast off?"))
		    (XmToggleButtonSetState (find-child sctrls "revoff") #t #t)
		    (if (not (reverb-control? ind)) (snd-display ";toggle but reverb off?"))
		    (XmToggleButtonSetState (find-child sctrls "fltoff") #t #t)
		    (if (not (filter-control? ind)) (snd-display ";toggle but filter off?"))
		    (if (not (filter-control-in-dB ind))
			(begin
			  (XmToggleButtonSetState (find-child sctrls "fltdB") #t #t)
			  (if (not (filter-control-in-dB ind)) (snd-display ";toggle but filter-in-db off?"))))
					;(click-button (cadr (find-child sctrls "expand-label")))
					;(if (fneq (expand-control ind) 1.0) (snd-display ";click expand: ~A" (expand-control)))
					;need click event here, not just pushbutton callback
		    (if (sound? ind)
			(close-sound ind)))
		  
		  (if (not (car (dialog-widgets))) 
		      (begin 
			(set! (with-background-processes) #t)
			(let ((ind (open-sound "obtest.snd")))
			  (without-errors (test-menus)) 
			  (if (sound? ind) (close-sound ind)))
			(dismiss-all-dialogs)
			(set! (with-background-processes) #f)))
		  
		  ;; ---------------- color dialog ----------------
		  (let* ((colord (list-ref (dialog-widgets) 0))
			 (inv (find-child colord "invert"))
			 (cut (find-child colord "cutoff"))
			 (scl (find-child colord "ccdscl"))
			 (ind (open-sound "pistol.snd")))
		    (XtManageChild colord)
		    (set! (transform-graph? ind 0) #t)
		    (set! (transform-graph-type ind 0) graph-as-sonogram)
		    (if (and inv (Widget? inv))
			(begin
			  (move-scale cut 32)
			  (if (fneq (color-cutoff) .032)
			      (snd-display ";moved color-cutoff: ~A ~A" (color-cutoff) (XmScaleGetValue cut)))
			  (move-scale scl 32)
			  (if (fneq (color-scale) .647)
			      (snd-display ";moved color-scale: ~A ~A" (color-scale) (XmScaleGetValue scl)))
			  (XmToggleButtonSetState inv #f #t)
			  (if (color-inverted)
			      (snd-display ";toggle invert off"))
			  (XmToggleButtonSetState inv #t #t)
			  (if (not (color-inverted))
			      (snd-display ";toggle invert on")))
			(snd-display ";can't find color invert button?"))
		    (let ((lst (find-child colord "colormap-list")))
		      (do ((i 2 (1+ i)))
			  ((= i 16))
			(XmListSelectPos lst i #t)
			(if (not (= (colormap) (- i 1)))
			    (snd-display ";color dialog list ~A: ~A" (- i 1) (colormap)))
			(update-transform-graph)))
		    (close-sound ind)
		    (click-button (XmMessageBoxGetChild colord XmDIALOG_CANCEL_BUTTON)) (force-event))
		  
		  ;; ---------------- orientation dialog ----------------
		  (orientation-dialog)
		  (let* ((orientd (list-ref (dialog-widgets) 1))
			 (cut (or (find-child orientd "cut") (snd-display ";can't find cut")))
			 (ax (or (find-child orientd "ax") (snd-display ";can't find x angle")))
			 (ay (or (find-child orientd "ay") (snd-display ";can't find y angle")))
			 (az (or (find-child orientd "az") (snd-display ";can't find z angle")))
			 (sx (or (find-child orientd "xs") (snd-display ";can't find x scale")))
			 (sy (or (find-child orientd "ys") (snd-display ";can't find y scale")))
			 (sz (or (find-child orientd "zs") (snd-display ";can't find z scale")))
			 (hop (or (find-child orientd "hop") (snd-display ";can't find hop"))))
		    (set! (spectro-x-scale) 2.0)
		    (click-button (XmMessageBoxGetChild orientd XmDIALOG_OK_BUTTON)) (force-event)
		    (if (and (fneq (spectro-x-scale) 1.0)
			     (fneq (spectro-x-scale) 1.5))
			(snd-display ";orientation reset: ~A" (spectro-x-scale)))
		    (move-scale cut 32)
		    (if (fneq (spectro-cutoff) .32)
			(snd-display ";moved spectro-cutoff: ~A ~A" (spectro-cutoff) (XmScaleGetValue cut)))
		    (move-scale ax 32)
		    (if (fneq (spectro-x-angle) 32)
			(snd-display ";moved spectro-x-angle: ~A ~A" (spectro-x-angle) (XmScaleGetValue ax)))
		    (move-scale ay 32)
		    (if (fneq (spectro-y-angle) 32)
			(snd-display ";moved spectro-y-angle: ~A ~A" (spectro-y-angle) (XmScaleGetValue ay)))
		    (move-scale az 32)
		    (if (fneq (spectro-z-angle) 32)
			(snd-display ";moved spectro-z-angle: ~A ~A" (spectro-z-angle) (XmScaleGetValue az)))
		    (move-scale sx 32)
		    (if (fneq (spectro-x-scale) .32)
			(snd-display ";moved spectro-x-scale: ~A ~A" (spectro-x-scale) (XmScaleGetValue sx)))
		    (move-scale sy 32)
		    (if (fneq (spectro-y-scale) .32)
			(snd-display ";moved spectro-y-scale: ~A ~A" (spectro-y-scale) (XmScaleGetValue sy)))
		    (move-scale sz 32)
		    (if (fneq (spectro-z-scale) .32)
			(snd-display ";moved spectro-z-scale: ~A ~A" (spectro-z-scale) (XmScaleGetValue sz)))
		    (move-scale hop 12)
		    (if (fneq (spectro-hop) 12)
			(snd-display ";moved spectro-hop: ~A ~A" (spectro-hop) (XmScaleGetValue hop)))
		    (click-button (XmMessageBoxGetChild orientd XmDIALOG_OK_BUTTON)) (force-event)
		    (if (and (fneq (spectro-x-scale) 1.0)
			     (fneq (spectro-x-scale) 1.5))
			(snd-display ";orientation reset: ~A" (spectro-x-scale)))
		    (set! (widget-position orientd) (list 200 300))
		    (set! (spectro-x-scale) 3.0)
		    (if (fneq (XmScaleGetValue sx) 300)
			(snd-display ";orientation x scale: ~A ~A" (spectro-x-scale) (XmScaleGetValue sx)))
		    (set! (spectro-z-scale) 2.0)
		    (if (fneq (XmScaleGetValue sz) 200)
			(snd-display ";orientation z scale: ~A ~A" (spectro-z-scale) (XmScaleGetValue sz)))
		    (set! (spectro-y-scale) 0.5)
		    (if (fneq (XmScaleGetValue sy) 50)
			(snd-display ";orientation y scale: ~A ~A" (spectro-y-scale) (XmScaleGetValue sy)))
		    (click-button (XmMessageBoxGetChild orientd XmDIALOG_CANCEL_BUTTON)) (force-event)
		    (if (XtIsManaged orientd)
			(snd-display ";orientation still active?")))
		  
		  ;; ---------------- enved dialog ----------------
		  (if (defined? 'enved-axis-info)
		      (begin
			(let* ((envd (list-ref (dialog-widgets) 2)))
			  (XtManageChild envd)
			  (let* ((ind2 (open-sound "storm.snd"))
				 (cwid (car (channel-widgets ind2 0)))
				 (waveb (find-child envd "wave"))
				 (selectb (find-child envd "selection")))
			    (make-selection 243873 702138 ind2 0)
			    (click-button selectb)
			    (set! (cursor ind2 0) 1000)
			    (take-keyboard-focus (car (channel-widgets)))
			    (key-event cwid (char->integer #\x) 4) (force-event)
			    (key-event cwid (char->integer #\q) 0) (force-event)
			    (set! (cursor ind2 0) 1195243)
			    (key-event cwid (char->integer #\x) 4) (force-event)
			    (key-event cwid (char->integer #\q) 0) (force-event)
			    (let* ((enved-widgets (enved-dialog-widgets))
				   (drawer (cadr enved-widgets))
				   (ewid drawer))
			      
			      (click-event ewid 1 0 (enved-x 0.5) (enved-y 1.0)) (force-event)
			      
			      (add-hook! enved-hook
					 (lambda (env pt x y reason)
					   (if (= reason enved-move-point)
					       (if (and (> x 0.0) (< x (envelope-last-x env)))
						   (let* ((old-x (list-ref env (* pt 2)))
							  (new-env (stretch-envelope env old-x x)))
						     (list-set! new-env (+ (* pt 2) 1) y)
						     new-env)
						   env)
					       #f)))
			      (drag-event ewid 1 0 (enved-x 0.25) (enved-y 0.0) (enved-x 0.4) (enved-y 0.1)) (force-event)
			      (drag-event ewid 1 0 (enved-x 0.75) (enved-y 1.0) (enved-x 0.6) (enved-y 0.6)) (force-event)
			      
			      (click-button (XmMessageBoxGetChild envd XmDIALOG_OK_BUTTON)) (force-event)
			      (click-button (find-child envd "Reset")) (force-event)
			      (click-button (XmMessageBoxGetChild envd XmDIALOG_CANCEL_BUTTON)) (force-event)
			      (close-sound ind2))))))
		  
		  ;; ---------------- error dialog ----------------
		  (let ((errord (list-ref (dialog-widgets) 3)))
		    (XtManageChild errord)
		    (XtSetKeyboardFocus errord (XmMessageBoxGetChild errord XmDIALOG_OK_BUTTON))
		    (click-button (XmMessageBoxGetChild errord XmDIALOG_OK_BUTTON)) (force-event)
		    (if (XtIsManaged errord)
			(snd-display ";why is error dialog alive?")))
		  
		  ;; ---------------- yes-or-no dialog ----------------
		  (if (provided? 'snd-debug)
		      (let ((old-val (with-background-processes)))
			(set! (with-background-processes) #f)
			(let* ((val (yes-or-no? "hiho"))
			       (yesd (list-ref (dialog-widgets) 4)))
			  (if (not yesd)
			      (snd-display ";no yes dialog"))
			  (XtManageChild yesd)
			  (click-button (XmMessageBoxGetChild yesd XmDIALOG_OK_BUTTON)) (force-event))
			(let* ((val (yes-or-no? "hiho"))
			       (yesd (list-ref (dialog-widgets) 4)))
			  (if (not yesd)
			      (snd-display ";no no dialog"))
			  (XtManageChild yesd)
			  (click-button (XmMessageBoxGetChild yesd XmDIALOG_CANCEL_BUTTON)) (force-event))
			(set! (with-background-processes) old-val)))
		  
		  ;; ---------------- transform dialog ----------------
		  (let* ((transd (list-ref (dialog-widgets) 5))
			 (beta (find-child transd "beta-scale")))
		    ;; push all the buttons
		    (for-each (lambda (name check off2)
				(let ((button (find-child transd name)))
				  (if (and button (Widget? button))
				      (begin
					(if off2
					    (begin
					      (XmToggleButtonSetState button #f #t)
					      (if (check)
						  (snd-display ";toggle ~A off" name))))
					(XmToggleButtonSetState button #t #t)
					(if (not (check))
					    (snd-display ";toggle ~A on" name)))
				      (snd-display ";no ~A togglebutton widget in transform dialog?" name))))
			      (list "normo-button" "sono-button" "spectro-button" "normo-button" "peaks-button" "db-button" 
				    "logfreq-button" "normalize-button" "selection-button")
			      (list (lambda () (= (transform-graph-type) graph-once))
				    (lambda () (= (transform-graph-type) graph-as-sonogram))
				    (lambda () (= (transform-graph-type) graph-as-spectrogram))
				    (lambda () (= (transform-graph-type) graph-once))
				    show-transform-peaks
				    fft-log-magnitude
				    fft-log-frequency
				    (lambda () (= (transform-normalization) 1))
				    show-selection-transform)
			      (list #f #f #f #f #t #t
				    #t #t #t))
		    (move-scale beta 32)
		    (if (fneq (fft-window-beta) .32)
			(snd-display ";moved fft-beta: ~A ~A" (fft-window-beta) (XmScaleGetValue beta)))
		    ;; click all the lists
		    (for-each (lambda (name check)
				(let ((lst (find-child transd name)))
				  (if (and lst (Widget? lst))
				      (check lst)
				      (snd-display ";no ~A list widget in transform dialog?" name))))
			      (list "type-list" "size-list" "wavelet-list" "window-list")
			      (list (lambda (w)
				      (XmListSelectPos w (+ autocorrelation 1) #t)
				      (if (not (= (transform-type) autocorrelation))
					  (snd-display ";transform-type autocorrelation: ~A ~A?" (transform-type) autocorrelation))
				      (XmListSelectPos w (+ wavelet-transform 1) #t)
				      (if (not (= (transform-type) wavelet-transform))
					  (snd-display ";transform-type wavelet-transform: ~A ~A?" (transform-type) wavelet-transform)))
				    (lambda (w)
				      (XmListSelectPos w 7 #t)
				      (if (not (= (transform-size) 1024))
					  (snd-display ";transform-size ~A ~A" (transform-size) 1024))
				      (XmListSelectPos w 2 #t)
				      (if (not (= (transform-size) 32))
					  (snd-display ";transform-size ~A ~A" (transform-size) 32)))
				    (lambda (w)
				      (XmListSelectPos w 4 #t)
				      (if (not (= (wavelet-type) 3))
					  (snd-display ";wavelet-type: ~A" (wavelet-type))))
				    (lambda (w)
				      (XmListSelectPos w (+ bartlett-window 1) #t)
				      (if (not (= (fft-window) bartlett-window))
					  (snd-display ";fft-window bartlett: ~A ~A" (fft-window) bartlett-window))
				      (XmListSelectPos w (+ kaiser-window 1) #t)
				      (if (not (= (fft-window) kaiser-window))
					  (snd-display ";fft-window kaiser: ~A ~A" (fft-window) kaiser-window)))))
		    (XtSetKeyboardFocus transd (XmMessageBoxGetChild transd XmDIALOG_OK_BUTTON))
		    (click-button (XmMessageBoxGetChild transd XmDIALOG_OK_BUTTON)) (force-event)
		    (if (XtIsManaged transd)
			(snd-display ";why is transform dialog active?")))
		  
		  ;; ---------------- file:open dialog ----------------
		  (open-file-dialog)
		  (let* ((filed (list-ref (dialog-widgets) 6))
			 (filename (XmFileSelectionBoxGetChild filed XmDIALOG_TEXT))
			 (snd-tab-key #xFF09))
		    (XmTextSetString filename "oboe.sn")
		    (key-event filename snd-tab-key 0) (force-event)
		    (XmUpdateDisplay filename)
		    (if (not (string=? (XmTextGetString filename) "oboe.snd")) (snd-display ";<tab>->~A?" (XmTextGetString filename)))
		    (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_OK_BUTTON)) (force-event)
		    (let ((ind (find-sound "oboe.snd")))
		      (if (not (sound? ind))
			  (snd-display ";file:open failed?"))
		      (close-sound ind)))
		  (open-file-dialog)
		  (let* ((filed (list-ref (dialog-widgets) 6)))
		    (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_APPLY_BUTTON)) (force-event)
		    (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_CANCEL_BUTTON)) (force-event)
		    (if (XtIsManaged filed)
			(snd-display ";file:open cancel failed?")))
		  (open-file-dialog)
		  (let* ((filed (list-ref (dialog-widgets) 6))
			 (sounds (find-child filed "sound files only"))
			 (plays (find-child filed "play selected sound"))
			 (files (XmFileSelectionBoxGetChild filed XmDIALOG_LIST)))
		    (XmToggleButtonSetState sounds #f #t)
		    (XmToggleButtonSetState sounds #t #t)
		    (XmListSelectPos files 1 #t)
		    (XmToggleButtonSetState plays #t #t)
		    (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_OK_BUTTON)) (force-event)
		    (let* ((filename (XmTextGetString (XmFileSelectionBoxGetChild filed XmDIALOG_TEXT)))
			   (ind (find-sound filename)))
		      (if (not (sound? ind))
			  (snd-display ";chose: ~A but not active?" filename))
		      (XmToggleButtonSetState plays #f #t)
		      (close-sound ind)
		      (XmFileSelectionDoSearch filed #f)
		      (XmFileSelectionDoSearch filed (XmStringCreateLocalized (string-append home-dir "/cl")))
		      (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_CANCEL_BUTTON)) 
		      (force-event)))
		  (open-file-dialog)
		  (let* ((filed (list-ref (dialog-widgets) 6))
			 (pattern (XmFileSelectionBoxGetChild filed XmDIALOG_FILTER_TEXT))
			 (sounds (find-child filed "sound files only")))
		    (XmToggleButtonSetState sounds #t #t)
		    (XmToggleButtonSetState sounds #f #t)
		    (XmTextSetString pattern (string-append cwd "*.snd"))
		    (XmToggleButtonSetState sounds #t #t)
		    (XmToggleButtonSetState sounds #f #t)
		    (XmTextSetString pattern (string-append cwd "*.wav"))
		    (XmToggleButtonSetState sounds #t #t)
		    (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_CANCEL_BUTTON)) (force-event))
		  (open-file-dialog)
		  (let* ((filed (list-ref (dialog-widgets) 6))
			 (filename (XmFileSelectionBoxGetChild filed XmDIALOG_TEXT))
			 (snd-tab-key #xFF09))
		    (XmTextSetString filename "oboe.sn")
		    (key-event filename snd-tab-key 0) (force-event)
		    (XmUpdateDisplay filename)
		    ;; now the completion help should be active
		    (let ((helper (list-ref (dialog-widgets) 15)))
		      (if (not helper)
			  (snd-display ";help completion inactive?")
			  (let ((choices (find-child (list-ref (dialog-widgets) 15) "completion-help-text")))
			    (XmListSelectPos choices 2 #f)
			    (click-button (XmMessageBoxGetChild helper XmDIALOG_OK_BUTTON)) (force-event)
			    )))
		    (click-button (XmFileSelectionBoxGetChild filed XmDIALOG_CANCEL_BUTTON)) (force-event))
		  
		  ;; ---------------- file save-as dialog ----------------
		  (set! (default-output-chans) 1)
		  (set! (default-output-format) mus-bshort)
		  (set! (default-output-srate) 22050)
		  (set! (default-output-type) mus-next)
		  
		  (let ((ind (open-sound "oboe.snd")))
		    (if (file-exists? "test.snd") (delete-file "test.snd"))
		    (scale-by 2.0)
		    (let ((wid (save-sound-dialog)))
		      (if (not (equal? wid (list-ref (dialog-widgets) 7)))
			  (snd-display ";save-sound-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 7))))
		    (let* ((saved (list-ref (dialog-widgets) 7))
			   (ok (XmFileSelectionBoxGetChild saved XmDIALOG_OK_BUTTON))
			   (filetext (XmFileSelectionBoxGetChild saved XmDIALOG_TEXT)))
		      (XmTextSetString filetext "test.snd")
		      (click-button ok) (force-event)
		      (if (not (file-exists? "test.snd"))
			  (snd-display ";file test.snd not saved?"))
		      (if (XtIsManaged saved)
			  (snd-display ";after save, file dialog still active?"))
		      (if (file-exists? "test.snd")
			  (let ((ind1 (open-sound "test.snd")))
			    (if (not (= (header-type ind1) (header-type ind))) 
				(snd-display ";save-as changed header type? ~A" (mus-header-type-name (header-type ind1))))
			    (if (not (= (data-format ind1) (data-format ind))) 
				(snd-display ";save-as changed data format? ~A" (mus-data-format-name (data-format ind1))))
			    (if (not (= (chans ind1) (chans ind))) 
				(snd-display ";save-as changed channels? ~A" (chans ind1)))
			    (if (not (= (srate ind1) (srate ind))) 
				(snd-display ";save-as changed srate? ~A" (srate ind1)))
			    (if (not (= (frames ind) (frames ind1)))
				(snd-display ";save-as changed length? ~A" (frames ind1)))
			    (let* ((r1 (make-sample-reader 0 ind1 0))
				   (ok (scan-channel (lambda (x)
						       (let ((val (next-sample r1)))
							 (if (fneq val x)
							     (list x val)
							     #f)))
						     0 (1- (frames ind)) ind 0)))
			      (if ok
				  (snd-display ";save-as diff: ~A" ok))
			      (free-sample-reader r1))
			    (close-sound ind1))))
		    (if (file-exists? "test.snd") (delete-file "test.snd"))
		    (save-sound-dialog)
		    (let* ((saved (list-ref (dialog-widgets) 7))
			   (types (find-child saved "header type")) ; list
			   (formats (find-child saved "data format")) ; list
			   (srtxt (find-child saved "srate-text")) 
			   (comtxt (find-child saved "comment-text"))
			   (cancel (XmFileSelectionBoxGetChild saved XmDIALOG_CANCEL_BUTTON))
			   (ok (XmFileSelectionBoxGetChild saved XmDIALOG_OK_BUTTON))
			   (filter (XmFileSelectionBoxGetChild saved XmDIALOG_APPLY_BUTTON))
			   (filetext (XmFileSelectionBoxGetChild saved XmDIALOG_TEXT)))
		      (do ((i 1 (1+ i)))
			  ((= i 7))
			(XmListSelectPos types i #t))
		      (XmListSelectPos types 2 #t)
		      (XmListSelectPos formats 2 #t)
		      (XmTextSetString filetext "test.snd")
		      (XmTextSetString srtxt "(* 2 22050)")
		      (XmTextSetString comtxt "This is a test of the file save-as dialog")
		      (click-button ok) (force-event)
		      (if (not (file-exists? "test.snd"))
			  (snd-display ";file 2 test.snd not saved?"))
		      (if (XtIsManaged saved)
			  (snd-display ";after save, file dialog still active?"))
		      (if (file-exists? "test.snd")
			  (let ((ind1 (open-sound "test.snd")))
			    (if (not (= (header-type ind1) mus-aifc))
				(snd-display ";save-as aifc header type? ~A" (mus-header-type-name (header-type ind1))))
			    (if (not (= (data-format ind1) mus-mulaw))
				(snd-display ";save-as mulaw data format? ~A" (mus-data-format-name (data-format ind1))))
			    (if (not (= (srate ind1) 44100))
				(snd-display ";save-as 44100 srate? ~A" (srate ind1)))
			    (if (or (not (string? (comment ind1)))
				    (not (string=? (comment ind1) "This is a test of the file save-as dialog")))
				(snd-display ";save-as comment: ~A" (comment ind1)))
			    (let* ((r1 (make-sample-reader 0 ind1 0))
				   (ok (scan-channel (lambda (x)
						       (let ((val (next-sample r1)))
							 (if (> (abs (- val x)) .01) ; mulaw not very close sometimes
							     (list x val)
							     #f)))
						     0 (1- (frames ind)) ind 0)))
			      (if ok
				  (snd-display ";save-as 2 diff: ~A" ok))
			      (free-sample-reader r1))
			    (close-sound ind1))))
		    (if (file-exists? "test.snd") (delete-file "test.snd"))
		    (save-sound-dialog)
		    (let* ((saved (list-ref (dialog-widgets) 7))
			   (filetext (XmFileSelectionBoxGetChild saved XmDIALOG_TEXT))
			   (cancel (XmFileSelectionBoxGetChild saved XmDIALOG_CANCEL_BUTTON))
			   (filter (XmFileSelectionBoxGetChild saved XmDIALOG_APPLY_BUTTON)))
		      (click-button filter) (force-event)
		      (if (string=? (XmTextGetString filetext) "test.snd")
			  (snd-display ";save-as filter: ~A?" (XmTextGetString filetext)))
		      (click-button cancel) (force-event)
		      (if (XtIsManaged saved)
			  (snd-display ";after cancel, file dialog still active?"))
		      (if (file-exists? "test.snd")
			  (snd-display ";cancelled save-as wrote a file?")))
		    (close-sound ind))
		  
		  ;; ---------------- edit save-as dialog ----------------
		  (let ((ind (open-sound "oboe.snd")))
		    (if (file-exists? "test.snd") (delete-file "test.snd"))
		    (make-selection 2000 3000 ind 0)
		    (scale-selection-by 2.0)
		    (let ((wid (save-selection-dialog)))
		      (if (not (equal? wid (list-ref (dialog-widgets) 7)))
			  (snd-display ";save-selection-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 7))))
		    (let* ((saved (list-ref (dialog-widgets) 7))
			   (ok (XmFileSelectionBoxGetChild saved XmDIALOG_OK_BUTTON))
			   (filetext (XmFileSelectionBoxGetChild saved XmDIALOG_TEXT))
			   (types (find-child saved "header type")) ; list
			   (formats (find-child saved "data format"))) ; list
		      (XmListSelectPos types 1 #t)
		      (XmListSelectPos formats 1 #t)
		      (XmTextSetString filetext "test.snd")
		      (click-button ok) (force-event)
		      (if (not (file-exists? "test.snd"))
			  (snd-display ";edit test.snd not saved?"))
		      (if (XtIsManaged saved)
			  (snd-display ";after save, edit dialog still active?"))
		      (if (file-exists? "test.snd")
			  (let ((ind1 (open-sound "test.snd")))
			    (let* ((r1 (make-sample-reader 2000 ind 0))
				   (ok (scan-channel (lambda (x)
						       (let ((val (next-sample r1)))
							 (if (fneq val x)
							     (list x val)
							     #f)))
						     0 (1- (frames ind1)) ind1 0)))
			      (if ok
				  (snd-display ";edit save-as diff: ~A" ok))
			      (free-sample-reader r1))
			    (close-sound ind1))))
		    (if (file-exists? "test.snd") (delete-file "test.snd"))
		    (save-selection-dialog)
		    (let* ((saved (list-ref (dialog-widgets) 7))
			   (filetext (XmFileSelectionBoxGetChild saved XmDIALOG_TEXT))
			   (cancel (XmFileSelectionBoxGetChild saved XmDIALOG_CANCEL_BUTTON))
			   (filter (XmFileSelectionBoxGetChild saved XmDIALOG_APPLY_BUTTON)))
		      (click-button cancel) (force-event)
		      (if (XtIsManaged saved)
			  (snd-display ";after cancel, edit save-as dialog still active?"))
		      (if (file-exists? "test.snd")
			  (snd-display ";cancelled edit save-as wrote a file?")))
		    (close-sound ind))
		  
		  (let* ((gotin #f)
			 (gotout #f)
			 (listener (list-ref (main-widgets) 4))
			 (mlist (XtParent listener)))
		    (reset-hook! mouse-enter-listener-hook)
		    (reset-hook! mouse-leave-listener-hook)
		    (add-hook! mouse-enter-listener-hook (lambda (w) (set! gotin #t)))
		    (add-hook! mouse-leave-listener-hook (lambda (w) (set! gotout #t)))
		    (enter-event mlist) (force-event)
		    (leave-event mlist) (force-event)
		    (if (not gotin) (snd-display ";no listener enter?"))
		    (if (not gotout) (snd-display ";no listener leave?"))
		    (reset-hook! mouse-enter-listener-hook)
		    (reset-hook! mouse-leave-listener-hook))
		  
		  
		  ;; ---------------- view files dialog ----------------
		  (if (not (provided? 'snd-nb.scm)) (load "nb.scm"))
		  (if (hook-empty? mouse-enter-label-hook)
		      (begin
			(add-hook! mouse-enter-label-hook files-popup-info)
			(add-hook! mouse-leave-label-hook files-popup-quit)))
		  (let ((ind1 (open-sound "oboe.snd"))
			(ind2 (open-sound "pistol.snd")))
		    (view-files-dialog)
		    (let ((ind (open-sound "2.snd")))
		      (close-sound ind))
		    (let* ((filed (list-ref (dialog-widgets) 8))
			   (curform (find-child filed "curform"))
			   (prevform (find-child filed "prevform"))
			   (sort-menu (find-child prevform "sort"))
			   (option-holder (cadr (XtGetValues sort-menu (list XmNsubMenuId 0))))
			   (rw1 (find-child prevform "rw"))
			   (pl1 (find-child rw1 "pl"))
			   (nm1 (find-child rw1 "nm"))
			   (name (cadr (XmStringGetLtoR (cadr (XtVaGetValues nm1 (list XmNlabelString 0))) XmFONTLIST_DEFAULT_TAG)))
			   (rw2 (find-child curform "rw"))
			   (pl2 (find-child rw2 "pl"))
			   (nm2 (find-child rw2 "nm")))
					;(add-hook! mouse-enter-label-hook (lambda (a b c) (snd-display ";~A ~A ~A" a b c)))
		      (enter-event nm1) (force-event)
		      (leave-event nm1) (force-event)
		      (enter-event nm2) (force-event)
		      (leave-event nm2) (force-event)
		      (click-button pl1) (force-event)
		      (click-button pl2) (force-event)
		      (if (not (hook-empty? initial-graph-hook))
			  (begin
			    (catch #t
				   (lambda ()
				     (XmToggleButtonSetState pl1 #t #t)
				     (XmToggleButtonSetState pl1 #f #t)
				     (click-button nm1)
				     (if (or (= (length (sounds)) 0)
					     (not (string=? (short-file-name (car (sounds))) name)))
					 (snd-display ";click previous: ~A ~A" name (map short-file-name (sounds))))
				     (XmToggleButtonSetState pl2 #t #t)
				     (XmToggleButtonSetState pl2 #f #t))
				   (lambda args args))
			    (enter-event nm1) (force-event)
			    (set! name (cadr (XmStringGetLtoR (cadr (XtVaGetValues nm2 (list XmNlabelString 0))) XmFONTLIST_DEFAULT_TAG)))
			    (close-sound (car (sounds)))
			    (for-each-child option-holder
					    (lambda (w)
					      (if (XmIsPushButton w)
						  (begin
						    (click-button w #t)
						    (force-event)))))
			    (let ((update (find-child filed "Update")))
			      (click-button update) (force-event))))
		      (let ((name (find-child option-holder "name"))
			    (date (find-child option-holder "date"))
			    (size (find-child option-holder "size"))
			    (entry (find-child option-holder "entry"))
			    (proc (find-child option-holder "proc")))
			(XtCallCallbacks date XmNactivateCallback (snd-global-state))
			(XtCallCallbacks size XmNactivateCallback (snd-global-state))
			(XtCallCallbacks entry XmNactivateCallback (snd-global-state))
			(if (XtIsSensitive proc) (XtCallCallbacks entry XmNactivateCallback (snd-global-state)))
			(XtCallCallbacks name XmNactivateCallback (snd-global-state)))
		      (click-button (XmMessageBoxGetChild filed XmDIALOG_CANCEL_BUTTON)) (force-event)     ;clear
		      (set! name (cadr (XmStringGetLtoR (cadr (XtVaGetValues nm2 (list XmNlabelString 0))) XmFONTLIST_DEFAULT_TAG)))
		      (XtSetKeyboardFocus filed (XmMessageBoxGetChild filed XmDIALOG_OK_BUTTON))
		      (click-button (XmMessageBoxGetChild filed XmDIALOG_OK_BUTTON)) (force-event)
		      (reset-hook! mouse-enter-label-hook)
		      (reset-hook! mouse-leave-label-hook)
		      (if (XtIsManaged filed)
			  (snd-display ";why is view files active?")))
		    (close-sound ind1)
		    (close-sound ind2))
		  
		  ;; ---------------- raw data dialog ----------------
		  (if (provided? 'snd-debug)
		      (let ((old-val (with-background-processes)))
			(set! (with-background-processes) #f)
			(let ((rf (open-sound (string-append sf-dir "addf8.nh"))))
			  (if (not (sound? rf))
			      (snd-display ";raw-data file: ~A" rf)
			      (close-sound rf))
			  (if (not (list-ref (dialog-widgets) 9))
			      (snd-display ";raw-data open: ~A" (list-ref (dialog-widgets) 9))
			      (let ((rd (list-ref (dialog-widgets) 9)))
				(click-button (XmMessageBoxGetChild rd XmDIALOG_CANCEL_BUTTON)) (force-event))))
			(reset-hook! bad-header-hook)
			(if (file-exists? (string-append home-dir "/sf1/bogus.snd"))
			    (let ((ind (open-sound (string-append home-dir "/sf1/bogus.snd"))))
			      (let ((rd (list-ref (dialog-widgets) 9)))
				(if (XtIsManaged rd)
				    (begin
				      (click-button (XmMessageBoxGetChild rd XmDIALOG_HELP_BUTTON)) (force-event)
				      (click-button (XmMessageBoxGetChild rd XmDIALOG_CANCEL_BUTTON)) (force-event))))))
			(set! (with-background-processes) old-val)))
		  (add-hook! bad-header-hook (lambda (n) #t))
		  
		  ;; ---------------- file:new dialog ----------------
		  (if (defined? 'new-file-dialog)
		      (begin
			(reset-hook! output-name-hook)
			(add-hook! output-name-hook (lambda () "hiho.snd"))
			(let ((old-val (with-background-processes)))
			  (set! (with-background-processes) #f)
			  (let ((newind (new-file-dialog)))
			    (if (not (sound? newind)) 
				(snd-display ";new file dialog: ~A" newind)
				(begin
				  (if (not (string=? (short-file-name newind) "hiho.snd"))
				      (snd-display ";output-name-hook: ~A" (short-file-name newind)))
				  (close-sound newind))))
			  (reset-hook! output-name-hook)
			  (set! (with-background-processes) old-val))))
		  
		  ;; ---------------- file:mix dialog ----------------
		  (if (list-ref (dialog-widgets) 11)
		      (let* ((mixd (list-ref (dialog-widgets) 11))
			     (filename (XmFileSelectionBoxGetChild mixd XmDIALOG_TEXT))
			     (ind (new-sound "test.snd" mus-next mus-bshort 22050 1 "mixing"))
			     (ind1 (open-sound "oboe.snd")))
			(XtManageChild mixd)
			(set! (cursor ind) 0)
			(XmTextSetString filename "oboe.snd")
			(click-button (XmFileSelectionBoxGetChild mixd XmDIALOG_OK_BUTTON)) (force-event)
			(let* ((r1 (make-sample-reader 0 ind1 0))
			       (ok (scan-channel (lambda (x)
						   (let ((val (next-sample r1)))
						     (if (fneq val x)
							 (list x val)
							 #f)))
						 0 (1- (frames ind)) ind 0)))
			  (if ok
			      (snd-display ";mix diff: ~A" ok))
			  (free-sample-reader r1))
			(close-sound ind1)
			(XtManageChild mixd)
			(click-button (XmFileSelectionBoxGetChild mixd XmDIALOG_CANCEL_BUTTON)) (force-event)
			(if (XtIsManaged mixd)
			    (snd-display ";mix file dialog still active?"))
			(close-sound ind))
		      (snd-display ";no mix file dialog?"))
		  
		  
		  ;; ---------------- edit header dialog ----------------
		  (let ((ind (open-sound "oboe.snd")))
		    (define (type->pos type)
		      (if (= type mus-next) 1
			  (if (= type mus-aifc) 2
			      (if (= type mus-riff) 3
				  (if (= type mus-raw) 4
				      (if (= type mus-aiff) 5
					  (if (= type mus-ircam) 6
					      7)))))))
		    
		    (define (format->pos type format)
		      (let ((next-formats (list mus-bshort mus-mulaw mus-byte mus-bfloat mus-bint mus-alaw mus-b24int mus-bdouble))
			    (ircam-formats (list mus-bshort mus-mulaw mus-bfloat mus-bint mus-alaw))
			    (wave-formats (list mus-mulaw mus-alaw mus-ubyte mus-lshort mus-lint mus-lfloat mus-ldouble mus-l24int))
			    (aifc-formats (list mus-bshort mus-mulaw mus-byte mus-bint mus-alaw mus-b24int 
						mus-bfloat mus-bdouble mus-ubyte mus-lshort mus-lint mus-l24int mus-ubshort))
			    (aiff-formats (list mus-bshort mus-bint mus-byte mus-b24int))
			    (nist-formats (list mus-bshort mus-lshort mus-bint mus-lint mus-byte mus-b24int mus-l24int))
			    (raw-formats (list mus-bshort mus-mulaw mus-byte mus-bfloat mus-bint mus-alaw mus-ubyte mus-b24int 
					       mus-bdouble mus-lshort mus-lint mus-lfloat mus-ldouble mus-ubshort mus-ulshort
					       mus-l24int mus-bintn mus-lintn)))
			(define (position val lst pos)
			  (call-with-current-continuation
			   (lambda (return)
			     (if (null? lst)
				 #f
				 (if (= val (car lst))
				     (return pos)
				     (position val (cdr lst) (1+ pos)))))))
			(if (= type mus-next) (position format next-formats 1)
			    (if (= type mus-aifc) (position format aifc-formats 1)
				(if (= type mus-riff) (position format wave-formats 1)
				    (if (= type mus-raw) (position format raw-formats 1)
					(if (= type mus-aiff) (position format aiff-formats 1)
					    (if (= type mus-ircam) (position format ircam-formats 1)
						(position format nist-formats 1)))))))))
		    
		    (if (file-exists? "fmv.snd") (delete-file "fmv.snd"))
		    (save-sound-as "fmv.snd" ind)
		    (close-sound ind)
		    (set! ind (open-sound "fmv.snd"))
		    (edit-header-dialog)
		    (if (provided? 'snd-debug)
			(let* ((editd (list-ref (dialog-widgets) 12))
			       ;; cancel ok=save 
			       (types (find-child editd "header type")) ; list
			       (formats (find-child editd "data format")) ; list
			       (srtxt (find-child editd "srate-text")) 
			       (chtxt (find-child editd "chans-text"))
			       (loctxt (find-child editd "location-text"))
			       (comtxt (find-child editd "comment-text")))
			  
			  (XmTextSetString loctxt "44")
			  (apply-edit-header)
			  (set! ind (find-sound "fmv.snd"))
			  (if (not (= (data-location ind) 44))
			      (snd-display ";edit header data location: ~A" (data-location ind)))
			  (edit-header-dialog)
			  
			  (do ((i 0 (1+ i)))
			      ((= i 7))
			    (XmListSelectPos types i #t))
			  
			  (XmListSelectPos types (type->pos mus-riff) #t)
			  (XmListSelectPos formats (format->pos mus-riff mus-lfloat) #t)
			  (XmTextSetString srtxt "8")
			  (key-event srtxt snd-tab-key 0) (force-event)
			  (XmUpdateDisplay srtxt)
			  (XmTextSetString loctxt "44")
			  (XmTextSetString comtxt "saved from edit-header dialog")
			  (apply-edit-header)
			  (set! ind (find-sound "fmv.snd"))
			  (if (not (= (header-type ind) mus-riff))
			      (snd-display ";edit-header -> riff? ~A" (mus-header-type-name (header-type ind))))
			  (if (not (= (data-format ind) mus-lfloat))
			      (snd-display ";edit-header -> lfloat? ~A" (mus-data-format-name (data-format ind))))
			  (if (not (= (srate ind) 8000))
			      (snd-display ";edit-header -> 8000? ~A" (srate ind)))
			  (if (or (not (string? (comment ind)))
				  (not (string=? (comment ind) "saved from edit-header dialog")))
			      (snd-display ";edit header comment: ~A" (comment ind)))
			  (if (XtIsManaged editd)
			      (snd-display ";why is edit header dialog active?"))
			  (close-sound ind)
			  (set! ind (open-sound "4.aiff"))
			  (let ((old-data (channel->vct 250000 500 ind 1))
				(old-silence (channel->vct 103000 500 ind 1))
				(old-length (mus-sound-duration "4.aiff")))
			    (close-sound ind)
			    (system "cp -f 4.aiff test.aiff")
			    (set! ind (open-sound "test.aiff"))
			    (if (not (sound? ind)) (snd-display ";cp -> test.aiff: ~A" ind))
			    (for-each
			     (lambda (typ frm chns sr com backout nominal-length)
			       (edit-header-dialog)
			       (if (not (XtIsManaged editd))
				   (snd-display ";why isn't the edit header dialog active?"))
			       (XmListSelectPos types (type->pos typ) #t)
			       (XmListSelectPos formats (format->pos typ frm) #t)
			       (apply-edit-header)
			       (set! ind (find-sound "test.aiff"))
			       (if (not (= (header-type ind) typ))
				   (snd-display ";ledit-header type -> ~A ~A" typ (mus-header-type-name (header-type ind))))
			       (edit-header-dialog)
			       (XmTextSetString srtxt (number->string sr))
			       (apply-edit-header)
			       (set! ind (find-sound "test.aiff"))
			       (if (not (= (data-format ind) frm))
				   (snd-display ";ledit-header format -> ~A ~A (~A ~A) [~A]" 
						frm (data-format ind) 
						(mus-data-format-name (data-format ind))
						(mus-data-format-name frm)
						(mus-header-type-name typ)))
			       (if (not (= (srate ind) sr))
				   (snd-display ";ledit-header srate -> ~A ~A" sr (srate ind)))
			       (edit-header-dialog)
			       (if com (XmTextSetString comtxt com))
			       (XmTextSetString chtxt (number->string chns))
			       (apply-edit-header)
			       (set! ind (find-sound "test.aiff"))
			       (if com
				   (if (or (not (string? (comment ind)))
					   (not (string=? (comment ind) com)))
				       (snd-display ";edit header comment ~A: ~A" com (comment ind))))
			       (if (not (= (chans ind) chns))
				   (snd-display ";ledit-header chans -> ~A ~A" chns (chans ind)))
			       (if (and nominal-length
					(fneq (mus-sound-duration "test.aiff") nominal-length))
				   (snd-display ";ledit-header duration: nominal: ~A, current: ~A [~A ~A ~A ~A]" 
						nominal-length (mus-sound-duration "test.aiff") 
						(mus-header-type-name typ) 
						(mus-data-format-name frm)
						sr chns))
			       (if backout
				   (let ((new-data (channel->vct 250000 500 ind 1))
					 (new-silence (channel->vct 103000 500 ind 1)))
				     (if (not (vequal new-data old-data))
					 (snd-display ";backout data diffs: ~A ~A ~A"
						      (let ((sum 0.0)
							    (sub-data (vct-copy new-data)))
							(vct-subtract! sub-data old-data)
							(do ((i 0 (1+ i)))
							    ((= i 500))
							  (set! sum (+ sum (abs (vct-ref sub-data i)))))
							sum)
						      old-data new-data))
				     (if (not (vequal new-silence old-silence))
					 (snd-display ";backout silence diffs: ~A ~A ~A"
						      (let ((sum 0.0)
							    (sub-silence (vct-copy new-silence)))
							(vct-subtract! sub-silence old-silence)
							(do ((i 0 (1+ i)))
							    ((= i 500))
							  (set! sum (+ sum (abs (vct-ref sub-silence i)))))
							sum)
						      old-silence new-silence)))))
			     (list mus-aiff mus-aifc mus-next mus-aifc mus-riff 
				   mus-next mus-next mus-aiff mus-aifc
				   mus-nist mus-ircam mus-aifc mus-aifc)
			     (list mus-bshort mus-bshort mus-bshort mus-bshort mus-lfloat 
				   mus-bshort mus-bfloat mus-bshort mus-bshort
				   mus-lint mus-alaw mus-bshort mus-bint)
			     (list 2 4 2 4 4 
				   2 2 2 4
				   2 4 4 4)
			     (list 22050 22050 44100 22050 22050 
				   22050 22050 22050 22050
				   44100 8000 44100 22050)
			     (list #f #f "this is a comment" "this is another comment" "riff time" 
				   "next time" #f "aiff time" "aifc time"
				   #f "ircam time" "aifc time" #f)
			     (list #f #t #f #t #f 
				   #f #f #f #t
				   #f #f #t #f)
			     (list (* 2 old-length) old-length old-length old-length (* 0.5 old-length) 
				   (* 2 old-length) old-length (* 2 old-length) old-length
				   #f #f (* 0.5 old-length) (* 0.5 old-length))))
			  (close-sound ind)
			  (click-button (XmMessageBoxGetChild editd XmDIALOG_CANCEL_BUTTON)) (force-event))
			(close-sound ind)))
		  (if (file-exists? "test.aiff") (delete-file "test.aiff"))
		  
		  ;; ---------------- edit:find dialog ----------------
			(find-dialog)
			(let* ((findd (list-ref (dialog-widgets) 13))
			       (ind (open-sound "oboe.snd"))
			       ;; ok = dismiss cancel = previous next = next
			       (dismiss (XmMessageBoxGetChild findd XmDIALOG_OK_BUTTON))
			       (previous (XmMessageBoxGetChild findd XmDIALOG_CANCEL_BUTTON))
			       (next (find-child findd "Next"))
			       (txt (find-child findd "text")))
			  (XmTextSetString txt "(lambda (n-find-dialog) (> n-find-dialog .1))")
			  (click-button next) (force-event)
			  (if (not (> (sample (cursor)) .1))
			      (snd-display ";sample at cursor upon edit find > .1: ~A (~A)" (sample (cursor)) (cursor)))
			  (click-button next) (force-event)
			  (click-button previous) (force-event)
			  (click-button dismiss) (force-event)
			  (close-sound ind)
			  (if (XtIsManaged findd)
			      (XtUnmanageChild findd)))
		  
		  ;; ---------------- help dialog ----------------
		  (help-dialog "Test" "snd-test here")
		  (let* ((helpd (list-ref (dialog-widgets) 14))
			 (txt (find-child helpd "help-search")))
		    (if (Widget? txt)
			(begin
			  (XmTextFieldSetString txt "reverb")
			  (XtCallCallbacks txt XmNactivateCallback #f)))
		    (click-button (XmMessageBoxGetChild helpd XmDIALOG_OK_BUTTON)) (force-event)
		    (if (XtIsManaged helpd)
			(snd-display ";help still active?")))
		  
		  ;; ---------------- info dialog ----------------
		  (let ((wid (info-dialog "Test" "snd-test here")))
		    (if (not (equal? wid (list-ref (dialog-widgets) 20)))
			(snd-display ";info-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 20))))
		  (let* ((helpd (list-ref (dialog-widgets) 20)))
		    (click-button (XmMessageBoxGetChild helpd XmDIALOG_OK_BUTTON)) (force-event)
		    (if (XtIsManaged helpd)
			(snd-display ";info still active?")))
		  
		  ;; ---------------- mix-dialog dialog ----------------
		  (let* ((ind (open-sound "oboe.snd"))
			 (v (make-vct 3))
			 (s1001 (sample 1001))
			 (s2001 (sample 2001)))
		    (vct-fill! v .1)
		    (let* ((id1 (mix-vct v 1000 ind 0 #t))
			   (id2 (mix-vct v 2000 ind 0 #t)))
		      (view-mixes-dialog)
		      (let* ((mixd (list-ref (dialog-widgets) 16))
			     (idtxt (find-child mixd "mix-id"))
			     (begtxt (find-child mixd "mix-times"))
			     (trktxt (find-child mixd "mix-track"))
			     (playb (find-child mixd "mix-play"))
			     (spdscr (find-child mixd "mix-speed"))
			     (ampscr (find-child mixd "mix-amp"))
			     (ampenv (find-child mixd "mix-amp-env-window"))
			     (db (find-child mixd "dB"))
			     (wave (find-child mixd "wave"))
			     (clip (find-child mixd "clip")))
			(if (fneq (sample 1001) (+ s1001 .1)) 
			    (snd-display ";mix-dialog at 1001: ~A (~A)?" (sample 1001) s1001))
			(if (fneq (sample 2001) (+ s2001 .1)) 
			    (snd-display ";mix-dialog at 2001: ~A (~A)?" (sample 2001) s2001))
			(set! (mix-dialog-mix) id1)
			(if (not (= (mix-dialog-mix) id1)) (snd-display ";mix-dialog-mix: ~A ~A" id1 (mix-dialog-mix)))
			(if (not (string=? (XmTextGetString trktxt) "0"))
			    (snd-display ";mix initial track: ~A" (XmTextGetString trktxt)))
			(if (not (string=? (XmTextGetString idtxt) (number->string id1)))
			    (snd-display ";mix initial id: ~A" (XmTextGetString idtxt)))
			(move-scroll ampscr 20)
			(if (not (> (sample 1001) (+ s1001 .1)))
			    (snd-display ";amp mix-dialog at 1001: ~A (~A)?" (sample 1001) s1001))
			(if (fneq (sample 2001) (+ s2001 .1)) 
			    (snd-display ";amp mix-dialog at 2001: ~A (~A)?" (sample 2001) s2001))
			(click-button playb)
			(move-scroll spdscr 20)
			(for-each
			 (lambda (scrl)
			   (XtCallCallbacks scrl XmNdragCallback
					    (let ((cb (XmScrollBarCallbackStruct)))
					      (set! (.value cb) 50)
					      (set! (.event cb) (XEvent))
					      cb)))
			 (list spdscr ampscr))
			(for-each
			 (lambda (n)
			   (click-button n #t 0)
			   (click-button n #t ControlMask))
			 (map
			  (lambda (w) (find-child mixd w))
			  (list "mix-speed-label" "mix-amp-label")))
			(click-button wave) (force-event)
			(if (XmDrawingArea? ampenv)
			    (let* ((xy (widget-size ampenv))
				   (x0 (inexact->exact (floor (/ (car xy) 2))))
				   (y0 (inexact->exact (floor (/ (cadr xy) 2)))))
			      (click-event ampenv 1 0 x0 y0)
			      (drag-event ampenv 1 0 x0 y0 (+ x0 20) (+ y0 20)))
			    (snd-display ";mix-dialog ampenv: ~A" ampenv))
			(force-event)
			(let ((edp (edit-position ind)))
			  (click-button (XmMessageBoxGetChild mixd XmDIALOG_CANCEL_BUTTON)) (force-event)
			  (if (= edp (edit-position ind)) 
			      (snd-display ";apply mix env: ~A" edp)
			      (undo 1 ind 0)))
			(focus-widget begtxt)
			(widget-string begtxt "0.5") (force-event)
			(key-event begtxt snd-return-key 0) (force-event)
			(widget-string trktxt "2") (force-event)
			(key-event trktxt snd-return-key 0) (force-event)
			(widget-string idtxt "2") (force-event)
			(key-event idtxt snd-return-key 0) (force-event)
			(click-button db) (force-event)
;			(click-button wave) (force-event)
			(click-button clip) (force-event)
			(click-button clip) (force-event)
			(click-button wave) (force-event)
			(click-button db) (force-event)
			(XtSetKeyboardFocus mixd (XmMessageBoxGetChild mixd XmDIALOG_OK_BUTTON))
			(click-button (XmMessageBoxGetChild mixd XmDIALOG_OK_BUTTON)) (force-event)     ;dismiss
			(if (XtIsManaged mixd)
			    (XtUnmanageChild mixd))
			))
		    (XtCallCallbacks (menu-option "Mixes") XmNactivateCallback (snd-global-state))
		    (let ((mixd (list-ref (dialog-widgets) 16)))
		      (if (not (XtIsManaged mixd))
			  (snd-display ";why isn't mix-dialog dialog alive?"))
		      (XtUnmanageChild mixd))

		    (let* ((id3 (make-track))
			   (id1 (mix-vct v 1000 ind 0 #t))
			   (id2 (mix-vct v 2000 ind 0 #t)))
		      (set! (mix-track id1) id3)
		      (set! (mix-track id2) id3)
		      (let ((wid (view-tracks-dialog)))
			(if (not (equal? wid (list-ref (dialog-widgets) 21)))
			    (snd-display ";view-tracks-dialog -> ~A ~A" wid (list-ref (dialog-widgets) 21))))
		      (let* ((trackd (list-ref (dialog-widgets) 21))
			     (idtxt (find-child trackd "track-id"))
			     (begtxt (find-child trackd "track-times"))
			     (trktxt (find-child trackd "track-track"))
			     (playb (find-child trackd "track-play"))
			     (spdscr (find-child trackd "track-speed"))
			     (ampscr (find-child trackd "track-amp"))
			     (ampenv (find-child trackd "track-amp-env-window"))
			     (temposcr (find-child trackd "track-tempo"))
			     (tempolab (find-child trackd "track-tempo-label"))
			     (db (find-child trackd "dB"))
			     (wave (find-child trackd "wave"))
			     (clip (find-child trackd "clip")))
			(set! (track-dialog-track) id3)
			(if (not (= (track-dialog-track) id3)) (snd-display ";track-dialog-track: ~A ~A" id3 (track-dialog-track)))
			(if (not (string=? (XmTextGetString trktxt) "0"))
			    (snd-display ";track initial track: ~A" (XmTextGetString trktxt)))
			(if (not (string=? (XmTextGetString idtxt) (number->string id3)))
			    (snd-display ";track initial id: ~A" (XmTextGetString idtxt)))
			(move-scroll ampscr 20)
			(click-button playb)
			(move-scroll spdscr 20)
			(click-button wave) (force-event)
			(for-each
			 (lambda (scrl)
			   (XtCallCallbacks scrl XmNdragCallback
					    (let ((cb (XmScrollBarCallbackStruct)))
					      (set! (.value cb) 50)
					      (set! (.event cb) (XEvent))
					      cb)))
			 (list spdscr ampscr temposcr))
			(for-each
			 (lambda (n)
			   (click-button n #t 0)
			   (click-button n #t ControlMask))
			 (map
			  (lambda (w) (find-child trackd w))
			  (list "track-speed-label" "track-amp-label" "track-tempo-label")))
			(if (XmDrawingArea? ampenv)
			    (let* ((xy (widget-size ampenv))
				   (x0 (inexact->exact (floor (/ (car xy) 2))))
				   (y0 (inexact->exact (floor (/ (cadr xy) 2)))))
			      (click-event ampenv 1 0 x0 y0)
			      (drag-event ampenv 1 0 x0 y0 (+ x0 20) (+ y0 20)))
			    (snd-display ";mix-dialog ampenv: ~A" ampenv))
			(force-event)
			(let ((edp (edit-position ind)))
			  (click-button (XmMessageBoxGetChild trackd XmDIALOG_CANCEL_BUTTON)) (force-event)
			  (if (= edp (edit-position ind)) 
			      (snd-display ";apply mix env: ~A" edp)
			      (undo 1 ind 0)))
			(click-button db) (force-event)
			(click-button clip) (force-event)
			(click-button clip) (force-event)
			(click-button wave) (force-event)
			(click-button db) (force-event)
			(focus-widget begtxt)
			(widget-string begtxt "0.5") (force-event)
			(key-event begtxt snd-return-key 0) (force-event)
			(widget-string trktxt "2") (force-event)
			(key-event trktxt snd-return-key 0) (force-event)
			(widget-string idtxt "2") (force-event)
			(key-event idtxt snd-return-key 0) (force-event)
			(XtSetKeyboardFocus trackd (XmMessageBoxGetChild trackd XmDIALOG_OK_BUTTON))
			(click-button (XmMessageBoxGetChild trackd XmDIALOG_OK_BUTTON)) (force-event)     ;dismiss
			(if (XtIsManaged trackd)
			    (XtUnmanageChild trackd))
			))
		    (XtCallCallbacks (menu-option "Tracks") XmNactivateCallback (snd-global-state))
		    (let ((trackd (list-ref (dialog-widgets) 21)))
		      (if (not (XtIsManaged trackd))
			  (snd-display ";why isn't track-dialog dialog alive?"))
		      (XtUnmanageChild trackd))

		    (close-sound ind))
		  
		  ;; ---------------- print dialog ----------------
		  (let* ((ind (open-sound "oboe.snd"))
			 (print-menu (menu-option "Print")))
		    (XtSetSensitive print-menu #t)
		    (click-button print-menu #t)
		    (let ((printd (list-ref (dialog-widgets) 17)))
		      (if (Widget? printd)
			  (begin
			    (if (not (XtIsManaged printd)) (XtManageChild printd))
			    (let ((txt (find-child printd "text")))
			      (XmTextSetString txt "test.eps")
			      (click-button (XmMessageBoxGetChild printd XmDIALOG_OK_BUTTON))
			      (if (not (file-exists? "test.eps"))
				  (snd-display ";print -> test.eps?")
				  (delete-file "test.eps"))
			      (XtSetKeyboardFocus printd (XmMessageBoxGetChild printd XmDIALOG_CANCEL_BUTTON))
			      (click-button (XmMessageBoxGetChild printd XmDIALOG_CANCEL_BUTTON))
			      (if (XtIsManaged printd)
				  (snd-display ";why is print dialog alive?"))))
			  (snd-display ";no print dialog?"))
		      (close-sound ind)))
		  
		  ;; ---------------- recorder dialog ----------------
		  (let ((old-val (with-background-processes)))
		    (set! (with-background-processes) #f) ; turns off recorder background process altogether
		    (if (not (list-ref (dialog-widgets) 18))
			(recorder-dialog))
		    (if (Widget? (list-ref (dialog-widgets) 18))
			(let* ((recd (list-ref (dialog-widgets) 18))
			       (file-pane (find-child recd "file-pane"))
			       (record (find-child recd "record-button"))
			       ;; cancel -> reset, ok -> dismiss
			       )
			  (if (not (XtIsManaged recd)) (XtManageChild recd))
			  (click-button record) (force-event)
			  (click-button record) (force-event)
			  (click-button (XmMessageBoxGetChild recd XmDIALOG_CANCEL_BUTTON)) (force-event)
			  (click-button (XmMessageBoxGetChild recd XmDIALOG_OK_BUTTON)) (force-event)
			  ))
		    (set! (with-background-processes) old-val))
		  
		  ;; ---------------- region dialog ----------------
		  (let ((ind (open-sound "4.aiff")))
		    (do ((i 0 (1+ i)))
			((= i 4))
		      (set! (selection-member? ind i) #t)
		      (set! (selection-position ind i) 0)
		      (set! (selection-frames ind i) 100))
		    (let ((id (make-region)))
		      (if (not (= (region-chans id) 4)) (snd-display ";region(dialog) ~A chans ~A" id (region-chans id))))
		    (let ((id (make-region)))
		      (if (not (= (region-chans id) 4)) (snd-display ";region(dialog) ~A chans ~A" id (region-chans id))))
		    (close-sound ind))
		  (view-regions-dialog)
		  (let* ((regd (list-ref (dialog-widgets) 19))
			 (prtb (find-child regd "print"))
			 (grf (find-child regd "grf"))
			 (downb (find-child grf "down"))
			 (upb (find-child grf "up"))
			 (frm (find-child regd "formw"))
			 (rw1 (find-child frm "rw"))
			 (pl1 (find-child rw1 "pl"))
			 (nm1 (find-child rw1 "nm"))
			 (editb (find-child regd "edit"))
			 (name (cadr (XmStringGetLtoR (cadr (XtVaGetValues nm1 (list XmNlabelString 0))) XmFONTLIST_DEFAULT_TAG))))
		    (XmToggleButtonSetState pl1 #t #t)
		    (XmToggleButtonSetState pl1 #f #t)
		    (click-button nm1)
		    (click-button (XmMessageBoxGetChild regd XmDIALOG_CANCEL_BUTTON)) (force-event)		  
		    (let ((name1 (cadr (XmStringGetLtoR (cadr (XtVaGetValues nm1 (list XmNlabelString 0))) XmFONTLIST_DEFAULT_TAG))))
		      (if (string=? name1 name)
			  (snd-display ";delete in region dialog: ~A?" name)))
		    (click-button prtb) (force-event)
		    (let* ((reglist (find-child regd "reglist"))
			   (ww (find-child reglist "ww")))
		      (if (not (Widget? ww)) (snd-display ";can't find region dialog region list"))
		      (for-each-child ww 
				      (lambda (w) 
					(if (XmIsPushButton w)
					    (let ((label (widget-text w)))
					      (if (and (string? label)
						       (> (string-length label) 3))
						  (begin
						    (XtCallCallbacks w XmNactivateCallback #f)
						    (if (XtIsSensitive downb)
							(begin
							  (click-button downb #t) (force-event)
							  (click-button upb #t) (force-event))))))))))
		    (let ((snds (sounds)))
		      (click-button editb #t) (force-event)
		      (let ((new-snds (sounds)))
			(if (not (= (length snds) (1- (length new-snds)))) (snd-display ";region edit: ~A -> ~A" snds new-snds))
			(for-each 
			 (lambda (snd)
			   (if (not (member snd snds)) 
			       (begin
				 (save-sound-as "reg.snd" snd)
				 (delete-file "reg.snd")
				 (close-sound snd))))
			 new-snds)))
		    (let ((regs (length (regions))))
		      (do ((i 0 (1+ i)))
			  ((> i regs))
			(click-button (XmMessageBoxGetChild regd XmDIALOG_CANCEL_BUTTON)) (force-event))
		      (if (not (null? (regions)))
			  (snd-display ";click through regions: ~A" (regions))))
		    (click-button (XmMessageBoxGetChild regd XmDIALOG_OK_BUTTON)) (force-event)		  
		    (if (XtIsManaged regd)
			(snd-display ";region dialog is still active?")))
		  (c-g!)
		  
		  (let* ((ind (open-sound "oboe.snd"))
			 (grf (car (channel-widgets ind 0)))
			 (xs (x-bounds))
			 (ax (axis-info ind 0 time-graph))
			 (x0 (list-ref ax 10))
			 (y0 (list-ref ax 11))
			 (x1 (list-ref ax 12))
			 (y1 (list-ref ax 13))
			 (midx (inexact->exact (floor (* 0.5 (+ x0 x1)))))
			 (midy (inexact->exact (floor (* 0.5 (+ y0 y1))))))
		    (set! (cursor) 500)
		    (click-event grf 0 4 midx midy) (force-event)
		    (update-time-graph)
		    (let ((new-xs (x-bounds)))
		      (if (> (abs (- (* 2 (- (cadr new-xs) (car new-xs))) (- (cadr xs) (car xs)))) (/ (- (cadr xs) (car xs)) 3))
			  (snd-display ";4 xs: ~A -> ~A" xs (x-bounds))))
		    (close-sound ind))

		  (if (> (length (sounds)) 0) (snd-display ";into zero: ~A" (sounds)))
		  (let ((ind (open-sound "zero.snd")))
		    (select-all)
		    (if (selection?)
			(snd-display ";select-all zero selected?"))
		    (for-each
		     (lambda (m)
		       (if (XtIsSensitive m)
			   (snd-display ";select-all zero: ~A?" (XtName m))))
		     (list (menu-option "Delete Selection")
			   (menu-option "Insert Selection C-x i")
			   (menu-option "Play Selection   C-x p")
			   (menu-option "Mix Selection    C-x q")
			   (menu-option "Save Selection   C-x w")))
		    (close-sound ind))
		  
		  ))))
      (reset-hook! snd-error-hook)
      (run-hook after-test-hook 24)
      ))


(set! (optimization) 0)


;;; ---------------- test 25: X/Xt/Xm --------------------

(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 (/ (.red col) 65535.0)
		    (/ (.green col) 65535.0)
		    (/ (.blue col) 65535.0)))))

(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 (or full-test (= snd-test 25) (and keep-going (<= snd-test 25)))
    (begin
      (run-hook before-test-hook 25)
      (if (and (provided? 'snd-motif) (provided? 'xm) (not (provided? 'gl)))
	  (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 ";Dimension miscast: ~A ~A" wid hgt)))
	    
	    ;; ---------------- X tests ----------------
	    (let ((scr (current-screen))
		  (dpy (XtDisplay (cadr (main-widgets)))))
	      (if (not (= (.height scr) 1200))
		  (snd-display ";screen height: ~A" (.height scr)))
	      (if (not (= (.width scr) 1600))
		  (snd-display ";screen width: ~A" (.width scr)))
	      (let ((ratio (/ (.mwidth scr) (.width scr))))
		(if (> (abs (- (* ratio (.height scr)) (.mheight scr))) 2)
		    (snd-display ";mheight/width: ~A ~A" (.mheight scr) (.mwidth scr))))
	      (if (not (= (.ndepths scr) 7))
		  (snd-display ";screen ndepths: ~A" (.ndepths scr)))
	      (let ((dps (.depths scr)))
		(if (or (not (= (length dps) (.ndepths scr)))
			(not (Depth? (car dps))))
		    (snd-display ";depths: ~A" (.depths scr)))
		(if (not (= (.depth (car dps)) 24)) (snd-display ";.depths val: ~A" (map .depth dps)))
		(if (not (= (.nvisuals (car dps)) 8)) (snd-display ";nvisuals: ~A" (map .nvisuals dps)))
		(if (not (null? (.visuals (car dps))))
		    (if (not (Visual? (car (.visuals (car dps))))) 
			(snd-display ";visuals: ~A" (map .visuals dps))
			(if (not (= (.bits_per_rgb (car (.visuals (car dps)))) 8))
			    (snd-display ";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 ";visuals: ~A" (map .visuals dps))
			    (if (not (= (.bits_per_rgb (car (.visuals (cadr dps)))) 8))
				(snd-display ";bits/visuals: ~A" (map .bits_per_rgb (.visuals (cadr dps)))))))))
	      (if (not (= (cadr (.white_pixel scr)) 16777215))
		  (snd-display ";screen white_pixel: ~A" (.white_pixel scr)))
	      (if (not (= (cadr (.black_pixel scr)) 0))
		  (snd-display ";screen black_pixel: ~A" (.black_pixel scr)))
	      (if (not (eq? (.backing_store scr) #f))
		  (snd-display ";screen backing_store: ~A" (.backing_store scr)))
	      (if (not (= (.min_maps scr) 1))
		  (snd-display ";screen min_maps: ~A" (.min_maps scr)))
	      (if (not (= (.max_maps scr) 1))
		  (snd-display ";screen max_maps: ~A" (.max_maps scr)))
	      (if (not (eq? (.save_unders scr) #f))
		  (snd-display ";screen save_unders: ~A" (.save_unders scr)))
	      (if (not (GC? (.default_gc scr)))
		  (snd-display ";screen default_gc: ~A" (.default_gc scr)))
	      (if (not (Window? (.root scr)))
		  (snd-display ";screen root: ~A" (.root scr)))
	      (if (not (Colormap? (.cmap scr)))
		  (snd-display ";screen colormap: ~A" (.cmap scr)))
	      
	      (if (not (equal? (DisplayOfScreen scr) (.display scr))) 
		  (snd-display ";DisplayOfScreen: ~A ~A" (DisplayOfScreen scr) (.display scr)))
	      (if (not (equal? (RootWindowOfScreen scr) (.root scr))) 
		  (snd-display ";RootWindowOfScreen: ~A ~A" (RootWindowOfScreen scr) (.root scr)))
	      (if (not (equal? (BlackPixelOfScreen scr) (.black_pixel scr))) 
		  (snd-display ";BlackPixelOfScreen: ~A ~A" (BlackPixelOfScreen scr) (.black_pixel scr)))
	      (if (not (equal? (WhitePixelOfScreen scr) (.white_pixel scr))) 
		  (snd-display ";WhitePixelOfScreen: ~A ~A" (WhitePixelOfScreen scr) (.white_pixel scr)))
	      (if (not (equal? (DefaultColormapOfScreen scr) (.cmap scr))) 
		  (snd-display ";DefaultColormapOfScreen: ~A ~A" (DefaultColormapOfScreen scr) (.cmap scr)))
	      (if (not (equal? (DefaultDepthOfScreen scr) (.root_depth scr))) 
		  (snd-display ";DefaultDepthOfScreen: ~A ~A" (DefaultDepthOfScreen scr) (.root_depth scr)))
	      (if (not (equal? (DefaultGCOfScreen scr) (.default_gc scr))) 
		  (snd-display ";DefaultGCOfScreen: ~A ~A" (DefaultGCOfScreen scr) (.default_gc scr)))
	      (if (not (equal? (DefaultVisualOfScreen scr) (.root_visual scr))) 
		  (snd-display ";DefaultVisualOfScreen: ~A ~A" (DefaultVisualOfScreen scr) (.root_visual scr)))
	      (if (not (equal? (WidthOfScreen scr) (.width scr))) 
		  (snd-display ";WidthOfScreen: ~A ~A" (WidthOfScreen scr) (.width scr)))
	      (if (not (equal? (HeightOfScreen scr) (.height scr))) 
		  (snd-display ";HeightOfScreen: ~A ~A" (HeightOfScreen scr) (.height scr)))
	      (if (not (equal? (WidthMMOfScreen scr) (.mwidth scr))) 
		  (snd-display ";WidthMMOfScreen: ~A ~A" (WidthMMOfScreen scr) (.mwidth scr)))
	      (if (not (equal? (HeightMMOfScreen scr) (.mheight scr))) 
		  (snd-display ";HeightMMOfScreen: ~A ~A" (HeightMMOfScreen scr) (.mheight scr)))
	      (if (not (equal? (PlanesOfScreen scr) (.root_depth scr))) 
		  (snd-display ";PlanesOfScreen: ~A ~A" (PlanesOfScreen scr) (.root_depth scr)))
	      (if (not (equal? (MinCmapsOfScreen scr) (.min_maps scr))) 
		  (snd-display ";MinCmapsOfScreen: ~A ~A" (MinCmapsOfScreen scr) (.min_maps scr)))
	      (if (not (equal? (MaxCmapsOfScreen scr) (.max_maps scr))) 
		  (snd-display ";MaxCmapsOfScreen: ~A ~A" (MaxCmapsOfScreen scr) (.max_maps scr)))
	      (if (not (equal? (DoesSaveUnders scr) (.save_unders scr))) 
		  (snd-display ";DoesSaveUnders: ~A ~A" (DoesSaveUnders scr) (.save_unders scr)))
	      (if (not (equal? (DoesBackingStore scr) (.backing_store scr))) 
		  (snd-display ";DoesBackingStore: ~A ~A" (DoesBackingStore scr) (.backing_store scr)))
	      (if (not (equal? (EventMaskOfScreen scr) (.root_input_mask scr))) 
		  (snd-display ";EventMaskOfScreen: ~A ~A" (EventMaskOfScreen scr) (.root_input_mask scr)))
	      
	      (if (not (equal? (XDisplayOfScreen scr) (.display scr))) 
		  (snd-display ";XDisplayOfScreen: ~A ~A" (XDisplayOfScreen scr) (.display scr)))
	      (if (not (equal? (XDisplayOfScreen (XScreenOfDisplay dpy 0)) dpy))
		  (snd-display ";XScreenOfDisplay ~A ~A" (XDisplayOfScreen (XScreenOfDisplay dpy 0)) dpy))
	      (if (not (equal? (XDefaultScreenOfDisplay dpy) scr))
		  (snd-display ";XDefaultScreenOfDisplay ~A ~A" (XDefaultScreenOfDisplay dpy) scr))
	      (if (not (equal? (XRootWindowOfScreen scr) (.root scr))) 
		  (snd-display ";XRootWindowOfScreen: ~A ~A" (XRootWindowOfScreen scr) (.root scr)))
	      (if (not (equal? (XBlackPixelOfScreen scr) (.black_pixel scr))) 
		  (snd-display ";XBlackPixelOfScreen: ~A ~A" (XBlackPixelOfScreen scr) (.black_pixel scr)))
	      (if (not (equal? (XWhitePixelOfScreen scr) (.white_pixel scr))) 
		  (snd-display ";XWhitePixelOfScreen: ~A ~A" (XWhitePixelOfScreen scr) (.white_pixel scr)))
	      (if (not (equal? (XDefaultColormapOfScreen scr) (.cmap scr))) 
		  (snd-display ";XDefaultColormapOfScreen: ~A ~A" (XDefaultColormapOfScreen scr) (.cmap scr)))
	      (if (not (equal? (XDefaultDepthOfScreen scr) (.root_depth scr))) 
		  (snd-display ";XDefaultDepthOfScreen: ~A ~A" (XDefaultDepthOfScreen scr) (.root_depth scr)))
	      (if (not (equal? (XDefaultGCOfScreen scr) (.default_gc scr)))
		  (snd-display ";XDefaultGCOfScreen: ~A ~A" (XDefaultGCOfScreen scr) (.default_gc scr)))
	      (if (not (equal? (XDefaultVisualOfScreen scr) (.root_visual scr)))
		  (snd-display ";XDefaultVisualOfScreen: ~A ~A" (XDefaultVisualOfScreen scr) (.root_visual scr)))
	      (if (not (equal? (XWidthOfScreen scr) (.width scr)))
		  (snd-display ";XWidthOfScreen: ~A ~A" (XWidthOfScreen scr) (.width scr)))
	      (if (not (equal? (XHeightOfScreen scr) (.height scr)))
		  (snd-display ";XHeightOfScreen: ~A ~A" (XHeightOfScreen scr) (.height scr)))
	      (if (not (equal? (XWidthMMOfScreen scr) (.mwidth scr))) 
		  (snd-display ";XWidthMMOfScreen: ~A ~A" (XWidthMMOfScreen scr) (.mwidth scr)))
	      (if (not (equal? (XHeightMMOfScreen scr) (.mheight scr))) 
		  (snd-display ";XHeightMMOfScreen: ~A ~A" (XHeightMMOfScreen scr) (.mheight scr)))
	      (if (not (equal? (XPlanesOfScreen scr) (.root_depth scr))) 
		  (snd-display ";XPlanesOfScreen: ~A ~A" (XPlanesOfScreen scr) (.root_depth scr)))
	      (if (not (equal? (XMinCmapsOfScreen scr) (.min_maps scr)))
		  (snd-display ";XMinCmapsOfScreen: ~A ~A" (XMinCmapsOfScreen scr) (.min_maps scr)))
	      (if (not (equal? (XMaxCmapsOfScreen scr) (.max_maps scr)))
		  (snd-display ";XMaxCmapsOfScreen: ~A ~A" (XMaxCmapsOfScreen scr) (.max_maps scr)))
	      (if (not (equal? (XDoesSaveUnders scr) (.save_unders scr)))
		  (snd-display ";XDoesSaveUnders: ~A ~A" (XDoesSaveUnders scr) (.save_unders scr)))
	      (if (not (equal? (XDoesBackingStore scr) (.backing_store scr))) 
		  (snd-display ";XDoesBackingStore: ~A ~A" (XDoesBackingStore scr) (.backing_store scr)))
	      (if (not (equal? (XEventMaskOfScreen scr) (.root_input_mask scr)))
		  (snd-display ";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 ";RootWindow: ~A ~A" (RootWindow dpy scrn) (.root scr)))
	      (if (not (equal? (DefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
		  (snd-display ";DefaultRootWindow: ~A ~A" (DefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
	      (if (not (equal? (DefaultVisual dpy scrn) (.root_visual scr)))
		  (snd-display ";DefaultVisual: ~A ~A" (DefaultVisual dpy scrn) (.root_visual scr)))
	      (if (not (equal? (DefaultGC dpy scrn) (.default_gc scr)))
		  (snd-display ";DefaultGC: ~A ~A" (DefaultGC dpy scrn) (.default_gc scr)))
	      (if (not (equal? (BlackPixel dpy scrn) (.black_pixel scr)))
		  (snd-display ";BlackPixel: ~A ~A" (BlackPixel dpy scrn) (.black_pixel scr)))
	      (if (not (equal? (WhitePixel dpy scrn) (.white_pixel scr)))
		  (snd-display ";WhitePixel ~A ~A" (WhitePixel dpy scrn) (.white_pixel scr)))
	      (if (not (equal? (DisplayWidth dpy scrn) (.width scr)))
		  (snd-display ";DisplayWidth: ~A ~A" (DisplayWidth dpy scrn) (.width scr)))
	      (if (not (equal? (DisplayHeight dpy scrn) (.height scr)))
		  (snd-display ";DisplayHeight: ~A ~A" (DisplayHeight dpy scrn) (.height scr)))
	      (if (not (equal? (DisplayWidthMM dpy scrn) (.mwidth scr)))
		  (snd-display ";DisplayWidthMM: ~A ~A" (DisplayWidthMM dpy scrn) (.mwidth scr)))
	      (if (not (equal? (DisplayHeightMM dpy scrn) (.mheight scr)))
		  (snd-display ";DisplayHeightMM: ~A ~A" (DisplayHeightMM dpy scrn) (.mheight scr)))
	      (if (not (equal? (DisplayPlanes dpy scrn) (.root_depth scr)))
		  (snd-display ";DisplayPlanes: ~A ~A" (DisplayPlanes dpy scrn) (.root_depth scr)))
	      (if (not (equal? (DefaultDepth dpy scrn) (.root_depth scr)))
		  (snd-display ";DefaultDepth: ~A ~A" (DefaultDepth dpy scrn) (.root_depth scr)))
	      (if (not (equal? (DefaultColormap dpy scrn) (.cmap scr)))
		  (snd-display ";DefaultColormap: ~A ~A" (DefaultColormap dpy scrn) (.cmap scr)))
	      
	      (if (not (equal? (XRootWindow dpy scrn) (.root scr)))
		  (snd-display ";XRootWindow: ~A ~A" (XRootWindow dpy scrn) (.root scr)))
	      (if (not (equal? (XDefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
		  (snd-display ";XDefaultRootWindow: ~A ~A" (XDefaultRootWindow dpy) (.root (ScreenOfDisplay dpy (DefaultScreen dpy)))))
	      (if (not (equal? (XDefaultVisual dpy scrn) (.root_visual scr)))
		  (snd-display ";XDefaultVisual: ~A ~A" (XDefaultVisual dpy scrn) (.root_visual scr)))
	      (if (not (equal? (XDefaultGC dpy scrn) (.default_gc scr)))
		  (snd-display ";XDefaultGC: ~A ~A" (XDefaultGC dpy scrn) (.default_gc scr)))
	      (if (not (equal? (XBlackPixel dpy scrn) (.black_pixel scr)))
		  (snd-display ";XBlackPixel: ~A ~A" (XBlackPixel dpy scrn) (.black_pixel scr)))
	      (if (not (equal? (XWhitePixel dpy scrn) (.white_pixel scr)))
		  (snd-display ";XWhitePixel ~A ~A" (XWhitePixel dpy scrn) (.white_pixel scr)))
	      (if (not (equal? (XDisplayWidth dpy scrn) (.width scr)))
		  (snd-display ";XDisplayWidth: ~A ~A" (XDisplayWidth dpy scrn) (.width scr)))
	      (if (not (equal? (XDisplayHeight dpy scrn) (.height scr)))
		  (snd-display ";XDisplayHeight: ~A ~A" (XDisplayHeight dpy scrn) (.height scr)))
	      (if (not (equal? (XDisplayWidthMM dpy scrn) (.mwidth scr)))
		  (snd-display ";XDisplayWidthMM: ~A ~A" (XDisplayWidthMM dpy scrn) (.mwidth scr)))
	      (if (not (equal? (XDisplayHeightMM dpy scrn) (.mheight scr)))
		  (snd-display ";XDisplayHeightMM: ~A ~A" (XDisplayHeightMM dpy scrn) (.mheight scr)))
	      (if (not (equal? (XDisplayPlanes dpy scrn) (.root_depth scr)))
		  (snd-display ";XDisplayPlanes: ~A ~A" (XDisplayPlanes dpy scrn) (.root_depth scr)))
	      (if (not (equal? (XDefaultDepth dpy scrn) (.root_depth scr)))
		  (snd-display ";XDefaultDepth: ~A ~A" (XDefaultDepth dpy scrn) (.root_depth scr)))
	      (if (not (equal? (XDefaultColormap dpy scrn) (.cmap scr)))
		  (snd-display ";XDefaultColormap: ~A ~A" (XDefaultColormap dpy scrn) (.cmap scr)))
	      
	      (if (not (equal? (XDefaultVisual dpy scrn) vis))
		  (snd-display ";XDefaultVisual: ~A ~A" (XDefaultVisual dpy scrn) vis))
	      (if (not (equal? (DisplayCells dpy scrn) (.map_entries vis)))
		  (snd-display ";DisplayCells: ~A ~A" (DisplayCells dpy scrn) (.map_entries vis)))
	      (if (not (equal? (CellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
		  (snd-display ";CellsOfScreen: ~A ~A" (CellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
	      (if (not (equal? (XDisplayCells dpy scrn) (.map_entries vis)))
		  (snd-display ";XDisplayCells: ~A ~A" (XDisplayCells dpy scrn) (.map_entries vis)))
	      (if (not (equal? (XCellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
		  (snd-display ";XCellsOfScreen: ~A ~A" (XCellsOfScreen scr) (.map_entries (DefaultVisualOfScreen scr))))
	      (if (< (XNextRequest dpy) (XLastKnownRequestProcessed dpy))
		  (snd-display ";XRequests: ~A ~A" (XNextRequest dpy) (XLastKnownRequestProcessed dpy)))
	      (if (< (NextRequest dpy) (LastKnownRequestProcessed dpy))
		  (snd-display ";Requests: ~A ~A" (NextRequest dpy) (LastKnownRequestProcessed dpy)))
	      (if (not (= (XDisplayMotionBufferSize dpy) 256))
		  (snd-display ";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 ";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) 1048575))
		  (snd-display ";XExtendedMaxRequestSize ~A" (XExtendedMaxRequestSize dpy)))
	      (if (not (= (XMaxRequestSize dpy) 65535))
		  (snd-display ";XMaxRequestSize ~A" (XMaxRequestSize dpy)))
	      (if (not (member (list 'Atom 40) (XListProperties dpy win)))
		  (snd-display ";XListProperties: ~A" (XListProperties dpy win)))
	      (if (not (member "SHAPE" (XListExtensions dpy)))
		  (snd-display ";XListExtensions: ~A" (XListExtensions dpy)))
	      (if (not (= (length (XListFontsWithInfo dpy "-*-times-medium-r-*-*-*-*-*-*-*-*-*-*" 4)) 4))
		  (snd-display ";XListFontsWithInfo: ~A" (XListFontsWithInfo dpy "-*-times-medium-r-*-*-*-*-*-*-*-*-*-*" 4)))
	      (if (not (= (length (XListFonts dpy "-*-times-medium-r-*-*-*-*-*-*-*-*-*-*" 4)) 4))
		  (snd-display ";XListFonts: ~A" (XListFonts dpy "-*-times-medium-r-*-*-*-*-*-*-*-*-*-*" 4)))
	      (let ((val (XListInstalledColormaps dpy win)))
		(if (or (not val)
			(null? val)
			(not (Colormap? (car val))))
		    (snd-display ";XListInstalledColormaps: ~A" (XListInstalledColormaps dpy win))))
	      (if (not (string=? (XKeysymToString (list 'KeySym 80)) "P"))
		  (snd-display ";XKeysymToString: ~A" (XKeysymToString (list 'KeySym 80))))
	      (if (not (string=? (XGetAtomName dpy (list 'Atom 40)) "WM_NORMAL_HINTS"))
		  (snd-display ";XGetAtomName: ~A" (XGetAtomName dpy (list 'Atom 40))))
	      
	      (if (not (= (.bits_per_rgb vis) 8)) (snd-display ";bits_per_rgb: ~A" (.bits_per_rgb vis)))
	      (if (not (= (.blue_mask vis) 255)) (snd-display ";blue_mask: ~A" (.blue_mask vis)))
	      (if (not (= (.green_mask vis) 65280)) (snd-display ";green_mask: ~A" (.green_mask vis)))
	      (if (not (= (.red_mask vis) 16711680)) (snd-display ";red_mask: ~A" (.red_mask vis)))
	      (if (not (= AllPlanes 4294967295)) (snd-display ";AllPlanes: ~A" AllPlanes))
	      
	      (if (< (QLength dpy) 0) (snd-display ";QLength: ~A" (QLength dpy)))
	      (if (not (= (ScreenCount dpy) 1)) (snd-display ";ScreenCount: ~A" (ScreenCount dpy)))
	      (if (not (string=? (ServerVendor dpy) "The XFree86 Project, Inc")) (snd-display ";ServerVendor: ~A" (ServerVendor dpy)))
	      (if (not (= (ProtocolRevision dpy) 0)) (snd-display ";ProtocolRevision: ~A" (ProtocolRevision dpy)))
	      (if (not (= (ProtocolVersion dpy) 11)) (snd-display ";ProtocolVersion: ~A" (ProtocolVersion dpy)))
	      (if (not (number? (VendorRelease dpy))) (snd-display ";VendorRelease: ~A" (VendorRelease dpy)))
	      (if (not (string=? (DisplayString dpy) ":0.0")) (snd-display ";DisplayString: ~A" (DisplayString dpy)))
	      (if (not (= (BitmapUnit dpy) 32)) (snd-display ";BitmapUnit: ~A" (BitmapUnit dpy)))
	      (if (not (= (BitmapPad dpy) 32)) (snd-display ";BitmapPad: ~A" (BitmapPad dpy)))
	      (if (not (= (BitmapBitOrder dpy) 0)) (snd-display ";BitmapBitOrder: ~A" (BitmapBitOrder dpy)))
	      (if (not (= (ImageByteOrder dpy) 0)) (snd-display ";ImageByteOrder: ~A" (ImageByteOrder dpy)))
	      (if (not (= (DefaultScreen dpy) 0)) (snd-display ";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 ";XAllocNamedColor blue ~A?" col))
		(if (not (= (.red col) 0)) (snd-display ";XAllocNamedColor: ~A" (.red col)))
		(if (= (XAllocColor dpy cmap col) 0) (snd-display ";XAllocColor?"))
		(if (not (= (.red col) 0)) (snd-display ";XAllocColor: ~A" (.red col)))
		(if (= (XParseColor dpy cmap "blue" col) 0) (snd-display ";XParseColor?"))
		(if (not (= (.red col) 0)) (snd-display ";XParseColor: ~A" (.red col)))
		(if (= (XAllocNamedColor dpy cmap "green" col1 col1) 0) (snd-display ";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 ";XDisplayKeycodes: ~A" (XDisplayKeycodes dpy)))
	      (let ((str (XFetchName dpy win)))
		(if (not (string=? str "snd"))
		    (snd-display ";XFetchName: ~A" str)))
	      (XStoreName dpy win "hiho")
	      (let ((str (XFetchName dpy win)))
		(if (not (string=? str "hiho"))
		    (snd-display ";XStoreName: ~A" str)))
	      (XStoreName dpy win "snd")
	      (let ((str (XGetIconName dpy win)))
		(if (not (string=? str "snd"))
		    (snd-display ";XGetIconName: ~A" str)))
	      (XSetIconName dpy win "hiho")
	      (let ((str (XGetIconName dpy win)))
		(if (not (string=? str "hiho"))
		    (snd-display ";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 ";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 ";XGetInputFocus: ~A" focus)))
	      (let ((vals (XGetPointerControl dpy)))
		(if (not (equal? vals (list 1 2 1 4))) (snd-display ";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 ";set pointer state: ~A" vals))
		(XChangePointerControl dpy #f #t 2 1 4))
	      (let ((vals (beep-state)))
		(if (not (= (car vals) 100)) (snd-display ";beep state: ~A" vals))
		(set! (beep-state) (list 100 200 100))
		(set! vals (beep-state))
		(if (not (= (cadr vals) 200)) (snd-display ";set beep state: ~A" vals)))
	      (XAutoRepeatOff dpy)
	      (if (not (= (list-ref (XGetKeyboardControl dpy) 5) 0)) (snd-display ";AutoRepeatOff?"))
	      (XAutoRepeatOn dpy)
	      (if (not (= (list-ref (XGetKeyboardControl dpy) 5) 1)) (snd-display ";AutoRepeatOn?"))
	      (let ((vals (XGetPointerMapping dpy 0 3)))
		(if (not (equal? vals (list 1 2 3))) (snd-display ";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 ";XMoveWindow x etc: ~A" (.x attr)))
		(if (> (abs (- (.y attr) 20)) 200) (snd-display ";XMoveWindow y etc: ~A" (.y attr)))
		(if (> (abs (- (.width attr) 500)) 20) (snd-display ";XMoveWindow width etc: ~A" (.width attr)))
		(if (> (abs (- (.height attr) 500)) 20) (snd-display ";XMoveWindow height etc: ~A" (.height attr)))
		(if (not (= (.border_width attr) 0)) (snd-display ";XGetWindowAttributes border_width: ~A" (.border_width attr)))
		(if (not (= (.depth attr) 24)) (snd-display ";XGetWindowAttributes depth: ~A" (.depth attr)))
		(if (not (= (.bit_gravity attr) 0)) (snd-display ";XGetWindowAttributes bit_gravity: ~A" (.bit_gravity attr)))
		(if (not (= (.win_gravity attr) 1)) (snd-display ";XGetWindowAttributes win_gravity: ~A" (.win_gravity attr)))
		(if (.backing_store attr) (snd-display ";XGetWindowAttributes backing_store: ~A" (.backing_store attr)))
		(if (.override_redirect attr) (snd-display ";XGetWindowAttributes override_redirect: ~A" (.override_redirect attr)))
		(if (.save_under attr) (snd-display ";XGetWindowAttributes save_under: ~A" (.save_under attr)))
		(if (not (.map_installed attr)) (snd-display ";XGetWindowAttributes map_installed: ~A" (.map_installed attr)))
		(if (not (equal? (.backing_pixel attr) (list 'Pixel 0))) (snd-display ";XGetWindowAttributes backing_pixel: ~A" (.backing_pixel attr)))
		(if (not (= (.map_state attr) 2)) (snd-display ";XGetWindowAttributes map_state: ~A" (.map_state attr)))
		(if (not (= (.your_event_mask attr) #x628033)) (snd-display ";your_event_mask: ~X" (.your_event_mask attr)))
		(if (not (= (.all_event_masks attr) #xe28033)) (snd-display ";all_event_masks: ~X" (.all_event_masks attr)))
		(if (not (Screen? (.screen attr))) (snd-display ";XGetWindowAttributes screen: ~A" (.screen attr)))
		(if (not (= (.do_not_propagate_mask attr) 0)) (snd-display ";XGetWindowAttributes do_not_propagate_mask: ~A" (.do_not_propagate_mask attr)))
		(if (not (= (.backing_planes attr) AllPlanes)) (snd-display ";XGetWindowAttributes backing_planes: ~A" (.backing_planes attr)))
		(if (not (= (.win_gravity attr) 1)) (snd-display ";XGetWindowAttributes win_gravity: ~A" (.win_gravity attr)))
		(if (not (= (.bit_gravity attr) 0)) (snd-display ";XGetWindowAttributes bit_gravity: ~A" (.bit_gravity attr))))
	      (XResetScreenSaver dpy)
	      (if (< (XPending dpy) 0) (snd-display ";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 ";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 ";XQueryTree: ~A (~A)" tree (XRootWindow dpy 0))))
	      
	      (if (< (XQLength dpy) 0) (snd-display ";XQLength: ~A" (XQLength dpy)))
	      (if (not (= (XScreenCount dpy) 1)) (snd-display ";XScreenCount: ~A" (XScreenCount dpy)))
	      (if (not (string=? (XServerVendor dpy) "The XFree86 Project, Inc")) (snd-display ";XServerVendor: ~A" (XServerVendor dpy)))
	      (if (not (= (XProtocolRevision dpy) 0)) (snd-display ";XProtocolRevision: ~A" (XProtocolRevision dpy)))
	      (if (not (= (XProtocolVersion dpy) 11)) (snd-display ";XProtocolVersion: ~A" (XProtocolVersion dpy)))
	      (if (not (number? (XVendorRelease dpy))) (snd-display ";XVendorRelease: ~A" (XVendorRelease dpy)))
	      (if (not (string=? (XDisplayString dpy) ":0.0")) (snd-display ";XDisplayString: ~A" (XDisplayString dpy)))
	      (if (not (= (XBitmapUnit dpy) 32)) (snd-display ";XBitmapUnit: ~A" (XBitmapUnit dpy)))
	      (if (not (= (XBitmapPad dpy) 32)) (snd-display ";XBitmapPad: ~A" (XBitmapPad dpy)))
	      (if (not (= (XBitmapBitOrder dpy) 0)) (snd-display ";XBitmapBitOrder: ~A" (XBitmapBitOrder dpy)))
	      (if (not (= (XImageByteOrder dpy) 0)) (snd-display ";XImageByteOrder: ~A" (XImageByteOrder dpy)))
	      (if (not (= (XDefaultScreen dpy) 0)) (snd-display ";XDefaultScreen: ~A" (XDefaultScreen dpy)))
	      (if (XGetIconSizes dpy win) (snd-display ";XGetIconSizes: ~A" (XGetIconSizes dpy win)))
	      (if (XGetStandardColormap dpy win XA_RGB_DEFAULT_MAP)
		  (snd-display ";XGetStandardColormap: ~A!" (XGetStandardColormap dpy win XA_RGB_DEFAULT_MAP)))
	      (if (XGetRGBColormaps dpy win XA_RGB_DEFAULT_MAP)
		  (snd-display ";XGetRGBColormaps: ~A!" (XGetRGBColormaps dpy win XA_RGB_DEFAULT_MAP)))
	      (let ((cmap (XAllocStandardColormap)))
		(for-each 
		 (lambda (func name)
		   (if (not (= (func cmap) 0)) (snd-display ";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 ";colormap: ~A" (.colormap cmap))))
	      (let ((icon (XAllocIconSize)))
		(for-each
		 (lambda (func name)
		   (if (not (= (func icon) 0)) (snd-display ";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-*-180-100-100-*-*")))
		(if (or (not (XFontSet? fs))
			(= (cadr fs) 0))
		    (snd-display ";XCreateFontSet: ~A" fs)
		    (let* ((fnts (XFontsOfFontSet fs))
			   (fnt (caar fnts)))
		      (if (not (XFontStruct? fnt))
			  (snd-display ";XFontsOfFontSet: ~A" fnts))
		      (if (XContextualDrawing fs)
			  (snd-display ";XContextualDrawing: ~A" (XContextualDrawing fs)))
		      (if (XContextDependentDrawing fs)
			  (snd-display ";XContextDependentDrawing: ~A" (XContextDependentDrawing fs)))
		      (if (XDirectionalDependentDrawing fs)
			  (snd-display ";XDirectionalDependentDrawing: ~A" (XDirectionalDependentDrawing fs)))
		      (if (not (string=? (XLocaleOfFontSet fs) "en_US"))
			  (snd-display ";XLocaleOfFontSet: ~A" (XLocaleOfFontSet fs)))
		      (if (not (string=? (XBaseFontNameListOfFontSet fs) "*-*-*-*-Normal-*-180-100-100-*-*"))
			  (snd-display ";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) 180)))
				(snd-display ";XGetFontProperty: ~A ~A" wgt siz))
			    (if (not (= (.descent fnt) 5)) (snd-display ";descent: ~A" (.descent fnt)))
			    (if (not (= (.ascent fnt) 18)) (snd-display ";ascent: ~A" (.ascent fnt)))
			    (if (not (XCharStruct? (.per_char fnt))) (snd-display ";per_char: ~A" (.per_char fnt)))
			    (if (not (XCharStruct? (.max_bounds fnt))) (snd-display ";max_bounds: ~A" (.max_bounds fnt)))
			    (if (not (XCharStruct? (.min_bounds fnt))) (snd-display ";min_bounds: ~A" (.min_bounds fnt)))
			    (if (not (XFontProp? (car (.properties fnt)))) (snd-display ";properties ~A" (.properties fnt)))
			    (if (not (= (.card32 (car (.properties fnt))) 15)) (snd-display ";card32: ~A" (.card32 (car (.properties fnt)))))))
		      (XFreeFontSet dpy fs))))
	      
	      (let ((dpy (XtDisplay (cadr (main-widgets))))
		    (win (XtWindow (cadr (main-widgets))))
		    (eKeyPress (XEvent KeyPress))
		    (eButtonPress (XEvent ButtonPress))
		    (eMotionNotify (XEvent MotionNotify))
		    (eEnterNotify (XEvent EnterNotify))
		    (eFocusIn (XEvent FocusIn))
		    (eKeymapNotify (XEvent KeymapNotify))
		    (eExpose (XEvent Expose))
		    (eGraphicsExpose (XEvent GraphicsExpose))
		    (eNoExpose (XEvent NoExpose))
		    (eVisibilityNotify (XEvent VisibilityNotify))
		    (eCreateNotify (XEvent CreateNotify))
		    (eDestroyNotify (XEvent DestroyNotify))
		    (eUnmapNotify (XEvent UnmapNotify))
		    (eMapNotify (XEvent MapNotify))
		    (eMapRequest (XEvent MapRequest))
		    (eReparentNotify (XEvent ReparentNotify))
		    (eConfigureNotify (XEvent ConfigureNotify))
		    (eConfigureRequest (XEvent ConfigureRequest))
		    (eGravityNotify (XEvent GravityNotify))
		    (eResizeRequest (XEvent ResizeRequest))
		    (eCirculateNotify (XEvent CirculateNotify))
		    (eCirculateRequest (XEvent CirculateRequest))
		    (ePropertyNotify (XEvent PropertyNotify))
		    (eSelectionClear (XEvent SelectionClear))
		    (eSelectionRequest (XEvent SelectionRequest))
		    (eSelectionNotify (XEvent SelectionNotify))
		    (eColormapNotify (XEvent ColormapNotify))
		    (eClientMessage (XEvent ClientMessage))
		    (eMappingNotify (XEvent MappingNotify)))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eKeyPress) val)
		   (if (not (equal? (func eKeyPress) val)) (snd-display ";eKeyPress ~A ~A" name (func eKeyPress))))
		 (list .type .serial .send_event .display .window .root .subwindow .time .x .y .x_root .y_root .state .keycode .same_screen)
		 (list KeyPress 0 #f dpy win win win (list 'Time 0) 0 0 0 0 0 (list 'KeyCode 0) #f)
		 (list 'type 'serial 'send_event 'display 'window 'root 'subwindow 'time 'x 'y 'x_root 'y_root 'state 'keycode 'same_screen))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eButtonPress) val)
		   (if (not (equal? (func eButtonPress) val)) (snd-display ";eButtonPress ~A ~A" name (func eButtonPress))))
		 (list .type .serial .send_event .display .window .root .subwindow .time .x .y .x_root .y_root .state .button .same_screen)
		 (list ButtonPress 0 #f dpy win win win (list 'Time 0) 0 0 0 0 0 0 #f)
		 (list 'type 'serial 'send_event 'display 'window 'root 'subwindow 'time 'x 'y 'x_root 'y_root 'state 'button 'same_screen))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eMotionNotify) val)
		   (if (not (equal? (func eMotionNotify) val)) (snd-display ";eMotionNotify ~A ~A" name (func eMotionNotify))))
		 (list .type .serial .send_event .display .window .root .subwindow .time .x .y .x_root .y_root .state .is_hint .same_screen)
		 (list MotionNotify 0 #f dpy win win win (list 'Time 0) 0 0 0 0 0 0 #f)
		 (list 'type 'serial 'send_event 'display 'window 'root 'subwindow 'time 'x 'y 'x_root 'y_root 'state 'is_hint 'same_screen))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eEnterNotify) val)
		   (if (not (equal? (func eEnterNotify) val)) (snd-display ";eEnterNotify ~A ~A" name (func eEnterNotify))))
		 (list .type .serial .send_event .display .window .root .subwindow .time .x .y .x_root .y_root .mode .detail .same_screen .focus .state)
		 (list EnterNotify 0 #f dpy win win win (list 'Time 0) 0 0 0 0 0 0 #f #f 0)
		 (list 'type 'serial 'send_event 'display 'window 'root 'subwindow 'time 'x 'y 'x_root 'y_root 'mode 'detail 'same_screen 'focus 'state))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eFocusIn) val)
		   (if (not (equal? (func eFocusIn) val)) (snd-display ";eFocusIn ~A ~A" name (func eFocusIn))))
		 (list .type .serial .send_event .display .window .mode .detail)
		 (list FocusIn 0 #f dpy win 0 0)
		 (list 'type 'serial 'send_event 'display 'window 'mode 'detail))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eKeymapNotify) val)
		   (if (not (equal? (func eKeymapNotify) val)) (snd-display ";eKeymapNotify ~A ~A" name (func eKeymapNotify))))
		 (list .type .serial .send_event .display .window .key_vector)
		 (list KeymapNotify 0 #f dpy win "hiho")
		 (list 'type 'serial 'send_event 'display 'window 'key-vector))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eExpose) val)
		   (if (not (equal? (func eExpose) val)) (snd-display ";eExpose ~A ~A" name (func eExpose))))
		 (list .type .serial .send_event .display .window .x .y .width .height .count)
		 (list Expose 0 #f dpy win 0 0 0 0 0)
		 (list 'type 'serial 'send_event 'display 'window 'x 'y 'width 'height 'count))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eGraphicsExpose) val)
		   (if (not (equal? (func eGraphicsExpose) val)) (snd-display ";eGraphicsExpose ~A ~A" name (func eGraphicsExpose))))
		 (list .type .serial .send_event .display .drawable .x .y .width .height .count .major_code .minor_code)
		 (list GraphicsExpose 0 #f dpy win 0 0 0 0 0 0 0)
		 (list 'type 'serial 'send_event 'display 'drawable 'x 'y 'width 'height 'count 'major_code 'minor_code))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eNoExpose) val)
		   (if (not (equal? (func eNoExpose) val)) (snd-display ";eNoExpose ~A ~A" name (func eNoExpose))))
		 (list .type .serial .send_event .display .drawable .major_code .minor_code)
		 (list NoExpose 0 #f dpy win 0 0)
		 (list 'type 'serial 'send_event 'display 'drawable 'major_code 'minor_code))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eVisibilityNotify) val)
		   (if (not (equal? (func eVisibilityNotify) val)) (snd-display ";eVisibilityNotify ~A ~A" name (func eVisibilityNotify))))
		 (list .type .serial .send_event .display .window .state)
		 (list VisibilityNotify 0 #f dpy win 0)
		 (list 'type 'serial 'send_event 'display 'window 'state))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eCreateNotify) val)
		   (if (not (equal? (func eCreateNotify) val)) (snd-display ";eCreateNotify ~A ~A" name (func eCreateNotify))))
		 (list .type .serial .send_event .display .parent .window .x .y .width .height .border_width .override_redirect)
		 (list CreateNotify 0 #f dpy win win 0 0 0 0 0 #f)
		 (list 'type 'serial 'send_event 'display 'parent 'window 'x 'y 'width 'height 'border_width 'override_redirect))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eDestroyNotify) val)
		   (if (not (equal? (func eDestroyNotify) val)) (snd-display ";eDestroyNotify ~A ~A" name (func eDestroyNotify))))
		 (list .type .serial .send_event .display .window)
		 (list DestroyNotify 0 #f dpy win)
		 (list 'type 'serial 'send_event 'display 'window))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eUnmapNotify) val)
		   (if (not (equal? (func eUnmapNotify) val)) (snd-display ";eUnmapNotify ~A ~A" name (func eUnmapNotify))))
		 (list .type .serial .send_event .event .display .window .from_configure)
		 (list UnmapNotify 0 #f win dpy win #f)
		 (list 'type 'serial 'send_event 'event 'display 'window 'from_configure))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eMapNotify) val)
		   (if (not (equal? (func eMapNotify) val)) (snd-display ";eMapNotify ~A ~A" name (func eMapNotify))))
		 (list .type .serial .send_event .event .display .window .override_redirect)
		 (list MapNotify 0 #f win dpy win #f)
		 (list 'type 'serial 'send_event 'event 'display 'window 'override_redirect))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eMapRequest) val)
		   (if (not (equal? (func eMapRequest) val)) (snd-display ";eMapRequest ~A ~A" name (func eMapRequest))))
		 (list .type .serial .send_event .display .window)
		 (list MapRequest 0 #f dpy win)
		 (list 'type 'serial 'send_event 'display 'window))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eReparentNotify) val)
		   (if (not (equal? (func eReparentNotify) val)) (snd-display ";eReparentNotify ~A ~A" name (func eReparentNotify))))
		 (list .type .serial .send_event .event .display .window .parent .x .y .override_redirect)
		 (list ReparentNotify 0 #f win dpy win win 0 0 #f)
		 (list 'type 'serial 'send_event 'event 'display 'window 'parent 'x 'y 'override_redirect))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eConfigureNotify) val)
		   (if (not (equal? (func eConfigureNotify) val)) (snd-display ";eConfigureNotify ~A ~A" name (func eConfigureNotify))))
		 (list .type .serial .send_event .display .window .x .y .width .height .border_width .above .override_redirect)
		 (list ConfigureNotify 0 #f dpy win 0 0 0 0 0 win #f)
		 (list 'type 'serial 'send_event 'display 'window 'x 'y 'width 'height 'border_width 'above 'override_redirect))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eGravityNotify) val)
		   (if (not (equal? (func eGravityNotify) val)) (snd-display ";eGravityNotify ~A ~A" name (func eGravityNotify))))
		 (list .type .serial .send_event .event .display .window .x .y)
		 (list GravityNotify 0 #f win dpy win 0 0)
		 (list 'type 'serial 'send_event 'event 'display 'window 'x 'y))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eResizeRequest) val)
		   (if (not (equal? (func eResizeRequest) val)) (snd-display ";eResizeRequest ~A ~A" name (func eResizeRequest))))
		 (list .type .serial .send_event .display .window .width .height)
		 (list ResizeRequest 0 #f dpy win 0 0)
		 (list 'type 'serial 'send_event 'display 'window 'width 'height))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eConfigureRequest) val)
		   (if (not (equal? (func eConfigureRequest) val)) (snd-display ";eConfigureRequest ~A ~A" name (func eConfigureRequest))))
		 (list .type .serial .send_event .display .parent .window .x .y .width .height .border_width .above .detail .value_mask)
		 (list ConfigureRequest 0 #f dpy win win 0 0 0 0 0 win 0 0)
		 (list 'type 'serial 'send_event 'display 'parent 'window 'x 'y 'width 'height 'border_width 'above 'detail 'value_mask))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eCirculateNotify) val)
		   (if (not (equal? (func eCirculateNotify) val)) (snd-display ";eCirculateNotify ~A ~A" name (func eCirculateNotify))))
		 (list .type .serial .send_event .display .window .event .place)
		 (list CirculateNotify 0 #f dpy win win 0)
		 (list 'type 'serial 'send_event 'display 'window 'event 'place))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eCirculateRequest) val)
		   (if (not (equal? (func eCirculateRequest) val)) (snd-display ";eCirculateRequest ~A ~A" name (func eCirculateRequest))))
		 (list .type .serial .send_event .display .window .parent .place)
		 (list CirculateRequest 0 #f dpy win win 0)
		 (list 'type 'serial 'send_event 'display 'window 'parent 'place))
		
		(for-each
		 (lambda (func val name)
		   (set! (func ePropertyNotify) val)
		   (if (not (equal? (func ePropertyNotify) val)) (snd-display ";ePropertyNotify ~A ~A" name (func ePropertyNotify))))
		 (list .type .serial .send_event .display .window .atom .time .state)
		 (list PropertyNotify 0 #f dpy win XA_STRING (list 'Time 0) 0)
		 (list 'type 'serial 'send_event 'display 'window 'atom 'time 'state))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eSelectionClear) val)
		   (if (not (equal? (func eSelectionClear) val)) (snd-display ";eSelectionClear ~A ~A" name (func eSelectionClear))))
		 (list .type .serial .send_event .display .window .selection .time)
		 (list SelectionClear 0 #f dpy win XA_STRING (list 'Time 0))
		 (list 'type 'serial 'send_event 'display 'window 'atom 'time))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eSelectionRequest) val)
		   (if (not (equal? (func eSelectionRequest) val)) (snd-display ";eSelectionRequest ~A ~A" name (func eSelectionRequest))))
		 (list .type .serial .send_event .display .owner .requestor .selection .target .property .time)
		 (list SelectionRequest 0 #f dpy win win XA_STRING XA_STRING XA_STRING (list 'Time 0))
		 (list 'type 'serial 'send_event 'display 'owner 'requestor 'selection 'target 'property 'time))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eSelectionNotify) val)
		   (if (not (equal? (func eSelectionNotify) val)) (snd-display ";eSelectionNotify ~A ~A" name (func eSelectionNotify))))
		 (list .type .serial .send_event .display .requestor .selection .target .property .time)
		 (list SelectionNotify 0 #f dpy win XA_STRING XA_STRING XA_STRING (list 'Time 0))
		 (list 'type 'serial 'send_event 'display 'requestor 'selection 'target 'property 'time))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eColormapNotify) val)
		   (if (not (equal? (func eColormapNotify) val)) (snd-display ";eColormapNotify ~A ~A" name (func eColormapNotify))))
		 (list .type .serial .send_event .display .window .colormap .state)
		 (list ColormapNotify 0 #f dpy win (XDefaultColormap dpy (XScreenNumberOfScreen (DefaultScreenOfDisplay dpy))) 0)
		 (list 'type 'serial 'send_event 'display 'window 'colormap 'state))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eMappingNotify) val)
		   (if (not (equal? (func eMappingNotify) val)) (snd-display ";eMappingNotify ~A ~A" name (func eMappingNotify))))
		 (list .type .serial .send_event .display .window .request .first_keycode .count)
		 (list MappingNotify 0 #f dpy win 0 0 0)
		 (list 'type 'serial 'send_event 'display 'window 'request 'first_keycode 'count))
		
		(for-each
		 (lambda (func val name)
		   (set! (func eClientMessage) val)
		   (if (not (equal? (func eClientMessage) val)) (snd-display ";eClientMessage ~A ~A" name (func eClientMessage))))
		 (list .type .serial .send_event .display .window .message_type .format .data)
		 (list ClientMessage 0 #f dpy win XA_STRING 8 "gogo")
		 (list 'type 'serial 'send_event 'display 'window 'message_type 'format 'data))
		)
	      
	      (XBell dpy 10)
	      (let ((cmd (XGetCommand dpy win)))
		(if (or (not (> (length cmd) 0))
			(not (string=? (substring (car cmd) (- (string-length (car cmd)) 3)) "snd")))
		    (snd-display ";XGetCommand: ~A" cmd)))
	      (XSetCommand dpy win (list "hiho" "away") 2)
	      (if (not (equal? (XGetCommand dpy win) (list "hiho" "away"))) 
		  (snd-display ";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 ";XGetWMProtocols: ~A" wmp)))
	      (if (not (equal? (XListDepths dpy 0) (list 24 1 4 8 15 16 32)))
		  (snd-display ";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 ";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 ";XQueryBestCursor: ~A" cs)))
	      (let ((pt (XQueryPointer dpy win)))
		(if (not (Window? (cadr pt))) (snd-display ";XQueryPointer: ~A" pt)))
	      (XRaiseWindow dpy win)
	      (XRotateBuffers dpy 1)
	      (XSetWindowBorderWidth dpy win 10)
	      (XSetWindowBorder dpy win (black-pixel))
	      (XSetWindowBackground dpy win (basic-color))
	      (let ((depth (.depth (car (XGetVisualInfo dpy 0 (list 'XVisualInfo 0))))))
		(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))
	      (let ((hints (XGetWMHints dpy win)))
		(if (or (not hints) (not (XWMHints? hints))) (snd-display ";XGetWMHints?"))
		(if (not (= (.flags hints) 7)) (snd-display ";flags wmhints: ~A" (.flags hints)))
		(if (not (= (.initial_state hints) 1)) (snd-display ";initial_state wmhints: ~A" (.initial_state hints)))
		(if (not (.input hints)) (snd-display ";input wmhints: ~A" (.input hints)))
		(if (not (Pixmap? (.icon_pixmap hints))) (snd-display ";icon_pixmap wmhints: ~A" (.icon_pixmap hints)))
		(if (.icon_window hints) (snd-display ";icon_window: ~A" (.icon_window hints)))
		(if (not (= (.icon_x hints) -1)) (snd-display ";icon_x wmhints: ~A" (.icon_x hints)))
		(if (not (= (.icon_y hints) -1)) (snd-display ";icon_y wmhints: ~A" (.icon_y hints)))
		(if (not (equal? (.icon_mask hints) (list 'Pixmap 0))) (snd-display ";icon_mask: ~A" (.icon_mask hints)))
		(if (not (number? (.window_group hints))) (snd-display ";window_group: ~A" (.window_group hints)))
		(let ((st (XAllocWMHints)))
		  (if (not (XWMHints? st)) (snd-display ";XAllocWMHints: ~A" st))
		  (XFree st))))
	    
	    (if (not (IsKeypadKey (list 'KeySym XK_KP_Space))) (snd-display ";IsKeypadKey kp-space"))
	    (if (IsKeypadKey (list 'KeySym XK_A)) (snd-display ";IsKeypadKey A"))
	    (if (IsPrivateKeypadKey (list 'KeySym XK_A)) (snd-display ";IsPrivateKeypadKey A"))
	    (if (not (IsCursorKey (list 'KeySym XK_Home))) (snd-display ";IsCursorKey Home"))
	    (if (IsCursorKey (list 'KeySym XK_S)) (snd-display ";IsCursorKey S"))
	    (if (not (IsPFKey (list 'KeySym XK_KP_F1))) (snd-display ";IsPFKey F1"))
	    (if (IsPFKey (list 'KeySym XK_S)) (snd-display ";IsPFKey S"))
	    (if (not (IsFunctionKey (list 'KeySym XK_F1))) (snd-display ";IsFunctionKey F1"))
	    (if (IsFunctionKey (list 'KeySym XK_S)) (snd-display ";IsFunctionKey S"))
	    (if (not (IsMiscFunctionKey (list 'KeySym XK_Select))) (snd-display ";IsMiscFunctionKey Select"))
	    (if (IsMiscFunctionKey (list 'KeySym XK_S)) (snd-display ";IsMiscFunctionKey S"))
	    (if (not (IsModifierKey (list 'KeySym XK_Shift_L))) (snd-display ";IsModifierKey Shift"))
	    (if (IsModifierKey (list 'KeySym XK_S)) (snd-display ";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 ";function: ~A ~A" (.function val) GXclear))
	      (set! (.line_width val) 10)
	      (if (not (equal? (.line_width val) 10)) 
		  (snd-display ";line_width: ~A ~A" (.line_width val) 10))
	      (set! (.line_style val) LineSolid)
	      (if (not (equal? (.line_style val) LineSolid)) 
		  (snd-display ";line_style: ~A ~A" (.line_style val) LineSolid))
	      (set! (.background val) (WhitePixelOfScreen (current-screen)))
	      (if (not (equal? (.background val) (WhitePixelOfScreen (current-screen)))) 
		  (snd-display ";background: ~A ~A" (.background val) (WhitePixelOfScreen (current-screen))))
	      (set! (.foreground val) (BlackPixelOfScreen (current-screen)))
	      (if (not (equal? (.foreground val) (BlackPixelOfScreen (current-screen)))) 
		  (snd-display ";foreground: ~A ~A" (.foreground val) (BlackPixelOfScreen (current-screen))))
	      ;; plane_mask?
	      (set! (.cap_style val) CapRound)
	      (if (not (equal? (.cap_style val) CapRound)) 
		  (snd-display ";cap_style: ~A ~A" (.cap_style val) CapRound))
	      (set! (.join_style val) JoinMiter)
	      (if (not (equal? (.join_style val) JoinMiter)) 
		  (snd-display ";join_style: ~A ~A" (.join_style val) JoinMiter))
	      (set! (.fill_style val) FillSolid)
	      (if (not (equal? (.fill_style val) FillSolid)) 
		  (snd-display ";fill_style: ~A ~A" (.fill_style val) FillSolid))
	      (set! (.fill_rule val) EvenOddRule)
	      (if (not (equal? (.fill_rule val) EvenOddRule)) 
		  (snd-display ";fill_rule: ~A ~A" (.fill_rule val) EvenOddRule))
	      (set! (.arc_mode val) ArcChord)
	      (if (not (equal? (.arc_mode val) ArcChord))
		  (snd-display ";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 ";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 ";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 ";subwindow_mode: ~A ~A" (.subwindow_mode val) ClipByChildren))
	      (set! (.graphics_exposures val) #f)
	      (if (not (equal? (.graphics_exposures val) #f)) 
		  (snd-display ";graphics_exposures: ~A ~A" (.graphics_exposures val) #f))
	      (set! (.clip_x_origin val) 0)
	      (if (not (equal? (.clip_x_origin val) 0)) 
		  (snd-display ";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 ";clip_y_origin: ~A ~A" (.clip_y_origin val) 0))
	      (set! (.dash_offset val) 1)
	      (if (not (equal? (.dash_offset val) 1))
		  (snd-display ";dash_offset: ~A ~A" (.dash_offset val) 1))
	      (if (not (number? (XConnectionNumber dpy)))
		  (snd-display ";XConnectionNumber: ~A" (XConnectionNumber dpy)))
	      
	      (let ((gc (XCreateGC dpy wn (+ GCFunction GCForeground GCBackground GCLineWidth GCLineStyle 
					     GCCapStyle GCJoinStyle GCFillStyle GCFillRule GCTileStipXOrigin
					     GCTileStipYOrigin GCSubwindowMode GCGraphicsExposures GCClipXOrigin
					     GCClipYOrigin GCDashOffset GCArcMode)
				   val)))
		
		(if (not (GC? gc)) (snd-display ";XCreateGC returned ~A" gc))
		(XSetArcMode dpy gc ArcPieSlice)
		(XSetFunction dpy gc GXcopy)
		(XSetLineAttributes dpy gc 3 LineDoubleDash CapButt JoinMiter)
		(XSetClipOrigin dpy gc 1 1)
		(XSetTSOrigin dpy gc 0 0)
		(XSetFillRule dpy gc WindingRule)
		(XSetFillStyle dpy gc FillStippled)
		(XSetForeground dpy gc (WhitePixelOfScreen (current-screen)))
		(XSetBackground dpy gc (BlackPixelOfScreen (current-screen)))
		(XSetGraphicsExposures dpy gc #t)
		(XSetSubwindowMode dpy gc IncludeInferiors)
		(if (not (string=? "unix/:7100" (car (XGetFontPath dpy))))
		    (snd-display ";XGetFontPath: ~A" (XGetFontPath dpy)))
		(let ((owner (XGetSelectionOwner dpy XA_PRIMARY)))
		  (if (and owner (not (Window? owner)))
		      (snd-display ";XGetSelectionOwner: ~A" owner)))
		(let ((mods (XGetModifierMapping dpy)))
		  (if (not (XModifierKeymap? mods))
		      (snd-display ";XGetModifierMapping: ~A" mods)))
		(let ((vis (XGetVisualInfo dpy 0 (list 'XVisualInfo 0))))
		  (if (or (not vis)
			  (not (XVisualInfo? (car vis))))
		      (snd-display ";XGetVisualInfo: ~A" vis))
		  (if (not (= (.depth (car vis)) 24)) (snd-display ";depth vis: ~A" (.depth (car vis))))
		  (if (not (= (.screen (car vis)) 0)) (snd-display ";screen vis: ~A" (.screen (car vis))))
		  (if (not (= (.class (car vis)) TrueColor)) (snd-display ";class vis: ~A (~A)" (.class (car vis)) TrueColor))
		  (if (not (= (.colormap_size (car vis)) 256)) (snd-display ";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 ";XMatchVisualInfo: ~A" (XMatchVisualInfo dpy 0 24 TrueColor))))
		(let ((e (XEvent KeyPress))
		      (cast-current-time (list 'Time CurrentTime)))
		  (set! (.type e) KeyPress)
		  (set! (.window e) wn)
		  (set! (.display e) dpy)
		  (set! (.root e) (RootWindow dpy (DefaultScreen dpy)))
		  (set! (.x e) 0)
		  (set! (.y e) 0)
		  (set! (.x_root e) 0)
		  (set! (.y_root e) 0)
		  (set! (.keycode e) (XKeysymToKeycode dpy (list 'KeySym 60)))
		  (set! (.state e) 0)
		  (set! (.time e) cast-current-time)
		  (set! (.same_screen e) #t)
		  (set! (.subwindow e) (list 'Window None))
		  (let ((val (XLookupString e)))
		    (if (not (equal? val (list 1 "<" (list 'KeySym 60))))
			(snd-display ";XLookupString: ~A" val)))
		  (let ((val (XFilterEvent e wn)))
		    (if val (snd-display ";XFilterEvent: ~A" val)))
		  (let ((val (XLookupKeysym e 0)))
		    (if (not (equal? val (list 'KeySym 60)))
			(snd-display ";XLookupKeysym: ~A" val))))
		(XCheckMaskEvent dpy KeyPressMask)
		
		(let ((cursor (XCreateFontCursor dpy XC_circle)))
		  (if (not (Cursor? cursor)) 
		      (snd-display ";XCreateFontCursor: ~A" cursor)
		      (begin
			(XDefineCursor dpy wn cursor)
			(XUndefineCursor dpy wn)
			(let ((old (XmGetMenuCursor dpy)))
			  (if (not (Cursor? old)) (snd-display ";XmGetMenuCursor: ~A" old))
			  (XmSetMenuCursor dpy cursor)
			  (if (not (equal? cursor (XmGetMenuCursor dpy))) (snd-display ";XmSetMenuCursor: ~A ~A" cursor (XmGetMenuCursor dpy)))
			  (XmSetMenuCursor dpy old)))))
		
		(let* ((vals (XGetGCValues dpy gc (+ 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 ";XGetGCValues failed"))
		  
		  (if (not (equal? (.function val1) GXcopy))
		      (snd-display ";function: ~A ~A" (.function val1) GXcopy))
		  (if (not (equal? (.line_width val1) 3)) 
		      (snd-display ";line_width: ~A ~A" (.line_width val1) 3))
		  (if (not (equal? (.line_style val1) LineDoubleDash)) 
		      (snd-display ";line_style: ~A ~A" (.line_style val1) LineDoubleDash))
		  (if (not (equal? (.background val1) (BlackPixelOfScreen (current-screen)))) 
		      (snd-display ";background: ~A ~A" (.background val1) (BlackPixelOfScreen (current-screen))))
		  (if (not (equal? (.foreground val1) (WhitePixelOfScreen (current-screen)))) 
		      (snd-display ";foreground: ~A ~A" (.foreground val1) (WhitePixelOfScreen (current-screen))))
		  (if (not (equal? (.cap_style val1) CapButt)) 
		      (snd-display ";cap_style: ~A ~A" (.cap_style val1) CapButt))
		  (if (not (equal? (.join_style val1) JoinMiter)) 
		      (snd-display ";join_style: ~A ~A" (.join_style val1) JoinMiter))
		  (if (not (equal? (.fill_style val1) FillStippled)) 
		      (snd-display ";fill_style: ~A ~A" (.fill_style val1) FillStippled))
		  (if (not (equal? (.fill_rule val1) WindingRule)) 
		      (snd-display ";fill_rule: ~A ~A" (.fill_rule val1) WindingRule))
		  (if (not (equal? (.arc_mode val1) ArcPieSlice))
		      (snd-display ";arc_mode: ~A ~A" (.arc_mode val1) ArcPieSlice))
		  (if (not (equal? (.ts_x_origin val1) 0)) 
		      (snd-display ";ts_x_origin: ~A ~A" (.ts_x_origin val1) 0))
		  (if (not (equal? (.ts_y_origin val1) 0)) 
		      (snd-display ";ts_y_origin: ~A ~A" (.ts_y_origin val1) 0))
		  (if (not (equal? (.subwindow_mode val1) IncludeInferiors)) 
		      (snd-display ";subwindow_mode: ~A ~A" (.subwindow_mode val1) IncludeInferiors))
		  (if (not (equal? (.graphics_exposures val1) #t)) 
		      (snd-display ";graphics_exposures: ~A ~A" (.graphics_exposures val1) #t))
		  (if (not (equal? (.clip_x_origin val1) 1)) 
		      (snd-display ";clip_x_origin: ~A ~A" (.clip_x_origin val1) 1))
		  (if (not (equal? (.clip_y_origin val1) 1)) 
		      (snd-display ";clip_y_origin: ~A ~A" (.clip_y_origin val1) 1))
		  (if (not (equal? (.dash_offset val1) 1))
		      (snd-display ";dash_offset: ~A ~A" (.dash_offset val1) 1))
		  
		  (set! (.plane_mask val) 0)
		  (if (not (equal? (.plane_mask val) 0)) 
		      (snd-display ";plane_mask: ~A ~A" (.plane_mask val) 0))
		  (set! (.tile val) (list 'Pixmap 0))
		  (if (not (equal? (.tile val) (list 'Pixmap 0)))
		      (snd-display ";tile: ~A" (.tile val)))
		  (set! (.stipple val) (list 'Pixmap 0))
		  (if (not (equal? (.stipple val) (list 'Pixmap 0)))
		      (snd-display ";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 ";do_not_propagate_mask: ~A" (.do_not_propagate_mask attr)))
		    (if (not (= (.event_mask attr) 0)) (snd-display ";event_mask: ~A" (.event_mask attr)))
		    (if (not (Pixel? (.backing_pixel attr))) (snd-display ";backing_pixel: ~A" (.backing_pixel attr)))
		    (if (not (Pixel? (.border_pixel attr))) (snd-display ";border_pixel: ~A" (.border_pixel attr)))
		    (if (not (= (cadr (.border_pixmap attr)) 0)) (snd-display ";border_pixmap: ~A" (.border_pixmap attr)))
		    (if (not (Pixel? (.background_pixel attr))) (snd-display ";background_pixel: ~A" (.background_pixel attr)))
		    (if (not (= (cadr (.background_pixmap attr)) 0)) (snd-display ";background_pixmap: ~A" (.background_pixmap attr)))
		    (if (not (= (.backing_planes attr) 0)) (snd-display ";backing_planes: ~A" (.backing_planes attr)))
		    (if (.save_under attr) (snd-display ";save_under: ~A" (.save_under attr)))
		    (if (not (= (cadr (.cursor attr)) 0)) (snd-display ";cursor: ~A" (.cursor attr)))
		    (if (not (Window? newwin)) (snd-display ";XCreateWindow: ~A" newwin))
		    (if (not (= (.bit_gravity attr) 0)) (snd-display ";bit_gravity: ~A" (.bit_gravity attr)))
		    (XChangeWindowAttributes dpy newwin (logior 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 gc (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 ";make-pixmap?")
			(begin
			  (XSetTile dpy gc pix)
			  (XSetStipple dpy gc (XCreateBitmapFromData dpy wn right-arrow 16 12))
			  (XSetClipMask dpy gc None)
			  (XSetState dpy gc (basic-color) (mark-color) GXcopy 0)
			  (XSetPlaneMask dpy gc 0)
			  (XSetDashes dpy gc 0 '(3 4 3 1))
			  (XSetClipRectangles dpy gc 0 0 (list (XRectangle 0 0 10 10) (XRectangle 10 10 100 100)) 2 Unsorted)
			  (let ((err (XWriteBitmapFile dpy "test.data" pix 16 12 -1 -1)))
			    (if (not (= BitmapSuccess err)) (snd-display ";XWriteBitmapFile: ~A" err)))
					;(let ((vals (XReadBitmapFile dpy (XtWindow (cadr (main-widgets))) "test.data")))
					;  (if (not (= (car vals BitmapSuccess))) (snd-display ";XReadBitmapFile: ~A" vals)))
					;(let ((vals (XReadBitmapFileData "test.data")))
					;  (if (not (= (car vals BitmapSuccess))) (snd-display ";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 ";XCreateGlyphCursor: ~A" vals)))
			    (let ((vals (XCreatePixmapCursor dpy pix None col col1 5 5)))
			      (if (not (Cursor? vals)) (snd-display ";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 ";XLoadFont: ~A" fid))
		    (if (not (XFontStruct? fnt)) (snd-display ";XLoadQueryFont: ~A" fnt))
		    (if (not (XFontStruct? fnt1)) (snd-display ";XQueryFont: ~A" fnt1))
		    (if (not (XCharStruct? struct)) (snd-display ";XQueryTextExtents: ~A" chs))
		    (if (not (= (list-ref chs 2) 12)) (snd-display ";XQueryTextExtents max ascent: ~A" (list-ref chs 2)))
		    (if (not (= (list-ref chs 3) 3)) (snd-display ";XQueryTextExtents max descent: ~A" (list-ref chs 3)))
		    (if (not (= (.lbearing struct) 0)) (snd-display ";lbearing: ~A" (.lbearing struct)))
		    (if (not (= (.rbearing struct) 23)) (snd-display ";rbearing: ~A" (.rbearing struct)))
		    (if (not (= (.width struct) 24)) (snd-display ";width: ~A" (.width struct)))
		    (if (not (= (.ascent struct) 10)) (snd-display ";ascent: ~A" (.ascent struct)))
		    (if (not (= (.descent struct) 0)) (snd-display ";descent: ~A" (.descent struct)))
		    (if (not (= (.attributes struct) 0)) (snd-display ";attributes: ~A" (.attributes struct)))
		    (let ((fid (load-font "-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*")))
		      (if (not (Font? fid)) (snd-display ";load-font -> ~A" fid)))
		    )
		  (XFreeGC (XtDisplay (cadr (main-widgets))) gc)
		  )))
	    
	    (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 ";Atom: ~A -> ~A" name (Atom? n))))
	       atoms
	       atom-names))
	    
	    (let ((r (XRectangle 10 20 100 110)))
	      (if (not (= (.width r) 100))
		  (snd-display ";XRectangle width: ~A" (.width r)))
	      (if (not (= (.height r) 110))
		  (snd-display ";XRectangle height: ~A" (.height r)))
	      (if (not (= (.x r) 10))
		  (snd-display ";XRectangle x: ~A" (.x r)))
	      (if (not (= (.y r) 20))
		  (snd-display ";XRectangle y: ~A" (.y r)))
	      (set! (.width r) 10)
	      (if (not (= (.width r) 10))
		  (snd-display ";set XRectangle width: ~A" (.width r)))
	      (set! (.height r) 11)
	      (if (not (= (.height r) 11))
		  (snd-display ";set XRectangle height: ~A" (.height r)))
	      (set! (.x r) 1)
	      (if (not (= (.x r) 1))
		  (snd-display ";set XRectangle x: ~A" (.x r)))
	      (set! (.y r) 2)
	      (if (not (= (.y r) 2))
		  (snd-display ";XRectangle y: ~A" (.y r))))
	    
	    (let ((r (XArc 10 20 100 110 0 235)))
	      (if (not (= (.width r) 100))
		  (snd-display ";XArc width: ~A" (.width r)))
	      (if (not (= (.height r) 110))
		  (snd-display ";XArc height: ~A" (.height r)))
	      (if (not (= (.x r) 10))
		  (snd-display ";XArc x: ~A" (.x r)))
	      (if (not (= (.y r) 20))
		  (snd-display ";XArc y: ~A" (.y r)))
	      (if (not (= (.angle1 r) 0))
		  (snd-display ";XArc angle1: ~A" (.angle1 r)))
	      (if (not (= (.angle2 r) 235))
		  (snd-display ";XArc angle2: ~A" (.angle2 r)))
	      (set! (.width r) 10)
	      (if (not (= (.width r) 10))
		  (snd-display ";set XArc width: ~A" (.width r)))
	      (set! (.height r) 11)
	      (if (not (= (.height r) 11))
		  (snd-display ";set XArc height: ~A" (.height r)))
	      (set! (.x r) 1)
	      (if (not (= (.x r) 1))
		  (snd-display ";set XArc x: ~A" (.x r)))
	      (set! (.y r) 2)
	      (if (not (= (.y r) 2))
		  (snd-display ";set XArc y: ~A" (.y r)))
	      (set! (.angle1 r) 123)
	      (if (not (= (.angle1 r) 123))
		  (snd-display ";set XArc angle1: ~A" (.angle1 r)))
	      (set! (.angle2 r) 321)
	      (if (not (= (.angle2 r) 321))
		  (snd-display ";set XArc angle2: ~A" (.angle2 r))))
	    
	    (let ((r (XPoint 10 20)))
	      (if (not (= (.x r) 10))
		  (snd-display ";XPoint x: ~A" (.x r)))
	      (if (not (= (.y r) 20))
		  (snd-display ";XPoint y: ~A" (.y r)))
	      (set! (.x r) 1)
	      (if (not (= (.x r) 1))
		  (snd-display ";set XPoint x: ~A" (.x r)))
	      (set! (.y r) 2)
	      (if (not (= (.y r) 2))
		  (snd-display ";set XPoint y: ~A" (.y r))))
	    
	    (let ((r (XSegment 10 20 100 110)))
	      (if (not (= (.x1 r) 10))
		  (snd-display ";XSegment x1: ~A" (.x1 r)))
	      (if (not (= (.y1 r) 20))
		  (snd-display ";XSegment y1: ~A" (.y1 r)))
	      (if (not (= (.x2 r) 100))
		  (snd-display ";XSegment x2: ~A" (.x2 r)))
	      (if (not (= (.y2 r) 110))
		  (snd-display ";XSegment y2: ~A" (.y2 r)))
	      (set! (.x1 r) 1)
	      (if (not (= (.x1 r) 1))
		  (snd-display ";set XSegment x1: ~A" (.x1 r)))
	      (set! (.y1 r) 2)
	      (if (not (= (.y1 r) 2))
		  (snd-display ";set XSegment y1: ~A" (.y1 r)))
	      (set! (.x2 r) 10)
	      (if (not (= (.x2 r) 10))
		  (snd-display ";set XSegment x2: ~A" (.x2 r)))
	      (set! (.y2 r) 11)
	      (if (not (= (.y2 r) 11))
		  (snd-display ";set XSegment y2: ~A" (.y2 r))))
	    
	    (let ((c (XColor)))
	      (set! (.red c) 1)
	      (if (not (= (.red c) 1)) (snd-display ";Xcolor red: ~A" (.red c)))
	      (set! (.green c) 1)
	      (if (not (= (.green c) 1)) (snd-display ";Xcolor green: ~A" (.green c)))
	      (set! (.blue c) 1)
	      (if (not (= (.blue c) 1)) (snd-display ";Xcolor blue: ~A" (.blue c)))
	      (set! (.flags c) DoRed)
	      (if (not (= (.flags c) DoRed)) (snd-display ";Xcolor flags: ~A" (.flags c)))
	      (if (not (= (.pad c) 0)) (snd-display ";pad: ~A" (.pad c)))
	      (set! (.pixel c) (basic-color))
	      (if (not (equal? (.pixel c) (basic-color))) (snd-display ";Xcolor pixel: ~A" (.pixel c))))
	    
	    (let ((obj (XTextItem "hiho" 4 3 (list 'Font 1))))
	      (if (not (XTextItem? obj)) (snd-display ";XTextItem -> ~A" obj))
	      (if (not (equal? (.font obj) (list 'Font 1))) (snd-display ";font ~A" (.font obj)))
	      (set! (.font obj) (list 'Font 2))
	      (if (not (equal? (.font obj) (list 'Font 2))) (snd-display ";set font ~A" (.font obj)))
	      (if (not (string=? (.chars obj) "hiho")) (snd-display ";chars: ~A" (.chars obj)))
	      (if (not (= (.nchars obj) 4)) (snd-display ";chars: ~A" (.nchars obj)))
	      (set! (.chars obj) "away!")
	      (set! (.nchars obj) 5)
	      (if (not (string=? (.chars obj) "away!")) (snd-display ";set chars: ~A" (.chars obj)))
	      (if (not (= (.nchars obj) 5)) (snd-display ";set chars: ~A" (.nchars obj)))
	      (if (not (= (.delta obj) 3)) (snd-display ";delta ~A" (.delta obj)))
	      (set! (.delta obj) 4)
	      (if (not (= (.delta obj) 4)) (snd-display ";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 ";XPointInRegion"))
	      (XShrinkRegion reg 1 2)
	      (if (not (XPointInRegion reg 4 7)) (snd-display ";t XShrinkRegion"))
	      (if (XPointInRegion reg 4 9) (snd-display ";f XShrinkRegion"))
	      (XOffsetRegion reg 1 2)
	      (if (not (XPointInRegion reg 4 9)) (snd-display ";t XOffsetRegion"))
	      (if (XPointInRegion reg 1 9) (snd-display ";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 ";f XEqualRegion"))
		(if (XEmptyRegion reg) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";XFindContext: ~A" val)))
	      (XDeleteContext dpy 123 xid)
	      (XStoreBytes dpy "hiho" 4)
	      (if (not (string=? (XFetchBytes dpy) "hiho")) (snd-display ";XStoreBytes: ~A" (XFetchBytes dpy)))
	      (XStoreBuffer dpy "hiho" 4 1)
	      (if (not (string=? (XFetchBuffer dpy 1) "hiho")) (snd-display ";XStoreBuffer: ~A" (XFetchBuffer dpy)))
	      )
	    
	    
	    ;; ---------------- Xt tests ----------------
	    (let ((name (XtGetApplicationNameAndClass (XtDisplay (cadr (main-widgets))))))
	      (if (not (equal? name (list "snd" "Snd")))
		  (snd-display ";XtGetApplicationNameAndClass: ~A?" name)))
	    (let ((dpys (XtGetDisplays (car (main-widgets)))))
	      (if (not (Display? (car dpys)))
		  (snd-display ";XtGetDisplays: ~A?" dpys)))
	    (let ((time (XtGetSelectionTimeout))
		  (time1 (XtAppGetSelectionTimeout (car (main-widgets)))))
	      (if (or (not (number? time))
		      (not (= time time1))
		      (< time 1))
		  (snd-display ";XtGetSelectionTimeout: ~A ~A?" time time1))
	      (XtAppSetSelectionTimeout (car (main-widgets)) 4000)
	      (if (not (= (XtAppGetSelectionTimeout (car (main-widgets))) 4000))
		  (snd-display ";XtAppSetSelectionTimeout: ~A" (XtAppGetSelectionTimeout (car (main-widgets)))))
	      (XtAppSetSelectionTimeout (car (main-widgets)) time1))
	    (XtAppSetFallbackResources (car (main-widgets)) (list XmNfontList "9x15"))
	    (let ((app (XtDisplayToApplicationContext (XtDisplay (cadr (main-widgets)))))
		  (orig (car (main-widgets)))
		  (wid (XtWidgetToApplicationContext (cadr (main-widgets)))))
	      (if (not (equal? app orig))
		  (snd-display ";XtDisplayToApplicationContext: ~A ~A?" app orig))
	      (if (not (equal? app wid))
		  (snd-display ";XtWidgetToApplicationContext: ~A ~A?" app wid)))
	    (if (not (string=? (XtName (caddr (main-widgets))) "mainpane"))
		(snd-display ";XtName main pane: ~A" (XtName (caddr (main-widgets)))))
	    (if (not (= (XtGetMultiClickTime (XtDisplay (cadr (main-widgets)))) 200))
		(snd-display ";XtGetMultiClickTime: ~A" (XtGetMultiClickTime (XtDisplay (cadr (main-widgets))))))
	    (XtSetMultiClickTime (XtDisplay (cadr (main-widgets))) 250)
	    (if (not (= (XtGetMultiClickTime (XtDisplay (cadr (main-widgets)))) 250))
		(snd-display ";XtSetMultiClickTime: ~A" (XtGetMultiClickTime (XtDisplay (cadr (main-widgets))))))
	    (XtGetResourceList xmListWidgetClass)

	    (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 ";XtIsApplicationShell"))
	      (if (not (XtIsApplicationShell shell)) (snd-display ";XtIsApplicationShell of appshell"))
	      (if (not (XtIsComposite wid)) (snd-display ";XtIsComposite"))
	      (if (not (XtIsConstraint wid)) (snd-display ";XtIsConstraint"))
	      (if (XtIsManaged wid) (snd-display ";XtIsManaged"))
	      (if (not (XtIsObject wid)) (snd-display ";XtIsObject"))
	      (if (XtIsOverrideShell wid) (snd-display ";XtIsOverrideShell"))
	      (if (XtIsRealized wid) (snd-display ";XtIsRealized"))
	      (if (not (XtIsRealized shell)) (snd-display ";XtIsRealized main shell"))
	      (if (not (XtIsRectObj wid)) (snd-display ";XtIsRectObj"))
	      (if (not (XtIsSensitive wid)) (snd-display ";XtIsSensitive"))
	      (if (not (XtIsSensitive shell)) (snd-display ";XtIsSensitive of main shell"))
	      (XtSetSensitive wid1 #t)
	      (if (not (XtIsSensitive wid1)) (snd-display ";XtIsSensitive of button"))
	      (if (XtIsSessionShell wid) (snd-display ";XtIsSessionShell"))
	      (if (XtIsShell wid) (snd-display ";XtIsShell"))
	      (if (not (XtIsShell shell)) (snd-display ";XtIsShell of main shell"))
	      (if (XtIsTopLevelShell wid) (snd-display ";XtIsTopLevelShell"))
	      (if (not (XtIsTopLevelShell shell)) (snd-display ";XtIsTopLevelShell of main shell"))
	      (if (XtIsTransientShell wid) (snd-display ";XtIsTransientShell"))
	      (if (XtIsVendorShell wid) (snd-display ";XtIsVendorShell"))
	      (if (not (XtIsVendorShell shell)) (snd-display ";XtIsVendorShell of main shell"))
	      (if (XtIsWMShell wid) (snd-display ";XtIsWMShell"))
	      (if (not (XtIsWidget wid)) (snd-display ";XtIsWidget"))
	      (XtRealizeWidget wid)
	      (if (not (XtIsRealized wid)) (snd-display ";XtRealizeWidget?"))
	      (XtAddGrab shell #f #f)
	      (XtRemoveGrab shell)
	      (XtMakeResizeRequest wid 200 200)
	      (XtMapWidget wid)
	      (XtUnmapWidget wid)
	      (XtUnrealizeWidget wid)
	      (XtDestroyWidget wid1))
	    (XtAppWarningMsg (car (main-widgets)) "conversionError" "string" "hi" "oops" '("hi") 1)
	    (XtWarningMsg "conversionError" "string" "hi" "oops: %s" (list "hi") 1)
	    (XtFree 0) (XtCalloc 0 0) (XtMalloc 0) (XtRealloc 0 0)
	    (XtSetLanguageProc 
	     (car (main-widgets)) 
	     (lambda (dpy str data)
	       (snd-display ";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 ";XtClass shell: ~A" (XtClass shell)))
	      (if (not (equal? (XtSuperclass shell) topLevelShellWidgetClass))
		  (snd-display ";XtSuperclass shell: ~A" (XtClass shell)))
	      (if (not (string=? (XtName shell) "snd"))
		  (snd-display ";XtName: ~A" (XtName shell)))
	      (if (not (equal? (XtWindow shell) (XtWindowOfObject shell)))
		  (snd-display ";XtWindow: ~A ~A" (XtWindow shell) (XtWindowOfObject shell)))
	      (if (not (equal? (XtScreen shell) (XtScreenOfObject shell)))
		  (snd-display ";XtScreen: ~A ~A" (XtScreen shell) (XtScreenOfObject shell)))
	      (if (not (equal? (XtDisplay shell) (XtDisplayOfObject shell)))
		  (snd-display ";XtDisplay: ~A ~A" (XtDisplay shell) (XtDisplayOfObject shell)))
	      (if (not (Time? (XtLastTimestampProcessed dpy)))
		  (snd-display ";XtLastTimestampProcessed: ~A" (XtLastTimestampProcessed dpy)))
	      (if (not (XEvent? (XtLastEventProcessed dpy)))
		  (snd-display ";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 ";XtConvertCase: ~A" k))
		(if (not (equal? k x))
		    (snd-display ";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 ";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 ";XtTranslateKeycode: ~A" vals))
		(if (not (equal? vals (XtTranslateKey dpy (list 'KeyCode XK_B) 0)))
		    (snd-display ";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 ";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 ";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 ";XtSetKeyTranslator: ~A ~A" vals newvals)))
		(XtSetKeyTranslator dpy #f))
	      (if (not (KeySym? (cadr (XmTranslateKey dpy (list 'KeyCode XK_B) 0))))
		  (snd-display ";XmTranslateKey: ~A" (XmTranslateKey dpy XK_B 0)))
	      (let ((kv (XtKeysymToKeycodeList dpy (list 'KeySym 65509))))
		(if (not (equal? (car kv) (list 'KeyCode 66))) 
		    (snd-display ";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 ";XtSetArg: ~A" (XtSetArg 0 1 2)))
	      (if (not (Widget? (XtGetKeyboardFocusWidget (cadr (main-widgets)))))
		  (snd-display ";XtGetKeyboardFocusWidget: ~A" (XtGetKeyboardFocusWidget (cadr (main-widgets)))))
	      (let ((id (XtAddTimeOut 10000 (lambda (a b) 0) #f)))
		(XtRemoveTimeOut id)
		(set! id (XtAppAddTimeOut (car (main-widgets)) 10000 (lambda (a b) 0) #f))
		(XtRemoveTimeOut id))
	      (let ((id (XtAppAddInput (car (main-widgets)) 1 XtInputReadMask (lambda (a b c) #f) #f)))
		(XtRemoveInput id)
		(set! id (XtAddInput 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 ";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)
	      (let ((val (XtFindFile "/lib/%N:/usr/lib/%N:/usr/local/lib/%N" (list (list #\N "libxm.so")) 1 file-exists?)))
		(if (or (not (string? val))
			(not (string=? val "/usr/local/lib/libxm.so")))
		    (snd-display ";can't find libxm? ~A" val)))
	      
	      (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 ";XtGetActionList: ~A" acts)))
	      )
	    
	    (let ((pop (XtCreatePopupShell "hiho" xmGrabShellWidgetClass (cadr (main-widgets))
					   (list XmNiconNameEncoding XA_STRING))))
	      (XtPopup pop XtGrabNone)
	      (XtPopdown pop))
	    (XtSetWarningHandler (lambda (n) 
				   (if (not (string=? n "hiho"))
				       (snd-display ";XtWarning: ~A" n))))
	    (XtWarning "hiho")
	    (XtAppSetWarningHandler (car (main-widgets))
				    (lambda (n) 
				      (if (not (string=? n "hiho"))
					  (snd-display ";XtWarning: ~A" n))))
	    (XtAppWarning (car (main-widgets)) "hiho")
	    (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)
	      (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 ((app (car (main-widgets)))
		  (str #f))
	      (XtSetErrorHandler (lambda (msg) (set! str msg)))
	      (XtError "hiho")
	      (if (or (not (string? str)) (not (string=? str "hiho"))) (snd-display ";XtError: ~A" str))
	      (XtAppSetErrorHandler app (lambda (msg) (set! str msg)))
	      (XtAppError app "hiho")
	      (if (or (not (string? str)) (not (string=? str "hiho"))) (snd-display ";XtAppError: ~A" str))
	      (XtSetErrorMsgHandler (lambda (name type class def pars numpars) (set! str name)))
	      (XtErrorMsg "name" "type" "class" "defp" (list "a") 1)
	      (if (or (not (string? str)) (not (string=? str "name"))) (snd-display ";XtErrorMsg: ~A" str))
	      (XtAppSetErrorMsgHandler app (lambda (name type class def pars numpars) (set! str name)))
	      (XtAppErrorMsg app "name" "type" "class" "defp" (list "a") 1)
	      (if (or (not (string? str)) (not (string=? str "name"))) (snd-display ";XtAppErrorMsg: ~A" str))
	      )
	    
	    ;; ---------------- 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 ";XmRenderTableGetRenditions name: ~A" default-font-name))
	      (if (not (XFontStruct? (list-ref default-font-info 1))) (snd-display ";XmRenderTableGetRenditions font struct: ~A" default-font-info))
	      (if (not (= (list-ref default-font-info 3) XmFONT_IS_FONT)) (snd-display ";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 ";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 ";SND_VERSION: ~A, ~A?" version (snd-version))))
	      (change-prop "SND_VERSION" "WM_NAME" "hiho")
	      (if (not (string=? (XFetchName dpy win) "hiho")) (snd-display ";change-prop: ~A" (XFetchName dpy win))))
	    
	    (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 ";tablist len: ~A ~A~%" (XmTabListTabCount tablist) (length tabs)))
	      (if (not (equal? (XmTabGetValues (XmTabListGetTab tablist 0)) (list 1.5 5 0 0 ".")))
		  (snd-display ";XmTabs 0: ~A" (XmTabGetValues (XmTabListGetTab tablist 0))))
	      (if (not (equal? (XmTabGetValues (XmTabListGetTab tablist 2)) (list 1.5 5 1 0 ".")))
		  (snd-display ";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 ";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 ";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 ";XmStringTableProposeTabList: ~A" tabl))
		  (XmTabListFree tabl)))
	      
	      (let ((hname (host-name))) ; from snd-motif.scm
		(if (and (not (string=? hname "fatty"))
			 (not (string=? hname "cat"))
			 (not (string=? hname "goggle")))
		    (snd-display ";host name appears to be ~A" hname)))
	      (let ((blu (x->snd-color "blue")))
		(if (not (Pixel? blu)) (snd-display ";x->snd-color can't find blue! ~A" blu))
		(if (not (equal? (color->list blu) (list 0.0 0.0 1.0)))
		    (snd-display ";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)
		(let ((newstr (XmStringParseText "hi" #f #f XmCHARSET_TEXT (list pm) 1 #f)))
		  (if (not (string=? (cadr (XmStringGetLtoR newstr XmFONTLIST_DEFAULT_TAG)) "hh"))
		      (snd-display ";XmStringParseText -> ~A" (XmStringGetLtoR newstr XmFONTLIST_DEFAULT_TAG))))
		(let ((vals (XmParseMappingGetValues pm (list XmNincludeStatus 0 XmNsubstitute 0))))
		  (if (or (not (= (cadr vals) XmINSERT))
			  (not (string=? (cadr (XmStringGetLtoR (list-ref vals 3) XmFONTLIST_DEFAULT_TAG)) "h")))
		      (snd-display ";XmParseMappingGetValues: ~A" vals))
		  (XmParseMappingSetValues pm (list XmNpattern "b")))
		(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 ";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 ";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 ";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 (1- ctr))
												 XmNfontName (list-ref fonts (1- ctr))
												 XmNfontType XmFONT_IS_FONT))))
								     tags))
							      (length tags)
							      XmMERGE_NEW)))
		
		(let* ((dpy (XtDisplay (cadr (main-widgets))))
		       (scr (DefaultScreenOfDisplay dpy))
		       (p1 (XmGetPixmap scr "hiho" (car pixels) (cadr pixels))))
		  (if (not (Pixmap? p1)) (snd-display ";XmGetPixmap: ~A" p1))
		  (set! p1 (XmGetPixmapByDepth scr "hoho" (car pixels) (cadr pixels) (XDefaultDepth dpy (XScreenNumberOfScreen scr))))
		  (if (not (Pixmap? p1)) (snd-display ";XmGetPixmapByDepth: ~A" p1))
		  (XmDestroyPixmap scr p1))
		
		(let ((prop (cadr (XmRenderTableCvtToProp (cadr (main-widgets)) rendertable))))
		  (if (not (string=? (substring prop 0 8) "tag,font"))
		      (snd-display ";XmRenderTableCvtToProp: ~A" (substring prop 0 8)))
		  (let ((copy (XmRenderTableCopy rendertable)))
		    (if (not (XmRenderTable? copy)) (snd-display ";XmRenderTableCopy full: ~A" copy))
		    (if (XmRenderTableCopy) (snd-display ";XmRenderTableCopy null: ~A" (XmRenderTableCopy)))
		    (let ((rtags (XmRenderTableGetTags copy))
			  (rends (XmRenderTableGetRenditions copy (list "one"))))
		      (if (XmRenderTableGetRenditions) (snd-display ";XmRenderTableGetRenditions null: ~A" (XmRenderTableGetRenditions)))
		      (set! copy (XmRenderTableRemoveRenditions copy (list (car rtags))))
		      (if (not (equal? (XmRenderTableGetTags copy) (list "two" "three" "four")))
			  (snd-display ";XmRenderTableRemoveRenditions: ~A" (XmRenderTableGetTags copy)))
		      (let ((another (XmRenderTableCvtFromProp (cadr (main-widgets)) prop (string-length prop))))
			(if (not (XmRenderTable? another)) (snd-display ";XmRenderTableCvtFromProp: ~A" another))
			(XmRenderTableFree another))
		      )))
		
		(let ((tabl (XmStringTableParseStringArray (list "hi" "ho") 2 "hiho" XmCHARSET_TEXT #f 0 #f)))
		  (if (not (XmString? (car tabl))) (snd-display ";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 ";XmStringTableUnparse: ~A" strs)))
		  (let ((str (XmStringTableToXmString tabl 2 #f)))
		    (if (not (XmString? str)) (snd-display ";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 ";XmStringUnparse: ~A" val))
		      (set! val (XmStringUnparse (XmStringCreateLocalized "hi") #f XmCHARSET_TEXT XmCHARSET_TEXT #f 0 XmOUTPUT_ALL))
		      (if (not (string=? val "hi")) (snd-display ";XmStringUnparse null tag: ~A" val))
		      (let* ((hi (XmStringCreateLocalized "hiho"))
			     (ho (XmCvtXmStringToByteStream hi)))
			(if (not (= (XmStringByteStreamLength (cadr ho)) 39)) 
			    (snd-display ";XmStringByteStreamLength: ~A" (XmStringByteStreamLength (cadr ho))))
			(set! val (XmStringUnparse (XmCvtByteStreamToXmString (cadr ho)) #f XmCHARSET_TEXT XmCHARSET_TEXT #f 0 XmOUTPUT_ALL))
			(if (not (string=? val "hiho")) (snd-display ";XmStringUnparse null tag of bytestream: ~A" val))))
		    (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 ";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 ";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 ";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 ";set current-font with ind/0: ~A ~A" old-font (current-font ind 0)))
			(set! (current-font) old-font))
		      (let* ((font (cadr (XtVaGetValues (list-ref (sound-widgets ind) 3) 
							(list XmNfontList 0))))
			     (context (XmFontListInitFontContext font))
			     (next-font (XmFontListGetNextFont context)))
			(if (car next-font)
			    (if (XFontStruct? (caddr next-font))
				(let* ((snd-name (cadr next-font))
				       (xfont (XGetFontProperty (caddr next-font) XA_FULL_NAME))
				       (x-name (and (car xfont)
						    (XGetAtomName 
						     (XtDisplay (cadr (main-widgets)))
						     (list 'Atom (cadr xfont))))))
				  (if (not (string=? snd-name "FONTLIST_DEFAULT_TAG_STRING"))
				      (snd-display ";mini font: ~A [~A]" snd-name x-name)))
				(snd-display ";mini-font not fontstruct: ~A" next-font))
			    (snd-display ";mini-font no good: ~A" next-font))
			(XmFontListFreeFontContext context)
			(set! context (XmFontListInitFontContext font))
			(let ((entry (XmFontListNextEntry context)))
			  (if (not (string=? (XmFontListEntryGetTag entry) "FONTLIST_DEFAULT_TAG_STRING"))
			      (snd-display ";fontlistentry ~A" (XmFontListEntryGetTag entry)))
			  (if (not (XFontStruct? (XmFontListEntryGetFont entry)))
			      (snd-display ";fontlistentry font: ~A" (XmFontListEntryGetFont entry)))
			  (XmFontListEntryFree (XmFontListEntryCreate "hiho" XmFONT_IS_FONT (XmFontListEntryGetFont entry)))
			  (XmFontListFree (XmFontListCopy font))
			  (let ((newlist (XmFontListCreate (XmFontListEntryGetFont entry) "hiho")))
			    (XmFontListAdd newlist (XmFontListEntryGetFont entry) "hiho")
					;(XmFontListRemoveEntry newlist entry)
					;(XmFontListFree newlist)
			    )
			  (XmFontListFreeFontContext context)))
		      (let ((fnt (XmFontListEntryLoad (XtDisplay (cadr (main-widgets)))
						      "-*-times-medium-r-normal-*-18-*-*-*-*-*-*-*"
						      XmFONT_IS_FONTSET
						      "a_new_font")))
			(XmFontListEntryFree fnt))
		      
		      (set! (.foreground gv) (data-color))
		      (set! (.background gv) (basic-color))
		      (set! (.function gv) GXcopy)
		      (let* ((gc (XtAllocateGC grf1
					       (XDefaultDepth dpy scrn) 
					       (logior GCForeground GCBackground GCFunction)
					       gv
					       (logior GCFont GCDashList)
					       0))
			     (str2 (XmStringCreateLocalized "hiho")))
			(XmStringDraw dpy win rendertable str2 gc 10 10 100 
				      XmALIGNMENT_END XmSTRING_DIRECTION_L_TO_R (XRectangle 0 0 100 100))
			(XmStringDrawImage dpy win rendertable str2 gc 10 10 100 
					   XmALIGNMENT_END XmSTRING_DIRECTION_L_TO_R (XRectangle 0 0 100 100))
			(XmStringDrawUnderline dpy win rendertable str2 gc 10 10 100 
					       XmALIGNMENT_END XmSTRING_DIRECTION_L_TO_R (XRectangle 0 0 100 100) str2)
			(XtGetGC (cadr (main-widgets)) GCForeground gv)
			(XCopyGC dpy gc GCFunction gc)
			(XCopyArea dpy win win gc 0 0 100 100 0 0)
			(XCopyPlane dpy win win gc 0 0 100 100 0 0 1)
			(XtReleaseGC grf1 gc))
		      (close-sound ind))
		    (let ((lc (XmStringLineCount (XmStringCreateLocalized "hiho"))))
		      (if (not (= lc 1)) (snd-display ";XmStringLineCount: ~A" lc)))
		    (if (not (XmStringHasSubstring str (XmStringCreateLocalized "hi"))) (snd-display ";XmStringHasSubstring?"))
		    (XmStringNCopy str 2)
		    (XmStringNConcat str (XmStringCreateLocalized "hiho") 2)
		    (if (not (XmStringByteCompare (XmStringCreateLocalized "hiho") (XmStringCreateLocalized "hiho")))
			(snd-display ";XmStringByteCompare?"))))
		
		(if (not (equal? (XmRenderTableGetTags rendertable) (list "one" "two" "three" "four")))
		    (snd-display ";tags: ~A~%" (XmRenderTableGetTags rendertable)))
		(let* ((rend (XmRenderTableGetRendition rendertable "one"))
		       (r (XmRenditionRetrieve rend
					       (list XmNrenditionForeground 0
						     XmNfontName 0
						     XmNfontType 0
						     XmNtag 0))))
		  (if (or (not (string=? (list-ref r 7) "one"))
			  (not (string=? (list-ref r 3) "fixed")))
		      (snd-display ";rendertable: ~A" r))
		  (let* ((str (XmStringPutRendition (XmStringCreateLocalized "hiho") "one"))
			 (ctx (cadr (XmStringInitContext str)))
			 (comp (XmStringPeekNextComponent ctx))
			 (comp1 (XmStringPeekNextTriple ctx))
			 (comp2 (XmStringGetNextComponent ctx)))
		    (if (not (= comp XmSTRING_COMPONENT_RENDITION_BEGIN)) (snd-display ";XmStringPeekNextComponent: ~A" comp))
		    (if (not (= comp1 comp)) (snd-display ";XmStringPeekNextTriple: ~A" comp1))
		    (if (not (= (list-ref comp2 4) comp)) (snd-display ";XmStringGetNextComponent: ~A" comp2)))
		  (XmRenditionUpdate rend (list XmNstrikethruType XmSINGLE_LINE))
		  (if (not (= (cadr (XmRenditionRetrieve rend (list XmNstrikethruType 0))) XmSINGLE_LINE))
		      (snd-display ";XmRenditionUpdate: ~A ~A" (cadr (XtGetValues rend (list XmNstrikethruType 0))) XmSINGLE_LINE)))
		(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 ";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 ";~A is void?" entry))
		       (if (XmStringEmpty entry) (snd-display ";~A is empty?" entry))
		       (if (<= (XmStringLength entry) 0) (snd-display ";XmStringLength: ~A ~A" entry (XmStringLength entry)))
		       (let ((str1 (XmStringCopy entry))
			     (strn #f))
			 (let ((val (XmStringCompare entry str1)))
			   (if (not val) (snd-display ";t XmStringCompare ~A ~A" entry str1)))
			 (set! strn (XmStringConcat str1 entry))
			 (if (not (> (XmStringLength strn) (XmStringLength entry)))
			     (snd-display ";concat xmstring: ~A ~A" (XmStringLength strn) (XmStringLength entry)))
			 (let ((hgt (XmStringHeight rendertable entry)))
			   (if (or (< hgt 5) (> hgt 120)) (snd-display ";~A height: ~A" entry hgt))
			   (let ((wid (XmStringWidth rendertable entry)))
			     (if (or (< wid 3) (> wid 120)) (snd-display ";~A width: ~A" entry wid))
			     (let ((extent (XmStringExtent rendertable entry)))
			       (if (or (not (= (car extent) wid))
				       (not (= (cadr extent) hgt)))
				   (snd-display ";XmStringExtent: ~A, wid: ~A, hgt: ~A", extent wid hgt)))))
			 (let ((hgt (XmStringBaseline rendertable entry)))
			   (if (or (< hgt 6) (> hgt 120)) (snd-display ";~A baseline: ~A" entry hgt)))
			 (XmStringFree strn)
			 (XmStringFree str1))
		       
		       (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))
		    (call-with-current-continuation
		     (lambda (done)
		       (do ((i 0 (1+ i)))
			   (#f)
			 (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 ";component ~A -> ~A" i (cdr type)))
			       (if (not (= (car type) XmSTRING_COMPONENT_TAB))
				   (if (= (car type) XmSTRING_COMPONENT_END)
				       (done #f))))))))
		    (XmStringFreeContext (cadr c))))))
	    
	    (XtAppAddActions (car (main-widgets))
			     (list (list "try1" (lambda (w e strs)	
						  (snd-display ";try1: ~A~%" strs)))
				   (list "try2" (lambda (w e strs)
						  (snd-display ";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 ";try3: ~A~%" strs)))
				    (list "try4" (lambda (w e strs)
						   (snd-display ";try4: ~A~%" strs))))))
	    
	    (let ((XmNhiho (add-resource "hiho" 0)))
	      (if (not (string=? XmNhiho "hiho")) (snd-display ";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))
		   (gc (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 gc 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 ";XCheckTypedWindowEvent: ~A" (XCheckTypedWindowEvent dpy win ExposureMask)))
		(if (XCheckTypedEvent dpy ExposureMask) 
		    (snd-display ";XCheckTypedEvent: ~A" (XCheckTypedEvent dpy ExposureMask)))
		(XCheckWindowEvent dpy win ExposureMask)
;		(if (XCheckIfEvent dpy (lambda (d e data) #f) #f)
;		    (snd-display ";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 ";stack_mode wc: ~A" (.stack_mode wc)))
		  (if (not (equal? (.sibling wc) win)) (snd-display ";sibling wc: ~A" (.sibling wc)))
		  (if (not (= (.x wc) 10)) (snd-display ";x wc: ~A" (.x wc)))
		  (if (not (= (.y wc) 10)) (snd-display ";y wc: ~A" (.y wc)))
		  (if (not (= (.width wc) 100)) (snd-display ";width wc: ~A" (.width wc)))
		  (if (not (= (.height wc) 100)) (snd-display ";height wc: ~A" (.height wc)))
		  (if (not (= (.border_width wc) 10)) (snd-display ";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 ";cpp xp: ~A" (.cpp xp)))
		      (if (not (= (.ncolors xp) 1)) (snd-display ";ncolors xp: ~A" (.ncolors xp)))))
		)
	      (XmObjectAtPoint shell 100 100)
	      (if (not (string=? (XmGetAtomName dpy XA_STRING) "STRING")) (snd-display ";XmGetAtomName: ~A" (XmGetAtomName dpy XA_STRING)))
	      (if (not (XmTargetsAreCompatible dpy (list XA_STRING) 1 (list XA_STRING) 1)) (snd-display ";XmTargetsAreCompatible"))
	      (XmUpdateDisplay grf1)
	      (let ((lines (XmWidgetGetBaselines (list-ref (main-widgets) 4))))
		(if (not lines) (snd-display ";XmWidgetGetBaselines?"))
		(if (< (length lines) 4) (snd-display ";no listener text?? ~A" lines)))
	      (let ((r (XmWidgetGetDisplayRect (list-ref (sound-widgets) 8))))
		(if (not (XRectangle? r)) (snd-display ";XmWidgetGetDisplayRect: ~A" r)))
	      (XDrawImageString dpy (list 'Window (cadr pix)) gc 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 ";bytes_per_line: ~A" (.bytes_per_line newimage)))
		(if (not (= (.byte_order newimage) 0)) (snd-display ";byte_order: ~A" (.byte_order newimage)))
		(if (not (= (.bitmap_pad newimage) 8)) (snd-display ";bitmap_pad: ~A" (.bitmap_pad newimage)))
		(if (not (= (.bitmap_bit_order newimage) 0)) (snd-display ";bitmap_bit_order: ~A" (.bitmap_bit_order newimage)))
		(if (not (= (.bitmap_unit newimage) 32)) (snd-display ";bitmap_unit: ~A" (.bitmap_unit newimage)))
		(if (not (= (.obdata newimage) 0)) (snd-display ";obdata: ~A" (.obdata newimage)))
		(if (not (= (.xoffset newimage) 0)) (snd-display ";xoffset: ~A" (.xoffset newimage)))
		(XPutPixel before 1 1 (basic-color))
		(XGetPixel before 1 1)
		(XPutImage dpy (list 'Window (cadr rotpix)) gc before 0 0 0 0 10 10)
		(XAddPixel before 1)
		(if (> (.bits_per_pixel before) 123) (snd-display ";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 ";.name colorsymbol: ~A" (.name sym)))
		      (set! (.name sym) "hiho")
		      (if (not (string=? (.name sym) "hiho")) (snd-display ";set .name colorsymbol: ~A" (.name sym)))
		      (set! (.visual attr) vis)
		      (if (not (equal? vis (.visual attr))) (snd-display ";visual xpm attr: ~A" (.visual attr)))
		      (if (not (list? (.colorsymbols attr))) (snd-display ";.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 ";numsymbols xpm attr: ~A" (.numsymbols attr)))
		      (set! (.depth attr) (list-ref vals 3))
		      (if (not (equal? (list-ref vals 3) (.depth attr))) (snd-display ";depth xpm attr: ~A" (.depth attr)))
		      (set! (.colormap attr) (list-ref vals 1))
		      (if (not (equal? (list-ref vals 1) (.colormap attr))) (snd-display ";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 ";valuemask: ~A" (.valuemask attr)))
		      (if (not (= (.x_hotspot attr) 0)) (snd-display ";x_hotspot: ~A" (.x_hotspot attr)))
		      (if (not (= (.y_hotspot attr) 0)) (snd-display ";y_hotspot: ~A" (.y_hotspot attr)))
		      (if (not (= (.npixels attr) 0)) (snd-display ";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 ";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 ";XpmGetErrorString: ~A" (XpmGetErrorString XpmSuccess)))
			(if (not (= status XpmSuccess))
			    (snd-display "; 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 "; 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 ";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)
		(let ((keys (XGetKeyboardMapping dpy (list 'KeyCode 40) 1)))
		  (if (not (equal? keys (list (list 'KeySym 100) (list 'KeySym 68) (list 'KeySym 0) (list 'KeySym 0))))
		      (snd-display ";XGetKeyboardMapping: ~A" keys)))
		(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* ((gc (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 ";XtWindowToWidget: ~A ~A" grf1 win)))
	      (if (not (equal? (XGetTransientForHint dpy win) (list 0 #f)))
		  (snd-display ";XGetTransientForHint: ~A" (XGetTransientForHint dpy win)))
	      (if (not (equal? (XGetErrorText dpy BadColor #f 9) (list 0 "BadColor")))
		  (snd-display ";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 ";XGeometry: ~A" (XGeometry dpy 0 "500x400" "500x400+10+10" 4 7 14 2 2)))
	      (if (< (XEventsQueued dpy QueuedAlready) 0)
		  (snd-display ";XEventsQueued: ~A" (XEventsQueued dpy QueuedAlready)))
	      (let ((coords (XTranslateCoordinates dpy (XtWindow shl) win 10 10)))
		(if (not (car coords))
		    (snd-display ";XTranslateCoordinates: ~A" coords)))
	      (let ((coords (XtTranslateCoords shl 10 10)))
		(if (not (number? (car coords)))
		    (snd-display ";XtTranslateCoords: ~A" coords)))
	      (if (not (XmIsVendorShell shl)) (snd-display ";XmIsVendorShell?"))
	      (if (XmIsPrimitive shl) (snd-display ";XmIsPrimitive?"))
	      (if (XmIsManager shl) (snd-display ";XmIsManager?"))
	      (if (XmIsIconGadget shl) (snd-display ";XmIsIconGadget?"))
	      (if (XmIsGadget shl) (snd-display ";XmIsGadget?"))
	      (if (XmIsIconHeader shl) (snd-display ";XmIsHeader?"))
	      (if (XmIsDropTransfer shl) (snd-display ";XmIsDropTransfer?"))
	      (if (XmIsDropSiteManager shl) (snd-display ";XmIsDropSiteManager?"))
	      (if (XmIsDragContext shl) (snd-display ";XmIsDragContext?"))
	      (if (XmIsDragIconObjectClass shl) (snd-display ";XmIsDragIconObjectClass?"))
	      (if (XmIsMessageBox shl) (snd-display ";XmIsMessageBox?"))
	      (if (XmIsScreen shl) (snd-display ";XmIsScreen?"))
	      (if (XmIsDisplay shl) (snd-display ";XmIsDisplay?"))
	      
	      (let ((val 0))
		(XSetErrorHandler (lambda (dpy e)
				    (set! val (.error_code e))))
		(XGetAtomName dpy '(Atom 0))
		(if (not (= val 5)) (snd-display ";XSetErrorHandler: ~A" val)))
	      
	      (XDrawImageString dpy win gc 10 10 "hiho" 4)
	      (XDrawRectangle dpy win gc 0 0 10 10)
	      (XDrawString dpy win gc 10 10 "hi" 2)
	      (XDrawSegments dpy win gc (list (XSegment 1 1 2 20) (XSegment 3 3 40 4)) 2)
	      (XDrawRectangles dpy win gc (list (XRectangle 0 0 10 10) (XRectangle 20 20 30 30)) 2)
	      (XFillRectangles dpy win gc (list (XRectangle 0 0 10 10) (XRectangle 20 20 30 30)) 2)
	      (XDrawRectangle dpy win gc 10 10 10 10)
	      (XFillRectangle dpy win gc 10 10 10 10)
	      (XDrawPoints dpy win gc (list (XPoint 23 23) (XPoint 109 10)) 2 CoordModeOrigin)
	      (XDrawPoint dpy win gc 10 10)
	      (XDrawLines dpy win gc (list (XPoint 23 23) (XPoint 109 10)) 2 CoordModeOrigin)
	      (XDrawLine dpy win gc 10 10 20 20)
	      (XDrawArcs dpy win gc (list (XArc 10 10 4 4 0 360) (XArc 20 20 1 23 0 123)) 2)
	      (XFillArcs dpy win gc (list (XArc 10 10 4 4 0 360) (XArc 20 20 1 23 0 123)) 2)
	      (XDrawArc dpy win gc 0 0 10 10 45 90)
	      (XFillArc dpy win gc 0 0 10 10 45 90)
	      (XFillPolygon dpy win gc (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 ";XtCallCallbacks val1: ~A" val1))
		(XtRemoveCallback button XmNactivateCallback descr)
		(let ((calls (XtHasCallbacks button XmNactivateCallback)))
		  (if (not (= calls XtCallbackHasNone))
		      (snd-display ";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 ";XtCallCallbacks val12: ~A ~A" val1 val2))
		(XtRemoveCallbacks button XmNactivateCallback (list descr1 descr2))
		(let ((calls (XtHasCallbacks button XmNactivateCallback)))
		  (if (not (= calls XtCallbackHasNone))
		      (snd-display ";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 ";XtCallCallbacks add val12: ~A ~A" val1 val2))
		(XtRemoveCallbacks button XmNactivateCallback descrs)
		(let ((calls (XtHasCallbacks button XmNactivateCallback)))
		  (if (not (= calls XtCallbackHasNone))
		      (snd-display ";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 ";XmNautomaticSelection: ~A" (list-ref vals 1)))
		(if (not (= (list-ref vals 3) 100)) (snd-display ";XmNdoubleClickInterval: ~A" (list-ref vals 3)))
		(if (not (= (list-ref vals 5) 3)) (snd-display ";XmNitemCount: ~A" (list-ref vals 5)))
		(if (or (null? (list-ref vals 7)) (not (XmString? (car (list-ref vals 7))))) (snd-display ";XmNitems: ~A" (list-ref vals 7)))
		(if (not (= (list-ref vals 9) 4)) (snd-display ";XmNlistMarginHeight: ~A" (list-ref vals 9)))
		(if (not (= (list-ref vals 11) 1)) (snd-display ";XmNlistMarginWidth: ~A" (list-ref vals 11)))
		(if (not (= (list-ref vals 13) XmVARIABLE)) (snd-display ";XmNlistSizePolicy: ~A" (list-ref vals 13)))
		(if (not (= (list-ref vals 15) 2)) (snd-display ";XmNlistSpacing: ~A" (list-ref vals 15)))
		(if (not (= (list-ref vals 17) XmQUICK_NAVIGATE)) (snd-display ";XmNmatchBehavior: ~A" (list-ref vals 17)))
		(if (not (= (list-ref vals 19) XmOWN_NEVER)) (snd-display ";XmNprimaryOwnership : ~A" (list-ref vals 19)))
		(if (not (= (list-ref vals 21) XmAS_NEEDED)) (snd-display ";XmNscrollBarDisplayPolicy: ~A" (list-ref vals 21)))
		(if (not (Pixel? (list-ref vals 23))) (snd-display ";XmNselectColor: ~A" (list-ref vals 23)))
		(if (not (= (list-ref vals 25) XmNORMAL_MODE)) (snd-display ";XmNselectionMode: ~A" (list-ref vals 25)))
		(if (not (= (list-ref vals 27) XmBROWSE_SELECT)) (snd-display ";XmNselectionPolicy: ~A" (list-ref vals 27)))
		(if (list-ref vals 29) (snd-display ";XmNhorizontalScrollBar: ~A" (list-ref vals 29)))
		(if (not (= (list-ref vals 31) 0)) (snd-display ";XmNselectedItemCount : ~A" (list-ref vals 31)))
		(if (not (= (list-ref vals 33) 1)) (snd-display ";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 ";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 ";XmAddItem len: ~A" (list-ref vals 1)))
		(if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 3) XmFONTLIST_DEFAULT_TAG)) "four"))
		    (snd-display ";added item: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 3) XmFONTLIST_DEFAULT_TAG))))
		(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 ";xstrings->list add: ~A" tag)))
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 6)) (snd-display ";XmAddItems len: ~A" (list-ref vals 1)))
		(if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 5) XmFONTLIST_DEFAULT_TAG)) "six"))
		    (snd-display ";added items: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 5) XmFONTLIST_DEFAULT_TAG))))
		
		(XmListDeletePos lst 1)
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 5)) (snd-display ";XmListDeletePos len: ~A" (list-ref vals 1)))
		(if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG)) "two"))
		    (snd-display ";deleted item 1: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG))))
		(XmListDeletePositions lst (list 2 4))
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 3)) (snd-display ";XmListDeletePositions len: ~A" (list-ref vals 1)))
		(if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG)) "four"))
		    (snd-display ";deleted item 2: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG))))
		
		(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 ";XmListAddItemUnselected len: ~A" (list-ref vals 1)))
		(if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 3) XmFONTLIST_DEFAULT_TAG)) "seven"))
		    (snd-display ";added item unselected: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 3) XmFONTLIST_DEFAULT_TAG))))
		(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 ";XmListAddItemsUnselected len: ~A" (list-ref vals 1)))
		(if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 5) XmFONTLIST_DEFAULT_TAG)) "nine"))
		    (snd-display ";added items unselected: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 5) XmFONTLIST_DEFAULT_TAG))))
		
		(XmListDeleteAllItems lst)
		(set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		(if (not (= (list-ref vals 1) 0)) (snd-display ";XmListDeleteAllItems len: ~A" (list-ref vals 1)))
		(if (not (null? (list-ref vals 3)))
		    (snd-display ";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 ";Xt set items len: ~A" (list-ref vals 1)))
		  (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG)) "one"))
		      (snd-display ";set items: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG))))
		  
		  (XmListSelectItem lst item3 #t)
		  (if (not (= browsed 123)) (snd-display ";XmListSelectItem callback: ~A" browsed))
		  (if (XmListPosSelected lst 1) (snd-display ";XmList selected pos 1?"))
		  (if (not (XmListPosSelected lst 3)) (snd-display ";XmList didn't select pos 3?"))
		  (set! vals (XtVaGetValues lst (list XmNselectedItemCount 0 XmNselectedItems 0)))
		  (if (not (= (list-ref vals 1) 1)) (snd-display ";selected count: ~A" (list-ref vals 1)))
		  (set! vals (XmListGetSelectedPos lst))
		  (if (not (= (length vals) 1)) (snd-display ";XmListGetSelectedPos: ~A" vals))
		  (if (not (= (car vals) 3)) (snd-display ";XmListGetSelectedPos: ~A" vals))
		  (set! browsed 0)
		  (XmListSelectPos lst 1 #f)
		  (if (not (= browsed 0)) (snd-display ";XmListSelectPos callback: ~A" browsed))
		  (if (not (XmListPosSelected lst 1)) (snd-display ";XmList select pos?"))
		  (if (not (= (XmListItemPos lst item3) 3)) (snd-display ";XmListItemPos: ~A" (XmListItemPos lst item3)))
		  (if (not (= (car (XmListGetMatchPos lst item3)) 3)) (snd-display ";XmListGetMatchPos: ~A" (XmListGetMatchPos lst item3)))
		  (if (not (= (XmListItemExists lst item3))) (snd-display ";XmListItemExists?"))
		  
		  (if (not (= (XmListYToPos lst 40) 2)) (snd-display ";XmListYToPos: ~A" (XmListYToPos lst 40)))
		  (let ((box (XmListPosToBounds lst 2)))
		    (if (not (= (cadr box) 3))
			(snd-display ";XmListPosToBounds: ~A" box)))
		  (XmListDeselectPos lst 1)
		  (if (XmListPosSelected lst 1) (snd-display ";XmList deselected pos?"))
		  (XmListSelectItem lst item3 #t)
		  (XmListDeselectAllItems lst)
		  (if (XmListPosSelected lst 3) (snd-display ";XmList deselect all pos?"))
		  (XmListSelectItem lst item3 #f)
		  (XmListDeselectItem lst item3)
		  (if (XmListPosSelected lst 3) (snd-display ";XmList deselect item?"))
		  
		  (XmListDeleteItem lst item2)
		  (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		  (if (not (= (list-ref vals 1) 4)) (snd-display ";XmDeleteItem len: ~A" (list-ref vals 1)))
		  (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG)) "three"))
		      (snd-display ";delete item: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG))))
		  (XmListDeleteItems lst (list item1 item4))
		  (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		  (if (not (= (list-ref vals 1) 2)) (snd-display ";XmDeleteItems len: ~A" (list-ref vals 1)))
		  (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG)) "three"))
		      (snd-display ";delete items: ~A" (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG))))
		  (XmListDeleteAllItems lst)
		  (XtVaSetValues lst 
				 (list XmNitemCount 5
				       XmNitems (list item1 item2 item3 item4 item5))) 
		  
		  (let ((item6 (XmStringCreate "six" XmFONTLIST_DEFAULT_TAG)))
		    (XmListReplacePositions lst (list 2) (list item6) 1)
		    (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		    (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG)) "six"))
			(snd-display ";replace pos: ~A ~A" 
				     (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG))
				     (map (lambda (n) 
					    (XmStringGetLtoR n XmFONTLIST_DEFAULT_TAG))
					  (list-ref vals 3))))
		    (XmListReplaceItemsUnselected lst (list item6 item3) 2 (list item2 item6))
		    (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		    (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 2) XmFONTLIST_DEFAULT_TAG)) "six"))
			(snd-display ";replace items unselected: ~A ~A" 
				     (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 1) XmFONTLIST_DEFAULT_TAG))
				     (map (lambda (n) 
					    (XmStringGetLtoR n XmFONTLIST_DEFAULT_TAG))
					  (list-ref vals 3))))
		    (XmListReplaceItemsPosUnselected lst (list item6 item3) 2 1)
		    (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		    (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG)) "six"))
			(snd-display ";replace items pos: ~A ~A" 
				     (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG))
				     (map (lambda (n) 
					    (XmStringGetLtoR n XmFONTLIST_DEFAULT_TAG))
					  (list-ref vals 3))))
		    (XmListReplaceItemsPos lst (list item4) 1 1)
		    (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		    (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG)) "four"))
			(snd-display ";replace items pos: ~A ~A" 
				     (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG))
				     (map (lambda (n) 
					    (XmStringGetLtoR n XmFONTLIST_DEFAULT_TAG))
					  (list-ref vals 3))))
		    (XmListReplaceItems lst (list item4 item3) 2 (list item2 item6))
		    (set! vals (XtGetValues lst (list XmNitemCount 0 XmNitems 0)))
		    (if (not (string=? (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG)) "two"))
			(snd-display ";replace items: ~A ~A" 
				     (cadr (XmStringGetLtoR (list-ref (list-ref vals 3) 0) XmFONTLIST_DEFAULT_TAG))
				     (map (lambda (n) 
					    (XmStringGetLtoR n XmFONTLIST_DEFAULT_TAG))
					  (list-ref vals 3))))
		    (XmListSetPos lst 1)
		    (if (not (XmListSetKbdItemPos lst 1)) (snd-display ";XmListSetKbdItemPos?"))
		    (XmListGetKbdItemPos lst)
		    (XmListUpdateSelectedList lst)
		    (XmListSetPos lst 1)
		    (XmListSetHorizPos lst 0)
		    (XmListSetBottomPos lst 0)
		    (XmListSetBottomItem lst item5)
		    (XmListSetAddMode lst #f)
		    (XmListSetItem lst item6)
		    (XmListDeleteItemsPos lst 1 3)))
		(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 (< (.destination_data i) 0) (snd-display ";destination_data: A~" (.destination_data i)))
							     (if (< (.location_data i) 0) (snd-display ";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 ";currInsert: A~" (.currInsert i)))
							     (if (< (.newInsert i) 0) (snd-display ";newInsert: A~" (.newInsert i)))
							     (if (string? (.doit i)) (snd-display ";doit: A~" (.doit i)))
							     (if (< (.startPos i) 0) (snd-display ";startPos: A~" (.startPos i)))
							     (if (< (.endPos i) 0) (snd-display ";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)))
				  (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 ";XmNrenderTable: ~A" (list-ref vals 1)))
		  (if (not (list-p (list-ref vals 3))) (snd-display ";XmNselectionArray: ~A" (list-ref vals 3))))
		(if (not (XmTextGetEditable txt)) (snd-display ";XmTextGetEditable?"))
		(if (not (XmTextFieldGetEditable txtf)) (snd-display ";XmTextFieldGetEditable?"))
		(XmTextSetEditable txt #f)
		(XmTextFieldSetEditable txtf #f)
		(if (XmTextGetEditable txt) (snd-display ";XmTextSetEditable?"))
		(if (XmTextFieldGetEditable txtf) (snd-display ";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 ";XmTextSetString: ~A" val))
		  (if (not (string=? valf "0123456789")) (snd-display ";XmTextFieldSetString: ~A" valf))
		  (if (not (string=? val1 "0123456789")) (snd-display ";text value: ~A" val1))
		  (if (not (string=? val1f "0123456789")) (snd-display ";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 ";XmTextSource? ~A" source))
		  (if (not (equal? (XmTextGetSource untext) source))
		      (snd-display ";XmTextSetSource: ~A ~A" source (XmTextGetSource untext)))
		  (if (XtIsSubclass untext xmFormWidgetClass)
		      (snd-display ";XtIsSubclass thinks untext is a form?"))
		  (if (not (XtIsSubclass untext coreWidgetClass))
		      (snd-display ";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 (not (string=? val "234")) (snd-display ";XmTextGetSubstring: ~A" val))
		  (if (not (string=? valf "234")) (snd-display ";XmTextFieldGetSubstring: ~A" valf)))
		(XmTextSetSelection txt 2 5 current-time)
		(let ((val (XmTextGetSelection txt)))
		  (if (not (string=? val "234")) (snd-display ";XmTextGetSelection: ~A" val)))
		(XmTextClearSelection txt current-time)
		(let ((val (XmTextGetSelection txt)))
		  (if val (snd-display ";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 ";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 ";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 ";XmTransferSetParameters type check: ~A" tag)))
		  (let ((tag (catch #t (lambda () (XmTrackingLocate txtf (list 'Cursor 1) "hiho")) (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XmTrackingLocate type check: ~A" tag)))
		  (let ((tag (catch #t (lambda () (XmTrackingEvent txtf (list 'Cursor 1) "hiho")) (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XmTrackingEvent 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 ";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 ";XmScrollVisible type check: ~A" tag)))
		  (let ((tag (catch #t (lambda () (XmScrolledWindowSetAreas txtf txtf txtf "hiho")) (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XmScrolledWindowSetAreas 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 ";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 ";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 ";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 ";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 ";XmRemoveProtocolCallback type check: ~A" tag)))
		  (if (provided? 'Xp)
		      (begin
			(let ((tag (catch #t (lambda () (XmPrintToFile dpy "hi" #f #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XmPrintToFile type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XmPrintSetup txtf (list 'Screen 0) "hi" (list 1 2) #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XmPrintSetup type check: ~A" tag)))))
		  (let ((tag (catch #t (lambda () (XSetStandardColormap dpy win 1 1)) (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XSetStandardColormap 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 ";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 ";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 ";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 ";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 ";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 ";XStoreColor type check: ~A" tag)))
		  (let ((tag (catch #t (lambda () (XtCreateApplicationShell "hiho" xmFormWidgetClass (list 1 2) #f)) (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XtCreateApplicationShell 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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";XtSendSelectionRequest type check: ~A" tag)))
		  
		  (if (provided? 'Xp)
		      (begin
			(let ((val (XpQueryExtension (XtDisplay (cadr (main-widgets))))))
			  (if (car val) (snd-display ";got Xp?? ~A" val)))
			(let ((tag (catch #t (lambda () (XpPutDocumentData dpy win "hi" 1 "hi" #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpPutDocumentData type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpGetDocumentData dpy (list 'XPContext 0) #f #f #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpGetDocumentData type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpSelectInput dpy (list 'XPContext 0) #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpSelectInput type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpInputSelected dpy (list 'XPContext 0) #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpInputSelected type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpGetPdmStartParams dpy win (list 'XPContext 0) dpy #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpGetPdmStartParams type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpSetImageResolution dpy (list 'XPContext 0) 1 #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpSetImageResolution type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpSendOneTicket dpy win (list 'XPContext 0) 1)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpSendOneTicket type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpGetAttributes dpy (list 'XPContext 0) #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpGetAttribuyes type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpNotifyPdm dpy win (list 'XPContext 0) dpy win 1)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpNotifyPdm type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpGetOneAttribute dpy (list 'XPContext 0) 1 #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpGetOneAttribute type check: ~A" tag)))
			(let ((tag (catch #t (lambda () (XpSetAttributes dpy (list 'XPContext 0) 1 "hi" #f)) (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg)) (snd-display ";XpSetAttributes type check: ~A" tag)))

			(let* ((ind (open-sound "oboe.snd"))
			       (x33 (XOpenDisplay ":33"))
			       (ctx (XpCreateContext x33 "lp0"))
			       (screen (XpGetScreenOfContext x33 ctx))
			       (win (XtWindow (car (channel-widgets)))))
			  (XpSetContext x33 ctx)
			  (XpStartJob x33 XPGetData)
			  (XpGetDocumentData x33 ctx 
					     (lambda (a b c d e)
					       (display (format #f "~A ~A~%" a b)))
					     (lambda (a b c d) #f (display "quit?"))
					     0)
			  (XpStartPage x33 win)
			  (update-time-graph)
			  (XpEndPage x33)
			  (XpEndJob x33)
			  (XpDestroyContext x33 ctx)
			  (close-sound ind))))
		  
		  (let ((tag (catch #t (lambda () (XReconfigureWMWindow dpy win 1 1 #f)) (lambda args (car args)))))
		    (if (not (eq? tag 'wrong-type-arg)) (snd-display ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";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 ";XmClipboardCancelCopy type check: ~A" tag)))
		  
		  )
		
		(let ((valf (XmTextFieldGetSelection txtf)))
		  (if (not (string=? valf "234")) (snd-display ";XmTextFieldGetSelection: ~A" valf)))
		(XmTextFieldClearSelection txtf current-time)
		(let ((valf (XmTextFieldGetSelection txtf)))
		  (if valf (snd-display ";XmTextFieldClearSelection: ~A" valf)))
		(let ((val (XmTextGetInsertionPosition txt))
		      (valf (XmTextFieldGetInsertionPosition txtf)))
		  (if (not (= val 5)) (snd-display ";XmTextGetInsertionPosition: ~A" val))
		  (if (not (= valf 5)) (snd-display ";XmTextFieldGetInsertionPosition: ~A" val)))
		
		(XmTextSetSelection txt 2 5 current-time)
		(XmTextCut txt current-time)
		(let ((val (XmTextGetString txt)))
		  (if (not (string=? val "0156789")) (snd-display ";XmTextCut: ~A" val)))
		(XmTextPaste txt) 
		(let ((val (XmTextGetString txt)))
		  (if (not (string=? val "0123456789")) (snd-display ";XmTextPaste: ~A" val)))
		(XmTextFieldSetSelection txtf 2 5 current-time)
		(XmTextFieldCut txtf current-time)
		(let ((val (XmTextFieldGetString txtf)))
		  (if (not (string=? val "0156789")) (snd-display ";XmTextFieldCut: ~A" val)))
		(XmTextFieldPaste txtf) 
		(let ((val (XmTextFieldGetString txtf)))
		  (if (not (string=? val "0123456789")) (snd-display ";XmTextFieldPaste: ~A" val)))
		
		(XmTextSetSelection txt 1 2 current-time)
		(if (not (equal? (XmTextGetSelectionPosition txt) (list #t 1 2)))
		    (snd-display ";XmTextGetSelectionPosition: ~A" (XmTextGetSelectionPosition txt)))
		(XmTextCopy txt current-time)
		(XmTextSetInsertionPosition txt 8)
		(XmTextPaste txt)
		(let ((dest (XmGetDestination (XtDisplay (cadr (main-widgets))))))
		  (if (not (equal? txt dest)) (snd-display ";XmGetDestination: ~A (~A)" dest txt)))
		(if (provided? 'Xp) (XmRedisplayWidget txt))
		(let ((val (XmTextGetString txt)))
		  (if (not (string=? val "01234567189")) (snd-display ";XmTextCopy and Paste: ~A" val)))
		(XmTextFieldSetSelection txtf 1 2 current-time)
		(if (not (equal? (XmTextFieldGetSelectionPosition txtf) (list #t 1 2)))
		    (snd-display ";XmTextFieldGetSelectionPosition: ~A" (XmTextFieldGetSelectionPosition txtf)))
		(XmTextFieldCopy txtf current-time)
		(XmTextFieldSetInsertionPosition txtf 8)
		(XmTextFieldPaste txtf)
		(let ((val (XmTextGetString txtf)))
		  (if (not (string=? val "01234567189")) (snd-display ";XmTextFieldCopy and Paste: ~A" val)))
		
		(XmTextSetMaxLength txt 1234)
		(if (not (= (XmTextGetMaxLength txt) 1234)) (snd-display ";XmTextGetMaxLength: ~A" (XmTextGetMaxLength txt)))
		(XmTextFieldSetMaxLength txtf 1234)
		(if (not (= (XmTextFieldGetMaxLength txtf) 1234)) (snd-display ";XmTextFieldGetMaxLength: ~A" (XmTextFieldGetMaxLength txtf)))
		
		(XmTextSetCursorPosition txt 1)
		(if (not (= (XmTextGetCursorPosition txt) 1)) (snd-display ";XmTextGetCursorPosition: ~A" (XmTextGetCursorPosition txt)))
		(XmTextFieldSetCursorPosition txtf 1)
		(if (not (= (XmTextFieldGetCursorPosition txtf) 1)) (snd-display ";XmTextFieldGetCursorPosition: ~A" (XmTextFieldGetCursorPosition txtf)))
		
		(XmTextReplace txt 0 2 "ab")
		(let ((val (XmTextGetString txt)))
		  (if (not (string=? val "ab234567189")) (snd-display ";XmTextReplace: ~A" val)))
		(XmTextFieldReplace txtf 0 2 "ab")
		(let ((val (XmTextFieldGetString txtf)))
		  (if (not (string=? val "ab234567189")) (snd-display ";XmTextFieldReplace: ~A" val)))
		
		(XmTextDisableRedisplay txt)
		(let ((pos (XmTextFindString txt 0 "67" XmTEXT_FORWARD)))
		  (if (or (not pos)
			  (not (= pos 6)))
		      (snd-display ";XmTextFindString ~A" pos)))
		(XmTextEnableRedisplay txt)
		(let ((base (XmTextGetBaseline txt))
		      (center (XmTextGetCenterline txt)))
		  (if (or (< base 0) (not (= center 0))) (snd-display ";XmTextGetCenterBaseline: ~A ~A" base center)))
		
		(let ((pos (XmTextGetLastPosition txt)))
		  (if (not (= pos 11)) (snd-display ";XmTextGetLastPosition: ~A" pos)))
		(let ((pos (XmTextFieldGetLastPosition txtf)))
		  (if (not (= pos 11)) (snd-display ";XmTextFieldGetLastPosition: ~A" pos)))
		(let ((pos (XmTextGetTopCharacter txt)))
		  (if (not (= pos 0)) (snd-display ";XmTextGetTopCharacter: ~A" pos)))
		(let ((pos (XmTextPosToXY txt 0)))
		  (if (not (number? (cadr pos))) (snd-display ";XmTextPosToXY: ~A" pos)))
		(let ((pos (XmTextFieldPosToXY txtf 0)))
		  (if (not (number? (cadr pos))) (snd-display ";XmTextFieldPosToXY: ~A" pos)))
		
		(XmTextSetSelection txt 0 2 current-time)
		(XmTextRemove txt)
		(let ((val (XmTextGetString txt)))
		  (if (not (string=? val "234567189")) (snd-display ";XmTextRemove: ~A" val)))
		(XmTextFieldSetSelection txtf 0 2 current-time)
		(XmTextFieldRemove txtf)
		(let ((val (XmTextFieldGetString txtf)))
		  (if (not (string=? val "234567189")) (snd-display ";XmTextFieldRemove: ~A" val)))
		
		(XmTextInsert txt 0 "hi")
		(let ((val (XmTextGetString txt)))
		  (if (not (string=? val "hi234567189")) (snd-display ";XmTextInsert: ~A" val)))
		(XmTextFieldInsert txtf 0 "hi")
		(let ((val (XmTextFieldGetString txtf)))
		  (if (not (string=? val "hi234567189")) (snd-display ";XmTextFieldInsert: ~A" val)))
		
		(XmTextScroll txt 1)
		(XmTextScroll txt -1)
		(let ((pos (XmTextGetTopCharacter txt)))
		  (if (not (= pos 0)) (snd-display ";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 ";XmTextSetAddMode?"))
		(XmTextFieldSetAddMode txtf #t)
		(if (not (XmTextFieldGetAddMode txtf)) (snd-display ";XmTextFieldSetAddMode?"))
		
		(if (not (string=? (vector-ref calls 1) "dest")) (snd-display ";destination callback: ~A" (vector-ref calls 1)))
					;(if (not (string=? (vector-ref calls 3) "focus")) (snd-display ";focus callback: ~A" (vector-ref calls 3)))
					;(if (not (string=? (vector-ref calls 4) "losingfocus")) (snd-display ";losingfocus callback: ~A" (vector-ref calls 4)))
		(if (not (string=? (vector-ref calls 5) "gain")) (snd-display ";gain callback: ~A" (vector-ref calls 5)))
		(if (not (string=? (vector-ref calls 6) "lose")) (snd-display ";lose callback: ~A" (vector-ref calls 6)))
		(if (not (string=? (vector-ref calls 7) "modify")) (snd-display ";modify callback: ~A" (vector-ref calls 7)))
		(if (not (string=? (vector-ref calls 8) "motion")) (snd-display ";motion callback: ~A" (vector-ref calls 8)))
		(if (not (string=? (vector-ref calls 9) "value")) (snd-display ";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 ";XmGetTabGroup: ~A " (XmGetTabGroup txtf1)))
		  (let ((fw (XmGetFocusWidget (cadr (main-widgets)))))
		    (if (not (equal? fw txtf1))
			(snd-display ";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 ";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 ";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 ";XmClipboardCopy: ~A" err))
			  (let ((item-id (cadr err)))
			    (set! err (XmClipboardEndCopy dpy win data-id))
			    (if (not (= err ClipboardSuccess)) (snd-display (format "copy ~A" err)))
			    (if (not (= (cadr (XmClipboardInquireLength dpy win "SND_DATA")) 10))
				(snd-display ";clip len: ~A" (XmClipboardInquireLength dpy win "SND_DATA")))
			    (let ((pend (XmClipboardInquirePendingItems dpy win "SND_DATA")))
			      (if (not (= (car pend) ClipboardSuccess)) (snd-display ";XmClipboardInquirePendingItems: ~A" pend)))
			    (let ((formats1 (XmClipboardInquireCount dpy win)))
			      (if (= (cadr formats1) 0) (snd-display ";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 ";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)))
		   (mnw (XtCreateManagedWidget "mnw" xmMainWindowWidgetClass frm
					       (list XmNcommandWindow       box
						     XmNleftAttachment      XmATTACH_FORM
						     XmNrightAttachment     XmATTACH_FORM
						     XmNtopAttachment       XmATTACH_WIDGET
						     XmNtopWidget           tgg
						     XmNbottomAttachment    XmATTACH_NONE)))
		   (spn (XtCreateManagedWidget "spn" xmSimpleSpinBoxWidgetClass frm
					       (list XmNleftAttachment      XmATTACH_FORM
						     XmNrightAttachment     XmATTACH_FORM
						     XmNtopAttachment       XmATTACH_WIDGET
						     XmNtopWidget           mnw
						     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 ";page_number: ~A" (.page_number info)))
		(if (.page_widget info) (snd-display ";page_widget: ~A" (.page_widget info)))
		(if (.status_area_widget info) (snd-display ";status_area_widget: ~A" (.status_area_widget info)))
		(if (not (Widget? (.major_tab_widget info))) (snd-display ";major_tab_widget: ~A" (.major_tab_widget info)))
		(if (.minor_tab_widget info) (snd-display ";minor_tab_widget: ~A" (.minor_tab_widget info))))
	      
	      (XmMainWindowSetAreas mnw #f box #f #f spn)
	      (if (not (Widget? (XmMainWindowSep1 mnw))) (snd-display ";XmMainWindowSep1: ~A" (XmMainWindowSep1 mnw)))
	      (if (not (Widget? (XmMainWindowSep2 mnw))) (snd-display ";XmMainWindowSep2: ~A" (XmMainWindowSep2 mnw)))
	      (if (not (Widget? (XmMainWindowSep3 mnw))) (snd-display ";XmMainWindowSep3: ~A" (XmMainWindowSep3 mnw)))
	      
	      (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 ";XmNeditable spin box"))
		(if (not (Widget? (list-ref vals 3))) (snd-display ";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 ";toggle calledback: ~A?" toggled))
	      (if (XmToggleButtonGetState tgl) (snd-display ";XmToggleButtonSetState #f"))
	      (if (XmToggleButtonGadgetGetState tgg) (snd-display ";XmToggleButtonGadgetSetState #f"))
	      (XtVaSetValues tgl (list XmNtoggleMode XmTOGGLE_INDETERMINATE))
	      (XmToggleButtonSetValue tgl XmINDETERMINATE #t)
	      (XmToggleButtonGadgetSetValue tgg XmINDETERMINATE #t)
	      (if (not (= toggled 123)) (snd-display ";toggle not calledback: ~A?" toggled))
	      
	      (XmCommandAppendValue cmd (XmStringCreateLocalized "hiho"))
	      (XmCommandError cmd (XmStringCreateLocalized "hiho"))
	      (if (not (Widget? (XmCommandGetChild cmd XmDIALOG_COMMAND_TEXT)))
		  (snd-display ";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 ";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 ";xm-float resource vals: ~A" vals)))
	      
	      (XtAddCallback scl XmNvalueChangedCallback (lambda (w c i) #f))
	      (XmScaleSetValue scl 25)
	      (if (not (= (XmScaleGetValue scl) 25)) (snd-display ";XmScaleSetValue: ~A" (XmScaleGetValue scl)))
	      (if (XmGetTearOffControl (car (menu-widgets))) (snd-display ";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)
	      )
	    
	    (let* ((shell (cadr (main-widgets)))
		   (dpy (XtDisplay shell))
		   (screen (XDefaultScreenOfDisplay dpy))
		   (vals (XtGetValues shell 
				      (list XmNscreen 0 XmNtitleEncoding 0 XmNbuttonFontList 0 XmNaudibleWarning 0
					    XmNpreeditType 0 XmNtextRenderTable 0 XmNtitle 0 XmNwindowGroup 0 
					    XmNargv 0 XmNcolormap 0))))
	      (if (not (equal? screen (list-ref vals 1))) (snd-display ";XmNscreen: ~A ~A" (list-ref vals 1) screen))
	      (if (not (Atom? (list-ref vals 3))) (snd-display ";XmNtitleEncoding: ~A" (list-ref vals 3)))
	      (if (not (XmFontList? (list-ref vals 5))) (snd-display ";XmNbuttonFontList: ~A" (list-ref vals 5)))
	      (if (not (list-ref vals 7)) (snd-display ";XmNaudibleWarning: ~A" (list-ref vals 7)))
	      (if (or (not (string? (list-ref vals 9)))
		      (not (string=? (list-ref vals 9) "OverTheSpot,OffTheSpot,Root,OnTheSpot")))
		  (snd-display ";XmNpreeditType: ~A" (list-ref vals 9)))
	      (if (not (XmRenderTable? (list-ref vals 11))) (snd-display ";XmNtextRenderTable: ~A" (list-ref vals 11)))
	      (if (not (string=? (list-ref vals 13) "snd")) (snd-display ";XmNtitle: ~A" (list-ref vals 13)))
	      (if (not (Window? (list-ref vals 15))) (snd-display ";XmNwindowgroup: ~A" (list-ref vals 15)))
	      (if (or (not (list-p (list-ref vals 17)))
		      (not (string=? (substring (car (list-ref vals 17)) (- (string-length (car (list-ref vals 17))) 3)) "snd")))
		  (snd-display ";XmNargv: ~A" (list-ref vals 17)))
	      (if (not (Colormap? (list-ref vals 19))) (snd-display ";XmNcolormap: ~A" (list-ref vals 19)))
	      )
	    
	    (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 ";XmIsScreen: ~A" scr))
	      (let ((colors (XmGetColors screen cmap (basic-color))))
		(if (not (Pixel? (car colors)))
		    (snd-display ";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 ";XmSetColorcalulcation ~A" (XmGetColorCalculation)))))
	      (let ((str (XmStringSegmentCreate "hi" XmFONTLIST_DEFAULT_TAG XmSTRING_DIRECTION_L_TO_R #f)))
		(if (not (XmString? str))
		    (snd-display ";XmStringSegmentCreate: ~A" str)))
	      (XmSetFontUnits dpy 8 10)
	      (if (or (not (= (cadr (XtVaGetValues scr (list XmNhorizontalFontUnit 0))) 8))
		      (not (= (cadr (XtVaGetValues scr (list XmNverticalFontUnit 0))) 10)))
		  (snd-display ";XmSetFontUnits: ~A" (XtVaGetValues scr (list XmNhorizontalFontUnit 0 XmNverticalFontUnit 0))))
	      (XmSetFontUnit dpy 8)
	      (if (or (not (= (cadr (XtVaGetValues scr (list XmNhorizontalFontUnit 0))) 8))
		      (not (= (cadr (XtVaGetValues scr (list XmNverticalFontUnit 0))) 8)))
		  (snd-display ";XmSetFontUnit: ~A" (XtVaGetValues scr (list XmNhorizontalFontUnit 0 XmNverticalFontUnit 0))))
	      (let ((vals (XtVaGetValues scr 
					 (list XmNbitmapConversionModel 0 XmNdarkThreshold 0 XmNfont 0 XmNunpostBehavior 0))))
		(if (not (= (list-ref vals 1) XmMATCH_DEPTH)) (snd-display ";XmNbitmapConversionModel: ~A" (list-ref vals 1)))
		(if (not (= (list-ref vals 3) 0)) (snd-display ";XmNdarkThreshold: ~A" (list-ref vals 3)))
		(if (not (XFontStruct? (list-ref vals 5))) (snd-display ";XmNfont: ~A" (list-ref vals 5)))
		(if (not (= (list-ref vals 7) XmUNPOST_AND_REPLAY)) (snd-display ";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 ";XmIsDisplay: ~A" dp))
		(if (not (= (list-ref vals 1) XmDRAG_PREFER_RECEIVER)) (snd-display ";XmNdragInitiatorProtocolStyle: ~A" (list-ref vals 1)))
		(if (list-ref vals 3) (snd-display ";XmNenableThinThickness?"))
		(if (not (= (list-ref vals 5) 2002)) (snd-display ";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 ";XmCvtXmStringToCT: ~A" (XmCvtXmStringToCT (XmStringCreateLocalized "hiho"))))
	      (let ((val (XmConvertStringToUnits (XDefaultScreenOfDisplay dpy) "3.14 in" XmHORIZONTAL XmINCHES)))
		(if (not (= val 3)) (snd-display ";XmConvertStringToUnits in->in ~A" val)))
	      (let ((val (XmConvertStringToUnits (XDefaultScreenOfDisplay dpy) "3.14 in" XmHORIZONTAL XmPOINTS)))
		(if (not (= val 225)) (snd-display ";XmConvertStringToUnits in->pts ~A" val)))
	      (let ((val (XmConvertStringToUnits (XDefaultScreenOfDisplay dpy) "3.14 in" XmHORIZONTAL XmCENTIMETERS)))
		(if (not (= val 7)) (snd-display ";XmConvertStringToUnits in->cm ~A" val)))
	      (let ((val (XmConvertUnits (cadr (main-widgets)) XmHORIZONTAL XmCENTIMETERS 7 XmMILLIMETERS)))
		(if (not (= val 70)) (snd-display ";XmConvertUnits cm->mm ~A" val)))
	      (let ((val (XmConvertUnits (cadr (main-widgets)) XmHORIZONTAL XmCENTIMETERS 7 XmPIXELS)))
		(if (not (= val 278)) (snd-display ";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 ";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 ";XmDropSiteRetrieve num: ~A" val)))
			(XmDropSiteRetrieve drop-site (list XmNimportTargets 0))
			(if (not (XmDropSiteRegistered drop-site))
			    (snd-display ";XmDropSiteRegistered?"))
			(XmDropSiteUnregister drop-site))
		      (snd-display ";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-current-continuation
					  (lambda (return)
					    (do ((i (- (string-length filename) 1) (1- i)))
						((= 0 i) filename)
					      (if (char=? (string-ref filename i) #\/)
						  (return (substring filename (+ i 1))))))))
				       (format #f "~~/peaks/~A-peaks-~D" 
					       (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 ";XmNlargeCellHeight: ~A" (list-ref vals 1)))
		  (if (not (Pixmap? (list-ref vals 3))) (snd-display ";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 ";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 ";XmIsColumn: ~A ~A" w1 w2))
			    (if (defined? 'XmColumnGetChildLabel)
				(let ((child (XmColumnGetChildLabel w1)))
				  (if (or (not (child)) (not (equal? child w1-child)))
				      (snd-display ";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 ";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 ";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 ";dropdown text: ~A" text))
			      (if (not (XmLabel? label)) (snd-display ";dropdown label: ~A" label))
			      (if (not (XmArrowButton? arrow)) (snd-display ";dropdown arrow: ~A" arrow))
			      (if (not (XmList? lst)) (snd-display ";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 ";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 ";XmIsTabStack: ~A ~A ~A" w1 (XmIsTabStack w1) (XmTabStack? w1)))
			    (let ((tab (XmTabStackGetSelectedTab w1)))
			      (XmTabStackSelectTab w1 #f)
			      w1))
			  #f))
		     (fntlst
		      (if (defined? 'XmIsMultiList)
			  (let ((w1 (XmCreateMultiList mainform "hiho" '())))
			    (if (or (not (XmIsMultiList w1))
				    (not (XmMultiList? w1)))
				(snd-display ";XmIsMultiList: ~A ~A ~A" w1 (XmIsMultiList w1) (XmMultiList? w1)))
			    (XmMultiListUnselectAllItems w1)
			    (XmMultiListDeselectAllItems w1)
			    (XmMultiListSelectAllItems w1 #f)
					;XmMultiListDeselectRow
					;XmMultiListSelectRow
					;XmMultiListToggleRow
					;XmMultiListMakeRowVisible
					;XmMultiListUnselectItem
					;XmMultiListDeselectItem
					;XmMultiListDeselectItems
					;XmMultiListSelectItems
					;XmMultiListGetSelectedRows
			    w1)
			  #f)))
		(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 ";XmInternAtom: ~A" prop))
	      (if (not (string=? (XmGetAtomName dpy prop) "TESTING")) (snd-display ";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 ";prehook: ~A ~A ~A" w c i))
				  12345
				  (lambda (w c i)
				    (snd-display ";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 (format #f "~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_BOOLEAN)
		    (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 ";resource ~A is not a string?" (car n)))
		 (XtVaGetValues shell (list (car n) 0)))
	       resource-list)
	      
	      (let* ((create-procs (list
			            XmCreateMenuShell XmCreateSimpleCheckBox XmCreateSimpleRadioBox
			            XmCreateSimpleOptionMenu XmCreateSimplePulldownMenu XmCreateSimplePopupMenu
			            XmCreateSimpleMenuBar XmCreateMainWindow XmCreateScrolledList XmCreateList
			            XmCreateLabel XmCreateLabelGadget XmCreateToggleButton XmCreateToggleButtonGadget
			            XmCreateGrabShell XmCreateFrame XmCreateFormDialog XmCreateForm XmCreateText
			            XmCreateScrolledText XmCreateFileSelectionDialog XmCreateFileSelectionBox
			            XmCreateTextField XmCreateSimpleSpinBox XmCreateDrawnButton XmCreateSpinBox
			            XmCreateDrawingArea XmCreateSeparator XmCreateDragIcon XmCreateSeparatorGadget
			            XmCreatePromptDialog XmCreateSelectionDialog XmCreateSelectionBox
			            XmCreateScrolledWindow XmCreateDialogShell XmCreateScrollBar XmCreateScale
			            XmCreateContainer XmCreatePulldownMenu XmCreatePopupMenu XmCreateMenuBar
			            XmCreateOptionMenu XmCreateRadioBox XmCreateWorkArea XmCreateRowColumn
			            XmCreateCommandDialog XmCreateCommand XmCreateDropDownList XmCreateDropDownComboBox
			            XmCreateComboBox XmCreatePushButton XmCreatePushButtonGadget XmCreateCascadeButton
			            XmCreateCascadeButtonGadget XmCreateBulletinBoardDialog XmCreateBulletinBoard
			            XmCreatePanedWindow XmCreateNotebook XmCreateArrowButton XmCreateArrowButtonGadget
			            XmCreateTemplateDialog XmCreateWorkingDialog XmCreateWarningDialog
			            XmCreateQuestionDialog XmCreateInformationDialog XmCreateErrorDialog
			            XmCreateMessageDialog XmCreateMessageBox XmCreateIconGadget))
		     (parent (list-ref (main-widgets) 3))
		     (str (XmStringCreateLocalized "yow"))
		     (args (list XmNheight 100 XmNwidth 100 XmNlabelString str))
		     (ques (list
			    XmMenuShell? #f #f #f #f
			    #f #f XmMainWindow? #f XmList?
			    XmLabel? XmLabelGadget? XmToggleButton?
			    XmToggleButtonGadget? XmGrabShell? XmFrame? #f XmForm?
			    XmText? #f #f XmFileSelectionBox?
			    XmTextField? #f XmDrawnButton? #f XmDrawingArea?
			    XmSeparator? #f XmSeparatorGadget? #f #f
			    XmSelectionBox? XmScrolledWindow? XmDialogShell? XmScrollBar?
			    XmScale? XmContainer? #f #f #f
			    #f #f #f XmRowColumn? #f
			    XmCommand? #f #f XmComboBox? XmPushButton?
			    XmPushButtonGadget? XmCascadeButton? XmCascadeButtonGadget? #f
			    XmBulletinBoard? XmPanedWindow? XmNotebook? XmArrowButton? XmArrowButtonGadget?
			    #f #f #f #f #f #f #f #f XmIconGadget?))
		     (is (list   
			  XmIsMenuShell #f #f #f #f
			  #f #f XmIsMainWindow #f XmIsList
			  XmIsLabel XmIsLabelGadget XmIsToggleButton
			  XmIsToggleButtonGadget XmIsGrabShell XmIsFrame #f XmIsForm
			  XmIsText #f #f XmIsFileSelectionBox
			  XmIsTextField #f XmIsDrawnButton #f XmIsDrawingArea
			  XmIsSeparator #f XmIsSeparatorGadget #f #f
			  XmIsSelectionBox XmIsScrolledWindow XmIsDialogShell XmIsScrollBar
			  XmIsScale XmIsContainer #f #f #f
			  #f #f #f XmIsRowColumn #f
			  XmIsCommand #f #f XmIsComboBox XmIsPushButton
			  XmIsPushButtonGadget XmIsCascadeButton XmIsCascadeButtonGadget #f
			  XmIsBulletinBoard XmIsPanedWindow XmIsNotebook XmIsArrowButton XmIsArrowButtonGadget
			  #f #f #f #f #f #f #f #f XmIsIconGadget)))
		
		(for-each 
		 (lambda (n q qq)
		   (let ((wid (n parent "hiho" args)))
		     (if (not (string=? (XtName wid) "hiho"))
			 (snd-display ";~A name: ~A" wid (XtName wid)))
		     (if (not (Widget? wid))
			 (snd-display ";~A not a widget?" wid))
		     (if (and q (not (q wid)))
			 (snd-display ";~A is not ~A?" wid q))
		     (if (and qq (not (qq wid)))
			 (snd-display ";~A is not ~A" wid qq))
		     (for-each
		      (lambda (n)
			(let ((val (XtVaGetValues wid (list (car n) 0))))
			  (if (not ((cadr n) (cadr val)))
	                      (snd-display ";resource: ~A -> ~A" (car n) (cadr val)))))
		      resource-list)
		     (XtAddCallback wid XmNhelpCallback (lambda (w c i) #f))
		     ))
		 create-procs ques is)))
	    
	    (if (not (XEvent? (XEvent)))
		(snd-display ";xevent type trouble! ~A -> ~A" (XEvent) (XEvent? (XEvent))))
	    (if (not (XGCValues? (XGCValues)))
		(snd-display ";xgcvalues type trouble! ~A -> ~A" (XGCValues) (XGCValues? (XGCValues))))
	    (if (not (= (.direction (XmTraverseObscuredCallbackStruct)) 0))
		(snd-display ";.direction: ~A" (.direction (XmTraverseObscuredCallbackStruct))))
	    (if (.ptr (XmTextBlock))
		(snd-display ";.ptr block: ~A" (.ptr (XmTextBlock))))
	    (let ((hi (XmTextBlock)))
	      (set! (.ptr hi) "hi")
	      (if (not (string=? (.ptr hi) "hi"))
		  (snd-display ";.ptr set block: ~A" (.ptr hi)))
	      (if (not (= (.length hi) 0)) (snd-display ";.length block: ~A" (.length hi)))
	      (set! (.length hi) 3)
	      (if (not (= (.length hi) 3)) (snd-display ";set .length block: ~A" (.length hi))))
	    (if (not (= (.dashes (XGCValues)) 0)) (snd-display ";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 ";error resourceid: ~A" (.resourceid (XEvent -1))))
	    (if (not (= (.request_code (XEvent -1)) 0)) (snd-display ";error request_code: ~A" (.request_code (XEvent -1))))
	    (set! (.pad (XColor)) 1)
	    
	    ;; snd-motif stuff
	    (show-widget-font (list-ref (menu-widgets) 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 ";XShapeQueryExtents: ~A" vals))
		  (set! vals (XShapeGetRectangles dpy win 0))
		  (if (not (list? vals)) (snd-display ";XShapeGetRectangles: ~A" vals))
		  (set! vals (XShapeQueryExtension dpy))
		  (if (not (equal? vals (list #t 64 0))) (snd-display ";XShapeQueryExtension: ~A" vals))
		  (set! vals (XShapeQueryVersion dpy))
		  (if (not (equal? vals (list #t 1 0))) (snd-display ";XShapeQueryVersion: ~A" vals))
		  (if (XShapeOffsetShape dpy win 0 0 0) (snd-display ";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 ";XStringToKeysym ~A ~A" key XK_Cancel)))

	    (let* ((win (XtWindow (cadr (main-widgets))))
		   (xm-procs-1
		    ;; these can't be called in this context:
		    ;;   XtProcessEvent XtMainLoop XtAddActions XtNextEvent XtPeekEvent XtMalloc XtCalloc XtRealloc XtFree XFree 
		    ;;   freeXPoints moveXPoints vector->XPoints XmParseMappingCreate XmParseMappingSetValues 
		    ;;   XReadBitmapFile XReadBitmapFileData XmTransferStartRequest XmTransferSendRequest XmTransferDone 
		    (list
		     XPutBackEvent XNextEvent
		     XtAppProcessEvent XtAppMainLoop XtAppAddActions XtAppNextEvent XtAppPeekEvent
		     
;		     XpStartPage XpEndPage XpCancelPage XpStartJob XpEndJob XpCancelJob XpStartDoc XpEndDoc
;		     XpCancelDoc XpRehashPrinterList XpCreateContext XpSetContext XpGetContext XpDestroyContext
;		     XpGetLocaleNetString XpNotifyPdm XpSendAuth XpGetImageResolution XpGetAttributes XpSetAttributes
;		     XpGetOneAttribute XpGetScreenOfContext XpFreePrinterList XpQueryVersion XpQueryExtension
;		     XpQueryScreens XpGetPdmStartParams XpGetAuthParams XpSendOneTicket XpGetPageDimensions
;		     XpSetImageResolution XpGetPrinterList XpSelectInput XpInputSelected XpPutDocumentData
;		     XpGetDocumentData 
		     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 XtAddTimeOut
		     XtAppAddTimeOut XtRemoveTimeOut XtAddInput XtAppAddInput XtRemoveInput XtPending XtAppPending
		     XtRealizeWidget XtUnrealizeWidget XtDestroyWidget 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
		     XtCreateApplicationShell XtAppCreateShell XtVaAppCreateShell XtToolkitInitialize
		     XtSetLanguageProc XtDisplayInitialize XtOpenApplication XtVaOpenApplication XtAppInitialize
		     XtVaAppInitialize XtInitialize XtOpenDisplay XtCreateApplicationContext
		     XtDestroyApplicationContext XtInitializeWidgetClass XtWidgetToApplicationContext
		     XtDisplayToApplicationContext XtCloseDisplay 
		     XtSetValues XtVaSetValues XtGetValues XtVaGetValues
		     XtAppSetErrorMsgHandler XtSetErrorMsgHandler XtAppSetWarningMsgHandler XtSetWarningMsgHandler
		     XtAppErrorMsg XtErrorMsg XtAppWarningMsg XtWarningMsg XtAppSetErrorHandler XtSetErrorHandler
		     XtAppSetWarningHandler XtSetWarningHandler XtAppError XtError XtAppWarning XtWarning
		     XtAddWorkProc XtAppAddWorkProc XtRemoveWorkProc XtGetGC XtAllocateGC XtDestroyGC XtReleaseGC
		     XtFindFile XtResolvePathname XtDisownSelection XtGetSelectionValue
		     XtGetSelectionValues XtAppSetSelectionTimeout XtSetSelectionTimeout XtAppGetSelectionTimeout
		     XtGetSelectionTimeout 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
		     XGetFontPath 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
		     XGetStandardColormap XGetVisualInfo XGetWMHints XIntersectRegion XConvertCase XLookupString
		     XMatchVisualInfo XOffsetRegion XPointInRegion XPolygonRegion XRectInRegion XSaveContext
		     XSetRGBColormaps XSetWMHints XSetRegion XSetStandardColormap 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 
;		     XmRedisplayWidget XmPrintSetup XmPrintToFile XmPrintPopupPDM
		     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 XmAddToPostFromList
		     XmRemoveFromPostFromList 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 XmScrolledWindowSetAreas
		     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
		     XmMainWindowSetAreas XmMainWindowSep1 XmMainWindowSep2 XmMainWindowSep3 XmCreateMainWindow
		     XmInstallImage XmUninstallImage XmGetPixmap XmGetPixmapByDepth XmDestroyPixmap XmUpdateDisplay
		     XmWidgetGetBaselines XmRegisterSegmentEncoding XmMapSegmentEncoding
		     XmCvtCTToXmString XmCvtXmStringToCT XmConvertUnits XmSetFontUnits XmSetFontUnit XmSetMenuCursor
		     XmGetMenuCursor XmCreateSimpleMenuBar XmCreateSimplePopupMenu XmCreateSimplePulldownMenu
		     XmCreateSimpleOptionMenu XmCreateSimpleRadioBox XmCreateSimpleCheckBox XmVaCreateSimpleMenuBar
		     XmVaCreateSimplePopupMenu XmVaCreateSimplePulldownMenu XmVaCreateSimpleOptionMenu
		     XmVaCreateSimpleRadioBox XmVaCreateSimpleCheckBox XmTrackingEvent XmTrackingLocate
		     XmSetColorCalculation XmGetColorCalculation XmGetColors XmChangeColor XmStringCreate
		     XmStringCreateSimple XmStringCreateLocalized XmStringDirectionCreate XmStringSeparatorCreate
		     XmStringSegmentCreate XmStringCreateLtoR XmStringInitContext
		     XmStringFreeContext XmStringGetNextComponent XmStringPeekNextComponent XmStringGetNextSegment
		     XmStringGetLtoR XmFontListEntryCreate
		     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 XmFontListEntryFree XmFontListEntryGetFont XmFontListEntryGetTag
		     XmFontListAppendEntry XmFontListNextEntry XmFontListRemoveEntry XmFontListEntryLoad
		     XmFontListCreate XmFontListFree XmFontListAdd XmFontListCopy
		     XmFontListInitFontContext XmFontListGetNextFont XmFontListFreeFontContext XmStringConcat
		     XmStringNConcat XmStringCopy XmStringNCopy XmStringByteCompare XmStringCompare XmStringLength
		     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 XmIsMainWindow 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?
		     XStandardColormap? 
;		     XPContext? 
		     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? XmMainWindow? XmMessageBox? XmManager?
		     XmMenuShell? XmLabelGadget? XmPushButtonGadget? XmSeparatorGadget? XmArrowButtonGadget?
		     XmCascadeButtonGadget? XmToggleButtonGadget? XmDrawnButton? XmPrimitive? XmFontList?
		     XmFontContext? XmFontListEntry? 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 .95 .95 .95)  '#(0 1) 3/4 'mus-error (sqrt -1.0) (make-delay 32)
		     (lambda () #t) (current-module) (make-sound-data 2 3) :order 0 1 -1 (make-hook 2) #f #t '() (make-vector 0) 12345678901234567890))

	      ;; ---------------- 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 .95 .95 .95) '#(0 1) 3/4 
			(sqrt -1.0) (make-delay 32) :feedback -1 0 #f #t '() (make-vector 0) 12345678901234567890)))
	       (list win 1.5 "/hiho" (list 0 1) 1234 (make-vct 3) (make-color .95 .95 .95) '#(0 1) 3/4 
		     (sqrt -1.0) (make-delay 32) :frequency -1 0 #f #t '() (make-vector 0) 12345678901234567890))
	      
	      (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) 12345678901234567890)))
			(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) 12345678901234567890)))
		     (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) 12345678901234567890))
		    
		    ;; ---------------- 4 Args
		    (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))))
				 xm-procs4))
			      (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) 12345678901234567890)))
			   (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) 12345678901234567890)))
			(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) 12345678901234567890)))
		     (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) 12345678901234567890))
		    ))
	      
	      (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 ";(~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 ";(~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 ";(~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 ";(~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 ";(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))))
	      (gc))
	    (show-sounds-in-directory)
	    ;(show-all-atoms)

	    ))

      (run-hook after-test-hook 25)
      ))

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

(if (or full-test (= snd-test 26) (and keep-going (<= snd-test 26)))
    (begin
      (run-hook before-test-hook 26)
      (if (and (provided? 'snd-gtk)
	       (provided? 'xg))
	  (let ((ind (open-sound "oboe.snd")))
	    (if (not (GTK_IS_WIDGET (cadr (main-widgets)))) (snd-display ";GTK_IS_WIDGET?"))
	    ;; all gtk proc names are in gtk-procs.scm
	    (if (not (GTK_IS_ENTRY (list-ref (sound-widgets) 3))) (snd-display ";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 ";SND_VERSION: ~A ~A" str (snd-version))))
	    (if (not (string=? "STRING" (gdk_atom_name GDK_TARGET_STRING)))
		(snd-display ";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 ";~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_curve_new GTK_IS_CURVE 'GTK_IS_CURVE)
	      (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 (lambda () (gtk_file_chooser_button_new "hiho")) GTK_IS_FILE_CHOOSER_BUTTON 'GTK_IS_FILE_CHOOSER_BUTTON)
	      (list (lambda () (gtk_file_selection_new "hi")) GTK_IS_FILE_SELECTION 'GTK_IS_FILE_SELECTION)
	      (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_gamma_curve_new GTK_IS_GAMMA_CURVE 'GTK_IS_GAMMA_CURVE)
	      (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_input_dialog_new GTK_IS_INPUT_DIALOG 'GTK_IS_INPUT_DIALGO)
	      (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_tooltips_new GTK_IS_TOOLTIPS 'GTK_IS_TOOLTIPS)
	      (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)))
	    
	    (for-each
	     (lambda (data)
	       (let ((func (car data))
		     (type (cadr data))
		     (name (caddr data)))
		 (if type
		     (if (not (= (func) type))
			 (snd-display ";~A: ~A ~A" name (func) type))
		     (if (not (integer? (func)))
			 (snd-display ";~A: ~A" name (func))))))
	     (list
	      (list gdk_colormap_get_type GDK_TYPE_COLORMAP 'gdk_colormap_get_type)
	      (list gdk_color_get_type GDK_TYPE_COLOR 'gdk_color_get_type)
	      (list gdk_cursor_get_type GDK_TYPE_CURSOR 'gdk_cursor_get_type)
	      (list gdk_drag_context_get_type GDK_TYPE_DRAG_CONTEXT 'gdk_drag_context_get_type)
	      (list gdk_drawable_get_type GDK_TYPE_DRAWABLE 'gdk_drawable_get_type)
	      (list gdk_cursor_type_get_type GDK_TYPE_CURSOR_TYPE 'gdk_cursor_type_get_type)
	      (list gdk_drag_action_get_type GDK_TYPE_DRAG_ACTION 'gdk_drag_action_get_type)
	      (list gdk_drag_protocol_get_type GDK_TYPE_DRAG_PROTOCOL 'gdk_drag_protocol_get_type)
	      (list gdk_filter_return_get_type GDK_TYPE_FILTER_RETURN 'gdk_filter_return_get_type)
	      (list gdk_event_type_get_type GDK_TYPE_EVENT_TYPE 'gdk_event_type_get_type)
	      (list gdk_event_mask_get_type GDK_TYPE_EVENT_MASK 'gdk_event_mask_get_type)
	      (list gdk_visibility_state_get_type GDK_TYPE_VISIBILITY_STATE 'gdk_visibility_state_get_type)
	      (list gdk_scroll_direction_get_type GDK_TYPE_SCROLL_DIRECTION 'gdk_scroll_direction_get_type)
	      (list gdk_notify_type_get_type GDK_TYPE_NOTIFY_TYPE 'gdk_notify_type_get_type)
	      (list gdk_crossing_mode_get_type GDK_TYPE_CROSSING_MODE 'gdk_crossing_mode_get_type)
	      (list gdk_property_state_get_type GDK_TYPE_PROPERTY_STATE 'gdk_property_state_get_type)
	      (list gdk_window_state_get_type GDK_TYPE_WINDOW_STATE 'gdk_window_state_get_type)
	      (list gdk_setting_action_get_type GDK_TYPE_SETTING_ACTION 'gdk_setting_action_get_type)
	      (list gdk_font_type_get_type GDK_TYPE_FONT_TYPE 'gdk_font_type_get_type)
	      (list gdk_cap_style_get_type GDK_TYPE_CAP_STYLE 'gdk_cap_style_get_type)
	      (list gdk_fill_get_type GDK_TYPE_FILL 'gdk_fill_get_type)
	      (list gdk_function_get_type GDK_TYPE_FUNCTION 'gdk_function_get_type)
	      (list gdk_join_style_get_type GDK_TYPE_JOIN_STYLE 'gdk_join_style_get_type)
	      (list gdk_line_style_get_type GDK_TYPE_LINE_STYLE 'gdk_line_style_get_type)
	      (list gdk_subwindow_mode_get_type GDK_TYPE_SUBWINDOW_MODE 'gdk_subwindow_mode_get_type)
	      (list gdk_gc_values_mask_get_type GDK_TYPE_GC_VALUES_MASK 'gdk_gc_values_mask_get_type)
	      (list gdk_image_type_get_type GDK_TYPE_IMAGE_TYPE 'gdk_image_type_get_type)
	      (list gdk_extension_mode_get_type GDK_TYPE_EXTENSION_MODE 'gdk_extension_mode_get_type)
	      (list gdk_input_source_get_type GDK_TYPE_INPUT_SOURCE 'gdk_input_source_get_type)
	      (list gdk_input_mode_get_type GDK_TYPE_INPUT_MODE 'gdk_input_mode_get_type)
	      (list gdk_axis_use_get_type GDK_TYPE_AXIS_USE 'gdk_axis_use_get_type)
	      (list gdk_prop_mode_get_type GDK_TYPE_PROP_MODE 'gdk_prop_mode_get_type)
	      (list gdk_fill_rule_get_type GDK_TYPE_FILL_RULE 'gdk_fill_rule_get_type)
	      (list gdk_overlap_type_get_type GDK_TYPE_OVERLAP_TYPE 'gdk_overlap_type_get_type)
	      (list gdk_rgb_dither_get_type GDK_TYPE_RGB_DITHER 'gdk_rgb_dither_get_type)
	      (list gdk_byte_order_get_type GDK_TYPE_BYTE_ORDER 'gdk_byte_order_get_type)
	      (list gdk_modifier_type_get_type GDK_TYPE_MODIFIER_TYPE 'gdk_modifier_type_get_type)
	      (list gdk_input_condition_get_type GDK_TYPE_INPUT_CONDITION 'gdk_input_condition_get_type)
	      (list gdk_status_get_type GDK_TYPE_STATUS 'gdk_status_get_type)
	      (list gdk_grab_status_get_type GDK_TYPE_GRAB_STATUS 'gdk_grab_status_get_type)
	      (list gdk_visual_type_get_type GDK_TYPE_VISUAL_TYPE 'gdk_visual_type_get_type)
	      (list gdk_window_class_get_type GDK_TYPE_WINDOW_CLASS 'gdk_window_class_get_type)
	      (list gdk_window_type_get_type GDK_TYPE_WINDOW_TYPE 'gdk_window_type_get_type)
	      (list gdk_window_attributes_type_get_type GDK_TYPE_WINDOW_ATTRIBUTES_TYPE 'gdk_window_attributes_type_get_type)
	      (list gdk_window_hints_get_type GDK_TYPE_WINDOW_HINTS 'gdk_window_hints_get_type)
	      (list gdk_window_type_hint_get_type GDK_TYPE_WINDOW_TYPE_HINT 'gdk_window_type_hint_get_type)
	      (list gdk_wm_decoration_get_type GDK_TYPE_WM_DECORATION 'gdk_wm_decoration_get_type)
	      (list gdk_wm_function_get_type GDK_TYPE_WM_FUNCTION 'gdk_wm_function_get_type)
	      (list gdk_gravity_get_type GDK_TYPE_GRAVITY 'gdk_gravity_get_type)
	      (list gdk_window_edge_get_type GDK_TYPE_WINDOW_EDGE 'gdk_window_edge_get_type)
	      (list gdk_event_get_type GDK_TYPE_EVENT 'gdk_event_get_type)
	      (list gdk_gc_get_type GDK_TYPE_GC 'gdk_gc_get_type)
	      (list gdk_rectangle_get_type GDK_TYPE_RECTANGLE 'gdk_rectangle_get_type)
	      (list gdk_image_get_type GDK_TYPE_IMAGE 'gdk_image_get_type)
	      (list gdk_device_get_type GDK_TYPE_DEVICE 'gdk_device_get_type)
	      (list gdk_keymap_get_type GDK_TYPE_KEYMAP 'gdk_keymap_get_type)
	      (list gdk_pixmap_get_type GDK_TYPE_PIXMAP 'gdk_pixmap_get_type)
	      (list gdk_visual_get_type GDK_TYPE_VISUAL 'gdk_visual_get_type)
	      (list gdk_pixbuf_get_type GDK_TYPE_PIXBUF 'gdk_pixbuf_get_type)
	      (list gdk_pixbuf_animation_get_type GDK_TYPE_PIXBUF_ANIMATION 'gdk_pixbuf_animation_get_type)
	      (list gdk_pixbuf_animation_iter_get_type GDK_TYPE_PIXBUF_ANIMATION_ITER 'gdk_pixbuf_animation_iter_get_type)
	      (list gdk_pixbuf_loader_get_type GDK_TYPE_PIXBUF_LOADER 'gdk_pixbuf_loader_get_type)
	      (list gdk_pixbuf_alpha_mode_get_type GDK_TYPE_PIXBUF_ALPHA_MODE 'gdk_pixbuf_alpha_mode_get_type)
	      (list gdk_colorspace_get_type GDK_TYPE_COLORSPACE 'gdk_colorspace_get_type)
	      (list gdk_pixbuf_error_get_type GDK_TYPE_PIXBUF_ERROR 'gdk_pixbuf_error_get_type)
	      (list gdk_interp_type_get_type GDK_TYPE_INTERP_TYPE 'gdk_interp_type_get_type)
	      (list gtk_vbox_get_type GTK_TYPE_VBOX 'gtk_vbox_get_type)
	      (list gtk_accel_group_get_type GTK_TYPE_ACCEL_GROUP 'gtk_accel_group_get_type)
	      (list gtk_accel_label_get_type GTK_TYPE_ACCEL_LABEL 'gtk_accel_label_get_type)
	      (list gtk_accessible_get_type GTK_TYPE_ACCESSIBLE 'gtk_accessible_get_type)
	      (list gtk_adjustment_get_type GTK_TYPE_ADJUSTMENT 'gtk_adjustment_get_type)
	      (list gtk_alignment_get_type GTK_TYPE_ALIGNMENT 'gtk_alignment_get_type)
	      (list gtk_arrow_get_type GTK_TYPE_ARROW 'gtk_arrow_get_type)
	      (list gtk_aspect_frame_get_type GTK_TYPE_ASPECT_FRAME 'gtk_aspect_frame_get_type)
	      (list gtk_button_box_get_type GTK_TYPE_BUTTON_BOX 'gtk_button_box_get_type)
	      (list gtk_bin_get_type GTK_TYPE_BIN 'gtk_bin_get_type)
	      (list gtk_box_get_type GTK_TYPE_BOX 'gtk_box_get_type)
	      (list gtk_button_get_type GTK_TYPE_BUTTON 'gtk_button_get_type)
	      (list gtk_calendar_get_type GTK_TYPE_CALENDAR 'gtk_calendar_get_type)
	      (list gtk_cell_editable_get_type GTK_TYPE_CELL_EDITABLE 'gtk_cell_editable_get_type)
	      (list gtk_cell_renderer_get_type GTK_TYPE_CELL_RENDERER 'gtk_cell_renderer_get_type)
	      (list gtk_cell_renderer_pixbuf_get_type GTK_TYPE_CELL_RENDERER_PIXBUF 'gtk_cell_renderer_pixbuf_get_type)
	      (list gtk_cell_renderer_text_get_type GTK_TYPE_CELL_RENDERER_TEXT 'gtk_cell_renderer_text_get_type)
	      (list gtk_cell_renderer_toggle_get_type GTK_TYPE_CELL_RENDERER_TOGGLE 'gtk_cell_renderer_toggle_get_type)
	      (list gtk_check_button_get_type GTK_TYPE_CHECK_BUTTON 'gtk_check_button_get_type)
	      (list gtk_check_menu_item_get_type GTK_TYPE_CHECK_MENU_ITEM 'gtk_check_menu_item_get_type)
	      (list gtk_color_selection_dialog_get_type GTK_TYPE_COLOR_SELECTION_DIALOG 'gtk_color_selection_dialog_get_type)
	      (list gtk_color_selection_get_type GTK_TYPE_COLOR_SELECTION 'gtk_color_selection_get_type)
	      (list gtk_container_get_type GTK_TYPE_CONTAINER 'gtk_container_get_type)
	      (list gtk_curve_get_type GTK_TYPE_CURVE 'gtk_curve_get_type)
	      (list gtk_dialog_get_type GTK_TYPE_DIALOG 'gtk_dialog_get_type)
	      (list gtk_drawing_area_get_type GTK_TYPE_DRAWING_AREA 'gtk_drawing_area_get_type)
	      (list gtk_editable_get_type GTK_TYPE_EDITABLE 'gtk_editable_get_type)
	      (list gtk_entry_get_type GTK_TYPE_ENTRY 'gtk_entry_get_type)
	      (list gtk_event_box_get_type GTK_TYPE_EVENT_BOX 'gtk_event_box_get_type)
	      (list gtk_file_selection_get_type GTK_TYPE_FILE_SELECTION 'gtk_file_selection_get_type)
	      (list gtk_icon_set_get_type GTK_TYPE_ICON_SET 'gtk_icon_set_get_type)
	      (list gtk_icon_source_get_type GTK_TYPE_ICON_SOURCE 'gtk_icon_source_get_type)
	      (list gtk_selection_data_get_type GTK_TYPE_SELECTION_DATA 'gtk_selection_data_get_type)
	      (list gtk_border_get_type GTK_TYPE_BORDER 'gtk_border_get_type)
	      (list gtk_tree_path_get_type GTK_TYPE_TREE_PATH 'gtk_tree_path_get_type)
	      (list gtk_tree_iter_get_type GTK_TYPE_TREE_ITER 'gtk_tree_iter_get_type)
	      (list gtk_identifier_get_type GTK_TYPE_IDENTIFIER 'gtk_identifier_get_type)
	      (list gtk_requisition_get_type GTK_TYPE_REQUISITION 'gtk_requisition_get_type)
	      (list gtk_file_chooser_button_get_type GTK_TYPE_FILE_CHOOSER_BUTTON 'gtk_file_chooser_button_get_type)
	      (list gtk_fixed_get_type GTK_TYPE_FIXED 'gtk_fixed_get_type)
	      (list gtk_font_selection_get_type GTK_TYPE_FONT_SELECTION 'gtk_font_selection_get_type)
	      (list gtk_font_selection_dialog_get_type GTK_TYPE_FONT_SELECTION_DIALOG 'gtk_font_selection_dialog_get_type)
	      (list gtk_frame_get_type GTK_TYPE_FRAME 'gtk_frame_get_type)
	      (list gtk_gamma_curve_get_type GTK_TYPE_GAMMA_CURVE 'gtk_gamma_curve_get_type)
	      (list gtk_handle_box_get_type GTK_TYPE_HANDLE_BOX 'gtk_handle_box_get_type)
	      (list gtk_hbutton_box_get_type GTK_TYPE_HBUTTON_BOX 'gtk_hbutton_box_get_type)
	      (list gtk_hbox_get_type GTK_TYPE_HBOX 'gtk_hbox_get_type)
	      (list gtk_hpaned_get_type GTK_TYPE_HPANED 'gtk_hpaned_get_type)
	      (list gtk_hruler_get_type GTK_TYPE_HRULER 'gtk_hruler_get_type)
	      (list gtk_hscale_get_type GTK_TYPE_HSCALE 'gtk_hscale_get_type)
	      (list gtk_hscrollbar_get_type GTK_TYPE_HSCROLLBAR 'gtk_hscrollbar_get_type)
	      (list gtk_hseparator_get_type GTK_TYPE_HSEPARATOR 'gtk_hseparator_get_type)
	      (list gtk_icon_factory_get_type #f 'gtk_icon_factory_get_type)
	      (list gtk_image_get_type GTK_TYPE_IMAGE 'gtk_image_get_type)
	      (list gtk_image_menu_item_get_type GTK_TYPE_IMAGE_MENU_ITEM 'gtk_image_menu_item_get_type)
	      (list gtk_im_context_get_type GTK_TYPE_IM_CONTEXT 'gtk_im_context_get_type)
	      (list gtk_im_context_simple_get_type GTK_TYPE_IM_CONTEXT_SIMPLE 'gtk_im_context_simple_get_type)
	      (list gtk_im_multicontext_get_type GTK_TYPE_IM_MULTICONTEXT 'gtk_im_multicontext_get_type)
	      (list gtk_input_dialog_get_type GTK_TYPE_INPUT_DIALOG 'gtk_input_dialog_get_type)
	      (list gtk_invisible_get_type GTK_TYPE_INVISIBLE 'gtk_invisible_get_type)
	      (list gtk_item_get_type GTK_TYPE_ITEM 'gtk_item_get_type)
	      (list gtk_label_get_type GTK_TYPE_LABEL 'gtk_label_get_type)
	      (list gtk_layout_get_type GTK_TYPE_LAYOUT 'gtk_layout_get_type)
	      (list gtk_list_store_get_type GTK_TYPE_LIST_STORE 'gtk_list_store_get_type)
	      (list gtk_menu_bar_get_type GTK_TYPE_MENU_BAR 'gtk_menu_bar_get_type)
	      (list gtk_menu_get_type GTK_TYPE_MENU 'gtk_menu_get_type)
	      (list gtk_menu_item_get_type GTK_TYPE_MENU_ITEM 'gtk_menu_item_get_type)
	      (list gtk_menu_shell_get_type GTK_TYPE_MENU_SHELL 'gtk_menu_shell_get_type)
	      (list gtk_message_dialog_get_type GTK_TYPE_MESSAGE_DIALOG 'gtk_message_dialog_get_type)
	      (list gtk_misc_get_type GTK_TYPE_MISC 'gtk_misc_get_type)
	      (list gtk_notebook_get_type GTK_TYPE_NOTEBOOK 'gtk_notebook_get_type)
	      (list gtk_object_get_type GTK_TYPE_OBJECT 'gtk_object_get_type)
	      (list gtk_paned_get_type GTK_TYPE_PANED 'gtk_paned_get_type)
	      (list gtk_plug_get_type GTK_TYPE_PLUG 'gtk_plug_get_type)
	      (list gtk_progress_bar_get_type GTK_TYPE_PROGRESS_BAR 'gtk_progress_bar_get_type)
	      (list gtk_radio_button_get_type GTK_TYPE_RADIO_BUTTON 'gtk_radio_button_get_type)
	      (list gtk_radio_menu_item_get_type GTK_TYPE_RADIO_MENU_ITEM 'gtk_radio_menu_item_get_type)
	      (list gtk_range_get_type GTK_TYPE_RANGE 'gtk_range_get_type)
	      (list gtk_rc_style_get_type GTK_TYPE_RC_STYLE 'gtk_rc_style_get_type)
	      (list gtk_ruler_get_type GTK_TYPE_RULER 'gtk_ruler_get_type)
	      (list gtk_scale_get_type GTK_TYPE_SCALE 'gtk_scale_get_type)
	      (list gtk_scrollbar_get_type GTK_TYPE_SCROLLBAR 'gtk_scrollbar_get_type)
	      (list gtk_scrolled_window_get_type GTK_TYPE_SCROLLED_WINDOW 'gtk_scrolled_window_get_type)
	      (list gtk_separator_get_type GTK_TYPE_SEPARATOR 'gtk_separator_get_type)
	      (list gtk_separator_menu_item_get_type GTK_TYPE_SEPARATOR_MENU_ITEM 'gtk_separator_menu_item_get_type)
	      (list gtk_size_group_get_type GTK_TYPE_SIZE_GROUP 'gtk_size_group_get_type)
	      (list gtk_socket_get_type GTK_TYPE_SOCKET 'gtk_socket_get_type)
	      (list gtk_spin_button_get_type GTK_TYPE_SPIN_BUTTON 'gtk_spin_button_get_type)
	      (list gtk_statusbar_get_type GTK_TYPE_STATUSBAR 'gtk_statusbar_get_type)
	      (list gtk_style_get_type GTK_TYPE_STYLE 'gtk_style_get_type)
	      (list gtk_table_get_type GTK_TYPE_TABLE 'gtk_table_get_type)
	      (list gtk_tearoff_menu_item_get_type GTK_TYPE_TEAROFF_MENU_ITEM 'gtk_tearoff_menu_item_get_type)
	      (list gtk_text_buffer_get_type GTK_TYPE_TEXT_BUFFER 'gtk_text_buffer_get_type)
	      (list gtk_text_child_anchor_get_type GTK_TYPE_TEXT_CHILD_ANCHOR 'gtk_text_child_anchor_get_type)
	      (list gtk_text_mark_get_type GTK_TYPE_TEXT_MARK 'gtk_text_mark_get_type)
	      (list gtk_text_tag_get_type GTK_TYPE_TEXT_TAG 'gtk_text_tag_get_type)
	      (list gtk_text_tag_table_get_type GTK_TYPE_TEXT_TAG_TABLE 'gtk_text_tag_table_get_type)
	      (list gtk_text_view_get_type GTK_TYPE_TEXT_VIEW 'gtk_text_view_get_type)
	      (list gtk_toggle_button_get_type GTK_TYPE_TOGGLE_BUTTON 'gtk_toggle_button_get_type)
	      (list gtk_toolbar_get_type GTK_TYPE_TOOLBAR 'gtk_toolbar_get_type)
	      (list gtk_tooltips_get_type GTK_TYPE_TOOLTIPS 'gtk_tooltips_get_type)
	      (list gtk_tree_drag_source_get_type GTK_TYPE_TREE_DRAG_SOURCE 'gtk_tree_drag_source_get_type)
	      (list gtk_tree_drag_dest_get_type GTK_TYPE_TREE_DRAG_DEST 'gtk_tree_drag_dest_get_type)
	      (list gtk_tree_model_get_type GTK_TYPE_TREE_MODEL 'gtk_tree_model_get_type)
	      (list gtk_tree_model_sort_get_type GTK_TYPE_TREE_MODEL_SORT 'gtk_tree_model_sort_get_type)
	      (list gtk_tree_selection_get_type GTK_TYPE_TREE_SELECTION 'gtk_tree_selection_get_type)
	      (list gtk_tree_sortable_get_type GTK_TYPE_TREE_SORTABLE 'gtk_tree_sortable_get_type)
	      (list gtk_tree_store_get_type GTK_TYPE_TREE_STORE 'gtk_tree_store_get_type)
	      (list gtk_tree_view_column_get_type GTK_TYPE_TREE_VIEW_COLUMN 'gtk_tree_view_column_get_type)
	      (list gtk_tree_view_get_type GTK_TYPE_TREE_VIEW 'gtk_tree_view_get_type)
	      (list gtk_vbutton_box_get_type GTK_TYPE_VBUTTON_BOX 'gtk_vbutton_box_get_type)
	      (list gtk_viewport_get_type GTK_TYPE_VIEWPORT 'gtk_viewport_get_type)
	      (list gtk_vpaned_get_type GTK_TYPE_VPANED 'gtk_vpaned_get_type)
	      (list gtk_vruler_get_type GTK_TYPE_VRULER 'gtk_vruler_get_type)
	      (list gtk_vscale_get_type GTK_TYPE_VSCALE 'gtk_vscale_get_type)
	      (list gtk_vscrollbar_get_type GTK_TYPE_VSCROLLBAR 'gtk_vscrollbar_get_type)
	      (list gtk_vseparator_get_type GTK_TYPE_VSEPARATOR 'gtk_vseparator_get_type)
	      (list gtk_widget_get_type GTK_TYPE_WIDGET 'gtk_widget_get_type)
	      (list gtk_window_get_type GTK_TYPE_WINDOW 'gtk_window_get_type)
	      (list pango_color_get_type #f 'pango_color_get_type)
	      (list pango_attr_list_get_type #f 'pango_attr_list_get_type)
	      (list pango_context_get_type #f 'pango_context_get_type)
	      (list pango_attr_type_get_type #f 'pango_attr_type_get_type)
	      (list pango_underline_get_type #f 'pango_underline_get_type)
	      (list pango_coverage_level_get_type #f 'pango_coverage_level_get_type)
	      (list pango_style_get_type #f 'pango_style_get_type)
	      (list pango_variant_get_type #f 'pango_variant_get_type)
	      (list pango_weight_get_type #f 'pango_weight_get_type)
	      (list pango_stretch_get_type #f 'pango_stretch_get_type)
	      (list pango_font_mask_get_type #f 'pango_font_mask_get_type)
	      (list pango_alignment_get_type #f 'pango_alignment_get_type)
	      (list pango_wrap_mode_get_type #f 'pango_wrap_mode_get_type)
	      (list pango_tab_align_get_type #f 'pango_tab_align_get_type)
	      (list pango_direction_get_type #f 'pango_direction_get_type)
	      (list pango_font_description_get_type #f 'pango_font_description_get_type)
	      (list pango_font_metrics_get_type #f 'pango_font_metrics_get_type)
	      (list pango_font_face_get_type #f 'pango_font_face_get_type)
	      (list pango_font_get_type #f 'pango_font_get_type)
	      (list pango_font_map_get_type #f 'pango_font_map_get_type)
	      (list pango_glyph_string_get_type #f 'pango_glyph_string_get_type)
	      (list pango_layout_get_type #f 'pango_layout_get_type)
	      (list pango_language_get_type #f 'pango_language_get_type)
	      (list gdk_display_get_type GDK_TYPE_DISPLAY 'gdk_display_get_type)
	      (list gdk_screen_get_type GDK_TYPE_SCREEN 'gdk_screen_get_type)
	      (list gtk_file_chooser_dialog_get_type GTK_TYPE_FILE_CHOOSER_DIALOG 'gtk_file_chooser_dialog_get_type)
	      (list gtk_file_chooser_widget_get_type GTK_TYPE_FILE_CHOOSER_WIDGET 'gtk_file_chooser_widget_get_type)
	      (list gtk_tree_model_filter_get_type GTK_TYPE_TREE_MODEL_FILTER 'gtk_tree_model_filter_get_type)
	      (list gtk_action_get_type GTK_TYPE_ACTION 'gtk_action_get_type)
	      (list gtk_action_group_get_type GTK_TYPE_ACTION_GROUP 'gtk_action_group_get_type)
	      (list gtk_combo_box_get_type GTK_TYPE_COMBO_BOX 'gtk_combo_box_get_type)
	      (list gtk_combo_box_entry_get_type GTK_TYPE_COMBO_BOX_ENTRY 'gtk_combo_box_entry_get_type)
	      (list gtk_expander_get_type GTK_TYPE_EXPANDER 'gtk_expander_get_type)
	      (list gtk_font_button_get_type GTK_TYPE_FONT_BUTTON 'gtk_font_button_get_type)
	      (list gtk_color_button_get_type GTK_TYPE_COLOR_BUTTON 'gtk_color_button_get_type)
	      (list gtk_entry_completion_get_type GTK_TYPE_ENTRY_COMPLETION 'gtk_entry_completion_get_type)
	      (list gtk_ui_manager_get_type GTK_TYPE_UI_MANAGER 'gtk_ui_manager_get_type)
	      (list gtk_radio_tool_button_get_type GTK_TYPE_RADIO_TOOL_BUTTON 'gtk_radio_tool_button_get_type)
	      (list gtk_radio_action_get_type GTK_TYPE_RADIO_ACTION 'gtk_radio_action_get_type)
	      (list gtk_separator_tool_item_get_type GTK_TYPE_SEPARATOR_TOOL_ITEM 'gtk_separator_tool_item_get_type)
	      (list gtk_toggle_action_get_type GTK_TYPE_TOGGLE_ACTION 'gtk_toggle_action_get_type)
	      (list gtk_toggle_tool_button_get_type GTK_TYPE_TOGGLE_TOOL_BUTTON 'gtk_toggle_tool_button_get_type)
	      (list gtk_file_filter_get_type GTK_TYPE_FILE_FILTER 'gtk_file_filter_get_type)
	      (list gtk_cell_layout_get_type GTK_TYPE_CELL_LAYOUT 'gtk_cell_layout_get_type)
	      (list gtk_file_chooser_get_type GTK_TYPE_FILE_CHOOSER 'gtk_file_chooser_get_type)
	      (list gtk_icon_theme_get_type GTK_TYPE_ICON_THEME 'gtk_icon_theme_get_type)
	      (list gtk_icon_info_get_type GTK_TYPE_ICON_INFO 'gtk_icon_info_get_type)
	      (list gtk_tool_button_get_type GTK_TYPE_TOOL_BUTTON 'gtk_tool_button_get_type)
	      (list gtk_tool_item_get_type GTK_TYPE_TOOL_ITEM 'gtk_tool_item_get_type)
	      (list gtk_accel_map_get_type #f 'gtk_accel_map_get_type)))

	    (let ((name (g_type_name (gtk_vscrollbar_get_type))))
	      (if (not (string=? name "GtkVScrollbar")) (snd-display ";g_type_name: ~A" name)))
	    (let ((type (g_type_from_name "GtkVScrollbar")))
	      (if (not (= type (gtk_vscrollbar_get_type))) 
		  (snd-display ";g_type_from_name: ~A ~A" type (g_type_name type))))
	    (let ((name (g_type_name (g_type_parent (gtk_vscrollbar_get_type)))))
	      (if (not (string=? name "GtkScrollbar")) (snd-display ";parent g_type_name: ~A" name)))      
	    (let ((_gchar_ (gdk_set_locale)))
	      (let ((_gchar1_ (gtk_set_locale)))
		(if (not (string=? _gchar_ _gchar1_))
		    (snd-display ";*-set-locale: ~A ~A" _gchar_ _gchar1_))))
	    (let ((_char_ (gdk_get_program_class)))
	      (if (or (not (string? _char_))
		      (not (string=? _char_ "Snd")))
		  (snd-display ";get program class: ~A" _char_))
	      (gdk_set_program_class "Hiho")
	      (if (not (string=? (gdk_get_program_class) "Hiho")) (snd-display ";set program class: ~A" (gdk_get_program_class)))
	      (gdk_set_program_class "Snd"))
	    (if (not (string=? (gdk_get_display) ":0.0")) (snd-display ";gdk_get_display: ~A" (gdk_get_display)))
	    (if (not (= (gdk_screen_width) 1600)) (snd-display ";gdk_screen_width: ~A" (gdk_screen_width)))
	    (if (not (= (gdk_screen_width_mm) 402)) (snd-display ";gdk_screen_width_mm: ~A" (gdk_screen_width_mm)))
	    (if (not (= (gdk_screen_height) 1200)) (snd-display ";gdk_screen_height: ~A" (gdk_screen_height)))
	    (if (not (= (gdk_screen_height_mm) 302)) (snd-display ";gdk_screen_height_mm: ~A" (gdk_screen_height_mm)))
	    (gdk_beep)
	    (if (not (gtk_true)) (snd-display ";gtk_true: ~A" (gtk_true)))
	    (if (gtk_false) (snd-display ";gtk_false: ~A" (gtk_false)))
	    (if (gdk_pointer_is_grabbed) (snd-display ";gdk_pointer_is_grabbed?"))
	    (if (not (gdk_devices_list)) (snd-display ";gdk_devices_list?"))
	    (if (not (gdk_list_visuals)) (snd-display ";gdk_list_visuals?"))
	    (if (not (gdk_window_get_toplevels)) (snd-display ";gdk_window_get_toplevels?"))
	    (if (not (gtk_window_list_toplevels)) (snd-display ";gtk_window_list_toplevels?"))
	    (gtk_window_set_default_icon_list (gtk_window_get_default_icon_list))
	    (if (gdk_rgb_ditherable) (snd-display ";rgb ditherable?"))
	    (if (not (= (gdk_visual_get_best_depth) 24)) (snd-display ";best depth: ~A" (gdk_visual_get_best_depth)))
	    (if (not (string=? (gtk_rc_get_theme_dir) "/usr/local/share/themes")) (snd-display ";theme dir: ~A" (gtk_rc_get_theme_dir)))
	    (if (not (string=? (gtk_rc_get_module_dir) "/usr/local/lib/gtk-2.0/2.4.0/engines")) (snd-display ";module dir: ~A" (gtk_rc_get_module_dir)))
	    (if (not (string? (gtk_rc_get_im_module_path))) (snd-display ";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 ";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 ";gtk rc def files: ~A" files)))
	    (if (not (gtk_get_default_language)) (snd-display ";def lang: ~A" (gtk_get_default_language)))

	    (let* ((vals (gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default) #x60))
		   (key (and (car vals) (cadr vals)))
		   (code (.keycode key)) ; 49
		   (level (.level key))  ; 0 
		   (group (.group key)) ; 0
		   (vals1 (gdk_keymap_get_entries_for_keycode (gdk_keymap_get_default) 49))
		   (code1 (.keycode (cadr vals1))) ; 49
		   (dir (gdk_keymap_get_direction (gdk_keymap_get_default))) ; 0
		   (key1 (gdk_keymap_lookup_key (gdk_keymap_get_default) key))) ; #x60
	      (if (not (= code 49)) (snd-display ";.keycode keymap for keyval: ~A" code))
	      (if (not (= level 0)) (snd-display ";.level keymap for keyval: ~A" level))
	      (if (not (= group 0)) (snd-display ";.group keymap for keyval: ~A" group))
	      (if (not (= code1 49)) (snd-display ";.keycode keymap for keycode: ~A" code1))  
	      (if (not (= dir 0)) (snd-display ";keymap direction: ~A" dir))
	      (if (not (= key1 #x60)) (snd-display ";keymap lookup key: ~A" key1)))

	    (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_))
		   (_GdkDevice_ (gdk_display_get_core_pointer _GdkDisplay_))
		   (_GdkDevice1_ (gdk_device_get_core_pointer))
		   (_gboolean2 (gdk_display_supports_cursor_alpha _GdkDisplay_))
		   (_gboolean3 (gdk_display_supports_cursor_color _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 ";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 ";visuals not equal"))
	      (if (or (not (equal? _GdkVisual2_ _GdkVisual4_)) (not (equal? _GdkVisual2_ _GdkVisual8_)) (not (equal? _GdkVisual2_ _GdkVisual5_)))
		  (snd-display ";visuals (2) not equal"))
	      (if (not (= _GdkVisualType 5)) (snd-display ";visual type: ~A" _GdkVisualType))
	      (if (not (equal? _GdkScreen_ _GdkScreen1_)) (snd-display ";screens not equal"))
	      (if (not (equal? _GdkDisplay_ _GdkDisplay1_)) (snd-display ";displays not equal"))
	      (if (not (= _gint 24)) (snd-display ";_gint: ~A" _gint))
	      (if (not (= _int 1)) (snd-display ";_int: ~A" _int))
	      (if (not (= _int1 0)) (snd-display ";_int1: ~A" _int1))
	      (if (not (= _int2 1600)) (snd-display ";_int2: ~A" _int2))
	      (if (not (= _int3 1200)) (snd-display ";_int3: ~A" _int3))
	      (if (not (= _int4 402)) (snd-display ";_int4: ~A" _int4))
	      (if (not (= _int5 302)) (snd-display ";_int5: ~A" _int5))
	      (if (not (= _int6 1)) (snd-display ";_int6: ~A" _int6))
	      (if (not (equal? _GdkDevice_ _GdkDevice1_)) (snd-display ";devices not equal"))
	      (if (or (not (equal? _GdkWindow_ _GdkWindow2_)) (not (equal? _GdkWindow1_ _GdkWindow2_))) (snd-display ";windows not equal"))
	      (if (not (string=? _gchar_ ":0.0")) (snd-display ";_gchar: ~A" _gchar_))
	      (if _gboolean (snd-display ";_gboolean: ~A" _gboolean))
	      (if _gboolean1 (snd-display ";_gboolean1: ~A" _gboolean1))
	      (if (not _gboolean2) (snd-display ";_gboolean2: ~A" _gboolean2))
	      (if (not _gboolean3) (snd-display ";_gboolean3: ~A" _gboolean3))
	      (if (not (= _guint 25)) (snd-display ";_giunt: ~A" _guint))
	      (if (not (GDK_IS_COLORMAP _GdkColormap6_)) (snd-display ";not colormap6: ~A" _GdkColormap6_))
	      (if (not (GTK_IS_WIDGET _GtkWidget_)) (snd-display ";not widget: ~A" _GtkWidget_))
	      (if (not (GDK_IS_DRAWABLE _GdkDrawable_)) (snd-display ";not drawable: ~A" _GdkDrawable_))
	      (if (not (GDK_IS_GC _GdkGC_)) (snd-display ";not gc: ~A" _GdkGC_))
	      (if (not (GDK_IS_VISUAL _GdkVisual_)) (snd-display ";not visual: ~A" _GdkVisual_))
	      (if (not (GDK_IS_SCREEN _GdkScreen_)) (snd-display ";not screen: ~A" _GdkScreen_))
	      (if (not (GDK_IS_DISPLAY _GdkDisplay_)) (snd-display ";not display: ~A" _GdkDisplay_))
	      (if (not (GDK_IS_WINDOW _GdkWindow_)) (snd-display ";not window: ~A" _GdkWindow_))
	      (if (not (GDK_IS_DEVICE _GdkDevice_)) (snd-display ";not device: ~A" _GdkDevice_))
	      (let ((types (gdk_query_visual_types)))
		(if (not (member _GdkVisualType (c-array->list (car types) (cadr types))))
		    (snd-display ";visuals: ~A and ~A" _GdkVisualType types)))
	      (let ((depths (gdk_query_depths)))
		(if (not (member _gint (c-array->list (car depths) (cadr depths))))
		    (snd-display ";depths: ~A and ~A" _gint depths)))
	      (for-each
	       (lambda (lst type check)
		 (let ((len (g_list_length lst)))
		   (if (<= len 0)
		       (snd-display ";~A is empty" lst)
		       (call-with-current-continuation
			(lambda (break)
			  (do ((i 0 (1+ i)))
			      ((= i len))
			    (let* ((element (g_list_nth_data lst i))
				   (datum (and element (type element)))
				   (err (if element 
					    (check datum) 
					    (format #f "~A[~A of ~A] is null?" lst i len))))
			      (if err 
				  (begin
				    (snd-display ";GList ~A[~A]: ~A" lst i err)
				    (break))))))))))
	       (list _GList_ _GList1_ _GList2_)
	       (list GDK_VISUAL GDK_WINDOW GDK_DEVICE)
	       (list (lambda (val)
		       (let ((depth (.depth val)))
			 (if (not (= depth 24))
			     (format #f "depth: ~A" depth)
			     #f)))
		     (lambda (val) #f)
		     (lambda (val) #f)))
	      (let ((new-list (g_list_copy _GList_)))
		(if (not (= (g_list_length _GList_) (g_list_length new-list))) 
		    (snd-display ";g_list_copy: ~A ~A" (g_list_length _GList_) (g_list_length new-list)))
		(let ((rev-list (g_list_reverse new-list))
		      (first (g_list_first new-list))
		      (last (g_list_last new-list)))
		  (g_list_free new-list)))
	      (gdk_display_beep _GdkDisplay_)
	      (let ((size (.size _GdkColormap_))
		    (colors (.colors _GdkColormap_))
		    (visual (.visual _GdkColormap_))
		    (data (.windowing_data _GdkColormap_))
		    (name (.name _GdkDevice_))
		    (mode (.mode _GdkDevice_))
		    (has_cursor (.has_cursor _GdkDevice_))
		    (num_axes (.num_axes _GdkDevice_))
		    (num_keys (.num_keys _GdkDevice_))
		    (keys (.keys _GdkDevice_))
		    (source (.source _GdkDevice_))
		    (axes (.axes _GdkDevice_))
		    (type (.type _GdkVisual_))
		    (depth (.depth _GdkVisual_))
		    (byte_order (.byte_order _GdkVisual_))
		    (colormap_size (.colormap_size _GdkVisual_))
		    (bits_per_rgb (.bits_per_rgb _GdkVisual_))
		    (red_mask (.red_mask _GdkVisual_))
		    (red_shift (.red_shift _GdkVisual_))
		    (red_prec (.red_prec _GdkVisual_))
		    (blue_mask (.blue_mask _GdkVisual_))
		    (blue_shift (.blue_shift _GdkVisual_))
		    (blue_prec (.blue_prec _GdkVisual_))
		    (green_mask (.green_mask _GdkVisual_))
		    (green_shift (.green_shift _GdkVisual_))
		    (green_prec (.green_prec _GdkVisual_)))
		(if (not (= size 256)) (snd-display ";.size: ~A" size))
		(if colors (snd-display ";.colors"))
		(if (not (GDK_IS_VISUAL visual)) (snd-display ";.visual: ~A" visual))
		(if (not (string=? name "Core Pointer")) (snd-display ";.name: ~A" name))
		(if (not (= mode 1)) (snd-display ";.mode: ~A" mode))
		(if (not has_cursor) (snd-display ";.has_cursor"))
		(if (not (= num_axes 2)) (snd-display ";.num_axes: ~A" num_axes))
		(if (not (= num_keys 0)) (snd-display ";.num_keys: ~A" num_keys))
		(if keys (snd-display ";.keys: ~A" keys))
		(if (not (= source 0)) (snd-display ";.source: ~A" source))
		(if (not (= type 4)) (snd-display ";.type: ~A" type))
		(if (not (= depth 24)) (snd-display ";.depth: ~A" depth))
		(if (not (= byte_order 0)) (snd-display ";.byte_order: ~A" byte_order))
		(if (not (= colormap_size 256)) (snd-display ";.colormap_size: ~A" colormap_size))
		(if (not (= bits_per_rgb 8)) (snd-display ";.bits_per_rgb: ~A" bits_per_rgb))
		(if (not (= red_mask 16711680)) (snd-display ";.red_mask: ~A" red_mask))
		(if (not (= red_shift 16)) (snd-display ";.red_shift: ~A" red_shift))
		(if (not (= red_prec 8)) (snd-display ";.red_prec: ~A" red_prec))
		(if (not (= blue_mask 255)) (snd-display ";.blue_mask: ~A" blue_mask))
		(if (not (= blue_shift 0)) (snd-display ";.blue_shift: ~A" blue_shift))
		(if (not (= blue_prec 8)) (snd-display ";.blue_prec: ~A" blue_prec))
		(if (not (= green_mask 65280)) (snd-display ";.green_mask: ~A" green_mask))
		(if (not (= green_shift 8)) (snd-display ";.green_shift: ~A" green_shift))
		(if (not (= green_prec 8)) (snd-display ";.green_prec: ~A" green_prec))))
	    
	    (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 ";gtk button label: ~A" _gchar1_))
	      (if _gboolean (snd-display ";button underline"))
	      (if _gboolean1 (snd-display ";button use stock"))
	      (if (not _gboolean2) (snd-display ";button focus on click"))
	      (if (not (= _GtkReliefStyle GTK_RELIEF_NORMAL)) (snd-display ";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 ";button align: ~A" align)))
	      ;; presumably these care explicit callbacks
	      (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 ";set gtk button label: ~A" _gchar1_))
	      (if (not (gtk_button_get_use_underline _GtkButton_)) (snd-display ";set button underline"))
	      (if (not (gtk_button_get_use_stock _GtkButton_)) (snd-display ";set button use stock"))
	      (if (gtk_button_get_focus_on_click _GtkButton_) (snd-display ";set button focus on click"))
	      (if (not (= (gtk_button_get_relief _GtkButton_) GTK_RELIEF_NONE)) (snd-display ";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 ";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 ";toggle mode"))
	      (if _gboolean1 (snd-display ";toggle active"))
	      (if _gboolean2 (snd-display ";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 ";set toggle mode"))
	      (if (not (gtk_toggle_button_get_mode _GtkToggleButton_)) (snd-display ";set toggle active"))
	      (if (not (gtk_toggle_button_get_mode _GtkToggleButton_)) (snd-display ";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_))
		   (_int (GTK_WIDGET_STATE _GtkWidget_))
		   (_int1 (GTK_WIDGET_SAVED_STATE _GtkWidget_))
		   (_int2 (GTK_WIDGET_FLAGS _GtkWidget_))
		   (_gboolean4 (GTK_WIDGET_TOPLEVEL _GtkWidget_))
		   (_gboolean5 (GTK_WIDGET_NO_WINDOW _GtkWidget_))
		   (_gboolean6 (GTK_WIDGET_REALIZED _GtkWidget_))
		   (_gboolean7 (GTK_WIDGET_MAPPED _GtkWidget_))
		   (_gboolean8 (GTK_WIDGET_VISIBLE _GtkWidget_))
		   (_gboolean9 (GTK_WIDGET_DRAWABLE _GtkWidget_))
		   (_gboolean10 (GTK_WIDGET_SENSITIVE _GtkWidget_))
		   (_gboolean11 (GTK_WIDGET_PARENT_SENSITIVE _GtkWidget_))
		   (_gboolean12 (GTK_WIDGET_IS_SENSITIVE _GtkWidget_))
		   (_gboolean13 (GTK_WIDGET_CAN_FOCUS _GtkWidget_))
		   (_gboolean14 (GTK_WIDGET_HAS_FOCUS _GtkWidget_))
		   (_gboolean15 (GTK_WIDGET_CAN_DEFAULT _GtkWidget_))
		   (_gboolean16 (GTK_WIDGET_HAS_DEFAULT _GtkWidget_))
		   (_gboolean17 (GTK_WIDGET_HAS_GRAB _GtkWidget_))
		   (_gboolean18 (GTK_WIDGET_RC_STYLE _GtkWidget_))
		   (_gboolean19 (GTK_WIDGET_COMPOSITE_CHILD _GtkWidget_))
		   (_gboolean20 (GTK_WIDGET_APP_PAINTABLE _GtkWidget_))
		   (_gboolean21 (GTK_WIDGET_RECEIVES_DEFAULT _GtkWidget_))
		   (_gboolean22 (GTK_WIDGET_DOUBLE_BUFFERED _GtkWidget_)))
	      (if (not (string=? _gchar_ "hiho")) (snd-display ";label text: ~A" _gchar_))
	      (if (not (string=? _gchar1_ "hiho")) (snd-display ";label label: ~A" _gchar1_))
	      (if (not (= _GtkJustification GTK_JUSTIFY_LEFT)) (snd-display ";label justification: ~A ~A" _GtkJustification GTK_JUSTIFY_LEFT))
	      (if (not (equal? (list #f 0 0) _list)) (snd-display ";label selection bounds: ~A" _list))
	      (if (not (equal? (list 0 0) _list1)) (snd-display ";label layout offsets: ~A" _list1))
	      (if (not (= _int 0)) (snd-display ";WIDGET STATE: ~A" _int))
	      (if (not (= _int1 0)) (snd-display ";WIDGET SAVED STATE: ~A" _int1))
	      (if _GtkWidget1_ (snd-display ";mnemnoinic widget: ~A" _GtkWidget1_))
	      (if _gboolean (snd-display ";label use markup"))
	      (if _gboolean1 (snd-display ";label underline"))
	      (if _gboolean2 (snd-display ";label line wrap"))
	      (if _gboolean3 (snd-display ";label selectable"))
	      (if _gboolean4 (snd-display ";WIDGET TOPLEVEL"))
	      (if (not _gboolean5) (snd-display ";WIDGET NO WINDOW"))
	      (if _gboolean6 (snd-display ";WIDGET REALIZED"))
	      (if _gboolean7 (snd-display ";WIDGET MAPPED"))
	      (if _gboolean8 (snd-display ";WIDGET VISIBLE"))
	      (if _gboolean9 (snd-display ";WIDGET DRAWABLE"))
	      (if (not _gboolean10) (snd-display ";WIDGET SENSITIVE"))
	      (if (not _gboolean11) (snd-display ";WIDGET SENSITIVE"))
	      (if (not _gboolean12) (snd-display ";WIDGET SENSITIVE"))
	      (if _gboolean13 (snd-display ";WIDGET CAN FOCUS"))
	      (if _gboolean14 (snd-display ";WIDGET HAS FOCUS"))
	      (if _gboolean15 (snd-display ";WIDGET CAN DEFAULT"))
	      (if _gboolean16 (snd-display ";WIDGET HAS DEFAULT"))
	      (if _gboolean17 (snd-display ";WIDGET HAS GRAB"))
	      (if _gboolean18 (snd-display ";WIDGET RC STYLE"))
	      (if _gboolean19 (snd-display ";WIDGET COMPOSITE CHILD"))
	      (if _gboolean20 (snd-display ";WIDGET APP PAINTABLE"))
	      (if _gboolean21 (snd-display ";WIDGET RECEIVES DEFAULT"))
	      (if (not _gboolean22) (snd-display ";WIDGET DOUBLE BUFFERED"))
	      (pango_attr_list_ref _PangoAttrList_)
	      (pango_attr_list_unref _PangoAttrList_)
	      (gtk_widget_ref _GtkWidget_)
	      (gtk_widget_unref _GtkWidget_)
	      (gtk_label_set_text _GtkLabel_ "another label")
	      (if (not (string=? (gtk_label_get_text _GtkLabel_) "another label")) (snd-display ";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 ";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 ";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 ";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 ";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 ";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.0 2.0 3.0) type))
		      (lst (c-array->list arr 3)))
		 (if (not (feql lst '(1.0 2.0 3.0)))
		     (snd-display ";~A c-array->list not invertible?: ~A ~A" type arr lst))))
	     (list "gfloat*" "gdouble*"))

	    (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 ";~A c-array->list not invertible?: ~A ~A" type arr lst))))
	     (list "gint*" "guint*" "gint8*" "guint32*" "guint8*" "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 ";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 ";~A c-array->list not invertible?: ~A ~A" type arr lst))))
	     (list "char**" "gchar**"))

	    (let ((_GtkCurve_ (GTK_CURVE (gtk_curve_new))))
	      (gtk_curve_reset _GtkCurve_)
	      (gtk_curve_set_gamma _GtkCurve_ 0.5)
	      (gtk_curve_set_curve_type _GtkCurve_ GTK_CURVE_TYPE_SPLINE)
	      (let ((vect (list->c-array (list 0.0 1.0) "gfloat*")))
		(gtk_curve_set_vector _GtkCurve_ 2 vect)
		(gtk_curve_get_vector _GtkCurve_ 2 vect) ; returns NaNs because the widget isn't actually allocated
		(gtk_curve_set_range _GtkCurve_ 0.0 1.0 0.0 1.0)))

	    (let* ((_GdkRegion_ (gdk_region_new))
		   (_GdkRegion1_ (gdk_region_copy _GdkRegion_))
		   (_GdkRectangle_ (GdkRectangle 0 0 10 10))
		   (x (.x _GdkRectangle_))
		   (y (.y _GdkRectangle_))
		   (width (.width _GdkRectangle_))
		   (height (.height _GdkRectangle_))
		   (_GdkRegion2_ (gdk_region_rectangle _GdkRectangle_))
		   (_gboolean (gdk_region_empty _GdkRegion_))
		   (_gboolean1 (gdk_region_equal _GdkRegion_ _GdkRegion1_))
		   (_GdkOverlapType (gdk_region_rect_in _GdkRegion_ _GdkRectangle_)) ;GDK_OVERLAP_RECTANGLE_IN
		   (_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 ";regions equal?"))
	      (if (or (not (= x 0)) (not (= y 0)) (not (= width 10)) (not (= height 10)))
		  (snd-display ";rectangle accessors: ~A ~A ~A ~A" x y width height))
	      (if (not _gboolean) (snd-display ";region not empty"))
	      (if (not _gboolean1) (snd-display ";region not copied equal"))
	      (if (not _gboolean2) (snd-display ";region no point"))
	      (if (not _gboolean3) (snd-display ";region no intersect"))
	      (if (not (= _GdkOverlapType GDK_OVERLAP_RECTANGLE_OUT)) (snd-display ";rectangle overlap type: ~A" _GdkOverlapType))
	      (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 ";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 ";key name: ~A" _gchar_))
	      (if (not (= _guint 60)) (snd-display ";key from less: ~A" _guint))
	      (if (not (= _guint1 88)) (snd-display ";key to upper: ~A" _guint1))
	      (if (not (= _guint2 97)) (snd-display ";key to lower: ~A" _guint2))
	      (if (not (= _guint32 65)) (snd-display ";key to unicode: ~A" _guint32))
	      (if (not (= _guint3 65)) (snd-display ";key from unicode: ~A" _guint3))
	      (if (not (equal? vals (list 120 88))) (snd-display ";key convert: ~A" vals))
	      (if _gboolean (snd-display ";is upper"))
	      (if _gboolean1 (snd-display ";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 ";entry not visible"))
	      (if (not (= _gunichar 42)) (snd-display ";entry invisible char: ~A" _gunichar))
	      (if (not _gboolean1) (snd-display ";entry no frame"))
	      (if _gboolean2 (snd-display ";entry activates default"))
	      (if (not (= _gint 0)) (snd-display ";max length: ~A" _gint))
	      (if (not (= _gint1 -1)) (snd-display ";width chars: ~A" _gint1))
	      (if (not (= (string-length _gchar_) 0)) (snd-display ";entry text: ~A" _gchar_))
	      (if (fneq _gfloat 0.0) (snd-display ";entry alignment: ~A" _gfloat))
	      (if (not (= _gint2 1)) (snd-display ";completion min key: ~A" _gint2))
	      (if (not (equal? _list (list 4 -8))) (snd-display ";entry layout offsets: ~A" _list))
	      (if _GtkWidget_ (snd-display ";completion get entry: ~A" _GtkWidget_))
	      (if _GtkEntryCompletion1_ (snd-display ";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 ";set entry visible"))
	      (gtk_entry_set_invisible_char _GtkEntry_ 65)
	      (if (not (= (gtk_entry_get_invisible_char _GtkEntry_) 65)) 
		  (snd-display ";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 ";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 ";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 ";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 ";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 ";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 (= _GtkCalendarDisplayOptions (+ GTK_CALENDAR_SHOW_HEADING GTK_CALENDAR_SHOW_DAY_NAMES)))
		  (snd-display ";calendar options: ~A" _GtkCalendarDisplayOptions))
	      (if (not _gboolean) (snd-display ";calendar mark day"))
	      (if (not _gboolean1) (snd-display ";calendar unmark day"))
	      (if (not _gboolean2) (snd-display ";calendar select month"))
	      (gtk_calendar_clear_marks _GtkCalendar_)
	      (gtk_calendar_freeze _GtkCalendar_)
	      (gtk_calendar_thaw _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 ";calendar sez birthday: ~A" vals))))
	    
	    (let* ((_gboolean (gtk_rc_reparse_all))
		   (_GtkRcStyle_ (gtk_rc_style_new))
		   (_GScanner_ (gtk_rc_scanner_new))
		   (_GtkWidget_ (gtk_label_new "hiho"))
		   (_GtkStyle_ (gtk_rc_get_style _GtkWidget_))
		   (_GtkRcStyle1_ (gtk_rc_style_copy _GtkRcStyle_))
		   (_guint (gtk_binding_parse_binding _GScanner_))
		   (_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)))
		   (_guint1 (gtk_rc_parse_color _GScanner_ _GdkColor_))
		   (_gchar_ (gtk_rc_find_module_in_path "hiho"))
		   (_list (gtk_rc_parse_priority _GScanner_))
		   (_list1 (gtk_rc_parse_state _GScanner_)))
	      (gtk_rc_add_default_file "Snd.gtkrc")
	      (gtk_rc_parse "Snd.gtkrc")
	      (gtk_rc_parse_string "widget \"*.preset_button\" style \"reset\"")
	      (gtk_rc_style_ref _GtkRcStyle_)
	      (gtk_rc_style_unref _GtkRcStyle_)
	      (gtk_accel_map_load_scanner _GScanner_))

	    (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 ";set paned position: ~A" _gint))
		(if (not (equal? _GtkWidget_ _GtkWidget4_)) (snd-display ";paned child1: ~A ~A" _GtkWidget_ _GtkWidget4_))
		(if (not (equal? _GtkWidget1_ _GtkWidget5_)) (snd-display ";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 ";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 ";statusbar grip"))
	      (gtk_statusbar_set_has_resize_grip _GtkStatusbar_ #f)
	      (if (gtk_statusbar_get_has_resize_grip _GtkStatusbar_) (snd-display ";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 ";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 ";set icon name: ~A" (gtk_window_get_icon_name _GtkWindow_)))
	      (if (not (gtk_window_get_focus_on_map _GtkWindow_)) (snd-display ";focus on map?"))
	      (gtk_window_set_default_icon_name "hiho")
	      (if (not (= _GdkWindowTypeHint GDK_WINDOW_TYPE_HINT_NORMAL)) (snd-display ";_GdkWindowTypeHint: ~A" _GdkWindowTypeHint))
	      (if _gboolean (snd-display ";gtk window destroy with parent"))
	      (if (not _gboolean1) (snd-display ";gtk window not resizable"))
	      (if (not (= _GdkGravity GDK_GRAVITY_NORTH_WEST)) (snd-display ";window gravity: ~A" _GdkGravity))
	      (if _gboolean2 (snd-display ";gtk window has frame"))
	      (if (not _gboolean3) (snd-display ";gtk window not decorated"))
	      (if _gboolean4 (snd-display ";gtk window modal"))
	      (if (not (= _GdkModifierType GDK_MOD1_MASK)) (snd-display ";_GdkModifierType: ~A" _GdkModifierType))
	      (if (not _gboolean7) (snd-display ";window not focusable"))
	      (if (not (= _GdkWindowType GDK_WINDOW_ROOT)) (snd-display ";root window type: ~A" _GdkWindowType))
	      (if _gboolean10 (snd-display ";window visible"))
	      (if (not _gboolean11) (snd-display ";window not viewable"))
	      (if (not (= _GdkWindowState GDK_WINDOW_STATE_WITHDRAWN)) (snd-display ";window state: ~A" _GdkWindowState))
	      (if (not (equal? (list 1 0 0) _list1)) (snd-display ";window get origin: ~A" _list1))
	      (if (not (equal? (list 0 0 1600 1200 24) _list3)) (snd-display ";window geometry: ~A" _list3))
	      (if (not (equal? (list -1 -1) _list4)) (snd-display ";window default size: ~A" _list4))
	      (if (not (equal? (list 0 0 0 0) _list6)) (snd-display ";window frame: ~A" _list6))
	      (if (not (equal? (list 0 0) _list7)) (snd-display ";window get root origin: ~A" _list7))
	      (if (not (equal? (list 0 0) _list8)) (snd-display ";window get position: ~A" _list8))
	      
	      (gdk_window_set_user_data _GdkWindow_ (GPOINTER (list 'int 123)))
	      (let ((data (gdk_window_get_user_data _GdkWindow_)))
		(if (not (= (cadar data) 123)) (snd-display ";set window user data: ~A" data)))
	      
	      (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 ";gtk_window_get_title: ~A?" title)))
	      
	      (gtk_window_present _GtkWindow_)
	      (gtk_window_deiconify _GtkWindow_)
	      (gtk_window_unmaximize _GtkWindow_)
	      (gtk_window_move _GtkWindow_ 200 20)
	      (let ((_list (gtk_window_get_position _GtkWindow_)))
		(if (not (equal? _list (list 200 20))) (snd-display ";gtk_window_move: ~A" _list)))
	      (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 ";progress text: ~A" _gchar_))
	      (if (fneq _gdouble 0.0) (snd-display ";progress fraction: ~A" _gdouble))
	      (if (fneq _gdouble1 0.1) (snd-display ";progress step: ~A" _gdouble1))
	      (if (not (= _GtkProgressBarOrientation 0)) (snd-display ";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 ";set progress text: ~A" _gchar_))
	      (if (fneq _gdouble 0.25) (snd-display ";set progress fraction: ~A" _gdouble))
	      (if (fneq _gdouble1 0.2) (snd-display ";set progress step: ~A" _gdouble1))
	      (if (not (= _GtkProgressBarOrientation GTK_PROGRESS_RIGHT_TO_LEFT)) (snd-display ";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 ";adjust init: ~A" _gdouble))
	      (if _gboolean (snd-display ";range invert"))
	      (if (fneq _gdouble1 0.0) (snd-display ";range init: ~A" _gdouble1))
	      (if (not _gboolean1) (snd-display ";scale not drawn"))
	      (if (not (= 1 _gint)) (snd-display ";scale init digits: ~A" _gint))
	      (if (not (= _GtkPositionType 2)) (snd-display ";scale init pos: ~A" _GtkPositionType))
	      (if (not (equal? _list (list -20 -20))) (snd-display ";layout offsets: ~A" _list))
	      (if (not (equal? _list1 (list 100 100))) (snd-display ";layout size: ~A" _list1))
	      (if (not (equal? _GtkAdjustment2_ _GtkAdjustment_)) (snd-display ";layout hadj: ~A ~A" _GtkAdjustment2_ _GtkAdjustment_))
	      (if (not (= _GtkUpdateType GTK_UPDATE_CONTINUOUS)) (snd-display ";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 ";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 ";set range invert"))
	      (gtk_range_set_value _GtkRange_ 0.5)
	      (set! _gdouble1 (gtk_range_get_value _GtkRange_))
	      (if (fneq _gdouble1 0.5) (snd-display ";set range val: ~A" _gdouble1))
	      (gtk_scale_set_digits _GtkScale_ 2)
	      (set! _gint (gtk_scale_get_digits _GtkScale_))
	      (if (not (= 2 _gint)) (snd-display ";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 ";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 ";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 ";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 ";spin button get adj: ~A ~A" _GtkAdjustment_ _GtkAdjustment1_))
	      (if (not (= _guint 0)) (snd-display ";spin digits: ~A" _guint))
	      (if (fneq _gdouble 0.0) (snd-display ";spin init: ~A" _gdouble))
	      (if (not (= _GtkSpinButtonUpdatePolicy GTK_UPDATE_ALWAYS)) (snd-display ";spin update: ~A" _GtkSpinButtonUpdatePolicy))
	      (if (not (= _gint 0)) (snd-display ";spin val as int: ~A" _gint))
	      (if (not _gboolean) (snd-display ";spin not numeric"))
	      (if _gboolean1 (snd-display ";spin wraps"))
	      (if _gboolean2 (snd-display ";spin snaps"))
	      (if (not (feql _list (list 1.0 10.0))) (snd-display ";spin incr: ~A" _list))
	      (if (not (feql _list1 (list 0.0 20.0))) (snd-display ";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 ";set spin digits: ~A" _guint))
	      (if (not (= _GtkSpinButtonUpdatePolicy GTK_UPDATE_ALWAYS)) (snd-display ";set spin update: ~A" _GtkSpinButtonUpdatePolicy))
	      (if (not _gboolean) (snd-display ";set spin not numeric"))
	      (if _gboolean1 (snd-display ";set spin wraps"))
	      (if _gboolean2 (snd-display ";set spin snaps"))
	      (if (not (feql _list1 (list 0.0 1.0))) (snd-display ";set spin range: ~A" _list1)))
	    
	    (let* ((_GtkTooltips_ (gtk_tooltips_new))
		   (_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))
		   (_gboolean (gtk_toolbar_get_tooltips _GtkToolbar_))
		   (_GtkTooltipsData_ (gtk_tooltips_data_get _GtkWidget_))
		   (_list (gtk_tooltips_get_info_from_tip_window _GtkWindow_))
		   (_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 _gboolean) (snd-display ";toolbar not tooltips"))
	      (if (not (equal? _list (list #f #f #f))) (snd-display ";tooltips from window: ~A" _list))
	      (if (not (= _GtkOrientation 0)) (snd-display ";tooltips orientation: ~A" _GtkOrientation))
	      (if (not (= _GtkToolbarStyle 2)) (snd-display ";toolbar style: ~A" _GtkToolbarStyle))
	      (if (not (= _GtkIconSize 3)) (snd-display ";toolbar icon size: ~A" _GtkIconSize))
	      (if (not (= _gint 0)) (snd-display ";toolbar items: ~A" _gint))
	      (if (not _gboolean1) (snd-display ";toolbar no arrow"))
	      (if (not (= _GtkReliefStyle 2)) (snd-display ";toolbar relief: ~A" _GtkReliefStyle))
	      (if _gboolean2 (snd-display ";toolbar underlined"))
	      (if (not (string=? _gchar1_ "gtk-cancel")) (snd-display ";tool button stock: ~A" _gchar1_))
	      (if _gboolean3 (snd-display ";tool item homogenous"))
	      (if _gboolean4 (snd-display ";tool item expands"))
	      (if _gboolean5 (snd-display ";tool item drags"))
	      (if (not _gboolean6) (snd-display ";tool item not visible horizontal"))
	      (if (not _gboolean7) (snd-display ";tool item not visible vertical"))
	      (if _gboolean8 (snd-display ";tool item important"))
	      (if (not (= _GtkIconSize1 3)) (snd-display ";tool item icon size: ~A" _GtkIconSize1))
	      (if (not (= _GtkOrientation1 0)) (snd-display ";tool item orientation: ~A" _GtkOrientation1))
	      (if (not (= _GtkToolbarStyle1 0)) (snd-display ";tool item style: ~A" _GtkToolbarStyle1))
	      (if (not (= _GtkReliefStyle1 2)) (snd-display ";tool item relief: ~A" _GtkReliefStyle))
	      
	      (gtk_radio_tool_button_set_group _GtkRadioToolButton_ #f)
	      (gtk_toggle_tool_button_set_active _GtkToggleToolButton_ #t)
	      (gtk_tooltips_enable _GtkTooltips_)
	      (gtk_tooltips_disable _GtkTooltips_)
	      (gtk_tooltips_force_window _GtkTooltips_)
	      (gtk_toolbar_set_tooltips _GtkToolbar_ #t)
	      (gtk_tooltips_set_tip _GtkTooltips_ _GtkWidget_ "hi" "ho")
	      (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)
	      (gtk_tool_item_set_tooltip _GtkToolItem_ _GtkTooltips_ "hi" "ho"))

	    (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 ";table row def: ~A" _guint))
	      (if (not (= _guint1 0)) (snd-display ";table col def: ~A" _guint1))
	      (if (not (= _guint2 0)) (snd-display ";table row: ~A" _guint2))
	      (if (not (= _guint3 0)) (snd-display ";table col: ~A" _guint3))
	      (if (not _gboolean) (snd-display ";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 (= _guint 10)) (snd-display ";set table row def: ~A" _guint))
	      (if (not (= _guint1 10)) (snd-display ";set table col def: ~A" _guint1))
	      (if (not (= _guint2 2)) (snd-display ";set table row: ~A" _guint2))
	      (if (not (= _guint3 3)) (snd-display ";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 ";notebook page: ~A" _gint))
	      (if (not (= _gint1 -1)) (snd-display ";notebook current page: ~A" _gint1))
	      (if (not _gboolean) (snd-display ";notebook no border"))
	      (if (not _gboolean1) (snd-display ";notebook no show tabs"))
	      (if (not (= _GtkPositionType 2)) (snd-display ";notebook tab pos: ~A" _GtkPositionType))
	      (if _gboolean2 (snd-display ";notebook scrollable"))
	      (if (not (= _int 1)) (snd-display ";notebook pages: ~A" _int))
	      (if (not (equal? _GtkWidget_ page)) (snd-display ";notebook page widget: ~A ~A" _GtkWidget_ page))
	      (if (not (= _gint2 0)) (snd-display ";notebook page num: ~A" _gint2))
	      (if (not (string=? _gchar_ "ho")) (snd-display ";notebook tab label: ~A" _gchar_))
	      (if (not (= _gint3 0)) (snd-display ";notebook prepend to: ~A" _gint3))
	      (if (not (= _gint6 1)) (snd-display ";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 ";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_ (gtk_widget_ref _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_))
		   (_GdkExtensionMode (gtk_widget_get_extension_events _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 ";gtk widget default dir: ~A" _GtkTextDirection))
	      (if _gboolean (snd-display ";gtk widget activated"))
	      (if _gboolean1 (snd-display ";gtk widget focussed"))
	      (if (not (string=? _gchar_ "GtkWindow")) (snd-display ";gtk widget name: ~A" _gchar_))
	      (if (not _gboolean2) (snd-display ";gtk widget child not visible"))
	      (if (not (= _gint 65536)) (snd-display ";gtk widget events: ~A" _gint))
	      (if (not (= _GtkTextDirection1 1)) (snd-display ";gtk widget get dir: ~A" _GtkTextDirection1))  
	      (if (not _gboolean4) (snd-display ";gtk widget no screen"))
	      (if _gboolean5 (snd-display ";gtk widget show all"))
	      (if (not _gboolean8) (snd-display ";gtk widget child not focussed"))
	      (if _gboolean9 (snd-display ";gtk widget ancestor shell"))
	      (if (not _gboolean11) (snd-display ";gtk widget no intersect"))
	      (if (not (equal? vals (list -1 -1))) (snd-display ";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_unref _GtkWidget1_)
	      (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 ";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 ";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 ";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 ";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 ";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))
		   (_GtkFileChooserAction (gtk_file_chooser_get_action _GtkFileChooser_))
		   (_gboolean4 (gtk_file_chooser_get_local_only _GtkFileChooser_))
		   (_gboolean5 (gtk_file_chooser_get_select_multiple _GtkFileChooser_))
		   (_gchar_5 (gtk_file_chooser_get_filename _GtkFileChooser_))
		   (_GSList_ (gtk_file_chooser_get_filenames _GtkFileChooser_))
		   (_gchar_6 (gtk_file_chooser_get_current_folder _GtkFileChooser_))
		   (_gchar_7 (gtk_file_chooser_get_uri _GtkFileChooser_))
		   (_GSList1_ (gtk_file_chooser_get_uris _GtkFileChooser_))
		   (_gchar_8 (gtk_file_chooser_get_current_folder_uri _GtkFileChooser_))
		   (_GtkWidget_2 (gtk_file_chooser_get_preview_widget _GtkFileChooser_))
		   (_gboolean6 (gtk_file_chooser_get_preview_widget_active _GtkFileChooser_))
		   (_char_ (gtk_file_chooser_get_preview_filename _GtkFileChooser_))
		   (_char_1 (gtk_file_chooser_get_preview_uri _GtkFileChooser_))
		   (_GtkWidget_3 (gtk_file_chooser_get_extra_widget _GtkFileChooser_))
		   (_GSList2_ (gtk_file_chooser_list_filters _GtkFileChooser_))
		   (_GtkFileFilter1_ (gtk_file_chooser_get_filter _GtkFileChooser_))
		   (_GSList3_ (gtk_file_chooser_list_shortcut_folders _GtkFileChooser_))
		   (_GSList4_ (gtk_file_chooser_list_shortcut_folder_uris _GtkFileChooser_))
		   (_gboolean7 (gtk_file_chooser_get_use_preview_label _GtkFileChooser_))
		   (_gchar_9 (gtk_file_selection_get_filename _GtkFileSelection_))
		   (_gboolean8 (gtk_file_selection_get_select_multiple _GtkFileSelection_)))
	      (if (not _gboolean) (snd-display ";dialog opacity"))
	      (if _gboolean1 (snd-display ";dialog palette"))
	      (if (not (= _guint16 65535)) (snd-display ";dialog alpha: ~A" _guint16))
	      (if (not (= _guint161 65535)) (snd-display ";dialog prev alpha: ~A" _guint161))
	      (if _gboolean2 (snd-display ";dialog adjusting"))
	      (if (not (string=? _gchar_1 "Sans 10")) (snd-display ";dialog font: ~A" _gchar_1))
	      (if (> (string-length _gchar_2) 0) (snd-display ";dialog preview: ~A" _gchar_2))
	      (if (not (string=? _gchar_3 "Sans 12")) (snd-display ";dialog font: ~A" _gchar_3))
	      (if (not (string=? _gchar_4 "abcdefghijk ABCDEFGHIJK")) (snd-display ";dialog preview text: ~A" _gchar_4))
	      (if (not _gboolean3) (snd-display ";dialog no sep"))
	      (if (not (= _GtkFileChooserAction 0)) (snd-display ";dialog action: ~A" _GtkFileChooserAction))
	      (if (not _gboolean4) (snd-display ";dialog not local"))
	      (if _gboolean5 (snd-display ";dialog sel mult"))
	      (if _gchar_5 (snd-display ";dialog filename: ~A" _gchar_5))
	      (if (not (string=? _gchar_6 "/home/bil/cl")) (snd-display ";dialog folder: ~A" _gchar_6))
	      (if _gchar_7 (snd-display ";dialog uri: ~A" _gchar_7))
	      (if (not (string=? _gchar_8 "file:///home/bil/cl")) (snd-display ";dialog folder uri: ~A" _gchar_8))
	      (if (not _gboolean6) (snd-display ";dialog not active"))
	      (if (not _gboolean7) (snd-display ";dialog not use preview"))
	      (if (not (string=? _gchar_9 "/home/bil/cl")) (snd-display ";dialog sel filename: ~A" _gchar_9))
	      (if _gboolean8 (snd-display ";dialog has sel mult"))
	      (gtk_file_selection_show_fileop_buttons _GtkFileSelection_)
	      (gtk_file_selection_hide_fileop_buttons _GtkFileSelection_)
	      (gtk_dialog_set_has_separator _GtkDialog_ #t)
	      (gtk_file_selection_set_filename _GtkFileSelection_ "/home/bil/cl/test.snd")
	      (set! _gchar_9 (gtk_file_selection_get_filename _GtkFileSelection_))
	      (if (not (string=? _gchar_9 "/home/bil/cl/test.snd")) (snd-display ";set dialog filename: ~A" _gchar_9))
	      (gtk_file_chooser_set_filename _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (let ((_gboolean (gtk_file_chooser_set_current_folder _GtkFileChooser_ "/home/bil/sf1")))
		(set! _gchar_6 (gtk_file_chooser_get_current_folder _GtkFileChooser_))
		(if (not (string=? _gchar_6 "/home/bil/sf1")) (snd-display ";set dialog chooser folder: ~A" _gchar_6)))
	      (gtk_font_selection_set_font_name _GtkFontSelection_ "Monospace 10")
	      (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_file_chooser_select_all _GtkFileChooser_)
	      (gtk_file_chooser_unselect_all _GtkFileChooser_)
	      (gtk_font_selection_set_preview_text _GtkFontSelection_ "preview")
	      (gtk_font_selection_dialog_set_preview_text _GtkFontSelectionDialog_ "text")
	      (gtk_color_selection_set_has_opacity_control _GtkColorSelection_ #t)
	      (gtk_file_chooser_set_action _GtkFileChooser_ GTK_FILE_CHOOSER_ACTION_SAVE)
	      (gtk_file_chooser_set_local_only _GtkFileChooser_ #t)
	      (gtk_file_chooser_add_filter _GtkFileChooser_ _GtkFileFilter_)
	      (gtk_file_chooser_remove_filter _GtkFileChooser_ _GtkFileFilter_)
	      (gtk_file_chooser_set_filter _GtkFileChooser_ (gtk_file_filter_new))
	      (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_file_selection_complete _GtkFileSelection_ "/home/bil/cl/test.sn")
	      (gtk_file_chooser_select_filename _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (gtk_file_chooser_set_uri _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (gtk_file_chooser_select_uri _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (gtk_file_chooser_set_current_folder_uri _GtkFileChooser_ "/home/bil/cl")
;	      (gtk_file_filter_get_name _GtkFileFilter_)
	      (gtk_file_filter_get_needed _GtkFileFilter_)
	      (gtk_font_selection_dialog_set_font_name _GtkFontSelectionDialog_ "Monospace 10")
	      (gtk_dialog_add_buttons _GtkDialog_ (list GTK_STOCK_CANCEL GTK_RESPONSE_REJECT))
	      (gtk_file_chooser_set_select_multiple _GtkFileChooser_ #f)
	      (gtk_file_chooser_set_current_name _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (gtk_file_chooser_unselect_filename _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (gtk_file_chooser_unselect_uri _GtkFileChooser_ "/home/bil/cl/test.snd")
	      (gtk_file_chooser_set_preview_widget _GtkFileChooser_ (gtk_label_new "preview"))
	      (gtk_file_chooser_set_preview_widget_active _GtkFileChooser_ #f)
	      (gtk_file_chooser_set_extra_widget _GtkFileChooser_ (gtk_label_new "hiho"))
	      (gtk_file_chooser_set_use_preview_label _GtkFileChooser_ #f)
	      (gtk_file_filter_set_name _GtkFileFilter_ "title")
	      (gtk_file_filter_add_mime_type _GtkFileFilter_ "base64")
	      (gtk_file_filter_add_pattern _GtkFileFilter_ "*.snd")
	      (gtk_file_selection_set_select_multiple _GtkFileSelection_ #f)
	      (gtk_dialog_set_response_sensitive _GtkDialog_ 0 #f)
	      (let ((vals (gtk_file_chooser_add_shortcut_folder _GtkFileChooser_ "/home/bil/cl")))
		(if (not (equal? vals (list #t #f))) (snd-display ";add shortcut: ~A" vals)))
	      (let ((vals (gtk_file_chooser_remove_shortcut_folder _GtkFileChooser_ "/home/bil/cl")))
		(if (not (equal? vals (list #t #f))) (snd-display ";remove shortcut: ~A" vals)))
	      (gtk_file_chooser_add_shortcut_folder_uri _GtkFileChooser_ "/home/bil/cl")
	      (gtk_file_chooser_remove_shortcut_folder_uri _GtkFileChooser_ "/home/bil/cl")
	      (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 ";gtkactions: ~A ~A" _GtkAction_ _GtkAction_1)))
	      (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/bil/cl" "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)))
		   (_gboolean (gtk_fixed_get_has_window _GtkFixed_)))
	      (gtk_fixed_set_has_window _GtkFixed_ #f)
	      (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 (list 'int 123)))
		(let ((_gpointer1 (g_object_get_data (G_OBJECT _GtkFixed_) "hiho")))
		  (if (not (= (cadr _gpointer1) 123)) (snd-display ";object data: ~A" _gpointer1)))
		(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 ";iter text buffer: ~A ~A" _GtkTextBuffer_ _GtkTextBuffer_1))
		  (if (not (equal? _GtkTextBuffer_ _GtkTextBuffer_3)) (snd-display ";view text buffer: ~A ~A" _GtkTextBuffer_ _GtkTextBuffer_3))
		  (if (not (equal? _GtkTextBuffer_1 _GtkTextBuffer_2)) (snd-display ";mark text buffer: ~A ~A" _GtkTextBuffer_1 _GtkTextBuffer_2))
		  (if (not (equal? _GtkTextTag_1 _GtkTextTag_2)) (snd-display ";view text tag: ~A ~A" _GtkTextTag_1 _GtkTextTag_2))
		  (if (not (= _gint 1)) (snd-display ";text lines: ~A" _gint))
		  (if (not (= _gint1 5)) (snd-display ";text chars: ~A" _gint1))
		  (if (not (= _gint2 5)) (snd-display ";text iter offset:~A" _gint2))
		  (if (not (= _gint3 0)) (snd-display ";text iter line:~A" _gint3))
		  (if (not (= _gint4 5)) (snd-display ";text iter line offset:~A" _gint4))
		  (if (not (= _gint5 7)) (snd-display ";text iter index:~A" _gint5))
		  (if (not (= _gint6 5)) (snd-display ";text vis line offset:~A" _gint6))
		  (if (not (= _gint7 7)) (snd-display ";text vis line index:~A" _gint7))
		  (if (not (= _gint8 5)) (snd-display ";text chars in line:~A" _gint8))
		  (if (not (= _gint9 7)) (snd-display ";text bytes in line:~A" _gint9))
		  (if (not (= _gint10 0)) (snd-display ";text priority:~A" _gint10))
		  (if (not (= _gint11 1)) (snd-display ";text table size:~A" _gint11))
		  (if (not (= _gint12 0)) (snd-display ";text left margin:~A" _gint12))
		  (if (not (= _gint13 0)) (snd-display ";text right margin:~A" _gint13))
		  (if (not (= _gint14 0)) (snd-display ";text indent:~A" _gint14))
		  (if (not (= _gint15 0)) (snd-display ";text above:~A" _gint15))
		  (if (not (= _gint16 0)) (snd-display ";text below:~A" _gint16))
		  (if (not (= _gint17 0)) (snd-display ";text inside:~A" _gint17))
		  (if (not (= _gint18 0)) (snd-display ";text iter compare:~A" _gint18))
		  (if (not (eq? _gboolean #t)) (snd-display ";text modified"))
		  (if (not (eq? _gboolean1 #f)) (snd-display ";text starts word"))
		  (if (not (eq? _gboolean2 #f)) (snd-display ";text ends word"))
		  (if (not (eq? _gboolean3 #f)) (snd-display ";text inside word"))
		  (if (not (eq? _gboolean4 #f)) (snd-display ";text starts sentence"))
		  (if (not (eq? _gboolean5 #t)) (snd-display ";text ends sentence"))
		  (if (not (eq? _gboolean6 #f)) (snd-display ";text inside sentence"))
		  (if (not (eq? _gboolean7 #f)) (snd-display ";text starts line"))
		  (if (not (eq? _gboolean8 #t)) (snd-display ";text ends line"))
		  (if (not (eq? _gboolean9 #t)) (snd-display ";text is cursor"))
		  (if (not (eq? _gboolean10 #t)) (snd-display ";text is end"))
		  (if (not (eq? _gboolean11 #f)) (snd-display ";text is start"))
		  (if (not (eq? _gboolean12 #t)) (snd-display ";text editable"))
		  (if (not (eq? _gboolean13 #f)) (snd-display ";text overwrite"))
		  (if (not (eq? _gboolean14 #t)) (snd-display ";text tabs"))
		  (if (not (eq? _gboolean15 #t)) (snd-display ";text iters equal"))
		  (if (not (eq? _gboolean16 #f)) (snd-display ";text begins tag"))
		  (if (not (eq? _gboolean17 #f)) (snd-display ";text ends tag"))
		  (if (not (eq? _gboolean18 #f)) (snd-display ";text toggles tag"))
		  (if (not (eq? _gboolean19 #f)) (snd-display ";text has attr"))
		  (if (not (eq? _gboolean20 #f)) (snd-display ";text get attr"))
		  (if (not (eq? _gboolean21 #f)) (snd-display ";text mark get visible"))
		  (if (not (eq? _gunichar 0)) (snd-display ";text iter char"))
		  (if (not (string=? _char_ "mark-name")) (snd-display ";text mark name: ~A" _char_))
		  (if (not (= _GtkWrapMode 0)) (snd-display ";text wrap: ~A" _gtkWrapMode))
		  (if (not (= _GtkJustification 0)) (snd-display ";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 ";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 ";event box visible"))
		(if _gboolean1 (snd-display ";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 ";font button title: ~A" _gchar_))
		(if (not _gboolean) (snd-display ";font button use font"))
		(if _gboolean1 (snd-display ";font button use size"))
		(if (not (string=? _gchar_1 "Monospace 10")) (snd-display ";font button font: ~A" _gchar_1))
		(if _gboolean2 (snd-display ";font button style"))
		(if _gboolean3 (snd-display ";font button size"))
		(if (not (= _guint16 12345)) (snd-display ";color button alpha: ~A" _guint16))
		(if _gboolean4 (snd-display ";color button alpha"))
		(if (not (string=? _gchar_2 "hi")) (snd-display ";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 ";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 ";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 ";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 ";scrolled policy: ~A" vals))
		(if (not (= _GtkCornerType 0)) (snd-display ";scrolled placement :~A" _GtkCornerType))
		(if (not (= _GtkShadowType 1)) (snd-display ";scrolled shadow :~A" _GtkShadowType))
		(if (not (= _gint 0)) (snd-display ";tree col fix wid:~A" _gint))
		(if (not (= _gint1 -1)) (snd-display ";tree col max wid:~A" _gint1))
		(if (not (= _gint2 -1)) (snd-display ";tree col min wid :~A" _gint2))
		(if (not (= _gint3 -1)) (snd-display ";tree col sort id:~A" _gint3))
		(if (not (= _gint4 0)) (snd-display ";tree col spacing:~A" _gint4))
		(if (not (= _gint5 0)) (snd-display ";tree col wid:~A" _gint5))
		(if (not (= _gint6 0)) (snd-display ";tree view col:~A" _gint6))
		(if (not (= _gint7 1)) (snd-display ";tree model n col:~A" _gint7))
		(if (not (= _GtkTreeModelFlags 3)) (snd-display ";tree mode flags:~A" _GtkTreeModelFlags))
		(if (not (= _GtkSortType 0)) (snd-display ";tree view sort:~A" _GtkSortType))
		(if (not (eq? _gboolean #f)) (snd-display ";tree col click:~A" _gboolean))
		(if (not (eq? _gboolean1 #f)) (snd-display ";tree col expand:~A" _gboolean1))
		(if (not (eq? _gboolean2 #f)) (snd-display ";tree col reorder:~A" _gboolean2))
		(if (not (eq? _gboolean3 #f)) (snd-display ";tree col resize:~A" _gboolean3))
		(if (not (eq? _gboolean4 #f)) (snd-display ";tree col sort:~A" _gboolean4))
		(if (not (eq? _gboolean5 #t)) (snd-display ";tree col vis:~A" _gboolean5))
		(if (not (eq? _gboolean6 #t)) (snd-display ";tree view search:~A" _gboolean6))
		(if (not (eq? _gboolean7 #t)) (snd-display ";tree view vis:~A" _gboolean7))
		(if (not (eq? _gboolean8 #f)) (snd-display ";tree view reorder:~A" _gboolean8))
		(if (not (eq? _gboolean9 #f)) (snd-display ";tree view hint:~A" _gboolean9))
		(if (not (string=? _gchar_ "hiho")) (snd-display ";tree col title:~A" _gchar_))
		(if (fneq _gfloat 0.0) (snd-display ";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 ";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_))
		       (_GList_ (gtk_tree_view_column_get_cell_renderers _GtkTreeViewColumn_))
		       (_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 ";tree path: ~S" _gchar_))
		  (if (not (string=? _gchar_1 "0")) (snd-display ";tree model iter path: ~S" _gchar_1))
		  (if (not (= _gint 1)) (snd-display ";tree path depth: ~A" _gint))
		  (if (not (equal? _gint_ (list 0))) (snd-display ";tree path indices: ~A" _gint_))
		  (if (not (equal? _GtkTreeModel_ _GtkTreeModel_5)) (snd-display ";tree model filter get model: ~A ~A" _GtkTreeModel_ _GtkTreeModel_5))
		  (if (not (equal? _GtkTreeModel_ _GtkTreeModel_6)) (snd-display ";tree model sort get model: ~A ~A" _GtkTreeModel_ _GtkTreeModel_6))
		  (if (not (equal? vals (list 10 10))) (snd-display ";cell renderer fixed size: ~A" vals))
		  (if (not (= _GType G_TYPE_STRING)) (snd-display ";tree model col type: ~A" _GType))
		  (if (not (equal? _GtkTreeView_ _GtkTreeView_3)) (snd-display ";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 ";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 ";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 ";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 ";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 ";tree path copy is ancestor"))
		    (if _gboolean11 (snd-display ";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 ";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)
	      (if (not (string=? icon-name "glade-2")) (snd-display ";icon name: ~A" icon-name))
	      (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/bil/cl")
	      (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 ";box not homogenous"))
	      (if (not (= _gint 0)) (snd-display ";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 ";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_WIDGET_SET_FLAGS _GtkWidget_ 0)
	      (GTK_WIDGET_UNSET_FLAGS _GtkWidget_ 0)
	      (GTK_OBJECT_SET_FLAGS (GTK_OBJECT _GtkWidget_) 0)
	      (GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT _GtkWidget_) 0))
	    
	    (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 ";menu item active"))
	      (if _gboolean1 (snd-display ";menu item radio"))
	      (if _gboolean2 (snd-display ";menu item inconsistent"))
	      (if _gboolean3 (snd-display ";menu item tearoff"))
	      (if _gboolean4 (snd-display ";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 ";accel width: ~A" _guint))
		(if (not (= _guint1 13)) (snd-display ";accel mod mask: ~A" _guint1))
		(if (not (string=? _gchar_ "title")) (snd-display ";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 "/home/bil/cl/accelmap")
	      (gtk_accel_map_load "/home/bil/cl/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 ";accelerator not valid"))
		(if (not (string=? _gchar_ "<Alt>c")) (snd-display ";accelerator name: ~A" _gchar_))
		(if (not (equal? vals (list 0 0))) (snd-display ";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_menu_item_remove_submenu _GtkMenuItem_)
	      (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"))
		   (_char_ (GTK_OBJECT_TYPE_NAME (GTK_OBJECT label)))
		   (_gboolean (GTK_IS_RESIZE_CONTAINER (GTK_WIDGET label)))
		   (_gboolean1 (GTK_OBJECT_FLOATING (GTK_OBJECT label)))
		   (_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 (not (string=? _char_ "GtkLabel")) (snd-display ";label type name: ~A" _char_))
	      (if _gboolean (snd-display ";label is resize container"))
	      (if (not _gboolean1) (snd-display ";label is not floating"))
	      (if (not _gboolean2) (snd-display ";editable not editable"))
	      (if _gboolean3 (snd-display ";expander expanded"))
	      (if _gboolean4 (snd-display ";expander use markup"))
	      (if _gboolean5 (snd-display ";expander use underline"))
	      (if (not (string=? "hi" _gchar_)) (snd-display ";expander name: ~A" _gchar_))
	      (if (not (= _gint 0)) (snd-display ";expander spacing: ~A" _gint))
	      (if (not (= _gint1 0)) (snd-display ";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 ";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 ";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 ";font descr familt: ~A" _char_))
		  (if (not (= _PangoStretch PANGO_STRETCH_NORMAL)) (snd-display ";font descr stretch: ~A" _PangoStretch))
		  (if (not (= _PangoStyle PANGO_STYLE_NORMAL)) (snd-display ";font descr style: ~A" _PangoStyle))
		  (if (not (= _PangoWeight PANGO_WEIGHT_NORMAL)) (snd-display ";font descr weight: ~A" _PangoWeight))
		  (if (not (= _PangoVariant PANGO_VARIANT_NORMAL)) (snd-display ";font descr variant: ~A" _PangoVariant))
		  (if (not (= _PangoAlignment PANGO_ALIGN_LEFT)) (snd-display ";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_))
			 (_PangoAttribute_1 (pango_attribute_copy _PangoAttribute_))
			 (_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_))
			 (_GList_1 (pango_reorder_items _GList_)))
		    (pango_glyph_string_set_size _PangoGlyphString_ 10)
		    (pango_glyph_string_extents _PangoGlyphString_ _PangoFont_ _PangoRectangle_1 _PangoRectangle_2)
		    (gdk_pango_context_set_colormap _PangoContext_ (gdk_colormap_get_system))
		    (pango_font_description_unset_fields _PangoFontDescription_ _PangoFontMask)
		    (pango_layout_context_changed _PangoLayout_)
		    (pango_layout_line_ref _PangoLayoutLine_)
		    (pango_layout_line_unref _PangoLayoutLine_)
		    (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)))))
	    
	    (let* ((gc (car (snd-gcs)))
		   (_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 (.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 (.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 ";g quark/string: ~A ~A" hi (g_quark_to_string hi)))
	      (if (not _gboolean) (snd-display ";gdk colors copy not equal"))
	      (if (not (string=? _gchar_ "SECONDARY")) (snd-display ";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)
	      (gdk_draw_rectangle wn gc #t 0 0 100 100)
	      (gdk_draw_line wn gc 0 0 100 100)
	      (gdk_draw_point wn gc 10 10)
	      (gdk_draw_arc wn gc #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 gc (list 'GdkPoint_ pts1) 2)
	      (gdk_draw_segments wn gc (list 'GdkSegment_ pts1) 1)
	      (gdk_draw_points wn gc (list 'GdkPoint_ pts1) 2)
	      (gdk_draw_polygon wn gc #f (list 'GdkPoint_ pts1) 2)
	      (freeGdkPoints pts1)
	      (gdk_drawable_set_colormap wn (gdk_colormap_get_system))
	      (gdk_draw_layout wn gc 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
		       (_GdkPixbufLoader_ (gdk_pixbuf_loader_new))
		       (_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 (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 (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")))
		  (gdk_draw_image wn gc _GdkImage_1 0 0 0 0 32 32)
		  (gdk_draw_drawable wn gc (GDK_DRAWABLE _GdkPixmap_1) 0 0 0 0 32 32)
		  (gdk_draw_gray_image wn gc 0 0 10 10 GDK_RGB_DITHER_NONE "hihohohio" 0)
		  (gdk_draw_rgb_image wn gc 0 0 10 10 GDK_RGB_DITHER_NONE "hihohohio" 0)
		  (gdk_draw_rgb_32_image wn gc 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 gc 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 (.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 ";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 ";about dialog isn't?"))
	      (gtk_about_dialog_set_name (GTK_ABOUT_DIALOG dialog) "About Dialog")
	      (let ((name (gtk_about_dialog_get_name (GTK_ABOUT_DIALOG dialog))))
		(if (not (string=? name "About Dialog")) (snd-display ";about dialog name: ~A" name)))
	      (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 ";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 ";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 ";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 ";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 ";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 ";about dialog website_label: ~A" website_label)))
	      (gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG dialog) (list->c-array (list "Who" "Why") "gchar**"))
	      (let ((authors (c-array->list (gtk_about_dialog_get_name (GTK_ABOUT_DIALOG dialog)) 2)))
		(if (and (list? authors)
			 (string? (car authors))
			 (not (string=? (car authors) "Who Else?")))
		    (snd-display ";about dialog authors: ~A" authors)))
	      (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 ";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 ";about dialog artists: ~A" artists)))
	      (gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG dialog) "he did it all")
	      (let ((translator_credits (gtk_about_dialog_get_name (GTK_ABOUT_DIALOG dialog))))
		;; oops...
		(if (and (string? translator_credits)
			 (not (string=? translator_credits "he did it all")))
		    (snd-display ";about dialog translator_credits: ~A" translator_credits)))
	      (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 ";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 ";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 ";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 ";icon view cols: ~A ~A" gint0 gint1)))
			    (let ((ic (gtk_icon_view_new)))
			      (if (not (GTK_IS_ICON_VIEW ic)) (snd-display ";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 ";icon view orientation")))
			    (let ((model (gtk_icon_view_get_model (GTK_ICON_VIEW icon_view))))
			      (if (not (GTK_TREE_MODEL model)) (snd-display ";icon view model: ~A (~A)" model store))
			      (gtk_icon_view_set_model (GTK_ICON_VIEW icon_view) (GTK_TREE_MODEL store)))
			    (let ((type (gtk_icon_view_get_type)))
			      (if (not (number? type)) (snd-display ";icon view type: ~A" type)))
			    (let ((gint0 (gtk_icon_view_get_markup_column (GTK_ICON_VIEW icon_view))))
			      (if (not (= gint0 -1)) (snd-display ";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 ";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 (number? (gtk_cell_view_get_type))) (snd-display ";cell view type"))
		(if (not (GTK_IS_CELL_VIEW cell1)) (snd-display ";not cell view? ~A" cell1))
		(gtk_cell_view_set_model (GTK_CELL_VIEW cell1) (GTK_TREE_MODEL store))
		(gtk_cell_view_set_background_color (GTK_CELL_VIEW cell1) (basic-color))
					;(gtk_cell_view_set_cell_data (GTK_CELL_VIEW cell1)) ; what the hell?
		(gtk_cell_view_get_cell_renderers (GTK_CELL_VIEW cell1))))

	    (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 (not (= int0 -1024)) (not (= int1 1024)) (not (= int2 3072)) (not (= int3 1024)))
		    (snd-display ";pango underlines: ~A ~A ~A ~A" int0 int1 int2 int3)))
	      (if (not _PangoScript) (snd-display ";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 ";not cell renderer combo?"))
	      (if (not (GTK_IS_CELL_RENDERER_PROGRESS cell1)) (snd-display ";not cell renderer progress?"))
	      (if (not (number? (gtk_cell_renderer_combo_get_type))) (snd-display ";cell renderer combo type?"))  
	      (if (not (number? (gtk_cell_renderer_progress_get_type))) (snd-display ";cell renderer progress type?")))

	    (let ((GtkW (GTK_FILE_CHOOSER_BUTTON (gtk_file_chooser_button_new "hiho"))))
	      (if (not (GTK_IS_FILE_CHOOSER_BUTTON GtkW))
		  (snd-display ";file chooser button new -> ~A" GtkW))
	      (if (not (string=? (gtk_file_chooser_button_get_title GtkW) "hiho"))
		  (snd-display ";file chooser button get title: ~A" (gtk_file_chooser_button_get_title GtkW)))
	      (gtk_file_chooser_button_set_title GtkW "a title")
	      (if (not (string=? (gtk_file_chooser_button_get_title GtkW) "a title"))
		  (snd-display ";file chooser button set title: ~A" (gtk_file_chooser_button_get_title GtkW)))
	      (gtk_file_chooser_button_set_active GtkW #f)
	      (if (gtk_file_chooser_button_get_active GtkW)
		  (snd-display ";file chooser button active?")))
	    ))
      (run-hook after-test-hook 26)
      ))

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

(if (and with-gui (or full-test (= snd-test 27) (and keep-going (<= snd-test 27))))
    (begin
      (run-hook before-test-hook 27)
      (if (and (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 gluBeginPolygon gluBuild1DMipmaps
		    gluBuild2DMipmaps gluDeleteTess gluEndPolygon gluErrorString gluGetString gluGetTessProperty gluLookAt gluNewTess gluNextContour
		    gluOrtho2D gluPerspective gluPickMatrix gluProject gluScaleImage gluTessBeginContour gluTessBeginPolygon gluTessEndContour
		    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)))
	      )
	    
	    (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))
	    
	    ))
      (run-hook after-test-hook 27)
      ))


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

(if (not (provided? 'snd-debug.scm)) (load "debug.scm"))
(define (traced a) (+ 2 a))

(define (make-identity-mixer chans)
  (if (and (integer? chans) 
	   (< chans 256))
      (let ((m1 (make-mixer chans)))
	(if (mixer? m1)
	    (do ((i 0 (1+ i)))
		((= i chans))
	      (mixer-set! m1 i i 1.0)))
	m1)
      #f))

(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 #:optional (snd #f) (chn #f))
  "(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 I'm 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
     (inexact->exact (expt 2 (ceiling (/ (log (/ cur-srate 10.0)) (log 2.0)))))
     snd chn)))

(define* (reverse-channels #:optional snd)
  (let* ((ind (or snd (selected-sound) (car (sounds))))
	 (chns (chans ind)))
    (let ((swaps (inexact->exact (floor (/ chns 2)))))
      (as-one-edit
       (lambda ()
	 (do ((i 0 (1+ i))
	      (j (1- chns) (1- j)))
	     ((= i swaps))
	   (swap-channels ind i ind j)))))))

(define* (rotate-channel #:optional (samps 1) snd chn)
  (let* ((ind (or snd (selected-sound) (car (sounds))))
	 (chan (or chn (selected-channel) 0)))
    (let ((reg (make-region 0 (1- samps) ind chan)))
      (as-one-edit
       (lambda ()
	 (delete-samples 0 samps ind chan)
	 (insert-region (frames ind chan) reg)))
      (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))
!#

(gc)
(if (defined? 'mem-report) (mem-report))
(if (file-exists? "memlog")
    (system "mv memlog memlog.27")) ; save pre-error version
;;; regions exist here (etc) so it's not a cleaned-out state

(define (check-error-tag expected-tag thunk)
  (let ((tag
	 (catch #t 
		thunk
		(lambda args (car args)))))
    (if (not (eq? tag expected-tag))
	(snd-display ";check-error-tag ~A from ~A: ~A" 
		     expected-tag (procedure-source thunk) tag))))

(defvar env3 '(0 0 1 1))
(define delay-32 (make-delay 32))
(define color-95 (make-color .95 .95 .95))
(define vector-0 (make-vector 0))
(define vct-3 (make-vct 3))
(define car-main (if with-gui (car (main-widgets)) #f))
(define cadr-main (if with-gui (cadr (main-widgets)) #f))
(define sound-data-23 (make-sound-data 2 3))
(define a-hook (make-hook 2))
(set! (with-background-processes) #t)

(if with-gui 
    (begin
      (define procs (list 
		     add-mark add-player add-sound-file-extension add-to-main-menu add-to-menu add-transform amp-control
		     as-one-edit ask-before-overwrite audio-input-device audio-output-device
		     auto-resize auto-update autocorrelate 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 ;close-sound-file 
		     color-cutoff color-dialog colormap-ref add-colormap delete-colormap colormap-size colormap-name
		     color-inverted color-scale color->list colormap color?  comment contrast-control contrast-control-amp
		     contrast-control? convolve-selection-with convolve-with channel-properties 
		     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 cursor-follows-play cursor-size
		     cursor-style dac-combines-channels dac-size data-clipped data-color data-format data-location data-size
		     default-output-chans default-output-format default-output-srate default-output-type define-envelope
		     delete-mark delete-marks forget-region delete-sample delete-samples delete-samples-with-origin
		     delete-selection dialog-widgets display-edits dot-size draw-dot draw-dots draw-line
		     draw-lines draw-string edit-header-dialog edit-fragment 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 emacs-style-save-as
		     eps-bottom-margin eps-size expand-control expand-control-hop expand-control-jitter expand-control-length expand-control-ramp
		     expand-control? fft fft-window-beta fft-log-frequency fft-log-magnitude 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
		     find-mark find-sound finish-progress-report foreground-color
		     frames free-sample-reader graph 
		     graph-color graph-cursor graph-data graph->ps graph-style lisp-graph?  graphs-horizontal header-type
		     help-dialog info-dialog highlight-color in 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 load-font
		     main-widgets make-color make-graph-data make-mix-sample-reader make-player make-region
		     make-region-sample-reader make-sample-reader make-track-sample-reader map-chan mark-color mark-name
		     mark-sample mark-sync mark-sync-max mark-home marks mark?  max-transform-peaks max-regions
		     maxamp menu-widgets minibuffer-history-length min-dB log-freq-start mix mixes mix-amp mix-amp-env
		     mix-tag-position mix-chans mix-color mix-track mix-frames mix-locked? mix? view-mixes-dialog mix-position view-tracks-dialog
		     track-dialog-track mix-dialog-mix mix-inverted?
		     mix-region mix-sample-reader?  mix-selection mix-sound mix-home mix-speed mix-tag-height mix-tag-width
		     mix-tag-y mix-vct mix-waveform-height time-graph-style lisp-graph-style transform-graph-style
					;new-sound 
		     read-mix-sample read-track-sample next-sample
		     transform-normalization equalize-panes open-raw-sound open-sound orientation-dialog
		     peak-env-info peaks play play-and-wait play-mix play-region play-selection play-track player? players
		     position-color position->x position->y preload-directory preload-file previous-files-sort previous-sample
		     print-length progress-report prompt-in-minibuffer pushed-button-color read-only
		     recorder-in-device read-peak-env-info-file recorder-autoload recorder-buffer-size recorder-dialog
		     recorder-file recorder-gain recorder-in-amp recorder-in-format recorder-max-duration recorder-out-amp
		     recorder-out-chans recorder-out-format recorder-out-type recorder-srate recorder-trigger redo region-chans view-regions-dialog
		     region-graph-style region-frames region-position region-maxamp selection-maxamp region-sample region->vct
		     region-srate regions region?  remove-from-menu report-in-minibuffer reset-controls restore-controls
		     restore-marks restore-region reverb-control-decay reverb-control-feedback recorder-in-chans
		     reverb-control-length reverb-control-lowpass reverb-control-scale reverb-control?  reverse-sound
		     reverse-selection revert-sound right-sample sample sample-reader-at-end?  sample-reader? samples sample-reader-position
		     samples->sound-data sash-color save-controls ladspa-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-backtrace 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 spectro-cutoff spectro-hop spectro-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 sound-properties temp-dir
		     text-focus-color tiny-font track-sample-reader?  region-sample-reader? transform-dialog transform-sample
		     transform->vct transform-frames transform-type trap-segfault optimization unbind-key undo
		     update-transform-graph update-time-graph update-lisp-graph update-sound run-safety clm-table-size
		     vct->sound-file verbose-cursor view-sound vu-font vu-font-size vu-size wavelet-type
		     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 write-peak-env-info-file x-axis-style 
		     beats-per-minute x-bounds x-position-slider x->position x-zoom-slider
		     y-bounds y-position-slider y->position y-zoom-slider zero-pad zoom-color zoom-focus-style
		     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-audio-report mus-audio-sun-outputs
		     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-file-data-clipped average average? make-average
		     mus-expand-filename make-sound-data sound-data-ref sound-data-set!  sound-data? sound-data-length
		     sound-data-maxamp sound-data-chans sound-data->vct vct->sound-data all-pass all-pass? amplitude-modulate
		     array->file array-interp asymmetric-fm asymmetric-fm? sound-data->sound-data
		     clear-array comb 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+
		     frame->file frame->file? frame->frame frame->list frame->sample frame-ref frame-set! frame?
		     granulate granulate? hz->radians iir-filter iir-filter?  in-any in-hz ina inb linear->db locsig
		     locsig-ref locsig-reverb-ref locsig-reverb-set! locsig-set!  locsig? make-all-pass make-asymmetric-fm
		     make-comb make-convolve make-delay make-env make-fft-window make-file->frame
		     make-file->sample make-filter make-fir-filter make-formant 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-ppolar
		     make-pulse-train make-rand make-rand-interp make-readin make-sample->file make-sawtooth-wave
		     make-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines make-ssb-am make-table-lookup make-triangle-wave
		     make-two-pole make-two-zero make-wave-train make-waveshape make-zpolar mixer* mixer-ref mixer-set! mixer? mixer+ mixer-scale
		     multiply-arrays mus-a0 mus-a1 mus-a2 mus-array-print-length mus-b1 mus-b2 mus-channel mus-channels
		     mus-close mus-cosines mus-data mus-feedback mus-feedforward mus-fft mus-formant-radius 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-xcoeffs mus-ycoeffs notch notch? one-pole one-pole?
		     one-zero one-zero? oscil oscil? out-any outa outb outc outd partials->polynomial
		     partials->wave partials->waveshape phase-partials->wave polynomial pulse-train pulse-train?
		     radians->degrees radians->hz rand rand-interp rand-interp?  rand? readin readin?  rectangular->polar
		     restart-env ring-modulate sample->file sample->file? sample->frame sawtooth-wave
		     sawtooth-wave? sine-summation sine-summation? spectrum square-wave square-wave? src src? sum-of-cosines sum-of-sines ssb-am
		     sum-of-cosines? sum-of-sines? ssb-am? table-lookup table-lookup? tap triangle-wave triangle-wave? two-pole two-pole? two-zero
		     two-zero? wave-train wave-train?  waveshape waveshape?  make-vct vct-add! vct-subtract!  vct-copy
		     vct-length vct-multiply! vct-offset! vct-ref vct-scale! vct-fill! vct-set! mus-audio-describe 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 map-channel scan-channel play-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 xen->sample snd->sample? xen->sample? make-snd->sample make-xen->sample make-scalar-mixer
		     
		     beats-per-minute channel-amp-envs convolve-files filter-control-coeffs 
		     locsig-type make-phase-vocoder mus-audio-mixer-read
		     mus-describe mus-error-to-string mus-file-buffer-size mus-name mus-offset mus-out-format
		     mus-rand-seed mus-width phase-vocoder?
		     polar->rectangular previous-files-sort-procedure 
		     phase-vocoder-amp-increments phase-vocoder-amps phase-vocoder-freqs phase-vocoder-outctr 
		     phase-vocoder-phase-increments phase-vocoder-phases 

		     read-sample reset-listener-cursor goto-listener-end sample-reader-home selection-chans selection-srate snd-gcs
		     snd-warning sine-bank vct-map make-variable-graph channel-data x-axis-label
		     snd-url snd-urls tempo-control-bounds
		     quit-button-color help-button-color reset-button-color doit-button-color doit-again-button-color

		     track tracks track? make-track track-amp track-position track-frames track-speed track-tempo track-amp-env
		     track-track delete-track delete-mix track-color free-track

		     delay-tick dac-is-running draw-axes copy-mix copy-track copy-sample-reader html-dir html-program
		     lock-track make-fir-coeffs make-identity-mixer mus-interp-type mus-make-error mus-run phase-vocoder
		     player-home redo-edit undo-edit widget-position widget-size 
		     (if (defined? 'window-property) window-property identity)
		     focus-widget

		     ;;add-amp-controls analyse-ladspa any-env-channel append-sound apply-ladspa 
		     ;;backward-graph backward-mark backward-mix channel-envelope channel-property
		     ;;channel-sync channels-equal? channels=? clone-sound-as color-samples
		     ;;compand-channel concatenate-envelopes contrast-channel cross-synthesis
		     ;;define-selection-via-marks delete-selection-and-smooth describe-mark
		     ;;dither-channel env-expt-channel env-sound-interp envelope-interp enveloped-mix
		     ;;eval-between-marks eval-over-selection every-sample? explode-sf2 extract-channel
		     ;;extract-channels fft-edit fft-squelch filter-track find-dialog find-mix
		     ;;forward-graph forward-mark forward-mix fractional-fourier-transform ;hide-widget
		     ;;insert-channel ladspa-descriptor list-ladspa main-menu make-bandpass make-bandstop
		     ;;make-biquad make-differentiator make-highpass make-hilbert-transform make-lowpass
		     ;;make-selection mark-explode mark-loops mark-name->id mark-property match-sound-files
		     ;;max-envelope mix->vct mix-channel mix-property mono->stereo moog-filter mpg
		     ;;normalized-mix notch-channel notch-out-rumble-and-hiss notch-selection notch-sound
		     ;;offset-channel pad-marks pan-mix power-env read-region-sample redo-channel reverse-channels
		     ;;reverse-envelope reverse-track rotate-channel scale-envelope selection-members
		     ;;sine-env-channel sine-ramp snap-mark-to-beat snap-mix-to-beat snd-apropos snd-help
		     ;;snd-trace sound-interp sound-property superimpose-ffts swap-selection-channels
		     ;;track->vct track-chans track-property transpose-track undo-channel vct-map!
		     ;;voiced->unvoiced window-samples with-background-processes with-mix xen-channel
		     ;;z-transform zip-sound zipper 

		     ))
      
      (define set-procs (list 
			 amp-control ask-before-overwrite audio-input-device audio-output-device auto-resize
			 auto-update axis-label-font axis-numbers-font ;basic-color 
			 channel-style peaks-font bold-peaks-font
			 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
			 cursor-follows-play cursor-size cursor-style dac-combines-channels dac-size data-clipped data-color
			 default-output-chans default-output-format default-output-srate default-output-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-beta fft-log-frequency fft-log-magnitude transform-size transform-graph-type fft-window
			 transform-graph? filter-control-in-dB filter-control-envelope enved-filter-order enved-filter emacs-style-save-as
			 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-sample mark-sync max-transform-peaks max-regions min-dB log-freq-start mix-amp
			 mix-amp-env mix-tag-position mix-chans mix-color mix-locked? mix-inverted? mix-position
			 mix-speed mix-tag-height mix-tag-width mix-tag-y mix-waveform-height transform-normalization
			 equalize-panes position-color recorder-in-device previous-files-sort print-length pushed-button-color
			 recorder-autoload recorder-buffer-size recorder-dialog recorder-file recorder-gain recorder-in-amp
			 recorder-in-format recorder-max-duration recorder-out-amp recorder-out-chans recorder-out-format recorder-out-type
			 recorder-srate region-graph-style recorder-trigger reverb-control-decay reverb-control-feedback recorder-in-chans
			 reverb-control-length reverb-control-lowpass reverb-control-scale time-graph-style lisp-graph-style transform-graph-style
			 reverb-control? sash-color ladspa-dir save-dir save-state-file selected-data-color selected-graph-color
			 selection-color selection-creates-region show-axes show-backtrace 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 spectro-cutoff spectro-hop spectro-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 temp-dir text-focus-color tiny-font y-bounds
			 transform-type trap-segfault optimization verbose-cursor vu-font vu-font-size vu-size 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 track-dialog-track
			 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
			 selected-sound selection-position selection-frames selection-member? sound-loop-info
			 srate time-graph-type x-position-slider x-zoom-slider tempo-control-bounds
			 y-position-slider y-zoom-slider sound-data-ref mus-a0 mus-a1 mus-a2 mus-array-print-length 
			 mus-b1 mus-b2 mus-cosines mus-data mus-feedback mus-feedforward mus-formant-radius mus-frequency mus-hop
			 mus-increment mus-length mus-location mus-phase mus-ramp mus-scaler vct-ref x-axis-label
			 beats-per-minute filter-control-coeffs locsig-type mus-file-buffer-size 
			 mus-rand-seed mus-width clm-table-size run-safety mus-offset
			 previous-files-sort-procedure phase-vocoder-amp-increments phase-vocoder-amps 
			 phase-vocoder-freqs phase-vocoder-outctr phase-vocoder-phase-increments phase-vocoder-phases 
			 quit-button-color help-button-color reset-button-color doit-button-color doit-again-button-color
			 track-amp track-position track-speed track-tempo track-amp-env track-color

			 html-dir html-program mus-interp-type widget-position widget-size 
			 (if (defined? 'window-property) window-property widget-size)

			 mixer-ref frame-ref locsig-ref locsig-reverb-ref
			 ))
      
      (define make-procs (list
			  make-all-pass make-asymmetric-fm make-snd->sample make-xen->sample make-average
			  make-comb make-convolve make-delay make-env make-fft-window make-file->frame
			  make-file->sample make-filter make-fir-filter make-formant 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-ppolar
			  make-pulse-train make-rand make-rand-interp make-readin make-sample->file make-sawtooth-wave
			  make-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines make-table-lookup make-triangle-wave
			  make-two-pole make-two-zero make-wave-train make-waveshape make-zpolar make-phase-vocoder make-ssb-am
			  make-color make-player make-track make-region make-scalar-mixer
			  ))
      
      (define 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))
      
      (define procs0 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 0)))) procs))
      (define set-procs0 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 1)))) set-procs))
      (define procs1 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 1)))) procs))
      (define set-procs1 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 2)))) set-procs))
      (define procs2 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 2)))) procs))
      (define set-procs2 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 3)))) set-procs))
      (define procs3 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 3)))) procs))
      (define set-procs3 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 4)))) set-procs))
      (define procs4 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 4)))) procs))
      (define set-procs4 (remove-if (lambda (n) (or (not (procedure? n)) (not (set-arity-ok n 5)))) set-procs))
      (define procs5 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 5)))) procs))
      (define procs6 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 6)))) procs))
      (define procs8 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 8)))) procs))
      (define procs10 (remove-if (lambda (n) (or (not (procedure? n)) (not (arity-ok n 10)))) procs))

      (define already-warned '("mus-length" "mus-data" "hz->radians" "in-hz" "mus-order" "mus-xcoeffs" "mus-ycoeffs"
			       "list->vct" "vct" "formant-bank"
			       ))

      (reset-almost-all-hooks)
      
      (if (or full-test (= snd-test 28) (and keep-going (<= snd-test 28)))
	  (begin
	    (run-hook before-test-hook 28)
	    (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 (make-sum-of-cosines 10 440))
		    (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 (make-pulse-train 100))
			(set! vector-0 (make-rand 100))
			(set! vct-3 (make-rand-interp 100))
			(set! car-main (make-asymmetric-fm 100))
			(set! cadr-main (make-sine-summation 100 0 7))
			(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 (make-two-pole .6 .1 .1))
			    (set! vector-0 (make-formant .1 100 1))
			    (set! vct-3 (make-waveshape :frequency 300 :partials '(1 1 2 1)))
			    (set! car-main (make-src :srate .1))
			    (set! cadr-main (make-granulate :expansion .1))
			    (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-fir-filter 3 (vct 1 2 3)))
				(set! vector-0 (make-iir-filter 3 (vct 1 2 3)))
				(set! vct-3 (make-convolve :filter (vct 2 1 2)))
				(set! car-main (make-env '(0 0 1 1) :end 100))
				(set! cadr-main (make-locsig :degree 90))
				(set! sound-data-23 (make-ssb-am 440))
				(set! a-hook (make-sum-of-sines 3 100)))
			      (begin
				(set! delay-32 (make-phase-vocoder :fft-size 128))
				(set! color-95 (make-average 3))
				(set! vector-0 (make-mixer 2 .1 .1 .2 .2)))))))

	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n 123))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-such-sound))
			      (snd-display ";snd no-such-sound ~A: ~A" n tag))))
		      (list amp-control bomb apply-controls channels chans 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? 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 swap-channels))
	    
	    (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 ";snd wrong-type-arg ~A: ~A ~A" n tag arg))))
				  (list amp-control bomb apply-controls channels chans 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? file-name
					filter-control-in-dB filter-control-in-hz filter-control-envelope filter-control-order filter-control?
					finish-progress-report frames 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 (current-module) (sqrt -1.0) 1.5 "hiho"))
	    
	    (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 (not (eq? tag 'wrong-type-arg))
					    (snd-display ";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 (current-module) (sqrt -1.0) 1.5 "hiho"))
	    
	    (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 ";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 (current-module) (sqrt -1.0) "hiho"))
	      (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 ";vct 0 wrong-type-arg ~A: ~A ~A" n tag arg))))
				  (list make-vct vct-copy vct-length vct->list vct-peak)))
		      (list (current-module) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1)))
	    
	    (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 ";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! vct-map!)))
				  (list (current-module) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1))))
		      (list (current-module) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1)))
	    
	    (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 ";vct 2 wrong-type-arg ~A: ~A" n tag))))
				  (list vct-add! vct-subtract! vct-multiply! vct-ref vct-scale! vct-fill! vct-map!)))
		      (list (current-module) "hiho" (sqrt -1.0) (list 1 0) '#(0 1)))
	    
	    (let ((tag
		   (catch #t
			  (lambda ()
			    (make-vct -23))
			  (lambda args (car args)))))
	      (if (not (eq? tag 'out-of-range))
		  (snd-display ";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 ";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 ";?proc ~A: ~A" n tag))))
				  (list all-pass? asymmetric-fm? comb? convolve? delay? env? file->frame? file->sample? snd->sample? xen->sample? 
					filter? fir-filter? formant? frame->file? frame? granulate? iir-filter? locsig? mixer? mus-input? 
					mus-output? notch? one-pole? one-zero? oscil? phase-vocoder? pulse-train? rand-interp? rand? readin? 
					sample->file? sawtooth-wave? sine-summation? square-wave? src? sum-of-cosines? sum-of-sines? table-lookup? 
					triangle-wave? two-pole? two-zero? wave-train? waveshape? color? mix-sample-reader? average? ssb-am?
					sample-reader? track-sample-reader? region-sample-reader? vct? )))
		      (list (current-module) "hiho" (sqrt -1.0) 1.5 (list 1 0) '#(0 1)))
	    (gc)
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (make-oscil 440)))
				      (lambda args (car args)))))
			  (if tag
			      (snd-display ";oscil?proc ~A: ~A" n tag))))
		      (list all-pass? asymmetric-fm? comb? convolve? delay? env? file->frame? file->sample? snd->sample? xen->sample?
			    filter? fir-filter? formant? frame->file? frame? granulate? iir-filter? locsig? mixer? mus-input? 
			    mus-output? notch? one-pole? one-zero? phase-vocoder? pulse-train? rand-interp? rand? readin? 
			    sample->file? sawtooth-wave? sine-summation? square-wave? src? sum-of-cosines? sum-of-sines? table-lookup? 
			    triangle-wave? two-pole? two-zero? wave-train? waveshape? sound? color? mix-sample-reader? average? ssb-am?
			    sample-reader? track-sample-reader? region-sample-reader? vct?))
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'no-active-selection))
			      (snd-display ";selection ~A: ~A" n tag))))
		      (list reverse-selection selection-position selection-frames smooth-selection
			    scale-selection-to play-selection 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 ";selection ~A: ~A" n tag))))
		      (list src-selection filter-selection env-selection))
	    
	    (let ((trk (make-track)))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (n (1+ trk)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'no-such-track))
				(snd-display ";track ~A: ~A" n tag))))
			(list track track-amp track-position track-frames track-speed track-tempo track-amp-env track-track delete-track track-color))
	      (for-each (lambda (n a)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (set! (n (1+ trk)) a))
					(lambda args (car args)))))
			    (if (not (eq? tag 'no-such-track))
				(snd-display ";set track ~A: ~A" n tag))))
			(list track-amp track-position track-speed track-tempo track-amp-env track-track track-color)
			(list 1.0 0 1.0 1.0 '(0 0 1 1) (1- trk) (make-color 1 0 0))))

	    (for-each (lambda (arg)
			(let ((ctr 0))
			  (for-each (lambda (n)
				      (let ((tag
					     (catch #t
						    (lambda ()
						      (n arg))
						    (lambda args (car args)))))
					(if (not (eq? tag 'wrong-type-arg))
					    (snd-display ";clm ~A: ~A ~A [~A]: ~A" n tag arg ctr (procedure-property n 'documentation)))
					(set! ctr (1+ ctr))))
				    (list all-pass asymmetric-fm clear-array comb convolve db->linear average
					  degrees->radians delay env formant frame->list granulate hz->radians in-hz linear->db
					  make-all-pass make-asymmetric-fm make-comb make-convolve make-delay make-env
					  make-file->frame make-file->sample make-filter make-fir-filter make-formant make-frame
					  make-granulate make-iir-filter make-locsig make-notch make-one-pole make-one-zero
					  make-oscil make-ppolar make-pulse-train make-rand make-rand-interp make-readin
					  make-sawtooth-wave make-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines 
					  make-table-lookup make-triangle-wave make-two-pole make-two-zero make-wave-train make-ssb-am
					  make-waveshape make-zpolar mus-a0 mus-a1 mus-a2 mus-b1 mus-b2 mus-channel mus-channels
					  mus-cosines mus-data mus-feedback mus-feedforward mus-formant-radius mus-frequency mus-hop
					  mus-increment mus-length mus-file-name mus-location mus-order mus-phase mus-ramp mus-random mus-run
					  mus-scaler mus-xcoeffs mus-ycoeffs notch one-pole one-zero make-average seconds->samples samples->seconds
					  oscil partials->polynomial partials->wave partials->waveshape phase-partials->wave
					  phase-vocoder pulse-train radians->degrees radians->hz rand rand-interp readin restart-env
					  sawtooth-wave sine-summation square-wave src sum-of-cosines sum-of-sines table-lookup tap triangle-wave
					  two-pole two-zero wave-train waveshape ssb-am))))
		      (list (current-module) (sqrt -1.0)))
	    (gc)
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (make-oscil) (current-module)))
				      (lambda args (car args)))))
			  (if (not (or (eq? tag 'wrong-type-arg)
				       (eq? tag 'bad-arity)
				       (eq? tag 'mus-error)))
			      (snd-display ";clm ~A: ~A" n tag))))
		      (list all-pass array-interp asymmetric-fm comb contrast-enhancement convolution convolve average
			    convolve-files delay dot-product env-interp file->frame file->sample snd->sample xen->sample filter fir-filter formant
			    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-convolve
			    make-delay make-env make-fft-window make-filter make-fir-filter make-formant make-frame make-granulate
			    make-iir-filter make-locsig make-notch make-one-pole make-one-zero make-oscil make-phase-vocoder
			    make-ppolar make-pulse-train make-rand make-rand-interp make-readin make-sawtooth-wave make-average
			    make-sine-summation make-square-wave make-src make-sum-of-cosines make-sum-of-sines make-table-lookup make-triangle-wave
			    make-two-pole make-two-zero make-wave-train make-waveshape make-zpolar mixer* mixer+ mixer-scale multiply-arrays
			    notch one-pole one-zero oscil partials->polynomial partials->wave partials->waveshape
			    phase-partials->wave phase-vocoder polynomial pulse-train rand rand-interp rectangular->polar
			    ring-modulate sample->frame sawtooth-wave sine-summation square-wave src sum-of-cosines sum-of-sines 
			    sine-bank table-lookup tap triangle-wave two-pole two-zero wave-train waveshape ssb-am make-ssb-am))
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(set! (n (make-oscil)) (current-module)))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display ";mus-gen ~A: ~A" n tag))))
		      (list mus-a0 mus-a1 mus-a2 mus-b1 mus-b2 mus-channel mus-channels mus-cosines mus-data
			    mus-feedback mus-feedforward mus-formant-radius mus-frequency mus-hop mus-increment mus-length
			    mus-location mus-mix mus-order mus-phase mus-ramp mus-random mus-run mus-scaler mus-xcoeffs
			    mus-ycoeffs))
	    (gc)
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n (current-module)))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display ";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-maxamp
			    mus-sound-maxamp-exists?))
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-number-of-args))
			      (snd-display ";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-maxamp
			    mus-sound-maxamp-exists?))
	    
	    (for-each (lambda (n)
			(let ((tag
			       (catch #t
				      (lambda ()
					(n "/bad/baddy"))
				      (lambda args (car args)))))
			  (if (not (eq? tag 'mus-error))
			      (snd-display ";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 (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: chn (no snd) procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list channel-widgets count-matches cursor channel-properties
			      cursor-follows-play cursor-position cursor-size cursor-style delete-sample display-edits dot-size
			      draw-dots draw-lines edit-fragment edit-position edit-tree edits fft-window-beta fft-log-frequency
			      fft-log-magnitude transform-size transform-graph-type fft-window transform-graph? find
			      graph graph-style lisp-graph? insert-region insert-sound
			      time-graph-style lisp-graph-style transform-graph-style
			      left-sample make-graph-data map-chan max-transform-peaks maxamp min-dB mix-region
			      transform-normalization peak-env-info peaks play play-and-wait position->x position->y reverse-sound
			      revert-sound right-sample sample samples->sound-data 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
			      spectro-cutoff spectro-hop spectro-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-bounds y-position-slider y-zoom-slider zero-pad))
	      (gc))
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (n 0 (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: chn (no chn) procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list channel-widgets count-matches cursor channel-properties
			      cursor-position cursor-size cursor-style delete-sample display-edits dot-size draw-dots draw-lines
			      edit-fragment edit-position edit-tree edits fft-window-beta fft-log-frequency fft-log-magnitude
			      transform-size transform-graph-type fft-window transform-graph? find 
			      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 min-dB mix-region transform-normalization
			      peak-env-info peaks play play-and-wait position->x position->y reverse-sound right-sample sample
			      samples->sound-data save-sound-as scan-chan show-axes show-transform-peaks show-marks
			      show-mix-waveforms show-y-zero show-grid show-sonogram-cursor spectro-cutoff spectro-hop spectro-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-bounds y-position-slider
			      y-zoom-slider zero-pad)))
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (n 1234))
					(lambda args (car args)))))
			    (if (not (eq? tag 'no-such-sound))
				(snd-display ";~D: chn procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list channel-widgets cursor cursor-follows-play channel-properties
			      cursor-position cursor-size cursor-style delete-sample display-edits dot-size edit-fragment
			      edit-position edit-tree edits env-sound fft-window-beta fft-log-frequency fft-log-magnitude
			      transform-size transform-graph-type fft-window transform-graph? filter-sound
			      graph-data graph-style lisp-graph? insert-region left-sample
			      time-graph-style lisp-graph-style transform-graph-style
			      make-graph-data max-transform-peaks maxamp min-dB transform-normalization peak-env-info play
			      play-and-wait position->x position->y redo reverse-sound revert-sound right-sample sample
			      samples->sound-data save-sound scale-by scale-to show-axes show-transform-peaks
			      show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor spectro-cutoff spectro-hop spectro-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 transform-sample transform->vct
			      transform-frames transform-type undo 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 normalize-channel
			      x->position x-zoom-slider y-bounds y-position-slider x-axis-label y->position y-zoom-slider zero-pad scale-channel)))
	    
	    (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 ";~D: snd(1) chn procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list delete-sample edit-fragment graph-data graph-style play play-and-wait 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 ";~D: snd(1 1234) chn procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list delete-sample edit-fragment graph-data play play-and-wait 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 (not (eq? tag 'no-such-channel))
				(snd-display ";~D: chn procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list channel-widgets cursor cursor-position cursor-size cursor-style display-edits
			      dot-size edit-position edit-tree edits fft-window-beta fft-log-frequency fft-log-magnitude
			      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 min-dB transform-normalization peak-env-info
			      reverse-sound right-sample show-axes show-transform-peaks show-marks 
			      show-mix-waveforms show-y-zero show-grid show-sonogram-cursor  grid-density
			      spectro-cutoff spectro-hop spectro-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))
	      (close-sound index))
	    
	    (let ((ctr 0)
		  (index (open-sound "oboe.snd")))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (set! (n index 0) (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~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-beta fft-log-frequency fft-log-magnitude transform-size transform-graph-type fft-window
			      transform-graph? graph-style lisp-graph? left-sample make-graph-data max-transform-peaks maxamp
			      time-graph-style lisp-graph-style transform-graph-style
			      min-dB transform-normalization peak-env-info reverse-sound right-sample show-axes  grid-density
			      show-transform-peaks show-marks show-mix-waveforms show-y-zero show-grid show-sonogram-cursor spectro-cutoff spectro-hop
			      spectro-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
			      ))
	      (gc)
	      (close-sound index))
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (n (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: mix procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list mix-amp mix-amp-env mix-tag-position mix-chans mix-track mix-frames mix-locked? mix-inverted?
			      mix-position mix-home mix-speed mix-tag-y))) 
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (n 1234))
					(lambda args (car args)))))
			    (if (not (eq? tag 'no-such-mix))
				(snd-display ";~D: mix procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list mix-amp mix-tag-position mix-chans mix-track mix-frames mix-locked? mix-inverted?
			      mix-position mix-home mix-speed mix-tag-y)))
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (set! (n 1234) (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: mix procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list mix-tag-position mix-chans mix-track mix-locked? mix-inverted?
			      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)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (set! (n id) (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: mix procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list mix-tag-position mix-chans mix-track mix-locked? mix-inverted?
			      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 (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~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 1234))
					(lambda args (car args)))))
			    (if (not (eq? tag 'no-such-mark))
				(snd-display ";~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) (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: set mark procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list mark-name mark-sample mark-sync))
	      (close-sound index)
	      (gc))
	    
	    (for-each (lambda (arg)
			(let ((ctr 0))
			  (for-each (lambda (n)
				      (let ((tag
					     (catch #t
						    (lambda ()
						      (n arg))
						    (lambda args (car args)))))
					(if (not (eq? tag 'wrong-type-arg))
					    (snd-display ";~D: region procs ~A: ~A ~A" ctr n tag arg))
					(set! ctr (+ ctr 1))))
				    (list play-region region-chans region-frames region-position region-maxamp region-sample 
					  region->vct region-srate forget-region))))
		      (list (current-module) '#(0 1) (sqrt -1.0) "hiho" (list 0 1)))
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (n 1234))
					(lambda args (car args)))))
			    (if (not (eq? tag 'no-such-region))
				(snd-display ";~D: (no) region procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list play-region region-chans region-frames region-position region-maxamp region-srate forget-region))) 
	    
	    (let ((ctr 0))
	      (for-each (lambda (n)
			  (let ((tag
				 (catch #t
					(lambda ()
					  (set! (n) (current-module)))
					(lambda args (car args)))))
			    (if (not (eq? tag 'wrong-type-arg))
				(snd-display ";~D: misc procs ~A: ~A" ctr n tag))
			    (set! ctr (+ ctr 1))))
			(list 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-dialog color-inverted color-scale
			      cursor-color dac-combines-channels dac-size data-clipped data-color default-output-chans emacs-style-save-as
			      default-output-format default-output-srate default-output-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
			      previous-files-sort print-length pushed-button-color recorder-in-device recorder-autoload
			      recorder-buffer-size recorder-file recorder-in-format recorder-max-duration recorder-out-chans recorder-in-chans
			      recorder-out-format recorder-out-type recorder-srate recorder-trigger sash-color ladspa-dir save-dir save-state-file
			      selected-channel selected-data-color selected-graph-color 
			      selected-sound selection-creates-region show-backtrace show-controls show-indices show-listener
			      show-selection-transform sinc-width temp-dir text-focus-color tiny-font
			      trap-segfault optimization unbind-key verbose-cursor vu-font vu-font-size vu-size window-height
			      window-width window-x window-y with-gl with-mix-tags x-axis-style beats-per-minute zoom-color zoom-focus-style mix-tag-height
			      mix-tag-width with-relative-panes run-safety clm-table-size
			      quit-button-color help-button-color reset-button-color doit-button-color doit-again-button-color
			      ))
	      (gc))
	    
	    (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 ";hooks ~A: ~A" hook-name tag))))
		      (list (list after-graph-hook 'after-graph-hook)
			    (list lisp-graph-hook 'lisp-graph-hook)
			    (list before-transform-hook 'before-transform-hook)
			    (list mix-release-hook 'mix-release-hook)
			    (list save-hook 'save-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 after-open-hook 'after-open-hook)
			    (list close-hook 'close-hook)
			    (list draw-mark-hook 'draw-mark-hook)
			    (list just-sounds-hook 'just-sounds-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 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-hook 'after-apply-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 previous-files-select-hook 'previous-files-select-hook)
			    (list during-open-hook 'during-open-hook)
			    (list transform-hook '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)))

	    (for-each (lambda (n)
			(let* ((hook (car n))
			       (hook-name (cadr n))
			       (tag
				(catch #t
				       (lambda () (add-hook! hook (lambda (a b c) (+ a b c))))
				       (lambda args (car args)))))
			  (if (not (eq? tag 'wrong-type-arg))
			      (snd-display ";hooks ~A: ~A" hook-name tag))))
		      (list (list exit-hook 'exit-hook)
			    (list stop-dac-hook 'stop-dac-hook)
			    (list output-name-hook 'output-name-hook)
			    (list stop-playing-selection-hook 'stop-playing-selection-hook)
			    (list color-hook 'color-hook)
			    (list orientation-hook 'orientation-hook)
			    (list start-playing-selection-hook 'start-playing-selection-hook)
			    (list selection-changed-hook 'selection-changed-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 '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-sample-reader 0 "oboe.snd" 1)))
	    (check-error-tag 'no-such-channel (lambda () (make-sample-reader 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 'wrong-type-arg (lambda () (mus-mix "oboe.snd" "pistol.snd" 0 12 0 (make-mixer 1 1.0) vector-0)))
	    (check-error-tag 'bad-header (lambda () (mus-mix "test.snd" (string-append sf-dir "bad_chans.aifc"))))
	    (check-error-tag 'mus-error (lambda () (mus-mix "test.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 'mus-error (lambda () (new-sound "fmv.snd" mus-nist mus-bfloat 22050 2 "this is a comment")))
	    (check-error-tag 'no-such-player (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 20 (make-vct 4))))
	    (check-error-tag 'no-such-file (lambda () (close-sound-file 23 3)))
	    (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 'no-such-sound (lambda () (restore-marks 123 123 123 '())))
	    (check-error-tag 'mus-error (lambda () (play (string-append sf-dir "midi60.mid"))))
	    (check-error-tag 'wrong-type-arg (lambda () (make-iir-filter :order 32 :ycoeffs (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 '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 () (set! (default-output-format) -1)))
	    (check-error-tag 'out-of-range (lambda () (set! (default-output-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 'mus-error (lambda () (vct-map (lambda () 1.0))))
	    (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 'mus-error (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 'wrong-type-arg (lambda () (vct (list #f))))
	    (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 'out-of-range (lambda () (set! (tempo-control-bounds) (list 9.0 0.0))))
	    (check-error-tag 'wrong-type-arg (lambda () (set! (tempo-control-bounds) (list 0.0))))
	    (check-error-tag 'wrong-type-arg (lambda () (set! (tempo-control-bounds) (list 0.0 "hiho"))))
	    (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 'mus-error (lambda () (filter-sound (make-frame 4))))
	      (check-error-tag 'wrong-type-arg (lambda () (smooth-sound 0 -10)))
	      (check-error-tag 'out-of-range (lambda () (let ((hi (make-sound-data 1 10))) (samples->sound-data 0 8 #f #f hi #f 2))))
	      (check-error-tag 'cannot-save (lambda () (write-peak-env-info-file ind 0 "/baddy/hi")))
	      (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 'mus-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 'out-of-range (lambda () (vct->sound-file 123 vct-3 4)))
	      (check-error-tag 'out-of-range (lambda () (vct->sound-file 123 vct-3 -4)))
	      (check-error-tag 'mus-error (lambda () (vct->sound-file 123 vct-3 2)))
	      (check-error-tag 'bad-header (lambda () (insert-sound (string-append sf-dir "bad_chans.snd"))))
	      (check-error-tag 'mus-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 'wrong-type-arg (lambda () (play-selection 0 (lambda () #f))))
	      (check-error-tag 'wrong-type-arg (lambda () (play-selection 0 0)))
	      (check-error-tag 'wrong-type-arg (lambda () (play-selection 0 (lambda (a b) #f))))
	      (check-error-tag 'no-data (lambda () (draw-lines '#())))
	      (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 0 1 1) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 1 1 0) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 1 1 -1) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-channel (make-env '(0 -1 1 1) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 0 1 1) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 1 1 0) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 1 1 -1) :end 10))))
	      (check-error-tag 'out-of-range (lambda () (src-sound (make-env '(0 -1 1 1) :end 10))))
	      (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 () (scan-channel (lambda (n) #f) (* (frames) 2))))
	      (check-error-tag 'no-such-sample (lambda () (map-channel (lambda (n) #f) (* (frames) 2))))
	      (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 'mus-error (lambda () (play (string-append sf-dir "nist-shortpack.wav"))))
	      (check-error-tag 'no-such-channel (lambda () (play 0 ind 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-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 (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 '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 0 1234)))
	      (check-error-tag 'no-such-channel (lambda () (play 0 ind 1234)))
	      (if (= (length (regions)) 0) (make-region 0 100))
	      (check-error-tag 'no-such-channel (lambda () (region-sample 0 (car (regions)) 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 0 1 -1)))
	      (check-error-tag 'no-such-channel (lambda () (region->vct 0 1 (car (regions)) 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)))
	      (check-error-tag 'wrong-type-arg (lambda () (play-region (car (regions)) #f (lambda () #f))))
	      (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 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-track (lambda () (make-track-sample-reader 0 1234 0)))
	      (check-error-tag 'no-such-track (lambda () (make-track-sample-reader 1234 0 0)))
	      (check-error-tag 'no-such-mix (lambda () (make-mix-sample-reader 1234)))
	      (check-error-tag 'no-such-mix (lambda () (set! (mix-track 1234) 4321)))
	      (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-sample-reader 0 ind 0 123)))
	      (check-error-tag 'no-such-direction (lambda () (make-sample-reader 0 ind 0 0)))
	      (check-error-tag 'no-such-direction (lambda () (make-sample-reader 0 ind 0 -2)))
	      (check-error-tag 'no-data (lambda () (scale-by '())))
	      (check-error-tag 'no-data (lambda () (scale-to '())))
	      (check-error-tag 'no-such-sample (lambda () (ptree-channel (lambda (y) (+ y .1)) 1234567)))
	      (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 'no-such-sample (lambda () (samples->sound-data -1)))
	      (check-error-tag 'out-of-range (lambda () (samples->sound-data 0 2 ind 0 (make-sound-data 1 4) 0 -1)))
	      (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 'wrong-type-arg (lambda () (play 0 #f #f #f #f #f (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))))
	      (let ((eds (edits)))
		(catch #t (lambda () (undo (log 0))) (lambda args args))
		(if (not (equal? (edits) eds)) (snd-display ";undo -inf): ~A" (edits))))
	      (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))))
	      (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-options "/bad/baddy")))
	    (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 'no-such-file (lambda () (open-sound-file "/bad/baddy.snd")))
	    (check-error-tag 'out-of-range (lambda () (close-sound-file 0 0)))
	    (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-track (lambda () (make-track-sample-reader 0)))
	    (check-error-tag 'wrong-type-arg (lambda () (yes-or-no? (list 0 1))))
	    (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-sample-reader 0 "/bad/baddy.snd")))
	    (check-error-tag 'no-such-region (lambda () (make-region-sample-reader 0 1234567)))
	    (check-error-tag 'no-such-mix (lambda () (mix-tag-position 12345)))
	    (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)))
	    (check-error-tag 'wrong-type-arg (lambda () (send-netscape -1)))
	    (check-error-tag 'bad-header (lambda () (file->array "/home/bil/sf1/bad_chans.snd" 0 0 123 (make-vct 123))))
	    (check-error-tag 'bad-header (lambda () (make-readin "/home/bil/sf1/bad_chans.snd")))
	    (check-error-tag 'out-of-range (lambda () (make-wave-train :size (expt 2 30))))
	    (check-error-tag 'out-of-range (lambda () (make-waveshape :size (expt 2 30))))
	    (check-error-tag 'out-of-range (lambda () (make-granulate :max-size (expt 2 30))))
	    (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 'wrong-type-arg (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-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 'out-of-range (lambda () (open-sound-file "test.snd" :channels -1)))
	    (check-error-tag 'out-of-range (lambda () (open-sound-file "test.snd" :srate -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 ";~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)
	    
	    ;; ---------------- 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 12345678901234567890 (log 0) (nan))))
	     keyargs)

	    (if all-args
		(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 12345678901234567890 (log 0) (nan))))
		      keyargs))
		   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))
		  
		  (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 12345678901234567890 (log 0) (nan))))
		      keyargs))
		   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 :wave -1 0 1 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))

	    (gc)
	    
	    ;; ---------------- 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 ";procs0: ~A ~A" err (procedure-property n 'documentation)))))
	     procs0)
	    (dismiss-all-dialogs)
	    (gc)
	    
	    ;; ---------------- 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 ";procs1 wna: ~A ~A" err (procedure-property n 'documentation)))))
		procs1))
	     (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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
		   '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
		   12345678901234567890 (log 0) (nan)))
	    (gc)
	    
	    ;; ---------------- 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 ";procs2: ~A ~A" err (procedure-property n 'documentation)))))
		   procs2))
		(if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
			  '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
			  12345678901234567890 (log 0) (nan))
		    (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
			  (sqrt -1.0) delay-32 :feedback -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))
	     (if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
		       '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
		       12345678901234567890 (log 0) (nan))
		 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
		       (sqrt -1.0) delay-32 :frequency -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
	    (gc)
	    
	    ;; ---------------- 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 ";set-procs0: ~A ~A" err (procedure-property n 'documentation)))))
		set-procs0))
	     (if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
		       '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
		       12345678901234567890 (log 0) (nan))
		 (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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
	    (gc)
	    
	    ;; ---------------- 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 ";set-procs1: ~A ~A" err (procedure-property n 'documentation)))))
		   set-procs1))
		(if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
			  '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
			  12345678901234567890 (log 0) (nan))
		    (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
			  (sqrt -1.0) delay-32 :feedback -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))
	     (if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
		       '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
		       12345678901234567890 (log 0) (nan))
		 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
		       (sqrt -1.0) delay-32 :frequency -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
	    (gc)
	    
	    ;; ---------------- 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 ";set-procs2: ~A ~A" err (procedure-property n 'documentation)))))
		      set-procs2))
		   (if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
			     '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
			     12345678901234567890 (log 0) (nan))
		       (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
			     (sqrt -1.0) delay-32 :feedback -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))
		(if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
			  '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
			  12345678901234567890 (log 0) (nan))
		    (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
			  (sqrt -1.0) delay-32 :frequency -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))
	     (if all-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) (current-module) sound-data-23 :order 0 1 -1 a-hook #f #t #\c 0.0 1.0 -1.0 
		       '() '3 4 2 8 16 32 64 vector-0 '(1 . 2) (expt 2.0 21.5) (expt 2.0 -18.0) car-main cadr-main 
		       12345678901234567890 (log 0) (nan))
		 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 color-95 '#(0 1) 3/4 
		       (sqrt -1.0) delay-32 :frequency -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
	    (gc)
	    
	    (if all-args
		;; these can take awhile...
		(begin
		  ;; ---------------- 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 ";procs3: ~A ~A" err (procedure-property n 'documentation)))))
			      procs3))
			   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 '#(0 1) (sqrt -1.0) delay-32 3/4 -1.0
				 :start -1 0 3 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
			(list 1.5 "/hiho" (list 0 1) 1234 vct-3 '#(0 1) (sqrt -1.0) delay-32 3/4 -1.0
			      :phase -1 0 3 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))
		   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 '#(0 1) (sqrt -1.0) delay-32 3/4 -1.0
			 :channels -1 0 3 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))
		  (gc)
		  
		  ;; ---------------- 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 ";set-procs3: ~A ~A" err (procedure-property n 'documentation)))))
			       set-procs3))
			    (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
				  :wave -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
			 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			       :initial-contents -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
		      (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			    :srate -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
		   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			 :input -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))
		  
		  
		  ;; ---------------- 4 Args
		  (for-each 
		   (lambda (arg1)
		     (begin
		       (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 ";procs4: ~A ~A ~A" err n (procedure-property n 'documentation)))))
				 procs4))
			      (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
				    :wave -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
			   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
				 :initial-contents -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
			(list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			      :srate -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))))
		   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			 :input -1 0 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))
		  
		  ;; ---------------- 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 ";set-procs4: ~A ~A" err (procedure-property n 'documentation)))))
				  set-procs4))
			       (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
				     :wave -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
			    (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
				  :initial-contents -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
			 (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			       :srate -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
		      (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			    :input -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan))))
		   (list 1.5 "/hiho" (list 0 1) 1234 vct-3 (sqrt -1.0) delay-32 3/4 '#(0 1) -1.0
			 :input -1 0 3 16 #f #t '() vector-0 12345678901234567890 (log 0) (nan)))
		  
		  ;; ---------------- 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 ";procs5: ~A ~A ~A" err n (procedure-property n 'documentation)))))
				  procs5))
			       (list 1.5 "/hiho" 1234 vct-3 (sqrt -1.0) -1 0 #f #t '() 3/4 12345678901234567890 (log 0) (nan))))
			    (list 1.5 "/hiho" 1234 vct-3 (sqrt -1.0) -1 0 #f #t '() 3/4 12345678901234567890 (log 0) (nan))))
			 (list 1.5 "/hiho" 1234 vct-3 (sqrt -1.0) -1 0 #f #t '() 3/4 12345678901234567890 (log 0) (nan))))
		      (list 1.5 "/hiho" 1234 vct-3 (sqrt -1.0) -1 0 #f #t '() 3/4 12345678901234567890 (log 0) (nan))))
		   (list 1.5 "/hiho" 1234 vct-3 (sqrt -1.0) -1 0 #f #t '() 3/4 12345678901234567890 (log 0) (nan)))
		  
		  ;; ---------------- 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 ";procs6: ~A ~A" err (procedure-property n 'documentation)))))
				     procs6))
				  (list 1.5 "/hiho" -1234 -1 0 #f #t (log 0))))
			       (list 1.5 "/hiho" -1234 0 #t)))
			    (list 1.5 "/hiho" -1234 vct-3 #f #t)))
			 (list 1.5 "/hiho" -1234 vct-3 -1 #t)))
		      (list 1.5 vct-3 -1 0 #f #t)))
		   (list 1.5 "/hiho" -1234 #f))
		  
		  ;; ---------------- 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 ";procs8: ~A ~A" err (procedure-property n 'documentation)))))
					   procs8))
					(list 1.5 -1 #f (log 0))))
				     (list "/hiho" 1234)))
				  (list #t vct-3)))
			       (list (sqrt -1.0) 1)))
			    (list 1.5 '())))
			 (list 2 1234)))
		      (list #f #t)))
		   (list 1.5 "/hiho"))
		  
		  
		  ;; ---------------- 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 ";procs10: ~A ~A" err (procedure-property n 'documentation)))))
						 procs10))
					      (list 1.5 -1 #f)))
					   (list "/hiho" 1234)))
					(list #t vct-3)))
				     (list (sqrt -1.0) 1)))
				  (list 1.5 '())))
			       (list 2 1234)))
			    (list #f #t)))
			 (list 1.5 "/hiho")))
		      (list 1.5 -1)))
		   (list #f 1234))
		  (gc))))
	    
	    (if (defined? 'mus-audio-reinitialize) (mus-audio-reinitialize))
	    (set! (window-y) 10)
	    (dismiss-all-dialogs)

	    (copy-file "oboe.snd" "test.snd")
	    (let ((ind (open-sound "test.snd")))
	      (delete-file "test.snd")
	      (let ((val (update-sound ind)))
		(let ((msg (widget-text (list-ref (sound-widgets ind) 3))))
		  (if (or (not (string? msg))
			  (not (string=? msg "test.snd no longer exists!")))
		      (snd-display ";delete sound msg: ~A" msg))))
	      (delete-sample 10)
	      (catch #t
		     (lambda () (save-sound ind))
		     (lambda args #f))
	      (let ((msg (widget-text (list-ref (sound-widgets ind) 3))))
		(if (or (not (string? msg))
			(not (string=? msg (format #f "~A/test.snd has disappeared!" (getcwd)))))
		    (snd-display ";save deleted sound msg: ~A" msg)))
	      (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)
	      (catch #t
		     (lambda () (save-sound ind))
		     (lambda args #f))
	      (let ((msg (widget-text (list-ref (sound-widgets ind) 3))))
		(if (or (not (string? msg))
			(not (string=? (substring msg 0 57)
				       (format #f "file write failed: Permission denied, edits are saved in:"))))
		    (snd-display ";save protected sound msg: ~A" msg)))
	      (close-sound ind))
	    
	    (let ((ind (open-sound "test.snd")))
	      (if (not (read-only ind))
		  (snd-display ";write-protected sound, but read-only not set"))
	      (system "chmod 644 test.snd")
	      (delete-file "test.snd")
	      (close-sound ind))
	    
	    (copy-file "oboe.snd" "test.snd")
	    (system "chmod 200 test.snd")
	    (let ((tag
		   (catch #t
			  (lambda () (open-sound "test.snd"))
			  (lambda args (car args)))))
	      (if (not (eq? tag 'no-such-file))
		  (snd-display ";open read-protected sound: ~A" tag)))
	    (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 ";save-as write-protected sound: ~A" tag)))
	      (close-sound ind))
	    (system "chmod 644 test.snd")
	    (delete-file "test.snd")

	    (trace traced)
	    (snd-trace (if #t (traced 12)))

	    (run-hook after-test-hook 28)
	    ))
      ))

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

;(set! (max-regions) 2)
(let ((regs (regions)))
  (for-each
   (lambda (n)
     (forget-region n))
   regs))
(set! (previous-files-sort) 0)

(if (file-exists? "saved-snd.scm") (delete-file "saved-snd.scm"))
(gc)
(clear-sincs)
(reset-almost-all-hooks)
(for-each free-track (tracks))

(save-listener "test.output")
(set! (listener-prompt) original-prompt)

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

(if (number? (vector-ref timings total-tests)) 
    (vector-set! timings total-tests (hundred (- (real-time) (vector-ref timings total-tests)))))

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


(if (and (string? test14-file)
	 (file-exists? test14-file))
    (display (format #f ";~%~A(~D)" test14-file (mus-sound-samples test14-file))))

(show-listener)

(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 ~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 "sndinfo ~A/snd_*" original-temp-dir))
      (system (format #f "rm ~A/snd_*" original-temp-dir))))

(if (file-exists? "/tmp")
    (begin ; -noinit possibly
      (display (format #f "ls /tmp/snd_* | wc~%"))
      (system "ls /tmp/snd_* | wc")
					;(system "sndinfo /tmp/snd_*") ; not a bug -- save_dir null will write to /tmp
      (system "rm /tmp/snd_*")
      (system "ls /tmp/file*.snd | wc") ; these are externally created perhaps 
      (system "rm /tmp/file*.snd")))

(mus-sound-prune)
(close-output-port optimizer-log)
;;;(mus-sound-report-cache "hiho.tmp")
(gc)
(if (defined? 'mem-report) (mem-report))
(if (and full-test
	 (file-exists? "oldopt.log"))
    (system "diff -w optimizer.log oldopt.log"))

(if (file-exists? (string-append home-dir "/dot-snd"))
    (system (string-append "cp " home-dir "/dot-snd " home-dir "/.snd")))

(snd-print #\#)
(snd-print #\t)

(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"
  "test.data"
  "test.output"
  "test.rev"
  "test.reverb"
  "test.snd"
  "test.snd.snd"
  "test.temp"
  "test.wav"
  "test.xpm"
  "test2.snd"
  "test3.snd"
  "tmp.snd"
  "with-mix.snd"
  "1"

  (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")

))

(if (file-exists? "../peaks/_home_bil_cl_storm.snd-peaks-0")
    (begin
      (system (string-append "rm ../peaks/_home_bil_snd-7*"))
      (system (string-append "rm ../peaks/_home_bil_cl_fmv*"))
      (system (string-append "rm ../peaks/_home_bil_cl_test*"))
      (system (string-append "rm ../peaks/_home_bil_cl_tmp*"))
      (system (string-append "rm ../peaks/_home_bil_cl_hiho*"))
      (system (string-append "rm ../peaks/_home_bil_cl_new*"))))

(set! (mus-audio-playback-amp) 1.0)
(if with-exit (exit))
