Specialized SoundRecorder which stores the captured audio data into a sound buffer. More...
#include <SoundBufferRecorder.hpp>
Public Member Functions | |
const SoundBuffer & | GetBuffer () const |
Get the sound buffer containing the captured audio data. | |
void | Start (unsigned int sampleRate=44100) |
Start the capture. | |
void | Stop () |
Stop the capture. | |
unsigned int | GetSampleRate () const |
Get the sample rate. | |
Static Public Member Functions | |
static bool | IsAvailable () |
Check if the system supports audio capture. |
Specialized SoundRecorder which stores the captured audio data into a sound buffer.
sf::SoundBufferRecorder allows to access a recorded sound through a sf::SoundBuffer, so that it can be played, saved to a file, etc.
It has the same simple interface as its base class (Start(), Stop()) and adds a function to retrieve the recorded sound buffer (GetBuffer()).
As usual, don't forget to call the IsAvailable() function before using this class (see sf::SoundRecorder for more details about this).
Usage example:
if (SoundBufferRecorder::IsAvailable()) { // Record some audio data SoundBufferRecorder recorder; recorder.Start(); ... recorder.Stop(); // Get the buffer containing the captured audio data const sf::SoundBuffer& buffer = recorder.GetBuffer(); // Save it to a file (for example...) buffer.SaveToFile("my_record.ogg"); }
Definition at line 43 of file SoundBufferRecorder.hpp.
const SoundBuffer & sf::SoundBufferRecorder::GetBuffer | ( | ) | const |
Get the sound buffer containing the captured audio data.
The sound buffer is valid only after the capture has ended. This function provides a read-only access to the internal sound buffer, but it can be copied if you need to make any modification to it.
Definition at line 63 of file SoundBufferRecorder.cpp.
unsigned int sf::SoundRecorder::GetSampleRate | ( | ) | const [inherited] |
Get the sample rate.
The sample rate defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality).
Definition at line 115 of file SoundRecorder.cpp.
bool sf::SoundRecorder::IsAvailable | ( | ) | [static, inherited] |
Check if the system supports audio capture.
This function should always be called before using the audio capture features. If it returns false, then any attempt to use sf::SoundRecorder or one of its derived classes will fail.
Definition at line 122 of file SoundRecorder.cpp.
void sf::SoundRecorder::Start | ( | unsigned int | sampleRate = 44100 |
) | [inherited] |
Start the capture.
The sampleRate parameter defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality). This function uses its own thread so that it doesn't block the rest of the program while the capture runs. Please note that only one capture can happen at the same time.
sampleRate | Desired capture rate, in number of samples per second |
Definition at line 62 of file SoundRecorder.cpp.
void sf::SoundRecorder::Stop | ( | ) | [inherited] |