1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Differentiate Rx and Tx DSP sample sizes

This commit is contained in:
f4exb 2018-01-22 08:46:05 +01:00
parent bacc6659b0
commit 2ddcb8c358
45 changed files with 136 additions and 132 deletions

View File

@ -28,7 +28,7 @@ option(V4L-MSI "Use Linux Kernel MSI2500 Source." OFF)
option(BUILD_TYPE "Build type (RELEASE, RELEASEWITHDBGINFO, DEBUG" RELEASE)
option(DEBUG_OUTPUT "Print debug messages" OFF)
option(HOST_RPI "Compiling on RPi" OFF)
option(SAMPLE_24BIT "Internal 24 bit DSP" OFF)
option(RX_SAMPLE_24BIT "Internal 24 bit Rx DSP" OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
@ -187,8 +187,8 @@ elseif (${ARCHITECTURE} MATCHES "aarch64")
endif()
# Compiler flags.
if (SAMPLE_24BIT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSDR_SAMPLE_24BIT")
if (RX_SAMPLE_24BIT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSDR_RX_SAMPLE_24BIT")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}")

View File

@ -639,7 +639,7 @@ void DevicePlutoSDRBox::formatFIRCoefficients(std::ostringstream& ostr, uint32_t
WFIR::BasicFIR(fcoeffs, nbTaps, WFIR::LPF, normalizedBW, 0.0, normalizedBW < 0.2 ? WFIR::wtHAMMING : WFIR::wtBLACKMAN_HARRIS, 0.0);
for (unsigned int i = 0; i < nbTaps; i++) {
ostr << (int16_t) (fcoeffs[i] * SDR_SCALEF) << ", " << (int16_t) (fcoeffs[i] * SDR_SCALEF) << std::endl;
ostr << (int16_t) (fcoeffs[i] * 32768.0f) << ", " << (int16_t) (fcoeffs[i] * 32768.0f) << std::endl;
}
delete[] fcoeffs;

View File

@ -114,8 +114,8 @@ void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const Samp
if (!(m_undersampleCount++ & decim_mask))
{
m_sum /= decim;
Real re = m_sum.real() / SDR_SCALED;
Real im = m_sum.imag() / SDR_SCALED;
Real re = m_sum.real() / SDR_RX_SCALED;
Real im = m_sum.imag() / SDR_RX_SCALED;
m_magsq = re*re + im*im;
if (m_ssb & !m_usb)

View File

@ -229,8 +229,8 @@ private:
if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
{
m_sum /= decim;
Real re = m_sum.real() / SDR_SCALED;
Real im = m_sum.imag() / SDR_SCALED;
Real re = m_sum.real() / SDR_RX_SCALED;
Real im = m_sum.imag() / SDR_RX_SCALED;
m_magsq = re*re + im*im;
if (m_running.m_ssb & !m_usb)

View File

@ -161,8 +161,8 @@ private:
void processOneSample(Complex &ci)
{
Real re = ci.real() / SDR_SCALED;
Real im = ci.imag() / SDR_SCALED;
Real re = ci.real() / SDR_RX_SCALED;
Real im = ci.imag() / SDR_RX_SCALED;
Real magsq = re*re + im*im;
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();
@ -210,7 +210,7 @@ private:
Real attack = (m_squelchCount - 0.05f * m_settings.m_audioSampleRate) / (0.05f * m_settings.m_audioSampleRate);
sample = demod * attack * 2048 * m_settings.m_volume;
if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(demod * attack * SDR_SCALEF);
if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(demod * attack * SDR_RX_SCALEF);
m_squelchOpen = true;
}

View File

@ -338,7 +338,7 @@ void ATVDemod::demod(Complex& c)
magSq = fltI*fltI + fltQ*fltQ;
m_objMagSqAverage.feed(magSq);
fltNorm = sqrt(magSq);
fltVal = fltNorm / SDR_SCALEF;
fltVal = fltNorm / SDR_RX_SCALEF;
//********** Mini and Maxi Amplitude tracking **********

View File

@ -474,7 +474,7 @@ void ATVDemodGUI::tick()
if (m_atvDemod)
{
m_objMagSqAverage.feed(m_atvDemod->getMagSq());
double magSqDB = CalcDb::dbPower(m_objMagSqAverage.average() / (SDR_SCALED*SDR_SCALED));
double magSqDB = CalcDb::dbPower(m_objMagSqAverage.average() / (SDR_RX_SCALED*SDR_RX_SCALED));
ui->channePowerText->setText(tr("%1 dB").arg(magSqDB, 0, 'f', 1));
if (m_atvDemod->getBFOLocked()) {

View File

@ -125,7 +125,7 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
for (SampleVector::const_iterator it = begin; it != end; ++it)
{
Complex c(it->real() / SDR_SCALEF, it->imag() / SDR_SCALEF);
Complex c(it->real() / SDR_RX_SCALEF, it->imag() / SDR_RX_SCALEF);
c *= m_nco.nextIQ();
rf_out = m_rfFilter->runFilt(c, &rf); // filter RF before demod
@ -163,7 +163,7 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if (!m_settings.m_showPilot)
{
m_sampleBuffer.push_back(Sample(demod * SDR_SCALEF, 0.0));
m_sampleBuffer.push_back(Sample(demod * SDR_RX_SCALEF, 0.0));
}
if (m_settings.m_rdsActive)
@ -197,7 +197,7 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if (m_settings.m_showPilot)
{
m_sampleBuffer.push_back(Sample(m_pilotPLLSamples[1] * SDR_SCALEF, 0.0)); // debug 38 kHz pilot
m_sampleBuffer.push_back(Sample(m_pilotPLLSamples[1] * SDR_RX_SCALEF, 0.0)); // debug 38 kHz pilot
}
if (m_settings.m_lsbStereo)

View File

@ -128,8 +128,8 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
{
qint16 sample, delayedSample;
Real re = ci.real() / SDR_SCALED;
Real im = ci.imag() / SDR_SCALED;
Real re = ci.real() / SDR_RX_SCALED;
Real im = ci.imag() / SDR_RX_SCALED;
Real magsq = re*re + im*im;
m_movingAverage.feed(magsq);
@ -142,7 +142,7 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_magsqCount++;
Real demod = SDR_SCALEF * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_demodGain;
Real demod = SDR_RX_SCALEF * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_demodGain;
m_sampleCount++;
// AF processing

View File

@ -261,7 +261,7 @@ void LoRaDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
for(SampleVector::const_iterator it = begin; it < end; ++it)
{
Complex c(it->real() / SDR_SCALEF, it->imag() / SDR_SCALEF);
Complex c(it->real() / SDR_RX_SCALEF, it->imag() / SDR_RX_SCALEF);
c *= m_nco.nextIQ();
if(m_interpolator.decimate(&m_sampleDistanceRemain, c, &ci))

View File

@ -153,7 +153,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
Real demod = m_phaseDiscri.phaseDiscriminatorDelta(ci, magsqRaw, deviation);
Real magsq = magsqRaw / (SDR_SCALED*SDR_SCALED);
Real magsq = magsqRaw / (SDR_RX_SCALED*SDR_RX_SCALED);
m_movingAverage.feed(magsq);
m_magsqSum += magsq;

View File

@ -77,7 +77,7 @@ SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) :
m_magsqPeak = 0.0f;
m_magsqCount = 0;
m_agc.setClampMax(SDR_SCALED*SDR_SCALED);
m_agc.setClampMax(SDR_RX_SCALED*SDR_RX_SCALED);
m_agc.setClamping(m_agcClamping);
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen);
@ -186,7 +186,7 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
{
Real avgr = m_sum.real() / decim;
Real avgi = m_sum.imag() / decim;
m_magsq = (avgr * avgr + avgi * avgi) / (SDR_SCALED*SDR_SCALED);
m_magsq = (avgr * avgr + avgi * avgi) / (SDR_RX_SCALED*SDR_RX_SCALED);
m_magsqSum += m_magsq;
@ -427,7 +427,7 @@ void SSBDemod::applySettings(const SSBDemodSettings& settings, bool force)
{
int agcNbSamples = 48 * (1<<settings.m_agcTimeLog2);
m_agc.setThresholdEnable(settings.m_agcPowerThreshold != -99);
double agcPowerThreshold = CalcDb::powerFromdB(settings.m_agcPowerThreshold) * (SDR_SCALED*SDR_SCALED);
double agcPowerThreshold = CalcDb::powerFromdB(settings.m_agcPowerThreshold) * (SDR_RX_SCALED*SDR_RX_SCALED);
int agcThresholdGate = 48 * settings.m_agcThresholdGate; // ms
bool agcClamping = settings.m_agcClamping;

View File

@ -112,7 +112,7 @@ void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
for (int i = 0 ; i < rf_out; i++)
{
demod = m_phaseDiscri.phaseDiscriminatorDelta(rf[i], msq, fmDev);
Real magsq = msq / (SDR_SCALED*SDR_SCALED);
Real magsq = msq / (SDR_RX_SCALED*SDR_RX_SCALED);
m_movingAverage.feed(magsq);
m_magsqSum += magsq;

View File

@ -105,7 +105,7 @@ void TCPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
if(m_interpolator.decimate(&m_sampleDistanceRemain, c, &ci))
{
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())*rescale*rescale) / (SDR_SCALED*SDR_SCALED);
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())*rescale*rescale) / (SDR_RX_SCALED*SDR_RX_SCALED);
m_sampleBuffer.push_back(Sample(ci.real() * rescale, ci.imag() * rescale));
m_sampleDistanceRemain += m_inputSampleRate / m_outputSampleRate;
}
@ -143,7 +143,7 @@ void TCPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
if((m_sampleFormat == TCPSrcSettings::FormatNFM) && (m_ssbSockets.count() > 0)) {
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
Complex cj(it->real() / SDR_SCALEF, it->imag() / SDR_SCALEF);
Complex cj(it->real() / SDR_RX_SCALEF, it->imag() / SDR_RX_SCALEF);
// An FFT filter here is overkill, but was already set up for SSB
int n_out = TCPFilter->runFilt(cj, &sideband);
if (n_out) {

View File

@ -92,7 +92,7 @@ UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) :
qWarning("UDPSrc::UDPSrc: cannot bind audio port");
}
m_agc.setClampMax(SDR_SCALED*SDR_SCALED);
m_agc.setClampMax(SDR_RX_SCALED*SDR_RX_SCALED);
m_agc.setClamping(true);
//DSPEngine::instance()->addAudioSink(&m_audioFifo);
@ -158,7 +158,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
inMagSq = ci.real()*ci.real() + ci.imag()*ci.imag();
}
m_inMovingAverage.feed(inMagSq / (SDR_SCALED*SDR_SCALED));
m_inMovingAverage.feed(inMagSq / (SDR_RX_SCALED*SDR_RX_SCALED));
m_inMagsq = m_inMovingAverage.average();
Sample ss(ci.real(), ci.imag());
@ -180,7 +180,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
l = m_squelchOpen ? sideband[i].real() * m_settings.m_gain : 0;
r = m_squelchOpen ? sideband[i].imag() * m_settings.m_gain : 0;
m_udpBuffer->write(Sample(l, r));
m_outMovingAverage.feed((l*l + r*r) / (SDR_SCALED*SDR_SCALED));
m_outMovingAverage.feed((l*l + r*r) / (SDR_RX_SCALED*SDR_RX_SCALED));
}
}
}
@ -196,21 +196,21 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
l = m_squelchOpen ? sideband[i].real() * m_settings.m_gain : 0;
r = m_squelchOpen ? sideband[i].imag() * m_settings.m_gain : 0;
m_udpBuffer->write(Sample(l, r));
m_outMovingAverage.feed((l*l + r*r) / (SDR_SCALED*SDR_SCALED));
m_outMovingAverage.feed((l*l + r*r) / (SDR_RX_SCALED*SDR_RX_SCALED));
}
}
}
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatNFM)
{
double demod = m_squelchOpen ? SDR_SCALED * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_gain : 0;
double demod = m_squelchOpen ? SDR_RX_SCALED * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_gain : 0;
m_udpBuffer->write(Sample(demod, demod));
m_outMovingAverage.feed((demod * demod) / (SDR_SCALED*SDR_SCALED));
m_outMovingAverage.feed((demod * demod) / (SDR_RX_SCALED*SDR_RX_SCALED));
}
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatNFMMono)
{
FixReal demod = m_squelchOpen ? (FixReal) (SDR_SCALEF * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_gain) : 0;
FixReal demod = m_squelchOpen ? (FixReal) (SDR_RX_SCALEF * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_gain) : 0;
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
m_outMovingAverage.feed((demod * demod) / SDR_RX_SCALED*SDR_RX_SCALED);
}
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatLSBMono) // Monaural LSB
{
@ -223,7 +223,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
{
l = m_squelchOpen ? (sideband[i].real() + sideband[i].imag()) * 0.7 * m_settings.m_gain : 0;
m_udpBufferMono->write(l);
m_outMovingAverage.feed((l * l) / (SDR_SCALED*SDR_SCALED));
m_outMovingAverage.feed((l * l) / (SDR_RX_SCALED*SDR_RX_SCALED));
}
}
}
@ -238,7 +238,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
{
l = m_squelchOpen ? (sideband[i].real() + sideband[i].imag()) * 0.7 * m_settings.m_gain : 0;
m_udpBufferMono->write(l);
m_outMovingAverage.feed((l * l) / (SDR_SCALED*SDR_SCALED));
m_outMovingAverage.feed((l * l) / (SDR_RX_SCALED*SDR_RX_SCALED));
}
}
}
@ -246,7 +246,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
{
FixReal demod = m_squelchOpen ? (FixReal) (sqrt(inMagSq) * agcFactor * m_settings.m_gain) : 0;
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
m_outMovingAverage.feed((demod * demod) / SDR_RX_SCALED*SDR_RX_SCALED);
}
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatAMNoDCMono)
{
@ -256,7 +256,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
m_amMovingAverage.feed(demodf);
FixReal demod = (FixReal) ((demodf - m_amMovingAverage.average()) * agcFactor * m_settings.m_gain);
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
m_outMovingAverage.feed((demod * demod) / SDR_RX_SCALED*SDR_RX_SCALED);
}
else
{
@ -273,7 +273,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
demodf /= 301.0;
FixReal demod = (FixReal) (demodf * agcFactor * m_settings.m_gain);
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
m_outMovingAverage.feed((demod * demod) / SDR_RX_SCALED*SDR_RX_SCALED);
}
else
{
@ -287,7 +287,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
{
Sample s(ci.real() * m_settings.m_gain, ci.imag() * m_settings.m_gain);
m_udpBuffer->write(s);
m_outMovingAverage.feed((inMagSq*m_settings.m_gain*m_settings.m_gain) / (SDR_SCALED*SDR_SCALED));
m_outMovingAverage.feed((inMagSq*m_settings.m_gain*m_settings.m_gain) / (SDR_RX_SCALED*SDR_RX_SCALED));
}
else
{

View File

@ -130,7 +130,7 @@ void AMMod::pull(Sample& sample)
m_settingsMutex.unlock();
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
magsq /= (SDR_SCALED*SDR_SCALED);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();

View File

@ -164,7 +164,7 @@ void ATVMod::pullFinalize(Complex& ci, Sample& sample)
m_settingsMutex.unlock();
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
magsq /= (SDR_SCALED*SDR_SCALED);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage.feed(magsq);
sample.m_real = (FixReal) ci.real();

View File

@ -43,7 +43,7 @@ void ATVModSettings::resetToDefaults()
m_cameraPlay = false;
m_channelMute = false;
m_invertedVideo = false;
m_rfScalingFactor = 0.891235351562f * SDR_SCALEF; // -1dB
m_rfScalingFactor = 0.891235351562f * SDR_TX_SCALEF; // -1dB
m_fmExcursion = 0.5f; // half bandwidth
m_forceDecimator = false;
m_overlayText = "ATV";

View File

@ -136,7 +136,7 @@ void NFMMod::pull(Sample& sample)
m_settingsMutex.unlock();
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
magsq /= (SDR_SCALED*SDR_SCALED);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();
@ -175,8 +175,8 @@ void NFMMod::modulateSample()
m_modPhasor += (m_settings.m_fmDeviation / (float) m_settings.m_audioSampleRate) * m_bandpass.filter(t) * (M_PI / 378.0f);
}
m_modSample.real(cos(m_modPhasor) * 0.891235351562f * SDR_SCALEF); // -1 dB
m_modSample.imag(sin(m_modPhasor) * 0.891235351562f * SDR_SCALEF);
m_modSample.real(cos(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF); // -1 dB
m_modSample.imag(sin(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF);
}
void NFMMod::pullAF(Real& sample)

View File

@ -160,12 +160,12 @@ void SSBMod::pull(Sample& sample)
m_interpolatorDistanceRemain += m_interpolatorDistance;
ci *= m_carrierNco.nextIQ(); // shift to carrier frequency
ci *= 0.891235351562f * SDR_SCALEF; //scaling at -1 dB to account for possible filter overshoot
ci *= 0.891235351562f * SDR_TX_SCALEF; //scaling at -1 dB to account for possible filter overshoot
m_settingsMutex.unlock();
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
magsq /= (SDR_SCALED*SDR_SCALED);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();
@ -298,13 +298,13 @@ void SSBMod::pullAF(Complex& sample)
{
if (m_settings.m_audioFlipChannels)
{
ci.real((m_audioBuffer[m_audioBufferFill].r / SDR_SCALEF) * m_settings.m_volumeFactor);
ci.imag((m_audioBuffer[m_audioBufferFill].l / SDR_SCALEF) * m_settings.m_volumeFactor);
ci.real((m_audioBuffer[m_audioBufferFill].r / SDR_TX_SCALEF) * m_settings.m_volumeFactor);
ci.imag((m_audioBuffer[m_audioBufferFill].l / SDR_TX_SCALEF) * m_settings.m_volumeFactor);
}
else
{
ci.real((m_audioBuffer[m_audioBufferFill].l / SDR_SCALEF) * m_settings.m_volumeFactor);
ci.imag((m_audioBuffer[m_audioBufferFill].r / SDR_SCALEF) * m_settings.m_volumeFactor);
ci.real((m_audioBuffer[m_audioBufferFill].l / SDR_TX_SCALEF) * m_settings.m_volumeFactor);
ci.imag((m_audioBuffer[m_audioBufferFill].r / SDR_TX_SCALEF) * m_settings.m_volumeFactor);
}
}
else
@ -419,8 +419,8 @@ void SSBMod::pullAF(Complex& sample)
if (!(m_undersampleCount++ & decim_mask))
{
Real avgr = (m_sum.real() / decim) * 0.891235351562f * SDR_SCALEF; //scaling at -1 dB to account for possible filter overshoot
Real avgi = (m_sum.imag() / decim) * 0.891235351562f * SDR_SCALEF;
Real avgr = (m_sum.real() / decim) * 0.891235351562f * SDR_TX_SCALEF; //scaling at -1 dB to account for possible filter overshoot
Real avgi = (m_sum.imag() / decim) * 0.891235351562f * SDR_TX_SCALEF;
if (!m_settings.m_dsb & !m_settings.m_usb)
{ // invert spectrum for LSB
@ -443,8 +443,8 @@ void SSBMod::pullAF(Complex& sample)
if (!(m_undersampleCount++ & decim_mask))
{
Real avgr = (m_sum.real() / decim) * 0.891235351562f * SDR_SCALEF; //scaling at -1 dB to account for possible filter overshoot
Real avgi = (m_sum.imag() / decim) * 0.891235351562f * SDR_SCALEF;
Real avgr = (m_sum.real() / decim) * 0.891235351562f * SDR_TX_SCALEF; //scaling at -1 dB to account for possible filter overshoot
Real avgi = (m_sum.imag() / decim) * 0.891235351562f * SDR_TX_SCALEF;
if (!m_settings.m_dsb & !m_settings.m_usb)
{ // invert spectrum for LSB

View File

@ -139,8 +139,8 @@ void WFMMod::pull(Sample& sample)
}
m_modPhasor += (m_settings.m_fmDeviation / (float) m_outputSampleRate) * ri.real() * M_PI * 2.0f;
ci.real(cos(m_modPhasor) * 0.891235351562f * SDR_SCALEF); // -1 dB
ci.imag(sin(m_modPhasor) * 0.891235351562f * SDR_SCALEF);
ci.real(cos(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF); // -1 dB
ci.imag(sin(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF);
// RF filtering
rf_out = m_rfFilter->runFilt(ci, &rf);
@ -158,7 +158,7 @@ void WFMMod::pull(Sample& sample)
m_settingsMutex.unlock();
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
magsq /= (SDR_SCALED*SDR_SCALED);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();

View File

@ -134,7 +134,7 @@ void UDPSink::pull(Sample& sample)
m_settingsMutex.unlock();
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
magsq /= (SDR_SCALED*SDR_SCALED);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();
@ -151,7 +151,7 @@ void UDPSink::modulateSample()
m_udpHandler.readSample(s);
uint64_t magsq = s.m_real * s.m_real + s.m_imag * s.m_imag;
m_inMovingAverage.feed(magsq/1073741824.0);
m_inMovingAverage.feed(magsq/(SDR_TX_SCALED*SDR_TX_SCALED));
m_inMagsq = m_inMovingAverage.average();
calculateSquelch(m_inMagsq);
@ -180,9 +180,9 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
m_modPhasor += (m_settings.m_fmDeviation / m_settings.m_inputSampleRate) * (t / SDR_SCALEF) * M_PI * 2.0f;
m_modSample.real(cos(m_modPhasor) * 0.3162292f * SDR_SCALEF * m_settings.m_gainOut);
m_modSample.imag(sin(m_modPhasor) * 0.3162292f * SDR_SCALEF * m_settings.m_gainOut);
m_modPhasor += (m_settings.m_fmDeviation / m_settings.m_inputSampleRate) * (t / SDR_TX_SCALEF) * M_PI * 2.0f;
m_modSample.real(cos(m_modPhasor) * 0.3162292f * SDR_TX_SCALEF * m_settings.m_gainOut);
m_modSample.imag(sin(m_modPhasor) * 0.3162292f * SDR_TX_SCALEF * m_settings.m_gainOut);
calculateLevel(m_modSample);
}
else
@ -195,14 +195,14 @@ void UDPSink::modulateSample()
{
FixReal t;
readMonoSample(t);
m_inMovingAverage.feed((t*t)/(SDR_SCALED*SDR_SCALED));
m_inMovingAverage.feed((t*t)/(SDR_TX_SCALED*SDR_TX_SCALED));
m_inMagsq = m_inMovingAverage.average();
calculateSquelch(m_inMagsq);
if (m_squelchOpen)
{
m_modSample.real(((t / SDR_SCALEF)*m_settings.m_amModFactor*m_settings.m_gainOut + 1.0f) * (SDR_SCALEF/2)); // modulate and scale zero frequency carrier
m_modSample.real(((t / SDR_TX_SCALEF)*m_settings.m_amModFactor*m_settings.m_gainOut + 1.0f) * (SDR_TX_SCALEF/2)); // modulate and scale zero frequency carrier
m_modSample.imag(0.0f);
calculateLevel(m_modSample);
}
@ -220,14 +220,14 @@ void UDPSink::modulateSample()
int n_out = 0;
readMonoSample(t);
m_inMovingAverage.feed((t*t)/1073741824.0);
m_inMovingAverage.feed((t*t)/(SDR_TX_SCALED*SDR_TX_SCALED));
m_inMagsq = m_inMovingAverage.average();
calculateSquelch(m_inMagsq);
if (m_squelchOpen)
{
ci.real((t / SDR_SCALEF) * m_settings.m_gainOut);
ci.real((t / SDR_TX_SCALEF) * m_settings.m_gainOut);
ci.imag(0.0f);
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_settings.m_sampleFormat == UDPSinkSettings::FormatUSB));
@ -239,8 +239,8 @@ void UDPSink::modulateSample()
}
c = m_SSBFilterBuffer[m_SSBFilterBufferIndex];
m_modSample.real(m_SSBFilterBuffer[m_SSBFilterBufferIndex].real() * SDR_SCALEF);
m_modSample.imag(m_SSBFilterBuffer[m_SSBFilterBufferIndex].imag() * SDR_SCALEF);
m_modSample.real(m_SSBFilterBuffer[m_SSBFilterBufferIndex].real() * SDR_TX_SCALEF);
m_modSample.imag(m_SSBFilterBuffer[m_SSBFilterBufferIndex].imag() * SDR_TX_SCALEF);
m_SSBFilterBufferIndex++;
calculateLevel(m_modSample);
@ -305,8 +305,8 @@ void UDPSink::calculateLevel(Complex sample)
}
else
{
qreal rmsLevel = m_levelSum > 0.0 ? sqrt((m_levelSum/(SDR_SCALED*SDR_SCALED)) / m_levelNbSamples) : 0.0;
emit levelChanged(rmsLevel, m_peakLevel / SDR_SCALEF, m_levelNbSamples);
qreal rmsLevel = m_levelSum > 0.0 ? sqrt((m_levelSum/(SDR_TX_SCALED*SDR_TX_SCALED)) / m_levelNbSamples) : 0.0;
emit levelChanged(rmsLevel, m_peakLevel / SDR_TX_SCALEF, m_levelNbSamples);
m_peakLevel = 0.0f;
m_levelSum = 0.0f;
m_levelCalcCount = 0;

View File

@ -51,7 +51,7 @@ private:
unsigned int m_log2Interp;
int m_fcPos;
Interpolators<qint16, SDR_SAMP_SZ, 12> m_interpolators;
Interpolators<qint16, SDR_TX_SAMP_SZ, 12> m_interpolators;
void run();
void callback(qint16* buf, qint32 len);

View File

@ -70,7 +70,7 @@ private:
QElapsedTimer m_elapsedTimer;
bool m_throttleToggle;
Interpolators<qint16, SDR_SAMP_SZ, 16> m_interpolators;
Interpolators<qint16, SDR_TX_SAMP_SZ, 16> m_interpolators;
int16_t *m_buf;
void run();

View File

@ -49,7 +49,7 @@ private:
unsigned int m_log2Interp;
Interpolators<qint8, SDR_SAMP_SZ, 8> m_interpolators;
Interpolators<qint8, SDR_TX_SAMP_SZ, 8> m_interpolators;
void run();
void callback(qint8* buf, qint32 len);

View File

@ -56,7 +56,7 @@ private:
unsigned int m_log2Interp; // soft decimation
int m_fcPos;
Interpolators<qint16, SDR_SAMP_SZ, 12> m_interpolators;
Interpolators<qint16, SDR_TX_SAMP_SZ, 12> m_interpolators;
void run();
void callback(qint16* buf, qint32 len);

View File

@ -54,7 +54,7 @@ private:
unsigned int m_log2Interp; // soft interpolation
Interpolators<qint16, SDR_SAMP_SZ, 12> m_interpolators;
Interpolators<qint16, SDR_TX_SAMP_SZ, 12> m_interpolators;
void run();
void convert(qint16* buf, qint32 len);

View File

@ -55,10 +55,10 @@ private:
int m_fcPos;
static AirspyThread *m_this;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#endif
void run();

View File

@ -53,10 +53,10 @@ private:
unsigned int m_log2Decim;
static AirspyHFThread *m_this;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 16> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 16> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 16> m_decimators;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16> m_decimators;
#endif
void run();

View File

@ -51,10 +51,10 @@ private:
unsigned int m_log2Decim;
int m_fcPos;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#endif
void run();

View File

@ -54,10 +54,10 @@ private:
unsigned int m_log2Decim;
int m_fcPos;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint8, SDR_SAMP_SZ, 8> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint8, SDR_RX_SAMP_SZ, 8> m_decimators;
#else
Decimators<qint32, qint8, SDR_SAMP_SZ, 8> m_decimators;
Decimators<qint32, qint8, SDR_RX_SAMP_SZ, 8> m_decimators;
#endif
void run();

View File

@ -55,10 +55,10 @@ private:
unsigned int m_log2Decim; // soft decimation
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#endif
void run();

View File

@ -59,10 +59,10 @@ private:
int m_fcPos;
float m_phasor;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#endif
void run();

View File

@ -52,10 +52,10 @@ private:
unsigned int m_log2Decim;
int m_fcPos;
#ifdef SDR_SAMPLE_24BIT
DecimatorsU<qint64, quint8, SDR_SAMP_SZ, 8, 127> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
DecimatorsU<qint64, quint8, SDR_RX_SAMP_SZ, 8, 127> m_decimators;
#else
DecimatorsU<qint32, quint8, SDR_SAMP_SZ, 8, 127> m_decimators;
DecimatorsU<qint32, quint8, SDR_RX_SAMP_SZ, 8, 127> m_decimators;
#endif
void run();

View File

@ -52,10 +52,10 @@ private:
unsigned int m_log2Decim;
int m_fcPos;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
#endif
void run();

View File

@ -85,14 +85,14 @@ private:
bool m_throttleToggle;
QMutex m_mutex;
#ifdef SDR_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_SAMP_SZ, 8> m_decimators_8;
Decimators<qint64, qint16, SDR_SAMP_SZ, 12> m_decimators_12;
Decimators<qint64, qint16, SDR_SAMP_SZ, 16> m_decimators_16;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 8> m_decimators_8;
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 12> m_decimators_12;
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 16> m_decimators_16;
#else
Decimators<qint32, qint16, SDR_SAMP_SZ, 8> m_decimators_8;
Decimators<qint32, qint16, SDR_SAMP_SZ, 12> m_decimators_12;
Decimators<qint32, qint16, SDR_SAMP_SZ, 16> m_decimators_16;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 8> m_decimators_8;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators_12;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16> m_decimators_16;
#endif
void run();

View File

@ -18,7 +18,7 @@
#define INCLUDE_GPL_DSP_DECIMATORS_H_
#include "dsp/dsptypes.h"
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
@ -240,7 +240,7 @@ public:
void decimate64_cen(SampleVector::iterator* it, const T* bufI, const T* bufQ, qint32 len);
private:
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages

View File

@ -24,7 +24,7 @@
#define INCLUDE_GPL_DSP_DECIMATORSU_H_
#include "dsp/dsptypes.h"
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
@ -206,7 +206,7 @@ public:
void decimate64_cen(SampleVector::iterator* it, const T* buf, qint32 len);
private:
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
IntHalfbandFilterDB<qint64, DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages

View File

@ -192,7 +192,7 @@ void DownChannelizer::applyConfiguration()
}
}
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
DownChannelizer::FilterStage::FilterStage(Mode mode) :
m_filter(new IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>),
m_workFunction(0),

View File

@ -23,7 +23,7 @@
#include <QMutex>
#include "util/export.h"
#include "util/message.h"
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
#include "dsp/inthalfbandfilterdb.h"
#else
#ifdef USE_SSE4_1
@ -82,7 +82,7 @@ protected:
ModeUpperHalf
};
#ifdef SDR_SAMPLE_24BIT
#ifdef SDR_RX_SAMPLE_24BIT
typedef bool (IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
IntHalfbandFilterDB<qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
#else

View File

@ -22,18 +22,22 @@
#include <vector>
#include <QtGlobal>
#ifdef SDR_SAMPLE_24BIT
#define SDR_SAMP_SZ 24 // internal fixed arithmetic sample size
#define SDR_SCALEF 8388608.0f
#define SDR_SCALED 8388608.0
#ifdef SDR_RX_SAMPLE_24BIT
#define SDR_RX_SAMP_SZ 24 // internal fixed arithmetic sample size
#define SDR_RX_SCALEF 8388608.0f
#define SDR_RX_SCALED 8388608.0
typedef qint32 FixReal;
#else
#define SDR_SAMP_SZ 16 // internal fixed arithmetic sample size
#define SDR_SCALEF 32768.0f
#define SDR_SCALED 32768.0
#define SDR_RX_SAMP_SZ 16 // internal fixed arithmetic sample size
#define SDR_RX_SCALEF 32768.0f
#define SDR_RX_SCALED 32768.0
typedef qint16 FixReal;
#endif
#define SDR_TX_SAMP_SZ 16
#define SDR_TX_SCALEF 32768.0f
#define SDR_TX_SCALED 32768.0
typedef float Real;
typedef std::complex<Real> Complex;

View File

@ -111,7 +111,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
for(int i = 0; i < count; ++i)
{
*it++ = Complex(begin->real() / SDR_SCALEF, begin->imag() / SDR_SCALEF);
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
++begin;
}
@ -234,7 +234,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
for(int i = 0; i < count; ++i)
{
*it++ = Complex(begin->real() / SDR_SCALEF, begin->imag() / SDR_SCALEF);
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
++begin;
}
@ -341,7 +341,7 @@ void ScopeVis::setSampleRate(int sampleRate)
bool ScopeVis::triggerCondition(SampleVector::const_iterator& it)
{
Complex c(it->real()/SDR_SCALEF, it->imag()/SDR_SCALEF);
Complex c(it->real()/SDR_RX_SCALEF, it->imag()/SDR_RX_SCALEF);
m_traceback.push_back(c); // store into trace memory FIFO
if (m_tracebackCount < m_traceback.size())

View File

@ -556,7 +556,7 @@ private:
switch (m_projectionType)
{
case ProjectionImag:
v = s.m_imag / SDR_SCALEF;
v = s.m_imag / SDR_RX_SCALEF;
break;
case ProjectionMagLin:
{
@ -590,7 +590,7 @@ private:
break;
case ProjectionReal:
default:
v = s.m_real / SDR_SCALEF;
v = s.m_real / SDR_RX_SCALEF;
break;
}

View File

@ -545,7 +545,7 @@ private:
switch (m_projectionType)
{
case ProjectionImag:
v = s.m_imag / SDR_SCALEF;
v = s.m_imag / SDR_RX_SCALEF;
break;
case ProjectionMagLin:
{
@ -579,7 +579,7 @@ private:
break;
case ProjectionReal:
default:
v = s.m_real / SDR_SCALEF;
v = s.m_real / SDR_RX_SCALEF;
break;
}

View File

@ -85,7 +85,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
for (std::size_t i = 0; i < samplesNeeded; ++i, ++begin)
{
*it++ = Complex(begin->real() / SDR_SCALEF, begin->imag() / SDR_SCALEF);
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
}
// apply fft window (and copy from m_fftBuffer to m_fftIn)
@ -144,7 +144,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
// not enough samples for FFT - just fill in new data and return
for(std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; begin < end; ++begin)
{
*it++ = Complex(begin->real() / SDR_SCALEF, begin->imag() / SDR_SCALEF);
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
}
m_fftBufferFill += todo;