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

Reel-to-reel tape emulation with physical hysteresis and transport. More...

#include <TapeMachine.h>

Public Types

enum class  Standard { NAB , CCIR }
 Playback equalization standard. More...
 
enum class  Speed { IPS_7_5 , IPS_15 , IPS_30 }
 Tape speed. More...
 

Public Member Functions

void prepare (const AudioSpec &spec)
 Allocates the whole chain. 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
 Clears all signal state (keeps parameters). RT-safe.
 
void setDrive (T driveDb) noexcept
 Input drive in dB [-12, +24]. Level-compensated: more drive means more saturation at roughly constant loudness. Non-finite values are ignored.
 
void setBias (T bias) noexcept
 Bias setting [0, 1]; 0.5 is nominal calibration (carrier at 3x the JA field constant: full branch-memory erasure, clean odd saturation). Below nominal the carrier drops under the erase threshold: growing distortion and the level instability of a real under-biased machine. Above nominal, self-erasure progressively rolls off the top octave. Non-finite values are ignored.
 
void setOversampling (int factor)
 Configures internal oversampling of the biased hysteresis core (visible, tunable and switchable off). SETUP THREAD ONLY - it reallocates the polyphase filters and re-prepares/re-calibrates the whole chain exactly like prepare(); never call it concurrently with processBlock().
 
int getOversamplingFactor () const noexcept
 Active oversampling factor (1 = off, 4 = default).
 
void setSpeed (Speed s) noexcept
 Tape speed (changes EQ time constants, losses and head bump). Out-of-range values are clamped.
 
void setStandard (Standard s) noexcept
 Equalization standard (NAB adds the LF time constant). Out-of-range values are clamped.
 
void setLossEffects (T amount) noexcept
 Playback loss intensity [0, 1] (0 bypasses the loss FIR). Non-finite values are ignored.
 
void setHeadBump (T amount) noexcept
 Head-bump resonance intensity [0, 1] (~2.5 dB at full). Non-finite values are ignored.
 
void setWowFlutter (T amount) noexcept
 Wow & flutter depth [0, 1] (~0.25% peak pitch deviation at 1). Non-finite values are ignored.
 
void setNoise (T dbfs) noexcept
 Tape hiss level in dBFS (e.g. -55 for audible vintage hiss); values <= -120 disable it (default). Non-finite values are ignored.
 
void setMix (T mix) noexcept
 Dry/wet mix [0, 1]; dry is latency-compensated. Non-finite values are ignored.
 
T getDrive () const noexcept
 
T getBias () const noexcept
 
Speed getSpeed () const noexcept
 
Standard getStandard () const noexcept
 
T getLossEffects () const noexcept
 
T getHeadBump () const noexcept
 
T getWowFlutter () const noexcept
 
T getNoise () const noexcept
 
T getMix () const noexcept
 
int getLatency () const noexcept
 Total latency in samples (active oversampler + loss FIR + transport delay); reflects the current factor for host PDC.
 
int getLatencySamples () const noexcept
 Compatibility alias of getLatency(), in prepared-rate samples.
 
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::TapeMachine< T >

Reel-to-reel tape emulation with physical hysteresis and transport.

Template Parameters
TSample type (float or double).

Definition at line 121 of file TapeMachine.h.

Member Enumeration Documentation

◆ Speed

template<FloatType T>
enum class dspark::TapeMachine::Speed
strong

Tape speed.

Enumerator
IPS_7_5 
IPS_15 
IPS_30 

Definition at line 128 of file TapeMachine.h.

◆ Standard

template<FloatType T>
enum class dspark::TapeMachine::Standard
strong

Playback equalization standard.

Enumerator
NAB 
CCIR 

Definition at line 125 of file TapeMachine.h.

Member Function Documentation

◆ getBias()

template<FloatType T>
T dspark::TapeMachine< T >::getBias ( ) const
inlinenoexcept

Definition at line 374 of file TapeMachine.h.

◆ getDrive()

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

Definition at line 373 of file TapeMachine.h.

◆ getHeadBump()

template<FloatType T>
T dspark::TapeMachine< T >::getHeadBump ( ) const
inlinenoexcept

Definition at line 384 of file TapeMachine.h.

◆ getLatency()

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

Total latency in samples (active oversampler + loss FIR + transport delay); reflects the current factor for host PDC.

Definition at line 391 of file TapeMachine.h.

◆ getLatencySamples()

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

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

Definition at line 394 of file TapeMachine.h.

◆ getLossEffects()

template<FloatType T>
T dspark::TapeMachine< T >::getLossEffects ( ) const
inlinenoexcept

Definition at line 383 of file TapeMachine.h.

◆ getMix()

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

Definition at line 387 of file TapeMachine.h.

◆ getNoise()

template<FloatType T>
T dspark::TapeMachine< T >::getNoise ( ) const
inlinenoexcept

Definition at line 386 of file TapeMachine.h.

◆ getOversamplingFactor()

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

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

Definition at line 307 of file TapeMachine.h.

◆ getSpeed()

template<FloatType T>
Speed dspark::TapeMachine< T >::getSpeed ( ) const
inlinenoexcept

Definition at line 375 of file TapeMachine.h.

◆ getStandard()

template<FloatType T>
Standard dspark::TapeMachine< T >::getStandard ( ) const
inlinenoexcept

Definition at line 379 of file TapeMachine.h.

◆ getState()

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

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

Definition at line 397 of file TapeMachine.h.

◆ getWowFlutter()

template<FloatType T>
T dspark::TapeMachine< T >::getWowFlutter ( ) const
inlinenoexcept

Definition at line 385 of file TapeMachine.h.

◆ prepare()

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

Allocates the whole chain. 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 135 of file TapeMachine.h.

◆ processBlock()

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

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

Definition at line 437 of file TapeMachine.h.

◆ reset()

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

Clears all signal state (keeps parameters). RT-safe.

Definition at line 228 of file TapeMachine.h.

◆ setBias()

template<FloatType T>
void dspark::TapeMachine< T >::setBias ( T  bias)
inlinenoexcept

Bias setting [0, 1]; 0.5 is nominal calibration (carrier at 3x the JA field constant: full branch-memory erasure, clean odd saturation). Below nominal the carrier drops under the erase threshold: growing distortion and the level instability of a real under-biased machine. Above nominal, self-erasure progressively rolls off the top octave. Non-finite values are ignored.

Definition at line 277 of file TapeMachine.h.

◆ setDrive()

template<FloatType T>
void dspark::TapeMachine< T >::setDrive ( T  driveDb)
inlinenoexcept

Input drive in dB [-12, +24]. Level-compensated: more drive means more saturation at roughly constant loudness. Non-finite values are ignored.

Definition at line 264 of file TapeMachine.h.

◆ setHeadBump()

template<FloatType T>
void dspark::TapeMachine< T >::setHeadBump ( T  amount)
inlinenoexcept

Head-bump resonance intensity [0, 1] (~2.5 dB at full). Non-finite values are ignored.

Definition at line 342 of file TapeMachine.h.

◆ setLossEffects()

template<FloatType T>
void dspark::TapeMachine< T >::setLossEffects ( T  amount)
inlinenoexcept

Playback loss intensity [0, 1] (0 bypasses the loss FIR). Non-finite values are ignored.

Definition at line 333 of file TapeMachine.h.

◆ setMix()

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

Dry/wet mix [0, 1]; dry is latency-compensated. Non-finite values are ignored.

Definition at line 367 of file TapeMachine.h.

◆ setNoise()

template<FloatType T>
void dspark::TapeMachine< T >::setNoise ( T  dbfs)
inlinenoexcept

Tape hiss level in dBFS (e.g. -55 for audible vintage hiss); values <= -120 disable it (default). Non-finite values are ignored.

Definition at line 359 of file TapeMachine.h.

◆ setOversampling()

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

Configures internal oversampling of the biased hysteresis core (visible, tunable and switchable off). SETUP THREAD ONLY - it reallocates the polyphase filters and re-prepares/re-calibrates the whole chain exactly like prepare(); never call it concurrently with processBlock().

Parameters
factorPower-of-two multiplier in {1,2,4,8,16}. DEFAULT 4. 1 = OFF (no internal resampling, zero added oversampler latency; the AC-bias carrier then lands in-band at a quarter of the base rate, so 1x is only sensible under host/chain oversampling). CPU scales ~linearly with the factor. Invalid/non-power-of-two values are ignored. getLatency() reflects the new factor after this call.

Definition at line 297 of file TapeMachine.h.

◆ setSpeed()

template<FloatType T>
void dspark::TapeMachine< T >::setSpeed ( Speed  s)
inlinenoexcept

Tape speed (changes EQ time constants, losses and head bump). Out-of-range values are clamped.

Definition at line 311 of file TapeMachine.h.

◆ setStandard()

template<FloatType T>
void dspark::TapeMachine< T >::setStandard ( Standard  s)
inlinenoexcept

Equalization standard (NAB adds the LF time constant). Out-of-range values are clamped.

Definition at line 322 of file TapeMachine.h.

◆ setState()

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

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

Definition at line 416 of file TapeMachine.h.

◆ setWowFlutter()

template<FloatType T>
void dspark::TapeMachine< T >::setWowFlutter ( T  amount)
inlinenoexcept

Wow & flutter depth [0, 1] (~0.25% peak pitch deviation at 1). Non-finite values are ignored.

Definition at line 351 of file TapeMachine.h.


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