| 70 | } |
| 71 | |
| 72 | void NoteTransformer::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation) |
| 73 | { |
| 74 | if (!mEnabled) |
| 75 | { |
| 76 | PlayNoteOutput(time, pitch, velocity, voiceIdx, modulation); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | if (velocity == 0) //note off the one we played for this pitch, in case the transformer changed it while the note was held |
| 81 | { |
| 82 | if (mLastNoteOnForPitch[pitch] != -1) |
| 83 | PlayNoteOutput(time, mLastNoteOnForPitch[pitch], 0, voiceIdx); |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | int tone = TheScale->GetToneFromPitch(pitch); |
| 88 | if (velocity > 0) |
| 89 | mLastTimeTonePlayed[tone % 7] = time; |
| 90 | int pitchOffset = pitch - TheScale->GetPitchFromTone(tone); |
| 91 | |
| 92 | tone += mToneMod[tone % TheScale->NumTonesInScale()]; |
| 93 | |
| 94 | int outPitch = TheScale->GetPitchFromTone(tone) + pitchOffset; |
| 95 | PlayNoteOutput(time, outPitch, velocity, voiceIdx, modulation); |
| 96 | mLastNoteOnForPitch[pitch] = outPitch; |
| 97 | } |
| 98 | |
| 99 | void NoteTransformer::LoadLayout(const ofxJSONElement& moduleInfo) |
| 100 | { |
nothing calls this directly
no test coverage detected