I always like to look for unusual applications of Sonic Pi, and earlier this week I thought it would be nice to use Sonic Pi to produce a musical talking clock. The fact that Sonic Pi is based on Ruby means that you can use the Ruby Time.now method to obtain information on the current time, and this can then be utilised to create notes at different pitches related to the seconds in the hour. Since you can also use your own audio samples with Sonic Pi it is not too difficult to get it speaking the time at the beginning of each minute. To make it a bit more musical I also programmed it to play the Westminster Chimes on the quarters of the hour. For this I decided not to use a bell sample but to make use of the ambi_glass_rub sample built in to Sonic Pi. I added flexibility by allowing the user to select various possibilites for the program and to turn them on or off by changing a flag from true to false.
To make everything visually more attractive, although Sonic Pi prints the current second value, I set up an Analog Clock using a processing script which can also display the time as the program runs. It is not connected directly with Sonic Pi, nor is it necessary but it looks quite nice.
You can download the software for the clock here
(including the speech samples and the processing sketch) and you can see a full video of the clock in operation here
I have spent a lot of time refining the program (this is version 8 of the program), trying to eliminate timing errors but without complete success. Part of the problem is that because it is a real time clock you have to run the program with the sched_ahead_time set to 0 which gives Sonic Pi very little leeway when things like garbage collection take place! However most of the errors do not affect the coninued running of the program.