El Octavio  1.0
This is a video game about adventures.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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:
+ Collaboration diagram for sf::SoundBufferRecorder:

Public Member Functions

 ~SoundBufferRecorder ()
 destructor More...
 
const SoundBuffergetBuffer () const
 Get the sound buffer containing the captured audio data. More...
 
- Public Member Functions inherited from sf::SoundRecorder
virtual ~SoundRecorder ()
 destructor More...
 
bool start (unsigned int sampleRate=44100)
 Start the capture. More...
 
void stop ()
 Stop the capture. More...
 
unsigned int getSampleRate () const
 Get the sample rate. More...
 
bool setDevice (const std::string &name)
 Set the audio capture device. More...
 
const std::string & getDevice () const
 Get the name of the current audio capture device. More...
 
void setChannelCount (unsigned int channelCount)
 Set the channel count of the audio capture device. More...
 
unsigned int getChannelCount () const
 Get the number of channels used by this recorder. More...
 

Protected Member Functions

virtual bool onStart ()
 Start capturing audio data. More...
 
virtual bool onProcessSamples (const Int16 *samples, std::size_t sampleCount)
 Process a new chunk of recorded samples. More...
 
virtual void onStop ()
 Stop capturing audio data. More...
 
- Protected Member Functions inherited from sf::SoundRecorder
 SoundRecorder ()
 Default constructor. More...
 
void setProcessingInterval (Time interval)
 Set the processing interval. More...
 
virtual bool onStart ()
 Start capturing audio data. More...
 
virtual bool onProcessSamples (const Int16 *samples, std::size_t sampleCount)=0
 Process a new chunk of recorded samples. More...
 
virtual void onStop ()
 Stop capturing audio data. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from sf::SoundRecorder
static std::vector< std::string > getAvailableDevices ()
 Get a list of the names of all available audio capture devices. More...
 
static std::string getDefaultDevice ()
 Get the name of the default audio capture device. More...
 
static bool isAvailable ()
 Check if the system supports audio capture. More...
 

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:

{
// Record some audio data
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");
}
Storage for audio samples defining a sound.
Definition: SoundBuffer.hpp:50
bool saveToFile(const std::string &filename) const
Save the sound buffer to an audio file.
Specialized SoundRecorder which stores the captured audio data into a sound buffer.
const SoundBuffer & getBuffer() const
Get the sound buffer containing the captured audio data.
bool start(unsigned int sampleRate=44100)
Start the capture.
void stop()
Stop the capture.
static bool isAvailable()
Check if the system supports audio capture.
See also
sf::SoundRecorder

Definition at line 44 of file SoundBufferRecorder.hpp.

Constructor & Destructor Documentation

◆ ~SoundBufferRecorder()

sf::SoundBufferRecorder::~SoundBufferRecorder ( )

destructor

Member Function Documentation

◆ getBuffer()

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

◆ onProcessSamples()

virtual bool sf::SoundBufferRecorder::onProcessSamples ( const Int16 samples,
std::size_t  sampleCount 
)
protectedvirtual

Process a new chunk of recorded samples.

Parameters
samplesPointer to the new chunk of recorded samples
sampleCountNumber of samples pointed by samples
Returns
True to continue the capture, or false to stop it

Implements sf::SoundRecorder.

◆ onStart()

virtual bool sf::SoundBufferRecorder::onStart ( )
protectedvirtual

Start capturing audio data.

Returns
True to start the capture, or false to abort it

Reimplemented from sf::SoundRecorder.

◆ onStop()

virtual void sf::SoundBufferRecorder::onStop ( )
protectedvirtual

Stop capturing audio data.

Reimplemented from sf::SoundRecorder.


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