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.

107 lines
2.8 KiB

  1. /******************************************************************************
  2. * BackendInt.h *
  3. *--------------*
  4. * Internal defs for Backend
  5. *------------------------------------------------------------------------------
  6. * Copyright (C) 2000 Microsoft Corporation Date: 03/02/00
  7. * All Rights Reserved
  8. *
  9. ********************************************************************* PACOG ***/
  10. #ifndef __BACKENDINT_H_
  11. #define __BACKENDINT_H_
  12. #include "backend.h"
  13. #include <vector>
  14. struct Epoch;
  15. struct NewF0Struct;
  16. class CSynth
  17. {
  18. friend class COlaBuf;
  19. friend class CSpeakerData;
  20. public:
  21. CSynth();
  22. ~CSynth();
  23. int LpcAnalysis (int iSampFreq, int iOrder);
  24. int FindPrecedent ();
  25. void GetNewF0 (std::vector<NewF0Struct>* pvNewF0, double* pdTime, double* pdRunTime );
  26. protected:
  27. double* GetDurbinCoef(double* data, int nData);
  28. void FreeLpcCoef();
  29. // Read from the input files
  30. double m_dRunTimeLimit;
  31. double m_dGain; // Gain to aply to the whole segment
  32. // Read from the database
  33. int m_iNumSamples;
  34. double* m_pdSamples;
  35. int m_iNumEpochs;
  36. Epoch* m_pEpochs;
  37. // Computed for synthesis
  38. double* m_pdSynEpochs; // Synthesis epoch track
  39. int* m_piMapping;
  40. double* m_pdGainVect;
  41. int m_iNumSynEpochs;
  42. // For lpc synthesis
  43. double** m_ppdLpcCoef;
  44. int m_iLpcOrder;
  45. };
  46. class COlaBuf
  47. {
  48. public:
  49. COlaBuf(bool fRtips = false);
  50. ~COlaBuf();
  51. int Init ( int sampFreq);
  52. int FillBuffer ( CSynth* unit, int periodNum, double gain);
  53. int NextPeriod (int periodLen, double** samples);
  54. private:
  55. enum {WindowFirstHalf, WindowSecondHalf};
  56. static const double m_iDefaultPeriod;
  57. int GetWindowedSignal (int whichBuffer, int periodLength, double** windowed, int* nWindowed);
  58. void HalfHanning (double* x, int xLen, double ampl, int whichHalf);
  59. struct CBuffer {
  60. double* m_pdSamples;
  61. int m_iNumSamples;
  62. int m_iCenter;
  63. double m_dDelay;
  64. } m_aBuffer[2];
  65. int m_iSampFreq;
  66. bool m_fRtips;
  67. // How to dither unvoiced regions
  68. int m_iRepetitions;
  69. int m_iInvert;
  70. };
  71. class CTips
  72. {
  73. public:
  74. static enum {LpTips = 1, RTips= 2};
  75. virtual ~CTips() {};
  76. virtual void Init (int iSampFormat, int iSampFreq) = 0;
  77. virtual void SetGain (double dGain) = 0;
  78. virtual void NewSentence (float* pfF0, int iNumF0, int iF0SampFreq) = 0;
  79. virtual int SynthesizeUnit (CSynth* pUnit, short** ppnSamples, int* piNumSamples) = 0;
  80. static CTips* ClassFactory(int iOptions);
  81. };
  82. #endif