wxMidiSystem

wxMidiSystem acts as the user application's entry point to the MIDI music system. It provides information about, and access to, the set of installed MIDI devices.

wxMidiSystem is a singleton and, therefore, the constructor is not public. Access to the only instance must be through method GetInstance.

Members

wxMidiSystem::CountDevices
wxMidiSystem::GetErrorText
wxMidiSystem::GetHostErrorText
wxMidiSystem::GetInstance
wxMidiSystem::GetTime
wxMidiSystem::~wxMidiSystem


wxMidiSystem::CountDevices

int CountDevices()

Returns the number of MIDI devices present in the system. The IDs of the MIDI devices will range from 0 to CountDevices() - 1. So, for example, if CountDevices() returns 3, it means that there are three MIDI devices in the system and that their IDs will be 0, 1 and 2.To determine if they are output devices or input devices, you will have to instantiate the corresponding wxMidiDevice object and use methods IsInput() or IsOutput(), as in the following example:

. Example

	// populate two combo boxes with available Midi devices, 
	// one combo box with in devices and the other one 
	// with out devices.
	
	wxMidiSystem* pMidi = wxMidiSystem::GetInstance();
	int nNumDevices = pMidi->CountDevices();
	wxString sMsg;

	// get available input and output devices
	int nItem, nInput=0, nOutput=0;
	for (int i = 0; i < nNumDevices; i++) {
      	wxMidiOutDevice* pMidiDev = new wxMidiOutDevice(i);
      	if (pMidiDev->IsOutputPort()) {
			nOutput++;
			sMsg.Printf(_T("%s [%s]"),
					pMidiDev->DeviceName(),
					pMidiDev->InterfaceUsed() );
			nItem = m_pOutCombo->Append(sMsg);
			m_pOutCombo->SetClientData(nItem, (void *)i);
      	}
		if (pMidiDev->IsInputPort()) {
			nInput++;
			sMsg.Printf(_T("%s [%s]"),
					pMidiDev->DeviceName(),
					pMidiDev->InterfaceUsed() );
			nItem = m_pInCombo->Append(sMsg);
			m_pInCombo->SetClientData(nItem, (void *)i);
      	}
		delete pMidiDev;
   	}
	if (nOutput > 0) m_pOutCombo->SetSelection(0);
	if (nInput > 0) m_pInCombo->SetSelection(0);


wxMidiSystem::GetErrorText

const wxString GetErrorText(wxMidiError errnum )

Translates a portmidi error number into a human readable message. For a explanation of error codes see wxMidi error codes.


wxMidiSystem::GetHostErrorText

wxString GetHostErrorText()

Translate portmidi host error into human readable message. After this routine executes, the host error is cleared.


wxMidiSystem::GetInstance

wxMidiError GetInstance()

Returns a pointer to the only wxMidiSystem instance. Note that wxMidiSystem is a singleton and, therefore, the constructor is not public. Access to the only instance must be through this GetInstance() method.


wxMidiSystem::GetTime

wxMidiTimestamp GetTime()

Returns current value of the Midi timer. This timer is started when the Midi package is initialized and has a resolution of one millisecond.


wxMidiSystem::~wxMidiSystem

~wxMidiSystem()

Destructror.