public void Start()
        {
            MessageHub.Instance.Subscribe <ReadyMessage>(ReadyToSend);
            MessageHub.Instance.Subscribe <DisconnectedMessage>(Disconnected);

            gameState = new DCSPlayerRadioInfo();
            gameState.radios[1].modulation = modulation[0];
            gameState.radios[1].freq       = freq[0]; // get into Hz
            gameState.radios[1].name       = name;

            Logger.Info($"Starting with params:");
            Logger.Info($"Path or Text to Say: {mp3Path} ");
            for (int i = 0; i < freq.Length; i++)
            {
                Logger.Info($"Frequency: {freq[i]} Hz - {modulation[i]} ");
            }
            Logger.Info($"Coalition: {coalition} ");
            Logger.Info($"IP: 127.0.0.1 ");
            Logger.Info($"Port: {port} ");
            Logger.Info($"Client Name: {name} ");
            Logger.Info($"Volume: {volume} ");

            var srsClientSyncHandler = new SRSClientSyncHandler(Guid, gameState, name, coalition);

            srsClientSyncHandler.TryConnect(new IPEndPoint(IPAddress.Loopback, port));

            //wait for it to end
            finished.Token.WaitHandle.WaitOne();
            Logger.Info("Finished - Closing");

            udpVoiceHandler?.RequestStop();
            srsClientSyncHandler?.Disconnect();

            MessageHub.Instance.ClearSubscriptions();
        }
Example #2
0
        public void StopEncoding()
        {
            if (_mixing != null)
            {
                _radioOutputBuffer   = null;
                _effectsOutputBuffer = null;

                _volumeSampleProvider = null;
                _mixing.RemoveAllMixerInputs();
                _mixing = null;
            }

            if (_waveIn != null)
            {
                _waveIn.StopRecording();
                _waveIn.Dispose();
                _waveIn = null;
            }

            if (_waveOut != null)
            {
                _waveOut.Stop();
                _waveOut.Dispose();
                _waveOut = null;
            }

            if (_playBuffer != null)
            {
                _playBuffer.ClearBuffer();
                _playBuffer = null;
            }


            if (_encoder != null)
            {
                _encoder.Dispose();
                _encoder = null;
            }

            if (_decoder != null)
            {
                _decoder.Dispose();
                _decoder = null;
            }
            if (_udpVoiceHandler != null)
            {
                _udpVoiceHandler.RequestStop();
                _udpVoiceHandler = null;
            }

            _stop = true;
        }
        public void StopEncoding()
        {
            lock (lockObj)
            {
                _textToSpeech?.Dispose();
                _textToSpeech = null;

                _wasapiCapture?.StopRecording();
                _wasapiCapture?.Dispose();
                _wasapiCapture = null;

                _resampler?.Dispose(true);
                _resampler = null;

                _waveOut?.Stop();
                _waveOut?.Dispose();
                _waveOut = null;

                _micWaveOut?.Stop();
                _micWaveOut?.Dispose();
                _micWaveOut = null;

                _volumeSampleProvider = null;
                _clientAudioMixer?.RemoveAllMixerInputs();
                _clientAudioMixer = null;

                _clientsBufferedAudio.Clear();

                _encoder?.Dispose();
                _encoder = null;

                if (_udpVoiceHandler != null)
                {
                    _udpVoiceHandler.RequestStop();
                    _udpVoiceHandler = null;
                }

                _speex?.Dispose();
                _speex = null;

                SpeakerMax = -100;
                MicMax     = -100;

                _effectsOutputBuffer = null;

                foreach (var guid in _subs)
                {
                    MessageHub.Instance.UnSubscribe(guid);
                }
                _subs.Clear();
            }
        }
Example #4
0
        public void StopEncoding()
        {
            lock (lockObj)
            {
                _wasapiCapture?.StopRecording();
                _wasapiCapture?.Dispose();
                _wasapiCapture = null;

                _resampler?.Dispose(true);
                _resampler = null;

                //Debug Wav
                // _afterFileWriter?.Close();
                // _afterFileWriter?.Dispose();
                // _beforeWaveFile?.Close();
                // _beforeWaveFile?.Dispose();

                _waveOut?.Stop();
                _waveOut?.Dispose();
                _waveOut = null;

                _micWaveOut?.Stop();
                _micWaveOut?.Dispose();
                _micWaveOut = null;

                _volumeSampleProvider = null;
                _clientAudioMixer?.RemoveAllMixerInputs();
                _clientAudioMixer = null;

                _clientsBufferedAudio.Clear();

                _encoder?.Dispose();
                _encoder = null;

                if (_udpVoiceHandler != null)
                {
                    _udpVoiceHandler.RequestStop();
                    _udpVoiceHandler = null;
                }

                _speex?.Dispose();
                _speex = null;

                SpeakerMax = -100;
                MicMax     = -100;

                _effectsOutputBuffer = null;

                MessageHub.Instance.ClearSubscriptions();
            }
        }
        public void StopEncoding()
        {
            if (_clientAudioMixer != null)
            {
                _effectsOutputBuffer = null;

                _volumeSampleProvider = null;
                _clientAudioMixer.RemoveAllMixerInputs();
                _clientAudioMixer = null;
            }

            _clientsBufferedAudio.Clear();

            if (_waveIn != null)
            {
                _waveIn.StopRecording();
                _waveIn.Dispose();
                _waveIn = null;
            }

            if (_waveOut != null)
            {
                _waveOut.Stop();
                _waveOut.Dispose();
                _waveOut = null;
            }

            if (_encoder != null)
            {
                _encoder.Dispose();
                _encoder = null;
            }

            if (_decoder != null)
            {
                _decoder.Dispose();
                _decoder = null;
            }
            if (_udpVoiceHandler != null)
            {
                _udpVoiceHandler.RequestStop();
                _udpVoiceHandler = null;
            }

            _stop = true;

            SpeakerMax = 0;
            MicMax     = 0;

            MessageHub.Instance.ClearSubscriptions();
        }
        public void StopEncoding()
        {
            lock (lockObj)
            {
                _waveIn?.StopRecording();
                _waveIn?.Dispose();
                _waveIn = null;

                _waveOut?.Stop();
                _waveOut?.Dispose();
                _waveOut = null;

                _micWaveOut?.Stop();
                _micWaveOut?.Dispose();
                _micWaveOut = null;

                _volumeSampleProvider = null;
                _clientAudioMixer?.RemoveAllMixerInputs();
                _clientAudioMixer = null;

                _clientsBufferedAudio.Clear();

                _encoder?.Dispose();
                _encoder = null;

                _decoder?.Dispose();
                _decoder = null;

                if (_udpVoiceHandler != null)
                {
                    _udpVoiceHandler.RequestStop();
                    _udpVoiceHandler = null;
                }

                _speex?.Dispose();
                _speex = null;

                SpeakerMax = -100;
                MicMax     = -100;

                _effectsOutputBuffer = null;

                MessageHub.Instance.ClearSubscriptions();
            }
        }
        public void Start()
        {
            MessageHub.Instance.Subscribe <ReadyMessage>(ReadyToSend);
            MessageHub.Instance.Subscribe <DisconnectedMessage>(Disconnected);

            gameState = new DCSPlayerRadioInfo();
            gameState.radios[1].modulation = modulation[0];
            gameState.radios[1].freq       = freq[0]; // get into Hz
            gameState.radios[1].name       = opts.Name;

            Logger.Info($"Starting with params:");
            for (int i = 0; i < freq.Length; i++)
            {
                Logger.Info($"Frequency: {freq[i]} Hz - {modulation[i]} ");
            }

            DCSLatLngPosition position = new DCSLatLngPosition()
            {
                alt = opts.Altitude,
                lat = opts.Latitude,
                lng = opts.Longitude
            };

            var srsClientSyncHandler = new SRSClientSyncHandler(Guid, gameState, opts.Name, opts.Coalition, position);

            srsClientSyncHandler.TryConnect(new IPEndPoint(IPAddress.Loopback, opts.Port));

            //wait for it to end
            finished.Token.WaitHandle.WaitOne();
            Logger.Info("Finished - Closing");

            udpVoiceHandler?.RequestStop();
            srsClientSyncHandler?.Disconnect();

            MessageHub.Instance.ClearSubscriptions();
        }