AGC - Automatic Gain Control

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.

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by greyham » Tue Jan 27, 2015 9:31 am

I've noticed that this plugin seems to slow down exponentially according to the length of the selection being processed. Applying it 6 times to successive 10 minute selections of an hour long audio file is much, much faster than applying it to a one hour selection... which takes forever. Anyone else noticed this?
greyham
 
Posts: 2
Joined: Fri Jan 23, 2015 10:11 pm
Operating System: Please select

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by waxcylinder » Tue Jan 27, 2015 10:07 am

No. cos I don't use that

But this segmentation idea is a cute trick that I'm going to try out on the Noise Removal (actually I'm using the new Noise Reduction in the alpha test versions) as I use that a lot.

What you may have to look out for is that you don't create a discontinuity at the segment boundaries - which will likely be heard as a click.

Thanks for that idea :idea:

WC
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * * Audacity Wiki * * * * *
waxcylinder
Forum Staff
 
Posts: 9083
Joined: Tue Jul 31, 2007 11:03 am
Location: Manchester, UK
Operating System: Windows 10

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by Gale Andrews » Tue Jan 27, 2015 5:46 pm

greyham wrote:I've noticed that this plugin seems to slow down exponentially according to the length of the selection being processed. Applying it 6 times to successive 10 minute selections of an hour long audio file is much, much faster than applying it to a one hour selection... which takes forever. Anyone else noticed this?

I expect that is because the selection is loaded into RAM. I would not expect that "segmentation" to provide so much benefit with a built-in effect.

Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 26089
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by Nicholas K. » Tue Feb 23, 2016 9:26 am

I've done some changes to the plugin to make it works with long sounds. Now it takes about 3 minutes for 100 minutes mono record on phenom x6. I am new with Nyquist so code review would be appreciated.
Attachments
agc-new.ny
New agc plugin
(2.92 KiB) Downloaded 100 times
Nicholas K.
 
Posts: 2
Joined: Tue Feb 23, 2016 9:15 am
Operating System: Linux Fedora/RHEL

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by steve » Tue Feb 23, 2016 6:03 pm

Nice :)
You've correctly identified where the slowdown occurs, and fixed it.

In a "DO" statement, the return value is optional. In line 73:
Code: Select all
((>= start duration) T)

the "T" is superfluous. You can use:
Code: Select all
((>= start duration))


Generally it's better to avoid single character names for variables. Short but descriptive names are nice and definitely help with bug fixing if you have to come back to the code 6 month or more after you've written it.

Now that the "window" function is not really a "window function", it may be better to rename it.

I also wonder whether, with your new approach to the task, whether amplifying each "window" by a constant gain gives the best results. Perhaps worth looking at whether the results are better if the "gains" controls extrapolate linearly from one gain level to the next rather than moving in "steps".

Using the raised cosine window (in the original code) was really just a quick and dirty way to smooth the gain changes (and it works surprisingly well). It could be worth looking at other ways. One method that is commonly used is for gain increases to be linear and gain reductions to be exponential. I recall that another Nyquist compressor effect fits parabolic curves to the peak measurements, then uses the curve as the variable gain control.

Probably worth noting that even with your (good) optimization, there is still a practical limit to the length of audio that may be processed in one go (look at memory usage while a long selection is processed). We don't yet have a good solution for that (see this post for background information about this issue: viewtopic.php?p=299293#p299293).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45316
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by Nicholas K. » Sat Feb 27, 2016 2:12 pm

steve wrote:Probably worth noting that even with your (good) optimization, there is still a practical limit to the length of audio that may be processed in one go (look at memory usage while a long selection is processed). We don't yet have a good solution for that (see this post for background information about this issue: viewtopic.php?p=299293#p299293).

Sure there is the limit. It caused not only memory limit for the Nyquist library but also memory leaks in Nyquist. I had to process two dozens of tracks and saw dramatically Nyquist slow down over steps of the batch with continuous growth of memory use till some limit. And the memory was not released after the batch was finished.

Thanks for the audio processing tips. I already thought that the cosine "windows" are some sort of interpolation and smoothing. You confirmed my guesses.
Nicholas K.
 
Posts: 2
Joined: Tue Feb 23, 2016 9:15 am
Operating System: Linux Fedora/RHEL

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by steve » Sun Oct 15, 2017 11:21 am

This updated version is a bit more efficient, and for smoothing it uses Hann windows (raised cosine) with 2/3 overlap for smoother gain changes.
I've also disabled the "Gain reaction speed" control as a setting of 0.5 seconds works pretty well in most cases. To enable this control, see line 12 in the plug-in code.

agc.ny
(2.94 KiB) Downloaded 44 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45316
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: AGC - Automatic Gain Control

Permanent link to this post Posted by steve » Wed Nov 22, 2017 3:08 pm

Unless any problems are found, this will hopefully be the final version of this plug-in.
It includes the optimisation by Nicholas K (thanks Nicholas), and the 2/3 overlap (for smoother gain changes) from the previous version.

The main new feature in this version is that it includes a help button that opens a manual page in the default web browser (requires Audacity 2.2.0 or later).

To install the effect, extract both files from the attached agc.zip package ("agc.ny" and "agc-help.html") into the Audacity plug-ins folder, then enable the agc effect in the normal way.

As always, feedback is both welcome and helpful.
Attachments
agc.zip
AGC effect + help file
(4.05 KiB) Downloaded 32 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45316
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Previous

Return to New Plug-Ins



Who is online

Users browsing this forum: Bing [Bot] and 4 guests