How to get input stream from microphone

Hi guys,
I need to perform very granular modulation of the voice coming from the microphone, which involves FFT transform on a basis of 2048 samples, applying EQ logic to the buckets of frequencies, applying pitch shift based on identified peaks. I have the code to perform all of this. But I’m struggling to get the input stream.
We have AudioCapture that can handle an event ‘On Audio Envelope Value’, but this looks like an averaged amplitude value over one second period or something. While I need straightforward access to all samples as they are captured.
Anybody has an idea where to go?

Using C++, you can override UAudioCapture’s OnGeneratedAudio function which passes in a float array of audio samples when microphone data is captured. You’ll have to first call OpenDefaultAudioStream() and StartCapturingAudio() on your UAudioCapture instance before the callback will work.

I wanted more control over the specific input device I was using, so I subclassed UAudioCapture and called AudioCapture.OpenCaptureStream() which lets you specify extra parameters like the device index and the number of frames you want to pass to your callback. Then you can call StartCapturingAudio().

The problem I’m having is getting the input data into a proper format that Unreal can play back through the speakers as a test. I converted the sample data to 16-bit pcm, but I’m getting static and I’m not sure if I need to add a Wav header or something else.

1 Like