Ejemplo n.º 1
0
        private void HandleData(object sender, DataEventArgs e)
        {
            if (recorder != null && recording)
            {
                try
                {
                    recorder.Record(e.Buffer, e.Length);
                }
                catch (Exception ex)
                {
                    systemLog.Error($"{LOG_PREFIX} Error while trying to send audio to recorder");
                    systemLog.Debug(ex.Message);
                    systemLog.Debug(ex.StackTrace);
                }
            }

            if (transcriber != null && transcriber.IsReady)
            {
                try
                {
                    transcriber.Transcribe(e.Buffer, e.Length);
                }
                catch (Exception ex)
                {
                    systemLog.Error($"{LOG_PREFIX} Error while trying to send audio to transcriber");
                    systemLog.Debug(ex.Message);
                    systemLog.Debug(ex.StackTrace);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows a sample loop where an action is executed, and the latency of each execution is recorded.
        /// </summary>
        private void RecordMeasurements(IRecorder recorder)
        {
            var    sut             = new SocketTester("google.com");
            Action actionToMeasure = sut.CreateAndCloseDatagramSocket;
            var    timer           = Stopwatch.StartNew();

            do
            {
                recorder.Record(actionToMeasure);
            } while (timer.Elapsed < RunPeriod);
            Interlocked.Increment(ref _isCompleted);
        }
Ejemplo n.º 3
0
 public void Record(IMdsDescriptor sequence, Strategy strategy)
 {
     if (writer != null)
     {
         writer.WriteLine("{0} {1} => {2}", sequence.IsSuccessful?"SUCCESS":"FAILURE", strategy, sequence);
     }
     if (wrappedLogger == null)
     {
         return;
     }
     wrappedLogger.Record(sequence, strategy);
 }
        private void btnRec_Click(object sender, RoutedEventArgs e)
        {
            var res = new ResourceDictionary {Source = new Uri("/Styles/CMIcons.xaml", UriKind.Relative)};
            if (_isRecording)
            {
                // rec stopped
                _isRecording = false;
                _audioRec.Stop();

                var dialog = new SaveAudioRecordingWindow();

                if (dialog.ShowDialog() == true)
                {
                    string filepath = dialog.FileLocation;
                    //TODO: method for saving sound file to chosen path
                    //audioRec.SaveRecordedFile(filepath);
                    // current sound is the one just recorded and saved to filepath
                    MediaEL.Source = new Uri(Path.GetFullPath(filepath));
                    ObjectPath = ConfigurationManager.AppSettings.Get("audio") + "/" + Path.GetFileName(filepath);
                    btnPlay.IsEnabled = true;
                    btnOk.IsEnabled = true;
                }

                // enable/disable correct buttons
                btnOpen.IsEnabled = true;
                btnStop.IsEnabled = false;
                btnMoveBackward.IsEnabled = false;
                btnMoveForward.IsEnabled = false;
                btnRec.Background = new ImageBrush(res["Rec_Start"] as BitmapImage);
            }
            else
            {
                var choiceWindow = new ChooseAudioDeviceForAudioRecordingWindow();

                if (choiceWindow.ShowDialog() == true)
                {
                    // rec started
                    _isRecording = true;

                    // start recording

                    _audioRec = new AudioRecorder(choiceWindow.Microphone);
                    _audioRec.Record();
                    // TODO: method for recording sound

                    // enable/disable correct buttons
                    btnOpen.IsEnabled = false;
                    btnPlay.IsEnabled = false;
                    btnStop.IsEnabled = false;
                    btnMoveBackward.IsEnabled = false;
                    btnMoveForward.IsEnabled = false;
                    btnRec.Background = new ImageBrush(res["Rec_Stop"] as BitmapImage);
                }
            }
        }
        private void Enumerate(IMdsDescriptor descriptor, Strategy strategy)
        {
            var deadEnd = true;

            if (LdIsAllowed)
            {
                for (var p = 0; p < descriptor.Length - 1; p++)
                {
                    for (var q = p + 1; q < descriptor.Length; q++)
                    {
                        IMdsDescriptor t;
                        if (!descriptor.TryLd(p, q, out t))
                        {
                            continue;
                        }
                        deadEnd = false;
                        Enumerate(t, strategy + new LdOperation(p, q));
                    }
                }
            }
            if (HiIsAllowed)
            {
                for (var p = 0; p < descriptor.Length - 1; p++)
                {
                    for (var q = p + 1; q < descriptor.Length; q++)
                    {
                        IMdsDescriptor t;
                        if (descriptor.TryHi1(p, q, out t))
                        {
                            deadEnd = false;
                            Enumerate(t, strategy + new HiOperation(p, q, 1));
                        }
                        if (descriptor.TryHi2(p, q, out t))
                        {
                            deadEnd = false;
                            Enumerate(t, strategy + new HiOperation(p, q, 2));
                        }
                    }
                }
            }
            if (DladIsAllowed)
            {
                for (var p = 0; p < descriptor.Length; p++)
                {
                    for (var q = p; q < descriptor.Length; q++)
                    {
                        for (var p2 = q; p2 < descriptor.Length; p2++)
                        {
                            for (var q2 = p2; q2 < descriptor.Length; q2++)
                            {
                                IMdsDescriptor t;
                                if (descriptor.TryDlad1(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 1));
                                }
                                if (descriptor.TryDlad2(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 2));
                                }
                                if (descriptor.TryDlad3(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 3));
                                }
                                if (descriptor.TryDlad4(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 4));
                                }
                                if (descriptor.TryDlad5(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 5));
                                }
                                if (descriptor.TryDlad6(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 6));
                                }
                                if (descriptor.TryDlad7(p, q, p2, q2, out t))
                                {
                                    deadEnd = false;
                                    Enumerate(t, strategy + new DladOperation(p, q, p2, q2, 7));
                                }
                            }
                        }
                    }
                }
            }
            if (!deadEnd)
            {
                return;
            }
            recorder.Record(descriptor, strategy);
        }
Ejemplo n.º 6
0
 public void Log(string message)
 {
     _recorder.Record(message);
 }
Ejemplo n.º 7
0
 public void RecordShow()
 {
     recorder.Record();
 }
 /// <summary>
 /// Shows a sample loop where an action is executed, and the latency of each execution is recorded.
 /// </summary>
 private void RecordMeasurements(IRecorder recorder)
 {
     var sut = new SocketTester("google.com");
     Action actionToMeasure = sut.CreateAndCloseDatagramSocket;
     var timer = Stopwatch.StartNew();
     do
     {
         recorder.Record(actionToMeasure);
     } while (timer.Elapsed < RunPeriod);
     Interlocked.Increment(ref _isCompleted);
 }