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 GetBufferId() const -> std::uint32_t override
Returns the backend id of the currently playing buffer.
auto GetBytesPerSample() const -> std::int32_t override
Returns the number of bytes per sample.
auto GetChannelCount() const -> std::int32_t override
Returns the number of audio channels of the currently playing buffer.
auto GetFrequency() const -> std::int32_t override
Returns the sample frequency of the currently playing buffer.
auto GetSampleCount() const -> std::int32_t override
Returns the total number of samples.
auto GetDuration() const -> float override
Returns the duration in seconds.
auto GetBufferSize() const -> std::int32_t override
Returns the size of the currently playing buffer in bytes.
auto GetAudioBuffer() 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 SetLooping(bool value) override
Sets whether the player should loop.
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.