![]() |
wxMidi - A MIDI interface based on PortMidi
|
Using wxMidi basically requires the following steps:
For very common messages, such as Note On or Note Off, steps 3 and 4 can be replaced by a call to the suitable method. For example:
The procedure is, basically, the same than for sending messages. The main diference is that in reception the user program does not conthol when the message is going to be received, so a method to be informed about the arrival of a message is needed. wxMidi provides two alternatives for this:
By using events and an event handler method
By defining an event handler method, the user program will be informed when a message has been received and will have the opportunity to process it. A commnad event with ID named wxEVT_MIDI_INPUT is defined in the wxMidi.h include file. The application program must request from the MIDI device to start listening by calling method StartListening() as in following example:
By polling
Alternatively, the user application could interrogate the MIDI device, from time to time, to see if a message has been received and, in that case, read and process it. See an example of this in sample program midisound.
See also: