     digitalWrite(LED_BUILTIN, LOW);
 }
 
-long durationgliss(int duration, float startpitch, float endpitch, bool dir, bool recentre) {
+long _durationgliss(int duration, float startpitch, float endpitch, bool dir,
+        bool recentre, bool accel, bool decel) {
     int startpulse = pitchToPulse(startpitch);
     int endpulse = pitchToPulse(endpitch);
-    unsigned long glissTime = max(0, (duration * 1000L) -
-        (((maxPulse + startpulse) * (accelSteps / 2)) +
-         ((endpulse + maxPulse) * (accelSteps / 2))) -
-        (durationGlissCompensation * 1000L));
+    int accelsteps = accelSteps * accel;
+    int decelsteps = accelSteps * decel;
+    unsigned long glissTime = (duration * 1000L) -
+        (((max(maxPulse, startpulse) + startpulse) * (accelsteps / 2)) +
+         ((endpulse + max(maxPulse, endpulse)) * (decelsteps / 2)));
+    glissTime = max(0, (glissTime * durationGlissMult) - (durationGlissDiff * 1000L));
     int glisssteps = glissTime / ((startpulse + endpulse) / 2);
     digitalWrite(LED_BUILTIN, HIGH);
     digitalWrite(dirPin, dir);
     delayMicroseconds(pulseWidth);
-    for (int i=0; i<accelSteps; i++) {
-        onestep(map(i, 0, accelSteps, max(maxPulse, startpulse), startpulse));
+    for (int i=0; i<accelsteps; i++) {
+        onestep(map(i, 0, accelsteps, max(maxPulse, startpulse), startpulse));
     }
     for (int i=0; i<glisssteps; i++) {
         onestep(map(i, 0, glisssteps, startpulse, endpulse));
     }
-    for (int i=0; i<accelSteps; i++) {
-        onestep(map(i, 0, accelSteps, endpulse, max(maxPulse, endpulse)));
+    for (int i=0; i<decelsteps; i++) {
+        onestep(map(i, 0, decelsteps, endpulse, max(maxPulse, endpulse)));
         if (i>(accelSteps - (decelLook * recentre) && digitalRead(sensorPin))) break;
     }
     if (recentre) findsensor(max(maxPulse, endpulse));
     digitalWrite(LED_BUILTIN, LOW);
+    return glissTime;
+}
+
+long durationgliss(int duration, float startpitch, float endpitch, bool dir, bool recentre) {
+    return _durationgliss(duration, startpitch, endpitch, dir, recentre, true, true);
+}
+
+long doublegliss(int durationone, int durationtwo, float startpitch,
+        float midpitch, float endpitch, bool dir, bool recentre) {
+    long glissTime;
+    glissTime = _durationgliss(durationone, startpitch, midpitch, dir, false, true, false);
+    glissTime += _durationgliss(durationtwo, midpitch, endpitch, dir, recentre, false, true);
     return glissTime;
 }
 

        } else if (data < 120) {
            true;
        } else if (data < 193) {
            endPitch = pitchbyteToMidi(data - 120);
        } else if (data < 203) {
            true;
        } else if (data < 210) {
            test(data - 203);
            flashled();
        }

        Serial.print(" calctime ");
        Serial.println(calcdur, DEC);
    } else if (style == 5) {
        // double gliss
        Serial.print("midduration ");
        Serial.print(midDuration, DEC);
        Serial.print(", duration ");
        Serial.println(duration, DEC);
        Serial.print("startpitch ");
        Serial.print(startPitch, DEC);
        Serial.print(" midpitch ");
        Serial.print(midPitch, DEC);
        Serial.print(" endpitch ");
        Serial.print(endPitch, DEC);
        Serial.print(" direction ");
        Serial.print(dir, DEC);
        Serial.print(" recentre ");
        Serial.print(recentre, DEC);
        Serial.print(" time ");
        unsigned long starttime = millis();
        long calcdur = doublegliss(midDuration, duration, startPitch, midPitch, endPitch, dir, recentre);
        Serial.print(millis() - starttime);
        Serial.print(" calctime ");
        Serial.println(calcdur, DEC);
    } else if (style == 6) {
        // scale
        for (int i=36; i<73; i++) {
            long dur = 666;
