CLEAN-ROOM GO MIT LICENSED v0.1.0 ACTIVELY DEVELOPED

Sound in.
State out.

Entrain is a clean-room Go engine for brainwave entrainment. It renders .sbg sessions to WAV, FLAC and MP3, verifies what any renderer put in a file with beatscope — and below, it plays a session live in your browser. Headphones on.

Install the CLI first
$ entrain focus-40-pink -f mp3
focus-40-pink.mp3 · 40 Hz γ over pink noise · 320 kbps
Live demo · Web Audio

The engine, playing live.

Three sessions from the shipped library, synthesized right here with phase-continuous oscillators — the same plans the CLI renders to audio. Switch mid-glide: retuning never clicks.

Session plan
Level
70%

Headphones required — binaural beats collapse on speakers. Each ear must receive its own carrier.

BEATSCOPE · LIVE STANDBY
focus-40-pink
40 Hz γ over pink noise
00:00
L carrier
180.00 Hz
R carrier
220.00 Hz
Beat
40.0 Hz γ
Bed
pink
Engine
Float64 · Go
Would render
focus-40-pink.mp3
STANDBY · 44.1 kHz stereo · press play to synthesize in-browser — nothing is downloaded, nothing is uploaded
Inside the engine

Pure Go in the core pipeline.

Packages you can lift, a binary you can ship.

01 Synth core

Phase-continuous sine oscillators, binaural L/R pairing, equal-power crossfades and amplitude glide envelopes — retuning never clicks. Float64 end-to-end.

02 .sbg reader + planner

Tone-sets, absolute / NOW / relative times, nested blocks — and sbagen's 30-second changeover crossfades with true tone continuity across segments.

03 Codec stack

WAV (go-audio), FLAC (mewkiz, bit-exact) and MP3 (pure-Go Shine, level-matched). Shared clip → TPDF-dither → quantize stage, 16/24-bit, deterministic.

04 Noise DSP

White, pink and brown noise with correct spectral slopes, decorrelated stereo and calibrated bed loudness — plus FFT-shaped 1/fα slopes in noisemaker.

05 beatscope

STFT carrier/beat detection with L/R pairing and window-voted confidence. Cross-engine validated against sbagen — all five brainwave bands match.

5/5 MATCH
06 MIT licensed

No SBaGen code anywhere — derived from public DSP technique and behavioral comparison. Embed it anywhere, including commercial use.

Handbook

Install, render, verify, generate.

All from the terminal.

# from source
$ go install github.com/desireco/entrain/cmd/entrain@latest
$ go install github.com/desireco/entrain/cmd/beatscope@latest
$ go install github.com/desireco/entrain/cmd/noisemaker@latest

# or grab a prebuilt binary:
# github.com/desireco/entrain/releases
formats -f wav|flac|mp3 depth -b 16|24 mp3 bitrate -q ≤ 320 length -L h:mm[:ss] output -o file
Plain text by design

Anatomy of a session.

A session is a few lines of plain text you can read, edit and version — no proprietary format, no binary blobs.

## One-hour focus: 40 Hz gamma over a pink-noise bed
all-off:
-
focus-40:
pink/20  180+40/30
 
0:00:00  focus-40
1:00:00  all-off
0:00:00 · focus in, 30 s changeover crossfade1:00:00 · all-off

01Tone-set line

carrier+beat/amplitude — amplitudes on a 0–100 scale, keep the sum under 100. The engine pairs L/R carriers for a true binaural beat.

02Schedule lines

time name — absolute, NOW, or +mm:ss relative.

03Changeovers

Crossfades happen automatically — 30 seconds, equal-power, with true tone continuity across segments.

04Session library

A small, growing set ships in the repo under examples/ — use as-is or edit in any text editor. Copy one, tweak the numbers, make it yours.

Questions

Asked, answered.

Why a rewrite?

SBaGen (Jim Peters) is wonderful 2000s software — powerful, battle-tested, and GPLv2 with a bespoke C codebase. Entrain keeps the functionality and modernizes everything around it: permissive license, static binaries, modern formats. The full rationale is in the migration plan.

Is Entrain affiliated with SBaGen?

No. Entrain is an independent clean-room reimplementation — no SBaGen code was read or copied, and it is not endorsed by Jim Peters. The original tool and its forks have their own SBaGen page.

What's next?

A native TOML session format ("trains"), EMDR bilateral voices, live playback, and a web player — see the roadmap.