166 {
167 const float dtMs = dtSec * 1000.0f;
168 const float slot = 1.0f /
static_cast<float>(
kMarkers);
169 const float beatsPerSec = (s.bpm > 20.0f) ? s.bpm / 60.0f : 0.0f;
170
171
172
173
174
176 if (s.events.beat) {
177 const float inSlot =
179 slot *
static_cast<float>(
static_cast<int>(
mRotation / slot));
180
181
182 const float err = (inSlot < slot * 0.5f) ? -inSlot : (slot - inSlot);
184 }
188 if (step > maxStep)
190 if (step < -maxStep)
196 }
197
198
199
200
201 float swellTarget;
202 if (s.beatPhase >= kSwellStart) {
203 swellTarget =
smoothstepf(kSwellStart, 1.0f, s.beatPhase);
204 } else {
205 swellTarget = 1.0f -
smoothstepf(0.0f, 0.25f, s.beatPhase);
206 }
207 const float swell =
208 mSwell.update(swellTarget, dtMs, kSwellAttackMs, kSwellReleaseMs);
209
210
211 const float flash =
mFlash.update(s.events.downbeat ? 1.0f : 0.0f, dtMs,
212 kFlashAttackMs, kFlashReleaseMs);
213 const float snare =
mSnare.update(s.events.snare ? 1.0f : 0.0f, dtMs,
214 kSnareAttackMs, kSnareReleaseMs);
215
216 const float markerGain = 0.45f + 0.55f * swell + 0.5f * s.punch;
217
218
219 const float bar = 0.5f + 0.5f *
fl::sin(kTwoPi * s.measurePhase);
221
222
223 for (
int k = 0; k <
kMarkers; ++k) {
225 const float t = (k & 1) ? 1.0f : 0.4f;
227 markerGain);
228 }
229
230
231 if (snare > 0.001f) {
232 for (
int k = 0; k <
kMarkers; ++k) {
235 c.lobe(
pos, kMarkerSigma * 0.6f,
rgbfWhite(), 0.6f * snare);
236 }
237 }
238
239
240 if (flash > 0.001f) {
242 }
243}
float mCorrection
remaining phase correction, turns
float mRotation
turns, advanced continuously
static const int kMarkers
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type step(T edge, T x) FL_NO_EXCEPT
constexpr float kCorrectionBeats
float advance(float pos, float turnsPerSec, float dtSec)
float smoothstepf(float e0, float e1, float x)
0 below e0, 1 above e1, smooth in between.
RGBf paletteColor(const MoodPalette &p, float t)
Colour at position t in [0, 1] along the family, at value v.
float wrapTurns(float t)
Wrap into [0, 1).