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::Vco Class Reference

An oscillator: Tune, and pitch, Wave and Shape as ports over a BlepOsc. More...

Detailed Description

An oscillator: Tune, and pitch, Wave and Shape as ports over a BlepOsc.

A component on the signal transport. It owns a BlepOsc<> and makes the one conversion from each port to the core's natural units. Its ports are process() arguments after the frame count, in the order PORTS declares (common/transport.hpp):

  • pitch, octaves relative to Tune, the exponential pitch path: Tune, the V/Oct input, the MIDI offset and modulation add in octaves, and this is where the sum becomes a frequency. As a scalar it moves to its value over RAMP_FRAMES, linearly in octaves, so a stepped control glides rather than steps. As a block it is used as given, one frequency per frame: the audio-rate FM path.
  • wave, in [0, 1], morphs from the saw at 0 to the pulse at 1. The blend of the two parts follows pulse_amount(), which takes the saw's even harmonics down 40 dB per unit of travel.
  • shape, in [0, 1], is phase distortion: 0 is the plain waveform, 1 the strongest bend. It moves the saw's knee and the pulse's width together from 0.5 down to the core's minimum along knee_for(), halving the knee every quarter turn, so one control means one thing across the morph. Wave and Shape are scalars and ramp inside the core over its RAMP_FRAMES.

Tune is a parameter: the frequency at zero pitch in cycles per frame, set once by the app from Hz and the target's sample rate, so the component holds no sample rate.

Out-of-range port values are clamped; a non-finite value counts as 0. Output is the core's, nominally [-1, 1] with the overshoot of its kernel (polyblep.hpp), LATENCY frames late, with the DC the bend and the pulse carry. Output does not depend on block size: every ramp is a fixed number of frames.

Definition at line 53 of file vco.hpp.

#include <vco.hpp>

Public Types

using Core = BlepOsc<>
 

Public Member Functions

 Vco ()
 No Tune until set; a scalar pitch ramps over RAMP_FRAMES.
 
void set_tune (float cycles_per_frame)
 Parameter: the frequency at zero pitch.
 
template<class... Ports>
void process (float *out, uint16_t frames, Ports... ports)
 One block, the ports in PORTS' order, any trailing ones left off.
 
void reset ()
 Phase to zero, every ramp at its target, corrections dropped.
 
float frequency () const
 The core's frequency after the last process(), cycles per frame.
 
float pitch () const
 The pitch the ramp is at, octaves.
 

Static Public Member Functions

static float pulse_amount (float wave)
 The pulse's weight for a Wave setting, with the saw's weight 1 minus it.
 
static float knee_for (float shape)
 The saw's knee and the pulse's width for a Shape setting: 0.5 halved SHAPE_OCTAVES times across the knob.
 

Static Public Attributes

static constexpr uint8_t LATENCY = Core::LATENCY
 
static constexpr float MIN_KNEE = Core::MIN_BREAKPOINT
 
static constexpr float WAVE_EVENS_DB_PER_UNIT = 40.0f
 
static constexpr float SHAPE_OCTAVES = 4.0f
 
static constexpr uint16_t RAMP_FRAMES = Core::RAMP_FRAMES
 
static constexpr uint16_t CHUNK_FRAMES = 32
 
static constexpr transport::Port PORTS []
 The ports, in the order process() takes them.
 
static constexpr transport::Parameter< Vco > PARAMETERS []
 The parameters, for tools.
 

Member Typedef Documentation

◆ Core

the core, on the default kernel

Definition at line 55 of file vco.hpp.

Constructor & Destructor Documentation

◆ Vco()

sbl::dsp::Vco::Vco ( )
inline

No Tune until set; a scalar pitch ramps over RAMP_FRAMES.

Definition at line 65 of file vco.hpp.

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

Referenced by process().

Member Function Documentation

◆ pulse_amount()

static float sbl::dsp::Vco::pulse_amount ( float  wave)
inlinestatic

The pulse's weight for a Wave setting, with the saw's weight 1 minus it.

The saw's even harmonics scale by (1 - w) * 10^(-2w): 40 dB per unit, and gone at 1.

Parameters
waveWave, clamped to [0, 1]; non-finite counts as 0
Returns
The pulse's weight, in [0, 1]

Definition at line 76 of file vco.hpp.

References sbl::math::clamp01(), sbl::math::finite_or(), and WAVE_EVENS_DB_PER_UNIT.

Referenced by process().

◆ knee_for()

static float sbl::dsp::Vco::knee_for ( float  shape)
inlinestatic

The saw's knee and the pulse's width for a Shape setting: 0.5 halved SHAPE_OCTAVES times across the knob.

Parameters
shapeShape, clamped to [0, 1]; non-finite counts as 0
Returns
The knee, in [MIN_KNEE, 0.5]

Definition at line 88 of file vco.hpp.

References sbl::math::clamp01(), sbl::math::finite_or(), and SHAPE_OCTAVES.

Referenced by process().

◆ set_tune()

void sbl::dsp::Vco::set_tune ( float  cycles_per_frame)
inline

Parameter: the frequency at zero pitch.

Parameters
cycles_per_frameTune in cycles per frame; non-finite or negative counts as 0
Context
Same thread as process(); real-time safe.

Definition at line 98 of file vco.hpp.

References sbl::math::finite_or().

◆ process()

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

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

Pitch as a block is used as given, one frequency per frame. As a scalar it moves to its value over RAMP_FRAMES; the first scalar jumps. Wave and Shape ramp inside the core. A port left off holds its last value, and ramps in progress continue.

Template Parameters
Portspitch as a block or an arithmetic scalar, then wave and shape as scalars
Parameters
[out]outOutput buffer, frames long
framesFrame count
portspitch in octaves over Tune; wave in [0, 1]; shape in [0, 1]
Context
Audio thread; real-time safe.

Definition at line 132 of file vco.hpp.

References sbl::transport::fits_v, knee_for(), pitch(), pulse_amount(), sbl::dsp::BlepOsc< Kernel >::set_blend(), sbl::dsp::BlepOsc< Kernel >::set_pulse_width(), sbl::dsp::BlepOsc< Kernel >::set_saw_knee(), and Vco().

◆ reset()

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

Phase to zero, every ramp at its target, corrections dropped.

Definition at line 158 of file vco.hpp.

References sbl::dsp::Ramp::jump(), sbl::dsp::BlepOsc< Kernel >::reset(), and sbl::dsp::Ramp::target().

◆ frequency()

float sbl::dsp::Vco::frequency ( ) const
inline

The core's frequency after the last process(), cycles per frame.

Definition at line 164 of file vco.hpp.

References sbl::dsp::BlepOsc< Kernel >::frequency().

◆ pitch()

float sbl::dsp::Vco::pitch ( ) const
inline

The pitch the ramp is at, octaves.

Definition at line 167 of file vco.hpp.

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

Referenced by process().

Member Data Documentation

◆ LATENCY

constexpr uint8_t sbl::dsp::Vco::LATENCY = Core::LATENCY
staticconstexpr

frames the output trails

Definition at line 57 of file vco.hpp.

◆ MIN_KNEE

constexpr float sbl::dsp::Vco::MIN_KNEE = Core::MIN_BREAKPOINT
staticconstexpr

the knee and width at Shape 1

Definition at line 58 of file vco.hpp.

◆ WAVE_EVENS_DB_PER_UNIT

constexpr float sbl::dsp::Vco::WAVE_EVENS_DB_PER_UNIT = 40.0f
staticconstexpr

how far the saw's even harmonics fall across Wave

Definition at line 59 of file vco.hpp.

Referenced by pulse_amount().

◆ SHAPE_OCTAVES

constexpr float sbl::dsp::Vco::SHAPE_OCTAVES = 4.0f
staticconstexpr

the knee halves this many times across Shape: 0.5 to 1/32

Definition at line 60 of file vco.hpp.

Referenced by knee_for().

◆ RAMP_FRAMES

constexpr uint16_t sbl::dsp::Vco::RAMP_FRAMES = Core::RAMP_FRAMES
staticconstexpr

a scalar pitch arrives after this many frames

Definition at line 61 of file vco.hpp.

Referenced by Vco().

◆ CHUNK_FRAMES

constexpr uint16_t sbl::dsp::Vco::CHUNK_FRAMES = 32
staticconstexpr

frames of per-frame frequency rendered at a time

Definition at line 62 of file vco.hpp.

◆ PORTS

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

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

Definition at line 106 of file vco.hpp.

◆ PARAMETERS

constexpr transport::Parameter<Vco> sbl::dsp::Vco::PARAMETERS[]
staticconstexpr
Initial value:
= {
}
void set_tune(float cycles_per_frame)
Parameter: the frequency at zero pitch.
Definition vco.hpp:98

The parameters, for tools.

Definition at line 113 of file vco.hpp.


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