fix linux builds

This commit is contained in:
2026-02-01 20:15:42 -06:00
parent 858b6c789a
commit 289318140c
6 changed files with 49 additions and 29 deletions

View File

@@ -6,7 +6,7 @@
MidiController::MidiController(NoteQueue& queue) : noteQueue_(queue) {
try {
midiIn_ = std::make_unique<RtMidiIn>();
midiIn_ = std::make_unique<RtMidiIn>(RtMidi::LINUX_ALSA);
midiIn_->ignoreTypes(false, false, false);
} catch (RtMidiError& e) {
std::cout << "RtMidi init failed: " << e.getMessage() << std::endl;
@@ -18,14 +18,23 @@ MidiController::~MidiController() {
close();
}
// this dont work too well but whatever
// open the first for thats successful
bool MidiController::openDefaultPort() {
if (!midiIn_) return false;
if (midiIn_->getPortCount() == 0) {
std::cout << "No MIDI input ports available" << std::endl;
return false;
}
return openPort(0);
uint32_t portCount = midiIn_->getPortCount();
std::cout << "Available MidiIn ports: " << portCount << std::endl;
for (int i = 0; i < portCount; i++) {
std::cout << "#" << i << " : " << midiIn_->getPortName(i) << std::endl;
if(openPort(i)) return true;
}
return false;
}
bool MidiController::openPort(unsigned int index) {
@@ -37,6 +46,7 @@ bool MidiController::openPort(unsigned int index) {
std::cout << "Opened MIDI port: " << midiIn_->getPortName(index) << std::endl;
return true;
} catch (RtMidiError& e) {
std::cout << "Midi Port error" << std::endl;
std::cerr << e.getMessage() << std::endl;
return false;
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include <RtMidi.h>
#include <rtmidi/RtMidi.h>
#include <memory>
#include "NoteQueue.h"
#include <unordered_set>

View File

@@ -115,7 +115,8 @@ MainWindow::MainWindow(QWidget *parent) :
// midi
#ifndef _WIN32
midi_.openPort(1); // TODO: error check
//midi_.openDefaultPort(); // TODO: error check
midi_.openPort(1);
#endif
}