mySoftware [Updates]

Once you create a user profile on Motifator and update with the appropriate information, the updates shown here will be specific to you.

rssFeeds [Syndicate]


forumforum
 

Old Motifator threads are available in the Archive.

Viewing topic "WIN32: MIDI access functions within callbacks"

     
Posted on: December 31, 2016 @ 09:40 PM
BruceV
Total Posts:  4
Joined  12-28-2016
status: Newcomer

I run my own MIDI software, under Windows10, and programmed in WIN32 MFC, using the MS winmm.lib. It’s worked fine for years, but I’m always a bit on edge about the cautionary note that winmm functions should not be invoked inside callback functions, because there is a risk of deadlock. When I initially wrote my application I hadn’t seen this note, and now my code contains things like this when I want to immediately ship out an incoming message:

// MIDI input callback function
void CALLBACK MidiInCB(…..)
{
……….
Midioutshortmsg (…) ; // ship straight out
…..
}

In probably thousands of hours of performance, there’s never once been a problem, but it would be good to do things ‘by the book’. I’ve tried to hunt down sample code but everything I’ve found is really simple and doesn’t illustrate my situation. Multithreading seems to be part of the solution, using real time signals such as events to trigger the output code. However, whatever approach is used needs to be fast, and my experience developing MT software suggests that could be a problem in the MIDI world where turnround times need to be ideally in the low milliseconds. Some of the Windows API synchronisation mechanisms also harbour significant overheads.

Could someone please point me to sample code that illustrates the correct approach, or provide a brief summary of the best way to do this?

THanks

  [ Ignore ]