#include <laudio.hh>
Public Types | |
| enum | iomode { m_listen, m_sing, m_monitor, m_converse } |
| enum | ioport { p_Speaker = 1, p_Phone = 2, p_Line = 4 } |
| typedef unsigned int | count_t |
Public Member Functions | |
| LAudio (void) | |
| LAudio (const char *device) | |
| ~LAudio (void) | |
| void | close (void) |
| void | drain (void) throw (std::runtime_error) |
| void | dumpStatus (std::ostream &out) const |
| std::string | getDevice (void) const |
| const char * | getEncoding (void) const throw (std::runtime_error) |
| count_t | getMonitorGain (void) const throw (std::runtime_error) |
| count_t | getPrecision (void) const throw (std::runtime_error) |
| count_t | getSpeed (void) const throw (std::runtime_error) |
| double | getVolume (void) const throw (std::runtime_error) |
| bool | isOpen (void) const |
| void | mute (bool mute) throw (std::runtime_error) |
| void | open (const char *device=0, iomode mode=m_sing) |
| void | reSample (double freq, short data[], count_t length) |
| void | reSample (double freq, float data[], count_t length) |
| void | setEncoding (const char *encode) throw (std::runtime_error) |
| void | setInputTransform (double bias, double scale) |
| void | setPorts (count_t mask) throw (std::runtime_error) |
| void | setMonitorGain (count_t gain) throw (std::runtime_error) |
| void | setSpeed (count_t rate) throw (std::runtime_error) |
| void | setPrecision (count_t bits) throw (std::runtime_error) |
| void | setVolume (double volume) throw (std::runtime_error) |
| void | sing (short data[], count_t length) |
Classes | |
| struct | DspStatus |
| typedef unsigned int LAudio::count_t |
Data type used internally for data counting.
| enum LAudio::iomode |
The mode specified whether the audio interface will beused for listening (Input from a microphone), Singing (output to a speaker), monitoring (Input from a microphone with an immediate copy going to the speaker) or Conversation (Listening and talking).
| enum LAudio::ioport |
Output port enumeration.
| LAudio::LAudio | ( | void | ) |
Create an interface to the default audio device. The default device is usually /dev/audio, but this default may be overridden by setting the DEVAUDIO environment vaariable. brief Connect to the default device.
| LAudio::LAudio | ( | const char * | device | ) |
Create an interface and connect to the spcified device.
| LAudio::~LAudio | ( | void | ) |
Disconnect/destroy the audio interface. brief destroy the interface.
| void LAudio::close | ( | void | ) |
Close a previously opened audio device. The close() request hangs while data are drained from the output buffer. brief close the audio device.
| void LAudio::drain | ( | void | ) | throw (std::runtime_error) |
Block further execution until all samples have been sent to the the audio device. brief Wait for data to be played.
| void LAudio::dumpStatus | ( | std::ostream & | out | ) | const |
Print out the status of the interfaces in use. brief Dump interface status.
| std::string LAudio::getDevice | ( | void | ) | const |
The device type is read from the nterface card. It is returned as an ASCII string in the form "<interface>-<version>-<configuation>". brief Get the device type.
| const char* LAudio::getEncoding | ( | void | ) | const throw (std::runtime_error) |
The signal may be encoded with either a "Linear" transformation, the mu-transformation ("mu-Law") or the A-transformation ("A-Law"). brief Get the signal encoding.
| count_t LAudio::getMonitorGain | ( | void | ) | const throw (std::runtime_error) |
Set the gain for feeding data from the microphone to the speaker when in monitor mode.
| count_t LAudio::getPrecision | ( | void | ) | const throw (std::runtime_error) |
Get the data bit precision. 8-bit and 16-bit data words are supported. brief Get data precision.
| count_t LAudio::getSpeed | ( | void | ) | const throw (std::runtime_error) |
Get the Sample rate. brief Get data sample rate.
| double LAudio::getVolume | ( | void | ) | const throw (std::runtime_error) |
Get the output amplifier gain for feeding the speaker when in monitor sing, monitor or converse mode.
| bool LAudio::isOpen | ( | void | ) | const |
Test whether the interface has a device connected to it. brief test if device is connected.
| void LAudio::mute | ( | bool | mute | ) | throw (std::runtime_error) |
Enable/Disable all sound outputs. All volume controls and output port selections are left intact. brief Mute audio outputs.
| mute | True if audio output is to be muted (disabled). |
| void LAudio::open | ( | const char * | device = 0, |
|
| iomode | mode = m_sing | |||
| ) |
Open the specified output device. If a NULL pointer or zero-length device name is specified, the device specified by the AUDIODEV environment variable is used or if AUDIODEV is not specified, "/dev/audio" is used. brief Open an audio device.
| device | pointer to the device name string. | |
| mode | Input/Output mode. |
| void LAudio::reSample | ( | double | freq, | |
| short | data[], | |||
| count_t | length | |||
| ) |
Interpolate samples where necessary to match the sampling frequency to the audio output rate and send the result to the audio output port. brief Blast out an interpolated wave form.
| freq | Sample frequency (in Hz) of input data. | |
| data | A short integer array containing the samples to be sung. | |
| length | Number of input data samples. |
| void LAudio::reSample | ( | double | freq, | |
| float | data[], | |||
| count_t | length | |||
| ) |
Interpolate samples where necessary to match the sampling frequency to the audio output rate and send the result to the audio output port. brief Blast out an interpolated wave form.
| freq | Sample frequency (in Hz) of input data. | |
| data | A float array containing the samples to be sung. | |
| length | Number of input data samples. |
| void LAudio::setEncoding | ( | const char * | encode | ) | throw (std::runtime_error) |
Select the specified encoding mode. Valid encoding modes are: Linear, A-Law and u-Law. At present only Linear is implemented. A runtime error is thrown if the specified encoding technique is not known or if the the selection is rejected by the device driver. brief Select data encoding technique.
| encode | Pointer to a string specifiying the encoding mode. |
| void LAudio::setInputTransform | ( | double | bias, | |
| double | scale | |||
| ) |
Set a linear transformation for input data.
| void LAudio::setPorts | ( | count_t | mask | ) | throw (std::runtime_error) |
Select audio output ports. The available port IDs are described in the ioport enumerator. brief Select audio output ports.
| mask | Bit mask with a bit set for each selected port. |
| void LAudio::setMonitorGain | ( | count_t | gain | ) | throw (std::runtime_error) |
Set the monitor gain. The monitor gain controls the amplitude with which the input port data are copied to the output port(s). brief Set monitor gain.
| gain | Multiplier for input to be added to the output. |
| void LAudio::setSpeed | ( | count_t | rate | ) | throw (std::runtime_error) |
Set the sample rate. Because of hardware limitations in some sound cards, the should be set only after the data format and number of channels have been set. brief rate Sample rate to be used.
| void LAudio::setPrecision | ( | count_t | bits | ) | throw (std::runtime_error) |
Set number of bits of precision for each audio sample. 8-bit and 16-bit precision are currently allowed. Setting the precision implies a Linear encoding format. brief bits Length of each sample in bits.
| void LAudio::setVolume | ( | double | volume | ) | throw (std::runtime_error) |
Set the amplifier gain for feeding the speaker.
| void LAudio::sing | ( | short | data[], | |
| count_t | length | |||
| ) |
Spew audio output. brief Blast out a sampled wave form.
| data | A short integer array containing the samples to be sung. | |
| length | Number of data samples. |
1.5.4