|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Uniform partitioned FIR convolver for low-latency streaming. More...
#include <fft.H>
Public Member Functions | |
| PartitionedConvolver (const Array< Real > &kernel, const size_t partition_size=0) | |
| PartitionedConvolver (const PartitionedConvolver &other)=default | |
| Copy the kernel partitions, the plan and the state of another convolver. | |
| PartitionedConvolver (PartitionedConvolver &&other) noexcept | |
| Take the state of another convolver, which is left empty. | |
| PartitionedConvolver & | operator= (const PartitionedConvolver &other)=default |
| Copy the kernel partitions, the plan and the state of another convolver. | |
| PartitionedConvolver & | operator= (PartitionedConvolver &&other) noexcept |
| Exchange this convolver with another, which is left with the previous state of this one. | |
| void | swap (PartitionedConvolver &other) noexcept |
| Exchange in O(1) the state of this convolver and another. | |
| size_t | partition_size () const noexcept |
| size_t | fft_size () const noexcept |
| const Array< Real > & | kernel () const noexcept |
| void | reset () |
| Array< Real > | process_block (const Array< Real > &block) |
| Convolve the next samples of a stream, a partition at a time. | |
| Array< Real > | flush () |
| Array< Real > | convolve (const Array< Real > &signal) |
| Convolve a whole signal with the kernel. | |
| template<typename Container > requires Is_Real_Container<Container> | |
| Array< Real > | process_block (const Container &block) |
| process_block() of the samples of a real container. | |
| template<typename Container > requires Is_Real_Container<Container> | |
| Array< Real > | convolve (const Container &signal) |
| convolve() of the samples of a real container. | |
Private Member Functions | |
| void | clear_state () |
| Rationale: Resets all delay-line history and overlap buffers. | |
| Array< Complex > | zero_spectrum () const |
| implementation helper for creating zero-filled complex spectra. | |
| Array< Real > | padded_partition (const Array< Real > &chunk) const |
| implementation helper for preparing a padded partition. | |
| Array< Real > | process_partition_impl (const Array< Real > &chunk) |
| Rationale: Implements the core frequency-domain partitioned convolution logic: | |
Static Private Member Functions | |
| static size_t | default_partition_size (const size_t kernel_size) |
| Rationale: Selects a partition size that minimizes latency while maintaining FFT efficiency (capped at 256 for low-latency). | |
Private Attributes | |
| Array< Real > | kernel_ |
| size_t | partition_size_ = 0 |
| size_t | fft_size_ = 0 |
| Plan | plan_ |
| Array< Array< Complex > > | kernel_partitions_ |
| Array< Array< Complex > > | input_history_ |
| size_t | head_ = 0 |
| Array< Real > | overlap_ |
| Array< Real > | pending_ |
| size_t | total_input_size_ = 0 |
| size_t | emitted_output_size_ = 0 |
Uniform partitioned FIR convolver for low-latency streaming.
The partition size controls algorithmic latency directly: each processed partition emits that many time-domain samples.
|
inlineexplicit |
Definition at line 15625 of file fft.H.
References ah_invalid_argument_if, Aleph::FFT< Real >::PartitionedConvolver::clear_state(), Aleph::Array< T >::create(), Aleph::FFT< Real >::PartitionedConvolver::default_partition_size(), Aleph::FFT< Real >::PartitionedConvolver::fft_size_, Aleph::FFT< Real >::PartitionedConvolver::input_history_, Aleph::Array< T >::is_empty(), Aleph::FFT< Real >::PartitionedConvolver::kernel_, Aleph::FFT< Real >::PartitionedConvolver::kernel_partitions_, Aleph::FFT< Real >::next_power_of_two(), offset, Aleph::FFT< Real >::PartitionedConvolver::overlap_, Aleph::partition(), Aleph::FFT< Real >::PartitionedConvolver::partition_size(), Aleph::FFT< Real >::PartitionedConvolver::partition_size_, Aleph::FFT< Real >::PartitionedConvolver::plan_, Aleph::Array< T >::size(), Aleph::FFT< Real >::Plan::transform(), and Aleph::FFT< Real >::PartitionedConvolver::zero_spectrum().
|
default |
Copy the kernel partitions, the plan and the state of another convolver.
| [in] | other | convolver to copy. |
| std::bad_alloc | if the buffers cannot be allocated. |
|
inlinenoexcept |
Take the state of another convolver, which is left empty.
The implicit move took the kernel partitions, the plan and the buffers but copied the sizes, the head and the counters: the moved-from convolver then transformed partitions with a plan that it no longer had. Now its sizes, head and counters are 0 and it has no kernel: it rejects every block and signal, while reset(), flush() and an assignment to it still work.
| [in,out] | other | convolver to move from. |
|
inlineprivate |
Rationale: Resets all delay-line history and overlap buffers.
Definition at line 15549 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::emitted_output_size_, Aleph::FFT< Real >::PartitionedConvolver::head_, Aleph::FFT< Real >::PartitionedConvolver::input_history_, Aleph::FFT< Real >::PartitionedConvolver::overlap_, Aleph::FFT< Real >::PartitionedConvolver::pending_, Aleph::Array< T >::size(), and Aleph::FFT< Real >::PartitionedConvolver::total_input_size_.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), and Aleph::FFT< Real >::PartitionedConvolver::reset().
|
inline |
Convolve a whole signal with the kernel.
| [in] | signal | signal to convolve; the convolver is reset first. |
| std::runtime_error | if the convolver is empty (it was moved from). |
Definition at line 15828 of file fft.H.
References ah_runtime_error_if, Aleph::FFT< Real >::append_all(), Aleph::FFT< Real >::PartitionedConvolver::flush(), Aleph::Array< T >::is_empty(), Aleph::FFT< Real >::PartitionedConvolver::kernel_, output, Aleph::FFT< Real >::PartitionedConvolver::process_block(), and Aleph::FFT< Real >::PartitionedConvolver::reset().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::convolve(), and Aleph::FFT< Real >::partitioned_convolution().
|
inline |
convolve() of the samples of a real container.
| Container | type of the container. |
| [in] | signal | signal to convolve. |
| std::runtime_error | if the convolver is empty (it was moved from). |
Definition at line 15864 of file fft.H.
References Aleph::FFT< Real >::build_real_input(), and Aleph::FFT< Real >::PartitionedConvolver::convolve().
|
inlinestaticprivate |
Rationale: Selects a partition size that minimizes latency while maintaining FFT efficiency (capped at 256 for low-latency).
Definition at line 15539 of file fft.H.
References ah_invalid_argument_if, and Aleph::FFT< Real >::next_power_of_two().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver().
|
inlinenoexcept |
Definition at line 15739 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::fft_size_.
|
inline |
Definition at line 15788 of file fft.H.
References Aleph::FFT< Real >::append_all(), Aleph::Array< T >::create(), Aleph::FFT< Real >::PartitionedConvolver::emitted_output_size_, Aleph::Array< T >::is_empty(), Aleph::FFT< Real >::PartitionedConvolver::kernel_, output, Aleph::FFT< Real >::PartitionedConvolver::partition_size_, Aleph::FFT< Real >::PartitionedConvolver::pending_, Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), Aleph::FFT< Real >::PartitionedConvolver::reset(), Aleph::Array< T >::size(), Aleph::FFT< Real >::slice_copy(), Aleph::FFT< Real >::PartitionedConvolver::total_input_size_, and Aleph::FFT< Real >::zeros().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::convolve().
|
inlinenoexcept |
Definition at line 15744 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::kernel_.
|
default |
Copy the kernel partitions, the plan and the state of another convolver.
| [in] | other | convolver to copy. |
| std::bad_alloc | if the buffers cannot be allocated. |
|
inlinenoexcept |
Exchange this convolver with another, which is left with the previous state of this one.
| [in,out] | other | convolver to move from. |
Definition at line 15710 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::swap().
|
inlineprivate |
implementation helper for preparing a padded partition.
Definition at line 15574 of file fft.H.
References Aleph::Array< T >::create(), Aleph::FFT< Real >::PartitionedConvolver::partition_size_, and Aleph::Array< T >::size().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl().
|
inlinenoexcept |
Definition at line 15734 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::partition_size_.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver().
|
inline |
Convolve the next samples of a stream, a partition at a time.
| [in] | block | next samples, of any number: they are buffered until a whole partition is available. |
| std::runtime_error | if the convolver is empty (it was moved from). |
Definition at line 15762 of file fft.H.
References ah_runtime_error_if, Aleph::FFT< Real >::append_all(), Aleph::Array< T >::is_empty(), Aleph::FFT< Real >::PartitionedConvolver::kernel_, Aleph::FFT< Real >::PartitionedConvolver::partition_size_, Aleph::FFT< Real >::PartitionedConvolver::pending_, Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), Aleph::Array< T >::size(), Aleph::FFT< Real >::slice_copy(), and Aleph::FFT< Real >::PartitionedConvolver::total_input_size_.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::convolve(), and Aleph::FFT< Real >::PartitionedConvolver::process_block().
|
inline |
process_block() of the samples of a real container.
| Container | type of the container. |
| [in] | block | next samples. |
| std::runtime_error | if the convolver is empty (it was moved from). |
Definition at line 15849 of file fft.H.
References Aleph::FFT< Real >::build_real_input(), and Aleph::FFT< Real >::PartitionedConvolver::process_block().
|
inlineprivate |
Rationale: Implements the core frequency-domain partitioned convolution logic:
Definition at line 15590 of file fft.H.
References Aleph::Array< T >::create(), Aleph::FFT< Real >::PartitionedConvolver::emitted_output_size_, Aleph::FFT< Real >::PartitionedConvolver::fft_size_, Aleph::FFT< Real >::PartitionedConvolver::head_, Aleph::FFT< Real >::PartitionedConvolver::input_history_, Aleph::FFT< Real >::Plan::inverse_transform_real(), Aleph::Array< T >::is_empty(), Aleph::FFT< Real >::PartitionedConvolver::kernel_partitions_, Aleph::FFT< Real >::PartitionedConvolver::overlap_, Aleph::FFT< Real >::PartitionedConvolver::padded_partition(), Aleph::FFT< Real >::PartitionedConvolver::partition_size_, Aleph::FFT< Real >::PartitionedConvolver::plan_, Aleph::Array< T >::size(), Aleph::FFT< Real >::Plan::transform(), and Aleph::FFT< Real >::PartitionedConvolver::zero_spectrum().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::flush(), and Aleph::FFT< Real >::PartitionedConvolver::process_block().
|
inline |
Definition at line 15749 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::clear_state().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::convolve(), and Aleph::FFT< Real >::PartitionedConvolver::flush().
|
inlinenoexcept |
Exchange in O(1) the state of this convolver and another.
| [in,out] | other | convolver to exchange with. |
Definition at line 15719 of file fft.H.
References Aleph::FFT< Real >::PartitionedConvolver::emitted_output_size_, Aleph::FFT< Real >::PartitionedConvolver::fft_size_, Aleph::FFT< Real >::PartitionedConvolver::head_, Aleph::FFT< Real >::PartitionedConvolver::input_history_, Aleph::FFT< Real >::PartitionedConvolver::kernel_, Aleph::FFT< Real >::PartitionedConvolver::kernel_partitions_, Aleph::FFT< Real >::PartitionedConvolver::overlap_, Aleph::FFT< Real >::PartitionedConvolver::partition_size_, Aleph::FFT< Real >::PartitionedConvolver::pending_, Aleph::FFT< Real >::PartitionedConvolver::plan_, Aleph::Array< T >::swap(), Aleph::FFT< Real >::Plan::swap(), and Aleph::FFT< Real >::PartitionedConvolver::total_input_size_.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::operator=().
|
inlineprivate |
implementation helper for creating zero-filled complex spectra.
Definition at line 15564 of file fft.H.
References Aleph::Array< T >::create(), Aleph::FFT< Real >::PartitionedConvolver::fft_size_, and Aleph::FFT< Real >::spectrum().
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), and Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl().
|
private |
|
private |
Definition at line 15525 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), Aleph::FFT< Real >::PartitionedConvolver::fft_size(), Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), Aleph::FFT< Real >::PartitionedConvolver::swap(), and Aleph::FFT< Real >::PartitionedConvolver::zero_spectrum().
|
private |
Definition at line 15529 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::clear_state(), Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), and Aleph::FFT< Real >::PartitionedConvolver::swap().
|
private |
|
private |
Definition at line 15523 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), Aleph::FFT< Real >::PartitionedConvolver::convolve(), Aleph::FFT< Real >::PartitionedConvolver::flush(), Aleph::FFT< Real >::PartitionedConvolver::kernel(), Aleph::FFT< Real >::PartitionedConvolver::process_block(), and Aleph::FFT< Real >::PartitionedConvolver::swap().
|
private |
Definition at line 15527 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), and Aleph::FFT< Real >::PartitionedConvolver::swap().
|
private |
|
private |
Definition at line 15524 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), Aleph::FFT< Real >::PartitionedConvolver::flush(), Aleph::FFT< Real >::PartitionedConvolver::padded_partition(), Aleph::FFT< Real >::PartitionedConvolver::partition_size(), Aleph::FFT< Real >::PartitionedConvolver::process_block(), Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), and Aleph::FFT< Real >::PartitionedConvolver::swap().
|
private |
Definition at line 15531 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::clear_state(), Aleph::FFT< Real >::PartitionedConvolver::flush(), Aleph::FFT< Real >::PartitionedConvolver::process_block(), and Aleph::FFT< Real >::PartitionedConvolver::swap().
|
private |
Definition at line 15526 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::PartitionedConvolver(), Aleph::FFT< Real >::PartitionedConvolver::process_partition_impl(), and Aleph::FFT< Real >::PartitionedConvolver::swap().
|
private |
Definition at line 15532 of file fft.H.
Referenced by Aleph::FFT< Real >::PartitionedConvolver::clear_state(), Aleph::FFT< Real >::PartitionedConvolver::flush(), Aleph::FFT< Real >::PartitionedConvolver::process_block(), and Aleph::FFT< Real >::PartitionedConvolver::swap().