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.

140 lines
6.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Client-server neutral sound interface
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef IENGINESOUND_H
  8. #define IENGINESOUND_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "basetypes.h"
  13. #include "interface.h"
  14. #include "soundflags.h"
  15. #include "irecipientfilter.h"
  16. #include "utlvector.h"
  17. #include "engine/SndInfo.h"
  18. #include "SoundEmitterSystem/isoundemittersystembase.h"
  19. //-----------------------------------------------------------------------------
  20. // forward declaration
  21. //-----------------------------------------------------------------------------
  22. class Vector;
  23. // Handy defines for EmitSound
  24. #define SOUND_FROM_LOCAL_PLAYER -1
  25. #define SOUND_FROM_WORLD 0
  26. // These are used to feed a soundlevel to the sound system and have it use
  27. // goldsrc-type attenuation. We should use this as little as possible and
  28. // phase it out as soon as possible.
  29. // Take a regular sndlevel and convert it to compatibility mode.
  30. #define SNDLEVEL_TO_COMPATIBILITY_MODE( x ) ((soundlevel_t)(int)( (x) + 256 ))
  31. // Take a compatibility-mode sndlevel and get the REAL sndlevel out of it.
  32. #define SNDLEVEL_FROM_COMPATIBILITY_MODE( x ) ((soundlevel_t)(int)( (x) - 256 ))
  33. // Tells if the given sndlevel is marked as compatibility mode.
  34. #define SNDLEVEL_IS_COMPATIBILITY_MODE( x ) ( (x) >= 256 )
  35. //-----------------------------------------------------------------------------
  36. // Client-server neutral effects interface
  37. //-----------------------------------------------------------------------------
  38. #define IENGINESOUND_CLIENT_INTERFACE_VERSION "IEngineSoundClient003"
  39. #define IENGINESOUND_SERVER_INTERFACE_VERSION "IEngineSoundServer003"
  40. abstract_class IEngineSound
  41. {
  42. public:
  43. // Precache a particular sample
  44. virtual bool PrecacheSound( const char *pSample, bool bPreload = false, bool bIsUISound = false ) = 0;
  45. virtual bool IsSoundPrecached( const char *pSample ) = 0;
  46. virtual void PrefetchSound( const char *pSample ) = 0;
  47. virtual bool IsLoopingSound( const char *pSample ) = 0;
  48. // Just loads the file header and checks for duration (not hooked up for .mp3's yet)
  49. // Is accessible to server and client though
  50. virtual float GetSoundDuration( const char *pSample ) = 0;
  51. // Pitch of 100 is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100
  52. // down to 1 is a lower pitch. 150 to 70 is the realistic range.
  53. // EmitSound with pitch != 100 should be used sparingly, as it's not quite as
  54. // fast (the pitchshift mixer is not native coded).
  55. // NOTE: setting iEntIndex to -1 will cause the sound to be emitted from the local
  56. // player (client-side only)
  57. // Will return the sound guid. If negative, the guid is unknown (call may be successful or not). 0 if the sound was not emitted. Positive if the guid is valid.
  58. virtual int EmitSound( IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSoundEntry, HSOUNDSCRIPTHASH nSoundEntryHash, const char *pSample,
  59. float flVolume, float flAttenuation, int nSeed, int iFlags = 0, int iPitch = PITCH_NORM,
  60. const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
  61. virtual int EmitSound( IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSoundEntry, HSOUNDSCRIPTHASH nSoundEntryHash, const char *pSample,
  62. float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags = 0, int iPitch = PITCH_NORM,
  63. const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
  64. virtual void EmitSentenceByIndex( IRecipientFilter& filter, int iEntIndex, int iChannel, int iSentenceIndex,
  65. float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags = 0, int iPitch = PITCH_NORM,
  66. const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
  67. virtual void StopSound( int iEntIndex, int iChannel, const char *pSample, HSOUNDSCRIPTHASH nSoundEntryHash = SOUNDEMITTER_INVALID_HASH ) = 0;
  68. // stop all active sounds (client only)
  69. virtual void StopAllSounds(bool bClearBuffers) = 0;
  70. // Set the room type for a player (client only)
  71. virtual void SetRoomType( IRecipientFilter& filter, int roomType ) = 0;
  72. // Set the dsp preset for a player (client only)
  73. virtual void SetPlayerDSP( IRecipientFilter& filter, int dspType, bool fastReset ) = 0;
  74. // emit an "ambient" sound that isn't spatialized
  75. // only available on the client, assert on server
  76. virtual int EmitAmbientSound( const char *pSample, float flVolume, int iPitch = PITCH_NORM, int flags = 0, float soundtime = 0.0f ) = 0;
  77. // virtual EntChannel_t CreateEntChannel() = 0;
  78. virtual float GetDistGainFromSoundLevel( soundlevel_t soundlevel, float dist ) = 0;
  79. // Client .dll only functions
  80. virtual int GetGuidForLastSoundEmitted() = 0;
  81. virtual bool IsSoundStillPlaying( int guid ) = 0;
  82. virtual void StopSoundByGuid( int guid, bool bForceSync = false ) = 0;
  83. // Set's master volume (0.0->1.0)
  84. virtual void SetVolumeByGuid( int guid, float fvol ) = 0;
  85. // Retrieves list of all active sounds
  86. virtual void GetActiveSounds( CUtlVector< SndInfo_t >& sndlist ) = 0;
  87. virtual void PrecacheSentenceGroup( const char *pGroupName ) = 0;
  88. virtual void NotifyBeginMoviePlayback() = 0;
  89. virtual void NotifyEndMoviePlayback() = 0;
  90. virtual bool IsMoviePlaying() = 0;
  91. virtual bool GetSoundChannelVolume( const char* sound, float &flVolumeLeft, float &flVolumeRight ) = 0;
  92. virtual float GetElapsedTimeByGuid( int guid ) = 0;
  93. // engine capable of playing sounds?
  94. virtual bool GetPreventSound( void ) = 0;
  95. virtual void SetReplaySoundFade( float flReplayVolume ) = 0;
  96. virtual float GetReplaySoundFade()const = 0;
  97. #if defined( _GAMECONSOLE )
  98. virtual void UnloadSound( const char *pSample ) = 0;
  99. #endif
  100. };
  101. #endif // IENGINESOUND_H