Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
spectral_jitter.hpp File Reference

The single, canonical spectral phase-jitter contract shared by every spectral-freeze engine in this library. More...

#include <cstdint>

Go to the source code of this file.

Namespaces

namespace  pulp
namespace  pulp::gpu_audio

Functions

float pulp::gpu_audio::spectral_phase_hash (std::uint32_t bin, std::uint32_t seed)
 Integer hash → float in [-0.5, 0.5], deterministic per (bin, seed).
std::uint32_t pulp::gpu_audio::advance_spectral_seed (std::uint32_t seed)
 Advance the jitter seed one render hop (the classic Numerical-Recipes LCG).

Variables

constexpr float pulp::gpu_audio::kSpectralTwoPi = 6.2831853071795864f
constexpr std::uint32_t pulp::gpu_audio::kSpectralSeedInit = 0x9E3779B9u
 Shared initial jitter seed so every engine starts the same wander sequence.

Detailed Description

The single, canonical spectral phase-jitter contract shared by every spectral-freeze engine in this library.

jitter (0..1) is a per-hop phase-wander depth: at each render hop every bin's running phase is perturbed by jitter * 2*pi * spectral_phase_hash(...) so the wander reaches a full turn at jitter == 1. Applied conjugate-antisymmetrically (bin k gets +h, bin n-k gets -h, DC and Nyquist none) so a magnitude-symmetric spectrum stays Hermitian and the synthesized frame stays real. The hash is stateless in the bin index — it depends only on (bin, seed) — so the same seed reproduces the same wander regardless of the order bins are visited, and it can be bit-matched between the CPU reference and the GPU compute shader.

This is the ONE meaning of the jitter knob across CpuSpectralStack, GpuSpectralStack, and GpuSpectralFreeze. The GPU-resident equivalent lives in the spectral_advance WGSL shader (core/render/src/gpu_compute.cpp): the hash01 + seed-advance math there MUST stay identical to the functions below, or the CPU reference and GPU engine will diverge.