|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Power-of-two oversampling processor with polyphase anti-aliasing. More...
#include <Oversampling.h>
Public Types | |
| enum class | Quality { Low , Medium , High , Maximum } |
| Quality presets defining the steepness and rejection of the anti-aliasing filter. More... | |
Public Member Functions | |
| Oversampling (int factor=2, Quality quality=Quality::High) | |
| Constructs the oversampling engine. | |
| void | prepare (const AudioSpec &spec) |
| Pre-allocates buffers and computes FIR filter coefficients. | |
| void | reset () noexcept |
| Flushes all internal delay lines and history buffers. Call this when resetting the transport or to clear audio tails. | |
| int | getFactor () const noexcept |
| Returns the current oversampling factor. | |
| Quality | getQuality () const noexcept |
| Returns the current quality preset. | |
| int | getLatency () const noexcept |
| Calculates the exact group delay latency of the oversampling chain. | |
| AudioBufferView< T > | upsample (AudioBufferView< const T > input) noexcept |
| Upsamples the input base-rate signal into the internal high-rate buffer. | |
| void | downsample (AudioBufferView< T > output) noexcept |
| Downsamples the internal high-rate buffer back to base-rate. | |
Power-of-two oversampling processor with polyphase anti-aliasing.
Usage is a paired streaming operation per audio callback:
Threading: prepare() and reset() belong to the setup thread (prepare allocates). upsample() and downsample() belong to the audio thread and are noexcept and allocation-free. There are no runtime setters – factor and quality are fixed at construction and all filter state is only touched by the audio thread – so no cross-thread synchronisation is needed.
| T | Sample type (float or double). |
| MaxChannels | Maximum number of channels supported. |
Definition at line 67 of file Oversampling.h.
|
strong |
Quality presets defining the steepness and rejection of the anti-aliasing filter.
Definition at line 73 of file Oversampling.h.
|
inlineexplicit |
Constructs the oversampling engine.
| factor | Oversampling factor. Must be a power of two (1, 2, 4, 8, 16). |
| quality | Filter quality preset. Default is High (-80 dB). |
Definition at line 89 of file Oversampling.h.
|
inlinenoexcept |
Downsamples the internal high-rate buffer back to base-rate.
Consumes the high-rate samples written by the most recent upsample() (and modified in place by the caller in between).
| output | Buffer view where the base-rate samples will be written. Use the same block length as the paired upsample() input. |
Definition at line 212 of file Oversampling.h.
|
inlinenoexcept |
Returns the current oversampling factor.
Definition at line 142 of file Oversampling.h.
|
inlinenoexcept |
Calculates the exact group delay latency of the oversampling chain.
Definition at line 151 of file Oversampling.h.
|
inlinenoexcept |
Returns the current quality preset.
Definition at line 145 of file Oversampling.h.
|
inline |
Pre-allocates buffers and computes FIR filter coefficients.
| spec | The audio specification at the base (1x) sample rate. |
spec.maxBlockSize base samples. Definition at line 112 of file Oversampling.h.
|
inlinenoexcept |
Flushes all internal delay lines and history buffers. Call this when resetting the transport or to clear audio tails.
Definition at line 134 of file Oversampling.h.
|
inlinenoexcept |
Upsamples the input base-rate signal into the internal high-rate buffer.
| input | View of the base-rate audio buffer. Blocks longer than prepare()'s maxBlockSize are truncated (release-safe); channels beyond the prepared channel count are ignored. |
Definition at line 174 of file Oversampling.h.