class EE::Audio::SoundBufferRecorder

Overview

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

#include <soundbufferrecorder.hpp>

class SoundBufferRecorder: public EE::Audio::SoundRecorder {
public:
    // construction

    ~SoundBufferRecorder();

    // methods

    const SoundBuffer& getBuffer() const;
};

Inherited Members

public:
    // methods

    bool start(unsigned int sampleRate = 44100);
    void stop();
    unsigned int getSampleRate() const;
    bool setDevice(const std::string& name);
    const std::string& getDevice() const;
    void setChannelCount(unsigned int channelCount);
    unsigned int getChannelCount() const;
    bool isCapturing();
    static std::vector<std::string> getAvailableDevices();
    static std::string getDefaultDevice();
    static bool isAvailable();

Detailed Documentation

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

SoundBufferRecorder allows to access a recorded sound through a 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 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 SoundBuffer& buffer = recorder.getBuffer();

 // Save it to a file (for example...)
 buffer.saveToFile("my_record.ogg");
}

See also:

SoundRecorder

Methods

const SoundBuffer& 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