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/StudioFadeOut.ny \
plug-ins/tremolo.ny \
plug-ins/vocalremover.ny \
plug-ins/vocalrediso.ny \
plug-ins/vocoder.ny \
$(NULL)

View File

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

View File

@ -6,24 +6,27 @@ $name (_ "Vocal Reduction and Isolation")
$manpage "Vocal_Reduction_and_Isolation"
$action (_ "Applying Action...")
$author (_ "Robert Haenggi")
$release 2.3.0
$release 2.3.3
$copyright (_ "Released under terms of the GNU General Public License version 2")
;; vocrediso.ny, based on rjh-stereo-tool.ny
;;categories "http://lv2plug.in/ns/lv2core#MixerPlugin"
;;
;; Plug-in version 1.56, June 2015
;; Requires Audacity 2.1.1 or later, developed under Audacity 2.1.1
;; vocrediso.ny, based on rjh-stereo-tool.ny
;; Released under terms of the GNU General Public License version 2:
;; 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:
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
$control action (_ "Action") choice (
("RemoveToMono" (_ "Remove Vocals: to mono"))
("Remove" (_ "Remove Vocals"))
("Isolate" (_ "Isolate Vocals"))
("IsolateInvert" (_ "Isolate Vocals and Invert"))
("RemoveCenterToMono" (_ "Remove Center: to mono"))
("RemoveCenter" (_ "Remove Center"))
("IsolateCenter" (_ "Isolate Center"))
("IsolateCenterInvert" (_ "Isolate Center and Invert"))
@ -33,11 +36,9 @@ $control action (_ "Action") choice (
$control strength (_ "Strength") real "" 1.0 0.0 50.0
$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 rotation "Rotation (Degrees)" real "" 0 -180 180
(setf rotation 0.0)
;
;; make aref shorter
(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))
(wt-exp (s-exp (scale strength (diff power-dif power-sum))))
(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)))
(do ((i low-transition (+ i 2))) ((>= i high-transition))
(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
(defun transform (snd &optional ( cosine (cos (abs rotation))) (sine (sin (abs 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))))
(R (seq (cue fft-offset) (cue (: snd 1)))))
(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."))
(setf snd (vector (snd-copy (: *track* 0)) (snd-copy (: *track* 1)))))
(cond
((= action 7)
((= action 8)
(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))))
(t; For everything that involves center isolation
(setf snd (transform snd))
(setf analyze-win (s-sqrt (fft-window fs type hop zs)))
(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 *win-sigma* (* fs (peak (integrate analyze-win) ny:all)))
(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 c (snd-ifft 0 *sr* dif-fft hop synthesis-win ))
(cond
((member action '(0 3))
((member action '(1 5))
(setf output (vector (extract-abs (/ hop *sr*) original-len (diff (: snd 0) c))
(extract-abs (/ hop *sr*) original-len (diff (: snd 1) c)))))
((member action '(1 4))
((member action '(2 6))
(setf strength (recip strength))
(setf output (extract-abs (/ hop *sr*) original-len c)))
((member action '(2 5))
((member action '(3 7))
(setf strength (recip strength))
(setf output (extract-abs (/ hop *sr*) original-len (mult -1 c)))))))
(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
(setf strength (expt (limit strength 0.02 50.0) 2.0))
; bins to be ignored (bass and treble)
(if (> action 2) (psetq low-transition 0.0 high-transition 24000.0))
(let* ((ltrans (logior (truncate (/ (* 2 fs (limit low-transition 1 (/ *sr* 2.0))) *sr*)) 1))
(if (> action 3) (psetq low-transition 0.0 high-transition 24000.0))
(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)))
(psetq low-transition (min 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 *map* (snd-pwl 0 10000 (list 0 0.5 10000 0.0 20000 -0.5 20001)))
(setf *norm* 1.0)
(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("tremolo.ny"),
wxT("vocalrediso.ny"),
wxT("vocalremover.ny"),
wxT("vocoder.ny"),
};

View File

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

View File

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