Пример #1
0
        public void Evaluate(int SpreadMax)
        {
            //create new buffer on startup
            if (FFirstFrame)
            {
                FOutput[0] = new Spread <T>(1);
            }

            //return null if one of the control inputs is null
            if (FIndex.IsAnyEmpty(FDoInsert, FFrameCount, FReset))
            {
                FOutput.SliceCount = 0;
                FPhase.SliceCount  = 0;
                return;
            }

            //get buffer size
            var frameCount = FFrameCount[0];

            if (FReset[0] || FFirstFrame) //set all slices to default
            {
                FOutput.SliceCount = frameCount;
                for (int i = 0; i < frameCount; i++)
                {
                    FOutput[i] = FCopier.CopySpread(FDefault[i]);
                }
            }

            //set slice count
            if (FOutput.SliceCount > frameCount)
            {
                FOutput.RemoveRange(frameCount, FOutput.SliceCount - frameCount);
            }
            else if (FOutput.SliceCount < frameCount)
            {
                for (int i = FOutput.SliceCount; i < frameCount; i++)
                {
                    FOutput.Add(FCopier.CopySpread(FDefault[i]));
                }
            }

            SpreadMax = Math.Max(Math.Max(FInput.SliceCount, FIndex.SliceCount), FDoInsert.SliceCount);

            //set phase slice count
            FPhase.SliceCount = SpreadMax;

            //per slice
            for (int i = 0; i < SpreadMax; i++)
            {
                var bufferCounter = FIndex[i];
                bufferCounter %= Math.Max(frameCount, 1);

                if (FDoInsert[i])
                {
                    FOutput[bufferCounter] = FCopier.CopySpread(FInput[i]);
                    FPhase[i] = frameCount > 1 ? bufferCounter / (double)(frameCount - 1) : 0;
                }
            }

            FFirstFrame = false;
        }