public MainWindow()
        {
            InitializeComponent();

            _samples = new ValueHolder<short[]>();
            _samplingRate = new ValueHolder<int>();

            _soundManager = new SoundManager();
            _soundManager.NewSamples += HandleNewSamples;
            _soundManager.StartRecording(0, 30);

            _samplingRate.Value = _soundManager.SamplingRate;

            _soundVisualizerVM = new SoundVisualizerVM(_samples, _samplingRate);

            _soundVisualizer = new SoundVisualizerControl(_soundVisualizerVM);
            //MainGrid.Children.Add(_soundVisualizer);

            _scene = new WPF3DScene();
            MainGrid.Children.Add(_scene);
            _model = Create3DModel();
            _scene.AddModel(_model);
            AddUIP3DPlane();
            _soundVisualizerVM.AverageAmplitudeFromLastSampling.PropertyChanged += HandleAverageAmplitudeChanged;

            DeviceButton.Click += DeviceButton_Click;
            DeviceButton.Content = _soundManager.GetAvailableDevices().Keys.First().ProductName;
        }
        public SoundVisualizerControl(SoundVisualizerVM viewModel)
        {
            InitializeComponent();
            _viewModel = viewModel;

            UpdateSound2ColorMappingLines(_viewModel.Sound2ColorMappings);
            _viewModel.Frequencies.PropertyChanged += HandleFrequenciesChanged;
            _viewModel.Amplitudes.PropertyChanged += HandleAmplitudesChanged;
            _viewModel.Color.PropertyChanged += HandleColorChanged;
            _viewModel.AverageIntensity.PropertyChanged += HandleAverageIntensityChanged;

            CreateFrequencyLabels();
        }