コード例 #1
0
ファイル: Queue.cs プロジェクト: tekcor/vvvv-sdk
        public void Evaluate(int SpreadMax)
        {
            //return null if one of the control inputs is null
            if (FDoInsert.IsAnyEmpty(FFrameCount, FReset))
            {
                FOutput.SliceCount = 0;
                return;
            }

            if (FReset[0])
            {
                FBuffer.Clear();
            }

            if (FDoInsert[0])
            {
                FBuffer.Insert(0, CloneInputSpread(FInput));
            }

            var frameCount = FFrameCount[0];

            if (frameCount >= 0 && FBuffer.Count > frameCount)
            {
                FBuffer.RemoveRange(frameCount, FBuffer.Count - frameCount);
            }

            FOutput.AssignFrom(FBuffer);
        }
コード例 #2
0
ファイル: RingBuffer.cs プロジェクト: tekcor/vvvv-sdk
        public void Evaluate(int SpreadMax)
        {
            //return null if one of the control inputs is null
            if (FDoSet.IsAnyEmpty(FFrameCount, FReset))
            {
                FOutput.SliceCount       = 0;
                FPhase.SliceCount        = 0;
                FCurrentFrame.SliceCount = 0;
                return;
            }

            if ((FFirstFrame) || (FReset[0]))
            {
                FOutput.SliceCount = 0;
                FCurrentPos        = -1;
            }

            var frameCount    = FFrameCount[0];
            var oldframecount = FOutput.SliceCount;

            FOutput.SliceCount       = frameCount;
            FPhase.SliceCount        = 1;
            FCurrentFrame.SliceCount = 1;

            if (oldframecount < frameCount)
            {
                for (int i = oldframecount; i < frameCount; i++)
                {
                    FOutput[i] = new Spread <T>(0);
                }
            }

            if (FDoSet[0])
            {
                FCurrentPos++;
                if (FCurrentPos > frameCount - 1)
                {
                    FCurrentPos = 0;
                }
                FOutput[FCurrentPos] = FInput.Clone() as ISpread <T>;
            }

            FCurrentFrame[0] = Math.Min(Math.Max(FCurrentPos, 0), frameCount - 1);
            FPhase[0]        = frameCount > 1 ? FCurrentFrame[0] / (double)(frameCount - 1) : 1;

            FFirstFrame = false;
        }
コード例 #3
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;
        }
コード例 #4
0
ファイル: QueueStore.cs プロジェクト: timpernagel/vvvv-sdk
        public void Evaluate(int SpreadMax)
        {
            //return null if one of the control inputs is null
            if (FDoInsert.IsAnyEmpty(FReset))
            {
                FOutput.SliceCount = 0;
                return;
            }

            if (FReset[0])
            {
                FBuffer.Clear();
                FFramesRecorded.SliceCount = 0;
            }

            if (FRemove[0])
            {
                if (FFramesRecorded.SliceCount > 0)
                {
                    foreach (int i in FIndex.Select(x => x % FFramesRecorded.SliceCount).Distinct().OrderByDescending(x => x))
                    {
                        int offset = 0;
                        for (int j = 0; j < i; j++)
                        {
                            offset += FFramesRecorded[j];
                        }

                        if (FFramesRecorded.SliceCount > 1)
                        {
                            FBuffer.RemoveRange(offset, FFramesRecorded[i]);
                        }
                        else
                        {
                            FBuffer.RemoveRange(0, FFramesRecorded[i]);
                        }

                        FFramesRecorded.RemoveAt(i);
                    }
                }
            }

            if (FDoInsert[0])
            {
                // is empty, so insert new slice
                if (FFramesRecorded.SliceCount < 1)
                {
                    FFramesRecorded.Insert(0, 0);
                }
                // new slice for FFramesRecorded reqested
                else if (FDoSplit[0])
                {
                    // duplicate current slice and insert in old queue
                    if (FSplitDuplicate[0])
                    {
                        if (!FAppend[0])
                        {
                            FBuffer.Insert(0, FCopier.CopySpread(FInput));
                            FFramesRecorded[0]++;
                        }
                        else
                        {
                            // search beginning of last queue
                            int count = 0;
                            for (int i = 0; i < FFramesRecorded.SliceCount - 1; i++)
                            {
                                count += FFramesRecorded[i];
                            }

                            FBuffer.Insert(count, FCopier.CopySpread(FInput));
                            FFramesRecorded[FFramesRecorded.SliceCount - 1]++;
                        }
                    }
                    if (!FAppend[0])
                    {
                        FFramesRecorded.Insert(0, 0);
                    }
                    else
                    {
                        FFramesRecorded.Add(0);
                    }
                }

                if (!FAppend[0])
                {
                    FBuffer.Insert(0, FCopier.CopySpread(FInput));
                    FFramesRecorded[0]++;
                }
                else
                {
                    // search beginning of last queue
                    int count = 0;
                    for (int i = 0; i < FFramesRecorded.SliceCount - 1; i++)
                    {
                        count += FFramesRecorded[i];
                    }

                    FBuffer.Insert(count, FCopier.CopySpread(FInput));
                    FFramesRecorded[FFramesRecorded.SliceCount - 1]++;
                }
            }

            FOutput.AssignFrom(FBuffer);

            if (FOutput.SliceCount == 0)
            {
                FFramesRecorded.SliceCount = 0;
            }

            // combines all recorded queues to one big queue
            if (FConsolidate[0] == true)
            {
                int count = 0;

                foreach (int current in FFramesRecorded)
                {
                    count += current;
                }

                FFramesRecorded.SliceCount = 1;
                FFramesRecorded[0]         = count;
            }
        }