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

Base for audio matchers. More...

#include <hart_matcher.hpp>

Inheritance diagram for Matcher< SampleType >:

Public Member Functions

virtual void prepare (double sampleRateHz, size_t numChannels, size_t maxBlockSizeFrames)=0
 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.
 
virtual bool match (const AudioBuffer< SampleType > &observedAudio)=0
 Tells the host if the piece of audio satisfies Matcher's condition or not.
 
virtual bool canOperatePerBlock ()=0
 Tells the host is if can operate on a block-by-block basis.
 
virtual void reset ()=0
 Resets the matcher to its initial state.
 
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 MatcherFailureDetails getFailureDetails () const =0
 Returns a description of why the match has failed.
 
virtual void represent (std::ostream &stream) const =0
 Makes a text representation of this Macther for test failure outputs.
 
virtual ~Matcher ()=default
 Destructor.
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

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

Base for audio matchers.

Those matchers get a piece of audio generated by some DSP effect and asked if if satisfies their condition or not

Template Parameters
SampleTypeType of data in the buffers to be checked, typically float or double.

Definition at line 21 of file hart_matcher.hpp.

Constructor & Destructor Documentation

◆ ~Matcher()

template<typename SampleType >
virtual ~Matcher ( )
virtualdefault

Destructor.

Member Function Documentation

◆ prepare()

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

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)

Implemented in EqualsTo< SampleType >, PeaksAt< SampleType >, and PeaksBelow< SampleType >.

◆ match()

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

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

Implemented in EqualsTo< SampleType >, PeaksAt< SampleType >, and PeaksBelow< SampleType >.

◆ canOperatePerBlock()

template<typename SampleType >
virtual bool canOperatePerBlock ( )
pure virtual

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.

Implemented in EqualsTo< SampleType >, PeaksAt< SampleType >, and PeaksBelow< SampleType >.

◆ reset()

template<typename SampleType >
virtual void reset ( )
pure virtual

Resets the matcher to its initial state.

Implemented in EqualsTo< SampleType >, PeaksAt< SampleType >, and PeaksBelow< SampleType >.

◆ copy()

template<typename SampleType >
virtual std::unique_ptr< Matcher< SampleType > > copy ( ) const
pure virtual

Returns a smart pointer with a copy of this object.

Just put one of those two macros into your class body, and your copy() and move() are sorted:

Read their description, and choose one that fits your class. You can, of course, make your own implementation, but you're not supposed to, unless you're doing something obscure.

◆ move()

template<typename SampleType >
virtual std::unique_ptr< Matcher< SampleType > > move ( )
pure virtual

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

Just pick a macro to define it - see description for copy() for details

◆ getFailureDetails()

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

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

Implemented in EqualsTo< SampleType >, PeaksAt< SampleType >, and PeaksBelow< SampleType >.

◆ represent()

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

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

Implemented in EqualsTo< SampleType >, PeaksAt< SampleType >, and PeaksBelow< SampleType >.


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