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.

128 lines
4.3 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // LocalTTSEngineSite.h: interface for the CLocalTTSEngineSite class.
  3. //
  4. // Created by JOEM 04-2000
  5. // Copyright (C) 2000 Microsoft Corporation
  6. // All Rights Reserved
  7. //
  8. /////////////////////////////////////////////////////// JOEM 4-2000 //
  9. #if !defined(AFX_LOCALTTSENGINESITE_H__70B0DA93_23F5_4F17_B525_4027F78AF195__INCLUDED_)
  10. #define AFX_LOCALTTSENGINESITE_H__70B0DA93_23F5_4F17_B525_4027F78AF195__INCLUDED_
  11. #include <sapiddk.h>
  12. #include "tsm.h"
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif // _MSC_VER > 1000
  16. //-------------------------------------------
  17. // Translate -10 <--> +10 rate control to
  18. // 10th root of three rate scale
  19. //-------------------------------------------
  20. enum USER_RATE_VALUE
  21. {
  22. MIN_RATE = -10,
  23. BASE_RATE = 0,
  24. MAX_RATE = 10,
  25. };
  26. const double g_dRateScale[] =
  27. {
  28. 1.0,
  29. 1.1161231740339044344426141383771, // 3 ^ 1/10
  30. 1.2457309396155173259666803366403,
  31. 1.3903891703159093404852542946161,
  32. 1.5518455739153596742733451355167,
  33. 1.7320508075688772935274463415059,
  34. 1.9331820449317627515248789432662,
  35. 2.1576692799745930995549489159803,
  36. 2.4082246852806920462855086141912,
  37. 2.6878753795222865835819210737269,
  38. 3,
  39. };
  40. struct Event
  41. {
  42. SPEVENT event;
  43. Event* pPrev;
  44. Event* pNext;
  45. };
  46. class CLocalTTSEngineSite : public ISpTTSEngineSite
  47. {
  48. public:
  49. CLocalTTSEngineSite();
  50. ~CLocalTTSEngineSite();
  51. public:
  52. //--- IUnknown --------------------------------------
  53. STDMETHOD(QueryInterface) ( REFIID iid, void** ppvObject );
  54. STDMETHOD_(ULONG, AddRef)(void);
  55. STDMETHOD_(ULONG, Release) (void);
  56. //--- ISpTTSEngineSite --------------------------------------
  57. STDMETHOD(GetEventInterest)( ULONGLONG * pullEventInterest )
  58. { return m_pMainOutputSite->GetEventInterest(pullEventInterest); }
  59. STDMETHOD(GetRate)( long* plRateAdjust );
  60. STDMETHOD(GetSkipInfo)( SPVSKIPTYPE* peType, long* plNumItems );
  61. STDMETHOD(CompleteSkip)( long lNumSkipped );
  62. STDMETHOD(GetVolume)( USHORT* punVolume );
  63. STDMETHOD(AddEvents)(const SPEVENT* pEventArray, ULONG ulCount );
  64. STDMETHOD(Write)( const void* pBuff, ULONG cb, ULONG *pcbWritten );
  65. STDMETHOD_(DWORD, GetActions)( void );
  66. //--- CLocalTTSEngineSite --------------------------------------
  67. void SetOutputSite(ISpTTSEngineSite* pOutputSite);
  68. STDMETHOD(SetBufferSize)(const ULONG ulSeconds);
  69. STDMETHOD(SetOutputFormat)(const GUID * pOutputFormatId, const WAVEFORMATEX *pOutputFormat);
  70. void UpdateBytesWritten()
  71. { m_ullPreviousBytesReceived = m_ullTotalBytesReceived; }
  72. private:
  73. STDMETHOD(WriteBuffer)();
  74. STDMETHOD(WriteToSAPI)( const void* pvBuff, const ULONG cb, bool* pfAbort );
  75. void ComputeRateAdj(const long lRate, float* flRate);
  76. STDMETHOD(ApplyGain)(const void* pvInBuff, void** ppvOutBuff, const int iNumSamples);
  77. STDMETHOD(SendEvents)();
  78. void RescheduleEvents(Event* pStart);
  79. void FlushEvents(const ULONG cb);
  80. private:
  81. volatile LONG m_vcRef;
  82. // output vars
  83. ISpTTSEngineSite* m_pMainOutputSite;
  84. const GUID* m_pOutputFormatId;
  85. WAVEFORMATEX* m_pOutputFormat;
  86. // audio buffer
  87. char* m_pcBuffer;
  88. ULONG m_ulBufferBytes;
  89. ULONG m_ulBufferSeconds;
  90. ULONG m_ulMinBufferShift;
  91. ULONG m_ulDataEnd;
  92. ULONG m_ulCurrentByte;
  93. ULONG m_ulSkipForward;
  94. // eventing managers
  95. Event* m_pEventQueue;
  96. Event* m_pCurrentEvent;
  97. Event* m_pLastEvent;
  98. // event ullAudioStreamOffset managers
  99. ULONGLONG m_ullTotalBytesReceived; // sums every byte as they come in
  100. ULONGLONG m_ullPreviousBytesReceived; // sums every byte of previous ::Write calls
  101. ULONGLONG m_ullBytesWritten; // sums every byte written (before rate adj)
  102. ULONGLONG m_ullBytesWrittenToSAPI; // sums every byte written to SAPI (differs due to rate change)
  103. LONG m_lTotalBytesSkipped; // cumulative skipped, plus or minus
  104. // rate changer
  105. CTsm* m_pTsm;
  106. float m_flRateAdj;
  107. double m_flVol;
  108. };
  109. #endif // !defined(AFX_LOCALTTSENGINESITE_H__70B0DA93_23F5_4F17_B525_4027F78AF195__INCLUDED_)