Gin
Loading...
Searching...
No Matches
SoftClipper Class Reference

Soft clipper with an adjustable knee, worked out in the dB domain. More...

#include <gin_softclipper.h>

Public Member Functions

 SoftClipper ()=default
 ~SoftClipper ()=default
void setDrive (float db)
 Gain applied before the curve, in dB.
void setKnee (float k)
 Knee width as a fraction of the drive, 0 to 1.
void setCeiling (float db)
 Output ceiling in dB - the level the curve flattens out at.
float processSample (float x) const
void process (juce::AudioSampleBuffer &buffer) const

Detailed Description

Soft clipper with an adjustable knee, worked out in the dB domain.

Below the knee nothing is touched at all. Through the knee the curve bends quadratically in dB, and above it the output is pinned to the ceiling. Doing the curve in dB rather than on the sample value is what makes it sound gradual: a waveshaper that looks smooth on a linear plot is still bending most sharply where the ear is most sensitive to it.

The knee is expressed as a fraction of the drive, so pushing the drive widens the region being softened instead of just hitting the ceiling harder and sooner.

Key Features:

  • Drive, knee width and ceiling
  • Continuous curve - gain and slope both match at the knee edges
  • Per sample, so it can be used anywhere in a chain
  • No allocation, no state, so it can be reset or reconfigured freely

Usage:

SoftClipper clipper;
clipper.setDrive (6.0f); // 6 dB in
clipper.setKnee (0.5f); // knee spans +/-3 dB around the ceiling
clipper.setCeiling (-0.1f);
clipper.process (buffer);
SoftClipper()=default
void setKnee(float k)
Knee width as a fraction of the drive, 0 to 1.
Definition gin_softclipper.h:69
void setDrive(float db)
Gain applied before the curve, in dB.
Definition gin_softclipper.h:59
void process(juce::AudioSampleBuffer &buffer) const
Definition gin_softclipper.h:112
void setCeiling(float db)
Output ceiling in dB - the level the curve flattens out at.
Definition gin_softclipper.h:76
See also
Distortion, Maximizer

Constructor & Destructor Documentation

◆ SoftClipper()

SoftClipper::SoftClipper ( )
default

◆ ~SoftClipper()

SoftClipper::~SoftClipper ( )
default

Member Function Documentation

◆ setDrive()

void SoftClipper::setDrive ( float db)

Gain applied before the curve, in dB.

More drive means more of the signal ends up in the knee and above it.

◆ setKnee()

void SoftClipper::setKnee ( float k)

Knee width as a fraction of the drive, 0 to 1.

At 0 this is a hard clip at the ceiling; at 1 the knee spans the whole drive range either side of it.

◆ setCeiling()

void SoftClipper::setCeiling ( float db)

Output ceiling in dB - the level the curve flattens out at.

◆ processSample()

float SoftClipper::processSample ( float x) const

Referenced by process().

◆ process()

void SoftClipper::process ( juce::AudioSampleBuffer & buffer) const

References processSample().


The documentation for this class was generated from the following file: