The timer only runs while playing — the SOMNA audio engine
A 2-channel mixer, a timer that stops when you pause, a fade-out over the last 30 seconds. And a notification icon that vanished only in release builds.
SOMNA is a sleep sound app that works without internet. Every sound is synthesized with ffmpeg, so there are no copyright worries.
Design principles
- Two channels — two players, each looping with its own volume control. Think rain + music box.
- The timer only runs while playing — if you pause, the remaining time pauses too. It's annoying to step away for a moment and come back to a timer that already ran out.
- 30-second fade-out at the end — if the sound cuts off abruptly, you wake up.
- A foreground service plus a media notification keep playback and the timer going even when the screen turns off.
- Pull out your earphones and it pauses; get a phone call and it yields audio focus.
The bug that only showed up in release
The debug build was fine, but in the release build the notification icon didn't show up. Resource shrinking looked at an icon referenced only by a name string in code, decided it was an "unused resource", and deleted it.
I fixed it by listing the resources to keep in res/raw/keep.xml. If your code looks up resources by name, checking the release build is a must.
Web demo
The SOMNA demo isn't the Flutter app uploaded as-is. I only ported the 2-channel mixer and the fade-out timer to Web Audio. The audio files are the same as in the app.

Try the demo