| 142 | } |
| 143 | |
| 144 | void NoteCanvas::OnTransportAdvanced(float amount) |
| 145 | { |
| 146 | PROFILER(NoteCanvas); |
| 147 | |
| 148 | if (mFreeRecord && mFreeRecordStartMeasure != -1) |
| 149 | { |
| 150 | if (TheTransport->GetMeasurePos(gTime) < amount && |
| 151 | !FreeRecordParityMatched()) |
| 152 | { |
| 153 | int oldNumMeasures = mNumMeasures; |
| 154 | while (!FreeRecordParityMatched()) |
| 155 | mNumMeasures *= 2; |
| 156 | int shift = mFreeRecordStartMeasure % mNumMeasures - mFreeRecordStartMeasure % oldNumMeasures; |
| 157 | SetNumMeasures(mNumMeasures); |
| 158 | |
| 159 | for (auto* element : mCanvas->GetElements()) |
| 160 | element->SetStart(element->GetStart() + float(shift) / mNumMeasures, true); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | if (mStopQueued) |
| 165 | { |
| 166 | mNoteOutput.Flush(NextBufferTime(false)); |
| 167 | for (int i = 0; i < mCurrentNotes.size(); ++i) |
| 168 | mCurrentNotes[i] = nullptr; |
| 169 | mStopQueued = false; |
| 170 | } |
| 171 | |
| 172 | if (!mEnabled || !mPlay) |
| 173 | { |
| 174 | mCanvas->SetCursorPos(-1); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | double cursorPlayTime = gTime; |
| 179 | //if (Transport::sDoEventLookahead)??? should we? |
| 180 | // cursorPlayTime += Transport::sEventEarlyMs; |
| 181 | //else |
| 182 | cursorPlayTime += amount * TheTransport->MsPerBar(); |
| 183 | double curPos = GetCurPos(cursorPlayTime); |
| 184 | |
| 185 | mCanvas->FillElementsAt(curPos, mNoteChecker); |
| 186 | for (int i = 0; i < 128; ++i) |
| 187 | { |
| 188 | int pitch = 128 - i - 1; |
| 189 | bool wasOn = mCurrentNotes[pitch] != nullptr || mInputNotes[pitch]; |
| 190 | bool nowOn = mNoteChecker[i] != nullptr || mInputNotes[pitch]; |
| 191 | bool hasChanged = (nowOn || wasOn) && mCurrentNotes[pitch] != static_cast<NoteCanvasElement*>(mNoteChecker[i]); |
| 192 | |
| 193 | if (wasOn && mInputNotes[pitch] == nullptr && hasChanged) |
| 194 | { |
| 195 | //note off |
| 196 | if (mCurrentNotes[pitch]) |
| 197 | { |
| 198 | double cursorAdvanceSinceEvent = curPos - mCurrentNotes[pitch]->GetEnd(); |
| 199 | if (cursorAdvanceSinceEvent < 0) |
| 200 | cursorAdvanceSinceEvent += 1; |
| 201 | double time = cursorPlayTime - cursorAdvanceSinceEvent * TheTransport->MsPerBar() * mNumMeasures; |
nothing calls this directly
no test coverage detected