Intercept the MIDI Out
I was wondering if there was any way (on any OS) to intercept the outgoing MIDI events. For example, if a program is running (maybe Cubase) and sends out a MIDI event for Channel 16, Note "Middle C", how could my program (which is also running) receive this event when it is sent?
So basically it's like the software equivalent of having a midi wire running from the computer's MIDI out to MIDI in.
(Oh, and is this possible through any cross-platform libraries, like PortMidi?)
For any OS, to intercept MIDI events from other applications would probably involve you hooking something low level. Needless to say this would be very OS specific once you got down to the actual method used.
For example, on Windows, you might be able to get away with this by injecting a DLL into a running process and hooking some function that processes MIDI events (I'm being extremely simplistic.). So yeah.... you might want to consider what you really want.
I don't know of any easy way of doing this.
I'm not sure, but I think another option (also quite complex) would be to write a "filter driver", which is essentially a driver that sits between the originating OS level and the actual hardware driver.
This involves quite a bit of understanding of how the OS does MIDI things.
Hooking, as suggested by MacGyver is generally not officially supported, and is likely to break at any update of the OS [for example, the structure of a DLL may change, a new function introduced, etc]. Not to mention that different processor architectures will require different methods to insert a hook.