| 103 | } |
| 104 | |
| 105 | void 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 | |
| 156 | void ControlSequencer::OnPulse(double time, float velocity, int flags) |
| 157 | { |
nothing calls this directly
no test coverage detected