sac_utils.h

Utility functions for the SPARK Audio Core.

Copyright

Copyright (C) 2023 SPARK Microsystems International Inc. All rights reserved.

License

This source code is proprietary and subject to the SPARK Microsystems Software EULA found in this package in file EULA.txt.

Author

SPARK FW Team.

Defines

SAC_CHECK_STATUS(cond, status_ptr, status_code, ret)

do {                                                     \

if (cond) {                                          \

*(status_ptr) = (status_code);                   \

ret;                                             \

}                                                    \

} while (0)


Functions

uint8_t sac_get_sample_size_from_format(sac_sample_format_t sample_format)

Get the number of bits used to store a sample of a given format.

Parameters:

sample_format – [in] Sample format.

Returns:

The number of bits required to store a single sample.

uint16_t sac_get_nb_packets_in_x_ms(uint16_t ms, uint16_t audio_payload_size, uint8_t nb_channel, sac_sample_format_t sample_format, uint32_t sampling_rate)

Get the number of audio packets in a given amount of milliseconds.

Parameters:
  • ms – [in] The number of milliseconds.

  • audio_payload_size – [in] The size of the audio payload in bytes.

  • nb_channel – [in] The number of audio channels.

  • sample_format – [in] The format of the samples in the audio payload.

  • sampling_rate – [in] The sampling rate of the samples in the audio payload in Hz.

Returns:

Number of audio packets, rounded down.

uint16_t sac_get_ms_in_x_packets(uint16_t nb_packet, uint16_t audio_payload_size, uint8_t nb_channel, sac_sample_format_t sample_format, uint32_t sampling_rate)

Get the number of milliseconds in a given number of audio packets.

Parameters:
  • nb_packet – [in] The number of packets.

  • audio_payload_size – [in] The size of the audio payload in bytes.

  • nb_channel – [in] The number of audio channels.

  • sample_format – [in] The format of the samples in the audio payload.

  • sampling_rate – [in] The sampling rate of the samples in the audio payload in Hz.

Returns:

Number of milliseconds, rounded down.