Team Fortress 2 Source Code as on 22/4/2020
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.

107 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SND_MIX_BUF_H
  8. #define SND_MIX_BUF_H
  9. #if defined( _WIN32 )
  10. #pragma once
  11. #endif
  12. // OPTIMIZE: note that making this larger will not increase performance (12/27/03)
  13. #define PAINTBUFFER_SIZE 1020 // 44k: was 512
  14. #define PAINTBUFFER (g_curpaintbuffer)
  15. #define REARPAINTBUFFER (g_currearpaintbuffer)
  16. #define CENTERPAINTBUFFER (g_curcenterpaintbuffer)
  17. enum SoundBufferType_t
  18. {
  19. SOUND_BUFFER_PAINT = 0,
  20. SOUND_BUFFER_ROOM,
  21. SOUND_BUFFER_FACING,
  22. SOUND_BUFFER_FACINGAWAY,
  23. SOUND_BUFFER_DRY,
  24. SOUND_BUFFER_SPEAKER,
  25. SOUND_BUFFER_BASETOTAL,
  26. SOUND_BUFFER_SPECIAL_START = SOUND_BUFFER_BASETOTAL
  27. };
  28. // !!! if this is changed, it much be changed in native assembly too !!!
  29. struct portable_samplepair_t
  30. {
  31. int left;
  32. int right;
  33. };
  34. // sound mixing buffer
  35. #define CPAINTFILTERMEM 3
  36. #define CPAINTFILTERS 4 // maximum number of consecutive upsample passes per paintbuffer
  37. struct paintbuffer_t
  38. {
  39. bool factive; // if true, mix to this paintbuffer using flags
  40. bool fsurround; // if true, mix to front and rear paintbuffers using flags
  41. bool fsurround_center; // if true, mix to front, rear and center paintbuffers using flags
  42. int idsp_specialdsp;
  43. int nPrevSpecialDSP;
  44. int nSpecialDSP;
  45. int flags; // SOUND_BUSS_ROOM, SOUND_BUSS_FACING, SOUND_BUSS_FACINGAWAY, SOUND_BUSS_SPEAKER, SOUND_BUSS_SPECIAL_DSP, SOUND_BUSS_DRY
  46. portable_samplepair_t *pbuf; // front stereo mix buffer, for 2 or 4 channel mixing
  47. portable_samplepair_t *pbufrear; // rear mix buffer, for 4 channel mixing
  48. portable_samplepair_t *pbufcenter; // center mix buffer, for 5 channel mixing
  49. int ifilter; // current filter memory buffer to use for upsampling pass
  50. portable_samplepair_t fltmem[CPAINTFILTERS][CPAINTFILTERMEM]; // filter memory, for upsampling with linear or cubic interpolation
  51. portable_samplepair_t fltmemrear[CPAINTFILTERS][CPAINTFILTERMEM]; // filter memory, for upsampling with linear or cubic interpolation
  52. portable_samplepair_t fltmemcenter[CPAINTFILTERS][CPAINTFILTERMEM]; // filter memory, for upsampling with linear or cubic interpolation
  53. };
  54. extern "C"
  55. {
  56. extern portable_samplepair_t *g_paintbuffer;
  57. // temp paintbuffer - not included in main list of paintbuffers
  58. extern portable_samplepair_t *g_temppaintbuffer;
  59. extern CUtlVector< paintbuffer_t > g_paintBuffers;
  60. extern void MIX_SetCurrentPaintbuffer( int ipaintbuffer );
  61. extern int MIX_GetCurrentPaintbufferIndex( void );
  62. extern paintbuffer_t *MIX_GetCurrentPaintbufferPtr( void );
  63. extern paintbuffer_t *MIX_GetPPaintFromIPaint( int ipaintbuffer );
  64. extern void MIX_ClearAllPaintBuffers( int SampleCount, bool clearFilters );
  65. extern bool MIX_InitAllPaintbuffers(void);
  66. extern void MIX_FreeAllPaintbuffers(void);
  67. extern portable_samplepair_t *g_curpaintbuffer;
  68. extern portable_samplepair_t *g_currearpaintbuffer;
  69. extern portable_samplepair_t *g_curcenterpaintbuffer;
  70. };
  71. // must be at least PAINTBUFFER_SIZE+1 for upsampling
  72. #define PAINTBUFFER_MEM_SIZE (PAINTBUFFER_SIZE+4)
  73. // size in samples of copy buffer used by pitch shifters in mixing
  74. #if defined(_GAMECONSOLE)
  75. #define TEMP_COPY_BUFFER_SIZE (PAINTBUFFER_MEM_SIZE * 2)
  76. #else
  77. // allow more memory for this on PC for developers to pitch-shift their way through dialog
  78. #define TEMP_COPY_BUFFER_SIZE (PAINTBUFFER_MEM_SIZE * 4)
  79. #endif
  80. // hard clip input value to -32767 <= y <= 32767
  81. #define CLIP(x) ((x) > 32767 ? 32767 : ((x) < -32767 ? -32767 : (x)))
  82. #endif // SND_MIX_BUF_H