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

Stateful ISTFT processor for chunked frame-by-frame synthesis. More...

#include <fft.H>

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

Public Member Functions

 ISTFTProcessor ()=default
 Default constructor for an unconfigured inverse processor.
 
 ISTFTProcessor (const size_t fft_size, const Array< Real > &analysis_window, const Array< Real > &synthesis_window, const ISTFTOptions &options)
 Construct an inverse STFT processor with custom windows.
 
 ISTFTProcessor (const size_t fft_size, const Array< Real > &window, const ISTFTOptions &options)
 Construct an inverse STFT processor with a single window.
 
 ISTFTProcessor (const size_t fft_size, const size_t frame_size, const ISTFTOptions &options)
 Construct an inverse STFT processor with a Hann window.
 
template<typename AnalysisContainer , typename SynthesisContainer >
requires Is_Real_Container<AnalysisContainer>
and Is_Real_Container< SynthesisContainer > ISTFTProcessor (const size_t fft_size, const AnalysisContainer &analysis_window, const SynthesisContainer &synthesis_window, const ISTFTOptions &options)
 Construct an inverse STFT processor from any real containers.
 
 ISTFTProcessor (const ISTFTProcessor &other)=default
 Copy the configuration and the pending samples of another processor.
 
 ISTFTProcessor (ISTFTProcessor &&other) noexcept
 Take the configuration and the pending samples of another processor, which is left unconfigured, as built by default.
 
ISTFTProcessor & operator= (const ISTFTProcessor &other)=default
 Copy the configuration and the pending samples of another processor.
 
ISTFTProcessor & operator= (ISTFTProcessor &&other) noexcept
 Exchange this processor with another, which is left with the previous state of this one.
 
void swap (ISTFTProcessor &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 fft_size () const noexcept
 
size_t hop_size () const noexcept
 
bool centered () const noexcept
 
bool finalized () const noexcept
 
void reset ()
 
Array< Real > process_frame (const Array< Complex > &spectrum)
 
Array< Real > pprocess_frame (ThreadPool &pool, const Array< Complex > &spectrum, const size_t chunk_size=0)
 
Array< Real > process_block (const Array< Array< Complex > > &spectrogram_block)
 
Array< Real > pprocess_block (ThreadPool &pool, const Array< Array< Complex > > &spectrogram_block, const size_t chunk_size=0)
 
Array< Real > flush ()
 
Array< Real > pflush (ThreadPool &, const size_t=0)
 
template<typename Container >
requires Is_Complex_Container<Container>
Array< Real > process_frame (const Container &spectrum)
 
template<typename Container >
requires Is_Complex_Container<Container>
Array< Real > pprocess_frame (ThreadPool &pool, const Container &spectrum, const size_t chunk_size=0)
 

Private Member Functions

void require_configured (const char *ctx) const
 
void initialize_state ()
 
void ensure_pending_size (const size_t size)
 
void accumulate_frame (const Array< Real > &frame)
 
Array< Real > normalize_prefix (const size_t count)
 
Array< Real > emit_samples (const Array< Real > &normalized, const bool final_flush)
 
Array< Real > drain_ready_samples (const bool final_flush)
 
Array< Real > process_frame_impl (const Array< Complex > &spectrum, ThreadPool *pool, const size_t chunk_size)
 

Private Attributes

Array< Real > analysis_window_
 
Array< Real > synthesis_window_
 
ISTFTOptions options_
 
size_t fft_size_ = 0
 
size_t center_pad_ = 0
 
Plan plan_
 
Array< Real > pending_output_
 
Array< Real > pending_norm_
 
size_t frames_processed_ = 0
 
size_t emitted_raw_samples_ = 0
 
size_t left_trim_remaining_ = 0
 
size_t emitted_signal_samples_ = 0
 
bool configured_ = false
 
bool has_seen_frame_ = false
 
bool finalized_ = false
 

Detailed Description

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

Stateful ISTFT processor for chunked frame-by-frame synthesis.

Definition at line 10675 of file fft.H.

Constructor & Destructor Documentation

◆ ISTFTProcessor() [1/7]

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

Default constructor for an unconfigured inverse processor.

◆ ISTFTProcessor() [2/7]

template<std::floating_point Real = double>
Aleph::FFT< Real >::ISTFTProcessor::ISTFTProcessor ( const size_t  fft_size,
const Array< Real > &  analysis_window,
const Array< Real > &  synthesis_window,
const ISTFTOptions &  options 
)
inlineexplicit

Construct an inverse STFT processor with custom windows.

Parameters
fft_sizeFixed FFT transform size.
analysis_windowAnalysis window used during STFT.
synthesis_windowSynthesis window for reconstruction.
optionsOverlap-add parameters.

Definition at line 10871 of file fft.H.

References Aleph::FFT< Real >::ISTFTProcessor::analysis_window_, Aleph::FFT< Real >::ISTFTProcessor::fft_size_, Aleph::FFT< Real >::ISTFTProcessor::initialize_state(), Aleph::FFT< Real >::ISTFTProcessor::options_, Aleph::FFT< Real >::ISTFTProcessor::synthesis_window_, and Aleph::FFT< Real >::validate_istft_configuration().

◆ ISTFTProcessor() [3/7]

template<std::floating_point Real = double>
Aleph::FFT< Real >::ISTFTProcessor::ISTFTProcessor ( const size_t  fft_size,
const Array< Real > &  window,
const ISTFTOptions &  options 
)
inlineexplicit

Construct an inverse STFT processor with a single window.

Parameters
fft_sizeFixed FFT transform size.
windowWindow used for both analysis and synthesis.
optionsOverlap-add parameters.

Definition at line 10897 of file fft.H.

◆ ISTFTProcessor() [4/7]

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

Construct an inverse STFT processor with a Hann window.

Parameters
fft_sizeFixed FFT transform size.
frame_sizeHann window size.
optionsOverlap-add parameters.

Definition at line 10909 of file fft.H.

◆ ISTFTProcessor() [5/7]

template<std::floating_point Real = double>
template<typename AnalysisContainer , typename SynthesisContainer >
requires Is_Real_Container<AnalysisContainer>
and Is_Real_Container< SynthesisContainer > Aleph::FFT< Real >::ISTFTProcessor::ISTFTProcessor ( const size_t  fft_size,
const AnalysisContainer &  analysis_window,
const SynthesisContainer &  synthesis_window,
const ISTFTOptions &  options 
)
inlineexplicit

Construct an inverse STFT processor from any real containers.

Template Parameters
AnalysisContainerType for analysis window.
SynthesisContainerType for synthesis window.
Parameters
fft_sizeFixed FFT transform size.
analysis_windowAnalysis window.
synthesis_windowSynthesis window.
optionsOverlap-add parameters.

Definition at line 10930 of file fft.H.

◆ ISTFTProcessor() [6/7]

template<std::floating_point Real = double>
Aleph::FFT< Real >::ISTFTProcessor::ISTFTProcessor ( const ISTFTProcessor &  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.

◆ ISTFTProcessor() [7/7]

template<std::floating_point Real = double>
Aleph::FFT< Real >::ISTFTProcessor::ISTFTProcessor ( ISTFTProcessor &&  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 windows, the plan and the pending samples but copied the FFT size, the counters 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 10958 of file fft.H.

Member Function Documentation

◆ accumulate_frame()

◆ centered()

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

◆ configured()

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

Definition at line 11023 of file fft.H.

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

◆ drain_ready_samples()

◆ emit_samples()

◆ ensure_pending_size()

template<std::floating_point Real = double>
void Aleph::FFT< Real >::ISTFTProcessor::ensure_pending_size ( const size_t  size)
inlineprivate

◆ fft_size()

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

Definition at line 11028 of file fft.H.

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

◆ finalized()

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

Definition at line 11043 of file fft.H.

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

◆ flush()

◆ frame_size()

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

◆ hop_size()

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

◆ initialize_state()

◆ normalize_prefix()

◆ operator=() [1/2]

template<std::floating_point Real = double>
ISTFTProcessor & Aleph::FFT< Real >::ISTFTProcessor::operator= ( const ISTFTProcessor &  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>
ISTFTProcessor & Aleph::FFT< Real >::ISTFTProcessor::operator= ( ISTFTProcessor &&  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 10990 of file fft.H.

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

◆ pflush()

template<std::floating_point Real = double>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::pflush ( ThreadPool &  ,
const size_t  = 0 
)
inline

◆ pprocess_block()

template<std::floating_point Real = double>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::pprocess_block ( ThreadPool &  pool,
const Array< Array< Complex > > &  spectrogram_block,
const size_t  chunk_size = 0 
)
inline

◆ pprocess_frame() [1/2]

template<std::floating_point Real = double>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::pprocess_frame ( ThreadPool &  pool,
const Array< Complex > &  spectrum,
const size_t  chunk_size = 0 
)
inline

◆ pprocess_frame() [2/2]

template<std::floating_point Real = double>
template<typename Container >
requires Is_Complex_Container<Container>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::pprocess_frame ( ThreadPool &  pool,
const Container &  spectrum,
const size_t  chunk_size = 0 
)
inline

◆ process_block()

template<std::floating_point Real = double>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::process_block ( const Array< Array< Complex > > &  spectrogram_block)
inline

◆ process_frame() [1/2]

template<std::floating_point Real = double>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::process_frame ( const Array< Complex > &  spectrum)
inline

◆ process_frame() [2/2]

template<std::floating_point Real = double>
template<typename Container >
requires Is_Complex_Container<Container>
Array< Real > Aleph::FFT< Real >::ISTFTProcessor::process_frame ( const Container &  spectrum)
inline

◆ process_frame_impl()

◆ require_configured()

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

◆ reset()

template<std::floating_point Real = double>
void Aleph::FFT< Real >::ISTFTProcessor::reset ( )
inline

◆ swap()

Member Data Documentation

◆ analysis_window_

template<std::floating_point Real = double>
Array<Real> Aleph::FFT< Real >::ISTFTProcessor::analysis_window_
private

◆ center_pad_

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

◆ configured_

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

◆ emitted_raw_samples_

◆ emitted_signal_samples_

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::ISTFTProcessor::emitted_signal_samples_ = 0
private

◆ fft_size_

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

◆ finalized_

◆ frames_processed_

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::ISTFTProcessor::frames_processed_ = 0
private

◆ has_seen_frame_

template<std::floating_point Real = double>
bool Aleph::FFT< Real >::ISTFTProcessor::has_seen_frame_ = false
private

◆ left_trim_remaining_

template<std::floating_point Real = double>
size_t Aleph::FFT< Real >::ISTFTProcessor::left_trim_remaining_ = 0
private

◆ options_

◆ pending_norm_

◆ pending_output_

◆ plan_

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

◆ synthesis_window_

template<std::floating_point Real = double>
Array<Real> Aleph::FFT< Real >::ISTFTProcessor::synthesis_window_
private

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