|
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 & | withWarmUp (double warmUpDurationSeconds, ResetSignal resetSignalAfterWarmUp=ResetSignal::no) |
| Adds a warm‑up period before the main test. | |
| AudioTestBuilder & | withInputSignal (const SignalBase< SampleType > &signal, ResetSignal resetSignalBeforeProcessing=ResetSignal::no) |
| Sets the input signal for the test by copying it. | |
| AudioTestBuilder & | withInputSignal (SignalBase< SampleType > &&signal, ResetSignal resetSignalBeforeProcessing=ResetSignal::no) |
| Sets the input signal for the test by moving it. | |
| AudioTestBuilder & | withInputSignal (std::unique_ptr< SignalBase< SampleType > > signal, ResetSignal resetSignalBeforeProcessing=ResetSignal::no) |
| 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< bool(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "expect" check using a function matcher. | |
| AudioTestBuilder & | expectTrue (std::function< bool(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "expect" check using a function matcher. | |
| AudioTestBuilder & | expectFalse (std::function< bool(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "expect" check using a function matcher. | |
| AudioTestBuilder & | expectFalse (std::function< bool(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "expect" check using a function matcher. | |
| AudioTestBuilder & | assertTrue (std::function< bool(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "assert" check using a function matcher. | |
| AudioTestBuilder & | assertTrue (std::function< bool(const AudioBuffer< SampleType > &, const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds an "assert" check using a function matcher. | |
| AudioTestBuilder & | assertFalse (std::function< bool(const AudioBuffer< SampleType > &)> matcherFunction, const std::string &label={}) |
| Adds a reversed "assert" check using a function matcher. | |
| AudioTestBuilder & | assertFalse (std::function< bool(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 () |
| Perfoems the test. | |
A DSP host used for building and running tests inside a test case.
Definition at line 49 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 58 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 79 of file hart_process_audio.hpp.
|
inline |
Sets the block size for the test.
| blockSizeFrames | Block size in frames (samples) |
Definition at line 93 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 106 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 115 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 |
| resetSignalAfterWarmUp | Whether to restart the input signal generator after the warm‑up stage, see hart::ResetSignal |
Definition at line 136 of file hart_process_audio.hpp.
|
inline |
Sets the input signal for the test by copying it.
| signal | Input signal, see Signals |
| resetSignalBeforeProcessing | Set to ResetSignal::yes if you want the runner to call Signal::reset() before rendering audio, or to ResetSignal::no to keep its pre-existing state |
Definition at line 150 of file hart_process_audio.hpp.
|
inline |
Sets the input signal for the test by moving it.
| signal | Input signal, see Signals |
| resetSignalBeforeProcessing | Set to ResetSignal::yes if you want the runner to call Signal::reset() before rendering audio, or to ResetSignal::no to keep its pre-existing state |
Definition at line 161 of file hart_process_audio.hpp.
|
inline |
Sets the input signal for the test by transfering its smart pointer.
| signal | Input signal, see Signals |
| resetSignalBeforeProcessing | Set to ResetSignal::yes if you want the runner to call Signal::reset() before rendering audio, or to ResetSignal::no to keep its pre-existing state |
Definition at line 173 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 197 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 216 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 232 of file hart_process_audio.hpp.
|
inline |
Sets number of input channels to two.
Definition at line 245 of file hart_process_audio.hpp.
|
inline |
Sets number of output channels to two.
Definition at line 251 of file hart_process_audio.hpp.
|
inline |
Sets number of input channels to one.
Definition at line 257 of file hart_process_audio.hpp.
|
inline |
Sets number of output channels to one.
Definition at line 263 of file hart_process_audio.hpp.
|
inline |
Sets number of input and output channels to one.
Definition at line 269 of file hart_process_audio.hpp.
|
inline |
Sets number of input and output channels to two.
Definition at line 275 of file hart_process_audio.hpp.
|
inline |
Adds an "expect" check using a Matcher object.
Definition at line 283 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "expect" check using a Matcher object.
Definition at line 292 of file hart_process_audio.hpp.
|
inline |
Adds an "assert" check using a Matcher object.
Definition at line 301 of file hart_process_audio.hpp.
|
inline |
Adds a reversed "assert" check using a Matcher object.
Definition at line 310 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: A DSP processor defined by a user-provided function. Definition hart_dsp_function.hpp:62 |
| label | Optional label used in failure reports |
Definition at line 327 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: |
| label | Optional label used in failure reports |
bool(const AudioBuffer<SampleType>& output). Definition at line 344 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: |
| label | Optional label used in failure reports |
Definition at line 358 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: |
| label | Optional label used in failure reports |
bool(const AudioBuffer<SampleType>& output). Definition at line 375 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: |
| label | Optional label used in failure reports |
Definition at line 389 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: |
| label | Optional label used in failure reports |
bool(const AudioBuffer<SampleType>& output). Definition at line 406 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: |
| label | Optional label used in failure reports |
Definition at line 420 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: |
| label | Optional label used in failure reports |
bool(const AudioBuffer<SampleType>& output). Definition at line 437 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 448 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 464 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 479 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 492 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 506 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 520 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 531 of file hart_process_audio.hpp.
|
inline |
Perfoems the test.
Call this after setting all the test parameters
Definition at line 539 of file hart_process_audio.hpp.