![]() |
![]() |
Data Structures | |
struct | Sound_Attrs |
Attributes used to create a Sound device driver instance. More... | |
Defines | |
#define | Sound_MAXDEVNAME 20 |
Max number of characters in the sound device name. | |
Typedefs | |
typedef struct Sound_Object * | Sound_Handle |
Handle through which to reference a Sound device driver. | |
Enumerations | |
enum | Sound_Std { Sound_Std_OSS = 0, Sound_Std_ALSA, Sound_Std_COUNT } |
Sound standards supported on Linux (OSS and ALSA). More... | |
enum | Sound_Mode { Sound_Mode_OUTPUT, Sound_Mode_INPUT, Sound_Mode_FULLDUPLEX, Sound_Mode_COUNT } |
Sound device driver opened for reading, writing or both. More... | |
enum | Sound_Input { Sound_Input_MIC, Sound_Input_LINE, Sound_Input_COUNT } |
Sound inputs. More... | |
Functions | |
Sound_Handle | Sound_create (Sound_Attrs *attrs) |
Creates a Sound device driver instance. | |
Int | Sound_write (Sound_Handle hSound, Buffer_Handle hBuf) |
Write a buffer to the sound output. This function can only be called if the driver was opened for writing. | |
Int | Sound_read (Sound_Handle hSound, Buffer_Handle hBuf) |
Fill a buffer from the sound input. This function can only be called if the driver was opened for reading. | |
Int | Sound_delete (Sound_Handle hSound) |
Deletes a Sound device driver instance. | |
Variables | |
const Sound_Attrs | Sound_Attrs_STEREO_DEFAULT |
Default attributes for a stereo Sound device driver. | |
const Sound_Attrs | Sound_Attrs_MONO_DEFAULT |
Default attributes for a mono Sound device driver. |
#include <xdc/std.h> #include <ti/sdo/dmai/Dmai.h> #include <ti/sdo/dmai/Sound.h> #include <ti/sdo/dmai/Buffer.h> Buffer_Attrs bAttrs = Buffer_Attrs_DEFAULT; Sound_Attrs sAttrs = Sound_Attrs_MONO_DEFAULT; Buffer_Handle hBuf; Sound_Handle hSound; Dmai_init(); hBuf = Buffer_create(1024, &bAttrs); hSound = Sound_create(&sAttrs); while (1) { Sound_read(hSound, hBuf); // Process read data in hBuf. Sound_write(hSound, hBuf); } Sound_delete(hSound); Buffer_delete(hBuf);
#define Sound_MAXDEVNAME 20 |
Max number of characters in the sound device name.
typedef struct Sound_Object* Sound_Handle |
Handle through which to reference a Sound device driver.
enum Sound_Std |
enum Sound_Mode |
enum Sound_Input |
Sound_Handle Sound_create | ( | Sound_Attrs * | attrs | ) |
Creates a Sound device driver instance.
[in] | attrs | Sound_Attrs to use for creating the Sound device driver instance. |
Handle | for use in subsequent operations (see Sound_Handle). | |
NULL | for failure. |
Int Sound_write | ( | Sound_Handle | hSound, | |
Buffer_Handle | hBuf | |||
) |
Write a buffer to the sound output. This function can only be called if the driver was opened for writing.
[in] | hSound | The Sound_Handle to write to. |
[in] | hBuf | The Buffer_Handle of the buffer to write to the sound device driver. |
Dmai_EOK | for success. | |
Negative value | for failure, see Dmai.h. |
If mono samples are being written, only half of the submitted buffer can be filled with data, as the Sound module will convert the mono samples to stereo before sending them to the device driver and need the extra space.
Int Sound_read | ( | Sound_Handle | hSound, | |
Buffer_Handle | hBuf | |||
) |
Fill a buffer from the sound input. This function can only be called if the driver was opened for reading.
[in] | hSound | The Sound_Handle to read from. |
[in] | hBuf | The Buffer_Handle of the buffer to fill using the sound device driver. |
Dmai_EOK | for success. | |
Negative value | for failure, see Dmai.h. |
If mono samples are being read, only half of the Buffer will be filled with data, use Buffer_getNumBytesUsed to get the actual number.
Int Sound_delete | ( | Sound_Handle | hSound | ) |
Deletes a Sound device driver instance.
[in] | hSound | The Sound_Handle to delete. |
Dmai_EOK | for success. | |
Negative value | for failure, see Dmai.h. |
Default attributes for a stereo Sound device driver.
sampleRate = 44100, channels = 2, leftGain = 100, rightGain = 100, mode = Sound_Mode_FULLDUPLEX, soundInput = Sound_Input_MIC, bufSize = 4096,
Default attributes for a mono Sound device driver.
sampleRate = 8000, channels = 1, leftGain = 100, rightGain = 100, mode = Sound_Mode_FULLDUPLEX, soundInput = Sound_Input_MIC, bufSize = 4096,