16template <
typename SampleType>
29 m_initialThresholdDb (thresholdDb),
34 void prepare (
double , size_t , size_t , size_t )
override {}
38 hassert (output.getNumFrames() == input.getNumFrames());
39 const size_t numChannels = input.getNumChannels();
40 const size_t numFrames = input.getNumFrames();
42 if (input.getNumChannels() != output.getNumChannels())
45 for (size_t channel = 0; channel < numChannels; ++channel)
47 if (channelsToProcess
[channel
] ==
true)
49 for (size_t frame = 0; frame < numFrames; ++frame)
50 output[channel][frame] = std::min (std::max (input[channel][frame], (SampleType) -m_thresholdLinear), (SampleType) m_thresholdLinear);
54 for (size_t frame = 0; frame < numFrames; ++frame)
55 output[channel][frame] = input[channel][frame];
66 if (id ==
Params::thresholdDb)
74 if (id ==
Params::thresholdDb)
83 return numInputChannels == numOutputChannels;
86 void represent (std::ostream& stream)
const override
88 stream << dbPrecision <<
"HardClip (" << m_initialThresholdDb <<
"_dB)";
97 double m_initialThresholdDb;
98 double m_thresholdLinear;
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.
Applies symmetrical hard clipping (no knee) to the signal.
void process(const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output, const EnvelopeBuffers &, ChannelFlags channelsToProcess) override
Processes the audio.
void represent(std::ostream &stream) const override
Makes a text representation of this DSP effect for test failure outputs.
void prepare(double, size_t, size_t, size_t) override
Prepare for processing.
HardClip(double thresholdDb=0.0)
Contructor.
double getValue(int id) const override
@ thresholdDb
Threshold in decibels.
bool supportsEnvelopeFor(int) const override
Tells whether this effect accepts automation envelopes for a particular parameter.
void setValue(int id, double value) override
void reset() override
Resets to initial state.
bool supportsChannelLayout(size_t numInputChannels, size_t numOutputChannels) const override
static SampleType ratioToDecibels(SampleType valueLinear)
Converts linear value (ratio) to dB.
static SampleType decibelsToRatio(SampleType valueDb)
Converts dB to linear value (ratio)
#define HART_DSP_DECLARE_ALIASES_FOR(ClassName)
#define HART_THROW_OR_RETURN_VOID(ExceptionType, message)
#define hassert(condition)