Old 02-17-2018, 10:52 PM   #1
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 256
Default Hysteresis in ReaGate

I'm trying to re-familiarize myself with JSFX programming and in doing so I'm programming a gate plugin. I'm using ReaGate as a basic template since I'm familiar with how it works and so are many on this forum. I started off with the most basic controls and added a new control with each new version.

v1 started with Threshold[dB], Attack[ms], and Release[ms] controls
v2 added a Hold[ms] control
v3 added a Pre-open[ms] control (i learned a bit about PDC and arrays on that one...)

Now I'm at version 4 and I'm trying to add a Hysteresis[dB] control.

I've got a control that indeed affects the threshold at which the gate closes, but when I a/b it with ReaGate (I put ReaGate in one headphone and my gate in the other) it doesn't quite behave in the same way... everything sounds mono at the same settings until i start using the Hysteresis controls.

So because I'm not just trying to learn how to program in JSFX, I'm also trying to learn the mathematics of how things work, I'm wondering if anybody knows where/how the value of the Hysteresis control in ReaGate is used...

This is the latest version of my plugin:

Code:
desc:Gate v4 - Threshold, Hysteresis, Pre-open, Attack, Hold, Release (by zappazapper)

slider1: -120 <-120, 60, 0.1>Threshold [dB]
slider2: 0 <-120, 12, 0.1>Hysteresis [dB]
slider3: 0 <0, 250, 1>Pre-open [ms]
slider4: 1 <0, 500, 1>Attack [ms]
slider5: 100 <0, 1000, 1>Hold [ms]
slider6: 20 <0, 5000, 1>Release [ms]

@init
gainOpen = 1;
gainClosed = 0;
gain = gainOpen;

pdc_bot_ch = 0;
pdc_top_ch = 2;
pdc_delay = 250 / 1000 * srate;
bufferWrite = 0;
bufferRead = bufferWrite + 1;

holdCurrent = 0;

@slider
threshold = 10 ^ (slider1 / 20);

hysteresis = 10 ^ ((slider1 + slider2) / 20);

preopen = (slider3 / 1000 * srate);

gainAttack = 1 / (slider4 / 1000 * srate);
slider4 == 0 ? gainAttack = 1;

hold = slider5 / 1000 * srate;

gainRelease = 1 / (slider6 / 1000 * srate);
slider6 == 0 ? gainRelease = 1;

@sample
detector = max(abs(spl0), abs(spl1));
detector < threshold ?
  (
    detector < hysteresis ?
      (
        holdCurrent < 1 ?
          (
            gain = gain - gainRelease;
          )
        :
          (
            gain = gain + gainAttack;
            holdCurrent = holdCurrent - 1;
          )
        ;
      )
    :
      (
        gain = gain + gainAttack;
        holdCurrent = hold;
      )
    ;
  )
:
  (
    gain = gain + gainAttack;
    holdCurrent = hold;
  )
;

gain < gainClosed ? gain = gainClosed;
gain > gainOpen ? gain = gainOpen;

buffer0[bufferWrite] = spl0;
buffer1[bufferWrite] = spl1;

bufferGain = bufferWrite - preopen;
bufferGain < 0 ? bufferGain = bufferGain + (250 / 1000 * srate);
buffer0[bufferGain] = buffer0[bufferGain] * gain;
buffer1[bufferGain] = buffer1[bufferGain] * gain;

spl0 = buffer0[bufferRead];
spl1 = buffer1[bufferRead];

bufferWrite = bufferWrite + 1;
bufferWrite > 250 / 1000 * srate ? bufferWrite = bufferWrite - (250 / 1000 * srate);

bufferRead = bufferWrite + 1;
bufferRead > 250 / 1000 * srate ? bufferRead = bufferRead - (250 / 1000 * srate);
As you can see, in my plugin, there is a "threshold" variable, which is converted from the Threshold[dB] slider, and a "hysteresis" variable, which is converted from the sum of the Threshold[dB] and Hysteresis[dB] sliders... to me, that's how it made sense... if your threshold is at -40dB, and your hysteresis is at -5dB, the gate should start closing when the level reaches -45dB...

Is anybody familiar with this concept and can give me some insight?

Thanks in advance...
zappazapper is offline   Reply With Quote
Old 02-17-2018, 11:05 PM   #2
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 256
Default

On second thought my plugin doesn't exactly behave the same way as ReaGate even with the Hysteresis at 0dB... is it possible that ReaGate uses a logarithmic curve for the attack and release?
zappazapper is offline   Reply With Quote
Old 02-17-2018, 11:55 PM   #3
pipelineaudio
Mortal
 
pipelineaudio's Avatar
 
Join Date: Jan 2006
Location: Wickenburg, Arizona
Posts: 14,047
Default

I originally intended the Hysteresis control of ReaGate to take its cue from the input, same as the threshold, but I'm not sure how exactly it ended up
pipelineaudio is offline   Reply With Quote
Old 02-18-2018, 12:44 AM   #4
zappazapper
Human being with feelings
 
zappazapper's Avatar
 
Join Date: Feb 2015
Posts: 256
Default

Quote:
Originally Posted by pipelineaudio View Post
I originally intended the Hysteresis control of ReaGate to take its cue from the input, same as the threshold, but I'm not sure how exactly it ended up
thanks for responding...

what about the attack? i find if i match all the other settings (besides hysteresis) in my plugin to ReaGate it sounds very close, a few artifacts here and there, but unless i have the attacks set to 1ms, there's a big difference...

Code:
            gain = gain + gainAttack;
            holdCurrent = holdCurrent - 1;
This is when the level has gone below the threshold but it hasn't exceeded the hold time... i figure if the gain hasn't reached 0dB yet, it would still be increasing until the hold time is up... does that sound right?
zappazapper is offline   Reply With Quote
Old 02-18-2018, 02:31 PM   #5
pipelineaudio
Mortal
 
pipelineaudio's Avatar
 
Join Date: Jan 2006
Location: Wickenburg, Arizona
Posts: 14,047
Default

I have some drawings from 2005 or 2006 that we’re kind of a block diagram of the different timings, I’ll see if I can dig them up, but again, I’m not sure exactly how the real deal ended up. Justin has a knack for figuring out what I’m really wanting to happen vs what I think should be the steps to get there, so things could be drastically different
pipelineaudio is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.