public void Navigate() { if (!_controlInterface.IsPlaying) { return; } var rowIndex = frequencyDataGridView.SelectedCells.Count > 0 ? frequencyDataGridView.SelectedCells[0].RowIndex : -1; if (rowIndex != -1) { try { var memoryEntry = (MemoryEntry)memoryEntryBindingSource.List[rowIndex]; _controlInterface.FrequencyShiftEnabled = memoryEntry.Shift != 0; if (_controlInterface.FrequencyShiftEnabled) { _controlInterface.FrequencyShift = memoryEntry.Shift; } _controlInterface.DetectorType = memoryEntry.DetectorType; _controlInterface.FilterBandwidth = (int)memoryEntry.FilterBandwidth; _controlInterface.SetFrequency(memoryEntry.Frequency, true); } catch (Exception e) { MessageBox.Show(this, e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Attempts to tune the radio to a set frequency /// </summary> private void TuneRadio() { try { if (_control != null) { _control.SetFrequency(_frequency, false); } } catch (System.ApplicationException) { MessageBox.Show("Could not tune the radio", "Auto Start Radio"); } }
public void Process(Complex *buffer, int length) { if (!_scanning) { return; } if (_control.Frequency == _checkedFrequency) { return; } if (_workingBuffer == null || _workingBuffer.Length < length) { _workingBuffer = new Complex[length]; } for (var n = 0; n < length; n++) { _workingBuffer[n] = buffer[n]; } if (_window == null || _window.Length < length) _window = FilterBuilder.MakeWindow(WindowType.Hamming, length); fixed(Complex *workingPtr = &_workingBuffer[0]) { fixed(float *winPtr = &_window[0]) Fourier.ApplyFFTWindow(workingPtr, winPtr, length); Fourier.ForwardTransform(workingPtr, length); if (_spectrum == null || _spectrum.Length < length) _spectrum = new float[length]; fixed(float *spectrumPtr = &_spectrum[0]) Fourier.SpectrumPower(workingPtr, spectrumPtr, length); } float avg = 0.0f; for (var n = 0; n < length; n++) { avg += _spectrum[n]; } avg /= length; _drawing.AddDataPoint(_control.Frequency, avg); if (_control.Frequency > _gui.EndFreq * 1000000 - _gui.Step * 1000) { StopScanning(); } else { if (_control.IsPlaying) { _checkedFrequency = _control.Frequency; _control.SetFrequency(_control.Frequency + _gui.Step * 1000, false); } } }