Leaked source code of windows server 2003
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.

49 lines
1.2 KiB

  1. #ifndef _AGC_H
  2. #define _AGC_H
  3. #include "mixer.h"
  4. #define PEAKARRAYSIZE 5
  5. #define AGC_INCREMENT 10000 // approx 1/6 of the mixer range
  6. #define AGC_MAXVOL 65535 // highest mixer volume setting
  7. #define AGC_HIGHVOL 24576 // minimum for loud volume see Update() method
  8. #define AGC_PEAKVOL 32767 // peak sample value (could also be 32768)
  9. #define AGC_DEFAULT_THRESH 16384
  10. #define AGC_NOUPDATE 0
  11. #define AGC_UPDATE_LOWERVOL 1
  12. #define AGC_UPDATE_RAISEVOL 2
  13. class AGC
  14. {
  15. private:
  16. CMixerDevice *m_pMixer;
  17. WORD m_aPeaks[PEAKARRAYSIZE];
  18. int m_cPeaks; // how many have been inserted into above array
  19. WORD m_wCurrentPeak; // max value of last second
  20. DWORD m_dwCollectionTime; // amount of sampling collected so far
  21. WORD m_wThreshStrength; // the minimum we are trying to target
  22. DWORD m_dwLastVolumeSetting; // last known volume setting
  23. int m_nLastUpdateResult;
  24. inline BOOL RaiseVolume();
  25. inline BOOL LowerVolume();
  26. inline BOOL HasVolumeChanged();
  27. public:
  28. AGC(CMixerDevice *pMixer);
  29. void SetMixer(CMixerDevice *pMixer);
  30. inline void SetThresholdStrength(WORD wStrength) {m_wThreshStrength=wStrength;}
  31. int Update(WORD wPeakStrength, DWORD dwLengthMS);
  32. void Reset();
  33. };
  34. #endif