[linux-audio-user] batch sample editing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Oops, one ")" too much. Replace remove-preceding-silence with this one:

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





[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux