MIDICTRL.DLL Help Page

Notes

The MIDICTRL DLL provides the functionality required for MIDI system exclusive communications. It uses an innovative approach of providing 2 buffers (1 each for Input and Output). It also provides a comprehensive debugging facility through the SetDebugMode. When this is called with a 'TRUE' parameter, anything that goes wrong is reported using a message box. The functions are divided into four sections:

Device Functions Functions that allow for the investigation, opening and closing of the MIDI ports
Buffer Functions Functions that allow manipulation of data to be sent to, or received from, the MIDI ports.
System Exclusive Functions Currently only the MidiRecord function fits in this category
Support Functions Miscellaneous, but important functions

Function List

Where b_midiIn is shown as a paremeter, this is used to distinguish between an operation on a MIDI In device (b_midiIn = TRUE or 1) and a MIDI Out device (b_midiIn = FALSE or 0)

Device Functions
DWORD MidiGetNumDevices(bool b_midiIn);
Returns the number of MIDI In/Out devices on the system
LPCSTR MidiGetDeviceName(bool b_midiIn, DWORD dw_deviceNum);
Returns the name of the required device
dw_deviceNum should be in the range 1 - MidiGetNumDevices
bool MidiSetDevice(bool b_midiIn, DWORD dw_deviceNum);
Sets the current MIDI In/Out device
dw_deviceNum should be in the range 1 - MidiGetNumDevices
DWORD MidiGetDevice(bool b_midiIn);
Gets the number of the current MIDI In/Out device
bool MidiOpen(bool b_midiIn);
Opens the current MIDI In/Out device
bool MidiClose(bool b_midiIn);
Closes the current MIDI In/Out device
Closing the MIDI In port ignores any messages that are being received
Closes the MIDI Out port sends a RESET on all MIDI channels and stops any messages going out
bool MidiIsOpen(bool b_midiIn);
Returns the status of the MIDI In/Out device
 
Buffer Functions
bool MidiSetMaxBufferSize(bool b_midiIn, DWORD bufferSize);
Sets the maximum number of characters a buffer can hold
The MIDI Out buffer has enough space dynamically allocated for it so this function has no effect on the MIDI Out buffer
DWORD MidiGetMaxBufferSize(bool b_midiIn);
Returns the number of MIDI In/Out devices on the system
As a result of the dynamic allocation of space for the MIDI Out buffer, this function returns 0 for the MIDI Out buffer
DWORD MidiGetBufferSize(bool b_midiIn);
Returns the current number of characters in the MIDI In/Out buffer
bool MidiClearBuffer(bool b_midiIn);
Clears the contents of the MIDI In/Out buffer and sets the buffer length back to zero
LPSTR MidiGetBuffer(bool b_midiIn);
Returns the contents of the MIDI In/Out buffer as a string
LPSTR MidiGetBufferHex(bool b_midiIn);
Returns the contents of the MIDI In/Out buffer as a hex string e.g. "F04100F7"
DWORD MidiLoadBuffer(bool b_midiIn, LPCSTR fileName);
Places the contents of a file located at fileName into the MIDI In/Out buffer
This function is normally used to load the MIDI Out buffer with the contents of a System Exclusive (SYX) file
bool MidiAppendBuffer(bool b_midiIn, LPCSTR sysExString);
Appends the characters in sysExString to the MIDI In/Out buffer
bool MidiAppendBufferHex(bool b_midiIn, LPCSTR sysExString);
Appends the characters in sysExString to the MIDI In/Out buffer
For this function use 'hex strings' e.g. sysExString = "F04100F7"
bool MidiSendBuffer(bool b_midiIn);
Send the contents of the MIDI In/Out buffer out the MIDI Out port
This is normally only performed for the MIDI Out (b_midiIn = FALSE) buffer
bool MidiSaveBuffer(bool b_midiIn, LPCSTR fileName);
Save the contents of the MIDI In/Out buffer to the file described by fileName
 
System Exclusive Functions
bool MidiRecord(bool b_start);
Starts (b_start = TRUE) and stops (b_start=FALSE) recording on the current MIDI In device
Messages received are placed in the MIDI In buffer
 
Support Functions
bool MidiSetDebugMode(bool b_mode);
Enables (b_mode = TRUE) and disables (b_mode = FALSE) the debugging facility
This facility is provided for my debugging puposes. In normal development the return values from each function should be enough to determine whether a call has been sucessful or not.
This function always returns TRUE (1)

Improvements

MidiSetMaxBufferSize, MidiGetMaxBufferSize Allow the MIDI In buffer to use dynamic memory allocation and remove these two functions. The WIN32 API may however make this difficult
MidiRecord Still a bit flakey, needs some fixing up
Sequencer type functions While I have the code to produce a sequencer type DLL, and the device functions are the same, I'm not intending to allow this DLL to send NOTE ON's etc. Priority Zero

 

Back to MIDI DLL Main Page