mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-12 07:35:51 +01:00
Update Vocal Remover to v4 and fix messages
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
;nyquist plug-in
|
;nyquist plug-in
|
||||||
;version 3
|
;version 4
|
||||||
;type process
|
;type process
|
||||||
;preview linear
|
;preview linear
|
||||||
;categories "http://lv2plug.in/ns/lv2core#UtilityPlugin"
|
|
||||||
;name "Vocal Remover..."
|
;name "Vocal Remover..."
|
||||||
;action "Removing center-panned audio..."
|
;action "Removing center-panned audio..."
|
||||||
;info "For reducing center-panned vocals"
|
;info "For reducing center-panned vocals"
|
||||||
@@ -26,11 +25,8 @@
|
|||||||
;control high-range "Frequency band to (Hz)" float-text "" 2000 0 nil
|
;control high-range "Frequency band to (Hz)" float-text "" 2000 0 nil
|
||||||
|
|
||||||
|
|
||||||
; Initialize globals
|
|
||||||
(setf message "") ; empty output message
|
|
||||||
|
|
||||||
(defun help ()
|
(defun help ()
|
||||||
(format nil
|
(let ((msg (format nil
|
||||||
"Vocal Remover requires a stereo track. It works best with
|
"Vocal Remover requires a stereo track. It works best with
|
||||||
lossless files like WAV or AIFF, rather than MP3 or
|
lossless files like WAV or AIFF, rather than MP3 or
|
||||||
other compressed formats. It only removes vocals or other
|
other compressed formats. It only removes vocals or other
|
||||||
@@ -55,27 +51,26 @@ sounds like the most significant frequency range of the
|
|||||||
original vocals. If the other choices remove too much
|
original vocals. If the other choices remove too much
|
||||||
audio in a particular frequency range (such as low drums
|
audio in a particular frequency range (such as low drums
|
||||||
or bass), try 'Retain frequency band'. This only removes
|
or bass), try 'Retain frequency band'. This only removes
|
||||||
frequencies outside the limits, retaining the others."))
|
frequencies outside the limits, retaining the others.")))
|
||||||
|
(format t "~a" msg) ;print to debug (coppying supported on all platforms)
|
||||||
|
msg)) ;return message
|
||||||
|
|
||||||
|
|
||||||
;;; ERROR CHECKING:
|
|
||||||
|
|
||||||
;; Check that selected audio is stereo
|
|
||||||
(defun check-stereo ()
|
(defun check-stereo ()
|
||||||
(if (soundp s)
|
(when (soundp *track*)
|
||||||
(setf message (format nil
|
(throw 'err (format nil
|
||||||
"~%Vocal Remover requires an unsplit, stereo track.~%~
|
"~%Vocal Remover requires an unsplit, stereo track.~%~
|
||||||
If you have a stereo track split into left and right~%~
|
If you have a stereo track split into left and right~%~
|
||||||
channels, use 'Make Stereo Track' on the Track~%~
|
channels, use 'Make Stereo Track' on the Track~%~
|
||||||
Drop-Down Menu, then run Vocal Remover again.~%"))))
|
Drop-Down Menu, then run Vocal Remover again.~%"))))
|
||||||
|
|
||||||
(defmacro validate (Hz)
|
(defmacro validate (Hz)
|
||||||
;; Filters become unstable when very close to 0 Hz or
|
;; Filters become unstable when very close to 0 Hz or
|
||||||
;; Nyquist frequency, so disable.
|
;; to Nyquist frequency, so return NIL to disable.
|
||||||
`(if (or (< ,Hz 1)(> ,hz (- (/ *sound-srate* 2) 1)))
|
`(if (or (< ,Hz 1)(> ,hz (- (/ *sound-srate* 2) 1)))
|
||||||
(setf ,Hz nil)))
|
(setf ,Hz nil)))
|
||||||
|
|
||||||
;;; Check that frequency range is valid
|
;;; Ensure frequency range is valid
|
||||||
(defun check-range ()
|
(defun check-range ()
|
||||||
;; Ensure min < max
|
;; Ensure min < max
|
||||||
(when (< high-range low-range)
|
(when (< high-range low-range)
|
||||||
@@ -85,17 +80,6 @@ frequencies outside the limits, retaining the others."))
|
|||||||
(validate low-range)
|
(validate low-range)
|
||||||
(validate high-range))
|
(validate high-range))
|
||||||
|
|
||||||
(defun show-message ()
|
|
||||||
;; output to both message box and to debug window
|
|
||||||
;; Copying from debug window is supported on all platforms.
|
|
||||||
(when (= action 0) ; error
|
|
||||||
(setf message (format nil "Error.~%~a" message)))
|
|
||||||
(format t message)
|
|
||||||
(format nil message))
|
|
||||||
|
|
||||||
|
|
||||||
;;; DSP FUNCTIONS:
|
|
||||||
|
|
||||||
(defun bandpass (sig low high)
|
(defun bandpass (sig low high)
|
||||||
(cond
|
(cond
|
||||||
((and low high) ;bandpass
|
((and low high) ;bandpass
|
||||||
@@ -107,7 +91,7 @@ frequencies outside the limits, retaining the others."))
|
|||||||
(t sig)))
|
(t sig)))
|
||||||
|
|
||||||
(defun bandstop (sig low high)
|
(defun bandstop (sig low high)
|
||||||
(if (< (/ (- high low) low) 0.1)
|
(if (and low high (< (/ (- high low) low) 0.1))
|
||||||
(format t "Warning:~%~
|
(format t "Warning:~%~
|
||||||
Selected band-stop filter is~%~
|
Selected band-stop filter is~%~
|
||||||
~a Hz to ~a Hz.~%~
|
~a Hz to ~a Hz.~%~
|
||||||
@@ -120,31 +104,26 @@ frequencies outside the limits, retaining the others."))
|
|||||||
(if high (highpass8 (diff sig low-sig) high)(s-rest 1)))))
|
(if high (highpass8 (diff sig low-sig) high)(s-rest 1)))))
|
||||||
|
|
||||||
(defun CentrePanRemove ()
|
(defun CentrePanRemove ()
|
||||||
|
(check-stereo)
|
||||||
|
(check-range)
|
||||||
(cond
|
(cond
|
||||||
((= band-choice 1) ; remove frequencies inside range
|
((= band-choice 1) ; remove frequencies inside range
|
||||||
(sum (aref s 0)
|
(sum (aref *track* 0)
|
||||||
(mult -1 (aref s 1))
|
(mult -1 (aref *track* 1))
|
||||||
(bandstop (aref s 1) low-range high-range)))
|
(bandstop (aref *track* 1) low-range high-range)))
|
||||||
((= band-choice 2) ; remove frequencies outside range
|
; Nothing to remove - skip effect.
|
||||||
(sum (aref s 0)
|
((and (= band-choice 2)(not low-range)(not high-range))
|
||||||
(mult -1 (aref s 1))
|
(format t "Current settings returned the original audio.")
|
||||||
(bandpass (aref s 1) low-range high-range)))
|
nil)
|
||||||
(t ; invert and add right to left channel
|
((= band-choice 2) ; remove frequencies inside range
|
||||||
(sum (aref s 0)
|
(sum (aref *track* 0)
|
||||||
(mult -1 (aref s 1))))))
|
(mult -1 (aref *track* 1))
|
||||||
|
(bandpass (aref *track* 1) low-range high-range)))
|
||||||
|
(t ; invert and add right to left channel
|
||||||
|
(sum (aref *track* 0)
|
||||||
|
(mult -1 (aref *track* 1))))))
|
||||||
|
|
||||||
|
|
||||||
;;; MAIN PROGRAM:
|
(if (= action 1)
|
||||||
|
(help)
|
||||||
(cond
|
(catch 'err (CentrePanRemove)))
|
||||||
((= action 1) ; Show help
|
|
||||||
(setf message (help)))
|
|
||||||
((= band-choice 0) ; Remove full spectrum
|
|
||||||
(check-stereo))
|
|
||||||
(t ; Remove band limited
|
|
||||||
(check-stereo)
|
|
||||||
(check-range)))
|
|
||||||
|
|
||||||
(if (= (length message) 0)
|
|
||||||
(CentrePanRemove)
|
|
||||||
(show-message))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user