1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 13:21:50 -05:00

UDP source: new icons. Implemented audio on/off button with icon

This commit is contained in:
f4exb 2015-12-05 11:49:24 +01:00
parent 74f1f4e675
commit 08a3bc9097
10 changed files with 67 additions and 25 deletions

View File

@ -31,6 +31,7 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s
m_settingsMutex(QMutex::Recursive), m_settingsMutex(QMutex::Recursive),
m_audioFifo(4, 24000), m_audioFifo(4, 24000),
m_audioActive(false), m_audioActive(false),
m_audioStereo(false),
m_volume(20) m_volume(20)
{ {
setObjectName("UDPSrc"); setObjectName("UDPSrc");
@ -382,24 +383,49 @@ void UDPSrc::audioReadyRead()
if (m_audioActive) if (m_audioActive)
{ {
for (int i = 0; i < buffer.size() - 3; i += 4) if (m_audioStereo)
{ {
qint16 l_sample = (qint16) *(&buffer.data()[i]); for (int i = 0; i < buffer.size() - 3; i += 4)
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())
{ {
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;
}
} }
} }

View File

@ -181,6 +181,7 @@ protected:
quint16 m_audioPort; quint16 m_audioPort;
int m_boost; int m_boost;
bool m_audioActive; bool m_audioActive;
bool m_audioStereo;
int m_volume; int m_volume;
Real m_magsq; Real m_magsq;

View File

@ -402,7 +402,7 @@ void UDPSrcGUI::on_applyBtn_clicked()
applySettings(); applySettings();
} }
void UDPSrcGUI::on_audioActive_toggled(bool checked) void UDPSrcGUI::on_audioActive_toggled(bool active)
{ {
ui->applyBtn->setEnabled(true); ui->applyBtn->setEnabled(true);
} }

View File

@ -47,7 +47,7 @@ private slots:
void on_udpAddress_textEdited(const QString& arg1); void on_udpAddress_textEdited(const QString& arg1);
void on_udpPort_textEdited(const QString& arg1); void on_udpPort_textEdited(const QString& arg1);
void on_audioPort_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 on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown); void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked(); void onMenuDoubleClicked();

View File

@ -167,6 +167,9 @@
<layout class="QHBoxLayout" name="DeltaFrequencyLayout"> <layout class="QHBoxLayout" name="DeltaFrequencyLayout">
<item> <item>
<widget class="QToolButton" name="deltaMinus"> <widget class="QToolButton" name="deltaMinus">
<property name="toolTip">
<string>Frequency shift direction</string>
</property>
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
@ -323,16 +326,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="audioActive">
<property name="toolTip">
<string>Activate audio</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item> <item>
<widget class="QLineEdit" name="audioPort"> <widget class="QLineEdit" name="audioPort">
<property name="toolTip"> <property name="toolTip">
@ -343,6 +336,24 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="audioActive">
<property name="toolTip">
<string>Toggle audio input</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/sound_off.png</normaloff>
<normalon>:/sound_on.png</normalon>:/sound_off.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">

BIN
sdrbase/resources/mono.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

View File

@ -37,5 +37,9 @@
<file>mem.png</file> <file>mem.png</file>
<file>minusw.png</file> <file>minusw.png</file>
<file>plusw.png</file> <file>plusw.png</file>
<file>mono.png</file>
<file>stereo.png</file>
<file>sound_off.png</file>
<file>sound_on.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B