#include "miniaudio.h"
#include "pv_circular_buffer.h"
#include "pv_recorder.h"
Go to the source code of this file.
|
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) |
|
◆ MINIAUDIO_IMPLEMENTATION
#define MINIAUDIO_IMPLEMENTATION |
◆ pv_recorder_delete()
◆ 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
-
count | The number of audio devices. |
devices | The array containing the list of audio devices. |
Definition at line 314 of file pvrecorder/src/pv_recorder.c.
◆ pv_recorder_get_audio_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] | count | The number of audio devices. |
[out] | devices | The 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 pvrecorder/src/pv_recorder.c.
◆ pv_recorder_get_selected_device()
Getter to get the current selected audio device name.
- Parameters
-
object | PV_Recorder object. |
- Returns
- A string containing the name of the device.
Definition at line 249 of file pvrecorder/src/pv_recorder.c.
◆ pv_recorder_init()
Constructor for Picovoice Audio Recorder.
- Parameters
-
| device_index | The index of the audio device to use. A value of (-1) will resort to default device. |
| frame_length | The length of audio frame to get for each read call. |
| buffer_size_msec | Time in milliseconds to store audio frames to a temporary buffer. |
| log_overflow | Boolean variable to enable overflow logs. This will enable warning logs when buffer overflow occurs. |
[out] | object | Audio 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 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 |
◆ pv_recorder_read()
Synchronous call to read frames. Copies param ${length} amount of frames to param ${pcm} array provided to input.
- Parameters
-
object | PV_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 pvrecorder/src/pv_recorder.c.
◆ pv_recorder_start()
Starts recording audio and processing audio frames.
- Parameters
-
object | PV_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 pvrecorder/src/pv_recorder.c.
◆ pv_recorder_status_to_string()
◆ pv_recorder_stop()
Stops recording audio.
- Parameters
-
object | PV_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 pvrecorder/src/pv_recorder.c.
◆ pv_recorder_version()
const PV_API char* pv_recorder_version |
( |
void |
| ) |
|
◆ READ_RETRY_COUNT
const int32_t READ_RETRY_COUNT = 500 |
|
static |
◆ READ_SLEEP_MILLI_SECONDS
const int32_t READ_SLEEP_MILLI_SECONDS = 2 |
|
static |