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>
DerivedSignal & followedBy (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.
 
DerivedSignal & followedBy (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.
 
DerivedSignal & skipTo (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.
 
bool supportsNumChannelsWithDSPChain (size_t numChannels)
 Checks whether the signal itself, and all the DSP instances in its signal chain support the requested channel number.
 
bool supportsSampleRateWithDSPChain (double sampleRateHz)
 Checks whether the signal itself, and all the DSP instances in its signal chain support the requested sample rate.
 
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< SampleType > operator+ (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< SampleType > operator- (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_maxBlockSizeFrames = 0
 
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 382 of file hart_signal.hpp.

Member Function Documentation

◆ followedBy() [1/4]

template<typename SampleType , typename DerivedSignal >
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 399 of file hart_signal.hpp.

◆ followedBy() [2/4]

template<typename SampleType , typename DerivedSignal >
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 418 of file hart_signal.hpp.

◆ followedBy() [3/4]

template<typename SampleType , typename DerivedSignal >
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 427 of file hart_signal.hpp.

◆ followedBy() [4/4]

template<typename SampleType , typename DerivedSignal >
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 436 of file hart_signal.hpp.

◆ copy()

template<typename SampleType , typename DerivedSignal >
std::unique_ptr< SignalBase< SampleType > > copy ( ) const
inlineoverridevirtual

Returns a smart pointer with a copy of this object.

Implements SignalBase< SampleType >.

Definition at line 442 of file hart_signal.hpp.

◆ move()

template<typename SampleType , typename DerivedSignal >
std::unique_ptr< SignalBase< SampleType > > move ( )
inlineoverridevirtual

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

Implements SignalBase< SampleType >.

Definition at line 447 of file hart_signal.hpp.

◆ skipTo() [1/2]

template<typename SampleType , typename DerivedSignal >
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 457 of file hart_signal.hpp.

◆ skipTo() [2/2]

template<typename SampleType , typename DerivedSignal >
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 468 of file hart_signal.hpp.

◆ operator-()

template<typename SampleType , typename DerivedSignal >
DerivedSignal operator- ( ) const
inline

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

Definition at line 475 of file hart_signal.hpp.

◆ operator~()

template<typename SampleType , typename DerivedSignal >
DerivedSignal operator~ ( ) const
inline

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

Definition at line 483 of file hart_signal.hpp.


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