Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::dsp::Vca Class Reference

An amplifier: gain, Level and Mod Amt as ports over a linear multiply. More...

Detailed Description

An amplifier: gain, Level and Mod Amt as ports over a linear multiply.

A linear multiplier with an exponential Level control, the two modes Moog gave the VCA in 1965 (pp. 203-204): the modulation input is linear, so an envelope's own shape is the loudness curve, and Level is exponential, so the knob is even in dB. Its ports are process() arguments after the frame count, in the order PORTS declares (common/transport.hpp):

  • gain, nominally unipolar [0, 1]: the modulation, an envelope. As a block it is used as given and not clamped; this is a four-quadrant multiplier, so a bipolar signal at Mod Amt 1 inverts the audio on its negative half (0-Coast manual p. 26, fig. 49). As a scalar it moves to its value over RAMP_FRAMES.
  • level, in [0, 1], through math::level_gain() over LEVEL_RANGE_DB: silence at 0, unity at 1. A scalar; the gain it maps to moves linearly over RAMP_FRAMES.
  • mod_amount, in [0, 1], blends the modulation in: the gain per frame is level * (1 - amount + amount * gain). At 0 the amplifier holds Level with the modulation ignored, Mavis's VCA MODE switch as a knob (Mavis manual p. 30); at 1 the modulation sets the whole gain. A scalar, ramped over RAMP_FRAMES.

The first call with ports arrives at its values at once. Output does not depend on block size: every ramp is a fixed number of frames. In place is fine: out may be in.

Definition at line 46 of file vca.hpp.

#include <vca.hpp>

Public Member Functions

 Vca ()
 Unity gain until ports are given; every scalar port ramps over RAMP_FRAMES.
 
template<class... Ports>
void process (const float *in, float *out, uint16_t frames, Ports... ports)
 One block, the ports in PORTS' order, any trailing ones left off.
 
void reset ()
 Every ramp at its target.
 
float level_gain () const
 Level's gain after the taper, where the ramp is now.
 
float mod_amount () const
 Mod Amt, where the ramp is now.
 
float gain () const
 The scalar gain, where the ramp is now, or the last frame of a gain block.
 

Static Public Attributes

static constexpr float LEVEL_RANGE_DB = 60.0f
 
static constexpr uint16_t RAMP_FRAMES = 64
 
static constexpr transport::Port PORTS []
 

Constructor & Destructor Documentation

◆ Vca()

sbl::dsp::Vca::Vca ( )
inline

Unity gain until ports are given; every scalar port ramps over RAMP_FRAMES.

Definition at line 52 of file vca.hpp.

References RAMP_FRAMES, and sbl::dsp::Ramp::set_length().

Referenced by process().

Member Function Documentation

◆ process()

template<class... Ports>
void sbl::dsp::Vca::process ( const float *  in,
float *  out,
uint16_t  frames,
Ports...  ports 
)
inline

One block, the ports in PORTS' order, any trailing ones left off.

gain as a block is used as given; as a scalar it moves to its value over RAMP_FRAMES. Level and Mod Amt are scalars. The first value a port is given jumps. A port left off holds its last value, and ramps in progress continue. In place is fine: out may be in.

Template Parameters
Portsgain as a block or an arithmetic scalar, then level and mod_amount as scalars
Parameters
inInput buffer, frames long
[out]outOutput buffer, frames long
framesFrame count
portsgain, nominally [0, 1]; level in [0, 1]; mod_amount in [0, 1], clamped. A non-finite scalar gain or mod_amount counts as 0
Context
Audio thread; real-time safe.

Definition at line 81 of file vca.hpp.

References sbl::math::clamp01(), sbl::math::finite_or(), sbl::transport::fits_v, gain(), sbl::dsp::Ramp::head(), sbl::dsp::Ramp::jump(), sbl::dsp::math::level_gain(), LEVEL_RANGE_DB, mod_amount(), sbl::dsp::Ramp::step(), and Vca().

◆ reset()

void sbl::dsp::Vca::reset ( )
inline

Every ramp at its target.

Definition at line 117 of file vca.hpp.

References sbl::dsp::Ramp::jump(), and sbl::dsp::Ramp::target().

◆ level_gain()

float sbl::dsp::Vca::level_gain ( ) const
inline

Level's gain after the taper, where the ramp is now.

Definition at line 124 of file vca.hpp.

References sbl::dsp::Ramp::value().

◆ mod_amount()

float sbl::dsp::Vca::mod_amount ( ) const
inline

Mod Amt, where the ramp is now.

Definition at line 126 of file vca.hpp.

References sbl::dsp::Ramp::value().

Referenced by process().

◆ gain()

float sbl::dsp::Vca::gain ( ) const
inline

The scalar gain, where the ramp is now, or the last frame of a gain block.

Definition at line 128 of file vca.hpp.

References sbl::dsp::Ramp::value().

Referenced by process().

Member Data Documentation

◆ LEVEL_RANGE_DB

constexpr float sbl::dsp::Vca::LEVEL_RANGE_DB = 60.0f
staticconstexpr

Level's exponential range above silence

Definition at line 48 of file vca.hpp.

Referenced by process().

◆ RAMP_FRAMES

constexpr uint16_t sbl::dsp::Vca::RAMP_FRAMES = 64
staticconstexpr

a scalar port arrives after this many frames

Definition at line 49 of file vca.hpp.

Referenced by Vca().

◆ PORTS

constexpr transport::Port sbl::dsp::Vca::PORTS[]
staticconstexpr
Initial value:

The ports, in the order process() takes them.

Definition at line 59 of file vca.hpp.


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