Typedefs | Functions
cj_audio_capture.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.


typedef void(* cj_ac_audio_frames_captured_handler) (short *audioFrames, size_t audioFramesLen)
 Callback delivers audio frames as they get captured. More...


void cj_ac_init (int sampleRate, int frameSize, cj_ac_audio_frames_captured_handler audioFramesCapturedHandler)
 Initializes library. More...
void cj_ac_deinit (void)
 Deinitializes the library.
void cj_ac_start (void)
 Start capturing frames.
void cj_ac_stop (void)
 Stop capturing frames.
void cj_ac_pause (void)
 Pause capturing frames. More...
void cj_ac_resume (void)
 Resume capturing frames.
bool cj_ac_is_paused (void)
 Check if frame capturing is paused.
void cj_ac_process_main_loop (void)
 This function needs to be called regularly for the library to function. More...

Typedef Documentation

◆ cj_ac_audio_frames_captured_handler

typedef void(* cj_ac_audio_frames_captured_handler) (short *audioFrames, size_t audioFramesLen)

Callback delivers audio frames as they get captured.

audioFramesAudio frames that were captured. It will contain the number of frames specified in init function (frameSize).
audioFramesLenNumber of audio frames.

Function Documentation

◆ cj_ac_init()

void cj_ac_init ( int  sampleRate,
int  frameSize,
cj_ac_audio_frames_captured_handler  audioFramesCapturedHandler 

Initializes library.

sampleRateSample rate of the audio being captured. The recommendation is to use the native sample rate of the microphone in order to minimize CPU usage.
frameSizeSize of the audio frame. For example if we want to capture 20 ms of 48KHz audio, the corresponding frame size is 960.
audioFramesCapturedHandlerCallback to receive captured audio frames.

◆ cj_ac_pause()

void cj_ac_pause ( void  )

Pause capturing frames.

When pausing, the library is still capturing audio frames but not calling the callback. Use pause/resume instead of start/stop when instant resumption of getting frames is necessary as starting and stopping can take a little bit of time.

◆ cj_ac_process_main_loop()

void cj_ac_process_main_loop ( void  )

This function needs to be called regularly for the library to function.

Suggested interval is every 4 milliseconds.