include/ad.h File Reference

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

#include <sphinx_config.h>
#include <sphinxbase_export.h>
#include <prim_type.h>

Go to the source code of this file.

Data Structures

struct  ad_rec_t
struct  ad_play_t

Defines

#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_tad_open_dev (const char *dev, int32 samples_per_sec)
 Open a specific audio device for recording.
SPHINXBASE_EXPORT ad_rec_tad_open_sps (int32 samples_per_sec)
 Open the default audio device with a given sampling rate.
SPHINXBASE_EXPORT ad_rec_tad_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_tad_open_play_sps (int32 samples_per_sec)
SPHINXBASE_EXPORT ad_play_tad_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.
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

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.

References ad_open_dev(), ad_rec_t::bps, and ad_rec_t::sps.

Referenced by ad_open_dev(), and 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(), and ad_open_sps().

Referenced by ad_open(), and ad_open_sps().

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 364 of file play_win32.c.

References ad_write().

Referenced by ad_write().


Generated on 24 Aug 2009 for SphinxBase by  doxygen 1.6.0