added lazy db thing

This commit is contained in:
Ryzerth 2021-02-12 22:44:29 +01:00
parent fe9af9ced6
commit a754becb46
3 changed files with 73 additions and 22 deletions

View File

@ -7,13 +7,13 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif() endif()
option(OPT_BUILD_RTL_TCP_SOURCE "Build RTL-TCP Source Module (no dependencies required)" ON) option(OPT_BUILD_RTL_TCP_SOURCE "Build RTL-TCP Source Module (no dependencies required)" ON)
option(OPT_BUILD_SPYSERVER_SOURCE "Build SpyServer Source Module (no dependencies required)" ON) option(OPT_BUILD_SPYSERVER_SOURCE "Build SpyServer Source Module (no dependencies required)" OFF)
option(OPT_BUILD_SOAPY_SOURCE "Build SoapySDR Source Module (Depedencies: soapysdr)" ON) option(OPT_BUILD_SOAPY_SOURCE "Build SoapySDR Source Module (Depedencies: soapysdr)" ON)
option(OPT_BUILD_AIRSPYHF_SOURCE "Build Airspy HF+ Source Module (Depedencies: libairspyhf)" ON) option(OPT_BUILD_AIRSPYHF_SOURCE "Build Airspy HF+ Source Module (Depedencies: libairspyhf)" ON)
option(OPT_BUILD_AIRSPY_SOURCE "Build Airspy Source Module (Depedencies: libairspy)" ON) option(OPT_BUILD_AIRSPY_SOURCE "Build Airspy Source Module (Depedencies: libairspy)" ON)
option(OPT_BUILD_SDRPLAY_SOURCE "Build SDRplay Source Module (Depedencies: libsdrplay)" ON) option(OPT_BUILD_SDRPLAY_SOURCE "Build SDRplay Source Module (Depedencies: libsdrplay)" OFF)
option(OPT_BUILD_PLUTOSDR_SOURCE "Build PlutoSDR Source Module (Depedencies: libiio, libad9361)" ON) option(OPT_BUILD_PLUTOSDR_SOURCE "Build PlutoSDR Source Module (Depedencies: libiio, libad9361)" ON)
option(OPT_BUILD_HACKRF_SOURCE "Build HackRF Source Module (Depedencies: libhackrf)" ON) option(OPT_BUILD_HACKRF_SOURCE "Build HackRF Source Module (Depedencies: libhackrf)" OFF)
option(OPT_BUILD_AUDIO_SINK "Build Audio Sink Module (Depedencies: portaudio)" ON) option(OPT_BUILD_AUDIO_SINK "Build Audio Sink Module (Depedencies: portaudio)" ON)
# Core of SDR++ # Core of SDR++

View File

@ -62,6 +62,7 @@ float* tempFFT;
float* FFTdata; float* FFTdata;
char buf[1024]; char buf[1024];
bool experimentalZoom = false; bool experimentalZoom = false;
bool lazyDb = false;
@ -71,7 +72,7 @@ void fftHandler(dsp::complex_t* samples, int count, void* ctx) {
int half = count / 2; int half = count / 2;
volk_32fc_s32f_power_spectrum_32f(tempFFT, (lv_32fc_t*)fft_out, count, count); volk_32fc_s32f_power_spectrum_32f(tempFFT, (lv_32fc_t*)fft_out, count, count);
volk_32f_s32f_multiply_32f(FFTdata, tempFFT, 0.5f, count); volk_32f_s32f_multiply_32f(FFTdata, tempFFT, lazyDb ? 1.0f : 0.5f, count);
memcpy(tempFFT, &FFTdata[half], half * sizeof(float)); memcpy(tempFFT, &FFTdata[half], half * sizeof(float));
memmove(&FFTdata[half], FFTdata, half * sizeof(float)); memmove(&FFTdata[half], FFTdata, half * sizeof(float));
@ -559,6 +560,8 @@ void drawWindow() {
spdlog::error("Will this make the software crash?"); spdlog::error("Will this make the software crash?");
} }
ImGui::Checkbox("Lazy dB Measurement", &lazyDb);
ImGui::Spacing(); ImGui::Spacing();
} }
@ -602,7 +605,7 @@ void drawWindow() {
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Max").x / 2.0)); ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Max").x / 2.0));
ImGui::Text("Max"); ImGui::Text("Max");
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10); ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
if (ImGui::VSliderFloat("##_8_", ImVec2(20.0, 150.0), &fftMax, 0.0, -100.0, "")) { if (ImGui::VSliderFloat("##_8_", ImVec2(20.0, 150.0), &fftMax, 0.0, lazyDb ? -160.0f : 100.0f, "")) {
fftMax = std::max<float>(fftMax, fftMin + 10); fftMax = std::max<float>(fftMax, fftMin + 10);
core::configManager.aquire(); core::configManager.aquire();
core::configManager.conf["max"] = fftMax; core::configManager.conf["max"] = fftMax;
@ -614,7 +617,7 @@ void drawWindow() {
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Min").x / 2.0)); ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Min").x / 2.0));
ImGui::Text("Min"); ImGui::Text("Min");
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10); ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
if (ImGui::VSliderFloat("##_9_", ImVec2(20.0, 150.0), &fftMin, 0.0, -100.0, "")) { if (ImGui::VSliderFloat("##_9_", ImVec2(20.0, 150.0), &fftMin, 0.0, lazyDb ? -160.0f : 100.0f, "")) {
fftMin = std::min<float>(fftMax - 10, fftMin); fftMin = std::min<float>(fftMax - 10, fftMin);
core::configManager.aquire(); core::configManager.aquire();
core::configManager.conf["min"] = fftMin; core::configManager.conf["min"] = fftMin;

View File

@ -28,6 +28,9 @@ public:
this->name = name; this->name = name;
// Init callbacks // Init callbacks
cbFuncs.EventCbFn = eventCB;
cbFuncs.StreamACbFn = streamCB;
cbFuncs.StreamBCbFn = streamCB;
sdrplay_api_Open(); sdrplay_api_Open();
@ -45,9 +48,11 @@ public:
refresh(); refresh();
selectFirst(); selectFirst();
if (sampleRateList.size() > 0) { // if (sampleRateList.size() > 0) {
sampleRate = sampleRateList[0]; // sampleRate = sampleRateList[0];
} // }
sampleRate = 8000000;
// Select device from config // Select device from config
// config.aquire(); // config.aquire();
@ -85,7 +90,26 @@ public:
for (unsigned int i = 0; i < numDev; i++) { for (unsigned int i = 0; i < numDev; i++) {
devList.push_back(devArr[i]); devList.push_back(devArr[i]);
devListTxt += devArr[i].SerNo; switch (devArr[i].hwVer) {
case SDRPLAY_RSP1_ID:
devListTxt += "RSP1 "; devListTxt += devArr[i].SerNo;
break;
case SDRPLAY_RSP1A_ID:
devListTxt += "RSP1A "; devListTxt += devArr[i].SerNo;
break;
case SDRPLAY_RSP2_ID:
devListTxt += "RSP2 "; devListTxt += devArr[i].SerNo;
break;
case SDRPLAY_RSPduo_ID:
devListTxt += "RSPduo "; devListTxt += devArr[i].SerNo;
break;
case SDRPLAY_RSPdx_ID:
devListTxt += "RSPdx "; devListTxt += devArr[i].SerNo;
break;
default:
devListTxt += "Unknown "; devListTxt += devArr[i].SerNo;
break;
}
devListTxt += '\0'; devListTxt += '\0';
} }
} }
@ -113,9 +137,14 @@ public:
return; return;
} }
err = sdrplay_api_Init(openDev.dev, &cbFuncs, this);
if (err != sdrplay_api_Success) {
const char* errStr = sdrplay_api_GetErrorString(err);
spdlog::error("Could not init RSP device: {0}", errStr);
return;
}
deviceOpen = true;
spdlog::info("Init OK");
} }
private: private:
@ -151,6 +180,19 @@ private:
} }
// Do start procedure here // Do start procedure here
sdrplay_api_ErrT err;
_this->openDevParams->devParams->samplesPerPkt = 8000000 / 200;
_this->openDevParams->devParams->fsFreq.fsHz = 8000000;
_this->openDevParams->rxChannelA->tunerParams.bwType = sdrplay_api_BW_8_000;
_this->openDevParams->rxChannelA->tunerParams.rfFreq.rfHz = _this->freq;
_this->openDevParams->rxChannelA->tunerParams.gain.LNAstate = 0;
//_this->openDevParams->devParams->
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Dev_Fs, sdrplay_api_Update_Ext1_None);
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_BwType, sdrplay_api_Update_Ext1_None);
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Frf, sdrplay_api_Update_Ext1_None);
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Gr, sdrplay_api_Update_Ext1_None);
_this->running = true; _this->running = true;
spdlog::info("SDRPlaySourceModule '{0}': Start!", _this->name); spdlog::info("SDRPlaySourceModule '{0}': Start!", _this->name);
@ -173,7 +215,8 @@ private:
static void tune(double freq, void* ctx) { static void tune(double freq, void* ctx) {
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx; SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
if (_this->running) { if (_this->running) {
// Tune here _this->openDevParams->rxChannelA->tunerParams.rfFreq.rfHz = _this->freq;
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Frf, sdrplay_api_Update_Ext1_None);
} }
_this->freq = freq; _this->freq = freq;
spdlog::info("SDRPlaySourceModule '{0}': Tune: {1}!", _this->name, freq); spdlog::info("SDRPlaySourceModule '{0}': Tune: {1}!", _this->name, freq);
@ -187,24 +230,28 @@ private:
ImGui::SetNextItemWidth(menuWidth); ImGui::SetNextItemWidth(menuWidth);
if (_this->running) { style::beginDisabled(); }
if (ImGui::Combo(CONCAT("##sdrplay_dev", _this->name), &_this->devId, _this->devListTxt.c_str())) { if (ImGui::Combo(CONCAT("##sdrplay_dev", _this->name), &_this->devId, _this->devListTxt.c_str())) {
} }
if (_this->running) { style::endDisabled(); } if (_this->running) { style::endDisabled(); }
} }
static void eventCB(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, static void streamCB(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params,
unsigned int numSamples, unsigned int reset, void *cbContext) { unsigned int numSamples, unsigned int reset, void *cbContext) {
// Code here SDRPlaySourceModule* _this = (SDRPlaySourceModule*)cbContext;
if (!_this->running) { return; }
for (int i = 0; i < numSamples; i++) {
_this->stream.writeBuf[i].i = (float)xi[i] / 32768.0f;
_this->stream.writeBuf[i].q = (float)xq[i] / 32768.0f;
}
_this->stream.swap(numSamples);
} }
static void tunerCB(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, static void eventCB(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner,
sdrplay_api_EventParamsT *params, void *cbContext) { sdrplay_api_EventParamsT *params, void *cbContext) {
// Code here SDRPlaySourceModule* _this = (SDRPlaySourceModule*)cbContext;
} }
std::string name; std::string name;
@ -214,8 +261,9 @@ private:
SourceManager::SourceHandler handler; SourceManager::SourceHandler handler;
bool running = false; bool running = false;
double freq; double freq;
bool deviceOpen = false;
sdrplay_api_CallbackFnsT cnFuncs; sdrplay_api_CallbackFnsT cbFuncs;
sdrplay_api_DeviceT openDev; sdrplay_api_DeviceT openDev;
sdrplay_api_DeviceParamsT * openDevParams; sdrplay_api_DeviceParamsT * openDevParams;