Classes | Macros | Functions | Variables
rhino/demo/c/pvrecorder/src/pv_recorder.c File Reference
#include "miniaudio.h"
#include "pv_circular_buffer.h"
#include "pv_recorder.h"
Include dependency graph for rhino/demo/c/pvrecorder/src/pv_recorder.c:

Go to the source code of this file.

Classes

struct  pv_recorder
 

Macros

#define MINIAUDIO_IMPLEMENTATION
 

Functions

PV_API void pv_recorder_delete (pv_recorder_t *object)
 
PV_API void pv_recorder_free_device_list (int32_t count, char **devices)
 
PV_API pv_recorder_status_t pv_recorder_get_audio_devices (int32_t *count, char ***devices)
 
const PV_API char * pv_recorder_get_selected_device (pv_recorder_t *object)
 
PV_API pv_recorder_status_t pv_recorder_init (int32_t device_index, int32_t frame_length, int32_t buffer_size_msec, bool log_overflow, pv_recorder_t **object)
 
static void pv_recorder_ma_callback (ma_device *device, void *output, const void *input, ma_uint32 frame_count)
 
PV_API pv_recorder_status_t pv_recorder_read (pv_recorder_t *object, int16_t *pcm)
 
PV_API pv_recorder_status_t pv_recorder_start (pv_recorder_t *object)
 
const PV_API char * pv_recorder_status_to_string (pv_recorder_status_t status)
 
PV_API pv_recorder_status_t pv_recorder_stop (pv_recorder_t *object)
 
const PV_API char * pv_recorder_version (void)
 

Variables

static const int32_t READ_RETRY_COUNT = 500
 
static const int32_t READ_SLEEP_MILLI_SECONDS = 2
 

Macro Definition Documentation

◆ MINIAUDIO_IMPLEMENTATION

#define MINIAUDIO_IMPLEMENTATION

Definition at line 16 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

Function Documentation

◆ pv_recorder_delete()

PV_API void pv_recorder_delete ( pv_recorder_t object)

Destructor.

Parameters
objectPV_Recorder object.

Definition at line 162 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_free_device_list()

PV_API void pv_recorder_free_device_list ( int32_t  count,
char **  devices 
)

Frees the device list initialized by pv_recorder_get_audio_devices. The function does not do any checks, providing correct count and pointer is up to the caller.

Parameters
countThe number of audio devices.
devicesThe array containing the list of audio devices.

Definition at line 314 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_get_audio_devices()

PV_API pv_recorder_status_t pv_recorder_get_audio_devices ( int32_t *  count,
char ***  devices 
)

Gets the input audio devices currently available. Each device name has a separate pointer, so the caller must free each item in the output array individually and free the output array itself. The utility function pv_recorder_free_device_list is provided to free the device list.

Parameters
[out]countThe number of audio devices.
[out]devicesThe output array containing the list of audio devices.
Returns
Status Code. Returns PV_RECORDER_STATUS_OUT_OF_MEMORY, PV_RECORDER_STATUS_BACKEND_ERROR or PV_RECORDER_STATUS_INVALID_ARGUMENT on failure.

Definition at line 256 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_get_selected_device()

const PV_API char* pv_recorder_get_selected_device ( pv_recorder_t object)

Getter to get the current selected audio device name.

Parameters
objectPV_Recorder object.
Returns
A string containing the name of the device.

Definition at line 249 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_init()

PV_API pv_recorder_status_t pv_recorder_init ( int32_t  device_index,
int32_t  frame_length,
int32_t  buffer_size_msec,
bool  log_overflow,
pv_recorder_t **  object 
)

Constructor for Picovoice Audio Recorder.

Parameters
device_indexThe index of the audio device to use. A value of (-1) will resort to default device.
frame_lengthThe length of audio frame to get for each read call.
buffer_size_msecTime in milliseconds to store audio frames to a temporary buffer.
log_overflowBoolean variable to enable overflow logs. This will enable warning logs when buffer overflow occurs.
[out]objectAudio Recorder object to initialize.
Returns
Status Code. PV_RECORDER_STATUS_INVALID_ARGUMENT, PV_RECORDER_STATUS_BACKEND_ERROR, PV_RECORDER_STATUS_DEVICE_INITIALIZED or PV_RECORDER_STATUS_OUT_OF_MEMORY on failure.

Definition at line 51 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_ma_callback()

static void pv_recorder_ma_callback ( ma_device device,
void *  output,
const void *  input,
ma_uint32  frame_count 
)
static

Definition at line 38 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_read()

PV_API pv_recorder_status_t pv_recorder_read ( pv_recorder_t object,
int16_t *  pcm 
)

Synchronous call to read frames. Copies param ${length} amount of frames to param ${pcm} array provided to input.

Parameters
objectPV_Recorder object.
pcm[out]An array for the frames to be copied to.
Returns
Status Code. Returns PV_RECORDER_STATUS_INVALID_ARGUMENT, PV_RECORDER_INVALID_STATE or PV_RECORDER_IO_ERROR on failure. Returns PV_RECORDER_STATUS_BUFFER_OVERFLOW if audio frames aren't being read fast enough. This means old audio frames are being replaced by new audio frames.

Definition at line 213 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_start()

PV_API pv_recorder_status_t pv_recorder_start ( pv_recorder_t object)

Starts recording audio and processing audio frames.

Parameters
objectPV_Recorder object. @returnStatus Status Code. Returns PV_RECORDER_STATUS_INVALID_ARGUMENT, PV_RECORDER_STATUS_DEVICE_NOT_INITIALIZED or PV_RECORDER_STATUS_INVALID_STATE on failure.

Definition at line 172 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_status_to_string()

const PV_API char* pv_recorder_status_to_string ( pv_recorder_status_t  status)

Provides string representations of status codes.

Parameters
statusStatus code.
Returns
String representation.

Definition at line 323 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_stop()

PV_API pv_recorder_status_t pv_recorder_stop ( pv_recorder_t object)

Stops recording audio.

Parameters
objectPV_Recorder object.
Returns
Status Code. Returns PV_RECORDER_STATUS_INVALID_ARGUMENT, PV_RECORDER_STATUS_DEVICE_NOT_INITIALIZED or PV_RECORDER_STATUS_INVALID_STATE on failure.

Definition at line 192 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ pv_recorder_version()

const PV_API char* pv_recorder_version ( void  )

Getter for version.

Returns
Version.

Definition at line 343 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

Variable Documentation

◆ READ_RETRY_COUNT

const int32_t READ_RETRY_COUNT = 500
static

Definition at line 25 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.

◆ READ_SLEEP_MILLI_SECONDS

const int32_t READ_SLEEP_MILLI_SECONDS = 2
static

Definition at line 26 of file rhino/demo/c/pvrecorder/src/pv_recorder.c.



picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:15:00