HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
Matcher< SampleType, Derived > Class Template Reference

Base for audio matchers. More...

#include <hart_matcher.hpp>

Inheritance diagram for Matcher< SampleType, Derived >:

Public Member Functions

virtual std::unique_ptr< MatcherBase< SampleType > > copy () const override
 Returns a smart pointer with a copy of this object.
 
virtual std::unique_ptr< MatcherBase< SampleType > > move () override
 Returns a smart pointer with a moved instance of this object.
 
DerivedatChannels (std::initializer_list< size_t > channelsToMatch)
 Makes this matcher check only specific channels, and ignore the rest.
 
DerivedatChannel (size_t channelToMatch)
 Makes this matcher check only one specific channel, and ignore the rest.
 
DerivedatAllChannels ()
 Makes this matcher check all channels.
 
DerivedatAllChannelsExcept (std::initializer_list< size_t > channelsToSkip)
 Makes this matcher check only specific channels, and ignore the rest.
 
void representWithActiveChannels (std::ostream &stream) const override
 Makes a text representation of this Matcher with optional "atChannels" appendix.
 
- Public Member Functions inherited from MatcherBase< SampleType >
virtual ~MatcherBase ()=default
 
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 if it can operate on a block-by-block basis.
 
virtual void reset ()=0
 Resets the matcher to its initial state.
 
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 Matcher for test failure outputs.
 

Protected Member Functions

bool appliesToChannel (size_t channel)
 Indicates whether this matcher should check a specific channel.
 

Protected Attributes

ChannelFlags m_channelsToMatch {true}
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

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

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 You can inherit from this class to create a new matcher (note the CRTP in the template args here, it's important!):

template<typename SampleType>
class MyCustomMatcher: public Matcher<SampleType, MyCustomMatcher<SampleType>>
{
// ...
};
Base for audio matchers.
Template Parameters
SampleTypeType of data in the buffers to be checked, typically float or double.
DerivedSubclass for CRTP

Definition at line 112 of file hart_matcher.hpp.

Member Function Documentation

◆ copy()

virtual std::unique_ptr< MatcherBase< SampleType > > copy ( ) const
inlineoverridevirtual

Returns a smart pointer with a copy of this object.

Returns
Copy of this object wrapped in a smart pointer

Implements MatcherBase< SampleType >.

Definition at line 119 of file hart_matcher.hpp.

◆ move()

virtual std::unique_ptr< MatcherBase< SampleType > > move ( )
inlineoverridevirtual

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

Returns
This object, moved and wrapped in a smart pointer

Implements MatcherBase< SampleType >.

Definition at line 126 of file hart_matcher.hpp.

◆ atChannels()

Derived & atChannels ( std::initializer_list< size_t channelsToMatch)
inline

Makes this matcher check only specific channels, and ignore the rest.

If not set, the matcher applies to all channels by default. If you call this method multiple times, only the last one will be applied. To select only one channel, consider using Matcher::atChannel() instead.

Parameters
channelsToMatchList of channels this matcher should apply to, e.g. {0, 1} or {Channel::left, Channel::right} for left and right channels only.
See also
hart::Channel

Definition at line 138 of file hart_matcher.hpp.

◆ atChannel()

Derived & atChannel ( size_t  channelToMatch)
inline

Makes this matcher check only one specific channel, and ignore the rest.

If not set, the matcher applies to all channels by default. If you call this method multiple times, only the last one will be applied. To select multiple channels, use Matcher::atChannels() instead.

Parameters
channelToMatchChannel this matcher should apply to (zero-based), e.g. 0 or Channel::left for left channel.
Note
If not set, the matcher applies to all channels by default
See also
hart::Channel

Definition at line 161 of file hart_matcher.hpp.

◆ atAllChannels()

Derived & atAllChannels ( )
inline

Makes this matcher check all channels.

This is the default setting anyway, so this method is only for cases when you need to override previous atChannel(), `atChannels()` or atAllChannelsExcept() calls.

Definition at line 176 of file hart_matcher.hpp.

◆ atAllChannelsExcept()

Derived & atAllChannelsExcept ( std::initializer_list< size_t channelsToSkip)
inline

Makes this matcher check only specific channels, and ignore the rest.

If not set, matcher checks all channels by default. If you call this method multiple times, only the last one will be applied.

Parameters
channelsToSkipList of channels this matcher should NOT check, e.g. {0, 1} or {Channel::left, Channel::right} to skip left and right channels, and match the rest
See also
hart::Channel

Definition at line 189 of file hart_matcher.hpp.

◆ representWithActiveChannels()

void representWithActiveChannels ( std::ostream &  stream) const
inlineoverridevirtual

Makes a text representation of this Matcher with optional "atChannels" appendix.

For internal use by hosts, don't override it in custom matchers.

Implements MatcherBase< SampleType >.

Definition at line 205 of file hart_matcher.hpp.

◆ appliesToChannel()

bool appliesToChannel ( size_t  channel)
inlineprotected

Indicates whether this matcher should check a specific channel.

You might want to use it in the match() callback. See atChannels(), atChannel(), atAllChannels(), atAllChannelsExcept().

Definition at line 224 of file hart_matcher.hpp.

Member Data Documentation

◆ m_channelsToMatch

ChannelFlags m_channelsToMatch {true}
protected

Definition at line 219 of file hart_matcher.hpp.


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