nCine::AudioBuffer class

Fully decoded audio buffer.

Holds an entire sound effect in device memory, can be shared by multiple AudioBufferPlayer instances. Where NCINE_HAS_NATIVE_AUDIO is defined, LoadFromFile() hands the file over to the device instead.

Base classes

class Object
Base class of all nCine objects.

Public types

using Format = IAudioDevice::BufferFormat
Sample format.

Public static functions

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

Constructors, destructors, conversion operators

AudioBuffer()
Creates an empty buffer.
AudioBuffer(StringView filename) explicit
Creates a buffer and loads it from the specified file.
~AudioBuffer() override
AudioBuffer(const AudioBuffer&) deleted
AudioBuffer(AudioBuffer&& other) noexcept
AudioBuffer(std::unique_ptr<Death::IO::Stream> fileHandle, StringView filename)
Creates a buffer and loads it from an already opened stream.

Public functions

auto operator=(const AudioBuffer&) -> AudioBuffer& deleted
auto operator=(AudioBuffer&& other) -> AudioBuffer& noexcept
auto LoadFromFile(StringView filename) -> bool
Loads audio data from the specified file.
void Init(Format format, std::int32_t frequency)
Initializes an empty buffer with the specified format and frequency.
auto LoadFromStream(std::unique_ptr<Death::IO::Stream> fileHandle, StringView filename) -> bool
Loads audio data from an already opened stream.
auto LoadFromSamples(const unsigned char* bufferPtr, std::int32_t bufferSize) -> bool
Loads samples in raw PCM format from a memory buffer.
auto GetBufferId() const -> std::uint32_t
Returns the backend buffer id.
auto GetBytesPerSample() const -> std::int32_t
Returns the number of bytes per sample.
auto GetChannelCount() const -> std::int32_t
Returns the number of audio channels.
auto GetFrequency() const -> std::int32_t
Returns the sample frequency.
auto GetSampleCount() const -> std::int32_t
Returns the total number of samples.
auto GetDuration() const -> float
Returns the duration in seconds.
auto GetBufferSize() const -> std::int32_t
Returns the size of the buffer in bytes.