I'm having an annoying problem when using Timidity in Windows MIDI driver
mode, with Virtual MIDI Piano Keyboard as the controller.
I can play fine just after starting VMPK, but once I leave it in the
background and do other things and come back, I get massive lag (up to
several seconds between hitting the key and hearing something) and massive
stuttering too. However, once I restart VMPK (which restarts Timidity too),
the problem goes away.
I can also reproduce this program every time by putting the computer to
sleep for a few seconds, then resuming.
Has anyone else encountered this and know how to fix it? I have a suspicion
about the way Timidity maintains time stamps, especially with all those
global time stamps like last play time, which might go out of sync? Also,
I don't like how it uses double precision for timing - you lose 12bits of
precision for a larger dynamic range that's not needed. It's convenient by
using seconds, but why not measure time in audio samples so that the code
isn't littered with all those (int)(sampleRate * t + 0.5)