wxMidi - A MIDI interface based on PortMidi
wxMidiSystem Class Reference

Class wxMidiSystem is the entry point to the wxMidi library. More...

#include <wxMidi.h>

Public Member Functions

 ~wxMidiSystem ()
 Destructor.
 
wxMidiTimestamp GetTime ()
 Returns current value of the Midi timer. More...
 
const wxString GetErrorText (wxMidiError errnum)
 Translates a portmidi error number into a human readable message. More...
 
wxString GetHostErrorText ()
 Translate portmidi host error into human readable message. More...
 
int CountDevices ()
 Returns the number of MIDI devices present in the system. More...
 

Static Public Member Functions

static wxMidiSystemGetInstance ()
 Returns a pointer to the only wxMidiSystem instance. More...
 

Detailed Description

Class wxMidiSystem is the entry point to the wxMidi library.

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 wxMidiSystem::GetInstance().

Member Function Documentation

◆ CountDevices()

int wxMidiSystem::CountDevices ( )
inline

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 wxMidiDevice::IsInput() or wxMidiDevice::IsOutput(), as in the following example:

// populate two combo boxes with the available Midi devices,
// one combo box with input devices and the other one
// with output devices.
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().c_str(),
pMidiDev->InterfaceUsed().c_str() );
nItem = m_pOutCombo->Append(sMsg);
m_pOutCombo->SetClientData(nItem, reinterpret_cast<void*>(i));
}
if (pMidiDev->IsInputPort()) {
nInput++;
sMsg.Printf(_T("%s [%s]"),
pMidiDev->DeviceName().c_str(),
pMidiDev->InterfaceUsed().c_str() );
nItem = m_pInCombo->Append(sMsg);
m_pInCombo->SetClientData(nItem, reinterpret_cast<void*>(i));
}
delete pMidiDev;
}
if (nOutput > 0) m_pOutCombo->SetSelection(0);
if (nInput > 0) m_pInCombo->SetSelection(0);

◆ GetErrorText()

const wxString wxMidiSystem::GetErrorText ( wxMidiError  errnum)

Translates a portmidi error number into a human readable message.

For an explanation of error codes see wxMidi error codes.

◆ GetHostErrorText()

wxString wxMidiSystem::GetHostErrorText ( )

Translate portmidi host error into human readable message.

After this routine executes, the host error is cleared.

◆ GetInstance()

wxMidiSystem * wxMidiSystem::GetInstance ( )
static

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.

◆ GetTime()

wxMidiTimestamp wxMidiSystem::GetTime ( )
inline

Returns current value of the Midi timer.

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


The documentation for this class was generated from the following files: