From 70959a97965e273f744b7ef3666ceb9d91af54d5 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Fri, 8 Apr 2022 11:21:04 -0400 Subject: [PATCH] Add a spinner control for scaling of I/Q input level. --- map65/devsetup.cpp | 11 ++++++++--- map65/devsetup.h | 3 ++- map65/devsetup.ui | 27 ++++++++++++++++++--------- map65/mainwindow.cpp | 12 ++++++------ map65/mainwindow.h | 2 +- map65/soundin.cpp | 14 +++++++------- map65/soundin.h | 4 ++-- 7 files changed, 44 insertions(+), 29 deletions(-) diff --git a/map65/devsetup.cpp b/map65/devsetup.cpp index 01f373e60..fe9d14a95 100644 --- a/map65/devsetup.cpp +++ b/map65/devsetup.cpp @@ -106,8 +106,8 @@ void DevSetup::initDlg() ui.comboBoxSndOut->setCurrentIndex(m_nDevOut); ui.sbPort->setValue(m_udpPort); ui.cbIQswap->setChecked(m_IQswap); - ui.cb10db->setChecked(m_10db); ui.cbInitIQplus->setChecked(m_initIQplus); + ui.sb_dB->setValue(m_dB); ui.mult570SpinBox->setValue(m_mult570); ui.mult570TxSpinBox->setValue(m_mult570Tx); ui.cal570SpinBox->setValue(m_cal570); @@ -176,8 +176,8 @@ void DevSetup::accept() m_paOutDevice=m_outDevList[m_nDevOut]; m_udpPort=ui.sbPort->value(); m_IQswap=ui.cbIQswap->isChecked(); - m_10db=ui.cb10db->isChecked(); m_initIQplus=ui.cbInitIQplus->isChecked(); + m_dB=ui.sb_dB->value(); m_mult570=ui.mult570SpinBox->value(); m_mult570Tx=ui.mult570TxSpinBox->value(); m_cal570=ui.cal570SpinBox->value(); @@ -195,7 +195,7 @@ void DevSetup::on_soundCardRadioButton_toggled(bool checked) ui.label_Port->setEnabled(!checked); ui.sbPort->setEnabled(!checked); ui.cbIQswap->setEnabled(checked); - ui.cb10db->setEnabled(checked); + ui.sb_dB->setEnabled(checked); } void DevSetup::on_cbXpol_stateChanged(int n) @@ -217,6 +217,11 @@ void DevSetup::on_mult570SpinBox_valueChanged(int mult) m_mult570=mult; } +void DevSetup::on_sb_dB_valueChanged(int n) +{ + m_dB=n; +} + void DevSetup::updateColorLabels() { QString t; diff --git a/map65/devsetup.h b/map65/devsetup.h index 148f76c4e..c32a83e96 100644 --- a/map65/devsetup.h +++ b/map65/devsetup.h @@ -27,6 +27,7 @@ public: qint32 m_astroFont; qint32 m_mult570; qint32 m_mult570Tx; + qint32 m_dB; double m_fAdd; double m_cal570; @@ -39,7 +40,6 @@ public: bool m_IQswap; bool m_restartSoundIn; bool m_restartSoundOut; - bool m_10db; bool m_initIQplus; bool m_bIQxt; @@ -81,6 +81,7 @@ private slots: void on_mult570TxSpinBox_valueChanged(int arg1); void on_rbIQXT_toggled(bool checked); void on_sbTxOffset_valueChanged(double f); + void on_sb_dB_valueChanged(int n); private: int r,g,b,r0,g0,b0,r1,g1,b1,r2,g2,b2,r3,g3,b3; diff --git a/map65/devsetup.ui b/map65/devsetup.ui index 81ae68e6a..7f6f79fc6 100644 --- a/map65/devsetup.ui +++ b/map65/devsetup.ui @@ -698,12 +698,21 @@ - - - false + + + dB - - +10 dB + + + + + -50 + + + 10 + + + 5 @@ -1772,8 +1781,8 @@ accept() - 248 - 254 + 257 + 380 157 @@ -1788,8 +1797,8 @@ reject() - 316 - 260 + 325 + 380 286 diff --git a/map65/mainwindow.cpp b/map65/mainwindow.cpp index 2e7bfa756..54b84b73a 100644 --- a/map65/mainwindow.cpp +++ b/map65/mainwindow.cpp @@ -372,7 +372,7 @@ void MainWindow::writeSettings() settings.setValue("SoundOutIndex",m_nDevOut); settings.setValue("paOutDevice",m_paOutDevice); settings.setValue("IQswap",m_IQswap); - settings.setValue("Plus10dB",m_10db); + settings.setValue("Scale_dB",m_dB); settings.setValue("IQxt",m_bIQxt); settings.setValue("InitIQplus",m_initIQplus); settings.setValue("UDPport",m_udpPort); @@ -447,12 +447,12 @@ void MainWindow::readSettings() m_nDevOut = settings.value("SoundOutIndex", 0).toInt(); m_paOutDevice = settings.value("paOutDevice",0).toInt(); m_IQswap = settings.value("IQswap",false).toBool(); - m_10db = settings.value("Plus10dB",false).toBool(); + m_dB = settings.value("Scale_dB",0).toInt(); m_initIQplus = settings.value("InitIQplus",false).toBool(); m_bIQxt = settings.value("IQxt",false).toBool(); m_udpPort = settings.value("UDPport",50004).toInt(); soundInThread.setSwapIQ(m_IQswap); - soundInThread.set10db(m_10db); + soundInThread.setScale(m_dB); soundInThread.setPort(m_udpPort); ui->actionCuteSDR->setChecked(settings.value( "PaletteCuteSDR",true).toBool()); @@ -682,7 +682,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog dlg.m_nDevOut=m_nDevOut; dlg.m_udpPort=m_udpPort; dlg.m_IQswap=m_IQswap; - dlg.m_10db=m_10db; + dlg.m_dB=m_dB; dlg.m_initIQplus=m_initIQplus; dlg.m_bIQxt=m_bIQxt; dlg.m_cal570=m_cal570; @@ -719,7 +719,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog m_paOutDevice=dlg.m_paOutDevice; m_udpPort=dlg.m_udpPort; m_IQswap=dlg.m_IQswap; - m_10db=dlg.m_10db; + m_dB=dlg.m_dB; m_initIQplus=dlg.m_initIQplus; m_bIQxt=dlg.m_bIQxt; m_colors=dlg.m_colors; @@ -732,7 +732,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog m_wide_graph_window->m_mult570Tx=m_mult570Tx; m_wide_graph_window->m_cal570=m_cal570; soundInThread.setSwapIQ(m_IQswap); - soundInThread.set10db(m_10db); + soundInThread.setScale(m_dB); if(dlg.m_restartSoundIn) { soundInThread.quit(); diff --git a/map65/mainwindow.h b/map65/mainwindow.h index 8b85e7611..b90683fc7 100644 --- a/map65/mainwindow.h +++ b/map65/mainwindow.h @@ -192,6 +192,7 @@ private: qint32 m_modeJT65; qint32 m_modeQ65; qint32 m_RxState; + qint32 m_dB; double m_fAdd; @@ -220,7 +221,6 @@ private: bool m_NB; bool m_fs96000; bool m_IQswap; - bool m_10db; bool m_initIQplus; bool m_bIQxt; diff --git a/map65/soundin.cpp b/map65/soundin.cpp index 0e50f2935..46433d4ea 100644 --- a/map65/soundin.cpp +++ b/map65/soundin.cpp @@ -1,4 +1,5 @@ #include "soundin.h" +#include #ifdef Q_OS_WIN32 #include @@ -53,9 +54,9 @@ typedef struct { int kin; //Parameters sent to/from the portaudio callback function int nrx; + int dB; bool bzero; bool iqswap; - bool b10db; } paUserData; //--------------------------------------------------------------- a2dCallback @@ -91,8 +92,7 @@ extern "C" int a2dCallback( const void *inputBuffer, void *outputBuffer, nbytes=udata->nrx*8*framesToProcess; //Bytes per frame memcpy(d4,inputBuffer,nbytes); //Copy all samples to d4 - fac=32767.0; - if(udata->b10db) fac=103618.35; + fac=32767.0 * pow(10.0,0.05*udata->dB); if(udata->nrx==2) { for(i=0; i<4*int(framesToProcess); i++) { //Negate odd-numbered frames @@ -185,7 +185,7 @@ void SoundInThread::run() //SoundInThread::run() udata.bzero=false; //Flag to request reset of kin udata.nrx=m_nrx; //Number of polarizations udata.iqswap=m_IQswap; - udata.b10db=m_10db; + udata.dB=m_dB; auto device_info = Pa_GetDeviceInfo (m_nDevIn); @@ -251,7 +251,7 @@ void SoundInThread::run() //SoundInThread::run() } k=udata.kin; udata.iqswap=m_IQswap; - udata.b10db=m_10db; + udata.dB=m_dB; if(m_monitoring) { if(m_bForceCenterFreq) { datcom_.fcenter=m_dForceCenterFreq; @@ -281,9 +281,9 @@ void SoundInThread::setSwapIQ(bool b) m_IQswap=b; } -void SoundInThread::set10db(bool b) +void SoundInThread::setScale(qint32 n) { - m_10db=b; + m_dB=n; } void SoundInThread::setPort(int n) //setPort() { diff --git a/map65/soundin.h b/map65/soundin.h index 369cf1d71..78947338f 100644 --- a/map65/soundin.h +++ b/map65/soundin.h @@ -30,7 +30,7 @@ public: } void setSwapIQ(bool b); - void set10db(bool b); + void setScale(qint32 n); void setPort(qint32 n); void setInputDevice(qint32 n); void setRate(double rate); @@ -62,7 +62,6 @@ private: bool m_monitoring; bool m_bForceCenterFreq; bool m_IQswap; - bool m_10db; double m_dForceCenterFreq; qint32 m_nrx; qint32 m_hsym; @@ -70,6 +69,7 @@ private: qint32 m_udpPort; qint32 m_TRperiod; qint32 m_TRperiod0; + qint32 m_dB; QUdpSocket *udpSocket; };