UtiLite  0.3.1
A lite utilities library
Public Member Functions | Protected Member Functions
UAudioCapture Class Reference

#include <UAudioCapture.h>

Inherits UThread.

Inherited by UAudioCaptureFile, and UAudioCaptureMic.

List of all members.

Public Member Functions

bool getNextFrame (std::vector< char > &frame, bool removeOldFrames=false)
bool getNextFrame (std::vector< char > &frame, int &frameId)
bool getMultiFrame (std::vector< char > &frame, int frameIdBeg, int frameIdEnd)
bool getFrame (std::vector< char > &frame, int frameId)
void removeFrames (int frameIdBeg, int frameIdEnd)
void removeSamples (int sampleByteBeg, int sampleByteEnd)

Protected Member Functions

virtual void mainLoopEnd ()

Detailed Description

This is the abstract class for all recorders. A recorder is used to get fixed frame length from a stream. It is configured with the length of the frame wanted. The main methods are Start, stop, and getNextFrame. See UAudioCaptureMic and UAudioCaptureFile for implementation. To extract samples in frequency domain, see UAudioCaptureFFT.


Example :

    UAudioCapture* recorder = <<SeeInheritedClasses>>;
    Frame frame;
    unsigned int frameId = 0;
    recorder->start();
    while(recorder->getNextFrame(frame, frameId))
    { 
      ...process the frame...
      ... break when a condition is reached...
    }
    recorder->stop();
    delete recorder;
See also:
UAudioCapture::start
UAudioCapture::stop
UAudioCapture::getNextFrame

Member Function Documentation

bool UAudioCapture::getFrame ( std::vector< char > &  frame,
int  frameId 
)

Get a specific frame from the stream. If the id is higher than the last frame recorded, the caller will wait until enough data is recorded.

Parameters:
framethe result frame
frameIdthe id of the frame
Returns:
true on success, this method failed when the end of the stream is reached.
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
bool UAudioCapture::getMultiFrame ( std::vector< char > &  frame,
int  frameIdBeg,
int  frameIdEnd 
)

Get the multiple frames from the stream. The caller will wait until enough data is recorded.

Parameters:
framethe result frame
frameIdBegthe id of the begin frame
frameIdEndthe id of the end frame
Returns:
true on success, this method failed when the end of the stream is reached.
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
bool UAudioCapture::getNextFrame ( std::vector< char > &  frame,
bool  removeOldFrames = false 
)

Get the next frame from the stream. The caller will wait until the length of the frame required is reached. The parameter removeOldFrames can be used to clean the memory after each call. When removeOldFrames = true, the frame id is reseted.

Parameters:
framethe result frame
removeOldFramestrue to remove old frames
Returns:
true on success, this method failed when the end of the stream is reached.
bool UAudioCapture::getNextFrame ( std::vector< char > &  frame,
int &  frameId 
)

Get the next frame from the stream. The caller will wait until the length of the frame required is reached.

Parameters:
framethe result frame
frameIdthe id of the frame
Returns:
true on success, this method failed when the end of the stream is reached.
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
virtual void UAudioCapture::mainLoopEnd ( ) [protected, virtual]

Virtual method mainLoopEnd(). User can implement this function to add a behavior after the thread is killed (after exiting the mainLoop(), work is still done in the thread before exiting).

Reimplemented from UThread.

Reimplemented in UAudioCaptureMic, and UAudioCaptureFile.

void UAudioCapture::removeFrames ( int  frameIdBeg,
int  frameIdEnd 
)

Used to clean the memory.

Parameters:
frameIdBegthe id of the begin frame
frameIdEndthe id of the end frame
Warning:
if getNextFrame with removeOldFrames=true is called, the id is reseted.
void UAudioCapture::removeSamples ( int  sampleByteBeg,
int  sampleByteEnd 
)

Used to clean the memory.

Parameters:
sampleByteBegsample byte begin
sampleByteEndsample byte end

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Friends Defines