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