Subversion Repositories Games.Chess Giants

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/***************************************************************************
2
 *
3
 *  Copyright (c) Microsoft Corporation.  All rights reserved.
4
 *
5
 *  File:     audiodefs.h
6
 *  Content:  Basic constants and data types for audio work.
7
 *
8
 *  Remarks:  This header file defines all of the audio format constants and
9
 *            structures required for XAudio2 and XACT work.  Providing these
10
 *            in a single location avoids certain dependency problems in the
11
 *            legacy audio headers (mmreg.h, mmsystem.h, ksmedia.h).
12
 *
13
 *            NOTE: Including the legacy headers after this one may cause a
14
 *            compilation error, because they define some of the same types
15
 *            defined here without preprocessor guards to avoid multiple
16
 *            definitions.  If a source file needs one of the old headers,
17
 *            it must include it before including audiodefs.h.
18
 *
19
 ***************************************************************************/
20
 
21
#ifndef __AUDIODEFS_INCLUDED__
22
#define __AUDIODEFS_INCLUDED__
23
 
24
#include <windef.h>  // For WORD, DWORD, etc.
25
 
26
#pragma pack(push, 1)  // Pack structures to 1-byte boundaries
27
 
28
 
29
/**************************************************************************
30
 *
31
 *  WAVEFORMATEX: Base structure for many audio formats.  Format-specific
32
 *  extensions can be defined for particular formats by using a non-zero
33
 *  cbSize value and adding extra fields to the end of this structure.
34
 *
35
 ***************************************************************************/
36
 
37
#ifndef _WAVEFORMATEX_
38
 
39
    #define _WAVEFORMATEX_
40
    typedef struct tWAVEFORMATEX
41
    {
42
        WORD wFormatTag;        // Integer identifier of the format
43
        WORD nChannels;         // Number of audio channels
44
        DWORD nSamplesPerSec;   // Audio sample rate
45
        DWORD nAvgBytesPerSec;  // Bytes per second (possibly approximate)
46
        WORD nBlockAlign;       // Size in bytes of a sample block (all channels)
47
        WORD wBitsPerSample;    // Size in bits of a single per-channel sample
48
        WORD cbSize;            // Bytes of extra data appended to this struct
49
    } WAVEFORMATEX;
50
 
51
#endif
52
 
53
// Defining pointer types outside of the #if block to make sure they are
54
// defined even if mmreg.h or mmsystem.h is #included before this file
55
 
56
typedef WAVEFORMATEX *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
57
typedef const WAVEFORMATEX *PCWAVEFORMATEX, *LPCWAVEFORMATEX;
58
 
59
 
60
/**************************************************************************
61
 *
62
 *  WAVEFORMATEXTENSIBLE: Extended version of WAVEFORMATEX that should be
63
 *  used as a basis for all new audio formats.  The format tag is replaced
64
 *  with a GUID, allowing new formats to be defined without registering a
65
 *  format tag with Microsoft.  There are also new fields that can be used
66
 *  to specify the spatial positions for each channel and the bit packing
67
 *  used for wide samples (e.g. 24-bit PCM samples in 32-bit containers).
68
 *
69
 ***************************************************************************/
70
 
71
#ifndef _WAVEFORMATEXTENSIBLE_
72
 
73
    #define _WAVEFORMATEXTENSIBLE_
74
    typedef struct
75
    {
76
        WAVEFORMATEX Format;          // Base WAVEFORMATEX data
77
        union
78
        {
79
            WORD wValidBitsPerSample; // Valid bits in each sample container
80
            WORD wSamplesPerBlock;    // Samples per block of audio data; valid
81
                                      // if wBitsPerSample=0 (but rarely used).
82
            WORD wReserved;           // Zero if neither case above applies.
83
        } Samples;
84
        DWORD dwChannelMask;          // Positions of the audio channels
85
        GUID SubFormat;               // Format identifier GUID
86
    } WAVEFORMATEXTENSIBLE;
87
 
88
#endif
89
 
90
typedef WAVEFORMATEXTENSIBLE *PWAVEFORMATEXTENSIBLE, *LPWAVEFORMATEXTENSIBLE;
91
typedef const WAVEFORMATEXTENSIBLE *PCWAVEFORMATEXTENSIBLE, *LPCWAVEFORMATEXTENSIBLE;
92
 
93
 
94
 
95
/**************************************************************************
96
 *
97
 *  Define the most common wave format tags used in WAVEFORMATEX formats.
98
 *
99
 ***************************************************************************/
100
 
101
#ifndef WAVE_FORMAT_PCM  // Pulse Code Modulation
102
 
103
    // If WAVE_FORMAT_PCM is not defined, we need to define some legacy types
104
    // for compatibility with the Windows mmreg.h / mmsystem.h header files.
105
 
106
    // Old general format structure (information common to all formats)
107
    typedef struct waveformat_tag
108
    {
109
        WORD wFormatTag;
110
        WORD nChannels;
111
        DWORD nSamplesPerSec;
112
        DWORD nAvgBytesPerSec;
113
        WORD nBlockAlign;
114
    } WAVEFORMAT, *PWAVEFORMAT, NEAR *NPWAVEFORMAT, FAR *LPWAVEFORMAT;
115
 
116
    // Specific format structure for PCM data
117
    typedef struct pcmwaveformat_tag
118
    {
119
        WAVEFORMAT wf;
120
        WORD wBitsPerSample;
121
    } PCMWAVEFORMAT, *PPCMWAVEFORMAT, NEAR *NPPCMWAVEFORMAT, FAR *LPPCMWAVEFORMAT;
122
 
123
    #define WAVE_FORMAT_PCM 0x0001
124
 
125
#endif
126
 
127
#ifndef WAVE_FORMAT_ADPCM  // Microsoft Adaptive Differental PCM
128
 
129
    // Replicate the Microsoft ADPCM type definitions from mmreg.h.
130
 
131
    typedef struct adpcmcoef_tag
132
    {
133
        short iCoef1;
134
        short iCoef2;
135
    } ADPCMCOEFSET;
136
 
137
    #pragma warning(push)
138
    #pragma warning(disable:4200)  // Disable zero-sized array warnings
139
 
140
    typedef struct adpcmwaveformat_tag {
141
        WAVEFORMATEX wfx;
142
        WORD wSamplesPerBlock;
143
        WORD wNumCoef;
144
        ADPCMCOEFSET aCoef[];  // Always 7 coefficient pairs for MS ADPCM
145
    } ADPCMWAVEFORMAT;
146
 
147
    #pragma warning(pop)
148
 
149
    #define WAVE_FORMAT_ADPCM 0x0002
150
 
151
#endif
152
 
153
// Other frequently used format tags
154
 
155
#ifndef WAVE_FORMAT_UNKNOWN
156
    #define WAVE_FORMAT_UNKNOWN         0x0000 // Unknown or invalid format tag
157
#endif
158
 
159
#ifndef WAVE_FORMAT_IEEE_FLOAT
160
    #define WAVE_FORMAT_IEEE_FLOAT      0x0003 // 32-bit floating-point
161
#endif
162
 
163
#ifndef WAVE_FORMAT_MPEGLAYER3
164
    #define WAVE_FORMAT_MPEGLAYER3      0x0055 // ISO/MPEG Layer3
165
#endif
166
 
167
#ifndef WAVE_FORMAT_DOLBY_AC3_SPDIF
168
    #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 // Dolby Audio Codec 3 over S/PDIF
169
#endif
170
 
171
#ifndef WAVE_FORMAT_WMAUDIO2
172
    #define WAVE_FORMAT_WMAUDIO2        0x0161 // Windows Media Audio
173
#endif
174
 
175
#ifndef WAVE_FORMAT_WMAUDIO3
176
    #define WAVE_FORMAT_WMAUDIO3        0x0162 // Windows Media Audio Pro
177
#endif
178
 
179
#ifndef WAVE_FORMAT_WMASPDIF
180
    #define WAVE_FORMAT_WMASPDIF        0x0164 // Windows Media Audio over S/PDIF
181
#endif
182
 
183
#ifndef WAVE_FORMAT_EXTENSIBLE
184
    #define WAVE_FORMAT_EXTENSIBLE      0xFFFE // All WAVEFORMATEXTENSIBLE formats
185
#endif
186
 
187
 
188
/**************************************************************************
189
 *
190
 *  Define the most common wave format GUIDs used in WAVEFORMATEXTENSIBLE
191
 *  formats.  Note that including the Windows ksmedia.h header after this
192
 *  one will cause build problems; this cannot be avoided, since ksmedia.h
193
 *  defines these macros without preprocessor guards.
194
 *
195
 ***************************************************************************/
196
 
197
#ifdef __cplusplus // uuid() and __uuidof() are only available in C++
198
 
199
    #ifndef KSDATAFORMAT_SUBTYPE_PCM
200
        struct __declspec(uuid("00000001-0000-0010-8000-00aa00389b71")) KSDATAFORMAT_SUBTYPE_PCM_STRUCT;
201
        #define KSDATAFORMAT_SUBTYPE_PCM __uuidof(KSDATAFORMAT_SUBTYPE_PCM_STRUCT)
202
    #endif
203
 
204
    #ifndef KSDATAFORMAT_SUBTYPE_ADPCM
205
        struct __declspec(uuid("00000002-0000-0010-8000-00aa00389b71")) KSDATAFORMAT_SUBTYPE_ADPCM_STRUCT;
206
        #define KSDATAFORMAT_SUBTYPE_ADPCM __uuidof(KSDATAFORMAT_SUBTYPE_ADPCM_STRUCT)
207
    #endif
208
 
209
    #ifndef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
210
        struct __declspec(uuid("00000003-0000-0010-8000-00aa00389b71")) KSDATAFORMAT_SUBTYPE_IEEE_FLOAT_STRUCT;
211
        #define KSDATAFORMAT_SUBTYPE_IEEE_FLOAT __uuidof(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT_STRUCT)
212
    #endif
213
 
214
#endif
215
 
216
 
217
/**************************************************************************
218
 *
219
 *  Speaker positions used in the WAVEFORMATEXTENSIBLE dwChannelMask field.
220
 *
221
 ***************************************************************************/
222
 
223
#ifndef SPEAKER_FRONT_LEFT
224
    #define SPEAKER_FRONT_LEFT            0x00000001
225
    #define SPEAKER_FRONT_RIGHT           0x00000002
226
    #define SPEAKER_FRONT_CENTER          0x00000004
227
    #define SPEAKER_LOW_FREQUENCY         0x00000008
228
    #define SPEAKER_BACK_LEFT             0x00000010
229
    #define SPEAKER_BACK_RIGHT            0x00000020
230
    #define SPEAKER_FRONT_LEFT_OF_CENTER  0x00000040
231
    #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080
232
    #define SPEAKER_BACK_CENTER           0x00000100
233
    #define SPEAKER_SIDE_LEFT             0x00000200
234
    #define SPEAKER_SIDE_RIGHT            0x00000400
235
    #define SPEAKER_TOP_CENTER            0x00000800
236
    #define SPEAKER_TOP_FRONT_LEFT        0x00001000
237
    #define SPEAKER_TOP_FRONT_CENTER      0x00002000
238
    #define SPEAKER_TOP_FRONT_RIGHT       0x00004000
239
    #define SPEAKER_TOP_BACK_LEFT         0x00008000
240
    #define SPEAKER_TOP_BACK_CENTER       0x00010000
241
    #define SPEAKER_TOP_BACK_RIGHT        0x00020000
242
    #define SPEAKER_RESERVED              0x7FFC0000
243
    #define SPEAKER_ALL                   0x80000000
244
    #define _SPEAKER_POSITIONS_
245
#endif
246
 
247
#ifndef SPEAKER_STEREO
248
    #define SPEAKER_MONO             (SPEAKER_FRONT_CENTER)
249
    #define SPEAKER_STEREO           (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT)
250
    #define SPEAKER_2POINT1          (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY)
251
    #define SPEAKER_SURROUND         (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER)
252
    #define SPEAKER_QUAD             (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT)
253
    #define SPEAKER_4POINT1          (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT)
254
    #define SPEAKER_5POINT1          (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT)
255
    #define SPEAKER_7POINT1          (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER)
256
    #define SPEAKER_5POINT1_SURROUND (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT)
257
    #define SPEAKER_7POINT1_SURROUND (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT  | SPEAKER_SIDE_RIGHT)
258
#endif
259
 
260
 
261
#pragma pack(pop)
262
 
263
#endif // #ifndef __AUDIODEFS_INCLUDED__