← API Reference Class

asge::media::AudioClip

Decoded PCM audio samples plus the SDL_AudioSpec describing them.

#include <AudioClip.hpp>

Produced by decoding a WAV or Ogg Vorbis file (see Load) into raw PCM ready for SDL's audio pipeline. Move-only, since the decoded sample buffer can be sizeable and copying it is rarely wanted.

Public Types

#using data_t = std::vector< std::uint8_t >

Private Attributes

#SDL_AudioSpec m_Specprivate
#data_t m_Dataprivate

Public Member Functions

#AudioClip()=delete
#AudioClip(SDL_AudioSpec inSpec, data_t inData)

Wraps already-decoded PCM samples and their format; prefer Load() to decode from a file.

#AudioClip(AudioClip const &)=delete
#AudioClip & operator=(AudioClip const &)=delete
#AudioClip(AudioClip &&)=default
#AudioClip & operator=(AudioClip &&)=default
#SDL_AudioSpec const & Spec() const noexcept

Sample format, channel count and frequency of the decoded audio.

#std::uint8_t const * Data() const noexcept

Pointer to the decoded raw PCM sample bytes.

#std::size_t Size() const noexcept

Size, in bytes, of the buffer returned by Data().

Static Public Member Functions

#static Result< AudioClip > Load(filesystem::Path const &inPath) noexcept

Reads an audio file from disk and decodes it (WAV or OGG, dispatched by extension) into raw PCM.