NoxNoise: Procedural Sleep — Beating Battery Drain With Real-Time Audio Synthesis
Anyone who uses white noise or environmental sound apps to sleep, study, or focus is familiar with the primary drawback: battery consumption. Leaving heavy MP3 or FLAC audio files looping all night drains your battery, heats up your device, and degrades long-term battery health.
From this frustration arose the idea for NoxNoise: Procedural Sleep, a completely free iOS app that reimagines how we interact with relaxing sounds. Instead of playing heavy, pre-recorded audio loops, NoxNoise synthesizes sound in real-time right on the device using pure mathematics.
In this post, we’ll explore how the app was born and dive into the technical architecture and design behind its zero-drain procedural audio engine.
How It Was Born
The inspiration for NoxNoise came from a common nuisance: an iPhone heating up on the nightstand overnight. Traditional relaxation apps load long audio files into memory and decode them continuously, keeping the CPU, storage controller, and sometimes network interface active.
The concept behind NoxNoise is simple yet powerful: generate noise from mathematical equations, eliminating the need for physical files.
Instead of reading gigabytes of audio data from disk or streaming them over the web, NoxNoise generates small audio buffers (of just 2.0 seconds) and hands them over to the hardware controller to loop seamlessly with near-zero energy consumption. The result? An incredibly lightweight app (only 15 MB on the App Store) that runs offline, protects your privacy 100%, and preserves your battery.
Technical Architecture & Design
The app is written entirely in Swift and SwiftUI and is structured around three key pillars: the AVAudioEngine-based audio synthesis engine, the CoreHaptics somatic biofeedback system, and local Apple Intelligence integration.
1. The Procedural Audio Engine
At the core of NoxNoise is the NoxEngine class, which coordinates a complex audio graph using Apple’s AVAudioEngine framework. The signal chain is designed as follows:
graph LR
SubPlayers[Player Nodes White/Brown/Rain...] --> EnvNode[AVAudioMixerNode]
EnvNode --> EQNode[AVAudioUnitEQ Low-Pass]
EQNode --> ReverbNode[AVAudioUnitReverb]
ReverbNode --> PitchNode[AVAudioUnitVarispeed]
PitchNode --> MainMixer[Main Mixer Node]
graph LR
SubPlayers[Player Nodes White/Brown/Rain...] --> EnvNode[AVAudioMixerNode]
EnvNode --> EQNode[AVAudioUnitEQ Low-Pass]
EQNode --> ReverbNode[AVAudioUnitReverb]
ReverbNode --> PitchNode[AVAudioUnitVarispeed]
PitchNode --> MainMixer[Main Mixer Node]
graph LR
SubPlayers[Player Nodes White/Brown/Rain...] --> EnvNode[AVAudioMixerNode]
EnvNode --> EQNode[AVAudioUnitEQ Low-Pass]
EQNode --> ReverbNode[AVAudioUnitReverb]
ReverbNode --> PitchNode[AVAudioUnitVarispeed]
PitchNode --> MainMixer[Main Mixer Node]
graph LR
SubPlayers[Player Nodes White/Brown/Rain...] --> EnvNode[AVAudioMixerNode]
EnvNode --> EQNode[AVAudioUnitEQ Low-Pass]
EQNode --> ReverbNode[AVAudioUnitReverb]
ReverbNode --> PitchNode[AVAudioUnitVarispeed]
PitchNode --> MainMixer[Main Mixer Node]To achieve optimal, battery-saving performance, the engine employs several strategies:
- Dynamic Hardware Sample Rate Alignment: The engine query’s the hardware’s active sample rate (such as 48,000 Hz) to allocate buffers. This completely eliminates CPU-intensive resampling operations.
- Selective Mono/Stereo Synthesis: Spatial sounds like rain or wind are generated in Stereo, while localized sounds like the hair dryer (
hairDryer), airplane cabin (airplanePlayer), and wave flutter (flutterPlayer) are synthesized in Mono to cut the required synthesis computation in half. - Pure Mathematical Generators:
- White Noise is computed using a pure random number generator (
Float.random(in: -1.0...1.0)). - Brown Noise (warmer and deeper) is synthesized by applying a custom integration filter:
let out = (lastOut + Double(white) * 0.02) / 1.02 - Sounds like the airplane cabin drone or wind sweeps use slow Low-Frequency Oscillators (LFOs at 0.05 Hz - 0.1 Hz) to modulate amplitude, recreating the natural dynamics of moving air or flight engines.
- White Noise is computed using a pure random number generator (
2. Hybrid Stochastic Engine (Organic Layers)
To prevent synthetic noise from sounding flat and sterile, NoxNoise allows users to layer Organic Sounds (campfire crackle, sea waves, crickets, thunder, owls).
Instead of playing these files continuously using CPU decoders, the engine generates a 30-second buffer where it stochastically (randomly) distributes transient audio layers onto a jittered temporal grid. The buffer is baked into memory once when activated and then played back by the hardware loop. This hybrid approach keeps nature’s unpredictability intact without costing a single CPU cycle during playback.
3. Cognitive Tuning (Binaural Beats)
Cognitive relaxation can be facilitated by brainwave entrainment. NoxNoise synthesizes real-time binaural beats (Delta, Theta, and Alpha waves) by sending slightly different frequencies to the left and right stereo channels (e.g., 200 Hz on the left channel and 204 Hz on the right to induce a 4 Hz Theta state) natively over headphones at absolutely zero extra CPU cost.
4. Local Apple Intelligence via FoundationModels
NoxNoise integrates local Apple Intelligence using the new FoundationModels framework (available starting from iOS 18.2+). Thanks to the AppleIntelligenceManager class, users can describe their desired soundscape in natural language (e.g., “Create a muffled airplane cabin sound with some light rain”).
The local SystemLanguageModel parses the request and returns a structured JSON payload containing the exact DSP variables to adjust the Noise Studio sliders:
This model runs offline directly on the device’s Neural Engine, keeping user requests entirely private.
5. “Liquid Glass” UI & Somatic Biofeedback
The interface of the app is designed around the Liquid Glass aesthetic, a glassmorphic neumorphic look where custom sliders resemble a capsule of volumetric glass filling with neon light when dragged.
Complementing the auditory experience is the Somatic Biofeedback system: by pairing the haptic engine (CHHapticEngine) with low-frequency wave dynamics, NoxNoise sends very soft, rhythmic micro-vibrations at 60 BPM (one beat per second) to your iPhone or Apple Watch, encouraging somatic calming and helping to gently lower your heart rate.
Lightweight Sharing and Synchronization
Since custom user presets contain mathematical parameters rather than raw audio files, their file size is under 1 KB. This enables:
- Instant iCloud Sync via CloudKit and KVS across iPhone, Mac, and Apple Watch.
- Spatial Share URLs: The app compresses audio variables into a lightweight URL. Clicking the URL allows another device to mathematically recreate the exact same audio environment locally.
Download NoxNoise: Procedural Sleep
The app is completely free, ad-free, and performs no tracking. It is available for iPhone, iPad, Apple Watch, and Apple Vision Pro.
For iOS developers, DSP enthusiasts, or anyone looking for a battery-friendly, privacy-focused way to sleep and focus, NoxNoise demonstrates how math and coding can improve our daily well-being.