| 311 | } |
| 312 | |
| 313 | void processMessage(const midi::Message& msg) |
| 314 | { |
| 315 | // DEBUG("MIDI: %ld %s", msg.getFrame(), msg.toString().c_str()); |
| 316 | |
| 317 | switch (msg.getStatus()) { |
| 318 | // note off |
| 319 | case 0x8: { |
| 320 | releaseNote(msg.getNote()); |
| 321 | } break; |
| 322 | // note on |
| 323 | case 0x9: { |
| 324 | if (msg.getValue() > 0) { |
| 325 | int c = msg.getChannel(); |
| 326 | pressNote(msg.getNote(), &c); |
| 327 | velocities[c] = msg.getValue(); |
| 328 | } |
| 329 | else { |
| 330 | // For some reason, some keyboards send a "note on" event with a velocity of 0 to signal that the key has been released. |
| 331 | releaseNote(msg.getNote()); |
| 332 | } |
| 333 | } break; |
| 334 | // key pressure |
| 335 | case 0xa: { |
| 336 | // Set the aftertouches with the same note |
| 337 | // TODO Should we handle the MPE case differently? |
| 338 | for (int c = 0; c < 16; c++) { |
| 339 | if (notes[c] == msg.getNote()) |
| 340 | aftertouches[c] = msg.getValue(); |
| 341 | } |
| 342 | } break; |
| 343 | // cc |
| 344 | case 0xb: { |
| 345 | processCC(msg); |
| 346 | } break; |
| 347 | // channel pressure |
| 348 | case 0xd: { |
| 349 | if (polyMode == MPE_MODE) { |
| 350 | // Set the channel aftertouch |
| 351 | aftertouches[msg.getChannel()] = msg.getNote(); |
| 352 | } |
| 353 | else { |
| 354 | // Set all aftertouches |
| 355 | for (int c = 0; c < 16; c++) { |
| 356 | aftertouches[c] = msg.getNote(); |
| 357 | } |
| 358 | } |
| 359 | } break; |
| 360 | // pitch wheel |
| 361 | case 0xe: { |
| 362 | int c = (polyMode == MPE_MODE) ? msg.getChannel() : 0; |
| 363 | pws[c] = ((uint16_t) msg.getValue() << 7) | msg.getNote(); |
| 364 | } break; |
| 365 | case 0xf: { |
| 366 | processSystem(msg); |
| 367 | } break; |
| 368 | default: break; |
| 369 | } |
| 370 | } |
nothing calls this directly
no test coverage detected