August 2, 2008

Ships Bells Revisited…

Posted in Mac, Mac Software, Productivity at 2:45 am by a11en

A kind reader (Russ P.) shared with me his method for playing the Naval Ship’s Bells (for the daily watch) with us on my About page.  I’ve been meaning to revisit this for a while, ever since my first discussion of Chimes on OsX.  Since I tend to be a fan of the Un*x underpinnings of OsX, I tend to try and use common commands (that are already on your system, that you might not know about) to get these types of tasks done.

For a bit of a review of the methods I’ve used for the Westminster Chimes on OsX, please read my previous post on the topic: Westminster Chimes

I will be using a few of the same tricks here, but I won’t be using one- AppleScript.  For the Ships Bells, AppleScript really isn’t needed.  We’ll be adding 8 lines to our Cron file (using the nice GUI program called Cronnix.  Unlike the Westminster chimes, we don’t have to do any computation to determine the number of times to chime a bell (for the hourly chimes).

First, snag some Ships Bells audio files.  The files here: WxTide Ships Bells are already separated by the number of bells: 1-8 bells.  You of course can use any Ships Bells audio files you like to accomplish this task.  Just be aware that we’re using an approach below that uses a separate file for each type of bell (1-8).

Second, head over to Wikipedia to read about the watches and when the bells are to chime: Wikipedia.  Look closely at that first table… we’ll use it in one second (save it).

Third, if you haven’t done so yet, snag a copy of Play Sound which is a simple program, very easy to call, and we’re going to use it like the following (you can try a variant of this in your terminal.app):

open -a /Applications/PlaySound.app /Users/yournamehere/soundfiles/2bells.wav

That’s a nifty little one-liner that will play a file (here 2bells.wav) with an application you specify (here PlaySound.app).  For more help on this command, in the terminal type “man open” (manual for open).

Now, the sneaky part is we’re not even going to use AppleScript at all to play the ShipsBells!  Haha!  What we are going to do, however, is to run that CLI command directly from Cronnix (the program that keeps track of when to run things for us).

Fourth, make 8 lines in your Cron file (via Cronnix GUI) to play the bells at the appropriate times.  I do this by simply following along with the table in the Wikipedia article, and adding commas for each field in the Cron file as needed…

An example.. the 1 Bell chime can be seen in the first line of the table in the wikipedia article… and here’s the cron command for it:
30    0,4,8,12,16,18,20    *    *    *    open -a /Applications/playsound/Play\ Sound.app /Users/yournamehere/ShipsBells/wxtide32_bells/1bells.wav

As you can see, the 1 bell chime plays on the half-hours of the following hours of the day: Midnight, 4am, 8am, 12pm, 4pm, 6pm, 8pm  (this one is funny, because of the Dog Watches).

Actually, with that little example, you can see the power of the simple Cron command… I can accommodate all the Dog watches very easily, where as some programs you can download don’t even do the dog watches.

We completely avoid Applescript because no calculations are required.  We only lose out in that we have 8 lines to add to our cron-file.  But, I don’t think Cron will be mad we added those 8 lines (one for each of the 8 bells specifying exactly when during the day they are to chime).

So, that’s a simple and quick way to add Ship’s Bells to your computer, if you’re in the Nautical mood.

A quick one goes out to Sailorman Jack- Fair Winds, Jack!

About these ads

1 Comment »

  1. Mark Bigham said,

    I know this is going sound simplistic but where do you put Cron and the sound files after you have written the eight terminal lines.

    And thanks for doing this post. Ever since OS 9 went away I have been looking for a way to reincorporate Ships Bells into my system sounds.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: