cannam@89
|
1 #ifndef PA_WIN_WAVEFORMAT_H
|
cannam@89
|
2 #define PA_WIN_WAVEFORMAT_H
|
cannam@89
|
3
|
cannam@89
|
4 /*
|
cannam@89
|
5 * PortAudio Portable Real-Time Audio Library
|
cannam@89
|
6 * Windows WAVEFORMAT* data structure utilities
|
cannam@89
|
7 * portaudio.h should be included before this file.
|
cannam@89
|
8 *
|
cannam@89
|
9 * Copyright (c) 2007 Ross Bencina
|
cannam@89
|
10 *
|
cannam@89
|
11 * Permission is hereby granted, free of charge, to any person obtaining
|
cannam@89
|
12 * a copy of this software and associated documentation files
|
cannam@89
|
13 * (the "Software"), to deal in the Software without restriction,
|
cannam@89
|
14 * including without limitation the rights to use, copy, modify, merge,
|
cannam@89
|
15 * publish, distribute, sublicense, and/or sell copies of the Software,
|
cannam@89
|
16 * and to permit persons to whom the Software is furnished to do so,
|
cannam@89
|
17 * subject to the following conditions:
|
cannam@89
|
18 *
|
cannam@89
|
19 * The above copyright notice and this permission notice shall be
|
cannam@89
|
20 * included in all copies or substantial portions of the Software.
|
cannam@89
|
21 *
|
cannam@89
|
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
cannam@89
|
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
cannam@89
|
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
cannam@89
|
25 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
cannam@89
|
26 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
cannam@89
|
27 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
cannam@89
|
28 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
cannam@89
|
29 */
|
cannam@89
|
30
|
cannam@89
|
31 /*
|
cannam@89
|
32 * The text above constitutes the entire PortAudio license; however,
|
cannam@89
|
33 * the PortAudio community also makes the following non-binding requests:
|
cannam@89
|
34 *
|
cannam@89
|
35 * Any person wishing to distribute modifications to the Software is
|
cannam@89
|
36 * requested to send the modifications to the original developer so that
|
cannam@89
|
37 * they can be incorporated into the canonical version. It is also
|
cannam@89
|
38 * requested that these non-binding requests be included along with the
|
cannam@89
|
39 * license above.
|
cannam@89
|
40 */
|
cannam@89
|
41
|
cannam@89
|
42 /** @file
|
cannam@89
|
43 @ingroup public_header
|
cannam@89
|
44 @brief Windows specific PortAudio API extension and utilities header file.
|
cannam@89
|
45 */
|
cannam@89
|
46
|
cannam@89
|
47 #ifdef __cplusplus
|
cannam@89
|
48 extern "C" {
|
cannam@89
|
49 #endif
|
cannam@89
|
50
|
cannam@89
|
51 /*
|
cannam@89
|
52 The following #defines for speaker channel masks are the same
|
cannam@89
|
53 as those in ksmedia.h, except with PAWIN_ prepended, KSAUDIO_ removed
|
cannam@89
|
54 in some cases, and casts to PaWinWaveFormatChannelMask added.
|
cannam@89
|
55 */
|
cannam@89
|
56
|
cannam@89
|
57 typedef unsigned long PaWinWaveFormatChannelMask;
|
cannam@89
|
58
|
cannam@89
|
59 /* Speaker Positions: */
|
cannam@89
|
60 #define PAWIN_SPEAKER_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1)
|
cannam@89
|
61 #define PAWIN_SPEAKER_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x2)
|
cannam@89
|
62 #define PAWIN_SPEAKER_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x4)
|
cannam@89
|
63 #define PAWIN_SPEAKER_LOW_FREQUENCY ((PaWinWaveFormatChannelMask)0x8)
|
cannam@89
|
64 #define PAWIN_SPEAKER_BACK_LEFT ((PaWinWaveFormatChannelMask)0x10)
|
cannam@89
|
65 #define PAWIN_SPEAKER_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20)
|
cannam@89
|
66 #define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER ((PaWinWaveFormatChannelMask)0x40)
|
cannam@89
|
67 #define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER ((PaWinWaveFormatChannelMask)0x80)
|
cannam@89
|
68 #define PAWIN_SPEAKER_BACK_CENTER ((PaWinWaveFormatChannelMask)0x100)
|
cannam@89
|
69 #define PAWIN_SPEAKER_SIDE_LEFT ((PaWinWaveFormatChannelMask)0x200)
|
cannam@89
|
70 #define PAWIN_SPEAKER_SIDE_RIGHT ((PaWinWaveFormatChannelMask)0x400)
|
cannam@89
|
71 #define PAWIN_SPEAKER_TOP_CENTER ((PaWinWaveFormatChannelMask)0x800)
|
cannam@89
|
72 #define PAWIN_SPEAKER_TOP_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1000)
|
cannam@89
|
73 #define PAWIN_SPEAKER_TOP_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x2000)
|
cannam@89
|
74 #define PAWIN_SPEAKER_TOP_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x4000)
|
cannam@89
|
75 #define PAWIN_SPEAKER_TOP_BACK_LEFT ((PaWinWaveFormatChannelMask)0x8000)
|
cannam@89
|
76 #define PAWIN_SPEAKER_TOP_BACK_CENTER ((PaWinWaveFormatChannelMask)0x10000)
|
cannam@89
|
77 #define PAWIN_SPEAKER_TOP_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20000)
|
cannam@89
|
78
|
cannam@89
|
79 /* Bit mask locations reserved for future use */
|
cannam@89
|
80 #define PAWIN_SPEAKER_RESERVED ((PaWinWaveFormatChannelMask)0x7FFC0000)
|
cannam@89
|
81
|
cannam@89
|
82 /* Used to specify that any possible permutation of speaker configurations */
|
cannam@89
|
83 #define PAWIN_SPEAKER_ALL ((PaWinWaveFormatChannelMask)0x80000000)
|
cannam@89
|
84
|
cannam@89
|
85 /* DirectSound Speaker Config */
|
cannam@89
|
86 #define PAWIN_SPEAKER_DIRECTOUT 0
|
cannam@89
|
87 #define PAWIN_SPEAKER_MONO (PAWIN_SPEAKER_FRONT_CENTER)
|
cannam@89
|
88 #define PAWIN_SPEAKER_STEREO (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT)
|
cannam@89
|
89 #define PAWIN_SPEAKER_QUAD (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
cannam@89
|
90 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
|
cannam@89
|
91 #define PAWIN_SPEAKER_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
cannam@89
|
92 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER)
|
cannam@89
|
93 #define PAWIN_SPEAKER_5POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
cannam@89
|
94 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
cannam@89
|
95 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
|
cannam@89
|
96 #define PAWIN_SPEAKER_7POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
cannam@89
|
97 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
cannam@89
|
98 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
|
cannam@89
|
99 PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)
|
cannam@89
|
100 #define PAWIN_SPEAKER_5POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
cannam@89
|
101 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
cannam@89
|
102 PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
|
cannam@89
|
103 #define PAWIN_SPEAKER_7POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
cannam@89
|
104 PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
cannam@89
|
105 PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
|
cannam@89
|
106 PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
|
cannam@89
|
107 /*
|
cannam@89
|
108 According to the Microsoft documentation:
|
cannam@89
|
109 The following are obsolete 5.1 and 7.1 settings (they lack side speakers). Note this means
|
cannam@89
|
110 that the default 5.1 and 7.1 settings (KSAUDIO_SPEAKER_5POINT1 and KSAUDIO_SPEAKER_7POINT1 are
|
cannam@89
|
111 similarly obsolete but are unchanged for compatibility reasons).
|
cannam@89
|
112 */
|
cannam@89
|
113 #define PAWIN_SPEAKER_5POINT1_BACK PAWIN_SPEAKER_5POINT1
|
cannam@89
|
114 #define PAWIN_SPEAKER_7POINT1_WIDE PAWIN_SPEAKER_7POINT1
|
cannam@89
|
115
|
cannam@89
|
116 /* DVD Speaker Positions */
|
cannam@89
|
117 #define PAWIN_SPEAKER_GROUND_FRONT_LEFT PAWIN_SPEAKER_FRONT_LEFT
|
cannam@89
|
118 #define PAWIN_SPEAKER_GROUND_FRONT_CENTER PAWIN_SPEAKER_FRONT_CENTER
|
cannam@89
|
119 #define PAWIN_SPEAKER_GROUND_FRONT_RIGHT PAWIN_SPEAKER_FRONT_RIGHT
|
cannam@89
|
120 #define PAWIN_SPEAKER_GROUND_REAR_LEFT PAWIN_SPEAKER_BACK_LEFT
|
cannam@89
|
121 #define PAWIN_SPEAKER_GROUND_REAR_RIGHT PAWIN_SPEAKER_BACK_RIGHT
|
cannam@89
|
122 #define PAWIN_SPEAKER_TOP_MIDDLE PAWIN_SPEAKER_TOP_CENTER
|
cannam@89
|
123 #define PAWIN_SPEAKER_SUPER_WOOFER PAWIN_SPEAKER_LOW_FREQUENCY
|
cannam@89
|
124
|
cannam@89
|
125
|
cannam@89
|
126 /*
|
cannam@89
|
127 PaWinWaveFormat is defined here to provide compatibility with
|
cannam@89
|
128 compilation environments which don't have headers defining
|
cannam@89
|
129 WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc.
|
cannam@89
|
130
|
cannam@89
|
131 The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an
|
cannam@89
|
132 unsigned char array here to avoid clients who include this file having
|
cannam@89
|
133 a dependency on windows.h and mmsystem.h, and also to to avoid having
|
cannam@89
|
134 to write separate packing pragmas for each compiler.
|
cannam@89
|
135 */
|
cannam@89
|
136 #define PAWIN_SIZEOF_WAVEFORMATEX 18
|
cannam@89
|
137 #define PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE (PAWIN_SIZEOF_WAVEFORMATEX + 22)
|
cannam@89
|
138
|
cannam@89
|
139 typedef struct{
|
cannam@89
|
140 unsigned char fields[ PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE ];
|
cannam@89
|
141 unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
|
cannam@89
|
142 } PaWinWaveFormat;
|
cannam@89
|
143
|
cannam@89
|
144 /*
|
cannam@89
|
145 WAVEFORMATEXTENSIBLE fields:
|
cannam@89
|
146
|
cannam@89
|
147 union {
|
cannam@89
|
148 WORD wValidBitsPerSample;
|
cannam@89
|
149 WORD wSamplesPerBlock;
|
cannam@89
|
150 WORD wReserved;
|
cannam@89
|
151 } Samples;
|
cannam@89
|
152 DWORD dwChannelMask;
|
cannam@89
|
153 GUID SubFormat;
|
cannam@89
|
154 */
|
cannam@89
|
155
|
cannam@89
|
156 #define PAWIN_INDEXOF_WVALIDBITSPERSAMPLE (PAWIN_SIZEOF_WAVEFORMATEX+0)
|
cannam@89
|
157 #define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2)
|
cannam@89
|
158 #define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6)
|
cannam@89
|
159
|
cannam@89
|
160
|
cannam@89
|
161 /*
|
cannam@89
|
162 Valid values to pass for the waveFormatTag PaWin_InitializeWaveFormatEx and
|
cannam@89
|
163 PaWin_InitializeWaveFormatExtensible functions below. These must match
|
cannam@89
|
164 the standard Windows WAVE_FORMAT_* values.
|
cannam@89
|
165 */
|
cannam@89
|
166 #define PAWIN_WAVE_FORMAT_PCM (1)
|
cannam@89
|
167 #define PAWIN_WAVE_FORMAT_IEEE_FLOAT (3)
|
cannam@89
|
168 #define PAWIN_WAVE_FORMAT_DOLBY_AC3_SPDIF (0x0092)
|
cannam@89
|
169 #define PAWIN_WAVE_FORMAT_WMA_SPDIF (0x0164)
|
cannam@89
|
170
|
cannam@89
|
171
|
cannam@89
|
172 /*
|
cannam@89
|
173 returns PAWIN_WAVE_FORMAT_PCM or PAWIN_WAVE_FORMAT_IEEE_FLOAT
|
cannam@89
|
174 depending on the sampleFormat parameter.
|
cannam@89
|
175 */
|
cannam@89
|
176 int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat );
|
cannam@89
|
177
|
cannam@89
|
178 /*
|
cannam@89
|
179 Use the following two functions to initialize the waveformat structure.
|
cannam@89
|
180 */
|
cannam@89
|
181
|
cannam@89
|
182 void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
|
cannam@89
|
183 int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate );
|
cannam@89
|
184
|
cannam@89
|
185
|
cannam@89
|
186 void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
|
cannam@89
|
187 int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
|
cannam@89
|
188 PaWinWaveFormatChannelMask channelMask );
|
cannam@89
|
189
|
cannam@89
|
190
|
cannam@89
|
191 /* Map a channel count to a speaker channel mask */
|
cannam@89
|
192 PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels );
|
cannam@89
|
193
|
cannam@89
|
194
|
cannam@89
|
195 #ifdef __cplusplus
|
cannam@89
|
196 }
|
cannam@89
|
197 #endif /* __cplusplus */
|
cannam@89
|
198
|
cannam@89
|
199 #endif /* PA_WIN_WAVEFORMAT_H */ |