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

Method Step

Source/ControlSequencer.cpp:105–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void ControlSequencer::Step(double time, int pulseFlags)
106{
107 int length = mLength;
108 if (length <= 0)
109 length = 1;
110
111 int direction = 1;
112 if (pulseFlags & kPulseFlag_Backward)
113 direction = -1;
114 if (pulseFlags & kPulseFlag_Repeat)
115 direction = 0;
116
117 mStep = (mStep + direction + length) % length;
118
119 if (pulseFlags & kPulseFlag_Reset)
120 mStep = 0;
121 else if (pulseFlags & kPulseFlag_Random)
122 mStep = gRandom() % length;
123
124 if (!mHasExternalPulseSource || (pulseFlags & kPulseFlag_SyncToTransport))
125 {
126 mStep = TheTransport->GetSyncedStep(time, this, mTransportListenerInfo, length);
127 }
128
129 if (pulseFlags & kPulseFlag_Align)
130 {
131 int stepsPerMeasure = TheTransport->GetStepsPerMeasure(this);
132 int numMeasures = ceil(float(length) / stepsPerMeasure);
133 int measure = TheTransport->GetMeasure(time) % numMeasures;
134 int step = ((TheTransport->GetQuantized(time, mTransportListenerInfo) % stepsPerMeasure) + measure * stepsPerMeasure) % length;
135 mStep = step;
136 }
137
138 mGrid->SetHighlightCol(time, mStep);
139
140 if (mRecord && mTargets[0] != nullptr)
141 mGrid->SetVal(mStep, 0, mTargets[0]->GetMidiValue());
142
143 if (mEnabled && !mRecord)
144 {
145 mControlCable->AddHistoryEvent(time, true);
146 mControlCable->AddHistoryEvent(time + 15, false);
147
148 for (auto* target : mTargets)
149 {
150 if (target != nullptr)
151 target->SetFromMidiCC(mGrid->GetVal(mStep, 0), time, true);
152 }
153 }
154}
155
156void ControlSequencer::OnPulse(double time, float velocity, int flags)
157{

Callers

nothing calls this directly

Calls 10

GetSyncedStepMethod · 0.80
GetStepsPerMeasureMethod · 0.80
GetMeasureMethod · 0.80
GetQuantizedMethod · 0.80
SetValMethod · 0.80
AddHistoryEventMethod · 0.80
GetValMethod · 0.80
SetHighlightColMethod · 0.45
GetMidiValueMethod · 0.45
SetFromMidiCCMethod · 0.45

Tested by

no test coverage detected