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)";
99 double m_initialThresholdDb;
100 double m_thresholdLinear;
Container for audio data.
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.
Thrown when a numbers of channels is mismatched.
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
#define HART_DSP_COPYABLE(ClassName)
Implements a generic hart::DSP::copy() method.
#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 hassert(condition)
Triggers a HartAssertException if the condition is false
std::ostream & dbPrecision(std::ostream &stream)
Sets number of decimal places for values in decibels.
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)