From 08a3bc90970a70be2cc1fc3d51309f25d4c5b2ee Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 5 Dec 2015 11:49:24 +0100 Subject: [PATCH] UDP source: new icons. Implemented audio on/off button with icon --- plugins/channel/udpsrc/udpsrc.cpp | 52 ++++++++++++++++++++------- plugins/channel/udpsrc/udpsrc.h | 1 + plugins/channel/udpsrc/udpsrcgui.cpp | 2 +- plugins/channel/udpsrc/udpsrcgui.h | 2 +- plugins/channel/udpsrc/udpsrcgui.ui | 31 ++++++++++------ sdrbase/resources/mono.png | Bin 0 -> 523 bytes sdrbase/resources/res.qrc | 4 +++ sdrbase/resources/sound_off.png | Bin 0 -> 528 bytes sdrbase/resources/sound_on.png | Bin 0 -> 890 bytes sdrbase/resources/stereo.png | Bin 0 -> 804 bytes 10 files changed, 67 insertions(+), 25 deletions(-) create mode 100644 sdrbase/resources/mono.png create mode 100644 sdrbase/resources/sound_off.png create mode 100644 sdrbase/resources/sound_on.png create mode 100644 sdrbase/resources/stereo.png diff --git a/plugins/channel/udpsrc/udpsrc.cpp b/plugins/channel/udpsrc/udpsrc.cpp index b780c2ca6..516881633 100644 --- a/plugins/channel/udpsrc/udpsrc.cpp +++ b/plugins/channel/udpsrc/udpsrc.cpp @@ -31,6 +31,7 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s m_settingsMutex(QMutex::Recursive), m_audioFifo(4, 24000), m_audioActive(false), + m_audioStereo(false), m_volume(20) { setObjectName("UDPSrc"); @@ -382,24 +383,49 @@ void UDPSrc::audioReadyRead() if (m_audioActive) { - for (int i = 0; i < buffer.size() - 3; i += 4) + if (m_audioStereo) { - qint16 l_sample = (qint16) *(&buffer.data()[i]); - qint16 r_sample = (qint16) *(&buffer.data()[i+2]); - m_audioBuffer[m_audioBufferFill].l = l_sample * 10 * m_volume; - m_audioBuffer[m_audioBufferFill].r = r_sample * 10 * m_volume; - ++m_audioBufferFill; - - if (m_audioBufferFill >= m_audioBuffer.size()) + for (int i = 0; i < buffer.size() - 3; i += 4) { - uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1); + qint16 l_sample = (qint16) *(&buffer.data()[i]); + qint16 r_sample = (qint16) *(&buffer.data()[i+2]); + m_audioBuffer[m_audioBufferFill].l = l_sample * 10 * m_volume; + m_audioBuffer[m_audioBufferFill].r = r_sample * 10 * m_volume; + ++m_audioBufferFill; - if (res != m_audioBufferFill) + if (m_audioBufferFill >= m_audioBuffer.size()) { - qDebug("UDPSrc::audioReadyRead: lost %u samples", m_audioBufferFill - res); - } + uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1); - m_audioBufferFill = 0; + if (res != m_audioBufferFill) + { + qDebug("UDPSrc::audioReadyRead: (stereo) lost %u samples", m_audioBufferFill - res); + } + + m_audioBufferFill = 0; + } + } + } + else + { + for (int i = 0; i < buffer.size() - 1; i += 2) + { + qint16 sample = (qint16) *(&buffer.data()[i]); + m_audioBuffer[m_audioBufferFill].l = sample * 10 * m_volume; + m_audioBuffer[m_audioBufferFill].r = sample * 10 * m_volume; + ++m_audioBufferFill; + + if (m_audioBufferFill >= m_audioBuffer.size()) + { + uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1); + + if (res != m_audioBufferFill) + { + qDebug("UDPSrc::audioReadyRead: (mono) lost %u samples", m_audioBufferFill - res); + } + + m_audioBufferFill = 0; + } } } diff --git a/plugins/channel/udpsrc/udpsrc.h b/plugins/channel/udpsrc/udpsrc.h index c8c4b0c54..874288f45 100644 --- a/plugins/channel/udpsrc/udpsrc.h +++ b/plugins/channel/udpsrc/udpsrc.h @@ -181,6 +181,7 @@ protected: quint16 m_audioPort; int m_boost; bool m_audioActive; + bool m_audioStereo; int m_volume; Real m_magsq; diff --git a/plugins/channel/udpsrc/udpsrcgui.cpp b/plugins/channel/udpsrc/udpsrcgui.cpp index 568e646f5..c69fa25f7 100644 --- a/plugins/channel/udpsrc/udpsrcgui.cpp +++ b/plugins/channel/udpsrc/udpsrcgui.cpp @@ -402,7 +402,7 @@ void UDPSrcGUI::on_applyBtn_clicked() applySettings(); } -void UDPSrcGUI::on_audioActive_toggled(bool checked) +void UDPSrcGUI::on_audioActive_toggled(bool active) { ui->applyBtn->setEnabled(true); } diff --git a/plugins/channel/udpsrc/udpsrcgui.h b/plugins/channel/udpsrc/udpsrcgui.h index 0fae6df23..8971de9e2 100644 --- a/plugins/channel/udpsrc/udpsrcgui.h +++ b/plugins/channel/udpsrc/udpsrcgui.h @@ -47,7 +47,7 @@ private slots: void on_udpAddress_textEdited(const QString& arg1); void on_udpPort_textEdited(const QString& arg1); void on_audioPort_textEdited(const QString& arg1); - void on_audioActive_toggled(bool checked); + void on_audioActive_toggled(bool active); void on_applyBtn_clicked(); void onWidgetRolled(QWidget* widget, bool rollDown); void onMenuDoubleClicked(); diff --git a/plugins/channel/udpsrc/udpsrcgui.ui b/plugins/channel/udpsrc/udpsrcgui.ui index 9be79fa62..57e1d3f7b 100644 --- a/plugins/channel/udpsrc/udpsrcgui.ui +++ b/plugins/channel/udpsrc/udpsrcgui.ui @@ -167,6 +167,9 @@ + + Frequency shift direction + ... @@ -323,16 +326,6 @@ - - - - Activate audio - - - - - - @@ -343,6 +336,24 @@ + + + + Toggle audio input + + + ... + + + + :/sound_off.png + :/sound_on.png:/sound_off.png + + + true + + + diff --git a/sdrbase/resources/mono.png b/sdrbase/resources/mono.png new file mode 100644 index 0000000000000000000000000000000000000000..d99257e7ba0ea1a66a3617e400d216c2b2ca18d5 GIT binary patch literal 523 zcmV+m0`&cfP)GEnuuVEeER&z0$aVp>k;T%+Hoqew+L;uA zv|)?gF2y5|kVSfd9qneN<)YtyP2lZ~272?J^h)0BE&Z42Q$Nwlv;m`N_!%wOWmXg9F;_HX(#{8~It?E)@WJSfo%W zZ1p>n6#Wv%jJmUcqf5vx1w^nOtaafR4P#@6v*fEnf05T`d(eApMEUUG__i- z3Ya8`y2xv| z2?17~g6zg-i!vr9}j{f`UvC2$M)0(|CQ;5*6kFYEp%{n7vc N002ovPDHLkV1l>hmem.png minusw.png plusw.png + mono.png + stereo.png + sound_off.png + sound_on.png diff --git a/sdrbase/resources/sound_off.png b/sdrbase/resources/sound_off.png new file mode 100644 index 0000000000000000000000000000000000000000..bee07d8fe9c527c473db48c608951bca48eb7cfa GIT binary patch literal 528 zcmV+r0`L8aP)FP!#!zQ6N+kW-SJq!X?wn=|+=;5qP6l1G`6 zbVE{KKlD!0&C-HrS#~1nwSMXCbpcnl$Qbhyc)ZzcSg+TGlC)Q}<`rH-KA#`GC_n3-PNzgsM7P@|O;e09muGSuz&VHS`}n?(G3GZw(crm% z^5tqu2b3~{e-5zL;&~p0|!Y& zK~zY`y_HXB9CZ}OKQq~Fv&lBqwnS^mQq-ata!C~&Qh!8yJMLY>XCD4oZ zA_(@D9?d1-L4vnPQHtUrDM2;~p$J7{8Y0~++9sxHoB4R?+jJ95*m&^4FmGnweBZy{ zdtYc$)STMFJ|%4u{21^#@V1)Y#imVtX}9ltfge&wyf5FV9Sz?K>f@om6E=fQgJ)UR zqF(TUjH!p!PBm3uSFfrss;9!{Yqho6=r5=)EiJjYxL9{^T%A_mRnMrm)XQN%u3lGr zn*sk)-JGAFx4*yNN~O~1;7|2O^{Dz&MBb&o75dpaPEJjLM}a2*fxEz2;QeZ~nwHCD z+S=Mk)2;Kc0bB$=1fB-Qfiu9Hz$G99POIZdl5C*1sxzutmYHRls;jH3c6WCR*wfSF z?CfkkgN`VT>IZ7CdPn_MeMtR9{Z2j7cue!PT8)W`38to|02mn=VQy}2w+b!;e*n({ zS0k&_z%Afc;1p2UHV2hTg>t#f(9jTTYilG)va=_RkE;RvRFw30;1F;aSOB_!gWDYB zayg2{BE@2nBuTb8*Z~f(4qOM01MR>ypanPz+z372^d#@hCZhfe=m?-%V6{hfTi7Z8 zO^nmh0wln_xF_*`f4k^kq$QfT4r~I&0KNkpXb9qggEURa=kw%pxn>-+0-aIs+rVSt z=q7L^Z0-Tn(b7_>#PIMirBaDPp+I|k`(6&(fRoYO+rX32mmA@%7TJJ$P`#wCt2g6v zVPV0(zP_zNo0*wu9JKBjw9nKN>V|qHu)bHP)XsVacY%*1A|tiluCA_gqobn?3=B}M zRvS-J3OpD372x^6xeOcwo&hF+zxP^niTaW1^z^iYgM&^^PS!K%RDV#fsVCL1BAb`h z7wRjdS&BTDWtq#%%dV`fG;Y&P^SG)Gu}r&co_!v7X-uKKMi} zstfAR>WTeOX0f3RV>>AG5%s;G)mOsi{Qk%GKG2vtv>P2pKR&H<^#3OR0Q?%V#nMWe Q(EtDd07*qoM6N<$f=wZ)0{{R3 literal 0 HcmV?d00001 diff --git a/sdrbase/resources/stereo.png b/sdrbase/resources/stereo.png new file mode 100644 index 0000000000000000000000000000000000000000..77a319ec5ef8459b7f58505629c14c0d60aa7ad7 GIT binary patch literal 804 zcmV+<1Ka$GP)clJEO!Yikpr_V)HtlxH$nTwGL3ON#(?bad$O z@KEP{B)zqOi065v(`gnK766!;nPGW(x#A0muSy90%8Raa|W<%o#wX<^aYRT-T+cp#j^r zE9>O**;FfwzpQ@)uq=y6B!c5ORh{?wLNLYTE8ZDpCmo?hb(vn(RTLq}Mw^yF$ zm71#Q9pFB2EgTh}fg7<{Y;1ORmj3>JipAm&D`|g!pRTShrl+TAYHAWN2)qaE z@c2JmH0X?^dy^m|<`#Fg~y0>GHtxf#a|c iUIGPR+!%Ar|I}Ce_H&X~{-!Yi0000