Issues With 0Exx And Envelope Loop

if there is a loop set on an instrument envelope, using 0Exx (set envelope offset) ignores it.

has this been done on purpose?

I actually see no reason for this behaviour, and I can’t remember I was favouring it when it was decided, so I wonder if this is just a bug or it is intended

ok I have realized that this is a bit more complex than I initially thought.

the problem arises when there is a sustain and a loop.

see attached example;

the first two behaviours are correct:

  1. note played with no envelope offset, then note-off.

standard behaviour and everything is ok.

  1. note played with 0E01 envelope offset, then note-off after a while.

the offset is set before the point where the sustain is set.
the note plays with sustain, then the note-off arrives and the envelope loop is correctly played.

  1. note played with 0E10 envelope offset, then note-off after a while.

the offset is set after the point where the sustain is set.
the envelope loop is ignored BUT the envelope is completely played once. then, the note off arrives. the envelope offset is abruptly reset at the point where the sustain is set and the play continues taking in count the loop

what should happen in 3)

before note-off:
the envelope loop should not be ignored. if a sustain point is reached while playing the loop, it should not be ignored (id est: the envelope should be sustained)

after note-off:
if a sustain point has been reached during loop playing, it should be released.
otherwise, instead of setting envelope offset to the sustain point, the loop should continue but the fadeout value should start affecting the sound