DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
include/waveformatex.h
00001 
00002 #ifndef __ISP_UTILS_V4_WIN_WAVEFORMATEX_H
00003 #define __ISP_UTILS_V4_WIN_WAVEFORMATEX_H
00004 
00005 #include <stdint.h>
00006 
00007 #include "informational.h"
00008 #include "guid.h"       /* <- need windows_GUID definition below */
00009 
00010 #if defined(_MSC_VER)
00011 # pragma pack(push,1)
00012 #endif
00013 
00014 /* [doc] windows_WAVEFORMATOLD
00015  *
00016  * Packed portable representation of the Microsoft Windows WAVEFORMAT
00017  * structure. In the Microsoft SDK this would be "WAVEFORMAT". The
00018  * wBitsPerSample field is missing. I don't know why Microsoft would
00019  * define other than perhaps being the earlier form of WAVEFORMAT that
00020  * was in use when they made the Windows 3.0 Multimedia Extensions.
00021  *
00022  * Note that if you actually try to make a WAV file with this variant
00023  * in the 'fmt' chunk almost nobody will read it properly, except
00024  * FFMPEG, who will always assume 8-bit signed PCM. Such files will
00025  * also cause the various multimedia components in Windows 98 to
00026  * crash!
00027  */
00028 typedef struct {                                                /* (sizeof) (offset hex) (offset dec) */
00029         uint16_t _Little_Endian_        wFormatTag;             /* (2)  +0x00 +0 */
00030         uint16_t _Little_Endian_        nChannels;              /* (2)  +0x02 +2 */
00031         uint32_t _Little_Endian_        nSamplesPerSec;         /* (4)  +0x04 +4 */
00032         uint32_t _Little_Endian_        nAvgBytesPerSec;        /* (4)  +0x08 +8 */
00033         uint16_t _Little_Endian_        nBlockAlign;            /* (2)  +0x0C +12 */
00034 } GCC_ATTRIBUTE(packed) windows_WAVEFORMATOLD;          /* (14) =0x0E =14 */
00035 #define windows_WAVEFORMATOLD_size (14)
00036 
00037 /* [doc] windows_WAVEFORMAT
00038  *
00039  * Packed portable representation of the Microsoft Windows WAVEFORMAT
00040  * structure. Unlike the Microsoft SDK version this struct also includes
00041  * the wBitsPerSample structure member. If you write plain PCM WAV files
00042  * this is the format you would write into the 'fmt' chunk. Essentially
00043  * WAVEFORMATEX without the cbSize.
00044  */
00045 typedef struct {                                                /* (sizeof) (offset hex) (offset dec) */
00046         uint16_t _Little_Endian_        wFormatTag;             /* (2)  +0x00 +0 */
00047         uint16_t _Little_Endian_        nChannels;              /* (2)  +0x02 +2 */
00048         uint32_t _Little_Endian_        nSamplesPerSec;         /* (4)  +0x04 +4 */
00049         uint32_t _Little_Endian_        nAvgBytesPerSec;        /* (4)  +0x08 +8 */
00050         uint16_t _Little_Endian_        nBlockAlign;            /* (2)  +0x0C +12 */
00051         uint16_t _Little_Endian_        wBitsPerSample;         /* (2)  +0x0E +14 */
00052 } GCC_ATTRIBUTE(packed) windows_WAVEFORMAT;                     /* (16) +0x10 +16 */
00053 #define windows_WAVEFORMAT_size (16)
00054 
00055 /* [doc] windows_WAVEFORMATEX
00056  *
00057  * Packed portable representation of the Microsoft Windows WAVEFORMATEX
00058  * structure. This is the most common format because it can accomodate
00059  * almost every non-PCM WAVE codec. WAVEFORMATEXTENSIBLE builds on this
00060  * for additional codecs that don't have a 16-bit wFormatTag registered.
00061  */
00062 typedef struct {                                                /* (sizeof) (offset hex) (offset dec) */
00063         uint16_t _Little_Endian_        wFormatTag;             /* (2)  +0x00 +0 */
00064         uint16_t _Little_Endian_        nChannels;              /* (2)  +0x02 +2 */
00065         uint32_t _Little_Endian_        nSamplesPerSec;         /* (4)  +0x04 +4 */
00066         uint32_t _Little_Endian_        nAvgBytesPerSec;        /* (4)  +0x08 +8 */
00067         uint16_t _Little_Endian_        nBlockAlign;            /* (2)  +0x0C +12 */
00068         uint16_t _Little_Endian_        wBitsPerSample;         /* (2)  +0x0E +14 */
00069         uint16_t _Little_Endian_        cbSize;                 /* (2)  +0x10 +16 */
00070 } GCC_ATTRIBUTE(packed) windows_WAVEFORMATEX;                   /* (18) =0x12 =18 */
00071 #define windows_WAVEFORMATEX_size (18)
00072 
00073 static const windows_WAVEFORMATEX WINDOWS_WAVEFORMATEX_INIT = {
00074         0,
00075         0,
00076         0,
00077         0,
00078         0,
00079         0,
00080         0
00081 };
00082 
00083 /* [doc] windows_ADPCMWAVEFORMAT
00084  *
00085  * Packed portable representation of the Microsoft Windows ADPCMWAVEFORMAT
00086  * structure for WAVE_FORMAT_MS_ADPCM. Microsoft's original definition
00087  * implies that wNumCoef could be anything and define the last member as
00088  * aCoef[]. However, every MS ADPCM WAV I've ever found or made has
00089  * wNumCoef == 7, so it's defined that way here.
00090  */
00091 typedef struct {                                                /* (sizeof) (offset hex) (offset dec) */
00092         windows_WAVEFORMATEX            wfx;                    /* (18) +0x00 +0 */
00093         uint16_t _Little_Endian_        wSamplesPerBlock;       /* (2)  +0x12 +18 */
00094         uint16_t _Little_Endian_        wNumCoef;               /* (2)  +0x14 +20 */
00095         uint16_t _Little_Endian_        aCoef[7*2];             /* (28) +0x16 +22 */ /* NTS: This array is wNumCoef*2 large, for MS-ADPCM wNumCoef == 7 */
00096 } GCC_ATTRIBUTE(packed) windows_ADPCMWAVEFORMAT;                /* (50) =0x42 =50 */
00097 #define windows_ADPCMWAVEFORMAT_size (50)
00098 
00099 /* [doc] windows_IMAADPCMWAVEFORMAT
00100  *
00101  * Microsoft's implementation of IMA-ADPCM 4-bit compression
00102  */
00103 typedef struct ima_adpcmwaveformat_tag {                        /* (sizeof) (offset hex) (offset dec) */
00104         windows_WAVEFORMATEX            wfx;                    /* (18) +0x00 +0 */
00105         uint16_t _Little_Endian_        wSamplesPerBlock;       /* (2)  +0x12 +18 */
00106 } GCC_ATTRIBUTE(packed) windows_IMAADPCMWAVEFORMAT;             /* (20) =0x14 +20 */
00107 #define windows_IMAADPCMWAVEFORMAT_size (20)
00108 
00109 /* [doc] windows_TRUESPEECHWAVEFORMAT
00110  *
00111  */
00112 typedef struct truespeechwaveformat_tag {                       /* (sizeof) (offset hex) (offset dec) */
00113         windows_WAVEFORMATEX            wfx;                    /* (18) +0x00 +0 */
00114         uint16_t _Little_Endian_        wRevision;              /* (2)  +0x12 +18 */
00115         uint16_t _Little_Endian_        nSamplesPerBlock;       /* (2)  +0x14 +20 */
00116         uint8_t                         abReserved[28];         /* (28) +0x16 +22 */
00117 } GCC_ATTRIBUTE(packed) windows_TRUESPEECHWAVEFORMAT;           /* (50) =0x42 =50 */
00118 #define windows_TRUESPEECHWAVEFORMAT_size (50)
00119 
00120 /* [doc] windows_GSM610WAVEFORMAT
00121  *
00122  */
00123 typedef struct gsm610waveformat_tag {                           /* (sizeof) (offset hex) (offset dec) */
00124         windows_WAVEFORMATEX            wfx;                    /* (18) +0x00 +0 */
00125         uint16_t _Little_Endian_        wSamplesPerBlock;       /* (2)  +0x12 +18 */
00126 } GCC_ATTRIBUTE(packed) windows_GSM610WAVEFORMAT;               /* (20) =0x14 =20 */
00127 #define windows_GSM610WAVEFORMAT_size (20)
00128 
00129 /* [doc] windows_WAVEFORMATEXTENSIBLE
00130  *
00131  * Packed portable representation of the Microsoft Windows WAVEFORMATEXTENSIBLE
00132  * structure. This is the latest evolution of the WAVEFORMATEX structure
00133  * that allows Windows to represent a wider variety of formats, extend codecs
00134  * beyond the original wFormatTag registry, and support up to 32 channel audio
00135  * with defined channel mapping. Microsoft also expects you to use this for
00136  * 24-bit and 32-bit PCM even though you *can* define WAVEFORMAT structures
00137  * for 24/32-bit as well (most will play it except Windows Media Player).
00138  */
00139 typedef struct {                                                        /* (sizeof) (offset hex) (offset dec) */
00140         windows_WAVEFORMATEX                    Format;                 /* (18) +0x00 +0 */
00141         union { /* Ooookay Microsoft how do I derive meaning from THIS now? */
00142                 uint16_t _Little_Endian_        wValidBitsPerSample;    /* <- if it's PCM */
00143                 uint16_t _Little_Endian_        wSamplesPerBlock;       /* <- if it's not PCM, and compressed */
00144                 uint16_t _Little_Endian_        wReserved;              /* <- if ??? */
00145         } Samples;                                                      /* (2)  +0x12 +18 */
00146         uint32_t _Little_Endian_                dwChannelMask;          /* (4)  +0x14 +20 */
00147         windows_GUID                            SubFormat;              /* (16) +0x18 +24 */
00148 } GCC_ATTRIBUTE(packed) windows_WAVEFORMATEXTENSIBLE;                   /* (40) =0x28 =40 */
00149 #define windows_WAVEFORMATEXTENSIBLE_size (40)
00150 
00151 #if defined(_MSC_VER)
00152 # pragma pack(pop)
00153 #endif
00154 
00155 #endif /* __ISP_UTILS_V4_WIN_WAVEFORMATEX_H */
00156