Musical alarm clock script
Project | Article by Maarten Tromp | Published | 521 words.
Introduction
My noisy computer had been my alarm clock for almost a year. But now that my computer was silent enough to just leave on during the night, how about waking up with some nice music instead?
In this article:
In 2002 you either had an alarm clock or a clock radio. Some mobile phones had an alarm clock built-in that could beep, but it would be years before there were apps or music players on phones. So mainly you had the choice between a device beeping at you or a radio.
If you were creative you could hook your stereo up to a mains timer switch and wake up with music from cd or tape. (Or use computer controlled relays to power on some devices like lights and the coffee maker, like I had done.) But subtly fading in music was not an option.
Unless, of course, you leave your speakers on and automate the music player and volume control on your computer.
And that is exactly what this script does. It can pause and unpause xmms, my main music player (sort of Winamp), and control the audio mixer master volume.
In the morning it would put the volume all the way down and start playing. The volume is slowly increased to a normal level over the course of about one minute. But the increasing continues some more after that, to give you some incentive for getting out of bed.
In the evening the script would do the reverse. It would slowly decrease the volume over the course of half an hour. Once the volume is all the way down, it pauses the music again.
Fine-tuning the curves was done by trial and error. When you increase the volume to fast, it feels very abrupt. You might as well use an alarm clock then. But when increasing the volume too slow I got very sensitive to sounds in the morning. A bird call would wake me up. The values that worked for me were hard-coded in the script.
To set your alarm clock, the script would call at
and schedule itself for the next morning. And once that line is in your bash history you can set your alarm very quickly.
For the first couple of months I had the script wake me up with my then favourite album (Zink by Bloem de Ligny). This was not a very good idea, since soon it stopped being my favourite album. So I modified the script to continue whatever was playing in the evening and that worked better.
The musical alarm clock script in this article is developed using free and open source software where possible. Code is written using Vim, runs in Bash, and music plays in XMMS.
In turn, this code and article are released into the public domain. You can find relevant files in the downloads directory of this article.