Update Vocal Remover to v4 and fix messages

This commit is contained in:
Steve Daulton 2016-01-11 13:07:30 +00:00
parent 57d1f5583d
commit c5943413b9
1 changed files with 34 additions and 55 deletions

View File

@ -1,8 +1,7 @@
;nyquist plug-in
;version 3
;version 4
;type process
;preview linear
;categories "http://lv2plug.in/ns/lv2core#UtilityPlugin"
;name "Vocal Remover..."
;action "Removing center-panned audio..."
;info "For reducing center-panned vocals"
@ -26,11 +25,8 @@
;control high-range "Frequency band to (Hz)" float-text "" 2000 0 nil
; Initialize globals
(setf message "") ; empty output message
(defun help ()
(format nil
(let ((msg (format nil
"Vocal Remover requires a stereo track. It works best with
lossless files like WAV or AIFF, rather than MP3 or
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
audio in a particular frequency range (such as low drums
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 ()
(if (soundp s)
(setf message (format nil
"~%Vocal Remover requires an unsplit, stereo track.~%~
If you have a stereo track split into left and right~%~
channels, use 'Make Stereo Track' on the Track~%~
Drop-Down Menu, then run Vocal Remover again.~%"))))
(when (soundp *track*)
(throw 'err (format nil
"~%Vocal Remover requires an unsplit, stereo track.~%~
If you have a stereo track split into left and right~%~
channels, use 'Make Stereo Track' on the Track~%~
Drop-Down Menu, then run Vocal Remover again.~%"))))
(defmacro validate (Hz)
;; 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)))
(setf ,Hz nil)))
;;; Check that frequency range is valid
;;; Ensure frequency range is valid
(defun check-range ()
;; Ensure min < max
(when (< high-range low-range)
@ -85,17 +80,6 @@ frequencies outside the limits, retaining the others."))
(validate low-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)
(cond
((and low high) ;bandpass
@ -107,7 +91,7 @@ frequencies outside the limits, retaining the others."))
(t sig)))
(defun bandstop (sig low high)
(if (< (/ (- high low) low) 0.1)
(if (and low high (< (/ (- high low) low) 0.1))
(format t "Warning:~%~
Selected band-stop filter is~%~
~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)))))
(defun CentrePanRemove ()
(check-stereo)
(check-range)
(cond
((= band-choice 1) ; remove frequencies inside range
(sum (aref s 0)
(mult -1 (aref s 1))
(bandstop (aref s 1) low-range high-range)))
((= band-choice 2) ; remove frequencies outside range
(sum (aref s 0)
(mult -1 (aref s 1))
(bandpass (aref s 1) low-range high-range)))
(t ; invert and add right to left channel
(sum (aref s 0)
(mult -1 (aref s 1))))))
((= band-choice 1) ; remove frequencies inside range
(sum (aref *track* 0)
(mult -1 (aref *track* 1))
(bandstop (aref *track* 1) low-range high-range)))
; Nothing to remove - skip effect.
((and (= band-choice 2)(not low-range)(not high-range))
(format t "Current settings returned the original audio.")
nil)
((= band-choice 2) ; remove frequencies inside range
(sum (aref *track* 0)
(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:
(cond
((= 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))
(if (= action 1)
(help)
(catch 'err (CentrePanRemove)))