Here’s the code and already added the Voice module.
FVoiceModule* myVoiceModule2;
TSharedPtr myVoiceEncoder2 = NULL;
myVoiceModule2 = &FVoiceModule::Get();
myVoiceEncoder2 = myVoiceModule2->CreateVoiceEncoder(48000, 2, EAudioEncodeHint::VoiceEncode_Audio);
myVoiceEncoder2->DumpState();
UE_LOG(LogVoiceEncode, Warning, ■■■■■■■■■■."));
myVoiceEncoder2->SetBitrate(32000);
myVoiceEncoder2->SetComplexity(10);
myVoiceEncoder2->DumpState();
UE_LOG(LogVoiceEncode, Warning, ■■■■■■■■■■."));
TArray<uint8> DecompressedVoiceBuffer;
TArray<uint8> CompressedVoiceBuffer;
DecompressedVoiceBuffer.Empty(10000);
CompressedVoiceBuffer.Empty(10000);
uint32 compressedSize;
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::FromInt(960));
int32 LastRemainderSize = myVoiceEncoder2->Encode(DecompressedVoiceBuffer.GetData(), 960, CompressedVoiceBuffer.GetData(), compressedSize);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, FString::FromInt(compressedSize));
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, FString::FromInt(LastRemainderSize));
There’s no error, but the compressedSize always be 0.
Did I miss something?