GPU-resident engine: the captured layer spectra live on the GPU and every hop runs advance + smear + weighted-sum + one inverse FFT on the device, reading back only the single synthesized frame. More...
#include <spectral_stack.hpp>
Public Member Functions | |
| bool | prepare (uint32_t fft_size, uint32_t hop, uint32_t num_layers, render::GpuCompute *shared_device=nullptr) |
| shared_device (optional) reuses an existing GpuCompute so the stack and a sibling don't each spin up a device; null = create + own one. | |
| uint32_t | fft_size () const override |
| uint32_t | num_layers () const override |
| bool | available () const override |
| True if this stack's compute backend is live. | |
| bool | capture (uint32_t layer, const float *frame_in) override |
| Analyze frame_in (fft_size real samples) with the analysis window and freeze its magnitude + phase into layer, activating it. | |
| void | clear (uint32_t layer) override |
| Deactivate a layer (its magnitude goes silent; phase keeps advancing). | |
| bool | layer_active (uint32_t layer) const override |
| bool | render (float *frame_out, const float *weights, float smear, float jitter) override |
| Advance + smear + weighted-sum the stack into frame_out (fft_size real samples). | |
| std::string | backend () const |
| GPU backend name ("Metal"/"D3D12"/"Vulkan"), or "" if no device. | |
GPU-resident engine: the captured layer spectra live on the GPU and every hop runs advance + smear + weighted-sum + one inverse FFT on the device, reading back only the single synthesized frame.
Wins over the CPU at high layer counts (the per-bin smear + the N-layer reduce parallelize). available() is true only with a GPU device; capture's forward FFT is done on the CPU (cheap, once per freeze). Not real-time-safe (blocks on the readback) — drive it off the audio thread. May share a device with a sibling primitive (e.g. GpuStft).
The layer spectra live on the device prepared here, so the stack records the device's generation at prepare(). Once the device reports loss or a new generation, available() goes false and capture()/render() refuse (render writes a silent frame) until the stack is prepared again.
|
overridevirtual |
True if this stack's compute backend is live.
The CPU stack is always available; the GPU stack is available only with a GPU device.
Implements pulp::gpu_audio::SpectralStack.
| std::string pulp::gpu_audio::GpuSpectralStack::backend | ( | ) | const |
GPU backend name ("Metal"/"D3D12"/"Vulkan"), or "" if no device.
|
overridevirtual |
Analyze frame_in (fft_size real samples) with the analysis window and freeze its magnitude + phase into layer, activating it.
Implements pulp::gpu_audio::SpectralStack.
|
overridevirtual |
Deactivate a layer (its magnitude goes silent; phase keeps advancing).
Implements pulp::gpu_audio::SpectralStack.
|
inlineoverridevirtual |
Implements pulp::gpu_audio::SpectralStack.
|
overridevirtual |
Implements pulp::gpu_audio::SpectralStack.
|
inlineoverridevirtual |
Implements pulp::gpu_audio::SpectralStack.
| bool pulp::gpu_audio::GpuSpectralStack::prepare | ( | uint32_t | fft_size, |
| uint32_t | hop, | ||
| uint32_t | num_layers, | ||
| render::GpuCompute * | shared_device = nullptr ) |
shared_device (optional) reuses an existing GpuCompute so the stack and a sibling don't each spin up a device; null = create + own one.
|
overridevirtual |
Advance + smear + weighted-sum the stack into frame_out (fft_size real samples).
weights (length num_layers) scales each layer; smear (0..1) blurs magnitude across frequency; jitter (0..1) adds phase wander. Returns false if no layer is active or the backend is unavailable.
Implements pulp::gpu_audio::SpectralStack.