Ejemplo n.º 1
0
        private void GenerateEvent(object source, ElapsedEventArgs e)
        {
            _LS_High.CreateSpectrumLine(0);
            _LS_Mid.CreateSpectrumLine(1);
            _LS_Low.CreateSpectrumLine(2);

            byte[] max = new byte[3] {
                0, 0, 0
            };

            // Only show the values if they reach past a certain threshold
            if (lowVal > 180)
            {
                max[0] = (byte)lowVal;
            }

            if (midVal > 88)
            {
                max[1] = (byte)midVal;
            }

            if (highVal > 37)
            {
                max[2] = (byte)highVal;
            }

            // Shifts the array
            _Scroll(max);
        }
Ejemplo n.º 2
0
 private void OnDraw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args)
 {
     if (_lineSpectrum != null && _audioProvider.IsPlaying)
     {
         _lineSpectrum.CreateSpectrumLine(sender, args.DrawingSession);
     }
 }
Ejemplo n.º 3
0
        private void GenerateLineSpectrum()
        {
            Image image    = pictureBox.Image;
            var   newImage = _lineSpectrum.CreateSpectrumLine(pictureBox.Size, Color.Green, Color.Red, Color.Black, true);

            if (newImage != null)
            {
                pictureBox.Image = newImage;
                if (image != null)
                {
                    image.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        private void GenerateLineSpectrum()
        {
            if (lineSpectrum == null)
            {
                return;
            }

            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

            Image image    = pictureBox1.Image;
            var   newImage = lineSpectrum.CreateSpectrumLine(pictureBox1.Size, Color.Green, Color.Red, Color.Black, true);

            if (newImage != null)
            {
                pictureBox1.Image = newImage;
                if (image != null)
                {
                    image.Dispose();
                }
            }
        }
Ejemplo n.º 5
0
        private void Music_Sync(object sender, DoWorkEventArgs e)
        {
            MSI = new Lighting(Allowed);
            double i = 0;

            while (Music)
            {
                int r = 0, g = 0, b = 0;
                var fftBuffer = new float[(int)FftSize.Fft128];
                if (_lineSpectrum.SpectrumProvider.GetFftData(fftBuffer, this))
                {
                    double bass = 0.0;
                    for (int z = 0; z < 8; z++)
                    {
                        bass += (fftBuffer[z] * 4);
                    }

                    bass += Sens;
                    if (bass > 1.0)
                    {
                        bass = 1.0;
                    }
                    else if (bass < 0.0)
                    {
                        bass = 0.0;
                    }

                    if (M_Rainbow)
                    {
                        HsvToRgb(i, 1, bass, out r, out g, out b);
                    }
                    else if (M_GR)
                    {
                        double val = bass * 255.0;
                        r = Convert.ToInt32(val);
                        g = 255 - Convert.ToInt32(val);
                        b = 0; // For better color effect
                    }
                    else if (M_OC)
                    {
                        r = Convert.ToInt32(OC_C.R * bass);
                        g = Convert.ToInt32(OC_C.G * bass);
                        b = Convert.ToInt32(OC_C.B * bass);
                    }
                }
                Color bcolor = Color.FromArgb(r, g, b);
                System.Windows.Media.Color colour;
                Convert2MSI(bcolor, out colour);

                Image image    = Visualizer_Image.Image;
                var   newImage = _lineSpectrum.CreateSpectrumLine(Visualizer_Image.Size, Color.FromArgb(r, g, b), Color.FromArgb(r, g, b), Color.FromArgb(0, 30, 30, 35), true);
                Music_Apply.BackColor = Color.FromArgb(r, g, b);

                if (newImage != null)
                {
                    Visualizer_Image.Image = newImage;
                    if (image != null)
                    {
                        image.Dispose();
                    }
                }

                MSI.BatchBegin();
                foreach (byte index in Range(1, 8))
                {
                    MSI.SetColour(index, colour);
                }
                MSI.BatchEnd();

                System.Threading.Thread.Sleep(50);
                if (i == 360)
                {
                    i = 0;
                    i = i + 1;
                }
                else
                {
                    i += 1;
                }
            }
        }