Noise Gate

9 years 4 days ago - 9 years 4 days ago #278 by jasolag
Noise Gate was created by jasolag
Hey guys

Recently I came up with the great idea of programming a noise gate for the pedalShield. Here is my code below


int in_ADC0, in_ADC1;
int POT0, POT1, POT2, out_DAC0, out_DAC1;
int LED = 3;
const int FOOTSWITCH = 7;
const int TOGGLE = 2;
int upper_threshold, lower_threshold;

void setup()
{
//ADC Configuration
ADC->ADC_MR |= 0x80;
ADC->ADC_CR=2;
ADC->ADC_CHER=0x1CC0;

//DAC Configuration
analogWrite(DAC0,0);
analogWrite(DAC1,0);

//LED On and Off
pinMode(LED, OUTPUT);
pinMode(FOOTSWITCH, INPUT);
}

void loop()
{
//Read the ADCs
while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);
in_ADC0=ADC->ADC_CDR[7];
in_ADC1=ADC->ADC_CDR[6];
POT0=ADC->ADC_CDR[10];
POT1=ADC->ADC_CDR[11];
POT2=ADC->ADC_CDR[12];

upper_threshold=map(POT0,0,4095,4095,2047);
lower_threshold=map(POT0,0,4095,0000,2047);

if(lower_threshold<in_ADC0<=upper_threshold) in_ADC0=0;

if(lower_threshold<in_ADC1<=upper_threshold) in_ADC1=0;



out_DAC0=map(in_ADC0,0,4095,1,POT2);
out_DAC1=map(in_ADC1,0,4095,1,POT2);


dacc_set_channel_selection(DACC_INTERFACE, 0);
dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);
dacc_set_channel_selection(DACC_INTERFACE, 1);
dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);

if (digitalRead(FOOTSWITCH)) digitalWrite(LED, HIGH);
else digitalWrite(LED, LOW);
}

I copied the code from the distortion program and modified the void loop part. My logic is that because a noise gate works by muting all sounds below a certain volume, mostly hums and buzzes, If anything falls inbetween the lower and upper threshold, ADC=0 will cause the sound to be muted.

I tried this with my pedal, but it doesn't work and when my left toggle switch is flipped, all sounds are muted from my guitar. Can anybody help me with this coding and give some advice as to where I have gone wrong? Thanks

Jasolag

Please Log in to join the conversation.

9 years 3 days ago #279 by Ray
Replied by Ray on topic Noise Gate
Hi, cool idea!

About the left switch:

but it doesn't work and when my left toggle switch is flipped

The left switch is the mix switch, it mixes the original guitar signal with the one you are generating, I reckon that for this pedal you dont need to use it, so it should be up:
- If the mix switch is OFF (up position): nothing happens.
- If it is ON (down position): the output processed wet signal from the Arduino board is mixed with the original input guitar signal. It is necessary to use it for some effects like delay, echo, chorus, etc...

Sometimes if you add the original and the processed signal, the processed one has the phase 180 degrees, cancellation one each other. In delay pedals does not happen because one signal is delayed respect to the other.


There is another thing, the input signal is biased to 1.65V (3.3V/2) with the resistors R19 and R20. So when there is no guitar signal, the input level is 1.65V (not 0V), so the ADC value with no signal present is 4095/2=2047 (not 0).

I hope this helps!

Please Log in to join the conversation.

9 years 1 day ago - 9 years 1 day ago #286 by Ray
Replied by Ray on topic Noise Gate

Rendering Error in layout Message/Item: array_keys(): Argument #1 ($array) must be of type array, null given. Please enable debug mode for more information.

Please Log in to join the conversation.

Time to create page: 0.157 seconds