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.

## Macros

#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

## Typedefs

typedef struct ad_rec_s | ad_rec_t

## Functions

SPHINXBASE_EXPORT ad_rec_t * | ad_open_dev (const char *dev, int32 samples_per_sec)
| Open a specific audio device for recording.
SPHINXBASE_EXPORT ad_rec_t * | ad_open_sps (int32 samples_per_sec)
| Open the default audio device with a given sampling rate.
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)

## Detailed Description

generic live audio interface for recording and playback

Definition in file ad.h.

## Macro Definition Documentation

## AD_EOF

#define AD_EOF -1

Definition at line 61 of file ad.h.

## AD_ERR_GEN

#define AD_ERR_GEN -1

Definition at line 62 of file ad.h.

## AD_ERR_NOT_OPEN

#define AD_ERR_NOT_OPEN -2

Definition at line 63 of file ad.h.

## AD_ERR_WAVE

#define AD_ERR_WAVE -3

Definition at line 64 of file ad.h.

## AD_OK

#define AD_OK 0

Definition at line 60 of file ad.h.

## DEFAULT_SAMPLES_PER_SEC

#define DEFAULT_SAMPLES_PER_SEC 16000

Definition at line 57 of file ad.h.

## Typedef Documentation

## ad_rec_t

typedef struct ad_rec_s ad_rec_t

Definition at line 66 of file ad.h.

## Function Documentation

## ad_close()

SPHINXBASE_EXPORT int32 ad_close | ( | ad_rec_t * | handle | ) |

Definition at line 235 of file ad_alsa.c.

## ad_open()

SPHINXBASE_EXPORT ad_rec_t * ad_open | ( | void |  | ) |

Open the default audio device.

Definition at line 228 of file ad_alsa.c.

References ad_open_sps().

## 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 187 of file ad_alsa.c.

References ad_open_dev().

Referenced by ad_open_dev(), and 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 222 of file ad_alsa.c.

References ad_open_dev(), and ad_open_sps().

Referenced by ad_open(), and ad_open_sps().

## ad_read()

SPHINXBASE_EXPORT int32 ad_read | ( | ad_rec_t * | handle,
|  | int16 * | buf,
|  | int32 | max )

Definition at line 301 of file ad_alsa.c.

## ad_start_rec()

SPHINXBASE_EXPORT int32 ad_start_rec | ( | ad_rec_t * | handle | ) |

Definition at line 252 of file ad_alsa.c.

## ad_stop_rec()

SPHINXBASE_EXPORT int32 ad_stop_rec | ( | ad_rec_t * | handle | ) |

Definition at line 279 of file ad_alsa.c.