if the CC-in is 4, then it sends to the left gate, otherwise the right. It looks like the noteon velocity is triggering the output twice. So I need to somehow send a zero velocity when the gate is sent to the left.
For sure its a simple reson. In this case its even good you did not post
an example patch as someone would just deliver the solution and you
didn't learn about the trace function.
Enable Trace in the Trace menu and step event by event through your
patch. I am sure you'll come across the culprit.
You might want to strip down your patch to the offending part before.