Exemple #1
0
 private void _referenceProperties_MapChanged(IObservableMap <string, object> sender, IMapChangedEventArgs <string> @event)
 {
     if (@event.Key == "samplegrabber")
     {
         // Configure the analyzer
         SampleGrabber.IMyInterface mft = (SampleGrabber.IMyInterface)sender["samplegrabber"];
         mft.Configure(60.0f, 0.5f, 2048);       // 60fps output, 50% overlap in frames and use 2048 fft
                                                 //mft.SetLogFScale(20.0f, 20000f, 800);   // Output data in logarithmic scale, from 20Hz-20kHz, 800 points per channel
         mft.SetLinearFScale(50);
     }
 }
Exemple #2
0
        const float peakMeterFallTime = 0.003f;     // Slow fall time

        void DrawSwapChain(CanvasSwapChain swapChain)
        {
            using (var ds = swapChain.CreateDrawingSession(Colors.Transparent))
            {
                var size   = swapChain.Size.ToVector2();
                var radius = (Math.Min(size.X, size.Y) / 2.0f) - 4.0f;

                var center = size / 2;

                if (PlayerService.Current.ReferencePropertySet?.ContainsKey("samplegrabber") == true)
                {
                    SampleGrabber.IMyInterface mft = (SampleGrabber.IMyInterface)PlayerService.Current.ReferencePropertySet["samplegrabber"];

                    var     dataFrame           = mft.GetFrame();
                    Vector2 visualizationOffset = new Vector2(200, 20);
                    Vector2 barSize             = new Vector2(5, 150);
                    DrawVisualization(dataFrame, ds, true, true, true, barSize, visualizationOffset);
                    // yuck
                    //lock (PassthroughEffect.GetBadLock())

                    /*
                     * {
                     *  if (PlayerService.Current.ReferencePropertySet != null &&
                     *      PlayerService.Current.ReferencePropertySet.ContainsKey("dataQueue") &&
                     *      this.dataQueue == null)
                     *  {
                     *      this.dataQueue = PlayerService.Current.ReferencePropertySet["dataQueue"] as Queue<Tuple<double, double>>;
                     *  }
                     *
                     *  if (this.dataQueue != null && !hasNextValue && this.dataQueue.Count>0)
                     *  {
                     *      nextvalue = this.dataQueue.Dequeue();
                     *      hasNextValue = true;
                     *  } else if (this.dataQueue != null && this.dataQueue.Count == 0)
                     *  {
                     *      hasNextValue = false;
                     *
                     *  }
                     * }
                     *
                     * if (dataQueue != null)
                     * {
                     *  Debug.WriteLine(dataQueue.Count);
                     * }
                     *
                     * if (!weAreVisualizing && hasNextValue)
                     * {
                     *  weAreVisualizing = true;
                     *  delayStart = true;
                     * }
                     *
                     * if (weAreVisualizing && delayStart && delayCurrent < delayTotal)
                     * {
                     *  delayCurrent++;
                     * }
                     * else
                     * {
                     *  delayStart = false;
                     *  delayCurrent = 0;
                     * }
                     *
                     * if (weAreVisualizing && delayStart)
                     * {
                     *  DrawVU(ds, -100, -100);
                     * } else if (weAreVisualizing && !delayStart && nextvalue != null)
                     * {
                     *  DrawVU(ds, nextvalue.Item1, nextvalue.Item2);
                     *  hasNextValue = false;
                     * } else
                     * {
                     *  Debug.WriteLine("miss");
                     *  DrawVU(ds, -100, -100);
                     * }*/
                }

                swapChain.Present();
            }
        }