Sonic Pi Musical Talking Clock

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

1 Like

Thank you for your( to me always quite) impressive experiments!

JFI: On my Win10 system (see below)
only with

use_real_time                            # or
use_sched_ahead_time 0.09    # >=

i do not get many ‘!! Out of time, skipping:…’-messages.

use_sched_ahead_time 0 always fails with all configurations.

It seems to me that the underlying semantics at least on windows
with use_sched_ahead_time 0 and use_real_time has changed

low/no load System:
AMD A8-7100 Radeon R5, 8 Compute Cores 4C+4G 1.80 GHz
with 1TB SSD and 16GB RAM


HI Bruce
Glad you enjoy the programs. It was written for an early version of Sonic Pi before the use_real_time command was added. This is much more sensible to use in the latest release version 3.3.1 (It also works in the current latest 4.0beta). I have it running now in that version on my Mac. No sign of any timing delays.