|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Multichannel overlap-add convolver with one shared kernel FFT. More...
#include <fft.H>
Public Member Functions | |
| OverlapAddBank (const size_t num_channels, const Array< Real > &kernel, const size_t block_size=0) | |
| size_t | num_channels () const noexcept |
| size_t | block_size () const noexcept |
| size_t | fft_size () const noexcept |
| size_t | overlap_size () const noexcept |
| const Array< Real > & | kernel () const noexcept |
| void | reset () |
| Array< Array< Real > > | convolve (const Array< Array< Real > > &signals) const |
| Array< Array< Real > > | pconvolve (ThreadPool &pool, const Array< Array< Real > > &signals, const size_t chunk_size=0) const |
| Array< Array< Real > > | process_block (const Array< Array< Real > > &block) |
| Array< Array< Real > > | pprocess_block (ThreadPool &pool, const Array< Array< Real > > &block, const size_t chunk_size=0) |
| Array< Array< Real > > | flush () |
| Array< Array< Real > > | pflush (ThreadPool &pool, const size_t chunk_size=0) |
Private Member Functions | |
| void | validate_channel_count (const size_t count, const char *ctx) const |
| Rationale: Internal safety guard. | |
| Array< Complex > | build_signal_block (const Array< Real > &signal, const size_t offset=0, const size_t length=std::numeric_limits< size_t >::max()) const |
| implementation helper for preparing a signal block for FFT. | |
| Array< Array< Complex > > | build_signal_batch (const Array< Array< Real > > &block) const |
| implementation helper for preparing a batch of signal blocks. | |
| Array< Array< Complex > > | build_signal_batch (const Array< Array< Real > > &source, const Array< size_t > &channels, const Array< size_t > &lengths, const size_t offset=0) const |
| implementation helper for preparing a subset of signal blocks. | |
| void | pointwise_multiply_batch (Array< Array< Complex > > &spectra, ThreadPool *pool, const size_t chunk_size) const |
| Rationale: Parallel pointwise multiplication of multiple signal spectra with the shared kernel spectrum. | |
| void | clear_channel_overlap (const size_t channel) |
| Rationale: Resets the overlap buffer for a single channel. | |
| void | clear_overlaps () |
| Array< Array< Real > > | process_chunk_batch_impl (const Array< Array< Real > > &block, ThreadPool *pool, const size_t chunk_size) |
| Array< Array< Real > > | convolve_impl (const Array< Array< Real > > &signals, ThreadPool *pool, const size_t chunk_size) const |
Static Private Member Functions | |
| static size_t | default_block_size (const size_t kernel_size) |
| Rationale: Selects a block size that is at least as large as the kernel to ensure efficient FFT processing (defaults to power of two). | |
| static size_t | max_batch_length (const Array< Array< Real > > &signals) noexcept |
| Returns the maximum signal length in a batch. | |
| static Array< Real > | slice_chunk (const Array< Real > &input, const size_t offset, const size_t length) |
Returns a contiguous slice of input. | |
Private Attributes | |
| Array< Real > | kernel_ |
| size_t | block_size_ = 0 |
| size_t | fft_size_ = 0 |
| Plan | plan_ |
| Array< Complex > | kernel_spectrum_ |
| Array< Array< Real > > | overlaps_ |
| Array< bool > | has_pending_tail_ |
Multichannel overlap-add convolver with one shared kernel FFT.
All channels reuse the same transform plan and kernel spectrum. This avoids recomputing the kernel FFT per channel and enables batched FFT execution when many channels share the same FIR kernel.
|
inlineexplicit |
Definition at line 14357 of file fft.H.
References ah_invalid_argument_if, Aleph::Array< T >::append(), Aleph::FFT< Real >::OverlapAddBank::block_size(), Aleph::FFT< Real >::OverlapAddBank::block_size_, Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::clear_overlaps(), Aleph::Array< T >::create(), Aleph::FFT< Real >::OverlapAddBank::default_block_size(), Aleph::FFT< Real >::OverlapAddBank::fft_size_, Aleph::FFT< Real >::OverlapAddBank::has_pending_tail_, Aleph::Array< T >::is_empty(), Aleph::FFT< Real >::OverlapAddBank::kernel_, Aleph::FFT< Real >::OverlapAddBank::kernel_spectrum_, Aleph::FFT< Real >::next_power_of_two(), Aleph::FFT< Real >::OverlapAddBank::num_channels(), Aleph::FFT< Real >::OverlapAddBank::overlaps_, Aleph::FFT< Real >::OverlapAddBank::plan_, Aleph::Array< T >::reserve(), Aleph::Array< T >::size(), and Aleph::FFT< Real >::Plan::transform().
|
inlinenoexcept |
Definition at line 14402 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::block_size_.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank().
|
inlineprivate |
implementation helper for preparing a batch of signal blocks.
Definition at line 14157 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::FFT< Real >::OverlapAddBank::build_signal_block().
Referenced by Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), and Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl().
|
inlineprivate |
implementation helper for preparing a subset of signal blocks.
Definition at line 14167 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::build_signal_block(), and offset.
|
inlineprivate |
implementation helper for preparing a signal block for FFT.
Definition at line 14134 of file fft.H.
References ah_invalid_argument_if, Aleph::FFT< Real >::OverlapAddBank::block_size_, Aleph::blossom_maximum_cardinality_matching(), Aleph::Array< T >::create(), Aleph::FFT< Real >::OverlapAddBank::fft_size_, offset, and Aleph::Array< T >::size().
Referenced by Aleph::FFT< Real >::OverlapAddBank::build_signal_batch(), and Aleph::FFT< Real >::OverlapAddBank::build_signal_batch().
|
inlineprivate |
Rationale: Resets the overlap buffer for a single channel.
Definition at line 14203 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::has_pending_tail_, and Aleph::FFT< Real >::OverlapAddBank::overlaps_.
Referenced by Aleph::FFT< Real >::OverlapAddBank::clear_overlaps(), Aleph::FFT< Real >::OverlapAddBank::flush(), and Aleph::FFT< Real >::OverlapAddBank::pflush().
|
inlineprivate |
Definition at line 14211 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::clear_channel_overlap(), and Aleph::FFT< Real >::OverlapAddBank::overlaps_.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), and Aleph::FFT< Real >::OverlapAddBank::reset().
|
inline |
Definition at line 14413 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), and Aleph::FFT< Real >::OverlapAddBank::validate_channel_count().
Referenced by Aleph::FFT< Real >::overlap_add_convolution_batch().
|
inlineprivate |
Definition at line 14286 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::block_size_, Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::build_signal_batch(), Aleph::Array< T >::create(), Aleph::FFT< Real >::OverlapAddBank::fft_size_, Aleph::FFT< Real >::Plan::inverse_transform_real_batch(), Aleph::FFT< Real >::OverlapAddBank::kernel_, Aleph::FFT< Real >::OverlapAddBank::max_batch_length(), offset, output, Aleph::FFT< Real >::Plan::pinverse_transform_real_batch(), Aleph::FFT< Real >::OverlapAddBank::plan_, Aleph::FFT< Real >::OverlapAddBank::pointwise_multiply_batch(), Aleph::FFT< Real >::Plan::ptransform_batch(), Aleph::Array< T >::reserve(), Aleph::FFT< Real >::should_parallelize_batch_work(), Aleph::Array< T >::size(), Aleph::size(), and Aleph::FFT< Real >::Plan::transform_batch().
Referenced by Aleph::FFT< Real >::OverlapAddBank::convolve(), and Aleph::FFT< Real >::OverlapAddBank::pconvolve().
|
inlinestaticprivate |
Rationale: Selects a block size that is at least as large as the kernel to ensure efficient FFT processing (defaults to power of two).
Definition at line 14093 of file fft.H.
References ah_invalid_argument_if, Aleph::blossom_maximum_cardinality_matching(), and Aleph::FFT< Real >::next_power_of_two().
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank().
|
inlinenoexcept |
Definition at line 14403 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::fft_size_.
|
inline |
|
inlinenoexcept |
Definition at line 14405 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::kernel_.
|
inlinestaticprivatenoexcept |
Returns the maximum signal length in a batch.
Definition at line 14111 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::size().
Referenced by Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), Aleph::FFT< Real >::OverlapAddBank::pprocess_block(), and Aleph::FFT< Real >::OverlapAddBank::process_block().
|
inlinenoexcept |
Definition at line 14397 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::overlaps_.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank().
|
inlinenoexcept |
Definition at line 14404 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::kernel_, and Aleph::Array< T >::size().
|
inline |
Definition at line 14420 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), and Aleph::FFT< Real >::OverlapAddBank::validate_channel_count().
Referenced by Aleph::FFT< Real >::poverlap_add_convolution_batch().
|
inline |
Definition at line 14514 of file fft.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::clear_channel_overlap(), Aleph::FFT< Real >::OverlapAddBank::has_pending_tail_, Aleph::ThreadPool::num_threads(), Aleph::FFT< Real >::OverlapAddBank::overlaps_, and Aleph::parallel_for_index().
|
inlineprivate |
Rationale: Parallel pointwise multiplication of multiple signal spectra with the shared kernel spectrum.
Definition at line 14184 of file fft.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::fft_size_, Aleph::FFT< Real >::OverlapAddBank::kernel_spectrum_, Aleph::ThreadPool::num_threads(), and Aleph::parallel_for_index().
Referenced by Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), and Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl().
|
inline |
Definition at line 14464 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::block_size_, Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::max_batch_length(), offset, Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl(), Aleph::Array< T >::size(), Aleph::size(), Aleph::FFT< Real >::OverlapAddBank::slice_chunk(), and Aleph::FFT< Real >::OverlapAddBank::validate_channel_count().
|
inline |
Definition at line 14429 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::block_size_, Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::max_batch_length(), offset, Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl(), Aleph::Array< T >::size(), Aleph::size(), Aleph::FFT< Real >::OverlapAddBank::slice_chunk(), and Aleph::FFT< Real >::OverlapAddBank::validate_channel_count().
|
inlineprivate |
Definition at line 14218 of file fft.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FFT< Real >::OverlapAddBank::build_signal_batch(), Aleph::FFT< Real >::count_non_empty_real_batch(), Aleph::Array< T >::create(), Aleph::FFT< Real >::OverlapAddBank::fft_size_, Aleph::FFT< Real >::OverlapAddBank::has_pending_tail_, Aleph::FFT< Real >::Plan::inverse_transform_real_batch(), Aleph::FFT< Real >::OverlapAddBank::overlaps_, Aleph::FFT< Real >::Plan::pinverse_transform_real_batch(), Aleph::FFT< Real >::OverlapAddBank::plan_, Aleph::FFT< Real >::OverlapAddBank::pointwise_multiply_batch(), Aleph::FFT< Real >::Plan::ptransform_batch(), Aleph::Array< T >::reserve(), Aleph::FFT< Real >::should_parallelize_batch_work(), Aleph::size(), Aleph::FFT< Real >::Plan::transform_batch(), and Aleph::FFT< Real >::OverlapAddBank::validate_channel_count().
Referenced by Aleph::FFT< Real >::OverlapAddBank::pprocess_block(), and Aleph::FFT< Real >::OverlapAddBank::process_block().
|
inline |
Definition at line 14407 of file fft.H.
References Aleph::FFT< Real >::OverlapAddBank::clear_overlaps().
|
inlinestaticprivate |
Returns a contiguous slice of input.
Definition at line 14121 of file fft.H.
References Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), offset, and Aleph::Array< T >::reserve().
Referenced by Aleph::FFT< Real >::OverlapAddBank::pprocess_block(), and Aleph::FFT< Real >::OverlapAddBank::process_block().
|
inlineprivate |
Rationale: Internal safety guard.
Definition at line 14102 of file fft.H.
References ah_invalid_argument_if, Aleph::count(), and Aleph::FFT< Real >::OverlapAddBank::overlaps_.
Referenced by Aleph::FFT< Real >::OverlapAddBank::convolve(), Aleph::FFT< Real >::OverlapAddBank::pconvolve(), Aleph::FFT< Real >::OverlapAddBank::pprocess_block(), Aleph::FFT< Real >::OverlapAddBank::process_block(), and Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl().
|
private |
Definition at line 14082 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), Aleph::FFT< Real >::OverlapAddBank::block_size(), Aleph::FFT< Real >::OverlapAddBank::build_signal_block(), Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), Aleph::FFT< Real >::OverlapAddBank::pprocess_block(), and Aleph::FFT< Real >::OverlapAddBank::process_block().
|
private |
Definition at line 14083 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), Aleph::FFT< Real >::OverlapAddBank::build_signal_block(), Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), Aleph::FFT< Real >::OverlapAddBank::fft_size(), Aleph::FFT< Real >::OverlapAddBank::pointwise_multiply_batch(), and Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl().
|
private |
Definition at line 14087 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), Aleph::FFT< Real >::OverlapAddBank::clear_channel_overlap(), Aleph::FFT< Real >::OverlapAddBank::flush(), Aleph::FFT< Real >::OverlapAddBank::pflush(), and Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl().
|
private |
Definition at line 14081 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), Aleph::FFT< Real >::OverlapAddBank::kernel(), and Aleph::FFT< Real >::OverlapAddBank::overlap_size().
|
private |
Definition at line 14085 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), and Aleph::FFT< Real >::OverlapAddBank::pointwise_multiply_batch().
|
private |
Definition at line 14086 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), Aleph::FFT< Real >::OverlapAddBank::clear_channel_overlap(), Aleph::FFT< Real >::OverlapAddBank::clear_overlaps(), Aleph::FFT< Real >::OverlapAddBank::flush(), Aleph::FFT< Real >::OverlapAddBank::num_channels(), Aleph::FFT< Real >::OverlapAddBank::pflush(), Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl(), and Aleph::FFT< Real >::OverlapAddBank::validate_channel_count().
|
private |
Definition at line 14084 of file fft.H.
Referenced by Aleph::FFT< Real >::OverlapAddBank::OverlapAddBank(), Aleph::FFT< Real >::OverlapAddBank::convolve_impl(), and Aleph::FFT< Real >::OverlapAddBank::process_chunk_batch_impl().