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