What is the way of getting data from Audio Capture Component

Hello.

How can I get raw data using Audio Capture Component?
All fields in class are private, as I see that data stored in
TArray<float> CaptureAudioData;

I don’t have experience with Synth Component, may be data could be somehow taken from there.
So, any help would be great.
Thanks!

1 Like

and through blueprints too, please

1 Like

I see some time has passed and nobody answered…
Did you manage to find out how?

For voice capture - my suggestion is to grab Engine Voice Module with IVoiceCapture interface and call there GetVoiceData on tick for example.


TSharedPtr<class IVoiceCapture> VoiceCapture = FVoiceModule::Get().CreateVoiceCapture("", VoiceSampleRate, VoiceNumChannels);

VoiceCapture->GetVoiceData(VoiceBuffer, VoiceBufferSize, OutAvailableVoiceData, OutSampleCounter);

Hi! In case someone still needs help with the AudioCapture data, here is a way to do it.

[How to use Audio Capture Component and Audio Capture in Unreal C++ | by Brandon McCowan | Medium]

To sum it up, you create an inherited class and override the OnGenerateAudio function.

#include "MyCaptureComponent.h"

int32 UMyCaptureComponent::OnGenerateAudio(float* OutAudio, int32 NumSamples)
{
 int32 Samples = Super::OnGenerateAudio(OutAudio, NumSamples);

 // Do something, for example reduce the amplitude for each sample by a factor of 10
 for (int i = 0; i < Samples; i++)
 {
  OutAudio[i] = OutAudio[i] / 10.f;
 }

 return Samples;
}