nCine::AudioBufferPlayer class

Plays back a fully decoded AudioBuffer.

Suitable for short sound effects that are decoded into memory ahead of time. The same buffer can be shared between several players.

Base classes

class IAudioPlayer
Interface for an audio player.

Public static functions

static auto sType() -> ObjectType
Returns the static object type of this class.

Constructors, destructors, conversion operators

AudioBufferPlayer()
AudioBufferPlayer(AudioBuffer* audioBuffer) explicit
Creates a player bound to the specified shared buffer.
~AudioBufferPlayer() override
AudioBufferPlayer(const AudioBufferPlayer&) deleted
AudioBufferPlayer(AudioBufferPlayer&&) defaulted

Public functions

auto operator=(const AudioBufferPlayer&) -> AudioBufferPlayer& deleted
auto operator=(AudioBufferPlayer&&) -> AudioBufferPlayer& defaulted
auto bufferId() const -> std::uint32_t override
Returns the OpenAL id of the currently playing buffer.
auto bytesPerSample() const -> std::int32_t override
Returns the number of bytes per sample.
auto numChannels() const -> std::int32_t override
Returns the number of audio channels of the currently playing buffer.
auto frequency() const -> std::int32_t override
Returns the sample frequency of the currently playing buffer.
auto numSamples() const -> std::int32_t override
Returns the total number of samples.
auto duration() const -> float override
Returns the duration in seconds.
auto bufferSize() const -> std::int32_t override
Returns the size of the currently playing buffer in bytes.
auto audioBuffer() const -> const AudioBuffer*
Returns the audio buffer used for playback.
void setAudioBuffer(AudioBuffer* audioBuffer)
Sets the audio buffer used for playback.
void play() override
Starts or resumes playback.
void pause() override
Pauses playback at the current position.
void stop() override
Stops playback and rewinds to the beginning.
void updateState() override
Updates the player state once the source has finished playing.

Function documentation

void nCine::AudioBufferPlayer::updateState() override

Updates the player state once the source has finished playing.

Called every frame by IAudioDevice. In stream players it is also responsible for queueing and unqueueing buffers.