master
Hannes Matuschek 12 years ago
parent 64ec3dfd12
commit 63c228ea49

@ -7,15 +7,26 @@
namespace sdr {
/** Forward declaration of type tratis template. */
template <class T> class Traits;
/** Forward declaration of type tratis template.
* For each supported type, @c uint8_t, @c std::comple<uint8_t>, @c int8_t,
* @c std::complex<uint8_t>, @c uint16_t, @c std::complex<uint16_t>, @c int16_t,
* @c std::complex<int16_t>, @c float, @c std::complex<float>, @c double and
* @c std::complex<double>, the Traits template povides the @c Scalar type (the template argument
* type), its real type (i.e. for the type @c std::complex<int16_t> it would be @c int16_t),
* its super scalar (i.e. for the @c int16_t, it would be @c int32_t but for @c float it is
* @c flaot again) which allows for safe multiplications of these values, the scale mapping
* the interval [-1,1] to the values of the scalar type, the bit shift from the scalar type to the
* super scalar type and the type id for the scalar. */
template <class Scalar> class Traits;
/** Template specialization of type tratis for uint8_t scalar. */
template <>
class Traits<uint8_t> {
public:
/** The Scalar type. */
/** The scalar type. */
typedef uint8_t Scalar;
/** The real scalar type. */
typedef uint8_t RScalar;
/** The compute scalar type. */
typedef uint16_t SScalar;
/** The scaleing factor from floating point to integer. */
@ -30,8 +41,10 @@ public:
template <>
class Traits< std::complex<uint8_t> > {
public:
/** The Scalar type. */
/** The scalar type. */
typedef std::complex<uint8_t> Scalar;
/** The real scalar type. */
typedef uint8_t RScalar;
/** The compute scalar type. */
typedef std::complex<uint16_t> SScalar;
/** The scaleing factor from floating point to integer. */
@ -46,8 +59,10 @@ public:
template <>
class Traits<int8_t> {
public:
/** The Scalar type. */
/** The scalar type. */
typedef int8_t Scalar;
/** The real scalar type. */
typedef int8_t RScalar;
/** The compute scalar type. */
typedef int16_t SScalar;
/** The scaleing factor from floating point to integer. */
@ -62,8 +77,10 @@ public:
template <>
class Traits< std::complex<int8_t> > {
public:
/** The Scalar type. */
/** The scalar type. */
typedef std::complex<int8_t> Scalar;
/** The real scalar type. */
typedef int8_t RScalar;
/** The compute scalar type. */
typedef std::complex<int16_t> SScalar;
/** The scaleing factor from floating point to integer. */
@ -78,8 +95,10 @@ public:
template <>
class Traits<uint16_t> {
public:
/** The Scalar type. */
/** The scalar type. */
typedef uint16_t Scalar;
/** The real scalar type. */
typedef uint16_t RScalar;
/** The compute scalar type. */
typedef uint32_t SScalar;
/** The scaleing factor from floating point to integer. */
@ -94,8 +113,10 @@ public:
template <>
class Traits< std::complex<uint16_t> > {
public:
/** The Scalar type. */
/** The scalar type. */
typedef std::complex<uint16_t> Scalar;
/** The real scalar type. */
typedef uint16_t RScalar;
/** The compute scalar type. */
typedef std::complex<uint32_t> SScalar;
/** The scaleing factor from floating point to integer. */
@ -110,8 +131,10 @@ public:
template <>
class Traits<int16_t> {
public:
/** The Scalar type. */
/** The scalar type. */
typedef int16_t Scalar;
/** The real scalar type. */
typedef int16_t RScalar;
/** The compute scalar type. */
typedef int32_t SScalar;
/** The scaleing factor from floating point to integer. */
@ -126,8 +149,10 @@ public:
template <>
class Traits< std::complex<int16_t> > {
public:
/** The Scalar type. */
/** The scalar type. */
typedef std::complex<int16_t> Scalar;
/** The real Scalar type. */
typedef int16_t RScalar;
/** The compute scalar type. */
typedef std::complex<int32_t> SScalar;
/** The scaleing factor from floating point to integer. */
@ -144,6 +169,8 @@ class Traits<float> {
public:
/** The Scalar type. */
typedef float Scalar;
/** The real scalar type. */
typedef float RScalar;
/** The compute scalar type. */
typedef float SScalar;
/** The scaleing factor from floating point to integer. */
@ -158,8 +185,10 @@ public:
template <>
class Traits< std::complex<float> > {
public:
/** The Scalar type. */
/** The scalar type. */
typedef std::complex<float> Scalar;
/** The real scalar type. */
typedef float RScalar;
/** The compute scalar type. */
typedef std::complex<float> SScalar;
/** The scaleing factor from floating point to integer. */
@ -174,8 +203,10 @@ public:
template <>
class Traits<double> {
public:
/** The Scalar type. */
/** The scalar type. */
typedef double Scalar;
/** The real scalar type. */
typedef double RScalar;
/** The compute scalar type. */
typedef double SScalar;
/** The scaleing factor from floating point to integer. */
@ -190,8 +221,10 @@ public:
template <>
class Traits< std::complex<double> > {
public:
/** The Scalar type. */
/** The scalar type. */
typedef std::complex<double> Scalar;
/** The real scalar type. */
typedef double RScalar;
/** The compute (super) scalar type. */
typedef std::complex<double> SScalar;
/** The scaleing factor from floating point to integer. */
@ -205,4 +238,4 @@ public:
}
#endif // TRAITS_HH
#endif

@ -545,7 +545,7 @@ protected:
/** An automatic gain control widget. */
/** An automatic gain control node. */
template <class Scalar>
class AGC: public Sink<Scalar>, public Source
{
@ -592,12 +592,12 @@ public:
}
/** Returns the current gain factor. */
inline double gain() const {
inline float gain() const {
return _gain;
}
/** Resets the current gain factor. */
inline void setGain(double gain) {
inline void setGain(float gain) {
_gain = gain;
}
@ -669,15 +669,15 @@ protected:
/** If true, the automatic gain adjustment is enabled. */
bool _enabled;
/** The time-constant of the AGC. */
double _tau;
float _tau;
/** One over the time-constant. */
double _lambda;
float _lambda;
/** The averaged std. dev. of the input signal. */
double _sd;
float _sd;
/** The target level of the output signal. */
double _target;
float _target;
/** The current gain factor. */
double _gain;
float _gain;
/** The current sample-rate. */
double _sample_rate;
/** The output buffer. */

Loading…
Cancel
Save