     }
     else if(gate)
     {
-      gate_time = millis();
+      gate_time = millis() - (unsigned long)((cv_current / 10.0) * float(adsr_values.A));
     }
   }
 

  virtual void setup()
  {
    gate_time = 0;
    retrigger = false;
    gt_attach_interrupt(GT3, gate_isr, CHANGE);
  }

    if(retrigger)
    {
      gate_time = 0;
      release_time = 0;
      retrigger = false;
    }

