Introduction
After 3 weeks of trying to setup Kubernetes + Nextcloud + static website in Minikube I decided to take a little break and focus on some Bash. The project I decided to make is as simple text to Morse [5] [4] script
Morse Beep Bash
The code is pretty easy to follow. First, I make reqular expression substitution for every letter of alphabet and numbers from 0 to 9
.
I also need some specyfic characters to escape spaces, in this case it’s character s
. For every regular expression I
need to end each Morse code character with some delimiter. I picked =
so later I can pause signal generation when condition is true
After that my enhanced Morse code is piped to fold
to end every character with new line and then again piped to xargs
which
invokes ffplay
[1] that plays sine
sound for specyfic period of time or use sleep
when break is needed
Results
I recorded simple sos sos sos
Morse code by using this script
And recorded it to .wav
file with arecord -vv -fdat morse.wav
As you can see it’s really easy to make yourself simple more code translator which will make sounds from your speaker
Morse code audio sample data extraction
In the very end of evening I decided to also play around a bit with .dat
file which can be
produced from .wav
I really wanted to see the interval in which my Morse code plays "beep" sound and for that
first I used sox
[2] program to extract data from .wav
;
Data visualization
First I started with some GNU Octave [3] code that is plotting amplitude of Morse code signal
This was really easy and as you can see clearly SOS SOS SOS
was generated properly
Second one is a bit more interesting as it shows spectrogram of sound.
I love the end result of it. I generated sine
wave with frequency of 1000Hz
and on this
diagram you can clearly see SOS
generated with 1kHz
Cool huh?
Conclusion
This was a small cool project that made just to refresh a bit from dust from kubernetes cave
As always I highly recommend to play around with Bash. It’s such a flexible scripting language. I love to use it whenever I have an oportunity
In 2 weeks I’m going back to Polish remote university mode but at least now everyday I wake up in the Netherlands
Sources
https://ffmpeg.org/ffplay.html
[1] “Ffplay Documentation.” [2] “SoX - Sound eXchange | HomePage.”https://www.gnu.org/software/octave/index
[3] “GNU Octave.”https://en.wikipedia.org/w/index.php?title=Morse_code&oldid=1012730449, Mar. 2021
[4] “Morse Code,” Wikipedia.https://www.youtube.com/watch?v=OB1Kc4s0aNE, Mar. 2017
[5] Shouldaville - Shorts, “The Importance of Morse Code Spacing.”