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.

105 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef SOUNDENVELOPE_H
  10. #define SOUNDENVELOPE_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "engine/IEngineSound.h"
  15. class CSoundPatch;
  16. enum soundcommands_t
  17. {
  18. SOUNDCTRL_CHANGE_VOLUME,
  19. SOUNDCTRL_CHANGE_PITCH,
  20. SOUNDCTRL_STOP,
  21. SOUNDCTRL_DESTROY,
  22. };
  23. //Envelope point
  24. struct envelopePoint_t
  25. {
  26. float amplitudeMin, amplitudeMax;
  27. float durationMin, durationMax;
  28. };
  29. //Envelope description
  30. struct envelopeDescription_t
  31. {
  32. envelopePoint_t *pPoints;
  33. int nNumPoints;
  34. };
  35. class IRecipientFilter;
  36. abstract_class CSoundEnvelopeController
  37. {
  38. public:
  39. virtual void SystemReset( void ) = 0;
  40. virtual void SystemUpdate( void ) = 0;
  41. virtual void Play( CSoundPatch *pSound, float volume, float pitch, float flStartTime = 0 ) = 0;
  42. virtual void CommandAdd( CSoundPatch *pSound, float executeDeltaTime, soundcommands_t command, float commandTime, float value ) = 0;
  43. virtual void CommandClear( CSoundPatch *pSound ) = 0;
  44. virtual void Shutdown( CSoundPatch *pSound ) = 0;
  45. virtual CSoundPatch *SoundCreate( IRecipientFilter& filter, int nEntIndex, const char *pSoundName ) = 0;
  46. virtual CSoundPatch *SoundCreate( IRecipientFilter& filter, int nEntIndex, int channel, const char *pSoundName,
  47. float attenuation, float scriptVolume = 1.0f ) = 0;
  48. virtual CSoundPatch *SoundCreate( IRecipientFilter& filter, int nEntIndex, int channel, const char *pSoundName,
  49. float attenuation, const Vector *pSoundOrigin, float scriptVolume = 1.0f ) = 0;
  50. virtual CSoundPatch *SoundCreate( IRecipientFilter& filter, int nEntIndex, int channel, const char *pSoundName,
  51. soundlevel_t soundlevel ) = 0;
  52. virtual CSoundPatch *SoundCreate( IRecipientFilter& filter, int nEntIndex, const EmitSound_t &es ) = 0;
  53. virtual void SoundDestroy( CSoundPatch * ) = 0;
  54. virtual void SoundChangePitch( CSoundPatch *pSound, float pitchTarget, float deltaTime ) = 0;
  55. virtual void SoundChangeVolume( CSoundPatch *pSound, float volumeTarget, float deltaTime ) = 0;
  56. virtual void SoundFadeOut( CSoundPatch *pSound, float deltaTime, bool destroyOnFadeout = false ) = 0;
  57. virtual float SoundGetPitch( CSoundPatch *pSound ) = 0;
  58. virtual float SoundGetVolume( CSoundPatch *pSound ) = 0;
  59. #ifdef CLIENT_DLL
  60. virtual float SoundGetElapsedTime( CSoundPatch *pSound) = 0;
  61. virtual bool SoundIsStillPlaying( CSoundPatch *pSound) = 0;
  62. virtual int SoundGetGuid( CSoundPatch * ) = 0;
  63. #endif
  64. virtual float SoundPlayEnvelope( CSoundPatch *pSound, soundcommands_t soundCommand, envelopePoint_t *points, int numPoints ) = 0;
  65. virtual float SoundPlayEnvelope( CSoundPatch *pSound, soundcommands_t soundCommand, envelopeDescription_t *envelope ) = 0;
  66. virtual void CheckLoopingSoundsForPlayer( CBasePlayer *pPlayer ) = 0;
  67. virtual string_t SoundGetName( CSoundPatch *pSound ) = 0;
  68. virtual string_t SoundGetScriptName( CSoundPatch *pSound ) = 0;
  69. static CSoundEnvelopeController &GetController( void );
  70. virtual void SoundSetCloseCaptionDuration( CSoundPatch *pSound, float flDuration ) = 0;
  71. };
  72. //-----------------------------------------------------------------------------
  73. // Save/restore
  74. //-----------------------------------------------------------------------------
  75. class ISaveRestoreOps;
  76. ISaveRestoreOps *GetSoundSaveRestoreOps( );
  77. #define DEFINE_SOUNDPATCH(name) \
  78. { FIELD_CUSTOM, #name, offsetof(classNameTypedef,name), 1, FTYPEDESC_SAVE, NULL, GetSoundSaveRestoreOps( ), NULL }
  79. #endif // SOUNDENVELOPE_H