Menu

Rebuilding Apple Watch's "Water Lock" Tone in the Browser (and 3 iOS Safari Gotchas)
πŸ“°

Rebuilding Apple Watch's "Water Lock" Tone in the Browser (and 3 iOS Safari Gotchas)

DEV Community: mobileΒ·nayeemΒ·3 days ago
#zoePbATF
#devtomobile#devto#dev#phone#speaker
Reading 0:00
15s threshold

When you finish a swim, Apple Watch can play a short, buzzy tone to push water out of its speaker. Phones don't have a button like that. Most "water eject" apps I found play a similar tone, and some put it behind a weekly subscription.

I wanted to know if a plain web page could do the same job on any phone, with nothing to install. It mostly can. Here's the physics, the code, and three iOS Safari problems I hit along the way.

Why a low tone, and why around 165 Hz

A speaker grille is a fine mesh. A droplet in the mesh is held there by surface tension, so it often won't drain out on its own.

The speaker sits right behind that mesh. At low pitches the speaker cone moves further with each cycle, so it pushes more air against the droplet. At high pitches it barely moves.

There's a limit, though. Small phone speakers can't play deep bass well. Their output drops off sharply below roughly 100–200 Hz, depending on the phone.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.