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.β¦