|
Wave Arts VQE
1.00
Voice Quality Enhancement
|
Audio device. More...
#include <WaAudioDev.h>
Public Member Functions | |
| virtual WadAPI | GetAPI ()=0 |
| return API enum | |
| virtual int | Init ()=0 |
| initialize the OS API and discover all devices | |
| virtual int | GetNumDevices (int *pNumDev)=0 |
| Get the count of devices discovered. | |
| virtual int | GetDevInfo (int devId, WadDevInfo *pInfo)=0 |
| Get device information. | |
| virtual int | GetDefaultInDevId (int *pId)=0 |
| Get the default input device. | |
| virtual int | GetDefaultOutDevId (int *pId)=0 |
| Get the default output device. | |
| void | SetMeteringEnable (bool enable) |
| Enable/disable metering. | |
| bool | GetInPeak (float *pPeakVal) |
| Get input peak value. | |
| bool | GetOutPeak (float *pPeakVal) |
| Get output peak value. | |
| float | GetLastInPeak () |
| Get peak value of last input buffer processed. | |
| float | GetLastOutPeak () |
| Get peak value of last output buffer processed. | |
| void | ResetMetering () |
| Reset peak metering values. | |
| virtual int | SetVol (int devId, bool isOutput, float vol) |
| Set volume. | |
| virtual int | GetVol (int devId, bool isOutput, float *pVol) |
| Get volume. | |
| virtual int | GetBufTime (bool isOutput, int *pBufTimeMsec) |
| Get buffer time. | |
| virtual int | GetClosestFormat (bool isOutput, WadStreamFormat *pFormat) |
| Get closest stream format after an unsupported format error. | |
| WaAudioDev * | GetDevice () |
| Get the device. | |
| virtual char * | GetErrorText () |
| Get the error text after error status is returned. | |
| bool | IsInitialized () |
| Return T/F if Init() has been called and devices are discovered. | |
| bool | IsOpen () |
| Return T/F if device is open for streaming. | |
| bool | IsInOpen () |
| return T/F if device is open for input streaming | |
| bool | IsOutOpen () |
| return T/F if device is open for output streaming | |
| virtual bool | IsRunning ()=0 |
| Test if stream I/O thread is running. | |
| void | SetErrorText (char *text) |
| Set the error text. | |
Static Public Member Functions | |
| static float | PeakToDb (float peak, float minDb, float maxDb) |
| Convert peak sample value to dB. | |
| static int | CalcPeakInt16 (short *buf, unsigned int numSamps) |
| Calculate maximum absolute value of short buffer. | |
| static float | CalcPeakFloat32 (float *buf, unsigned int numSamps) |
| Calculate maximum absolute value of float buffer. | |
| static WaAudioDev * | WadMake (int options) |
| Make audio device. | |
Protected Member Functions | |
| void | ProcInPeakInt16 (short *buf, unsigned int numSamps) |
| do input meter processing on 16-bit integer samples | |
| void | ProcInPeakFloat32 (float *buf, unsigned int numSamps) |
| do input meter processing on 32-bit float samples | |
| void | ProcOutPeakInt16 (short *buf, unsigned int numSamps) |
| do output meter processing on 16-bit integer samples | |
| void | ProcOutPeakFloat32 (float *buf, unsigned int numSamps) |
| do output meter processing on 32-bit float samples | |
| void | SetIsInitialized (bool isInitialized) |
| set initialized flag | |
Protected Attributes | |
| float | inPeak |
| running input peak value | |
| float | lastInPeak |
| last input buffer peak value | |
| float | outPeak |
| running ouput peak value | |
| float | lastOutPeak |
| last output buffer peak value | |
| bool | inPeakIsValid |
| is inPeak valid, i.e. any samples processed? | |
| bool | outPeakIsValid |
| is outPeak value, i.e any samples processed? | |
| WadParam | param |
| parameters used to open the device | |
| bool | isInitialized |
| Init() has completed, devices have been discovered. | |
| bool | isMeteringEnabled |
| metering is enabled/disabled | |
| bool | isOpen |
| successful Open sets this, Close resets | |
| char | errorText [WAD_MAX_ERROR_TEXT] |
| error text used by device and connected ports | |
Audio device.
Virtual base class for cross-platform audio devices. This can be implemented for each OS audio device API, e.g. Windows MME. This is intended for telecom use, not pro audio, hence there is no support for 24-bit or 32-bit integer sample formats or surround multichannel formats.
Creating the object doesn't do anything. Init() initializes the OS API and discovers audio devices. Use the WaAudioDevPort methods to open input and output devices for streaming. A single WaAudioDev object can have at most one input and one output stream. If you want more audio streams you need to create more instances of WaAudioDev.
If you want to rescan devices due to notification of a device change, you must create a new WaAudioDev object. You will probably want to remember any existing active device names, close open streams, and attempt to reopen using the saved device names to find the new device indices.
The audio device interface provides support for device volume control and signal level metering.
| float WaAudioDev::CalcPeakFloat32 | ( | float * | buf, |
| unsigned int | numSamps | ||
| ) | [static] |
Calculate maximum absolute value of float buffer.
| [in] | buf | buffer of float samples |
| [in] | numSamps | number of samples |
| int WaAudioDev::CalcPeakInt16 | ( | short * | buf, |
| unsigned int | numSamps | ||
| ) | [static] |
Calculate maximum absolute value of short buffer.
| [in] | buf | buffer of short samples |
| [in] | numSamps | number of samples |
| virtual WadAPI WaAudioDev::GetAPI | ( | ) | [pure virtual] |
| int WaAudioDev::GetBufTime | ( | bool | isOutput, |
| int * | pBufTimeMsec | ||
| ) | [virtual] |
Get buffer time.
| [in] | isOutput | true if get output buffer time, else get input buffer time |
| [out] | pBufTimeMsec | pointer to buffer time in milliseconds |
Return total buffer times in msec for the currently open devices. This is useful in case we want to increase the buffering because we're getting dropouts.
| int WaAudioDev::GetClosestFormat | ( | bool | isOutput, |
| WadStreamFormat * | pFormat | ||
| ) | [virtual] |
Get closest stream format after an unsupported format error.
| [in] | isOutput | true if get output format, else get input format |
| [out] | pFormat | pointer to closest format |
After an unsupported format error, calling this will return the closest supported format. The caller can then set up appropriate sample rate and sample format and channel format conversions and try to reopen the device.
Reimplemented in WadWASAPI.
| virtual int WaAudioDev::GetDefaultInDevId | ( | int * | pId | ) | [pure virtual] |
| virtual int WaAudioDev::GetDefaultOutDevId | ( | int * | pId | ) | [pure virtual] |
| WaAudioDev * WaAudioDev::GetDevice | ( | ) | [virtual] |
Get the device.
Returns pointer to the actual WaAudioDev at the end of the processing chain. Hence if you have a WaAudioDevPort pointer and you want to do an operation like get device name or change volume, you can first get the WaAudioDev pointer and call methods on that.
Implements WaAudioDevPort.
| virtual int WaAudioDev::GetDevInfo | ( | int | devId, |
| WadDevInfo * | pInfo | ||
| ) | [pure virtual] |
| char * WaAudioDev::GetErrorText | ( | ) | [virtual] |
Get the error text after error status is returned.
When an error occurs using a device or device port the code will often store a descriptive error message. Call this to retrieve the error text after an error. Note that device ports store their errors in the WaAudioDev at the end of the processing chain. You should use or copy the error text before calling additional methods, closing, or deleting port or device.
| bool WaAudioDev::GetInPeak | ( | float * | pPeakVal | ) |
Get input peak value.
| [out] | pPeakVal | pointer to peak value |
Returns true if any samples processed since last poll. All peak values are represented as float samples where 1.0 is maximum.
| float WaAudioDev::GetLastInPeak | ( | ) |
Get peak value of last input buffer processed.
This is for internal use (autogain).
| float WaAudioDev::GetLastOutPeak | ( | ) |
Get peak value of last output buffer processed.
This is for internal use.
| virtual int WaAudioDev::GetNumDevices | ( | int * | pNumDev | ) | [pure virtual] |
| bool WaAudioDev::GetOutPeak | ( | float * | pPeakVal | ) |
Get output peak value.
| [out] | pPeakVal | pointer to peak value |
Returns true if any samples processed since last poll. All peak values are represented as float samples where 1.0 is maximum.
| int WaAudioDev::GetVol | ( | int | devId, |
| bool | isOutput, | ||
| float * | pVol | ||
| ) | [virtual] |
Get volume.
| [in] | devId | device ID |
| [in] | isOutput | true if get output volume, else get input volume |
| [out] | vol | pointer to volume, 0.0 (min) to 1.0 (max) |
Get volume of device. Any discovered device can be specified and the device does not need to be open for streaming.
| virtual int WaAudioDev::Init | ( | ) | [pure virtual] |
initialize the OS API and discover all devices
Initialize, which means do device discovery. The idea is that the devices are enumerated at Init time, and from then on only this device set can be used. Any dynamic changes to the device set can be caught via messages and then this WaAudioDev object must be recreated to discover the new devices updating the device table.
| virtual bool WaAudioDev::IsRunning | ( | ) | [pure virtual] |
Test if stream I/O thread is running.
Implement this to return false if the I/O thread has exited perhaps because a callback has returned false. This is a non-blocking alternative to Wait(). But why can't we just use IsOpen()? Ah, because the thread terminating doesn't automatically close the device, that's why.
| float WaAudioDev::PeakToDb | ( | float | peak, |
| float | minDb, | ||
| float | maxDb | ||
| ) | [static] |
Convert peak sample value to dB.
| [in] | peak | peak value, 1.0 is maximum |
| [in] | minDb | minimum dB value to return |
| [in] | maxDb | maximum dB value to return |
Helper function to convert peak values to dBFS (full scale) and restrict range. A peak of 1.0 maps to 0 dB.
| void WaAudioDev::ResetMetering | ( | ) |
Reset peak metering values.
Implementations should reset metering in Close or Open.
| void WaAudioDev::SetErrorText | ( | char * | text | ) |
Set the error text.
| [in] | text | error text |
Set the error text. This method is public so that ports can set error text. Ports report error text by storing text in device.
| void WaAudioDev::SetMeteringEnable | ( | bool | enable | ) |
Enable/disable metering.
| [in] | enable | enable flag |
| int WaAudioDev::SetVol | ( | int | devId, |
| bool | isOutput, | ||
| float | vol | ||
| ) | [virtual] |
Set volume.
| [in] | devId | device ID |
| [in] | isOutput | true if set output volume, else set input volume |
| [in] | vol | volume, 0.0 (min) to 1.0 (max) |
Set volume of device. Any discovered device can be specified and the device does not need to be open for streaming.
| WaAudioDev * WaAudioDev::WadMake | ( | int | options | ) | [static] |
Make audio device.
| [in] | options | option flags |
Make an audio device for the OS platform. The options argument allows some control. Note that this only creates the WaAudioDev object, the caller must call Init() after creating the object.
1.7.5.1