MIDI **********/
| 1315 | |
| 1316 | /********** MIDI **********/ |
| 1317 | void MainWindow::midiThreadReceivedEvent(double delay, const uint8_t *msg, size_t len, void *userData) |
| 1318 | { |
| 1319 | MainWindow *self = reinterpret_cast<MainWindow *>(userData); |
| 1320 | |
| 1321 | Q_UNUSED(delay) |
| 1322 | |
| 1323 | // Note-On/Note-Off |
| 1324 | if (len == 3 && (msg[0] & 0xe0) == 0x80) { |
| 1325 | uint8_t status = msg[0]; |
| 1326 | uint8_t key = msg[1]; |
| 1327 | uint8_t velocity = msg[2]; |
| 1328 | QMetaMethod method = self->metaObject()->method(self->midiKeyEventMethod_); |
| 1329 | method.invoke(self, Qt::QueuedConnection, |
| 1330 | Q_ARG(uchar, status), Q_ARG(uchar, key), Q_ARG(uchar, velocity)); |
| 1331 | } |
| 1332 | // Program change |
| 1333 | else if (len == 2 && (msg[0] & 0xf0) == 0xc0) { |
| 1334 | uint8_t status = msg[0]; |
| 1335 | uint8_t program = msg[1]; |
| 1336 | QMetaMethod method = self->metaObject()->method(self->midiProgramEventMethod_); |
| 1337 | method.invoke(self, Qt::QueuedConnection, |
| 1338 | Q_ARG(uchar, status), Q_ARG(uchar, program)); |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | void MainWindow::midiKeyEvent(uchar status, uchar key, uchar velocity) |
| 1343 | { |