6 #ifndef _INC_cWaveFormat_H
7 #define _INC_cWaveFormat_H
19 enum WAVE_FORMAT_TYPE_
23 WAVE_FORMAT_ADPCM = 2,
25 WAVE_FORMAT_MULAW = 7,
26 WAVE_FORMAT_DIGIADPCM = 0x0036,
27 WAVE_FORMAT_MPEG = 0x0050,
28 WAVE_FORMAT_MPEGLAYER3 = 0x0055,
50 #if ! defined(_WAVEFORMATEX_) && ( ! defined(_WIN32) || (WINVER < 0x0400))
51 #define _WAVEFORMATEX_
83 void Init(WORD wFormatTag2, WORD nChannels2 = 1, UINT nSamplesPerSec2 = 8000, WORD wBitsPerSample2 = 8, WORD wSizeEx2 = 0) noexcept
86 this->wFormatTag = wFormatTag2;
87 this->nChannels = nChannels2;
88 this->nSamplesPerSec = nSamplesPerSec2;
89 this->wBitsPerSample = wBitsPerSample2;
90 this->nAvgBytesPerSec = 0;
91 this->nBlockAlign = 0;
92 this->cbSize = wSizeEx2;
97 return(this->wFormatTag == WAVE_FORMAT_PCM);
101 return(this->nChannels);
106 return(this->nBlockAlign);
110 return(this->nSamplesPerSec);
114 return(this->nAvgBytesPerSec);
120 return((this->wBitsPerSample == 8) ? 1 : 2);
126 ASSERT(this->wBitsPerSample);
127 return((1 << (this->wBitsPerSample - 1)) - 1);
133 switch (this->wFormatTag)
137 case WAVE_FORMAT_PCM:
147 bool isValidFormat()
const;
160 size_t GetStructSize(
bool bMin)
const;
166 void SetFormatNull();
168 HRESULT SetFormatBytes(
const void* pFormData,
size_t iSize);
169 HRESULT SetFormatEx(WORD wFormatTag, WORD nChannels = 1, UINT nSamplesPerSec = 8000, WORD wBitsPerSample = 8, WORD wSizeEx = 0);
170 HRESULT SetFormatPCM(WORD nChannels = 1, UINT32 nSamplesPerSec = 11025, WORD wBitsPerSample = 8);
172 bool isValidFormat()
const;
173 virtual void ReCalc(
void);
199 if (get_WF() ==
nullptr)
201 return get_WF()->isPCM();
206 if (get_WF() ==
nullptr)
208 return(get_WF()->get_BlockSize());
212 if (get_WF() ==
nullptr)
214 return(get_WF()->get_SamplesPerSec());
218 if (get_WF() ==
nullptr)
220 return(get_WF()->get_BytesPerSec());
224 if (get_WF() ==
nullptr)
226 return(get_WF()->get_Channels());
231 if (get_WF() ==
nullptr)
233 return(get_WF()->get_SampleSize());
238 if (get_WF() ==
nullptr)
240 return(get_WF()->get_SampleRangeHalf());
247 return(
index * get_BlockSize());
261 bool ReAllocFormatSize(
size_t iSize);
291 virtual void ReCalc(
void);
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cStream.h:126
UINT WAVE_BLOCKS_t
Index in blocks (not bytes or samples) of current wave format in sound buffer.
Definition: cWaveFormat.h:67
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
uint16 index
Definition: sample3.cpp:29
static void Zero(void *pData, size_t nSizeBlock) noexcept
Definition: cMem.h:100