Preamp
A minimal stereo preamp introducing musical soft saturation, gentle harmonics, and automatic gain normalization. Designed as a clean example script.
Download
Contents
preamp.cpp
- // -----------------------------------------------------------------------------
- // PreAmp - Simple warm saturation
- // Author: ravegeneration.io
- //
- // A minimal stereo preamp introducing musical soft saturation, gentle harmonics,
- // and automatic gain normalization. Designed as a clean example script.
- //
- // - Single control: "PreAmp" adjusts drive amount (0–100%)
- // - Stereo processing
- // - Lightweight CPU usage
- // -----------------------------------------------------------------------------
- #include <cmath>
- #include <string>
- #include <vector>
- #include "../dspapi.h"
- #include "../cpphelpers.h"
- #include "../params.h"
- DSP_EXPORT string name = "PreAmp";
- int PREAMP;
- inline double processPreamp(double x, double p)
- {
- if (p < 0.001) return x;
- double drive = 1.0 + p * 3.0;
- double warmth = p * 0.25;
- double sat = tanh(x * drive * 0.9);
- double harm = x * x * warmth;
- return (sat + harm) * (1.0 / (1.0 + p * 0.8));
- }
- {
- audioInputsCount = 2;
- audioOutputsCount = 2;
- PREAMP = ip("PreAmp", "%", 0, 100, 0, ".1");
- return true;
- }
- {
- double p = IP[PREAMP] / 100.0;
- for (uint i = 0; i < data.samplesToProcess; i++)
- {
- data.samples[0][i] = processPreamp(data.samples[0][i], p);
- data.samples[1][i] = processPreamp(data.samples[1][i], p);
- }
- }
Comments
Please, authorize to view and post comments.