HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_mute.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm> // fill
4#include <bitset>
5#include <iomanip> // hex
6
7#include "hart_dsp.hpp"
9
10namespace hart
11{
12
13/// @brief Mutes selected channels in the signal
14/// @details Fills all specified channels to zeros.
15/// By default, mutes all the channels, unless specific channels are set.
16/// @ingroup DSP
17template <typename SampleType>
18class Mute:
19 public hart::DSP<SampleType, Mute<SampleType>>
20{
21public:
22 void prepare (double /*sampleRateHz*/, size_t numInputChannels, size_t numOutputChannels, size_t /*maxBlockSizeFrames*/) override
23 {
24 if (numInputChannels != numOutputChannels)
25 HART_THROW_OR_RETURN_VOID (hart::ChannelLayoutError, "Unsupported channel configuration");
26 }
27
28 void process (const AudioBuffer<SampleType>& input, AudioBuffer<SampleType>& output, const EnvelopeBuffers& /*envelopeBuffers*/, ChannelFlags channelsToProcess) override
29 {
30 if (input.getNumChannels() != output.getNumChannels())
31 HART_THROW_OR_RETURN_VOID (hart::ChannelLayoutError, "Channel number mismatch");
32
33 const size_t numChannels = output.getNumChannels();
34 const size_t numFrames = output.getNumFrames();
35
36 for (size_t channel = 0; channel < numChannels; ++channel)
37 {
38 if (channelsToProcess[channel] == true)
39 output.clear (channel, 0, numFrames);
40 else
41 output.copyFrom (channel, 0, input, channel, 0, numFrames);
42 }
43 }
44
45 void reset() override {}
46
47 void setValue (int /*id*/, double /*value*/) override {}
48
49 double getValue (int /*id*/) const override { return 0.0; }
50
51 bool supportsChannelLayout (size_t numInputChannels, size_t numOutputChannels) const override
52 {
53 return numInputChannels == numOutputChannels;
54 }
55
56 bool supportsEnvelopeFor(int /*id*/) const override
57 {
58 return false;
59 }
60
62};
63
65
66} // namespace hart
A set of boolean flags mapped to each audio channel.
std::bitset< m_maxChannels >::reference operator[](size_t channel)
Access the flag value for a specific channel.
Base for DSP effects.
Definition hart_dsp.hpp:322
Mutes selected channels in the signal.
Definition hart_mute.hpp:20
void setValue(int, double) override
Sets DSP value.
Definition hart_mute.hpp:47
void process(const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output, const EnvelopeBuffers &, ChannelFlags channelsToProcess) override
Processes the audio.
Definition hart_mute.hpp:28
double getValue(int) const override
Retrieves DSP value.
Definition hart_mute.hpp:49
bool supportsEnvelopeFor(int) const override
Tells whether this effect accepts automation envelopes for a particular parameter.
Definition hart_mute.hpp:56
void prepare(double, size_t numInputChannels, size_t numOutputChannels, size_t) override
Prepare for processing.
Definition hart_mute.hpp:22
void reset() override
Resets to initial state.
Definition hart_mute.hpp:45
bool supportsChannelLayout(size_t numInputChannels, size_t numOutputChannels) const override
Tells the runner (host) whether this effect supports a specific i/o configuration.
Definition hart_mute.hpp:51
#define HART_DEFINE_GENERIC_REPRESENT(ClassName)
Defines a basic string representation of your class.
#define HART_DSP_DECLARE_ALIASES_FOR(ClassName)
Definition hart_dsp.hpp:487
#define HART_THROW_OR_RETURN_VOID(ExceptionType, message)