ezequiel.is-a.dev
Open the app

Personal project, 2025 and 2026

Buzzify

A quiz buzzer that runs in the phone's browser: hold the button down and it buzzes until you let go. I made the first version for a trivia game in philosophy class, and rebuilt it in 2026.

Built with
JavaScript, no dependencies
Runs in
The browser, no backend
Weighs
118 KB, and works offline
Buzzify on three phones: the big green button in light and dark themes, with the prompt in Spanish and in English.
Light and dark themes, in Spanish and English.

The trivia game

In my last year of technical high school, at UTU, I had to give a presentation on Anaximander in philosophy class. I ended it with a trivia game about what I had just explained, and the class answered by pressing the buzzer on their phones. There were about ten of us, and those without a phone teamed up with someone who had one.

That first version was a button and an MP3 that played once per tap, and it was enough. The buzzer got a laugh, and the answers showed people had been listening.

Why I rebuilt it

In 2026 I went back to polish it and publish the code as a proper project, clean enough for someone else to read. A real buzzer sounds for as long as you hold it, so the sound was the first thing to change. I also added a color picker for the button, with eight presets and a custom color, and made Buzzify a PWA, so it installs like an app and works offline.

Buzzify on a laptop, in dark theme with a red button, and on a phone, in light theme with a green button.
The color picker is in the top bar, next to language and theme.

The sound

I didn't record the buzz. A Python script generates it from a model of an electromagnetic buzzer: a metal reed that a coil pulls twice per cycle of 60 Hz mains. Each pull is a hit, with the click of the contact and a few mechanical modes that keep ringing. The two hits in a cycle come out slightly different, and that difference is what makes it sound like a buzzer instead of a plain tone.

The ear is much more sensitive around 3 kHz than at 120 Hz, where the buzz sits, so two versions with the same energy can sound very different in loudness. That's why I set the level with A-weighting, which follows the ear: if I change the sound, the loudness you hear stays about the same.

A loop without a thump

If you just repeat the file, you hear a thump on every pass. Part of it is the short fade at the start and end of the file, which gets repeated too. The rest is that the sound isn't steady: the low end grows about 25% at the start, half of that in the first 50 ms. A loop that includes that stretch drops the low end every time it starts over, and it sounds like a kick drum.

So the browser builds the loop on the first tap on the page, before anyone presses the button, and plays it with the Web Audio API. It looks for the stretch where the low end is already close to its final level, and picks the loop length by signal correlation, without assuming the sound is periodic. The loop goes at the end of that stretch, where the sound has settled, and the join gets a 20 ms crossfade. On my computer it all takes between 4 and 14 ms.

I never told the algorithm how the sound is made, and the loop it picks is always a whole number of mains cycles. At the five sample rates I test, from 44.1 to 192 kHz, it's exactly 9, because the 150 ms minimum I set for the loop is 9 cycles at 60 Hz. If I raise the minimum, it picks other lengths, but always whole cycles.

The audio is AAC, with an Ogg Vorbis copy for browsers that can't play it. Vorbis adds more noise, so the mismatch at the join goes from -41 dB with AAC to -23 dB with Ogg (lower is better).

On an iPhone

Getting it to work on an iPhone took two more fixes. On iOS, a page can only start audio inside a user gesture, and on a touch screen the gesture counts when the finger lifts, not when it touches down. The buzzer sounds on press, so the first press stayed silent. The fix is a screen you tap once when the page opens.

The other problem is silent mode, which on iOS also mutes Web Audio. Newer versions of iOS let the page declare that it plays audio, and then silent mode leaves it alone. On older ones, a silent track generated in memory and played on a loop does the same job. The catch is that either way, it pauses whatever else the phone was playing.

Offline

You can't count on the classroom Wi-Fi, and a buzzer that stops working halfway through a game is useless. Everything the app needs to run fits in 118 KB, so a service worker saves it all on the first visit, and from then on it works without a connection. Online, each request goes to the network first and the saved copy gets updated. Offline, or if the network takes more than 3 seconds to answer, the saved copy is used.

How I test it

The tests use node:test. Some generate the same buzz in JavaScript at five sample rates and check the loop at each one. Others run the service worker against a fake network and cache, simulate a tap on an iPhone, and check that the app weight noted in the code matches the real one. They all run on every push.

What it doesn't do

Each phone is its own buzzer. They don't talk to each other and there is no server, so the app can't tell who pressed first. That's up to whoever runs the game.