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.

101 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //===========================================================================//
  9. #ifndef SND_AUDIO_SOURCE_H
  10. #define SND_AUDIO_SOURCE_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "tier0/platform.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CAudioSource;
  19. class IAudioDevice;
  20. struct channel_t;
  21. //-----------------------------------------------------------------------------
  22. // Purpose: This is an instance of an audio source.
  23. // Mixers are attached to channels and reference an audio source.
  24. // Mixers are specific to the sample format and source format.
  25. // Mixers are never re-used, so they can track instance data like
  26. // sample position, fractional sample, stream cache, faders, etc.
  27. //-----------------------------------------------------------------------------
  28. abstract_class CAudioMixer
  29. {
  30. public:
  31. virtual ~CAudioMixer( void ) {}
  32. // UNDONE: time compress
  33. virtual bool MixDataToDevice( IAudioDevice *pDevice, channel_t *pChannel, int startSample, int sampleCount, int outputRate, bool forward = true ) = 0;
  34. virtual void IncrementSamples( channel_t *pChannel, int startSample, int sampleCount,int outputRate, bool forward = true ) = 0;
  35. virtual bool SkipSamples( IAudioDevice *pDevice, channel_t *pChannel, int startSample, int sampleCount, int outputRate, bool forward = true ) = 0;
  36. virtual CAudioSource *GetSource( void ) = 0;
  37. virtual int GetSamplePosition( void ) = 0;
  38. virtual int GetScubPosition( void ) = 0;
  39. virtual bool SetSamplePosition( int position, bool scrubbing = false ) = 0;
  40. virtual void SetLoopPosition( int position ) = 0;
  41. virtual int GetStartPosition( void ) = 0;
  42. virtual bool GetActive( void ) = 0;
  43. virtual void SetActive( bool active ) = 0;
  44. virtual void SetModelIndex( int index ) = 0;
  45. virtual int GetModelIndex( void ) const = 0;
  46. virtual void SetDirection( bool forward ) = 0;
  47. virtual bool GetDirection( void ) const = 0;
  48. virtual void SetAutoDelete( bool autodelete ) = 0;
  49. virtual bool GetAutoDelete( void ) const = 0;
  50. virtual void SetVolume( float volume ) = 0;
  51. virtual channel_t *GetChannel() = 0;
  52. };
  53. //-----------------------------------------------------------------------------
  54. // Purpose: A source is an abstraction for a stream, cached file, or procedural
  55. // source of audio.
  56. //-----------------------------------------------------------------------------
  57. class CSentence;
  58. abstract_class CAudioSource
  59. {
  60. public:
  61. CAudioSource( void );
  62. virtual ~CAudioSource( void );
  63. // Create an instance (mixer) of this audio source
  64. virtual CAudioMixer *CreateMixer( void ) = 0;
  65. virtual int GetOutputData( void **pData, int samplePosition, int sampleCount, bool forward = true ) = 0;
  66. virtual int SampleRate( void ) = 0;
  67. virtual int SampleSize( void ) = 0;
  68. virtual int SampleCount( void ) = 0;
  69. virtual float TrueSampleSize( void ) = 0;
  70. virtual bool IsLooped( void ) = 0;
  71. virtual bool IsStreaming( void ) = 0;
  72. virtual float GetRunningLength( void ) = 0;
  73. virtual int GetNumChannels() = 0;
  74. virtual CSentence *GetSentence( void ) { return NULL; };
  75. };
  76. extern CAudioSource *AudioSource_Create( const char *pName );
  77. #endif // SND_AUDIO_SOURCE_H