81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
#pragma once
|
|
#include "lasp_siggen.h"
|
|
#include "lasp_types.h"
|
|
|
|
class Noise : public Siggen {
|
|
d level_linear;
|
|
virtual vd genSignalUnscaled(const us nframes) override;
|
|
void resetImpl() override;
|
|
public:
|
|
|
|
/**
|
|
* @brief Constructs a noise generator. If no filter is used, the output will
|
|
* be white noise. By default, the output will be standard deviation = 1
|
|
* noise, which clips the output for standard audio devices, so make sure the
|
|
* level is set properly.
|
|
*/
|
|
Noise();
|
|
~Noise() = default;
|
|
|
|
};
|
|
|
|
class Sine : public Siggen {
|
|
d phase = 0;
|
|
d omg;
|
|
|
|
public:
|
|
|
|
/**
|
|
* @brief Create a sine wave generator
|
|
*
|
|
* @param freq_Hz
|
|
* @param level_dB
|
|
*/
|
|
Sine(const d freq_Hz);
|
|
~Sine() = default;
|
|
virtual vd genSignalUnscaled(const us nframes) override;
|
|
void setFreq(const d newFreq);
|
|
void resetImpl() override { phase=0; }
|
|
};
|
|
class Periodic: public Siggen {
|
|
protected:
|
|
vd _signal { 1, arma::fill::zeros};
|
|
us _cur_pos = 0;
|
|
public:
|
|
|
|
virtual vd genSignalUnscaled(const us nframes) override;
|
|
~Periodic() = default;
|
|
|
|
};
|
|
|
|
class Sweep : public Periodic {
|
|
d fl_, fu_, Ts, Tq;
|
|
us index;
|
|
us flags;
|
|
|
|
static constexpr int ForwardSweep = 1 << 0;
|
|
static constexpr int BackwardSweep = 1 << 1;
|
|
static constexpr int LinearSweep = 1 << 2;
|
|
static constexpr int LogSweep = 1 << 3;
|
|
|
|
void resetImpl() override;
|
|
|
|
public:
|
|
|
|
/**
|
|
* Create a sweep signal
|
|
*
|
|
* @param[in] fl: Lower frequency [Hz]
|
|
* @param[in] fu: Upper frequency [Hz]
|
|
* @param[in] Ts: Sweep time [s]
|
|
* @param[in] Tq: Quescent tail time [s]. Choose this value long enough to
|
|
* avoid temporal aliasing in case of measuring impulse responses.
|
|
* @param[in] sweep_flags: Sweep period [s]
|
|
*/
|
|
Sweep(const d fl, const d fu, const d Ts, const d Tq,
|
|
const us sweep_flags);
|
|
|
|
~Sweep() = default;
|
|
|
|
};
|