Esempio n. 1
0
        public void Volume()
        {
            Volume volume = new Volume();

            volume.Load(Directory.GetCurrentDirectory() + "\\table.csv");
            SingleDoubleSerie serie = volume.Calculate();

            Assert.IsNotNull(serie);
            Assert.IsTrue(serie.Values.Count > 0);
        }
Esempio n. 2
0
        public void Volume()
        {
            Volume volume = new Volume();

            volume.Load(OhlcList);
            SingleDoubleSerie serie = volume.Calculate();

            Assert.IsNotNull(serie);
            Assert.IsTrue(serie.Values.Count > 0);
        }
        public void Volume()
        {
            Volume volume = new Volume();

            volume.Load(csvPath);
            SingleDoubleSerie serie = volume.Calculate();

            Assert.NotNull(serie);
            Assert.True(serie.Values.Count > 0);
        }
        public void RefreshCalculations(int?frameLength = null, int?beStart = null, int?beStop = null)
        {
            if (frameLength.HasValue)
            {
                this.FrameLength = frameLength.Value;
            }
            if (beStart.HasValue)
            {
                this.BEFrequencyStart = beStart.Value;
            }
            if (beStop.HasValue)
            {
                this.BEFrequencyStop = beStop.Value;
            }
            BEFrequencyStart = Math.Max(BEFrequencyStart, 0);
            BEFrequencyStop  = Math.Max(BEFrequencyStop, 0);
            if (BEFrequencyStop < BEFrequencyStart)
            {
                (BEFrequencyStart, BEFrequencyStop) = (BEFrequencyStop, BEFrequencyStart);
            }
            //Eagerly calculate FFT per frame as it's needed in every parameter
            fftPerFrame = new float [samples.Length / FrameLength] [];
            _           = Parallel.For(0, samples.Length / FrameLength, (i) => fftPerFrame [i] = FastFourierTransform.SelectedFrameFFT(GetSamples(), SampleRate, i, FrameLength, false));
            //First batch of tasks - independent from one another
            var taskList = new Task <float []> []
            {
                Volume.Calculate(this),
                FrequencyCentroid.Calculate(this),
                BandEnergy.Calculate(this),
                SpectralFlatnessMeasure.Calculate(this),
                SpectralCrestFactor.Calculate(this)
            };

            Task.WaitAll(taskList);
            volume                  = taskList [0].Result;
            frequencyCentroid       = taskList [1].Result;
            bandEnergy              = taskList [2].Result;
            spectralFlatnessMeasure = taskList [3].Result;
            spectralCrestFactor     = taskList [4].Result;
            //Second batch - previously calculated parameters are needed here
            taskList = new Task <float []> []
            {
                EffectiveBandwidth.Calculate(this),
                BandEnergyRatio.Calculate(this)
            };
            Task.WaitAll(taskList);
            effectiveBandwidth = taskList [0].Result;
            bandEnergyRatio    = taskList [1].Result;
        }