Continuous array

The continuous array library introduces an array that you can loop over, for example if you want to create a period of a Pulse-code modulated (PCM) sine wave. You can use it to test playback with applications that support audio development kits, for example the nRF5340 Audio.

The library introduces the contin_array_create() function, which takes an array that the user wants to loop over. For more information, see API documentation.

Configuration

To enable the library, set the CONFIG_CONTIN_ARRAY Kconfig option to y in the project configuration file prj.conf.

API documentation

Header file: include/contin_array.h
Source file: lib/contin_array/contin_array.c
group contin_array

Basic continuous array.

Functions

int contin_array_create(void *pcm_cont, uint32_t pcm_cont_size, void const *const pcm_finite, uint32_t pcm_finite_size, uint32_t *const finite_pos)

Creates a continuous array from a finite array.

Note

This function serves the purpose of e.g. having a set of audio samples stored in pcm_finite. This can then be fetched in smaller pieces into ram and played back in a loop using the results in pcm_cont. The function keeps track of the current position in finite_pos, so that the function can be called multiple times and maintain the correct position in pcm_finite.

Parameters:
  • pcm_cont – Pointer to the destination array.

  • pcm_cont_size – Size of pcm_cont.

  • pcm_finite – Pointer to an array of samples or data.

  • pcm_finite_size – Size of pcm_finite.

  • finite_pos – Variable used internally. Must be set to 0 for the first run and not changed.

Return values:
  • 0 – If the operation was successful.

  • -EPERM – If any sizes are zero.

  • -ENXIO – On NULL pointer.