UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
MessageChunkAudioContainer.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 "LipSyncType.h"
7#include "MessageChunkState.h"
8
9class UImportedSoundWave;
12
22class MessageChunkAudioContainer : public TSharedFromThis<MessageChunkAudioContainer>
23{
24#pragma region public API
25public:
37 MessageChunkAudioContainer(const FString& fullUrl,
38 LipSyncType lipSyncType,
39 TWeakPtr<Audio2FaceRESTHandler> A2FRestHandler,
40 TFunction<void(const MessageChunkAudioContainer* newState)> callback,
41 int id);
42
43 virtual ~MessageChunkAudioContainer() = default;
44
49 void Continue();
50
55 void CleanupData();
56
64 const TArray<uint8>& GetRawAudioData() const;
65
71 template <typename T, typename = std::enable_if_t<std::is_base_of_v<ILipSyncBaseData, T>>>
72 const T* GetLipSyncData() const
73 {
74 return StaticCast<const T*>(m_lipSyncData);
75 }
76
79
85 UImportedSoundWave* GetSoundWave() const;
86
87#pragma endregion
88
89#pragma region data
90public:
92 const int INDEX;
93
96
97private:
98 const FString FULL_DOWNLOAD_URL;
99 const TFunction<void(const MessageChunkAudioContainer* chunk)> ON_STATE_CHANGED;
100
101 TArray<uint8> m_rawAudioData;
102 TWeakPtr<Audio2FaceRESTHandler> m_A2FRestHandler = nullptr;
104
105 // UObjects added to root while this object is alive; as UPROPERTY doesn't work with normal classes
106 UImportedSoundWave* m_soundWave = nullptr;
107 ILipSyncBaseData* m_lipSyncData = nullptr;
108#pragma endregion
109
110#pragma region private API
111private:
113 void DownloadData();
114
116 void ProcessAudioData();
117
123 void GenerateLipSync();
124
130 void UpdateState(MessageChunkState newState);
131#pragma endregion
132};
LipSyncType
LipSyncType All the possible LipSync types that are currently supported by the UnrealVoxta client.
Definition LipSyncType.h:21
MessageChunkState
MessageChunkState All the possible states that an instance of MessageChunkAudioContainer could be in.
Definition MessageChunkState.h:16
@ Idle
Definition MessageChunkState.h:17
Audio2FaceRESTHandler Manages the HTTP REST API for A2F_headless mode.
Definition Audio2FaceRESTHandler.h:18
ILipSyncBaseData Interface for lipsync data containers.
Definition LipSyncBaseData.h:25
MessageChunkState GetCurrentState() const
Definition MessageChunkAudioContainer.cpp:82
void Continue()
Advance the internal state machine to the next processing step (download, decode, lipsync,...
Definition MessageChunkAudioContainer.cpp:29
virtual ~MessageChunkAudioContainer()=default
MessageChunkAudioContainer(const FString &fullUrl, LipSyncType lipSyncType, TWeakPtr< Audio2FaceRESTHandler > A2FRestHandler, TFunction< void(const MessageChunkAudioContainer *newState)> callback, int id)
Construct a new MessageChunkAudioContainer for a specific audio chunk.
Definition MessageChunkAudioContainer.cpp:17
const T * GetLipSyncData() const
Get an immutable pointer to the lipsync data object for this chunk, cast to the requested type.
Definition MessageChunkAudioContainer.h:72
const TArray< uint8 > & GetRawAudioData() const
Get a reference to the raw audio data bytes for this chunk.
Definition MessageChunkAudioContainer.cpp:77
const int INDEX
The index of this sound asset in the collection of the VoxtaAudioPlayback.
Definition MessageChunkAudioContainer.h:92
UImportedSoundWave * GetSoundWave() const
Definition MessageChunkAudioContainer.cpp:87
const LipSyncType LIP_SYNC_TYPE
The type of lipsync that this voiceline instance will support with its data.
Definition MessageChunkAudioContainer.h:95
void CleanupData()
Clean up all dynamically created objects and data, and mark this chunk as cleaned up.
Definition MessageChunkAudioContainer.cpp:59