我找不到相关的解决方案,所以我终于在这里发布了。 我有一个非常小的程序,它使用RTMidi库将控制器键映射为热键。一切在调试模式下都可以正常工作,发布应用程序也不会给我任何错误,但是RTMidiIn类在发布版本中找不到任何端口。
这是我的代码
MidiToMacro::MidiToMacro(QWidget *parent)
: QMainWindow(parent)
{
m_ui.setupUi(this);
RtMidiIn *midiin;
try
{
midiin = new RtMidiIn(RtMidi::WINDOWS_MM);
}
catch (RtMidiError &error) {
m_ui.uiLog->append("midiin initiation failed!");
error.printMessage();
exit(EXIT_FAILURE);
}
unsigned int nPorts = midiin->getPortCount();
QString inputCount = QString::number(nPorts);
m_ui.uiLog->append("There are " + inputCount + " MIDI input sources
available.");
std::string portName;
std::string akai = "Akai MPK49 2";
opened = 1000;
for (unsigned int i = 0; i < nPorts;++i)
{
try
{
portName = midiin->getPortName(i);
if (portName == akai)
{
midiin->openPort(i);
midiin->setCallback(&mycallback, this);
opened = i;
}
}
catch (RtMidiError &error)
{
//not printing an error
error.printMessage();
delete midiin;
}
QString portnumber = QString::number(i);
m_ui.uiLog->append(" Input Port #" + portnumber + ": " + QString::fromStdString(portName));
}
if (opened == 1000)
{
m_ui.uiLog->append("Error finding Akai Controller!");
}
答案 0 :(得分:0)
忘记在发行版的预处理器定义中定义WINDOWS_MM。