carb::audio::bytesToMilliseconds

Defined in carb/audio/AudioUtils.h

constexpr size_t carb::audio::bytesToMilliseconds(size_t bytes, size_t frameRate, size_t channels, size_t bps)

converts a byte count to an approximate time in milliseconds.

Parameters
  • bytes[in] the number of bytes to be converted to a time in milliseconds. Note that this byte count is expected to be frame aligned.

  • frameRate[in] the frame rate of the audio that needs a time calculated.

  • 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 approximate number of milliseconds of audio data that the requested byte count represents for the given format.