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

Checks whether the audio is identical to some signal. More...

#include <hart_equalsto.hpp>

Inheritance diagram for EqualsTo< SampleType >:

Public Member Functions

template<typename SignalType >
 EqualsTo (const SignalType &referenceSignal, double toleranceLinear=(SampleType) 1e-5)
 Creates a matcher for a specific signal details The reference signal can be something simple like a SineWave, or more complex signal with DSP effects chain and automation envelopes.
 
 EqualsTo (EqualsTo &&other) noexcept
 
 EqualsTo (const EqualsTo &other)
 
void prepare (double sampleRateHz, size_t numChannels, size_t maxBlockSizeFrames) override
 Prepare for processing It is guaranteed that all subsequent process() calls will be in line with the arguments received in this callback. This callback is guaranteed to be called after canOperatePerBlock() If any of the values supplied by this callback are not supported by the matcher, it is expected to act as if the match has failed when match() gets called.
 
bool match (const AudioBuffer< SampleType > &observedAudio) override
 Tells the host if the piece of audio satisfies Matcher's condition or not.
 
bool canOperatePerBlock () override
 Tells the host is if can operate on a block-by-block basis.
 
void reset () override
 Resets the matcher to its initial state.
 
virtual MatcherFailureDetails getFailureDetails () const override
 Returns a description of why the match has failed.
 
void represent (std::ostream &stream) const override
 Makes a text representation of this Macther for test failure outputs.
 
 HART_MATCHER_DEFINE_COPY_AND_MOVE (EqualsTo)
 
- Public Member Functions inherited from Matcher< SampleType >
virtual std::unique_ptr< Matcher< SampleType > > copy () const =0
 Returns a smart pointer with a copy of this object.
 
virtual std::unique_ptr< Matcher< SampleType > > move ()=0
 Returns a smart pointer with a moved instance of this object.
 
virtual ~Matcher ()=default
 Destructor.
 

Additional Inherited Members

Detailed Description

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

Checks whether the audio is identical to some signal.

Holds an internal Signal instance, and gets it to generate reference audio as the matcher receives new audio blocks through match(). Reports mismatch if even one of the frames in the audio does not match the reference signal within tolerance specified in epsilon during its instantiation.

Definition at line 22 of file hart_equalsto.hpp.

Constructor & Destructor Documentation

◆ EqualsTo() [1/3]

template<typename SampleType >
template<typename SignalType >
EqualsTo ( const SignalType referenceSignal,
double  toleranceLinear = (SampleType) 1e-5 
)
inline

Creates a matcher for a specific signal details The reference signal can be something simple like a SineWave, or more complex signal with DSP effects chain and automation envelopes.

Note
Tip: To compare audio to a pre-recorded wav file, you can use WavFile.
Parameters
referenceSignalSignal to compare the incoming audio against
toleranceLinearAbsolute tolerance for comparing frames, in linear domain (not decibels)

Definition at line 33 of file hart_equalsto.hpp.

◆ EqualsTo() [2/3]

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

Definition at line 44 of file hart_equalsto.hpp.

◆ EqualsTo() [3/3]

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

Definition at line 50 of file hart_equalsto.hpp.

Member Function Documentation

◆ prepare()

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

Prepare for processing It is guaranteed that all subsequent process() calls will be in line with the arguments received in this callback. This callback is guaranteed to be called after canOperatePerBlock() If any of the values supplied by this callback are not supported by the matcher, it is expected to act as if the match has failed when match() gets called.

Parameters
sampleRateHzsample rate at which the audio should be interpreted
numChannelsNumber of audio channels
maxBlockSizeFramesMaximum block size in frames (samples)

Implements Matcher< SampleType >.

Definition at line 56 of file hart_equalsto.hpp.

◆ match()

template<typename SampleType >
bool match ( const AudioBuffer< SampleType > &  observedAudio)
inlineoverridevirtual

Tells the host if the piece of audio satisfies Matcher's condition or not.

It is guaranteed to be called only after prepare(), or not be called at all. It is guaranteed to be handed an AudioBuffer in line with values set by the last prepare() call. If canOperatePerBlock() has returned false, this callback is guaranteed to be handed a full piece of audio to check. Otherwise, it may still get a full piece of audio, or get data on a block-by-block basis.

Parameters
observedAudioA piece of audio to check
Returns
true if the audio satisfies the Matcher's condition, false otherwise

Implements Matcher< SampleType >.

Definition at line 61 of file hart_equalsto.hpp.

◆ canOperatePerBlock()

template<typename SampleType >
bool canOperatePerBlock ( )
inlineoverridevirtual

Tells the host is if can operate on a block-by-block basis.

Some types of conditions absolutely require having a full piece of audio to produce an appropriate responce. For example, PeaksAt matcher. Those types of matchers will return false on this callback. Matcher is guaranteed to receive a full piece of audio if this callback has returned false. Otherwise, it may receive audio either block-by-block basis, or still get a full piece of audio, if the host decides to do so.

Implements Matcher< SampleType >.

Definition at line 84 of file hart_equalsto.hpp.

◆ reset()

template<typename SampleType >
void reset ( )
inlineoverridevirtual

Resets the matcher to its initial state.

Implements Matcher< SampleType >.

Definition at line 89 of file hart_equalsto.hpp.

◆ getFailureDetails()

template<typename SampleType >
virtual MatcherFailureDetails getFailureDetails ( ) const
inlineoverridevirtual

Returns a description of why the match has failed.

It is guaranteed to be called strictly after calling match(), or not called at all

Note
This method is a callback for the test host, so you probably don't need to call it yourself ever. If you're making a custom matcher, use it to communicate the data with test host.
Return values
MatcherFailureDetails::frameIndex of frame at which the match has failed
MatcherFailureDetails::channelIndex of channel at which the failure was detected
MatcherFailureDetails::descriptionReadable description of why the match has failed. Do not include the value of observed frame value or its timing in the description, as well as any of values printed by represent(), as all of this will be added to the output anyway. Also, query CLIConfig for number of displayed decimal places, whenever applicable.
See also
MatcherFailureDetails

Implements Matcher< SampleType >.

Definition at line 94 of file hart_equalsto.hpp.

◆ represent()

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

Makes a text representation of this Macther 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 Matcher< SampleType >.

Definition at line 110 of file hart_equalsto.hpp.

◆ HART_MATCHER_DEFINE_COPY_AND_MOVE()

template<typename SampleType >
HART_MATCHER_DEFINE_COPY_AND_MOVE ( EqualsTo< SampleType )

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