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

Method PlayNote

Source/NoteCanvas.cpp:104–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104void NoteCanvas::PlayNote(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation)
105{
106 mNoteOutput.PlayNote(time, pitch, velocity, voiceIdx, modulation);
107
108 if (!mEnabled || !mRecord)
109 return;
110
111 if (mInputNotes[pitch]) //handle note-offs or retriggers
112 {
113 double endPos = GetCurPos(time);
114 if (mInputNotes[pitch]->GetStart() > endPos)
115 endPos += 1; //wrap
116 mInputNotes[pitch]->SetEnd(endPos);
117 mInputNotes[pitch] = nullptr;
118 }
119
120 if (velocity > 0)
121 {
122 if (mFreeRecord && mFreeRecordStartMeasure == -1)
123 mFreeRecordStartMeasure = TheTransport->GetMeasure(time);
124
125 double measurePos = GetCurPos(time) * mNumMeasures;
126 NoteCanvasElement* element = AddNote(measurePos, pitch, velocity, 1 / mCanvas->GetNumCols(), voiceIdx, modulation);
127 mInputNotes[pitch] = element;
128 mCanvas->SetRowOffset(element->mRow - mCanvas->GetNumVisibleRows() / 2);
129 }
130}
131
132void NoteCanvas::KeyPressed(int key, bool isRepeat)
133{

Callers 1

OnTransportAdvancedMethod · 0.45

Calls 6

GetStartMethod · 0.80
SetEndMethod · 0.80
GetMeasureMethod · 0.80
GetNumColsMethod · 0.80
SetRowOffsetMethod · 0.80
GetNumVisibleRowsMethod · 0.80

Tested by

no test coverage detected