cAudio::cAudioCapture Class Reference

Inheritance diagram for cAudio::cAudioCapture:
Inheritance graph
[legend]
Collaboration diagram for cAudio::cAudioCapture:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Events {
  ON_INIT, ON_UPDATE, ON_RELEASE, ON_BEGINCAPTURE,
  ON_ENDCAPTURE, ON_USERREQUESTEDBUFFER
}

Public Member Functions

bool checkCaptureExtension ()
 Checks to see if capturing audio is supported by OpenAL.
virtual bool initialize (const char *deviceName=0x0, unsigned int frequency=22050, AudioFormats format=EAF_16BIT_MONO, unsigned int internalBufferSize=8192)
 Initializes the capture device to the selected settings.
virtual bool isSupported ()
 Returns true if the current OpenAL implementation supports capturing audio.
virtual bool isReady ()
 Returns true if the capture device is ready to be used. False may indicate an error with the current settings.
virtual void updateCaptureBuffer (bool force=false)
 Grabs samples from the OpenAL buffer into the capture buffer if the OpenAL buffer has reached half full. Should be run once every audio frame, unless threading is enabled.
virtual void shutdown ()
 Shuts down the capture device, clearing the internal buffer and setting the audio capture into an uninitialized state. You must call initialize() again in order to reuse this object.
virtual const char * getAvailableDeviceName (unsigned int index)
 Returns the name of an available capture device.
virtual unsigned int getAvailableDeviceCount ()
 Returns the number of capture devices available for use.
virtual const char * getDefaultDeviceName ()
 Returns the name of the default system playback device.
virtual const char * getDeviceName ()
 Returns the name of the audio device being used to capture audio.
virtual unsigned int getFrequency ()
 Returns the frequency that the captured audio will be at.
virtual AudioFormats getFormat ()
 Returns the format of the captured audio.
virtual unsigned int getInternalBufferSize ()
 Returns the internal OpenAL buffer size in bytes.
virtual unsigned int getSampleSize ()
 Returns the size of a "sample" of audio data. Useful for making sure you grab audio data at sample boundaries.
virtual bool setDevice (const char *deviceName)
 Sets the audio device . Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
virtual bool setFrequency (unsigned int frequency)
 Sets the frequency that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
virtual bool setFormat (AudioFormats format)
 Sets the format that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
virtual bool setInternalBufferSize (unsigned int internalBufferSize)
 Sets the internal buffer size that OpenAL will use to store captured audio between calls to getCapturedAudio() in bytes. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.
virtual bool beginCapture ()
 Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.
virtual void stopCapture ()
 Stops capturing audio data to an internal buffer.
virtual unsigned int getCapturedAudio (void *outputBuffer, unsigned int outputBufferSize)
 Allows access to the audio data in the internal capture buffer.
virtual unsigned int getCurrentCapturedAudioSize ()
 Returns the current size of the internal audio buffer in bytes.
void getAvailableDevices ()
virtual void registerEventHandler (ICaptureEventHandler *handler)
 Registers a new event handler to this manager.
virtual void unRegisterEventHandler (ICaptureEventHandler *handler)
 Removes the specified event handler from this manager.
virtual void unRegisterAllEventHandlers ()
 Removes all event handlers attached to this manager.

Protected Member Functions

bool initOpenALDevice ()
void shutdownOpenALDevice ()
bool checkError ()
ALenum convertAudioFormatEnum (AudioFormats format)
void signalEvent (Events sevent)

Protected Attributes

cAudioMutex Mutex
unsigned int Frequency
AudioFormats Format
unsigned int InternalBufferSize
int SampleSize
std::vector< char > CaptureBuffer
std::vector< std::string > AvailableDevices
std::string DefaultDevice
std::list< ICaptureEventHandler * > eventHandlerList
bool Supported
bool Ready
bool Capturing
std::string DeviceName
ALCdevice * CaptureDevice

Detailed Description

Definition at line 18 of file cAudioCapture.h.


Member Function Documentation

bool cAudio::cAudioCapture::beginCapture (  )  [virtual]

Starts capturing audio data to an internal buffer. Will clear any old data in the buffer.

Returns:
True if capture was successfully started.

Implements cAudio::IAudioCapture.

Definition at line 182 of file cAudioCapture.cpp.

unsigned int cAudio::cAudioCapture::getAvailableDeviceCount (  )  [virtual]

Returns the number of capture devices available for use.

Returns:
Number of capture devices available.

Implements cAudio::IAudioCapture.

Definition at line 144 of file cAudioCapture.cpp.

const char * cAudio::cAudioCapture::getAvailableDeviceName ( unsigned int  index  )  [virtual]

Returns the name of an available capture device.

Parameters:
index,: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ).
Returns:
Name of the selected device.

Implements cAudio::IAudioCapture.

Definition at line 131 of file cAudioCapture.cpp.

unsigned int cAudio::cAudioCapture::getCapturedAudio ( void *  outputBuffer,
unsigned int  outputBufferSize 
) [virtual]

Allows access to the audio data in the internal capture buffer.

Can be called at any time to retrieve recorded audio. It is recommended that you call it every so often with long recordings to prevent the internal buffer from growing too large. Once successfully retrieved, the captured audio will be deleted from the internal buffer.

Parameters:
outputBuffer,: Pointer to an output array to copy audio data to.
outputBufferSize,: Size of the output array in bytes.
Returns:
Size in bytes of the data actually copied to the output buffer.

Implements cAudio::IAudioCapture.

Definition at line 216 of file cAudioCapture.cpp.

const char * cAudio::cAudioCapture::getDefaultDeviceName (  )  [virtual]

Returns the name of the default system playback device.

Returns:
Name of the default capture device.

Implements cAudio::IAudioCapture.

Definition at line 150 of file cAudioCapture.cpp.

virtual unsigned int cAudio::cAudioCapture::getInternalBufferSize (  )  [inline, virtual]

Returns the internal OpenAL buffer size in bytes.

Returns:
Size of the buffer in bytes.

Implements cAudio::IAudioCapture.

Definition at line 50 of file cAudioCapture.h.

virtual unsigned int cAudio::cAudioCapture::getSampleSize (  )  [inline, virtual]

Returns the size of a "sample" of audio data. Useful for making sure you grab audio data at sample boundaries.

Returns:
Size of a sample in bytes.

Implements cAudio::IAudioCapture.

Definition at line 51 of file cAudioCapture.h.

bool cAudio::cAudioCapture::initialize ( const char *  deviceName = 0x0,
unsigned int  frequency = 22050,
AudioFormats  format = EAF_16BIT_MONO,
unsigned int  internalBufferSize = 8192 
) [virtual]

Initializes the capture device to the selected settings.

Note that calling this will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.

Parameters:
deviceName,: Name of the audio device to capture audio from, pass NULL to specify the default one.
frequency,: Frequency that the captured audio will be captured at in hertz.
format,: Format of the captured audio.
internalBufferSize,: Size of the internal OpenAL buffer used to store the captured audio between calls to getCapturedAudio() in bytes.
Returns:
True on success, False if the capture device failed to initialize.

Implements cAudio::IAudioCapture.

Definition at line 282 of file cAudioCapture.cpp.

void cAudio::cAudioCapture::registerEventHandler ( ICaptureEventHandler handler  )  [virtual]

Registers a new event handler to this manager.

Parameters:
handler,: Pointer to an event handler to attach.

Implements cAudio::IAudioCapture.

Definition at line 393 of file cAudioCapture.cpp.

bool cAudio::cAudioCapture::setDevice ( const char *  deviceName  )  [virtual]

Sets the audio device . Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.

Parameters:
deviceName,: Name of the audio device to capture audio from, pass NULL to specify the default one.
Returns:
True on success, False if the capture device failed to initialize.

Implements cAudio::IAudioCapture.

Definition at line 273 of file cAudioCapture.cpp.

bool cAudio::cAudioCapture::setFormat ( AudioFormats  format  )  [virtual]

Sets the format that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.

Parameters:
format,: Format of the captured audio.
Returns:
True on success, False if the capture device failed to initialize.

Implements cAudio::IAudioCapture.

Definition at line 247 of file cAudioCapture.cpp.

bool cAudio::cAudioCapture::setFrequency ( unsigned int  frequency  )  [virtual]

Sets the frequency that the captured audio will be at. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.

Parameters:
frequency,: Frequency that the captured audio will be captured at in hertz.
Returns:
True on success, False if the capture device failed to initialize.

Implements cAudio::IAudioCapture.

Definition at line 239 of file cAudioCapture.cpp.

bool cAudio::cAudioCapture::setInternalBufferSize ( unsigned int  internalBufferSize  )  [virtual]

Sets the internal buffer size that OpenAL will use to store captured audio between calls to getCapturedAudio() in bytes. Will cause the capture device to be reinitialized. Calling while in use will clear the internal audio buffer.

Parameters:
internalBufferSize,: Size of the internal OpenAL buffer in bytes.
Returns:
True on success, False if the capture device failed to initialize.

Implements cAudio::IAudioCapture.

Definition at line 264 of file cAudioCapture.cpp.

void cAudio::cAudioCapture::unRegisterEventHandler ( ICaptureEventHandler handler  )  [virtual]

Removes the specified event handler from this manager.

Parameters:
handler,: Pointer to an event handler to remove.

Implements cAudio::IAudioCapture.

Definition at line 401 of file cAudioCapture.cpp.

void cAudio::cAudioCapture::updateCaptureBuffer ( bool  force = false  )  [virtual]

Grabs samples from the OpenAL buffer into the capture buffer if the OpenAL buffer has reached half full. Should be run once every audio frame, unless threading is enabled.

Parameters:
force,: Force capturing data from the buffer, even if the buffer is not half full.

Implements cAudio::IAudioCapture.

Definition at line 156 of file cAudioCapture.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations

Generated on Sat Feb 20 22:55:26 2010 for cAudio by  doxygen 1.6.2