hi, I’m a newbie and I’m trying to use IVoiceEncode::Encode so I can encode my voice, there’s no error when I compile but when I played it this pop up
Here’s my begin play code:
void AFPSCharacter::BeginPlay()
{
// Call the base class
Super::BeginPlay();
VoiceCapture = FVoiceModule::Get().CreateVoiceCapture();
bool Success = VoiceCapture->Start();
if (Success)
{
UE_LOG(LogTemp, Warning, TEXT("Voice capture started successfully"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Voice capture not started successfully"));
}
VoiceEncoder = FVoiceModule::Get().CreateVoiceEncoder(16000, 2, EAudioEncodeHint::VoiceEncode_Voice);
bool SuccessEncode = VoiceEncoder->Init(16000, 2, EAudioEncodeHint::VoiceEncode_Voice);
if (SuccessEncode)
{
UE_LOG(LogTemp, Warning, TEXT("Voice Encode started successfully"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Voice Encode not started successfully"));
}
my tick code:
void AFPSCharacter::VoiceCaptureTick()
{
if (!VoiceCapture.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("Voice capture is not valid; skipping the rest of voice capture tick"));
return;
}
uint32 VoiceCaptureBytesAvailable = 0;
EVoiceCaptureState::Type CaptureState = VoiceCapture->GetCaptureState(VoiceCaptureBytesAvailable);
VoiceCaptureBuffer.Reset();
VoiceEncoder.Reset();
if (CaptureState == EVoiceCaptureState::Ok && VoiceCaptureBytesAvailable > 0)
{
//UE_LOG(LogTemp, Warning, TEXT("Voice is capture"));
uint32 VoiceCaptureReadBytes;
float VoiceCaptureTotalSquared = 0;
uint32 VoiceEncodePacketSize;
VoiceCaptureBuffer.SetNumUninitialized(VoiceCaptureBytesAvailable);
VoiceCapture->GetVoiceData(VoiceCaptureBuffer.GetData(), VoiceCaptureBytesAvailable, VoiceCaptureReadBytes);
uint8 *VoiceEncodePacket;
VoiceEncodePacket = &Packet;
VoiceEncoder->Encode(VoiceCaptureBuffer.GetData(), VoiceCaptureReadBytes, VoiceEncodePacket, VoiceEncodePacketSize);
}
}