From a Controller on the Belly to the Headset Itself
In BreathSync (2021), my team detected breathing by strapping a VR controller to the user's stomach. It worked, but it asked people to wear extra hardware. For Brain Candy I wanted the same responsiveness with nothing added at all.
The insight: breathing moves the head too. As the chest and shoulders rise and fall, the headset's forward tilt shifts by a small, rhythmic amount — enough to track if you calibrate for it.
How the Algorithm Works
The detector runs every frame in Unity, in four stages:
- Calibrate: it records the headset's forward tilt over a rolling ~5-second window and averages the window's minimum and maximum, giving a personal range for each user.
- Normalize and smooth: the current tilt is mapped into that range, clamped, and smoothed so small jitters don't read as breaths.
- Classify: comparing the smoothed value with its value about a second earlier tells rising (inhale) from falling (exhale); a change below a small threshold reads as a held breath.
- Respond: the breath state drives a breath orb that rises and falls, changes color, and cues the user to breathe in, out or hold.
Design Decisions
- Self-calibrating, not fixed thresholds: posture, headset fit and breathing depth differ for every person, so the range is learned live and keeps adapting.
- A dead band for holds: breath holds are part of breathwork, so a small, deliberate threshold separates a still breath from noise.
- Smoothing over speed: a calm, steady signal matters more in a meditative experience than reacting to every micro-movement.
- Honest feedback during setup: a short calibration message tells the user to settle in while the detector learns their range.
About Brain Candy
Brain Candy, created by David Lobser, is a VR app for Meta Quest and Steam that uses flicker light stimulation, sound and visual patterns to support relaxation, focus and creative exploration. I contributed the breath detection for its Breathwork DLC, and published the algorithm as open source so others can build breath-aware VR without extra sensors.
Breathwork is an add-on to Brain Candy on the Meta Quest store: over two dozen breathing experiences that pair breathing pacers with pattern entrainment, including box breathing, holotropic breathing, mindful breathing, parasympathetic breathing and voice-guided sessions.
