From 1ace1f58d06f679eb37a6cbfad68e265f711c0be Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 4 Oct 2017 01:51:56 +0200 Subject: [PATCH] CRLF problem --- devices/limesdr/devicelimesdr.cpp | 650 ++++----- devices/limesdr/devicelimesdr.h | 112 +- devices/limesdr/devicelimesdrparam.h | 140 +- libsqlite3/libsqlite3.pro | 50 +- plugins/channelrx/chanalyzerng/chanalyzerng.h | 366 ++--- .../chanalyzerng/chanalyzernggui.cpp | 1090 +++++++------- .../channelrx/chanalyzerng/chanalyzernggui.ui | 1296 ++++++++--------- .../limesdroutput/limesdroutputsettings.h | 124 +- .../samplesource/fcdproplus/fcdproplus.pro | 86 +- .../limesdrinput/limesdrinputsettings.h | 152 +- sdrbase/audio/audioinput.h | 138 +- sdrbase/dsp/basebandsamplesource.cpp | 116 +- sdrbase/dsp/basebandsamplesource.h | 142 +- sdrbase/dsp/devicesamplesink.cpp | 90 +- sdrbase/gui/cwkeyergui.ui | 882 +++++------ sdrbase/gui/myposdialog.ui | 244 ++-- sdrbase/gui/valuedialz.h | 166 +-- 17 files changed, 2922 insertions(+), 2922 deletions(-) diff --git a/devices/limesdr/devicelimesdr.cpp b/devices/limesdr/devicelimesdr.cpp index 1806072c1..6902b2b2e 100644 --- a/devices/limesdr/devicelimesdr.cpp +++ b/devices/limesdr/devicelimesdr.cpp @@ -1,325 +1,325 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include "devicelimesdr.h" - -bool DeviceLimeSDR::setNCOFrequency(lms_device_t *device, bool dir_tx, std::size_t chan, bool enable, float frequency) -{ - if (enable) - { - bool positive; - float_type freqs[LMS_NCO_VAL_COUNT]; - float_type phos[LMS_NCO_VAL_COUNT]; - - if (LMS_GetNCOFrequency(device, dir_tx, chan, freqs, phos) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot get NCO frequencies and phases\n"); - } - - if (frequency < 0) - { - positive = false; - frequency = -frequency; - } - else - { - positive = true; - } - - freqs[0] = frequency; - - if (LMS_SetNCOFrequency(device, dir_tx, chan, freqs, 0.0f) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot set frequency to %f\n", frequency); - return false; - } - - if (LMS_SetNCOIndex(device, dir_tx, chan, 0, !positive) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot set conversion direction %sfreq\n", positive ? "+" : "-"); - return false; - } - - return true; - } - else - { - if (LMS_SetNCOIndex(device, dir_tx, chan, LMS_NCO_VAL_COUNT, true) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot disable NCO\n"); - return false; - } - else - { - fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: NCO disabled\n"); - return true; - } - } -} - -bool DeviceLimeSDR::SetRFELNA_dB(lms_device_t *device, std::size_t chan, int value) -{ - if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set channel to #%lu\n", chan); - return false; - } - - if (value > 30) { - value = 30; - } - - int val = value - 30; - - int g_lna_rfe = 0; - if (val >= 0) g_lna_rfe = 15; - else if (val >= -1) g_lna_rfe = 14; - else if (val >= -2) g_lna_rfe = 13; - else if (val >= -3) g_lna_rfe = 12; - else if (val >= -4) g_lna_rfe = 11; - else if (val >= -5) g_lna_rfe = 10; - else if (val >= -6) g_lna_rfe = 9; - else if (val >= -9) g_lna_rfe = 8; - else if (val >= -12) g_lna_rfe = 7; - else if (val >= -15) g_lna_rfe = 6; - else if (val >= -18) g_lna_rfe = 5; - else if (val >= -21) g_lna_rfe = 4; - else if (val >= -24) g_lna_rfe = 3; - else if (val >= -27) g_lna_rfe = 2; - else g_lna_rfe = 1; - - if (LMS_WriteParam(device, LMS7param(G_LNA_RFE), g_lna_rfe) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set LNA gain to %d (%d)\n", value, g_lna_rfe); - return false; - } - - return true; -} - -bool DeviceLimeSDR::SetRFETIA_dB(lms_device_t *device, std::size_t chan, int value) -{ - if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRFETIA_dB: cannot set channel to #%lu\n", chan); - return false; - } - - if (value > 3) { - value = 3; - } else if (value < 1) { - value = 1; - } - - int g_tia_rfe = value; - - if (LMS_WriteParam(device, LMS7param(G_TIA_RFE), g_tia_rfe) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set TIA gain to %d (%d)\n", value, g_tia_rfe); - return false; - } - - return true; -} - -bool DeviceLimeSDR::SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float value) -{ - if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set channel to #%lu\n", chan); - return false; - } - - int g_pga_rbb = (int)(value + 12.5); - if (g_pga_rbb > 0x1f) g_pga_rbb = 0x1f; - if (g_pga_rbb < 0) g_pga_rbb = 0; - - if (LMS_WriteParam(device, LMS7param(G_PGA_RBB), g_pga_rbb) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set G_PGA_RBB to %d\n", g_pga_rbb); - return false; - } - - int rcc_ctl_pga_rbb = (430.0*pow(0.65, (g_pga_rbb/10.0))-110.35)/20.4516 + 16; - - int c_ctl_pga_rbb = 0; - if (0 <= g_pga_rbb && g_pga_rbb < 8) c_ctl_pga_rbb = 3; - if (8 <= g_pga_rbb && g_pga_rbb < 13) c_ctl_pga_rbb = 2; - if (13 <= g_pga_rbb && g_pga_rbb < 21) c_ctl_pga_rbb = 1; - if (21 <= g_pga_rbb) c_ctl_pga_rbb = 0; - - if (LMS_WriteParam(device, LMS7param(RCC_CTL_PGA_RBB), rcc_ctl_pga_rbb) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set RCC_CTL_PGA_RBB to %d\n", rcc_ctl_pga_rbb); - return false; - } - - if (LMS_WriteParam(device, LMS7param(C_CTL_PGA_RBB), c_ctl_pga_rbb) < 0) - { - fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set C_CTL_PGA_RBB to %d\n", c_ctl_pga_rbb); - return false; - } - - return true; -} - -bool DeviceLimeSDR::setRxAntennaPath(lms_device_t *device, std::size_t chan, int path) -{ -// if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) -// { -// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set channel to #%lu\n", chan); -// return false; -// } -// -// int sel_path_rfe = 0; -// switch ((PathRFE) path) -// { -// case PATH_RFE_NONE: sel_path_rfe = 0; break; -// case PATH_RFE_LNAH: sel_path_rfe = 1; break; -// case PATH_RFE_LNAL: sel_path_rfe = 2; break; -// case PATH_RFE_LNAW: sel_path_rfe = 3; break; -// case PATH_RFE_LB1: sel_path_rfe = 3; break; -// case PATH_RFE_LB2: sel_path_rfe = 2; break; -// } -// -// int pd_lna_rfe = 1; -// switch ((PathRFE) path) -// { -// case PATH_RFE_LNAH: -// case PATH_RFE_LNAL: -// case PATH_RFE_LNAW: pd_lna_rfe = 0; break; -// default: break; -// } -// -// int pd_rloopb_1_rfe = (path == (int) PATH_RFE_LB1) ? 0 : 1; -// int pd_rloopb_2_rfe = (path == (int) PATH_RFE_LB2) ? 0 : 1; -// int en_inshsw_l_rfe = (path == (int) PATH_RFE_LNAL ) ? 0 : 1; -// int en_inshsw_w_rfe = (path == (int) PATH_RFE_LNAW) ? 0 : 1; -// int en_inshsw_lb1_rfe = (path == (int) PATH_RFE_LB1) ? 0 : 1; -// int en_inshsw_lb2_rfe = (path == (int) PATH_RFE_LB2) ? 0 : 1; -// -// int ret = 0; -// -// ret += LMS_WriteParam(device, LMS7param(PD_LNA_RFE), pd_lna_rfe); -// ret += LMS_WriteParam(device, LMS7param(PD_RLOOPB_1_RFE), pd_rloopb_1_rfe); -// ret += LMS_WriteParam(device, LMS7param(PD_RLOOPB_2_RFE), pd_rloopb_2_rfe); -// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_LB1_RFE), en_inshsw_lb1_rfe); -// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_LB2_RFE), en_inshsw_lb2_rfe); -// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_L_RFE), en_inshsw_l_rfe); -// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_W_RFE), en_inshsw_w_rfe); -// ret += LMS_WriteParam(device, LMS7param(SEL_PATH_RFE), sel_path_rfe); -// -// if (ret < 0) -// { -// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set channel #%lu to %d\n", chan, path); -// return false; -// } -// -// //enable/disable the loopback path -// const bool loopback = (path == (int) PATH_RFE_LB1) or (path == (int) PATH_RFE_LB2); -// -// if (LMS_WriteParam(device, LMS7param(EN_LOOPB_TXPAD_TRF), loopback ? 1 : 0) < 0) -// { -// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot %sset loopback on channel #%lu\n", loopback ? "" : "re", chan); -// return false; -// } -// -// //update external band-selection to match -// //this->UpdateExternalBandSelect(); -// -// return true; - - switch ((PathRxRFE) path) - { - case PATH_RFE_LNAH: - if (LMS_SetAntenna(device, LMS_CH_RX, chan, 1) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAH\n"); - return false; - } - break; - case PATH_RFE_LNAL: - if (LMS_SetAntenna(device, LMS_CH_RX, chan, 2) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAL\n"); - return false; - } - break; - case PATH_RFE_LNAW: - if (LMS_SetAntenna(device, LMS_CH_RX, chan, 3) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAW\n"); - return false; - } - break; - case PATH_RFE_LB1: - if (LMS_SetAntenna(device, LMS_CH_TX, chan, 1) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to Loopback TX1\n"); - return false; - } - break; - case PATH_RFE_LB2: - if (LMS_SetAntenna(device, LMS_CH_TX, chan, 2) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to Loopback TX2\n"); - return false; - } - break; - case PATH_RFE_RX_NONE: - default: - if (LMS_SetAntenna(device, LMS_CH_RX, chan, 0) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to none\n"); - return false; - } - } - - return true; -} - -bool DeviceLimeSDR::setTxAntennaPath(lms_device_t *device, std::size_t chan, int path) -{ - switch ((PathTxRFE) path) - { - case PATH_RFE_TXRF1: - if (LMS_SetAntenna(device, LMS_CH_TX, chan, 1) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to TXRF1\n"); - return false; - } - break; - case PATH_RFE_TXRF2: - if (LMS_SetAntenna(device, LMS_CH_TX, chan, 2) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to TXRF2\n"); - return false; - } - break; - case PATH_RFE_TX_NONE: - default: - if (LMS_SetAntenna(device, LMS_CH_TX, chan, 0) < 0) - { - fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to none\n"); - return false; - } - } - - return true; -} +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include "devicelimesdr.h" + +bool DeviceLimeSDR::setNCOFrequency(lms_device_t *device, bool dir_tx, std::size_t chan, bool enable, float frequency) +{ + if (enable) + { + bool positive; + float_type freqs[LMS_NCO_VAL_COUNT]; + float_type phos[LMS_NCO_VAL_COUNT]; + + if (LMS_GetNCOFrequency(device, dir_tx, chan, freqs, phos) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot get NCO frequencies and phases\n"); + } + + if (frequency < 0) + { + positive = false; + frequency = -frequency; + } + else + { + positive = true; + } + + freqs[0] = frequency; + + if (LMS_SetNCOFrequency(device, dir_tx, chan, freqs, 0.0f) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot set frequency to %f\n", frequency); + return false; + } + + if (LMS_SetNCOIndex(device, dir_tx, chan, 0, !positive) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot set conversion direction %sfreq\n", positive ? "+" : "-"); + return false; + } + + return true; + } + else + { + if (LMS_SetNCOIndex(device, dir_tx, chan, LMS_NCO_VAL_COUNT, true) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot disable NCO\n"); + return false; + } + else + { + fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: NCO disabled\n"); + return true; + } + } +} + +bool DeviceLimeSDR::SetRFELNA_dB(lms_device_t *device, std::size_t chan, int value) +{ + if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set channel to #%lu\n", chan); + return false; + } + + if (value > 30) { + value = 30; + } + + int val = value - 30; + + int g_lna_rfe = 0; + if (val >= 0) g_lna_rfe = 15; + else if (val >= -1) g_lna_rfe = 14; + else if (val >= -2) g_lna_rfe = 13; + else if (val >= -3) g_lna_rfe = 12; + else if (val >= -4) g_lna_rfe = 11; + else if (val >= -5) g_lna_rfe = 10; + else if (val >= -6) g_lna_rfe = 9; + else if (val >= -9) g_lna_rfe = 8; + else if (val >= -12) g_lna_rfe = 7; + else if (val >= -15) g_lna_rfe = 6; + else if (val >= -18) g_lna_rfe = 5; + else if (val >= -21) g_lna_rfe = 4; + else if (val >= -24) g_lna_rfe = 3; + else if (val >= -27) g_lna_rfe = 2; + else g_lna_rfe = 1; + + if (LMS_WriteParam(device, LMS7param(G_LNA_RFE), g_lna_rfe) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set LNA gain to %d (%d)\n", value, g_lna_rfe); + return false; + } + + return true; +} + +bool DeviceLimeSDR::SetRFETIA_dB(lms_device_t *device, std::size_t chan, int value) +{ + if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRFETIA_dB: cannot set channel to #%lu\n", chan); + return false; + } + + if (value > 3) { + value = 3; + } else if (value < 1) { + value = 1; + } + + int g_tia_rfe = value; + + if (LMS_WriteParam(device, LMS7param(G_TIA_RFE), g_tia_rfe) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRFELNA_dB: cannot set TIA gain to %d (%d)\n", value, g_tia_rfe); + return false; + } + + return true; +} + +bool DeviceLimeSDR::SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float value) +{ + if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set channel to #%lu\n", chan); + return false; + } + + int g_pga_rbb = (int)(value + 12.5); + if (g_pga_rbb > 0x1f) g_pga_rbb = 0x1f; + if (g_pga_rbb < 0) g_pga_rbb = 0; + + if (LMS_WriteParam(device, LMS7param(G_PGA_RBB), g_pga_rbb) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set G_PGA_RBB to %d\n", g_pga_rbb); + return false; + } + + int rcc_ctl_pga_rbb = (430.0*pow(0.65, (g_pga_rbb/10.0))-110.35)/20.4516 + 16; + + int c_ctl_pga_rbb = 0; + if (0 <= g_pga_rbb && g_pga_rbb < 8) c_ctl_pga_rbb = 3; + if (8 <= g_pga_rbb && g_pga_rbb < 13) c_ctl_pga_rbb = 2; + if (13 <= g_pga_rbb && g_pga_rbb < 21) c_ctl_pga_rbb = 1; + if (21 <= g_pga_rbb) c_ctl_pga_rbb = 0; + + if (LMS_WriteParam(device, LMS7param(RCC_CTL_PGA_RBB), rcc_ctl_pga_rbb) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set RCC_CTL_PGA_RBB to %d\n", rcc_ctl_pga_rbb); + return false; + } + + if (LMS_WriteParam(device, LMS7param(C_CTL_PGA_RBB), c_ctl_pga_rbb) < 0) + { + fprintf(stderr, "DeviceLimeSDR::SetRBBPGA_dB: cannot set C_CTL_PGA_RBB to %d\n", c_ctl_pga_rbb); + return false; + } + + return true; +} + +bool DeviceLimeSDR::setRxAntennaPath(lms_device_t *device, std::size_t chan, int path) +{ +// if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0) +// { +// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set channel to #%lu\n", chan); +// return false; +// } +// +// int sel_path_rfe = 0; +// switch ((PathRFE) path) +// { +// case PATH_RFE_NONE: sel_path_rfe = 0; break; +// case PATH_RFE_LNAH: sel_path_rfe = 1; break; +// case PATH_RFE_LNAL: sel_path_rfe = 2; break; +// case PATH_RFE_LNAW: sel_path_rfe = 3; break; +// case PATH_RFE_LB1: sel_path_rfe = 3; break; +// case PATH_RFE_LB2: sel_path_rfe = 2; break; +// } +// +// int pd_lna_rfe = 1; +// switch ((PathRFE) path) +// { +// case PATH_RFE_LNAH: +// case PATH_RFE_LNAL: +// case PATH_RFE_LNAW: pd_lna_rfe = 0; break; +// default: break; +// } +// +// int pd_rloopb_1_rfe = (path == (int) PATH_RFE_LB1) ? 0 : 1; +// int pd_rloopb_2_rfe = (path == (int) PATH_RFE_LB2) ? 0 : 1; +// int en_inshsw_l_rfe = (path == (int) PATH_RFE_LNAL ) ? 0 : 1; +// int en_inshsw_w_rfe = (path == (int) PATH_RFE_LNAW) ? 0 : 1; +// int en_inshsw_lb1_rfe = (path == (int) PATH_RFE_LB1) ? 0 : 1; +// int en_inshsw_lb2_rfe = (path == (int) PATH_RFE_LB2) ? 0 : 1; +// +// int ret = 0; +// +// ret += LMS_WriteParam(device, LMS7param(PD_LNA_RFE), pd_lna_rfe); +// ret += LMS_WriteParam(device, LMS7param(PD_RLOOPB_1_RFE), pd_rloopb_1_rfe); +// ret += LMS_WriteParam(device, LMS7param(PD_RLOOPB_2_RFE), pd_rloopb_2_rfe); +// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_LB1_RFE), en_inshsw_lb1_rfe); +// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_LB2_RFE), en_inshsw_lb2_rfe); +// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_L_RFE), en_inshsw_l_rfe); +// ret += LMS_WriteParam(device, LMS7param(EN_INSHSW_W_RFE), en_inshsw_w_rfe); +// ret += LMS_WriteParam(device, LMS7param(SEL_PATH_RFE), sel_path_rfe); +// +// if (ret < 0) +// { +// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot set channel #%lu to %d\n", chan, path); +// return false; +// } +// +// //enable/disable the loopback path +// const bool loopback = (path == (int) PATH_RFE_LB1) or (path == (int) PATH_RFE_LB2); +// +// if (LMS_WriteParam(device, LMS7param(EN_LOOPB_TXPAD_TRF), loopback ? 1 : 0) < 0) +// { +// fprintf(stderr, "DeviceLimeSDR::setAntennaPath: cannot %sset loopback on channel #%lu\n", loopback ? "" : "re", chan); +// return false; +// } +// +// //update external band-selection to match +// //this->UpdateExternalBandSelect(); +// +// return true; + + switch ((PathRxRFE) path) + { + case PATH_RFE_LNAH: + if (LMS_SetAntenna(device, LMS_CH_RX, chan, 1) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAH\n"); + return false; + } + break; + case PATH_RFE_LNAL: + if (LMS_SetAntenna(device, LMS_CH_RX, chan, 2) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAL\n"); + return false; + } + break; + case PATH_RFE_LNAW: + if (LMS_SetAntenna(device, LMS_CH_RX, chan, 3) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to LNAW\n"); + return false; + } + break; + case PATH_RFE_LB1: + if (LMS_SetAntenna(device, LMS_CH_TX, chan, 1) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to Loopback TX1\n"); + return false; + } + break; + case PATH_RFE_LB2: + if (LMS_SetAntenna(device, LMS_CH_TX, chan, 2) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to Loopback TX2\n"); + return false; + } + break; + case PATH_RFE_RX_NONE: + default: + if (LMS_SetAntenna(device, LMS_CH_RX, chan, 0) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setRxAntennaPath: cannot set to none\n"); + return false; + } + } + + return true; +} + +bool DeviceLimeSDR::setTxAntennaPath(lms_device_t *device, std::size_t chan, int path) +{ + switch ((PathTxRFE) path) + { + case PATH_RFE_TXRF1: + if (LMS_SetAntenna(device, LMS_CH_TX, chan, 1) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to TXRF1\n"); + return false; + } + break; + case PATH_RFE_TXRF2: + if (LMS_SetAntenna(device, LMS_CH_TX, chan, 2) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to TXRF2\n"); + return false; + } + break; + case PATH_RFE_TX_NONE: + default: + if (LMS_SetAntenna(device, LMS_CH_TX, chan, 0) < 0) + { + fprintf(stderr, "DeviceLimeSDR::setTxAntennaPath: cannot set to none\n"); + return false; + } + } + + return true; +} diff --git a/devices/limesdr/devicelimesdr.h b/devices/limesdr/devicelimesdr.h index 8a50ceb94..4cc34d177 100644 --- a/devices/limesdr/devicelimesdr.h +++ b/devices/limesdr/devicelimesdr.h @@ -1,56 +1,56 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef DEVICES_LIMESDR_DEVICELIMESDR_H_ -#define DEVICES_LIMESDR_DEVICELIMESDR_H_ - -#include "lime/LimeSuite.h" - -class DeviceLimeSDR -{ -public: - enum PathRxRFE - { - PATH_RFE_RX_NONE = 0, - PATH_RFE_LNAH, - PATH_RFE_LNAL, - PATH_RFE_LNAW, - PATH_RFE_LB1, - PATH_RFE_LB2 - }; - - enum PathTxRFE - { - PATH_RFE_TX_NONE = 0, - PATH_RFE_TXRF1, - PATH_RFE_TXRF2, - }; - - /** set NCO frequency with positive or negative frequency (deals with up/down convert). Enables or disables NCO */ - static bool setNCOFrequency(lms_device_t *device, bool dir_tx, std::size_t chan, bool enable, float frequency); - /** set LNA gain Range: [1-30] (dB) **/ - static bool SetRFELNA_dB(lms_device_t *device, std::size_t chan, int value); - /** set TIA gain Range: [1-3] **/ - static bool SetRFETIA_dB(lms_device_t *device, std::size_t chan, int value); - /** set PGA gain Range: [0-32] (dB) **/ - static bool SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float value); - /** Set Rx antenna path **/ - static bool setRxAntennaPath(lms_device_t *device, std::size_t chan, int path); - /** Set Tx antenna path **/ - static bool setTxAntennaPath(lms_device_t *device, std::size_t chan, int path); -}; - -#endif /* DEVICES_LIMESDR_DEVICELIMESDR_H_ */ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef DEVICES_LIMESDR_DEVICELIMESDR_H_ +#define DEVICES_LIMESDR_DEVICELIMESDR_H_ + +#include "lime/LimeSuite.h" + +class DeviceLimeSDR +{ +public: + enum PathRxRFE + { + PATH_RFE_RX_NONE = 0, + PATH_RFE_LNAH, + PATH_RFE_LNAL, + PATH_RFE_LNAW, + PATH_RFE_LB1, + PATH_RFE_LB2 + }; + + enum PathTxRFE + { + PATH_RFE_TX_NONE = 0, + PATH_RFE_TXRF1, + PATH_RFE_TXRF2, + }; + + /** set NCO frequency with positive or negative frequency (deals with up/down convert). Enables or disables NCO */ + static bool setNCOFrequency(lms_device_t *device, bool dir_tx, std::size_t chan, bool enable, float frequency); + /** set LNA gain Range: [1-30] (dB) **/ + static bool SetRFELNA_dB(lms_device_t *device, std::size_t chan, int value); + /** set TIA gain Range: [1-3] **/ + static bool SetRFETIA_dB(lms_device_t *device, std::size_t chan, int value); + /** set PGA gain Range: [0-32] (dB) **/ + static bool SetRBBPGA_dB(lms_device_t *device, std::size_t chan, float value); + /** Set Rx antenna path **/ + static bool setRxAntennaPath(lms_device_t *device, std::size_t chan, int path); + /** Set Tx antenna path **/ + static bool setTxAntennaPath(lms_device_t *device, std::size_t chan, int path); +}; + +#endif /* DEVICES_LIMESDR_DEVICELIMESDR_H_ */ diff --git a/devices/limesdr/devicelimesdrparam.h b/devices/limesdr/devicelimesdrparam.h index 779eb35b9..34dfd8925 100644 --- a/devices/limesdr/devicelimesdrparam.h +++ b/devices/limesdr/devicelimesdrparam.h @@ -1,70 +1,70 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ -#define DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ - -#include "lime/LimeSuite.h" - -/** - * This structure refers to one physical device shared among parties (logical devices represented by - * the DeviceSinkAPI or DeviceSourceAPI). - * It allows storing information on the common resources in one place and is shared among participants. - * There is only one copy that is constructed by the first participant and destroyed by the last. - * A participant knows it is the first or last by checking the lists of buddies (Rx + Tx). - */ -struct DeviceLimeSDRParams -{ - lms_device_t *m_dev; //!< device handle - uint32_t m_nbRxChannels; //!< number of Rx channels (normally 2, we'll see if we really use it...) - uint32_t m_nbTxChannels; //!< number of Tx channels (normally 2, we'll see if we really use it...) - lms_range_t m_lpfRangeRx; //!< Low pass filter range information (Rx side) - lms_range_t m_lpfRangeTx; //!< Low pass filter range information (Tx side) - lms_range_t m_loRangeRx; //!< LO range for Rx - lms_range_t m_loRangeTx; //!< LO range for Tx - lms_range_t m_srRangeRx; //!< ADC sample rate range - lms_range_t m_srRangeTx; //!< DAC sample rate range - float m_sampleRate; //!< ADC/DAC sample rate - int m_log2OvSRRx; //!< log2 of Rx oversampling (0..5) - int m_log2OvSRTx; //!< log2 of Tx oversampling (0..5) - float m_rxFrequency; //!< Rx frequency - float m_txFrequency; //!< Tx frequency - - DeviceLimeSDRParams() : - m_dev(0), - m_nbRxChannels(0), - m_nbTxChannels(0), - m_sampleRate(1e6), - m_log2OvSRRx(0), - m_log2OvSRTx(0), - m_rxFrequency(1e6), - m_txFrequency(1e6) - { - } - - /** - * Opens and initialize the device and obtain information (# channels, ranges, ...) - */ - bool open(lms_info_str_t deviceStr); - void close(); - lms_device_t *getDevice() { return m_dev; } - - ~DeviceLimeSDRParams() - { - } -}; - -#endif /* DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ */ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ +#define DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ + +#include "lime/LimeSuite.h" + +/** + * This structure refers to one physical device shared among parties (logical devices represented by + * the DeviceSinkAPI or DeviceSourceAPI). + * It allows storing information on the common resources in one place and is shared among participants. + * There is only one copy that is constructed by the first participant and destroyed by the last. + * A participant knows it is the first or last by checking the lists of buddies (Rx + Tx). + */ +struct DeviceLimeSDRParams +{ + lms_device_t *m_dev; //!< device handle + uint32_t m_nbRxChannels; //!< number of Rx channels (normally 2, we'll see if we really use it...) + uint32_t m_nbTxChannels; //!< number of Tx channels (normally 2, we'll see if we really use it...) + lms_range_t m_lpfRangeRx; //!< Low pass filter range information (Rx side) + lms_range_t m_lpfRangeTx; //!< Low pass filter range information (Tx side) + lms_range_t m_loRangeRx; //!< LO range for Rx + lms_range_t m_loRangeTx; //!< LO range for Tx + lms_range_t m_srRangeRx; //!< ADC sample rate range + lms_range_t m_srRangeTx; //!< DAC sample rate range + float m_sampleRate; //!< ADC/DAC sample rate + int m_log2OvSRRx; //!< log2 of Rx oversampling (0..5) + int m_log2OvSRTx; //!< log2 of Tx oversampling (0..5) + float m_rxFrequency; //!< Rx frequency + float m_txFrequency; //!< Tx frequency + + DeviceLimeSDRParams() : + m_dev(0), + m_nbRxChannels(0), + m_nbTxChannels(0), + m_sampleRate(1e6), + m_log2OvSRRx(0), + m_log2OvSRTx(0), + m_rxFrequency(1e6), + m_txFrequency(1e6) + { + } + + /** + * Opens and initialize the device and obtain information (# channels, ranges, ...) + */ + bool open(lms_info_str_t deviceStr); + void close(); + lms_device_t *getDevice() { return m_dev; } + + ~DeviceLimeSDRParams() + { + } +}; + +#endif /* DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ */ diff --git a/libsqlite3/libsqlite3.pro b/libsqlite3/libsqlite3.pro index 2bd77a68c..475d5884e 100644 --- a/libsqlite3/libsqlite3.pro +++ b/libsqlite3/libsqlite3.pro @@ -1,25 +1,25 @@ -#-------------------------------------------------------- -# -# Pro file for Android and Windows builds with Qt Creator -# -#-------------------------------------------------------- - -QT += core - -TEMPLATE = lib -TARGET = libsqlite3 - -CONFIG(MINGW32):LIBSQLITE3SRC = "." -CONFIG(MINGW64):LIBSQLITE3SRC = "." - -CONFIG(MINGW32):INCLUDEPATH += "src" -CONFIG(MINGW64):INCLUDEPATH += "src" - -SOURCES = $$LIBSQLITE3SRC/src/sqlite3.c - -HEADERS = $$LIBSQLITE3SRC/src/sqlite3.h\ - $$LIBSQLITE3SRC/src/sqlite3ext.h - -CONFIG(ANDROID):CONFIG += mobility -CONFIG(ANDROID):MOBILITY = - +#-------------------------------------------------------- +# +# Pro file for Android and Windows builds with Qt Creator +# +#-------------------------------------------------------- + +QT += core + +TEMPLATE = lib +TARGET = libsqlite3 + +CONFIG(MINGW32):LIBSQLITE3SRC = "." +CONFIG(MINGW64):LIBSQLITE3SRC = "." + +CONFIG(MINGW32):INCLUDEPATH += "src" +CONFIG(MINGW64):INCLUDEPATH += "src" + +SOURCES = $$LIBSQLITE3SRC/src/sqlite3.c + +HEADERS = $$LIBSQLITE3SRC/src/sqlite3.h\ + $$LIBSQLITE3SRC/src/sqlite3ext.h + +CONFIG(ANDROID):CONFIG += mobility +CONFIG(ANDROID):MOBILITY = + diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.h b/plugins/channelrx/chanalyzerng/chanalyzerng.h index c58b74105..671e12c92 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.h +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.h @@ -1,183 +1,183 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef INCLUDE_CHANALYZERNG_H -#define INCLUDE_CHANALYZERNG_H - -#include -#include -#include - -#include "dsp/interpolator.h" -#include "dsp/ncof.h" -#include "dsp/fftfilt.h" -#include "audio/audiofifo.h" -#include "util/message.h" - -#define ssbFftLen 1024 - -class ChannelAnalyzerNG : public BasebandSampleSink { -public: - ChannelAnalyzerNG(BasebandSampleSink* m_sampleSink); - virtual ~ChannelAnalyzerNG(); - - void configure(MessageQueue* messageQueue, - int channelSampleRate, - Real Bandwidth, - Real LowCutoff, - int spanLog2, - bool ssb); - - int getInputSampleRate() const { return m_running.m_inputSampleRate; } - int getChannelSampleRate() const { return m_running.m_channelSampleRate; } - double getMagSq() const { return m_magsq; } - - virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); - virtual void start(); - virtual void stop(); - virtual bool handleMessage(const Message& cmd); - -private: - class MsgConfigureChannelAnalyzer : public Message { - MESSAGE_CLASS_DECLARATION - - public: - int getChannelSampleRate() const { return m_channelSampleRate; } - Real getBandwidth() const { return m_Bandwidth; } - Real getLoCutoff() const { return m_LowCutoff; } - int getSpanLog2() const { return m_spanLog2; } - bool getSSB() const { return m_ssb; } - - static MsgConfigureChannelAnalyzer* create( - int channelSampleRate, - Real Bandwidth, - Real LowCutoff, - int spanLog2, - bool ssb) - { - return new MsgConfigureChannelAnalyzer(channelSampleRate, Bandwidth, LowCutoff, spanLog2, ssb); - } - - private: - int m_channelSampleRate; - Real m_Bandwidth; - Real m_LowCutoff; - int m_spanLog2; - bool m_ssb; - - MsgConfigureChannelAnalyzer( - int channelSampleRate, - Real Bandwidth, - Real LowCutoff, - int spanLog2, - bool ssb) : - Message(), - m_channelSampleRate(channelSampleRate), - m_Bandwidth(Bandwidth), - m_LowCutoff(LowCutoff), - m_spanLog2(spanLog2), - m_ssb(ssb) - { } - }; - - struct Config - { - int m_frequency; - int m_inputSampleRate; - int m_channelSampleRate; - Real m_Bandwidth; - Real m_LowCutoff; - int m_spanLog2; - bool m_ssb; - - Config() : - m_frequency(0), - m_inputSampleRate(96000), - m_channelSampleRate(96000), - m_Bandwidth(5000), - m_LowCutoff(300), - m_spanLog2(3), - m_ssb(false) - {} - }; - - Config m_config; - Config m_running; - - int m_undersampleCount; - fftfilt::cmplx m_sum; - bool m_usb; - double m_magsq; - bool m_useInterpolator; - - NCOF m_nco; - Interpolator m_interpolator; - Real m_interpolatorDistance; - Real m_interpolatorDistanceRemain; - - fftfilt* SSBFilter; - fftfilt* DSBFilter; - - BasebandSampleSink* m_sampleSink; - SampleVector m_sampleBuffer; - QMutex m_settingsMutex; - - void apply(bool force = false); - - void processOneSample(Complex& c, fftfilt::cmplx *sideband) - { - int n_out; - int decim = 1<runSSB(c, &sideband, m_usb); - } - else - { - n_out = DSBFilter->runDSB(c, &sideband); - } - - for (int i = 0; i < n_out; i++) - { - // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display - // smart decimation with bit gain using float arithmetic (23 bits significand) - - m_sum += sideband[i]; - - if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1) - { - m_sum /= decim; - m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30); - - if (m_running.m_ssb & !m_usb) - { // invert spectrum for LSB - //m_sampleBuffer.push_back(Sample(m_sum.imag() * 32768.0, m_sum.real() * 32768.0)); - m_sampleBuffer.push_back(Sample(m_sum.imag(), m_sum.real())); - } - else - { - //m_sampleBuffer.push_back(Sample(m_sum.real() * 32768.0, m_sum.imag() * 32768.0)); - m_sampleBuffer.push_back(Sample(m_sum.real(), m_sum.imag())); - } - - m_sum = 0; - } - } - } -}; - -#endif // INCLUDE_CHANALYZERNG_H +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHANALYZERNG_H +#define INCLUDE_CHANALYZERNG_H + +#include +#include +#include + +#include "dsp/interpolator.h" +#include "dsp/ncof.h" +#include "dsp/fftfilt.h" +#include "audio/audiofifo.h" +#include "util/message.h" + +#define ssbFftLen 1024 + +class ChannelAnalyzerNG : public BasebandSampleSink { +public: + ChannelAnalyzerNG(BasebandSampleSink* m_sampleSink); + virtual ~ChannelAnalyzerNG(); + + void configure(MessageQueue* messageQueue, + int channelSampleRate, + Real Bandwidth, + Real LowCutoff, + int spanLog2, + bool ssb); + + int getInputSampleRate() const { return m_running.m_inputSampleRate; } + int getChannelSampleRate() const { return m_running.m_channelSampleRate; } + double getMagSq() const { return m_magsq; } + + virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); + virtual void start(); + virtual void stop(); + virtual bool handleMessage(const Message& cmd); + +private: + class MsgConfigureChannelAnalyzer : public Message { + MESSAGE_CLASS_DECLARATION + + public: + int getChannelSampleRate() const { return m_channelSampleRate; } + Real getBandwidth() const { return m_Bandwidth; } + Real getLoCutoff() const { return m_LowCutoff; } + int getSpanLog2() const { return m_spanLog2; } + bool getSSB() const { return m_ssb; } + + static MsgConfigureChannelAnalyzer* create( + int channelSampleRate, + Real Bandwidth, + Real LowCutoff, + int spanLog2, + bool ssb) + { + return new MsgConfigureChannelAnalyzer(channelSampleRate, Bandwidth, LowCutoff, spanLog2, ssb); + } + + private: + int m_channelSampleRate; + Real m_Bandwidth; + Real m_LowCutoff; + int m_spanLog2; + bool m_ssb; + + MsgConfigureChannelAnalyzer( + int channelSampleRate, + Real Bandwidth, + Real LowCutoff, + int spanLog2, + bool ssb) : + Message(), + m_channelSampleRate(channelSampleRate), + m_Bandwidth(Bandwidth), + m_LowCutoff(LowCutoff), + m_spanLog2(spanLog2), + m_ssb(ssb) + { } + }; + + struct Config + { + int m_frequency; + int m_inputSampleRate; + int m_channelSampleRate; + Real m_Bandwidth; + Real m_LowCutoff; + int m_spanLog2; + bool m_ssb; + + Config() : + m_frequency(0), + m_inputSampleRate(96000), + m_channelSampleRate(96000), + m_Bandwidth(5000), + m_LowCutoff(300), + m_spanLog2(3), + m_ssb(false) + {} + }; + + Config m_config; + Config m_running; + + int m_undersampleCount; + fftfilt::cmplx m_sum; + bool m_usb; + double m_magsq; + bool m_useInterpolator; + + NCOF m_nco; + Interpolator m_interpolator; + Real m_interpolatorDistance; + Real m_interpolatorDistanceRemain; + + fftfilt* SSBFilter; + fftfilt* DSBFilter; + + BasebandSampleSink* m_sampleSink; + SampleVector m_sampleBuffer; + QMutex m_settingsMutex; + + void apply(bool force = false); + + void processOneSample(Complex& c, fftfilt::cmplx *sideband) + { + int n_out; + int decim = 1<runSSB(c, &sideband, m_usb); + } + else + { + n_out = DSBFilter->runDSB(c, &sideband); + } + + for (int i = 0; i < n_out; i++) + { + // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display + // smart decimation with bit gain using float arithmetic (23 bits significand) + + m_sum += sideband[i]; + + if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1) + { + m_sum /= decim; + m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30); + + if (m_running.m_ssb & !m_usb) + { // invert spectrum for LSB + //m_sampleBuffer.push_back(Sample(m_sum.imag() * 32768.0, m_sum.real() * 32768.0)); + m_sampleBuffer.push_back(Sample(m_sum.imag(), m_sum.real())); + } + else + { + //m_sampleBuffer.push_back(Sample(m_sum.real() * 32768.0, m_sum.imag() * 32768.0)); + m_sampleBuffer.push_back(Sample(m_sum.real(), m_sum.imag())); + } + + m_sum = 0; + } + } + } +}; + +#endif // INCLUDE_CHANALYZERNG_H diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp index d71ac0855..7940da613 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp @@ -1,545 +1,545 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "chanalyzernggui.h" - -#include -#include -#include -#include - -#include "dsp/threadedbasebandsamplesink.h" -#include "ui_chanalyzernggui.h" -#include "dsp/spectrumscopengcombovis.h" -#include "dsp/spectrumvis.h" -#include "dsp/scopevis.h" -#include "gui/glspectrum.h" -#include "gui/glscopeng.h" -#include "plugin/pluginapi.h" -#include "util/simpleserializer.h" -#include "util/db.h" -#include "gui/basicchannelsettingswidget.h" -#include "dsp/dspengine.h" -#include "mainwindow.h" - -#include "chanalyzerng.h" - -const QString ChannelAnalyzerNGGUI::m_channelID = "sdrangel.channel.chanalyzerng"; - -ChannelAnalyzerNGGUI* ChannelAnalyzerNGGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI) -{ - ChannelAnalyzerNGGUI* gui = new ChannelAnalyzerNGGUI(pluginAPI, deviceAPI); - return gui; -} - -void ChannelAnalyzerNGGUI::destroy() -{ - delete this; -} - -void ChannelAnalyzerNGGUI::setName(const QString& name) -{ - setObjectName(name); -} - -QString ChannelAnalyzerNGGUI::getName() const -{ - return objectName(); -} - -qint64 ChannelAnalyzerNGGUI::getCenterFrequency() const -{ - return m_channelMarker.getCenterFrequency(); -} - -void ChannelAnalyzerNGGUI::setCenterFrequency(qint64 centerFrequency) -{ - m_channelMarker.setCenterFrequency(centerFrequency); - applySettings(); -} - -void ChannelAnalyzerNGGUI::resetToDefaults() -{ - blockApplySettings(true); - - ui->useRationalDownsampler->setChecked(false); - ui->BW->setValue(30); - ui->deltaFrequency->setValue(0); - ui->spanLog2->setCurrentIndex(3); - - blockApplySettings(false); - applySettings(); -} - -QByteArray ChannelAnalyzerNGGUI::serialize() const -{ - SimpleSerializer s(1); - s.writeS32(1, m_channelMarker.getCenterFrequency()); - s.writeS32(2, ui->BW->value()); - s.writeBlob(3, ui->spectrumGUI->serialize()); - s.writeU32(4, m_channelMarker.getColor().rgb()); - s.writeS32(5, ui->lowCut->value()); - s.writeS32(6, ui->spanLog2->currentIndex()); - s.writeBool(7, ui->ssb->isChecked()); - s.writeBlob(8, ui->scopeGUI->serialize()); - s.writeU64(9, ui->channelSampleRate->getValueNew()); - return s.final(); -} - -bool ChannelAnalyzerNGGUI::deserialize(const QByteArray& data) -{ - SimpleDeserializer d(data); - - if(!d.isValid()) - { - resetToDefaults(); - return false; - } - - if(d.getVersion() == 1) - { - QByteArray bytetmp; - quint32 u32tmp; - quint64 u64tmp; - qint32 tmp, spanLog2, bw, lowCut; - bool tmpBool; - - blockApplySettings(true); - m_channelMarker.blockSignals(true); - - d.readS32(1, &tmp, 0); - m_channelMarker.setCenterFrequency(tmp); - d.readS32(2, &bw, 30); - d.readBlob(3, &bytetmp); - ui->spectrumGUI->deserialize(bytetmp); - - if(d.readU32(4, &u32tmp)) - { - m_channelMarker.setColor(u32tmp); - } - - d.readS32(5, &lowCut, 3); - d.readS32(6, &spanLog2, 3); - d.readBool(7, &tmpBool, false); - ui->ssb->setChecked(tmpBool); - d.readBlob(8, &bytetmp); - ui->scopeGUI->deserialize(bytetmp); - d.readU64(9, &u64tmp, 2000U); - ui->channelSampleRate->setValue(u64tmp); - - blockApplySettings(false); - m_channelMarker.blockSignals(false); - - ui->spanLog2->setCurrentIndex(spanLog2); - setNewFinalRate(spanLog2); - ui->BW->setValue(bw); - ui->lowCut->setValue(lowCut); // does applySettings(); - - return true; - } - else - { - resetToDefaults(); - return false; - } -} - -bool ChannelAnalyzerNGGUI::handleMessage(const Message& message __attribute__((unused))) -{ - return false; -} - -void ChannelAnalyzerNGGUI::viewChanged() -{ - applySettings(); -} - -void ChannelAnalyzerNGGUI::tick() -{ - double powDb = CalcDb::dbPower(m_channelAnalyzer->getMagSq()); - m_channelPowerDbAvg.feed(powDb); - ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1)); -} - -void ChannelAnalyzerNGGUI::channelizerInputSampleRateChanged() -{ - //ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate()); - setNewFinalRate(m_spanLog2); - applySettings(); -} - -void ChannelAnalyzerNGGUI::on_channelSampleRate_changed(quint64 value) -{ - ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate()); - - if (ui->useRationalDownsampler->isChecked()) - { - qDebug("ChannelAnalyzerNGGUI::on_channelSampleRate_changed: %llu", value); - setNewFinalRate(m_spanLog2); - applySettings(); - } -} - -void ChannelAnalyzerNGGUI::on_useRationalDownsampler_toggled(bool checked __attribute__((unused))) -{ - setNewFinalRate(m_spanLog2); - applySettings(); -} - -int ChannelAnalyzerNGGUI::getRequestedChannelSampleRate() -{ - if (ui->useRationalDownsampler->isChecked()) { - return ui->channelSampleRate->getValueNew(); - } else { - return m_channelizer->getInputSampleRate(); - } -} - -void ChannelAnalyzerNGGUI::on_deltaFrequency_changed(qint64 value) -{ - m_channelMarker.setCenterFrequency(value); -} - -void ChannelAnalyzerNGGUI::on_BW_valueChanged(int value) -{ - m_channelMarker.setBandwidth(value * 100 * 2); - - if (ui->ssb->isChecked()) - { - QString s = QString::number(value/10.0, 'f', 1); - ui->BWText->setText(tr("%1k").arg(s)); - } - else - { - QString s = QString::number(value/5.0, 'f', 1); // BW = value * 2 - ui->BWText->setText(tr("%1k").arg(s)); - } - - displayBandwidth(); - on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); -} - -int ChannelAnalyzerNGGUI::getEffectiveLowCutoff(int lowCutoff) -{ - int ssbBW = m_channelMarker.getBandwidth() / 2; - int effectiveLowCutoff = lowCutoff; - const int guard = 100; - - if (ssbBW < 0) { - if (effectiveLowCutoff < ssbBW + guard) { - effectiveLowCutoff = ssbBW + guard; - } - if (effectiveLowCutoff > 0) { - effectiveLowCutoff = 0; - } - } else { - if (effectiveLowCutoff > ssbBW - guard) { - effectiveLowCutoff = ssbBW - guard; - } - if (effectiveLowCutoff < 0) { - effectiveLowCutoff = 0; - } - } - - return effectiveLowCutoff; -} - -void ChannelAnalyzerNGGUI::on_lowCut_valueChanged(int value) -{ - int lowCutoff = getEffectiveLowCutoff(value * 100); - m_channelMarker.setLowCutoff(lowCutoff); - QString s = QString::number(lowCutoff/1000.0, 'f', 1); - ui->lowCutText->setText(tr("%1k").arg(s)); - ui->lowCut->setValue(lowCutoff/100); - applySettings(); -} - -void ChannelAnalyzerNGGUI::on_spanLog2_currentIndexChanged(int index) -{ - if (setNewFinalRate(index)) { - applySettings(); - } - -} - -void ChannelAnalyzerNGGUI::on_ssb_toggled(bool checked) -{ - //int bw = m_channelMarker.getBandwidth(); - - if (checked) - { - setFiltersUIBoundaries(); - - ui->BWLabel->setText("LP"); - QString s = QString::number(ui->BW->value()/10.0, 'f', 1); // bw/2 - ui->BWText->setText(tr("%1k").arg(s)); - - on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); - } - else - { - if (ui->BW->value() < 0) { - ui->BW->setValue(-ui->BW->value()); - } - - setFiltersUIBoundaries(); - //m_channelMarker.setBandwidth(ui->BW->value() * 200.0); - - ui->BWLabel->setText("BP"); - QString s = QString::number(ui->BW->value()/5.0, 'f', 1); // bw - ui->BWText->setText(tr("%1k").arg(s)); - - ui->lowCut->setEnabled(false); - ui->lowCut->setValue(0); - ui->lowCutText->setText("0.0k"); - } - - applySettings(); - displayBandwidth(); -} - -void ChannelAnalyzerNGGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused))) -{ - /* - if((widget == ui->spectrumContainer) && (m_ssbDemod != NULL)) - m_ssbDemod->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown); - */ -} - -void ChannelAnalyzerNGGUI::onMenuDoubleClicked() -{ - if(!m_basicSettingsShown) { - m_basicSettingsShown = true; - BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this); - bcsw->show(); - } -} - -ChannelAnalyzerNGGUI::ChannelAnalyzerNGGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) : - RollupWidget(parent), - ui(new Ui::ChannelAnalyzerNGGUI), - m_pluginAPI(pluginAPI), - m_deviceAPI(deviceAPI), - m_channelMarker(this), - m_basicSettingsShown(false), - m_doApplySettings(true), - m_rate(6000), - m_spanLog2(0), - m_channelPowerDbAvg(40,0) -{ - ui->setupUi(this); - setAttribute(Qt::WA_DeleteOnClose, true); - connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked())); - - m_spectrumVis = new SpectrumVis(ui->glSpectrum); - m_scopeVis = new ScopeVisNG(ui->glScope); - m_spectrumScopeComboVis = new SpectrumScopeNGComboVis(m_spectrumVis, m_scopeVis); - m_channelAnalyzer = new ChannelAnalyzerNG(m_spectrumScopeComboVis); - m_channelizer = new DownChannelizer(m_channelAnalyzer); - m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); - connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelizerInputSampleRateChanged())); - m_deviceAPI->addThreadedSink(m_threadedChannelizer); - - ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03))); - ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); - ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); - - ui->channelSampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); - ui->channelSampleRate->setValueRange(7, 2000U, 9999999U); - - ui->glSpectrum->setCenterFrequency(m_rate/2); - ui->glSpectrum->setSampleRate(m_rate); - ui->glSpectrum->setDisplayWaterfall(true); - ui->glSpectrum->setDisplayMaxHold(true); - ui->glSpectrum->setSsbSpectrum(false); - ui->glSpectrum->setLsbDisplay(false); - ui->BWLabel->setText("BP"); - - ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); - ui->glScope->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); - connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); - - //m_channelMarker = new ChannelMarker(this); - m_channelMarker.setColor(Qt::gray); - m_channelMarker.setBandwidth(m_rate); - m_channelMarker.setSidebands(ChannelMarker::usb); - m_channelMarker.setCenterFrequency(0); - m_channelMarker.setVisible(true); - - connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); - - m_deviceAPI->registerChannelInstance(m_channelID, this); - m_deviceAPI->addChannelMarker(&m_channelMarker); - m_deviceAPI->addRollupWidget(this); - - ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); - ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); - - applySettings(); - setNewFinalRate(m_spanLog2); -} - -ChannelAnalyzerNGGUI::~ChannelAnalyzerNGGUI() -{ - m_deviceAPI->removeChannelInstance(this); - m_deviceAPI->removeThreadedSink(m_threadedChannelizer); - delete m_threadedChannelizer; - delete m_channelizer; - delete m_channelAnalyzer; - delete m_spectrumVis; - delete m_scopeVis; - delete m_spectrumScopeComboVis; - //delete m_channelMarker; - delete ui; -} - -bool ChannelAnalyzerNGGUI::setNewFinalRate(int spanLog2) -{ - qDebug("ChannelAnalyzerNGGUI::setNewRate"); - - if ((spanLog2 < 0) || (spanLog2 > 6)) { - return false; - } - - m_spanLog2 = spanLog2; - //m_rate = 48000 / (1<getInputSampleRate() / (1<spanText->setText(tr("%1 kS/s").arg(s)); - - displayBandwidth(); - - ui->glScope->setSampleRate(m_rate); - m_scopeVis->setSampleRate(m_rate); - - return true; -} - -void ChannelAnalyzerNGGUI::displayBandwidth() -{ - if (ui->ssb->isChecked()) - { - if (ui->BW->value() < 0) - { - m_channelMarker.setSidebands(ChannelMarker::lsb); - ui->glSpectrum->setLsbDisplay(true); - } - else - { - m_channelMarker.setSidebands(ChannelMarker::usb); - ui->glSpectrum->setLsbDisplay(false); - } - - ui->glSpectrum->setCenterFrequency(m_rate/4); - ui->glSpectrum->setSampleRate(m_rate/2); - ui->glSpectrum->setSsbSpectrum(true); - } - else - { - m_channelMarker.setSidebands(ChannelMarker::dsb); - - ui->glSpectrum->setCenterFrequency(0); - ui->glSpectrum->setSampleRate(m_rate); - ui->glSpectrum->setLsbDisplay(false); - ui->glSpectrum->setSsbSpectrum(false); - } - - -} - -void ChannelAnalyzerNGGUI::setFiltersUIBoundaries() -{ - if (ui->BW->value() < -m_rate/200) { - ui->BW->setValue(-m_rate/200); - m_channelMarker.setBandwidth(-m_rate*2); - } else if (ui->BW->value() > m_rate/200) { - ui->BW->setValue(m_rate/200); - m_channelMarker.setBandwidth(m_rate*2); - } - - if (ui->lowCut->value() < -m_rate/200) { - ui->lowCut->setValue(-m_rate/200); - m_channelMarker.setLowCutoff(-m_rate); - } else if (ui->lowCut->value() > m_rate/200) { - ui->lowCut->setValue(m_rate/200); - m_channelMarker.setLowCutoff(m_rate); - } - - if (ui->ssb->isChecked()) { - ui->BW->setMinimum(-m_rate/200); - ui->lowCut->setMinimum(-m_rate/200); - } else { - ui->BW->setMinimum(0); - ui->lowCut->setMinimum(-m_rate/200); - ui->lowCut->setValue(0); - } - - ui->BW->setMaximum(m_rate/200); - ui->lowCut->setMaximum(m_rate/200); -} - -void ChannelAnalyzerNGGUI::blockApplySettings(bool block) -{ - ui->glScope->blockSignals(block); - ui->glSpectrum->blockSignals(block); - m_doApplySettings = !block; -} - -void ChannelAnalyzerNGGUI::applySettings() -{ - if (m_doApplySettings) - { - setTitleColor(m_channelMarker.getColor()); - ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); - - m_channelizer->configure(m_channelizer->getInputMessageQueue(), - //m_channelizer->getInputSampleRate(), - getRequestedChannelSampleRate(), - m_channelMarker.getCenterFrequency()); - - m_channelAnalyzer->configure(m_channelAnalyzer->getInputMessageQueue(), - //m_channelizer->getInputSampleRate(), // TODO: specify required channel sample rate - getRequestedChannelSampleRate(), // TODO: specify required channel sample rate - ui->BW->value() * 100.0, - ui->lowCut->value() * 100.0, - m_spanLog2, - ui->ssb->isChecked()); - } -} - -void ChannelAnalyzerNGGUI::leaveEvent(QEvent*) -{ - blockApplySettings(true); - m_channelMarker.setHighlighted(false); - blockApplySettings(false); -} - -void ChannelAnalyzerNGGUI::enterEvent(QEvent*) -{ - blockApplySettings(true); - m_channelMarker.setHighlighted(true); - blockApplySettings(false); -} - +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "chanalyzernggui.h" + +#include +#include +#include +#include + +#include "dsp/threadedbasebandsamplesink.h" +#include "ui_chanalyzernggui.h" +#include "dsp/spectrumscopengcombovis.h" +#include "dsp/spectrumvis.h" +#include "dsp/scopevis.h" +#include "gui/glspectrum.h" +#include "gui/glscopeng.h" +#include "plugin/pluginapi.h" +#include "util/simpleserializer.h" +#include "util/db.h" +#include "gui/basicchannelsettingswidget.h" +#include "dsp/dspengine.h" +#include "mainwindow.h" + +#include "chanalyzerng.h" + +const QString ChannelAnalyzerNGGUI::m_channelID = "sdrangel.channel.chanalyzerng"; + +ChannelAnalyzerNGGUI* ChannelAnalyzerNGGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI) +{ + ChannelAnalyzerNGGUI* gui = new ChannelAnalyzerNGGUI(pluginAPI, deviceAPI); + return gui; +} + +void ChannelAnalyzerNGGUI::destroy() +{ + delete this; +} + +void ChannelAnalyzerNGGUI::setName(const QString& name) +{ + setObjectName(name); +} + +QString ChannelAnalyzerNGGUI::getName() const +{ + return objectName(); +} + +qint64 ChannelAnalyzerNGGUI::getCenterFrequency() const +{ + return m_channelMarker.getCenterFrequency(); +} + +void ChannelAnalyzerNGGUI::setCenterFrequency(qint64 centerFrequency) +{ + m_channelMarker.setCenterFrequency(centerFrequency); + applySettings(); +} + +void ChannelAnalyzerNGGUI::resetToDefaults() +{ + blockApplySettings(true); + + ui->useRationalDownsampler->setChecked(false); + ui->BW->setValue(30); + ui->deltaFrequency->setValue(0); + ui->spanLog2->setCurrentIndex(3); + + blockApplySettings(false); + applySettings(); +} + +QByteArray ChannelAnalyzerNGGUI::serialize() const +{ + SimpleSerializer s(1); + s.writeS32(1, m_channelMarker.getCenterFrequency()); + s.writeS32(2, ui->BW->value()); + s.writeBlob(3, ui->spectrumGUI->serialize()); + s.writeU32(4, m_channelMarker.getColor().rgb()); + s.writeS32(5, ui->lowCut->value()); + s.writeS32(6, ui->spanLog2->currentIndex()); + s.writeBool(7, ui->ssb->isChecked()); + s.writeBlob(8, ui->scopeGUI->serialize()); + s.writeU64(9, ui->channelSampleRate->getValueNew()); + return s.final(); +} + +bool ChannelAnalyzerNGGUI::deserialize(const QByteArray& data) +{ + SimpleDeserializer d(data); + + if(!d.isValid()) + { + resetToDefaults(); + return false; + } + + if(d.getVersion() == 1) + { + QByteArray bytetmp; + quint32 u32tmp; + quint64 u64tmp; + qint32 tmp, spanLog2, bw, lowCut; + bool tmpBool; + + blockApplySettings(true); + m_channelMarker.blockSignals(true); + + d.readS32(1, &tmp, 0); + m_channelMarker.setCenterFrequency(tmp); + d.readS32(2, &bw, 30); + d.readBlob(3, &bytetmp); + ui->spectrumGUI->deserialize(bytetmp); + + if(d.readU32(4, &u32tmp)) + { + m_channelMarker.setColor(u32tmp); + } + + d.readS32(5, &lowCut, 3); + d.readS32(6, &spanLog2, 3); + d.readBool(7, &tmpBool, false); + ui->ssb->setChecked(tmpBool); + d.readBlob(8, &bytetmp); + ui->scopeGUI->deserialize(bytetmp); + d.readU64(9, &u64tmp, 2000U); + ui->channelSampleRate->setValue(u64tmp); + + blockApplySettings(false); + m_channelMarker.blockSignals(false); + + ui->spanLog2->setCurrentIndex(spanLog2); + setNewFinalRate(spanLog2); + ui->BW->setValue(bw); + ui->lowCut->setValue(lowCut); // does applySettings(); + + return true; + } + else + { + resetToDefaults(); + return false; + } +} + +bool ChannelAnalyzerNGGUI::handleMessage(const Message& message __attribute__((unused))) +{ + return false; +} + +void ChannelAnalyzerNGGUI::viewChanged() +{ + applySettings(); +} + +void ChannelAnalyzerNGGUI::tick() +{ + double powDb = CalcDb::dbPower(m_channelAnalyzer->getMagSq()); + m_channelPowerDbAvg.feed(powDb); + ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1)); +} + +void ChannelAnalyzerNGGUI::channelizerInputSampleRateChanged() +{ + //ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate()); + setNewFinalRate(m_spanLog2); + applySettings(); +} + +void ChannelAnalyzerNGGUI::on_channelSampleRate_changed(quint64 value) +{ + ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate()); + + if (ui->useRationalDownsampler->isChecked()) + { + qDebug("ChannelAnalyzerNGGUI::on_channelSampleRate_changed: %llu", value); + setNewFinalRate(m_spanLog2); + applySettings(); + } +} + +void ChannelAnalyzerNGGUI::on_useRationalDownsampler_toggled(bool checked __attribute__((unused))) +{ + setNewFinalRate(m_spanLog2); + applySettings(); +} + +int ChannelAnalyzerNGGUI::getRequestedChannelSampleRate() +{ + if (ui->useRationalDownsampler->isChecked()) { + return ui->channelSampleRate->getValueNew(); + } else { + return m_channelizer->getInputSampleRate(); + } +} + +void ChannelAnalyzerNGGUI::on_deltaFrequency_changed(qint64 value) +{ + m_channelMarker.setCenterFrequency(value); +} + +void ChannelAnalyzerNGGUI::on_BW_valueChanged(int value) +{ + m_channelMarker.setBandwidth(value * 100 * 2); + + if (ui->ssb->isChecked()) + { + QString s = QString::number(value/10.0, 'f', 1); + ui->BWText->setText(tr("%1k").arg(s)); + } + else + { + QString s = QString::number(value/5.0, 'f', 1); // BW = value * 2 + ui->BWText->setText(tr("%1k").arg(s)); + } + + displayBandwidth(); + on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); +} + +int ChannelAnalyzerNGGUI::getEffectiveLowCutoff(int lowCutoff) +{ + int ssbBW = m_channelMarker.getBandwidth() / 2; + int effectiveLowCutoff = lowCutoff; + const int guard = 100; + + if (ssbBW < 0) { + if (effectiveLowCutoff < ssbBW + guard) { + effectiveLowCutoff = ssbBW + guard; + } + if (effectiveLowCutoff > 0) { + effectiveLowCutoff = 0; + } + } else { + if (effectiveLowCutoff > ssbBW - guard) { + effectiveLowCutoff = ssbBW - guard; + } + if (effectiveLowCutoff < 0) { + effectiveLowCutoff = 0; + } + } + + return effectiveLowCutoff; +} + +void ChannelAnalyzerNGGUI::on_lowCut_valueChanged(int value) +{ + int lowCutoff = getEffectiveLowCutoff(value * 100); + m_channelMarker.setLowCutoff(lowCutoff); + QString s = QString::number(lowCutoff/1000.0, 'f', 1); + ui->lowCutText->setText(tr("%1k").arg(s)); + ui->lowCut->setValue(lowCutoff/100); + applySettings(); +} + +void ChannelAnalyzerNGGUI::on_spanLog2_currentIndexChanged(int index) +{ + if (setNewFinalRate(index)) { + applySettings(); + } + +} + +void ChannelAnalyzerNGGUI::on_ssb_toggled(bool checked) +{ + //int bw = m_channelMarker.getBandwidth(); + + if (checked) + { + setFiltersUIBoundaries(); + + ui->BWLabel->setText("LP"); + QString s = QString::number(ui->BW->value()/10.0, 'f', 1); // bw/2 + ui->BWText->setText(tr("%1k").arg(s)); + + on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); + } + else + { + if (ui->BW->value() < 0) { + ui->BW->setValue(-ui->BW->value()); + } + + setFiltersUIBoundaries(); + //m_channelMarker.setBandwidth(ui->BW->value() * 200.0); + + ui->BWLabel->setText("BP"); + QString s = QString::number(ui->BW->value()/5.0, 'f', 1); // bw + ui->BWText->setText(tr("%1k").arg(s)); + + ui->lowCut->setEnabled(false); + ui->lowCut->setValue(0); + ui->lowCutText->setText("0.0k"); + } + + applySettings(); + displayBandwidth(); +} + +void ChannelAnalyzerNGGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused))) +{ + /* + if((widget == ui->spectrumContainer) && (m_ssbDemod != NULL)) + m_ssbDemod->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown); + */ +} + +void ChannelAnalyzerNGGUI::onMenuDoubleClicked() +{ + if(!m_basicSettingsShown) { + m_basicSettingsShown = true; + BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this); + bcsw->show(); + } +} + +ChannelAnalyzerNGGUI::ChannelAnalyzerNGGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) : + RollupWidget(parent), + ui(new Ui::ChannelAnalyzerNGGUI), + m_pluginAPI(pluginAPI), + m_deviceAPI(deviceAPI), + m_channelMarker(this), + m_basicSettingsShown(false), + m_doApplySettings(true), + m_rate(6000), + m_spanLog2(0), + m_channelPowerDbAvg(40,0) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose, true); + connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); + connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked())); + + m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_scopeVis = new ScopeVisNG(ui->glScope); + m_spectrumScopeComboVis = new SpectrumScopeNGComboVis(m_spectrumVis, m_scopeVis); + m_channelAnalyzer = new ChannelAnalyzerNG(m_spectrumScopeComboVis); + m_channelizer = new DownChannelizer(m_channelAnalyzer); + m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); + connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelizerInputSampleRateChanged())); + m_deviceAPI->addThreadedSink(m_threadedChannelizer); + + ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03))); + ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); + ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); + + ui->channelSampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); + ui->channelSampleRate->setValueRange(7, 2000U, 9999999U); + + ui->glSpectrum->setCenterFrequency(m_rate/2); + ui->glSpectrum->setSampleRate(m_rate); + ui->glSpectrum->setDisplayWaterfall(true); + ui->glSpectrum->setDisplayMaxHold(true); + ui->glSpectrum->setSsbSpectrum(false); + ui->glSpectrum->setLsbDisplay(false); + ui->BWLabel->setText("BP"); + + ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); + ui->glScope->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); + connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); + + //m_channelMarker = new ChannelMarker(this); + m_channelMarker.setColor(Qt::gray); + m_channelMarker.setBandwidth(m_rate); + m_channelMarker.setSidebands(ChannelMarker::usb); + m_channelMarker.setCenterFrequency(0); + m_channelMarker.setVisible(true); + + connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); + + m_deviceAPI->registerChannelInstance(m_channelID, this); + m_deviceAPI->addChannelMarker(&m_channelMarker); + m_deviceAPI->addRollupWidget(this); + + ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); + ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); + + applySettings(); + setNewFinalRate(m_spanLog2); +} + +ChannelAnalyzerNGGUI::~ChannelAnalyzerNGGUI() +{ + m_deviceAPI->removeChannelInstance(this); + m_deviceAPI->removeThreadedSink(m_threadedChannelizer); + delete m_threadedChannelizer; + delete m_channelizer; + delete m_channelAnalyzer; + delete m_spectrumVis; + delete m_scopeVis; + delete m_spectrumScopeComboVis; + //delete m_channelMarker; + delete ui; +} + +bool ChannelAnalyzerNGGUI::setNewFinalRate(int spanLog2) +{ + qDebug("ChannelAnalyzerNGGUI::setNewRate"); + + if ((spanLog2 < 0) || (spanLog2 > 6)) { + return false; + } + + m_spanLog2 = spanLog2; + //m_rate = 48000 / (1<getInputSampleRate() / (1<spanText->setText(tr("%1 kS/s").arg(s)); + + displayBandwidth(); + + ui->glScope->setSampleRate(m_rate); + m_scopeVis->setSampleRate(m_rate); + + return true; +} + +void ChannelAnalyzerNGGUI::displayBandwidth() +{ + if (ui->ssb->isChecked()) + { + if (ui->BW->value() < 0) + { + m_channelMarker.setSidebands(ChannelMarker::lsb); + ui->glSpectrum->setLsbDisplay(true); + } + else + { + m_channelMarker.setSidebands(ChannelMarker::usb); + ui->glSpectrum->setLsbDisplay(false); + } + + ui->glSpectrum->setCenterFrequency(m_rate/4); + ui->glSpectrum->setSampleRate(m_rate/2); + ui->glSpectrum->setSsbSpectrum(true); + } + else + { + m_channelMarker.setSidebands(ChannelMarker::dsb); + + ui->glSpectrum->setCenterFrequency(0); + ui->glSpectrum->setSampleRate(m_rate); + ui->glSpectrum->setLsbDisplay(false); + ui->glSpectrum->setSsbSpectrum(false); + } + + +} + +void ChannelAnalyzerNGGUI::setFiltersUIBoundaries() +{ + if (ui->BW->value() < -m_rate/200) { + ui->BW->setValue(-m_rate/200); + m_channelMarker.setBandwidth(-m_rate*2); + } else if (ui->BW->value() > m_rate/200) { + ui->BW->setValue(m_rate/200); + m_channelMarker.setBandwidth(m_rate*2); + } + + if (ui->lowCut->value() < -m_rate/200) { + ui->lowCut->setValue(-m_rate/200); + m_channelMarker.setLowCutoff(-m_rate); + } else if (ui->lowCut->value() > m_rate/200) { + ui->lowCut->setValue(m_rate/200); + m_channelMarker.setLowCutoff(m_rate); + } + + if (ui->ssb->isChecked()) { + ui->BW->setMinimum(-m_rate/200); + ui->lowCut->setMinimum(-m_rate/200); + } else { + ui->BW->setMinimum(0); + ui->lowCut->setMinimum(-m_rate/200); + ui->lowCut->setValue(0); + } + + ui->BW->setMaximum(m_rate/200); + ui->lowCut->setMaximum(m_rate/200); +} + +void ChannelAnalyzerNGGUI::blockApplySettings(bool block) +{ + ui->glScope->blockSignals(block); + ui->glSpectrum->blockSignals(block); + m_doApplySettings = !block; +} + +void ChannelAnalyzerNGGUI::applySettings() +{ + if (m_doApplySettings) + { + setTitleColor(m_channelMarker.getColor()); + ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); + + m_channelizer->configure(m_channelizer->getInputMessageQueue(), + //m_channelizer->getInputSampleRate(), + getRequestedChannelSampleRate(), + m_channelMarker.getCenterFrequency()); + + m_channelAnalyzer->configure(m_channelAnalyzer->getInputMessageQueue(), + //m_channelizer->getInputSampleRate(), // TODO: specify required channel sample rate + getRequestedChannelSampleRate(), // TODO: specify required channel sample rate + ui->BW->value() * 100.0, + ui->lowCut->value() * 100.0, + m_spanLog2, + ui->ssb->isChecked()); + } +} + +void ChannelAnalyzerNGGUI::leaveEvent(QEvent*) +{ + blockApplySettings(true); + m_channelMarker.setHighlighted(false); + blockApplySettings(false); +} + +void ChannelAnalyzerNGGUI::enterEvent(QEvent*) +{ + blockApplySettings(true); + m_channelMarker.setHighlighted(true); + blockApplySettings(false); +} + diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.ui b/plugins/channelrx/chanalyzerng/chanalyzernggui.ui index 724975b02..4776e1e36 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.ui +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.ui @@ -1,648 +1,648 @@ - - - ChannelAnalyzerNGGUI - - - - 0 - 0 - 739 - 778 - - - - - 720 - 0 - - - - - Sans Serif - 9 - - - - Channel Analyzer NG - - - - - 0 - 10 - 631 - 81 - - - - Settings - - - - 3 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 2 - - - - - - - - 16 - 0 - - - - Df - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - DejaVu Sans Mono - 12 - - - - PointingHandCursor - - - Qt::StrongFocus - - - Demod shift frequency from center in Hz - - - - - - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - - - 118 - 118 - 117 - - - - - - - 255 - 255 - 255 - - - - - - - - Hz - - - - - - - - - - - Use rational downsampler - - - - - - - :/arrow_down.png:/arrow_down.png - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - DejaVu Sans Mono - 12 - - - - PointingHandCursor - - - Rational downsampler output rate - - - - - - - S/s - - - - - - - - 40 - 16777215 - - - - Channel decimation - - - - 1 - - - - - 2 - - - - - 4 - - - - - 8 - - - - - 16 - - - - - 32 - - - - - 64 - - - - - - - - Channel final sample rate - - - 6.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 52 - 0 - - - - Channel power - - - Qt::LeftToRight - - - -100.0 dB - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 15 - 0 - - - - BP - - - - - - - Lowpass filter cutoff frequency - - - -60 - - - 60 - - - 1 - - - 30 - - - Qt::Horizontal - - - - - - - - 50 - 0 - - - - 3.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - SSB/DSB togggle - - - SSB - - - - - - - - 15 - 0 - - - - HP - - - - - - - Highpass filter cutoff frequency (SSB) - - - -60 - - - 60 - - - 1 - - - 3 - - - Qt::Horizontal - - - - - - - - 50 - 0 - - - - 0.3k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - 0 - 98 - 720 - 284 - - - - - 716 - 0 - - - - Channel Spectrum - - - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 200 - 250 - - - - - Monospace - 8 - - - - - - - - - - - - - 0 - 390 - 720 - 334 - - - - - 716 - 0 - - - - Channel Scope - - - - 2 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 200 - 300 - - - - - Monospace - 8 - - - - - - - - - - - - - RollupWidget - QWidget -
gui/rollupwidget.h
- 1 -
- - GLSpectrum - QWidget -
gui/glspectrum.h
- 1 -
- - GLSpectrumGUI - QWidget -
gui/glspectrumgui.h
- 1 -
- - ValueDialZ - QWidget -
gui/valuedialz.h
- 1 -
- - ValueDial - QWidget -
gui/valuedial.h
- 1 -
- - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
- - GLScopeNG - QWidget -
gui/glscopeng.h
- 1 -
- - GLScopeNGGUI - QWidget -
gui/glscopenggui.h
- 1 -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + ChannelAnalyzerNGGUI + + + + 0 + 0 + 739 + 778 + + + + + 720 + 0 + + + + + Sans Serif + 9 + + + + Channel Analyzer NG + + + + + 0 + 10 + 631 + 81 + + + + Settings + + + + 3 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + 2 + + + + + + + + 16 + 0 + + + + Df + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + + + Demod shift frequency from center in Hz + + + + + + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + + + 118 + 118 + 117 + + + + + + + 255 + 255 + 255 + + + + + + + + Hz + + + + + + + + + + + Use rational downsampler + + + + + + + :/arrow_down.png:/arrow_down.png + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Rational downsampler output rate + + + + + + + S/s + + + + + + + + 40 + 16777215 + + + + Channel decimation + + + + 1 + + + + + 2 + + + + + 4 + + + + + 8 + + + + + 16 + + + + + 32 + + + + + 64 + + + + + + + + Channel final sample rate + + + 6.0k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 52 + 0 + + + + Channel power + + + Qt::LeftToRight + + + -100.0 dB + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + 15 + 0 + + + + BP + + + + + + + Lowpass filter cutoff frequency + + + -60 + + + 60 + + + 1 + + + 30 + + + Qt::Horizontal + + + + + + + + 50 + 0 + + + + 3.0k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + + + + SSB/DSB togggle + + + SSB + + + + + + + + 15 + 0 + + + + HP + + + + + + + Highpass filter cutoff frequency (SSB) + + + -60 + + + 60 + + + 1 + + + 3 + + + Qt::Horizontal + + + + + + + + 50 + 0 + + + + 0.3k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 98 + 720 + 284 + + + + + 716 + 0 + + + + Channel Spectrum + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + 200 + 250 + + + + + Monospace + 8 + + + + + + + + + + + + + 0 + 390 + 720 + 334 + + + + + 716 + 0 + + + + Channel Scope + + + + 2 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + 200 + 300 + + + + + Monospace + 8 + + + + + + + + + + + + + RollupWidget + QWidget +
gui/rollupwidget.h
+ 1 +
+ + GLSpectrum + QWidget +
gui/glspectrum.h
+ 1 +
+ + GLSpectrumGUI + QWidget +
gui/glspectrumgui.h
+ 1 +
+ + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +
+ + ValueDial + QWidget +
gui/valuedial.h
+ 1 +
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+ + GLScopeNG + QWidget +
gui/glscopeng.h
+ 1 +
+ + GLScopeNGGUI + QWidget +
gui/glscopenggui.h
+ 1 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/samplesink/limesdroutput/limesdroutputsettings.h b/plugins/samplesink/limesdroutput/limesdroutputsettings.h index cf84863e0..991f0932e 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputsettings.h +++ b/plugins/samplesink/limesdroutput/limesdroutputsettings.h @@ -1,62 +1,62 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUTSETTINGS_H_ -#define PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUTSETTINGS_H_ - -#include -#include - -/** - * These are the settings individual to each hardware channel or software Tx chain - * Plus the settings to be saved in the presets - */ -struct LimeSDROutputSettings -{ - typedef enum { - FC_POS_INFRA = 0, - FC_POS_SUPRA, - FC_POS_CENTER - } fcPos_t; - - enum PathRFE - { - PATH_RFE_NONE = 0, - PATH_RFE_TXRF1, - PATH_RFE_TXEF2 - }; - - // global settings to be saved - uint64_t m_centerFrequency; - int m_devSampleRate; - uint32_t m_log2HardInterp; - // channel settings - uint32_t m_log2SoftInterp; - float m_lpfBW; //!< LMS amalog lowpass filter bandwidth (Hz) - bool m_lpfFIREnable; //!< Enable LMS digital lowpass FIR filters - float m_lpfFIRBW; //!< LMS digital lowpass FIR filters bandwidth (Hz) - uint32_t m_gain; //!< Optimally distributed gain (dB) - bool m_ncoEnable; //!< Enable TSP NCO and mixing - int m_ncoFrequency; //!< Actual NCO frequency (the resulting frequency with mixing is displayed) - PathRFE m_antennaPath; - - LimeSDROutputSettings(); - void resetToDefaults(); - QByteArray serialize() const; - bool deserialize(const QByteArray& data); -}; - -#endif /* PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ */ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUTSETTINGS_H_ +#define PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUTSETTINGS_H_ + +#include +#include + +/** + * These are the settings individual to each hardware channel or software Tx chain + * Plus the settings to be saved in the presets + */ +struct LimeSDROutputSettings +{ + typedef enum { + FC_POS_INFRA = 0, + FC_POS_SUPRA, + FC_POS_CENTER + } fcPos_t; + + enum PathRFE + { + PATH_RFE_NONE = 0, + PATH_RFE_TXRF1, + PATH_RFE_TXEF2 + }; + + // global settings to be saved + uint64_t m_centerFrequency; + int m_devSampleRate; + uint32_t m_log2HardInterp; + // channel settings + uint32_t m_log2SoftInterp; + float m_lpfBW; //!< LMS amalog lowpass filter bandwidth (Hz) + bool m_lpfFIREnable; //!< Enable LMS digital lowpass FIR filters + float m_lpfFIRBW; //!< LMS digital lowpass FIR filters bandwidth (Hz) + uint32_t m_gain; //!< Optimally distributed gain (dB) + bool m_ncoEnable; //!< Enable TSP NCO and mixing + int m_ncoFrequency; //!< Actual NCO frequency (the resulting frequency with mixing is displayed) + PathRFE m_antennaPath; + + LimeSDROutputSettings(); + void resetToDefaults(); + QByteArray serialize() const; + bool deserialize(const QByteArray& data); +}; + +#endif /* PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ */ diff --git a/plugins/samplesource/fcdproplus/fcdproplus.pro b/plugins/samplesource/fcdproplus/fcdproplus.pro index 45cf21dc2..c6ea9344f 100644 --- a/plugins/samplesource/fcdproplus/fcdproplus.pro +++ b/plugins/samplesource/fcdproplus/fcdproplus.pro @@ -1,43 +1,43 @@ -#-------------------------------------------------------- -# -# Pro file for Android and Windows builds with Qt Creator -# -#-------------------------------------------------------- - -TEMPLATE = lib -CONFIG += plugin - -QT += core gui widgets multimedia network - -TARGET = inputfcdproplus - -DEFINES += USE_SSE2=1 -QMAKE_CXXFLAGS += -msse2 -DEFINES += USE_SSE4_1=1 -QMAKE_CXXFLAGS += -msse4.1 - -INCLUDEPATH += $$PWD -INCLUDEPATH += ../../../sdrbase -INCLUDEPATH += ../../../fcdhid -INCLUDEPATH += ../../../fcdlib - -CONFIG(Release):build_subdir = release -CONFIG(Debug):build_subdir = debug - -SOURCES = fcdproplusgui.cpp\ - fcdproplusinputqt.cpp\ - fcdproplusplugin.cpp\ - fcdproplussettings.cpp\ - fcdproplusreader.cpp - -HEADERS = fcdproplusgui.h\ - fcdproplusinputqt.h\ - fcdproplusplugin.h\ - fcdproplussettings.h\ - fcdproplusreader.h - -FORMS += fcdproplusgui.ui - -LIBS += -L../../../fcdlib/$${build_subdir} -lfcdlib -LIBS += -L../../../fcdhid/$${build_subdir} -lfcdhid -LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase +#-------------------------------------------------------- +# +# Pro file for Android and Windows builds with Qt Creator +# +#-------------------------------------------------------- + +TEMPLATE = lib +CONFIG += plugin + +QT += core gui widgets multimedia network + +TARGET = inputfcdproplus + +DEFINES += USE_SSE2=1 +QMAKE_CXXFLAGS += -msse2 +DEFINES += USE_SSE4_1=1 +QMAKE_CXXFLAGS += -msse4.1 + +INCLUDEPATH += $$PWD +INCLUDEPATH += ../../../sdrbase +INCLUDEPATH += ../../../fcdhid +INCLUDEPATH += ../../../fcdlib + +CONFIG(Release):build_subdir = release +CONFIG(Debug):build_subdir = debug + +SOURCES = fcdproplusgui.cpp\ + fcdproplusinputqt.cpp\ + fcdproplusplugin.cpp\ + fcdproplussettings.cpp\ + fcdproplusreader.cpp + +HEADERS = fcdproplusgui.h\ + fcdproplusinputqt.h\ + fcdproplusplugin.h\ + fcdproplussettings.h\ + fcdproplusreader.h + +FORMS += fcdproplusgui.ui + +LIBS += -L../../../fcdlib/$${build_subdir} -lfcdlib +LIBS += -L../../../fcdhid/$${build_subdir} -lfcdhid +LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase diff --git a/plugins/samplesource/limesdrinput/limesdrinputsettings.h b/plugins/samplesource/limesdrinput/limesdrinputsettings.h index cb5f858f5..32caafa2f 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputsettings.h +++ b/plugins/samplesource/limesdrinput/limesdrinputsettings.h @@ -1,76 +1,76 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ -#define PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ - -#include -#include - -/** - * These are the settings individual to each hardware channel or software Rx chain - * Plus the settings to be saved in the presets - */ -struct LimeSDRInputSettings -{ - typedef enum { - FC_POS_INFRA = 0, - FC_POS_SUPRA, - FC_POS_CENTER - } fcPos_t; - - enum PathRFE - { - PATH_RFE_NONE = 0, - PATH_RFE_LNAH, - PATH_RFE_LNAL, - PATH_RFE_LNAW, - PATH_RFE_LB1, - PATH_RFE_LB2 - }; - - typedef enum { - GAIN_AUTO, - GAIN_MANUAL - } GainMode; - - // global settings to be saved - uint64_t m_centerFrequency; - int m_devSampleRate; - uint32_t m_log2HardDecim; - // channel settings - bool m_dcBlock; - bool m_iqCorrection; - uint32_t m_log2SoftDecim; - float m_lpfBW; //!< LMS amalog lowpass filter bandwidth (Hz) - bool m_lpfFIREnable; //!< Enable LMS digital lowpass FIR filters - float m_lpfFIRBW; //!< LMS digital lowpass FIR filters bandwidth (Hz) - uint32_t m_gain; //!< Optimally distributed gain (dB) - bool m_ncoEnable; //!< Enable TSP NCO and mixing - int m_ncoFrequency; //!< Actual NCO frequency (the resulting frequency with mixing is displayed) - PathRFE m_antennaPath; - GainMode m_gainMode; //!< Gain mode: auto or manual - uint32_t m_lnaGain; //!< Manual LAN gain - uint32_t m_tiaGain; //!< Manual TIA gain - uint32_t m_pgaGain; //!< Manual PGA gain - - LimeSDRInputSettings(); - void resetToDefaults(); - QByteArray serialize() const; - bool deserialize(const QByteArray& data); -}; - -#endif /* PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ */ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ +#define PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ + +#include +#include + +/** + * These are the settings individual to each hardware channel or software Rx chain + * Plus the settings to be saved in the presets + */ +struct LimeSDRInputSettings +{ + typedef enum { + FC_POS_INFRA = 0, + FC_POS_SUPRA, + FC_POS_CENTER + } fcPos_t; + + enum PathRFE + { + PATH_RFE_NONE = 0, + PATH_RFE_LNAH, + PATH_RFE_LNAL, + PATH_RFE_LNAW, + PATH_RFE_LB1, + PATH_RFE_LB2 + }; + + typedef enum { + GAIN_AUTO, + GAIN_MANUAL + } GainMode; + + // global settings to be saved + uint64_t m_centerFrequency; + int m_devSampleRate; + uint32_t m_log2HardDecim; + // channel settings + bool m_dcBlock; + bool m_iqCorrection; + uint32_t m_log2SoftDecim; + float m_lpfBW; //!< LMS amalog lowpass filter bandwidth (Hz) + bool m_lpfFIREnable; //!< Enable LMS digital lowpass FIR filters + float m_lpfFIRBW; //!< LMS digital lowpass FIR filters bandwidth (Hz) + uint32_t m_gain; //!< Optimally distributed gain (dB) + bool m_ncoEnable; //!< Enable TSP NCO and mixing + int m_ncoFrequency; //!< Actual NCO frequency (the resulting frequency with mixing is displayed) + PathRFE m_antennaPath; + GainMode m_gainMode; //!< Gain mode: auto or manual + uint32_t m_lnaGain; //!< Manual LAN gain + uint32_t m_tiaGain; //!< Manual TIA gain + uint32_t m_pgaGain; //!< Manual PGA gain + + LimeSDRInputSettings(); + void resetToDefaults(); + QByteArray serialize() const; + bool deserialize(const QByteArray& data); +}; + +#endif /* PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUTSETTINGS_H_ */ diff --git a/sdrbase/audio/audioinput.h b/sdrbase/audio/audioinput.h index 39e7ed40c..c08d366b6 100644 --- a/sdrbase/audio/audioinput.h +++ b/sdrbase/audio/audioinput.h @@ -1,69 +1,69 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 Edouard Griffiths, F4EXB // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_AUDIO_AUDIOINPUT_H_ -#define SDRBASE_AUDIO_AUDIOINPUT_H_ - -#include -#include -#include -#include -#include -#include "util/export.h" - -class QAudioInput; -class AudioFifo; -class AudioOutputPipe; - - -class SDRANGEL_API AudioInput : public QIODevice { -public: - AudioInput(); - virtual ~AudioInput(); - - bool start(int device, int rate); - void stop(); - - void addFifo(AudioFifo* audioFifo); - void removeFifo(AudioFifo* audioFifo); - - uint getRate() const { return m_audioFormat.sampleRate(); } - void setOnExit(bool onExit) { m_onExit = onExit; } - void setVolume(float volume) { m_volume = volume; } - -private: - QMutex m_mutex; - QAudioInput* m_audioInput; - uint m_audioUsageCount; - bool m_onExit; - float m_volume; - - typedef std::list AudioFifos; - AudioFifos m_audioFifos; - std::vector m_mixBuffer; - - QAudioFormat m_audioFormat; - - //virtual bool open(OpenMode mode); - virtual qint64 readData(char* data, qint64 maxLen); - virtual qint64 writeData(const char* data, qint64 len); - - friend class AudioOutputPipe; -}; - - - -#endif /* SDRBASE_AUDIO_AUDIOINPUT_H_ */ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2016 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_AUDIO_AUDIOINPUT_H_ +#define SDRBASE_AUDIO_AUDIOINPUT_H_ + +#include +#include +#include +#include +#include +#include "util/export.h" + +class QAudioInput; +class AudioFifo; +class AudioOutputPipe; + + +class SDRANGEL_API AudioInput : public QIODevice { +public: + AudioInput(); + virtual ~AudioInput(); + + bool start(int device, int rate); + void stop(); + + void addFifo(AudioFifo* audioFifo); + void removeFifo(AudioFifo* audioFifo); + + uint getRate() const { return m_audioFormat.sampleRate(); } + void setOnExit(bool onExit) { m_onExit = onExit; } + void setVolume(float volume) { m_volume = volume; } + +private: + QMutex m_mutex; + QAudioInput* m_audioInput; + uint m_audioUsageCount; + bool m_onExit; + float m_volume; + + typedef std::list AudioFifos; + AudioFifos m_audioFifos; + std::vector m_mixBuffer; + + QAudioFormat m_audioFormat; + + //virtual bool open(OpenMode mode); + virtual qint64 readData(char* data, qint64 maxLen); + virtual qint64 writeData(const char* data, qint64 len); + + friend class AudioOutputPipe; +}; + + + +#endif /* SDRBASE_AUDIO_AUDIOINPUT_H_ */ diff --git a/sdrbase/dsp/basebandsamplesource.cpp b/sdrbase/dsp/basebandsamplesource.cpp index 63c2d9853..76ea093a3 100644 --- a/sdrbase/dsp/basebandsamplesource.cpp +++ b/sdrbase/dsp/basebandsamplesource.cpp @@ -1,58 +1,58 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 F4EXB // -// written by Edouard Griffiths // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "dsp/basebandsamplesource.h" -#include "util/message.h" - -BasebandSampleSource::BasebandSampleSource() : - m_sampleFifo(48000) // arbitrary, will be adjusted to match device sink FIFO size -{ - connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); - connect(&m_sampleFifo, SIGNAL(dataWrite(int)), this, SLOT(handleWriteToFifo(int))); -} - -BasebandSampleSource::~BasebandSampleSource() -{ -} - -void BasebandSampleSource::handleInputMessages() -{ - Message* message; - - while ((message = m_inputMessageQueue.pop()) != 0) - { - if (handleMessage(*message)) - { - delete message; - } - } -} - -void BasebandSampleSource::handleWriteToFifo(int nbSamples) -{ - SampleVector::iterator writeAt; - m_sampleFifo.getWriteIterator(writeAt); - pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly - - for (int i = 0; i < nbSamples; i++) - { - pull((*writeAt)); - m_sampleFifo.bumpIndex(writeAt); - } -} - - +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2016 F4EXB // +// written by Edouard Griffiths // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "dsp/basebandsamplesource.h" +#include "util/message.h" + +BasebandSampleSource::BasebandSampleSource() : + m_sampleFifo(48000) // arbitrary, will be adjusted to match device sink FIFO size +{ + connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); + connect(&m_sampleFifo, SIGNAL(dataWrite(int)), this, SLOT(handleWriteToFifo(int))); +} + +BasebandSampleSource::~BasebandSampleSource() +{ +} + +void BasebandSampleSource::handleInputMessages() +{ + Message* message; + + while ((message = m_inputMessageQueue.pop()) != 0) + { + if (handleMessage(*message)) + { + delete message; + } + } +} + +void BasebandSampleSource::handleWriteToFifo(int nbSamples) +{ + SampleVector::iterator writeAt; + m_sampleFifo.getWriteIterator(writeAt); + pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly + + for (int i = 0; i < nbSamples; i++) + { + pull((*writeAt)); + m_sampleFifo.bumpIndex(writeAt); + } +} + + diff --git a/sdrbase/dsp/basebandsamplesource.h b/sdrbase/dsp/basebandsamplesource.h index ce7b0014b..0e257297d 100644 --- a/sdrbase/dsp/basebandsamplesource.h +++ b/sdrbase/dsp/basebandsamplesource.h @@ -1,71 +1,71 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 F4EXB // -// written by Edouard Griffiths // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ -#define SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ - -#include -#include "dsp/dsptypes.h" -#include "dsp/samplesourcefifo.h" -#include "util/export.h" -#include "util/messagequeue.h" - -class Message; - -class SDRANGEL_API BasebandSampleSource : public QObject { - Q_OBJECT -public: - BasebandSampleSource(); - virtual ~BasebandSampleSource(); - - virtual void start() = 0; - virtual void stop() = 0; - virtual void pull(Sample& sample) = 0; - virtual void pullAudio(int nbSamples __attribute__((unused))) {} - - /** direct feeding of sample source FIFO */ - void feed(SampleSourceFifo* sampleFifo, int nbSamples) - { - SampleVector::iterator writeAt; - sampleFifo->getWriteIterator(writeAt); - pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly - - for (int i = 0; i < nbSamples; i++) - { - pull((*writeAt)); - sampleFifo->bumpIndex(writeAt); - } - } - - SampleSourceFifo& getSampleSourceFifo() { return m_sampleFifo; } - - virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed - - MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication - MessageQueue *getOutputMessageQueue() { return &m_outputMessageQueue; } //!< Get the queue for asynchronous outbound communication - -protected: - MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication - MessageQueue m_outputMessageQueue; //!< Queue for asynchronous outbound communication - SampleSourceFifo m_sampleFifo; //!< Internal FIFO for multi-channel processing - -protected slots: - void handleInputMessages(); - void handleWriteToFifo(int nbSamples); -}; - -#endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2016 F4EXB // +// written by Edouard Griffiths // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ +#define SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ + +#include +#include "dsp/dsptypes.h" +#include "dsp/samplesourcefifo.h" +#include "util/export.h" +#include "util/messagequeue.h" + +class Message; + +class SDRANGEL_API BasebandSampleSource : public QObject { + Q_OBJECT +public: + BasebandSampleSource(); + virtual ~BasebandSampleSource(); + + virtual void start() = 0; + virtual void stop() = 0; + virtual void pull(Sample& sample) = 0; + virtual void pullAudio(int nbSamples __attribute__((unused))) {} + + /** direct feeding of sample source FIFO */ + void feed(SampleSourceFifo* sampleFifo, int nbSamples) + { + SampleVector::iterator writeAt; + sampleFifo->getWriteIterator(writeAt); + pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly + + for (int i = 0; i < nbSamples; i++) + { + pull((*writeAt)); + sampleFifo->bumpIndex(writeAt); + } + } + + SampleSourceFifo& getSampleSourceFifo() { return m_sampleFifo; } + + virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed + + MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication + MessageQueue *getOutputMessageQueue() { return &m_outputMessageQueue; } //!< Get the queue for asynchronous outbound communication + +protected: + MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication + MessageQueue m_outputMessageQueue; //!< Queue for asynchronous outbound communication + SampleSourceFifo m_sampleFifo; //!< Internal FIFO for multi-channel processing + +protected slots: + void handleInputMessages(); + void handleWriteToFifo(int nbSamples); +}; + +#endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */ diff --git a/sdrbase/dsp/devicesamplesink.cpp b/sdrbase/dsp/devicesamplesink.cpp index bd76d6e5a..dfedfdbb7 100644 --- a/sdrbase/dsp/devicesamplesink.cpp +++ b/sdrbase/dsp/devicesamplesink.cpp @@ -1,45 +1,45 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 F4EXB // -// written by Edouard Griffiths // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "dsp/devicesamplesink.h" - -DeviceSampleSink::DeviceSampleSink() : - m_sampleSourceFifo(1<<19) -{ - connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); -} - -DeviceSampleSink::~DeviceSampleSink() -{ -} - -void DeviceSampleSink::handleInputMessages() -{ - Message* message; - - while ((message = m_inputMessageQueue.pop()) != 0) - { - if (handleMessage(*message)) - { - delete message; - } - } -} - - - - +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2016 F4EXB // +// written by Edouard Griffiths // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "dsp/devicesamplesink.h" + +DeviceSampleSink::DeviceSampleSink() : + m_sampleSourceFifo(1<<19) +{ + connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); +} + +DeviceSampleSink::~DeviceSampleSink() +{ +} + +void DeviceSampleSink::handleInputMessages() +{ + Message* message; + + while ((message = m_inputMessageQueue.pop()) != 0) + { + if (handleMessage(*message)) + { + delete message; + } + } +} + + + + diff --git a/sdrbase/gui/cwkeyergui.ui b/sdrbase/gui/cwkeyergui.ui index de024323a..fe5899f94 100644 --- a/sdrbase/gui/cwkeyergui.ui +++ b/sdrbase/gui/cwkeyergui.ui @@ -1,441 +1,441 @@ - - - CWKeyerGUI - - - - 0 - 0 - 375 - 60 - - - - - Sans Serif - 8 - - - - CW Keyer - - - - 2 - - - 3 - - - - - 3 - - - - - WPM - - - - - - - - 24 - 24 - - - - CW speed (WPM) - - - 1 - - - 26 - - - 1 - - - 13 - - - - - - - - 16 - 0 - - - - - 9 - - - - CW speed display (WPM) - - - 13 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 12 - 75 - true - - - - Send dots - - - . - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 12 - 75 - true - - - - Send dashes - - - - - - - - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 106 - 104 - 100 - - - - - - - - - DejaVu Serif - 9 - 75 - true - - - - Send text written above - - - T - - - true - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - Play text in a loop - - - - :/playloop.png:/playloop.png - - - - 16 - 16 - - - - true - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - Play / stop text coding - - - - :/play.png - :/stop.png:/play.png - - - - 16 - 16 - - - - true - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - CW text - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - Clear CW text - - - - - - - :/clear.png:/clear.png - - - - 16 - 16 - - - - - - - - - - - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
-
- - playLoopCW - - - - - -
+ + + CWKeyerGUI + + + + 0 + 0 + 375 + 60 + + + + + Sans Serif + 8 + + + + CW Keyer + + + + 2 + + + 3 + + + + + 3 + + + + + WPM + + + + + + + + 24 + 24 + + + + CW speed (WPM) + + + 1 + + + 26 + + + 1 + + + 13 + + + + + + + + 16 + 0 + + + + + 9 + + + + CW speed display (WPM) + + + 13 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 12 + 75 + true + + + + Send dots + + + . + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 12 + 75 + true + + + + Send dashes + + + - + + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 106 + 104 + 100 + + + + + + + + + DejaVu Serif + 9 + 75 + true + + + + Send text written above + + + T + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + Play text in a loop + + + + :/playloop.png:/playloop.png + + + + 16 + 16 + + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + Play / stop text coding + + + + :/play.png + :/stop.png:/play.png + + + + 16 + 16 + + + + true + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + CW text + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Clear CW text + + + + + + + :/clear.png:/clear.png + + + + 16 + 16 + + + + + + + + + + + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+
+ + playLoopCW + + + + + +
diff --git a/sdrbase/gui/myposdialog.ui b/sdrbase/gui/myposdialog.ui index a794c7925..d87ff3ad8 100644 --- a/sdrbase/gui/myposdialog.ui +++ b/sdrbase/gui/myposdialog.ui @@ -1,122 +1,122 @@ - - - MyPositionDialog - - - - 0 - 0 - 324 - 127 - - - - - Sans Serif - 9 - - - - Dialog - - - - - - My Station Position - - - - - - Latitude - - - - - - - Longitude - - - - - - - 6 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - 6 - - - -90.000000000000000 - - - 90.000000000000000 - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - buttonBox - - - - - buttonBox - accepted() - MyPositionDialog - accept() - - - 257 - 194 - - - 157 - 203 - - - - - buttonBox - rejected() - MyPositionDialog - reject() - - - 314 - 194 - - - 286 - 203 - - - - - + + + MyPositionDialog + + + + 0 + 0 + 324 + 127 + + + + + Sans Serif + 9 + + + + Dialog + + + + + + My Station Position + + + + + + Latitude + + + + + + + Longitude + + + + + + + 6 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + 6 + + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + buttonBox + + + + + buttonBox + accepted() + MyPositionDialog + accept() + + + 257 + 194 + + + 157 + 203 + + + + + buttonBox + rejected() + MyPositionDialog + reject() + + + 314 + 194 + + + 286 + 203 + + + + + diff --git a/sdrbase/gui/valuedialz.h b/sdrbase/gui/valuedialz.h index c7ad6b005..f7da0d8ab 100644 --- a/sdrbase/gui/valuedialz.h +++ b/sdrbase/gui/valuedialz.h @@ -1,83 +1,83 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 F4EXB // -// written by Edouard Griffiths // -// // -// Same as ValueDial but handles optionally positive and negative numbers with // -// sign display. // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include "gui/colormapper.h" -#include "util/export.h" - -class SDRANGEL_API ValueDialZ : public QWidget { - Q_OBJECT - -public: - ValueDialZ(bool positiveOnly = true, QWidget* parent = NULL, ColorMapper colorMapper = ColorMapper(ColorMapper::Normal)); - - void setValue(qint64 value); - void setValueRange(bool positiveOnly, uint numDigits, qint64 min, qint64 max); - void setFont(const QFont& font); - void setBold(bool bold); - void setColorMapper(ColorMapper colorMapper); - qint64 getValue() const { return m_value; } - qint64 getValueNew() const { return m_valueNew; } - -signals: - void changed(qint64 value); - -private: - QLinearGradient m_background; - int m_numDigits; - int m_numDecimalPoints; - int m_digitWidth; - int m_digitHeight; - int m_hightlightedDigit; - int m_cursor; - bool m_cursorState; - qint64 m_value; - qint64 m_valueMax; - qint64 m_valueMin; - bool m_positiveOnly; - QString m_text; - - qint64 m_valueNew; - QString m_textNew; - int m_animationState; - QTimer m_animationTimer; - QTimer m_blinkTimer; - - ColorMapper m_colorMapper; - - quint64 findExponent(int digit); - QChar digitNeigh(QChar c, bool dir); - QString formatText(qint64 value); - - void paintEvent(QPaintEvent*); - - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void wheelEvent(QWheelEvent*); - void leaveEvent(QEvent*); - void keyPressEvent(QKeyEvent*); - void focusInEvent(QFocusEvent*); - void focusOutEvent(QFocusEvent*); - -private slots: - void animate(); - void blink(); -}; +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// Same as ValueDial but handles optionally positive and negative numbers with // +// sign display. // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include "gui/colormapper.h" +#include "util/export.h" + +class SDRANGEL_API ValueDialZ : public QWidget { + Q_OBJECT + +public: + ValueDialZ(bool positiveOnly = true, QWidget* parent = NULL, ColorMapper colorMapper = ColorMapper(ColorMapper::Normal)); + + void setValue(qint64 value); + void setValueRange(bool positiveOnly, uint numDigits, qint64 min, qint64 max); + void setFont(const QFont& font); + void setBold(bool bold); + void setColorMapper(ColorMapper colorMapper); + qint64 getValue() const { return m_value; } + qint64 getValueNew() const { return m_valueNew; } + +signals: + void changed(qint64 value); + +private: + QLinearGradient m_background; + int m_numDigits; + int m_numDecimalPoints; + int m_digitWidth; + int m_digitHeight; + int m_hightlightedDigit; + int m_cursor; + bool m_cursorState; + qint64 m_value; + qint64 m_valueMax; + qint64 m_valueMin; + bool m_positiveOnly; + QString m_text; + + qint64 m_valueNew; + QString m_textNew; + int m_animationState; + QTimer m_animationTimer; + QTimer m_blinkTimer; + + ColorMapper m_colorMapper; + + quint64 findExponent(int digit); + QChar digitNeigh(QChar c, bool dir); + QString formatText(qint64 value); + + void paintEvent(QPaintEvent*); + + void mousePressEvent(QMouseEvent*); + void mouseMoveEvent(QMouseEvent*); + void wheelEvent(QWheelEvent*); + void leaveEvent(QEvent*); + void keyPressEvent(QKeyEvent*); + void focusInEvent(QFocusEvent*); + void focusOutEvent(QFocusEvent*); + +private slots: + void animate(); + void blink(); +};