Browse Source

implemented MidiProbe-Class

master
Lars Mewes 3 years ago
parent
commit
f202d250f8
1 changed files with 45 additions and 0 deletions
  1. 45
    0
      MidiProbe.cpp

+ 45
- 0
MidiProbe.cpp View File

@@ -0,0 +1,45 @@
#include "MidiProbe.h"
#include <QErrorMessage>
#include <string>

MidiProbe::MidiProbe()
{
midiin = new RtMidiIn();
portCount = midiin->getPortCount();
}

unsigned int MidiProbe::getPort()
{
QString selectedPort = "";
unsigned int i=0;
if(portCount==0)
{
QErrorMessage * message = new QErrorMessage();
message->setWindowTitle("Fehler!");
message->setWindowFlags(message->windowFlags()^Qt::WindowContextHelpButtonHint);
message->setModal(true);
message->showMessage("Keine MIDI-Geräte erkannt!");
}
else if(portCount == 1) //automatically select port 0 if it is the only one
{
return(0);
}
else if(portCount == 2) // let user select port
{
for(i=0; i<portCount; i++)
midiDevices.push_back(QString::fromStdString(midiin->getPortName(i)));

QInputDialog * dialog = new QInputDialog();
dialog->setWindowFlags(dialog->windowFlags()^Qt::WindowContextHelpButtonHint);
dialog->setModal(true);

selectedPort = dialog->getItem(nullptr, "Bitte ein Midi-Gerät auswählen:", "Midi-Geräte:", midiDevices, 0, true);
for(i=0; i<portCount; i++)
if(selectedPort==midiDevices.at(i)) return i;


}
return 100;
}



Loading…
Cancel
Save