Christoph Wintersteiger
Christoph Wintersteiger

Reputation: 8402

WAVEFORMATEX parameters for DSD64

The Windows WASAPI does not provide a function to list all supported audio formats of an audio device. Instead, one has to provide a WAVEFORMATEX structure with the desired format parameters and use IsFormatSupported to check whether that particular format is supported. There is support for IEC61937 DST/DSD, but I can not figure out how to set the format parameters for e.g. DSD64, and it never provides a closest matching format either. What's wrong with these parameters?

WAVEFORMATEXTENSIBLE_IEC61937 format;
memset(&format, 0, sizeof(WAVEFORMATEXTENSIBLE_IEC61937));
format.FormatExt.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
format.FormatExt.Format.nChannels = 2;
format.FormatExt.Format.nSamplesPerSec = 44100 * 64;
format.FormatExt.Format.wBitsPerSample = 1;
format.FormatExt.Format.nBlockAlign = format.FormatExt.Format.nChannels * 64;
format.FormatExt.Format.nAvgBytesPerSec = format.FormatExt.Format.nChannels * format.FormatExt.Format.nSamplesPerSec / 8;
format.FormatExt.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE_IEC61937) - sizeof(WAVEFORMATEX);
format.FormatExt.Samples.wValidBitsPerSample = 1;
format.FormatExt.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
format.FormatExt.SubFormat = KSDATAFORMAT_SUBTYPE_IEC61937_DST;
format.dwEncodedSamplesPerSec = 0;
format.dwEncodedChannelCount = 2;
format.dwAverageBytesPerSec = 0;

Upvotes: 2

Views: 83

Answers (1)

Gordon Childs
Gordon Childs

Reputation: 36169

I think dwEncodedSamplesPerSec should be 44100.

The IEC-61937 format doc says:

The dwEncodedSamplesPerSec, dwEncodedChannelCount, and dwAverageBytesPerSec members of WAVEFORMATEXTENSIBLE_IEC61937 describe the sampling rate, number of channels, and bit rate in bytes of the stream of the audio stream after it has been decoded.

ksmedia.h, the header file, says the same thing, but adds that the byte rate "can be zero".

Upvotes: 0

Related Questions