diff --git a/plugins/channelrx/demodnfm/readme.md b/plugins/channelrx/demodnfm/readme.md
index 78406836c..92f0b8021 100644
--- a/plugins/channelrx/demodnfm/readme.md
+++ b/plugins/channelrx/demodnfm/readme.md
@@ -70,7 +70,7 @@ Use the checkbox to toggle CTCSS activation. When activated it will look for a t
11: CTCSS tone
-This is the tone squelch in Hz. It can be selected using the toolbox among the usual CTCSS values and `--` for none. When a value is given and the CTCSS is activated the squelch will open only for signals with this tone squelch.
+This is the tone squelch in Hz. It can be selected using the toolbox among [these CTCSS values](https://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System) and `--` for none. When a value is given and the CTCSS is activated the squelch will open only for signals with this tone squelch.
12: CTCSS tone value
diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp
index 842525e30..9f90275fd 100644
--- a/plugins/channeltx/modnfm/nfmmodgui.cpp
+++ b/plugins/channeltx/modnfm/nfmmodgui.cpp
@@ -399,8 +399,7 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
ui->tone->setChecked(false);
ui->mic->setChecked(false);
- for (int i=0; i< NFMModSettings::m_nbCTCSSFreqs; i++)
- {
+ for (int i=0; i< NFMModSettings::getNbCTCSSFreq(); i++) {
ui->ctcss->addItem(QString("%1").arg((double) NFMModSettings::getCTCSSFreq(i), 0, 'f', 1));
}
diff --git a/plugins/channeltx/modnfm/nfmmodsettings.cpp b/plugins/channeltx/modnfm/nfmmodsettings.cpp
index 43717d990..a20842346 100644
--- a/plugins/channeltx/modnfm/nfmmodsettings.cpp
+++ b/plugins/channeltx/modnfm/nfmmodsettings.cpp
@@ -19,6 +19,7 @@
#include
#include "dsp/dspengine.h"
+#include "dsp/ctcssfrequencies.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "nfmmodsettings.h"
@@ -28,14 +29,6 @@ const int NFMModSettings::m_rfBW[] = {
};
const int NFMModSettings::m_nbRfBW = 11;
-const float NFMModSettings::m_ctcssFreqs[] = {
- 67.0, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8,
- 97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123.0, 127.3, 131.8,
- 136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2,
- 192.8, 203.5
-};
-const int NFMModSettings::m_nbCTCSSFreqs = 32;
-
NFMModSettings::NFMModSettings() :
m_channelMarker(0),
@@ -215,27 +208,29 @@ int NFMModSettings::getRFBWIndex(int rfbw)
return m_nbRfBW-1;
}
+int NFMModSettings::getNbCTCSSFreq()
+{
+ return CTCSSFrequencies::m_nbFreqs;
+}
+
float NFMModSettings::getCTCSSFreq(int index)
{
- if (index < 0) {
- return m_ctcssFreqs[0];
- } else if (index < m_nbCTCSSFreqs) {
- return m_ctcssFreqs[index];
+ if (index < CTCSSFrequencies::m_nbFreqs) {
+ return CTCSSFrequencies::m_Freqs[index];
} else {
- return m_ctcssFreqs[m_nbCTCSSFreqs-1];
+ return CTCSSFrequencies::m_Freqs[0];
}
}
int NFMModSettings::getCTCSSFreqIndex(float ctcssFreq)
{
- for (int i = 0; i < m_nbCTCSSFreqs; i++)
+ for (int i = 0; i < CTCSSFrequencies::m_nbFreqs; i++)
{
- if (ctcssFreq <= m_ctcssFreqs[i])
- {
+ if (ctcssFreq <= CTCSSFrequencies::m_Freqs[i]) {
return i;
}
}
- return m_nbCTCSSFreqs-1;
+ return CTCSSFrequencies::m_nbFreqs - 1;
}
diff --git a/plugins/channeltx/modnfm/nfmmodsettings.h b/plugins/channeltx/modnfm/nfmmodsettings.h
index 2080339bd..9a72a093f 100644
--- a/plugins/channeltx/modnfm/nfmmodsettings.h
+++ b/plugins/channeltx/modnfm/nfmmodsettings.h
@@ -37,8 +37,6 @@ struct NFMModSettings
static const int m_nbRfBW;
static const int m_rfBW[];
- static const int m_nbCTCSSFreqs;
- static const float m_ctcssFreqs[];
qint64 m_inputFrequencyOffset;
Real m_rfBandwidth;
@@ -80,6 +78,7 @@ struct NFMModSettings
static int getRFBW(int index);
static int getRFBWIndex(int rfbw);
+ static int getNbCTCSSFreq();
static float getCTCSSFreq(int index);
static int getCTCSSFreqIndex(float ctcssFreq);
};
diff --git a/plugins/channeltx/modnfm/readme.md b/plugins/channeltx/modnfm/readme.md
index 2cec43d70..22139d828 100644
--- a/plugins/channeltx/modnfm/readme.md
+++ b/plugins/channeltx/modnfm/readme.md
@@ -72,7 +72,7 @@ Checkbox to switch on the CTCSS sub-audio tone
12: CTSS tone frequency
-Select the CTCSS sub-audio tone in Hz among these values: 67.0, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8, 97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123.0, 127.3, 131.8, 136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2, 192.8 and 203.5 Hz
+Select the CTCSS sub-audio tone in Hz among [these values](https://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System)
14: CW (Morse) text
diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt
index 9439b5c85..ab08c08ab 100644
--- a/sdrbase/CMakeLists.txt
+++ b/sdrbase/CMakeLists.txt
@@ -79,6 +79,7 @@ set(sdrbase_SOURCES
dsp/upchannelizer.cpp
dsp/channelmarker.cpp
dsp/ctcssdetector.cpp
+ dsp/ctcssfrequencies.cpp
dsp/channelsamplesink.cpp
dsp/channelsamplesource.cpp
dsp/cwkeyer.cpp
@@ -219,6 +220,8 @@ set(sdrbase_HEADERS
dsp/channelsamplesink.h
dsp/channelsamplesource.h
dsp/complex.h
+ dsp/ctcssdetector.h
+ dsp/ctcssfrequencies.h
dsp/cwkeyer.h
dsp/cwkeyersettings.h
dsp/decimators.h
diff --git a/sdrbase/dsp/ctcssdetector.cpp b/sdrbase/dsp/ctcssdetector.cpp
index 622930c3a..c9122d3de 100644
--- a/sdrbase/dsp/ctcssdetector.cpp
+++ b/sdrbase/dsp/ctcssdetector.cpp
@@ -6,6 +6,7 @@
*/
#include
#include "dsp/ctcssdetector.h"
+#include "ctcssfrequencies.h"
#undef M_PI
#define M_PI 3.14159265358979323846
@@ -18,47 +19,14 @@ CTCSSDetector::CTCSSDetector() :
toneDetected(false),
maxPower(0.0)
{
- nTones = 32;
+ nTones = CTCSSFrequencies::m_nbFreqs;
k = new Real[nTones];
coef = new Real[nTones];
toneSet = new Real[nTones];
u0 = new Real[nTones];
u1 = new Real[nTones];
power = new Real[nTones];
-
- // The 32 EIA standard tones
- toneSet[0] = 67.0;
- toneSet[1] = 71.9;
- toneSet[2] = 74.4;
- toneSet[3] = 77.0;
- toneSet[4] = 79.7;
- toneSet[5] = 82.5;
- toneSet[6] = 85.4;
- toneSet[7] = 88.5;
- toneSet[8] = 91.5;
- toneSet[9] = 94.8;
- toneSet[10] = 97.4;
- toneSet[11] = 100.0;
- toneSet[12] = 103.5;
- toneSet[13] = 107.2;
- toneSet[14] = 110.9;
- toneSet[15] = 114.8;
- toneSet[16] = 118.8;
- toneSet[17] = 123.0;
- toneSet[18] = 127.3;
- toneSet[19] = 131.8;
- toneSet[20] = 136.5;
- toneSet[21] = 141.3;
- toneSet[22] = 146.2;
- toneSet[23] = 151.4;
- toneSet[24] = 156.7;
- toneSet[25] = 162.2;
- toneSet[26] = 167.9;
- toneSet[27] = 173.8;
- toneSet[28] = 179.9;
- toneSet[29] = 186.2;
- toneSet[30] = 192.8;
- toneSet[31] = 203.5;
+ toneSet = CTCSSFrequencies::m_Freqs;
}
CTCSSDetector::CTCSSDetector(int _nTones, Real *tones) :
@@ -69,18 +37,14 @@ CTCSSDetector::CTCSSDetector(int _nTones, Real *tones) :
toneDetected(false),
maxPower(0.0)
{
- nTones = _nTones;
+ nTones = CTCSSFrequencies::m_nbFreqs;
k = new Real[nTones];
coef = new Real[nTones];
toneSet = new Real[nTones];
u0 = new Real[nTones];
u1 = new Real[nTones];
power = new Real[nTones];
-
- for (int j = 0; j < nTones; ++j)
- {
- toneSet[j] = tones[j];
- }
+ toneSet = CTCSSFrequencies::m_Freqs;
}
diff --git a/sdrbase/dsp/ctcssdetector.h b/sdrbase/dsp/ctcssdetector.h
index 419b9ed10..0edf3c5a0 100644
--- a/sdrbase/dsp/ctcssdetector.h
+++ b/sdrbase/dsp/ctcssdetector.h
@@ -79,7 +79,7 @@ private:
Real maxPower;
Real *k;
Real *coef;
- Real *toneSet;
+ const float *toneSet;
Real *u0;
Real *u1;
Real *power;
diff --git a/sdrbase/dsp/ctcssfrequencies.cpp b/sdrbase/dsp/ctcssfrequencies.cpp
new file mode 100644
index 000000000..233250b3b
--- /dev/null
+++ b/sdrbase/dsp/ctcssfrequencies.cpp
@@ -0,0 +1,75 @@
+///////////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 2020 Edouard Griffiths, F4EXB //
+// //
+// This program is free software, you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation as version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY, without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License V3 for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+///////////////////////////////////////////////////////////////////////////////////
+
+#include "ctcssfrequencies.h"
+
+// The 51 tones from various standards (https://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System)
+const float CTCSSFrequencies::m_Freqs[] = {
+ 67.0, // 0
+ 69.3,
+ 71.9,
+ 74.4,
+ 77.0,
+ 79.7,
+ 82.5,
+ 85.4,
+ 88.5,
+ 91.5,
+ 94.8, // 10
+ 97.4,
+ 100.0,
+ 103.5,
+ 107.2,
+ 110.9,
+ 114.8,
+ 118.8,
+ 123.0,
+ 127.3,
+ 131.8, // 20
+ 136.5,
+ 141.3,
+ 146.2,
+ 150.0,
+ 151.4,
+ 156.7,
+ 159.8,
+ 162.2,
+ 165.5,
+ 167.9, // 30
+ 171.3,
+ 173.8,
+ 177.3,
+ 179.9,
+ 183.5,
+ 186.2,
+ 189.9,
+ 192.8,
+ 196.6,
+ 199.5, // 40
+ 203.5,
+ 206.5,
+ 210.7,
+ 218.1,
+ 225.7,
+ 229.1,
+ 233.6,
+ 241.8,
+ 250.3,
+ 254.1, // 50
+};
+
+const int CTCSSFrequencies::m_nbFreqs = 51;
diff --git a/sdrbase/dsp/ctcssfrequencies.h b/sdrbase/dsp/ctcssfrequencies.h
new file mode 100644
index 000000000..5b50ef0f8
--- /dev/null
+++ b/sdrbase/dsp/ctcssfrequencies.h
@@ -0,0 +1,23 @@
+///////////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 2020 Edouard Griffiths, F4EXB //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation as version 3 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License V3 for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program. If not, see . //
+///////////////////////////////////////////////////////////////////////////////////
+
+#include "export.h"
+
+struct SDRBASE_API CTCSSFrequencies {
+ static const int m_nbFreqs;
+ static const float m_Freqs[];
+};