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::MP3Decoder Class Reference

Decoder implementation for MPEG Audio Layer III (MP3) files. More...

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

Inheritance diagram for utility::sound::MP3Decoder:
Collaboration diagram for utility::sound::MP3Decoder:

Public Member Functions

 MP3Decoder ()
 Creates an MP3 decoder instance.
 
 ~MP3Decoder () override
 Destroys the MP3 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 an MP3 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 MPEG Audio Layer III (MP3) files.

MP3Decoder uses the dr_mp3 library to decode MP3-encoded audio data into raw Pulse-Code Modulation (PCM) samples compatible with OpenAL.

Decoded audio samples are converted to 16-bit PCM format and uploaded to an AudioBuffer instance for playback.

Definition at line 40 of file mp3_decoder.hpp.

Constructor & Destructor Documentation

◆ MP3Decoder()

utility::sound::MP3Decoder::MP3Decoder ( )

Creates an MP3 decoder instance.

Definition at line 33 of file mp3_decoder.cpp.

Here is the call graph for this function:

◆ ~MP3Decoder()

utility::sound::MP3Decoder::~MP3Decoder ( )
override

Destroys the MP3 decoder instance.

Definition at line 38 of file mp3_decoder.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ canDecode() [1/2]

bool utility::sound::MP3Decoder::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 50 of file mp3_decoder.cpp.

◆ canDecode() [2/2]

bool utility::sound::MP3Decoder::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 43 of file mp3_decoder.cpp.

◆ decode()

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

Decodes an MP3 file into an AudioBuffer.

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

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

Implements utility::sound::AAudioDecoder.

Definition at line 56 of file mp3_decoder.cpp.


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