|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Generates decorellated noise (white, pink, brown) across multiple channels. More...
#include <NoiseGenerator.h>
Public Types | |
| enum class | Type { White , Pink , Brown } |
Public Member Functions | |
| void | prepare (const AudioSpec &spec) |
| Prepares the noise generator and allocates internal state. | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Fills the buffer with generated noise. | |
| void | reset () noexcept |
| Resets the internal PRNG and filter states. | |
| void | setType (Type type) noexcept |
| Sets the noise spectrum type. | |
| void | setLevel (T levelDb) noexcept |
| Sets the output level in decibels. Thread-safe. | |
| void | setGain (T gain) noexcept |
| Sets the output level as linear gain. Thread-safe. | |
| Type | getType () const noexcept |
| Retrieves the currently requested noise type. | |
| T | getGain () const noexcept |
| Retrieves the current target gain in linear scale. | |
| std::vector< uint8_t > | getState () const |
| Serializes the parameter state (setup/UI threads; allocates). | |
| bool | setState (const uint8_t *data, size_t size) |
| Restores parameters from a blob (tolerant; rejects foreign ids). | |
Generates decorellated noise (white, pink, brown) across multiple channels.
Ensures cache-friendly memory layout and lock-free thread safety. Implements block-level linear gain smoothing to prevent audio artifacts (zipper noise) upon parameter changes.
| T | Sample type (float or double). |
Definition at line 62 of file NoiseGenerator.h.
|
strong |
| Enumerator | |
|---|---|
| White | |
| Pink | |
| Brown | |
Definition at line 65 of file NoiseGenerator.h.
|
inlinenoexcept |
Retrieves the current target gain in linear scale.
Definition at line 240 of file NoiseGenerator.h.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 247 of file NoiseGenerator.h.
|
inlinenoexcept |
Retrieves the currently requested noise type.
Definition at line 231 of file NoiseGenerator.h.
|
inline |
Prepares the noise generator and allocates internal state.
An invalid spec (non-positive or non-finite fields) is a no-op that keeps the previous state.
| spec | Audio environment specification containing sample rate and channel count. |
Definition at line 80 of file NoiseGenerator.h.
|
inlinenoexcept |
Fills the buffer with generated noise.
Overwrites all existing data in the buffer. Applies smoothed gain changes transparently. Real-time safe (lock-free, zero allocations).
| buffer | Audio buffer view to fill. |
Definition at line 118 of file NoiseGenerator.h.
|
inlinenoexcept |
Resets the internal PRNG and filter states.
Restores the per-channel deterministic seeds too, so an offline render after reset() reproduces the exact same noise sequence (the generator's own reset() only clears filter state; the PRNG would otherwise continue from wherever it was).
Definition at line 176 of file NoiseGenerator.h.
|
inlinenoexcept |
Sets the output level as linear gain. Thread-safe.
| gain | Linear gain coefficient (1.0 = unity). Non-finite values are ignored. |
Definition at line 221 of file NoiseGenerator.h.
|
inlinenoexcept |
Sets the output level in decibels. Thread-safe.
| levelDb | Level in dB (0 = unity, -inf = silence). NaN and +inf are ignored; -inf maps to gain 0 as documented. |
Definition at line 210 of file NoiseGenerator.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids).
Definition at line 256 of file NoiseGenerator.h.
|
inlinenoexcept |
Sets the noise spectrum type.
Thread-safe and lock-free. The update is deferred to the audio thread during the next processBlock() call to avoid mutating filter states mid-read.
| type | Noise color (White, Pink, or Brown). |
Definition at line 196 of file NoiseGenerator.h.