SquidgeDSP/core/Clipper.hpp

33 lines
807 B
C++
Raw Permalink Normal View History

2026-08-02 20:03:04 +01:00
#ifndef CLIPPER_HPP_INCLUDED
#define CLIPPER_HPP_INCLUDED
#include <cstdint>
class Clipper {
public:
2026-08-02 23:13:42 +01:00
enum ClipperMode {
kClipperModeSoft,
kClipperModeHard,
kClipperModeFold,
kClipperModeCount
};
2026-08-02 22:58:56 +01:00
Clipper(float init_clip = 1.0f, ClipperMode mode = kClipperModeSoft);
2026-08-02 20:03:04 +01:00
void process(const float *in, float *out, uint32_t frames);
void processStereo(const float *inLeft, const float *inRight, float *outLeft,
float *outRight, uint32_t frames);
private:
float threshold_;
float clip(const float in);
2026-08-02 22:58:56 +01:00
ClipperMode mode_;
2026-08-02 20:03:04 +01:00
public:
void setThreshold(float c) { threshold_ = c; }
float getThreshold() const { return threshold_; }
2026-08-02 22:58:56 +01:00
void setMode(ClipperMode m) { mode_ = m; }
ClipperMode getMode() const { return mode_; }
2026-08-02 20:03:04 +01:00
};
#endif // CLIPPER_HPP_INCLUDED