annotate src/portaudio_20161030/include/pa_win_waveformat.h @ 55:284acf908dcd

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