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.

74 lines
2.6 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_MIXER_PRIVATE_H
  14. #define SND_WAVE_MIXER_PRIVATE_H
  15. #pragma once
  16. #include "snd_audio_source.h"
  17. #include "snd_wave_mixer.h"
  18. #include "sound_private.h"
  19. #include "snd_wave_source.h"
  20. class IWaveData;
  21. abstract_class CAudioMixerWave : public CAudioMixer
  22. {
  23. public:
  24. CAudioMixerWave( IWaveData *data );
  25. virtual ~CAudioMixerWave( void );
  26. int MixDataToDevice( IAudioDevice *pDevice, channel_t *pChannel, int sampleCount, int outputRate, int outputOffset );
  27. int SkipSamples( channel_t *pChannel, int sampleCount, int outputRate, int outputOffset );
  28. bool ShouldContinueMixing( void );
  29. virtual void Mix( IAudioDevice *pDevice, channel_t *pChannel, void *pData, int outputOffset, int inputOffset, fixedint fracRate, int outCount, int timecompress ) = 0;
  30. virtual int GetOutputData( void **pData, int sampleCount, char copyBuf[AUDIOSOURCE_COPYBUF_SIZE] );
  31. virtual CAudioSource* GetSource( void );
  32. virtual int GetSamplePosition( void );
  33. virtual float ModifyPitch( float pitch );
  34. virtual float GetVolumeScale( void );
  35. // Move the current position to newPosition
  36. virtual void SetSampleStart( int newPosition );
  37. // End playback at newEndPosition
  38. virtual void SetSampleEnd( int newEndPosition );
  39. virtual void SetStartupDelaySamples( int delaySamples );
  40. // private helper routines
  41. char * LoadMixBuffer( channel_t *pChannel, int sample_load_request, int *psamples_loaded, char copyBuf[AUDIOSOURCE_COPYBUF_SIZE] );
  42. int MixDataToDevice_( IAudioDevice *pDevice, channel_t *pChannel, int sampleCount, int outputRate, int outputOffset, bool bSkipAllSamples );
  43. int GetSampleLoadRequest( double rate, int sampleCount, bool bInterpolated_pitch );
  44. virtual bool IsReadyToMix();
  45. virtual int GetPositionForSave() { return GetSamplePosition(); }
  46. virtual void SetPositionFromSaved( int savedPosition ) { SetSampleStart(savedPosition); }
  47. protected:
  48. double m_fsample_index; // index of next sample to output
  49. int m_sample_max_loaded; // count of total samples loaded - ie: the index of
  50. // the next sample to be loaded.
  51. int m_sample_loaded_index; // index of last sample loaded
  52. IWaveData *m_pData;
  53. double m_forcedEndSample;
  54. bool m_finished;
  55. int m_delaySamples;
  56. };
  57. #endif // SND_WAVE_MIXER_PRIVATE_H