Esempio n. 1
0
        private static IEnumerable <Model> CreateModels()
        {
            for (var i = 0; i < 3; i++)
            {
                var pm = new PlotModel {
                    Title = string.Format("Plot {0}", i + 1)
                };

                var series = new LineSeries();
                for (var j = 0; j < 10; j++)
                {
                    series.Points.Add(new DataPoint(j, r.NextDouble()));
                }

                pm.Series.Add(series);

                var pc = new PlotController();
                pc.UnbindAll();
                pc.BindKeyDown(OxyKey.Left, PlotCommands.PanRight);
                pc.BindKeyDown(OxyKey.Right, PlotCommands.PanLeft);

                yield return(new Model {
                    PlotModel = pm, PlotController = pc
                });
            }
        }
Esempio n. 2
0
        public async Task <bool> UpdatePreviewPlot()
        {
            try
            {
                var ticks = await _xtbWrapper.LoadData(Name, DurationEnum.Year1);

                var dateValues = ticks.ToDateValuePoints(x => x.Close).ToList();
                var plot       = CreatePlot(null, CreateLineSeries("Close Price", OxyColors.Gray, dateValues));

                foreach (var ax in plot.Axes)
                {
                    ax.IsAxisVisible = false;
                    ax.IsPanEnabled  = false;
                    ax.IsZoomEnabled = false;
                }

                plot.IsLegendVisible         = false;
                plot.PlotMargins             = new OxyThickness(0);
                plot.PlotAreaBackground      = OxyColors.Transparent;
                plot.PlotAreaBorderThickness = new OxyThickness(0);

                PreviewPlot           = plot;
                PreviewPlotController = new PlotController();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        private void initPlot(string t, int n)
        {
            PlotModel = new PlotModel();

            PlotController plotController = new PlotController();

            PlotModel.Title           = t;
            PlotModel.TitleFontWeight = OxyPlot.FontWeights.Normal;
            PlotModel.TitleFontSize   = 21;
            var x = (Color)Application.Current.FindResource("OnSurfaceColor");
            var c = OxyColor.FromArgb(x.A, x.R, x.G, x.B);

            PlotModel.TitleColor = c;
            if (t == "Attitude")
            {
                PlotModel.LegendPlacement       = LegendPlacement.Outside;
                PlotModel.LegendPosition        = LegendPosition.TopCenter;
                PlotModel.LegendOrientation     = LegendOrientation.Horizontal;
                PlotModel.LegendBorderThickness = 0;
            }
            else
            {
                PlotModel.IsLegendVisible = false;
            }
            PlotModel.PlotAreaBorderColor = OxyColors.Transparent;
            initSeries(n);
        }
Esempio n. 4
0
            public void UnbindLeftMouseButton()
            {
                var c = new PlotController();

                c.Unbind(new OxyMouseDownGesture(OxyMouseButton.Left));
                Assert.IsFalse(c.InputCommandBindings.Any(b => b.Gesture.Equals(new OxyMouseDownGesture(OxyMouseButton.Left))));
            }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        audioSource = GetComponent <AudioSource>();


        preProcessedSpectralFluxAnalyzer = new SpectralFluxAnalyzer();
        preProcessedPlotController       = GameObject.Find("PreprocessedPlot").GetComponent <PlotController>();

        // Need all audio samples.  If in stereo, samples will return with left and right channels interweaved
        // [L,R,L,R,L,R]
        multiChannelSamples = new float[audioSource.clip.samples * audioSource.clip.channels];
        numChannels         = audioSource.clip.channels;
        numTotalSamples     = audioSource.clip.samples;
        clipLength          = audioSource.clip.length;

        // We are not evaluating the audio as it is being played by Unity, so we need the clip's sampling rate
        sampleRate = audioSource.clip.frequency;

        audioSource.clip.GetData(multiChannelSamples, 0);


        Thread processSampleThread = new Thread(new ThreadStart(getFullSpectrumThreaded));

        processSampleThread.Start();
    }
Esempio n. 6
0
        double l; // reference length which is max{grid length, grid height}

        public MainWindow()
        {
            InitializeComponent();

            this.plot.Model = new PlotModel()
            {
                PlotType = PlotType.Cartesian
            };
            this.plotModel = this.plot.Model;

            this.customController = new PlotController();
            this.plot.Controller  = this.customController;
            customController.UnbindMouseDown(OxyMouseButton.Left);
            customController.BindMouseEnter(PlotCommands.HoverPointsOnlyTrack);

            plotModel.Axes.Add(new LinearAxis()
            {
                Position = AxisPosition.Bottom,
                //IsAxisVisible = false
            });

            plotModel.Axes.Add(new LinearAxis()
            {
                Position = AxisPosition.Left,
                //IsAxisVisible = false
            });
        }
Esempio n. 7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            spark = (SparkWindow)this.Owner;
            if (graphSetting == null)
            {
                graphSetting = spark.settingCommon.graphSetting;
            }
            DirectoryInfo folder = new DirectoryInfo(Core.Work.EnvPath);

            FileInfo[] files     = folder.GetFiles("*.sqlite");
            string[]   filesName = new string[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                filesName[i] = Path.GetFileNameWithoutExtension(files[i].FullName);
            }
            lbDataBases.ItemsSource = filesName;
            timerEmul.Elapsed      += TimerEmul_Elapsed;

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control, PlotCommands.ZoomRectangle);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Alt, PlotCommands.PointsOnlyTrack);
            controller.BindMouseWheel(PlotCommands.ZoomWheel);
            controller.BindKeyDown(OxyKey.R, PlotCommands.Reset);
            plotter.Controller = controller;
        }
Esempio n. 8
0
        public PlotViewCustomZoom() : base()
        {
            Controller = new PlotController();

            var zoomWheel = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheel(view, args));

            Controller.BindMouseWheel(OxyModifierKeys.None, zoomWheel);

            var zoomWheelCtrl = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheelAndCtrl(view, args));

            Controller.BindMouseWheel(OxyModifierKeys.Control, zoomWheelCtrl);

            var zoomWheelShift = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheelAndShift(view, args));

            Controller.BindMouseWheel(OxyModifierKeys.Shift, zoomWheelShift);

            var customPanAt = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.XY), args));

            Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.None, customPanAt);

            var customPanAtCtrl = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.Y), args));

            Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Control, customPanAtCtrl);

            var customPanAtShift = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.X), args));

            Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Shift, customPanAtShift);

            MouseDoubleClick += new MouseButtonEventHandler(OnMouseDoubleClick);
        }
    // Use this for initialization
    void Start()
    {
        audioSource = GetComponent <AudioSource>();

        // Process audio as it plays
        if (realTimeSamples)
        {
            realTimeSpectrum             = new float[1024];
            realTimeSpectralFluxAnalyzer = new SpectrumProcessing();
            realTimePlotController       = GameObject.Find("RealtimePlot").GetComponent <PlotController>();

            this.sampleRate = AudioSettings.outputSampleRate;
        }
        if (preProcessSamples)
        {
            preProcessedSpectralFluxAnalyzer = new SpectrumProcessing();
            // Need all audio samples.  If in stereo, samples will return with left and right channels interweaved
            // [L,R,L,R,L,R]
            multiChannelSamples = new float[audioSource.clip.samples * audioSource.clip.channels];
            numChannels         = audioSource.clip.channels;
            numTotalSamples     = audioSource.clip.samples;
            clipLength          = audioSource.clip.length;

            // We are not evaluating the audio as it is being played by Unity, so we need the clip's sampling rate
            this.sampleRate = audioSource.clip.frequency;

            audioSource.clip.GetData(multiChannelSamples, 0);
            Debug.Log("GetData done");

            Thread bgThread = new Thread(this.getFullSpectrumThreaded);

            Debug.Log("Starting Background Thread");
            bgThread.Start();
        }
    }
Esempio n. 10
0
            public void UnbindPlotCommand()
            {
                var c = new PlotController();

                c.Unbind(PlotCommands.SnapTrack);
                Assert.IsFalse(c.InputCommandBindings.Any(b => b.Command == PlotCommands.SnapTrack));
            }
Esempio n. 11
0
        public MainForm()
        {
            InitializeComponent();

            ShowPreviousLines_ComboBox.SelectedIndex = 0;
            ShowGraphs_ComboBox.SelectedIndex        = 0;

            plot1.Model = new PlotModel()
            {
                IsLegendVisible = false,
            };

            controller = new QtsController(this, new OxyPlotFactory());

            /*
             * OxyPlot по умолчанию уже использует
             * клавиши стрелок для движения по диаграмме,
             * так что отцепим их
             */
            var keyBinder = new PlotController();

            keyBinder.UnbindKeyDown(OxyKey.Up);
            keyBinder.UnbindKeyDown(OxyKey.Down);
            keyBinder.UnbindKeyDown(OxyKey.Left);
            keyBinder.UnbindKeyDown(OxyKey.Right);

            plot1.Controller = keyBinder;

            System.Globalization.CultureInfo myCulture =
                (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            myCulture.NumberFormat.NaNSymbol = "Не определено";

            System.Threading.Thread.CurrentThread.CurrentCulture = myCulture;
        }
Esempio n. 12
0
            public void UnbindAll()
            {
                var c = new PlotController();

                c.UnbindAll();
                Assert.AreEqual(0, c.InputCommandBindings.Count);
            }
        public static Example MouseHandlingExample()
        {
            var model = new PlotModel {
                Title = "Mouse handling example"
            };
            var series = new ScatterSeries();

            model.Series.Add(series);

            // Create a command that adds points to the scatter series
            var command = new DelegatePlotCommand <OxyMouseDownEventArgs>(
                (v, c, a) =>
            {
                a.Handled = true;
                var point = series.InverseTransform(a.Position);
                series.Points.Add(new ScatterPoint(point.X, point.Y));
                model.InvalidatePlot(true);
            });

            var controller = new PlotController();

            controller.BindMouseDown(OxyMouseButton.Left, command);

            return(new Example(model, controller));
        }
Esempio n. 14
0
        public SubsequenceViewModel(ObservableCollection <Event> primaryEvents)
        {
            Plot = new PlotModel
            {
                Axes =
                {
                    new DateTimeAxis
                    {
                        Position     = AxisPosition.Top,
                        StringFormat = "HH:mm:ss.FFFFF"
                    },
                    (categoryAxis = new CategoryAxis
                    {
                        Position = AxisPosition.Left
                    })
                },
                Series =
                {
                    (series = new IntervalBarSeries())
                }
            };

            Controller = new PlotController();
            Controller.UnbindMouseDown(OxyMouseButton.Left);
            Controller.BindMouseDown(OxyMouseButton.Left,
                                     new DelegateViewCommand <OxyMouseDownEventArgs>(OnPlotEdit));

            Events = primaryEvents;
            Events.CollectionChanged += (o, e) =>
            {
                RebuildPlotData();
            };

            RebuildPlotData();
        }
 public MeasurementPlotPage()
 {
     InitializeComponent();
     OxyPlotView.Model             = CreatePlotModel();
     OxyPlotView.HorizontalOptions = LayoutOptions.Fill;
     OxyPlotView.VerticalOptions   = LayoutOptions.Fill;
     var Controller = new PlotController();
 }
Esempio n. 16
0
        public PlotControllerTest(ITestOutputHelper output)
        {
            this.plotRepository = new PlotInMemoryRepository();

            var logger = LoggerFactory.CreateLogger <PlotController>(output);

            this.plotController = new PlotController(this.plotRepository, logger);
        }
Esempio n. 17
0
        private PlotController CreateDefaultController()
        {
            var c = new PlotController();

            c.UnbindMouseDown(OxyMouseButton.Left);
            c.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(c);
        }
Esempio n. 18
0
        public static PlotController CreateController()
        {
            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(controller);
        }
        private void UpdateChart()
        {
            m_plotModel      = new PlotModel();
            m_plotController = new PlotController();

            m_plotModel.Title = "Range Values Line Chart";
            DateTimeAxis tAxis = new DateTimeAxis()
            {
                Minimum = DateTimeAxis.ToDouble(m_start),
                Maximum = DateTimeAxis.ToDouble(m_end)
            };

            m_plotModel.Axes.Add(tAxis);

            tAxis.AxisChanged += AxisChanged;

            //m_plotController.UnbindAll();
            int i = 0;

            foreach (IReader reader in m_readers)
            {
                LineSeries        max = new LineSeries();
                LineSeries        min = new LineSeries();
                LineSeries        avg = new LineSeries();
                List <GraphPoint> lst = reader.GetRangeTrend(m_start, m_end, 100).ToList();

                max.Points.AddRange(lst.Select(item => new DataPoint((DateTimeAxis.ToDouble(item.Tmax) + DateTimeAxis.ToDouble(item.Tmin)) / 2, item.Max)));
                min.Points.AddRange(lst.Select(item => new DataPoint((DateTimeAxis.ToDouble(item.Tmax) + DateTimeAxis.ToDouble(item.Tmin)) / 2, item.Min)));
                avg.Points.AddRange(lst.Select(item => new DataPoint((DateTimeAxis.ToDouble(item.Tmax) + DateTimeAxis.ToDouble(item.Tmin)) / 2, item.Avg)));

                max.Color = m_plotModel.DefaultColors[i];
                min.Color = m_plotModel.DefaultColors[i];
                avg.Color = m_plotModel.DefaultColors[i];

                max.LineStyle = LineStyle.Dot;
                min.LineStyle = LineStyle.Dot;
                avg.Title     = reader.Signal.Name;

                m_plotModel.Series.Add(max);
                m_plotModel.Series.Add(min);
                m_plotModel.Series.Add(avg);

                i++;
                if (i >= m_plotModel.DefaultColors.Count)
                {
                    i = 0;
                }
            }

            m_plotModel.Legends.Add(new Legend()
            {
                LegendTitle    = "",
                LegendPosition = LegendPosition.RightTop,
            });

            OnPropertyChanged(nameof(PlotModel));
            OnPropertyChanged(nameof(PlotController));
        }
Esempio n. 20
0
 public LineChartVM() : base()
 {
     m_xamlClass       = new LineChart();
     m_plotModel       = new PlotModel();
     m_plotController  = new PlotController();
     m_plotModel.Title = "Average Value Line Chart";
     OnPropertyChanged(nameof(PlotModel));
     OnPropertyChanged(nameof(PlotController));
 }
 public EventCollumnVM() : base()
 {
     m_xamlClass       = new LineChart();
     m_plotModel       = new PlotModel();
     m_plotController  = new PlotController();
     m_plotModel.Title = "Event Occurrences";
     OnPropertyChanged(nameof(PlotModel));
     OnPropertyChanged(nameof(PlotController));
 }
Esempio n. 22
0
        private static PlotController CreatePlotController()
        {
            // create a new plot controller with default bindings
            var plotController = new PlotController();

            // add a tracker command to the mouse enter event
            plotController.BindMouseEnter(PlotCommands.HoverPointsOnlyTrack);

            return(plotController);
        }
Esempio n. 23
0
 public ViewModel()
 {
     _data = new ModelData();
     InitData(_data);
     //Show point legend when hovering
     _customPlotController = new PlotController();
     _customPlotController.UnbindMouseDown(OxyMouseButton.Left);
     _customPlotController.BindMouseEnter(PlotCommands.HoverSnapTrack);
     _plotModel = new PlotModel();
     // ShowPMass();
 }
Esempio n. 24
0
        private void formantButton_Click(object sender, EventArgs e)
        {
            MPAiUser user = UserManagement.CurrentUser;

            PlotController.PlotType?plotType = PlotController.PlotType.FORMANT_PLOT;
            VoiceType voiceType = user.Voice;

            PlotController.RunPlot(plotType, voiceType);

            closeThis();
        }
Esempio n. 25
0
        private void InitGraph()
        {
            Model = new PlotModel();
            DateTimeAxis axisX = new DateTimeAxis()
            {
                Title        = "Время",
                Position     = AxisPosition.Bottom,
                StringFormat = "HH:mm:ss",
            };

            axisX.MajorGridlineStyle     = LineStyle.Solid;
            axisX.MajorGridlineThickness = 1;
            Model.Axes.Add(axisX);

            int pos = 0;

            foreach (DataParam param in DataParams)
            {
                LinearAxis axisY = new LinearAxis()
                {
                    Title        = param.Title + ", " + param.ParamUnit.Title,
                    Key          = param.Title,
                    Position     = AxisPosition.Left,
                    PositionTier = pos++
                };
                if (pos == 1)
                {
                    axisY.AxisChanged           += AxeY_AxisChanged;
                    axisY.MajorGridlineStyle     = LineStyle.Solid;
                    axisY.MajorGridlineThickness = 1;
                }
                Model.Axes.Add(axisY);
                LineSeries series = new LineSeries()
                {
                    Title    = param.Title,
                    YAxisKey = param.Title
                };
                Model.Series.Add(series);
            }

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control, PlotCommands.ZoomRectangle);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Alt, PlotCommands.PointsOnlyTrack);
            controller.BindMouseWheel(PlotCommands.ZoomWheel);
            controller.BindKeyDown(OxyKey.R, PlotCommands.Reset);
            plotter.Controller = controller;

            plotter.Model = Model;
        }
Esempio n. 26
0
        public static Example LargeDataSetNarrow()
        {
            var pm = new PlotModel {
                Title = "Large Data Set (narrow window)"
            };

            var timeSpanAxis1 = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };

            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Left
            };

            pm.Axes.Add(linearAxis1);
            var series = new CandleStickSeries
            {
                Color               = OxyColors.Black,
                IncreasingColor     = OxyColors.DarkGreen,
                DecreasingColor     = OxyColors.Red,
                DataFieldX          = "Time",
                DataFieldHigh       = "H",
                DataFieldLow        = "L",
                DataFieldOpen       = "O",
                DataFieldClose      = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
            };

            var n = 1000000;

            foreach (var bar in HighLowItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            timeSpanAxis1.Minimum = series.Items[0].X;
            timeSpanAxis1.Maximum = series.Items[29].X;

            linearAxis1.Minimum = series.Items.Take(30).Select(x => x.Low).Min();
            linearAxis1.Maximum = series.Items.Take(30).Select(x => x.High).Max();

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
        public static Example ClickingOnAnAnnotation()
        {
            var plotModel = new PlotModel {
                Title = "Clicking on an annotation", Subtitle = "Click on the rectangles"
            };

            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left
            });

            var annotation1 = new RectangleAnnotation {
                Fill = OxyColors.Green, Text = "RectangleAnnotation 1", MinimumX = 25, MaximumX = 75, MinimumY = 20, MaximumY = 40
            };

            plotModel.Annotations.Add(annotation1);

            var annotation2 = new RectangleAnnotation {
                Fill = OxyColors.SkyBlue, Text = "RectangleAnnotation 2", MinimumX = 25, MaximumX = 75, MinimumY = 60, MaximumY = 80
            };

            plotModel.Annotations.Add(annotation2);

            EventHandler <OxyMouseDownEventArgs> handleMouseClick = (s, e) =>
            {
                plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)s).Text;
                plotModel.InvalidatePlot(false);
            };

            annotation1.MouseDown += handleMouseClick;
            annotation2.MouseDown += handleMouseClick;

            var controller  = new PlotController();
            var handleClick = new DelegatePlotCommand <OxyMouseDownEventArgs>(
                (v, c, e) =>
            {
                var args     = new HitTestArguments(e.Position, 10);
                var firstHit = v.ActualModel.HitTest(args).FirstOrDefault(x => x.Element is RectangleAnnotation);
                if (firstHit != null)
                {
                    e.Handled          = true;
                    plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)firstHit.Element).Text;
                    plotModel.InvalidatePlot(false);
                }
            });

            controller.Bind(new OxyMouseDownGesture(OxyMouseButton.Left), handleClick);

            return(new Example(plotModel, controller));
        }
Esempio n. 28
0
        public MainWindow()
        {
            InitializeComponent();

            PointsTable.ItemsSource = operatingDataSet;

            model = Plot.ActualModel;

            Type[]        typelist          = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.Namespace == "EstimationsAndPlots").ToArray();
            List <string> functionNamesList = new List <string>();

            foreach (Type type in typelist)
            {
                if (type.BaseType == Type.GetType("EstimationsAndPlots.Function"))
                {
                    functionNamesList.Add(type.Name);
                }
            }
            FunctionChoice.ItemsSource = functionNamesList;

            var myController = new PlotController();

            Plot.Controller = myController;

            myController.BindKeyDown(OxyKey.Right, OxyPlot.PlotCommands.PanLeft);
            myController.BindKeyDown(OxyKey.Left, OxyPlot.PlotCommands.PanRight);
            myController.BindKeyDown(OxyKey.Up, OxyPlot.PlotCommands.PanDown);
            myController.BindKeyDown(OxyKey.Down, OxyPlot.PlotCommands.PanUp);

            myController.UnbindMouseWheel();

            parametersTextBoxes.Add(P1);
            parametersTextBoxes.Add(P2);
            parametersTextBoxes.Add(P3);
            parametersTextBoxes.Add(P4);
            parametersTextBoxes.Add(P5);
            parametersTextBoxes.Add(P6);

            parametersTextBlocks.Add(T1);
            parametersTextBlocks.Add(T2);
            parametersTextBlocks.Add(T3);
            parametersTextBlocks.Add(T4);
            parametersTextBlocks.Add(T5);
            parametersTextBlocks.Add(T6);

            Maxiter.Text = maxiter.ToString();
            Eps.Text     = eps.ToString();

            this.model.MouseDown += (s, e) => this.Plot_MouseDown(s, e);
        }
Esempio n. 29
0
    /* END MY SHITTY ADDON */

    void Start()
    {
        audioSource = GetComponent <AudioSource> ();

        /* START MY SHITTY ADDON */

        spectrumBoy                   = GameObject.Find("Spectograph").GetComponent <SpectrumBuilder> ();
        spectrumRealTime              = GameObject.Find("Spectograph").GetComponent <RealtimeSpectrumBuilder> ();
        backgroundThreadCompleted     = false;
        threeDimensionalSpectrumBuild = false;

        /* END MY SHITTY ADDON */

        // Process audio as it plays
        if (realTimeSamples)
        {
            realTimeSpectrum             = new float[1024];
            realTimeSpectralFluxAnalyzer = new SpectralFluxAnalyzer();
            realTimePlotController       = GameObject.Find("RealtimePlot").GetComponent <PlotController> ();

            this.sampleRate = AudioSettings.outputSampleRate;
        }

        // Preprocess entire audio file upfront
        if (preProcessSamples)
        {
            preProcessedSpectralFluxAnalyzer = new SpectralFluxAnalyzer();
            preProcessedPlotController       = GameObject.Find("PreprocessedPlot").GetComponent <PlotController> ();

            // Need all audio samples.  If in stereo, samples will return with left and right channels interweaved
            // [L,R,L,R,L,R]
            multiChannelSamples = new float[audioSource.clip.samples * audioSource.clip.channels];
            numChannels         = audioSource.clip.channels;
            numTotalSamples     = audioSource.clip.samples;
            clipLength          = audioSource.clip.length;

            // We are not evaluating the audio as it is being played by Unity, so we need the clip's sampling rate
            this.sampleRate = audioSource.clip.frequency;

            audioSource.clip.GetData(multiChannelSamples, 0);             // Fills mutliChannelSamples[] !
            Debug.Log("GetData done");

            Thread bgThread = new Thread(this.getFullSpectrumThreaded);

            Debug.Log("Starting Background Thread");
            bgThread.Start();
        }
    }
Esempio n. 30
0
        public MainWindowViewModel()
        {
            this.Controller = new PlotController();
            myPlotModel     = new PlotModel {
                Title = "Example 1"
            };
            myPlotModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

            var arrowAnnotation = new ArrowAnnotation
            {
                StartPoint = new DataPoint(0, 0),
                EndPoint   = new DataPoint(3, 1)
            };

            myPlotModel.Annotations.Add(arrowAnnotation);
        }
Esempio n. 31
0
 private PlotController CreateDefaultController()
 {
     var c = new PlotController ();
     c.UnbindMouseDown (OxyMouseButton.Left);
     c.BindMouseDown (OxyMouseButton.Left, PlotCommands.PanAt);
     return c;
 }
Esempio n. 32
0
 public void UnbindAll()
 {
     var c = new PlotController();
     c.UnbindAll();
     Assert.AreEqual(0, c.InputCommandBindings.Count);
 }
Esempio n. 33
0
 public void UnbindPlotCommand()
 {
     var c = new PlotController();
     c.Unbind(PlotCommands.SnapTrack);
     Assert.IsFalse(c.InputCommandBindings.Any(b => b.Command == PlotCommands.SnapTrack));
 }
Esempio n. 34
0
 public void UnbindLeftMouseButton()
 {
     var c = new PlotController();
     c.Unbind(new OxyMouseDownGesture(OxyMouseButton.Left));
     Assert.IsFalse(c.InputCommandBindings.Any(b => b.Gesture.Equals(new OxyMouseDownGesture(OxyMouseButton.Left))));
 }