122 lines
2.8 KiB
C++
122 lines
2.8 KiB
C++
#ifndef _SAMPLE_FMTCHNKADPCM_HPP_
|
|
#define _SAMPLE_FMTCHNKADPCM_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_MMREG_HPP_
|
|
#include <common/mmreg.hpp>
|
|
#endif
|
|
#ifndef _COMMON_ARRAY_HPP_
|
|
#include <common/array.hpp>
|
|
#endif
|
|
|
|
class FormatChunkADPCM : public Array<ADPCMCOEFSET>
|
|
{
|
|
public:
|
|
FormatChunkADPCM();
|
|
virtual ~FormatChunkADPCM();
|
|
bool write(MemFile &memFile)const;
|
|
bool read(FileHandle &handle);
|
|
WORD extraSize(void)const;
|
|
void extraSize(WORD extraSize);
|
|
WORD samplesPerBlock(void)const;
|
|
void samplesPerBlock(WORD samplesPerBlock);
|
|
WORD numCoef(void)const;
|
|
void numCoef(WORD numCoef);
|
|
String toString(void)const;
|
|
private:
|
|
WORD mExtraSize;
|
|
WORD mSamplesPerBlock;
|
|
};
|
|
|
|
inline
|
|
FormatChunkADPCM::FormatChunkADPCM()
|
|
: mExtraSize(0), mSamplesPerBlock(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
FormatChunkADPCM::~FormatChunkADPCM()
|
|
{
|
|
}
|
|
|
|
inline
|
|
bool FormatChunkADPCM::write(MemFile &memFile)const
|
|
{
|
|
WORD numCoefs;
|
|
if(!memFile.write((char*)&mExtraSize,sizeof(WORD)))return false;
|
|
if(!memFile.write((char*)&mSamplesPerBlock,sizeof(WORD)))return false;
|
|
numCoefs=size();
|
|
if(!memFile.write((char*)&numCoefs,sizeof(WORD)))return false;
|
|
if(!memFile.write((char*)&(((Array<ADPCMCOEFSET>&)*this).operator[](0)),sizeBytes()))return false;
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool FormatChunkADPCM::read(FileHandle &handle)
|
|
{
|
|
WORD numCoef;
|
|
|
|
if(!handle.read((BYTE*)&mExtraSize,sizeof(WORD)))return false;
|
|
if(!handle.read((BYTE*)&mSamplesPerBlock,sizeof(WORD)))return false;
|
|
if(!handle.read((BYTE*)&numCoef,sizeof(WORD)))return false;
|
|
size(numCoef);
|
|
if(!handle.read((BYTE*)&(((Array<ADPCMCOEFSET>&)*this).operator[](0)),sizeBytes()))return false;
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
WORD FormatChunkADPCM::extraSize(void)const
|
|
{
|
|
return mExtraSize;
|
|
}
|
|
|
|
inline
|
|
void FormatChunkADPCM::extraSize(WORD extraSize)
|
|
{
|
|
mExtraSize=extraSize;
|
|
}
|
|
|
|
inline
|
|
WORD FormatChunkADPCM::samplesPerBlock(void)const
|
|
{
|
|
return mSamplesPerBlock;
|
|
}
|
|
|
|
inline
|
|
void FormatChunkADPCM::samplesPerBlock(WORD samplesPerBlock)
|
|
{
|
|
mSamplesPerBlock=samplesPerBlock;
|
|
}
|
|
|
|
inline
|
|
WORD FormatChunkADPCM::numCoef(void)const
|
|
{
|
|
return size();
|
|
}
|
|
|
|
inline
|
|
void FormatChunkADPCM::numCoef(WORD numCoef)
|
|
{
|
|
size(numCoef);
|
|
}
|
|
|
|
inline
|
|
String FormatChunkADPCM::toString(void)const
|
|
{
|
|
String strChunk="<FORMATCHUNKADPCM>";
|
|
strChunk+=String(" ExtraSize=")+String().fromInt(mExtraSize).quotes();
|
|
strChunk+=String(" SamplesPerBlock=")+String().fromInt(mSamplesPerBlock).quotes();
|
|
strChunk+=String(" NumCoefs=")+String().fromInt(size()).quotes();
|
|
for(int index=0;index<size();index++)
|
|
{
|
|
strChunk+="<COEF>";
|
|
strChunk+=String(" Coef1=")+String().fromInt(((Array<ADPCMCOEFSET>&)*this).operator[](index).iCoef1).quotes();
|
|
strChunk+=String(" Coef2=")+String().fromInt(((Array<ADPCMCOEFSET>&)*this).operator[](index).iCoef2).quotes();
|
|
strChunk+="</COEF>";
|
|
}
|
|
strChunk+="</FORMATCHUNKADPCM>";
|
|
return strChunk;
|
|
}
|
|
#endif
|