23template<
typename SampleType>
37 virtual void prepare (
double sampleRateHz, size_t numChannels, size_t maxBlockSizeFrames) = 0;
81 virtual void represent (std::ostream& stream)
const = 0;
111template<
typename SampleType,
typename Derived>
121 return hart::make_unique<Derived> (
static_cast<
const Derived&> (*
this));
128 return hart::make_unique<Derived> (std::move (
static_cast<Derived&> (*
this)));
138 Derived&
atChannels (std::initializer_list<size_t> channelsToMatch)
142 for (size_t channel : channelsToMatch)
150 return static_cast<Derived&> (*
this);
169 return static_cast<Derived&> (*
this);
179 return static_cast<Derived&> (*
this);
193 for (size_t channel : channelsToSkip)
201 return static_cast<Derived&> (*
this);
207 this->represent (stream);
212 stream <<
".atChannels (";
233template <
typename SampleType>
234inline std::ostream& operator<< (std::ostream& stream,
const MatcherBase<SampleType>& matcher)
236 matcher.representWithActiveChannels (stream);
243#define HART_MATCHER_DECLARE_ALIASES_FOR(ClassName)
244 namespace aliases_float{
245 using ClassName = hart::ClassName<float>;
247 namespace aliases_double{
248 using ClassName = hart::ClassName<double>;
A set of boolean flags mapped to each audio channel.
bool allTrue() const noexcept
Checks if all flags are set to true
std::bitset< m_maxChannels >::reference operator[](size_t channel)
Access the flag value for a specific channel.
size_t size() const noexcept
Returns the size (not capacity) of the container.
ChannelFlags(bool defaultValues=true, size_t numChannels=m_maxChannels)
Creates a new channel flags object.
void setAllTo(bool newValues)
Sets all flags to a new value.
void representAsInitializerList(std::ostream &stream) const
Makes text representation of itself as a initializer list of active channels.
Polymorphic base for all matchers.
virtual bool canOperatePerBlock()=0
Tells the host if it can operate on a block-by-block basis.
virtual std::unique_ptr< MatcherBase< SampleType > > copy() const =0
Returns a smart pointer with a copy of this object.
virtual void reset()=0
Resets the matcher to its initial state.
virtual void represent(std::ostream &stream) const =0
Makes a text representation of this Matcher for test failure outputs.
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 ...
virtual MatcherFailureDetails getFailureDetails() const =0
Returns a description of why the match has failed.
virtual bool match(const AudioBuffer< SampleType > &observedAudio)=0
Tells the host if the piece of audio satisfies Matcher's condition or not.
virtual void representWithActiveChannels(std::ostream &stream) const =0
Makes a text representation of this Matcher with optional "atChannels" appendix.
virtual std::unique_ptr< MatcherBase< SampleType > > move()=0
Returns a smart pointer with a moved instance of this object.
virtual ~MatcherBase()=default
Derived & atChannel(size_t channelToMatch)
Makes this matcher check only one specific channel, and ignore the rest.
bool appliesToChannel(size_t channel)
Indicates whether this matcher should check a specific channel.
virtual std::unique_ptr< MatcherBase< SampleType > > copy() const override
Returns a smart pointer with a copy of this object.
Derived & atChannels(std::initializer_list< size_t > channelsToMatch)
Makes this matcher check only specific channels, and ignore the rest.
Derived & atAllChannelsExcept(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.
Derived & atAllChannels()
Makes this matcher check all channels.
virtual std::unique_ptr< MatcherBase< SampleType > > move() override
Returns a smart pointer with a moved instance of this object.
ChannelFlags m_channelsToMatch
#define HART_THROW_OR_RETURN_VOID(ExceptionType, message)
Details about matcher failure.