The opcodes one can use to manipulate a note's duration are:
ihold
turnoff
turnoff2
turnoff3
turnon
For other realtime instrument control see Real-time Performance Control and Instrument Invocation.