|
HART
0.2.0
High level Audio Regression and Testing
|
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< DSPBase< SampleType >, typename std::decay< DSPType >::type >::value >::type *=0) | |
| Moves the DSP instance into the host. | |
| AudioTestBuilder (std::unique_ptr< DSPBase< SampleType > > dsp) | |
| Transfers the DSP smart pointer into the host. | |
| AudioTestBuilder & | withSampleRate (double sampleRateHz) |
| Sets the sample rate for the test. | |
| AudioTestBuilder & | withBlockSize (size_t blockSizeFrames) |
| Sets the block size for the test. | |
| AudioTestBuilder & | withValue (int id, double value) |
| Sets the initial param value for the tested DSP. | |
| AudioTestBuilder & | withDuration (double durationSeconds) |
| Sets the total duration of the input signal to be processed. | |
| AudioTestBuilder & | withDspPreparation (Preparation dspPreparation) |
| Sets whether to call reset() and/or prepare() on DSP testee before rendering audio. | |
| AudioTestBuilder & | withSignalPreparation (Preparation signalPreparation) |
| Sets whether to call reset() and/or prepare() on the input Signal before rendering audio. | |
| AudioTestBuilder & | withWarmUp (double warmUpDurationSeconds, Preparation signalPreparation=Preparation::none, Preparation dspPreparation=Preparation::none) |
| Adds a warm‑up period before the main test. | |
| AudioTestBuilder & | withInputSignal (const SignalBase< SampleType > &signal) |
| Sets the input signal for the test by copying it. | |
| AudioTestBuilder & | withInputSignal (SignalBase< SampleType > &&signal) |
| Sets the input signal for the test by moving it. | |
| AudioTestBuilder & | withInputSignal (std::unique_ptr< SignalBase< SampleType > > signal) |
| Sets the input signal for the test by transfering its smart pointer. | |
| AudioTestBuilder & | withInputSignal (std::function< void(AudioBuffer< SampleType > &)> signalFunction, const std::string &label={}, Loop loop=Loop::yes) |
| Sets the input signal using a function-based signal definition. | |
| AudioTestBuilder & | withInputChannels (size_t numInputChannels) |
| Sets arbitrary number of input channels. | |
| AudioTestBuilder & | withOutputChannels (size_t numOutputChannels) |
| Sets arbitrary number of output channels. | |
| AudioTestBuilder & | withStereoInput () |
| Sets number of input channels to two. | |
| AudioTestBuilder & | withStereoOutput () |
| Sets number of output channels to two. | |
| AudioTestBuilder & | withMonoInput () |
| Sets number of input channels to one. | |
| AudioTestBuilder & | withMonoOutput () |
| Sets number of output channels to one. | |
| AudioTestBuilder & | inMono () |
| Sets number of input and output channels to one. | |
| AudioTestBuilder & | inStereo () |
| Sets number of input and output channels to two. | |
| template<typename MatcherType > | |
| AudioTestBuilder & | expectTrue (MatcherType &&matcher) |
| Adds an "expect" check using a Matcher object. | |
| template<typename MatcherType > | |
| AudioTestBuilder & | expectFalse (MatcherType &&matcher) |
| Adds a reversed "expect" check using a Matcher object. | |
| template<typename MatcherType > | |
| AudioTestBuilder & | assertTrue (MatcherType &&matcher) |
| Adds an "assert" check using a Matcher object. | |
| template<typename MatcherType > | |
| AudioTestBuilder & | assertFalse (MatcherType &&matcher) |
| Adds a reversed "assert" check using a Matcher object. | |
| AudioTestBuilder & | expectTrue (std::function< Condition(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "expect" check using a function matcher. | |
| AudioTestBuilder & | expectTrue (std::function< Condition(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "expect" check using a function matcher. | |
| AudioTestBuilder & | expectFalse (std::function< Condition(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "expect" check using a function matcher. | |
| AudioTestBuilder & | expectFalse (std::function< Condition(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "expect" check using a function matcher. | |
| AudioTestBuilder & | assertTrue (std::function< Condition(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "assert" check using a function matcher. | |
| AudioTestBuilder & | assertTrue (std::function< Condition(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "assert" check using a function matcher. | |
| AudioTestBuilder & | assertFalse (std::function< Condition(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "assert" check using a function matcher. | |
| AudioTestBuilder & | assertFalse (std::function< Condition(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "assert" check using a function matcher. | |
| AudioTestBuilder & | saveOutputTo (const std::string &path, Save mode=Save::always, WavFormat wavFormat=WavFormat::pcm24) |
| Enables saving output audio to a wav file. | |
| AudioTestBuilder & | saveOutputTo (AudioBuffer< SampleType > &receivingBuffer) |
| Enables saving output audio to a provided buffer. | |
| AudioTestBuilder & | saveOutputTo (std::function< void(AudioBuffer< SampleType > &&)> outputBufferSink) |
| Enables saving output audio via provided callback. | |
| AudioTestBuilder & | savePlotTo (const std::string &path, Save mode=Save::always) |
| Enables saving a plot to an SVG file. | |
| AudioTestBuilder & | saveInputSignalTo (std::unique_ptr< SignalBase< SampleType > > &receivingSignal) |
| Moves the input signal after the processing into the provided smart pointer. | |
| AudioTestBuilder & | saveInputSignalTo (std::function< void(std::unique_ptr< SignalBase< SampleType > > &&)> inputSignalSink) |
| Moves the input signal after the processing via provided callback. | |
| AudioTestBuilder & | withLabel (const std::string &testLabel) |
| Adds a label to the test. | |
| std::unique_ptr< DSPBase< SampleType > > | process () |
| Performs the test. | |
A DSP host used for building and running tests inside a test case.
Definition at line 52 of file hart_process_audio.hpp.
|
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. You can only pass a DSP by moving it, since some of the custom DSP wrappers can be non-copyable. If you do want to copy a DSP instance here, use its DSPBase::copy() method explicitly.
| dsp | Your DSP instance |
Definition at line 61 of file hart_process_audio.hpp.
|
inline |
|
inline |
Sets the sample rate for the test.
All the signals, effects and sub hosts are guaranteed to be initialized to this sample rate
| sampleRateHz | Sample rate in Hz. You can use frequency-related literails from Units. |
Definition at line 82 of file hart_process_audio.hpp.
|
inline |
Sets the block size for the test.
| blockSizeFrames | Block size in frames (samples) |
Definition at line 96 of file hart_process_audio.hpp.
|
inline |
Sets the initial param value for the tested DSP.
It will call DSP::setValue() for DSP under test
| id | Parameter ID (see DSP::setValue()) |
| value | Value that needs to be set |
Definition at line 109 of file hart_process_audio.hpp.
|
inline |
Sets the total duration of the input signal to be processed.
| durationSeconds | of the signal in seconds. You can use time-related literails from Units. |
Definition at line 118 of file hart_process_audio.hpp.
|
inline |
Sets whether to call reset() and/or prepare() on DSP testee before rendering audio.
It is useful when you re-use your DSP instance, to control whether you want to preserve its pre-existing state. If you also request withWarmUp(), this call will only affect pre-warp-up preparation. Post-warm-up preparaton is selected via withWarmUp() args.
Definition at line 131 of file hart_process_audio.hpp.
|
inline |
Sets whether to call reset() and/or prepare() on the input Signal before rendering audio.
It is useful when you re-use your Signal instance, to control whether you want to preserve its pre-existing state. If you also request withWarmUp(), this call will only affect pre-warp-up preparation. Post-warm-up preparaton is selected via withWarmUp() args.
Definition at line 141 of file hart_process_audio.hpp.
|
inline |
Adds a warm‑up period before the main test.
The signal will be processed for this time, but no matchers will be invoked. This can be useful if your DSP uses parameter smoothers internally, that need to settle before performing the test, or has some sort of attack envelope stage, like a compressor, that you want to skip. This time will be added up with a regular test render run, i.e. processAudioWith (...).withDuration (100_ms).withWarmUp (10_ms) will result in 10 + 100 = 110 ms of total rendered audio.
saveOutputTo() (both for wav files and AudioBuffers) and savePlotTo() will always output the entire rendered piece of audio, including this warm-up stage. | warmUpDurationSeconds | Duration of the warm‑up in seconds |
| signalPreparation | Whether to call reset() and/or prepare() on an input signal after the warm-up stage |
| dspPreparation | Whether to call reset() and/or prepare() on the DSP testee after the warm-up stage |
Definition at line 161 of file hart_process_audio.hpp.
|
inline |
Sets the input signal for the test by copying it.
| signal | Input signal, see Signals |
Definition at line 178 of file hart_process_audio.hpp.
|
inline |
Sets the input signal for the test by moving it.
| signal | Input signal, see Signals |
Definition at line 186 of file hart_process_audio.hpp.
|
inline |
Sets the input signal for the test by transfering its smart pointer.
| signal | Input signal, see Signals |
Definition at line 195 of file hart_process_audio.hpp.
|
inline |
Sets the input signal using a function-based signal definition.
| signalFunction | Function that generates the signal buffer. It will moved to a Signal object. |
| label | Human-readable label for the signal to use in the test error output |
| loop | Determines whether the generated buffer should loop |
This overload constructs a SignalFunction internally, allowing inline definition of signals without explicitly creating a Signal object, for slightly less verbose syntax.
The function must have the signature: void (AudioBuffer<SampleType>&)
This method echoes the ctor of the hart::SignalFunction class, so see its documentaion for more detailed description.
saveInputSignalTo(). Definition at line 218 of file hart_process_audio.hpp.
|
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.
| numInputChannels | Number of input channels |
Definition at line 236 of file hart_process_audio.hpp.
|
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.
| numOutputChannels | Number of output channels |
Definition at line 252 of file hart_process_audio.hpp.
|
inline |
Sets number of input channels to two.
Definition at line 265 of file hart_process_audio.hpp.
|
inline |
Sets number of output channels to two.
Definition at line 271 of file hart_process_audio.hpp.
|
inline |
Sets number of input channels to one.
Definition at line 277 of file hart_process_audio.hpp.
|
inline |
Sets number of output channels to one.
Definition at line 283 of file hart_process_audio.hpp.
|
inline |
Sets number of input and output channels to one.
Definition at line 289 of file hart_process_audio.hpp.
|
inline |
Sets number of input and output channels to two.
Definition at line 295 of file hart_process_audio.hpp.
|
inline |
Adds an "expect" check using a Matcher object.
Definition at line 303 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "expect" check using a Matcher object.
Definition at line 312 of file hart_process_audio.hpp.
|
inline |
Adds an "assert" check using a Matcher object.
Definition at line 321 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "assert" check using a Matcher object.
Definition at line 330 of file hart_process_audio.hpp.
|
inline |
Adds an "expect" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: |
Example:
| label | Optional label used in failure reports |
Definition at line 352 of file hart_process_audio.hpp.
|
inline |
Adds an "expect" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: const AudioBuffer<SampleType>& output)
|
Example:
| label | Optional label used in failure reports |
Condition (const AudioBuffer<SampleType>& output). Definition at line 377 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "expect" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: |
Example:
| label | Optional label used in failure reports |
Definition at line 396 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "expect" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: const AudioBuffer<SampleType>& output)
|
Example:
| label | Optional label used in failure reports |
Condition (const AudioBuffer<SampleType>& output). Definition at line 421 of file hart_process_audio.hpp.
|
inline |
Adds an "assert" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: |
Example:
| label | Optional label used in failure reports |
Definition at line 440 of file hart_process_audio.hpp.
|
inline |
Adds an "assert" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: const AudioBuffer<SampleType>& output)
|
Example:
| label | Optional label used in failure reports |
Condition (const AudioBuffer<SampleType>& output). Definition at line 465 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "assert" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: |
Example:
| label | Optional label used in failure reports |
Definition at line 484 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "assert" check using a function matcher.
Intended for simple inline expressions. For anything more than that, consider making a custom hart::Matcher subclass and use it instead.
| matcherFunction | Function with signature: const AudioBuffer<SampleType>& output)
|
Example:
| label | Optional label used in failure reports |
Condition (const AudioBuffer<SampleType>& output). Definition at line 509 of file hart_process_audio.hpp.
|
inline |
Enables saving output audio to a wav file.
withWarmUp(), this warm-up section of audio will also be included in the output file | path | File path - relative or absolute. If relative path is set, it will be appended to the provided --data-root-path CLI argument. |
| mode | When to save, see hart::Save |
| wavFormat | Format of the wav file, see hart::WavFormat for supported options |
Definition at line 520 of file hart_process_audio.hpp.
|
inline |
Enables saving output audio to a provided buffer.
withWarmUp(), this warm-up section of audio will also be included in the output bufferTip: You can use HART_STR() to construct file names using "<<" syntax.
| receivingBuffer | An output buffer to receive the data. You can pass an unitialised buffer, among other things, as it will be move-assigned. |
Definition at line 536 of file hart_process_audio.hpp.
|
inline |
Enables saving output audio via provided callback.
withWarmUp(), this warm-up section of audio will also be included in the output bufferTip: You can use HART_STR() to construct file names using "<<" syntax.
| outputBufferSink | A callable that accepts a buffer rvalue. The buffer is moved into the provided sink. The test runner takes ownership of the callable object. |
Definition at line 551 of file hart_process_audio.hpp.
|
inline |
Enables saving a plot to an SVG file.
This will plot an input and output audio as a waveform
withWarmUp(), this warm-up section of audio will also be included in the plot Tip: You can use HART_STR() to construct file names using "<<" syntax. | path | File path - relative or absolute. If relative path is set, it will be appended to the provided --data-root-path CLI argument. |
| mode | When to save, see hart::Save |
Definition at line 564 of file hart_process_audio.hpp.
|
inline |
Moves the input signal after the processing into the provided smart pointer.
It's useful if you want to re-use your signal, query it for something, or extract some DSP instance from its DSP chain after the test.
| receivingSignal | A smart pointer that will receive the moved signal |
Definition at line 578 of file hart_process_audio.hpp.
|
inline |
Moves the input signal after the processing via provided callback.
It's useful if you want to re-use your signal, query it for something, or extract some DSP instance from its DSP chain after the test.
| inputSignalSink | A callable that accepts the moved signal |
Definition at line 592 of file hart_process_audio.hpp.
|
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. Tip: You can use HART_STR() to construct label strings using "<<" syntax.
| testLabel | Any text, to be used as a label |
Definition at line 603 of file hart_process_audio.hpp.
|
inline |
Performs the test.
Call this after setting all the test parameters
Definition at line 611 of file hart_process_audio.hpp.