feat: add Gain Node
This commit is contained in:
parent
786966e9e0
commit
11f701ed5c
4 changed files with 43 additions and 1 deletions
1
.clangd
1
.clangd
|
|
@ -3,6 +3,7 @@ CompileFlags:
|
||||||
- -Idpf/distrho
|
- -Idpf/distrho
|
||||||
- -Idpf/include
|
- -Idpf/include
|
||||||
- -Iplugins/SquidgeDistortion
|
- -Iplugins/SquidgeDistortion
|
||||||
|
- -Icore
|
||||||
- -DDISTRHO_PLUGIN_MAGIC=1
|
- -DDISTRHO_PLUGIN_MAGIC=1
|
||||||
Remove:
|
Remove:
|
||||||
- -fno-gnu-unique
|
- -fno-gnu-unique
|
||||||
17
core/Gain.cpp
Normal file
17
core/Gain.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "Gain.hpp"
|
||||||
|
|
||||||
|
Gain::Gain(float init_gain) : gain_(init_gain) {}
|
||||||
|
|
||||||
|
void Gain::process(const float *in, float *out, uint32_t frames) {
|
||||||
|
for (uint32_t i = 0; i < frames; ++i) {
|
||||||
|
out[i] = in[i] * gain_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gain::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] * gain_;
|
||||||
|
outRight[i] = inRight[i] * gain_;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
core/Gain.hpp
Normal file
24
core/Gain.hpp
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef GAIN_HPP_INCLUDED
|
||||||
|
#define GAIN_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class Gain {
|
||||||
|
public:
|
||||||
|
Gain(float init_gain = 1.0f);
|
||||||
|
// Process mono signal
|
||||||
|
void process(const float *in, float *out, uint32_t frames);
|
||||||
|
|
||||||
|
// Process stereo (two channels)
|
||||||
|
void processStereo(const float *inLeft, const float *inRight, float *outLeft,
|
||||||
|
float *outRight, uint32_t frames);
|
||||||
|
|
||||||
|
private:
|
||||||
|
float gain_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setGain(float g) { gain_ = g; }
|
||||||
|
float getGain() const { return gain_; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GAIN_H__INCLUDED
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
NAME = SquidgeDistortion
|
NAME = SquidgeDistortion
|
||||||
|
|
||||||
FILES_DSP = SquidgeDistortion.cpp
|
FILES_DSP = SquidgeDistortion.cpp ../../core/Gain.cpp
|
||||||
|
|
||||||
TARGETS = vst3 clap
|
TARGETS = vst3 clap
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue