API参考

更改构建设置

要从C++代码调用CRIWARE ADX LipSync插件API,您需要修改项目的模块文件 以添加对CriWareAdxLipSync模块和CriWareRuntime模块的依赖关系。
public class MyProject : ModuleRules
{
public MyProject(TargetInfo Target)
{
/* CriWareAdxLipSync */
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "CriWareRuntime", "CriWareAdxLipSync"});
}
}

include(包含)头文件

CRIWARE ADX LipSync插件API定义于多个头文件。
  • Plugins/Runtime/CriWare/CriWareAdxLipSync/Source/CriWareAdxLipSync/Public/LipsAtomAnalyzer.h : API for UE4 C++
  • Plugins/Runtime/CriWare/CriWare/Source/CriWareRuntime/Public/CriAdxLipSyncApi.h : C-style API

FCriLipsMouthInfo

存储口形信息的结构体。其成员的定义如下。

float LipWidth

嘴巴宽度(0.0f ~ 1.0f)

float LipHeight

嘴巴高度(0.0f 以上 1.0f 以下)

float TonguePosition

舌头位置(0.0f 以上 1.0f 以下)

bool IsLipWidthReleased

嘴巴宽度是否正在转换至闭合状态

bool IsLipHeightReleased

嘴巴高度是否正在转换至闭合状态

bool IsTonguePositionReleased

舌头位置是否正在转换至闭合状态

FCriLipsMorphTargetBlendAmountAsJapanese

存储口形信息的结构体。其成员的定义如下。

float A

变形目标 "A"([ɑ]) 的混合量(0.0f 以上 1.0f 以下)

float I

变形目标 "I"([i]) 的混合量(0.0f 以上 1.0f 以下)

float U

变形目标 "U"([u]) 的混合量(0.0f 以上 1.0f 以下)

float E

变形目标 "E"([ɛ]) 的混合量(0.0f 以上 1.0f 以下)

float O

变形目标 "O"([ɔ]) 的混合量(0.0f 以上 1.0f 以下)

ULipsAtomAnalyzer

ULipsAtomAnalyzer 是创建或获取口形数据的类。用户从此类创建对象,并必须绑定UAtomComponent。 ULipsAtomAnalyzer对象可以对其绑定的UAtomComponent对象播放的音频进行自动实时解析,以创建或获取口形数据。 用户可以通过ULipsAtomAnalyzer对象的接口获取口形数据。
本类提供以下的接口。

Init(const int32 MaxInputSamplingRate)

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
void Init(const int32 MaxInputSamplingRate);

初始化口形解析对象。
调用此函数时,Atom音频解析模块 LipsAtomAnalyzer r
将创建于CRI 运行库内部。同时分配其他必要的内部资源。
不调用此函数将无法获取口形数据。
参数
MaxInputSamplingRate可输入的最大采样率

GetInfo()

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
FCriLipsMouthInfo GetInfo () const;

获取口形数据。
获取通过解析音频数据所取得的口形数据。

返回
包含输入音频的解析结果的口形数据

GetMorphTargetBlendAmountAsJapanese()

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
FCriLipsMorphTargetBlendAmountAsJapanese GetMorphTargetBlendAmountAsJapanese() const;

获取日语五元音变形目标的混合量。
获取通过解析音频数据所取得的日语五元音变形目标的混合量。

返回
包含输入音频的解析结果的日语五元音变形目标的混合量

GetVolume()

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
float GetVolume() const;

获取音量
获取已解析的音频数据(示例)的音量(dB)。

返回
解析示例的音量(dB)

SetSamplingRate(const int SamplingRateHz)

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
void SetSamplingRate(const int SamplingRateHz);

设置采样频率。
设置解析対象的音频数据的采样频率。
请在播放音频之前,设置波形数据的采样频率。
调用此函数将清除内部状态。
可解析的采样频率为 16000 Hz或以上。
参数
SamplingRate采样频率
返回
设置成功时为true,失败时为false

SetSilenceThreshold(const float VolumeDb)

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
void SetSilenceThreshold(const float VolumeDb);

设置被判断为静音时的音量阈值。
将解析对象的音频数据判断为静音时的最大音量(dB)设为0以下的值。
预设为-60dB。
参数
VolumeDb最大音量(dB)
返回
设置成功时为true,失败时为false

GetSilenceThreshold()

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
float GetSilenceThreshold() const;

设置被判断为静音时的音量阈值。
从CriAtomExPlayer输出的解析对象示例被判断为静音时,获取其最大音量(dB)。
发生错误时返回比0更大的值。

返回
最大音量(dB)

IsAtSilence()

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
bool IsAtSilence() const;

获取是否没有发声和嘴巴是否闭合。
获取当前的状态是否未有发出声音(嘴巴是否闭合)。
没有播放音频时、正在播放静音时或播放音频后经过了一段时间等情况下,
此函数将返回true。

返回
嘴巴闭合时为 true,张开时为 false

GetInfoAtSilence()

UFUNCTION(BlueprintCallable, Category = "CriLipsAnalyzerCommon")
FCriLipsMouthInfo GetInfoAtSilence() const;

静音时获取口形数据。
可以获取静音状态( IsAtSilence() 返回 true 的状态)
获取闭合的口形数据。

返回
闭合的口形数据

Attach(UAtomComponent* InAtomComponent)

UFUNCTION(BlueprintCallable, Category = "LipsAtomAnalyzer")
void Attach(UAtomComponent* InAtomComponent);

挂载至AtomComponent。
对解析対象的 AtomComponent 挂载分析器。
调用此函数后,将解析使用AtomComponent播放的音频,
从而可以获取口形数据和日语五元音变形目标的混合量。
如果分析器所挂载的 AtomComponent 正在播放音频,则将被强制停止。
调用此函数时,作为参数指定的 AtomComponent 的状态将立即变为 EAtomComponentStatus::Stop 。
此外,如果分析器已经被挂载到了另一个 AtomComponent 上,则在此函数內部
将强行停止之前的AtomComponent,卸载连接,
并重新挂载到新的AtomComponent上。
参数
AtomComponentAtomComponent对象

Detach()

UFUNCTION(BlueprintCallable, Category = "LipsAtomAnalyzer")
void Detach();

从AtomComponent卸载。
从解析対象的 AtomComponent 卸载分析器。
卸载前的所有已经挂载了的 AtomComponent 的音频播放将全部被强制停止。
请注意, 分析器被卸载的 AtomComponent 状态将
立即变为 EAtomComponentStatus::Stop 。