MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / HandleKeyboardNote

Method HandleKeyboardNote

Source/FamiTrackerView.cpp:2701–2757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2699}
2700
2701void CFamiTrackerView::HandleKeyboardNote(char nChar, bool Pressed)
2702{
2703 if (FTEnv.GetAccelerator()->IsKeyUsed(nChar))
2704 return; // // //
2705
2706 // Play a note from the keyboard
2707 int Note = TranslateKey(nChar);
2708 int Channel = GetSelectedChannel();
2709
2710 if (Pressed) {
2711 if (CheckHaltKey(nChar)) {
2712 if (m_bEditEnable)
2713 CutMIDINote(Channel, m_iLastPressedKey, true);
2714 else {
2715 for (const auto &x : m_iNoteCorrection) // // //
2716 CutMIDINote(Channel, TranslateKey(x.first), false);
2717 m_iNoteCorrection.clear();
2718 }
2719 }
2720 else if (CheckReleaseKey(nChar)) {
2721 if (m_bEditEnable)
2722 ReleaseMIDINote(Channel, m_iLastPressedKey, true);
2723 else {
2724 for (const auto &x : m_iNoteCorrection) // // //
2725 ReleaseMIDINote(Channel, TranslateKey(x.first), false);
2726 m_iNoteCorrection.clear();
2727 }
2728 }
2729 else {
2730 // Invalid key
2731 if (Note == -1)
2732 return;
2733 TriggerMIDINote(Channel, Note, 0x7F, m_bEditEnable);
2734 m_iLastPressedKey = Note;
2735 m_iNoteCorrection[nChar] = 0; // // //
2736 }
2737 }
2738 else {
2739 if (Note == -1)
2740 return;
2741 // IT doesn't cut the note when key is released
2742 if (FTEnv.GetSettings()->General.iEditStyle != edit_style_t::IT) {
2743 // Find if note release should be used
2744 // TODO: make this an option instead?
2745 if (DoRelease())
2746 ReleaseMIDINote(Channel, Note, false);
2747 else
2748 CutMIDINote(Channel, Note, false);
2749 auto it = m_iNoteCorrection.find(nChar); // // //
2750 if (it != m_iNoteCorrection.end())
2751 m_iNoteCorrection.erase(it);
2752 }
2753 else {
2754 m_pArpeggiator->ReleaseNote(Note); // // //
2755 }
2756 }
2757}
2758

Callers

nothing calls this directly

Calls 6

IsKeyUsedMethod · 0.80
GetAcceleratorMethod · 0.45
clearMethod · 0.45
GetSettingsMethod · 0.45
endMethod · 0.45
ReleaseNoteMethod · 0.45

Tested by

no test coverage detected