sf::SoundBufferRecorder Class Reference

Specialized SoundRecorder which stores the captured audio data into a sound buffer. More...

#include <SoundBufferRecorder.hpp>

Inheritance diagram for sf::SoundBufferRecorder:
sf::SoundRecorder sf::Thread

List of all members.

Public Member Functions

const SoundBufferGetBuffer () 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.

Detailed Description

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");
 }
See also:
sf::SoundRecorder

Definition at line 43 of file SoundBufferRecorder.hpp.


Member Function Documentation

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.

Returns:
Read-only access to the sound buffer

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).

Returns:
Sample rate, in samples per second

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.

Returns:
True if audio capture is supported, false otherwise

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.

Parameters:
sampleRate Desired capture rate, in number of samples per second
See also:
Stop

Definition at line 62 of file SoundRecorder.cpp.

void sf::SoundRecorder::Stop (  )  [inherited]

Stop the capture.

See also:
Start

Definition at line 106 of file SoundRecorder.cpp.


The documentation for this class was generated from the following files: