1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

Bug 1341 - ENH: Vocal Remover effect should be removed - misleading and duplicated effectively

Updated vocal reduction and isolation by merging bug 1341 attachment into current version.
This commit is contained in:
James Crook 2019-07-17 10:59:05 +01:00
parent d18cfb097b
commit 5726d49e15
7 changed files with 36 additions and 167 deletions

View File

@ -84,7 +84,6 @@ nobase_dist_pkgdata_DATA = \
plug-ins/SpectralEditShelves.ny \ plug-ins/SpectralEditShelves.ny \
plug-ins/StudioFadeOut.ny \ plug-ins/StudioFadeOut.ny \
plug-ins/tremolo.ny \ plug-ins/tremolo.ny \
plug-ins/vocalremover.ny \
plug-ins/vocalrediso.ny \ plug-ins/vocalrediso.ny \
plug-ins/vocoder.ny \ plug-ins/vocoder.ny \
$(NULL) $(NULL)

View File

@ -602,7 +602,6 @@ nobase_dist_pkgdata_DATA = \
plug-ins/SpectralEditShelves.ny \ plug-ins/SpectralEditShelves.ny \
plug-ins/StudioFadeOut.ny \ plug-ins/StudioFadeOut.ny \
plug-ins/tremolo.ny \ plug-ins/tremolo.ny \
plug-ins/vocalremover.ny \
plug-ins/vocalrediso.ny \ plug-ins/vocalrediso.ny \
plug-ins/vocoder.ny \ plug-ins/vocoder.ny \
$(NULL) $(NULL)

View File

@ -6,24 +6,27 @@ $name (_ "Vocal Reduction and Isolation")
$manpage "Vocal_Reduction_and_Isolation" $manpage "Vocal_Reduction_and_Isolation"
$action (_ "Applying Action...") $action (_ "Applying Action...")
$author (_ "Robert Haenggi") $author (_ "Robert Haenggi")
$release 2.3.0 $release 2.3.3
$copyright (_ "Released under terms of the GNU General Public License version 2") $copyright (_ "Released under terms of the GNU General Public License version 2")
;;categories "http://lv2plug.in/ns/lv2core#MixerPlugin"
;; vocrediso.ny, based on rjh-stereo-tool.ny
;; ;;
;; Plug-in version 1.56, June 2015 ;; vocrediso.ny, based on rjh-stereo-tool.ny
;; Requires Audacity 2.1.1 or later, developed under Audacity 2.1.1
;; Released under terms of the GNU General Public License version 2: ;; Released under terms of the GNU General Public License version 2:
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html ;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
;; Plug-in version 1.7, May 2017
;; added legacy Vocal Remover since V. 1.56, 06-2015
;; Requires Audacity 2.1.1 or later, developed under Audacity 2.2.0 Alpha
;; requires Audacity 2.2.0 for embedded help (button)
;; ;;
;; For information about writing and modifying Nyquist plug-ins: ;; For information about writing and modifying Nyquist plug-ins:
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference ;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
$control action (_ "Action") choice ( $control action (_ "Action") choice (
("RemoveToMono" (_ "Remove Vocals: to mono"))
("Remove" (_ "Remove Vocals")) ("Remove" (_ "Remove Vocals"))
("Isolate" (_ "Isolate Vocals")) ("Isolate" (_ "Isolate Vocals"))
("IsolateInvert" (_ "Isolate Vocals and Invert")) ("IsolateInvert" (_ "Isolate Vocals and Invert"))
("RemoveCenterToMono" (_ "Remove Center: to mono"))
("RemoveCenter" (_ "Remove Center")) ("RemoveCenter" (_ "Remove Center"))
("IsolateCenter" (_ "Isolate Center")) ("IsolateCenter" (_ "Isolate Center"))
("IsolateCenterInvert" (_ "Isolate Center and Invert")) ("IsolateCenterInvert" (_ "Isolate Center and Invert"))
@ -33,11 +36,9 @@ $control action (_ "Action") choice (
$control strength (_ "Strength") real "" 1.0 0.0 50.0 $control strength (_ "Strength") real "" 1.0 0.0 50.0
$control low-transition (_ "Low Cut for Vocals (Hz)") real "" 120 1 24000 $control low-transition (_ "Low Cut for Vocals (Hz)") real "" 120 1 24000
$control high-transition (_ "High Cut for Vocals (Hz)") real "" 9000 1 24000 $control high-transition (_ "High Cut for Vocals (Hz)") real "" 9000 1 24000
;;control rotation "Rotation (Degrees)" real "" 0 -180 180 ;;control rotation "Rotation (Degrees)" real "" 0 -180 180
(setf rotation 0.0) (setf rotation 0.0)
;
;; make aref shorter ;; make aref shorter
(defmacro : (array index) (backquote (aref ,array ,index))) (defmacro : (array index) (backquote (aref ,array ,index)))
;; ;;
@ -179,6 +180,7 @@ bar-x bar-y s-xy s-x2 s-y2 (sqrt s-x2) (sqrt s-y2) r r2 (* s-y2 (- 1 r2)) a0 a1)
(power-dif (power-spectrum side fs 2)) (power-dif (power-spectrum side fs 2))
(wt-exp (s-exp (scale strength (diff power-dif power-sum)))) (wt-exp (s-exp (scale strength (diff power-dif power-sum))))
(weight (shape wt-exp *map* 0)) (weight (shape wt-exp *map* 0))
;(weight (shape (db-to-linear power-dif) (s-exp (mult 2 (s-log *map2*))) 1))
(weight (snd-samples weight ny:all))) (weight (snd-samples weight ny:all)))
(do ((i low-transition (+ i 2))) ((>= i high-transition)) (do ((i low-transition (+ i 2))) ((>= i high-transition))
(setf (: out i) (: weight (/ (1+ i) 2))) (setf (: out i) (: weight (/ (1+ i) 2)))
@ -192,7 +194,7 @@ bar-x bar-y s-xy s-x2 s-y2 (sqrt s-x2) (sqrt s-y2) r r2 (* s-y2 (- 1 r2)) a0 a1)
;; between the two speakers ;; between the two speakers
(defun transform (snd &optional ( cosine (cos (abs rotation))) (sine (sin (abs rotation)))) (defun transform (snd &optional ( cosine (cos (abs rotation))) (sine (sin (abs rotation))))
(let* ((direction (/ (+ 1e-15 rotation) (abs (+ 1e-15 rotation)))) (let* ((direction (/ (+ 1e-15 rotation) (abs (+ 1e-15 rotation))))
(fft-offset (s-rest (if (< action 6) (/ hop (get-duration *sr*)) 0))) (fft-offset (s-rest (if (< action 7) (/ hop (get-duration *sr*)) 0)))
(L (seq (cue fft-offset) (cue (: snd 0)))) (L (seq (cue fft-offset) (cue (: snd 0))))
(R (seq (cue fft-offset) (cue (: snd 1))))) (R (seq (cue fft-offset) (cue (: snd 1)))))
(vector (sum (mult cosine L) (mult (- direction) sine R)) (vector (sum (mult cosine L) (mult (- direction) sine R))
@ -204,28 +206,34 @@ bar-x bar-y s-xy s-x2 s-y2 (sqrt s-x2) (sqrt s-y2) r r2 (* s-y2 (- 1 r2)) a0 a1)
(if (soundp *track*) (return-from catalog (_ "This plug-in works only with stereo tracks.")) (if (soundp *track*) (return-from catalog (_ "This plug-in works only with stereo tracks."))
(setf snd (vector (snd-copy (: *track* 0)) (snd-copy (: *track* 1))))) (setf snd (vector (snd-copy (: *track* 0)) (snd-copy (: *track* 1)))))
(cond (cond
((= action 7) ((= action 8)
(return-from catalog (summary (least-squares-xy (: snd 0) (: snd 1) :show nil)))) (return-from catalog (summary (least-squares-xy (: snd 0) (: snd 1) :show nil))))
((= action 6) ((= action 0)
(display "" low-transition high-transition); values are quantized to bins
(return-from catalog
(sum (: snd 0) (mult -1 (: snd 1))
(sum (lowpass8 (: snd 1) low-transition)
(highpass8 (diff (: snd 1) (lowpass8 (: snd 1) low-transition)) high-transition)))))
((= action 4)
(return-from catalog (diff (: snd 0) (: snd 1)))) (return-from catalog (diff (: snd 0) (: snd 1))))
(t; For everything that involves center isolation (t; For everything that involves center isolation
(setf snd (transform snd)) (setf snd (transform snd))
(setf analyze-win (s-sqrt (fft-window fs type hop zs))) (setf analyze-win (s-sqrt (fft-window fs type hop zs)))
(setf synthesis-win analyze-win) (setf synthesis-win analyze-win)
(unless double-win (setf analyze-win (fft-window fs type hop zs)) (unless double-win (setf analyze-win (fft-window fs type hop zs))
(setf synthesis-win nil)) (setf synthesis-win nil))
(setf *win-sigma* (* fs (peak (integrate analyze-win) ny:all))) (setf *win-sigma* (* fs (peak (integrate analyze-win) ny:all)))
(setf sum-fft (stft (sum (: snd 0) (: snd 1)) fs hop analyze-win)) (setf sum-fft (stft (sum (: snd 0) (: snd 1)) fs hop analyze-win))
(setf dif-fft (stft (diff (: snd 0) (: snd 1)) fs hop analyze-win 'steer sum-fft)) (setf dif-fft (stft (diff (: snd 0) (: snd 1)) fs hop analyze-win 'steer sum-fft))
(setf c (snd-ifft 0 *sr* dif-fft hop synthesis-win )) (setf c (snd-ifft 0 *sr* dif-fft hop synthesis-win ))
(cond (cond
((member action '(0 3)) ((member action '(1 5))
(setf output (vector (extract-abs (/ hop *sr*) original-len (diff (: snd 0) c)) (setf output (vector (extract-abs (/ hop *sr*) original-len (diff (: snd 0) c))
(extract-abs (/ hop *sr*) original-len (diff (: snd 1) c))))) (extract-abs (/ hop *sr*) original-len (diff (: snd 1) c)))))
((member action '(1 4)) ((member action '(2 6))
(setf strength (recip strength)) (setf strength (recip strength))
(setf output (extract-abs (/ hop *sr*) original-len c))) (setf output (extract-abs (/ hop *sr*) original-len c)))
((member action '(2 5)) ((member action '(3 7))
(setf strength (recip strength)) (setf strength (recip strength))
(setf output (extract-abs (/ hop *sr*) original-len (mult -1 c))))))) (setf output (extract-abs (/ hop *sr*) original-len (mult -1 c)))))))
(if (soundp output) (setf output (vector output output))) (if (soundp output) (setf output (vector output output)))
@ -244,13 +252,21 @@ bar-x bar-y s-xy s-x2 s-y2 (sqrt s-x2) (sqrt s-y2) r r2 (* s-y2 (- 1 r2)) a0 a1)
;; Some input corrections ;; Some input corrections
(setf strength (expt (limit strength 0.02 50.0) 2.0)) (setf strength (expt (limit strength 0.02 50.0) 2.0))
; bins to be ignored (bass and treble) ; bins to be ignored (bass and treble)
(if (> action 2) (psetq low-transition 0.0 high-transition 24000.0)) (if (> action 3) (psetq low-transition 0.0 high-transition 24000.0))
(let* ((ltrans (logior (truncate (/ (* 2 fs (limit low-transition 1 (/ *sr* 2.0))) *sr*)) 1)) (let* ((ltrans (logior (truncate (/ (* 2 (1- fs) (limit low-transition 1 (/ *sr* 2.0))) *sr*)) 1))
(htrans (logior (limit (truncate (/ (* 2 fs high-transition) *sr*)) 1 (1- fs)) 1))) (htrans (logior (limit (truncate (/ (* 2 fs high-transition) *sr*)) 1 (1- fs)) 1)))
(psetq low-transition (min ltrans htrans) (psetq low-transition (min ltrans htrans)
high-transition (max ltrans htrans))) high-transition (max ltrans htrans)))
; back to real frequencies for the classic Vocal Remover
; Note: Fqs are quantized as if FFT would be used
; ca. 2.6 Hz bin-distance @ 44.1 kHz
(when (= action 0)
(setq bin-distance (/ *sr* 2.0 fs))
(psetq low-transition (* low-transition bin-distance)
high-transition (* high-transition bin-distance)))
;
(setf out (snd-samples (snd-const 0.0 0 fs fs) fs)); holds the left/right weights (removal) (setf out (snd-samples (snd-const 0.0 0 fs fs) fs)); holds the left/right weights (removal)
(setf *map* (snd-pwl 0 10000 (list 0 0.5 10000 0.0 20000 -0.5 20001))) (setf *map* (snd-pwl 0 10000 (list 0 0.5 10000 0.0 20000 -0.5 20001)))
(setf *norm* 1.0) (setf *norm* 1.0)
(expand 120); remove for lower efficiency/more conservative memory management (expand 120); remove for lower efficiency/more conservative memory management
(catalog) (catalog)

View File

@ -1,140 +0,0 @@
$nyquist plug-in
$version 4
$type process
$preview linear
$name (_ "Vocal Remover")
$manpage "Vocal_Remover"
$action (_ "Removing center-panned audio...")
$author (_ "Steve Daulton")
$release 2.3.0
$copyright (_ "Released under terms of the GNU General Public License version 2")
;; This version of vocalremover.ny by Steve Daulton June 2013.
;;
;; based on Center pan Remover by David R. Sky November 12, 2004
;; Modified by Gale Andrews January 2008 to make full spectrum removal
;; the default, restore a single Help screen and restore error checking.
;; Thanks to David Hostetler for notes in his own vocal remover plug-in,
;; http://www.freelists.org/archives/audacity4blind/06-2006/msg00049.html
;; Released under terms of the GNU General Public License version 2:
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
;;
;; For information about writing and modifying Nyquist plug-ins:
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
$control action (_ "Remove vocals or view Help") choice (
(_ "Remove Vocals")
(_ "View Help")
) 0
$control band-choice (_ "Removal choice") choice (
("Simple" (_ "Simple (Entire Spectrum)"))
("Remove" (_ "Remove Frequency Band"))
("Retain" (_ "Retain Frequency Band"))
) 0
$control low-range (_ "Frequency band from (Hz)") float-text "" 500 0 nil
$control high-range (_ "Frequency band to (Hz)") float-text "" 2000 0 nil
(defun help ()
(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
audio that is panned to center (sounds equally loud in left
and right). Vocals may be mixed this way. Inverting one
channel then panning both to center cancels out any audio
which was originally center-panned, making it inaudible.
This can remove some parts of the audio you may want to
keep, such as drums, which are also often mixed to center.
If the vocals and other centered parts differ in pitch,
this can be solved by removing only selected frequencies.~%
Vocal Remover thus has three choices of removal method.
'Simple' inverts the entire frequency spectrum of one
channel. This may remove too much music if other parts of
the audio are centered as well as the vocals. In that case,
try the other choices. If the vocals are at a different
pitch than the other audio (such as a high female voice),
try 'Remove frequency band'. This only removes frequencies
between a lower and upper limit which you can enter in the
'Frequency band...' boxes. Experiment by entering what
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."))))
(format t "~a" msg) ;print to debug (coppying supported on all platforms)
msg)) ;return message
(defun check-stereo ()
(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
;; to Nyquist frequency, so return NIL to disable.
`(if (or (< ,Hz 1)(> ,hz (- (/ *sound-srate* 2) 1)))
(setf ,Hz nil)))
;;; Ensure frequency range is valid
(defun check-range ()
;; Ensure min < max
(when (< high-range low-range)
(let ((temp low-range))
(setf low-range high-range)
(setf high-range temp)))
(validate low-range)
(validate high-range))
(defun bandpass (sig low high)
(cond
((and low high) ;bandpass
(lowpass8
(highpass8 sig low)
high))
(low (highpass8 sig low))
(high (lowpass8 sig high))
(t sig)))
(defun bandstop (sig low high)
(if (and low high (< (/ (- high low) low) 0.1))
(format t (_ "Warning:~%~
Selected band-stop filter is~%~
~a Hz to ~a Hz.~%~
A very narrow stop-band filter may have~%~
unexpected results.~%~%")
low high))
(let ((low-sig (if low (lowpass8 sig low)(s-rest 1))))
(sum
low-sig
(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 *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))))))
(if (= action 1)
(help)
(catch 'err (CentrePanRemove)))

View File

@ -46,7 +46,6 @@ const static wxChar *kShippedEffects[] =
wxT("StudioFadeOut.ny"), wxT("StudioFadeOut.ny"),
wxT("tremolo.ny"), wxT("tremolo.ny"),
wxT("vocalrediso.ny"), wxT("vocalrediso.ny"),
wxT("vocalremover.ny"),
wxT("vocoder.ny"), wxT("vocoder.ny"),
}; };

View File

@ -940,7 +940,6 @@
<copy Include="..\..\..\plug-ins\StudioFadeOut.ny" /> <copy Include="..\..\..\plug-ins\StudioFadeOut.ny" />
<copy Include="..\..\..\plug-ins\tremolo.ny" /> <copy Include="..\..\..\plug-ins\tremolo.ny" />
<copy Include="..\..\..\plug-ins\vocalrediso.ny" /> <copy Include="..\..\..\plug-ins\vocalrediso.ny" />
<copy Include="..\..\..\plug-ins\vocalremover.ny" />
<copy Include="..\..\..\plug-ins\vocoder.ny" /> <copy Include="..\..\..\plug-ins\vocoder.ny" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -2644,9 +2644,6 @@
<copy Include="..\..\..\plug-ins\tremolo.ny"> <copy Include="..\..\..\plug-ins\tremolo.ny">
<Filter>plug-ins</Filter> <Filter>plug-ins</Filter>
</copy> </copy>
<copy Include="..\..\..\plug-ins\vocalremover.ny">
<Filter>plug-ins</Filter>
</copy>
<copy Include="..\..\..\plug-ins\vocoder.ny"> <copy Include="..\..\..\plug-ins\vocoder.ny">
<Filter>plug-ins</Filter> <Filter>plug-ins</Filter>
</copy> </copy>
@ -2686,4 +2683,4 @@
<Filter>Resources</Filter> <Filter>Resources</Filter>
</Manifest> </Manifest>
</ItemGroup> </ItemGroup>
</Project> </Project>