How to handle adjacent midi note on&off events

Hi to all!

I recently started to do my first steps in JUCE world and plugins development domain.

I have an idea for a midi effect plugin, but as in any case I need to start from the basics tasks.

So, the first tasks i put on myself is to do a simple midi-arp functionality like this:
1. plugin receives midi msg note-on (C3 - for example)
2. plugin produce (1/16 - for example) midi note (C3) on/off msgs and sends them to host constantly 
while input midi msg note-off (C3) not received.

midi event   :     on       off    on off
plug's input :     C . . . . C     C - C      
plug's output:     C . C . C .     C . C       (1/16th notes)

As always, On the paper it looks very simple, but it taked me some time to figure out how it will looks like in code.

I made some progress and after few unsuccessful attempts the plugin is actually do what I want, reacts to imcoming messages from host and send back midi messages to host accordingly but...

I currently have a case where it doesn't work properly:

When host about to send midi note off and midi note on adjacently, on the same sample offset, as on screenshot:

How to handle this situation?




I find it rather hard to deduce what's wrong in your implementation just given the logics you're trying to implement.

I hoped to find someone on the forum who came across this problem and knows how to solve it, as it's should be pretty common in any midi processing plugin.

Thanks, for your interest! I'll throw pseudo code of my plugin's processing. (or c++ code if it will be better?)

I think I may know where the problem is... at least I need to check it first, before I post any code.

Don't want to waste your time!

Mike - Getting tempo synced midi working was the hardest thing I've had to do!  If it hurts your head I can see why.  Watch out for the data from the sequencer not being entirely reliable as well :)  


It's very encouraging, especially that last statement! laugh

I fixed that issue but the rest is not working anymore smiley

I think I have a bug in design and lack of some basic understanding, rather then something technical: