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