Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cWaveFormat Class Reference

#include <cWaveFormat.h>

Inheritance diagram for GrayLib::cWaveFormat:
Gray::cHeapBlock Gray::cMemBlock GrayLib::cWaveFormatN

Public Member Functions

 cWaveFormat ()
 
virtual ~cWaveFormat ()
 
void SetFormatNull ()
 
HRESULT SetFormat (const cWaveFormatEx *pForm)
 
HRESULT SetFormatBytes (const void *pFormData, size_t iSize)
 
HRESULT SetFormatEx (WORD wFormatTag, WORD nChannels=1, UINT nSamplesPerSec=8000, WORD wBitsPerSample=8, WORD wSizeEx=0)
 
HRESULT SetFormatPCM (WORD nChannels=1, UINT32 nSamplesPerSec=11025, WORD wBitsPerSample=8)
 
bool isValidFormat () const
 
virtual void ReCalc (void)
 
bool IsSameAs (const cWaveFormatEx *pForm) const
 
WAVE_BLOCKS_t CvtSrcToDstSize (WAVE_BLOCKS_t SrcSize, const cWaveFormatEx *pDstForm) const
 
UINT GetRateDiff (const cWaveFormatEx *pDstForm) const
 
const cWaveFormatExget_WF () const
 Get info about the format. More...
 
cWaveFormatExref_WF ()
 
 operator const cWaveFormatEx * () const
 
bool isPCM () const
 
size_t get_BlockSize () const
 
UINT get_SamplesPerSec () const
 
size_t get_BytesPerSec () const
 
WORD get_Channels () const
 
size_t get_SampleSize () const
 
UINT get_SampleRangeHalf (void) const
 
size_t CvtBlocksToBytes (WAVE_BLOCKS_t index) const
 Convert Samples, Time(ms), and Bytes to Blocks and back. More...
 
WAVE_BLOCKS_t CvtBytesToBlocks (size_t sizebytes) const
 
UINT CvtBlocksToSamples (WAVE_BLOCKS_t index) const
 
WAVE_BLOCKS_t CvtSamplesToBlocks (UINT dwSamples) const
 
TIMESYSD_t CvtBlocksTomSec (WAVE_BLOCKS_t index) const
 
WAVE_BLOCKS_t CvtmSecToBlocks (TIMESYSD_t mSec) const
 
bool ReAllocFormatSize (size_t iSize)
 
HRESULT WriteStream (cStreamOutput *pFile) const
 
HRESULT ReadStream (cStreamInput &strIn, size_t iSizeMax)
 
 UNITTEST_FRIEND (cWaveFormat)
 
- Public Member Functions inherited from Gray::cHeapBlock
 cHeapBlock () noexcept
 
 cHeapBlock (const THIS_t &ref)
 
 cHeapBlock (THIS_t &&ref) noexcept
 
 cHeapBlock (size_t nSize)
 
 cHeapBlock (const void *pDataCopy, size_t nSize)
 
 ~cHeapBlock ()
 
THIS_toperator= (const THIS_t &ref)
 
THIS_toperator= (THIS_t &&ref)
 
bool isValidRead () const noexcept
 
bool isCorrupt () const noexcept
 
size_t get_AllocSize () const
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const
 
void Free ()
 
void FreeSecure ()
 
void SetHeapBlock (void *pData, size_t nSize)
 
void DetachHeapBlock ()
 
bool Alloc (size_t nSize)
 
bool Alloc (const void *pData, size_t nSize)
 
bool ReAlloc (size_t nSize)
 
bool ReAlloc (const void *pData, size_t nSize)
 
bool ReAllocLazy (size_t iSizeNew)
 
bool SetCopy (const cHeapBlock &rSrc)
 
void * get_Data () const noexcept
 
BYTE * get_DataBytes () const noexcept
 
char * get_DataA () const noexcept
 
wchar_t * get_DataW () const noexcept
 
 operator void * () const noexcept
 
 operator BYTE * () const noexcept
 
 operator char * () const noexcept
 
- Public Member Functions inherited from Gray::cMemBlock
 cMemBlock () noexcept
 
 cMemBlock (const void *pData, size_t nSize) noexcept
 
 cMemBlock (const cMemBlock &block) noexcept
 
 cMemBlock (const cMemBlock *pBlock) noexcept
 
size_t get_DataSize () const noexcept
 
void * get_Data () const noexcept
 
BYTE * get_DataBytes () const noexcept
 
char * get_DataA () const noexcept
 
 operator const BYTE * () const noexcept
 
bool isValidPtr () const noexcept
 
bool IsValidIndex (size_t i) const noexcept
 
bool IsValidIndex2 (size_t i) const noexcept
 
bool IsValidPtr (const void *p) const noexcept
 
bool IsValidPtr2 (const void *p) const noexcept
 
bool IsZeros () const noexcept
 
bool IsEqualData (const void *pData, size_t nSize) const noexcept
 
bool IsEqualData (const cMemBlock *pData) const noexcept
 
bool IsEqualData (const cMemBlock &data) const noexcept
 
BYTE * GetOffset (size_t nOffset) const
 
const void * get_DataEnd () const noexcept
 
void put_DataPtr (void *pStart) noexcept
 
void put_Size (size_t nSize) noexcept
 
void SetBlock (void *pData, size_t nSize) noexcept
 
void SetEmptyBlock () noexcept
 
void InitZeros () noexcept
 
StrLen_t ConvertToString (char *pszDst, StrLen_t iDstSizeMax) const
 

Protected Member Functions

size_t GetStructSize (bool bMin) const
 

Additional Inherited Members

- Static Public Member Functions inherited from Gray::cMemBlock
static COMPARE_t __stdcall Compare (const void *pData1, size_t iLen1, const void *pData2, size_t iLen2)
 
- Protected Attributes inherited from Gray::cMemBlock
size_t m_nSize
 size_t of m_pData in bytes. May be determined at runtime. More...
 
void * m_pData
 

Detailed Description

Format description for wave audio data. Base container to contain cWaveFormatEx (with variable length data) size = sizeof(cWaveFormatEx) + cWaveFormatEx.cbSize (bytes)

Constructor & Destructor Documentation

◆ cWaveFormat()

GrayLib::cWaveFormat::cWaveFormat ( void  )

◆ ~cWaveFormat()

GrayLib::cWaveFormat::~cWaveFormat ( )
virtual

Member Function Documentation

◆ CvtBlocksToBytes()

size_t GrayLib::cWaveFormat::CvtBlocksToBytes ( WAVE_BLOCKS_t  index) const
inline

Convert Samples, Time(ms), and Bytes to Blocks and back.

◆ CvtBlocksTomSec()

TIMESYSD_t GrayLib::cWaveFormat::CvtBlocksTomSec ( WAVE_BLOCKS_t  index) const

return play time in milliseconds. Avoid overflow use: INT64

◆ CvtBlocksToSamples()

UINT GrayLib::cWaveFormat::CvtBlocksToSamples ( WAVE_BLOCKS_t  index) const

Convert blocks (iSize) to samples (time).

  • index = the number of blocks of sound data.
    Returns
    number of samples. (time)
    Note
    Given that we may have a variable rate compression scheme this could be just a guess as to max size !!!

◆ CvtBytesToBlocks()

WAVE_BLOCKS_t GrayLib::cWaveFormat::CvtBytesToBlocks ( size_t  sizebytes) const
inline

◆ CvtmSecToBlocks()

WAVE_BLOCKS_t GrayLib::cWaveFormat::CvtmSecToBlocks ( TIMESYSD_t  mSec) const

◆ CvtSamplesToBlocks()

WAVE_BLOCKS_t GrayLib::cWaveFormat::CvtSamplesToBlocks ( UINT  dwSamples) const

◆ CvtSrcToDstSize()

WAVE_BLOCKS_t GrayLib::cWaveFormat::CvtSrcToDstSize ( WAVE_BLOCKS_t  SrcSize,
const cWaveFormatEx pDstForm 
) const

What is the STORAGE SIZE in DEST BLOCKS, if the data is converted from pSrcForm to pDstForm. This may be a rate or format change.

  • nSrcSize = the source size in blocks. pDstForm = the Dest format.
    Returns
    The number of destination blocks required. For variable rate sample conversion this will be APPROXIMATE ! The blocks may be different byte sizes !!! Dif comp types.
    Note
    Different PCM frame storage type does not affect us here. same # blocks

◆ get_BlockSize()

size_t GrayLib::cWaveFormat::get_BlockSize ( ) const
inline

in bytes

◆ get_BytesPerSec()

size_t GrayLib::cWaveFormat::get_BytesPerSec ( ) const
inline

◆ get_Channels()

WORD GrayLib::cWaveFormat::get_Channels ( ) const
inline

◆ get_SampleRangeHalf()

UINT GrayLib::cWaveFormat::get_SampleRangeHalf ( void  ) const
inline

Get half the max dynamic range available

◆ get_SampleSize()

size_t GrayLib::cWaveFormat::get_SampleSize ( ) const
inline

In Bytes (only valid for PCM really.)

◆ get_SamplesPerSec()

UINT GrayLib::cWaveFormat::get_SamplesPerSec ( ) const
inline

◆ get_WF()

const cWaveFormatEx* GrayLib::cWaveFormat::get_WF ( ) const
inline

Get info about the format.

◆ GetRateDiff()

UINT GrayLib::cWaveFormat::GetRateDiff ( const cWaveFormatEx pDstForm) const
inline

Get a sample rate conversion factor.

◆ GetStructSize()

size_t GrayLib::cWaveFormat::GetStructSize ( bool  bMin) const
protected

Size needed for cWaveFormatEx structure.

◆ isPCM()

bool GrayLib::cWaveFormat::isPCM ( ) const
inline

◆ IsSameAs()

bool GrayLib::cWaveFormat::IsSameAs ( const cWaveFormatEx pForm) const

◆ isValidFormat()

bool GrayLib::cWaveFormat::isValidFormat ( void  ) const

Ia the format valid ? Get the data about any special compression form from the ACM.

Returns
true = OK.

◆ operator const cWaveFormatEx *()

GrayLib::cWaveFormat::operator const cWaveFormatEx * ( ) const
inline

◆ ReadStream()

HRESULT GrayLib::cWaveFormat::ReadStream ( cStreamInput strIn,
size_t  iSizeMax 
)

Expect the complete 'fmt' chunk to be at least as large as "PCMWAVEFORMAT" if there are extra parameters at the end, we'll ignore them

Note
ASSUME nothing is WAVEFORMAT alone sized ?

◆ ReAllocFormatSize()

bool GrayLib::cWaveFormat::ReAllocFormatSize ( size_t  iSize)

Create cWaveFormatEx of variable size.

  • iSizeNew >= sizeof(cWaveFormatEx)

◆ ReCalc()

void GrayLib::cWaveFormat::ReCalc ( void  )
virtual

Set derived values properly.

Reimplemented in GrayLib::cWaveFormatN.

◆ ref_WF()

cWaveFormatEx* GrayLib::cWaveFormat::ref_WF ( )
inline

◆ SetFormat()

HRESULT GrayLib::cWaveFormat::SetFormat ( const cWaveFormatEx pForm)

Copy the format info.

Returns
<0 = format is not valid.

◆ SetFormatBytes()

HRESULT GrayLib::cWaveFormat::SetFormatBytes ( const void *  pFormData,
size_t  iSize 
)

Copy the format data as just a blob of bytes. If the cbSize doesn't match iSize. prefer cbSize

  • iSize = full class size.

◆ SetFormatEx()

HRESULT GrayLib::cWaveFormat::SetFormatEx ( WORD  wFormatTag,
WORD  nChannels = 1,
UINT  nSamplesPerSec = 8000,
WORD  wBitsPerSample = 8,
WORD  wSizeEx = 0 
)

◆ SetFormatNull()

void GrayLib::cWaveFormat::SetFormatNull ( )

◆ SetFormatPCM()

HRESULT GrayLib::cWaveFormat::SetFormatPCM ( WORD  nChannels = 1,
UINT32  nSamplesPerSec = 11025,
WORD  wBitsPerSample = 8 
)

◆ UNITTEST_FRIEND()

GrayLib::cWaveFormat::UNITTEST_FRIEND ( cWaveFormat  )

◆ WriteStream()

HRESULT GrayLib::cWaveFormat::WriteStream ( cStreamOutput pFile) const

compliment ReadStream()


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