| 106 | } |
| 107 | |
| 108 | void EventCanvas::OnTransportAdvanced(float amount) |
| 109 | { |
| 110 | PROFILER(EventCanvas); |
| 111 | |
| 112 | if (mCanvas == nullptr) |
| 113 | return; |
| 114 | |
| 115 | //look ahead two buffers so that we set things slightly early, so we'll do things like catch the downbeat right after enabling a sequencer, etc. |
| 116 | double lookaheadMsAmount = gBufferSizeMs * 2; |
| 117 | double lookaheadTime = gTime + lookaheadMsAmount; |
| 118 | double lookaheadPos = DoubleWrap(((TheTransport->GetMeasure(lookaheadTime) % mNumMeasures) + TheTransport->GetMeasurePos(lookaheadTime)) / mNumMeasures, 1); |
| 119 | |
| 120 | mCanvas->SetCursorPos(lookaheadPos); |
| 121 | mPosition = lookaheadPos; |
| 122 | double bufferOffsetAmount = gBufferSizeMs / TheTransport->MsPerBar() / mNumMeasures; |
| 123 | mPreviousPosition = std::min(mPreviousPosition, lookaheadPos - bufferOffsetAmount); |
| 124 | |
| 125 | if (!mEnabled) |
| 126 | return; |
| 127 | |
| 128 | for (auto* canvasElement : mCanvas->GetElements()) |
| 129 | { |
| 130 | float elementStart = canvasElement->GetStart(); |
| 131 | bool startPassed = (lookaheadPos >= elementStart && mPreviousPosition < elementStart); |
| 132 | float elementEnd = canvasElement->GetEnd(); |
| 133 | if (elementEnd > mCanvas->GetLength()) |
| 134 | elementEnd = FloatWrap(elementEnd, mCanvas->GetLength()); |
| 135 | bool endPassed = (lookaheadPos >= elementEnd && mPreviousPosition < elementEnd); |
| 136 | if (startPassed || endPassed) |
| 137 | { |
| 138 | EventCanvasElement* element = static_cast<EventCanvasElement*>(canvasElement); |
| 139 | if (lookaheadPos > elementEnd) |
| 140 | { |
| 141 | if (startPassed) |
| 142 | element->Trigger(GetTriggerTime(lookaheadTime, lookaheadPos, elementStart)); |
| 143 | if (endPassed) |
| 144 | element->TriggerEnd(GetTriggerTime(lookaheadTime, lookaheadPos, elementEnd)); |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | if (endPassed) |
| 149 | element->TriggerEnd(GetTriggerTime(lookaheadTime, lookaheadPos, elementEnd)); |
| 150 | if (startPassed) |
| 151 | element->Trigger(GetTriggerTime(lookaheadTime, lookaheadPos, elementStart)); |
| 152 | } |
| 153 | |
| 154 | IUIControl* control = mRowConnections[element->mRow].mUIControl; |
| 155 | if (control) |
| 156 | mRowConnections[element->mRow].mLastValue = control->GetValue(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | for (int i = 0; i < mControlCables.size(); ++i) |
| 161 | { |
| 162 | if (mRowConnections[i].mUIControl) |
| 163 | { |
| 164 | float value = mRowConnections[i].mUIControl->GetValue(); |
| 165 |
nothing calls this directly
no test coverage detected