Welcome, Guest
Username: Password: Remember me

TOPIC: Echo Pedal.

Echo Pedal. 5 years 11 months ago #13

  • JR
  • JR's Avatar
  • OFFLINE
  • Senior Member
  • Posts: 77
  • Thank you received: 31
  • Karma: 6
This echo pedal creates a delayed signal which is played back multiple times, creating the sound of a repeating decaying echo.
  1. Potentiometer 0: Adjust the depth of the echo .
  2. Potentiometer 1: Not used.
  3. Potentiometer 2: Set the effect volume.

echo.ino:
// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield
 
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 40000
uint16_t sDelayBuffer0[MAX_DELAY];
unsigned int Delay_Depth, DelayCounter = 0;
 
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()
{
  //Clear status allowing the interrupt to be fired again.
  TC_GetStatus(TC1, 1);
 
  //Store current readings  
  sDelayBuffer0[DelayCounter]  = (in_ADC0 + (sDelayBuffer0[DelayCounter]))>>1;
 
  //Adjust Delay Depth based in pot0 position.
  Delay_Depth =map(POT0>>2,0,2047,1,MAX_DELAY);
 
  //Increse/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 listen this Echo effect in SoundCloud.

File Attachment:

File Name: echo.rar
File Size: 1 KB
keep it simple
Last Edit: 5 years 10 months ago by JR.
The administrator has disabled public write access.

Echo Pedal. 1 year 10 months ago #1164

  • Bruno
  • Bruno's Avatar
  • OFFLINE
  • New Member
  • Posts: 7
  • Karma: 0
Hi, could you please help me to use POT1 to adjust the number of repeatings? If it's possible here ..
Thank you!
The administrator has disabled public write access.

Echo Pedal. 1 year 10 months ago #1168

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
could you please help me to use POT1 to adjust the number of repeatings?
This code is made to do "infinite" amount of repeatings.
If we go a bit backward, the only difference between the delay pedal (one repetition) and this echo pedal (infinite repetitions) is one line of code:
  • Delay:
    sDelayBuffer0[DelayCounter] = in_ADC0;
  • Echo:
    sDelayBuffer0[DelayCounter]  = (in_ADC0 + (sDelayBuffer0[DelayCounter]))>>1;
I am trying to think the best solution for this... it is possible, but it is not easy! :ohmy:
The administrator has disabled public write access.

Echo Pedal. 1 year 10 months ago #1177

  • Bruno
  • Bruno's Avatar
  • OFFLINE
  • New Member
  • Posts: 7
  • Karma: 0
If I understand it good:
x>>y equals to x/2^y
so if the signal is 12 bit then there are 12 repetitions and each repetition is 1/2 of the previous, right ?
The administrator has disabled public write access.

Echo Pedal. 1 year 9 months ago #1181

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
x>>y equals to x/2^y
Yes, usually this tool is used because the division operation in Arduino is quite intensive (you can have a look to this article: www.engblaze.com/faster-code-fridays-und...speed-of-operations/ where they explain a bit more about how slow is this operation).
So in oder to speed-up the division operation (only if you are dividing by 2,4, 8, etc) you can use the ">>" operator.

If you have to add and average two signals, instead of doing:
Result = (A+ B)/2
You can do:
Result = (A +B)>>1
Which in fact is the same.
Or
Instead of:
Result = (A+ B)/4
You can do:
Result = (A +B)>>2
so if the signal is 12 bit then there are 12 repetitions and each repetition is 1/2 of the previous, right ?
Are you referring to any code or line in particular?
Last Edit: 1 year 9 months ago by Ray.
The administrator has disabled public write access.

Echo Pedal. 1 year 9 months ago #1182

  • Bruno
  • Bruno's Avatar
  • OFFLINE
  • New Member
  • Posts: 7
  • Karma: 0
It's nonsense, sorry. I hear that there are more repetitions .. but that means that I don't understand how the echoing works ...
The administrator has disabled public write access.
Time to create page: 0.488 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio