Overview
Most "noise machines" generate one or two flavors of hiss and call it a day. This one generates six colors of noise from first principles -; white, pink, brown, blue, violet, and green -; each shaped to the correct spectral slope rather than faked with an EQ curve. It exists in two forms: a Pythonista build that runs on iOS, and a Flask web app that streams continuously in the browser and exports clean WAV files.
Background
This is the tooling half of the colored-noise research -; if you want to study how spectral color affects cognition, you first need a generator you can trust to actually produce a real 1/f pink spectrum or a true −6 dB/octave brown. The off-the-shelf apps are opaque about what they're doing, so the simplest path was to write the synthesis directly and keep the math honest.
The annoying part of streaming noise is the clicks: cumulative noise types (brown, green) drift, and naive chunked playback pops at every chunk boundary. Solving that -; continuity accumulators and crossfades -; ended up being most of the engineering.
How It Works
Each color is synthesized from white noise (Gaussian random samples) and then shaped:
- White -; Gaussian random distribution, flat spectrum.
- Pink -; FFT-based 1/f filtering (−3 dB/octave).
- Brown -; cumulative sum of white noise (−6 dB/octave).
- Blue -; FFT-based √f amplification (+3 dB/octave).
- Violet -; first difference of white noise (+6 dB/octave).
- Green -; 200-;2000 Hz bandpass plus a brown component, for a nature-like mid-band.
The pink and blue filters are the textbook frequency-domain approach -; transform white noise, scale each bin by a power of frequency, transform back:
Brown and green are cumulative, so they can't be regenerated independently per chunk without drifting. The generator keeps an accumulator between chunks and normalizes by RMS (target RMS 0.3) so the volume stays even and the seams stay silent. Exported files glue 0.5-second chunks together with 512-sample crossfades.
# pink noise via FFT shaping of white noise white = np.random.normal(0, 1, samples) spectrum = np.fft.rfft(white) freqs = np.fft.rfftfreq(samples) spectrum[1:] /= np.sqrt(freqs[1:]) # 1/f power -> -3 dB/oct pink = np.fft.irfft(spectrum, n=samples) pink /= np.max(np.abs(pink)) # normalize
On top of the noise sit two optional effects: phase-coherent binaural beats (a slightly detuned tone per ear, with presets for delta through gamma) and amplitude or square-wave modulation. Output is 44.1 kHz, 16-bit PCM.
Current Status
Archived and working. Both the iOS and web builds run; the web app streams click-free and exports WAVs from 10 seconds to 10 minutes. It shipped with batch presets -; Meditation, Sleep, and Focus sets -; that bundle specific colors with matching binaural frequencies.
- Six colors generated, all with verified spectral slopes.
- Continuity system keeps brown/green seamless across chunks.
- Built primarily as the instrument for the colored-noise neuro research.