Welcome, Guest
Username: Password: Remember me

TOPIC: Delay Pedal

Delay Pedal 5 years 4 months ago #8

  • JR
  • JR's Avatar
  • OFFLINE
  • Senior Member
  • Posts: 77
  • Thank you received: 31
  • Karma: 6
This is a delay pedal which gives great clean tones. The program is very simple:
  1. Potentiometer 0: Adjusts the delay time from 0 to 450 ms
  2. Potentiometer 2: Sets the presence of the delayed signal
  3. Mix Switch: Should be ON (down) to mix the original an delayed signal.

delay.ino:
// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield
 
 
/* delay.ino buffers the input signal up to 450 ms (MAX_DELAY/44100).
HARDWARE config: the Mix Potentiometer should be ON (down) in order to enable the output 
mixer which blends original and delayed signals.
- Main Loop: Both ADCs and potentiometes are read.
- TC4_Handler (sampling funtion): buffer the input signal to be delayed  adjusting the 
volume and writes de DACs.  
 The DSP is like:  input --> [0][1][2][3][...][][][][][][][MAX_DELAY] -->output */
 
int in_ADC0, in_ADC1;  //variables for 2 ADCs values (ADC0, ADC1)
int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10)
int LED = 3;
int FOOTSWITCH = 7; 
int TOGGLE = 2; 
 
#define MAX_DELAY 20000
uint16_t sDelayBuffer0[MAX_DELAY];
uint16_t sDelayBuffer1[MAX_DELAY];
unsigned int DelayCounter = 0;
unsigned int Delay_Depth = MAX_DELAY;
 
void setup()
{
  //turn on the timer clock in the power management controller
  pmc_set_writeprotect(false);
  pmc_enable_periph_clk(ID_TC4);
 
  //we want wavesel 01 with RC 
  TC_Configure(TC1,1,TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK2);
  TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate
  TC_Start(TC1, 1);
 
  // enable timer interrupts on the timer
  TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS;
  TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS;
 
  //Enable the interrupt in the nested vector interrupt controller 
  //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 
  //(=(1*3)+1) for timer1 channel1 
  NVIC_EnableIRQ(TC4_IRQn);
 
  //ADC Configuration
  ADC->ADC_MR |= 0x80;   // DAC in free running mode.
  ADC->ADC_CR=2;         // Starts ADC conversion.
  ADC->ADC_CHER=0x1CC0;  // Enable ADC channels 0,1,8,9 and 10  
 
  //DAC Configuration
  analogWrite(DAC0,0);  // Enables DAC0
  analogWrite(DAC1,0);  // Enables DAC0
}
 
void loop()
{
  //Read the ADCs
  while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete.
  in_ADC0=ADC->ADC_CDR[7];               // read data from ADC0
  in_ADC1=ADC->ADC_CDR[6];               // read data from ADC1  
  POT0=ADC->ADC_CDR[10];                 // read data from ADC8        
  POT1=ADC->ADC_CDR[11];                 // read data from ADC9   
  POT2=ADC->ADC_CDR[12];                 // read data from ADC10     
}
 
//Interrupt at 44.1KHz rate (every 22.6us)
void TC4_Handler()
{
  //Store current readings  
  sDelayBuffer0[DelayCounter] = in_ADC0;
  sDelayBuffer1[DelayCounter] = in_ADC1;
 
  //Adjust Delay Depth based in pot2 position.
  Delay_Depth=map(POT0>>2,0,1023,1,MAX_DELAY);
 
  //Increse/reset delay counter.   
  DelayCounter++;
  if(DelayCounter >= Delay_Depth) DelayCounter = 0; 
 
  out_DAC0 = ((sDelayBuffer0[DelayCounter]));
  out_DAC1 = ((sDelayBuffer1[DelayCounter]));
 
  //Add volume feature
  out_DAC0=map(out_DAC0,0,4095,1,POT2);
  out_DAC1=map(out_DAC1,0,4095,1,POT2);
 
  //Write the DACs
  dacc_set_channel_selection(DACC_INTERFACE, 0);       //select DAC channel 0
  dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC
  dacc_set_channel_selection(DACC_INTERFACE, 1);       //select DAC channel 1
  dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC
 
  //Clear status allowing the interrupt to be fired again.
  TC_GetStatus(TC1, 1);
}
You can listen how the delay effect sounds in SoundCloud.

You can download the latest delay.ino code from the .rar file in the "How to Start Programming pedalSHIELD" topic.
keep it simple
Last Edit: 3 years 11 months ago by Ray.
The administrator has disabled public write access.
The following user(s) said Thank You: gianni

Delay Pedal 5 years 4 months ago #9

  • JR
  • JR's Avatar
  • OFFLINE
  • Senior Member
  • Posts: 77
  • Thank you received: 31
  • Karma: 6
delay_long.ino is an evolution of delay.ino, the sampling rate is reduced to 16KHz an only one ADC is used in order to save save resources and create a 3s delay.
  1. Potentiometer 0: Adjusts the delay time from 0 to 3000 ms
  2. Potentiometer 2: Sets the presence of the delayed signal
  3. Mix Switch: Should be ON (down) mixing the original an delayed signal.

delay_long.ino:
// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield
 
 
/* delay_long.ino buffers the input signal up to 3s (MAX_DELAY/16000).
HARDWARE config: the Mix Potentiometer should be ON (down) in order to enable the output 
mixer which blends original and delayed signals.
- Main Loop: Both ADCs and potentiometers are read.
- TC4_Handler (sampling function): buffer the input signal to be delayed  adjusting the 
volume and writes de DACs.  
 The DSP works like:  input --> [0][1][2][3][...][][][][][][][MAX_DELAY] -->output */
 
int in_ADC0, in_ADC1;  //variables for 2 ADCs values (ADC0, ADC1)
int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10)
const int LED = 3;
const int FOOTSWITCH = 7; 
const int TOGGLE = 2; 
 
#define MAX_DELAY 46000
uint16_t sDelayBuffer0[MAX_DELAY];
unsigned int DelayCounter = 0;
unsigned int Delay_Depth;
 
void setup()
{
  //turn on the timer clock in the power management controller
  pmc_set_writeprotect(false);
  pmc_enable_periph_clk(ID_TC4);
 
  //we want wavesel 01 with RC 
  TC_Configure(TC1,1, TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK2);
  TC_SetRC(TC1, 1, 656); // sets 16 Khz interrupt rate (10.5MHz/656=16KHz)
  TC_Start(TC1, 1);
 
  // enable timer interrupts on the timer
  TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS;
  TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS;
 
  //Enable the interrupt in the nested vector interrupt controller 
  //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 
  //(=(1*3)+1) for timer1 channel1 
  NVIC_EnableIRQ(TC4_IRQn);
 
  //ADC Configuration
  ADC->ADC_MR |= 0x80;   // DAC in free running mode.
  ADC->ADC_CR=2;         // Starts ADC conversion.
  ADC->ADC_CHER=0x1CC0;  // Enable ADC channels 0,1,8,9 and 10  
 
  //DAC Configuration
  analogWrite(DAC0,0);  // Enables DAC0
  analogWrite(DAC1,0);  // Enables DAC0
}
 
void loop()
{
  //Read the ADCs
  while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete.
  in_ADC0=ADC->ADC_CDR[7];               // read data from ADC0
  in_ADC1=ADC->ADC_CDR[6];               // read data from ADC1  
  POT0=ADC->ADC_CDR[10];                 // read data from ADC8        
  POT1=ADC->ADC_CDR[11];                 // read data from ADC9   
  POT2=ADC->ADC_CDR[12];                 // read data from ADC10     
}
 
//Interrupt at 44.1KHz rate (every 22.6us)
void TC4_Handler()
{
  //Clear status allowing the interrupt to be fired again.
  TC_GetStatus(TC1, 1);
 
  //Store current readings  
  sDelayBuffer0[DelayCounter] = in_ADC0;
 
  //Adjust Delay Depth based in pot0 position.
  Delay_Depth=map(POT0>>2,0,1023,1,MAX_DELAY);
 
  //Increase/reset delay counter.   
  DelayCounter++;
  if(DelayCounter >= Delay_Depth) DelayCounter = 0; 
 
  out_DAC0 = ((sDelayBuffer0[DelayCounter]));
 
  //Add volume feature based in pot2 position.
  out_DAC0=map(out_DAC0,0,4095,1,POT2);
 
  //Write the DACs
  dacc_set_channel_selection(DACC_INTERFACE, 0);       //select DAC channel 0
  dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC
  dacc_set_channel_selection(DACC_INTERFACE, 1);       //select DAC channel 1
  dacc_write_conversion_data(DACC_INTERFACE, 0);       //write on DAC
}

You can download the latest delay_long.ino code from the .rar file in the "How to Start Programming pedalSHIELD" topic.
keep it simple
Last Edit: 3 years 11 months ago by Ray.
The administrator has disabled public write access.

Delay Pedal 4 years 3 months ago #178

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Platinum Member
  • Posts: 575
  • Thank you received: 133
  • Karma: 32
Some folks asked for a better explanation of the delay.ino code, so I hope it helps:
Starting from the beginning...

- The idea is to buffer the guitar signal 450 ms. Keeping a sample rate of 44.1 KHz (which is one sample every 22.6us) we will need 20000 samples to be stored (450000/22us= 200000 samples). This is why MAX_DELAY=20000.

- The Mix Potentiometer should be ON (down) in order to mix the original and the delayed signal and make them sound at the same time.

- Main Loop: Both ADCs and potentiometers are read.

- TC4_Handler (sampling function): This function is executed every 22.6us. It will save the current read signal in a buffer.
This is maybe the most tricky part, but is a very easy idea,
It also adjust the volume and writes de DACs.

- The main idea can be resumed in this image, with the key points (1,2,3) highlighted in the code below:


delay_2014-12-16.png



Variable Definitions:

int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1)
int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10)
int LED = 3;
int FOOTSWITCH = 7;
int TOGGLE = 2;

#define MAX_DELAY 20000
uint16_t sDelayBuffer0[MAX_DELAY];
uint16_t sDelayBuffer1[MAX_DELAY];
unsigned int DelayCounter = 0;
unsigned int Delay_Depth = MAX_DELAY;



Setup loop, it sets the sampling frequency at 44.1KHz (1/44KHz=22.6us). It also fixes all the general parameters like the ADC and DAC configuration.

void setup()
{
//turn on the timer clock in the power management controller
pmc_set_writeprotect(false);
pmc_enable_periph_clk(ID_TC4);

//we want wavesel 01 with RC
TC_Configure(TC1,1,TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK2);
TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate
TC_Start(TC1, 1);

// enable timer interrupts on the timer
TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS;
TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS;

//Enable the interrupt in the nested vector interrupt controller
//TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number
//(=(1*3)+1) for timer1 channel1
NVIC_EnableIRQ(TC4_IRQn);

//ADC Configuration
ADC->ADC_MR |= 0x80; // DAC in free running mode.
ADC->ADC_CR=2; // Starts ADC conversion.
ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10

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



The main loop, just read the inputs (guitar signal ADCs, and potentiometer ADCs )

void loop()
{
//Read the ADCs
while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete.
in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0
in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1
POT0=ADC->ADC_CDR[10]; // read data from ADC8
POT1=ADC->ADC_CDR[11]; // read data from ADC9
POT2=ADC->ADC_CDR[12]; // read data from ADC10
}


The interrupt function at 44.1KHz rate (every 22.6us)
void TC4_Handler()
{
//Save in the buffer the current guitar signal, to be stored Store current readings
(1) sDelayBuffer0[DelayCounter] = in_ADC0;
(1) sDelayBuffer1[DelayCounter] = in_ADC1;

//Adjust Delay Depth based in pot2 position, this part is tricky, POT0>>2 is the same as writing POT0/2. To the values that this potentiometer produces (from 0 to 2097) are re-maped in values between 1 and 20000. There is more info about the map function in the Arduino website.
Basically Delay_Depth value will go from 1 to 20000 depending on POT0 position (i.e if POT0 is at the middle point, Delay_Depth=10000 )


Delay_Depth=map(POT0>>2,0,2097,1,MAX_DELAY);

THIS IS VERY IMPORTANT: We use an index to save the data in the buffer, so we increment it, the actual reading will be stored one sample before the index position.
//--Increse/reset delay counter.

(2)DelayCounter++;
//If we reach the end of the buffer, we reset the counter
if(DelayCounter >= Delay_Depth) DelayCounter = 0;

We write on the DACs the current index buffer sample, which is indeed the one that was stored here 20000 samples before:

(3)out_DAC0 = ((sDelayBuffer0[DelayCounter]));
(3)out_DAC1 = ((sDelayBuffer1[DelayCounter]));

//Add volume feature - this is easy.
out_DAC0=map(out_DAC0,0,4095,1,POT2);
out_DAC1=map(out_DAC1,0,4095,1,POT2);

//Write the DACs
dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0
dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC
dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1
dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC

//Clear status allowing the interrupt to be fired again.
TC_GetStatus(TC1, 1);
}
Attachments:
Last Edit: 4 years 3 months ago by Ray.
The administrator has disabled public write access.

Delay Pedal 3 years 11 months ago #274

Really like what you guys are doing with this. I did find a small correction in the delay.ino code.

In the interrupt function, this line:
Delay_Depth=map(POT0>>2,0,2097,1,MAX_DELAY);

POT0>>2 divides by 4, not 2. So you're actually getting a range from 0 to 1023. Changing it to POT0>>1 divides by 2 and gives a bigger range on the delay knob.

My question is, why shift at all? Why not use
Delay_Depth=map(POT0,0,4095,1,MAX_DELAY);

Does the shift give a performance boost?

Thanks for all your work.
The administrator has disabled public write access.

Delay Pedal 3 years 11 months ago #275

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Platinum Member
  • Posts: 575
  • Thank you received: 133
  • Karma: 32
Hi John, well spotted!! you are right, the code should be:
Delay_Depth=map(POT0>>2,0,1023,1,MAX_DELAY);
or
Delay_Depth=map(POT0>>1,0,2097,1,MAX_DELAY);
POT0>>2 divides by 4, not 2. So you're actually getting a range from 0 to 1023. Changing it to POT0>>1 divides by 2 and gives a bigger range on the delay knob.

My question is, why shift at all? Why not use

Delay_Depth=map(POT0,0,4095,1,MAX_DELAY);

Does the shift give a performance boost?

Short answer:
Dividing the pot value by 4 makes the system more immune to voltage ripple in the potentiometer input, removing any glitch in the delay.

Looooong answer:

- Potentiometers are not perfect, and when generating a voltage, the level is not stable and perfect, so i.e if they are generating 1.25V, they will in fact have some voltage fluctuation, i.e 1.253V~1.254V~1.255V

- After the ADC conversion, this slightly and ridiculous voltage fluctuation could generate a fluctuating value, i.e 2049~2050~2051

- In the delay pedal, every time that the buffer length is changed there is a very subtle glitch in the sound, so if this pot has some small voltage variation during the normal operation a small glitches can appear from time to time.

- Dividing the value by 4, this fluctuation disappear, in the above example: 2049/4=512, 2050/4=512, 2051/4=512, so we are applying in fact a low pass filter to the potentiometer and removing unwanted fluctuations!

I will fix the codes, thanks!!! :)
The administrator has disabled public write access.

Delay Pedal 3 years 9 months ago #299

  • mtytgat
  • mtytgat's Avatar
  • OFFLINE
  • New Member
  • Posts: 1
  • Karma: 0
Hi everyone,

I really like this project. I've been playing around a bit with the Delay effect and added a feedback, as described here: en.wikipedia.org/wiki/Delay_%28audio_effect%29
I own a Boss DD-2 pedal, and I was trying to emulate its behaviour. The feedback makes the delayed version repeat several times until it fades out.
One problem I have is that if I increase the feedback factor too much, the signal level keeps rising and I get a lot of distortion/noise. I suppose some number is overflowing. I am however not a C-programmer at all, so I'm having a hard time to fix it.

The idea I had though, was to add some compression in the feedback path, such that the signal can never increase above a certain value (I want to avoid hard clipping though). I suppose that's how they do it in 'real' delay pedals as well.
But I want to do this symmetrically, so as not to introduce 2nd order harmonics. That means I'll first have to remove the DC from the signal.
Anyway, I'm kinda stuck at the removal of the DC. I though 'int' was by default signed, but now I'm not so sure.

Below's the code that I have now. I only have 1 pot at the moment so I replaced the others with constant values. There are a couple of lines that I'm not using, since it really is work in progress. But this version should compile and work. If you increase the value of POT1 on line 63 above 4000, it should start making a lot of noise...

Any feedback (heheh) or help is appreciated, thanks!
/* delay_long.ino buffers the input signal up to 3s (MAX_DELAY/16000).
HARDWARE config: the Mix Potentiometer should be ON (down) in order to enable the output 
mixer which blends original and delayed signals.
- Main Loop: Both ADCs and potentiometers are read.
- TC4_Handler (sampling function): buffer the input signal to be delayed  adjusting the 
volume and writes de DACs.  
 The DSP works like:  input --> [0][1][2][3][...][][][][][][][MAX_DELAY] -->output */
 
int in_ADC0;  //variables for 2 ADCs values (ADC0, ADC1)
int POT0, POT1, POT2, out_DAC0, out_DAC1, out_Delay1, out_Delay1_mix; //variables for 3 pots (ADC8, ADC9, ADC10)
int AC_in, filtered_value, last_filtered_value, sample;
const int LED = 3;
const int FOOTSWITCH = 7; 
const int TOGGLE = 2; 
int feedback;
int in_delay = 0;
 int ledPin = 13;      // select the pin for the LED
 
#define MAX_DELAY 46000 // must be smaller than 2^16
uint16_t sDelayBuffer0[MAX_DELAY]; // array of unsigned integer of 16 bits, length MAX_DELAY type arrayName [ arraySize ];
unsigned int DelayCounter = 0;
unsigned int Delay_Depth;
 
void setup()
{  //turn on the timer clock in the power management controller
  pmc_set_writeprotect(false); // disable write protection for pmc registers
  pmc_enable_periph_clk(ID_TC4); // enable peripheral clk 4
 
  //we want wavesel 01 with RC 
  TC_Configure(TC1,1, TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK2);
  TC_SetRC(TC1, 1, 238); // sets 44.1 Khz interrupt rate (10.5MHz/656=16KHz) -> why 10.5? because tc1 is chosen with TC_CMR_TCCLKS_TIMER_CLOCK2 which means 84/8=10.5MHz
  TC_Start(TC1, 1);
 
  // enable timer interrupts on the timer
  TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; // interrupt enable register
  TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; // disable
 
  //Enable the interrupt in the nested vector interrupt controller 
  //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 
  //(=(1*3)+1) for timer1 channel1 
  NVIC_EnableIRQ(TC4_IRQn);
 
  //ADC Configuration
  ADC->ADC_MR |= 0x80;   // DAC in free running mode.
  ADC->ADC_CR=2;         // Starts ADC conversion.
  ADC->ADC_CHER=0x1CC0;  // Enable ADC channels 0,1,8,9 and 10  
 
  //DAC Configuration
  analogWrite(DAC1,0);  // Enables DAC1
 
    pinMode(ledPin, OUTPUT);
 
}
 
void loop()
{
  //Read the ADCs
  while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete.
  in_ADC0=ADC->ADC_CDR[7];               // read data from ADC0
  POT0=ADC->ADC_CDR[10];                 // read data from ADC8        
  //POT0 = 1023; // Delay depth
  //POT1=ADC->ADC_CDR[11];                 // read data from ADC9   
  POT1=1000; // feedback
//  POT2=ADC->ADC_CDR[12];                 // read data from ADC10     
POT2 = 4095; //volume
}
 
//Interrupt at 44.1KHz rate (every 22.6us)
void TC4_Handler()
{
  //Clear status allowing the interrupt to be fired again.
  TC_GetStatus(TC1, 1);
// if (in_ADC0>32767 || in_ADC0<-32767/128) 
// { digitalWrite(ledPin, HIGH);} // light led
// else
//  { digitalWrite(ledPin, LOW);} // light led OFF
last_filtered_value = filtered_value;
sample=in_ADC0;
filtered_value=last_filtered_value + 0.004*(sample - last_filtered_value); // this is a LPF version of the input signal
AC_in=sample; //-filtered_value; //subtract DC
  //Store current readings  
  feedback=POT1;
  sDelayBuffer0[DelayCounter] = AC_in/2+feedback*out_Delay1/(4096); // write in [0] [1] ... [MAX_DELAY-1] [MAX_DELAY]
 if(sDelayBuffer0[DelayCounter]>4095) 
 { sDelayBuffer0[DelayCounter]=4095;
 digitalWrite(ledPin, HIGH); // light led; //clip
 }
 else
 { digitalWrite(ledPin, LOW);} // light led OFF
  if(sDelayBuffer0[DelayCounter]<-2047) 
 { sDelayBuffer0[DelayCounter]=-2047;
 digitalWrite(ledPin, HIGH);} // light led; //clip
 else
 { digitalWrite(ledPin, LOW);} // light led OFF
  //Adjust Delay Depth based in pot0 position.
  Delay_Depth=map(POT0>>2,0,1023,1,MAX_DELAY);
 
  //Increase/reset delay counter.   
  DelayCounter++;
  if(DelayCounter >= Delay_Depth) DelayCounter = 0; 
 
  out_Delay1 = (sDelayBuffer0[DelayCounter]);  // read from [1] [2] ... [MAX_DELAY] [0] --> these are the values written on these places the previous time!!!
 
  //Add volume feature based in pot2 position.
  out_Delay1_mix=map(out_Delay1,0,4095,1,POT2);
out_DAC1=in_ADC0/2+out_Delay1_mix; // add DC again
  //Write the DACs
  dacc_set_channel_selection(DACC_INTERFACE, 1);       //select DAC channel 0
  dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC
}
The administrator has disabled public write access.

Delay Pedal 3 years 9 months ago #301

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Platinum Member
  • Posts: 575
  • Thank you received: 133
  • Karma: 32
Hi, have a look to the echo pedal, I think it has the behavior you are looking for.

However if your code get unstable due to the positive feedback (something very usual) you can try to limit the amount of feedback of the POT1 by using the map function, something like
POT1=map(POT1,0,4095,1,4000);
so, once you read the POT1, its value will be limited from 0 to 4000.
Last Edit: 3 years 9 months ago by Ray.
The administrator has disabled public write access.
Time to create page: 0.258 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio