Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::FFT< Real >::STFTProcessor Class Reference

Stateful STFT processor for chunked real-time analysis. More...

#include <fft.H>

Collaboration diagram for Aleph::FFT< Real >::STFTProcessor:
[legend]

Public Member Functions

 STFTProcessor ()=default
 Default constructor for an unconfigured processor.
 
 STFTProcessor (const Array< Real > &window, const STFTOptions &options)
 Construct an STFT processor with a fixed analysis window.
 
 STFTProcessor (const size_t frame_size, const STFTOptions &options)
 Construct an STFT processor using a Hann window.
 
template<typename WindowContainer >
requires Is_Real_Container<WindowContainer>
 STFTProcessor (const WindowContainer &window, const STFTOptions &options)
 Construct an STFT processor from any real container.
 
 STFTProcessor (const STFTProcessor &other)=default
 Copy the configuration and the pending samples of another processor.
 
 STFTProcessor (STFTProcessor &&other) noexcept
 Take the configuration and the pending samples of another processor, which is left unconfigured, as built by default.
 
STFTProcessor & operator= (const STFTProcessor &other)=default
 Copy the configuration and the pending samples of another processor.
 
STFTProcessor & operator= (STFTProcessor &&other) noexcept
 Exchange this processor with another, which is left with the previous state of this one.
 
void swap (STFTProcessor &other) noexcept
 Exchange in O(1) the state of this processor and another.
 
size_t frame_size () const noexcept
 
bool configured () const noexcept
 
size_t hop_size () const noexcept
 
size_t fft_size () const noexcept
 
bool centered () const noexcept
 
bool pad_end () const noexcept
 
bool finalized () const noexcept
 
const Array< Real > & window () const noexcept
 
void reset ()
 
Array< Array< Complex > > process_block (const Array< Real > &block)
 
Array< Array< Complex > > pprocess_block (ThreadPool &pool, const Array< Real > &block, const size_t chunk_size=0)
 
Array< Array< Complex > > flush ()
 
Array< Array< Complex > > pflush (ThreadPool &pool, const size_t chunk_size=0)
 
template<typename Container >
requires Is_Real_Container<Container>
Array< Array< Complex > > process_block (const Container &block)
 
template<typename Container >
requires Is_Real_Container<Container>
Array< Array< Complex > > pprocess_block (ThreadPool &pool, const Container &block, const size_t chunk_size=0)
 

Private Member Functions

void require_configured (const char *ctx) const
 
void initialize_pending ()
 
void append_samples (const Array< Real > &block)
 
Array< Array< Complex > > emit_ready_frames (ThreadPool *pool, const size_t chunk_size, const bool allow_partial_frames)
 

Private Attributes

Array< Real > window_
 
STFTOptions options_
 
size_t fft_size_ = 0
 
size_t center_pad_ = 0
 
Plan plan_
 
Array< Real > pending_
 
bool configured_ = false
 
bool has_seen_input_ = false
 
bool finalized_ = false
 

Detailed Description

template<std::floating_point Real = double>
class Aleph::FFT< Real >::STFTProcessor

Stateful STFT processor for chunked real-time analysis.

Definition at line 10347 of file fft.H.

Constructor & Destructor Documentation

◆ STFTProcessor() [1/6]

template<std::floating_point Real = double>
Aleph::FFT< Real >::STFTProcessor::STFTProcessor ( )
default

Default constructor for an unconfigured processor.

◆ STFTProcessor() [2/6]

template<std::floating_point Real = double>
Aleph::FFT< Real >::STFTProcessor::STFTProcessor ( const Array< Real > &  window,
const STFTOptions &  options 
)
inlineexplicit

Construct an STFT processor with a fixed analysis window.

Parameters
windowAnalysis window (e.g. Hann, Hamming).
optionsSTFT parameters (hop size, centered, etc.).

Definition at line 10416 of file fft.H.

References Aleph::FFT< Real >::STFTProcessor::initialize_pending().

◆ STFTProcessor() [3/6]

template<std::floating_point Real = double>
Aleph::FFT< Real >::STFTProcessor::STFTProcessor ( const size_t  frame_size,
const STFTOptions &  options 
)
inlineexplicit

Construct an STFT processor using a Hann window.

Parameters
frame_sizeAnalysis window size.
optionsSTFT parameters.

Definition at line 10435 of file fft.H.

◆ STFTProcessor() [4/6]

template<std::floating_point Real = double>
template<typename WindowContainer >
requires Is_Real_Container<WindowContainer>
Aleph::FFT< Real >::STFTProcessor::STFTProcessor ( const WindowContainer &  window,
const STFTOptions &  options 
)
inlineexplicit

Construct an STFT processor from any real container.

Template Parameters
WindowContainerContainer type (e.g. std::vector<double>).
Parameters
windowAnalysis window.
optionsSTFT parameters.

Definition at line 10448 of file fft.H.

◆ STFTProcessor() [5/6]

template<std::floating_point Real = double>
Aleph::FFT< Real >::STFTProcessor::STFTProcessor ( const STFTProcessor &  other)
default

Copy the configuration and the pending samples of another processor.

Parameters
[in]otherprocessor to copy.
Exceptions
std::bad_allocif the buffers cannot be allocated.

◆ STFTProcessor() [6/6]

template<std::floating_point Real = double>
Aleph::FFT< Real >::STFTProcessor::STFTProcessor ( STFTProcessor &&  other)
inlinenoexcept

Take the configuration and the pending samples of another processor, which is left unconfigured, as built by default.

The implicit move took the window, the plan and the pending samples but copied the FFT size and the flags: the moved-from processor then said that it was configured and transformed frames with a plan that it no longer had.

Parameters
[in,out]otherprocessor to move from.
Note
Complexity: O(1).

Definition at line 10471 of file fft.H.

Member Function Documentation

◆ append_samples()

◆ centered()

template<std::floating_point Real = double>
bool Aleph::FFT< Real >::STFTProcessor::centered ( ) const
inlinenoexcept

◆ configured()

template<std::floating_point Real = double>
bool Aleph::FFT< Real >::STFTProcessor::configured ( ) const
inlinenoexcept

Definition at line 10524 of file fft.H.

References Aleph::FFT< Real >::STFTProcessor::configured_.

◆ emit_ready_frames()

◆ fft_size()

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::STFTProcessor::fft_size ( ) const
inlinenoexcept

Definition at line 10534 of file fft.H.

References Aleph::FFT< Real >::STFTProcessor::fft_size_.

◆ finalized()

template<std::floating_point Real = double>
bool Aleph::FFT< Real >::STFTProcessor::finalized ( ) const
inlinenoexcept

Definition at line 10549 of file fft.H.

References Aleph::FFT< Real >::STFTProcessor::finalized_.

◆ flush()

◆ frame_size()

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::STFTProcessor::frame_size ( ) const
inlinenoexcept

◆ hop_size()

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::STFTProcessor::hop_size ( ) const
inlinenoexcept

◆ initialize_pending()

template<std::floating_point Real = double>
void Aleph::FFT< Real >::STFTProcessor::initialize_pending ( )
inlineprivate

◆ operator=() [1/2]

template<std::floating_point Real = double>
STFTProcessor & Aleph::FFT< Real >::STFTProcessor::operator= ( const STFTProcessor &  other)
default

Copy the configuration and the pending samples of another processor.

Parameters
[in]otherprocessor to copy.
Returns
this processor.
Exceptions
std::bad_allocif the buffers cannot be allocated.

◆ operator=() [2/2]

template<std::floating_point Real = double>
STFTProcessor & Aleph::FFT< Real >::STFTProcessor::operator= ( STFTProcessor &&  other)
inlinenoexcept

Exchange this processor with another, which is left with the previous state of this one.

Parameters
[in,out]otherprocessor to move from.
Returns
this processor.
Note
Complexity: O(1).

Definition at line 10497 of file fft.H.

References Aleph::FFT< Real >::STFTProcessor::swap().

◆ pad_end()

template<std::floating_point Real = double>
bool Aleph::FFT< Real >::STFTProcessor::pad_end ( ) const
inlinenoexcept

◆ pflush()

◆ pprocess_block() [1/2]

◆ pprocess_block() [2/2]

template<std::floating_point Real = double>
template<typename Container >
requires Is_Real_Container<Container>
Array< Array< Complex > > Aleph::FFT< Real >::STFTProcessor::pprocess_block ( ThreadPool &  pool,
const Container &  block,
const size_t  chunk_size = 0 
)
inline

◆ process_block() [1/2]

◆ process_block() [2/2]

template<std::floating_point Real = double>
template<typename Container >
requires Is_Real_Container<Container>
Array< Array< Complex > > Aleph::FFT< Real >::STFTProcessor::process_block ( const Container &  block)
inline

◆ require_configured()

template<std::floating_point Real = double>
void Aleph::FFT< Real >::STFTProcessor::require_configured ( const char *  ctx) const
inlineprivate

◆ reset()

◆ swap()

◆ window()

template<std::floating_point Real = double>
const Array< Real > & Aleph::FFT< Real >::STFTProcessor::window ( ) const
inlinenoexcept

Definition at line 10554 of file fft.H.

References Aleph::FFT< Real >::STFTProcessor::window_.

Member Data Documentation

◆ center_pad_

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::STFTProcessor::center_pad_ = 0
private

◆ configured_

template<std::floating_point Real = double>
bool Aleph::FFT< Real >::STFTProcessor::configured_ = false
private

◆ fft_size_

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::STFTProcessor::fft_size_ = 0
private

◆ finalized_

◆ has_seen_input_

◆ options_

◆ pending_

◆ plan_

template<std::floating_point Real = double>
Plan Aleph::FFT< Real >::STFTProcessor::plan_
private

◆ window_

template<std::floating_point Real = double>
Array<Real> Aleph::FFT< Real >::STFTProcessor::window_
private

The documentation for this class was generated from the following file: