4#include "CoreMinimal.h"
5#include "Components/AudioComponent.h"
8#include "VoxtaAudioPlayback.generated.h"
14class USoundWaveProcedural;
26UCLASS(HideCategories = (Mobility, Rendering, LOD), ClassGroup = Voxta, meta = (BlueprintSpawnableComponent))
27class UNREALVOXTA_API UVoxtaAudioPlayback :
public UAudioComponent,
public IA2FWeightProvider
31#pragma region delegate declarations
34 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FVoxtaMessageAudioPlaybackCompleted,
const FGuid&, messageId);
36 DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FVoxtaMessageAudioChunkReadyForCustomPlayback,
const TArray<uint8>&, rawBytes,
const USoundWaveProcedural*, processedSoundWave, FGuid, audioChunkGuid);
39 DECLARE_MULTICAST_DELEGATE_OneParam(FVoxtaMessageAudioPlaybackCompletedNative,
const FGuid&);
40 DECLARE_MULTICAST_DELEGATE_ThreeParams(FVoxtaMessageAudioChunkReadyForCustomPlaybackNative,
const TArray<uint8>&,
const USoundWaveProcedural*, FGuid);
46 UPROPERTY(BlueprintAssignable, Category =
"Voxta", meta = (IsBindableEvent =
"True"))
47 FVoxtaMessageAudioPlaybackCompleted VoxtaMessageAudioPlaybackFinishedEvent;
49 FVoxtaMessageAudioPlaybackCompletedNative VoxtaMessageAudioPlaybackFinishedEventNative;
60 UPROPERTY(BlueprintAssignable, Category =
"Voxta", meta = (IsBindableEvent =
"True"))
61 FVoxtaMessageAudioChunkReadyForCustomPlayback VoxtaMessageAudioChunkReadyForCustomPlaybackEvent;
64 FVoxtaMessageAudioChunkReadyForCustomPlaybackNative VoxtaMessageAudioChunkReadyForCustomPlaybackEventNative;
67#pragma region public API
74 UFUNCTION(BlueprintCallable, Category =
"Voxta")
75 void Initialize(const FGuid& characterId);
84 void Initialize(const FGuid& characterId,
LipSyncType lipSyncType);
92 UFUNCTION(BlueprintCallable, Category =
"Voxta")
93 void MarkAudioChunkCustomPlaybackComplete(const FGuid& guid);
101 virtual
void PlaybackMessage(const FBaseCharData& sender, const FChatMessage& message);
107#pragma region IA2FWeightProvider overrides
117#pragma region UActorComponent overrides
126 virtual void BeginPlay()
override;
132 virtual void EndPlay(
const EEndPlayReason::Type endPlayReason)
override;
135#pragma region private helper classes
138 enum class AudioPlaybackInternalState : uint8
148 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category =
"Voxta", meta = (AllowPrivateAccess =
"true", DisplayName =
"Lipsync Type"))
151 UVoxtaClient* m_clientReference;
157 UObject* m_lipSyncHandler;
159 FGuid m_currentlyPlayingMessageId;
160 TArray<TSharedPtr<MessageChunkAudioContainer>> m_orderedAudio;
162 FDelegateHandle m_playbackFinishedHandle;
164 FString m_hostAddress;
166 AudioPlaybackInternalState m_internalState;
167 int m_currentAudioClipIndex = 0;
170#pragma region private API
172 void InitializeInternal(
bool autoRegisterHandler =
true);
176 void PlayCurrentAudioChunkIfAvailable();
187 void OnAudioPlaybackFinished(UAudioComponent* component);
193 void MarkAudioChunkPlaybackCompleteInternal();
200 void OnChunkStateChange(const MessageChunkAudioContainer* finishedChunk);
LipSyncType
LipSyncType All the possible LipSync types that are currently supported by the UnrealVoxta client.
Definition LipSyncType.h:21
@ Idle
Definition MessageChunkState.h:17
IA2FWeightProvider The interface implemented by whoever can provide the A2F curves for any given upda...
Definition AbstractA2FWeightProvider.h:25
virtual void GetA2FCurveWeightsPreUpdate(TArray< float > &targetArrayRef)
Retrieve the A2F curveWeights for the upcoming update tick.
Definition AbstractA2FWeightProvider.h:34
MessageChunkAudioContainer Internal utility class that encapsulates the download, decoding,...
Definition MessageChunkAudioContainer.h:23
UAudio2FacePlaybackHandler Handles synchronization and playback of Audio2Face lipsync data with audio...
Definition Audio2FacePlaybackHandler.h:20
UVoxtaClient Main public-facing subsystem for Voxta integration.
Definition VoxtaClient.h:50
FBaseCharData Read-only data struct containing all the universal information fields for a character.
Definition BaseCharData.h:17
FChatMessage Represents a single message in a chat conversation, containing both text and audio data.
Definition ChatMessage.h:16