MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / PlayNote

Method PlayNote

Source/NoteLooper.cpp:232–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232void 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
264NoteCanvasElement* NoteLooper::AddNote(double measurePos, int pitch, int velocity, double length, int voiceIdx /*=-1*/, ModulationParameters modulation /* = ModulationParameters()*/)
265{

Callers 3

OnTransportAdvancedMethod · 0.45
CheckboxUpdatedMethod · 0.45
ButtonClickedMethod · 0.45

Calls 3

GetStartMethod · 0.80
SetEndMethod · 0.80
GetNumColsMethod · 0.80

Tested by

no test coverage detected