feat: add clipper node
This commit is contained in:
parent
229b3eb1e2
commit
77c4851119
3 changed files with 39 additions and 1 deletions
16
core/Clipper.cpp
Normal file
16
core/Clipper.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "Clipper.hpp"
|
||||
|
||||
Clipper::Clipper(float init_clip) : clip_(init_clip) {}
|
||||
|
||||
void Clipper::process(const float *in, float *out, uint32_t frames) {
|
||||
for (uint32_t i = 0; i < frames; ++i) {
|
||||
out[i] = in[i] > clip_ ? clip_ : in[i];
|
||||
}
|
||||
}
|
||||
void Clipper::processStereo(const float *inLeft, const float *inRight,
|
||||
float *outLeft, float *outRight, uint32_t frames) {
|
||||
for (uint32_t i = 0; i < frames; ++i) {
|
||||
outLeft[i] = inLeft[i] > clip_ ? clip_ : inLeft[i];
|
||||
outRight[i] = inRight[i] > clip_ ? clip_ : inRight[i];
|
||||
}
|
||||
}
|
||||
22
core/Clipper.hpp
Normal file
22
core/Clipper.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CLIPPER_HPP_INCLUDED
|
||||
#define CLIPPER_HPP_INCLUDED
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class Clipper {
|
||||
public:
|
||||
Clipper(float init_clip = 1.0f);
|
||||
|
||||
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_;
|
||||
|
||||
public:
|
||||
void setGain(float c) { clip_ = c; }
|
||||
float getGain() const { return clip_; }
|
||||
};
|
||||
|
||||
#endif // CLIPPER_HPP_INCLUDED
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/make -f
|
||||
NAME = SquidgeDistortion
|
||||
|
||||
FILES_DSP = SquidgeDistortion.cpp ../../core/Gain.cpp
|
||||
FILES_DSP = SquidgeDistortion.cpp ../../core/Gain.cpp ../../core/Clipper.cpp
|
||||
|
||||
TARGETS = vst3 clap
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue