nCine::IAudioLoader class

Interface for an audio loader.

Opens an audio file, reads its header and exposes the format metadata. Use one of the create*() factory methods to obtain the loader matching a given file, then call createReader() to decode the actual samples.

Derived classes

class AudioLoaderMpt
Audio loader for tracker module formats, backed by libopenmpt.
class AudioLoaderOgg
Audio loader for the Ogg Vorbis format, backed by libvorbis.
class AudioLoaderWav
Audio loader for the WAVE (.wav) format.

Public static functions

static auto createFromFile(const Death::Containers::StringView path) -> std::unique_ptr<IAudioLoader>
Creates the loader matching the extension of the specified file.
static auto createFromStream(std::unique_ptr<Death::IO::Stream> fileHandle, Death::Containers::StringView path) -> std::unique_ptr<IAudioLoader>
Creates the loader matching the specified file for an already opened stream.

Constructors, destructors, conversion operators

~IAudioLoader() virtual
IAudioLoader(std::unique_ptr<Death::IO::Stream> fileHandle) protected explicit

Public functions

auto hasLoaded() const -> bool
Returns true if the audio file was loaded successfully.
auto bytesPerSample() const -> std::int32_t
Returns the number of bytes per sample.
auto numChannels() const -> std::int32_t
Returns the number of channels.
auto frequency() const -> std::int32_t
Returns the sample frequency.
auto numSamples() const -> std::int32_t
Returns the total number of samples.
auto duration() const -> float
Returns the duration in seconds.
auto bufferSize() const -> std::int32_t
Returns the decoded buffer size in bytes.
auto createReader() -> std::unique_ptr<IAudioReader> pure virtual
Creates the audio reader matching this loader.

Protected static functions

static auto createLoader(std::unique_ptr<Death::IO::Stream> fileHandle, Death::Containers::StringView path) -> std::unique_ptr<IAudioLoader>