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

Method OnTransportAdvanced

Source/EventCanvas.cpp:108–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void 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

Callers

nothing calls this directly

Calls 15

DoubleWrapFunction · 0.85
FloatWrapFunction · 0.85
GetMeasureMethod · 0.80
SetCursorPosMethod · 0.80
MsPerBarMethod · 0.80
GetStartMethod · 0.80
GetEndMethod · 0.80
TriggerMethod · 0.80
TriggerEndMethod · 0.80
sizeMethod · 0.80
GetNumColsMethod · 0.80
AddElementMethod · 0.80

Tested by

no test coverage detected