Esempio n. 1
0
        public void Initialize()
        {
            if (_isInitialized)
            {
                return;
            }
            _isInitialized = true;

            FftResult fftResult = _fftAnalyzer.Analyze(_batCall);

            SimpleIntBin[] simpleIntBins = new SimpleIntBin[fftResult.FftData.Length - 1];
            int            iPeak         = 0;

            for (int i = 1; i < fftResult.FftData.Length; i++)
            {
                //231kHz Sample Rate with 1024 Buffer -> 115.5 / 256 Bins => 0.451 kHz pro Bin
                simpleIntBins[i - 1] = new SimpleIntBin(fftResult.FftData[i], Math.Round(i * 0.451).ToString(CultureInfo.CurrentCulture), false);
                if ((iPeak < fftResult.Peaks.Length) && (fftResult.Peaks[iPeak] == i))
                {
                    simpleIntBins[i - 1].IsHighlighted = true;
                    iPeak++;
                }
            }

            Frequencies = new ObservableCollection <SimpleIntBin>(simpleIntBins);

            PlotModel  pm         = new PlotModel();
            LineSeries lineSeries = new LineSeries();

            pm.Series.Add(lineSeries);
            pm.Axes.Add(new LinearAxis {
                Maximum = 260, Minimum = 0, Position = AxisPosition.Left, Title = "Intensität"
            });
            pm.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Title = "Dauer [ms]"
            });

            LineAnnotation lineAnnotation = new LineAnnotation {
                Color = OxyColors.DarkRed, LineStyle = LineStyle.Dash, Type = LineAnnotationType.Horizontal, Y = BatCall.MaxPower, Text = $"Ø {BatCall.MaxPower}"
            };

            pm.Annotations.Add(lineAnnotation);

            if (_batCall.PowerData != null)
            {
                lineSeries.Points.AddRange(_batCall.PowerData.Select((b, i) => new DataPoint(i * 0.246, b)));
            }
            Power = pm.AddStyles();
        }
Esempio n. 2
0
		public void Initialize()
		{
			if (_isInitialized)
			{
				return;
			}
			_isInitialized = true;

			SimpleIntBin[] simpleIntBins = new SimpleIntBin[255];

			FftResult fftResult = _fftAnalyzer.Analyze(_batCall);
			int iPeak = 0;
			for (int i = 1; i < fftResult.FftData.Length; i++)
			{
				//231kHz Sample Rate with 1024 Buffer -> 115.5 / 256 Bins => 0.451 kHz pro Bin
				simpleIntBins[i - 1] = new SimpleIntBin(fftResult.FftData[i], (Math.Round(i * 0.451).ToString(CultureInfo.CurrentCulture), false);
				if (iPeak < fftResult.Peaks.Length && fftResult.Peaks[iPeak] == i)
				{
					simpleIntBins[i - 1].IsHighlighted = true;
					iPeak++;
				}
			}

			Frequencies = new ObservableCollection<SimpleIntBin>(simpleIntBins);
		}