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

Simple gain processor with ramping to avoid discontinuities. More...

#include <gin_audioutil.h>

Public Member Functions

void setGain (float g)
void reset ()
void process (juce::AudioSampleBuffer &buffer)

Detailed Description

Simple gain processor with ramping to avoid discontinuities.

GainProcessor applies gain to an audio buffer with automatic ramping between gain values to prevent clicks and pops. It maintains the previous gain value and applies a linear ramp when the gain changes.

Key Features:

  • Automatic gain ramping (click-free)
  • Lightweight and efficient
  • Stateful (remembers last gain)
  • Reset method for voice restarts

Usage:

GainProcessor gainProc;
gainProc.setGain(0.5f); // Set to 50% volume
// In audio callback
gainProc.process(audioBuffer); // Applies gain with ramping
// When starting a new voice/note
gainProc.reset(); // Snap to current gain without ramping
Simple gain processor with ramping to avoid discontinuities.
Definition gin_audioutil.h:89
void process(juce::AudioSampleBuffer &buffer)
Definition gin_audioutil.h:94
void reset()
Definition gin_audioutil.h:92
void setGain(float g)
Definition gin_audioutil.h:91

Note: Gain ramping occurs over the entire buffer length. For longer buffers, this provides smoother transitions. For per-sample control, consider juce::LinearSmoothedValue instead.

See also
juce::LinearSmoothedValue, applyGain

Member Function Documentation

◆ setGain()

void GainProcessor::setGain ( float g)

◆ reset()

void GainProcessor::reset ( )

◆ process()

void GainProcessor::process ( juce::AudioSampleBuffer & buffer)

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