SDRSharp + CTCSS decoder plug-in
Visual Studio + dotPeek .NET decompiler
https://i.ibb.co/vJpv7Vd/sdr-ccir-dec.jpg
AuxWindows.cs
this.lastToneLabel.TabIndex = 1;
this.lastToneLabel.Text = "0000.0 Hz"; //modx 000.0 -> 0000.0
this.lastToneLabel.TextAlign = ContentAlignment.TopRight;
this.toneLabel.TabIndex = 3;
this.toneLabel.Text = "0000,0 Hz"; //modx 000,0 -> 0000,0
this.toneLabel.TextAlign = ContentAlignment.TopRight;
this.ShowInTaskbar = false;
this.Text = "Tone"; //modx CTCSS tone->Tone
this.TopMost = true;
CTCSSDecoderPlugin.cs
public class CTCSSDecoderPlugin : ISharpPlugin
{
private const string _displayName = "Tone decoder"; //modx CTCSS decoder->Tone decoder
public string DisplayName
{
get
{
return "Tone decoder"; //modx CTCSS decoder->Tone decoder
}
}
Decoder.cs
public class Decoder
{
private const int SubToneFilterOrder = 1000;
private const int SubToneLow = 985; //modx 60->985
private const int SubToneHigh = 2406; //modx 260->2406
public Decoder(double sampleRate, float squelchTone)
{
if (this._squelchToneFilter != null)
this._squelchToneFilter.Dispose();
this._squelchToneFilter = new FirFilter(FilterBuilder.MakeBandPassKernel(sampleRate, 1000, (double) squelchTone - 2.0, (double) squelchTone + 2.0, WindowType.BlackmanHarris4), 1);
if (this._subToneFilter != null)
this._subToneFilter.Dispose();
this._subToneFilter = new FirFilter(FilterBuilder.MakeBandPassKernel(sampleRate, 1000, 985.0, 2406.0, WindowType.BlackmanHarris4), 1); //modx 1000,60.0,260.0 -> 1000,985.0,2406.0
this._squelchTone = squelchTone;
this._samplerate = (float) sampleRate;
}
CTCSSDecoderPanel.cs
public class CTCSSDecoderPanel : UserControl
{
private readonly float[] _ctcssToneTable = new float[15] //modx 55->15
{
//67f,
//69.3f,
//71.9f,
//74.4f,
//77f,
//79.7f,
//82.5f,
//85.4f,
//88.5f,
//91.5f,
//94.8f,
//97.4f,
//100f,
//103.5f,
//107.2f,
//110.9f,
//114.8f,
//118.8f,
//123f,
//127.3f,
//131.8f,
//136.5f,
//141.3f,
//146.2f,
//150f,
//151.4f,
//156.7f,
//159.8f,
//162.2f,
//165.5f,
//167.9f,
//171.3f,
//173.8f,
//177.3f,
//179.9f,
//183.5f,
//186.2f,
//189.9f,
//192.8f,
//196.6f,
//199.5f,
//203.5f,
//206.5f,
//210.7f,
//213.8f,
//218.1f,
//221.3f,
//225.7f,
//229.1f,
//233.6f,
//237.1f,
//241.8f,
//245.5f,
//250.3f,
//254.1f,
930f, //modx add these
991f,
1124f,
1197f,
1275f,
1358f,
1446f,
1540f,
1640f,
1747f,
1860f,
1981f,
2110f,
2247f,
2400f // end modx
};
private AudioProcessor _audioProcessor;
public void Reset()
{
this._toneInText = "----.- Hz"; //modx ---.- -> ----.-
this.lastToneLabel.Text = this._toneInText;
this._auxWindow.LastTone = this._toneInText;
}
private void CustomPaint(object sender, CustomPaintEventArgs e)
{
SpectrumAnalyzer spectrumAnalyzer = (SpectrumAnalyzer) sender;
using (SolidBrush solidBrush1 = new SolidBrush(Color.FromArgb(100, Color.Black)))
{
using (SolidBrush solidBrush2 = new SolidBrush(Color.FromArgb(200, Color.White)))
{
using (SolidBrush solidBrush3 = new SolidBrush(Color.FromArgb(200, Color.LightGreen)))
{
using (StringFormat format = new StringFormat(StringFormat.GenericTypographic))
{
using (Font font = new Font("Arial", 10f))
{
format.Alignment = StringAlignment.Near;
Rectangle rect = new Rectangle();
Point point = new Point();
string str1 = string.Format("Tone {0,6:F1} Hz", (object) this._audioProcessor.DecodeTone); //modx CTCSS->Tone
if (this.squelchEnableCheckBox.Checked)
this.squelchLevelNumericUpDown.Location = new Point(96, 18);
this.squelchLevelNumericUpDown.Maximum = new Decimal(new int[4]
{
2410, //modx 260->2410
0,
0,
0
});
this.subToneLabel.TabIndex = 11;
this.subToneLabel.Text = "0000,0 Hz"; //modx 000,0->0000,0
this.subToneLabel.TextAlign = ContentAlignment.TopRight;
this.lastToneLabel.TabIndex = 12;
this.lastToneLabel.Text = "0000,0 Hz"; //modx 000,0->0000,0
this.lastToneLabel.TextAlign = ContentAlignment.TopRight;
//modx
private float ConvertTone(float tone)
{
if ((double)tone < 988.0 || (double)tone > 2402.0)
return tone;
float num1 = 976f;
for (int index = 0; index < _ctcssToneTable.Length; ++index)
{
float num2 = Math.Abs(tone - _ctcssToneTable[index]);
if ((double)num2 > (double)num1)
{
return _ctcssToneTable[index - 1];
}
num1 = num2;
}
return _ctcssToneTable[_ctcssToneTable.Length - 1];
}
//end modx
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.