Tag Archives: audio

morse-1 code

Cron Driven Morse Code Time Sounder

My goal was to make a new hourly chime,something with a bit of intelligence to it than just the same tone every hour. It was actually one of those random things that runs through your head when laying in bed trying to get in a mood to sleep.

A bit of history

Typically I have been using a preexisting system sound on a Linux PC to annunciate that it is the top of the hour. This helps to keep track of how long I am on the computer, time to take a break maybe. It also makes me away of the time, in case I am in the zone with coding or whatnot and need to be aware of how time flies. Once you have this, you kind of look for it, even when you are in the room doing something other than computer work.

Up to now this is what I typically had in my crontab…

00 09-23 * * * aplay /usr/share/sounds/fLight__2.0/stereo/Message.wav

I restrict the hours down, just so the thing doesn’t wake me at night if I forget to turn off the PC.


Years ago I used Festival, the text to speech program and made it annunciate the time. This works OK as long as you are at the PC. If you are away from it a bit, you don’t always pick up what the machine generated voice is saying. Morse Code has an advantage over voice, in that the tones are easy to pick up, even when faint. I have a ham license and have experienced this first hand. So that was my line of thinking with using Morse to give me the time at the top of the hour. It would be easy to not only know that it is the top of the hour but, I can tell what hour it is easily with Morse code. Plus it seemed like a fun twist. I have even thought of putting something like this on my Pi which runs 24/7 in my office. In our living room we have a bird clock, that has different bird sounds for each hour and that has been pretty useful at times, so that got me going on this whole hourly chime adventure years ago.

I was initially inclined to make my own tones but, a brief search found Stephen C. Phillips site and his Morse Code Translator. Using it I was able to create a more code “hour” sound file from 0-23, that plays the correct sounding for every hour.

It is possible to take any sound files and label them 0-23.wav and get other types of sounds to chime at the top of the hour. Birds songs, train whistles, nature sounds, the possibilities are endless.

How it works

Using the Morse Code Translator, I was able to create a series of Morse Code translations from 0-23, in WAV file format. The WAV files get put in a directory, morse-code-audio under my home folder and the following script gets called in place of the line shown above in my crontab….



# Grab the Hours off of the date.

hour=$(date +"%H")

#Call the correct file based off of the hour
 aplay $sounddir/$hour.wav

WAV Files for the Morse Code Time Sounder

I put the 0-23.wav files online, as a tar.gz.


Compression, Signal Processing, Information Theory and Cryptography

Uncompressed the 24 WAV files in the tar file are a total of 348K , it is interesting just how compressible single frequency tones are. All of them compress down to a 2.8K tar.gz. I had to check twice, I thought I was missing a bunch of files. But it stands to reason when one thinks of a single frequency turned on and off slowly, has very little bandwidth. Provided the keying is shaped in a way so that it is not a pure sine wave modulated by a square wave, the pulses have to be shaped the corners rounded off to get the bandwidth below 100Hz. Thinking of Fourier transform, a tone left on from infinity has a bandwidth of zero. A digital signal, pulse shaped, on and off keying at 20WPM code is going to have a real narrow bandwidth, therefore highly compressible. The opposite extreme, white noise, would not be compressed down at all by gzip or any of the fancier types of compression. White noise is random, equally distributed across the spectrum, hence incompressible. But it makes for a hell of an encryption key for that very reason. The worlds of signal processing and cryptography do come together in interesting ways!


Stephen C Phillips has an excellent website and blog that covers a lot of technical topics among with the Morse Code Translator is an example. He also covers Python code and the Raspberry Pi for example.


The featured image is from this site and it is an interesting read…


avconv replaces ffmpeg for Video/Audio Conversion

Recently I wanted to convert an AVI file to an m4v on Linux Mint 17.3. I tried to use ffmpeg, it’s not there. I can’t isntall it…hmmm. So I did some digging, it has been replaced by avconv. To get avconv….

sudo apt-get install libav-tools

To use

Online, I read that there are some syntax differences between ffmpeg and avconv, so I was reluctant to just symlink pointing ffmpeg to avconv and have scripts break.

But I did a quick test taking a good guess…

avconv -i timelapse-wx-station-4-08-to-7-12-2016.avi timelapse-wx-station-4-08-to-7-12-2016.m4v

…and, it worked. Got me a much smaller file than the AVI and worked it’s magic in a short minute or two.

Video of Weather Station from April 8,2016 to July 12,2016

This was what I was testing out with the conversion. Video taken by using fswebcam to gather a still shot of my weather station once per hour on the Raspberry Pi. Once per day the shots are rolled up into an AVI video and stored in a tmp folder which is mounted in RAM. Well the RAM folder does fill up after a while and I copied the file off and saved it on my desktop. This video shows the weather changing from spring to summer.




Hourly Chime for Linux and Mac

It is easy to set up a simple CRON job to run a sound on the top of the hour by running aplay on a Linux machine. Something like this would also work on a Mac with minor changes, afplay is the default command line player for Mac, CRON works the same. For Windows, I have not tried it but task scheduler, every hour and there must be some easy command line program out there to fire off, that stuff has been around since DOS.


aplay works with wave files so you can use oggdec to convert ogg files to wav. A lot of sound theme files come in ogg or wav. aplay and mplayer come installed in Ubuntu at least by default in 14.04 LTS, which I am running. If not a simple…

 sudo apt-get install aplay


sudo apt-get install mplayer

…will get them installed.


Oggdec is part of a very small install package, takes seconds to install.

To install…

sudo apt-get install vorbis-tools

To convert OGG ausio file to a WAV audio file…

oggdec filename.ogg

Sound Themes

The sound themes are located at /usr/share/sounds . If you go there and try out the sounds you might find one that sounds good to you for an hourly chime.

Two level tree of /usr/share/sounds, using the tree command. If you don’t have it get in a few seconds using…

sudo apt-get install tree

Output of tree command show 2 levels below /usr/share/sounds

(tree /usr/share/sounds -d -L 2)

├── alsa
│   ├── Front_Center.wav
│   ├── Front_Left.wav
│   ├── Front_Right.wav
│   ├── Noise.wav
│   ├── Rear_Center.wav
│   ├── Rear_Left.wav
│   ├── Rear_Right.wav
│   ├── Side_Left.wav
│   └── Side_Right.wav
├── fLight__2.0
│   ├── Copyright
│   ├── index.theme
│   └── stereo
├── freedesktop
│   ├── index.theme
│   └── stereo
├── Fresh_and_CLean

Sound Theme Downloads

I went to a site see link below and downloaded two sound themes (fLight 2.0 and Fresh and Clean, the third one on the site was a dead link ) and tried out the sounds. I found that the Message sound in the fLight 2.0 theme was a pleasant but catchy enough sound to be heard at a distance and over any music I might be playing at the time the CRON job runs.


The CRON job that runs to do the hourly sound is..

00 09-23 * * * aplay /usr/share/sounds/fLight__2.0/stereo/Message.wav

It will produce a sound from 9AM to 11PM and uses the Message.wav which I converted from an ogg to a wav file…

I have attached the Message.wav below for your listening pleasure!



So far I have not switched my overall sound theme from the Ubuntu default, but I might try out the two themes that I have downloaded for variety.


Create Cron Jobs on a Mac

Command Line Audio Player on a Mac