PebbleOS
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
mic.h File Reference
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

Macros

#define MIC_SAMPLE_RATE   (16000)
 Sample rate of the captured audio, in Hz.
 
#define MIC_DEFAULT_VOLUME   (-1)
 Volume value meaning the driver default; not used by the drivers.
 

Typedefs

typedef const struct MicDevice MicDevice
 Microphone device, defined by the driver implementation.
 
typedef void(* MicDataHandlerCB) (int16_t *samples, size_t sample_count, void *context)
 Handler for a full buffer of captured audio.
 
typedef void(* MicDataReadyCB) (void *context)
 Notification that a frame is ready for mic_poll().
 

Functions

void mic_init (MicDevice *this)
 Initialize the microphone driver.
 
void mic_set_volume (MicDevice *this, uint16_t volume)
 Set the capture gain.
 
bool mic_start (MicDevice *this, MicDataHandlerCB data_handler, void *context, int16_t *audio_buffer, size_t audio_buffer_len)
 Start capturing.
 
bool mic_start_polling (MicDevice *this, MicDataHandlerCB data_handler, void *context, int16_t *audio_buffer, size_t audio_buffer_len, MicDataReadyCB ready)
 Start capturing with realtime dispatch.
 
void mic_poll (MicDevice *this)
 Deliver the pending frames to the data handler.
 
bool mic_get_frame_time (MicDevice *this, uint32_t *sample_time)
 Get the capture time of the frame being delivered.
 
void mic_stop (MicDevice *this)
 Stop capturing.
 
bool mic_is_running (MicDevice *this)
 Check whether the microphone is running.
 
uint32_t mic_get_channels (MicDevice *this)
 Get the number of audio channels.