示例#1
0
QStringList CMidiDeviceRt::getMidiPortList(midiType_t type)
{
    unsigned int nPorts;
    QString name;
    RtMidi* midiDevice;
    QStringList portNameList;

    if (type == MIDI_INPUT)
        midiDevice = m_midiin;
    else
        midiDevice = m_midiout;

    nPorts = midiDevice->getPortCount();

    for(unsigned int i=0; i< nPorts; i++)
    {
        // kotechnology creating indexed string from the post name
        name = addIndexToString(midiDevice->getPortName(i).c_str(),i);
        if (name.contains("RtMidi Output Client"))
            continue;
        if (name.contains("RtMidi Input Client"))
            continue;
         portNameList << name;
    }


    return portNameList;
}
示例#2
0
bool CMidiDeviceRt::openMidiPort(midiType_t type, QString portName)
{
    unsigned int nPorts;
    QString name;
    RtMidi* midiDevice;


    if (portName.length() == 0)
        return false;

    int dev;
    if (type == MIDI_INPUT)
    {
        midiDevice = m_midiin;
        dev = 0;
    }
    else
    {
        midiDevice = m_midiout;
        dev = 1;
    }

    nPorts = midiDevice->getPortCount();

    for(unsigned int i=0; i< nPorts; i++)
    {
        // kotechnology creating indexed string from the post name
        name = addIndexToString(midiDevice->getPortName(i).c_str(),i);
        if (name == portName) // Test for a match
        {
            if (m_midiPorts[dev] >= 0)
                midiDevice->closePort();

            m_midiPorts[dev] = i;
            m_rawDataIndex = 0;

            midiDevice->openPort( i );
            return true;
        }
    }
    return false;
}
示例#3
0
const char* rtmidi_get_port_name (RtMidiPtr device, unsigned int portNumber)
{
#if defined(__NO_EXCEPTIONS__)
    RtMidi* rtm = (RtMidi*) device->ptr;
    rtm->resetError();
    std::string name = rtm->getPortName (portNumber);
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return "";
    }
    return strdup (name.c_str ());
#else
    try {
        std::string name = ((RtMidi*) device->ptr)->getPortName (portNumber);
        return strdup (name.c_str ());
    
    } catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();
        return "";
    }
#endif
}