Re: [linux-audio-user] batch sample editing

From: Kjetil Svalastog Matheussen <k.s.matheussen@email-addr-hidden>
Date: Sat Aug 06 2005 - 16:10:57 EEST

John Mulholland:
>
> I have a large amount of aiff samples that have a predecing second or
> two of ambient silence. To trim this out of each file is going to take a
> very long time. Is there a program that can do this for me?
>

Probably a lot of programs...

Heres a solution for SND. Its probably not the most
elegant way, but anyway:

(define (for-each-file path func)
  (let* ((dir (opendir path))
         (entry (readdir dir)))
    (while (not (eof-object? entry))
           (if (and (not (string=? "." entry))
                    (not (string=? ".." entry)))
               (func entry))
           (set! entry (readdir dir)))
    (closedir dir)))

(define (remove-preceding-silence infile outfile how-much)
  (open-sound infile))
  (set! (selection-position) 0)
  (set! (selection-frames) (* (srate) how-much))
  (delete-selection)
  (save-sound-as outfile))

(define (delete-preceding-silence-in-dir indir outdir how-much)
  (for-each-file indir
                 (lambda (name)
                   (remove-preceding-silence (string-append indir "/" name)
                                             (string-append outdir "/" name)
                                             how-much))))

;;(delete-preceding-silence-in-dir "/home/kjetil/testdir"
"/home/kjetil/testdirout" 2)
Received on Sat Aug 6 20:15:06 2005

This archive was generated by hypermail 2.1.8 : Sat Aug 06 2005 - 20:15:06 EEST