1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

FreeDV demod: implemented modem input volume control. FreeDV mod: set volume polling to 10ms

This commit is contained in:
f4exb 2019-02-28 17:55:03 +01:00
parent 2c8cce0940
commit 554db8fe82
10 changed files with 149 additions and 67 deletions

View File

@ -306,11 +306,16 @@ void FreeDVDemod::feed(const SampleVector::const_iterator& begin, const SampleVe
if (m_agcActive) if (m_agcActive)
{ {
m_simpleAGC.feed(demod); m_simpleAGC.feed(demod);
demod *= 3276.8f / m_simpleAGC.getValue(); // provision for peak to average ratio (here 10) demod *= (m_settings.m_volumeIn * 3276.8f) / m_simpleAGC.getValue(); // provision for peak to average ratio (here 10) compensated by m_volumeIn
// if (i == 0) { // if (i == 0) {
// qDebug("FreeDVDemod::feed: m_simpleAGC: %f", m_simpleAGC.getValue()); // qDebug("FreeDVDemod::feed: m_simpleAGC: %f", m_simpleAGC.getValue());
// } // }
} }
else
{
demod *= m_settings.m_volumeIn;
}
pushSampleToDV((qint16) demod); pushSampleToDV((qint16) demod);
} }
@ -650,6 +655,7 @@ void FreeDVDemod::applySettings(const FreeDVDemodSettings& settings, bool force)
qDebug() << "FreeDVDemod::applySettings:" qDebug() << "FreeDVDemod::applySettings:"
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_volume: " << settings.m_volume << " m_volume: " << settings.m_volume
<< " m_volumeIn: " << settings.m_volumeIn
<< " m_spanLog2: " << settings.m_spanLog2 << " m_spanLog2: " << settings.m_spanLog2
<< " m_audioMute: " << settings.m_audioMute << " m_audioMute: " << settings.m_audioMute
<< " m_agcActive: " << settings.m_agc << " m_agcActive: " << settings.m_agc
@ -669,6 +675,11 @@ void FreeDVDemod::applySettings(const FreeDVDemodSettings& settings, bool force)
m_volume /= 4.0; // for 3276.8 m_volume /= 4.0; // for 3276.8
} }
if ((m_settings.m_volumeIn != settings.m_volumeIn) || force)
{
reverseAPIKeys.append("volumeIn");
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
{ {
reverseAPIKeys.append("audioDeviceName"); reverseAPIKeys.append("audioDeviceName");
@ -781,6 +792,9 @@ int FreeDVDemod::webapiSettingsPutPatch(
if (channelSettingsKeys.contains("volume")) { if (channelSettingsKeys.contains("volume")) {
settings.m_volume = response.getFreeDvDemodSettings()->getVolume(); settings.m_volume = response.getFreeDvDemodSettings()->getVolume();
} }
if (channelSettingsKeys.contains("volumeIn")) {
settings.m_volumeIn = response.getFreeDvDemodSettings()->getVolumeIn();
}
if (channelSettingsKeys.contains("spanLog2")) { if (channelSettingsKeys.contains("spanLog2")) {
settings.m_spanLog2 = response.getFreeDvDemodSettings()->getSpanLog2(); settings.m_spanLog2 = response.getFreeDvDemodSettings()->getSpanLog2();
} }
@ -838,6 +852,7 @@ void FreeDVDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& r
response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0); response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
response.getFreeDvDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset); response.getFreeDvDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getFreeDvDemodSettings()->setVolume(settings.m_volume); response.getFreeDvDemodSettings()->setVolume(settings.m_volume);
response.getFreeDvDemodSettings()->setVolumeIn(settings.m_volumeIn);
response.getFreeDvDemodSettings()->setSpanLog2(settings.m_spanLog2); response.getFreeDvDemodSettings()->setSpanLog2(settings.m_spanLog2);
response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0); response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
response.getFreeDvDemodSettings()->setAgc(settings.m_agc ? 1 : 0); response.getFreeDvDemodSettings()->setAgc(settings.m_agc ? 1 : 0);
@ -884,6 +899,9 @@ void FreeDVDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys,
if (channelSettingsKeys.contains("volume") || force) { if (channelSettingsKeys.contains("volume") || force) {
swgFreeDVDemodSettings->setVolume(settings.m_volume); swgFreeDVDemodSettings->setVolume(settings.m_volume);
} }
if (channelSettingsKeys.contains("volumeIn") || force) {
swgFreeDVDemodSettings->setVolumeIn(settings.m_volumeIn);
}
if (channelSettingsKeys.contains("spanLog2") || force) { if (channelSettingsKeys.contains("spanLog2") || force) {
swgFreeDVDemodSettings->setSpanLog2(settings.m_spanLog2); swgFreeDVDemodSettings->setSpanLog2(settings.m_spanLog2);
} }

View File

@ -288,7 +288,7 @@
<item> <item>
<widget class="QLabel" name="voluneInLabel"> <widget class="QLabel" name="voluneInLabel">
<property name="text"> <property name="text">
<string>Input</string> <string>In</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -300,6 +300,15 @@
<height>24</height> <height>24</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>Modem input volume adjustment</string>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -310,6 +319,9 @@
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>Modem input volume</string>
</property>
<property name="text"> <property name="text">
<string>2.0</string> <string>2.0</string>
</property> </property>
@ -361,6 +373,9 @@
<height>24</height> <height>24</height>
</size> </size>
</property> </property>
<property name="maximum">
<number>99</number>
</property>
<property name="pageStep"> <property name="pageStep">
<number>1</number> <number>1</number>
</property> </property>
@ -404,64 +419,6 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="statsLayout"> <layout class="QHBoxLayout" name="statsLayout">
<item>
<widget class="QLabel" name="snrLabel">
<property name="text">
<string>SNR</string>
</property>
</widget>
</item>
<item>
<widget class="LevelMeterSignalDB" name="snrMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>SNR estimation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="snrText">
<property name="minimumSize">
<size>
<width>52</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>SNR estimation</string>
</property>
<property name="text">
<string>-10.0 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="berLabel"> <widget class="QLabel" name="berLabel">
<property name="text"> <property name="text">
@ -513,6 +470,64 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="snrLabel">
<property name="text">
<string>SNR</string>
</property>
</widget>
</item>
<item>
<widget class="LevelMeterSignalDB" name="snrMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>SNR estimation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="snrText">
<property name="minimumSize">
<size>
<width>52</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>SNR estimation</string>
</property>
<property name="text">
<string>-10.0 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item> <item>
<widget class="Line" name="line_5"> <widget class="Line" name="line_5">
<property name="orientation"> <property name="orientation">

View File

@ -41,7 +41,7 @@ void FreeDVDemodSettings::resetToDefaults()
m_audioMute = false; m_audioMute = false;
m_agc = true; m_agc = true;
m_volume = 3.0; m_volume = 3.0;
m_volumeIn = 3.0; m_volumeIn = 1.0;
m_spanLog2 = 3; m_spanLog2 = 3;
m_inputFrequencyOffset = 0; m_inputFrequencyOffset = 0;
m_rgbColor = QColor(0, 255, 204).rgb(); m_rgbColor = QColor(0, 255, 204).rgb();
@ -109,7 +109,7 @@ bool FreeDVDemodSettings::deserialize(const QByteArray& data)
} }
d.readU32(5, &m_rgbColor); d.readU32(5, &m_rgbColor);
d.readS32(6, &tmp, 30); d.readS32(6, &tmp, 10);
m_volumeIn = tmp / 10.0; m_volumeIn = tmp / 10.0;
d.readS32(7, &m_spanLog2, 3); d.readS32(7, &m_spanLog2, 3);
d.readBool(11, &m_agc, false); d.readBool(11, &m_agc, false);

View File

@ -50,7 +50,7 @@ MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgReportFileSourceStreamTiming, Message)
const QString FreeDVMod::m_channelIdURI = "sdrangel.channeltx.freedvmod"; const QString FreeDVMod::m_channelIdURI = "sdrangel.channeltx.freedvmod";
const QString FreeDVMod::m_channelId = "FreeDVMod"; const QString FreeDVMod::m_channelId = "FreeDVMod";
const int FreeDVMod::m_levelNbSamples = 480; // every 10ms const int FreeDVMod::m_levelNbSamples = 80; // every 10ms
const int FreeDVMod::m_ssbFftLen = 1024; const int FreeDVMod::m_ssbFftLen = 1024;
FreeDVMod::FreeDVMod(DeviceSinkAPI *deviceAPI) : FreeDVMod::FreeDVMod(DeviceSinkAPI *deviceAPI) :

View File

@ -2580,7 +2580,13 @@ margin-bottom: 20px;
}, },
"volume" : { "volume" : {
"type" : "number", "type" : "number",
"format" : "float" "format" : "float",
"description" : "Audio volume"
},
"volumeIn" : {
"type" : "number",
"format" : "float",
"description" : "Modem input volume"
}, },
"spanLog2" : { "spanLog2" : {
"type" : "integer" "type" : "integer"
@ -24528,7 +24534,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2019-02-28T13:56:13.268+01:00 Generated 2019-02-28T17:16:26.748+01:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -5,6 +5,11 @@ FreeDVDemodSettings:
type: integer type: integer
format: int64 format: int64
volume: volume:
description: Audio volume
type: number
format: float
volumeIn:
description: Modem input volume
type: number type: number
format: float format: float
spanLog2: spanLog2:

View File

@ -5,6 +5,11 @@ FreeDVDemodSettings:
type: integer type: integer
format: int64 format: int64
volume: volume:
description: Audio volume
type: number
format: float
volumeIn:
description: Modem input volume
type: number type: number
format: float format: float
spanLog2: spanLog2:

View File

@ -2580,7 +2580,13 @@ margin-bottom: 20px;
}, },
"volume" : { "volume" : {
"type" : "number", "type" : "number",
"format" : "float" "format" : "float",
"description" : "Audio volume"
},
"volumeIn" : {
"type" : "number",
"format" : "float",
"description" : "Modem input volume"
}, },
"spanLog2" : { "spanLog2" : {
"type" : "integer" "type" : "integer"
@ -24528,7 +24534,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2019-02-28T13:56:13.268+01:00 Generated 2019-02-28T17:16:26.748+01:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -32,6 +32,8 @@ SWGFreeDVDemodSettings::SWGFreeDVDemodSettings() {
m_input_frequency_offset_isSet = false; m_input_frequency_offset_isSet = false;
volume = 0.0f; volume = 0.0f;
m_volume_isSet = false; m_volume_isSet = false;
volume_in = 0.0f;
m_volume_in_isSet = false;
span_log2 = 0; span_log2 = 0;
m_span_log2_isSet = false; m_span_log2_isSet = false;
audio_mute = 0; audio_mute = 0;
@ -58,6 +60,8 @@ SWGFreeDVDemodSettings::init() {
m_input_frequency_offset_isSet = false; m_input_frequency_offset_isSet = false;
volume = 0.0f; volume = 0.0f;
m_volume_isSet = false; m_volume_isSet = false;
volume_in = 0.0f;
m_volume_in_isSet = false;
span_log2 = 0; span_log2 = 0;
m_span_log2_isSet = false; m_span_log2_isSet = false;
audio_mute = 0; audio_mute = 0;
@ -82,6 +86,7 @@ SWGFreeDVDemodSettings::cleanup() {
if(title != nullptr) { if(title != nullptr) {
delete title; delete title;
} }
@ -106,6 +111,8 @@ SWGFreeDVDemodSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&volume, pJson["volume"], "float", ""); ::SWGSDRangel::setValue(&volume, pJson["volume"], "float", "");
::SWGSDRangel::setValue(&volume_in, pJson["volumeIn"], "float", "");
::SWGSDRangel::setValue(&span_log2, pJson["spanLog2"], "qint32", ""); ::SWGSDRangel::setValue(&span_log2, pJson["spanLog2"], "qint32", "");
::SWGSDRangel::setValue(&audio_mute, pJson["audioMute"], "qint32", ""); ::SWGSDRangel::setValue(&audio_mute, pJson["audioMute"], "qint32", "");
@ -142,6 +149,9 @@ SWGFreeDVDemodSettings::asJsonObject() {
if(m_volume_isSet){ if(m_volume_isSet){
obj->insert("volume", QJsonValue(volume)); obj->insert("volume", QJsonValue(volume));
} }
if(m_volume_in_isSet){
obj->insert("volumeIn", QJsonValue(volume_in));
}
if(m_span_log2_isSet){ if(m_span_log2_isSet){
obj->insert("spanLog2", QJsonValue(span_log2)); obj->insert("spanLog2", QJsonValue(span_log2));
} }
@ -187,6 +197,16 @@ SWGFreeDVDemodSettings::setVolume(float volume) {
this->m_volume_isSet = true; this->m_volume_isSet = true;
} }
float
SWGFreeDVDemodSettings::getVolumeIn() {
return volume_in;
}
void
SWGFreeDVDemodSettings::setVolumeIn(float volume_in) {
this->volume_in = volume_in;
this->m_volume_in_isSet = true;
}
qint32 qint32
SWGFreeDVDemodSettings::getSpanLog2() { SWGFreeDVDemodSettings::getSpanLog2() {
return span_log2; return span_log2;
@ -264,6 +284,7 @@ SWGFreeDVDemodSettings::isSet(){
do{ do{
if(m_input_frequency_offset_isSet){ isObjectUpdated = true; break;} if(m_input_frequency_offset_isSet){ isObjectUpdated = true; break;}
if(m_volume_isSet){ isObjectUpdated = true; break;} if(m_volume_isSet){ isObjectUpdated = true; break;}
if(m_volume_in_isSet){ isObjectUpdated = true; break;}
if(m_span_log2_isSet){ isObjectUpdated = true; break;} if(m_span_log2_isSet){ isObjectUpdated = true; break;}
if(m_audio_mute_isSet){ isObjectUpdated = true; break;} if(m_audio_mute_isSet){ isObjectUpdated = true; break;}
if(m_agc_isSet){ isObjectUpdated = true; break;} if(m_agc_isSet){ isObjectUpdated = true; break;}

View File

@ -48,6 +48,9 @@ public:
float getVolume(); float getVolume();
void setVolume(float volume); void setVolume(float volume);
float getVolumeIn();
void setVolumeIn(float volume_in);
qint32 getSpanLog2(); qint32 getSpanLog2();
void setSpanLog2(qint32 span_log2); void setSpanLog2(qint32 span_log2);
@ -79,6 +82,9 @@ private:
float volume; float volume;
bool m_volume_isSet; bool m_volume_isSet;
float volume_in;
bool m_volume_in_isSet;
qint32 span_log2; qint32 span_log2;
bool m_span_log2_isSet; bool m_span_log2_isSet;