bool isAvailable(char* ret_whay_not = 0);
Tests if a sound recording device is available. If not the return string
will contain a text whay not. It can contain two messages: "no device exists"
or "can not open device".
Opens a sound recording device.
Note: this function can throw two types of exceptions: wf_error, std::bad_alloc.
Stops recording and closes the sound recording device.
void read(char *buff, int n)
Reads n bytes from a sound device to an output buffer. The reading is performed
through an internal buffer. If the buffer is free, it starts recording. The
calling of reading can be random but if the interval between two calls is
not too long and the internal buffer does not overflow, the recording is
Note: this function can throw the wf_error exception.
void setFormat(int sf, int ch, int bps)
Sets a format of recorded data. Number of channels can be 1 or 2, bits per
sample is 8 r 16.
This exception is thrown when memory allocation error occured.
This exception is trown if a error in opening/closing recording device or
during recording occured. You can call a wf_error::what() function to get
error message. It can be one of following:
Can not open sound device.
Can not prepare a sound buffer.
Can not add a buffer.
A sound device is not open.
Can not start recording.
A CWFS_BUFFERLENGTH constant must be multiplication of a CWFS_FRAMELENGTH
int N = 40;
WFS.setFormat(8000, 1, 16);
WFS.read((char *)buffer, N * sizeof(short));
printf("ERROR: %s\n", err.what());