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

Base for DSP effects. More...

#include <hart_dsp.hpp>

Inheritance diagram for DSP< SampleType, Derived >:

Public Member Functions

DerivedwithEnvelope (int paramId, Envelope &&envelope)
 Adds envelope to a specific parameter by moving it.
 
DerivedwithEnvelope (int paramId, const Envelope &envelope)
 Adds envelope to a specific parameter by copying it.
 
virtual std::unique_ptr< DSPBase< SampleType > > copy () const override
 Returns a smart pointer with a copy of this object.
 
virtual std::unique_ptr< DSPBase< SampleType > > move () override
 Returns a smart pointer with a moved instance of this object.
 
DerivedatChannels (std::initializer_list< size_t > channelsToProcess)
 Makes this DSP process only specific channels, and ignore the rest.
 
DerivedatChannel (size_t channelToProcess)
 Makes this DSP process only specific channels, and bypass the rest.
 
DerivedatAllChannels ()
 Makes this DSP apply to all channels.
 
DerivedatAllChannelsExcept (std::initializer_list< size_t > channelsToSkip)
 Makes this DSP process only specific channels, and bypass the rest.
 
- Public Member Functions inherited from DSPBase< SampleType >
virtual void prepare (double sampleRateHz, size_t numInputChannels, size_t numOutputChannels, size_t maxBlockSizeFrames)=0
 Prepare for processing.
 
virtual void process (const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output, const EnvelopeBuffers &envelopeBuffers, ChannelFlags channelsToProcess)=0
 Processes the audio.
 
virtual void reset ()=0
 Resets to initial state.
 
virtual void setValue (int paramId, double value)=0
 Sets DSP value.
 
virtual double getValue (int paramId) const =0
 Retrieves DSP value.
 
virtual bool supportsChannelLayout (size_t numInputChannels, size_t numOutputChannels) const =0
 Tells the runner (host) whether this effect supports a specific i/o configuration.
 
virtual void represent (std::ostream &stream) const =0
 Makes a text representation of this DSP effect for test failure outputs.
 
virtual bool supportsEnvelopeFor (int) const
 Tells whether this effect accepts automation envelopes for a particular parameter.
 
virtual bool supportsSampleRate (double) const
 Tells whether this effect supports given sample rate.
 
virtual ~DSPBase ()=default
 Destructor.
 
 DSPBase ()=default
 Default constructor.
 
 DSPBase (const DSPBase &other)
 Copies from another DSP effect instance.
 
 DSPBase (DSPBase &&other) noexcept
 Move constructor.
 
DSPBaseoperator= (const DSPBase &other)
 Copies from another DSP effect instance.
 
DSPBaseoperator= (DSPBase &&other) noexcept
 Move assignment.
 
bool hasEnvelopeFor (int paramId)
 Checks if there's an automation envelope attached to a specific parameter.
 
void prepareWithEnvelopes (double sampleRateHz, size_t numInputChannels, size_t numOutputChannels, size_t maxBlockSizeFrames)
 Prepares all the attached envelopes and the effect itself for processing.
 
ChannelFlags getChannelsToProcess ()
 Returns a structure indicating which channels should be processed by this DSP.
 
void processWithEnvelopes (const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output)
 Renders all the automation envelopes and processes the audio.
 
void representWithActiveChannels (std::ostream &stream) const
 Makes a text representation of this DSP with optional "atChannels" appendix.
 

Related Symbols

(Note that these are not member symbols.)

template<typename SampleType >
std::ostream & operator<< (std::ostream &stream, const DSPBase< SampleType > &dsp)
 Prints readable text representation of the DSP object into the I/O stream.
 

Additional Inherited Members

- Protected Attributes inherited from DSPBase< SampleType >
std::unordered_map< int, std::unique_ptr< Envelope > > m_envelopes
 
ChannelFlags m_channelsToProcess {true}
 

Detailed Description

template<typename SampleType, typename Derived>
class hart::DSP< SampleType, Derived >

Base for DSP effects.

This class is used both for adapting your DSP classes that you wish to test, and for using in DSP chains of Signals, so you can use stock effects like GainDb as tested processors, and you can use your tested DSP subclasses in Signals' DSP chains with other effects. You can even chain multiple of your own DSP classes together this way. All the callbacks of this class are guaranteed to be called from the same thread. To make your custom DSP wrapper, inherit from it like so (note the CRTP in the template args here, it's important!):

template<typename SampleType>
class MyCustomDSP: public DSP<SampleType, MyCustomDSP<SampleType>>
{
// ...
};
Base for DSP effects.
Definition hart_dsp.hpp:322
Template Parameters
SampleTypeType of values that will be processed, typically float or double
DerivedSubclass for CRTP

Definition at line 320 of file hart_dsp.hpp.

Member Function Documentation

◆ withEnvelope() [1/2]

Derived & withEnvelope ( int  paramId,
Envelope &&  envelope 
)
inline

Adds envelope to a specific parameter by moving it.

Guaranteed to be called strictly after the supportsEnvelopeFor() callback, and only if it has returned true for this specific paramId. Can be chained together like myEffect.withEnvelope (someId, someEnvelope).withEnvelope (otherId, otherEnvelope). If called multiple times for the same paramId, only last envelope for this ID will be used, all previous ones will be descarded.

Parameters
paramIdSome ID that your subclass understands
envelopeEnvelope to be attached
Returns
Reference to itself for chaining

Definition at line 333 of file hart_dsp.hpp.

◆ withEnvelope() [2/2]

Derived & withEnvelope ( int  paramId,
const Envelope envelope 
)
inline

Adds envelope to a specific parameter by copying it.

Guaranteed to be called strictly after the supportsEnvelopeFor() callback, and only if it has returned true for this specific paramId. Can be chained together like myEffect.withEnvelope (someId, someEnvelope).withEnvelope (otherId, otherEnvelope). If called multiple times for the same paramId, only last envelope for this ID will be used, all previous ones will be descarded.

Parameters
paramIdSome ID that your subclass understands
envelopeEnvelope to be attached
Returns
Reference to itself for chaining

Definition at line 350 of file hart_dsp.hpp.

◆ copy()

virtual std::unique_ptr< DSPBase< SampleType > > copy ( ) const
inlineoverridevirtual

Returns a smart pointer with a copy of this object.

Implements DSPBase< SampleType >.

Definition at line 362 of file hart_dsp.hpp.

◆ move()

virtual std::unique_ptr< DSPBase< SampleType > > move ( )
inlineoverridevirtual

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

Implements DSPBase< SampleType >.

Definition at line 368 of file hart_dsp.hpp.

◆ atChannels()

Derived & atChannels ( std::initializer_list< size_t channelsToProcess)
inline

Makes this DSP process only specific channels, and ignore the rest.

If not set, the DSP applies to all channels by default. If you call this method multiple times, only the last one will be applied. To select only one channel, consider using DSP::atChannel() instead.

Parameters
channelsToProcessList of channels this DSP should apply to, e.g. {0, 1} or {Channel::left, Channel::right} for left and right channels only.
See also
hart::Channel

Definition at line 380 of file hart_dsp.hpp.

◆ atChannel()

Derived & atChannel ( size_t  channelToProcess)
inline

Makes this DSP process only specific channels, and bypass the rest.

If not set, the DSP applies to all channels by default. If you call this method multiple times, only the last one will be applied. To select multiple channels, use DSP::atChannels() or atAllChannelsExcept() instead.

Parameters
channelToProcessChannel this DSP should apply to (zero-based), e.g. 0 or Channel::left for left channel.
Note
If not set, the DSP applies to all channels by default
See also
hart::Channel

Definition at line 404 of file hart_dsp.hpp.

◆ atAllChannels()

Derived & atAllChannels ( )
inline

Makes this DSP apply to all channels.

This is the default setting anyway, so this method is only for cases when you need to override previous atChannel(), atChannels() or atAllChannelsExcept() calls.

Definition at line 419 of file hart_dsp.hpp.

◆ atAllChannelsExcept()

Derived & atAllChannelsExcept ( std::initializer_list< size_t channelsToSkip)
inline

Makes this DSP process only specific channels, and bypass the rest.

If not set, DSP applies to all channels by default. If you call this method multiple times, only the last one will be applied.

Parameters
channelsToSkipList of channels this DSP should NOT apply to, e.g. {0, 1} or {Channel::left, Channel::right} to bypass left and right channels, and process the rest
See also
hart::Channel

Definition at line 432 of file hart_dsp.hpp.


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