Simple set of python functions to translate alphanumeric characters to morse code and back
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
morse.py
morse_sound.py
morsepy.gif

README.md

MorsePy

MorsePy Demo

Look at the HTML5/Javascript code branch for this demo here

morse.py contains a simple set of python functions to translate alphanumeric characters to morse code and back

morse_sound.py generates base 64 encoded strings of the dit and dah sounds for use in the HTML5 page.

The wave sounds are a 800Hz tone, 100ms and 300ms for dit and dah respectively, at a framerate of 4.410 Khz.

Example output for morse.py

--------------------------------------------------------------
Original: THIS IS NUMBER 1 TEST.
   Morse: - .... .. ...  .. ...  -. ..- -- -... . .-.  .----  - . ... - .-.-.-
and Back: THIS IS NUMBER 1 TEST.
Valid? Yes
--------------------------------------------------------------
--------------------------------------------------------------
Original: WHAT IS THE MEANING OF LIFE, THE UNIVERSE, AND EVERYTHING?
   Morse: .-- .... .- -  .. ...  - .... .  -- . .- -. .. -. --.  --- ..-.  .-.. .. ..-. . --..--  - .... .  ..- -. .. ...- . .-. ... . --..--  .- -. -..  . ...- . .-. -.-- - .... .. -. --. ..--..
and Back: WHAT IS THE MEANING OF LIFE, THE UNIVERSE, AND EVERYTHING?
Valid? Yes
--------------------------------------------------------------
--------------------------------------------------------------
Original: WIERD CHARS # IS !@#$%^&*()<> BLOOP 
   Morse: .-- .. . .-. -..  -.-. .... .- .-. ...    .. ...  -.-.-- .--.-. ...-..- .-... -.--. -.--.-  -... .-.. --- --- .--.  
and Back: WIERD CHARS  IS !@$&() BLOOP 
Valid? No
--------------------------------------------------------------

Dit/Dah output

Dit

UklGRpYDAABXQVZFZm10IBAAAAABAAEAOhEAAHQiAAACABAAZGF0YXIDAAAAACU6lTBz7sHAtdzCIYA/TBOg0B7FLv5cOcAxNvAPwTPbMiCzPwcV39FuxFv8hzjgMvzxacG52Zse2T++FifTycOK+qY39jPF89HBR9j+HPI/cBh51DHDufi6NgE1kPVGwt3WWxv+Px0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