Tag Archives: wav

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.

Festival

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

#!/bin/bash

sounddir=/home/erick/morse-code-audio

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

morse-code-audio.tar

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!

Resources

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.

http://blog.scphillips.com/

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

https://www.raspberrypi.org/learning/morse-code-virtual-radio/worksheet/

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

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

…or…

sudo apt-get install mplayer

…will get them installed.

oggdec

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)

/usr/share/sounds
├── 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.

http://www.ubuntuvibes.com/2010/08/3-awesome-sound-themes-for-ubuntu.html

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.

Resources

Create Cron Jobs on a Mac

Command Line Audio Player on a Mac