You can write here long tales if you want, but first you should understand the problem, and write solutions, if any available, related to THAT problem, not your tales.
If you can invert bypass state with same note (pitch and velocity same), tell me how, do not write tales.