23template<
typename SampleType>
37 virtual void prepare (
double sampleRateHz, size_t numChannels, size_t maxBlockSizeFrames) = 0;
47 HART_DEPRECATED (
"This match() overload will be removed in HART 1.0.0, use \"match (const AudioBuffer&, const AudioBuffer&)\" instead")
48 virtual bool match (
const AudioBuffer<SampleType>& observedAudio)
67 return this->match (observedOutputAudio);
103 virtual void represent (std::ostream& stream)
const = 0;
133template<
typename SampleType,
typename Derived>
143 return hart::make_unique<Derived> (
static_cast<
const Derived&> (*
this));
150 return hart::make_unique<Derived> (std::move (
static_cast<Derived&> (*
this)));
160 Derived&
atChannels (std::initializer_list<size_t> channelsToMatch) &
162 _atChannels (channelsToMatch);
163 return static_cast<Derived&> (*
this);
173 Derived&&
atChannels (std::initializer_list<size_t> channelsToMatch) &&
175 _atChannels (channelsToMatch);
176 return static_cast<Derived&&> (*
this);
189 _atChannel (channelToMatch);
190 return static_cast<Derived&> (*
this);
203 _atChannel (channelToMatch);
204 return static_cast<Derived&&> (*
this);
214 return static_cast<Derived&> (*
this);
224 return static_cast<Derived&&> (*
this);
236 _atAllChannelsExcept (channelsToSkip);
237 return static_cast<Derived&> (*
this);
249 _atAllChannelsExcept (channelsToSkip);
250 return static_cast<Derived&&> (*
this);
256 this->represent (stream);
261 stream <<
".atChannels (";
279 void _atChannels (std::initializer_list<size_t> channelsToMatch)
283 for (size_t channel : channelsToMatch)
292 void _atChannel (size_t channelToMatch)
301 void _atAllChannels()
306 void _atAllChannelsExcept (std::initializer_list<size_t> channelsToSkip)
310 for (size_t channel : channelsToSkip)
323template <
typename SampleType>
324inline std::ostream& operator<< (std::ostream& stream,
const MatcherBase<SampleType>& matcher)
326 matcher.representWithActiveChannels (stream);
333#define HART_MATCHER_DECLARE_ALIASES_FOR(ClassName)
334 namespace aliases_float{
335 using ClassName = hart::ClassName<float>;
337 namespace aliases_double{
338 using ClassName = hart::ClassName<double>;
Container for audio data.
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 std::unique_ptr< MatcherBase< SampleType > > copy() const =0
Returns a smart pointer with a copy of this object.
virtual void represent(std::ostream &stream) const =0
Makes a text representation of this Matcher for test failure outputs.
virtual bool canOperatePerBlock() const =0
Tells the host if it can operate on a block-by-block basis.
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 void reset()
Resets the matcher to its initial state.
virtual MatcherFailureDetails getFailureDetails() const =0
Returns a description of why the match has failed.
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
virtual bool match(const AudioBuffer< SampleType > &inputAudio, const AudioBuffer< SampleType > &observedOutputAudio)
Tells the host if the piece of audio satisfies Matcher's condition or not.
Derived & atChannels(std::initializer_list< size_t > channelsToMatch) &
Makes this matcher check only specific channels, and ignore the rest.
bool appliesToChannel(size_t channel)
Indicates whether this matcher should check a specific channel.
Derived && atChannels(std::initializer_list< size_t > channelsToMatch) &&
Makes this matcher check only specific channels, and ignore the rest.
virtual std::unique_ptr< MatcherBase< SampleType > > copy() const override
Returns a smart pointer with a copy of this object.
Derived && atChannel(size_t channelToMatch) &&
Makes this matcher check only one specific channel, and ignore the rest.
Derived & atChannel(size_t channelToMatch) &
Makes this matcher check only one specific channel, and ignore the rest.
void representWithActiveChannels(std::ostream &stream) const override
Makes a text representation of this Matcher with optional "atChannels" appendix.
Derived & atAllChannelsExcept(std::initializer_list< size_t > channelsToSkip) &
Makes this matcher check only specific channels, and ignore the rest.
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.
Derived && atAllChannels() &&
Makes this matcher check all channels.
ChannelFlags m_channelsToMatch
Derived && atAllChannelsExcept(std::initializer_list< size_t > channelsToSkip) &&
Makes this matcher check only specific channels, and ignore the rest.
Thrown when an inappropriate value is encountered.
#define HART_THROW_OR_RETURN_VOID(ExceptionType, message)
Throws an exception if HART_DO_NOT_THROW_EXCEPTIONS is set, prints a message and returns otherwise.
#define HART_DEPRECATED(msg)
Details about matcher failure.