FSK tweaks, minimum bandwidth adjust

This commit is contained in:
Charles J. Cliffe 2015-12-01 00:59:11 -05:00
parent 76d69ffd78
commit 0f8065f48a
12 changed files with 46 additions and 32 deletions

View File

@ -120,6 +120,7 @@ AppFrame::AppFrame() :
demodWaterfallCanvas->setup(1024, 128);
demodWaterfallCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000);
demodWaterfallCanvas->attachSpectrumCanvas(demodSpectrumCanvas);
demodWaterfallCanvas->setMinBandwidth(8000);
demodSpectrumCanvas->attachWaterfallCanvas(demodWaterfallCanvas);
demodVisuals->Add(demodWaterfallCanvas, 6, wxEXPAND | wxALL, 0);
wxGetApp().getDemodSpectrumProcessor()->attachOutput(demodWaterfallCanvas->getVisualDataQueue());

View File

@ -173,8 +173,8 @@ int DemodulatorMgr::getLastBandwidth() const {
}
void DemodulatorMgr::setLastBandwidth(int lastBandwidth) {
if (lastBandwidth < 1500) {
lastBandwidth = 1500;
if (lastBandwidth < MIN_BANDWIDTH) {
lastBandwidth = MIN_BANDWIDTH;
} else if (lastBandwidth > wxGetApp().getSampleRate()) {
lastBandwidth = wxGetApp().getSampleRate();
}

View File

@ -6,6 +6,8 @@
#include <cmath>
#include <atomic>
#define MIN_BANDWIDTH 500
class ModemKit {
public:
ModemKit() : sampleRate(0), audioSampleRate(0) {

View File

@ -9,8 +9,8 @@ std::string ModemAnalog::getType() {
}
int ModemAnalog::checkSampleRate(long long sampleRate, int audioSampleRate) {
if (sampleRate < 1500) {
return 1500;
if (sampleRate < MIN_BANDWIDTH) {
return MIN_BANDWIDTH;
}
return sampleRate;
}

View File

@ -20,8 +20,8 @@ std::string ModemDigital::getType() {
}
int ModemDigital::checkSampleRate(long long sampleRate, int audioSampleRate) {
if (sampleRate < 1500) {
return 1500;
if (sampleRate < MIN_BANDWIDTH) {
return MIN_BANDWIDTH;
}
return sampleRate;
}

View File

@ -20,8 +20,8 @@ ModemLSB::~ModemLSB() {
}
int ModemLSB::checkSampleRate(long long sampleRate, int audioSampleRate) {
if (sampleRate < 1500) {
return 1500;
if (sampleRate < MIN_BANDWIDTH) {
return MIN_BANDWIDTH;
}
if (sampleRate % 2 == 0) {
return sampleRate;

View File

@ -20,8 +20,8 @@ ModemUSB::~ModemUSB() {
}
int ModemUSB::checkSampleRate(long long sampleRate, int audioSampleRate) {
if (sampleRate < 1500) {
return 1500;
if (sampleRate < MIN_BANDWIDTH) {
return MIN_BANDWIDTH;
}
if (sampleRate % 2 == 0) {
return sampleRate;

View File

@ -5,6 +5,7 @@ ModemFSK::ModemFSK() : ModemDigital() {
// DMR defaults?
bps = 1;
sps = 9600;
bw = 0.45;
outStream << std::hex;
}
@ -35,6 +36,7 @@ ModemArgInfoList ModemFSK::getSettings() {
bpsArg.value = std::to_string(bps);
bpsArg.description = "Modem bits-per-symbol";
bpsArg.type = ModemArgInfo::STRING;
bpsArg.units = "bits";
std::vector<std::string> bpsOpts;
bpsOpts.push_back("1");
@ -51,21 +53,20 @@ ModemArgInfoList ModemFSK::getSettings() {
spsArg.name = "Symbols/second";
spsArg.value = std::to_string(sps);
spsArg.description = "Modem symbols-per-second";
spsArg.type = ModemArgInfo::STRING;
spsArg.type = ModemArgInfo::INT;
spsArg.range = ModemRange(10,115200);
std::vector<std::string> spsOpts;
// some common modem rates ..?
spsOpts.push_back("300");
spsOpts.push_back("600");
spsOpts.push_back("1200");
spsOpts.push_back("2400");
spsOpts.push_back("4800");
spsOpts.push_back("9600");
spsOpts.push_back("19200");
spsOpts.push_back("38400");
spsArg.options = spsOpts;
args.push_back(spsArg);
ModemArgInfo bwArg;
bwArg.key = "bw";
bwArg.name = "Signal bandwidth";
bwArg.value = std::to_string(bw);
bwArg.description = "Total signal bandwidth";
bwArg.type = ModemArgInfo::FLOAT;
bwArg.range = ModemRange(0.1,0.49);
args.push_back(bwArg);
return args;
}
@ -77,6 +78,9 @@ void ModemFSK::writeSetting(std::string setting, std::string value) {
} else if (setting == "sps") {
sps = std::stoi(value);
rebuildKit();
} else if (setting == "bw") {
bw = std::stof(value);
rebuildKit();
}
}
@ -85,6 +89,8 @@ std::string ModemFSK::readSetting(std::string setting) {
return std::to_string(bps);
} else if (setting == "sps") {
return std::to_string(sps);
} else if (setting == "bw") {
return std::to_string(bw);
}
return "";
}
@ -93,8 +99,9 @@ ModemKit *ModemFSK::buildKit(long long sampleRate, int audioSampleRate) {
ModemKitFSK *dkit = new ModemKitFSK;
dkit->m = bps;
dkit->k = sampleRate / sps;
dkit->bw = bw;
dkit->demodFSK = fskdem_create(dkit->m, dkit->k, 0.45);
dkit->demodFSK = fskdem_create(dkit->m, dkit->k, dkit->bw);
dkit->sampleRate = sampleRate;
dkit->audioSampleRate = audioSampleRate;

View File

@ -5,6 +5,7 @@
class ModemKitFSK : public ModemKitDigital {
public:
unsigned int m, k;
float bw;
fskdem demodFSK;
std::vector<liquid_float_complex> inputBuffer;
@ -33,7 +34,7 @@ public:
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
private:
int sps;
int bps;
int sps, bps;
float bw;
};

View File

@ -21,8 +21,8 @@ Modem *ModemGMSK::factory() {
}
int ModemGMSK::checkSampleRate(long long sampleRate, int audioSampleRate) {
if (sampleRate < 1500) {
return 1500;
if (sampleRate < MIN_BANDWIDTH) {
return MIN_BANDWIDTH;
}
return sampleRate;
}

View File

@ -17,8 +17,6 @@
#include <wx/numformatter.h>
#define MIN_BANDWIDTH 1500
wxBEGIN_EVENT_TABLE(WaterfallCanvas, wxGLCanvas)
EVT_PAINT(WaterfallCanvas::OnPaint)
EVT_KEY_DOWN(WaterfallCanvas::OnKeyDown)
@ -44,6 +42,7 @@ WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
preBuf = false;
SetCursor(wxCURSOR_CROSS);
scaleMove = 0;
minBandwidth = 30000;
}
WaterfallCanvas::~WaterfallCanvas() {
@ -179,8 +178,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
if (currentZoom < 1) {
bw = (long long) ceil((long double) bw * currentZoom);
if (bw < 30000) {
bw = 30000;
if (bw < minBandwidth) {
bw = minBandwidth;
}
if (mouseInView) {
long long mfreqA = getFrequencyAt(mpos);
@ -852,4 +851,6 @@ void WaterfallCanvas::setLinesPerSecond(int lps) {
tex_update.unlock();
}
void WaterfallCanvas::setMinBandwidth(int min) {
minBandwidth = min;
}

View File

@ -30,6 +30,7 @@ public:
SpectrumVisualDataQueue *getVisualDataQueue();
void setLinesPerSecond(int lps);
void setMinBandwidth(int min);
private:
void OnPaint(wxPaintEvent& event);
@ -75,6 +76,7 @@ private:
double lpsIndex;
bool preBuf;
std::mutex tex_update;
int minBandwidth;
// event table
wxDECLARE_EVENT_TABLE();
};