Skip to content

Noise Generator

Tier: Primitives | ComponentType: 3 | Params: 2

White, pink, and brown noise generator with selectable type and level control.

Overview

NoiseGenerator produces three colors of noise. White noise (flat spectrum) uses an xorshift32 PRNG. Pink noise (-3 dB/octave rolloff) uses the Voss-McCartney algorithm with 8 octave bands. Brown noise (-6 dB/octave rolloff) integrates white noise through a leaky integrator with soft clamping.

Used as excitation for physical models, as a modulation source, for testing frequency response, or as a sound source in its own right.

File Locations

Path
Header Sources/FolioDSP/include/FolioDSP/Primitives/NoiseGenerator.h
Implementation Sources/FolioDSP/src/Primitives/NoiseGenerator.cpp
Tests Tests/FolioDSPTests/NoiseGeneratorTests.swift
Bridge Sources/FolioDSPBridge/src/FolioDSPBridge.mm (NoiseGeneratorBridge)

Parameters

Index Name Description Min Max Default Min Default Max Default Unit
0 Type Noise color: 0=White, 1=Pink, 2=Brown 0.0 2.0 0.0 2.0 0.0
1 Level Output amplitude scaling 0.0 1.0 0.0 1.0 1.0

Processing Algorithm

1. White Noise (xorshift32)

\[\text{state} \oplus= \text{state} \ll 13;\ \text{state} \oplus= \text{state} \gg 17;\ \text{state} \oplus= \text{state} \ll 5\]
\[y = \frac{\text{state (as int32)}}{2^{31}}\]

2. Pink Noise (Voss-McCartney)

8 octave bands, each updated at decreasing rates (band \(i\) updates every \(2^i\) samples):

\[y = \frac{1}{8} \sum_{i=0}^{7} \text{band}_i\]

3. Brown Noise (Leaky Integrator)

\[s \leftarrow s + 0.02 \cdot \text{white}\]
\[s \leftarrow s \cdot e^{-2\pi \cdot 20 / f_s}\]
\[y = \text{clamp}(3.5 \cdot s, -1, 1)\]

4. Level Scaling

\[y_{\text{out}} = y \cdot \text{level}\]

Snapshot Fields

Field Type Range Unit Description
Type Float 0–2 Active noise type
Level Float 0–1 Current level
Output Float -1–1 Current output sample

Implementation Notes

  • White noise is statistically mean-zero; pink noise is mean-zero by construction
  • Brown noise may drift, mitigated by the leaky integrator at 20 Hz and soft clamp
  • Scaling factor 3.5 for brown noise empirically normalizes amplitude to match white/pink levels
  • No DC blocker applied (white/pink are inherently AC; brown is limited by the integrator)

Equation Summary

y = xorshift32 | Voss-McCartney | leaky∫