Esempio n. 1
0
bool MidiInRt::getPortList(QVector<QString> &ports)
{
    RtMidiIn *midiin = lazyInstance();
#if (QT_VERSION < 0x050000) && defined(_WIN32)
    RtMidi::Api api = midiin->getCurrentApi();
#endif

    m_errorSignaled = false;
    unsigned count = midiin->getPortCount();
    if(m_errorSignaled)
        return false;

    ports.resize(count);
    for(unsigned i = 0; i < count; ++i)
    {
        m_errorSignaled = false;
#if (QT_VERSION < 0x050000) && defined(_WIN32)
        if(api == RtMidi::WINDOWS_MM)
        {
            MIDIINCAPSA deviceCaps;
            midiInGetDevCapsA(i, &deviceCaps, sizeof(MIDIINCAPSA));
            ports[i] = QString::fromLocal8Bit(deviceCaps.szPname);
        }
        else
#endif
        {
            std::string name = midiin->getPortName(i);
            if(m_errorSignaled)
                return false;
            ports[i] = QString::fromStdString(name);
        }
    }
    return true;
}
Esempio n. 2
0
int main()
{
  // Create an api map.
  std::map<int, std::string> apiMap;
  apiMap[RtMidi::MACOSX_CORE] = "OS-X CoreMidi";
  apiMap[RtMidi::WINDOWS_MM] = "Windows MultiMedia";
  apiMap[RtMidi::UNIX_JACK] = "Jack Client";
  apiMap[RtMidi::LINUX_ALSA] = "Linux ALSA";
  apiMap[RtMidi::RTMIDI_DUMMY] = "RtMidi Dummy";

  std::vector< RtMidi::Api > apis;
  RtMidi :: getCompiledApi( apis );

  std::cout << "\nCompiled APIs:\n";
  for ( unsigned int i=0; i<apis.size(); i++ )
    std::cout << "  " << apiMap[ apis[i] ] << std::endl;

  RtMidiIn  *midiin = 0;
  RtMidiOut *midiout = 0;

  try {

    // RtMidiIn constructor ... exception possible
    midiin = new RtMidiIn();

    std::cout << "\nCurrent input API: " << apiMap[ midiin->getCurrentApi() ] << std::endl;

    // Check inputs.
    unsigned int nPorts = midiin->getPortCount();
    std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";

    for ( unsigned i=0; i<nPorts; i++ ) {
      std::string portName = midiin->getPortName(i);
      std::cout << "  Input Port #" << i+1 << ": " << portName << '\n';
    }

    // RtMidiOut constructor ... exception possible
    midiout = new RtMidiOut();

    std::cout << "\nCurrent output API: " << apiMap[ midiout->getCurrentApi() ] << std::endl;

    // Check outputs.
    nPorts = midiout->getPortCount();
    std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";

    for ( unsigned i=0; i<nPorts; i++ ) {
      std::string portName = midiout->getPortName(i);
      std::cout << "  Output Port #" << i+1 << ": " << portName << std::endl;
    }
    std::cout << std::endl;

  } catch ( RtMidiError &error ) {
    error.printMessage();
  }

  delete midiin;
  delete midiout;

  return 0;
}
Esempio n. 3
0
bool MidiInRt::canOpenVirtual()
{
    RtMidiIn *midiin = lazyInstance();
    switch(midiin->getCurrentApi())
    {
    default:
        return true;
    case RtMidi::WINDOWS_MM:
    case RtMidi::RTMIDI_DUMMY:
        return false;
    }
}
Esempio n. 4
0
enum RtMidiApi rtmidi_in_get_current_api (RtMidiPtr device)
{
#if defined(__NO_EXCEPTIONS__)
    RtMidiIn* rtm = (RtMidiIn*) device->ptr;
    rtm->resetError();
    RtMidiApi curApi = (RtMidiApi) rtm->getCurrentApi ();
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return RT_MIDI_API_UNSPECIFIED;
    }
    return curApi;
#else
    try {
        return (RtMidiApi) ((RtMidiIn*) device->ptr)->getCurrentApi ();
    
    } catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();

        return RT_MIDI_API_UNSPECIFIED;
    }
#endif
}