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.

91 lines
3.5 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef IUISOUNDSYSTEM_H
  6. #define IUISOUNDSYSTEM_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #if !defined( SOURCE2_PANORAMA )
  11. #include "audio/iaudiointerface.h"
  12. #endif
  13. #ifdef SUPPORTS_AUDIO
  14. class IAudioOutputStream;
  15. #endif
  16. namespace panorama
  17. {
  18. typedef void * HAUDIOSAMPLE;
  19. //
  20. // Interface that handles sound
  21. //
  22. class IUISoundSystem
  23. {
  24. public:
  25. virtual ~IUISoundSystem() {}
  26. // Play a sound referenced by name.
  27. // flVolume should be 0.0 to 1.0, 0.5 would equal -10DB. volume is modulated by the mixer volume for the specified sound type.
  28. // flVolumePan sets the position on mono samples, or panning on stereo, 0.0 is full left, 1.0 is full right, 0.5 is no attenuation.
  29. // flRepeats sets the number of times to repeat the sound, 0.0f will result in infinite
  30. virtual HAUDIOSAMPLE PlaySound( const char *pchSoundName, ESoundType soundType,
  31. float flVolume = 1.0f, float flVolumePan = 0.5f, float flRepeats = 1.0f ) = 0;
  32. // Set the base volume / panning for the sound sample
  33. virtual void SetSoundSampleVolumePan( HAUDIOSAMPLE hSample, float flVolume, float flVolumePan ) = 0;
  34. // Fade out the sound sample and stop it
  35. virtual void FadeOutAndStopSoundSample( HAUDIOSAMPLE hSample, float flFadeOutSeconds ) = 0;
  36. // Set a volume ramp that will change the volume of the sample smoothly, note that this acts as a filter and scales the volume from
  37. // the base set when playing or with SetSoundSampleVolumePan, the base is not actually modified and still must be set as audible for
  38. // this ramp to have any impact.
  39. virtual void VolumeRampSoundSample( HAUDIOSAMPLE hSample, float flVolumeTarget, float flTransitionSeconds ) = 0;
  40. // retrieves the user-specified sound volume for the specified sound type.
  41. //
  42. // Normally you don't need to use this as PlaySound auto-applies the right volume;
  43. // but it is needed on raw audio streams created with CreateAudioOutputStream.
  44. //
  45. // The value returned here honors the muted state.
  46. virtual float GetSoundVolume( ESoundType soundType ) = 0;
  47. // here you can set the volume for the specified sound type programmatically
  48. virtual void SetSoundVolume( ESoundType soundType, float flVolume ) = 0;
  49. // and you can set a global mute state
  50. virtual void SetSoundMuted( bool bMute ) = 0;
  51. #ifdef SUPPORTS_AUDIO
  52. virtual IAudioOutputStream *CreateAudioOutputStream( int nRate, int nChannels, int nBits ) = 0;
  53. virtual void FreeAudioOutputStream( IAudioOutputStream *pStream ) = 0;
  54. #endif
  55. // Push that the system now requires a larger mix ahead buffer to prevent skipping, "large" is somewhat undefined
  56. // at this level, but you are trading off latency on sounds beginning to get a bigger buffer pre-mixed by miles
  57. // to avoid skipping/stuttering.
  58. virtual void PushAudioBigMixAheadBuffer() = 0;
  59. // Pop that the system now requires a larger mix ahead buffer to prevent skipping, "large" is somewhat undefined
  60. // at this level, but you are trading off latency on sounds beginning to get a bigger buffer pre-mixed by miles
  61. // to avoid skipping/stuttering. Popping moves back towards the lower latency setup once nothing needs the no-skipping
  62. // larger buffer setup.
  63. virtual void PopAudioBigMixAheadBuffer() = 0;
  64. // Give time to audio service
  65. virtual void ServiceAudio() = 0;
  66. // Consider pausing audio based on the last time audio was started. Used when the app loses focus.
  67. virtual void ConsiderPausingAudio() = 0;
  68. };
  69. } // namespace panorama
  70. #endif // IUISOUNDSYSTEM_H