diff --git a/sdrbase/audio/audiocompressor.cpp b/sdrbase/audio/audiocompressor.cpp
index aced6a949..ac4f8a083 100644
--- a/sdrbase/audio/audiocompressor.cpp
+++ b/sdrbase/audio/audiocompressor.cpp
@@ -107,8 +107,7 @@ int16_t AudioCompressor::compress(int16_t sample)
int8_t AudioCompressor::compress8(int16_t sample)
{
- return ALaw_Encode(sample);
- //return m_lut[sample/2 + 16384];
+ return m_lut[sample/2 + 16384];
}
/* http://dystopiancode.blogspot.com/2012/02/pcm-law-and-u-law-companding-algorithms.html
diff --git a/sdrbase/audio/audiodevicemanager.cpp b/sdrbase/audio/audiodevicemanager.cpp
index 40a599fa7..dc60cfff6 100644
--- a/sdrbase/audio/audiodevicemanager.cpp
+++ b/sdrbase/audio/audiodevicemanager.cpp
@@ -48,7 +48,8 @@ QDataStream& operator<<(QDataStream& ds, const AudioDeviceManager::OutputDeviceI
<< info.copyToUDP
<< info.udpUseRTP
<< (int) info.udpChannelMode
- << (int) info.udpChannelCodec;
+ << (int) info.udpChannelCodec
+ << info.decimationFactor;
return ds;
}
@@ -63,7 +64,8 @@ QDataStream& operator>>(QDataStream& ds, AudioDeviceManager::OutputDeviceInfo& i
>> info.copyToUDP
>> info.udpUseRTP
>> intChannelMode
- >> intChannelCodec;
+ >> intChannelCodec
+ >> info.decimationFactor;
info.udpChannelMode = (AudioOutput::UDPChannelMode) intChannelMode;
info.udpChannelCodec = (AudioOutput::UDPChannelCodec) intChannelCodec;
return ds;
@@ -362,6 +364,7 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
bool udpUseRTP;
AudioOutput::UDPChannelMode udpChannelMode;
AudioOutput::UDPChannelCodec udpChannelCodec;
+ uint32_t decimationFactor;
QString deviceName;
if (getOutputDeviceName(outputDeviceIndex, deviceName))
@@ -375,6 +378,7 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
udpUseRTP = false;
udpChannelMode = AudioOutput::UDPChannelLeft;
udpChannelCodec = AudioOutput::UDPCodecL16;
+ decimationFactor = 1;
}
else
{
@@ -385,6 +389,7 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
udpUseRTP = m_audioOutputInfos[deviceName].udpUseRTP;
udpChannelMode = m_audioOutputInfos[deviceName].udpChannelMode;
udpChannelCodec = m_audioOutputInfos[deviceName].udpChannelCodec;
+ decimationFactor = m_audioOutputInfos[deviceName].decimationFactor;
}
m_audioOutputs[outputDeviceIndex]->start(outputDeviceIndex, sampleRate);
@@ -395,6 +400,7 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
m_audioOutputInfos[deviceName].udpUseRTP = udpUseRTP;
m_audioOutputInfos[deviceName].udpChannelMode = udpChannelMode;
m_audioOutputInfos[deviceName].udpChannelCodec = udpChannelCodec;
+ m_audioOutputInfos[deviceName].decimationFactor = decimationFactor;
}
else
{
@@ -776,6 +782,7 @@ void AudioDeviceManager::debugAudioOutputInfos() const
<< " copyToUDP: " << it.value().copyToUDP
<< " udpUseRTP: " << it.value().udpUseRTP
<< " udpChannelMode: " << (int) it.value().udpChannelMode
- << " udpChannelCodec: " << (int) it.value().udpChannelCodec;
+ << " udpChannelCodec: " << (int) it.value().udpChannelCodec
+ << " decimationFactor: " << it.value().decimationFactor;
}
}
diff --git a/sdrbase/audio/audiodevicemanager.h b/sdrbase/audio/audiodevicemanager.h
index c1240d208..b4dad5754 100644
--- a/sdrbase/audio/audiodevicemanager.h
+++ b/sdrbase/audio/audiodevicemanager.h
@@ -59,7 +59,9 @@ public:
udpPort(m_defaultUDPPort),
copyToUDP(false),
udpUseRTP(false),
- udpChannelMode(AudioOutput::UDPChannelLeft)
+ udpChannelMode(AudioOutput::UDPChannelLeft),
+ udpChannelCodec(AudioOutput::UDPCodecL16),
+ decimationFactor(1)
{}
void resetToDefaults() {
sampleRate = m_defaultAudioSampleRate;
@@ -68,6 +70,8 @@ public:
copyToUDP = false;
udpUseRTP = false;
udpChannelMode = AudioOutput::UDPChannelLeft;
+ udpChannelCodec = AudioOutput::UDPCodecL16;
+ decimationFactor = 1;
}
unsigned int sampleRate;
QString udpAddress;
@@ -76,6 +80,7 @@ public:
bool udpUseRTP;
AudioOutput::UDPChannelMode udpChannelMode;
AudioOutput::UDPChannelCodec udpChannelCodec;
+ uint32_t decimationFactor;
friend QDataStream& operator<<(QDataStream& ds, const OutputDeviceInfo& info);
friend QDataStream& operator>>(QDataStream& ds, OutputDeviceInfo& info);
};
diff --git a/sdrgui/gui/audiodialog.cpp b/sdrgui/gui/audiodialog.cpp
index 3ae10455b..5616a4288 100644
--- a/sdrgui/gui/audiodialog.cpp
+++ b/sdrgui/gui/audiodialog.cpp
@@ -211,6 +211,30 @@ void AudioDialogX::on_outputCleanup_clicked(bool checked)
m_audioDeviceManager->outputInfosCleanup();
}
+void AudioDialogX::on_outputSampleRate_valueChanged(int value)
+{
+ m_outputDeviceInfo.sampleRate = value;
+ updateOutputSDPString();
+}
+
+void AudioDialogX::on_decimationFactor_currentIndexChanged(int index)
+{
+ m_outputDeviceInfo.decimationFactor = index + 1;
+ updateOutputSDPString();
+}
+
+void AudioDialogX::on_outputUDPChannelCodec_currentIndexChanged(int index)
+{
+ m_outputDeviceInfo.udpChannelCodec = (AudioOutput::UDPChannelCodec) index;
+ updateOutputSDPString();
+}
+
+void AudioDialogX::on_outputUDPChannelMode_currentIndexChanged(int index)
+{
+ m_outputDeviceInfo.udpChannelMode = (AudioOutput::UDPChannelMode) index;
+ updateOutputSDPString();
+}
+
void AudioDialogX::updateOutputDisplay()
{
ui->outputSampleRate->setValue(m_outputDeviceInfo.sampleRate);
@@ -220,6 +244,8 @@ void AudioDialogX::updateOutputDisplay()
ui->outputUDPUseRTP->setChecked(m_outputDeviceInfo.udpUseRTP);
ui->outputUDPChannelMode->setCurrentIndex((int) m_outputDeviceInfo.udpChannelMode);
ui->outputUDPChannelCodec->setCurrentIndex((int) m_outputDeviceInfo.udpChannelCodec);
+ ui->decimationFactor->setCurrentIndex(m_outputDeviceInfo.decimationFactor - 1);
+ updateOutputSDPString();
}
void AudioDialogX::updateOutputDeviceInfo()
@@ -231,5 +257,31 @@ void AudioDialogX::updateOutputDeviceInfo()
m_outputDeviceInfo.udpUseRTP = ui->outputUDPUseRTP->isChecked();
m_outputDeviceInfo.udpChannelMode = (AudioOutput::UDPChannelMode) ui->outputUDPChannelMode->currentIndex();
m_outputDeviceInfo.udpChannelCodec = (AudioOutput::UDPChannelCodec) ui->outputUDPChannelCodec->currentIndex();
+ m_outputDeviceInfo.decimationFactor = ui->decimationFactor->currentIndex() + 1;
}
+void AudioDialogX::updateOutputSDPString()
+{
+ QString format;
+
+ switch(m_outputDeviceInfo.udpChannelCodec)
+ {
+ case AudioOutput::UDPCodecALaw:
+ format = "PCMA";
+ break;
+ case AudioOutput::UDPCodecULaw:
+ format = "PCMU";
+ break;
+ case AudioOutput::UDPCodecL8:
+ format = "L8";
+ break;
+ case AudioOutput::UDPCodecL16:
+ default:
+ format = "L16";
+ break;
+ }
+
+ int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo ? 2 : 1;
+
+ ui->outputSDPText->setText(tr("%1/%2/%3").arg(format).arg(m_outputDeviceInfo.sampleRate/m_outputDeviceInfo.decimationFactor).arg(nChannels));
+}
diff --git a/sdrgui/gui/audiodialog.h b/sdrgui/gui/audiodialog.h
index 963806345..9305a582e 100644
--- a/sdrgui/gui/audiodialog.h
+++ b/sdrgui/gui/audiodialog.h
@@ -27,6 +27,7 @@ private:
void updateOutputDisplay();
void updateInputDeviceInfo();
void updateOutputDeviceInfo();
+ void updateOutputSDPString();
Ui::AudioDialog* ui;
@@ -46,6 +47,10 @@ private slots:
void on_outputUDPPort_editingFinished();
void on_outputReset_clicked(bool checked);
void on_outputCleanup_clicked(bool checked);
+ void on_outputSampleRate_valueChanged(int value);
+ void on_decimationFactor_currentIndexChanged(int index);
+ void on_outputUDPChannelCodec_currentIndexChanged(int index);
+ void on_outputUDPChannelMode_currentIndexChanged(int index);
};
#endif // INCLUDE_AUDIODIALOG_H
diff --git a/sdrgui/gui/audiodialog.ui b/sdrgui/gui/audiodialog.ui
index 43109542e..aed980dff 100644
--- a/sdrgui/gui/audiodialog.ui
+++ b/sdrgui/gui/audiodialog.ui
@@ -6,14 +6,14 @@
0
0
- 560
- 400
+ 460
+ 460
- 560
- 400
+ 460
+ 460
@@ -124,6 +124,170 @@
+ -
+
+
+ 6
+
+
-
+
+
+
+ 70
+ 0
+
+
+
+
+ 70
+ 16777215
+
+
+
+ Channel copy mode
+
+
-
+
+ Left
+
+
+ -
+
+ Right
+
+
+ -
+
+ Mixed
+
+
+ -
+
+ Stereo
+
+
+
+
+ -
+
+
+ /
+
+
+
+ -
+
+
+
+ 40
+ 16777215
+
+
+
+ Decimation
+
+
-
+
+ 1
+
+
+ -
+
+ 2
+
+
+ -
+
+ 3
+
+
+ -
+
+ 4
+
+
+ -
+
+ 5
+
+
+ -
+
+ 6
+
+
+
+
+ -
+
+
+
+ 65
+ 0
+
+
+
+
+ 65
+ 16777215
+
+
+
+ Encoding
+
+
-
+
+ L16
+
+
+ -
+
+ L8
+
+
+ -
+
+ PCMA
+
+
+ -
+
+ PCMU
+
+
+
+
+ -
+
+
+
+ 120
+ 0
+
+
+
+ Encoding string in SDP format
+
+
+ PCMA/48000
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
-
-
@@ -204,72 +368,6 @@
- -
-
-
-
- 80
- 0
-
-
-
- Channel copy mode
-
-
-
-
- Left
-
-
- -
-
- Right
-
-
- -
-
- Mixed
-
-
- -
-
- Stereo
-
-
-
-
- -
-
-
-
- 85
- 0
-
-
-
- Encoding
-
-
-
-
- L16
-
-
- -
-
- L8
-
-
- -
-
- PCMA/8k
-
-
- -
-
- PCMU/8k
-
-
-
-
-