Well, thank you for your replies but I don't think we can go much further. I had already added the ampeg_attack to a region definition, just for testing, but It made no difference at all in the playback. Of course I could have missed something but I made it as simple as I could to avoid introducing other problems. In any event, the solution you have shown discriminates between the region on the basis of pitch, and you could do it on velocity, but I want it on note length, *in real time*. And that is still only the start of the solution.

Bernard, it is important for you to understand that the note length information is NOT part of the note-on information! The note length is only set later by a note-off event, thus, at note-on the attack length cannot be set based on the - still unknown - note length. Only the note value and the velocity are part of the note-on information.