在Audacity中添加白噪声链

时间:2018-02-06 22:33:11

标签: audio audacity nyquist

我需要使用Audacity将恒定dB级别的白噪声添加到批量声音文件中。 Generate插件'Noise'基本上就是我正在寻找的,但它不能用于为链中的文件添加噪声,因为它会覆盖每个文件而不是向其添加白噪声。有一个效果插件'添加噪音'也非常接近我需要的,但白噪声是每个文件中总噪声的百分比,而不是以恒定的dB级别添加到每个文件。

我正在尝试使用“Nyquist Prompt”编辑“添加噪音”插件的代码,以便将噪音级别设置从百分比更改为dB,但对于新代码应该是什么不知所措。我认为我需要更改的2行是第9行和第13行,但同样,我并不完全确定。 “添加噪音”插件来自Audacity forum

;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
;name "Add Noise ..."
;action "Adding Selected Noise ..."
;info "by 'Steve Daulton.\nReleased under GPL V2."

;control mix "Noise mix (%)" real "" 20 0 100
;control type "Type of Noise" choice "White,Pink,Crackle,Wind" 0


(setf mix (/ mix 100))

;;; Wind noise by Robert J. H. 
(defun wind (gust speed)
  (defmacro contour (scale offset min-wind max-wind)
    `(sum ,offset 
       (mult ,scale 
         (s-abs (reson (noise) ,min-wind ,max-wind 1)))))
  (mult 2
    (contour 300 0.7 gust speed)
        (sim (reson (noise) 593 80 2)
             (reson (noise) (contour 300000 300 gust speed) 200 2))))

;;; pink noise
(defun pink ()
  (setf params (list '(25600 -4 2.0) '(12800 -3 2.0) '(6400 -2 2.0) '(3200 -1 2.0)
    '(1600 0 2.0) '(800 1 2.0) '(400 2 2.0) '(200 3 2.0) '(100 4 2.0)
    '(50 5 2.0) '(25 6 2.0) '(12.5 7 2.0)))
    (force-srate *sound-srate*
      (sound-srate-abs 96000
        (progn
          (setf colour-noise (noise))
          (dotimes (i (length params))
            (setf colour-noise 
              (eq-band colour-noise
                (first (nth i params))
                (second (nth i params))
                (third (nth i params)))))
          (lowpass2 colour-noise 25600 0.5)))))

;;; crackle
(defun crackle (density)
  (defun clicks ()
    (let ((mynoise (mult 1.33 (lp (noise) 1000)))
          (density (max 
                     (- 0.9 density)
                     0.1)))
      (clip
        (mult (/ (- 1 density))
          (diff (s-max mynoise density) density))
        1.0)))
  (sum (clicks) (mult -1 (clicks))))

;;; mix two mono sounds
(defun mono-mix (snd1 snd2 mix)
  (sim (mult (- 1 mix) snd1)
    (mult mix snd2)))

;; select the type of noise
(setf my-noise 
  (case type
    (0 (noise))
    (1 (pink))
    (2 (crackle 0.4))
    (t (let ((gustiness 0.2)
             (wind-speed 0.2))
         (wind gustiness wind-speed)))))

; stereo mix sound and noise
(multichan-expand #'mono-mix s my-noise mix)

1 个答案:

答案 0 :(得分:0)

史蒂夫(Audacity论坛的网站管理员)为我编辑了代码。第9,13和58行需要更改。 Here's my post on the Audacity Forum.

;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
;name "Add Noise ..."
;action "Adding Selected Noise ..."
;info "by 'Steve Daulton.\nReleased under GPL V2."

;control level "Noise level (0 to 1)" real "" 0.5 0 1
;control type "Type of Noise" choice "White,Pink,Crackle,Wind" 0


(setf mix level)

;;; Wind noise by Robert J. H. 
(defun wind (gust speed)
  (defmacro contour (scale offset min-wind max-wind)
    `(sum ,offset 
       (mult ,scale 
         (s-abs (reson (noise) ,min-wind ,max-wind 1)))))
  (mult 2
    (contour 300 0.7 gust speed)
        (sim (reson (noise) 593 80 2)
             (reson (noise) (contour 300000 300 gust speed) 200 2))))

;;; pink noise
(defun pink ()
  (setf params (list '(25600 -4 2.0) '(12800 -3 2.0) '(6400 -2 2.0) '(3200 -1 2.0)
    '(1600 0 2.0) '(800 1 2.0) '(400 2 2.0) '(200 3 2.0) '(100 4 2.0)
    '(50 5 2.0) '(25 6 2.0) '(12.5 7 2.0)))
    (force-srate *sound-srate*
      (sound-srate-abs 96000
        (progn
          (setf colour-noise (noise))
          (dotimes (i (length params))
            (setf colour-noise 
              (eq-band colour-noise
                (first (nth i params))
                (second (nth i params))
                (third (nth i params)))))
          (lowpass2 colour-noise 25600 0.5)))))

;;; crackle
(defun crackle (density)
  (defun clicks ()
    (let ((mynoise (mult 1.33 (lp (noise) 1000)))
          (density (max 
                     (- 0.9 density)
                     0.1)))
      (clip
        (mult (/ (- 1 density))
          (diff (s-max mynoise density) density))
        1.0)))
  (sum (clicks) (mult -1 (clicks))))

;;; mix two mono sounds
(defun mono-mix (snd1 snd2 mix)
  (sim snd1
    (mult mix snd2)))

;; select the type of noise
(setf my-noise 
  (case type
    (0 (noise))
    (1 (pink))
    (2 (crackle 0.4))
    (t (let ((gustiness 0.2)
             (wind-speed 0.2))
         (wind gustiness wind-speed)))))

; stereo mix sound and noise
(multichan-expand #'mono-mix s my-noise mix)`