public void GetBackwardPrediction_SinInput_ReturnsCorrectPrediction()
        {
            const int coefNumber             = 4;
            const int historyLength          = 512;
            const int numberOfSamplesToCheck = 10;

            var inputAudio =
                new double[historyLength + numberOfSamplesToCheck];

            for (var i = 0; i < inputAudio.Length; i++)
            {
                inputAudio[i] = Math.Sin(
                    2 * Math.PI * i / (historyLength / 5.2));
            }

            var fba = new FastBurgAlgorithm64(inputAudio);

            for (var index = historyLength + 1;
                 index < historyLength + numberOfSamplesToCheck;
                 index++)
            {
                fba.Train(index, coefNumber, historyLength);
                var backwardPrediction = fba.GetBackwardPrediction();

                Assert.AreEqual(
                    inputAudio[index - historyLength - 1],
                    backwardPrediction,
                    0.000001);
            }
        }
Exemple #2
0
        /// <inheritdoc/>
        public double GetBackward(double[] samples)
        {
            var fastBurgAlgorithm = new FastBurgAlgorithm64(samples);

            fastBurgAlgorithm.Train(
                samples.Length,
                this.coefficientsNumber,
                this.historyLength);

            return(fastBurgAlgorithm.GetBackwardPrediction());
        }