Counter Strike : Global Offensive Source Code
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.

164 lines
4.9 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef SFMPHONEMEEXTRACTOR_H
  7. #define SFMPHONEMEEXTRACTOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "phonemeextractor/PhonemeExtractor.h"
  12. #include "tier1/UtlString.h"
  13. #include "sentence.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. class CDmeSoundClip;
  18. class CDmeGameSound;
  19. class CDmeAnimationSet;
  20. class CDmeFilmClip;
  21. struct LogPreview_t;
  22. //-----------------------------------------------------------------------------
  23. // Info about a particular phoneme to extract
  24. //-----------------------------------------------------------------------------
  25. class CExtractInfo
  26. {
  27. public:
  28. CExtractInfo();
  29. CExtractInfo( const CExtractInfo& src );
  30. ~CExtractInfo();
  31. void ClearTags();
  32. // Filled in by caller
  33. CDmeSoundClip *m_pClip;
  34. CDmeGameSound *m_pSound;
  35. CUtlString m_sHintText;
  36. bool m_bUseSentence;
  37. bool m_bFullPathInSoundName;
  38. // Filled in by Extract()
  39. CSentence m_Sentence;
  40. float m_flDuration;
  41. bool m_bSentenceValid;
  42. // Must be passed in when calling for Apply, will be created and passed back for Extract
  43. CUtlVector< CBasePhonemeTag * > m_ApplyTags;
  44. };
  45. //-----------------------------------------------------------------------------
  46. // Extraction type
  47. //-----------------------------------------------------------------------------
  48. enum SFMPhonemeExtractType_t
  49. {
  50. EXTRACT_WIPE_RANGE = 0, // Wipe logs from start of first selected clip to end of last selected clip
  51. EXTRACT_WIPE_CLIP, // Wipe all log entries (for facial controls) over entire clip
  52. EXTRACT_WIPE_SOUNDS, // Leave logs untouched, except underneath each selected .wav file
  53. NUM_EXTRACT_WIPE_TYPES,
  54. };
  55. //-----------------------------------------------------------------------------
  56. // Filter type
  57. //-----------------------------------------------------------------------------
  58. enum SFMPhonemeFilterType_t
  59. {
  60. EXTRACT_FILTER_HOLD, // hold for phoneme duration
  61. EXTRACT_FILTER_LINEAR, // linearly blend from phoneme start to next phoneme
  62. EXTRACT_FILTER_FIXED_WIDTH, // hold and linearly falloff before and after
  63. NUM_EXTRACT_FILTER_TYPES,
  64. };
  65. //-----------------------------------------------------------------------------
  66. // Extraction information
  67. //-----------------------------------------------------------------------------
  68. struct ExtractDesc_t
  69. {
  70. SFMPhonemeExtractType_t m_nExtractType;
  71. SFMPhonemeFilterType_t m_nFilterType;
  72. bool m_bCreateBookmarks;
  73. CUtlVector< CExtractInfo > m_WorkList; // One or more .wavs to extract from
  74. CUtlVector< LogPreview_t* > m_ControlList; // List of facial controls
  75. CDmeFilmClip *m_pMovie;
  76. CDmeFilmClip *m_pShot;
  77. CDmeAnimationSet *m_pSet;
  78. float m_flSampleRateHz;
  79. float m_flSampleFilterSize;
  80. };
  81. //-----------------------------------------------------------------------------
  82. // Main interface for phoneme extraction
  83. //-----------------------------------------------------------------------------
  84. class ISFMPhonemeExtractor
  85. {
  86. public:
  87. virtual ~ISFMPhonemeExtractor() {};
  88. virtual bool Init() = 0;
  89. virtual void Shutdown() = 0;
  90. virtual int GetAPICount() = 0;
  91. virtual void GetAPIInfo( int nIndex, CUtlString* pPrintName, PE_APITYPE *pAPIType ) = 0;
  92. virtual void Extract( const PE_APITYPE& apiType, ExtractDesc_t& info, bool bWritePhonemesToWavFiles = false ) = 0;
  93. virtual void ReApply( ExtractDesc_t& info ) = 0;
  94. virtual bool GetSentence( CDmeGameSound *pGameSound, CSentence& sentence ) = 0;
  95. };
  96. extern ISFMPhonemeExtractor *sfm_phonemeextractor;
  97. //-----------------------------------------------------------------------------
  98. // inline methods of CExtractInfo
  99. //-----------------------------------------------------------------------------
  100. inline CExtractInfo::CExtractInfo() : m_pClip( 0 ), m_pSound( 0 ),
  101. m_bSentenceValid( false ), m_bUseSentence( false ), m_bFullPathInSoundName( false ), m_flDuration( 0.0f )
  102. {
  103. }
  104. inline CExtractInfo::CExtractInfo( const CExtractInfo& src )
  105. {
  106. m_pClip = src.m_pClip;
  107. m_pSound = src.m_pSound;
  108. m_sHintText = src.m_sHintText;
  109. m_Sentence = src.m_Sentence;
  110. m_bSentenceValid = src.m_bSentenceValid;
  111. m_bUseSentence = src.m_bUseSentence;
  112. m_bFullPathInSoundName = src.m_bFullPathInSoundName;
  113. m_flDuration = src.m_flDuration;
  114. ClearTags();
  115. for ( int i = 0; i < src.m_ApplyTags.Count(); ++i )
  116. {
  117. CBasePhonemeTag *newTag = new CBasePhonemeTag( *src.m_ApplyTags[ i ] );
  118. m_ApplyTags.AddToTail( newTag );
  119. }
  120. }
  121. inline CExtractInfo::~CExtractInfo()
  122. {
  123. ClearTags();
  124. }
  125. inline void CExtractInfo::ClearTags()
  126. {
  127. for ( int i = 0; i < m_ApplyTags.Count(); ++i )
  128. {
  129. delete m_ApplyTags[ i ];
  130. }
  131. m_ApplyTags.RemoveAll();
  132. }
  133. #endif // PHONEMEEXTRACTOR_H