Hello,
Recently I created a chain in Audacity that will only fade 0.001 seconds of audio in, and leave the rest alone. I.e. For the first 0.001 seconds the audio will fade in. I’ve also created another chain whereby the last 0.001 seconds fade out. But there’s a problem I’m having. I use the Fade IO.ny plugin. When I apply the chain to only fade in the first 0.001 seconds of audio, there is a horrendous click that occurs at the end of the selection, even though I told the plugin not to do anything at the end. What is this click caused by? I’ll get the code for both the plugin and the chain below.
Plugin:
;nyquist plug-in
;version 2
;type process
;name "Fade In and Out..."
;action "Fading in and out..."
;info "Fade In and Out by David R. Sky"
;control in "Fade in time" real "seconds" 1.00 0.00 30.00
;control out "Fade out time" real "seconds" 1.00 0.00 30.00
; Fade In and Out by David R. Sky, October 22, 2004
; set duration of selection in seconds
(setf dur (/ len *sound-srate*))
; set in and out as percentages of duration
(setf in (/ in dur))
(setf out (/ out dur))
; set percentage of dur that has gone by for start of fade out
(setf out (- 1.0 out))
; PWL treats time as not seconds, but percentages of selection.
(mult (pwl in 1 out 1 1 0) s)
And the chain
FadeInAndOut…: in=0.001000 out=0.000000
So this chain only tells the fade plugin to only fade in the first 0.001 seconds of audio. However, after the end of the selection, there’s a click. I’m trying to get rid of this stupid click. I’ve tried to modify the plugin, but to no avail. I hope you can help. Thanks
Are you applying the Chain (hence applying the effect) to a selection in the current project (rather than batch processing files)?
If so, then the problem is that the plug-in code that you have posted will always fade out at the end of the selection, even if the fade-out time is set to zero, which can cause a discontinuity like this (zoomed in very close on the end of the selection):
The reason this occurs is because the amplitude envelope, created by the PWL function, has a low sample rate. By default, Nyquist creates control signals at a sample rate of 1/20th of the sound sample rate. Because the PWL function always ends with an amplitude of zero, this translates to a fade-out over the final 20 samples of the selected sound.
The simplest solution is to set the “control rate” (sample rate of control signals) to the same rate as the sound sample rate. This will ensure that the gain envelope remains at the correct level right up to the very last sample (and the theoretical fade to zero is less than one sample, so it does not occur).
Here’s a simplified and updated version that should avoid the problem:
;nyquist plug-in
;version 4
;type process
;name "Fade In and Out..."
;action "Fading in and out..."
;author "David R. Sky and Steve Daulton"
;copyright "Released under terms of the GNU General Public License version 2"
;control in "Fade in time" float "seconds" 1 0 30
;control out "Fade out time" float "seconds" 1 0 30
;; IN and OUT as proportion of duration
(let ((in (/ in (get-duration 1)))
(out (- 1 (/ out (get-duration 1)))))
(setf *control-srate* *sound-srate*)
(mult (pwl in 1 out 1 1 0) *track*))