ARDUINO TAP TEMPO experiments.

Started by deadastronaut, December 11, 2018, 08:06:50 AM

Previous topic - Next topic

potul

Forgot to mention... when you use the tap tempo to set the time, and afterward you move the pot, there will always be some jump, because the LFO will change the period from the tapped tempo to the position of the pot.

Mat

pbrommer

Quote from: potul on December 17, 2018, 08:53:12 AM
Ok, the way it is coded, the leds are never stopping, so they always flash. When you tap you update the timing, but they don't stop in between taps. And the timing is only updated after you do at least two taps. But only if you tap 3 times it will work properly.
This is because the code doesn't know if you are in the middle of tapping or not. they way it works is that it simply counts time between taps, and always average the last 2 intervals you tapped.


Hopefully this isn't bringing up too old of a post, but it has been helpful to read what is going on for myself and an idea I've had for a while.

Since you say the LEDs are always on, is there a way to write the code without the jLEDs to cause the LEDs to write on and off in a cycling sequence at the rate of the taps? I've seen an example from the author of the original code, but it works with bytes and numbers that I can't translate. The link is here: https://github.com/Interlock-Rochester/light-displays/blob/master/Arlene/Arlene.ino. Works better than the previous code and is a bit more complex, but I cannot figure out how to write the code for a tap tempo LED sequencer. Thanks for the help. Maybe this will help.

Patrick
  • SUPPORTER

potul

Quote from: pbrommer on February 28, 2019, 01:28:18 PM


Since you say the LEDs are always on, is there a way to write the code without the jLEDs to cause the LEDs to write on and off in a cycling sequence at the rate of the taps?


I thought this is what the code does. LEDs flashing at the rate given by the tap tempo

pbrommer

It does. I was just hoping to see if there was a way to write the code to turn the LEDs on and off in sequence and cycle through 1-8.

Does that make sense? I can start another thread if needed to break this down.
  • SUPPORTER

potul

I see... so one LED at a time and scrolling through leds?

deadastronaut

hi guys, back on this again,  i gave up on the pot with tap, it was a bit too glitchy...

so i am back to 1 blink led, and 1 fade led setup..

tap is working all fine as it should. i was just wondering how to have ''unlimited time'' between taps.

so i can go ultra uber slow fade (for a filter sweep using lfo led) ....or is there a limit to this?.

heres where i am as a reference.


/*
    Tap Tempo using Jleds
   
*/

#include <jled.h>

int period = 2000;
JLed leds[] = {
    JLed(3).Breathe(period).Forever(),
    JLed(4).Blink(period/4*3, period/4).Forever(),

    JLed(LED_BUILTIN).Blink(period/2, period/2).Forever()};

void setup()
{
  pinMode( 12, INPUT );   /* tap button - press it to set the tempo */
}


int lastTapState = LOW;  /* the last tap button state */
unsigned long currentTimer[2] = { 500, 500 };  /* array of most recent tap counts */

void loop()
{
  /* read the button on pin 12, and only pay attention to the
     HIGH-LOW transition so that we only register when the
     button is first pressed down */
  int tapState = digitalRead( 12 );
  if( tapState == LOW && tapState != lastTapState )
  {
    tap(); /* we got a HIGH-LOW transition, call our tap() function */
  }
  lastTapState = tapState; /* keep track of the state */
 
    // update leds
    for (auto& led : leds) {led.Update();}
    delay(1);
}

unsigned long lastTap = 0; /* when the last tap happened */

void tap()
{
  /* we keep two of these around to average together later */
  currentTimer[1] = currentTimer[0];
  currentTimer[0] = millis() - lastTap;
  lastTap = millis();
 
  // establish new period
  period = ((currentTimer[0] + currentTimer[1])/2);

  // update leds period
  leds[0] = JLed(3).Breathe(period).Forever();
  leds[1] = JLed(4).Blink(period/4*3, period/4).Forever();

  leds[4] = JLed(LED_BUILTIN).Blink(period/2, period/2).Forever();
}
https://www.youtube.com/user/100roberthenry
https://deadastronaut.wixsite.com/effects

chasm reverb/tremshifter/faze filter/abductor II delay/timestream reverb/dreamtime delay/skinwalker hi gain dist/black triangle OD/ nano drums/space patrol fuzz//

slacker

There's nothing in that code that times out if you don't make a second tap a certain amount of time after the first one, so It looks like the maximum time between taps is set by the fact that "period" is held as an int (integer). The biggest number this can hold is 32767, the tap time is in milli seconds so this gives a maximum time of about 32 seconds.
If you want even longer times you could try changing
int period = 2000;

to

long period = 2000;

"period" could then be up to about 2 billion milli seconds or roughly 24 days :) This will probably break the JLed code though.

deadastronaut

24 days should be long enough ha ha..... ;D

cheers ian, good to see ya back. thanks man .  8) 8) 8)
https://www.youtube.com/user/100roberthenry
https://deadastronaut.wixsite.com/effects

chasm reverb/tremshifter/faze filter/abductor II delay/timestream reverb/dreamtime delay/skinwalker hi gain dist/black triangle OD/ nano drums/space patrol fuzz//