WaveFormatExtensible (Structures)
Last changed: -84.150.145.180

.
Summary
TODO - a short description

C# Definition:

Definition Untested!!

[StructLayout(LayoutKind.Sequential)]
public class WaveFormatExtensible
{
    public ushort wFormatTag;
    public ushort nChannels;
    public uint nSamplesPerSec;
    public uint nAvgBytesPerSec;
    public ushort nBlockAlign;
    public ushort wBitsPerSample;
    public ushort cbSize;

    public ushort wValidBitsPerSample;
    public uint dwChannelMask;
    public Guid SubFormat;

    public WaveFormatExtensible(uint rate, uint bits, uint channels)
    {
        wFormatTag = 0xFFFE; //WAVE_FORMAT_EXTENSIBLE
        nChannels = (ushort)channels;
        nSamplesPerSec = rate;
        wBitsPerSample = (ushort)bits;
        cbSize = 22;

        nBlockAlign = (ushort)(channels * (bits / 8));
        nAvgBytesPerSec = nSamplesPerSec * nBlockAlign;

        wValidBitsPerSample = wBitsPerSample;
        dwChannelMask = 3; //Stereo
        SubFormat = new Guid("00000001-0000-0010-8000-00aa00389b71");
    }
}

VB Definition:

<StructLayout(LayoutKind.Sequential, pack:=1)> Public Structure WAVEFORMATEXTENSIBLE
    Dim Format As WAVEFORMATEX
    'union {
    'WORD  wValidBitsPerSample;
    'WORD  wSamplesPerBlock;
    'WORD  wReserved;
    ';} Samples;
    Dim wUnionSamples As UInt16
    Dim dwChannelMask As UInteger
    Dim SubFormat As Guid
End Structure

User-Defined Field Types:

None.

Notes:

VB - wUnionSamples replaces the union of 3 values commented out above it as a union is not possible in VB - just put the value into wUnionSamples for whichever of the wValidBitsPerSample/wSamplesPerBlock/wReserved required based on the SubFormat.

Documentation