CUGL 2.0
Cornell University Game Library
Public Member Functions | Protected Attributes | List of all members
cugl::audio::ADPCMDecoder Class Referenceabstract

#include <CUWAVDecoder.h>

Public Member Functions

 ADPCMDecoder ()
 
virtual ~ADPCMDecoder ()
 
virtual bool init (WaveFMT *format)
 
Uint64 getFrames (Uint64 bytes) const
 
Uint32 getBlockSize () const
 
virtual Sint32 read (SDL_RWops *source, Uint8 *buffer)=0
 

Protected Attributes

WaveFMT _wavefmt
 
Uint8 * _blkbuffer
 
Uint16 _blocksize
 

Detailed Description

This class represents an internal decoder for ADPCM encoded WAV files.

This decoder is a proxy decoder for ADPCM files, which are compressed. This is the abstract base class for either MS or IMA decoding. This class is for internal use and should never be instantiated by the user.

Constructor & Destructor Documentation

◆ ADPCMDecoder()

cugl::audio::ADPCMDecoder::ADPCMDecoder ( )
inline

Creates an initialized decoder proxy

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an asset on the heap, use one of the static constructors instead.

◆ ~ADPCMDecoder()

virtual cugl::audio::ADPCMDecoder::~ADPCMDecoder ( )
virtual

Deletes this decoder proxy, disposing of all resources.

Member Function Documentation

◆ getBlockSize()

Uint32 cugl::audio::ADPCMDecoder::getBlockSize ( ) const
inline

Returns the block size of a single page

This is the size of buffer for the read methd.

Returns
the block size of a single page

◆ getFrames()

Uint64 cugl::audio::ADPCMDecoder::getFrames ( Uint64  bytes) const
inline

Returns the number of frames to decompress from the given number of bytes

ADPCM decoding expands the number of frames that a group of bytes can produce. This method allows the main decoder to align with the proxy.

Parameters
bytesThe number of bytes to convert
Returns
the number of frames to decompress from the given number of bytes

◆ init()

virtual bool cugl::audio::ADPCMDecoder::init ( WaveFMT format)
virtual

Initializes a new decoder proxy from the given WAV header.

This is an abstract method that depends on the specific ADPCM encoding. This method will fail if the header is not compatible with the appropriate encoding.

Parameters
formatThe WAV header
Returns
true if the decoder proxy was initialized successfully

◆ read()

virtual Sint32 cugl::audio::ADPCMDecoder::read ( SDL_RWops *  source,
Uint8 *  buffer 
)
pure virtual

Reads a single page from the given file.

The buffer should be able to store block size * channels * 2 bytes of data (the latter 2 representing sizeof(Sint16) ). If the read fails, this method returns -1.

Parameters
sourceThe source file
bufferThe buffer to store the decoded data
Returns
the number of bytes read (or -1 on error)

Member Data Documentation

◆ _blkbuffer

Uint8* cugl::audio::ADPCMDecoder::_blkbuffer
protected

The buffer size for AD PCM decoding

◆ _blocksize

Uint16 cugl::audio::ADPCMDecoder::_blocksize
protected

The internal buffer for AD PCM decoding

◆ _wavefmt

WaveFMT cugl::audio::ADPCMDecoder::_wavefmt
protected

The RIFF header


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