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)
46 for (size_t frame = 0; frame < numFrames; ++frame)
47 output[channel][frame] = std::min (std::max (input[channel][frame], (SampleType) -m_thresholdLinear), (SampleType) m_thresholdLinear);
56 if (id ==
Params::thresholdDb)
64 if (id ==
Params::thresholdDb)
73 return numInputChannels == numOutputChannels;
76 void represent (std::ostream& stream)
const override
78 stream << dbPrecision <<
"HardClip (" << m_initialThresholdDb <<
"_dB)";
89 double m_initialThresholdDb;
90 double m_thresholdLinear;
Applies symmetrical hard clipping (no knee) to the signal.
void represent(std::ostream &stream) const override
Makes a text representation of this DSP effect for test failure outputs.
void process(const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output, const EnvelopeBuffers &) override
Processes the audio.
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_DEFINE_COPY_AND_MOVE(ClassName)
Defines hart::DSP::copy() and hart::DSP::move() methods.
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)