5D Library › Rhythmic Acoustic Stimulation, Auditory Steady-State Responses and Modulation Signal Engineering · 中文

Chapter 3. Pink Noise, A-Weighting and Sleep Masking

What pink noise is

White noise has a flat power density, the same power per hertz; pink noise has density proportional to 1/f1/f, the same power in every octave, so its density falls by 10log⁡10210\log_{10}2, that is 3.01 dB, per octave; brown noise goes as 1/f21/f^2 and falls 6.02 dB per octave. Voss and Clarke found 1/f1/f spectra in the loudness fluctuations of music and speech (Voss and Clarke 1978), and Gardner brought Voss’s synthesis algorithm to general readers (Gardner 1978).

Two methods of making pink noise are common. Voss-McCartney: keep several rows of random numbers, redraw row kk every 2k2^k samples and add the rows; slow rows supply the low frequencies, fast rows the high ones. Filter bank: integrate white noise with a few leaky integrators (first-order IIR filters) and add them with fixed weights. The program makes 2172^{17} samples of each at 44,100 Hz, estimates the spectrum by Welch’s method and fits the slope over seven octaves from 125 Hz to 8 kHz.

Calculation

# Chapter 3. p05: Two ways to make pink noise, and how to check them.
# Pink noise has power density proportional to 1/f^alpha with alpha = 1,
# so each octave carries equal power and the density falls by
# 10 log10(2) = 3.01 dB per octave. Generators at fs = 44,100 Hz,
# 2^17 samples each, fixed seed:
#   white: independent uniform samples;
#   Voss-McCartney: 16 random rows, row k redrawn every 2^k samples,
#     plus one white row, summed;
#   IIR bank: three leaky integrators of white noise (a widely used
#     "economy" filter, coefficients for 44.1 kHz);
#   brown: leaky running sum of white (alpha = 2, 6.02 dB per octave).
# Welch estimate: Hann windows of 4,096, 50 % overlap. Octave bands
# 125 Hz to 8 kHz; slope by least squares of dB on log2(f).
import cmath
import math
import random

FS, N, SEG = 44100, 1 << 17, 4096

def fft(x):
    n = len(x)
    a = list(x)
    j = 0
    for i in range(1, n):
        bit = n >> 1
        while j & bit:
            j ^= bit
            bit >>= 1
        j |= bit
        if i < j:
            a[i], a[j] = a[j], a[i]
    size = 2
    while size <= n:
        w = [cmath.exp(-2j * math.pi * k / size) for k in range(size // 2)]
        for s in range(0, n, size):
            for k in range(size // 2):
                u, v = a[s + k], a[s + k + size // 2] * w[k]
                a[s + k], a[s + k + size // 2] = u + v, u - v
        size *= 2
    return a

def welch(x):
    win = [0.5 - 0.5 * math.cos(2 * math.pi * i / SEG) for i in range(SEG)]
    acc = [0.0] * (SEG // 2)
    count = 0
    for s in range(0, len(x) - SEG + 1, SEG // 2):
        X = fft([x[s + i] * win[i] for i in range(SEG)])
        for k in range(SEG // 2):
            acc[k] += abs(X[k]) ** 2
        count += 1
    return [a / count for a in acc]

def bands(psd):
    out = []
    for o in range(7):
        fc = 125.0 * 2 ** o
        lo, hi = fc / math.sqrt(2), fc * math.sqrt(2)
        ks = [k for k in range(len(psd)) if lo <= k * FS / SEG < hi]
        out.append((fc, 10 * math.log10(sum(psd[k] for k in ks) / len(ks))))
    return out

def slope(b):
    xs = [math.log2(fc) for fc, _ in b]
    ys = [d for _, d in b]
    mx, my = sum(xs) / len(xs), sum(ys) / len(ys)
    return (sum((x - mx) * (y - my) for x, y in zip(xs, ys)) /
            sum((x - mx) ** 2 for x in xs))

def gens(seed=11):
    rng = random.Random(seed)
    white = [rng.uniform(-1, 1) for _ in range(N)]
    rows = [rng.uniform(-1, 1) for _ in range(16)]
    voss = []
    for i in range(N):
        if i:
            k = (i & -i).bit_length() - 1
            if k < 16:
                rows[k] = rng.uniform(-1, 1)
        voss.append(sum(rows) + rng.uniform(-1, 1))
    b0 = b1 = b2 = 0.0
    iir = []
    for w in white:
        b0 = 0.99765 * b0 + w * 0.0990460
        b1 = 0.96300 * b1 + w * 0.2965164
        b2 = 0.57000 * b2 + w * 1.0526913
        iir.append(b0 + b1 + b2 + w * 0.1848)
    acc, brown = 0.0, []
    for w in white:
        acc = 0.998 * acc + w
        brown.append(acc)
    return [("white", white), ("Voss-McCartney", voss),
            ("IIR bank", iir), ("brown", brown)]

if __name__ == "__main__":
    print("   band level in dB relative to the 1 kHz band")
    print("   generator        125   250   500    1k    2k    4k    8k"
          "  dB/oct")
    for name, x in gens():
        b = bands(welch(x))
        ref = b[3][1]
        print("   {:15s}".format(name) + "".join(
            "{:6.1f}".format(d - ref) for _, d in b) +
            "{:8.2f}".format(slope(b)))
    print("   targets: white 0, pink {:.2f}, brown {:.2f}".format(
        -10 * math.log10(2), -20 * math.log10(2)))
    print("\nReading: both pink generators land within 0.1 dB per")
    print("octave of the target slope over seven octaves, while single")
    print("bands wander by up to about 1 dB around the straight line.")
    print("A file sold as pink noise can be checked the same way in a")
    print("few seconds.")
#    band level in dB relative to the 1 kHz band
#    generator        125   250   500    1k    2k    4k    8k  dB/oct
#    white            -0.4   0.3   0.0   0.0   0.0   0.0  -0.0    0.02
#    Voss-McCartney    8.6   5.8   3.1   0.0  -3.2  -6.5  -9.8   -3.08
#    IIR bank          8.9   7.1   3.5   0.0  -2.6  -5.2  -8.8   -2.99
#    brown            17.4  12.3   6.1   0.0  -6.0 -11.9 -17.6   -5.92
#    targets: white 0, pink -3.01, brown -6.02
#
# Reading: both pink generators land within 0.1 dB per
# octave of the target slope over seven octaves, while single
# bands wander by up to about 1 dB around the straight line.
# A file sold as pink noise can be checked the same way in a
# few seconds.

The two pink generators fall by 3.08 dB and 2.99 dB per octave, both within 0.1 dB of the 3.01 dB target; single bands wander by up to about 1 dB around the straight line. Brown noise gives 5.92 dB and white noise 0.02 dB. Any audio file sold as pink noise can be checked the same way in a few seconds.

Relative band levels of four noises over seven octaves (the 1 kHz band at 0 dB).

Same level, different reading

Sound level meters usually report A-weighted levels (dBA). The A-curve cuts the low frequencies hard and is 0 dB at 1 kHz (International Electrotechnical Commission 2013). So for the same unweighted level, the more low-frequency content a noise has, the lower its A-weighted reading. This matters for sleep masking: a brown noise machine reading “only” a few tens of dBA can be quite loud in the bass.

Calculation

# Chapter 3. p06: A-weighting, masking margin and night-time arousals.
# Part 1. Three noises with the same flat (unweighted) level of 50 dB
# between 20 Hz and 20 kHz: white (flat density), pink (1/f) and brown
# (1/f^2). Their A-weighted levels follow from integrating the density
# times the IEC 61672 A-curve on a fine logarithmic grid:
#   RA(f) = 12194^2 f^4 / ((f^2 + 20.6^2)
#           sqrt((f^2 + 107.7^2)(f^2 + 737.9^2)) (f^2 + 12194^2)),
#   A(f) = 20 log10 RA(f) + 2.00 dB.
# Part 2. An illustrative arousal model: a noise event of maximum
# level Lmax (dBA) over a steady background B (dBA) has emergence
# E = Lmax - B. Probability of an EEG arousal per event:
#   p = 0.02 + 0.30 / (1 + exp(-(E - 25) / 5)).
# A steady masker raises B and so lowers E for every event, but it
# adds its own sound energy all night long.
import math

def ra(f):
    f2 = f * f
    return (12194.0 ** 2 * f2 * f2 /
            ((f2 + 20.6 ** 2) *
             math.sqrt((f2 + 107.7 ** 2) * (f2 + 737.9 ** 2)) *
             (f2 + 12194.0 ** 2)))

def a_db(f):
    return 20 * math.log10(ra(f)) + 2.00

def levels(alpha, flat_db=50.0, n=4000):
    lo, hi = math.log(20.0), math.log(20000.0)
    tot = wtot = 0.0
    for i in range(n):
        f = math.exp(lo + (hi - lo) * (i + 0.5) / n)
        d = f ** (-alpha) * f
        tot += d
        wtot += d * 10 ** (a_db(f) / 10)
    return flat_db + 10 * math.log10(wtot / tot)

def p_arousal(lmax, bg):
    e = lmax - bg
    return 0.02 + 0.30 / (1 + math.exp(-(e - 25) / 5))

if __name__ == "__main__":
    print("   A-curve at 31.5, 63, 125, 1000 Hz: " + ", ".join(
        "{:.1f}".format(a_db(f)) for f in (31.5, 63, 125, 1000)) + " dB")
    print("\n   noise   flat level   A-weighted   difference")
    for name, al in (("white", 0.0), ("pink", 1.0), ("brown", 2.0)):
        la = levels(al)
        print("   {:6s} {:9.1f} dB {:9.1f} dBA {:9.1f} dB".format(
            name, 50.0, la, la - 50.0))
    print("\n   arousal probability per event")
    print("   background dBA   event 50   event 60   event 70")
    for bg in (25, 35, 40):
        print("   {:14d}   ".format(bg) + "  ".join(
            "{:9.3f}".format(p_arousal(l, bg)) for l in (50, 60, 70)))
    print("\n   expected arousals in a night with 20 events of 60 dBA:")
    for bg in (25, 35, 40):
        print("     background {} dBA: {:.2f}".format(
            bg, 20 * p_arousal(60, bg)))
    print("\nReading: the same unweighted level reads very differently")
    print("on an A-weighted meter. Brown noise hides most of its energy")
    print("below the A-curve, so a 'quiet' brown masker can be loud in")
    print("the bass. Masking lowers arousal per event by shrinking the")
    print("emergence, at the price of a louder night.")
#    A-curve at 31.5, 63, 125, 1000 Hz: -39.5, -26.2, -16.2, 0.0 dB
#
#    noise   flat level   A-weighted   difference
#    white       50.0 dB      48.0 dBA      -2.0 dB
#    pink        50.0 dB      47.1 dBA      -2.9 dB
#    brown       50.0 dB      37.2 dBA     -12.8 dB
#
#    arousal probability per event
#    background dBA   event 50   event 60   event 70
#                25       0.170      0.284      0.315
#                35       0.056      0.170      0.284
#                40       0.034      0.101      0.239
#
#    expected arousals in a night with 20 events of 60 dBA:
#      background 25 dBA: 5.68
#      background 35 dBA: 3.40
#      background 40 dBA: 2.01
#
# Reading: the same unweighted level reads very differently
# on an A-weighted meter. Brown noise hides most of its energy
# below the A-curve, so a 'quiet' brown masker can be loud in
# the bass. Masking lowers arousal per event by shrinking the
# emergence, at the price of a louder night.

The A-curve cuts 39.5 dB at 31.5 Hz, 26.2 dB at 63 Hz and 16.2 dB at 125 Hz. Three noises with the same unweighted level of 50 dB read as follows: white noise 48.0 dBA, pink noise 47.1 dBA, brown noise 37.2 dBA, the last 12.8 dB below its unweighted level.

Masking and micro-arousals

Night-time traffic noise events cause EEG micro-arousals, with a probability that rises with the maximum level of the event (Basner et al. 2011). The program’s illustrative model writes the arousal probability as a logistic function of the event’s emergence (maximum level minus background). Raising the background from 25 dBA to 40 dBA lowers the arousal probability for a 60 dBA event from 0.284 to 0.101; over a night with 20 such events, the expected micro-arousals fall from 5.68 to 2.01. This is the mechanism of sound masking: it relies on no special frequency, only on shrinking the emergence.

Probability that one noise event causes a micro-arousal at three background levels (illustrative model).

Evidence

Published evidence. A small study reported more stable sleep time under steady pink noise (Zhou et al. 2012). A quite different line of work is closed-loop acoustic stimulation: short pink-noise bursts played on the rising phase of slow waves strengthen the slow oscillation and improve next-day memory retention (Ngo et al. 2013). It depends on timing locked to the EEG phase and is not the same intervention as steady noise played all night. The World Health Organization’s night noise guidelines discuss the effects of night noise on sleep and its limits (World Health Organization Regional Office for Europe 2009).

The price of masking is extra sound energy all night. A background of 40 dBA is not quiet in itself; Chapter 5 shows that it hardly affects hearing dose, but its long-run effect on sleep is a matter for trials, not reasoning.

Hypothesis · not established

Testable consequence. In bedrooms with frequent noise events, steady pink noise at 40 dBA should reduce event-related micro-arousals per night compared with a quiet control; in quiet bedrooms with few events it should give no measurable benefit. What would show this wrong: if the benefit appears equally in quiet bedrooms, the mechanism is not masking and needs another explanation; if it does not appear in noisy bedrooms either, the masking model fails.

Summary

Pink noise can be made with two simple algorithms and its slope checked in seconds. A-weighted readings understate the energy of low-frequency noise. The sleep effect of pink noise most likely comes from masking: it raises the background and shrinks the emergence of noise events.

References

Basner, Mathias, Uwe Müller, and Eva-Maria Elmenhorst. 2011. “Single and Combined Effects of Air, Road, and Rail Traffic Noise on Sleep and Recuperation.” Sleep 34 (1): 11–23.
Gardner, Martin. 1978. “Mathematical Games: White and Brown Music, Fractal Curves and One-over-f Fluctuations.” Scientific American 238 (4): 16–32.
International Electrotechnical Commission. 2013. IEC 61672-1:2013, Electroacoustics. Sound Level Meters. Part 1: Specifications. International Standard.
Ngo, Hong-Viet V., Thomas Martinetz, Jan Born, and Matthias Mölle. 2013. “Auditory Closed-Loop Stimulation of the Sleep Slow Oscillation Enhances Memory.” Neuron 78 (3): 545–53.
Voss, Richard F., and John Clarke. 1978. “‘1/f Noise’ in Music: Music from 1/f Noise.” Journal of the Acoustical Society of America 63 (1): 258–63.
World Health Organization Regional Office for Europe. 2009. Night Noise Guidelines for Europe. WHO Regional Office for Europe.
Zhou, Junhong, Dongdong Liu, Xin Li, Jing Ma, Jue Zhang, and Jing Fang. 2012. “Pink Noise: Effect on Complexity Synchronization of Brain Activity and Sleep Consolidation.” Journal of Theoretical Biology 306: 68–72.

Fan, Y. (2026). Rhythmic Acoustic Stimulation, Auditory Steady-State Responses and Modulation Signal Engineering: Binaural versus Isochronic Envelope Depth, 40-Hz Phase-Locking Bounds and Pink-Noise Spectral Masking [节律声刺激、听觉稳态反应与双耳等时调制工程] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090211 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).