I guess you send some signal/command when the the virtual keyboard pressed and released?
And Java must have some sort of timer/clock. Isn't it simplest for a virtual keyboard, that just write the integer notevalue into a two dimensional array together with the clock timestamp after "rec" pressed and notes start to be pressed.and released. You could use 0-127 for pressed and 128-255 for released notes.
And then save these to a simple textfile?
I guess since you use a virtual keyboard there really is no other information to save or?
At playup you just read in file again to array, and from it generate/calculate a time difference array between notes. This differences between timed events is then used in a thread that sleeps x milliseconds and then send the next array element command to playup or release next note in array?
"Or do i missunderstand you is there a hardware keyboard connected over midi? That play up tonegenerator or samples on computer?"