From 11f701ed5ccb1d8148cfb5b353096d69dbbe1450 Mon Sep 17 00:00:00 2001 From: Liam Kerr Date: Sun, 2 Aug 2026 19:38:30 +0100 Subject: [PATCH] feat: add Gain Node --- .clangd | 1 + core/Gain.cpp | 17 +++++++++++++++++ core/Gain.hpp | 24 ++++++++++++++++++++++++ plugins/SquidgeDistortion/Makefile | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 core/Gain.cpp create mode 100644 core/Gain.hpp diff --git a/.clangd b/.clangd index f5fe506..e3b4e35 100644 --- a/.clangd +++ b/.clangd @@ -3,6 +3,7 @@ CompileFlags: - -Idpf/distrho - -Idpf/include - -Iplugins/SquidgeDistortion + - -Icore - -DDISTRHO_PLUGIN_MAGIC=1 Remove: - -fno-gnu-unique \ No newline at end of file diff --git a/core/Gain.cpp b/core/Gain.cpp new file mode 100644 index 0000000..088a1f5 --- /dev/null +++ b/core/Gain.cpp @@ -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_; + } +} diff --git a/core/Gain.hpp b/core/Gain.hpp new file mode 100644 index 0000000..0624eab --- /dev/null +++ b/core/Gain.hpp @@ -0,0 +1,24 @@ +#ifndef GAIN_HPP_INCLUDED +#define GAIN_HPP_INCLUDED + +#include + +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 \ No newline at end of file diff --git a/plugins/SquidgeDistortion/Makefile b/plugins/SquidgeDistortion/Makefile index 49e290f..4055cd1 100644 --- a/plugins/SquidgeDistortion/Makefile +++ b/plugins/SquidgeDistortion/Makefile @@ -1,7 +1,7 @@ #!/usr/bin/make -f NAME = SquidgeDistortion -FILES_DSP = SquidgeDistortion.cpp +FILES_DSP = SquidgeDistortion.cpp ../../core/Gain.cpp TARGETS = vst3 clap