示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 private void UpdateScreenCapture(ScreenCaptureMessage message)
 {
     if (ScreenCaptureImage.Source != null)
     {
         ((BitmapImage)ScreenCaptureImage.Source).StreamSource.Dispose();
     }
     ScreenCaptureImage.Source = ImageHelpers.BitmapToImageSource(message.RawImage);
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        private void UpdateScreenCapture(WebcamCaptureMessage message)
        {
            if (WebcamImage.Source != null)
            {
                ((BitmapImage)WebcamImage.Source).StreamSource.Dispose();
            }
            WebcamImage.Source = ImageHelpers.BitmapToImageSource(message.RawImage);

            TxtBoxRate.Text = message.FrameRate.ToString();
        }
示例#3
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            double[] newAudio = listener.GetNewAudio();
            spec.Add(newAudio, process: false);

            double multiplier = Brightness / 20.0;

            if (spec.FftsToProcess > 0)
            {
                Stopwatch sw = Stopwatch.StartNew();
                spec.Process();
                //if (SpectrogamImageSource != null)
                spec.SetFixedWidth(1024);// (int)SpectrogamImageSource.Width);

                Bitmap bmpSpec = new Bitmap(spec.Width, spec.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                using (var bmpSpecIndexed = spec.GetBitmap(multiplier, Decibels, Roll))
                    using (var gfx = Graphics.FromImage(bmpSpec))
                        using (var pen = new System.Drawing.Pen(System.Drawing.Color.White))
                        {
                            gfx.DrawImage(bmpSpecIndexed, 0, 0);
                            if (Roll)
                            {
                                gfx.DrawLine(pen, spec.NextColumnIndex, 0, spec.NextColumnIndex, SpectrogramHeight);
                            }
                        }
                sw.Stop();

                //SpectrogamImageSource.Dispose();
                SpectrogamImageSource    = ImageHelpers.BitmapToImageSource(bmpSpec);
                VerticalScaleImageSource = ImageHelpers.BitmapToImageSource(spec.GetVerticalScale(75));

                RenderTime = $"Render time: {sw.ElapsedMilliseconds:D2} ms";
                Peak       = $"Peak (Hz): {spec.GetPeak().freqHz:N0}";
            }

            TotalTime     = $"Time: {listener.TotalTimeSec:N3} sec";
            FftsProcessed = $"FFTs processed: {spec.FftsProcessed:N0}";

            //Default max on the progressbar is 100 so hardcoding it here for now
            Amplitude = (int)(listener.AmplitudeFrac * 100);

            SpectrogramHeight = spec.Height;

            VerticalScaleImageSource = null;
            VerticalScaleImageSource = ImageHelpers.BitmapToImageSource(spec.GetVerticalScale(LEGEND_WIDTH));
        }
示例#4
0
        private void StartListening()
        {
            try
            {
                int sampleRate = 6000;
                int fftSize    = SelectedFftSize;
                int stepSize   = fftSize / 20;

                SpectrogamImageSource = null;
                listener?.Dispose();
                listener = new Listener(DeviceCapabilities.IndexOf(selectedDevice), sampleRate);

                spec = new Spectrogram.Spectrogram(sampleRate, fftSize, stepSize);
                spec.SetWindow(FftSharp.Window.Rectangular(fftSize));
                SpectrogramHeight = spec.Height;

                VerticalScaleImageSource = null;
                VerticalScaleImageSource = ImageHelpers.BitmapToImageSource(spec.GetVerticalScale(LEGEND_WIDTH));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exeption when attempting to start to listen: " + ex.Message);
            }
        }