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