DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
NoiseGenerator.h File Reference

Audio noise generator conforming to the AudioProcessor contract. More...

#include "../Core/AnalogRandom.h"
#include "../Core/AudioBuffer.h"
#include "../Core/AudioSpec.h"
#include "../Core/DspMath.h"
#include "../Core/StateBlob.h"
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <utility>
#include <vector>
Include dependency graph for NoiseGenerator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::NoiseGenerator< T >
 Generates decorellated noise (white, pink, brown) across multiple channels. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Audio noise generator conforming to the AudioProcessor contract.

Generates white, pink, or brown noise using AnalogRandom internally. Follows the standard prepare/processBlock/reset pattern. This acts as a signal generator, completely overwriting the input buffer (channels beyond the prepared count are left untouched).

Threading: prepare() belongs to the setup thread (allocates). processBlock() and reset() belong to the audio thread. Setters are lock-free atomic publications, safe from any thread; a type change is applied at the next processBlock(). Non-finite gains are ignored (setLevel(-inf) is the documented silence and maps to gain 0).

Dependencies: AnalogRandom.h, DspMath.h, AudioSpec.h, AudioBuffer.h, StateBlob.h.

noise.prepare(spec);
noise.setLevel(-12.0f);
// In the audio callback, fills the buffer with noise:
noise.processBlock(buffer);
Generates decorellated noise (white, pink, brown) across multiple channels.
void setLevel(T levelDb) noexcept
Sets the output level in decibels. Thread-safe.
void prepare(const AudioSpec &spec)
Prepares the noise generator and allocates internal state.
void setType(Type type) noexcept
Sets the noise spectrum type.
void processBlock(AudioBufferView< T > buffer) noexcept
Fills the buffer with generated noise.

Definition in file NoiseGenerator.h.