Source code of Windows XP (NT5)
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.

70 lines
2.8 KiB

  1. /******************************************************************************
  2. * CFmtConvert.h *
  3. *---------------*
  4. * Declarations of CFmtConvert class.
  5. *------------------------------------------------------------------------------
  6. * Copyright (C) 2000 Microsoft Corporation Date: 05/03/00
  7. * All Rights Reserved
  8. *
  9. ********************************************************************** DING ***/
  10. #ifndef _FMTCONVERT_H_
  11. #define _FMTCONVERT_H_
  12. #include <windows.h>
  13. #include <mmreg.h>
  14. // #define FILTER_LEN_2 .0005 //(sec)
  15. //--- class declare
  16. class CFmtConvert
  17. {
  18. public:
  19. CFmtConvert(double dHalfFilterLen = 0.0005);
  20. ~CFmtConvert();
  21. void SetInputFormat (WAVEFORMATEX* userWavFormat);
  22. void SetOutputFormat (WAVEFORMATEX* userWavFormat);
  23. HRESULT ConvertSamples (const void* pvInSamples, int iInSampleLen, void** pvOutSamples, int* iOutSampleLen);
  24. HRESULT FlushLastBuff (void** ppvOutSamples, int* piOutSampleLen);
  25. private:
  26. //-- mono & stereo
  27. HRESULT SplitStereo (short* pnInSample, int* iSamplesLen, short** pnLeftSamples, short** pnRightSamples);
  28. HRESULT MergeStereo (short* pnLeftSamples, short* pnRightSamples, int *iSamplesLen, short** pnOutSamples);
  29. HRESULT Stereo2Mono (short* pnInSample, int* iSamplesLen, short** pnOutSample);
  30. HRESULT Mono2Stereo (short* pnInSample, int* iSamplesLen, short** pnOutSample);
  31. //-- precission conversions
  32. double* Short2Double (short* pnIn, int iLen);
  33. short* Double2Short (double* pdIn, int iLen);
  34. //-- resample
  35. HRESULT Resampling (double* pdInSamples, int iInNumSamples, double *pdMemory,
  36. double** ppdOutSamples, int* piOutNumSamples);
  37. HRESULT CreateResamplingFilter (int iInSampFreq, int iOutSampFreq);
  38. void DeleteResamplingFilter ();
  39. void FindResampleFactors (int iInSampFreq, int iOutSampFreq);
  40. double* WindowedLowPass (double dCutOff, double dGain);
  41. //-- memory
  42. HRESULT CreateBuffers ();
  43. void DeleteBuffers ();
  44. enum BlockCntrl_t { FMTCNVT_FIRST, FMTCNVT_BLOCK, FMTCNVT_LAST };
  45. WAVEFORMATEX m_OutWavFormat;
  46. WAVEFORMATEX m_InWavFormat;
  47. BOOL m_fResetFilter;
  48. BlockCntrl_t m_eChunkStatus;
  49. int m_iUpFactor;
  50. int m_iDownFactor;
  51. int m_iFilterHalf;
  52. int m_iFilterLen;
  53. int m_iBuffLen;
  54. double m_dHalfFilterLen;
  55. double* m_pdFilterCoef;
  56. double* m_pdLeftMemory;
  57. double* m_pdRightMemory;
  58. };
  59. #endif