From ffb9579a9ea03d1ed41b5086c9ca15cb2593917e Mon Sep 17 00:00:00 2001 From: Tait Hoyem <44244401+TTWNO@users.noreply.github.com> Date: Sun, 16 Jun 2019 20:19:30 +0000 Subject: [PATCH] Add script to play morse code on Linux.: --- playmorse.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 playmorse.sh diff --git a/playmorse.sh b/playmorse.sh new file mode 100755 index 0000000..fe424a8 --- /dev/null +++ b/playmorse.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# REQUIRES: play + +# TODO: write using play libraries in C. Not sure if possible, but would be nice. +# ... even if just for compatibility reasons. + +FILENAME="$1" +FILE_CONTENTS="$(cat $FILENAME)" + + + +while read -n1 character; do + if [ "$character" == "-" ]; then + play -q -n synth 0.15 sine 850 vol 0.5 + elif [ "$character" == "." ]; then + play -q -n synth 0.05 sine 850 vol 0.5 + elif [ "$chracter" == "" ]; then + sleep 0.2 + elif [ "$character" == "/" ]; then + sleep 0.5 + fi +done < <(echo -n "$FILE_CONTENTS")