Пример #1
0
        /// <summary>
        /// Executes the block
        /// </summary>
        public override void Execute()
        {
            var inputNode = InputNodes[0].ConnectingNode as BlockOutputNode;

            if (inputNode == null || inputNode.Object == null)
            {
                return;
            }

            OutputNodes[0].Object.Clear();
            OutputNodes[1].Object.Clear();
            foreach (var inputSignal in inputNode.Object)
            {
                var fft = WaveMath.UpSample(inputSignal.Samples);
                ManagedFFT.Instance.FFT(ref fft, true, Mode);
                var abs = WaveMath.AbsFromComplex(fft, 0, fft.Length / 2);
                abs = WaveMath.Normalize(abs, abs.Length);

                var absSignal = new Signal(abs)
                {
                    Start  = 0,
                    Finish = abs.Length - 1
                };
                var fftSignal = new Signal(fft)
                {
                    Start            = 0,
                    Finish           = fft.Length - 1,
                    IsComplex        = true,
                    SamplingInterval = fft.Length
                };

                OutputNodes[0].Object.Add(absSignal);
                OutputNodes[1].Object.Add(fftSignal);
            }

            if (Cascade && OutputNodes[0].ConnectingNode != null)
            {
                OutputNodes[0].ConnectingNode.Root.Execute();
            }
            if (Cascade && OutputNodes[1].ConnectingNode != null)
            {
                OutputNodes[1].ConnectingNode.Root.Execute();
            }
        }