Welcome, Guest
Username: Password: Remember me

TOPIC: Tap Delay Effect Pedal

Tap Delay Effect Pedal 1 month 3 weeks ago #1652

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Platinum Member
  • Posts: 575
  • Thank you received: 133
  • Karma: 32
The Tap Delay effect will adjust the delay time of the effect based on the rhythm that the player will create stomping on the TAP footswitch.

The audio relays are set in "delay" position:
delay_2019-01-25-2.jpg



To do this we have created a table "delay_conv[]", this table will convert the time in ms to the variable to be used in the "analogWrite" function that controls the PT2399 delay. To create this table we used an oscilloscope to measure the timing and correlate it with the table values.

The typical use to adjust the delay is:
analogWrite(DELAY1, delay_conv[duration]);
where "duration" is the time in ms that we want to have for delay, i.e 100 for 100ms, 200 for 200ms, etc.

To measure the TAP timing, we use the millis(); function, you can find more info here:
forum.arduino.cc/index.php?topic=503368.0

The complete code looks like:
// CC-by-www.ElectroSmash.com Tap Delay Effect Pedal.
// More info about the project at www.ElectroSmash.com/Time-Manipulator
 
// Pin Definitions: 
#define DELAY1 10
#define DELAY2 9
#define SWA 3
#define SWB 14
#define SWC 2
#define SWD 4 
#define LED1_G 1 
#define LED1_R 0
#define LED2_G 5
#define LED2_R 6
#define ENC_A 16
#define ENC_B 18
#define ENC_GND 17
#define ENC_PUSH 19
#define BYPASS_DETECT 8
#define TAP_DETECT  15

//Time to ms conversion table
 int delay_conv[]={ 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,
 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,
 230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,230,
 230,230,230,230,230,230,230,230,230,230,230,
 230,229,228,227,226,224,223,222,221,220,219,218,217,216,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,198,196,194,192,190,189,188,187,186,184,183,182,181,180,179,178,176,175,174,
 173,171,170,169,168,168,167,166,165,164,163,163,162,161,160,159,158,157,156,155,155,154,153,152,151,150,149,148,148,147,146,145,144,143,143,142,141,140,139,139,138,137,137,136,135,135,134,133,133,132,131,131,130,
 129,129,128,128,127,127,126,126,125,124,124,123,123,122,122,121,121,120,120,119,119,118,118,117,117,116,116,115,115,114,114,113,113,112,112,111,111,110,110,109,109,108,108,108,107,107,106,106,105,105,105,104,104,
 103,103,103,102,102,101,101,100,100,100,99,99,99,98,98,98,97,97,97,96,96,96,95,95,94,94,94,93,93,93,92,92,92,91,91,91,90,90,90,89,89,89,89,88,88,88,88,87,87,87,86,86,86,86,85,85,85,84,84,84,84,83,83,83,83,82,82,
 82,81,81,81,81,80,80,80,80,79,79,79,79,79,78,78,78,78,78,77,77,77,77,76,76,76,76,76,75,75,75,75,75,74,74,74,74,74,73,73,73,73,73,72,72,72,72,71,71,71,71,71,70,70,70,70,70,70,69,69,69,69,69,69,68,68,68,68,68,68,68,
 67,67,67,67,67,67,66,66,66,66,66,66,66,65,65,65,65,65,65,64,64,64,64,64,64,64,63,63,63,63,63,63,62,62,62,62,62,62,62,61,61,61,61,61,61,60,60,60,60,60,60,60,60,59,59,59,59,59,59,59,59,58,58,58,58,58,58,58,58,58,57,
 57,57,57,57,57,57,57,57,56,56,56,56,56,56,56,56,55,55,55,55,55,55,55,55,55,54,54,54,54,54,54,54,54,53,53,53,53,53,53,53,53,53,52,52,52,52,52,52,52,52,52,51,51,51,51,51,51,51,51,50,50,50,50,50,50,50,50,50,50,
 50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50};
 
//VARIABLES
unsigned int ENC_counter = 100; 
int ENC_aState;
int ENC_aLastState;  
int ENC_aState_selection=0;
int ENC_aLastState_selection=0;
byte timerRunning=0;
unsigned long startTime;
unsigned long endTime;
unsigned long duration=200;
unsigned long currentMillis,previousMillis = 0; 
 
// the setup function runs once when you press reset or power the board
void setup() 
{
//set the pins //init the values
pinMode(DELAY1, OUTPUT);    analogWrite(DELAY1, 100);
pinMode(DELAY2, OUTPUT);    analogWrite(DELAY2, 100);
pinMode(SWA, OUTPUT);       digitalWrite(SWA, LOW);
pinMode(SWB, OUTPUT);       digitalWrite(SWB, LOW);
pinMode(SWC, OUTPUT);       digitalWrite(SWC, LOW);
pinMode(SWD, OUTPUT);       digitalWrite(SWD, LOW);
pinMode(LED1_G, OUTPUT);    analogWrite(LED1_G, 0);
pinMode(LED1_R, OUTPUT);    analogWrite(LED1_R, 0);
pinMode(LED2_G, OUTPUT);    analogWrite(LED2_G, 0);
pinMode(LED2_R, OUTPUT);    analogWrite(LED2_R, 0);
pinMode(ENC_A, INPUT_PULLUP);
pinMode(ENC_B, INPUT_PULLUP);
pinMode(ENC_GND, OUTPUT);
pinMode(ENC_PUSH, INPUT_PULLUP);
pinMode(BYPASS_DETECT, INPUT_PULLUP);
pinMode(TAP_DETECT, INPUT_PULLUP);
ENC_aLastState = digitalRead(ENC_A); 
void read_encoder(void);
}
 
 
void loop() // the loop function runs over and over again forever
{
//detect if the effect is on or off
while((digitalRead(BYPASS_DETECT) == LOW)) 
  {
  digitalWrite(LED1_R,LOW);digitalWrite(LED2_R,LOW);digitalWrite(LED1_G,LOW);digitalWrite(LED2_G,LOW); 
  }  
//set the audio relays  
digitalWrite(SWA, LOW);digitalWrite(SWB, HIGH);digitalWrite(SWC, HIGH);digitalWrite(SWD, LOW);
 
//detect the TAP footswitch rythm and set the correct delay time
if (timerRunning == 0 && digitalRead(TAP_DETECT) == LOW)
{ // button pressed & timer not running already  
  startTime = millis();
  timerRunning = 1;
  delay(200);//debouncing  
}
if (timerRunning == 1 && digitalRead(TAP_DETECT) == LOW)
{ // timer running, button released
endTime = millis();
timerRunning = 0;
duration = endTime - startTime;
}
 
currentMillis = millis();
if ( currentMillis - previousMillis >= duration) 
{
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
digitalWrite(LED1_R,!digitalRead(LED1_R));
digitalWrite(LED2_R,!digitalRead(LED2_R));
}   
 
//if the duration of the rythm is too long (over 600ms), the delay time is splitted
if (duration<600)
{       
  analogWrite(DELAY1, delay_conv[duration]);
  analogWrite(DELAY2, delay_conv[duration]);
}
  else if (duration<1200)
  {       
   analogWrite(DELAY1, delay_conv[duration>>1]);
   analogWrite(DELAY2, delay_conv[duration>>1]);
  }
    else if (duration<2400)
    {
    analogWrite(DELAY1, delay_conv[duration>>2]);
    analogWrite(DELAY2, delay_conv[duration>>2]);
    }
      else 
      {
      analogWrite(DELAY1, 50);
      analogWrite(DELAY2, 50);
  }        
 
}


File Attachment:

File Name: Time-Manipulator_tap_delay.zip
File Size: 2 KB
The administrator has disabled public write access.
Time to create page: 0.151 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio