SquidgeDSP/core/Clipper.hpp

28 lines
746 B
C++
Raw 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 22:58:56 +01:00
enum ClipperMode { kClipperModeSoft, kClipperModeHard, kClipperModeCount };
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 clip_;
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 setGain(float c) { clip_ = c; }
float getGain() const { return clip_; }
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