├── Core Includes ├── BandPlan.xml ├── FrontEnds.xml ├── NDde.dll ├── Plugins.xml ├── PortAudio.dll ├── SDRSharp.AfedriSDRNet.dll ├── SDRSharp.FUNcube.dll ├── SDRSharp.FUNcubeProPlus.dll ├── SDRSharp.HackRF.dll ├── SDRSharp.RTLSDR.dll ├── SDRSharp.RTLTCP.dll ├── SDRSharp.SDRIP.dll ├── SDRSharp.SDRIQ.dll ├── SDRSharp.SoftRock.dll ├── SRDLL.dll ├── airspy.dll ├── airspyhf.dll ├── digital_frequencies.xml ├── frequencies.xml ├── hackrf.dll ├── install-rtlsdr.bat ├── inverted_frequencies.xml ├── libusb-1.0.dll ├── modesparser.dll ├── msvcr100.dll ├── pthreadVCE2.dll ├── rtlsdr.dll ├── sdriq.dll └── shark.dll ├── README.md ├── SDRSharp.CollapsiblePanel ├── Properties │ └── AssemblyInfo.cs ├── SDRSharp.CollapsiblePanel.Properties │ ├── Resources.cs │ ├── Resources.resource │ └── Resources.resx ├── SDRSharp.CollapsiblePanel.csproj ├── SDRSharp.CollapsiblePanel.sln └── SDRSharp.CollapsiblePanel │ ├── CollapsiblePanel.cs │ ├── CollapsiblePanel.resource │ ├── CollapsiblePanel.resx │ ├── CollapsiblePanelDesigner.cs │ ├── ContentPanel.cs │ ├── ContentPanelDesigner.cs │ └── PanelStateOptions.cs ├── SDRSharp.Common ├── Properties │ └── AssemblyInfo.cs ├── SDRSharp.Common.csproj ├── SDRSharp.Common.sln ├── SDRSharp.Common │ ├── ByteSamplesEventArgs.cs │ ├── ComplexSamplesEventArgs.cs │ ├── IFFTSource.cs │ ├── ISharpControl.cs │ ├── ISharpPlugin.cs │ ├── IVFOSource.cs │ ├── PluginPosition.cs │ ├── RealSamplesEventArgs.cs │ └── SamplesAvailableDelegate.cs └── refs SDRSharp.PanView and Radio.txt ├── SDRSharp.FrequencyEdit ├── EntryMode.cs ├── FrequencyChangingEventArgs.cs ├── FrequencyEdit.cs ├── FrequencyEditDigit.cs ├── FrequencyEditDigitClickEventArgs.cs ├── FrequencyEditSeparator.cs ├── IRenderable.cs ├── OnDigitClickDelegate.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx └── SDRSharp.FrequencyEdit.csproj ├── SDRSharp.PanView ├── Properties │ └── AssemblyInfo.cs ├── SDRSharp.PanView.csproj ├── SDRSharp.PanView.sln ├── SDRSharp.PanView │ ├── BandType.cs │ ├── BandwidthEventArgs.cs │ ├── CustomPaintEventArgs.cs │ ├── CustomPaintEventHandler.cs │ ├── FrequencyChangeSource.cs │ ├── FrequencyEventArgs.cs │ ├── GradientDialog.cs │ ├── GradientDialog.resx │ ├── LineInsertEventArgs.cs │ ├── LineInsertEventHandler.cs │ ├── ManualBandwidthChangeEventHandler.cs │ ├── ManualFrequencyChangeEventHandler.cs │ ├── PeakDetector.cs │ ├── SpectrumAnalyzer.cs │ ├── SpectrumStyle.cs │ └── Waterfall.cs └── refs Radio.txt ├── SDRSharp.Radio ├── PortAudioSharp │ ├── PaDeviceIndex.cs │ ├── PaDeviceInfo.cs │ ├── PaError.cs │ ├── PaHostApiInfo.cs │ ├── PaHostApiTypeId.cs │ ├── PaHostErrorInfo.cs │ ├── PaSampleFormat.cs │ ├── PaStreamCallbackDelegate.cs │ ├── PaStreamCallbackFlags.cs │ ├── PaStreamCallbackResult.cs │ ├── PaStreamCallbackTimeInfo.cs │ ├── PaStreamFinishedCallbackDelegate.cs │ ├── PaStreamFlags.cs │ ├── PaStreamInfo.cs │ ├── PaStreamParameters.cs │ └── PortAudioAPI.cs ├── Properties │ └── AssemblyInfo.cs ├── SDRSharp.Radio.PortAudio │ ├── AudioBufferAvailableDelegate.cs │ ├── AudioBufferNeededDelegate.cs │ ├── AudioDevice.cs │ ├── DeviceDirection.cs │ ├── Int24.cs │ ├── WaveDuplex.cs │ ├── WaveFile.cs │ ├── WavePlayer.cs │ └── WaveRecorder.cs ├── SDRSharp.Radio.csproj ├── SDRSharp.Radio.sln ├── SDRSharp.Radio │ ├── AmAntiFading.cs │ ├── AmDetector.cs │ ├── AutomaticGainControl.cs │ ├── BlockMode.cs │ ├── BufferNeededDelegate.cs │ ├── CarrierLocker.cs │ ├── CircularBuffer.cs │ ├── Complex.cs │ ├── ComplexCircularBuffer.cs │ ├── ComplexDecimator.cs │ ├── ComplexFifoStream.cs │ ├── ComplexFilter.cs │ ├── CwDetector.cs │ ├── DSPThreadPool.cs │ ├── DcRemover.cs │ ├── DetectorType.cs │ ├── DownConverter.cs │ ├── FilterBuilder.cs │ ├── FirFilter.cs │ ├── FloatCircularBuffer.cs │ ├── FloatDecimator.cs │ ├── FloatFifoStream.cs │ ├── FmDetector.cs │ ├── FmMode.cs │ ├── Fourier.cs │ ├── FrequencyTranslator.cs │ ├── HookManager.cs │ ├── IBaseProcessor.cs │ ├── IConfigurationPanelProvider.cs │ ├── IConnectableSource.cs │ ├── IControlAwareObject.cs │ ├── IFloatingConfigDialogProvider.cs │ ├── IFrontendController.cs │ ├── IFrontendOffset.cs │ ├── IIQProcessor.cs │ ├── IIQStreamController.cs │ ├── INonBlockingController.cs │ ├── IQBalancer.cs │ ├── IQFirFilter.cs │ ├── IRdsBitStreamProcessor.cs │ ├── IRealProcessor.cs │ ├── ISampleRateChangeSource.cs │ ├── ISoundcardController.cs │ ├── ISpectrumProvider.cs │ ├── IStreamProcessor.cs │ ├── ITunableSource.cs │ ├── IirFilter.cs │ ├── IirFilterType.cs │ ├── Oscillator.cs │ ├── OverlapAddProcessor.cs │ ├── OverlapCrossfadeProcessor.cs │ ├── OverlapSaveProcessor.cs │ ├── OverlapSlideProcessor.cs │ ├── Pll.cs │ ├── ProcessorType.cs │ ├── RdsDecoder.cs │ ├── RdsDetectorBank.cs │ ├── RdsDumpGroups.cs │ ├── RdsFrame.cs │ ├── RdsFrameAvailableDelegate.cs │ ├── Resampler.cs │ ├── SamplesAvailableDelegate.cs │ ├── SharpEvent.cs │ ├── SharpThreadPool.cs │ ├── SideBandDetector.cs │ ├── StereoDecoder.cs │ ├── StreamControl.cs │ ├── SyndromeDetector.cs │ ├── Trig.cs │ ├── TuningStyle.cs │ ├── UnsafeBuffer.cs │ ├── Utils.cs │ ├── Vfo.cs │ └── WindowType.cs └── refs to PortAudio.dll & Shark.dll.txt ├── SDRSharp.sln └── SDRSharp ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs └── Resources.resx ├── SDRSharp.FrontEnds.Airspy ├── AirspyDevice.cs ├── AirspyGainMode.cs ├── AirspyIO.cs ├── ControllerPanel.cs ├── ControllerPanel.resx ├── ConversionFilters.cs ├── NativeMethods.cs ├── airspy_error.cs ├── airspy_gpio_pin_t.cs ├── airspy_gpio_port_t.cs ├── airspy_sample_block_cb_fn.cs ├── airspy_sample_type.cs └── airspy_transfer.cs ├── SDRSharp.FrontEnds.AirspyHF ├── AirspyHFDevice.cs ├── AirspyHFIO.cs ├── ControllerPanel.cs ├── ControllerPanel.resx ├── NativeMethods.cs ├── airspyhf_error.cs ├── airspyhf_sample_cb.cs └── airspyhf_transfer.cs ├── SDRSharp.FrontEnds.SpyServer ├── ClientHandshake.cs ├── ClientSync.cs ├── CommandHeader.cs ├── CommandType.cs ├── Constants.cs ├── ControllerPanel.cs ├── ControllerPanel.resx ├── DeviceInfo.cs ├── DeviceType.cs ├── MessageHeader.cs ├── MessageType.cs ├── SettingTarget.cs ├── SettingType.cs ├── SpyClient.cs ├── SpyServerIO.cs ├── StreamFormat.cs ├── StreamType.cs └── StreamingMode.cs ├── SDRSharp.csproj ├── SDRSharp.sln ├── SDRSharp ├── App.config ├── MainForm.cs ├── MainForm.resource ├── MainForm.resx ├── Program.cs ├── SDRSharp.ico ├── SharpControlProxy.cs └── app.manifest ├── refs Panel Common FreqEdit PanView Radio & airspy.dll airspyhf.dll .txt └── ver 1.0.0.1632.txt /Core Includes/FrontEnds.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Core Includes/NDde.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/NDde.dll -------------------------------------------------------------------------------- /Core Includes/Plugins.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Core Includes/PortAudio.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/PortAudio.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.AfedriSDRNet.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.AfedriSDRNet.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.FUNcube.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.FUNcube.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.FUNcubeProPlus.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.FUNcubeProPlus.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.HackRF.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.HackRF.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.RTLSDR.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.RTLSDR.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.RTLTCP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.RTLTCP.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.SDRIP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.SDRIP.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.SDRIQ.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.SDRIQ.dll -------------------------------------------------------------------------------- /Core Includes/SDRSharp.SoftRock.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SDRSharp.SoftRock.dll -------------------------------------------------------------------------------- /Core Includes/SRDLL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/SRDLL.dll -------------------------------------------------------------------------------- /Core Includes/airspy.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/airspy.dll -------------------------------------------------------------------------------- /Core Includes/airspyhf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/airspyhf.dll -------------------------------------------------------------------------------- /Core Includes/digital_frequencies.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Core Includes/frequencies.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | NOAA - Oxnard 6 | Weather 7 | 162550000 8 | NFM 9 | 0 10 | 24390 11 | 12 | 13 | -------------------------------------------------------------------------------- /Core Includes/hackrf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/hackrf.dll -------------------------------------------------------------------------------- /Core Includes/install-rtlsdr.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | mkdir tmp 4 | 5 | echo Downloading RTLSDR Driver 6 | httpget http://osmocom.org/attachments/download/2242/RelWithDebInfo.zip tmp\RelWithDebInfo.zip 7 | 8 | echo Downloading Zadig 9 | set zadig_exe=zadig.exe 10 | ver | findstr /l "5.1." > NUL 11 | if %errorlevel% equ 0 set zadig_exe=zadig_xp.exe 12 | httpget http://zadig.akeo.ie/downloads/%zadig_exe% %zadig_exe% 13 | 14 | unzip -o tmp\RelWithDebInfo.zip -d tmp 15 | move tmp\rtl-sdr-release\x32\rtlsdr.dll . 16 | 17 | rmdir tmp /S /Q -------------------------------------------------------------------------------- /Core Includes/inverted_frequencies.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Core Includes/libusb-1.0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/libusb-1.0.dll -------------------------------------------------------------------------------- /Core Includes/modesparser.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/modesparser.dll -------------------------------------------------------------------------------- /Core Includes/msvcr100.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/msvcr100.dll -------------------------------------------------------------------------------- /Core Includes/pthreadVCE2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/pthreadVCE2.dll -------------------------------------------------------------------------------- /Core Includes/rtlsdr.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/rtlsdr.dll -------------------------------------------------------------------------------- /Core Includes/sdriq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/sdriq.dll -------------------------------------------------------------------------------- /Core Includes/shark.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/Core Includes/shark.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SDRSharp Build 1632 Core Full Source (VS2017) 2 |

Build Order:

3 | Radio
4 | PanView
5 | Common
6 | CollapsiblePanel
7 | FrequencyEdit
8 | SDRSharp - Don't forget to check your references to the above.
9 |
10 | After successful build copy all files from 'Core Includes' to build directory.
11 |
12 | Have fun experimenting with current source!
13 |
14 | TODO: Add direct support for P25 ;)

15 | Stay tuned for further releases... Upcoming... UniTrunker (mainly for trunking) and DSDplus (mainly since they dont want to release unless your 'Fastlane', 6 months my ass)!! Just cleaning it up for successful compile. ;) 16 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.Versioning; 5 | using System.Security.Permissions; 6 | 7 | [assembly: CompilationRelaxations(8)] 8 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 9 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 10 | [assembly: AssemblyTitle("Collapsible Panel")] 11 | [assembly: AssemblyDescription("Collapsible Panel Component")] 12 | [assembly: AssemblyProduct("SDR#")] 13 | [assembly: AssemblyCopyright("Copyright © Youssef TOUIL 2012")] 14 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 15 | [assembly: AssemblyVersion("0.0.0.0")] 16 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel.Properties/Resources.cs: -------------------------------------------------------------------------------- 1 | using System.CodeDom.Compiler; 2 | using System.ComponentModel; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.Globalization; 6 | using System.Resources; 7 | using System.Runtime.CompilerServices; 8 | 9 | namespace SDRSharp.CollapsiblePanel.Properties 10 | { 11 | [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 12 | [DebuggerNonUserCode] 13 | [CompilerGenerated] 14 | internal class Resources 15 | { 16 | private static ResourceManager resourceMan; 17 | 18 | private static CultureInfo resourceCulture; 19 | 20 | [EditorBrowsable(EditorBrowsableState.Advanced)] 21 | internal static ResourceManager ResourceManager 22 | { 23 | get 24 | { 25 | if (Resources.resourceMan == null) 26 | { 27 | Resources.resourceMan = new ResourceManager("SDRSharp.CollapsiblePanel.Properties.Resources", typeof(Resources).Assembly); 28 | } 29 | return Resources.resourceMan; 30 | } 31 | } 32 | 33 | [EditorBrowsable(EditorBrowsableState.Advanced)] 34 | internal static CultureInfo Culture 35 | { 36 | get 37 | { 38 | return Resources.resourceCulture; 39 | } 40 | set 41 | { 42 | Resources.resourceCulture = value; 43 | } 44 | } 45 | 46 | internal static Bitmap CollapsedIcon 47 | { 48 | get 49 | { 50 | return (Bitmap)Resources.ResourceManager.GetObject("CollapsedIcon", Resources.resourceCulture); 51 | } 52 | } 53 | 54 | internal static string ExpandedHeigth 55 | { 56 | get 57 | { 58 | return Resources.ResourceManager.GetString("ExpandedHeigth", Resources.resourceCulture); 59 | } 60 | } 61 | 62 | internal static Bitmap ExpandedIcon 63 | { 64 | get 65 | { 66 | return (Bitmap)Resources.ResourceManager.GetObject("ExpandedIcon", Resources.resourceCulture); 67 | } 68 | } 69 | 70 | internal static Bitmap titleBackground 71 | { 72 | get 73 | { 74 | return (Bitmap)Resources.ResourceManager.GetObject("titleBackground", Resources.resourceCulture); 75 | } 76 | } 77 | 78 | internal Resources() 79 | { 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823} 5 | Debug 6 | AnyCPU 7 | Library 8 | SDRSharp.CollapsiblePanel 9 | .NETFramework 10 | v4.6 11 | 4 12 | True 13 | 14 | 15 | AnyCPU 16 | 17 | 18 | bin\Debug\ 19 | true 20 | full 21 | false 22 | 23 | 24 | bin\Release\ 25 | true 26 | pdbonly 27 | true 28 | 29 | 30 | 31 | C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll 32 | 33 | 34 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll 35 | 36 | 37 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll 38 | 39 | 40 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Design\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Design.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | UserControl 48 | 49 | 50 | 51 | Component 52 | 53 | 54 | 55 | 56 | 57 | 58 | Resources.cs 59 | 60 | 61 | CollapsiblePanel.cs 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.CollapsiblePanel", "SDRSharp.CollapsiblePanel.csproj", "{A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {AF25AAAB-B38C-48F7-A7D7-0D815C0D1E47} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel/CollapsiblePanelDesigner.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows.Forms.Design; 3 | 4 | namespace SDRSharp.CollapsiblePanel 5 | { 6 | public class CollapsiblePanelDesigner : ParentControlDesigner 7 | { 8 | public override void Initialize(IComponent component) 9 | { 10 | base.Initialize(component); 11 | if (this.Control is CollapsiblePanel) 12 | { 13 | base.EnableDesignMode(((CollapsiblePanel)this.Control).Content, "Content"); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel/ContentPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows.Forms; 4 | 5 | namespace SDRSharp.CollapsiblePanel 6 | { 7 | [Designer(typeof(ContentPanelDesigner))] 8 | public class ContentPanel : Panel 9 | { 10 | public ContentPanel() 11 | { 12 | base.Dock = DockStyle.Fill; 13 | } 14 | 15 | protected override void OnControlAdded(ControlEventArgs e) 16 | { 17 | e.Control.Resize += this.sourceControlPanel_Resize; 18 | base.OnControlAdded(e); 19 | } 20 | 21 | protected override void OnControlRemoved(ControlEventArgs e) 22 | { 23 | e.Control.Resize -= this.sourceControlPanel_Resize; 24 | base.OnControlRemoved(e); 25 | } 26 | 27 | private void sourceControlPanel_Resize(object sender, EventArgs e) 28 | { 29 | ((CollapsiblePanel)base.Parent).UpdateState(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel/ContentPanelDesigner.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Windows.Forms.Design; 3 | 4 | namespace SDRSharp.CollapsiblePanel 5 | { 6 | public class ContentPanelDesigner : ScrollableControlDesigner 7 | { 8 | protected override void PreFilterProperties(IDictionary properties) 9 | { 10 | properties.Remove("Dock"); 11 | properties.Remove("AutoSize"); 12 | properties.Remove("AutoSizeMode"); 13 | base.PreFilterProperties(properties); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SDRSharp.CollapsiblePanel/SDRSharp.CollapsiblePanel/PanelStateOptions.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.CollapsiblePanel 2 | { 3 | public enum PanelStateOptions 4 | { 5 | Collapsed, 6 | Expanded 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SDRSharp.Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.Versioning; 5 | using System.Security; 6 | using System.Security.Permissions; 7 | 8 | [assembly: CompilationRelaxations(8)] 9 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 10 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 11 | [assembly: SecurityRules(SecurityRuleSet.Level1)] 12 | [assembly: AssemblyTitle("SDR Sharp")] 13 | [assembly: AssemblyDescription("Software Defined Radio")] 14 | [assembly: AssemblyProduct("SDR#")] 15 | [assembly: AssemblyCopyright("Copyright © Youssef TOUIL 2012")] 16 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 17 | [assembly: AssemblyVersion("0.0.0.0")] 18 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E} 5 | Debug 6 | AnyCPU 7 | Library 8 | SDRSharp.Common 9 | .NETFramework 10 | v4.6 11 | 4 12 | True 13 | 14 | 15 | AnyCPU 16 | 17 | 18 | bin\Debug\ 19 | true 20 | full 21 | false 22 | 23 | 24 | bin\Release\ 25 | true 26 | pdbonly 27 | true 28 | 29 | 30 | 31 | ..\SDRSharp.PanView\bin\Debug\SDRSharp.PanView.dll 32 | 33 | 34 | ..\SDRSharp.Radio\bin\Debug\SDRSharp.Radio.dll 35 | 36 | 37 | C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll 38 | 39 | 40 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll 41 | 42 | 43 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.Common", "SDRSharp.Common.csproj", "{E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0AE04AD9-F937-4F9E-9BEC-85735408578C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/ByteSamplesEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Common 4 | { 5 | public sealed class ByteSamplesEventArgs : EventArgs 6 | { 7 | public int Length 8 | { 9 | get; 10 | set; 11 | } 12 | 13 | public unsafe byte* Buffer 14 | { 15 | get; 16 | set; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/ComplexSamplesEventArgs.cs: -------------------------------------------------------------------------------- 1 | using SDRSharp.Radio; 2 | using System; 3 | 4 | namespace SDRSharp.Common 5 | { 6 | public sealed class ComplexSamplesEventArgs : EventArgs 7 | { 8 | public int Length 9 | { 10 | get; 11 | set; 12 | } 13 | 14 | public ulong DroppedSamples 15 | { 16 | get; 17 | set; 18 | } 19 | 20 | public unsafe Complex* Buffer 21 | { 22 | get; 23 | set; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/IFFTSource.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Common 2 | { 3 | public interface IFFTSource 4 | { 5 | bool FFTEnabled 6 | { 7 | get; 8 | set; 9 | } 10 | 11 | int FFTRange 12 | { 13 | get; 14 | set; 15 | } 16 | 17 | int FFTOffset 18 | { 19 | get; 20 | set; 21 | } 22 | 23 | int DisplayBandwidth 24 | { 25 | get; 26 | } 27 | 28 | int DisplayPixels 29 | { 30 | get; 31 | set; 32 | } 33 | 34 | event SamplesAvailableDelegate FFTAvailable; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/ISharpControl.cs: -------------------------------------------------------------------------------- 1 | using SDRSharp.PanView; 2 | using SDRSharp.Radio; 3 | using System; 4 | using System.ComponentModel; 5 | using System.Drawing.Drawing2D; 6 | using System.Windows.Forms; 7 | 8 | namespace SDRSharp.Common 9 | { 10 | public interface ISharpControl 11 | { 12 | DetectorType DetectorType 13 | { 14 | get; 15 | set; 16 | } 17 | 18 | WindowType FilterType 19 | { 20 | get; 21 | set; 22 | } 23 | 24 | int AudioGain 25 | { 26 | get; 27 | set; 28 | } 29 | 30 | long CenterFrequency 31 | { 32 | get; 33 | set; 34 | } 35 | 36 | int CWShift 37 | { 38 | get; 39 | set; 40 | } 41 | 42 | bool FilterAudio 43 | { 44 | get; 45 | set; 46 | } 47 | 48 | bool UnityGain 49 | { 50 | get; 51 | set; 52 | } 53 | 54 | int FilterBandwidth 55 | { 56 | get; 57 | set; 58 | } 59 | 60 | int FilterOrder 61 | { 62 | get; 63 | set; 64 | } 65 | 66 | bool FmStereo 67 | { 68 | get; 69 | set; 70 | } 71 | 72 | long Frequency 73 | { 74 | get; 75 | set; 76 | } 77 | 78 | long FrequencyShift 79 | { 80 | get; 81 | set; 82 | } 83 | 84 | bool FrequencyShiftEnabled 85 | { 86 | get; 87 | set; 88 | } 89 | 90 | bool MarkPeaks 91 | { 92 | get; 93 | set; 94 | } 95 | 96 | bool SnapToGrid 97 | { 98 | get; 99 | set; 100 | } 101 | 102 | bool SquelchEnabled 103 | { 104 | get; 105 | set; 106 | } 107 | 108 | int SquelchThreshold 109 | { 110 | get; 111 | set; 112 | } 113 | 114 | bool IsSquelchOpen 115 | { 116 | get; 117 | } 118 | 119 | bool SwapIq 120 | { 121 | get; 122 | set; 123 | } 124 | 125 | bool UseAgc 126 | { 127 | get; 128 | set; 129 | } 130 | 131 | bool AgcHang 132 | { 133 | get; 134 | set; 135 | } 136 | 137 | int AgcThreshold 138 | { 139 | get; 140 | set; 141 | } 142 | 143 | int AgcDecay 144 | { 145 | get; 146 | set; 147 | } 148 | 149 | int AgcSlope 150 | { 151 | get; 152 | set; 153 | } 154 | 155 | int FFTResolution 156 | { 157 | get; 158 | } 159 | 160 | float FFTRange 161 | { 162 | get; 163 | } 164 | 165 | float FFTOffset 166 | { 167 | get; 168 | } 169 | 170 | int FFTContrast 171 | { 172 | get; 173 | } 174 | 175 | float VisualSNR 176 | { 177 | get; 178 | } 179 | 180 | int IFOffset 181 | { 182 | get; 183 | } 184 | 185 | ColorBlend Gradient 186 | { 187 | get; 188 | } 189 | 190 | SpectrumStyle FFTSpectrumStyle 191 | { 192 | get; 193 | } 194 | 195 | int StepSize 196 | { 197 | get; 198 | set; 199 | } 200 | 201 | int Zoom 202 | { 203 | get; 204 | set; 205 | } 206 | 207 | bool IsPlaying 208 | { 209 | get; 210 | } 211 | 212 | float SAttack 213 | { 214 | get; 215 | set; 216 | } 217 | 218 | float SDecay 219 | { 220 | get; 221 | set; 222 | } 223 | 224 | float WAttack 225 | { 226 | get; 227 | set; 228 | } 229 | 230 | float WDecay 231 | { 232 | get; 233 | set; 234 | } 235 | 236 | bool UseTimeMarkers 237 | { 238 | get; 239 | set; 240 | } 241 | 242 | string RdsProgramService 243 | { 244 | get; 245 | } 246 | 247 | string RdsRadioText 248 | { 249 | get; 250 | } 251 | 252 | bool RdsUseFEC 253 | { 254 | get; 255 | set; 256 | } 257 | 258 | int RFBandwidth 259 | { 260 | get; 261 | } 262 | 263 | int RFDisplayBandwidth 264 | { 265 | get; 266 | } 267 | 268 | int TunableBandwidth 269 | { 270 | get; 271 | } 272 | 273 | float TuningLimit 274 | { 275 | get; 276 | set; 277 | } 278 | 279 | TuningStyle TuningStyle 280 | { 281 | get; 282 | set; 283 | } 284 | 285 | bool TuningStyleFreezed 286 | { 287 | get; 288 | set; 289 | } 290 | 291 | bool SourceIsSoundCard 292 | { 293 | get; 294 | } 295 | 296 | bool SourceIsWaveFile 297 | { 298 | get; 299 | } 300 | 301 | bool SourceIsTunable 302 | { 303 | get; 304 | } 305 | 306 | object Source 307 | { 308 | get; 309 | } 310 | 311 | bool AudioIsMuted 312 | { 313 | get; 314 | set; 315 | } 316 | 317 | bool BypassDemodulation 318 | { 319 | get; 320 | set; 321 | } 322 | 323 | Type SourceType 324 | { 325 | get; 326 | } 327 | 328 | string SourceName 329 | { 330 | get; 331 | } 332 | 333 | double AudioSampleRate 334 | { 335 | get; 336 | } 337 | 338 | event PropertyChangedEventHandler PropertyChanged; 339 | 340 | event CustomPaintEventHandler WaterfallCustomPaint; 341 | 342 | event CustomPaintEventHandler SpectrumAnalyzerCustomPaint; 343 | 344 | event CustomPaintEventHandler SpectrumAnalyzerBackgroundCustomPaint; 345 | 346 | void SetFrequency(long frequency, bool onlyMoveCenterFrequency); 347 | 348 | void ResetFrequency(long frequency); 349 | 350 | void ResetFrequency(long frequency, long centerFrequency); 351 | 352 | [Obsolete("Use GetSpectrumSnapshot(float[], float, float) instead")] 353 | void GetSpectrumSnapshot(byte[] destArray); 354 | 355 | void GetSpectrumSnapshot(float[] destArray, float scale = 1f, float offset = 0f); 356 | 357 | void StartRadio(); 358 | 359 | void StopRadio(); 360 | 361 | void RegisterStreamHook(object streamHook, ProcessorType processorType); 362 | 363 | void UnregisterStreamHook(object streamHook); 364 | 365 | void RegisterFrontControl(UserControl control, PluginPosition preferredPosition); 366 | 367 | void Perform(); 368 | 369 | void RefreshSource(bool reload); 370 | } 371 | } 372 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/ISharpPlugin.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace SDRSharp.Common 4 | { 5 | public interface ISharpPlugin 6 | { 7 | UserControl Gui 8 | { 9 | get; 10 | } 11 | 12 | string DisplayName 13 | { 14 | get; 15 | } 16 | 17 | void Initialize(ISharpControl control); 18 | 19 | void Close(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/IVFOSource.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Common 2 | { 3 | public interface IVFOSource 4 | { 5 | long VFOFrequency 6 | { 7 | get; 8 | set; 9 | } 10 | 11 | int VFODecimation 12 | { 13 | get; 14 | set; 15 | } 16 | 17 | int VFOMinIQDecimation 18 | { 19 | get; 20 | } 21 | 22 | double VFOMaxSampleRate 23 | { 24 | get; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/PluginPosition.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Common 2 | { 3 | public enum PluginPosition 4 | { 5 | Top, 6 | Bottom, 7 | Left, 8 | Right 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/RealSamplesEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Common 4 | { 5 | public sealed class RealSamplesEventArgs : EventArgs 6 | { 7 | public int Length 8 | { 9 | get; 10 | set; 11 | } 12 | 13 | public ulong DroppedSamples 14 | { 15 | get; 16 | set; 17 | } 18 | 19 | public unsafe float* Buffer 20 | { 21 | get; 22 | set; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SDRSharp.Common/SDRSharp.Common/SamplesAvailableDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Common 2 | { 3 | public delegate void SamplesAvailableDelegate(object sender, ArgsType e); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.Common/refs SDRSharp.PanView and Radio.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/SDRSharp.Common/refs SDRSharp.PanView and Radio.txt -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/EntryMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.FrequencyEdit 4 | { 5 | public enum EntryMode 6 | { 7 | None, 8 | Direct, 9 | Arrow 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/FrequencyChangingEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.FrequencyEdit 4 | { 5 | public class FrequencyChangingEventArgs : EventArgs 6 | { 7 | public long Frequency { get; set; } 8 | 9 | public bool Accept { get; set; } 10 | 11 | public FrequencyChangingEventArgs() 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/FrequencyEditDigitClickEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace SDRSharp.FrequencyEdit 5 | { 6 | public class FrequencyEditDigitClickEventArgs 7 | { 8 | public FrequencyEditDigitClickEventArgs(bool isUpperHalf, MouseButtons button) 9 | { 10 | this.IsUpperHalf = isUpperHalf; 11 | this.Button = button; 12 | } 13 | 14 | public bool IsUpperHalf; 15 | 16 | public MouseButtons Button; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/FrequencyEditSeparator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Drawing.Imaging; 4 | using System.Windows.Forms; 5 | 6 | namespace SDRSharp.FrequencyEdit 7 | { 8 | internal sealed class FrequencyEditSeparator : UserControl, IRenderable 9 | { 10 | public Image Image 11 | { 12 | get 13 | { 14 | return this._image; 15 | } 16 | set 17 | { 18 | this._image = value; 19 | } 20 | } 21 | 22 | public bool Masked 23 | { 24 | get 25 | { 26 | return this._masked; 27 | } 28 | set 29 | { 30 | if (this._masked != value) 31 | { 32 | this._masked = value; 33 | this._renderNeeded = true; 34 | } 35 | } 36 | } 37 | 38 | public FrequencyEditSeparator() 39 | { 40 | this.DoubleBuffered = true; 41 | base.UpdateStyles(); 42 | ColorMatrix colorMatrix = new ColorMatrix(); 43 | colorMatrix.Matrix33 = 0.3f; 44 | this._maskedAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); 45 | } 46 | 47 | public void Render() 48 | { 49 | if (this._renderNeeded) 50 | { 51 | base.Invalidate(); 52 | this._renderNeeded = false; 53 | } 54 | } 55 | 56 | protected override void OnPaint(PaintEventArgs e) 57 | { 58 | if (this._image != null) 59 | { 60 | ImageAttributes imageAttrs = (this._masked || !base.Parent.Enabled) ? this._maskedAttributes : null; 61 | e.Graphics.DrawImage(this._image, new Rectangle(0, 0, base.Width, base.Height), 0f, 0f, (float)this._image.Width, (float)this._image.Height, GraphicsUnit.Pixel, imageAttrs); 62 | } 63 | } 64 | 65 | private const float MaskedDigitTransparency = 0.3f; 66 | 67 | private Image _image; 68 | 69 | private bool _masked; 70 | 71 | private bool _renderNeeded; 72 | 73 | private readonly ImageAttributes _maskedAttributes = new ImageAttributes(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/IRenderable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.FrequencyEdit 4 | { 5 | internal interface IRenderable 6 | { 7 | void Render(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/OnDigitClickDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.FrequencyEdit 4 | { 5 | public delegate void OnDigitClickDelegate(object sender, FrequencyEditDigitClickEventArgs args); 6 | } 7 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Runtime.Versioning; 7 | using System.Security; 8 | using System.Security.Permissions; 9 | 10 | [assembly: AssemblyVersion("1.0.0.0")] 11 | [assembly: CompilationRelaxations(8)] 12 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 13 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 14 | [assembly: AssemblyTitle("Frequency Edit Control")] 15 | [assembly: AssemblyDescription("Frequency Edit Control")] 16 | [assembly: AssemblyConfiguration("")] 17 | [assembly: AssemblyCompany("")] 18 | [assembly: AssemblyProduct("SDR#")] 19 | [assembly: AssemblyCopyright("Copyright © 2012 Youssef Touil, Ian Gilmour")] 20 | [assembly: AssemblyTrademark("")] 21 | [assembly: ComVisible(false)] 22 | [assembly: Guid("300880ef-fb6f-41ec-b607-d468751fe0ad")] 23 | [assembly: AssemblyFileVersion("1.0.0.0")] 24 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 25 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom.Compiler; 3 | using System.ComponentModel; 4 | using System.Diagnostics; 5 | using System.Drawing; 6 | using System.Globalization; 7 | using System.Resources; 8 | using System.Runtime.CompilerServices; 9 | 10 | namespace SDRSharp.FrequencyEdit.Properties 11 | { 12 | [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 13 | [DebuggerNonUserCode] 14 | [CompilerGenerated] 15 | internal class Resources 16 | { 17 | internal Resources() 18 | { 19 | } 20 | 21 | [EditorBrowsable(EditorBrowsableState.Advanced)] 22 | internal static ResourceManager ResourceManager 23 | { 24 | get 25 | { 26 | if (Resources.resourceMan == null) 27 | { 28 | Resources.resourceMan = new ResourceManager("SDRSharp.FrequencyEdit.Properties.Resources", typeof(Resources).Assembly); 29 | } 30 | return Resources.resourceMan; 31 | } 32 | } 33 | 34 | [EditorBrowsable(EditorBrowsableState.Advanced)] 35 | internal static CultureInfo Culture 36 | { 37 | get 38 | { 39 | return Resources.resourceCulture; 40 | } 41 | set 42 | { 43 | Resources.resourceCulture = value; 44 | } 45 | } 46 | 47 | internal static Bitmap Numbers 48 | { 49 | get 50 | { 51 | return (Bitmap)Resources.ResourceManager.GetObject("Numbers", Resources.resourceCulture); 52 | } 53 | } 54 | 55 | private static ResourceManager resourceMan; 56 | 57 | private static CultureInfo resourceCulture; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SDRSharp.FrequencyEdit/SDRSharp.FrequencyEdit.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0} 8 | Library 9 | SDRSharp.FrequencyEdit 10 | SDRSharp.FrequencyEdit 11 | v4.6 12 | 512 13 | 14 | 15 | AnyCPU 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | true 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | UserControl 48 | 49 | 50 | UserControl 51 | 52 | 53 | 54 | UserControl 55 | 56 | 57 | 58 | 59 | 60 | Resources.resx 61 | True 62 | True 63 | 64 | 65 | 66 | 67 | ResXFileCodeGenerator 68 | Resources.Designer.cs 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /SDRSharp.PanView/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.Versioning; 5 | using System.Security.Permissions; 6 | 7 | [assembly: CompilationRelaxations(8)] 8 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 9 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 10 | [assembly: AssemblyTitle("Panoramic Spectrum Viewer")] 11 | [assembly: AssemblyDescription("Panoramic Spectrum Viewer")] 12 | [assembly: AssemblyProduct("SDR#")] 13 | [assembly: AssemblyCopyright("Copyright © Youssef TOUIL 2012")] 14 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 15 | [assembly: AssemblyVersion("0.0.0.0")] 16 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D} 5 | Debug 6 | AnyCPU 7 | Library 8 | SDRSharp.PanView 9 | .NETFramework 10 | v4.6 11 | 4 12 | True 13 | 14 | 15 | AnyCPU 16 | 17 | 18 | bin\Debug\ 19 | true 20 | full 21 | false 22 | 23 | 24 | bin\Release\ 25 | true 26 | pdbonly 27 | true 28 | 29 | 30 | 31 | ..\SDRSharp.Radio\bin\Debug\SDRSharp.Radio.dll 32 | 33 | 34 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll 35 | 36 | 37 | C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll 38 | 39 | 40 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Form 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | UserControl 61 | 62 | 63 | 64 | UserControl 65 | 66 | 67 | 68 | 69 | GradientDialog.cs 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.PanView", "SDRSharp.PanView.csproj", "{040E3622-194B-4FA6-9CBB-1A22BD52A13D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A133AD22-210D-4E51-898D-75EF97AE9732} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/BandType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public enum BandType 4 | { 5 | Lower, 6 | Upper, 7 | Center 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/BandwidthEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.PanView 4 | { 5 | public class BandwidthEventArgs : EventArgs 6 | { 7 | public int Bandwidth 8 | { 9 | get; 10 | set; 11 | } 12 | 13 | public int Offset 14 | { 15 | get; 16 | set; 17 | } 18 | 19 | public bool Cancel 20 | { 21 | get; 22 | set; 23 | } 24 | 25 | public BandType Side 26 | { 27 | get; 28 | private set; 29 | } 30 | 31 | public BandwidthEventArgs(int bandwidth, int offset, BandType side) 32 | { 33 | this.Bandwidth = bandwidth; 34 | this.Offset = offset; 35 | this.Side = side; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/CustomPaintEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | 4 | namespace SDRSharp.PanView 5 | { 6 | public class CustomPaintEventArgs : EventArgs 7 | { 8 | public Graphics Graphics 9 | { 10 | get; 11 | private set; 12 | } 13 | 14 | public Point CursorPosition 15 | { 16 | get; 17 | private set; 18 | } 19 | 20 | public string CustomTitle 21 | { 22 | get; 23 | set; 24 | } 25 | 26 | public bool Cancel 27 | { 28 | get; 29 | set; 30 | } 31 | 32 | public CustomPaintEventArgs(Graphics graphics, Point cursorPosition) 33 | { 34 | this.Graphics = graphics; 35 | this.CursorPosition = cursorPosition; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/CustomPaintEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public delegate void CustomPaintEventHandler(object sender, CustomPaintEventArgs e); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/FrequencyChangeSource.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public enum FrequencyChangeSource 4 | { 5 | Scroll, 6 | Drag, 7 | Click 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/FrequencyEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.PanView 4 | { 5 | public class FrequencyEventArgs : EventArgs 6 | { 7 | public long Frequency 8 | { 9 | get; 10 | set; 11 | } 12 | 13 | public FrequencyChangeSource Source 14 | { 15 | get; 16 | set; 17 | } 18 | 19 | public bool Cancel 20 | { 21 | get; 22 | set; 23 | } 24 | 25 | public FrequencyEventArgs(long frequency, FrequencyChangeSource source) 26 | { 27 | this.Frequency = frequency; 28 | this.Source = source; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/GradientDialog.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/LineInsertEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.PanView 4 | { 5 | public class LineInsertEventArgs : EventArgs 6 | { 7 | public unsafe int* RgbBuffer 8 | { 9 | get; 10 | private set; 11 | } 12 | 13 | public int Length 14 | { 15 | get; 16 | private set; 17 | } 18 | 19 | public unsafe LineInsertEventArgs(int* rgbBuffer, int length) 20 | { 21 | rgbBuffer = this.RgbBuffer; 22 | this.Length = length; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/LineInsertEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public delegate void LineInsertEventHandler(object sender, LineInsertEventArgs e); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/ManualBandwidthChangeEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public delegate void ManualBandwidthChangeEventHandler(object sender, BandwidthEventArgs e); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/ManualFrequencyChangeEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public delegate void ManualFrequencyChangeEventHandler(object sender, FrequencyEventArgs e); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/PeakDetector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SDRSharp.PanView 5 | { 6 | public sealed class PeakDetector 7 | { 8 | private const byte Threshold = 20; 9 | 10 | public static void GetPeaks(byte[] buffer, List peaks, int windowSize) 11 | { 12 | windowSize |= 1; 13 | int halfSize = windowSize / 2; 14 | float num = 1f / (float)windowSize; 15 | peaks.Clear(); 16 | for (int i = 0; i < buffer.Length; i++) 17 | { 18 | int num2 = 0; 19 | int max_index = i; 20 | for (int j = 0; j < windowSize; j++) 21 | { 22 | int num3 = i + j - halfSize; 23 | if (num3 < 0) 24 | { 25 | num3 = 0; 26 | } 27 | if (num3 >= buffer.Length) 28 | { 29 | num3 = buffer.Length - 1; 30 | } 31 | if (buffer[num3] >= buffer[max_index]) 32 | { 33 | max_index = num3; 34 | } 35 | num2 += buffer[num3]; 36 | } 37 | float num4 = (float)num2 * num; 38 | if ((float)(int)buffer[max_index] - num4 > 20f && !peaks.Exists(delegate(int x) 39 | { 40 | if (Math.Abs(max_index - x) <= halfSize) 41 | { 42 | return buffer[x] > buffer[max_index]; 43 | } 44 | return false; 45 | })) 46 | { 47 | peaks.RemoveAll((int x) => Math.Abs(max_index - x) <= halfSize); 48 | peaks.Add(max_index); 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SDRSharp.PanView/SDRSharp.PanView/SpectrumStyle.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.PanView 2 | { 3 | public enum SpectrumStyle 4 | { 5 | Dots, 6 | SimpleCurve, 7 | SolidFill, 8 | StaticGradient, 9 | DynamicGradient, 10 | MinMax 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SDRSharp.PanView/refs Radio.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/SDRSharp.PanView/refs Radio.txt -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaDeviceIndex.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaDeviceIndex 4 | { 5 | PaNoDevice = -1, 6 | PaUseHostApiSpecificDeviceSpecification = -2 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaDeviceInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace PortAudioSharp 4 | { 5 | internal struct PaDeviceInfo 6 | { 7 | public int structVersion; 8 | 9 | [MarshalAs(UnmanagedType.LPStr)] 10 | public string name; 11 | 12 | public int hostApi; 13 | 14 | public int maxInputChannels; 15 | 16 | public int maxOutputChannels; 17 | 18 | public double defaultLowInputLatency; 19 | 20 | public double defaultLowOutputLatency; 21 | 22 | public double defaultHighInputLatency; 23 | 24 | public double defaultHighOutputLatency; 25 | 26 | public double defaultSampleRate; 27 | 28 | public override string ToString() 29 | { 30 | return "[" + ((object)this).GetType().Name + "]\nname: " + this.name + "\nhostApi: " + this.hostApi + "\nmaxInputChannels: " + this.maxInputChannels + "\nmaxOutputChannels: " + this.maxOutputChannels + "\ndefaultLowInputLatency: " + this.defaultLowInputLatency + "\ndefaultLowOutputLatency: " + this.defaultLowOutputLatency + "\ndefaultHighInputLatency: " + this.defaultHighInputLatency + "\ndefaultHighOutputLatency: " + this.defaultHighOutputLatency + "\ndefaultSampleRate: " + this.defaultSampleRate; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaError.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaError 4 | { 5 | paNoError, 6 | paNotInitialized = -10000, 7 | paUnanticipatedHostError, 8 | paInvalidChannelCount, 9 | paInvalidSampleRate, 10 | paInvalidDevice, 11 | paInvalidFlag, 12 | paSampleFormatNotSupported, 13 | paBadIODeviceCombination, 14 | paInsufficientMemory, 15 | paBufferTooBig, 16 | paBufferTooSmall, 17 | paNullCallback, 18 | paBadStreamPtr, 19 | paTimedOut, 20 | paInternalError, 21 | paDeviceUnavailable, 22 | paIncompatibleHostApiSpecificStreamInfo, 23 | paStreamIsStopped, 24 | paStreamIsNotStopped, 25 | paInputOverflowed, 26 | paOutputUnderflowed, 27 | paHostApiNotFound, 28 | paInvalidHostApi, 29 | paCanNotReadFromACallbackStream, 30 | paCanNotWriteToACallbackStream, 31 | paCanNotReadFromAnOutputOnlyStream, 32 | paCanNotWriteToAnInputOnlyStream, 33 | paIncompatibleStreamHostApi, 34 | paBadBufferPtr 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaHostApiInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace PortAudioSharp 4 | { 5 | internal struct PaHostApiInfo 6 | { 7 | public int structVersion; 8 | 9 | public PaHostApiTypeId type; 10 | 11 | [MarshalAs(UnmanagedType.LPStr)] 12 | public string name; 13 | 14 | public int deviceCount; 15 | 16 | public int defaultInputDevice; 17 | 18 | public int defaultOutputDevice; 19 | 20 | public override string ToString() 21 | { 22 | return "[" + ((object)this).GetType().Name + "]\nstructVersion: " + this.structVersion + "\ntype: " + this.type + "\nname: " + this.name + "\ndeviceCount: " + this.deviceCount + "\ndefaultInputDevice: " + this.defaultInputDevice + "\ndefaultOutputDevice: " + this.defaultOutputDevice; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaHostApiTypeId.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaHostApiTypeId : uint 4 | { 5 | paInDevelopment, 6 | paDirectSound, 7 | paMME, 8 | paASIO, 9 | paSoundManager, 10 | paCoreAudio, 11 | paOSS = 7u, 12 | paALSA, 13 | paAL, 14 | paBeOS, 15 | paWDMKS, 16 | paJACK, 17 | paWASAPI, 18 | paAudioScienceHPI 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaHostErrorInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace PortAudioSharp 4 | { 5 | internal struct PaHostErrorInfo 6 | { 7 | public PaHostApiTypeId hostApiType; 8 | 9 | public int errorCode; 10 | 11 | [MarshalAs(UnmanagedType.LPStr)] 12 | public string errorText; 13 | 14 | public override string ToString() 15 | { 16 | return "[" + ((object)this).GetType().Name + "]\nhostApiType: " + this.hostApiType + "\nerrorCode: " + this.errorCode + "\nerrorText: " + this.errorText; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaSampleFormat.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaSampleFormat : uint 4 | { 5 | PaFloat32 = 1u, 6 | PaInt32, 7 | PaInt24 = 4u, 8 | PaInt16 = 8u, 9 | PaInt8 = 0x10, 10 | PaUInt8 = 0x20, 11 | PaCustomFormat = 0x10000, 12 | PaNonInterleaved = 0x80000000 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamCallbackDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace PortAudioSharp 5 | { 6 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 7 | internal unsafe delegate PaStreamCallbackResult PaStreamCallbackDelegate(float* input, float* output, uint frameCount, ref PaStreamCallbackTimeInfo timeInfo, PaStreamCallbackFlags statusFlags, IntPtr userData); 8 | } 9 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamCallbackFlags.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaStreamCallbackFlags : uint 4 | { 5 | PaInputUnderflow = 1u, 6 | PaInputOverflow, 7 | PaOutputUnderflow = 4u, 8 | PaOutputOverflow = 8u, 9 | PaPrimingOutput = 0x10 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamCallbackResult.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaStreamCallbackResult : uint 4 | { 5 | PaContinue, 6 | PaComplete, 7 | PaAbort 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamCallbackTimeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal struct PaStreamCallbackTimeInfo 4 | { 5 | public double inputBufferAdcTime; 6 | 7 | public double currentTime; 8 | 9 | public double outputBufferDacTime; 10 | 11 | public override string ToString() 12 | { 13 | return "[" + ((object)this).GetType().Name + "]\ncurrentTime: " + this.currentTime + "\ninputBufferAdcTime: " + this.inputBufferAdcTime + "\noutputBufferDacTime: " + this.outputBufferDacTime; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamFinishedCallbackDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace PortAudioSharp 5 | { 6 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 7 | internal delegate void PaStreamFinishedCallbackDelegate(IntPtr userData); 8 | } 9 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamFlags.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal enum PaStreamFlags : uint 4 | { 5 | PaNoFlag, 6 | PaClipOff, 7 | PaDitherOff, 8 | PaNeverDropInput = 4u, 9 | PaPrimeOutputBuffersUsingStreamCallback = 8u, 10 | PaPlatformSpecificFlags = 4294901760u 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamInfo.cs: -------------------------------------------------------------------------------- 1 | namespace PortAudioSharp 2 | { 3 | internal struct PaStreamInfo 4 | { 5 | public int structVersion; 6 | 7 | public double inputLatency; 8 | 9 | public double outputLatency; 10 | 11 | public double sampleRate; 12 | 13 | public override string ToString() 14 | { 15 | return "[" + ((object)this).GetType().Name + "]\nstructVersion: " + this.structVersion + "\ninputLatency: " + this.inputLatency + "\noutputLatency: " + this.outputLatency + "\nsampleRate: " + this.sampleRate; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SDRSharp.Radio/PortAudioSharp/PaStreamParameters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PortAudioSharp 4 | { 5 | internal struct PaStreamParameters 6 | { 7 | public int device; 8 | 9 | public int channelCount; 10 | 11 | public PaSampleFormat sampleFormat; 12 | 13 | public double suggestedLatency; 14 | 15 | public IntPtr hostApiSpecificStreamInfo; 16 | 17 | public override string ToString() 18 | { 19 | return "[" + ((object)this).GetType().Name + "]\ndevice: " + this.device + "\nchannelCount: " + this.channelCount + "\nsampleFormat: " + this.sampleFormat + "\nsuggestedLatency: " + this.suggestedLatency; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SDRSharp.Radio/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.Versioning; 5 | using System.Security.Permissions; 6 | 7 | [assembly: CompilationRelaxations(8)] 8 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 9 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 10 | [assembly: AssemblyTitle("Radio DSP")] 11 | [assembly: AssemblyDescription("Radio DSP")] 12 | [assembly: AssemblyProduct("SDR#")] 13 | [assembly: AssemblyCopyright("Copyright © Youssef TOUIL 2012")] 14 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 15 | [assembly: AssemblyVersion("0.0.0.0")] 16 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/AudioBufferAvailableDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio.PortAudio 2 | { 3 | public unsafe delegate void AudioBufferAvailableDelegate(float* buffer, int length); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/AudioBufferNeededDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio.PortAudio 2 | { 3 | public unsafe delegate void AudioBufferNeededDelegate(float* buffer, int length); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/AudioDevice.cs: -------------------------------------------------------------------------------- 1 | using PortAudioSharp; 2 | using System.Collections.Generic; 3 | 4 | namespace SDRSharp.Radio.PortAudio 5 | { 6 | public class AudioDevice 7 | { 8 | public int Index 9 | { 10 | get; 11 | set; 12 | } 13 | 14 | public string Name 15 | { 16 | get; 17 | set; 18 | } 19 | 20 | public string Host 21 | { 22 | get; 23 | set; 24 | } 25 | 26 | public DeviceDirection Direction 27 | { 28 | get; 29 | set; 30 | } 31 | 32 | public bool IsDefault 33 | { 34 | get; 35 | set; 36 | } 37 | 38 | public static List GetDevices(DeviceDirection direction) 39 | { 40 | List list = new List(); 41 | int num = PortAudioAPI.Pa_GetDefaultInputDevice(); 42 | int num2 = PortAudioAPI.Pa_GetDefaultOutputDevice(); 43 | int num3 = PortAudioAPI.Pa_GetDeviceCount(); 44 | for (int i = 0; i < num3; i++) 45 | { 46 | PaDeviceInfo paDeviceInfo = PortAudioAPI.Pa_GetDeviceInfo(i); 47 | DeviceDirection deviceDirection = (paDeviceInfo.maxInputChannels <= 0) ? DeviceDirection.Output : ((paDeviceInfo.maxOutputChannels > 0) ? DeviceDirection.InputOutput : DeviceDirection.Input); 48 | if (deviceDirection == direction || deviceDirection == DeviceDirection.InputOutput) 49 | { 50 | PaHostApiInfo paHostApiInfo = PortAudioAPI.Pa_GetHostApiInfo(paDeviceInfo.hostApi); 51 | AudioDevice audioDevice = new AudioDevice(); 52 | audioDevice.Name = paDeviceInfo.name; 53 | audioDevice.Host = paHostApiInfo.name; 54 | audioDevice.Index = i; 55 | audioDevice.Direction = deviceDirection; 56 | audioDevice.IsDefault = (i == num || i == num2); 57 | list.Add(audioDevice); 58 | } 59 | } 60 | return list; 61 | } 62 | 63 | public override string ToString() 64 | { 65 | return "[" + this.Host + "] " + this.Name; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/DeviceDirection.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio.PortAudio 2 | { 3 | public enum DeviceDirection 4 | { 5 | Input, 6 | Output, 7 | InputOutput 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/Int24.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio.PortAudio 2 | { 3 | public struct Int24 4 | { 5 | public byte C; 6 | 7 | public byte B; 8 | 9 | public sbyte A; 10 | 11 | public static implicit operator float(Int24 i) 12 | { 13 | return (float)((i.C << 8 | i.B << 16 | i.A << 24) >> 8); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/WaveDuplex.cs: -------------------------------------------------------------------------------- 1 | using PortAudioSharp; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace SDRSharp.Radio.PortAudio 6 | { 7 | public class WaveDuplex : IDisposable 8 | { 9 | private IntPtr _streamHandle; 10 | 11 | private GCHandle _gcHandle; 12 | 13 | private readonly AudioBufferAvailableDelegate _bufferAvailable; 14 | 15 | private unsafe readonly PaStreamCallbackDelegate _paCallback = WaveDuplex.PaStreamCallback; 16 | 17 | public unsafe WaveDuplex(int deviceIndex, double sampleRate, int framesPerBuffer, AudioBufferAvailableDelegate bufferNeededDelegate) 18 | { 19 | this._bufferAvailable = bufferNeededDelegate; 20 | PaStreamParameters paStreamParameters = new PaStreamParameters 21 | { 22 | device = deviceIndex, 23 | channelCount = 2, 24 | suggestedLatency = 0.0, 25 | sampleFormat = PaSampleFormat.PaFloat32 26 | }; 27 | PaError paError = PortAudioAPI.Pa_IsFormatSupported(ref paStreamParameters, ref paStreamParameters, sampleRate); 28 | if (paError != 0) 29 | { 30 | throw new ApplicationException(paError.ToString()); 31 | } 32 | this._gcHandle = GCHandle.Alloc(this); 33 | paError = PortAudioAPI.Pa_OpenStream(out this._streamHandle, ref paStreamParameters, ref paStreamParameters, sampleRate, (uint)framesPerBuffer, PaStreamFlags.PaNoFlag, this._paCallback, (IntPtr)this._gcHandle); 34 | if (paError != 0) 35 | { 36 | this._gcHandle.Free(); 37 | throw new ApplicationException(paError.ToString()); 38 | } 39 | paError = PortAudioAPI.Pa_StartStream(this._streamHandle); 40 | if (paError == PaError.paNoError) 41 | { 42 | return; 43 | } 44 | PortAudioAPI.Pa_CloseStream(this._streamHandle); 45 | this._gcHandle.Free(); 46 | throw new ApplicationException(paError.ToString()); 47 | } 48 | 49 | private unsafe static PaStreamCallbackResult PaStreamCallback(float* input, float* output, uint frameCount, ref PaStreamCallbackTimeInfo timeInfo, PaStreamCallbackFlags statusFlags, IntPtr userData) 50 | { 51 | GCHandle gCHandle = GCHandle.FromIntPtr(userData); 52 | if (!gCHandle.IsAllocated) 53 | { 54 | return PaStreamCallbackResult.PaAbort; 55 | } 56 | WaveDuplex waveDuplex = (WaveDuplex)gCHandle.Target; 57 | try 58 | { 59 | Utils.Memcpy(output, input, (int)(frameCount * 2 * 4)); 60 | if (waveDuplex._bufferAvailable != null) 61 | { 62 | waveDuplex._bufferAvailable(output, (int)frameCount); 63 | } 64 | } 65 | catch 66 | { 67 | return PaStreamCallbackResult.PaAbort; 68 | } 69 | return PaStreamCallbackResult.PaContinue; 70 | } 71 | 72 | public void Dispose() 73 | { 74 | if (this._streamHandle != IntPtr.Zero) 75 | { 76 | PortAudioAPI.Pa_StopStream(this._streamHandle); 77 | PortAudioAPI.Pa_CloseStream(this._streamHandle); 78 | this._streamHandle = IntPtr.Zero; 79 | } 80 | this._gcHandle.Free(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/WavePlayer.cs: -------------------------------------------------------------------------------- 1 | using PortAudioSharp; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace SDRSharp.Radio.PortAudio 6 | { 7 | public class WavePlayer : IDisposable 8 | { 9 | private IntPtr _streamHandle; 10 | 11 | private GCHandle _gcHandle; 12 | 13 | private readonly AudioBufferNeededDelegate _bufferNeeded; 14 | 15 | private unsafe readonly PaStreamCallbackDelegate _paCallback = WavePlayer.PaStreamCallback; 16 | 17 | public unsafe WavePlayer(int deviceIndex, double sampleRate, int framesPerBuffer, AudioBufferNeededDelegate bufferNeededDelegate) 18 | { 19 | this._bufferNeeded = bufferNeededDelegate; 20 | PaStreamParameters paStreamParameters = new PaStreamParameters 21 | { 22 | device = deviceIndex, 23 | channelCount = 2, 24 | suggestedLatency = 0.0, 25 | sampleFormat = PaSampleFormat.PaFloat32 26 | }; 27 | PaError paError = PortAudioAPI.Pa_IsFormatSupported(IntPtr.Zero, ref paStreamParameters, sampleRate); 28 | if (paError != 0) 29 | { 30 | throw new ApplicationException(paError.ToString()); 31 | } 32 | this._gcHandle = GCHandle.Alloc(this); 33 | paError = PortAudioAPI.Pa_OpenStream(out this._streamHandle, IntPtr.Zero, ref paStreamParameters, sampleRate, (uint)framesPerBuffer, PaStreamFlags.PaNoFlag, this._paCallback, (IntPtr)this._gcHandle); 34 | if (paError != 0) 35 | { 36 | this._gcHandle.Free(); 37 | throw new ApplicationException(paError.ToString()); 38 | } 39 | paError = PortAudioAPI.Pa_StartStream(this._streamHandle); 40 | if (paError == PaError.paNoError) 41 | { 42 | return; 43 | } 44 | PortAudioAPI.Pa_CloseStream(this._streamHandle); 45 | this._gcHandle.Free(); 46 | throw new ApplicationException(paError.ToString()); 47 | } 48 | 49 | private unsafe static PaStreamCallbackResult PaStreamCallback(float* input, float* output, uint frameCount, ref PaStreamCallbackTimeInfo timeInfo, PaStreamCallbackFlags statusFlags, IntPtr userData) 50 | { 51 | GCHandle gCHandle = GCHandle.FromIntPtr(userData); 52 | if (!gCHandle.IsAllocated) 53 | { 54 | return PaStreamCallbackResult.PaAbort; 55 | } 56 | WavePlayer wavePlayer = (WavePlayer)gCHandle.Target; 57 | try 58 | { 59 | if (wavePlayer._bufferNeeded != null) 60 | { 61 | wavePlayer._bufferNeeded(output, (int)frameCount); 62 | } 63 | } 64 | catch 65 | { 66 | return PaStreamCallbackResult.PaAbort; 67 | } 68 | return PaStreamCallbackResult.PaContinue; 69 | } 70 | 71 | public void Dispose() 72 | { 73 | if (this._streamHandle != IntPtr.Zero) 74 | { 75 | PortAudioAPI.Pa_StopStream(this._streamHandle); 76 | PortAudioAPI.Pa_CloseStream(this._streamHandle); 77 | this._streamHandle = IntPtr.Zero; 78 | } 79 | this._gcHandle.Free(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.PortAudio/WaveRecorder.cs: -------------------------------------------------------------------------------- 1 | using PortAudioSharp; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace SDRSharp.Radio.PortAudio 6 | { 7 | public class WaveRecorder : IDisposable 8 | { 9 | private IntPtr _streamHandle; 10 | 11 | private GCHandle _gcHandle; 12 | 13 | private readonly AudioBufferAvailableDelegate _bufferAvailable; 14 | 15 | private unsafe readonly PaStreamCallbackDelegate _paCallback = WaveRecorder.PaStreamCallback; 16 | 17 | public unsafe WaveRecorder(int deviceIndex, double sampleRate, int framesPerBuffer, AudioBufferAvailableDelegate bufferAvailable) 18 | { 19 | this._bufferAvailable = bufferAvailable; 20 | PaStreamParameters paStreamParameters = new PaStreamParameters 21 | { 22 | device = deviceIndex, 23 | channelCount = 2, 24 | suggestedLatency = 0.0, 25 | sampleFormat = PaSampleFormat.PaFloat32 26 | }; 27 | PaError paError = PortAudioAPI.Pa_IsFormatSupported(ref paStreamParameters, IntPtr.Zero, sampleRate); 28 | if (paError != 0) 29 | { 30 | throw new ApplicationException(paError.ToString()); 31 | } 32 | this._gcHandle = GCHandle.Alloc(this); 33 | paError = PortAudioAPI.Pa_OpenStream(out this._streamHandle, ref paStreamParameters, IntPtr.Zero, sampleRate, (uint)framesPerBuffer, PaStreamFlags.PaNoFlag, this._paCallback, (IntPtr)this._gcHandle); 34 | if (paError != 0) 35 | { 36 | this._gcHandle.Free(); 37 | throw new ApplicationException(paError.ToString()); 38 | } 39 | paError = PortAudioAPI.Pa_StartStream(this._streamHandle); 40 | if (paError == PaError.paNoError) 41 | { 42 | return; 43 | } 44 | PortAudioAPI.Pa_CloseStream(this._streamHandle); 45 | this._gcHandle.Free(); 46 | throw new ApplicationException(paError.ToString()); 47 | } 48 | 49 | private unsafe static PaStreamCallbackResult PaStreamCallback(float* input, float* output, uint frameCount, ref PaStreamCallbackTimeInfo timeInfo, PaStreamCallbackFlags statusFlags, IntPtr userData) 50 | { 51 | GCHandle gCHandle = GCHandle.FromIntPtr(userData); 52 | if (!gCHandle.IsAllocated) 53 | { 54 | return PaStreamCallbackResult.PaAbort; 55 | } 56 | WaveRecorder waveRecorder = (WaveRecorder)gCHandle.Target; 57 | try 58 | { 59 | if (waveRecorder._bufferAvailable != null) 60 | { 61 | waveRecorder._bufferAvailable(input, (int)frameCount); 62 | } 63 | } 64 | catch 65 | { 66 | return PaStreamCallbackResult.PaAbort; 67 | } 68 | return PaStreamCallbackResult.PaContinue; 69 | } 70 | 71 | public void Dispose() 72 | { 73 | if (this._streamHandle != IntPtr.Zero) 74 | { 75 | PortAudioAPI.Pa_StopStream(this._streamHandle); 76 | PortAudioAPI.Pa_CloseStream(this._streamHandle); 77 | this._streamHandle = IntPtr.Zero; 78 | } 79 | this._gcHandle.Free(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.Radio", "SDRSharp.Radio.csproj", "{A24DD927-34EF-4301-BDF3-42C872BC944E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6BA50BE1-BD57-44A9-8AD3-3F881F01F86F} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/AmAntiFading.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class AmAntiFading : OverlapAddProcessor 4 | { 5 | public AmAntiFading() 6 | : base(4096) 7 | { 8 | } 9 | 10 | protected unsafe override void ProcessFft(Complex* buffer, int length) 11 | { 12 | for (int i = 1; i < length / 2 - 1; i++) 13 | { 14 | int num = i; 15 | int num2 = length - i; 16 | float num3 = buffer[num].ModulusSquared(); 17 | float num4 = buffer[num2].ModulusSquared(); 18 | if (num3 > num4) 19 | { 20 | buffer[num2] = buffer[num].Conjugate(); 21 | } 22 | else 23 | { 24 | buffer[num] = buffer[num2].Conjugate(); 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/AmDetector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public sealed class AmDetector 6 | { 7 | private float _avg; 8 | 9 | private float _powerThreshold; 10 | 11 | private int _squelchThreshold; 12 | 13 | private bool _isSquelchOpen; 14 | 15 | public int SquelchThreshold 16 | { 17 | get 18 | { 19 | return this._squelchThreshold; 20 | } 21 | set 22 | { 23 | if (this._squelchThreshold != value) 24 | { 25 | this._squelchThreshold = value; 26 | this._powerThreshold = ((float)this._squelchThreshold / 100f - 1f) * 100f - 50f; 27 | } 28 | } 29 | } 30 | 31 | public bool IsSquelchOpen 32 | { 33 | get 34 | { 35 | return this._isSquelchOpen; 36 | } 37 | } 38 | 39 | public unsafe void Demodulate(Complex* iq, float* audio, int length) 40 | { 41 | for (int i = 0; i < length; i++) 42 | { 43 | float num = iq[i].Modulus(); 44 | if (this._squelchThreshold == 0) 45 | { 46 | audio[i] = num; 47 | } 48 | else 49 | { 50 | float num2 = (float)(20.0 * Math.Log10(1E-60 + (double)num)); 51 | this._avg = 0.99f * this._avg + 0.01f * num2; 52 | this._isSquelchOpen = (this._avg > this._powerThreshold); 53 | audio[i] = num; 54 | if (!this._isSquelchOpen) 55 | { 56 | audio[i] *= 1E-15f; 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/BlockMode.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum BlockMode 4 | { 5 | None, 6 | BlockingRead, 7 | BlockingWrite, 8 | BlockingReadWrite 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/BufferNeededDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public unsafe delegate void BufferNeededDelegate(Complex* iqBuffer, float* audioBuffer, int length); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/CarrierLocker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public class CarrierLocker 6 | { 7 | private const int PllRange = 2000; 8 | 9 | private const int PllBandwith = 10; 10 | 11 | private const float PllThreshold = 2f; 12 | 13 | private const float PllLockTime = 0.5f; 14 | 15 | private const float PllResumeDelay = 0.5f; 16 | 17 | private const float PllZeta = 1.5f; 18 | 19 | private const float PllPhaseAdjM = 0f; 20 | 21 | private const float PllPhaseAdjB = 0f; 22 | 23 | private const float TimeConst = 0.003f; 24 | 25 | private Pll _pll; 26 | 27 | private float _iavg; 28 | 29 | private float _qavg; 30 | 31 | private float _alpha; 32 | 33 | private int _unlockedCount; 34 | 35 | private int _maxUnlockedTicks; 36 | 37 | private bool _resetNeeded; 38 | 39 | private double _sampleRate; 40 | 41 | public double SampleRate 42 | { 43 | get 44 | { 45 | return this._sampleRate; 46 | } 47 | set 48 | { 49 | if (value != this._sampleRate) 50 | { 51 | this._sampleRate = value; 52 | this.Configure(); 53 | } 54 | } 55 | } 56 | 57 | public bool IsLocked 58 | { 59 | get 60 | { 61 | return this._pll.IsLocked; 62 | } 63 | } 64 | 65 | private void Configure() 66 | { 67 | this._pll.SampleRate = (float)this._sampleRate; 68 | this._pll.DefaultFrequency = 0f; 69 | this._pll.Range = 2000f; 70 | this._pll.Bandwidth = 10f; 71 | this._pll.Zeta = 1.5f; 72 | this._pll.PhaseAdjM = 0f; 73 | this._pll.PhaseAdjB = 0f; 74 | this._pll.LockTime = 0.5f; 75 | this._pll.LockThreshold = 2f; 76 | this._alpha = (float)(1.0 - Math.Exp(-1.0 / (this._sampleRate * 0.0030000000260770321))); 77 | this._maxUnlockedTicks = (int)(this._sampleRate * 0.5); 78 | } 79 | 80 | public void Reset() 81 | { 82 | this._resetNeeded = true; 83 | } 84 | 85 | public unsafe void Process(Complex* buffer, int length) 86 | { 87 | if (this._resetNeeded) 88 | { 89 | this._pll.Reset(); 90 | this._resetNeeded = false; 91 | } 92 | for (int i = 0; i < length; i++) 93 | { 94 | Complex b = Complex.FromAngleFast(this._pll.Phase); 95 | Complex* intPtr = buffer + i; 96 | *intPtr *= b; 97 | Complex complex = buffer[i]; 98 | if (this._pll.StickOnFrequencyIfNotLocked || this._pll.IsLocked) 99 | { 100 | this._iavg += this._alpha * (complex.Real - this._iavg); 101 | this._qavg += this._alpha * (complex.Imag - this._qavg); 102 | complex.Real = this._iavg; 103 | complex.Imag = this._qavg; 104 | this._pll.StickOnFrequencyIfNotLocked = true; 105 | if (this._pll.IsLocked) 106 | { 107 | this._unlockedCount = 0; 108 | } 109 | else if (++this._unlockedCount > this._maxUnlockedTicks) 110 | { 111 | this._pll.StickOnFrequencyIfNotLocked = false; 112 | this._unlockedCount = 0; 113 | } 114 | } 115 | complex *= b.Conjugate(); 116 | this._pll.Process(complex); 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/CircularBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public class CircularBuffer : IDisposable 7 | { 8 | private readonly int _bufferSize; 9 | 10 | private readonly int _elementSize; 11 | 12 | private readonly int _maxBufferCount; 13 | 14 | private readonly SharpEvent _readEvent = new SharpEvent(false); 15 | 16 | private readonly SharpEvent _writeEvent = new SharpEvent(false); 17 | 18 | private int _count; 19 | 20 | private int _len; 21 | 22 | private int _head; 23 | 24 | private int _tail; 25 | 26 | private bool _closed; 27 | 28 | private List _buffers = new List(); 29 | 30 | public int BufferSize 31 | { 32 | get 33 | { 34 | return this._bufferSize; 35 | } 36 | } 37 | 38 | public int BufferCount 39 | { 40 | get 41 | { 42 | return this._maxBufferCount; 43 | } 44 | } 45 | 46 | public int AvailableCount 47 | { 48 | get 49 | { 50 | return this._count; 51 | } 52 | } 53 | 54 | protected CircularBuffer(int bufferSize, int elementSize, int maxBufferCount) 55 | { 56 | this._bufferSize = bufferSize; 57 | this._elementSize = elementSize; 58 | this._maxBufferCount = maxBufferCount; 59 | for (int i = 0; i < this._maxBufferCount; i++) 60 | { 61 | this._buffers.Add(UnsafeBuffer.Create(this._bufferSize, this._elementSize)); 62 | } 63 | } 64 | 65 | ~CircularBuffer() 66 | { 67 | this.Dispose(); 68 | } 69 | 70 | public void Dispose() 71 | { 72 | this.Close(); 73 | GC.SuppressFinalize(this); 74 | } 75 | 76 | protected unsafe bool Write(byte* buffer, int len, bool block) 77 | { 78 | int num = len; 79 | while (num > 0 && !this._closed) 80 | { 81 | if (block) 82 | { 83 | while (this._count >= this._maxBufferCount && !this._closed) 84 | { 85 | this._writeEvent.WaitOne(); 86 | } 87 | } 88 | else if (this._count >= this._maxBufferCount) 89 | { 90 | return false; 91 | } 92 | if (this._closed) 93 | { 94 | return false; 95 | } 96 | byte* ptr = (byte*)(void*)this._buffers[this._head]; 97 | int num2 = Math.Min(this._bufferSize - this._len, num); 98 | int num3 = num2 * this._elementSize; 99 | Utils.Memcpy(ptr + this._len * this._elementSize, buffer, num3); 100 | buffer += num3; 101 | this._len += num2; 102 | num -= num2; 103 | if (this._len == this._bufferSize) 104 | { 105 | this._len = 0; 106 | this._head = (this._head + 1) % this._maxBufferCount; 107 | lock (this) 108 | { 109 | this._count++; 110 | this._readEvent.Set(); 111 | } 112 | } 113 | } 114 | return true; 115 | } 116 | 117 | protected unsafe void* AcquireRawBuffer(bool block) 118 | { 119 | if (this._closed) 120 | { 121 | return null; 122 | } 123 | if (block) 124 | { 125 | while (this._count == 0 && !this._closed) 126 | { 127 | this._readEvent.WaitOne(); 128 | } 129 | } 130 | if (!this._closed && this._count != 0) 131 | { 132 | return this._buffers[this._tail]; 133 | } 134 | return null; 135 | } 136 | 137 | public void Release() 138 | { 139 | if (!this._closed && this._count != 0) 140 | { 141 | this._tail = (this._tail + 1) % this._maxBufferCount; 142 | lock (this) 143 | { 144 | this._count--; 145 | this._writeEvent.Set(); 146 | } 147 | } 148 | } 149 | 150 | public void Close() 151 | { 152 | this._closed = true; 153 | this._readEvent.Set(); 154 | this._writeEvent.Set(); 155 | this._head = 0; 156 | this._tail = 0; 157 | this._count = 0; 158 | this._len = 0; 159 | lock (this) 160 | { 161 | foreach (UnsafeBuffer buffer in this._buffers) 162 | { 163 | buffer.Dispose(); 164 | } 165 | this._buffers.Clear(); 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/Complex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public struct Complex 6 | { 7 | public float Real; 8 | 9 | public float Imag; 10 | 11 | public Complex(float real, float imaginary) 12 | { 13 | this.Real = real; 14 | this.Imag = imaginary; 15 | } 16 | 17 | public Complex(Complex c) 18 | { 19 | this.Real = c.Real; 20 | this.Imag = c.Imag; 21 | } 22 | 23 | public float Modulus() 24 | { 25 | return (float)Math.Sqrt((double)this.ModulusSquared()); 26 | } 27 | 28 | public float ModulusSquared() 29 | { 30 | return this.Real * this.Real + this.Imag * this.Imag; 31 | } 32 | 33 | public float Argument() 34 | { 35 | return (float)Math.Atan2((double)this.Imag, (double)this.Real); 36 | } 37 | 38 | public float ArgumentFast() 39 | { 40 | return Trig.Atan2(this.Imag, this.Real); 41 | } 42 | 43 | public Complex Conjugate() 44 | { 45 | Complex result = default(Complex); 46 | result.Real = this.Real; 47 | result.Imag = 0f - this.Imag; 48 | return result; 49 | } 50 | 51 | public Complex Normalize() 52 | { 53 | float b = 1f / this.Modulus(); 54 | return this * b; 55 | } 56 | 57 | public Complex NormalizeFast() 58 | { 59 | float b = 1.95f - this.ModulusSquared(); 60 | return this * b; 61 | } 62 | 63 | public override string ToString() 64 | { 65 | return string.Format("real {0}, imag {1}", this.Real, this.Imag); 66 | } 67 | 68 | public static Complex FromAngle(double angle) 69 | { 70 | Complex result = default(Complex); 71 | result.Real = (float)Math.Cos(angle); 72 | result.Imag = (float)Math.Sin(angle); 73 | return result; 74 | } 75 | 76 | public static Complex FromAngleFast(float angle) 77 | { 78 | return Trig.SinCos(angle); 79 | } 80 | 81 | public static bool operator ==(Complex leftHandSide, Complex rightHandSide) 82 | { 83 | if (leftHandSide.Real != rightHandSide.Real) 84 | { 85 | return false; 86 | } 87 | return leftHandSide.Imag == rightHandSide.Imag; 88 | } 89 | 90 | public static bool operator !=(Complex leftHandSide, Complex rightHandSide) 91 | { 92 | if (leftHandSide.Real != rightHandSide.Real) 93 | { 94 | return true; 95 | } 96 | return leftHandSide.Imag != rightHandSide.Imag; 97 | } 98 | 99 | public static Complex operator +(Complex a, Complex b) 100 | { 101 | Complex result = default(Complex); 102 | result.Real = a.Real + b.Real; 103 | result.Imag = a.Imag + b.Imag; 104 | return result; 105 | } 106 | 107 | public static Complex operator -(Complex a, Complex b) 108 | { 109 | Complex result = default(Complex); 110 | result.Real = a.Real - b.Real; 111 | result.Imag = a.Imag - b.Imag; 112 | return result; 113 | } 114 | 115 | public static Complex operator *(Complex a, Complex b) 116 | { 117 | Complex result = default(Complex); 118 | result.Real = a.Real * b.Real - a.Imag * b.Imag; 119 | result.Imag = a.Imag * b.Real + a.Real * b.Imag; 120 | return result; 121 | } 122 | 123 | public static Complex operator *(Complex a, float b) 124 | { 125 | Complex result = default(Complex); 126 | result.Real = a.Real * b; 127 | result.Imag = a.Imag * b; 128 | return result; 129 | } 130 | 131 | public static Complex operator /(Complex a, Complex b) 132 | { 133 | float num = b.Real * b.Real + b.Imag * b.Imag; 134 | num = 1f / num; 135 | Complex result = default(Complex); 136 | result.Real = (a.Real * b.Real + a.Imag * b.Imag) * num; 137 | result.Imag = (a.Imag * b.Real - a.Real * b.Imag) * num; 138 | return result; 139 | } 140 | 141 | public static Complex operator /(Complex a, float b) 142 | { 143 | b = 1f / b; 144 | Complex result = default(Complex); 145 | result.Real = a.Real * b; 146 | result.Imag = a.Imag * b; 147 | return result; 148 | } 149 | 150 | public static Complex operator ~(Complex a) 151 | { 152 | return a.Conjugate(); 153 | } 154 | 155 | public static implicit operator Complex(float d) 156 | { 157 | return new Complex(d, 0f); 158 | } 159 | 160 | public override int GetHashCode() 161 | { 162 | return this.Real.GetHashCode() * 397 ^ this.Imag.GetHashCode(); 163 | } 164 | 165 | public bool Equals(Complex obj) 166 | { 167 | if (obj.Real == this.Real) 168 | { 169 | return obj.Imag == this.Imag; 170 | } 171 | return false; 172 | } 173 | 174 | public override bool Equals(object obj) 175 | { 176 | if (obj.GetType() != typeof(Complex)) 177 | { 178 | return false; 179 | } 180 | return this.Equals((Complex)obj); 181 | } 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ComplexCircularBuffer.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class ComplexCircularBuffer : CircularBuffer 4 | { 5 | public unsafe ComplexCircularBuffer(int bufferSize, int maxBufferCount) 6 | : base(bufferSize, sizeof(Complex), maxBufferCount) 7 | { 8 | } 9 | 10 | public unsafe bool Write(Complex* buffer, int len, bool block) 11 | { 12 | return base.Write((byte*)buffer, len, block); 13 | } 14 | 15 | public unsafe bool Write(Complex* buffer, int len) 16 | { 17 | return base.Write((byte*)buffer, len, true); 18 | } 19 | 20 | public unsafe Complex* Acquire() 21 | { 22 | return this.Acquire(true); 23 | } 24 | 25 | public unsafe Complex* Acquire(bool block) 26 | { 27 | return (Complex*)base.AcquireRawBuffer(block); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ComplexDecimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class ComplexDecimator : IDisposable 7 | { 8 | private IntPtr _dec; 9 | 10 | private int _decimationRatio; 11 | 12 | public int DecimationRatio 13 | { 14 | get 15 | { 16 | return this._decimationRatio; 17 | } 18 | } 19 | 20 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 21 | private static extern IntPtr complex_decimator_create(int decimation); 22 | 23 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 24 | private static extern void complex_decimator_destroy(IntPtr instance); 25 | 26 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 27 | private unsafe static extern int complex_decimator_process(IntPtr instance, Complex* buffer, int length); 28 | 29 | public ComplexDecimator(int decimationRatio) 30 | { 31 | this._decimationRatio = decimationRatio; 32 | this._dec = ComplexDecimator.complex_decimator_create(decimationRatio); 33 | } 34 | 35 | public void Dispose() 36 | { 37 | if (this._dec != IntPtr.Zero) 38 | { 39 | ComplexDecimator.complex_decimator_destroy(this._dec); 40 | this._dec = IntPtr.Zero; 41 | } 42 | } 43 | 44 | public unsafe int Process(Complex* buffer, int length) 45 | { 46 | return ComplexDecimator.complex_decimator_process(this._dec, buffer, length); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ComplexFilter.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class ComplexFilter : OverlapSaveProcessor 4 | { 5 | private UnsafeBuffer _kernelBuffer; 6 | 7 | private unsafe Complex* _kernelPtr; 8 | 9 | private int _actualKernelLength; 10 | 11 | public int KernelSize 12 | { 13 | get 14 | { 15 | return this._actualKernelLength; 16 | } 17 | } 18 | 19 | public unsafe ComplexFilter(Complex[] kernel) 20 | : base(ComplexFilter.GetFFTSize(kernel.Length)) 21 | { 22 | this._actualKernelLength = kernel.Length; 23 | this._kernelBuffer = UnsafeBuffer.Create(base.FFTSize, sizeof(Complex)); 24 | this._kernelPtr = (Complex*)(void*)this._kernelBuffer; 25 | this.SetKernel(kernel); 26 | } 27 | 28 | private static int GetFFTSize(int length) 29 | { 30 | int num; 31 | for (num = 1; num < length; num <<= 1) 32 | { 33 | } 34 | return num << 1; 35 | } 36 | 37 | public bool IsKernelLengthSupported(int length) 38 | { 39 | return length < base.FFTSize / 2; 40 | } 41 | 42 | public unsafe void SetKernel(Complex[] kernel) 43 | { 44 | if (this.IsKernelLengthSupported(kernel.Length)) 45 | { 46 | fixed (Complex* src = kernel) 47 | { 48 | Utils.Memcpy(this._kernelPtr, src, kernel.Length * sizeof(Complex)); 49 | } 50 | for (int i = kernel.Length; i < base.FFTSize; i++) 51 | { 52 | this._kernelPtr[i] = 0f; 53 | } 54 | Fourier.ForwardTransform(this._kernelPtr, base.FFTSize, false); 55 | } 56 | } 57 | 58 | protected unsafe override void ProcessFft(Complex* buffer, int length) 59 | { 60 | for (int i = 0; i < length; i++) 61 | { 62 | Complex* intPtr = buffer + i; 63 | *intPtr *= this._kernelPtr[i]; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/CwDetector.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public sealed class CwDetector 4 | { 5 | private Oscillator _bfo = new Oscillator(); 6 | 7 | public double SampleRate 8 | { 9 | get 10 | { 11 | return this._bfo.SampleRate; 12 | } 13 | set 14 | { 15 | this._bfo.SampleRate = value; 16 | } 17 | } 18 | 19 | public int BfoFrequency 20 | { 21 | get 22 | { 23 | return (int)this._bfo.Frequency; 24 | } 25 | set 26 | { 27 | this._bfo.Frequency = (double)value; 28 | } 29 | } 30 | 31 | public unsafe void Demodulate(Complex* iq, float* audio, int length) 32 | { 33 | for (int i = 0; i < length; i++) 34 | { 35 | this._bfo.Tick(); 36 | audio[i] = (iq[i] * this._bfo.Phase).Real; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/DSPThreadPool.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public static class DSPThreadPool 6 | { 7 | private static SharpThreadPool _threadPool; 8 | 9 | public static void Initialize() 10 | { 11 | if (DSPThreadPool._threadPool == null) 12 | { 13 | DSPThreadPool._threadPool = new SharpThreadPool(); 14 | } 15 | } 16 | 17 | public static void Initialize(int threadCount) 18 | { 19 | if (DSPThreadPool._threadPool == null) 20 | { 21 | DSPThreadPool._threadPool = new SharpThreadPool(threadCount); 22 | } 23 | } 24 | 25 | public static void QueueUserWorkItem(WaitCallback callback) 26 | { 27 | if (DSPThreadPool._threadPool == null) 28 | { 29 | DSPThreadPool._threadPool = new SharpThreadPool(); 30 | } 31 | DSPThreadPool._threadPool.QueueUserWorkItem(callback); 32 | } 33 | 34 | public static void QueueUserWorkItem(WaitCallback callback, object parameter) 35 | { 36 | if (DSPThreadPool._threadPool == null) 37 | { 38 | DSPThreadPool._threadPool = new SharpThreadPool(); 39 | } 40 | DSPThreadPool._threadPool.QueueUserWorkItem(callback, parameter); 41 | } 42 | 43 | public static void Terminate() 44 | { 45 | if (DSPThreadPool._threadPool != null) 46 | { 47 | DSPThreadPool._threadPool.Dispose(); 48 | DSPThreadPool._threadPool = null; 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/DcRemover.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | [StructLayout(LayoutKind.Sequential, Pack = 16)] 6 | public struct DcRemover 7 | { 8 | private float _average; 9 | 10 | private float _ratio; 11 | 12 | public float Offset 13 | { 14 | get 15 | { 16 | return this._average; 17 | } 18 | } 19 | 20 | public DcRemover(float ratio) 21 | { 22 | this._ratio = ratio; 23 | this._average = 0f; 24 | } 25 | 26 | public void Init(float ratio) 27 | { 28 | this._ratio = ratio; 29 | this._average = 0f; 30 | } 31 | 32 | public unsafe void Process(float* buffer, int length) 33 | { 34 | for (int i = 0; i < length; i++) 35 | { 36 | this._average += this._ratio * (buffer[i] - this._average); 37 | buffer[i] -= this._average; 38 | } 39 | } 40 | 41 | public unsafe void ProcessInterleaved(float* buffer, int length) 42 | { 43 | length *= 2; 44 | for (int i = 0; i < length; i += 2) 45 | { 46 | this._average += this._ratio * (buffer[i] - this._average); 47 | buffer[i] -= this._average; 48 | } 49 | } 50 | 51 | public void Reset() 52 | { 53 | this._average = 0f; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/DetectorType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum DetectorType 4 | { 5 | NFM, 6 | WFM, 7 | AM, 8 | DSB, 9 | LSB, 10 | USB, 11 | CW, 12 | RAW 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/DownConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class DownConverter : IDisposable 7 | { 8 | private IntPtr _dec; 9 | 10 | private int _decimationRatio; 11 | 12 | private double _sampleRate; 13 | 14 | private double _frequency; 15 | 16 | public double Frequency 17 | { 18 | get 19 | { 20 | return this._frequency; 21 | } 22 | set 23 | { 24 | if (this._frequency != value) 25 | { 26 | this._frequency = value; 27 | DownConverter.ddc_tune(this._dec, this._frequency); 28 | } 29 | } 30 | } 31 | 32 | public int DecimationRatio 33 | { 34 | get 35 | { 36 | return this._decimationRatio; 37 | } 38 | } 39 | 40 | public double SampleRate 41 | { 42 | get 43 | { 44 | return this._sampleRate; 45 | } 46 | } 47 | 48 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 49 | private static extern IntPtr ddc_create(double sample_rate, int decimation); 50 | 51 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 52 | private static extern void ddc_destroy(IntPtr instance); 53 | 54 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 55 | private static extern void ddc_tune(IntPtr instance, double frequency); 56 | 57 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 58 | private unsafe static extern int ddc_process(IntPtr instance, Complex* buffer, int length); 59 | 60 | public DownConverter(double sampleRate, int decimationRatio) 61 | { 62 | this._sampleRate = sampleRate; 63 | this._decimationRatio = decimationRatio; 64 | this._dec = DownConverter.ddc_create(this._sampleRate, this._decimationRatio); 65 | } 66 | 67 | public void Dispose() 68 | { 69 | if (this._dec != IntPtr.Zero) 70 | { 71 | DownConverter.ddc_destroy(this._dec); 72 | this._dec = IntPtr.Zero; 73 | } 74 | } 75 | 76 | public unsafe int Process(Complex* buffer, int length) 77 | { 78 | return DownConverter.ddc_process(this._dec, buffer, length); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/FirFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class FirFilter : IDisposable 7 | { 8 | private int _decimationRatio; 9 | 10 | private int _length; 11 | 12 | private IntPtr _fir; 13 | 14 | public int Length 15 | { 16 | get 17 | { 18 | return this._length; 19 | } 20 | } 21 | 22 | public int DecimationRatio 23 | { 24 | get 25 | { 26 | return this._decimationRatio; 27 | } 28 | } 29 | 30 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 31 | private unsafe static extern IntPtr float_fir_create(float* kernel, int length, int decimation); 32 | 33 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 34 | private static extern void float_fir_destroy(IntPtr instance); 35 | 36 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 37 | private unsafe static extern int float_fir_process(IntPtr instance, float* buffer, int length); 38 | 39 | public unsafe FirFilter(float[] coefficients, int decimationRatio = 1) 40 | { 41 | if (decimationRatio <= 0) 42 | { 43 | throw new ArgumentException("The decimation factor must be greater than zero", "decimationRatio"); 44 | } 45 | this._decimationRatio = decimationRatio; 46 | this._length = coefficients.Length; 47 | fixed (float* kernel = coefficients) 48 | { 49 | this._fir = FirFilter.float_fir_create(kernel, this._length, decimationRatio); 50 | } 51 | } 52 | 53 | public void Dispose() 54 | { 55 | if (this._fir != IntPtr.Zero) 56 | { 57 | FirFilter.float_fir_destroy(this._fir); 58 | this._fir = IntPtr.Zero; 59 | } 60 | GC.SuppressFinalize(this); 61 | } 62 | 63 | public unsafe int Process(float* buffer, int length) 64 | { 65 | return FirFilter.float_fir_process(this._fir, buffer, length); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/FloatCircularBuffer.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class FloatCircularBuffer : CircularBuffer 4 | { 5 | public FloatCircularBuffer(int bufferSize, int maxBufferCount) 6 | : base(bufferSize, 4, maxBufferCount) 7 | { 8 | } 9 | 10 | public unsafe bool Write(float* buffer, int len, bool block) 11 | { 12 | return base.Write((byte*)buffer, len, block); 13 | } 14 | 15 | public unsafe bool Write(float* buffer, int len) 16 | { 17 | return base.Write((byte*)buffer, len, true); 18 | } 19 | 20 | public unsafe float* Acquire() 21 | { 22 | return (float*)base.AcquireRawBuffer(true); 23 | } 24 | 25 | public unsafe float* Acquire(bool block) 26 | { 27 | return (float*)base.AcquireRawBuffer(block); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/FloatDecimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class FloatDecimator : IDisposable 7 | { 8 | private IntPtr _dec; 9 | 10 | private int _decimationRatio; 11 | 12 | public int DecimationRatio 13 | { 14 | get 15 | { 16 | return this._decimationRatio; 17 | } 18 | } 19 | 20 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 21 | private static extern IntPtr float_decimator_create(int decimation); 22 | 23 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 24 | private static extern void float_decimator_destroy(IntPtr instance); 25 | 26 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 27 | private unsafe static extern int float_decimator_process(IntPtr instance, float* buffer, int length); 28 | 29 | public FloatDecimator(int decimationRatio) 30 | { 31 | this._decimationRatio = decimationRatio; 32 | this._dec = FloatDecimator.float_decimator_create(decimationRatio); 33 | } 34 | 35 | public void Dispose() 36 | { 37 | if (this._dec != IntPtr.Zero) 38 | { 39 | FloatDecimator.float_decimator_destroy(this._dec); 40 | this._dec = IntPtr.Zero; 41 | } 42 | } 43 | 44 | public unsafe int Process(float* buffer, int length) 45 | { 46 | return FloatDecimator.float_decimator_process(this._dec, buffer, length); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/FmDetector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public sealed class FmDetector 6 | { 7 | private const float NarrowAFGain = 0.5f; 8 | 9 | private const float FMGain = 1E-05f; 10 | 11 | private const int MinHissFrequency = 4000; 12 | 13 | private const int MaxHissFrequency = 6000; 14 | 15 | private const int HissFilterOrder = 20; 16 | 17 | private const float HissFactor = 2E-05f; 18 | 19 | private unsafe float* _hissPtr; 20 | 21 | private UnsafeBuffer _hissBuffer; 22 | 23 | private FirFilter _hissFilter; 24 | 25 | private Complex _iqState; 26 | 27 | private float _noiseLevel; 28 | 29 | private double _sampleRate; 30 | 31 | private float _noiseAveragingRatio; 32 | 33 | private int _squelchThreshold; 34 | 35 | private bool _isSquelchOpen; 36 | 37 | private float _noiseThreshold; 38 | 39 | private FmMode _mode; 40 | 41 | public double SampleRate 42 | { 43 | get 44 | { 45 | return this._sampleRate; 46 | } 47 | set 48 | { 49 | if (value != this._sampleRate) 50 | { 51 | this._sampleRate = value; 52 | this._noiseAveragingRatio = (float)(30.0 / this._sampleRate); 53 | float[] coefficients = FilterBuilder.MakeBandPassKernel(this._sampleRate, 20, 4000.0, 6000.0, WindowType.BlackmanHarris4); 54 | if (this._hissFilter != null) 55 | { 56 | this._hissFilter.Dispose(); 57 | } 58 | this._hissFilter = new FirFilter(coefficients, 1); 59 | } 60 | } 61 | } 62 | 63 | public int SquelchThreshold 64 | { 65 | get 66 | { 67 | return this._squelchThreshold; 68 | } 69 | set 70 | { 71 | if (this._squelchThreshold != value) 72 | { 73 | this._squelchThreshold = value; 74 | this._noiseThreshold = (float)Math.Log10(2.0 - (double)this._squelchThreshold / 100.0) * 2E-05f; 75 | } 76 | } 77 | } 78 | 79 | public bool IsSquelchOpen 80 | { 81 | get 82 | { 83 | return this._isSquelchOpen; 84 | } 85 | } 86 | 87 | public FmMode Mode 88 | { 89 | get 90 | { 91 | return this._mode; 92 | } 93 | set 94 | { 95 | this._mode = value; 96 | } 97 | } 98 | 99 | public unsafe void Demodulate(Complex* iq, float* audio, int length) 100 | { 101 | for (int i = 0; i < length; i++) 102 | { 103 | Complex a = iq[i] * this._iqState.Conjugate(); 104 | float num = a.Modulus(); 105 | if (num > 0f) 106 | { 107 | a /= num; 108 | } 109 | float num2 = a.Argument(); 110 | if (!float.IsNaN(num2)) 111 | { 112 | audio[i] = num2 * 1E-05f; 113 | } 114 | else 115 | { 116 | audio[i] = 0f; 117 | } 118 | this._iqState = iq[i]; 119 | } 120 | if (this._mode == FmMode.Narrow) 121 | { 122 | this.ProcessSquelch(audio, length); 123 | for (int j = 0; j < length; j++) 124 | { 125 | audio[j] *= 0.5f; 126 | } 127 | } 128 | } 129 | 130 | private unsafe void ProcessSquelch(float* audio, int length) 131 | { 132 | if (this._squelchThreshold > 0) 133 | { 134 | if (this._hissBuffer == null || this._hissBuffer.Length != length) 135 | { 136 | this._hissBuffer = UnsafeBuffer.Create(length, 4); 137 | this._hissPtr = (float*)(void*)this._hissBuffer; 138 | } 139 | Utils.Memcpy(this._hissPtr, audio, length * 4); 140 | this._hissFilter.Process(this._hissPtr, length); 141 | for (int i = 0; i < this._hissBuffer.Length; i++) 142 | { 143 | this._noiseLevel = (1f - this._noiseAveragingRatio) * this._noiseLevel + this._noiseAveragingRatio * Math.Abs(this._hissPtr[i]); 144 | if (this._noiseLevel > this._noiseThreshold) 145 | { 146 | audio[i] *= 1E-15f; 147 | } 148 | } 149 | this._isSquelchOpen = (this._noiseLevel < this._noiseThreshold); 150 | } 151 | else 152 | { 153 | this._isSquelchOpen = true; 154 | } 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/FmMode.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum FmMode 4 | { 5 | Narrow, 6 | Wide 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/FrequencyTranslator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public class FrequencyTranslator : IDisposable 7 | { 8 | private IntPtr _nco; 9 | 10 | private double _sampleRate; 11 | 12 | private double _frequency; 13 | 14 | public double SampleRate 15 | { 16 | get 17 | { 18 | return this._sampleRate; 19 | } 20 | } 21 | 22 | public double Frequency 23 | { 24 | get 25 | { 26 | return this._frequency; 27 | } 28 | set 29 | { 30 | if (this._frequency != value) 31 | { 32 | this._frequency = value; 33 | FrequencyTranslator.nco_tune(this._nco, this._frequency); 34 | } 35 | } 36 | } 37 | 38 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 39 | private static extern IntPtr nco_create(double sample_rate); 40 | 41 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 42 | private static extern void nco_destroy(IntPtr instance); 43 | 44 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 45 | private static extern void nco_tune(IntPtr instance, double frequency); 46 | 47 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 48 | private unsafe static extern void nco_process(IntPtr instance, Complex* buffer, int length); 49 | 50 | public FrequencyTranslator(double sampleRate) 51 | { 52 | this._sampleRate = sampleRate; 53 | this._nco = FrequencyTranslator.nco_create(sampleRate); 54 | } 55 | 56 | public void Dispose() 57 | { 58 | if (this._nco != IntPtr.Zero) 59 | { 60 | FrequencyTranslator.nco_destroy(this._nco); 61 | this._nco = IntPtr.Zero; 62 | } 63 | } 64 | 65 | public unsafe void Process(Complex* buffer, int length) 66 | { 67 | FrequencyTranslator.nco_process(this._nco, buffer, length); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IBaseProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IBaseProcessor 4 | { 5 | bool Enabled 6 | { 7 | get; 8 | set; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IConfigurationPanelProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public interface IConfigurationPanelProvider 6 | { 7 | UserControl Gui 8 | { 9 | get; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IConnectableSource.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IConnectableSource 4 | { 5 | bool Connected 6 | { 7 | get; 8 | } 9 | 10 | void Connect(); 11 | 12 | void Disconnect(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IControlAwareObject.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IControlAwareObject 4 | { 5 | void SetControl(object control); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IFloatingConfigDialogProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public interface IFloatingConfigDialogProvider 6 | { 7 | void ShowSettingGUI(IWin32Window parent); 8 | 9 | void HideSettingGUI(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IFrontendController.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IFrontendController 4 | { 5 | void Open(); 6 | 7 | void Close(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IFrontendOffset.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IFrontendOffset 4 | { 5 | int Offset 6 | { 7 | get; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IIQProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IIQProcessor : IStreamProcessor, IBaseProcessor 4 | { 5 | unsafe void Process(Complex* buffer, int length); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IIQStreamController.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IIQStreamController 4 | { 5 | double Samplerate 6 | { 7 | get; 8 | } 9 | 10 | void Start(SamplesAvailableDelegate callback); 11 | 12 | void Stop(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/INonBlockingController.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface INonBlockingController 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IQFirFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class IQFirFilter : IDisposable 7 | { 8 | private int _decimationRatio; 9 | 10 | private int _length; 11 | 12 | private IntPtr _fir; 13 | 14 | public int Length 15 | { 16 | get 17 | { 18 | return this._length; 19 | } 20 | } 21 | 22 | public int DecimationRatio 23 | { 24 | get 25 | { 26 | return this._decimationRatio; 27 | } 28 | } 29 | 30 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 31 | private unsafe static extern IntPtr complex_fir_create(float* kernel, int length, int decimation); 32 | 33 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 34 | private static extern void complex_fir_destroy(IntPtr instance); 35 | 36 | [DllImport("shark", CallingConvention = CallingConvention.Cdecl)] 37 | private unsafe static extern int complex_fir_process(IntPtr instance, Complex* buffer, int length); 38 | 39 | public unsafe IQFirFilter(float[] coefficients, int decimationRatio = 1) 40 | { 41 | if (decimationRatio <= 0) 42 | { 43 | throw new ArgumentException("The decimation factor must be greater than zero", "decimationRatio"); 44 | } 45 | this._decimationRatio = decimationRatio; 46 | this._length = coefficients.Length; 47 | fixed (float* kernel = coefficients) 48 | { 49 | this._fir = IQFirFilter.complex_fir_create(kernel, this._length, decimationRatio); 50 | } 51 | } 52 | 53 | public void Dispose() 54 | { 55 | if (this._fir != IntPtr.Zero) 56 | { 57 | IQFirFilter.complex_fir_destroy(this._fir); 58 | this._fir = IntPtr.Zero; 59 | } 60 | GC.SuppressFinalize(this); 61 | } 62 | 63 | public unsafe int Process(Complex* buffer, int length) 64 | { 65 | return IQFirFilter.complex_fir_process(this._fir, buffer, length); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IRdsBitStreamProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IRdsBitStreamProcessor : IBaseProcessor 4 | { 5 | void Process(ref RdsFrame frame); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IRealProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IRealProcessor : IStreamProcessor, IBaseProcessor 4 | { 5 | unsafe void Process(float* buffer, int length); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ISampleRateChangeSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public interface ISampleRateChangeSource 6 | { 7 | event EventHandler SampleRateChanged; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ISoundcardController.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface ISoundcardController 4 | { 5 | string SoundCardHint 6 | { 7 | get; 8 | } 9 | 10 | double SampleRateHint 11 | { 12 | get; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ISpectrumProvider.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface ISpectrumProvider 4 | { 5 | float UsableSpectrumRatio 6 | { 7 | get; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IStreamProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface IStreamProcessor : IBaseProcessor 4 | { 5 | double SampleRate 6 | { 7 | set; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ITunableSource.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public interface ITunableSource 4 | { 5 | bool CanTune 6 | { 7 | get; 8 | } 9 | 10 | long Frequency 11 | { 12 | get; 13 | set; 14 | } 15 | 16 | long MinimumTunableFrequency 17 | { 18 | get; 19 | } 20 | 21 | long MaximumTunableFrequency 22 | { 23 | get; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IirFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | [StructLayout(LayoutKind.Sequential, Pack = 16)] 7 | public struct IirFilter 8 | { 9 | private float _a0; 10 | 11 | private float _a1; 12 | 13 | private float _a2; 14 | 15 | private float _b0; 16 | 17 | private float _b1; 18 | 19 | private float _b2; 20 | 21 | private float _x1; 22 | 23 | private float _x2; 24 | 25 | private float _y1; 26 | 27 | private float _y2; 28 | 29 | public void Init(IirFilterType filterType, double frequency, double sampleRate, double qualityFactor) 30 | { 31 | double num = 6.2831853071795862 * frequency / sampleRate; 32 | double num2 = Math.Sin(num) / (2.0 * qualityFactor); 33 | switch (filterType) 34 | { 35 | case IirFilterType.LowPass: 36 | this._b0 = (float)((1.0 - Math.Cos(num)) / 2.0); 37 | this._b1 = (float)(1.0 - Math.Cos(num)); 38 | this._b2 = (float)((1.0 - Math.Cos(num)) / 2.0); 39 | this._a0 = (float)(1.0 + num2); 40 | this._a1 = (float)(-2.0 * Math.Cos(num)); 41 | this._a2 = (float)(1.0 - num2); 42 | break; 43 | case IirFilterType.HighPass: 44 | this._b0 = (float)((1.0 + Math.Cos(num)) / 2.0); 45 | this._b1 = (float)(0.0 - (1.0 + Math.Cos(num))); 46 | this._b2 = (float)((1.0 + Math.Cos(num)) / 2.0); 47 | this._a0 = (float)(1.0 + num2); 48 | this._a1 = (float)(-2.0 * Math.Cos(num)); 49 | this._a2 = (float)(1.0 - num2); 50 | break; 51 | default: 52 | this._b0 = (float)num2; 53 | this._b1 = 0f; 54 | this._b2 = (float)(0.0 - num2); 55 | this._a0 = (float)(1.0 + num2); 56 | this._a1 = (float)(-2.0 * Math.Cos(num)); 57 | this._a2 = (float)(1.0 - num2); 58 | break; 59 | case IirFilterType.Notch: 60 | this._b0 = 1f; 61 | this._b1 = (float)(-2.0 * Math.Cos(num)); 62 | this._b2 = 1f; 63 | this._a0 = (float)(1.0 + num2); 64 | this._a1 = (float)(-2.0 * Math.Cos(num)); 65 | this._a2 = (float)(1.0 - num2); 66 | break; 67 | } 68 | this._b0 /= this._a0; 69 | this._b1 /= this._a0; 70 | this._b2 /= this._a0; 71 | this._a1 /= this._a0; 72 | this._a2 /= this._a0; 73 | this._x1 = 0f; 74 | this._x2 = 0f; 75 | this._y1 = 0f; 76 | this._y2 = 0f; 77 | } 78 | 79 | public void Reset() 80 | { 81 | this._x1 = 0f; 82 | this._x2 = 0f; 83 | this._y1 = 0f; 84 | this._y2 = 0f; 85 | } 86 | 87 | public float Process(float sample) 88 | { 89 | float num = this._b0 * sample + this._b1 * this._x1 + this._b2 * this._x2 - this._a1 * this._y1 - this._a2 * this._y2; 90 | this._x2 = this._x1; 91 | this._x1 = sample; 92 | this._y2 = this._y1; 93 | this._y1 = num; 94 | return num; 95 | } 96 | 97 | public unsafe void Process(float* buffer, int length) 98 | { 99 | for (int i = 0; i < length; i++) 100 | { 101 | buffer[i] = this.Process(buffer[i]); 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/IirFilterType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum IirFilterType 4 | { 5 | LowPass, 6 | HighPass, 7 | BandPass, 8 | Notch 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/Oscillator.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class Oscillator 4 | { 5 | private Complex _vector; 6 | 7 | private Complex _rotation; 8 | 9 | private double _sampleRate; 10 | 11 | private double _frequency; 12 | 13 | public double SampleRate 14 | { 15 | get 16 | { 17 | return this._sampleRate; 18 | } 19 | set 20 | { 21 | if (this._sampleRate != value) 22 | { 23 | this._sampleRate = value; 24 | this.Configure(); 25 | } 26 | } 27 | } 28 | 29 | public double Frequency 30 | { 31 | get 32 | { 33 | return this._frequency; 34 | } 35 | set 36 | { 37 | if (this._frequency != value) 38 | { 39 | this._frequency = value; 40 | this.Configure(); 41 | } 42 | } 43 | } 44 | 45 | public Complex Phase 46 | { 47 | get 48 | { 49 | return this._vector; 50 | } 51 | set 52 | { 53 | this._vector = value; 54 | } 55 | } 56 | 57 | public float Real 58 | { 59 | get 60 | { 61 | return this._vector.Real; 62 | } 63 | set 64 | { 65 | this._vector.Real = value; 66 | } 67 | } 68 | 69 | public float Imag 70 | { 71 | get 72 | { 73 | return this._vector.Imag; 74 | } 75 | set 76 | { 77 | this._vector.Imag = value; 78 | } 79 | } 80 | 81 | private void Configure() 82 | { 83 | if (this._vector.Real == 0f && this._vector.Imag == 0f) 84 | { 85 | this._vector.Real = 1f; 86 | } 87 | if (this._sampleRate != 0.0) 88 | { 89 | double angle = 6.2831853071795862 * this._frequency / this._sampleRate; 90 | this._rotation = Complex.FromAngle(angle); 91 | } 92 | } 93 | 94 | public void Tick() 95 | { 96 | this._vector *= this._rotation; 97 | this._vector = this._vector.NormalizeFast(); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/OverlapAddProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public abstract class OverlapAddProcessor 6 | { 7 | private readonly int _fftSize; 8 | 9 | private readonly int _halfSize; 10 | 11 | private int _inputPos; 12 | 13 | private int _outputPos; 14 | 15 | private UnsafeBuffer _fftBuffer; 16 | 17 | private unsafe Complex* _fftPtr; 18 | 19 | private UnsafeBuffer _queuepBuffer; 20 | 21 | private unsafe Complex* _queuePtr; 22 | 23 | private UnsafeBuffer _outputBuffer; 24 | 25 | private unsafe Complex* _outputPtr; 26 | 27 | private UnsafeBuffer _overlapBuffer; 28 | 29 | private unsafe Complex* _overlapPtr; 30 | 31 | private UnsafeBuffer _windowBuffer; 32 | 33 | private unsafe float* _windowPtr; 34 | 35 | public int FFTSize 36 | { 37 | get 38 | { 39 | return this._fftSize; 40 | } 41 | } 42 | 43 | public unsafe OverlapAddProcessor(int fftSize) 44 | { 45 | this._fftSize = fftSize; 46 | this._halfSize = this._fftSize / 2; 47 | this._inputPos = this._halfSize; 48 | this._queuepBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 49 | this._queuePtr = (Complex*)(void*)this._queuepBuffer; 50 | this._windowBuffer = UnsafeBuffer.Create(this._fftSize, 4); 51 | this._windowPtr = (float*)(void*)this._windowBuffer; 52 | this._fftBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 53 | this._fftPtr = (Complex*)(void*)this._fftBuffer; 54 | this._outputBuffer = UnsafeBuffer.Create(this._halfSize, sizeof(Complex)); 55 | this._outputPtr = (Complex*)(void*)this._outputBuffer; 56 | this._overlapBuffer = UnsafeBuffer.Create(this._halfSize, sizeof(Complex)); 57 | this._overlapPtr = (Complex*)(void*)this._overlapBuffer; 58 | double num = 1.5707963267948966 / (double)(this._halfSize - 1); 59 | for (int i = 0; i < this._halfSize; i++) 60 | { 61 | double a = (double)i * num; 62 | this._windowPtr[i] = (float)Math.Sin(a); 63 | this._windowPtr[this._fftSize - 1 - i] = this._windowPtr[i]; 64 | } 65 | } 66 | 67 | public unsafe virtual void Process(Complex* buffer, int length) 68 | { 69 | while (length > 0) 70 | { 71 | int num = Math.Min(this._fftSize - this._inputPos, length); 72 | Utils.Memcpy(this._queuePtr + this._inputPos, buffer, num * sizeof(Complex)); 73 | Utils.Memcpy(buffer, this._outputPtr + this._outputPos, num * sizeof(Complex)); 74 | buffer += num; 75 | this._inputPos += num; 76 | this._outputPos += num; 77 | length -= num; 78 | if (this._inputPos == this._fftSize) 79 | { 80 | this.OverlapAdd(); 81 | this._inputPos = this._halfSize; 82 | this._outputPos = 0; 83 | } 84 | } 85 | } 86 | 87 | public unsafe virtual void Process(float* buffer, int length, int step = 1) 88 | { 89 | for (int i = 0; i < length; i += step) 90 | { 91 | this._queuePtr[this._inputPos++] = buffer[i]; 92 | buffer[i] = this._outputPtr[this._outputPos++].Real; 93 | if (this._inputPos == this._fftSize) 94 | { 95 | this.OverlapAdd(); 96 | this._inputPos = this._halfSize; 97 | this._outputPos = 0; 98 | } 99 | } 100 | } 101 | 102 | private unsafe void OverlapAdd() 103 | { 104 | for (int i = 0; i < this._fftSize; i++) 105 | { 106 | this._fftPtr[i] = this._queuePtr[i] * this._windowPtr[i]; 107 | } 108 | Fourier.ForwardTransform(this._fftPtr, this._fftSize, false); 109 | this.ProcessFft(this._fftPtr, this._fftSize); 110 | Fourier.InverseTransform(this._fftPtr, this._fftSize); 111 | for (int j = 0; j < this._halfSize; j++) 112 | { 113 | this._outputPtr[j] = this._overlapPtr[j] * this._windowPtr[this._halfSize + j] + this._fftPtr[j] * this._windowPtr[j]; 114 | } 115 | Utils.Memcpy(this._overlapPtr, this._fftPtr + this._halfSize, this._halfSize * sizeof(Complex)); 116 | Utils.Memcpy(this._queuePtr, this._queuePtr + this._halfSize, this._halfSize * sizeof(Complex)); 117 | } 118 | 119 | protected unsafe abstract void ProcessFft(Complex* buffer, int length); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/OverlapCrossfadeProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public abstract class OverlapCrossfadeProcessor 6 | { 7 | private readonly int _fftSize; 8 | 9 | private readonly int _halfSize; 10 | 11 | private readonly int _outputSize; 12 | 13 | private readonly int _crossFadingSize; 14 | 15 | private int _inputPos; 16 | 17 | private int _outputPos; 18 | 19 | private UnsafeBuffer _fftBuffer; 20 | 21 | private unsafe Complex* _fftPtr; 22 | 23 | private UnsafeBuffer _queuepBuffer; 24 | 25 | private unsafe Complex* _queuePtr; 26 | 27 | private UnsafeBuffer _outputBuffer; 28 | 29 | private unsafe Complex* _outputPtr; 30 | 31 | private UnsafeBuffer _crossFadingBuffer; 32 | 33 | private unsafe Complex* _crossFadingPtr; 34 | 35 | private UnsafeBuffer _windowBuffer; 36 | 37 | private unsafe float* _windowPtr; 38 | 39 | public int FFTSize 40 | { 41 | get 42 | { 43 | return this._fftSize; 44 | } 45 | } 46 | 47 | public unsafe OverlapCrossfadeProcessor(int fftSize, float crossFadingRatio = 0f) 48 | { 49 | this._fftSize = fftSize; 50 | this._halfSize = this._fftSize / 2; 51 | this._crossFadingSize = (int)((float)this._halfSize * crossFadingRatio); 52 | this._outputSize = this._halfSize - this._crossFadingSize; 53 | this._inputPos = this._halfSize + this._crossFadingSize; 54 | this._queuepBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 55 | this._queuePtr = (Complex*)(void*)this._queuepBuffer; 56 | this._windowBuffer = UnsafeBuffer.Create(this._crossFadingSize, 4); 57 | this._windowPtr = (float*)(void*)this._windowBuffer; 58 | this._fftBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 59 | this._fftPtr = (Complex*)(void*)this._fftBuffer; 60 | this._outputBuffer = UnsafeBuffer.Create(this._outputSize, sizeof(Complex)); 61 | this._outputPtr = (Complex*)(void*)this._outputBuffer; 62 | this._crossFadingBuffer = UnsafeBuffer.Create(this._crossFadingSize, sizeof(Complex)); 63 | this._crossFadingPtr = (Complex*)(void*)this._crossFadingBuffer; 64 | double num = 1.5707963267948966 / (double)(this._crossFadingSize - 1); 65 | for (int i = 0; i < this._crossFadingSize; i++) 66 | { 67 | double a = (double)i * num; 68 | this._windowPtr[i] = (float)Math.Pow(Math.Sin(a), 2.0); 69 | } 70 | } 71 | 72 | public unsafe virtual void Process(Complex* buffer, int length) 73 | { 74 | while (length > 0) 75 | { 76 | int num = Math.Min(this._fftSize - this._inputPos, length); 77 | Utils.Memcpy(this._queuePtr + this._inputPos, buffer, num * sizeof(Complex)); 78 | Utils.Memcpy(buffer, this._outputPtr + this._outputPos, num * sizeof(Complex)); 79 | buffer += num; 80 | this._inputPos += num; 81 | this._outputPos += num; 82 | length -= num; 83 | if (this._inputPos == this._fftSize) 84 | { 85 | this.OverlapCrossfade(); 86 | this._inputPos = this._halfSize + this._crossFadingSize; 87 | this._outputPos = 0; 88 | } 89 | } 90 | } 91 | 92 | public unsafe virtual void Process(float* buffer, int length, int step = 1) 93 | { 94 | for (int i = 0; i < length; i += step) 95 | { 96 | this._queuePtr[this._inputPos++] = buffer[i]; 97 | buffer[i] = this._outputPtr[this._outputPos++].Real; 98 | if (this._inputPos == this._fftSize) 99 | { 100 | this.OverlapCrossfade(); 101 | this._inputPos = this._halfSize + this._crossFadingSize; 102 | this._outputPos = 0; 103 | } 104 | } 105 | } 106 | 107 | private unsafe void OverlapCrossfade() 108 | { 109 | Utils.Memcpy(this._fftPtr, this._queuePtr, this._fftSize * sizeof(Complex)); 110 | Fourier.ForwardTransform(this._fftPtr, this._fftSize, false); 111 | this.ProcessFft(this._fftPtr, this._fftSize); 112 | Fourier.InverseTransform(this._fftPtr, this._fftSize); 113 | int num = 0; 114 | int num2 = this._crossFadingSize - 1; 115 | int num3 = this._halfSize; 116 | while (num < this._crossFadingSize) 117 | { 118 | this._outputPtr[num] = this._fftPtr[num3] * this._windowPtr[num] + this._crossFadingPtr[num] * this._windowPtr[num2]; 119 | num++; 120 | num2--; 121 | num3++; 122 | } 123 | Utils.Memcpy(this._outputPtr + this._crossFadingSize, this._fftPtr + this._halfSize + this._crossFadingSize, (this._outputSize - this._crossFadingSize) * sizeof(Complex)); 124 | Utils.Memcpy(this._crossFadingPtr, this._fftPtr + this._halfSize + this._outputSize, this._crossFadingSize * sizeof(Complex)); 125 | Utils.Memcpy(this._queuePtr, this._queuePtr + this._outputSize, (this._fftSize - this._outputSize) * sizeof(Complex)); 126 | } 127 | 128 | protected unsafe abstract void ProcessFft(Complex* buffer, int length); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/OverlapSaveProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public abstract class OverlapSaveProcessor 6 | { 7 | private readonly int _fftSize; 8 | 9 | private readonly int _halfSize; 10 | 11 | private int _inputPos; 12 | 13 | private int _outputPos; 14 | 15 | private UnsafeBuffer _fftBuffer; 16 | 17 | private unsafe Complex* _fftPtr; 18 | 19 | private UnsafeBuffer _queuepBuffer; 20 | 21 | private unsafe Complex* _queuePtr; 22 | 23 | private UnsafeBuffer _outputBuffer; 24 | 25 | private unsafe Complex* _outputPtr; 26 | 27 | public int FFTSize 28 | { 29 | get 30 | { 31 | return this._fftSize; 32 | } 33 | } 34 | 35 | public unsafe OverlapSaveProcessor(int fftSize) 36 | { 37 | this._fftSize = fftSize; 38 | this._halfSize = this._fftSize / 2; 39 | this._inputPos = this._halfSize; 40 | this._queuepBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 41 | this._queuePtr = (Complex*)(void*)this._queuepBuffer; 42 | this._fftBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 43 | this._fftPtr = (Complex*)(void*)this._fftBuffer; 44 | this._outputBuffer = UnsafeBuffer.Create(this._halfSize, sizeof(Complex)); 45 | this._outputPtr = (Complex*)(void*)this._outputBuffer; 46 | } 47 | 48 | public unsafe virtual void Process(Complex* buffer, int length) 49 | { 50 | while (length > 0) 51 | { 52 | int num = Math.Min(this._fftSize - this._inputPos, length); 53 | Utils.Memcpy(this._queuePtr + this._inputPos, buffer, num * sizeof(Complex)); 54 | Utils.Memcpy(buffer, this._outputPtr + this._outputPos, num * sizeof(Complex)); 55 | buffer += num; 56 | this._inputPos += num; 57 | this._outputPos += num; 58 | length -= num; 59 | if (this._inputPos == this._fftSize) 60 | { 61 | this.OverlapSave(); 62 | this._inputPos = this._halfSize; 63 | this._outputPos = 0; 64 | } 65 | } 66 | } 67 | 68 | public unsafe virtual void Process(float* buffer, int length, int step = 1) 69 | { 70 | for (int i = 0; i < length; i += step) 71 | { 72 | this._queuePtr[this._inputPos++] = buffer[i]; 73 | buffer[i] = this._outputPtr[this._outputPos++].Real; 74 | if (this._inputPos == this._fftSize) 75 | { 76 | this.OverlapSave(); 77 | this._inputPos = this._halfSize; 78 | this._outputPos = 0; 79 | } 80 | } 81 | } 82 | 83 | private unsafe void OverlapSave() 84 | { 85 | Utils.Memcpy(this._fftPtr, this._queuePtr, this._fftSize * sizeof(Complex)); 86 | Fourier.ForwardTransform(this._fftPtr, this._fftSize, false); 87 | this.ProcessFft(this._fftPtr, this._fftSize); 88 | Fourier.InverseTransform(this._fftPtr, this._fftSize); 89 | Utils.Memcpy(this._outputPtr, this._fftPtr + this._halfSize, this._halfSize * sizeof(Complex)); 90 | Utils.Memcpy(this._queuePtr, this._queuePtr + this._halfSize, this._halfSize * sizeof(Complex)); 91 | } 92 | 93 | protected unsafe abstract void ProcessFft(Complex* buffer, int length); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/OverlapSlideProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public abstract class OverlapSlideProcessor 6 | { 7 | private readonly int _fftSize; 8 | 9 | private readonly int _outputSize; 10 | 11 | private readonly float _overlapRatio; 12 | 13 | private int _inputPos; 14 | 15 | private int _outputPos; 16 | 17 | private UnsafeBuffer _fftBuffer; 18 | 19 | private unsafe Complex* _fftPtr; 20 | 21 | private UnsafeBuffer _queuepBuffer; 22 | 23 | private unsafe Complex* _queuePtr; 24 | 25 | private UnsafeBuffer _outputBuffer; 26 | 27 | private unsafe Complex* _outputPtr; 28 | 29 | private UnsafeBuffer _overlapBuffer; 30 | 31 | private unsafe Complex* _overlapPtr; 32 | 33 | public int FFTSize 34 | { 35 | get 36 | { 37 | return this._fftSize; 38 | } 39 | } 40 | 41 | public float OverlapRatio 42 | { 43 | get 44 | { 45 | return this._overlapRatio; 46 | } 47 | } 48 | 49 | public OverlapSlideProcessor(int fftSize) 50 | : this(fftSize, 0.75f) 51 | { 52 | } 53 | 54 | public unsafe OverlapSlideProcessor(int fftSize, float overlapRatio) 55 | { 56 | if (overlapRatio < 0.75f) 57 | { 58 | throw new ArgumentException("Overlap ratio must be greater than or equal to 0.75", "overlapRatio"); 59 | } 60 | if (overlapRatio > 1f) 61 | { 62 | throw new ArgumentException("Overlap ratio must be less than 1.0", "overlapRatio"); 63 | } 64 | this._fftSize = fftSize; 65 | this._outputSize = (int)Math.Round((double)((float)this._fftSize * (1f - overlapRatio))); 66 | if (this._outputSize < 3) 67 | { 68 | this._outputSize = 3; 69 | } 70 | this._overlapRatio = 1f - (float)this._outputSize / (float)this._fftSize; 71 | this._inputPos = this._fftSize - this._outputSize; 72 | this._queuepBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 73 | this._queuePtr = (Complex*)(void*)this._queuepBuffer; 74 | this._fftBuffer = UnsafeBuffer.Create(this._fftSize, sizeof(Complex)); 75 | this._fftPtr = (Complex*)(void*)this._fftBuffer; 76 | this._outputBuffer = UnsafeBuffer.Create(this._outputSize, sizeof(Complex)); 77 | this._outputPtr = (Complex*)(void*)this._outputBuffer; 78 | this._overlapBuffer = UnsafeBuffer.Create(this._outputSize, sizeof(Complex)); 79 | this._overlapPtr = (Complex*)(void*)this._overlapBuffer; 80 | } 81 | 82 | public unsafe virtual void Process(Complex* buffer, int length) 83 | { 84 | while (length > 0) 85 | { 86 | int num = Math.Min(this._fftSize - this._inputPos, length); 87 | Utils.Memcpy(this._queuePtr + this._inputPos, buffer, num * sizeof(Complex)); 88 | Utils.Memcpy(buffer, this._outputPtr + this._outputPos, num * sizeof(Complex)); 89 | buffer += num; 90 | this._inputPos += num; 91 | this._outputPos += num; 92 | length -= num; 93 | if (this._inputPos == this._fftSize) 94 | { 95 | this.OverlapAdd(); 96 | this._inputPos = this._fftSize - this._outputSize; 97 | this._outputPos = 0; 98 | } 99 | } 100 | } 101 | 102 | public unsafe virtual void Process(float* buffer, int length, int step = 1) 103 | { 104 | for (int i = 0; i < length; i += step) 105 | { 106 | this._queuePtr[this._inputPos++] = buffer[i]; 107 | buffer[i] = this._outputPtr[this._outputPos++].Real; 108 | if (this._inputPos == this._fftSize) 109 | { 110 | this.OverlapAdd(); 111 | this._inputPos = this._fftSize - this._outputSize; 112 | this._outputPos = 0; 113 | } 114 | } 115 | } 116 | 117 | private unsafe void OverlapAdd() 118 | { 119 | Utils.Memcpy(this._fftPtr, this._queuePtr, this._fftSize * sizeof(Complex)); 120 | Fourier.ForwardTransform(this._fftPtr, this._fftSize, false); 121 | this.ProcessFft(this._fftPtr, this._fftSize); 122 | Fourier.InverseTransform(this._fftPtr, this._fftSize); 123 | Complex* ptr = this._fftPtr + this._fftSize / 2; 124 | float num = 1f / (float)(this._outputSize - 1); 125 | for (int i = 0; i < this._outputSize; i++) 126 | { 127 | float num2 = num * (float)i; 128 | this._outputPtr[i] = this._overlapPtr[i] * (1f - num2) + ptr[i] * num2; 129 | } 130 | Utils.Memmove(this._overlapPtr, ptr + this._outputSize, this._outputSize * sizeof(Complex)); 131 | Utils.Memmove(this._queuePtr, this._queuePtr + this._outputSize, (this._fftSize - this._outputSize) * sizeof(Complex)); 132 | } 133 | 134 | protected unsafe abstract void ProcessFft(Complex* buffer, int length); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/ProcessorType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum ProcessorType 4 | { 5 | RawIQ, 6 | DecimatedAndFilteredIQ, 7 | DemodulatorOutput, 8 | FilteredAudioOutput, 9 | FMMPX, 10 | RDSBitStream 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/RdsDetectorBank.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class RdsDetectorBank 4 | { 5 | private readonly RdsDumpGroups _dumpGroups; 6 | 7 | private readonly SyndromeDetector _detector; 8 | 9 | public string RadioText 10 | { 11 | get 12 | { 13 | return this._dumpGroups.RadioText; 14 | } 15 | } 16 | 17 | public string ProgramService 18 | { 19 | get 20 | { 21 | return this._dumpGroups.ProgramService; 22 | } 23 | } 24 | 25 | public ushort PICode 26 | { 27 | get 28 | { 29 | return this._dumpGroups.PICode; 30 | } 31 | } 32 | 33 | public bool UseFEC 34 | { 35 | get 36 | { 37 | return this._detector.UseFEC; 38 | } 39 | set 40 | { 41 | this._detector.UseFEC = value; 42 | } 43 | } 44 | 45 | public event RdsFrameAvailableDelegate FrameAvailable; 46 | 47 | public RdsDetectorBank() 48 | { 49 | this._dumpGroups = new RdsDumpGroups(); 50 | this._detector = new SyndromeDetector(this._dumpGroups); 51 | this._detector.FrameAvailable += this.FrameAvailableHandler; 52 | } 53 | 54 | public void Process(bool b) 55 | { 56 | this._detector.Clock(b); 57 | } 58 | 59 | public void Reset() 60 | { 61 | this._dumpGroups.Reset(); 62 | } 63 | 64 | private void FrameAvailableHandler(ref RdsFrame frame) 65 | { 66 | RdsFrameAvailableDelegate frameAvailable = this.FrameAvailable; 67 | if (frameAvailable != null) 68 | { 69 | frameAvailable(ref frame); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/RdsDumpGroups.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | 5 | namespace SDRSharp.Radio 6 | { 7 | public class RdsDumpGroups 8 | { 9 | private StringBuilder _radioTextSB = new StringBuilder(" "); 10 | 11 | private StringBuilder _programServiceSB = new StringBuilder(" "); 12 | 13 | private string _radioText = string.Empty; 14 | 15 | private string _programService = " "; 16 | 17 | private ushort _piCode; 18 | 19 | private bool _radioTextABFlag; 20 | 21 | public string RadioText 22 | { 23 | get 24 | { 25 | return this._radioText; 26 | } 27 | } 28 | 29 | public string ProgramService 30 | { 31 | get 32 | { 33 | return this._programService; 34 | } 35 | } 36 | 37 | public ushort PICode 38 | { 39 | get 40 | { 41 | return this._piCode; 42 | } 43 | } 44 | 45 | public void Reset() 46 | { 47 | lock (this) 48 | { 49 | this._radioTextSB = new StringBuilder(" "); 50 | this._programServiceSB = new StringBuilder(" "); 51 | this._radioText = string.Empty; 52 | this._programService = " "; 53 | this._piCode = 0; 54 | this._radioTextABFlag = false; 55 | } 56 | } 57 | 58 | public bool AnalyseFrames(ref RdsFrame frame) 59 | { 60 | bool result = false; 61 | if ((frame.GroupB & 0xF800) == 8192) 62 | { 63 | int num = (frame.GroupB & 0xF) * 4; 64 | bool flag = (frame.GroupB >> 4 & 1) == 1; 65 | StringBuilder stringBuilder = new StringBuilder(); 66 | stringBuilder.Append((char)(frame.GroupC >> 8)); 67 | stringBuilder.Append((char)(frame.GroupC & 0xFF)); 68 | stringBuilder.Append((char)(frame.GroupD >> 8)); 69 | stringBuilder.Append((char)(frame.GroupD & 0xFF)); 70 | if (stringBuilder.ToString().Any(delegate(char ch) 71 | { 72 | if (ch >= ' ') 73 | { 74 | return ch > '\u007f'; 75 | } 76 | return true; 77 | })) 78 | { 79 | return false; 80 | } 81 | lock (this) 82 | { 83 | if (flag != this._radioTextABFlag) 84 | { 85 | for (int i = 0; i < this._radioTextSB.Length; i++) 86 | { 87 | this._radioTextSB[i] = ' '; 88 | } 89 | this._radioTextABFlag = flag; 90 | } 91 | else 92 | { 93 | this._radioTextSB.Remove(num, 4); 94 | } 95 | this._radioTextSB.Insert(num, stringBuilder.ToString()); 96 | this._radioText = this._radioTextSB.ToString().Trim(); 97 | this._piCode = frame.GroupA; 98 | } 99 | result = true; 100 | } 101 | if ((frame.GroupB & 0xF800) == 0) 102 | { 103 | int num2 = (frame.GroupB & 3) * 2; 104 | StringBuilder stringBuilder2 = new StringBuilder(); 105 | stringBuilder2.Append((char)(frame.GroupD >> 8)); 106 | stringBuilder2.Append((char)(frame.GroupD & 0xFF)); 107 | if (stringBuilder2.ToString().Any(delegate(char ch) 108 | { 109 | if (ch >= ' ') 110 | { 111 | return ch > '\u007f'; 112 | } 113 | return true; 114 | })) 115 | { 116 | return false; 117 | } 118 | lock (this) 119 | { 120 | this._programServiceSB.Remove(num2, 2); 121 | this._programServiceSB.Insert(num2, stringBuilder2.ToString()); 122 | this._programService = this._programServiceSB.ToString().Substring(0, 8); 123 | this._piCode = frame.GroupA; 124 | } 125 | result = true; 126 | } 127 | return result; 128 | } 129 | 130 | private static string Dump4A(ushort blockB, ushort block3, ushort block4) 131 | { 132 | int num = block4 & 0x1F; 133 | if ((block4 & 0x20) != 0) 134 | { 135 | num *= -1; 136 | } 137 | int minute = block4 >> 6 & 0x3F; 138 | int hour = (block4 >> 12 & 0xF) | (block3 << 4 & 0x10); 139 | int num2 = block3 >> 1 | (blockB << 15 & 0x18000); 140 | int num3 = (int)(((double)num2 - 15078.2) / 365.25); 141 | int num4 = (int)(((double)num2 - 14956.1 - (double)(int)((double)num3 * 365.25)) / 30.6001); 142 | int day = num2 - 14956 - (int)((double)num3 * 365.25) - (int)((double)num4 * 30.6001); 143 | int num5 = 0; 144 | if (num4 == 14 || num4 == 15) 145 | { 146 | num5 = 1; 147 | } 148 | num3 = num3 + num5 + 1900; 149 | num4 = num4 - 1 - num5 * 12; 150 | try 151 | { 152 | DateTime d = new DateTime(num3, num4, day, hour, minute, 0); 153 | TimeSpan t = new TimeSpan(num / 2, num * 30 % 60, 0); 154 | d += t; 155 | return "4A " + d.ToLongDateString() + " " + d.ToLongTimeString(); 156 | } 157 | catch (Exception ex) 158 | { 159 | return ex.Message; 160 | } 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/RdsFrame.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public struct RdsFrame 4 | { 5 | public ushort GroupA; 6 | 7 | public ushort GroupB; 8 | 9 | public ushort GroupC; 10 | 11 | public ushort GroupD; 12 | 13 | public bool Filter; 14 | 15 | public RdsFrame(ushort groupA, ushort groupB, ushort groupC, ushort groupD) 16 | { 17 | this.GroupA = groupA; 18 | this.GroupB = groupB; 19 | this.GroupC = groupC; 20 | this.GroupD = groupD; 21 | this.Filter = false; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/RdsFrameAvailableDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public delegate void RdsFrameAvailableDelegate(ref RdsFrame frame); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/Resampler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public class Resampler 6 | { 7 | public const double DefaultProtectedPassband = 0.45; 8 | 9 | public const int DefaultTapsPerPhase = 160; 10 | 11 | private int _phase; 12 | 13 | private readonly int _interpolationFactor; 14 | 15 | private readonly int _decimationFactor; 16 | 17 | private readonly int _tapsPerPhase; 18 | 19 | private readonly UnsafeBuffer _firKernelBuffer; 20 | 21 | private unsafe readonly float* _firKernel; 22 | 23 | private readonly UnsafeBuffer _firQueueBuffer; 24 | 25 | private unsafe readonly float* _firQueue; 26 | 27 | public unsafe Resampler(double inputSampleRate, double outputSampleRate, int tapsPerPhase = 160, double protectedPassband = 0.45) 28 | { 29 | Resampler.DoubleToFraction(outputSampleRate / inputSampleRate, out this._interpolationFactor, out this._decimationFactor); 30 | this._tapsPerPhase = tapsPerPhase; 31 | int num = tapsPerPhase * this._interpolationFactor; 32 | this._firKernelBuffer = UnsafeBuffer.Create(num, 4); 33 | this._firKernel = (float*)(void*)this._firKernelBuffer; 34 | double cutoffFrequency = Math.Min(inputSampleRate, outputSampleRate) * protectedPassband; 35 | float[] array = FilterBuilder.MakeLowPassKernel(inputSampleRate * (double)this._interpolationFactor, num - 1, cutoffFrequency, WindowType.BlackmanHarris4); 36 | float[] array2 = array; 37 | fixed (float* ptr = array2) 38 | { 39 | for (int i = 0; i < array.Length; i++) 40 | { 41 | ptr[i] *= (float)this._interpolationFactor; 42 | } 43 | Utils.Memcpy(this._firKernel, ptr, (num - 1) * 4); 44 | this._firKernel[num - 1] = 0f; 45 | } 46 | this._firQueueBuffer = UnsafeBuffer.Create(num, 4); 47 | this._firQueue = (float*)(void*)this._firQueueBuffer; 48 | } 49 | 50 | private static void DoubleToFraction(double value, out int num, out int den) 51 | { 52 | int num2 = 1; 53 | int num3 = 1; 54 | double num4 = 1.0; 55 | while (Math.Abs(num4 - value) > 1E-15) 56 | { 57 | if (num4 > value) 58 | { 59 | num3++; 60 | } 61 | else 62 | { 63 | num2++; 64 | } 65 | num4 = (double)num2 / (double)num3; 66 | } 67 | num = num2; 68 | den = num3; 69 | } 70 | 71 | public unsafe int Process(float* input, float* output, int inputLength) 72 | { 73 | int num = 0; 74 | while (inputLength > 0) 75 | { 76 | int num2 = 0; 77 | while (this._phase >= this._interpolationFactor) 78 | { 79 | this._phase -= this._interpolationFactor; 80 | num2++; 81 | if (--inputLength == 0) 82 | { 83 | break; 84 | } 85 | } 86 | if (num2 >= this._tapsPerPhase) 87 | { 88 | input += num2 - this._tapsPerPhase; 89 | num2 = this._tapsPerPhase; 90 | } 91 | for (int num3 = this._tapsPerPhase - 1; num3 >= num2; num3--) 92 | { 93 | this._firQueue[num3] = this._firQueue[num3 - num2]; 94 | } 95 | for (int num4 = num2 - 1; num4 >= 0; num4--) 96 | { 97 | float* intPtr = this._firQueue + num4; 98 | float* intPtr2 = input; 99 | input = intPtr2 + 1; 100 | *intPtr = *intPtr2; 101 | } 102 | while (this._phase < this._interpolationFactor) 103 | { 104 | float* ptr = this._firKernel + this._phase; 105 | float num5 = 0f; 106 | for (int i = 0; i < this._tapsPerPhase; i++) 107 | { 108 | num5 += *ptr * this._firQueue[i]; 109 | ptr += this._interpolationFactor; 110 | } 111 | float* intPtr3 = output; 112 | output = intPtr3 + 1; 113 | *intPtr3 = num5; 114 | num++; 115 | this._phase += this._decimationFactor; 116 | } 117 | } 118 | return num; 119 | } 120 | 121 | public unsafe int ProcessInterleaved(float* input, float* output, int inputLength) 122 | { 123 | int num = 0; 124 | while (inputLength > 0) 125 | { 126 | int num2 = 0; 127 | while (this._phase >= this._interpolationFactor) 128 | { 129 | this._phase -= this._interpolationFactor; 130 | num2++; 131 | if (--inputLength == 0) 132 | { 133 | break; 134 | } 135 | } 136 | if (num2 >= this._tapsPerPhase) 137 | { 138 | input += (num2 - this._tapsPerPhase) * 2; 139 | num2 = this._tapsPerPhase; 140 | } 141 | for (int num3 = this._tapsPerPhase - 1; num3 >= num2; num3--) 142 | { 143 | this._firQueue[num3] = this._firQueue[num3 - num2]; 144 | } 145 | for (int num4 = num2 - 1; num4 >= 0; num4--) 146 | { 147 | this._firQueue[num4] = *input; 148 | input += 2; 149 | } 150 | while (this._phase < this._interpolationFactor) 151 | { 152 | float* ptr = this._firKernel + this._phase; 153 | float num5 = 0f; 154 | for (int i = 0; i < this._tapsPerPhase; i++) 155 | { 156 | num5 += *ptr * this._firQueue[i]; 157 | ptr += this._interpolationFactor; 158 | } 159 | *output = num5; 160 | output += 2; 161 | num++; 162 | this._phase += this._decimationFactor; 163 | } 164 | } 165 | return num; 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/SamplesAvailableDelegate.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public unsafe delegate void SamplesAvailableDelegate(IFrontendController sender, Complex* data, int len); 4 | } 5 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/SharpEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class SharpEvent 7 | { 8 | private bool _state; 9 | 10 | private bool _waiting; 11 | 12 | public SharpEvent(bool initialState) 13 | { 14 | this._state = initialState; 15 | } 16 | 17 | public SharpEvent() 18 | : this(false) 19 | { 20 | } 21 | 22 | ~SharpEvent() 23 | { 24 | this.Dispose(); 25 | } 26 | 27 | public void Dispose() 28 | { 29 | this.Set(); 30 | GC.SuppressFinalize(this); 31 | } 32 | 33 | public void Set() 34 | { 35 | lock (this) 36 | { 37 | this._state = true; 38 | if (this._waiting) 39 | { 40 | Monitor.Pulse(this); 41 | } 42 | } 43 | } 44 | 45 | public void WaitOne() 46 | { 47 | lock (this) 48 | { 49 | if (!this._state) 50 | { 51 | this._waiting = true; 52 | try 53 | { 54 | Monitor.Wait(this); 55 | } 56 | finally 57 | { 58 | this._waiting = false; 59 | } 60 | } 61 | this._state = false; 62 | } 63 | } 64 | 65 | public void Reset() 66 | { 67 | lock (this) 68 | { 69 | this._state = false; 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/SharpThreadPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | 5 | namespace SDRSharp.Radio 6 | { 7 | public class SharpThreadPool 8 | { 9 | private struct WorkItem 10 | { 11 | private readonly WaitCallback _callback; 12 | 13 | private readonly object _parameter; 14 | 15 | public WorkItem(WaitCallback callback, object parameter) 16 | { 17 | this._callback = callback; 18 | this._parameter = parameter; 19 | } 20 | 21 | public void Invoke() 22 | { 23 | this._callback(this._parameter); 24 | } 25 | } 26 | 27 | private readonly Queue _jobQueue = new Queue(); 28 | 29 | private readonly Thread[] _workerThreads; 30 | 31 | private int _threadsWaiting; 32 | 33 | private bool _terminated; 34 | 35 | public SharpThreadPool() 36 | : this(Environment.ProcessorCount) 37 | { 38 | } 39 | 40 | public SharpThreadPool(int threadCount) 41 | { 42 | this._workerThreads = new Thread[threadCount]; 43 | for (int i = 0; i < this._workerThreads.Length; i++) 44 | { 45 | this._workerThreads[i] = new Thread(this.DispatchLoop); 46 | this._workerThreads[i].Priority = ThreadPriority.Highest; 47 | this._workerThreads[i].Start(); 48 | } 49 | } 50 | 51 | public void QueueUserWorkItem(WaitCallback callback) 52 | { 53 | this.QueueUserWorkItem(callback, null); 54 | } 55 | 56 | public void QueueUserWorkItem(WaitCallback callback, object parameter) 57 | { 58 | WorkItem item = new WorkItem(callback, parameter); 59 | lock (this._jobQueue) 60 | { 61 | this._jobQueue.Enqueue(item); 62 | if (this._threadsWaiting > 0) 63 | { 64 | Monitor.Pulse(this._jobQueue); 65 | } 66 | } 67 | } 68 | 69 | private void DispatchLoop() 70 | { 71 | while (true) 72 | { 73 | WorkItem workItem; 74 | lock (this._jobQueue) 75 | { 76 | if (!this._terminated) 77 | { 78 | while (this._jobQueue.Count == 0) 79 | { 80 | this._threadsWaiting++; 81 | try 82 | { 83 | Monitor.Wait(this._jobQueue); 84 | } 85 | finally 86 | { 87 | this._threadsWaiting--; 88 | } 89 | if (this._terminated) 90 | { 91 | return; 92 | } 93 | } 94 | workItem = this._jobQueue.Dequeue(); 95 | goto end_IL_0009; 96 | } 97 | return; 98 | end_IL_0009:; 99 | } 100 | workItem.Invoke(); 101 | } 102 | } 103 | 104 | public void Dispose() 105 | { 106 | this._terminated = true; 107 | lock (this._jobQueue) 108 | { 109 | Monitor.PulseAll(this._jobQueue); 110 | } 111 | for (int i = 0; i < this._workerThreads.Length; i++) 112 | { 113 | this._workerThreads[i].Join(); 114 | } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/SideBandDetector.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public sealed class SideBandDetector 4 | { 5 | public unsafe void Demodulate(Complex* iq, float* audio, int length) 6 | { 7 | for (int i = 0; i < length; i++) 8 | { 9 | audio[i] = iq[i].Real; 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/SyndromeDetector.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public class SyndromeDetector 4 | { 5 | protected enum BlockSequence 6 | { 7 | GotA, 8 | GotB, 9 | GotC, 10 | GotD, 11 | WaitBitSync, 12 | GotBitSync 13 | } 14 | 15 | private const int MaxCorrectableBits = 5; 16 | 17 | private const int CheckwordBitsCount = 10; 18 | 19 | private readonly RdsDumpGroups _dumpGroups; 20 | 21 | private readonly ushort[] _blocks = new ushort[4]; 22 | 23 | private bool _useFec = Utils.GetBooleanSetting("RdsUseFec"); 24 | 25 | private BlockSequence _sequence = BlockSequence.WaitBitSync; 26 | 27 | private ushort _syndrome; 28 | 29 | private uint _raw; 30 | 31 | private RdsFrame _frame; 32 | 33 | private int _count; 34 | 35 | public bool UseFEC 36 | { 37 | get 38 | { 39 | return this._useFec; 40 | } 41 | set 42 | { 43 | this._useFec = value; 44 | } 45 | } 46 | 47 | public event RdsFrameAvailableDelegate FrameAvailable; 48 | 49 | public SyndromeDetector(RdsDumpGroups dumpGroups) 50 | { 51 | this._dumpGroups = dumpGroups; 52 | } 53 | 54 | public void Clock(bool b) 55 | { 56 | this._raw <<= 1; 57 | this._raw |= (uint)(b ? 1 : 0); 58 | this._count++; 59 | if (this._sequence == BlockSequence.WaitBitSync) 60 | { 61 | this._syndrome = SyndromeDetector.BuildSyndrome(this._raw); 62 | this._syndrome ^= 984; 63 | this._sequence = ((this._syndrome != 0) ? BlockSequence.WaitBitSync : BlockSequence.GotA); 64 | this._blocks[0] = (ushort)(this._raw >> 10 & 0xFFFF); 65 | this._count = 0; 66 | } 67 | if (this._count == 26) 68 | { 69 | this.ProcessSyndrome(); 70 | if (this._sequence == BlockSequence.GotD) 71 | { 72 | this._frame.GroupA = this._blocks[0]; 73 | this._frame.GroupB = this._blocks[1]; 74 | this._frame.GroupC = this._blocks[2]; 75 | this._frame.GroupD = this._blocks[3]; 76 | this._frame.Filter = false; 77 | RdsFrameAvailableDelegate frameAvailable = this.FrameAvailable; 78 | if (frameAvailable != null) 79 | { 80 | frameAvailable(ref this._frame); 81 | } 82 | if (!this._frame.Filter) 83 | { 84 | this._dumpGroups.AnalyseFrames(ref this._frame); 85 | } 86 | this._sequence = BlockSequence.GotBitSync; 87 | } 88 | this._count = 0; 89 | } 90 | } 91 | 92 | private void ProcessSyndrome() 93 | { 94 | this._syndrome = SyndromeDetector.BuildSyndrome(this._raw); 95 | switch (this._sequence) 96 | { 97 | case BlockSequence.GotBitSync: 98 | this._syndrome ^= 984; 99 | this._sequence = BlockSequence.GotA; 100 | break; 101 | case BlockSequence.GotA: 102 | this._syndrome ^= 980; 103 | this._sequence = BlockSequence.GotB; 104 | break; 105 | case BlockSequence.GotB: 106 | this._syndrome ^= (ushort)(((this._blocks[1] & 0x800) == 0) ? 604 : 972); 107 | this._sequence = BlockSequence.GotC; 108 | break; 109 | case BlockSequence.GotC: 110 | this._syndrome ^= 600; 111 | this._sequence = BlockSequence.GotD; 112 | break; 113 | } 114 | int sequence = (int)this._sequence; 115 | if (this._syndrome != 0) 116 | { 117 | if (this._useFec) 118 | { 119 | int num = this.ApplyFEC(); 120 | if (this._syndrome != 0 || num > 5) 121 | { 122 | this._sequence = BlockSequence.WaitBitSync; 123 | } 124 | else 125 | { 126 | this._blocks[sequence] = (ushort)(this._raw & 0xFFFF); 127 | } 128 | } 129 | else 130 | { 131 | this._sequence = BlockSequence.WaitBitSync; 132 | } 133 | } 134 | else 135 | { 136 | this._blocks[sequence] = (ushort)(this._raw >> 10 & 0xFFFF); 137 | } 138 | } 139 | 140 | private int ApplyFEC() 141 | { 142 | uint num = 33554432u; 143 | int num2 = 0; 144 | for (int i = 0; i < 16; i++) 145 | { 146 | bool flag = (this._syndrome & 0x200) == 512; 147 | bool flag2 = (this._syndrome & 0x20) == 0; 148 | this._raw ^= ((flag & flag2) ? num : 0); 149 | this._syndrome <<= 1; 150 | this._syndrome ^= (ushort)((flag && !flag2) ? 1465 : 0); 151 | num2 += ((flag & flag2) ? 1 : 0); 152 | num >>= 1; 153 | } 154 | this._syndrome &= 1023; 155 | return num2; 156 | } 157 | 158 | private static ushort BuildSyndrome(uint raw) 159 | { 160 | ushort[] array = new ushort[16] 161 | { 162 | 732, 163 | 366, 164 | 183, 165 | 647, 166 | 927, 167 | 787, 168 | 853, 169 | 886, 170 | 443, 171 | 513, 172 | 988, 173 | 494, 174 | 247, 175 | 679, 176 | 911, 177 | 795 178 | }; 179 | uint num = raw & 0x3FFFFFF; 180 | ushort num2 = (ushort)(num >> 16); 181 | for (int i = 0; i < 16; i++) 182 | { 183 | num2 = (ushort)(num2 ^ (((num & 0x8000) == 32768) ? array[i] : 0)); 184 | num <<= 1; 185 | } 186 | return num2; 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/Trig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.Radio 4 | { 5 | public static class Trig 6 | { 7 | private const int ResolutionInBits = 16; 8 | 9 | private static readonly int _mask; 10 | 11 | private static readonly float _indexScale; 12 | 13 | private static readonly UnsafeBuffer _sinBuffer; 14 | 15 | private static readonly UnsafeBuffer _cosBuffer; 16 | 17 | private unsafe static readonly float* _sinPtr; 18 | 19 | private unsafe static readonly float* _cosPtr; 20 | 21 | unsafe static Trig() 22 | { 23 | Trig._mask = 65535; 24 | int num = Trig._mask + 1; 25 | Trig._sinBuffer = UnsafeBuffer.Create(num, 4); 26 | Trig._cosBuffer = UnsafeBuffer.Create(num, 4); 27 | Trig._sinPtr = (float*)(void*)Trig._sinBuffer; 28 | Trig._cosPtr = (float*)(void*)Trig._cosBuffer; 29 | Trig._indexScale = (float)num / 6.28318548f; 30 | for (int i = 0; i < num; i++) 31 | { 32 | Trig._sinPtr[i] = (float)Math.Sin((double)(((float)i + 0.5f) / (float)num * 6.28318548f)); 33 | Trig._cosPtr[i] = (float)Math.Cos((double)(((float)i + 0.5f) / (float)num * 6.28318548f)); 34 | } 35 | for (float num2 = 0f; num2 < 6.28318548f; num2 += 1.57079637f) 36 | { 37 | Trig._sinPtr[(int)(num2 * Trig._indexScale) & Trig._mask] = (float)Math.Sin((double)num2); 38 | Trig._cosPtr[(int)(num2 * Trig._indexScale) & Trig._mask] = (float)Math.Cos((double)num2); 39 | } 40 | } 41 | 42 | public unsafe static float Sin(float angle) 43 | { 44 | return Trig._sinPtr[(int)(angle * Trig._indexScale) & Trig._mask]; 45 | } 46 | 47 | public unsafe static float Cos(float angle) 48 | { 49 | return Trig._cosPtr[(int)(angle * Trig._indexScale) & Trig._mask]; 50 | } 51 | 52 | public unsafe static Complex SinCos(float rad) 53 | { 54 | int num = (int)(rad * Trig._indexScale) & Trig._mask; 55 | Complex result = default(Complex); 56 | result.Real = Trig._cosPtr[num]; 57 | result.Imag = Trig._sinPtr[num]; 58 | return result; 59 | } 60 | 61 | public static float Atan2(float y, float x) 62 | { 63 | if ((double)x == 0.0) 64 | { 65 | if ((double)y > 0.0) 66 | { 67 | return 1.57079637f; 68 | } 69 | if ((double)y == 0.0) 70 | { 71 | return 0f; 72 | } 73 | return -1.57079637f; 74 | } 75 | float num = y / x; 76 | float num2; 77 | if ((double)Math.Abs(num) < 1.0) 78 | { 79 | num2 = num / (1f + 0.2854f * num * num); 80 | if ((double)x < 0.0) 81 | { 82 | if ((double)y < 0.0) 83 | { 84 | return num2 - 3.14159274f; 85 | } 86 | return num2 + 3.14159274f; 87 | } 88 | } 89 | else 90 | { 91 | num2 = 1.57079637f - num / (num * num + 0.2854f); 92 | if ((double)y < 0.0) 93 | { 94 | return num2 - 3.14159274f; 95 | } 96 | } 97 | return num2; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/TuningStyle.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum TuningStyle 4 | { 5 | Free, 6 | Sticky, 7 | Center 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/UnsafeBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.Radio 5 | { 6 | public sealed class UnsafeBuffer : IDisposable 7 | { 8 | private readonly GCHandle _handle; 9 | 10 | private unsafe void* _ptr; 11 | 12 | private int _length; 13 | 14 | private Array _buffer; 15 | 16 | public unsafe void* Address 17 | { 18 | get 19 | { 20 | return this._ptr; 21 | } 22 | } 23 | 24 | public int Length 25 | { 26 | get 27 | { 28 | return this._length; 29 | } 30 | } 31 | 32 | private unsafe UnsafeBuffer(Array buffer, int realLength, bool aligned) 33 | { 34 | this._buffer = buffer; 35 | this._handle = GCHandle.Alloc(this._buffer, GCHandleType.Pinned); 36 | this._ptr = (void*)this._handle.AddrOfPinnedObject(); 37 | if (aligned) 38 | { 39 | this._ptr = (void*)((long)this._ptr + 15 & -16); 40 | } 41 | this._length = realLength; 42 | } 43 | 44 | ~UnsafeBuffer() 45 | { 46 | this.Dispose(); 47 | } 48 | 49 | public unsafe void Dispose() 50 | { 51 | GCHandle handle = this._handle; 52 | if (handle.IsAllocated) 53 | { 54 | handle = this._handle; 55 | handle.Free(); 56 | } 57 | this._buffer = null; 58 | this._ptr = null; 59 | this._length = 0; 60 | GC.SuppressFinalize(this); 61 | } 62 | 63 | public void Clear() 64 | { 65 | Array.Clear(this._buffer, 0, this._buffer.Length); 66 | } 67 | 68 | public unsafe static implicit operator void*(UnsafeBuffer unsafeBuffer) 69 | { 70 | return unsafeBuffer.Address; 71 | } 72 | 73 | public static UnsafeBuffer Create(int size) 74 | { 75 | return UnsafeBuffer.Create(size, 1, true); 76 | } 77 | 78 | public static UnsafeBuffer Create(int length, int sizeOfElement) 79 | { 80 | return UnsafeBuffer.Create(length, sizeOfElement, true); 81 | } 82 | 83 | public static UnsafeBuffer Create(int length, int sizeOfElement, bool aligned) 84 | { 85 | return new UnsafeBuffer(new byte[length * sizeOfElement + (aligned ? 16 : 0)], length, aligned); 86 | } 87 | 88 | public static UnsafeBuffer Create(Array buffer) 89 | { 90 | return new UnsafeBuffer(buffer, buffer.Length, false); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /SDRSharp.Radio/SDRSharp.Radio/WindowType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.Radio 2 | { 3 | public enum WindowType 4 | { 5 | None, 6 | Hamming, 7 | Blackman, 8 | BlackmanHarris4, 9 | BlackmanHarris7, 10 | HannPoisson, 11 | Youssef 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SDRSharp.Radio/refs to PortAudio.dll & Shark.dll.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/SDRSharp.Radio/refs to PortAudio.dll & Shark.dll.txt -------------------------------------------------------------------------------- /SDRSharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp", "SDRSharp\SDRSharp.csproj", "{4331A8D2-EF97-40C6-AE40-F1D8066B466C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.Radio", "SDRSharp.Radio\SDRSharp.Radio.csproj", "{A24DD927-34EF-4301-BDF3-42C872BC944E}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.PanView", "SDRSharp.PanView\SDRSharp.PanView.csproj", "{040E3622-194B-4FA6-9CBB-1A22BD52A13D}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.FrequencyEdit", "SDRSharp.FrequencyEdit\SDRSharp.FrequencyEdit.csproj", "{A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.Common", "SDRSharp.Common\SDRSharp.Common.csproj", "{E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.CollapsiblePanel", "SDRSharp.CollapsiblePanel\SDRSharp.CollapsiblePanel.csproj", "{A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Debug|x86 = Debug|x86 22 | Release|Any CPU = Release|Any CPU 23 | Release|x86 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Debug|Any CPU.ActiveCfg = Debug|x86 27 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Debug|x86.ActiveCfg = Debug|x86 28 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Debug|x86.Build.0 = Debug|x86 29 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Release|Any CPU.ActiveCfg = Release|x86 30 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Release|x86.ActiveCfg = Release|x86 31 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Release|x86.Build.0 = Release|x86 32 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Debug|x86.ActiveCfg = Debug|Any CPU 35 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Debug|x86.Build.0 = Debug|Any CPU 36 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Release|x86.ActiveCfg = Release|Any CPU 39 | {A24DD927-34EF-4301-BDF3-42C872BC944E}.Release|x86.Build.0 = Release|Any CPU 40 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Debug|x86.ActiveCfg = Debug|Any CPU 43 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Debug|x86.Build.0 = Debug|Any CPU 44 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Release|x86.ActiveCfg = Release|Any CPU 47 | {040E3622-194B-4FA6-9CBB-1A22BD52A13D}.Release|x86.Build.0 = Release|Any CPU 48 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Debug|x86.ActiveCfg = Debug|Any CPU 51 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Debug|x86.Build.0 = Debug|Any CPU 52 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Release|x86.ActiveCfg = Release|Any CPU 55 | {A50690CF-7A7A-4B31-9A03-B3A2AF0AF0E0}.Release|x86.Build.0 = Release|Any CPU 56 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Debug|x86.ActiveCfg = Debug|Any CPU 59 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Debug|x86.Build.0 = Debug|Any CPU 60 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Release|Any CPU.ActiveCfg = Release|Any CPU 61 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Release|Any CPU.Build.0 = Release|Any CPU 62 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Release|x86.ActiveCfg = Release|Any CPU 63 | {E8BB1EAC-ED6B-4D5E-AA88-6A6CD961F37E}.Release|x86.Build.0 = Release|Any CPU 64 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Debug|x86.ActiveCfg = Debug|Any CPU 67 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Debug|x86.Build.0 = Debug|Any CPU 68 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Release|Any CPU.ActiveCfg = Release|Any CPU 69 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Release|Any CPU.Build.0 = Release|Any CPU 70 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Release|x86.ActiveCfg = Release|Any CPU 71 | {A5EFB9F9-6F99-4EBD-B5C9-3F68EFEFC823}.Release|x86.Build.0 = Release|Any CPU 72 | EndGlobalSection 73 | GlobalSection(SolutionProperties) = preSolution 74 | HideSolutionNode = FALSE 75 | EndGlobalSection 76 | GlobalSection(ExtensibilityGlobals) = postSolution 77 | SolutionGuid = {379FF569-D44F-4EE1-9196-41EA04C154C2} 78 | EndGlobalSection 79 | EndGlobal 80 | -------------------------------------------------------------------------------- /SDRSharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.Versioning; 5 | using System.Security; 6 | using System.Security.Permissions; 7 | 8 | [assembly: CompilationRelaxations(8)] 9 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] 10 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 11 | [assembly: SecurityRules(SecurityRuleSet.Level1)] 12 | [assembly: AssemblyTitle("SDR Sharp")] 13 | [assembly: AssemblyDescription("Software Defined Radio")] 14 | [assembly: AssemblyProduct("SDR#")] 15 | [assembly: AssemblyCopyright("Copyright © Youssef TOUIL 2012")] 16 | [assembly: AssemblyFileVersion("1.0.0.1632")] 17 | [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] 18 | [assembly: AssemblyVersion("1.0.0.1632")] 19 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/AirspyGainMode.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.Airspy 2 | { 3 | public enum AirspyGainMode 4 | { 5 | Linearity, 6 | Sensitivity, 7 | Custom 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/AirspyIO.cs: -------------------------------------------------------------------------------- 1 | using SDRSharp.Common; 2 | using SDRSharp.Radio; 3 | using System; 4 | using System.Windows.Forms; 5 | 6 | namespace SDRSharp.FrontEnds.Airspy 7 | { 8 | public class AirspyIO : IFrontendController, IIQStreamController, ITunableSource, ISampleRateChangeSource, IControlAwareObject, ISpectrumProvider, IConfigurationPanelProvider, IFrontendOffset, IDisposable 9 | { 10 | private const int DefaultIFOffset = -1582; 11 | 12 | private const double DefaultSampleRate = 10000000.0; 13 | 14 | private bool _disposed; 15 | 16 | private ControllerPanel _gui; 17 | 18 | private AirspyDevice _airspyDevice; 19 | 20 | private ISharpControl _control; 21 | 22 | private long _frequency = 102998418L; 23 | 24 | private SamplesAvailableDelegate _callback; 25 | 26 | private static float _aliasFreeRatio = (float)Math.Min(Math.Max(Utils.GetDoubleSetting("airspy.aliasFreeRatio", 0.8), 0.1), 1.0); 27 | 28 | public bool CanTune 29 | { 30 | get 31 | { 32 | return true; 33 | } 34 | } 35 | 36 | public long MinimumTunableFrequency 37 | { 38 | get 39 | { 40 | return 0L; 41 | } 42 | } 43 | 44 | public long MaximumTunableFrequency 45 | { 46 | get 47 | { 48 | return 2000000000L; 49 | } 50 | } 51 | 52 | public ISharpControl SharpControl 53 | { 54 | get 55 | { 56 | return this._control; 57 | } 58 | } 59 | 60 | public double Samplerate 61 | { 62 | get 63 | { 64 | if (this._airspyDevice != null) 65 | { 66 | return (double)this._airspyDevice.DecimatedSampleRate; 67 | } 68 | return 10000000.0; 69 | } 70 | } 71 | 72 | public long Frequency 73 | { 74 | get 75 | { 76 | return this._frequency; 77 | } 78 | set 79 | { 80 | this._frequency = value; 81 | this.SetDeviceFrequency(); 82 | } 83 | } 84 | 85 | public float UsableSpectrumRatio 86 | { 87 | get 88 | { 89 | return AirspyIO._aliasFreeRatio; 90 | } 91 | } 92 | 93 | public UserControl Gui 94 | { 95 | get 96 | { 97 | return this._gui; 98 | } 99 | } 100 | 101 | public bool IsDeviceHung 102 | { 103 | get 104 | { 105 | if (this._airspyDevice != null && this._airspyDevice.IsHung) 106 | { 107 | return true; 108 | } 109 | return false; 110 | } 111 | } 112 | 113 | public int Offset 114 | { 115 | get 116 | { 117 | return -1582; 118 | } 119 | } 120 | 121 | public event EventHandler SampleRateChanged; 122 | 123 | public AirspyIO() 124 | { 125 | this._gui = new ControllerPanel(this); 126 | } 127 | 128 | ~AirspyIO() 129 | { 130 | this.Dispose(); 131 | } 132 | 133 | public void Dispose() 134 | { 135 | if (!this._disposed) 136 | { 137 | this._disposed = true; 138 | this.Close(); 139 | GC.SuppressFinalize(this); 140 | } 141 | } 142 | 143 | public void Open() 144 | { 145 | this._airspyDevice = new AirspyDevice(false); 146 | this._airspyDevice.Frequency = (uint)this._frequency; 147 | this._gui.Device = this._airspyDevice; 148 | this._airspyDevice.ComplexSamplesAvailable += this.AirSpyDevice_SamplesAvailable; 149 | this._airspyDevice.SampleRateChanged += this.AirSpyDevice_SampleRateChanged; 150 | this._gui.RefreshTimerEnabled = true; 151 | } 152 | 153 | public void Close() 154 | { 155 | if (this._airspyDevice != null) 156 | { 157 | this._gui.RefreshTimerEnabled = false; 158 | this._gui.SaveSettings(); 159 | this._gui.Device = null; 160 | this._airspyDevice.ComplexSamplesAvailable -= this.AirSpyDevice_SamplesAvailable; 161 | this._airspyDevice.SampleRateChanged -= this.AirSpyDevice_SampleRateChanged; 162 | this._airspyDevice.Dispose(); 163 | this._airspyDevice = null; 164 | } 165 | } 166 | 167 | public unsafe void Start(SamplesAvailableDelegate callback) 168 | { 169 | this._callback = callback; 170 | try 171 | { 172 | if (this._airspyDevice == null) 173 | { 174 | this.Open(); 175 | } 176 | this._airspyDevice.Start(); 177 | this.SetDeviceFrequency(); 178 | } 179 | catch 180 | { 181 | this.Close(); 182 | throw; 183 | } 184 | } 185 | 186 | public void Stop() 187 | { 188 | if (this._airspyDevice != null) 189 | { 190 | this._airspyDevice.Stop(); 191 | } 192 | } 193 | 194 | public void SetControl(object control) 195 | { 196 | this._control = (ISharpControl)control; 197 | } 198 | 199 | private void SetDeviceFrequency() 200 | { 201 | if (this._airspyDevice != null) 202 | { 203 | this._airspyDevice.Frequency = (uint)this._frequency; 204 | } 205 | } 206 | 207 | private unsafe void AirSpyDevice_SamplesAvailable(object sender, ComplexSamplesEventArgs e) 208 | { 209 | this._callback(this, e.Buffer, e.Length); 210 | } 211 | 212 | private void AirSpyDevice_SampleRateChanged(object sender, EventArgs e) 213 | { 214 | EventHandler evt = this.SampleRateChanged; 215 | this._gui.BeginInvoke((Action)delegate 216 | { 217 | if (evt != null) 218 | { 219 | evt(this, EventArgs.Empty); 220 | } 221 | }); 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/ConversionFilters.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.Airspy 2 | { 3 | public static class ConversionFilters 4 | { 5 | private static readonly float[] Kernel_Dec16_110dB = new float[7] 6 | { 7 | -0.03183508f, 8 | 0f, 9 | 0.2818315f, 10 | 0.5000073f, 11 | 0.2818315f, 12 | 0f, 13 | -0.03183508f 14 | }; 15 | 16 | private static readonly float[] Kernel_Dec8_100dB = new float[11] 17 | { 18 | 0.006633401f, 19 | 0f, 20 | -0.0510355234f, 21 | 0f, 22 | 0.2944033f, 23 | 0.4999975f, 24 | 0.2944033f, 25 | 0f, 26 | -0.0510355234f, 27 | 0f, 28 | 0.006633401f 29 | }; 30 | 31 | private static readonly float[] Kernel_Dec4_90dB = new float[15] 32 | { 33 | -0.0024741888f, 34 | 0f, 35 | 0.0169657469f, 36 | 0f, 37 | -0.0676806f, 38 | 0f, 39 | 0.303180575f, 40 | 0.500017047f, 41 | 0.303180575f, 42 | 0f, 43 | -0.0676806f, 44 | 0f, 45 | 0.0169657469f, 46 | 0f, 47 | -0.0024741888f 48 | }; 49 | 50 | private static readonly float[] Kernel_Dec2_80dB = new float[47] 51 | { 52 | -0.00019800663f, 53 | 0f, 54 | 0.000576853752f, 55 | 0f, 56 | -0.001352191f, 57 | 0f, 58 | 0.00272917747f, 59 | 0f, 60 | -0.00498819351f, 61 | 0f, 62 | 0.008499503f, 63 | 0f, 64 | -0.0137885809f, 65 | 0f, 66 | 0.0217131376f, 67 | 0f, 68 | -0.0339800119f, 69 | 0f, 70 | 0.0549448729f, 71 | 0f, 72 | -0.100657463f, 73 | 0f, 74 | 0.3164574f, 75 | 0.5f, 76 | 0.3164574f, 77 | 0f, 78 | -0.100657463f, 79 | 0f, 80 | 0.0549448729f, 81 | 0f, 82 | -0.0339800119f, 83 | 0f, 84 | 0.0217131376f, 85 | 0f, 86 | -0.0137885809f, 87 | 0f, 88 | 0.008499503f, 89 | 0f, 90 | -0.00498819351f, 91 | 0f, 92 | 0.00272917747f, 93 | 0f, 94 | -0.001352191f, 95 | 0f, 96 | 0.000576853752f, 97 | 0f, 98 | -0.00019800663f 99 | }; 100 | 101 | public static readonly float[][] FirKernels100dB = new float[4][] 102 | { 103 | ConversionFilters.Kernel_Dec2_80dB, 104 | ConversionFilters.Kernel_Dec4_90dB, 105 | ConversionFilters.Kernel_Dec8_100dB, 106 | ConversionFilters.Kernel_Dec16_110dB 107 | }; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/airspy_error.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.Airspy 2 | { 3 | public enum airspy_error 4 | { 5 | AIRSPY_SUCCESS, 6 | AIRSPY_TRUE, 7 | AIRSPY_ERROR_INVALID_PARAM = -2, 8 | AIRSPY_ERROR_NOT_FOUND = -5, 9 | AIRSPY_ERROR_BUSY = -6, 10 | AIRSPY_ERROR_NO_MEM = -11, 11 | AIRSPY_ERROR_LIBUSB = -1000, 12 | AIRSPY_ERROR_THREAD = -1001, 13 | AIRSPY_ERROR_STREAMING_THREAD_ERR = -1002, 14 | AIRSPY_ERROR_STREAMING_STOPPED = -1003, 15 | AIRSPY_ERROR_OTHER = -9999 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/airspy_gpio_pin_t.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.Airspy 2 | { 3 | public enum airspy_gpio_pin_t 4 | { 5 | GPIO_PIN0, 6 | GPIO_PIN1, 7 | GPIO_PIN2, 8 | GPIO_PIN3, 9 | GPIO_PIN4, 10 | GPIO_PIN5, 11 | GPIO_PIN6, 12 | GPIO_PIN7, 13 | GPIO_PIN8, 14 | GPIO_PIN9, 15 | GPIO_PIN10, 16 | GPIO_PIN11, 17 | GPIO_PIN12, 18 | GPIO_PIN13, 19 | GPIO_PIN14, 20 | GPIO_PIN15, 21 | GPIO_PIN16, 22 | GPIO_PIN17, 23 | GPIO_PIN18, 24 | GPIO_PIN19, 25 | GPIO_PIN20, 26 | GPIO_PIN21, 27 | GPIO_PIN22, 28 | GPIO_PIN23, 29 | GPIO_PIN24, 30 | GPIO_PIN25, 31 | GPIO_PIN26, 32 | GPIO_PIN27, 33 | GPIO_PIN28, 34 | GPIO_PIN29, 35 | GPIO_PIN30, 36 | GPIO_PIN31 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/airspy_gpio_port_t.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.Airspy 2 | { 3 | public enum airspy_gpio_port_t 4 | { 5 | GPIO_PORT0, 6 | GPIO_PORT1, 7 | GPIO_PORT2, 8 | GPIO_PORT3, 9 | GPIO_PORT4, 10 | GPIO_PORT5, 11 | GPIO_PORT6, 12 | GPIO_PORT7 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/airspy_sample_block_cb_fn.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace SDRSharp.FrontEnds.Airspy 4 | { 5 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 6 | public unsafe delegate int airspy_sample_block_cb_fn(airspy_transfer* ptr); 7 | } 8 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/airspy_sample_type.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.Airspy 2 | { 3 | public enum airspy_sample_type 4 | { 5 | AIRSPY_SAMPLE_FLOAT32_IQ, 6 | AIRSPY_SAMPLE_FLOAT32_REAL, 7 | AIRSPY_SAMPLE_INT16_IQ, 8 | AIRSPY_SAMPLE_INT16_REAL 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.Airspy/airspy_transfer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.FrontEnds.Airspy 4 | { 5 | public struct airspy_transfer 6 | { 7 | public IntPtr device; 8 | 9 | public IntPtr ctx; 10 | 11 | public unsafe void* samples; 12 | 13 | public int sample_count; 14 | 15 | public ulong dropped_samples; 16 | 17 | public airspy_sample_type sample_type; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.AirspyHF/AirspyHFIO.cs: -------------------------------------------------------------------------------- 1 | using SDRSharp.Common; 2 | using SDRSharp.Radio; 3 | using System; 4 | using System.Windows.Forms; 5 | 6 | namespace SDRSharp.FrontEnds.AirspyHF 7 | { 8 | public class AirspyHFIO : IFrontendController, IIQStreamController, ITunableSource, IFrontendOffset, IControlAwareObject, ISpectrumProvider, IConfigurationPanelProvider, ISampleRateChangeSource, IDisposable 9 | { 10 | private const float AliasFreeRatio = 1f; 11 | 12 | private bool _disposed; 13 | 14 | private ControllerPanel _gui; 15 | 16 | private AirspyHFDevice _device; 17 | 18 | private ISharpControl _control; 19 | 20 | private long _frequency = 7200000L; 21 | 22 | private int _decimationStages; 23 | 24 | private SamplesAvailableDelegate _callback; 25 | 26 | public bool CanTune 27 | { 28 | get 29 | { 30 | return true; 31 | } 32 | } 33 | 34 | public long MinimumTunableFrequency 35 | { 36 | get 37 | { 38 | return 0L; 39 | } 40 | } 41 | 42 | public long MaximumTunableFrequency 43 | { 44 | get 45 | { 46 | return 1700000000L; 47 | } 48 | } 49 | 50 | public ISharpControl SharpControl 51 | { 52 | get 53 | { 54 | return this._control; 55 | } 56 | } 57 | 58 | public double Samplerate 59 | { 60 | get 61 | { 62 | return 768000.0 / Math.Pow(2.0, (double)this._decimationStages); 63 | } 64 | } 65 | 66 | public long Frequency 67 | { 68 | get 69 | { 70 | return this._frequency; 71 | } 72 | set 73 | { 74 | this._frequency = value; 75 | this.SetDeviceFrequency(); 76 | } 77 | } 78 | 79 | public float UsableSpectrumRatio 80 | { 81 | get 82 | { 83 | return 1f; 84 | } 85 | } 86 | 87 | public UserControl Gui 88 | { 89 | get 90 | { 91 | return this._gui; 92 | } 93 | } 94 | 95 | public bool IsDeviceHung 96 | { 97 | get 98 | { 99 | if (this._device != null) 100 | { 101 | return this._device.IsHung; 102 | } 103 | return false; 104 | } 105 | } 106 | 107 | public int Offset 108 | { 109 | get 110 | { 111 | return 0; 112 | } 113 | } 114 | 115 | public int DecimationStages 116 | { 117 | get 118 | { 119 | return this._decimationStages; 120 | } 121 | set 122 | { 123 | this._decimationStages = value; 124 | if (this._device != null) 125 | { 126 | this._device.DecimationStages = value; 127 | } 128 | if (this._gui != null) 129 | { 130 | this.NotifySampleRateChanged(); 131 | } 132 | } 133 | } 134 | 135 | public event EventHandler SampleRateChanged; 136 | 137 | public AirspyHFIO() 138 | { 139 | this._gui = new ControllerPanel(this); 140 | } 141 | 142 | ~AirspyHFIO() 143 | { 144 | this.Dispose(); 145 | } 146 | 147 | public void Dispose() 148 | { 149 | if (!this._disposed) 150 | { 151 | this._disposed = true; 152 | this.Close(); 153 | GC.SuppressFinalize(this); 154 | } 155 | } 156 | 157 | public void Open() 158 | { 159 | this._device = new AirspyHFDevice(); 160 | this._device.DecimationStages = this._decimationStages; 161 | this._device.Frequency = (uint)this._frequency; 162 | this._gui.Device = this._device; 163 | this._device.SamplesAvailable += this.Device_SamplesAvailable; 164 | } 165 | 166 | public void Close() 167 | { 168 | if (this._device != null) 169 | { 170 | this._gui.Device = null; 171 | this._device.SamplesAvailable -= this.Device_SamplesAvailable; 172 | this._device.Dispose(); 173 | this._device = null; 174 | } 175 | } 176 | 177 | public unsafe void Start(SamplesAvailableDelegate callback) 178 | { 179 | this._callback = callback; 180 | try 181 | { 182 | if (this._device == null) 183 | { 184 | this.Open(); 185 | } 186 | this._device.Start(); 187 | this.SetDeviceFrequency(); 188 | } 189 | catch 190 | { 191 | this.Close(); 192 | throw; 193 | } 194 | } 195 | 196 | public void Stop() 197 | { 198 | if (this._device != null) 199 | { 200 | this._device.Stop(); 201 | } 202 | } 203 | 204 | public void ShowSettingGUI(IWin32Window parent) 205 | { 206 | } 207 | 208 | public void HideSettingGUI() 209 | { 210 | } 211 | 212 | public void SetControl(object control) 213 | { 214 | this._control = (ISharpControl)control; 215 | } 216 | 217 | private void SetDeviceFrequency() 218 | { 219 | if (this._device != null) 220 | { 221 | this._device.Frequency = (uint)this._frequency; 222 | } 223 | } 224 | 225 | private unsafe void Device_SamplesAvailable(object sender, ComplexSamplesEventArgs e) 226 | { 227 | this._callback(this, e.Buffer, e.Length); 228 | } 229 | 230 | public void NotifySampleRateChanged() 231 | { 232 | this._gui.BeginInvoke((Action)delegate 233 | { 234 | EventHandler sampleRateChanged = this.SampleRateChanged; 235 | if (sampleRateChanged != null) 236 | { 237 | sampleRateChanged(this, EventArgs.Empty); 238 | } 239 | }); 240 | } 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.AirspyHF/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SDRSharp.FrontEnds.AirspyHF 5 | { 6 | public static class NativeMethods 7 | { 8 | private const string LibAirspyHF = "airspyhf"; 9 | 10 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 11 | public static extern airspyhf_error airspyhf_open(out IntPtr dev); 12 | 13 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 14 | public static extern airspyhf_error airspyhf_close(IntPtr dev); 15 | 16 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 17 | public static extern airspyhf_error airspyhf_start(IntPtr dev, airspyhf_sample_cb cb, IntPtr ctx); 18 | 19 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 20 | public static extern airspyhf_error airspyhf_stop(IntPtr dev); 21 | 22 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 23 | [return: MarshalAs(UnmanagedType.Bool)] 24 | public static extern bool airspyhf_is_streaming(IntPtr dev); 25 | 26 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 27 | public static extern airspyhf_error airspyhf_set_freq(IntPtr dev, uint freq_hz); 28 | 29 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 30 | public static extern airspyhf_error airspyhf_i2c_write(IntPtr device, byte register_number, byte value); 31 | 32 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 33 | public static extern airspyhf_error airspyhf_i2c_read(IntPtr device, byte register_number, out byte value); 34 | 35 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 36 | public static extern airspyhf_error airspyhf_tuner_write(IntPtr device, uint address, uint value); 37 | 38 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 39 | public unsafe static extern airspyhf_error airspyhf_tuner_read(IntPtr device, uint address, byte* data); 40 | 41 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 42 | public unsafe static extern airspyhf_error airspyhf_get_samplerates(IntPtr device, uint* buffer, uint len); 43 | 44 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 45 | public static extern airspyhf_error airspyhf_set_samplerate(IntPtr device, uint samplerate); 46 | 47 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 48 | public static extern airspyhf_error airspyhf_get_calibration(IntPtr device, out int ppb); 49 | 50 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 51 | public static extern airspyhf_error airspyhf_set_calibration(IntPtr device, int ppb); 52 | 53 | [DllImport("airspyhf", CallingConvention = CallingConvention.Cdecl)] 54 | public static extern airspyhf_error airspyhf_flash_calibration(IntPtr dev); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.AirspyHF/airspyhf_error.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.AirspyHF 2 | { 3 | public enum airspyhf_error 4 | { 5 | SUCCESS, 6 | ERROR = -1 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.AirspyHF/airspyhf_sample_cb.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace SDRSharp.FrontEnds.AirspyHF 4 | { 5 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 6 | public unsafe delegate int airspyhf_sample_cb(airspyhf_transfer* ptr); 7 | } 8 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.AirspyHF/airspyhf_transfer.cs: -------------------------------------------------------------------------------- 1 | using SDRSharp.Radio; 2 | using System; 3 | 4 | namespace SDRSharp.FrontEnds.AirspyHF 5 | { 6 | public struct airspyhf_transfer 7 | { 8 | public IntPtr device; 9 | 10 | public IntPtr ctx; 11 | 12 | public unsafe Complex* samples; 13 | 14 | public int sample_count; 15 | 16 | public ulong dropped_samples; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/ClientHandshake.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public struct ClientHandshake 4 | { 5 | public uint ProtocolVersion; 6 | 7 | public uint ClientNameLength; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/ClientSync.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public struct ClientSync 4 | { 5 | public uint CanControl; 6 | 7 | public uint Gain; 8 | 9 | public uint DeviceCenterFrequency; 10 | 11 | public uint IQCenterFrequency; 12 | 13 | public uint FFTCenterFrequency; 14 | 15 | public uint MinimumIQCenterFrequency; 16 | 17 | public uint MaximumIQCenterFrequency; 18 | 19 | public uint MinimumFFTCenterFrequency; 20 | 21 | public uint MaximumFFTCenterFrequency; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/CommandHeader.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public struct CommandHeader 4 | { 5 | public CommandType CommandType; 6 | 7 | public uint BodySize; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/CommandType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public enum CommandType : uint 4 | { 5 | CMD_HELLO, 6 | CMD_GET_SETTING, 7 | CMD_SET_SETTING, 8 | CMD_PING 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public static class Constants 4 | { 5 | public const uint SPYSERVER_PROTOCOL_VERSION = 33556024u; 6 | 7 | public const uint SPYSERVER_MAX_COMMAND_BODY_SIZE = 256u; 8 | 9 | public const uint SPYSERVER_MAX_MESSAGE_BODY_SIZE = 1048576u; 10 | 11 | public const uint SPYSERVER_MAX_DISPLAY_PIXELS = 32768u; 12 | 13 | public const uint SPYSERVER_MIN_DISPLAY_PIXELS = 100u; 14 | 15 | public const uint SPYSERVER_MAX_FFT_DB_RANGE = 150u; 16 | 17 | public const uint SPYSERVER_MIN_FFT_DB_RANGE = 10u; 18 | 19 | public const uint SPYSERVER_MAX_FFT_DB_OFFSET = 100u; 20 | 21 | public const uint SPYSERVER_DIGITAL_GAIN_AUTO = uint.MaxValue; 22 | 23 | public const int SPYSERVER_MESSAGE_TYPE_BITS = 16; 24 | 25 | public const uint SPYSERVER_MESSAGE_TYPE_MASK = 65535u; 26 | 27 | public static string GetDeviceName(DeviceType deviceID) 28 | { 29 | switch (deviceID) 30 | { 31 | case DeviceType.DEVICE_AIRSPY_ONE: 32 | return "Airspy One"; 33 | case DeviceType.DEVICE_AIRSPY_HF: 34 | return "Airspy HF+"; 35 | case DeviceType.DEVICE_RTLSDR: 36 | return "RTL-SDR"; 37 | default: 38 | return "Unknown"; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/DeviceInfo.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public struct DeviceInfo 4 | { 5 | public DeviceType DeviceType; 6 | 7 | public uint DeviceSerial; 8 | 9 | public uint MaximumSampleRate; 10 | 11 | public uint MaximumBandwidth; 12 | 13 | public uint DecimationStageCount; 14 | 15 | public uint GainStageCount; 16 | 17 | public uint MaximumGainIndex; 18 | 19 | public uint MinimumFrequency; 20 | 21 | public uint MaximumFrequency; 22 | 23 | public uint Resolution; 24 | 25 | public uint MinimumIQDecimation; 26 | 27 | public uint ForcedIQFormat; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/DeviceType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public enum DeviceType : uint 4 | { 5 | DEVICE_INVALID, 6 | DEVICE_AIRSPY_ONE, 7 | DEVICE_AIRSPY_HF, 8 | DEVICE_RTLSDR 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/MessageHeader.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public struct MessageHeader 4 | { 5 | public uint ProtocolID; 6 | 7 | public MessageType MessageType; 8 | 9 | public StreamType StreamType; 10 | 11 | public uint SequenceNumber; 12 | 13 | public uint BodySize; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/MessageType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SDRSharp.FrontEnds.SpyServer 4 | { 5 | [Flags] 6 | public enum MessageType : uint 7 | { 8 | MSG_TYPE_DEVICE_INFO = 0u, 9 | MSG_TYPE_CLIENT_SYNC = 1u, 10 | MSG_TYPE_PONG = 2u, 11 | MSG_TYPE_READ_SETTING = 3u, 12 | MSG_TYPE_UINT8_IQ = 0x64, 13 | MSG_TYPE_INT16_IQ = 0x65, 14 | MSG_TYPE_INT24_IQ = 0x66, 15 | MSG_TYPE_FLOAT_IQ = 0x67, 16 | MSG_TYPE_UINT8_AF = 0xC8, 17 | MSG_TYPE_INT16_AF = 0xC9, 18 | MSG_TYPE_INT24_AF = 0xCA, 19 | MSG_TYPE_FLOAT_AF = 0xCB, 20 | MSG_TYPE_DINT4_FFT = 0x12C, 21 | MSG_TYPE_UINT8_FFT = 0x12D 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/SettingTarget.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public struct SettingTarget 4 | { 5 | public StreamType StreamType; 6 | 7 | public SettingType SettingType; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/SettingType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public enum SettingType : uint 4 | { 5 | SETTING_STREAMING_MODE, 6 | SETTING_STREAMING_ENABLED, 7 | SETTING_GAIN, 8 | SETTING_IQ_FORMAT = 100u, 9 | SETTING_IQ_FREQUENCY, 10 | SETTING_IQ_DECIMATION, 11 | SETTING_IQ_DIGITAL_GAIN, 12 | SETTING_FFT_FORMAT = 200u, 13 | SETTING_FFT_FREQUENCY, 14 | SETTING_FFT_DECIMATION, 15 | SETTING_FFT_DB_OFFSET, 16 | SETTING_FFT_DB_RANGE, 17 | SETTING_FFT_DISPLAY_PIXELS 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/StreamFormat.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public enum StreamFormat : uint 4 | { 5 | STREAM_FORMAT_INVALID, 6 | STREAM_FORMAT_UINT8, 7 | STREAM_FORMAT_INT16, 8 | STREAM_FORMAT_INT24, 9 | STREAM_FORMAT_FLOAT, 10 | STREAM_FORMAT_DINT4 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/StreamType.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public enum StreamType : uint 4 | { 5 | STREAM_TYPE_STATUS, 6 | STREAM_TYPE_IQ, 7 | STREAM_TYPE_AF, 8 | STREAM_TYPE_FFT = 4u 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.FrontEnds.SpyServer/StreamingMode.cs: -------------------------------------------------------------------------------- 1 | namespace SDRSharp.FrontEnds.SpyServer 2 | { 3 | public enum StreamingMode : uint 4 | { 5 | STREAM_MODE_IQ_ONLY = 1u, 6 | STREAM_MODE_AF_ONLY, 7 | STREAM_MODE_FFT_ONLY = 4u, 8 | STREAM_MODE_FFT_IQ, 9 | STREAM_MODE_FFT_AF 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp", "SDRSharp.csproj", "{4331A8D2-EF97-40C6-AE40-F1D8066B466C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Debug|x86.ActiveCfg = Debug|x86 15 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Debug|x86.Build.0 = Debug|x86 16 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Release|x86.ActiveCfg = Release|x86 17 | {4331A8D2-EF97-40C6-AE40-F1D8066B466C}.Release|x86.Build.0 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {379FF569-D44F-4EE1-9196-41EA04C154C2} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp/Program.cs: -------------------------------------------------------------------------------- 1 | using SDRSharp.Radio; 2 | using System; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | 8 | namespace SDRSharp 9 | { 10 | public static class Program 11 | { 12 | [STAThread] 13 | private static void Main() 14 | { 15 | AppDomain.CurrentDomain.UnhandledException += Program.CurrentDomain_UnhandledException; 16 | if (Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.Win32NT) 17 | { 18 | Process currentProcess = Process.GetCurrentProcess(); 19 | currentProcess.PriorityBoostEnabled = true; 20 | currentProcess.PriorityClass = (ProcessPriorityClass)Utils.GetIntSetting("processPriority", 256); 21 | Utils.TimeBeginPeriod(1u); 22 | } 23 | DSPThreadPool.Initialize(); 24 | Control.CheckForIllegalCrossThreadCalls = false; 25 | Application.EnableVisualStyles(); 26 | Application.Run(new MainForm()); 27 | if (Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.Win32NT) 28 | { 29 | Utils.TimeEndPeriod(1u); 30 | } 31 | DSPThreadPool.Terminate(); 32 | Application.Exit(); 33 | } 34 | 35 | private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) 36 | { 37 | Exception ex = (Exception)e.ExceptionObject; 38 | StackTrace stackTrace = new StackTrace(ex); 39 | StringBuilder stringBuilder = new StringBuilder(); 40 | StackFrame[] frames = stackTrace.GetFrames(); 41 | foreach (StackFrame stackFrame in frames) 42 | { 43 | stringBuilder.AppendLine("at " + stackFrame.GetMethod().Module.Name + "." + stackFrame.GetMethod().ReflectedType.Name + "." + stackFrame.GetMethod().Name + " (IL offset: 0x" + stackFrame.GetILOffset().ToString("x") + ")"); 44 | } 45 | File.WriteAllText("crash.txt", ex.Message + Environment.NewLine + stringBuilder); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SDRSharp/SDRSharp/SDRSharp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/SDRSharp/SDRSharp/SDRSharp.ico -------------------------------------------------------------------------------- /SDRSharp/SDRSharp/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /SDRSharp/refs Panel Common FreqEdit PanView Radio & airspy.dll airspyhf.dll .txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/SDRSharp/refs Panel Common FreqEdit PanView Radio & airspy.dll airspyhf.dll .txt -------------------------------------------------------------------------------- /SDRSharp/ver 1.0.0.1632.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SDRSharpR/SDRSharp/e14d273f1e6d1e14edbd966375f19cb66bd1810c/SDRSharp/ver 1.0.0.1632.txt --------------------------------------------------------------------------------