audio.h File Reference

#include <stdint.h>

Include dependency graph for audio.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ts_audio_pub
struct  ts_audio_api

Defines

#define AUDIO_DEVICE_NAME_LENGTH   20
#define AUDIO_DEVICE_TEMINATOR   {0, NULL, NULL, NULL, NULL, NULL}

Typedefs

typedef struct ts_audio_devicep_audio_device
typedef struct ts_audio_apip_audio_api
typedef void(* message_handler )(char *message)
typedef void(* audio_error_message_handler )(char *error_message)
typedef struct ts_audio_pubp_audio_pub

Enumerations

enum  te_audio_segments { BUFFER_SEGMENT_1 = 0, BUFFER_SEGMENT_2, AUDIO_BUFFER_SEGMENTS }
enum  te_audio_channels { AUDIO_MONO = 0, AUDIO_STEREO }
enum  te_audio_rec_play { AUDIO_DEVICE_RECORD = 0, AUDIO_DEVICE_PLAY }

Functions

p_audio_device audio_create (uint32_t device_type, te_audio_rec_play rec_play)
int32_t audio_open (p_audio_device device, int32_t sample_frequency)
int32_t audio_close (p_audio_device device)
int32_t audio_init (p_audio_device device)
int32_t audio_destroy (p_audio_device *device)
void audio_capture (p_audio_device device, te_audio_segments buffer_segment)
void audio_capture_wait (p_audio_device device, te_audio_segments buffer_segment)
void audio_play (p_audio_device device, te_audio_segments buffer_segment)
void audio_raw2double (p_audio_device device, te_audio_segments buffer_segment, double *audio_data)
void audio_double2raw (p_audio_device device, te_audio_segments buffer_segment, double *audio_data)
void register_error_message_handler (message_handler handler)
uint32_t audio_device_samples_get (p_audio_device device)
int32_t audio_supported_device_types_get (void)
char * audio_device_type_name_get (int32_t audio_device_type_id)
void audio_device_name_set (p_audio_device device, const char *name)
void audio_device_name_get (p_audio_device device, char **name)
void audio_sample_rate_set (p_audio_device device, int32_t Hertz)
int32_t audio_sample_rate_get (p_audio_device device)


Define Documentation

#define AUDIO_DEVICE_NAME_LENGTH   20

Definition at line 26 of file audio.h.

Referenced by audio_device_name_set(), load_config_file(), and on_morse2txt_properties_apply().

#define AUDIO_DEVICE_TEMINATOR   {0, NULL, NULL, NULL, NULL, NULL}

Used to terminate search for supported audio device types.

Definition at line 106 of file audio.h.


Typedef Documentation

typedef void(* audio_error_message_handler)(char *error_message)

Definition at line 58 of file audio.h.

typedef void(* message_handler)(char *message)

Definition at line 57 of file audio.h.

typedef struct ts_audio_api* p_audio_api

Pointer to audio api's

See also:
ts_audio_api

Definition at line 31 of file audio.h.

Pointer to audio device object.

See also:
audio_create

Definition at line 29 of file audio.h.

typedef struct ts_audio_pub * p_audio_pub


Enumeration Type Documentation

Audio segments used in audio record/playback

Enumerator:
AUDIO_MONO  One Channel.
AUDIO_STEREO  Two Channels.

Definition at line 50 of file audio.h.

Audio direction, record or play

Enumerator:
AUDIO_DEVICE_RECORD 
AUDIO_DEVICE_PLAY 

Definition at line 61 of file audio.h.

Audio segments used in audio record/playback

Enumerator:
BUFFER_SEGMENT_1  Index for audio buffer segment 1.
BUFFER_SEGMENT_2  Index for audio buffer segment 2.
AUDIO_BUFFER_SEGMENTS  Number of audio buffer segments. The audio buffer is broken up into 2 segments. That is, th audio buffer looks like this:
[<---- Segment 1 ---->|<---- Segment 2 ---->]

When audio data is being written to Segment 1, Segment 2 is
being post processed. And visa versa.

Definition at line 34 of file audio.h.


Function Documentation

void audio_capture ( p_audio_device  device,
te_audio_segments  buffer_segment 
)

Capture raw audio data from audio device.

Parameters:
device The audio device object.
See also:
p_audio_device
Parameters:
buffer_segment The buffer segment to put data into.

Definition at line 150 of file audio.c.

References ts_audio_device::audio_api, ts_audio_device::audio_pub, ts_audio_api::record, and ts_audio_device::segment_cond_t.

Referenced by data_collection().

void audio_capture_wait ( p_audio_device  device,
te_audio_segments  buffer_segment 
)

Blocking function that releases when buffer segment has been captured.

Parameters:
device The audio device object.
See also:
p_audio_device
Parameters:
buffer_segment The buffer segment capture to wait on.

Definition at line 158 of file audio.c.

References ts_audio_device::segment_cond_t, and ts_audio_device::segment_mutex_t.

Referenced by audio_post_process().

int32_t audio_close ( p_audio_device  device  ) 

Close audio device.

Note:
Audio device MUST be created first.
See also:
audio_create
Parameters:
device Pointer to audio device object.
See also:
p_audio_device
Returns:
-1 if error, 0 if no error.

Definition at line 117 of file audio.c.

References ts_audio_device::audio_api, ts_audio_device::audio_pub, and ts_audio_api::close.

Referenced by free_all().

p_audio_device audio_create ( uint32_t  device_type,
te_audio_rec_play  rec_play 
)

Creates an audio object.

Parameters:
device_type OSS, ALSA, ...
rec_play REcord or Playback device.
See also:
te_audio_rec_play
Returns:
Pointer to audio object.
See also:
p_audio_device

Definition at line 66 of file audio.c.

References ts_audio_device::audio_api, ts_audio_pub::audio_buffer_raw, AUDIO_BUFFER_SEGMENTS, AUDIO_NUMBER_OF_DEVICE_TYPES, ts_audio_device::audio_pub, error_message(), ts_audio_pub::error_msg_handler, ts_audio_pub::play_record, ts_audio_device::segment_cond_t, and ts_audio_device::segment_mutex_t.

Referenced by audio_loopback_start(), and morse_initialize().

Here is the call graph for this function:

int32_t audio_destroy ( p_audio_device device  ) 

Close and release audio device.

Note:
Audio device MUST be created for this to apply.
See also:
audio_create
Parameters:
device Pointer to audio device object.
See also:
p_audio_device
Returns:
-1 if error, 0 if no error.

Definition at line 137 of file audio.c.

Referenced by audio_loopback_stop(), and morse_shutdown().

void audio_device_name_get ( p_audio_device  device,
char **  name 
)

Get the audio device name, i.e. /dev/dsp.

Parameters:
device Pointer to the audio device
name Destination for audio device name.

Definition at line 264 of file audio.c.

References ts_audio_device::audio_pub, and ts_audio_pub::name.

Referenced by on_morse2txt_properties_show(), and save_config_file().

void audio_device_name_set ( p_audio_device  device,
const char *  name 
)

Set the audio device name, i.e. /dev/dsp.

Parameters:
device Pointer to the audio device
name Audio device name to set.
See also:
audio_create

Definition at line 257 of file audio.c.

References AUDIO_DEVICE_NAME_LENGTH, ts_audio_device::audio_pub, and ts_audio_pub::name.

Referenced by load_config_file(), and on_morse2txt_properties_apply().

uint32_t audio_device_samples_get ( p_audio_device  device  ) 

Returns the samples that will be captured by the audio device.

See also:
p_audio_device
Parameters:
device Pointer to the audio device
See also:
audio_create
Returns:
The number of samples to be acquired by the audio device.

Definition at line 220 of file audio.c.

References ts_audio_device::audio_pub, and ts_audio_pub::samples.

Referenced by audio_loopback_start(), audio_post_process(), morse_code(), morse_create_fft_amp_array(), and morse_start_threads().

char* audio_device_type_name_get ( int32_t  audio_device_type_id  ) 

Get the name of audio device type.

Parameters:
audio_device_type_id Device type Id.
Returns:
Pointer to the name of the audio device API (OSS, Alsa, ...)

Definition at line 249 of file audio.c.

References ts_audio_api::audio_device_type_name.

Referenced by on_morse2txt_properties_show().

void audio_double2raw ( p_audio_device  device,
te_audio_segments  buffer_segment,
double *  audio_data 
)

Converts double audio data to raw for soundcard.

Parameters:
device The audio device object.
buffer_segment the buffer segment to convert to fill with raw.
audio_data Pointer to double formatted audio data.
Note:
This assumes that the real audio data is not clipped.
See also:
p_audio_device

Definition at line 197 of file audio.c.

References ts_audio_pub::audio_buffer_raw, ts_audio_pub::audio_buffer_size, ts_audio_device::audio_pub, and ts_audio_pub::dsp_channels.

Referenced by audio_loopback_convert_thr().

int32_t audio_init ( p_audio_device  device  ) 

Initialize audio device.

Note:
Audio device MUST be opened first.
See also:
audio_open
Parameters:
device Pointer to audio device object.
See also:
p_audio_device
Returns:
-1 if error, 0 if no error.

Definition at line 127 of file audio.c.

References ts_audio_device::audio_api, ts_audio_device::audio_pub, and ts_audio_api::init.

Referenced by audio_loopback_start().

int32_t audio_open ( p_audio_device  device,
int32_t  sample_frequency 
)

Open audio device.

Note:
Audio device MUST be created first.
See also:
audio_create
Parameters:
device Pointer to audio device object.
See also:
p_audio_device
Parameters:
sample_frequency Sample frequency in Hertz.
Returns:
-1 if error, 0 if no error.

Definition at line 101 of file audio.c.

References ts_audio_device::audio_api, ts_audio_device::audio_pub, ts_audio_api::init, ts_audio_api::open, and ts_audio_pub::sample_frequency.

Referenced by audio_loopback_start(), and morse_start_threads().

void audio_play ( p_audio_device  device,
te_audio_segments  buffer_segment 
)

Send raw audio data to audio device.

Parameters:
device The audio device object.
See also:
p_audio_device
Parameters:
buffer_segment The buffer segment to play.

Definition at line 165 of file audio.c.

References ts_audio_device::audio_api, ts_audio_device::audio_pub, and ts_audio_api::play.

Referenced by audio_loopback_thr().

void audio_raw2double ( p_audio_device  device,
te_audio_segments  buffer_segment,
double *  audio_data 
)

Converts the raw audio data to real.

Note:
Real data is required GSL's FFT library.
Parameters:
device The audio device object.
See also:
p_audio_device
Parameters:
buffer_segment the buffer segment to convert to real.
audio_data Pointer to scaled audio data.

Definition at line 172 of file audio.c.

References ts_audio_pub::audio_buffer_raw, ts_audio_pub::audio_buffer_size, ts_audio_device::audio_pub, ts_audio_pub::dsp_channels, and ts_audio_device::segment_mutex_t.

Referenced by audio_post_process().

int32_t audio_sample_rate_get ( p_audio_device  device  ) 

Get the audio sample rate.

Returns:
Sample rate in Hertz.

Note:
This assumes record and playback are at the same rate. The audio API could support multiple cards at different rates, but that capability will not be used for now.

Definition at line 281 of file audio.c.

References ts_audio_device::audio_pub, and ts_audio_pub::sample_frequency.

Referenced by morse_start_threads().

void audio_sample_rate_set ( p_audio_device  device,
int32_t  Hertz 
)

Set the audio device sample rate.

Parameters:
device Pointer to the audio device
Hertz Frequency in Hertz.

Definition at line 274 of file audio.c.

References ts_audio_device::audio_pub, and ts_audio_pub::sample_frequency.

int32_t audio_supported_device_types_get ( void   ) 

Get the number of audio device types supported (OSS, Alsa, etc.).

Returns:
The number of audio device API's supported.

Definition at line 244 of file audio.c.

References AUDIO_NUMBER_OF_DEVICE_TYPES.

void register_error_message_handler ( message_handler  handler  ) 

Used to register an external error message handler function.

Definition at line 299 of file audio.c.

References msg_handler.

Referenced by init_gui_interface_hooks().


Generated on Mon Jun 22 21:38:39 2009 for morse2txt by  doxygen 1.5.6