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:
|
2026-08-03 15:43:02 +01:00
|
|
|
float threshold_;
|
2026-08-02 20:26:06 +01:00
|
|
|
float clip(const float in);
|
2026-08-02 22:58:56 +01:00
|
|
|
ClipperMode mode_;
|
2026-08-02 20:03:04 +01:00
|
|
|
|
|
|
|
|
public:
|
2026-08-03 15:43:02 +01:00
|
|
|
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
|