diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/public/xwvfile.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/public/xwvfile.h')
| -rw-r--r-- | mp/src/public/xwvfile.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/mp/src/public/xwvfile.h b/mp/src/public/xwvfile.h new file mode 100644 index 00000000..9058d25f --- /dev/null +++ b/mp/src/public/xwvfile.h @@ -0,0 +1,85 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef XWVFILE_H
+#define XWVFILE_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#pragma pack(1)
+
+#define XWV_ID (('X'<<24)|('W'<<16)|('V'<<8)|(' '<<0))
+#define XWV_VERSION 4
+
+enum xwvSampleRate_t
+{
+ XWV_RATE_11025 = 0,
+ XWV_RATE_22050 = 1,
+ XWV_RATE_44100 = 2,
+};
+
+enum xwvFormat_t
+{
+ XWV_FORMAT_PCM = 0,
+ XWV_FORMAT_XMA = 1,
+ XWV_FORMAT_ADPCM = 2,
+};
+
+// generated in big-endian
+struct xwvHeader_t
+{
+ unsigned int id;
+ unsigned int version;
+ unsigned int headerSize; // header only
+ unsigned int staticDataSize; // follows header
+ unsigned int dataOffset; // start of samples, possibly sector aligned
+ unsigned int dataSize; // length of samples in bytes
+ unsigned int numDecodedSamples; // for duration calcs
+ int loopStart; // -1 = no loop, offset of loop in samples
+ unsigned short loopBlock; // the xma block where the loop starts
+ unsigned short numLeadingSamples; // number of leading samples in the loop block to discard
+ unsigned short numTrailingSamples; // number of trailing samples at the final block to discard
+ unsigned short vdatSize; // follows seek table
+ byte format;
+ byte bitsPerSample;
+ byte sampleRate;
+ byte channels;
+ byte quality;
+ byte bHasSeekTable; // indicates presence, follows header
+ byte padding[2]; // created as 0
+
+ inline unsigned int GetPreloadSize() { return headerSize + staticDataSize; }
+
+ inline int GetBitsPerSample() const { return bitsPerSample; }
+
+ int GetSampleRate() const
+ {
+ int rates[] = {11025, 22050, 44100};
+ int rate = sampleRate;
+ return rates[rate];
+ }
+
+ inline int GetChannels() const { return channels; }
+
+ void SetSampleRate( int sampleRateIn )
+ {
+ byte rate = ( sampleRateIn == 11025 ) ? XWV_RATE_11025 : ( sampleRateIn==22050 )? XWV_RATE_22050 : XWV_RATE_44100;
+ sampleRate = rate;
+ }
+
+ inline void SetChannels( int channelsIn ) { channels = channelsIn; }
+
+ inline int GetSeekTableSize()
+ {
+ // seek table is indexed by packets
+ return bHasSeekTable ? ( dataSize / 2048 ) * sizeof( int ) : 0;
+ }
+};
+
+#pragma pack()
+
+#endif // XWVFILE_H
|