public TestRunner(BinaryFskAnalyzerSettings binaryFskAnalyzerSettings = null,
                          IFrequencyDetector frequencyDetector = null)
        {
            _audioStream               = new MemoryStream();
            _audioGenerator            = new AudioGenerator(_audioStream);
            _fskAudioGenerator         = new FskAudioGenerator(_audioGenerator);
            _binaryFskAnalyzerSettings = binaryFskAnalyzerSettings != null ? binaryFskAnalyzerSettings : new Bell103BinaryFskAnalyzerSettings();
            var bitManipulator = new BitManipulator();

            _fskAudioGenerator.GenerateAudio(_binaryFskAnalyzerSettings.BaudRate, _binaryFskAnalyzerSettings.SpaceFrequency,
                                             _binaryFskAnalyzerSettings.MarkFrequency, bitManipulator.StringToBits("Test string"));
            _audioAnalyzer     = new AudioAnalyzer(_audioStream, _audioGenerator);
            _frequencyDetector = frequencyDetector != null ? frequencyDetector : new ZeroCrossingsFrequencyDetector();
            FskAnalyzer        = new BinaryFskAnalyzer(_audioAnalyzer, _frequencyDetector, _binaryFskAnalyzerSettings);
        }
        public void Run(TestRunnerArguments arguments)
        {
            var fileTimestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");

            var bitManipulator = new BitManipulator();
            var bits           = bitManipulator.StringToBits(arguments.TestString);

            for (var baudRate = arguments.BaudStart; baudRate <= arguments.BaudEnd; baudRate += arguments.BaudIncrement)
            {
                for (var loopBoostFrequency = arguments.BoostStart; loopBoostFrequency <= arguments.BoostEnd;
                     loopBoostFrequency += arguments.BoostIncrement)
                {
                    _binaryFskAnalyzerSettings = new Bell103BinaryFskAnalyzerSettings
                    {
                        SpaceFrequency = arguments.SpaceFrequency,
                        MarkFrequency  = arguments.MarkFrequency,
                        BaudRate       = baudRate,
                        FrequencyDeviationTolerance = arguments.Tolerance
                    };

                    _audioStream = new MemoryStream();

                    _audioGenerator    = new AudioGenerator(_audioStream);
                    _fskAudioGenerator = new FskAudioGenerator(_audioGenerator);
                    _fskAudioGenerator.GenerateAudio(_binaryFskAnalyzerSettings.BaudRate,
                                                     _binaryFskAnalyzerSettings.SpaceFrequency, _binaryFskAnalyzerSettings.MarkFrequency, bits);

                    var audioLengthInMicroseconds = (int)(bits.Count * Math.Pow(10, 6) / _binaryFskAnalyzerSettings.BaudRate);

                    _audioStream       = new MemoryStream();
                    _audioGenerator    = new AudioGenerator(_audioStream);
                    _fskAudioGenerator = new FskAudioGenerator(_audioGenerator);
                    var samples = _fskAudioGenerator.GenerateAudio(_binaryFskAnalyzerSettings.BaudRate,
                                                                   _binaryFskAnalyzerSettings.SpaceFrequency, _binaryFskAnalyzerSettings.MarkFrequency, bits);

                    SignalGenerationComplete(bits.Count, audioLengthInMicroseconds, samples, _audioAnalyzer.SampleRate);

                    if (arguments.WriteFaveFiles == true)
                    {
                        using (var file = File.Create($"{fileTimestamp}_{baudRate}_baud.wav"))
                        {
                            var previousPosition = _audioStream.Position;
                            _audioStream.Position = 0;
                            _audioStream.CopyTo(file);
                            _audioStream.Position = previousPosition;
                        }
                    }

                    _binaryFskAnalyzerSettings = new Bell103BinaryFskAnalyzerSettings
                    {
                        SpaceFrequency = (int)(arguments.SpaceFrequency + loopBoostFrequency),
                        MarkFrequency  = (int)(arguments.MarkFrequency + loopBoostFrequency),
                        BaudRate       = baudRate,
                        FrequencyDeviationTolerance = arguments.Tolerance
                    };

                    _audioAnalyzer = new AudioAnalyzer(_audioStream, _audioGenerator, (int)loopBoostFrequency);

                    FskAnalyzer.Initialize(_audioAnalyzer, new ZeroCrossingsFrequencyDetector(), _binaryFskAnalyzerSettings);
                    FskAnalyzer.AnalyzeSignal(arguments.TestString);

                    if (arguments.PlayAudio == true)
                    {
                        AudioAnalyzer.Play(_audioStream, (int)Math.Ceiling((audioLengthInMicroseconds / Math.Pow(10, 3))));
                    }
                }
            }
        }