Simple Noise Gate

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Philcaster
Posts: 4
Joined: Mon Feb 24, 2020 2:12 pm

Simple Noise Gate

Post by Philcaster »

I wrote a simple noise gate patch last night. I was considering building a Fortin Zuul clone for playing with heavier distortions and fuzzes at home to get cleaner sounds and some of the that tight gated effect. Then I had the idea to try to write up a patch on FV-1 to get what I wanted good enough for home use.

Anyway, the noise gate/expander snippet on the spinsemi knowledge base page is nice, but this code here totally cuts your signal off more drastically. The downside is the decay isn't as smooth, and at times can get a little glitchy. However, in my opinion, if I'm playing with high gain pedals, there's enough sustain that I cut the note off before it would decay naturally.

It's pretty simple, there's a "noise_redux" variable that is at 0 when the signal is above the threshold. If the signal is below the threshold, a counter starts, and once the counter gets to the release time, the noise_redux variable starts ramping up to 1. As the gain_redux ramps up, the gain applied to the signal ramps down, and once the gain_redux reaches 1, your output is silent. I have a build where the dacr is tied to an LED, so I had the gain_redux variable control the LED so I could confirm that it was working as expected, but those lines are commented out below.

So far I thought there was good success both before and after hi gain pedals with my single coil telecaster in all 3 positions (neck only and bridge only being the buzziest of course). Again, it's not perfect, and some more effort could be done to smooth out the decay. But, for now I'm satisfied and can throw it on one of my muli-effect FV-1 pedals, so that I don't feel compelled to build the Zuul anytime soon.

Feel free to leave any feedback about the code or the results.

Code: Select all

;Phil's Noise Gate

;pot0 - threshold
;pot1 - release time

equ thresh reg0
equ release reg1
equ gain reg2
equ count reg3
equ gain_redux reg4
equ tick reg5
equ decay_flag reg6
equ gain_fade reg7

skp run, ENDRUN
clr
OR %00000000_00000001_00000000	;sets value of counter as 1/(2^15), or 1/32768.
wrax tick, 0
ENDRUN:

ldax pot0
mulx pot0			;log taper
sof 0.098, 0.002		;threshold range is 0.002 to 0.1
wrax thresh, 0

ldax pot1
sof 0.488, 0.012		;release time is 0.012 to 0.500 (ms)
wrax release, 1

log -1, -0.5
exp 0.0078125, 0		;1/X trick from spinsemi plus some math so the fade out time correlates to the release knob
wrax gain_fade, 0

ldax adcl
absa
rdax thresh, -1
skp neg, UNDER			;skip if signal is under threshold
OVER:
wrax count, 0			;if signal over threshold, clear count
wrax decay_flag, 0		;clear decay_flag
wrax gain_redux, 0		;clear gain redux
skp zro, FINAL

UNDER:
ldax decay_flag
skp gez, FADE
ldax count
rdax tick, 1			;add 1/32768
wrax count, 1
rdax release, -1
skp neg, FINAL			;tick counter has not reached release time, so hold with gain_redux = 0
sof 0, 0.99
wrax decay_flag, 0		

FADE:
ldax gain_redux
rdax gain_fade, 1
wrax gain_redux, 1

;sof 0.3, 0.2			;convert range 0-1 to LED brightness range 0.2 - 0.5 of my build
;wrax dacr, 0			;this is for my build which has an led tied to dacr with a transistor buffer, lit when gated

FINAL:
ldax gain_redux
sof -1, 0.99
sof 1, 0.01			
wrax gain, 0			;gain = 1 - gain redux


ldax adcl
mulx gain
wrax dacl, 0
lymark
Posts: 7
Joined: Tue Jan 05, 2021 12:49 am

Re: Simple Noise Gate

Post by lymark »

I have learned the above code, I have a question:

Code: Select all

OVER:
wrax count, 0			;if signal over threshold, clear count

Is it possible to change to this:

Code: Select all

OVER:
sof 0,0
wrax count, 0			;if signal over threshold, clear count

Used to ensure count is 0.
Sweetalk
Posts: 141
Joined: Thu Oct 15, 2009 5:13 am

Re: Simple Noise Gate

Post by Sweetalk »

lymark wrote: Tue Apr 12, 2022 1:40 am I have learned the above code, I have a question:

Code: Select all

OVER:
wrax count, 0			;if signal over threshold, clear count

Is it possible to change to this:

Code: Select all

OVER:
sof 0,0
wrax count, 0			;if signal over threshold, clear count

Used to ensure count is 0.
I think you're right, when the code reaches the OVER label isn't ensured to be cleared and then directly writes to the count register. Should place a clr statement before that to clear ir, maybe that's the glitchy part OP is mentioning
lymark
Posts: 7
Joined: Tue Jan 05, 2021 12:49 am

Re: Simple Noise Gate

Post by lymark »

There is another question, if the decay_flag can only have 0, then the following code cannot be executed.

Code: Select all

ldax decay_flag
skp gez, FADE
ldax count
rdax tick, 1			;add 1/32768
wrax count, 1
rdax release, -1
skp neg, FINAL			;tick counter has not reached release time, so hold with gain_redux = 0
sof 0, 0.99
wrax decay_flag, 0	
Because I didn't find decay_flag to be given other possible values.
Post Reply