Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: Gate

  1. #1
    Senior Member
    Join Date
    Jul 2014
    Posts
    139

    Gate

    It's common in live performance to use gates on things like drum kits to clean up the sound from the mic on each drum.
    (https://en.wikipedia.org/wiki/Noise_gate)

    From an audio waveform perspective, it looks a little like this:
    Click image for larger version. 

Name:	Gate in action.png 
Views:	40 
Size:	8.2 KB 
ID:	10506
    Top trace is before gate, bottom is after gate.

    Gates tend to have threshold/attack/hold/release/floor settings.

    Graphically shown here with exaggerated settings:
    Click image for larger version. 

Name:	Gate.png 
Views:	38 
Size:	27.4 KB 
ID:	10507
    (Threshold: 0.3, Floor: 0.1)

    Source (effect_gate.h):
    https://github.com/macaba/Audio

    I'm happy to create a pull request if this is suitable for the main repo.

  2. #2
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    181
    Cool. Gates are an essential part of my VST based live gigging rig.

    How does yours compare with the Envelope filter effect already in the library? I've not used it but it has attack, hold, delay, sustain, release controls.

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    139
    Quote Originally Posted by Blackaddr View Post
    How does yours compare with the Envelope filter effect already in the library? I've not used it but it has attack, hold, delay, sustain, release controls.
    It's not a direct comparison as Envelope generator is externally triggered (using noteOn()) whereas a Gate is signal triggered (using threshold(n) to set trigger level).
    Envelope = for synthesis, Gate = for audio processing.
    To misuse the envelope as a gate would require a bit of glue logic in the user code - polling a 'peak' object to call noteOn() on the envelope. Also the envelope would need to be retriggerable, I'm not sure if the current one is.
    Last edited by macaba; 05-07-2017 at 05:20 PM.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,305
    I recently improved the envelope object, and I'm looking to do more in June. The new version is a huge improvement, but I understand there's more work to be done.

    But I need feedback. The most helpful form of feedback is a test program which synthesizes or plays a specific sound and calls the envelope note on/off functions are specific times, to demonstrate the cases where clicks or other undesirable output happens. I get quite a bit of feedback that's really not very helpful. Test programs that actually demonstrate the limitations are the best way to get me to fix something...

    I'm also considering adding many more objects to the library with signal control inputs. A gate input to ADSR control signal is one of the ideas on my list. To achieve the envelope, you'd feed that ADSR control signal to the multiplier object (the equivalent of a voltage controlled amplifier). This sort of usage will offer much finer timing and will probably feel familiar to people used to analog & modular synthesis. But it will cost significantly higher CPU usage. The existing envelope effect uses well under 1% CPU on Teensy 3.2. This sort of control signal approach is likely to be around 2% to 5%.

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    139
    Quote Originally Posted by PaulStoffregen View Post
    A gate input to ADSR control signal is one of the ideas on my list.
    I think there is a case of confused terminology here - A Noise Gate isn't a modular synthesis thing, it's an industry standard live audio processing thing.
    Example device:
    http://www.drawmer.com/company.php#201

    I guess it comes down to whether you're just aiming the audio library at synthesis applications, or if live audio is also in scope. The new object I've created is purely a live audio processing concept - it doesn't really have a place in synthesis.

    Edit:
    Apple have a nice definition here:
    https://documentation.apple.com/en/l...0%26tasks=true
    Last edited by macaba; 05-07-2017 at 09:57 PM.

  6. #6
    Member
    Join Date
    Dec 2016
    Location
    Apeldoorn, Netherlands
    Posts
    24
    I think gates can just as well have a place in synthesis. In fact some synthesizers include a rythmical gate effect.
    Besides that, I think you're missing some generalisation: a gate is nothing more than an automatic volume control that sets it's volume to 0 when the input falls below some threshold. If the library already provides all the building blocks, one could easily make a gate using those. So split audio signal to a level\peak detector and the vca audio input, compare the output level of the level detector with a DC level (threshold control). Mult the level with a envelope and you should have something like a gate,but the building blocks are generic enough to build other stuff as well, (compressors and what not). Maybe only thing missing is a comparator and maybe an inverter.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,305
    Lately the effort on the audio library has been for synthesis stuff, mostly because it's been somewhat lacking in synthesis features. Certainly the intention is to support real-time signal processing, and play & record applications. Just because some work is recently going into improving features for one application doesn't mean all development will go that way!

  8. #8
    Senior Member
    Join Date
    Jul 2014
    Posts
    139
    Quote Originally Posted by PaulStoffregen View Post
    Certainly the intention is to support real-time signal processing, and play & record applications.
    Perfect, I'll keep releasing real-time oriented objects. When I've used them a lot and they're confirmed to be bug free, I'll look at doing pull requests.

    I've seen there is a F32 fork of the audio library for floats but it needed a bit of work before coming 'official' - can I help?

    I'd like to get this going for my Teensy 3.6, I think it makes sense to normalise any input source to +/- 1.0 and then objects like mixers won't clip (they'll just give out greater than 1.0, giving any downstream processing a chance to limit it to 1.0 before the output device).
    It's also serendipitous that 2^24 is the largest contiguous number that a 32-bit float can do before skipping integer values so a float can be confidently converted back to 24 bit int for those (non-official) 24 bit audio shields.
    Last edited by macaba; 05-10-2017 at 07:46 AM.

  9. #9
    Junior Member
    Join Date
    May 2017
    Posts
    11
    I have just uploaded my dynamics object here https://github.com/MarkzP/AudioEffectDynamics
    It's a combination of gate/compressor/limiter that I modeled after a popular unit
    I'm certainly not done optimizing it, it doesn't work on the LC (yet) but that should be a good starting point

    Marc

  10. #10
    macaba,

    Been using your gate object. I love it thanks, was able to get the settings to replicate a noise pedal I got pretty well. Thanks.

  11. #11
    Hi, may I ask for a pull request to include this great object into the official library?
    Best regards,
    Christof

  12. #12
    Hi,
    to use this object for a guitar input signal it makes sense to bring in some hysteresis. The level to Switch on has to be higher than the Level to switch off.
    My very simple modification:
    Code:
    .....
    switch (state) {
    				case S_Floor:
    					currentGain = floorGain;
    					if(maxAbsSample > (2*thresholdLevelInt)) { // <==== Hysteresis
    						state = S_Attack;
    						processNextState = true;
    					}					
    					break;
    				case S_Attack:
    					currentGain += attackTimeDelta;
    					if(currentGain >= 1.0f) {
    						currentGain = 1.0f;
    						state = S_Hold;
    						processNextState = true;
    					}
    					break;
    				case S_Hold:
    					currentGain = 1.0f;
    					if(maxAbsSample > thresholdLevelInt)
    						break;			//Re-triggered. Also prevents infinite loop.
    					currentHoldTime += holdTimeDelta;
    					if(currentHoldTime >= 1.0f) {
    						currentHoldTime = 0.0f;
    						state = S_Release;
    						processNextState = true;
    					}
    					break;
    				case S_Release:
    					if(maxAbsSample > (2*thresholdLevelInt)) { //   <=== Hysteresis
    						state = S_Attack;
    						processNextState = true;
    						break;			//Re-triggered
    					}
    ....
    Best regards Christof

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •