ad.h File Reference

generic live audio interface for recording and playback More...

`#include <sphinx_config.h>`
`#include <sphinxbase/sphinxbase_export.h>`
`#include <sphinxbase/prim_type.h>`

Go to the source code of this file.

## Data Structures

struct | ad_rec_t
struct | ad_play_t

## Macros

#define | AD_SAMPLE_SIZE (sizeof(int16))
#define | DEFAULT_SAMPLES_PER_SEC 16000
#define | AD_OK 0
#define | AD_EOF -1
#define | AD_ERR_GEN -1
#define | AD_ERR_NOT_OPEN -2
#define | AD_ERR_WAVE -3
#define | DEFAULT_DEVICE NULL

## Functions

SPHINXBASE_EXPORT ad_rec_t * | ad_open_dev (const char *dev, int32 samples_per_sec)
| Open a specific audio device for recording. More...
SPHINXBASE_EXPORT ad_rec_t * | ad_open_sps (int32 samples_per_sec)
| Open the default audio device with a given sampling rate. More...
SPHINXBASE_EXPORT ad_rec_t * | ad_open (void)
| Open the default audio device.
SPHINXBASE_EXPORT int32 | ad_start_rec (ad_rec_t *)
SPHINXBASE_EXPORT int32 | ad_stop_rec (ad_rec_t *)
SPHINXBASE_EXPORT int32 | ad_close (ad_rec_t *)
SPHINXBASE_EXPORT int32 | ad_read (ad_rec_t *, int16 *buf, int32 max)
SPHINXBASE_EXPORT ad_play_t * | ad_open_play_sps (int32 samples_per_sec)
SPHINXBASE_EXPORT ad_play_t * | ad_open_play (void)
SPHINXBASE_EXPORT int32 | ad_start_play (ad_play_t *)
SPHINXBASE_EXPORT int32 | ad_stop_play (ad_play_t *)
SPHINXBASE_EXPORT int32 | ad_close_play (ad_play_t *)
SPHINXBASE_EXPORT int32 | ad_write (ad_play_t *, int16 *buf, int32 len)
| Queue a block of audio samples for playback. More...
SPHINXBASE_EXPORT void | ad_mu2li (int16 *outbuf, unsigned char *inbuf, int32 n_samp)
| Convert mu-law data to int16 linear PCM format.

## Detailed Description

generic live audio interface for recording and playback

Definition in file ad.h.

## Function Documentation

## ad_open_dev()

SPHINXBASE_EXPORT ad_rec_t* ad_open_dev | ( | const char * | dev,
|  | int32 | samples_per_sec
| ) |  |

Open a specific audio device for recording.

The device is opened in non-blocking mode and placed in idle state.

Returns
  pointer to read-only ad_rec_t structure if successful, NULL otherwise. The return value to be used as the first argument to other recording functions.

Parameters

  dev | Device name (platform-specific)
  samples_per_sec | Samples per second

Definition at line 252 of file ad_alsa.c.

Referenced by ad_open_sps().

## ad_open_sps()

SPHINXBASE_EXPORT ad_rec_t* ad_open_sps | ( | int32 | samples_per_sec | ) |

Open the default audio device with a given sampling rate.

Parameters

  samples_per_sec | Samples per second

Definition at line 290 of file ad_alsa.c.

References ad_open_dev().

Referenced by ad_open().

## ad_write()

SPHINXBASE_EXPORT int32 ad_write | ( | ad_play_t * | ,
|  | int16 * | buf,
|  | int32 | len
| ) |  |

Queue a block of audio samples for playback.

Write the next block of [len] samples from rawbuf to the A/D device for playback. The device may queue less than len samples, possibly 0, since it is non-blocking. The application should resubmit the remaining data to be played. Return value: # samples accepted for playback; -1 if error.

Definition at line 373 of file play_win32.c.