new Noise Gate plugin

Discussion in 'Effects and the DSP' started by Russ, Mar 21, 2006.

  1. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    I do not understand what you mean. I only use the abs for threshold detection (i.e. detecting the volume level, which is the same whether it is positive or negative). The rest of the code works on the original signal, and not the abs.
     
  2. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Here is the psuedo-code. Hopefully it will be readable.

    Code:
    MAIN:
    if signal_level > threshold_off
    	if signal_level < threshold_on
    		if gate is on
    			going_down = false
    			hold = false
    			release = false
    			goto ATTACK
    		else
    			out = 0
    			goto END
    	else
    		goto ON
    else
    	goto OFF		
    
    ON:
    going_down = false
    hold = false
    release = false
    if gate is off
    	attack = true
    	inititalize attack_counter
    	if release = true
    		adjust attack_counter
    	turn on gate
    	goto ATTACK
    else
    	goto ATTACK
    
    OFF:
    if gate is on
    	if going_down = false
    		going_down = true
    		hold = true
    		inititalize hold-release_counter
    		goto HOLD
    	else
    		goto HOLD
    else
    	out = 0
    	goto END
    
    HOLD:
    if hold = true
    	increment hold-release_counter
    	if hold-release_counter != hold_time
    		goto ATTACK
    	else
    		hold = false
    		release = true
    		initialize hold-release_counter
    		if attack = true
    			adjust hold-release_counter			
    		goto RELEASE
    else
    	goto RELEASE
    
    RELEASE:
    if release = true
    	decrement hold-release_counter
    	if hold-release_counter != release_time
    		out = in * (( 1 / release_time ) * hold-release_counter )
    		goto END
    	else
    		release = false
    		attack = false
    		turn off gate
    		out = 0
    		goto END
    else
    	out = 0
    	goto END
    
    ATTACK:
    if attack = true
    	increment attack_counter
    	if attack_counter != attack_time
    		out = in * (( 1 / attack_time ) * attack_counter )
    		goto END
    	else
    		attack = false
    		out = in
    		goto END
    else	
    	out = in
    	goto END
    
    END:
    end		
    		
    
     
    Last edited: Mar 25, 2006
  3. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Looking at the code this way, I noticed that it still does not handle going directly from RELEASE to ATTACK correctly, as the line that adjusts the counter, never gets executed (I knew I had to fix how the counter is adjusted anyway, but I did not notice that it never got exectuted), so this is probably causing distortion/popping.

    Also, I think I may need to increment the attack counter while in release, if attack is still in effect.

    It is the going directly from release to attack, and vice-versa, that makes things confusing and complicated, as I am not exactly sure what should happen in those situations.

    BTW: The psuedo-code intentionally has unneeded 'else' and 'goto' statements (where it would normally just fall through to the next statement), etc, just to try and make it more clear as to what it is doing (especially if the lines do not line up right).
     
    Last edited: Mar 24, 2006
  4. thomasabarnes

    thomasabarnes Long Time ***** Friend

    Joined:
    Jan 7, 2003
    Messages:
    1,404
    Likes Received:
    13
    Trophy Points:
    48
    Russ:

    I've been playing around with the plug in. So far no chrashes when enabling/disabling bypass.

    Here are the settings I'm sticking with (as I have the ADC Mic signal going into N Gate)

    TH On=-48
    TH Off= -49
    attack= 0.001
    Hold= 0.0003
    Release= 0.739

    This is my esperience:

    When the release is set at the lowest or low values, I'm hearing some crackles. The lower the release value, it seems the more the presence of the crackles. The crackles are not very bad, but I hear them. And it seems the higher the release value, the farther apart and more quiet the crackles become.

    At a Release setting of 0.739 or higher, I don't hear the crackles any more.

    The noise floor is being controlled with this plugin, but I must say that if the release time could be set to work at 0.001 0r 0.003 or those types of low settings without the crackles, that will be a more desirable setting because at those low settings it's like complete silence until a signal comes in (and the plugin TH off setting is low enough so that even a wisper in the mic turns the processing of the plugin off).

    Thanks for the link to the Article on Noise Gates and Dynamic compressors. It was really helpful. I understand all the buttons on this plugin, now.:)

    If, I encounter any problems with the plugin, I'll post here.
     
    Last edited: Mar 24, 2006
  5. thomasabarnes

    thomasabarnes Long Time ***** Friend

    Joined:
    Jan 7, 2003
    Messages:
    1,404
    Likes Received:
    13
    Trophy Points:
    48
    Oh yeah, one more thing that messing around with the settings on this plugin has made me see is that an option for a more detailed signal/peak meter graphic is desirable!!!

    The way the meters are on MX6/8 or PeakX, one has to guess what the meter reading is precisely. For instance, when determining what the noise floor is for my Mic coming in through ADC AC97 input, I can see that the noise signal is right over -60 but between -60 and -48, however one has to guess what that meter reading is precisely. And a more precise meter reading would help to make more accurate settings for the threshold settings. Hence, it would be nice to have a peak meter with a more detailed graphic. PeakX and the new ProFX Peak meters are more detailed than the MX6/8 or the ADC meter, but but a more detailed meter graphic would be better. It could even be just a stereo peak meter, but a good sized one may be required to have the needed detailed meter features.:)

    Just had to make that point. hehe

    Cya all around.
     
  6. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    Yep, exactly. The main point is that abs(x) should be fed to
    some integrator to get enveloppe. (peak 'smoothing')
    I think Russ is using abs(x) value directly.

    Btw Max, in your code, shouldn't
    limit z, y, t, z
    be
    limit z, t, t, z
    ..?

    PS:
    Nice one:,.. "hello world" envelope detectors ...lol.
     
    Last edited: Mar 24, 2006
  7. Max M.

    Max M. h/h member-shmember

    Joined:
    Dec 7, 2002
    Messages:
    2,690
    Likes Received:
    9
    Trophy Points:
    63
    Russ,

    I agree with Lex.
    It's not a good idea to use just "the abs" of signal to trigger the VCA...
    Rectified signal (= "the abs") should be smothed/integrated before, one way or another. Otherwise it gives too much false triggering and causes some pumping/jumping where unexpected.. well, it's a long story... (you know... the "peak" itself is too far from "volume/envelope" yet)

    edit:

    i suppose both limit z, t, t, z and limit z, i, t, z would be valid - giving two different detectors... lol
     
    Last edited: Mar 24, 2006
  8. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Yes, I am not doing any envelope detection or peak smoothing.
    I am working with the original waveform directly, but my envelopes work a little differently as well.

    The envelopes I see other plugins use (i.e. the bundled noise gate), work with the signal level itself:
    i.e.
    interp ampl, ampl, hold, abs;

    It scale's the volume based on the current level at the time (momentary level), and I can understand the need for peak smoothing there.

    On the other hand, the envelopes I use go from 0 to 1 (for attack, and 1 to 0 for release) based on the time value alone, and that value is mutiplied by the signal (i.e. like a volume slider), so I do not think jumps in the signal level should make a difference (as the envelope does not work with the momentray signal level, and thus peak smoothing, etc. should not be necessary).

    Maybe I am wrong. Again, I am not an expert here (I never went to school for any of this stuff, I only started playing with it, when I started playing with kX, and learn as I go. I am not even sure I know how to do the stuff you mention.).
     
    Last edited: Mar 24, 2006
  9. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Ok, I think I understand what you are saying. You guys mean to do the smoothing for the gate triggering detection, and not for the envelopes. That makes a little more sense, than what I was thinking you meant (although, I am not sure I know how to implement it completely).
     
  10. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    @thomasabarnes,
    Thanks for the update.
    Try adjusting the hold up a little more, instead of release.

    As for the peak meters, I know what you mean. That is one reason why I allow the OFF threshold to go above the ON threshold, even though you would not use it that way under normal circumstances. It lets you move it up until the gate goes OFF, and thus helps you find that area above the noise floor you are talking about (or whatever level you might be looking for).

    BTW: Do not forget that the bundled peak plugins, show the peak level (label at bottom) as well.
     
    Last edited: Mar 24, 2006
  11. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    No. Let's brake it down:

    A noisegate can roughly be devided in 3 major parts;
    1. envelope detector/generator
    2. comparator(s)
    3. VCA

    1. Derive an envelope from the input signal.
    An envelope is a rectified and smoothed representation of the input signal.
    It shows the 'overall' volume level of the signal.
    *Not* the abs per sample!
    (Max already gave the code. I use similair, just slightly diff)
    Note that this env.det. also has attack&release.
    They have nothing to do with the VCA attack&release

    2. Compare envelope signal to your thresholds and,

    3. ..force VCA into either it's Attack or Release mode.
    Your VCA should also work 'smoothed' and not produce pops&clicks,
    zipper noises or distortion, else it would be a lousy VCA.

    That's it.
     
  12. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    @Max M. and Lex,
    What do you guys think should happen if it goes into Release before the Attack phase has finished (considering that the signal level may go back up, before the Release phase finishes)? Should the Attack counter be increment while in Release (and then the Attack continued for the remaining time if the signal goes back up), or it should it be restarted when the signal level goes back above the OFF threshold?
     
  13. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    So you would not use hold at all, and use a forced envelope at all times?

    BTW: I am not sure I am using a VCA at all. It is just a delayed (not really delayed, but a volume ramp) ON/OFF.

    <edit>
    Regarding my previous question, I guess the way you do it, that would never happen?
     
    Last edited: Mar 24, 2006
  14. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    But if you implement a proper envelope detector/generator,
    you'll automaticly have some sort of 'hold' by means of the env.det.'s release time
    in conjunction with the lower threshold.
     
  15. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Yes, I understand that.
    Also, I understand Max's envelope detection code for the most part, I am just not sure how ga/gr is used there (are those user definable parameters, or some fixed values, etc?).

    Again, I think this may be a little above my current knowledge (although I will try and look up the stuff I do not understand, etc, and learn from what you guys are saying, I just do not know that I can implement something good, within a reasonable time period). If you have a good Noise Gate implementation, why not release it?

    BTW: Thanks for your input (Lex, and Max M.), I appreciate the info (even if I do not understand everything right away).
     
  16. Max M.

    Max M. h/h member-shmember

    Joined:
    Dec 7, 2002
    Messages:
    2,690
    Likes Received:
    9
    Trophy Points:
    63
    > if it goes into Release before the Attack phase has finished

    i would said that release phase should not start before attack is finished (in noise-gate context at least).
    but i'd also said there're no rules - there're too many possible combinations each having its pros and cons.

    >So you would not use hold at all, and use a forced envelope at all times?

    same here... - no rules.
    btw. the release time of the detector can serve as a hold time of env.gen.
    it's not the same but it defines how soon detector's output falls below treshold (after the peak falls) and therefore defines how long vca stays at 1.
    (in my opinion it's even better then the hold of env.gen) - edit: oh, Lex have already said that.
    but all this is so complicated so i would not say this or that without prototyping
    (you know i never contructed dynamic processors of any kind so..)
     
    Last edited: Mar 24, 2006
  17. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Yes, more complicated than I had first envisioned :).
    I was actually failry amazed, when I looked the the code of the bundled Noise Gate(s), that it performs as well as it does, with only 8 instructions per channel, including I/O.
     
  18. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    ga, gr are attack/release of the env.det.
    You decide wheter to fixate them or make them user configurable.
    For example, I have env.det.attack always set to 0 and release fixed.
    I figure you do this, just like me/us, for your own pleasure.
    If so, why care about 'time periods'. It's not like we're getting paid, now isn't it?
    I guess just like any other developer here I have lots of unreleased stuff.
    Up untill now I didn't realize there was any interest/need for another noisegate
    np your welcome, and rest assured that there are many, things I do not understand right away, and quite a few I probably never will:cool: .
     
  19. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Well, there definatley seems to be an interest, so I would say to release it.
    I think a lot of people only tolerate the issues with the bundled gates, because there is nothing else available (and they just never said anything), and that more people probably do use them (or would if they knew what they were used for) then what is apparent.

    BTW: On an unrelated note, I am wondering if you are going to release your Guitar Amp plugin (in case you are wondering if there is an interest there, I am very interested :drool: ).
     
  20. ReWired

    ReWired New Member

    Joined:
    Nov 28, 2003
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    0
    @Russ:
    a strange bug here:
    after restart - there is no n-gate in the DSP, it is registered, but somehow it is not saved in the DSP when closing kXmixer.exe.
     

Share This Page

visited