|
dsplib 1.1.0
C++ DSP library for MATLAB-like coding
|
Accumulates data samples and processes them in fixed-size chunks. More...
#include <buffer.h>
Public Types | |
| using | Callback = std::function< void(span_t< T >)> |
| Callback type for processing full chunks. | |
Public Member Functions | |
| ChunkBuffer (int chunk_size) | |
| Construct a chunk buffer with specified chunk size. | |
| void | write (span_t< T > data, Callback fn) |
| Add data to buffer and process complete chunks. | |
| void | flush (Callback fn) |
| Process remaining data. | |
| void | reset () |
| Clear buffer contents Resets buffer to empty state. Preserves allocated capacity. | |
| int | size () const noexcept |
| Get current number of accumulated samples. | |
Accumulates data samples and processes them in fixed-size chunks.
| T | Data type of stored elements (typically real_t or cmplx_t) |
This buffer collects incoming data samples and automatically processes complete chunks of specified size through a callback. Partial chunks are preserved between write operations. Useful for block-based DSP processing.
|
inlineexplicit |
Construct a chunk buffer with specified chunk size.
| chunk_size | Fixed processing chunk size (must be > 1) |
|
inline |
Process remaining data.
| fn | Callback receiving all remaining samples |
Clears buffer after processing. Safe to call with empty buffer (callback receives empty span). Use for end-of-stream processing.
|
inline |
Clear buffer contents Resets buffer to empty state. Preserves allocated capacity.
| Assertion | if called during write/flush operation |
|
inlinenoexcept |
|
inline |
Add data to buffer and process complete chunks.
| data | Input data span |
| fn | Processing callback for each full chunk |
Behavior: