GPU short-time Fourier transform primitive (spectral toolkit). More...
#include <gpu_stft.hpp>
Public Member Functions | |
| bool | prepare (uint32_t fft_size, signal::WindowFunction::Type window=signal::WindowFunction::Type::hann, float window_param=0.0f, render::GpuCompute *shared_device=nullptr) |
| shared_device (optional) reuses an existing GpuCompute so this STFT and a sibling primitive don't each spin up a device (the prerequisite for cross-effect batching); it must already be initialized and must outlive this GpuStft. | |
| bool | gpu_available () const |
| bool | device_usable () const |
| True while the prepared device can still run this STFT's work: present, not lost, and on the generation recorded at prepare(). | |
| uint32_t | fft_size () const |
| const std::vector< float > & | window () const |
| render::GpuCompute * | compute () |
| The underlying GPU compute device (or null if none initialized). | |
| bool | analyze (const float *frame_in, float *spectrum_out) |
| frame_in: fft_size real samples. | |
| bool | synthesize (const float *spectrum_in, float *frame_out) |
| spectrum_in: 2*fft_size interleaved complex. | |
GPU short-time Fourier transform primitive (spectral toolkit).
analyze(): apply the analysis window to one frame, then a GPU forward FFT → an interleaved-complex spectral frame. synthesize(): GPU inverse FFT → the real time-domain frame (no synthesis window; the caller overlap-adds). With a COLA window/hop (e.g. Hann at 50% overlap), analyze→synthesize→overlap-add reconstructs the input. fft_size must be a power of two. GPU work runs via render::GpuCompute; not real-time-safe (blocks on readback) — for the worker / offline analysis, the foundation for spectral freeze / morph / paint.
| bool pulp::gpu_audio::GpuStft::analyze | ( | const float * | frame_in, |
| float * | spectrum_out ) |
frame_in: fft_size real samples.
spectrum_out: 2*fft_size interleaved complex (windowed forward FFT). Returns false if not GPU-ready.
|
inline |
The underlying GPU compute device (or null if none initialized).
Exposed so a sibling primitive (e.g. the multi-layer spectral stack) can run on the SAME device and keep spectral frames GPU-resident without a second device. Worker / offline use only — not real-time-safe.
| bool pulp::gpu_audio::GpuStft::device_usable | ( | ) | const |
|
inline |
|
inline |
| bool pulp::gpu_audio::GpuStft::prepare | ( | uint32_t | fft_size, |
| signal::WindowFunction::Type | window = signal::WindowFunction::Type::hann, | ||
| float | window_param = 0.0f, | ||
| render::GpuCompute * | shared_device = nullptr ) |
shared_device (optional) reuses an existing GpuCompute so this STFT and a sibling primitive don't each spin up a device (the prerequisite for cross-effect batching); it must already be initialized and must outlive this GpuStft.
null = create + own a private device.
prepare() records the device's device_generation(). From then on analyze() and synthesize() refuse (return false, output zeroed) once the device reports device_lost() or its generation differs from the one recorded, because work prepared on the old device cannot run on a new one. Prepare again against the re-acquired device to resume.
| bool pulp::gpu_audio::GpuStft::synthesize | ( | const float * | spectrum_in, |
| float * | frame_out ) |
spectrum_in: 2*fft_size interleaved complex.
frame_out: fft_size real samples (inverse FFT, no synthesis window). Returns false if not ready.
|
inline |