public long RunMeasurementRoutine()
        {
            Console.WriteLine($"We will take {c_sampleCount} samples to calculate the end-to-end system latency.");
            Console.WriteLine("Setting up audio devices...");

            InterceptKeys.Instance.OnKey += OnKey;
            InterceptKeys.Start();
            Thread.Sleep(1000);
            _capture.Initialize();
            _capture.DataAvailable += OnData;
            _tracker.Start();
            _capture.Start();

            _output.Initialize(new SampleToIeeeFloat32(new MetronomeGenerator()));
            _output.Play();

            _done.WaitOne();

            float delta = 0;

            for (int i = 0; i < c_sampleCount; i++)
            {
                delta += _keyTicks[i] - _audioTicks[i];
            }
            delta /= c_sampleCount;
            Console.WriteLine($"End-to-end latency: {delta / 10000}ms");
            Thread.Sleep(5000);
            return((long)(delta));
        }
예제 #2
0
 public void Run()
 {
     _periodicThread = new Thread(PeriodicCancelThread);
     _periodicThread.Start();
     _tracker.Start();
     _capture.Start();
     InterceptKeys.Instance.OnKey += OnKey;
     InterceptKeys.Start();
 }