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

A DSP host used for building and running tests inside a test case. More...

#include <hart_process_audio.hpp>

Public Member Functions

template<typename DSPType >
 AudioTestBuilder (DSPType &&dsp, typename std::enable_if< std::is_lvalue_reference< DSPType && >::value &&std::is_base_of< DSP< SampleType >, typename std::decay< DSPType >::type >::value >::type *=0)
 Copies the DSP instance into the host.
 
template<typename DSPType >
 AudioTestBuilder (DSPType &&dsp, typename std::enable_if< ! std::is_lvalue_reference< DSPType && >::value &&std::is_base_of< DSP< SampleType >, typename std::decay< DSPType >::type >::value >::type *=0)
 Moves the DSP instance into the host.
 
 AudioTestBuilder (std::unique_ptr< DSP< SampleType > > dsp)
 Transfers the DSP smart pointer into the host.
 
AudioTestBuilderwithSampleRate (double sampleRateHz)
 Sets the sample rate for the test.
 
AudioTestBuilderwithBlockSize (size_t blockSizeFrames)
 Sets the block size for the test.
 
AudioTestBuilderwithValue (int id, double value)
 Sets the initial param value for the tested DSP.
 
AudioTestBuilderwithDuration (double durationSeconds)
 Sets the total duration of the input signal to be processed.
 
AudioTestBuilderwithInputSignal (const Signal< SampleType > &signal)
 Sets the input signal for the test.
 
AudioTestBuilderwithInputChannels (size_t numInputChannels)
 Sets arbitrary number of input channels.
 
AudioTestBuilderwithOutputChannels (size_t numOutputChannels)
 Sets arbitrary number of output channels.
 
AudioTestBuilderwithStereoInput ()
 Sets number of input channels to two.
 
AudioTestBuilderwithStereoOutput ()
 Sets number of output channels to two.
 
AudioTestBuilderwithMonoInput ()
 Sets number of input channels to one.
 
AudioTestBuilderwithMonoOutput ()
 Sets number of output channels to one.
 
AudioTestBuilderinMono ()
 Sets number of input and output channels to one.
 
AudioTestBuilderinStereo ()
 Sets number of input and output channels to two.
 
AudioTestBuilderexpectTrue (const Matcher< SampleType > &matcher)
 Adds an "expect" check.
 
template<typename MatcherType >
AudioTestBuilderexpectTrue (MatcherType &&matcher)
 Adds an "expect" check.
 
AudioTestBuilderexpectFalse (const Matcher< SampleType > &matcher)
 Adds a reversed "expect" check.
 
template<typename MatcherType >
AudioTestBuilderexpectFalse (MatcherType &&matcher)
 Adds a reversed "expect" check.
 
AudioTestBuilderassertTrue (const Matcher< SampleType > &matcher)
 Adds an "assert" check.
 
template<typename MatcherType >
AudioTestBuilderassertTrue (MatcherType &&matcher)
 Adds an "assert" check.
 
AudioTestBuilderassertFalse (const Matcher< SampleType > &matcher)
 Adds a reversed "assert" check.
 
template<typename MatcherType >
AudioTestBuilderassertFalse (MatcherType &&matcher)
 Adds a reversed "assert" check.
 
AudioTestBuildersaveOutputTo (const std::string &path, Save mode=Save::always, WavFormat wavFormat=WavFormat::pcm24)
 Enables saving output audio to a wav file.
 
AudioTestBuildersavePlotTo (const std::string &path, Save mode=Save::always)
 Enables saving a plot to an SVG file.
 
AudioTestBuilderwithLabel (const std::string &testLabel)
 Adds a label to the test.
 
std::unique_ptr< DSP< SampleType > > process ()
 Perfoems the test.
 

Related Symbols

(Note that these are not member symbols.)

template<typename DSPType >
AudioTestBuilder< typename std::decay< DSPType >::type::SampleTypePublicAlias > processAudioWith (DSPType &&dsp)
 Call this to start building your test.
 
template<typename DSPType >
AudioTestBuilder< typename DSPType::SampleTypePublicAlias > processAudioWith (std::unique_ptr< DSPType > &&dsp)
 Call this to start building your test.
 

Detailed Description

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

A DSP host used for building and running tests inside a test case.

Definition at line 38 of file hart_process_audio.hpp.

Constructor & Destructor Documentation

◆ AudioTestBuilder() [1/3]

template<typename SampleType >
template<typename DSPType >
AudioTestBuilder ( DSPType &&  dsp,
typename std::enable_if< std::is_lvalue_reference< DSPType && >::value &&std::is_base_of< DSP< SampleType >, typename std::decay< DSPType >::type >::value >::type *  = 0 
)
inline

Copies the DSP instance into the host.

DSP instance will be moved into this host, and then returned by process(), so you can re-use it.

Parameters
dspYour DSP instance.

Definition at line 45 of file hart_process_audio.hpp.

◆ AudioTestBuilder() [2/3]

template<typename SampleType >
template<typename DSPType >
AudioTestBuilder ( DSPType &&  dsp,
typename std::enable_if< ! std::is_lvalue_reference< DSPType && >::value &&std::is_base_of< DSP< SampleType >, typename std::decay< DSPType >::type >::value >::type *  = 0 
)
inline

Moves the DSP instance into the host.

DSP instance will be moved into this host, and then returned by process(), so you can re-use it.

Parameters
dspYour DSP instance

Definition at line 58 of file hart_process_audio.hpp.

◆ AudioTestBuilder() [3/3]

template<typename SampleType >
AudioTestBuilder ( std::unique_ptr< DSP< SampleType > >  dsp)
inline

Transfers the DSP smart pointer into the host.

Use this if your DSP does not support copying or moving. It will be owned by this host, and then returned by process(), so you can re-use it.

Parameters
dspA smart pointer to your DSP instance

Definition at line 71 of file hart_process_audio.hpp.

Member Function Documentation

◆ withSampleRate()

template<typename SampleType >
AudioTestBuilder & withSampleRate ( double  sampleRateHz)
inline

Sets the sample rate for the test.

All the signals, effects and sub hosts are guaranteed to be initialized to this sample rate

Parameters
sampleRateHzSample rate in Hz. You can use frequency-related literails from Units.

Definition at line 79 of file hart_process_audio.hpp.

◆ withBlockSize()

template<typename SampleType >
AudioTestBuilder & withBlockSize ( size_t  blockSizeFrames)
inline

Sets the block size for the test.

Parameters
blockSizeFramesBlock size in frames (samples)

Definition at line 93 of file hart_process_audio.hpp.

◆ withValue()

template<typename SampleType >
AudioTestBuilder & withValue ( int  id,
double  value 
)
inline

Sets the initial param value for the tested DSP.

It will call DSP::setValue() for DSP under test

Parameters
idParameter ID (see DSP::setValue())
valueValue that needs to be set

Definition at line 106 of file hart_process_audio.hpp.

◆ withDuration()

template<typename SampleType >
AudioTestBuilder & withDuration ( double  durationSeconds)
inline

Sets the total duration of the input signal to be processed.

Parameters
Durationof the signal in seconds. You can use time-related literails from Units.

Definition at line 115 of file hart_process_audio.hpp.

◆ withInputSignal()

template<typename SampleType >
AudioTestBuilder & withInputSignal ( const Signal< SampleType > &  signal)
inline

Sets the input signal for the test.

Parameters
signalInput signal, see Signals

Definition at line 126 of file hart_process_audio.hpp.

◆ withInputChannels()

template<typename SampleType >
AudioTestBuilder & withInputChannels ( size_t  numInputChannels)
inline

Sets arbitrary number of input channels.

For common mono and stereo cases, you may use dedicated methods like inStereo() or withMonoInput() instead of this one for better readability.

Parameters
numInputChannelsNumber of input channels

Definition at line 137 of file hart_process_audio.hpp.

◆ withOutputChannels()

template<typename SampleType >
AudioTestBuilder & withOutputChannels ( size_t  numOutputChannels)
inline

Sets arbitrary number of output channels.

For common mono and stereo cases, you may use dedicated methods like inMono() or withStereoOutput() instead of this one for better readability.

Parameters
numOutputChannelsNumber of output channels

Definition at line 153 of file hart_process_audio.hpp.

◆ withStereoInput()

template<typename SampleType >
AudioTestBuilder & withStereoInput ( )
inline

Sets number of input channels to two.

Definition at line 166 of file hart_process_audio.hpp.

◆ withStereoOutput()

template<typename SampleType >
AudioTestBuilder & withStereoOutput ( )
inline

Sets number of output channels to two.

Definition at line 172 of file hart_process_audio.hpp.

◆ withMonoInput()

template<typename SampleType >
AudioTestBuilder & withMonoInput ( )
inline

Sets number of input channels to one.

Definition at line 178 of file hart_process_audio.hpp.

◆ withMonoOutput()

template<typename SampleType >
AudioTestBuilder & withMonoOutput ( )
inline

Sets number of output channels to one.

Definition at line 184 of file hart_process_audio.hpp.

◆ inMono()

template<typename SampleType >
AudioTestBuilder & inMono ( )
inline

Sets number of input and output channels to one.

Definition at line 190 of file hart_process_audio.hpp.

◆ inStereo()

template<typename SampleType >
AudioTestBuilder & inStereo ( )
inline

Sets number of input and output channels to two.

Definition at line 196 of file hart_process_audio.hpp.

◆ expectTrue() [1/2]

template<typename SampleType >
AudioTestBuilder & expectTrue ( const Matcher< SampleType > &  matcher)
inline

Adds an "expect" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 203 of file hart_process_audio.hpp.

◆ expectTrue() [2/2]

template<typename SampleType >
template<typename MatcherType >
AudioTestBuilder & expectTrue ( MatcherType &&  matcher)
inline

Adds an "expect" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 212 of file hart_process_audio.hpp.

◆ expectFalse() [1/2]

template<typename SampleType >
AudioTestBuilder & expectFalse ( const Matcher< SampleType > &  matcher)
inline

Adds a reversed "expect" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 226 of file hart_process_audio.hpp.

◆ expectFalse() [2/2]

template<typename SampleType >
template<typename MatcherType >
AudioTestBuilder & expectFalse ( MatcherType &&  matcher)
inline

Adds a reversed "expect" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 235 of file hart_process_audio.hpp.

◆ assertTrue() [1/2]

template<typename SampleType >
AudioTestBuilder & assertTrue ( const Matcher< SampleType > &  matcher)
inline

Adds an "assert" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 248 of file hart_process_audio.hpp.

◆ assertTrue() [2/2]

template<typename SampleType >
template<typename MatcherType >
AudioTestBuilder & assertTrue ( MatcherType &&  matcher)
inline

Adds an "assert" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 257 of file hart_process_audio.hpp.

◆ assertFalse() [1/2]

template<typename SampleType >
AudioTestBuilder & assertFalse ( const Matcher< SampleType > &  matcher)
inline

Adds a reversed "assert" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 270 of file hart_process_audio.hpp.

◆ assertFalse() [2/2]

template<typename SampleType >
template<typename MatcherType >
AudioTestBuilder & assertFalse ( MatcherType &&  matcher)
inline

Adds a reversed "assert" check.

Parameters
matcherMatcher to perform the check, see Matchers

Definition at line 279 of file hart_process_audio.hpp.

◆ saveOutputTo()

template<typename SampleType >
AudioTestBuilder & saveOutputTo ( const std::string &  path,
Save  mode = Save::always,
WavFormat  wavFormat = WavFormat::pcm24 
)
inline

Enables saving output audio to a wav file.

Parameters
pathFile path - relative or absolute. If relative path is set, it will be appended to the provided --data-root-path CLI argument.
modeWhen to save, see hart::Save
wavFormatFormat of the wav file, see hart::WavFormat for supported options
See also
HART_REQUIRES_DATA_PATH_ARG

Definition at line 295 of file hart_process_audio.hpp.

◆ savePlotTo()

template<typename SampleType >
AudioTestBuilder & savePlotTo ( const std::string &  path,
Save  mode = Save::always 
)
inline

Enables saving a plot to an SVG file.

This will plot an input and output audio as a waveform

Parameters
pathFile path - relative or absolute. If relative path is set, it will be appended to the provided --data-root-path CLI argument.
modeWhen to save, see hart::Save
See also
HART_REQUIRES_DATA_PATH_ARG

Definition at line 311 of file hart_process_audio.hpp.

◆ withLabel()

template<typename SampleType >
AudioTestBuilder & withLabel ( const std::string &  testLabel)
inline

Adds a label to the test.

Useful when you call process() multiple times in one test case - the label will be put into test failure report to indicate exactly which test has failed.

Parameters
testLabelAny text, to be used as a label

Definition at line 325 of file hart_process_audio.hpp.

◆ process()

template<typename SampleType >
std::unique_ptr< DSP< SampleType > > process ( )
inline

Perfoems the test.

Call this after setting all the test parameters

Definition at line 333 of file hart_process_audio.hpp.


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