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.

MidiListener.cpp 817B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "MidiListener.h"
  2. #include <vector>
  3. #include <QString>
  4. void MidiListener::start(int Port){
  5. midiin = new RtMidiIn(RtMidi::Api::LINUX_ALSA, "Scrjabin");
  6. try {
  7. midiin->openPort(Port);
  8. }
  9. catch ( RtMidiError &error ) {
  10. error.printMessage();
  11. }
  12. emit newMidiMessage(0,0,0);
  13. };
  14. void MidiListener::listen(){
  15. std::vector<unsigned char> message;
  16. // Don't ignore sysex, timing, or active sensing messages.
  17. midiin->ignoreTypes( false, false, false );
  18. midiin->getMessage( &message );
  19. if ( message.size() == 3 )
  20. emit newMidiMessage(message[0], message[1], message[2]);
  21. else
  22. emit newMidiMessage(0,0,0);
  23. };
  24. void MidiListener::stop(){
  25. delete midiin;
  26. this->disconnect();
  27. this->~MidiListener();
  28. }
  29. MidiListener::~MidiListener(){
  30. }