Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
gpu_stft.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <vector>
6
9
10namespace pulp::gpu_audio {
11
21class GpuStft {
22 public:
33 bool prepare(uint32_t fft_size,
35 float window_param = 0.0f,
36 render::GpuCompute* shared_device = nullptr);
37
38 bool gpu_available() const { return gpu_ != nullptr; }
39
43 bool device_usable() const;
44 uint32_t fft_size() const { return fft_size_; }
45 const std::vector<float>& window() const { return window_; }
46
51 render::GpuCompute* compute() { return gpu_; }
52
55 bool analyze(const float* frame_in, float* spectrum_out);
56
59 bool synthesize(const float* spectrum_in, float* frame_out);
60
61private:
62 uint32_t fft_size_ = 0;
63 std::vector<float> window_;
64 render::GpuCompute* gpu_ = nullptr; // borrowed or == owned_.get()
65 std::unique_ptr<render::GpuCompute> owned_; // when not sharing a device
66 std::vector<float> scratch_; // 2*fft_size interleaved-complex scratch
67 std::uint64_t device_generation_ = 0; // gpu_->device_generation() at prepare
68};
69
70} // namespace pulp::gpu_audio
GPU short-time Fourier transform primitive (spectral toolkit).
Definition gpu_stft.hpp:21
bool device_usable() const
True while the prepared device can still run this STFT's work: present, not lost, and on the generati...
uint32_t fft_size() const
Definition gpu_stft.hpp:44
render::GpuCompute * compute()
The underlying GPU compute device (or null if none initialized).
Definition gpu_stft.hpp:51
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 eac...
bool synthesize(const float *spectrum_in, float *frame_out)
spectrum_in: 2*fft_size interleaved complex.
bool analyze(const float *frame_in, float *spectrum_out)
frame_in: fft_size real samples.
bool gpu_available() const
Definition gpu_stft.hpp:38
const std::vector< float > & window() const
Definition gpu_stft.hpp:45
GPU compute pipeline for non-rendering workloads (e.g.
Definition gpu_compute.hpp:48
Type
Definition windowing.hpp:43
@ hann
Definition windowing.hpp:45
Definition flow_pans.hpp:19