Initial
This commit is contained in:
176
sample/FmtChnk.hpp
Normal file
176
sample/FmtChnk.hpp
Normal file
@@ -0,0 +1,176 @@
|
||||
#ifndef _SAMPLE_FORMATCHUNK_HPP_
|
||||
#define _SAMPLE_FORMATCHUNK_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_MMSYSTEM_HPP_
|
||||
#include <common/mmsystem.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_MEMFILE_HPP_
|
||||
#include <common/memfile.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_OPENFILE_HPP_
|
||||
#include <common/openfile.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILEIO_HPP_
|
||||
#include <common/fileio.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
#ifndef _SAMPLE_CHUNKID_HPP_
|
||||
#include <sample/chunkid.hpp>
|
||||
#endif
|
||||
#ifndef _SAMPLE_FMTCHNKADPCM_HPP_
|
||||
#include <sample/FmtChnkADPCM.hpp>
|
||||
#endif
|
||||
|
||||
class FormatChunk
|
||||
{
|
||||
public:
|
||||
enum {WaveFormatPCM=0x01,NumChannels=0x01,BlockAlign=0x01,BitsPerSample=0x08};
|
||||
FormatChunk(void);
|
||||
FormatChunk(const FormatChunk &someFormatChunk);
|
||||
virtual ~FormatChunk();
|
||||
bool write(MemFile &memFile);
|
||||
bool read(FileHandle &handle);
|
||||
FormatChunk &operator=(const FormatChunk &someFormatChunk);
|
||||
WORD formatTag(void)const;
|
||||
void formatTag(WORD formatTag);
|
||||
WORD channels(void)const;
|
||||
void channels(WORD channels);
|
||||
DWORD samplesPerSecond(void)const;
|
||||
void samplesPerSecond(DWORD samplesPerSecond);
|
||||
DWORD averageBytesPerSecond(void)const;
|
||||
void averageBytesPerSecond(DWORD averageBytesPerSecond);
|
||||
WORD blockAlign(void)const;
|
||||
void blockAlign(WORD blockAlign);
|
||||
WORD bitsPerSample(void)const;
|
||||
void bitsPerSample(WORD bitsPerSample);
|
||||
DWORD size(void)const;
|
||||
String toString(void)const;
|
||||
private:
|
||||
void initChunk(void);
|
||||
ChunkID mChunkID; // 4 bytes
|
||||
DWORD mSize; // 4 bytes
|
||||
WORD mFormatTag; // 2 bytes
|
||||
WORD mChannels; // 2 bytes
|
||||
DWORD mSamplesPerSecond; // 4 bytes
|
||||
DWORD mAvgBytesPerSecond; // 4 bytes
|
||||
WORD mBlockAlign; // 2 bytes
|
||||
WORD mBitsPerSample; // 2 bytes
|
||||
Array<BYTE> mExtraInfo; // extra chunk information
|
||||
SmartPointer<FormatChunkADPCM> mFormatChunkADPCM;
|
||||
};
|
||||
|
||||
inline
|
||||
FormatChunk::FormatChunk(void)
|
||||
: mSize(0), mFormatTag(WaveFormatPCM), mChannels(NumChannels), mSamplesPerSecond(0),
|
||||
mAvgBytesPerSecond(0), mBlockAlign(BlockAlign), mBitsPerSample(0)
|
||||
{
|
||||
initChunk();
|
||||
}
|
||||
|
||||
inline
|
||||
FormatChunk::FormatChunk(const FormatChunk &someFormatChunk)
|
||||
: mSize(0), mFormatTag(WaveFormatPCM), mChannels(NumChannels), mSamplesPerSecond(0),
|
||||
mAvgBytesPerSecond(0), mBlockAlign(BlockAlign), mBitsPerSample(0)
|
||||
{
|
||||
initChunk();
|
||||
*this=someFormatChunk;
|
||||
}
|
||||
|
||||
inline
|
||||
FormatChunk::~FormatChunk()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FormatChunk::formatTag(void)const
|
||||
{
|
||||
return mFormatTag;
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::formatTag(WORD formatTag)
|
||||
{
|
||||
mFormatTag=formatTag;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FormatChunk::channels(void)const
|
||||
{
|
||||
return mChannels;
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::channels(WORD channels)
|
||||
{
|
||||
mChannels=channels;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FormatChunk::samplesPerSecond(void)const
|
||||
{
|
||||
return mSamplesPerSecond;
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::samplesPerSecond(DWORD samplesPerSecond)
|
||||
{
|
||||
mSamplesPerSecond=samplesPerSecond;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FormatChunk::averageBytesPerSecond(void)const
|
||||
{
|
||||
return mAvgBytesPerSecond;
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::averageBytesPerSecond(DWORD averageBytesPerSecond)
|
||||
{
|
||||
mAvgBytesPerSecond=averageBytesPerSecond;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FormatChunk::blockAlign(void)const
|
||||
{
|
||||
return mBlockAlign;
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::blockAlign(WORD blockAlign)
|
||||
{
|
||||
mBlockAlign=blockAlign;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FormatChunk::bitsPerSample(void)const
|
||||
{
|
||||
return mBitsPerSample;
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::bitsPerSample(WORD bitsPerSample)
|
||||
{
|
||||
mBitsPerSample=bitsPerSample;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FormatChunk::size(void)const
|
||||
{
|
||||
return mSize+mChunkID.size();
|
||||
}
|
||||
|
||||
inline
|
||||
void FormatChunk::initChunk(void)
|
||||
{
|
||||
mChunkID=String("fmt ");
|
||||
mSize=(mChunkID.size()+sizeof(mSize)+sizeof(mFormatTag)+sizeof(mChannels)+sizeof(mSamplesPerSecond)+
|
||||
sizeof(mAvgBytesPerSecond)+sizeof(mBlockAlign)+sizeof(mBitsPerSample))-(mChunkID.size()+sizeof(mSize));
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user