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.

150 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: client sound i/o functions
  4. //
  5. //===========================================================================//
  6. #ifndef SOUND_H
  7. #define SOUND_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "basetypes.h"
  12. #include "datamap.h"
  13. #include "mathlib/vector.h"
  14. #include "mathlib/mathlib.h"
  15. #include "tier1/strtools.h"
  16. #include "soundflags.h"
  17. #include "utlvector.h"
  18. #include "engine/SndInfo.h"
  19. #define MAX_SFX 2048
  20. #define AUDIOSOURCE_CACHE_ROOTDIR "maps/soundcache"
  21. class CSfxTable;
  22. enum soundlevel_t;
  23. struct SoundInfo_t;
  24. struct AudioState_t;
  25. class IFileList;
  26. void S_Init (void);
  27. void S_Shutdown (void);
  28. bool S_IsInitted();
  29. void S_StopAllSounds(bool clear);
  30. void S_Update( const AudioState_t *pAudioState );
  31. void S_ExtraUpdate (void);
  32. void S_ClearBuffer (void);
  33. void S_BlockSound (void);
  34. void S_UnblockSound (void);
  35. float S_GetMasterVolume( void );
  36. void S_SoundFade( float percent, float holdtime, float intime, float outtime );
  37. void S_OnLoadScreen(bool value);
  38. void S_EnableThreadedMixing( bool bEnable );
  39. void S_EnableMusic( bool bEnable );
  40. struct StartSoundParams_t
  41. {
  42. StartSoundParams_t() :
  43. staticsound( false ),
  44. userdata( 0 ),
  45. soundsource( 0 ),
  46. entchannel( CHAN_AUTO ),
  47. pSfx( 0 ),
  48. bUpdatePositions( true ),
  49. fvol( 1.0f ),
  50. soundlevel( SNDLVL_NORM ),
  51. flags( SND_NOFLAGS ),
  52. pitch( PITCH_NORM ),
  53. specialdsp( 0 ),
  54. fromserver( false ),
  55. delay( 0.0f ),
  56. speakerentity( -1 ),
  57. suppressrecording( false ),
  58. initialStreamPosition( 0 )
  59. {
  60. origin.Init();
  61. direction.Init();
  62. }
  63. bool staticsound;
  64. int userdata;
  65. int soundsource;
  66. int entchannel;
  67. CSfxTable *pSfx;
  68. Vector origin;
  69. Vector direction;
  70. bool bUpdatePositions;
  71. float fvol;
  72. soundlevel_t soundlevel;
  73. int flags;
  74. int pitch;
  75. int specialdsp;
  76. bool fromserver;
  77. float delay;
  78. int speakerentity;
  79. bool suppressrecording;
  80. int initialStreamPosition;
  81. };
  82. int S_StartSound( StartSoundParams_t& params );
  83. void S_StopSound ( int entnum, int entchannel );
  84. enum clocksync_index_t
  85. {
  86. CLOCK_SYNC_CLIENT = 0,
  87. CLOCK_SYNC_SERVER,
  88. NUM_CLOCK_SYNCS
  89. };
  90. extern float S_ComputeDelayForSoundtime( float soundtime, clocksync_index_t syncIndex );
  91. void S_StopSoundByGuid( int guid );
  92. float S_SoundDurationByGuid( int guid );
  93. int S_GetGuidForLastSoundEmitted();
  94. bool S_IsSoundStillPlaying( int guid );
  95. void S_GetActiveSounds( CUtlVector< SndInfo_t >& sndlist );
  96. void S_SetVolumeByGuid( int guid, float fvol );
  97. float S_GetElapsedTimeByGuid( int guid );
  98. bool S_IsLoopingSoundByGuid( int guid );
  99. void S_ReloadSound( const char *pSample );
  100. float S_GetMono16Samples( const char *pszName, CUtlVector< short >& sampleList );
  101. CSfxTable *S_DummySfx( const char *name );
  102. CSfxTable *S_PrecacheSound (const char *sample );
  103. void S_PrefetchSound( char const *name, bool bPlayOnce );
  104. void S_MarkUISound( CSfxTable *pSfx );
  105. void S_ReloadFilesInList( IFileList *pFilesToReload );
  106. vec_t S_GetNominalClipDist();
  107. extern bool TestSoundChar(const char *pch, char c);
  108. extern char *PSkipSoundChars(const char *pch);
  109. #include "soundchars.h"
  110. // for recording movies
  111. void SND_MovieStart( void );
  112. void SND_MovieEnd( void );
  113. //-------------------------------------
  114. int S_GetCurrentStaticSounds( SoundInfo_t *pResult, int nSizeResult, int entchannel );
  115. //-----------------------------------------------------------------------------
  116. float S_GetGainFromSoundLevel( soundlevel_t soundlevel, vec_t dist );
  117. struct musicsave_t
  118. {
  119. DECLARE_SIMPLE_DATADESC();
  120. char songname[ 128 ];
  121. int sampleposition;
  122. short master_volume;
  123. };
  124. void S_GetCurrentlyPlayingMusic( CUtlVector< musicsave_t >& list );
  125. void S_RestartSong( const musicsave_t *song );
  126. #endif // SOUND_H