Exemplo n.º 1
0
 public void Update(OpenGL gl, Complex[] result)
 {
     //Destroy Old Bitmap
     audioBitmap.Dispose();
     audioBitmap = new Bitmap(512, 2);
     //Create Bitmap
     for (int i = 0; i < 512; i++)
     {
         Complex c           = result[i];
         double  intensityDB = 10 * Math.Log10(c.X * c.X + c.Y * c.Y);
         double  minDB       = -90;
         if (intensityDB < minDB)
         {
             intensityDB = minDB;
         }
         double percent = intensityDB / minDB;
         //Console.WriteLine("% : " + percent);
         if (percent < 0)
         {
             percent = 0;
         }
         if (percent > 1)
         {
             percent = 1;
         }
         int val = Convert.ToInt16(percent * 255);
         //audioBitmap.SetPixel(i, 0, Color.FromArgb(sval, sval, sval));
         audioBitmap.SetPixel(i, 1, Color.FromArgb(255 - val, 255 - val, 255 - val));
         audioBitmap.SetPixel(i, 0, Color.FromArgb(255 - val, 255 - val, 255 - val));
     }
     OnBitmapUpdated.Invoke(this, new BitmapUpdateEventArgs(audioBitmap));
     //Console.WriteLine("BMP UPDT");
 }
Exemplo n.º 2
0
        private void ClockTimer_Tick(object sender, EventArgs e)
        {
            // running clock
            currentTimeClock.Content = DateTime.Now.ToString("hh:mm:ss");

            // get free space
            ShowDiskFreeSpace(tbSaveImgLocation.Text);

            // when camera started streaming video
            fpsLbl.Content = "-";
            if (videoSource != null && videoSource.IsRunning)
            {
                if (playOnce)
                {
                    playOnce = false;
                }
                if (captureImageOnce)
                {
                    captureImageOnce = false;
                }

                // get number of frames for the last second
                statCount[statIndex] = videoSource.FramesReceived;

                // increment indexes
                if (++statIndex >= statLength)
                {
                    statIndex = 0;
                }
                if (statReady < statLength)
                {
                    statReady++;
                }

                float fps = 0;

                // calculate average value
                for (int i = 0; i < statReady; i++)
                {
                    fps += statCount[i];
                }
                fps /= statReady;

                statCount[statIndex] = 0;

                fpsLbl.Content = fps.ToString("F2") + " fps";

                // update histograms
                OnBitmapUpdated?.Invoke(this, bitmapImageCopy);
            }
        }