|
|
|
|
|
|
|
|
#include "MidiListener.h" |
|
|
|
|
|
#include <vector> |
|
|
|
|
|
#include <QString> |
|
|
|
|
|
void MidiListener::start(int Port){ |
|
|
|
|
|
midiin = new RtMidiIn(RtMidi::Api::LINUX_ALSA, "Scrjabin"); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
midiin->openPort(Port); |
|
|
|
|
|
} |
|
|
|
|
|
catch ( RtMidiError &error ) { |
|
|
|
|
|
error.printMessage(); |
|
|
|
|
|
} |
|
|
|
|
|
emit newMidiMessage(0,0,0); |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
void MidiListener::listen(){ |
|
|
|
|
|
std::vector<unsigned char> message; |
|
|
|
|
|
|
|
|
|
|
|
// Don't ignore sysex, timing, or active sensing messages. |
|
|
|
|
|
midiin->ignoreTypes( false, false, false ); |
|
|
|
|
|
|
|
|
|
|
|
midiin->getMessage( &message ); |
|
|
|
|
|
if ( message.size() == 3 ) |
|
|
|
|
|
emit newMidiMessage(message[0], message[1], message[2]); |
|
|
|
|
|
else |
|
|
|
|
|
emit newMidiMessage(0,0,0); |
|
|
|
|
|
}; |
|
|
|
|
|
void MidiListener::stop(){ |
|
|
|
|
|
delete midiin; |
|
|
|
|
|
this->disconnect(); |
|
|
|
|
|
this->~MidiListener(); |
|
|
|
|
|
} |
|
|
|
|
|
MidiListener::~MidiListener(){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|