Example #1
0
        private async void ColorClick_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            SelectedColor = (sender as Button).Background;
            SelectionMade = true;
        }
Example #2
0
        private async void Grid_Initialized(object sender, EventArgs e)
        {
            int  Count       = 0;
            Type brushesType = typeof(Brushes);
            var  properties  = brushesType.GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            for (int i = 0; i < ColorGrid.RowDefinitions.Count; i++)
            {
                for (int j = 0; j < ColorGrid.ColumnDefinitions.Count; j++)
                {
                    Button NewColorButton = new Button();
                    NewColorButton.Background = (SolidColorBrush) new BrushConverter().ConvertFromString(properties[Count].Name);
                    NewColorButton.Click     += ColorClick_Click;
                    Grid.SetRow(NewColorButton, i);
                    Grid.SetColumn(NewColorButton, j);
                    ColorGrid.Children.Add(NewColorButton);
                    Count++;
                    if (Count >= properties.Length)
                    {
                        i = ColorGrid.RowDefinitions.Count;
                        break;
                    }
                }
            }

            await GI.FadeIn(this);
        }
Example #3
0
        private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!ProperClosed)
            {
                e.Cancel = true;

                RunVisualizer = false;

                SaveConfig("Saves\\autosave.txt");

                var tasks = new List <Task>();

                int Count = VisualizerStack.Count;
                for (int i = 0; i < Count; i++)
                {
                    var task = VisualizerStack[i].PerformClose();
                    tasks.Add(task);
                }

                await Task.WhenAll(tasks);

                VisualizerStack.Clear();

                await GI.FadeOut(this);

                while (VisualizersRunning)
                {
                    await Task.Delay(100);
                }

                ProperClosed = true;

                Application.Current.Shutdown();
            }
        }
Example #4
0
        public async Task PerformClose()
        {
            await GI.FadeOut(this);

            SenderWindow.VisualizerStack.Remove(this);
            SenderWindow.RefreshVisualizerCountLabel();
            this.Close();
        }
Example #5
0
        private async void ColorPickerCancel_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            SelectedColor = null;
            SelectionMade = true;
            this.Close();
        }
Example #6
0
        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Saves"))
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Saves");
            }

            SaveFileDialog.DefaultExt   = ".txt";
            LoadFileDialog.DefaultExt   = ".txt";
            SaveFileDialog.AddExtension = true;
            LoadFileDialog.AddExtension = true;

            AudioSourceCombobox.Items.Clear();
            int DeviceCount = BassWasapi.BASS_WASAPI_GetDeviceCount();

            for (int i = 0; i < DeviceCount; i++)
            {
                var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i);
                if (device.IsEnabled && device.IsLoopback)
                {
                    AudioSourceCombobox.Items.Add(string.Format("{0} - {1}", i, device.name));
                }
            }
            AudioSourceCombobox.SelectedIndex = 0;

            RefreshRateCombobox.Items.Clear();
            for (int i = 0; i < 105; i += 5)
            {
                RefreshRateCombobox.Items.Add(i.ToString());
            }
            RefreshRateCombobox.SelectedIndex = 0;

            if (File.Exists("Saves\\autosave.txt"))
            {
                LoadConfig("Saves\\autosave.txt");
            }

            await GI.FadeIn(this);
        }
Example #7
0
 private async void Window_Loaded(object sender, RoutedEventArgs e)
 {
     await GI.FadeIn(this);
 }
Example #8
0
        public void UpdateVisualizer(List <List <double> > _AudioDataPointStore)
        {
            if (!SuspendUpdate)
            {
                if (VisualSamplesInvokeRequiered)
                {
                    Dispatcher.Invoke(() => { VisualSamples = (int)VisualizerControlVisualSamplesSlider.Value; });
                }
                if (SmoothnessInvokeRequiered)
                {
                    Dispatcher.Invoke(() => { Smoothness = (int)VisualizerControlSmoothnessSlider.Value; });
                }
                if (SensitivityInvokeRequiered)
                {
                    Dispatcher.Invoke(() => { Sensitivity = (int)VisualizerControlSensitivitySlider.Value; });
                }
                if (BeatZoneFromInvokeRequiered)
                {
                    Dispatcher.Invoke(() => { BeatZoneFrom = (int)VisualizerControlBeatZoneFromSlider.Value; });
                }
                if (BeatZoneToInvokeRequiered)
                {
                    Dispatcher.Invoke(() => { BeatZoneTo = (int)VisualizerControlBeatZoneToSlider.Value; });
                }
                if (VisualizationIndexInvokeRequiered)
                {
                    Dispatcher.Invoke(() => { VisualizationIndex = (int)VisualizerControlTypeCombobox.SelectedIndex; });
                }

                VisualSamplesInvokeRequiered      = false;
                SmoothnessInvokeRequiered         = false;
                SensitivityInvokeRequiered        = false;
                BeatZoneFromInvokeRequiered       = false;
                BeatZoneToInvokeRequiered         = false;
                VisualizationIndexInvokeRequiered = false;

                List <double> AudioValues = new List <double>(new double[BeatZoneTo - BeatZoneFrom]);
                int           AudioIndex  = 0;
                int           ActIndex    = 0;

                for (double j = 0; j < _AudioDataPointStore.Count; j += (double)_AudioDataPointStore.Count / VisualSamples)
                {
                    int ActJ = (int)Math.Round(j, 0);
                    if (ActJ >= _AudioDataPointStore.Count)
                    {
                        break;
                    }

                    if (ActIndex > BeatZoneFrom && ActIndex < BeatZoneTo)
                    {
                        if (Smoothness != 1)
                        {
                            double AvrVal = 0;
                            for (int i = _AudioDataPointStore[ActJ].Count - 1; i >= _AudioDataPointStore[ActJ].Count - Smoothness; i--)
                            {
                                AvrVal += (_AudioDataPointStore[ActJ][i] * Sensitivity);
                            }
                            AvrVal = AvrVal / Smoothness;
                            if (AvrVal > 1024)
                            {
                                AvrVal = 1024;
                            }
                            if (AvrVal < 0)
                            {
                                AvrVal = 0;
                            }
                            AudioValues[AudioIndex] = AvrVal;
                        }
                        else
                        {
                            AudioValues[AudioIndex] = _AudioDataPointStore[ActJ][_AudioDataPointStore[ActJ].Count - 1] * Sensitivity;
                        }
                        AudioIndex++;
                    }
                    ActIndex++;
                }

                Dispatcher.Invoke(() => {
                    GI.GenerateVisualization(VisualizationIndex, VisualizerControlBeatZoneCanvas, AudioValues, VisualizerControlBeatZoneCanvas.ActualWidth, VisualizerControlBeatZoneCanvas.ActualHeight, ColorData);
                });
            }
        }