Defined in carb/audio/AudioUtils.h

inline size_t carb::audio::incrementWithWrap(size_t counter, size_t modulo)

Increment a counter with a non-power-of-2 modulo.


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 this is considerably more efficient than use of the % operator where a power-of-2 optimization cannot be made.

  • counter[in] The counter value to increment. This must be less than modulo.

  • modulo[in] The value to perform a modulo by. This may not be 0.


counter incremented and wrapped around modulo.