From 827fc6cf275ea0909aaee1a2cbb6e2c2743f6f2e Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 18 Jul 2019 01:48:07 +0200 Subject: [PATCH] SSB demod: implement compressor based on sndfilter code. Removed previous AGC based compressor --- plugins/channeltx/modssb/ssbmod.cpp | 109 +------- plugins/channeltx/modssb/ssbmod.h | 3 +- plugins/channeltx/modssb/ssbmodgui.cpp | 68 +---- plugins/channeltx/modssb/ssbmodgui.h | 6 - plugins/channeltx/modssb/ssbmodgui.ui | 251 ++---------------- plugins/channeltx/modssb/ssbmodplugin.cpp | 2 +- plugins/channeltx/modssb/ssbmodsettings.cpp | 43 --- plugins/channeltx/modssb/ssbmodsettings.h | 9 - sdrbase/audio/audiocompressorsnd.cpp | 13 +- sdrbase/resources/webapi/doc/html2/index.html | 23 +- .../webapi/doc/swagger/include/SSBMod.yaml | 21 +- .../resources/webapi/doc/swagger/swagger.yaml | 2 +- .../sdrangel/api/swagger/include/SSBMod.yaml | 21 +- swagger/sdrangel/api/swagger/swagger.yaml | 2 +- swagger/sdrangel/code/html2/index.html | 23 +- .../code/qt5/client/SWGAMDemodReport.cpp | 2 +- .../code/qt5/client/SWGAMDemodReport.h | 2 +- .../code/qt5/client/SWGAMDemodSettings.cpp | 2 +- .../code/qt5/client/SWGAMDemodSettings.h | 2 +- .../code/qt5/client/SWGAMModReport.cpp | 2 +- .../sdrangel/code/qt5/client/SWGAMModReport.h | 2 +- .../code/qt5/client/SWGAMModSettings.cpp | 2 +- .../code/qt5/client/SWGAMModSettings.h | 2 +- .../code/qt5/client/SWGATVModReport.cpp | 2 +- .../code/qt5/client/SWGATVModReport.h | 2 +- .../code/qt5/client/SWGATVModSettings.cpp | 2 +- .../code/qt5/client/SWGATVModSettings.h | 2 +- .../code/qt5/client/SWGAirspyHFReport.cpp | 2 +- .../code/qt5/client/SWGAirspyHFReport.h | 2 +- .../code/qt5/client/SWGAirspyHFSettings.cpp | 2 +- .../code/qt5/client/SWGAirspyHFSettings.h | 2 +- .../code/qt5/client/SWGAirspyReport.cpp | 2 +- .../code/qt5/client/SWGAirspyReport.h | 2 +- .../code/qt5/client/SWGAirspySettings.cpp | 2 +- .../code/qt5/client/SWGAirspySettings.h | 2 +- .../sdrangel/code/qt5/client/SWGArgInfo.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGArgInfo.h | 2 +- .../sdrangel/code/qt5/client/SWGArgValue.cpp | 2 +- .../sdrangel/code/qt5/client/SWGArgValue.h | 2 +- .../code/qt5/client/SWGAudioDevices.cpp | 2 +- .../code/qt5/client/SWGAudioDevices.h | 2 +- .../code/qt5/client/SWGAudioInputDevice.cpp | 2 +- .../code/qt5/client/SWGAudioInputDevice.h | 2 +- .../code/qt5/client/SWGAudioOutputDevice.cpp | 2 +- .../code/qt5/client/SWGAudioOutputDevice.h | 2 +- .../code/qt5/client/SWGBFMDemodReport.cpp | 2 +- .../code/qt5/client/SWGBFMDemodReport.h | 2 +- .../code/qt5/client/SWGBFMDemodSettings.cpp | 2 +- .../code/qt5/client/SWGBFMDemodSettings.h | 2 +- .../sdrangel/code/qt5/client/SWGBandwidth.cpp | 2 +- .../sdrangel/code/qt5/client/SWGBandwidth.h | 2 +- .../qt5/client/SWGBladeRF1InputSettings.cpp | 2 +- .../qt5/client/SWGBladeRF1InputSettings.h | 2 +- .../qt5/client/SWGBladeRF1OutputSettings.cpp | 2 +- .../qt5/client/SWGBladeRF1OutputSettings.h | 2 +- .../qt5/client/SWGBladeRF2InputReport.cpp | 2 +- .../code/qt5/client/SWGBladeRF2InputReport.h | 2 +- .../qt5/client/SWGBladeRF2InputSettings.cpp | 2 +- .../qt5/client/SWGBladeRF2InputSettings.h | 2 +- .../qt5/client/SWGBladeRF2OutputReport.cpp | 2 +- .../code/qt5/client/SWGBladeRF2OutputReport.h | 2 +- .../qt5/client/SWGBladeRF2OutputSettings.cpp | 2 +- .../qt5/client/SWGBladeRF2OutputSettings.h | 2 +- .../code/qt5/client/SWGCWKeyerSettings.cpp | 2 +- .../code/qt5/client/SWGCWKeyerSettings.h | 2 +- .../sdrangel/code/qt5/client/SWGChannel.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGChannel.h | 2 +- .../code/qt5/client/SWGChannelListItem.cpp | 2 +- .../code/qt5/client/SWGChannelListItem.h | 2 +- .../code/qt5/client/SWGChannelReport.cpp | 2 +- .../code/qt5/client/SWGChannelReport.h | 2 +- .../code/qt5/client/SWGChannelSettings.cpp | 2 +- .../code/qt5/client/SWGChannelSettings.h | 2 +- .../code/qt5/client/SWGChannelsDetail.cpp | 2 +- .../code/qt5/client/SWGChannelsDetail.h | 2 +- .../sdrangel/code/qt5/client/SWGComplex.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGComplex.h | 2 +- .../code/qt5/client/SWGDSDDemodReport.cpp | 2 +- .../code/qt5/client/SWGDSDDemodReport.h | 2 +- .../code/qt5/client/SWGDSDDemodSettings.cpp | 2 +- .../code/qt5/client/SWGDSDDemodSettings.h | 2 +- .../code/qt5/client/SWGDVSeralDevices.cpp | 2 +- .../code/qt5/client/SWGDVSeralDevices.h | 2 +- .../code/qt5/client/SWGDVSerialDevice.cpp | 2 +- .../code/qt5/client/SWGDVSerialDevice.h | 2 +- .../code/qt5/client/SWGDeviceListItem.cpp | 2 +- .../code/qt5/client/SWGDeviceListItem.h | 2 +- .../code/qt5/client/SWGDeviceReport.cpp | 2 +- .../code/qt5/client/SWGDeviceReport.h | 2 +- .../sdrangel/code/qt5/client/SWGDeviceSet.cpp | 2 +- .../sdrangel/code/qt5/client/SWGDeviceSet.h | 2 +- .../code/qt5/client/SWGDeviceSetApi.cpp | 2 +- .../code/qt5/client/SWGDeviceSetApi.h | 2 +- .../code/qt5/client/SWGDeviceSetList.cpp | 2 +- .../code/qt5/client/SWGDeviceSetList.h | 2 +- .../code/qt5/client/SWGDeviceSettings.cpp | 2 +- .../code/qt5/client/SWGDeviceSettings.h | 2 +- .../code/qt5/client/SWGDeviceState.cpp | 2 +- .../sdrangel/code/qt5/client/SWGDeviceState.h | 2 +- .../code/qt5/client/SWGErrorResponse.cpp | 2 +- .../code/qt5/client/SWGErrorResponse.h | 2 +- .../code/qt5/client/SWGFCDProPlusSettings.cpp | 2 +- .../code/qt5/client/SWGFCDProPlusSettings.h | 2 +- .../code/qt5/client/SWGFCDProSettings.cpp | 2 +- .../code/qt5/client/SWGFCDProSettings.h | 2 +- .../code/qt5/client/SWGFileInputReport.cpp | 2 +- .../code/qt5/client/SWGFileInputReport.h | 2 +- .../code/qt5/client/SWGFileInputSettings.cpp | 2 +- .../code/qt5/client/SWGFileInputSettings.h | 2 +- .../code/qt5/client/SWGFileSourceReport.cpp | 2 +- .../code/qt5/client/SWGFileSourceReport.h | 2 +- .../code/qt5/client/SWGFileSourceSettings.cpp | 2 +- .../code/qt5/client/SWGFileSourceSettings.h | 2 +- .../code/qt5/client/SWGFreeDVDemodReport.cpp | 2 +- .../code/qt5/client/SWGFreeDVDemodReport.h | 2 +- .../qt5/client/SWGFreeDVDemodSettings.cpp | 2 +- .../code/qt5/client/SWGFreeDVDemodSettings.h | 2 +- .../code/qt5/client/SWGFreeDVModReport.cpp | 2 +- .../code/qt5/client/SWGFreeDVModReport.h | 2 +- .../code/qt5/client/SWGFreeDVModSettings.cpp | 2 +- .../code/qt5/client/SWGFreeDVModSettings.h | 2 +- .../code/qt5/client/SWGFreqTrackerReport.cpp | 2 +- .../code/qt5/client/SWGFreqTrackerReport.h | 2 +- .../qt5/client/SWGFreqTrackerSettings.cpp | 2 +- .../code/qt5/client/SWGFreqTrackerSettings.h | 2 +- .../sdrangel/code/qt5/client/SWGFrequency.cpp | 2 +- .../sdrangel/code/qt5/client/SWGFrequency.h | 2 +- .../code/qt5/client/SWGFrequencyBand.cpp | 2 +- .../code/qt5/client/SWGFrequencyBand.h | 2 +- .../code/qt5/client/SWGFrequencyRange.cpp | 2 +- .../code/qt5/client/SWGFrequencyRange.h | 2 +- swagger/sdrangel/code/qt5/client/SWGGain.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGGain.h | 2 +- .../qt5/client/SWGHackRFInputSettings.cpp | 2 +- .../code/qt5/client/SWGHackRFInputSettings.h | 2 +- .../qt5/client/SWGHackRFOutputSettings.cpp | 2 +- .../code/qt5/client/SWGHackRFOutputSettings.h | 2 +- .../sdrangel/code/qt5/client/SWGHelpers.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGHelpers.h | 2 +- .../code/qt5/client/SWGHttpRequest.cpp | 2 +- .../sdrangel/code/qt5/client/SWGHttpRequest.h | 2 +- .../code/qt5/client/SWGInstanceApi.cpp | 2 +- .../sdrangel/code/qt5/client/SWGInstanceApi.h | 2 +- .../client/SWGInstanceChannelsResponse.cpp | 2 +- .../qt5/client/SWGInstanceChannelsResponse.h | 2 +- .../qt5/client/SWGInstanceDevicesResponse.cpp | 2 +- .../qt5/client/SWGInstanceDevicesResponse.h | 2 +- .../qt5/client/SWGInstanceSummaryResponse.cpp | 2 +- .../qt5/client/SWGInstanceSummaryResponse.h | 2 +- .../code/qt5/client/SWGKiwiSDRReport.cpp | 2 +- .../code/qt5/client/SWGKiwiSDRReport.h | 2 +- .../code/qt5/client/SWGKiwiSDRSettings.cpp | 2 +- .../code/qt5/client/SWGKiwiSDRSettings.h | 2 +- .../code/qt5/client/SWGLimeSdrInputReport.cpp | 2 +- .../code/qt5/client/SWGLimeSdrInputReport.h | 2 +- .../qt5/client/SWGLimeSdrInputSettings.cpp | 2 +- .../code/qt5/client/SWGLimeSdrInputSettings.h | 2 +- .../qt5/client/SWGLimeSdrOutputReport.cpp | 2 +- .../code/qt5/client/SWGLimeSdrOutputReport.h | 2 +- .../qt5/client/SWGLimeSdrOutputSettings.cpp | 2 +- .../qt5/client/SWGLimeSdrOutputSettings.h | 2 +- .../code/qt5/client/SWGLocalInputReport.cpp | 2 +- .../code/qt5/client/SWGLocalInputReport.h | 2 +- .../code/qt5/client/SWGLocalInputSettings.cpp | 2 +- .../code/qt5/client/SWGLocalInputSettings.h | 2 +- .../code/qt5/client/SWGLocalOutputReport.cpp | 2 +- .../code/qt5/client/SWGLocalOutputReport.h | 2 +- .../qt5/client/SWGLocalOutputSettings.cpp | 2 +- .../code/qt5/client/SWGLocalOutputSettings.h | 2 +- .../code/qt5/client/SWGLocalSinkSettings.cpp | 2 +- .../code/qt5/client/SWGLocalSinkSettings.h | 2 +- .../qt5/client/SWGLocalSourceSettings.cpp | 2 +- .../code/qt5/client/SWGLocalSourceSettings.h | 2 +- .../qt5/client/SWGLocationInformation.cpp | 2 +- .../code/qt5/client/SWGLocationInformation.h | 2 +- .../code/qt5/client/SWGLoggingInfo.cpp | 2 +- .../sdrangel/code/qt5/client/SWGLoggingInfo.h | 2 +- .../code/qt5/client/SWGModelFactory.h | 2 +- .../code/qt5/client/SWGNFMDemodReport.cpp | 2 +- .../code/qt5/client/SWGNFMDemodReport.h | 2 +- .../code/qt5/client/SWGNFMDemodSettings.cpp | 2 +- .../code/qt5/client/SWGNFMDemodSettings.h | 2 +- .../code/qt5/client/SWGNFMModReport.cpp | 2 +- .../code/qt5/client/SWGNFMModReport.h | 2 +- .../code/qt5/client/SWGNFMModSettings.cpp | 2 +- .../code/qt5/client/SWGNFMModSettings.h | 2 +- .../sdrangel/code/qt5/client/SWGNamedEnum.cpp | 2 +- .../sdrangel/code/qt5/client/SWGNamedEnum.h | 2 +- swagger/sdrangel/code/qt5/client/SWGObject.h | 2 +- .../code/qt5/client/SWGPerseusReport.cpp | 2 +- .../code/qt5/client/SWGPerseusReport.h | 2 +- .../code/qt5/client/SWGPerseusSettings.cpp | 2 +- .../code/qt5/client/SWGPerseusSettings.h | 2 +- .../qt5/client/SWGPlutoSdrInputReport.cpp | 2 +- .../code/qt5/client/SWGPlutoSdrInputReport.h | 2 +- .../qt5/client/SWGPlutoSdrInputSettings.cpp | 2 +- .../qt5/client/SWGPlutoSdrInputSettings.h | 2 +- .../qt5/client/SWGPlutoSdrOutputReport.cpp | 2 +- .../code/qt5/client/SWGPlutoSdrOutputReport.h | 2 +- .../qt5/client/SWGPlutoSdrOutputSettings.cpp | 2 +- .../qt5/client/SWGPlutoSdrOutputSettings.h | 2 +- .../code/qt5/client/SWGPresetExport.cpp | 2 +- .../code/qt5/client/SWGPresetExport.h | 2 +- .../code/qt5/client/SWGPresetGroup.cpp | 2 +- .../sdrangel/code/qt5/client/SWGPresetGroup.h | 2 +- .../code/qt5/client/SWGPresetIdentifier.cpp | 2 +- .../code/qt5/client/SWGPresetIdentifier.h | 2 +- .../code/qt5/client/SWGPresetImport.cpp | 2 +- .../code/qt5/client/SWGPresetImport.h | 2 +- .../code/qt5/client/SWGPresetItem.cpp | 2 +- .../sdrangel/code/qt5/client/SWGPresetItem.h | 2 +- .../code/qt5/client/SWGPresetTransfer.cpp | 2 +- .../code/qt5/client/SWGPresetTransfer.h | 2 +- .../sdrangel/code/qt5/client/SWGPresets.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGPresets.h | 2 +- .../sdrangel/code/qt5/client/SWGRDSReport.cpp | 2 +- .../sdrangel/code/qt5/client/SWGRDSReport.h | 2 +- .../client/SWGRDSReport_altFrequencies.cpp | 2 +- .../qt5/client/SWGRDSReport_altFrequencies.h | 2 +- swagger/sdrangel/code/qt5/client/SWGRange.cpp | 2 +- swagger/sdrangel/code/qt5/client/SWGRange.h | 2 +- .../code/qt5/client/SWGRangeFloat.cpp | 2 +- .../sdrangel/code/qt5/client/SWGRangeFloat.h | 2 +- .../code/qt5/client/SWGRemoteInputReport.cpp | 2 +- .../code/qt5/client/SWGRemoteInputReport.h | 2 +- .../qt5/client/SWGRemoteInputSettings.cpp | 2 +- .../code/qt5/client/SWGRemoteInputSettings.h | 2 +- .../code/qt5/client/SWGRemoteOutputReport.cpp | 2 +- .../code/qt5/client/SWGRemoteOutputReport.h | 2 +- .../qt5/client/SWGRemoteOutputSettings.cpp | 2 +- .../code/qt5/client/SWGRemoteOutputSettings.h | 2 +- .../code/qt5/client/SWGRemoteSinkSettings.cpp | 2 +- .../code/qt5/client/SWGRemoteSinkSettings.h | 2 +- .../code/qt5/client/SWGRemoteSourceReport.cpp | 2 +- .../code/qt5/client/SWGRemoteSourceReport.h | 2 +- .../qt5/client/SWGRemoteSourceSettings.cpp | 2 +- .../code/qt5/client/SWGRemoteSourceSettings.h | 2 +- .../code/qt5/client/SWGRtlSdrReport.cpp | 2 +- .../code/qt5/client/SWGRtlSdrReport.h | 2 +- .../code/qt5/client/SWGRtlSdrSettings.cpp | 2 +- .../code/qt5/client/SWGRtlSdrSettings.h | 2 +- .../code/qt5/client/SWGSDRPlayReport.cpp | 2 +- .../code/qt5/client/SWGSDRPlayReport.h | 2 +- .../code/qt5/client/SWGSDRPlaySettings.cpp | 2 +- .../code/qt5/client/SWGSDRPlaySettings.h | 2 +- .../code/qt5/client/SWGSSBDemodReport.cpp | 2 +- .../code/qt5/client/SWGSSBDemodReport.h | 2 +- .../code/qt5/client/SWGSSBDemodSettings.cpp | 2 +- .../code/qt5/client/SWGSSBDemodSettings.h | 2 +- .../code/qt5/client/SWGSSBModReport.cpp | 2 +- .../code/qt5/client/SWGSSBModReport.h | 2 +- .../code/qt5/client/SWGSSBModSettings.cpp | 128 +-------- .../code/qt5/client/SWGSSBModSettings.h | 38 +-- .../code/qt5/client/SWGSampleRate.cpp | 2 +- .../sdrangel/code/qt5/client/SWGSampleRate.h | 2 +- .../code/qt5/client/SWGSamplingDevice.cpp | 2 +- .../code/qt5/client/SWGSamplingDevice.h | 2 +- .../client/SWGSoapySDRFrequencySetting.cpp | 2 +- .../qt5/client/SWGSoapySDRFrequencySetting.h | 2 +- .../qt5/client/SWGSoapySDRGainSetting.cpp | 2 +- .../code/qt5/client/SWGSoapySDRGainSetting.h | 2 +- .../qt5/client/SWGSoapySDRInputSettings.cpp | 2 +- .../qt5/client/SWGSoapySDRInputSettings.h | 2 +- .../qt5/client/SWGSoapySDROutputSettings.cpp | 2 +- .../qt5/client/SWGSoapySDROutputSettings.h | 2 +- .../code/qt5/client/SWGSoapySDRReport.cpp | 2 +- .../code/qt5/client/SWGSoapySDRReport.h | 2 +- .../code/qt5/client/SWGSuccessResponse.cpp | 2 +- .../code/qt5/client/SWGSuccessResponse.h | 2 +- .../code/qt5/client/SWGTestMISettings.cpp | 2 +- .../code/qt5/client/SWGTestMISettings.h | 2 +- .../qt5/client/SWGTestMiStreamSettings.cpp | 2 +- .../code/qt5/client/SWGTestMiStreamSettings.h | 2 +- .../code/qt5/client/SWGTestSourceSettings.cpp | 2 +- .../code/qt5/client/SWGTestSourceSettings.h | 2 +- .../code/qt5/client/SWGUDPSinkReport.cpp | 2 +- .../code/qt5/client/SWGUDPSinkReport.h | 2 +- .../code/qt5/client/SWGUDPSinkSettings.cpp | 2 +- .../code/qt5/client/SWGUDPSinkSettings.h | 2 +- .../code/qt5/client/SWGUDPSourceReport.cpp | 2 +- .../code/qt5/client/SWGUDPSourceReport.h | 2 +- .../code/qt5/client/SWGUDPSourceSettings.cpp | 2 +- .../code/qt5/client/SWGUDPSourceSettings.h | 2 +- .../code/qt5/client/SWGWFMDemodReport.cpp | 2 +- .../code/qt5/client/SWGWFMDemodReport.h | 2 +- .../code/qt5/client/SWGWFMDemodSettings.cpp | 2 +- .../code/qt5/client/SWGWFMDemodSettings.h | 2 +- .../code/qt5/client/SWGWFMModReport.cpp | 2 +- .../code/qt5/client/SWGWFMModReport.h | 2 +- .../code/qt5/client/SWGWFMModSettings.cpp | 2 +- .../code/qt5/client/SWGWFMModSettings.h | 2 +- .../code/qt5/client/SWGXtrxInputReport.cpp | 2 +- .../code/qt5/client/SWGXtrxInputReport.h | 2 +- .../code/qt5/client/SWGXtrxInputSettings.cpp | 2 +- .../code/qt5/client/SWGXtrxInputSettings.h | 2 +- .../code/qt5/client/SWGXtrxOutputReport.cpp | 2 +- .../code/qt5/client/SWGXtrxOutputReport.h | 2 +- .../code/qt5/client/SWGXtrxOutputSettings.cpp | 2 +- .../code/qt5/client/SWGXtrxOutputSettings.h | 2 +- 299 files changed, 349 insertions(+), 977 deletions(-) diff --git a/plugins/channeltx/modssb/ssbmod.cpp b/plugins/channeltx/modssb/ssbmod.cpp index 5a231091a..757799a4c 100644 --- a/plugins/channeltx/modssb/ssbmod.cpp +++ b/plugins/channeltx/modssb/ssbmod.cpp @@ -73,7 +73,6 @@ SSBMod::SSBMod(DeviceAPI *deviceAPI) : m_levelCalcCount(0), m_peakLevel(0.0f), m_levelSum(0.0f), - m_inAGC(9600, 0.2, 1e-4), m_agcStepLength(2400) { setObjectName(m_channelId); @@ -107,10 +106,16 @@ SSBMod::SSBMod(DeviceAPI *deviceAPI) : m_cwKeyer.setWPM(13); m_cwKeyer.setMode(CWKeyerSettings::CWNone); - m_inAGC.setGate(m_settings.m_agcThresholdGate); - m_inAGC.setStepDownDelay(m_settings.m_agcThresholdDelay); - m_inAGC.setClamping(true); - m_inAGC.setHardLimiting(true); + + m_audioCompressor.initSimple( + 48000, // fixed 48 kS/s sample rate for audio + 50, // pregain (dB) + -30, // threshold (dB) + 20, // knee (dB) + 12, // ratio (dB) + 0.003, // attack (s) + 0.25 // release (s) + ); applyChannelSettings(m_basebandSampleRate, m_outputSampleRate, m_inputFrequencyOffset, true); applySettings(m_settings, true); @@ -282,9 +287,9 @@ void SSBMod::pullAF(Complex& sample) if (m_settings.m_agc) { + real = m_audioCompressor.compress(real); ci.real(real); ci.imag(0.0f); - m_inAGC.feed(ci); ci *= m_settings.m_volumeFactor; } else @@ -320,8 +325,8 @@ void SSBMod::pullAF(Complex& sample) if (m_settings.m_agc) { ci.real(((m_audioBuffer[m_audioBufferFill].l + m_audioBuffer[m_audioBufferFill].r) / 65536.0f)); + ci.real(m_audioCompressor.compress(ci.real())); ci.imag(0.0f); - m_inAGC.feed(ci); ci *= m_settings.m_volumeFactor; } else @@ -706,8 +711,6 @@ void SSBMod::applyAudioSampleRate(int sampleRate) m_toneNco.setFreq(m_settings.m_toneFrequency, sampleRate); m_cwKeyer.setSampleRate(sampleRate); - m_agcStepLength = std::min(sampleRate/20, m_settings.m_agcTime/2); // 50 ms or half the AGC length whichever is smaller - m_settingsMutex.unlock(); m_audioSampleRate = sampleRate; @@ -795,24 +798,6 @@ void SSBMod::applySettings(const SSBModSettings& settings, bool force) if ((settings.m_agc != m_settings.m_agc) || force) { reverseAPIKeys.append("agc"); } - if ((settings.m_agcOrder != m_settings.m_agcOrder) || force) { - reverseAPIKeys.append("agcOrder"); - } - if ((settings.m_agcTime != m_settings.m_agcTime) || force) { - reverseAPIKeys.append("agcTime"); - } - if ((settings.m_agcThresholdEnable != m_settings.m_agcThresholdEnable) || force) { - reverseAPIKeys.append("agcThresholdEnable"); - } - if ((settings.m_agcThreshold != m_settings.m_agcThreshold) || force) { - reverseAPIKeys.append("agcThreshold"); - } - if ((settings.m_agcThresholdGate != m_settings.m_agcThresholdGate) || force) { - reverseAPIKeys.append("agcThresholdGate"); - } - if ((settings.m_agcThresholdDelay != m_settings.m_agcThresholdDelay) || force) { - reverseAPIKeys.append("agcThresholdDelay"); - } if ((settings.m_rgbColor != m_settings.m_rgbColor) || force) { reverseAPIKeys.append("rgbColor"); } @@ -872,34 +857,6 @@ void SSBMod::applySettings(const SSBModSettings& settings, bool force) } } - if ((settings.m_agcTime != m_settings.m_agcTime) || - (settings.m_agcOrder != m_settings.m_agcOrder) || force) - { - m_settingsMutex.lock(); - m_inAGC.resize(settings.m_agcTime, m_agcStepLength, settings.m_agcOrder); - m_settingsMutex.unlock(); - } - - if ((settings.m_agcThresholdEnable != m_settings.m_agcThresholdEnable) || force) - { - m_inAGC.setThresholdEnable(settings.m_agcThresholdEnable); - } - - if ((settings.m_agcThreshold != m_settings.m_agcThreshold) || force) - { - m_inAGC.setThreshold(settings.m_agcThreshold); - } - - if ((settings.m_agcThresholdGate != m_settings.m_agcThresholdGate) || force) - { - m_inAGC.setGate(settings.m_agcThresholdGate); - } - - if ((settings.m_agcThresholdDelay != m_settings.m_agcThresholdDelay) || force) - { - m_inAGC.setStepDownDelay(settings.m_agcThresholdDelay); - } - if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) { AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager(); @@ -1012,24 +969,6 @@ int SSBMod::webapiSettingsPutPatch( if (channelSettingsKeys.contains("agc")) { settings.m_agc = response.getSsbModSettings()->getAgc() != 0; } - if (channelSettingsKeys.contains("agcOrder")) { - settings.m_agcOrder = response.getSsbModSettings()->getAgcOrder(); - } - if (channelSettingsKeys.contains("agcTime")) { - settings.m_agcTime = response.getSsbModSettings()->getAgcTime(); - } - if (channelSettingsKeys.contains("agcThresholdEnable")) { - settings.m_agcThresholdEnable = response.getSsbModSettings()->getAgcThresholdEnable() != 0; - } - if (channelSettingsKeys.contains("agcThreshold")) { - settings.m_agcThreshold = response.getSsbModSettings()->getAgcThreshold(); - } - if (channelSettingsKeys.contains("agcThresholdGate")) { - settings.m_agcThresholdGate = response.getSsbModSettings()->getAgcThresholdGate(); - } - if (channelSettingsKeys.contains("agcThresholdDelay")) { - settings.m_agcThresholdDelay = response.getSsbModSettings()->getAgcThresholdDelay(); - } if (channelSettingsKeys.contains("rgbColor")) { settings.m_rgbColor = response.getSsbModSettings()->getRgbColor(); } @@ -1139,12 +1078,6 @@ void SSBMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon response.getSsbModSettings()->setAudioMute(settings.m_audioMute ? 1 : 0); response.getSsbModSettings()->setPlayLoop(settings.m_playLoop ? 1 : 0); response.getSsbModSettings()->setAgc(settings.m_agc ? 1 : 0); - response.getSsbModSettings()->setAgcOrder(settings.m_agcOrder); - response.getSsbModSettings()->setAgcTime(settings.m_agcTime); - response.getSsbModSettings()->setAgcThresholdEnable(settings.m_agcThresholdEnable ? 1 : 0); - response.getSsbModSettings()->setAgcThreshold(settings.m_agcThreshold); - response.getSsbModSettings()->setAgcThresholdGate(settings.m_agcThresholdGate); - response.getSsbModSettings()->setAgcThresholdDelay(settings.m_agcThresholdDelay); response.getSsbModSettings()->setRgbColor(settings.m_rgbColor); if (response.getSsbModSettings()->getTitle()) { @@ -1250,24 +1183,6 @@ void SSBMod::webapiReverseSendSettings(QList& channelSettingsKeys, cons if (channelSettingsKeys.contains("agc") || force) { swgSSBModSettings->setAgc(settings.m_agc ? 1 : 0); } - if (channelSettingsKeys.contains("agcOrder") || force) { - swgSSBModSettings->setAgcOrder(settings.m_agcOrder); - } - if (channelSettingsKeys.contains("agcTime") || force) { - swgSSBModSettings->setAgcTime(settings.m_agcTime); - } - if (channelSettingsKeys.contains("agcThresholdEnable") || force) { - swgSSBModSettings->setAgcThresholdEnable(settings.m_agcThresholdEnable ? 1 : 0); - } - if (channelSettingsKeys.contains("agcThreshold") || force) { - swgSSBModSettings->setAgcThreshold(settings.m_agcThreshold); - } - if (channelSettingsKeys.contains("agcThresholdGate") || force) { - swgSSBModSettings->setAgcThresholdGate(settings.m_agcThresholdGate); - } - if (channelSettingsKeys.contains("agcThresholdDelay") || force) { - swgSSBModSettings->setAgcThresholdDelay(settings.m_agcThresholdDelay); - } if (channelSettingsKeys.contains("rgbColor") || force) { swgSSBModSettings->setRgbColor(settings.m_rgbColor); } diff --git a/plugins/channeltx/modssb/ssbmod.h b/plugins/channeltx/modssb/ssbmod.h index 5dd12b494..dbae54b1e 100644 --- a/plugins/channeltx/modssb/ssbmod.h +++ b/plugins/channeltx/modssb/ssbmod.h @@ -35,6 +35,7 @@ #include "dsp/fftfilt.h" #include "dsp/cwkeyer.h" #include "audio/audiofifo.h" +#include "audio/audiocompressorsnd.h" #include "util/message.h" #include "ssbmodsettings.h" @@ -321,7 +322,7 @@ private: Real m_levelSum; CWKeyer m_cwKeyer; - MagAGC m_inAGC; + AudioCompressorSnd m_audioCompressor; int m_agcStepLength; QNetworkAccessManager *m_networkManager; diff --git a/plugins/channeltx/modssb/ssbmodgui.cpp b/plugins/channeltx/modssb/ssbmodgui.cpp index a709b02e4..47f21e8aa 100644 --- a/plugins/channeltx/modssb/ssbmodgui.cpp +++ b/plugins/channeltx/modssb/ssbmodgui.cpp @@ -297,43 +297,6 @@ void SSBModGUI::on_agc_toggled(bool checked) applySettings(); } -void SSBModGUI::on_agcOrder_valueChanged(int value){ - QString s = QString::number(value / 100.0, 'f', 2); - ui->agcOrderText->setText(s); - m_settings.m_agcOrder = value / 100.0; - applySettings(); -} - -void SSBModGUI::on_agcTime_valueChanged(int value){ - QString s = QString::number(SSBModSettings::getAGCTimeConstant(value), 'f', 0); - ui->agcTimeText->setText(s); - m_settings.m_agcTime = SSBModSettings::getAGCTimeConstant(value) * 48; - applySettings(); -} - -void SSBModGUI::on_agcThreshold_valueChanged(int value) -{ - m_settings.m_agcThreshold = value; // dB - displayAGCPowerThreshold(); - applySettings(); -} - -void SSBModGUI::on_agcThresholdGate_valueChanged(int value) -{ - QString s = QString::number(value, 'f', 0); - ui->agcThresholdGateText->setText(s); - m_settings.m_agcThresholdGate = value * 48; - applySettings(); -} - -void SSBModGUI::on_agcThresholdDelay_valueChanged(int value) -{ - QString s = QString::number(value * 10, 'f', 0); - ui->agcThresholdDelayText->setText(s); - m_settings.m_agcThresholdDelay = value * 480; - applySettings(); -} - void SSBModGUI::on_navTimeSlider_valueChanged(int value) { if (m_enableNavTime && ((value >= 0) && (value <= 100))) @@ -658,20 +621,6 @@ void SSBModGUI::displaySettings() blockApplySettings(true); - QString s = QString::number(m_settings.m_agcTime / 48, 'f', 0); - ui->agcTimeText->setText(s); - ui->agcTime->setValue(SSBModSettings::getAGCTimeConstantIndex(m_settings.m_agcTime / 48)); - displayAGCPowerThreshold(); - s = QString::number(m_settings.m_agcThresholdGate / 48, 'f', 0); - ui->agcThresholdGateText->setText(s); - ui->agcThresholdGate->setValue(m_settings.m_agcThresholdGate / 48); - s = QString::number(m_settings.m_agcThresholdDelay / 48, 'f', 0); - ui->agcThresholdDelayText->setText(s); - ui->agcThresholdDelay->setValue(m_settings.m_agcThresholdDelay / 480); - s = QString::number(m_settings.m_agcOrder, 'f', 2); - ui->agcOrderText->setText(s); - ui->agcOrder->setValue(roundf(m_settings.m_agcOrder * 100.0)); - ui->agc->setChecked(m_settings.m_agc); ui->audioBinaural->setChecked(m_settings.m_audioBinaural); ui->audioFlipChannels->setChecked(m_settings.m_audioFlipChannels); @@ -687,7 +636,7 @@ void SSBModGUI::displaySettings() ui->spanLog2->setValue(5 - m_settings.m_spanLog2); ui->BW->setValue(roundf(m_settings.m_bandwidth/100.0)); - s = QString::number(m_settings.m_bandwidth/1000.0, 'f', 1); + QString s = QString::number(m_settings.m_bandwidth/1000.0, 'f', 1); if (m_settings.m_dsb) { @@ -732,21 +681,6 @@ void SSBModGUI::displaySettings() blockApplySettings(false); } -void SSBModGUI::displayAGCPowerThreshold() -{ - if (m_settings.m_agcThreshold == -99) - { - ui->agcThresholdText->setText("---"); - } - else - { - QString s = QString::number(m_settings.m_agcThreshold, 'f', 0); - ui->agcThresholdText->setText(s); - } - - ui->agcThreshold->setValue(m_settings.m_agcThreshold); -} - void SSBModGUI::leaveEvent(QEvent*) { m_channelMarker.setHighlighted(false); diff --git a/plugins/channeltx/modssb/ssbmodgui.h b/plugins/channeltx/modssb/ssbmodgui.h index 6d770708e..e88c3b44e 100644 --- a/plugins/channeltx/modssb/ssbmodgui.h +++ b/plugins/channeltx/modssb/ssbmodgui.h @@ -90,7 +90,6 @@ private: void applySettings(bool force = false); void applyBandwidths(int spanLog2, bool force = false); void displaySettings(); - void displayAGCPowerThreshold(); void updateWithStreamData(); void updateWithStreamTime(); void channelMarkerUpdate(); @@ -114,11 +113,6 @@ private slots: void on_toneFrequency_valueChanged(int value); void on_mic_toggled(bool checked); void on_agc_toggled(bool checked); - void on_agcOrder_valueChanged(int value); - void on_agcTime_valueChanged(int value); - void on_agcThreshold_valueChanged(int value); - void on_agcThresholdGate_valueChanged(int value); - void on_agcThresholdDelay_valueChanged(int value); void on_play_toggled(bool checked); void on_playLoop_toggled(bool checked); void on_morseKeyer_toggled(bool checked); diff --git a/plugins/channeltx/modssb/ssbmodgui.ui b/plugins/channeltx/modssb/ssbmodgui.ui index b5d2a6112..89c01451a 100644 --- a/plugins/channeltx/modssb/ssbmodgui.ui +++ b/plugins/channeltx/modssb/ssbmodgui.ui @@ -53,7 +53,16 @@ 3 - + + 2 + + + 2 + + + 2 + + 2 @@ -709,7 +718,14 @@ - + + + Qt::Horizontal + + + + + @@ -723,226 +739,6 @@ - - - - - 24 - 24 - - - - AGC volume order in fraction of maximum amplitude - - - 100 - - - 1 - - - 20 - - - - - - - AGC volume order in fraction of maximum amplitude - - - 0.00 - - - - - - - - 24 - 24 - - - - Compressor time constant (attack) in ms - - - 0 - - - 9 - - - 1 - - - 7 - - - - - - - - 25 - 0 - - - - Compressor time constant in ms - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 24 - 24 - - - - Audio squelch threshold (db power) - - - -99 - - - 0 - - - 1 - - - -40 - - - - - - - - 14 - 0 - - - - Audio squelch threshold (dB power) - - - -00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 24 - 24 - - - - Audio squelch gate in ms - - - 1 - - - 4 - - - - - - - - 18 - 0 - - - - Audio squelch gate in ms - - - 00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 24 - 24 - - - - Audio squelch delay (release) in ms - - - 1 - - - 5 - - - - - - - - 25 - 0 - - - - Audio squelch delay in ms - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - - @@ -1245,7 +1041,16 @@ 2 - + + 3 + + + 3 + + + 3 + + 3 diff --git a/plugins/channeltx/modssb/ssbmodplugin.cpp b/plugins/channeltx/modssb/ssbmodplugin.cpp index c877e5423..951ab7952 100644 --- a/plugins/channeltx/modssb/ssbmodplugin.cpp +++ b/plugins/channeltx/modssb/ssbmodplugin.cpp @@ -26,7 +26,7 @@ const PluginDescriptor SSBModPlugin::m_pluginDescriptor = { QString("SSB Modulator"), - QString("4.7.1"), + QString("4.11.1"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/channeltx/modssb/ssbmodsettings.cpp b/plugins/channeltx/modssb/ssbmodsettings.cpp index e49405c96..c39ebdd1f 100644 --- a/plugins/channeltx/modssb/ssbmodsettings.cpp +++ b/plugins/channeltx/modssb/ssbmodsettings.cpp @@ -59,12 +59,6 @@ void SSBModSettings::resetToDefaults() m_audioMute = false; m_playLoop = false; m_agc = false; - m_agcOrder = 0.2; - m_agcTime = 9600; - m_agcThresholdEnable = true; - m_agcThreshold = -40; // dB - m_agcThresholdGate = 192; - m_agcThresholdDelay = 2400; m_rgbColor = QColor(0, 255, 0).rgb(); m_title = "SSB Modulator"; m_modAFInput = SSBModInputAF::SSBModInputNone; @@ -100,11 +94,6 @@ QByteArray SSBModSettings::serialize() const s.writeBool(10, m_audioFlipChannels); s.writeBool(11, m_dsb); s.writeBool(12, m_agc); - s.writeS32(13, getAGCTimeConstantIndex(m_agcTime/48)); - s.writeS32(14, m_agcThreshold); // dB - s.writeS32(15, m_agcThresholdGate / 48); - s.writeS32(16, m_agcThresholdDelay / 48); - s.writeS32(17, roundf(m_agcOrder * 100.0)); if (m_channelMarker) { s.writeBlob(18, m_channelMarker->serialize()); @@ -169,14 +158,6 @@ bool SSBModSettings::deserialize(const QByteArray& data) d.readBool(11, &m_dsb, false); d.readBool(12, &m_agc, false); d.readS32(13, &tmp, 7); - m_agcTime = getAGCTimeConstant(tmp) * 48; - d.readS32(14, &m_agcThreshold, -40); - d.readS32(15, &tmp, 4); - m_agcThresholdGate = tmp * 48; - d.readS32(16, &tmp, 5); - m_agcThresholdDelay = tmp * 48; - d.readS32(17, &tmp, 20); - m_agcOrder = tmp / 100.0; if (m_channelMarker) { d.readBlob(18, &bytetmp); @@ -216,27 +197,3 @@ bool SSBModSettings::deserialize(const QByteArray& data) return false; } } - -int SSBModSettings::getAGCTimeConstant(int index) -{ - if (index < 0) { - return m_agcTimeConstant[0]; - } else if (index < m_nbAGCTimeConstants) { - return m_agcTimeConstant[index]; - } else { - return m_agcTimeConstant[m_nbAGCTimeConstants-1]; - } -} - -int SSBModSettings::getAGCTimeConstantIndex(int agcTimeConstant) -{ - for (int i = 0; i < m_nbAGCTimeConstants; i++) - { - if (agcTimeConstant <= m_agcTimeConstant[i]) - { - return i; - } - } - - return m_nbAGCTimeConstants-1; -} diff --git a/plugins/channeltx/modssb/ssbmodsettings.h b/plugins/channeltx/modssb/ssbmodsettings.h index c00ff2e10..f8e98dc39 100644 --- a/plugins/channeltx/modssb/ssbmodsettings.h +++ b/plugins/channeltx/modssb/ssbmodsettings.h @@ -51,12 +51,6 @@ struct SSBModSettings bool m_audioMute; bool m_playLoop; bool m_agc; - float m_agcOrder; - int m_agcTime; - bool m_agcThresholdEnable; - int m_agcThreshold; - int m_agcThresholdGate; - int m_agcThresholdDelay; quint32 m_rgbColor; QString m_title; @@ -80,9 +74,6 @@ struct SSBModSettings void setCWKeyerGUI(Serializable *cwKeyerGUI) { m_cwKeyerGUI = cwKeyerGUI; } QByteArray serialize() const; bool deserialize(const QByteArray& data); - - static int getAGCTimeConstant(int index); - static int getAGCTimeConstantIndex(int agcTimeConstant); }; diff --git a/sdrbase/audio/audiocompressorsnd.cpp b/sdrbase/audio/audiocompressorsnd.cpp index 1f98a2a08..39bc4c702 100644 --- a/sdrbase/audio/audiocompressorsnd.cpp +++ b/sdrbase/audio/audiocompressorsnd.cpp @@ -57,18 +57,19 @@ void AudioCompressorSnd::initState() float AudioCompressorSnd::compress(float sample) { + float compressedSample; + if (m_sampleIndex >= AUDIOCOMPRESSORSND_SF_COMPRESSOR_CHUNKSIZE) { sf_compressor_process(&m_compressorState, AUDIOCOMPRESSORSND_SF_COMPRESSOR_CHUNKSIZE, m_storageBuffer, m_processedBuffer); m_sampleIndex = 0; } - else - { - m_storageBuffer[m_sampleIndex] = sample; - m_sampleIndex++; - } - return m_processedBuffer[m_sampleIndex]; + compressedSample = m_processedBuffer[m_sampleIndex]; + m_storageBuffer[m_sampleIndex] = sample; + m_sampleIndex++; + + return compressedSample; } // populate the compressor state with advanced parameters diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 0486b2f11..f7fcb944e 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -4944,25 +4944,6 @@ margin-bottom: 20px; "agc" : { "type" : "integer" }, - "agcOrder" : { - "type" : "number", - "format" : "float" - }, - "agcTime" : { - "type" : "integer" - }, - "agcThresholdEnable" : { - "type" : "integer" - }, - "agcThreshold" : { - "type" : "integer" - }, - "agcThresholdGate" : { - "type" : "integer" - }, - "agcThresholdDelay" : { - "type" : "integer" - }, "rgbColor" : { "type" : "integer" }, @@ -6267,7 +6248,7 @@ margin-bottom: 20px;