HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
Signal< SampleType, DerivedSignal > Class Template Reference

Base class for signals. More...

#include <hart_signal.hpp>

Inheritance diagram for Signal< SampleType, DerivedSignal >:

Public Member Functions

template<typename DerivedDSP , typename = typename std::enable_if< ! std::is_lvalue_reference<DerivedDSP>::value && std::is_base_of< DSPBase<SampleType>, typename std::decay<DerivedDSP>::type >::value >::type>
DerivedSignalfollowedBy (DerivedDSP &&dsp) &
 Adds a DSP effect to the end of signal's DSP chain.
 
template<typename DerivedDSP , typename = typename std::enable_if< ! std::is_lvalue_reference<DerivedDSP>::value && std::is_base_of< DSPBase<SampleType>, typename std::decay<DerivedDSP>::type >::value >::type>
DerivedSignal && followedBy (DerivedDSP &&dsp) &&
 Adds a DSP effect to the end of signal's DSP chain.
 
DerivedSignalfollowedBy (std::unique_ptr< DSPBase< SampleType > > dsp) &
 Adds a DSP effect to the end of signal's DSP chain.
 
DerivedSignal && followedBy (std::unique_ptr< DSPBase< SampleType > > dsp) &&
 Adds a DSP effect to the end of signal's DSP chain.
 
std::unique_ptr< SignalBase< SampleType > > copy () const override
 Returns a smart pointer with a copy of this object.
 
std::unique_ptr< SignalBase< SampleType > > move () override
 Returns a smart pointer with a moved instance of this object.
 
DerivedSignalskipTo (double startTimestampSeconds) &
 Skips the signal to a specific timestamp.
 
DerivedSignal && skipTo (double startTimestampSeconds) &&
 Skips the signal to a specific timestamp.
 
DerivedSignal operator- () const
 Returns a copy of this signal, but with flipped phase.
 
DerivedSignal operator~ () const
 Returns a copy of this signal, but with flipped phase.
 
- Public Member Functions inherited from SignalBase< SampleType >
 SignalBase ()=default
 Default constructor.
 
 SignalBase (const SignalBase &other)
 Copies other signal.
 
 SignalBase (SignalBase &&other) noexcept
 Moves from other signal.
 
virtual ~SignalBase ()=default
 Destructor.
 
SignalBaseoperator= (const SignalBase &other)
 Copies from other signal.
 
SignalBaseoperator= (SignalBase &&other) noexcept
 Moves from other signal.
 
virtual bool supportsNumChannels (size_t) const
 Tells the host whether this Signal is capable of generating audio for a certain amount of channels.
 
virtual bool supportsSampleRate (double) const
 Tells whether this Signal supports given sample rate.
 
virtual void prepare (double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames)=0
 Prepare the signal for rendering.
 
virtual void renderNextBlock (AudioBuffer< SampleType > &output)=0
 Renders next block audio for the signal.
 
virtual void reset ()=0
 Resets the Signal to initial state.
 
virtual void represent (std::ostream &stream) const =0
 Makes a text representation of this Signal for test failure outputs.
 
void prepareWithDSPChain (double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames)
 Prepares the signal and all attached effects in the DSP chain for rendering.
 
void renderNextBlockWithDSPChain (AudioBuffer< SampleType > &output)
 Renders next block audio for the signal and all the effects in the DSP chain.
 
virtual void resetWithDSPChain ()
 Resets to Signal and all the effects attached to its DSP chain to initial state.
 
size_t getDSPChainSize () const
 Returns the size of the DSP chain attached to the Signal.
 
DSPBase< SampleType > * getDSP (int index=-1) const
 Access a specific element in the DSP chain.
 
std::unique_ptr< DSPBase< SampleType > > popDSP (int index=-1)
 Extract a specific element in the DSP chain by removing it.
 

Related Symbols

(Note that these are not member symbols.)

template<typename SampleType , typename DerivedSignalTypeLHS , typename DerivedSignalTypeRHS >
MixedSignal< SampleTypeoperator+ (const Signal< SampleType, DerivedSignalTypeLHS > &lhs, const Signal< SampleType, DerivedSignalTypeRHS > &rhs)
 Adds one signal to another, resulting in a new mixed signal.
 
template<typename SampleType , typename DerivedSignalTypeLHS , typename DerivedSignalTypeRHS >
MixedSignal< SampleTypeoperator- (const Signal< SampleType, DerivedSignalTypeLHS > &lhs, const Signal< SampleType, DerivedSignalTypeRHS > &rhs)
 Subtracts one signal from another, resulting in a new mixed signal.
 
template<typename SampleType >
std::ostream & operator<< (std::ostream &stream, const SignalBase< SampleType > &signal)
 Prints readable text representation of the Signal object into the I/O stream.
 
template<typename DerivedSignal , typename DerivedDSP >
auto operator>> (DerivedSignal &signal, DerivedDSP &&dsp) -> decltype(signal.followedBy(std::forward< DerivedDSP >(dsp)))
 Adds a DSP effect to the end of signal's DSP chain by transfering it.
 
template<typename DerivedSignal , typename DerivedDSP >
auto operator>> (DerivedSignal &&signal, DerivedDSP &&dsp) -> decltype(std::move(signal).followedBy(std::forward< DerivedDSP >(dsp)))
 Adds a DSP effect to the end of signal's DSP chain by transfering it.
 

Additional Inherited Members

- Protected Member Functions inherited from SignalBase< SampleType >
void setNumChannels (size_t numChannels)
 
size_t getNumChannels ()
 
- Protected Attributes inherited from SignalBase< SampleType >
size_t m_numChannels = 1
 
double m_startTimestampSeconds = 0.0
 
std::vector< std::unique_ptr< DSPBase< SampleType > > > m_dspChain
 

Detailed Description

template<typename SampleType, typename DerivedSignal>
class hart::Signal< SampleType, DerivedSignal >

Base class for signals.

Template Parameters
SampleTypeType of values that will be generated, typically float or double
DerivedSignalSubclass for CRTP

Definition at line 348 of file hart_signal.hpp.

Member Function Documentation

◆ followedBy() [1/4]

template<typename DerivedDSP , typename = typename std::enable_if< ! std::is_lvalue_reference<DerivedDSP>::value && std::is_base_of< DSPBase<SampleType>, typename std::decay<DerivedDSP>::type >::value >::type>
DerivedSignal & followedBy ( DerivedDSP &&  dsp) &
inline

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

Note
You can only add a DSP by moving it, since some of the custom DSP wrappers can be non-copyable. If you do want to copy a dsp to the chain, use its DSPBase::copy() method explicitly.
Parameters
dspA DSP effect instance

Definition at line 365 of file hart_signal.hpp.

◆ followedBy() [2/4]

template<typename DerivedDSP , typename = typename std::enable_if< ! std::is_lvalue_reference<DerivedDSP>::value && std::is_base_of< DSPBase<SampleType>, typename std::decay<DerivedDSP>::type >::value >::type>
DerivedSignal && followedBy ( DerivedDSP &&  dsp) &&
inline

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

Note
You can only add a DSP by moving it, since some of the custom DSP wrappers can be non-copyable. If you do want to copy a dsp to the chain, use its DSPBase::copy() method explicitly.
Parameters
dspA DSP effect instance

Definition at line 384 of file hart_signal.hpp.

◆ followedBy() [3/4]

DerivedSignal & followedBy ( std::unique_ptr< DSPBase< SampleType > >  dsp) &
inline

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

Note
DSP smart pointer ownership will be transferred to the Signal instance
Parameters
dspSmart pointer to DSP effect instance

Definition at line 393 of file hart_signal.hpp.

◆ followedBy() [4/4]

DerivedSignal && followedBy ( std::unique_ptr< DSPBase< SampleType > >  dsp) &&
inline

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

Note
DSP smart pointer ownership will be transferred to the Signal instance
Parameters
dspSmart pointer to DSP effect instance

Definition at line 402 of file hart_signal.hpp.

◆ copy()

std::unique_ptr< SignalBase< SampleType > > copy ( ) const
inlineoverridevirtual

Returns a smart pointer with a copy of this object.

Implements SignalBase< SampleType >.

Definition at line 408 of file hart_signal.hpp.

◆ move()

std::unique_ptr< SignalBase< SampleType > > move ( )
inlineoverridevirtual

Returns a smart pointer with a moved instance of this object.

Implements SignalBase< SampleType >.

Definition at line 413 of file hart_signal.hpp.

◆ skipTo() [1/2]

DerivedSignal & skipTo ( double  startTimestampSeconds) &
inline

Skips the signal to a specific timestamp.

Fast-forwards the signal, with all attaches DSP effects and their automation envelopes. Calling it multiple times on one instance will stack the skip times.

Note
Keep in mind that the skip is accurate within one audio frame tolerance
Parameters
startTimestampSecondsHow much time to skip from the start of the signal

Definition at line 423 of file hart_signal.hpp.

◆ skipTo() [2/2]

DerivedSignal && skipTo ( double  startTimestampSeconds) &&
inline

Skips the signal to a specific timestamp.

Fast-forwards the signal, with all attaches DSP effects and their automation envelopes. Calling it multiple times on one instance will stack the skip times.

Note
Keep in mind that the skip is accurate within one audio frame tolerance
Parameters
startTimestampSecondsHow much time to skip from the start of the signal

Definition at line 434 of file hart_signal.hpp.

◆ operator-()

Returns a copy of this signal, but with flipped phase.

Definition at line 441 of file hart_signal.hpp.

◆ operator~()

DerivedSignal operator~ ( ) const
inline

Returns a copy of this signal, but with flipped phase.

Definition at line 449 of file hart_signal.hpp.


The documentation for this class was generated from the following files: