 long durationgliss(int duration, float startpitch, float endpitch, bool dir,
         bool recentre, int sustain) {
     return _durationgliss(duration, startpitch, endpitch,
-            dir, recentre, true, true, sustain);
+            dir, recentre, true, true, sustain, sustain);
 }
 
 long doublegliss(int durationone, int durationtwo, float startpitch,
         float midpitch, float endpitch, bool dir, bool recentre, int sustain) {
     long glissTime;
     glissTime = _durationgliss(durationone, startpitch, midpitch,
-            dir, false, true, false, 0);
+            dir, false, true, false, sustain, 0);
     glissTime += _durationgliss(durationtwo, midpitch, endpitch,
-            dir, recentre, false, true, sustain);
+            dir, recentre, false, true, sustain, sustain);
     return glissTime;
 }
 

}

long _durationgliss(int duration, float startpitch, float endpitch, bool dir,
        bool recentre, bool accel, bool decel, int sustain) {
    int startpulse = pitchToPulse(startpitch);
    int endpulse = pitchToPulse(endpitch);
    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);
    int sustainsteps = (sustain * 1000L) / endpulse;
    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<glisssteps; i++) {
        onestep(map(i, 0, glisssteps, startpulse, endpulse));
    }
    for (int i=0; i<sustainsteps; i++) {
        onestep(map(i, 0, sustainsteps, endpulse, endpulse));
    }
    for (int i=0; i<decelsteps; i++) {
        onestep(map(i, 0, decelsteps, endpulse, max(maxPulse, endpulse)));
    }

        Serial.print("direction ");
        Serial.print(dir, BIN);
        Serial.print(", recentre ");
        Serial.print(recentre, BIN);
        Serial.print(", sustain ");
        Serial.println(sustainDuration, BIN);
    } else {
        // show test styles
        Serial.println("203: 0xcb: turn");
