| 230 | } |
| 231 | |
| 232 | void NoteLooper::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation) |
| 233 | { |
| 234 | if (voiceIdx != -1) //try to pick a voice that is unique, to avoid stomping on the voices of already-recorded notes when overdubbing |
| 235 | { |
| 236 | if (velocity > 0) |
| 237 | voiceIdx = GetNewVoice(voiceIdx); |
| 238 | else |
| 239 | voiceIdx = mVoiceMap[voiceIdx]; |
| 240 | } |
| 241 | |
| 242 | mNoteOutput.PlayNote(time, pitch, velocity, voiceIdx, modulation); |
| 243 | |
| 244 | if ((mEnabled && mWrite) || (mInputNotes[pitch] && velocity == 0)) |
| 245 | { |
| 246 | if (mInputNotes[pitch]) //handle note-offs or retriggers |
| 247 | { |
| 248 | double endPos = GetCurPos(time); |
| 249 | if (mInputNotes[pitch]->GetStart() > endPos) |
| 250 | endPos += 1; //wrap |
| 251 | mInputNotes[pitch]->SetEnd(endPos); |
| 252 | mInputNotes[pitch] = nullptr; |
| 253 | } |
| 254 | |
| 255 | if (velocity > 0) |
| 256 | { |
| 257 | double measurePos = GetCurPos(time) * mNumMeasures; |
| 258 | NoteCanvasElement* element = AddNote(measurePos, pitch, velocity, 1 / mCanvas->GetNumCols(), voiceIdx, modulation); |
| 259 | mInputNotes[pitch] = element; |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | NoteCanvasElement* NoteLooper::AddNote(double measurePos, int pitch, int velocity, double length, int voiceIdx /*=-1*/, ModulationParameters modulation /* = ModulationParameters()*/) |
| 265 | { |
no test coverage detected