Nyquist-Audacity-Convolution-Plugin

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.
Post Reply
dlpoole
Posts: 3
Joined: Wed May 16, 2018 6:03 pm
Operating System: Linux *buntu

Nyquist-Audacity-Convolution-Plugin

Post by dlpoole » Tue May 22, 2018 5:02 pm

Nyquist-Audacity-Convolution-Plugin

This plug-in convolves the two channels of a selection from a stereo track, overwriting both channels of the source track. A typical application is for one channel to contain a monaural audio sample and the other an impulse response representing a reverberant environment into which it is to be placed.

There are some limitations:

Audacity imposes a memory limit on the Nyquist (convolve) function; experimentally, this results in a 20 second limit on the selection at 48KHz sample rate. Attempts to convolve longer selections throw a table limit error that will be found in the Debug window.

Audacity applies a common selection to both channels of the selection. It will probably be necessary to prepare separate monaural tracks of your source audio and impulse response, time align them, then combine them into a stereo track to convolve. Audacity forces both the sample and the impulse, if shorter, to the length of the selection, so the convolved track will have twice the length of the original selection and will overwrite it so as to contain the "tail" of the impulse response.

(convolution) took 8 minutes to process a 10-second audio selection and impulse function at 48KHz sampling rate on a Dell laptop with an i5-5200U CPU.

Convolution is prone to overflow, so you may wish to set the input coefficients to 20%, convolve a short but high amplitude portion of your source material including the entire impulse response, then adjust the input coefficients before you commit to a 15-minute run. You can always UNDO a clipped result to get your raw material back for another try. Attempts to convolve a monaural track, convolve between tracks, or convolve selections with unmatched sample rates will also throw an error.

Code: Select all

;nyquist plug-in
;version 3
;type process
;name "Channel Convolver..."
;action "Convolving..."
;preview "enabled"
;author "Dave Poole"
;copyright "Released under terms of the GNU General Public License version 2" 
;;  v0.1 14-May-2018
;; http://www.gnu.org/copyleft/gpl.html

;control left-input-scale "Input Scale Factors\nLeft channel (%)" float "" 50 0 100
;control right-input-scale "   Right channel (%)" float "" 50 0 100

;; Create list of values from the slider values
(setq channels (list left-input-scale right-input-scale))

; Print settings to debug window	  
(format T "Convolution of:~%Left mix = ~a %~%Right mix = ~a %\n"
(nth 0 channels)(nth 1 channels))

; convert percent to +/- 1
(setf channels (mapcar #'(lambda (num) (/ num 100.0)) channels))

; convolve and output as (two channel monoaural) vector
(if (arrayp s) ; check for stereo track
		(convolve
			(mult (aref s 0)(nth 0 channels))
			(mult (aref s 1)(nth 1 channels)))
; or error if not stereo
	(format NIL "Error\nChannel Convolver convolves stereo channels"))
Attachments
Channel-Convolver.ny
(1.02 KiB) Downloaded 101 times

kozikowski
Forum Staff
Posts: 41754
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: OS X 10.9 Mavericks

Re: Nyquist-Audacity-Convolution-Plugin

Post by kozikowski » Tue May 22, 2018 6:06 pm

There are some limitations:
Actually, there are one or two more.

It is very strongly recommended that the user make safety WAV copies of any work before they press [OK] on any effect or filter. Nothing like having a computer or Audacity problem trash the only clean copy of the performance.

I noticed you carefully avoided the phrase "gets rid of echoes." Not that a convolver doesn't do that. It does, but the conditions don't lend themselves to the casual user trying to produce a podcast in the kitchen—and then correcting all the echoes solely in post production.

I think you described another shortcoming in your text. The impulse (walk out and clap, right?) has to be perfect. No peak distortion. Zero. The impulse has to be in as clear condition as the performance.

The impulse has to be produced in the exact conditions as the performance. So no fair clapping in an empty hall ahead of a live reading to a full house.

I know you understand these conditions, but we play to a lot of first-time users.

"How can I get rid of echoes/reverb in my [some bad environment] recording?" It's important!"


What do you recommend to produce the impulse if clapping doesn't do it for you? This is your opportunity to market an impulse generator.

"Can't use your Convolver without an Impulse Generator®!"

Koz

steve
Site Admin
Posts: 49424
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Nyquist-Audacity-Convolution-Plugin

Post by steve » Tue May 22, 2018 10:39 pm

dlpoole wrote:(convolution) took 8 minutes to process a 10-second audio selection and impulse function at 48KHz sampling rate on a Dell laptop with an i5-5200U CPU.
The latest version of Nyquist (not yet in Audacity, but available here: http://www.cs.cmu.edu/afs/cs.cmu.edu/pr ... tware.html) has a new "fast convolution" primitive, which is very, very much faster. I've just tested with a 20 second impulse, and it can process faster than real time (tested on a reasonably quick laptop).

I'm hoping that this will be available in Audacity in the not too distant future, though it is unlikely to be in the next release.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

dlpoole
Posts: 3
Joined: Wed May 16, 2018 6:03 pm
Operating System: Linux *buntu

Re: Nyquist-Audacity-Convolution-Plugin

Post by dlpoole » Wed May 23, 2018 4:24 am

I avoided any promise of deconvolution as I think the practical problems are too great for anything but trivial cases. See https://en.wikipedia.org/wiki/Deconvolution. The podcast guy is better to record with a Voxguard or the like in the first place or tweak his recording to taste in the frequency domain afterward.

I consider auralization something of a curiosity, but once used convolutions with captured and estimated impulse responses to dispel a fear that pew cushions would noticeably impair the performance of a pipe organ in a Sanctuary that was too small for it anyway. Ultimately, they didn't.

For lack of commercial instrumentation, a hand clap can tell you a lot, particularly what you'd rather not know about a bad room. I've also obtained reasonable simulations of church sanctuaries with balloon pop impulses. Although I thought of that as an amateur technique for lack of commercial instrumentation, I was recently surprised to find that some serious research has been done on the subject https://asa.scitation.org/doi/10.1121/1.3518780 A pull-string firecracker (where legal as they are in Indiana) probably comes closer to theoretical - at least it exhibits more uniform spectra and is (just barely) loud enough to get down to RT60 with a quiet mic and preamp in a quiet room. Microphone dynamic range requires separation between the source and record positions to avoid clipping and introducing a microphone's own, and highly nonlinear, impulse response. The results then apply only to those same positions and don't necessarily capture how bad a room can be in others.

I wrote this plug-in for my own convenience of experimenting in Audacity. As long as one doesn't expect too much, it can be a fun tool.

Giovani
Posts: 52
Joined: Wed Mar 16, 2011 7:07 pm
Operating System: Windows 10

Re: Nyquist-Audacity-Convolution-Plugin

Post by Giovani » Sat Dec 01, 2018 4:08 pm

Due to those limitations, I love this plugin. I hope, that It'll be better.

dlpoole
Posts: 3
Joined: Wed May 16, 2018 6:03 pm
Operating System: Linux *buntu

Re: Nyquist-Audacity-Convolution-Plugin

Post by dlpoole » Mon Jan 14, 2019 11:09 pm

Koz,

Thanks for your prior comments. I needed this again and had to return to the forum to re-download it. After a rebuild, I had reinstalled Audacity from a snap and couldn't figure out where to put the plug-in. I removed it and reinstalled Audacity from a repo then installed the plugin.

You're right about the quality of the impulse for auralization. My preferred impulse source is the "string popper" firecracker, which is legal in Indiana. With a quiet mic and preamp and HVAC, etc. quieted in the venue, one firecracker can create barely enough pressure to reach RT60 in a 10,000 sq ft space. I suppose one could pull several of them simultaneously to get more. The direct impulse will overload any mic, so the mic's own recovery must be trimmed from the recorded impulse response. If the nearest single reflection is at least as far away as the direct path from the firecracker to the mic, the trim should have minimal effect.

'Good to see that the convolver still works.

Dave

Post Reply