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.

97 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef SOUND_H
  9. #define SOUND_H
  10. #pragma once
  11. class CAudioMixer;
  12. class CAudioInput
  13. {
  14. public:
  15. // factory to create a suitable audio input for this system
  16. static CAudioInput *Create( void );
  17. // base class needs virtual destructor
  18. virtual ~CAudioInput( void ) {}
  19. // ------------------- interface ------------------------
  20. // Returns the current count of available samples
  21. virtual int SampleCount( void ) = 0;
  22. // returns the size of each sample in bytes
  23. virtual int SampleSize( void ) = 0;
  24. // returns the sampling rate of the data
  25. virtual int SampleRate( void ) = 0;
  26. // returns a pointer to the available data
  27. virtual void *SampleData( void ) = 0;
  28. // release the available data (mark as done)
  29. virtual void SampleRelease( void ) = 0;
  30. // returns the mono/stereo status of this device (true if stereo)
  31. virtual bool IsStereo( void ) = 0;
  32. // begin sampling
  33. virtual void Start( void ) = 0;
  34. // stop sampling
  35. virtual void Stop( void ) = 0;
  36. };
  37. class CAudioSource;
  38. class CAudioOutput
  39. {
  40. public:
  41. // factory to create a suitable audio output for this system
  42. static CAudioOutput *Create( void );
  43. // base class needs virtual destructor
  44. virtual ~CAudioOutput( void ) {}
  45. // ------------------- interface ------------------------
  46. // returns the size of each sample in bytes
  47. virtual int SampleSize( void ) = 0;
  48. // returns the sampling rate of the data
  49. virtual int SampleRate( void ) = 0;
  50. // returns the mono/stereo status of this device (true if stereo)
  51. virtual bool IsStereo( void ) = 0;
  52. // move up to time (time is absolute)
  53. virtual void Update( float dt ) = 0;
  54. virtual void Flush( void ) = 0;
  55. // Hook up a filter to the input channel
  56. virtual void AddSource( CAudioMixer *pSource ) = 0;
  57. virtual void StopSounds( void ) = 0;
  58. virtual void FreeChannel( int channel ) = 0;
  59. virtual int FindSourceIndex( CAudioMixer *pSource ) = 0;
  60. virtual float GetAmountofTimeAhead( void ) = 0;
  61. virtual int GetNumberofSamplesAhead( void ) = 0;
  62. virtual CAudioMixer *GetMixerForSource( CAudioSource *pDevice ) = 0;
  63. };
  64. int AudioResample( void *pInput, int inCount, int inSize, bool inStereo, int inRate,
  65. void *pOutput, int outCount, int outSize, bool outStereo, int outRate );
  66. #endif // SOUND_H