DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::TubePreamp< T > Class Template Reference

One/two 12AX7 stages with sag and a WDF tone circuit. More...

#include <TubePreamp.h>

Public Member Functions

void prepare (const AudioSpec &spec)
 Allocates both stage configurations per channel and runs the reference calibration. Invalid specs (non-positive or non-finite rate, block size or channel count) are ignored: the previous state is kept and an unprepared instance stays pass-through.
 
void reset () noexcept
 Re-settles every stage at its DC operating point. RT-safe.
 
void setDrive (T db) noexcept
 Input drive in dB [-12, +36]; level-compensated. Non-finite values are ignored.
 
void setTreble (T treble) noexcept
 Treble control of the FMV stack [0, 1]. Non-finite values are ignored.
 
void setBass (T bass) noexcept
 Bass control of the FMV stack [0, 1] (log-taper, like the original). Non-finite values are ignored.
 
void setMiddle (T middle) noexcept
 Middle control of the FMV stack [0, 1]. Non-finite values are ignored.
 
void setSag (T sag) noexcept
 Supply sag depth [0, 1] (0 = stiff supply). Non-finite values are ignored.
 
void setStages (int stages) noexcept
 Number of triode stages (1 = clean/edge, 2 = high gain). RT-safe; the prepared latency does not change. A running stream keeps its circuit while the new path warms for 5 ms, then crossfades over 20 ms. Reversing a running fade preserves both circuit states.
 
void setOversampling (int factor)
 Configures internal oversampling of the nonlinear circuit (visible, tunable and switchable off). SETUP THREAD ONLY - it reallocates the polyphase filters and re-runs the reference calibration exactly like prepare(); never call it concurrently with processBlock().
 
int getOversamplingFactor () const noexcept
 Active oversampling factor (1 = off, 2 = default).
 
void setOutput (T db) noexcept
 Static output trim in dB [-24, +12]. Non-finite values are ignored.
 
void setMix (T mix) noexcept
 Dry/wet mix [0, 1]; dry is latency-compensated and the mix is ramped over at least 20 ms. Non-finite values are ignored.
 
T getDrive () const noexcept
 
T getTreble () const noexcept
 
T getBass () const noexcept
 
T getMiddle () const noexcept
 
T getSag () const noexcept
 
int getStages () const noexcept
 
T getOutput () const noexcept
 
T getMix () const noexcept
 
int getLatency () const noexcept
 Latency in prepared-rate samples added by the oversampler and the continuous core (0 at 1x = off); reflects the current factor, so hosts can compensate (PDC).
 
int getLatencySamples () const noexcept
 Compatibility alias of getLatency(), in prepared-rate samples.
 
T getSupplyVoltage () const noexcept
 Effective B+ supply voltage of channel 0 (sag meter readout). During a stage transition, uses the same blend weights as the wet paths.
 
std::vector< uint8_t > getState () const
 Serializes the parameter state (setup/UI threads; allocates).
 
bool setState (const uint8_t *data, size_t size)
 Restores parameters from a blob (tolerant; rejects foreign ids).
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes a block in-place. Pass-through until prepare() succeeds.
 

Detailed Description

template<FloatType T>
class dspark::TubePreamp< T >

One/two 12AX7 stages with sag and a WDF tone circuit.

Template Parameters
TSample type (float or double).

Definition at line 709 of file TubePreamp.h.

Member Function Documentation

◆ getBass()

template<FloatType T>
T dspark::TubePreamp< T >::getBass ( ) const
inlinenoexcept

Definition at line 901 of file TubePreamp.h.

◆ getDrive()

template<FloatType T>
T dspark::TubePreamp< T >::getDrive ( ) const
inlinenoexcept

Definition at line 899 of file TubePreamp.h.

◆ getLatency()

template<FloatType T>
int dspark::TubePreamp< T >::getLatency ( ) const
inlinenoexcept

Latency in prepared-rate samples added by the oversampler and the continuous core (0 at 1x = off); reflects the current factor, so hosts can compensate (PDC).

Definition at line 911 of file TubePreamp.h.

◆ getLatencySamples()

template<FloatType T>
int dspark::TubePreamp< T >::getLatencySamples ( ) const
inlinenoexcept

Compatibility alias of getLatency(), in prepared-rate samples.

Definition at line 914 of file TubePreamp.h.

◆ getMiddle()

template<FloatType T>
T dspark::TubePreamp< T >::getMiddle ( ) const
inlinenoexcept

Definition at line 902 of file TubePreamp.h.

◆ getMix()

template<FloatType T>
T dspark::TubePreamp< T >::getMix ( ) const
inlinenoexcept

Definition at line 906 of file TubePreamp.h.

◆ getOutput()

template<FloatType T>
T dspark::TubePreamp< T >::getOutput ( ) const
inlinenoexcept

Definition at line 905 of file TubePreamp.h.

◆ getOversamplingFactor()

template<FloatType T>
int dspark::TubePreamp< T >::getOversamplingFactor ( ) const
inlinenoexcept

Active oversampling factor (1 = off, 2 = default).

Definition at line 882 of file TubePreamp.h.

◆ getSag()

template<FloatType T>
T dspark::TubePreamp< T >::getSag ( ) const
inlinenoexcept

Definition at line 903 of file TubePreamp.h.

◆ getStages()

template<FloatType T>
int dspark::TubePreamp< T >::getStages ( ) const
inlinenoexcept

Definition at line 904 of file TubePreamp.h.

◆ getState()

template<FloatType T>
std::vector< uint8_t > dspark::TubePreamp< T >::getState ( ) const
inline

Serializes the parameter state (setup/UI threads; allocates).

Definition at line 924 of file TubePreamp.h.

◆ getSupplyVoltage()

template<FloatType T>
T dspark::TubePreamp< T >::getSupplyVoltage ( ) const
inlinenoexcept

Effective B+ supply voltage of channel 0 (sag meter readout). During a stage transition, uses the same blend weights as the wet paths.

Definition at line 918 of file TubePreamp.h.

◆ getTreble()

template<FloatType T>
T dspark::TubePreamp< T >::getTreble ( ) const
inlinenoexcept

Definition at line 900 of file TubePreamp.h.

◆ prepare()

template<FloatType T>
void dspark::TubePreamp< T >::prepare ( const AudioSpec &  spec)
inline

Allocates both stage configurations per channel and runs the reference calibration. Invalid specs (non-positive or non-finite rate, block size or channel count) are ignored: the previous state is kept and an unprepared instance stays pass-through.

Definition at line 718 of file TubePreamp.h.

◆ processBlock()

template<FloatType T>
void dspark::TubePreamp< T >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes a block in-place. Pass-through until prepare() succeeds.

Definition at line 963 of file TubePreamp.h.

◆ reset()

template<FloatType T>
void dspark::TubePreamp< T >::reset ( )
inlinenoexcept

Re-settles every stage at its DC operating point. RT-safe.

Definition at line 781 of file TubePreamp.h.

◆ setBass()

template<FloatType T>
void dspark::TubePreamp< T >::setBass ( T  bass)
inlinenoexcept

Bass control of the FMV stack [0, 1] (log-taper, like the original). Non-finite values are ignored.

Definition at line 823 of file TubePreamp.h.

◆ setDrive()

template<FloatType T>
void dspark::TubePreamp< T >::setDrive ( T  db)
inlinenoexcept

Input drive in dB [-12, +36]; level-compensated. Non-finite values are ignored.

Definition at line 806 of file TubePreamp.h.

◆ setMiddle()

template<FloatType T>
void dspark::TubePreamp< T >::setMiddle ( T  middle)
inlinenoexcept

Middle control of the FMV stack [0, 1]. Non-finite values are ignored.

Definition at line 831 of file TubePreamp.h.

◆ setMix()

template<FloatType T>
void dspark::TubePreamp< T >::setMix ( T  mix)
inlinenoexcept

Dry/wet mix [0, 1]; dry is latency-compensated and the mix is ramped over at least 20 ms. Non-finite values are ignored.

Definition at line 893 of file TubePreamp.h.

◆ setOutput()

template<FloatType T>
void dspark::TubePreamp< T >::setOutput ( T  db)
inlinenoexcept

Static output trim in dB [-24, +12]. Non-finite values are ignored.

Definition at line 885 of file TubePreamp.h.

◆ setOversampling()

template<FloatType T>
void dspark::TubePreamp< T >::setOversampling ( int  factor)
inline

Configures internal oversampling of the nonlinear circuit (visible, tunable and switchable off). SETUP THREAD ONLY - it reallocates the polyphase filters and re-runs the reference calibration exactly like prepare(); never call it concurrently with processBlock().

Parameters
factorPower-of-two multiplier in {1,2,4,8,16}. 1 = OFF (no internal resampling, zero added latency; the triode/grid nonlinearity then aliases in-band unless the surrounding chain is oversampled). 2 is the default. Higher factors lower the residual error at higher CPU. Invalid or non-power-of-two values are ignored. getLatency() reflects the new factor after this call (0 at 1x).

Definition at line 869 of file TubePreamp.h.

◆ setSag()

template<FloatType T>
void dspark::TubePreamp< T >::setSag ( T  sag)
inlinenoexcept

Supply sag depth [0, 1] (0 = stiff supply). Non-finite values are ignored.

Definition at line 839 of file TubePreamp.h.

◆ setStages()

template<FloatType T>
void dspark::TubePreamp< T >::setStages ( int  stages)
inlinenoexcept

Number of triode stages (1 = clean/edge, 2 = high gain). RT-safe; the prepared latency does not change. A running stream keeps its circuit while the new path warms for 5 ms, then crossfades over 20 ms. Reversing a running fade preserves both circuit states.

Definition at line 850 of file TubePreamp.h.

◆ setState()

template<FloatType T>
bool dspark::TubePreamp< T >::setState ( const uint8_t *  data,
size_t  size 
)
inline

Restores parameters from a blob (tolerant; rejects foreign ids).

Definition at line 942 of file TubePreamp.h.

◆ setTreble()

template<FloatType T>
void dspark::TubePreamp< T >::setTreble ( T  treble)
inlinenoexcept

Treble control of the FMV stack [0, 1]. Non-finite values are ignored.

Definition at line 814 of file TubePreamp.h.


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