[CM] mark-explode modifications
cristopher pierson ewing
cewing@u.washington.edu
Wed, 23 Jun 2004 12:19:35 -0700 (PDT)
So here's my stab at the facility of naming exploded sounds after the
original sound they were created from:
;;;------find-char
(define (find-char string char)
(do ((position 0)
(i 0 (+ i 1)))
((= i (string-length string)) position)
(if (char=? char (string-ref string i))
(set! position i))))
;;;------trim-name
(define (trim-name name)
(let ((start 0)
(end (find-char name #\.)))
(substring name start end)))
;;; -------- mark-explode
;;;
;;; write out each section of a file between marks as a separate file
(define (mark-explode snd)
"(mark-explode) splits a sound into a bunch of sounds based on mark
placements"
(let ((start 0)
(file-ctr 0)
(name (trim-name (short-file-name snd))))
(for-each
(lambda (mark)
(let ((len (- (mark-sample mark) start)))
(array->file (format #f "~A-~D.aif" name file-ctr)
(channel->vct start len)
len (srate) 1)
(set! file-ctr (1+ file-ctr))
(set! start (mark-sample mark))))
(caar (marks)))))
I'll try later to work on the problem of choosing an output file type
according to the input file type. Can one set (default-output-type) from
inside a let statement so that it returns to normal after the let closes
and normal scope is returned? I'll try to find out.
C
********************************
Cris Ewing
CME and Telehealth Web Services
University of Washington
School of Medicine
Work Phone: (206) 685-9116
Home Phone: (206) 365-3413
E-mail: cewing@u.washington.edu
*******************************