Input latency / lag: where is it coming from? how to reduce it?

I don’t have answers yet, but I’ll post my investigations here just as a log.

I followed this audio plugin tutorial (very nice, btw) to run my own synth code. In the OnGenerateAudio function, I checked the NumSamples requested:

int32 ULibpdSynthComponent::OnGenerateAudio(float* OutAudio, int32 NumSamples)
{
	//each tick is one block of audio, typically 64 samples
	int32 ticks = NumSamples / pd.blockSize();
	pd.processFloat(ticks, InBufferPlaceholder, OutAudio);
	pd.receiveMessages();

	return NumSamples;
}

What I was expecting to see was the buffer size I requested in Project Settings >> Platforms >> Windows >> Callback Buffer Size, i.e., something like 256 or 512. However, no matter what settings I input there, the NumSamples requested was always 1024.

Diving into the engine source, I found in the AudioMixerSourceDecode.cpp DoWork() function that the ProceduralTaskData.NumSamples that filters down to my generate audio function is always set to… 8192!

So, my current understanding is that something in my system is setting the actual buffer size to 8192, and my plugin OnGenerateAudio() function is being run in blocks of 1024 samples multiple times to fill it up.

Next step… who is setting the buffer size to 8192?

1 Like