UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
Audio2FacePlaybackHandler.h
Go to the documentation of this file.
1// Copyright(c) 2024 grrimgrriefer & DZnnah, see LICENSE for details.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "LipSyncDataA2F.h"
7#include "Audio2FacePlaybackHandler.generated.h"
8
9class UAudioComponent;
10
18UCLASS()
19class VOXTAUTILITY_A2F_API UAudio2FacePlaybackHandler : public UObject
20{
21 GENERATED_BODY()
22
23#pragma region public API
24public:
30 void Initialize(UAudioComponent* audioComponent);
31
38 void GetA2FCurveWeights(TArray<float>& targetArrayRef);
39
46 void Play(const ULipSyncDataA2F* lipsyncData);
47
51 void Stop();
52#pragma endregion
53
54#pragma region UObject overrides
59 virtual void BeginDestroy() override;
60#pragma endregion
61
62#pragma region data
63public:
65 static const int CURVE_COUNT = 52;
67 static const FName CURVE_NAMES[CURVE_COUNT];
68
69private:
70 UPROPERTY()
71 const ULipSyncDataA2F* m_lipsyncData = nullptr;
72
73 UPROPERTY()
74 UAudioComponent* m_audioComponent = nullptr;
75
76 FCriticalSection m_curvesGuard;
77
78 FDelegateHandle m_playbackPercentHandle;
79 FDelegateHandle m_playbackFinishedHandle;
80 TArray<float> m_currentCurves;
81 bool m_forcedNeutral = true;
82#pragma endregion
83
84#pragma region private API
86 void InitNeutralPose();
87
96 void OnAudioPlaybackPercent(const UAudioComponent* audioComponent, const USoundWave* soundWave, float Percent);
97
103 void OnAudioPlaybackFinished(UAudioComponent* audioComponent);
104#pragma endregion
105};
UAudio2FacePlaybackHandler Handles synchronization and playback of Audio2Face lipsync data with audio...
Definition Audio2FacePlaybackHandler.h:20
virtual void BeginDestroy() override
Called when the object is being destroyed.
Definition Audio2FacePlaybackHandler.cpp:127
void Initialize(UAudioComponent *audioComponent)
Register the AudioComponent that will be used to sync the A2F lipsync data.
Definition Audio2FacePlaybackHandler.cpp:65
void GetA2FCurveWeights(TArray< float > &targetArrayRef)
Fetch the curve values for the upcoming frame, mapping to the blendshapes of the ARKit.
Definition Audio2FacePlaybackHandler.cpp:76
static const int CURVE_COUNT
Number of ARKit blendshape curves.
Definition Audio2FacePlaybackHandler.h:65
void Play(const ULipSyncDataA2F *lipsyncData)
Begin playback of the A2F lipsync data along with the audio in the AudioComponent.
Definition Audio2FacePlaybackHandler.cpp:89
void Stop()
Stop the playback and return to a lipsync state (closed mouth).
Definition Audio2FacePlaybackHandler.cpp:113
static const FName CURVE_NAMES[CURVE_COUNT]
Names of the ARKit blendshape curves.
Definition Audio2FacePlaybackHandler.h:9
ULipSyncDataA2F UObject-based container for Audio2Face lipsync data.
Definition LipSyncDataA2F.h:18