Wave Arts VQE  1.00
Voice Quality Enhancement
Public Member Functions | Protected Attributes
WadFile Class Reference

File device for WaAudioDev. More...

#include <WadFile.h>

Inheritance diagram for WadFile:
WaAudioDev WaAudioDevPort

List of all members.

Public Member Functions

 WadFile (char *inFile, char *outFile, bool simRealTime)
 Create a WadFile.
 ~WadFile ()
 destructor
WadAPI GetAPI ()
 return API enum
int Init ()
 initialize the OS API and discover all devices
int GetNumDevices (int *pNumDev)
 Get the count of devices discovered.
int GetDevInfo (int devId, WadDevInfo *pInfo)
 Get device information.
int GetDefaultInDevId (int *pId)
 Get the default input device.
int GetDefaultOutDevId (int *pId)
 Get the default output device.
int Open (WadParam *param, WadCallbackFn *inFn, WadCallbackFn *outFn, void *arg)
 Open devices for streaming.
int Start ()
 Start streaming.
int Stop ()
 Stop streaming.
void Close ()
 Close devices and release memory.
void Wait ()
 Wait for stream to complete.
int GetBufTime (bool isOutput, int *pBufTimeMsec)
 Get buffer time.
bool IsRunning ()
 Test if stream I/O thread is running.
int Thread ()
 I/O thread entry point.

Protected Attributes

char * inFile
 input file name, or NULL if fill with zeros
char * outFile
 output file name, or NULL if discard
WadParam param
 stream parameters
AFileInafi
 input file
AFileOutafo
 output file
void * inBuf
 temp input buffer
void * outBuf
 temp output buffer
bool isRunning
 T/F running?
bool simRealTime
 T/F simulating realtime by pausing between buffers?
void * arg
 argument to callback functions
WadCallbackFninFn
 input (record) callback
WadCallbackFnoutFn
 output (play) callback

Detailed Description

File device for WaAudioDev.

The WadFile file device reads from an input file (or fills with zeros), and writes to an output file (or discards). There is one device discovered, device ID == 0 (called the "File device"), which supports both input and output. Volume control and metering are currently not implemented but could be.


Constructor & Destructor Documentation

WadFile::WadFile ( char *  inFile,
char *  outFile,
bool  simRealTime 
)

Create a WadFile.

Parameters:
[in]inFileinput file name, or NULL to fill with zeros
[in]outFileoutput file name, or NULL to discard
[in]simRealTimeT/F if simulating realtime

WAV and AIF files are supported. Files will be created using 16-bit integer sample format. If simulating realtime, the I/O thread will pause between callbacks, else the processing runs as fast as possible.


Member Function Documentation

void WadFile::Close ( ) [virtual]

Close devices and release memory.

Close the devices and release all memory associated with streaming. Different devices can be re-opened with different parameters without having to recreate the WaAudioDev object.

Implements WaAudioDevPort.

WadAPI WadFile::GetAPI ( ) [virtual]

return API enum

Return enum specifying the low level API in use.

Implements WaAudioDev.

int WadFile::GetBufTime ( bool  isOutput,
int *  pBufTimeMsec 
) [virtual]

Get buffer time.

Parameters:
[in]isOutputtrue if get output buffer time, else get input buffer time
[out]pBufTimeMsecpointer 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.

Reimplemented from WaAudioDev.

int WadFile::GetDefaultInDevId ( int *  pId) [virtual]

Get the default input device.

Parameters:
[out]pIdpointer to default input device ID

Implements WaAudioDev.

int WadFile::GetDefaultOutDevId ( int *  pId) [virtual]

Get the default output device.

Parameters:
[out]pIdpointer to default output device ID

Implements WaAudioDev.

int WadFile::GetDevInfo ( int  devId,
WadDevInfo pInfo 
) [virtual]

Get device information.

Parameters:
[in]devIdthe device ID, 0 to numDev-1
[out]pInfopointer to device info

Implements WaAudioDev.

int WadFile::GetNumDevices ( int *  pNumDev) [virtual]

Get the count of devices discovered.

Parameters:
[out]pNumDevpointer to number of devices

Implements WaAudioDev.

int WadFile::Init ( ) [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.

Implements WaAudioDev.

bool WadFile::IsRunning ( ) [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.

Implements WaAudioDev.

int WadFile::Open ( WadParam param,
WadCallbackFn inFn,
WadCallbackFn outFn,
void *  arg 
) [virtual]

Open devices for streaming.

Open devices for streaming with provided parameters. Asynchronous callbacks fetch and deliver sample buffers: inFn delivers input sample buffers and outFn fetches output sample buffers. Streaming directions are determined by valid device IDs in parameter structure, at least one direction must be enabled. Pass NULL for callback if that direction is not enabled.

Parameters:
[in]paramStream parameters
[in]inFnInput callback function, or NULL
[in]outFnOutput callback function, or NULL
[in]argArgument to callbacks

Implements WaAudioDevPort.

int WadFile::Start ( ) [virtual]

Start streaming.

Start streaming audio. This must be called after Open to actually start stream.

Implements WaAudioDevPort.

int WadFile::Stop ( ) [virtual]

Stop streaming.

Stop streaming audio. Stream can be restarted by calling Start().

Implements WaAudioDevPort.

void WadFile::Wait ( ) [virtual]

Wait for stream to complete.

Wait for streaming I/O thread to terminate. This call blocks and should only be called if the callbacks will return false status to stop streaming and terminate I/O thread.

Implements WaAudioDevPort.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines