|
From: Martin R. <ru...@us...> - 2004-08-30 18:05:25
|
Update of /cvsroot/foo/foo/elkfoo/scm/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19134 Modified Files: elkfoo.scm Log Message: - removed foo-default-soundfile-extension - changed param order in (foo:synthesize) in order to reflect params of (create|make-soundfile) - adopted (syn) and (synt) to changes in (foo:synthesize) - changed (foo:string-(r)index) in order to return -1 if char not found instead of #f, cause this led to an error in synt when using local path without '/'. however, (foo:dirname) returns strings with trailing '/' now, but (foo:dirname "test.aiff") now returns "" correctly instead of yielding an error Index: elkfoo.scm =================================================================== RCS file: /cvsroot/foo/foo/elkfoo/scm/kernel/elkfoo.scm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** elkfoo.scm 30 Aug 2004 15:59:48 -0000 1.4 --- elkfoo.scm 30 Aug 2004 18:05:15 -0000 1.5 *************** *** 72,76 **** (define foo-default-soundfile-format 'short) (define foo-default-soundfile-filetype 'aiff) - (define foo-default-soundfile-extension ".aiff") (define foo-default-play-command "sndfile-play") --- 72,75 ---- *************** *** 259,263 **** "/foo" (number->string (getpid)) ! foo-default-soundfile-extension)) (define (foo:cleanup) --- 258,262 ---- "/foo" (number->string (getpid)) ! (foo:soundfile-type-extension foo-default-soundfile-filetype))) (define (foo:cleanup) *************** *** 282,286 **** (define (loop n) (if (>= n len) ! #f (if (eq? (string-ref aString n) aCharacter) n --- 281,285 ---- (define (loop n) (if (>= n len) ! -1 (if (eq? (string-ref aString n) aCharacter) n *************** *** 292,296 **** (define (loop n) (if (< n 0) ! #f (if (eq? (string-ref aString n) aCharacter) n --- 291,295 ---- (define (loop n) (if (< n 0) ! -1 (if (eq? (string-ref aString n) aCharacter) n *************** *** 299,329 **** (define (foo:basename path) ! (substring path (+ (foo:string-rindex path #\/) 1) (string-length path))) (define (foo:dirname path) ! (substring path 0 (foo:string-rindex path #\/))) ! (define (foo:synthesize channels duration srate filename fileformat filetype thunk) (let ((c (make-context channels)) ! (d (substring filename 0 (foo:string-rindex filename #\/)))) ! (if (not (file-exists? d)) ! (system (string-append "mkdir -p " d))) ! (if (file-exists? filename) ! (system (string-append "rm " filename))) ! (make-soundfile filename fileformat channels srate filetype) ! (with-context c thunk) ! (let ((start 0) (finish 0) (done 0)) ! (define (pf filename n) ! (let ((s (number->string filename))) ! (substring s 0 (min (string-length s) n)))) ! (set! start (seconds)) ! (set! done (run-task (make-task 0 0 filename c 'punch srate) duration)) ! (set! finish (seconds)) ! (format #t ! "len: ~as, tim: ~as, rtf: ~a, sr: ~aHz~%fil: ~a, fmt: ~a, typ: ~a" (pf done 7) (pf (- finish start) 7) (pf (/ (- finish start) done) 7) ! (pf srate 7) filename fileformat filetype))) #v) --- 298,327 ---- (define (foo:basename path) ! (substring path (1+ (foo:string-rindex path #\/)) (string-length path))) (define (foo:dirname path) ! (substring path 0 (1+ (foo:string-rindex path #\/)))) ! (define (foo:synthesize channels duration filename filetype sampleformat srate thunk) (let ((c (make-context channels)) ! (d (substring filename 0 (1+ (foo:string-rindex filename #\/))))) ! (if (> (string-length d) 0) ! (if (not (file-exists? d)) ! (system (string-append "mkdir -p " d)))) ! (create-soundfile filename filetype sampleformat srate channels) ! (with-context c thunk) ! (let ((start 0) (finish 0) (done 0)) ! (define (pf f n) ! (let ((s (number->string f))) ! (substring s 0 (min (string-length s) n)))) ! (set! start (seconds)) ! (set! done (run-task (make-task 0 0 filename c 'punch srate) duration)) ! (set! finish (seconds)) ! (format #t ! "len: ~as, tim: ~as, rtf: ~a, sr: ~aHz~%fil: ~a, typ: ~a, fmt: ~a" (pf done 7) (pf (- finish start) 7) (pf (/ (- finish start) done) 7) ! (pf srate 7) filename filetype sampleformat))) #v) *************** *** 331,342 **** `(foo:synthesize ,c ,d - (foo-default-srate) (foo:test-file-name) - foo-default-soundfile-format foo-default-soundfile-filetype (lambda () ,@e))) ! (define-macro (synt c d s n f t . e) ! `(foo:synthesize ,c ,d ,s ,n ,f ,t (lambda () ,@e))) (define (play . name) --- 329,340 ---- `(foo:synthesize ,c ,d (foo:test-file-name) foo-default-soundfile-filetype + foo-default-soundfile-format + (foo-default-srate) (lambda () ,@e))) ! (define-macro (synt c d n t f s . e) ! `(foo:synthesize ,c ,d ,n ,t ,f ,s (lambda () ,@e))) (define (play . name) |