Suppose you have a pull based audio graph, where every node has a method to read the current buffer. The Read method returns the same buffer until the engine calls Reset and requests to calculate a new buffer. This is necessary because there can be multiple other nodes downstream which are connected to the output of a node:
Code: Select all
protected bool FNeedsRead = true;
protected float[] FReadBuffer = new float[1];
public int Read(float[] buffer, int offset, int count)
{
//first call per frame
if(FNeedsRead)
{
//the FillBuffer method does the actual work
this.FillBuffer(FReadBuffer, offset, count);
FNeedsRead = false;
}
//every call
Array.Copy(FReadBuffer, offset, buffer, offset, count);
return count;
}
//will read new data on next Read call
public void Reset()
{
FNeedsRead = true;
}
Is this some kind of design flaw, or is it simply not possible? Any ideas?