UtiLite
0.3.1
A lite utilities library
|
#include <UAudioCapture.h>
Inherits UThread.
Inherited by UAudioCaptureFile, and UAudioCaptureMic.
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 () |
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;
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.
frame | the result frame |
frameId | the id of the frame |
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.
frame | the result frame |
frameIdBeg | the id of the begin frame |
frameIdEnd | the id of the end frame |
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.
frame | the result frame |
removeOldFrames | true to remove old frames |
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.
frame | the result frame |
frameId | the id of the frame |
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.
frameIdBeg | the id of the begin frame |
frameIdEnd | the id of the end frame |
void UAudioCapture::removeSamples | ( | int | sampleByteBeg, |
int | sampleByteEnd | ||
) |
Used to clean the memory.
sampleByteBeg | sample byte begin |
sampleByteEnd | sample byte end |