Chris@4: #ifndef PA_WIN_WAVEFORMAT_H Chris@4: #define PA_WIN_WAVEFORMAT_H Chris@4: Chris@4: /* Chris@4: * PortAudio Portable Real-Time Audio Library Chris@4: * Windows WAVEFORMAT* data structure utilities Chris@4: * portaudio.h should be included before this file. Chris@4: * Chris@4: * Copyright (c) 2007 Ross Bencina Chris@4: * Chris@4: * Permission is hereby granted, free of charge, to any person obtaining Chris@4: * a copy of this software and associated documentation files Chris@4: * (the "Software"), to deal in the Software without restriction, Chris@4: * including without limitation the rights to use, copy, modify, merge, Chris@4: * publish, distribute, sublicense, and/or sell copies of the Software, Chris@4: * and to permit persons to whom the Software is furnished to do so, Chris@4: * subject to the following conditions: Chris@4: * Chris@4: * The above copyright notice and this permission notice shall be Chris@4: * included in all copies or substantial portions of the Software. Chris@4: * Chris@4: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@4: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@4: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. Chris@4: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR Chris@4: * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@4: * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@4: * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@4: */ Chris@4: Chris@4: /* Chris@4: * The text above constitutes the entire PortAudio license; however, Chris@4: * the PortAudio community also makes the following non-binding requests: Chris@4: * Chris@4: * Any person wishing to distribute modifications to the Software is Chris@4: * requested to send the modifications to the original developer so that Chris@4: * they can be incorporated into the canonical version. It is also Chris@4: * requested that these non-binding requests be included along with the Chris@4: * license above. Chris@4: */ Chris@4: Chris@4: /** @file Chris@4: @ingroup public_header Chris@4: @brief Windows specific PortAudio API extension and utilities header file. Chris@4: */ Chris@4: Chris@4: #ifdef __cplusplus Chris@4: extern "C" { Chris@4: #endif Chris@4: Chris@4: /* Chris@4: The following #defines for speaker channel masks are the same Chris@4: as those in ksmedia.h, except with PAWIN_ prepended, KSAUDIO_ removed Chris@4: in some cases, and casts to PaWinWaveFormatChannelMask added. Chris@4: */ Chris@4: Chris@4: typedef unsigned long PaWinWaveFormatChannelMask; Chris@4: Chris@4: /* Speaker Positions: */ Chris@4: #define PAWIN_SPEAKER_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1) Chris@4: #define PAWIN_SPEAKER_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x2) Chris@4: #define PAWIN_SPEAKER_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x4) Chris@4: #define PAWIN_SPEAKER_LOW_FREQUENCY ((PaWinWaveFormatChannelMask)0x8) Chris@4: #define PAWIN_SPEAKER_BACK_LEFT ((PaWinWaveFormatChannelMask)0x10) Chris@4: #define PAWIN_SPEAKER_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20) Chris@4: #define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER ((PaWinWaveFormatChannelMask)0x40) Chris@4: #define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER ((PaWinWaveFormatChannelMask)0x80) Chris@4: #define PAWIN_SPEAKER_BACK_CENTER ((PaWinWaveFormatChannelMask)0x100) Chris@4: #define PAWIN_SPEAKER_SIDE_LEFT ((PaWinWaveFormatChannelMask)0x200) Chris@4: #define PAWIN_SPEAKER_SIDE_RIGHT ((PaWinWaveFormatChannelMask)0x400) Chris@4: #define PAWIN_SPEAKER_TOP_CENTER ((PaWinWaveFormatChannelMask)0x800) Chris@4: #define PAWIN_SPEAKER_TOP_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1000) Chris@4: #define PAWIN_SPEAKER_TOP_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x2000) Chris@4: #define PAWIN_SPEAKER_TOP_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x4000) Chris@4: #define PAWIN_SPEAKER_TOP_BACK_LEFT ((PaWinWaveFormatChannelMask)0x8000) Chris@4: #define PAWIN_SPEAKER_TOP_BACK_CENTER ((PaWinWaveFormatChannelMask)0x10000) Chris@4: #define PAWIN_SPEAKER_TOP_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20000) Chris@4: Chris@4: /* Bit mask locations reserved for future use */ Chris@4: #define PAWIN_SPEAKER_RESERVED ((PaWinWaveFormatChannelMask)0x7FFC0000) Chris@4: Chris@4: /* Used to specify that any possible permutation of speaker configurations */ Chris@4: #define PAWIN_SPEAKER_ALL ((PaWinWaveFormatChannelMask)0x80000000) Chris@4: Chris@4: /* DirectSound Speaker Config */ Chris@4: #define PAWIN_SPEAKER_DIRECTOUT 0 Chris@4: #define PAWIN_SPEAKER_MONO (PAWIN_SPEAKER_FRONT_CENTER) Chris@4: #define PAWIN_SPEAKER_STEREO (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT) Chris@4: #define PAWIN_SPEAKER_QUAD (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \ Chris@4: PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT) Chris@4: #define PAWIN_SPEAKER_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \ Chris@4: PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER) Chris@4: #define PAWIN_SPEAKER_5POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \ Chris@4: PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \ Chris@4: PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT) Chris@4: #define PAWIN_SPEAKER_7POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \ Chris@4: PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \ Chris@4: PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \ Chris@4: PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER) Chris@4: #define PAWIN_SPEAKER_5POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \ Chris@4: PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \ Chris@4: PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT) Chris@4: #define PAWIN_SPEAKER_7POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \ Chris@4: PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \ Chris@4: PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \ Chris@4: PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT) Chris@4: /* Chris@4: According to the Microsoft documentation: Chris@4: The following are obsolete 5.1 and 7.1 settings (they lack side speakers). Note this means Chris@4: that the default 5.1 and 7.1 settings (KSAUDIO_SPEAKER_5POINT1 and KSAUDIO_SPEAKER_7POINT1 are Chris@4: similarly obsolete but are unchanged for compatibility reasons). Chris@4: */ Chris@4: #define PAWIN_SPEAKER_5POINT1_BACK PAWIN_SPEAKER_5POINT1 Chris@4: #define PAWIN_SPEAKER_7POINT1_WIDE PAWIN_SPEAKER_7POINT1 Chris@4: Chris@4: /* DVD Speaker Positions */ Chris@4: #define PAWIN_SPEAKER_GROUND_FRONT_LEFT PAWIN_SPEAKER_FRONT_LEFT Chris@4: #define PAWIN_SPEAKER_GROUND_FRONT_CENTER PAWIN_SPEAKER_FRONT_CENTER Chris@4: #define PAWIN_SPEAKER_GROUND_FRONT_RIGHT PAWIN_SPEAKER_FRONT_RIGHT Chris@4: #define PAWIN_SPEAKER_GROUND_REAR_LEFT PAWIN_SPEAKER_BACK_LEFT Chris@4: #define PAWIN_SPEAKER_GROUND_REAR_RIGHT PAWIN_SPEAKER_BACK_RIGHT Chris@4: #define PAWIN_SPEAKER_TOP_MIDDLE PAWIN_SPEAKER_TOP_CENTER Chris@4: #define PAWIN_SPEAKER_SUPER_WOOFER PAWIN_SPEAKER_LOW_FREQUENCY Chris@4: Chris@4: Chris@4: /* Chris@4: PaWinWaveFormat is defined here to provide compatibility with Chris@4: compilation environments which don't have headers defining Chris@4: WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc. Chris@4: Chris@4: The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an Chris@4: unsigned char array here to avoid clients who include this file having Chris@4: a dependency on windows.h and mmsystem.h, and also to to avoid having Chris@4: to write separate packing pragmas for each compiler. Chris@4: */ Chris@4: #define PAWIN_SIZEOF_WAVEFORMATEX 18 Chris@4: #define PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE (PAWIN_SIZEOF_WAVEFORMATEX + 22) Chris@4: Chris@4: typedef struct{ Chris@4: unsigned char fields[ PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE ]; Chris@4: unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */ Chris@4: } PaWinWaveFormat; Chris@4: Chris@4: /* Chris@4: WAVEFORMATEXTENSIBLE fields: Chris@4: Chris@4: union { Chris@4: WORD wValidBitsPerSample; Chris@4: WORD wSamplesPerBlock; Chris@4: WORD wReserved; Chris@4: } Samples; Chris@4: DWORD dwChannelMask; Chris@4: GUID SubFormat; Chris@4: */ Chris@4: Chris@4: #define PAWIN_INDEXOF_WVALIDBITSPERSAMPLE (PAWIN_SIZEOF_WAVEFORMATEX+0) Chris@4: #define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2) Chris@4: #define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6) Chris@4: Chris@4: Chris@4: /* Chris@4: Valid values to pass for the waveFormatTag PaWin_InitializeWaveFormatEx and Chris@4: PaWin_InitializeWaveFormatExtensible functions below. These must match Chris@4: the standard Windows WAVE_FORMAT_* values. Chris@4: */ Chris@4: #define PAWIN_WAVE_FORMAT_PCM (1) Chris@4: #define PAWIN_WAVE_FORMAT_IEEE_FLOAT (3) Chris@4: #define PAWIN_WAVE_FORMAT_DOLBY_AC3_SPDIF (0x0092) Chris@4: #define PAWIN_WAVE_FORMAT_WMA_SPDIF (0x0164) Chris@4: Chris@4: Chris@4: /* Chris@4: returns PAWIN_WAVE_FORMAT_PCM or PAWIN_WAVE_FORMAT_IEEE_FLOAT Chris@4: depending on the sampleFormat parameter. Chris@4: */ Chris@4: int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat ); Chris@4: Chris@4: /* Chris@4: Use the following two functions to initialize the waveformat structure. Chris@4: */ Chris@4: Chris@4: void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat, Chris@4: int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate ); Chris@4: Chris@4: Chris@4: void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat, Chris@4: int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate, Chris@4: PaWinWaveFormatChannelMask channelMask ); Chris@4: Chris@4: Chris@4: /* Map a channel count to a speaker channel mask */ Chris@4: PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels ); Chris@4: Chris@4: Chris@4: #ifdef __cplusplus Chris@4: } Chris@4: #endif /* __cplusplus */ Chris@4: Chris@4: #endif /* PA_WIN_WAVEFORMAT_H */