mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 08:04:49 -05:00
Put smootherstep function code in one place
This commit is contained in:
parent
ca8cad26c5
commit
38318577de
@ -22,6 +22,7 @@
|
||||
#include <stdio.h>
|
||||
#include <complex.h>
|
||||
#include <dsp/downchannelizer.h>
|
||||
#include "util/stepfunctions.h"
|
||||
#include "audio/audiooutput.h"
|
||||
#include "dsp/pidcontroller.h"
|
||||
#include "dsp/dspengine.h"
|
||||
@ -285,7 +286,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
||||
else
|
||||
{
|
||||
demod = m_bandpass.filter(demod);
|
||||
Real squelchFactor = smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
|
||||
Real squelchFactor = StepFunctions::smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
|
||||
sample = demod * m_running.m_volume * squelchFactor;
|
||||
}
|
||||
}
|
||||
|
@ -250,21 +250,6 @@ private:
|
||||
PhaseDiscriminators m_phaseDiscri;
|
||||
|
||||
void apply(bool force = false);
|
||||
|
||||
float smootherstep(float x)
|
||||
{
|
||||
if (x == 1.0f) {
|
||||
return 1.0f;
|
||||
} else if (x == 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
double x3 = x * x * x;
|
||||
double x4 = x * x3;
|
||||
double x5 = x * x4;
|
||||
|
||||
return (float) (6.0*x5 - 15.0*x4 + 10.0*x3);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // INCLUDE_NFMDEMOD_H
|
||||
|
@ -16,7 +16,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../../channelrx/demodssb/ssbdemod.h"
|
||||
#include "ssbdemod.h"
|
||||
|
||||
#include <dsp/downchannelizer.h>
|
||||
#include <QTime>
|
||||
|
@ -7,7 +7,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include "dsp/agc.h"
|
||||
#include "util/smootherstep.h"
|
||||
|
||||
#include "util/stepfunctions.h"
|
||||
|
||||
#define StepLengthMax 2400 // 50ms
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <QChar>
|
||||
#include <QDebug>
|
||||
#include "cwkeyer.h"
|
||||
#include "util/stepfunctions.h"
|
||||
|
||||
/**
|
||||
* 0: dot
|
||||
@ -488,8 +489,8 @@ void CWSmoother::setNbFadeSamples(unsigned int nbFadeSamples)
|
||||
float x = i/ (float) m_nbFadeSamples;
|
||||
float y = 1.0f -x;
|
||||
|
||||
m_fadeInSamples[i] = smootherstep(x);
|
||||
m_fadeOutSamples[i] = smootherstep(y);
|
||||
m_fadeInSamples[i] = StepFunctions::smootherstep(x);
|
||||
m_fadeOutSamples[i] = StepFunctions::smootherstep(y);
|
||||
}
|
||||
|
||||
m_fadeInCounter = 0;
|
||||
@ -534,12 +535,3 @@ bool CWSmoother::getFadeSample(bool on, float& sample)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float CWSmoother::smootherstep(float x)
|
||||
{
|
||||
double x3 = x * x * x;
|
||||
double x4 = x * x3;
|
||||
double x5 = x * x4;
|
||||
|
||||
return (float) (6.0*x5 - 15.0*x4 + 10.0*x3);
|
||||
}
|
||||
|
@ -119,8 +119,6 @@ private:
|
||||
unsigned int m_nbFadeSamples;
|
||||
float *m_fadeInSamples;
|
||||
float *m_fadeOutSamples;
|
||||
|
||||
float smootherstep(float x);
|
||||
};
|
||||
|
||||
#endif /* SDRBASE_DSP_CWKEYER_H_ */
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* smootherstep.h
|
||||
*
|
||||
* Created on: Jul 25, 2017
|
||||
* Author: f4exb
|
||||
*/
|
||||
|
||||
#ifndef SDRBASE_UTIL_SMOOTHERSTEP_H_
|
||||
#define SDRBASE_UTIL_SMOOTHERSTEP_H_
|
||||
|
||||
class StepFunctions
|
||||
{
|
||||
public:
|
||||
static float smootherstep(float x)
|
||||
{
|
||||
if (x == 1.0f) {
|
||||
return 1.0f;
|
||||
} else if (x == 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
double x3 = x * x * x;
|
||||
double x4 = x * x3;
|
||||
double x5 = x * x4;
|
||||
|
||||
return (float) (6.0*x5 - 15.0*x4 + 10.0*x3);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SDRBASE_UTIL_SMOOTHERSTEP_H_ */
|
39
sdrbase/util/stepfunctions.h
Normal file
39
sdrbase/util/stepfunctions.h
Normal file
@ -0,0 +1,39 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_UTIL_STEPFUNCTIONS_H_
|
||||
#define SDRBASE_UTIL_STEPFUNCTIONS_H_
|
||||
|
||||
class StepFunctions
|
||||
{
|
||||
public:
|
||||
static float smootherstep(float x)
|
||||
{
|
||||
if (x == 1.0f) {
|
||||
return 1.0f;
|
||||
} else if (x == 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
double x3 = x * x * x;
|
||||
double x4 = x * x3;
|
||||
double x5 = x * x4;
|
||||
|
||||
return (float) (6.0*x5 - 15.0*x4 + 10.0*x3);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SDRBASE_UTIL_STEPFUNCTIONS_H_ */
|
Loading…
Reference in New Issue
Block a user