Esempio n. 1
0
        public void Process(double[] input, int sampleCount)
        {
            var feedbackBuffer = DiffuserEnabled ? diffuser.Output : filterOutputBuffer;

            for (int i = 0; i < sampleCount; i++)
            {
                tempBuffer[i] = input[i] + feedbackBuffer[i] * feedback;
            }

            delay.Process(tempBuffer, sampleCount);
            delay.Output.Copy(tempBuffer, sampleCount);

            if (LowShelfEnabled)
            {
                lowShelf.Process(tempBuffer, tempBuffer, sampleCount);
            }
            if (HighShelfEnabled)
            {
                highShelf.Process(tempBuffer, tempBuffer, sampleCount);
            }
            if (CutoffEnabled)
            {
                lowPass.Process(tempBuffer, tempBuffer, sampleCount);
            }

            tempBuffer.Copy(filterOutputBuffer, sampleCount);

            if (DiffuserEnabled)
            {
                diffuser.Process(filterOutputBuffer, sampleCount);
            }
        }
Esempio n. 2
0
        public void Process(double[] input, int sampleCount)
        {
            int len            = sampleCount;
            var predelayOutput = preDelay.Output;
            var lowPassInput   = highPassEnabled ? tempBuffer : input;

            if (highPassEnabled)
            {
                highPass.Process(input, tempBuffer, len);
            }
            if (lowPassEnabled)
            {
                lowPass.Process(lowPassInput, tempBuffer, len);
            }
            if (!lowPassEnabled && !highPassEnabled)
            {
                input.Copy(tempBuffer, len);
            }

            // completely zero if no input present
            // Previously, the very small values were causing some really strange CPU spikes
            for (int i = 0; i < len; i++)
            {
                var n = tempBuffer[i];
                if (n * n < 0.000000001)
                {
                    tempBuffer[i] = 0;
                }
            }

            preDelay.Process(tempBuffer, len);
            multitap.Process(preDelay.Output, len);

            var earlyOutStage = diffuserEnabled ? diffuser.Output : multitap.Output;

            if (diffuserEnabled)
            {
                diffuser.Process(multitap.Output, len);
                diffuser.Output.Copy(tempBuffer, len);
            }
            else
            {
                multitap.Output.Copy(tempBuffer, len);
            }

            for (int i = 0; i < lineCount; i++)
            {
                lines[i].Process(tempBuffer, len);
            }

            for (int i = 0; i < lineCount; i++)
            {
                var buf = lines[i].Output;

                if (i == 0)
                {
                    for (int j = 0; j < len; j++)
                    {
                        tempBuffer[j] = buf[j];
                    }
                }
                else
                {
                    for (int j = 0; j < len; j++)
                    {
                        tempBuffer[j] += buf[j];
                    }
                }
            }

            tempBuffer.Gain(perLineGain, len);

            for (int i = 0; i < len; i++)
            {
                outBuffer[i] =
                    dryOut * input[i] +
                    predelayOut * predelayOutput[i] +
                    earlyOut * earlyOutStage[i] +
                    lineOut * tempBuffer[i];
            }
        }