Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.4 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef XWVFILE_H
  7. #define XWVFILE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #pragma pack(1)
  12. #define XWV_ID (('X'<<24)|('W'<<16)|('V'<<8)|(' '<<0))
  13. #define XWV_VERSION 4
  14. enum xwvSampleRate_t
  15. {
  16. XWV_RATE_11025 = 0,
  17. XWV_RATE_22050 = 1,
  18. XWV_RATE_44100 = 2,
  19. };
  20. enum xwvFormat_t
  21. {
  22. XWV_FORMAT_PCM = 0,
  23. XWV_FORMAT_XMA = 1,
  24. XWV_FORMAT_ADPCM = 2,
  25. XWV_FORMAT_MP3 = 3,
  26. // Used to detect MP3 frame issues.
  27. XWV_FORMAT_TEMP = 123,
  28. };
  29. // 1152 samples for one MP3 frame. 2304 bytes in mono, 4608 in stereo.
  30. #define NUMBER_OF_SAMPLES_PER_MP3_FRAME 1152
  31. // generated in big-endian
  32. struct xwvHeader_t
  33. {
  34. unsigned int id;
  35. unsigned int version;
  36. unsigned int headerSize; // header only
  37. unsigned int staticDataSize; // follows header
  38. unsigned int dataOffset; // start of samples, possibly sector aligned
  39. unsigned int dataSize; // length of samples in bytes
  40. unsigned int numDecodedSamples; // for duration calcs
  41. int loopStart; // -1 = no loop, offset of loop in samples
  42. unsigned short loopBlock; // the xma block where the loop starts
  43. unsigned short numLeadingSamples; // number of leading samples in the loop block to discard
  44. unsigned short numTrailingSamples; // number of trailing samples at the final block to discard
  45. unsigned short vdatSize; // follows seek table
  46. byte format;
  47. byte bitsPerSample;
  48. byte sampleRate;
  49. byte channels;
  50. byte quality;
  51. byte bHasSeekTable; // indicates presence, follows header
  52. byte padding[2]; // created as 0
  53. inline unsigned int GetPreloadSize() { return headerSize + staticDataSize; }
  54. inline int GetBitsPerSample() const { return bitsPerSample; }
  55. int GetSampleRate() const
  56. {
  57. int rates[] = {11025, 22050, 44100};
  58. int rate = sampleRate;
  59. return rates[rate];
  60. }
  61. inline int GetChannels() const { return channels; }
  62. void SetSampleRate( int sampleRateIn )
  63. {
  64. byte rate = ( sampleRateIn == 11025 ) ? XWV_RATE_11025 : ( sampleRateIn==22050 )? XWV_RATE_22050 : XWV_RATE_44100;
  65. sampleRate = rate;
  66. }
  67. inline void SetChannels( int channelsIn ) { channels = channelsIn; }
  68. inline int GetSeekTableSize()
  69. {
  70. // seek table is indexed by packets
  71. return bHasSeekTable ? ( dataSize / 2048 ) * sizeof( int ) : 0;
  72. }
  73. };
  74. #pragma pack()
  75. #endif // XWVFILE_H