Skip to content

Commit 22019c4

Browse files
author
stevethefiddle@gmail.com
committed
Updated Vocal Remover GUI to current guidelines.
The effect is functionally identical to the previous version.
1 parent f02dec7 commit 22019c4

File tree

1 file changed

+143
-99
lines changed

1 file changed

+143
-99
lines changed

plug-ins/vocalremover.ny

+143-99
Original file line numberDiff line numberDiff line change
@@ -3,109 +3,153 @@
33
;type process
44
;preview enabled
55
;categories "http://lv2plug.in/ns/lv2core#UtilityPlugin"
6-
;name "Vocal Remover (for center-panned vocals)..."
7-
;action "Removing vocals or other center-panned audio..."
8-
;info "Removes center-panned audio in a stereo track by inversion and panning to center.\n\n'Simple' removal removes all the center-panned audio. If too much audio is removed,\ntry removing only selected frequencies - enter these in the box 'Frequency band\nlower and upper limit'. Then choose 'Remove band' to remove only frequencies in\nthat band, or 'Retain band' to remove only frequencies outside that band. After\nremoval, the audio will sound mono because both channels are panned to center.\n\nFor further help, select 'View Help' in the first dropdown menu and click OK. After\nreading Help, please reopen Vocal Remover to use it.\n"
9-
6+
;name "Vocal Remover..."
7+
;action "Removing center-panned audio..."
8+
;info "For reducing center-panned vocals"
9+
10+
;; This version of vocalremover.ny by Steve Daulton June 2013.
11+
;;
12+
;; based on Center pan Remover by David R. Sky November 12, 2004
13+
;; Modified by Gale Andrews January 2008 to make full spectrum removal
14+
;; the default, restore a single Help screen and restore error checking.
15+
;; Thanks to David Hostetler for notes in his own vocal remover plug-in,
16+
;; http://www.freelists.org/archives/audacity4blind/06-2006/msg00049.html
17+
;;
1018
;; Released under terms of the GNU General Public License version 2:
1119
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1220

1321
;control action "Remove vocals or view Help" choice "Remove vocals,View Help" 0
14-
;control bc "Removal choice" choice "Simple (entire spectrum),Remove frequency band,Retain frequency band" 0
15-
;control range "Frequency band lower and upper limit [Hz]\n [Enter two values between 0 and 20000]" string " " "500 2000"
16-
17-
; Center pan Remover by David R. Sky November 12, 2004
18-
; updated October/November 2007. Further modified by
19-
; Gale Andrews January 2008 to make full spectrum removal
20-
; the default, restore a single Help screen and restore error checking.
21-
; Ideally wants rewriting so that no error checking occurs when
22-
; default full spectrum removal selected.
23-
; Thanks to David Hostetler for notes in his own vocal remover plug-in,
24-
; which makes this plug-in more effective. See -
25-
; http://www.freelists.org/archives/audacity4blind/06-2006/msg00049.html
26-
27-
(cond ; either explain this effect or perform it
28-
((= action 1) ; display Help screen
29-
(format nil
30-
"Vocal Remover requires a stereo track. It works best with\nlossless files like like WAV or AIFF, rather than MP3 or\nother compressed formats. It only removes vocals or other\naudio that is panned to center (sounds equally loud in left\nand right). Vocals are often mixed this way. Inverting one\nchannel then panning both to center cancels out any audio\nwhich was originally center-panned, making it inaudible.\nThis can remove some parts of the audio you may want to\nkeep, such as drums, which are also often mixed to center.\nIf the vocals and other centered parts differ in pitch,\nthis can be solved by removing only selected frequencies.\n
31-
Vocal Remover thus has three choices of removal method.\n'Simple' inverts the entire frequency spectrum of one\nchannel. This may remove too much music if other parts of\nthe audio are centered as well as the vocals. In that case,\ntry the other choices. If the vocals are at a different\npitch than the other audio (such as a high female voice),\ntry 'Remove frequency band'. This only removes frequencies\nbetween a lower and upper limit which you can enter in the\n'Frequency band...' box. Experiment by entering what sounds\nlike the most significant frequency range of the original\nvocals. If the other choices remove too much audio in a\nparticular frequency range (such as low drums or bass), try\n'Retain frequency band'. This only removes frequencies\noutside the limits entered, retaining the others."))
32-
33-
34-
(t ; perform effect
35-
(defun string-to-list (str)
36-
(read (make-string-input-stream (format nil "(~a)" str))))
37-
38-
39-
(setf range (string-to-list range))
40-
41-
; initialize empty error-msg
42-
(setf error-msg "")
43-
44-
; Error-checking...
45-
;
46-
; check that selected audio is stereo
47-
(setf error-msg (if (arrayp s)
48-
error-msg
49-
(strcat error-msg (format nil
50-
"Error:\n\nVocal Remover requires an unsplit, stereo track.\n\nIf you have a stereo track split into left and right\nchannels, use 'Make Stereo Track' on the Track\nDropdown Menu, then run Vocal Remover again.
51-
"))))
52-
53-
54-
; Check there are two input frequency values given. If not and remove or retain band is selected,
55-
; ask to enter their required values. If not and 'Simple' removal selected, ask to enter any two values.
56-
(setf error-msg (if
57-
(and (> bc 0)
58-
(< (length range) 2))
59-
(strcat error-msg (format nil
60-
"Error:\n\nPlease enter both a lower and upper value for the\nfrequency band you want to remove or retain.\n\nBoth values must be between 0 and 20000.
61-
" (nth bc '("" ""))))
62-
63-
; are range values numbers?
64-
(if
65-
(or (not (numberp (first range))) (not (numberp (second range))))
66-
(strcat error-msg (format nil
67-
"To perform 'Simple' removal you can enter any\ntwo numbers (separated by a space) in the\n'Frequency band lower and upper limit' box.\nThe numbers entered don't affect the result.\n\nTo remove or retain a frequency band, enter\nlower and upper values for the band between\n0 and 20000.
68-
" (first range) (second range)))
69-
70-
; if 'Simple' removal not selected, throw error if both frequency values are not between 0 and 20000
71-
(if (or (= bc 0)
72-
(and
73-
(>= (first range) 0) (<= (first range) 20000)
74-
(>= (second range) 0) (<= (second range) 20000)))
75-
error-msg
76-
(strcat error-msg (format nil
77-
"Error:\n\n~aAt least one frequency value in your band is invalid. \nYou entered: ~a ~a\n\nBoth the lower and upper values must be between\n0 and 20000.
78-
"(nth bc '("" "" ""))
79-
(first range) (second range)))))))
80-
81-
82-
(cond
83-
((> (length error-msg) 0)
84-
(format nil "~a" error-msg))
85-
86-
(t ; no error msg
87-
(setf lower (min (first range) (second range)))
88-
(setf upper (max (first range) (second range)))
89-
90-
;; Temporary fix to keep frequencies within valid range (see bug 152)
91-
;; ToDo - fix this properly SD
92-
(setf lower (min (truncate (/ *sound-srate* 2.0)) lower))
93-
(setf upper (min (truncate (/ *sound-srate* 2.0)) upper))
22+
;control band-choice "Removal choice" choice "Simple (entire spectrum),Remove frequency band,Retain frequency band" 0
23+
;control low-range "Lower frequency band limit (Hz)" string " " "500"
24+
;control high-range "Upper frequency band limit (Hz)" string " " "2000"
25+
26+
27+
; Initialize globals
28+
(setf message "") ; empty output message
29+
30+
(defun help ()
31+
(format nil
32+
"Vocal Remover requires a stereo track. It works best with
33+
lossless files like WAV or AIFF, rather than MP3 or
34+
other compressed formats. It only removes vocals or other
35+
audio that is panned to center (sounds equally loud in left
36+
and right). Vocals may be mixed this way. Inverting one
37+
channel then panning both to center cancels out any audio
38+
which was originally center-panned, making it inaudible.
39+
This can remove some parts of the audio you may want to
40+
keep, such as drums, which are also often mixed to center.
41+
If the vocals and other centered parts differ in pitch,
42+
this can be solved by removing only selected frequencies.~%
43+
Vocal Remover thus has three choices of removal method.
44+
'Simple' inverts the entire frequency spectrum of one
45+
channel. This may remove too much music if other parts of
46+
the audio are centered as well as the vocals. In that case,
47+
try the other choices. If the vocals are at a different
48+
pitch than the other audio (such as a high female voice),
49+
try 'Remove frequency band'. This only removes frequencies
50+
between a lower and upper limit which you can enter in the
51+
'Frequency band...' boxes. Experiment by entering what
52+
sounds like the most significant frequency range of the
53+
original vocals. If the other choices remove too much
54+
audio in a particular frequency range (such as low drums
55+
or bass), try 'Retain frequency band'. This only removes
56+
frequencies outside the limits, retaining the others."))
9457

58+
(defun string-to-list (str)
59+
(read (make-string-input-stream (format nil "(~a)" str))))
60+
61+
62+
;;; ERROR CHECKING:
63+
64+
;; Check that selected audio is stereo
65+
(defun check-stereo ()
66+
(if (soundp s)
67+
(setf message (format nil
68+
"~%Vocal Remover requires an unsplit, stereo track.~%~
69+
If you have a stereo track split into left and right~%~
70+
channels, use 'Make Stereo Track' on the Track~%~
71+
Drop-Down Menu, then run Vocal Remover again.~%"))))
72+
73+
;;; Check that frequency range is valid
74+
(defun check-range ()
75+
(setq low-range (first (string-to-list low-range)))
76+
(setq high-range (first (string-to-list high-range)))
77+
(if (or (not (numberp low-range))
78+
(not (numberp high-range))
79+
(< low-range 0)
80+
(> low-range 20000)
81+
(< high-range 0)
82+
(> high-range 20000))
83+
(progn
84+
(if (= band-choice 1)
85+
(setf band-type "remove")
86+
(setf band-type "retain"))
87+
(setf message (format nil
88+
"~a~%~
89+
Enter both a lower and an upper limit for the~%~
90+
frequency band you want to ~a.~%~
91+
You entered: \"~a\" \"~a\"~%~%~
92+
Both values must be between 0 and 20000."
93+
message
94+
band-type
95+
low-range
96+
high-range)))
97+
;; Else ensure that high-range > low-range.
98+
(let ((temp low-range))
99+
(when (> low-range high-range)
100+
(setq low-range high-range)
101+
(setq high-range temp))))
102+
;; Range values must cannot be higher than Nyquist frequency.
103+
(setq low-range (min low-range (/ *sound-srate* 2)))
104+
(setq high-range (min high-range (/ *sound-srate* 2))))
105+
106+
107+
(defun show-message ()
108+
;; output to both message box and to debug window
109+
;; Copying from debug window is supported on all platforms.
110+
(when (= action 0) ; error
111+
(setf message (format nil "Error.~%~a" message)))
112+
(format t message)
113+
(format nil message))
114+
115+
116+
;;; DSP FUNCTIONS:
117+
118+
(defun bandpass (sig low high)
119+
(lowpass8
120+
(highpass8 sig low)
121+
high))
122+
123+
(defun bandstop (sig low high)
124+
(sum (lowpass8 sig low)
125+
(highpass8 sig high)))
126+
127+
(defun CentrePanRemove ()
128+
(cond
129+
((= band-choice 1) ; remove frequencies inside range
130+
(sum (aref s 0)
131+
(mult -1 (aref s 1))
132+
(bandstop (aref s 1) low-range high-range)))
133+
((= band-choice 2) ; remove frequencies outside range
134+
(sum (aref s 0)
135+
(mult -1 (aref s 1))
136+
(bandpass (aref s 1) low-range high-range)))
137+
(t ; invert and add right to left channel
138+
(sum (aref s 0)
139+
(mult -1 (aref s 1))))))
140+
141+
142+
;;; MAIN PROGRAM:
95143

96144
(cond
97-
((= bc 1) ; invert [delete] band of frequencies inside range
98-
(sum (aref s 0) (mult -1 (aref s 1))
99-
(highpass8 (aref s 1) upper)
100-
(lowpass8 (aref s 1) lower)))
101-
102-
((= bc 2) ; invert [delete] frequencies outside band range
103-
(sum (aref s 0) (mult -1 (aref s 1))
104-
(highpass8 (lowpass8 (aref s 1) upper) lower)))
105-
106-
(t ; invert one channel
107-
(sum (aref s 0) (mult -1 (aref s 1)))))
108-
) ; end t apply effect
109-
) ; end cond between display error msg or apply effect
110-
) ; end t perform effect
111-
) ; end cond explain effect or perform it
145+
((= action 1) ; Show help
146+
(setf message (help)))
147+
((= band-choice 0) ; Remove full spectrum
148+
(check-stereo))
149+
(t ; Remove band limited
150+
(check-stereo)
151+
(check-range)))
152+
153+
(if (= (length message) 0)
154+
(CentrePanRemove)
155+
(show-message))

0 commit comments

Comments
 (0)