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.

77 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef SND_WAVE_SOURCE_H
  14. #define SND_WAVE_SOURCE_H
  15. #pragma once
  16. #include "snd_audio_source.h"
  17. #include "sentence.h"
  18. class IterateRIFF;
  19. class CAudioSourceWave : public CAudioSource
  20. {
  21. public:
  22. CAudioSourceWave( void );
  23. ~CAudioSourceWave( void );
  24. void Setup( const char *pFormat, int formatSize, IterateRIFF &walk );
  25. virtual int SampleRate( void ) { return m_rate; }
  26. inline int SampleSize( void ) { return m_sampleSize; }
  27. virtual float TrueSampleSize( void );
  28. void *GetHeader( void );
  29. // Legacy
  30. virtual void ParseChunk( IterateRIFF &walk, int chunkName );
  31. virtual void ParseSentence( IterateRIFF &walk );
  32. void ConvertSamples( char *pData, int sampleCount );
  33. bool IsLooped( void ) { return (m_loopStart >= 0) ? true : false; }
  34. bool IsStreaming( void ) { return false; }
  35. int ConvertLoopedPosition( int samplePosition );
  36. int SampleCount( void );
  37. virtual float GetRunningLength( void )
  38. {
  39. if ( m_rate > 0.0 )
  40. {
  41. return (float)SampleCount() / m_rate;
  42. }
  43. return 0.0f; }
  44. CSentence *GetSentence( void );
  45. protected:
  46. // returns the loop start from a cue chunk
  47. int ParseCueChunk( IterateRIFF &walk );
  48. void Init( const char *pHeaderBuffer, int headerSize );
  49. int m_bits;
  50. int m_rate;
  51. int m_channels;
  52. int m_format;
  53. int m_sampleSize;
  54. int m_loopStart;
  55. int m_sampleCount;
  56. private:
  57. char *m_pHeader;
  58. CSentence m_Sentence;
  59. };
  60. #endif // SND_WAVE_SOURCE_H