carb::audio::alignBytesToFrameFloor

Defined in carb/audio/AudioUtils.h

constexpr size_t carb::audio::alignBytesToFrameFloor(size_t bytes, size_t channels, size_t bps)

aligns a byte count to a frame boundary for an audio data format.

Parameters
  • bytes[in] the byte count to align to a frame boundary. This will be aligned to the previous frame boundary if it is not already aligned.

  • channels[in] the number of channels in the audio data format.

  • bps[in] the number of bits per sample of audio data. This must be 8, 16, 24, or

    1. This does not properly handle byte offset calculations for compressed audio formats.

Returns

the requested byte count aligned to the previous frame boundary if it is not already aligned.

Returns

the requested byte count unmodified if it is already aligned to a frame boundary.