| 58 | } |
| 59 | |
| 60 | void Monophonify::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation) |
| 61 | { |
| 62 | if (!mEnabled) |
| 63 | { |
| 64 | PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | if (pitch < 0 || pitch >= 128) |
| 69 | return; |
| 70 | |
| 71 | mPitchBend.AppendTo(modulation.pitchBend); |
| 72 | modulation.pitchBend = &mPitchBend; |
| 73 | |
| 74 | voiceIdx = mVoiceIdx; |
| 75 | |
| 76 | if (velocity > 0) |
| 77 | { |
| 78 | mLastVelocity = velocity; |
| 79 | |
| 80 | int currentlyHeldPitch = GetMostRecentCurrentlyHeldPitch(); |
| 81 | |
| 82 | if (currentlyHeldPitch != -1) |
| 83 | { |
| 84 | if (mPortamentoMode == PortamentoMode::kBendHeld) |
| 85 | { |
| 86 | //just bend to the new note |
| 87 | mPitchBend.RampValue(time, mPitchBend.GetIndividualValue(0), pitch - mInitialPitch, mGlideTime); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | //trigger new note and bend |
| 92 | mPitchBend.RampValue(time, currentlyHeldPitch - pitch + mPitchBend.GetIndividualValue(0), 0, mGlideTime); |
| 93 | PlayNoteOutput(time, currentlyHeldPitch, 0, -1, modulation); |
| 94 | PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation); |
| 95 | } |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | if (mPortamentoMode == PortamentoMode::kAlways && mLastPlayedPitch != -1) |
| 100 | { |
| 101 | //bend to new note |
| 102 | mPitchBend.RampValue(time, mLastPlayedPitch - pitch + mPitchBend.GetIndividualValue(0), 0, mGlideTime); |
| 103 | } |
| 104 | else |
| 105 | { |
| 106 | //reset pitch bend |
| 107 | mPitchBend.RampValue(time, 0, 0, 0); |
| 108 | } |
| 109 | |
| 110 | mInitialPitch = pitch; |
| 111 | PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation); |
| 112 | } |
| 113 | mLastPlayedPitch = pitch; |
| 114 | mHeldNotes[pitch] = time; |
| 115 | } |
| 116 | else |
| 117 | { |
nothing calls this directly
no test coverage detected