| 139 | } |
| 140 | |
| 141 | void NoteCounter::Step(double time, float velocity, int pulseFlags) |
| 142 | { |
| 143 | if (!mEnabled) |
| 144 | return; |
| 145 | |
| 146 | bool sync = mSync || pulseFlags & kPulseFlag_SyncToTransport; |
| 147 | |
| 148 | if (sync) |
| 149 | { |
| 150 | mStep = TheTransport->GetSyncedStep(time, this, mTransportListenerInfo, mLength); |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | if (pulseFlags & kPulseFlag_Reset) |
| 155 | mStep = 0; |
| 156 | if (pulseFlags & kPulseFlag_Random) |
| 157 | mStep = GetRandom(time, 999) % mLength; |
| 158 | if (pulseFlags & kPulseFlag_Align) |
| 159 | { |
| 160 | int stepsPerMeasure = TheTransport->GetStepsPerMeasure(this); |
| 161 | int numMeasures = ceil(float(mLength) / stepsPerMeasure); |
| 162 | int measure = TheTransport->GetMeasure(time) % numMeasures; |
| 163 | int step = ((TheTransport->GetQuantized(time, mTransportListenerInfo) % stepsPerMeasure) + measure * stepsPerMeasure) % mLength; |
| 164 | mStep = step; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | mNoteOutput.Flush(time); |
| 169 | if (mRandom) |
| 170 | PlayNoteOutput(time, GetRandom(time, 0) % mLength + mStart, 127, -1); |
| 171 | else |
| 172 | PlayNoteOutput(time, mStep + mStart, 127, -1); |
| 173 | |
| 174 | if (!sync) |
| 175 | { |
| 176 | int direction = 1; |
| 177 | if (pulseFlags & kPulseFlag_Backward) |
| 178 | direction = -1; |
| 179 | if (pulseFlags & kPulseFlag_Repeat) |
| 180 | direction = 0; |
| 181 | mStep = (mStep + mLength + direction) % mLength; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | std::uint64_t NoteCounter::GetRandom(double time, int seedOffset) const |
| 186 | { |
nothing calls this directly
no test coverage detected