Engineering

Designing Granular Audio Mixers for Mindful Soundscapes

A technical breakdown of implementing multi-layered audio controls to prevent sound masking in productivity apps.

Amin Shekh · November 21, 2026
Share

Audio in a productivity context is often binary: it is either on or off. When we began building Mindful Assistant, our goal was to create a background environment that protected a user's attention. However, we quickly discovered that a single volume slider for "Background Noise" was insufficient. If a user wanted the soothing texture of heavy rain alongside a low-frequency brown noise for focus, one would inevitably mask the other. This phenomenon, known as auditory masking, occurs when the perception of one sound is affected by the presence of another. In a focus app, this leads to a muddy, distracting acoustic mess rather than a calibrated workspace.

To solve this, we moved away from a master-volume approach toward a granular audio mixer. This engineering shift required us to rethink how we handle concurrent audio streams in Android and how we present that complexity to a user who is already trying to reduce cognitive load. The result is a system that allows for "sound stacking," where each layer serves a specific psychological purpose without competing for the same frequency space.

The Technical Challenge of Concurrent Streams

Most Android applications handle audio through a single MediaPlayer or ExoPlayer instance. For a simple meditation track, this is fine. But for a granular mixer, we needed to play three, four, or even five loops simultaneously. Each loop must be perfectly seamless, and each must have its gain controlled independently in real-time.

We initially explored SoundPool, which is excellent for low-latency triggers like those we use for discrete notifications in Salah Companion. However, SoundPool is not designed for long-form, gapless looping of high-fidelity ambient files. Instead, we implemented a multi-track ExoPlayer architecture where each ambient layer (Rain, White Noise, Cafe Ambience, Birds) resides in its own player instance, managed by a central AudioManager service.

This architecture introduced a synchronization hurdle. If a user enables "Thunder" and "Rain," these files must loop without the tiny "click" or silence that occurs when a buffer reaches its end. We solved this by using Ogg Vorbis files with specific metadata for gapless playback, ensuring that as the gain on one track is adjusted, the underlying timing remains locked with the others.

Solving the Audio Masking Problem

Auditory masking is most prevalent when two sounds share a similar frequency spectrum. For example, the high-frequency hiss of white noise will easily drown out the delicate pitter-patter of light rain. If the user only has one volume slider, they are forced to choose one or the other, or turn both up until they reach an uncomfortable decibel level.

Our solution was to implement a "Gain Normalization Matrix." When a user adjusts the volume of one layer, we don't just change a float value; we calculate how that change affects the perceived clarity of other active layers.

Comparison: Master Volume vs. Granular Mixer

FeatureMaster Volume ApproachMindful Assistant Granular Mixer
Frequency ControlNone; all sounds rise/fall togetherIndependent gain per frequency profile
Cognitive LoadHigh; user struggles to hear specific soundsLow; user balances sounds once per session
LayeringDestructive; loud sounds mask quiet onesAdditive; distinct layers remain audible
Resource UsageLow; single audio streamModerate; multiple concurrent decoders

By allowing the user to drop the "White Noise" to 20% while keeping "Rain" at 80%, the rain provides the rhythmic, soothing foreground while the white noise provides a structural floor that blocks out sudden external sounds like a slamming door or a car horn.

Designing a Low-Friction Mixer UI

Exposing five or six volume sliders to a user who is trying to focus is a dangerous UI choice. If the interface looks like a professional DAW (Digital Audio Workstation), we have failed. The user wants to work, not act as a sound engineer.

We adopted a "Discovery-Based Mixing" pattern.

  1. 1.The Base Layer: The user selects a primary environment (e.g., "Library").
  2. 2.The Texture Layers: Small icons represent additive sounds (e.g., "Keyboard Clicks," "Rain on Window").
  3. 3.Inline Adjustment: Instead of a separate mixer screen, tapping an active icon reveals a vertical slider directly on the main focus screen.

This keeps the UI flat and prevents the user from diving into nested menus. It mirrors the design philosophy we used in Salah Companion, where complex calculation settings are tucked away so the primary focus—the prayer times—remains central. In Mindful Assistant, the primary focus is the timer; the audio is a supporting element that should be adjustable with a single thumb gesture.

Managing Battery and Memory Overhead

Running multiple audio decoders is computationally expensive. On older Android devices, this can lead to thermal throttling or rapid battery drain. To maintain our studio's commitment to lightweight, efficient apps, we implemented several optimizations:

  • Resource Pooling: We only initialize an ExoPlayer instance when a sound is actually toggled on. If a user only listens to rain, the other four players are never instantiated.
  • Downsampling for Ambience: Since ambient sounds like "Brown Noise" don't require the same dynamic range as a symphony, we use lower-bitrate files that still sound excellent through headphones but require significantly less CPU for decoding.
  • Foreground Service Management: We use a high-priority foreground service to ensure the Android system doesn't kill the audio process when the screen turns off. This is a lesson we learned when Handling Precise Timing in Jetpack Compose Countdown UI, where background process persistence is vital for user trust.

User Case Study: The "Deep Work" Stack

Consider a user working in a noisy open-plan office. They need to block out human speech—one of the hardest sounds to ignore.

With a standard app, they turn up music, which can itself be distracting. With the Mindful Assistant mixer, they build a stack:

  • Pink Noise (70%): Provides a broad spectrum of sound that specifically masks the frequencies of human speech.
  • Rhythmic Heartbeat (30%): Provides a low-frequency pulse that helps the user maintain a steady working pace.
  • Wind Chimes (15%): Provides occasional, non-rhythmic high-frequency sounds that prevent the "vacuum effect" of pure static noise.

Because the user can dial these in specifically, they can achieve total isolation at a lower overall volume than they would need with a single-track solution. This protects their long-term hearing health while significantly improving their short-term focus.

Implementation Checklist for Audio Layering

If you are building an app that requires simultaneous audio streams, use this checklist to ensure a smooth experience:

  • [ ] Validate Gapless Assets: Ensure your audio files have no silence at the beginning or end. Use Ogg or Flac for the best results on Android.
  • [ ] Handle Audio Focus: Ensure your app responds correctly when the user receives a phone call or plays a video in another app (use OnAudioFocusChangeListener).
  • [ ] Implement Fade-in/Fade-out: Sudden starts and stops are jarring. We use a 500ms linear fade for every layer toggle.
  • [ ] Memory Monitoring: Track the number of active decoders and set a hard cap to prevent crashes on low-end hardware.
  • [ ] State Persistence: Save the user's specific mix levels. If they found a perfect balance, they shouldn't have to recreate it the next morning.

Conclusion: Focus Through Calibration

In the world of productivity software, "less is more" is a common refrain. But when it comes to the sensory environment, "less control" often leads to more frustration. By engineering a granular audio mixer for Mindful Assistant, we didn't just add a feature; we solved a physiological problem. We gave users the tools to calibrate their environment to their specific neurodivergent needs, their specific office noise, or their specific task.

Building focused tools means understanding the nuances of the problem. Whether it's calculating precise times for Salah Companion or balancing the frequencies of a rainfall loop, the goal is the same: software that serves the user's intent without getting in the way.

What to do next

  1. 1.Audit your current focus sounds: Try listening to your favorite ambient track and identify if any frequencies feel harsh or if you're struggling to hear certain elements.
  2. 2.Experiment with stacking: Use a tool that allows multiple layers to see if a combination of low-frequency (brown noise) and high-frequency (rain) works better for your focus than either alone.
  3. 3.Check your volume levels: Aim for the lowest volume possible that still masks distracting external sounds. Granular mixing makes this easier to achieve.
#android engineering#ux design#audio programming#productivity

One email per launch. No spam, unsubscribe any time.