Пример #1
0
        private bool Run(Config config, Logger log)
        {
            System.Console.WriteLine($"Listening for Dispatches on Device: {config.InputDevice}");

            audioStorage          = new WatcherAudioStorage(log);
            evaluator             = new AudioEvaluator(log);
            recorder              = new AudioRecorder(evaluator, audioStorage);
            processor             = new AudioProcessor(recorder, evaluator, audioStorage);
            com                   = new ComService(log, processor);
            com.CallCreatedEvent += Com_CallCreatedEvent;

            System.Console.WriteLine("Hooking into Events");
            recorder.SampleAggregator.MaximumCalculated  += SampleAggregator_MaximumCalculated;
            recorder.SampleAggregator.WaveformCalculated += SampleAggregator_WaveformCalculated;

            processor.TriggerProcessingStarted  += Processor_TriggerProcessingStarted;
            processor.TriggerProcessingFinished += Processor_TriggerProcessingFinished;

            evaluator.WatcherTriggered += Evaluator_WatcherTriggered;

            ResgridV3ApiClient.Init(config.ApiUrl, config.Username, config.Password);

            System.Console.WriteLine(
                $"Config Loaded with {config.Watchers.Count} watchers ({config.Watchers.Count(x => x.Active)} active)");

            System.Console.WriteLine("Initializing Processor");
            processor.Init(config);

            System.Console.WriteLine("Starting Processor");
            processor.Start();

            System.Console.WriteLine("Starting Communication Service");
            com.Init(config);
            System.Console.WriteLine("Communication Service: Validating API Connection");

            if (com.IsConnectionValid())
            {
                System.Console.WriteLine("Communication Service: API Connection is Valid");
            }
            else
            {
                System.Console.WriteLine(
                    "Communication Service: CANNOT TALK TO RESGRID API, CHECK YOUR CONFIG APIURL AND ENSURE YOUR COMPUTER CAN TALK TO THAT URL");
            }

            System.Console.WriteLine("Ready, Listening to Audio. Press Ctrl+C to exit.");

            while (recorder.RecordingState == RecordingState.Monitoring || recorder.RecordingState == RecordingState.Recording)
            {
                Thread.Sleep(250);
            }

            return(true);
        }
Пример #2
0
        public string Execute(MonitorArgs args)
        {
            Logger log = new LoggerConfiguration()
                         .MinimumLevel.Error()
                         .WriteTo.Console()
                         .CreateLogger();

            audioStorage = new WatcherAudioStorage(log);
            evaluator    = new AudioEvaluator(log);
            recorder     = new AudioRecorder(evaluator, audioStorage);
            processor    = new AudioProcessor(recorder, evaluator, audioStorage);

            System.Console.WriteLine("Resgrid Audio");
            System.Console.WriteLine("-----------------------------------------");
            System.Console.WriteLine("Monitoring Audio on Device: " + args.Device);

            System.Console.WriteLine("Hooking into Events");
            recorder.SampleAggregator.MaximumCalculated  += SampleAggregator_MaximumCalculated;
            recorder.SampleAggregator.WaveformCalculated += SampleAggregator_WaveformCalculated;

            processor.TriggerProcessingStarted  += Processor_TriggerProcessingStarted;
            processor.TriggerProcessingFinished += Processor_TriggerProcessingFinished;

            evaluator.WatcherTriggered += Evaluator_WatcherTriggered;

            System.Console.WriteLine("Loading Settings");
            Config config = new Config();

            config.InputDevice = args.Device;
            config.AudioLength = 10;

            System.Console.WriteLine("Initializing Processor");
            processor.Init(config);

            System.Console.WriteLine("Starting Processor");
            processor.Start();

            System.Console.WriteLine("Ready, Monitoring Audio. Press Ctrl+C to exit.");
            System.Console.WriteLine($"Timestamp:		Min			Max			dB");
            System.Console.WriteLine($"---------------------------------------------------------------------------");

            while (recorder.RecordingState == RecordingState.Monitoring || recorder.RecordingState == RecordingState.Recording)
            {
                Thread.Sleep(100);
            }

            return("");
        }