DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::detail Namespace Reference

Namespaces

namespace  continuous_clip
 
namespace  fft
 
namespace  offline_clip
 
namespace  offline_sinc
 
namespace  stereo_color_coefficients
 

Classes

class  AccountedAllocator
 
struct  AllocationAccount
 
class  BitcrusherAlgorithm
 
class  ContinuousStereoColor
 
class  ConvolutionRate
 
struct  DcBlockState
 Previous input and output of the one-pole DC blocker. More...
 
class  DownsampleAlgorithm
 
class  ExciterAlgorithm
 
class  HardClipAlgorithm
 
class  MultiStageAlgorithm
 
class  OfflineAttenuation
 
struct  OfflineBeatEngine
 
class  OfflineBlock
 
class  OfflineBoundaryFeasibility
 
class  OfflineBoxSmoother
 
struct  OfflineClipCalibration
 
struct  OfflineClipMeasurement
 
struct  OfflineClipOptions
 
class  OfflineClipProcessor
 
class  OfflineConvolutionWindow
 
class  OfflineEndpointWeights
 
class  OfflineExclusions
 
struct  OfflineFailure
 
class  OfflineGainProduct
 
struct  OfflineGainRenderSettings
 
class  OfflineGainSource
 
class  OfflineHilbertMap
 
class  OfflineMemoryPool
 
class  OfflineProductCombination
 
class  OfflineProductWorkspace
 
class  OfflinePunchEnvelope
 
struct  OfflineScratchDeleter
 
class  OfflineSession
 
struct  OfflineSinkTransaction
 
struct  OfflineSoftClipOptions
 
struct  OfflineSourceSummary
 
class  OfflineStereoStream
 
class  OnsetNovelty
 Shared whitening, spectral/complex flux and SuperFlux feature history. More...
 
class  OnsetPeakPicker
 Allocation-free symmetric novelty peak picker with an explicit frame clock. More...
 
class  OnsetSpectrum
 Reusable periodic-Hann real spectrum, without feature history. More...
 
class  OversampledStereoColor
 
class  PhaseVocoderEngine
 Identity-phase-locked STFT analysis/synthesis core (internal). More...
 
class  RetimedDcBlock
 
class  ReverbBankPublisher
 
struct  ReverbPublisherNoopHooks
 
class  SaturationAlgorithm
 
class  ScaledSumSquares
 Scaled sum of squares; caller validates finite input and counts values. More...
 
class  StereoColor
 
class  StudioVocoder
 Streaming phase-gradient vocoder with a strike-anchored time map. More...
 
class  TanhAlgorithm
 
class  TapeAlgorithm
 
struct  TptSvfOutput
 Lowpass and constant-skirt-gain bandpass outputs. More...
 
struct  TptSvfState
 Equivalent-current memories of the two trapezoidal integrators. More...
 
class  TransformerAlgorithm
 
class  TubeAlgorithm
 
class  WavefolderAlgorithm
 

Typedefs

template<typename T >
using OfflineScratchArray = std::unique_ptr< T[], OfflineScratchDeleter< T > >
 
using OfflineBeatMemory = OfflineMemoryPool
 

Enumerations

enum class  ClipperCurve {
  Hard , Tanh , Sine , GoldenRatio ,
  SymmetricKnee , AsymmetricKnee
}
 

Functions

double advanceBoxAverage (double incoming, double outgoing, double &sum, double inverseLength) noexcept
 
template<ClipperCurve Curve, FloatType T>
constexpr T clipperSmallSignalSlope () noexcept
 Exact small-signal slope of the implemented stateless curve.
 
template<ClipperCurve Curve, FloatType T>
std::array< T, 2 > clipperLinearLimits (T ceiling) noexcept
 Exact linear-region endpoints of a rational clipping curve.
 
template<ClipperCurve Curve, FloatType T>
T clipperShape (T sample, T ceiling) noexcept
 Shared transfer functions; no state or implicit antialiasing.
 
double dcBlockStep (double pole, DcBlockState &state, double input) noexcept
 Applies (1 - z^-1) / (1 - pole * z^-1), with a pole in [0, 1).
 
template<typename T >
T logCosh (T x) noexcept
 
double integralLogCosh (double x) noexcept
 
double offlineClipPeakErrorDb (double peak, double target) noexcept
 
bool offlineClipTargetMet (double peak, double target, double errorDb) noexcept
 
template<class Render >
OfflineClipCalibration offlineCalibrateClip (double initialCeiling, double target, Render render)
 
template<class Result , FloatType T, class Report , class CursorFactory >
Result offlineRenderGain (OfflineAudioSource< T > &source, const OfflineAudioSpec &spec, const OfflineFingerprint &expectedFingerprint, double inputPeak, bool valid, bool changed, const Report &report, OfflineAudioSink< T > &sink, const OfflineJobOptions &options, CursorFactory makeCursor, OfflineGainRenderSettings settings={})
 
template<class LeftReader , class RightReader , class Consumer >
void offlineBandlimitedProduct (OfflineSession &job, std::int64_t frames, LeftReader left, RightReader right, Consumer consume, int block=0)
 
template<FloatType T>
double offlineRepresentablePeakGain (double inputPeak, double gain) noexcept
 
template<FloatType T, class Consume >
OfflineSourceSummary offlineScanSource (OfflineAudioSource< T > &source, const OfflineAudioSpec &spec, OfflineBlock< T > &scratch, const OfflineSession &job, OfflinePhase phase, Consume consume)
 
template<FloatType T, class Consume >
void offlineScanMagnitude (OfflineAudioSource< T > &source, const OfflineAudioSpec &spec, const OfflineFingerprint &expectedFingerprint, double inputPeak, OfflineBlock< T > &scratch, const OfflineSession &job, Consume consume)
 
template<class Function >
void offlineCallSink (Function &&function)
 
template<class Processor , FloatType T, int MaxChannels, class Options >
Processor::Result offlineRun (const Processor &processor, const AudioBuffer< T, MaxChannels > &input, AudioBuffer< T, MaxChannels > &output, double sampleRate, const Options &options, const OfflineJobOptions &job)
 
template<FloatType T>
T rationalKneeMagnitude (T magnitude, T knee, T ceiling) noexcept
 Positive magnitude of the original Clipper rational soft knee.
 
double rationalKneeShape (double input, double positiveKnee, double negativeKnee) noexcept
 Unit-ceiling curve with independent positive and negative knees.
 
double rationalKneeIntegral (double input, double positiveKnee, double negativeKnee) noexcept
 Antiderivative of the unit-ceiling curve, with F(0) = 0.
 
template<FloatType T>
TptSvfOutput< T > tptSvfStep (T input, TptSvfState< T > &state, T a1, T a2, T a3) noexcept
 Advances the expanded Simper TPT recurrence by one sample.
 
double hilbertIdealImpulse (std::int64_t index) noexcept
 
void offlineFail (OfflineStatus status)
 
OfflineStatus offlineExceptionStatus () noexcept
 
std::size_t offlineBytes (std::uint64_t count, std::size_t size)
 
OfflineJobOptions offlineRemaining (const OfflineJobOptions &job, std::size_t used)
 
void offlineValidateSpec (const OfflineAudioSpec &spec, int maximumChannels=16)
 
template<FloatType T>
void offlineRead (OfflineAudioSource< T > &source, const OfflineAudioSpec &expected, std::int64_t first, AudioBufferView< T > block)
 
template<FloatType T>
void offlineHash (OfflineFingerprint &state, T sample) noexcept
 
void appendStateJsonString (std::string &out, const std::string &s)
 Appends a JSON string literal, escaping the characters JSON forbids. Keys follow the [A-Za-z0-9._] convention (so this normally emits verbatim), but the convention is not enforced on the writer or reader, and untrusted blobs can carry arbitrary key bytes; escaping keeps the emitted JSON valid and non-injectable in every case.
 
void appendStateJsonNumber (std::string &out, float v)
 Locale-independent float rendering ("%.9g" with a forced dot). Non-finite payloads (NaN/Inf – e.g. a corrupt blob or a bugged parameter) are emitted as JSON-legal 0 so the output always parses and round-trips.
 
const char * parseStateJsonNumber (const char *s, const char *end, double &out) noexcept
 Locale-independent number parse over [s, end); nullptr on failure.
 
std::string stateToJsonImpl (const std::vector< uint8_t > &blob, int depth)
 
std::vector< uint8_t > stateFromJsonImpl (const std::string &json, int depth)
 

Variables

template<FloatType T>
constexpr std::array< T, 5 > fastSinPolynomial
 
constexpr int kMaxStateJsonDepth = 32
 

Typedef Documentation

◆ OfflineBeatMemory

Definition at line 23 of file OfflineBeatEngine.h.

◆ OfflineScratchArray

template<typename T >
using dspark::detail::OfflineScratchArray = typedef std::unique_ptr<T[], OfflineScratchDeleter<T> >

Definition at line 312 of file OfflineProcessing.h.

Enumeration Type Documentation

◆ ClipperCurve

enum class dspark::detail::ClipperCurve
strong
Enumerator
Hard 
Tanh 
Sine 
GoldenRatio 
SymmetricKnee 
AsymmetricKnee 

Definition at line 23 of file ClipperShape.h.

Function Documentation

◆ advanceBoxAverage()

double dspark::detail::advanceBoxAverage ( double  incoming,
double  outgoing,
double &  sum,
double  inverseLength 
)
inlinenoexcept

Definition at line 12 of file BoxAverage.h.

◆ appendStateJsonNumber()

void dspark::detail::appendStateJsonNumber ( std::string &  out,
float  v 
)
inline

Locale-independent float rendering ("%.9g" with a forced dot). Non-finite payloads (NaN/Inf – e.g. a corrupt blob or a bugged parameter) are emitted as JSON-legal 0 so the output always parses and round-trips.

Definition at line 323 of file StateBlob.h.

◆ appendStateJsonString()

void dspark::detail::appendStateJsonString ( std::string &  out,
const std::string &  s 
)
inline

Appends a JSON string literal, escaping the characters JSON forbids. Keys follow the [A-Za-z0-9._] convention (so this normally emits verbatim), but the convention is not enforced on the writer or reader, and untrusted blobs can carry arbitrary key bytes; escaping keeps the emitted JSON valid and non-injectable in every case.

Definition at line 289 of file StateBlob.h.

◆ clipperLinearLimits()

template<ClipperCurve Curve, FloatType T>
std::array< T, 2 > dspark::detail::clipperLinearLimits ( T  ceiling)
inlinenoexcept

Exact linear-region endpoints of a rational clipping curve.

Definition at line 45 of file ClipperShape.h.

◆ clipperShape()

template<ClipperCurve Curve, FloatType T>
T dspark::detail::clipperShape ( T  sample,
T  ceiling 
)
inlinenoexcept

Shared transfer functions; no state or implicit antialiasing.

Definition at line 62 of file ClipperShape.h.

◆ clipperSmallSignalSlope()

template<ClipperCurve Curve, FloatType T>
constexpr T dspark::detail::clipperSmallSignalSlope ( )
constexprnoexcept

Exact small-signal slope of the implemented stateless curve.

Definition at line 35 of file ClipperShape.h.

◆ dcBlockStep()

double dspark::detail::dcBlockStep ( double  pole,
DcBlockState &  state,
double  input 
)
inlinenoexcept

Applies (1 - z^-1) / (1 - pole * z^-1), with a pole in [0, 1).

Definition at line 24 of file DcBlock.h.

◆ hilbertIdealImpulse()

double dspark::detail::hilbertIdealImpulse ( std::int64_t  index)
inlinenoexcept

Definition at line 41 of file Hilbert.h.

◆ integralLogCosh()

double dspark::detail::integralLogCosh ( double  x)
inlinenoexcept

Integral of log(cosh(x)), with value zero at the origin. A Chebyshev polynomial handles |x| < 1 without cancellation. The outer branch integrates the exponentially convergent log1p expansion; its omitted dilogarithm tail is below 5e-18 at |x| >= 1.

Definition at line 30 of file LogCosh.h.

◆ logCosh()

template<typename T >
T dspark::detail::logCosh ( T  x)
inlinenoexcept

Stable log(cosh(x)), shared by the tanh antiderivative kernels.

Definition at line 11 of file LogCosh.h.

◆ offlineBandlimitedProduct()

template<class LeftReader , class RightReader , class Consumer >
void dspark::detail::offlineBandlimitedProduct ( OfflineSession &  job,
std::int64_t  frames,
LeftReader  left,
RightReader  right,
Consumer  consume,
int  block = 0 
)
inline

Definition at line 460 of file OfflineProduct.h.

◆ offlineBytes()

std::size_t dspark::detail::offlineBytes ( std::uint64_t  count,
std::size_t  size 
)
inline

Definition at line 289 of file OfflineProcessing.h.

◆ offlineCalibrateClip()

template<class Render >
OfflineClipCalibration dspark::detail::offlineCalibrateClip ( double  initialCeiling,
double  target,
Render  render 
)

Definition at line 82 of file OfflineClip.h.

◆ offlineCallSink()

template<class Function >
void dspark::detail::offlineCallSink ( Function &&  function)
inline

Definition at line 186 of file OfflineWorker.h.

◆ offlineClipPeakErrorDb()

double dspark::detail::offlineClipPeakErrorDb ( double  peak,
double  target 
)
inlinenoexcept

Definition at line 62 of file OfflineClip.h.

◆ offlineClipTargetMet()

bool dspark::detail::offlineClipTargetMet ( double  peak,
double  target,
double  errorDb 
)
inlinenoexcept

Definition at line 70 of file OfflineClip.h.

◆ offlineExceptionStatus()

OfflineStatus dspark::detail::offlineExceptionStatus ( )
inlinenoexcept

Definition at line 269 of file OfflineProcessing.h.

◆ offlineFail()

void dspark::detail::offlineFail ( OfflineStatus  status)
inline

Definition at line 262 of file OfflineProcessing.h.

◆ offlineHash()

template<FloatType T>
void dspark::detail::offlineHash ( OfflineFingerprint &  state,
T  sample 
)
inlinenoexcept

Definition at line 537 of file OfflineProcessing.h.

◆ offlineRead()

template<FloatType T>
void dspark::detail::offlineRead ( OfflineAudioSource< T > &  source,
const OfflineAudioSpec &  expected,
std::int64_t  first,
AudioBufferView< T >  block 
)
inline

Definition at line 517 of file OfflineProcessing.h.

◆ offlineRemaining()

OfflineJobOptions dspark::detail::offlineRemaining ( const OfflineJobOptions &  job,
std::size_t  used 
)
inline

Definition at line 469 of file OfflineProcessing.h.

◆ offlineRenderGain()

template<class Result , FloatType T, class Report , class CursorFactory >
Result dspark::detail::offlineRenderGain ( OfflineAudioSource< T > &  source,
const OfflineAudioSpec &  spec,
const OfflineFingerprint &  expectedFingerprint,
double  inputPeak,
bool  valid,
bool  changed,
const Report &  report,
OfflineAudioSink< T > &  sink,
const OfflineJobOptions &  options,
CursorFactory  makeCursor,
OfflineGainRenderSettings  settings = {} 
)

Definition at line 124 of file OfflineGain.h.

◆ offlineRepresentablePeakGain()

template<FloatType T>
double dspark::detail::offlineRepresentablePeakGain ( double  inputPeak,
double  gain 
)
inlinenoexcept

Definition at line 26 of file OfflineWorker.h.

◆ offlineRun()

template<class Processor , FloatType T, int MaxChannels, class Options >
Processor::Result dspark::detail::offlineRun ( const Processor &  processor,
const AudioBuffer< T, MaxChannels > &  input,
AudioBuffer< T, MaxChannels > &  output,
double  sampleRate,
const Options &  options,
const OfflineJobOptions &  job 
)

Definition at line 206 of file OfflineWorker.h.

◆ offlineScanMagnitude()

template<FloatType T, class Consume >
void dspark::detail::offlineScanMagnitude ( OfflineAudioSource< T > &  source,
const OfflineAudioSpec &  spec,
const OfflineFingerprint &  expectedFingerprint,
double  inputPeak,
OfflineBlock< T > &  scratch,
const OfflineSession &  job,
Consume  consume 
)
inline

Definition at line 82 of file OfflineWorker.h.

◆ offlineScanSource()

template<FloatType T, class Consume >
OfflineSourceSummary dspark::detail::offlineScanSource ( OfflineAudioSource< T > &  source,
const OfflineAudioSpec &  spec,
OfflineBlock< T > &  scratch,
const OfflineSession &  job,
OfflinePhase  phase,
Consume  consume 
)
inline

Definition at line 45 of file OfflineWorker.h.

◆ offlineValidateSpec()

void dspark::detail::offlineValidateSpec ( const OfflineAudioSpec &  spec,
int  maximumChannels = 16 
)
inline

Definition at line 479 of file OfflineProcessing.h.

◆ parseStateJsonNumber()

const char * dspark::detail::parseStateJsonNumber ( const char *  s,
const char *  end,
double &  out 
)
inlinenoexcept

Locale-independent number parse over [s, end); nullptr on failure.

Definition at line 334 of file StateBlob.h.

◆ rationalKneeIntegral()

double dspark::detail::rationalKneeIntegral ( double  input,
double  positiveKnee,
double  negativeKnee 
)
inlinenoexcept

Antiderivative of the unit-ceiling curve, with F(0) = 0.

Definition at line 39 of file RationalKnee.h.

◆ rationalKneeMagnitude()

template<FloatType T>
T dspark::detail::rationalKneeMagnitude ( T  magnitude,
T  knee,
T  ceiling 
)
inlinenoexcept

Positive magnitude of the original Clipper rational soft knee.

Definition at line 21 of file RationalKnee.h.

◆ rationalKneeShape()

double dspark::detail::rationalKneeShape ( double  input,
double  positiveKnee,
double  negativeKnee 
)
inlinenoexcept

Unit-ceiling curve with independent positive and negative knees.

Definition at line 31 of file RationalKnee.h.

◆ stateFromJsonImpl()

std::vector< uint8_t > dspark::detail::stateFromJsonImpl ( const std::string &  json,
int  depth 
)
inline

Definition at line 431 of file StateBlob.h.

◆ stateToJsonImpl()

std::string dspark::detail::stateToJsonImpl ( const std::vector< uint8_t > &  blob,
int  depth 
)
inline

Definition at line 391 of file StateBlob.h.

◆ tptSvfStep()

template<FloatType T>
TptSvfOutput< T > dspark::detail::tptSvfStep ( T  input,
TptSvfState< T > &  state,
T  a1,
T  a2,
T  a3 
)
inlinenoexcept

Advances the expanded Simper TPT recurrence by one sample.

Parameters
inputCurrent input sample.
stateIntegrator memories, updated in place.
a11 / (1 + g * (g + k)), where g = tan(pi * f / fs) and k = 1 / Q.
a2g * a1.
a3g * a2.
Note
Keeps the operation order of StateVariableFilter, including its state update. See https://cytomic.com/files/dsp/SvfLinearTrapOptimised2.pdf .

Definition at line 43 of file TptSvf.h.

Variable Documentation

◆ fastSinPolynomial

template<FloatType T>
constexpr std::array<T, 5> dspark::detail::fastSinPolynomial
inlineconstexpr
Initial value:
{
T(0.99999997408724855), T(-0.16666646026660671), T(0.0083328727116396326),
T(-0.00019799239565814083), T(2.5871610835732768e-6)}

Definition at line 35 of file DspMath.h.

◆ kMaxStateJsonDepth

constexpr int dspark::detail::kMaxStateJsonDepth = 32
constexpr

Nesting cap for the JSON round-trip: real processor states nest 2-3 levels; a crafted input must not be able to overflow the stack.

Definition at line 282 of file StateBlob.h.