utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::sound::WAVDecoder Class Reference

Decoder implementation for Waveform Audio File Format (WAV) files. More...

#include <headers/utility/sound/decoder/wav_decoder.hpp>

Inheritance diagram for utility::sound::WAVDecoder:
Collaboration diagram for utility::sound::WAVDecoder:

Public Member Functions

 WAVDecoder ()
 Creates a WAV decoder instance.
 
 ~WAVDecoder () override
 Destroys the WAV decoder instance.
 
bool canDecode (const std::string &filePath) const override
 Determines whether the specified file can be decoded.
 
bool canDecode (AudioDecoderType type) const override
 Determines whether the specified decoder type is supported.
 
std::shared_ptr< AudioBufferdecode (std::shared_ptr< utility::File > file) override
 Decodes a WAV file into an AudioBuffer.
 
- Public Member Functions inherited from utility::sound::AAudioDecoder
virtual ~AAudioDecoder ()=default
 Virtual destructor.
 
ALenum getALFormat (uint16_t channels, uint16_t bitsPerSample) const
 Converts audio properties to an OpenAL format.
 

Detailed Description

Decoder implementation for Waveform Audio File Format (WAV) files.

WAVDecoder uses the dr_wav library to decode WAV-encoded audio data into raw Pulse-Code Modulation (PCM) samples compatible with OpenAL.

The decoder supports uncompressed PCM WAV files and uploads the decoded samples to an AudioBuffer instance for playback.

Definition at line 41 of file wav_decoder.hpp.

Constructor & Destructor Documentation

◆ WAVDecoder()

utility::sound::WAVDecoder::WAVDecoder ( )

Creates a WAV decoder instance.

Definition at line 34 of file wav_decoder.cpp.

Here is the call graph for this function:

◆ ~WAVDecoder()

utility::sound::WAVDecoder::~WAVDecoder ( )
override

Destroys the WAV decoder instance.

Definition at line 39 of file wav_decoder.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ canDecode() [1/2]

bool utility::sound::WAVDecoder::canDecode ( AudioDecoderType  type) const
overridevirtual

Determines whether the specified decoder type is supported.

Parameters
typeAudio decoder type to test.
Returns
true if the decoder supports the specified type, false otherwise.

Implements utility::sound::AAudioDecoder.

Definition at line 51 of file wav_decoder.cpp.

◆ canDecode() [2/2]

bool utility::sound::WAVDecoder::canDecode ( const std::string &  filePath) const
overridevirtual

Determines whether the specified file can be decoded.

Compatibility is determined from the file extension.

Parameters
filePathPath to the audio file.
Returns
true if the file extension is supported, false otherwise.

Implements utility::sound::AAudioDecoder.

Definition at line 44 of file wav_decoder.cpp.

◆ decode()

std::shared_ptr< utility::sound::AudioBuffer > utility::sound::WAVDecoder::decode ( std::shared_ptr< utility::File file)
overridevirtual

Decodes a WAV file into an AudioBuffer.

The encoded audio stream is decoded into PCM samples and uploaded to an AudioBuffer for playback.

Parameters
fileThe file containing WAV-encoded audio data.
Returns
A shared pointer to the decoded AudioBuffer, or nullptr if decoding fails.

Implements utility::sound::AAudioDecoder.

Definition at line 57 of file wav_decoder.cpp.


The documentation for this class was generated from the following files: