Beispiel #1
0
 private unsafe void FrontendFiller(IFrontendController sender, Complex *samples, int len)
 {
     if (this._isPlaying)
     {
         if (this._hookManager != null)
         {
             this._hookManager.ProcessRawIQ(samples, len);
         }
         this._iqCircularBuffer.Write(samples, len, !(sender is INonBlockingController));
     }
 }
Beispiel #2
0
 public void Stop()
 {
     this._isPlaying = false;
     if (this._inputType == InputType.Plugin && this._frontend is IIQStreamController)
     {
         ((IIQStreamController)this._frontend).Stop();
         this._frontend = null;
     }
     if (this._iqCircularBuffer != null)
     {
         this._iqCircularBuffer.Close();
     }
     if (this._audioCircularBuffer != null)
     {
         this._audioCircularBuffer.Close();
     }
     if (this._wavePlayer != null)
     {
         this._wavePlayer.Dispose();
         this._wavePlayer = null;
     }
     if (this._waveRecorder != null)
     {
         this._waveRecorder.Dispose();
         this._waveRecorder = null;
     }
     if (this._waveDuplex != null)
     {
         this._waveDuplex.Dispose();
         this._waveDuplex = null;
     }
     this._inputSampleRate = 0.0;
     if (this._waveReadThread != null)
     {
         this._waveReadThread.Join();
         this._waveReadThread = null;
     }
     if (this._dspThread != null)
     {
         this._dspThread.Join();
         this._dspThread = null;
     }
     if (this._waveFile != null)
     {
         this._waveFile.Dispose();
         this._waveFile = null;
     }
     this._iqCircularBuffer    = null;
     this._audioCircularBuffer = null;
     this._dspOutBuffer        = null;
 }
Beispiel #3
0
 public void OpenPlugin(IFrontendController frontend, int outputDevice, int latency)
 {
     this.Stop();
     try
     {
         this._inputType            = InputType.Plugin;
         this._frontend             = frontend;
         this._inputSampleRate      = this._frontend.Samplerate;
         this._outputDevice         = outputDevice;
         this._bufferSizeInMs       = latency;
         this._inputBufferSize      = (int)((double)this._bufferSizeInMs * this._inputSampleRate / 1000.0);
         this._decimationStageCount = this.GetDecimationStageCount();
         int num = (int)Math.Pow(2.0, (double)this._decimationStageCount);
         this._inputBufferSize = this._inputBufferSize / num * num;
         this._inputBufferSize = this._inputBufferSize / StreamControl._processorCount * StreamControl._processorCount;
         int num2 = (int)Math.Log((double)this._inputBufferSize, 2.0);
         this._inputBufferSize  = (int)Math.Pow(2.0, (double)num2);
         this._bufferSizeInMs   = (int)Math.Round((double)this._inputBufferSize / this._inputSampleRate * 1000.0);
         this._outputSampleRate = this._inputSampleRate / (double)num;
         this._outputBufferSize = this._inputBufferSize / num * 2;
         if (this._outputSampleRate > 192000.0)
         {
             this._soundCardRatio = this._outputSampleRate / 192000.0;
         }
         else
         {
             this._soundCardRatio = (this._useASIO ? (this._outputSampleRate / (double)this._minOutputSampleRate) : 1.0);
         }
         Console.WriteLine("_inputBuffersize (complex) set to " + (Utils.FastConvolve ? "power of 2 : " : ": ") + this._inputBufferSize.ToString());
         Console.WriteLine("_outputBuffersize (real) set to : " + this._outputBufferSize.ToString());
         Console.WriteLine("_soundCardRatio set to : " + this._soundCardRatio.ToString());
     }
     catch
     {
         this.Stop();
         throw;
     }
 }
Beispiel #4
0
 private void iqSourceComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.StopRadio();
       if (this._frontendController != null)
       {
     this._frontendController.HideSettingGUI();
     this._frontendController.Close();
     this._frontendController = (IFrontendController) null;
       }
       if (this.SourceIsSoundCard)
       {
     this.inputDeviceComboBox.Enabled = true;
     this.outputDeviceComboBox.Enabled = true;
     this.sampleRateComboBox.Enabled = true;
     this.frequencyShiftCheckBox.Enabled = true;
     this.frequencyShiftNumericUpDown.Enabled = this.frequencyShiftCheckBox.Checked;
     this._tooltip.SetToolTip((Control) this.configureSourceButton, "Configure");
     this.configureSourceButton.Enabled = false;
     this.SetCenterFrequency(0L);
     this.vfoFrequencyEdit.Frequency = this._frequencyShift;
       }
       else
       {
     this.configureSourceButton.Enabled = true;
     if (this.SourceIsWaveFile)
     {
       this._tooltip.SetToolTip((Control) this.configureSourceButton, "Select");
       this.sampleRateComboBox.Enabled = false;
       this.inputDeviceComboBox.Enabled = false;
       this.outputDeviceComboBox.Enabled = true;
       this.latencyNumericUpDown.Enabled = true;
       this.frequencyShiftCheckBox.Enabled = false;
       this.frequencyShiftNumericUpDown.Enabled = false;
       this.frequencyShiftCheckBox.Checked = false;
       this._frequencyShift = 0L;
       if (this._initializing)
     return;
       this.SetCenterFrequency(0L);
       this.vfoFrequencyEdit.Frequency = 0L;
       this.SelectWaveFile();
     }
     else
     {
       this._tooltip.SetToolTip((Control) this.configureSourceButton, "Configure");
       this.frequencyShiftCheckBox.Enabled = true;
       this.frequencyShiftNumericUpDown.Enabled = this.frequencyShiftCheckBox.Checked;
       IFrontendController newFrontendController = this._frontendControllers[(string) this.iqSourceComboBox.SelectedItem];
       try
       {
     this.SelectFrontend(newFrontendController, true);
     this._frontendController = newFrontendController;
       }
       catch
       {
     newFrontendController.Close();
       }
       this.centerButton.Enabled = this.SourceIsTunable;
     }
       }
 }
Beispiel #5
0
        private void iqSourceComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            StopRadio();

            if (_frontendController != null)
            {
                _frontendController.HideSettingGUI();
                _frontendController.Close();
                _frontendController = null;
            }

            if (SourceIsSoundCard)
            {
                inputDeviceComboBox.Enabled = true;
                outputDeviceComboBox.Enabled = true;
                sampleRateComboBox.Enabled = true;
                frequencyShiftCheckBox.Enabled = true;
                frequencyShiftNumericUpDown.Enabled = frequencyShiftCheckBox.Checked;
                configureSourceButton.Text = "Configure";
                configureSourceButton.Enabled = false;
                SetCenterFrequency(0);
                vfoFrequencyEdit.Frequency = _frequencyShift;
                return;
            }
            
            configureSourceButton.Enabled = true;

            if (SourceIsWaveFile)
            {
                configureSourceButton.Text = "Select";
                sampleRateComboBox.Enabled = false;
                inputDeviceComboBox.Enabled = false;
                outputDeviceComboBox.Enabled = true;
                latencyNumericUpDown.Enabled = true;
                frequencyShiftCheckBox.Enabled = false;
                frequencyShiftNumericUpDown.Enabled = false;
                frequencyShiftCheckBox.Checked = false;
                _frequencyShift = 0;

                if (!_initializing)
                {
                    SetCenterFrequency(0);
                    vfoFrequencyEdit.Frequency = 0;
                    SelectWaveFile();
                }
                return;
            }

            configureSourceButton.Text = "Configure";
            frequencyShiftCheckBox.Enabled = true;
            frequencyShiftNumericUpDown.Enabled = frequencyShiftCheckBox.Checked;

            var frontendName = (string) iqSourceComboBox.SelectedItem;
            var newFrontendController = _frontendControllers[frontendName];
            try
            {
                newFrontendController.Open();
                inputDeviceComboBox.Enabled = newFrontendController.IsSoundCardBased;
                sampleRateComboBox.Enabled = newFrontendController.IsSoundCardBased;
                if (newFrontendController.IsSoundCardBased)
                {
                    var regex = new Regex(newFrontendController.SoundCardHint, RegexOptions.IgnoreCase);
                    for (var i = 0; i < inputDeviceComboBox.Items.Count; i++)
                    {
                        var item = inputDeviceComboBox.Items[i].ToString();
                        if (regex.IsMatch(item))
                        {
                            inputDeviceComboBox.SelectedIndex = i;
                            break;
                        }
                    }
                    if (newFrontendController.Samplerate > 0)
                    {
                        sampleRateComboBox.Text = newFrontendController.Samplerate.ToString();
                    }
                }
                if (newFrontendController.Samplerate > 0)
                {
                    waterfall.SpectrumWidth = (int) newFrontendController.Samplerate;
                    spectrumAnalyzer.SpectrumWidth = (int) newFrontendController.Samplerate;
                }
                _vfo.SampleRate = newFrontendController.Samplerate;
                _vfo.Frequency = 0;
                SetCenterFrequency(newFrontendController.Frequency);
                vfoFrequencyEdit.Frequency = newFrontendController.Frequency + _frequencyShift;
                _frontendController = newFrontendController;
            }
            catch
            {
                iqSourceComboBox.SelectedIndex = iqSourceComboBox.Items.Count - 1;
                newFrontendController.Close();
                if (!_initializing)
                {
                    MessageBox.Show(
                        frontendName + " is either not connected or its driver is not working properly.",
                        "Information",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                }
            }
        }
Beispiel #6
0
 public void Stop()
 {
     if (_inputType == InputType.Plugin && _frontend != null)
     {
         _frontend.Stop();
         _frontend = null;
     }
     if (_wavePlayer != null)
     {
         _wavePlayer.Dispose();
         _wavePlayer = null;
     }
     if (_waveRecorder != null)
     {
         _waveRecorder.Dispose();
         _waveRecorder = null;
     }
     if (_waveDuplex != null)
     {
         _waveDuplex.Dispose();
         _waveDuplex = null;
     }
     _inputSampleRate = 0;
     if (_waveReadThread != null)
     {
         _waveReadThread.Join();
         _waveReadThread = null;
     }
     if (_iqStream != null)
     {
         _iqStream.Close();
     }
     if (_audioStream != null)
     {
         _audioStream.Close();
     }
     if (_streamHookManager != null)
     {
         _streamHookManager.CloseStreams();
         _streamHookManager.Stop();                
     }
     if (_dspThread != null)
     {
         _dspThread.Join();
         _dspThread = null;
     }
     if (_streamHookManager != null)
     {
         _streamHookManager.StopIQObserverThread();
     }
     if (_waveFile != null)
     {
         _waveFile.Dispose();
         _waveFile = null;
     }
     if (_iqStream != null)
     {
         _iqStream.Dispose();
         _iqStream = null;
     }           
     if (_streamHookManager != null)
     {
         _streamHookManager.DisposeStreams();                
     }
     _audioStream = null;
     _dspOutBuffer = null;
     _iqInBuffer = null;
 }
Beispiel #7
0
 public void Stop()
 {
     if (_inputType == InputType.Plugin && _frontend != null)
     {
         _frontend.Stop();
         _frontend = null;
     }
     if (_wavePlayer != null)
     {
         _wavePlayer.Dispose();
         _wavePlayer = null;
     }
     if (_waveRecorder != null)
     {
         _waveRecorder.Dispose();
         _waveRecorder = null;
     }
     if (_waveDuplex != null)
     {
         _waveDuplex.Dispose();
         _waveDuplex = null;
     }
     _inputSampleRate = 0;
     if (_waveReadThread != null)
     {
         _waveReadThread.Join();
         _waveReadThread = null;
     }
     if (_iqStream != null)
     {
         _iqStream.Close();
     }
     if (_audioStream != null)
     {
         _audioStream.Close();
     }
     if (_streamHookManager != null)
     {
         _streamHookManager.CloseStreams();
         _streamHookManager.Stop();
     }
     if (_dspThread != null)
     {
         _dspThread.Join();
         _dspThread = null;
     }
     if (_streamHookManager != null)
     {
         _streamHookManager.StopIQObserverThread();
     }
     if (_waveFile != null)
     {
         _waveFile.Dispose();
         _waveFile = null;
     }
     if (_iqStream != null)
     {
         _iqStream.Dispose();
         _iqStream = null;
     }
     if (_streamHookManager != null)
     {
         _streamHookManager.DisposeStreams();
     }
     _audioStream  = null;
     _dspOutBuffer = null;
     _iqInBuffer   = null;
 }
Beispiel #8
0
        private void MainForm_Closing(object sender, CancelEventArgs e)
        {
            _terminated = true;
            _streamControl.Stop();
            _fftEvent.Set();
            if (_frontendController != null)
            {
                _frontendController.Close();
                _frontendController = null;
            }

            #region ISharpPlugin Teardown
            
            foreach(var plugin in _sharpPlugins.Values)
            {
                plugin.Close();
            }
            
            #endregion

            _modeStates[_vfo.DetectorType] = GetModeState();

            Utils.SaveSetting("spectrumAnalyzerAttack", spectrumAnalyzer.Attack);
            Utils.SaveSetting("spectrumAnalyzerDecay", spectrumAnalyzer.Decay);
            Utils.SaveSetting("waterfallAttack", waterfall.Attack);
            Utils.SaveSetting("waterfallDecay", waterfall.Decay);
            Utils.SaveSetting("useTimeMarkers", useTimestampsCheckBox.Checked);
            Utils.SaveSetting("fftSpeed", fftSpeedTrackBar.Value);
            Utils.SaveSetting("fftContrast", fftContrastTrackBar.Value);
            Utils.SaveSetting("fftWindowType", fftWindowComboBox.SelectedIndex);
            Utils.SaveSetting("fftView", viewComboBox.SelectedIndex);
            Utils.SaveSetting("fftResolution", fftResolutionComboBox.SelectedIndex);
            Utils.SaveSetting("detectorType", (int) DetectorType);
            Utils.SaveSetting("useAGC", agcCheckBox.Checked);
            Utils.SaveSetting("agcThreshold", (int) agcThresholdNumericUpDown.Value);
            Utils.SaveSetting("agcDecay", (int) agcDecayNumericUpDown.Value);
            Utils.SaveSetting("agcSlope", (int) agcSlopeNumericUpDown.Value);
            Utils.SaveSetting("agcHang", agcUseHangCheckBox.Checked);
            Utils.SaveSetting("frequencyShift", (long) frequencyShiftNumericUpDown.Value);
            Utils.SaveSetting("frequencyShiftEnabled", frequencyShiftCheckBox.Checked);
            Utils.SaveSetting("swapIQ", swapIQCheckBox.Checked);
            Utils.SaveSetting("correctIQ", correctIQCheckBox.Checked);
            Utils.SaveSetting("markPeaks", markPeaksCheckBox.Checked);
            Utils.SaveSetting("fmStereo", fmStereoCheckBox.Checked);
            Utils.SaveSetting("filterAudio", filterAudioCheckBox.Checked);
            Utils.SaveSetting("unityGain", unityGainCheckBox.Checked);
            Utils.SaveSetting("latency", (int) latencyNumericUpDown.Value);
            Utils.SaveSetting("sampleRate", sampleRateComboBox.Text);
            Utils.SaveSetting("audioGain", audioGainTrackBar.Value);
            Utils.SaveSetting("windowState", (int) WindowState);
            Utils.SaveSetting("windowPosition", Utils.IntArrayToString(_lastLocation.X, _lastLocation.Y));
            Utils.SaveSetting("windowSize", Utils.IntArrayToString(_lastSize.Width, _lastSize.Height));
            Utils.SaveSetting("collapsiblePanelStates", Utils.IntArrayToString(GetCollapsiblePanelStates()));
            Utils.SaveSetting("splitterPosition", panSplitContainer.SplitterDistance);
            Utils.SaveSetting("iqSource", iqSourceComboBox.SelectedIndex);
            Utils.SaveSetting("waveFile", "" + _waveFile);
            Utils.SaveSetting("centerFrequency", _centerFrequency);
            Utils.SaveSetting("vfo", vfoFrequencyEdit.Frequency);
            Utils.SaveSetting("fftDisplayOffset", fftOffsetTrackBar.Value);
            Utils.SaveSetting("fftDisplayRange", fftRangeTrackBar.Value);
            Utils.SaveSetting("inputDevice", inputDeviceComboBox.SelectedItem);
            Utils.SaveSetting("outputDevice", outputDeviceComboBox.SelectedItem);
            Utils.SaveSetting("spectrumWidth", spectrumAnalyzer.SpectrumWidth);
            Utils.SaveSetting("wfmState", Utils.IntArrayToString(_modeStates[DetectorType.WFM]));
            Utils.SaveSetting("nfmState", Utils.IntArrayToString(_modeStates[DetectorType.NFM]));
            Utils.SaveSetting("amState",  Utils.IntArrayToString(_modeStates[DetectorType.AM]));
            Utils.SaveSetting("lsbState", Utils.IntArrayToString(_modeStates[DetectorType.LSB]));
            Utils.SaveSetting("usbState", Utils.IntArrayToString(_modeStates[DetectorType.USB]));
            Utils.SaveSetting("dsbState", Utils.IntArrayToString(_modeStates[DetectorType.DSB]));
            Utils.SaveSetting("cwState",  Utils.IntArrayToString(_modeStates[DetectorType.CW]));
            Utils.SaveSetting("rawState", Utils.IntArrayToString(_modeStates[DetectorType.RAW]));
        }
Beispiel #9
0
 private void Open()
 {
     AudioDevice audioDevice1 = (AudioDevice) this.inputDeviceComboBox.SelectedItem;
       AudioDevice audioDevice2 = (AudioDevice) this.outputDeviceComboBox.SelectedItem;
       long num = this._centerFrequency;
       if (this.SourceIsWaveFile)
       {
     if (!File.Exists(this._waveFile))
       throw new ApplicationException("No such file");
     this._streamControl.OpenFile(this._waveFile, audioDevice2.Index, (int) this.latencyNumericUpDown.Value);
     Match match = Regex.Match(Path.GetFileName(this._waveFile) ?? "", "([0-9]+)kHz", RegexOptions.IgnoreCase);
     if (match.Success)
       this.SetCenterFrequency((long) (int.Parse(match.Groups[1].Value) * 1000));
     else
       this.SetCenterFrequency(0L);
       }
       else if (this.SourceIsSoundCard)
       {
     double inputSampleRate = 0.0;
     Match match = Regex.Match(this.sampleRateComboBox.Text, "([0-9\\.]+)", RegexOptions.IgnoreCase);
     if (match.Success)
       inputSampleRate = double.Parse(match.Groups[1].Value);
     this._streamControl.OpenSoundDevice(audioDevice1.Index, audioDevice2.Index, inputSampleRate, (int) this.latencyNumericUpDown.Value);
       }
       else
       {
     if (this._frontendController == null)
     {
       IFrontendController newFrontendController = this._frontendControllers[(string) this.iqSourceComboBox.SelectedItem];
       try
       {
     this.SelectFrontend(newFrontendController, false);
     this._frontendController = newFrontendController;
       }
       catch
       {
     newFrontendController.Close();
     throw;
       }
     }
     if (this._frontendController.IsSoundCardBased)
     {
       double inputSampleRate = 0.0;
       Match match = Regex.Match(this.sampleRateComboBox.Text, "([0-9\\.]+)", RegexOptions.IgnoreCase);
       if (match.Success)
     inputSampleRate = double.Parse(match.Groups[1].Value);
       this._streamControl.OpenSoundDevice(audioDevice1.Index, audioDevice2.Index, inputSampleRate, (int) this.latencyNumericUpDown.Value);
     }
     else
       this._streamControl.OpenPlugin(this._frontendController, audioDevice2.Index, (int) this.latencyNumericUpDown.Value);
       }
       if (this._streamControl.SampleRate > 0.0)
       {
     this._vfo.SampleRate = this._streamControl.SampleRate;
     this._vfo.DecimationStageCount = this._streamControl.DecimationStageCount;
     this.spectrumAnalyzer.SpectrumWidth = (int) this._streamControl.SampleRate;
     this.waterfall.SpectrumWidth = this.spectrumAnalyzer.SpectrumWidth;
       }
       if (this._changingSampleRate)
       {
     this._changingFrequency = true;
     this.SetCenterFrequency(this.vfoFrequencyEdit.Frequency - this._frequencyShift);
     this._changingFrequency = false;
       }
       else if (this._centerFrequency != num)
       {
     this.vfoFrequencyEdit.Frequency = this._centerFrequency + this._frequencyShift;
     this.fftZoomTrackBar.Value = 0;
     this.fftZoomTrackBar_ValueChanged((object) null, (EventArgs) null);
       }
       this.vfoFrequencyEdit_FrequencyChanged((object) null, (EventArgs) null);
       this._frequencySet = 0L;
       this.BuildFFTWindow();
 }
Beispiel #10
0
 private void SelectFrontend(IFrontendController newFrontendController, bool overrideFrequency = false)
 {
     ITunableSource tunableSource = newFrontendController as ITunableSource;
       bool flag = tunableSource == null || tunableSource.IsTunable;
       if (overrideFrequency && newFrontendController.Frequency > 0L)
       {
     this._vfo.Frequency = 0;
     this.SetCenterFrequency(newFrontendController.Frequency);
     this.vfoFrequencyEdit.Frequency = newFrontendController.Frequency + (flag ? this._frequencyShift : 0L);
       }
       if (!flag)
       {
     this.frequencyShiftCheckBox.Enabled = false;
     this.frequencyShiftNumericUpDown.Enabled = false;
     this.frequencyShiftCheckBox.Checked = false;
       }
       this.inputDeviceComboBox.Enabled = newFrontendController.IsSoundCardBased;
       this.sampleRateComboBox.Enabled = newFrontendController.IsSoundCardBased;
       if (newFrontendController.IsSoundCardBased && !string.IsNullOrEmpty(newFrontendController.SoundCardHint))
       {
     Regex regex = new Regex(newFrontendController.SoundCardHint, RegexOptions.IgnoreCase);
     for (int index = 0; index < this.inputDeviceComboBox.Items.Count; ++index)
     {
       string input = this.inputDeviceComboBox.Items[index].ToString();
       if (regex.IsMatch(input))
       {
     this.inputDeviceComboBox.SelectedIndex = index;
     break;
       }
     }
       }
       if (newFrontendController.Samplerate > 0.0)
       {
     this.waterfall.SpectrumWidth = (int) newFrontendController.Samplerate;
     this.spectrumAnalyzer.SpectrumWidth = (int) newFrontendController.Samplerate;
     this._vfo.SampleRate = newFrontendController.Samplerate;
       }
       newFrontendController.Open();
 }
Beispiel #11
0
 private void FrontendFiller(IFrontendController sender, Complex* samples, int len)
 {
     if (_iqStream.Length < _inputBufferSize * 4)
     {
         _iqStream.Write(samples, len);
     }
 }
Beispiel #12
0
 private void MainForm_Closing(object sender, CancelEventArgs e)
 {
     this._terminated = true;
       this._streamControl.Stop();
       this._fftEvent.Set();
       if (this._frontendController != null)
       {
     this._frontendController.Close();
     this._frontendController = (IFrontendController) null;
       }
       foreach (ISharpPlugin sharpPlugin in this._sharpPlugins.Values)
     sharpPlugin.Close();
       this._modeStates[this._vfo.DetectorType] = this.GetModeState();
       Utils.SaveSetting("spectrumAnalyzerAttack", (object) this.spectrumAnalyzer.Attack);
       Utils.SaveSetting("spectrumAnalyzerDecay", (object) this.spectrumAnalyzer.Decay);
       Utils.SaveSetting("waterfallAttack", (object) this.waterfall.Attack);
       Utils.SaveSetting("waterfallDecay", (object) this.waterfall.Decay);
       Utils.SaveSetting("useTimeMarkers", (object) (bool) (this.useTimestampsCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("fftSpeed", (object) this.fftSpeedTrackBar.Value);
       Utils.SaveSetting("fftContrast", (object) this.fftContrastTrackBar.Value);
       Utils.SaveSetting("fftWindowType", (object) this.fftWindowComboBox.SelectedIndex);
       Utils.SaveSetting("spectrumStyle", (object) this.spectrumStyleComboBox.SelectedIndex);
       Utils.SaveSetting("fftView", (object) this.viewComboBox.SelectedIndex);
       Utils.SaveSetting("fftResolution", (object) this.fftResolutionComboBox.SelectedIndex);
       Utils.SaveSetting("detectorType", (object) this.DetectorType);
       Utils.SaveSetting("useAGC", (object) (bool) (this.agcCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("agcThreshold", (object) (int) this.agcThresholdNumericUpDown.Value);
       Utils.SaveSetting("agcDecay", (object) (int) this.agcDecayNumericUpDown.Value);
       Utils.SaveSetting("agcSlope", (object) (int) this.agcSlopeNumericUpDown.Value);
       Utils.SaveSetting("agcHang", (object) (bool) (this.agcUseHangCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("frequencyShift", (object) (long) this.frequencyShiftNumericUpDown.Value);
       Utils.SaveSetting("frequencyShiftEnabled", (object) (bool) (this.frequencyShiftCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("swapIQ", (object) (bool) (this.swapIQCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("correctIQ", (object) (bool) (this.correctIQCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("markPeaks", (object) (bool) (this.markPeaksCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("fmStereo", (object) (bool) (this.fmStereoCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("filterAudio", (object) (bool) (this.filterAudioCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("unityGain", (object) (bool) (this.unityGainCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("latency", (object) (int) this.latencyNumericUpDown.Value);
       Utils.SaveSetting("sampleRate", this.sampleRateComboBox.Text);
       Utils.SaveSetting("audioGain", (object) this.audioGainTrackBar.Value);
       Utils.SaveSetting("AudioIsMuted", (object) (bool) (this._vfo.Muted ? 1 : 0));
       Utils.SaveSetting("windowState", (object) this.WindowState);
       Utils.SaveSetting("windowPosition", Utils.IntArrayToString(this._lastLocation.X, this._lastLocation.Y));
       Utils.SaveSetting("windowSize", Utils.IntArrayToString(this._lastSize.Width, this._lastSize.Height));
       Utils.SaveSetting("collapsiblePanelStates", Utils.IntArrayToString(this.GetCollapsiblePanelStates()));
       Utils.SaveSetting("splitterPosition", (object) this.spectrumSplitter.SplitPosition);
       Utils.SaveSetting("iqSource", (object) this.iqSourceComboBox.SelectedIndex);
       Utils.SaveSetting("waveFile", this._waveFile ?? "");
       Utils.SaveSetting("centerFrequency", (object) this._centerFrequency);
       Utils.SaveSetting("vfo", (object) this.vfoFrequencyEdit.Frequency);
       Utils.SaveSetting("tuningStyle", (object) this._tuningStyle);
       Utils.SaveSetting("fftDisplayOffset", (object) this.fftOffsetTrackBar.Value);
       Utils.SaveSetting("fftDisplayRange", (object) this.fftRangeTrackBar.Value);
       Utils.SaveSetting("inputDevice", this.inputDeviceComboBox.SelectedItem);
       Utils.SaveSetting("outputDevice", this.outputDeviceComboBox.SelectedItem);
       Utils.SaveSetting("spectrumWidth", (object) this.spectrumAnalyzer.SpectrumWidth);
       Utils.SaveSetting("lockCarrier", (object) (bool) (this.lockCarrierCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("useAntiFading", (object) (bool) (this.useAntiFadingCheckBox.Checked ? 1 : 0));
       Utils.SaveSetting("wfmState", Utils.IntArrayToString(this._modeStates[DetectorType.WFM]));
       Utils.SaveSetting("nfmState", Utils.IntArrayToString(this._modeStates[DetectorType.NFM]));
       Utils.SaveSetting("amState", Utils.IntArrayToString(this._modeStates[DetectorType.AM]));
       Utils.SaveSetting("lsbState", Utils.IntArrayToString(this._modeStates[DetectorType.LSB]));
       Utils.SaveSetting("usbState", Utils.IntArrayToString(this._modeStates[DetectorType.USB]));
       Utils.SaveSetting("dsbState", Utils.IntArrayToString(this._modeStates[DetectorType.DSB]));
       Utils.SaveSetting("cwState", Utils.IntArrayToString(this._modeStates[DetectorType.CW]));
       Utils.SaveSetting("rawState", Utils.IntArrayToString(this._modeStates[DetectorType.RAW]));
       if (this._oldTopSplitterPosition > 0)
     Utils.SaveSetting("topSplitter", (object) this._oldTopSplitterPosition);
       if (this._oldBottomSplitterPosition > 0)
     Utils.SaveSetting("bottomSplitter", (object) this._oldBottomSplitterPosition);
       if (this._oldLeftSplitterPosition > 0)
     Utils.SaveSetting("leftSplitter", (object) this._oldLeftSplitterPosition);
       if (this._oldRightSplitterPosition > 0)
     Utils.SaveSetting("rightSplitter", (object) this._oldRightSplitterPosition);
       Utils.SaveSetting("menuIsHidden", (object) (bool) (!this.scrollPanel.Visible ? 1 : 0));
 }
Beispiel #13
0
 private void frontendGuiButton_Click(object sender, EventArgs e)
 {
     if (this.SourceIsWaveFile)
       {
     this.SelectWaveFile();
       }
       else
       {
     if (this._frontendController == null)
     {
       IFrontendController newFrontendController = this._frontendControllers[(string) this.iqSourceComboBox.SelectedItem];
       try
       {
     this.SelectFrontend(newFrontendController, false);
     this._frontendController = newFrontendController;
       }
       catch (Exception ex)
       {
     newFrontendController.Close();
     int num = (int) MessageBox.Show((IWin32Window) this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     return;
       }
     }
     this._frontendController.ShowSettingGUI((IWin32Window) this);
       }
 }
Beispiel #14
0
 private unsafe void FrontendFiller(IFrontendController sender, Complex* samples, int len)
 {
     if (this._hookManager != null)
     this._hookManager.ProcessRawIQ(samples, len);
       this._iqStream.Write(samples, len);
 }
Beispiel #15
0
 public void Stop()
 {
     if (this._inputType == StreamControl.InputType.Plugin && this._frontend != null)
       {
     this._frontend.Stop();
     this._frontend = (IFrontendController) null;
       }
       if (this._wavePlayer != null)
       {
     this._wavePlayer.Dispose();
     this._wavePlayer = (WavePlayer) null;
       }
       if (this._waveRecorder != null)
       {
     this._waveRecorder.Dispose();
     this._waveRecorder = (WaveRecorder) null;
       }
       if (this._waveDuplex != null)
       {
     this._waveDuplex.Dispose();
     this._waveDuplex = (WaveDuplex) null;
       }
       this._inputSampleRate = 0.0;
       if (this._iqStream != null)
     this._iqStream.Close();
       if (this._waveReadThread != null)
       {
     this._waveReadThread.Join();
     this._waveReadThread = (Thread) null;
       }
       if (this._audioStream != null)
     this._audioStream.Close();
       if (this._dspThread != null)
       {
     this._dspThread.Join();
     this._dspThread = (Thread) null;
       }
       if (this._waveFile != null)
       {
     this._waveFile.Dispose();
     this._waveFile = (WaveFile) null;
       }
       if (this._iqStream != null)
       {
     this._iqStream.Dispose();
     this._iqStream = (ComplexFifoStream) null;
       }
       this._audioStream = (FloatFifoStream) null;
       this._dspOutBuffer = (UnsafeBuffer) null;
       this._iqInBuffer = (UnsafeBuffer) null;
 }
Beispiel #16
0
 public void OpenPlugin(IFrontendController frontend, int outputDevice, int bufferSizeInMs)
 {
     this.Stop();
       try
       {
     this._inputType = StreamControl.InputType.Plugin;
     this._frontend = frontend;
     this._inputSampleRate = this._frontend.Samplerate;
     this._outputDevice = outputDevice;
     this._bufferSizeInMs = bufferSizeInMs;
     this._inputBufferSize = (int) ((double) this._bufferSizeInMs * this._inputSampleRate / 1000.0);
     this._decimationStageCount = this.GetDecimationStageCount();
     if (this._inputBufferSize == 0)
       throw new ArgumentException("The source '" + (object) this._frontend + "' is not ready");
     int num = (int) Math.Pow(2.0, (double) this._decimationStageCount);
     this._inputBufferSize = this._inputBufferSize / num * num;
     this._inputBufferSize = this._inputBufferSize / StreamControl._processorCount * StreamControl._processorCount;
     this._bufferSizeInMs = (int) Math.Round((double) this._inputBufferSize / this._inputSampleRate * 1000.0);
     this._outputSampleRate = this._inputSampleRate / (double) num;
     this._outputBufferSize = this._inputBufferSize / num * 2;
       }
       catch
       {
     this.Stop();
     throw;
       }
 }
Beispiel #17
0
        public void OpenPlugin(IFrontendController frontend, int outputDevice, int bufferSizeInMs)
        {
            Stop();
            try
            {
                _inputType = InputType.Plugin;

                _frontend = frontend;
                _inputSampleRate = _frontend.Samplerate;

                _outputDevice = outputDevice;
                _bufferSizeInMs = bufferSizeInMs;
                _inputBufferSize = (int) (_bufferSizeInMs * _inputSampleRate / 1000);

                _decimationStageCount = GetDecimationStageCount();
                
                var decimationFactor = (int) Math.Pow(2.0, _decimationStageCount);
                _inputBufferSize = _inputBufferSize / decimationFactor * decimationFactor;
                _inputBufferSize = _inputBufferSize / _processorCount * _processorCount;
                _bufferSizeInMs = (int) Math.Round(_inputBufferSize / _inputSampleRate * 1000);
                _outputSampleRate = _inputSampleRate / decimationFactor;
                _outputBufferSize = _inputBufferSize / decimationFactor * 2;
            }
            catch
            {
                Stop();
                throw;
            }
        }