carb::audio::decrementWithWrap
Defined in carb/audio/AudioUtils.h
-
inline size_t carb::audio::decrementWithWrap(size_t counter, size_t modulo)
Decrement a counter with a non-power-of-2 modulo.
Remark
This function exists to perform a modulo around a non-power-of-2 modulo without having to duplicate the wrap code in multiple places. Note that % does not work for decrementing with a non-power-of-2 modulo.
- Parameters
counter – [in] The counter value to increment. This must be less than or equal to
modulo
.counter
==modulo
is allowed for some edge cases where it’s useful.modulo – [in] The value to perform a modulo by. This may not be 0.
- Returns
counter
incremented and wrapped aroundmodulo
.