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

Produces a mix of multiple signals. More...

#include <hart_mixed_signal.hpp>

Inheritance diagram for MixedSignal< SampleType >:

Public Member Functions

 MixedSignal ()=default
 Default constructor.
 
 ~MixedSignal ()=default
 Destructor.
 
 MixedSignal (const SignalBase< SampleType > &signalA, const SignalBase< SampleType > &signalB)
 Creates a MixedSignals from two existing signals.
 
 MixedSignal (const MixedSignal &other)
 Copies other MixedSignal.
 
 MixedSignal (MixedSignal &&other) noexcept
 Moves from other MixedSignal.
 
MixedSignaloperator= (const MixedSignal &other)
 Copies other MixedSignal.
 
MixedSignaloperator= (MixedSignal &&other) noexcept
 Moves from other MixedSignal.
 
void prepare (double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames) override
 Prepare the signal for rendering.
 
void renderNextBlock (AudioBuffer< SampleType > &output) override
 Renders next block audio for the signal.
 
void reset () override
 Resets the Signal to initial state.
 
void represent (std::ostream &s) const override
 Makes a text representation of this Signal for test failure outputs.
 
- Public Member Functions inherited from Signal< SampleType, MixedSignal< SampleType > >
MixedSignal< SampleType > & followedBy (const DSPBase< SampleType > &dsp)
 Adds a DSP effect to the end of signal's DSP chain by copying it.
 
SignalfollowedBy (std::unique_ptr< DSPBase< SampleType > > dsp)
 Adds a DSP effect to the end of signal's DSP chain by transfering a smart pointer.
 
SignalfollowedBy (DerivedDSP &&dsp)
 Adds a DSP effect to the end of signal's DSP chain by moving it.
 
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.
 
MixedSignal< SampleType > & skipTo (double startTimestampSeconds)
 Skips the signal to a specific timestamp.
 
MixedSignal< SampleTypeoperator- () const
 Returns a copy of this signal, but with flipped phase.
 
MixedSignal< SampleTypeoperator~ () 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.
 
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.
 

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 > > > dspChain
 

Detailed Description

template<typename SampleType>
class hart::MixedSignal< SampleType >

Produces a mix of multiple signals.

You get this class as a result of adding or subtracting signals, so you don't want to instantiate it directly.

Definition at line 16 of file hart_mixed_signal.hpp.

Constructor & Destructor Documentation

◆ MixedSignal() [1/4]

template<typename SampleType >
MixedSignal ( )
default

Default constructor.

◆ ~MixedSignal()

template<typename SampleType >
~MixedSignal ( )
default

Destructor.

◆ MixedSignal() [2/4]

template<typename SampleType >
MixedSignal ( const SignalBase< SampleType > &  signalA,
const SignalBase< SampleType > &  signalB 
)
inline

Creates a MixedSignals from two existing signals.

For internal use by "+" and "-" operators, so you probably don't want to call it directly.

Parameters
signalASignal to add to the mix
signalBAnother signal to add to the mix

Definition at line 32 of file hart_mixed_signal.hpp.

◆ MixedSignal() [3/4]

template<typename SampleType >
MixedSignal ( const MixedSignal< SampleType > &  other)
inline

Copies other MixedSignal.

Definition at line 39 of file hart_mixed_signal.hpp.

◆ MixedSignal() [4/4]

template<typename SampleType >
MixedSignal ( MixedSignal< SampleType > &&  other)
inlinenoexcept

Moves from other MixedSignal.

Definition at line 49 of file hart_mixed_signal.hpp.

Member Function Documentation

◆ operator=() [1/2]

template<typename SampleType >
MixedSignal & operator= ( const MixedSignal< SampleType > &  other)
inline

Copies other MixedSignal.

Definition at line 56 of file hart_mixed_signal.hpp.

◆ operator=() [2/2]

template<typename SampleType >
MixedSignal & operator= ( MixedSignal< SampleType > &&  other)
inlinenoexcept

Moves from other MixedSignal.

Definition at line 75 of file hart_mixed_signal.hpp.

◆ prepare()

template<typename SampleType >
void prepare ( double  sampleRateHz,
size_t  numOutputChannels,
size_t  maxBlockSizeFrames 
)
inlineoverridevirtual

Prepare the signal for rendering.

This method is guaranteed to be called after supportsNumChannels() and supportsSampleRate(), but before renderNextBlock(). It is guaranteed that numChannels obeys supportsNumChannels() preferences, same with sampleRateHz and supportsSampleRate(). It is guaranteed that all subsequent renderNextBlock() calls will be in line with the arguments received in this callback.

Parameters
sampleRateHzsample rate at which the audio should be generated
numOutputChannelsNumber of output channels to be filled
maxBlockSizeFramesMaximum block size in frames (samples)

Implements SignalBase< SampleType >.

Definition at line 86 of file hart_mixed_signal.hpp.

◆ renderNextBlock()

template<typename SampleType >
void renderNextBlock ( AudioBuffer< SampleType > &  output)
inlineoverridevirtual

Renders next block audio for the signal.

Depending on circumstances, this callback will either be called once to generate an entire piece of audio from start to finish, or called repeatedly, one block at a time. This method is guaranteed to be called strictly after prepare(), or not called at all. Number of channels and max block size are guaranteed to be in line with the ones set by prepare() callback. Assume sample rate to always be equal to the one received in the last prepare() callback. All audio blocks except the last one are guaranteed to be equal to maxBlockSizeFrames set in prepare() callback.

Warning
Remember that the very last block of audio is almost always smaller than the block size set in prepare(), so be careful with buffer bounds.
Note
Note that this method does not have to be real-time safe, as all rendering always happens offline. Also note that, unlike real-time audio applications, this method is called on the same thread as all others like prepare().
Parameters
outputOutput audio block
Warning
Output audio buffer is not guaranteed to be pre-filled with zeros, it may contain junk data.

Implements SignalBase< SampleType >.

Definition at line 92 of file hart_mixed_signal.hpp.

◆ reset()

template<typename SampleType >
void reset ( )
inlineoverridevirtual

Resets the Signal to initial state.

Ideally should be implemented in a way that audio produced after resetting is identical to audio produced after instantiation

Implements SignalBase< SampleType >.

Definition at line 118 of file hart_mixed_signal.hpp.

◆ represent()

template<typename SampleType >
void represent ( std::ostream &  stream) const
inlineoverridevirtual

Makes a text representation of this Signal for test failure outputs.

It is strongly encouraged to follow python's repr() conventions for returned text - basically, put something like "MyClass(value1, value2)" (with no quotes) into the stream whenever possible, or "<Readable info in angled brackets>" otherwise. Also, use built-in stream manipulators like dbPrecision wherever applicable. Use HART_DEFINE_GENERIC_REPRESENT() to get a basic implementation for this method.

Parameters
[out]streamOutput stream to write to

Implements SignalBase< SampleType >.

Definition at line 124 of file hart_mixed_signal.hpp.


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