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.

78 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. bool IsStereoWav( void );
  36. int ConvertLoopedPosition( int samplePosition );
  37. int SampleCount( void );
  38. virtual float GetRunningLength( void )
  39. {
  40. if ( m_rate > 0.0 )
  41. {
  42. return (float)SampleCount() / m_rate;
  43. }
  44. return 0.0f; }
  45. CSentence *GetSentence( void );
  46. protected:
  47. // returns the loop start from a cue chunk
  48. int ParseCueChunk( IterateRIFF &walk );
  49. void Init( const char *pHeaderBuffer, int headerSize );
  50. int m_bits;
  51. int m_rate;
  52. int m_channels;
  53. int m_format;
  54. int m_sampleSize;
  55. int m_loopStart;
  56. int m_sampleCount;
  57. private:
  58. char *m_pHeader;
  59. CSentence m_Sentence;
  60. };
  61. #endif // SND_WAVE_SOURCE_H