Merge pull request #885 from cjcliffe/compiler-warning-cleanup-fixes

Cleanup: C++11 updates, clean-up, warning fixes
This commit is contained in:
Charles J. Cliffe 2021-07-05 20:58:00 -04:00 committed by GitHub
commit 29db1bde99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
171 changed files with 1932 additions and 2196 deletions

View File

@ -14,7 +14,7 @@
namespace CubicVR {
enum aabb_enum { AABB_DISJOINT, AABB_A_INSIDE_B, AABB_B_INSIDE_A, AABB_INTERSECT };
enum class aabb_intersect { AABB_DISJOINT, AABB_A_INSIDE_B, AABB_B_INSIDE_A, AABB_INTERSECT };
struct aabb {
vec3 min, max;
@ -76,33 +76,33 @@ namespace CubicVR {
CubicVR.enums.aabb.B_INSIDE_A if boxB is inside boxA
CubicVR.enums.aabb.DISJOINT if AABBs are disjoint (do not intersect)
*/
aabb_enum intersects(aabb boxA, aabb boxB) {
aabb_intersect intersects(aabb boxA, aabb boxB) {
// Disjoint
if( boxA.min[0] > boxB.max[0] || boxA.max[0] < boxB.min[0] ){
return AABB_DISJOINT;
return aabb_intersect::AABB_DISJOINT;
}
if( boxA.min[1] > boxB.max[1] || boxA.max[1] < boxB.min[1] ){
return AABB_DISJOINT;
return aabb_intersect::AABB_DISJOINT;
}
if( boxA.min[2] > boxB.max[2] || boxA.max[2] < boxB.min[2] ){
return AABB_DISJOINT;
return aabb_intersect::AABB_DISJOINT;
}
// boxA is inside boxB.
if( boxA.min[0] >= boxB.min[0] && boxA.max[0] <= boxB.max[0] &&
boxA.min[1] >= boxB.min[1] && boxA.max[1] <= boxB.max[1] &&
boxA.min[2] >= boxB.min[2] && boxA.max[2] <= boxB.max[2]) {
return AABB_A_INSIDE_B;
return aabb_intersect::AABB_A_INSIDE_B;
}
// boxB is inside boxA.
if( boxB.min[0] >= boxA.min[0] && boxB.max[0] <= boxA.max[0] &&
boxB.min[1] >= boxA.min[1] && boxB.max[1] <= boxA.max[1] &&
boxB.min[2] >= boxA.min[2] && boxB.max[2] <= boxA.max[2]) {
return AABB_B_INSIDE_A;
return aabb_intersect::AABB_B_INSIDE_A;
}
// Otherwise AABB's intersect.
return AABB_INTERSECT;
return aabb_intersect::AABB_INTERSECT;
}
};
};

View File

@ -6,35 +6,35 @@
#include <wx/msgdlg.h>
DeviceConfig::DeviceConfig() : deviceId("") {
DeviceConfig::DeviceConfig() {
ppm.store(0);
offset.store(0);
agcMode.store(true);
sampleRate.store(0);
}
DeviceConfig::DeviceConfig(std::string deviceId) : DeviceConfig() {
this->deviceId = deviceId;
DeviceConfig::DeviceConfig(std::string deviceId_in) : DeviceConfig() {
deviceId = deviceId_in;
}
void DeviceConfig::setPPM(int ppm) {
this->ppm.store(ppm);
void DeviceConfig::setPPM(int ppm_in) {
ppm.store(ppm_in);
}
int DeviceConfig::getPPM() {
return ppm.load();
}
void DeviceConfig::setOffset(long long offset) {
this->offset.store(offset);
void DeviceConfig::setOffset(long long offset_in) {
offset.store(offset_in);
}
long long DeviceConfig::getOffset() {
return offset.load();
}
void DeviceConfig::setSampleRate(long srate) {
sampleRate.store(srate);
void DeviceConfig::setSampleRate(long sampleRate_in) {
sampleRate.store(sampleRate_in);
}
long DeviceConfig::getSampleRate() {
@ -49,8 +49,8 @@ const std::string& DeviceConfig::getAntennaName() {
return antennaName;
}
void DeviceConfig::setAGCMode(bool agcMode) {
this->agcMode.store(agcMode);
void DeviceConfig::setAGCMode(bool agcMode_in) {
agcMode.store(agcMode_in);
}
bool DeviceConfig::getAGCMode() {
@ -58,9 +58,9 @@ bool DeviceConfig::getAGCMode() {
}
void DeviceConfig::setDeviceId(std::string deviceId) {
void DeviceConfig::setDeviceId(std::string deviceId_in) {
std::lock_guard < std::mutex > lock(busy_lock);
this->deviceId = deviceId;
deviceId = deviceId_in;
}
@ -74,18 +74,16 @@ std::string DeviceConfig::getDeviceId() {
return tmp;
}
void DeviceConfig::setDeviceName(std::string deviceName) {
void DeviceConfig::setDeviceName(std::string deviceName_in) {
std::lock_guard < std::mutex > lock(busy_lock);
this->deviceName = deviceName;
deviceName = deviceName_in;
}
std::string DeviceConfig::getDeviceName() {
std::string tmp;
std::lock_guard < std::mutex > lock(busy_lock);
tmp = (deviceName=="")?deviceId:deviceName;
tmp = deviceName.empty()?deviceId:deviceName;
return tmp;
}
@ -105,19 +103,19 @@ void DeviceConfig::save(DataNode *node) {
*node->newChild("antenna") = antennaName;
}
if (streamOpts.size()) {
if (!streamOpts.empty()) {
DataNode *streamOptsNode = node->newChild("streamOpts");
for (ConfigSettings::const_iterator opt_i = streamOpts.begin(); opt_i != streamOpts.end(); opt_i++) {
*streamOptsNode->newChild(opt_i->first.c_str()) = opt_i->second;
}
}
if (settings.size()) {
if (!settings.empty()) {
DataNode *settingsNode = node->newChild("settings");
for (ConfigSettings::const_iterator set_i = settings.begin(); set_i != settings.end(); set_i++) {
*settingsNode->newChild(set_i->first.c_str()) = set_i->second;
}
}
if (rigIF.size()) {
if (!rigIF.empty()) {
DataNode *rigIFs = node->newChild("rig_ifs");
for (std::map<int, long long>::const_iterator rigIF_i = rigIF.begin(); rigIF_i != rigIF.end(); rigIF_i++) {
DataNode *ifNode = rigIFs->newChild("rig_if");
@ -125,7 +123,7 @@ void DeviceConfig::save(DataNode *node) {
*ifNode->newChild("sdr_if") = rigIF_i->second;
}
}
if (gains.size()) {
if (!gains.empty()) {
DataNode *gainsNode = node->newChild("gains");
for (ConfigGains::const_iterator gain_i = gains.begin(); gain_i != gains.end(); gain_i++) {
DataNode *gainNode = gainsNode->newChild("gain");
@ -157,7 +155,7 @@ void DeviceConfig::load(DataNode *node) {
DataNode *agc_node = node->getNext("agc_mode");
int agcModeValue = 0;
agc_node->element()->get(agcModeValue);
setAGCMode(agcModeValue?true:false);
setAGCMode(agcModeValue != 0);
}
if (node->hasAnother("sample_rate")) {
DataNode *sample_rate_node = node->getNext("sample_rate");
@ -178,7 +176,7 @@ void DeviceConfig::load(DataNode *node) {
std::string keyName = streamOptNode->getName();
std::string strSettingValue = streamOptNode->element()->toString();
if (keyName != "") {
if (!keyName.empty()) {
setStreamOpt(keyName, strSettingValue);
}
}
@ -190,7 +188,7 @@ void DeviceConfig::load(DataNode *node) {
std::string keyName = settingNode->getName();
std::string strSettingValue = settingNode->element()->toString();
if (keyName != "") {
if (!keyName.empty()) {
setSetting(keyName, strSettingValue);
}
}
@ -201,7 +199,7 @@ void DeviceConfig::load(DataNode *node) {
DataNode *rigIFNode = rigIFNodes->getNext("rig_if");
if (rigIFNode->hasAnother("model") && rigIFNode->hasAnother("sdr_if")) {
int load_model;
long long load_freq;
long long load_freq = 0;
rigIFNode->getNext("model")->element()->get(load_model);
rigIFNode->getNext("sdr_if")->element()->get(load_freq);
@ -215,12 +213,12 @@ void DeviceConfig::load(DataNode *node) {
while (gainsNode->hasAnother("gain")) {
DataNode *gainNode = gainsNode->getNext("gain");
std::string keyName;
float fltSettingValue;
float fltSettingValue = 0;
gainNode->getNext("id")->element()->get(keyName);
gainNode->getNext("value")->element()->get(fltSettingValue);
if (keyName != "" && !(fltSettingValue!=fltSettingValue)) {
if (!keyName.empty() && !(fltSettingValue!=fltSettingValue)) {
setGain(keyName, fltSettingValue);
}
}
@ -236,11 +234,11 @@ ConfigSettings DeviceConfig::getStreamOpts() {
return streamOpts;
}
void DeviceConfig::setStreamOpt(std::string key, std::string value) {
void DeviceConfig::setStreamOpt(const std::string& key, std::string value) {
streamOpts[key] = value;
}
std::string DeviceConfig::getStreamOpt(std::string key, std::string defaultValue) {
std::string DeviceConfig::getStreamOpt(const std::string& key, std::string defaultValue) {
if (streamOpts.find(key) == streamOpts.end()) {
return defaultValue;
}
@ -248,15 +246,15 @@ std::string DeviceConfig::getStreamOpt(std::string key, std::string defaultValue
return streamOpts[key];
}
void DeviceConfig::setSettings(ConfigSettings settings) {
this->settings = settings;
void DeviceConfig::setSettings(ConfigSettings settings_in) {
settings = settings_in;
}
void DeviceConfig::setSetting(std::string key, std::string value) {
this->settings[key] = value;
void DeviceConfig::setSetting(const std::string& key, std::string value) {
settings[key] = value;
}
std::string DeviceConfig::getSetting(std::string key, std::string defaultValue) {
std::string DeviceConfig::getSetting(const std::string& key, std::string defaultValue) {
if (settings.find(key) == settings.end()) {
return defaultValue;
}
@ -268,19 +266,19 @@ ConfigSettings DeviceConfig::getSettings() {
}
void DeviceConfig::setGains(ConfigGains gains) {
this->gains = gains;
void DeviceConfig::setGains(ConfigGains gains_in) {
gains = gains_in;
}
ConfigGains DeviceConfig::getGains() {
return gains;
}
void DeviceConfig::setGain(std::string key, float value) {
void DeviceConfig::setGain(const std::string& key, float value) {
gains[key] = value;
}
float DeviceConfig::getGain(std::string key, float defaultValue) {
float DeviceConfig::getGain(const std::string& key, float defaultValue) {
if (gains.find(key) != gains.end()) {
return gains[key];
}
@ -299,7 +297,7 @@ long long DeviceConfig::getRigIF(int rigType) {
return 0;
}
AppConfig::AppConfig() : configName("") {
AppConfig::AppConfig() {
winX.store(0);
winY.store(0);
winW.store(0);
@ -334,7 +332,7 @@ AppConfig::AppConfig() : configName("") {
#endif
}
DeviceConfig *AppConfig::getDevice(std::string deviceId) {
DeviceConfig *AppConfig::getDevice(const std::string& deviceId) {
if (deviceConfig.find(deviceId) == deviceConfig.end()) {
deviceConfig[deviceId] = new DeviceConfig();
}
@ -402,23 +400,23 @@ AppConfig::PerfModeEnum AppConfig::getPerfMode() {
}
wxRect *AppConfig::getWindow() {
wxRect *r = NULL;
wxRect *r = nullptr;
if (winH.load() && winW.load()) {
r = new wxRect(winX.load(),winY.load(),winW.load(),winH.load());
}
return r;
}
void AppConfig::setTheme(int themeId) {
this->themeId.store(themeId);
void AppConfig::setTheme(int themeId_in) {
themeId.store(themeId_in);
}
int AppConfig::getTheme() {
return themeId.load();
}
void AppConfig::setFontScale(int fontScale) {
this->fontScale.store(fontScale);
void AppConfig::setFontScale(int fontScale_in) {
fontScale.store(fontScale_in);
}
int AppConfig::getFontScale() {
@ -540,7 +538,7 @@ void AppConfig::setRecordingSquelchOption(int enumChoice) {
recordingSquelchOption = enumChoice;
}
int AppConfig::getRecordingSquelchOption() {
int AppConfig::getRecordingSquelchOption() const {
return recordingSquelchOption;
}
@ -548,13 +546,13 @@ void AppConfig::setRecordingFileTimeLimit(int nbSeconds) {
recordingFileTimeLimitSeconds = nbSeconds;
}
int AppConfig::getRecordingFileTimeLimit() {
int AppConfig::getRecordingFileTimeLimit() const {
return recordingFileTimeLimitSeconds;
}
void AppConfig::setConfigName(std::string configName) {
this->configName = configName;
void AppConfig::setConfigName(std::string configName_in) {
configName = configName_in;
}
std::string AppConfig::getConfigFileName(bool ignoreName) {
@ -597,7 +595,7 @@ bool AppConfig::save() {
*window_node->newChild("center_freq") = centerFreq.load();
*window_node->newChild("waterfall_lps") = waterfallLinesPerSec.load();
*window_node->newChild("spectrum_avg") = spectrumAvgSpeed.load();
*window_node->newChild("modemprops_collapsed") = modemPropsCollapsed.load();;
*window_node->newChild("modemprops_collapsed") = modemPropsCollapsed.load();
*window_node->newChild("db_offset") = dbOffset.load();
*window_node->newChild("main_split") = mainSplit.load();
@ -620,12 +618,12 @@ bool AppConfig::save() {
device_config_i->second->save(device_node);
}
if (manualDevices.size()) {
if (!manualDevices.empty()) {
DataNode *manual_node = cfg.rootNode()->newChild("manual_devices");
for (std::vector<SDRManualDef>::const_iterator i = manualDevices.begin(); i != manualDevices.end(); i++) {
for (const auto & manualDevice : manualDevices) {
DataNode *rig_node = manual_node->newChild("device");
*rig_node->newChild("factory") = i->factory;
*rig_node->newChild("params") = i->params;
*rig_node->newChild("factory") = manualDevice.factory;
*rig_node->newChild("params") = manualDevice.params;
}
}
@ -708,12 +706,12 @@ bool AppConfig::load() {
if (win_node->hasAnother("max")) {
win_node->getNext("max")->element()->get(max);
winMax.store(max?true:false);
winMax.store(max != 0);
}
if (win_node->hasAnother("tips")) {
win_node->getNext("tips")->element()->get(tips);
showTips.store(tips?true:false);
showTips.store(tips != 0);
}
// default:
@ -730,31 +728,31 @@ bool AppConfig::load() {
}
if (win_node->hasAnother("theme")) {
int theme;
int theme = 0;
win_node->getNext("theme")->element()->get(theme);
themeId.store(theme);
}
if (win_node->hasAnother("font_scale")) {
int fscale;
int fscale = 0;
win_node->getNext("font_scale")->element()->get(fscale);
fontScale.store(fscale);
}
if (win_node->hasAnother("snap")) {
long long snapVal;
long long snapVal = 0;
win_node->getNext("snap")->element()->get(snapVal);
snap.store(snapVal);
}
if (win_node->hasAnother("center_freq")) {
long long freqVal;
long long freqVal = 0;
win_node->getNext("center_freq")->element()->get(freqVal);
centerFreq.store(freqVal);
}
if (win_node->hasAnother("waterfall_lps")) {
int lpsVal;
int lpsVal = 30;
win_node->getNext("waterfall_lps")->element()->get(lpsVal);
waterfallLinesPerSec.store(lpsVal);
}
@ -767,7 +765,7 @@ bool AppConfig::load() {
if (win_node->hasAnother("modemprops_collapsed")) {
win_node->getNext("modemprops_collapsed")->element()->get(mpc);
modemPropsCollapsed.store(mpc?true:false);
modemPropsCollapsed.store(mpc != 0);
}
if (win_node->hasAnother("db_offset")) {
@ -858,7 +856,7 @@ bool AppConfig::load() {
if (rig_node->hasAnother("enabled")) {
int loadEnabled;
rig_node->getNext("enabled")->element()->get(loadEnabled);
rigEnabled.store(loadEnabled?true:false);
rigEnabled.store(loadEnabled != 0);
}
if (rig_node->hasAnother("model")) {
int loadModel;
@ -876,22 +874,22 @@ bool AppConfig::load() {
if (rig_node->hasAnother("control")) {
int loadControl;
rig_node->getNext("control")->element()->get(loadControl);
rigControlMode.store(loadControl?true:false);
rigControlMode.store(loadControl != 0);
}
if (rig_node->hasAnother("follow")) {
int loadFollow;
rig_node->getNext("follow")->element()->get(loadFollow);
rigFollowMode.store(loadFollow?true:false);
rigFollowMode.store(loadFollow != 0);
}
if (rig_node->hasAnother("center_lock")) {
int loadCenterLock;
rig_node->getNext("center_lock")->element()->get(loadCenterLock);
rigCenterLock.store(loadCenterLock?true:false);
rigCenterLock.store(loadCenterLock != 0);
}
if (rig_node->hasAnother("follow_modem")) {
int loadFollow;
rig_node->getNext("follow_modem")->element()->get(loadFollow);
rigFollowModem.store(loadFollow?true:false);
rigFollowModem.store(loadFollow != 0);
}
}
#endif
@ -912,24 +910,24 @@ int AppConfig::getRigModel() {
return rigModel.load();
}
void AppConfig::setRigModel(int rigModel) {
this->rigModel.store(rigModel);
void AppConfig::setRigModel(int rigModel_in) {
rigModel.store(rigModel_in);
}
int AppConfig::getRigRate() {
return rigRate.load();
}
void AppConfig::setRigRate(int rigRate) {
this->rigRate.store(rigRate);
void AppConfig::setRigRate(int rigRate_in) {
rigRate.store(rigRate_in);
}
std::string AppConfig::getRigPort() {
return rigPort;
}
void AppConfig::setRigPort(std::string rigPort) {
this->rigPort = rigPort;
void AppConfig::setRigPort(std::string rigPort_in) {
rigPort = rigPort_in;
}
void AppConfig::setRigControlMode(bool cMode) {

View File

@ -20,43 +20,43 @@ typedef std::map<std::string, float> ConfigGains;
class DeviceConfig {
public:
DeviceConfig();
DeviceConfig(std::string deviceId);
explicit DeviceConfig(std::string deviceId_in);
void setPPM(int ppm);
void setPPM(int ppm_in);
int getPPM();
void setOffset(long long offset);
void setOffset(long long offset_in);
long long getOffset();
void setSampleRate(long srate);
void setSampleRate(long sampleRate_in);
long getSampleRate();
void setAntennaName(const std::string& name);
const std::string& getAntennaName();
void setAGCMode(bool agcMode);
void setAGCMode(bool agcMode_in);
bool getAGCMode();
void setDeviceId(std::string deviceId);
void setDeviceId(std::string deviceId_in);
std::string getDeviceId();
void setDeviceName(std::string deviceName);
void setDeviceName(std::string deviceName_in);
std::string getDeviceName();
void setStreamOpts(ConfigSettings opts);
ConfigSettings getStreamOpts();
void setStreamOpt(std::string key, std::string value);
std::string getStreamOpt(std::string key, std::string defaultValue);
void setStreamOpt(const std::string& key, std::string value);
std::string getStreamOpt(const std::string& key, std::string defaultValue);
void setSettings(ConfigSettings settings);
void setSettings(ConfigSettings settings_in);
ConfigSettings getSettings();
void setSetting(std::string key, std::string value);
std::string getSetting(std::string key, std::string defaultValue);
void setSetting(const std::string& key, std::string value);
std::string getSetting(const std::string& key, std::string defaultValue);
void setGains(ConfigGains gains);
void setGains(ConfigGains gains_in);
ConfigGains getGains();
void setGain(std::string key, float value);
float getGain(std::string key, float defaultValue);
void setGain(const std::string& key, float value);
float getGain(const std::string& key, float defaultValue);
void setRigIF(int rigType, long long freq);
long long getRigIF(int rigType);
@ -70,10 +70,10 @@ private:
std::mutex busy_lock;
std::atomic_int ppm;
std::atomic_llong offset;
std::atomic_bool agcMode;
std::atomic_long sampleRate;
std::atomic_int ppm{};
std::atomic_llong offset{};
std::atomic_bool agcMode{};
std::atomic_long sampleRate{};
std::string antennaName;
ConfigSettings streamOpts;
ConfigGains gains;
@ -93,7 +93,7 @@ public:
AppConfig();
std::string getConfigDir();
DeviceConfig *getDevice(std::string deviceId);
DeviceConfig *getDevice(const std::string& deviceId);
void setWindow(wxPoint winXY, wxSize winWH);
wxRect *getWindow();
@ -110,10 +110,10 @@ public:
void setPerfMode(PerfModeEnum mode);
PerfModeEnum getPerfMode();
void setTheme(int themeId);
void setTheme(int themeId_in);
int getTheme();
void setFontScale(int scaleValue);
void setFontScale(int fontScale_in);
int getFontScale();
void setSnap(long long snapVal);
@ -152,20 +152,20 @@ public:
bool verifyRecordingPath();
void setRecordingSquelchOption(int enumChoice);
int getRecordingSquelchOption();
int getRecordingSquelchOption() const;
void setRecordingFileTimeLimit(int nbSeconds);
int getRecordingFileTimeLimit();
int getRecordingFileTimeLimit() const;
#if USE_HAMLIB
int getRigModel();
void setRigModel(int rigModel);
void setRigModel(int rigModel_in);
int getRigRate();
void setRigRate(int rigRate);
void setRigRate(int rigRate_in);
std::string getRigPort();
void setRigPort(std::string rigPort);
void setRigPort(std::string rigPort_in);
void setRigControlMode(bool cMode);
bool getRigControlMode();
@ -183,7 +183,7 @@ public:
bool getRigEnabled();
#endif
void setConfigName(std::string configName);
void setConfigName(std::string configName_in);
std::string getConfigFileName(bool ignoreName=false);
bool save();
bool load();
@ -192,26 +192,26 @@ public:
private:
std::string configName;
std::map<std::string, DeviceConfig *> deviceConfig;
std::atomic_int winX,winY,winW,winH;
std::atomic_bool winMax, showTips, modemPropsCollapsed;
std::atomic_int themeId;
std::atomic_int fontScale;
std::atomic_llong snap;
std::atomic_llong centerFreq;
std::atomic_int waterfallLinesPerSec;
std::atomic<float> spectrumAvgSpeed, mainSplit, visSplit, bookmarkSplit;
std::atomic_int dbOffset;
std::atomic_int winX{},winY{},winW{},winH{};
std::atomic_bool winMax{}, showTips{}, modemPropsCollapsed{};
std::atomic_int themeId{};
std::atomic_int fontScale{};
std::atomic_llong snap{};
std::atomic_llong centerFreq{};
std::atomic_int waterfallLinesPerSec{};
std::atomic<float> spectrumAvgSpeed{}, mainSplit{}, visSplit{}, bookmarkSplit{};
std::atomic_int dbOffset{};
std::vector<SDRManualDef> manualDevices;
std::atomic_bool bookmarksVisible;
std::atomic_bool bookmarksVisible{};
std::atomic<PerfModeEnum> perfMode;
std::atomic<PerfModeEnum> perfMode{};
std::string recordingPath = "";
std::string recordingPath;
int recordingSquelchOption = 0;
int recordingFileTimeLimitSeconds = 0;
#if USE_HAMLIB
std::atomic_int rigModel, rigRate;
std::atomic_int rigModel{}, rigRate{};
std::string rigPort;
std::atomic_bool rigEnabled, rigFollowMode, rigControlMode, rigCenterLock, rigFollowModem;
std::atomic_bool rigEnabled{}, rigFollowMode{}, rigControlMode{}, rigCenterLock{}, rigFollowModem{};
#endif
};

View File

@ -32,7 +32,7 @@
#include <wx/panel.h>
#include <wx/numformatter.h>
#include <stddef.h>
#include <cstddef>
#if defined(__linux__) || defined(__FreeBSD__)
#include "CubicSDR.xpm"
@ -61,7 +61,7 @@ public:
m_questionText->SetLabelText(wxT("Resetting bookmarks will erase all current bookmarks; are you sure?"));
}
void doClickOK() {
void doClickOK() override {
wxGetApp().getBookmarkMgr().resetBookmarks();
wxGetApp().getBookmarkMgr().updateBookmarks();
wxGetApp().getBookmarkMgr().updateActiveList();
@ -73,7 +73,7 @@ public:
#define APPFRAME_MODEMPROPS_MAXSIZE 240
AppFrame::AppFrame() :
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(nullptr) {
wxFrame(nullptr, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(nullptr) {
initIcon();
@ -81,8 +81,8 @@ AppFrame::AppFrame() :
modemPropertiesUpdated.store(false);
demodTray = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *demodTunerTray = new wxBoxSizer(wxHORIZONTAL);
auto *demodScopeTray = new wxBoxSizer(wxVERTICAL);
auto *demodTunerTray = new wxBoxSizer(wxHORIZONTAL);
// OpenGL settings:
//deprecated format: std::vector<int> attribList = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
@ -93,7 +93,7 @@ AppFrame::AppFrame() :
mainSplitter->SetSashGravity(10.0f / 37.0f);
mainSplitter->SetMinimumPaneSize(1);
wxPanel *demodPanel = new wxPanel(mainSplitter, wxID_ANY);
auto *demodPanel = new wxPanel(mainSplitter, wxID_ANY);
#ifdef CUBICSDR_HEADER_IMAGE
wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath());
@ -143,7 +143,7 @@ AppFrame::AppFrame() :
#if CUBICSDR_ENABLE_VIEW_DEMOD
// Demodulator View
wxBoxSizer *demodVisuals = new wxBoxSizer(wxVERTICAL);
auto *demodVisuals = new wxBoxSizer(wxVERTICAL);
// Demod Spectrum
demodSpectrumCanvas = makeDemodSpectrumCanvas(demodPanel, attribList);
@ -203,7 +203,7 @@ AppFrame::AppFrame() :
demodTray->Add(demodScopeTray, 30, wxEXPAND | wxALL, 0);
demodTray->AddSpacer(1);
wxBoxSizer *demodGainTray = new wxBoxSizer(wxVERTICAL);
auto *demodGainTray = new wxBoxSizer(wxVERTICAL);
// Demod Gain Meter
demodGainMeter = makeModemGainMeter(demodPanel, attribList);
@ -231,8 +231,8 @@ AppFrame::AppFrame() :
mainVisSplitter->SetMinimumPaneSize(1);
mainVisSplitter->SetSashGravity(6.0f / 25.0f);
wxPanel *spectrumPanel = new wxPanel(mainVisSplitter, wxID_ANY);
wxBoxSizer *spectrumSizer = new wxBoxSizer(wxHORIZONTAL);
auto *spectrumPanel = new wxPanel(mainVisSplitter, wxID_ANY);
auto *spectrumSizer = new wxBoxSizer(wxHORIZONTAL);
// Spectrum Canvas
spectrumCanvas = makeSpectrumCanvas(spectrumPanel, attribList);
@ -243,7 +243,7 @@ AppFrame::AppFrame() :
spectrumSizer->Add(spectrumCanvas, 63, wxEXPAND | wxALL, 0);
spectrumSizer->AddSpacer(1);
wxBoxSizer *spectrumCtlTray = new wxBoxSizer(wxVERTICAL);
auto *spectrumCtlTray = new wxBoxSizer(wxVERTICAL);
// Peak Hold
peakHoldButton = makePeakHoldButton(spectrumPanel, attribList);
@ -256,8 +256,8 @@ AppFrame::AppFrame() :
spectrumSizer->Add(spectrumCtlTray, 1, wxEXPAND | wxALL, 0);
spectrumPanel->SetSizer(spectrumSizer);
wxPanel *waterfallPanel = new wxPanel(mainVisSplitter, wxID_ANY);
wxBoxSizer *waterfallSizer = new wxBoxSizer(wxHORIZONTAL);
auto *waterfallPanel = new wxPanel(mainVisSplitter, wxID_ANY);
auto *waterfallSizer = new wxBoxSizer(wxHORIZONTAL);
// Waterfall
waterfallCanvas = makeWaterfall(waterfallPanel, attribList);
@ -291,7 +291,7 @@ AppFrame::AppFrame() :
spectrumCanvas->attachWaterfallCanvas(waterfallCanvas);
// Primary sizer for the window
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
auto *vbox = new wxBoxSizer(wxVERTICAL);
vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0);
/* * /
@ -451,7 +451,7 @@ void AppFrame::initConfigurationSettings() {
}
ModemProperties *AppFrame::makeModemProperties(wxPanel *parent) {
ModemProperties *pProperties = new ModemProperties(parent, wxID_ANY);
auto *pProperties = new ModemProperties(parent, wxID_ANY);
pProperties->SetMinSize(wxSize(APPFRAME_MODEMPROPS_MAXSIZE, -1));
pProperties->SetMaxSize(wxSize(APPFRAME_MODEMPROPS_MAXSIZE, -1));
@ -462,7 +462,7 @@ ModemProperties *AppFrame::makeModemProperties(wxPanel *parent) {
}
ModeSelectorCanvas *AppFrame::makeModemAdvSelectorPanel(wxPanel *parent, const wxGLAttributes &attribList) {
ModeSelectorCanvas *pCanvas = new ModeSelectorCanvas(parent, attribList);
auto *pCanvas = new ModeSelectorCanvas(parent, attribList);
pCanvas->addChoice("ASK");
pCanvas->addChoice("APSK");
pCanvas->addChoice("BPSK");
@ -578,7 +578,7 @@ wxMenu *AppFrame::makeRigMenu() {
ScopeCanvas *AppFrame::makeScopeCanvas(wxPanel *parent, const wxGLAttributes &attribList) {
ScopeCanvas *pCanvas = new ScopeCanvas(parent, attribList);
auto *pCanvas = new ScopeCanvas(parent, attribList);
pCanvas->setHelpTip("Audio Visuals, drag left/right to toggle Scope or Spectrum, 'B' to toggle decibels display.");
pCanvas->SetMinSize(wxSize(128, -1));
return pCanvas;
@ -587,8 +587,8 @@ ScopeCanvas *AppFrame::makeScopeCanvas(wxPanel *parent, const wxGLAttributes &at
wxMenu *AppFrame::makeDisplayMenu() {
//Add Display menu
wxMenu *dispMenu = new wxMenu;
wxMenu *fontMenu = new wxMenu;
auto *dispMenu = new wxMenu;
auto *fontMenu = new wxMenu;
int fontScale = wxGetApp().getConfig()->getFontScale();
@ -598,7 +598,7 @@ wxMenu *AppFrame::makeDisplayMenu() {
dispMenu->AppendSubMenu(fontMenu, "&Text Size");
wxMenu *themeMenu = new wxMenu;
auto *themeMenu = new wxMenu;
int themeId = wxGetApp().getConfig()->getTheme();
@ -621,48 +621,47 @@ wxMenu *AppFrame::makeDisplayMenu() {
wxMenu *AppFrame::makeAudioSampleRateMenu() {
// Audio Sample Rates
wxMenu *pMenu = new wxMenu;
auto *pMenu = new wxMenu;
auto outputDevices = wxGetApp().getDemodMgr().getOutputDevices();
#define NUM_RATES_DEFAULT 4
unsigned int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };
for (auto mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
for (auto & outputDevice : outputDevices) {
unsigned int desired_rate = 0;
unsigned int desired_rank = NUM_RATES_DEFAULT + 1;
for (auto srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
srate++) {
for (unsigned int & sampleRate : outputDevice.second.sampleRates) {
for (unsigned int i = 0; i < NUM_RATES_DEFAULT; i++) {
if (desired_rates[i] == (*srate)) {
if (desired_rates[i] == sampleRate) {
if (desired_rank > i) {
desired_rank = i;
desired_rate = (*srate);
desired_rate = sampleRate;
}
}
}
}
if (desired_rank > NUM_RATES_DEFAULT) {
desired_rate = mdevices_i->second.sampleRates.back();
desired_rate = outputDevice.second.sampleRates.back();
}
AudioThread::deviceSampleRate[mdevices_i->first] = desired_rate;
AudioThread::deviceSampleRate[outputDevice.first] = desired_rate;
}
for (auto mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
wxMenu *subMenu = new wxMenu;
pMenu->AppendSubMenu(subMenu, mdevices_i->second.name, wxT("Description?"));
for (auto & outputDevice : outputDevices) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * outputDevice.first;
auto *subMenu = new wxMenu;
pMenu->AppendSubMenu(subMenu, outputDevice.second.name, wxT("Description?"));
int j = 0;
for (auto srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
for (auto srate = outputDevice.second.sampleRates.begin(); srate != outputDevice.second.sampleRates.end();
srate++) {
stringstream srateName;
srateName << ((float) (*srate) / 1000.0f) << "kHz";
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id + j, srateName.str(), wxT("Description?"));
if ((int)(*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
if ((int)(*srate) == AudioThread::deviceSampleRate[outputDevice.first]) {
itm->Check(true);
}
audioSampleRateMenuItems[menu_id + j] = itm;
@ -674,7 +673,7 @@ wxMenu *AppFrame::makeAudioSampleRateMenu() {
}
MeterCanvas *AppFrame::makeWaterfallSpeedMeter(wxWindow *parent, const wxGLAttributes &attribList) {
MeterCanvas *pCanvas = new MeterCanvas(parent, attribList);
auto *pCanvas = new MeterCanvas(parent, attribList);
pCanvas->setHelpTip("Waterfall speed, click or drag to adjust (max 1024 lines per second)");
pCanvas->setMax(sqrt(1024));
pCanvas->setLevel(sqrt(DEFAULT_WATERFALL_LPS));
@ -684,13 +683,13 @@ MeterCanvas *AppFrame::makeWaterfallSpeedMeter(wxWindow *parent, const wxGLAttri
}
WaterfallCanvas *AppFrame::makeWaterfall(wxWindow *parent, const wxGLAttributes &attribList) {
WaterfallCanvas *pCanvas = new WaterfallCanvas(parent, attribList);
auto *pCanvas = new WaterfallCanvas(parent, attribList);
pCanvas->setup(DEFAULT_FFT_SIZE, DEFAULT_MAIN_WATERFALL_LINES_NB);
return pCanvas;
}
MeterCanvas * AppFrame::makeSpectrumAvgMeter(wxWindow *parent, const wxGLAttributes &attribList) {
MeterCanvas *pCanvas = new MeterCanvas(parent, attribList);
auto *pCanvas = new MeterCanvas(parent, attribList);
pCanvas->setHelpTip("Spectrum averaging speed, click or drag to adjust.");
pCanvas->setMax(1.0);
pCanvas->setLevel(0.65f);
@ -700,7 +699,7 @@ MeterCanvas * AppFrame::makeSpectrumAvgMeter(wxWindow *parent, const wxGLAttribu
}
SpectrumCanvas *AppFrame::makeSpectrumCanvas(wxWindow *parent, const wxGLAttributes &attribList) {
SpectrumCanvas *pCanvas = new SpectrumCanvas(parent, attribList);
auto *pCanvas = new SpectrumCanvas(parent, attribList);
pCanvas->setShowDb(true);
pCanvas->setUseDBOfs(true);
pCanvas->setScaleFactorEnabled(true);
@ -708,7 +707,7 @@ SpectrumCanvas *AppFrame::makeSpectrumCanvas(wxWindow *parent, const wxGLAttribu
}
ModeSelectorCanvas *AppFrame::makePeakHoldButton(wxWindow *parent, const wxGLAttributes &attribList) {
ModeSelectorCanvas *pCanvas = new ModeSelectorCanvas(parent, attribList);
auto *pCanvas = new ModeSelectorCanvas(parent, attribList);
pCanvas->addChoice(1, "P");
pCanvas->setPadding(-1, -1);
pCanvas->setHighlightColor(RGBA4f(0.2f, 0.8f, 0.2f));
@ -720,7 +719,7 @@ ModeSelectorCanvas *AppFrame::makePeakHoldButton(wxWindow *parent, const wxGLAtt
}
ModeSelectorCanvas *AppFrame::makeModemMuteButton(wxWindow *parent, const wxGLAttributes &attribList) {
ModeSelectorCanvas *pCanvas = new ModeSelectorCanvas(parent, attribList);
auto *pCanvas = new ModeSelectorCanvas(parent, attribList);
pCanvas->addChoice(1, "M");
pCanvas->setPadding(-1, -1);
pCanvas->setHighlightColor(RGBA4f(0.8f, 0.2f, 0.2f));
@ -732,7 +731,7 @@ ModeSelectorCanvas *AppFrame::makeModemMuteButton(wxWindow *parent, const wxGLAt
}
ModeSelectorCanvas *AppFrame::makeSoloModeButton(wxWindow *parent, const wxGLAttributes &attribList) {
ModeSelectorCanvas *pCanvas = new ModeSelectorCanvas(parent, attribList);
auto *pCanvas = new ModeSelectorCanvas(parent, attribList);
pCanvas->addChoice(1, "S");
pCanvas->setPadding(-1, -1);
pCanvas->setHighlightColor(RGBA4f(0.8f, 0.8f, 0.2f));
@ -744,7 +743,7 @@ ModeSelectorCanvas *AppFrame::makeSoloModeButton(wxWindow *parent, const wxGLAtt
}
MeterCanvas *AppFrame::makeModemGainMeter(wxWindow *parent, const wxGLAttributes &attribList) {
MeterCanvas *pCanvas = new MeterCanvas(parent, attribList);
auto *pCanvas = new MeterCanvas(parent, attribList);
pCanvas->setMax(2.0);
pCanvas->setHelpTip("Current Demodulator Gain Level. Click / Drag to set Gain level.");
pCanvas->setShowUserInput(false);
@ -753,13 +752,13 @@ MeterCanvas *AppFrame::makeModemGainMeter(wxWindow *parent, const wxGLAttributes
}
TuningCanvas *AppFrame::makeModemTuner(wxWindow *parent, const wxGLAttributes &attribList) {
TuningCanvas *pCanvas = new TuningCanvas(parent, attribList);
auto *pCanvas = new TuningCanvas(parent, attribList);
pCanvas->SetMinClientSize(wxSize(200, 28));
return pCanvas;
}
ModeSelectorCanvas * AppFrame::makeDeltaLockButton(wxWindow *parent, const wxGLAttributes &attribList) {
ModeSelectorCanvas *pCanvas = new ModeSelectorCanvas(parent, attribList);
auto *pCanvas = new ModeSelectorCanvas(parent, attribList);
pCanvas->addChoice(1, "V");
pCanvas->setPadding(-1, -1);
pCanvas->setHighlightColor(RGBA4f(0.8f, 0.8f, 0.2f));
@ -771,7 +770,7 @@ ModeSelectorCanvas * AppFrame::makeDeltaLockButton(wxWindow *parent, const wxGLA
}
MeterCanvas *AppFrame::makeSignalMeter(wxWindow *parent, const wxGLAttributes &attribList) {
MeterCanvas *pCanvas = new MeterCanvas(parent, attribList);
auto *pCanvas = new MeterCanvas(parent, attribList);
pCanvas->setMax(DEMOD_SIGNAL_MAX);
pCanvas->setMin(DEMOD_SIGNAL_MIN);
pCanvas->setLevel(DEMOD_SIGNAL_MIN);
@ -782,13 +781,13 @@ MeterCanvas *AppFrame::makeSignalMeter(wxWindow *parent, const wxGLAttributes &a
}
SpectrumCanvas *AppFrame::makeDemodSpectrumCanvas(wxWindow *parent, const wxGLAttributes &attribList) {
SpectrumCanvas *pCanvas = new SpectrumCanvas(parent, attribList);
auto *pCanvas = new SpectrumCanvas(parent, attribList);
pCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000);
return pCanvas;
}
WaterfallCanvas *AppFrame::makeWaterfallCanvas(wxWindow *parent, const wxGLAttributes &attribList) {
WaterfallCanvas *pCanvas = new WaterfallCanvas(parent, attribList);
auto *pCanvas = new WaterfallCanvas(parent, attribList);
pCanvas->setup(DEFAULT_DMOD_FFT_SIZE, DEFAULT_DEMOD_WATERFALL_LINES_NB);
pCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000);
pCanvas->setMinBandwidth(8000);
@ -811,9 +810,9 @@ ModeSelectorCanvas *AppFrame::makeModemSelectorPanel(wxWindow *parent, const wxG
}
#endif
ModeSelectorCanvas *pCanvas = new ModeSelectorCanvas(parent, attribList);
auto *pCanvas = new ModeSelectorCanvas(parent, attribList);
for (auto mt_i : modemList) {
for (const auto& mt_i : modemList) {
pCanvas->addChoice(mt_i);
}
@ -837,7 +836,7 @@ AppFrame::~AppFrame() {
wxMenu *AppFrame::makeFileMenu() {
wxMenu *menu = new wxMenu;
auto *menu = new wxMenu;
#ifndef __APPLE__
#ifdef CUBICSDR_ENABLE_ABOUT_DIALOG
menu->Append(wxID_ABOUT_CUBICSDR, "About " CUBICSDR_INSTALL_NAME);
@ -848,7 +847,7 @@ wxMenu *AppFrame::makeFileMenu() {
menu->Append(wxID_SDR_START_STOP, "Stop / Start Device");
menu->AppendSeparator();
wxMenu *sessionMenu = new wxMenu;
auto *sessionMenu = new wxMenu;
sessionMenu->Append(wxID_OPEN, "&Open Session");
sessionMenu->Append(wxID_SAVE, "&Save Session");
@ -860,7 +859,7 @@ wxMenu *AppFrame::makeFileMenu() {
menu->AppendSeparator();
wxMenu *bookmarkMenu = new wxMenu;
auto *bookmarkMenu = new wxMenu;
bookmarkMenu->Append(wxID_OPEN_BOOKMARKS, "Open Bookmarks");
bookmarkMenu->Append(wxID_SAVE_BOOKMARKS, "Save Bookmarks");
@ -890,14 +889,14 @@ wxMenu *AppFrame::makeRecordingMenu() {
recordingMenuItems.clear();
wxMenu *menu = new wxMenu;
auto *menu = new wxMenu;
recordingMenuItems[wxID_RECORDING_PATH] = menu->Append(wxID_RECORDING_PATH, getSettingsLabel("Set Recording Path", "<Not Set>"));
menu->AppendSeparator();
//Squelch options as sub-menu:
wxMenu *subMenu = new wxMenu;
auto *subMenu = new wxMenu;
recordingMenuItems[wxID_RECORDING_SQUELCH_BASE] = menu->AppendSubMenu(subMenu, "Squelch");
recordingMenuItems[wxID_RECORDING_SQUELCH_SILENCE] = subMenu->AppendRadioItem(wxID_RECORDING_SQUELCH_SILENCE, "Record Silence",
@ -962,8 +961,8 @@ void AppFrame::updateRecordingMenu() {
}
}
void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) {
this->devInfo = devInfo;
void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo_in) {
devInfo = devInfo_in;
deviceChanged.store(true);
}
@ -981,14 +980,14 @@ void AppFrame::handleUpdateDeviceParams() {
SoapySDR::Device *soapyDev = devInfo->getSoapyDevice();
// Build settings menu
wxMenu *newSettingsMenu = new wxMenu;
auto *newSettingsMenu = new wxMenu;
showTipMenuItem = newSettingsMenu->AppendCheckItem(wxID_SET_TIPS, "Show Hover Tips");
showTipMenuItem->Check(wxGetApp().getConfig()->getShowTips());
// CPU usage menu:
performanceMenuItems.clear();
wxMenu *subMenu = new wxMenu;
auto *subMenu = new wxMenu;
performanceMenuItems[wxID_PERF_BASE + (int)AppConfig::PERF_HIGH] = subMenu->AppendRadioItem(wxID_PERF_BASE + (int)AppConfig::PERF_HIGH, "High (+enhanced DSP)");
performanceMenuItems[wxID_PERF_BASE + (int)AppConfig::PERF_NORMAL] = subMenu->AppendRadioItem(wxID_PERF_BASE + (int)AppConfig::PERF_NORMAL, "Normal");
@ -1026,7 +1025,7 @@ void AppFrame::handleUpdateDeviceParams() {
}
agcMenuItem = nullptr;
if (soapyDev->listGains(SOAPY_SDR_RX, 0).size()) {
if (!soapyDev->listGains(SOAPY_SDR_RX, 0).empty()) {
agcMenuItem = newSettingsMenu->AppendCheckItem(wxID_AGC_CONTROL, "Automatic Gain");
agcMenuItem->Check(wxGetApp().getAGCMode());
} else if (!wxGetApp().getAGCMode()) {
@ -1044,11 +1043,11 @@ void AppFrame::handleUpdateDeviceParams() {
antennaNames = availableAntennas;
wxMenu *subMenu = new wxMenu;
auto *subMenu = new wxMenu;
int i = 0;
std::string antennaChecked;
for (std::string currentAntenna : availableAntennas) {
for (const std::string& currentAntenna : availableAntennas) {
antennaMenuItems[wxID_ANTENNAS_BASE + i] = subMenu->AppendRadioItem(wxID_ANTENNAS_BASE + i, currentAntenna);
@ -1083,7 +1082,7 @@ void AppFrame::handleUpdateDeviceParams() {
SoapySDR::ArgInfoList::const_iterator args_i;
settingArgs = soapyDev->getSettingInfo();
if (settingArgs.size()) {
if (!settingArgs.empty()) {
newSettingsMenu->AppendSeparator();
}
//for each Runtime option of index i:
@ -1105,16 +1104,16 @@ void AppFrame::handleUpdateDeviceParams() {
settingsMenuItems[wxID_SETTINGS_BASE + i] = newSettingsMenu->Append(wxID_SETTINGS_BASE + i, getSettingsLabel(arg.name, currentVal, arg.units), arg.description);
i++;
} else if (arg.type == SoapySDR::ArgInfo::STRING) {
if (arg.options.size()) {
wxMenu *subMenu = new wxMenu;
if (!arg.options.empty()) {
auto *subMenu = new wxMenu;
int j = 0;
std::vector<int> subItemsIds;
//for each of this options
for (std::string optName : arg.options) {
for (const std::string& optName : arg.options) {
//by default the option name is the same as the displayed name.
std::string displayName = optName;
if (arg.optionNames.size()) {
if (!arg.optionNames.empty()) {
displayName = arg.optionNames[j];
}
wxMenuItem *item = subMenu->AppendRadioItem(wxID_SETTINGS_BASE+i, displayName);
@ -1146,7 +1145,7 @@ void AppFrame::handleUpdateDeviceParams() {
sampleRates = devInfo->getSampleRates(SOAPY_SDR_RX, 0);
sampleRateMenuItems.clear();
wxMenu *newSampleRateMenu = new wxMenu;
auto *newSampleRateMenu = new wxMenu;
int ofs = 0;
//Current sample rate, try to keep it as is.
@ -1167,11 +1166,11 @@ void AppFrame::handleUpdateDeviceParams() {
}
bool checked = false;
for (vector<long>::iterator i = sampleRates.begin(); i != sampleRates.end(); i++) {
for (long & i : sampleRates) {
sampleRateMenuItems[wxID_BANDWIDTH_BASE+ofs] = newSampleRateMenu->AppendRadioItem(wxID_BANDWIDTH_BASE+ofs, frequencyToStr(*i));
sampleRateMenuItems[wxID_BANDWIDTH_BASE+ofs] = newSampleRateMenu->AppendRadioItem(wxID_BANDWIDTH_BASE+ofs, frequencyToStr(i));
if (sampleRate == (*i)) {
if (sampleRate == i) {
sampleRateMenuItems[wxID_BANDWIDTH_BASE+ofs]->Check(true);
checked = true;
}
@ -1262,11 +1261,11 @@ void AppFrame::disableRig() {
wxGetApp().getConfig()->setRigEnabled(false);
}
void AppFrame::setRigControlPort(std::string portName) {
void AppFrame::setRigControlPort(const std::string& portName) {
if (rigPortDialog == nullptr) {
return;
}
if (portName != "") {
if (!portName.empty()) {
rigPort = portName;
wxGetApp().stopRig();
@ -1321,7 +1320,7 @@ bool AppFrame::actionOnMenuDisplay(wxCommandEvent& event) {
if (event.GetId() == wxID_THEME_DEFAULT) {
ThemeMgr::mgr.setTheme(COLOR_THEME_DEFAULT);
}
else if (event.GetId() == wxID_THEME_DEFAULT_JET) {
else if (event.GetId() == wxID_THEME_DEFAULT_JET) {
ThemeMgr::mgr.setTheme(COLOR_THEME_DEFAULT_JET);
}
else if (event.GetId() == wxID_THEME_SHARP) {
@ -1437,8 +1436,8 @@ bool AppFrame::actionOnMenuAbout(wxCommandEvent& event) {
aboutDlg->SetFocus();
}
else {
aboutDlg = new AboutDialog(NULL);
aboutDlg->Connect(wxEVT_CLOSE_WINDOW, wxCommandEventHandler(AppFrame::OnAboutDialogClose), NULL, this);
aboutDlg = new AboutDialog(nullptr);
aboutDlg->Connect(wxEVT_CLOSE_WINDOW, wxCommandEventHandler(AppFrame::OnAboutDialogClose), nullptr, this);
aboutDlg->Show();
}
@ -1465,10 +1464,8 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
int setIdx = event.GetId() - wxID_SETTINGS_BASE;
int menuIdx = 0;
for (std::vector<SoapySDR::ArgInfo>::iterator arg_i = settingArgs.begin(); arg_i != settingArgs.end(); arg_i++) {
SoapySDR::ArgInfo &arg = (*arg_i);
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size() && setIdx >= menuIdx && setIdx < menuIdx + (int)arg.options.size()) {
for (auto & arg : settingArgs) {
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty() && setIdx >= menuIdx && setIdx < menuIdx + (int)arg.options.size()) {
int optIdx = setIdx - menuIdx;
wxGetApp().getSDRThread()->writeSetting(arg.key, arg.options[optIdx]);
@ -1476,7 +1473,7 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
settingsMenuItems[menuIdx + wxID_SETTINGS_BASE]->SetItemLabel(getSettingsLabel(arg.name, arg.options[optIdx], arg.units));
break;
}
else if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
else if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
menuIdx += arg.options.size();
}
else if (menuIdx == setIdx) {
@ -1489,7 +1486,7 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
settingsMenuItems[menuIdx + wxID_SETTINGS_BASE]->SetItemLabel(getSettingsLabel(arg.name, stringVal.ToStdString(), arg.units));
if (stringVal.ToStdString() != "") {
if (!stringVal.ToStdString().empty()) {
wxGetApp().getSDRThread()->writeSetting(arg.key, stringVal.ToStdString());
}
break;
@ -1499,7 +1496,7 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
try {
currentVal = std::stoi(wxGetApp().getSDRThread()->readSetting(arg.key));
}
catch (std::invalid_argument e) {
catch (const std::invalid_argument &) {
currentVal = 0;
}
int intVal = wxGetNumberFromUser(arg.description, arg.units, arg.name, currentVal, arg.range.minimum(), arg.range.maximum(), this);
@ -1516,7 +1513,7 @@ bool AppFrame::actionOnMenuSettings(wxCommandEvent& event) {
try {
wxGetApp().getSDRThread()->writeSetting(arg.key, floatVal.ToStdString());
}
catch (std::invalid_argument e) {
catch (const std::invalid_argument &) {
// ...
}
settingsMenuItems[menuIdx + wxID_SETTINGS_BASE]->SetItemLabel(getSettingsLabel(arg.name, floatVal.ToStdString(), arg.units));
@ -1541,7 +1538,7 @@ bool AppFrame::actionOnMenuAGC(wxCommandEvent& event) {
if (event.GetId() == wxID_AGC_CONTROL) {
if (wxGetApp().getDevice() == NULL) {
if (wxGetApp().getDevice() == nullptr) {
agcMenuItem->Check(true);
return true;
}
@ -1582,15 +1579,15 @@ bool AppFrame::actionOnMenuSampleRate(wxCommandEvent& event) {
SDRDeviceInfo *dev = wxGetApp().getDevice();
if (dev != nullptr) {
std::vector<long> sampleRates = dev->getSampleRates(SOAPY_SDR_RX, 0);
std::vector<long> sampleRateList = dev->getSampleRates(SOAPY_SDR_RX, 0);
//default
rateLow = MANUAL_SAMPLE_RATE_MIN;
rateHigh = MANUAL_SAMPLE_RATE_MAX;
if (sampleRates.size()) {
rateLow = sampleRates.front();
rateHigh = sampleRates.back();
if (!sampleRateList.empty()) {
rateLow = sampleRateList.front();
rateHigh = sampleRateList.back();
}
long bw = wxGetNumberFromUser("\n" + dev->getName() + "\n\n "
@ -1635,17 +1632,17 @@ bool AppFrame::actionOnMenuAudioSampleRate(wxCommandEvent& event) {
auto outputDevices = wxGetApp().getDemodMgr().getOutputDevices();
int i = 0;
for (auto mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
for (auto & outputDevice : outputDevices) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * outputDevice.first;
int j = 0;
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
for (auto srate = outputDevice.second.sampleRates.begin(); srate != outputDevice.second.sampleRates.end();
srate++) {
if (evId == menu_id + j) {
//audioSampleRateMenuItems[menu_id+j];
//std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl;
AudioThread::setDeviceSampleRate(mdevices_i->first, *srate);
AudioThread::setDeviceSampleRate(outputDevice.first, *srate);
return true;
}
@ -1696,7 +1693,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
}
//save mecanic for bookmark files
else if (event.GetId() == wxID_SAVE_BOOKMARKS) {
else if (event.GetId() == wxID_SAVE_BOOKMARKS) {
if (!currentBookmarkFile.empty()) {
wxGetApp().getBookmarkMgr().saveToFile(currentBookmarkFile, false, true);
@ -1723,7 +1720,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
return true;
}
else if (event.GetId() == wxID_OPEN_BOOKMARKS) {
else if (event.GetId() == wxID_OPEN_BOOKMARKS) {
wxFileDialog openFileDialog(this, _("Open XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() == wxID_CANCEL) {
@ -1743,7 +1740,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
return true;
}
else if (event.GetId() == wxID_SAVEAS_BOOKMARKS) {
else if (event.GetId() == wxID_SAVEAS_BOOKMARKS) {
wxFileDialog saveFileDialog(this, _("Save XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_CANCEL) {
@ -1765,7 +1762,7 @@ bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) {
return true;
}
else if (event.GetId() == wxID_RESET_BOOKMARKS) {
else if (event.GetId() == wxID_RESET_BOOKMARKS) {
ActionDialog::showDialog(new ActionDialogBookmarkReset());
@ -2271,7 +2268,7 @@ void AppFrame::handleModemProperties() {
modemProps->fitColumns();
#if ENABLE_DIGITAL_LAB
if (demod->getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *) demod->getOutput();
auto *outp = (ModemDigitalOutputConsole *) demod->getOutput();
if (!outp->getDialog()) {
outp->setTitle(demod->getDemodulatorType() + ": " + frequencyToStr(demod->getFrequency()));
outp->setDialog(new DigitalConsole(this, outp));
@ -2404,14 +2401,14 @@ void AppFrame::handleModeSelector() {
string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
// basic demodulators
if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) {
if (!dSelection.empty() && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelection));
demodTuner->setHalfBand(dSelection == "USB" || dSelection == "LSB");
demodModeSelectorAdv->setSelection(-1);
}
// advanced demodulators
else if (dSelectionadv != "" && dSelectionadv != mgr->getLastDemodulatorType()) {
else if (!dSelectionadv.empty() && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelectionadv));
demodTuner->setHalfBand(false);
@ -2507,13 +2504,13 @@ void AppFrame::handleCurrentModem() {
string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
// basic demodulators
if (dSelection != "" && dSelection != demod->getDemodulatorType()) {
if (!dSelection.empty() && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection);
demodTuner->setHalfBand(dSelection == "USB" || dSelection == "LSB");
demodModeSelectorAdv->setSelection(-1);
}
// advanced demodulators
else if (dSelectionadv != "" && dSelectionadv != demod->getDemodulatorType()) {
else if (!dSelectionadv.empty() && dSelectionadv != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelectionadv);
demodTuner->setHalfBand(false);
demodModeSelector->setSelection(-1);
@ -2609,7 +2606,7 @@ void AppFrame::handleCurrentModem() {
void AppFrame::OnDoubleClickSash(wxSplitterEvent& event)
{
wxWindow *a, *b;
wxSplitterWindow *w = NULL;
wxSplitterWindow *w = nullptr;
float g = 0.5;
if (event.GetId() == wxID_MAIN_SPLITTER) {
@ -2620,7 +2617,7 @@ void AppFrame::OnDoubleClickSash(wxSplitterEvent& event)
g = 6.0f/25.0f;
}
if (w != NULL) {
if (w != nullptr) {
a = w->GetWindow1();
b = w->GetWindow2();
w->Unsplit();
@ -2643,7 +2640,7 @@ void AppFrame::OnAboutDialogClose(wxCommandEvent& /* event */) {
aboutDlg = nullptr;
}
void AppFrame::saveSession(std::string fileName) {
void AppFrame::saveSession(const std::string& fileName) {
wxGetApp().getSessionMgr().saveSession(fileName);
currentSessionFile = fileName;
@ -2659,7 +2656,7 @@ void AppFrame::saveSession(std::string fileName) {
SetTitle(titleBar);
}
bool AppFrame::loadSession(std::string fileName) {
bool AppFrame::loadSession(const std::string& fileName) {
bool result = wxGetApp().getSessionMgr().loadSession(fileName);
int sample_rate = wxGetApp().getSampleRate();
@ -2794,7 +2791,7 @@ FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() {
return target;
}
void AppFrame::gkNudge(DemodulatorInstancePtr demod, int snap) {
void AppFrame::gkNudge(const DemodulatorInstancePtr& demod, int snap) {
if (demod) {
auto demodFreq = demod->getFrequency()+snap;
auto demodBw = demod->getBandwidth();
@ -3114,14 +3111,14 @@ void AppFrame::toggleAllActiveDemodRecording() {
//by default, do a false => true for all:
bool stateToSet = true;
for (auto i : allDemods) {
for (const auto& i : allDemods) {
if (i->isRecording()) {
stateToSet = false;
break;
}
}
for (auto i : allDemods) {
for (const auto& i : allDemods) {
i->setRecording(stateToSet);
}
@ -3161,7 +3158,7 @@ int AppFrame::getViewBandwidth() {
}
void AppFrame::setStatusText(wxWindow* window, std::string statusText) {
void AppFrame::setStatusText(wxWindow* window, const std::string& statusText) {
GetStatusBar()->SetStatusText(statusText);
if (wxGetApp().getConfig()->getShowTips()) {
if (statusText != lastToolTip) {
@ -3178,7 +3175,7 @@ void AppFrame::setStatusText(wxWindow* window, std::string statusText) {
}
}
void AppFrame::setStatusText(std::string statusText, int value) {
void AppFrame::setStatusText(const std::string& statusText, int value) {
GetStatusBar()->SetStatusText(
wxString::Format(statusText.c_str(), wxNumberFormatter::ToString((long)value, wxNumberFormatter::Style_WithThousandsSep)));
}

View File

@ -40,9 +40,9 @@ class PortSelectorDialog;
class AppFrame: public wxFrame {
public:
AppFrame();
~AppFrame();
~AppFrame() override;
void initDeviceParams(SDRDeviceInfo *devInfo);
void initDeviceParams(SDRDeviceInfo *devInfo_in);
FFTVisualDataThread *getWaterfallDataThread();
WaterfallCanvas *getWaterfallCanvas();
@ -80,12 +80,12 @@ public:
bool canFocus();
#endif
//set tooltip to window
void setStatusText(wxWindow* window, std::string statusText);
void setStatusText(std::string statusText, int value);
void setStatusText(wxWindow* window, const std::string& statusText);
void setStatusText(const std::string& statusText, int value);
#ifdef USE_HAMLIB
void setRigControlPort(std::string portName);
void setRigControlPort(const std::string& portName);
void dismissRigControlPortDialog();
#endif
@ -192,13 +192,13 @@ private:
/**
* Session Management
*/
void saveSession(std::string fileName);
bool loadSession(std::string fileName);
void saveSession(const std::string& fileName);
bool loadSession(const std::string& fileName);
/**
* Keyboard handlers
*/
void gkNudge(DemodulatorInstancePtr demod, int snap);
void gkNudge(const DemodulatorInstancePtr& demod, int snap);
void toggleActiveDemodRecording();
void toggleAllActiveDemodRecording();

View File

@ -4,7 +4,6 @@
#include "BookmarkMgr.h"
#include "CubicSDR.h"
#include "DataTree.h"
#include <wx/string.h>
#define BOOKMARK_RECENTS_MAX 25
@ -16,7 +15,7 @@ BookmarkMgr::BookmarkMgr() {
rangesSorted = false;
}
//
void BookmarkMgr::saveToFile(std::string bookmarkFn, bool backup, bool useFullpath) {
void BookmarkMgr::saveToFile(const std::string& bookmarkFn, bool backup, bool useFullpath) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
@ -33,7 +32,7 @@ void BookmarkMgr::saveToFile(std::string bookmarkFn, bool backup, bool useFullpa
DataNode *view_ranges = s.rootNode()->newChild("ranges");
for (auto re_i : ranges) {
for (const auto& re_i : ranges) {
DataNode *range = view_ranges->newChild("range");
*range->newChild("label") = re_i->label;
*range->newChild("freq") = re_i->freq;
@ -69,7 +68,7 @@ void BookmarkMgr::saveToFile(std::string bookmarkFn, bool backup, bool useFullpa
DataNode *recent_modems = s.rootNode()->newChild("recent_modems");
for (auto demod : wxGetApp().getDemodMgr().getDemodulators()) {
for (const auto& demod : wxGetApp().getDemodMgr().getDemodulators()) {
wxGetApp().getDemodMgr().saveInstance(recent_modems->newChild("modem"),demod);
}
@ -98,7 +97,7 @@ void BookmarkMgr::saveToFile(std::string bookmarkFn, bool backup, bool useFullpa
}
}
bool BookmarkMgr::loadFromFile(std::string bookmarkFn, bool backup, bool useFullpath) {
bool BookmarkMgr::loadFromFile(const std::string& bookmarkFn, bool backup, bool useFullpath) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
@ -157,10 +156,10 @@ bool BookmarkMgr::loadFromFile(std::string bookmarkFn, bool backup, bool useFull
if (branches->hasAnother("range")) branches->getNext("range")->element()->get(bRange);
if (branches->hasAnother("bookmark")) branches->getNext("bookmark")->element()->get(bBookmark);
if (branches->hasAnother("recent")) branches->getNext("recent")->element()->get(bRecent);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("active", bActive?true:false);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("range", bRange?true:false);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("bookmark", bBookmark?true:false);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("recent", bRecent?true:false);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("active", bActive != 0);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("range", bRange != 0);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("bookmark", bBookmark != 0);
wxGetApp().getAppFrame()->getBookmarkView()->setExpandState("recent", bRecent != 0);
}
if (s.rootNode()->hasAnother("ranges")) {
@ -183,20 +182,20 @@ bool BookmarkMgr::loadFromFile(std::string bookmarkFn, bool backup, bool useFull
DataNode *modems = s.rootNode()->getNext("modems");
while (modems->hasAnother("group")) {
DataNode *group = modems->getNext("group");
std::string expandState = "true";
std::string groupExpandState = "true";
std::string groupName = "Unnamed";
if (group->hasAnother("@name")) {
groupName = group->getNext("@name")->element()->toString();
}
if (group->hasAnother("@expanded")) {
expandState = group->getNext("@expanded")->element()->toString();
groupExpandState = group->getNext("@expanded")->element()->toString();
}
setExpandState(groupName, (expandState == "true"));
setExpandState(groupName, (groupExpandState == "true"));
while (group->hasAnother("modem")) {
DataNode *modem = group->getNext("modem");
BookmarkEntryPtr be = nodeToBookmark(modem);
if (be) {
addBookmark(groupName.c_str(), be);
addBookmark(groupName, be);
} else {
std::cout << "error loading bookmarked modem.." << std::endl;
loadStatusOk = false;
@ -227,7 +226,7 @@ bool BookmarkMgr::loadFromFile(std::string bookmarkFn, bool backup, bool useFull
wxCopyFile(loadFile.GetFullPath(wxPATH_NATIVE).ToStdString(), lastLoaded.GetFullPath(wxPATH_NATIVE).ToStdString());
}
}
} else if (!loadStatusOk) {
} else {
if (loadFile.IsDirWritable()) { // Load failed; keep a copy of the failed bookmark file for analysis?
if (loadFile.FileExists() && (!failFile.FileExists() || failFile.IsFileWritable())) {
wxCopyFile(loadFile.GetFullPath(wxPATH_NATIVE).ToStdString(), failFile.GetFullPath(wxPATH_NATIVE).ToStdString());
@ -278,17 +277,17 @@ void BookmarkMgr::resetBookmarks() {
}
bool BookmarkMgr::hasLastLoad(std::string bookmarkFn) {
bool BookmarkMgr::hasLastLoad(const std::string& bookmarkFn) {
wxFileName lastLoaded(wxGetApp().getConfig()->getConfigDir(), bookmarkFn + ".lastloaded");
return lastLoaded.FileExists() && lastLoaded.IsFileReadable();
}
bool BookmarkMgr::hasBackup(std::string bookmarkFn) {
bool BookmarkMgr::hasBackup(const std::string& bookmarkFn) {
wxFileName backupFile(wxGetApp().getConfig()->getConfigDir(), bookmarkFn + ".backup");
return backupFile.FileExists() && backupFile.IsFileReadable();
}
void BookmarkMgr::addBookmark(std::string group, DemodulatorInstancePtr demod) {
void BookmarkMgr::addBookmark(const std::string& group, const DemodulatorInstancePtr& demod) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
//Create a BookmarkEntry from demod data, saving its
@ -299,7 +298,7 @@ void BookmarkMgr::addBookmark(std::string group, DemodulatorInstancePtr demod) {
bmDataSorted[group] = false;
}
void BookmarkMgr::addBookmark(std::string group, BookmarkEntryPtr be) {
void BookmarkMgr::addBookmark(const std::string& group, const BookmarkEntryPtr& be) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
bmData[group].push_back(be);
@ -307,14 +306,14 @@ void BookmarkMgr::addBookmark(std::string group, BookmarkEntryPtr be) {
}
void BookmarkMgr::removeBookmark(std::string group, BookmarkEntryPtr be) {
void BookmarkMgr::removeBookmark(const std::string& group, const BookmarkEntryPtr& be) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
if (bmData.find(group) == bmData.end()) {
return;
}
BookmarkList::iterator i = std::find(bmData[group].begin(), bmData[group].end(), be);
auto i = std::find(bmData[group].begin(), bmData[group].end(), be);
if (i != bmData[group].end()) {
@ -322,22 +321,22 @@ void BookmarkMgr::removeBookmark(std::string group, BookmarkEntryPtr be) {
}
}
void BookmarkMgr::removeBookmark(BookmarkEntryPtr be) {
void BookmarkMgr::removeBookmark(const BookmarkEntryPtr& be) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
for (auto &bmd_i : bmData) {
BookmarkList::iterator i = std::find(bmd_i.second.begin(), bmd_i.second.end(), be);
auto i = std::find(bmd_i.second.begin(), bmd_i.second.end(), be);
if (i != bmd_i.second.end()) {
bmd_i.second.erase(i);
}
}
}
void BookmarkMgr::moveBookmark(BookmarkEntryPtr be, std::string group) {
void BookmarkMgr::moveBookmark(const BookmarkEntryPtr& be, const std::string& group) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
for (auto &bmd_i : bmData) {
BookmarkList::iterator i = std::find(bmd_i.second.begin(), bmd_i.second.end(), be);
auto i = std::find(bmd_i.second.begin(), bmd_i.second.end(), be);
if (i != bmd_i.second.end()) {
if (bmd_i.first == group) {
return;
@ -352,7 +351,7 @@ void BookmarkMgr::moveBookmark(BookmarkEntryPtr be, std::string group) {
}
void BookmarkMgr::addGroup(std::string group) {
void BookmarkMgr::addGroup(const std::string& group) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
if (bmData.find(group) == bmData.end()) {
@ -360,10 +359,10 @@ void BookmarkMgr::addGroup(std::string group) {
}
}
void BookmarkMgr::removeGroup(std::string group) {
void BookmarkMgr::removeGroup(const std::string& group) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
BookmarkMap::iterator i = bmData.find(group);
auto i = bmData.find(group);
if (i != bmData.end()) {
@ -371,18 +370,18 @@ void BookmarkMgr::removeGroup(std::string group) {
}
}
void BookmarkMgr::renameGroup(std::string group, std::string ngroup) {
void BookmarkMgr::renameGroup(const std::string& group, const std::string& ngroup) {
if (group == ngroup) {
return;
}
std::lock_guard < std::recursive_mutex > lock(busy_lock);
BookmarkMap::iterator i = bmData.find(group);
BookmarkMap::iterator it = bmData.find(ngroup);
auto i = bmData.find(group);
auto it = bmData.find(ngroup);
if (i != bmData.end() && it != bmData.end()) {
for (auto ii : bmData[group]) {
for (const auto& ii : bmData[group]) {
bmData[ngroup].push_back(ii);
}
bmData.erase(group);
@ -392,7 +391,7 @@ void BookmarkMgr::renameGroup(std::string group, std::string ngroup) {
}
}
BookmarkList BookmarkMgr::getBookmarks(std::string group) {
BookmarkList BookmarkMgr::getBookmarks(const std::string& group) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
if (bmData.find(group) == bmData.end()) {
@ -411,28 +410,28 @@ BookmarkList BookmarkMgr::getBookmarks(std::string group) {
void BookmarkMgr::getGroups(BookmarkNames &arr) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
for (BookmarkMap::iterator i = bmData.begin(); i!= bmData.end(); ++i) {
arr.push_back(i->first);
for (auto & i : bmData) {
arr.push_back(i.first);
}
}
void BookmarkMgr::getGroups(wxArrayString &arr) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
for (BookmarkMap::iterator i = bmData.begin(); i!= bmData.end(); ++i) {
arr.push_back(i->first);
for (auto & i : bmData) {
arr.push_back(i.first);
}
}
void BookmarkMgr::setExpandState(std::string groupName, bool state) {
void BookmarkMgr::setExpandState(const std::string& groupName, bool state) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
expandState[groupName] = state;
}
bool BookmarkMgr::getExpandState(std::string groupName) {
bool BookmarkMgr::getExpandState(const std::string& groupName) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
@ -465,7 +464,7 @@ void BookmarkMgr::updateBookmarks() {
}
}
void BookmarkMgr::updateBookmarks(std::string group) {
void BookmarkMgr::updateBookmarks(const std::string& group) {
BookmarkView *bmv = wxGetApp().getAppFrame()->getBookmarkView();
@ -475,7 +474,7 @@ void BookmarkMgr::updateBookmarks(std::string group) {
}
void BookmarkMgr::addRecent(DemodulatorInstancePtr demod) {
void BookmarkMgr::addRecent(const DemodulatorInstancePtr& demod) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
recents.push_back(demodToBookmarkEntry(demod));
@ -483,7 +482,7 @@ void BookmarkMgr::addRecent(DemodulatorInstancePtr demod) {
trimRecents();
}
void BookmarkMgr::addRecent(BookmarkEntryPtr be) {
void BookmarkMgr::addRecent(const BookmarkEntryPtr& be) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
recents.push_back(be);
@ -493,10 +492,10 @@ void BookmarkMgr::addRecent(BookmarkEntryPtr be) {
void BookmarkMgr::removeRecent(BookmarkEntryPtr be) {
void BookmarkMgr::removeRecent(const BookmarkEntryPtr& be) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
BookmarkList::iterator bm_i = std::find(recents.begin(),recents.end(), be);
auto bm_i = std::find(recents.begin(),recents.end(), be);
if (bm_i != recents.end()) {
recents.erase(bm_i);
@ -526,17 +525,17 @@ void BookmarkMgr::trimRecents() {
}
void BookmarkMgr::addRange(BookmarkRangeEntryPtr re) {
void BookmarkMgr::addRange(const BookmarkRangeEntryPtr& re) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
ranges.push_back(re);
rangesSorted = false;
}
void BookmarkMgr::removeRange(BookmarkRangeEntryPtr re) {
void BookmarkMgr::removeRange(const BookmarkRangeEntryPtr& re) {
std::lock_guard < std::recursive_mutex > lock(busy_lock);
BookmarkRangeList::iterator re_i = std::find(ranges.begin(), ranges.end(), re);
auto re_i = std::find(ranges.begin(), ranges.end(), re);
if (re_i != ranges.end()) {
@ -564,7 +563,7 @@ void BookmarkMgr::clearRanges() {
}
BookmarkEntryPtr BookmarkMgr::demodToBookmarkEntry(DemodulatorInstancePtr demod) {
BookmarkEntryPtr BookmarkMgr::demodToBookmarkEntry(const DemodulatorInstancePtr& demod) {
BookmarkEntryPtr be(new BookmarkEntry);
@ -583,7 +582,7 @@ BookmarkEntryPtr BookmarkMgr::demodToBookmarkEntry(DemodulatorInstancePtr demod)
std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string& childNodeName) {
std::wstring decodedWString = L"";
std::wstring decodedWString;
if (node != nullptr) {
@ -593,7 +592,7 @@ std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string&
try {
childNode->element()->get(decodedWString);
} catch (DataTypeMismatchException e) {
} catch (const DataTypeMismatchException &) {
//2) wstring decode fail, try simple std::string
std::string decodedStdString;
try {
@ -603,7 +602,7 @@ std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string&
//use wxString for a clean conversion to a wstring:
decodedWString = wxString(decodedStdString).ToStdWstring();
} catch (DataTypeMismatchException e) {
} catch (const DataTypeMismatchException &) {
//nothing works, return an empty string.
decodedWString = L"";
}
@ -639,10 +638,10 @@ BookmarkEntryPtr BookmarkMgr::nodeToBookmark(DataNode *node) {
}
std::wstring BookmarkMgr::getBookmarkEntryDisplayName(BookmarkEntryPtr bmEnt) {
std::wstring BookmarkMgr::getBookmarkEntryDisplayName(const BookmarkEntryPtr& bmEnt) {
std::wstring dispName = bmEnt->label;
if (dispName == L"") {
if (dispName.empty()) {
std::string freqStr = frequencyToStr(bmEnt->frequency) + " " + bmEnt->type;
dispName = wxString(freqStr).ToStdWstring();
@ -651,10 +650,10 @@ std::wstring BookmarkMgr::getBookmarkEntryDisplayName(BookmarkEntryPtr bmEnt) {
return dispName;
}
std::wstring BookmarkMgr::getActiveDisplayName(DemodulatorInstancePtr demod) {
std::wstring BookmarkMgr::getActiveDisplayName(const DemodulatorInstancePtr& demod) {
std::wstring activeName = demod->getDemodulatorUserLabel();
if (activeName == L"") {
if (activeName.empty()) {
std::string wstr = frequencyToStr(demod->getFrequency()) + " " + demod->getDemodulatorType();
activeName = wxString(wstr).ToStdWstring();
@ -663,7 +662,7 @@ std::wstring BookmarkMgr::getActiveDisplayName(DemodulatorInstancePtr demod) {
return activeName;
}
void BookmarkMgr::removeActive(DemodulatorInstancePtr demod) {
void BookmarkMgr::removeActive(const DemodulatorInstancePtr& demod) {
if (demod == nullptr) {
return;

View File

@ -32,7 +32,7 @@ public:
class BookmarkRangeEntry {
public:
BookmarkRangeEntry() : label(L""), freq(0), startFreq(0), endFreq(0) {
BookmarkRangeEntry() : freq(0), startFreq(0), endFreq(0) {
}
BookmarkRangeEntry(std::wstring label, long long freq, long long startFreq, long long endFreq) : label(label), freq(freq), startFreq(startFreq), endFreq(endFreq) {
@ -60,57 +60,57 @@ public:
BookmarkMgr();
//if useFullpath = false, use the application config dir.
//else assume bookmarkFn is a full path and use it for location.
void saveToFile(std::string bookmarkFn, bool backup = true, bool useFullpath = false);
bool loadFromFile(std::string bookmarkFn, bool backup = true, bool useFullpath = false);
void saveToFile(const std::string& bookmarkFn, bool backup = true, bool useFullpath = false);
bool loadFromFile(const std::string& bookmarkFn, bool backup = true, bool useFullpath = false);
void resetBookmarks();
bool hasLastLoad(std::string bookmarkFn);
bool hasBackup(std::string bookmarkFn);
bool hasLastLoad(const std::string& bookmarkFn);
bool hasBackup(const std::string& bookmarkFn);
void addBookmark(std::string group, DemodulatorInstancePtr demod);
void addBookmark(std::string group, BookmarkEntryPtr be);
void removeBookmark(std::string group, BookmarkEntryPtr be);
void removeBookmark(BookmarkEntryPtr be);
void moveBookmark(BookmarkEntryPtr be, std::string group);
void addBookmark(const std::string& group, const DemodulatorInstancePtr& demod);
void addBookmark(const std::string& group, const BookmarkEntryPtr& be);
void removeBookmark(const std::string& group, const BookmarkEntryPtr& be);
void removeBookmark(const BookmarkEntryPtr& be);
void moveBookmark(const BookmarkEntryPtr& be, const std::string& group);
void addGroup(std::string group);
void removeGroup(std::string group);
void renameGroup(std::string group, std::string ngroup);
void addGroup(const std::string& group);
void removeGroup(const std::string& group);
void renameGroup(const std::string& group, const std::string& ngroup);
//return an independent copy on purpose
BookmarkList getBookmarks(std::string group);
BookmarkList getBookmarks(const std::string& group);
void getGroups(BookmarkNames &arr);
void getGroups(wxArrayString &arr);
void setExpandState(std::string groupName, bool state);
bool getExpandState(std::string groupName);
void setExpandState(const std::string& groupName, bool state);
bool getExpandState(const std::string& groupName);
void updateActiveList();
void updateBookmarks();
void updateBookmarks(std::string group);
void updateBookmarks(const std::string& group);
void addRecent(DemodulatorInstancePtr demod);
void addRecent(BookmarkEntryPtr be);
void removeRecent(BookmarkEntryPtr be);
void addRecent(const DemodulatorInstancePtr& demod);
void addRecent(const BookmarkEntryPtr& be);
void removeRecent(const BookmarkEntryPtr& be);
//return an independent copy on purpose
BookmarkList getRecents();
void clearRecents();
void removeActive(DemodulatorInstancePtr demod);
void removeActive(const DemodulatorInstancePtr& demod);
void addRange(BookmarkRangeEntryPtr re);
void removeRange(BookmarkRangeEntryPtr re);
void addRange(const BookmarkRangeEntryPtr& re);
void removeRange(const BookmarkRangeEntryPtr& re);
//return an independent copy on purpose
BookmarkRangeList getRanges();
void clearRanges();
static std::wstring getBookmarkEntryDisplayName(BookmarkEntryPtr bmEnt);
static std::wstring getActiveDisplayName(DemodulatorInstancePtr demod);
static std::wstring getBookmarkEntryDisplayName(const BookmarkEntryPtr& bmEnt);
static std::wstring getActiveDisplayName(const DemodulatorInstancePtr& demod);
protected:
@ -122,7 +122,7 @@ protected:
//return an empty string.
static std::wstring getSafeWstringValue(DataNode* node, const std::string& childNodeName);
BookmarkEntryPtr demodToBookmarkEntry(DemodulatorInstancePtr demod);
BookmarkEntryPtr demodToBookmarkEntry(const DemodulatorInstancePtr& demod);
BookmarkEntryPtr nodeToBookmark(DataNode *node);
BookmarkMap bmData;

View File

@ -81,7 +81,7 @@ std::string frequencyToStr(long long freq) {
long double freqTemp;
freqTemp = freq;
std::string suffix("");
std::string suffix;
std::stringstream freqStr;
if (freqTemp >= 1.0e9) {
@ -133,7 +133,7 @@ long long strToFrequency(std::string freqStr) {
} else if (suffixStr.find_first_of("Hh") != std::string::npos) {
// ...
}
} else if (numPartStr.find_first_of(".") != std::string::npos || freqTemp <= 3000) {
} else if (numPartStr.find_first_of('.') != std::string::npos || freqTemp <= 3000) {
freqTemp *= 1.0e6;
}
@ -148,7 +148,7 @@ public:
m_questionText->SetLabelText(wxT("All attempts to recover bookmarks have failed. \nWould you like to exit without touching any more save files?\nClick OK to exit without saving; or Cancel to continue anyways."));
}
void doClickOK() {
void doClickOK() override {
wxGetApp().getAppFrame()->disableSave(true);
wxGetApp().getAppFrame()->Close(false);
}
@ -162,7 +162,7 @@ public:
m_questionText->SetLabelText(wxT("Sorry; unable to load your bookmarks backup file. \nWould you like to attempt to load the last succssfully loaded bookmarks file?"));
}
void doClickOK() {
void doClickOK() override {
if (wxGetApp().getBookmarkMgr().hasLastLoad("bookmarks.xml")) {
if (wxGetApp().getBookmarkMgr().loadFromFile("bookmarks.xml.lastloaded",false)) {
wxGetApp().getBookmarkMgr().updateBookmarks();
@ -181,7 +181,7 @@ public:
m_questionText->SetLabelText(wxT("Sorry; unable to load your bookmarks file. \nWould you like to attempt to load the backup file?"));
}
void doClickOK() {
void doClickOK() override {
bool loadOk = false;
if (wxGetApp().getBookmarkMgr().hasBackup("bookmarks.xml")) {
loadOk = wxGetApp().getBookmarkMgr().loadFromFile("bookmarks.xml.backup",false);
@ -201,11 +201,11 @@ public:
class ActionDialogRigError : public ActionDialog {
public:
ActionDialogRigError(std::string message) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Rig Control Error")) {
explicit ActionDialogRigError(const std::string& message) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Rig Control Error")) {
m_questionText->SetLabelText(message);
}
void doClickOK() {
void doClickOK() override {
}
};
@ -238,12 +238,12 @@ void CubicSDR::initAudioDevices() const {
int i = 0;
for (auto devices_i = devices.begin(); devices_i != devices.end(); devices_i++) {
if (devices_i->inputChannels) {
inputDevices[i] = *devices_i;
for (auto & device : devices) {
if (device.inputChannels) {
inputDevices[i] = device;
}
if (devices_i->outputChannels) {
outputDevices[i] = *devices_i;
if (device.outputChannels) {
outputDevices[i] = device;
}
i++;
}
@ -541,7 +541,7 @@ int CubicSDR::OnExit() {
PrimaryGLContext& CubicSDR::GetContext(wxGLCanvas *canvas) {
PrimaryGLContext *glContext;
if (!m_glContext) {
m_glContext = new PrimaryGLContext(canvas, NULL, GetContextAttributes());
m_glContext = new PrimaryGLContext(canvas, nullptr, GetContextAttributes());
}
glContext = m_glContext;
@ -559,9 +559,9 @@ void CubicSDR::OnInitCmdLine(wxCmdLineParser& parser) {
}
bool CubicSDR::OnCmdLineParsed(wxCmdLineParser& parser) {
wxString *confName = new wxString;
auto *confName = new wxString;
if (parser.Found("c",confName)) {
if (confName) {
if (!confName->empty()) {
config.setConfigName(confName->ToStdString());
}
}
@ -576,10 +576,10 @@ bool CubicSDR::OnCmdLineParsed(wxCmdLineParser& parser) {
useLocalMod.store(true);
#endif
wxString *modPath = new wxString;
auto *modPath = new wxString;
if (parser.Found("m",modPath)) {
if (modPath) {
if (!modPath->empty()) {
modulePath = modPath->ToStdString();
} else {
modulePath = "";
@ -611,17 +611,17 @@ void CubicSDR::deviceSelector() {
deviceSelectorDialog->Show();
}
void CubicSDR::addRemote(std::string remoteAddr) {
void CubicSDR::addRemote(const std::string& remoteAddr) {
SDREnumerator::addRemote(remoteAddr);
devicesReady.store(false);
t_SDREnum = new std::thread(&SDREnumerator::threadMain, sdrEnum);
}
void CubicSDR::removeRemote(std::string remoteAddr) {
void CubicSDR::removeRemote(const std::string& remoteAddr) {
SDREnumerator::removeRemote(remoteAddr);
}
void CubicSDR::sdrThreadNotify(SDRThread::SDRThreadState state, std::string message) {
void CubicSDR::sdrThreadNotify(SDRThread::SDRThreadState state, const std::string& message) {
std::lock_guard < std::mutex > lock(notify_busy);
@ -912,7 +912,7 @@ long long CubicSDR::getSampleRate() {
return sampleRate;
}
void CubicSDR::removeDemodulator(DemodulatorInstancePtr demod) {
void CubicSDR::removeDemodulator(const DemodulatorInstancePtr& demod) {
if (!demod) {
return;
}
@ -949,7 +949,7 @@ int CubicSDR::getPPM() {
return ppm;
}
void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode, wxString initString) {
void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode, const wxString& initString) {
const wxString demodTitle("Set Demodulator Frequency");
const wxString freqTitle("Set Center Frequency");
const wxString bwTitle("Modem Bandwidth (150Hz - 500KHz)");
@ -976,7 +976,7 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
break;
case FrequencyDialog::FDIALOG_TARGET_GAIN:
title = gainTitle;
if (wxGetApp().getActiveGainEntry() == "") {
if (wxGetApp().getActiveGainEntry().empty()) {
return;
}
break;
@ -1005,11 +1005,11 @@ AppFrame *CubicSDR::getAppFrame() {
return appframe;
}
void CubicSDR::setFrequencySnap(int snap) {
if (snap > 1000000) {
snap = 1000000;
void CubicSDR::setFrequencySnap(int snap_in) {
if (snap_in > 1000000) {
snap_in = 1000000;
}
this->snap = snap;
this->snap = snap_in;
}
int CubicSDR::getFrequencySnap() {
@ -1065,11 +1065,11 @@ bool CubicSDR::getAGCMode() {
}
void CubicSDR::setGain(std::string name, float gain_in) {
void CubicSDR::setGain(const std::string& name, float gain_in) {
sdrThread->setGain(name,gain_in);
}
float CubicSDR::getGain(std::string name) {
float CubicSDR::getGain(const std::string& name) {
return sdrThread->getGain(name);
}

View File

@ -75,14 +75,14 @@ public:
PrimaryGLContext &GetContext(wxGLCanvas *canvas);
wxGLContextAttrs* GetContextAttributes();
virtual bool OnInit();
virtual int OnExit();
bool OnInit() override;
int OnExit() override;
virtual void OnInitCmdLine(wxCmdLineParser& parser);
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
void OnInitCmdLine(wxCmdLineParser& parser) override;
bool OnCmdLineParsed(wxCmdLineParser& parser) override;
void deviceSelector();
void sdrThreadNotify(SDRThread::SDRThreadState state, std::string message);
void sdrThreadNotify(SDRThread::SDRThreadState state, const std::string& message);
void sdrEnumThreadNotify(SDREnumerator::SDREnumState state, std::string message);
void setFrequency(long long freq);
@ -128,9 +128,9 @@ public:
void notifyDemodulatorsChanged();
void removeDemodulator(DemodulatorInstancePtr demod);
void removeDemodulator(const DemodulatorInstancePtr& demod);
void setFrequencySnap(int snap);
void setFrequencySnap(int snap_in);
int getFrequencySnap();
AppConfig *getConfig();
@ -139,7 +139,7 @@ public:
void setPPM(int ppm_in);
int getPPM();
void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, wxString initString = "");
void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, const wxString& initString = "");
void showLabelInput();
AppFrame *getAppFrame();
@ -150,8 +150,8 @@ public:
void notifyMainUIOfDeviceChange(bool forceRefreshOfGains = false);
void addRemote(std::string remoteAddr);
void removeRemote(std::string remoteAddr);
void addRemote(const std::string& remoteAddr);
void removeRemote(const std::string& remoteAddr);
void setDeviceSelectorClosed();
void reEnumerateDevices();
@ -161,8 +161,8 @@ public:
void setAGCMode(bool mode);
bool getAGCMode();
void setGain(std::string name, float gain_in);
float getGain(std::string name);
void setGain(const std::string& name, float gain_in);
float getGain(const std::string& name);
void setStreamArgs(SoapySDR::Kwargs streamArgs_in);
void setDeviceArgs(SoapySDR::Kwargs settingArgs_in);
@ -186,7 +186,7 @@ public:
#endif
private:
int FilterEvent(wxEvent& event);
int FilterEvent(wxEvent& event) override;
AppFrame *appframe = nullptr;
AppConfig config;

View File

@ -19,7 +19,7 @@ DemodLabelDialog::DemodLabelDialog(wxWindow * parent, wxWindowID id, const wxStr
wxString labelStr;
//by construction, is allways != nullptr
//by construction, is always != nullptr
activeDemod = demod;
labelStr = activeDemod->getDemodulatorUserLabel();
@ -39,7 +39,7 @@ DemodLabelDialog::DemodLabelDialog(wxWindow * parent, wxWindowID id, const wxStr
int titleX = this->GetTextExtent(title).GetWidth();
dialogText->SetMinSize(wxSize(max(int(2.0 * titleX), int(2.0 * textCtrlX)), -1));
wxBoxSizer* dialogsizer = new wxBoxSizer(wxALL);
auto* dialogsizer = new wxBoxSizer(wxALL);
dialogsizer->Add(dialogText, wxSizerFlags(1).Expand().Border(wxALL, 5));
SetSizerAndFit(dialogsizer);
Centre();

View File

@ -25,7 +25,6 @@ public:
private:
DemodulatorInstancePtr activeDemod = nullptr;
void OnEnter ( wxCommandEvent &event );
void OnChar ( wxKeyEvent &event );
void OnShow(wxShowEvent &event);
DECLARE_EVENT_TABLE()

View File

@ -13,8 +13,8 @@ EVT_CHAR_HOOK(FrequencyDialog::OnChar)
EVT_SHOW(FrequencyDialog::OnShow)
wxEND_EVENT_TABLE()
FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstancePtr demod, const wxPoint & position,
const wxSize & size, long style, FrequencyDialogTarget targetMode, wxString initString) :
FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstancePtr demod, const wxPoint & /*position*/,
const wxSize & /*size*/, long style, FrequencyDialogTarget targetMode, wxString initString) :
wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize, style) {
wxString freqStr;
@ -49,7 +49,7 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
}
if (targetMode == FDIALOG_TARGET_GAIN) {
if (wxGetApp().getActiveGainEntry() != "") {
if (!wxGetApp().getActiveGainEntry().empty()) {
freqStr = std::to_string((int)wxGetApp().getGain(wxGetApp().getActiveGainEntry()));
}
}
@ -63,17 +63,17 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin
int titleX = this->GetTextExtent(title).GetWidth();
dialogText->SetMinSize(wxSize(max(int(2.0 * titleX), int(2.0 * std::max(textCtrlX, initTextCtrlX))), -1));
wxBoxSizer* dialogsizer = new wxBoxSizer(wxALL);
auto* dialogsizer = new wxBoxSizer(wxALL);
dialogsizer->Add(dialogText, wxSizerFlags(1).Expand().Border(wxALL, 5));
SetSizerAndFit(dialogsizer);
Centre();
if (initString != "" && initString.length() == 1) {
if (!initString.empty() && initString.length() == 1) {
dialogText->SetValue(initString);
dialogText->SetSelection(2, 2);
dialogText->SetFocus();
} else {
if (initString != "") {
if (!initString.empty()) {
dialogText->SetValue(initString);
}
dialogText->SetSelection(-1, -1);
@ -87,7 +87,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
double dblval;
std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
std::string strValue = dialogText->GetValue().ToStdString();
bool ranged = false;
bool ranged;
std::string strValue2;
size_t range_pos;
@ -170,7 +170,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) {
try {
freq = std::stoi(strValue);
} catch (exception e) {
} catch (const exception &) {
Close();
break;
}
@ -185,7 +185,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) {
try {
dblval = std::stod(strValue);
} catch (exception e) {
} catch (const exception &) {
Close();
break;
}
@ -201,12 +201,12 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
if (targetMode == FDIALOG_TARGET_GAIN) {
try {
freq = std::stoi(strValue);
} catch (exception e) {
} catch (const exception &) {
break;
}
SDRDeviceInfo *devInfo = wxGetApp().getDevice();
std::string gainName = wxGetApp().getActiveGainEntry();
if (gainName == "") {
if (gainName.empty()) {
break;
}
SDRRangeMap gains = devInfo->getGains(SOAPY_SDR_RX, 0);

View File

@ -35,7 +35,6 @@ public:
private:
DemodulatorInstancePtr activeDemod;
void OnEnter ( wxCommandEvent &event );
void OnChar ( wxKeyEvent &event );
void OnShow(wxShowEvent &event);
FrequencyDialogTarget targetMode;

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-2.0+
#include "IOThread.h"
#include <typeinfo>
#include <memory>
#define SPIN_WAIT_SLEEP_MS 5
@ -53,51 +52,51 @@ void IOThread::threadMain() {
terminated.store(true);
stopping.store(true);
};
}
#endif
void IOThread::setup() {
//redefined in subclasses
};
}
void IOThread::run() {
//redefined in subclasses
};
}
void IOThread::terminate() {
stopping.store(true);
};
}
void IOThread::onBindOutput(std::string /* name */, ThreadQueueBasePtr /* threadQueue */) {
};
}
void IOThread::onBindInput(std::string /* name */, ThreadQueueBasePtr /* threadQueue */) {
};
}
void IOThread::setInputQueue(std::string qname, ThreadQueueBasePtr threadQueue) {
void IOThread::setInputQueue(const std::string& qname, const ThreadQueueBasePtr& threadQueue) {
std::lock_guard < std::mutex > lock(m_queue_bindings_mutex);
input_queues[qname] = threadQueue;
this->onBindInput(qname, threadQueue);
};
}
ThreadQueueBasePtr IOThread::getInputQueue(std::string qname) {
ThreadQueueBasePtr IOThread::getInputQueue(const std::string& qname) {
std::lock_guard < std::mutex > lock(m_queue_bindings_mutex);
return input_queues[qname];
};
}
void IOThread::setOutputQueue(std::string qname, ThreadQueueBasePtr threadQueue) {
void IOThread::setOutputQueue(const std::string& qname, const ThreadQueueBasePtr& threadQueue) {
std::lock_guard < std::mutex > lock(m_queue_bindings_mutex);
output_queues[qname] = threadQueue;
this->onBindOutput(qname, threadQueue);
};
}
ThreadQueueBasePtr IOThread::getOutputQueue(std::string qname) {
ThreadQueueBasePtr IOThread::getOutputQueue(const std::string& qname) {
std::lock_guard < std::mutex > lock(m_queue_bindings_mutex);
return output_queues[qname];
};
}
bool IOThread::isTerminated(int waitMs) {
@ -109,13 +108,12 @@ bool IOThread::isTerminated(int waitMs) {
}
//this is a stupid busy plus sleep loop
int nbCyclesToWait = 0;
int nbCyclesToWait;
if (waitMs < 0) {
nbCyclesToWait = std::numeric_limits<int>::max();
}
else {
nbCyclesToWait = (waitMs / SPIN_WAIT_SLEEP_MS) + 1;
}

View File

@ -37,7 +37,7 @@ public:
PtrType ptr;
int age;
virtual ~ReBufferAge() {};
virtual ~ReBufferAge() = default;;
};
#define REBUFFER_GC_LIMIT 100
@ -51,12 +51,10 @@ class ReBuffer {
public:
//Virtual destructor to assure correct freeing of all descendants.
virtual ~ReBuffer() {
//nothing
}
virtual ~ReBuffer() = default;
//constructor
ReBuffer(std::string bufferId) : bufferId(bufferId) {
explicit ReBuffer(std::string bufferId) : bufferId(bufferId) {
//nothing
}
@ -187,10 +185,10 @@ public:
virtual void onBindOutput(std::string name, ThreadQueueBasePtr threadQueue);
virtual void onBindInput(std::string name, ThreadQueueBasePtr threadQueue);
void setInputQueue(std::string qname, ThreadQueueBasePtr threadQueue);
ThreadQueueBasePtr getInputQueue(std::string qname);
void setOutputQueue(std::string qname, ThreadQueueBasePtr threadQueue);
ThreadQueueBasePtr getOutputQueue(std::string qname);
void setInputQueue(const std::string& qname, const ThreadQueueBasePtr& threadQueue);
ThreadQueueBasePtr getInputQueue(const std::string& qname);
void setOutputQueue(const std::string& qname, const ThreadQueueBasePtr& threadQueue);
ThreadQueueBasePtr getOutputQueue(const std::string& qname);
protected:
std::map<std::string, ThreadQueueBasePtr, map_string_less> input_queues;

View File

@ -15,13 +15,13 @@ ModemProperties::ModemProperties(wxWindow *parent, wxWindowID winid,
this->SetSizer(bSizer);
m_propertyGrid->Connect( wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEventHandler( ModemProperties::OnCollapse ), NULL, this );
m_propertyGrid->Connect( wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEventHandler( ModemProperties::OnExpand ), NULL, this );
m_propertyGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( ModemProperties::OnChange ), NULL, this );
this->Connect( wxEVT_SHOW, wxShowEventHandler( ModemProperties::OnShow ), NULL, this );
m_propertyGrid->Connect( wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEventHandler( ModemProperties::OnCollapse ), nullptr, this );
m_propertyGrid->Connect( wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEventHandler( ModemProperties::OnExpand ), nullptr, this );
m_propertyGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( ModemProperties::OnChange ), nullptr, this );
this->Connect( wxEVT_SHOW, wxShowEventHandler( ModemProperties::OnShow ), nullptr, this );
this->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( ModemProperties::OnMouseEnter ), NULL, this);
this->Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( ModemProperties::OnMouseLeave ), NULL, this);
this->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( ModemProperties::OnMouseEnter ), nullptr, this);
this->Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( ModemProperties::OnMouseLeave ), nullptr, this);
updateTheme();
@ -48,14 +48,12 @@ void ModemProperties::updateTheme() {
m_propertyGrid->SetLineColour(btn);
}
ModemProperties::~ModemProperties() {
}
ModemProperties::~ModemProperties() = default;
void ModemProperties::initDefaultProperties() {
if (!audioOutputDevices.size()) {
if (audioOutputDevices.empty()) {
std::vector<string> outputOpts;
std::vector<string> outputOptNames;
@ -63,7 +61,7 @@ void ModemProperties::initDefaultProperties() {
int i = 0;
for (auto aDev : audioDevices) {
for (const auto& aDev : audioDevices) {
if (aDev.inputChannels) {
audioInputDevices[i] = aDev;
}
@ -76,7 +74,7 @@ void ModemProperties::initDefaultProperties() {
// int defaultDevice = 0;
// int dc = 0;
for (auto mdevices_i : audioOutputDevices) {
for (const auto& mdevices_i : audioOutputDevices) {
outputOpts.push_back(std::to_string(mdevices_i.first));
outputOptNames.push_back(mdevices_i.second.name);
@ -89,7 +87,7 @@ void ModemProperties::initDefaultProperties() {
outputArg.key ="._audio_output";
outputArg.name = "Audio Out";
outputArg.description = "Set the current modem's audio output device.";
outputArg.type = ModemArgInfo::STRING;
outputArg.type = ModemArgInfo::Type::STRING;
outputArg.options = outputOpts;
outputArg.optionNames = outputOptNames;
}
@ -101,7 +99,7 @@ void ModemProperties::initDefaultProperties() {
defaultProps["._audio_output"] = addArgInfoProperty(m_propertyGrid, outputArg);
}
void ModemProperties::initProperties(ModemArgInfoList newArgs, DemodulatorInstancePtr demodInstance) {
void ModemProperties::initProperties(ModemArgInfoList newArgs, const DemodulatorInstancePtr& demodInstance) {
args = newArgs;
demodContext = demodInstance;
@ -139,10 +137,10 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
std::vector<std::string>::iterator stringIter;
switch (arg.type) {
case ModemArgInfo::INT:
case ModemArgInfo::Type::INT:
try {
intVal = std::stoi(arg.value);
} catch (std::invalid_argument e) {
} catch (const std::invalid_argument &) {
intVal = 0;
}
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
@ -151,10 +149,10 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum());
}
break;
case ModemArgInfo::FLOAT:
case ModemArgInfo::Type::FLOAT:
try {
floatVal = std::stod(arg.value);
} catch (std::invalid_argument e) {
} catch (const std::invalid_argument &) {
floatVal = 0;
}
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
@ -163,17 +161,17 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum());
}
break;
case ModemArgInfo::BOOL:
case ModemArgInfo::Type::BOOL:
prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) );
break;
case ModemArgInfo::STRING:
if (arg.options.size()) {
case ModemArgInfo::Type::STRING:
if (!arg.options.empty()) {
intVal = 0;
prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) );
for (stringIter = arg.options.begin(); stringIter != arg.options.end(); stringIter++) {
std::string optName = (*stringIter);
std::string displayName = optName;
if (arg.optionNames.size()) {
if (!arg.optionNames.empty()) {
displayName = arg.optionNames[intVal];
}
@ -188,22 +186,22 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
prop = pg->Append( new wxStringProperty(arg.name, wxPG_LABEL, arg.value) );
}
break;
case ModemArgInfo::PATH_DIR:
case ModemArgInfo::Type::PATH_DIR:
break;
case ModemArgInfo::PATH_FILE:
case ModemArgInfo::Type::PATH_FILE:
break;
case ModemArgInfo::COLOR:
case ModemArgInfo::Type::COLOR:
break;
}
if (prop != NULL) {
if (prop != nullptr) {
prop->SetHelpString(arg.name + ": " + arg.description);
}
return prop;
}
std::string ModemProperties::readProperty(std::string key) {
std::string ModemProperties::readProperty(const std::string& key) {
int i = 0;
ModemArgInfoList::const_iterator args_i;
@ -212,10 +210,10 @@ std::string ModemProperties::readProperty(std::string key) {
if (arg.key == key) {
wxPGProperty *prop = props[key];
std::string result = "";
if (arg.type == ModemArgInfo::STRING && arg.options.size()) {
std::string result;
if (arg.type == ModemArgInfo::Type::STRING && !arg.options.empty()) {
return arg.options[prop->GetChoiceSelection()];
} else if (arg.type == ModemArgInfo::BOOL) {
} else if (arg.type == ModemArgInfo::Type::BOOL) {
return (prop->GetValueAsString()=="True")?"true":"false";
} else {
return prop->GetValueAsString().ToStdString();
@ -241,7 +239,7 @@ void ModemProperties::OnChange(wxPropertyGridEvent &event) {
if (demodContext) {
try {
demodContext->setOutputDevice(std::stoi(outputArg.value));
} catch (exception e) {
} catch (const exception &) {
// .. this should never happen ;)
}
@ -292,7 +290,7 @@ void ModemProperties::setCollapsed(bool state) {
}
}
bool ModemProperties::isCollapsed() {
bool ModemProperties::isCollapsed() const {
return collapsed;
}

View File

@ -13,7 +13,7 @@
class ModemProperties : public wxPanel {
public:
ModemProperties(
explicit ModemProperties(
wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
@ -21,20 +21,20 @@ public:
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr
);
~ModemProperties();
~ModemProperties() override;
void initDefaultProperties();
void initProperties(ModemArgInfoList newArgs, DemodulatorInstancePtr demodInstance);
void initProperties(ModemArgInfoList newArgs, const DemodulatorInstancePtr& demodInstance);
bool isMouseInView();
void setCollapsed(bool state);
bool isCollapsed();
bool isCollapsed() const;
void fitColumns();
void updateTheme();
private:
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg);
std::string readProperty(std::string);
std::string readProperty(const std::string&);
void OnChange(wxPropertyGridEvent &event);
void OnShow(wxShowEvent &event);
void OnCollapse(wxPropertyGridEvent &event);

View File

@ -45,7 +45,7 @@ void SessionMgr::saveSession(std::string fileName) {
s.SaveToFileXML(fileName);
}
bool SessionMgr::loadSession(std::string fileName) {
bool SessionMgr::loadSession(const std::string& fileName) {
DataTree l;
if (!l.LoadFromFileXML(fileName)) {
@ -88,7 +88,7 @@ bool SessionMgr::loadSession(std::string fileName) {
if (header->hasAnother("sample_rate")) {
long sample_rate = *header->getNext("sample_rate");
long sample_rate = (long)*header->getNext("sample_rate");
SDRDeviceInfo *dev = wxGetApp().getSDRThread()->getDevice();
if (dev) {
@ -120,7 +120,7 @@ bool SessionMgr::loadSession(std::string fileName) {
if (header->hasAnother("solo_mode")) {
int solo_mode_activated = *header->getNext("solo_mode");
int solo_mode_activated = (int)*header->getNext("solo_mode");
wxGetApp().setSoloMode(solo_mode_activated > 0);
}
@ -162,7 +162,7 @@ bool SessionMgr::loadSession(std::string fileName) {
} // if l.rootNode()->hasAnother("demodulators")
if (header->hasAnother("center_freq")) {
long long center_freq = *header->getNext("center_freq");
long long center_freq = (long long)*header->getNext("center_freq");
wxGetApp().setFrequency(center_freq);
// std::cout << "\tCenter Frequency: " << center_freq << std::endl;
}
@ -171,8 +171,8 @@ bool SessionMgr::loadSession(std::string fileName) {
DataNode *viewState = header->getNext("view_state");
if (viewState->hasAnother("center_freq") && viewState->hasAnother("bandwidth")) {
long long center_freq = *viewState->getNext("center_freq");
int bandwidth = *viewState->getNext("bandwidth");
auto center_freq = (long long)*viewState->getNext("center_freq");
auto bandwidth = (int)*viewState->getNext("bandwidth");
spectrumCanvas->setView(center_freq, bandwidth);
waterfallCanvas->setView(center_freq, bandwidth);
}

View File

@ -10,5 +10,5 @@
class SessionMgr {
public:
void saveSession(std::string fileName);
bool loadSession(std::string fileName);
bool loadSession(const std::string& fileName);
};

View File

@ -5,13 +5,9 @@
#include "CubicSDR.h"
#include <sstream>
AudioFile::AudioFile() {
AudioFile::AudioFile() = default;
}
AudioFile::~AudioFile() {
}
AudioFile::~AudioFile() = default;
void AudioFile::setOutputFileName(std::string filename) {
filenameBase = filename;

View File

@ -22,7 +22,8 @@ namespace little_endian_io
template <typename Word>
std::istream& read_word(std::istream& ins, Word& value, unsigned size = sizeof(Word)) {
for (unsigned n = 0, value = 0; n < size; ++n) {
value = 0;
for (unsigned n = 0; n < size; ++n) {
value |= ins.get() << (8 * n);
}
return ins;
@ -50,11 +51,10 @@ namespace big_endian_io
using namespace little_endian_io;
AudioFileWAV::AudioFileWAV() : AudioFile() {
AudioFileWAV::AudioFileWAV() : AudioFile(), dataChunkPos(0) {
}
AudioFileWAV::~AudioFileWAV() {
}
AudioFileWAV::~AudioFileWAV() = default;
std::string AudioFileWAV::getExtension()
@ -119,7 +119,7 @@ bool AudioFileWAV::closeFile()
return true;
}
void AudioFileWAV::writeHeaderToFileStream(AudioThreadInputPtr input) {
void AudioFileWAV::writeHeaderToFileStream(const AudioThreadInputPtr& input) {
// Based on simple wav file output code from
// http://www.cplusplus.com/forum/beginner/166954/
@ -140,7 +140,7 @@ void AudioFileWAV::writeHeaderToFileStream(AudioThreadInputPtr input) {
outputFileStream << "data----"; // (chunk size to be filled in later)
}
void AudioFileWAV::writePayloadToFileStream(AudioThreadInputPtr input, size_t startInputPosition, size_t endInputPosition) {
void AudioFileWAV::writePayloadToFileStream(const AudioThreadInputPtr& input, size_t startInputPosition, size_t endInputPosition) {
// Prevent clipping
float intScale = (input->peak < 1.0) ? 32767.0f : (32767.0f / input->peak);
@ -164,7 +164,7 @@ void AudioFileWAV::writePayloadToFileStream(AudioThreadInputPtr input, size_t st
}
}
size_t AudioFileWAV::getMaxWritableNumberOfSamples(AudioThreadInputPtr input) {
size_t AudioFileWAV::getMaxWritableNumberOfSamples(const AudioThreadInputPtr& input) const {
long long remainingBytesInFile = (long long)(MAX_WAV_FILE_SIZE) - currentFileSize;

View File

@ -11,19 +11,19 @@ class AudioFileWAV : public AudioFile {
public:
AudioFileWAV();
~AudioFileWAV();
~AudioFileWAV() override;
//override to manage name change with multi-part WAV.
virtual void setOutputFileName(std::string filename);
void setOutputFileName(std::string filename) override;
//override of the base method to generate multi-part
//WAV to overcome the WAV format size limit.
virtual std::string getOutputFileName();
std::string getOutputFileName() override;
virtual std::string getExtension();
std::string getExtension() override;
virtual bool writeToFile(AudioThreadInputPtr input);
virtual bool closeFile();
bool writeToFile(AudioThreadInputPtr input) override;
bool closeFile() override;
protected:
std::ofstream outputFileStream;
@ -33,10 +33,10 @@ protected:
private:
size_t getMaxWritableNumberOfSamples(AudioThreadInputPtr input);
size_t getMaxWritableNumberOfSamples(const AudioThreadInputPtr& input) const;
void writeHeaderToFileStream(AudioThreadInputPtr input);
void writeHeaderToFileStream(const AudioThreadInputPtr& input);
//write [startInputPosition; endInputPosition[ samples from input into the file.
void writePayloadToFileStream(AudioThreadInputPtr input, size_t startInputPosition, size_t endInputPosition);
void writePayloadToFileStream(const AudioThreadInputPtr& input, size_t startInputPosition, size_t endInputPosition);
};

View File

@ -11,7 +11,7 @@ class AudioSinkFileThread : public AudioSinkThread {
public:
AudioSinkFileThread();
~AudioSinkFileThread();
~AudioSinkFileThread() override;
enum SquelchOption {
SQUELCH_RECORD_SILENCE = 0, // default value, record as a user would hear it.
@ -20,8 +20,8 @@ public:
SQUELCH_RECORD_MAX
};
virtual void sink(AudioThreadInputPtr input);
virtual void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps);
void sink(AudioThreadInputPtr input) override;
void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps) override;
void setAudioFileHandler(AudioFile *output);

View File

@ -11,9 +11,7 @@ AudioSinkThread::AudioSinkThread() {
setInputQueue("input", inputQueuePtr);
}
AudioSinkThread::~AudioSinkThread() {
}
AudioSinkThread::~AudioSinkThread() = default;
void AudioSinkThread::run() {
#ifdef __APPLE__

View File

@ -10,10 +10,10 @@ class AudioSinkThread : public IOThread {
public:
AudioSinkThread();
virtual ~AudioSinkThread();
~AudioSinkThread() override;
virtual void run();
virtual void terminate();
void run() override;
void terminate() override;
virtual void sink(AudioThreadInputPtr input) = 0;
virtual void inputChanged(AudioThreadInput oldProps, AudioThreadInputPtr newProps) = 0;

View File

@ -2,13 +2,10 @@
// SPDX-License-Identifier: GPL-2.0+
#include "AudioThread.h"
#include "CubicSDRDefs.h"
#include <vector>
#include <algorithm>
#include "CubicSDR.h"
#include "DemodulatorThread.h"
#include "DemodulatorInstance.h"
#include <memory.h>
#include <mutex>
//50 ms
@ -80,9 +77,9 @@ void AudioThread::deviceCleanup() {
//NOT PROTECTED by m_device_mutex on purpose, to prevent deadlocks with i->second->controllerThread
// it doesn't matter, it is only called when all "normal" audio threads are detached from the controller.
//
for (auto i = deviceController.begin(); i != deviceController.end(); i++) {
for (auto & i : deviceController) {
delete i->second;
delete i.second;
}
deviceController.clear();
@ -98,7 +95,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
::memset(out, 0, nBufferFrames * 2 * sizeof(float));
//src in the controller thread:
AudioThread *src = (AudioThread *)userData;
auto *src = (AudioThread *)userData;
//by construction, src is a controller thread, from deviceController:
std::lock_guard<std::recursive_mutex> lock(src->getMutex());
@ -157,7 +154,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
}
if (srcmix->currentInput->channels == 0 || !srcmix->currentInput->data.size()) {
if (srcmix->currentInput->channels == 0 || srcmix->currentInput->data.empty()) {
if (!srcmix->inputQueue->empty()) {
srcmix->audioQueuePtr = 0;
if (srcmix->currentInput) {
@ -195,7 +192,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
mixPeak = srcPeak;
}
}
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
if (srcmix->currentInput && !srcmix->currentInput->data.empty()) {
float v = srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
out[i * 2] += v;
out[i * 2 + 1] += v;
@ -204,7 +201,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
}
}
else {
for (int i = 0, iMax = srcmix->currentInput->channels * nBufferFrames; i < iMax; i++) {
for (unsigned int i = 0, iMax = srcmix->currentInput->channels * nBufferFrames; i < iMax; i++) {
if (srcmix->audioQueuePtr >= srcmix->currentInput->data.size()) {
srcmix->audioQueuePtr = 0;
@ -222,7 +219,7 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
mixPeak = srcPeak;
}
}
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
if (srcmix->currentInput && !srcmix->currentInput->data.empty()) {
out[i] = out[i] + srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
}
@ -248,9 +245,9 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
void AudioThread::enumerateDevices(std::vector<RtAudio::DeviceInfo> &devs) {
RtAudio endac;
int numDevices = endac.getDeviceCount();
unsigned int numDevices = endac.getDeviceCount();
for (int i = 0; i < numDevices; i++) {
for (unsigned int i = 0; i < numDevices; i++) {
RtAudio::DeviceInfo info = endac.getDeviceInfo(i);
devs.push_back(info);
@ -315,14 +312,14 @@ void AudioThread::setDeviceSampleRate(int deviceId, int sampleRate) {
if (matchingControllerThread != nullptr) {
AudioThreadCommand refreshDevice;
refreshDevice.cmd = AudioThreadCommand::AUDIO_THREAD_CMD_SET_SAMPLE_RATE;
refreshDevice.cmdType = AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_SAMPLE_RATE;
refreshDevice.int_value = sampleRate;
//VSO : blocking push !
matchingControllerThread->getCommandQueue()->push(refreshDevice);
}
}
void AudioThread::setSampleRate(int sampleRate) {
void AudioThread::setSampleRate(int sampleRate_in) {
bool thisIsAController = false;
@ -332,7 +329,7 @@ void AudioThread::setSampleRate(int sampleRate) {
if (deviceController[outputDevice.load()] == this) {
thisIsAController = true;
deviceSampleRate[outputDevice.load()] = sampleRate;
deviceSampleRate[outputDevice.load()] = sampleRate_in;
}
}
@ -344,31 +341,30 @@ void AudioThread::setSampleRate(int sampleRate) {
dac.closeStream();
//Set bounded sample rate:
for (size_t j = 0; j < boundThreads.size(); j++) {
AudioThread *srcmix = boundThreads[j];
srcmix->setSampleRate(sampleRate);
for (auto srcmix : boundThreads) {
srcmix->setSampleRate(sampleRate_in);
}
//make a local copy, snapshot of the list of demodulators
std::vector<DemodulatorInstancePtr> demodulators = wxGetApp().getDemodMgr().getDemodulators();
for (auto demod : demodulators) {
for (const auto& demod : demodulators) {
if (demod->getOutputDevice() == outputDevice.load()) {
demod->setAudioSampleRate(sampleRate);
demod->setAudioSampleRate(sampleRate_in);
}
}
dac.openStream(&parameters, NULL, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
dac.openStream(&parameters, nullptr, RTAUDIO_FLOAT32, sampleRate_in, &nBufferFrames, &audioCallback, (void *)this, &opts);
dac.startStream();
}
this->sampleRate = sampleRate;
sampleRate = sampleRate_in;
}
int AudioThread::getSampleRate() {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
return this->sampleRate;
return sampleRate;
}
void AudioThread::setupDevice(int deviceId) {
@ -411,7 +407,7 @@ void AudioThread::setupDevice(int deviceId) {
if (deviceController.find(parameters.deviceId) == deviceController.end()) {
//Create a new controller thread for parameters.deviceId:
AudioThread* newController = new AudioThread();
auto* newController = new AudioThread();
newController->setInitOutputDevice(parameters.deviceId, sampleRate);
newController->bindThread(this);
@ -422,7 +418,7 @@ void AudioThread::setupDevice(int deviceId) {
else if (deviceController[parameters.deviceId] == this) {
//Attach callback
dac.openStream(&parameters, NULL, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
dac.openStream(&parameters, nullptr, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
dac.startStream();
}
else {
@ -455,21 +451,21 @@ int AudioThread::getOutputDevice() {
return outputDevice;
}
void AudioThread::setInitOutputDevice(int deviceId, int sampleRate) {
void AudioThread::setInitOutputDevice(int deviceId, int sampleRate_in) {
//global lock
std::lock_guard<std::recursive_mutex> lock(m_device_mutex);
outputDevice = deviceId;
if (sampleRate == -1) {
if (sampleRate_in == -1) {
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
sampleRate = deviceSampleRate[deviceId];
sampleRate_in = deviceSampleRate[deviceId];
}
}
else {
deviceSampleRate[deviceId] = sampleRate;
deviceSampleRate[deviceId] = sampleRate_in;
}
this->sampleRate = sampleRate;
sampleRate = sampleRate_in;
}
void AudioThread::run() {
@ -501,10 +497,10 @@ void AudioThread::run() {
continue;
}
if (command.cmd == AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE) {
if (command.cmdType == AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_DEVICE) {
setupDevice(command.int_value);
}
if (command.cmd == AudioThreadCommand::AUDIO_THREAD_CMD_SET_SAMPLE_RATE) {
if (command.cmdType == AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_SAMPLE_RATE) {
setSampleRate(command.int_value);
}
} //end while
@ -517,20 +513,20 @@ void AudioThread::run() {
//Nullify currentInput...
currentInput = nullptr;
//Stop : Retreive the matching controling thread in a scope lock:
AudioThread* controllerThread = nullptr;
//Stop : Retrieve the matching controlling thread in a scope lock:
AudioThread* controllerMatchingThread;
{
std::lock_guard<std::recursive_mutex> global_lock(m_device_mutex);
controllerThread = deviceController[parameters.deviceId];
controllerMatchingThread = deviceController[parameters.deviceId];
}
if (controllerThread != this) {
if (controllerMatchingThread != this) {
//'this' is not the controller, so remove it from the bounded list:
//beware, we must take the controller mutex, because the audio callback may use the list of bounded
//threads at that moment:
std::lock_guard<std::recursive_mutex> lock(controllerThread->getMutex());
std::lock_guard<std::recursive_mutex> lock(controllerMatchingThread->getMutex());
controllerThread->removeThread(this);
controllerMatchingThread->removeThread(this);
}
else {
// 'this' is a controller thread:

View File

@ -15,13 +15,13 @@
class AudioThreadInput {
public:
long long frequency;
int inputRate;
int sampleRate;
int channels;
float peak;
int type;
bool is_squelch_active;
long long frequency{};
int inputRate{};
int sampleRate{};
int channels{};
float peak{};
int type{};
bool is_squelch_active{};
std::vector<float> data;
@ -31,7 +31,7 @@ public:
}
AudioThreadInput(AudioThreadInput *copyFrom) {
explicit AudioThreadInput(AudioThreadInput *copyFrom) {
copy(copyFrom);
}
@ -47,9 +47,7 @@ public:
}
virtual ~AudioThreadInput() {
}
virtual ~AudioThreadInput() = default;
};
typedef std::shared_ptr<AudioThreadInput> AudioThreadInputPtr;
@ -60,15 +58,15 @@ typedef std::shared_ptr<DemodulatorThreadOutputQueue> DemodulatorThreadOutputQue
class AudioThreadCommand {
public:
enum AudioThreadCommandEnum {
enum class Type {
AUDIO_THREAD_CMD_NULL, AUDIO_THREAD_CMD_SET_DEVICE, AUDIO_THREAD_CMD_SET_SAMPLE_RATE
};
AudioThreadCommand() :
cmd(AUDIO_THREAD_CMD_NULL), int_value(0) {
cmdType(AudioThreadCommand::Type::AUDIO_THREAD_CMD_NULL), int_value(0) {
}
AudioThreadCommandEnum cmd;
AudioThreadCommand::Type cmdType;
int int_value;
};
@ -83,17 +81,17 @@ class AudioThread : public IOThread {
public:
AudioThread();
virtual ~AudioThread();
~AudioThread() override;
static void enumerateDevices(std::vector<RtAudio::DeviceInfo> &devs);
void setInitOutputDevice(int deviceId, int sampleRate = -1);
void setInitOutputDevice(int deviceId, int sampleRate_in = -1);
int getOutputDevice();
int getSampleRate();
virtual void run();
virtual void terminate();
void run() override;
void terminate() override;
bool isActive();
void setActive(bool state);
@ -141,7 +139,7 @@ private:
std::recursive_mutex m_mutex;
void setupDevice(int deviceId);
void setSampleRate(int sampleRate);
void setSampleRate(int sampleRate_in);
void bindThread(AudioThread *other);
void removeThread(AudioThread *other);

View File

@ -15,20 +15,6 @@
class DemodulatorThread;
class DemodulatorThreadControlCommand {
public:
enum DemodulatorThreadControlCommandEnum {
DEMOD_THREAD_CMD_CTL_NULL, DEMOD_THREAD_CMD_CTL_SQUELCH_ON, DEMOD_THREAD_CMD_CTL_SQUELCH_OFF, DEMOD_THREAD_CMD_CTL_TYPE
};
DemodulatorThreadControlCommand() :
cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType("") {
}
DemodulatorThreadControlCommandEnum cmd;
std::string demodType;
};
class DemodulatorThreadIQData {
public:
long long frequency;
@ -48,9 +34,7 @@ public:
return *this;
}
virtual ~DemodulatorThreadIQData() {
}
virtual ~DemodulatorThreadIQData() = default;
};
class Modem;
@ -71,41 +55,14 @@ public:
}
virtual ~DemodulatorThreadPostIQData() {
}
virtual ~DemodulatorThreadPostIQData() = default;
};
class DemodulatorThreadAudioData {
public:
long long frequency;
unsigned int sampleRate;
unsigned char channels;
std::vector<float> *data;
DemodulatorThreadAudioData() :
frequency(0), sampleRate(0), channels(0), data(NULL) {
}
DemodulatorThreadAudioData(long long frequency, unsigned int sampleRate, std::vector<float> *data) :
frequency(frequency), sampleRate(sampleRate), channels(1), data(data) {
}
virtual ~DemodulatorThreadAudioData() {
}
};
typedef std::shared_ptr<DemodulatorThreadIQData> DemodulatorThreadIQDataPtr;
typedef std::shared_ptr<DemodulatorThreadPostIQData> DemodulatorThreadPostIQDataPtr;
typedef ThreadBlockingQueue<DemodulatorThreadIQDataPtr> DemodulatorThreadInputQueue;
typedef ThreadBlockingQueue<DemodulatorThreadPostIQDataPtr> DemodulatorThreadPostInputQueue;
typedef ThreadBlockingQueue<DemodulatorThreadControlCommand> DemodulatorThreadControlCommandQueue;
typedef std::shared_ptr<DemodulatorThreadInputQueue> DemodulatorThreadInputQueuePtr;
typedef std::shared_ptr<DemodulatorThreadPostInputQueue> DemodulatorThreadPostInputQueuePtr;
typedef std::shared_ptr<DemodulatorThreadControlCommandQueue> DemodulatorThreadControlCommandQueuePtr;

View File

@ -20,9 +20,7 @@ DemodVisualCue::DemodVisualCue() {
squelchBreak.store(false);
}
DemodVisualCue::~DemodVisualCue() {
}
DemodVisualCue::~DemodVisualCue() = default;
void DemodVisualCue::triggerSquelchBreak(int counter) {
squelchBreak.store(counter);
@ -48,7 +46,6 @@ DemodulatorInstance::DemodulatorInstance() {
#endif
active.store(false);
squelch.store(false);
muted.store(false);
recording.store(false);
deltaLock.store(false);
@ -75,12 +72,8 @@ DemodulatorInstance::DemodulatorInstance() {
pipeAudioData = std::make_shared<AudioThreadInputQueue>();
pipeAudioData->set_max_num_items(100);
threadQueueControl = std::make_shared<DemodulatorThreadControlCommandQueue>();
threadQueueControl->set_max_num_items(2);
demodulatorThread = new DemodulatorThread(this);
demodulatorThread->setInputQueue("IQDataInput",pipeIQDemodData);
demodulatorThread->setInputQueue("ControlQueue",threadQueueControl);
demodulatorThread->setOutputQueue("AudioDataOutput", pipeAudioData);
audioThread->setInputQueue("AudioDataInput", pipeAudioData);
@ -121,7 +114,7 @@ DemodulatorInstance::~DemodulatorInstance() {
} //end while
}
void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueuePtr tQueue) {
void DemodulatorInstance::setVisualOutputQueue(const DemodulatorThreadOutputQueuePtr& tQueue) {
demodulatorThread->setOutputQueue("AudioVisualOutput", tQueue);
}
@ -194,7 +187,6 @@ void DemodulatorInstance::terminate() {
pipeIQInputData->flush();
pipeAudioData->flush();
pipeIQDemodData->flush();
threadQueueControl->flush();
}
std::string DemodulatorInstance::getLabel() {
@ -307,30 +299,15 @@ void DemodulatorInstance::setActive(bool state) {
}
void DemodulatorInstance::squelchAuto() {
DemodulatorThreadControlCommand command;
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON;
//VSO: blocking push
threadQueueControl->push(command);
squelch = true;
demodulatorThread->setSquelchEnabled(true);
}
bool DemodulatorInstance::isSquelchEnabled() {
return (demodulatorThread->getSquelchLevel() != 0.0);
return demodulatorThread->isSquelchEnabled();
}
void DemodulatorInstance::setSquelchEnabled(bool state) {
if (!state && squelch) {
DemodulatorThreadControlCommand command;
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_OFF;
threadQueueControl->push(command);
} else if (state && !squelch) {
DemodulatorThreadControlCommand command;
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON;
//VSO: blocking push!
threadQueueControl->push(command);
}
squelch = state;
demodulatorThread->setSquelchEnabled(state);
}
float DemodulatorInstance::getSignalLevel() {
@ -360,7 +337,7 @@ void DemodulatorInstance::setOutputDevice(int device_id) {
audioThread->setInitOutputDevice(device_id);
} else if (audioThread) {
AudioThreadCommand command;
command.cmd = AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE;
command.cmdType = AudioThreadCommand::Type::AUDIO_THREAD_CMD_SET_DEVICE;
command.int_value = device_id;
//VSO: blocking push
audioThread->getCommandQueue()->push(command);
@ -379,11 +356,11 @@ int DemodulatorInstance::getOutputDevice() {
return currentOutputDevice;
}
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
void DemodulatorInstance::setDemodulatorType(const std::string& demod_type_in) {
setGain(getGain());
if (demodulatorPreThread) {
std::string currentDemodType = demodulatorPreThread->getDemodType();
if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
if ((!currentDemodType.empty()) && (currentDemodType != demod_type_in)) {
lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth();
}
@ -395,7 +372,7 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
demodulatorPreThread->setDemodType(demod_type_in);
int lastbw = 0;
if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
if (!currentDemodType.empty() && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
lastbw = lastModemBandwidth[demod_type_in];
}
if (!lastbw) {
@ -407,7 +384,7 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
#if ENABLE_DIGITAL_LAB
if (isModemInitialized() && getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput();
auto *outp = (ModemDigitalOutputConsole *)getOutput();
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
}
#endif
@ -463,7 +440,7 @@ void DemodulatorInstance::setFrequency(long long freq) {
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
if (isModemInitialized() && getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput();
auto *outp = (ModemDigitalOutputConsole *)getOutput();
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
}
}
@ -488,7 +465,7 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) {
demodulatorPreThread->setAudioSampleRate(sampleRate);
}
int DemodulatorInstance::getAudioSampleRate() {
int DemodulatorInstance::getAudioSampleRate() const {
if (!audioThread) {
return 0;
}
@ -509,16 +486,16 @@ bool DemodulatorInstance::isFollow() {
return follow.load();
}
void DemodulatorInstance::setFollow(bool follow) {
this->follow.store(follow);
void DemodulatorInstance::setFollow(bool follow_in) {
follow.store(follow_in);
}
bool DemodulatorInstance::isTracking() {
return tracking.load();
}
void DemodulatorInstance::setTracking(bool tracking) {
this->tracking.store(tracking);
void DemodulatorInstance::setTracking(bool tracking_in) {
tracking.store(tracking_in);
}
bool DemodulatorInstance::isDeltaLock() {
@ -541,10 +518,10 @@ bool DemodulatorInstance::isMuted() {
return demodulatorThread->isMuted();
}
void DemodulatorInstance::setMuted(bool muted) {
this->muted = muted;
demodulatorThread->setMuted(muted);
wxGetApp().getDemodMgr().setLastMuted(muted);
void DemodulatorInstance::setMuted(bool muted_in) {
muted = muted_in;
demodulatorThread->setMuted(muted_in);
wxGetApp().getDemodMgr().setLastMuted(muted_in);
}
bool DemodulatorInstance::isRecording()
@ -580,11 +557,11 @@ ModemArgInfoList DemodulatorInstance::getModemArgs() {
return args;
}
std::string DemodulatorInstance::readModemSetting(std::string setting) {
std::string DemodulatorInstance::readModemSetting(const std::string& setting) {
return demodulatorPreThread->readModemSetting(setting);
}
void DemodulatorInstance::writeModemSetting(std::string setting, std::string value) {
void DemodulatorInstance::writeModemSetting(const std::string& setting, std::string value) {
demodulatorPreThread->writeModemSetting(setting, value);
}
@ -610,7 +587,7 @@ std::string DemodulatorInstance::getModemType() {
return "";
}
ModemSettings DemodulatorInstance::getLastModemSettings(std::string demodType) {
ModemSettings DemodulatorInstance::getLastModemSettings(const std::string& demodType) {
if (lastModemSettings.find(demodType) != lastModemSettings.end()) {
return lastModemSettings[demodType];
} else {
@ -625,8 +602,8 @@ void DemodulatorInstance::startRecording() {
return;
}
AudioSinkFileThread *newSinkThread = new AudioSinkFileThread();
AudioFileWAV *afHandler = new AudioFileWAV();
auto *newSinkThread = new AudioSinkFileThread();
auto *afHandler = new AudioFileWAV();
std::stringstream fileName;
@ -701,7 +678,7 @@ void DemodulatorInstance::hideOutput() {
void DemodulatorInstance::closeOutput() {
if (isModemInitialized()) {
if (getModemType() == "digital") {
ModemDigital *dModem = (ModemDigital *)demodulatorPreThread->getModem();
auto *dModem = (ModemDigital *)demodulatorPreThread->getModem();
dModem->setOutput(nullptr);
}
}

View File

@ -50,7 +50,7 @@ public:
DemodulatorInstance();
~DemodulatorInstance();
void setVisualOutputQueue(DemodulatorThreadOutputQueuePtr tQueue);
void setVisualOutputQueue(const DemodulatorThreadOutputQueuePtr& tQueue);
void run();
void terminate();
@ -76,7 +76,7 @@ public:
void setOutputDevice(int device_id);
int getOutputDevice();
void setDemodulatorType(std::string demod_type_in);
void setDemodulatorType(const std::string& demod_type_in);
std::string getDemodulatorType();
std::wstring getDemodulatorUserLabel();
@ -95,13 +95,13 @@ public:
long long getFrequency();
void setAudioSampleRate(int sampleRate);
int getAudioSampleRate();
int getAudioSampleRate() const;
bool isFollow();
void setFollow(bool follow);
void setFollow(bool follow_in);
bool isTracking();
void setTracking(bool tracking);
void setTracking(bool tracking_in);
bool isDeltaLock();
void setDeltaLock(bool lock);
@ -109,7 +109,7 @@ public:
int getDeltaLockOfs();
bool isMuted();
void setMuted(bool muted);
void setMuted(bool muted_in);
bool isRecording();
void setRecording(bool recording);
@ -119,14 +119,14 @@ public:
DemodulatorThreadInputQueuePtr getIQInputDataPipe();
ModemArgInfoList getModemArgs();
std::string readModemSetting(std::string setting);
std::string readModemSetting(const std::string& setting);
ModemSettings readModemSettings();
void writeModemSetting(std::string setting, std::string value);
void writeModemSetting(const std::string& setting, std::string value);
void writeModemSettings(ModemSettings settings);
bool isModemInitialized();
std::string getModemType();
ModemSettings getLastModemSettings(std::string demodType);
ModemSettings getLastModemSettings(const std::string& demodType);
#if ENABLE_DIGITAL_LAB
ModemDigitalOutput *getOutput();
@ -145,7 +145,6 @@ private:
AudioThreadInputQueuePtr pipeAudioData;
DemodulatorPreThread *demodulatorPreThread;
DemodulatorThread *demodulatorThread;
DemodulatorThreadControlCommandQueuePtr threadQueueControl;
AudioSinkThread *audioSinkThread = nullptr;
std::thread *t_AudioSink = nullptr;
@ -159,7 +158,6 @@ private:
std::atomic<std::wstring *> user_label;
std::atomic_bool active;
std::atomic_bool squelch;
std::atomic_bool muted;
std::atomic_bool deltaLock;
std::atomic_bool recording;

View File

@ -2,13 +2,9 @@
// SPDX-License-Identifier: GPL-2.0+
#include <DemodulatorMgr.h>
#include <sstream>
#include <algorithm>
#include <string>
#include <sstream>
#include <algorithm>
#include "DemodulatorMgr.h"
#include "CubicSDR.h"
#if USE_HAMLIB
@ -18,8 +14,8 @@
#include "DataTree.h"
#include <wx/string.h>
bool demodFreqCompare (DemodulatorInstancePtr i, DemodulatorInstancePtr j) { return (i->getFrequency() < j->getFrequency()); }
bool inactiveCompare (DemodulatorInstancePtr i, DemodulatorInstancePtr j) { return (i->isActive() < j->isActive()); }
bool demodFreqCompare (const DemodulatorInstancePtr& i, const DemodulatorInstancePtr& j) { return (i->getFrequency() < j->getFrequency()); }
bool inactiveCompare (const DemodulatorInstancePtr& i, const DemodulatorInstancePtr& j) { return (i->isActive() < j->isActive()); }
DemodulatorMgr::DemodulatorMgr() {
@ -55,7 +51,7 @@ void DemodulatorMgr::terminateAll() {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
while (demods.size()) {
while (!demods.empty()) {
DemodulatorInstancePtr d = demods.back();
demods.pop_back();
@ -95,7 +91,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getOrderedDemodulators(bool
return demods_ordered;
}
DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives) {
DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(const DemodulatorInstancePtr& demod, bool actives) {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
if (!getCurrentModem()) {
return nullptr;
@ -112,7 +108,7 @@ DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstanc
return *(--p);
}
DemodulatorInstancePtr DemodulatorMgr::getNextDemodulator(DemodulatorInstancePtr demod, bool actives) {
DemodulatorInstancePtr DemodulatorMgr::getNextDemodulator(const DemodulatorInstancePtr& demod, bool actives) {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
if (!getCurrentModem()) {
return nullptr;
@ -144,7 +140,7 @@ DemodulatorInstancePtr DemodulatorMgr::getFirstDemodulator() {
return getOrderedDemodulators().front();
}
void DemodulatorMgr::deleteThread(DemodulatorInstancePtr demod) {
void DemodulatorMgr::deleteThread(const DemodulatorInstancePtr& demod) {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
@ -176,9 +172,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getDemodulatorsAt(long long
std::vector<DemodulatorInstancePtr> foundDemods;
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
DemodulatorInstancePtr testDemod = demods[i];
for (auto testDemod : demods) {
long long freqTest = testDemod->getFrequency();
long long bandwidthTest = testDemod->getBandwidth();
long long halfBandwidthTest = bandwidthTest / 2;
@ -195,9 +189,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getDemodulatorsAt(long long
bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
DemodulatorInstancePtr testDemod = demods[i];
for (auto testDemod : demods) {
long long freqTest = testDemod->getFrequency();
long long bandwidthTest = testDemod->getBandwidth();
long long halfBandwidthTest = bandwidthTest / 2;
@ -214,7 +206,7 @@ bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
}
void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary) {
void DemodulatorMgr::setActiveDemodulator(const DemodulatorInstancePtr& demod, bool temporary) {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
@ -261,7 +253,7 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool tem
void DemodulatorMgr::setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary) {
std::lock_guard < std::recursive_mutex > lock(demods_busy);
for (auto existing_demod : demods) {
for (const auto& existing_demod : demods) {
if (existing_demod.get() == demod) {
@ -335,7 +327,7 @@ void DemodulatorMgr::updateLastState() {
if (currentModem) {
lastBandwidth = currentModem->getBandwidth();
lastDemodType = currentModem->getDemodulatorType();
lastDemodLock = currentModem->getDemodulatorLock()?true:false;
lastDemodLock = currentModem->getDemodulatorLock() != 0;
lastSquelchEnabled = currentModem->isSquelchEnabled();
lastSquelch = currentModem->getSquelchLevel();
lastGain = currentModem->getGain();
@ -348,29 +340,29 @@ int DemodulatorMgr::getLastBandwidth() const {
return lastBandwidth;
}
void DemodulatorMgr::setLastBandwidth(int lastBandwidth) {
if (lastBandwidth < MIN_BANDWIDTH) {
lastBandwidth = MIN_BANDWIDTH;
} else if (lastBandwidth > wxGetApp().getSampleRate()) {
lastBandwidth = wxGetApp().getSampleRate();
void DemodulatorMgr::setLastBandwidth(int lastBandwidth_in) {
if (lastBandwidth_in < MIN_BANDWIDTH) {
lastBandwidth_in = MIN_BANDWIDTH;
} else if (lastBandwidth_in > wxGetApp().getSampleRate()) {
lastBandwidth_in = wxGetApp().getSampleRate();
}
this->lastBandwidth = lastBandwidth;
lastBandwidth = lastBandwidth_in;
}
std::string DemodulatorMgr::getLastDemodulatorType() const {
return lastDemodType;
}
void DemodulatorMgr::setLastDemodulatorType(std::string lastDemodType) {
this->lastDemodType = lastDemodType;
void DemodulatorMgr::setLastDemodulatorType(std::string lastDemodType_in) {
lastDemodType = lastDemodType_in;
}
float DemodulatorMgr::getLastGain() const {
return lastGain;
}
void DemodulatorMgr::setLastGain(float lastGain) {
this->lastGain = lastGain;
void DemodulatorMgr::setLastGain(float lastGain_in) {
lastGain = lastGain_in;
}
@ -386,31 +378,31 @@ float DemodulatorMgr::getLastSquelchLevel() const {
return lastSquelch;
}
void DemodulatorMgr::setLastSquelchLevel(float lastSquelch) {
this->lastSquelch = lastSquelch;
void DemodulatorMgr::setLastSquelchLevel(float lastSquelch_in) {
lastSquelch = lastSquelch_in;
}
bool DemodulatorMgr::isLastSquelchEnabled() const {
return lastSquelchEnabled;
}
void DemodulatorMgr::setLastSquelchEnabled(bool lastSquelchEnabled) {
this->lastSquelchEnabled = lastSquelchEnabled;
void DemodulatorMgr::setLastSquelchEnabled(bool lastSquelchEnabled_in) {
lastSquelchEnabled = lastSquelchEnabled_in;
}
bool DemodulatorMgr::isLastMuted() const {
return lastMuted;
}
void DemodulatorMgr::setLastMuted(bool lastMuted) {
this->lastMuted = lastMuted;
void DemodulatorMgr::setLastMuted(bool lastMuted_in) {
lastMuted = lastMuted_in;
}
ModemSettings DemodulatorMgr::getLastModemSettings(std::string modemType) {
ModemSettings DemodulatorMgr::getLastModemSettings(const std::string& modemType) {
return lastModemSettings[modemType];
}
void DemodulatorMgr::setLastModemSettings(std::string modemType, ModemSettings settings) {
void DemodulatorMgr::setLastModemSettings(const std::string& modemType, ModemSettings settings) {
lastModemSettings[modemType] = settings;
}
@ -422,7 +414,7 @@ std::map<int, RtAudio::DeviceInfo> DemodulatorMgr::getOutputDevices() {
return outputDevices;
}
void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
void DemodulatorMgr::saveInstance(DataNode *node, const DemodulatorInstancePtr& inst) {
*node->newChild("bandwidth") = inst->getBandwidth();
*node->newChild("frequency") = inst->getFrequency();
@ -444,7 +436,7 @@ void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
}
ModemSettings saveSettings = inst->readModemSettings();
if (saveSettings.size()) {
if (!saveSettings.empty()) {
DataNode *settingsNode = node->newChild("settings");
for (ModemSettings::const_iterator msi = saveSettings.begin(); msi != saveSettings.end(); msi++) {
*settingsNode->newChild(msi->first.c_str()) = msi->second;
@ -454,7 +446,7 @@ void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
std::wstring decodedWString = L"";
std::wstring decodedWString;
if (node != nullptr) {
@ -462,7 +454,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
try {
node->element()->get(decodedWString);
} catch (DataTypeMismatchException e) {
} catch (const DataTypeMismatchException &) {
//2) wstring decode fail, try simple std::string
std::string decodedStdString;
try {
@ -472,7 +464,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
//use wxString for a clean conversion to a wstring:
decodedWString = wxString(decodedStdString).ToStdWstring();
} catch (DataTypeMismatchException e) {
} catch (const DataTypeMismatchException &) {
//nothing works, return an empty string.
decodedWString = L"";
}
@ -490,22 +482,22 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
node->rewindAll();
long bandwidth = *node->getNext("bandwidth");
long long freq = *node->getNext("frequency");
long bandwidth = (long)*node->getNext("bandwidth");
long long freq = (long long)*node->getNext("frequency");
float squelch_level = node->hasAnother("squelch_level") ? (float) *node->getNext("squelch_level") : 0;
int squelch_enabled = node->hasAnother("squelch_enabled") ? (int) *node->getNext("squelch_enabled") : 0;
int muted = node->hasAnother("muted") ? (int) *node->getNext("muted") : 0;
int delta_locked = node->hasAnother("delta_lock") ? (int) *node->getNext("delta_lock") : 0;
int delta_ofs = node->hasAnother("delta_ofs") ? (int) *node->getNext("delta_ofs") : 0;
std::string output_device = node->hasAnother("output_device") ? string(*(node->getNext("output_device"))) : "";
float gain = node->hasAnother("gain") ? (float) *node->getNext("gain") : 1.0;
std::string output_device = node->hasAnother("output_device") ? ((string)*(node->getNext("output_device"))) : "";
float gain = node->hasAnother("gain") ? (float) *node->getNext("gain") : 1.0f;
std::string type = "FM";
DataNode *demodTypeNode = node->hasAnother("type")?node->getNext("type"):nullptr;
if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::DATA_INT) {
int legacyType = *demodTypeNode;
if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::Type::DATA_INT) {
int legacyType = (int)*demodTypeNode;
int legacyStereo = node->hasAnother("stereo") ? (int) *node->getNext("stereo") : 0;
switch (legacyType) { // legacy demod ID
case 1: type = legacyStereo?"FMS":"FM"; break;
@ -526,12 +518,12 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
case 16: type = "I/Q"; break;
default: type = "FM"; break;
}
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::DATA_STRING) {
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::Type::DATA_STRING) {
demodTypeNode->element()->get(type);
}
//read the user label associated with the demodulator
std::wstring user_label = L"";
std::wstring user_label;
DataNode *demodUserLabel = node->hasAnother("user_label") ? node->getNext("user_label") : nullptr;
@ -549,7 +541,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
std::string keyName = settingNode->getName();
std::string strSettingValue = settingNode->element()->toString();
if (keyName != "" && strSettingValue != "") {
if (!keyName.empty() && !strSettingValue.empty()) {
mSettings[keyName] = strSettingValue;
}
}
@ -564,7 +556,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
newDemod->setFrequency(freq);
newDemod->setGain(gain);
newDemod->updateLabel(freq);
newDemod->setMuted(muted?true:false);
newDemod->setMuted(muted != 0);
if (delta_locked) {
newDemod->setDeltaLock(true);
newDemod->setDeltaLockOfs(delta_ofs);

View File

@ -24,16 +24,16 @@ public:
std::vector<DemodulatorInstancePtr> getOrderedDemodulators(bool actives = true);
std::vector<DemodulatorInstancePtr> getDemodulatorsAt(long long freq, int bandwidth);
DemodulatorInstancePtr getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives = true);
DemodulatorInstancePtr getNextDemodulator(DemodulatorInstancePtr demod, bool actives = true);
DemodulatorInstancePtr getPreviousDemodulator(const DemodulatorInstancePtr& demod, bool actives = true);
DemodulatorInstancePtr getNextDemodulator(const DemodulatorInstancePtr& demod, bool actives = true);
DemodulatorInstancePtr getLastDemodulator();
DemodulatorInstancePtr getFirstDemodulator();
bool anyDemodulatorsAt(long long freq, int bandwidth);
void deleteThread(DemodulatorInstancePtr);
void deleteThread(const DemodulatorInstancePtr&);
void terminateAll();
void setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary = true);
void setActiveDemodulator(const DemodulatorInstancePtr& demod, bool temporary = true);
//Dangerous: this is only intended by some internal classes,
// and only set a pre-existing demod
@ -47,34 +47,34 @@ public:
int bandwidth);
int getLastBandwidth() const;
void setLastBandwidth(int lastBandwidth);
void setLastBandwidth(int lastBandwidth_in);
std::string getLastDemodulatorType() const;
void setLastDemodulatorType(std::string lastDemodType);
void setLastDemodulatorType(std::string lastDemodType_in);
float getLastGain() const;
void setLastGain(float lastGain);
void setLastGain(float lastGain_in);
bool getLastDeltaLock() const;
void setLastDeltaLock(bool lock);
float getLastSquelchLevel() const;
void setLastSquelchLevel(float lastSquelch);
void setLastSquelchLevel(float lastSquelch_in);
bool isLastSquelchEnabled() const;
void setLastSquelchEnabled(bool lastSquelchEnabled);
void setLastSquelchEnabled(bool lastSquelchEnabled_in);
bool isLastMuted() const;
void setLastMuted(bool lastMuted);
void setLastMuted(bool lastMuted_in);
ModemSettings getLastModemSettings(std::string);
void setLastModemSettings(std::string, ModemSettings);
ModemSettings getLastModemSettings(const std::string&);
void setLastModemSettings(const std::string&, ModemSettings);
void updateLastState();
void setOutputDevices(std::map<int,RtAudio::DeviceInfo> devs);
std::map<int, RtAudio::DeviceInfo> getOutputDevices();
void saveInstance(DataNode *node, DemodulatorInstancePtr inst);
void saveInstance(DataNode *node, const DemodulatorInstancePtr& inst);
DemodulatorInstancePtr loadInstance(DataNode *node);

View File

@ -1,7 +1,6 @@
// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+
#include "CubicSDRDefs.h"
#include <vector>
#ifdef __APPLE__
@ -15,7 +14,7 @@
//50 ms
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
DemodulatorPreThread::DemodulatorPreThread(DemodulatorInstance* parent) : IOThread(), iqResampler(NULL), iqResampleRatio(1), cModem(nullptr), cModemKit(nullptr)
DemodulatorPreThread::DemodulatorPreThread(DemodulatorInstance* parent) : IOThread(), iqResampler(nullptr), iqResampleRatio(1), cModem(nullptr), cModemKit(nullptr)
{
initialized.store(false);
this->parent = parent;
@ -50,8 +49,7 @@ bool DemodulatorPreThread::isInitialized() {
return initialized.load();
}
DemodulatorPreThread::~DemodulatorPreThread() {
}
DemodulatorPreThread::~DemodulatorPreThread() = default;
void DemodulatorPreThread::run() {
#ifdef __APPLE__
@ -98,15 +96,14 @@ void DemodulatorPreThread::run() {
audioSampleRateChanged.store(true);
}
} else if (parent->getAudioSampleRate() != newAudioSampleRate) {
int newRate;
if ((newRate = parent->getAudioSampleRate())) {
if (parent->getAudioSampleRate()) {
newAudioSampleRate = parent->getAudioSampleRate();
audioSampleRateChanged.store(true);
}
}
if (demodTypeChanged.load() && (newSampleRate && newAudioSampleRate && newBandwidth)) {
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD);
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD);
command.frequency = newFrequency;
command.sampleRate = newSampleRate;
command.demodType = newDemodType;
@ -116,9 +113,9 @@ void DemodulatorPreThread::run() {
sampleRateChanged.store(false);
audioSampleRateChanged.store(false);
ModemSettings lastSettings = parent->getLastModemSettings(newDemodType);
if (lastSettings.size() != 0) {
if (!lastSettings.empty()) {
command.settings = lastSettings;
if (modemSettingsBuffered.size()) {
if (!modemSettingsBuffered.empty()) {
for (ModemSettings::const_iterator msi = modemSettingsBuffered.begin(); msi != modemSettingsBuffered.end(); msi++) {
command.settings[msi->first] = msi->second;
}
@ -140,7 +137,7 @@ void DemodulatorPreThread::run() {
(bandwidthChanged.load() || sampleRateChanged.load() || audioSampleRateChanged.load() || cModem->shouldRebuildKit()) &&
(newSampleRate && newAudioSampleRate && newBandwidth)
) {
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS);
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS);
command.frequency = newFrequency;
command.sampleRate = newSampleRate;
command.bandwidth = newBandwidth;
@ -168,7 +165,7 @@ void DemodulatorPreThread::run() {
// std::lock_guard < std::mutex > lock(inp->m_mutex);
std::vector<liquid_float_complex> *data = &inp->data;
if (data->size() && (inp->sampleRate == currentSampleRate) && cModem && cModemKit) {
if (!data->empty() && (inp->sampleRate == currentSampleRate) && cModem && cModemKit) {
size_t bufSize = data->size();
if (in_buf_data.size() != bufSize) {
@ -184,7 +181,7 @@ void DemodulatorPreThread::run() {
liquid_float_complex *in_buf = &in_buf_data[0];
liquid_float_complex *out_buf = &out_buf_data[0];
liquid_float_complex *temp_buf = NULL;
liquid_float_complex *temp_buf;
if (shiftFrequency != 0) {
if (shiftFrequency < 0) {
@ -228,7 +225,7 @@ void DemodulatorPreThread::run() {
while (!stopping && workerResults->try_pop(result)) {
switch (result.cmd) {
case DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS:
case DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_FILTERS:
if (result.iqResampler) {
if (iqResampler) {
msresamp_crcf_destroy(iqResampler);
@ -241,7 +238,7 @@ void DemodulatorPreThread::run() {
cModem = result.modem;
#if ENABLE_DIGITAL_LAB
if (cModem->getType() == "digital") {
ModemDigital *mDigi = (ModemDigital *)cModem;
auto *mDigi = (ModemDigital *)cModem;
mDigi->setOutput(parent->getOutput());
}
#endif
@ -260,7 +257,7 @@ void DemodulatorPreThread::run() {
currentSampleRate = result.sampleRate;
}
if (result.modemName != "") {
if (!result.modemName.empty()) {
demodType = result.modemName;
demodTypeChanged.store(false);
}
@ -285,8 +282,8 @@ void DemodulatorPreThread::run() {
iqInputQueue->flush();
}
void DemodulatorPreThread::setDemodType(std::string demodType) {
newDemodType = demodType;
void DemodulatorPreThread::setDemodType(std::string demodType_in) {
newDemodType = demodType_in;
demodTypeChanged.store(true);
}
@ -377,7 +374,7 @@ ModemKit *DemodulatorPreThread::getModemKit() {
}
std::string DemodulatorPreThread::readModemSetting(std::string setting) {
std::string DemodulatorPreThread::readModemSetting(const std::string& setting) {
if (cModem) {
return cModem->readSetting(setting);
} else if (modemSettingsBuffered.find(setting) != modemSettingsBuffered.end()) {
@ -386,7 +383,7 @@ std::string DemodulatorPreThread::readModemSetting(std::string setting) {
return "";
}
void DemodulatorPreThread::writeModemSetting(std::string setting, std::string value) {
void DemodulatorPreThread::writeModemSetting(const std::string& setting, std::string value) {
modemSettingsBuffered[setting] = value;
modemSettingsChanged.store(true);
}

View File

@ -17,12 +17,12 @@ class DemodulatorInstance;
class DemodulatorPreThread : public IOThread {
public:
DemodulatorPreThread(DemodulatorInstance* parent);
virtual ~DemodulatorPreThread();
explicit DemodulatorPreThread(DemodulatorInstance* parent);
~DemodulatorPreThread() override;
virtual void run();
void run() override;
void setDemodType(std::string demodType);
void setDemodType(std::string demodType_in);
std::string getDemodType();
void setFrequency(long long sampleRate);
@ -39,13 +39,13 @@ public:
bool isInitialized();
virtual void terminate();
void terminate() override;
Modem *getModem();
ModemKit *getModemKit();
std::string readModemSetting(std::string setting);
void writeModemSetting(std::string setting, std::string value);
std::string readModemSetting(const std::string& setting);
void writeModemSetting(const std::string& setting, std::string value);
ModemSettings readModemSettings();
void writeModemSettings(ModemSettings settings);

View File

@ -1,7 +1,6 @@
// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+
#include "CubicSDRDefs.h"
#include "DemodulatorThread.h"
#include "DemodulatorInstance.h"
#include "CubicSDR.h"
@ -23,12 +22,8 @@ DemodulatorInstance* DemodulatorThread::squelchLock(nullptr);
std::mutex DemodulatorThread::squelchLockMutex;
DemodulatorThread::DemodulatorThread(DemodulatorInstance* parent)
: IOThread(), outputBuffers("DemodulatorThreadBuffers"), squelchLevel(-100),
signalLevel(-100), signalFloor(-30), signalCeil(30), squelchEnabled(false) {
demodInstance = parent;
muted.store(false);
squelchBreak = false;
: IOThread(), demodInstance(parent), outputBuffers("DemodulatorThreadBuffers"), muted(false), squelchLevel(-100),
signalLevel(-100), signalFloor(-30), signalCeil(30), squelchEnabled(false), squelchBreak(false) {
}
DemodulatorThread::~DemodulatorThread() {
@ -83,7 +78,6 @@ void DemodulatorThread::run() {
iqInputQueue = std::static_pointer_cast<DemodulatorThreadPostInputQueue>(getInputQueue("IQDataInput"));
audioOutputQueue = std::static_pointer_cast<AudioThreadInputQueue>(getOutputQueue("AudioDataOutput"));
threadQueueControl = std::static_pointer_cast<DemodulatorThreadControlCommandQueue>(getInputQueue("ControlQueue"));
ModemIQData modemData;
@ -148,7 +142,7 @@ void DemodulatorThread::run() {
double currentSignalLevel = 0;
double sampleTime = double(inp->data.size()) / double(inp->sampleRate);
if (audioOutputQueue != nullptr && ati && ati->data.size()) {
if (audioOutputQueue != nullptr && ati && !ati->data.empty()) {
double accum = 0;
if (cModem->useSignalOutput()) {
@ -168,7 +162,7 @@ void DemodulatorThread::run() {
currentSignalLevel = linearToDb(accum / double(inp->data.size()));
}
float sf = signalFloor.load(), sc = signalCeil.load(), sl = squelchLevel.load();
float sf = signalFloor, sc = signalCeil, sl = squelchLevel;
if (currentSignalLevel > sc) {
@ -191,8 +185,8 @@ void DemodulatorThread::run() {
sc -= (sc - (currentSignalLevel + 2.0f)) * sampleTime * 0.05f;
sf += ((currentSignalLevel - 5.0f) - sf) * sampleTime * 0.15f;
signalFloor.store(sf);
signalCeil.store(sc);
signalFloor = sf;
signalCeil = sc;
}
if (currentSignalLevel > signalLevel) {
@ -322,7 +316,7 @@ void DemodulatorThread::run() {
}
if (!squelched && ati != nullptr) {
if (!muted.load() && (!wxGetApp().getSoloMode() || (demodInstance ==
if (!muted && (!wxGetApp().getSoloMode() || (demodInstance ==
wxGetApp().getDemodMgr().getCurrentModem().get()))) {
//non-blocking push needed for audio out
if (!audioOutputQueue->try_push(ati)) {
@ -349,23 +343,6 @@ void DemodulatorThread::run() {
std::this_thread::yield();
}
}
DemodulatorThreadControlCommand command;
//empty command queue, execute commands
while (threadQueueControl->try_pop(command)) {
switch (command.cmd) {
case DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON:
squelchEnabled = true;
break;
case DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_OFF:
squelchEnabled = false;
break;
default:
break;
}
}
}
// end while !stopping
@ -382,27 +359,34 @@ void DemodulatorThread::terminate() {
//unblock the curretly blocked push()
iqInputQueue->flush();
audioOutputQueue->flush();
threadQueueControl->flush();
}
bool DemodulatorThread::isMuted() {
return muted.load();
return muted;
}
void DemodulatorThread::setMuted(bool muted) {
this->muted.store(muted);
void DemodulatorThread::setMuted(bool muted_in) {
muted = muted_in;
}
float DemodulatorThread::getSignalLevel() {
return signalLevel.load();
return signalLevel;
}
float DemodulatorThread::getSignalFloor() {
return signalFloor.load();
return signalFloor;
}
float DemodulatorThread::getSignalCeil() {
return signalCeil.load();
return signalCeil;
}
void DemodulatorThread::setSquelchEnabled(bool squelchEnabled_in) {
squelchEnabled = squelchEnabled_in;
}
bool DemodulatorThread::isSquelchEnabled() {
return squelchEnabled;
}
void DemodulatorThread::setSquelchLevel(float signal_level_in) {

View File

@ -21,19 +21,21 @@ class DemodulatorInstance;
class DemodulatorThread : public IOThread {
public:
DemodulatorThread(DemodulatorInstance* parent);
virtual ~DemodulatorThread();
explicit DemodulatorThread(DemodulatorInstance* parent);
~DemodulatorThread() override;
void onBindOutput(std::string name, ThreadQueueBasePtr threadQueue);
void onBindOutput(std::string name, ThreadQueueBasePtr threadQueue) override;
virtual void run();
virtual void terminate();
void run() override;
void terminate() override;
void setMuted(bool state);
void setMuted(bool muted_in);
bool isMuted();
float getSignalLevel();
float getSignalCeil();
void setSquelchEnabled(bool squelchEnabled_in);
bool isSquelchEnabled();
float getSignalFloor();
void setSquelchLevel(float signal_level_in);
float getSquelchLevel();
@ -54,7 +56,7 @@ protected:
std::atomic<float> squelchLevel;
std::atomic<float> signalLevel, signalFloor, signalCeil;
bool squelchEnabled, squelchBreak;
std::atomic<bool> squelchEnabled, squelchBreak;
static DemodulatorInstance* squelchLock;
static std::mutex squelchLockMutex;
@ -66,8 +68,6 @@ protected:
DemodulatorThreadPostInputQueuePtr iqInputQueue;
AudioThreadInputQueuePtr audioOutputQueue;
DemodulatorThreadOutputQueuePtr audioVisOutputQueue;
DemodulatorThreadControlCommandQueuePtr threadQueueControl;
DemodulatorThreadOutputQueuePtr audioSinkOutputQueue = nullptr;
//protects the audioVisOutputQueue dynamic binding change at runtime (in DemodulatorMgr)

View File

@ -2,9 +2,7 @@
// SPDX-License-Identifier: GPL-2.0+
#include "DemodulatorWorkerThread.h"
#include "CubicSDRDefs.h"
#include "CubicSDR.h"
#include <vector>
//50 ms
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
@ -13,8 +11,7 @@ DemodulatorWorkerThread::DemodulatorWorkerThread() : IOThread(),
cModem(nullptr), cModemKit(nullptr) {
}
DemodulatorWorkerThread::~DemodulatorWorkerThread() {
}
DemodulatorWorkerThread::~DemodulatorWorkerThread() = default;
void DemodulatorWorkerThread::run() {
@ -40,11 +37,11 @@ void DemodulatorWorkerThread::run() {
}
switch (command.cmd) {
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
case DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
filterChanged = true;
filterCommand = command;
break;
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD:
case DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD:
makeDemod = true;
demodCommand = command;
break;
@ -55,7 +52,7 @@ void DemodulatorWorkerThread::run() {
} //end while done.
if ((makeDemod || filterChanged) && !stopping) {
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_FILTERS);
if (filterCommand.sampleRate) {
@ -66,7 +63,7 @@ void DemodulatorWorkerThread::run() {
cModem = Modem::makeModem(demodCommand.demodType);
cModemName = cModem->getName();
cModemType = cModem->getType();
if (demodCommand.settings.size()) {
if (!demodCommand.settings.empty()) {
cModem->writeSettings(demodCommand.settings);
}
result.sampleRate = demodCommand.sampleRate;

View File

@ -14,28 +14,28 @@
class DemodulatorWorkerThreadResult {
public:
enum DemodulatorThreadResultEnum {
enum class Type {
DEMOD_WORKER_THREAD_RESULT_NULL, DEMOD_WORKER_THREAD_RESULT_FILTERS
};
DemodulatorWorkerThreadResult() :
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr), modemType("") {
cmd(DemodulatorWorkerThreadResult::Type::DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
}
DemodulatorWorkerThreadResult(DemodulatorThreadResultEnum cmd) :
explicit DemodulatorWorkerThreadResult(DemodulatorWorkerThreadResult::Type cmd) :
DemodulatorWorkerThreadResult() {
this->cmd = cmd;
}
DemodulatorThreadResultEnum cmd;
DemodulatorWorkerThreadResult::Type cmd;
msresamp_crcf iqResampler;
double iqResampleRatio;
long long sampleRate;
unsigned int bandwidth;
Modem *modem;
Modem *modem{};
ModemKit *modemKit;
std::string modemType;
std::string modemName;
@ -43,21 +43,21 @@ public:
class DemodulatorWorkerThreadCommand {
public:
enum DemodulatorThreadCommandEnum {
enum class Type {
DEMOD_WORKER_THREAD_CMD_NULL, DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS, DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD
};
DemodulatorWorkerThreadCommand() :
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
cmd(DemodulatorWorkerThreadCommand::Type::DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
}
DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
explicit DemodulatorWorkerThreadCommand(DemodulatorWorkerThreadCommand::Type cmd) :
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
}
DemodulatorThreadCommandEnum cmd;
DemodulatorWorkerThreadCommand::Type cmd;
long long frequency;
long long sampleRate;
@ -77,9 +77,9 @@ class DemodulatorWorkerThread : public IOThread {
public:
DemodulatorWorkerThread();
virtual ~DemodulatorWorkerThread();
~DemodulatorWorkerThread() override;
virtual void run();
void run() override;
void setCommandQueue(DemodulatorThreadWorkerCommandQueuePtr tQueue) {
commandQueue = tQueue;
@ -89,7 +89,7 @@ public:
resultQueue = tQueue;
}
virtual void terminate();
void terminate() override;
protected:

View File

@ -5,7 +5,6 @@
#include <wx/textdlg.h>
#include <algorithm>
#include <wchar.h>
#include "BookmarkView.h"
#include "CubicSDR.h"
@ -25,10 +24,10 @@
#define BOOKMARK_VIEW_STR_RENAME_GROUP "Rename Group"
BookmarkViewVisualDragItem::BookmarkViewVisualDragItem(wxString labelValue) : wxDialog(NULL, wxID_ANY, L"", wxPoint(20,20), wxSize(-1,-1), wxFRAME_TOOL_WINDOW | wxNO_BORDER | wxSTAY_ON_TOP | wxALL ) {
BookmarkViewVisualDragItem::BookmarkViewVisualDragItem(const wxString& labelValue) : wxDialog(nullptr, wxID_ANY, L"", wxPoint(20,20), wxSize(-1,-1), wxFRAME_TOOL_WINDOW | wxNO_BORDER | wxSTAY_ON_TOP | wxALL ) {
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxStaticText *label = new wxStaticText( this, wxID_ANY, labelValue, wxDefaultPosition, wxDefaultSize, wxEXPAND );
auto *sizer = new wxBoxSizer(wxVERTICAL);
auto *label = new wxStaticText( this, wxID_ANY, labelValue, wxDefaultPosition, wxDefaultSize, wxEXPAND );
sizer->Add(label, 1, wxALL | wxEXPAND, 5);
@ -38,12 +37,12 @@ BookmarkViewVisualDragItem::BookmarkViewVisualDragItem(wxString labelValue) : wx
class ActionDialogRemoveBookmark : public ActionDialog {
public:
ActionDialogRemoveBookmark( BookmarkEntryPtr be ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Remove Bookmark?")) {
explicit ActionDialogRemoveBookmark( BookmarkEntryPtr be ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Remove Bookmark?")) {
subject = be;
m_questionText->SetLabelText(wxT("Are you sure you want to remove the bookmark\n '" + BookmarkMgr::getBookmarkEntryDisplayName(subject) + "'?"));
}
void doClickOK() {
void doClickOK() override {
wxGetApp().getBookmarkMgr().removeBookmark(subject);
wxGetApp().getBookmarkMgr().updateBookmarks();
}
@ -54,12 +53,12 @@ private:
class ActionDialogRemoveGroup : public ActionDialog {
public:
ActionDialogRemoveGroup( std::string groupName ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Remove Group?")) {
explicit ActionDialogRemoveGroup( std::string groupName ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Remove Group?")) {
subject = groupName;
m_questionText->SetLabelText(wxT("Warning: Are you sure you want to remove the group\n '" + subject + "' AND ALL BOOKMARKS WITHIN IT?"));
}
void doClickOK() {
void doClickOK() override {
wxGetApp().getBookmarkMgr().removeGroup(subject);
wxGetApp().getBookmarkMgr().updateBookmarks();
}
@ -71,7 +70,7 @@ private:
class ActionDialogRemoveRange : public ActionDialog {
public:
ActionDialogRemoveRange( BookmarkRangeEntryPtr rangeEnt ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Remove Range?")) {
explicit ActionDialogRemoveRange( const BookmarkRangeEntryPtr& rangeEnt ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Remove Range?")) {
subject = rangeEnt;
std::wstring name = rangeEnt->label;
@ -85,7 +84,7 @@ public:
m_questionText->SetLabelText(L"Are you sure you want to remove the range\n '" + name + L"'?");
}
void doClickOK() {
void doClickOK() override {
wxGetApp().getBookmarkMgr().removeRange(subject);
wxGetApp().getBookmarkMgr().updateActiveList();
}
@ -97,7 +96,7 @@ private:
class ActionDialogUpdateRange : public ActionDialog {
public:
ActionDialogUpdateRange( BookmarkRangeEntryPtr rangeEnt ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Update Range?")) {
explicit ActionDialogUpdateRange( const BookmarkRangeEntryPtr& rangeEnt ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Update Range?")) {
subject = rangeEnt;
std::wstring name = rangeEnt->label;
@ -111,7 +110,7 @@ public:
m_questionText->SetLabelText(L"Are you sure you want to update the range\n '" + name + L"' to the active range?");
}
void doClickOK() {
void doClickOK() override {
BookmarkRangeEntryPtr ue = BookmarkView::makeActiveRangeEntry();
subject->freq = ue->freq;
@ -232,7 +231,7 @@ void BookmarkView::updateBookmarks() {
}
void BookmarkView::updateBookmarks(std::string group) {
void BookmarkView::updateBookmarks(const std::string& group) {
doUpdateBookmarkGroup.insert(group);
doUpdateBookmarks.store(true);
}
@ -241,7 +240,7 @@ bool BookmarkView::isKeywordMatch(std::wstring search_str, std::vector<std::wstr
wstring str = search_str;
std::transform(str.begin(), str.end(), str.begin(), towlower);
for (auto k : keywords) {
for (const auto& k : keywords) {
if (str.find(k) == wstring::npos) {
return false;
}
@ -257,19 +256,19 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
TreeViewItem* prevSel = itemToTVI(m_treeView->GetSelection());
TreeViewItem* prevSelCopy = nullptr;
if (prevSel != NULL) {
if (prevSel != nullptr) {
prevSelCopy = new TreeViewItem(*prevSel);
}
BookmarkNames groupNames;
wxGetApp().getBookmarkMgr().getGroups(groupNames);
BookmarkNames groupNameList;
wxGetApp().getBookmarkMgr().getGroups(groupNameList);
doUpdateBookmarkGroup.clear();
wxTreeItemId bmSelFound = nullptr;
std::map<std::string, bool> groupExpandState;
bool searchState = (searchKeywords.size() != 0);
bool searchState = !searchKeywords.empty();
groups.clear();
@ -277,16 +276,16 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
bool bmExpandState = expandState["bookmark"];
for (auto gn_i : groupNames) {
TreeViewItem* tvi = new TreeViewItem();
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP;
for (const auto& gn_i : groupNameList) {
auto* tvi = new TreeViewItem();
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP;
tvi->groupName = gn_i;
wxTreeItemId group_itm = m_treeView->AppendItem(bookmarkBranch, gn_i);
SetTreeItemData(group_itm, tvi);
groups[gn_i] = group_itm;
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP && gn_i == prevSelCopy->groupName) {
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP && gn_i == prevSelCopy->groupName) {
bmSelFound = group_itm;
} else if (nextGroup != "" && gn_i == nextGroup) {
} else if (!nextGroup.empty() && gn_i == nextGroup) {
bmSelFound = group_itm;
nextGroup = "";
}
@ -298,7 +297,7 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
m_treeView->Collapse(bookmarkBranch);
}
for (auto gn_i : groupNames) {
for (const auto& gn_i : groupNameList) {
wxTreeItemId groupItem = groups[gn_i];
bool groupExpanded = searchState || wxGetApp().getBookmarkMgr().getExpandState(gn_i);
@ -324,14 +323,14 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
}
}
TreeViewItem* tvi = new TreeViewItem();
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK;
auto* tvi = new TreeViewItem();
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK;
tvi->bookmarkEnt = bmEnt;
tvi->groupName = gn_i;
wxTreeItemId itm = m_treeView->AppendItem(groupItem, labelVal);
SetTreeItemData(itm, tvi);
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK && prevSelCopy->bookmarkEnt == bmEnt && groupExpanded) {
if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK && prevSelCopy->bookmarkEnt == bmEnt && groupExpanded) {
bmSelFound = itm;
}
if (nextEnt == bmEnt) {
@ -361,7 +360,7 @@ void BookmarkView::doUpdateActiveList() {
TreeViewItem* prevSel = itemToTVI(m_treeView->GetSelection());
TreeViewItem* prevSelCopy = nullptr;
if (prevSel != NULL) {
if (prevSel != nullptr) {
prevSelCopy = new TreeViewItem(*prevSel);
}
@ -369,10 +368,10 @@ void BookmarkView::doUpdateActiveList() {
m_treeView->DeleteChildren(activeBranch);
bool activeExpandState = expandState["active"];
bool searchState = (searchKeywords.size() != 0);
bool searchState = !searchKeywords.empty();
wxTreeItemId selItem = nullptr;
for (auto demod_i : demods) {
for (const auto& demod_i : demods) {
wxString activeLabel = BookmarkMgr::getActiveDisplayName(demod_i);
if (searchState) {
@ -392,8 +391,8 @@ void BookmarkView::doUpdateActiveList() {
}
}
TreeViewItem* tvi = new TreeViewItem();
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE;
auto* tvi = new TreeViewItem();
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE;
tvi->demod = demod_i;
wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel);
@ -407,7 +406,7 @@ void BookmarkView::doUpdateActiveList() {
}
}
bool rangeExpandState = searchState?false:expandState["range"];
bool rangeExpandState = !searchState && expandState["range"];
//Ranges
BookmarkRangeList bmRanges = wxGetApp().getBookmarkMgr().getRanges();
@ -415,13 +414,13 @@ void BookmarkView::doUpdateActiveList() {
m_treeView->DeleteChildren(rangeBranch);
for (auto &re_i: bmRanges) {
TreeViewItem* tvi = new TreeViewItem();
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE;
auto* tvi = new TreeViewItem();
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE;
tvi->rangeEnt = re_i;
std::wstring labelVal = re_i->label;
if (labelVal == L"") {
if (labelVal.empty()) {
std::string wstr = frequencyToStr(re_i->startFreq) + " - " + frequencyToStr(re_i->endFreq);
labelVal = wxString(wstr).ToStdWstring();
@ -433,7 +432,7 @@ void BookmarkView::doUpdateActiveList() {
if (nextRange == re_i) {
selItem = itm;
nextRange = nullptr;
} else if (!selItem && rangeExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE && prevSelCopy->rangeEnt == re_i) {
} else if (!selItem && rangeExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE && prevSelCopy->rangeEnt == re_i) {
selItem = itm;
}
}
@ -446,20 +445,20 @@ void BookmarkView::doUpdateActiveList() {
m_treeView->DeleteChildren(recentBranch);
for (auto &bmr_i: bmRecents) {
TreeViewItem* tvi = new TreeViewItem();
tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT;
auto* tvi = new TreeViewItem();
tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT;
tvi->bookmarkEnt = bmr_i;
std::wstring labelVal;
bmr_i->node->child("user_label")->element()->get(labelVal);
if (labelVal == L"") {
if (labelVal.empty()) {
std::string str = frequencyToStr(bmr_i->frequency) + " " + bmr_i->type;
labelVal = wxString(str).ToStdWstring();
}
if (searchKeywords.size()) {
if (!searchKeywords.empty()) {
std::string freqStr = frequencyToStr(bmr_i->frequency);
std::string bwStr = frequencyToStr(bmr_i->bandwidth);
@ -482,7 +481,7 @@ void BookmarkView::doUpdateActiveList() {
if (nextEnt == bmr_i) {
selItem = itm;
nextEnt = nullptr;
} else if (!selItem && recentExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT && prevSelCopy->bookmarkEnt == bmr_i) {
} else if (!selItem && recentExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT && prevSelCopy->bookmarkEnt == bmr_i) {
selItem = itm;
}
}
@ -539,15 +538,15 @@ void BookmarkView::onKeyUp( wxKeyEvent& event ) {
// Handlers
if (event.m_keyCode == WXK_DELETE || event.m_keyCode == WXK_NUMPAD_DELETE) {
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
onRemoveActive(treeEvent);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
onRemoveRecent(treeEvent);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
onRemoveBookmark(treeEvent);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
onRemoveRange(treeEvent);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
onRemoveGroup(treeEvent);
}
@ -559,28 +558,28 @@ void BookmarkView::onKeyUp( wxKeyEvent& event ) {
void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
wxTreeItemId itm = event.GetItem();
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));
auto* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));
if (tvi == nullptr) {
event.Skip();
return;
}
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (!tvi->demod->isActive()) {
wxGetApp().setFrequency(tvi->demod->getFrequency());
nextDemod = tvi->demod;
wxGetApp().getDemodMgr().setActiveDemodulator(nextDemod, false);
}
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
nextEnt = tvi->bookmarkEnt;
wxGetApp().getBookmarkMgr().removeRecent(tvi->bookmarkEnt);
activateBookmark(tvi->bookmarkEnt);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
activateBookmark(tvi->bookmarkEnt);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
activateRange(tvi->rangeEnt);
}
}
@ -588,7 +587,7 @@ void BookmarkView::onTreeActivate( wxTreeEvent& event ) {
void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
bool searchState = (searchKeywords.size() != 0);
bool searchState = !searchKeywords.empty();
if (searchState) {
event.Skip();
@ -607,7 +606,7 @@ void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
TreeViewItem *tvi = itemToTVI(event.GetItem());
if (tvi != nullptr) {
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
wxGetApp().getBookmarkMgr().setExpandState(tvi->groupName,false);
}
}
@ -618,7 +617,7 @@ void BookmarkView::onTreeCollapse( wxTreeEvent& event ) {
void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {
bool searchState = (searchKeywords.size() != 0);
bool searchState = !searchKeywords.empty();
if (searchState) {
event.Skip();
@ -637,7 +636,7 @@ void BookmarkView::onTreeExpanded( wxTreeEvent& event ) {
TreeViewItem *tvi = itemToTVI(event.GetItem());
if (tvi != nullptr) {
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
wxGetApp().getBookmarkMgr().setExpandState(tvi->groupName,true);
}
}
@ -651,7 +650,7 @@ void BookmarkView::onTreeItemMenu( wxTreeEvent& /* event */ ) {
if (m_treeView->GetSelection() == bookmarkBranch) {
wxMenu menu;
menu.Append(wxCONTEXT_ADD_GROUP_ID, BOOKMARK_VIEW_STR_ADD_GROUP);
menu.Connect(wxCONTEXT_ADD_GROUP_ID, wxEVT_MENU, (wxObjectEventFunction)&BookmarkView::onMenuItem, nullptr, this);
menu.Connect(wxCONTEXT_ADD_GROUP_ID, wxEVT_MENU, wxCommandEventHandler(BookmarkView::onMenuItem), nullptr, this);
PopupMenu(&menu);
}
}
@ -676,12 +675,12 @@ bool BookmarkView::isMouseInView() {
}
bool BookmarkView::getExpandState(std::string branchName) {
bool BookmarkView::getExpandState(const std::string& branchName) {
return expandState[branchName];
}
void BookmarkView::setExpandState(std::string branchName, bool state) {
void BookmarkView::setExpandState(const std::string& branchName, bool state) {
expandState[branchName] = state;
}
@ -741,29 +740,29 @@ void BookmarkView::refreshLayout() {
}
wxButton *BookmarkView::makeButton(wxWindow * /* parent */, std::string labelVal, wxObjectEventFunction handler) {
wxButton *nButton = new wxButton( m_buttonPanel, wxID_ANY, labelVal);
wxButton *BookmarkView::makeButton(wxWindow * /* parent */, const std::string& labelVal, wxObjectEventFunction handler) {
auto *nButton = new wxButton( m_buttonPanel, wxID_ANY, labelVal);
nButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, handler, nullptr, this);
return nButton;
}
wxButton *BookmarkView::addButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler) {
wxButton *BookmarkView::addButton(wxWindow *parent, const std::string& labelVal, wxObjectEventFunction handler) {
wxButton *nButton = makeButton(parent, labelVal, handler);
parent->GetSizer()->Add( nButton, 0, wxEXPAND);
return nButton;
}
void BookmarkView::doBookmarkActive(std::string group, DemodulatorInstancePtr demod) {
void BookmarkView::doBookmarkActive(const std::string& group, const DemodulatorInstancePtr& demod) {
wxGetApp().getBookmarkMgr().addBookmark(group, demod);
wxGetApp().getBookmarkMgr().updateBookmarks();
}
void BookmarkView::doBookmarkRecent(std::string group, BookmarkEntryPtr be) {
void BookmarkView::doBookmarkRecent(const std::string& group, const BookmarkEntryPtr& be) {
wxGetApp().getBookmarkMgr().addBookmark(group, be);
nextEnt = be;
@ -773,7 +772,7 @@ void BookmarkView::doBookmarkRecent(std::string group, BookmarkEntryPtr be) {
}
void BookmarkView::doMoveBookmark(BookmarkEntryPtr be, std::string group) {
void BookmarkView::doMoveBookmark(const BookmarkEntryPtr& be, const std::string& group) {
wxGetApp().getBookmarkMgr().moveBookmark(be, group);
nextEnt = be;
wxGetApp().getBookmarkMgr().updateBookmarks();
@ -781,14 +780,14 @@ void BookmarkView::doMoveBookmark(BookmarkEntryPtr be, std::string group) {
}
void BookmarkView::doRemoveActive(DemodulatorInstancePtr demod) {
void BookmarkView::doRemoveActive(const DemodulatorInstancePtr& demod) {
wxGetApp().getBookmarkMgr().removeActive(demod);
wxGetApp().getBookmarkMgr().updateActiveList();
}
void BookmarkView::doRemoveRecent(BookmarkEntryPtr be) {
void BookmarkView::doRemoveRecent(const BookmarkEntryPtr& be) {
wxGetApp().getBookmarkMgr().removeRecent(be);
wxGetApp().getBookmarkMgr().updateActiveList();
}
@ -805,7 +804,7 @@ void BookmarkView::updateBookmarkChoices() {
TreeViewItem *activeSel = itemToTVI(m_treeView->GetSelection());
bookmarkChoices.push_back(((activeSel != nullptr && activeSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK))?BOOKMARK_VIEW_CHOICE_MOVE:BOOKMARK_VIEW_CHOICE_DEFAULT);
bookmarkChoices.push_back(((activeSel != nullptr && activeSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK))?BOOKMARK_VIEW_CHOICE_MOVE:BOOKMARK_VIEW_CHOICE_DEFAULT);
wxGetApp().getBookmarkMgr().getGroups(bookmarkChoices);
bookmarkChoices.push_back(BOOKMARK_VIEW_CHOICE_NEW);
}
@ -814,7 +813,7 @@ void BookmarkView::addBookmarkChoice(wxWindow *parent) {
updateBookmarkChoices();
bookmarkChoice = new wxChoice(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, bookmarkChoices, wxEXPAND, wxDefaultValidator, "Bookmark");
bookmarkChoice->Select(0);
bookmarkChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&BookmarkView::onBookmarkChoice, nullptr, this);
bookmarkChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(BookmarkView::onBookmarkChoice), nullptr, this);
parent->GetSizer()->Add(bookmarkChoice, 0, wxALL | wxEXPAND);
}
@ -838,24 +837,24 @@ void BookmarkView::onBookmarkChoice( wxCommandEvent & /* event */ ) {
stringVal = bookmarkChoices[sel];
}
if (stringVal == "") {
if (stringVal.empty()) {
return;
}
if (tvi != nullptr) {
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
doBookmarkActive(stringVal.ToStdString(), tvi->demod);
}
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
doBookmarkRecent(stringVal.ToStdString(), tvi->bookmarkEnt);
}
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
doMoveBookmark(tvi->bookmarkEnt, stringVal.ToStdString());
}
}
}
void BookmarkView::activeSelection(DemodulatorInstancePtr dsel) {
void BookmarkView::activeSelection(const DemodulatorInstancePtr& dsel) {
if (dsel == nullptr) {
hideProps();
@ -901,7 +900,7 @@ void BookmarkView::activeSelection(DemodulatorInstancePtr dsel) {
}
void BookmarkView::activateBookmark(BookmarkEntryPtr bmEnt) {
void BookmarkView::activateBookmark(const BookmarkEntryPtr& bmEnt) {
wxTreeItemId selItem = m_treeView->GetSelection();
if (selItem) {
@ -942,7 +941,7 @@ void BookmarkView::activateBookmark(BookmarkEntryPtr bmEnt) {
}
void BookmarkView::activateRange(BookmarkRangeEntryPtr rangeEnt) {
void BookmarkView::activateRange(const BookmarkRangeEntryPtr& rangeEnt) {
//the following oly works if rangeEnt->freq is the middle of [rangeEnt->startFreq ; rangeEnt->startFreq]
wxGetApp().setFrequency(rangeEnt->freq);
@ -952,7 +951,7 @@ void BookmarkView::activateRange(BookmarkRangeEntryPtr rangeEnt) {
}
void BookmarkView::bookmarkSelection(BookmarkEntryPtr bmSel) {
void BookmarkView::bookmarkSelection(const BookmarkEntryPtr& bmSel) {
m_frequencyVal->SetLabelText(frequencyToStr(bmSel->frequency));
m_bandwidthVal->SetLabelText(frequencyToStr(bmSel->bandwidth));
@ -985,7 +984,7 @@ void BookmarkView::bookmarkSelection(BookmarkEntryPtr bmSel) {
}
void BookmarkView::recentSelection(BookmarkEntryPtr bmSel) {
void BookmarkView::recentSelection(const BookmarkEntryPtr& bmSel) {
m_frequencyVal->SetLabelText(frequencyToStr(bmSel->frequency));
m_bandwidthVal->SetLabelText(frequencyToStr(bmSel->bandwidth));
@ -1017,7 +1016,7 @@ void BookmarkView::recentSelection(BookmarkEntryPtr bmSel) {
refreshLayout();
}
void BookmarkView::groupSelection(std::string groupName) {
void BookmarkView::groupSelection(const std::string& groupName) {
clearButtons();
@ -1037,7 +1036,7 @@ void BookmarkView::groupSelection(std::string groupName) {
}
void BookmarkView::rangeSelection(BookmarkRangeEntryPtr re) {
void BookmarkView::rangeSelection(const BookmarkRangeEntryPtr& re) {
clearButtons();
hideProps(false);
@ -1118,7 +1117,7 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
}
wxTreeItemId itm = event.GetItem();
TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));
auto* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));
if (!tvi) {
@ -1138,20 +1137,20 @@ void BookmarkView::onTreeSelect( wxTreeEvent& event ) {
return;
}
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
activeSelection(tvi->demod);
if (tvi->demod->isActive()) {
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
wxGetApp().getDemodMgr().setActiveDemodulator(tvi->demod, false);
tvi->demod->setTracking(true);
}
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
recentSelection(tvi->bookmarkEnt);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
bookmarkSelection(tvi->bookmarkEnt);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
groupSelection(tvi->groupName);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
rangeSelection(tvi->rangeEnt);
} else {
hideProps();
@ -1179,24 +1178,24 @@ void BookmarkView::onLabelText( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel != nullptr) {
if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
curSel->demod->setDemodulatorUserLabel(newLabel);
wxGetApp().getBookmarkMgr().updateActiveList();
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
curSel->bookmarkEnt->label = m_labelText->GetValue().ToStdWstring();
curSel->bookmarkEnt->node->child("user_label")->element()->set(newLabel);
wxGetApp().getBookmarkMgr().updateBookmarks();
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
curSel->bookmarkEnt->label = m_labelText->GetValue().ToStdWstring();
curSel->bookmarkEnt->node->child("user_label")->element()->set(newLabel);
wxGetApp().getBookmarkMgr().updateActiveList();
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
curSel->rangeEnt->label = m_labelText->GetValue().ToStdWstring();
wxGetApp().getBookmarkMgr().updateActiveList();
} else if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
} else if (curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
std::string newGroupName = m_labelText->GetValue().ToStdString();
if (newGroupName != "" && newGroupName != curSel->groupName) {
if (!newGroupName.empty() && newGroupName != curSel->groupName) {
wxGetApp().getBookmarkMgr().renameGroup(curSel->groupName, newGroupName);
nextGroup = newGroupName;
wxGetApp().getBookmarkMgr().updateBookmarks();
@ -1212,7 +1211,7 @@ void BookmarkView::onDoubleClickFreq( wxMouseEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
wxGetApp().getDemodMgr().setActiveDemodulator(curSel->demod, false);
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT);
@ -1224,7 +1223,7 @@ void BookmarkView::onDoubleClickBandwidth( wxMouseEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
wxGetApp().getDemodMgr().setActiveDemodulator(curSel->demod, false);
wxGetApp().showFrequencyInput(FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH);
@ -1236,7 +1235,7 @@ void BookmarkView::onRemoveActive( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
doRemoveActive(curSel->demod);
}
}
@ -1245,7 +1244,7 @@ void BookmarkView::onStartRecording( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (!curSel->demod->isRecording() && wxGetApp().getConfig()->verifyRecordingPath()) {
curSel->demod->setRecording(true);
@ -1259,7 +1258,7 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (curSel->demod->isRecording()) {
curSel->demod->setRecording(false);
@ -1273,7 +1272,7 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveBookmark( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
ActionDialog::showDialog(new ActionDialogRemoveBookmark(curSel->bookmarkEnt));
}
}
@ -1283,7 +1282,7 @@ void BookmarkView::onActivateBookmark( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
activateBookmark(curSel->bookmarkEnt);
}
}
@ -1293,7 +1292,7 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
BookmarkEntryPtr bookmarkEntToActivate = curSel->bookmarkEnt;
//let removeRecent() + activateBookmark() refresh the tree
@ -1308,13 +1307,12 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
BookmarkEntryPtr bookmarkEntToRemove = curSel->bookmarkEnt;
//let removeRecent() + updateActiveList() refresh the tree
//and delete the recent node properly...
wxGetApp().getBookmarkMgr().removeRecent(bookmarkEntToRemove);
wxGetApp().getBookmarkMgr().updateActiveList();
doRemoveRecent(bookmarkEntToRemove);
}
}
@ -1326,7 +1324,7 @@ void BookmarkView::onClearRecents ( wxCommandEvent& /* event */ ) {
void BookmarkView::onAddGroup( wxCommandEvent& /* event */ ) {
wxString stringVal = wxGetTextFromUser(BOOKMARK_VIEW_STR_ADD_GROUP_DESC, BOOKMARK_VIEW_STR_ADD_GROUP, "");
if (stringVal.ToStdString() != "") {
if (!stringVal.ToStdString().empty()) {
wxGetApp().getBookmarkMgr().addGroup(stringVal.ToStdString());
wxGetApp().getBookmarkMgr().updateBookmarks();
}
@ -1336,7 +1334,7 @@ void BookmarkView::onAddGroup( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveGroup( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
ActionDialog::showDialog(new ActionDialogRemoveGroup(curSel->groupName));
}
}
@ -1356,7 +1354,7 @@ void BookmarkView::onAddRange( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveRange( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
ActionDialog::showDialog(new ActionDialogRemoveRange(curSel->rangeEnt));
}
}
@ -1366,7 +1364,7 @@ void BookmarkView::onRenameRange( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (!curSel || curSel->type != TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
if (!curSel || curSel->type != TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP) {
return;
}
@ -1375,7 +1373,7 @@ void BookmarkView::onRenameRange( wxCommandEvent& /* event */ ) {
std::string newGroupName = stringVal.Trim().ToStdString();
if (newGroupName != "") {
if (!newGroupName.empty()) {
wxGetApp().getBookmarkMgr().renameGroup(curSel->groupName, newGroupName);
wxGetApp().getBookmarkMgr().updateBookmarks();
}
@ -1385,7 +1383,7 @@ void BookmarkView::onActivateRange( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
activateRange(curSel->rangeEnt);
}
}
@ -1394,7 +1392,7 @@ void BookmarkView::onUpdateRange( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
if (curSel && curSel->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RANGE) {
ActionDialog::showDialog(new ActionDialogUpdateRange(curSel->rangeEnt));
}
}
@ -1416,10 +1414,10 @@ void BookmarkView::onTreeBeginDrag( wxTreeEvent& event ) {
bool bAllow = false;
std::wstring dragItemName;
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
bAllow = true;
dragItemName = BookmarkMgr::getActiveDisplayName(tvi->demod);
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT || tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
} else if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT || tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
bAllow = true;
dragItemName = BookmarkMgr::getBookmarkEntryDisplayName(tvi->bookmarkEnt);
}
@ -1470,33 +1468,24 @@ void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {
if (!tvi) {
if (event.GetItem() == bookmarkBranch) {
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) {
doBookmarkActive(BOOKMARK_VIEW_STR_UNNAMED, dragItem->demod);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) {
doBookmarkRecent(BOOKMARK_VIEW_STR_UNNAMED, dragItem->bookmarkEnt);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
doMoveBookmark(dragItem->bookmarkEnt, BOOKMARK_VIEW_STR_UNNAMED);
}
}
return;
}
if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
if (tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_GROUP || tvi->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) {
if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
doBookmarkActive(tvi->groupName, dragItem->demod);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
m_treeView->Delete(dragItemId);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item
doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);
}
} else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Same Group
doBookmarkActive(tvi->groupName, dragItem->demod);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Same Group
doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
m_treeView->Delete(dragItemId);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Same Group
} else if (dragItem && dragItem->type == TreeViewItem::Type::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item
doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);
}
}
@ -1541,7 +1530,7 @@ void BookmarkView::onMotion( wxMouseEvent& event ) {
event.Skip();
}
void BookmarkView::setStatusText(std::string statusText) {
void BookmarkView::setStatusText(const std::string& statusText) {
//make tooltips active on the tree view.
wxGetApp().getAppFrame()->setStatusText(m_treeView, statusText);
}
@ -1599,10 +1588,10 @@ void BookmarkView::onSearchText( wxCommandEvent& /* event */ ) {
}
}
if (searchKeywords.size() != 0 && !m_clearSearchButton->IsShown()) {
if (!searchKeywords.empty() && !m_clearSearchButton->IsShown()) {
m_clearSearchButton->Show();
refreshLayout();
} else if (searchKeywords.size() == 0 && m_clearSearchButton->IsShown()) {
} else if (searchKeywords.empty() && m_clearSearchButton->IsShown()) {
m_clearSearchButton->Hide();
refreshLayout();
}
@ -1641,10 +1630,8 @@ BookmarkRangeEntryPtr BookmarkView::makeActiveRangeEntry() {
void BookmarkView::SetTreeItemData(const wxTreeItemId& item, wxTreeItemData *data) {
TreeViewItem *itemData = itemToTVI(item);
if (itemData != NULL) {
//cleanup previous data, if any
delete itemData;
}
// cleanup previous data, if any
delete itemData;
m_treeView->SetItemData(item, data);
}

View File

@ -12,7 +12,7 @@
class TreeViewItem : public wxTreeItemData {
public:
enum TreeViewItemType {
enum class Type {
TREEVIEW_ITEM_TYPE_GROUP,
TREEVIEW_ITEM_TYPE_ACTIVE,
TREEVIEW_ITEM_TYPE_RECENT,
@ -34,11 +34,9 @@ public:
groupName = src.groupName;
};
virtual ~TreeViewItem() {
//
};
~TreeViewItem() override = default;
TreeViewItemType type;
TreeViewItem::Type type;
BookmarkEntryPtr bookmarkEnt;
BookmarkRangeEntryPtr rangeEnt;
@ -50,16 +48,16 @@ public:
class BookmarkViewVisualDragItem : public wxDialog {
public:
BookmarkViewVisualDragItem(wxString labelValue = L"Popup");
explicit BookmarkViewVisualDragItem(const wxString& labelValue = L"Popup");
};
class BookmarkView : public BookmarkPanel {
public:
BookmarkView( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxTAB_TRAVERSAL );
explicit BookmarkView( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxTAB_TRAVERSAL );
virtual ~BookmarkView();
~BookmarkView() override;
//order an asynchronous refresh/rebuild of the whole tree,
//will take effect at the next onUpdateTimer() occurence.
@ -68,7 +66,7 @@ public:
//order asynchronous updates of the bookmarks,
//will take effect at the next onUpdateTimer() occurence.
void updateBookmarks();
void updateBookmarks(std::string group);
void updateBookmarks(const std::string& group);
bool isKeywordMatch(std::wstring str, std::vector<std::wstring> &keywords);
@ -77,21 +75,21 @@ public:
void onMenuItem(wxCommandEvent& event);
bool isMouseInView();
bool getExpandState(std::string branchName);
void setExpandState(std::string branchName, bool state);
bool getExpandState(const std::string& branchName);
void setExpandState(const std::string& branchName, bool state);
static BookmarkRangeEntryPtr makeActiveRangeEntry();
protected:
void activeSelection(DemodulatorInstancePtr dsel);
void bookmarkSelection(BookmarkEntryPtr bmSel);
void rangeSelection(BookmarkRangeEntryPtr re);
void activeSelection(const DemodulatorInstancePtr& dsel);
void bookmarkSelection(const BookmarkEntryPtr& bmSel);
void rangeSelection(const BookmarkRangeEntryPtr& re);
void activateBookmark(BookmarkEntryPtr bmEnt);
void activateBookmark(const BookmarkEntryPtr& bmEnt);
void activateRange(BookmarkRangeEntryPtr rangeEnt);
void recentSelection(BookmarkEntryPtr bmSel);
void groupSelection(std::string groupName);
void activateRange(const BookmarkRangeEntryPtr& rangeEnt);
void recentSelection(const BookmarkEntryPtr& bmSel);
void groupSelection(const std::string& groupName);
void bookmarkBranchSelection();
void recentBranchSelection();
void rangeBranchSelection();
@ -101,45 +99,45 @@ protected:
void hideProps(bool hidePanel = true);
void showProps();
void onUpdateTimer( wxTimerEvent& event );
void onUpdateTimer( wxTimerEvent& event ) override;
//refresh / rebuild the whole tree item immediatly
void doUpdateActiveList();
void onKeyUp( wxKeyEvent& event );
void onTreeActivate( wxTreeEvent& event );
void onTreeCollapse( wxTreeEvent& event );
void onTreeExpanded( wxTreeEvent& event );
void onTreeItemMenu( wxTreeEvent& event );
void onTreeSelect( wxTreeEvent& event );
void onTreeSelectChanging( wxTreeEvent& event );
void onLabelKillFocus(wxFocusEvent& event );
void onLabelText( wxCommandEvent& event );
void onDoubleClickFreq( wxMouseEvent& event );
void onDoubleClickBandwidth( wxMouseEvent& event );
void onTreeBeginDrag( wxTreeEvent& event );
void onTreeEndDrag( wxTreeEvent& event );
void onTreeItemGetTooltip( wxTreeEvent& event );
void onEnterWindow( wxMouseEvent& event );
void onLeaveWindow( wxMouseEvent& event );
void onMotion( wxMouseEvent& event );
void onKeyUp( wxKeyEvent& event ) override;
void onTreeActivate( wxTreeEvent& event ) override;
void onTreeCollapse( wxTreeEvent& event ) override;
void onTreeExpanded( wxTreeEvent& event ) override;
void onTreeItemMenu( wxTreeEvent& event ) override;
void onTreeSelect( wxTreeEvent& event ) override;
void onTreeSelectChanging( wxTreeEvent& event ) override;
void onLabelKillFocus(wxFocusEvent& event ) override;
void onLabelText( wxCommandEvent& event ) override;
void onDoubleClickFreq( wxMouseEvent& event ) override;
void onDoubleClickBandwidth( wxMouseEvent& event ) override;
void onTreeBeginDrag( wxTreeEvent& event ) override;
void onTreeEndDrag( wxTreeEvent& event ) override;
void onTreeItemGetTooltip( wxTreeEvent& event ) override;
void onEnterWindow( wxMouseEvent& event ) override;
void onLeaveWindow( wxMouseEvent& event ) override;
void onMotion( wxMouseEvent& event ) override;
void onSearchTextFocus( wxMouseEvent& event );
void onSearchText( wxCommandEvent& event );
void onClearSearch( wxCommandEvent& event );
void onSearchTextFocus( wxMouseEvent& event ) override;
void onSearchText( wxCommandEvent& event ) override;
void onClearSearch( wxCommandEvent& event ) override;
void clearButtons();
void showButtons();
void refreshLayout();
wxButton *makeButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);
wxButton *addButton(wxWindow *parent, std::string labelVal, wxObjectEventFunction handler);
wxButton *makeButton(wxWindow *parent, const std::string& labelVal, wxObjectEventFunction handler);
wxButton *addButton(wxWindow *parent, const std::string& labelVal, wxObjectEventFunction handler);
void doBookmarkActive(std::string group, DemodulatorInstancePtr demod);
void doBookmarkRecent(std::string group, BookmarkEntryPtr be);
void doMoveBookmark(BookmarkEntryPtr be, std::string group);
void doRemoveActive(DemodulatorInstancePtr demod);
void doRemoveRecent(BookmarkEntryPtr be);
void doBookmarkActive(const std::string& group, const DemodulatorInstancePtr& demod);
void doBookmarkRecent(const std::string& group, const BookmarkEntryPtr& be);
void doMoveBookmark(const BookmarkEntryPtr& be, const std::string& group);
void doRemoveActive(const DemodulatorInstancePtr& demod);
void doRemoveRecent(const BookmarkEntryPtr& be);
void doClearRecents();
void updateBookmarkChoices();
@ -184,7 +182,6 @@ protected:
// Bookmarks
std::atomic_bool doUpdateBookmarks;
std::set< std::string > doUpdateBookmarkGroup;
BookmarkNames groupNames;
std::map<std::string, wxTreeItemId> groups;
wxArrayString bookmarkChoices;
wxChoice *bookmarkChoice;
@ -201,6 +198,6 @@ protected:
// Search
std::vector<std::wstring> searchKeywords;
void setStatusText(std::string statusText);
void setStatusText(const std::string& statusText);
};

View File

@ -8,7 +8,7 @@
class AboutDialog : public AboutDialogBase {
public:
AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About"),
explicit AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 530, 420 ),
long style = wxDEFAULT_DIALOG_STYLE );

View File

@ -11,9 +11,7 @@ ActionDialog::ActionDialog( wxWindow* parent, wxWindowID id, const wxString& tit
}
ActionDialog::~ActionDialog() {
}
ActionDialog::~ActionDialog() = default;
void ActionDialog::showDialog(ActionDialog *dlg) {
if (activeDialog) { // rejected

View File

@ -6,11 +6,11 @@
class ActionDialog : public ActionDialogBase {
public:
ActionDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("QuestionTitle"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
~ActionDialog();
explicit ActionDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("QuestionTitle"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
~ActionDialog() override;
void onClickCancel( wxCommandEvent& event );
void onClickOK( wxCommandEvent& event );
void onClickCancel( wxCommandEvent& event ) override;
void onClickOK( wxCommandEvent& event ) override;
virtual void doClickCancel();
virtual void doClickOK();

View File

@ -3,7 +3,7 @@
#include "rs232.h"
#include "CubicSDR.h"
PortSelectorDialog::PortSelectorDialog( wxWindow* parent, wxWindowID id, std::string defaultPort ) : PortSelectorDialogBase(parent, id) {
PortSelectorDialog::PortSelectorDialog( wxWindow* parent, wxWindowID id, const std::string& defaultPort ) : PortSelectorDialogBase(parent, id) {
comEnumerate();
int nPorts = comGetNoPorts();

View File

@ -2,11 +2,11 @@
class PortSelectorDialog : public PortSelectorDialogBase {
public:
PortSelectorDialog( wxWindow* parent, wxWindowID id = wxID_ANY, std::string defaultPort = "" );
explicit PortSelectorDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const std::string& defaultPort = "" );
protected:
void onListSelect( wxCommandEvent& event );
void onCancelButton( wxCommandEvent& event );
void onOKButton( wxCommandEvent& event );
void onClose( wxCloseEvent& event );
void onListSelect( wxCommandEvent& event ) override;
void onCancelButton( wxCommandEvent& event ) override;
void onOKButton( wxCommandEvent& event ) override;
void onClose( wxCloseEvent& event ) override;
};

View File

@ -51,7 +51,7 @@ void DigitalConsole::OnClear( wxCommandEvent& /* event */ ) {
m_dataView->Clear();
}
void DigitalConsole::write(std::string outp) {
void DigitalConsole::write(const std::string& outp) {
if (streamPaused.load()) {
return;
}
@ -76,13 +76,11 @@ ModemDigitalOutputConsole::ModemDigitalOutputConsole(): ModemDigitalOutput(), di
streamWritten.store(false);
}
ModemDigitalOutputConsole::~ModemDigitalOutputConsole() {
}
ModemDigitalOutputConsole::~ModemDigitalOutputConsole() = default;
void ModemDigitalOutputConsole::setDialog(DigitalConsole *dialog_in) {
dialog = dialog_in;
if (dialog && dialogTitle != "") {
if (dialog && !dialogTitle.empty()) {
dialog->SetTitle(dialogTitle);
}
}
@ -119,7 +117,7 @@ void ModemDigitalOutputConsole::Close() {
dialog = nullptr;
}
void ModemDigitalOutputConsole::setTitle(std::string title) {
void ModemDigitalOutputConsole::setTitle(const std::string& title) {
if (dialog) {
dialog->SetTitle(title);
}

View File

@ -16,19 +16,19 @@ class ModemDigitalOutputConsole;
class DigitalConsole: public DigitalConsoleFrame {
public:
DigitalConsole( wxWindow* parent, ModemDigitalOutputConsole *doParent );
~DigitalConsole();
~DigitalConsole() override;
void write(std::string outp);
void write(const std::string& outp);
void write(char outc);
private:
void DoRefresh( wxTimerEvent& event );
void OnClose( wxCloseEvent& event );
void OnClear( wxCommandEvent& event );
void DoRefresh( wxTimerEvent& event ) override;
void OnClose( wxCloseEvent& event ) override;
void OnClear( wxCommandEvent& event ) override;
void OnCopy( wxCommandEvent& event );
void OnPause( wxCommandEvent& event );
void OnCopy( wxCommandEvent& event ) override;
void OnPause( wxCommandEvent& event ) override;
std::stringstream streamBuf;
std::mutex stream_busy;
@ -40,19 +40,19 @@ private:
class ModemDigitalOutputConsole: public ModemDigitalOutput {
public:
ModemDigitalOutputConsole();
~ModemDigitalOutputConsole();
~ModemDigitalOutputConsole() override;
void setDialog(DigitalConsole *dialog_in);
DigitalConsole *getDialog();
void setTitle(std::string title);
void setTitle(const std::string& title);
void write(std::string outp);
void write(char outc);
void write(std::string outp) override;
void write(char outc) override;
void Show();
void Hide();
void Close();
void Show() override;
void Hide() override;
void Close() override;
private:
DigitalConsole *dialog;

View File

@ -48,7 +48,7 @@ void SDRDeviceAddDialog::OnOkButton( wxCommandEvent& /* event */) {
Close(true);
}
bool SDRDeviceAddDialog::wasOkPressed() {
bool SDRDeviceAddDialog::wasOkPressed() const {
return okPressed;
}

View File

@ -7,13 +7,13 @@
class SDRDeviceAddDialog : public SDRDeviceAddForm {
public:
SDRDeviceAddDialog( wxWindow* parent );
explicit SDRDeviceAddDialog( wxWindow* parent );
void OnSoapyModuleChanged( wxCommandEvent& event );
void OnCancelButton( wxCommandEvent& event );
void OnOkButton( wxCommandEvent& event );
void OnSoapyModuleChanged( wxCommandEvent& event ) override;
void OnCancelButton( wxCommandEvent& event ) override;
void OnOkButton( wxCommandEvent& event ) override;
bool wasOkPressed();
bool wasOkPressed() const;
std::string getSelectedModule();
std::string getModuleParam();

View File

@ -3,7 +3,6 @@
#include "SDRDevices.h"
#include <wx/textdlg.h>
#include <wx/msgdlg.h>
#include "CubicSDR.h"
@ -45,7 +44,7 @@ void SDRDevicesDialog::OnDeleteItem( wxTreeEvent& event ) {
wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg) {
wxPGProperty *prop = NULL;
wxPGProperty *prop = nullptr;
int intVal;
double floatVal;
@ -55,7 +54,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
case SoapySDR::ArgInfo::INT:
try {
intVal = std::stoi(arg.value);
} catch (std::invalid_argument e) {
} catch (const std::invalid_argument &) {
intVal = 0;
}
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
@ -67,7 +66,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
case SoapySDR::ArgInfo::FLOAT:
try {
floatVal = std::stod(arg.value);
} catch (std::invalid_argument e) {
} catch (const std::invalid_argument &) {
floatVal = 0;
}
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
@ -80,13 +79,13 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) );
break;
case SoapySDR::ArgInfo::STRING:
if (arg.options.size()) {
if (!arg.options.empty()) {
intVal = 0;
prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) );
for (stringIter = arg.options.begin(); stringIter != arg.options.end(); stringIter++) {
std::string optName = (*stringIter);
std::string displayName = optName;
if (arg.optionNames.size()) {
if (!arg.optionNames.empty()) {
displayName = arg.optionNames[intVal];
}
@ -103,7 +102,7 @@ wxPGProperty *SDRDevicesDialog::addArgInfoProperty(wxPropertyGrid *pg, SoapySDR:
break;
}
if (prop != NULL) {
if (prop != nullptr) {
prop->SetHelpString(arg.key + ": " + arg.description);
}
@ -157,7 +156,7 @@ void SDRDevicesDialog::refreshDeviceProperties() {
}
//build device settings
for (std::string antenna : antennaOpts) {
for (const std::string& antenna : antennaOpts) {
antennasArg.options.push_back(antenna);
antennasArg.optionNames.push_back(antenna);
}
@ -208,11 +207,11 @@ void SDRDevicesDialog::refreshDeviceProperties() {
runtimeProps.clear();
streamProps.clear();
if (args.size()) {
if (!args.empty()) {
m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings"));
for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) {
SoapySDR::ArgInfo arg = (*args_i);
for (const auto & args_i : args) {
SoapySDR::ArgInfo arg = args_i;
//We-reread the Device configuration, else we use the user settings.
if (dev) {
//Apply saved settings
@ -234,18 +233,18 @@ void SDRDevicesDialog::refreshDeviceProperties() {
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
if (devStreamOpts.size()) {
for (int j = 0, jMax = args.size(); j < jMax; j++) {
if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) {
args[j].value = devStreamOpts[args[j].key];
if (!devStreamOpts.empty()) {
for (auto & arg : args) {
if (devStreamOpts.find(arg.key) != devStreamOpts.end()) {
arg.value = devStreamOpts[arg.key];
}
}
}
if (args.size()) {
if (!args.empty()) {
m_propertyGrid->Append(new wxPropertyCategory("Stream Settings"));
for (SoapySDR::ArgInfo arg : args) {
for (const SoapySDR::ArgInfo& arg : args) {
streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
}
@ -316,7 +315,7 @@ void SDRDevicesDialog::OnAddRemote( wxMouseEvent& /* event */) {
if (module == "SoapyRemote") {
if (!SDREnumerator::hasRemoteModule()) {
wxMessageDialog *info;
info = new wxMessageDialog(NULL, wxT("Install SoapyRemote module to add remote servers.\n\nhttps://github.com/pothosware/SoapyRemote"), wxT("SoapyRemote not found."), wxOK | wxICON_ERROR);
info = new wxMessageDialog(nullptr, wxT("Install SoapyRemote module to add remote servers.\n\nhttps://github.com/pothosware/SoapyRemote"), wxT("SoapyRemote not found."), wxOK | wxICON_ERROR);
info->ShowModal();
return;
}
@ -339,27 +338,27 @@ void SDRDevicesDialog::OnAddRemote( wxMouseEvent& /* event */) {
}
}
SDRDeviceInfo *SDRDevicesDialog::getSelectedDevice(wxTreeItemId selId) {
devItems_i = devItems.find(selId);
SDRDeviceInfo *SDRDevicesDialog::getSelectedDevice(wxTreeItemId selId_in) {
devItems_i = devItems.find(selId_in);
if (devItems_i != devItems.end()) {
return devItems[selId];
return devItems[selId_in];
}
return NULL;
return nullptr;
}
void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event) {
if (dev != NULL) {
if (dev != nullptr) {
SoapySDR::ArgInfoList args = dev->getSoapyDevice()->getSettingInfo();
SoapySDR::Kwargs settingArgs;
SoapySDR::Kwargs streamArgs;
for (SoapySDR::ArgInfo arg : args) {
for (const SoapySDR::ArgInfo& arg : args) {
wxPGProperty *prop = runtimeProps[arg.key];
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
settingArgs[arg.key] = getSelectedChoiceOption(prop, arg);
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
settingArgs[arg.key] = (prop->GetValueAsString()=="True")?"true":"false";
@ -371,12 +370,12 @@ void SDRDevicesDialog::OnUseSelected( wxMouseEvent& event) {
if (dev) {
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
if (args.size()) {
for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) {
SoapySDR::ArgInfo arg = (*args_i);
if (!args.empty()) {
for (const auto & args_i : args) {
SoapySDR::ArgInfo arg = args_i;
wxPGProperty *prop = streamProps[arg.key];
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
streamArgs[arg.key] = getSelectedChoiceOption(prop, arg);
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
streamArgs[arg.key] = (prop->GetValueAsString()=="True")?"true":"false";
@ -415,7 +414,7 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
if (!failed) {
failed = true;
wxMessageDialog *info;
info = new wxMessageDialog(NULL, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
info = new wxMessageDialog(nullptr, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
info->ShowModal();
}
return;
@ -439,9 +438,9 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
wxTreeItemId manualBranch = devTree->AppendItem(devRoot, "Manual");
devs[""] = SDREnumerator::enumerate_devices("",true);
if (devs[""] != NULL) {
if (devs[""] != nullptr) {
for (devs_i = devs[""]->begin(); devs_i != devs[""]->end(); devs_i++) {
DeviceConfig *devConfig = nullptr;
DeviceConfig *devConfig;
if ((*devs_i)->isManual()) {
std::string devName = "Unknown";
if ((*devs_i)->isAvailable()) {
@ -465,14 +464,14 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
std::vector<SDRDeviceInfo *>::iterator remoteDevs_i;
if (remotes.size()) {
for (std::string remote : remotes) {
if (!remotes.empty()) {
for (const std::string& remote : remotes) {
devs[remote] = SDREnumerator::enumerate_devices(remote, true);
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(remote);
wxTreeItemId remoteNode = devTree->AppendItem(remoteBranch, devConfig->getDeviceName());
if (devs[remote] != NULL) {
if (devs[remote] != nullptr) {
for (remoteDevs_i = devs[remote]->begin(); remoteDevs_i != devs[remote]->end(); remoteDevs_i++) {
devItems[devTree->AppendItem(remoteNode, (*remoteDevs_i)->getName())] = (*remoteDevs_i);
}
@ -498,11 +497,11 @@ void SDRDevicesDialog::OnRefreshDevices( wxMouseEvent& /* event */) {
std::string SDRDevicesDialog::getSelectedChoiceOption(wxPGProperty* prop, const SoapySDR::ArgInfo& arg) {
std::string optionName = "";
std::string optionName;
int choiceIndex = prop->GetChoiceSelection();
if (arg.options.size() > 0) {
if (!arg.options.empty()) {
int choiceMax = arg.options.size();
if (choiceIndex >= 0 && choiceIndex < choiceMax) {
@ -529,7 +528,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
if (editId) {
devTree->SetItemText(editId, devConfig->getDeviceName());
}
if (devName == "") {
if (devName.empty()) {
event.GetProperty()->SetValueFromString(devConfig->getDeviceName());
}
} else if (dev && event.GetProperty() == devSettings["offset"]) {
@ -556,7 +555,7 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
if (dev->isActive() || !wxGetApp().getDevice()) {
wxGetApp().setSampleRate(srate);
}
} catch (std::invalid_argument e) {
} catch (const std::invalid_argument &) {
// nop
}
} else if (dev && event.GetProperty() == devSettings["antenna"]) {
@ -571,19 +570,19 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
wxGetApp().setAntennaName(strAntennaName);
}
}
catch (std::invalid_argument e) {
catch (const std::invalid_argument &) {
// nop
}
}
else if (dev) {
wxPGProperty *prop = event.GetProperty();
//change value of RuntimeProps
for (std::map<std::string, wxPGProperty *>::iterator rtp = runtimeProps.begin(); rtp != runtimeProps.end(); rtp++) {
if (rtp->second == prop) {
for (auto & runtimeProp : runtimeProps) {
if (runtimeProp.second == prop) {
SoapySDR::Device *soapyDev = dev->getSoapyDevice();
std::string settingValue = prop->GetValueAsString().ToStdString();
SoapySDR::ArgInfo arg = runtimeArgs[rtp->first];
if (arg.type == SoapySDR::ArgInfo::STRING && arg.options.size()) {
SoapySDR::ArgInfo arg = runtimeArgs[runtimeProp.first];
if (arg.type == SoapySDR::ArgInfo::STRING && !arg.options.empty()) {
settingValue = getSelectedChoiceOption(prop, arg);
} else if (arg.type == SoapySDR::ArgInfo::BOOL) {
settingValue = (prop->GetValueAsString()=="True")?"true":"false";
@ -591,9 +590,9 @@ void SDRDevicesDialog::OnPropGridChanged( wxPropertyGridEvent& event ) {
settingValue = prop->GetValueAsString();
}
soapyDev->writeSetting(rtp->first, settingValue);
soapyDev->writeSetting(runtimeProp.first, settingValue);
if (dev->isActive()) {
wxGetApp().getSDRThread()->writeSetting(rtp->first, settingValue);
wxGetApp().getSDRThread()->writeSetting(runtimeProp.first, settingValue);
}
return;
}

View File

@ -13,24 +13,24 @@
class SDRDevicesDialog: public devFrame {
public:
SDRDevicesDialog( wxWindow* parent, const wxPoint &wxPos = wxDefaultPosition);
explicit SDRDevicesDialog( wxWindow* parent, const wxPoint &wxPos = wxDefaultPosition);
void OnClose( wxCloseEvent& event );
void OnDeleteItem( wxTreeEvent& event );
void OnSelectionChanged( wxTreeEvent& event );
void OnAddRemote( wxMouseEvent& event );
void OnUseSelected( wxMouseEvent& event );
void OnTreeDoubleClick( wxMouseEvent& event );
void OnDeviceTimer( wxTimerEvent& event );
void OnRefreshDevices( wxMouseEvent& event );
void OnPropGridChanged( wxPropertyGridEvent& event );
void OnPropGridFocus( wxFocusEvent& event );
void OnClose( wxCloseEvent& event ) override;
void OnDeleteItem( wxTreeEvent& event ) override;
void OnSelectionChanged( wxTreeEvent& event ) override;
void OnAddRemote( wxMouseEvent& event ) override;
void OnUseSelected( wxMouseEvent& event ) override;
void OnTreeDoubleClick( wxMouseEvent& event ) override;
void OnDeviceTimer( wxTimerEvent& event ) override;
void OnRefreshDevices( wxMouseEvent& event ) override;
void OnPropGridChanged( wxPropertyGridEvent& event ) override;
void OnPropGridFocus( wxFocusEvent& event ) override;
private:
void refreshDeviceProperties();
void doRefreshDevices();
SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId);
SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId_in);
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg);
//

View File

@ -2,14 +2,13 @@
// SPDX-License-Identifier: GPL-2.0+
#include "Modem.h"
#include "CubicSDR.h"
ModemFactoryList Modem::modemFactories;
DefaultRatesList Modem::modemDefaultRates;
//! Create an empty range (0.0, 0.0)
ModemRange::ModemRange(void) {
ModemRange::ModemRange() {
_min = 0;
_max = 0;
}
@ -21,26 +20,22 @@ ModemRange::ModemRange(const double minimum, const double maximum) {
}
//! Get the range minimum
double ModemRange::minimum(void) const {
double ModemRange::minimum() const {
return _min;
}
//! Get the range maximum
double ModemRange::maximum(void) const {
double ModemRange::maximum() const {
return _max;
}
ModemArgInfo::ModemArgInfo(void) {
}
ModemArgInfo::ModemArgInfo() = default;
Modem::Modem() {
useSignalOutput(false);
}
Modem::~Modem() {
}
Modem::~Modem() = default;
void Modem::addModemFactory(ModemFactoryFn factoryFunc, std::string modemName, int defaultRate) {
modemFactories[modemName] = factoryFunc;
@ -94,8 +89,8 @@ void Modem::writeSettings(ModemSettings settings) {
ModemSettings Modem::readSettings() {
ModemArgInfoList args = getSettings();
ModemSettings rs;
for (ModemArgInfoList::const_iterator i = args.begin(); i != args.end(); i++) {
rs[i->key] = readSetting(i->key);
for (const auto & arg : args) {
rs[arg.key] = readSetting(arg.key);
}
return rs;
}

View File

@ -35,9 +35,7 @@ public:
}
virtual ~ModemIQData() {
}
virtual ~ModemIQData() = default;
};
typedef std::shared_ptr<ModemIQData> ModemIQDataPtr;
@ -48,16 +46,16 @@ class ModemRange
public:
//! Create an empty range (0.0, 0.0)
ModemRange(void);
ModemRange();
//! Create a min/max range
ModemRange(const double minimum, const double maximum);
ModemRange(double minimum, double maximum);
//! Get the range minimum
double minimum(void) const;
double minimum() const;
//! Get the range maximum
double maximum(void) const;
double maximum() const;
private:
double _min, _max;
@ -68,7 +66,7 @@ class ModemArgInfo
{
public:
//! Default constructor
ModemArgInfo(void);
ModemArgInfo();
//! The key used to identify the argument (required)
std::string key;
@ -90,7 +88,7 @@ public:
std::string units;
//! The data type of the argument (required)
enum Type { BOOL, INT, FLOAT, STRING, PATH_DIR, PATH_FILE, COLOR } type;
enum class Type { BOOL, INT, FLOAT, STRING, PATH_DIR, PATH_FILE, COLOR } type;
/*!
* The range of possible numeric values (optional)

View File

@ -19,7 +19,7 @@ int ModemAnalog::checkSampleRate(long long sampleRate, int /* audioSampleRate */
}
ModemKit *ModemAnalog::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitAnalog *akit = new ModemKitAnalog;
auto *akit = new ModemKitAnalog;
// stop-band attenuation [dB]
float As = 60.0f;
@ -33,7 +33,7 @@ ModemKit *ModemAnalog::buildKit(long long sampleRate, int audioSampleRate) {
}
void ModemAnalog::disposeKit(ModemKit *kit) {
ModemKitAnalog *akit = (ModemKitAnalog *)kit;
auto *akit = (ModemKitAnalog *)kit;
msresamp_rrrf_destroy(akit->audioResampler);
delete akit;

View File

@ -18,10 +18,10 @@ public:
class ModemAnalog : public Modem {
public:
ModemAnalog();
std::string getType();
virtual int checkSampleRate(long long sampleRate, int audioSampleRate);
virtual ModemKit *buildKit(long long sampleRate, int audioSampleRate);
virtual void disposeKit(ModemKit *kit);
std::string getType() override;
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
void disposeKit(ModemKit *kit) override;
virtual void initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input);
virtual void buildAudioOutput(ModemKitAnalog *akit, AudioThreadInput *audioOut, bool autoGain);
virtual std::vector<float> *getDemodOutputData();

View File

@ -4,9 +4,7 @@
#include "ModemDigital.h"
ModemDigitalOutput::ModemDigitalOutput() {
}
ModemDigitalOutput::ModemDigitalOutput() = default;
ModemDigital::ModemDigital() : Modem() {
#if ENABLE_DIGITAL_LAB
@ -14,9 +12,7 @@ ModemDigital::ModemDigital() : Modem() {
#endif
}
ModemDigitalOutput::~ModemDigitalOutput() {
}
ModemDigitalOutput::~ModemDigitalOutput() = default;
std::string ModemDigital::getType() {
return "digital";
@ -30,7 +26,7 @@ int ModemDigital::checkSampleRate(long long sampleRate, int /* audioSampleRate *
}
ModemKit *ModemDigital::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitDigital *dkit = new ModemKitDigital;
auto *dkit = new ModemKitDigital;
dkit->sampleRate = sampleRate;
dkit->audioSampleRate = audioSampleRate;
@ -39,7 +35,7 @@ ModemKit *ModemDigital::buildKit(long long sampleRate, int audioSampleRate) {
}
void ModemDigital::disposeKit(ModemKit *kit) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
delete dkit;
}

View File

@ -35,12 +35,12 @@ class ModemDigital : public Modem {
public:
ModemDigital();
std::string getType();
std::string getType() override;
virtual int checkSampleRate(long long sampleRate, int audioSampleRate);
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
virtual ModemKit *buildKit(long long sampleRate, int audioSampleRate);
virtual void disposeKit(ModemKit *kit);
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
void disposeKit(ModemKit *kit) override;
virtual void digitalStart(ModemKitDigital *kit, modem mod, ModemIQData *input);
virtual void digitalFinish(ModemKitDigital *kit, modem mod);

View File

@ -27,7 +27,7 @@ int ModemAM::getDefaultSampleRate() {
}
void ModemAM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput* audioOut) {
ModemKitAnalog *amkit = (ModemKitAnalog *)kit;
auto *amkit = (ModemKitAnalog *)kit;
initOutputBuffers(amkit,input);

View File

@ -8,15 +8,15 @@
class ModemAM : public ModemAnalog {
public:
ModemAM();
~ModemAM();
~ModemAM() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int getDefaultSampleRate();
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
firfilt_rrrf mDCBlock;

View File

@ -40,7 +40,7 @@ ModemArgInfoList ModemCW::getSettings() {
offsetArg.value = std::to_string(mBeepFrequency);
offsetArg.units = "Hz";
offsetArg.description = "Frequency Offset / Beep frequency (200-1000Hz)";
offsetArg.type = ModemArgInfo::FLOAT;
offsetArg.type = ModemArgInfo::Type::FLOAT;
offsetArg.range = ModemRange(200.0, 1000.0);
args.push_back(offsetArg);
@ -48,7 +48,7 @@ ModemArgInfoList ModemCW::getSettings() {
autoGain.key = "auto";
autoGain.name = "Auto Gain";
autoGain.value = "on";
autoGain.type = ModemArgInfo::STRING;
autoGain.type = ModemArgInfo::Type::STRING;
std::vector<std::string> autoOpts;
autoOpts.push_back("on");
autoOpts.push_back("off");
@ -63,7 +63,7 @@ ModemArgInfoList ModemCW::getSettings() {
gain.units = "dB";
gain.description = "Gain Setting (0-40dB)";
gain.range = ModemRange(0.0, 40.0);
gain.type = ModemArgInfo::FLOAT;
gain.type = ModemArgInfo::Type::FLOAT;
args.push_back(gain);
return args;
}
@ -101,7 +101,7 @@ std::string ModemCW::getName() {
int ModemCW::checkSampleRate(long long srate, int /* arate */) {
if (srate < MIN_BANDWIDTH)
return MIN_BANDWIDTH;
return srate;
return (int)srate;
}
int ModemCW::getDefaultSampleRate() {
@ -116,18 +116,18 @@ int ModemCW::getDefaultSampleRate() {
// the input IQ to audioOut, frequency shift, then pass the real part.
// Simple solution is just interpolate the IQ data to the audio sample rate.
ModemKit *ModemCW::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitCW *kit = new ModemKitCW();
auto *kit = new ModemKitCW();
float As = 60.0f;
double ratio = double(audioSampleRate) / double(sampleRate);
kit->sampleRate = sampleRate;
kit->audioSampleRate = audioSampleRate;
kit->audioResampleRatio = ratio;
kit->mInputResampler = msresamp_cccf_create(ratio, As);
kit->mInputResampler = msresamp_cccf_create((float)ratio, As);
return kit;
}
void ModemCW::disposeKit(ModemKit *kit) {
ModemKitCW *cwkit = (ModemKitCW *) kit;
auto *cwkit = (ModemKitCW *) kit;
msresamp_cccf_destroy(cwkit->mInputResampler);
delete kit;
}
@ -156,7 +156,7 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
unsigned int outSize;
float lsb;
liquid_float_complex sig;
ModemKitCW *cwkit = (ModemKitCW *) kit;
auto *cwkit = (ModemKitCW *) kit;
initOutputBuffers(cwkit, input);
@ -166,7 +166,7 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
// Interpolate IQ samples to full audio band. We need to be able to
// sample at 2 times the desired beep frequency.
msresamp_cccf_execute(cwkit->mInputResampler, &input->data[0], bufSize, &mInput[0], &outSize);
msresamp_cccf_execute(cwkit->mInputResampler, &input->data[0], (unsigned int)bufSize, &mInput[0], &outSize);
// Make the shoe fit.
if (demodOutputData.size() != outSize) {
@ -174,7 +174,7 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
}
// Set the LO to the desired beep frequency.
nco_crcf_set_frequency(mLO, 2.0 * M_PI * mBeepFrequency / kit->audioSampleRate);
nco_crcf_set_frequency(mLO, 2.0f * (float)M_PI * mBeepFrequency / kit->audioSampleRate);
// Mix up from base band by beep frequency. Extract real part
for (unsigned int i = 0; i < outSize; i++) {
@ -195,12 +195,12 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
}
}
mGain = 10.0 * std::log10(0.5f / aOutputCeilMAA);
mGain = 10.0f * std::log10(0.5f / aOutputCeilMAA);
}
// Apply gain to demodulated output data
for (size_t i = 0; i < outSize; i++) {
demodOutputData[i] *= std::pow(10.0, mGain / 10.0);
demodOutputData[i] *= std::pow(10.0f, mGain / 10.0f);
}
audioOut->channels = 1;

View File

@ -10,39 +10,39 @@ class ModemKitCW : public ModemKitAnalog {
public:
ModemKitCW() : ModemKitAnalog() {
};
msresamp_cccf mInputResampler;
msresamp_cccf mInputResampler{};
};
class ModemCW : public ModemAnalog {
public:
ModemCW();
~ModemCW();
~ModemCW() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long srate, int arate);
int checkSampleRate(long long srate, int arate) override;
ModemKit *buildKit(long long srate, int arate);
ModemKit *buildKit(long long srate, int arate) override;
void disposeKit(ModemKit *kit);
void disposeKit(ModemKit *kit) override;
void initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input);
void initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input) override;
int getDefaultSampleRate();
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
ModemArgInfoList getSettings();
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value);
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting);
std::string readSetting(std::string setting) override;
// No resampling required.
std::vector<float> *getResampledOutputData() { return &demodOutputData; }
std::vector<float> *getResampledOutputData() override { return &demodOutputData; }
private:
float mBeepFrequency;

View File

@ -25,7 +25,7 @@ int ModemDSB::getDefaultSampleRate() {
}
void ModemDSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
ModemKitAnalog *amkit = (ModemKitAnalog *)kit;
auto *amkit = (ModemKitAnalog *)kit;
initOutputBuffers(amkit, input);

View File

@ -8,15 +8,15 @@
class ModemDSB : public ModemAnalog {
public:
ModemDSB();
~ModemDSB();
~ModemDSB() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int getDefaultSampleRate();
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
ampmodem demodAM_DSB;

View File

@ -24,7 +24,7 @@ int ModemFM::getDefaultSampleRate() {
}
void ModemFM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
ModemKitAnalog *fmkit = (ModemKitAnalog *)kit;
auto *fmkit = (ModemKitAnalog *)kit;
initOutputBuffers(fmkit, input);

View File

@ -8,15 +8,15 @@
class ModemFM : public ModemAnalog {
public:
ModemFM();
~ModemFM();
~ModemFM() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int getDefaultSampleRate();
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
freqdem demodFM;

View File

@ -47,7 +47,7 @@ ModemArgInfoList ModemFMStereo::getSettings() {
demphArg.value = std::to_string(_demph);
demphArg.description = "FM Stereo De-Emphasis, typically 75us in US/Canada, 50us elsewhere.";
demphArg.type = ModemArgInfo::STRING;
demphArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> demphOptNames;
demphOptNames.push_back("None");
@ -87,7 +87,7 @@ std::string ModemFMStereo::readSetting(std::string setting) {
}
ModemKit *ModemFMStereo::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitFMStereo *kit = new ModemKitFMStereo;
auto *kit = new ModemKitFMStereo;
kit->audioResampleRatio = double(audioSampleRate) / double(sampleRate);
kit->sampleRate = sampleRate;
@ -161,7 +161,7 @@ ModemKit *ModemFMStereo::buildKit(long long sampleRate, int audioSampleRate) {
}
void ModemFMStereo::disposeKit(ModemKit *kit) {
ModemKitFMStereo *fmkit = (ModemKitFMStereo *)kit;
auto *fmkit = (ModemKitFMStereo *)kit;
msresamp_rrrf_destroy(fmkit->audioResampler);
msresamp_rrrf_destroy(fmkit->stereoResampler);
@ -176,7 +176,7 @@ void ModemFMStereo::disposeKit(ModemKit *kit) {
void ModemFMStereo::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
ModemKitFMStereo *fmkit = (ModemKitFMStereo *)kit;
auto *fmkit = (ModemKitFMStereo *)kit;
size_t bufSize = input->data.size();
liquid_float_complex u, v, w, x, y;

View File

@ -6,7 +6,8 @@
class ModemKitFMStereo: public ModemKit {
public:
ModemKitFMStereo() : audioResampler(nullptr), stereoResampler(nullptr), audioResampleRatio(0), firStereoLeft(nullptr), firStereoRight(nullptr), iirStereoPilot(nullptr) {
ModemKitFMStereo() : audioResampler(nullptr), stereoResampler(nullptr), audioResampleRatio(0), firStereoLeft(nullptr), firStereoRight(nullptr), iirStereoPilot(nullptr),
demph(0), iirDemphR(nullptr), iirDemphL(nullptr), firStereoR2C(nullptr), firStereoC2R(nullptr), stereoPilot(nullptr) {
}
msresamp_rrrf audioResampler;
@ -31,24 +32,24 @@ public:
class ModemFMStereo : public Modem {
public:
ModemFMStereo();
~ModemFMStereo();
~ModemFMStereo() override;
std::string getType();
std::string getName();
std::string getType() override;
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int getDefaultSampleRate();
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
int getDefaultSampleRate() override;
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
ModemKit *buildKit(long long sampleRate, int audioSampleRate);
void disposeKit(ModemKit *kit);
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
void disposeKit(ModemKit *kit) override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
std::vector<float> demodOutputData;

View File

@ -3,9 +3,7 @@
#include "ModemIQ.h"
ModemIQ::ModemIQ() {
}
ModemIQ::ModemIQ() = default;
std::string ModemIQ::getType() {
return "analog";
@ -20,7 +18,7 @@ ModemBase *ModemIQ::factory() {
}
ModemKit *ModemIQ::buildKit(long long sampleRate, int audioSampleRate) {
ModemKit *kit = new ModemKit;
auto *kit = new ModemKit;
kit->sampleRate = sampleRate;
kit->audioSampleRate = audioSampleRate;
return kit;

View File

@ -8,19 +8,19 @@ class ModemIQ : public Modem {
public:
ModemIQ();
std::string getType();
std::string getName();
std::string getType() override;
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int getDefaultSampleRate();
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
int getDefaultSampleRate() override;
ModemKit *buildKit(long long sampleRate, int audioSampleRate);
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
void disposeKit(ModemKit *kit);
void disposeKit(ModemKit *kit) override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:

View File

@ -41,7 +41,7 @@ int ModemLSB::getDefaultSampleRate() {
}
void ModemLSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
ModemKitAnalog *akit = (ModemKitAnalog *)kit;
auto *akit = (ModemKitAnalog *)kit;
initOutputBuffers(akit,input);

View File

@ -7,16 +7,16 @@
class ModemLSB : public ModemAnalog {
public:
ModemLSB();
~ModemLSB();
~ModemLSB() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int getDefaultSampleRate();
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
iirfilt_crcf ssbFilt;

View File

@ -24,7 +24,7 @@ int ModemNBFM::getDefaultSampleRate() {
}
void ModemNBFM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
ModemKitAnalog *fmkit = (ModemKitAnalog *)kit;
auto *fmkit = (ModemKitAnalog *)kit;
initOutputBuffers(fmkit, input);

View File

@ -8,15 +8,15 @@
class ModemNBFM : public ModemAnalog {
public:
ModemNBFM();
~ModemNBFM();
~ModemNBFM() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int getDefaultSampleRate();
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
freqdem demodFM;

View File

@ -41,7 +41,7 @@ int ModemUSB::getDefaultSampleRate() {
}
void ModemUSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
ModemKitAnalog *akit = (ModemKitAnalog *)kit;
auto *akit = (ModemKitAnalog *)kit;
initOutputBuffers(akit,input);

View File

@ -7,16 +7,16 @@
class ModemUSB : public ModemAnalog {
public:
ModemUSB();
~ModemUSB();
~ModemUSB() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int getDefaultSampleRate();
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
int getDefaultSampleRate() override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
iirfilt_crcf ssbFilt;

View File

@ -41,7 +41,7 @@ ModemArgInfoList ModemAPSK::getSettings() {
consArg.name = "Constellation";
consArg.description = "Modem Constellation Pattern";
consArg.value = std::to_string(cons);
consArg.type = ModemArgInfo::STRING;
consArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> consOpts;
consOpts.push_back("4");
consOpts.push_back("8");
@ -70,9 +70,9 @@ std::string ModemAPSK::readSetting(std::string setting) {
return "";
}
void ModemAPSK::updateDemodulatorCons(int cons) {
this->cons = cons;
switch (cons) {
void ModemAPSK::updateDemodulatorCons(int cons_in) {
cons = cons_in;
switch (cons_in) {
case 4:
demodAPSK = demodAPSK4;
break;
@ -98,7 +98,7 @@ void ModemAPSK::updateDemodulatorCons(int cons) {
}
void ModemAPSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodAPSK, input);

View File

@ -7,18 +7,18 @@
class ModemAPSK : public ModemDigital {
public:
ModemAPSK();
~ModemAPSK();
~ModemAPSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
void updateDemodulatorCons(int cons);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void updateDemodulatorCons(int cons_in);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int cons;

View File

@ -42,7 +42,7 @@ ModemArgInfoList ModemASK::getSettings() {
consArg.name = "Constellation";
consArg.description = "Modem Constellation Pattern";
consArg.value = std::to_string(cons);
consArg.type = ModemArgInfo::STRING;
consArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> consOpts;
consOpts.push_back("2");
consOpts.push_back("4");
@ -72,9 +72,9 @@ std::string ModemASK::readSetting(std::string setting) {
return "";
}
void ModemASK::updateDemodulatorCons(int cons) {
this->cons = cons;
switch (cons) {
void ModemASK::updateDemodulatorCons(int cons_in) {
cons = cons_in;
switch (cons_in) {
case 2:
demodASK = demodASK2;
break;
@ -103,7 +103,7 @@ void ModemASK::updateDemodulatorCons(int cons) {
}
void ModemASK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodASK, input);

View File

@ -7,18 +7,18 @@
class ModemASK : public ModemDigital {
public:
ModemASK();
~ModemASK();
~ModemASK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
void updateDemodulatorCons(int cons);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void updateDemodulatorCons(int cons_in);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int cons;

View File

@ -20,7 +20,7 @@ std::string ModemBPSK::getName() {
}
void ModemBPSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodBPSK, input);
for (size_t i = 0, bufSize=input->data.size(); i < bufSize; i++) {

View File

@ -7,13 +7,13 @@
class ModemBPSK : public ModemDigital {
public:
ModemBPSK();
~ModemBPSK();
~ModemBPSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
modem demodBPSK;

View File

@ -43,7 +43,7 @@ ModemArgInfoList ModemDPSK::getSettings() {
consArg.name = "Constellation";
consArg.description = "Modem Constellation Pattern";
consArg.value = std::to_string(cons);
consArg.type = ModemArgInfo::STRING;
consArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> consOpts;
consOpts.push_back("2");
consOpts.push_back("4");
@ -73,9 +73,9 @@ std::string ModemDPSK::readSetting(std::string setting) {
return "";
}
void ModemDPSK::updateDemodulatorCons(int cons) {
this->cons = cons;
switch (cons) {
void ModemDPSK::updateDemodulatorCons(int cons_in) {
cons = cons_in;
switch (cons_in) {
case 2:
demodDPSK = demodDPSK2;
break;
@ -104,7 +104,7 @@ void ModemDPSK::updateDemodulatorCons(int cons) {
}
void ModemDPSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodDPSK, input);

View File

@ -7,18 +7,18 @@
class ModemDPSK : public ModemDigital {
public:
ModemDPSK();
~ModemDPSK();
~ModemDPSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
void updateDemodulatorCons(int cons);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void updateDemodulatorCons(int cons_in);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int cons;

View File

@ -38,7 +38,7 @@ ModemArgInfoList ModemFSK::getSettings() {
bpsArg.name = "Bits/symbol";
bpsArg.value = std::to_string(bps);
bpsArg.description = "Modem bits-per-symbol";
bpsArg.type = ModemArgInfo::STRING;
bpsArg.type = ModemArgInfo::Type::STRING;
bpsArg.units = "bits";
std::vector<std::string> bpsOpts;
@ -56,7 +56,7 @@ ModemArgInfoList ModemFSK::getSettings() {
spsArg.name = "Symbols/second";
spsArg.value = std::to_string(sps);
spsArg.description = "Modem symbols-per-second";
spsArg.type = ModemArgInfo::INT;
spsArg.type = ModemArgInfo::Type::INT;
spsArg.range = ModemRange(10,115200);
std::vector<std::string> spsOpts;
@ -67,7 +67,7 @@ ModemArgInfoList ModemFSK::getSettings() {
bwArg.name = "Signal bandwidth";
bwArg.value = std::to_string(bw);
bwArg.description = "Total signal bandwidth";
bwArg.type = ModemArgInfo::FLOAT;
bwArg.type = ModemArgInfo::Type::FLOAT;
bwArg.range = ModemRange(0.1,0.49);
args.push_back(bwArg);
@ -99,7 +99,7 @@ std::string ModemFSK::readSetting(std::string setting) {
}
ModemKit *ModemFSK::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitFSK *dkit = new ModemKitFSK;
auto *dkit = new ModemKitFSK;
dkit->m = bps;
dkit->k = (unsigned int)(sampleRate / sps);
dkit->bw = bw;
@ -113,7 +113,7 @@ ModemKit *ModemFSK::buildKit(long long sampleRate, int audioSampleRate) {
}
void ModemFSK::disposeKit(ModemKit *kit) {
ModemKitFSK *dkit = (ModemKitFSK *)kit;
auto *dkit = (ModemKitFSK *)kit;
fskdem_destroy(dkit->demodFSK);
@ -124,12 +124,10 @@ std::string ModemFSK::getName() {
return "FSK";
}
ModemFSK::~ModemFSK() {
}
ModemFSK::~ModemFSK() = default;
void ModemFSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitFSK *dkit = (ModemKitFSK *)kit;
auto *dkit = (ModemKitFSK *)kit;
digitalStart(dkit, nullptr, input);

View File

@ -18,23 +18,23 @@ public:
class ModemFSK : public ModemDigital {
public:
ModemFSK();
~ModemFSK();
~ModemFSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int getDefaultSampleRate();
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
int getDefaultSampleRate() override;
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
ModemKit *buildKit(long long sampleRate, int audioSampleRate);
void disposeKit(ModemKit *kit);
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
void disposeKit(ModemKit *kit) override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int sps, bps;

View File

@ -11,9 +11,7 @@ ModemGMSK::ModemGMSK() : ModemDigital() {
outStream << std::hex;
}
ModemGMSK::~ModemGMSK() {
}
ModemGMSK::~ModemGMSK() = default;
std::string ModemGMSK::getName() {
return "GMSK";
@ -42,7 +40,7 @@ ModemArgInfoList ModemGMSK::getSettings() {
fdelayArg.name = "Filter delay";
fdelayArg.value = std::to_string(_fdelay);
fdelayArg.description = "Filter delay in samples";
fdelayArg.type = ModemArgInfo::INT;
fdelayArg.type = ModemArgInfo::Type::INT;
fdelayArg.units = "samples";
fdelayArg.range = ModemRange(1,128);
args.push_back(fdelayArg);
@ -52,7 +50,7 @@ ModemArgInfoList ModemGMSK::getSettings() {
spsArg.name = "Samples / symbol";
spsArg.value = std::to_string(_sps);
spsArg.description = "Modem samples-per-symbol";
spsArg.type = ModemArgInfo::INT;
spsArg.type = ModemArgInfo::Type::INT;
spsArg.units = "samples/symbol";
spsArg.range = ModemRange(2,512);
args.push_back(spsArg);
@ -62,7 +60,7 @@ ModemArgInfoList ModemGMSK::getSettings() {
ebfArg.name = "Excess bandwidth";
ebfArg.value = std::to_string(_ebf);
ebfArg.description = "Modem excess bandwidth factor";
ebfArg.type = ModemArgInfo::FLOAT;
ebfArg.type = ModemArgInfo::Type::FLOAT;
ebfArg.range = ModemRange(0.1,0.49);
args.push_back(ebfArg);
@ -94,7 +92,7 @@ std::string ModemGMSK::readSetting(std::string setting) {
}
ModemKit *ModemGMSK::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitGMSK *dkit = new ModemKitGMSK;
auto *dkit = new ModemKitGMSK;
dkit->sps = _sps;
dkit->fdelay = _fdelay;
dkit->ebf = _ebf;
@ -108,7 +106,7 @@ ModemKit *ModemGMSK::buildKit(long long sampleRate, int audioSampleRate) {
}
void ModemGMSK::disposeKit(ModemKit *kit) {
ModemKitGMSK *dkit = (ModemKitGMSK *)kit;
auto *dkit = (ModemKitGMSK *)kit;
gmskdem_destroy(dkit->demodGMSK);
@ -116,7 +114,7 @@ void ModemGMSK::disposeKit(ModemKit *kit) {
}
void ModemGMSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitGMSK *dkit = (ModemKitGMSK *)kit;
auto *dkit = (ModemKitGMSK *)kit;
unsigned int sym_out;
digitalStart(dkit, nullptr, input);

View File

@ -18,23 +18,23 @@ public:
class ModemGMSK : public ModemDigital {
public:
ModemGMSK();
~ModemGMSK();
~ModemGMSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int getDefaultSampleRate();
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
int getDefaultSampleRate() override;
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
ModemKit *buildKit(long long sampleRate, int audioSampleRate);
void disposeKit(ModemKit *kit);
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
void disposeKit(ModemKit *kit) override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int _sps; // samples per symbol

View File

@ -27,7 +27,7 @@ int ModemOOK::checkSampleRate(long long sampleRate, int /* audioSampleRate */) {
}
void ModemOOK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodOOK, input);
for (size_t i = 0, bufSize=input->data.size(); i < bufSize; i++) {

View File

@ -7,15 +7,15 @@
class ModemOOK : public ModemDigital {
public:
ModemOOK();
~ModemOOK();
~ModemOOK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
int checkSampleRate(long long sampleRate, int audioSampleRate);
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
modem demodOOK;

View File

@ -44,7 +44,7 @@ ModemArgInfoList ModemPSK::getSettings() {
consArg.name = "Constellation";
consArg.description = "Modem Constellation Pattern";
consArg.value = std::to_string(cons);
consArg.type = ModemArgInfo::STRING;
consArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> consOpts;
consOpts.push_back("2");
consOpts.push_back("4");
@ -74,9 +74,9 @@ std::string ModemPSK::readSetting(std::string setting) {
return "";
}
void ModemPSK::updateDemodulatorCons(int cons) {
this->cons = cons;
switch (cons) {
void ModemPSK::updateDemodulatorCons(int cons_in) {
cons = cons_in;
switch (cons_in) {
case 2:
demodPSK = demodPSK2;
break;
@ -105,7 +105,7 @@ void ModemPSK::updateDemodulatorCons(int cons) {
}
void ModemPSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodPSK, input);

View File

@ -7,18 +7,18 @@
class ModemPSK : public ModemDigital {
public:
ModemPSK();
~ModemPSK();
~ModemPSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
void updateDemodulatorCons(int cons);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void updateDemodulatorCons(int cons_in);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int cons;

View File

@ -41,7 +41,7 @@ ModemArgInfoList ModemQAM::getSettings() {
consArg.name = "Constellation";
consArg.description = "Modem Constellation Pattern";
consArg.value = std::to_string(cons);
consArg.type = ModemArgInfo::STRING;
consArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> consOpts;
consOpts.push_back("4");
consOpts.push_back("8");
@ -70,9 +70,9 @@ std::string ModemQAM::readSetting(std::string setting) {
return "";
}
void ModemQAM::updateDemodulatorCons(int cons) {
this->cons = cons;
switch (cons) {
void ModemQAM::updateDemodulatorCons(int cons_in) {
cons = cons_in;
switch (cons_in) {
case 4:
demodQAM = demodQAM4;
break;
@ -98,7 +98,7 @@ void ModemQAM::updateDemodulatorCons(int cons) {
}
void ModemQAM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodQAM, input);
for (size_t i = 0, bufSize = input->data.size(); i < bufSize; i++) {

View File

@ -7,18 +7,18 @@
class ModemQAM : public ModemDigital {
public:
ModemQAM();
~ModemQAM();
~ModemQAM() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
void updateDemodulatorCons(int cons);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void updateDemodulatorCons(int cons_in);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int cons;

View File

@ -20,7 +20,7 @@ std::string ModemQPSK::getName() {
}
void ModemQPSK::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodQPSK, input);
for (size_t i = 0, bufSize = input->data.size(); i < bufSize; i++) {

View File

@ -7,13 +7,13 @@
class ModemQPSK : public ModemDigital {
public:
ModemQPSK();
~ModemQPSK();
~ModemQPSK() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
modem demodQPSK;

View File

@ -31,7 +31,7 @@ ModemArgInfoList ModemSQAM::getSettings() {
consArg.name = "Constellation";
consArg.description = "Modem Constellation Pattern";
consArg.value = std::to_string(cons);
consArg.type = ModemArgInfo::STRING;
consArg.type = ModemArgInfo::Type::STRING;
std::vector<std::string> consOpts;
consOpts.push_back("32");
consOpts.push_back("128");
@ -55,9 +55,9 @@ std::string ModemSQAM::readSetting(std::string setting) {
return "";
}
void ModemSQAM::updateDemodulatorCons(int cons) {
this->cons = cons;
switch (cons) {
void ModemSQAM::updateDemodulatorCons(int cons_in) {
cons = cons_in;
switch (cons_in) {
case 32:
demodSQAM = demodSQAM32;
break;
@ -68,7 +68,7 @@ void ModemSQAM::updateDemodulatorCons(int cons) {
}
void ModemSQAM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodSQAM, input);

View File

@ -7,18 +7,18 @@
class ModemSQAM : public ModemDigital {
public:
ModemSQAM();
~ModemSQAM();
~ModemSQAM() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
ModemArgInfoList getSettings();
void writeSetting(std::string setting, std::string value);
std::string readSetting(std::string setting);
ModemArgInfoList getSettings() override;
void writeSetting(std::string setting, std::string value) override;
std::string readSetting(std::string setting) override;
void updateDemodulatorCons(int cons);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void updateDemodulatorCons(int cons_in);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
int cons;

View File

@ -20,7 +20,7 @@ ModemST::~ModemST() {
}
void ModemST::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput * /* audioOut */) {
ModemKitDigital *dkit = (ModemKitDigital *)kit;
auto *dkit = (ModemKitDigital *)kit;
digitalStart(dkit, demodST, input);
for (size_t i = 0, bufSize = input->data.size(); i < bufSize; i++) {

View File

@ -7,13 +7,13 @@
class ModemST : public ModemDigital {
public:
ModemST();
~ModemST();
~ModemST() override;
std::string getName();
std::string getName() override;
static ModemBase *factory();
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
private:
modem demodST;

View File

@ -5,7 +5,7 @@
#include "ColorTheme.h"
MeterPanel::MeterPanel(std::string name, float low, float high, float current) {
MeterPanel::MeterPanel(const std::string& name, float low, float high, float current) {
this->name = name;
this->low = low;
this->high = high;
@ -35,7 +35,7 @@ MeterPanel::MeterPanel(std::string name, float low, float high, float current) {
highlightPanel.setBlend(GL_ONE, GL_ONE);
highlightPanel.visible = false;
c1 = RGBA4f(0.3f,0.3f,0.3f,1.0f);
c2 = RGBA4f(0.65f,0.65f,0.65f,1.0f);;
c2 = RGBA4f(0.65f,0.65f,0.65f,1.0f);
highlightPanel.setFillColor(c1, c2);
bgPanel.addChild(&highlightPanel);
@ -58,9 +58,7 @@ MeterPanel::MeterPanel(std::string name, float low, float high, float current) {
addChild(&valuePanel);
}
MeterPanel::~MeterPanel() {
}
MeterPanel::~MeterPanel() = default;
void MeterPanel::setName(std::string name_in) {
@ -71,17 +69,17 @@ std::string MeterPanel::getName() {
return name;
}
void MeterPanel::setRange(float low, float high) {
this->low = low;
this->high = high;
void MeterPanel::setRange(float low_in, float high_in) {
low = low_in;
high = high_in;
}
float MeterPanel::getLow() {
return this->low;
float MeterPanel::getLow() const {
return low;
}
float MeterPanel::getHigh() {
return this->high;
float MeterPanel::getHigh() const {
return high;
}
void MeterPanel::setValue(float value) {
@ -112,7 +110,7 @@ void MeterPanel::setHighlightVisible(bool vis) {
highlightPanel.visible = vis;
}
float MeterPanel::getValue() {
float MeterPanel::getValue() const {
return current;
}
@ -196,16 +194,16 @@ void MeterPanel::setValueLabel(std::string label) {
}
void MeterPanel::setPanelLevel(float setValue, GLPanel &panel) {
void MeterPanel::setPanelLevel(float setValue, GLPanel &panel) const {
float valueNorm = (setValue - low) / (high - low);
panel.setSize(1.0, valueNorm);
panel.setPosition(0.0, (-1.0+(valueNorm)));
}
bool MeterPanel::getChanged() {
bool MeterPanel::getChanged() const {
return changed;
}
void MeterPanel::setChanged(bool changed) {
this->changed = changed;
void MeterPanel::setChanged(bool changed_in) {
changed = changed_in;
}

Some files were not shown because too many files have changed in this diff Show More