Procedural Audio

Ok Folks -

I have a working procedural sound example. But there is a problem with it. I created this by looking at the source code for the USoundWave, USoundNodeWavPlayer, and the USoundWaveStreaming objects. I created two classes USoundNodeProceduralTest and USoundWaveProceduralTest which derive from USoundNode and USoundWave respectively. The USoundNodeProceduralTest is a node that is available in a Sound Cue and acts as a source for the procedurally generated audio signal. When this node get’s parsed it creates a USoundWaveProceduralTest object (only creates the first time) and then calls it’s Parse method. The USoundWaveProceduralTest object is a procedural audio source following the implementation of USoundWaveStreaming (implements GeneratePCMData , bProcedural = true, etc.) .

This all seems to be working fine and plays the pure tone I create and fill into the PCM buffer, EXCEPT, I noticed a “clicking sound” at a very regular time interval. I traced this back to the size of the PCM buffer. This size is set in AudioDecompress.h :

#define MONO_PCM_BUFFER_SAMPLES 8192

The “clicking sound” seems to be coming from a delay whenever the buffer is drained and the GeneratePCMData method is called to re-fill the buffer. If I set this to a much higher value I still hear the click but of course at much larger intervals. (8192 corresponds to 186ms for 44100 sample rate).

I think I’m implementing this system the way UE4 would expect. Is there a way to get rid of this delay (e.g. it should ultimately be fetching the data sooner and double buffering somewhere behind the scenes) ?

I will post full source code here momentarily.

Thanks!