int onLength = (length + 254) / 255;
MfiEvent[] mfiEvents = new MfiEvent[1/* onLength */];
for (int i = 0; i < Math.max(onLength, 1); i++) {
NoteMessage mfiMessage = new VaviNoteMessage();
mfiMessage.setDelta(i == 0 ? delta : 0);
mfiMessage.setVoice(voice);
mfiMessage.setNote(context.retrievePitch(channel, data1));
mfiMessage.setGateTime(i == onLength - 1 ? length % 255 : 255);
mfiMessage.setVelocity(data2 / 2);
if (length >= 255) {
Debug.println(channel + "ch, " + mfiMessage.getNote() + ", " + mfiMessage.getDelta() + ":[" + i + "]:" + (i == onLength - 1 ? length % 255 : 255) + "/" + length);
}
//Debug.println(channel + ", " + mfiMessage.getVoice() + ", " + ((mfiMessage.getMessage()[1] & 0xc0) >> 6));
mfiEvents[i] = new MfiEvent(mfiMessage, 0l); // TODO 0l
//if (mfiEvents[i] == null) {
// Debug.println("[" + i + "]: " + mfiEvents[i]);