   {
     if (retrigger_)
     {
+      // update the currently selected envelope (we use the same envelope for the duration of a curve)
       env_ = selected_env_;
+
+      // reset the gate and release times so that the curve logic can execute
       gate_time_ = 0;
       release_time_ = 0;
+
+      // reset to wait for another retrigger
       retrigger_ = false;
     }
 

    {
      if (gate_)
      {
        uint16_t elapsed = millis() - gate_time_;
        if (elapsed < adsr_values_[env_].A)
        {

        }
        else
        {
          // initial release step; record the release time and the initial CV value at release
          release_time_ = millis();
          cv_released_ = cv_current_;
        }
      }

      // output the 10V and 5V envelope outputs on CO1 and CO3
      cv_out(CO1, cv_current_);
      cv_out(CO3, cv_current_ / 2.0);
    }
    else if (gate_)
    {
      // set the gate time to the time when the attack curve would have started for the current CV output value, so that
      // subsequent curve calculations are correct for retrigger (this will just be the current time if current CV is 0)
      gate_time_ = millis()
          - (unsigned long)(-float(adsr_values_[env_].A) * log(1 - (cv_current_ / (ENV_PEAK * ENV_SATURATION))));
    }
