Help with code for Midi legato playing and pitchbend

pempi78:
I know that , this is for 1 note playing at a time (mono) but that's why i'm thinking there may be a way i can detect whether the note has been turned off or is still pressed after another note off has been sent, for example like i said i play d3 and it sends pitchbend and then i play d#3 after with the d3 still held down and i tell it to pitchbend 0 amount on d3 so everything is fine untill here, its playing only D#3 with pitchbend zero

That is not what the picture of the log shows. It shows you send the pitchbend -2949 just before the D3 ON passes through, then you press and release D#3, and press and release C3, then send pitchbend 0 just before the D3 off passes through.

Does your output device allow Aftertouch (polyphonic key pressure) to be used for pitch control? That might allow you to pitch bend individual notes). Your sketch could add aftertouch for specific notes.