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

Frequency-domain hold with tonal and diffuse phase modes. More...

#include <SpectralFreeze.h>

Public Types

enum class  PhaseMode : std::uint8_t { Tonal , Diffuse }
 Phase evolution used by the captured spectrum. More...
 

Public Member Functions

void prepare (const AudioSpec &spec, int fftSize=2048, int hopSize=0)
 Prepares the processor and allocates all audio-path storage.
 
void reset () noexcept
 Clears WOLA, history, capture and transition state. Requested controls are intentionally preserved.
 
void setFrozen (bool frozen) noexcept
 Publishes the requested freeze state with one atomic RMW.
 
bool isFrozen () const noexcept
 Returns the requested freeze state, not transition completion.
 
void setPhaseMode (PhaseMode mode) noexcept
 Publishes the requested phase mode with one atomic RMW. Any representation other than exactly Diffuse selects Tonal.
 
PhaseMode getPhaseMode () const noexcept
 Returns the requested phase mode.
 
std::vector< uint8_t > getState () const
 Serializes the requested freeze state and phase mode (setup/UI threads; allocates). The FFT and hop sizes are prepare() arguments and are not part of it.
 
bool setState (const uint8_t *data, size_t size)
 Restores the freeze request and phase mode from a blob (tolerant; rejects foreign ids). A restored freeze behaves exactly as setFrozen(true) does.
 
int getLatency () const noexcept
 Returns the exact input-signal latency, or zero before prepare.
 
int getFFTSize () const noexcept
 Returns the prepared FFT size, or zero before prepare.
 
int getHopSize () const noexcept
 Returns the prepared hop size, or zero before prepare.
 
int getTransitionSamples () const noexcept
 Returns the N-sample transition duration, or zero unprepared.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes an in-place block without allocation or locking.
 

Detailed Description

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

Frequency-domain hold with tonal and diffuse phase modes.

Template Parameters
TSample type (float or double).

Definition at line 56 of file SpectralFreeze.h.

Member Enumeration Documentation

◆ PhaseMode

template<FloatType T>
enum class dspark::SpectralFreeze::PhaseMode : std::uint8_t
strong

Phase evolution used by the captured spectrum.

Enumerator
Tonal 
Diffuse 

Definition at line 60 of file SpectralFreeze.h.

Member Function Documentation

◆ getFFTSize()

template<FloatType T>
int dspark::SpectralFreeze< T >::getFFTSize ( ) const
inlinenoexcept

Returns the prepared FFT size, or zero before prepare.

Definition at line 203 of file SpectralFreeze.h.

◆ getHopSize()

template<FloatType T>
int dspark::SpectralFreeze< T >::getHopSize ( ) const
inlinenoexcept

Returns the prepared hop size, or zero before prepare.

Definition at line 209 of file SpectralFreeze.h.

◆ getLatency()

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

Returns the exact input-signal latency, or zero before prepare.

Definition at line 197 of file SpectralFreeze.h.

◆ getPhaseMode()

template<FloatType T>
PhaseMode dspark::SpectralFreeze< T >::getPhaseMode ( ) const
inlinenoexcept

Returns the requested phase mode.

Definition at line 166 of file SpectralFreeze.h.

◆ getState()

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

Serializes the requested freeze state and phase mode (setup/UI threads; allocates). The FFT and hop sizes are prepare() arguments and are not part of it.

Definition at line 176 of file SpectralFreeze.h.

◆ getTransitionSamples()

template<FloatType T>
int dspark::SpectralFreeze< T >::getTransitionSamples ( ) const
inlinenoexcept

Returns the N-sample transition duration, or zero unprepared.

Definition at line 215 of file SpectralFreeze.h.

◆ isFrozen()

template<FloatType T>
bool dspark::SpectralFreeze< T >::isFrozen ( ) const
inlinenoexcept

Returns the requested freeze state, not transition completion.

Definition at line 148 of file SpectralFreeze.h.

◆ prepare()

template<FloatType T>
void dspark::SpectralFreeze< T >::prepare ( const AudioSpec &  spec,
int  fftSize = 2048,
int  hopSize = 0 
)
inline

Prepares the processor and allocates all audio-path storage.

Invalid specifications are ignored and preserve the current stream. FFT requests are clamped to [256,32768] and rounded upward to a power of two. Only N/8, N/4 and N/2 are accepted as explicit hop sizes; every other hop selects N/4.

Definition at line 70 of file SpectralFreeze.h.

◆ processBlock()

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

Processes an in-place block without allocation or locking.

Missing prepared channels advance on zero input. Runtime channels beyond the prepared width remain bit-for-bit untouched. Oversize calls are internally sliced without disturbing absolute hop anchors.

Definition at line 227 of file SpectralFreeze.h.

◆ reset()

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

Clears WOLA, history, capture and transition state. Requested controls are intentionally preserved.

Definition at line 132 of file SpectralFreeze.h.

◆ setFrozen()

template<FloatType T>
void dspark::SpectralFreeze< T >::setFrozen ( bool  frozen)
inlinenoexcept

Publishes the requested freeze state with one atomic RMW.

Definition at line 139 of file SpectralFreeze.h.

◆ setPhaseMode()

template<FloatType T>
void dspark::SpectralFreeze< T >::setPhaseMode ( PhaseMode  mode)
inlinenoexcept

Publishes the requested phase mode with one atomic RMW. Any representation other than exactly Diffuse selects Tonal.

Definition at line 157 of file SpectralFreeze.h.

◆ setState()

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

Restores the freeze request and phase mode from a blob (tolerant; rejects foreign ids). A restored freeze behaves exactly as setFrozen(true) does.

Definition at line 187 of file SpectralFreeze.h.


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