Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
EnthusiastGames's avatar
6 years ago

Oculus GO - Best way to pull mic input

Unreal has an AudioCapture component with a back-end using rtAudio, which supports Windows, Mac and Linux, but not android. I've looked around and couldn't seem to find a way other than using the native sdk to pull the microphone data from the Oculus Go.

So I wrote a little component that does the following:
#include "OculusNativeMicComponent.h"


void UOculusNativeMicComponent::Start()
{
micHandle = ovr_Microphone_Create();
ovr_Microphone_Start(micHandle);

// We also need to determine the maximum size of the buffer
pcmSize = 2400;
}

void UOculusNativeMicComponent::Stop()
{
ovr_Microphone_Stop(micHandle);
}

float UOculusNativeMicComponent::GetAmplitude()
{
QUICK_SCOPE_CYCLE_COUNTER(STAT_GetAmplitude);

// Pull correct data into buffer
size_t capturedSize = ovr_Microphone_GetPCM(micHandle, pcmBuffer, pcmSize);


float max = 0.f;
float amplitude = 0.f;
for (size_t i = 0; i < pcmSize; i++)
{
// Since the format of the stream is in 16-bit fixed point, we want to place in range of 0 .. 1.0 (float)
float sample = abs(pcmBuffer / 32768.0f);

if (sample > max)
max = sample;

amplitude += sample * sample;
}

amplitude = sqrt(amplitude / pcmSize);
return amplitude;
}
Unfortunately, pcmBuffer is always filled with zeros all the way through, before it even goes through any processing. Does anyone have any experience using ovr_Microphone_GetPCM?

Is there any other setup that would be required?

Replies have been turned off for this discussion