Re: Ending a UI Thread?
"Michael K. O'Neill" <mikeathon2000@nospam.hotmail.com> wrote in message
news:ekVrJiI9HHA.4712@TK2MSFTNGP04.phx.gbl...
The callback function specified at ::midiOpen is called in a different
thread context anyway. This means that your callback was already in a
separate thread, so that your idea of providing your own thread was in
principle no different from the pre-existing situation. That probably
explains why there was no boservable difference in latency between the
midiOpen callback and the UI thread.
Thanks! I hadn't realised this, but it makes a lot of sense. [Though by
creating the thread myself, I *was* able to control its priority.]
The usual reason for latency is a mis-behaving callback function, that
blocks processing for a short period of time. It might be some other
program's callback, incidentally, and not necessarily your own, so you
should ensure that no other midi ports are open.
AFAIK no other midi ports are open - certainly not MIDI-in, as I only have
one.
In my application, I may, not realising it was a separate thread, have used
some ill-advised calls in the callback function. (I'll check.) However,
even if so, until this machine, it has not been a problem. Even on the
misbehaving machine, performance counters indicate that the callback
function (in the debug build) takes about 0.7ms from entry to just after I
send the midi message to midi-out. The audible latency is of the order of
100ms.
But in the little stand-alone app I wrote to test using a callback thread,
it is as simple as it can be:
void CThreadMidiIn::OnMmMimData( WPARAM wParam, LPARAM lParam )
{
DWORD dwData = (DWORD)lParam;
::midiOutShortMsg( m_hMidiOut, dwData );
return;
}
and the latecy is still there. (CThreadMidiIn is derived from CWinThread,
and set up with THREAD_PRIORITY_HIGHEST.)
I have looked at the "Creative SoundFont bank manager", one of the
applications which came with the Creative labs SioundBlaster X-Fi card.
Even if you don't use it for anything, while it is up, it *does* echo any
MIDI-in, and so I can hear my keyboard when I play it. There is no
detectable latency. This is infuriating. :-(
There *must* be a simple reason.
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm