I am trying to use the ~swingify Prout from the pattern docs, but I run into problems when using the legato key in the pattern. Here is the link to the help docs.

Here is a demonstration of the issue. Any ideas of how I can modify the ~swingify Prout to deal with changing legato values so I avoid stuck notes?

```
(
~swingify = Prout({ |ev|
var now, nextTime = 0, thisShouldSwing, nextShouldSwing = false, adjust;
while { ev.notNil } {
// current time is what was "next" last time
now = nextTime;
nextTime = now + ev.delta;
thisShouldSwing = nextShouldSwing;
nextShouldSwing = ((nextTime absdif: nextTime.round(ev[\swingBase])) <= (ev[\swingThreshold] ? 0)) and: {
(nextTime / ev[\swingBase]).round.asInteger.odd
};
adjust = ev[\swingBase] * ev[\swingAmount];
// an odd number here means we're on an off-beat
if(thisShouldSwing) {
ev[\timingOffset] = (ev[\timingOffset] ? 0) + adjust;
// if next note will not swing, this note needs to be shortened
if(nextShouldSwing.not) {
ev[\sustain] = ev.use { ~sustain.value } - adjust;
};
} {
// if next note will swing, this note needs to be lengthened
if(nextShouldSwing) {
ev[\sustain] = ev.use { ~sustain.value } + adjust;
};
};
ev[\sustain].debug(\sustain);
ev = ev.yield;
};
});
)
( // works fine, no stuck notes
~line = Pbind(
\dur, 0.25,
\legato, 0.98,
\midinote, Pseq([60, 62, 63, 65], inf),
);
Pdef(\test, Pchain(~swingify, ~line, (swingBase: 0.25, swingAmount: 0.3))).play
)
( // eventually I get a negative value of \sustain (see post window) and a stuck note
~line = Pbind(
\dur, Prand([0.25, 0.5, 0.75, 1], inf),
\legato, Pseq([0.2, 0.3, 0.98, 0.98], inf),
\midinote, Pseq([60, 62, 63, 65], inf),
);
Pdef(\test, Pchain(~swingify, ~line, (swingBase: 0.25, swingAmount: 0.3))).play
)
Pdef(\test).clear;
```