Deactivates all notes that are not held, and reactivates notes that are. */
| 628 | |
| 629 | /** Deactivates all notes that are not held, and reactivates notes that are. */ |
| 630 | void refreshHeld() { |
| 631 | // Monophonic |
| 632 | if (channels <= 1) { |
| 633 | // Reactivate note if at least one is held |
| 634 | if (!heldNotes.empty()) { |
| 635 | if (monoMode == LAST_PRIORITY_MODE) { |
| 636 | notes[0] = heldNotes.back(); |
| 637 | } |
| 638 | if (monoMode == FIRST_PRIORITY_MODE) { |
| 639 | notes[0] = heldNotes.front(); |
| 640 | } |
| 641 | if (monoMode == LOWEST_PRIORITY_MODE) { |
| 642 | notes[0] = *std::min_element(heldNotes.begin(), heldNotes.end()); |
| 643 | } |
| 644 | if (monoMode == HIGHEST_PRIORITY_MODE) { |
| 645 | notes[0] = *std::max_element(heldNotes.begin(), heldNotes.end()); |
| 646 | } |
| 647 | gates[0] = true; |
| 648 | if (retriggerOnResume) { |
| 649 | retriggerPulses[0].trigger(1e-3); |
| 650 | } |
| 651 | } |
| 652 | else { |
| 653 | gates[0] = false; |
| 654 | } |
| 655 | } |
| 656 | // Polyphonic |
| 657 | else { |
| 658 | // Deactivate notes that are not held |
| 659 | for (uint8_t c = 0; c < channels; c++) { |
| 660 | if (!gates[c]) |
| 661 | continue; |
| 662 | // Check if note is still held |
| 663 | bool held = std::find(heldNotes.begin(), heldNotes.end(), notes[c]) != heldNotes.end(); |
| 664 | if (!held) |
| 665 | gates[c] = false; |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | void pressPedal() { |
| 671 | if (pedal) |