Host generated midi playback issue

This is such a specific issue that I’m not even sure where to begin googling to find the answer.
I’ve built my own midi processor that runs the envelopes for my synth. I’m currently trying to make this envelope system comply with the host related behavior typical of most plugins. For instance, if you stop audio playback, all envelopes are terminated. And you can still trigger midi notes outside of playback. (I’ve solved this one already, pretty straightforward.)

Here’s where I’m stuck. In cubase for instance, you are able to drag midi notes around the piano roll and preview them. This triggers the note to play in the associated audio plugin. My synth plays the triggered note but if the note has a long release time (like 20 seconds), then you have to wait 20 seconds for the note to decay. It doesn’t terminate automatically because all the host is doing is triggering midi on and off events.

This behavior is not at all surprising since that’s exactly how my synth is programmed to work. The envelope enters the release stage once the note is released. However, every synth I have ever used not only has this same kind of standard release behavior but also terminates its envelopes abruptly when midi note commands are sent to it through this piano roll preview.

Are there standard solutions for dealing with these kinds of host generated midi commands?

Edit: Hold up. Other synths actually produce this same behavior in the piano roll preview. Should have checked this before posting. My bad. Somehow my memory of this behavior from years of music production was totally wrong.

So I guess my question is a bit different then. While I could leave this how it is, triggering crazy long envelope releases from a note preview is not particularly great from a user perspective. Has anyone encountered something like this before and found a straightforward solution? Obviously plugin hosts can trigger midi on and off events however they’d like and there’s not a whole lot a plugin developer can do about that. But if there were a not too hacky solution this problem I’d definitely want to take the time to implement it.

That is a problem, because your synth is just doing what you told him to do. Where do you draw the line of “not too hacky solution?”
The shortest way I can think of right now is switching off the ADSR envelope manually if you know you’ll be moving long notes around.

I don’t think you should do anything since everything you describe is expected behavior.
If you really want to do something, one thing you could check is the isPlaying flag of AudioPlayHead::CurrentPositionInfo. You could, for example, limit the release time when the transport is not rolling. But note that when the transport is not rolling, the user can still play notes on the midi keyboard, so you’d end up cutting these notes too. You have no way of knowing if messages come from the host preview or something else.


Thanks for the input guys. Ya I think I’m just gonna leave this as it is, especially since its just an edge case. Doesn’t seem like something worth tampering with.