Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::FreezeHoldSnapshotT< SampleType > Struct Template Reference

Value image of a FreezeHold's held state: everything needed to reproduce the held output bit-for-bit on a hold prepared with the same geometry. More...

#include <freeze_hold.hpp>

Public Member Functions

bool prepare (int fft, int ch, int hop)
 Allocate storage for a geometry. Not audio-thread safe.
bool valid () const noexcept
 Shape and value check: geometry in bounds, storage sized for it, a consistent fade record, every value finite, magnitudes non-negative, phases wrapped, and a non-zero PRNG state (zero is a fixed point of xorshift).
bool write_bytes (std::vector< std::uint8_t > &out) const
 Serialize to the versioned byte image.

Static Public Member Functions

static bool valid_geometry (int fft, int ch, int hop) noexcept
static std::size_t serialized_size (int fft, int ch) noexcept
 Byte size of the serialized image for a geometry, or 0 when the geometry is outside the supported bounds.
static bool read_bytes (const std::uint8_t *data, std::size_t size, FreezeHoldSnapshotT &out)
 Parse a byte image.

Public Attributes

int fft_size = 0
int channels = 0
int analysis_hop = 0
int capture_frames = 0
 Frames averaged into the hold (informational).
int crossfade_frames = 1
 Crossfade length and position when the snapshot was taken.
int fade_step = 0
bool engaged = false
bool releasing = false
double sample_rate = 0.0
 Sample rate of the capture, or 0 when the hold was not told one.
std::uint64_t rng_state = 0
std::vector< SampleType > magnitudes
std::vector< double > phases
std::vector< double > inst_freq

Static Public Attributes

static constexpr std::uint32_t kFormatVersion = 1
static constexpr int kMinFftSize = 256
static constexpr int kMaxFftSize = 16384
static constexpr int kMaxChannels = 16
static constexpr std::size_t kHeaderBytes = 56
static constexpr std::uint32_t kFlagEngaged = 1u
static constexpr std::uint32_t kFlagReleasing = 2u

Detailed Description

template<typename SampleType = float>
struct pulp::signal::FreezeHoldSnapshotT< SampleType >

Value image of a FreezeHold's held state: everything needed to reproduce the held output bit-for-bit on a hold prepared with the same geometry.

Storage is allocated by prepare() (control thread). Byte serialization allocates and is not audio-thread safe; snapshot() and stage_restore() only copy into prepared storage.

Byte image (little-endian, format version 1), 56-byte header: "PFHS" magic, u32 version, u32 fft_size, u32 channels, u32 analysis_hop, u32 capture_frames, u32 crossfade_frames, u32 fade_step, u32 flags (bit 0 engaged, bit 1 releasing), u32 reserved (0), f64 sample_rate (0 = unknown), u64 rng_state then f32 magnitudes[channels * bins], f64 phases[channels * bins], f64 inst_freq[bins], where bins = fft_size / 2 + 1. Phases are wrapped to [-pi, pi]; instantaneous frequencies are radians per sample. The largest supported image (16384-point, 16 channels) is under 2 MB.

Member Function Documentation

◆ prepare()

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::prepare ( int fft,
int ch,
int hop )
inline

Allocate storage for a geometry. Not audio-thread safe.

◆ read_bytes()

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::read_bytes ( const std::uint8_t * data,
std::size_t size,
FreezeHoldSnapshotT< SampleType > & out )
inlinestatic

Parse a byte image.

Rejects a wrong magic or version, an out-of-bounds geometry, a size that does not match the geometry exactly, unknown flag or reserved bits, and any invalid value. Allocates; not audio-thread safe. out is only modified on success.

◆ serialized_size()

template<typename SampleType = float>
std::size_t pulp::signal::FreezeHoldSnapshotT< SampleType >::serialized_size ( int fft,
int ch )
inlinestaticnoexcept

Byte size of the serialized image for a geometry, or 0 when the geometry is outside the supported bounds.

◆ valid()

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::valid ( ) const
inlinenoexcept

Shape and value check: geometry in bounds, storage sized for it, a consistent fade record, every value finite, magnitudes non-negative, phases wrapped, and a non-zero PRNG state (zero is a fixed point of xorshift).

◆ valid_geometry()

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::valid_geometry ( int fft,
int ch,
int hop )
inlinestaticnoexcept

◆ write_bytes()

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::write_bytes ( std::vector< std::uint8_t > & out) const
inline

Serialize to the versioned byte image.

Allocates; not audio-thread safe. Returns false (and leaves out empty) for an invalid image.

Member Data Documentation

◆ analysis_hop

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::analysis_hop = 0

◆ capture_frames

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::capture_frames = 0

Frames averaged into the hold (informational).

◆ channels

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::channels = 0

◆ crossfade_frames

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::crossfade_frames = 1

Crossfade length and position when the snapshot was taken.

◆ engaged

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::engaged = false

◆ fade_step

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::fade_step = 0

◆ fft_size

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::fft_size = 0

◆ inst_freq

template<typename SampleType = float>
std::vector<double> pulp::signal::FreezeHoldSnapshotT< SampleType >::inst_freq

◆ kFlagEngaged

template<typename SampleType = float>
std::uint32_t pulp::signal::FreezeHoldSnapshotT< SampleType >::kFlagEngaged = 1u
staticconstexpr

◆ kFlagReleasing

template<typename SampleType = float>
std::uint32_t pulp::signal::FreezeHoldSnapshotT< SampleType >::kFlagReleasing = 2u
staticconstexpr

◆ kFormatVersion

template<typename SampleType = float>
std::uint32_t pulp::signal::FreezeHoldSnapshotT< SampleType >::kFormatVersion = 1
staticconstexpr

◆ kHeaderBytes

template<typename SampleType = float>
std::size_t pulp::signal::FreezeHoldSnapshotT< SampleType >::kHeaderBytes = 56
staticconstexpr

◆ kMaxChannels

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::kMaxChannels = 16
staticconstexpr

◆ kMaxFftSize

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::kMaxFftSize = 16384
staticconstexpr

◆ kMinFftSize

template<typename SampleType = float>
int pulp::signal::FreezeHoldSnapshotT< SampleType >::kMinFftSize = 256
staticconstexpr

◆ magnitudes

template<typename SampleType = float>
std::vector<SampleType> pulp::signal::FreezeHoldSnapshotT< SampleType >::magnitudes

◆ phases

template<typename SampleType = float>
std::vector<double> pulp::signal::FreezeHoldSnapshotT< SampleType >::phases

◆ releasing

template<typename SampleType = float>
bool pulp::signal::FreezeHoldSnapshotT< SampleType >::releasing = false

◆ rng_state

template<typename SampleType = float>
std::uint64_t pulp::signal::FreezeHoldSnapshotT< SampleType >::rng_state = 0

◆ sample_rate

template<typename SampleType = float>
double pulp::signal::FreezeHoldSnapshotT< SampleType >::sample_rate = 0.0

Sample rate of the capture, or 0 when the hold was not told one.

A restore refuses a known rate that differs from the receiver's.


The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/signal/include/pulp/signal/freeze_hold.hpp