HART  0.1.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
Signals

Generate signals. More...

Classes

class  Signal< SampleType >
 Base class for signals. More...
 
class  Silence< SampleType >
 Produces silence (zeros) More...
 
class  SineSweep< SampleType >
 Produces a sine sweep. More...
 
class  SineWave< SampleType >
 Produces a sine wave at fixed frequency. More...
 
class  WavFile< SampleType >
 Produces audio from a wav file. More...
 
class  WhiteNoise< SampleType >
 Produces deterministic white noise. More...
 

Macros

#define HART_SIGNAL_DEFINE_COPY_AND_MOVE(ClassName)
 Defines hart::Signal::copy() and hart::Signal::move() methods.
 
#define HART_SIGNAL_FORBID_COPY_AND_MOVE
 Forbids hart::Signal::copy() and hart::Signal::move() methods.
 

Functions

template<typename SampleType >
std::ostream & operator<< (std::ostream &stream, const Signal< SampleType > &signal)
 Prints readable text representation of the Signal object into the I/O stream.
 
template<typename SampleType , typename DerivedDSP , typename std::enable_if< std::is_base_of< DSP< SampleType >, typename std::decay< DerivedDSP >::type >::value >::type >
Signal< SampleType > & operator>> (Signal< SampleType > &signal, DerivedDSP &&dsp)
 Adds a DSP effect to the end of signal's DSP chain by moving it.
 
template<typename SampleType >
Signal< SampleType > & operator>> (Signal< SampleType > &signal, const DSP< SampleType > &dsp)
 Adds a DSP effect to the end of signal's DSP chain by copying it.
 
template<typename SampleType >
Signal< SampleType > && operator>> (Signal< SampleType > &&signal, const DSP< SampleType > &dsp)
 Adds a DSP effect to the end of signal's DSP chain by copying it.
 
template<typename SampleType >
Signal< SampleType > & operator>> (Signal< SampleType > &signal, std::unique_ptr< DSP< SampleType > > dsp)
 Adds a DSP effect to the end of signal's DSP chain by transfering it.
 
template<typename SampleType >
Signal< SampleType > && operator>> (Signal< SampleType > &&signal, std::unique_ptr< DSP< SampleType > > dsp)
 Adds a DSP effect to the end of signal's DSP chain by transfering it.
 

Detailed Description

Generate signals.

Macro Definition Documentation

◆ HART_SIGNAL_DEFINE_COPY_AND_MOVE

#define HART_SIGNAL_DEFINE_COPY_AND_MOVE (   ClassName)
Value:
std::unique_ptr<Signal<SampleType>> copy() const override { \
return hart::make_unique<ClassName> (*this); \
} \
std::unique_ptr<Signal<SampleType>> move() override { \
return hart::make_unique<ClassName> (std::move (*this)); \
}

Defines hart::Signal::copy() and hart::Signal::move() methods.

Put this into your class body's public section if either is true:

  • Your class is trivially copyable and movable
  • You have your Rule Of Five methods explicitly defined in this class (see Rule Of Three/Five/Zero)

If neither of those is true, or you're unsure, use HART_SIGNAL_FORBID_COPY_AND_MOVE instead

Despite returning a smart pointer to an abstract Signal class, those two methods must construct an object of a specific class, hence the mandatory boilerplate methods - sorry!

Parameters
ClassNameName of your class

Definition at line 346 of file hart_signal.hpp.

◆ HART_SIGNAL_FORBID_COPY_AND_MOVE

#define HART_SIGNAL_FORBID_COPY_AND_MOVE
Value:
std::unique_ptr<Signal<SampleType>> copy() const override { \
static_assert(false, "This Signal cannot be copied"); \
return nullptr; \
} \
std::unique_ptr<Signal<SampleType>> move() override { \
static_assert(false, "This Signal cannot be moved"); \
return nullptr; \
}

Forbids hart::Signal::copy() and hart::Signal::move() methods.

Put this into your class body's public section if either is true:

  • Your class is not trivially copyable and movable
  • You don't want to trouble yourself with implementing move and copy semantics for your class

Otherwise, use HART_SIGNAL_DEFINE_COPY_AND_MOVE() instead. Obviously, you won't be able to pass your class to the host by reference, copy or explicit move, but you still can pass it wrapped into a smart pointer like so:

processAudioWith (MyDSP())
.withInputSignal(hart::make_unique<MyDspType>()) // As input signal
.expectTrue (EqualsTo (hart::make_unique<MyDspType>())) // As reference signal
.process();

Definition at line 370 of file hart_signal.hpp.

Function Documentation

◆ operator<<()

template<typename SampleType >
std::ostream & operator<< ( std::ostream &  stream,
const Signal< SampleType > &  signal 
)
related

Prints readable text representation of the Signal object into the I/O stream.

Definition at line 278 of file hart_signal.hpp.

◆ operator>>() [1/5]

template<typename SampleType , typename DerivedDSP , typename std::enable_if< std::is_base_of< DSP< SampleType >, typename std::decay< DerivedDSP >::type >::value >::type >
Signal< SampleType > & operator>> ( Signal< SampleType > &  signal,
DerivedDSP &&  dsp 
)
related

Adds a DSP effect to the end of signal's DSP chain by moving it.

Definition at line 289 of file hart_signal.hpp.

◆ operator>>() [2/5]

template<typename SampleType >
Signal< SampleType > & operator>> ( Signal< SampleType > &  signal,
const DSP< SampleType > &  dsp 
)
related

Adds a DSP effect to the end of signal's DSP chain by copying it.

Definition at line 298 of file hart_signal.hpp.

◆ operator>>() [3/5]

template<typename SampleType >
Signal< SampleType > && operator>> ( Signal< SampleType > &&  signal,
const DSP< SampleType > &  dsp 
)
related

Adds a DSP effect to the end of signal's DSP chain by copying it.

Definition at line 307 of file hart_signal.hpp.

◆ operator>>() [4/5]

template<typename SampleType >
Signal< SampleType > & operator>> ( Signal< SampleType > &  signal,
std::unique_ptr< DSP< SampleType > >  dsp 
)
related

Adds a DSP effect to the end of signal's DSP chain by transfering it.

Definition at line 316 of file hart_signal.hpp.

◆ operator>>() [5/5]

template<typename SampleType >
Signal< SampleType > && operator>> ( Signal< SampleType > &&  signal,
std::unique_ptr< DSP< SampleType > >  dsp 
)
related

Adds a DSP effect to the end of signal's DSP chain by transfering it.

Definition at line 326 of file hart_signal.hpp.