public void NextSample(double newValue)
        {
            delay.Filter(newValue);

            // Create Analytic signal and calculate absolute value "levelMagnitude"

            double levelReal = delay.GetNthDelayedSampleValue(3);

            // Discrete Hilbert transform
            double levelImaginary =
                (delay.GetNthDelayedSampleValue(2) - delay.GetNthDelayedSampleValue(4)) * 2.0 / 1.0 / Math.PI +
                (delay.GetNthDelayedSampleValue(0) - delay.GetNthDelayedSampleValue(6)) * 2.0 / 3.0 / Math.PI;
            double levelMagnitude = Math.Sqrt(levelReal * levelReal + levelImaginary * levelImaginary);

            double db = Double.NegativeInfinity;

            if (Double.Epsilon < levelMagnitude)
            {
                db = 20.0 * Math.Log10(levelMagnitude);
            }

            if (PeakDb < db)
            {
                PeakDb = db;
            }
        }
        public override WWUtil.LargeArray <double> FilterDo(WWUtil.LargeArray <double> inPcmLA)
        {
            var inPcm = inPcmLA.ToArray();

            double [] outPcm = new double[inPcm.Length];

            for (long i = 0; i < outPcm.Length; ++i)
            {
                mDelay.Filter(inPcm[i]);
                outPcm[i] = Convolution();
            }
            return(new WWUtil.LargeArray <double>(outPcm));
        }
        public override WWUtil.LargeArray <double> FilterDo(WWUtil.LargeArray <double> inPcmLA)
        {
            var inPcm  = inPcmLA.ToArray();
            var outPcm = new double[inPcm.Length];

            for (int i = 0; i < inPcm.Length; ++i)
            {
                double x = inPcm[i];

                double delayedY = mDelayX.Filter(x);

                for (int j = 0; j < MOVING_AVERAGER_NUM; ++j)
                {
                    x = mMovingAveragerList[j].Filter(x);
                }

                double y = delayedY - x;
                outPcm[i] = y;
            }

            if (0 < mDiscardSamples)
            {
                if (outPcm.Length < mDiscardSamples)
                {
                    mDiscardSamples -= outPcm.Length;
                    return(new WWUtil.LargeArray <double>(0));
                }
                else
                {
                    var outPcm2 = new double[outPcm.Length - mDiscardSamples];
                    Array.Copy(outPcm, mDiscardSamples, outPcm2, 0, outPcm2.Length);

                    mDiscardSamples = 0;
                    return(new WWUtil.LargeArray <double>(outPcm2));
                }
            }

            return(new WWUtil.LargeArray <double>(outPcm));
        }
        public void UpdateEnd()
        {
            if (delayPeakHoldDb == null)
            {
                // ピークホールドがずっと持続
                if (PeakHoldDb < PeakDb)
                {
                    PeakHoldDb = PeakDb;
                }
                return;
            }

            delayPeakHoldDb.Filter(PeakDb);

            PeakHoldDb = Double.NegativeInfinity;
            for (int i = 0; i < delayPeakHoldDb.DelaySamples; ++i)
            {
                if (PeakHoldDb < delayPeakHoldDb.GetNthDelayedSampleValue(i))
                {
                    PeakHoldDb = delayPeakHoldDb.GetNthDelayedSampleValue(i);
                }
            }
        }