mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-25 10:28:28 +01:00
Added AGC + Started working on channel selection
This commit is contained in:
parent
e5123dd8bf
commit
929ca50b06
@ -123,9 +123,8 @@ void windowInit() {
|
|||||||
|
|
||||||
// TODO for 0.2.5
|
// TODO for 0.2.5
|
||||||
// Add "select folder" option for the file source
|
// Add "select folder" option for the file source
|
||||||
// FIX AUDIO ISSUE ON BOTH LINUX AND SOMETIMES WINDOWS (probly the ring buffer, though double buffering could help)
|
|
||||||
// Add default main config to avoid having to ship one
|
// Add default main config to avoid having to ship one
|
||||||
// Have a good directory system on both linux and windows
|
// Have a good directory system on both linux and windows (should fix occassional underruns)
|
||||||
// Switch to double buffering
|
// Switch to double buffering
|
||||||
|
|
||||||
// TODO for 0.2.6
|
// TODO for 0.2.6
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
{
|
{
|
||||||
"audio": {
|
|
||||||
"Radio": {
|
|
||||||
"device": "Speakers (Realtek High Definiti",
|
|
||||||
"sampleRate": 48000.0,
|
|
||||||
"volume": 0.4609375
|
|
||||||
},
|
|
||||||
"Radio 1": {
|
|
||||||
"device": "Speakers (Realtek High Definition Audio)",
|
|
||||||
"sampleRate": 48000.0,
|
|
||||||
"volume": 0.609375
|
|
||||||
},
|
|
||||||
"Radio 2": {
|
|
||||||
"device": "CABLE Input (VB-Audio Virtual Cable)",
|
|
||||||
"sampleRate": 48000.0,
|
|
||||||
"volume": 1.0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bandPlan": "General",
|
"bandPlan": "General",
|
||||||
"bandPlanEnabled": true,
|
"bandPlanEnabled": true,
|
||||||
"fftHeight": 296,
|
"fftHeight": 296,
|
||||||
"frequency": 99000000,
|
"frequency": 99000000,
|
||||||
"max": 0.0,
|
"max": 0.0,
|
||||||
"maximized": false,
|
"maximized": true,
|
||||||
"menuOrder": [
|
"menuOrder": [
|
||||||
"Source",
|
"Source",
|
||||||
"Radio",
|
"Radio",
|
||||||
@ -33,7 +16,7 @@
|
|||||||
"Display"
|
"Display"
|
||||||
],
|
],
|
||||||
"menuWidth": 300,
|
"menuWidth": 300,
|
||||||
"min": -54.41176986694336,
|
"min": -70.5882339477539,
|
||||||
"offset": 0.0,
|
"offset": 0.0,
|
||||||
"showWaterfall": true,
|
"showWaterfall": true,
|
||||||
"source": "SoapySDR",
|
"source": "SoapySDR",
|
||||||
@ -42,17 +25,7 @@
|
|||||||
"Radio": {
|
"Radio": {
|
||||||
"muted": false,
|
"muted": false,
|
||||||
"sink": "Audio",
|
"sink": "Audio",
|
||||||
"volume": 0.6887755393981934
|
"volume": 0.4285714328289032
|
||||||
},
|
|
||||||
"Radio 1": {
|
|
||||||
"muted": true,
|
|
||||||
"sink": "Audio",
|
|
||||||
"volume": 0.625
|
|
||||||
},
|
|
||||||
"Radio 2": {
|
|
||||||
"muted": false,
|
|
||||||
"sink": "Audio",
|
|
||||||
"volume": 1.0
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"windowSize": {
|
"windowSize": {
|
||||||
|
@ -18,11 +18,12 @@
|
|||||||
"sampleRate": 96000.0
|
"sampleRate": 96000.0
|
||||||
},
|
},
|
||||||
"Default Device": {
|
"Default Device": {
|
||||||
"sampleRate": 32000.0
|
"sampleRate": 192000.0
|
||||||
},
|
},
|
||||||
"Generic RTL2832U OEM :: 00000001": {
|
"Generic RTL2832U OEM :: 00000001": {
|
||||||
|
"agc": false,
|
||||||
"gains": {
|
"gains": {
|
||||||
"TUNER": 23.406999588012695
|
"TUNER": 37.3390007019043
|
||||||
},
|
},
|
||||||
"sampleRate": 2560000.0
|
"sampleRate": 2560000.0
|
||||||
},
|
},
|
||||||
|
@ -114,20 +114,22 @@ private:
|
|||||||
|
|
||||||
SoapySDR::Device* dev = SoapySDR::Device::make(devArgs);
|
SoapySDR::Device* dev = SoapySDR::Device::make(devArgs);
|
||||||
|
|
||||||
gainList = dev->listGains(SOAPY_SDR_RX, 0);
|
gainList = dev->listGains(SOAPY_SDR_RX, channelId);
|
||||||
delete[] uiGains;
|
delete[] uiGains;
|
||||||
uiGains = new float[gainList.size()];
|
uiGains = new float[gainList.size()];
|
||||||
for (auto gain : gainList) {
|
for (auto gain : gainList) {
|
||||||
gainRanges.push_back(dev->getGainRange(SOAPY_SDR_RX, 0, gain));
|
gainRanges.push_back(dev->getGainRange(SOAPY_SDR_RX, channelId, gain));
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleRates = dev->listSampleRates(SOAPY_SDR_RX, 0);
|
sampleRates = dev->listSampleRates(SOAPY_SDR_RX, channelId);
|
||||||
txtSrList = "";
|
txtSrList = "";
|
||||||
for (double sr : sampleRates) {
|
for (double sr : sampleRates) {
|
||||||
txtSrList += std::to_string((int)sr);
|
txtSrList += std::to_string((int)sr);
|
||||||
txtSrList += '\0';
|
txtSrList += '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasAgc = dev->hasGainMode(SOAPY_SDR_RX, channelId);
|
||||||
|
|
||||||
SoapySDR::Device::unmake(dev);
|
SoapySDR::Device::unmake(dev);
|
||||||
|
|
||||||
config.aquire();
|
config.aquire();
|
||||||
@ -137,16 +139,33 @@ private:
|
|||||||
if (config.conf["devices"][name]["gains"].contains(gain)) {
|
if (config.conf["devices"][name]["gains"].contains(gain)) {
|
||||||
uiGains[i] = config.conf["devices"][name]["gains"][gain];
|
uiGains[i] = config.conf["devices"][name]["gains"][gain];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
uiGains[i] = gainRanges[i].minimum();
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (hasAgc && config.conf["devices"][name].contains("agc")) {
|
||||||
|
agc = config.conf["devices"][name]["agc"];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
agc = false;
|
||||||
|
}
|
||||||
|
if (config.conf["devices"][name].contains("sampleRate")) {
|
||||||
selectSampleRate(config.conf["devices"][name]["sampleRate"]);
|
selectSampleRate(config.conf["devices"][name]["sampleRate"]);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
selectSampleRate(sampleRates[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto gain : gainList) {
|
for (auto gain : gainList) {
|
||||||
uiGains[i] = gainRanges[i].minimum();
|
uiGains[i] = gainRanges[i].minimum();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (hasAgc) {
|
||||||
|
agc = false;
|
||||||
|
}
|
||||||
selectSampleRate(sampleRates[0]); // Select default
|
selectSampleRate(sampleRates[0]); // Select default
|
||||||
}
|
}
|
||||||
config.release();
|
config.release();
|
||||||
@ -161,6 +180,9 @@ private:
|
|||||||
conf["gains"][gain] = uiGains[i];
|
conf["gains"][gain] = uiGains[i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (hasAgc) {
|
||||||
|
conf["agc"] = agc;
|
||||||
|
}
|
||||||
config.aquire();
|
config.aquire();
|
||||||
config.conf["devices"][devArgs["label"]] = conf;
|
config.conf["devices"][devArgs["label"]] = conf;
|
||||||
config.release(true);
|
config.release(true);
|
||||||
@ -184,15 +206,19 @@ private:
|
|||||||
SoapyModule* _this = (SoapyModule*)ctx;
|
SoapyModule* _this = (SoapyModule*)ctx;
|
||||||
_this->dev = SoapySDR::Device::make(_this->devArgs);
|
_this->dev = SoapySDR::Device::make(_this->devArgs);
|
||||||
|
|
||||||
_this->dev->setSampleRate(SOAPY_SDR_RX, 0, _this->sampleRate);
|
_this->dev->setSampleRate(SOAPY_SDR_RX, _this->channelId, _this->sampleRate);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto gain : _this->gainList) {
|
for (auto gain : _this->gainList) {
|
||||||
_this->dev->setGain(SOAPY_SDR_RX, 0, gain, _this->uiGains[i]);
|
_this->dev->setGain(SOAPY_SDR_RX, _this->channelId, gain, _this->uiGains[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
_this->dev->setFrequency(SOAPY_SDR_RX, 0, _this->freq);
|
if (_this->hasAgc) {
|
||||||
|
_this->dev->setGainMode(SOAPY_SDR_RX, _this->channelId, _this->agc);
|
||||||
|
}
|
||||||
|
|
||||||
|
_this->dev->setFrequency(SOAPY_SDR_RX, _this->channelId, _this->freq);
|
||||||
|
|
||||||
_this->devStream = _this->dev->setupStream(SOAPY_SDR_RX, "CF32");
|
_this->devStream = _this->dev->setupStream(SOAPY_SDR_RX, "CF32");
|
||||||
_this->dev->activateStream(_this->devStream);
|
_this->dev->activateStream(_this->devStream);
|
||||||
@ -218,12 +244,11 @@ private:
|
|||||||
SoapyModule* _this = (SoapyModule*)ctx;
|
SoapyModule* _this = (SoapyModule*)ctx;
|
||||||
_this->freq = freq;
|
_this->freq = freq;
|
||||||
if (_this->running) {
|
if (_this->running) {
|
||||||
_this->dev->setFrequency(SOAPY_SDR_RX, 0, freq);
|
_this->dev->setFrequency(SOAPY_SDR_RX, _this->channelId, freq);
|
||||||
}
|
}
|
||||||
spdlog::info("SoapyModule '{0}': Tune: {1}!", _this->name, freq);
|
spdlog::info("SoapyModule '{0}': Tune: {1}!", _this->name, freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void menuHandler(void* ctx) {
|
static void menuHandler(void* ctx) {
|
||||||
SoapyModule* _this = (SoapyModule*)ctx;
|
SoapyModule* _this = (SoapyModule*)ctx;
|
||||||
|
|
||||||
@ -269,6 +294,21 @@ private:
|
|||||||
}
|
}
|
||||||
gainNameLen += 5.0f;
|
gainNameLen += 5.0f;
|
||||||
|
|
||||||
|
if (_this->hasAgc) {
|
||||||
|
if (ImGui::Checkbox((std::string("AGC##_agc_sel_") + _this->name).c_str(), &_this->agc)) {
|
||||||
|
if (_this->running) { _this->dev->setGainMode(SOAPY_SDR_RX, _this->channelId, _this->agc); }
|
||||||
|
// When disabled, reset the gains
|
||||||
|
if (!_this->agc) {
|
||||||
|
int i = 0;
|
||||||
|
for (auto gain : _this->gainList) {
|
||||||
|
_this->dev->setGain(SOAPY_SDR_RX, _this->channelId, gain, _this->uiGains[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_this->saveCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto gain : _this->gainList) {
|
for (auto gain : _this->gainList) {
|
||||||
ImGui::Text("%s gain", gain.c_str());
|
ImGui::Text("%s gain", gain.c_str());
|
||||||
@ -278,7 +318,7 @@ private:
|
|||||||
if (ImGui::SliderFloat((gain + std::string("##_gain_sel_") + _this->name).c_str(), &_this->uiGains[i],
|
if (ImGui::SliderFloat((gain + std::string("##_gain_sel_") + _this->name).c_str(), &_this->uiGains[i],
|
||||||
_this->gainRanges[i].minimum(), _this->gainRanges[i].maximum())) {
|
_this->gainRanges[i].minimum(), _this->gainRanges[i].maximum())) {
|
||||||
if (_this->running) {
|
if (_this->running) {
|
||||||
_this->dev->setGain(SOAPY_SDR_RX, 0, gain, _this->uiGains[i]);
|
_this->dev->setGain(SOAPY_SDR_RX, _this->channelId, gain, _this->uiGains[i]);
|
||||||
}
|
}
|
||||||
_this->saveCurrent();
|
_this->saveCurrent();
|
||||||
}
|
}
|
||||||
@ -315,9 +355,13 @@ private:
|
|||||||
double freq;
|
double freq;
|
||||||
double sampleRate;
|
double sampleRate;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
bool hasAgc = false;
|
||||||
|
bool agc = false;
|
||||||
std::vector<double> sampleRates;
|
std::vector<double> sampleRates;
|
||||||
int srId = -1;
|
int srId = -1;
|
||||||
float* uiGains;
|
float* uiGains;
|
||||||
|
int channelCount = 1;
|
||||||
|
int channelId = 0;
|
||||||
std::vector<std::string> gainList;
|
std::vector<std::string> gainList;
|
||||||
std::vector<SoapySDR::Range> gainRanges;
|
std::vector<SoapySDR::Range> gainRanges;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user