You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MidiProbe.cpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "MidiProbe.h"
  2. #include <QErrorMessage>
  3. #include <string>
  4. MidiProbe::MidiProbe()
  5. {
  6. midiin = new RtMidiIn();
  7. portCount = midiin->getPortCount();
  8. }
  9. unsigned int MidiProbe::getPort()
  10. {
  11. QString selectedPort = "";
  12. unsigned int i=0;
  13. if(portCount==0)
  14. {
  15. QErrorMessage * message = new QErrorMessage();
  16. message->setWindowTitle("Fehler!");
  17. message->setWindowFlags(message->windowFlags()^Qt::WindowContextHelpButtonHint);
  18. message->setModal(true);
  19. message->showMessage("Keine MIDI-Geräte erkannt!");
  20. }
  21. else if(portCount == 1) //automatically select port 0 if it is the only one
  22. {
  23. return(0);
  24. }
  25. else if(portCount == 2) // let user select port
  26. {
  27. for(i=0; i<portCount; i++)
  28. midiDevices.push_back(QString::fromStdString(midiin->getPortName(i)));
  29. QInputDialog * dialog = new QInputDialog();
  30. dialog->setWindowFlags(dialog->windowFlags()^Qt::WindowContextHelpButtonHint);
  31. dialog->setModal(true);
  32. selectedPort = dialog->getItem(nullptr, "Bitte ein Midi-Gerät auswählen:", "Midi-Geräte:", midiDevices, 0, true);
  33. for(i=0; i<portCount; i++)
  34. if(selectedPort==midiDevices.at(i)) return i;
  35. }
  36. return 100;
  37. }