MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ record()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = Eigen::MatrixXd>
size_t MayaFlux::Yantra::SpectralAnalyzer< InputType, OutputType >::record ( std::span< const double > channel)
inlinenodiscard

Transform the windows of one channel without waiting for the result.

The descriptors stay on the device, in descriptor_buffer, recorded into the analyzer's recording with no submission and no read back. A consumer on the same recording, for instance a WordPairMap ToFloat32 stage that hands them to a network, reads them in place. Bind the consumer after the analyzer's settings are final, since a change of window or bands makes a new context.

Parameters
channelSamples of one channel.
Returns
The number of windows recorded.

Definition at line 164 of file SpectralAnalyzer.hpp.

165 {
166 const auto& cfg = this->template config<SpectralAnalyzerConfig>();
167 auto& context = this->context(cfg);
168 const size_t windows = channel.size() < cfg.window_size
169 ? 0
170 : (channel.size() - cfg.window_size) / cfg.hop_size + 1;
172 if (windows == 0) {
173 return 0;
174 }
175 const std::vector<double> taper = cfg.taper ? Kinesis::Discrete::hann(cfg.window_size) : std::vector<double> {};
176 context.ensure_shared_buffer(0, FftContext::result_binding, windows * context.descriptors(), GpuBufferBinding::ElementType::VEC2_U32);
177 context.record_real(channel,
178 { .length = cfg.window_size, .stride = cfg.hop_size, .offset = 0, .count = static_cast<uint32_t>(windows) }, taper);
179 return windows;
180 }
const Config & config() const
The stored config struct of type Config, or its defaults when none was set.
FftContext & context(const SpectralAnalyzerConfig &cfg) const
Windowed spectral descriptors of every channel, run on the GPU.
std::vector< double > hann(size_t n)
Hann (raised cosine) taper coefficients.
Definition Taper.cpp:11