Clock chime

project , published by Maarten Tromp, 287 words

Some years ago I lived very close to a clock tower. What surprised me it that I hardly noticed it toll, but always had a sense of what time it was. Now that I have moved away, I would like to replicate that feeling. Since we don't have a clock tower nearby, I decided to do the next best thing and write a simple script that plays some striking samples. Like clockwork.

Screenshot of clock chime code
Screenshot of clock chime code

Since I couldn't find an audio sample for that specific clock tower, I downloaded another one from FreeSFX. I cut a shorter version of the sample, which can be played on repeated tolling. The full-length sample is always played last and has a nice long sustain.

A small Python script is started every half hour by the cron daemon. It checks what time it is and plays the corresponding number of samples. The first version had a bug that made the clock strike 13 times at high noon and midnight, but decided it's hilarious and left it in. So far nobody else seems to have noticed. Maybe I'm the only one counting strikes.

The script runs on our home server. It is connected to some Trust computer speakers from the previous century. One speaker sits in the cupboard with the server, the other one is patched over network cabling to the other side of the house. So wherever you are in the house, chances are you will hear the clock strike.

Guests sometimes are surprised at hearing our clock toll when there isn't a clock tower anywhere to be seen.

This code and article are released into the public domain. You can find code, samples and cronjob fragment in the downloads directory of this article.