CComHeapPtr< WAVEFORMATEX> pDeviceFormat;
pAudioClient-> GetMixFormat ( & pDeviceFormat) ;
constexpr int REFTIMES_PER_SEC = 10000000 ;
constexpr int REFTIMES_PER_MILLISEC = 10000 ;
// Microsoft
if (pDeviceFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
printf("WAV format : Microsoft \n");
WAVEFORMATEX* pWavFormatEx = pDeviceFormat;
PWAVEFORMATEXTENSIBLE pWavFormatExtensible = reinterpret_cast<PWAVEFORMATEXTENSIBLE>(pWavFormatEx);
switch (pDeviceFormat->wFormatTag)
{
case WAVE_FORMAT_IEEE_FLOAT:
{
pWavFormatEx->wBitsPerSample = 16;
pWavFormatEx->nSamplesPerSec = 48000;
pWavFormatEx->nChannels = 2;
pWavFormatEx->wFormatTag = WAVE_FORMAT_PCM;
pWavFormatEx->nBlockAlign = pWavFormatEx->nChannels * pWavFormatEx->wBitsPerSample / 8;
pWavFormatEx->nAvgBytesPerSec = pWavFormatEx->nBlockAlign * pWavFormatEx->nSamplesPerSec;
break;
}
case WAVE_FORMAT_EXTENSIBLE:
{
// naked scope for case-local variable
if (IsEqualGUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, pWavFormatExtensible->SubFormat))
{
pWavFormatExtensible->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
pWavFormatExtensible->Samples.wValidBitsPerSample = 16;
pWavFormatEx->wBitsPerSample = 16;
pWavFormatEx->nSamplesPerSec = 48000;
pWavFormatEx->nChannels = 2;
pWavFormatEx->wFormatTag = WAVE_FORMAT_PCM;
pWavFormatEx->nBlockAlign = pWavFormatEx->nChannels * pWavFormatEx->wBitsPerSample / 8;
pWavFormatEx->nAvgBytesPerSec = pWavFormatEx->nBlockAlign * pWavFormatEx->nSamplesPerSec;
}
else
{
return false;
}
break;
}
}
}