Quantcast
Channel: Linux Device Hacking
Viewing all articles
Browse latest Browse all 3205

old wall clock simulation (no replies)

$
0
0
My parents have an old wind-up wall clock with a gong that strikes every hour. Last year I had recorded the sound of that clock. Yesterday when we changed the time in the US I decided to simulate that on my dockstar. I thought I will share this simple shell script with the nice folks on this forum.

My Debian dockstar is connected via USB sound card to a nice set of computer speakers (built-in power save mode) that are on 24/7. I am running this script with crontab on the top of the hour.

#!/bin/bash
# d is current time in 0-12 format in my time zone to count strikes
# e is current time in 0-24 format to keep it quiet at night
# 1strike is edited sound of a short strike
# strikend is a strike with sustain and some gear sound at the end
# for the effect
# I do 1strike.mp3 (d -1) times in a loop and then strikeend.mp3 at the
# end 

d=`TZ='YOUR TIME ZONE' date +%I`
e=`TZ='YOUR TIME ZONE' date +%H`

 if [ "$e" -lt 23 ] && [ "$e" -gt 7 ]
 then
        for (( c=1; c<d; c++ ))
                do
                mpg123 -q -f 120 /home/metric/clock/1strike.mp3
                done
        mpg123 -q -f 120 /home/metric/clock/strikeend.mp3
 fi


Viewing all articles
Browse latest Browse all 3205