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.

96 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef ENVMICROPHONE_H
  7. #define ENVMICROPHONE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CBaseFilter;
  12. const int SF_MICROPHONE_SOUND_COMBAT = 0x01;
  13. const int SF_MICROPHONE_SOUND_WORLD = 0x02;
  14. const int SF_MICROPHONE_SOUND_PLAYER = 0x04;
  15. const int SF_MICROPHONE_SOUND_BULLET_IMPACT = 0x08;
  16. const int SF_MICROPHONE_SWALLOW_ROUTED_SOUNDS = 0x10;
  17. const int SF_MICROPHONE_SOUND_EXPLOSION = 0x20;
  18. const int SF_MICROPHONE_IGNORE_NONATTENUATED = 0x40;
  19. // Return codes from SoundPlayed
  20. enum MicrophoneResult_t
  21. {
  22. MicrophoneResult_Ok = 0,
  23. MicrophoneResult_Swallow, // The microphone swallowed the sound. Don't play it.
  24. MicrophoneResult_Remove, // The microphone should be removed from the list of microphones.
  25. };
  26. //-----------------------------------------------------------------------------
  27. // Purpose:
  28. //-----------------------------------------------------------------------------
  29. class CEnvMicrophone : public CPointEntity
  30. {
  31. DECLARE_CLASS( CEnvMicrophone, CPointEntity );
  32. public:
  33. ~CEnvMicrophone();
  34. void Spawn(void);
  35. void Activate(void);
  36. void OnRestore( void );
  37. void ActivateSpeaker( void );
  38. void Think(void);
  39. bool CanHearSound(CSound *pSound, float &flVolume);
  40. bool CanHearSound( int entindex, soundlevel_t soundlevel, float &flVolume, const Vector *pOrigin );
  41. void SetSensitivity( float flSensitivity );
  42. void SetMaxRange( float flMaxRange );
  43. void SetSpeakerName( string_t iszSpeakerName );
  44. void SetSpeaker( string_t iszSpeakerName, EHANDLE hSpeaker );
  45. void InputEnable( inputdata_t &inputdata );
  46. void InputDisable( inputdata_t &inputdata );
  47. void InputSetSpeakerName( inputdata_t &inputdata );
  48. DECLARE_DATADESC();
  49. // Hook for the sound system to tell us when a sound's been played. Returns true if it's to swallow the passed in sound.
  50. static bool OnSoundPlayed( int entindex, const char *soundname, soundlevel_t soundlevel,
  51. float flVolume, int iFlags, int iPitch, const Vector *pOrigin, float soundtime, CUtlVector< Vector >& soundorigins );
  52. static void OnSoundStopped( const char *soundname );
  53. private:
  54. // Per-microphone notification that a sound has played.
  55. MicrophoneResult_t SoundPlayed( int entindex, const char *soundname, soundlevel_t soundlevel,
  56. float flVolume, int iFlags, int iPitch, const Vector *pOrigin, float soundtime, CUtlVector< Vector >& soundorigins );
  57. void SoundStopped( const char *soundname );
  58. bool m_bDisabled; // If true, the microphone will not measure sound.
  59. EHANDLE m_hMeasureTarget; // Point at which to measure sound level.
  60. int m_nSoundMask; // Which sound types we are interested in.
  61. float m_flSensitivity; // 0 = deaf, 1 = default, 10 = maximum sensitivity
  62. float m_flSmoothFactor; // 0 = no smoothing of samples, 0.9 = maximum smoothing
  63. float m_flMaxRange; // Maximum sound hearing range, irrelevant of attenuation
  64. string_t m_iszSpeakerName; // Name of a speaker to output any heard sounds through
  65. EHANDLE m_hSpeaker; // Speaker to output any heard sounds through
  66. bool m_bAvoidFeedback;
  67. int m_iSpeakerDSPPreset; // Speaker DSP preset to use when this microphone is enabled
  68. string_t m_iszListenFilter;
  69. CHandle<CBaseFilter> m_hListenFilter;
  70. COutputFloat m_SoundLevel; // Fired when the sampled volume level changes.
  71. COutputEvent m_OnRoutedSound; // Fired when a sound has been played through our speaker
  72. COutputEvent m_OnHeardSound; // Heard sound.
  73. char m_szLastSound[256];
  74. };
  75. #endif // ENVMICROPHONE_H