spkr-beep / beep

beep is a command line tool for linux that beeps the PC speaker
https://github.com/spkr-beep/beep
GNU General Public License v2.0
68 stars 11 forks source link

Create morse2beep #16

Closed jidanni closed 3 years ago

jidanni commented 3 years ago

(I'm not sure if my name or date or version belong in here. Feel free to remove them.)

ndim commented 3 years ago

In case you do not want to install perl, tr and sed can help as well:

#!/usr/bin/env sed -f
# Usage:
#   cat text-file.txt | morse | tr '\n' '\r' | sed -f morse2beep.sed | xargs beep
#
i -l0 -D0
s/ daw\r\r/-n -l300 -D700 /g
s/ dit\r\r/-n -l100 -D700 /g
s/ daw\r/-n -l300 -D300 /g
s/ dit\r/-n -l100 -D300 /g
s/ daw/-n -l300 -D100 /g
s/ dit/-n -l100 -D100 /g
jidanni commented 3 years ago

Ah, that is simply brilliant, @ndim. I have an idea. Make a subdirectory, contrib/morse and rename my version to contrib/morse/morse2beep.pl, and install your version as contrib/morse/morse2beep.sed !

ndim commented 3 years ago

Thank you for the brilliant idea of converting morse code to beep parameters.

The sed script looks deceivingly simple, but it does several runs through the whole input, so it certainly will not be very efficient for long inputs. OTOH, nobody is going to transmit gigabytes of text in morse code via beep.

@jidanni Could you address the two things I have brought up in the review? Then I can pull that, add my sed script, and merge to master.

jidanni commented 3 years ago

I would love to, if I could find it. What review?

ndim commented 3 years ago

@jidanni As far as I can tell, I can basically merge this. Any more remarks before I do that?

jidanni commented 3 years ago

OK, looks good from my tiny cell phone. Give it a rip!

ndim commented 3 years ago

Thank you very much for the code, the ideas, and the fruitful discussion!