`brown-noise`: The Tiny Go Engine That Makes Endless Brown Noise Feel Instant

A real-time audio generator that trades loops and media players for a minimal, low-GC pipeline, a first-order filter, and a shell-script switch you can actually live with.

6 to 8 min read • View on GitHub • More from ulsc

A compact mechanical audio machine sits in a white studio. Random sparks enter from the left, pass through a small filter chamber in the middle, and emerge on the right as a steady ribbon of dark wave bands flowing into headphones. The scene explains that the project generates brown noise live instead of replaying a loop.
The whole idea fits on one workbench: synthesize, smooth, stream.

Compared to playing a pre-recorded brown noise MP3 or WAV file, the real-time generation approach used in this application offers the following benefits: Infinite, non-repeating noise generation. No need for large audio files or continuous looping.

Ulas Can Cengiz, Project Creator / Maintainer · ulsc/brown-noise GitHub README
Key Takeaways

Most noise apps solve the wrong problem. They ship a file, loop it, and hope your ear never notices the seam. brown-noise takes a cleaner route: it generates an endless signal in real time, so there is no loop point to betray itself and no media player hanging around the edges.

What `brown-noise` actually does under the hood

The repo is small, but it is not casual. A Go program talks to the oto audio backend, fills byte buffers in the background, and writes them out as a continuous stream. That makes the project feel less like a consumer app and more like a compact audio engine with one job.

The program is a pipeline, not a file player. Noise is generated, filtered, and written forward in a loop that keeps state alive between samples.

lastSample = alpha*randomSample + (1-alpha)*lastSample

That line is the center of gravity. Instead of treating brown noise as a static asset, the program treats it as a sequence of samples that are continuously shaped by a first-order filter. The state in lastSample is what keeps the sound connected from one moment to the next.

The filter that turns white noise into brown noise

The math is a smoothed random walk. Each new random sample nudges the previous output instead of replacing it outright, which strips away high-frequency harshness and gives the result that low, rolling character people associate with brown noise. In practical terms, the filter makes the signal feel deeper and less speckled.

A close-up cross section of a filter chamber shows random input samples entering from the left, a central dial for alpha, and a persistent lastSample reservoir beneath the chamber. Smooth output waves leave on the right and become visibly more rounded as the filter strengthens. The image explains how state and smoothing transform white noise into brown noise.
The interesting part is not the randomness. It is the memory. Brown noise happens because each new sample leans on the one before it.
u := uint16((sample + 1) * 32767.5)
binary.LittleEndian.PutUint32(buffer[i:i+4], (u<<16)|u)

That byte-level write matters. The program is not just making sound, it is packing stereo output efficiently enough that the whole thing can stay lightweight and responsive. The point is not cleverness for its own sake. It is to keep the pipeline smooth.

Why the audio stays smooth instead of glitchy

Real-time audio exposes sloppy engineering immediately. If buffers stall, you hear it. If state resets, you hear clicks. If garbage collection interrupts the flow, the illusion breaks. `brown-noise` avoids that with a buffer pool, buffered channels, and a design that keeps the generator busy while playback consumes the next chunk.

ToolRuntime footprintDeployment styleRealtime generationBest use case
brown-noiseTiny compiled binaryLocal CLI plus shell toggleYesDeveloper-friendly background noise
SoXBroader command-line suiteInstalled system toolYesGeneral audio processing
myNoiseBrowser and web serviceWeb appYesPolished preset-based listening
Python or C# noise toolsHeavier runtimeScript or app runtimeUsuallyQuick prototyping and custom DSP

The tradeoff is clear. SoX is a heavyweight generalist. Browser tools are polished but live inside a browser. Higher-level implementations are convenient but often bring a bigger runtime along for the ride. `brown-noise` is narrower than all of them, and that is the point.

Why the shell script matters more than it looks

The toggle_noise.sh script is a product decision disguised as a utility. It removes the mental overhead of process management and turns the generator into something closer to a light switch. That matters because the best background tool is the one you stop thinking about.

if pgrep -f brown-noise >/dev/null; then
  pkill -f brown-noise
else
  ./brown-noise &
fi

That tiny loop is the whole UX thesis. The repo does not ask you to learn a new interface. It just gives you a reliable local process and a quick way to start or stop it.

What this repo says about Go as a utility language

This is a strong Go story because it is so unglamorous. The language is being used to do one operational thing well, with low ceremony and enough control to care about latency, memory reuse, and byte layout. That combination is exactly why Go still feels like a good language for small tools that need to behave like real systems.

The bigger lesson is not that every audio app should be written in Go. It is that a mundane problem can feel carefully designed when the implementation respects the physics of the thing. Here, the physics is audio continuity. The result is a tool that disappears once it starts, which is probably the highest compliment a noise generator can get.

A WSJ hedcut-style portrait of Ulas Can Cengiz based on his GitHub avatar. The portrait provides attribution for the project creator and anchors the quote card to a verified public image.