i trying delete silence audio file using audacity. there nyquist plugin called trim silence deletes silence start , end of file, not middle. invert this, , delete silence everywhere except start , end.
i think function below relevant part of plugin. how should change truncate-internal-silences function? (i don't know nyquist, or lisp, i'm struggling understand does, let alone change it.)
entirely different approaches welcome - current best guess @ how edit many audio files.
(defun trim-silence () ;; nyquist plug-ins cannot return 'no audio', trap error. (if (< (get '*selection* 'peak-level) threshold) (throw 'error (format nil "error.~%all selected audio in ~a selected track~%~ below silence threshold.~%~%~ try setting threshold a~%~ lower (more negative) db level." (add-num-suffix (get '*track* 'index))))) (if (> len (* limit *sound-srate*)) ;max length in samples (throw 'error (format nil "error.\nmax ram usage trim silence set ~a gb.~%this allows maximum duration ~ ~a~%track @ ~a hz of ~a.~%selected track ~a.~%" ram-limit (if (arrayp *track*) "stereo" "mono") (round *sound-srate*) (to-hhmmss limit) (to-hhmmss (get-duration 1))))) (let* (;; ratio provides tighter trimming short selections ;; while maintaining reasonable speed long selections (ratio (max 10 (min 200 (round (/ len 100000.0))))) (my-srate (/ *sound-srate* ratio)) (mysound (convert *track* ratio)) (limits (get-clip-limits)) ; (list start, end) times of audio clips (clip-start (if (first limits) (abs-to-relative-time (nth 0 limits)))) ; nil id invalid (clip-end (if (second limits) (abs-to-relative-time (nth 1 limits))))) ; nil if invalid ;loop through samples , mark start , end (setf result (find-sil mysound clip-start clip-end)) (let ((start (if clip-start (max clip-start (- (/ (first result) my-srate) min-start-silence)) 0)) (end (if clip-end (min (+ (- (get-duration 1) (/ (second result) my-srate)) min-end-silence) clip-end) (get '*selection* 'end)))) ;; ensure @ least 1 sample remains ;; should never happen. (if (>= start end) (setq start (- end (/ *sound-srate*)))) ; trim (multichan-expand #'extract-abs start end (cue *track*)))))
Comments
Post a Comment