Microphone I2S Driver for Machine Learning#

Microphone driver API for I2S interface on SI91x.

Typedefs#

typedef void(*
sl_mic_buffer_ready_callback_t)(const void *buffer, uint32_t n_frames)

Callback function indicating that the sample buffer is ready.

Functions#

sl_status_t
sl_ml_mic_init(uint32_t sample_rate, uint8_t channels)

Initialize the microphone.

sl_status_t

De-initialize the microphone.

sl_status_t
sl_ml_mic_start_streaming(void *buffer, uint32_t n_frames, sl_mic_buffer_ready_callback_t callback)

Read samples from the microphone into a sample buffer continuously.

sl_status_t

Stop the microphone.

Typedef Documentation#

sl_mic_buffer_ready_callback_t#

typedef void(* sl_mic_buffer_ready_callback_t) (const void *buffer, uint32_t n_frames) )(const void *buffer, uint32_t n_frames)

Callback function indicating that the sample buffer is ready.

Parameters
TypeDirectionArgument NameDescription
[in]buffer

Pointer to the sample buffer.

[in]n_frames

Number of audio frames in the sample buffer.

Returns

  • None.


Function Documentation#

sl_ml_mic_init#

sl_status_t sl_ml_mic_init (uint32_t sample_rate, uint8_t channels)

Initialize the microphone.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]sample_rate

The desired sample rate in Hz

uint8_t[in]channels

Number of audio channels (1 or 2)

Returns

  • Returns SL_STATUS_OK on success, non-zero otherwise


sl_ml_mic_deinit#

sl_status_t sl_ml_mic_deinit (void )

De-initialize the microphone.

Parameters
TypeDirectionArgument NameDescription
voidN/A

sl_ml_mic_start_streaming#

sl_status_t sl_ml_mic_start_streaming (void * buffer, uint32_t n_frames, sl_mic_buffer_ready_callback_t callback)

Read samples from the microphone into a sample buffer continuously.

Parameters
TypeDirectionArgument NameDescription
void *[in]buffer

Pointer to the sample buffer to store the data. 16-bit channel data is stored consecutively, starting with ch0. This buffer shall be big enough to hold twice the n_frames because of the ping-pong operation.

uint32_t[in]n_frames

The number of audio frames to receive before the callback is called. Maximum value limited by DMADRV_MAX_XFER_COUNT.

sl_mic_buffer_ready_callback_t[in]callback

Callback is called when n_frames in the sample buffer is ready.

This function starts the microphone sampling and stops only upon calling sl_ml_mic_stop or sl_ml_mic_deinit. The buffer is used in a "ping-pong" manner meaning that one half of the buffer is used for sampling while the other half is being processed.


sl_ml_mic_stop#

sl_status_t sl_ml_mic_stop (void )

Stop the microphone.

Parameters
TypeDirectionArgument NameDescription
voidN/A